MoonA2A
API reference

Every public name.

Every public type, function and constant, grouped by package. Generated from pkg.generated.mbti and the sources' own documentation comments, so it says what the code says.

@moona2a

import { "moonbitstack/moona2a" }

Types

AgentCapabilities

struct
pub(all) struct AgentCapabilities

What optional parts of the protocol an agent does (A2A AgentCapabilities).

  • streaming : Bool
  • push_notifications : Bool
  • extended_agent_card : Bool
  • extensions : Array[AgentExtension]
Methods
pub fn AgentCapabilities::plain() -> Self

An agent that answers in a single body and sends nothing out of band.

pub fn AgentCapabilities::streaming_and_push() -> Self

An agent that streams, sends push notifications and serves no extended card.

Trait methods
pub fn AgentCapabilities::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn AgentCapabilities::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn AgentCapabilities::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn AgentCapabilities::to_json(Self) -> @json.Json

AgentCard

struct
pub(all) struct AgentCard

An agent's self-description, the document a caller reads before talking to it (A2A AgentCard).

  • name : String
  • description : String
  • supported_interfaces : Array[AgentInterface]
  • provider : AgentProvider?
  • version : String
  • documentation_url : String?
  • capabilities : AgentCapabilities
  • security_schemes : @json.Json?
  • security_requirements : @json.Json?
  • default_input_modes : Array[String]
  • default_output_modes : Array[String]
  • skills : Array[AgentSkill]
  • signatures : @json.Json?
  • icon_url : String?
Methods
pub fn AgentCard::new(String, String, String, String, Array[AgentSkill]) -> Self

A card with no provider, no security and no signatures, serving text in and out.

name Stringdescription Stringversion Stringurl Stringskills Array[AgentSkill]
pub fn AgentCard::capable(Self, AgentCapabilities) -> Self

The same card advertising capabilities.

capabilities AgentCapabilities
pub fn AgentCard::input_modes(Self) -> Array[String]

The media types the card offers to take, from its defaults and its skills together.

pub fn AgentCard::preferred(Self) -> AgentInterface?

The interface a client should try first, which is the one the card lists first.

Trait methods
pub fn AgentCard::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn AgentCard::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn AgentCard::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn AgentCard::to_json(Self) -> @json.Json

AgentExtension

struct
pub(all) struct AgentExtension

A protocol extension an agent speaks (A2A AgentExtension).

  • uri : String
  • description : String?
  • required : Bool
  • params : @json.Json?
Trait methods
pub fn AgentExtension::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn AgentExtension::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn AgentExtension::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn AgentExtension::to_json(Self) -> @json.Json

AgentInterface

struct
pub(all) struct AgentInterface

One address an agent answers on (A2A AgentInterface).

  • url : String
  • protocol_binding : String
  • protocol_version : String
  • tenant : String?
Methods
pub fn AgentInterface::json_rpc(String, protocol_version~ : String) -> Self

An interface speaking JSON-RPC at url.

url Stringprotocol_version~ String
Trait methods
pub fn AgentInterface::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn AgentInterface::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn AgentInterface::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn AgentInterface::to_json(Self) -> @json.Json

AgentProvider

struct
pub(all) struct AgentProvider

The provider of an agent (A2A AgentProvider).

  • organization : String
  • url : String
Trait methods
pub fn AgentProvider::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn AgentProvider::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn AgentProvider::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn AgentProvider::to_json(Self) -> @json.Json

AgentSkill

struct
pub(all) struct AgentSkill

One thing an agent is good at (A2A AgentSkill).

  • id : String
  • name : String
  • description : String
  • tags : Array[String]
  • examples : Array[String]
  • input_modes : Array[String]
  • output_modes : Array[String]
Methods
pub fn AgentSkill::new(String, String, String, Array[String]) -> Self

A skill named and described, tagged with tags, with no examples or modes of its own.

