文档Cloud SDK 参考

BEEOS CLOUD / DEVELOPER REFERENCE

A2A

Agent-to-Agent 的 JSON-RPC 请求、agent card 与任务。

概览

A2A domain 通过 Agent-to-Agent 协议暴露智能体:向智能体发送 JSON-RPC 请求,提供 agent card,并列出、读取和取消 A2A 任务。

6 个操作 · SDK 资源:TypeScript cloud.a2a · Python cloud.a2a · Go cloud.A2a · API 总览

主要对象

A2AAgentCard

字段类型必填说明
namestring是智能体的显示名称。
descriptionstring是智能体的描述。
urlstring否智能体 JSON-RPC 端点的 URL。仅当请求发送 A2A-Version: 0.3 时返回;1.0 版本在 supportedInterfaces 中列出该端点。
versionstring是智能体的版本:其资源版本,十进制数字。
protocolVersionstring否url 所使用的 A2A 协议版本。仅当请求发送 A2A-Version: 0.3 时返回。
defaultInputModesarray<string>是智能体接受作为输入的媒体类型,例如 text/plain。
defaultOutputModesarray<string>是智能体产出的输出媒体类型,例如 text/plain。
supportedInterfacesarray<object>否可以访问该智能体的接口。除非请求发送 A2A-Version: 0.3,否则返回。
supportedInterfaces[].urlstring是接口的 URL。
supportedInterfaces[].protocolBindingstring是该接口使用的传输方式:JSONRPC。
supportedInterfaces[].protocolVersionstring是该接口使用的 A2A 协议版本。

完整字段和使用该对象的方法见附录。

RuntimeMethodResponse

JSON-RPC 2.0 响应。成功时携带 result,失败时携带 error,二者不会同时出现。错误以 HTTP 状态 200 返回。

字段类型必填说明
jsonrpcstring是JSON-RPC 协议版本:始终为 2.0。 可选值: "2.0" — JSON-RPC 2.0 版本.
idstring | integer是该响应所回答的请求的 ID。请求无法读取时为 null。 可为 null。
resultJSONValue否方法的结果。仅在成功时出现;其结构取决于方法。 可为 null。
errorobject否调用的错误。仅在失败时出现。
error.codeinteger是错误码。-32700 解析错误,-32600 无效请求,-32601 方法不存在,-32602 无效参数,-32603 内部错误,-32001 任务不存在,-32002 任务不可取消,-32003 不支持推送通知,-32004 不支持的操作,-32005 不支持的内容类型,-32006 智能体响应无效,-32007 未配置 agent card,-32008 智能体繁忙,-32009 A2A-Version 不兼容,-32010 任务派发之后连接断开(请读取该任务,不要再次发送),-32011 任务超时,-32012 派发之前连接断开(没有任何运行;可以安全重试)。
error.messagestring是错误的可读描述。
error.dataJSONValue否错误的机器可读详情:包含一个 type.googleapis.com/google.rpc.ErrorInfo 类型对象的列表。其 reason 为错误名称,例如 TASK_NOT_FOUND,其 metadata 重复 code 和 message。 可为 null。

完整字段和使用该对象的方法见附录。

a2aTaskView

字段类型必填说明
idstring是任务的 ID。
contextIdstring是任务所属的上下文(会话)的 ID。
statusA2ATaskStatus是任务的当前状态。
artifactsarray<A2AArtifact>否智能体为该任务产出的输出。没有时省略。
historyarray<A2AMessage>否任务的消息。读取单个任务时最多返回其中 history_length 条。没有存储历史时,包含原始请求这一条消息。没有时省略。
metadatamap<string, JSONValue>否任务的额外元数据。没有时省略。
caller_principal_idstring是提交该任务的主体的 ID。
caller_agent_idstring是提交该任务的智能体的 ID(如果有)。
caller_owner_idstring是提交方所有者的 ID。Cloud 根据凭证的组织和应用派生该值。调用方不发送终端用户 ID。
target_principal_idstring是任务所发送给的主体的 ID。
target_agent_idstring是任务所发送给的智能体的 ID。
target_owner_idstring是接收方所有者的 ID。
channel_idstring否承载该任务流式回复的通道的 ID。任务不使用基于通道的投递时省略。
created_atstring否任务的创建时间,UTC 时间戳,例如 2026-01-02T15:04:05.000Z。未知时省略。
updated_atstring否任务最后一次更新的时间,格式与 created_at 相同。未知时省略。
completed_atstring否任务结束的时间,格式与 created_at 相同。任务结束之前省略。

完整字段和使用该对象的方法见附录。

A2ATaskStatus

字段类型必填说明
statestring是任务的当前状态。 取值见下表 A2ATaskStatus.state 取值。
messageA2AMessage否说明该状态的消息,例如错误文本。它是带一个文本 part 的智能体消息。没有需要报告的内容时省略。 可为 null。
timestampstring否任务最后一次更新的时间;从未更新过则为创建时间,UTC 时间戳,例如 2026-01-02T15:04:05.000Z。

A2ATaskStatus.state 取值

取值含义
"TASK_STATE_SUBMITTED"任务已创建,正在等待智能体开始处理。消息送达智能体后也会报告该状态。
"TASK_STATE_WORKING"智能体正在处理该任务。
"TASK_STATE_COMPLETED"最终状态。任务成功完成。
"TASK_STATE_FAILED"最终状态。任务因错误或超时而结束。
"TASK_STATE_CANCELED"最终状态。任务在完成前被取消。
"TASK_STATE_INPUT_REQUIRED"任务已暂停:智能体需要调用方提供更多输入才能继续。
"TASK_STATE_REJECTED"最终状态。智能体拒绝了该任务。
"TASK_STATE_AUTH_REQUIRED"任务已暂停:智能体需要额外的身份验证才能继续。

完整字段和使用该对象的方法见附录。

A2AMessage

字段类型必填说明
messageIdstring是消息的 ID。服务器为每条渲染的消息生成新的 ID。
rolestring是消息的作者:ROLE_USER 为调用方,ROLE_AGENT 为智能体。 可选值: "ROLE_USER" — 该消息由调用方撰写; "ROLE_AGENT" — 该消息由智能体撰写. (枚举表)
partsarray<A2AOutputPart>是消息的内容,按顺序排列的 part。每个 part 是文本 part、文件 part 或数据 part。
contextIdstring否消息所属的上下文(会话)的 ID。未设置时省略。
taskIdstring否消息所属任务的 ID。未设置时省略。
referenceTaskIdsarray<string>否该消息所引用的其他任务的 ID。没有时省略。
metadatamap<string, JSONValue>否附加在消息上的额外元数据。没有时省略。

完整字段和使用该对象的方法见附录。

A2AArtifact

字段类型必填说明
artifactIdstring是产物的 ID。智能体未提供时,服务器使用 <task ID>-a<index>,index 从 0 开始计数。
namestring否产物的显示名称。未设置时省略。
descriptionstring否产物的描述。未设置时省略。
partsarray<A2AOutputPart>是产物的内容,按顺序排列的 part。每个 part 是文本 part、文件 part 或数据 part。
metadatamap<string, JSONValue>否附加在产物上的额外元数据。没有时省略。
extensionsarray<string>否适用于该产物的协议扩展的 URI。没有时省略。

完整字段和使用该对象的方法见附录。

典型流程

  1. 用 a2a.getAgentCard 读取 agent card(a2a.getAgentCardLegacy 提供旧路径)。
  2. 用 a2a.invoke 发送 JSON-RPC 请求。
  3. 用 a2a.listTasks 与 a2a.getTask 跟踪工作,用 a2a.cancelTask 停止。

方法

方法HTTP摘要
a2a.invokePOST /v1/a2a/{agentId}发送 A2A JSON-RPC 请求
a2a.getAgentCardGET /v1/a2a/{agentId}/.well-known/agent-card.json获取 A2A agent card
a2a.getAgentCardLegacyGET /v1/a2a/{agentId}/.well-known/agent.json获取 A2A agent card(旧路径)
a2a.listTasksGET /v1/a2a/{agentId}/tasks列出 A2A 任务
a2a.getTaskGET /v1/a2a/{agentId}/tasks/{taskId}获取一个 A2A 任务
a2a.cancelTaskPOST /v1/a2a/{agentId}/tasks/{taskId}/cancel取消一个 A2A 任务

a2a.invoke

POST /v1/a2a/{agentId} · Operation ID invokeA2A

