跳到主要内容

A2A 命令参考

本页面记录每个 A2A 相关的 iac-code 命令。当你需要准确的选项名称、常见命令模式以及每个 flag 的运行含义时,请使用本页面。

命令概览

命令用途
iac-code a2a将 iac-code 作为 A2A server 运行
iac-code a2a-client call发现远程 Agent Card 并发送 prompt
iac-code a2a-client discover获取并可选验证 Agent Card
iac-code a2a-client task-get按 ID 获取一个 task
iac-code a2a-client task-list使用过滤器和分页列出 tasks
iac-code a2a-client task-cancel取消活动 task
iac-code a2a-client task-subscribe订阅活动 task event stream
iac-code a2a-client push-config-create创建 task push notification config
iac-code a2a-client push-config-get获取一个 task push notification config
iac-code a2a-client push-config-list列出 task push notification configs
iac-code a2a-client push-config-delete删除 task push notification config
iac-code a2a-client extended-card获取已认证的扩展 Agent Card
iac-code a2a-route-previewa2a-client call 预览本地路由选择

所有 HTTP client 命令都接受相同的认证选项:

选项描述
--token作为 Authorization: Bearer <token> 发送的 Bearer token
--basic-usernameBasic auth username
--basic-passwordBasic auth password
--api-keyAPI key 值
--api-key-headerAPI key header 名称;默认为 X-API-Key

A2A Client 配置

所有 a2a-client 子命令都在 group 层级接受 YAML 配置文件:

iac-code a2a-client --config a2a-client.yml call --prompt "Create a VPC"

CLI 选项会覆盖配置值。使用 config 保存稳定连接、认证、验证、路由以及重复任务或推送设置;一次性的 prompt 文本保留在命令行上。

url: http://127.0.0.1:41242/
token: your-bearer-token
basic-username: iac-code
basic-password: your-password
api-key: your-api-key
api-key-header: X-IAC-Code-Key
verify-card-secret: your-card-signing-secret
verify-card-jwks-url: https://a2a.example.com/.well-known/jwks.json
require-card-signature: true
timeout: 30
cwd: /path/to/workspace
context-id: ctx-123
task-id: task-123
config-id: webhook-1
callback-url: https://hooks.example.com/a2a
notification-token: notification-token
auth-scheme: bearer
auth-credentials: callback-token
routes:
- name: ros
url: http://127.0.0.1:41242/
skills:
- iac_generation
tags:
- ros
- template

iac-code a2a

将 iac-code 作为 A2A server 运行。

iac-code a2a

默认情况下,服务器绑定到 127.0.0.1:41242,并通过 HTTP 提供 JSON-RPC。端口 41242 是 iac-code 默认值;它不是已注册的 A2A 端口。

基本服务器选项

选项默认值描述
--config包含 A2A server 选项的 YAML 配置文件
--host127.0.0.1HTTP server host
--port41242HTTP server port
--transporthttpServer transport:httpstdiounixwebsocketgrpcgrpc-jsonrpcredis-streams
--thinking-exposuretool-trace暴露一种 A2A thinking 信号类型;可重复指定多个。取值:raw-thinkingtool-trace
--debug, -dfalse启用 debug logging

示例:

iac-code a2a --host 127.0.0.1 --port 41242 --debug

YAML 配置

使用 --config 配置认证、存储、签名、传输专用设置、推送投递和其他部署细节。Keys 可以使用连字符或下划线。常用 CLI flags --host--port--transport 会覆盖 config-file values。

host: 127.0.0.1
port: 41242
transport: http
token: local-dev-token
persistence-dir: .iac-code-a2a/state
artifact-dir: .iac-code-a2a/artifacts
push-notifications: true

使用以下命令运行:

iac-code a2a --config a2a-server.yml --port 41243

HTTP 认证

认证是可选的。可以在 YAML 或环境变量中配置服务器认证。如果未配置任何 auth 设置,请求无需认证。当配置了一个或多个方案时,请求可以满足任一已配置方案。