id Stringname Stringdescription Stringtags Array[String]
Trait methods
pub fn AgentSkill::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn AgentSkill::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn AgentSkill::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn AgentSkill::to_json(Self) -> @json.Json

Artifact

struct
pub(all) struct Artifact

An output a task produced (A2A Artifact).

  • artifact_id : String
  • name : String?
  • description : String?
  • parts : Array[Part]
  • extensions : Array[String]?
  • metadata : @json.Json?
Methods
pub fn Artifact::new(String, Array[Part]) -> Self

An artifact carrying parts under artifact_id.

artifact_id Stringparts Array[Part]
pub fn Artifact::named(Self, String) -> Self

The same artifact under name.

name String
pub fn Artifact::text(String, String) -> Self

An artifact carrying one text part.

artifact_id Stringtext String
pub fn Artifact::text_of(Self) -> String

The text of every text part, in order and with nothing added: a part is content, so joining must not invent characters between them.

Trait methods
pub fn Artifact::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn Artifact::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn Artifact::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn Artifact::to_json(Self) -> @json.Json

AuthenticationInfo

struct
pub(all) struct AuthenticationInfo

How the agent proves itself to the caller's webhook (A2A AuthenticationInfo).

  • scheme : String
  • credentials : String?
Methods
pub fn AuthenticationInfo::bearer(String) -> Self

A bearer token the agent sends with each notification.

token String
Trait methods
pub fn AuthenticationInfo::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn AuthenticationInfo::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn AuthenticationInfo::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn AuthenticationInfo::to_json(Self) -> @json.Json

CallableExecutor

struct
pub struct CallableExecutor
  • run : async (RequestContext, &EventSink) -> Unit
  • stop : async (String) -> Unit
Methods
pub fn CallableExecutor::new(run~ : async (RequestContext, &EventSink) -> Unit, stop~ : async (String) -> Unit) -> Self

An executor that works requests with run and stops tasks with stop.

run~ async (RequestContext, &EventSink) -> Unitstop~ async (String) -> Unit

Client

struct
pub struct Client
  • transport : &Transport
  • mut next : Int64
Methods
pub fn Client::new(&Transport) -> Self

A client talking to the agent behind transport.

transport &Transport

Collected

struct
pub struct Collected
  • taken : Array[StreamEvent]
Methods
pub fn Collected::new() -> Self

An empty collection.

pub fn Collected::events(Self) -> Array[StreamEvent]

The events the sink took, in the order they happened.

pub fn Collected::message(Self) -> Message?

The message the agent answered with directly, when the run produced one instead of a task.

Discard

struct
pub struct Discard

ListTasksQuery

struct
pub(all) struct ListTasksQuery

The filters a list request carries (A2A ListTasksRequest).

  • context_id : String?
  • state : TaskState?
  • page_size : Int32?
  • page_token : String?
  • history_length : Int32?
  • status_timestamp_after : String?
  • include_artifacts : Bool
  • tenant : String?
Methods
pub fn ListTasksQuery::all() -> Self

No filter at all: every task the caller may see.

pub fn ListTasksQuery::in_context(Self, String) -> Self

The same query, limited to one conversation.

context_id String
Trait methods
pub fn ListTasksQuery::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn ListTasksQuery::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn ListTasksQuery::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn ListTasksQuery::to_json(Self) -> @json.Json

MemoryStore

struct
pub struct MemoryStore
  • tasks : Map[String, Task]
  • mut order : Array[String]
  • capacity : Int32
Methods
pub fn MemoryStore::new(capacity? : Int32) -> Self

An empty store holding up to capacity tasks.

capacity? Int32
Trait methods
pub fn MemoryStore::all(Self) -> Array[Task]
pub fn MemoryStore::get(Self, String) -> Task?
pub fn MemoryStore::put(Self, Task) -> Unit
pub fn MemoryStore::remove(Self, String) -> Unit

Message

struct
pub(all) struct Message

