import type { JsonRpcRequest } from './protocol.js'; import type { AcpSession } from './commands.js'; /** Session record held by the running server. Lives in server.ts; re-exposed * here so handler signatures can name it without re-declaring the shape. */ export interface AcpServerSession extends AcpSession { /** Controllers of the prompts still running; session/cancel aborts all. */ activePrompts: Set; currentModeId: string; titleSent: boolean; hadHistory: boolean; } /** Sessions map the server owns. */ export type SessionMap = Map; /** The transport surface handlers actually use. Mirrors `StdioTransport`'s * public methods — stub this in tests. */ export interface AcpTransport { respond(id: string | number, result: unknown): void; error(id: string | number, code: number, message: string): void; notify(method: string, params: unknown): void; } /** Everything a handler needs. Constructed once in `startAcpServer()` and * passed to every handler call. */ export interface AcpHandlerDeps { transport: AcpTransport; sessions: SessionMap; } /** * Switch the agent confirmation mode for a session (auto = no prompts, * manual = prompt before destructive tools). Per-session only — the global * `agentConfirmation` config is deliberately NOT mutated, see the comment * in the body. */ export declare function handleSetMode(msg: JsonRpcRequest, deps: AcpHandlerDeps): void; /** * Apply a session-level config change coming from the ACP client (model picker, * language dropdown, confirmation toggles, login field). Mutates the global * config (these ARE meant to persist across sessions, unlike mode) and pushes * the refreshed config-option list back to the client. */ export declare function handleSetConfigOption(msg: JsonRpcRequest, deps: AcpHandlerDeps): void; /** * Pure-ish: apply a single config-option update to the global config. * Split out from the handler so it can be tested without a transport. * * - `model` / `provider`: switch the active provider + model. * - `customBaseUrl`: point the `custom` OpenAI-compatible provider at a * self-hosted endpoint. * - `language`: response language code. * - `agentConfirm*` / `userProfile` / `autoLearnProfile`: boolean toggles, * accept `true`/`false` or the strings `"true"`/`"false"` (Zed sends strings). * - `login`: special-case `"providerId:apiKey"` — sets the provider and writes * the key to the keychain. The keychain write is async and fire-and-forget; * a persistence failure only means the key isn't durable, it's still usable * in-process via the cache. */ export declare function applyConfigOption(configId: string, value: unknown): void; /** * List saved sessions (project-scoped first, then global fallback), deduped * by name and sorted newest-first. */ export declare function handleSessionList(msg: JsonRpcRequest, deps: AcpHandlerDeps): void; /** * Remove a session: drop it from the in-memory map, tear down any MCP child * processes attached to it, then delete the on-disk session file (project dir * first, global fallback). */ export declare function handleSessionDelete(msg: JsonRpcRequest, deps: AcpHandlerDeps): void; /** * Pure shape: map the PROVIDERS table into the serialisable form ACP clients * expect (id/name/groupLabel/models/dynamicModels/…). No transport side-effect. * Exported so the handler is a one-liner and the shape can be unit-tested. */ export declare function buildProviderList(): { id: string; name: string; description: string; groupLabel: string; hint: string; requiresKey: boolean; subscribeUrl: string | undefined; models: { id: string; name: string; }[]; defaultModel: string; dynamicModels: boolean; }[]; /** session/list_providers handler — delegate to the pure builder + respond. */ export declare function handleListProviders(msg: JsonRpcRequest, deps: AcpHandlerDeps): void;