@fitlab-ai/agent-infra 0.12.1 → 0.12.2

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.
Files changed (303) hide show
  1. package/README.md +0 -2
  2. package/README.zh-CN.md +0 -2
  3. package/dist/bin/internal-cli.js +2 -17
  4. package/dist/lib/agent-clients/adapter.js +0 -13
  5. package/dist/lib/agent-clients/adapters/antigravity-cli.js +0 -5
  6. package/dist/lib/agent-clients/adapters/claude-code-credentials.js +0 -17
  7. package/dist/lib/agent-clients/adapters/claude-code.js +0 -9
  8. package/dist/lib/agent-clients/adapters/codex.js +0 -52
  9. package/dist/lib/agent-clients/adapters/opencode.js +0 -5
  10. package/dist/lib/agent-clients/adapters/traecli.js +0 -5
  11. package/dist/lib/agent-clients/config.js +19 -54
  12. package/dist/lib/agent-clients/registry.js +1 -12
  13. package/dist/lib/agent-clients/schema.js +0 -18
  14. package/dist/lib/agent-clients/tokens.js +1 -2
  15. package/dist/lib/agent-clients/types.js +0 -1
  16. package/dist/lib/decide.js +2 -0
  17. package/dist/lib/git/worktree-identity.js +1 -9
  18. package/dist/lib/internal/agent-client.js +2 -62
  19. package/dist/lib/internal/cli-route-inventory.js +1 -5
  20. package/dist/lib/internal/manual-validation.js +18 -10
  21. package/dist/lib/internal/task-create.js +1 -1
  22. package/dist/lib/internal/task-event.js +1 -8
  23. package/dist/lib/internal/task-finalization.js +0 -1
  24. package/dist/lib/internal/task-lifecycle.js +2 -2
  25. package/dist/lib/internal/task-operation-registry.js +4 -20
  26. package/dist/lib/internal/task-review.js +4 -4
  27. package/dist/lib/platform/comment-safety.js +1 -7
  28. package/dist/lib/platform/in-label-sync.js +1 -14
  29. package/dist/lib/platform/issue-comments.js +1 -16
  30. package/dist/lib/platform/issues.js +1 -1
  31. package/dist/lib/platform/operation-coordinator.js +4 -2
  32. package/dist/lib/platform/pr-change-report.js +1 -4
  33. package/dist/lib/platform/pr-checks.js +2 -8
  34. package/dist/lib/platform/provider-validation.js +0 -20
  35. package/dist/lib/platform/pull-requests.js +73 -84
  36. package/dist/lib/platform/releases.js +1 -43
  37. package/dist/lib/platform/verification-required.js +0 -2
  38. package/dist/lib/platform/verification-sync.js +1 -79
  39. package/dist/lib/process-data/normalize.js +1 -185
  40. package/dist/lib/process-data/privacy.js +1 -16
  41. package/dist/lib/process-data/sources.js +2 -279
  42. package/dist/lib/render.js +0 -12
  43. package/dist/lib/run/index.js +15 -10
  44. package/dist/lib/run/skills.js +0 -3
  45. package/dist/lib/sandbox/commands/create.js +40 -53
  46. package/dist/lib/sandbox/commands/list-running.js +0 -18
  47. package/dist/lib/sandbox/commands/start.js +7 -8
  48. package/dist/lib/sandbox/constants.js +0 -6
  49. package/dist/lib/sandbox/control/client.js +0 -1
  50. package/dist/lib/sandbox/control/container-identity.js +1 -16
  51. package/dist/lib/sandbox/control/executor.js +0 -4
  52. package/dist/lib/sandbox/control/identity-sentinel.js +0 -7
  53. package/dist/lib/sandbox/control/lifecycle.js +21 -37
  54. package/dist/lib/sandbox/control/native-file-lock.js +0 -3
  55. package/dist/lib/sandbox/control/server.js +18 -38
  56. package/dist/lib/sandbox/control/state.js +1 -9
  57. package/dist/lib/sandbox/dockerfile.js +0 -6
  58. package/dist/lib/sandbox/engine.js +0 -14
  59. package/dist/lib/sandbox/engines/docker-exact-discovery.js +1 -4
  60. package/dist/lib/sandbox/engines/wsl2-paths.js +0 -3
  61. package/dist/lib/sandbox/recovery.js +24 -26
  62. package/dist/lib/sandbox/removal.js +11 -519
  63. package/dist/lib/sandbox/task-resolver.js +0 -41
  64. package/dist/lib/sandbox/tools.js +1 -4
  65. package/dist/lib/sandbox/workspace-view.js +1 -2
  66. package/dist/lib/server/display.js +0 -6
  67. package/dist/lib/task/activity-intent.js +45 -40
  68. package/dist/lib/task/activity-log.js +9 -16
  69. package/dist/lib/task/artifact-command.js +1 -1
  70. package/dist/lib/task/artifact-lifecycle.js +61 -63
  71. package/dist/lib/task/artifact-name.js +0 -6
  72. package/dist/lib/task/artifact-operations.js +3 -3
  73. package/dist/lib/task/capabilities.js +4 -5
  74. package/dist/lib/task/commands/log.js +0 -6
  75. package/dist/lib/task/commands/status.js +17 -60
  76. package/dist/lib/task/commit-operation.js +28 -39
  77. package/dist/lib/task/completion-facts.js +56 -43
  78. package/dist/lib/task/control-authority.js +23 -256
  79. package/dist/lib/task/control-recovery.js +3 -5
  80. package/dist/lib/task/create.js +2 -4
  81. package/dist/lib/task/decision-intents.js +8 -9
  82. package/dist/lib/task/delivery-target.js +1 -40
  83. package/dist/lib/task/events.js +84 -107
  84. package/dist/lib/task/finalization.js +44 -8
  85. package/dist/lib/task/ledger-intents.js +1 -1
  86. package/dist/lib/task/lifecycle-execution.js +38 -33
  87. package/dist/lib/task/lifecycle.js +49 -41
  88. package/dist/lib/task/local-artifact-finalization.js +1 -4
  89. package/dist/lib/task/manual-validation-evidence.js +1 -37
  90. package/dist/lib/task/platform-operation-recovery.js +67 -24
  91. package/dist/lib/task/pr-delivery-fact.js +2 -5
  92. package/dist/lib/task/qualification-confirmation.js +5 -7
  93. package/dist/lib/task/resolve-ref.js +1 -25
  94. package/dist/lib/task/review-command.js +2 -2
  95. package/dist/lib/task/review-finalization.js +1 -21
  96. package/dist/lib/task/review-fingerprint.js +0 -4
  97. package/dist/lib/task/secure-fs.js +0 -56
  98. package/dist/lib/task/short-id.js +1 -39
  99. package/dist/lib/task/skill-scope.js +0 -1
  100. package/dist/lib/task/verification-engine.js +58 -282
  101. package/dist/lib/task/verification.js +6 -3
  102. package/dist/lib/task/write.js +11 -1
  103. package/lib/agent-clients/adapter.ts +0 -76
  104. package/lib/agent-clients/adapters/antigravity-cli.ts +0 -5
  105. package/lib/agent-clients/adapters/claude-code-credentials.ts +0 -19
  106. package/lib/agent-clients/adapters/claude-code.ts +0 -9
  107. package/lib/agent-clients/adapters/codex.ts +0 -56
  108. package/lib/agent-clients/adapters/opencode.ts +0 -5
  109. package/lib/agent-clients/adapters/traecli.ts +0 -5
  110. package/lib/agent-clients/config.ts +20 -61
  111. package/lib/agent-clients/registry.ts +1 -34
  112. package/lib/agent-clients/schema.ts +0 -18
  113. package/lib/agent-clients/tokens.ts +1 -2
  114. package/lib/agent-clients/types.ts +0 -15
  115. package/lib/decide.ts +1 -0
  116. package/lib/git/worktree-identity.ts +0 -10
  117. package/lib/internal/agent-client.ts +2 -70
  118. package/lib/internal/cli-route-inventory.ts +1 -4
  119. package/lib/internal/manual-validation.ts +16 -9
  120. package/lib/internal/task-create.ts +0 -1
  121. package/lib/internal/task-event.ts +1 -5
  122. package/lib/internal/task-finalization.ts +0 -1
  123. package/lib/internal/task-lifecycle.ts +3 -5
  124. package/lib/internal/task-operation-registry.ts +3 -19
  125. package/lib/internal/task-review.ts +4 -4
  126. package/lib/platform/comment-safety.ts +0 -10
  127. package/lib/platform/github-provider.ts +0 -2
  128. package/lib/platform/in-label-sync.ts +0 -16
  129. package/lib/platform/issue-comments.ts +0 -21
  130. package/lib/platform/issues.ts +0 -2
  131. package/lib/platform/operation-coordinator.ts +4 -2
  132. package/lib/platform/pr-change-report.ts +0 -5
  133. package/lib/platform/pr-checks.ts +1 -10
  134. package/lib/platform/pr-review.ts +1 -1
  135. package/lib/platform/provider-bridge.ts +0 -1
  136. package/lib/platform/provider-loader.ts +1 -5
  137. package/lib/platform/provider-validation.ts +1 -49
  138. package/lib/platform/pull-requests.ts +64 -99
  139. package/lib/platform/releases.ts +1 -40
  140. package/lib/platform/verification-required.ts +0 -2
  141. package/lib/platform/verification-sync.ts +0 -94
  142. package/lib/process-data/normalize.ts +1 -186
  143. package/lib/process-data/privacy.ts +2 -19
  144. package/lib/process-data/sources.ts +3 -283
  145. package/lib/render.ts +0 -15
  146. package/lib/run/index.ts +13 -7
  147. package/lib/run/skills.ts +0 -4
  148. package/lib/sandbox/commands/create.ts +37 -74
  149. package/lib/sandbox/commands/list-running.ts +0 -19
  150. package/lib/sandbox/commands/start.ts +7 -10
  151. package/lib/sandbox/constants.ts +0 -8
  152. package/lib/sandbox/control/client.ts +0 -1
  153. package/lib/sandbox/control/container-identity.ts +1 -16
  154. package/lib/sandbox/control/executor.ts +1 -5
  155. package/lib/sandbox/control/identity-sentinel.ts +0 -8
  156. package/lib/sandbox/control/lifecycle.ts +18 -51
  157. package/lib/sandbox/control/native-file-lock.ts +0 -8
  158. package/lib/sandbox/control/protocol.ts +0 -2
  159. package/lib/sandbox/control/server.ts +13 -39
  160. package/lib/sandbox/control/state.ts +1 -10
  161. package/lib/sandbox/dockerfile.ts +0 -11
  162. package/lib/sandbox/engine.ts +0 -17
  163. package/lib/sandbox/engines/docker-exact-discovery.ts +1 -5
  164. package/lib/sandbox/engines/wsl2-paths.ts +0 -4
  165. package/lib/sandbox/recovery.ts +24 -26
  166. package/lib/sandbox/removal.ts +11 -696
  167. package/lib/sandbox/shell.ts +1 -1
  168. package/lib/sandbox/task-resolver.ts +0 -48
  169. package/lib/sandbox/tools.ts +1 -5
  170. package/lib/sandbox/workspace-view.ts +2 -4
  171. package/lib/server/display.ts +0 -14
  172. package/lib/server/process-control.ts +1 -1
  173. package/lib/task/activity-intent.ts +36 -44
  174. package/lib/task/activity-log.ts +9 -22
  175. package/lib/task/artifact-command.ts +1 -1
  176. package/lib/task/artifact-lifecycle.ts +58 -67
  177. package/lib/task/artifact-name.ts +0 -7
  178. package/lib/task/artifact-operations.ts +3 -3
  179. package/lib/task/capabilities.ts +5 -6
  180. package/lib/task/commands/log.ts +0 -7
  181. package/lib/task/commands/status.ts +14 -79
  182. package/lib/task/commit-operation.ts +29 -51
  183. package/lib/task/completion-facts.ts +45 -42
  184. package/lib/task/control-authority.ts +27 -317
  185. package/lib/task/control-recovery.ts +2 -5
  186. package/lib/task/create.ts +2 -5
  187. package/lib/task/decision-intents.ts +5 -5
  188. package/lib/task/delivery-target.ts +0 -40
  189. package/lib/task/events.ts +89 -123
  190. package/lib/task/finalization.ts +41 -9
  191. package/lib/task/ledger-intents.ts +1 -1
  192. package/lib/task/lifecycle-execution.ts +37 -89
  193. package/lib/task/lifecycle.ts +48 -44
  194. package/lib/task/local-artifact-finalization.ts +0 -7
  195. package/lib/task/manual-validation-evidence.ts +1 -47
  196. package/lib/task/platform-operation-recovery.ts +50 -26
  197. package/lib/task/pr-delivery-fact.ts +2 -11
  198. package/lib/task/qualification-confirmation.ts +6 -6
  199. package/lib/task/resolve-ref.ts +0 -23
  200. package/lib/task/review-command.ts +2 -2
  201. package/lib/task/review-finalization.ts +1 -27
  202. package/lib/task/review-fingerprint.ts +0 -8
  203. package/lib/task/secure-fs.ts +0 -42
  204. package/lib/task/short-id.ts +0 -43
  205. package/lib/task/skill-scope.ts +0 -1
  206. package/lib/task/verification-engine.ts +56 -287
  207. package/lib/task/verification.ts +5 -5
  208. package/lib/task/write.ts +12 -1
  209. package/package.json +2 -2
  210. package/templates/.agents/README.en.md +1 -3
  211. package/templates/.agents/README.zh-CN.md +0 -2
  212. package/templates/.agents/rules/README.en.md +0 -1
  213. package/templates/.agents/rules/README.zh-CN.md +0 -1
  214. package/templates/.agents/rules/commit-and-pr.en.md +1 -1
  215. package/templates/.agents/rules/commit-and-pr.zh-CN.md +1 -1
  216. package/templates/.agents/rules/no-mid-flow-questions.en.md +0 -10
  217. package/templates/.agents/rules/no-mid-flow-questions.zh-CN.md +0 -10
  218. package/templates/.agents/rules/pr-sync.en.md +1 -1
  219. package/templates/.agents/rules/pr-sync.zh-CN.md +1 -1
  220. package/templates/.agents/rules/task-management.en.md +3 -3
  221. package/templates/.agents/rules/task-management.zh-CN.md +3 -3
  222. package/templates/.agents/skills/analyze-task/SKILL.en.md +3 -3
  223. package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +3 -3
  224. package/templates/.agents/skills/cancel-task/SKILL.en.md +2 -2
  225. package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +2 -2
  226. package/templates/.agents/skills/code-task/SKILL.en.md +2 -2
  227. package/templates/.agents/skills/code-task/SKILL.zh-CN.md +4 -4
  228. package/templates/.agents/skills/commit/SKILL.en.md +2 -2
  229. package/templates/.agents/skills/commit/SKILL.zh-CN.md +2 -2
  230. package/templates/.agents/skills/commit/reference/commit-orchestration.en.md +6 -6
  231. package/templates/.agents/skills/commit/reference/commit-orchestration.zh-CN.md +6 -6
  232. package/templates/.agents/skills/plan-task/SKILL.en.md +2 -2
  233. package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +2 -2
  234. package/templates/.agents/skills/review-analysis/SKILL.en.md +3 -3
  235. package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +3 -3
  236. package/templates/.agents/skills/review-code/SKILL.en.md +5 -5
  237. package/templates/.agents/skills/review-code/SKILL.zh-CN.md +5 -5
  238. package/templates/.agents/skills/review-plan/SKILL.en.md +3 -3
  239. package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +3 -3
  240. package/templates/.agents/skills/review-pr/SKILL.en.md +4 -4
  241. package/templates/.agents/skills/review-pr/SKILL.zh-CN.md +4 -4
  242. package/templates/.agents/skills/run-manual-validation/SKILL.en.md +1 -1
  243. package/templates/.agents/skills/run-manual-validation/SKILL.zh-CN.md +1 -1
  244. package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +3 -75
  245. package/templates/.agents/templates/task.en.md +1 -0
  246. package/templates/.agents/templates/task.zh-CN.md +1 -0
  247. package/templates/.claude/settings.json +0 -24
  248. package/templates/.codex/hooks.json +0 -50
  249. package/dist/lib/agent-clients/adapters/codex-lifecycle/app-server.js +0 -582
  250. package/dist/lib/agent-clients/adapters/codex-lifecycle/binding.js +0 -114
  251. package/dist/lib/agent-clients/adapters/codex-lifecycle/build-identity.js +0 -237
  252. package/dist/lib/agent-clients/adapters/codex-lifecycle/cli.js +0 -443
  253. package/dist/lib/agent-clients/adapters/codex-lifecycle/evidence.js +0 -236
  254. package/dist/lib/agent-clients/adapters/codex-lifecycle/recovery.js +0 -292
  255. package/dist/lib/agent-clients/adapters/codex-lifecycle/store.js +0 -267
  256. package/dist/lib/agent-clients/adapters/codex-orchestration.js +0 -466
  257. package/dist/lib/internal/task-orchestration.js +0 -71
  258. package/dist/lib/platform/verification.js +0 -6
  259. package/dist/lib/run/prompt.js +0 -2
  260. package/dist/lib/sandbox/engines/authority.js +0 -289
  261. package/dist/lib/task/delegation-receipts.js +0 -410
  262. package/dist/lib/task/orchestration.js +0 -1233
  263. package/dist/lib/task/verification-checks.js +0 -9
  264. package/dist/lib/task/workspace-snapshot.js +0 -121
  265. package/dist/lifecycle-build-manifest.json +0 -6
  266. package/lib/agent-clients/adapters/codex-lifecycle/app-server.ts +0 -688
  267. package/lib/agent-clients/adapters/codex-lifecycle/binding.ts +0 -147
  268. package/lib/agent-clients/adapters/codex-lifecycle/build-identity.ts +0 -349
  269. package/lib/agent-clients/adapters/codex-lifecycle/cli.ts +0 -506
  270. package/lib/agent-clients/adapters/codex-lifecycle/evidence.ts +0 -385
  271. package/lib/agent-clients/adapters/codex-lifecycle/manifest-files.json +0 -41
  272. package/lib/agent-clients/adapters/codex-lifecycle/recovery.ts +0 -418
  273. package/lib/agent-clients/adapters/codex-lifecycle/store.ts +0 -354
  274. package/lib/agent-clients/adapters/codex-orchestration.ts +0 -630
  275. package/lib/internal/task-orchestration.ts +0 -74
  276. package/lib/platform/verification.ts +0 -11
  277. package/lib/run/prompt.ts +0 -1
  278. package/lib/sandbox/engines/authority.ts +0 -365
  279. package/lib/task/delegation-receipts.ts +0 -547
  280. package/lib/task/orchestration.ts +0 -1651
  281. package/lib/task/verification-checks.ts +0 -10
  282. package/lib/task/workspace-snapshot.ts +0 -144
  283. package/templates/.agents/hooks/lifecycle-delegation.js +0 -140
  284. package/templates/.agents/rules/lifecycle-orchestration.en.md +0 -44
  285. package/templates/.agents/rules/lifecycle-orchestration.zh-CN.md +0 -44
  286. package/templates/.agents/skills/run-task/SKILL.en.md +0 -29
  287. package/templates/.agents/skills/run-task/SKILL.zh-CN.md +0 -29
  288. package/templates/.agents/skills/run-task/config/verify.en.json +0 -10
  289. package/templates/.agents/skills/run-task/config/verify.zh-CN.json +0 -10
  290. package/templates/.agents/skills/run-task/reference/host-validation.en.md +0 -24
  291. package/templates/.agents/skills/run-task/reference/host-validation.zh-CN.md +0 -24
  292. package/templates/.claude/agents/agent-infra-lifecycle-executor.en.md +0 -6
  293. package/templates/.claude/agents/agent-infra-lifecycle-executor.zh-CN.md +0 -6
  294. package/templates/.claude/agents/agent-infra-lifecycle-reviewer.en.md +0 -6
  295. package/templates/.claude/agents/agent-infra-lifecycle-reviewer.zh-CN.md +0 -6
  296. package/templates/.claude/commands/run-task.en.md +0 -8
  297. package/templates/.claude/commands/run-task.zh-CN.md +0 -8
  298. package/templates/.codex/agents/agent-infra-lifecycle-executor.en.toml +0 -3
  299. package/templates/.codex/agents/agent-infra-lifecycle-executor.zh-CN.toml +0 -3
  300. package/templates/.codex/agents/agent-infra-lifecycle-reviewer.en.toml +0 -3
  301. package/templates/.codex/agents/agent-infra-lifecycle-reviewer.zh-CN.toml +0 -3
  302. package/templates/.opencode/commands/run-task.en.md +0 -11
  303. package/templates/.opencode/commands/run-task.zh-CN.md +0 -11
