@fitlab-ai/agent-infra 0.9.6 → 0.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/internal-cli.js +5 -0
- package/dist/lib/agent-clients/adapters/codex-lifecycle/app-server.js +45 -4
- package/dist/lib/agent-clients/adapters/codex-lifecycle/build-identity.js +162 -0
- package/dist/lib/agent-clients/adapters/codex-lifecycle/capability-store.js +244 -0
- package/dist/lib/agent-clients/adapters/codex-lifecycle/sandbox-controller.js +370 -0
- package/dist/lib/agent-clients/adapters/codex-lifecycle/store.js +21 -5
- package/dist/lib/defaults.json +10 -2
- package/dist/lib/git/workflow.js +30 -3
- package/dist/lib/internal/codex-lifecycle.js +69 -1
- package/dist/lib/internal/codex-sandbox-controller.js +106 -0
- package/dist/lib/internal/task-orchestration.js +37 -5
- package/dist/lib/platform/context.js +6 -4
- package/dist/lib/platform/github-client.js +55 -2
- package/dist/lib/process-data/checkpoint.js +319 -0
- package/dist/lib/process-data/index.js +128 -60
- package/dist/lib/process-data/materialize.js +84 -0
- package/dist/lib/process-data/normalize.js +34 -1
- package/dist/lib/process-data/reconcile.js +55 -1
- package/dist/lib/process-data/sources.js +422 -1
- package/dist/lib/process-data/store.js +341 -11
- package/dist/lib/sandbox/commands/create.js +103 -51
- package/dist/lib/sandbox/commands/rm.js +64 -15
- package/dist/lib/sandbox/commands/start.js +4 -3
- package/dist/lib/sandbox/control/container-identity.js +64 -0
- package/dist/lib/sandbox/control/executor.js +13 -7
- package/dist/lib/sandbox/control/lifecycle.js +238 -29
- package/dist/lib/sandbox/control/protocol.js +7 -0
- package/dist/lib/sandbox/control/server.js +202 -26
- package/dist/lib/sandbox/control/state.js +25 -15
- package/dist/lib/sandbox/control/timing.js +8 -0
- package/dist/lib/sandbox/mounts.js +5 -13
- package/dist/lib/sandbox/recovery.js +59 -42
- package/dist/lib/sandbox/workspace-view.js +57 -40
- package/dist/lib/server/daemon.js +1 -1
- package/dist/lib/server/process-control.js +11 -1
- package/dist/lib/server/process-state.js +57 -20
- package/dist/lib/task/artifact-lifecycle.js +82 -11
- package/dist/lib/task/artifact-receipts.js +128 -0
- package/dist/lib/task/codex-orchestration.js +81 -6
- package/dist/lib/task/commands/validate.js +1 -1
- package/dist/lib/task/create.js +10 -2
- package/dist/lib/task/delegation-receipts.js +84 -2
- package/dist/lib/task/events.js +139 -2
- package/dist/lib/task/ledger.js +13 -1
- package/dist/lib/task/orchestration.js +235 -14
- package/dist/lib/task/sections.js +5 -1
- package/dist/lib/task/task-execution-lock.js +5 -4
- package/dist/lib/task/verification-engine.js +40 -8
- package/dist/lifecycle-build-manifest.json +6 -0
- package/lib/agent-clients/adapters/codex-lifecycle/app-server.ts +60 -3
- package/lib/agent-clients/adapters/codex-lifecycle/build-identity.ts +227 -0
- package/lib/agent-clients/adapters/codex-lifecycle/capability-store.ts +321 -0
- package/lib/agent-clients/adapters/codex-lifecycle/manifest-files.json +26 -0
- package/lib/agent-clients/adapters/codex-lifecycle/sandbox-controller.ts +453 -0
- package/lib/agent-clients/adapters/codex-lifecycle/store.ts +33 -4
- package/lib/defaults.json +10 -2
- package/lib/git/workflow.ts +25 -2
- package/lib/internal/codex-lifecycle.ts +68 -1
- package/lib/internal/codex-sandbox-controller.ts +109 -0
- package/lib/internal/task-orchestration.ts +31 -4
- package/lib/platform/context.ts +8 -5
- package/lib/platform/github-client.ts +61 -3
- package/lib/process-data/checkpoint.ts +335 -0
- package/lib/process-data/index.ts +112 -60
- package/lib/process-data/materialize.ts +83 -0
- package/lib/process-data/normalize.ts +29 -1
- package/lib/process-data/reconcile.ts +64 -2
- package/lib/process-data/sources.ts +449 -2
- package/lib/process-data/store.ts +304 -11
- package/lib/process-data/types.ts +124 -2
- package/lib/sandbox/commands/create.ts +56 -7
- package/lib/sandbox/commands/rm.ts +64 -14
- package/lib/sandbox/commands/start.ts +4 -3
- package/lib/sandbox/control/container-identity.ts +93 -0
- package/lib/sandbox/control/executor.ts +14 -10
- package/lib/sandbox/control/lifecycle.ts +264 -33
- package/lib/sandbox/control/protocol.ts +31 -5
- package/lib/sandbox/control/server.ts +184 -24
- package/lib/sandbox/control/state.ts +34 -17
- package/lib/sandbox/control/timing.ts +12 -0
- package/lib/sandbox/mounts.ts +5 -15
- package/lib/sandbox/recovery.ts +71 -42
- package/lib/sandbox/workspace-view.ts +61 -40
- package/lib/server/daemon.ts +1 -1
- package/lib/server/process-control.ts +13 -3
- package/lib/server/process-state.ts +82 -27
- package/lib/task/artifact-lifecycle.ts +73 -10
- package/lib/task/artifact-receipts.ts +161 -0
- package/lib/task/codex-orchestration.ts +91 -5
- package/lib/task/commands/validate.ts +1 -1
- package/lib/task/create.ts +11 -2
- package/lib/task/delegation-receipts.ts +160 -8
- package/lib/task/events.ts +122 -1
- package/lib/task/ledger.ts +16 -1
- package/lib/task/orchestration.ts +356 -17
- package/lib/task/sections.ts +6 -2
- package/lib/task/task-execution-lock.ts +11 -9
- package/lib/task/verification-engine.ts +51 -16
- package/package.json +1 -1
- package/templates/.agents/README.en.md +7 -0
- package/templates/.agents/README.zh-CN.md +5 -0
- package/templates/.agents/hooks/lifecycle-delegation.js +25 -1
- package/templates/.agents/rules/lifecycle-orchestration.en.md +8 -2
- package/templates/.agents/rules/lifecycle-orchestration.zh-CN.md +8 -2
- package/templates/.agents/rules/pr-checks-commands.github.en.md +1 -1
- package/templates/.agents/rules/pr-checks-commands.github.zh-CN.md +1 -1
- package/templates/.agents/rules/review-handshake.en.md +3 -1
- package/templates/.agents/rules/review-handshake.zh-CN.md +3 -1
- package/templates/.agents/skills/code-task/reference/dual-mode.en.md +3 -1
- package/templates/.agents/skills/code-task/reference/dual-mode.zh-CN.md +3 -1
- package/templates/.agents/skills/complete-task/SKILL.en.md +4 -0
- package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +4 -0
- package/templates/.agents/skills/run-manual-validation/SKILL.en.md +6 -6
- package/templates/.agents/skills/run-manual-validation/SKILL.zh-CN.md +6 -6
- package/templates/.agents/skills/run-manual-validation/config/verify.en.json +14 -3
- package/templates/.agents/skills/run-manual-validation/config/verify.zh-CN.json +14 -3
- package/templates/.agents/skills/run-manual-validation/reference/discovery-and-execution.en.md +67 -0
- package/templates/.agents/skills/run-manual-validation/reference/discovery-and-execution.zh-CN.md +67 -0
- package/templates/.agents/skills/run-manual-validation/reference/report-template.en.md +25 -0
- package/templates/.agents/skills/run-manual-validation/reference/report-template.zh-CN.md +25 -0
- package/templates/.agents/skills/run-task/SKILL.en.md +9 -7
- package/templates/.agents/skills/run-task/SKILL.zh-CN.md +9 -7
- package/templates/.agents/skills/run-task/reference/host-validation.en.md +2 -0
- package/templates/.agents/skills/run-task/reference/host-validation.zh-CN.md +2 -0
- package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +75 -3
- package/templates/.agents/workspace/README.en.md +0 -26
- package/templates/.agents/workspace/README.zh-CN.md +0 -26
package/templates/.agents/skills/run-manual-validation/reference/discovery-and-execution.en.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Automatic Discovery and Per-item Execution
|
|
2
|
+
|
|
3
|
+
Read this file before parsing input, discovering manual-validation items, or constructing validation actions.
|
|
4
|
+
|
|
5
|
+
## Input Modes
|
|
6
|
+
|
|
7
|
+
| Input | Handling |
|
|
8
|
+
|-------|----------|
|
|
9
|
+
| Non-empty target and command surround a literal `--` | Explicit mode; the command is authoritative for that target |
|
|
10
|
+
| A literal `--` is present but the target or command is empty | Invalid input; stop before `validation-run.started` |
|
|
11
|
+
| No `--` and only a task ref | Automatic mode |
|
|
12
|
+
| No `--` and additional positional arguments | Invalid or partial input; do not ignore arguments or guess a command |
|
|
13
|
+
|
|
14
|
+
Explicit mode still reads available sources to map coverage, but it must not synthesize another command for the same target. Only automatic mode constructs actions for discovered items.
|
|
15
|
+
|
|
16
|
+
## Work Gate Matrix
|
|
17
|
+
|
|
18
|
+
| mode | source state | gate |
|
|
19
|
+
|------|--------------|------|
|
|
20
|
+
| `explicit` | `any` | `continue` |
|
|
21
|
+
| `automatic` | `items` | `continue` |
|
|
22
|
+
| `automatic` | `empty` | `stop` |
|
|
23
|
+
| `automatic` | `unreadable-only` | `stop` |
|
|
24
|
+
|
|
25
|
+
The user command is effective work in valid explicit mode. Empty or unreadable sources affect only coverage mapping and reporting and must not cause an early stop. Automatic mode depends on reliable discovery results.
|
|
26
|
+
|
|
27
|
+
## Discovery Sources
|
|
28
|
+
|
|
29
|
+
1. Read manual-validation items from the latest `review-code` returned by `task-artifact`; this is the canonical local source. Read only that round's structured list, never task.md prose, older reviews, the activity log, or comment history.
|
|
30
|
+
2. Run `agent-infra-internal platform-pr inspect {task-id}` and read the bound PR body's pending manual-validation list from a successful response as the supplemental source.
|
|
31
|
+
3. Deduplicate semantically by target, required environment, and expected assertion. Merge identical items with review-code details taking precedence, append PR-only items, and classify material conflicts as `unresolved`.
|
|
32
|
+
4. Assign report-local IDs `MV-1..N` and record source, target, expected assertion, required capability, and candidate steps. Do not write the task ledger.
|
|
33
|
+
|
|
34
|
+
## PR Source Status
|
|
35
|
+
|
|
36
|
+
| PR inspect result | Local items exist | No local items |
|
|
37
|
+
|-------------------|-------------------|----------------|
|
|
38
|
+
| Success | Merge lists; use only local items if the PR list is empty | Use the PR list; stop before started when both lists are empty |
|
|
39
|
+
| `no-op` + `PR_NOT_LINKED` | Use local items only | Stop normally before started |
|
|
40
|
+
| `failed` or `blocked` | Continue with local items; record typed status, stable error code, and the source coverage gap | Fail closed before started and request a retry after platform access is restored |
|
|
41
|
+
|
|
42
|
+
Explicit mode may run its authoritative command when PR inspection fails, but the report must state that the PR list could not be reconciled. Never treat a read failure as an empty list or record the raw remote response.
|
|
43
|
+
|
|
44
|
+
## Classification and Safe Actions
|
|
45
|
+
|
|
46
|
+
Assign exactly one classification per item:
|
|
47
|
+
|
|
48
|
+
- `executable`: host capability is supported by sufficient evidence and the action is minimal, non-interactive, and scoped.
|
|
49
|
+
- `unavailable`: the required platform, filesystem semantics, permission, container, or account is definitely absent.
|
|
50
|
+
- `unknown`: only weak signals exist and a safe probe cannot prove capability.
|
|
51
|
+
- `unsafe`: validation would require destructive, secret-exposing, or unsanitizable actions.
|
|
52
|
+
- `unresolved`: sources materially conflict about the environment or expected assertion.
|
|
53
|
+
|
|
54
|
+
Only `executable` items may run. Commands must not expose credentials, environment variables, full argv, absolute user paths, or raw transcripts. Leave a coverage gap when safety cannot be established.
|
|
55
|
+
|
|
56
|
+
## Per-item Execution
|
|
57
|
+
|
|
58
|
+
1. Invoke each executable item separately:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
ai task validate {task-ref} --scope snapshot --format json -- {command...}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
2. Only when the item or first-run evidence proves a dependency on uncommitted content, original mounts, or in-place permissions, explicitly invoke that item a second time with `--scope inplace` and record the reason.
|
|
65
|
+
3. One item failure does not stop independent remaining items. Record exit status, cleanup, and the sanitized JSON allowlist separately.
|
|
66
|
+
4. When the list is non-empty but no item is `executable`, still create and complete a validation-run artifact after started; do not run placeholder or fabricated commands.
|
|
67
|
+
5. Always stop before started for invalid input. In automatic mode, also stop before started without an artifact when both sources are reliably empty or the sole possible source is unreadable with no local items; those source-based stop conditions do not apply to valid explicit mode.
|
package/templates/.agents/skills/run-manual-validation/reference/discovery-and-execution.zh-CN.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# 自动发现与逐项执行
|
|
2
|
+
|
|
3
|
+
在解析输入、发现人工校验项或构造验证动作前读取本文件。
|
|
4
|
+
|
|
5
|
+
## 输入模式
|
|
6
|
+
|
|
7
|
+
| 输入 | 处理 |
|
|
8
|
+
|------|------|
|
|
9
|
+
| literal `--` 前后分别有非空验证目标和命令 | 显式模式;命令为该目标的权威动作 |
|
|
10
|
+
| 存在 literal `--`,但目标或命令为空 | 非法输入;在 `validation-run.started` 前停止 |
|
|
11
|
+
| 不存在 `--`,且只有 task ref | 自动模式 |
|
|
12
|
+
| 不存在 `--`,但还有位置参数 | 非法/半截输入;不得忽略参数或猜测命令 |
|
|
13
|
+
|
|
14
|
+
显式模式也要读取可用来源以映射覆盖范围,但不得为同一目标另行合成命令。自动模式才为发现项构造动作。
|
|
15
|
+
|
|
16
|
+
## 工作门禁矩阵
|
|
17
|
+
|
|
18
|
+
| mode | source state | gate |
|
|
19
|
+
|------|--------------|------|
|
|
20
|
+
| `explicit` | `any` | `continue` |
|
|
21
|
+
| `automatic` | `items` | `continue` |
|
|
22
|
+
| `automatic` | `empty` | `stop` |
|
|
23
|
+
| `automatic` | `unreadable-only` | `stop` |
|
|
24
|
+
|
|
25
|
+
合法显式模式的用户命令本身就是有效工作;来源为空或不可读只影响覆盖映射和报告,不得触发早退。自动模式必须依赖可靠发现结果。
|
|
26
|
+
|
|
27
|
+
## 发现来源
|
|
28
|
+
|
|
29
|
+
1. 从 `task-artifact` 返回的最新 `review-code` 读取人工校验项,作为 canonical 本地来源。只读取该轮结构化的人工校验清单,不扫描 task.md 自由文本、旧审查轮次、活动日志或评论历史。
|
|
30
|
+
2. 运行 `agent-infra-internal platform-pr inspect {task-id}`,从成功返回的绑定 PR 正文读取待人工验证清单,作为补充来源。
|
|
31
|
+
3. 按目标、所需环境和预期断言语义去重。相同项合并来源并优先采用 review-code 细节;PR 独有项追加;关键要求冲突的项标为 `unresolved`。
|
|
32
|
+
4. 为本轮清单分配局部 ID `MV-1..N`,记录来源、目标、预期断言、所需能力和候选步骤;不得写入 task ledger。
|
|
33
|
+
|
|
34
|
+
## PR 来源状态
|
|
35
|
+
|
|
36
|
+
| PR inspect 结果 | 本地有项目 | 本地无项目 |
|
|
37
|
+
|-----------------|------------|------------|
|
|
38
|
+
| 成功 | 合并清单;PR 空清单时仅用本地项 | 使用 PR 清单;两边均为空时 started 前正常停止 |
|
|
39
|
+
| `no-op` + `PR_NOT_LINKED` | 仅使用本地项 | started 前正常停止 |
|
|
40
|
+
| `failed` 或 `blocked` | 继续本地项;在报告记录 typed 状态、稳定错误码和来源覆盖缺口 | started 前 fail closed,提示恢复平台访问后重试 |
|
|
41
|
+
|
|
42
|
+
显式模式在 PR 检查失败时仍可执行权威命令,但必须记录无法核对 PR 清单。不要把读取失败当作空清单,也不要记录原始远端响应。
|
|
43
|
+
|
|
44
|
+
## 分类与安全动作
|
|
45
|
+
|
|
46
|
+
逐项选择一种分类:
|
|
47
|
+
|
|
48
|
+
- `executable`:宿主能力已有充分证据;动作最小、非交互且作用域受限。
|
|
49
|
+
- `unavailable`:明确缺少所需平台、文件系统语义、权限、容器或账号。
|
|
50
|
+
- `unknown`:仅有弱信号,安全探测也无法证明能力。
|
|
51
|
+
- `unsafe`:只能通过破坏性、泄密或无法去敏的动作验证。
|
|
52
|
+
- `unresolved`:来源对环境或预期断言存在关键冲突。
|
|
53
|
+
|
|
54
|
+
只有 `executable` 可以运行。命令不得输出凭据、环境变量、完整 argv、绝对用户路径或原始 transcript;不能证明安全就保留覆盖缺口。
|
|
55
|
+
|
|
56
|
+
## 逐项执行
|
|
57
|
+
|
|
58
|
+
1. 每个可执行项分别调用:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
ai task validate {task-ref} --scope snapshot --format json -- {command...}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
2. 仅当项目要求或首次证据证明依赖未提交内容、原挂载或原位权限时,再为该项显式调用一次 `--scope inplace`,并记录升级理由。
|
|
65
|
+
3. 单项失败不阻止其余独立项;分别记录退出状态、cleanup 和去敏 JSON allowlist。
|
|
66
|
+
4. 清单非空但没有 `executable` 项时,仍在 started 后生成 validation-run 产物并完成 lifecycle,不运行占位或伪造命令。
|
|
67
|
+
5. 输入非法时始终在 started 前停止。自动模式下,两来源可靠地确认无项,或唯一可能来源不可读且本地无项时,也在 started 前停止且不写产物;合法显式模式不适用这两个来源停止条件。
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Validation Run Evidence
|
|
2
2
|
|
|
3
|
+
## Input Mode
|
|
4
|
+
|
|
5
|
+
- Mode: `{explicit|automatic}`
|
|
6
|
+
- Input decision: {sanitized-input-decision}
|
|
7
|
+
- PR source status: `{success|no-op|failed|blocked}` / `{stable-code-or-none}`
|
|
8
|
+
|
|
3
9
|
## State Check
|
|
4
10
|
|
|
5
11
|
```text
|
|
@@ -11,6 +17,12 @@ $ agent-infra-internal task-snapshot {task-id} --format text
|
|
|
11
17
|
|
|
12
18
|
{target-and-coverage}
|
|
13
19
|
|
|
20
|
+
## Discovered Items
|
|
21
|
+
|
|
22
|
+
| ID | Source | Target | Required Capability | Expected Assertion | Classification |
|
|
23
|
+
|----|--------|--------|---------------------|--------------------|----------------|
|
|
24
|
+
| `MV-{N}` | `{review-code|pr|merged|explicit}` | {target} | {capability} | {expected-assertion} | `{executable|unavailable|unknown|unsafe|unresolved}` |
|
|
25
|
+
|
|
14
26
|
## Mode Decision
|
|
15
27
|
|
|
16
28
|
- Mode: `{snapshot|inplace}`
|
|
@@ -28,6 +40,19 @@ $ agent-infra-internal task-snapshot {task-id} --format text
|
|
|
28
40
|
{sanitized-ai-task-validate-json}
|
|
29
41
|
```
|
|
30
42
|
|
|
43
|
+
## Per-item Results
|
|
44
|
+
|
|
45
|
+
### MV-{N}
|
|
46
|
+
|
|
47
|
+
- Source: `{source}`
|
|
48
|
+
- Classification: `{classification}`
|
|
49
|
+
- Scope: `{snapshot|inplace|not-run}`
|
|
50
|
+
- Command name: `{basename-only|not-run}`
|
|
51
|
+
- Exit status: `{exit-status|not-run}`
|
|
52
|
+
- Runtime upgrade: {none-or-reason}
|
|
53
|
+
- Result: {sanitized-result-or-coverage-gap}
|
|
54
|
+
- Cleanup: {cleanup-result}
|
|
55
|
+
|
|
31
56
|
## Cleanup and Recovery
|
|
32
57
|
|
|
33
58
|
{cleanup-and-recovery-result}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# 验证运行证据
|
|
2
2
|
|
|
3
|
+
## 输入模式
|
|
4
|
+
|
|
5
|
+
- 模式:`{explicit|automatic}`
|
|
6
|
+
- 输入判定:{sanitized-input-decision}
|
|
7
|
+
- PR 来源状态:`{success|no-op|failed|blocked}` / `{stable-code-or-none}`
|
|
8
|
+
|
|
3
9
|
## 状态核对
|
|
4
10
|
|
|
5
11
|
```text
|
|
@@ -11,6 +17,12 @@ $ agent-infra-internal task-snapshot {task-id} --format text
|
|
|
11
17
|
|
|
12
18
|
{target-and-coverage}
|
|
13
19
|
|
|
20
|
+
## 发现清单
|
|
21
|
+
|
|
22
|
+
| ID | 来源 | 目标 | 所需能力 | 预期断言 | 分类 |
|
|
23
|
+
|----|------|------|----------|----------|------|
|
|
24
|
+
| `MV-{N}` | `{review-code|pr|merged|explicit}` | {target} | {capability} | {expected-assertion} | `{executable|unavailable|unknown|unsafe|unresolved}` |
|
|
25
|
+
|
|
14
26
|
## 模式判定
|
|
15
27
|
|
|
16
28
|
- 模式:`{snapshot|inplace}`
|
|
@@ -28,6 +40,19 @@ $ agent-infra-internal task-snapshot {task-id} --format text
|
|
|
28
40
|
{sanitized-ai-task-validate-json}
|
|
29
41
|
```
|
|
30
42
|
|
|
43
|
+
## 逐项结果
|
|
44
|
+
|
|
45
|
+
### MV-{N}
|
|
46
|
+
|
|
47
|
+
- 来源:`{source}`
|
|
48
|
+
- 分类:`{classification}`
|
|
49
|
+
- Scope:`{snapshot|inplace|not-run}`
|
|
50
|
+
- 命令名称:`{basename-only|not-run}`
|
|
51
|
+
- 退出状态:`{exit-status|not-run}`
|
|
52
|
+
- 运行时升级:{none-or-reason}
|
|
53
|
+
- 结果:{sanitized-result-or-coverage-gap}
|
|
54
|
+
- Cleanup:{cleanup-result}
|
|
55
|
+
|
|
31
56
|
## 清理与恢复
|
|
32
57
|
|
|
33
58
|
{cleanup-and-recovery-result}
|
|
@@ -9,13 +9,15 @@ description: >
|
|
|
9
9
|
|
|
10
10
|
The orchestrator delegates only and never executes a stage skill itself. First read `.agents/rules/no-mid-flow-questions.md`, `.agents/rules/lifecycle-orchestration.md`, and `reference/host-validation.md`.
|
|
11
11
|
|
|
12
|
-
1. Resolve the task, current Agent Client, and optional atomic policy flags
|
|
13
|
-
2.
|
|
14
|
-
3. Run `
|
|
15
|
-
4.
|
|
16
|
-
5. Codex
|
|
17
|
-
6.
|
|
18
|
-
7.
|
|
12
|
+
1. Resolve the canonical task ID, current Agent Client, and optional atomic policy flags, then run `task-snapshot`. If one explicit role field is present, all four are required.
|
|
13
|
+
2. Before `begin-or-resume`, Codex selects a host. Without `AGENT_INFRA_CONTROL_TOKEN`, use direct-host. With task-bound control authority but no `AGENT_INFRA_CODEX_CONTROLLER_CONTEXT`, only run `codex-sandbox-controller run --task-id {task-id} --task-ref {task-ref}` with the complete policy and wait; the outer loop must not create a run, baseline, or receipt. With a context, run `verify-context --task-id {task-id}` first. Stop on any bootstrap, bundle, source/profile discovery, or context failure.
|
|
14
|
+
3. Run `task-orchestration {task-id} begin-or-resume --client {client}` with the complete explicit policy. With no explicit policy, core reads that client's configured policy; existing v2/v3 runs use persisted policy. Stop on paused/completed results.
|
|
15
|
+
4. Run `route`. On `completed`, run `agent-infra-internal task-verify {task-id} run-task.completed --format text` and stop. Only a `running` result with non-null `next` supplies action, role, round, artifact, requested model, and requested effort.
|
|
16
|
+
5. Codex runs `codex-lifecycle capability-arm --task-id {task-id}` once. The current loop's real PostToolUse must attest that ordinary tool response. Pass only its marker token to `prepare --client {client} --capability-token {token}`. Before snapshotting, core atomically consumes it, verifies task, hook source, build, contract, and controller binding, and persists the capability session, turn, and tool-use origin. Activation then verifies that spawn belongs to the same session and turn and uses a distinct tool-use. Other clients use the same prepare without a token. Failure creates no baseline, receipt, or child.
|
|
17
|
+
6. After prepare, run `task-orchestration <task-ref> dispatch` immediately before calling the fresh native child, then use route's exact model/effort and only the short task ref, skill, `--orchestrated`, and stage identity. The trusted hook-spawn first-observation time must fall between dispatch and the deadline. Its first provenance-sensitive command must be `await-activation --stage ... --round ... --artifact ... --role ...`; before `running`, it must not snapshot, emit stage-started, write business files, or start commit. Only explicit `recover-prepared` may clear an expired orphan when the task fingerprint is exact, no commit intent exists, and no matching unconsumed active lifecycle evidence remains.
|
|
18
|
+
7. Codex uses SubagentStart/Stop and App Server actual evidence to activate, consume, and seal one v3 receipt; trusted parent fallback must produce the same provenance. Timed-out waits do nothing. Advance only a sealed receipt and repeat step 4 only while running.
|
|
19
|
+
8. Create a fresh child each round and never follow up with an old reviewer. Each requested/actual mismatch needs its own host fallback reason. Capability, hook, source, controller, build, identity, ledger, or fingerprint failure pauses and fails closed.
|
|
20
|
+
9. On pause or completion, run the matching typed verification and report the structured endpoint.
|
|
19
21
|
|
|
20
22
|
## Stop
|
|
21
23
|
|
|
@@ -9,13 +9,15 @@ description: >
|
|
|
9
9
|
|
|
10
10
|
总控只编排,不直接执行任何阶段技能。执行前先读取 `.agents/rules/no-mid-flow-questions.md`、`.agents/rules/lifecycle-orchestration.md` 与 `reference/host-validation.md`。
|
|
11
11
|
|
|
12
|
-
1.
|
|
13
|
-
2.
|
|
14
|
-
3. 调用 `
|
|
15
|
-
4.
|
|
16
|
-
5. Codex
|
|
17
|
-
6.
|
|
18
|
-
7.
|
|
12
|
+
1. 解析规范任务 ID、当前 Agent Client,以及可选的原子策略 `--executor-model`、`--executor-reasoning-effort`、`--reviewer-model`、`--reviewer-reasoning-effort`,并执行 `agent-infra-internal task-snapshot {task-id} --format text`。任一显式策略字段出现时四个 role 字段必须完整,不得与配置拼接;两个角色可以使用同一模型。
|
|
13
|
+
2. Codex 在 `begin-or-resume` 前选择宿主:没有 `AGENT_INFRA_CONTROL_TOKEN` 时使用 direct-host;有 task-bound control authority 但没有 `AGENT_INFRA_CODEX_CONTROLLER_CONTEXT` 时,只调用 `agent-infra-internal codex-sandbox-controller run --task-id {task-id} --task-ref {task-ref}`(转发完整显式策略)并等待其终态,外层不得创建 run、baseline 或 receipt;已有 context 时先调用 `verify-context --task-id {task-id}`。controller 的 bootstrap、bundle、source/profile discovery 或 context 任一校验失败即停止。
|
|
14
|
+
3. 调用 `agent-infra-internal task-orchestration {task-id} begin-or-resume --client {client}` 并转发完整显式策略。完全没有显式策略时由核心读取当前 client 的 `agentClients[].orchestration`;已有 v2/v3 run 使用持久化策略。仅当核心返回 `ORCHESTRATION_MODEL_POLICY_REQUIRED` 时,先用 `agent-client model-selection` 展示 complete/partial/interactive-only 来源,再一次收集完整策略;未回答则不创建 run。若为 paused/completed,按结构化结果停止。
|
|
15
|
+
4. 调用 `route` 并读取结构化结果。若返回 `completed`,立即运行 `agent-infra-internal task-verify {task-id} run-task.completed --format text` 并停止;仅当返回 `running` 且 `next` 非空时读取唯一 action、role、round、artifact、`requestedModel` 和 `requestedReasoningEffort`,不得自行推断。
|
|
16
|
+
5. Codex 先调用一次 `agent-infra-internal codex-lifecycle capability-arm --task-id {task-id}`。该普通工具调用必须由当前 loop 的真实 PostToolUse 回写 attestation;仅把返回的 marker 中 token 传给 `prepare --client {client} --capability-token {token}`。核心在快照前原子消费 token,校验 task、hook source、build、contract 与 controller binding,并持久化 capability 的 session、turn、tool-use 来源。activation 再校验 spawn 与该来源属于同一 session/turn,且 spawn 使用独立的 tool-use。其他客户端直接调用同一 prepare(无 token)。任一失败不得创建 baseline、receipt 或 child。
|
|
17
|
+
6. prepare 成功后,在调用 fresh 原生子 Agent 的紧邻前一步执行 `task-orchestration <task-ref> dispatch`,再显式覆盖 route 返回的 model/effort;只传短任务引用、skill 名、`--orchestrated` 与 stage/round/artifact/role。可信 hook-spawn 首次观察时间必须位于 dispatch 与 deadline 之间。child 的第一条 provenance-sensitive 命令必须是 `await-activation --stage ... --round ... --artifact ... --role ...`;返回 running 前禁止 snapshot、阶段 started、业务写入或 commit-start。超时由核心暂停;崩溃遗留 prepared receipt 只能在 exact workspace fingerprint、无 commit intent、无匹配的未消费 active lifecycle evidence 且 deadline 已过时显式 `recover-prepared`。
|
|
18
|
+
7. Codex 用 SubagentStart/Stop 与 App Server actual evidence 激活、消费并封存唯一 receipt;受信 parent fallback 仍必须形成相同 v3 provenance。timed-out wait 无动作;只有 empty turns 或协议 `inProgress` 可等待,malformed、身份/传输错误或异常 terminal 均暂停。子 Agent 返回后只对 sealed receipt 调用 `advance`;只有 `running` 才重复步骤 4。
|
|
19
|
+
8. 每轮创建新 child;禁止 follow-up 复用 reviewer。actual model/effort 与 requested 不同时必须有各自的宿主降级理由。任何 capability、hook、source、controller、build、身份、账本或 fingerprint 异常都调用 `pause` 并失败关闭。
|
|
20
|
+
9. 完成或暂停后运行对应 typed verification,并把结构化 run 摘要、暂停原因、commit 终点或 clean completion evidence 告知用户。
|
|
19
21
|
|
|
20
22
|
## 停止
|
|
21
23
|
|
|
@@ -8,6 +8,7 @@ Before publishing support for a client, prove the lifecycle evidence chain with
|
|
|
8
8
|
- Raw start/stop events, or the parent PostTool spawn/completed-wait fallback when custom roles omit them, stably correlate the managed agent, parent/child identity, fresh spawn mode, actual model, and actual reasoning effort.
|
|
9
9
|
- Explicit requested model/effort reaches each executor/reviewer. A fallback of either field reports the corresponding actual value and its own non-empty reason.
|
|
10
10
|
- Candidate-checkout and packed-install behavior match, with model policy, receipts, and verification results auditable in `orchestration.json`.
|
|
11
|
+
- Direct-host project/managed source and sandbox isolated-user source preserve the same build, contract, profile, and controller provenance through prepare/start/stop/consume.
|
|
11
12
|
|
|
12
13
|
## Validation Sequence
|
|
13
14
|
|
|
@@ -16,5 +17,6 @@ Before publishing support for a client, prove the lifecycle evidence chain with
|
|
|
16
17
|
3. Validate model/effort match paths, single and dual justified fallbacks, and fail-closed behavior for missing actual fields.
|
|
17
18
|
4. Validate the same commit from a candidate checkout and an `npm pack` install; record the tarball hash and results.
|
|
18
19
|
5. Commit only redacted summaries and non-sensitive fixtures. Remove or replace tokens, user-specific absolute paths, transcript content, and credentials.
|
|
20
|
+
6. For sandbox, run at least ten cold executor starts and ten cold reviewer starts. Record monotonic prepared, spawn-dispatch, SubagentStart, and activation-completed timestamps plus p50/p95/max. Enable only when max plus 20% fits the deadline and symlink/config/plugin/lease/context/build failure injection and terminal cleanup audits pass.
|
|
19
21
|
|
|
20
22
|
If any required field cannot be observed reliably from the real host, keep that client's orchestration capability `unsupported` and record the gap as manual validation. Codex may advertise `experimental`, but every `prepare` must still pass static preflight and either native start/stop or the parent spawn/completed-wait fallback must produce verifiable consumed host evidence. The fallback may wait only for empty turns or protocol `inProgress`; malformed, identity/transport errors, or abnormal terminals pause deterministically.
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
- 原始 start/stop 事件,或 custom role 缺少它们时的 parent PostTool spawn/completed-wait fallback,能稳定关联 managed agent、parent/child identity、fresh spawn mode、actual model 和 actual reasoning effort。
|
|
9
9
|
- 显式 requested model/effort 能传给 executor/reviewer;宿主对任一字段回退时,事件能给出对应 actual 值与独立的非空 fallback reason。
|
|
10
10
|
- candidate checkout 与打包安装后的行为一致,且模型策略、receipt 与验证结果可从 `orchestration.json` 复核。
|
|
11
|
+
- direct-host 的 project/managed source 与 sandbox controller 的 isolated-user source、build/contract/profile/controller digest 必须在 prepare/start/stop/consume 全链路一致。
|
|
11
12
|
|
|
12
13
|
## 验证顺序
|
|
13
14
|
|
|
@@ -16,5 +17,6 @@
|
|
|
16
17
|
3. 分别验证 model/effort 的 requested/actual 一致路径、单项与双项有理由 fallback 路径,并确认缺 actual 字段会失败关闭。
|
|
17
18
|
4. 对同一 commit 执行 candidate checkout 与 `npm pack` 安装验证,记录 tarball 哈希和结果。
|
|
18
19
|
5. 仅把去敏摘要与非敏感 fixture 纳入版本库;token、绝对用户路径、transcript 内容和凭证必须删除或替换。
|
|
20
|
+
6. sandbox backend 另做至少 10 次 executor 与 10 次 reviewer 冷启动,记录 prepared、spawn dispatch、SubagentStart、activation completed 的单调时钟及 p50/p95/max;仅当 max 加 20% 余量不超过 deadline,并通过 symlink/config/plugin/lease/context/build 失败注入和终态清理审计时启用。
|
|
19
21
|
|
|
20
22
|
任一字段无法从真实宿主稳定观察时,该客户端的 orchestration capability 保持 `unsupported`,并把缺口记录为人工验证项。Codex 可声明为 `experimental`,但每次 `prepare` 仍必须通过静态 preflight,且原生 start/stop 或 parent spawn/completed-wait fallback 必须形成可验证的 consumed host evidence。fallback 只允许 empty turns/协议 `inProgress` 等待;malformed、身份/传输错误或异常 terminal 都稳定暂停。
|
|
@@ -82,7 +82,6 @@ const DEFAULTS = {
|
|
|
82
82
|
".agents/skills/",
|
|
83
83
|
".agents/templates/",
|
|
84
84
|
".agents/workflows/",
|
|
85
|
-
".agents/workspace/README.md",
|
|
86
85
|
".git-hooks/check-large-files.cjs",
|
|
87
86
|
".git-hooks/check-version-format.sh",
|
|
88
87
|
".github/scripts/",
|
|
@@ -110,7 +109,16 @@ const DEFAULTS = {
|
|
|
110
109
|
".git-hooks/pre-commit",
|
|
111
110
|
".gitignore"
|
|
112
111
|
],
|
|
113
|
-
"ejected": []
|
|
112
|
+
"ejected": [],
|
|
113
|
+
"retiredManaged": [
|
|
114
|
+
{
|
|
115
|
+
"path": ".agents/workspace/README.md",
|
|
116
|
+
"templateHashes": [
|
|
117
|
+
"sha256:967b27ca4008154c5abf99a1df728242f80ed3ace9bd98eb2828bc1c76af826c",
|
|
118
|
+
"sha256:15aa21942cf2a1396d27834f1d3d723b61a46f8d14600b706f39f3bebc21aea3"
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
]
|
|
114
122
|
}
|
|
115
123
|
};
|
|
116
124
|
|
|
@@ -1224,6 +1232,26 @@ function entryVariantRels(entry, allSet, platform) {
|
|
|
1224
1232
|
return rels;
|
|
1225
1233
|
}
|
|
1226
1234
|
|
|
1235
|
+
function ensureRuntimeWorkspace(projectRoot) {
|
|
1236
|
+
const directories = [
|
|
1237
|
+
path.join(projectRoot, '.agents'),
|
|
1238
|
+
path.join(projectRoot, '.agents', 'workspace'),
|
|
1239
|
+
...['active', 'blocked', 'completed', 'archive'].map((state) =>
|
|
1240
|
+
path.join(projectRoot, '.agents', 'workspace', state)
|
|
1241
|
+
)
|
|
1242
|
+
];
|
|
1243
|
+
for (const directory of directories) {
|
|
1244
|
+
if (fs.existsSync(directory)) {
|
|
1245
|
+
const stat = fs.lstatSync(directory);
|
|
1246
|
+
if (!stat.isDirectory() || stat.isSymbolicLink()) {
|
|
1247
|
+
throw new Error(`Runtime workspace path must be a real directory: ${directory}`);
|
|
1248
|
+
}
|
|
1249
|
+
continue;
|
|
1250
|
+
}
|
|
1251
|
+
fs.mkdirSync(directory, { mode: 0o700 });
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1227
1255
|
function syncTemplates(projectRoot, templateRootOverride) {
|
|
1228
1256
|
const configDir = path.join(projectRoot, '.agents');
|
|
1229
1257
|
const cfgPath = path.join(configDir, '.airc.json');
|
|
@@ -1234,6 +1262,7 @@ function syncTemplates(projectRoot, templateRootOverride) {
|
|
|
1234
1262
|
|
|
1235
1263
|
const originalConfigText = fs.readFileSync(cfgPath, 'utf8');
|
|
1236
1264
|
const cfg = JSON.parse(originalConfigText);
|
|
1265
|
+
ensureRuntimeWorkspace(projectRoot);
|
|
1237
1266
|
const configPathRel = norm(path.relative(projectRoot, cfgPath));
|
|
1238
1267
|
let templateRoot = templateRootOverride;
|
|
1239
1268
|
if (!templateRoot) {
|
|
@@ -1271,6 +1300,16 @@ function syncTemplates(projectRoot, templateRootOverride) {
|
|
|
1271
1300
|
merged: [...(cfg.files.merged || [])],
|
|
1272
1301
|
ejected: [...(cfg.files.ejected || [])]
|
|
1273
1302
|
};
|
|
1303
|
+
const retiredManaged = new Map((DEFAULTS.files.retiredManaged || []).map((retired) => {
|
|
1304
|
+
const descriptor = typeof retired === 'string' ? { path: retired } : retired;
|
|
1305
|
+
return [norm(descriptor.path), new Set(
|
|
1306
|
+
(descriptor.templateHashes || []).map(trustedBaseline).filter(Boolean)
|
|
1307
|
+
)];
|
|
1308
|
+
}));
|
|
1309
|
+
const planningRegistry = {
|
|
1310
|
+
...currentRegistry,
|
|
1311
|
+
managed: currentRegistry.managed.filter((entry) => !retiredManaged.has(norm(entry)))
|
|
1312
|
+
};
|
|
1274
1313
|
const sharedDefaults = {
|
|
1275
1314
|
managed: (DEFAULTS.files.managed || []).filter(
|
|
1276
1315
|
(entry) => !isPathOwnedByOtherPlatform(entry, platformType)
|
|
@@ -1280,7 +1319,7 @@ function syncTemplates(projectRoot, templateRootOverride) {
|
|
|
1280
1319
|
),
|
|
1281
1320
|
ejected: [...(DEFAULTS.files.ejected || [])]
|
|
1282
1321
|
};
|
|
1283
|
-
const assetPlan = planProjectRegistry(
|
|
1322
|
+
const assetPlan = planProjectRegistry(planningRegistry, sharedDefaults, enabledTUIs);
|
|
1284
1323
|
const managed = [...assetPlan.registry.managed];
|
|
1285
1324
|
const merged = [...assetPlan.registry.merged];
|
|
1286
1325
|
const ejected = [...assetPlan.registry.ejected];
|
|
@@ -1295,6 +1334,7 @@ function syncTemplates(projectRoot, templateRootOverride) {
|
|
|
1295
1334
|
for (const target of Object.keys(managedBaselines)) {
|
|
1296
1335
|
if (
|
|
1297
1336
|
!guardedManaged.has(norm(target))
|
|
1337
|
+
&& !retiredManaged.has(norm(target))
|
|
1298
1338
|
&& !allClientManaged.some((entry) => assetMatches(entry, target))
|
|
1299
1339
|
) {
|
|
1300
1340
|
delete managedBaselines[target];
|
|
@@ -1369,6 +1409,38 @@ function syncTemplates(projectRoot, templateRootOverride) {
|
|
|
1369
1409
|
)
|
|
1370
1410
|
);
|
|
1371
1411
|
|
|
1412
|
+
for (const [entry, historicalTemplateHashes] of retiredManaged) {
|
|
1413
|
+
const target = path.join(projectRoot, entry);
|
|
1414
|
+
const owned = currentRegistry.managed.some((candidate) => norm(candidate) === entry);
|
|
1415
|
+
if (!fs.existsSync(target)) continue;
|
|
1416
|
+
const stat = fs.lstatSync(target);
|
|
1417
|
+
const baseline = trustedBaseline(managedBaselines[entry]);
|
|
1418
|
+
const localHash = stat.isFile() && !stat.isSymbolicLink()
|
|
1419
|
+
? sha256(fs.readFileSync(target))
|
|
1420
|
+
: null;
|
|
1421
|
+
const safeToRemove = owned
|
|
1422
|
+
&& localHash !== null
|
|
1423
|
+
&& (localHash === baseline || historicalTemplateHashes.has(localHash));
|
|
1424
|
+
if (safeToRemove) {
|
|
1425
|
+
fs.unlinkSync(target);
|
|
1426
|
+
report.managed.removed.push(entry);
|
|
1427
|
+
if (Object.prototype.hasOwnProperty.call(managedBaselines, entry)) {
|
|
1428
|
+
delete managedBaselines[entry];
|
|
1429
|
+
baselinesChanged = true;
|
|
1430
|
+
}
|
|
1431
|
+
} else {
|
|
1432
|
+
report.managed.protected.push({
|
|
1433
|
+
target: entry,
|
|
1434
|
+
reason: owned && localHash !== null && baseline !== null
|
|
1435
|
+
? 'user-modified'
|
|
1436
|
+
: (owned && localHash === null ? 'invalid-type' : 'unknown-origin'),
|
|
1437
|
+
baseline,
|
|
1438
|
+
local: localHash,
|
|
1439
|
+
template: null
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1372
1444
|
const templateSources = Array.isArray(cfg.templates?.sources) ? cfg.templates.sources : [];
|
|
1373
1445
|
report.templateSources.configured = templateSources.length;
|
|
1374
1446
|
const { mergedRels, sourceMap } = mergeTemplateSources(templateRoot, templateSources, report);
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# AI Workspace
|
|
2
|
-
|
|
3
|
-
This directory is the runtime workspace for multi-AI collaboration. All contents are **git-ignored** except for this README and `.gitkeep` files.
|
|
4
|
-
|
|
5
|
-
## Directory Structure
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
.agents/workspace/
|
|
9
|
-
active/ # Currently active tasks and handoff documents
|
|
10
|
-
blocked/ # Tasks that are blocked and waiting for resolution
|
|
11
|
-
completed/ # Completed tasks (kept for reference)
|
|
12
|
-
logs/ # Collaboration logs and session records
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Usage
|
|
16
|
-
|
|
17
|
-
- **active/**: Place task files here when work begins. Move them to `completed/` or `blocked/` as appropriate.
|
|
18
|
-
- **blocked/**: Move tasks here when they cannot proceed. Document the blocker in the task file.
|
|
19
|
-
- **completed/**: Move tasks here when they are done. These serve as a historical record.
|
|
20
|
-
- **logs/**: Store session logs, AI conversation exports, or collaboration notes.
|
|
21
|
-
|
|
22
|
-
## Important
|
|
23
|
-
|
|
24
|
-
- Contents of this directory are **not version-controlled** (git-ignored).
|
|
25
|
-
- Do not store anything here that needs to be shared via git.
|
|
26
|
-
- Templates and workflow definitions belong in `.agents/`, not here.
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# AI 工作区
|
|
2
|
-
|
|
3
|
-
本目录是多 AI 协作的运行时工作区。除本 README 和 `.gitkeep` 文件外,所有内容均被 **git ignore**。
|
|
4
|
-
|
|
5
|
-
## 目录结构
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
.agents/workspace/
|
|
9
|
-
active/ # 当前活跃的任务和交接文档
|
|
10
|
-
blocked/ # 被阻塞的任务,等待解决
|
|
11
|
-
completed/ # 已完成的任务(保留供参考)
|
|
12
|
-
logs/ # 协作日志和会话记录
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## 使用方法
|
|
16
|
-
|
|
17
|
-
- **active/**:工作开始时将任务文件放在这里。根据情况将其移至 `completed/` 或 `blocked/`。
|
|
18
|
-
- **blocked/**:当任务无法继续时将其移至此处。在任务文件中记录阻塞原因。
|
|
19
|
-
- **completed/**:任务完成后将其移至此处。这些作为历史记录保留。
|
|
20
|
-
- **logs/**:存储会话日志、AI 对话导出或协作笔记。
|
|
21
|
-
|
|
22
|
-
## 重要事项
|
|
23
|
-
|
|
24
|
-
- 本目录的内容**不受版本控制**(已被 git ignore)。
|
|
25
|
-
- 不要在这里存储需要通过 git 共享的内容。
|
|
26
|
-
- 模板和工作流定义属于 `.agents/` 目录,而非此处。
|