@iowarp/clio-coder 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (312) hide show
  1. package/.claude-plugin/marketplace.json +4 -4
  2. package/CHANGELOG.md +35 -0
  3. package/CONTRIBUTING.md +9 -0
  4. package/README.md +12 -9
  5. package/ROADMAP.md +30 -5
  6. package/dist/{acp-KS7ARGV6.js → acp-F6PGOFZ4.js} +2 -2
  7. package/dist/{agents-YOGJ2YEJ.js → agents-ZHP4R6EX.js} +22 -21
  8. package/dist/assets/codewiki.json +1 -1
  9. package/dist/{auth-CEDCO6O6.js → auth-N75U2H3Z.js} +4 -4
  10. package/dist/{chunk-D3KWFOUT.js → chunk-23UIXH6Z.js} +3 -3
  11. package/dist/{chunk-ZR5YA6ZF.js → chunk-36XVK5P5.js} +5 -5
  12. package/dist/{chunk-AVSR2HKI.js → chunk-3DZ4LPLS.js} +6 -6
  13. package/dist/{chunk-LYJJ6546.js → chunk-3GSPCWFX.js} +12 -12
  14. package/dist/{chunk-CRHPCPZP.js → chunk-4KC4CHKJ.js} +2 -2
  15. package/dist/{chunk-4VDHLCF5.js → chunk-4WJBWKMI.js} +2 -2
  16. package/dist/{chunk-KBUTSJSR.js → chunk-4XBYHXGK.js} +2 -2
  17. package/dist/{chunk-6W75D37F.js → chunk-53P775GE.js} +6 -3
  18. package/dist/{chunk-XZWSP67B.js → chunk-5APYAXCB.js} +2 -2
  19. package/dist/{chunk-D65E25JG.js → chunk-67HPYNTJ.js} +2 -2
  20. package/dist/{chunk-5JQR5B4D.js → chunk-6KV4KCQZ.js} +4 -4
  21. package/dist/{chunk-V4XJWDHR.js → chunk-6UKFRTXI.js} +2 -1
  22. package/dist/{chunk-NDPF2N2L.js → chunk-7DW7CJW2.js} +2 -2
  23. package/dist/{chunk-5KQEUIWM.js → chunk-7LUEQODV.js} +4 -4
  24. package/dist/{chunk-LNOXCGN2.js → chunk-7UFDIOBT.js} +3 -3
  25. package/dist/{chunk-DXSETN72.js → chunk-7WUGNN43.js} +2 -2
  26. package/dist/{chunk-V35KZDUZ.js → chunk-AA3GRZWS.js} +2 -2
  27. package/dist/{chunk-X4CEFOSG.js → chunk-ADO3OQIC.js} +4 -4
  28. package/dist/{chunk-UX2L5CUD.js → chunk-AI36V3ON.js} +3 -3
  29. package/dist/{chunk-B7GY6QER.js → chunk-B26OUMJW.js} +2 -2
  30. package/dist/{chunk-LAR7DX5E.js → chunk-B5TASTCK.js} +153 -62
  31. package/dist/{chunk-TGWZXJ7L.js → chunk-BEMQK5Q7.js} +92 -84
  32. package/dist/{chunk-RNDCROSG.js → chunk-CNXU7TR2.js} +3 -3
  33. package/dist/{chunk-3JLTRPN7.js → chunk-CVMUXT64.js} +35 -66
  34. package/dist/{chunk-733ZBT5P.js → chunk-E74MJF6G.js} +4 -4
  35. package/dist/{chunk-T2MDZES3.js → chunk-EBMTBE76.js} +3 -3
  36. package/dist/{chunk-OZ76TLGU.js → chunk-EEITU7S6.js} +2 -2
  37. package/dist/{chunk-GRHOXDKB.js → chunk-ELDJWJKM.js} +97 -14
  38. package/dist/{chunk-GCQFN7YI.js → chunk-EMYEQLWO.js} +2 -2
  39. package/dist/{chunk-LTWH2ACR.js → chunk-EQPFEDFV.js} +222 -127
  40. package/dist/{chunk-TDGYTWM6.js → chunk-F4I3H56H.js} +2 -2
  41. package/dist/chunk-F6KCJO3U.js +523 -0
  42. package/dist/{chunk-FGSQHUCK.js → chunk-F6VKWTTY.js} +5 -5
  43. package/dist/{chunk-UJD5MPP6.js → chunk-FLNXQQ5B.js} +2 -2
  44. package/dist/{chunk-EX57VVWW.js → chunk-FOSRJ2VZ.js} +4 -4
  45. package/dist/{chunk-ZARZ4POR.js → chunk-G5ZDQQE3.js} +3 -3
  46. package/dist/{chunk-HQVN7G4F.js → chunk-G62JBPXN.js} +7 -7
  47. package/dist/{chunk-ZJPORZTC.js → chunk-GIAI7A2K.js} +2 -2
  48. package/dist/chunk-GPTR6OTU.js +2551 -0
  49. package/dist/{chunk-EZD2BXGP.js → chunk-GUFQPTQK.js} +2 -2
  50. package/dist/{chunk-OPD7GL6F.js → chunk-H6FQVNZC.js} +8 -7
  51. package/dist/chunk-H7REJ7L5.js +80 -0
  52. package/dist/{chunk-EYTLV3W3.js → chunk-HTWTORF7.js} +2 -2
  53. package/dist/{chunk-DF6PI6GN.js → chunk-I6UKQPGS.js} +3 -3
  54. package/dist/{chunk-ISHUS7HC.js → chunk-JRW236JT.js} +3 -3
  55. package/dist/{chunk-DE2LU267.js → chunk-KKAJGT3B.js} +3 -2
  56. package/dist/{chunk-OV62D6KO.js → chunk-KQMYL5GR.js} +3 -3
  57. package/dist/{chunk-QDUUOZ3S.js → chunk-KWMFC7FN.js} +3 -3
  58. package/dist/{chunk-R7FGRZNF.js → chunk-LXYHCCIZ.js} +9 -9
  59. package/dist/{chunk-NFSK2VNU.js → chunk-LZMTVVN4.js} +2 -2
  60. package/dist/{chunk-62UK7AGW.js → chunk-M5PMRZSR.js} +397 -44
  61. package/dist/chunk-MMZMM6SW.js +131 -0
  62. package/dist/{chunk-FFYTC2KQ.js → chunk-MNABNEBX.js} +2 -2
  63. package/dist/{chunk-XMDBTYCH.js → chunk-N3CWOGVF.js} +3 -3
  64. package/dist/{chunk-VYRQHORQ.js → chunk-NMQSO6Z6.js} +4 -3
  65. package/dist/{chunk-R2UUNSNQ.js → chunk-O3ZAF7UY.js} +18 -5
  66. package/dist/{chunk-4SYHGVDE.js → chunk-OQNCLZI4.js} +4 -4
  67. package/dist/{chunk-EG4ARXPC.js → chunk-OX6QTA4N.js} +3 -3
  68. package/dist/{chunk-P4GNZPXO.js → chunk-OYUS3UZP.js} +2 -2
  69. package/dist/{chunk-OQ2EOAHA.js → chunk-PF36KOGI.js} +291 -112
  70. package/dist/{chunk-55RMDDFM.js → chunk-PGQG7ZMW.js} +2 -2
  71. package/dist/{chunk-CBAQPTDU.js → chunk-PIU6BXXW.js} +2 -2
  72. package/dist/{chunk-EKV4UBCM.js → chunk-PZBQUJ2F.js} +2 -2
  73. package/dist/{chunk-7RET77VB.js → chunk-Q2HKY32Y.js} +2 -2
  74. package/dist/{chunk-U6YTUVOX.js → chunk-Q4RMNWMZ.js} +4 -4
  75. package/dist/chunk-Q6FRR3AQ.js +48 -0
  76. package/dist/{chunk-6RJMYYIE.js → chunk-QJSIAJBY.js} +3 -3
  77. package/dist/{chunk-DOUISWEE.js → chunk-QOJ4ERMU.js} +5 -5
  78. package/dist/{chunk-IFPDAD7R.js → chunk-RWSRKXLT.js} +3 -3
  79. package/dist/{chunk-T33IYTZM.js → chunk-SAASVMIY.js} +3 -3
  80. package/dist/{chunk-2DTIWSAW.js → chunk-SEQDH6JC.js} +3 -3
  81. package/dist/{chunk-BRCOSE7O.js → chunk-SZUO5BSE.js} +2 -2
  82. package/dist/{chunk-HOEDA42N.js → chunk-T7HZ7KJF.js} +2 -2
  83. package/dist/{chunk-OJXOA6YU.js → chunk-TL6LNERH.js} +2 -2
  84. package/dist/{chunk-UCINIRHW.js → chunk-TPCZXWLT.js} +3 -3
  85. package/dist/{chunk-ZUKUCZYZ.js → chunk-TQ2KTH4A.js} +2 -2
  86. package/dist/{chunk-4WOOTKFD.js → chunk-U3FETNQB.js} +341 -20
  87. package/dist/{chunk-5B3RTYAK.js → chunk-UGDSB4AN.js} +2 -2
  88. package/dist/{chunk-VKHLUZNO.js → chunk-UZ7YBL43.js} +3 -3
  89. package/dist/{chunk-QNUQ7K7D.js → chunk-VKMSEO7Y.js} +4 -4
  90. package/dist/{chunk-IN7DGBVS.js → chunk-VLX5VZ35.js} +5 -5
  91. package/dist/{chunk-SJGS3GDI.js → chunk-WAGBMMNX.js} +5 -5
  92. package/dist/{chunk-BFOSV5EZ.js → chunk-WX2YCH7F.js} +2 -2
  93. package/dist/{chunk-3LT34CAM.js → chunk-XBIGUILU.js} +32 -17
  94. package/dist/{chunk-XDHUDE5K.js → chunk-XKYBFRWR.js} +5 -5
  95. package/dist/{chunk-U5QU5ZOD.js → chunk-XYPWFSU5.js} +3 -3
  96. package/dist/{chunk-YBUECLAF.js → chunk-YEJQDODA.js} +2 -2
  97. package/dist/{chunk-YQ6XEFVK.js → chunk-Z74OGONW.js} +39 -7
  98. package/dist/{chunk-I4ELN5BX.js → chunk-ZTNOEJRI.js} +2 -2
  99. package/dist/cli/index.js +26 -26
  100. package/dist/{clio-K2PBVCEM.js → clio-4IKFE25F.js} +2 -2
  101. package/dist/{clio-context-tools-GR4OHFSO.js → clio-context-tools-OHJXYX4R.js} +25 -23
  102. package/dist/{code-nav-4X3OI6DK.js → code-nav-XPM3MY5I.js} +7 -7
  103. package/dist/{config-Q5J7UBAB.js → config-343YS25T.js} +43 -41
  104. package/dist/{config-graph-P3555574.js → config-graph-WI263KDX.js} +43 -41
  105. package/dist/{configure-KIJ32ZO6.js → configure-GZDG4HER.js} +21 -21
  106. package/dist/{context-LFBQOSXT.js → context-4OFO7N7Y.js} +12 -12
  107. package/dist/{context-WBH3KSVR.js → context-JLK2RLOG.js} +42 -40
  108. package/dist/{context-NNLBES2Y.js → context-O6DIWCF6.js} +23 -21
  109. package/dist/{context-clear-YOHMQ6SQ.js → context-clear-MR7KOGQI.js} +42 -40
  110. package/dist/{context-working-set-MRAEVDNV.js → context-working-set-YZAD3KWO.js} +14 -13
  111. package/dist/{data-tool-JJPBGMQJ.js → data-tool-EKD7DFHG.js} +7 -7
  112. package/dist/{detail-RHJOTGN4.js → detail-YZPHFEVJ.js} +43 -41
  113. package/dist/{dispatch-runner-NC7PYNIO.js → dispatch-runner-VKVXVTWJ.js} +44 -42
  114. package/dist/{doctor-S5KZ2GTN.js → doctor-53AVQXAO.js} +17 -16
  115. package/dist/{doctor-deep-2EJQSHIZ.js → doctor-deep-BLRB2NCG.js} +5 -5
  116. package/dist/{eval-3D6M36N7.js → eval-P3BQSLQE.js} +21 -20
  117. package/dist/{evidence-XNVPPLVK.js → evidence-6LLI6SZH.js} +44 -42
  118. package/dist/{evidence-6IYN52ET.js → evidence-HTN3JLUO.js} +42 -40
  119. package/dist/{evidence-JVECPI3F.js → evidence-NJRE3R5H.js} +42 -40
  120. package/dist/{evolve-TLPUDJDM.js → evolve-WWZHJVJP.js} +42 -40
  121. package/dist/{fleet-WKVBF5SZ.js → fleet-GGZ4BVJE.js} +64 -62
  122. package/dist/{fleet-6RJWIOEO.js → fleet-QG3IIWWM.js} +44 -42
  123. package/dist/{fleet-commands-L6WFT7KZ.js → fleet-commands-J2ZIKISQ.js} +7 -7
  124. package/dist/{fleet-decisions-BTQMWU5A.js → fleet-decisions-Y2Q7375Q.js} +8 -8
  125. package/dist/{fleet-graph-553DZ67Q.js → fleet-graph-TCBCCCBP.js} +11 -11
  126. package/dist/{fleet-inspect-236FZPRB.js → fleet-inspect-KOLKBC56.js} +44 -42
  127. package/dist/{fleet-preflight-NZQHABWO.js → fleet-preflight-44UNCC4Y.js} +27 -25
  128. package/dist/{fleet-validate-7NLAE26R.js → fleet-validate-K2FXRZVA.js} +13 -13
  129. package/dist/{fleet-verify-E3RO6A5W.js → fleet-verify-AS444WDW.js} +42 -40
  130. package/dist/{fleet-view-KMZQY7YJ.js → fleet-view-X4JU4J6O.js} +43 -41
  131. package/dist/gui/ops-worker.js +9 -9
  132. package/dist/gui/reads-worker.js +9 -8
  133. package/dist/{init-DV5B6HQG.js → init-VSOWFHVL.js} +54 -52
  134. package/dist/{interactive-OXGYZYAS.js → interactive-JRCBENLZ.js} +1733 -577
  135. package/dist/{interop-J7UOBOSF.js → interop-JR6BCY7R.js} +10 -10
  136. package/dist/{inventory-OEGIL6PY.js → inventory-3JUGLVJI.js} +43 -41
  137. package/dist/{library-ROZAMUIL.js → library-7BOH3Y7N.js} +15 -15
  138. package/dist/{library-B3UPGY4V.js → library-7PFONXUI.js} +9 -9
  139. package/dist/{library-MXQA5DLT.js → library-TUYZMFIA.js} +7 -7
  140. package/dist/{library-import-2LTWOVBD.js → library-import-TJVXKLDK.js} +10 -10
  141. package/dist/{library-inventory-LJ3XHLWO.js → library-inventory-MD3AYTP4.js} +9 -9
  142. package/dist/{library-validation-DARHHUNW.js → library-validation-ZDLITEA3.js} +7 -7
  143. package/dist/{mcp-2GSPYQ54.js → mcp-EFCWUPUR.js} +3 -3
  144. package/dist/{memory-J3STUUIK.js → memory-Q2YVOKK5.js} +42 -40
  145. package/dist/{models-Y3GMFJ2V.js → models-M7BOCW7F.js} +17 -16
  146. package/dist/{monitor-LHNH577J.js → monitor-2HD3MC67.js} +47 -45
  147. package/dist/{orchestrator-DTAPXULA.js → orchestrator-OUW3ZN6Y.js} +1894 -226
  148. package/dist/{panes-A743ONZ5.js → panes-TTPPSYCL.js} +3 -3
  149. package/dist/{preload-OJBMAIXF.js → preload-A47C2NUF.js} +42 -40
  150. package/dist/{providers-CMETPZNS.js → providers-T43W7EL4.js} +4 -4
  151. package/dist/{resources-FY6XYFN2.js → resources-TP6X2V6W.js} +20 -11
  152. package/dist/{run-H64MEVTA.js → run-LDSBPMCS.js} +61 -59
  153. package/dist/{share-CAFMMQLM.js → share-URHKKMHR.js} +9 -9
  154. package/dist/{skills-ERKQUC7L.js → skills-E477MOOO.js} +13 -11
  155. package/dist/{skills-eval-CQ23MYQK.js → skills-eval-AIBR2L7H.js} +583 -93
  156. package/dist/{skills-inventory-TVUYJDVN.js → skills-inventory-HLMKY3R5.js} +13 -11
  157. package/dist/{slash-commands-ROG3KIFJ.js → slash-commands-LIIZKA5Y.js} +28 -26
  158. package/dist/{startup-background-KDWCQMWT.js → startup-background-JR2KDK6R.js} +43 -41
  159. package/dist/{steer-KKYXJSH4.js → steer-D7RTAPCM.js} +3 -3
  160. package/dist/{system-ZDW44ZGX.js → system-X2P5N4IY.js} +14 -13
  161. package/dist/{targets-AJWA6E7Z.js → targets-VFFAKUFM.js} +25 -24
  162. package/dist/{tasks-6L2JJRC5.js → tasks-ERAWZA22.js} +6 -6
  163. package/dist/{terminal-lease-YFUSDPAD.js → terminal-lease-V2N2BIKQ.js} +2 -2
  164. package/dist/{trace-LA5MVR4Y.js → trace-MA5BT7XY.js} +3 -3
  165. package/dist/{usage-XSILDHKF.js → usage-WYFY2L6M.js} +50 -48
  166. package/dist/{verifiers-ECA5GIHL.js → verifiers-TYIW2XKF.js} +7 -7
  167. package/dist/{verify-R6QQCCEB.js → verify-242UFYTP.js} +6 -6
  168. package/dist/{web-fetch-PVZNMBOB.js → web-fetch-LRAGYU6Y.js} +3 -3
  169. package/dist/{wiki-generate-RP22WP5K.js → wiki-generate-OFKOX2T6.js} +53 -51
  170. package/dist/worker/entry.js +31 -29
  171. package/docs/architecture/architecture.md +1 -0
  172. package/docs/architecture/context-engine.md +4 -2
  173. package/docs/architecture/observability.md +6 -4
  174. package/docs/architecture/prompt-envelope-and-tools.md +1 -1
  175. package/docs/architecture/session-lifecycle.md +1 -1
  176. package/docs/architecture/tui-design.md +12 -9
  177. package/docs/gui/parity/02-slash-and-surfaces.md +1 -1
  178. package/docs/guide/commands-and-modes.md +91 -5
  179. package/docs/guide/configuration-and-targets.md +2 -2
  180. package/docs/guide/context-continuity.md +49 -0
  181. package/docs/guide/proactive-memory.md +6 -3
  182. package/library/registry.yaml +292 -32
  183. package/library/skills/README.md +27 -2
  184. package/library/skills/context/context-handoff/SKILL.md +10 -4
  185. package/library/skills/meta/clio-coder-dev/SKILL.md +92 -88
  186. package/library/skills/meta/clio-coder-dev/evals.md +51 -46
  187. package/library/skills/meta/clio-coder-dev/plugin.json +2 -2
  188. package/library/skills/meta/clio-coder-dev/references/change-map.md +49 -0
  189. package/library/skills/meta/clio-coder-test/SKILL.md +89 -142
  190. package/library/skills/meta/clio-coder-test/evals.md +58 -62
  191. package/library/skills/meta/clio-coder-test/plugin.json +2 -2
  192. package/library/skills/meta/clio-coder-test/references/harness.md +3 -3
  193. package/library/skills/meta/clio-coder-test/references/lifecycle-validation.md +30 -0
  194. package/library/skills/meta/clio-coder-test/references/test-map.md +60 -89
  195. package/library/skills/registry.yaml +5 -5
  196. package/library/skills/skill-marketplace.json +12 -14
  197. package/package.json +1 -1
  198. package/src/cli/skills-eval.ts +1064 -54
  199. package/src/cli/usage.ts +2 -2
  200. package/src/core/clio-repo.ts +3 -0
  201. package/src/core/tool-names.ts +1 -0
  202. package/src/domains/context/budget/inspection.ts +9 -0
  203. package/src/domains/context/budget/live-view.ts +418 -0
  204. package/src/domains/context/budget/pressure.ts +393 -0
  205. package/src/domains/context/budget/request-fit.ts +15 -0
  206. package/src/domains/evidence/build.ts +24 -0
  207. package/src/domains/gateway/mcp/client.ts +1 -1
  208. package/src/domains/memory/commit-state.ts +160 -0
  209. package/src/domains/memory/operations.ts +18 -10
  210. package/src/domains/memory/prompt-cache.ts +95 -0
  211. package/src/domains/memory/prompt-section.ts +50 -7
  212. package/src/domains/memory/relevance.ts +93 -0
  213. package/src/domains/memory/restoration.ts +78 -0
  214. package/src/domains/memory/store.ts +39 -1
  215. package/src/domains/middleware/memory-intervention.ts +116 -24
  216. package/src/domains/observability/background-memory-usage.ts +1 -1
  217. package/src/domains/observability/cost.ts +3 -3
  218. package/src/domains/observability/extension.ts +1 -1
  219. package/src/domains/observability/metrics.ts +1 -1
  220. package/src/domains/prompts/compiler.ts +1 -1
  221. package/src/domains/prompts/extension.ts +38 -1
  222. package/src/domains/quota/anthropic-max-provider.ts +134 -0
  223. package/src/domains/quota/anthropic-usage.ts +220 -0
  224. package/src/domains/quota/antigravity-provider.ts +339 -0
  225. package/src/domains/quota/cache.ts +87 -0
  226. package/src/domains/quota/claude-code-provider.ts +169 -0
  227. package/src/domains/quota/codex-provider.ts +237 -0
  228. package/src/domains/quota/presentation.ts +240 -0
  229. package/src/domains/quota/registry.ts +23 -0
  230. package/src/domains/quota/service.ts +93 -0
  231. package/src/domains/quota/summary-feed.ts +86 -0
  232. package/src/domains/quota/types.ts +84 -0
  233. package/src/domains/resources/index.ts +11 -0
  234. package/src/domains/resources/skills/catalog-view.ts +571 -0
  235. package/src/domains/resources/skills/lexical-match.ts +136 -0
  236. package/src/domains/resources/skills/loader.ts +38 -0
  237. package/src/domains/resources/skills/promotion.ts +1 -55
  238. package/src/domains/resources/skills/provenance-pin.ts +50 -20
  239. package/src/domains/safety/action-classifier.ts +1 -0
  240. package/src/domains/session/compaction/branch-summary.ts +4 -1
  241. package/src/domains/session/compaction/compact.ts +18 -2
  242. package/src/domains/session/compaction/cut-point.ts +20 -1
  243. package/src/domains/session/compaction/tokens.ts +48 -3
  244. package/src/domains/session/context-accounting.ts +8 -1
  245. package/src/domains/session/continuity/carry.ts +59 -0
  246. package/src/domains/session/continuity/contract.ts +592 -0
  247. package/src/domains/session/continuity/evidence.ts +290 -0
  248. package/src/domains/session/continuity/fold.ts +1075 -0
  249. package/src/domains/session/continuity/note.ts +79 -0
  250. package/src/domains/session/continuity/operator-request.ts +104 -0
  251. package/src/domains/session/continuity/persistence.ts +408 -0
  252. package/src/domains/session/continuity/ports.ts +231 -0
  253. package/src/domains/session/continuity/projection.ts +538 -0
  254. package/src/domains/session/continuity/validate.ts +352 -0
  255. package/src/domains/session/entries.ts +50 -3
  256. package/src/domains/session/index.ts +48 -0
  257. package/src/domains/session/migrations/index.ts +7 -3
  258. package/src/domains/session/tree/fork.ts +15 -1
  259. package/src/domains/session/usage.ts +2 -2
  260. package/src/engine/acp/commands.ts +1 -1
  261. package/src/engine/agent.ts +133 -9
  262. package/src/engine/session.ts +13 -6
  263. package/src/entry/orchestrator.ts +116 -33
  264. package/src/interactive/chat-loop-messages.ts +2 -2
  265. package/src/interactive/chat-loop.ts +219 -63
  266. package/src/interactive/chat-renderer.ts +99 -8
  267. package/src/interactive/context-overlay.ts +24 -3
  268. package/src/interactive/continuity-controller.ts +526 -0
  269. package/src/interactive/dispatch-board.ts +21 -3
  270. package/src/interactive/footer/dashboard.ts +25 -1
  271. package/src/interactive/footer/key-hints.ts +2 -2
  272. package/src/interactive/footer/pages.ts +70 -27
  273. package/src/interactive/footer/widgets.ts +32 -7
  274. package/src/interactive/footer-panel.ts +1 -1
  275. package/src/interactive/interactive-application.ts +7 -2
  276. package/src/interactive/interactive-input-runtime.ts +2 -2
  277. package/src/interactive/interactive-presentation.ts +15 -0
  278. package/src/interactive/interactive-slash-runtime.ts +45 -8
  279. package/src/interactive/interactive-tickers.ts +7 -1
  280. package/src/interactive/model-session-replay.ts +130 -3
  281. package/src/interactive/output-reserve.ts +35 -0
  282. package/src/interactive/overlay-general-openers.ts +12 -8
  283. package/src/interactive/overlay-key-routing.ts +6 -9
  284. package/src/interactive/overlay-lifecycle.ts +10 -6
  285. package/src/interactive/overlay-session-lifecycle.ts +21 -14
  286. package/src/interactive/quota-view.ts +229 -0
  287. package/src/interactive/session-last-turn.ts +1 -1
  288. package/src/interactive/session-transcript.ts +2 -1
  289. package/src/interactive/session-usage-reseed.ts +2 -2
  290. package/src/interactive/side-question.ts +2 -2
  291. package/src/interactive/slash-commands.ts +28 -9
  292. package/src/interactive/turn-context.ts +686 -63
  293. package/src/interactive/turn-middleware.ts +39 -6
  294. package/src/interactive/turn-persistence.ts +15 -2
  295. package/src/interactive/turn-prewarm.ts +1 -1
  296. package/src/interactive/turn-runtime.ts +48 -5
  297. package/src/interactive/{cost-overlay.ts → usage-overlay.ts} +121 -33
  298. package/src/interactive/welcome-dashboard.ts +26 -3
  299. package/src/tools/agent-tools.ts +3 -1
  300. package/src/tools/bootstrap.ts +6 -0
  301. package/src/tools/builtin-tool-catalog.ts +9 -0
  302. package/src/tools/context/index.ts +148 -113
  303. package/src/tools/context/surface.ts +11 -7
  304. package/src/tools/core-bootstrap.ts +4 -0
  305. package/src/tools/observation.ts +8 -2
  306. package/src/tools/policy.ts +3 -0
  307. package/src/tools/self-compact.ts +31 -0
  308. package/src/tools/surface.ts +1 -0
  309. package/src/tools/tasks.ts +1 -1
  310. package/dist/chunk-CTFPFW3H.js +0 -44
  311. package/dist/chunk-EOJPDNUP.js +0 -1325
  312. package/dist/chunk-I4Y4WKZR.js +0 -386
