moonacp

    The Agent Client Protocol for MoonBit: editors talking to agents, over ASGI or stdio.

    acp
    agent-client-protocol
    agent
    client
    editor
    coding-agent
    zed
    json-rpc
    jsonrpc
    rpc
    asgi
    stdio
    stdin
    websocket
    ws
    sse
    http
    streamable-http
    http-client
    remote
    session
    prompt
    streaming
    tool-call
    permission
    terminal
    elicitation
    protocol
    async
    server
    opentelemetry
    otel
    tracing
    telemetry
    gen-ai
    semantic-conventions
    moonbit
    Download zip
    Version
    0.2.3
    License
    Apache-2.0
    Last updated
    9 hours ago
    Downloads
    269

    #moonacp

    An editor talks, an agent answers. The Agent Client Protocol for MoonBit.

    An editor and a coding agent are two programs that need to agree on more than text: who owns the session, how an answer arrives while it is still being written, who may write a file, who runs the command. This library is that agreement — the session, the streamed updates, the permission prompts, the files and the terminals — with both sides of it in one place and two transports to carry it.

    moon add moonbitstack/moonacp

    #An agent in full

    Three methods are required. Everything else has a default that reports itself as unsupported, so an agent advertises in initialize exactly what it answers.

    struct Notes {
    mut sessions : Int32
    }

    fn Notes::new() -> Notes {
    { sessions: 0 }
    }

    impl @moonacp.Agent for Notes with fn initialize(self, request) {
    ignore(self)
    ignore(request)
    {
    ..@moonacp.Initialized::new(),
    capabilities: {
    ..@moonacp.AgentCapabilities::none(),
    prompt: { image: true, audio: false, embedded_context: true, meta: None },
    },
    agent_info: Some(@moonacp.Implementation::new("notes", "0.1.0")),
    }
    }

    impl @moonacp.Agent for Notes with fn new_session(self, request) {
    ignore(request)
    self.sessions = self.sessions + 1
    { session_id: "notes-\{self.sessions}", modes: None, config_options: None, meta: None }
    }

    impl @moonacp.Agent for Notes with fn prompt(self, request, session) {
    let text = request.prompt.map(block => match block {
    @moonacp.ContentBlock::Text(content) => content.text
    _ => ""
    }).join(" ")
    session.update(@moonacp.SessionUpdate::AgentMessageChunk({
    content: @moonacp.ContentBlock::Text({ text: "You said: " + text, annotations: None, meta: None }),
    message_id: None,
    meta: None,
    }))
    @moonacp.StopReason::EndTurn
    }

    Serve it on the pipe an editor launches it with:

    @stdio.serve_stdio(Notes::new())

    #An editor in full

    The client side is the same shape: implement Client for what the editor answers, connect it to a transport, and run the connection so updates arrive while a turn is in flight.

    struct Editor {
    mut chunks : Int32
    }

    fn Editor::new() -> Editor {
    { chunks: 0 }
    }

    impl @moonacp.Client for Editor with fn update(self, id, update) {
    ignore(id)
    match update {
    @moonacp.SessionUpdate::AgentMessageChunk(chunk) =>
    if chunk.content is @moonacp.ContentBlock::Text(text) {
    self.chunks = self.chunks + 1
    println(text.text)
    }
    _ => ()
    }
    }

    impl @moonacp.Client for Editor with fn request_permission(self, ask) {
    ignore(self)
    match ask.options {
    [] => @moonacp.Outcome::Cancelled
    [first, ..] => @moonacp.Outcome::Selected(first.option_id)
    }
    }

    async fn main {
    let child = @stdio.spawn(Editor::new(), ["/usr/local/bin/notes-agent"])
    let conn = child.conn()
    @async.with_task_group(async fn(group) {
    group.spawn_bg(async fn() { conn.run() })
    ignore(conn.initialize({
    protocol_version: @moonacp.protocol_version,
    client_capabilities: @moonacp.ClientCapabilities::none(),
    client_info: None,
    meta: None,
    }))
    let session = conn.new_session({
    cwd: "/work",
    additional_directories: None,
    mcp_servers: [],
    meta: None,
    })
    let answer = conn.prompt({
    session_id: session.session_id,
    prompt: [@moonacp.ContentBlock::Text({ text: "hello", annotations: None, meta: None })],
    meta: None,
    })
    println(answer.stop_reason.to_string())
    })
    }

    #Transports

    TransportEntry pointShape
    stdio@stdio.serve_stdio, @stdio.spawnOne JSON-RPC message per line on the process's own streams. The transport an editor uses when it launches an agent.
    ASGI@asgi.to_asgiOne endpoint: POST for client-to-agent messages, long-lived GET streams for the answers, DELETE to end a connection, and a WebSocket upgrade carrying the same messages on one channel.
    remote@remote.openThe editor's side of that endpoint. open builds the connection and sends nothing; the first message connects it, run receives on it, and close ends it on both sides.

    A session's own stream carries its turn: while the client has one open for a session, that session's updates and answers go there, and everything else — initialize, session/new, the answers to calls that name no session — goes to the connection's stream. A client that reads one stream reads everything, and one that opens a stream per session reads each turn where it started.

    The remote transport follows the protocol's request for discussion of 2026-11-04. That document is not final, and the schema has no member for the connection identifier it introduces: the identifier travels in the initialize answer's _meta and in an Acp-Connection-Id header.

    #Reaching an agent across the network

    @asgi serves; @remote is the other half, for an editor whose agent is not a child process. It speaks the same messages to a running server, and a server's per-session streams are opened as the calls that need them are made.

    async fn reach(editor : &@moonacp.Client) -> Unit raise {
    let remote = @remote.open(editor, "http://127.0.0.1:12000/acp")
    let conn = remote.conn()
    @async.with_task_group(async fn(group) {
    group.spawn_bg(async fn() { remote.run() })
    let started = conn.initialize({
    protocol_version: @moonacp.protocol_version,
    client_capabilities: @moonacp.ClientCapabilities::none(),
    client_info: None,
    meta: None,
    })
    println("talking to " + started.protocol_version.to_string())
    // Everything the agent says arrives while `run` runs; `close` is what ends the exchange.
    remote.close()
    })
    }

    run is in a task of its own because every stream the connection opens is read by a task of its own — the HTTP client underneath reads one stream per task — and the peer takes its messages from one queue.

    #Traces and metrics

    @otel wraps either side of the conversation, so that what happened in it can be read afterwards. A turn becomes one span and one observation of a duration, and every file or terminal request the agent makes of the editor becomes one more of each. Every name here — of a span, of a metric, of an attribute — is read from moontel/semconv, which is generated from the OpenTelemetry GenAI registry; nothing in a signal is named by this library.

    SignalWritten byCarries
    invoke_agent {agent} span@otel.traced, one per promptthe agent and its version, the conversation — ACP's session — and the stop reason as gen_ai.response.finish_reasons
    execute_tool {method} span@otel.traced_client, one per fs/* and terminal/* requestthe tool, named after the method, the conversation, and the agent when the editor knows it
    gen_ai.invoke_agent.duration histogram, in seconds@otel.metered, one observation per promptthe operation and the agent
    gen_ai.execute_tool.duration histogram, in seconds@otel.metered_client, one observation per answered requestthe tool, and the agent when the editor knows it

    A span covers the call, so a turn that failed ends as an error with the failure as its status, and a turn that was cancelled ends as Ok with cancelled among its finish reasons. Prompt and answer text is never recorded: a trace is read by more people than the conversation is.

    let tracer = @trace.Tracer::new(
    rand=width => Bytes::make(width, b'\x21'),
    sink=@trace.Recorder::new(),
    sampler=@trace.always,
    )
    @stdio.serve_stdio(@otel.traced(Notes::new(), tracer))

    The tracer is the one moontel builds, so spans go wherever its sinks send them: a recorder in a test, a collector over OTLP, a file. Metrics go the same way — a histogram is one observation per turn, and the built-in bounds are five milliseconds to ten seconds:

    let transport = @grpc.GrpcTransport::connect(host="127.0.0.1", port=4317)
    let metrics = @otlp.MetricsExporter::new(
    transport~,
    encoding=@binary.protobuf,
    now=@async.now,
    rand=width => Bytes::make(width, b'\x21'),
    )
    @stdio.serve_stdio(@otel.metered(Notes::new(), metrics))

    The wrappers compose, so one line gets both: @otel.metered(@otel.traced(agent, tracer), metrics). The example in src/examples/04-otel runs a whole conversation with all four wrappers on and exports both signals.

    #The interface

    // The agent's side
    pub(open) trait Agent {
    async fn initialize(Self, Initialize) -> Initialized raise Refused
    async fn new_session(Self, NewSession) -> SessionStarted raise Refused
    async fn prompt(Self, Prompt, Session) -> StopReason raise Refused
    // authenticate, logout, session/load, session/resume, session/list, session/delete,
    // session/close, session/set_mode, session/set_config_option, cancel: optional
    }

    // What a prompt uses to talk back
    pub async fn Session::update(Self, SessionUpdate) -> Unit raise Refused
    pub async fn Session::request_permission(Self, Permission) -> Outcome raise Refused
    pub async fn Session::read_text_file(Self, String, line? : Int64, limit? : Int64) -> String raise Refused
    pub async fn Session::write_text_file(Self, String, String) -> Unit raise Refused
    pub async fn Session::terminal(Self, String, ..) -> Terminal raise Refused
    pub async fn Session::elicit(Self, Elicitation) -> Answer raise Refused

    // The editor's side
    pub(open) trait Client {
    async fn update(Self, String, SessionUpdate) -> Unit
    async fn request_permission(Self, Permission) -> Outcome raise Refused
    // read_text_file, write_text_file, create_terminal, terminal_output, wait_for_terminal_exit,
    // kill_terminal, release_terminal, elicit: optional
    }

    pub fn serve(&Agent, &@peer.Frames) -> @peer.Peer
    pub fn connect(&Client, &@peer.Frames) -> Conn

    // The editor's side of the remote transport
    pub fn open(&Client, String, headers? : Array[(String, String)], timeout? : Int32) -> Remote
    pub fn Remote::conn(Self) -> Conn
    pub async fn Remote::run(Self) -> Unit
    pub async fn Remote::close(Self) -> Unit
    pub async fn Conn::initialize(Self, Initialize) -> Initialized raise Refused
    pub async fn Conn::prompt(Self, Prompt) -> PromptResult raise Refused
    pub async fn Conn::cancel(Self, String) -> Unit raise Refused
    pub async fn Conn::run(Self) -> Unit

    The wire types are the schema's own: ContentBlock, SessionUpdate with its fourteen shapes, ToolCall, StopReason, AgentCapabilities, ClientCapabilities, the MCP server records, the elicitation forms, and one type per method for its parameters and its answer.

    #MCP servers

    A client names the MCP servers it wants in session/new; launching them and talking to them is the agent's job, and it is written where that job lives — in the example. mcp.mbt there spawns each stdio server, completes the MCP handshake, asks what tools it offers, and closes its input when the session ends. The library itself carries the servers' records and nothing more, because speaking MCP is a protocol of its own.

    #Consistency

    Every implementation this protocol has an official client for is driven against the example agent, in both directions, and every message either side writes is checked against the published schema. Nothing is listed as passing that does not run on every push.

    CheckPinned atResult
    acp-tck, the official conformance suitecommit b7f40fb, v1 suiteCONFORMANT: every mandatory requirement and every declared capability
    The published schemav1.29.1every message, both directions
    Official TypeScript client → this library@agentclientprotocol/sdk 2.4.0conversation, streamed answer, cancel
    Official Python client → this libraryagent-client-protocol 0.12.1conversation, streamed answer, cancel
    This library → official TypeScript agent@agentclientprotocol/sdk 2.4.0conversation, streamed answer
    This library → official Python agentagent-client-protocol 0.12.1conversation, streamed answer
    Official Rust client over HTTP → this library's serveragent-client-protocol-http 5.0.0initialize, session, streamed turn, cancel, list
    This library's client over HTTP → official Rust agentagent-client-protocol-http 5.0.0, serverinitialize, session, streamed turn
    The signals this library writes against the GenAI registryweaver 0.28.0, conventions aa3b7f4spans and metrics, no findings

    #License

    Apache-2.0.

    Agent

    pub(open) trait Agent {
    async fn initialize(Self, Initialize) -> Initialized raise Refused
    async fn authenticate(Self, Authenticate) -> Unit raise Refused = _
    async fn logout(Self) -> Unit raise Refused = _
    async fn new_session(Self, NewSession) -> SessionStarted raise Refused
    async fn load_session(Self, LoadSession, Session) -> SessionStarted raise Refused = _
    async fn resume_session(Self, ResumeSession, Session) -> SessionStarted raise Refused = _
    async fn list_sessions(Self, ListSessions) -> SessionList raise Refused = _
    async fn delete_session(Self, DeleteSession) -> Unit raise Refused = _
    async fn close_session(Self, CloseSession) -> Unit raise Refused = _
    async fn set_mode(Self, SetMode) -> Unit raise Refused = _
    async fn set_config_option(Self, SetConfigOption) -> Array[ConfigOption] raise Refused = _
    async fn prompt(Self, Prompt, Session) -> StopReason raise Refused
    async fn cancel(Self, id : String) -> Unit = _
    }

    The agent side. Implement what the agent can do and leave the rest: initialize and new_session and prompt are the three every agent has, the others have defaults that report themselves as unsupported.

    Client

    pub(open) trait Client {
    async fn update(Self, String, SessionUpdate) -> Unit
    async fn request_permission(Self, Permission) -> Outcome raise Refused
    async fn read_text_file(Self, ReadTextFile) -> String raise Refused = _
    async fn write_text_file(Self, WriteTextFile) -> Unit raise Refused = _
    async fn create_terminal(Self, TerminalCommand) -> String raise Refused = _
    async fn terminal_output(Self, TerminalRequest) -> TerminalOutput raise Refused = _
    async fn wait_for_terminal_exit(Self, TerminalRequest) -> ExitStatus raise Refused = _
    async fn kill_terminal(Self, TerminalRequest) -> Unit raise Refused = _
    async fn release_terminal(Self, TerminalRequest) -> Unit raise Refused = _
    async fn elicit(Self, Elicitation) -> Answer raise Refused = _
    }

    The client side. update is the only method the protocol requires; the rest exist so the agent can ask for them, and a client that leaves one out answers -32601 when the agent asks.

    Refused

    pub(all) suberror Refused {
    Refused(code~ : Int, message~ : String, data~ :
    Json
    ?)
    Unsupported(name~ : String)
    Malformed(reason~ : String)
    Closed(reason~ : String)
    } derive(Eq)

    What a handler raises, and what the other side's error object becomes when a call fails. A variant's code is the JSON-RPC code it travels as: Refused(code~, ..) carries the wire code itself, Unsupported is -32601, Malformed is -32602.

    Refused::code

    fn Refused::code(self : Refused) -> Int

    The code this failure travels as.

    Refused::data

    Anything else attached to the failure.

    Refused::equal

    fn Refused::equal(Refused, Refused) -> Bool
    automatically derived

    Refused::failure

    The wire form of a failure.

    Refused::message

    fn Refused::message(self : Refused) -> String

    What the other side reads.

    Refused::new

    fn Refused::new(code : Int, message : String, data? :
    Json
    ) -> Refused

    An error object with a code of your choosing.

    Refused::not_equal

    fn Refused::not_equal(x : Refused, y : Refused) -> Bool
    automatically derived

    AgentAuthCapabilities

    pub(all) struct AgentAuthCapabilities {
    logout : Bool
    meta :
    Json
    ?
    } derive(Eq)

    Authentication the agent offers.

    AgentAuthCapabilities::equal

    automatically derived

    AgentAuthCapabilities::none

    No authentication step offered.

    AgentAuthCapabilities::not_equal

    automatically derived

    AgentAuthCapabilities::to_json

    AgentCapabilities

    pub(all) struct AgentCapabilities {
    load_session : Bool
    prompt : PromptCapabilities
    mcp : McpCapabilities
    session : SessionCapabilities
    auth : AgentAuthCapabilities?
    meta :
    Json
    ?
    } derive(Eq)

    Everything the agent says it can do, sent back from initialize.

    AgentCapabilities::equal

    automatically derived

    AgentCapabilities::none

    An agent that supports only session/new and session/prompt.

    AgentCapabilities::not_equal

    fn AgentCapabilities::not_equal(x : AgentCapabilities, y : AgentCapabilities) -> Bool
    automatically derived

    AgentCapabilities::to_json

    Annotations

    pub(all) struct Annotations {
    audience : Array[Role]?
    last_modified : String?
    priority : Double?
    meta :
    Json
    ?
    } derive(Eq)

    Hints for how a client shows a piece of content.

    Annotations::equal

    fn Annotations::equal(Annotations, Annotations) -> Bool
    automatically derived

    Annotations::not_equal

    fn Annotations::not_equal(x : Annotations, y : Annotations) -> Bool
    automatically derived

    Annotations::to_json

    Answer

    pub(all) enum Answer {
    Accept(Map[String,
    Json
    ]?)
    Decline
    Cancel
    Other(String)
    } derive(Eq)

    What the user did with the ask. content holds one value per field, of whatever type the field asked for, so it stays raw.

    Answer::equal

    fn Answer::equal(Answer, Answer) -> Bool
    automatically derived

    Answer::not_equal

    fn Answer::not_equal(x : Answer, y : Answer) -> Bool
    automatically derived

    Answer::to_json

    AudioContent

    pub(all) struct AudioContent {
    data : String
    mime_type : String
    annotations : Annotations?
    meta :
    Json
    ?
    } derive(Eq)

    AuthMethod

    pub(all) enum AuthMethod {
    Terminal(AuthMethodTerminal)
    Agent(AuthMethodAgent)
    } derive(Eq)

    An authentication method the agent offers, one of two shapes tagged by type on the wire; the agent-driven one carries no tag.

    AuthMethod::equal

    fn AuthMethod::equal(AuthMethod, AuthMethod) -> Bool
    automatically derived

    AuthMethod::not_equal

    fn AuthMethod::not_equal(x : AuthMethod, y : AuthMethod) -> Bool
    automatically derived

    AuthMethod::to_json

    AuthMethodAgent

    pub(all) struct AuthMethodAgent {
    id : String
    name : String
    description : String?
    meta :
    Json
    ?
    } derive(Eq)

    The agent runs the flow itself once authenticate is called.

    AuthMethodAgent::equal

    automatically derived

    AuthMethodAgent::not_equal

    fn AuthMethodAgent::not_equal(x : AuthMethodAgent, y : AuthMethodAgent) -> Bool
    automatically derived

    AuthMethodAgent::to_json

    AuthMethodTerminal

    pub(all) struct AuthMethodTerminal {
    id : String
    name : String
    description : String?
    args : Array[String]?
    env : Map[String, String]?
    meta :
    Json
    ?
    } derive(Eq)

    Authenticate

    pub(all) struct Authenticate {
    method_id : String
    meta :
    Json
    ?
    } derive(Eq)

    Names one of the methods from initialize.

    Authenticate::equal

    automatically derived

    Authenticate::not_equal

    fn Authenticate::not_equal(x : Authenticate, y : Authenticate) -> Bool
    automatically derived

    Authenticate::to_json

    AvailableCommand

    pub(all) struct AvailableCommand {
    name : String
    description : String
    input : CommandInput?
    meta :
    Json
    ?
    } derive(Eq)

    AvailableCommands

    pub(all) struct AvailableCommands {
    available_commands : Array[AvailableCommand]
    meta :
    Json
    ?
    } derive(Eq)

    BlobResource

    pub(all) struct BlobResource {
    uri : String
    blob : String
    mime_type : String?
    meta :
    Json
    ?
    } derive(Eq)

    Resource contents carried as base64 in blob.

    BlobResource::equal

    automatically derived

    BlobResource::not_equal

    fn BlobResource::not_equal(x : BlobResource, y : BlobResource) -> Bool
    automatically derived

    BlobResource::to_json

    BooleanField

    pub(all) struct BooleanField {
    title : String?
    description : String?
    default : Bool?
    meta :
    Json
    ?
    } derive(Eq)

    Cancel

    pub(all) struct Cancel {
    session_id : String
    meta :
    Json
    ?
    } derive(Eq)

    Stops whatever turn is running in a session. A notification, so it is never answered.

    Cancel::equal

    fn Cancel::equal(Cancel, Cancel) -> Bool
    automatically derived

    Cancel::not_equal

    fn Cancel::not_equal(x : Cancel, y : Cancel) -> Bool
    automatically derived

    Cancel::to_json

    ChoiceItems

    pub(all) enum ChoiceItems {
    Values(Array[String])
    Titled(Array[EnumOption])
    } derive(Eq)

    What a multi-select offers: bare values or titled ones.

    ChoiceItems::equal

    fn ChoiceItems::equal(ChoiceItems, ChoiceItems) -> Bool
    automatically derived

    ChoiceItems::not_equal

    fn ChoiceItems::not_equal(x : ChoiceItems, y : ChoiceItems) -> Bool
    automatically derived

    ChoiceItems::to_json

    ClientAuthCapabilities

    pub(all) struct ClientAuthCapabilities {
    terminal : Bool
    meta :
    Json
    ?
    } derive(Eq)

    Whether the client runs terminal commands for the agent.

    ClientAuthCapabilities::equal

    automatically derived

    ClientAuthCapabilities::none

    No terminal authentication offered by the client.

    ClientAuthCapabilities::not_equal

    automatically derived

    ClientAuthCapabilities::to_json

    ClientCapabilities

    pub(all) struct ClientCapabilities {
    fs : FileSystemCapabilities
    terminal : Bool
    session : ClientSessionCapabilities?
    auth : ClientAuthCapabilities?
    elicitation : ElicitationCapabilities?
    meta :
    Json
    ?
    } derive(Eq)

    Everything the client says it can do, sent with initialize.

    ClientCapabilities::equal

    automatically derived

    ClientCapabilities::none

    A client that reads and writes nothing, runs nothing, and answers no ask.

    ClientCapabilities::not_equal

    automatically derived

    ClientCapabilities::to_json

    ClientSessionCapabilities

    pub(all) struct ClientSessionCapabilities {
    compaction : Bool
    config_options : Bool
    booleans : Bool
    notices : Bool
    meta :
    Json
    ?
    } derive(Eq)

    The client's support for supplementary session features.

    ClientSessionCapabilities::equal

    automatically derived

    ClientSessionCapabilities::none

    No supplementary session features.

    ClientSessionCapabilities::not_equal

    automatically derived

    ClientSessionCapabilities::to_json

    CloseSession

    pub(all) struct CloseSession {
    session_id : String
    meta :
    Json
    ?
    } derive(Eq)

    Ends a session that is still running.

    CloseSession::equal

    automatically derived

    CloseSession::not_equal

    fn CloseSession::not_equal(x : CloseSession, y : CloseSession) -> Bool
    automatically derived

    CloseSession::to_json

    CommandInput

    pub(all) struct CommandInput {
    hint : String
    meta :
    Json
    ?
    } derive(Eq)

    The text typed after a command's name, offered to the user as a hint.

    CommandInput::equal

    automatically derived

    CommandInput::not_equal

    fn CommandInput::not_equal(x : CommandInput, y : CommandInput) -> Bool
    automatically derived

    CommandInput::to_json

    Compaction

    pub(all) struct Compaction {
    compaction_id : String
    status : CompactionStatus
    summary : Array[ContentBlock]?
    error : String?
    meta :
    Json
    ?
    } derive(Eq)

    A compaction, created the first time its identifier is seen and updated after that.

    Compaction::equal

    fn Compaction::equal(Compaction, Compaction) -> Bool
    automatically derived

    Compaction::not_equal

    fn Compaction::not_equal(x : Compaction, y : Compaction) -> Bool
    automatically derived

    Compaction::to_json

    CompactionStatus

    pub(all) enum CompactionStatus {
    InProgress
    Completed
    Failed
    Cancelled
    Other(String)
    } derive(Eq)

    Where a context compaction got to. Unknown states are kept as they came.

    CompactionStatus::equal

    automatically derived

    CompactionStatus::not_equal

    fn CompactionStatus::not_equal(x : CompactionStatus, y : CompactionStatus) -> Bool
    automatically derived

    CompactionStatus::of

    fn CompactionStatus::of(name : String) -> CompactionStatus

    The state with that name; unknown names are kept as they came.

    CompactionStatus::to_json

    CompactionStatus::to_string

    fn CompactionStatus::to_string(self : CompactionStatus) -> String

    The name the state travels as.

    CompactionSummary

    pub(all) struct CompactionSummary {
    compaction_id : String
    content : ContentBlock
    meta :
    Json
    ?
    } derive(Eq)

    ConfigCategory

    pub(all) enum ConfigCategory {
    Mode
    Model
    ModelConfig
    ThoughtLevel
    Other(String)
    } derive(Eq)

    What a configuration option is about, so a client can place it. Unknown categories are kept.

    ConfigCategory::equal

    automatically derived

    ConfigCategory::not_equal

    fn ConfigCategory::not_equal(x : ConfigCategory, y : ConfigCategory) -> Bool
    automatically derived

    ConfigCategory::of

    fn ConfigCategory::of(name : String) -> ConfigCategory

    The category with that name; unknown names are kept as they came.

    ConfigCategory::to_json

    ConfigCategory::to_string

    fn ConfigCategory::to_string(self : ConfigCategory) -> String

    The name the category travels as.

    ConfigChoice

    pub(all) struct ConfigChoice {
    value : String
    name : String
    description : String?
    meta :
    Json
    ?
    } derive(Eq)

    One value of a dropdown.

    ConfigChoice::equal

    automatically derived

    ConfigChoice::not_equal

    fn ConfigChoice::not_equal(x : ConfigChoice, y : ConfigChoice) -> Bool
    automatically derived

    ConfigChoice::to_json

    ConfigChoices

    pub(all) enum ConfigChoices {
    Flat(Array[ConfigChoice])
    Grouped(Array[ConfigGroup])
    } derive(Eq)

    The choices of a dropdown, flat or grouped. The two are told apart by whether the first entry carries group.

    ConfigChoices::equal

    automatically derived

    ConfigChoices::not_equal

    fn ConfigChoices::not_equal(x : ConfigChoices, y : ConfigChoices) -> Bool
    automatically derived

    ConfigChoices::to_json

    ConfigGroup

    pub(all) struct ConfigGroup {
    group : String
    name : String
    options : Array[ConfigChoice]
    meta :
    Json
    ?
    } derive(Eq)

    Choices under a heading.

    ConfigGroup::equal

    fn ConfigGroup::equal(ConfigGroup, ConfigGroup) -> Bool
    automatically derived

    ConfigGroup::not_equal

    fn ConfigGroup::not_equal(x : ConfigGroup, y : ConfigGroup) -> Bool
    automatically derived

    ConfigGroup::to_json

    ConfigOption

    pub(all) struct ConfigOption {
    id : String
    name : String
    description : String?
    category : ConfigCategory?
    value : ConfigValue
    meta :
    Json
    ?
    } derive(Eq)

    One entry of the session configuration picker.

    ConfigOption::equal

    automatically derived

    ConfigOption::not_equal

    fn ConfigOption::not_equal(x : ConfigOption, y : ConfigOption) -> Bool
    automatically derived

    ConfigOption::to_json

    ConfigValue

    pub(all) enum ConfigValue {
    Select(String, ConfigChoices)
    Boolean(Bool)
    } derive(Eq)

    What a configuration option holds: a picked value or a switch.

    ConfigValue::equal

    fn ConfigValue::equal(ConfigValue, ConfigValue) -> Bool
    automatically derived

    ConfigValue::not_equal

    fn ConfigValue::not_equal(x : ConfigValue, y : ConfigValue) -> Bool
    automatically derived

    ConfigValue::to_json

    ConfigValueId

    pub(all) enum ConfigValueId {
    Value(String)
    Boolean(Bool)
    } derive(Eq)

    Sets a configuration option. The wire has two shapes, a value id or a boolean, told apart by type.

    ConfigValueId::equal

    automatically derived

    ConfigValueId::not_equal

    fn ConfigValueId::not_equal(x : ConfigValueId, y : ConfigValueId) -> Bool
    automatically derived

    Conn

    pub struct Conn {
    peer :
    Peer

    client : &Client
    }

    A connection to an agent, from the editor's side. run takes messages in; the methods here send them out and wait for their answers.

    Conn::authenticate

    async fn Conn::authenticate(self : Conn, request : Authenticate) -> Unit raise Refused

    Runs one of the agent's authentication methods.

    Conn::call

    async fn Conn::call(self : Conn, name : String, params :
    Json
    ) ->
    Json
    raise Refused

    A call the protocol does not name: send it raw and read the answer raw.

    Conn::cancel

    async fn Conn::cancel(self : Conn, session_id : String) -> Unit raise Refused

    Asks the agent to stop the turn running in a session. A notice: nothing comes back, and the turn answers Cancelled on its own.

    Conn::client

    fn Conn::client(self : Conn) -> &Client

    The client this connection feeds.

    Conn::close_session

    async fn Conn::close_session(self : Conn, request : CloseSession) -> Unit raise Refused

    Ends a running session, as if session/cancel had been sent.

    Conn::delete_session

    async fn Conn::delete_session(self : Conn, request : DeleteSession) -> Unit raise Refused

    Forgets a session.

    Conn::initialize

    async fn Conn::initialize(self : Conn, request : Initialize) -> Initialized raise Refused

    Negotiates the version and trades capabilities. Call it once, before anything else.

    Conn::list_sessions

    async fn Conn::list_sessions(self : Conn, request : ListSessions) -> SessionList raise Refused

    The sessions the agent remembers, one page at a time.

    Conn::load_session

    async fn Conn::load_session(self : Conn, request : LoadSession) -> SessionStarted raise Refused

    Reopens a session; the updates that replay its history arrive on run.

    Conn::logout

    async fn Conn::logout(self : Conn) -> Unit raise Refused

    Drops whatever authenticate established.

    Conn::new_session

    async fn Conn::new_session(self : Conn, request : NewSession) -> SessionStarted raise Refused

    Starts a session and returns what the agent says about it: identifier, modes, options.

    Conn::notify

    async fn Conn::notify(self : Conn, name : String, params :
    Json
    ) -> Unit raise Refused

    A notice the protocol does not name.

    Conn::prompt

    async fn Conn::prompt(self : Conn, request : Prompt) -> PromptResult raise Refused

    Sends one turn and waits for its answer. Updates arrive through the client's update while this waits, because the connection is being run in another task.

    Conn::resume_session

    async fn Conn::resume_session(self : Conn, request : ResumeSession) -> SessionStarted raise Refused

    Reattaches to a live session without replaying anything.

    Conn::run

    async fn Conn::run(self : Conn) -> Unit

    Takes messages in until the other side goes away. Updates reach the client from here, so it has to run in a task of its own while the other tasks call the agent.

    Conn::set_config_option

    async fn Conn::set_config_option(self : Conn, request : SetConfigOption) -> Array[ConfigOption] raise Refused

    Sets one configuration option and returns the whole list, as the protocol requires.

    Conn::set_mode

    async fn Conn::set_mode(self : Conn, request : SetMode) -> Unit raise Refused

    Switches the session's mode.

    Content

    pub(all) struct Content {
    content : ContentBlock
    meta :
    Json
    ?
    } derive(Eq)

    A standard content block wrapped for a tool call's output.

    Content::equal

    fn Content::equal(Content, Content) -> Bool
    automatically derived

    Content::not_equal

    fn Content::not_equal(x : Content, y : Content) -> Bool
    automatically derived

    Content::to_json

    ContentBlock

    pub(all) enum ContentBlock {
    Text(TextContent)
    Image(ImageContent)
    Audio(AudioContent)
    ResourceLink(ResourceLink)
    Resource(EmbeddedResource)
    } derive(Eq)

    One displayable piece of a prompt or of a tool's output, tagged by type on the wire.

    ContentBlock::equal

    automatically derived

    ContentBlock::not_equal

    fn ContentBlock::not_equal(x : ContentBlock, y : ContentBlock) -> Bool
    automatically derived

    ContentBlock::to_json

    ContentChunk

    pub(all) struct ContentChunk {
    content : ContentBlock
    message_id : String?
    meta :
    Json
    ?
    } derive(Eq)

    One streamed item of content.

    ContentChunk::equal

    automatically derived

    ContentChunk::not_equal

    fn ContentChunk::not_equal(x : ContentChunk, y : ContentChunk) -> Bool
    automatically derived

    ContentChunk::to_json

    Cost

    pub(all) struct Cost {
    amount : Double
    currency : String
    meta :
    Json
    ?
    } derive(Eq)

    What the turn cost, in whatever currency the agent bills in.

    Cost::equal

    fn Cost::equal(Cost, Cost) -> Bool
    automatically derived

    Cost::not_equal

    fn Cost::not_equal(x : Cost, y : Cost) -> Bool
    automatically derived

    Cost::to_json

    DeleteSession

    pub(all) struct DeleteSession {
    session_id : String
    meta :
    Json
    ?
    } derive(Eq)

    Removes a session from what session/list returns.

    DeleteSession::equal

    automatically derived

    DeleteSession::not_equal

    fn DeleteSession::not_equal(x : DeleteSession, y : DeleteSession) -> Bool
    automatically derived

    DeleteSession::to_json

    Diff

    pub(all) struct Diff {
    path : String
    new_text : String
    old_text : String?
    meta :
    Json
    ?
    } derive(Eq)

    A file edit, given as the whole file before and after.

    Diff::equal

    fn Diff::equal(Diff, Diff) -> Bool
    automatically derived

    Diff::not_equal

    fn Diff::not_equal(x : Diff, y : Diff) -> Bool
    automatically derived

    Diff::to_json

    ElicitScope

    pub(all) enum ElicitScope {
    OfSession(String, String?)
    OfRequest(
    Json
    )
    } derive(Eq)

    Which request an elicitation belongs to: a session's turn, or a bare JSON-RPC request.

    ElicitScope::equal

    fn ElicitScope::equal(ElicitScope, ElicitScope) -> Bool
    automatically derived

    ElicitScope::not_equal

    fn ElicitScope::not_equal(x : ElicitScope, y : ElicitScope) -> Bool
    automatically derived

    ElicitScope::to_json

    Elicitation

    pub(all) enum Elicitation {
    Form(FormRequest)
    Url(UrlRequest)
    } derive(Eq)

    An ask, tagged by mode on the wire.

    Elicitation::equal

    fn Elicitation::equal(Elicitation, Elicitation) -> Bool
    automatically derived

    Elicitation::not_equal

    fn Elicitation::not_equal(x : Elicitation, y : Elicitation) -> Bool
    automatically derived

    Elicitation::to_json

    ElicitationCapabilities

    pub(all) struct ElicitationCapabilities {
    form : Bool
    url : Bool
    meta :
    Json
    ?
    } derive(Eq)

    ElicitationSchema

    pub(all) struct ElicitationSchema {
    properties : Map[String, Field]
    required : Array[String]?
    title : String?
    description : String?
    meta :
    Json
    ?
    } derive(Eq)

    EmbeddedResource

    pub(all) struct EmbeddedResource {
    resource : Resource
    annotations : Annotations?
    meta :
    Json
    ?
    } derive(Eq)

    EnumOption

    pub(all) struct EnumOption {
    value : String
    title : String
    description : String?
    meta :
    Json
    ?
    } derive(Eq)

    One titled choice of a string field.

    EnumOption::equal

    fn EnumOption::equal(EnumOption, EnumOption) -> Bool
    automatically derived

    EnumOption::not_equal

    fn EnumOption::not_equal(x : EnumOption, y : EnumOption) -> Bool
    automatically derived

    EnumOption::to_json

    EnvVariable

    pub(all) struct EnvVariable {
    name : String
    value : String
    meta :
    Json
    ?
    } derive(Eq)

    One environment variable for a spawned MCP server.

    EnvVariable::equal

    fn EnvVariable::equal(EnvVariable, EnvVariable) -> Bool
    automatically derived

    EnvVariable::not_equal

    fn EnvVariable::not_equal(x : EnvVariable, y : EnvVariable) -> Bool
    automatically derived

    EnvVariable::to_json

    ExitStatus

    pub(all) struct ExitStatus {
    exit_code : Int64?
    signal : String?
    meta :
    Json
    ?
    } derive(Eq)

    How a command ended.

    ExitStatus::equal

    fn ExitStatus::equal(ExitStatus, ExitStatus) -> Bool
    automatically derived

    ExitStatus::not_equal

    fn ExitStatus::not_equal(x : ExitStatus, y : ExitStatus) -> Bool
    automatically derived

    ExitStatus::to_json

    Field

    pub(all) enum Field {
    Text(TextField)
    Number(NumberField)
    Integer(IntegerField)
    Boolean(BooleanField)
    MultiSelect(MultiSelectField)
    Other(
    Json
    )
    } derive(Eq)

    One field of a form, tagged by type on the wire. A kind the protocol does not define yet is kept as it came so a client can still show it.

    Field::equal

    fn Field::equal(Field, Field) -> Bool
    automatically derived

    Field::not_equal

    fn Field::not_equal(x : Field, y : Field) -> Bool
    automatically derived

    Field::to_json

    FileSystemCapabilities

    pub(all) struct FileSystemCapabilities {
    read_text_file : Bool
    write_text_file : Bool
    meta :
    Json
    ?
    } derive(Eq)

    Files the client lets the agent read and write on its behalf.

    FileSystemCapabilities::equal

    automatically derived

    FileSystemCapabilities::none

    No file access granted.

    FileSystemCapabilities::not_equal

    automatically derived

    FileSystemCapabilities::to_json

    FileText

    pub(all) struct FileText {
    content : String
    meta :
    Json
    ?
    } derive(Eq)

    What a read returns.

    FileText::equal

    fn FileText::equal(FileText, FileText) -> Bool
    automatically derived

    FileText::not_equal

    fn FileText::not_equal(x : FileText, y : FileText) -> Bool
    automatically derived

    FileText::to_json

    FormRequest

    pub(all) struct FormRequest {
    message : String
    schema : ElicitationSchema
    scope : ElicitScope
    meta :
    Json
    ?
    } derive(Eq)

    A form for the user to fill in.

    FormRequest::equal

    fn FormRequest::equal(FormRequest, FormRequest) -> Bool
    automatically derived

    FormRequest::not_equal

    fn FormRequest::not_equal(x : FormRequest, y : FormRequest) -> Bool
    automatically derived

    FormRequest::to_json

    HttpHeader

    pub(all) struct HttpHeader {
    name : String
    value : String
    meta :
    Json
    ?
    } derive(Eq)

    One header sent to an MCP server.

    HttpHeader::equal

    fn HttpHeader::equal(HttpHeader, HttpHeader) -> Bool
    automatically derived

    HttpHeader::not_equal

    fn HttpHeader::not_equal(x : HttpHeader, y : HttpHeader) -> Bool
    automatically derived

    HttpHeader::to_json

    ImageContent

    pub(all) struct ImageContent {
    data : String
    mime_type : String
    uri : String?
    annotations : Annotations?
    meta :
    Json
    ?
    } derive(Eq)

    An image, base64 in data.

    ImageContent::equal

    automatically derived

    ImageContent::not_equal

    fn ImageContent::not_equal(x : ImageContent, y : ImageContent) -> Bool
    automatically derived

    ImageContent::to_json

    Implementation

    pub(all) struct Implementation {
    name : String
    version : String
    title : String?
    meta :
    Json
    ?
    } derive(Eq)

    A name and version, for the log and the about box.

    Implementation::equal

    automatically derived

    Implementation::new

    fn Implementation::new(name : String, version : String) -> Implementation

    A name and a version, which is all the protocol asks for.

    Implementation::not_equal

    fn Implementation::not_equal(x : Implementation, y : Implementation) -> Bool
    automatically derived

    Implementation::to_json

    Initialize

    pub(all) struct Initialize {
    protocol_version : Int
    client_capabilities : ClientCapabilities
    client_info : Implementation?
    meta :
    Json
    ?
    } derive(Eq)

    Opens the conversation: versions and capabilities, once per connection.

    Initialize::equal

    fn Initialize::equal(Initialize, Initialize) -> Bool
    automatically derived

    Initialize::not_equal

    fn Initialize::not_equal(x : Initialize, y : Initialize) -> Bool
    automatically derived

    Initialize::to_json

    Initialized

    pub(all) struct Initialized {
    protocol_version : Int
    capabilities : AgentCapabilities
    auth_methods : Array[AuthMethod]
    agent_info : Implementation?
    meta :
    Json
    ?
    } derive(Eq)

    The answer to initialize.

    Initialized::equal

    fn Initialized::equal(Initialized, Initialized) -> Bool
    automatically derived

    Initialized::new

    A first answer for an agent that supports nothing beyond session/new: the version, no capabilities, no authentication.

    Initialized::not_equal

    fn Initialized::not_equal(x : Initialized, y : Initialized) -> Bool
    automatically derived

    Initialized::to_json

    IntegerField

    pub(all) struct IntegerField {
    title : String?
    description : String?
    minimum : Int64?
    maximum : Int64?
    default : Int64?
    meta :
    Json
    ?
    } derive(Eq)

    A field for a whole number.

    IntegerField::equal

    automatically derived

    IntegerField::not_equal

    fn IntegerField::not_equal(x : IntegerField, y : IntegerField) -> Bool
    automatically derived

    IntegerField::to_json

    ListSessions

    pub(all) struct ListSessions {
    cwd : String?
    cursor : String?
    meta :
    Json
    ?
    } derive(Eq)

    Asks for the sessions the agent remembers.

    ListSessions::equal

    automatically derived

    ListSessions::not_equal

    fn ListSessions::not_equal(x : ListSessions, y : ListSessions) -> Bool
    automatically derived

    ListSessions::to_json

    LoadSession

    pub(all) struct LoadSession {
    session_id : String
    cwd : String
    additional_directories : Array[String]?
    mcp_servers : Array[McpServer]
    meta :
    Json
    ?
    } derive(Eq)

    Reopens a session and replays its history as updates.

    LoadSession::equal

    fn LoadSession::equal(LoadSession, LoadSession) -> Bool
    automatically derived

    LoadSession::not_equal

    fn LoadSession::not_equal(x : LoadSession, y : LoadSession) -> Bool
    automatically derived

    LoadSession::to_json

    McpCapabilities

    pub(all) struct McpCapabilities {
    http : Bool
    sse : Bool
    meta :
    Json
    ?
    } derive(Eq)

    MCP transports the agent can connect to.

    McpCapabilities::equal

    automatically derived

    McpCapabilities::none

    No MCP transport supported.

    McpCapabilities::not_equal

    fn McpCapabilities::not_equal(x : McpCapabilities, y : McpCapabilities) -> Bool
    automatically derived

    McpCapabilities::to_json

    McpHttp

    pub(all) struct McpHttp {
    name : String
    url : String
    headers : Array[HttpHeader]
    meta :
    Json
    ?
    } derive(Eq)

    An MCP server reached over HTTP.

    McpHttp::equal

    fn McpHttp::equal(McpHttp, McpHttp) -> Bool
    automatically derived

    McpHttp::not_equal

    fn McpHttp::not_equal(x : McpHttp, y : McpHttp) -> Bool
    automatically derived

    McpHttp::to_json

    McpServer

    pub(all) enum McpServer {
    Http(McpHttp)
    Sse(McpSse)
    Stdio(McpStdio)
    } derive(Eq)

    An MCP server a session may use. The wire tells the two HTTP shapes apart by type; the stdio shape carries no tag at all.

    McpServer::equal

    fn McpServer::equal(McpServer, McpServer) -> Bool
    automatically derived

    McpServer::not_equal

    fn McpServer::not_equal(x : McpServer, y : McpServer) -> Bool
    automatically derived

    McpServer::to_json

    McpSse

    pub(all) struct McpSse {
    name : String
    url : String
    headers : Array[HttpHeader]
    meta :
    Json
    ?
    } derive(Eq)

    An MCP server reached over the older HTTP plus SSE transport.

    McpSse::equal

    fn McpSse::equal(McpSse, McpSse) -> Bool
    automatically derived

    McpSse::not_equal

    fn McpSse::not_equal(x : McpSse, y : McpSse) -> Bool
    automatically derived

    McpSse::to_json

    McpStdio

    pub(all) struct McpStdio {
    name : String
    command : String
    args : Array[String]
    env : Array[EnvVariable]
    meta :
    Json
    ?
    } derive(Eq)

    An MCP server the client is to launch as a child process.

    McpStdio::equal

    fn McpStdio::equal(McpStdio, McpStdio) -> Bool
    automatically derived

    McpStdio::not_equal

    fn McpStdio::not_equal(x : McpStdio, y : McpStdio) -> Bool
    automatically derived

    McpStdio::to_json

    ModeChanged

    pub(all) struct ModeChanged {
    current_mode_id : String
    meta :
    Json
    ?
    } derive(Eq)

    The session's mode changed.

    ModeChanged::equal

    fn ModeChanged::equal(ModeChanged, ModeChanged) -> Bool
    automatically derived

    ModeChanged::not_equal

    fn ModeChanged::not_equal(x : ModeChanged, y : ModeChanged) -> Bool
    automatically derived

    ModeChanged::to_json

    MultiSelectField

    pub(all) struct MultiSelectField {
    title : String?
    description : String?
    min_items : Int64?
    max_items : Int64?
    items : ChoiceItems
    default : Array[String]?
    meta :
    Json
    ?
    } derive(Eq)

    NewSession

    pub(all) struct NewSession {
    cwd : String
    additional_directories : Array[String]?
    mcp_servers : Array[McpServer]
    meta :
    Json
    ?
    } derive(Eq)

    Starts a conversation. The working directory is where the agent reads and writes.

    NewSession::equal

    fn NewSession::equal(NewSession, NewSession) -> Bool
    automatically derived

    NewSession::not_equal

    fn NewSession::not_equal(x : NewSession, y : NewSession) -> Bool
    automatically derived

    NewSession::to_json

    Notice

    pub(all) struct Notice {
    severity : Severity
    title : String
    description : String?
    meta :
    Json
    ?
    } derive(Eq)

    Something to tell the user that is not part of the conversation.

    Notice::equal

    fn Notice::equal(Notice, Notice) -> Bool
    automatically derived

    Notice::not_equal

    fn Notice::not_equal(x : Notice, y : Notice) -> Bool
    automatically derived

    Notice::to_json

    NumberField

    pub(all) struct NumberField {
    title : String?
    description : String?
    minimum : Double?
    maximum : Double?
    default : Double?
    meta :
    Json
    ?
    } derive(Eq)

    A field for a fractional number.

    NumberField::equal

    fn NumberField::equal(NumberField, NumberField) -> Bool
    automatically derived

    NumberField::not_equal

    fn NumberField::not_equal(x : NumberField, y : NumberField) -> Bool
    automatically derived

    NumberField::to_json

    Outcome

    pub(all) enum Outcome {
    Selected(String)
    Cancelled
    } derive(Eq)

    What came back: one option chosen, or the ask dismissed.

    Outcome::equal

    fn Outcome::equal(Outcome, Outcome) -> Bool
    automatically derived

    Outcome::not_equal

    fn Outcome::not_equal(x : Outcome, y : Outcome) -> Bool
    automatically derived

    Outcome::to_json

    Permission

    pub(all) struct Permission {
    tool_call : ToolCallUpdate
    options : Array[PermissionOption]
    meta :
    Json
    ?
    } derive(Eq)

    The ask the agent makes: run this tool call, and here is what the user may choose.

    Permission::equal

    fn Permission::equal(Permission, Permission) -> Bool
    automatically derived

    Permission::not_equal

    fn Permission::not_equal(x : Permission, y : Permission) -> Bool
    automatically derived

    Permission::to_json

    PermissionOption

    pub(all) struct PermissionOption {
    option_id : String
    name : String
    kind : PermissionOptionKind
    meta :
    Json
    ?
    } derive(Eq)

    PermissionOptionKind

    pub(all) enum PermissionOptionKind {
    AllowOnce
    AllowAlways
    RejectOnce
    RejectAlways
    } derive(Eq)

    What choosing an option means, so a client can group the buttons.

    PermissionOptionKind::equal

    automatically derived

    PermissionOptionKind::not_equal

    automatically derived

    PermissionOptionKind::of

    fn PermissionOptionKind::of(name : String) -> PermissionOptionKind?

    The option kind with that name, or None.

    PermissionOptionKind::to_json

    PermissionOptionKind::to_string

    fn PermissionOptionKind::to_string(self : PermissionOptionKind) -> String

    The name the option kind travels as.

    Plan

    pub(all) struct Plan {
    entries : Array[PlanEntry]
    meta :
    Json
    ?
    } derive(Eq)

    The whole plan, replacing whatever came before.

    Plan::equal

    fn Plan::equal(Plan, Plan) -> Bool
    automatically derived

    Plan::not_equal

    fn Plan::not_equal(x : Plan, y : Plan) -> Bool
    automatically derived

    Plan::to_json

    PlanEntry

    pub(all) struct PlanEntry {
    content : String
    priority : PlanEntryPriority
    status : PlanEntryStatus
    meta :
    Json
    ?
    } derive(Eq)

    One step of the agent's plan.

    PlanEntry::equal

    fn PlanEntry::equal(PlanEntry, PlanEntry) -> Bool
    automatically derived

    PlanEntry::not_equal

    fn PlanEntry::not_equal(x : PlanEntry, y : PlanEntry) -> Bool
    automatically derived

    PlanEntry::to_json

    PlanEntryPriority

    pub(all) enum PlanEntryPriority {
    High
    Medium
    Low
    } derive(Eq)

    How urgent a plan entry is.

    PlanEntryPriority::equal

    automatically derived

    PlanEntryPriority::not_equal

    fn PlanEntryPriority::not_equal(x : PlanEntryPriority, y : PlanEntryPriority) -> Bool
    automatically derived

    PlanEntryPriority::of

    fn PlanEntryPriority::of(name : String) -> PlanEntryPriority?

    The priority with that name, or None.

    PlanEntryPriority::to_json

    PlanEntryPriority::to_string

    fn PlanEntryPriority::to_string(self : PlanEntryPriority) -> String

    The name the priority travels as.

    PlanEntryStatus

    pub(all) enum PlanEntryStatus {
    Pending
    InProgress
    Completed
    } derive(Eq)

    How far a plan entry got.

    PlanEntryStatus::equal

    automatically derived

    PlanEntryStatus::not_equal

    fn PlanEntryStatus::not_equal(x : PlanEntryStatus, y : PlanEntryStatus) -> Bool
    automatically derived

    PlanEntryStatus::of

    fn PlanEntryStatus::of(name : String) -> PlanEntryStatus?

    The status with that name, or None.

    PlanEntryStatus::to_json

    PlanEntryStatus::to_string

    fn PlanEntryStatus::to_string(self : PlanEntryStatus) -> String

    The name the status travels as.

    Prompt

    pub(all) struct Prompt {
    session_id : String
    prompt : Array[ContentBlock]
    meta :
    Json
    ?
    } derive(Eq)

    One turn of the conversation.

    Prompt::equal

    fn Prompt::equal(Prompt, Prompt) -> Bool
    automatically derived

    Prompt::not_equal

    fn Prompt::not_equal(x : Prompt, y : Prompt) -> Bool
    automatically derived

    Prompt::to_json

    PromptCapabilities

    pub(all) struct PromptCapabilities {
    image : Bool
    audio : Bool
    embedded_context : Bool
    meta :
    Json
    ?
    } derive(Eq)

    Content kinds the agent accepts inside a prompt.

    PromptCapabilities::equal

    automatically derived

    PromptCapabilities::none

    Nothing supported: no images, no audio, no embedded context.

    PromptCapabilities::not_equal

    automatically derived

    PromptCapabilities::to_json

    PromptResult

    pub(all) struct PromptResult {
    stop_reason : StopReason
    meta :
    Json
    ?
    } derive(Eq)

    The answer to a prompt: why the turn ended.

    PromptResult::equal

    automatically derived

    PromptResult::not_equal

    fn PromptResult::not_equal(x : PromptResult, y : PromptResult) -> Bool
    automatically derived

    PromptResult::to_json

    ReadTextFile

    pub(all) struct ReadTextFile {
    session_id : String
    path : String
    line : Int64?
    limit : Int64?
    meta :
    Json
    ?
    } derive(Eq)

    Resource

    pub(all) enum Resource {
    Text(TextResource)
    Blob(BlobResource)
    } derive(Eq)

    Either kind of embedded resource contents, told apart by text against blob.

    Resource::equal

    fn Resource::equal(Resource, Resource) -> Bool
    automatically derived

    Resource::not_equal

    fn Resource::not_equal(x : Resource, y : Resource) -> Bool
    automatically derived

    Resource::to_json

    pub(all) struct ResourceLink {
    uri : String
    name : String
    title : String?
    description : String?
    mime_type : String?
    size : Int64?
    annotations : Annotations?
    meta :
    Json
    ?
    } derive(Eq)

    A resource the client can read, named by URI rather than by value.

    ResourceLink::equal

    automatically derived

    ResourceLink::not_equal

    fn ResourceLink::not_equal(x : ResourceLink, y : ResourceLink) -> Bool
    automatically derived

    ResourceLink::to_json

    ResumeSession

    pub(all) struct ResumeSession {
    session_id : String
    cwd : String
    additional_directories : Array[String]?
    mcp_servers : Array[McpServer]?
    meta :
    Json
    ?
    } derive(Eq)

    Reattaches to a session without replaying its history.

    ResumeSession::equal

    automatically derived

    ResumeSession::not_equal

    fn ResumeSession::not_equal(x : ResumeSession, y : ResumeSession) -> Bool
    automatically derived

    ResumeSession::to_json

    Role

    pub(all) enum Role {
    Assistant
    User
    } derive(Eq)

    Who a piece of content is for.

    Role::equal

    fn Role::equal(Role, Role) -> Bool
    automatically derived

    Role::not_equal

    fn Role::not_equal(x : Role, y : Role) -> Bool
    automatically derived

    Role::of

    fn Role::of(name : String) -> Role?

    The role with that name, or None.

    Role::to_json

    Role::to_string

    fn Role::to_string(self : Role) -> String

    The name the role travels as.

    Session

    pub struct Session {
    peer :
    Peer

    id : String
    }

    One session, as the agent sees it inside prompt. Everything here is a call to the client: updates, permission, files, terminals, elicitation.

    Session::elicit

    async fn Session::elicit(self : Session, ask : Elicitation) -> Answer raise Refused

    Asks the user for a few fields or for a visit to a URL. The ask is scoped to this session, and to the tool call it came from when one is given.

    Session::id

    fn Session::id(self : Session) -> String

    The session's identifier, the one the client sent with session/new.

    Session::read_text_file

    async fn Session::read_text_file(self : Session, path : String, line? : Int64, limit? : Int64) -> String raise Refused

    Reads a text file through the client, sliced from line when one is given.

    Session::request_permission

    async fn Session::request_permission(self : Session, ask : Permission) -> Outcome raise Refused

    Asks the user to allow a tool call. The client answers with the option it picked, or Cancelled when the prompt was dismissed; a client that never answers blocks the turn, so keep the ask in the turn's own task.

    Session::terminal

    async fn Session::terminal(self : Session, command : String, args? : Array[String], env? : Array[EnvVariable], cwd? : String, output_byte_limit? : Int64) -> Terminal raise Refused

    Runs a command in a terminal the client owns. The returned handle reads, waits for, kills and releases it.

    Session::update

    async fn Session::update(self : Session, update : SessionUpdate) -> Unit raise Refused

    Sends one update. Updates are notifications, so they are never answered and never fail the turn by themselves; the connection going away raises Closed.

    Session::write_text_file

    async fn Session::write_text_file(self : Session, path : String, content : String) -> Unit raise Refused

    Writes a text file through the client.

    SessionCapabilities

    pub(all) struct SessionCapabilities {
    list : Bool
    delete : Bool
    additional_directories : Bool
    resume_session : Bool
    close : Bool
    meta :
    Json
    ?
    } derive(Eq)

    Session methods beyond session/new. Each flag is a promise to answer that method.

    SessionCapabilities::equal

    automatically derived

    SessionCapabilities::none

    No session method beyond session/new.

    SessionCapabilities::not_equal

    automatically derived

    SessionCapabilities::to_json

    SessionInfo

    pub(all) struct SessionInfo {
    session_id : String
    cwd : String
    additional_directories : Array[String]?
    title : String?
    updated_at : String?
    meta :
    Json
    ?
    } derive(Eq)

    One row of session/list.

    SessionInfo::equal

    fn SessionInfo::equal(SessionInfo, SessionInfo) -> Bool
    automatically derived

    SessionInfo::not_equal

    fn SessionInfo::not_equal(x : SessionInfo, y : SessionInfo) -> Bool
    automatically derived

    SessionInfo::to_json

    SessionInfoChanged

    pub(all) struct SessionInfoChanged {
    title : String?
    updated_at : String?
    meta :
    Json
    ?
    } derive(Eq)

    The session's metadata changed; only the fields that changed are present.

    SessionInfoChanged::equal

    automatically derived

    SessionInfoChanged::not_equal

    automatically derived

    SessionInfoChanged::to_json

    SessionList

    pub(all) struct SessionList {
    sessions : Array[SessionInfo]
    next_cursor : String?
    meta :
    Json
    ?
    } derive(Eq)

    The page of sessions, and the cursor for the next one.

    SessionList::equal

    fn SessionList::equal(SessionList, SessionList) -> Bool
    automatically derived

    SessionList::not_equal

    fn SessionList::not_equal(x : SessionList, y : SessionList) -> Bool
    automatically derived

    SessionList::to_json

    SessionMode

    pub(all) struct SessionMode {
    id : String
    name : String
    description : String?
    meta :
    Json
    ?
    } derive(Eq)

    One mode the agent can work in.

    SessionMode::equal

    fn SessionMode::equal(SessionMode, SessionMode) -> Bool
    automatically derived

    SessionMode::not_equal

    fn SessionMode::not_equal(x : SessionMode, y : SessionMode) -> Bool
    automatically derived

    SessionMode::to_json

    SessionModes

    pub(all) struct SessionModes {
    current_mode_id : String
    available_modes : Array[SessionMode]
    meta :
    Json
    ?
    } derive(Eq)

    The modes on offer and the one in force.

    SessionModes::equal

    automatically derived

    SessionModes::not_equal

    fn SessionModes::not_equal(x : SessionModes, y : SessionModes) -> Bool
    automatically derived

    SessionModes::to_json

    SessionNotification

    pub(all) struct SessionNotification {
    session_id : String
    update : SessionUpdate
    meta :
    Json
    ?
    } derive(Eq)

    One update as it travels: the session it belongs to and the update itself.

    SessionNotification::equal

    automatically derived

    SessionNotification::not_equal

    automatically derived

    SessionNotification::to_json

    SessionStarted

    pub(all) struct SessionStarted {
    session_id : String
    modes : SessionModes?
    config_options : Array[ConfigOption]?
    meta :
    Json
    ?
    } derive(Eq)

    What session/new and its siblings answer with.

    SessionStarted::equal

    automatically derived

    SessionStarted::not_equal

    fn SessionStarted::not_equal(x : SessionStarted, y : SessionStarted) -> Bool
    automatically derived

    SessionStarted::to_json

    SessionUpdate

    pub(all) enum SessionUpdate {
    UserMessageChunk(ContentChunk)
    AgentMessageChunk(ContentChunk)
    AgentThoughtChunk(ContentChunk)
    ToolCall(ToolCall)
    ToolCallUpdate(ToolCallUpdate)
    Plan(Plan)
    AvailableCommands(AvailableCommands)
    ModeChanged(ModeChanged)
    ConfigOptionChanged(Array[ConfigOption])
    SessionInfoChanged(SessionInfoChanged)
    Usage(Usage)
    Notice(Notice)
    Compaction(Compaction)
    CompactionSummary(CompactionSummary)
    } derive(Eq)

    Everything the agent may tell the client mid-turn, tagged by sessionUpdate on the wire.

    SessionUpdate::equal

    automatically derived

    SessionUpdate::not_equal

    fn SessionUpdate::not_equal(x : SessionUpdate, y : SessionUpdate) -> Bool
    automatically derived

    SessionUpdate::to_json

    SetConfigOption

    pub(all) struct SetConfigOption {
    session_id : String
    config_id : String
    value : ConfigValueId
    meta :
    Json
    ?
    } derive(Eq)

    SetConfigOptions

    pub(all) struct SetConfigOptions {
    config_options : Array[ConfigOption]
    meta :
    Json
    ?
    } derive(Eq)

    The whole option list after one of them changed.

    SetConfigOptions::equal

    automatically derived

    SetConfigOptions::not_equal

    fn SetConfigOptions::not_equal(x : SetConfigOptions, y : SetConfigOptions) -> Bool
    automatically derived

    SetConfigOptions::to_json

    SetMode

    pub(all) struct SetMode {
    session_id : String
    mode_id : String
    meta :
    Json
    ?
    } derive(Eq)

    Picks a mode.

    SetMode::equal

    fn SetMode::equal(SetMode, SetMode) -> Bool
    automatically derived

    SetMode::not_equal

    fn SetMode::not_equal(x : SetMode, y : SetMode) -> Bool
    automatically derived

    SetMode::to_json

    Severity

    pub(all) enum Severity {
    Info
    Warning
    Error
    Other(String)
    } derive(Eq)

    How loud a notice is. Unknown severities are kept as they came.

    Severity::equal

    fn Severity::equal(Severity, Severity) -> Bool
    automatically derived

    Severity::not_equal

    fn Severity::not_equal(x : Severity, y : Severity) -> Bool
    automatically derived

    Severity::of

    fn Severity::of(name : String) -> Severity

    The severity with that name; unknown names are kept as they came.

    Severity::to_json

    Severity::to_string

    fn Severity::to_string(self : Severity) -> String

    The name the severity travels as.

    StopReason

    pub(all) enum StopReason {
    EndTurn
    MaxTokens
    MaxTurnRequests
    Refusal
    Cancelled
    } derive(Eq)

    Why the agent stopped.

    StopReason::equal

    fn StopReason::equal(StopReason, StopReason) -> Bool
    automatically derived

    StopReason::not_equal

    fn StopReason::not_equal(x : StopReason, y : StopReason) -> Bool
    automatically derived

    StopReason::of

    fn StopReason::of(name : String) -> StopReason?

    The reason with that name, or None.

    StopReason::to_json

    StopReason::to_string

    fn StopReason::to_string(self : StopReason) -> String

    The name the reason travels as.

    StringFormat

    pub(all) enum StringFormat {
    Email
    Uri
    Date
    DateTime
    } derive(Eq)

    A string field's format hint.

    StringFormat::equal

    automatically derived

    StringFormat::not_equal

    fn StringFormat::not_equal(x : StringFormat, y : StringFormat) -> Bool
    automatically derived

    StringFormat::of

    fn StringFormat::of(name : String) -> StringFormat?

    The format with that name, or None.

    StringFormat::to_json

    StringFormat::to_string

    fn StringFormat::to_string(self : StringFormat) -> String

    The name the format travels as.

    Terminal

    pub struct Terminal {
    session : Session
    terminal_id : String
    }

    A command running in a terminal the client owns. Holding one is not owning a process: release hands the terminal back, and the exit status is only known after wait.

    Terminal::id

    fn Terminal::id(self : Terminal) -> String

    The identifier the client gave this terminal.

    Terminal::kill

    async fn Terminal::kill(self : Terminal) -> Unit raise Refused

    Stops the command without giving the terminal back.

    Terminal::output

    async fn Terminal::output(self : Terminal) -> TerminalOutput raise Refused

    Everything the command has printed so far.

    Terminal::reference

    fn Terminal::reference(self : Terminal) -> TerminalRef

    The terminal as a tool call refers to it, for ToolCallContent.

    Terminal::release

    async fn Terminal::release(self : Terminal) -> Unit raise Refused

    Gives the terminal back. The client may reuse it for the next command.

    Terminal::wait

    async fn Terminal::wait(self : Terminal) -> ExitStatus raise Refused

    Waits for the command to exit and reports how it did.

    TerminalCommand

    pub(all) struct TerminalCommand {
    session_id : String
    command : String
    args : Array[String]?
    env : Array[EnvVariable]?
    cwd : String?
    output_byte_limit : Int64?
    meta :
    Json
    ?
    } derive(Eq)

    TerminalOpened

    pub(all) struct TerminalOpened {
    terminal_id : String
    meta :
    Json
    ?
    } derive(Eq)

    The identifier of the terminal the client opened.

    TerminalOpened::equal

    automatically derived

    TerminalOpened::not_equal

    fn TerminalOpened::not_equal(x : TerminalOpened, y : TerminalOpened) -> Bool
    automatically derived

    TerminalOpened::to_json

    TerminalOutput

    pub(all) struct TerminalOutput {
    output : String
    truncated : Bool
    exit_status : ExitStatus?
    meta :
    Json
    ?
    } derive(Eq)

    What a terminal has printed so far, and whether it has exited.

    TerminalOutput::equal

    automatically derived

    TerminalOutput::not_equal

    fn TerminalOutput::not_equal(x : TerminalOutput, y : TerminalOutput) -> Bool
    automatically derived

    TerminalOutput::to_json

    TerminalRef

    pub(all) struct TerminalRef {
    terminal_id : String
    meta :
    Json
    ?
    } derive(Eq)

    A reference to a terminal the client opened, embedded in a tool call.

    TerminalRef::equal

    fn TerminalRef::equal(TerminalRef, TerminalRef) -> Bool
    automatically derived

    TerminalRef::new

    fn TerminalRef::new(terminal_id : String) -> TerminalRef

    A reference to a terminal, as a tool call embeds it.

    TerminalRef::not_equal

    fn TerminalRef::not_equal(x : TerminalRef, y : TerminalRef) -> Bool
    automatically derived

    TerminalRef::to_json

    TerminalRequest

    pub(all) struct TerminalRequest {
    session_id : String
    terminal_id : String
    meta :
    Json
    ?
    } derive(Eq)

    Names an existing terminal, for terminal/output, terminal/wait_for_exit, terminal/kill and terminal/release.

    TerminalRequest::equal

    automatically derived

    TerminalRequest::not_equal

    fn TerminalRequest::not_equal(x : TerminalRequest, y : TerminalRequest) -> Bool
    automatically derived

    TerminalRequest::to_json

    TextContent

    pub(all) struct TextContent {
    text : String
    annotations : Annotations?
    meta :
    Json
    ?
    } derive(Eq)

    Text the model reads or writes.

    TextContent::equal

    fn TextContent::equal(TextContent, TextContent) -> Bool
    automatically derived

    TextContent::not_equal

    fn TextContent::not_equal(x : TextContent, y : TextContent) -> Bool
    automatically derived

    TextContent::to_json

    TextField

    pub(all) struct TextField {
    title : String?
    description : String?
    min_length : Int64?
    max_length : Int64?
    pattern : String?
    format : StringFormat?
    default : String?
    choices : Array[String]?
    titled_choices : Array[EnumOption]?
    meta :
    Json
    ?
    } derive(Eq)

    A field the user types into.

    TextField::equal

    fn TextField::equal(TextField, TextField) -> Bool
    automatically derived

    TextField::not_equal

    fn TextField::not_equal(x : TextField, y : TextField) -> Bool
    automatically derived

    TextField::to_json

    TextResource

    pub(all) struct TextResource {
    uri : String
    text : String
    mime_type : String?
    meta :
    Json
    ?
    } derive(Eq)

    Resource contents carried as text.

    TextResource::equal

    automatically derived

    TextResource::not_equal

    fn TextResource::not_equal(x : TextResource, y : TextResource) -> Bool
    automatically derived

    TextResource::to_json

    ToolCall

    pub(all) struct ToolCall {
    tool_call_id : String
    title : String
    name : String?
    kind : ToolKind?
    status : ToolCallStatus?
    content : Array[ToolCallContent]?
    locations : Array[ToolCallLocation]?
    raw_input :
    Json
    ?
    raw_output :
    Json
    ?
    meta :
    Json
    ?
    } derive(Eq)

    A tool call the model has asked for.

    ToolCall::equal

    fn ToolCall::equal(ToolCall, ToolCall) -> Bool
    automatically derived

    ToolCall::not_equal

    fn ToolCall::not_equal(x : ToolCall, y : ToolCall) -> Bool
    automatically derived

    ToolCall::to_json

    ToolCallContent

    pub(all) enum ToolCallContent {
    Content(Content)
    Diff(Diff)
    Terminal(TerminalRef)
    } derive(Eq)

    What a tool call produced, tagged by type on the wire.

    ToolCallContent::equal

    automatically derived

    ToolCallContent::not_equal

    fn ToolCallContent::not_equal(x : ToolCallContent, y : ToolCallContent) -> Bool
    automatically derived

    ToolCallContent::to_json

    ToolCallLocation

    pub(all) struct ToolCallLocation {
    path : String
    line : Int64?
    meta :
    Json
    ?
    } derive(Eq)

    ToolCallStatus

    pub(all) enum ToolCallStatus {
    Pending
    InProgress
    Completed
    Failed
    } derive(Eq)

    How far a tool call got.

    ToolCallStatus::equal

    automatically derived

    ToolCallStatus::not_equal

    fn ToolCallStatus::not_equal(x : ToolCallStatus, y : ToolCallStatus) -> Bool
    automatically derived

    ToolCallStatus::of

    fn ToolCallStatus::of(name : String) -> ToolCallStatus?

    The status with that name, or None.

    ToolCallStatus::to_json

    ToolCallStatus::to_string

    fn ToolCallStatus::to_string(self : ToolCallStatus) -> String

    The name the status travels as.

    ToolCallUpdate

    pub(all) struct ToolCallUpdate {
    tool_call_id : String
    kind : ToolKind?
    status : ToolCallStatus?
    title : String?
    name : String?
    content : Array[ToolCallContent]?
    locations : Array[ToolCallLocation]?
    raw_input :
    Json
    ?
    raw_output :
    Json
    ?
    meta :
    Json
    ?
    } derive(Eq)

    A later change to a tool call: only what changed is present.

    ToolCallUpdate::equal

    automatically derived

    ToolCallUpdate::not_equal

    fn ToolCallUpdate::not_equal(x : ToolCallUpdate, y : ToolCallUpdate) -> Bool
    automatically derived

    ToolCallUpdate::to_json

    ToolKind

    pub(all) enum ToolKind {
    Read
    Edit
    Delete
    Move
    Search
    Execute
    Think
    Fetch
    SwitchMode
    Other
    } derive(Eq)

    What kind of thing a tool does, for a client that wants to pick an icon.

    ToolKind::equal

    fn ToolKind::equal(ToolKind, ToolKind) -> Bool
    automatically derived

    ToolKind::not_equal

    fn ToolKind::not_equal(x : ToolKind, y : ToolKind) -> Bool
    automatically derived

    ToolKind::of

    fn ToolKind::of(name : String) -> ToolKind?

    The kind with that name, or None.

    ToolKind::to_json

    ToolKind::to_string

    fn ToolKind::to_string(self : ToolKind) -> String

    The name the kind travels as.

    UrlRequest

    pub(all) struct UrlRequest {
    message : String
    elicitation_id : String
    url : String
    scope : ElicitScope
    meta :
    Json
    ?
    } derive(Eq)

    A link the user follows.

    UrlRequest::equal

    fn UrlRequest::equal(UrlRequest, UrlRequest) -> Bool
    automatically derived

    UrlRequest::not_equal

    fn UrlRequest::not_equal(x : UrlRequest, y : UrlRequest) -> Bool
    automatically derived

    UrlRequest::to_json

    Usage

    pub(all) struct Usage {
    used : Int64
    size : Int64
    cost : Cost?
    meta :
    Json
    ?
    } derive(Eq)

    How much of the context window the conversation fills.

    Usage::equal

    fn Usage::equal(Usage, Usage) -> Bool
    automatically derived

    Usage::not_equal

    fn Usage::not_equal(x : Usage, y : Usage) -> Bool
    automatically derived

    Usage::to_json

    WriteTextFile

    pub(all) struct WriteTextFile {
    session_id : String
    path : String
    content : String
    meta :
    Json
    ?
    } derive(Eq)

    authentication_required

    let authentication_required : Int

    The client has to authenticate before this method works.

    connect

    fn connect(client : &Client, frames : &
    Frames
    ) -> Conn

    Wires a client to a transport. The caller runs the returned connection, which is what delivers updates and answers the agent's calls.

    failure_of

    fn failure_of(error : Error) ->
    Failure

    Turns anything a handler raised into the error object to send: the wire code is kept, and anything that is not a Refused becomes -32603 with no detail, because what a handler trips over is not the caller's to read.

    internal_error

    let internal_error : Int

    The handler failed for its own reasons.

    invalid_params

    let invalid_params : Int

    The parameters are not what the method takes.

    invalid_request

    let invalid_request : Int

    The value is not a valid message.

    method_not_found

    let method_not_found : Int

    Nobody handles that method.

    parse_error

    let parse_error : Int

    The text is not JSON.

    protocol_version

    let protocol_version : Int

    The protocol version this library speaks. It only changes when the protocol breaks.

    refused_of

    The reverse, for a call that came back with an error object.

    request_cancelled

    let request_cancelled : Int

    The caller asked for the work to stop.

    resource_not_found

    let resource_not_found : Int

    A path, a session or a resource named in the request does not exist.

    serve

    Serves an agent over any transport: the caller runs the returned peer. Messages are answered in the order they arrive, and batches are refused, because the protocol has none.