@fitlab-ai/agent-infra 0.9.7 → 0.9.8

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 (96) hide show
  1. package/dist/bin/internal-cli.js +5 -0
  2. package/dist/lib/agent-clients/adapters/claude-code.js +3 -3
  3. package/dist/lib/agent-clients/adapters/codex-lifecycle/app-server.js +2 -1
  4. package/dist/lib/agent-clients/adapters/codex-lifecycle/capability-store.js +2 -1
  5. package/dist/lib/agent-clients/adapters/codex-lifecycle/sandbox-controller.js +30 -2
  6. package/dist/lib/agent-clients/adapters/codex-lifecycle/store.js +2 -1
  7. package/dist/lib/decide.js +68 -14
  8. package/dist/lib/init.js +1 -1
  9. package/dist/lib/internal/release-workflow.js +1 -3
  10. package/dist/lib/internal/task-activity.js +57 -7
  11. package/dist/lib/internal/task-event.js +57 -4
  12. package/dist/lib/internal/task-ledger.js +59 -5
  13. package/dist/lib/internal/task-lifecycle.js +59 -8
  14. package/dist/lib/internal/task-orchestration.js +11 -3
  15. package/dist/lib/internal/task-override.js +131 -0
  16. package/dist/lib/internal/task-review.js +64 -6
  17. package/dist/lib/internal/task-verify.js +65 -3
  18. package/dist/lib/internal/task-warning.js +57 -4
  19. package/dist/lib/platform/pr-summary.js +5 -3
  20. package/dist/lib/runtime/agent-runtime.js +56 -0
  21. package/dist/lib/sandbox/commands/create.js +389 -311
  22. package/dist/lib/sandbox/control/container-identity.js +1 -1
  23. package/dist/lib/sandbox/control/executor.js +10 -2
  24. package/dist/lib/sandbox/control/lifecycle.js +392 -72
  25. package/dist/lib/sandbox/control/state.js +27 -11
  26. package/dist/lib/sandbox/engine.js +14 -7
  27. package/dist/lib/sandbox/mounts.js +20 -5
  28. package/dist/lib/sandbox/recovery.js +78 -10
  29. package/dist/lib/sandbox/workspace-view.js +62 -40
  30. package/dist/lib/server/process-state.js +51 -1
  31. package/dist/lib/task/activity-intent.js +4 -1
  32. package/dist/lib/task/decision-intents.js +4 -2
  33. package/dist/lib/task/delegation-receipts.js +37 -16
  34. package/dist/lib/task/events.js +9 -5
  35. package/dist/lib/task/guard-override.js +31 -0
  36. package/dist/lib/task/human-override.js +1240 -0
  37. package/dist/lib/task/ledger-intents.js +6 -3
  38. package/dist/lib/task/lifecycle.js +69 -14
  39. package/dist/lib/task/orchestration.js +60 -6
  40. package/dist/lib/task/review-finalization.js +3 -2
  41. package/dist/lib/task/verification-engine.js +40 -14
  42. package/dist/lib/task/verification.js +13 -1
  43. package/dist/lib/task/workflow-warning-intents.js +4 -2
  44. package/dist/lib/task/write.js +2 -1
  45. package/dist/lifecycle-build-manifest.json +3 -3
  46. package/lib/agent-clients/adapters/claude-code.ts +3 -3
  47. package/lib/agent-clients/adapters/codex-lifecycle/app-server.ts +2 -1
  48. package/lib/agent-clients/adapters/codex-lifecycle/capability-store.ts +2 -1
  49. package/lib/agent-clients/adapters/codex-lifecycle/sandbox-controller.ts +29 -2
  50. package/lib/agent-clients/adapters/codex-lifecycle/store.ts +2 -1
  51. package/lib/decide.ts +59 -14
  52. package/lib/init.ts +1 -1
  53. package/lib/internal/release-workflow.ts +1 -3
  54. package/lib/internal/task-activity.ts +46 -6
  55. package/lib/internal/task-event.ts +53 -4
  56. package/lib/internal/task-ledger.ts +48 -4
  57. package/lib/internal/task-lifecycle.ts +56 -12
  58. package/lib/internal/task-orchestration.ts +12 -4
  59. package/lib/internal/task-override.ts +138 -0
  60. package/lib/internal/task-review.ts +51 -6
  61. package/lib/internal/task-verify.ts +52 -3
  62. package/lib/internal/task-warning.ts +44 -3
  63. package/lib/platform/pr-summary.ts +10 -3
  64. package/lib/runtime/agent-runtime.ts +76 -0
  65. package/lib/sandbox/commands/create.ts +88 -4
  66. package/lib/sandbox/config.ts +2 -1
  67. package/lib/sandbox/control/container-identity.ts +3 -3
  68. package/lib/sandbox/control/executor.ts +10 -2
  69. package/lib/sandbox/control/lifecycle.ts +463 -76
  70. package/lib/sandbox/control/protocol.ts +5 -2
  71. package/lib/sandbox/control/state.ts +35 -18
  72. package/lib/sandbox/engine.ts +20 -9
  73. package/lib/sandbox/mounts.ts +23 -5
  74. package/lib/sandbox/recovery.ts +90 -9
  75. package/lib/sandbox/workspace-view.ts +70 -40
  76. package/lib/server/process-state.ts +48 -1
  77. package/lib/task/activity-intent.ts +4 -2
  78. package/lib/task/decision-intents.ts +4 -2
  79. package/lib/task/delegation-receipts.ts +46 -18
  80. package/lib/task/events.ts +10 -5
  81. package/lib/task/guard-override.ts +50 -0
  82. package/lib/task/human-override.ts +1503 -0
  83. package/lib/task/ledger-intents.ts +6 -3
  84. package/lib/task/lifecycle.ts +71 -14
  85. package/lib/task/orchestration.ts +89 -7
  86. package/lib/task/review-finalization.ts +6 -2
  87. package/lib/task/verification-engine.ts +42 -16
  88. package/lib/task/verification.ts +15 -1
  89. package/lib/task/workflow-warning-intents.ts +4 -2
  90. package/lib/task/write.ts +4 -1
  91. package/package.json +1 -1
  92. package/templates/.agents/hooks/lifecycle-delegation.js +8 -3
  93. package/templates/.agents/rules/lifecycle-orchestration.en.md +3 -2
  94. package/templates/.agents/rules/lifecycle-orchestration.zh-CN.md +3 -2
  95. package/templates/.agents/skills/run-task/reference/host-validation.en.md +3 -1
  96. package/templates/.agents/skills/run-task/reference/host-validation.zh-CN.md +3 -1
