Skip to content

[统一能力平台] OpenClaw 插件支持 Agent Delegation JWT 与统一 Run Event #2

Description

@ax2

背景

OpenClaw/QVeris 插件目前主要通过静态 QVeris API Key 调用工具。统一身份方案要求 Agent Runtime 不再持有用户完整 API Key,而是接收短期、窄权限、绑定 run 与预算的 Agent Delegation JWT,并输出可追踪的结构化 Run Event。

目标

  • 插件支持 API Key 与 Agent Delegation JWT 双模式。
  • JWT 模式按 resource/scope 调用 discover/inspect/call 和 Model API。
  • 所有 Agent 步骤传播 run_id/request_id/session_id,输出统一事件。
  • 不在 workspace、子进程环境、日志或模型上下文中泄露凭证。

认证设计

  • 新增 token provider 接口,调用前按 resource 获取 token。
  • hosted runtime 由上游注入短期 delegation token;插件不得持久化。
  • 本地高级模式继续支持 API Key,但明确标注为兼容模式。
  • token 过期时向宿主请求重新委托,不自行使用 refresh token。
  • Tool token 不得调用 Model resource,反之亦然。

Run Event

统一事件建议包括:

  • run.started/completed/failed
  • step.started/completed/failed
  • tool.discovered/inspected/called/result
  • model.started/delta/completed
  • usage.reported

每条事件包含 schema_version、event_id、run_id、step_id、request_id、timestamp 和安全 metadata。事件中不输出 chain-of-thought、token、API Key 或第三方密钥。

调用行为

  • discover/inspect/call 使用结构化协议,不把 ACL/价格/质量信号压扁到描述文本。
  • 调用前检查 delegation token 的工具、模型和预算约束。
  • 重试生成新的 attempt_id,但保持同一 request/step/settlement 关联。
  • 供应商或 Tool 失败应输出可分类错误,不把失败结果伪装成成功文本。

测试

  • API Key 与 delegation token 两种模式。
  • scope/resource/预算/工具白名单限制。
  • token 过期后的 re-delegation 行为。
  • 事件顺序、关联 ID 和流式 delta。
  • 子进程 env、日志、错误和模型 prompt 的凭证泄漏测试。
  • 与 QVeris Tool Resource Server 的集成测试。

验收标准

  • Hosted Agent 不需要用户完整 API Key。
  • delegation 权限和预算在客户端与服务端均可验证。
  • FinBot/Playground 可消费同一 Run Event 协议。
  • 重试、失败和 usage 可通过关联 ID 追踪。
  • 本地 API Key 模式保持兼容。
  • 安全文档和升级指南完整。

依赖

  • WonderfulValley/qveris-website#1696
  • WonderfulValley/quaestio#907
  • WonderfulValley/quaestio-shared#83

非目标

  • 不在插件内保存 OAuth refresh token。
  • 不实现 Credits 账本和模型供应商路由。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions