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
    session
    prompt
    streaming
    tool-call
    permission
    terminal
    elicitation
    protocol
    async
    server
    moonbit
    Download zip
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    10 hours ago
    Downloads
    6

    #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.

    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) {
    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:

    async fn main {
    @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.

    let child = @stdio.spawn(editor, ["/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.

    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.

    #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
    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

    The official conformance suite runs against the example agent on every push, and both official SDKs are driven in both directions. The suite's verdict is CONFORMANT, with every mandatory requirement and every capability the example advertises passing — including its advisory check that the agent connects to the MCP server a session is given. One gap remains, and it is listed rather than hidden:

    • The remote transport has not been driven by the official Rust SDK's HTTP client, which the Rust SDK does not publish yet.

    #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

    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

    AgentAuthCapabilities

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

    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

    AgentCapabilities::none

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

    AgentCapabilities::not_equal

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

    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

    Annotations::not_equal

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

    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

    Answer::not_equal

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

    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

    AuthMethod::not_equal

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

    AuthMethod::to_json

    AuthMethodAgent

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

    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)

    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)

    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

    Cancel::not_equal

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

    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

    ChoiceItems::not_equal

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

    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

    ClientAuthCapabilities::none

    No terminal authentication offered by the client.

    ClientAuthCapabilities::not_equal

    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

    ClientCapabilities::none

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

    ClientCapabilities::not_equal

    ClientCapabilities::to_json

    ClientSessionCapabilities

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

    CloseSession

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

    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

    CommandInput::not_equal

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

    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

    Compaction::not_equal

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

    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

    CompactionStatus::not_equal

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

    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

    ConfigCategory::not_equal

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

    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)

    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

    ConfigChoices::not_equal

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

    ConfigChoices::to_json

    ConfigGroup

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

    ConfigOption

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

    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

    ConfigValue::not_equal

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

    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

    ConfigValueId::not_equal

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

    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

    Content::not_equal

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

    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

    ContentBlock::not_equal

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

    ContentBlock::to_json

    ContentChunk

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

    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

    Cost::not_equal

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

    Cost::to_json

    DeleteSession

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

    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

    Diff::not_equal

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

    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

    ElicitScope::not_equal

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

    ElicitScope::to_json

    Elicitation

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

    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)

    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

    EnvVariable::not_equal

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

    EnvVariable::to_json

    ExitStatus

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

    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

    Field::not_equal

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

    Field::to_json

    FileSystemCapabilities

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

    FileText

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

    FormRequest

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

    HttpHeader

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

    ImageContent

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

    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

    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

    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

    Initialize::not_equal

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

    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

    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

    Initialized::to_json

    IntegerField

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

    ListSessions

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

    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

    LoadSession::not_equal

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

    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

    McpCapabilities::none

    No MCP transport supported.

    McpCapabilities::not_equal

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

    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

    McpHttp::not_equal

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

    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

    McpServer::not_equal

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

    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

    McpSse::not_equal

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

    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

    McpStdio::not_equal

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

    McpStdio::to_json

    ModeChanged

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

    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

    NewSession::not_equal

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

    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

    Notice::not_equal

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

    Notice::to_json

    NumberField

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

    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

    Outcome::not_equal

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

    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

    Permission::not_equal

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

    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

    PermissionOptionKind::not_equal

    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

    Plan::not_equal

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

    Plan::to_json

    PlanEntry

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

    PlanEntryPriority

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

    How urgent a plan entry is.

    PlanEntryPriority::equal

    PlanEntryPriority::not_equal

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

    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

    PlanEntryStatus::not_equal

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

    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

    Prompt::not_equal

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

    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

    PromptCapabilities::none

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

    PromptCapabilities::not_equal

    PromptCapabilities::to_json

    PromptResult

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

    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

    Resource::not_equal

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

    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

    ResourceLink::not_equal

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

    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)

    Role

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

    Who a piece of content is for.

    Role::equal

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

    Role::not_equal

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

    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

    SessionCapabilities::none

    No session method beyond session/new.

    SessionCapabilities::not_equal

    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)

    SessionInfoChanged

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

    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

    SessionList::not_equal

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

    SessionList::to_json

    SessionMode

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

    SessionModes

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

    SessionNotification

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

    SessionStarted

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

    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

    SessionUpdate::not_equal

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

    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)

    SetMode

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

    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

    Severity::not_equal

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

    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

    StopReason::not_equal

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

    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

    StringFormat::not_equal

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

    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)

    TerminalOutput

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

    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

    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

    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

    TerminalRequest::not_equal

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

    TerminalRequest::to_json

    TextContent

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

    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)

    TextResource

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

    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

    ToolCall::not_equal

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

    ToolCall::to_json

    ToolCallContent

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

    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

    ToolCallStatus::not_equal

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

    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)

    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

    ToolKind::not_equal

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

    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)

    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

    Usage::not_equal

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

    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.