You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(service-ai): share agent-alias registry across ESM/CJS builds + decouple agent catalog from it (#2190)
Live EE-rig verification of ADR-0063/0064 surfaced two coupled defects in the
AI agent catalog/alias layer:
1. GET /api/v1/ai/agents omitted `build` even though build chat worked.
2. POST /api/v1/ai/agents/metadata_assistant/chat 404'd — the legacy alias was dead.
Root cause (deeper than the suspected record-init order): `@objectstack/service-ai`
ships BOTH an ESM (`import`→index.js) and a CJS (`require`→index.cjs) build, and the
alias table was a module-level `new Map()` — so each build got its OWN copy. The
cloud AI Studio plugin is bundled as CJS and `require`s the CJS copy to register
`metadata_assistant`→`build`, while the framework agent routes load as ESM and read
the ESM copy — the alias was written to a Map nobody read.
- agent-aliases: anchor the registry (and its `data_chat`→`ask` seed) on a
`Symbol.for` key on globalThis so the ESM and CJS builds share ONE table.
- agent-runtime.listAgents: stop keying catalog membership solely on the in-memory
alias-table values. Decide membership from an INTRINSIC, persisted package
signal (`_provenance:'package'`/`_lock`, or a pre-translation `protection`
block), with the alias values kept as a fallback union. A missed alias must
never hide a real platform agent (ADR-0063 §2 still hides stray tenant agents).
- ask-agent: carry a package `protection` block (lock:'full'); translate it to the
runtime `_lock`/`_provenance` envelope at register via applyProtection so the
catalog signal is present and the built-in persona is locked against overlay edits.
Tests: globalThis-shared registry; listAgents surfaces a platform agent via the
intrinsic signal with NO alias registered, and still hides an envelope-less tenant
agent. Full service-ai suite green (409).
Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments