#github.com/xulang-org/packages/a2a
Xu 0.16.0 API
import: a2a #github.com/xulang-org/packages/a2a
counts: 5 functions, 15 methods, 8 types, 0 constants, 0 method sets
External package `a2a #github.com/xulang-org/packages/a2a`, provided by github.com/xulang-org/packages.
github.com/xulang-org/packages · 1.17.2 · Install and use
struct AgentSkill
pub struct AgentSkill {
pub id string
pub name string
pub description string
}
Purpose
Structure encapsulating id, name, description.
Public fields
id string- field (string)
name string- name
description string- field (string)
struct AgentCard
pub struct AgentCard {
pub name string
pub description string
pub url string
pub version string
pub skills []AgentSkill
}
Purpose
Structure encapsulating name, description, url, version, skills.
Public fields
name string- name
description string- field (string)
url string- field (string)
version string- field (string)
skills []AgentSkill- field ([]AgentSkill)
struct TaskMessage
pub struct TaskMessage {
pub role string
pub text string
}
Purpose
Structure encapsulating role, text.
Public fields
role string- field (string)
text string- text
struct TaskArtifact
pub struct TaskArtifact {
pub name string
pub mime_type string
pub text string
}
Purpose
Structure encapsulating name, mime_type, text.
Public fields
name string- name
mime_type string- field (string)
text string- text
struct Task
pub struct Task {
pub id string
pub state string
pub history []TaskMessage
pub output string
pub artifacts []TaskArtifact
}
Purpose
Structure encapsulating id, state, history, output, artifacts.
Public fields
id string- field (string)
state string- field (string)
history []TaskMessage- field ([]TaskMessage)
output string- field (string)
artifacts []TaskArtifact- field ([]TaskArtifact)
struct StreamChunk
pub struct StreamChunk {
pub text string
pub done bool
}
Purpose
Structure encapsulating text, done.
Public fields
text string- text
done bool- field (bool)
struct Server
pub struct Server {
pub card AgentCard
}
Purpose
Structure encapsulating card.
Public fields
card AgentCard- field (AgentCard)
struct Client
pub struct Client {
pub base_url string
pub auth_token string
}
Purpose
A2a Client session maintaining connection and operations.
Public fields
base_url string- field (string)
auth_token string- field (string)
new_agent_card
pub fn new_agent_card(name string, description string, url string, version string) AgentCard
Purpose
Construct agent card.
Parameters
name string- name (string)
description string- description (string)
url string- url (string)
version string- version (string)
Returns
AgentCard — a value of this type
($&AgentCard) add_skill
pub fn (c $&AgentCard) add_skill(id string, name string, description string)
Purpose
Operation on $&AgentCard: add skill.
Parameters
c $&AgentCard- The
AgentCard instance used by this call (exclusive borrow).
id string- id (string)
name string- name (string)
description string- description (string)
Returns
This call does not return a value.
format_agent_card_json
pub fn format_agent_card_json(c &AgentCard) string
Purpose
Format as agent card json.
Parameters
c &AgentCard- byte or character code (read-only borrow; caller keeps the original; type &AgentCard)
Returns
string — result string
parse_agent_card_json
pub fn parse_agent_card_json(raw &string) AgentCard
Purpose
Parse as agent card json. Throws on failure; handle the error or propagate it to the caller.
Parameters
raw &string- raw (read-only borrow; caller keeps the original; type &string)
Returns
AgentCard — a value of this type
new_server
pub fn new_server(card AgentCard, handler fn(&string, &string) string) Server
Purpose
Construct server.
Parameters
card AgentCard- card (AgentCard)
handler fn(&string, &string) string- handler (function value; type fn(&string, &string) string)
Returns
Server — a value of this type
($&Server) set_stream_handler
pub fn (s $&Server) set_stream_handler(handler fn(&string, &string, chan StreamChunk) string)
Purpose
Operation on $&Server: set stream handler.
Parameters
s $&Server- The
Server instance used by this call (exclusive borrow).
handler fn(&string, &string, chan StreamChunk) string- handler (function value; type fn(&string, &string, chan StreamChunk) string)
Returns
This call does not return a value.
($&Server) set_api_key
pub fn (s $&Server) set_api_key(token string)
Purpose
Operation on $&Server: set api key.
Parameters
s $&Server- The
Server instance used by this call (exclusive borrow).
token string- token (string)
Returns
This call does not return a value.
($&Server) set_auth_hook
pub fn (s $&Server) set_auth_hook(hook fn(&string, &string) bool)
Purpose
Operation on $&Server: set auth hook.
Parameters
s $&Server- The
Server instance used by this call (exclusive borrow).
hook fn(&string, &string) bool- hook (function value; type fn(&string, &string) bool)
Returns
This call does not return a value.
($&Server) set_sqlite_store
pub fn (s $&Server) set_sqlite_store(path string) int
Purpose
Operation on $&Server: set sqlite store. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&Server- The
Server instance used by this call (exclusive borrow).
path string- filesystem path (string)
Returns
int — a value of this type
($&Server) handle_rpc
pub fn (s $&Server) handle_rpc(body &string) string
Purpose
Operation on $&Server: handle rpc.
Parameters
s $&Server- The
Server instance used by this call (exclusive borrow).
body &string- body (read-only borrow; caller keeps the original; type &string)
Returns
string — result string
($&Server) serve_http_server
pub fn (s $&Server) serve_http_server(srv $&http.Server) int
Purpose
Operation on $&Server: serve http server. Throws on failure; handle the error or propagate it to the caller.
Parameters
s $&Server- The
Server instance used by this call (exclusive borrow).
srv $&http.Server- srv (exclusive borrow; may modify the original; type $&http.Server)
Returns
int — a value of this type
new_client
pub fn new_client(base_url string) Client
Purpose
Construct client.
Parameters
base_url string- base_url (string)
Returns
Client — a value of this type
($&Client) set_auth_token
pub fn (c $&Client) set_auth_token(token string)
Purpose
Operation on $&Client: set auth token.
Parameters
c $&Client- The
Client instance used by this call (exclusive borrow).
token string- token (string)
Returns
This call does not return a value.
(&Client) discover
pub fn (c &Client) discover() AgentCard
Purpose
Execute discover on &Client. Throws on failure; handle the error or propagate it to the caller.
Parameters
c &Client- The
Client instance used by this call (borrow).
Returns
AgentCard — a value of this type
(&Client) send_task
pub fn (c &Client) send_task(id string, text string) Task
Purpose
Operation on &Client: send task. Throws on failure; handle the error or propagate it to the caller.
Parameters
c &Client- The
Client instance used by this call (borrow).
id string- id (string)
text string- text (string)
Returns
Task — a value of this type
(&Client) get_task
pub fn (c &Client) get_task(id string) Task
Purpose
Operation on &Client: read task. Throws on failure; handle the error or propagate it to the caller.
Parameters
c &Client- The
Client instance used by this call (borrow).
id string- id (string)
Returns
Task — a value of this type
(&Client) cancel_task
pub fn (c &Client) cancel_task(id string) Task
Purpose
Operation on &Client: cancel task. Throws on failure; handle the error or propagate it to the caller.
Parameters
c &Client- The
Client instance used by this call (borrow).
id string- id (string)
Returns
Task — a value of this type
(&Client) send_task_stream_live
pub fn (c &Client) send_task_stream_live(id string, text string, on_event fn(Task) bool) []Task
Purpose
Operation on &Client: send task stream live. Throws on failure; handle the error or propagate it to the caller.
Parameters
c &Client- The
Client instance used by this call (borrow).
id string- id (string)
text string- text (string)
on_event fn(Task) bool- on_event (function value; type fn(Task) bool)
Returns
[]Task — slice result
(&Client) send_task_stream_chan
pub fn (c &Client) send_task_stream_chan(id string, text string, ch chan Task) []Task
Purpose
Operation on &Client: send task stream chan. Throws on failure; handle the error or propagate it to the caller.
Parameters
c &Client- The
Client instance used by this call (borrow).
id string- id (string)
text string- text (string)
ch chan Task- character code (channel; type chan Task)
Returns
[]Task — slice result
(&Client) send_task_stream
pub fn (c &Client) send_task_stream(id string, text string) []Task
Purpose
Operation on &Client: send task stream. Throws on failure; handle the error or propagate it to the caller.
Parameters
c &Client- The
Client instance used by this call (borrow).
id string- id (string)
text string- text (string)
Returns
[]Task — slice result