@@ -2,7 +2,7 @@ import { createRequire as __clioCreateRequire } from "node:module"; const requir
2
2
  import {
3
3
  createTaskBoardStore,
4
4
  taskBoardCounts
5
- } from "./chunk-NDPF2N2L.js";
5
+ } from "./chunk-7DW7CJW2.js";
6
6
  import {
7
7
  CONFIRMED_SCOPE,
8
8
  READONLY_SCOPE,
@@ -20,7 +20,7 @@ import {
20
20
  parseWorkerContextProvenance,
21
21
  routePriorForLatencyClass,
22
22
  sameRouteIdentity
23
- } from "./chunk-T33IYTZM.js";
23
+ } from "./chunk-SAASVMIY.js";
24
24
  import {
25
25
  isLoadableExtension
26
26
  } from "./chunk-OH3YYA3B.js";
@@ -41,17 +41,17 @@ import {
41
41
  TOOL_PROFILE_NAMES,
42
42
  applyToolProfile,
43
43
  isToolProfileName
44
- } from "./chunk-XZWSP67B.js";
44
+ } from "./chunk-5APYAXCB.js";
45
45
  import {
46
46
  deriveExecutionRole,
47
47
  isExecutionRole,
48
48
  requestExecutionRole
49
- } from "./chunk-BRCOSE7O.js";
49
+ } from "./chunk-SZUO5BSE.js";
50
50
  import {
51
51
  McpError,
52
52
  createMcpStdioClient,
53
53
  resolveMcpServers
54
- } from "./chunk-55RMDDFM.js";
54
+ } from "./chunk-PGQG7ZMW.js";
55
55
  import {
56
56
  isDispatchIntent,
57
57
  resolveDispatchPathScope
@@ -59,16 +59,20 @@ import {
59
59
  import {
60
60
  clioDocsToolSurface,
61
61
  clioLibraryToolSurface
62
- } from "./chunk-TDGYTWM6.js";
62
+ } from "./chunk-F4I3H56H.js";
63
63
  import {
64
64
  contextToolSurface
65
- } from "./chunk-CTFPFW3H.js";
65
+ } from "./chunk-Q6FRR3AQ.js";
66
66
  import {
67
67
  gatewayCapabilityKind,
68
68
  toolPlacement,
69
69
  toolSpecPlacement,
70
70
  withGatewayForCapabilities
71
- } from "./chunk-DE2LU267.js";
71
+ } from "./chunk-KKAJGT3B.js";
72
+ import {
73
+ distinctiveTokens,
74
+ normalize
75
+ } from "./chunk-H7REJ7L5.js";
72
76
  import {
73
77
  runScriptToolSurface
74
78
  } from "./chunk-YYLCPDCC.js";