One turn of a conversation between a client and an agent (A2A Message).

  • message_id : String
  • role : Role
  • parts : Array[Part]
  • context_id : String?
  • task_id : String?
  • reference_task_ids : Array[String]?
  • extensions : Array[String]?
  • metadata : @json.Json?
Methods
pub fn Message::new(String, Role, Array[Part]) -> Self

A message from role carrying parts.

message_id Stringrole Roleparts Array[Part]
pub fn Message::agent(String, String) -> Self

A message from the agent, carrying one text part.

message_id Stringtext String
pub fn Message::in_task(Self, String, String) -> Self

The same message, continuing the task and context given.

task_id Stringcontext_id String
pub fn Message::text(Self) -> String

The text of every text part, in order and with nothing added: a part is content, so joining must not invent characters between them.

pub fn Message::user(String, String) -> Self

A message from the client, carrying one text part.

message_id Stringtext String
Trait methods
pub fn Message::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn Message::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn Message::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn Message::to_json(Self) -> @json.Json

Method

enum
pub(all) enum Method

Every method of the JSON-RPC binding.

  • SendMessage
  • SendStreamingMessage
  • GetTask
  • ListTasks
  • CancelTask
  • SubscribeToTask
  • CreatePushConfig
  • GetPushConfig
  • ListPushConfigs
  • DeletePushConfig
  • GetExtendedCard
Methods
pub fn Method::from_name(String) -> Self?

The method that goes by name, when it is one of the protocol's.

name String
pub fn Method::name(Self) -> String

The name the method goes by on the wire: PascalCase, as section 9.1 requires.

pub fn Method::streams(Self) -> Bool

Whether the answer to this method is a stream of events rather than a single body.

Trait methods
pub fn Method::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn Method::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

Part

struct
pub(all) struct Part

One piece of a message or an artifact (A2A Part).

  • content : PartContent
  • metadata : @json.Json?
Methods
pub fn Part::bytes(Bytes, filename? : String, media_type? : String) -> Self

A part carrying bytes inline.

bytes Bytesfilename? Stringmedia_type? String
pub fn Part::data(@json.Json) -> Self

A part carrying a structured JSON value.

data Json
pub fn Part::media_type(Self) -> String?

The media type this part declares, when it declares one.

pub fn Part::text(String) -> Self

A text part.

text String
pub fn Part::text_of(Self) -> String?

The text this part carries, when it is a text part.

pub fn Part::uri(String, filename? : String, media_type? : String) -> Self

A part pointing at content by URL.

url Stringfilename? Stringmedia_type? String
pub fn Part::with_metadata(Self, @json.Json) -> Self

The same part with metadata attached.

metadata Json
Trait methods
pub fn Part::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn Part::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn Part::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn Part::to_json(Self) -> @json.Json

PartContent

enum
pub(all) enum PartContent

What a part carries (A2A Part.content oneof).

  • Text(String)
  • Raw(bytes~ : Bytes, filename~ : String?, media_type~ : String?)
  • Url(url~ : String, filename~ : String?, media_type~ : String?)
  • Data(@json.Json)
Trait methods
pub fn PartContent::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn PartContent::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

PushConfigPage

struct
pub(all) struct PushConfigPage

One page of a task's registrations (A2A ListTaskPushNotificationConfigsResponse).

  • configs : Array[TaskPushConfig]
  • next_page_token : String
Trait methods
pub fn PushConfigPage::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn PushConfigPage::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn PushConfigPage::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn PushConfigPage::to_json(Self) -> @json.Json

RequestContext

struct
pub(all) struct RequestContext

What an executor is given when it is asked to work a request: the message, the ids it belongs to, and the task as it stands when the message continues one.

  • message : Message
  • task_id : String
  • context_id : String
  • task : Task?
Methods
pub fn RequestContext::artifact(Self, Artifact, append? : Bool, last_chunk? : Bool) -> StreamEvent