@@ -1,10 +0,0 @@
1
- const LOCAL_VERIFICATION_CHECKS = [
2
- 'task-meta', 'artifact', 'implementation-input', 'activity-log', 'completion-checklist',
3
- 'orchestration-state', 'orchestration-evidence'
4
- ] as const;
5
-
6
- function isLocalVerificationCheck(value: string): value is typeof LOCAL_VERIFICATION_CHECKS[number] {
7
- return (LOCAL_VERIFICATION_CHECKS as readonly string[]).includes(value);
8
- }
9
-
10
- export { LOCAL_VERIFICATION_CHECKS, isLocalVerificationCheck };
@@ -1,144 +0,0 @@
1
- import { createHash } from 'node:crypto';
2
- import fs from 'node:fs';
3
- import os from 'node:os';
4
- import path from 'node:path';
5
- import { spawnSync } from 'node:child_process';
6
- import { resolveProjectTaskWorkspaceRoot } from './workspace-root.ts';
7
-
8
- function git(repoRoot: string, indexFile: string | null, args: string[]): string {
9
- const env = indexFile ? { ...process.env, GIT_INDEX_FILE: indexFile } : process.env;
10
- const result = spawnSync('git', args, { cwd: repoRoot, env, encoding: 'utf8' });
11
- if (result.status !== 0) {
12
- throw new Error(String(result.stderr || result.stdout || `git ${args[0]} failed`).trim());
13
- }
14
- return result.stdout;
15
- }
16
-
17
- type RepositorySnapshot = Readonly<{
18
- head: string;
19
- headTree: string;
20
- worktreeTree: string;
21
- }>;
22
-
23
- type WorkspaceSnapshotContext = Readonly<{
24
- gitRoot: string;
25
- stateRoot: string;
26
- taskId: string | null;
27
- }>;
28
-
29
- type TaskFileFingerprint = Readonly<{
30
- path: string;
31
- mode: number;
32
- kind: 'file' | 'symlink';
33
- sha256: string;
34
- }>;
35
-
36
- type OrchestrationWorkspaceFingerprint = Readonly<{
37
- version: 2;
38
- gitTree: string;
39
- taskFiles: readonly TaskFileFingerprint[];
40
- }>;
41
-
42
- function captureWorktreeTree(repoRoot: string, forcedPath: string | null): string {
43
- const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-infra-orchestration-index-'));
44
- const indexFile = path.join(tempDir, 'index');
45
- try {
46
- try { git(repoRoot, indexFile, ['read-tree', 'HEAD']); }
47
- catch { git(repoRoot, indexFile, ['read-tree', '--empty']); }
48
- git(repoRoot, indexFile, ['add', '-A', '--', ':/']);
49
- if (forcedPath && fs.existsSync(path.join(repoRoot, forcedPath))) {
50
- git(repoRoot, indexFile, ['add', '-f', '--', forcedPath]);
51
- }
52
- return git(repoRoot, indexFile, ['write-tree']).trim();
53
- } finally {
54
- fs.rmSync(tempDir, { recursive: true, force: true });
55
- }
56
- }
57
-
58
- function taskFileFingerprints(stateRoot: string, taskId: string | null): TaskFileFingerprint[] {
59
- const activeRoot = path.join(resolveProjectTaskWorkspaceRoot(stateRoot), 'active');
60
- const roots = taskId ? [path.join(activeRoot, taskId)] : [activeRoot];
61
- const records: TaskFileFingerprint[] = [];
62
- const visit = (absolute: string, relative: string): void => {
63
- const stat = fs.lstatSync(absolute);
64
- if (stat.isDirectory()) {
65
- for (const name of fs.readdirSync(absolute).sort()) {
66
- visit(path.join(absolute, name), path.posix.join(relative, name));
67
- }
68
- return;
69
- }
70
- if (!stat.isFile() && !stat.isSymbolicLink()) return;
71
- if (/^task-workspace\/(?:active|blocked|completed)\/TASK-[0-9]{8}-[0-9]{6}\/\.runtime\/orchestration\.json$/u.test(relative)) return;
72
- const content = stat.isSymbolicLink()
73
- ? Buffer.from(fs.readlinkSync(absolute))
74
- : fs.readFileSync(absolute);
75
- records.push({
76
- path: relative,
77
- mode: stat.mode & 0o777,
78
- kind: stat.isSymbolicLink() ? 'symlink' : 'file',
79
- sha256: createHash('sha256').update(content).digest('hex')
80
- });
81
- };
82
- for (const root of roots) {
83
- if (!fs.existsSync(root)) continue;
84
- const relative = path.posix.join('task-workspace/active', path.relative(activeRoot, root).split(path.sep).join('/'));
85
- visit(root, relative.replace(/\/$/, ''));
86
- }
87
- return records.sort((left, right) => left.path.localeCompare(right.path));
88
- }
89
-
90
- function encodeWorkspaceFingerprint(value: OrchestrationWorkspaceFingerprint): string {
91
- return `ws2:${Buffer.from(JSON.stringify(value)).toString('base64url')}`;
92
- }
93
-
94
- function decodeWorkspaceFingerprint(value: string): OrchestrationWorkspaceFingerprint | null {
95
- if (!value.startsWith('ws2:')) return null;
96
- try {
97
- const parsed = JSON.parse(Buffer.from(value.slice(4), 'base64url').toString('utf8')) as OrchestrationWorkspaceFingerprint;
98
- if (parsed.version !== 2 || !/^[a-f0-9]{40,64}$/.test(parsed.gitTree) || !Array.isArray(parsed.taskFiles)) {
99
- throw new Error('invalid workspace fingerprint fields');
100
- }
101
- return parsed;
102
- } catch (error) {
103
- throw new Error(`ORCHESTRATION_SNAPSHOT_FAILED: ${error instanceof Error ? error.message : String(error)}`);
104
- }
105
- }
106
-
107
- function captureWorkspaceSnapshot(context: WorkspaceSnapshotContext): string {
108
- return encodeWorkspaceFingerprint({
109
- version: 2,
110
- gitTree: captureWorktreeTree(context.gitRoot, null),
111
- taskFiles: taskFileFingerprints(context.stateRoot, context.taskId)
112
- });
113
- }
114
-
115
- function captureRepositorySnapshot(repoRoot: string): RepositorySnapshot {
116
- return {
117
- head: git(repoRoot, null, ['rev-parse', 'HEAD']).trim(),
118
- headTree: git(repoRoot, null, ['rev-parse', 'HEAD^{tree}']).trim(),
119
- worktreeTree: captureWorktreeTree(repoRoot, null)
120
- };
121
- }
122
-
123
- function diffWorkspaceSnapshots(repoRoot: string, before: string, after: string): string[] {
124
- const beforeV2 = decodeWorkspaceFingerprint(before);
125
- const afterV2 = decodeWorkspaceFingerprint(after);
126
- if ((beforeV2 === null) !== (afterV2 === null)) {
127
- throw new Error('ORCHESTRATION_SNAPSHOT_FAILED: workspace fingerprint versions cannot be mixed');
128
- }
129
- if (!beforeV2 || !afterV2) {
130
- const output = git(repoRoot, null, ['diff', '--name-only', '-z', before, after]);
131
- return output.split('\0').filter(Boolean);
132
- }
133
- const output = git(repoRoot, null, ['diff', '--name-only', '-z', beforeV2.gitTree, afterV2.gitTree]);
134
- const changed = new Set(output.split('\0').filter(Boolean));
135
- const beforeFiles = new Map(beforeV2.taskFiles.map((record) => [record.path, JSON.stringify(record)]));
136
- const afterFiles = new Map(afterV2.taskFiles.map((record) => [record.path, JSON.stringify(record)]));
137
- for (const filePath of new Set([...beforeFiles.keys(), ...afterFiles.keys()])) {
138
- if (beforeFiles.get(filePath) !== afterFiles.get(filePath)) changed.add(filePath);
139
- }
140
- return [...changed].sort();
141
- }
142
-
143
- export { captureRepositorySnapshot, captureWorkspaceSnapshot, captureWorktreeTree, diffWorkspaceSnapshots };
144
- export type { OrchestrationWorkspaceFingerprint, RepositorySnapshot, WorkspaceSnapshotContext };
@@ -1,140 +0,0 @@
1
- import { execFileSync } from 'node:child_process';
2
- import { createHash } from 'node:crypto';
3
- import { readFileSync } from 'node:fs';
4
- import { fileURLToPath } from 'node:url';
5
-
6
- const MAX_INPUT_BYTES = 64 * 1024;
7
- const codexHooks = fileURLToPath(new URL('../../.codex/hooks.json', import.meta.url));
8
- const clientIndex = process.argv.indexOf('--client');
9
- const client = clientIndex >= 0 ? process.argv[clientIndex + 1] : '';
10
- if (client !== 'claude-code' && client !== 'codex') {
11
- process.stderr.write('Lifecycle delegation hook requires a supported --client value\n');
12
- process.exit(1);
13
- }
14
-
15
- function internalCliInvocation(args) {
16
- return { command: 'agent-infra-internal', commandArgs: args, shell: process.platform === 'win32' };
17
- }
18
-
19
- let input = '';
20
- process.stdin.setEncoding('utf8');
21
- process.stdin.on('data', (chunk) => {
22
- input += chunk;
23
- if (Buffer.byteLength(input) > MAX_INPUT_BYTES) {
24
- process.stderr.write('Lifecycle delegation hook input exceeds 64 KiB\n');
25
- process.exit(1);
26
- }
27
- });
28
- process.stdin.on('end', () => {
29
- let event;
30
- try {
31
- event = JSON.parse(input || '{}');
32
- } catch {
33
- process.stderr.write('Lifecycle delegation hook received invalid JSON\n');
34
- process.exit(1);
35
- }
36
- const phaseIndex = process.argv.indexOf('--event');
37
- const explicitPhase = phaseIndex >= 0 ? process.argv[phaseIndex + 1] : '';
38
- const hook = String(explicitPhase || event.hook_event_name || event.event || '').toLowerCase();
39
- const toolInput = event.tool_input && typeof event.tool_input === 'object' ? event.tool_input : {};
40
- const toolName = String(event.tool_name || event.tool || '').toLowerCase();
41
- let toolResponse = {};
42
- try {
43
- toolResponse = typeof event.tool_response === 'string'
44
- ? JSON.parse(event.tool_response)
45
- : (event.tool_response || {});
46
- } catch {
47
- // Core ignores opaque tool responses; only the host timeout bit is forwarded.
48
- }
49
- const nativeAgent = event.agent_name || event.agent_type || event.agent?.name
50
- || toolInput.agent_type || toolInput.agent || toolInput.name;
51
- if (client === 'codex') {
52
- const phases = new Set(['pre-tool', 'subagent-start', 'post-tool', 'subagent-stop']);
53
- if (!phases.has(hook)) {
54
- process.stderr.write('Managed Codex lifecycle hook event has an unknown type\n');
55
- process.exit(1);
56
- }
57
- const managedAgent = /^agent-infra-lifecycle-(executor|reviewer)$/.test(String(nativeAgent || ''));
58
- const parentReconcile = hook === 'post-tool'
59
- && toolName === 'collaborationwait_agent'
60
- && toolResponse.timed_out !== true;
61
- if (!managedAgent && !parentReconcile) process.exit(0);
62
- const hookDefinitionHash = createHash('sha256').update(readFileSync(codexHooks)).digest('hex');
63
- const normalized = {
64
- sessionId: String(event.session_id || ''),
65
- turnId: String(event.turn_id || ''),
66
- toolUseId: String(event.tool_use_id || ''),
67
- childThreadId: String(event.agent_id || event.child_id || event.thread_id || event.tool_response?.agent_id || ''),
68
- nativeAgent: String(nativeAgent),
69
- requestedModel: String(toolInput.model || ''),
70
- requestedReasoningEffort: String(toolInput.reasoning_effort || toolInput.reasoningEffort || ''),
71
- hookDefinitionHash,
72
- toolName,
73
- taskName: String(toolInput.task_name || ''),
74
- transcriptPath: String(event.transcript_path || '')
75
- };
76
- const args = ['codex-lifecycle', 'hook-event', '--event', hook, '--bridge', 'true'];
77
- try {
78
- const { command, commandArgs, shell } = internalCliInvocation(args);
79
- const output = execFileSync(command, commandArgs, {
80
- encoding: 'utf8',
81
- input: JSON.stringify(normalized),
82
- shell,
83
- stdio: ['pipe', 'pipe', 'pipe'],
84
- timeout: 30_000
85
- });
86
- process.stdout.write(output);
87
- } catch (error) {
88
- if (error.stdout) process.stdout.write(String(error.stdout));
89
- if (error.stderr) process.stderr.write(String(error.stderr));
90
- process.exit(typeof error.status === 'number' ? error.status : 1);
91
- }
92
- return;
93
- }
94
- if (!/^agent-infra-lifecycle-(executor|reviewer)$/.test(String(nativeAgent || ''))) process.exit(0);
95
- const start = hook.includes('start');
96
- const stop = hook.includes('stop');
97
- if (!start && !stop) {
98
- process.stderr.write('Managed lifecycle hook event has an unknown type\n');
99
- process.exit(1);
100
- }
101
- const args = ['task-orchestration', 'auto', start ? 'hook-start' : 'hook-stop', '--client', client];
102
- if (start) {
103
- args.push(
104
- '--native-agent', String(nativeAgent),
105
- '--child-id', String(event.child_id || event.agent_id || event.thread_id || ''),
106
- '--parent-id', String(event.parent_id || event.parent_session_id || event.session_id || '')
107
- );
108
- if (event.spawn_mode) args.push('--spawn-mode', String(event.spawn_mode));
109
- if (event.model) args.push('--actual-model', String(event.model));
110
- const actualEffort = event.effort?.level || event.actual_reasoning_effort || event.reasoning_effort || event.model_reasoning_effort;
111
- if (actualEffort) args.push('--actual-reasoning-effort', String(actualEffort));
112
- if (event.model_fallback_reason) args.push('--model-fallback-reason', String(event.model_fallback_reason));
113
- if (event.reasoning_effort_fallback_reason) {
114
- args.push('--reasoning-effort-fallback-reason', String(event.reasoning_effort_fallback_reason));
115
- }
116
- } else {
117
- args.push(
118
- '--native-agent', String(nativeAgent),
119
- '--child-id', String(event.child_id || event.agent_id || event.thread_id || '')
120
- );
121
- if (client === 'claude-code') {
122
- if (event.model) args.push('--actual-model', String(event.model));
123
- const actualEffort = event.effort?.level || event.actual_reasoning_effort || event.reasoning_effort;
124
- if (actualEffort) args.push('--actual-reasoning-effort', String(actualEffort));
125
- }
126
- }
127
- try {
128
- const { command, commandArgs, shell } = internalCliInvocation(args);
129
- const output = execFileSync(command, commandArgs, {
130
- encoding: 'utf8',
131
- shell,
132
- stdio: ['ignore', 'pipe', 'pipe']
133
- });
134
- process.stdout.write(output);
135
- } catch (error) {
136
- if (error.stdout) process.stdout.write(String(error.stdout));
137
- if (error.stderr) process.stderr.write(String(error.stderr));
138
- process.exit(typeof error.status === 'number' ? error.status : 1);
139
- }
140
- });
@@ -1,44 +0,0 @@
1
- # Common Rule - Lifecycle Orchestration
2
-
3
- ## Guarantee Boundary
4
-
5
- - The orchestrator only routes and delegates. Stage skills remain the single source of truth for behavior and artifacts.
6
- - Every stage and rework round uses a fresh executor. Every review uses a fresh reviewer; follow-up reuse is forbidden.
7
- - A reviewer may only write its review artifact and core-generated task metadata. Business-code, HEAD, or index changes invalidate the receipt.
8
- - An active run has one pending delegation. Keep the stage associated with the observed child and report actual start and terminal failures.
9
- - The first release ends after one existing safely gated `commit`; it does not create a PR, monitor checks, or complete the task.
10
-
11
- ## Current Execution Records
12
-
13
- `orchestration.json` records stages, model policy, child identity, and actual outcomes. Records use the current structure; trusted local operators may correct them and rerun validation. Stages for one task run sequentially; atomic writes and identity/state validation continue to protect state updates.
14
-
15
- ## Current Host
16
-
17
- - Use native spawn, wait, and App Server results from the current host. A task-bound sandbox executes ordinary task orchestration locally in the current worktree.
18
- - Prepare validates the current task, model policy, and host preflight. Start and terminal records associate observed parent/child identity; failure must not be recorded as success.
19
- - Client-specific preflight, event sources, and stop-evidence validation belong to the client adapter. The common orchestrator calls only the shared capability and contains no client-ID branches.
20
-
21
- ## Activated Delegation Recovery
22
-
23
- - Before `begin-or-resume`, the orchestrator calls internal `task-lifecycle <task> recover-started --agent <client> --auto`. This entry is not user-facing and never infers child termination from missing liveness evidence.
24
- - The client adapter declares recovery support and validates trusted stop evidence for the current pending delegation. Unsupported adapters and runs without an activated pending delegation return `no-op`; uncertain termination fails closed.
25
- - Recovery consumes stop evidence, saves an aborted receipt while clearing pending, then appends the Activity Log terminal row. If the run save succeeds and the log write fails, the next invocation appends only the missing row.
26
- - Routing continues only after `no-op` or `applied`. Lost control responses are not reconstructed; the next operator invocation relies on the idempotent persisted state.
27
-
28
- ## Current-only Cutover and Rollback
29
-
30
- - Enter a quiet window before cutover: let in-flight orchestration intents return and preserve the worktree, task/run/orchestration state, receipts, and audit. For an unknown result, inspect local `status`/`route` before using existing recover/advance semantics; do not replay an old broker request.
31
- - Deploy or roll back the CLI, broker, and protocol as one versioned unit. After stopping the old container/broker, rebuild and run `ai sandbox start --recreate <task-ref>` to resume with a new control generation; never reuse an old token or request.
32
- - On either the new or rolled-back version, first confirm the same task through `status`/`route`. Keep the quiet window and evidence intact if any check fails; do not mix component versions or rewrite domain facts.
33
-
34
- ## Model Policy
35
-
36
- - A new run persists model and reasoning effort for both roles. Explicit policy is atomic across all four role fields; only a fully absent explicit policy may fall back to the current client's `agentClients[].orchestration`.
37
- - Route resolves requested model/effort by role, and prepare matches both before snapshotting. Native spawn must not inherit session defaults.
38
- - Native start records host-observed actual model/effort. Fields declared unobservable by the adapter follow the recording rules; each observable mismatch needs its own fallback reason, and requested values must never be fabricated as actual evidence.
39
- - Model selection is labeled as a complete catalog, partial catalog, or interactive-only guidance; a local override enum must not be presented as complete.
40
- - An adapter must declare any policy field it cannot dispatch per role. Values observed in host events are actual evidence only; they do not promise dispatch or gate activation.
41
-
42
- ## Stable Pause Conditions
43
-
44
- Human decisions, manual validation, handshake or step limits, permissions/network failures, worktree conflicts, unsupported client capability, and unknown hook schemas are persisted as pauses. The orchestrator must not ask mid-flow or degrade to same-context self-review.
@@ -1,44 +0,0 @@
1
- # 通用规则 - 生命周期总控
2
-
3
- ## 保证边界
4
-
5
- - 总控只路由和委派;阶段技能仍是业务规则与产物格式的单一事实源。
6
- - 每个阶段和每轮返工都创建 fresh executor;每轮审查创建 fresh reviewer,禁止 follow-up 复用。
7
- - reviewer 只能写当前审查产物和核心生成的任务元数据。业务代码、HEAD 或暂存区变化会使 receipt 失效。
8
- - active run 中只有一个 pending delegation;阶段与实际 child 身份保持一致,启动和终态失败如实记录。
9
- - 首版成功终点是一次通过既有安全门禁的 `commit`;不创建 PR、不监控 checks、不执行 `complete-task`。
10
-
11
- ## 当前执行记录
12
-
13
- `orchestration.json` 记录阶段、模型策略、child 身份及实际执行结果。记录必须符合当前结构;本地操作者可直接修正后重新校验。同一任务的阶段按序调用;原子写入、身份校验和状态校验继续保护状态更新。
14
-
15
- ## 当前宿主
16
-
17
- - 使用当前宿主的原生 spawn、wait 与 App Server 结果;task-bound sandbox 在当前 worktree 本地执行普通任务编排。
18
- - prepare 校验当前任务、模型策略与宿主 preflight。启动和完成记录关联实际 parent/child 身份,失败不得写成成功。
19
- - 客户端特有的 preflight、事件来源与停止证据校验由客户端适配器实现;公共总控只调用统一能力。不得在公共流程中新增客户端 ID 分支。
20
-
21
- ## Activated delegation 自动恢复
22
-
23
- - 总控在 `begin-or-resume` 前调用内部 `task-lifecycle <task> recover-started --agent <client> --auto`。该入口不公开给用户,也不从缺少存活证据推断 child 已终止。
24
- - 客户端适配器决定是否支持恢复,并验证当前 pending delegation 的可信停止证据;不支持或没有 activated pending 时返回 `no-op`,无法确认停止时失败关闭。
25
- - 恢复按固定顺序消费停止证据、保存 aborted receipt 并清除 pending,再写 Activity Log 结束记录。任务状态已保存而日志未写时,下次调用只补日志。
26
- - 只有 `no-op` 或 `applied` 才能继续 route。控制响应丢失时不重建恢复结果;下一次人为调用依靠幂等状态继续。
27
-
28
- ## Current-only 切换与回滚
29
-
30
- - 切换前进入静默窗口:等待在途编排 intent 返回,并保留 worktree、task/run/orchestration 状态、receipts 与 audit。结果未知时先用本地 `status`/`route` 判断 domain 是否已提交,再按现有 recover/advance 语义处理;不重放旧 broker request。
31
- - CLI、broker 与协议必须作为同一版本单元部署或回退。停止旧 container/broker 后执行 rebuild 与 `ai sandbox start --recreate <task-ref>`,以新的 control generation 恢复执行;旧 token 和 request 不得复用。
32
- - 新版本或回滚版本都必须先核对同一任务的 `status`/`route`。任一检查失败时继续保持静默并保留证据,不局部混用组件或改写 domain 事实。
33
-
34
- ## 模型策略
35
-
36
- - 新 run 必须固化 executor/reviewer 各自的 model 与 reasoning effort;显式策略必须四字段原子完整,完全没有显式字段时才读取当前 client 的 `agentClients[].orchestration`。重入不得静默改写策略。
37
- - route 按 role 返回 requested model/effort,prepare 必须在工作区快照前精确匹配两者;原生 spawn 不能继承会话默认值。
38
- - 原生 start 必须记录宿主观察到的 actual model/effort。适配器声明无法观察的字段按记录规则处理;任一可观察字段与 requested 不同时必须记录独立 fallback reason,requested 值不得补造 actual 证据。
39
- - 模型选择能力必须标记 complete catalog、partial catalog 或 interactive-only guidance;局部 override 枚举不得冒充完整目录。
40
- - 客户端无法按角色下发的策略字段必须由适配器明确声明;宿主事件中观察到的值只作为实际证据,不构成下发承诺或放行门禁。
41
-
42
- ## 稳定暂停条件
43
-
44
- 人工裁决、人工验证、握手或总步骤上限、权限/网络失败、用户工作区冲突、客户端 capability 不支持及未知 hook schema 都持久化为暂停原因。总控不得中途询问或降级为同上下文自审。
@@ -1,29 +0,0 @@
1
- ---
2
- name: run-task
3
- description: >
4
- Orchestrate lifecycle stages from the task's current state with fresh executors/reviewers and recorded execution results.
5
- Use when one entry should advance an existing task until a safe commit or stable pause.
6
- ---
7
-
8
- # Run Task Lifecycle
9
-
10
- ## Task Context Resolution
11
-
12
- The entry point may omit the task ref; explicit task scope accepts only `--task <ref>` or `-t <ref>`, and positional task refs are not interpreted. Preserve the four policy options and their values, then call `agent-infra-internal task-context resolve {task-scope}`. Pass through resolution failures without scanning tasks locally. The internal orchestration protocol continues to use a positional task ref.
13
-
14
- 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`.
15
-
16
- 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.
17
- 2. Use the current host's native child spawn, wait, and result interfaces. Task-bound sandboxes execute ordinary task orchestration locally in the current worktree. Retain task binding and checks for real external process operations.
18
- 3. Before each loop, run `agent-infra-internal task-lifecycle {task-id} recover-started --agent {client} --auto`. The client adapter owns recovery capability and stop-evidence validation; an unsupported adapter or a run that needs no recovery returns `no-op`. Continue only after `no-op` or `applied`. Stop on every other result; a later operator invocation retries from persisted state without routing or dispatching a child.
19
- 4. 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 runs use persisted policy. Disk state outside the complete current structure fails closed without rewriting; finish or clear active runs before upgrading. Stop on paused/completed results.
20
- 5. Run `route`. On `completed`, run `agent-infra-internal task-verify {task-id} run-task.completed --format text`, present its summary per `.agents/rules/validation-output.md` while retaining necessary diagnostics, and stop. Only a `running` result with non-null `next` supplies action, role, round, artifact, requested model, and requested effort.
21
- 6. Call `prepare --client {client} --requested-model {requestedModel} --requested-reasoning-effort {requestedReasoningEffort}` with route's exact policy. The client adapter runs host preflight. Report actual task, policy, or host failures.
22
- 7. After prepare, forward the optional `adapterContext` unchanged to `agent-infra-internal agent-client launch-carrier --client {client} --adapter-context {adapterContext} --stage {stage} --round {round} --role {role} --format json`. The shared skill must not parse, rewrite, or validate this opaque value. The controlled entry point calls the current Agent Client adapter's `createLaunchCarrier` and returns a carrier for native spawn. Stop dispatch with the structured error if carrier support is unavailable or conversion fails. Then run `task-orchestration <task-ref> dispatch` with route's exact model/effort, passing the short task ref, skill, `--orchestrated`, stage/round/artifact/role, and the returned carrier unchanged to native spawn. The child calls `await-activation --stage ... --round ... --artifact ... --role ...` to associate its actual identity before executing. Code-task creates the local checkpoint; do not delegate a separate commit stage or push. Execute task stages sequentially; state updates retain atomic writes and identity/state validation.
23
- 8. Record actual start and terminal results through the current host's native lifecycle events and result interfaces. A timed-out wait does not imply success. Pause on actual identity, transport, or terminal failures. After the stage and child finish, call `advance`; repeat step 3 only while running.
24
- 9. Create a fresh child each round and never reuse a reviewer. Record actual model/effort and host fallback reasons. Validate current identity, artifacts, ledger, and execution results. User rulings override derived historical plan requirements. Do not introduce child discovery, orphan recovery, or a dedicated recovery protocol.
25
- 10. On pause or completion, run the matching typed verification and report the structured endpoint.
26
-
27
- ## Stop
28
-
29
- Stop after a safe `commit` or reviewed-head-clean endpoint; do not create a PR, monitor checks, or archive the task.
@@ -1,29 +0,0 @@
1
- ---
2
- name: run-task
3
- description: >
4
- 从任务当前状态持续编排生命周期阶段,使用 fresh executor/reviewer 并记录实际执行结果。
5
- 当用户希望通过单一入口推进已有任务直到安全提交或稳定暂停时使用。
6
- ---
7
-
8
- # 运行任务生命周期
9
-
10
- ## 任务上下文解析
11
-
12
- 入口可省略 task ref;显式 task scope 仅接受 `--task <ref>` 或 `-t <ref>`,不再解释位置 task ref。保留四个策略选项及其值,再调用 `agent-infra-internal task-context resolve {task-scope}`。解析失败时透传非零退出码,不自行扫描任务。内部 orchestration 协议仍使用位置 task ref。
13
-
14
- 总控只编排,不直接执行任何阶段技能。执行前先读取 `.agents/rules/no-mid-flow-questions.md`、`.agents/rules/lifecycle-orchestration.md` 与 `reference/host-validation.md`。
15
-
16
- 1. 解析规范任务 ID、当前 Agent Client,以及可选的原子策略 `--executor-model`、`--executor-reasoning-effort`、`--reviewer-model`、`--reviewer-reasoning-effort`,并执行 `agent-infra-internal task-snapshot {task-id} --format text`。任一显式策略字段出现时四个 role 字段必须完整,不得与配置拼接;两个角色可以使用同一模型。
17
- 2. 使用当前宿主的原生子 Agent 启动、等待与结果接口。task-bound sandbox 在当前 worktree 本地执行普通任务编排。保留任务绑定与真实外部进程操作检查。
18
- 3. 每次进入循环时先调用 `agent-infra-internal task-lifecycle {task-id} recover-started --agent {client} --auto`。客户端适配器负责恢复能力和停止证据校验;没有该能力或无需恢复时返回 `no-op`。仅在结构化结果为 `no-op` 或 `applied` 时继续,其他结果安全停止;下一次人为调用按持久化状态幂等重试,不 route、不派发 child。
19
- 4. 调用 `agent-infra-internal task-orchestration {task-id} begin-or-resume --client {client}` 并转发完整显式策略。完全没有显式策略时由核心读取当前 client 的 `agentClients[].orchestration`;existing run 使用持久化策略。磁盘状态不符合当前完整结构时核心失败关闭且不改写;升级前必须完成或清空 active run。仅当核心返回 `ORCHESTRATION_MODEL_POLICY_REQUIRED` 时,先用 `agent-client model-selection` 展示 complete/partial/interactive-only 来源,再一次收集完整策略;未回答则不创建 run。若为 paused/completed,按结构化结果停止。
20
- 5. 调用 `route` 并读取结构化结果。若返回 `completed`,立即运行 `agent-infra-internal task-verify {task-id} run-task.completed --format text` 并停止;按 `.agents/rules/validation-output.md` 展示摘要并保留必要诊断。仅当返回 `running` 且 `next` 非空时读取唯一 action、role、round、artifact、`requestedModel` 和 `requestedReasoningEffort`,不得自行推断。
21
- 6. 调用 `prepare --client {client} --requested-model {requestedModel} --requested-reasoning-effort {requestedReasoningEffort}`,使用 route 返回的精确策略。客户端适配器执行宿主 preflight;任务身份、策略或宿主检查失败时记录实际诊断。
22
- 7. prepare 成功后,原样转发返回的可选 `adapterContext`,调用 `agent-infra-internal agent-client launch-carrier --client {client} --adapter-context {adapterContext} --stage {stage} --round {round} --role {role} --format json`。共享技能不解析、重写或验证该不透明值;受控入口调用当前 Agent Client adapter 的 `createLaunchCarrier`,并返回可直接交给 native spawn 的 carrier。缺少 carrier 能力或转换失败时按结构化错误停止派发。随后执行 `task-orchestration <task-ref> dispatch`,显式指定 route 返回的 model/effort;传递短任务引用、skill 名、`--orchestrated` 与 stage/round/artifact/role,并把返回的 carrier 原样交给 native spawn。child 调用 `await-activation --stage ... --round ... --artifact ... --role ...`,确认当前阶段与实际 child 关联后执行。代码阶段通过 code-task 创建本地 checkpoint;禁止单独委派 commit 阶段或推送。任务阶段按序执行,状态更新保留原子写入与身份、状态校验。
23
- 8. 通过当前宿主的原生生命周期事件和结果接口记录实际启动及终态。timed-out wait 不推断成功;身份、传输或异常终态失败如实暂停。阶段结果和 child 完成后调用 `advance`;只有 `running` 才重复步骤 3。
24
- 9. 每轮创建新 child;禁止 follow-up 复用 reviewer。如实记录 actual model/effort 及宿主降级理由。检查当前身份、产物、账本与实际执行结果;用户裁决优先于历史方案派生要求。不得新增 child discovery、孤立 child 恢复或专用恢复协议。
25
- 10. 完成或暂停后运行对应 typed verification,并把结构化 run 摘要、暂停原因、commit 终点或 clean completion evidence 告知用户。
26
-
27
- ## 停止
28
-
29
- 在安全 `commit` 或 reviewed-head-clean 终点后结束;不要继续创建 PR、监控 checks 或归档任务。
@@ -1,10 +0,0 @@
1
- {
2
- "skill": "run-task",
3
- "checks": {
4
- "task-meta": {
5
- "required_fields": ["id", "status", "updated_at", "agent_infra_version", "current_step", "assigned_to"]
6
- },
7
- "orchestration-state": {},
8
- "orchestration-evidence": {}
9
- }
10
- }
@@ -1,10 +0,0 @@
1
- {
2
- "skill": "run-task",
3
- "checks": {
4
- "task-meta": {
5
- "required_fields": ["id", "status", "updated_at", "agent_infra_version", "current_step", "assigned_to"]
6
- },
7
- "orchestration-state": {},
8
- "orchestration-evidence": {}
9
- }
10
- }
@@ -1,24 +0,0 @@
1
- # Host Contract Validation
2
-
3
- Before publishing support for a client, prove the lifecycle evidence chain with real host events. Bridge tests prove field mapping only; they do not prove host provenance.
4
-
5
- ## Required Evidence
6
-
7
- - Client version, enabled multi-agent capability, launch surface, and trust boundary.
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
- > Direct-host clients that structurally do not emit fork/spawn-mode event fields (currently claude-code) may derive identity correlation solely from parent/child identity uniqueness plus the receipt's one-shot state machine, without an additional fresh-spawn-mode proof; the client must still honestly record this gap and how the substitute guarantee is composed, and must never fabricate spawn-mode evidence. This exception does not apply to any other client. Concretely, claude-code's identity guarantee is provided only by non-empty and mutually distinct `parentId`/`childId`, a unique `childId` within the same run, and the receipt's one-shot state machine — it carries none of Codex's `spawn_mode` fork proof and is weaker than Codex's.
10
- - Explicit requested model/effort reaches each executor/reviewer. A fallback of either field reports the corresponding actual value and its own non-empty reason.
11
- > claude-code exception: requested reasoning effort does not yet support per-role dispatch to executor/reviewer — `.claude/agents/{executor,reviewer}.md` is a repository-level shared singleton, and writing it per role would race across concurrent tasks. This client only needs to honestly record the actual model/actual reasoning effort observed in native Start/Stop host events (`delegationEvidence.actualReasoningEffort` is declared `spawn-ack`); when not observed it is recorded as missing, which is not treated as a fallback requiring its own reason and does not fail closed. This exception does not apply to any other client.
12
- - Candidate-checkout and packed-install behavior match, with model policy, receipts, and verification results auditable in `orchestration.json`.
13
- - Use the hooks/profiles actually loaded by the current host and verify observed parent/child identity and terminal results. Prepare does not depend on historical capability or controller attestation.
14
-
15
- ## Validation Sequence
16
-
17
- 1. Record client version, feature state, and launch command in a clean temporary repository.
18
- 2. Start a fresh executor and reviewer, retaining redacted raw stdin and the structured run. Validate both native start/stop and the parent PostTool fallback; timed-out waits must do nothing. Never synthesize a field the host did not emit.
19
- 3. Validate model/effort match paths, single and dual justified fallbacks, and fail-closed behavior for missing actual fields. Confirm package/build/contract or hook/profile content drift produces only an actionable warning telling the user to rebuild the sandbox.
20
- 4. Validate the same commit from a candidate checkout and an `npm pack` install; record the tarball hash and results.
21
- 5. Commit only redacted summaries and non-sensitive fixtures. Remove or replace tokens, user-specific absolute paths, transcript content, and credentials.
22
- 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.
23
-
24
- 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 record verifiable execution results. The fallback may wait only for empty turns or protocol `inProgress`; malformed, identity/transport errors, or abnormal terminals pause deterministically. The claude-code exception above is already scoped in the second bullet and does not change this rule's fail-closed requirement for any other field or client.
@@ -1,24 +0,0 @@
1
- # 宿主契约验证
2
-
3
- 发布支持某个客户端前,必须用真实宿主事件证明生命周期证据链;bridge 单测只证明字段映射,不能证明事件来自宿主。
4
-
5
- ## 必须证明的字段
6
-
7
- - 客户端版本、启用的多代理能力、启动入口与信任边界。
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
- > 结构上不提供 fork/spawn-mode 事件字段的 direct-host 客户端(当前为 claude-code),身份关联允许仅由 parent/child identity 的唯一性与一次性状态机提供,不要求额外的 fresh spawn mode 证明;该客户端仍需如实记录这一缺口与替代保证的构成,不得补造 spawn mode 证据。此例外不适用于其他客户端。具体而言,claude-code 的身份保证仅由 `parentId`/`childId` 非空且互不相等、同一 run 内 `childId` 唯一、receipt 一次性状态机三者提供,不含 codex 式的 `spawn_mode` fork 证明,强度弱于 codex。
10
- - 显式 requested model/effort 能传给 executor/reviewer;宿主对任一字段回退时,事件能给出对应 actual 值与独立的非空 fallback reason。
11
- > claude-code 例外:requested reasoning effort 暂不支持按角色下发给 executor/reviewer——`.claude/agents/{executor,reviewer}.md` 是仓库级共享单例,动态写入存在跨任务竞态,解决该竞态超出本任务范围。该客户端只要求如实记录宿主原生 Start/Stop 事件中能观察到的 actual model/actual reasoning effort(`delegationEvidence.actualReasoningEffort` 声明为 `spawn-ack`);观察不到时记录为缺失,不视为需要独立 fallback reason 的回退场景,也不构成 fail-closed 阻断。此例外不适用于其他客户端。
12
- - candidate checkout 与打包安装后的行为一致,且模型策略、receipt 与验证结果可从 `orchestration.json` 复核。
13
- - 使用当前宿主实际加载的 hook/profile,并核对实际 parent/child 身份与终态;prepare 不依赖历史 capability 或 controller attestation。
14
-
15
- ## 验证顺序
16
-
17
- 1. 在干净临时仓库记录客户端版本、feature 状态和启动命令。
18
- 2. 分别启动 fresh executor 与 fresh reviewer,保存去敏后的原始 stdin 和结构化 run;同时验证原生 start/stop 与 parent PostTool fallback。timed-out wait 必须无动作;不得补写宿主未产生的字段。
19
- 3. 分别验证 model/effort 的 requested/actual 一致路径、单项与双项有理由 fallback 路径,并确认缺 actual 字段会失败关闭;对 package/build/contract 或 hook/profile 内容漂移确认只产生可操作 warning,并提示用户重建 sandbox。
20
- 4. 对同一 commit 执行 candidate checkout 与 `npm pack` 安装验证,记录 tarball 哈希和结果。
21
- 5. 仅把去敏摘要与非敏感 fixture 纳入版本库;token、绝对用户路径、transcript 内容和凭证必须删除或替换。
22
- 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 失败注入和终态清理审计时启用。
23
-
24
- 任一字段无法从真实宿主稳定观察时,该客户端的 orchestration capability 保持 `unsupported`,并把缺口记录为人工验证项。Codex 可声明为 `experimental`,但每次 `prepare` 仍必须通过静态 preflight,且原生 start/stop 或 parent spawn/completed-wait fallback 必须记录可核对的实际执行结果。fallback 只允许 empty turns/协议 `inProgress` 等待;malformed、身份/传输错误或异常 terminal 都稳定暂停。上述关于 claude-code 的例外已在第 2 条单独说明,不改变本条对其余字段/客户端的 fail-closed 要求。
@@ -1,6 +0,0 @@
1
- ---
2
- name: agent-infra-lifecycle-executor
3
- description: Execute exactly one agent-infra lifecycle stage in a fresh context.
4
- ---
5
-
6
- Run only the requested non-review lifecycle skill for the supplied task reference. Do not run any `review-*` skill. Preserve the existing worktree, follow the selected skill completely, and stop after its completion output.
@@ -1,6 +0,0 @@
1
- ---
2
- name: agent-infra-lifecycle-executor
3
- description: 在全新上下文中只执行一个 agent-infra 生命周期阶段。
4
- ---
5
-
6
- 只为给定任务引用运行指定的非审查生命周期技能。不得运行任何 `review-*` 技能。保留现有工作树,完整遵循所选技能,并在该技能完成输出后停止。
@@ -1,6 +0,0 @@
1
- ---
2
- name: agent-infra-lifecycle-reviewer
3
- description: Review exactly one agent-infra lifecycle artifact in a fresh isolated context.
4
- ---
5
-
6
- Run only the requested `review-*` skill for the supplied task reference. Do not modify business code, do not execute implementation skills, and stop after producing and finalizing the review artifact.
@@ -1,6 +0,0 @@
1
- ---
2
- name: agent-infra-lifecycle-reviewer
3
- description: 在全新隔离上下文中只审查一个 agent-infra 生命周期产物。
4
- ---
5
-
6
- 只为给定任务引用运行指定的 `review-*` 技能。不得修改业务代码,不得执行实现技能,并在生成和最终化审查产物后停止。
@@ -1,8 +0,0 @@
1
- ---
2
- description: "Orchestrate a task lifecycle with fresh isolated agents"
3
- usage: "/run-task [--task <ref> | -t <ref>] [--executor-model <model> --executor-reasoning-effort <effort> --reviewer-model <model> --reviewer-reasoning-effort <effort>]"
4
- ---
5
-
6
- Read and execute the run-task skill from `.agents/skills/run-task/SKILL.md`.
7
-
8
- Follow all steps defined in the skill exactly.
@@ -1,8 +0,0 @@
1
- ---
2
- description: "使用 fresh 隔离 Agent 总控任务生命周期"
3
- usage: "/run-task [--task <ref> | -t <ref>] [--executor-model <model> --executor-reasoning-effort <effort> --reviewer-model <model> --reviewer-reasoning-effort <effort>]"
4
- ---
5
-
6
- 读取并执行 `.agents/skills/run-task/SKILL.md` 中的 run-task 技能。
7
-
8
- 严格按照技能中定义的所有步骤执行。
@@ -1,3 +0,0 @@
1
- name = "agent-infra-lifecycle-executor"
2
- description = "Execute exactly one agent-infra lifecycle stage in a fresh thread."
3
- developer_instructions = "Run only the requested non-review lifecycle skill for the supplied task reference. Never run review-* skills. Stop after the stage completes."
@@ -1,3 +0,0 @@
1
- name = "agent-infra-lifecycle-executor"
2
- description = "在全新线程中只执行一个 agent-infra 生命周期阶段。"
3
- developer_instructions = "只为给定任务引用运行指定的非审查生命周期技能。不得运行 review-* 技能。阶段完成后停止。"
@@ -1,3 +0,0 @@
1
- name = "agent-infra-lifecycle-reviewer"
2
- description = "Review exactly one lifecycle artifact in a fresh isolated thread."
3
- developer_instructions = "Run only the requested review-* skill. Never modify business code or execute implementation skills. Stop after the review artifact is finalized."
@@ -1,3 +0,0 @@
1
- name = "agent-infra-lifecycle-reviewer"
2
- description = "在全新隔离线程中只审查一个生命周期产物。"
3
- developer_instructions = "只运行指定的 review-* 技能。不得修改业务代码或执行实现技能。审查产物最终化后停止。"
@@ -1,11 +0,0 @@
1
- ---
2
- description: "Orchestrate a task lifecycle with fresh isolated agents"
3
- agent: general
4
- subtask: false
5
- ---
6
-
7
- Run task lifecycle $ARGUMENTS.
8
-
9
- Read and execute the run-task skill from `.agents/skills/run-task/SKILL.md`.
10
-
11
- Follow all steps defined in the skill exactly.