@@ -147,11 +147,11 @@ process.stdin.on('end', () => {
147
147
  args.push(
148
148
  '--native-agent', String(nativeAgent),
149
149
  '--child-id', String(event.child_id || event.agent_id || event.thread_id || ''),
150
- '--parent-id', String(event.parent_id || event.parent_session_id || event.session_id || ''),
151
- '--spawn-mode', String(event.spawn_mode || (client === 'claude-code' ? 'fresh' : ''))
150
+ '--parent-id', String(event.parent_id || event.parent_session_id || event.session_id || '')
152
151
  );
152
+ if (event.spawn_mode) args.push('--spawn-mode', String(event.spawn_mode));
153
153
  if (event.model) args.push('--actual-model', String(event.model));
154
- const actualEffort = event.actual_reasoning_effort || event.reasoning_effort || event.model_reasoning_effort;
154
+ const actualEffort = event.effort?.level || event.actual_reasoning_effort || event.reasoning_effort || event.model_reasoning_effort;
155
155
  if (actualEffort) args.push('--actual-reasoning-effort', String(actualEffort));
156
156
  if (event.model_fallback_reason) args.push('--model-fallback-reason', String(event.model_fallback_reason));
157
157
  if (event.reasoning_effort_fallback_reason) {
@@ -162,6 +162,11 @@ process.stdin.on('end', () => {
162
162
  '--native-agent', String(nativeAgent),
163
163
  '--child-id', String(event.child_id || event.agent_id || event.thread_id || '')
164
164
  );
165
+ if (client === 'claude-code') {
166
+ if (event.model) args.push('--actual-model', String(event.model));
167
+ const actualEffort = event.effort?.level || event.actual_reasoning_effort || event.reasoning_effort;
168
+ if (actualEffort) args.push('--actual-reasoning-effort', String(actualEffort));
169
+ }
165
170
  }
166
171
  try {
167
172
  const { command, commandArgs, shell } = internalCliInvocation(args);
@@ -5,7 +5,7 @@
5
5
  - The orchestrator only routes and delegates. Stage skills remain the single source of truth for behavior and artifacts.
6
6
  - Every stage and rework round uses a fresh executor. Every review uses a fresh reviewer; follow-up reuse is forbidden.
7
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. The child must pass the activation barrier before any stage side effect. Missing, late, mismatched, forked, replayed, hook-less, or drifted evidence pauses the run.
8
+ - An active run has one pending delegation. The child must pass the activation barrier before any stage side effect. Missing, late, mismatched, forked, replayed, hook-less, or drifted evidence pauses the run (on the claude-code path, missing or mismatched model/effort evidence, and fork/spawn-mode evidence this host structurally does not provide, follow the recording rules in `.agents/skills/run-task/reference/host-validation.md` instead and are exempt from this; missing or mismatched `parentId`/`childId` still pauses).
9
9
  - The first release ends after one existing safely gated `commit`; it does not create a PR, monitor checks, or complete the task.
10
10
 
11
11
  ## Recovery
@@ -22,8 +22,9 @@
22
22
 
23
23
  - 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`.
24
24
  - Route resolves requested model/effort by role, and prepare matches both before snapshotting. Native spawn must not inherit session defaults.
25
- - Native start records host-observed actual model/effort. Each mismatch needs its own fallback reason, and requested values must never be fabricated as actual evidence.
25
+ - Native start records host-observed actual model/effort. Each mismatch needs its own fallback reason (the claude-code path may leave this blank and follow the recording rules instead), and requested values must never be fabricated as actual evidence.
26
26
  - Model selection is labeled as a complete catalog, partial catalog, or interactive-only guidance; a local override enum must not be presented as complete.
27
+ - claude-code's requested reasoning effort does not yet support per-role dispatch (concurrent tasks would race on a shared file); `delegationEvidence.actualReasoningEffort` is declared `spawn-ack`, meaning it is only recorded when honestly observed in a native spawn lifecycle event (Start/Stop) — it is not a promise of per-role dispatch and does not gate activation.
27
28
 
28
29
  ## Stable Pause Conditions
29
30
 
@@ -5,7 +5,7 @@
5
5
  - 总控只路由和委派;阶段技能仍是业务规则与产物格式的单一事实源。
6
6
  - 每个阶段和每轮返工都创建 fresh executor;每轮审查创建 fresh reviewer,禁止 follow-up 复用。
7
7
  - reviewer 只能写当前审查产物和核心生成的任务元数据。业务代码、HEAD 或暂存区变化会使 receipt 失效。
8
- - active run 中只有一个 pending delegation。child 必须在任何阶段副作用前通过 activation barrier;缺失、超时、错配、fork、重放、hook 不可用或工作区漂移一律暂停。
8
+ - active run 中只有一个 pending delegation。child 必须在任何阶段副作用前通过 activation barrier;缺失、超时、错配、fork、重放、hook 不可用或工作区漂移一律暂停(claude-code 路径下 model/effort 证据的缺失或错配、以及该宿主结构上不提供的 fork/spawn-mode 证据,按 `.agents/skills/run-task/reference/host-validation.md` 的记录规则处理,不在此列;`parentId`/`childId` 的缺失或错配仍然暂停)。
9
9
  - 首版成功终点是一次通过既有安全门禁的 `commit`;不创建 PR、不监控 checks、不执行 `complete-task`。
10
10
 
11
11
  ## 恢复语义
@@ -22,8 +22,9 @@
22
22
 
23
23
  - 新 run 必须固化 executor/reviewer 各自的 model 与 reasoning effort;显式策略必须四字段原子完整,完全没有显式字段时才读取当前 client 的 `agentClients[].orchestration`。重入不得静默改写策略。
24
24
  - route 按 role 返回 requested model/effort,prepare 必须在工作区快照前精确匹配两者;原生 spawn 不能继承会话默认值。
25
- - 原生 start 必须记录宿主观察到的 actual model/effort。任一字段与 requested 不同时必须记录独立 fallback reason;requested 值不得补造 actual 证据。
25
+ - 原生 start 必须记录宿主观察到的 actual model/effort。任一字段与 requested 不同时必须记录独立 fallback reason(claude-code 路径下允许留空,按记录规则处理);requested 值不得补造 actual 证据。
26
26
  - 模型选择能力必须标记 complete catalog、partial catalog 或 interactive-only guidance;局部 override 枚举不得冒充完整目录。
27
+ - claude-code 的 requested reasoning effort 暂不支持按角色下发(跨任务共享文件存在写入竞态);`delegationEvidence.actualReasoningEffort` 声明为 `spawn-ack`,语义为"仅能在宿主原生 spawn 生命周期事件(Start/Stop)里如实观察到时记录,不构成按角色下发的承诺,也不构成放行门禁"。
27
28
 
28
29
  ## 稳定暂停条件
29
30
 
@@ -6,7 +6,9 @@ Before publishing support for a client, prove the lifecycle evidence chain with
6
6
 
7
7
  - Client version, enabled multi-agent capability, launch surface, and trust boundary.
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
+ > 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.
9
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.
10
12
  - Candidate-checkout and packed-install behavior match, with model policy, receipts, and verification results auditable in `orchestration.json`.
11
13
  - Direct-host project/managed source and sandbox isolated-user source preserve the same build, contract, profile, and controller provenance through prepare/start/stop/consume.
12
14
 
@@ -19,4 +21,4 @@ Before publishing support for a client, prove the lifecycle evidence chain with
19
21
  5. Commit only redacted summaries and non-sensitive fixtures. Remove or replace tokens, user-specific absolute paths, transcript content, and credentials.
20
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.
21
23
 
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.
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 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. 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.
@@ -6,7 +6,9 @@
6
6
 
7
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
+ > 结构上不提供 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。
9
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 阻断。此例外不适用于其他客户端。
10
12
  - candidate checkout 与打包安装后的行为一致,且模型策略、receipt 与验证结果可从 `orchestration.json` 复核。
11
13
  - direct-host 的 project/managed source 与 sandbox controller 的 isolated-user source、build/contract/profile/controller digest 必须在 prepare/start/stop/consume 全链路一致。
12
14
 
@@ -19,4 +21,4 @@
19
21
  5. 仅把去敏摘要与非敏感 fixture 纳入版本库;token、绝对用户路径、transcript 内容和凭证必须删除或替换。
20
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 失败注入和终态清理审计时启用。
21
23
 
22
- 任一字段无法从真实宿主稳定观察时,该客户端的 orchestration capability 保持 `unsupported`,并把缺口记录为人工验证项。Codex 可声明为 `experimental`,但每次 `prepare` 仍必须通过静态 preflight,且原生 start/stop 或 parent spawn/completed-wait fallback 必须形成可验证的 consumed host evidence。fallback 只允许 empty turns/协议 `inProgress` 等待;malformed、身份/传输错误或异常 terminal 都稳定暂停。
24
+ 任一字段无法从真实宿主稳定观察时,该客户端的 orchestration capability 保持 `unsupported`,并把缺口记录为人工验证项。Codex 可声明为 `experimental`,但每次 `prepare` 仍必须通过静态 preflight,且原生 start/stop 或 parent spawn/completed-wait fallback 必须形成可验证的 consumed host evidence。fallback 只允许 empty turns/协议 `inProgress` 等待;malformed、身份/传输错误或异常 terminal 都稳定暂停。上述关于 claude-code 的例外已在第 2 条单独说明,不改变本条对其余字段/客户端的 fail-closed 要求。