发送 A2A JSON-RPC 请求

SDK 方法

语言方法签名
TypeScriptcloud.a2a.invokeinvoke(agentId: string, input: Models.InvokeA2ARequest): Promise<Models.InvokeA2AResponse>
Pythoncloud.a2a.invokedef invoke(self, agent_id: str, input: InvokeA2ARequest) -> RuntimeMethodResponse
Gocloud.A2a.Invokefunc (r *A2aResource) Invoke(ctx context.Context, agentId string, input InvokeA2ARequest) (RuntimeMethodResponse, error)

参数

参数位置类型必填说明
agentIdpathstring是智能体的 ID。它必须属于你的应用。对于 JSON-RPC 和 agent card 请求,该智能体还必须启用其 A2A 协议,否则请求返回 403 a2a_disabled;读取任务则不受此限制。

请求体

application/json · 必填

字段类型必填说明
jsonrpcstring是JSON-RPC 协议版本:必须为 2.0。 可选值: "2.0".
idstring否请求的 ID,在响应的 id 中原样返回。
methodstring是要调用的 A2A 方法。每个方法都有 A2A 1.0 名称和 A2A 0.3 别名:SendMessage(message/send)向智能体发送消息并创建任务;SendStreamingMessage(message/stream)同上,并以 server-sent events 流式返回更新;SubscribeToTask(tasks/resubscribe)恢复任务的更新流;GetTask(tasks/get)、CancelTask(tasks/cancel)和 ListTasks(tasks/list)读取和取消任务;CompleteTask(tasks/complete)以结果或错误消息结束任务;UpdateStatus(tasks/updateStatus)设置任务状态;CreateTaskPushNotificationConfig(SetPushNotificationConfig、tasks/pushNotification/set)、GetTaskPushNotificationConfig(GetPushNotificationConfig、tasks/pushNotification/get)、ListTaskPushNotificationConfigs(ListPushNotificationConfigs、tasks/pushNotification/list)和 DeleteTaskPushNotificationConfig(DeletePushNotificationConfig、tasks/pushNotification/delete)管理任务的推送通知设置。未知方法返回错误 -32601。
paramsJSONValue否方法的参数。其结构取决于 method,由 A2A 协议定义。 可为 null。

响应

200 · application/json · Schema: RuntimeMethodResponse

字段类型必填说明
jsonrpcstring是JSON-RPC 协议版本:始终为 2.0。 可选值: "2.0" — JSON-RPC 2.0 版本.
idstring | integer是该响应所回答的请求的 ID。请求无法读取时为 null。 可为 null。
resultJSONValue否方法的结果。仅在成功时出现;其结构取决于方法。 可为 null。
errorobject否调用的错误。仅在失败时出现。
error.codeinteger是错误码。-32700 解析错误,-32600 无效请求,-32601 方法不存在,-32602 无效参数,-32603 内部错误,-32001 任务不存在,-32002 任务不可取消,-32003 不支持推送通知,-32004 不支持的操作,-32005 不支持的内容类型,-32006 智能体响应无效,-32007 未配置 agent card,-32008 智能体繁忙,-32009 A2A-Version 不兼容,-32010 任务派发之后连接断开(请读取该任务,不要再次发送),-32011 任务超时,-32012 派发之前连接断开(没有任何运行;可以安全重试)。
error.messagestring是错误的可读描述。
error.dataJSONValue否错误的机器可读详情:包含一个 type.googleapis.com/google.rpc.ErrorInfo 类型对象的列表。其 reason 为错误名称,例如 TASK_NOT_FOUND,其 metadata 重复 code 和 message。 可为 null。

错误

状态码Schema说明
其他(default)ErrorResponseCloud Server 错误

错误 schema 见错误。

示例

import { BeeOSClient } from "@beeos-ai/cloud-sdk";

const cloud = new BeeOSClient({
  baseURL: "https://api.cloud.beeos.ai/v1",
  apiKey: "YOUR_API_KEY", // bsk_ key: backend only
});
const result = await cloud.a2a.invoke("agent_123", { jsonrpc: "2.0", method: "example_method" });
console.log(result);

a2a.getAgentCard

GET /v1/a2a/{agentId}/.well-known/agent-card.json · Operation ID getA2AAgentCard