配置键环境变量描述
tokenIACCODE_A2A_HTTP_TOKENBearer token
basic-usernameIACCODE_A2A_BASIC_USERNAMEBasic auth username
basic-passwordIACCODE_A2A_BASIC_PASSWORDBasic auth password
api-keyIACCODE_A2A_API_KEYAPI key 值
api-key-headerIACCODE_A2A_API_KEY_HEADERAPI key header 名称

Bearer token:

token: local-dev-token

Basic auth:

basic-username: iac-code
basic-password: local-dev-password

API key:

api-key: local-dev-key
api-key-header: X-IAC-Code-Key

持久化和 Artifacts

配置键默认值描述
persistence-dir~/.iac-code/a2a用于 tasks、contexts、routes 和 push configs 的本地 JSON 元数据
artifact-dir<persistence-dir>/artifacts本地 artifact payload store

持久化会镜像 task 和 context snapshots,用作恢复元数据。它不会在进程崩溃后重启正在运行的 asyncio task。

persistence-dir: ~/.iac-code/a2a
artifact-dir: ~/.iac-code/a2a/artifacts

Agent Card 签名

配置键描述
signing-secret用于签名 public Agent Card 的 HMAC secret

服务器会发出 A2A SDK AgentCardSignature JWS 字段。对称模式使用 HS256

signing-secret: local-card-signing-secret

推送通知投递

配置键默认值描述
push-notificationsfalse启用 A2A task push notification config 方法和终态投递
push-queuelocal-filePush queue backend:local-fileredis-streams
push-redis-urlRedis-backed push queue 的 Redis URL
push-streamiac-code:a2a:pushpush jobs 的 Redis stream
push-retry-keyiac-code:a2a:push:retrydelayed retries 的 Redis sorted set
push-dead-streamiac-code:a2a:push:deaddead-letter jobs 的 Redis stream
push-consumer-groupiac-code-pushpush workers 的 Redis consumer group
push-consumer-name此 worker 的 Redis consumer name
push-lease-timeout-ms300000Redis pending lease timeout

本地文件队列:

push-notifications: true
persistence-dir: ~/.iac-code/a2a
push-queue: local-file

Redis Streams 队列:

push-notifications: true
push-queue: redis-streams
push-redis-url: redis://localhost:6379/0
push-stream: iac-code:a2a:push
push-retry-key: iac-code:a2a:push:retry
push-dead-stream: iac-code:a2a:push:dead
push-consumer-group: iac-code-push
push-consumer-name: worker-1

Redis-backed push delivery 需要 a2a-redis extra。

传输选项

传输命令说明
HTTP JSON-RPC 和 RESTiac-code a2a --transport http默认。公布 JSONRPCHTTP+JSON 接口。
stdioiac-code a2a --transport stdio标准输入/输出上的实验性自定义 JSON-RPC frames。
Unix socketiac-code a2a --config a2a-server.yml --transport unix需要 config 中的 socket-path
WebSocketiac-code a2a --config a2a-server.yml --transport websocket使用 config 中的 ws-path,默认为 /a2a
gRPCiac-code a2a --config a2a-server.yml --transport grpc使用 config 中的 grpc-hostgrpc-port
gRPC JSON-RPCiac-code a2a --config a2a-server.yml --transport grpc-jsonrpcgRPC 上的自定义 JSON-RPC envelope。
Redis Streamsiac-code a2a --config a2a-server.yml --transport redis-streams需要 config 中的 redis-url

Redis Streams 传输选项:

配置键默认值描述
redis-urlRedis connection URL;--transport redis-streams 必需
request-streamiac-code:a2a:requestsRequest stream 名称
response-streamiac-code:a2a:responsesResponse stream 名称
consumer-groupiac-codeRequest stream consumer group

Thinking 暴露

配置键默认值描述
thinking-exposuretool-trace通过 A2A metadata.iac_code 暴露的非回答运行时信号类型。可使用 YAML 列表、逗号分隔字符串,或重复的 --thinking-exposure flag。支持值为 tool-traceraw-thinking

