js/ai/acp/server
js/ai/acp/server.ts
internal:ai/acp/server — stateful ACP v1 agent server orchestration.
AcpServer owns one live JSON-RPC peer at a time, active prompt
cancellation, negotiated MCP clients, and session activation. Persisted
records remain in the caller-owned store after connection shutdown.
Interfaces
interface AcpMcpServerPolicyContext {
Context passed to an MCP connection policy.
Properties
sessionId: string
Session receiving the MCP server.
cwd: string
Session working directory.
additionalDirectories: string[]
Additional workspace roots.
interface AcpAuthenticationOptions {
Authentication policy and methods exposed by the server.
Properties
methods: AcpAuthMethod[]
Authentication methods advertised at initialization.
Methods
authenticate(
methodId: string,
context: { clientInfo?: AcpImplementation; meta?: AcpMeta; signal: AbortSignal },
): boolean | void | Promise<boolean | void>
Authenticate one agent-managed method.
isAuthenticated?(context: {
clientInfo?: AcpImplementation;
signal: AbortSignal;
}): boolean | Promise<boolean>
Recheck shared credentials after client-launched terminal authentication.
logout?(context: { signal: AbortSignal }): void | Promise<void>
Clear connection authentication and application credentials.
interface AcpAgentContext {
Dynamic agent-selection and session-policy context.
Properties
sessionId: string
Active session id.
cwd: string
Session working directory.
additionalDirectories: string[]
Additional workspace roots.
modeId?: string
Current legacy mode id.
configOptions: AcpSessionConfigOption[]
Current session configuration.
client: AcpClient
Session-bound negotiated client.
interface AcpServerOptions {
Options for a complete ACP v1 agent server.
Properties
agent: Agent | ((context: AcpAgentContext) => Agent | Promise<Agent>)
Reusable agent definition or per-prompt agent factory.
name?: string
Machine-readable implementation name.
title?: string
Optional display title.
version?: string
Implementation version.
store?: AtomicStore
Shared atomic store; defaults to a fresh memoryStore().
Caller-supplied stores remain caller-owned and are not closed by the server.
sessionListPageSize?: number
Maximum sessions returned per ACP list page. Defaults to 50.
promptCapabilities?: { image?: boolean; audio?: boolean; embeddedContext?: boolean }
Rich prompt types accepted by the configured application.
contextWindowSize?: number
Context window size reported in usage updates.
authentication?: AcpAuthenticationOptions
Optional authentication policy.
modes?: AcpSessionModeState
Optional legacy session modes.
configOptions?: AcpSessionConfigOption[]
Initial session configuration options.
commands?: AcpAvailableCommand[]
Commands announced to clients for every activated session.
extensions?: Record<
string,
(
params: unknown,
context: RequestContext & {
clientInfo?: AcpImplementation;
clientCapabilities: AcpClientCapabilities;
},
) => unknown | Promise<unknown>
>
Underscore-prefixed agent extension request handlers.
capabilityMeta?: Record<string, unknown>
Opaque metadata attached to advertised agent capabilities.
Methods
onModeChange?(context: AcpAgentContext, modeId: string): void | Promise<void>
Apply application policy after a valid mode selection.
onConfigOptionChange?(
context: AcpAgentContext,
option: AcpSessionConfigOption,
): void | Promise<void>
Apply application policy after a valid configuration selection.
allowMcpServer?(
server: AcpMcpServer,
context: AcpMcpServerPolicyContext,
): boolean | Promise<boolean>
Authorize each client-supplied MCP connection descriptor.
Classes
class AcpServer {
Complete stable ACP v1 server for reusable Fino agent definitions.
Constructors
constructor(opts: AcpServerOptions)
Create a server. Each serve() call owns one isolated ACP connection.
Methods
async serve(transport: Transport): Promise<void>
Serve one bidirectional ACP connection until EOF.
async close(): Promise<void>
Close the active connection and its live resources; persisted sessions remain.
Functions
function acpServer(opts: AcpServerOptions): AcpServer
Create a complete stable ACP v1 server.