import type { McpConsent, RunContext } from "@vendoai/core"; /** The RunContext the door mints for every MCP tool call. CORE-2 (wave 5): * `mcpConsent` is core's own typed field now — this narrows it to required * (every door call carries the consent projection) instead of re-declaring * the shape structurally. */ export type McpRunContext = RunContext & { mcpConsent: McpConsent; }; /** An opaque transport/runtime handle associated with the current protocol's * session key. A stateless transport can supply this from request scope. */ export interface McpStateSession { readonly subject: string; /** Opaque approval-replay namespace. The 2025-11-25 adapter uses its MCP * session id; a stateless adapter supplies an authenticated durable scope. */ replayScope: string; /** * An OAuth session carries {@link McpRunContext} — the consent projection is * what makes host execution attributable. A TURN-credential session carries * the live turn's OWN `RunContext` verbatim instead: it has no MCP consent * because it is not an MCP client's call, it is the host's own turn reaching * its own tools through the door. */ context: RunContext; handleRequest(req: Request): Promise; close(): Promise; } export interface SessionStateRecord { sessionId: string; subject: string; clientId: string; grantFamilyId?: string; session: McpStateSession; expiresAt: number; } export interface ReplayStateOptions { /** Authenticated owner used for fail-closed revocation cleanup. */ subject: string; /** Absolute wall-clock expiry, shared with the owning context/session. */ expiresAt: number; /** Maximum fingerprints retained for one context key. */ capacity: number; } type MaybePromise = T | Promise; /** * Internal state seam for the MCP transport lifetime. * * Keys and absolute expiries make the contract implementable over a durable * store; MaybePromise keeps the default in-memory callbacks synchronous while * allowing a store-backed adapter to perform I/O. Session values are opaque: * the 2025-11-25 adapter supplies its SDK runtime, while a future stateless * adapter can supply a request-scoped runtime and durably store only replay * records and serializable context metadata. */ export interface McpDoorState { /** Session methods serve the 2025-11-25 transport runtime. Implementations * must remove replay records for the same key whenever a session is removed. */ getSession(sessionId: string): MaybePromise; setSession(record: SessionStateRecord): MaybePromise; /** Extends both the session and every replay entry scoped to its key. */ touchSession(sessionId: string, expiresAt: number): MaybePromise; deleteSession(sessionId: string): MaybePromise; /** Removes every session and replay record owned by the subject. */ deleteSessionsBySubject(subject: string): MaybePromise; /** Removes live sessions for one host subject/client grant set. */ deleteSessionsBySubjectClient(subject: string, clientId: string): MaybePromise; /** Removes live sessions descended from one local OAuth grant family. */ deleteSessionsByGrantFamily(familyId: string): MaybePromise; /** Atomically removes and returns every session whose expiry is <= now. */ sweepExpiredSessions(now: number): MaybePromise; /** Replay methods are transport-neutral: callers supply the opaque context * scope, canonical call fingerprint, and absolute expiry. */ getReplay(scope: string, key: string, now: number): MaybePromise; setReplay(scope: string, key: string, callId: string, options: ReplayStateOptions): MaybePromise; deleteReplay(scope: string, key: string): MaybePromise; } /** Today's byte-compatible process-memory implementation. */ export declare class InMemoryMcpDoorState implements McpDoorState { #private; getSession(sessionId: string): McpStateSession | null; setSession(record: SessionStateRecord): void; touchSession(sessionId: string, expiresAt: number): void; deleteSession(sessionId: string): McpStateSession | null; deleteSessionsBySubject(subject: string): McpStateSession[]; deleteSessionsBySubjectClient(subject: string, clientId: string): McpStateSession[]; deleteSessionsByGrantFamily(familyId: string): McpStateSession[]; sweepExpiredSessions(now: number): McpStateSession[]; getReplay(scope: string, key: string, now: number): string | null; setReplay(scope: string, key: string, callId: string, options: ReplayStateOptions): void; deleteReplay(scope: string, key: string): void; } export {}; //# sourceMappingURL=state.d.ts.map