@kya-os/mcp-i
Version:
The TypeScript MCP framework with identity features built-in
41 lines (40 loc) • 1.93 kB
TypeScript
/**
* Outbound Identity Bridge (mcp-i → @kya-os/compute interceptor)
*
* Bridges this package's AsyncLocalStorage request context into the compute
* outbound-identity interceptor so the Layer-2 delegation headers and the
* `KYA-OS-Session-Id` anchor are emitted on the compute (OpenClaw sidecar)
* path — resolving the long-standing `interceptor.ts:183-188` TODO.
*
* Why a global rendezvous (not a direct import): neither package depends on
* the other (compute must not import the SDK; the SDK must not pull in the
* Fly.io sidecar). When the compute interceptor installs it publishes a
* registrar on `Symbol.for("kya-os.outbound-identity.registry")`; this module
* reads that registrar and registers providers backed by `getContext()`. When
* compute is absent (pure-Node / Cloudflare deployments) the registrar is
* missing and this is a clean no-op — those paths inject delegation headers via
* their own fetch wrap (`outbound-delegation.ts`).
*
* Authority model follows ADR-001: the DelegationCredential VC is
* authoritative; `-Chain` / `-Granted-Scopes` are advisory hints.
*
* Related Spec: DIF MCP-I §8 — Outbound Delegation Propagation
*/
interface Logger {
debug: (msg: string, meta?: Record<string, unknown>) => void;
warn: (msg: string, meta?: Record<string, unknown>) => void;
}
/**
* Register the AsyncLocalStorage-backed delegation / session providers with the
* compute outbound-identity interceptor, if it is installed in this process.
*
* Idempotent and best-effort: safe to call from multiple init sites. Returns
* true when the registrar was found and providers were wired, false otherwise.
*/
export declare function ensureOutboundIdentityBridge(logger?: Logger): boolean;
/**
* Test-only reset of the idempotency guard. Not part of the public runtime API.
* @internal
*/
export declare function __resetOutboundIdentityBridgeForTests(): void;
export {};