import { type Agent, type AgentSideConnection, type AuthenticateRequest, type AuthenticateResponse, type AvailableCommand, type CancelNotification, type ClientCapabilities, type CloseSessionRequest, type CloseSessionResponse, type DeleteSessionRequest, type DeleteSessionResponse, type ForkSessionRequest, type ForkSessionResponse, type InitializeRequest, type InitializeResponse, type ListSessionsRequest, type ListSessionsResponse, type LoadSessionRequest, type LoadSessionResponse, type NewSessionRequest, type NewSessionResponse, type PromptRequest, type PromptResponse, type ResumeSessionRequest, type ResumeSessionResponse, type SetSessionConfigOptionRequest, type SetSessionConfigOptionResponse, type SetSessionModeRequest, type SetSessionModeResponse } from "@agentclientprotocol/sdk"; import { type AcpProviderRegistration, type AcpReverseConnection, AcpSdkAdapter } from "../../sdk/acp"; import { type PromptWatchdogClock } from "../../sdk/prompt-watchdog"; import type { AcpStartupOptions } from "./startup-options"; type JsonObject = Record; /** Applies ACP's offset cursor after narrowing the broker listing to the requested cwd. */ export declare function paginateAcpSessions(listed: unknown[], cwd: string | undefined, offset: number, sessionMetadata?: ReadonlyMap): ListSessionsResponse; /** Build the ACP command palette from the shared builtins and live SDK skill state. */ export declare function acpAvailableCommandsFromSkills(query: unknown): AvailableCommand[]; export type TranscriptReplayBlock = { type: "text"; text: string; } | { type: "image"; data: string; mimeType: string; }; /** * The production transcript query exposes durable `{ body, textSummary }` * entries, not an ACP-shaped `content` array. Historical session JSONL has no * recoverable image bytes, so replay exposes that boundary rather than * pretending images were restored. */ export interface TranscriptReplayContent { blocks: TranscriptReplayBlock[]; images: { available: false; reason: "historical_transcript_images_unavailable"; }; } /** Machine-readable reason replay could not restore a transcript entry. */ export type TranscriptReplaySkipReason = "transcript_body_unavailable" | "transcript_tool_call_unavailable"; /** * Replay decides per entry. An entry whose production body is missing is not * replayable, and the caller reports that boundary instead of failing the whole * load; fabricating an empty body would replay a message that never existed. */ export type TranscriptReplayEntry = { replayable: true; content: TranscriptReplayContent; } | { replayable: false; reason: TranscriptReplaySkipReason; }; export declare function transcriptReplayContent(entry: unknown): TranscriptReplayEntry; /** * `transcript.list` answers an entry larger than one page with a body-less row * `{ id, error: { code: "item_too_large" }, continuations }`. Each continuation is a * `Q23` (`resource.body`) descriptor for one indexed string field of that entry, so * the row is a pointer to the largest message in the session rather than a broken * entry. Replay follows it instead of dropping the message. */ export interface TranscriptContinuation { query: string; resourceKind: string; resourceId: string; revision: string; itemId: string; field: string; } export declare function transcriptContinuations(entry: unknown): TranscriptContinuation[]; /** * Collect every page of `providers.list/active` (Q29, GJC >= 0.12.8) and * return the providers with usable stored credentials or credentialless * connection kinds, mirroring the TUI model picker's * `modelRegistry.getAvailable()`. The openwebui-gjc-adapter applies the same * filter to `/v1/models`. Q29 pages are byte-bounded and can span multiple * pages when custom provider ids inflate the payload, so all pages are * consumed before the provider set is built. Returns undefined only when the * session host rejects the query with `operation_not_session_owned`; any * other query failure or malformed page is thrown. */ export declare function collectActiveProviderIds(adapter: Pick): Promise | undefined>; /** * Collect the model catalog (Q10) and the active-provider set (Q29) under one * credential ordering. Assembling the first Q10 page is what finalizes host-side * credential state — expired or invalid OAuth credentials are refreshed or * disabled while that snapshot is built, and continuation pages replay the * frozen revision without further side effects — so Q29 must not start until * page 1 has resolved. Starting both together would let Q29 snapshot pre-refresh * credential state and mix catalog rows and provider availability from different * credential states. After page 1, the provider walk overlaps the remaining * catalog pages instead of adding its latency after them. */ export declare function collectModelCatalogAndActiveProviders(adapter: Pick): Promise<{ modelCatalog: unknown; activeProviders: ReadonlySet | undefined; }>; /** Maps live canonical SDK config and the selected model catalog into the ACP 1.2.1 session state surface. */ export declare function acpSessionStateFromConfig(query: unknown, modelCatalogQuery?: unknown, modelPreset?: string, activeProviders?: ReadonlySet): { configOptions: ({ id: string; name: string; category: "mode"; type: "select"; currentValue: string; options: { value: string; name: string; }[]; } | { id: "model"; name: string; category: "model"; type: "select"; currentValue: string; options: { value: string; name: string; }[] | ({ readonly value: "all"; readonly name: "All"; } | { readonly value: "one-at-a-time"; readonly name: "One at a time"; } | { readonly value: "all"; readonly name: "All"; } | { readonly value: "one-at-a-time"; readonly name: "One at a time"; } | { readonly value: "immediate"; readonly name: "Immediate"; } | { readonly value: "wait"; readonly name: "Wait"; })[]; } | { id: "thinking"; name: string; category: "thought_level"; type: "select"; currentValue: string; options: { value: string; name: string; }[] | ({ readonly value: "all"; readonly name: "All"; } | { readonly value: "one-at-a-time"; readonly name: "One at a time"; } | { readonly value: "all"; readonly name: "All"; } | { readonly value: "one-at-a-time"; readonly name: "One at a time"; } | { readonly value: "immediate"; readonly name: "Immediate"; } | { readonly value: "wait"; readonly name: "Wait"; })[]; } | { id: "steeringMode"; name: string; type: "select"; currentValue: string; options: { value: string; name: string; }[] | ({ readonly value: "all"; readonly name: "All"; } | { readonly value: "one-at-a-time"; readonly name: "One at a time"; } | { readonly value: "all"; readonly name: "All"; } | { readonly value: "one-at-a-time"; readonly name: "One at a time"; } | { readonly value: "immediate"; readonly name: "Immediate"; } | { readonly value: "wait"; readonly name: "Wait"; })[]; } | { id: "followUpMode"; name: string; type: "select"; currentValue: string; options: { value: string; name: string; }[] | ({ readonly value: "all"; readonly name: "All"; } | { readonly value: "one-at-a-time"; readonly name: "One at a time"; } | { readonly value: "all"; readonly name: "All"; } | { readonly value: "one-at-a-time"; readonly name: "One at a time"; } | { readonly value: "immediate"; readonly name: "Immediate"; } | { readonly value: "wait"; readonly name: "Wait"; })[]; } | { id: "interruptMode"; name: string; type: "select"; currentValue: string; options: { value: string; name: string; }[] | ({ readonly value: "all"; readonly name: "All"; } | { readonly value: "one-at-a-time"; readonly name: "One at a time"; } | { readonly value: "all"; readonly name: "All"; } | { readonly value: "one-at-a-time"; readonly name: "One at a time"; } | { readonly value: "immediate"; readonly name: "Immediate"; } | { readonly value: "wait"; readonly name: "Wait"; })[]; })[]; modes: { availableModes: { id: string; name: string; }[]; currentModeId: string; }; }; /** Recognize a canonical ACP skill command only when it is the complete, single text prompt. */ export declare function acpSkillInvocation(blocks: PromptRequest["prompt"]): { name: string; args: string; } | undefined; /** Convert every ACP prompt block the agent advertises without silently discarding context. */ export declare function acpPromptPayload(blocks: PromptRequest["prompt"]): { text: string; images: Array<{ data: string; mimeType: string; }>; }; /** * `AcpSdkAdapterError.code` is an internal string, but the SDK only derives a * JSON-RPC code from a `RequestError`. Everything else collapses to an opaque * `-32603 Internal error`, which hides the reason and defeats client-side * recovery (an ACP client cannot see that it must authenticate). Map the codes * that have a defined ACP/JSON-RPC counterpart onto a real `RequestError`. */ export declare function acpRequestFailure(error: unknown): unknown; /** * Registers the permission reverse channel whenever a form-less client needs * to answer selector asks. The permission mode (prompt vs allow) only gates * tool-authorization prompts via `permission_mode.set`; workflow questions * still need a channel, so form-less clients always get the permission * capability and the bus installs the permission-backed ask source on it. */ export declare function acpProviderRegistrations(capabilities: ClientCapabilities | undefined, env?: NodeJS.ProcessEnv): AcpProviderRegistration[]; export declare function createAcpReverseConnection(connection: AgentSideConnection, sessionId: string): AcpReverseConnection; /** Maps ACP permission handling to the session's canonical SDK policy. */ export declare function applyAcpPermissionMode(adapter: Pick, capabilities: ClientCapabilities | undefined, env?: NodeJS.ProcessEnv): Promise; /** Applies CLI-provided ACP startup settings through SDK controls before session exposure. */ export declare function applyAcpStartupOptions(adapter: Pick, options: AcpStartupOptions | undefined): Promise; /** * ACP is a pure SDK client. Session processes are created and resumed by the * broker, while all per-session operations use that session's authenticated SDK * endpoint. This class deliberately imports neither AgentSession nor any local * runtime host component. */ export declare class AcpAgent implements Agent { #private; constructor(connection: AgentSideConnection, options?: { agentDir?: string; startupOptions?: AcpStartupOptions; cancelSettlementGraceMs?: number; promptWatchdogClock?: PromptWatchdogClock; } | unknown); initialize(params: InitializeRequest): Promise; authenticate(params: AuthenticateRequest): Promise; newSession(params: NewSessionRequest): Promise; loadSession(params: LoadSessionRequest): Promise; resumeSession(params: ResumeSessionRequest): Promise; unstable_forkSession(params: ForkSessionRequest): Promise; listSessions(params: ListSessionsRequest): Promise; closeSession(params: CloseSessionRequest): Promise; deleteSession(params: DeleteSessionRequest): Promise; setSessionMode(params: SetSessionModeRequest): Promise; setSessionConfigOption(params: SetSessionConfigOptionRequest): Promise; prompt(params: PromptRequest): Promise; cancel(params: CancelNotification): Promise; extMethod(method: string, params: JsonObject): Promise; extNotification(_method: string, _params: JsonObject): Promise; get signal(): AbortSignal; get closed(): Promise; } export {};