获取 A2A agent card

SDK 方法

语言方法签名
TypeScriptcloud.a2a.getAgentCardgetAgentCard(agentId: string): Promise<Models.GetA2AAgentCardResponse>
Pythoncloud.a2a.get_agent_carddef get_agent_card(self, agent_id: str) -> A2AAgentCard
Gocloud.A2a.GetAgentCardfunc (r *A2aResource) GetAgentCard(ctx context.Context, agentId string) (A2AAgentCard, error)

参数

参数位置类型必填说明
agentIdpathstring是智能体的 ID。它必须属于你的应用。对于 JSON-RPC 和 agent card 请求,该智能体还必须启用其 A2A 协议,否则请求返回 403 a2a_disabled;读取任务则不受此限制。

响应

200 · application/json · Schema: A2AAgentCard

字段类型必填说明
namestring是智能体的显示名称。
descriptionstring是智能体的描述。
urlstring否智能体 JSON-RPC 端点的 URL。仅当请求发送 A2A-Version: 0.3 时返回;1.0 版本在 supportedInterfaces 中列出该端点。
versionstring是智能体的版本:其资源版本,十进制数字。
protocolVersionstring否url 所使用的 A2A 协议版本。仅当请求发送 A2A-Version: 0.3 时返回。
defaultInputModesarray<string>是智能体接受作为输入的媒体类型,例如 text/plain。
defaultOutputModesarray<string>是智能体产出的输出媒体类型,例如 text/plain。
supportedInterfacesarray<object>否可以访问该智能体的接口。除非请求发送 A2A-Version: 0.3,否则返回。
supportedInterfaces[].urlstring是接口的 URL。
supportedInterfaces[].protocolBindingstring是该接口使用的传输方式:JSONRPC。
supportedInterfaces[].protocolVersionstring是该接口使用的 A2A 协议版本。

错误

状态码Schema说明
其他(default)ErrorResponseCloud Server 错误

错误 schema 见错误。

示例

import { BeeOSClient } from "@beeos-ai/cloud-sdk";

const cloud = new BeeOSClient({
  baseURL: "https://api.cloud.beeos.ai/v1",
  apiKey: "YOUR_API_KEY", // bsk_ key: backend only
});
const result = await cloud.a2a.getAgentCard("agent_123");
console.log(result);

a2a.getAgentCardLegacy

GET /v1/a2a/{agentId}/.well-known/agent.json · Operation ID getA2AAgentCardLegacy

获取 A2A agent card(旧路径)

SDK 方法

语言方法签名
TypeScriptcloud.a2a.getAgentCardLegacygetAgentCardLegacy(agentId: string): Promise<Models.GetA2AAgentCardLegacyResponse>
Pythoncloud.a2a.get_agent_card_legacydef get_agent_card_legacy(self, agent_id: str) -> A2AAgentCard
Gocloud.A2a.GetAgentCardLegacyfunc (r *A2aResource) GetAgentCardLegacy(ctx context.Context, agentId string) (A2AAgentCard, error)

参数

参数位置类型必填说明
agentIdpathstring是智能体的 ID。它必须属于你的应用。对于 JSON-RPC 和 agent card 请求,该智能体还必须启用其 A2A 协议,否则请求返回 403 a2a_disabled;读取任务则不受此限制。

响应

200 · application/json · Schema: A2AAgentCard

字段类型必填说明
namestring是智能体的显示名称。
descriptionstring是智能体的描述。
urlstring否智能体 JSON-RPC 端点的 URL。仅当请求发送 A2A-Version: 0.3 时返回;1.0 版本在 supportedInterfaces 中列出该端点。
versionstring是智能体的版本:其资源版本,十进制数字。
protocolVersionstring否url 所使用的 A2A 协议版本。仅当请求发送 A2A-Version: 0.3 时返回。
defaultInputModesarray<string>是智能体接受作为输入的媒体类型,例如 text/plain。
defaultOutputModesarray<string>是智能体产出的输出媒体类型,例如 text/plain。
supportedInterfacesarray<object>否可以访问该智能体的接口。除非请求发送 A2A-Version: 0.3,否则返回。
supportedInterfaces[].urlstring是接口的 URL。
supportedInterfaces[].protocolBindingstring是该接口使用的传输方式:JSONRPC。
supportedInterfaces[].protocolVersionstring是该接口使用的 A2A 协议版本。

