import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js"; import { type CapabilityRecord, type HookIntent, type McpToolName, type SessionScope } from "../sidekick-contracts/index.js"; import { type ApplyOutcome, type Delegation, type DelegationInput, type SidekickResult } from "../sidekick-contracts/index.js"; /** The MCP boundary needs status, not local-only worker state or Cloud secrets. */ export type CoordinatorDelegation = Pick & { /** Durable coordinators can prove replay across native process restarts. */ duplicate?: boolean; attempt: Pick & { result: { digest: string; } | null; }; }; export type CoordinatorPort = { delegate(input: DelegationInput): Promise; get(delegationId: string): CoordinatorDelegation | Promise; result(delegationId: string): Promise; followUp(input: { delegationId: string; operationId: string; generation: string; resultDigest: string; task: string; }): Promise; cancel(delegationId: string, generation: string): Promise; review(request: unknown, hostApproved?: boolean): Promise; }; export type CapabilityIssuer = { issue(scope: SessionScope, tools?: readonly McpToolName[], now?: Date): { token: string; record: CapabilityRecord; }; resolve(token: string): CapabilityRecord | undefined; revoke(token: string): void; }; export type SidekickMcpOptions = { scope: SessionScope; lead: TrustedLead; coordinator: CoordinatorPort; capabilities?: CapabilityIssuer; now?: () => Date; installationId?: string; }; export type TrustedLead = { scope: SessionScope; harness: "codex" | "claude_code"; model: string; }; export declare function createCapabilityIssuer(): CapabilityIssuer; export declare class SessionSidekickMcpAdapter { #private; constructor(options: SidekickMcpOptions); issueCapability(tools?: readonly McpToolName[]): string; revokeCapability(): void; capability(): CapabilityRecord | undefined; call(tool: McpToolName, args: unknown, token?: string | undefined): Promise; /** Host-only review entrypoint. Model calls intentionally cannot approve apply. */ reviewApproved(request: unknown): Promise; emitHook(kind: HookIntent["kind"]): HookIntent; /** Register tools on an SDK McpServer; host approval remains outside args. */ register(server: McpServer): void; } export declare function createHookIntent(input: { sessionId: string; kind: HookIntent["kind"]; harness: HookIntent["harness"]; installationId: string; occurredAt?: Date; }): HookIntent; /** Start the adapter on the native stdio MCP transport. */ export declare function serveSessionSidekickMcp(adapter: SessionSidekickMcpAdapter, options?: { transport?: Transport; signal?: AbortSignal; }): Promise; export type { ApplyOutcome, CapabilityRecord, Delegation, DelegationInput, McpToolName, SessionScope, SidekickResult };