Skip to content

Commit e90efb7

Browse files
authored
Feat/a2a call oauth (#97)
2 parents 64656b1 + efaebf6 commit e90efb7

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎docs/content/2.agentkit-cli/2.commands.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ agentkit add harness --name <name> [options]
401401
| `--register-network-type` | 注册网络类型。 | `--register-network-type public` |
402402
| `--directory` | 写入 `<name>.harness.json` 的目录(默认当前目录)。 | `--directory ./my_harness` |
403403

404-
配置 A2A registry 时,CLI 会在解析出 SpaceId 后调用 `UpdateA2aSpace`,将该空间的 `IntentEnabled` 设置为 `true`,因此调用方需要 `agentkit:UpdateA2aSpace` 权限。部署后的 Harness Runtime 会在每轮对话前用用户输入的前 2048 个 UTF-8 bytes 调用 `SearchAgentCards`,再通过 `GetA2aAgent` 把本轮命中的远程 Agent 临时挂载为 `remote_a2a_*` 动态工具。
404+
配置 A2A registry 时,CLI 会在解析出 SpaceId 后调用 `UpdateA2aSpace`,将该空间的 `IntentEnabled` 设置为 `true`,因此调用方需要 `agentkit:UpdateA2aSpace` 权限。部署后的 Harness Runtime 会在每轮对话前用用户输入的前 2048 个 UTF-8 bytes 调用 `SearchAgentCards`,再通过 `GetA2aAgent` 把本轮命中的远程 Agent 临时挂载为 `remote_a2a_*` 动态工具。远程 Agent 可使用 `apiKey` 或 `oauth2.clientCredentials` 鉴权;OAuth 类型会自动通过 Identity UserPool 的 M2M client 换取 access token,并以 `Authorization: Bearer <access_token>` 调用 `message/send` / `tasks/get`。
405405

406406
### 组件参数
407407

@@ -1620,6 +1620,7 @@ agentkit invoke harness <name> [消息内容] [选项]
16201620
- `--registry default` 等价于 `--registry "agentkit://a2a-registry?space_name=Default&region=cn-beijing&endpoint=https://open.volcengineapi.com/"`
16211621
- `--registry-space-name` 和 URI 中的 `space_name` 会在本地通过 `ListA2aSpaces` 解析为 space id 后传给运行时
16221622
- 解析出 space id 后会调用 `UpdateA2aSpace` 开启 `IntentEnabled=true`
1623+
- 命中的 remote-agent 若是 OAuth 类型,运行时会根据 `GetA2aAgent` 返回的 AgentCard 中的 `oauth2.clientCredentials.tokenUrl` 自动获取 Bearer token
16231624
- URI 中只支持 `space_name`,不支持 `registry_space_name` 等别名
16241625
- 示例:`agentkit invoke harness my-harness --registry-space-name my-space --registry-region cn-beijing "找一个财务专家"`
16251626

‎docs/content/2.agentkit-cli/5.harness.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ agentkit add harness --name my-harness --registry default
124124

125125
部署后的 Harness Runtime 在每轮用户对话开始前,会用用户原始输入的前 2048 个 UTF-8 bytes 调用 `SearchAgentCards`;对本轮返回的每个 AgentCard,再调用 `GetA2aAgent` 获取 endpoint 与鉴权信息,并临时包装为本轮可用的 `remote_a2a_*` 工具。这些动态工具只对当前轮次生效,不写回 spec,也不污染已部署的基础 Agent。
126126

127+
远程 Agent 的调用鉴权由 Runtime 自动处理:`apiKey` 类型 AgentCard 会按 `securitySchemes` 中声明的 header 注入;`oauth2` 且声明 `clientCredentials.tokenUrl` 的 AgentCard 会从 token URL 解析火山引擎 Identity UserPool,查询其中的 `MACHINE_TO_MACHINE` client,使用 `client_credentials` 换取 access token,并以 `Authorization: Bearer <access_token>` 调用远程 A2A endpoint。通常无需额外配置;如果 `registry endpoint` 不是公网 OpenAPI 网关且无法同时访问 Identity OpenAPI,可用 `REGISTRY_ID_ENDPOINT` / `AGENTKIT_ID_ENDPOINT` 指定 Identity OpenAPI 地址。
128+
127129
`--registry-endpoint` 用于指定 Harness Runtime 后续访问 A2A Registry OpenAPI 的地址。通常不传时会按 region 推导默认 endpoint;如果部署后的运行时环境无法解析 region 专属域名,或需要统一走火山引擎公网 OpenAPI 网关,可以显式设置为 `https://open.volcengineapi.com/`:
128130

129131
```bash
@@ -376,6 +378,8 @@ agentkit add harness --name my-harness \
376378
377379
当本次调用通过 `--registry` / `--registry-space-id` / `--registry-space-name` 指定了 A2A SpaceId 时,CLI 同样会先调用 `UpdateA2aSpace` 开启 `IntentEnabled=true`,再把 registry 覆写发送给 Harness Runtime。
378380

381+
本次调用若命中 OAuth 类型 remote-agent,鉴权行为与部署时的 registry 配置一致:Runtime 会在 `GetA2aAgent` 后根据 AgentCard 的 `oauth2.clientCredentials.tokenUrl` 自动获取 access token,并在动态 `remote_a2a_*` 工具执行 `message/send` / `tasks/get` 时附加 Bearer token。
382+
379383
```bash
380384
# 基础调用(run_sse,默认,流式)
381385
agentkit invoke harness my-harness "今天杭州天气如何?"

0 commit comments

Comments
 (0)