refactor(box): introduce reusable workspace session helper

This commit is contained in:
youhuanghe
2026-04-08 12:16:03 +00:00
committed by WangCham
parent 51fcf26571
commit a8eb6e6984
7 changed files with 644 additions and 258 deletions
@@ -125,6 +125,8 @@ def mcp_module():
'mcp.py',
)
mcp_path = os.path.normpath(mcp_path)
pkg_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(mcp_path))))
sys.modules['langbot.pkg'].__path__ = [pkg_root]
sys.modules['langbot.pkg.provider.tools.loaders'].__path__ = [os.path.dirname(mcp_path)]
spec = importlib.util.spec_from_file_location(mod_fqn, mcp_path)
mod = importlib.util.module_from_spec(spec)
@@ -136,6 +138,7 @@ def mcp_module():
# Cleanup
sys.modules.pop(mod_fqn, None)
sys.modules.pop('langbot.pkg.provider.tools.loaders.mcp_stdio', None)
sys.modules.pop('langbot.pkg.box.workspace', None)
for name in reversed(list(saved)):
if saved[name] is None:
sys.modules.pop(name, None)