The event that hands this request's caller artifact, or more of one.

artifact Artifactappend? Boollast_chunk? Bool
pub fn RequestContext::replying(Self, Array[Part]) -> StreamEvent

A message this request's caller receives outside the task. An executor that says only this answers with a message instead of opening a task.

parts Array[Part]
pub fn RequestContext::status(Self, TaskState) -> StreamEvent

The event that moves this request's task to state.

state TaskState

Role

enum
pub(all) enum Role

The sender of a message (A2A Role).

  • Unspecified
  • User
  • Agent
Methods
pub fn Role::from_wire(String) -> Self

The role named by its wire form. Both the proto name and the bare word are read, because clients written against earlier drafts send the bare word.

name String
pub fn Role::wire(Self) -> String

The wire name of the role, as ProtoJSON writes an enum.

Trait methods
pub fn Role::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn Role::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn Role::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn Role::to_json(Self) -> @json.Json

SendMessageConfig

struct
pub(all) struct SendMessageConfig

How a send request should be handled: whether to wait, how much history to bring back, and what the caller is willing to receive.

  • return_immediately : Bool
  • history_length : Int32?
  • accepted_output_modes : Array[String]
  • push : TaskPushConfig?
Methods
pub fn SendMessageConfig::at_most(Self, Int32) -> Self

The same configuration, bringing back at most history_length messages.

history_length Int32
pub fn SendMessageConfig::immediately(Self) -> Self

The same configuration, returning before the task finishes.

pub fn SendMessageConfig::pushing(Self, TaskPushConfig) -> Self

The same configuration, registering push for the task it creates.

push TaskPushConfig
pub fn SendMessageConfig::waiting() -> Self

Wait for the task to finish, and bring back its whole history.

Trait methods
pub fn SendMessageConfig::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn SendMessageConfig::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn SendMessageConfig::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn SendMessageConfig::to_json(Self) -> @json.Json

SendMessageRequest

struct
pub(all) struct SendMessageRequest

Everything a send request carries (A2A SendMessageRequest).

  • message : Message
  • configuration : SendMessageConfig?
  • metadata : @json.Json?
  • tenant : String?
Methods
pub fn SendMessageRequest::new(Message) -> Self

A request to send message with nothing else set.

message Message
Trait methods
pub fn SendMessageRequest::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn SendMessageRequest::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn SendMessageRequest::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn SendMessageRequest::to_json(Self) -> @json.Json

Server

struct
pub struct Server
  • state : ServerState
Methods
pub fn Server::new(&Executor, AgentCard) -> Self

A server for executor and card, keeping tasks in its own memory and sending no notifications.

executor &Executorcard AgentCard
pub fn Server::attach(Self, @async.TaskGroup[Unit]) -> Self

Let the server start runs in group when a caller asks not to wait. A run started this way outlives the request that asked for it, and stops when the group does.

group @async.TaskGroup[Unit]
pub fn Server::card(Self) -> AgentCard

The card this server publishes.

pub fn Server::card_json(Self) -> @json.Json

The public card as the well-known document serves it.

pub fn Server::configured(executor~ : &Executor, card~ : AgentCard, store~ : &TaskStore, notifier~ : &Notifier, config~ : ServerConfig) -> Self

A server over the given store, notifier and configuration.

executor~ &Executorcard~ AgentCardstore~ &TaskStorenotifier~ &Notifierconfig~ ServerConfig
pub fn Server::notifying(Self, &Notifier) -> Self

The same server, sending its push notifications through notifier.

notifier &Notifier
pub fn Server::storing(Self, &TaskStore) -> Self

The same server, keeping its tasks in store and sending notifications through notifier.

store &TaskStore
pub fn Server::under(Self, ServerConfig) -> Self

The same server under config.

config ServerConfig
pub fn Server::with_extended_card(Self, AgentCard) -> Self

The same server, handing an authenticated caller card instead of the public one.

card AgentCard

ServerConfig

struct
pub(all) struct ServerConfig

The defaults a server runs with.

  • history_limit : Int32
  • page_size : Int32
  • max_page_size : Int32
  • refuse_unknown_media : Bool
Methods
pub fn ServerConfig::new() -> Self

A server that brings back the whole history, 50 tasks to a page, and no more than 100.

StreamEvent

enum
pub(all) enum StreamEvent

One item of a streamed response (A2A StreamResponse.payload oneof).

  • TaskSnapshot(Task)
  • TaskMessage(Message)
  • StatusChange(TaskStatusUpdate)
  • ArtifactChunk(TaskArtifactUpdate)
Methods
pub fn StreamEvent::is_final(Self) -> Bool

Whether the event ends the task for good.

pub fn StreamEvent::state(Self) -> TaskState?

The state this event reports, when it reports one.

pub fn StreamEvent::task_id(Self) -> String?

The task this event belongs to, when it belongs to one.

Trait methods
pub fn StreamEvent::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn StreamEvent::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn StreamEvent::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn StreamEvent::to_json(Self) -> @json.Json

Task

struct
pub(all) struct Task

A unit of work an agent runs on a caller's behalf (A2A Task).

  • id : String
  • context_id : String
  • status : TaskStatus
  • artifacts : Array[Artifact]
  • history : Array[Message]
  • metadata : @json.Json?
Methods
pub fn Task::new(String, String) -> Self

A new task in context_id, submitted and not yet worked on.

id Stringcontext_id String
pub fn Task::artifact(Self, String) -> Artifact?

The artifact with artifact_id, when the task has one.

artifact_id String
pub fn Task::encode(Self, view? : View) -> @json.Json

The task as the wire wants it, cut down to view.

view? View
pub fn Task::recent(Self, Int32?) -> Array[Message]

The most recent limit messages of the history; all of them when limit is unset.

limit Int32?
pub fn Task::saying(Self, Message) -> Self

The same task with message appended to its history.

message Message
pub fn Task::taking(Self, Artifact, Bool) -> Self

The same task with artifact added, or with the parts of an existing artifact of the same id replaced or appended to.

artifact Artifactappend Bool
pub fn Task::with_state(Self, TaskState) -> Self

The same task in state, with the clock stamped.

state TaskState
Trait methods
pub fn Task::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn Task::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn Task::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn Task::to_json(Self) -> @json.Json

TaskArtifactUpdate

struct
pub(all) struct TaskArtifactUpdate

An artifact was produced, or more of it arrived (A2A TaskArtifactUpdateEvent).

  • task_id : String
  • context_id : String
  • artifact : Artifact
  • append : Bool
  • last_chunk : Bool
  • metadata : @json.Json?
Methods
pub fn TaskArtifactUpdate::of(String, String, Artifact, append? : Bool, last_chunk? : Bool) -> Self

An artifact update event carrying artifact for the task with task_id.

task_id Stringcontext_id Stringartifact Artifactappend? Boollast_chunk? Bool
Trait methods
pub fn TaskArtifactUpdate::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn TaskArtifactUpdate::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn TaskArtifactUpdate::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn TaskArtifactUpdate::to_json(Self) -> @json.Json

TaskLog

struct
pub struct TaskLog
  • events : Array[StreamEvent]
  • mut open : Bool
Methods
pub fn TaskLog::new() -> Self

An empty log for a task that has not finished.

TaskPage

struct
pub(all) struct TaskPage

One page of tasks (A2A ListTasksResponse).

  • tasks : Array[Task]
  • next_page_token : String
  • page_size : Int32
  • total_size : Int32
Trait methods
pub fn TaskPage::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn TaskPage::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn TaskPage::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn TaskPage::to_json(Self) -> @json.Json

TaskPushConfig

struct
pub(all) struct TaskPushConfig

