@iowarp/clio-coder 0.4.2 → 0.4.3

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 (369) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/CONTRIBUTING.md +86 -19
  3. package/README.md +35 -6
  4. package/dist/{acp-TMDQZDIG.js → acp-H2NGRPWO.js} +11 -11
  5. package/dist/{agents-5N5NG3XG.js → agents-TL5LLUQP.js} +54 -53
  6. package/dist/assets/codewiki.json +1 -1
  7. package/dist/{auth-Z5CCBXKQ.js → auth-E5SW4HMS.js} +19 -16
  8. package/dist/{builtins-K6TNDT24.js → builtins-IA7V7FUC.js} +9 -4
  9. package/dist/{chunk-ZW4HH5JJ.js → chunk-2APPQIER.js} +6 -6
  10. package/dist/{chunk-72GZI5EV.js → chunk-2JH2WHGE.js} +2 -2
  11. package/dist/{chunk-UBRFI4HS.js → chunk-2UG5F4C5.js} +127 -47
  12. package/dist/{chunk-UH632ZYL.js → chunk-2UH2KFUP.js} +2 -2
  13. package/dist/{chunk-3F7VUY77.js → chunk-2VIKGWFZ.js} +2 -2
  14. package/dist/{chunk-I66EAJFY.js → chunk-2WZ546HR.js} +267 -232
  15. package/dist/{chunk-RKSR6VSF.js → chunk-4IUZQIJ3.js} +29 -1
  16. package/dist/{chunk-2X4RYJTJ.js → chunk-4UVU7BJ5.js} +2 -2
  17. package/dist/{chunk-M2DAX4F6.js → chunk-4WR7VSYB.js} +2 -2
  18. package/dist/{chunk-5KW52TEP.js → chunk-54CBCGIR.js} +5 -5
  19. package/dist/{chunk-3KIPBMUA.js → chunk-5ICU3EUH.js} +2 -2
  20. package/dist/{chunk-77QIVUZB.js → chunk-5MEZN6CB.js} +4 -4
  21. package/dist/{chunk-O42A54GG.js → chunk-5OIVVPHF.js} +2 -2
  22. package/dist/{chunk-LJID3DYZ.js → chunk-64I3JVYM.js} +2 -2
  23. package/dist/{chunk-4JDLP6ZS.js → chunk-6PTFB5VS.js} +7 -7
  24. package/dist/{chunk-VN3SHNBN.js → chunk-7DICMOS6.js} +2 -2
  25. package/dist/{chunk-HLAFFSEK.js → chunk-7DRAWPTZ.js} +2 -2
  26. package/dist/chunk-7E7I3WLS.js +3762 -0
  27. package/dist/{chunk-YJISEZKC.js → chunk-7ZYNNDKC.js} +6 -6
  28. package/dist/{chunk-I66ZTYNP.js → chunk-AF4YM7Z4.js} +236 -101
  29. package/dist/{chunk-2HFQNRV3.js → chunk-AX2THNSA.js} +12 -12
  30. package/dist/{chunk-PGF63K6I.js → chunk-B4OAX3SI.js} +65 -3
  31. package/dist/{chunk-W6NIE6OW.js → chunk-B4VEBZKF.js} +3 -3
  32. package/dist/{chunk-JBCS7CRR.js → chunk-BEPZRGGU.js} +10 -10
  33. package/dist/{chunk-XGDPUNND.js → chunk-CE5AX47J.js} +2 -2
  34. package/dist/{chunk-I64IFBLB.js → chunk-DWUOQKRU.js} +17 -10
  35. package/dist/{chunk-DZAW46HP.js → chunk-E3TPLWFX.js} +3 -3
  36. package/dist/{chunk-HIICAHCJ.js → chunk-EKCHAPYA.js} +2 -2
  37. package/dist/{chunk-XE3PCIXH.js → chunk-F5JHEYZM.js} +7 -7
  38. package/dist/{chunk-5PFYMY2V.js → chunk-FTMGRKEF.js} +2 -2
  39. package/dist/{chunk-ZNT2M6TG.js → chunk-G76U63X4.js} +17 -17
  40. package/dist/{chunk-34BHNEE3.js → chunk-GHS5EBTQ.js} +58 -7
  41. package/dist/{chunk-2NHR3NAY.js → chunk-GI7YYQ3F.js} +40 -34
  42. package/dist/{chunk-DYHAXKHD.js → chunk-GWZNEVM2.js} +12 -8
  43. package/dist/chunk-GYV6VZOC.js +26 -0
  44. package/dist/{chunk-MQXIVJ35.js → chunk-HAXOFFRH.js} +5 -5
  45. package/dist/{chunk-W4YEMFBX.js → chunk-HEQY7ZFI.js} +2 -2
  46. package/dist/{chunk-IKOZFYBN.js → chunk-I7ZPNEJM.js} +145 -102
  47. package/dist/{chunk-WNP7O5WZ.js → chunk-ID64D7PE.js} +4 -4
  48. package/dist/{chunk-XQRY4DTA.js → chunk-IGLP3ODT.js} +10 -10
  49. package/dist/chunk-IJNZMHLA.js +101 -0
  50. package/dist/{chunk-JWJGP5DQ.js → chunk-INY6HTFL.js} +7 -7
  51. package/dist/{chunk-PBP4B7XR.js → chunk-IUE3Y34X.js} +2 -2
  52. package/dist/{chunk-B74PXLU7.js → chunk-IWT4SF4R.js} +3 -3
  53. package/dist/{chunk-B7HM5Z7T.js → chunk-JDAY6FIL.js} +5 -5
  54. package/dist/{chunk-PJX3WQUQ.js → chunk-JEQ3XTHC.js} +2 -2
  55. package/dist/{chunk-FSP7CMNU.js → chunk-JGRC33J2.js} +50 -4
  56. package/dist/{chunk-X7IARSHT.js → chunk-JKKCYP3C.js} +9 -9
  57. package/dist/{chunk-HJWWJ6IL.js → chunk-JSC3U7TI.js} +16 -4
  58. package/dist/{chunk-SSEYRH53.js → chunk-KK4JZPBQ.js} +19 -140
  59. package/dist/{chunk-IHXBNWMM.js → chunk-KXDSS5WJ.js} +7 -3
  60. package/dist/{chunk-Q4XWMHX6.js → chunk-L47TF46W.js} +2 -2
  61. package/dist/{chunk-O3YUNJZ2.js → chunk-LDJG7DW3.js} +81 -24
  62. package/dist/{chunk-CDNVLKUX.js → chunk-LLDJM5XK.js} +13 -7
  63. package/dist/{chunk-F2I26BDK.js → chunk-MUW2BDDH.js} +4 -4
  64. package/dist/{chunk-HKMD33FO.js → chunk-MWUZBSAQ.js} +79 -76
  65. package/dist/{chunk-QQLGQY2A.js → chunk-N2Z7HLVY.js} +20 -20
  66. package/dist/{chunk-DZEK6CJN.js → chunk-NIQJ66N4.js} +19 -19
  67. package/dist/{chunk-CWVRRIEI.js → chunk-NZMNUPZZ.js} +2 -2
  68. package/dist/{chunk-462T4EGZ.js → chunk-O5CVSAG5.js} +2 -2
  69. package/dist/{chunk-TPEQIQIE.js → chunk-OML5D5V5.js} +8 -8
  70. package/dist/{chunk-IKSLQ4XV.js → chunk-PAJQJ7BS.js} +558 -216
  71. package/dist/{chunk-ZW55JB7N.js → chunk-PUVDKJ2Y.js} +2 -2
  72. package/dist/{chunk-UH347SHR.js → chunk-QWGDJJYJ.js} +11 -11
  73. package/dist/chunk-R6Q67RJH.js +134 -0
  74. package/dist/{chunk-CRFOIAX3.js → chunk-RRNP2ANY.js} +6 -6
  75. package/dist/{chunk-IDNA72AH.js → chunk-RSJ25QSL.js} +2 -2
  76. package/dist/chunk-SKHCAU7K.js +385 -0
  77. package/dist/{chunk-RLYRBIYQ.js → chunk-TM6LQDI3.js} +20 -12
  78. package/dist/chunk-UOIZ7DA4.js +41 -0
  79. package/dist/{chunk-P75RZCJW.js → chunk-UPZU6GE4.js} +3 -3
  80. package/dist/{chunk-MCMZMDAC.js → chunk-V2ANDPVT.js} +4 -4
  81. package/dist/{chunk-AK5XEFVZ.js → chunk-VA5FNYMT.js} +26 -13
  82. package/dist/{chunk-IMXMHHMQ.js → chunk-VW6DOEDG.js} +332 -57
  83. package/dist/{chunk-XOXV5GKE.js → chunk-W6RRQCPQ.js} +16 -7
  84. package/dist/{chunk-CYZW7JHJ.js → chunk-WBKFA554.js} +8 -8
  85. package/dist/{chunk-BO7Y52RY.js → chunk-WCXUNS7U.js} +7 -7
  86. package/dist/{chunk-ZGNYYXQ6.js → chunk-WRBAGUNF.js} +3 -3
  87. package/dist/{chunk-FVDGR2ZL.js → chunk-XIVNBFZS.js} +85 -30
  88. package/dist/{chunk-BYMNWQ7O.js → chunk-XPWWI35G.js} +299 -58
  89. package/dist/{chunk-KPXDY6QF.js → chunk-XRZT5WY5.js} +2 -2
  90. package/dist/{chunk-AZ4WMN4W.js → chunk-Y3CBHOR6.js} +2 -2
  91. package/dist/{chunk-VXMFAE2W.js → chunk-YPC6ZR5L.js} +19 -6
  92. package/dist/{chunk-54ODD65L.js → chunk-YQWYVTMC.js} +4 -4
  93. package/dist/{chunk-M2WXEHER.js → chunk-ZA4VCIGV.js} +2 -2
  94. package/dist/{chunk-7BHIY2MW.js → chunk-ZDN3Y73Y.js} +6 -6
  95. package/dist/{chunk-E7GT7O5N.js → chunk-ZWPRK62N.js} +7 -4
  96. package/dist/cli/index.js +38 -37
  97. package/dist/{clio-7VB377CC.js → clio-CMMK4KRR.js} +7 -7
  98. package/dist/{code-nav-YVLCYA7V.js → code-nav-MDZNQS33.js} +7 -7
  99. package/dist/{components-UBWCQSRW.js → components-UCUQ4QXW.js} +4 -4
  100. package/dist/{config-4HVOS65E.js → config-SVM5P5YI.js} +76 -74
  101. package/dist/{configure-PIWO7B24.js → configure-LE3IK2TJ.js} +26 -24
  102. package/dist/{context-IYEHL3WQ.js → context-2OHRKS42.js} +66 -63
  103. package/dist/{context-N6ZE3LGJ.js → context-E3VC7RX5.js} +15 -11
  104. package/dist/{context-KQYIWPWT.js → context-VNCR7KAG.js} +60 -45
  105. package/dist/{context-clear-G4OGZJDS.js → context-clear-BW4O37TG.js} +61 -59
  106. package/dist/context-map-COB37XXN.js +505 -0
  107. package/dist/{context-working-set-BWLF6LJP.js → context-working-set-VDS25HXZ.js} +17 -16
  108. package/dist/{dispatch-runner-2QQAITS3.js → dispatch-runner-5AHT53RF.js} +85 -74
  109. package/dist/{doctor-LHBD36VU.js → doctor-WNNVO6FY.js} +37 -37
  110. package/dist/{eval-C45FYRJ6.js → eval-7G7SGAYO.js} +285 -114
  111. package/dist/{eval-inventory-6DEJPLBF.js → eval-inventory-Y6QRFOH5.js} +4 -4
  112. package/dist/{evidence-6SHONYAF.js → evidence-VD6736FQ.js} +63 -62
  113. package/dist/{evolve-KRKMV72X.js → evolve-AL3NGVRL.js} +62 -61
  114. package/dist/{extensions-KPZ2UHBB.js → extensions-MOVJ32NM.js} +7 -7
  115. package/dist/{fleet-IVTCKDHT.js → fleet-QZHUMAGI.js} +110 -108
  116. package/dist/{fleet-commands-EDWL3IT7.js → fleet-commands-BAYT5FJZ.js} +10 -10
  117. package/dist/{fleet-decisions-YP3YEFGK.js → fleet-decisions-IREVMRU4.js} +7 -6
  118. package/dist/{fleet-graph-ZFWKHY2M.js → fleet-graph-YCTT3HTI.js} +19 -18
  119. package/dist/{fleet-inspect-FVUNCBML.js → fleet-inspect-QVJTDAVB.js} +55 -54
  120. package/dist/{fleet-preflight-UN5XED4R.js → fleet-preflight-25QAFPK4.js} +4 -4
  121. package/dist/{fleet-validate-XOWC4HSX.js → fleet-validate-5O57AAJ7.js} +23 -22
  122. package/dist/{fleet-verify-UN3SODEL.js → fleet-verify-CPH2W2T6.js} +56 -55
  123. package/dist/{fleet-view-TWHJKCN6.js → fleet-view-SWBR3VGQ.js} +55 -54
  124. package/dist/{init-T2QORQ3Y.js → init-J477LKZH.js} +78 -76
  125. package/dist/{interop-IN5I2A66.js → interop-3FCM6XLG.js} +11 -11
  126. package/dist/{library-LSCATDLZ.js → library-QUQEIUG6.js} +28 -27
  127. package/dist/{memory-HYOKAGGJ.js → memory-SGGSEP65.js} +64 -63
  128. package/dist/{models-2GPMFYCM.js → models-HEKUAXXK.js} +49 -43
  129. package/dist/{monitor-E4ASVUJH.js → monitor-HKU57TYQ.js} +61 -60
  130. package/dist/{orchestrator-DDMPR3PY.js → orchestrator-VDFAEFAI.js} +919 -546
  131. package/dist/{panes-E3RUXOW5.js → panes-DN2SSFOH.js} +3 -3
  132. package/dist/{panes-IXKLOKA2.js → panes-TALGNPZT.js} +8 -8
  133. package/dist/{paths-L7LGY6RN.js → paths-NBMFAIEZ.js} +5 -5
  134. package/dist/reset-EAJFFJVB.js +344 -0
  135. package/dist/{resources-OTRSN34L.js → resources-OVKSEFVE.js} +27 -20
  136. package/dist/{run-5DEYH5QK.js → run-7DP7ZF2J.js} +113 -109
  137. package/dist/{share-IHWTLO3M.js → share-WML67FT3.js} +26 -25
  138. package/dist/{skills-IYMXMKW4.js → skills-SG662R2K.js} +39 -31
  139. package/dist/{skills-eval-DROHSJAR.js → skills-eval-VVZEUU46.js} +74 -73
  140. package/dist/{skills-inventory-D7X4L4ZX.js → skills-inventory-I2E23GET.js} +21 -20
  141. package/dist/{slash-commands-QBM7UZ3B.js → slash-commands-S7MBJDQK.js} +35 -34
  142. package/dist/{steer-Z5DO23FJ.js → steer-2LQOMCPB.js} +3 -3
  143. package/dist/{support-U7QOWY26.js → support-CC2UJBJ6.js} +6 -6
  144. package/dist/{targets-P2FUC4IL.js → targets-4QC3HIEW.js} +48 -45
  145. package/dist/{terminal-lease-YREJ3JX2.js → terminal-lease-TUHIJ6Y2.js} +2 -2
  146. package/dist/{tools-5B7RO6MV.js → tools-TFGJICCU.js} +8 -8
  147. package/dist/{trace-YMGMUM6A.js → trace-FXMXUZUF.js} +7 -7
  148. package/dist/uninstall-5PEVOE5B.js +408 -0
  149. package/dist/upgrade-M4WXY6KN.js +303 -0
  150. package/dist/{usage-ME5MPXGX.js → usage-N7ZNVLEM.js} +147 -102
  151. package/dist/{verifiers-BVZ7IWOO.js → verifiers-DJTP4XX6.js} +15 -15
  152. package/dist/{verify-5K7ZKQFC.js → verify-RWE4PPEK.js} +9 -9
  153. package/dist/{wiki-generate-F5W5QTYY.js → wiki-generate-C7IQOXSP.js} +84 -82
  154. package/dist/{with-panes-BYOJCLAM.js → with-panes-4GCGSL7J.js} +9 -9
  155. package/dist/worker/entry.js +61 -60
  156. package/docs/architecture/artifact-placement.md +1 -0
  157. package/docs/architecture/artifact-versions.md +1 -1
  158. package/docs/architecture/context-engine.md +4 -0
  159. package/docs/architecture/middleware-and-components.md +1 -1
  160. package/docs/architecture/model-catalog.md +21 -10
  161. package/docs/architecture/observability.md +12 -1
  162. package/docs/architecture/prompt-envelope-and-tools.md +2 -0
  163. package/docs/architecture/provider-adapter-cookbook.md +63 -0
  164. package/docs/architecture/safety-model.md +15 -5
  165. package/docs/guide/built-in-agents.md +17 -3
  166. package/docs/guide/commands-and-modes.md +1 -1
  167. package/docs/guide/configuration-and-targets.md +97 -9
  168. package/docs/guide/configuration-reference.md +7 -2
  169. package/docs/guide/environment-variables.md +2 -0
  170. package/docs/guide/installation-and-lifecycle.md +37 -4
  171. package/docs/guide/proactive-memory.md +66 -55
  172. package/docs/guide/skills-marketplace.md +18 -0
  173. package/docs/process/development-pipeline.md +34 -1
  174. package/docs/process/eval-runner.md +67 -3
  175. package/evals/behavioral-model.yaml +3 -2
  176. package/package.json +2 -2
  177. package/skills/README.md +7 -5
  178. package/skills/coding/ast-grep/SKILL.md +101 -30
  179. package/skills/coding/ast-grep/evals.md +26 -0
  180. package/skills/coding/coding-standards/SKILL.md +40 -5
  181. package/skills/coding/coding-standards/evals.md +23 -0
  182. package/skills/coding/prototype/SKILL.md +87 -28
  183. package/skills/coding/prototype/evals.md +19 -0
  184. package/skills/coding/tdd/SKILL.md +80 -53
  185. package/skills/coding/tdd/evals.md +20 -0
  186. package/skills/context/context-handoff/SKILL.md +43 -2
  187. package/skills/context/context-handoff/evals.md +44 -0
  188. package/skills/context/context-prime/SKILL.md +45 -15
  189. package/skills/context/context-prime/evals.md +45 -0
  190. package/skills/git/branch-closeout/SKILL.md +132 -0
  191. package/skills/git/branch-closeout/evals.md +133 -0
  192. package/skills/git/branch-closeout/references/closeout-checklist.md +81 -0
  193. package/skills/git/file-ticket/SKILL.md +77 -63
  194. package/skills/git/file-ticket/assets/issue-template.md +22 -0
  195. package/skills/git/file-ticket/evals.md +31 -26
  196. package/skills/git/file-ticket/references/issue-discovery.md +49 -0
  197. package/skills/git/fix-issue/SKILL.md +87 -64
  198. package/skills/git/fix-issue/evals.md +35 -31
  199. package/skills/git/fix-issue/references/diagnosis-and-rca.md +46 -0
  200. package/skills/git/resolve-merge-conflicts/SKILL.md +100 -51
  201. package/skills/git/resolve-merge-conflicts/evals.md +52 -25
  202. package/skills/git/resolve-merge-conflicts/references/conflict-matrix.md +126 -0
  203. package/skills/git/ship/SKILL.md +103 -67
  204. package/skills/git/ship/assets/pr-template.md +21 -0
  205. package/skills/git/ship/evals.md +44 -28
  206. package/skills/git/ship/references/remote-and-branch-policy.md +62 -0
  207. package/skills/git/worktree-create/SKILL.md +80 -50
  208. package/skills/git/worktree-create/evals.md +40 -33
  209. package/skills/git/worktree-create/references/worktree-setup.md +62 -66
  210. package/skills/git/worktree-merge/SKILL.md +112 -65
  211. package/skills/git/worktree-merge/evals.md +42 -34
  212. package/skills/git/worktree-merge/references/merge-strategies.md +52 -0
  213. package/skills/planning/archify/SKILL.md +196 -0
  214. package/skills/planning/archify/evals.md +65 -0
  215. package/skills/planning/architecture/SKILL.md +61 -12
  216. package/skills/planning/architecture/evals.md +65 -0
  217. package/skills/planning/backlog/SKILL.md +130 -14
  218. package/skills/planning/backlog/evals.md +142 -0
  219. package/skills/planning/prd/SKILL.md +46 -6
  220. package/skills/planning/prd/evals.md +54 -0
  221. package/skills/planning/product-intent/SKILL.md +57 -2
  222. package/skills/planning/product-intent/evals.md +70 -0
  223. package/skills/planning/tech-spec/SKILL.md +53 -2
  224. package/skills/planning/tech-spec/evals.md +73 -0
  225. package/skills/registry.yaml +58 -50
  226. package/skills/remote.yaml +13 -0
  227. package/skills/research/arxiv-literature/SKILL.md +76 -18
  228. package/skills/research/arxiv-literature/evals.md +50 -0
  229. package/skills/research/experiment-protocol/SKILL.md +20 -1
  230. package/skills/research/experiment-protocol/evals.md +23 -0
  231. package/skills/research/scientific-debugging/SKILL.md +23 -1
  232. package/skills/research/scientific-debugging/evals.md +18 -0
  233. package/skills/research/scientific-modernization/SKILL.md +26 -1
  234. package/skills/research/scientific-modernization/evals.md +27 -0
  235. package/skills/skill-marketplace.json +63 -28
  236. package/skills/workflow/cut-it/SKILL.md +65 -5
  237. package/skills/workflow/cut-it/evals.md +101 -0
  238. package/skills/workflow/design-council/SKILL.md +117 -27
  239. package/skills/workflow/design-council/evals.md +161 -0
  240. package/skills/workflow/grill-me/SKILL.md +86 -10
  241. package/skills/workflow/grill-me/evals.md +153 -0
  242. package/skills/workflow/workflow-distiller/SKILL.md +76 -17
  243. package/skills/workflow/workflow-distiller/evals.md +118 -0
  244. package/src/cli/configure-interop.ts +105 -13
  245. package/src/cli/configure-oauth.ts +57 -0
  246. package/src/cli/configure-onboarding.ts +980 -0
  247. package/src/cli/configure-target.ts +594 -0
  248. package/src/cli/configure.ts +1082 -528
  249. package/src/cli/context-map.ts +114 -0
  250. package/src/cli/context.ts +4 -0
  251. package/src/cli/index.ts +1 -0
  252. package/src/cli/lifecycle-presenter.ts +436 -0
  253. package/src/cli/models.ts +10 -2
  254. package/src/cli/modes/print.ts +5 -1
  255. package/src/cli/reset.ts +228 -106
  256. package/src/cli/run.ts +7 -2
  257. package/src/cli/select.ts +664 -0
  258. package/src/cli/skills.ts +9 -2
  259. package/src/cli/targets.ts +3 -0
  260. package/src/cli/uninstall.ts +233 -165
  261. package/src/cli/upgrade.ts +204 -149
  262. package/src/cli/usage.ts +86 -27
  263. package/src/cli/validate-model.ts +3 -3
  264. package/src/core/config.ts +56 -0
  265. package/src/core/external-diagnostic.ts +44 -0
  266. package/src/core/gateway-routing.ts +157 -0
  267. package/src/core/safe-exec.ts +17 -2
  268. package/src/core/skill-activation.ts +89 -2
  269. package/src/domains/agents/builtins/world-knowledge.md +31 -0
  270. package/src/domains/agents/catalog.ts +1 -1
  271. package/src/domains/agents/result-contract.ts +70 -0
  272. package/src/domains/context/wiki/map-seed.ts +589 -0
  273. package/src/domains/context/wiki/plan.ts +2 -2
  274. package/src/domains/dispatch/admission.ts +29 -0
  275. package/src/domains/dispatch/agent-candidates.ts +10 -0
  276. package/src/domains/dispatch/budget-envelope.ts +86 -1
  277. package/src/domains/dispatch/capability-match.ts +1 -0
  278. package/src/domains/dispatch/capacity-lease.ts +17 -0
  279. package/src/domains/dispatch/contract.ts +11 -1
  280. package/src/domains/dispatch/extension.ts +134 -29
  281. package/src/domains/dispatch/types.ts +3 -0
  282. package/src/domains/dispatch/worker-model-metadata.ts +38 -0
  283. package/src/domains/eval/metrics/call-ledger-stream.ts +34 -11
  284. package/src/domains/eval/metrics/token-stream.ts +201 -31
  285. package/src/domains/eval/metrics/tracked.ts +40 -4
  286. package/src/domains/eval/runners/clio-run.ts +5 -2
  287. package/src/domains/eval/schema/suite.ts +28 -0
  288. package/src/domains/eval/schema/verdict.ts +2 -2
  289. package/src/domains/eval/suites/resolve.ts +13 -1
  290. package/src/domains/eval/suites/run.ts +24 -3
  291. package/src/domains/interop/registry.ts +6 -2
  292. package/src/domains/interop/types.ts +4 -0
  293. package/src/domains/lifecycle/migrations/index.ts +4 -0
  294. package/src/domains/memory/task-memory-policy.ts +70 -26
  295. package/src/domains/memory/task-memory-telemetry.ts +1 -0
  296. package/src/domains/middleware/index.ts +0 -1
  297. package/src/domains/middleware/marketplace-offer.ts +3 -35
  298. package/src/domains/middleware/memory-intervention.ts +127 -32
  299. package/src/domains/middleware/memory-step-endpoint.ts +3 -2
  300. package/src/domains/middleware/skills-reminder.ts +31 -2
  301. package/src/domains/observability/compaction-usage.ts +118 -0
  302. package/src/domains/observability/cost.ts +1 -1
  303. package/src/domains/observability/extension.ts +6 -1
  304. package/src/domains/observability/out-of-turn-usage.ts +52 -21
  305. package/src/domains/providers/contract.ts +4 -1
  306. package/src/domains/providers/extension.ts +40 -9
  307. package/src/domains/providers/model-capabilities.ts +9 -0
  308. package/src/domains/providers/model-discovery.ts +2 -0
  309. package/src/domains/providers/model-runtime-capabilities.ts +15 -5
  310. package/src/domains/providers/models/local-models/clio-coder-local-coding-targets.yaml +32 -12
  311. package/src/domains/providers/runtimes/antigravity/antigravity-code.ts +225 -45
  312. package/src/domains/providers/runtimes/common/lmstudio-http.ts +6 -2
  313. package/src/domains/providers/runtimes/common/local-synth.ts +2 -0
  314. package/src/domains/providers/runtimes/protocol/litellm.ts +119 -29
  315. package/src/domains/providers/support.ts +11 -5
  316. package/src/domains/providers/target-model-cache.ts +25 -2
  317. package/src/domains/providers/types/capability-flags.ts +2 -0
  318. package/src/domains/providers/types/runtime-descriptor.ts +20 -1
  319. package/src/domains/providers/types/target-descriptor.ts +19 -0
  320. package/src/domains/resources/index.ts +3 -0
  321. package/src/domains/resources/skills/install.ts +72 -7
  322. package/src/domains/resources/skills/loader.ts +7 -0
  323. package/src/domains/resources/skills/marketplace.ts +63 -11
  324. package/src/domains/safety/autonomy.ts +15 -0
  325. package/src/domains/safety/index.ts +1 -0
  326. package/src/domains/safety/path-policy.ts +1 -1
  327. package/src/domains/safety/policy-engine.ts +34 -11
  328. package/src/domains/safety/protected-artifacts.ts +191 -88
  329. package/src/domains/safety/run-effects.ts +2 -22
  330. package/src/domains/safety/skill-authority.ts +55 -0
  331. package/src/domains/session/compaction/compact.ts +72 -22
  332. package/src/domains/session/entries.ts +6 -0
  333. package/src/domains/session/usage.ts +3 -3
  334. package/src/engine/agent.ts +13 -3
  335. package/src/engine/ai.ts +26 -8
  336. package/src/engine/antigravity/subprocess-runtime.ts +386 -120
  337. package/src/engine/api-registry.ts +3 -0
  338. package/src/engine/apis/openai-completions.ts +117 -14
  339. package/src/engine/external-subprocess.ts +114 -6
  340. package/src/entry/background-model-metadata.ts +18 -0
  341. package/src/entry/compaction-prompt.ts +57 -0
  342. package/src/entry/orchestrator.ts +405 -216
  343. package/src/entry/task-memory-lifecycle.ts +35 -0
  344. package/src/interactive/chat-loop-messages.ts +13 -4
  345. package/src/interactive/chat-loop.ts +65 -2
  346. package/src/interactive/chat-renderer.ts +1 -0
  347. package/src/interactive/cost-overlay.ts +26 -2
  348. package/src/interactive/interactive-slash-runtime.ts +2 -1
  349. package/src/interactive/renderers/worker-entry.ts +32 -0
  350. package/src/interactive/slash-commands.ts +24 -6
  351. package/src/interactive/theme/labels.ts +19 -13
  352. package/src/interactive/turn-context.ts +9 -5
  353. package/src/interactive/turn-recovery.ts +8 -0
  354. package/src/interactive/turn-runtime.ts +27 -11
  355. package/src/interactive/turn-state.ts +7 -0
  356. package/src/interactive/worker-receipts.ts +1 -0
  357. package/src/interactive/worker-stream.ts +6 -1
  358. package/src/tools/context/index.ts +30 -9
  359. package/src/tools/dispatch-arguments.ts +1 -0
  360. package/src/tools/dispatch-event-text.ts +10 -0
  361. package/src/tools/dispatch-plan.ts +1 -0
  362. package/src/tools/dispatch-runner.ts +12 -0
  363. package/src/tools/registry.ts +11 -5
  364. package/src/tools/worker-evidence.ts +3 -1
  365. package/src/worker/spec-contract.ts +4 -0
  366. package/dist/chunk-2Z2IKEXI.js +0 -1554
  367. package/dist/reset-OAQP3W4O.js +0 -230
  368. package/dist/uninstall-N34PCTGJ.js +0 -331
  369. package/dist/upgrade-PXK3S2YM.js +0 -325
