acp

    Type-safe Agent Client Protocol (ACP) SDK for MoonBit.

    acp
    agent-client-protocol
    ai
    agent
    json-rpc
    Download zip
    Author
    Version
    0.2.1
    License
    Apache-2.0
    Last updated
    6 days ago
    Downloads
    214

    Dependencies

    #MoonBit ACP SDK

    Type-safe Agent Client Protocol (ACP) v1 SDK for MoonBit.

    Version: 0.1.3 · Protocol: ACP v1 · Target: native · License: Apache-2.0

    Implement the agent side, the client side, or both. Peers exchange newline-delimited JSON-RPC frames over stdio: every v1 type has a strict codec, endpoints are composed from immutable typed services, and a single engine-owned runtime drives requests, streamed session updates, and reverse requests (permissions, filesystem, terminals, elicitation) across real pipes.

    #Installation

    moon add colmugx/acp

    Then declare the root facade in your package's moon.pkg:

    import { "colmugx/acp" }

    #Quick Start

    #Agent

    Compose the services once, derive the endpoint and its initial state, then serve this process's real stdio. Handlers stream session/update notifications and ask permissions through the typed AgentContext; ids, correlation, and the serial writer queue stay engine-owned.

    ///|
    fn agent_endpoint() -> @acp.AgentEndpoint {
    let spec = @acp.agent_spec(
    info={
    name: "my-agent",
    title: @acp.ProtocolNullable::Omitted,
    version: "0.1.0",
    meta: @acp.ProtocolNullable::Omitted,
    },
    sessions=@acp.agent_session_service(new_session~, prompt~, cancel~),
    support=@acp.agent_support(),
    ).unwrap()
    @acp.agent_endpoint_from_spec(spec)
    }

    ///|
    fn agent_initial_state(endpoint : @acp.AgentEndpoint) -> @acp.AgentAdapterState {
    let config : @acp.AgentProtocolConfig = {
    agent_capabilities: @acp.ProtocolNullable::Value(endpoint.capabilities()),
    auth_methods: endpoint.auth_methods(),
    agent_info: @acp.ProtocolNullable::Omitted,
    }
    @acp.agent_adapter_state_new(protocol=@acp.agent_protocol_state_new(config~))
    }

    ///|
    async fn new_session(
    _context : @acp.AgentContext,
    _params : @acp.NewSessionParams,
    ) -> @acp.NewSessionResult {
    {
    session_id: "session-1",
    modes: @acp.ProtocolNullable::Omitted,
    config_options: @acp.ProtocolNullable::Omitted,
    meta: @acp.ProtocolNullable::Omitted,
    }
    }

    ///|
    async fn prompt(
    context : @acp.AgentContext,
    _params : @acp.PromptParams,
    ) -> @acp.PromptResult {
    context.session_update({
    session_id: "session-1",
    update: @acp.SessionUpdate::AgentMessageChunk({
    content: @acp.ContentBlock::Text({
    annotations: @acp.ProtocolNullable::Omitted,
    text: "Working on it...",
    meta: @acp.ProtocolNullable::Omitted,
    }),
    message_id: @acp.ProtocolNullable::Value("message-1"),
    meta: @acp.ProtocolNullable::Omitted,
    }),
    meta: @acp.ProtocolNullable::Omitted,
    })
    let permission = context.request_permission(permission_request())
    let _selected = match permission.outcome {
    @acp.RequestPermissionOutcome::Selected(outcome) => outcome.option_id
    @acp.RequestPermissionOutcome::Cancelled => "cancelled"
    }
    {
    stop_reason: @acp.StopReason::EndTurn,
    meta: @acp.ProtocolNullable::Omitted,
    }
    }

    ///|
    async fn cancel(
    _context : @acp.AgentContext,
    _params : @acp.CancelParams,
    ) -> Unit {
    ()
    }

    ///|
    async fn main {
    let endpoint = agent_endpoint()
    @acp.agent_serve_stdio_with_outbound(
    endpoint~,
    context_factory=channel => @acp.agent_context_over_channel(channel~),
    initial_state=agent_initial_state(endpoint),
    )
    }

    This example mirrors the compiling fixture tests/interop/agent-fixture/main.mbt. permission_request() is elided above: build the RequestPermissionRequest from the session id, the tracked tool call, and one PermissionOption per choice — see interop_fixture_permission_request in the same file.

    The loop ends at stdin EOF. Stdout carries only ACP frames. Advertise authentication with auth=@acp.agent_auth_service(methods=~, authenticate=~). When handlers never issue reverse requests or stream updates, agent_serve_stdio(endpoint~, context~, initial_state~) takes a pre-built AgentContext instead of the channel factory.

    #Client

    Spawn any ACP v1 agent binary as a child process, drive it with typed forward requests, and consume its session updates and permission requests as typed values. This example mirrors the compiling end-to-end proof tests/interop/interop_test.mbt.

    The client side needs the async and JSON dependencies alongside the facade:

    import { "colmugx/acp" "colmugx/reader" "moonbitlang/async" "moonbitlang/async/aqueue" @aqueue "moonbitlang/core/json" @json }

    ///|
    fn client_endpoint(
    updates : Array[@acp.SessionUpdateParams],
    ) -> @acp.ClientEndpoint {
    let spec = @acp.client_spec(
    info={
    name: "my-client",
    title: @acp.ProtocolNullable::Omitted,
    version: "0.1.0",
    meta: @acp.ProtocolNullable::Omitted,
    },
    session=@acp.client_session_service(
    session_update=async fn(params : @acp.SessionUpdateParams) {
    updates.push(params) // typed update, in wire order
    },
    request_permission=async fn(
    request : @acp.RequestPermissionRequest,
    ) -> @acp.RequestPermissionResponse {
    {
    outcome: @acp.RequestPermissionOutcome::Selected({
    option_id: request.options[0].option_id,
    meta: @acp.ProtocolNullable::Omitted,
    }),
    meta: @acp.ProtocolNullable::Omitted,
    }
    },
    ),
    ).unwrap()
    @reader.Reader::run(@acp.client_program(@reader.Reader::pure(spec)), ()).unwrap()
    }

    ///|
    async fn main {
    let updates : Array[@acp.SessionUpdateParams] = []
    let endpoint = client_endpoint(updates)
    let connections : @aqueue.Queue[@acp.ClientConnection] = Queue(kind=Unbounded)
    @async.with_task_group(group => {
    let driver = group.spawn(() => {
    let connection = connections.get()
    connection.initialize({
    protocol_version: 1,
    client_capabilities: @acp.ProtocolNullable::Omitted,
    client_info: @acp.ProtocolNullable::Omitted,
    meta: @acp.ProtocolNullable::Omitted,
    })
    let session = connection.new_session({
    cwd: "/",
    additional_directories: @acp.ProtocolNullable::Omitted,
    mcp_servers: [],
    meta: @acp.ProtocolNullable::Omitted,
    })
    let result = connection.prompt({
    session_id: session.session_id,
    prompt: [],
    meta: @acp.ProtocolNullable::Omitted,
    })
    ignore(result) // result.stop_reason / result.meta carry the typed outcome
    })
    @acp.client_connect_process(
    endpoint_factory=channel => {
    let _ = connections.try_put(
    @acp.client_connection_over_channel(channel~),
    ) catch {
    _ => false
    }
    endpoint
    },
    initial_state=@acp.client_adapter_state_new(
    protocol=@acp.client_protocol_state_ready(
    capabilities=@acp.ProtocolNullable::Value(endpoint.capabilities()),
    ),
    ),
    handlers={
    request: _ => {
    @acp.RuntimeHandlerResult::HandlerSuccess(@json.Json::null())
    },
    notification: _ => (),
    response: _ => (),
    outbound_failure: None,
    },
    command="path/to/agent-binary",
    )
    driver.wait()
    })
    // Fold the recorded updates with the pure consumer fold: chunks sharing
    // one messageId aggregate into one message and tool-call updates patch
    // the tracked call (used end to end in tests/interop/interop_test.mbt).
    let folded = @acp.session_update_fold(known_modes=[])
    println("messages: \{folded.agent_messages.length()}")
    }

    Connection scope equals child scope: the child is spawned and reaped inside the client_connect_process call. Pass spawned=ports => ... to capture ports.child_stdin; closing it sends the ACP stdio shutdown signal (EOF) to the child, which is how a live interactive session ends.

    #Capabilities by Service Presence

    There is no builder, no registration phase, and no manually maintained capability map. You compose immutable service values once, and each endpoint derives its capabilities from which services are present:

    • AgentEndpoint::capabilities() comes from the handlers in agent_session_service, the flags in agent_support(), and agent_auth_service when supplied.
    • ClientEndpoint::capabilities() comes from client_session_service plus whichever of client_file_system_service, client_terminal_service, and client_elicitation_service you passed to client_spec.

    Omit a service and its capability is simply not advertised; call an operation you did not wire and the endpoint raises UnavailableOperation instead of failing silently.

    #API Map

    ConcernFacade exports
    JSON-RPC envelope & framingJsonRpcRequest, JsonRpcMessage, jsonrpc_encode, jsonrpc_decode, framing_feed, framing_finish
    ACP v1 models & codecstyped *_from_json / *_to_json per model, decode_agent_request, decode_client_request, acp_v1_method_manifest
    Agent compositionagent_spec, agent_session_service, agent_support, agent_auth_service, agent_endpoint_from_spec, AgentContext
    Client compositionclient_spec, client_session_service, client_file_system_service, client_terminal_service, client_elicitation_service, client_program
    Connections & outboundClientConnection, client_connection_over_channel, agent_context_over_channel
    Runnersagent_serve_stdio(_with_outbound), client_connect_process, agent_runtime_run, client_runtime_run, connection_runtime_run_owner(_with_outbound)
    Initial state & foldagent_protocol_state_new, agent_adapter_state_new, client_protocol_state_new, client_protocol_state_ready, client_adapter_state_new, session_update_fold
    Ports & traceruntime_stdio_ports, runtime_process_ports, RuntimeHandlerPort, runtime_default_options, runtime_stderr_trace
    ErrorsHandlerError, AgentCompositionError, ClientCompositionError, AgentContextError, ClientConnectionError, RuntimeError

    #Experimental: ACP v2

    colmugx/acp/experimental implements the ACP v2 Draft stable baseline against the pinned v2 schema (see spec/LOCK.md). It is an opt-in import — the v1 facade above is unchanged — with v2-only version negotiation (a v1 peer is rejected, no downgrade). Draft quality: breaking changes may occur at any time.

    #Trace and Diagnostics

    Stdout carries only newline-delimited ACP JSON-RPC frames. Diagnostics are sanitized single-line traces — direction, phase, request id, method, and error kind only, never payloads — written to stderr by default; every runner accepts a trace~ sink so you can capture them yourself.

    #License

    Apache-2.0

    AcpV1Method

    The fixed stable v1 method manifest plus the unstable overlay subset.

    AcpV1MethodDirection

    The fixed stable v1 method manifest plus the unstable overlay subset.

    AcpV1MethodKind

    The fixed stable v1 method manifest plus the unstable overlay subset.

    AgentAdapterState

    Agent composition, endpoint, and outbound context APIs together with the initial adapter-state constructor the facade runners require as initial_state. Adapter admission, completion, and invocation internals intentionally remain in the agent package.

    AgentAuthCapabilities

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    AgentAuthService

    Agent composition, endpoint, and outbound context APIs together with the initial adapter-state constructor the facade runners require as initial_state. Adapter admission, completion, and invocation internals intentionally remain in the agent package.

    AgentCapabilities

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    AgentCompositionError

    Canonical composition and handler failures.

    AgentContext

    Agent composition, endpoint, and outbound context APIs together with the initial adapter-state constructor the facade runners require as initial_state. Adapter admission, completion, and invocation internals intentionally remain in the agent package.

    AgentContextError

    Agent composition, endpoint, and outbound context APIs together with the initial adapter-state constructor the facade runners require as initial_state. Adapter admission, completion, and invocation internals intentionally remain in the agent package.

    AgentContextNotificationBroker

    The notification-side composition seam. Notifications have no response value, so success is represented only by Unit.

    AgentContextRequestBroker

    The request-side composition seam. It is a one-shot broker, not a queue or a mutable registry; connection state remains owned by the runtime.

    AgentEndpoint

    Agent composition, endpoint, and outbound context APIs together with the initial adapter-state constructor the facade runners require as initial_state. Adapter admission, completion, and invocation internals intentionally remain in the agent package.

    AgentLoadSessionHandler

    Typed async handler signatures for optional session operations.

    AgentMcpCapabilities

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    AgentMessageError

    Typed method surfaces for both protocol directions.

    AgentNewSessionHandler

    Typed async handler signatures for the required session operations.

    AgentNotification

    Typed method surfaces for both protocol directions.

    AgentOutboundReply

    Agent composition, endpoint, and outbound context APIs together with the initial adapter-state constructor the facade runners require as initial_state. Adapter admission, completion, and invocation internals intentionally remain in the agent package.

    AgentProgram

    The Reader program produced by the Agent composition root.

    AgentPromptCapabilities

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    AgentProtocolConfig

    Agent-side protocol handshake state. The config value and the fresh-state constructor are the facade seam for building the initial_state value the agent runners accept. Reducer events, commands, and steps intentionally remain in the agent protocol package.

    AgentProtocolState

    Agent-side protocol handshake state. The config value and the fresh-state constructor are the facade seam for building the initial_state value the agent runners accept. Reducer events, commands, and steps intentionally remain in the agent protocol package.

    AgentRequest

    Typed method surfaces for both protocol directions.

    AgentSessionCapabilities

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    AgentSessionService

    Agent composition, endpoint, and outbound context APIs together with the initial adapter-state constructor the facade runners require as initial_state. Adapter admission, completion, and invocation internals intentionally remain in the agent package.

    AgentSpec

    Agent composition, endpoint, and outbound context APIs together with the initial adapter-state constructor the facade runners require as initial_state. Adapter admission, completion, and invocation internals intentionally remain in the agent package.

    AgentSupport

    Agent composition, endpoint, and outbound context APIs together with the initial adapter-state constructor the facade runners require as initial_state. Adapter admission, completion, and invocation internals intentionally remain in the agent package.

    Annotations

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    AudioContent

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    AuthMethod

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    AuthenticateParams

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    AuthenticateResult

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    AvailableCommand

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    AvailableCommandInput

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    AvailableCommandsUpdate

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    BlobResourceContents

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    CancelParams

    Session lifecycle, mode, configuration, and prompt wire data.

    CapabilityMarker

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ClientAdapterState

    Client composition, endpoint, and typed connection APIs together with the initial adapter-state constructor the facade runners require as initial_state. Adapter admission, completion, and invocation internals intentionally remain in the client package.

    ClientAuthCapabilities

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ClientCapabilities

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ClientCompositionError

    Canonical composition and handler failures.

    ClientConfigOptionCapabilities

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ClientConnection

    Client composition, endpoint, and typed connection APIs together with the initial adapter-state constructor the facade runners require as initial_state. Adapter admission, completion, and invocation internals intentionally remain in the client package.

    ClientConnectionError

    Client composition, endpoint, and typed connection APIs together with the initial adapter-state constructor the facade runners require as initial_state. Adapter admission, completion, and invocation internals intentionally remain in the client package.

    ClientElicitationCapabilities

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ClientElicitationCompleteHandler

    type ClientElicitationCompleteHandler = async (
    ElicitationCompleteParams
    ) -> Unit

    ClientElicitationFormHandler

    Typed elicitation callbacks. Form and URL requests carry their mode-specific payloads; completion is a separate notification observer.

    ClientElicitationService

    Client composition, endpoint, and typed connection APIs together with the initial adapter-state constructor the facade runners require as initial_state. Adapter admission, completion, and invocation internals intentionally remain in the client package.

    ClientEndpoint

    Client composition, endpoint, and typed connection APIs together with the initial adapter-state constructor the facade runners require as initial_state. Adapter admission, completion, and invocation internals intentionally remain in the client package.

    ClientFileSystemCapabilities

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ClientFileSystemService

    Client composition, endpoint, and typed connection APIs together with the initial adapter-state constructor the facade runners require as initial_state. Adapter admission, completion, and invocation internals intentionally remain in the client package.

    ClientMessageError

    Errors raised while mapping a method and params value to the Client-side closed unions above.

    ClientNotification

    Stable v1 notifications delivered to a Client, including the bidirectional JSON-RPC cancellation notification.

    ClientNotificationBroker

    A one-shot typed notification transport. Notifications have no reply, and this facade deliberately keeps this port synchronous: a runtime may accept the immutable notification intent into a bounded queue (or fail fast); Ok does not claim that transport I/O has completed.

    ClientProgram

    A pure Reader composition program for one caller-owned environment.

    ClientProtocolState

    Client-side protocol readiness state. The awaiting-ready and ready constructors are the facade seam for building the initial_state value the client runners accept. Reducer events, commands, and steps intentionally remain in the client protocol package.

    ClientReadTextFileHandler

    Typed filesystem callbacks. Read and write remain independent services so each capability can be derived without a manually supplied flag.

    ClientReply

    Client composition, endpoint, and typed connection APIs together with the initial adapter-state constructor the facade runners require as initial_state. Adapter admission, completion, and invocation internals intentionally remain in the client package.

    ClientRequest

    The complete stable v1 request surface delivered to a Client.

    Every variant contains a protocol-validated payload. The closed union prevents Agent-to-Client dispatch from falling through to an untyped JSON handler.

    ClientRequestBroker

    A one-shot typed request transport. It owns no request identifiers or connection state; those remain with the runtime that implements it.

    ClientRequestPermissionHandler

    A typed handler for Agent permission requests received by the Client.

    ClientSessionCapabilities

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ClientSessionService

    Client composition, endpoint, and typed connection APIs together with the initial adapter-state constructor the facade runners require as initial_state. Adapter admission, completion, and invocation internals intentionally remain in the client package.

    ClientSessionUpdateHandler

    type ClientSessionUpdateHandler = async (
    SessionUpdateParams
    ) -> Unit

    A typed observer for Agent session/update notifications received by the Client.

    ClientSpec

    Client composition, endpoint, and typed connection APIs together with the initial adapter-state constructor the facade runners require as initial_state. Adapter admission, completion, and invocation internals intentionally remain in the client package.

    ClientTerminalCreateHandler

    Typed terminal callbacks. Terminal support is all-or-nothing at the service boundary, matching the five-operation ACP surface.

    ClientTerminalService

    Client composition, endpoint, and typed connection APIs together with the initial adapter-state constructor the facade runners require as initial_state. Adapter admission, completion, and invocation internals intentionally remain in the client package.

    CloseSessionParams

    Session lifecycle, mode, configuration, and prompt wire data.

    CloseSessionResult

    Session lifecycle, mode, configuration, and prompt wire data.

    ConfigOptionUpdate

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    Content

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ContentBlock

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ContentChunk

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    Cost

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    CurrentModeUpdate

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    DeleteSessionParams

    Session lifecycle, mode, configuration, and prompt wire data.

    DeleteSessionResult

    Session lifecycle, mode, configuration, and prompt wire data.

    Diff

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ElicitationAction

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ElicitationCompleteParams

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ElicitationCreateParams

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ElicitationCreateResult

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ElicitationFormParams

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ElicitationId

    type ElicitationId = String

    Stable wire identifier for a URL elicitation.

    ElicitationScope

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ElicitationUrlParams

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    EmbeddedResource

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    EmbeddedResourceResource

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ForkSessionParams

    Session lifecycle, mode, configuration, and prompt wire data.

    ForkSessionResult

    Session lifecycle, mode, configuration, and prompt wire data.

    FramingError

    Newline framing is stable; the stdio transport adapter is intentionally not exported until the native process lifecycle is complete.

    FramingState

    Newline framing is stable; the stdio transport adapter is intentionally not exported until the native process lifecycle is complete.

    FramingStep

    Newline framing is stable; the stdio transport adapter is intentionally not exported until the native process lifecycle is complete.

    HandlerError

    Canonical composition and handler failures.

    ImageContent

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    Implementation

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    InitializeParams

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    InitializeResult

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    JsonRpcCodecError

    Stable JSON-RPC envelope and error surface.

    JsonRpcError

    Stable JSON-RPC envelope and error surface.

    JsonRpcErrorCode

    Stable JSON-RPC envelope and error surface.

    JsonRpcFailure

    Stable JSON-RPC envelope and error surface.

    JsonRpcId

    Stable JSON-RPC envelope and error surface.

    JsonRpcMessage

    Stable JSON-RPC envelope and error surface.

    JsonRpcNotification

    Stable JSON-RPC envelope and error surface.

    JsonRpcRequest

    Stable JSON-RPC envelope and error surface.

    JsonRpcResponse

    Stable JSON-RPC envelope and error surface.

    JsonRpcSuccess

    Stable JSON-RPC envelope and error surface.

    ListSessionsParams

    Session lifecycle, mode, configuration, and prompt wire data.

    ListSessionsResult

    Session lifecycle, mode, configuration, and prompt wire data.

    LoadSessionParams

    Session lifecycle, mode, configuration, and prompt wire data.

    LoadSessionResult

    Session lifecycle, mode, configuration, and prompt wire data.

    LogoutParams

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    LogoutResult

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    McpEnvVariable

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    McpHttpHeader

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    McpServer

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    McpServerHttp

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    McpServerSse

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    McpServerStdio

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    MessageId

    type MessageId = String

    NewSessionParams

    Session lifecycle, mode, configuration, and prompt wire data.

    NewSessionResult

    Session lifecycle, mode, configuration, and prompt wire data.

    PermissionOption

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    PermissionOptionId

    type PermissionOptionId = String

    PermissionOptionKind

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    Plan

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    PlanEntry

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    PlanEntryPriority

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    PlanEntryStatus

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    PromptParams

    Session lifecycle, mode, configuration, and prompt wire data.

    PromptResult

    Session lifecycle, mode, configuration, and prompt wire data.

    ProtocolDecodeError

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ProtocolNullable

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ReadTextFileParams

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ReadTextFileResult

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    RequestId

    Stable JSON-RPC envelope and error surface.

    RequestPermissionOutcome

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    RequestPermissionRequest

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    RequestPermissionResponse

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ResponseId

    using @colmugx/acp/jsonrpc { type JsonRpcId as ResponseId }

    The conventional name for a JSON-RPC response identifier.

    ResumeSessionParams

    Session lifecycle, mode, configuration, and prompt wire data.

    ResumeSessionResult

    Session lifecycle, mode, configuration, and prompt wire data.

    Role

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    RuntimeError

    Native runtime ports and bounded-runtime configuration. The runtime implementation itself remains below this facade; the two real I/O port constructors (runtime_stdio_ports for serving this process's stdio, runtime_process_ports for driving a spawned agent subprocess) and the default stderr trace sink are the composition-root seams. The RuntimeProcessPorts fields expose the underlying moonbitlang/async process handles, so facade consumers of those fields depend on that package themselves.

    RuntimeHandlerPort

    Native runtime ports and bounded-runtime configuration. The runtime implementation itself remains below this facade; the two real I/O port constructors (runtime_stdio_ports for serving this process's stdio, runtime_process_ports for driving a spawned agent subprocess) and the default stderr trace sink are the composition-root seams. The RuntimeProcessPorts fields expose the underlying moonbitlang/async process handles, so facade consumers of those fields depend on that package themselves.

    RuntimeHandlerResult

    Native runtime ports and bounded-runtime configuration. The runtime implementation itself remains below this facade; the two real I/O port constructors (runtime_stdio_ports for serving this process's stdio, runtime_process_ports for driving a spawned agent subprocess) and the default stderr trace sink are the composition-root seams. The RuntimeProcessPorts fields expose the underlying moonbitlang/async process handles, so facade consumers of those fields depend on that package themselves.

    RuntimeOptions

    Native runtime ports and bounded-runtime configuration. The runtime implementation itself remains below this facade; the two real I/O port constructors (runtime_stdio_ports for serving this process's stdio, runtime_process_ports for driving a spawned agent subprocess) and the default stderr trace sink are the composition-root seams. The RuntimeProcessPorts fields expose the underlying moonbitlang/async process handles, so facade consumers of those fields depend on that package themselves.

    RuntimeOutboundChannel

    Owner-loop runner seam. The public runners are the only connection loop entry points exposed by the stable facade; both drive the same single reader/writer/reducer engine. The owner state machine itself (RuntimeOwner values and its admit/execute/spawn/cancel/close/complete transitions) is engine-internal and stays unexported; only the runner functions, the outbound channel, the owner port, and the types a port implementor must name are re-exported here. Reducer steps and the legacy handler runner remain package-internal.

    RuntimeOwnerCommand

    Owner-loop runner seam. The public runners are the only connection loop entry points exposed by the stable facade; both drive the same single reader/writer/reducer engine. The owner state machine itself (RuntimeOwner values and its admit/execute/spawn/cancel/close/complete transitions) is engine-internal and stays unexported; only the runner functions, the outbound channel, the owner port, and the types a port implementor must name are re-exported here. Reducer steps and the legacy handler runner remain package-internal.

    RuntimeOwnerEffect

    Owner-loop runner seam. The public runners are the only connection loop entry points exposed by the stable facade; both drive the same single reader/writer/reducer engine. The owner state machine itself (RuntimeOwner values and its admit/execute/spawn/cancel/close/complete transitions) is engine-internal and stays unexported; only the runner functions, the outbound channel, the owner port, and the types a port implementor must name are re-exported here. Reducer steps and the legacy handler runner remain package-internal.

    RuntimeOwnerLocalPlan

    Owner-loop runner seam. The public runners are the only connection loop entry points exposed by the stable facade; both drive the same single reader/writer/reducer engine. The owner state machine itself (RuntimeOwner values and its admit/execute/spawn/cancel/close/complete transitions) is engine-internal and stays unexported; only the runner functions, the outbound channel, the owner port, and the types a port implementor must name are re-exported here. Reducer steps and the legacy handler runner remain package-internal.

    RuntimeOwnerNotificationAdmission

    Owner-loop runner seam. The public runners are the only connection loop entry points exposed by the stable facade; both drive the same single reader/writer/reducer engine. The owner state machine itself (RuntimeOwner values and its admit/execute/spawn/cancel/close/complete transitions) is engine-internal and stays unexported; only the runner functions, the outbound channel, the owner port, and the types a port implementor must name are re-exported here. Reducer steps and the legacy handler runner remain package-internal.

    RuntimeOwnerNotificationCompletion

    Owner-loop runner seam. The public runners are the only connection loop entry points exposed by the stable facade; both drive the same single reader/writer/reducer engine. The owner state machine itself (RuntimeOwner values and its admit/execute/spawn/cancel/close/complete transitions) is engine-internal and stays unexported; only the runner functions, the outbound channel, the owner port, and the types a port implementor must name are re-exported here. Reducer steps and the legacy handler runner remain package-internal.

    RuntimeOwnerPort

    Owner-loop runner seam. The public runners are the only connection loop entry points exposed by the stable facade; both drive the same single reader/writer/reducer engine. The owner state machine itself (RuntimeOwner values and its admit/execute/spawn/cancel/close/complete transitions) is engine-internal and stays unexported; only the runner functions, the outbound channel, the owner port, and the types a port implementor must name are re-exported here. Reducer steps and the legacy handler runner remain package-internal.

    RuntimeOwnerRequestAdmission

    Owner-loop runner seam. The public runners are the only connection loop entry points exposed by the stable facade; both drive the same single reader/writer/reducer engine. The owner state machine itself (RuntimeOwner values and its admit/execute/spawn/cancel/close/complete transitions) is engine-internal and stays unexported; only the runner functions, the outbound channel, the owner port, and the types a port implementor must name are re-exported here. Reducer steps and the legacy handler runner remain package-internal.

    RuntimeOwnerRequestCompletion

    Owner-loop runner seam. The public runners are the only connection loop entry points exposed by the stable facade; both drive the same single reader/writer/reducer engine. The owner state machine itself (RuntimeOwner values and its admit/execute/spawn/cancel/close/complete transitions) is engine-internal and stays unexported; only the runner functions, the outbound channel, the owner port, and the types a port implementor must name are re-exported here. Reducer steps and the legacy handler runner remain package-internal.

    RuntimeOwnerTask

    Owner-loop runner seam. The public runners are the only connection loop entry points exposed by the stable facade; both drive the same single reader/writer/reducer engine. The owner state machine itself (RuntimeOwner values and its admit/execute/spawn/cancel/close/complete transitions) is engine-internal and stays unexported; only the runner functions, the outbound channel, the owner port, and the types a port implementor must name are re-exported here. Reducer steps and the legacy handler runner remain package-internal.

    RuntimePorts

    Native runtime ports and bounded-runtime configuration. The runtime implementation itself remains below this facade; the two real I/O port constructors (runtime_stdio_ports for serving this process's stdio, runtime_process_ports for driving a spawned agent subprocess) and the default stderr trace sink are the composition-root seams. The RuntimeProcessPorts fields expose the underlying moonbitlang/async process handles, so facade consumers of those fields depend on that package themselves.

    RuntimeProcessPorts

    Native runtime ports and bounded-runtime configuration. The runtime implementation itself remains below this facade; the two real I/O port constructors (runtime_stdio_ports for serving this process's stdio, runtime_process_ports for driving a spawned agent subprocess) and the default stderr trace sink are the composition-root seams. The RuntimeProcessPorts fields expose the underlying moonbitlang/async process handles, so facade consumers of those fields depend on that package themselves.

    RuntimeReaderPort

    Native runtime ports and bounded-runtime configuration. The runtime implementation itself remains below this facade; the two real I/O port constructors (runtime_stdio_ports for serving this process's stdio, runtime_process_ports for driving a spawned agent subprocess) and the default stderr trace sink are the composition-root seams. The RuntimeProcessPorts fields expose the underlying moonbitlang/async process handles, so facade consumers of those fields depend on that package themselves.

    RuntimeTraceEvent

    Native runtime ports and bounded-runtime configuration. The runtime implementation itself remains below this facade; the two real I/O port constructors (runtime_stdio_ports for serving this process's stdio, runtime_process_ports for driving a spawned agent subprocess) and the default stderr trace sink are the composition-root seams. The RuntimeProcessPorts fields expose the underlying moonbitlang/async process handles, so facade consumers of those fields depend on that package themselves.

    RuntimeWriterPort

    Native runtime ports and bounded-runtime configuration. The runtime implementation itself remains below this facade; the two real I/O port constructors (runtime_stdio_ports for serving this process's stdio, runtime_process_ports for driving a spawned agent subprocess) and the default stderr trace sink are the composition-root seams. The RuntimeProcessPorts fields expose the underlying moonbitlang/async process handles, so facade consumers of those fields depend on that package themselves.

    SelectedPermissionOutcome

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    SessionConfigBoolean

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    SessionConfigGroupId

    type SessionConfigGroupId = String

    SessionConfigId

    type SessionConfigId = String

    SessionConfigOption

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    SessionConfigOptionCategory

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    SessionConfigOptionKind

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    SessionConfigSelect

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    SessionConfigSelectGroup

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    SessionConfigSelectOption

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    SessionConfigSelectOptions

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    SessionConfigValue

    Session lifecycle, mode, configuration, and prompt wire data.

    SessionConfigValueId

    type SessionConfigValueId = String

    SessionId

    type SessionId = String

    Stable ACP identifiers are strings on the wire.

    SessionInfo

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    SessionInfoUpdate

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    SessionMode

    Session lifecycle, mode, configuration, and prompt wire data.

    SessionModeId

    type SessionModeId = String

    SessionModeState

    Session lifecycle, mode, configuration, and prompt wire data.

    SessionUpdate

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    SessionUpdateFold

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    SessionUpdateFoldError

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    SessionUpdateMessage

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    SessionUpdateParams

    Session lifecycle, mode, configuration, and prompt wire data.

    SetSessionConfigOptionParams

    Session lifecycle, mode, configuration, and prompt wire data.

    SetSessionConfigOptionResult

    Session lifecycle, mode, configuration, and prompt wire data.

    SetSessionModeParams

    Session lifecycle, mode, configuration, and prompt wire data.

    SetSessionModeResult

    Session lifecycle, mode, configuration, and prompt wire data.

    StopReason

    Session lifecycle, mode, configuration, and prompt wire data.

    Terminal

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    TerminalCreateParams

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    TerminalCreateResult

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    TerminalEnvVariable

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    TerminalExitStatus

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    TerminalId

    type TerminalId = String

    TerminalKillParams

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    TerminalKillResult

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    TerminalOutputParams

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    TerminalOutputResult

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    TerminalReleaseParams

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    TerminalReleaseResult

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    TerminalWaitForExitParams

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    TerminalWaitForExitResult

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    TextContent

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    TextResourceContents

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ToolCall

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ToolCallContent

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ToolCallId

    type ToolCallId = String

    ToolCallLocation

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ToolCallStatus

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ToolCallUpdate

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    ToolKind

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    UnstructuredCommandInput

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    UsageUpdate

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    WriteTextFileParams

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    WriteTextFileResult

    Stable ACP v1 wire data, its typed codecs, and the pure session-update consumer fold. Low-level map/path helpers from the protocol implementation remain package-local to the protocol package; callers use the domain codecs and the fold below.

    JSON_RPC_VERSION

    let JSON_RPC_VERSION : String

    The JSON-RPC protocol version implemented by this package.

    acp_v1_method_manifest

    fn acp_v1_method_manifest() -> Array[
    AcpV1Method
    ]

    Return a fresh, exact manifest for the stable ACP v1 method surface.

    A fresh array on every call keeps the public value free of shared mutable state. This list follows the fixed v1 table in the implementation plan; v2 and unstable overlays are deliberately absent.

    acp_v1_unstable_method_manifest

    fn acp_v1_unstable_method_manifest() -> Array[
    AcpV1Method
    ]

    Return a fresh manifest for the v1 unstable-overlay method surface this facade implements. Upstream unstable (RFD session-fork, Draft).

    This is a deliberate subset of the pinned v1 unstable overlay (spec/schema/v1/meta.unstable.json, vendored): only session/fork is implemented. Unstable overlay methods deliberately stay out of the stable manifest above and out of its exact-set drift gate against the pinned stable meta.json/schema.json bytes.

    agent_auth_capabilities_from_json

    Decode Agent authentication capabilities.

    agent_auth_capabilities_to_json

    Encode Agent authentication capabilities.

    agent_capabilities_from_json

    Decode Agent capabilities.

    agent_capabilities_to_json

    Encode Agent capabilities.

    agent_context

    Construct one immutable context around caller-owned typed transport ports. This is intentionally a one-shot constructor rather than a builder. client_info defaults to a constant-Omitted accessor; the runtime runner injects the accessor backed by the peer's initialize params.

    agent_context_over_channel

    Bind one immutable typed Agent outbound context onto the engine-level outbound channel. A handler running inside the single owner loop can use the returned context to issue reverse requests (session/request_permission, fs/*, terminal/*, elicitation/create) and stream notifications (session/update, elicitation/complete) through the real engine: ids, envelopes, correlation, and the serial writer queue stay engine-owned.

    The context owns only immutable broker closures over the channel; it holds no connection state, queue, task, or registry, and it introduces no second loop. Every failure is reported through the typed AgentContextError mapping documented on the helpers below; nothing is stringified, dropped, or converted into a success.

    agent_endpoint_from_spec

    agent_mcp_capabilities_from_json

    Decode Agent MCP capabilities.

    agent_mcp_capabilities_to_json

    Encode Agent MCP capabilities.

    agent_program

    Turn a caller-owned Reader of a validated service specification into a one-shot endpoint program. The Reader is still pure and synchronous; it only captures the async callbacks in the endpoint value.

    agent_program_from

    Convenience composition boundary for an arbitrary caller-owned Env. The projection is evaluated only when the returned Reader is run.

    agent_prompt_capabilities_from_json

    Decode Agent prompt capabilities.

    agent_prompt_capabilities_to_json

    Encode Agent prompt capabilities.

    agent_protocol_state_new

    Construct a fresh state for one Agent endpoint.

    agent_runtime_owner_port

    Bind one Agent endpoint and its outbound context onto the single connection owner-loop engine. The returned port captures the immutable endpoint and context values plus one owner-write publication cell; every protocol transition stays inside the engine-owned AgentAdapterState. There is no second owner loop, shadow pending map, Mutex, or builder surface here: the only Ref is the write-once clientInfo cell that the owner-loop admit path publishes so session handlers read the connecting client's identity through the read-only AgentContext::client_info accessor. Handler tasks never write it.

    Residual AgentAdapterError values (EndpointMismatch, UnexpectedMessage) indicate composition or protocol bugs, but the owner port closures are total by signature. Each residual is therefore answered with an explicit typed fallback instead of being swallowed: requests get exactly one internal-error response plus one trace effect, notifications get one trace effect and no response, and the owner state is held unchanged. The fallback is visible on the wire and in the trace sink; it is never a silent success.

    agent_runtime_run

    Run one Agent connection on the single native owner-loop engine. This is a thin composition of connection_runtime_run_owner with agent_runtime_owner_port: it validates the options fail-fast and creates no connection state of its own.

    agent_serve_stdio

    Serve this process's real stdio as one Agent connection: inbound ACP frames arrive on stdin, outbound frames (including one final response per request) go to stdout, and every diagnostic goes to the trace sink (stderr by default). This is a thin composition of agent_runtime_run over runtime_stdio_ports: it validates the options fail-fast before any I/O binding and creates no connection state of its own. The loop ends when stdin reaches EOF or the engine fails; both outcomes surface through the same single reader/writer/reducer engine as every other runner.

    agent_serve_stdio_with_outbound

    Serve this process's real stdio as one Agent connection with the engine-level outbound channel handed to the Agent context factory, so handlers running mid-execution can stream session/update notifications and issue reverse requests (session/request_permission, elicitation, filesystem, terminal) through the real engine instead of a fail-fast broker. Without this composition a stdio Agent could answer requests but never exercise the reverse direction of the protocol; the factory timing mirrors agent_runtime_run_with_outbound (after the connection-local queues exist, before the loop starts). This is a thin composition over runtime_stdio_ports: it validates the options fail-fast before any I/O binding and creates no second loop, channel state, or connection state of its own. The loop ends when stdin reaches EOF or the engine fails.

    agent_session_capabilities_from_json

    Decode Agent session capabilities.

    agent_session_capabilities_to_json

    Encode Agent session capabilities.

    agent_session_service

    fn agent_session_service(new_session~ : async (
    AgentContext
    ,
    NewSessionParams
    ) ->
    NewSessionResult
    , prompt~ : async (
    AgentContext
    ,
    PromptParams
    ) ->
    PromptResult
    , cancel~ : async (
    AgentContext
    ,
    CancelParams
    ) -> Unit, load? : async (
    AgentContext
    ,
    LoadSessionParams
    ) ->
    LoadSessionResult
    , resume_session? : async (
    AgentContext
    ,
    ResumeSessionParams
    ) ->
    ResumeSessionResult
    , fork_session? : async (
    AgentContext
    ,
    ForkSessionParams
    ) ->
    ForkSessionResult
    , list? : async (
    AgentContext
    ,
    ListSessionsParams
    ) ->
    ListSessionsResult
    , delete? : async (
    AgentContext
    ,
    DeleteSessionParams
    ) ->
    DeleteSessionResult
    , close? : async (
    AgentContext
    ,
    CloseSessionParams
    ) ->
    CloseSessionResult
    , set_mode? : async (
    AgentContext
    ,
    SetSessionModeParams
    ) ->
    SetSessionModeResult
    , set_config_option? : async (
    AgentContext
    ,
    SetSessionConfigOptionParams
    ) ->
    SetSessionConfigOptionResult
    ) ->
    AgentSessionService

    Compose all required session callbacks once. Optional callbacks are represented by None; there is no mutable registration phase.

    agent_support

    fn agent_support(prompt_image? : Bool, prompt_audio? : Bool, prompt_embedded_context? : Bool, mcp_http? : Bool, mcp_sse? : Bool, additional_directories? : Bool) ->
    AgentSupport

    annotations_from_json

    Decode annotations from a JSON value.

    annotations_to_json

    Encode annotations as a JSON object.

    audio_content_from_json

    Decode audio content from a JSON value.

    audio_content_to_json

    Encode audio content as a JSON object.

    auth_method_from_json

    Decode one authentication method.

    auth_method_to_json

    Encode one authentication method.

    authenticate_params_from_json

    Decode authenticate request parameters.

    authenticate_params_to_json

    Encode authenticate request parameters.

    authenticate_result_from_json

    Decode authenticate response data.

    authenticate_result_to_json

    Encode authenticate response data.

    available_command_input_from_json

    Decode a command input from JSON.

    available_command_input_to_json

    Encode a command input as JSON.

    available_commands_update_from_json

    Decode an available-commands update from JSON.

    available_commands_update_to_json

    Encode an available-commands update as JSON.

    blob_resource_contents_from_json

    Decode binary resource contents from a JSON value.

    blob_resource_contents_to_json

    Encode binary resource contents as a JSON object.

    cancel_params_from_json

    Decode session/cancel notification parameters.

    cancel_params_to_json

    Encode session/cancel notification parameters.

    capability_marker_from_json

    Decode a capability marker object.

    capability_marker_to_json

    Encode a capability marker object.

    client_capabilities_from_json

    Decode Client capabilities.

    client_capabilities_to_json

    Encode Client capabilities.

    client_config_option_capabilities_from_json

    Decode Client config-option capabilities.

    client_config_option_capabilities_to_json

    Encode Client config-option capabilities.

    client_connect_process

    Drive one spawned agent subprocess as a Client connection over real process stdio. The child's stdin/stdout become the engine's writer/reader ports (frames flushed per write), the child's stderr is redirected to this process's stderr, and diagnostics go to the trace sink (stderr by default). This is a thin composition of client_runtime_run_with_outbound over runtime_process_ports; it validates the options fail-fast before spawning and reuses the same single reader/writer/reducer engine.

    Connection scope equals child scope: the composition opens one task group, spawns the child inside it with no_wait = true, runs the engine, then closes the child's stdin — the ACP stdio shutdown signal — before group teardown. A well-behaved agent exits on that EOF and is reaped with its exit status; an agent that keeps running is gracefully terminated and then forcefully killed by the async process layer's cancellation handler during teardown, still inside this call. No detached child and no background reaper can outlive the returned call.

    The client owns that shutdown signal, and closing the child's stdin is what ends a live interactive session: the engine itself only ends on the child's stdout EOF, which a well-behaved agent produces after observing its own stdin EOF. The built-in close therefore runs after the engine has already ended and cannot serve as the client's proactive shutdown. The optional spawned callback closes exactly that gap: it receives the real RuntimeProcessPorts handle right after the spawn succeeds and before the engine starts, so a composition root (or test driver) can close the child's stdin, wait for the exit status, or cancel the child at the moment its session logic decides to. The default is a no-op, so callers that only consume a self-terminating child keep the previous behavior.

    client_connection

    Construct one immutable Client connection around caller-owned typed transport ports. This is intentionally a one-shot constructor rather than a builder or registration API.

    client_connection_over_channel

    Bind one immutable typed Client connection facade onto the engine-level outbound channel. Forward requests (initialize, session/new, ...) are submitted through the real single engine with the total typed ClientConnectionError mapping documented on the helpers below; ids, envelopes, correlation, and the serial writer queue stay engine-owned.

    The notification broker of the stable ClientConnection facade is synchronous by contract, so it submits through the channel's synchronous notification offer: no task parks, and the one engine loop still owns the envelope, framing, and the serial writer queue. Ok therefore records only acceptance into the engine's event queue (the facade's notification port contract); writer-offer and transport failures stay observable at the connection level through the loop's fail-and-close semantics.

    v1 manifest fact (see method/manifest.mbt): the stable v1 surface has exactly one Client-to-Agent notification method, session/cancel, plus the Bidirectional engine-handled $/cancel_request notification. Both flow through this synchronous submission path.

    client_elicitation_capabilities_from_json

    Decode Client elicitation capabilities.

    client_elicitation_capabilities_to_json

    Encode Client elicitation capabilities.

    client_file_system_capabilities_from_json

    Decode Client file-system capabilities.

    client_file_system_capabilities_to_json

    Encode Client file-system capabilities.

    client_program

    Turn a Reader of a validated Client specification into a one-shot endpoint program. Each Reader::run derives an isolated endpoint from its Env.

    client_program_from

    Compose a Client endpoint directly from a caller-owned environment projection without storing that environment globally.

    client_protocol_state_new

    Construct a Client state that has negotiated capability data but is not yet ready to receive Agent business traffic.

    client_protocol_state_ready

    Construct a ready Client state when the caller has already completed the initialize exchange.

    client_runtime_owner_port

    Bind one Client endpoint onto the single connection owner-loop engine. The returned port captures only the immutable endpoint value; every protocol transition stays inside the engine-owned ClientAdapterState. There is no second owner loop, shadow pending map, Ref, Mutex, or builder surface here.

    Residual ClientAdapterError values (EndpointMismatch, UnexpectedMessage, CompletionMismatch) indicate composition or protocol bugs, but the owner port closures are total by signature. Each residual is therefore answered with an explicit typed fallback instead of being swallowed: requests get exactly one internal-error response plus one trace effect, notifications get one trace effect and no response, and the owner state is held unchanged. The fallback is visible on the wire and in the trace sink; it is never a silent success.

    client_runtime_run

    Run one Client connection on the single native owner-loop engine. This is a thin composition of connection_runtime_run_owner with client_runtime_owner_port: it validates the options fail-fast and creates no connection state of its own.

    client_session_capabilities_from_json

    Decode Client session capabilities.

    client_session_capabilities_to_json

    Encode Client session capabilities.

    client_session_service

    Compose the baseline Client service. Both callbacks are required by the signature; an incomplete baseline cannot be represented as a service value.

    close_session_params_from_json

    Decode session/close parameters.

    close_session_params_to_json

    Encode session/close parameters.

    close_session_result_from_json

    Decode the result of session/close.

    close_session_result_to_json

    Encode the result of session/close.

    config_option_update_from_json

    Decode a configuration-options update from JSON.

    config_option_update_to_json

    Encode a configuration-options update as JSON.

    connection_runtime_run_owner

    async fn[S, I, C, E] connection_runtime_run_owner(ports :
    RuntimePorts
    , options :
    RuntimeOptions
    , owner_port :
    RuntimeOwnerPort
    [S, I, C, E]) -> Unit

    connection_runtime_run_owner_with_outbound

    Run the one owner engine with an engine-level outbound submission channel. The factory runs after the connection-local queues and shutdown state exist and before the loop starts; its closures may capture the channel and hand it to typed request/notification brokers in a later work order. This runner adds no second loop: it reuses the same single reader/writer/reducer engine as connection_runtime_run_owner, whose signature and behavior stay unchanged for existing callers.

    content_block_from_json

    Decode one of the five stable ACP content block variants.

    content_block_to_json

    Encode one of the five stable ACP content block variants.

    content_chunk_from_json

    content_chunk_to_json

    Encode a streamed content item.

    content_from_json

    content_to_json

    Encode a standard content wrapper.

    cost_from_json

    Decode cost information from JSON.

    cost_to_json

    Encode cost information as JSON.

    current_mode_update_from_json

    Decode a current-mode update from JSON.

    current_mode_update_to_json

    Encode a current-mode update as JSON.

    decode_agent_notification

    decode_agent_request

    decode_client_notification

    Decode one Agent-to-Client notification params value. String, integer, and null cancellation identifiers remain distinct typed RequestId values.

    decode_client_request

    Decode one Agent-to-Client request params value into the closed request union. Known Client-to-Agent methods and notifications are rejected explicitly rather than being treated as unknown methods.

    delete_session_params_from_json

    Decode session/delete parameters.

    delete_session_params_to_json

    Encode session/delete parameters.

    delete_session_result_from_json

    Decode the result of session/delete.

    delete_session_result_to_json

    Encode the result of session/delete.

    diff_from_json

    Decode a diff from JSON.

    diff_to_json

    Encode a diff as JSON.

    elicitation_complete_params_from_json

    Decode the elicitation/complete notification parameters.

    elicitation_complete_params_to_json

    Encode the elicitation/complete notification parameters.

    elicitation_create_params_from_json

    Decode the form/URL union for elicitation/create.

    elicitation_create_params_to_json

    Encode the form/URL union for elicitation/create.

    elicitation_create_result_from_json

    Decode the result of elicitation/create. Only the accept outcome may carry content; a decline or cancel carrying content is an explicit invalid-params failure, never a silently ignored payload.

    elicitation_create_result_to_json

    Encode the result of elicitation/create. Encoding a decline or cancel result whose content is set fails fast instead of dropping the payload.

    embedded_resource_from_json

    Decode an embedded resource from a JSON value.

    embedded_resource_resource_from_json

    Decode an embedded resource payload from a JSON value.

    embedded_resource_resource_to_json

    Encode an embedded resource payload as a JSON object.

    embedded_resource_to_json

    Encode an embedded resource as a JSON object.

    fork_session_params_from_json

    Decode session/fork parameters.

    fork_session_params_to_json

    Encode session/fork parameters.

    fork_session_result_from_json

    Decode the result of session/fork.

    fork_session_result_to_json

    Encode the result of session/fork.

    framing_feed

    Feed an arbitrary byte chunk. A chunk may contain partial or multiple frames. CRLF is accepted by removing the CR immediately before LF.

    framing_finish

    Finish the stream. A partial line is never silently discarded.

    framing_state

    Create a decoder with a positive maximum payload size in bytes.

    image_content_from_json

    Decode image content from a JSON value.

    image_content_to_json

    Encode image content as a JSON object.

    implementation_from_json

    Decode implementation information.

    implementation_to_json

    Encode implementation information.

    initialize_params_from_json

    Decode initialization request parameters.

    initialize_params_to_json

    Encode initialization request parameters.

    initialize_result_from_json

    Decode initialization response data.

    initialize_result_to_json

    Encode initialization response data.

    jsonrpc_decode

    Decode one complete JSON-RPC message from JSON text.

    This function parses exactly one JSON value and then validates its complete envelope. It does not implement line framing; callers that use stdio must split frames before calling it.

    jsonrpc_decode_int64

    fn jsonrpc_decode_int64(value : Double, repr : String?, path~ : String) -> Int64 raise
    JsonRpcCodecError

    jsonrpc_decode_json

    Decode one JSON-RPC message from an already parsed JSON value.

    jsonrpc_encode

    Encode one JSON-RPC message as compact JSON text.

    The returned text contains no framing newline. Newline-delimited stdio is a runtime concern and must append its own delimiter.

    jsonrpc_to_json

    Encode one JSON-RPC message as a JSON value.

    list_sessions_params_from_json

    Decode session/list parameters.

    list_sessions_params_to_json

    Encode session/list parameters.

    list_sessions_result_from_json

    Decode the result of session/list.

    list_sessions_result_to_json

    Encode the result of session/list.

    load_session_params_from_json

    Decode session/load parameters.

    load_session_params_to_json

    Encode session/load parameters.

    load_session_result_from_json

    Decode the result of session/load.

    load_session_result_to_json

    Encode the result of session/load.

    logout_params_from_json

    Decode logout request parameters.

    logout_params_to_json

    Encode logout request parameters.

    logout_result_from_json

    Decode logout response data.

    logout_result_to_json

    Encode logout response data.

    mcp_server_from_json

    Decode one MCP server transport configuration.

    Per the wire schema only http/sse carry a type tag; stdio is the untagged variant, so an absent type decodes as stdio. An explicit "stdio" tag stays accepted for backwards compatibility with payloads produced before this fix.

    mcp_server_to_json

    Encode one MCP server transport configuration with its wire discriminator.

    new_session_params_from_json

    Decode session/new parameters.

    new_session_params_to_json

    Encode session/new parameters.

    new_session_result_from_json

    Decode the result of session/new.

    new_session_result_to_json

    Encode the result of session/new.

    permission_option_from_json

    Decode a permission option from JSON.

    permission_option_to_json

    Encode a permission option as JSON.

    plan_entry_from_json

    Decode a plan entry from JSON.

    plan_entry_to_json

    Encode a plan entry as JSON.

    plan_from_json

    Decode a plan update from JSON.

    plan_to_json

    Encode a plan update as JSON.

    prompt_params_from_json

    Decode session/prompt parameters.

    prompt_params_to_json

    Encode session/prompt parameters.

    prompt_result_from_json

    Decode the result of session/prompt.

    prompt_result_to_json

    Encode the result of session/prompt.

    read_text_file_params_from_json

    Decode fs/read_text_file parameters.

    read_text_file_params_to_json

    Encode fs/read_text_file parameters.

    read_text_file_result_from_json

    Decode the result of fs/read_text_file.

    read_text_file_result_to_json

    Encode the result of fs/read_text_file.

    request_permission_outcome_from_json

    Decode a permission outcome from JSON.

    request_permission_outcome_to_json

    Encode a permission outcome as JSON.

    request_permission_request_from_json

    Decode a permission request payload from JSON.

    request_permission_request_to_json

    Encode a permission request payload as JSON.

    request_permission_response_from_json

    Decode a permission response payload from JSON.

    request_permission_response_to_json

    Encode a permission response payload as JSON.

    Decode a resource link from a JSON value.

    Encode a resource link as a JSON object.

    resume_session_params_from_json

    Decode session/resume parameters.

    resume_session_params_to_json

    Encode session/resume parameters.

    resume_session_result_from_json

    Decode the result of session/resume.

    resume_session_result_to_json

    Encode the result of session/resume.

    runtime_default_options

    runtime_process_ports

    async fn[G] runtime_process_ports(group :
    TaskGroup
    [G], handlers~ :
    RuntimeHandlerPort
    , command~ : String, args? : Array[String], extra_env? : Map[String, String], inherit_env? : Bool, cancel_outbound? : async (
    RequestId
    ) -> Unit?, trace? : (
    RuntimeTraceEvent
    ) -> Unit) ->
    RuntimeProcessPorts
    raise
    RuntimeError

    Construct the client side of one ACP stdio connection over a spawned child process. The child's stdin is the writer target and its stdout is the reader source; the child's stderr is redirected to this process's real stderr so agent diagnostics stay diagnostics and stdout stays pure frames. Both pipe ends are raw, unbuffered @process handles, so every frame write is delivered to the operating system in that call — the pinned flush-per-write discipline, structurally identical to runtime_stdio_ports.

    The child is spawned with no_wait = true inside the caller's task group: when the group terminates, the async process layer cancels its wait task, which gracefully terminates the child (then forcefully after its timeout) and reaps it. Child lifetime is therefore bound to the structured concurrency scope that owns the connection — no background reaper loop, no detached process. A well-behaved agent additionally observes the stdin EOF a composition sends through child_stdin.close() before teardown.

    Fail-fast mapping (the closed stable RuntimeError set has no process category, so each failure keeps its precise kind in the trace, mirroring the documented closest-category mapping of the outbound channel): an empty command is rejected as InvalidOptions before any OS call; a failed stdout pipe is ReaderFailed and a failed stdin pipe is WriterFailed (the seam that could not be constructed); an OS spawn rejection — including a missing command — is InvalidOptions with trace kind process_spawn_failed, because the caller's process configuration was rejected before any I/O seam ever ran. Every failure is typed and accompanied by one trace event; nothing degrades silently.

    runtime_request_id_text

    fn runtime_request_id_text(id :
    RequestId
    ) -> String

    runtime_stderr_trace

    Default trace sink: one write(2) per event to the real standard error. Stdout is never touched here, so the protocol channel keeps carrying newline-delimited ACP frames only. The sink type (RuntimeTraceEvent) -> Unit has no failure channel: when the OS rejects a diagnostics write (for example a closed stderr under a daemon supervisor), the event is dropped without inventing a failure the trace contract cannot carry. Protocol I/O failures stay fully typed at the reader/writer seams.

    runtime_stdio_ports

    Serve the native ACP stdio boundary of this process. The reader reads the real stdin chunk-wise (None is EOF, non-empty chunks only, exactly the RuntimeReaderPort contract). The writer writes each complete newline-delimited frame to the real stdout in one Output::write call: @stdio.Output wraps the raw file descriptor with no userspace buffering (moonbitlang/async/src/stdio/stdio.mbt), so every write is handed to the operating system immediately — the pinned flush-per-write discipline holds structurally because no buffered writer layer exists on this path.

    The handler seams exist only for engine runners with an outbound channel. response and outbound_failure are deliberate no-op observers: reply delivery to parked submitters is owned by the engine's outbound channel, never by these callbacks. The legacy dispatch seams (request, notification) abort fail-fast: these ports exist for owner-loop runners, and a legacy handler dispatch through them would silently answer nothing, so it must crash loudly instead.

    Diagnostics go to the trace sink, defaulting to stderr. Nothing in this constructor writes to stdout, and it performs no I/O at all beyond binding the process file descriptors.

    runtime_trace_event

    fn runtime_trace_event(direction : String, phase : String, request_id : String, method_name : String, error_kind : String) ->
    RuntimeTraceEvent

    runtime_validate_options

    selected_permission_outcome_from_json

    Decode a selected permission outcome payload from JSON.

    selected_permission_outcome_to_json

    Encode a selected permission outcome payload as JSON.

    session_config_option_category_from_json

    Decode a session configuration category from JSON.

    session_config_option_category_to_json

    fn session_config_option_category_to_json(value :
    SessionConfigOptionCategory
    ) -> Json

    Encode a session configuration category as JSON.

    session_config_option_from_json

    Decode one complete configuration option from JSON.

    session_config_option_to_json

    Encode one complete configuration option as JSON.

    session_config_select_group_from_json

    Decode a selectable configuration group from JSON.

    session_config_select_group_to_json

    Encode a selectable configuration group as JSON.

    session_config_select_option_from_json

    Decode a selectable configuration option from JSON.

    session_config_select_option_to_json

    Encode a selectable configuration option as JSON.

    session_config_select_options_from_json

    Decode selectable configuration values from JSON.

    session_config_select_options_to_json

    Encode selectable configuration values as JSON.

    session_info_from_json

    Decode session metadata from JSON.

    session_info_to_json

    Encode session metadata as JSON.

    session_info_update_from_json

    Decode a session-information update from JSON.

    session_info_update_to_json

    Encode a session-information update as JSON.

    session_mode_from_json

    Decode one session mode.

    session_mode_state_from_json

    Decode the mode state returned by session lifecycle methods.

    session_mode_state_to_json

    Encode the mode state returned by session lifecycle methods.

    session_mode_to_json

    Encode one session mode.

    session_update_fold

    fn session_update_fold(known_modes~ : Array[String]) ->
    SessionUpdateFold

    Create the initial consumer state for one session.

    known_modes is the immutable mode set the consumer knows for the session (typically SessionModeState.available_modes from session/new); it is only read by current_mode_update validation and is never modified by any applied update.

    session_update_from_json

    Decode one stable v1 session update variant.

    session_update_params_from_json

    Decode session/update notification parameters.

    session_update_params_to_json

    Encode session/update notification parameters.

    session_update_to_json

    Encode one stable v1 session update variant.

    set_session_config_option_params_from_json

    Decode session/set_config_option parameters.

    set_session_config_option_params_to_json

    Encode session/set_config_option parameters.

    set_session_config_option_result_from_json

    Decode the result of session/set_config_option.

    set_session_config_option_result_to_json

    Encode the result of session/set_config_option.

    set_session_mode_params_from_json

    Decode session/set_mode parameters.

    set_session_mode_params_to_json

    Encode session/set_mode parameters.

    set_session_mode_result_from_json

    Decode the result of session/set_mode.

    set_session_mode_result_to_json

    Encode the result of session/set_mode.

    terminal_create_params_from_json

    Decode terminal/create parameters.

    terminal_create_params_to_json

    Encode terminal/create parameters.

    terminal_create_result_from_json

    Decode the result of terminal/create.

    terminal_create_result_to_json

    Encode the result of terminal/create.

    terminal_from_json

    Decode a terminal reference from JSON.

    terminal_kill_params_from_json

    Decode terminal/kill parameters.

    terminal_kill_params_to_json

    Encode terminal/kill parameters.

    terminal_kill_result_from_json

    Decode the result of terminal/kill.

    terminal_kill_result_to_json

    Encode the result of terminal/kill.

    terminal_output_params_from_json

    Decode terminal/output parameters.

    terminal_output_params_to_json

    Encode terminal/output parameters.

    terminal_output_result_from_json

    Decode the result of terminal/output.

    terminal_output_result_to_json

    Encode the result of terminal/output.

    terminal_release_params_from_json

    Decode terminal/release parameters.

    terminal_release_params_to_json

    Encode terminal/release parameters.

    terminal_release_result_from_json

    Decode the result of terminal/release.

    terminal_release_result_to_json

    Encode the result of terminal/release.

    terminal_to_json

    Encode a terminal reference as JSON.

    terminal_wait_for_exit_params_from_json

    Decode terminal/wait_for_exit parameters.

    terminal_wait_for_exit_params_to_json

    Encode terminal/wait_for_exit parameters.

    terminal_wait_for_exit_result_from_json

    Decode the result of terminal/wait_for_exit.

    terminal_wait_for_exit_result_to_json

    Encode the result of terminal/wait_for_exit.

    text_content_from_json

    Decode text content from a JSON value.

    text_content_to_json

    Encode text content as a JSON object.

    text_resource_contents_from_json

    Decode text resource contents from a JSON value.

    text_resource_contents_to_json

    Encode text resource contents as a JSON object.

    tool_call_content_from_json

    Decode tool-call content from JSON.

    tool_call_content_to_json

    Encode tool-call content as JSON.

    tool_call_from_json

    Decode an initial tool call from JSON.

    tool_call_location_from_json

    Decode a tool-call location from JSON.

    tool_call_location_to_json

    Encode a tool-call location as JSON.

    tool_call_to_json

    Encode an initial tool call as JSON.

    tool_call_update_from_json

    Decode a tool call update from JSON.

    tool_call_update_to_json

    Encode a tool call update as JSON.

    unstructured_command_input_from_json

    Decode unstructured command input from JSON.

    unstructured_command_input_to_json

    Encode unstructured command input as JSON.

    usage_update_from_json

    Decode a usage update from JSON.

    usage_update_to_json

    Encode a usage update as JSON.

    write_text_file_params_from_json

    Decode fs/write_text_file parameters.

    write_text_file_params_to_json

    Encode fs/write_text_file parameters.

    write_text_file_result_from_json

    Decode the result of fs/write_text_file.

    write_text_file_result_to_json

    Encode the result of fs/write_text_file.