Where the agent posts a task's updates, and how it authenticates there (A2A TaskPushNotificationConfig).

  • id : String
  • task_id : String
  • url : String
  • token : String?
  • authentication : AuthenticationInfo?
  • tenant : String?
Methods
pub fn TaskPushConfig::new(String, String, String) -> Self

A registration of url for task_id, under id.

id Stringtask_id Stringurl String
pub fn TaskPushConfig::authenticating(Self, AuthenticationInfo) -> Self

The same registration, authenticating with authentication.

authentication AuthenticationInfo
pub fn TaskPushConfig::with_token(Self, String) -> Self

The same registration, carrying the caller's own token in each notification's headers.

token String
Trait methods
pub fn TaskPushConfig::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn TaskPushConfig::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn TaskPushConfig::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn TaskPushConfig::to_json(Self) -> @json.Json

TaskState

enum
pub(all) enum TaskState

The lifecycle state of a task (A2A TaskState).

  • Unspecified
  • Submitted
  • Working
  • Completed
  • Failed
  • Canceled
  • InputRequired
  • Rejected
  • AuthRequired
Methods
pub fn TaskState::from_wire(String) -> Self

The state named by its wire form. The proto name, the bare word and the hyphenated draft name are all read: a client written against an earlier draft sends input-required.

name String
pub fn TaskState::interrupted(Self) -> Bool

Whether the task is waiting on the caller and processing can resume from here.

pub fn TaskState::terminal(Self) -> Bool

Whether the task has finished for good: no further message, cancel or transition can apply.

pub fn TaskState::wire(Self) -> String

The wire name of the state, as ProtoJSON writes an enum.

Trait methods
pub fn TaskState::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn TaskState::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn TaskState::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn TaskState::to_json(Self) -> @json.Json

TaskStatus

struct
pub(all) struct TaskStatus

The state of a task, with the message and time that go with it (A2A TaskStatus).

  • state : TaskState
  • message : Message?
  • timestamp : String?
Methods
pub fn TaskStatus::of(TaskState) -> Self

A status with no message and no timestamp.

state TaskState
pub fn TaskStatus::recorded(TaskState) -> Self

The status of state, recorded now.

state TaskState
Trait methods
pub fn TaskStatus::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn TaskStatus::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn TaskStatus::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn TaskStatus::to_json(Self) -> @json.Json

TaskStatusUpdate

struct
pub(all) struct TaskStatusUpdate

A task changed state (A2A TaskStatusUpdateEvent).

  • task_id : String
  • context_id : String
  • status : TaskStatus
  • metadata : @json.Json?
Methods
pub fn TaskStatusUpdate::of(String, String, TaskState) -> Self

A status update event for the task with task_id, moving it to state.

task_id Stringcontext_id Stringstate TaskState
Trait methods
pub fn TaskStatusUpdate::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn TaskStatusUpdate::from_json(@json.Json, @json.JsonPath) -> Self raise @json.JsonDecodeError
pub fn TaskStatusUpdate::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

pub fn TaskStatusUpdate::to_json(Self) -> @json.Json

View

struct
pub(all) struct View

How much of a task a reply carries: whether its artifacts travel with it, and how many of the most recent messages do. None history means all of them.

  • artifacts : Bool
  • history : Int32?
Methods
pub fn View::bare() -> Self

The task alone, without what it produced.

pub fn View::full() -> Self

Everything the task has.

Trait methods
pub fn View::equal(Self, Self) -> Bool

Structural equality from Eq.

pub fn View::not_equal(Self, Self) -> Bool

The negation of equal, from Eq.

Errors

Refused

suberror
pub(all) suberror Refused