@@ -12,7 +12,7 @@ import {
12
12
  projectWorkingSet,
13
13
  resolveWorkingSetPolicy,
14
14
  selectVisibleEntries
15
- } from "./chunk-M2WXEHER.js";
15
+ } from "./chunk-ZA4VCIGV.js";
16
16
  import {
17
17
  assistantSessionPayload,
18
18
  attachedToolSchemasFromState,
@@ -47,63 +47,92 @@ import {
47
47
  toolNamesFromAgentState,
48
48
  toolResultSummary,
49
49
  toolSignatureFromState
50
- } from "./chunk-XOXV5GKE.js";
51
- import {
52
- ToolchainDomainModule
53
- } from "./chunk-HRQMFLJP.js";
50
+ } from "./chunk-W6RRQCPQ.js";
54
51
  import {
55
52
  ShareDomainModule
56
- } from "./chunk-UH347SHR.js";
53
+ } from "./chunk-QWGDJJYJ.js";
57
54
  import {
58
55
  bootstrapInputFromInitOptions,
59
56
  modelBootstrapGenerate,
60
57
  resolveBootstrapRoute
61
- } from "./chunk-DZEK6CJN.js";
58
+ } from "./chunk-NIQJ66N4.js";
62
59
  import "./chunk-MNJGS2IN.js";
63
60
  import {
64
61
  SchedulingDomainModule,
65
62
  createPromptsDomainModule,
66
63
  renderAgentCatalogSectionsFromSpecs
67
- } from "./chunk-BO7Y52RY.js";
64
+ } from "./chunk-WCXUNS7U.js";
65
+ import {
66
+ recordFailedCompactionCalls
67
+ } from "./chunk-IJNZMHLA.js";
68
68
  import {
69
69
  capturedHookSourcesFor
70
70
  } from "./chunk-SZAA6XDG.js";
71
71
  import {
72
72
  SafetyDomainModule
73
- } from "./chunk-54ODD65L.js";
73
+ } from "./chunk-YQWYVTMC.js";
74
74
  import {
75
75
  LifecycleDomainModule,
76
76
  describeUpgradeNotice
77
- } from "./chunk-F2I26BDK.js";
78
- import "./chunk-DYHAXKHD.js";
79
- import "./chunk-QQLGQY2A.js";
80
- import {
81
- ensureClioState,
82
- takeUpgradeNotice
83
- } from "./chunk-XQRY4DTA.js";
84
- import "./chunk-3KIPBMUA.js";
77
+ } from "./chunk-MUW2BDDH.js";
78
+ import "./chunk-GWZNEVM2.js";
79
+ import "./chunk-5ICU3EUH.js";
85
80
  import {
86
81
  ConfigDomainModule,
87
82
  createConfigDomainModule,
88
83
  loadDomains
89
- } from "./chunk-CYZW7JHJ.js";
84
+ } from "./chunk-WBKFA554.js";
85
+ import {
86
+ monitorToolSurface
87
+ } from "./chunk-JEQ3XTHC.js";
88
+ import {
89
+ ObservabilityDomainModule,
90
+ readAccountabilitySummary,
91
+ recordBackgroundMemoryStep,
92
+ resolveDispatchFailureStatus
93
+ } from "./chunk-MWUZBSAQ.js";
94
+ import {
95
+ appendOutOfTurnUsageRow
96
+ } from "./chunk-VA5FNYMT.js";
90
97
  import {
91
98
  steerToolSurface
92
- } from "./chunk-W4YEMFBX.js";
99
+ } from "./chunk-HEQY7ZFI.js";
93
100
  import {
94
101
  panesToolSurface
95
- } from "./chunk-2X4RYJTJ.js";
102
+ } from "./chunk-4UVU7BJ5.js";
96
103
  import {
97
104
  describePanesLeftBehind,
98
105
  paneWatchDecision
99
106
  } from "./chunk-3EBYEESD.js";
100
- import "./chunk-3M6DQK6S.js";
101
107
  import {
102
108
  flushRawStdout,
103
109
  writeRawStdout
104
110
  } from "./chunk-2VTFPG5O.js";
105
- import "./chunk-M2DAX4F6.js";
106
- import "./chunk-D4CJV46V.js";
111
+ import "./chunk-4WR7VSYB.js";
112
+ import {
113
+ createContextDomainModule,
114
+ loadProjectClioMd
115
+ } from "./chunk-KK4JZPBQ.js";
116
+ import "./chunk-R6Q67RJH.js";
117
+ import {
118
+ renderCodewikiDigest
119
+ } from "./chunk-Y3CBHOR6.js";
120
+ import {
121
+ buildMemoryPromptSection,
122
+ canonicalMemoryRepositoryIdentity,
123
+ createTaskMemoryTrace,
124
+ describeTaskMemoryActivity,
125
+ formatTaskMemorySpend,
126
+ loadMemoryRecordsSync,
127
+ proposeInjectedTaskMemory,
128
+ proposeMemoryPromotion,
129
+ readTaskMemorySpendSummary,
130
+ renderTaskMemoryHandoffSource,
131
+ seedTaskMemoryFromNewestHandoff,
132
+ taskMemoryBankSize,
133
+ taskMemoryHandoffSeedOffer,
134
+ taskMemoryTracePath
135
+ } from "./chunk-BEPZRGGU.js";
107
136
  import {
108
137
  BUILTIN_SLASH_COMMANDS,
109
138
  COMPLETION_SLOT_NAMES,
@@ -124,38 +153,187 @@ import {
124
153
  workerAskedByModel,
125
154
  workerReceiptSummary,
126
155
  workerTargetLabel
127
- } from "./chunk-RLYRBIYQ.js";
156
+ } from "./chunk-TM6LQDI3.js";
128
157
  import "./chunk-35MSIRKH.js";
129
158
  import {
130
159
  discoverDeclaredChecks
131
- } from "./chunk-MCMZMDAC.js";
160
+ } from "./chunk-V2ANDPVT.js";
161
+ import {
162
+ listWikiPages,
163
+ wikiCompleteness,
164
+ wikiStaleness,
165
+ wikiStalenessAsync
166
+ } from "./chunk-NDINPTJ4.js";
167
+ import "./chunk-MXHC5QYU.js";
132
168
  import {
133
169
  buildRecallFields,
134
170
  recallErrorMessage,
135
171
  recallParentTurnId,
136
172
  recallableRefListing,
137
173
  resolveRecall
138
- } from "./chunk-462T4EGZ.js";
174
+ } from "./chunk-O5CVSAG5.js";
139
175
  import {
140
176
  foldWorkingSet,
141
177
  isTurnStart
142
178
  } from "./chunk-GTUD2WMY.js";