tool-trace 保留现有的工具进度、权限和结果元数据。raw-thinking 会将 provider 推理 chunk 作为 metadata.iac_code.thinking 更新发出,包含 type: raw_thinkingtext。iac-code 目前不会生成独立的 thought-summary 或 progress-summary 事件,因此这些不是有效的暴露类型。

thinking-exposure:
- tool-trace
- raw-thinking

权限行为

配置键默认值描述
auto-approve-permissionsfalse自动批准 A2A 轮次期间发起的工具权限请求

如果没有 auto-approve-permissions: true,A2A 模式会拒绝权限提示并发出权限元数据。仅在受信任的自动化环境中使用它。

iac-code a2a-client call

发现 Agent Card、选择已公布端点并发送 prompt。

iac-code a2a-client --config a2a-client.yml call \
--prompt "Create a ROS VPC template with two vSwitches." \
--cwd "$PWD"
选项默认值描述
--urlA2A agent base URL 或 JSON-RPC endpoint URL;可来自 config
--route可重复省略 --url 时使用的 route spec
--route-name要选择的 named route
--prompt, -p必需Prompt text
--cwd.作为 message.metadata.iac_code.cwd 发送的 workspace path
--context-id用于后续消息的现有 A2A context ID
--verify-card-secret, --signing-secretAgent Card verification 的 HMAC secret
--verify-card-jwks-url用于 Agent Card verification 的远程 JWKS URL
--require-card-signature, --require-signaturefalse拒绝未签名或无效的 Agent Cards
--timeout30.0调用 timeout(秒)
--streamfalse使用 SendStreamingMessage 并打印 stream events

在同一 context 中发送后续消息:

iac-code a2a-client --config a2a-client.yml call \
--context-id ctx-123 \
--prompt "Now add outputs for the VPC and vSwitch IDs." \
--cwd "$PWD"

流式:

iac-code a2a-client --config a2a-client.yml call \
--prompt "Review this Terraform module." \
--cwd "$PWD" \
--stream

要求已签名 Agent Card:

iac-code a2a-client --config a2a-client.yml call \
--prompt "Generate a production VPC template." \
--cwd "$PWD"

使用远程 JWKS URL 验证:

iac-code a2a-client --config jwks-client.yml call \
--prompt "Review the ROS stack."

iac-code a2a-client discover

获取并打印远程 Agent Card。

iac-code a2a-client --config a2a-client.yml discover
选项描述
--urlA2A agent base URL;可来自 config
--verify-card-secret, --signing-secret用于验证的 HMAC secret
--verify-card-jwks-url用于验证的远程 JWKS URL
--require-card-signature, --require-signature要求有效签名

已认证发现:

iac-code a2a-client --config a2a-client.yml discover

Task 命令

Task 命令会直接调用 JSON-RPC task methods。它们适用于运维工具、仪表板和调试。

iac-code a2a-client task-get

iac-code a2a-client --config a2a-client.yml task-get \
--task-id task-123 \
--history-length 20
选项描述
--urlA2A JSON-RPC endpoint URL;可来自 config
--task-idTask ID;可来自 config
--history-length要返回的最大 task history entries 数

iac-code a2a-client task-list

iac-code a2a-client --config a2a-client.yml task-list \
--context-id ctx-123 \
--status TASK_STATE_INPUT_REQUIRED \
--page-size 20 \
--output table
选项默认值描述
--urlA2A JSON-RPC endpoint URL;可来自 config
--context-id按 context ID 过滤
--status按 task state 过滤
--page-size要返回的最大 tasks 数
--page-tokenPagination token
--include-artifactsfalse在响应中包含 task artifacts
--outputtabletablejson

JSON 输出:

iac-code a2a-client --config a2a-client.yml task-list \
--include-artifacts \
--output json

iac-code a2a-client task-cancel

iac-code a2a-client --config a2a-client.yml task-cancel \
--task-id task-123

取消是协作式的。已完成、失败、已取消或需要输入的 task 会返回标准 A2A task-not-cancelable 错误。

iac-code a2a-client task-subscribe

iac-code a2a-client --config a2a-client.yml task-subscribe \
--task-id task-123