错误

状态码Schema说明
其他(default)ErrorResponseCloud Server 错误

错误 schema 见错误。

示例

import { BeeOSClient } from "@beeos-ai/cloud-sdk";

const cloud = new BeeOSClient({
  baseURL: "https://api.cloud.beeos.ai/v1",
  apiKey: "YOUR_API_KEY", // bsk_ key: backend only
});
const result = await cloud.a2a.getAgentCardLegacy("agent_123");
console.log(result);

a2a.listTasks

GET /v1/a2a/{agentId}/tasks · Operation ID listA2ATasks

列出 A2A 任务

SDK 方法

语言方法签名
TypeScriptcloud.a2a.listTaskslistTasks(agentId: string, query?: Models.ListA2ATasksQuery): Promise<Models.ListA2ATasksResponse>
Pythoncloud.a2a.list_tasksdef list_tasks(self, agent_id: str, options: ListA2ATasksOptions | None = None) -> ListA2ATasksResponse
Gocloud.A2a.ListTasksfunc (r *A2aResource) ListTasks(ctx context.Context, agentId string, options ListA2ATasksOptions) (ListA2ATasksResponse, error)

参数

参数位置类型必填说明
agentIdpathstring是智能体的 ID。它必须属于你的应用。对于 JSON-RPC 和 agent card 请求,该智能体还必须启用其 A2A 协议,否则请求返回 403 a2a_disabled;读取任务则不受此限制。
directionquerystring否sent 列出该智能体提交的任务,received 列出提交给它的任务。省略时两者都列出。其他任何值都会被拒绝。
agent_idquerystring否只返回与该另一个智能体交换的任务,最多 128 个字符。它按提交方还是接收方匹配,取决于 direction。
cursorquerystring否下一页的不透明游标:上一次响应的 next_cursor,最多 4096 字节。
limitqueryinteger否每页的任务数量,1 到 100。默认为 20。

响应

200 · application/json

字段类型必填说明
tasksarray<a2aTaskView>是—
totalinteger是—
next_cursorstring是—
has_moreboolean是—

错误

状态码Schema说明
其他(default)ErrorResponseCloud Server 错误

错误 schema 见错误。

示例

import { BeeOSClient } from "@beeos-ai/cloud-sdk";

const cloud = new BeeOSClient({
  baseURL: "https://api.cloud.beeos.ai/v1",
  apiKey: "YOUR_API_KEY", // bsk_ key: backend only
});
const result = await cloud.a2a.listTasks("agent_123");
console.log(result);

a2a.getTask

GET /v1/a2a/{agentId}/tasks/{taskId} · Operation ID getA2ATask

获取一个 A2A 任务

SDK 方法

语言方法签名
TypeScriptcloud.a2a.getTaskgetTask(agentId: string, taskId: string, query?: Models.GetA2ATaskQuery): Promise<Models.GetA2ATaskResponse>
Pythoncloud.a2a.get_taskdef get_task(self, agent_id: str, task_id: str, options: GetA2ATaskOptions | None = None) -> a2aTaskView
Gocloud.A2a.GetTaskfunc (r *A2aResource) GetTask(ctx context.Context, agentId string, taskId string, options GetA2ATaskOptions) (a2aTaskView, error)

参数

参数位置类型必填说明
agentIdpathstring是智能体的 ID。它必须属于你的应用。对于 JSON-RPC 和 agent card 请求,该智能体还必须启用其 A2A 协议,否则请求返回 403 a2a_disabled;读取任务则不受此限制。
taskIdpathstring是任务的 ID,最多 256 个字符。
history_lengthqueryinteger否返回的历史消息的最大数量,0 到 200。默认为 50。

响应

200 · application/json · Schema: a2aTaskView