179
+ import {
180
+ classifyLibraryRequirements,
181
+ createResourcesDomainModule,
182
+ discoverLibrary,
183
+ installLibraryPlan,
184
+ libraryEntryInstalled,
185
+ libraryEntryPin,
186
+ libraryEntryRef,
187
+ libraryInstallPath,
188
+ planLibraryInstall
189
+ } from "./chunk-G76U63X4.js";
190
+ import {
191
+ AgentsDomainModule
192
+ } from "./chunk-UPZU6GE4.js";
193
+ import "./chunk-RRNP2ANY.js";
194
+ import "./chunk-DR52UMZW.js";
143
195
  import {
144
196
  compileScoutTransition
145
- } from "./chunk-UH632ZYL.js";
197
+ } from "./chunk-2UH2KFUP.js";
146
198
  import {
147
- monitorToolSurface
148
- } from "./chunk-PJX3WQUQ.js";
199
+ ACP_AGENT_META_KEY,
200
+ ACP_MAX_CHUNK_BYTES,
201
+ ACP_MAX_RAW_RECORD_BYTES,
202
+ ACP_MAX_STRING_BYTES,
203
+ ACP_MAX_TOOL_CALL_ID_BYTES,
204
+ ACP_SESSION_META_KEY,
205
+ ACP_TURN_FAILED_MESSAGE,
206
+ ACP_USAGE_META_KEY,
207
+ AcpRequestError,
208
+ AcpTimeoutError,
209
+ COST_NOT_MEASURED,
210
+ acpErrorMessage,
211
+ aggregateCostAmounts,
212
+ capacityLeaseUsage,
213
+ costAggregateForAmount,
214
+ createDispatchDomainModule,
215
+ createDispatchRunEventRegistry,
216
+ createRunReceiptQuality,
217
+ createStdioServerTransport,
218
+ endpointCapacityUsage,
219
+ evidenceDirectory,
220
+ executeFleetRun,
221
+ formatCostAggregate,
222
+ inspectEvidence,
223
+ listEvidenceOverviews,
224
+ openLedger,
225
+ protectedResidencyModels,
226
+ renderCostAggregate,
227
+ renderDispatchReviewerTask
228
+ } from "./chunk-AF4YM7Z4.js";
149
229
  import {
150
- ObservabilityDomainModule,
151
- readAccountabilitySummary,
152
- recordBackgroundMemoryStep,
153
- resolveDispatchFailureStatus
154
- } from "./chunk-HKMD33FO.js";
230
+ describeWriteBoundaryAttributionDowngrade,
231
+ gitCheckoutRoot,
232
+ isGitRepository,
233
+ preflightWriteBoundaries,
234
+ recoverCleanupReadyCompeteGroups
235
+ } from "./chunk-B4VEBZKF.js";
155
236
  import {
156
- appendOutOfTurnUsageRow
157
- } from "./chunk-AK5XEFVZ.js";
237
+ bindExecutionPlanEndpoints,
238
+ compileFleetExecutionPlan,
239
+ requireAgentSteps
240
+ } from "./chunk-E3TPLWFX.js";
241
+ import {
242
+ readGateDecisionArtifacts,
243
+ readPendingGateDecisions
244
+ } from "./chunk-WRBAGUNF.js";
245
+ import {
246
+ TRUST_STATUS_AXES,
247
+ formatTrustSummaryLine,
248
+ inspectRunReceiptTrustStatus,
249
+ isReceiptIntegrity,
250
+ retiredReceiptIntegrity,
251
+ retiredReceiptIntegrityReason,
252
+ summarizeTrustStatus,
253
+ trustStateWord,
254
+ verifyReceiptIntegrity
255
+ } from "./chunk-IWT4SF4R.js";
256
+ import {
257
+ SessionDomainModule,
258
+ addResponseModelIdObservationCount,
259
+ addResponseModelIdObservationCounts,
260
+ attributedModelId,
261
+ collectSessionEntries,
262
+ emptyResponseModelIdObservationCounts,
263
+ ledgerUsageCalls,
264
+ protectedArtifactEntryFromArtifact,
265
+ protectedArtifactStateFromSessionEntries,
266
+ readAuditRows,
267
+ responseModelIdObservationCountsLabel,
268
+ responseModelIdObservationFromRecord
269
+ } from "./chunk-JKKCYP3C.js";
270
+ import "./chunk-FTMGRKEF.js";
271
+ import "./chunk-XRZT5WY5.js";
272
+ import {
273
+ parseRigorOverride,
274
+ resolveRigor
275
+ } from "./chunk-RVG5JXAL.js";
276
+ import {
277
+ configureRunEventJournal
278
+ } from "./chunk-VIA6RFQZ.js";
279
+ import "./chunk-T56WDKA5.js";
280
+ import {
281
+ filterEntriesToActivePath
282
+ } from "./chunk-W6GROXXM.js";
283
+ import {
284
+ FLEET_COMMANDS_REMEDY,
285
+ FleetCommandRegistryMissingError,
286
+ fleetStepBoundaries,
287
+ loadFleetCommands,
288
+ loadFleetContract,
289
+ renderFleetPrompt,
290
+ validateFleetCommands,
291
+ validateFleetGraph
292
+ } from "./chunk-2VIKGWFZ.js";
293
+ import "./chunk-RKKLTLYB.js";
294
+ import "./chunk-6PTFB5VS.js";
295
+ import {
296
+ shellQuote
297
+ } from "./chunk-TXOTCRLG.js";
298
+ import {
299
+ ToolchainDomainModule
300
+ } from "./chunk-HRQMFLJP.js";
301
+ import "./chunk-N2Z7HLVY.js";
302
+ import {
303
+ ensureClioState,
304
+ takeUpgradeNotice
305
+ } from "./chunk-IGLP3ODT.js";
158
306
  import "./chunk-VKPAQYEB.js";
307
+ import "./chunk-3M6DQK6S.js";
308
+ import "./chunk-LCGCVYZ4.js";
309
+ import {
310
+ MARKETPLACE_UNCONFIGURED,
311
+ discoverMarketplaceSkills,
312
+ getMarketplaceSkills,
313
+ installSkill,
314
+ modelVisibleSkills
315
+ } from "./chunk-LDJG7DW3.js";
316
+ import "./chunk-NDDGJUXD.js";
317
+ import "./chunk-CE5AX47J.js";
318
+ import {
319
+ foldPromptCacheTelemetry,
320
+ hasPromptCacheTelemetry,
321
+ uncachedPrefillTokens
322
+ } from "./chunk-3DPEIQKN.js";
323
+ import {
324
+ EXTENSION_SNAPSHOT_DIAGNOSTIC_MESSAGE_CAP,
325
+ ExtensionsDomainModule
326
+ } from "./chunk-7DRAWPTZ.js";
327
+ import "./chunk-5MEZN6CB.js";
328
+ import "./chunk-D4CJV46V.js";
329
+ import "./chunk-NEKRRTYW.js";
330
+ import {
331
+ INHERITED_PROJECT_CONTEXT,
332
+ InteropDomainModule,
333
+ delegationEntryForKind,
334
+ renderProposalEntry
335
+ } from "./chunk-INY6HTFL.js";
336
+ import "./chunk-I7XBWTYH.js";
159
337
  import {
160
338
  ClioEditor,
161
339
  CombinedAutocompleteProvider,
@@ -228,185 +406,23 @@ import {
228
406
  visibleWidth,
229
407
  wrapTextWithAnsi,
230
408
  writeInputWedgeDump
231
- } from "./chunk-I64IFBLB.js";
409
+ } from "./chunk-DWUOQKRU.js";
232
410
  import {
233
411
  getTerminationCoordinator
234
412
  } from "./chunk-4O6MANBS.js";
235
- import {
236
- createContextDomainModule,
237
- loadProjectClioMd
238
- } from "./chunk-SSEYRH53.js";
239
- import {
240
- renderCodewikiDigest
241
- } from "./chunk-AZ4WMN4W.js";
242
- import {
243
- buildMemoryPromptSection,
244
- canonicalMemoryRepositoryIdentity,
245
- createTaskMemoryTrace,
246
- describeTaskMemoryActivity,
247
- formatTaskMemorySpend,
248
- loadMemoryRecordsSync,
249
- proposeInjectedTaskMemory,
250
- proposeMemoryPromotion,
251
- readTaskMemorySpendSummary,
252
- renderTaskMemoryHandoffSource,
253
- seedTaskMemoryFromNewestHandoff,
254
- taskMemoryBankSize,
255
- taskMemoryHandoffSeedOffer,
256
- taskMemoryTracePath
257
- } from "./chunk-JBCS7CRR.js";
258
- import "./chunk-LCGCVYZ4.js";
259
- import {
260
- listWikiPages,
261
- wikiCompleteness,
262
- wikiStaleness,
263
- wikiStalenessAsync
264
- } from "./chunk-NDINPTJ4.js";
265
- import "./chunk-MXHC5QYU.js";
266
- import {
267
- ACP_AGENT_META_KEY,
268
- ACP_MAX_CHUNK_BYTES,
269
- ACP_MAX_RAW_RECORD_BYTES,
270
- ACP_MAX_STRING_BYTES,
271
- ACP_MAX_TOOL_CALL_ID_BYTES,
272
- ACP_SESSION_META_KEY,
273
- ACP_TURN_FAILED_MESSAGE,
274
- ACP_USAGE_META_KEY,
275
- AcpRequestError,
276
- AcpTimeoutError,
277
- COST_NOT_MEASURED,
278
- acpErrorMessage,
279
- aggregateCostAmounts,
280
- capacityLeaseUsage,
281
- costAggregateForAmount,
282
- createDispatchDomainModule,
283
- createDispatchRunEventRegistry,
284
- createRunReceiptQuality,
285
- createStdioServerTransport,
286
- evidenceDirectory,
287
- executeFleetRun,
288
- formatCostAggregate,
289
- inspectEvidence,
290
- listEvidenceOverviews,
291
- openLedger,
292
- protectedResidencyModels,
293
- renderCostAggregate,
294
- renderDispatchReviewerTask
295
- } from "./chunk-I66ZTYNP.js";
296
- import {
297
- readGateDecisionArtifacts,
298
- readPendingGateDecisions
299
- } from "./chunk-ZGNYYXQ6.js";
300
- import {
301
- TRUST_STATUS_AXES,
302
- formatTrustSummaryLine,
303
- inspectRunReceiptTrustStatus,
304
- isReceiptIntegrity,
305
- retiredReceiptIntegrity,
306
- retiredReceiptIntegrityReason,
307
- summarizeTrustStatus,
308
- trustStateWord,
309
- verifyReceiptIntegrity
310
- } from "./chunk-B74PXLU7.js";
311
- import {
312
- SessionDomainModule,
313
- addResponseModelIdObservationCount,
314
- addResponseModelIdObservationCounts,
315
- attributedModelId,
316
- collectSessionEntries,
317
- emptyResponseModelIdObservationCounts,
318
- ledgerUsageCalls,
319
- protectedArtifactEntryFromArtifact,
320
- protectedArtifactStateFromSessionEntries,
321
- readAuditRows,
322
- responseModelIdObservationCountsLabel,
323
- responseModelIdObservationFromRecord
324
- } from "./chunk-X7IARSHT.js";
325
- import "./chunk-KPXDY6QF.js";
326
- import {
327
- describeWriteBoundaryAttributionDowngrade,
328
- gitCheckoutRoot,
329
- isGitRepository,
330
- preflightWriteBoundaries,
331
- recoverCleanupReadyCompeteGroups
332
- } from "./chunk-W6NIE6OW.js";
333
- import {
334
- bindExecutionPlanEndpoints,
335
- compileFleetExecutionPlan,
336
- requireAgentSteps
337
- } from "./chunk-DZAW46HP.js";
338
- import {
339
- parseRigorOverride,
340
- resolveRigor
341
- } from "./chunk-RVG5JXAL.js";
342
- import {
343
- foldPromptCacheTelemetry,
344
- hasPromptCacheTelemetry,
345
- uncachedPrefillTokens
346
- } from "./chunk-3DPEIQKN.js";
347
- import "./chunk-5PFYMY2V.js";
348
- import {
349
- configureRunEventJournal
350
- } from "./chunk-VIA6RFQZ.js";
351
- import "./chunk-T56WDKA5.js";
352
- import {
353
- filterEntriesToActivePath
354
- } from "./chunk-W6GROXXM.js";
355
413
  import "./chunk-JVCV3ICN.js";
356
- import "./chunk-4JDLP6ZS.js";
357
- import {
358
- shellQuote
359
- } from "./chunk-TXOTCRLG.js";
360
414
  import {
361
415
  emptyWorkspaceSnapshot,
362
416
  probeGitStatusAsync,
363
417
  probeWorkspaceAsync
364
418
  } from "./chunk-HVDIIIQW.js";
365
- import {
366
- classifyLibraryRequirements,
367
- createResourcesDomainModule,
368
- discoverLibrary,
369
- installLibraryPlan,
370
- libraryEntryInstalled,
371
- libraryEntryPin,
372
- libraryEntryRef,
373
- libraryInstallPath,
374
- planLibraryInstall
375
- } from "./chunk-ZNT2M6TG.js";
376
- import {
377
- AgentsDomainModule
378
- } from "./chunk-P75RZCJW.js";
379
- import "./chunk-CRFOIAX3.js";
380
- import "./chunk-DR52UMZW.js";
381
- import {
382
- MARKETPLACE_UNCONFIGURED,
383
- discoverMarketplaceSkills,
384
- getMarketplaceSkills,
385
- installSkill,
386
- modelVisibleSkills
387
- } from "./chunk-O3YUNJZ2.js";
388
- import "./chunk-NDDGJUXD.js";
389
- import "./chunk-XGDPUNND.js";
390
- import {
391
- FLEET_COMMANDS_REMEDY,
392
- FleetCommandRegistryMissingError,
393
- fleetStepBoundaries,
394
- loadFleetCommands,
395
- loadFleetContract,
396
- renderFleetPrompt,
397
- validateFleetCommands,
398
- validateFleetGraph
399
- } from "./chunk-3F7VUY77.js";
400
- import "./chunk-RKKLTLYB.js";
401
- import {
402
- EXTENSION_SNAPSHOT_DIAGNOSTIC_MESSAGE_CAP,
403
- ExtensionsDomainModule
404
- } from "./chunk-HLAFFSEK.js";
405
- import "./chunk-77QIVUZB.js";
406
419
  import {
407
420
  formatBootTrace,
408
421
  traceBoot
409
422
  } from "./chunk-ZTJUVLTU.js";
423
+ import {
424
+ source_default
425
+ } from "./chunk-5TSRNF4G.js";
410
426
  import {
411
427
  INTERACTIVE_LOOP_BLOCK_BUDGET,
412
428
  applyEditsToNormalizedContent,
@@ -427,7 +443,7 @@ import {
427
443
  resolveSessionTools,
428
444
  sanitizeLockedSynthesisMessage,
429
445
  stripBom
430
- } from "./chunk-2NHR3NAY.js";
446
+ } from "./chunk-GI7YYQ3F.js";
431
447
  import {
432
448
  MIDDLEWARE_HOOK_TEXT_MAX_CHARS,
433
449
  MiddlewareDomainModule,
@@ -449,24 +465,23 @@ import {
449
465
  openDetachedBatchViews,
450
466
  watchdogBriefing,
451
467
  writeMiddlewareDiagnosticToStderr
452
- } from "./chunk-UBRFI4HS.js";
468
+ } from "./chunk-2UG5F4C5.js";
453
469
  import "./chunk-5PSMVOLM.js";
454
470
  import {
455
471
  resolveFdBinary
456
472
  } from "./chunk-BMS5RKQY.js";
457
- import "./chunk-QSNYB6ZV.js";
458
- import "./chunk-QDC3K2U3.js";
459
- import "./chunk-MCEPRMZW.js";
460
- import "./chunk-7BHIY2MW.js";
461
- import "./chunk-LJID3DYZ.js";
462
- import "./chunk-PBP4B7XR.js";
463
473
  import {
464
474
  TaskMemoryBank,
475
+ TaskMemoryEndpointBusyError,
465
476
  createTaskMemoryTelemetrySink
466
- } from "./chunk-I66EAJFY.js";
477
+ } from "./chunk-2WZ546HR.js";
478
+ import "./chunk-MCEPRMZW.js";
479
+ import "./chunk-ZDN3Y73Y.js";
480
+ import "./chunk-64I3JVYM.js";
467
481
  import {
468
482
  escapeRegExp
469
483
  } from "./chunk-VG7TBQIY.js";
484
+ import "./chunk-IUE3Y34X.js";
470
485
  import {
471
486
  ASK_USER_OTHER_LABEL,
472
487
  COUNCIL_JUDGE_PROMPT,
@@ -511,22 +526,22 @@ import {
511
526
  timeoutMsArg,
512
527
  toolPresentationPolicy,
513
528
  withResolvedDispatchPlan
514
- } from "./chunk-IKSLQ4XV.js";
529
+ } from "./chunk-PAJQJ7BS.js";
515
530
  import {
516
531
  defaultRoutingIntent,
517
532
  sameRouteIdentity
518
- } from "./chunk-HIICAHCJ.js";
533
+ } from "./chunk-EKCHAPYA.js";
519
534
  import {
520
535
  createTaskBoardStore,
521
536
  foldSessionTaskHistory,
522
537
  foldTaskBoard,
523
538
  taskBoardCounts
524
- } from "./chunk-Q4XWMHX6.js";
539
+ } from "./chunk-L47TF46W.js";
525
540
  import {
526
541
  DEFAULT_RECENT_ENTRY_LIMIT,
527
542
  assessFinishContract
528
- } from "./chunk-IDNA72AH.js";
529
- import "./chunk-FVDGR2ZL.js";
543
+ } from "./chunk-RSJ25QSL.js";
544
+ import "./chunk-XIVNBFZS.js";
530
545
  import {
531
546
  describeCallTarget,
532
547
  redactSecretString,
@@ -543,81 +558,57 @@ import {
543
558
  requestExecutionRole,
544
559
  withAttemptRole
545
560
  } from "./chunk-H7IXIC72.js";
546
- import "./chunk-VN3SHNBN.js";
561
+ import "./chunk-7DICMOS6.js";
547
562
  import {
548
563
  resolveToCwd
549
564
  } from "./chunk-OQE5J4C6.js";
550
- import {
551
- DEFAULT_AUTONOMY_LEVEL,
552
- SKILL_SUGGESTION_PREFIX,
553
- isSkillActivation,
554
- skillActivationFromToolDetails
555
- } from "./chunk-FSP7CMNU.js";
556
- import {
557
- sweepExpiredToolOffloads,
558
- toolResultPresentationPolicy,
559
- toolResultPresentationText
560
- } from "./chunk-B7HM5Z7T.js";
561
- import {
562
- formatSize
563
- } from "./chunk-OZNBF4L3.js";
564
- import "./chunk-4BJ5BYCE.js";
565
- import "./chunk-6XLNIQDB.js";
566
- import {
567
- combineBashOutput,
568
- runBashCommand
569
- } from "./chunk-NMJXSHBJ.js";
570
- import "./chunk-VAVR4IJY.js";
571
- import "./chunk-2LEAKD4C.js";
572
565
  import "./chunk-HHV2GANA.js";
573
566
  import {
574
567
  parseJsonObjectPayload,
575
568
  parseScoutResult,
576
569
  parseVerifierResult,
577
570
  resultContractSourceId
578
- } from "./chunk-PGF63K6I.js";
571
+ } from "./chunk-B4OAX3SI.js";
579
572
  import {
580
- CLIO_PROJECT_DIR,
581
573
  toolMutationPaths
582
- } from "./chunk-IKOZFYBN.js";
574
+ } from "./chunk-I7ZPNEJM.js";
575
+ import {
576
+ CLIO_PROJECT_DIR
577
+ } from "./chunk-GYV6VZOC.js";
583
578
  import {
584
579
  VERIFICATION_SCRIPT_FAMILY_HINT
585
580
  } from "./chunk-UL3WSD3F.js";
581
+ import {
582
+ sweepExpiredToolOffloads,
583
+ toolResultPresentationPolicy,
584
+ toolResultPresentationText
585
+ } from "./chunk-JDAY6FIL.js";
586
+ import {
587
+ formatSize
588
+ } from "./chunk-OZNBF4L3.js";
586
589
  import "./chunk-ECH6PKUQ.js";
590
+ import "./chunk-6XLNIQDB.js";
587
591
  import {
588
592
  typebox_exports
589
593
  } from "./chunk-5B2AEOW5.js";
594
+ import "./chunk-VAVR4IJY.js";
595
+ import "./chunk-QSNYB6ZV.js";
596
+ import {
597
+ DEFAULT_AUTONOMY_LEVEL,
598
+ SKILL_SUGGESTION_PREFIX,
599
+ armedSkillSurface,
600
+ isSkillActivation,
601
+ modelMayActivateSkills,
602
+ skillActivationFromToolDetails,
603
+ skillSurfaceLabels,
604
+ skillSurfaceNames,
605
+ withModelSkillActivation
606
+ } from "./chunk-JGRC33J2.js";
607
+ import "./chunk-4BJ5BYCE.js";
590
608
  import {
591
609
  ToolNames
592
610
  } from "./chunk-K6BSR66V.js";
