@iowarp/clio-coder 0.3.4 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (376) hide show
  1. package/CHANGELOG.md +65 -2
  2. package/CONTRIBUTING.md +6 -6
  3. package/README.md +16 -5
  4. package/dist/{acp-S5R4RR5B.js → acp-SK4MD6MM.js} +11 -11
  5. package/dist/{agents-P6DMMVZY.js → agents-2FN2K6ME.js} +33 -26
  6. package/dist/assets/codewiki.json +1 -1
  7. package/dist/{auth-2XCZLPKS.js → auth-QIYZWM5I.js} +15 -15
  8. package/dist/{chunk-EKMEHE4H.js → chunk-33YXPOE3.js} +2 -3
  9. package/dist/{chunk-VAWWTKDP.js → chunk-3HAPLH5M.js} +11 -11
  10. package/dist/{chunk-YCWGATWI.js → chunk-465YSENW.js} +3 -3
  11. package/dist/{chunk-4OC57DA6.js → chunk-4DGYLA73.js} +53 -2
  12. package/dist/{chunk-UZHIZC5S.js → chunk-4DWFMQDR.js} +61 -76
  13. package/dist/{chunk-ZWMF7253.js → chunk-5C3AQNDW.js} +328 -9
  14. package/dist/{chunk-22NAGB7X.js → chunk-5C77SEEY.js} +5 -94
  15. package/dist/{chunk-WPQLXFOZ.js → chunk-5FR74PWO.js} +3 -2
  16. package/dist/{chunk-35MKKU5R.js → chunk-5UJ6ECTS.js} +18 -10
  17. package/dist/{chunk-BRXQQJFP.js → chunk-6M7VS3J3.js} +571 -50
  18. package/dist/{chunk-QQK64KLB.js → chunk-6TUKSZVF.js} +141 -23
  19. package/dist/{chunk-N4CZJQRK.js → chunk-AB4XIIVB.js} +8 -6
  20. package/dist/{chunk-KRPY7NTG.js → chunk-BMWK7ZIZ.js} +14 -20
  21. package/dist/{chunk-4BPJXDWC.js → chunk-C4JBQ5SR.js} +30 -14
  22. package/dist/{chunk-ZYKPLLNQ.js → chunk-CEYBNUGC.js} +821 -83
  23. package/dist/{chunk-VEZEGCGW.js → chunk-D4MDIG46.js} +20 -18
  24. package/dist/chunk-DJNLUABN.js +843 -0
  25. package/dist/{chunk-BP4OYD6A.js → chunk-DMD2AGVS.js} +21 -2
  26. package/dist/{chunk-KOHPCX4K.js → chunk-DOOEX22V.js} +2 -2
  27. package/dist/chunk-DQA7QLMD.js +123 -0
  28. package/dist/chunk-DR52UMZW.js +21 -0
  29. package/dist/{chunk-3HZ5RWN2.js → chunk-EBEFWSGL.js} +9 -7
  30. package/dist/{chunk-EDRHSCIE.js → chunk-EELBMBT6.js} +128 -13
  31. package/dist/{chunk-HV5X7OR2.js → chunk-EOOQZZDE.js} +16 -14
  32. package/dist/{chunk-WR67VIZY.js → chunk-FOT2FX5J.js} +63 -5
  33. package/dist/{chunk-BPGS2WCQ.js → chunk-GEYXPTRF.js} +2 -1
  34. package/dist/{chunk-FYYLNIL5.js → chunk-GH5622CP.js} +2 -2
  35. package/dist/{chunk-BEY543CS.js → chunk-GOXNB3AO.js} +5 -2
  36. package/dist/chunk-GWS3VEIW.js +195 -0
  37. package/dist/{chunk-G4BMMOKF.js → chunk-HVDIIIQW.js} +2 -2
  38. package/dist/chunk-HWUFFB6L.js +83 -0
  39. package/dist/{chunk-X6COSD2O.js → chunk-J7PIKKWC.js} +8 -436
  40. package/dist/{chunk-NILBFAPG.js → chunk-JNXPYBB4.js} +2 -2
  41. package/dist/{chunk-4VP4KH3K.js → chunk-JRIO5UD2.js} +4 -4
  42. package/dist/{chunk-K6WL7QZT.js → chunk-JTSEDYVQ.js} +7 -7
  43. package/dist/{chunk-QKMUKYO7.js → chunk-KCMKRQX4.js} +236 -84
  44. package/dist/chunk-KZ2H5X4G.js +1026 -0
  45. package/dist/{chunk-A2GZF7DC.js → chunk-LADCF22A.js} +13 -13
  46. package/dist/chunk-LCGCVYZ4.js +57 -0
  47. package/dist/chunk-M4AKACEO.js +382 -0
  48. package/dist/{chunk-POHLU5DW.js → chunk-M6L6IDJG.js} +3 -3
  49. package/dist/{chunk-4JUF2NNX.js → chunk-MXI6J5JF.js} +7 -7
  50. package/dist/{chunk-X4RCMKVQ.js → chunk-NDINPTJ4.js} +2 -2
  51. package/dist/{chunk-TTNYS3EA.js → chunk-OB5HIGJY.js} +1 -1
  52. package/dist/{chunk-7RXG6QRZ.js → chunk-OBMAI2DP.js} +61 -840
  53. package/dist/{chunk-5M54SPOL.js → chunk-ODFEOB4F.js} +161 -5
  54. package/dist/chunk-PD3MESLB.js +242 -0
  55. package/dist/{chunk-ED4KHGC3.js → chunk-PPAMZ32Z.js} +9 -2
  56. package/dist/{chunk-VMNQ6OZA.js → chunk-QCTRSGHQ.js} +963 -786
  57. package/dist/chunk-RVG5JXAL.js +41 -0
  58. package/dist/{chunk-RD5U66HV.js → chunk-SROCI7ZU.js} +7 -7
  59. package/dist/{chunk-MFFY33HR.js → chunk-THKY7CD7.js} +466 -205
  60. package/dist/{chunk-34475P3I.js → chunk-TSHXZTOQ.js} +5 -4
  61. package/dist/{chunk-PCZJO5TI.js → chunk-UFQ3F4FW.js} +13 -178
  62. package/dist/{chunk-AD2SYQYC.js → chunk-UHXRNZ2J.js} +121 -3
  63. package/dist/chunk-UND3GU2L.js +103 -0
  64. package/dist/{chunk-QQL5RT5M.js → chunk-UUANF5CR.js} +2323 -2114
  65. package/dist/{chunk-VJWL6YS5.js → chunk-UUVG37B4.js} +2 -2
  66. package/dist/chunk-UVDSQ6LW.js +472 -0
  67. package/dist/{chunk-QWU7ZBO7.js → chunk-VQNODYQ4.js} +215 -56
  68. package/dist/chunk-VREKEFLL.js +37 -0
  69. package/dist/{chunk-2TZWSW76.js → chunk-WHGPSPT5.js} +2 -2
  70. package/dist/{chunk-TW3WDMVS.js → chunk-WHJYKASB.js} +2 -2
  71. package/dist/{chunk-MEQ45TQ4.js → chunk-WJHBC77E.js} +21 -7
  72. package/dist/{chunk-HXG4IURW.js → chunk-X2KV5FXT.js} +2 -2
  73. package/dist/{chunk-YHZX5GEU.js → chunk-XAKHZX5N.js} +2 -2
  74. package/dist/{chunk-2LZI5CAG.js → chunk-XEGB6BCN.js} +228 -36
  75. package/dist/{chunk-E25LMLRW.js → chunk-YD734TPH.js} +2 -2
  76. package/dist/{verifiers-4UUM6TEE.js → chunk-YTYFXUI3.js} +121 -372
  77. package/dist/{chunk-3JLKSKD7.js → chunk-ZGH7FGS5.js} +17 -7
  78. package/dist/{chunk-VSNATDE6.js → chunk-ZZMN5OM4.js} +2 -2
  79. package/dist/cli/index.js +34 -32
  80. package/dist/{clio-J5JIOIDS.js → clio-WBVQEBKO.js} +7 -7
  81. package/dist/{code-nav-AXCXSBHX.js → code-nav-FGGFIE7L.js} +7 -7
  82. package/dist/codewiki/build-worker.js +4 -4
  83. package/dist/{components-KELWS457.js → components-F7OEATSO.js} +5 -5
  84. package/dist/{config-OEBMIN2U.js → config-TRBL3RCF.js} +48 -41
  85. package/dist/{configure-PUQOSIXQ.js → configure-OLCVPHNM.js} +17 -17
  86. package/dist/{context-URSXPBCK.js → context-MJIJ6GOX.js} +12 -12
  87. package/dist/{context-EKDCKUUZ.js → context-WFPKQSM6.js} +26 -9
  88. package/dist/{context-MGSE4Z2T.js → context-XEWE3MOJ.js} +44 -37
  89. package/dist/{context-clear-KDAJRNUK.js → context-clear-KNOS2JPB.js} +44 -37
  90. package/dist/{context-index-BZ4UYMTC.js → context-index-SSR5ECNE.js} +3 -3
  91. package/dist/{context-working-set-SBKMPPI2.js → context-working-set-EUXAZI6N.js} +14 -13
  92. package/dist/{dispatch-runner-MSWN72NK.js → dispatch-runner-B7MTOVKL.js} +321 -60
  93. package/dist/{docs-2C2LTVT2.js → docs-FLJTIDSE.js} +5 -5
  94. package/dist/{doctor-7BSE27PJ.js → doctor-RN4YKO2X.js} +15 -15
  95. package/dist/{eval-IZGDOO4H.js → eval-RUBJVSNQ.js} +52 -236
  96. package/dist/{evidence-SR7WXB5B.js → evidence-JZNBUOQZ.js} +39 -33
  97. package/dist/{evolve-K7VE2CBX.js → evolve-FJVC4KKI.js} +39 -33
  98. package/dist/{extensions-QVDOHDGJ.js → extensions-IQL36S7K.js} +5 -5
  99. package/dist/{fleet-7XMJNQNF.js → fleet-BDKYJFCP.js} +243 -370
  100. package/dist/fleet-commands-ZFIWZSB3.js +70 -0
  101. package/dist/fleet-graph-Y6HPXIVF.js +125 -0
  102. package/dist/fleet-new-RDVJLHHH.js +48 -0
  103. package/dist/{fleet-preflight-AQNAH644.js → fleet-preflight-BHSNPBMH.js} +2 -2
  104. package/dist/fleet-validate-BIYREGIK.js +79 -0
  105. package/dist/{init-JGNPAYXT.js → init-LQUB5COQ.js} +57 -48
  106. package/dist/library-NJAHIGG4.js +217 -0
  107. package/dist/memory-OG6HOYKM.js +472 -0
  108. package/dist/{models-ZMMLFJNN.js → models-5ZG5XY7J.js} +23 -22
  109. package/dist/{monitor-2F3T5KHP.js → monitor-TJ7AMTGB.js} +69 -35
  110. package/dist/{orchestrator-ORHT43JB.js → orchestrator-WZYB54DM.js} +4868 -1189
  111. package/dist/{paths-UXLN5YYZ.js → paths-XUC7GS6E.js} +5 -5
  112. package/dist/{reset-NXGTYNUO.js → reset-PXQT45IY.js} +8 -8
  113. package/dist/{run-RF4WJGMT.js → run-FQ74YF62.js} +82 -62
  114. package/dist/{share-UT3W6E4M.js → share-FW7SVCL3.js} +34 -10
  115. package/dist/{skills-PSACKC5Q.js → skills-7E7IRB3R.js} +25 -9
  116. package/dist/{skills-eval-WJSI55RZ.js → skills-eval-LI75W6OK.js} +43 -35
  117. package/dist/{targets-PIIRAOYS.js → targets-4CIFKCTW.js} +27 -24
  118. package/dist/{terminal-lease-ULWXWNVY.js → terminal-lease-WUZY7ZV5.js} +5 -4
  119. package/dist/{uninstall-FZCQCDKC.js → uninstall-7FV7IP4E.js} +5 -5
  120. package/dist/{upgrade-346TZ6AV.js → upgrade-K2HVIVMQ.js} +21 -20
  121. package/dist/{usage-6KKXR32N.js → usage-GTZELZQX.js} +159 -59
  122. package/dist/verifiers-RLAHT27O.js +336 -0
  123. package/dist/{verify-X5HDROLA.js → verify-BX3BRKH5.js} +7 -6
  124. package/dist/{wiki-generate-7STOCIFZ.js → wiki-generate-ASIFASCN.js} +58 -48
  125. package/dist/worker/entry.js +98 -84
  126. package/dist/{workspace-G4ZWUIPR.js → workspace-ZJ6BFM3Q.js} +4 -4
  127. package/docs/README.md +4 -3
  128. package/docs/acp.md +1 -1
  129. package/docs/alcf-provider.md +1 -1
  130. package/docs/architecture.md +2 -2
  131. package/docs/artifact-placement.md +1 -2
  132. package/docs/artifact-versions.md +10 -6
  133. package/docs/built-in-agents.md +26 -2
  134. package/docs/capacity-and-scheduling.md +1 -1
  135. package/docs/commands-and-modes.md +90 -8
  136. package/docs/configuration-and-targets.md +90 -2
  137. package/docs/context-engine.md +4 -2
  138. package/docs/context-working-set.md +4 -4
  139. package/docs/development-pipeline.md +1 -1
  140. package/docs/dispatch-architecture-rationale.md +1 -1
  141. package/docs/documentation-coverage.md +4 -4
  142. package/docs/documentation-guide.md +4 -4
  143. package/docs/eval-runner.md +1 -1
  144. package/docs/evals-internal.md +4 -45
  145. package/docs/evidence-and-memory.md +70 -10
  146. package/docs/evolution.md +1 -1
  147. package/docs/exit-codes-and-output.md +4 -1
  148. package/docs/extensions-and-sharing.md +6 -2
  149. package/docs/fleet-demo-runbook.md +2 -2
  150. package/docs/fleet-dispatch.md +224 -11
  151. package/docs/git-commit-provenance.md +2 -2
  152. package/docs/glossary.md +1 -1
  153. package/docs/installation-and-lifecycle.md +2 -2
  154. package/docs/middleware-and-components.md +20 -2
  155. package/docs/model-catalog.md +1 -1
  156. package/docs/observability.md +55 -8
  157. package/docs/proactive-memory.md +26 -16
  158. package/docs/prompt-envelope-and-tools.md +4 -2
  159. package/docs/provider-adapter-cookbook.md +1 -1
  160. package/docs/release-cut-checklist.md +83 -65
  161. package/docs/resource-library.md +59 -0
  162. package/docs/safety-model.md +29 -7
  163. package/docs/scientific-validation.md +3 -3
  164. package/docs/session-lifecycle.md +37 -1
  165. package/docs/skills-marketplace.md +16 -3
  166. package/docs/tool-usage.md +14 -7
  167. package/docs/trace-store.md +1 -1
  168. package/docs/troubleshooting.md +1 -1
  169. package/docs/tui-design.md +38 -4
  170. package/docs/worker-dispatch-mechanics.md +3 -3
  171. package/package.json +7 -4
  172. package/src/cli/agents.ts +2 -3
  173. package/src/cli/argv.ts +14 -1
  174. package/src/cli/fleet-commands.ts +37 -0
  175. package/src/cli/fleet-graph.ts +102 -0
  176. package/src/cli/fleet-new.ts +36 -0
  177. package/src/cli/fleet-preflight.ts +121 -0
  178. package/src/cli/fleet-validate.ts +30 -0
  179. package/src/cli/fleet.ts +188 -335
  180. package/src/cli/index.ts +4 -2
  181. package/src/cli/library.ts +190 -0
  182. package/src/cli/memory.ts +272 -10
  183. package/src/cli/modes/json-stream.ts +2 -2
  184. package/src/cli/modes/print.ts +12 -1
  185. package/src/cli/run.ts +22 -2
  186. package/src/cli/share.ts +13 -1
  187. package/src/cli/targets.ts +12 -3
  188. package/src/cli/usage.ts +160 -20
  189. package/src/core/bus-events.ts +7 -0
  190. package/src/core/commit-attribution.ts +4 -4
  191. package/src/core/config.ts +130 -0
  192. package/src/core/defaults.ts +81 -0
  193. package/src/core/response-model-id.ts +134 -0
  194. package/src/core/toml.ts +62 -0
  195. package/src/core/workspace-files.ts +0 -1
  196. package/src/domains/agents/builtins/architect.md +2 -1
  197. package/src/domains/agents/builtins/oracle.md +33 -0
  198. package/src/domains/agents/catalog.ts +18 -5
  199. package/src/domains/agents/fleet-contract.ts +278 -16
  200. package/src/domains/agents/index.ts +14 -0
  201. package/src/domains/agents/recipe.ts +54 -14
  202. package/src/domains/agents/result-contract.ts +242 -5
  203. package/src/domains/config/classify.ts +4 -0
  204. package/src/domains/context/bootstrap.ts +36 -27
  205. package/src/domains/context/project-metadata.ts +19 -63
  206. package/src/domains/context/prompt-context.ts +8 -0
  207. package/src/domains/context/working-set/policies/index.ts +3 -4
  208. package/src/domains/dispatch/active-route-planner.ts +14 -0
  209. package/src/domains/dispatch/backoff.ts +2 -1
  210. package/src/domains/dispatch/budget-envelope.ts +396 -0
  211. package/src/domains/dispatch/capability-match.ts +1 -0
  212. package/src/domains/dispatch/checkout-writer-lease.ts +175 -0
  213. package/src/domains/dispatch/contract.ts +36 -0
  214. package/src/domains/dispatch/delegation-plan.ts +167 -0
  215. package/src/domains/dispatch/execution-plan.ts +76 -5
  216. package/src/domains/dispatch/execution-role.ts +3 -1
  217. package/src/domains/dispatch/execution-scheduler.ts +183 -67
  218. package/src/domains/dispatch/extension.ts +339 -36
  219. package/src/domains/dispatch/fleet-gate.ts +14 -0
  220. package/src/domains/dispatch/fleet-plan.ts +63 -3
  221. package/src/domains/dispatch/fleet-run.ts +737 -0
  222. package/src/domains/dispatch/gate-role-prompts.ts +9 -0
  223. package/src/domains/dispatch/host-verification.ts +178 -0
  224. package/src/domains/dispatch/index.ts +38 -0
  225. package/src/domains/dispatch/intent.ts +159 -0
  226. package/src/domains/dispatch/orphan-recovery.ts +1 -0
  227. package/src/domains/dispatch/receipt-integrity.ts +12 -4
  228. package/src/domains/dispatch/state.ts +37 -3
  229. package/src/domains/dispatch/types.ts +61 -9
  230. package/src/domains/dispatch/validation.ts +80 -6
  231. package/src/domains/dispatch/worker-spawn.ts +14 -3
  232. package/src/domains/eval/metrics/evidence.ts +0 -116
  233. package/src/domains/eval/metrics/invariants.ts +1 -1
  234. package/src/domains/eval/runners/clio-run.ts +1 -10
  235. package/src/domains/eval/runners/external-command.ts +2 -29
  236. package/src/domains/eval/schema/suite.ts +0 -7
  237. package/src/domains/eval/suites/run.ts +1 -7
  238. package/src/domains/evidence/trust-status.ts +10 -1
  239. package/src/domains/memory/index.ts +22 -0
  240. package/src/domains/memory/operations.ts +58 -1
  241. package/src/domains/memory/promotion.ts +281 -0
  242. package/src/domains/memory/prompt-section.ts +25 -5
  243. package/src/domains/memory/proposal.ts +51 -7
  244. package/src/domains/memory/task-bank.ts +3 -2
  245. package/src/domains/memory/task-memory-handoff.ts +181 -24
  246. package/src/domains/memory/task-memory-policy.ts +3 -1
  247. package/src/domains/memory/types.ts +37 -0
  248. package/src/domains/memory/validate.ts +178 -0
  249. package/src/domains/middleware/index.ts +15 -0
  250. package/src/domains/middleware/memory-intervention.ts +35 -25
  251. package/src/domains/middleware/runtime.ts +6 -0
  252. package/src/domains/middleware/skills-reminder.ts +19 -4
  253. package/src/domains/middleware/stalled-turn.ts +43 -1
  254. package/src/domains/middleware/types.ts +10 -0
  255. package/src/domains/middleware/watchdog.ts +281 -0
  256. package/src/domains/observability/contract.ts +9 -2
  257. package/src/domains/observability/cost.ts +31 -4
  258. package/src/domains/observability/extension.ts +2 -2
  259. package/src/domains/observability/index.ts +10 -0
  260. package/src/domains/observability/out-of-turn-usage.ts +223 -0
  261. package/src/domains/providers/index.ts +3 -0
  262. package/src/domains/providers/model-discovery.ts +9 -0
  263. package/src/domains/providers/runtime-resolution.ts +38 -1
  264. package/src/domains/providers/runtimes/common/probe-helpers.ts +97 -16
  265. package/src/domains/providers/types/context-window-slots.ts +18 -0
  266. package/src/domains/providers/types/runtime-descriptor.ts +3 -1
  267. package/src/domains/resources/index.ts +20 -0
  268. package/src/domains/resources/library.ts +326 -0
  269. package/src/domains/resources/skills/marketplace.ts +37 -12
  270. package/src/domains/safety/call-target.ts +211 -14
  271. package/src/domains/safety/decision-presentation.ts +268 -0
  272. package/src/domains/safety/redaction.ts +73 -0
  273. package/src/domains/session/context-ledger.ts +10 -1
  274. package/src/domains/session/decision-board.ts +4 -0
  275. package/src/domains/session/entries.ts +3 -0
  276. package/src/domains/session/handoff.ts +629 -0
  277. package/src/domains/session/history.ts +68 -19
  278. package/src/domains/session/usage.ts +24 -7
  279. package/src/domains/share/archive.ts +67 -2
  280. package/src/engine/acp/event-mapper.ts +7 -0
  281. package/src/engine/acp/server.ts +29 -2
  282. package/src/engine/apis/lmstudio.ts +25 -4
  283. package/src/engine/apis/openai-completions.ts +147 -22
  284. package/src/engine/claude/sdk-runtime.ts +8 -2
  285. package/src/engine/claude/tool-safety.ts +13 -0
  286. package/src/engine/loop-guard.ts +27 -3
  287. package/src/engine/worker-events.ts +4 -3
  288. package/src/engine/worker-runtime.ts +59 -54
  289. package/src/entry/orchestrator.ts +55 -1
  290. package/src/interactive/bus-notices.ts +26 -0
  291. package/src/interactive/chat-loop-messages.ts +22 -0
  292. package/src/interactive/chat-loop.ts +248 -1
  293. package/src/interactive/chat-renderer.ts +41 -3
  294. package/src/interactive/clio-editor.ts +44 -7
  295. package/src/interactive/context-overlay.ts +43 -5
  296. package/src/interactive/cost-overlay.ts +70 -11
  297. package/src/interactive/council-dispatch.ts +30 -0
  298. package/src/interactive/council-grid.ts +213 -0
  299. package/src/interactive/council.ts +99 -0
  300. package/src/interactive/dispatch-board.ts +471 -50
  301. package/src/interactive/fleet-run-preview.ts +307 -0
  302. package/src/interactive/footer/notifications.ts +219 -0
  303. package/src/interactive/footer/widgets.ts +13 -0
  304. package/src/interactive/handoff-round.ts +56 -0
  305. package/src/interactive/interactive-application.ts +49 -2
  306. package/src/interactive/interactive-event-projection.ts +9 -1
  307. package/src/interactive/interactive-input-runtime.ts +11 -1
  308. package/src/interactive/interactive-presentation.ts +11 -1
  309. package/src/interactive/interactive-slash-runtime.ts +52 -2
  310. package/src/interactive/interactive-subscriptions.ts +14 -2
  311. package/src/interactive/memory-overlay.ts +89 -4
  312. package/src/interactive/oracle.ts +179 -0
  313. package/src/interactive/overlay-ask-user-lifecycle.ts +7 -1
  314. package/src/interactive/overlay-frame.ts +5 -2
  315. package/src/interactive/overlay-general-openers.ts +230 -2
  316. package/src/interactive/overlay-key-routing.ts +58 -2
  317. package/src/interactive/overlay-lifecycle.ts +52 -5
  318. package/src/interactive/overlay-permission-lifecycle.ts +33 -8
  319. package/src/interactive/overlay-resource-openers.ts +11 -3
  320. package/src/interactive/overlay-session-lifecycle.ts +234 -2
  321. package/src/interactive/overlay-transitions.ts +11 -0
  322. package/src/interactive/overlays/ask-user.ts +74 -30
  323. package/src/interactive/overlays/decisions.ts +3 -1
  324. package/src/interactive/overlays/fleet-run-approval.ts +208 -0
  325. package/src/interactive/overlays/handoff-review.ts +185 -0
  326. package/src/interactive/overlays/library-install-confirm.ts +151 -0
  327. package/src/interactive/overlays/list-overlay.ts +168 -2
  328. package/src/interactive/overlays/settings.ts +101 -4
  329. package/src/interactive/overlays/side-question.ts +139 -0
  330. package/src/interactive/overlays/skills-hub.ts +401 -15
  331. package/src/interactive/permission-hint.ts +35 -0
  332. package/src/interactive/permission-overlay.ts +95 -45
  333. package/src/interactive/renderers/tool-execution.ts +19 -49
  334. package/src/interactive/session-last-turn.ts +8 -1
  335. package/src/interactive/session-usage-reseed.ts +36 -10
  336. package/src/interactive/side-question.ts +171 -0
  337. package/src/interactive/slash-commands.ts +434 -7
  338. package/src/interactive/slash-spec.ts +19 -6
  339. package/src/interactive/status/summary.ts +5 -0
  340. package/src/interactive/status/types.ts +5 -0
  341. package/src/interactive/terminal-lease.ts +1 -0
  342. package/src/interactive/theme/tokens.ts +30 -0
  343. package/src/interactive/turn-context.ts +96 -23
  344. package/src/interactive/turn-middleware.ts +16 -1
  345. package/src/interactive/turn-runtime.ts +37 -8
  346. package/src/interactive/turn-state.ts +3 -0
  347. package/src/interactive/watchdog-run.ts +75 -0
  348. package/src/interactive/worker-progress.ts +440 -0
  349. package/src/interactive/worker-share.ts +56 -1
  350. package/src/interactive/worker-stream.ts +58 -110
  351. package/src/tools/agent-tools.ts +28 -3
  352. package/src/tools/ask-user.ts +21 -1
  353. package/src/tools/bootstrap.ts +3 -0
  354. package/src/tools/compete-worktrees.ts +13 -79
  355. package/src/tools/context/index.ts +2 -2
  356. package/src/tools/dispatch-admission.ts +242 -8
  357. package/src/tools/dispatch-arguments.ts +65 -1
  358. package/src/tools/dispatch-event-text.ts +19 -0
  359. package/src/tools/dispatch-plan.ts +136 -6
  360. package/src/tools/dispatch-runner.ts +319 -13
  361. package/src/tools/dispatch-types.ts +20 -1
  362. package/src/tools/dispatch.ts +96 -3
  363. package/src/tools/monitor.ts +31 -0
  364. package/src/tools/profiles.ts +18 -4
  365. package/src/tools/registry.ts +15 -5
  366. package/src/tools/result-disposition.ts +156 -0
  367. package/src/tools/result-shaping.ts +59 -1
  368. package/src/tools/task-worktree.ts +238 -0
  369. package/src/tools/verify/authoring.ts +116 -55
  370. package/src/tools/verify/scripts.ts +62 -0
  371. package/src/tools/worker-evidence.ts +21 -1
  372. package/src/worker/spec-contract.ts +44 -3
  373. package/dist/chunk-EFADSJET.js +0 -18
  374. package/dist/chunk-HC4CLZ2Y.js +0 -68
  375. package/dist/memory-4ALKDJ4Q.js +0 -246
  376. package/src/domains/eval/metrics/chaos-stream.ts +0 -93