该命令会为活动 tasks 流式传输 events。对于新轮次,优先使用 a2a-client call --stream;它会在一个命令中启动 task 并流式传输更新。

推送通知配置命令

这些命令需要服务器以 push-notifications: true 启动。它们管理标准 A2A task push notification configs。

iac-code a2a-client push-config-create

iac-code a2a-client --config a2a-client.yml push-config-create \
--task-id task-123 \
--config-id webhook-1 \
--callback-url https://hooks.example.com/a2a \
--notification-token "$NOTIFICATION_TOKEN" \
--auth-scheme bearer \
--auth-credentials "$WEBHOOK_BEARER_TOKEN"
选项描述
--urlA2A JSON-RPC endpoint URL;可来自 config
--task-idTask ID;可来自 config
--config-idPush config ID;可来自 config
--callback-urlHTTP(S) callback URL;可来自 config
--notification-token作为 X-A2A-Notification-Token 发送的 token
--auth-schemeCallback auth scheme,例如 bearerbasic
--auth-credentialsCallback auth credentials

Callback URLs 会在存储和分发前校验。默认 validator 会拒绝非 HTTP(S) URLs、localhost names 和字面量 private/local IP addresses。

iac-code a2a-client push-config-get

iac-code a2a-client --config a2a-client.yml push-config-get \
--task-id task-123 \
--config-id webhook-1

iac-code a2a-client push-config-list

iac-code a2a-client --config a2a-client.yml push-config-list \
--task-id task-123 \
--page-size 10

iac-code a2a-client push-config-delete

iac-code a2a-client --config a2a-client.yml push-config-delete \
--task-id task-123 \
--config-id webhook-1

iac-code a2a-client extended-card

获取已认证的扩展 Agent Card。

iac-code a2a-client --config a2a-client.yml extended-card \
--token "$A2A_TOKEN"

Public Agent Card 会公布 capabilities.extendedAgentCard=true。扩展 card 会添加已认证运行时细节,包括任务管理和推送配置能力元数据。

iac-code a2a-route-preview

预览省略 --urla2a-client call 如何解析已配置路由。

iac-code a2a-route-preview \
--route "template=http://127.0.0.1:41242/;skills=iac_generation;tags=ros,template" \
--skill iac_generation \
--prompt "Create a ROS VPC template"
选项描述
--routename=url;skills=a,b;tags=x,y 格式的可重复 route spec
--name要解析的 route name
--skill要解析的 Skill ID
--prompt用于 name/tag matching 的 prompt text
--route-state-dir, --persistence-dir用于持久化 route snapshots 的目录
--save-routes将提供的 routes 保存到 route state directory

保存 route snapshots:

iac-code a2a-route-preview \
--route "ros=http://127.0.0.1:41242/;skills=iac_generation;tags=ros" \
--route-state-dir ~/.iac-code/a2a \
--save-routes

通过 routes 调用:

iac-code a2a-client call \
--route "ros=http://127.0.0.1:41242/;skills=iac_generation;tags=ros" \
--route-name ros \
--prompt "Create a ROS VPC template." \
--cwd "$PWD"

环境变量

变量描述
IACCODE_A2A_HTTP_TOKENServer/client Bearer token 默认值
IACCODE_A2A_BASIC_USERNAMEServer/client Basic auth username 默认值
IACCODE_A2A_BASIC_PASSWORDServer/client Basic auth password 默认值
IACCODE_A2A_API_KEYServer/client API key 默认值
IACCODE_A2A_API_KEY_HEADERAPI key header 名称默认值
IACCODE_A2A_ALLOWED_CWDS用于传入 message metadata 和 file URLs 的按 OS path separator 分隔的 allowed workspace roots 列表
IACCODE_A2A_TEXT_MIME_TYPES额外的以逗号或分号分隔的 text-like MIME types
IACCODE_A2A_MULTIMODAL_MIME_TYPES额外的以逗号或分号分隔的 multimodal MIME types
IAC_CODE_A2A_PUSH_KEYRING由环境管理的 encrypted push secret keyring