feat: 实现 Queue Q2 受控 dispatch

This commit is contained in:
Codex
2026-06-01 22:44:27 +08:00
parent db886617dc
commit b19143ad85
9 changed files with 337 additions and 3 deletions
+4
View File
@@ -58,6 +58,8 @@ CLI 官方 TypeScript 入口固定为 `scripts/agentrun-cli.ts`。在 G14 非交
./scripts/agentrun queue commander [--queue <queue>]
./scripts/agentrun queue read <taskId>
./scripts/agentrun queue cancel <taskId> [--reason <text>]
./scripts/agentrun queue dispatch <taskId> [--json-file <dispatch.json>]
./scripts/agentrun queue refresh <taskId>
./scripts/agentrun sessions show <sessionId|sessionPath>
./scripts/agentrun sessions output <sessionId|sessionPath> [--cursor <cursor>] [--limit <limit>]
./scripts/agentrun sessions trace <sessionId|sessionPath> [--cursor <cursor>] [--limit <limit>]
@@ -74,6 +76,8 @@ CLI 官方 TypeScript 入口固定为 `scripts/agentrun-cli.ts`。在 G14 非交
- `server logs` 返回有界日志摘要,并指向完整日志文件或 Kubernetes pod identity。
- `secrets codex render --dry-run` 返回 Codex stdio profile Secret 创建计划、输入文件 bytes/hash、SecretRef、manifest 摘要和 apply 命令形状;`--profile codex` 默认 Secret name 为 `agentrun-v01-provider-codex``--profile deepseek` 默认 Secret name 为 `agentrun-v01-provider-deepseek`;它不得输出 Secret value 或执行 Kubernetes 写操作。
- `backends list` 必须显示 `codex``deepseek` profile 的 backendKind、protocol、transport、command、requiredSecretKeys 和状态;不得因为 `deepseek` 尚未配置 Secret 就隐藏 capability。
- `queue dispatch` 是 Q2 的受控手动调度入口,只对单个 task 显式创建 attempt 和 Core run/command/runner job;不得伪装成自动 scheduler。
- `queue refresh` 只根据 Queue task 中保存的 Core run/command 引用回写 Queue attempt 状态,不读取 Core trace 反推 commander 或统计。
- `queue show` 必须返回 task/attempt summary、state、read cursor、stats 相关字段和 `sessionPath`;不得返回或代理完整 output/trace。
- `sessions output``sessions trace` 是输出和 trace 的唯一 CLI 查询入口;不得新增 `queue output``queue trace` 兼容命令。
+5 -1
View File
@@ -34,6 +34,8 @@ GET /api/v1/queue/tasks?queue=<queue>&state=<state>&cursor=<cursor>&limit=<limi
GET /api/v1/queue/tasks/:taskId
POST /api/v1/queue/tasks/:taskId/cancel
POST /api/v1/queue/tasks/:taskId/read
POST /api/v1/queue/tasks/:taskId/dispatch
POST /api/v1/queue/tasks/:taskId/refresh
GET /api/v1/queue/stats?queue=<queue>
GET /api/v1/queue/commander?queue=<queue>
```
@@ -80,6 +82,8 @@ AgentRun CLI 必须提供 Queue 和 Session 两组命令。Queue 命令只操作
./scripts/agentrun queue commander [--queue <queue>]
./scripts/agentrun queue read <taskId>
./scripts/agentrun queue cancel <taskId> [--reason <text>]
./scripts/agentrun queue dispatch <taskId> [--json-file <dispatch.json>]
./scripts/agentrun queue refresh <taskId>
```
Session 命令负责输出、trace 和会话控制:
@@ -135,7 +139,7 @@ Queue 首版新增或扩展的稳定表方向:
| --- | --- | --- |
| Q0 | 固化 Queue SPEC 和 schema migration 计划 | 文档与旧 Code Queue 兼容口径不冲突。 |
| Q1 | Queue RESTful API 和 CLI 骨架 | submit/list/show/stats/read/cancel 全部短返回 JSON,不触发真实执行也能保存 task。 |
| Q2 | attempt 到 Core run/command/runner job 的真实闭环 | Queue submit 产生 attemptScheduler 或受控 dispatch 创建真实 runner job。 |
| Q2 | attempt 到 Core run/command/runner job 的真实闭环 | Queue submit 后通过受控 `queue dispatch` 产生 attempt,并创建真实 Core run/command/runner job`queue refresh` 从 Core run/command 终态回写 Queue attempt;自动 Scheduler 仍 deferred。 |
| Q3 | Session 引用边界 | `queue show` 返回 `sessionPath`,输出和 trace 只能通过 `sessions ...` 查询。 |
| Q4 | summary/stats/read/commander | Queue overview、stats、read cursor、commander 全部直接查 Queue 模型。 |
| Q5 | retry/judge/cancel | retry/backoff、judge、cancel 与 attempt/session/core 状态一致。 |