@@ -7,26 +7,31 @@ import {
7
7
  TASK_MEMORY_POLICY_DEFAULT_TIMEOUT_MS,
8
8
  runTaskMemoryPolicy,
9
9
  taskMemoryBankDelta
10
- } from "./chunk-2TZWSW76.js";
10
+ } from "./chunk-WHGPSPT5.js";
11
11
  import {
12
12
  isTerminalRunEnvelope
13
- } from "./chunk-ZYKPLLNQ.js";
13
+ } from "./chunk-CEYBNUGC.js";
14
14
  import {
15
15
  taskBoardCounts
16
- } from "./chunk-WPQLXFOZ.js";
16
+ } from "./chunk-5FR74PWO.js";
17
17
  import {
18
- SKILL_SUGGESTION_ANCHOR
19
- } from "./chunk-BEY543CS.js";
18
+ SKILL_SUGGESTION_ANCHOR,
19
+ SKILL_SUGGESTION_PREFIX
20
+ } from "./chunk-GOXNB3AO.js";
21
+ import {
22
+ legacyToolResultDigest,
23
+ sanitizeToolResultDigest
24
+ } from "./chunk-ODFEOB4F.js";
20
25
  import {
21
26
  ToolNames
22
27
  } from "./chunk-CGKSTWHD.js";