字段类型必填说明
idstring是任务的 ID。
contextIdstring是任务所属的上下文(会话)的 ID。
statusA2ATaskStatus是任务的当前状态。
artifactsarray<A2AArtifact>否智能体为该任务产出的输出。没有时省略。
historyarray<A2AMessage>否任务的消息。读取单个任务时最多返回其中 history_length 条。没有存储历史时,包含原始请求这一条消息。没有时省略。
metadatamap<string, JSONValue>否任务的额外元数据。没有时省略。
caller_principal_idstring是提交该任务的主体的 ID。
caller_agent_idstring是提交该任务的智能体的 ID(如果有)。
caller_owner_idstring是提交方所有者的 ID。Cloud 根据凭证的组织和应用派生该值。调用方不发送终端用户 ID。
target_principal_idstring是任务所发送给的主体的 ID。
target_agent_idstring是任务所发送给的智能体的 ID。
target_owner_idstring是接收方所有者的 ID。
channel_idstring否承载该任务流式回复的通道的 ID。任务不使用基于通道的投递时省略。
created_atstring否任务的创建时间,UTC 时间戳,例如 2026-01-02T15:04:05.000Z。未知时省略。
updated_atstring否任务最后一次更新的时间,格式与 created_at 相同。未知时省略。
completed_atstring否任务结束的时间,格式与 created_at 相同。任务结束之前省略。

错误

状态码Schema说明
其他(default)ErrorResponseCloud Server 错误

错误 schema 见错误。

示例

import { BeeOSClient } from "@beeos-ai/cloud-sdk";

const cloud = new BeeOSClient({
  baseURL: "https://api.cloud.beeos.ai/v1",
  apiKey: "YOUR_API_KEY", // bsk_ key: backend only
});
const result = await cloud.a2a.getTask("agent_123", "task_123");
console.log(result);

a2a.cancelTask

POST /v1/a2a/{agentId}/tasks/{taskId}/cancel · Operation ID cancelA2ATask

取消一个 A2A 任务

SDK 方法

语言方法签名
TypeScriptcloud.a2a.cancelTaskcancelTask(agentId: string, taskId: string): Promise<Models.CancelA2ATaskResponse>
Pythoncloud.a2a.cancel_taskdef cancel_task(self, agent_id: str, task_id: str) -> a2aTaskView
Gocloud.A2a.CancelTaskfunc (r *A2aResource) CancelTask(ctx context.Context, agentId string, taskId string) (a2aTaskView, error)

参数

参数位置类型必填说明
agentIdpathstring是智能体的 ID。它必须属于你的应用。对于 JSON-RPC 和 agent card 请求,该智能体还必须启用其 A2A 协议,否则请求返回 403 a2a_disabled;读取任务则不受此限制。
taskIdpathstring是任务的 ID,最多 256 个字符。

响应

200 · application/json · Schema: a2aTaskView

字段类型必填说明
idstring是任务的 ID。
contextIdstring是任务所属的上下文(会话)的 ID。
statusA2ATaskStatus是任务的当前状态。
artifactsarray<A2AArtifact>否智能体为该任务产出的输出。没有时省略。
historyarray<A2AMessage>否任务的消息。读取单个任务时最多返回其中 history_length 条。没有存储历史时,包含原始请求这一条消息。没有时省略。
metadatamap<string, JSONValue>否任务的额外元数据。没有时省略。
caller_principal_idstring是提交该任务的主体的 ID。
caller_agent_idstring是提交该任务的智能体的 ID(如果有)。
caller_owner_idstring是提交方所有者的 ID。Cloud 根据凭证的组织和应用派生该值。调用方不发送终端用户 ID。
target_principal_idstring是任务所发送给的主体的 ID。
target_agent_idstring是任务所发送给的智能体的 ID。
target_owner_idstring是接收方所有者的 ID。
channel_idstring否承载该任务流式回复的通道的 ID。任务不使用基于通道的投递时省略。
created_atstring否任务的创建时间,UTC 时间戳,例如 2026-01-02T15:04:05.000Z。未知时省略。
updated_atstring否任务最后一次更新的时间,格式与 created_at 相同。未知时省略。
completed_atstring否任务结束的时间,格式与 created_at 相同。任务结束之前省略。

错误

状态码Schema说明
其他(default)ErrorResponseCloud Server 错误

错误 schema 见错误。

示例

import { BeeOSClient } from "@beeos-ai/cloud-sdk";

const cloud = new BeeOSClient({
  baseURL: "https://api.cloud.beeos.ai/v1",
  apiKey: "YOUR_API_KEY", // bsk_ key: backend only
});
const result = await cloud.a2a.cancelTask("agent_123", "task_123");
console.log(result);