@iowarp/clio-coder 0.3.8 → 0.3.9

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 (333) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +7 -3
  3. package/dist/{acp-U67UHUK2.js → acp-7LOELQFP.js} +6 -6
  4. package/dist/{agents-YU6SGALZ.js → agents-FIBG2SHA.js} +27 -25
  5. package/dist/assets/codewiki.json +1 -1
  6. package/dist/{auth-5ZPJOIVG.js → auth-OI4LIH2I.js} +11 -12
  7. package/dist/{builtins-C6JMZVV6.js → builtins-AD25UL3C.js} +5 -5
  8. package/dist/{chunk-5FR74PWO.js → chunk-2JDWVJND.js} +2 -2
  9. package/dist/chunk-3DPEIQKN.js +113 -0
  10. package/dist/{chunk-4SPRNWDE.js → chunk-3DUR4WUA.js} +15 -15
  11. package/dist/{chunk-VHN4MY6O.js → chunk-3MRC2YSQ.js} +2 -2
  12. package/dist/{chunk-5DHKRSMQ.js → chunk-3UUY7R3Z.js} +11 -7
  13. package/dist/{chunk-IGWKHNIQ.js → chunk-3V5AYSEQ.js} +8 -8
  14. package/dist/{chunk-FHJEP5SW.js → chunk-465CC7FK.js} +8 -5
  15. package/dist/{chunk-5WIGXA4T.js → chunk-47CMYGET.js} +111 -4
  16. package/dist/{chunk-A3WNZD3P.js → chunk-4H6ULJ3H.js} +67 -21
  17. package/dist/{chunk-TB5666IT.js → chunk-4LJX2PUC.js} +3 -3
  18. package/dist/{chunk-XWSF374K.js → chunk-56KB5IJP.js} +2 -2
  19. package/dist/{chunk-SPULKLCF.js → chunk-5DQRIYDZ.js} +2 -2
  20. package/dist/{chunk-2HEJ2F35.js → chunk-5HFBWUMU.js} +20 -8
  21. package/dist/{chunk-WNIJTQQK.js → chunk-5PVQ4SRS.js} +78 -6
  22. package/dist/{chunk-DYIM5TJT.js → chunk-5QKCQQ3E.js} +262 -6
  23. package/dist/{chunk-TYPGUK6W.js → chunk-5T7RBWN2.js} +111 -5
  24. package/dist/{chunk-IIZWH4XA.js → chunk-774ILSRL.js} +2 -2
  25. package/dist/chunk-7C6RYZGQ.js +391 -0
  26. package/dist/{chunk-TANS5ZJS.js → chunk-AD7Y7STJ.js} +3 -3
  27. package/dist/{chunk-RWSI4YD7.js → chunk-AEYBF3TB.js} +33 -12
  28. package/dist/{chunk-DGSYXYMX.js → chunk-AMKHQW3C.js} +2 -2
  29. package/dist/{chunk-VWZOAB7K.js → chunk-B5XRQOLB.js} +7 -7
  30. package/dist/{chunk-WXY7KU3G.js → chunk-BVDVID7E.js} +2 -2
  31. package/dist/{chunk-PMDBGQSJ.js → chunk-CA42X6KT.js} +2 -2
  32. package/dist/{chunk-HLE42MG7.js → chunk-D73KXYPF.js} +3 -3
  33. package/dist/{chunk-5Q2VVUKB.js → chunk-DG4M6ZUE.js} +3 -3
  34. package/dist/{chunk-ME6CCNFO.js → chunk-EBOC7MT3.js} +6 -6
  35. package/dist/{chunk-MXKJU4JB.js → chunk-ECUO3KDP.js} +48 -7
  36. package/dist/{chunk-26LEYJZH.js → chunk-FALJGAWU.js} +2 -2
  37. package/dist/{chunk-GWS3VEIW.js → chunk-FWDFM5ZU.js} +24 -3
  38. package/dist/{chunk-7RGZWPB6.js → chunk-GAYUJ7LE.js} +67 -13
  39. package/dist/{chunk-VCBR6CU7.js → chunk-HAY4ZE2P.js} +2 -2
  40. package/dist/{chunk-FBVTI2TJ.js → chunk-HCBCAYZU.js} +11 -130
  41. package/dist/{chunk-WSB3FPX7.js → chunk-HJB5IUKP.js} +32 -136
  42. package/dist/{chunk-J3YUBZWY.js → chunk-HKO36JWF.js} +33 -5
  43. package/dist/{chunk-E77JEWSD.js → chunk-HPCTNZM2.js} +6 -36
  44. package/dist/{chunk-FJ3H4MN5.js → chunk-IHKBWSXF.js} +2 -2
  45. package/dist/{chunk-NMPKI6XL.js → chunk-JEQQR47K.js} +37 -18
  46. package/dist/{chunk-3BINW3FP.js → chunk-KV2AOLDF.js} +24 -4
  47. package/dist/{chunk-YS5VLNH5.js → chunk-LXPJXFM5.js} +7 -7
  48. package/dist/{chunk-7RFXX52T.js → chunk-MIX5N5AC.js} +271 -41
  49. package/dist/{chunk-K4XHGFR5.js → chunk-MLOK6ZOS.js} +1297 -218
  50. package/dist/{chunk-ZNLWCMVZ.js → chunk-MV2VUEJC.js} +2 -2
  51. package/dist/{chunk-MVVUPGPW.js → chunk-MXHC5QYU.js} +6 -6
  52. package/dist/{chunk-5H3GB5BO.js → chunk-N3PBVRTZ.js} +4 -382
  53. package/dist/{chunk-2HFZQUHL.js → chunk-N5XKWMDW.js} +17 -7
  54. package/dist/{chunk-5C3AQNDW.js → chunk-NNNWO6F2.js} +124 -36
  55. package/dist/{chunk-GU2UIAFZ.js → chunk-NQ6UCCOD.js} +3 -3
  56. package/dist/{chunk-N22QMJKY.js → chunk-NZU6YDNV.js} +4 -4
  57. package/dist/{chunk-ZVJ5BLO2.js → chunk-O6I4CIEU.js} +151 -13
  58. package/dist/{chunk-XN3L4EYL.js → chunk-OEDBCISO.js} +2 -2
  59. package/dist/{chunk-VAWNZU7Z.js → chunk-P3JGPQFL.js} +2 -2
  60. package/dist/{chunk-IJ7RPIYJ.js → chunk-PNY46YEY.js} +20 -3
  61. package/dist/{chunk-U6MBIEMB.js → chunk-PZ4I4JE2.js} +56 -35
  62. package/dist/{chunk-GPIEI3LY.js → chunk-QQ7EKM72.js} +2 -2
  63. package/dist/{chunk-WLFILSD5.js → chunk-R7LNVMCS.js} +66 -28
  64. package/dist/{chunk-GOXNB3AO.js → chunk-RAPCMZL4.js} +75 -4
  65. package/dist/chunk-RKKLTLYB.js +45 -0
  66. package/dist/{chunk-TT36MB5S.js → chunk-RKRLDWD3.js} +3 -1
  67. package/dist/{chunk-TTHACPOM.js → chunk-S4COXYBG.js} +456 -18
  68. package/dist/{chunk-WWCZ5F23.js → chunk-T3Z6VAAF.js} +69 -10
  69. package/dist/{chunk-GN57SG4G.js → chunk-TD7UE2L5.js} +9 -7
  70. package/dist/{chunk-TLQJPP24.js → chunk-TEO2TLVN.js} +523 -322
  71. package/dist/{chunk-FCSXB6T2.js → chunk-UOSL25KY.js} +14 -2
  72. package/dist/{chunk-KTYTFRMB.js → chunk-VKBMFOYV.js} +17 -15
  73. package/dist/{chunk-PT7HYKEM.js → chunk-VO2LKSTM.js} +2 -2
  74. package/dist/{chunk-P43ETTHK.js → chunk-VPTUJU4P.js} +2 -2
  75. package/dist/{chunk-WEH5XRJQ.js → chunk-WIE7ZOSW.js} +2 -2
  76. package/dist/{chunk-EMYUUSFG.js → chunk-WXCJ7VME.js} +5 -5
  77. package/dist/{chunk-4DGYLA73.js → chunk-XDOQXGFO.js} +22 -7
  78. package/dist/{chunk-JOZYP4GM.js → chunk-YKOFT37S.js} +5 -5
  79. package/dist/chunk-YSEHGPCT.js +127 -0
  80. package/dist/{chunk-HFSBBKSQ.js → chunk-YW7UVM5V.js} +138 -3
  81. package/dist/cli/index.js +27 -27
  82. package/dist/{clio-QVTYJ57A.js → clio-LT5V7SSZ.js} +6 -6
  83. package/dist/{code-nav-FGGFIE7L.js → code-nav-LMW275PA.js} +4 -4
  84. package/dist/{config-LW5IJFQN.js → config-RXS5T3JT.js} +71 -43
  85. package/dist/{configure-7XIZCOU4.js → configure-2WYWSCSD.js} +14 -15
  86. package/dist/{context-Y6Y7QPR6.js → context-I3BTOTCS.js} +12 -12
  87. package/dist/{context-L3WL3X7K.js → context-MVOORGMF.js} +34 -33
  88. package/dist/{context-N52ZA626.js → context-PALKKQYL.js} +20 -20
  89. package/dist/{context-clear-MBQRLSDQ.js → context-clear-N2WOYZ2K.js} +34 -33
  90. package/dist/{context-index-HVMFQHK3.js → context-index-HNG3MOME.js} +2 -2
  91. package/dist/{context-working-set-GS6DSO7F.js → context-working-set-MIEVECVZ.js} +10 -11
  92. package/dist/{dispatch-runner-22ZCNOM3.js → dispatch-runner-VVA4SRRH.js} +34 -33
  93. package/dist/doctor-TWBWFK5V.js +165 -0
  94. package/dist/{eval-BEC2WHDA.js → eval-IJ5VEZDJ.js} +2016 -142
  95. package/dist/{evidence-REJUMSKM.js → evidence-L5APPXNV.js} +29 -28
  96. package/dist/{evolve-PY5ZBA5K.js → evolve-RGNKFJ52.js} +29 -28
  97. package/dist/{extensions-HVKU65YU.js → extensions-7WYWUX5A.js} +9 -3
  98. package/dist/{fleet-7WZEWRFA.js → fleet-6CNVBZZP.js} +87 -55
  99. package/dist/{fleet-commands-UVHWM76J.js → fleet-commands-L2SXSYEI.js} +6 -6
  100. package/dist/{fleet-graph-6ULH7PES.js → fleet-graph-2J3OOIPO.js} +14 -12
  101. package/dist/{fleet-preflight-J53T6CCE.js → fleet-preflight-CZRJ4JP5.js} +3 -4
  102. package/dist/{fleet-validate-72PC4SLA.js → fleet-validate-C5RI6DP7.js} +16 -15
  103. package/dist/{init-OG3TPGQG.js → init-VBN2ACVA.js} +50 -48
  104. package/dist/{library-CNTMPLRF.js → library-JHGUMLY2.js} +13 -11
  105. package/dist/{memory-6IS7F275.js → memory-K4OQIYWG.js} +31 -30
  106. package/dist/{models-ENRJDA5W.js → models-2NCZUWDD.js} +23 -22
  107. package/dist/{monitor-XLDVO7TN.js → monitor-MMVTJABD.js} +35 -34
  108. package/dist/{orchestrator-6KSPYRHA.js → orchestrator-ZKBPCHW6.js} +1627 -294
  109. package/dist/{reset-RZ4ER727.js → reset-DD5JGOY3.js} +3 -3
  110. package/dist/{run-Y2CNK5RU.js → run-QEGNX7FL.js} +56 -55
  111. package/dist/{share-A55GYP6Z.js → share-JKD3BQMW.js} +13 -11
  112. package/dist/{skills-ALC5J6AT.js → skills-LMQIKDOZ.js} +14 -12
  113. package/dist/{skills-eval-JPBEBYQU.js → skills-eval-I7X2774U.js} +34 -32
  114. package/dist/{steer-GGWFUJUD.js → steer-CF5TDANS.js} +3 -3
  115. package/dist/{support-MIETYA5E.js → support-I7LOJLIF.js} +4 -4
  116. package/dist/{targets-VGNXIR3S.js → targets-RUSR6B5Z.js} +58 -32
  117. package/dist/{terminal-lease-WOBR64YA.js → terminal-lease-QYVORFR4.js} +6 -4
  118. package/dist/{trace-PNCASAXC.js → trace-ODOQIVIW.js} +61 -6
  119. package/dist/{upgrade-FUSUAGHR.js → upgrade-XANW3FXB.js} +17 -16
  120. package/dist/{usage-N4MKVHKD.js → usage-4H7ZRXQT.js} +88 -44
  121. package/dist/{verifiers-YAWOJ3H2.js → verifiers-UZXNBZEB.js} +6 -6
  122. package/dist/{verify-LTDHYBGY.js → verify-BVKWTNDL.js} +5 -5
  123. package/dist/{wiki-generate-6M7GHTBJ.js → wiki-generate-MY7WV2QI.js} +49 -47
  124. package/dist/worker/entry.js +29 -33
  125. package/docs/alcf-provider.md +1 -1
  126. package/docs/architecture.md +1 -1
  127. package/docs/artifact-versions.md +6 -1
  128. package/docs/built-in-agents.md +1 -1
  129. package/docs/capacity-and-scheduling.md +23 -2
  130. package/docs/commands-and-modes.md +1 -1
  131. package/docs/configuration-and-targets.md +30 -3
  132. package/docs/context-engine.md +63 -4
  133. package/docs/documentation-coverage.md +3 -3
  134. package/docs/documentation-guide.md +1 -1
  135. package/docs/environment-variables.md +2 -0
  136. package/docs/eval-runner.md +262 -11
  137. package/docs/evals-internal.md +72 -2
  138. package/docs/evidence-and-memory.md +11 -10
  139. package/docs/evolution.md +1 -1
  140. package/docs/extensions-and-sharing.md +3 -1
  141. package/docs/fleet-dispatch.md +4 -4
  142. package/docs/installation-and-lifecycle.md +1 -1
  143. package/docs/middleware-and-components.md +1 -1
  144. package/docs/model-catalog.md +1 -1
  145. package/docs/observability.md +53 -2
  146. package/docs/proactive-memory.md +127 -14
  147. package/docs/prompt-envelope-and-tools.md +19 -1
  148. package/docs/provider-adapter-cookbook.md +1 -1
  149. package/docs/release-cut-checklist.md +19 -3
  150. package/docs/safety-model.md +1 -1
  151. package/docs/scientific-validation.md +1 -1
  152. package/docs/skills-marketplace.md +1 -1
  153. package/docs/tool-usage.md +1 -1
  154. package/docs/trace-store.md +1 -1
  155. package/docs/troubleshooting.md +87 -0
  156. package/docs/tui-design.md +1 -1
  157. package/docs/worker-dispatch-mechanics.md +1 -1
  158. package/package.json +2 -1
  159. package/src/cli/agents.ts +1 -1
  160. package/src/cli/config-inspect.ts +33 -6
  161. package/src/cli/config.ts +1 -1
  162. package/src/cli/doctor-state-size.ts +82 -0
  163. package/src/cli/doctor.ts +3 -1
  164. package/src/cli/eval.ts +80 -16
  165. package/src/cli/extensions.ts +5 -1
  166. package/src/cli/fleet.ts +32 -3
  167. package/src/cli/targets.ts +44 -13
  168. package/src/cli/trace.ts +63 -4
  169. package/src/cli/usage.ts +63 -14
  170. package/src/core/bus-events.ts +29 -1
  171. package/src/core/cache-telemetry.ts +42 -0
  172. package/src/core/config.ts +18 -0
  173. package/src/core/defaults.ts +36 -6
  174. package/src/core/endpoint-key.ts +27 -0
  175. package/src/core/residency-target-key.ts +25 -0
  176. package/src/core/response-schema.ts +36 -2
  177. package/src/domains/config/classify.ts +3 -0
  178. package/src/domains/context/codewiki/coordinator.ts +12 -4
  179. package/src/domains/dispatch/admission.ts +40 -3
  180. package/src/domains/dispatch/capacity-lease.ts +98 -9
  181. package/src/domains/dispatch/contract.ts +11 -0
  182. package/src/domains/dispatch/execution-plan.ts +44 -4
  183. package/src/domains/dispatch/extension.ts +166 -42
  184. package/src/domains/dispatch/fleet-run.ts +23 -3
  185. package/src/domains/dispatch/heartbeat.ts +32 -8
  186. package/src/domains/dispatch/index.ts +3 -0
  187. package/src/domains/dispatch/orphan-recovery.ts +5 -0
  188. package/src/domains/dispatch/reservation-store.ts +116 -8
  189. package/src/domains/dispatch/state.ts +4 -0
  190. package/src/domains/dispatch/worker-spawn.ts +25 -11
  191. package/src/domains/dispatch/write-boundary-enforcer.ts +20 -3
  192. package/src/domains/dispatch/write-boundary.ts +62 -1
  193. package/src/domains/eval/artifacts/store.ts +62 -0
  194. package/src/domains/eval/compare/behavioral.ts +224 -0
  195. package/src/domains/eval/compare/compare.ts +355 -2
  196. package/src/domains/eval/compare/envelope.ts +128 -0
  197. package/src/domains/eval/compare/gates.ts +24 -6
  198. package/src/domains/eval/compare/thresholds.ts +30 -3
  199. package/src/domains/eval/execution-provenance.ts +240 -0
  200. package/src/domains/eval/metrics/aggregate.ts +136 -0
  201. package/src/domains/eval/metrics/call-ledger-stream.ts +112 -0
  202. package/src/domains/eval/metrics/tracked.ts +413 -0
  203. package/src/domains/eval/provenance.ts +117 -0
  204. package/src/domains/eval/reports/comparison.ts +128 -0
  205. package/src/domains/eval/reports/junit.ts +17 -3
  206. package/src/domains/eval/reports/markdown.ts +3 -3
  207. package/src/domains/eval/reports/text.ts +14 -0
  208. package/src/domains/eval/run-compare.ts +20 -0
  209. package/src/domains/eval/runners/clio-run.ts +127 -0
  210. package/src/domains/eval/runners/external-command.ts +28 -3
  211. package/src/domains/eval/schema/adapter.ts +111 -0
  212. package/src/domains/eval/schema/artifact.ts +20 -0
  213. package/src/domains/eval/schema/behavioral-metrics.ts +204 -0
  214. package/src/domains/eval/schema/behavioral.ts +520 -0
  215. package/src/domains/eval/schema/execution-envelope.ts +194 -0
  216. package/src/domains/eval/schema/serving.ts +74 -0
  217. package/src/domains/eval/schema/suite.ts +38 -8
  218. package/src/domains/eval/schema/validate.ts +58 -3
  219. package/src/domains/eval/schema/verdict.ts +237 -0
  220. package/src/domains/eval/suites/resolve.ts +2 -0
  221. package/src/domains/eval/suites/run.ts +264 -33
  222. package/src/domains/eval/verifiers/command.ts +2 -1
  223. package/src/domains/eval/workspaces/temp-copy.ts +145 -13
  224. package/src/domains/evidence/build.ts +2 -13
  225. package/src/domains/evidence/eval.ts +2 -12
  226. package/src/domains/evidence/findings-markdown.ts +33 -0
  227. package/src/domains/evidence/run-trust.ts +7 -113
  228. package/src/domains/evidence/trust-projection.ts +2 -2
  229. package/src/domains/extensions/compatibility.ts +285 -0
  230. package/src/domains/extensions/discovery.ts +38 -3
  231. package/src/domains/extensions/resources.ts +1 -1
  232. package/src/domains/extensions/state.ts +12 -3
  233. package/src/domains/extensions/types.ts +2 -0
  234. package/src/domains/lifecycle/doctor.ts +69 -1
  235. package/src/domains/memory/index.ts +14 -0
  236. package/src/domains/memory/task-bank-promotion.ts +64 -0
  237. package/src/domains/memory/task-memory-policy.ts +77 -8
  238. package/src/domains/memory/task-memory-spend.ts +131 -0
  239. package/src/domains/memory/task-memory-status.ts +7 -0
  240. package/src/domains/memory/task-memory-telemetry.ts +2 -0
  241. package/src/domains/middleware/index.ts +1 -0
  242. package/src/domains/middleware/memory-intervention.ts +69 -5
  243. package/src/domains/middleware/memory-step-endpoint.ts +71 -0
  244. package/src/domains/observability/background-memory-usage.ts +140 -0
  245. package/src/domains/observability/cost.ts +1 -1
  246. package/src/domains/observability/index.ts +7 -0
  247. package/src/domains/observability/out-of-turn-usage.ts +51 -2
  248. package/src/domains/observability/trace-store.ts +192 -2
  249. package/src/domains/prompts/compiler.ts +100 -13
  250. package/src/domains/providers/endpoint-capacity.ts +96 -0
  251. package/src/domains/providers/index.ts +10 -0
  252. package/src/domains/providers/models/local-models/clio-local-coding-targets.yaml +243 -1
  253. package/src/domains/providers/runtime-resolution.ts +8 -1
  254. package/src/domains/providers/runtimes/common/probe-helpers.ts +31 -9
  255. package/src/domains/providers/runtimes/local-native/llamacpp-anthropic.ts +1 -1
  256. package/src/domains/providers/runtimes/local-native/llamacpp-completion.ts +1 -1
  257. package/src/domains/providers/runtimes/local-native/llamacpp-embed.ts +1 -1
  258. package/src/domains/providers/runtimes/local-native/llamacpp-rerank.ts +1 -1
  259. package/src/domains/providers/runtimes/local-native/llamacpp.ts +4 -1
  260. package/src/domains/providers/runtimes/local-native/lmstudio.ts +4 -1
  261. package/src/domains/providers/runtimes/local-native/ollama-native.ts +6 -1
  262. package/src/domains/providers/types/capability-flags.ts +2 -0
  263. package/src/domains/providers/types/target-descriptor.ts +2 -0
  264. package/src/domains/resources/prompts/loader.ts +95 -33
  265. package/src/domains/safety/call-target.ts +52 -0
  266. package/src/domains/safety/run-effects.ts +35 -4
  267. package/src/domains/session/context-accounting.ts +52 -1
  268. package/src/domains/session/context-ledger.ts +37 -13
  269. package/src/domains/session/index.ts +6 -0
  270. package/src/domains/session/prompt-cache.ts +140 -0
  271. package/src/domains/session/prompt-manifest.ts +42 -0
  272. package/src/engine/acp/adapter.ts +18 -3
  273. package/src/engine/ai.ts +35 -0
  274. package/src/engine/apis/llamacpp-residency.ts +55 -3
  275. package/src/engine/apis/lmstudio.ts +25 -5
  276. package/src/engine/apis/ollama-native.ts +2 -1
  277. package/src/engine/apis/openai-completions.ts +80 -17
  278. package/src/engine/apis/residency-lock.ts +3 -1
  279. package/src/engine/apis/residency.ts +34 -1
  280. package/src/engine/provider-payload.ts +29 -1
  281. package/src/entry/orchestrator.ts +176 -30
  282. package/src/interactive/chat-loop-messages.ts +26 -7
  283. package/src/interactive/chat-loop.ts +318 -41
  284. package/src/interactive/chat-panel.ts +62 -8
  285. package/src/interactive/clio-editor.ts +45 -8
  286. package/src/interactive/context-activity.ts +5 -1
  287. package/src/interactive/context-meter.ts +1 -1
  288. package/src/interactive/context-overlay.ts +40 -10
  289. package/src/interactive/cost-overlay.ts +64 -6
  290. package/src/interactive/dispatch-board.ts +84 -12
  291. package/src/interactive/fleet-run-preview.ts +41 -15
  292. package/src/interactive/handoff-round.ts +41 -2
  293. package/src/interactive/interactive-application.ts +24 -1
  294. package/src/interactive/interactive-input-runtime.ts +8 -0
  295. package/src/interactive/interactive-presentation.ts +4 -0
  296. package/src/interactive/interactive-shell.ts +20 -17
  297. package/src/interactive/interactive-slash-runtime.ts +27 -4
  298. package/src/interactive/memory-overlay.ts +8 -0
  299. package/src/interactive/mutation-preview.ts +295 -0
  300. package/src/interactive/overlay-general-openers.ts +16 -0
  301. package/src/interactive/overlay-key-routing.ts +38 -0
  302. package/src/interactive/overlay-lifecycle.ts +38 -5
  303. package/src/interactive/overlay-permission-lifecycle.ts +22 -2
  304. package/src/interactive/overlay-session-lifecycle.ts +73 -9
  305. package/src/interactive/overlays/ask-user.ts +91 -19
  306. package/src/interactive/overlays/help-reference.ts +4 -0
  307. package/src/interactive/overlays/prompts.ts +11 -1
  308. package/src/interactive/overlays/settings.ts +35 -1
  309. package/src/interactive/permission-hint.ts +34 -2
  310. package/src/interactive/permission-overlay.ts +159 -9
  311. package/src/interactive/prewarm.ts +197 -0
  312. package/src/interactive/render-trace.ts +162 -15
  313. package/src/interactive/renderers/tool-execution.ts +4 -0
  314. package/src/interactive/side-question.ts +58 -1
  315. package/src/interactive/status/controller.ts +11 -0
  316. package/src/interactive/status/state-machine.ts +54 -2
  317. package/src/interactive/status/types.ts +7 -0
  318. package/src/interactive/terminal-lease.ts +2 -0
  319. package/src/interactive/turn-context.ts +299 -31
  320. package/src/interactive/turn-persistence.ts +14 -4
  321. package/src/interactive/turn-prewarm.ts +364 -0
  322. package/src/interactive/turn-queues.ts +7 -4
  323. package/src/interactive/turn-runtime.ts +8 -1
  324. package/src/interactive/turn-state.ts +23 -0
  325. package/src/interactive/view/view-overlay.ts +28 -3
  326. package/src/tools/ask-user.ts +43 -2
  327. package/src/tools/dispatch-plan.ts +17 -9
  328. package/src/tools/dispatch-scout.ts +1 -1
  329. package/src/tools/registry.ts +16 -0
  330. package/dist/chunk-AOCYTWAV.js +0 -449
  331. package/dist/chunk-HWUFFB6L.js +0 -83
  332. package/dist/chunk-R346GLFC.js +0 -31
  333. package/dist/doctor-M7YEDGAE.js +0 -91