28
+ import {
29
+ ceilChars
30
+ } from "./chunk-GEYXPTRF.js";
23
31
  import {
24
32
  reportCommitAttributionDiagnostic,
25
33
  withManagedGitCommitAttributionEnvironment
26
- } from "./chunk-VEZEGCGW.js";
27
- import {
28
- ceilChars
29
- } from "./chunk-BPGS2WCQ.js";
34
+ } from "./chunk-D4MDIG46.js";
30
35
  import {
31
36
  require_dist
32
37
  } from "./chunk-APJ265NV.js";
@@ -63,6 +68,10 @@ function metadataNumber(input, key) {
63
68
  const value = input.metadata?.[key];
64
69
  return typeof value === "number" && Number.isFinite(value) ? value : null;
65
70
  }
71
+ function metadataString(input, key) {
72
+ const value = input.metadata?.[key];
73
+ return typeof value === "string" ? value : null;
74
+ }
66
75
  function isMiddlewareHook(value) {
67
76
  return MIDDLEWARE_HOOKS.includes(value);
68
77
  }
@@ -189,6 +198,7 @@ init_esm_shims();
189
198
  init_esm_shims();
190
199
  var STALLED_TURN_REGISTRATION_ID = "nudge.stalled-turn";
191
200
  var STALLED_TURN_REQUEST_CONTINUATION_MESSAGE = "You ended your turn after announcing an action without executing it: no tools were called. Continue now and perform the announced action, or state plainly that you are finished and waiting for the user.";