593
- import {
594
- incompleteInstallationAdvice
595
- } from "./chunk-65DEGPJ6.js";
596
- import "./chunk-BWH6N36D.js";
597
- import "./chunk-UUVG37B4.js";
598
- import {
599
- readCodewiki,
600
- readCodewikiAsync
601
- } from "./chunk-LBMZMYH2.js";
602
- import "./chunk-XAKHZX5N.js";
603
- import {
604
- enumerateWorkspaceFilesAsync
605
- } from "./chunk-33YXPOE3.js";
606
- import "./chunk-7CR24IG7.js";
607
- import {
608
- getVersionInfo
609
- } from "./chunk-XPLRXC72.js";
610
- import "./chunk-NEKRRTYW.js";
611
- import {
612
- INHERITED_PROJECT_CONTEXT,
613
- InteropDomainModule,
614
- delegationEntryForKind,
615
- renderProposalEntry
616
- } from "./chunk-JWJGP5DQ.js";
617
- import "./chunk-I7XBWTYH.js";
618
- import {
619
- source_default
620
- } from "./chunk-5TSRNF4G.js";
611
+ import "./chunk-QDC3K2U3.js";
621
612
  import {
622
613
  ProvidersDomainModule,
623
614
  applyModelCapabilityPatch,
@@ -626,6 +617,9 @@ import {
626
617
  endpointCapacityForStatus,
627
618
  firstRuntimeResolutionError,
628
619
  foregroundStreamUsage,
620
+ gatewayRoutingObservationFromRecord,
621
+ gatewayRoutingObservationLabel,
622
+ hasLiveModelCatalog,
629
623
  isDispatchEligibleRuntime,
630
624
  isOrchestratorEligibleRuntime,
631
625
  memoryInterventionModelMaxTokens,
@@ -637,7 +631,9 @@ import {
637
631
  registerForegroundStream,
638
632
  residencyTargetKey,
639
633
  resolveCostProvenance,
634
+ resolveEndpointCapacities,
640
635
  resolveModelCapabilities,
636
+ resolveModelReference,
641
637
  resolveModelRuntimeCapabilitiesForProviders,
642
638
  resolveReservedOutputTokens,
643
639
  resolveRuntimeTarget,
@@ -647,9 +643,8 @@ import {
647
643
  thinkingLevelChoiceLabel,
648
644
  thinkingLevelFromChoiceLabel,
649
645
  withRunOverrides
650
- } from "./chunk-BYMNWQ7O.js";
646
+ } from "./chunk-XPWWI35G.js";
651
647
  import "./chunk-CFGTUFWB.js";
652
- import "./chunk-72GZI5EV.js";
653
648
  import {
654
649
  AutoCompactionTrigger,
655
650
  DEFAULT_COMPACTION_THRESHOLD,
@@ -669,7 +664,8 @@ import {
669
664
  reconcileSnapshot,
670
665
  shouldCompact,
671
666
  snapshotInputTokens
672
- } from "./chunk-CWVRRIEI.js";
667
+ } from "./chunk-NZMNUPZZ.js";
668
+ import "./chunk-2JH2WHGE.js";
673
669
  import {
674
670
  atomicWrite,
675
671
  cwdHash,
@@ -677,15 +673,11 @@ import {
677
673
  readSessionTailTurns,
678
674
  sessionCurrentPath,
679
675
  sessionPaths
680
- } from "./chunk-MQXIVJ35.js";
676
+ } from "./chunk-HAXOFFRH.js";
681
677
  import "./chunk-R346GLFC.js";
682
- import {
683
- getSharedBus
684
- } from "./chunk-PMZVFWSR.js";
685
- import "./chunk-BTK3SSSK.js";
686
678
  import {
687
679
  interopAgentKind
688
- } from "./chunk-IHXBNWMM.js";
680
+ } from "./chunk-KXDSS5WJ.js";
689
681
  import {
690
682
  SETTINGS_V1_PATH_MOVES,
691
683
  bindAgentProfileInSettings,
@@ -695,21 +687,37 @@ import {
695
687
  setFleetProfileInSettings,
696
688
  updateSettings,
697
689
  useTargetInSettings
698
- } from "./chunk-34BHNEE3.js";
690
+ } from "./chunk-GHS5EBTQ.js";
699
691
  import "./chunk-D7E7WCDF.js";
700
- import "./chunk-HJWWJ6IL.js";
692
+ import "./chunk-BTK3SSSK.js";
693
+ import {
694
+ combineBashOutput,
695
+ runBashCommand
696
+ } from "./chunk-NMJXSHBJ.js";
697
+ import {
698
+ getSharedBus
699
+ } from "./chunk-PMZVFWSR.js";
701
700
  import {
702
701
  BusChannels,
703
702
  isRunAbortedPayload
704
703
  } from "./chunk-F4EKGO4N.js";
705
704
  import {
706
- setGitCommitAttributionEnabled
707
- } from "./chunk-JIEGK6UF.js";
705
+ incompleteInstallationAdvice
706
+ } from "./chunk-65DEGPJ6.js";
707
+ import "./chunk-BWH6N36D.js";
708
+ import "./chunk-UUVG37B4.js";
708
709
  import {
709
- MAX_TIMER_DELAY_MS,
710
- rawDurationMs
711
- } from "./chunk-EBY63B7G.js";
712
- import "./chunk-6EJMN2Y3.js";
710
+ readCodewiki,
711
+ readCodewikiAsync
712
+ } from "./chunk-LBMZMYH2.js";
713
+ import "./chunk-XAKHZX5N.js";
714
+ import {
715
+ enumerateWorkspaceFilesAsync
716
+ } from "./chunk-33YXPOE3.js";
717
+ import "./chunk-7CR24IG7.js";
718
+ import {
719
+ getVersionInfo
720
+ } from "./chunk-XPLRXC72.js";
713
721
  import {
714
722
  readClioVersion,
715
723
  readPiMonoVersion
@@ -718,7 +726,7 @@ import {
718
726
  VALID_THINKING_LEVELS,
719
727
  formatContextWindowSlots,
720
728
  registerBuiltinRuntimes
721
- } from "./chunk-IMXMHHMQ.js";
729
+ } from "./chunk-VW6DOEDG.js";
722
730
  import {
723
731
  ACTIVE_ROUTING_POSTURES,
724
732
  ACTIVE_ROUTING_ROLES,
@@ -727,26 +735,29 @@ import {
727
735
  THINKING_LEVELS
728
736
  } from "./chunk-UXCU4E3T.js";
729
737
  import "./chunk-LL4KHSZI.js";
738
+ import "./chunk-JSC3U7TI.js";
730
739
  import {
731
740
  configureGuardrails,
732
741
  guardrailValuesFromSettings
733
742
  } from "./chunk-S66XZJOF.js";
743
+ import {
744
+ setGitCommitAttributionEnabled
745
+ } from "./chunk-JIEGK6UF.js";
746
+ import {
747
+ MAX_TIMER_DELAY_MS,
748
+ rawDurationMs
749
+ } from "./chunk-EBY63B7G.js";
750
+ import "./chunk-6EJMN2Y3.js";
734
751
  import {
735
752
  resolveProviderReference
736
- } from "./chunk-CDNVLKUX.js";
753
+ } from "./chunk-LLDJM5XK.js";
737
754
  import {
738
755
  targetRequiresAuth
739
- } from "./chunk-WNP7O5WZ.js";
756
+ } from "./chunk-ID64D7PE.js";
740
757
  import "./chunk-336NSSKI.js";
741
758
  import "./chunk-IKCO5N3L.js";
742
759
  import "./chunk-3I7MS7N2.js";
743
760
  import "./chunk-APJ265NV.js";
744
- import {
745
- clioConfigDir,
746
- clioDataDir,
747
- clioStateDir,
748
- stateRootRemoved
749
- } from "./chunk-BYP5D4HI.js";
750
761
  import {
751
762
  safeResourceWrite
752
763
  } from "./chunk-WEPFGWHJ.js";
@@ -756,7 +767,7 @@ import {
756
767
  import {
757
768
  AGENT_ROLE_TOOLS_REQUIRED_REASON,
758
769
  supportsAgentRoleTools
759
- } from "./chunk-O42A54GG.js";
770
+ } from "./chunk-5OIVVPHF.js";
760
771
  import {
761
772
  StringEnum,
762
773
  cleanupEngineSessionResources,
@@ -764,14 +775,23 @@ import {
764
775
  isEngineRetryableAssistantError,
765
776
  stream,
766
777
  streamSimple
767
- } from "./chunk-VXMFAE2W.js";
778
+ } from "./chunk-YPC6ZR5L.js";
768
779
  import "./chunk-YXLYO42X.js";
780
+ import "./chunk-2LEAKD4C.js";
781
+ import {
782
+ clioConfigDir,
783
+ clioDataDir,
784
+ clioStateDir,
785
+ stateRootRemoved
786
+ } from "./chunk-BYP5D4HI.js";
769
787
  import {
770
788
  init_esm_shims
771
789
  } from "./chunk-3R73A4XB.js";
772
790
 
773
791
  // src/entry/orchestrator.ts
774
792
  init_esm_shims();
793
+ import { randomUUID as randomUUID3 } from "node:crypto";
794
+ import { readFileSync as readFileSync10 } from "node:fs";
775
795
  import { join as join12 } from "node:path";
776
796
 
777
797
  // src/cli/modes/print.ts
@@ -823,10 +843,11 @@ function resultFromEvent(event, current) {
823
843
  }
824
844
  if (event.type !== "message_end") return current;
825
845
  const message = event.message;
846
+ if (message?.role !== "assistant") return current;
826
847
  const error = assistantError(message);
827
848
  if (error) return { ...current, text: "", error };
828
849
  const text = assistantText(message).trimEnd();
829
- if (text.length === 0) return current;
850
+ if (text.length === 0) return { ...current, error: null };
830
851
  return { ...current, text, error: null };
831
852
  }
832
853
  function blankToolStat(tool) {
@@ -2045,6 +2066,22 @@ function addCompactionUsage(total, raw) {
2045
2066
  apiCalls: base.apiCalls + 1
2046
2067
  };
2047
2068
  }
