Ship the bridge with the pack (moved from the agent core)
The core now keeps only the shared bridge contract (semif_agent/bridges/base.py) and the discovery registry (semif_agent/bridges/registry.py); a pack ships its own bridge under bridge/<name>.py and the registry imports it by convention from the pack's declared `bridges`. The bridge's hermetic test moves here too and runs via the agent repo's tests/test_packs.py (or standalone with conftest.py).
This commit is contained in:
1 parent
f0396edf16
commit
dcc935f6b8
6 files changed
+2143
-6
No files matched your search
+25
-6
@@ -51,12 +51,31 @@ _AGENT_ROOT = _agent_root()
|
||||
if _AGENT_ROOT is not None and str(_AGENT_ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(_AGENT_ROOT))
|
||||
|
||||
from semif_agent.bridges.outlook_client import ( # noqa: E402
|
||||
DEFAULT_TENANT,
|
||||
OutlookError,
|
||||
run_device_code_flow,
|
||||
save_token,
|
||||
)
|
||||
|
||||
def _load_outlook_client():
|
||||
"""The pack's own Graph client (`../bridge/outlook_client.py`).
|
||||
|
||||
The bridge ships with the pack, so the script loads its sibling module by
|
||||
path rather than importing a (removed) core module.
|
||||
"""
|
||||
import importlib.util
|
||||
|
||||
bridge_dir = Path(__file__).resolve().parents[1] / "bridge"
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
"outlook_client", bridge_dir / "outlook_client.py"
|
||||
)
|
||||
if spec is None or spec.loader is None:
|
||||
raise ImportError(f"cannot load {bridge_dir / 'outlook_client.py'}")
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
_outlook_client = _load_outlook_client()
|
||||
DEFAULT_TENANT = _outlook_client.DEFAULT_TENANT
|
||||
OutlookError = _outlook_client.OutlookError
|
||||
run_device_code_flow = _outlook_client.run_device_code_flow
|
||||
save_token = _outlook_client.save_token
|
||||
|
||||
DEFAULT_TOKEN_PATH = str((_AGENT_ROOT or Path.cwd()) / ".runtime" / "outlook" / "token.json")
|
||||
|
||||
|
||||
Reference in new issue
Block a user