201
+ var SKILL_SUGGESTION_WAIT_CONTINUATION_MESSAGE = "You ended your turn on a skill suggestion without doing the task. The suggestion line has already made the offer and only the operator loads a skill, so nothing is needed from them before you proceed. Continue the task now without the skill.";
192
202
  var INTENT_PATTERN = /\b(let me|i['’]ll|i will|i am going to|i['’]m going to|now i|next i|let's|let us)\b/i;
193
203
  var CONCRETE_ACTION_STEMS = [
194
204
  "add",
@@ -288,6 +298,24 @@ var STALLED_TURN_RULE_DEFINITION = {
288
298
  effects: [{ kind: "request_continuation", message: STALLED_TURN_REQUEST_CONTINUATION_MESSAGE }],
289
299
  predicate: shouldRequestStalledTurnContinuation
290
300
  };
301
+ var SKILL_WAIT_PATTERN = /\/skill\b|\bskills?\b|\bskip\b/i;
302
+ function isSkillSuggestionWait(input) {
303
+ if (input.hook !== "turn_end") return false;
304
+ if (!isNormalStopReason(input.metadata?.stopReason)) return false;
305
+ const text = input.text ?? "";
306
+ if (!text.includes(SKILL_SUGGESTION_PREFIX)) return false;
307
+ const toolNames = metadataString(input, "turnToolNames");
308
+ if (toolNames === null) {
309
+ if ((metadataNumber(input, "turnToolCalls") ?? 0) !== 0) return false;
310
+ } else if (toolNames.split(",").filter((name) => name.length > 0).some((name) => name !== ToolNames.Context)) {
311
+ return false;
312
+ }
313
+ const lastLine = lastNonEmptyLine(text);
314
+ if (lastLine === null) return false;
315
+ const finalSentence = lastSentence(lastLine);
316
+ if (finalSentence.length === 0) return false;
317
+ return SKILL_WAIT_PATTERN.test(finalSentence) || isQuestion(finalSentence) || LET_ME_KNOW_PATTERN.test(finalSentence);
318
+ }
291
319
  function shouldRequestStalledTurnContinuation(input) {
292
320
  if (input.hook !== "turn_end") return false;
293
321
  if (input.metadata?.turnToolCalls !== 0) return false;
@@ -551,6 +579,12 @@ function cloneHookInput(input) {
551
579
  if (input.metadata !== void 0) cloned.metadata = { ...input.metadata };
552
580
  if (input.toolArgs !== void 0) cloned.toolArgs = { ...input.toolArgs };
553
581
  if (input.toolResultDetails !== void 0) cloned.toolResultDetails = { ...input.toolResultDetails };
582
+ if (input.toolResultDigest !== void 0) {
583
+ cloned.toolResultDigest = {
584
+ text: input.toolResultDigest.text,
585
+ provenance: { ...input.toolResultDigest.provenance }
586
+ };
587
+ }
554
588
  if (input.text !== void 0) cloned.text = input.text.slice(0, MIDDLEWARE_HOOK_TEXT_MAX_CHARS);
555
589
  return cloned;
556
590
  }
@@ -1351,7 +1385,6 @@ var MEMORY_INTERVENTION_DEFAULT_WINDOW_STEPS = 8;
1351
1385
  var MEMORY_INTERVENTION_DEFAULT_MAX_TOKENS = 400;
1352
1386
  var MEMORY_INTERVENTION_DEFAULT_EVERY_N_TOOLS = 10;
1353
1387
  var MEMORY_INTERVENTION_ACTIVITY_LIMIT = 20;
1354
- var RESULT_DIGEST_MAX_CHARS = 240;
1355
1388
  var CALL_DESCRIPTION_MAX_CHARS = 180;
1356
1389
  var NO_EFFECTS = [];
1357
1390
  function createMemoryInterventionRegistration(deps) {
@@ -1361,7 +1394,7 @@ function createMemoryInterventionRegistration(deps) {
1361
1394
  let toolStep = 0;
1362
1395
  let lastTurnEndStep = 0;
1363
1396
  let reactivateAfterCompaction = false;
1364
- let lastInjectedFingerprint = null;
1397
+ let lastInjectedOperationFingerprint = null;
1365
1398
  let currentTask = "(current task unavailable)";
1366
1399
  let toolsSinceMemoryStep = 0;
1367
1400
  let consecutiveErrors = 0;
@@ -1630,12 +1663,12 @@ function createMemoryInterventionRegistration(deps) {
1630
1663
  function observeBeforeTool(input) {
1631
1664
  const prepared = prepareToolStep(input);
1632
1665
  if (prepared === null) return;
1633
- setBounded(pending, pendingKey(input, prepared.fingerprint), prepared, settings().windowSteps);
1666
+ setBounded(pending, pendingKey(input, prepared.operationFingerprint), prepared, settings().windowSteps);
1634
1667
  }
1635
1668
  function observeAfterTool(input) {
1636
1669
  const fallback = prepareToolStep(input);
1637
1670
  if (fallback === null) return NO_EFFECTS;
1638
- const key = pendingKey(input, fallback.fingerprint);
1671
+ const key = pendingKey(input, fallback.operationFingerprint);
1639
1672
  const prepared = pending.get(key) ?? fallback;
1640
1673
  pending.delete(key);
1641
1674
  const outcome = input.metadata?.resultKind === "error" ? "error" : "ok";
@@ -1649,11 +1682,13 @@ function createMemoryInterventionRegistration(deps) {
1649
1682
  } else {
1650
1683
  consecutiveErrors = 0;
1651
1684
  }
1685
+ const digest = resultDigest(input, outcome);
1652
1686
  const step = {
1653
1687
  ...prepared,
1654
1688
  step: toolStep,
1655
1689
  outcome,
1656
- resultDigest: resultDigest(input, outcome)
1690
+ resultDigest: digest.text,
1691
+ resultDigestProvenance: digest.provenance
1657
1692
  };
1658
1693
  trajectory.push(step);
1659
1694
  if (trajectory.length > live.windowSteps) trajectory.splice(0, trajectory.length - live.windowSteps);
@@ -1662,19 +1697,19 @@ function createMemoryInterventionRegistration(deps) {
1662
1697
  return annotateRepeatedFailure(step);
1663
1698
  }
1664
1699
  function annotateRepeatedFailure(step) {
1665
- if (annotatedThisTurn.has(step.fingerprint)) return NO_EFFECTS;
1700
+ if (annotatedThisTurn.has(step.operationFingerprint)) return NO_EFFECTS;
1666
1701
  const occurrences = trajectory.filter(
1667
- (candidate) => candidate.outcome === "error" && candidate.fingerprint === step.fingerprint
1702
+ (candidate) => candidate.outcome === "error" && candidate.operationFingerprint === step.operationFingerprint
1668
1703
  ).length;
1669
- const failure = failures.get(step.fingerprint);
1704
+ const failure = failures.get(step.operationFingerprint);
1670
1705
  if (occurrences < 2 || failure === void 0) return NO_EFFECTS;
1671
1706
  const message = boundedReminder(
1672
1707
  `Memory: [${failure.entryId}] you already tried ${failure.callDescription} at step ${failure.firstStep} and it failed with ${failure.errorDigest}. Change the approach rather than repeating it.`,
1673
1708
  settings().maxTokens
1674
1709
  );
1675
1710
  if (message.length === 0) return NO_EFFECTS;
1676
- annotatedThisTurn.add(step.fingerprint);
1677
- lastInjectedFingerprint = step.fingerprint;
1711
+ annotatedThisTurn.add(step.operationFingerprint);
1712
+ lastInjectedOperationFingerprint = step.operationFingerprint;
1678
1713
  lastDecision = "injected";
1679
1714
  rulesInjectedSincePromptedStep = true;
1680
1715
  annotatedSinceTurnEnd = true;
@@ -1683,7 +1718,7 @@ function createMemoryInterventionRegistration(deps) {
1683
1718
  return [{ kind: "annotate_tool_result", message, severity: "warn" }];
1684
1719
  }
1685
1720
  function rememberFailure(step) {
1686
- const previous = failures.get(step.fingerprint);
1721
+ const previous = failures.get(step.operationFingerprint);
1687
1722
  const attempts = (previous?.attempts ?? 0) + 1;
1688
1723
  const firstStep = previous?.firstStep ?? step.step;
1689
1724
  const content = proceduralContent(step.callDescription, attempts, firstStep, step.resultDigest);
@@ -1699,7 +1734,7 @@ function createMemoryInterventionRegistration(deps) {
1699
1734
  }
1700
1735
  setBounded(
1701
1736
  failures,
1702
- step.fingerprint,
1737
+ step.operationFingerprint,
1703
1738
  {
1704
1739
  entryId,
1705
1740
  attempts,
@@ -1714,20 +1749,20 @@ function createMemoryInterventionRegistration(deps) {
1714
1749
  try {
1715
1750
  for (let index = trajectory.length - 1; index >= 0; index -= 1) {
1716
1751
  const step = trajectory[index];
1717
- if (step === void 0 || step.outcome !== "error" || step.step <= lastTurnEndStep || step.fingerprint === lastInjectedFingerprint) {
1752
+ if (step === void 0 || step.outcome !== "error" || step.step <= lastTurnEndStep || step.operationFingerprint === lastInjectedOperationFingerprint) {
1718
1753
  continue;
1719
1754
  }
1720
1755
  const occurrences = trajectory.filter(
1721
- (candidate) => candidate.outcome === "error" && candidate.fingerprint === step.fingerprint
1756
+ (candidate) => candidate.outcome === "error" && candidate.operationFingerprint === step.operationFingerprint
1722
1757
  ).length;
1723
- const failure = failures.get(step.fingerprint);
1758
+ const failure = failures.get(step.operationFingerprint);
1724
1759
  if (occurrences < 2 || failure === void 0) continue;
1725
1760
  const message = boundedReminder(
1726
1761
  `Memory: [${failure.entryId}] you already tried ${failure.callDescription} at step ${failure.firstStep} and it failed with ${failure.errorDigest}.`,
1727
1762
  settings().maxTokens
1728
1763
  );
1729
1764
  if (message.length === 0) return NO_EFFECTS;
1730
- lastInjectedFingerprint = step.fingerprint;
1765
+ lastInjectedOperationFingerprint = step.operationFingerprint;
1731
1766
  lastInjectedMessage = message;
1732
1767
  lastDecision = "injected";
1733
1768
  rulesInjectedSincePromptedStep = true;
@@ -1769,29 +1804,33 @@ function prepareToolStep(input) {
1769
1804
  const canonical = hashToolCall(toolName, input.toolArgs ?? {});
1770
1805
  return {
1771
1806
  toolName,
1772
- fingerprint: createHash2("sha256").update(canonical).digest("hex").slice(0, 16),
1807
+ operationFingerprint: createHash2("sha256").update(canonical).digest("hex").slice(0, 16),
1773
1808
  callDescription: shortText(canonical, CALL_DESCRIPTION_MAX_CHARS)
1774
1809
  };
1775
1810
  }
1776
- function pendingKey(input, fingerprint) {
1777
- return input.toolCallId ?? `anonymous:${fingerprint}`;
1811
+ function pendingKey(input, operationFingerprint) {
1812
+ return input.toolCallId ?? `anonymous:${operationFingerprint}`;
1778
1813
  }
1779
1814
  function resultDigest(input, outcome) {
1815
+ if (input.toolResultDigest !== void 0) return sanitizeToolResultDigest(input.toolResultDigest);
1780
1816
  if (outcome === "error") {
1781
1817
  const metadataMessage = input.metadata?.errorMessage;
1782
1818
  if (typeof metadataMessage === "string" && metadataMessage.trim().length > 0) {
1783
- return shortText(diagnosticLine(metadataMessage), RESULT_DIGEST_MAX_CHARS);
1819
+ return legacyToolResultDigest(diagnosticLine(metadataMessage), { outcome });
1784
1820
  }
1785
1821
  for (const key of ["error", "message"]) {
1786
1822
  const value = input.toolResultDetails?.[key];
1787
1823
  if (typeof value === "string" && value.trim().length > 0) {
1788
- return shortText(diagnosticLine(value), RESULT_DIGEST_MAX_CHARS);
1824
+ return legacyToolResultDigest(diagnosticLine(value), { outcome });
1789
1825
  }
1790
1826
  }
1791
- return "an unknown tool error";
1827
+ return legacyToolResultDigest("", { outcome });
1792
1828
  }
1793
1829
  const resultFingerprint = input.metadata?.resultFingerprint;
1794
- return typeof resultFingerprint === "string" ? `ok result ${resultFingerprint.slice(0, 16)}` : "ok";
1830
+ return legacyToolResultDigest(
1831
+ typeof resultFingerprint === "string" ? `ok result ${resultFingerprint.slice(0, 16)}` : "ok",
1832
+ { outcome }
1833
+ );
1795
1834
  }
1796
1835
  var DIAGNOSTIC_HINT = /\b(error|failed|failure|cannot|unable|expected|refused|denied|missing|not found|timed out|timeout|fatal)\b/iu;
1797
1836
  function diagnosticLine(value) {
@@ -1833,7 +1872,7 @@ init_esm_shims();
1833
1872
  var SKILLS_REMINDER_REGISTRATION_ID = "observer.skills-reminder";
1834
1873
  function skillsReminderMessage(installed, installable = 0) {
1835
1874
  const counts = installable > 0 ? `${installed} installed, ${installable} installable from the marketplace` : `${installed} installed`;
1836
- return `[Skills] ${counts}. Start this task by listing them with context(scope="skills") and checking for a match; if one matches, open your reply with the line \`${SKILL_SUGGESTION_ANCHOR}\` (a comma-separated sequence, in order, when several compose) and wait for the operator; load only on operator request, and a marketplace skill is offered for install when the operator runs it. If none match, do not mention skills and continue with the task.`;
1875
+ return `[Skills] ${counts}. Start this task by listing them with context(scope="skills") and checking for a match; if one matches, open your reply with the line \`${SKILL_SUGGESTION_ANCHOR}\` (a comma-separated sequence, in order, when several compose) and then continue the task in the same turn without the skill. Only the operator loads a skill, and a marketplace skill is offered for install when the operator runs it. If none match, do not mention skills and continue with the task.`;
1837
1876
  }
1838
1877
  var NO_EFFECTS2 = [];
1839
1878
  var GREETING_WORDS = /* @__PURE__ */ new Set([
@@ -1887,9 +1926,12 @@ function createSkillsReminderRegistration(deps) {
1887
1926
  let observedAnyTurn = false;
1888
1927
  return {
1889
1928
  id: SKILLS_REMINDER_REGISTRATION_ID,
1890
- description: "once per session, on the first substantive turn, teaches the skill-suggestion reply protocol",
1891
- hooks: ["turn_start"],
1929
+ description: "once per session, on the first substantive turn, teaches the skill-suggestion reply protocol; keeps a turn going that stopped on the suggestion",
1930
+ hooks: ["turn_start", "turn_end"],
1892
1931
  evaluate(input) {
1932
+ if (input.hook === "turn_end") {
1933
+ return isSkillSuggestionWait(input) ? [{ kind: "request_continuation", message: SKILL_SUGGESTION_WAIT_CONTINUATION_MESSAGE }] : NO_EFFECTS2;
1934
+ }
1893
1935
  const sessionId = input.sessionId ?? null;
1894
1936
  if (lastSeenSessionId === void 0) {
1895
1937
  lastSeenSessionId = sessionId;
@@ -2055,6 +2097,153 @@ function createMiddlewareToolChoiceControl() {
2055
2097
  };
2056
2098
  }
2057
2099
 
2100
+ // src/domains/middleware/watchdog.ts
2101
+ init_esm_shims();
2102
+ var WATCHDOG_REGISTRATION_ID = "observer.watchdog";
2103
+ var WATCHDOG_DIFF_MAX_BYTES = 12 * 1024;
2104
+ var WATCHDOG_PATHS_MAX = 40;
2105
+ var WATCHDOG_TRUNCATION_MARKER = "\n[diff truncated]";
2106
+ var MUTATING_TOOL_NAMES = /* @__PURE__ */ new Set([ToolNames.Write, ToolNames.Edit, ToolNames.Artifact]);
2107
+ var NO_EFFECTS4 = [];
2108
+ function stringValue2(value) {
2109
+ return typeof value === "string" && value.length > 0 ? value : null;
2110
+ }
2111
+ function firstPath(details) {
2112
+ const paths = details?.paths;
2113
+ if (!Array.isArray(paths)) return null;
2114
+ for (const entry of paths) {
2115
+ const path = stringValue2(entry);
2116
+ if (path !== null) return path;
2117
+ }
2118
+ return null;
2119
+ }
2120
+ function coalesceTurnDiff(byPath, maxBytes = WATCHDOG_DIFF_MAX_BYTES) {
2121
+ const blocks = [];
2122
+ let index = 0;
2123
+ for (const [path, diff] of byPath) {
2124
+ if (index >= WATCHDOG_PATHS_MAX) {
2125
+ blocks.push(`[${byPath.size - WATCHDOG_PATHS_MAX} more changed path(s) omitted]`);
2126
+ break;
2127
+ }
2128
+ blocks.push(`--- ${path}
2129
+ ${diff}`);
2130
+ index += 1;
2131
+ }
2132
+ const whole = blocks.join("\n\n");
2133
+ if (Buffer.byteLength(whole, "utf8") <= maxBytes) return whole;
2134
+ const room = Math.max(0, maxBytes - Buffer.byteLength(WATCHDOG_TRUNCATION_MARKER, "utf8"));
2135
+ const buffer = Buffer.from(whole, "utf8");
2136
+ let cut = Math.min(room, buffer.byteLength);
2137
+ while (cut > 0) {
2138
+ const next = buffer[cut];
2139
+ if (next === void 0 || (next & 192) !== 128) break;
2140
+ cut -= 1;
2141
+ }
2142
+ return `${buffer.subarray(0, cut).toString("utf8")}${WATCHDOG_TRUNCATION_MARKER}`;
2143
+ }
2144
+ var WATCHDOG_TASK = "Review the coalesced diff in the briefing against the scope it names. Report one check per concern: a change outside the stated scope, a change the scope required that the diff does not make, or a defect visible in the diff itself. Run no commands and change nothing.";
2145
+ function watchdogBriefing(trigger) {
2146
+ const scope = trigger.scope === null ? "(no task board; scope is unstated)" : trigger.scope;
2147
+ const paths = trigger.paths.length === 0 ? "(none)" : trigger.paths.join("\n");
2148
+ return [
2149
+ "## Current scope",
2150
+ scope,
2151
+ "",
2152
+ "## Changed paths",
2153
+ paths,
2154
+ "",
2155
+ "## Coalesced diff for this turn",
2156
+ trigger.diff
2157
+ ].join("\n");
2158
+ }
2159
+ function createWatchdogRegistration(deps) {
2160
+ const diffByPath = /* @__PURE__ */ new Map();
2161
+ let toolCalls = 0;
2162
+ let dropped = 0;
2163
+ let inFlight = false;
2164
+ let outstanding = Promise.resolve();
2165
+ const active = () => {
2166
+ if (deps.firesOnThisSurface === false) return null;
2167
+ let settings;
2168
+ try {
2169
+ settings = deps.getSettings();
2170
+ } catch {
2171
+ return null;
2172
+ }
2173
+ return settings.enabled ? settings : null;
2174
+ };
2175
+ const resetTurn = () => {
2176
+ diffByPath.clear();
2177
+ toolCalls = 0;
2178
+ };
2179
+ const fire = (reason) => {
2180
+ if (diffByPath.size === 0) return;
2181
+ if (inFlight) {
2182
+ dropped += 1;
2183
+ return;
2184
+ }
2185
+ const trigger = {
2186
+ reason,
2187
+ diff: coalesceTurnDiff(diffByPath),
2188
+ paths: [...diffByPath.keys()].slice(0, WATCHDOG_PATHS_MAX),
2189
+ scope: scopeNow(),
2190
+ toolCalls
2191
+ };
2192
+ inFlight = true;
2193
+ let started;
2194
+ try {
2195
+ started = deps.run(trigger);
2196
+ } catch {
2197
+ inFlight = false;
2198
+ return;
2199
+ }
2200
+ outstanding = started.catch(() => {
2201
+ }).finally(() => {
2202
+ inFlight = false;
2203
+ });
2204
+ };
2205
+ const scopeNow = () => {
2206
+ try {
2207
+ return deps.getScope?.() ?? null;
2208
+ } catch {
2209
+ return null;
2210
+ }
2211
+ };
2212
+ return {
2213
+ id: WATCHDOG_REGISTRATION_ID,
2214
+ description: "review a mutating turn's coalesced diff against the board scope with a read-only verifier run",
2215
+ hooks: ["after_tool", "turn_end"],
2216
+ evaluate(input) {
2217
+ const settings = active();
2218
+ if (settings === null) {
2219
+ if (input.hook === "turn_end") resetTurn();
2220
+ return NO_EFFECTS4;
2221
+ }
2222
+ if (input.hook === "after_tool") {
2223
+ toolCalls += 1;
2224
+ recordMutation(input);
2225
+ const cadence = settings.cadenceToolCalls;
2226
+ if (cadence !== void 0 && cadence >= 1 && toolCalls % cadence === 0) fire("cadence");
2227
+ return NO_EFFECTS4;
2228
+ }
2229
+ if (input.hook !== "turn_end") return NO_EFFECTS4;
2230
+ fire("turn_end");
2231
+ resetTurn();
2232
+ return NO_EFFECTS4;
2233
+ },
2234
+ droppedTriggers: () => dropped,
2235
+ runInFlight: () => inFlight,
2236
+ whenIdle: () => outstanding
2237
+ };
2238
+ function recordMutation(input) {
2239
+ if (input.metadata?.resultKind !== "ok") return;
2240
+ if (input.toolName === void 0 || !MUTATING_TOOL_NAMES.has(input.toolName)) return;
2241
+ const diff = stringValue2(input.toolResultDetails?.diff);
2242
+ if (diff === null) return;
2243
+ diffByPath.set(firstPath(input.toolResultDetails) ?? input.toolName, diff);
2244
+ }
2245
+ }
2246
+
2058
2247
  // src/domains/middleware/index.ts
2059
2248
  init_esm_shims();
2060
2249
 
@@ -2210,6 +2399,9 @@ export {
2210
2399
  createTaskBoardReminderRegistration,
2211
2400
  createTaskNudgeRegistration,
2212
2401
  createMiddlewareToolChoiceControl,
2402
+ WATCHDOG_TASK,
2403
+ watchdogBriefing,
2404
+ createWatchdogRegistration,
2213
2405
  MiddlewareDomainModule
2214
2406
  };
2215
- //# sourceMappingURL=chunk-2LZI5CAG.js.map
2407
+ //# sourceMappingURL=chunk-XEGB6BCN.js.map
@@ -5,7 +5,7 @@ import {
5
5
  settingsPath,
6
6
  updateSavedSettingsDocument,
7
7
  validateSettings
8
- } from "./chunk-AD2SYQYC.js";
8
+ } from "./chunk-UHXRNZ2J.js";
9
9
  import {
10
10
  require_dist
11
11
  } from "./chunk-APJ265NV.js";
@@ -226,4 +226,4 @@ export {
226
226
  updateLayeredSettings,
227
227
  settingsSourceFor
228
228
  };
229
- //# sourceMappingURL=chunk-E25LMLRW.js.map
229
+ //# sourceMappingURL=chunk-YD734TPH.js.map