@@ -827,9 +827,14 @@ function resolveRowSize(value, termHeight) {
827
827
 
828
828
  // src/interactive/permission-hint.ts
829
829
  init_esm_shims();
830
- function permissionHintEntries(composerHasDraft = false) {
830
+ var MUTATION_PREVIEW_KEY = "v";
831
+ function permissionHintEntries(composerHasDraft = false, inspection = "none") {
831
832
  return [
832
833
  composerHasDraft ? { key: "Backspace", verb: "clear the draft to allow", short: "clear draft", critical: true } : { key: "Enter", verb: "allow once", short: "allow", critical: true },
834
+ ...inspection === "none" ? [] : inspection === "open" ? [
835
+ { key: "\u2191\u2193", verb: "scroll", critical: false },
836
+ { key: MUTATION_PREVIEW_KEY, verb: "hide mutation", short: "hide", critical: false }
837
+ ] : [{ key: MUTATION_PREVIEW_KEY, verb: "inspect mutation", short: "inspect", critical: false }],
833
838
  { key: "s", verb: "stop turn", short: "stop", critical: true },
834
839
  // With a draft, deny and stop are the only immediate answers, so Esc
835
840
  // outranks the narrowing that would otherwise drop it first.
@@ -841,6 +846,8 @@ function permissionHintEntries(composerHasDraft = false) {
841
846
  var REVERSE_VIDEO_BLANK = `${String.fromCharCode(27)}[7m ${String.fromCharCode(27)}[0m`;
842
847
  var EMPTY_PROMPT = "Ask Clio\u2026 / for commands";
843
848
  var CONFIRM_PROMPT = "A parked call is waiting for your decision";
849
+ var PREPARING_PROMPT = "Clio has your prompt and is preparing the turn";
850
+ var COMPACTING_PROMPT = "Clio has your prompt and is compacting the context first";
844
851
  var MIN_HINT_WIDTH = 60;
845
852
  function hasScrollIndicator(line) {
846
853
  const stripped = stripTerminalSequences(line);
@@ -870,7 +877,12 @@ function styledRailLabel(theme, chrome) {
870
877
  }
871
878
  function composerMode(chrome, text) {
872
879
  if (chrome.isAwaitingApproval?.() ?? false) return "CONFIRM";
873
- if (!(chrome.isStreaming?.() ?? false)) return "MESSAGE";
880
+ if (!(chrome.isStreaming?.() ?? false)) {
881
+ const preparation = chrome.getTurnPreparation?.() ?? "idle";
882
+ if (preparation === "compacting") return "COMPACTING";
883
+ if (preparation === "preparing") return "PREPARING";
884
+ return "MESSAGE";
885
+ }
874
886
  const willSteer = chrome.willEnterSteer?.(text) ?? text.trim().length > 0;
875
887
  return willSteer ? "STEER" : "FOLLOW-UP";
876
888
  }
@@ -880,14 +892,20 @@ function lowerRailHint(theme, chrome) {
880
892
  `${chrome.getSubmitKeyLabel?.() ?? "Enter"} send \xB7 ${chrome.getNewlineKeyLabel?.() ?? "Shift+Enter"} newline`
881
893
  );
882
894
  }
883
- function confirmRailHint(theme, width, hasDraft) {
884
- return theme.fg("warning", fitHintEntries(permissionHintEntries(hasDraft), Math.max(1, width - 3)));
895
+ function confirmRailHint(theme, width, hasDraft, inspection) {
896
+ return theme.fg("warning", fitHintEntries(permissionHintEntries(hasDraft, inspection), Math.max(1, width - 3)));
885
897
  }
886
898
  function modeToken(mode) {
887
- if (mode === "STEER") return "action";
899
+ if (mode === "STEER" || mode === "PREPARING" || mode === "COMPACTING") return "action";
888
900
  if (mode === "CONFIRM") return "warning";
889
901
  return "accentDeep";
890
902
  }
903
+ function emptyPromptFor(mode) {
904
+ if (mode === "CONFIRM") return CONFIRM_PROMPT;
905
+ if (mode === "PREPARING") return PREPARING_PROMPT;
906
+ if (mode === "COMPACTING") return COMPACTING_PROMPT;
907
+ return EMPTY_PROMPT;
908
+ }
891
909
  function renderEmptyPrompt(line, width, theme, text = EMPTY_PROMPT) {
892
910
  const cursorAt = line.indexOf(REVERSE_VIDEO_BLANK);
893
911
  if (cursorAt < 0) return line;
@@ -931,12 +949,12 @@ var ClioEditor = class extends Editor {
931
949
  });
932
950
  }
933
951
  if (text.length === 0 && lines[1]) {
934
- lines[1] = renderEmptyPrompt(lines[1], safeWidth, theme, mode === "CONFIRM" ? CONFIRM_PROMPT : EMPTY_PROMPT);
952
+ lines[1] = renderEmptyPrompt(lines[1], safeWidth, theme, emptyPromptFor(mode));
935
953
  }
936
954
  const bottomRail = findBottomRail(lines, safeWidth);
937
955
  if (bottomRail >= 0 && mode === "CONFIRM") {
938
956
  lines[bottomRail] = rule(theme, safeWidth, {
939
- right: confirmRailHint(theme, safeWidth, text.length > 0),
957
+ right: confirmRailHint(theme, safeWidth, text.length > 0, this.chrome.getPermissionInspection?.() ?? "none"),
940
958
  fillToken: "frameStrong",
941
959
  rightRaw: true,
942
960
  rightTail: theme.style("frameStrong", "\u2500", { bold: true })
@@ -977,10 +995,49 @@ init_esm_shims();
977
995
 
978
996
  // src/interactive/render-trace.ts
979
997
  init_esm_shims();
980
- import { mkdirSync, writeFileSync } from "node:fs";
998
+ import { mkdirSync, readdirSync, rmSync, writeFileSync } from "node:fs";
981
999
  import { appendFile } from "node:fs/promises";
982
- import { dirname } from "node:path";
1000
+ import { dirname, join } from "node:path";
983
1001
  var RENDER_TRACE_VERSION = 2;
1002
+ var INPUT_WEDGE_RING_CAPACITY = 256;
1003
+ var INPUT_WEDGE_DUMP_DIRNAME = "input-wedge";
1004
+ var INPUT_WEDGE_DUMP_RETAINED = 5;
1005
+ function createRing(capacity) {
1006
+ const slots = [];
1007
+ let next = 0;
1008
+ return {
1009
+ push(value) {
1010
+ if (slots.length < capacity) slots.push(value);
1011
+ else slots[next] = value;
1012
+ next = (next + 1) % capacity;
1013
+ },
1014
+ toArray() {
1015
+ if (slots.length < capacity) return [...slots];
1016
+ return [...slots.slice(next), ...slots.slice(0, next)];
1017
+ }
1018
+ };
1019
+ }
1020
+ function classifyInputWedge(inputIngress, frames) {
1021
+ const newest = [...inputIngress].reverse().find((record) => record.visualExpected) ?? inputIngress.at(-1);
1022
+ if (newest === void 0) return "no-input-recorded";
1023
+ return frames.some((frame2) => frame2.inputHighWater >= newest.inputSeq) ? "input-committed" : "input-not-committed";
1024
+ }
1025
+ function writeInputWedgeDump(stateDir, snapshot) {
1026
+ const directory = join(stateDir, INPUT_WEDGE_DUMP_DIRNAME);
1027
+ mkdirSync(directory, { recursive: true });
1028
+ const stamp = new Date(snapshot.atEpochMs).toISOString().replace(/[:.]/gu, "-");
1029
+ const path = join(directory, `${stamp}-${snapshot.pid}.json`);
1030
+ writeFileSync(path, `${JSON.stringify(snapshot, null, 2)}
1031
+ `, "utf8");
1032
+ try {
1033
+ const existing = readdirSync(directory).filter((name) => name.endsWith(".json")).sort();
1034
+ for (const name of existing.slice(0, Math.max(0, existing.length - INPUT_WEDGE_DUMP_RETAINED))) {
1035
+ rmSync(join(directory, name), { force: true });
1036
+ }
1037
+ } catch {
1038
+ }
1039
+ return path;
1040
+ }
984
1041
  function createAsyncTraceWriter(path, options = {}) {
985
1042
  const maxRecords = options.maxRecords ?? 4096;
986
1043
  const batchRecords = options.batchRecords ?? 128;
@@ -1073,11 +1130,16 @@ function renderTracePath(env = process.env) {
1073
1130
  return raw && raw.length > 0 ? raw : null;
1074
1131
  }
1075
1132
  function createRenderTrace(path, now = () => performance.now(), writerOptions = {}) {
1076
- mkdirSync(dirname(path), { recursive: true });
1077
- writeFileSync(path, "", "utf8");
1133
+ if (path !== null) {
1134
+ mkdirSync(dirname(path), { recursive: true });
1135
+ writeFileSync(path, "", "utf8");
1136
+ }
1078
1137
  const openedAt = now();
1138
+ const openedAtEpochMs = Date.now();
1079
1139
  const at = () => rounded(now() - openedAt);
1080
- const writer = createAsyncTraceWriter(path, { ...writerOptions, recordTime: at });
1140
+ const writer = path === null ? null : createAsyncTraceWriter(path, { ...writerOptions, recordTime: at });
1141
+ const inputRing = createRing(INPUT_WEDGE_RING_CAPACITY);
1142
+ const frameRing = createRing(INPUT_WEDGE_RING_CAPACITY);
1081
1143
  let frameSeq = 0;
1082
1144
  let writeSeq = 0;
1083
1145
  let eventSeq = 0;
@@ -1093,7 +1155,7 @@ function createRenderTrace(path, now = () => performance.now(), writerOptions =
1093
1155
  let firstCommitDelivered = false;
1094
1156
  const ranges = /* @__PURE__ */ new Map();
1095
1157
  const pendingDrains = /* @__PURE__ */ new Map();
1096
- writer.enqueue({ type: "trace_start", version: RENDER_TRACE_VERSION, at: 0 });
1158
+ writer?.enqueue({ type: "trace_start", version: RENDER_TRACE_VERSION, at: 0 });
1097
1159
  const trace = {
1098
1160
  recordPanelRender(metrics) {
1099
1161
  pendingPanel = metrics;
@@ -1104,12 +1166,13 @@ function createRenderTrace(path, now = () => performance.now(), writerOptions =
1104
1166
  },
1105
1167
  recordVisibleEvent(fields) {
1106
1168
  eventSeq += 1;
1169
+ if (writer === null) return eventSeq;
1107
1170
  const key = `${generation}:${fields.kind}:${fields.contentIndex}`;
1108
1171
  const previous = ranges.get(key) ?? { codeUnits: 0, graphemes: 0 };
1109
1172
  const graphemes = graphemeCount(fields.delta);
1110
1173
  const next = { codeUnits: previous.codeUnits + fields.delta.length, graphemes: previous.graphemes + graphemes };
1111
1174
  ranges.set(key, next);
1112
- writer.enqueue({
1175
+ writer?.enqueue({
1113
1176
  type: "event_ingress",
1114
1177
  version: RENDER_TRACE_VERSION,
1115
1178
  eventSeq,
@@ -1127,7 +1190,7 @@ function createRenderTrace(path, now = () => performance.now(), writerOptions =
1127
1190
  },
1128
1191
  recordQueue(sequence, action) {
1129
1192
  queueDepth = Math.max(0, queueDepth + (action === "admit" ? 1 : -1));
1130
- writer.enqueue({
1193
+ writer?.enqueue({
1131
1194
  type: "queue",
1132
1195
  version: RENDER_TRACE_VERSION,
1133
1196
  eventSeq: sequence,
@@ -1138,7 +1201,7 @@ function createRenderTrace(path, now = () => performance.now(), writerOptions =
1138
1201
  },
1139
1202
  recordPanelApplied(sequence) {
1140
1203
  panelHighWater = Math.max(panelHighWater, sequence);
1141
- writer.enqueue({
1204
+ writer?.enqueue({
1142
1205
  type: "panel",
1143
1206
  version: RENDER_TRACE_VERSION,
1144
1207
  eventSeq: sequence,
@@ -1149,7 +1212,7 @@ function createRenderTrace(path, now = () => performance.now(), writerOptions =
1149
1212
  recordInputIngress(action, bytes, visualExpected = action !== "no-visual-change") {
1150
1213
  inputSeq += 1;
1151
1214
  if (visualExpected) inputHighWater = inputSeq;
1152
- writer.enqueue({
1215
+ const record = {
1153
1216
  type: "input_ingress",
1154
1217
  version: RENDER_TRACE_VERSION,
1155
1218
  inputSeq,
@@ -1157,7 +1220,9 @@ function createRenderTrace(path, now = () => performance.now(), writerOptions =
1157
1220
  at: at(),
1158
1221
  bytes,
1159
1222
  visualExpected
1160
- });
1223
+ };
1224
+ inputRing.push(record);
1225
+ writer?.enqueue(record);
1161
1226
  return inputSeq;
1162
1227
  },
1163
1228
  beginFrame(fields) {
@@ -1205,8 +1270,9 @@ function createRenderTrace(path, now = () => performance.now(), writerOptions =
1205
1270
  },
1206
1271
  commits: frame2.commits
1207
1272
  };
1208
- writer.enqueue(record);
1273
+ writer?.enqueue(record);
1209
1274
  if (frame2.commits.length > 0) {
1275
+ frameRing.push(record);
1210
1276
  lastCommitAt = frame2.commits.at(-1)?.at ?? endAt;
1211
1277
  if (!firstCommitDelivered) {
1212
1278
  firstCommitDelivered = true;
@@ -1241,6 +1307,7 @@ function createRenderTrace(path, now = () => performance.now(), writerOptions =
1241
1307
  backpressured: !fields.returned
1242
1308
  };
1243
1309
  currentFrame?.commits.push(commit);
1310
+ if (writer === null) return writeSeq;
1244
1311
  writer.enqueue({ type: "terminal_write", version: RENDER_TRACE_VERSION, frameId, ...commit });
1245
1312
  if (!fields.returned) pendingDrains.set(writeSeq, { frameId, at: commit.at });
1246
1313
  return writeSeq;
@@ -1250,7 +1317,7 @@ function createRenderTrace(path, now = () => performance.now(), writerOptions =
1250
1317
  if (!pending) return;
1251
1318
  pendingDrains.delete(writeId);
1252
1319
  const drainAt = at();
1253
- writer.enqueue({
1320
+ writer?.enqueue({
1254
1321
  type: "terminal_drain",
1255
1322
  version: RENDER_TRACE_VERSION,
1256
1323
  writeId,
@@ -1263,7 +1330,28 @@ function createRenderTrace(path, now = () => performance.now(), writerOptions =
1263
1330
  onFirstFrameCommit(listener) {
1264
1331
  firstCommitListener = listener;
1265
1332
  },
1266
- close: () => writer.close()
1333
+ snapshotInputWedge() {
1334
+ const inputIngress = inputRing.toArray();
1335
+ const frames = frameRing.toArray();
1336
+ const nowAt = at();
1337
+ const lastIngressAt = inputIngress.at(-1)?.at;
1338
+ const lastFrame = frames.at(-1);
1339
+ const lastFrameCommitAt = lastFrame?.commits.at(-1)?.at ?? lastFrame?.endAt;
1340
+ return {
1341
+ version: RENDER_TRACE_VERSION,
1342
+ capacity: INPUT_WEDGE_RING_CAPACITY,
1343
+ pid: process.pid,
1344
+ openedAtEpochMs,
1345
+ atEpochMs: Date.now(),
1346
+ at: nowAt,
1347
+ classification: classifyInputWedge(inputIngress, frames),
1348
+ msSinceLastInputIngress: lastIngressAt === void 0 ? null : rounded(nowAt - lastIngressAt),
1349
+ msSinceLastCommittedFrame: lastFrameCommitAt === void 0 ? null : rounded(nowAt - lastFrameCommitAt),
1350
+ inputIngress,
1351
+ frames
1352
+ };
1353
+ },
1354
+ close: () => writer?.close() ?? Promise.resolve()
1267
1355
  };
1268
1356
  return trace;
1269
1357
  }
@@ -1490,20 +1578,18 @@ function createProcessInteractiveShell(options = {}) {
1490
1578
  let restoreRoot = null;
1491
1579
  let backpressure = null;
1492
1580
  let observedBackpressure = false;
1493
- if (tracePath) {
1494
- let candidate = null;
1495
- try {
1496
- candidate = createRenderTrace(tracePath);
1497
- restoreStdout = traceProcessStdout(candidate);
1498
- activeRenderTrace = candidate;
1499
- } catch {
1500
- restoreStdout?.();
1501
- restoreStdout = null;
1502
- void candidate?.close().catch(() => {
1503
- });
1504
- activeRenderTrace = null;
1505
- }
1506
- } else activeRenderTrace = null;
1581
+ let candidate = null;
1582
+ try {
1583
+ candidate = createRenderTrace(tracePath);
1584
+ restoreStdout = traceProcessStdout(candidate);
1585
+ activeRenderTrace = candidate;
1586
+ } catch {
1587
+ restoreStdout?.();
1588
+ restoreStdout = null;
1589
+ void candidate?.close().catch(() => {
1590
+ });
1591
+ activeRenderTrace = null;
1592
+ }
1507
1593
  const trace = activeRenderTrace;
1508
1594
  if (trace && options.onFirstFrameCommit) trace.onFirstFrameCommit(options.onFirstFrameCommit);
1509
1595
  let firstFrameDelivered = false;
@@ -2187,8 +2273,10 @@ export {
2187
2273
  formatRuntimeResolutionDiagnostic,
2188
2274
  runtimeResolutionDiagnosticLine,
2189
2275
  showClioOverlayFrame,
2276
+ MUTATION_PREVIEW_KEY,
2190
2277
  permissionHintEntries,
2191
2278
  ClioEditor,
2279
+ writeInputWedgeDump,
2192
2280
  getActiveRenderTrace,
2193
2281
  createProcessInteractiveShell,
2194
2282
  validateKeybindings,
@@ -2198,4 +2286,4 @@ export {
2198
2286
  formatPlatformKeybindingNotice,
2199
2287
  createKeybindingManager
2200
2288
  };
2201
- //# sourceMappingURL=chunk-5C3AQNDW.js.map
2289
+ //# sourceMappingURL=chunk-NNNWO6F2.js.map
@@ -4,14 +4,14 @@ import {
4
4
  listChecks,
5
5
  runProjectCheck,
6
6
  runScriptCheck
7
- } from "./chunk-VAWNZU7Z.js";
7
+ } from "./chunk-P3JGPQFL.js";
8
8
  import {
9
9
  BROWSER_MODES,
10
10
  maxOutputArg,
11
11
  prepareVerifyArguments,
12
12
  timeoutArg,
13
13
  verifyToolSurface
14
- } from "./chunk-PMDBGQSJ.js";
14
+ } from "./chunk-CA42X6KT.js";
15
15
  import {
16
16
  escapeRegExp
17
17
  } from "./chunk-VG7TBQIY.js";
@@ -633,4 +633,4 @@ var verifyTool = {
633
633
  export {
634
634
  verifyTool
635
635
  };
636
- //# sourceMappingURL=chunk-GU2UIAFZ.js.map
636
+ //# sourceMappingURL=chunk-NQ6UCCOD.js.map
@@ -1,18 +1,18 @@
1
1
  import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
2
2
  import {
3
3
  receiptResponseModelIdObservationLabel
4
- } from "./chunk-HLE42MG7.js";
4
+ } from "./chunk-D73KXYPF.js";
5
5
  import {
6
6
  adaptRunReceiptTrustStatus,
7
7
  formatTrustAxes,
8
8
  formatTrustSummary
9
- } from "./chunk-K4XHGFR5.js";
9
+ } from "./chunk-MLOK6ZOS.js";
10
10
  import {
11
11
  formatBudgetPolicy,
12
12
  formatBudgetReasons,
13
13
  formatBudgetRequest,
14
14
  formatEffectiveBudget
15
- } from "./chunk-A3WNZD3P.js";
15
+ } from "./chunk-4H6ULJ3H.js";
16
16
  import {
17
17
  mentionsWorkerToolCallCap
18
18
  } from "./chunk-4ZG3XFUR.js";
@@ -173,4 +173,4 @@ export {
173
173
  workerTextLabel,
174
174
  workerTextNonEvidenceNotices
175
175
  };
176
- //# sourceMappingURL=chunk-N22QMJKY.js.map
176
+ //# sourceMappingURL=chunk-NZU6YDNV.js.map
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
2
2
  import {
3
3
  ceilChars
4
- } from "./chunk-RWSI4YD7.js";
4
+ } from "./chunk-AEYBF3TB.js";
5
5
  import {
6
6
  clioStateDir
7
7
  } from "./chunk-BNAZZHFG.js";
@@ -231,6 +231,83 @@ function taskMemoryBankDelta(before, after) {
231
231
  procedural: entryDelta(before.procedural, after.procedural)
232
232
  };
233
233
  }
234
+ function parseTaskMemoryTelemetryRecord(value) {
235
+ if (!isRecord(value) || !hasExactKeys(value, TELEMETRY_KEYS)) return null;
236
+ if (value.version !== TASK_MEMORY_TELEMETRY_VERSION || !validIsoTimestamp(value.at)) return null;
237
+ if (!validTriggerReasons(value.triggerReasons) || !isTier(value.tier) || !isDecision(value.decision)) return null;
238
+ if (!isReason(value.reason) || !isNonNegativeInteger(value.citedEntries)) return null;
239
+ if (!isNonNegativeInteger(value.bankOperations) || !isNonNegativeInteger(value.droppedOperations)) return null;
240
+ const bankDelta = parseBankDelta(value.bankDelta);
241
+ const tokenCost = parseTokenCost(value.tokenCost);
242
+ if (bankDelta === null || tokenCost === null || !isNonNegativeFinite(value.latencyMs)) return null;
243
+ return {
244
+ version: TASK_MEMORY_TELEMETRY_VERSION,
245
+ at: value.at,
246
+ triggerReasons: value.triggerReasons,
247
+ tier: value.tier,
248
+ bankDelta,
249
+ decision: value.decision,
250
+ reason: value.reason,
251
+ bankOperations: value.bankOperations,
252
+ droppedOperations: value.droppedOperations,
253
+ citedEntries: value.citedEntries,
254
+ tokenCost,
255
+ latencyMs: value.latencyMs
256
+ };
257
+ }
258
+ var TELEMETRY_KEYS = [
259
+ "version",
260
+ "at",
261
+ "triggerReasons",
262
+ "tier",
263
+ "bankDelta",
264
+ "decision",
265
+ "reason",
266
+ "bankOperations",
267
+ "droppedOperations",
268
+ "citedEntries",
269
+ "tokenCost",
270
+ "latencyMs"
271
+ ];
272
+ var DELTA_KEYS = ["status", "knowledge", "procedural"];
273
+ var CLASS_DELTA_KEYS = ["added", "updated", "deleted"];
274
+ var TOKEN_KEYS = ["input", "output", "total"];
275
+ var TRIGGERS = /* @__PURE__ */ new Set([
276
+ "interval",
277
+ "tool_error_streak",
278
+ "loop_signal",
279
+ "repeated_failure",
280
+ "turn_end",
281
+ "post_compaction",
282
+ "manual"
283
+ ]);
284
+ var DECISIONS = /* @__PURE__ */ new Set([
285
+ "silent",
286
+ "injected",
287
+ "gated",
288
+ "timeout",
289
+ "malformed",
290
+ "dropped"
291
+ ]);
292
+ var REASONS = /* @__PURE__ */ new Set([
293
+ "intervened",
294
+ "model_silent",
295
+ "duplicate_reminder",
296
+ "suppressed",
297
+ "uncited",
298
+ "over_budget",
299
+ "unparseable",
300
+ "all_operations_invalid",
301
+ "deadline",
302
+ "timed_out",
303
+ "endpoint_busy",
304
+ "client_error",
305
+ "no_client",
306
+ "no_consumer",
307
+ "step_in_flight",
308
+ "no_repeated_failure",
309
+ "bank_empty"
310
+ ]);
234
311
  function entryDelta(before, after) {
235
312
  const old = new Map(before.map((entry) => [entry.id, entry]));
236
313
  const next = new Map(after.map((entry) => [entry.id, entry]));
@@ -250,9 +327,58 @@ function entryDelta(before, after) {
250
327
  function sameEntry(left, right) {
251
328
  return left.content === right.content && left.createdAt === right.createdAt;
252
329
  }
330
+ function parseBankDelta(value) {
331
+ if (!isRecord(value) || !hasExactKeys(value, DELTA_KEYS)) return null;
332
+ const status = parseClassDelta(value.status);
333
+ const knowledge = parseClassDelta(value.knowledge);
334
+ const procedural = parseClassDelta(value.procedural);
335
+ return status === null || knowledge === null || procedural === null ? null : { status, knowledge, procedural };
336
+ }
337
+ function parseClassDelta(value) {
338
+ if (!isRecord(value) || !hasExactKeys(value, CLASS_DELTA_KEYS)) return null;
339
+ return isNonNegativeInteger(value.added) && isNonNegativeInteger(value.updated) && isNonNegativeInteger(value.deleted) ? { added: value.added, updated: value.updated, deleted: value.deleted } : null;
340
+ }
341
+ function parseTokenCost(value) {
342
+ if (!isRecord(value) || !hasExactKeys(value, TOKEN_KEYS)) return null;
343
+ if (!isNonNegativeInteger(value.input) || !isNonNegativeInteger(value.output) || !isNonNegativeInteger(value.total))
344
+ return null;
345
+ if (value.total !== value.input + value.output) return null;
346
+ return { input: value.input, output: value.output, total: value.total };
347
+ }
348
+ function validTriggerReasons(value) {
349
+ return Array.isArray(value) && value.length > 0 && value.length <= 3 && new Set(value).size === value.length && value.every((item) => typeof item === "string" && TRIGGERS.has(item));
350
+ }
351
+ function isTier(value) {
352
+ return value === "rules" || value === "llm";
353
+ }
354
+ function isDecision(value) {
355
+ return typeof value === "string" && DECISIONS.has(value);
356
+ }
357
+ function isReason(value) {
358
+ return typeof value === "string" && REASONS.has(value);
359
+ }
360
+ function validIsoTimestamp(value) {
361
+ if (typeof value !== "string" || value.length > 40) return false;
362
+ const timestamp = Date.parse(value);
363
+ return Number.isFinite(timestamp) && new Date(timestamp).toISOString() === value;
364
+ }
365
+ function isRecord(value) {
366
+ return typeof value === "object" && value !== null && !Array.isArray(value);
367
+ }
368
+ function hasExactKeys(value, keys) {
369
+ const actual = Object.keys(value).sort();
370
+ const expected = [...keys].sort();
371
+ return actual.length === expected.length && actual.every((key, index) => key === expected[index]);
372
+ }
373
+ function isNonNegativeInteger(value) {
374
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
375
+ }
253
376
  function nonNegativeInteger(value) {
254
377
  return Number.isSafeInteger(value) && value >= 0 ? value : 0;
255
378
  }
379
+ function isNonNegativeFinite(value) {
380
+ return typeof value === "number" && Number.isFinite(value) && value >= 0;
381
+ }
256
382
  function nonNegativeFinite(value) {
257
383
  return Number.isFinite(value) && value >= 0 ? value : 0;
258
384
  }
@@ -303,7 +429,7 @@ function buildMemoryInterventionUserPrompt(input) {
303
429
 
304
430
  // src/domains/memory/task-memory-policy.ts
305
431
  var TASK_MEMORY_POLICY_MAX_OPERATIONS = 8;
306
- var TASK_MEMORY_POLICY_DEFAULT_TIMEOUT_MS = 18e4;
432
+ var TASK_MEMORY_POLICY_DEFAULT_TIMEOUT_MS = 3e4;
307
433
  var TASK_MEMORY_POLICY_MODEL_MAX_OUTPUT_TOKENS = 4e3;
308
434
  var TASK_PROMPT_MAX_CHARS = 2e3;
309
435
  var TRAJECTORY_PROMPT_MAX_CHARS = 4e3;
@@ -331,6 +457,7 @@ async function runTaskMemoryPolicy(bank, client, input) {
331
457
  let userPrompt = "";
332
458
  let rawResponse = "";
333
459
  let clientError = null;
460
+ let stepUsage = null;
334
461
  const settle = (decision, reason, parts = {}) => {
335
462
  const result = {
336
463
  decision,
@@ -339,7 +466,8 @@ async function runTaskMemoryPolicy(bank, client, input) {
339
466
  droppedOperations: parts.droppedOperations ?? 0,
340
467
  reminder: parts.reminder ?? null,
341
468
  inputTokens: parts.inputTokens ?? 0,
342
- outputTokens: parts.outputTokens ?? 0
469
+ outputTokens: parts.outputTokens ?? 0,
470
+ usage: stepUsage
343
471
  };
344
472
  try {
345
473
  input.onEnvelope?.({
@@ -379,9 +507,10 @@ async function runTaskMemoryPolicy(bank, client, input) {
379
507
  return settle("timeout", "deadline");
380
508
  }
381
509
  rawResponse = typeof response.text === "string" ? response.text : "";
510
+ stepUsage = response.usage ?? null;
382
511
  const usage = {
383
- inputTokens: nonNegativeInteger2(response.inputTokens),
384
- outputTokens: nonNegativeInteger2(response.outputTokens)
512
+ inputTokens: nonNegativeInteger2(response.inputTokens ?? stepUsage?.input),
513
+ outputTokens: nonNegativeInteger2(response.outputTokens ?? stepUsage?.output)
385
514
  };
386
515
  const read = readPolicyStep(rawResponse);
387
516
  if (!read.ok) return settle("malformed", read.reason, { ...usage, droppedOperations: read.dropped });
@@ -403,6 +532,7 @@ async function runTaskMemoryPolicy(bank, client, input) {
403
532
  return settle("injected", "intervened", { ...counts, reminder });
404
533
  } catch (error) {
405
534
  clientError = errorMessage(error);
535
+ if (isTimeoutError(error)) return settle("timeout", "timed_out");
406
536
  return settle("silent", "client_error");
407
537
  } finally {
408
538
  if (timer !== void 0) clearTimeout(timer);
@@ -493,10 +623,10 @@ function readOperations(value) {
493
623
  const operations = [];
494
624
  let dropped = 0;
495
625
  for (const raw of value) {
496
- if (!isRecord(raw) || typeof raw.op !== "string") return null;
626
+ if (!isRecord2(raw) || typeof raw.op !== "string") return null;
497
627
  switch (raw.op) {
498
628
  case "update_status": {
499
- if (!hasExactKeys(raw, ["op", "content"])) return null;
629
+ if (!hasExactKeys2(raw, ["op", "content"])) return null;
500
630
  const content = boundedContent(raw.content);
501
631
  if (content === null) return null;
502
632
  operations.push({ op: raw.op, content });
@@ -504,7 +634,7 @@ function readOperations(value) {
504
634
  }
505
635
  case "save_knowledge":
506
636
  case "save_procedural": {
507
- if (!hasExactKeys(raw, raw.id === void 0 ? ["op", "content"] : ["op", "content", "id"])) return null;
637
+ if (!hasExactKeys2(raw, raw.id === void 0 ? ["op", "content"] : ["op", "content", "id"])) return null;
508
638
  const content = boundedContent(raw.content);
509
639
  if (content === null) return null;
510
640
  if (raw.id !== void 0 && !nonEmptyString(raw.id)) return null;
@@ -514,7 +644,7 @@ function readOperations(value) {
514
644
  break;
515
645
  }
516
646
  case "delete":
517
- if (!hasExactKeys(raw, ["op", "id"]) || !nonEmptyString(raw.id)) return null;
647
+ if (!hasExactKeys2(raw, ["op", "id"]) || !nonEmptyString(raw.id)) return null;
518
648
  operations.push({ op: raw.op, id: raw.id });
519
649
  break;
520
650
  default:
@@ -585,10 +715,10 @@ function boundedContent(value) {
585
715
  const normalized = value.replace(/\s+/gu, " ").trim();
586
716
  return normalized.length > 0 && normalized.length <= TASK_MEMORY_CONTENT_MAX_CHARS ? normalized : null;
587
717
  }
588
- function isRecord(value) {
718
+ function isRecord2(value) {
589
719
  return value !== null && typeof value === "object" && !Array.isArray(value);
590
720
  }
591
- function hasExactKeys(record, expected) {
721
+ function hasExactKeys2(record, expected) {
592
722
  const keys = Object.keys(record).sort();
593
723
  return keys.length === expected.length && [...expected].sort().every((key, index) => keys[index] === key);
594
724
  }
@@ -601,6 +731,12 @@ function positiveInteger2(value, fallback) {
601
731
  function nonNegativeInteger2(value) {
602
732
  return value !== void 0 && Number.isInteger(value) && value >= 0 ? value : 0;
603
733
  }
734
+ function isTimeoutError(error) {
735
+ const name = error instanceof Error ? error.name : "";
736
+ if (name === "AbortError" || name === "TimeoutError") return true;
737
+ const message = error instanceof Error ? error.message : typeof error === "string" ? error : "";
738
+ return /\b(abort(ed)?|timed out|timeout)\b/iu.test(message);
739
+ }
604
740
  function errorMessage(error) {
605
741
  if (error instanceof Error) return error.message.length > 0 ? error.message : error.name;
606
742
  return typeof error === "string" && error.length > 0 ? error : "an unknown client failure";
@@ -613,7 +749,9 @@ export {
613
749
  TaskMemoryBank,
614
750
  TASK_MEMORY_POLICY_DEFAULT_TIMEOUT_MS,
615
751
  runTaskMemoryPolicy,
752
+ TASK_MEMORY_TELEMETRY_FILE,
616
753
  createTaskMemoryTelemetrySink,
617
- taskMemoryBankDelta
754
+ taskMemoryBankDelta,
755
+ parseTaskMemoryTelemetryRecord
618
756
  };
619
- //# sourceMappingURL=chunk-ZVJ5BLO2.js.map
757
+ //# sourceMappingURL=chunk-O6I4CIEU.js.map
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-CGKSTWHD.js";
8
8
  import {
9
9
  StringEnum
10
- } from "./chunk-FCSXB6T2.js";
10
+ } from "./chunk-UOSL25KY.js";
11
11
  import {
12
12
  init_esm_shims
13
13
  } from "./chunk-3R73A4XB.js";
@@ -43,4 +43,4 @@ export {
43
43
  CODE_NAV_MAX_LIMIT,
44
44
  codeNavToolSurface
45
45
  };
46
- //# sourceMappingURL=chunk-XN3L4EYL.js.map
46
+ //# sourceMappingURL=chunk-OEDBCISO.js.map
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
2
2
  import {
3
3
  runVectorTool
4
- } from "./chunk-PMDBGQSJ.js";
4
+ } from "./chunk-CA42X6KT.js";
5
5
  import {
6
6
  PROJECT_VERIFIER_CATALOG_RELATIVE_PATH,
7
7
  loadProjectVerifierCatalog,
@@ -239,4 +239,4 @@ export {
239
239
  runProjectCheck,
240
240
  runScriptCheck
241
241
  };
242
- //# sourceMappingURL=chunk-VAWNZU7Z.js.map
242
+ //# sourceMappingURL=chunk-P3JGPQFL.js.map