@tea-agent/loop-agent 0.1.0-fe-test.4 → 0.1.0-fe-test.6

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 (555) hide show
  1. package/AGENTS.md +1 -1
  2. package/CHANGELOG.md +442 -2524
  3. package/README.md +19 -12
  4. package/dist/adapters/loop-agent.js +34 -0
  5. package/dist/application/dag/args.js +8 -0
  6. package/dist/application/dag/run-dag.js +5 -0
  7. package/dist/application/evaluation/budget.js +40 -1
  8. package/dist/application/evaluation/corpus-hash.js +10 -15
  9. package/dist/application/evaluation/corpus.js +2 -1
  10. package/dist/application/evaluation/frontend-browser-acceptance.js +77 -0
  11. package/dist/application/evaluation/frontend-corpus-browser-acceptance.js +175 -0
  12. package/dist/application/evaluation/frontend-gateway-evidence.js +226 -0
  13. package/dist/application/evaluation/frontend-pair-registration.js +143 -0
  14. package/dist/application/evaluation/frontend-paired-summary.js +150 -0
  15. package/dist/application/evaluation/frontend-run-observation.js +144 -0
  16. package/dist/application/evaluation/frontend-shared-evidence.js +105 -0
  17. package/dist/application/evaluation/types.js +45 -12
  18. package/dist/application/task-lifecycle/advance.js +64 -15
  19. package/dist/application/task-lifecycle/observe.js +69 -30
  20. package/dist/application/task-lifecycle/plan-transitions.js +5 -4
  21. package/dist/build-stamp.json +3 -3
  22. package/dist/cli/command-definitions.js +18 -5
  23. package/dist/cli/program.js +8 -5
  24. package/dist/cli/update/init-surface-notifier.js +2 -0
  25. package/dist/cli/update/policy.js +2 -0
  26. package/dist/commands/client-recovery.js +20 -55
  27. package/dist/commands/cursor-prompt.js +2 -0
  28. package/dist/commands/dag-approve.js +2 -0
  29. package/dist/commands/dag-final-verification.js +2 -0
  30. package/dist/commands/dag-init-hybrid.js +2 -0
  31. package/dist/commands/dag-reconcile-tasks.js +2 -0
  32. package/dist/commands/dag-reject.js +2 -0
  33. package/dist/commands/dag-report.js +2 -0
  34. package/dist/commands/dag-rerun.js +2 -0
  35. package/dist/commands/dag-resume.js +2 -0
  36. package/dist/commands/dag-workflow-compile.js +2 -0
  37. package/dist/commands/dag-workflow-plan.js +2 -0
  38. package/dist/commands/dag-workflow-validate.js +2 -0
  39. package/dist/commands/delegate.js +2 -0
  40. package/dist/commands/examples.js +2 -0
  41. package/dist/commands/import-prd.js +2 -0
  42. package/dist/commands/init-legacy-audit.js +330 -0
  43. package/dist/commands/init-model-catalog.js +2 -0
  44. package/dist/commands/init-upgrade.js +644 -104
  45. package/dist/commands/init.js +700 -338
  46. package/dist/commands/instructions.js +2 -0
  47. package/dist/commands/knowledge.js +2 -0
  48. package/dist/commands/loop-benchmark.js +2 -0
  49. package/dist/commands/operator-guide.js +99 -0
  50. package/dist/commands/operator.js +16 -3
  51. package/dist/commands/pi-prompt.js +2 -0
  52. package/dist/commands/pi-reuse-benchmark.js +2 -0
  53. package/dist/commands/promote-run.js +2 -0
  54. package/dist/commands/stats.js +1 -1
  55. package/dist/commands/study-init.js +2 -0
  56. package/dist/commands/task-advance.js +32 -0
  57. package/dist/commands/task-source-prepare.js +18 -2
  58. package/dist/commands/worktree-create.js +2 -0
  59. package/dist/commands/worktree-remove.js +2 -0
  60. package/dist/executors/dag-pi/guards.js +4 -0
  61. package/dist/executors/dag-pi/model-config.js +30 -0
  62. package/dist/executors/dag-pi/plan/fact-adoption.js +55 -0
  63. package/dist/executors/dag-pi/plan/facts.js +180 -0
  64. package/dist/executors/dag-pi/plan/finalize-tools.js +259 -0
  65. package/dist/executors/dag-pi/plan/ledger-contract.js +55 -0
  66. package/dist/executors/dag-pi/plan/record-tools.js +861 -0
  67. package/dist/executors/dag-pi/plan/schema.js +129 -0
  68. package/dist/executors/dag-pi/plan/tool-helpers.js +16 -0
  69. package/dist/executors/dag-pi/sessions/index.js +6 -0
  70. package/dist/executors/dag-pi/sessions/plan-batches.js +280 -0
  71. package/dist/executors/dag-pi/sessions/plan-prompts.js +367 -0
  72. package/dist/executors/dag-pi/sessions/scout-parallel.js +197 -0
  73. package/dist/executors/dag-pi/sessions/segmented-plan.js +1184 -0
  74. package/dist/executors/dag-pi/sessions/writer-evidence.js +60 -0
  75. package/dist/executors/dag-pi/tools/contract-tools.js +515 -0
  76. package/dist/executors/dag-pi/tools/design-terminal-tools.js +159 -0
  77. package/dist/executors/dag-pi/tools/plan-decision-tools.js +529 -0
  78. package/dist/executors/dag-pi/tools/review-terminal-tools.js +159 -0
  79. package/dist/executors/dag-pi/tools/scout-evidence-tools.js +270 -0
  80. package/dist/executors/dag-pi-executor.js +1517 -3180
  81. package/dist/executors/pi-executor.js +112 -4
  82. package/dist/executors/pi-sdk-executor.js +258 -44
  83. package/dist/executors/pi-writer-tool-policy.js +60 -4
  84. package/dist/executors/playwright-cli-launcher.js +31 -45
  85. package/dist/executors/shell-executor.js +358 -48
  86. package/dist/executors/shell-presets.js +1 -1
  87. package/dist/executors/shell-verification.js +3 -0
  88. package/dist/executors/shell-write-guard.js +77 -102
  89. package/dist/governance/exec-plans.js +16 -4
  90. package/dist/governance/harness.js +2 -7
  91. package/dist/governance/manifest-types.js +28 -9
  92. package/dist/governance/project-capability-scanner.js +263 -0
  93. package/dist/governance/project-config.js +96 -0
  94. package/dist/governance/resource-catalog.js +151 -0
  95. package/dist/infrastructure/console/app-data.js +12 -2
  96. package/dist/infrastructure/console/operation-store.js +48 -14
  97. package/dist/infrastructure/evaluation/corpus-store.js +37 -12
  98. package/dist/shared/artifacts-core.js +2 -0
  99. package/dist/shared/backend-dogfood-preflight.js +47 -0
  100. package/dist/shared/dag-failure-category.js +9 -0
  101. package/dist/shared/file-identity.js +23 -0
  102. package/dist/shared/frontend-execution-policy.js +23 -0
  103. package/dist/shared/git-progress.js +2 -0
  104. package/dist/shared/git-workspace-status.js +482 -0
  105. package/dist/shared/one-shot-prompt-args.js +2 -0
  106. package/dist/shared/operator/capabilities.js +185 -0
  107. package/dist/shared/package-metadata.js +29 -11
  108. package/dist/shared/path-safety.js +2 -2
  109. package/dist/shared/pi-context-pressure/extension.js +49 -16
  110. package/dist/shared/pi-context-pressure/index.js +1 -0
  111. package/dist/shared/pi-context-pressure/sift-bridge.js +1 -1
  112. package/dist/shared/pi-context-pressure/telemetry.js +4 -0
  113. package/dist/shared/pi-context-pressure/tool-result-pruner.js +98 -0
  114. package/dist/shared/pi-provider-recovery.js +182 -0
  115. package/dist/shared/pi-retry-settings.js +40 -0
  116. package/dist/shared/reference-context.js +2 -0
  117. package/dist/shared/update/npm-client.js +49 -1
  118. package/dist/shared/wizard-local-telemetry.js +51 -0
  119. package/dist/task/config-types.js +51 -2
  120. package/dist/task/contract/apply.js +36 -2
  121. package/dist/task/contract/project.js +22 -0
  122. package/dist/task/contract/recover.js +6 -0
  123. package/dist/task/contract/schema.js +12 -0
  124. package/dist/task/frontend-preflight.js +1 -1
  125. package/dist/task/source-prepare/artifact-meta.js +9 -2
  126. package/dist/task/source-prepare/build-draft.js +61 -0
  127. package/dist/task/source-prepare/fragment-inventory.js +4 -1
  128. package/dist/task/source-prepare/ledger-reconciliation.js +2 -2
  129. package/dist/task/source-prepare/ledger-review.js +6 -9
  130. package/dist/task/source-prepare/parse-intent.js +165 -14
  131. package/dist/task/source-prepare/path-policy.js +17 -7
  132. package/dist/task/source-prepare/prepare.js +6 -1
  133. package/dist/task/source-prepare/semantic-intake.js +33 -28
  134. package/dist/task/source-prepare/source-execution.js +65 -0
  135. package/dist/task/source-prepare/source-fidelity-pi.js +49 -17
  136. package/dist/task/source-prepare/source-provider-budget.js +290 -0
  137. package/dist/task/source-references.js +48 -23
  138. package/dist/task/task-demand-routing.js +5 -2
  139. package/dist/worker/cli.js +3 -5
  140. package/dist/worker/console/chat/assistant-content.js +5 -13
  141. package/dist/worker/console/chat/browser-automation.js +937 -0
  142. package/dist/worker/console/chat/browser-content.js +74 -0
  143. package/dist/worker/console/chat/browser-diagnostics.js +250 -0
  144. package/dist/worker/console/chat/browser-evaluation.js +58 -0
  145. package/dist/worker/console/chat/browser-operation-queue.js +19 -0
  146. package/dist/worker/console/chat/browser-pick.js +113 -0
  147. package/dist/worker/console/chat/browser-policy.js +113 -0
  148. package/dist/worker/console/chat/browser-routes.js +329 -0
  149. package/dist/worker/console/chat/browser-screenshot-result.js +47 -0
  150. package/dist/worker/console/chat/browser-storage.js +89 -0
  151. package/dist/worker/console/chat/chat-event-store.js +73 -18
  152. package/dist/worker/console/chat/context-insights.js +788 -0
  153. package/dist/worker/console/chat/conversation-nodes.js +383 -0
  154. package/dist/worker/console/chat/db-connections.js +854 -0
  155. package/dist/worker/console/chat/explore-tools.js +18 -2
  156. package/dist/worker/console/chat/pet/pet-affinity.js +169 -0
  157. package/dist/worker/console/chat/pet/pet-persist.js +109 -0
  158. package/dist/worker/console/chat/pet/pet-registry.js +142 -0
  159. package/dist/worker/console/chat/pet/pet-remarks.js +48 -0
  160. package/dist/worker/console/chat/pet/pet-routes.js +125 -0
  161. package/dist/worker/console/chat/pet/pet-service.js +262 -0
  162. package/dist/worker/console/chat/pet/pet-state.js +99 -0
  163. package/dist/worker/console/chat/pi-mode-loop-isolation.js +170 -0
  164. package/dist/worker/console/chat/pi-runtime/custom-tools/ask-user-question.js +44 -0
  165. package/dist/worker/console/chat/pi-runtime/custom-tools/browser-tools.js +135 -0
  166. package/dist/worker/console/chat/pi-runtime/custom-tools/explore-tools.js +202 -0
  167. package/dist/worker/console/chat/pi-runtime/custom-tools/goal-tools.js +79 -0
  168. package/dist/worker/console/chat/pi-runtime/custom-tools/operator-tools.js +94 -0
  169. package/dist/worker/console/chat/pi-runtime/custom-tools/scheduled-goal-tools.js +22 -0
  170. package/dist/worker/console/chat/pi-runtime/custom-tools/sql-tools.js +670 -0
  171. package/dist/worker/console/chat/pi-runtime/custom-tools/todo-write.js +38 -0
  172. package/dist/worker/console/chat/pi-runtime/inspection-types.js +28 -0
  173. package/dist/worker/console/chat/pi-runtime/inspection.js +439 -0
  174. package/dist/worker/console/chat/pi-runtime/progressive-tools.js +195 -0
  175. package/dist/worker/console/chat/pi-runtime/sdk-bindings.js +153 -0
  176. package/dist/worker/console/chat/pi-runtime/sdk-session.js +5 -0
  177. package/dist/worker/console/chat/pi-runtime.js +793 -1230
  178. package/dist/worker/console/chat/provider-error.js +0 -12
  179. package/dist/worker/console/chat/repo-browser.js +132 -6
  180. package/dist/worker/console/chat/repo-preview-kind.js +155 -0
  181. package/dist/worker/console/chat/resource-loader.js +4 -1
  182. package/dist/worker/console/chat/routes.js +861 -148
  183. package/dist/worker/console/chat/scheduled-goal-booking.js +59 -0
  184. package/dist/worker/console/chat/scheduled-goal-delivery.js +27 -0
  185. package/dist/worker/console/chat/scheduled-goal-request.js +198 -0
  186. package/dist/worker/console/chat/scm-routes.js +217 -0
  187. package/dist/worker/console/chat/scm-service.js +283 -0
  188. package/dist/worker/console/chat/scm-tools.js +111 -0
  189. package/dist/worker/console/chat/sdd-data-alignment.js +85 -41
  190. package/dist/worker/console/chat/session-catalog.js +32 -0
  191. package/dist/worker/console/chat/session-mode-view.js +49 -0
  192. package/dist/worker/console/chat/session-mode.js +224 -0
  193. package/dist/worker/console/chat/session-store.js +232 -32
  194. package/dist/worker/console/chat/shortcuts.js +13 -0
  195. package/dist/worker/console/chat/subagents/agent-tool.js +62 -0
  196. package/dist/worker/console/chat/subagents/explore-agent.js +169 -0
  197. package/dist/worker/console/chat/subagents/index.js +5 -0
  198. package/dist/worker/console/chat/subagents/orchestrator.js +273 -0
  199. package/dist/worker/console/chat/subagents/tool-policy.js +53 -0
  200. package/dist/worker/console/chat/subagents/types.js +13 -0
  201. package/dist/worker/console/chat/terminal-routes.js +216 -0
  202. package/dist/worker/console/chat/terminal-sessions.js +348 -0
  203. package/dist/worker/console/chat/terminal-tools.js +211 -0
  204. package/dist/worker/console/chat/timeline-message-order.js +22 -0
  205. package/dist/worker/console/chat/tool-preview.js +136 -0
  206. package/dist/worker/console/chat/tools.js +69 -1
  207. package/dist/worker/console/chat/turn-order.js +13 -0
  208. package/dist/worker/console/chat/turn-process.js +210 -36
  209. package/dist/worker/console/chat/user-turn-outline.js +19 -0
  210. package/dist/worker/console/console-shutdown.js +34 -0
  211. package/dist/worker/console/console-update-and-init.js +1 -19
  212. package/dist/worker/console/console-update-runtime.js +7 -22
  213. package/dist/worker/console/dag-confirmation.js +3 -0
  214. package/dist/worker/console/dag-execution-receipt.js +3 -0
  215. package/dist/worker/console/interview/tools.js +1 -0
  216. package/dist/worker/console/operator-actions.js +95 -4
  217. package/dist/worker/console/operator-user-error.js +28 -1
  218. package/dist/worker/console/pi-readiness.js +4 -4
  219. package/dist/worker/console/prd-intake-bridge.js +47 -1
  220. package/dist/worker/console/recovery-cta.js +14 -14
  221. package/dist/worker/console/routes.js +13 -0
  222. package/dist/worker/console/scheduled-goal-host.js +98 -0
  223. package/dist/worker/console/scheduled-goal-operation-adapter.js +127 -0
  224. package/dist/worker/console/server.js +33 -31
  225. package/dist/worker/console/static/app-icon.svg +39 -0
  226. package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-BZogYNl1.js → abnfDiagram-N423BO3Z-DASc69AM.js} +1 -1
  227. package/dist/worker/console/static/assets/{arc-DcJTLe2v.js → arc-h09p-LAc.js} +1 -1
  228. package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-B39EQQ9n.js → architectureDiagram-T3A2C74G-CZ3dtLkh.js} +1 -1
  229. package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-CitCGV56.js → blockDiagram-VBNYF7ZC-DMrRhMXG.js} +1 -1
  230. package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-rvWuOHLG.js → c4Diagram-5PPSVZJV-DQxisHV6.js} +1 -1
  231. package/dist/worker/console/static/assets/channel-D1zgKZfg.js +1 -0
  232. package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-DGXplIJs.js → chunk-2GRJ4B5K-CefVN9zh.js} +1 -1
  233. package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-ur9OqjPn.js → chunk-2Q5K7J3B-DmR1Koq2.js} +1 -1
  234. package/dist/worker/console/static/assets/{chunk-5RXB4S5H-D1KqU_Vi.js → chunk-5RXB4S5H-NlzrSW7L.js} +1 -1
  235. package/dist/worker/console/static/assets/{chunk-5VM5RSS4-BlVZrbtM.js → chunk-5VM5RSS4-DfelJv-0.js} +1 -1
  236. package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-BAzz3nQy.js → chunk-6Q2QTUOP-BK6RFy58.js} +1 -1
  237. package/dist/worker/console/static/assets/{chunk-GF5L2VYU-CP_nYuCV.js → chunk-GF5L2VYU-BAeh9lz4.js} +1 -1
  238. package/dist/worker/console/static/assets/{chunk-JWPE2WC7-CWvKQ80X.js → chunk-JWPE2WC7-ChPS5WzG.js} +1 -1
  239. package/dist/worker/console/static/assets/{chunk-KBJHAD2P-CyUki8wp.js → chunk-KBJHAD2P-BoVe5IM6.js} +1 -1
  240. package/dist/worker/console/static/assets/{chunk-RYQCIY6F-5NYzNKfY.js → chunk-RYQCIY6F-C4q_0Lw9.js} +1 -1
  241. package/dist/worker/console/static/assets/{chunk-XXDRQBXY-DHdUgjS-.js → chunk-XXDRQBXY-Bb9TvjeY.js} +1 -1
  242. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-CXNNsY2M.js +1 -0
  243. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-CXNNsY2M.js +1 -0
  244. package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-ANQ5g_t6.js → cose-bilkent-JH36ORCC-DmNnL8Ff.js} +1 -1
  245. package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-CruT_4-0.js → cynefin-VYW2F7L2-Contvx58.js} +1 -1
  246. package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-rbFo77ID.js → cynefinDiagram-MW4NZA55-Cigq7cjk.js} +1 -1
  247. package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-asstxBQs.js → dagre-VZM6K2ZE-dEbC0nxb.js} +1 -1
  248. package/dist/worker/console/static/assets/{diagram-7IWD3JNH-DzTyBZwI.js → diagram-7IWD3JNH-CzIztESV.js} +1 -1
  249. package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-gw8ccH3B.js → diagram-B4RE2ZJO-Bo14zbaY.js} +1 -1
  250. package/dist/worker/console/static/assets/{diagram-LBJQPF4R-B8RpZzOf.js → diagram-LBJQPF4R-C4xUyil6.js} +1 -1
  251. package/dist/worker/console/static/assets/{diagram-Q27KOJAE-B1zJkCS9.js → diagram-Q27KOJAE-CaBY_uYa.js} +1 -1
  252. package/dist/worker/console/static/assets/{diagram-UB23O5K3-B6JLWZmO.js → diagram-UB23O5K3-ClUXUeiu.js} +1 -1
  253. package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-q2iZP-Ps.js → ebnfDiagram-BXEA7PRR-BbGCgjC6.js} +1 -1
  254. package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-B3dbbktQ.js → erDiagram-JOGREHBK-Dr-AcwSl.js} +1 -1
  255. package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-C-zc6-kB.js → flowDiagram-UKHOOZJN-BG8Gcfyc.js} +1 -1
  256. package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-BSolnot9.js → ganttDiagram-PKOTCBZU-CFVaPs5r.js} +1 -1
  257. package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-Bo8jGxTk.js → gitGraphDiagram-DS77QQ5N-ChJ8pm-O.js} +1 -1
  258. package/dist/worker/console/static/assets/index-B_5GhVIO.js +488 -0
  259. package/dist/worker/console/static/assets/index-C7YMBluX.css +1 -0
  260. package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-DQaZqJOH.js → infoDiagram-6WML65LV-C5J9-uCZ.js} +1 -1
  261. package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-DsdX1WnE.js → ishikawaDiagram-WSZJBQD7-BcfjqzDv.js} +1 -1
  262. package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-CP5EYDZL.js → journeyDiagram-NVQOT4AX-BzzCO-rD.js} +1 -1
  263. package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-DAm14Dr8.js → kanban-definition-27J2QSJJ-NCHUZ46h.js} +1 -1
  264. package/dist/worker/console/static/assets/{linear-gZECoLc5.js → linear-BKZlWCUU.js} +1 -1
  265. package/dist/worker/console/static/assets/{mermaid.core-BRJNIM6p.js → mermaid.core-DbTaQjFE.js} +5 -5
  266. package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-Cja3kLkR.js → mindmap-definition-FAOFIHXS-CroYl5xQ.js} +1 -1
  267. package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-22ZGFisL.js → pegDiagram-VL7TDLO6-DgMBx-9k.js} +1 -1
  268. package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-BXin0Y1o.js → pieDiagram-7S7Q4E2Y-CyWDmbq1.js} +1 -1
  269. package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-Cw6T69Yt.js → quadrantDiagram-CIZ2JOQS-BgGEOqSP.js} +1 -1
  270. package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-C1-gTieN.js → railroadDiagram-AXF67PYL-BMZ7oeeV.js} +1 -1
  271. package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP--H5N2iI1.js → requirementDiagram-LRYGKXZP-DxqyGhcc.js} +1 -1
  272. package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-CgWAPeRz.js → sankeyDiagram-W5VNT64P-DnSvNCG8.js} +1 -1
  273. package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-CrKqzGvt.js → sequenceDiagram-SI44F4Z6-BiZh6f-R.js} +1 -1
  274. package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-BB3wG06K.js → sizeCapture-X5ZJPWSS-BKXSI8WB.js} +1 -1
  275. package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-DjsGgdgY.js → stateDiagram-OKZ733FA-CfSgoYFm.js} +1 -1
  276. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-DgHi3vjb.js +1 -0
  277. package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-DYKEbvAR.js → swimlanes-SLNWSIFB-CyGADcHe.js} +2 -2
  278. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-Bgvdt1Y0.js +8 -0
  279. package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-eQOb5k9Y.js → timeline-definition-Z64GVDOM-HmPaSPOK.js} +1 -1
  280. package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-B2-l9FIu.js → vennDiagram-T6HMQDX7-VA2VBbez.js} +1 -1
  281. package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-BX2Cda3l.js → wardleyDiagram-T6FBY63Y-BxjiBPZa.js} +1 -1
  282. package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-D9S892ph.js → xychartDiagram-ELKLHX3M--hUY-qFj.js} +1 -1
  283. package/dist/worker/console/static/index.html +5 -2
  284. package/dist/worker/console/static/manifest.webmanifest +19 -0
  285. package/dist/worker/console/static/pets/ember/pet.json +167 -0
  286. package/dist/worker/console/static/pets/ember/spritesheet.png +0 -0
  287. package/dist/worker/console/static-src/app/console-types.js +9 -1
  288. package/dist/worker/console/static-src/chat-view-types.js +1 -1
  289. package/dist/worker/console/static-src/operator-chat/active-turn-tail.js +10 -0
  290. package/dist/worker/console/static-src/operator-chat/animation-frame-batcher.js +38 -0
  291. package/dist/worker/console/static-src/operator-chat/chat-link.js +114 -0
  292. package/dist/worker/console/static-src/operator-chat/chat-scroll-position.js +24 -0
  293. package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +360 -14
  294. package/dist/worker/console/static-src/operator-chat/chat-stream-continuity.js +101 -0
  295. package/dist/worker/console/static-src/operator-chat/compaction-message.js +10 -2
  296. package/dist/worker/console/static-src/operator-chat/composer-session-ledger.js +192 -0
  297. package/dist/worker/console/static-src/operator-chat/context-insights-store.js +64 -0
  298. package/dist/worker/console/static-src/operator-chat/details-rail-surfaces.js +99 -0
  299. package/dist/worker/console/static-src/operator-chat/file-palette-nav.js +81 -0
  300. package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +57 -9
  301. package/dist/worker/console/static-src/operator-chat/pending-user-message.js +66 -0
  302. package/dist/worker/console/static-src/operator-chat/process-label.js +63 -0
  303. package/dist/worker/console/static-src/operator-chat/slash-palette-nav.js +15 -5
  304. package/dist/worker/console/static-src/operator-chat/timeline-merge.js +29 -0
  305. package/dist/worker/console/static-src/operator-chat/tools-catalog.js +36 -8
  306. package/dist/worker/console/static-src/operator-chat/transcript-mode.js +21 -0
  307. package/dist/worker/console/static-src/operator-chat/turn-group-equality.js +16 -0
  308. package/dist/worker/console/static-src/operator-chat/turn-process-disclosure.js +18 -0
  309. package/dist/worker/console/static-src/operator-chat/turn-state-projection.js +166 -0
  310. package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +58 -2
  311. package/dist/worker/console/static-src/operator-chat/use-searchable-hidden.js +51 -0
  312. package/dist/worker/console/static-src/operator-chat/use-stat-dialog.js +95 -0
  313. package/dist/worker/console/static-src/operator-chat/useChatSessions.js +338 -93
  314. package/dist/worker/console/static-src/operator-chat/useChatStream.js +310 -106
  315. package/dist/worker/console/static-src/operator-chat/useChatThread.js +179 -75
  316. package/dist/worker/console/static-src/operator-chat/useComposer.js +281 -79
  317. package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +21 -3
  318. package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +36 -17
  319. package/dist/worker/console/static-src/operator-chat/useRuntimeSnapshot.js +18 -0
  320. package/dist/worker/console/static-src/operator-chat/useWorkspaceBrowserGate.js +4 -0
  321. package/dist/worker/console/static-src/operator-chat/user-turn-anchor-equality.js +21 -0
  322. package/dist/worker/console/static-src/prd-file-import.js +3 -1
  323. package/dist/worker/console/static-src/shell/console-update-reload.js +1 -1
  324. package/dist/worker/console/workspace-context.js +54 -1
  325. package/dist/worker/console/workspace-initialization.js +218 -0
  326. package/dist/worker/delivery/git-transaction.js +2 -0
  327. package/dist/worker/delivery/package.js +4 -1
  328. package/dist/worker/feature/fullstack-validate.js +2 -0
  329. package/dist/worker/loop-agent/loop-agent-client.js +8 -2
  330. package/dist/worker/materialize/harness-task-lineage.js +4 -2
  331. package/dist/worker/materialize/harness-task-materializer.js +4 -1
  332. package/dist/worker/metrics/projector.js +1 -1
  333. package/dist/worker/observability/event-store.js +4 -1
  334. package/dist/worker/observability/read-model.js +27 -3
  335. package/dist/worker/observe/node-context-insights.js +479 -0
  336. package/dist/worker/observe/node-transparency.js +103 -72
  337. package/dist/worker/observe/routes.js +24 -1
  338. package/dist/worker/observe/static/console-theme.css +178 -0
  339. package/dist/worker/observe/static/console-theme.js +74 -0
  340. package/dist/worker/observe/static/dag-inspector-humanize.js +3 -0
  341. package/dist/worker/observe/static/dom.js +20 -1
  342. package/dist/worker/observe/static/format-pool.d.ts +2 -0
  343. package/dist/worker/observe/static/format-pool.js +6 -0
  344. package/dist/worker/observe/static/format.js +7 -0
  345. package/dist/worker/observe/static/inspect-workspace.js +34 -7
  346. package/dist/worker/observe/static/inspector-submission.js +32 -0
  347. package/dist/worker/observe/static/kpi.js +1 -0
  348. package/dist/worker/observe/static/operator-chrome.css +85 -0
  349. package/dist/worker/observe/static/operator-chrome.js +13 -1
  350. package/dist/worker/observe/static/relations.js +2 -0
  351. package/dist/worker/observe/static/router.js +13 -0
  352. package/dist/worker/observe/static/run-processing.js +2 -0
  353. package/dist/worker/observe/static/shell-chrome.js +36 -3
  354. package/dist/worker/observe/static/state.js +35 -2
  355. package/dist/worker/observe/static/styles.css +263 -39
  356. package/dist/worker/observe/static/task-failure-labels.d.ts +4 -0
  357. package/dist/worker/observe/static/task-failure-labels.js +67 -0
  358. package/dist/worker/observe/static/task-history.js +12 -0
  359. package/dist/worker/observe/static/views/batch.js +6 -13
  360. package/dist/worker/observe/static/views/dag-graph.js +50 -3
  361. package/dist/worker/observe/static/views/dag-inspector.js +742 -268
  362. package/dist/worker/observe/static/views/dag-trajectory.js +3 -0
  363. package/dist/worker/observe/static/views/dag.d.ts +6 -0
  364. package/dist/worker/observe/static/views/dag.js +49 -11
  365. package/dist/worker/observe/static/views/dags.js +2 -0
  366. package/dist/worker/observe/static/views/dashboard.js +21 -12
  367. package/dist/worker/observe/static/views/failures.js +21 -11
  368. package/dist/worker/observe/static/views/feature.js +11 -29
  369. package/dist/worker/observe/static/views/pool.js +37 -28
  370. package/dist/worker/observe/static/views/run.js +48 -5
  371. package/dist/worker/observe/static/views/session-timeline.js +189 -240
  372. package/dist/worker/observe/static/views/task.js +81 -62
  373. package/dist/worker/outcomes/declared-artifacts.js +2 -0
  374. package/dist/worker/preflight.js +3 -0
  375. package/dist/worker/scheduler/scheduled-goal-dispatch.js +118 -0
  376. package/dist/worker/scheduler/scheduled-goal-evidence.js +230 -0
  377. package/dist/worker/scheduler/scheduled-goal-recovery.js +62 -0
  378. package/dist/worker/scheduler/scheduled-goal-store.js +709 -0
  379. package/dist/worker/scheduler/scheduled-goal-supervisor.js +132 -0
  380. package/dist/worker/scheduler/scheduled-goal-time.js +102 -0
  381. package/dist/worker/scheduler/scheduled-goal-types.js +95 -0
  382. package/dist/worker/task-spec/validate.js +4 -1
  383. package/dist/workflows/dag/backend-test-case-coverage-analysis.js +3 -1
  384. package/dist/workflows/dag/backend-test-layout.js +27 -7
  385. package/dist/workflows/dag/backend-test-markdown-workflow.js +9 -25
  386. package/dist/workflows/dag/backend-test-plan-protocol.js +82 -5
  387. package/dist/workflows/dag/backend-test-pytest-collection.js +4 -1
  388. package/dist/workflows/dag/budget-enforcement.js +82 -3
  389. package/dist/workflows/dag/checkpoint.js +686 -0
  390. package/dist/workflows/dag/dag-retry-schema.js +14 -0
  391. package/dist/workflows/dag/decision-envelope.js +2 -0
  392. package/dist/workflows/dag/dynamic-runtime/map.js +15 -2
  393. package/dist/workflows/dag/dynamic-runtime/shared.js +2 -2
  394. package/dist/workflows/dag/final-verification.js +45 -10
  395. package/dist/workflows/dag/frontend-capacity.js +9 -0
  396. package/dist/workflows/dag/frontend-closeout.js +5 -1
  397. package/dist/workflows/dag/frontend-committed-facts.js +461 -0
  398. package/dist/workflows/dag/frontend-contract-facts.js +133 -0
  399. package/dist/workflows/dag/frontend-design-policy.js +107 -21
  400. package/dist/workflows/dag/frontend-durable-tools.js +225 -0
  401. package/dist/workflows/dag/frontend-execution-groups.js +24 -0
  402. package/dist/workflows/dag/frontend-implementation-contract.js +554 -26
  403. package/dist/workflows/dag/frontend-input-projection.js +76 -0
  404. package/dist/workflows/dag/frontend-plan-canary.js +103 -0
  405. package/dist/workflows/dag/frontend-plan-decision-contract.js +795 -0
  406. package/dist/workflows/dag/frontend-plan-progress.js +92 -0
  407. package/dist/workflows/dag/frontend-plan-recovery-policy.js +18 -0
  408. package/dist/workflows/dag/frontend-plan-render.js +21 -5
  409. package/dist/workflows/dag/frontend-provider-capability-matrix.js +8 -61
  410. package/dist/workflows/dag/frontend-recovery-controller.js +7 -7
  411. package/dist/workflows/dag/frontend-recovery-lineage.js +13 -0
  412. package/dist/workflows/dag/frontend-recovery-plan.js +10 -5
  413. package/dist/workflows/dag/frontend-recovery-run.js +148 -47
  414. package/dist/workflows/dag/frontend-repair-assertions.js +36 -0
  415. package/dist/workflows/dag/frontend-repair.js +79 -76
  416. package/dist/workflows/dag/frontend-review-context.js +71 -69
  417. package/dist/workflows/dag/frontend-review-scopes.js +237 -0
  418. package/dist/workflows/dag/frontend-risk.js +101 -12
  419. package/dist/workflows/dag/frontend-root-observation.js +261 -0
  420. package/dist/workflows/dag/frontend-session-budget.js +376 -0
  421. package/dist/workflows/dag/frontend-session-context.js +10 -0
  422. package/dist/workflows/dag/frontend-shape-facts.js +12 -2
  423. package/dist/workflows/dag/frontend-shape.js +27 -32
  424. package/dist/workflows/dag/frontend-test-case-checklist.js +14 -3
  425. package/dist/workflows/dag/frontend-test-case-generation-assessment.js +88 -0
  426. package/dist/workflows/dag/frontend-test-case-manifest.js +6 -1
  427. package/dist/workflows/dag/frontend-test-case-quality.js +3 -3
  428. package/dist/workflows/dag/frontend-test-environment-probe.js +0 -2
  429. package/dist/workflows/dag/frontend-test-execution-evidence.js +328 -0
  430. package/dist/workflows/dag/frontend-test-framework-adapters.js +309 -0
  431. package/dist/workflows/dag/frontend-test-layout.js +41 -12
  432. package/dist/workflows/dag/frontend-test-result-contract.js +15 -1
  433. package/dist/workflows/dag/frontend-typed-event-store.js +57 -26
  434. package/dist/workflows/dag/frontend-verification-trace.js +65 -48
  435. package/dist/workflows/dag/frontend-writer-admission.js +6 -48
  436. package/dist/workflows/dag/frontend-writer-status.js +0 -23
  437. package/dist/workflows/dag/hybrid/sources.js +1831 -0
  438. package/dist/workflows/dag/hybrid/templates/backend-test.js +1822 -0
  439. package/dist/workflows/dag/hybrid/templates/frontend-test.js +807 -0
  440. package/dist/workflows/dag/hybrid/templates/frontend.js +1529 -0
  441. package/dist/workflows/dag/hybrid/templates/index.js +8 -0
  442. package/dist/workflows/dag/hybrid/templates/kg-bootstrap.js +449 -0
  443. package/dist/workflows/dag/hybrid/templates/knowledge-sync.js +495 -0
  444. package/dist/workflows/dag/hybrid/templates/shared.js +101 -0
  445. package/dist/workflows/dag/hybrid/templates/standard.js +265 -0
  446. package/dist/workflows/dag/hybrid/types.js +32 -0
  447. package/dist/workflows/dag/init-hybrid.js +57 -7077
  448. package/dist/workflows/dag/interrupt-request.js +2 -0
  449. package/dist/workflows/dag/lifecycle.js +11 -2
  450. package/dist/workflows/dag/node-execution.js +257 -247
  451. package/dist/workflows/dag/output-protocol.js +1 -0
  452. package/dist/workflows/dag/prompt.js +4 -0
  453. package/dist/workflows/dag/reconcile-run.js +2 -0
  454. package/dist/workflows/dag/repair-artifact.js +3 -1
  455. package/dist/workflows/dag/report.js +2 -0
  456. package/dist/workflows/dag/rerun-feedback.js +36 -4
  457. package/dist/workflows/dag/rerun-plan.js +106 -4
  458. package/dist/workflows/dag/rerun-run.js +7 -0
  459. package/dist/workflows/dag/rerun-task.js +75 -1
  460. package/dist/workflows/dag/retry-policy.js +34 -10
  461. package/dist/workflows/dag/runner-exit-diagnostics.js +125 -0
  462. package/dist/workflows/dag/runner.js +38 -1074
  463. package/dist/workflows/dag/scheduler.js +2 -4
  464. package/dist/workflows/dag/skill-instructions.js +102 -32
  465. package/dist/workflows/dag/skill-snapshot.js +3 -0
  466. package/dist/workflows/dag/skills.js +7 -7
  467. package/dist/workflows/dag/structured-output-repair.js +4 -1
  468. package/dist/workflows/dag/terminal-status.js +502 -0
  469. package/dist/workflows/dag/test-artifact-namespace.js +73 -0
  470. package/dist/workflows/dag/types.js +79 -7
  471. package/dist/workflows/dag/validate.js +38 -13
  472. package/dist/workflows/dag/workspace-checkpoint.js +79 -1
  473. package/dist/workflows/loop/benchmark.js +11 -8
  474. package/docs/README.md +2 -1
  475. package/docs/architecture/dag-execution.md +4 -4
  476. package/docs/architecture/runtime-boundaries.md +29 -23
  477. package/docs/governance/README.md +1 -0
  478. package/docs/governance/harness-methodology-verification.md +11 -0
  479. package/docs/init-surface.manifest.json +44 -295
  480. package/docs/operations/README.md +4 -0
  481. package/docs/templates/README.md +5 -5
  482. package/docs/templates/agent-dag.base.json +9 -9
  483. package/docs/templates/agent-dag.final-verification.json +6 -6
  484. package/docs/templates/agent-dag.schema.json +2 -2
  485. package/docs/templates/agent-dag.supervised-implementation.json +12 -12
  486. package/docs/templates/backend-test-dag.generate-pytest.prompt.md +3 -3
  487. package/docs/templates/backend-test-dag.json +708 -703
  488. package/docs/templates/backend-test-dag.review-cases.prompt.md +3 -3
  489. package/docs/templates/frontend-design-contract.md +4 -4
  490. package/docs/templates/frontend-implementation-contract.schema.json +99 -22
  491. package/docs/templates/frontend-implementation-dag.json +7 -7
  492. package/docs/templates/frontend-test-case-checklist.md +2 -2
  493. package/docs/templates/frontend-test-case.example.md +2 -0
  494. package/docs/templates/frontend-test-dag.generate-cases.prompt.md +1 -1
  495. package/docs/templates/frontend-test-dag.json +48 -39
  496. package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +2 -2
  497. package/docs/templates/frontend-test-dag.retrospect.prompt.md +1 -1
  498. package/docs/templates/frontend-test-dag.review-cases.prompt.md +1 -1
  499. package/docs/templates/hybrid-dag.json +9 -9
  500. package/docs/templates/knowledge-sync-dag.json +8 -8
  501. package/harness.json +1 -1
  502. package/package.json +27 -8
  503. package/resource-catalog.v1.json +1981 -0
  504. package/resources/agent-bridge/loop-agent/SKILL.md +40 -0
  505. package/resources/init-history/legacy-surface.v1.json +33 -0
  506. package/skills/fe-test-ui-scout/SKILL.md +4 -4
  507. package/skills/fe-test-ui-scout/references/ledger-schema.md +1 -1
  508. package/skills/frontend-bounded-implement/references/code-standards.md +3 -3
  509. package/skills/frontend-contract/SKILL.md +2 -1
  510. package/skills/frontend-contract/references/contract-protocol.md +22 -4
  511. package/skills/frontend-design-review/SKILL.md +16 -18
  512. package/skills/frontend-design-review/references/review-checklist.md +3 -4
  513. package/skills/frontend-plan/SKILL.md +25 -3
  514. package/skills/frontend-plan/references/decision-contract.md +117 -8
  515. package/skills/frontend-plan/references/design-decisions.md +32 -0
  516. package/skills/frontend-review/SKILL.md +29 -36
  517. package/skills/frontend-review/references/review-findings.md +8 -3
  518. package/skills/frontend-scout/references/scout-evidence.md +4 -0
  519. package/skills/init-update/SKILL.md +34 -0
  520. package/skills/init-update/agents/openai.yaml +6 -0
  521. package/skills/loop-agent/references/command-reference.md +8 -0
  522. package/skills/loop-agent/references/hybrid-dag.md +1 -1
  523. package/skills/playwright-cli/SKILL.md +1 -1
  524. package/skills/playwright-cli-case-generator/SKILL.md +7 -5
  525. package/dist/commands/new-task.js +0 -5
  526. package/dist/commands/status.js +0 -57
  527. package/dist/commands/task-contract.js +0 -269
  528. package/dist/shared/prompts.js +0 -26
  529. package/dist/task/config.js +0 -2
  530. package/dist/task/contract/validate-draft.js +0 -106
  531. package/dist/task/goal.js +0 -3
  532. package/dist/task/index.js +0 -12
  533. package/dist/task/lifecycle.js +0 -1
  534. package/dist/task/operator/capabilities.js +0 -6
  535. package/dist/task/operator/envelope.js +0 -2
  536. package/dist/task/operator/index.js +0 -5
  537. package/dist/task/operator/registry.js +0 -2
  538. package/dist/task/paths.js +0 -1
  539. package/dist/task/source-state.js +0 -1
  540. package/dist/task/subagent-guidance.js +0 -1
  541. package/dist/worker/console/chat/sift-bridge.js +0 -1
  542. package/dist/worker/console/index.js +0 -20
  543. package/dist/worker/console/static/assets/channel-CXqdP5pW.js +0 -1
  544. package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-D9C3agF7.js +0 -1
  545. package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-D9C3agF7.js +0 -1
  546. package/dist/worker/console/static/assets/index-CAZ2fC_X.css +0 -1
  547. package/dist/worker/console/static/assets/index-DhfjOafu.js +0 -449
  548. package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Tp7V0U4q.js +0 -1
  549. package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DUZWZWi8.js +0 -8
  550. package/dist/worker/scheduler/index.js +0 -25
  551. package/dist/workflows/dag/facts.js +0 -4
  552. package/dist/workflows/dag/frontend-shadow-dual-write.js +0 -941
  553. package/dist/workflows/dag/index.js +0 -6
  554. package/dist/workflows/dynamic/index.js +0 -7
  555. /package/dist/{task/operator/types.js → executors/dag-pi/plan/session.js} +0 -0