@@ -79,24 +83,24 @@ import {
79
83
  networkToolsDisabled,
80
84
  webFetchToolSurface,
81
85
  webReadToolSurface
82
- } from "./chunk-KBUTSJSR.js";
86
+ } from "./chunk-4XBYHXGK.js";
83
87
  import {
84
88
  detectSupportedImageMimeType,
85
89
  prepareBoundedImage,
86
90
  verifyToolSurface
87
- } from "./chunk-YBUECLAF.js";
91
+ } from "./chunk-YEJQDODA.js";
88
92
  import {
89
93
  gitTool
90
- } from "./chunk-CRHPCPZP.js";
94
+ } from "./chunk-4KC4CHKJ.js";
91
95
  import {
92
96
  DATA_OBSERVATION_SELF_CAP_BYTES,
93
97
  GATEWAY_FIND_SELF_CAP_BYTES,
94
98
  dataToolSurface,
95
99
  prepareDataAdmissionArguments
96
- } from "./chunk-FFYTC2KQ.js";
100
+ } from "./chunk-MNABNEBX.js";
97
101
  import {
98
102
  codeNavToolSurface
99
- } from "./chunk-UJD5MPP6.js";
103
+ } from "./chunk-FLNXQQ5B.js";
100
104
  import {
101
105
  compileGlobRegex,
102
106
  fallbackIgnoredDirs,
@@ -123,11 +127,11 @@ import {
123
127
  toolResultContextText,
124
128
  toolResultDigestFor,
125
129
  writeToolOffload
126
- } from "./chunk-OPD7GL6F.js";
130
+ } from "./chunk-H6FQVNZC.js";
127
131
  import {
128
132
  createSafetyPolicyEngine,
129
133
  formatModelRejection
130
- } from "./chunk-733ZBT5P.js";
134
+ } from "./chunk-E74MJF6G.js";
131
135
  import {
132
136
  DEFAULT_MAX_LINES,
133
137
  splitLinesForCounting,
@@ -157,7 +161,7 @@ import {
157
161
  } from "./chunk-W53XSRQE.js";
158
162
  import {
159
163
  ceilChars
160
- } from "./chunk-6W75D37F.js";
164
+ } from "./chunk-53P775GE.js";
161
165
  import {
162
166
  StringEnum,
163
167
  validateEngineToolArguments
@@ -166,16 +170,8 @@ import {
166
170
  incompleteInstallationAdvice
167
171
  } from "./chunk-HMN2C6YL.js";
168
172
  import {
169
- SKILL_INSTALL_OFFER_OPTION_NEVER,
170
- SKILL_INSTALL_OFFER_OPTION_NOT_NOW,
171
- SKILL_INSTALL_OFFER_OPTION_PROJECT,
172
- SKILL_INSTALL_OFFER_OPTION_USER,
173
- SKILL_SUGGESTION_ANCHOR,
174
- SKILL_SUGGESTION_PREFIX,
175
- decisionRef,
176
- evaluateSkillToolSurface,
177
- skillActivationFromToolDetails
178
- } from "./chunk-I4Y4WKZR.js";
173
+ decisionRef
174
+ } from "./chunk-F6KCJO3U.js";
179
175
  import {
180
176
  DEFAULT_AUTONOMY_EXPOSURE,
181
177
  DEFAULT_AUTONOMY_LEVEL,
@@ -184,6 +180,16 @@ import {
184
180
  isAutonomyLevel,
185
181
  mapAutonomy
186
182
  } from "./chunk-UZVYEF57.js";
183
+ import {
184
+ SKILL_INSTALL_OFFER_OPTION_NEVER,
185
+ SKILL_INSTALL_OFFER_OPTION_NOT_NOW,
186
+ SKILL_INSTALL_OFFER_OPTION_PROJECT,
187
+ SKILL_INSTALL_OFFER_OPTION_USER,
188
+ SKILL_SUGGESTION_ANCHOR,
189
+ SKILL_SUGGESTION_PREFIX,
190
+ evaluateSkillToolSurface,
191
+ skillActivationFromToolDetails
192
+ } from "./chunk-MMZMM6SW.js";
187
193
  import {
188
194
  assertSafeId
189
195
  } from "./chunk-UHW5V7HC.js";
@@ -195,18 +201,18 @@ import {
195
201
  parseAgentLedgerBody,
196
202
  parseResultSummaryMaxBytes,
197
203
  toolSignatureOf
198
- } from "./chunk-LNOXCGN2.js";
204
+ } from "./chunk-7UFDIOBT.js";
199
205
  import {
200
206
  extensionContentDigestWithCapture
201
207
  } from "./chunk-BJH6WFIB.js";