A refused operation, named as the specification names it. The string is the server's own note on what the caller did, empty when the name says everything.

  • TaskNotFound(String)
  • TaskNotCancelable(String)
  • PushNotificationNotSupported(String)
  • UnsupportedOperation(String)
  • ContentTypeNotSupported(String)
  • InvalidAgentResponse(String)
  • ExtendedAgentCardNotConfigured(String)
  • ExtensionSupportRequired(String)
  • VersionNotSupported(String)
  • InvalidRequest(String)
  • InvalidParams(String)

Functions

pub fn is_streaming_method(String) -> Bool

Whether name is one of the methods whose answer is a stream, for a transport that has to decide before reading the whole request.

name String
pub fn request_method(StringView) -> String?

The method this request asks for, so a transport can decide whether its answer is a stream before reading the whole body.

body StringView
pub fn timestamp_now() -> String

The current instant as an ISO 8601 timestamp in UTC, e.g. 2026-11-06T02:02:55.123Z.

Millisecond precision is what the specification asks for and all @env.now offers on every backend; a timestamp that is a few milliseconds coarse still orders correctly.

Constants

pub let card_path : String

Where the card is served (section 8.2).

pub let default_capacity : Int32

How many tasks an in-memory store keeps before it starts forgetting the ones that finished. 1024 is enough for a session's worth of work and small enough that a forgotten task cannot grow without bound.

pub let follow_tick_millis : Int32

How long a follower waits between looks at the log it is watching.

The log is the ordering guarantee, not the wake-up: a follower reads forward from its own cursor, so it sees every event once, in order, whether it woke on the first tick or the fifth. 25 milliseconds is short enough that a stream feels live and long enough that an idle subscription costs nothing worth measuring.

pub let protocol_version : String

The protocol version this library speaks, as a client writes it in A2A-Version.

@asgi

import { "moonbitstack/moona2a/asgi" }

Types

Options

struct
pub(all) struct Options

Where the endpoint answers, and how long a client may cache the card.

  • rpc_path : String
  • card_path : String
  • cache_seconds : Int32
Methods
pub fn Options::new() -> Self

The endpoint at /, the card at its well-known address, and a card a client may keep for five minutes.

Functions

pub fn to_asgi(@moona2a.Server, options? : Options) -> async (@spec.Scope, async () -> @spec.Event, async (@spec.Event) -> Unit) -> Unit

The ASGI application for server: a GET of the card's well-known address answers with the card, a POST of a JSON-RPC body answers with a body or, for a streaming method, with a stream of server-sent events.

The application writes its events as it goes, rather than assembling one Response: a stream answer is only worth having if each event leaves as it happens.

server @moona2a.Serveroptions? Options

@fetch

import { "moonbitstack/moona2a/fetch" }

Types

HttpTransport

struct
pub(all) struct HttpTransport

The JSON-RPC endpoint of one agent, reached over HTTP.

  • client : @moonfetch.Client
  • path : String
  • card_path : String
Methods
pub fn HttpTransport::new(String, path? : String, card_path? : String) -> Self raise

A transport to the agent at url, e.g. https://agent.example.com, answering JSON-RPC on the root path and serving its card at the well-known one.

url Stringpath? Stringcard_path? String

Webhook

struct
pub(all) struct Webhook

A notifier that posts to whatever URL a registration names.

Errors

Unreachable

suberror
pub suberror Unreachable
  • Unreachable(String)

WrongShape

suberror
pub suberror WrongShape
  • WrongShape(String)

Functions

pub fn delivery_headers(@moona2a.TaskPushConfig) -> Array[(String, String)]

The headers a delivery goes out under: the payload type, the registration's token, and the credentials it names. Separate from the send so the part a caller cares about can be read without a webhook to read it from.

config @moona2a.TaskPushConfig

Constants

pub let token_header : String

How the token in a registration travels, when the caller set one. The specification names the field but not the header, so this is the name the rest of the ecosystem uses.

pub let webhook_timeout_millis : Int32

How long to wait for the caller's webhook before giving up on this delivery. Section 4.3.3 suggests ten to thirty seconds; ten keeps a slow webhook from holding a task's run.