@@ -0,0 +1,96 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { z } from "zod";
4
+ import { harnessManifestSchema, verificationCommandsSchema, workflowPolicySchema, workerPolicySchema, worktreeManifestConfigSchema, } from "./manifest-types.js";
5
+ function isSafeProjectPath(value) {
6
+ if (!value || path.isAbsolute(value))
7
+ return false;
8
+ return !value.replaceAll("\\", "/").split("/").some((part) => part === "" || part === "." || part === "..");
9
+ }
10
+ const nullablePathMapSchema = z.record(z.string(), z.string().refine(isSafeProjectPath, "path must be a safe project-relative path").nullable());
11
+ /** Shared, credential-free overrides that are safe to commit with the project. */
12
+ export const projectConfigSchema = z
13
+ .object({
14
+ $schema: z.string().optional(),
15
+ version: z.literal(1),
16
+ verification: verificationCommandsSchema.optional(),
17
+ entrypoints: nullablePathMapSchema.optional(),
18
+ artifacts: nullablePathMapSchema.optional(),
19
+ workflowPolicy: workflowPolicySchema.optional(),
20
+ workerPolicy: workerPolicySchema.optional(),
21
+ worktree: worktreeManifestConfigSchema.optional(),
22
+ })
23
+ .strict();
24
+ const EMPTY_VERIFICATION = { quick: [], standard: [], full: [] };
25
+ function appendUnique(left, right) {
26
+ return [...new Set([...left, ...right])];
27
+ }
28
+ function mergeVerification(tracked, local) {
29
+ const shared = tracked ?? EMPTY_VERIFICATION;
30
+ const machine = local ?? EMPTY_VERIFICATION;
31
+ const sources = [];
32
+ if ([...shared.quick, ...shared.standard, ...shared.full].length > 0)
33
+ sources.push("tracked");
34
+ if ([...machine.quick, ...machine.standard, ...machine.full].length > 0)
35
+ sources.push("local");
36
+ return {
37
+ quick: appendUnique(shared.quick, machine.quick),
38
+ standard: appendUnique(shared.standard, machine.standard),
39
+ full: appendUnique(shared.full, machine.full),
40
+ reproducibility: sources.includes("local") ? "local-only" : sources.includes("tracked") ? "tracked" : "inferred",
41
+ sources,
42
+ };
43
+ }
44
+ async function readOptionalJson(file) {
45
+ try {
46
+ return JSON.parse(await readFile(file, "utf8"));
47
+ }
48
+ catch (error) {
49
+ if (error.code === "ENOENT")
50
+ return undefined;
51
+ throw error;
52
+ }
53
+ }
54
+ /**
55
+ * Load package defaults, tracked project policy, then machine-local runtime
56
+ * settings. Local verification is additive by construction: it cannot remove
57
+ * or replace a command committed in project.json.
58
+ */
59
+ export async function loadNormalizedProjectConfig(repoRoot) {
60
+ const localPath = path.join(repoRoot, "harness.json");
61
+ const trackedPath = path.join(repoRoot, ".loop-agent", "project.json");
62
+ const [localRaw, trackedRaw] = await Promise.all([
63
+ readOptionalJson(localPath),
64
+ readOptionalJson(trackedPath),
65
+ ]);
66
+ if (localRaw === undefined)
67
+ throw Object.assign(new Error("harness.json not found"), { code: "HARNESS_NOT_FOUND" });
68
+ const local = harnessManifestSchema.parse(localRaw);
69
+ const tracked = trackedRaw === undefined ? undefined : projectConfigSchema.parse(trackedRaw);
70
+ const verification = mergeVerification(tracked?.verification, local.verification);
71
+ const localInput = localRaw;
72
+ const localFields = { ...local };
73
+ delete localFields.modelProfiles;
74
+ const manifest = harnessManifestSchema.parse({
75
+ ...localFields,
76
+ entrypoints: { ...(tracked?.entrypoints ?? {}), ...(local.entrypoints ?? {}) },
77
+ artifacts: { ...(tracked?.artifacts ?? {}), ...(local.artifacts ?? {}) },
78
+ workflowPolicy: Object.hasOwn(localInput, "workflowPolicy") ? local.workflowPolicy : tracked?.workflowPolicy ?? local.workflowPolicy,
79
+ workerPolicy: Object.hasOwn(localInput, "workerPolicy") ? local.workerPolicy : tracked?.workerPolicy ?? local.workerPolicy,
80
+ worktree: Object.hasOwn(localInput, "worktree") ? local.worktree : tracked?.worktree ?? local.worktree,
81
+ verification: {
82
+ quick: verification.quick,
83
+ standard: verification.standard,
84
+ full: verification.full,
85
+ },
86
+ });
87
+ return {
88
+ schemaVersion: 1,
89
+ manifest,
90
+ verification,
91
+ sources: {
92
+ tracked: tracked ? ".loop-agent/project.json" : null,
93
+ local: "harness.json",
94
+ },
95
+ };
96
+ }
@@ -0,0 +1,151 @@
1
+ import { createHash } from "node:crypto";
2
+ import { lstat, readFile, realpath, stat } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { z } from "zod";
6
+ import { findPackageRoot } from "../shared/package-metadata.js";
7
+ const SHA256_RE = /^[a-f0-9]{64}$/;
8
+ function isSafePackagePath(value) {
9
+ if (!value || path.isAbsolute(value) || value.includes("\\"))
10
+ return false;
11
+ const parts = value.split("/");
12
+ return parts.every((part) => part !== "" && part !== "." && part !== "..");
13
+ }
14
+ export const resourceCatalogEntrySchema = z
15
+ .object({
16
+ id: z.string().trim().min(1).regex(/^[A-Za-z0-9][A-Za-z0-9:._/-]*$/),
17
+ path: z.string().refine(isSafePackagePath, "path must stay within the package root"),
18
+ kind: z.enum(["document", "skill", "template", "schema", "prompt", "script", "other"]),
19
+ bytes: z.number().int().nonnegative(),
20
+ sha256: z.string().regex(SHA256_RE),
21
+ schemaVersion: z.number().int().positive(),
22
+ })
23
+ .strict();
24
+ export const resourceCatalogSchema = z
25
+ .object({
26
+ schemaVersion: z.literal(1),
27
+ entries: z.array(resourceCatalogEntrySchema),
28
+ })
29
+ .strict()
30
+ .superRefine((catalog, ctx) => {
31
+ const ids = new Set();
32
+ const paths = new Set();
33
+ for (const [index, entry] of catalog.entries.entries()) {
34
+ if (ids.has(entry.id))
35
+ ctx.addIssue({ code: "custom", path: ["entries", index, "id"], message: "duplicate resource id" });
36
+ if (paths.has(entry.path))
37
+ ctx.addIssue({ code: "custom", path: ["entries", index, "path"], message: "duplicate resource path" });
38
+ ids.add(entry.id);
39
+ paths.add(entry.path);
40
+ }
41
+ });
42
+ export const CONTROLLER_RESOURCE_IDS = {
43
+ loopAgentBridgeSkill: "agent-bridge:loop-agent",
44
+ };
45
+ export function builtinSkillResourceId(name) {
46
+ return `builtin-skill:${name}`;
47
+ }
48
+ export function builtinSkillReferenceResourceId(name, relativePath) {
49
+ return `builtin-skill-resource:${name}/${relativePath}`;
50
+ }
51
+ export class ResourceCatalogError extends Error {
52
+ code;
53
+ constructor(code, message) {
54
+ super(message);
55
+ this.code = code;
56
+ this.name = "ResourceCatalogError";
57
+ }
58
+ }
59
+ function sha256(bytes) {
60
+ return createHash("sha256").update(bytes).digest("hex");
61
+ }
62
+ async function assertContainedRegularFile(root, candidate) {
63
+ const [rootReal, candidateReal, linkInfo] = await Promise.all([
64
+ realpath(root),
65
+ realpath(candidate),
66
+ lstat(candidate),
67
+ ]);
68
+ const relative = path.relative(rootReal, candidateReal);
69
+ if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) {
70
+ throw new ResourceCatalogError("RESOURCE_PATH_ESCAPE", `resource resolves outside package root: ${candidate}`);
71
+ }
72
+ if (!linkInfo.isFile() || linkInfo.isSymbolicLink() || linkInfo.nlink !== 1) {
73
+ throw new ResourceCatalogError("RESOURCE_NOT_REGULAR", `resource is not a regular file: ${candidate}`);
74
+ }
75
+ }
76
+ /** Lazy package resource provider: load the small catalog once, hash bytes only when used. */
77
+ export class ControllerContextProvider {
78
+ packageRoot;
79
+ identity;
80
+ entries;
81
+ constructor(packageRoot, catalog, catalogBytes) {
82
+ this.packageRoot = packageRoot;
83
+ this.entries = new Map(catalog.entries.map((entry) => [entry.id, entry]));
84
+ this.identity = { schemaVersion: 1, catalogDigest: sha256(catalogBytes) };
85
+ }
86
+ static async load(packageRoot, catalogName = "resource-catalog.v1.json") {
87
+ const catalogPath = path.join(packageRoot, catalogName);
88
+ await assertContainedRegularFile(packageRoot, catalogPath);
89
+ const bytes = await readFile(catalogPath);
90
+ let parsed;
91
+ try {
92
+ parsed = JSON.parse(bytes.toString("utf8"));
93
+ }
94
+ catch (error) {
95
+ throw new ResourceCatalogError("RESOURCE_CATALOG_INVALID", `invalid resource catalog JSON: ${String(error)}`);
96
+ }
97
+ const catalog = resourceCatalogSchema.safeParse(parsed);
98
+ if (!catalog.success) {
99
+ throw new ResourceCatalogError("RESOURCE_CATALOG_INVALID", `invalid resource catalog: ${catalog.error.message}`);
100
+ }
101
+ return new ControllerContextProvider(packageRoot, catalog.data, bytes);
102
+ }
103
+ list() {
104
+ return [...this.entries.values()].map((entry) => ({ ...entry }));
105
+ }
106
+ entry(id) {
107
+ const entry = this.entries.get(id);
108
+ return entry ? { ...entry } : undefined;
109
+ }
110
+ async read(id) {
111
+ const entry = this.entries.get(id);
112
+ if (!entry)
113
+ throw new ResourceCatalogError("RESOURCE_NOT_FOUND", `resource not found: ${id}`);
114
+ const file = path.join(this.packageRoot, ...entry.path.split("/"));
115
+ await assertContainedRegularFile(this.packageRoot, file);
116
+ const before = await stat(file);
117
+ const bytes = await readFile(file);
118
+ const after = await stat(file);
119
+ if (before.dev !== after.dev || before.ino !== after.ino || before.size !== after.size || before.mtimeMs !== after.mtimeMs) {
120
+ throw new ResourceCatalogError("RESOURCE_CHANGED_DURING_READ", `resource changed while reading: ${id}`);
121
+ }
122
+ if (bytes.byteLength !== entry.bytes || sha256(bytes) !== entry.sha256) {
123
+ throw new ResourceCatalogError("RESOURCE_HASH_MISMATCH", `resource does not match catalog: ${id}`);
124
+ }
125
+ return bytes;
126
+ }
127
+ async readText(id) {
128
+ const entry = this.entries.get(id);
129
+ if (!entry)
130
+ throw new ResourceCatalogError("RESOURCE_NOT_FOUND", `resource not found: ${id}`);
131
+ const bytes = await this.read(id);
132
+ return {
133
+ id,
134
+ relativePath: entry.path,
135
+ absolutePath: path.join(this.packageRoot, ...entry.path.split("/")),
136
+ kind: entry.kind,
137
+ schemaVersion: entry.schemaVersion,
138
+ bytes: entry.bytes,
139
+ sha256: entry.sha256,
140
+ text: bytes.toString("utf8"),
141
+ };
142
+ }
143
+ }
144
+ export async function createControllerContextProvider(options = {}) {
145
+ const packageRoot = options.packageRoot
146
+ ?? findPackageRoot(path.dirname(fileURLToPath(import.meta.url)));
147
+ if (!packageRoot) {
148
+ throw new ResourceCatalogError("PACKAGE_ROOT_NOT_FOUND", "cannot locate the loop-agent package root for controller resources");
149
+ }
150
+ return ControllerContextProvider.load(packageRoot, options.catalogName ?? "resource-catalog.v1.json");
151
+ }
@@ -45,6 +45,9 @@ export function openConsoleAppData(options) {
45
45
  chats: path.join(repoNamespace, "chats"),
46
46
  chatSessions: path.join(repoNamespace, "chat-sessions"),
47
47
  chatEvents: path.join(repoNamespace, "chat-events"),
48
+ browserProfile: path.join(repoNamespace, "browser-profile"),
49
+ browserDownloads: path.join(repoNamespace, "browser-downloads"),
50
+ browserScreenshots: path.join(repoNamespace, "browser-screenshots"),
48
51
  resourcePreferences: path.join(repoNamespace, "resource-preferences.json"),
49
52
  };