202
208
  import {
203
209
  classify,
204
210
  webFetchIsOutward
205
- } from "./chunk-VYRQHORQ.js";
211
+ } from "./chunk-NMQSO6Z6.js";
206
212
  import {
207
213
  detectValidationCommand,
208
214
  protectedArtifactMutationBlockReason
209
- } from "./chunk-P4GNZPXO.js";
215
+ } from "./chunk-OYUS3UZP.js";
210
216
  import {
211
217
  asDirectoryPathBoundary,
212
218
  pathBoundaryCovers,
@@ -231,7 +237,7 @@ import {
231
237
  isBuiltinToolName,
232
238
  isMcpToolName,
233
239
  mcpToolName
234
- } from "./chunk-V4XJWDHR.js";
240
+ } from "./chunk-6UKFRTXI.js";
235
241
  import {
236
242
  THINKING_LEVELS
237
243
  } from "./chunk-QZTTRSJE.js";
@@ -5497,51 +5503,6 @@ import { randomUUID as randomUUID2 } from "node:crypto";
5497
5503
  init_esm_shims();
5498
5504
  import { existsSync, readFileSync as readFileSync2 } from "node:fs";
5499
5505
  import path3 from "node:path";
5500
- var TOKEN_STOPWORDS = /* @__PURE__ */ new Set([
5501
- "the",
5502
- "a",
5503
- "an",
5504
- "and",
5505
- "or",
5506
- "for",
5507
- "with",
5508
- "this",
5509
- "that",
5510
- "when",
5511
- "what",
5512
- "how",
5513
- "into",
5514
- "from",
5515
- "use",
5516
- "used",
5517
- "using",
5518
- "one",
5519
- "not",
5520
- "skill",
5521
- "skills",
5522
- "clio",
5523
- "please",
5524
- "can",
5525
- "you",
5526
- "should",
5527
- "would",
5528
- "about",
5529
- "need",
5530
- "want",
5531
- "help",
5532
- "make",
5533
- "file",
5534
- "files",
5535
- "code"
5536
- ]);
5537
- function normalize(text) {
5538
- return text.toLowerCase().replace(/[^\p{L}\p{N}\s]/gu, " ").replace(/\s+/g, " ").trim();
5539
- }
5540
- function distinctiveTokens(text) {
5541
- return new Set(
5542
- normalize(text).split(" ").filter((token) => token.length >= 4 && !TOKEN_STOPWORDS.has(token))
5543
- );
5544
- }
5545
5506
  var TRIGGER_SCORE = 4;
