import { type AgentCapabilities, type AuthMethod, type ClientCapabilities, type ContentBlock, type Implementation, type InitializeResponse } from "@agentclientprotocol/sdk"; import { type McpServerConfig } from "@automatalabs/shared-types"; import type { Backend } from "./backend.js"; /** The bare `_meta` keys whose emission is gated by Codex's custom-capability advertisement. * Each is named EXACTLY like the advertised flag that gates it, so `support[key] === true` is the * whole test. session/new carries baseInstructions/developerInstructions and session/prompt carries * outputSchema — one list covers both (a key absent from a given `_meta` is simply skipped). */ export declare const GATED_CUSTOM_META_KEYS: readonly string[]; /** The capability state a pooled connection derives from its initialize response. */ export interface NegotiatedCapabilities { /** The protocol version the agent selected (echoes the client's when supported, else the agent's * latest). Validated by isSupportedProtocolVersion before the connection is used. */ protocolVersion: number; /** The agent's full advertised capabilities — an empty object when the agent sent none (every * capability is then UNSUPPORTED per the ACP spec). */ agent: AgentCapabilities; /** The agent's self-identification, when it sent agentInfo. */ agentInfo: Implementation | undefined; /** Authentication methods advertised by the agent in initialize, defaulting to [] when absent. */ authMethods: AuthMethod[]; /** Initialize-response `_meta`, when the agent sent it. */ initializeMeta: InitializeResponse["_meta"] | undefined; /** Whether the agent advertises the `_session/steering` vendor extension through the * top-level initialize-response `_meta.steering.supported === true` contract. This is * intentionally independent of agentCapabilities._meta, which gates outgoing custom metadata. */ supportsSteering: boolean; /** Whether the agent advertises the `_session/loaded_turn` vendor extension through the * top-level initialize-response `_meta.loadedTurn.supported === true` contract: the * loaded-session founding-turn TERMINAL STATE channel (the re-attach arm's authoritative * completion evidence — see `InteractiveSession.awaitCurrentTurn`). Same strict parse and * same independence from agentCapabilities._meta as steering. */ supportsLoadedTurnTerminalState: boolean; /** Whether session/close is advertised (gates the best-effort release-time close). */ supportsClose: boolean; /** Whether session/load is advertised. The current SDK keeps this as the legacy top-level * `loadSession` flag; tolerate a future sessionCapabilities.load shape for forward compat. */ supportsLoadSession: boolean; /** Whether session/list is advertised. */ supportsListSessions: boolean; /** Whether session/delete is advertised. */ supportsDeleteSession: boolean; /** Whether `session/fork` is advertised via `sessionCapabilities.fork`. UNSTABLE in the SDK. */ supportsForkSession: boolean; /** Whether session/resume is advertised. */ supportsResumeSession: boolean; /** Whether logout is advertised under agentCapabilities.auth.logout. */ supportsLogout: boolean; /** Whether the unstable provider-configuration block is advertised. */ supportsProviders: boolean; /** The parsed backend-declared custom-capability block (the namespaced `_meta` object), or * undefined when the backend declared none or the agent did not advertise it — passthrough. */ customMetaSupport: Record | undefined; /** The backend-declared bare `_meta` keys gated by customMetaSupport; undefined when this backend * has no custom-capability contract, so custom `_meta` is never gated. */ gatedKeys: readonly string[] | undefined; } /** Parse an initialize response into the connection's derived capability state. */ export declare function negotiateCapabilities(response: InitializeResponse, customCapabilities?: Backend["customCapabilities"]): NegotiatedCapabilities; /** Human-readable lifecycle advertisement summary for strict wrapper gate errors. */ export declare function describeLifecycleAdvertisement(agent: AgentCapabilities): string; /** Human-readable auth/provider advertisement summary for strict wrapper gate errors. */ export declare function describeAuthProviderAdvertisement(agent: AgentCapabilities, authMethods?: readonly AuthMethod[]): string; /** Human-readable summary of the CLIENT-side auth advertisement this runner sends at initialize — * the symmetric counterpart to describeAuthProviderAdvertisement (the agent side). Used for * error/diagnostic text (§1.2); reads only the pinned boolean gates, never any secret. Renders * e.g. `auth.terminal=true; auth._meta.gateway=true; _meta["terminal-auth"]=true`, or `auth=none` * when nothing is advertised. */ export declare function describeClientAuthAdvertisement(auth: ClientCapabilities["auth"], meta: ClientCapabilities["_meta"]): string; /** True only when the agent selected EXACTLY PROTOCOL_VERSION. This client implements that one wire * version and adapts its behavior to no other, so any other selected version — older or newer — * means close the connection per the ACP spec's SHOULD-close rule. Per the spec the agent echoes * the requested version when it supports it, else its own latest; we do NOT accept older versions * (we cannot speak them) — the equality is the whole test. */ export declare function isSupportedProtocolVersion(version: number): boolean; /** Remove the declared custom bare `_meta` keys the connected agent did NOT advertise support for. * A no-op when the agent advertised no namespace (`support` undefined => legacy => every key * passes) or the meta is empty/undefined. Never mutates its input; collapses to undefined if * gating empties the object (so no `_meta` is sent at all). */ export declare function gateCustomMeta(meta: Record | undefined, support: Record | undefined, gatedKeys?: readonly string[]): Record | undefined; /** Adapt prompt content to the agent's PromptCapabilities. ACP baseline content (text and * resource_link) is never gated; optional blocks follow the spec's capability table: * image->promptCapabilities.image, audio->promptCapabilities.audio, and resource-> * promptCapabilities.embeddedContext. Unsupported optional blocks are represented as explicit * bracketed text notes so context is never silently lost. Returns the SAME array reference when * no block changes and never mutates the input or any surviving block. */ export declare function adaptPromptContent(blocks: ContentBlock[], agent: AgentCapabilities, backendId: string): ContentBlock[]; /** The first client-provided MCP server whose transport cannot be served, or undefined when every * server is serviceable. stdio is ALWAYS serviceable (the baseline transport); http/sse keep the * legacy leniency and gate only after any mcpCapabilities block exists. ACP transport is stricter: * both sides must be explicit because the client is the MCP server host and an unwired declaration * would otherwise spend tokens before failing at mcp/connect. */ export declare function unsupportedMcpServer(servers: McpServerConfig[] | undefined, agent: AgentCapabilities, options?: { clientCanServeAcp?: boolean; }): { name: string; transport: "http" | "sse" | "acp"; reason?: "client"; } | undefined; //# sourceMappingURL=capabilities.d.ts.map