50
53
  for (const dir of [
@@ -60,6 +63,9 @@ export function openConsoleAppData(options) {
60
63
  paths.chats,
61
64
  paths.chatSessions,
62
65
  paths.chatEvents,
66
+ paths.browserProfile,
67
+ paths.browserDownloads,
68
+ paths.browserScreenshots,
63
69
  path.dirname(paths.resourcePreferences),
64
70
  ]) {
65
71
  ensureSecureDir(dir);
@@ -284,13 +290,17 @@ export async function removeStaged(filePath) {
284
290
  await rm(filePath, { force: true });
285
291
  }
286
292
  /** Synchronous helpers used by boot-time path checks. */
287
- export function writeSecureJsonSync(filePath, value) {
293
+ export function writeSecureJsonSync(filePath, value, options) {
288
294
  const dir = path.dirname(filePath);
289
295
  ensureSecureDir(dir);
290
296
  const resolved = assertSafeAppDataPath(dir, filePath);
291
297
  const tmp = `${resolved}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
298
+ const pretty = options?.pretty !== false;
299
+ const body = pretty
300
+ ? `${JSON.stringify(value, null, 2)}\n`
301
+ : `${JSON.stringify(value)}\n`;
292
302
  try {
293
- writeFileSync(tmp, `${JSON.stringify(value, null, 2)}\n`, {
303
+ writeFileSync(tmp, body, {
294
304
  encoding: "utf8",
295
305
  mode: 0o600,
296
306
  });
@@ -6,6 +6,26 @@ import { buildFrontendSplitAggregateCloseout, computeFrontendSplitDigest, finali
6
6
  import { frontendCloseoutFactsSchema, frontendTestHandoffSchema, } from "../../workflows/dag/frontend-closeout.js";
7
7
  import { listJsonFiles, readJsonIfExists, sha256Json, writeSecureJson, } from "./app-data.js";
8
8
  export const TERMINAL_OPERATION_STATES = new Set(["succeeded", "failed", "timed-out", "restarting"]);
9
+ /**
10
+ * Operation states that hold an admission slot. needs-reconcile requires
11
+ * inspection but does not itself prove a live operation; callers still check
12
+ * DAG/Worker/chat activity separately. restarting is the terminal receipt of
13
+ * a successful Console handoff, retained across boots, not a live slot.
14
+ * A needs-reconcile record remains visible as a non-business outcome, but
15
+ * must never strand later mutations after its runtime is gone.
16
+ */
17
+ export const OCCUPIED_OPERATION_STATES = new Set(["queued", "starting", "running"]);
18
+ /** True when the state can still make progress and therefore holds the slot. */
19
+ export function isOperationOccupied(state) {
20
+ return OCCUPIED_OPERATION_STATES.has(state);
21
+ }
22
+ /**
23
+ * True when no further state transition will ever occur: a business terminal
24
+ * (succeeded/failed/timed-out/restarting) or a stranded needs-reconcile.
25
+ */
26
+ export function isOperationSettled(state) {
27
+ return TERMINAL_OPERATION_STATES.has(state) || state === "needs-reconcile";
28
+ }
9
29
  function operationFile(appData, operationId) {
10
30
  return path.join(appData.operations, `${operationId}.json`);
11
31
  }
@@ -359,14 +379,11 @@ export class OperationStore {
359
379
  for (const op of await this.list()) {
360
380
  if (TERMINAL_OPERATION_STATES.has(op.state))
361
381
  continue;
362
- // A consoleUpdateAndInit whose record already proves a requested
363
- // handoff died before writing its terminal state: the update and
364
- // restart themselves succeeded — the booting process IS the
365
- // handoff target. Mark it succeeded instead of surfacing the
366
- // generic needs-reconcile failure copy to the operator.
382
+ // A consoleUpdateAndInit that proved its handoff before the process
383
+ // died must not be reported as a stranded failure: the booting
384
+ // process IS the handoff target, so the update actually succeeded.
367
385
  if (op.action === "consoleUpdateAndInit" &&
368
- op.state === "needs-reconcile" &&
369
- isProvenConsoleUpdateHandoff(op.result)) {
386
+ isProvenConsoleUpdateHandoff(op)) {
370
387
  changed.push(await this.update(op.operationId, {
371
388
  state: "succeeded",
372
389
  errorCode: undefined,
@@ -398,17 +415,34 @@ export function isTerminalOperationState(state) {
398
415
  return TERMINAL_OPERATION_STATES.has(state);
399
416
  }
400
417
  /**
401
- * True when a consoleUpdateAndInit result proves the handoff was requested
402
- * (install verified + init clean + new Console spawned). Used by boot
403
- * reconcile to close the record as succeeded even though the old process
404
- * died before writing its terminal state.
418
+ * True when a consoleUpdateAndInit record proves the handoff actually
419
+ * succeeded (install verified + new Console spawned), so boot reconcile can
420
+ * close it as succeeded even though the dying process never wrote its
421
+ * terminal state.
422
+ *
423
+ * The proof reads the maintenance projection rather than only `result.state`.
424
+ * The old check required `result.state === "restarting"`, but the executor
425
+ * writes `state` and `maintenance` together (`console-update-and-init.ts`),
426
+ * so any path that recorded the handoff proof together with a non-restarting
427
+ * `state` — most importantly the `needs-reconcile` record that
428
+ * `acceptConsoleUpdateAndInit` writes when the executor throws *after* a
429
+ * successful handoff — could never satisfy it. Such records were stranded
430
+ * forever: boot reconcile skipped them and they blocked later updates.
431
+ *
432
+ * `handoff.status === "requested"` is only ever set on the success path, and
433
+ * `package.status === "failed"` explicitly disqualifies a record, so this
434
+ * stays fail-closed for genuine failures.
405
435
  */
406
- function isProvenConsoleUpdateHandoff(result) {
436
+ export function isProvenConsoleUpdateHandoff(operation) {
437
+ if (!operation || operation.action !== "consoleUpdateAndInit")
438
+ return false;
439
+ const result = operation.result;
407
440
  if (!result || typeof result !== "object")
408
441
  return false;
409
442
  const shape = result;
410
- return (shape.state === "restarting" &&
411
- shape.maintenance?.handoff?.status === "requested");
443
+ if (shape.maintenance?.handoff?.status !== "requested")
444
+ return false;
445
+ return shape.maintenance?.package?.status !== "failed";
412
446
  }
413
447
  export function clipPreview(text, max = 4096) {
414
448
  if (text.length <= max)
@@ -1,3 +1,4 @@
1
+ import { readFileBoundarySafe } from "../../shared/path-safety.js";
1
2
  import { access, mkdir, readdir, readFile, rename, rm } from "node:fs/promises";
2
3
  import path from "node:path";
3
4
  import { mkdtemp } from "node:fs/promises";
@@ -30,28 +31,27 @@ async function pathExists(filePath) {
30
31
  function serializeManifest(manifest) {
31
32
  return `${JSON.stringify(manifest, null, 2)}\n`;
32
33
  }
34
+ function compareArtifactPaths(a, b) {
35
+ return a.path < b.path ? -1 : a.path > b.path ? 1 : 0;
36
+ }
33
37
  function normalizeTasksForStorage(tasks) {
34
38
  return [...tasks]
35
39
  .map((task) => ({
36
40
  ...task,
37
41
  taskRef: task.taskRef.replace(/\\/g, "/"),
38
42
  seeds: [...task.seeds].sort((a, b) => a - b),
43
+ ...("category" in task ? {
44
+ requirements: [...task.requirements].sort(compareArtifactPaths),
45
+ initialFiles: [...task.initialFiles].sort(compareArtifactPaths),
46
+ oracleFiles: [...task.oracleFiles].sort(compareArtifactPaths),
47
+ } : {}),
39
48
  }))
40
49
  .sort((a, b) => a.taskRef < b.taskRef ? -1 : a.taskRef > b.taskRef ? 1 : 0);
41
50
  }
42
51
  export async function materializeCorpusManifest(raw) {
43
52
  const input = corpusManifestInputSchema.parse(raw);
44
53
  const tasks = normalizeTasksForStorage(input.tasks);
45
- const withoutHash = {
46
- schemaVersion: 1,
47
- corpusId: input.corpusId,
48
- createdAt: input.createdAt,
49
- ...(input.description !== undefined
50
- ? { description: input.description }
51
- : {}),
52
- tasks,
53
- };
54
- const corpusHash = computeCorpusHash(withoutHash);
54
+ const corpusHash = computeCorpusHash(input);
55
55
  if (input.corpusHash) {
56
56
  const provided = formatContentSha(normalizeContentSha(input.corpusHash));
57
57
  if (provided !== corpusHash) {
@@ -59,10 +59,30 @@ export async function materializeCorpusManifest(raw) {
59
59
  }
60
60
  }
61
61
  return corpusManifestSchema.parse({
62
- ...withoutHash,
62
+ ...input,
63
+ tasks,
63
64
  corpusHash,
64
65
  });
65
66
  }
67
+ export async function assertCorpusArtifacts(repoRoot, manifest) {
68
+ if (manifest.schemaVersion !== 2)
69
+ return;
70
+ const snapshots = new Map();
71
+ for (const task of manifest.tasks)
72
+ for (const ref of [...task.requirements, ...task.initialFiles, ...task.oracleFiles]) {
73
+ const bytes = await readFileBoundarySafe({ boundaryRoot: repoRoot,
74
+ targetPath: path.resolve(repoRoot, ref.path), label: "frontend corpus artifact" });
75
+ if (sha256Hex(bytes) !== ref.sha256)
76
+ throw Error(`corpus artifact hash mismatch: ${ref.path}`);
77
+ snapshots.set(ref.path, bytes);
78
+ }
79
+ for (const [file, expected] of snapshots) {
80
+ const actual = await readFileBoundarySafe({ boundaryRoot: repoRoot,
81
+ targetPath: path.resolve(repoRoot, file), label: "frontend corpus artifact recheck" });
82
+ if (!actual.equals(expected))
83
+ throw Error(`corpus artifact changed during collection: ${file}`);
84
+ }
85
+ }
66
86
  async function assertManifestIntegrity(repoRoot, corpusId, rawManifest) {
67
87
  const integrityPath = path.join(corpusDir(repoRoot, corpusId), MANIFEST_INTEGRITY_FILE);
68
88
  const expected = (await readFile(integrityPath, "utf-8")).trim();
@@ -98,6 +118,7 @@ export async function readCorpusManifest(repoRoot, corpusId) {
98
118
  if (recomputed !== stored.corpusHash) {
99
119
  throw new Error(`corpusHash mismatch for ${corpusId}: expected ${recomputed}, got ${stored.corpusHash}`);
100
120
  }
121
+ await assertCorpusArtifacts(repoRoot, stored);
101
122
  return stored;
102
123
  }
103
124
  export async function listCorpusIds(repoRoot) {
@@ -117,7 +138,11 @@ export async function listCorpusIds(repoRoot) {
117
138
  }
118
139
  }
119
140
  export async function registerCorpusManifest(input) {
120
- const { repoRoot, manifest } = input;
141
+ const repoRoot = input.repoRoot;
142
+ const manifest = corpusManifestSchema.parse(input.manifest);
143
+ if (computeCorpusHash(manifest) !== manifest.corpusHash)
144
+ throw Error("corpusHash mismatch");
145
+ await assertCorpusArtifacts(repoRoot, manifest);
121
146
  assertCorpusId(manifest.corpusId);
122
147
  const manifestPath = corpusManifestPath(repoRoot, manifest.corpusId);
123
148
  if (await pathExists(manifestPath)) {
@@ -81,6 +81,8 @@ function isUnchangedNewTaskTemplate(step, content) {
81
81
  }
82
82
  function firstRequiredSectionIsEmpty(step, content) {
83
83
  const [, firstSectionHeading] = REQUIRED_HEADINGS[step];
84
+ if (!firstSectionHeading)
85
+ return false;
84
86
  const headingIndex = content.indexOf(firstSectionHeading);
85
87
  if (headingIndex < 0) {
86
88
  return false;
@@ -0,0 +1,47 @@
1
+ import { createHash } from "node:crypto";
2
+ import { readFileSync } from "node:fs";
3
+ import path from "node:path";
4
+ import { buildControllerIdentityFromEntry, readBuildStamp } from "./package-metadata.js";
5
+ export function sha256File(file) {
6
+ return `sha256:${createHash("sha256").update(readFileSync(file)).digest("hex")}`;
7
+ }
8
+ export function classifyBackendDogfoodProvenance(input) {
9
+ if (input.tarballPath)
10
+ return { kind: "local-tarball", version: input.identity.packageVersion, tarballSha256: sha256File(input.tarballPath) };
11
+ if (input.distTag)
12
+ return { kind: "published-npm", version: input.identity.packageVersion, distTag: input.distTag };
13
+ return { kind: "local-candidate", version: input.identity.packageVersion };
14
+ }
15
+ export function buildBackendDogfoodIdentityEvidence(input) {
16
+ const controller = buildControllerIdentityFromEntry({ requested: input.controllerEntry, entry: path.resolve(input.controllerEntry) });
17
+ if (!controller)
18
+ throw new Error("BACKEND_DOGFOOD_IDENTITY_UNRESOLVED");
19
+ const fingerprint = controller.packageFingerprint.value;
20
+ if (fingerprint !== input.expectedFingerprint)
21
+ throw new Error(`BACKEND_DOGFOOD_CONTROLLER_MISMATCH: expected ${input.expectedFingerprint}, got ${fingerprint}`);
22
+ const consoleIdentity = input.consoleHost
23
+ ? undefined
24
+ : buildControllerIdentityFromEntry({
25
+ requested: input.consoleControllerEntry ?? path.join(controller.packageRoot, "bin", "agent-worker.js"),
26
+ entry: input.consoleControllerEntry ?? path.join(controller.packageRoot, "bin", "agent-worker.js"),
27
+ });
28
+ if (!input.consoleHost && !consoleIdentity)
29
+ throw new Error("BACKEND_DOGFOOD_CONSOLE_IDENTITY_UNRESOLVED");
30
+ const consoleHost = {
31
+ packageName: String(input.consoleHost?.packageName ?? consoleIdentity?.packageName),
32
+ packageVersion: String(input.consoleHost?.packageVersion ?? consoleIdentity?.packageVersion),
33
+ packageFingerprint: String(input.consoleHost?.packageFingerprint ?? consoleIdentity?.packageFingerprint.value),
34
+ };
35
+ const expected = `${controller.packageName}@${controller.packageVersion}@${fingerprint}`;
36
+ const actual = `${consoleHost.packageName}@${consoleHost.packageVersion}@${consoleHost.packageFingerprint}`;
37
+ if (actual !== expected)
38
+ throw new Error(`BACKEND_DOGFOOD_CONSOLE_IDENTITY_MISMATCH: expected ${expected}, got ${actual}`);
39
+ return {
40
+ schemaVersion: 1,
41
+ controller,
42
+ provenance: classifyBackendDogfoodProvenance({ identity: controller, distTag: input.distTag, tarballPath: input.tarballPath }),
43
+ buildCommitSha: readBuildStamp(controller.packageRoot)?.gitSha ?? null,
44
+ consoleHost,
45
+ dagController: { packageName: controller.packageName, packageVersion: controller.packageVersion, packageFingerprint: fingerprint },
46
+ };
47
+ }
@@ -59,10 +59,19 @@ const RAW_TO_NORMALIZED = {
59
59
  quota: "executor",
60
60
  "rate-limit": "executor",
61
61
  unavailable: "executor",
62
+ // Gateway reachability outage: still an executor-class failure, but named so
63
+ // reports do not read as a capability mismatch.
64
+ "upstream-unavailable": "executor",
62
65
  // Context window overflow (400 request-too-large): the session needs
63
66
  // compaction / fresh context before retrying — an executor-side
64
67
  // environment condition, not a plan-quality defect.
65
68
  "context-overflow": "executor",
69
+ // stopReason=length output-capacity truncation: same executor-side
70
+ // capacity class as context-overflow. Legacy thinking-exhausted labels
71
+ // (pre-output-limit artifacts) map to the same class.
72
+ "output-limit": "executor",
73
+ "writer-thinking-exhausted": "executor",
74
+ "planner-thinking-exhausted": "executor",
66
75
  // Deterministic capability/policy refusal: missing verified launcher JS
67
76
  // entry, capability allowlist rejection, or missing bounded write tool
68
77
  // profile. These are environment/config defects the operator repairs
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Compare two stat records as the same file identity.
3
+ *
4
+ * POSIX: `dev` and `ino` together identify the inode; both must match.
5
+ *
6
+ * win32: libuv reports `dev` inconsistently across stat APIs — `fstat()`
7
+ * (from an open handle) returns the volume serial number while `lstat()`
8
+ * (from a path) returns 0. A cross-API comparison therefore always fails on
9
+ * Windows even when the path still refers to the same file, breaking every
10
+ * guard that rechecks identity after opening (user-reported on 0.42.1 and
11
+ * 0.43.0, Node 23.x). On win32 the `dev` field is skipped and `ino` plus the
12
+ * caller-side type/link/realpath checks remain the identity boundary.
13
+ *
14
+ * When both stats come from the same API the comparison is exact on every
15
+ * platform; the win32 relaxation only affects cross-API rechecks.
16
+ */
17
+ export function sameFileIdentity(opened, current, platform = process.platform) {
18
+ if (current.ino !== opened.ino)
19
+ return false;
20
+ if (platform !== "win32" && current.dev !== opened.dev)
21
+ return false;
22
+ return true;
23
+ }
@@ -0,0 +1,23 @@
1
+ import { z } from "zod";
2
+ /** Execution hints and estimation reserves, never model-name capacity defaults. */
3
+ export const frontendExecutionPolicySchema = z.object({
4
+ scopeTargetBytes: z.number().int().positive().default(24_000),
5
+ maxScopeUnits: z.number().int().positive().default(4),
6
+ maxCoverageConcurrency: z.number().int().min(1).max(4).default(4),
7
+ outputReserveTokens: z.number().int().positive().default(4096),
8
+ readGrowthReserveTokens: z.number().int().nonnegative().default(2048),
9
+ safetyRatio: z.number().min(0).max(0.5).default(0.15),
10
+ }).strict();
11
+ export function frontendModelCapabilities(model) {
12
+ const value = model && typeof model === "object" ? model : {};
13
+ const positive = (v) => typeof v === "number" && Number.isFinite(v) && v > 0 ? v : null;
14
+ return { model: typeof value.id === "string" ? `${value.provider ?? "unknown"}/${value.id}` : null, source: Object.keys(value).length ? "model-registry" : "unknown", inputLimit: positive(value.inputLimit), totalContextLimit: positive(value.contextWindow), outputLimit: positive(value.maxTokens), reasoningControllability: "unknown" };
15
+ }
16
+ export function measureFrontendRequestEnvelope(context, model, policy) {
17
+ const bytes = Buffer.byteLength(JSON.stringify(context));
18
+ const estimatedTokens = Math.ceil(bytes / 3);
19
+ const capabilities = frontendModelCapabilities(model);
20
+ const outputReserve = Math.min(policy.outputReserveTokens, capabilities.outputLimit ?? policy.outputReserveTokens);
21
+ const availableInputTokens = Math.min(capabilities.inputLimit ?? Infinity, capabilities.totalContextLimit === null ? Infinity : Math.floor(capabilities.totalContextLimit * (1 - policy.safetyRatio)) - outputReserve - policy.readGrowthReserveTokens);
22
+ return { bytes, estimatedTokens, estimatorVersion: "utf8-bytes-div3-v1-estimate", capabilities, availableInputTokens: Number.isFinite(availableInputTokens) ? availableInputTokens : null, exceedsEstimate: estimatedTokens > availableInputTokens };
23
+ }
@@ -112,6 +112,8 @@ function globToRegExp(pattern) {
112
112
  let regex = '^';
113
113
  for (let i = 0; i < normalized.length; i += 1) {
114
114
  const char = normalized[i];
115
+ if (char === undefined)
116
+ continue;
115
117
  const next = normalized[i + 1];
116
118
  if (char === '*' && next === '*') {
117
119
  const afterGlobstar = normalized[i + 2];