5546
5507
  var TOKEN_FIRE_THRESHOLD = 3;
5547
5508
  function scorePromotionEntry(userText, entry) {
@@ -6557,6 +6518,155 @@ function nonNegativeFinite(value) {
6557
6518
  // src/domains/middleware/memory-intervention.ts
6558
6519
  init_esm_shims();
6559
6520
  import { createHash as createHash3 } from "node:crypto";
6521
+
6522
+ // src/domains/memory/commit-state.ts
6523
+ init_esm_shims();
6524
+
6525
+ // src/domains/memory/restoration.ts
6526
+ init_esm_shims();
6527
+ var PREFIX = "Memory: remembered execution context (unverified; current instructions take precedence).\n";
6528
+ function renderMemoryRestoration(input) {
6529
+ const hasCurrentState = input.currentState !== null && input.currentState.text.trim().length > 0;
6530
+ const source = [
6531
+ ...!hasCurrentState && input.bank.status !== null ? [input.bank.status] : [],
6532
+ ...input.bank.knowledge,
6533
+ ...input.bank.procedural
6534
+ ].sort((a, b) => {
6535
+ const status = Number(b.kind === "status") - Number(a.kind === "status");
6536
+ return status || b.lastTouchedAt.localeCompare(a.lastTouchedAt) || a.id.localeCompare(b.id);
6537
+ });
6538
+ const groups = /* @__PURE__ */ new Map();
6539
+ for (const entry of source) {
6540
+ const content = entry.content.replace(/\s+/gu, " ").trim();
6541
+ const group = groups.get(content);
6542
+ if (group) {
6543
+ if (!group.ids.includes(entry.id)) group.ids.push(entry.id);
6544
+ group.kinds.add(entry.kind);
6545
+ } else groups.set(content, { ids: [entry.id], kinds: /* @__PURE__ */ new Set([entry.kind]), content: entry.content });
6546
+ }
6547
+ const lines = [];
6548
+ const cited = [];
6549
+ const omitted = hasCurrentState && input.bank.status !== null ? [input.bank.status.id] : [];
6550
+ const validBudget = Number.isFinite(input.maxTokens) && input.maxTokens > 0;
6551
+ for (const [content, group] of groups) {
6552
+ const kinds = [...group.kinds].sort().map((kind) => kind === "status" ? "historical status" : `remembered ${kind}`).join("/");
6553
+ const line = `- ${group.ids.map((id) => `[${id}]`).join(" ")} ${kinds}: ${JSON.stringify(group.content)}`;
6554
+ const candidate = PREFIX + [...lines, line].join("\n");
6555
+ if (!validBudget || content.length === 0 || ceilChars(candidate.length) > input.maxTokens) {
6556
+ omitted.push(...group.ids);
6557
+ continue;
6558
+ }
6559
+ lines.push(line);
6560
+ cited.push(...group.ids);
6561
+ }
6562
+ const message = lines.length > 0 ? PREFIX + lines.join("\n") : "";
6563
+ return Object.freeze({
6564
+ message,
6565
+ tokens: ceilChars(message.length),
6566
+ citedEntryIds: Object.freeze(cited),
6567
+ omittedEntryIds: Object.freeze(omitted)
6568
+ });
6569
+ }
6570
+
6571
+ // src/domains/memory/commit-state.ts
6572
+ var MemoryCommitState = class {
6573
+ #scope;
6574
+ #generation;
6575
+ #commitEpoch = 0;
6576
+ #disposed = false;
6577
+ #seen = /* @__PURE__ */ new Map();
6578
+ #pending = null;
6579
+ #issued = null;
6580
+ constructor(scope, generation) {
6581
+ assertScope(scope);
6582
+ assertGeneration(generation);
6583
+ this.#scope = copyScope(scope);
6584
+ this.#generation = generation;
6585
+ }
6586
+ capture() {
6587
+ return Object.freeze({ generation: this.#generation, commitEpoch: this.#commitEpoch });
6588
+ }
6589
+ isCurrent(stamp, scope) {
6590
+ return !this.#disposed && this.#matches(scope, stamp.generation) && stamp.commitEpoch === this.#commitEpoch;
6591
+ }
6592
+ notifyContextCommitted(input, generation) {
6593
+ if (this.#disposed) return "disposed";
6594
+ if (!this.#matches(input, generation)) {
6595
+ return generation === this.#generation && this.#seen.has(input.commitId) ? "conflict" : "stale";
6596
+ }
6597
+ if (input.commitId.trim().length === 0) throw new Error("memory commit identity must be nonblank");
6598
+ const previous = this.#seen.get(input.commitId);
6599
+ if (previous !== void 0) return previous === input.outcome ? "duplicate" : "conflict";
6600
+ if (this.#commitEpoch === Number.MAX_SAFE_INTEGER) throw new Error("memory commit epoch exhausted");
6601
+ this.#seen.set(input.commitId, input.outcome);
6602
+ this.#commitEpoch += 1;
6603
+ this.#pending = input.commitId;
6604
+ this.#issued = null;
6605
+ return "accepted";
6606
+ }
6607
+ prepareRestoration(input) {
6608
+ if (this.#disposed || !this.#matches(input.scope, input.generation) || this.#pending === null) return null;
6609
+ const rendered = renderMemoryRestoration(input);
6610
+ this.#issued = Object.freeze({
6611
+ ...rendered,
6612
+ commitId: this.#pending,
6613
+ scope: this.#scope,
6614
+ authority: this.capture()
6615
+ });
6616
+ return this.#issued;
6617
+ }
6618
+ /** Host calls only after installing the exact offered bytes into its admitted context. */
6619
+ acknowledgeRestoration(offer, scope, generation) {
6620
+ if (this.#disposed || offer !== this.#issued || !this.#matches(scope, generation) || !this.isCurrent(offer.authority, offer.scope))
6621
+ return false;
6622
+ this.#pending = null;
6623
+ this.#issued = null;
6624
+ return true;
6625
+ }
6626
+ /** Caller supplies a strictly newer generation; no bank reset and no new commit epoch. */
6627
+ cancel(generation) {
6628
+ if (this.#disposed || !validGeneration(generation) || generation <= this.#generation) return false;
6629
+ this.#generation = generation;
6630
+ this.#issued = null;
6631
+ return true;
6632
+ }
6633
+ /** Navigation is explicit even when returning to the same session/branch identity. */
6634
+ reset(scope, generation) {
6635
+ if (this.#disposed || !validGeneration(generation) || generation <= this.#generation) return false;
6636
+ assertScope(scope);
6637
+ this.#scope = copyScope(scope);
6638
+ this.#generation = generation;
6639
+ this.#commitEpoch = 0;
6640
+ this.#seen.clear();
6641
+ this.#pending = null;
6642
+ this.#issued = null;
6643
+ return true;
6644
+ }
6645
+ dispose() {
6646
+ this.#disposed = true;
6647
+ this.#seen.clear();
6648
+ this.#pending = null;
6649
+ this.#issued = null;
6650
+ }
6651
+ #matches(scope, generation) {
6652
+ return generation === this.#generation && scope.sessionId === this.#scope.sessionId && scope.branchAnchorTurnId === this.#scope.branchAnchorTurnId;
6653
+ }
6654
+ };
6655
+ function validGeneration(value) {
6656
+ return Number.isSafeInteger(value) && value >= 0;
6657
+ }
6658
+ function assertGeneration(value) {
6659
+ if (!validGeneration(value)) throw new Error("memory generation must be a nonnegative safe integer");
6660
+ }
6661
+ function assertScope(scope) {
6662
+ if (scope.sessionId.trim().length === 0 || scope.branchAnchorTurnId !== null && scope.branchAnchorTurnId.trim().length === 0)
6663
+ throw new Error("memory scope identities must be nonblank");
6664
+ }
6665
+ function copyScope(scope) {
6666
+ return Object.freeze({ sessionId: scope.sessionId, branchAnchorTurnId: scope.branchAnchorTurnId });
6667
+ }
6668
+
6669
+ // src/domains/middleware/memory-intervention.ts
6560
6670
  var MEMORY_INTERVENTION_REGISTRATION_ID = "observer.memory-intervention";
6561
6671
  var MEMORY_INTERVENTION_DEFAULT_WINDOW_STEPS = 8;
6562
6672
  var MEMORY_INTERVENTION_DEFAULT_MAX_TOKENS = 2e3;
@@ -6567,6 +6677,16 @@ var CALL_DESCRIPTION_MAX_CHARS = 180;
6567
6677
  var NO_EFFECTS3 = [];
6568
6678
  function createMemoryInterventionRegistration(deps) {
6569
6679
  let generation = 0;
6680
+ let commitState = null;
6681
+ let commitScope = null;
6682
+ let commitBridgeEnabled = false;
6683
+ const captureContentGuard = () => {
6684
+ const capturedGeneration = generation;
6685
+ const owner = commitState;
6686
+ const scope = commitScope;
6687
+ const stamp = owner?.capture();
6688
+ return () => !disposed && generation === capturedGeneration && commitState === owner && (!owner || !!stamp && !!scope && owner.isCurrent(stamp, scope));
6689
+ };
6570
6690
  let generationController = new AbortController();
6571
6691
  let observedSessionId;
6572
6692
  let disposed = false;
@@ -6594,6 +6714,34 @@ function createMemoryInterventionRegistration(deps) {
6594
6714
  let annotatedSinceTurnEnd = false;
6595
6715
  let consecutiveLlmTimeouts = 0;
6596
6716
  return {
6717
+ bindCommitScope(scope) {
6718
+ commitBridgeEnabled = true;
6719
+ if (commitScope?.sessionId === scope.sessionId && commitScope.branchAnchorTurnId === scope.branchAnchorTurnId && commitState)
6720
+ return;
6721
+ if (commitState) reset();
6722
+ commitScope = { ...scope };
6723
+ commitState = new MemoryCommitState(scope, generation);
6724
+ observedSessionId = scope.sessionId;
6725
+ },
6726
+ notifyContextCommitted(input) {
6727
+ commitState?.notifyContextCommitted(input, generation);
6728
+ },
6729
+ prepareRestoration(currentState, maxTokens) {
6730
+ if (!commitScope || !settings().enabled) return null;
6731
+ return commitState?.prepareRestoration({
6732
+ scope: commitScope,
6733
+ generation,
6734
+ bank: deps.bank.snapshot(),
6735
+ currentState,
6736
+ maxTokens: Math.min(maxTokens, settings().maxTokens)
6737
+ }) ?? null;
6738
+ },
6739
+ acknowledgeRestoration(offer) {
6740
+ if (!commitScope || !commitState?.acknowledgeRestoration(offer, commitScope, generation)) return false;
6741
+ deps.bank.recordInjection(offer.citedEntryIds);
6742
+ return true;
6743
+ },
6744
+ isContentCurrent: captureContentGuard,
6597
6745
  reset,
6598
6746
  dispose() {
6599
6747
  disposed = true;
@@ -6637,7 +6785,7 @@ function createMemoryInterventionRegistration(deps) {
6637
6785
  }
6638
6786
  case "on_compaction":
6639
6787
  if (input.metadata?.stage === "working_set_recall") return NO_EFFECTS3;
6640
- reactivateAfterCompaction = true;
6788
+ if (!commitBridgeEnabled) reactivateAfterCompaction = true;
6641
6789
  return NO_EFFECTS3;
6642
6790
  case "turn_start": {
6643
6791
  if (input.text?.trim()) currentTask = shortText(input.text, 2e3);
@@ -6711,17 +6859,18 @@ function createMemoryInterventionRegistration(deps) {
6711
6859
  ) ?? false);
6712
6860
  rulesInjectedSincePromptedStep = false;
6713
6861
  const stepGeneration = generation;
6862
+ const contentCurrent = captureContentGuard();
6714
6863
  promptedStepInFlight = true;
6715
6864
  outstandingStep = runPromptedStep({
6716
6865
  deterministicTrigger: triggers.some((trigger) => trigger !== "interval"),
6717
6866
  suppressIntervention: rulesAlreadySpoke,
6718
6867
  triggerReasons: triggers
6719
6868
  }).then((result) => {
6720
- if (stepGeneration !== generation || disposed) return;
6869
+ if (!contentCurrent()) return;
6721
6870
  if (rulesAlreadySpoke && result.decision === "silent") lastDecision = "injected";
6722
6871
  if (result.reminder === null) return;
6723
6872
  lastInjectedMessage = result.reminder;
6724
- deps.onDeferredReminder?.(result.reminder);
6873
+ deps.onDeferredReminder?.(result.reminder, contentCurrent);
6725
6874
  }).catch(() => {
6726
6875
  }).finally(() => {
6727
6876
  if (stepGeneration === generation) promptedStepInFlight = false;
@@ -6746,6 +6895,7 @@ function createMemoryInterventionRegistration(deps) {
6746
6895
  if (!promptedStepInFlight && pendingTriggers.size === 0 && toolStep <= lastTurnEndStep) return;
6747
6896
  const tier = promptedStepInFlight ? promptedStepTier : "rules";
6748
6897
  generation += 1;
6898
+ commitState?.cancel(generation);
6749
6899
  generationController.abort();
6750
6900
  generationController = new AbortController();
6751
6901
  promptedStepInFlight = false;
@@ -6760,6 +6910,9 @@ function createMemoryInterventionRegistration(deps) {
6760
6910
  emitTelemetry(["turn_end"], tier, "silent", "scope_changed", 0, 0, 0, process.hrtime.bigint());
6761
6911
  }
6762
6912
  function reset() {
6913
+ commitState?.dispose();
6914
+ commitState = null;
6915
+ commitScope = null;
6763
6916
  generation += 1;
6764
6917
  generationController.abort();
6765
6918
  generationController = new AbortController();
@@ -6816,7 +6969,8 @@ function createMemoryInterventionRegistration(deps) {
6816
6969
  });
6817
6970
  const live = settings();
6818
6971
  const stepGeneration = generation;
6819
- const isCurrent = () => !disposed && stepGeneration === generation;
6972
+ const isCurrent = captureContentGuard();
6973
+ const isUsageCurrent = () => !disposed && stepGeneration === generation;
6820
6974
  const usageSink = deps.captureStepUsage?.();
6821
6975
  if (disposed || !live.enabled) {
6822
6976
  const result = silent("no_client");
@@ -6849,7 +7003,7 @@ function createMemoryInterventionRegistration(deps) {
6849
7003
  isCurrent,
6850
7004
  signal: generationController.signal,
6851
7005
  onStepUsage: (usage) => {
6852
- if (usageSink) usageSink(usage, isCurrent());
7006
+ if (usageSink) usageSink(usage, isUsageCurrent());
6853
7007
  else deps.onStepUsage?.(usage);
6854
7008
  },
6855
7009
  task: input.task?.trim() || currentTask,
@@ -6860,7 +7014,11 @@ function createMemoryInterventionRegistration(deps) {
6860
7014
  ...input.suppressIntervention === void 0 ? {} : { suppressIntervention: input.suppressIntervention },
6861
7015
  previousReminder: lastInjectedMessage,
6862
7016
  timeoutMs,
6863
- ...deps.onEnvelope === void 0 ? {} : { onEnvelope: deps.onEnvelope }
7017
+ ...deps.onEnvelope === void 0 ? {} : {
7018
+ onEnvelope: (envelope) => {
7019
+ if (isCurrent()) deps.onEnvelope?.(envelope);
7020
+ }
7021
+ }
6864
7022
  });
6865
7023
  const remainingMs = () => Math.floor(live.timeoutMs - Number(process.hrtime.bigint() - started) / 1e6);
6866
7024
  const initialTimeoutMs = remainingMs();
@@ -6894,17 +7052,18 @@ function createMemoryInterventionRegistration(deps) {
6894
7052
  }
6895
7053
  } catch (error) {
6896
7054
  promptedResult = silent("client_error");
6897
- deps.onEnvelope?.({
6898
- systemPrompt: "",
6899
- userPrompt: "",
6900
- response: "",
6901
- decision: "silent",
6902
- reason: "client_error",
6903
- bankOperations: 0,
6904
- droppedOperations: 0,
6905
- reminder: null,
6906
- error: error instanceof Error ? error.message : "resolving the background model client failed"
6907
- });
7055
+ if (isCurrent())
7056
+ deps.onEnvelope?.({
7057
+ systemPrompt: "",
7058
+ userPrompt: "",
7059
+ response: "",
7060
+ decision: "silent",
7061
+ reason: "client_error",
7062
+ bankOperations: 0,
7063
+ droppedOperations: 0,
7064
+ reminder: null,
7065
+ error: error instanceof Error ? error.message : "resolving the background model client failed"
7066
+ });
6908
7067
  }
6909
7068
  if (!isCurrent()) return { ...promptedResult, reminder: null, effects: NO_EFFECTS3 };
6910
7069
  if (promptedResult.reason === "endpoint_busy") telemetryDecision = "dropped";
@@ -7011,17 +7170,23 @@ function createMemoryInterventionRegistration(deps) {
7011
7170
  };
7012
7171
  trajectory.push(step);
7013
7172
  if (trajectory.length > live.windowSteps) trajectory.splice(0, trajectory.length - live.windowSteps);
7173
+ if (input.metadata?.resultKind === "ok") {
7174
+ failures.delete(step.operationFingerprint);
7175
+ annotatedThisTurn.delete(step.operationFingerprint);
7176
+ if (lastInjectedOperationFingerprint === step.operationFingerprint) lastInjectedOperationFingerprint = null;
7177
+ }
7014
7178
  if (outcome !== "error") return NO_EFFECTS3;
7015
7179
  rememberFailure(step);
7016
7180
  return annotateRepeatedFailure(step);
7017
7181
  }
7018
7182
  function annotateRepeatedFailure(step) {
7019
7183
  if (annotatedThisTurn.has(step.operationFingerprint)) return NO_EFFECTS3;
7184
+ const failure = failures.get(step.operationFingerprint);
7185
+ if (failure === void 0) return NO_EFFECTS3;
7020
7186
  const occurrences = trajectory.filter(
7021
- (candidate) => candidate.outcome === "error" && candidate.operationFingerprint === step.operationFingerprint
7187
+ (candidate) => candidate.outcome === "error" && candidate.operationFingerprint === step.operationFingerprint && candidate.step >= failure.firstStep
7022
7188
  ).length;
7023
- const failure = failures.get(step.operationFingerprint);
7024
- if (occurrences < 2 || failure === void 0) return NO_EFFECTS3;
7189
+ if (occurrences < 2) return NO_EFFECTS3;
7025
7190
  const message = boundedReminder(
7026
7191
  `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.`,
7027
7192
  settings().maxTokens
@@ -7071,11 +7236,12 @@ function createMemoryInterventionRegistration(deps) {
7071
7236
  if (step === void 0 || step.outcome !== "error" || step.step <= lastTurnEndStep || step.operationFingerprint === lastInjectedOperationFingerprint) {
7072
7237
  continue;
7073
7238
  }
7239
+ const failure = failures.get(step.operationFingerprint);
7240
+ if (failure === void 0 || step.step < failure.firstStep) continue;
7074
7241
  const occurrences = trajectory.filter(
7075
- (candidate) => candidate.outcome === "error" && candidate.operationFingerprint === step.operationFingerprint
7242
+ (candidate) => candidate.outcome === "error" && candidate.operationFingerprint === step.operationFingerprint && candidate.step >= failure.firstStep
7076
7243
  ).length;
7077
- const failure = failures.get(step.operationFingerprint);
7078
- if (occurrences < 2 || failure === void 0) continue;
7244
+ if (occurrences < 2) continue;
7079
7245
  const message = boundedReminder(
7080
7246
  `Memory: [${failure.entryId}] you already tried ${failure.callDescription} at step ${failure.firstStep} and it failed with ${failure.errorDigest}.`,
7081
7247
  settings().maxTokens
@@ -8506,7 +8672,9 @@ function resolveSessionTools(runtime, toolRegistry, invokeOptions, telemetry) {
8506
8672
  supportsImages: runtime.runtimeResolution.capabilityDecisions.vision === true
8507
8673
  });
8508
8674
  if (telemetry) input.telemetry = telemetry;
8509
- return resolveAgentTools(input);
8675
+ return resolveAgentTools(input).filter(
8676
+ (tool) => tool.name !== ToolNames.SelfCompact || !runtime.runtimeResolution.runtime.externalAgentLoop
8677
+ );
8510
8678
  }
8511
8679
 
8512
8680
  // src/tools/core-bootstrap.ts
@@ -9578,6 +9746,14 @@ var TOOL_METADATA = {
9578
9746
  costLatency: "local_fast",
9579
9747
  promptHint: "Use code_nav with source=workspace (default) for project code and source=clio for Clio's shipped code map; modes: symbol, path, entries, outline, deps, dependents, wiki (workspace only)."
9580
9748
  },
9749
+ [ToolNames.SelfCompact]: {
9750
+ objective: "Save an exact assistant handoff and reduce native session context.",
9751
+ uiLabel: "Compact",
9752
+ retrySafety: "not_retry_safe",
9753
+ resultSizePolicy: { kind: "exact", maxBytes: 2048 },
9754
+ costLatency: "local_fast",
9755
+ promptHint: 'Use self_compact alone at a safe boundary. Preserve decisions, evidence, paths, and next actions in note_to_self. Inspect context(scope="budget") for current pressure; recovery belongs to the operator.'
9756
+ },
9581
9757
  [ToolNames.Context]: {
9582
9758
  objective: "Return workspace, effective configuration, skill, or recall context.",
9583
9759
  uiLabel: "Context",
@@ -11261,7 +11437,7 @@ var evidenceTool = {
11261
11437
  try {
11262
11438
  const dataDir = clioDataDir();
11263
11439
  if (mode === "list") {
11264
- const { evidenceInventorySnapshot } = await import("./inventory-OEGIL6PY.js");
11440
+ const { evidenceInventorySnapshot } = await import("./inventory-3JUGLVJI.js");
11265
11441
  return boundedResult(await evidenceInventorySnapshot(Date.now, dataDir));
11266
11442
  }
11267
11443
  const id = mode === "inspect" ? args.id : args.runId;
@@ -11269,8 +11445,8 @@ var evidenceTool = {
11269
11445
  return { kind: "error", message: `evidence: ${mode} requires ${mode === "inspect" ? "id" : "runId"}` };
11270
11446
  }
11271
11447
  assertSafeId(id, mode === "inspect" ? "evidence" : "run");
11272
- const { buildEvidence, EvidenceNotFoundError, inspectEvidence, loadEvidenceGateDecisions } = await import("./evidence-JVECPI3F.js");
11273
- const { evidenceDetailSnapshot } = await import("./detail-RHJOTGN4.js");
11448
+ const { buildEvidence, EvidenceNotFoundError, inspectEvidence, loadEvidenceGateDecisions } = await import("./evidence-NJRE3R5H.js");
11449
+ const { evidenceDetailSnapshot } = await import("./detail-YZPHFEVJ.js");
11274
11450
  let evidenceId = mode === "run" ? `run-${id}` : id;
11275
11451
  let inspected;
11276
11452
  try {
@@ -13337,6 +13513,7 @@ var TOOL_PLANES = {
13337
13513
  [ToolNames.Find]: { plane: "observe", actionClass: "read", executionMode: "parallel" },
13338
13514
  [ToolNames.Ls]: { plane: "observe", actionClass: "read", executionMode: "parallel" },
13339
13515
  [ToolNames.CodeNav]: { plane: "observe", actionClass: "read", executionMode: "parallel" },
13516
+ [ToolNames.SelfCompact]: { plane: "orchestrate", actionClass: "read", executionMode: "sequential" },
13340
13517
  [ToolNames.Context]: { plane: "observe", actionClass: "read", executionMode: "parallel" },
13341
13518
  [ToolNames.CredentialPresent]: { plane: "observe", actionClass: "read", executionMode: "parallel" },
13342
13519
  // clio_docs and clio_library are the bundled-documentation and recipe-catalog
@@ -13452,6 +13629,7 @@ function validateBuiltinToolPolicy(specs, options = {}) {
13452
13629
  const includeLedgerTools = options.includeLedgerTools ?? false;
13453
13630
  const includeNetworkTools = options.includeNetworkTools ?? true;
13454
13631
  const required = new Set(Object.values(ToolNames));
13632
+ required.delete(ToolNames.SelfCompact);
13455
13633
  for (const tool of [...required]) {
13456
13634
  if (!includeSessionTools && SESSION_BOUND_TOOLS.has(tool)) required.delete(tool);
13457
13635
  if (!includeDispatchTools && DISPATCH_BOUND_TOOLS.has(tool)) required.delete(tool);
@@ -13593,7 +13771,7 @@ function createTasksTool(deps) {
13593
13771
  };
13594
13772
  return {
13595
13773
  name: ToolNames.Tasks,
13596
- description: "Session task board. plan declares a titled board (replaces any prior board); add appends tasks; pick moves one operator task uN onto the board; start marks one task active (the current focus); done completes a task (started or still pending) and requires note as the evidence the work actually finished; block parks it with a required reason; drop cancels it; list shows the board. For operator handoff, pick the intended uN and use its linked tN; CLI hand does not pick it. Never pick unrelated tasks. Before claiming completion, list: the linked row must be completed and the operator task done on the same session/board link; report IDs and states. Work that did not happen is blocked or dropped, never done. A self-created plan is not operator authorization. For proposal-only work, plan/add with initialStatus=blocked and note naming the pending operator decision; wait for an explicit operator go-ahead before start or implementation. A skill-install choice does not grant that go-ahead.",
13774
+ description: "Session task board. plan declares a titled board (replaces any prior board); add appends tasks; pick moves one operator task uN onto the board; start marks one task active (the current focus); done completes a task (started or still pending) and requires note as the evidence the work actually finished; block parks it with a required reason; drop cancels it; list shows the board. For operator handoff, pick the intended uN before work and use its linked tN; CLI hand alone does not pick it. Never pick unrelated tasks. Before claiming completion, list: the linked row must be completed and the operator task done on the same session/board link; report IDs and states. Work that did not happen is blocked or dropped, never done. A self-created plan is not operator authorization. For proposal-only work, plan/add with initialStatus=blocked and note naming the pending operator decision; wait for an explicit operator go-ahead before start or implementation. A skill-install choice does not grant that go-ahead.",
13597
13775
  parameters: typebox_exports.Object({
13598
13776
  action: StringEnum(TASKS_ACTIONS, { description: "Board action." }),
13599
13777
  title: typebox_exports.Optional(typebox_exports.String({ description: "Board title (plan)." })),
@@ -13835,13 +14013,13 @@ function registerCoreTools(registry, deps = {}) {
13835
14013
  if (includeNetworkTools) {
13836
14014
  registry.register({
13837
14015
  ...builtin(
13838
- lazyTool(webReadToolSurface, async () => (await import("./web-fetch-PVZNMBOB.js")).webReadTool),
14016
+ lazyTool(webReadToolSurface, async () => (await import("./web-fetch-LRAGYU6Y.js")).webReadTool),
13839
14017
  { path: "src/tools/web-fetch.ts", scope: "core" }
13840
14018
  )
13841
14019
  });
13842
14020
  registry.register({
13843
14021
  ...builtin(
13844
- lazyTool(webFetchToolSurface, async () => (await import("./web-fetch-PVZNMBOB.js")).webFetchTool),
14022
+ lazyTool(webFetchToolSurface, async () => (await import("./web-fetch-LRAGYU6Y.js")).webFetchTool),
13845
14023
  { path: "src/tools/web-fetch.ts", scope: "core" }
13846
14024
  )
13847
14025
  });
@@ -13851,7 +14029,7 @@ function registerCoreTools(registry, deps = {}) {
13851
14029
  });
13852
14030
  registry.register({
13853
14031
  ...builtin(
13854
- lazyTool(verifyToolSurface, async () => (await import("./verify-R6QQCCEB.js")).verifyTool),
14032
+ lazyTool(verifyToolSurface, async () => (await import("./verify-242UFYTP.js")).verifyTool),
13855
14033
  { path: "src/tools/verify/index.ts", scope: "core" }
13856
14034
  )
13857
14035
  });
@@ -13872,18 +14050,19 @@ function registerCoreTools(registry, deps = {}) {
13872
14050
  ...dataToolSurface,
13873
14051
  prepareAdmissionArguments: (args) => prepareDataAdmissionArguments(args, getWorkspaceRoot())
13874
14052
  },
13875
- async () => (await import("./data-tool-JJPBGMQJ.js")).createDataTool({ getCwd: getWorkspaceRoot })
14053
+ async () => (await import("./data-tool-EKD7DFHG.js")).createDataTool({ getCwd: getWorkspaceRoot })
13876
14054
  ),
13877
14055
  { path: "src/tools/gateway/data-tool.ts", scope: "core" }
13878
14056
  )
13879
14057
  });
13880
14058
  registry.register({
13881
14059
  ...builtin(
13882
- lazyTool(codeNavToolSurface, async () => (await import("./code-nav-4X3OI6DK.js")).codeNavTool),
14060
+ lazyTool(codeNavToolSurface, async () => (await import("./code-nav-XPM3MY5I.js")).codeNavTool),
13883
14061
  { path: "src/tools/codewiki/code-nav.ts", scope: "core" }
13884
14062
  )
13885
14063
  });
13886
14064
  const skillToolDeps = {
14065
+ ...deps.getContextBudget ? { getContextBudget: deps.getContextBudget } : {},
13887
14066
  ...deps.getSettings ? { getSettings: deps.getSettings } : {},
13888
14067
  ...deps.workerRecall ? { workerRecall: deps.workerRecall } : {},
13889
14068
  getCwd: () => deps.session?.current()?.cwd ?? process.cwd(),
@@ -13915,7 +14094,7 @@ function registerCoreTools(registry, deps = {}) {
13915
14094
  registry.register({
13916
14095
  ...builtin(
13917
14096
  lazyTool(contextToolSurface, async () => {
13918
- const { createContextTool } = await import("./context-NNLBES2Y.js");
14097
+ const { createContextTool } = await import("./context-O6DIWCF6.js");
13919
14098
  if (!session) return createContextTool(skillToolDeps);
13920
14099
  const { probeWorkspace } = await import("./workspace-DZ7JADBG.js");
13921
14100
  return createContextTool({
@@ -13951,7 +14130,7 @@ function registerCoreTools(registry, deps = {}) {
13951
14130
  });
13952
14131
  registry.register({
13953
14132
  ...builtin(
13954
- lazyTool(clioDocsToolSurface, async () => (await import("./clio-context-tools-GR4OHFSO.js")).createClioDocsTool()),
14133
+ lazyTool(clioDocsToolSurface, async () => (await import("./clio-context-tools-OHJXYX4R.js")).createClioDocsTool()),
13955
14134
  { path: "src/tools/gateway/clio-context-tools.ts", scope: "core" }
13956
14135
  )
13957
14136
  });
@@ -13959,7 +14138,7 @@ function registerCoreTools(registry, deps = {}) {
13959
14138
  ...builtin(
13960
14139
  lazyTool(
13961
14140
  clioLibraryToolSurface,
13962
- async () => (await import("./clio-context-tools-GR4OHFSO.js")).createClioLibraryTool({
14141
+ async () => (await import("./clio-context-tools-OHJXYX4R.js")).createClioLibraryTool({
13963
14142
  getCwd: skillToolDeps.getCwd,
13964
14143
  ...deps.skillMarketplace !== void 0 ? { skillMarketplace: deps.skillMarketplace } : {},
13965
14144
  ...deps.getSkillLoaderOptions ? { getSkillLoaderOptions: deps.getSkillLoaderOptions } : {}
@@ -14396,4 +14575,4 @@ export {
14396
14575
  createWorkerToolRegistry,
14397
14576
  attestedToolSignature
14398
14577
  };
14399
- //# sourceMappingURL=chunk-OQ2EOAHA.js.map
14578
+ //# sourceMappingURL=chunk-PF36KOGI.js.map