2069
+ function retainReportedUsage(previous, raw) {
2070
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return previous;
2071
+ const usage = raw;
2072
+ const known = { ...previous };
2073
+ for (const field2 of ["input", "output", "cacheRead", "cacheWrite", "totalTokens"]) {
2074
+ const value = numberOrZero(usage[field2]);
2075
+ if (value > 0) known[field2] = value;
2076
+ }
2077
+ const reasoning = extractReasoningTokens({ ...usage, reasoningTokens: void 0 });
2078
+ if (reasoning !== null && reasoning > 0) known.reasoning = reasoning;
2079
+ if (usage.cost && typeof usage.cost === "object" && "total" in usage.cost) {
2080
+ const cost = numberOrZero(usage.cost.total);
2081
+ if (cost > 0) known.cost = { total: cost };
2082
+ }
2083
+ return known;
2084
+ }
2048
2085
  async function runSummaryStream(input, userText, systemPrompt, maxTokens) {
2049
2086
  const options = { maxTokens };
2050
2087
  if (input.apiKey !== void 0) options.apiKey = input.apiKey;
@@ -2054,25 +2091,43 @@ async function runSummaryStream(input, userText, systemPrompt, maxTokens) {
2054
2091
  systemPrompt,
2055
2092
  messages: [buildUserMessage(userText)]
2056
2093
  };
2057
- const events = stream(
2058
- input.model,
2059
- context,
2060
- options
2061
- );
2062
- let summary = "";
2094
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
2095
+ const started = performance.now();
2063
2096
  let usage;
2064
- for await (const event of events) {
2065
- if (event.type === "done") {
2066
- summary = textFromAssistant(event.message);
2067
- usage = event.message.usage;
2068
- break;
2069
- }
2070
- if (event.type === "error") {
2071
- const reason = event.error.errorMessage ?? "unknown error";
2072
- throw new Error(`compaction stream failed: ${reason}`);
2097
+ let reported = {};
2098
+ let outcome = "error";
2099
+ try {
2100
+ const events = streamSimple(
2101
+ input.model,
2102
+ context,
2103
+ options
2104
+ );
2105
+ for await (const event of events) {
2106
+ if ("partial" in event) {
2107
+ usage = event.partial.usage ?? usage;
2108
+ reported = retainReportedUsage(reported, usage);
2109
+ }
2110
+ if (event.type === "done") {
2111
+ usage = event.message.usage ?? usage;
2112
+ outcome = "success";
2113
+ return { text: textFromAssistant(event.message).trim(), usage };
2114
+ }
2115
+ if (event.type === "error") {
2116
+ usage = event.error.usage ?? usage;
2117
+ reported = retainReportedUsage(reported, usage);
2118
+ outcome = event.error.stopReason === "aborted" ? "aborted" : "error";
2119
+ throw new Error(`compaction stream failed: ${event.error.errorMessage ?? "unknown error"}`);
2120
+ }
2073
2121
  }
2122
+ throw new Error("compaction stream ended without a terminal response");
2123
+ } finally {
2124
+ input.onCall?.({
2125
+ outcome: outcome === "error" && input.signal?.aborted ? "aborted" : outcome,
2126
+ usage: outcome === "success" ? usage : reported,
2127
+ timestamp,
2128
+ durationMs: Math.max(0, performance.now() - started)
2129
+ });
2074
2130
  }
2075
- return { text: summary.trim(), usage };
2076
2131
  }
2077
2132
  async function compact(input) {
2078
2133
  const reserveTokens = input.reserveTokens ?? DEFAULT_RESERVE_TOKENS;
@@ -2112,18 +2167,18 @@ async function compact(input) {
2112
2167
  const userText = buildUserText(conversationText, input.instructions, previousContextText);
2113
2168
  const historySummary = await runSummaryStream(input, userText, systemPrompt, maxTokens);
2114
2169
  usage = addCompactionUsage(usage, historySummary.usage);
2115
- if (historySummary.text.length > 0) summaryParts.push(historySummary.text);
2170
+ if (historySummary.text.length === 0) throw new Error("compaction returned an empty history summary");
2171
+ summaryParts.push(historySummary.text);
2116
2172
  }
2117
2173
  if (turnPrefix.length > 0) {
2118
2174
  const conversationText = serializeConversation(turnPrefix);
2119
2175
  const userText = buildTurnPrefixUserText(conversationText, input.instructions, previousContextText);
2120
2176
  const prefixSummary = await runSummaryStream(input, userText, systemPrompt, maxTokens);
2121
2177
  usage = addCompactionUsage(usage, prefixSummary.usage);
2122
- if (prefixSummary.text.length > 0) {
2123
- summaryParts.push(`**Turn Context (split turn):**
2178
+ if (prefixSummary.text.length === 0) throw new Error("compaction returned an empty split-turn summary");
2179
+ summaryParts.push(`**Turn Context (split turn):**
2124
2180
 
2125
2181
  ${prefixSummary.text}`);
2126
- }
2127
2182
  }
2128
2183
  const summary = `${summaryParts.join("\n\n---\n\n").trim()}${formatFileOperations(fileOps)}${formatRecallableRefs(
2129
2184
  input.entries,
@@ -2627,8 +2682,8 @@ function createUserTasksStore(deps) {
2627
2682
  if (current.status === "done" || current.status === "dropped") continue;
2628
2683
  const candidates = links.filter((link2) => link2.userTaskId === current.id);
2629
2684
  const completed = candidates.find((link2) => link2.status === "completed");
2630
- const open2 = candidates.find((link2) => link2.status === "active" || link2.status === "pending");
2631
- const link = completed ?? open2;
2685
+ const open3 = candidates.find((link2) => link2.status === "active" || link2.status === "pending");
2686
+ const link = completed ?? open3;
2632
2687
  if (link) {
2633
2688
  const status = completed ? "done" : "picked";
2634
2689
  if (current.status !== status || current.boardTaskId !== link.boardTaskId || current.handedSessionId !== sessionId) {
@@ -3025,8 +3080,8 @@ function endToolCallId(active, engineId) {
3025
3080
  if (engineId === void 0 || engineId.length === 0) {
3026
3081
  return newestOpenToolCallId(active) ?? active.lastEmittedToolCallId;
3027
3082
  }
3028
- const open2 = openWireIdFor(active, engineId);
3029
- if (open2 !== null) return open2;
3083
+ const open3 = openWireIdFor(active, engineId);
3084
+ if (open3 !== null) return open3;
3030
3085
  const wireIds = active.toolCallWireIds.get(engineId);
3031
3086
  if (wireIds === void 0) return null;
3032
3087
  return wireIds[wireIds.length - 1] ?? null;
@@ -4429,7 +4484,7 @@ async function serveClioAcpAgent(options) {
4429
4484
  }
4430
4485
  return promptResponse(active.stopReason, active);
4431
4486
  });
4432
- return await new Promise((resolve8) => {
4487
+ return await new Promise((resolve9) => {
4433
4488
  options.transport.onClose(() => {
4434
4489
  permission.unregister();
4435
4490
  unsubscribeEventStream();
@@ -4437,14 +4492,14 @@ async function serveClioAcpAgent(options) {
4437
4492
  for (const session of sessions.values()) cancelSession(session, "ACP transport closed");
4438
4493
  const inFlight = promptSettled;
4439
4494
  if (inFlight === null) {
4440
- resolve8(0);
4495
+ resolve9(0);
4441
4496
  return;
4442
4497
  }
4443
- const timer = setTimeout(() => resolve8(0), ACP_PROMPT_SETTLE_BOUND_MS);
4498
+ const timer = setTimeout(() => resolve9(0), ACP_PROMPT_SETTLE_BOUND_MS);
4444
4499
  timer.unref?.();
4445
4500
  void inFlight.then(() => {
4446
4501
  clearTimeout(timer);
4447
- resolve8(0);
4502
+ resolve9(0);
4448
4503
  });
4449
4504
  });
4450
4505
  });
@@ -11828,6 +11883,7 @@ var PRESENTED_RESULT_CONTRACTS = [
11828
11883
  "debugger-report",
11829
11884
  "verifier-report",
11830
11885
  "research-report",
11886
+ "world-knowledge-report",
11831
11887
  "scout-report"
11832
11888
  ];
11833
11889
  function contractKindFrom(receipt) {
@@ -12231,6 +12287,7 @@ function richMessageFromEntry(entry, maxTextChars) {
12231
12287
  "responseModelIdObservation",
12232
12288
  "responseModel",
12233
12289
  "responseId",
12290
+ "gatewayRouting",
12234
12291
  "diagnostics",
12235
12292
  "contextUsageInvalidated"
12236
12293
  ]) {
@@ -13163,8 +13220,8 @@ function createTurnContext(deps) {
13163
13220
  if (!usage || !deps.observability) return;
13164
13221
  if (usage.totalTokens <= 0 && usage.cost.total <= 0) return;
13165
13222
  deps.observability.recordTokens(
13166
- agentRuntime.targetId,
13167
- agentRuntime.wireModelId,
13223
+ usage.targetId ?? agentRuntime.targetId,
13224
+ usage.modelId ?? agentRuntime.wireModelId,
13168
13225
  usage.totalTokens,
13169
13226
  usage.cost.total,
13170
13227
  {
@@ -13176,7 +13233,7 @@ function createTurnContext(deps) {
13176
13233
  totalTokens: usage.totalTokens,
13177
13234
  apiCalls: Math.max(1, Math.round(usage.apiCalls))
13178
13235
  },
13179
- agentRuntime.runtimeResolution.costProvenance
13236
+ usage.targetId === void 0 && usage.modelId === void 0 ? agentRuntime.runtimeResolution.costProvenance : usage.cost.total > 0 ? "estimated" : "unknown"
13180
13237
  );
13181
13238
  };
13182
13239
  const runAutoCompact = async (agentRuntime, force, instructions, triggerOverride, pendingUserText) => {
@@ -14512,9 +14569,9 @@ function createTurnPrewarm(deps) {
14512
14569
  releaseActiveRound();
14513
14570
  },
14514
14571
  settled() {
14515
- return new Promise((resolve8) => {
14572
+ return new Promise((resolve9) => {
14516
14573
  setTimeout(() => {
14517
- resolve8(inFlight.catch(() => null));
14574
+ resolve9(inFlight.catch(() => null));
14518
14575
  }, 0);
14519
14576
  });
14520
14577
  },
@@ -14675,7 +14732,7 @@ function createTurnRecovery(deps) {
14675
14732
  deps.emitFailureMessage(message);
14676
14733
  };
14677
14734
  const waitForRetryCountdown = async (status) => {
14678
- return new Promise((resolve8) => {
14735
+ return new Promise((resolve9) => {
14679
14736
  let settled = false;
14680
14737
  let currentHandle = null;
14681
14738
  const handle = createRetryCountdown({
@@ -14692,12 +14749,12 @@ function createTurnRecovery(deps) {
14692
14749
  onDone: () => {
14693
14750
  settled = true;
14694
14751
  if (retryCountdown2 === currentHandle) retryCountdown2 = null;
14695
- resolve8("done");
14752
+ resolve9("done");
14696
14753
  },
14697
14754
  onCancel: () => {
14698
14755
  settled = true;
14699
14756
  if (retryCountdown2 === currentHandle) retryCountdown2 = null;
14700
- resolve8("cancelled");
14757
+ resolve9("cancelled");
14701
14758
  }
14702
14759
  });
14703
14760
  currentHandle = handle;
@@ -14733,6 +14790,10 @@ function createTurnRecovery(deps) {
14733
14790
  }
14734
14791
  };
14735
14792
  const runTransientRetryChain = async (agentRuntime, text, initialFailure) => {
14793
+ if (agentRuntime.runtimeId === "litellm") {
14794
+ ensureFailureVisibleAndPersisted(initialFailure);
14795
+ return true;
14796
+ }
14736
14797
  const settings = deps.retrySettings();
14737
14798
  if (!settings.enabled || settings.maxRetries <= 0) return false;
14738
14799
  if (initialFailure.stopReason === "aborted" || !isRetryableErrorMessage(initialFailure.errorMessage)) return false;
@@ -15127,6 +15188,9 @@ function createTurnRuntime(deps) {
15127
15188
  cleanupSessionResources(state.runtime.agent.sessionId);
15128
15189
  }
15129
15190
  let getCurrentAgentSignal = () => void 0;
15191
+ const gatewaySessionId = target.runtime.id === "litellm" ? deps.sessionId?.() : void 0;
15192
+ let apiCallStartedAt = null;
15193
+ let apiCallFirstDeltaAt = null;
15130
15194
  const handle = deps.createAgent({
15131
15195
  initialState: {
15132
15196
  systemPrompt: fallbackIdentityPrompt(),
@@ -15136,6 +15200,11 @@ function createTurnRuntime(deps) {
15136
15200
  messages: priorMessages
15137
15201
  },
15138
15202
  maxRetryDelayMs: deps.retrySettings().maxDelayMs,
15203
+ ...gatewaySessionId ? { sessionId: gatewaySessionId } : {},
15204
+ onStreamInvocation: () => {
15205
+ apiCallStartedAt = performance4.now();
15206
+ apiCallFirstDeltaAt = null;
15207
+ },
15139
15208
  onPayload: async (payload, currentModel) => {
15140
15209
  const thinkingPatched = patchProviderThinkingPayload(payload, currentModel, state.currentThinkingLevel);
15141
15210
  const basePayload = thinkingPatched ?? payload;
@@ -15215,8 +15284,6 @@ function createTurnRuntime(deps) {
15215
15284
  };
15216
15285
  let streamStartedAt = null;
15217
15286
  let firstAssistantDeltaAt = null;
15218
- let apiCallStartedAt = null;
15219
- let apiCallFirstDeltaAt = null;
15220
15287
  let runFirstCallVerdict = null;
15221
15288
  let pendingTerminalToolResult = null;
15222
15289
  let runStartMessageCount = 0;
@@ -15261,6 +15328,12 @@ function createTurnRuntime(deps) {
15261
15328
  }
15262
15329
  let publicEvent = enrichedEvent;
15263
15330
  if (enrichedEvent.type === "message_end" && enrichedEvent.message?.role === "assistant") {
15331
+ const gatewayRouting = gatewayRoutingObservationFromRecord(
15332
+ enrichedEvent.message
15333
+ );
15334
+ if (gatewayRouting !== null && ((gatewayRouting.attemptedFallbacks ?? 0) > 0 || (gatewayRouting.attemptedRetries ?? 0) > 0)) {
15335
+ deps.emitNotice(`[Clio Coder] ${gatewayRoutingObservationLabel(gatewayRouting)}`);
15336
+ }
15264
15337
  const interruptedUsage = estimatedUsageForInterruptedTurn(enrichedEvent.message, context.promptSideTokens());
15265
15338
  if (interruptedUsage !== null) {
15266
15339
  interruptedUsageByMessage.set(enrichedEvent.message, interruptedUsage);
@@ -15295,13 +15368,9 @@ function createTurnRuntime(deps) {
15295
15368
  if (stallMs > 0) armStallTimer(stallMs);
15296
15369
  }
15297
15370
  if (publicEvent?.type === "turn_end") toolsInFlight = 0;
15298
- if (publicEvent?.type === "message_start" && publicEvent.message?.role === "assistant") {
15299
- apiCallStartedAt = eventClock;
15300
- apiCallFirstDeltaAt = null;
15301
- }
15302
15371
  if (publicEvent?.type === "message_update") {
15303
15372
  const assistantEvent = publicEvent.assistantMessageEvent;
15304
- const hasDelta = assistantEvent.type === "text_delta" || assistantEvent.type === "thinking_delta" || assistantEvent.type === "toolcall_start" || assistantEvent.type === "toolcall_delta";
15373
+ const hasDelta = assistantEvent.type === "toolcall_start" || (assistantEvent.type === "text_delta" || assistantEvent.type === "thinking_delta" || assistantEvent.type === "toolcall_delta") && typeof assistantEvent.delta === "string" && assistantEvent.delta.length > 0;
15305
15374
  if (hasDelta && firstAssistantDeltaAt === null) firstAssistantDeltaAt = eventClock;
15306
15375
  if (hasDelta && apiCallFirstDeltaAt === null) apiCallFirstDeltaAt = eventClock;
15307
15376
  }
@@ -15466,6 +15535,7 @@ function createTurnState(initialThinkingLevel) {
15466
15535
  stalledTurnNudgeSpent: false,
15467
15536
  pendingRequestContinuation: false,
15468
15537
  currentPendingSkillPolicy: void 0,
15538
+ activeSkillSurface: void 0,
15469
15539
  currentAskUserPolicy: void 0,
15470
15540
  lastRunSnapshot: null
15471
15541
  };
@@ -15533,6 +15603,21 @@ function createChatLoop(deps) {
15533
15603
  const emitNotice = (text, level = "info", key) => {
15534
15604
  emit({ type: "notice", level, surface: "transcript", text, ...key === void 0 ? {} : { key } });
15535
15605
  };
15606
+ const armSkillSurface = (policy, loadedBefore) => {
15607
+ const previous = skillSurfaceNames(state.activeSkillSurface).join(", ");
15608
+ const next = armedSkillSurface(policy);
15609
+ const current = skillSurfaceNames(next).join(", ");
15610
+ state.activeSkillSurface = next;
15611
+ const activated = skillSurfaceLabels(policy).filter((label) => !loadedBefore?.has(label.split(" ")[0] ?? label));
15612
+ if (activated.length > 0) {
15613
+ emitNotice(
15614
+ current.length > 0 ? `[Clio Coder] Skill activated: ${activated.join(", ")}. Its tool surface stays armed across your next turns until another skill replaces it or you run /skill off.` : `[Clio Coder] Skill activated: ${activated.join(", ")}. It declares no tool narrowing.`
15615
+ );
15616
+ }
15617
+ if (current !== previous && current.length === 0 && previous.length > 0) {
15618
+ emitNotice(`[Clio Coder] Skill tool surface cleared: ${previous}. The full tool surface is back.`);
15619
+ }
15620
+ };
15536
15621
  const emitAdmissionNotice = (text, reason) => {
15537
15622
  emit({ type: "notice", level: "info", surface: "transcript", text, admission: { reason } });
15538
15623
  };
@@ -15630,6 +15715,7 @@ function createChatLoop(deps) {
15630
15715
  context,
15631
15716
  middleware,
15632
15717
  retrySettings,
15718
+ sessionId: () => deps.session?.current()?.id,
15633
15719
  emit: emitRuntimeEvent,
15634
15720
  emitNotice,
15635
15721
  toolStartTimes
@@ -15765,6 +15851,11 @@ function createChatLoop(deps) {
15765
15851
  steer: (text) => queues.steer(text),
15766
15852
  queueFollowUp: (text) => queues.queueFollowUp(text),
15767
15853
  interruptRefusal: () => state.streaming ? interruptRefusalReason() : null,
15854
+ clearSkillSurface: () => {
15855
+ const cleared = skillSurfaceNames(state.activeSkillSurface);
15856
+ armSkillSurface(void 0);
15857
+ return cleared;
15858
+ },
15768
15859
  clearQueuedFollowUps: () => queues.clearQueuedMirror().map((entry) => entry.text),
15769
15860
  queuedMessages: () => queues.queuedMessages(),
15770
15861
  async submit(text, options = {}) {
@@ -15831,7 +15922,11 @@ function createChatLoop(deps) {
15831
15922
  const images = options.images && options.images.length > 0 ? [...options.images] : void 0;
15832
15923
  const pendingSkillRequests = options.pendingSkillRequests ?? [];
15833
15924
  context.addWorkingContextPaths(options.workingContextPaths ?? []);
15834
- const pendingSkillPolicy = createPendingSkillToolPolicy(pendingSkillRequests);
15925
+ const pendingSkillPolicy = withModelSkillActivation(
15926
+ createPendingSkillToolPolicy(pendingSkillRequests) ?? state.activeSkillSurface,
15927
+ modelMayActivateSkills(deps.getAutonomy?.() ?? deps.getSettings().safety.autonomy)
15928
+ );
15929
+ const skillsLoadedBeforeTurn = new Set(pendingSkillPolicy?.loadedSkillNames ?? []);
15835
15930
  agentRuntime.agent.state.tools = resolveSessionTools(
15836
15931
  agentRuntime,
15837
15932
  deps.toolRegistry,
@@ -16027,6 +16122,7 @@ function createChatLoop(deps) {
16027
16122
  }
16028
16123
  state.currentPendingSkillPolicy = priorPendingSkillPolicy;
16029
16124
  state.currentAskUserPolicy = priorAskUserPolicy;
16125
+ armSkillSurface(pendingSkillPolicy, skillsLoadedBeforeTurn);
16030
16126
  state.activeUserTurnId = null;
16031
16127
  context.flushReconciledSnapshot();
16032
16128
  if (!await queues.resubmitStrandedSteers()) await queues.resubmitRequestContinuation();
@@ -16231,8 +16327,8 @@ function createChatLoop(deps) {
16231
16327
  const previous = admissionTail;
16232
16328
  let release = () => {
16233
16329
  };
16234
- const ticket = new Promise((resolve8) => {
16235
- release = resolve8;
16330
+ const ticket = new Promise((resolve9) => {
16331
+ release = resolve9;
16236
16332
  });
16237
16333
  admissionTail = ticket;
16238
16334
  const releaseTicket = () => {
@@ -17091,8 +17187,8 @@ var AskUserOverlayView = class {
17091
17187
  this.setSurface(askUserSurface(this.questions, this.history.length));
17092
17188
  this.rebuildControl();
17093
17189
  this.deps.requestRender();
17094
- return new Promise((resolve8) => {
17095
- this.resolveCurrent = resolve8;
17190
+ return new Promise((resolve9) => {
17191
+ this.resolveCurrent = resolve9;
17096
17192
  });
17097
17193
  }
17098
17194
  cancel() {
@@ -17329,7 +17425,7 @@ var AskUserOverlayView = class {
17329
17425
  this.deps.onSurface(next);
17330
17426
  }
17331
17427
  finish(result) {
17332
- const resolve8 = this.resolveCurrent;
17428
+ const resolve9 = this.resolveCurrent;
17333
17429
  this.resolveCurrent = null;
17334
17430
  this.list = null;
17335
17431
  this.input = null;
@@ -17338,7 +17434,7 @@ var AskUserOverlayView = class {
17338
17434
  if (this.phase !== "closed") this.phase = "waiting";
17339
17435
  if (this.history.length > 0) this.setSurface("interview");
17340
17436
  this.deps.requestRender();
17341
- resolve8?.(result);
17437
+ resolve9?.(result);
17342
17438
  }
17343
17439
  renderWaiting(width, maxRows) {
17344
17440
  const theme6 = clioTheme();
@@ -18073,14 +18169,14 @@ function createAuthDialogController(title, onCancel) {
18073
18169
  });
18074
18170
  input.onSubmit = () => {
18075
18171
  if (!resolver) return;
18076
- const resolve8 = resolver;
18172
+ const resolve9 = resolver;
18077
18173
  resolver = void 0;
18078
18174
  rejecter = void 0;
18079
18175
  const value = input.getValue();
18080
18176
  promptLabel = null;
18081
18177
  input.setValue("");
18082
18178
  rebuild();
18083
- resolve8(value);
18179
+ resolve9(value);
18084
18180
  };
18085
18181
  input.onEscape = () => {
18086
18182
  cancel();
@@ -18134,8 +18230,8 @@ function createAuthDialogController(title, onCancel) {
18134
18230
  promptLabel = label;
18135
18231
  input.setValue("");
18136
18232
  rebuild();
18137
- return new Promise((resolve8, reject) => {
18138
- resolver = resolve8;
18233
+ return new Promise((resolve9, reject) => {
18234
+ resolver = resolve9;
18139
18235
  rejecter = reject;
18140
18236
  });
18141
18237
  }
@@ -18359,10 +18455,10 @@ function createOverlayAuthLifecycle(deps) {
18359
18455
  },
18360
18456
  onPrompt: async (prompt) => (await dialog.controller.prompt(prompt.message)).trim(),
18361
18457
  onSelect: (prompt) => selectOAuthOption(prompt, [`Target: ${targetId}`, `Runtime: ${runtime.id}`]),
18362
- onManualCodeInput: async () => await new Promise((resolve8, reject) => {
18458
+ onManualCodeInput: async () => await new Promise((resolve9, reject) => {
18363
18459
  manualCodeTimer = setTimeout(() => {
18364
18460
  manualCodeTimer = null;
18365
- dialog.controller.prompt("Verification code").then((value) => resolve8(value.trim())).catch(reject);
18461
+ dialog.controller.prompt("Verification code").then((value) => resolve9(value.trim())).catch(reject);
18366
18462
  }, 1e4);
18367
18463
  manualCodeTimer.unref?.();
18368
18464
  }),
@@ -18667,6 +18763,7 @@ function aggregateCostEntries(entries) {
18667
18763
  if (entry.label === "handoff") existing.row.handoffs += 1;
18668
18764
  if (entry.label === "prewarm") existing.row.prewarms += 1;
18669
18765
  if (entry.label === "background-memory") existing.row.backgroundMemory += 1;
18766
+ if (entry.label === "failed-compaction") existing.row.failedCompaction += 1;
18670
18767
  for (const requestedModelId of entry.requestedModelIds) existing.requestedModelIds.add(requestedModelId);
18671
18768
  addResponseModelIdObservationCounts(
18672
18769
  existing.responseModelIdObservationCounts,
@@ -18690,7 +18787,8 @@ function aggregateCostEntries(entries) {
18690
18787
  sideQuestions: entry.label === "side-question" ? 1 : 0,
18691
18788
  handoffs: entry.label === "handoff" ? 1 : 0,
18692
18789
  prewarms: entry.label === "prewarm" ? 1 : 0,
18693
- backgroundMemory: entry.label === "background-memory" ? 1 : 0
18790
+ backgroundMemory: entry.label === "background-memory" ? 1 : 0,
18791
+ failedCompaction: entry.label === "failed-compaction" ? 1 : 0
18694
18792
  },
18695
18793
  requestedModelIds: new Set(entry.requestedModelIds),
18696
18794
  responseModelIdObservationCounts: { ...entry.responseModelIdObservationCounts },
@@ -18724,7 +18822,8 @@ function sumRows(rows) {
18724
18822
  sideQuestions: acc.sideQuestions + row2.sideQuestions,
18725
18823
  handoffs: acc.handoffs + row2.handoffs,
18726
18824
  prewarms: acc.prewarms + row2.prewarms,
18727
- backgroundMemory: acc.backgroundMemory + row2.backgroundMemory
18825
+ backgroundMemory: acc.backgroundMemory + row2.backgroundMemory,
18826
+ failedCompaction: acc.failedCompaction + row2.failedCompaction
18728
18827
  }),
18729
18828
  {
18730
18829
  runs: 0,
@@ -18738,7 +18837,8 @@ function sumRows(rows) {
18738
18837
  sideQuestions: 0,
18739
18838
  handoffs: 0,
18740
18839
  prewarms: 0,
18741
- backgroundMemory: 0
18840
+ backgroundMemory: 0,
18841
+ failedCompaction: 0
18742
18842
  }
18743
18843
  );
18744
18844
  }
@@ -18777,13 +18877,19 @@ function summaryBlock(totalCost, totalTokens, rows, promptCache) {
18777
18877
  return kvBlock([
18778
18878
  [
18779
18879
  "turns",
18780
- formatTokens2(totals.runs - totals.sideQuestions - totals.handoffs - totals.prewarms - totals.backgroundMemory)
18880
+ formatTokens2(
18881
+ totals.runs - totals.sideQuestions - totals.handoffs - totals.prewarms - totals.backgroundMemory - totals.failedCompaction
18882
+ )
18781
18883
  ],
18782
18884
  ["model calls", formatTokens2(totals.apiCalls)],
18783
18885
  ...totals.sideQuestions > 0 ? [["side questions", formatTokens2(totals.sideQuestions)]] : [],
18784
18886
  ...totals.handoffs > 0 ? [["handoffs", formatTokens2(totals.handoffs)]] : [],
18785
18887
  ...totals.prewarms > 0 ? [["pre-warms", formatTokens2(totals.prewarms)]] : [],
18786
18888
  ...totals.backgroundMemory > 0 ? [["memory steps", formatTokens2(totals.backgroundMemory)]] : [],
18889
+ ...totals.failedCompaction > 0 ? [
18890
+ ["failed compaction calls", formatTokens2(totals.failedCompaction)],
18891
+ ["compaction usage", "known subtotals; missing usage is unknown"]
18892
+ ] : [],
18787
18893
  ...cost === null ? [] : [["cost", cost]],
18788
18894
  ["input", formatTokens2(totals.input)],
18789
18895
  ["output", formatTokens2(totals.output)],
@@ -18799,12 +18905,18 @@ function modelBlock(row2) {
18799
18905
  return kvBlock([
18800
18906
  ["requested model ids", row2.requestedModelIds.join(", ")],
18801
18907
  ["response model id observation", responseModelIdObservationCountsLabel(row2.responseModelIdObservationCounts)],
18802
- ["turns", formatTokens2(row2.runs - row2.sideQuestions - row2.handoffs - row2.prewarms - row2.backgroundMemory)],
18908
+ [
18909
+ "turns",
18910
+ formatTokens2(
18911
+ row2.runs - row2.sideQuestions - row2.handoffs - row2.prewarms - row2.backgroundMemory - row2.failedCompaction
18912
+ )
18913
+ ],
18803
18914
  ["model calls", formatTokens2(row2.apiCalls)],
18804
18915
  ...row2.sideQuestions > 0 ? [["side questions", formatTokens2(row2.sideQuestions)]] : [],
18805
18916
  ...row2.handoffs > 0 ? [["handoffs", formatTokens2(row2.handoffs)]] : [],
18806
18917
  ...row2.prewarms > 0 ? [["pre-warms", formatTokens2(row2.prewarms)]] : [],
18807
18918
  ...row2.backgroundMemory > 0 ? [["memory steps", formatTokens2(row2.backgroundMemory)]] : [],
18919
+ ...row2.failedCompaction > 0 ? [["failed compaction calls", formatTokens2(row2.failedCompaction)]] : [],
18808
18920
  ...cost === null ? [] : [["cost", cost]],
18809
18921
  ["input", formatTokens2(row2.input)],
18810
18922
  ["output", formatTokens2(row2.output)],
@@ -27092,14 +27204,14 @@ function openSkillsHub(tui, deps) {
27092
27204
  let pendingWithRequirements = null;
27093
27205
  const columns = () => typeof process.stdout.columns === "number" ? process.stdout.columns : 100;
27094
27206
  let handle;
27095
- const confirmInstall = deps.confirmInstall ?? ((subject) => new Promise((resolve8) => {
27207
+ const confirmInstall = deps.confirmInstall ?? ((subject) => new Promise((resolve9) => {
27096
27208
  handle.setHidden(true);
27097
27209
  const settle = (accepted) => {
27098
27210
  if (!closed) {
27099
27211
  handle.setHidden(false);
27100
27212
  handle.focus();
27101
27213
  }
27102
- resolve8(accepted);
27214
+ resolve9(accepted);
27103
27215
  };
27104
27216
  const confirmation = openLibraryInstallConfirmOverlay(tui, {
27105
27217
  subject,
@@ -28729,9 +28841,9 @@ function createOverlaySessionLifecycle(deps) {
28729
28841
  openHandoffReview(session, fromSessionId, goal, document);
28730
28842
  }
28731
28843
  function editHandoffDocument(current) {
28732
- const resolve8 = deps.resolveEditor ?? resolveExternalEditor;
28844
+ const resolve9 = deps.resolveEditor ?? resolveExternalEditor;
28733
28845
  const edit = deps.editExternally ?? editTextExternally;
28734
- const command = resolve8();
28846
+ const command = resolve9();
28735
28847
  if (!command) {
28736
28848
  deps.notify("warning", "handoff: no external editor configured; set VISUAL or EDITOR", "handoff:no-editor");
28737
28849
  return null;
@@ -29426,8 +29538,8 @@ function resolveApplicationCtrlCAction(state) {
29426
29538
  function createApplicationController(deps) {
29427
29539
  let resolveRun = () => {
29428
29540
  };
29429
- const run = new Promise((resolve8) => {
29430
- resolveRun = resolve8;
29541
+ const run = new Promise((resolve9) => {
29542
+ resolveRun = resolve9;
29431
29543
  });
29432
29544
  const keepAlive = deps.intervals.setInterval(() => {
29433
29545
  }, 1 << 30);
@@ -30204,16 +30316,16 @@ function createInteractiveDesktopNotifications(deps) {
30204
30316
  } catch {
30205
30317
  return;
30206
30318
  }
30207
- const open2 = /* @__PURE__ */ new Set();
30319
+ const open3 = /* @__PURE__ */ new Set();
30208
30320
  for (const view of views) {
30209
- open2.add(view.id);
30321
+ open3.add(view.id);
30210
30322
  if (view.total <= 0 || view.terminal < view.total) continue;
30211
30323
  if (announcedBatches.has(view.id)) continue;
30212
30324
  announcedBatches.add(view.id);
30213
30325
  notifier.notify({ kind: "batch-settled", shortId: view.id.slice(0, BATCH_SHORT_ID_CHARS) });
30214
30326
  }
30215
30327
  for (const id of [...announcedBatches]) {
30216
- if (!open2.has(id)) announcedBatches.delete(id);
30328
+ if (!open3.has(id)) announcedBatches.delete(id);
30217
30329
  }
30218
30330
  },
30219
30331
  approvalParked() {
@@ -31480,6 +31592,27 @@ function researchReport(value) {
31480
31592
  }
31481
31593
  return { lines: lines.length === 0 ? ["No findings reported."] : lines, footer: `source ${value.source}` };
31482
31594
  }
31595
+ function worldKnowledgeReport(value) {
31596
+ if (value.discovery !== "performed" && value.discovery !== "caller-supplied-only" && value.discovery !== "unavailable" || !Array.isArray(value.facts) || !isStringArray(value.synthesis) || !isStringArray(value.uncertainties) || !isStringArray(value.followUpVerification)) {
31597
+ return null;
31598
+ }
31599
+ const lines = [];
31600
+ for (const raw of value.facts) {
31601
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return null;
31602
+ const fact = raw;
31603
+ const claim = reportString(fact.claim);
31604
+ const evidence = reportString(fact.evidence);
31605
+ if (claim === null || evidence === null || !isStringArray(fact.sources)) return null;
31606
+ lines.push(`- ${claim}`, ` support: ${evidence}`);
31607
+ if (fact.sources.length > 0) lines.push(` sources: ${fact.sources.join(", ")}`);
31608
+ }
31609
+ if (value.synthesis.length > 0) lines.push("Synthesis:", ...value.synthesis.map((item) => `- ${item}`));
31610
+ if (value.uncertainties.length > 0) lines.push("Uncertainties:", ...value.uncertainties.map((item) => `- ${item}`));
31611
+ if (value.followUpVerification.length > 0) {
31612
+ lines.push("Verify next:", ...value.followUpVerification.map((item) => `- ${item}`));
31613
+ }
31614
+ return { lines: lines.length === 0 ? ["No findings reported."] : lines, footer: `discovery ${value.discovery}` };
31615
+ }
31483
31616
  function scoutReport(value) {
31484
31617
  if (!Array.isArray(value.findings) || typeof value.needsSplit !== "boolean") return null;
31485
31618
  const lines = [];
@@ -31523,6 +31656,8 @@ function presentedContractAnswer(entry) {
31523
31656
  return verifierReport(value);
31524
31657
  case "research-report":
31525
31658
  return researchReport(value);
31659
+ case "world-knowledge-report":
31660
+ return worldKnowledgeReport(value);
31526
31661
  case "scout-report":
31527
31662
  return scoutReport(value);
31528
31663
  }
@@ -32198,17 +32333,17 @@ function createChatPanel(options = {}) {
32198
32333
  return entry;
32199
32334
  };
32200
32335
  const closeOpenThinking = (entry) => {
32201
- const open2 = openThinkingSegment(entry);
32202
- if (open2 === null) return;
32203
- open2.finalized = true;
32336
+ const open3 = openThinkingSegment(entry);
32337
+ if (open3 === null) return;
32338
+ open3.finalized = true;
32204
32339
  invalidateEntryCache(entry);
32205
32340
  };
32206
32341
  const appendThinkingDelta = (entry, delta) => {
32207
32342
  if (delta.length === 0) return;
32208
32343
  invalidateEntryCache(entry);
32209
- const open2 = openThinkingSegment(entry);
32210
- if (open2 !== null) {
32211
- open2.text += delta;
32344
+ const open3 = openThinkingSegment(entry);
32345
+ if (open3 !== null) {
32346
+ open3.text += delta;
32212
32347
  return;
32213
32348
  }
32214
32349
  entry.segments.push({ kind: "thinking", text: delta, finalized: false, startedAtMs: now() });
@@ -35169,8 +35304,8 @@ function createInteractiveSlashRuntime(deps) {
35169
35304
  deps.requestRender();
35170
35305
  let acknowledgeAdmission = () => {
35171
35306
  };
35172
- const admitted = new Promise((resolve8) => {
35173
- acknowledgeAdmission = resolve8;
35307
+ const admitted = new Promise((resolve9) => {
35308
+ acknowledgeAdmission = resolve9;
35174
35309
  });
35175
35310
  const turn = deps.chat.submit(sub.text, {
35176
35311
  ...sub.images.length > 0 ? { images: sub.images } : {},
@@ -35291,6 +35426,7 @@ function createInteractiveSlashRuntime(deps) {
35291
35426
  listPrompts: () => deps.resources?.prompts(cwd()) ?? { items: [], diagnostics: [] },
35292
35427
  ...resources ? { expandPromptTemplate: (text) => resources.expandPromptTemplate(text, cwd()) } : {},
35293
35428
  openSkillsHub: deps.openSkillsHub,
35429
+ clearSkillSurface: () => deps.chat.clearSkillSurface(),
35294
35430
  listExtensions: () => deps.extensions?.list(cwd(), { all: true }) ?? [],
35295
35431
  listAgents: () => deps.agents?.listSpecs().filter((spec) => spec.audience !== "internal") ?? [],
35296
35432
  listDelegationAgents: () => deps.getSettings?.().integrations.externalAgents.entries ?? [],
@@ -36652,6 +36788,66 @@ async function startInteractive(deps) {
36652
36788
  return createInteractiveApplication(deps);
36653
36789
  }
36654
36790
 
36791
+ // src/entry/background-model-metadata.ts
36792
+ init_esm_shims();
36793
+ async function prepareBackgroundModelMetadata(providers, targetId, signal) {
36794
+ signal?.throwIfAborted();
36795
+ const status = providers.list().find((entry) => entry.target.id === targetId);
36796
+ if (status?.target.runtime === "litellm" && status.health.lastCheckAt === null) {
36797
+ await providers.probeTarget(targetId, { reasoning: false, ...signal ? { signal } : {} });
36798
+ }
36799
+ signal?.throwIfAborted();
36800
+ }
36801
+
36802
+ // src/entry/compaction-prompt.ts
36803
+ init_esm_shims();
36804
+ import { constants } from "node:fs";
36805
+ import { open as open2 } from "node:fs/promises";
36806
+ import { resolve as resolve7 } from "node:path";
36807
+ var MAX_PROMPT_BYTES = 64 * 1024;
36808
+ async function readCompactionSystemPrompt(path2, workspace) {
36809
+ if (path2 === void 0 || path2 === null) return void 0;
36810
+ const quotedPath = JSON.stringify(path2).replace(
36811
+ /[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/gu,
36812
+ (character) => `\\u{${character.codePointAt(0)?.toString(16)}}`
36813
+ );
36814
+ const displayPath = quotedPath.length <= 1024 ? quotedPath : `${quotedPath.slice(0, 1024)}...`;
36815
+ const failure2 = (reason) => new Error(
36816
+ `context.compaction.systemPrompt ${displayPath} ${reason}; set a readable, nonempty UTF-8 file of at most ${MAX_PROMPT_BYTES} bytes (relative to the session workspace), or unset the override`
36817
+ );
36818
+ if (!path2.trim()) throw failure2("path is empty");
36819
+ let file;
36820
+ try {
36821
+ file = await open2(resolve7(workspace, path2), constants.O_RDONLY | constants.O_NONBLOCK);
36822
+ } catch {
36823
+ throw failure2("cannot be opened");
36824
+ }
36825
+ try {
36826
+ if (!(await file.stat()).isFile()) throw failure2("must refer to a regular file");
36827
+ const buffer = Buffer.alloc(MAX_PROMPT_BYTES + 1);
36828
+ let length = 0;
36829
+ while (length < buffer.length) {
36830
+ const { bytesRead } = await file.read(buffer, length, buffer.length - length, null);
36831
+ if (bytesRead === 0) break;
36832
+ length += bytesRead;
36833
+ }
36834
+ if (length > MAX_PROMPT_BYTES) throw failure2("file is oversized");
36835
+ let text;
36836
+ try {
36837
+ text = new TextDecoder("utf-8", { fatal: true }).decode(buffer.subarray(0, length));
36838
+ } catch {
36839
+ throw failure2("file is not valid UTF-8");
36840
+ }
36841
+ if (!text.trim()) throw failure2("file is empty");
36842
+ return text;
36843
+ } catch (error) {
36844
+ if (error instanceof Error && error.message.startsWith("context.compaction.systemPrompt ")) throw error;
36845
+ throw failure2("file cannot be read");
36846
+ } finally {
36847
+ await file.close();
36848
+ }
36849
+ }
36850
+
36655
36851
  // src/entry/extension-reload.ts
36656
36852
  init_esm_shims();
36657
36853
  import { realpathSync as realpathSync2 } from "node:fs";
@@ -36862,6 +37058,27 @@ function resolvePanesEnablement(flag, setting) {
36862
37058
  return setting ?? "off";
36863
37059
  }
36864
37060
 
37061
+ // src/entry/task-memory-lifecycle.ts
37062
+ init_esm_shims();
37063
+ function bindTaskMemoryLifecycle(bus, memory) {
37064
+ const unsubscribe = [
37065
+ bus.on(BusChannels.SessionParked, () => memory.reset()),
37066
+ bus.on(BusChannels.SessionResumed, () => memory.reset()),
37067
+ bus.on(BusChannels.SessionTurnSwitched, () => memory.reset()),
37068
+ bus.on(BusChannels.SessionEnd, () => memory.dispose())
37069
+ ];
37070
+ return () => {
37071
+ memory.dispose();
37072
+ for (const off of unsubscribe) off();
37073
+ };
37074
+ }
37075
+ function captureTaskMemoryUsage(input) {
37076
+ const { observability, ...origin } = input;
37077
+ return (usage, isCurrent) => {
37078
+ recordBackgroundMemoryStep({ ...origin, usage, observability: isCurrent ? observability : void 0 });
37079
+ };
37080
+ }
37081
+
36865
37082
  // src/interactive/tool-prose-registration.ts
36866
37083
  init_esm_shims();
36867
37084
  var TOOL_PROSE_REGISTRATION_ID = "assessor.tool-prose-loop";
@@ -36939,7 +37156,7 @@ init_esm_shims();
36939
37156
 
36940
37157
  // src/tools/dispatch-admission.ts
36941
37158
  init_esm_shims();
36942
- import { isAbsolute as isAbsolute6, relative as relative8, resolve as resolve7 } from "node:path";
37159
+ import { isAbsolute as isAbsolute6, relative as relative8, resolve as resolve8 } from "node:path";
36943
37160
 
36944
37161
  // src/tools/dispatch-scout-admission.ts
36945
37162
  init_esm_shims();
@@ -37316,7 +37533,7 @@ function createDispatchAdmissionController(deps) {
37316
37533
  return {
37317
37534
  check: entry.check,
37318
37535
  argv: [...check.command],
37319
- cwd: resolve7(process.cwd(), check.cwd),
37536
+ cwd: resolve8(process.cwd(), check.cwd),
37320
37537
  timeoutMs: entry.timeoutMs
37321
37538
  };
37322
37539
  })
@@ -37379,7 +37596,7 @@ function createDispatchAdmissionController(deps) {
37379
37596
  ...request.worktree === true ? {
37380
37597
  worktree: true,
37381
37598
  apply: request.apply ?? "merge",
37382
- ...gitCheckoutRoot(resolve7(request.cwd ?? process.cwd())) === null ? {} : { worktreeDestination: gitCheckoutRoot(resolve7(request.cwd ?? process.cwd())) }
37599
+ ...gitCheckoutRoot(resolve8(request.cwd ?? process.cwd())) === null ? {} : { worktreeDestination: gitCheckoutRoot(resolve8(request.cwd ?? process.cwd())) }
37383
37600
  } : {},
37384
37601
  target: resolution.targetId,
37385
37602
  model: resolution.wireModelId,
@@ -37506,7 +37723,7 @@ function createDispatchAdmissionController(deps) {
37506
37723
  return shapeRejection(args, "dispatch: apply_winner.branch must be a clio-coder/compete/<group>/<n> branch");
37507
37724
  }
37508
37725
  try {
37509
- const cwd = resolve7(stringArg(args.apply_winner, "cwd") ?? process.cwd());
37726
+ const cwd = resolve8(stringArg(args.apply_winner, "cwd") ?? process.cwd());
37510
37727
  return trustExecution(
37511
37728
  markPrepared(
37512
37729
  withResolvedDispatchPlan(args, {
@@ -37550,7 +37767,7 @@ function createDispatchAdmissionController(deps) {
37550
37767
  const spec = deps.getAgentSpecs().find((candidate) => candidate.id === request.agentId);
37551
37768
  if (spec?.capabilityClass === "read-only") return shapeRejection(args, "worktree_read_only_agent");
37552
37769
  if (request.cwd !== void 0) {
37553
- const requested = resolve7(request.cwd);
37770
+ const requested = resolve8(request.cwd);
37554
37771
  const rel = relative8(parentCheckout, requested);
37555
37772
  if (rel === ".." || rel.startsWith("../") || isAbsolute6(rel)) {
37556
37773
  return shapeRejection(args, "worktree_cwd_outside_checkout");
@@ -38068,7 +38285,7 @@ function createDispatchTool(inputDeps, surfaceOptions = {}) {
38068
38285
  const admission = createDispatchAdmissionController(deps);
38069
38286
  let runnerPromise = null;
38070
38287
  const loadRunner = () => {
38071
- runnerPromise ??= (surfaceOptions.loadRunner ?? (() => import("./dispatch-runner-2QQAITS3.js")))();
38288
+ runnerPromise ??= (surfaceOptions.loadRunner ?? (() => import("./dispatch-runner-5AHT53RF.js")))();
38072
38289
  return runnerPromise;
38073
38290
  };
38074
38291
  return {
@@ -38135,7 +38352,7 @@ function registerAllTools(registry, deps = {}) {
38135
38352
  ...builtin(
38136
38353
  lazyTool(
38137
38354
  monitorToolSurface,
38138
- async () => (await import("./monitor-E4ASVUJH.js")).createMonitorTool({ dispatch, runEvents: dispatchRunEvents })
38355
+ async () => (await import("./monitor-HKU57TYQ.js")).createMonitorTool({ dispatch, runEvents: dispatchRunEvents })
38139
38356
  ),
38140
38357
  {
38141
38358
  path: "src/tools/monitor.ts",
@@ -38145,7 +38362,7 @@ function registerAllTools(registry, deps = {}) {
38145
38362
  });
38146
38363
  registry.register({
38147
38364
  ...builtin(
38148
- lazyTool(steerToolSurface, async () => (await import("./steer-Z5DO23FJ.js")).createSteerTool({ dispatch })),
38365
+ lazyTool(steerToolSurface, async () => (await import("./steer-2LQOMCPB.js")).createSteerTool({ dispatch })),
38149
38366
  {
38150
38367
  path: "src/tools/steer.ts",
38151
38368
  scope: "core"
@@ -38157,7 +38374,7 @@ function registerAllTools(registry, deps = {}) {
38157
38374
  const panes = deps.panes;
38158
38375
  registry.register({
38159
38376
  ...builtin(
38160
- lazyTool(panesToolSurface, async () => (await import("./panes-E3RUXOW5.js")).createPanesTool({ panes })),
38377
+ lazyTool(panesToolSurface, async () => (await import("./panes-DN2SSFOH.js")).createPanesTool({ panes })),
38161
38378
  { path: "src/tools/panes.ts", scope: "core" }
38162
38379
  )
38163
38380
  });
@@ -38294,18 +38511,40 @@ function advanceThinkingLevel(current, available) {
38294
38511
  return levels[(idx + 1) % levels.length] ?? "off";
38295
38512
  }
38296
38513
  var LOCAL_API_KEY_FALLBACK2 = "clio-coder-local-target";
38297
- async function resolveApiKeyForTarget(target, providers, signal) {
38298
- const runtime = providers.getRuntime(target.runtime);
38299
- if (!runtime) return void 0;
38300
- if (!targetRequiresAuth(target, runtime)) return LOCAL_API_KEY_FALLBACK2;
38301
- const resolved = await providers.auth.resolveForTarget(target, runtime, signal ? { signal } : void 0);
38302
- return resolved.apiKey;
38303
- }
38304
- function createBackgroundMemoryModelClient(providers, settings, timeoutMs, bus) {
38305
- const targetId = settings.context.memory.target?.trim();
38306
- const wireModelId = settings.context.memory.model?.trim();
38307
- if (!targetId || !wireModelId) return null;
38308
- if (backgroundSharesReasoningModelWithOrchestrator(providers, settings)) return null;
38514
+ function createBackgroundMemoryModelClient(providers, settings, timeoutMs, bus, fallbackOnly = false) {
38515
+ const configuredTarget = settings.context.memory.target?.trim();
38516
+ const configuredModel = settings.context.memory.model?.trim();
38517
+ if (!configuredTarget || !configuredModel) return null;
38518
+ const chatTarget = settings.chat.target?.trim();
38519
+ const chatModel = settings.chat.model?.trim();
38520
+ const sameRoute = configuredTarget === chatTarget && configuredModel === chatModel;
38521
+ if (fallbackOnly && sameRoute) return null;
38522
+ let fallbackReason;
38523
+ if (!fallbackOnly) {
38524
+ try {
38525
+ return prepareBackgroundMemoryRoute(providers, configuredTarget, configuredModel, timeoutMs, bus, "dedicated");
38526
+ } catch {
38527
+ fallbackReason = "configured route unavailable";
38528
+ }
38529
+ } else fallbackReason = "configured route client error";
38530
+ if (!chatTarget || !chatModel || sameRoute) {
38531
+ if (fallbackOnly) return null;
38532
+ throw new Error("configured memory route is unavailable and no distinct chat fallback can run");
38533
+ }
38534
+ try {
38535
+ return {
38536
+ ...prepareBackgroundMemoryRoute(providers, chatTarget, chatModel, timeoutMs, bus, "chat-fallback"),
38537
+ fallbackReason
38538
+ };
38539
+ } catch {
38540
+ if (fallbackOnly) return null;
38541
+ throw new Error("neither the configured memory route nor the active chat fallback is available");
38542
+ }
38543
+ }
38544
+ function prepareBackgroundMemoryModel(providers, targetId, wireModelId) {
38545
+ const status = providers.list().find((entry) => entry.target.id === targetId);
38546
+ if (status && (!status.available || status.health.status === "down" || hasLiveModelCatalog(status) && !status.discoveredModels.includes(wireModelId) || modelResidencyForStatus(status, wireModelId) === "absent" || modelResidencyForStatus(status, wireModelId) === "loading"))
38547
+ throw new Error("background memory route is unavailable");
38309
38548
  const resolved = resolveRuntimeTarget(providers, {
38310
38549
  targetId,
38311
38550
  wireModelId,
@@ -38325,9 +38564,23 @@ function createBackgroundMemoryModelClient(providers, settings, timeoutMs, bus)
38325
38564
  const model = resolved.target.runtime.synthesizeModel(resolved.target.target, resolved.target.wireModelId, kbHit);
38326
38565
  const refined = refineRuntimeTargetWithModelHints(resolved.target, model, providers.knowledgeBase);
38327
38566
  applyModelCapabilityPatch(model, refined.capabilities);
38328
- const costProvenance = normalizeCostProvenance(refined.costProvenance);
38567
+ return { model, refined };
38568
+ }
38569
+ function backgroundMemoryEndpointBusy(providers, endpointKey, targets) {
38570
+ if (endpointKey === null) return false;
38571
+ const capacity = resolveEndpointCapacities({
38572
+ statuses: providers.list(),
38573
+ targets,
38574
+ runtimeFor: (id) => providers.getRuntime(id)
38575
+ })[endpointKey];
38576
+ return capacity !== void 0 && (endpointCapacityUsage()[endpointKey] ?? 0) >= capacity.limit;
38577
+ }
38578
+ function prepareBackgroundMemoryRoute(providers, targetId, wireModelId, timeoutMs, bus, selection) {
38579
+ const initial = prepareBackgroundMemoryModel(providers, targetId, wireModelId);
38580
+ const { refined } = initial;
38329
38581
  const endpointKey = canonicalEndpointKey(refined.target);
38330
38582
  return {
38583
+ selection,
38331
38584
  targetId,
38332
38585
  wireModelId: refined.wireModelId,
38333
38586
  endpointKey,
@@ -38340,42 +38593,100 @@ function createBackgroundMemoryModelClient(providers, settings, timeoutMs, bus)
38340
38593
  // Wrapped at the layer that knows a request left the process: the step
38341
38594
  // holds endpoint capacity while it is out and publishes the cache
38342
38595
  // disturbance even when a timeout means the usage sink never sees it.
38343
- complete: announceMemoryStepEndpoint({ bus, endpointKey, targetId }, async (request) => {
38344
- const apiKey = targetRequiresAuth(refined.target, refined.runtime) ? (await providers.auth.resolveForTarget(refined.target, refined.runtime, { signal: request.signal })).apiKey : LOCAL_API_KEY_FALLBACK2;
38345
- const startedAt = Date.now();
38346
- const completion = await completeEngineText({
38347
- model,
38348
- systemPrompt: request.systemPrompt,
38349
- userPrompt: request.userPrompt,
38350
- maxTokens: request.maxTokens,
38351
- // Always off, never the operator's chat thinking level. A model that
38352
- // reasons anyway still works: `completeEngineText` keeps only text
38353
- // blocks, and the memory output budget leaves room for the preamble.
38354
- thinkingLevel: "off",
38355
- signal: request.signal,
38356
- timeoutMs,
38357
- ...apiKey === void 0 ? {} : { apiKey }
38358
- });
38359
- return {
38360
- text: completion.text,
38361
- inputTokens: completion.inputTokens,
38362
- outputTokens: completion.outputTokens,
38363
- usage: {
38596
+ complete: async (request) => {
38597
+ await prepareBackgroundModelMetadata(providers, targetId, request.signal);
38598
+ const { model, refined: refined2 } = prepareBackgroundMemoryModel(providers, targetId, wireModelId);
38599
+ if (refined2.runtimeId !== initial.refined.runtimeId || canonicalEndpointKey(refined2.target) !== endpointKey) {
38600
+ throw new Error("background memory target changed during preparation");
38601
+ }
38602
+ const costProvenance = normalizeCostProvenance(refined2.costProvenance);
38603
+ const apiKey = targetRequiresAuth(refined2.target, refined2.runtime) ? (await providers.auth.resolveForTarget(refined2.target, refined2.runtime, { signal: request.signal })).apiKey : LOCAL_API_KEY_FALLBACK2;
38604
+ request.signal.throwIfAborted();
38605
+ if (backgroundMemoryEndpointBusy(providers, endpointKey, [refined2.target])) {
38606
+ throw new TaskMemoryEndpointBusyError("background memory endpoint is busy");
38607
+ }
38608
+ return announceMemoryStepEndpoint({ bus, endpointKey, targetId }, async () => {
38609
+ const startedAt = Date.now();
38610
+ let observedUsage;
38611
+ const mapUsage = (completion2) => ({
38612
+ ...completion2.usage,
38364
38613
  targetId,
38365
- attributedModelId: refined.wireModelId,
38366
- input: completion.usage.input,
38367
- output: completion.usage.output,
38368
- cacheRead: completion.usage.cacheRead,
38369
- cacheWrite: completion.usage.cacheWrite,
38370
- reasoning: completion.usage.reasoning,
38371
- totalTokens: completion.usage.totalTokens,
38372
- costUsd: completion.usage.costUsd,
38614
+ attributedModelId: refined2.wireModelId,
38373
38615
  costProvenance,
38374
38616
  durationMs: Date.now() - startedAt,
38375
- backend: completion.backend
38376
- }
38377
- };
38378
- })
38617
+ backend: completion2.backend
38618
+ });
38619
+ const completion = await completeEngineText({
38620
+ model,
38621
+ systemPrompt: request.systemPrompt,
38622
+ userPrompt: request.userPrompt,
38623
+ maxTokens: refined2.capabilityDecisions.maxTokens > 0 ? Math.min(request.maxTokens, refined2.capabilityDecisions.maxTokens) : request.maxTokens,
38624
+ // Always off, never the operator's chat thinking level. A model that
38625
+ // reasons anyway still works: `completeEngineText` keeps only text
38626
+ // blocks, and the memory output budget leaves room for the preamble.
38627
+ thinkingLevel: "off",
38628
+ signal: request.signal,
38629
+ timeoutMs,
38630
+ onUsage: (observation) => {
38631
+ observedUsage = mapUsage(observation);
38632
+ request.onUsage?.(observedUsage);
38633
+ },
38634
+ ...apiKey === void 0 ? {} : { apiKey },
38635
+ ...refined2.target.auth?.headers ? { headers: refined2.target.auth.headers } : {}
38636
+ });
38637
+ return {
38638
+ text: completion.text,
38639
+ inputTokens: completion.inputTokens,
38640
+ outputTokens: completion.outputTokens,
38641
+ usage: observedUsage ?? mapUsage(completion)
38642
+ };
38643
+ })(request);
38644
+ }
38645
+ }
38646
+ };
38647
+ }
38648
+ function createBackgroundMemoryRouting(providers, getSettings, bus) {
38649
+ let route = null;
38650
+ let snapshot;
38651
+ let lastNotice = null;
38652
+ const noteFallback = () => {
38653
+ if (route?.selection !== "chat-fallback") {
38654
+ lastNotice = null;
38655
+ return;
38656
+ }
38657
+ const message = `Memory: ${route.fallbackReason}; selected chat fallback ${route.targetId}/${route.wireModelId} for this step, subject to available endpoint capacity.`;
38658
+ if (message === lastNotice) return;
38659
+ lastNotice = message;
38660
+ try {
38661
+ bus?.emit(BusChannels.RuntimeNotice, {
38662
+ kind: "degraded",
38663
+ level: "info",
38664
+ message,
38665
+ targetId: route.targetId,
38666
+ runtimeId: providers.getTarget(route.targetId)?.runtime ?? "unknown",
38667
+ model: route.wireModelId
38668
+ });
38669
+ } catch {
38670
+ }
38671
+ };
38672
+ return {
38673
+ getModelClient: () => {
38674
+ const current = getSettings();
38675
+ snapshot = current === void 0 ? void 0 : structuredClone(current);
38676
+ route = snapshot === void 0 ? null : createBackgroundMemoryModelClient(providers, snapshot, snapshot.context.memory.timeoutMs, bus);
38677
+ noteFallback();
38678
+ return route?.client ?? null;
38679
+ },
38680
+ getFallbackModelClient: () => {
38681
+ if (route?.selection !== "dedicated" || snapshot === void 0) return null;
38682
+ route = createBackgroundMemoryModelClient(providers, snapshot, snapshot.context.memory.timeoutMs, bus, true);
38683
+ noteFallback();
38684
+ return route?.client ?? null;
38685
+ },
38686
+ getModelMaxTokens: (configured) => route?.modelMaxTokens(configured) ?? configured,
38687
+ backgroundEndpointBusy: () => {
38688
+ if (route?.endpointKey == null || snapshot === void 0) return false;
38689
+ return backgroundMemoryEndpointBusy(providers, route.endpointKey, snapshot.targets);
38379
38690
  }
38380
38691
  };
38381
38692
  }
@@ -38402,53 +38713,79 @@ function agentRoleToolWarnings(providers, settings) {
38402
38713
  }
38403
38714
  return warnings;
38404
38715
  }
38405
- function backgroundSharesReasoningModelWithOrchestrator(providers, settings) {
38406
- const backgroundModel = settings.context.memory.model?.trim();
38407
- const orchestratorModel = settings.chat.model?.trim();
38408
- if (!backgroundModel || backgroundModel !== orchestratorModel) return false;
38409
- if (settings.context.memory.target?.trim() !== settings.chat.target?.trim()) return false;
38410
- try {
38411
- const status = providers.list().find((entry) => entry.target.id === settings.context.memory.target?.trim());
38412
- if (!status) return false;
38413
- return resolveModelCapabilities(status, backgroundModel, providers.knowledgeBase).reasoning === true;
38414
- } catch {
38415
- return false;
38716
+ async function resolveCompactionModel(settings, providers) {
38717
+ const override = settings.context.compaction.model;
38718
+ let targetId = settings.chat.target;
38719
+ let wireModelId = settings.chat.model;
38720
+ if (override !== void 0 && override !== null) {
38721
+ let selected;
38722
+ try {
38723
+ selected = resolveModelReference(override, providers);
38724
+ } catch {
38725
+ throw new Error("context.compaction.model is an invalid pattern; set a unique target/model reference");
38726
+ }
38727
+ if (!selected.ref || selected.warning) {
38728
+ throw new Error(
38729
+ "context.compaction.model must match exactly one configured model; set a unique target/model reference"
38730
+ );
38731
+ }
38732
+ targetId = selected.ref.target;
38733
+ wireModelId = selected.ref.model;
38416
38734
  }
38417
- }
38418
- function synthesizeOrchestratorModel(providers, target, wireModelId) {
38419
- const runtime = providers.getRuntime(target.runtime);
38420
- if (!runtime) return null;
38735
+ if (!targetId || !wireModelId) return null;
38736
+ await prepareBackgroundModelMetadata(providers, targetId);
38737
+ const status = providers.list().find((entry) => entry.target.id === targetId);
38738
+ if (!status?.available) {
38739
+ throw new Error("context.compaction.model target is unavailable; check the selected target with clio-coder targets");
38740
+ }
38741
+ const resolved = resolveRuntimeTarget(providers, {
38742
+ targetId,
38743
+ wireModelId,
38744
+ use: "orchestrator",
38745
+ requestedThinkingLevel: "off",
38746
+ requireTools: false,
38747
+ requireStreaming: true,
38748
+ requireOutputBudget: true
38749
+ });
38750
+ if (!resolved.ok) {
38751
+ throw new Error(
38752
+ "context.compaction.model cannot run as a summarizer; select an available HTTP chat model with an output budget"
38753
+ );
38754
+ }
38755
+ const route = resolved.target;
38421
38756
  let model;
38422
38757
  try {
38423
- const kbHit = providers.knowledgeBase?.lookup(wireModelId) ?? null;
38424
- model = runtime.synthesizeModel(target, wireModelId, kbHit);
38758
+ model = route.runtime.synthesizeModel(
38759
+ route.target,
38760
+ route.wireModelId,
38761
+ providers.knowledgeBase?.lookup(route.wireModelId) ?? null
38762
+ );
38425
38763
  } catch {
38426
- return null;
38764
+ throw new Error("context.compaction.model could not be prepared; check the selected target/model configuration");
38427
38765
  }
38428
- try {
38429
- const status = providers.list().find((entry) => entry.target.id === target.id);
38430
- if (status) {
38431
- const caps = resolveModelCapabilities(status, wireModelId, providers.knowledgeBase, {
38432
- detectedReasoning: providers.getDetectedReasoning(target.id, wireModelId)
38433
- });
38434
- applyModelCapabilityPatch(model, caps);
38766
+ const refined = refineRuntimeTargetWithModelHints(route, model, providers.knowledgeBase);
38767
+ if (refined.capabilityDecisions.maxTokens <= 0) {
38768
+ throw new Error("context.compaction.model has no output budget; select a model with a known positive output limit");
38769
+ }
38770
+ applyModelCapabilityPatch(model, refined.capabilities);
38771
+ let apiKey = LOCAL_API_KEY_FALLBACK2;
38772
+ if (targetRequiresAuth(route.target, route.runtime)) {
38773
+ const auth = await providers.auth.resolveForTarget(route.target, route.runtime);
38774
+ if (!auth.available || !auth.apiKey) {
38775
+ throw new Error(
38776
+ "context.compaction.model authentication is unavailable; authenticate the selected target with clio-coder auth"
38777
+ );
38435
38778
  }
38436
- } catch {
38779
+ apiKey = auth.apiKey;
38437
38780
  }
38438
- return model;
38439
- }
38440
- async function resolveCompactionModel(settings, providers) {
38441
- const targetId = settings.chat?.target ?? null;
38442
- const wireModelId = settings.chat?.model ?? null;
38443
- if (!targetId || !wireModelId) return null;
38444
- const target = resolveTarget(providers, targetId);
38445
- if (!target) return null;
38446
- const model = synthesizeOrchestratorModel(providers, target, wireModelId);
38447
- if (!model) return null;
38448
- const apiKey = await resolveApiKeyForTarget(target, providers);
38449
- const resolution = { model, targetId, endpointKey: canonicalEndpointKey(target) };
38450
- if (apiKey !== void 0) resolution.apiKey = apiKey;
38451
- return resolution;
38781
+ return {
38782
+ model,
38783
+ targetId: route.targetId,
38784
+ wireModelId: route.wireModelId,
38785
+ endpointKey: canonicalEndpointKey(route.target),
38786
+ apiKey,
38787
+ ...route.target.auth?.headers ? { headers: route.target.auth.headers } : {}
38788
+ };
38452
38789
  }
38453
38790
  function readSessionEntriesForCompact(sessionId) {
38454
38791
  const reader = openSession(sessionId);
@@ -38506,34 +38843,72 @@ function appendSkillActivationRegistryEvent(session, activation) {
38506
38843
  } catch {
38507
38844
  }
38508
38845
  }
38509
- async function runCompactionFlow(session, settings, providers, instructions, trigger) {
38846
+ async function runCompactionFlow(session, settings, providers, instructions, trigger, observability) {
38510
38847
  const meta = session.current();
38511
38848
  if (!meta) {
38512
38849
  throw new Error("no current session to compact; start one with /new or /resume first");
38513
38850
  }
38851
+ const stateDir = clioStateDir();
38852
+ const activeLeafTurnId = session.tree(meta.id).leafId ?? void 0;
38853
+ const isOriginCurrent = () => session.current()?.id === meta.id && (session.tree(meta.id).leafId ?? void 0) === activeLeafTurnId;
38854
+ const entries = filterEntriesToActivePath(readSessionEntriesForCompact(meta.id), activeLeafTurnId);
38855
+ if (entries.length === 0) return null;
38856
+ const systemPrompt = await readCompactionSystemPrompt(settings.context.compaction.systemPrompt, meta.cwd);
38514
38857
  const resolved = await resolveCompactionModel(settings, providers);
38515
38858
  if (!resolved) {
38516
38859
  throw new Error("no model configured; set chat.target + chat.model");
38517
38860
  }
38518
- const activeLeafTurnId = session.tree(meta.id).leafId ?? void 0;
38519
- const entries = filterEntriesToActivePath(readSessionEntriesForCompact(meta.id), activeLeafTurnId);
38520
- if (entries.length === 0) return null;
38861
+ if (!isOriginCurrent()) throw new Error("compaction session or branch changed before summarization");
38862
+ const calls = [];
38863
+ const preserveCalls = () => recordFailedCompactionCalls(
38864
+ {
38865
+ stateDir,
38866
+ sessionId: meta.id,
38867
+ repoIdentity: meta.cwdHash || cwdHash(meta.cwd),
38868
+ target: resolved.targetId,
38869
+ model: resolved.wireModelId
38870
+ },
38871
+ calls,
38872
+ isOriginCurrent() ? observability : void 0
38873
+ );
38521
38874
  const releaseEndpointSlot = resolved.endpointKey === null ? () => {
38522
38875
  } : registerForegroundStream(resolved.endpointKey);
38523
38876
  let result;
38524
38877
  try {
38525
38878
  result = await compact({
38526
38879
  entries,
38880
+ onCall: (call) => calls.push(call),
38527
38881
  model: resolved.model,
38882
+ ...systemPrompt !== void 0 ? { systemPrompt } : {},
38883
+ ...resolved.headers !== void 0 ? { headers: resolved.headers } : {},
38528
38884
  ...resolved.apiKey !== void 0 ? { apiKey: resolved.apiKey } : {},
38529
38885
  ...instructions !== void 0 ? { instructions } : {}
38530
38886
  });
38887
+ } catch (error) {
38888
+ try {
38889
+ preserveCalls();
38890
+ } catch (recordingError) {
38891
+ throw new AggregateError([error, recordingError], "compaction failed and its usage could not be fully recorded");
38892
+ }
38893
+ throw error;
38531
38894
  } finally {
38532
38895
  releaseEndpointSlot();
38533
38896
  }
38534
- if (result.messagesSummarized === 0 || result.summary.length === 0) return null;
38897
+ if (!isOriginCurrent()) {
38898
+ preserveCalls();
38899
+ throw new Error("compaction session or branch changed; summary discarded and originating usage retained");
38900
+ }
38901
+ if (result.messagesSummarized === 0 || result.summary.length === 0) {
38902
+ preserveCalls();
38903
+ if (calls.length > 0) throw new Error("compaction returned no summary; reported usage retained without a checkpoint");
38904
+ return null;
38905
+ }
38906
+ if (result.usage) {
38907
+ result.usage = { ...result.usage, targetId: resolved.targetId, modelId: resolved.wireModelId };
38908
+ }
38535
38909
  const entry = {
38536
38910
  kind: "compactionSummary",
38911
+ turnId: randomUUID3(),
38537
38912
  parentTurnId: result.firstKeptTurnId ?? null,
38538
38913
  summary: result.summary,
38539
38914
  tokensBefore: result.tokensBefore,
@@ -38547,11 +38922,38 @@ async function runCompactionFlow(session, settings, providers, instructions, tri
38547
38922
  ...result.usage !== void 0 ? { usage: result.usage } : {}
38548
38923
  };
38549
38924
  if (trigger !== void 0) entry.trigger = trigger;
38550
- session.appendEntry(entry);
38925
+ try {
38926
+ session.appendEntry(entry);
38927
+ } catch (error) {
38928
+ try {
38929
+ if (!compactionCheckpointWasWritten(sessionPaths(meta).current, entry.turnId)) preserveCalls();
38930
+ } catch (recordingError) {
38931
+ throw new AggregateError(
38932
+ [error, recordingError],
38933
+ "compaction checkpoint persistence is unresolved; usage was not duplicated"
38934
+ );
38935
+ }
38936
+ throw error;
38937
+ }
38551
38938
  return result;
38552
38939
  }
38553
- function createProductionAutoCompact(session, getSettings, providers) {
38554
- return (instructions, trigger) => runCompactionFlow(session, getSettings(), providers, instructions, trigger);
38940
+ function compactionCheckpointWasWritten(path2, turnId) {
38941
+ let malformed = false;
38942
+ for (const line of readFileSync10(path2, "utf8").split("\n")) {
38943
+ if (line.trim().length === 0) continue;
38944
+ try {
38945
+ const entry = JSON.parse(line);
38946
+ if (entry && typeof entry === "object" && "turnId" in entry && entry.turnId === turnId && "kind" in entry && entry.kind === "compactionSummary")
38947
+ return true;
38948
+ } catch {
38949
+ malformed = true;
38950
+ }
38951
+ }
38952
+ if (malformed) throw new Error("cannot prove checkpoint absence in a malformed session ledger");
38953
+ return false;
38954
+ }
38955
+ function createProductionAutoCompact(session, getSettings, providers, observability) {
38956
+ return (instructions, trigger) => runCompactionFlow(session, getSettings(), providers, instructions, trigger, observability);
38555
38957
  }
38556
38958
  function estimateTokensFromSummary(summary) {
38557
38959
  return Math.max(1, ceilChars(summary.length));
@@ -38654,7 +39056,7 @@ async function bootOrchestrator(options = {}) {
38654
39056
  let protectedArtifactStateForDispatch = null;
38655
39057
  const muxInteractive = !options.headless && options.acp === void 0 && process.env.CLIO_CODER_INTERACTIVE === "1";
38656
39058
  const muxEnablement = resolvePanesEnablement(options.panes, options.startupSettings?.interface.panes.enabled);
38657
- const withPanes = muxInteractive && muxEnablement !== "off" ? await import("./with-panes-BYOJCLAM.js") : null;
39059
+ const withPanes = muxInteractive && muxEnablement !== "off" ? await import("./with-panes-4GCGSL7J.js") : null;
38658
39060
  const result = await loadDomains(
38659
39061
  [
38660
39062
  options.startupSettings ? createConfigDomainModule(options.startupSettings) : ConfigDomainModule,
@@ -38902,49 +39304,21 @@ async function bootOrchestrator(options = {}) {
38902
39304
  middleware.registerHook(
38903
39305
  createSkillActivationObserver((activation) => appendSkillActivationRegistryEvent(session, activation))
38904
39306
  );
38905
- if (resources) {
38906
- middleware.registerHook(
38907
- createSkillsReminderRegistration({
38908
- countModelVisibleSkills: () => modelVisibleSkills(resources.skills(process.cwd()).items).length,
38909
- // Same lookup context(scope="skills") lists under its Marketplace
38910
- // heading, minus what is already installed, so the count the
38911
- // reminder quotes is the count the listing will show.
38912
- countInstallableSkills: () => {
38913
- const installed2 = new Set(resources.skills(process.cwd()).items.map((skill) => skill.name));
38914
- return discoverMarketplaceSkills({ cwd: process.cwd() }).skills.filter((skill) => !installed2.has(skill.name)).length;
38915
- }
38916
- })
38917
- );
38918
- }
38919
39307
  middleware.registerHook(createTaskBoardReminderRegistration());
38920
39308
  const taskMemoryBank = new TaskMemoryBank();
38921
- let taskMemorySessionId = session?.current()?.id ?? null;
38922
- const ensureTaskMemorySession = () => {
38923
- const currentSessionId = session?.current()?.id ?? null;
38924
- if (currentSessionId === taskMemorySessionId) return;
38925
- taskMemoryBank.clear();
38926
- taskMemorySessionId = currentSessionId;
38927
- };
38928
39309
  const memorySettings = (config?.get() ?? readSettings()).context.memory;
38929
39310
  let deferredMemoryReminderSink = null;
38930
39311
  let deferredWatchdogNoticeSink = null;
38931
39312
  const memoryTracePath = taskMemoryTracePath();
38932
39313
  const memoryTrace = memoryTracePath === null ? null : createTaskMemoryTrace(memoryTracePath);
38933
- let backgroundMemoryRoute = null;
38934
- const recordBackgroundMemoryUsage = (usage) => {
39314
+ const captureBackgroundMemoryUsage = () => {
38935
39315
  const meta = session?.current() ?? null;
38936
- try {
38937
- recordBackgroundMemoryStep({
38938
- usage,
38939
- stateDir: clioStateDir(),
38940
- sessionId: meta?.id ?? null,
38941
- // The identity the session ledger is filed under, so `usage report
38942
- // --repo` selects these rows with the same hash it selects ledgers with.
38943
- repoIdentity: meta ? meta.cwdHash || cwdHash(meta.cwd || process.cwd()) : null,
38944
- ...observability === void 0 ? {} : { observability }
38945
- });
38946
- } catch {
38947
- }
39316
+ return captureTaskMemoryUsage({
39317
+ stateDir: clioStateDir(),
39318
+ sessionId: meta?.id ?? null,
39319
+ repoIdentity: meta ? meta.cwdHash || cwdHash(meta.cwd || process.cwd()) : null,
39320
+ ...observability === void 0 ? {} : { observability }
39321
+ });
38948
39322
  };
38949
39323
  const proposeInjectedMemoryEntries = (entries) => {
38950
39324
  const meta = session?.current() ?? null;
@@ -38973,7 +39347,6 @@ async function bootOrchestrator(options = {}) {
38973
39347
  deliversDeferredReminders: options.headless === void 0,
38974
39348
  onDeferredReminder: (message) => deferredMemoryReminderSink?.(message),
38975
39349
  getSettings: () => {
38976
- ensureTaskMemorySession();
38977
39350
  const memory = effectiveSettingsForDispatch?.().context.memory ?? memorySettings;
38978
39351
  return {
38979
39352
  enabled: memory.enabled,
@@ -38983,28 +39356,17 @@ async function bootOrchestrator(options = {}) {
38983
39356
  timeoutMs: memory.timeoutMs
38984
39357
  };
38985
39358
  },
38986
- getModelClient: () => {
38987
- const settings = effectiveSettingsForDispatch?.();
38988
- backgroundMemoryRoute = settings === void 0 ? null : createBackgroundMemoryModelClient(providers, settings, settings.context.memory.timeoutMs, bus);
38989
- return backgroundMemoryRoute?.client ?? null;
38990
- },
38991
- getModelMaxTokens: (configuredMaxTokens) => backgroundMemoryRoute?.modelMaxTokens(configuredMaxTokens) ?? configuredMaxTokens,
38992
- // A single-slot local server serves one request at a time, so a memory step
38993
- // started while the operator's turn is streaming either waits behind it or
38994
- // makes the server swap the resident model out to answer. The chat loop
38995
- // registers its stream on the endpoint it streams against, so the two are
38996
- // compared by the same canonical key dispatch admission counts slots on.
38997
- backgroundEndpointBusy: () => {
38998
- const endpointKey = backgroundMemoryRoute?.endpointKey ?? null;
38999
- if (endpointKey === null) return false;
39000
- return (foregroundStreamUsage()[endpointKey] ?? 0) > 0;
39001
- },
39002
- onStepUsage: (usage) => recordBackgroundMemoryUsage(usage),
39359
+ ...createBackgroundMemoryRouting(providers, () => effectiveSettingsForDispatch?.(), bus),
39360
+ captureStepUsage: captureBackgroundMemoryUsage,
39003
39361
  onInjectedEntries: (entries) => proposeInjectedMemoryEntries(entries)
39004
39362
  });
39005
39363
  middleware.registerHook(memoryIntervention);
39006
39364
  const unsubscribeMemoryLoop = bus.on(BusChannels.LoopBlocked, () => memoryIntervention.signalLoop());
39007
- termination.onDrain(() => unsubscribeMemoryLoop());
39365
+ const disposeMemoryLifecycle = bindTaskMemoryLifecycle(bus, memoryIntervention);
39366
+ termination.onDrain(() => {
39367
+ unsubscribeMemoryLoop();
39368
+ disposeMemoryLifecycle();
39369
+ });
39008
39370
  if (contextDomain) {
39009
39371
  middleware.registerHook(createFileMutationObserver(({ paths }) => contextDomain.noteFileChanges(paths)));
39010
39372
  }
@@ -39025,12 +39387,26 @@ async function bootOrchestrator(options = {}) {
39025
39387
  let activeAcpSessionAutonomy = null;
39026
39388
  const resolveBaselineAutonomy = () => effectiveSettingsForDispatch?.().safety.autonomy ?? options.headless?.autonomy ?? (config?.get() ?? readSettings()).safety.autonomy ?? "auto-edit";
39027
39389
  const resolveEffectiveAutonomy = () => activeAcpSessionAutonomy ?? resolveBaselineAutonomy();
39390
+ if (resources) {
39391
+ middleware.registerHook(
39392
+ createSkillsReminderRegistration({
39393
+ countModelVisibleSkills: () => modelVisibleSkills(resources.skills(process.cwd()).items).length,
39394
+ // Same lookup context(scope="skills") lists under its Marketplace
39395
+ // heading, minus what is already installed, so the count the
39396
+ // reminder quotes is the count the listing will show.
39397
+ countInstallableSkills: () => {
39398
+ const installed2 = new Set(resources.skills(process.cwd()).items.map((skill) => skill.name));
39399
+ return discoverMarketplaceSkills({ cwd: process.cwd() }).skills.filter((skill) => !installed2.has(skill.name)).length;
39400
+ },
39401
+ modelMayActivateSkills: () => modelMayActivateSkills(resolveEffectiveAutonomy())
39402
+ })
39403
+ );
39404
+ }
39028
39405
  if (resources) {
39029
39406
  middleware.registerHook(
39030
39407
  createMarketplaceOfferRegistration({
39031
39408
  listInstalledSkillNames: () => resources.skills(process.cwd()).items.map((skill) => skill.name),
39032
39409
  listMarketplaceEntries: () => discoverMarketplaceSkills({ cwd: process.cwd() }).skills,
39033
- getAutonomy: resolveEffectiveAutonomy,
39034
39410
  installEntry: (entry, scope) => {
39035
39411
  const installed2 = installSkill({ source: entry.sourceUrl, scope, name: entry.name, cwd: process.cwd() });
39036
39412
  return { path: installed2.path, sourceUrl: installed2.sourceUrl, installedHash: installed2.installedHash };
@@ -39189,7 +39565,6 @@ async function bootOrchestrator(options = {}) {
39189
39565
  return taskMemoryHandoffSeedOffer(process.cwd(), getCurrentSettings().context.memory.enabled);
39190
39566
  };
39191
39567
  const seedCurrentTaskMemoryFromHandoff = () => {
39192
- ensureTaskMemorySession();
39193
39568
  return seedTaskMemoryFromNewestHandoff(taskMemoryBank, process.cwd(), getCurrentSettings().context.memory.enabled);
39194
39569
  };
39195
39570
  if (resumedSessionAtBoot) {
@@ -39362,6 +39737,7 @@ async function bootOrchestrator(options = {}) {
39362
39737
  return key === null ? null : registerForegroundStream(key);
39363
39738
  },
39364
39739
  getSettings: getCurrentSettings,
39740
+ getAutonomy: resolveEffectiveAutonomy,
39365
39741
  providers,
39366
39742
  middleware,
39367
39743
  middlewareToolChoice,
@@ -39390,7 +39766,6 @@ async function bootOrchestrator(options = {}) {
39390
39766
  }
39391
39767
  },
39392
39768
  getTaskMemoryHandoffSource: () => {
39393
- ensureTaskMemorySession();
39394
39769
  const meta = session?.current();
39395
39770
  if (!meta) throw new Error("task memory handoff requires an active session");
39396
39771
  const settings = getCurrentSettings();
@@ -39414,7 +39789,7 @@ async function bootOrchestrator(options = {}) {
39414
39789
  },
39415
39790
  ...session ? {
39416
39791
  readSessionEntries: readCurrentSessionEntries,
39417
- autoCompact: createProductionAutoCompact(session, getCurrentSettings, providers)
39792
+ autoCompact: createProductionAutoCompact(session, getCurrentSettings, providers, observability)
39418
39793
  } : {},
39419
39794
  toolRegistry,
39420
39795
  hasAttachedDispatch: () => dispatchBackground.size() > 0,
@@ -39628,7 +40003,6 @@ async function bootOrchestrator(options = {}) {
39628
40003
  supersedeDecision: (interviewId, key, correction) => decisionBoard.supersede(interviewId, key, correction),
39629
40004
  userTasks,
39630
40005
  getTaskMemoryStatus: () => {
39631
- ensureTaskMemorySession();
39632
40006
  const settings = getCurrentSettings();
39633
40007
  const bank = taskMemoryBank.snapshot();
39634
40008
  return {
@@ -39758,10 +40132,8 @@ async function bootOrchestrator(options = {}) {
39758
40132
  ...session ? {
39759
40133
  onResumeSession: (sessionId) => {
39760
40134
  try {
39761
- const previousSessionId = session.current()?.id ?? null;
39762
40135
  session.resume(sessionId);
39763
40136
  taskBoard.snapshot();
39764
- if (previousSessionId !== sessionId) ensureTaskMemorySession();
39765
40137
  } catch (err) {
39766
40138
  process.stderr.write(
39767
40139
  `[/resume] failed to resume ${sessionId}: ${err instanceof Error ? err.message : String(err)}
@@ -39776,13 +40148,11 @@ async function bootOrchestrator(options = {}) {
39776
40148
  if (settings.chat.model) input.model = settings.chat.model;
39777
40149
  session.create(input);
39778
40150
  taskBoard.snapshot();
39779
- ensureTaskMemorySession();
39780
40151
  },
39781
40152
  onForkSession: (parentTurnId) => {
39782
40153
  try {
39783
40154
  session.fork(parentTurnId);
39784
40155
  taskBoard.snapshot();
39785
- ensureTaskMemorySession();
39786
40156
  } catch (err) {
39787
40157
  process.stderr.write(
39788
40158
  `[/fork] failed at turn ${parentTurnId}: ${err instanceof Error ? err.message : String(err)}
@@ -39803,6 +40173,9 @@ async function bootOrchestrator(options = {}) {
39803
40173
  return { exitCode: 0, bootTimeMs: timer.snapshot().totalMs };
39804
40174
  }
39805
40175
  export {
39806
- bootOrchestrator
40176
+ bootOrchestrator,
40177
+ createBackgroundMemoryModelClient,
40178
+ createBackgroundMemoryRouting,
40179
+ createProductionAutoCompact
39807
40180
  };
39808
- //# sourceMappingURL=orchestrator-DDMPR3PY.js.map
40181
+ //# sourceMappingURL=orchestrator-VDFAEFAI.js.map