chainlesschain 0.166.101 → 0.166.103

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 (219) hide show
  1. package/package.json +2 -2
  2. package/src/assets/linux-subreaper/linux-arm64/manifest.json +1 -1
  3. package/src/assets/linux-subreaper/linux-x64/manifest.json +1 -1
  4. package/src/assets/web-panel/assets/{AIOps-BjBS_29I.js → AIOps-BLrXpdnP.js} +1 -1
  5. package/src/assets/web-panel/assets/{ActionButton-CUnnQUaj.js → ActionButton-C0xy9uFy.js} +1 -1
  6. package/src/assets/web-panel/assets/{Analytics-BqYZxgnY.js → Analytics-C6EephQP.js} +3 -3
  7. package/src/assets/web-panel/assets/{AppLayout-m8B886ka.js → AppLayout-ZCXdOD9y.js} +5 -5
  8. package/src/assets/web-panel/assets/{Artifacts-JEOxU3Ug.js → Artifacts-D4MfZ-pl.js} +1 -1
  9. package/src/assets/web-panel/assets/{Audit-DAXS5c9J.js → Audit-BQ8c3bBu.js} +1 -1
  10. package/src/assets/web-panel/assets/{BackgroundAgents-e3a9XHw3.js → BackgroundAgents-BOA7_ljM.js} +1 -1
  11. package/src/assets/web-panel/assets/{Backup-D3Qmp68h.js → Backup-60uiQjGT.js} +1 -1
  12. package/src/assets/web-panel/assets/{BaseInput-C7CXyiUl.js → BaseInput-BDvEbGs_.js} +1 -1
  13. package/src/assets/web-panel/assets/{Chat-2AHlAGi8.js → Chat-B3IkAuFQ.js} +6 -6
  14. package/src/assets/web-panel/assets/ChatBubbleRenderer-n6BVStHf.js +1 -0
  15. package/src/assets/web-panel/assets/{Checkbox-YfBuQlBH.js → Checkbox-njGbfJWq.js} +1 -1
  16. package/src/assets/web-panel/assets/{Codegen-DCCQDfTL.js → Codegen-CF7DtdxC.js} +1 -1
  17. package/src/assets/web-panel/assets/{Col-03i2WfrV.js → Col-C_3Zix40.js} +1 -1
  18. package/src/assets/web-panel/assets/{Community-CJQIpng6.js → Community-CzU-ZC2d.js} +1 -1
  19. package/src/assets/web-panel/assets/{Compact-CCtcQ2pq.js → Compact-BgeqsPRh.js} +1 -1
  20. package/src/assets/web-panel/assets/{Compliance-Vxl7ZszJ.js → Compliance-6l7cwiqp.js} +1 -1
  21. package/src/assets/web-panel/assets/{Cowork-DN-BwA8I.js → Cowork-D4s905fI.js} +2 -2
  22. package/src/assets/web-panel/assets/{Cron-Dc2Q46X7.js → Cron-CGTYSxRS.js} +2 -2
  23. package/src/assets/web-panel/assets/{Crosschain-CQCblsl-.js → Crosschain-BnSo-Yt3.js} +1 -1
  24. package/src/assets/web-panel/assets/{DID-YYvqUR8C.js → DID-Dm4vk2X1.js} +2 -2
  25. package/src/assets/web-panel/assets/{Dashboard-Cafy3DZT.js → Dashboard-D7H-PZ_N.js} +2 -2
  26. package/src/assets/web-panel/assets/{Dropdown-BOyYpIpv.js → Dropdown-COslkgxn.js} +1 -1
  27. package/src/assets/web-panel/assets/{EmailListRenderer-B7NYjc1j.js → EmailListRenderer-CJWEetmk.js} +1 -1
  28. package/src/assets/web-panel/assets/{EvolutionSettings-C5wfxztf.js → EvolutionSettings-BbzebAWe.js} +1 -1
  29. package/src/assets/web-panel/assets/{FamilyGuardDashboard-aA7KnDGK.js → FamilyGuardDashboard-BsoTOXwk.js} +1 -1
  30. package/src/assets/web-panel/assets/{Federation-DlgXUu1L.js → Federation-Ck5kM_5H.js} +1 -1
  31. package/src/assets/web-panel/assets/{FormItemContext-B5YsrLDg.js → FormItemContext-gShxCqtF.js} +1 -1
  32. package/src/assets/web-panel/assets/{GenericCardRenderer-DaWojPFw.js → GenericCardRenderer-DarN1G-z.js} +1 -1
  33. package/src/assets/web-panel/assets/{Git-dkhh6Fx2.js → Git-CJfpLyP5.js} +2 -2
  34. package/src/assets/web-panel/assets/{Governance-Cz6vmkjc.js → Governance-CVcJmpQz.js} +1 -1
  35. package/src/assets/web-panel/assets/{Inference-DWt0hbh8.js → Inference-ComU_ig8.js} +1 -1
  36. package/src/assets/web-panel/assets/{KnowledgeGraph-BZJ0Z-nL.js → KnowledgeGraph-35hprFJy.js} +1 -1
  37. package/src/assets/web-panel/assets/{Logs-BaBBmL1A.js → Logs-BQDqBTz0.js} +2 -2
  38. package/src/assets/web-panel/assets/MarkdownRenderer-BpdGAVCC.js +1 -0
  39. package/src/assets/web-panel/assets/{Marketplace-ct8sgQ0s.js → Marketplace-B9O9OKnn.js} +1 -1
  40. package/src/assets/web-panel/assets/{McpTools-CXKCRGYQ.js → McpTools-VMKxA4Wc.js} +3 -3
  41. package/src/assets/web-panel/assets/{Memory-O7ZwlS6a.js → Memory-CcBbf3Bc.js} +2 -2
  42. package/src/assets/web-panel/assets/{MobileBridge-By12C-eC.js → MobileBridge-D7myz46N.js} +1 -1
  43. package/src/assets/web-panel/assets/{MobileProjects-Ba-EVdex.js → MobileProjects-Da5KBXyx.js} +1 -1
  44. package/src/assets/web-panel/assets/{Mtc-g-932zV2.js → Mtc-x3NPZfuL.js} +5 -5
  45. package/src/assets/web-panel/assets/{MtcAudit-BW8hB0ly.js → MtcAudit-CwnzptEC.js} +4 -4
  46. package/src/assets/web-panel/assets/{Multisig-zspLaMbT.js → Multisig-CCAxf4Ye.js} +3 -3
  47. package/src/assets/web-panel/assets/{NLProgramming-dJeUPDoq.js → NLProgramming-CptHKz-Q.js} +1 -1
  48. package/src/assets/web-panel/assets/{Notes-C4msiRQL.js → Notes-0uEp4DCJ.js} +3 -3
  49. package/src/assets/web-panel/assets/{NotificationSettings-MOCHM-qg.js → NotificationSettings-DthvrOLd.js} +1 -1
  50. package/src/assets/web-panel/assets/{OrderTableRenderer-CX0T66NM.js → OrderTableRenderer-CxXuPzZg.js} +1 -1
  51. package/src/assets/web-panel/assets/{Organization-DOZurBfk.js → Organization-BWf2tmQQ.js} +4 -4
  52. package/src/assets/web-panel/assets/{Overflow-qOT9BhUp.js → Overflow-BbvAtEth.js} +1 -1
  53. package/src/assets/web-panel/assets/{P2P-BMoy7Eo4.js → P2P-zBo6enit.js} +2 -2
  54. package/src/assets/web-panel/assets/{PdhVaultBrowser-ByyV1q-D.js → PdhVaultBrowser-D_LMQ4A4.js} +3 -3
  55. package/src/assets/web-panel/assets/{Permissions-6Qyro4ye.js → Permissions-C1ucb2ck.js} +4 -4
  56. package/src/assets/web-panel/assets/{PersonalDataHub-DR3DRNSX.js → PersonalDataHub-Bz64RddJ.js} +5 -5
  57. package/src/assets/web-panel/assets/{Pipeline-Cr6TTdud.js → Pipeline-DXJt3y3_.js} +1 -1
  58. package/src/assets/web-panel/assets/{Privacy-B70otG0l.js → Privacy-DiZ8b_ut.js} +1 -1
  59. package/src/assets/web-panel/assets/{ProjectInit-BHCqxoSk.js → ProjectInit-DfLKKrJ4.js} +2 -2
  60. package/src/assets/web-panel/assets/{ProjectSettings-B80GZpZk.js → ProjectSettings-Ct6kJuIY.js} +2 -2
  61. package/src/assets/web-panel/assets/{Projects-cq-b9-fQ.js → Projects-BBUMlZ3m.js} +1 -1
  62. package/src/assets/web-panel/assets/{Providers-dsVTimHa.js → Providers-DYVQPHvc.js} +1 -1
  63. package/src/assets/web-panel/assets/{QrScannerModal-DRJ8YepZ.js → QrScannerModal-23Il7iPp.js} +1 -1
  64. package/src/assets/web-panel/assets/{QuickAsk-BSXdEjIB.js → QuickAsk-WgOZKrv1.js} +1 -1
  65. package/src/assets/web-panel/assets/{Recommend-CQLJGyKC.js → Recommend-CRIka6xT.js} +1 -1
  66. package/src/assets/web-panel/assets/{RemoteSession-BF9WUFVZ.js → RemoteSession-DOy3GjVZ.js} +2 -2
  67. package/src/assets/web-panel/assets/{Reputation-Cy9o5tvW.js → Reputation-BXyi6xeR.js} +1 -1
  68. package/src/assets/web-panel/assets/{Row-BP346_3b.js → Row-CoMxuIcR.js} +1 -1
  69. package/src/assets/web-panel/assets/{RssFeed-BKulxXf3.js → RssFeed-87hPkoM6.js} +3 -3
  70. package/src/assets/web-panel/assets/{Search-EemQj2Dv.js → Search-B1EqFCO4.js} +1 -1
  71. package/src/assets/web-panel/assets/{Security-DcWPAwwk.js → Security-HcC41eGs.js} +4 -4
  72. package/src/assets/web-panel/assets/{Services-Bltqciay.js → Services-BqLwmvCM.js} +2 -2
  73. package/src/assets/web-panel/assets/{Skeleton-BwRyOGY8.js → Skeleton-CIMmjW4r.js} +1 -1
  74. package/src/assets/web-panel/assets/{Skills-D98qlvpJ.js → Skills-CgurezJU.js} +1 -1
  75. package/src/assets/web-panel/assets/{Sla-BUTtBMY0.js → Sla-CJuRuqPE.js} +1 -1
  76. package/src/assets/web-panel/assets/{SpeechSettings-C7kcY_98.js → SpeechSettings-BUwsbd1o.js} +1 -1
  77. package/src/assets/web-panel/assets/{SyncSettings-Bsk6lKvT.js → SyncSettings-qo04TOX-.js} +2 -2
  78. package/src/assets/web-panel/assets/Tasks-QEFENVsp.js +1 -0
  79. package/src/assets/web-panel/assets/{Templates-BUM6LwPs.js → Templates-D1PTczPW.js} +1 -1
  80. package/src/assets/web-panel/assets/{Tenant-D9TkOm7z.js → Tenant-Bi0FkEPR.js} +1 -1
  81. package/src/assets/web-panel/assets/{Terminal-CP8ZVErN.js → Terminal-DfSt3bIF.js} +2 -2
  82. package/src/assets/web-panel/assets/{TimelineRenderer-V3SoKZ1T.js → TimelineRenderer-B7bIVs4R.js} +1 -1
  83. package/src/assets/web-panel/assets/{Tokens-CCRlUTOA.js → Tokens-B6w5XrMb.js} +1 -1
  84. package/src/assets/web-panel/assets/{Trigger-CznUcPme.js → Trigger-XXVSDWiF.js} +1 -1
  85. package/src/assets/web-panel/assets/{Trust-D1GIk_NF.js → Trust-DYvlgcK-.js} +1 -1
  86. package/src/assets/web-panel/assets/{UkeySign-DHtvtyC-.js → UkeySign-XyYwJMBM.js} +1 -1
  87. package/src/assets/web-panel/assets/{VideoEditing-CVxdaJIq.js → VideoEditing-C47WbtHH.js} +1 -1
  88. package/src/assets/web-panel/assets/{Wallet-D221OjyE.js → Wallet-CYfqTj_C.js} +4 -4
  89. package/src/assets/web-panel/assets/{WebAuthn-Cw0-ESsq.js → WebAuthn-3AduFn1l.js} +3 -3
  90. package/src/assets/web-panel/assets/{WorkflowEditor-ZYScrBx3.js → WorkflowEditor-DHYEHjMJ.js} +1 -1
  91. package/src/assets/web-panel/assets/{chat-BU0e1obR.js → chat-AeehErSw.js} +1 -1
  92. package/src/assets/web-panel/assets/{colors-gzYweuha.js → colors-DKXJ8paX.js} +1 -1
  93. package/src/assets/web-panel/assets/{compact-item-ChAXal_k.js → compact-item-BOlCiomD.js} +1 -1
  94. package/src/assets/web-panel/assets/{createContext-of3FolD7.js → createContext-BAP6U85b.js} +1 -1
  95. package/src/assets/web-panel/assets/devWarning-rGldFhxo.js +1 -0
  96. package/src/assets/web-panel/assets/{hasIn-4PsK_Kx8.js → hasIn-BLmeL1Xe.js} +1 -1
  97. package/src/assets/web-panel/assets/{index-Cn1clrxx.js → index-B0IjlB9m.js} +1 -1
  98. package/src/assets/web-panel/assets/{index-BOeX7BzS.js → index-BAS2QqLn.js} +1 -1
  99. package/src/assets/web-panel/assets/{index-Cx4Z6nUl.js → index-BRcJlKSa.js} +1 -1
  100. package/src/assets/web-panel/assets/{index-DjRAIRX7.js → index-BSOenF5s.js} +1 -1
  101. package/src/assets/web-panel/assets/{index-Djfgsjfy.js → index-BTnp4Nt3.js} +1 -1
  102. package/src/assets/web-panel/assets/{index-BfI4dXbi.js → index-BhcpWl5z.js} +1 -1
  103. package/src/assets/web-panel/assets/{index-D_5LTPMH.js → index-Bn54FU3i.js} +1 -1
  104. package/src/assets/web-panel/assets/{index-CyDQNprx.js → index-Bpx54vfs.js} +1 -1
  105. package/src/assets/web-panel/assets/{index-DEXBckNR.js → index-Bs2O3f81.js} +1 -1
  106. package/src/assets/web-panel/assets/{index-Ef5YkVAn.js → index-Bt-FCVzh.js} +1 -1
  107. package/src/assets/web-panel/assets/{index-E8oDMSAo.js → index-BuUwKmEI.js} +1 -1
  108. package/src/assets/web-panel/assets/{index-BdxRVNPY.js → index-C5AKY6bJ.js} +1 -1
  109. package/src/assets/web-panel/assets/{index-Wr91cnWr.js → index-C8qi53Ki.js} +1 -1
  110. package/src/assets/web-panel/assets/{index-B5L7zddz.js → index-CFKzWIo8.js} +1 -1
  111. package/src/assets/web-panel/assets/{index-Dy0ojH6G.js → index-CRa4pAaM.js} +3 -3
  112. package/src/assets/web-panel/assets/{index-wo0De0iG.js → index-CaHhfpBi.js} +1 -1
  113. package/src/assets/web-panel/assets/{index-D-Zss5KL.js → index-CdNSmvog.js} +1 -1
  114. package/src/assets/web-panel/assets/{index-DEzjUgkl.js → index-CgtaOzMo.js} +1 -1
  115. package/src/assets/web-panel/assets/{index-DDYj14Q4.js → index-CiqeF0Pf.js} +1 -1
  116. package/src/assets/web-panel/assets/{index-D_9k680X.js → index-ClpwxOXo.js} +1 -1
  117. package/src/assets/web-panel/assets/{index-D1PGrfHE.js → index-Co7pjF53.js} +1 -1
  118. package/src/assets/web-panel/assets/index-Cw-lfvvV.js +1 -0
  119. package/src/assets/web-panel/assets/{index-CeEE_SGZ.js → index-DE7cbDDe.js} +1 -1
  120. package/src/assets/web-panel/assets/{index-CxzBcXOa.js → index-DQLQuwpA.js} +1 -1
  121. package/src/assets/web-panel/assets/{index-DEB5fQqG.js → index-DWYqOI1A.js} +1 -1
  122. package/src/assets/web-panel/assets/{index-CO2owKe0.js → index-De2fPxdb.js} +1 -1
  123. package/src/assets/web-panel/assets/{index-1dzYRBbg.js → index-DpZqbc4w.js} +1 -1
  124. package/src/assets/web-panel/assets/{index-CGFL59q4.js → index-DsQ38fVY.js} +1 -1
  125. package/src/assets/web-panel/assets/{index-DsoV9rzn.js → index-Dv8-g1pY.js} +1 -1
  126. package/src/assets/web-panel/assets/{index-yMf7zmWv.js → index-EKNODw4P.js} +1 -1
  127. package/src/assets/web-panel/assets/{index-CHv_63Cp.js → index-FPXLIXoy.js} +1 -1
  128. package/src/assets/web-panel/assets/{index-CCLsbul3.js → index-IlzfIRNh.js} +1 -1
  129. package/src/assets/web-panel/assets/{index-cFkMIx1x.js → index-OLKhib9T.js} +1 -1
  130. package/src/assets/web-panel/assets/{index-Bftq5rJR.js → index-PEe9OWEQ.js} +1 -1
  131. package/src/assets/web-panel/assets/index-QBXRSyoZ.js +1 -0
  132. package/src/assets/web-panel/assets/{index-DJVrzXtk.js → index-T28naovw.js} +1 -1
  133. package/src/assets/web-panel/assets/{index-By-pper5.js → index-ZMbXl5lo.js} +1 -1
  134. package/src/assets/web-panel/assets/{index-DZ0oKtBg.js → index-urPvyUVk.js} +1 -1
  135. package/src/assets/web-panel/assets/{index-D_ialOHx.js → index-wyKpTsGM.js} +1 -1
  136. package/src/assets/web-panel/assets/{initDefaultProps-D0Bx6pgr.js → initDefaultProps-CDWa1rnn.js} +1 -1
  137. package/src/assets/web-panel/assets/{motion-BnLuJqJ5.js → motion-CX2Cnsd5.js} +1 -1
  138. package/src/assets/web-panel/assets/{move-Bxpq9xgR.js → move-Bfe1NcEF.js} +1 -1
  139. package/src/assets/web-panel/assets/{mtc-parser-BdmrNhOs.js → mtc-parser-DbdqleHE.js} +1 -1
  140. package/src/assets/web-panel/assets/{omit-tjJD34BZ.js → omit-CE2K7NVv.js} +1 -1
  141. package/src/assets/web-panel/assets/{pickAttrs-CMFzLt7b.js → pickAttrs-y_bZgxWG.js} +1 -1
  142. package/src/assets/web-panel/assets/{placementArrow-BZf6O3cd.js → placementArrow-BOHR4zwr.js} +1 -1
  143. package/src/assets/web-panel/assets/{responsiveObserve-DFDLazsV.js → responsiveObserve-B8Jwq05-.js} +1 -1
  144. package/src/assets/web-panel/assets/{slide-CMbTvp4Y.js → slide-BD7RJ3Kn.js} +1 -1
  145. package/src/assets/web-panel/assets/{statusUtils-FOan8MI7.js → statusUtils-BuxDJeDx.js} +1 -1
  146. package/src/assets/web-panel/assets/{styleChecker-DTABspd4.js → styleChecker-DgYQ2Q0o.js} +1 -1
  147. package/src/assets/web-panel/assets/{useFlexGapSupport-CNHXWBpY.js → useFlexGapSupport-DAHF0Fwi.js} +1 -1
  148. package/src/assets/web-panel/assets/{useFs-5K-c_RoL.js → useFs-D4kDyLFp.js} +1 -1
  149. package/src/assets/web-panel/assets/{usePersonalDataHub-Di0hL4G-.js → usePersonalDataHub-BHtSxW4A.js} +1 -1
  150. package/src/assets/web-panel/assets/{vnode-DTyDv4ja.js → vnode-CHKtdqW0.js} +1 -1
  151. package/src/assets/web-panel/assets/{zoom-ontRt8ft.js → zoom-CIZAMma9.js} +1 -1
  152. package/src/assets/web-panel/index.html +1 -1
  153. package/src/command-help-index.json +1 -1
  154. package/src/commands/agent.js +64 -40
  155. package/src/commands/ask.js +6 -4
  156. package/src/commands/team.js +28 -19
  157. package/src/data/changelog.json +26 -0
  158. package/src/harness/prompt-compressor.js +2 -0
  159. package/src/lib/advisor-runtime.js +4 -2
  160. package/src/lib/agent-ipc-bus.js +2 -0
  161. package/src/lib/background-agent-keeper-client.js +3 -0
  162. package/src/lib/browser-automation.js +4 -0
  163. package/src/lib/cc-android-bridge.js +4 -0
  164. package/src/lib/chat-core.js +11 -9
  165. package/src/lib/cloud/cloud-client.js +10 -1
  166. package/src/lib/config-schema.js +18 -5
  167. package/src/lib/context-memory-kernel/memory-query-index.js +5 -2
  168. package/src/lib/context-memory-kernel/runtime.js +4 -0
  169. package/src/lib/context-memory-kernel/segmented-memory-port.js +28 -3
  170. package/src/lib/context-source-ledger.js +52 -9
  171. package/src/lib/cowork-adapter.js +4 -3
  172. package/src/lib/decision-layer/providers.js +16 -11
  173. package/src/lib/evolution/governed-hub-llm.js +31 -16
  174. package/src/lib/evolution/governed-hub-resolver.js +4 -0
  175. package/src/lib/evolution/governed-skill-synthesis-process-grader.js +4 -0
  176. package/src/lib/evomap-client.js +14 -2
  177. package/src/lib/formal-budget-authority.js +191 -59
  178. package/src/lib/formal-budget-contract.js +7 -13
  179. package/src/lib/formal-budget-errors.js +31 -0
  180. package/src/lib/formal-budget-lineage-registry.js +612 -0
  181. package/src/lib/formal-budget-provider-scope.js +143 -0
  182. package/src/lib/formal-budget-transport.js +235 -100
  183. package/src/lib/gateway-client-resilience.js +5 -0
  184. package/src/lib/goal-condition-engine.js +25 -2
  185. package/src/lib/hub-llm-client.js +25 -16
  186. package/src/lib/llm-config-defaults.js +10 -4
  187. package/src/lib/llm-connection-probe.js +17 -10
  188. package/src/lib/llm-pricing.js +16 -4
  189. package/src/lib/llm-providers.js +4 -1
  190. package/src/lib/model-capabilities.js +26 -0
  191. package/src/lib/model-catalog-review.js +18 -1
  192. package/src/lib/model-context-catalog.js +41 -1
  193. package/src/lib/model-failure-policy.js +2 -0
  194. package/src/lib/openai-responses.js +8 -0
  195. package/src/lib/plugin-runtime/marketplace-network.js +9 -5
  196. package/src/lib/process-execution-broker/credential-agent.js +7 -2
  197. package/src/lib/process-execution-broker/credential-transport.js +4 -0
  198. package/src/lib/process-execution-broker/index.js +8 -0
  199. package/src/lib/provider-stream.js +28 -13
  200. package/src/lib/sandbox-egress-worker.js +3 -0
  201. package/src/lib/skill-retrieval-router.js +1 -0
  202. package/src/lib/stream-retry.js +2 -0
  203. package/src/lib/sub-agent-context.js +6 -3
  204. package/src/lib/usage-pricing-context.js +33 -2
  205. package/src/lib/web-fetch.js +2 -0
  206. package/src/lib/web-search.js +5 -0
  207. package/src/repl/agent-repl.js +247 -153
  208. package/src/runtime/agent-core.js +228 -96
  209. package/src/runtime/coding-agent-contract-shared.cjs +14 -1
  210. package/src/runtime/headless-runner.js +1 -0
  211. package/src/runtime/headless-stream.js +1 -0
  212. package/src/runtime/mcp-tool-search.js +0 -0
  213. package/src/runtime/provider-stream-state.js +14 -1
  214. package/src/assets/web-panel/assets/ChatBubbleRenderer-D3KsyCUV.js +0 -1
  215. package/src/assets/web-panel/assets/MarkdownRenderer-C1yByobo.js +0 -1
  216. package/src/assets/web-panel/assets/Tasks-DvSrtz0P.js +0 -1
  217. package/src/assets/web-panel/assets/devWarning-Pa13TVrO.js +0 -1
  218. package/src/assets/web-panel/assets/index-BhQg-v6V.js +0 -1
  219. package/src/assets/web-panel/assets/index-DUD5o-vW.js +0 -1
@@ -430,9 +430,9 @@ export async function runReplDirectToolWithLedger({
430
430
  tool,
431
431
  isError: Boolean(
432
432
  executionFailed ||
433
- result?.error ||
434
- result?.is_error ||
435
- result?.isError,
433
+ result?.error ||
434
+ result?.is_error ||
435
+ result?.isError,
436
436
  ),
437
437
  skill: tool === "run_skill" ? args?.skill_name : undefined,
438
438
  ...extractPluginUsageAttribution(result),
@@ -522,8 +522,9 @@ async function _fireNotification(message, type = "info", session = null) {
522
522
  // Fire settings.json observe hooks first (best-effort)
523
523
  if (_settingsHooks) {
524
524
  try {
525
- const { runObserveHooks } =
526
- await import("../lib/settings-hook-events.js");
525
+ const { runObserveHooks } = await import(
526
+ "../lib/settings-hook-events.js"
527
+ );
527
528
  await runObserveHooks(
528
529
  _settingsHooks,
529
530
  "Notification",
@@ -3451,8 +3452,9 @@ async function startAgentReplInWorkspaceOwned(
3451
3452
  // Initialize prompt compressor (adaptive to model's context window). A
3452
3453
  // canonical cutover cannot disable the Kernel writer by toggling the legacy
3453
3454
  // compressor feature flag; the compressor remains only its summarizer.
3454
- const { resolveCliContextMemoryCutover } =
3455
- await import("../lib/context-memory-kernel/authority.js");
3455
+ const { resolveCliContextMemoryCutover } = await import(
3456
+ "../lib/context-memory-kernel/authority.js"
3457
+ );
3456
3458
  const contextMemoryCutover = resolveCliContextMemoryCutover({
3457
3459
  env: options.contextMemoryEnv || process.env,
3458
3460
  scopeKey: sessionId ? `cli:session:${sessionId}` : "cli:repl",
@@ -3499,8 +3501,9 @@ async function startAgentReplInWorkspaceOwned(
3499
3501
  });
3500
3502
  if (contextMemoryCutover.canonical) {
3501
3503
  const compatibilitySummarizer = _compressor;
3502
- const { compactLiveMessagesCanonical } =
3503
- await import("../lib/context-memory-kernel/live-compaction.js");
3504
+ const { compactLiveMessagesCanonical } = await import(
3505
+ "../lib/context-memory-kernel/live-compaction.js"
3506
+ );
3504
3507
  _compressor = {
3505
3508
  canonicalKernel: true,
3506
3509
  maxTokens: compatibilitySummarizer.maxTokens,
@@ -3595,8 +3598,9 @@ async function startAgentReplInWorkspaceOwned(
3595
3598
  // MEDIUM/HIGH-risk commands against the session's policy tier
3596
3599
  // (strict / trusted / autopilot).
3597
3600
  try {
3598
- const { getApprovalGate } =
3599
- await import("../lib/session-core-singletons.js");
3601
+ const { getApprovalGate } = await import(
3602
+ "../lib/session-core-singletons.js"
3603
+ );
3600
3604
  _approvalGate = await getApprovalGate();
3601
3605
  _approvalGate =
3602
3606
  _approvalGate?.createSessionScope?.(
@@ -3882,12 +3886,14 @@ async function startAgentReplInWorkspaceOwned(
3882
3886
  // project plugins get a process spawned. Reaped in the SessionEnd cleanup +
3883
3887
  // a process-exit backstop, so no monitor outlives the session.
3884
3888
  try {
3885
- const { collectPluginMonitors } =
3886
- await import("../lib/plugin-runtime/monitors.js");
3889
+ const { collectPluginMonitors } = await import(
3890
+ "../lib/plugin-runtime/monitors.js"
3891
+ );
3887
3892
  const monitors = collectPluginMonitors({ cwd: process.cwd() });
3888
3893
  if (monitors.length > 0) {
3889
- const { PluginMonitorSupervisor } =
3890
- await import("../lib/plugin-monitor-supervisor.js");
3894
+ const { PluginMonitorSupervisor } = await import(
3895
+ "../lib/plugin-monitor-supervisor.js"
3896
+ );
3891
3897
  _pluginMonitors = new PluginMonitorSupervisor();
3892
3898
  const started = _pluginMonitors.start(monitors);
3893
3899
  if (started.length > 0) {
@@ -3919,8 +3925,9 @@ async function startAgentReplInWorkspaceOwned(
3919
3925
  // Apply trusted plugins' default env vars (Phase 3.3o) — only for env keys the
3920
3926
  // user/system didn't already set; restored at SessionEnd.
3921
3927
  try {
3922
- const { applyPluginSettingsEnv } =
3923
- await import("../lib/plugin-runtime/settings.js");
3928
+ const { applyPluginSettingsEnv } = await import(
3929
+ "../lib/plugin-runtime/settings.js"
3930
+ );
3924
3931
  const res = applyPluginSettingsEnv({ cwd: process.cwd() });
3925
3932
  _pluginSettingsRestore = res.restore;
3926
3933
  if (res.added.length > 0) {
@@ -3988,8 +3995,9 @@ async function startAgentReplInWorkspaceOwned(
3988
3995
  let _sessionMgr = null;
3989
3996
  let _sessionHandle = null;
3990
3997
  try {
3991
- const { getSessionManager } =
3992
- await import("../lib/session-core-singletons.js");
3998
+ const { getSessionManager } = await import(
3999
+ "../lib/session-core-singletons.js"
4000
+ );
3993
4001
  // Keep durable lifecycle sidecars on the same launch-authoritative Claude
3994
4002
  // project bucket as the JSONL transcript. Project settings may not switch
3995
4003
  // this map/path after the REPL has admitted its launch environment.
@@ -4038,8 +4046,9 @@ async function startAgentReplInWorkspaceOwned(
4038
4046
  error.code = "CC_REMOTE_APPROVAL_GATE_UNAVAILABLE";
4039
4047
  throw error;
4040
4048
  }
4041
- const { startHeadlessRemoteApproval } =
4042
- await import("../lib/remote-approval-bridge.js");
4049
+ const { startHeadlessRemoteApproval } = await import(
4050
+ "../lib/remote-approval-bridge.js"
4051
+ );
4043
4052
  const started = await startHeadlessRemoteApproval({
4044
4053
  agentSessionId:
4045
4054
  sessionId || `repl-${process.pid}-${Date.now().toString(36)}`,
@@ -4299,8 +4308,9 @@ async function startAgentReplInWorkspaceOwned(
4299
4308
  // project memory is off or no hook is registered.
4300
4309
  if (_settingsHooks && _loadedReplInstructions) {
4301
4310
  try {
4302
- const { runInstructionsLoadedHooks } =
4303
- await import("../lib/settings-hook-events.js");
4311
+ const { runInstructionsLoadedHooks } = await import(
4312
+ "../lib/settings-hook-events.js"
4313
+ );
4304
4314
  const ctx = (
4305
4315
  await runInstructionsLoadedHooks(_settingsHooks, {
4306
4316
  files: _loadedReplInstructions.files,
@@ -4317,8 +4327,9 @@ async function startAgentReplInWorkspaceOwned(
4317
4327
  // settings.json SessionStart hooks → inject session context (observe-only).
4318
4328
  if (_settingsHooks) {
4319
4329
  try {
4320
- const { runSessionStartHooks } =
4321
- await import("../lib/settings-hook-events.js");
4330
+ const { runSessionStartHooks } = await import(
4331
+ "../lib/settings-hook-events.js"
4332
+ );
4322
4333
  const ctx = (
4323
4334
  await runSessionStartHooks(_settingsHooks, {
4324
4335
  source: "startup",
@@ -4382,15 +4393,18 @@ async function startAgentReplInWorkspaceOwned(
4382
4393
  };
4383
4394
  if (options.bundlePath) {
4384
4395
  try {
4385
- const { loadBundle } =
4386
- await import("@chainlesschain/session-core/agent-bundle-loader");
4387
- const { parseUserMdSeed, resolveBundle } =
4388
- await import("@chainlesschain/session-core/agent-bundle-resolver");
4396
+ const { loadBundle } = await import(
4397
+ "@chainlesschain/session-core/agent-bundle-loader"
4398
+ );
4399
+ const { parseUserMdSeed, resolveBundle } = await import(
4400
+ "@chainlesschain/session-core/agent-bundle-resolver"
4401
+ );
4389
4402
  const bundle = loadBundle(options.bundlePath);
4390
4403
  if (contextMemoryCutover.canonical) {
4391
4404
  _bundleResolved = resolveBundle(bundle);
4392
- const { createCliCanonicalMemoryService } =
4393
- await import("../lib/context-memory-kernel/memory-service.js");
4405
+ const { createCliCanonicalMemoryService } = await import(
4406
+ "../lib/context-memory-kernel/memory-service.js"
4407
+ );
4394
4408
  const memoryService = createCliCanonicalMemoryService({
4395
4409
  env: options.contextMemoryEnv || process.env,
4396
4410
  });
@@ -4432,8 +4446,9 @@ async function startAgentReplInWorkspaceOwned(
4432
4446
  }
4433
4447
  _bundleResolved.seedResult = { seeded, skipped };
4434
4448
  } else {
4435
- const { getMemoryStore } =
4436
- await import("../lib/session-core-singletons.js");
4449
+ const { getMemoryStore } = await import(
4450
+ "../lib/session-core-singletons.js"
4451
+ );
4437
4452
  _bundleResolved = resolveBundle(bundle, {
4438
4453
  memoryStore: getMemoryStore(),
4439
4454
  seedOptions: {
@@ -4562,8 +4577,9 @@ async function startAgentReplInWorkspaceOwned(
4562
4577
  // MCP tool search (context scaling): defer big tool schemas behind the
4563
4578
  // internal tool_search tool. Below-threshold / disabled → no-op.
4564
4579
  try {
4565
- const { maybeApplyToolSearch } =
4566
- await import("../runtime/mcp-tool-search.js");
4580
+ const { maybeApplyToolSearch } = await import(
4581
+ "../runtime/mcp-tool-search.js"
4582
+ );
4567
4583
  const ts = maybeApplyToolSearch(_adhocMcp, {
4568
4584
  model,
4569
4585
  provider,
@@ -4690,8 +4706,9 @@ async function startAgentReplInWorkspaceOwned(
4690
4706
  // when there are no extra roots. Best-effort.
4691
4707
  if (additionalDirectories.length > 0) {
4692
4708
  try {
4693
- const { workspaceRootDirs, notifyMcpRootsChanged } =
4694
- await import("./add-dir.js");
4709
+ const { workspaceRootDirs, notifyMcpRootsChanged } = await import(
4710
+ "./add-dir.js"
4711
+ );
4695
4712
  notifyMcpRootsChanged(
4696
4713
  [_adhocMcp?.mcpClient, _bundleMcpClient],
4697
4714
  workspaceRootDirs(process.cwd(), additionalDirectories),
@@ -4744,8 +4761,9 @@ async function startAgentReplInWorkspaceOwned(
4744
4761
  // --no-recall-memory is passed.
4745
4762
  if (!options.sessionId && options.recallMemory !== false) {
4746
4763
  try {
4747
- const { buildMemoryInjection } =
4748
- await import("../lib/memory-injection.js");
4764
+ const { buildMemoryInjection } = await import(
4765
+ "../lib/memory-injection.js"
4766
+ );
4749
4767
  const injection = buildMemoryInjection({
4750
4768
  agentId: options.agentId || null,
4751
4769
  query: options.recallQuery || "",
@@ -4835,8 +4853,9 @@ async function startAgentReplInWorkspaceOwned(
4835
4853
  // Observe-only, best-effort — never blocks entering the REPL.
4836
4854
  if (_settingsHooks && _startupResumeCommitted) {
4837
4855
  try {
4838
- const { runObserveHooks } =
4839
- await import("../lib/settings-hook-events.js");
4856
+ const { runObserveHooks } = await import(
4857
+ "../lib/settings-hook-events.js"
4858
+ );
4840
4859
  await runObserveHooks(
4841
4860
  _settingsHooks,
4842
4861
  "SessionResume",
@@ -4874,8 +4893,9 @@ async function startAgentReplInWorkspaceOwned(
4874
4893
  // transcript snapshot and ZERO tools. Compact call/outcome metadata shares
4875
4894
  // the session hash chain, while advice text itself is never persisted.
4876
4895
  try {
4877
- const { createConfiguredAdvisorRuntime } =
4878
- await import("../lib/advisor-runtime.js");
4896
+ const { createConfiguredAdvisorRuntime } = await import(
4897
+ "../lib/advisor-runtime.js"
4898
+ );
4879
4899
  const advisorOverrides = {};
4880
4900
  if (options.advisorEnabled !== undefined) {
4881
4901
  advisorOverrides.enabled = options.advisorEnabled === true;
@@ -5244,8 +5264,9 @@ async function startAgentReplInWorkspaceOwned(
5244
5264
  return;
5245
5265
  }
5246
5266
  try {
5247
- const { defaultOpenBrowser } =
5248
- await import("../lib/mcp-oauth.js");
5267
+ const { defaultOpenBrowser } = await import(
5268
+ "../lib/mcp-oauth.js"
5269
+ );
5249
5270
  const opened = defaultOpenBrowser(request.url);
5250
5271
  resolve(opened ? { action: "accept" } : { action: "cancel" });
5251
5272
  } catch {
@@ -5288,8 +5309,9 @@ async function startAgentReplInWorkspaceOwned(
5288
5309
  let _channels = null;
5289
5310
  if (options.channels) {
5290
5311
  try {
5291
- const { startChannels, formatChannelEvent } =
5292
- await import("../lib/channels/channel-manager.js");
5312
+ const { startChannels, formatChannelEvent } = await import(
5313
+ "../lib/channels/channel-manager.js"
5314
+ );
5293
5315
  let channelsConfig = {};
5294
5316
  try {
5295
5317
  channelsConfig =
@@ -5582,8 +5604,9 @@ async function startAgentReplInWorkspaceOwned(
5582
5604
  const _notifyVersionSkew = async () => {
5583
5605
  if (_versionSkewNotified) return;
5584
5606
  try {
5585
- const { detectVersionSkew, versionSkewMessage } =
5586
- await import("../lib/version-skew.js");
5607
+ const { detectVersionSkew, versionSkewMessage } = await import(
5608
+ "../lib/version-skew.js"
5609
+ );
5587
5610
  const skew = detectVersionSkew();
5588
5611
  if (skew) {
5589
5612
  _versionSkewNotified = true;
@@ -5758,8 +5781,9 @@ async function startAgentReplInWorkspaceOwned(
5758
5781
  // to the model verbatim — the same fall-through an unmatched slash line
5759
5782
  // already takes. /exit and /quit stay live so the session can be closed.
5760
5783
  // Predicate + sentinel are pure (lib/slash-dispatch.js, unit-tested).
5761
- const { slashDispatchBypassed, slashBypassSentinel } =
5762
- await import("../lib/slash-dispatch.js");
5784
+ const { slashDispatchBypassed, slashBypassSentinel } = await import(
5785
+ "../lib/slash-dispatch.js"
5786
+ );
5763
5787
  const _slashBypassed = slashDispatchBypassed(
5764
5788
  rawLine,
5765
5789
  _slashCommandsDisabled,
@@ -5788,8 +5812,9 @@ async function startAgentReplInWorkspaceOwned(
5788
5812
  // no LLM round-trip — and fold the output into the conversation context.
5789
5813
  if (trimmed.startsWith("!") && trimmed.slice(1).trim()) {
5790
5814
  try {
5791
- const { runBangCommand, shouldRespondToBashCommands } =
5792
- await import("../lib/repl-bang-memorize.js");
5815
+ const { runBangCommand, shouldRespondToBashCommands } = await import(
5816
+ "../lib/repl-bang-memorize.js"
5817
+ );
5793
5818
  const res = runBangCommand(trimmed, { cwd: process.cwd() });
5794
5819
  logger.log(chalk.gray(`$ ${res.cmd}`));
5795
5820
  if (res.stdout)
@@ -5826,8 +5851,9 @@ async function startAgentReplInWorkspaceOwned(
5826
5851
  // cc.md (auto-loaded next session) and keep it active in this one.
5827
5852
  if (trimmed.startsWith("#") && trimmed.slice(1).trim()) {
5828
5853
  try {
5829
- const { appendMemoryNote } =
5830
- await import("../lib/repl-bang-memorize.js");
5854
+ const { appendMemoryNote } = await import(
5855
+ "../lib/repl-bang-memorize.js"
5856
+ );
5831
5857
  const res = appendMemoryNote(trimmed, { cwd: process.cwd() });
5832
5858
  messages.push({
5833
5859
  role: "system",
@@ -6212,8 +6238,9 @@ async function startAgentReplInWorkspaceOwned(
6212
6238
  if (trimmed === "/init" || trimmed.startsWith("/init ")) {
6213
6239
  const force = /(^|\s)(--force|-f)(\s|$)/.test(trimmed);
6214
6240
  try {
6215
- const { inventoryProject, renderMemoryFile } =
6216
- await import("../lib/project-inventory.js");
6241
+ const { inventoryProject, renderMemoryFile } = await import(
6242
+ "../lib/project-inventory.js"
6243
+ );
6217
6244
  const initCwd = process.cwd();
6218
6245
  const target = path.join(initCwd, "cc.md");
6219
6246
  if (fs.existsSync(target) && !force) {
@@ -6257,10 +6284,12 @@ async function startAgentReplInWorkspaceOwned(
6257
6284
  try {
6258
6285
  const { parseAgentsCommand, formatAgentsList, formatAgentDetail } =
6259
6286
  await import("./agents-status.js");
6260
- const { discoverAgents, getAgent, scaffoldAgent } =
6261
- await import("../lib/agents.js");
6262
- const { listSubAgentProfiles } =
6263
- await import("../lib/sub-agent-profiles.js");
6287
+ const { discoverAgents, getAgent, scaffoldAgent } = await import(
6288
+ "../lib/agents.js"
6289
+ );
6290
+ const { listSubAgentProfiles } = await import(
6291
+ "../lib/sub-agent-profiles.js"
6292
+ );
6264
6293
  const cmd = parseAgentsCommand(trimmed);
6265
6294
  if (cmd.action === "help") {
6266
6295
  logger.log(
@@ -6316,8 +6345,9 @@ async function startAgentReplInWorkspaceOwned(
6316
6345
 
6317
6346
  if (trimmed === "/sub-agents" || trimmed === "/subagents") {
6318
6347
  try {
6319
- const { SubAgentRegistry } =
6320
- await import("../lib/sub-agent-registry.js");
6348
+ const { SubAgentRegistry } = await import(
6349
+ "../lib/sub-agent-registry.js"
6350
+ );
6321
6351
  const registry = SubAgentRegistry.getInstance();
6322
6352
  const active = registry.getActive();
6323
6353
  const history = registry.getHistory();
@@ -6369,8 +6399,9 @@ async function startAgentReplInWorkspaceOwned(
6369
6399
  // user could silently switch to a retired id and only learn of it when
6370
6400
  // the next turn fails with an opaque "model not found".
6371
6401
  try {
6372
- const { maybeWarnDeprecatedModel } =
6373
- await import("../lib/model-deprecation.js");
6402
+ const { maybeWarnDeprecatedModel } = await import(
6403
+ "../lib/model-deprecation.js"
6404
+ );
6374
6405
  maybeWarnDeprecatedModel({ model });
6375
6406
  } catch {
6376
6407
  // deprecation notice is best-effort
@@ -6465,8 +6496,9 @@ async function startAgentReplInWorkspaceOwned(
6465
6496
  // One-shot advice is queued as an ephemeral prepareCall suffix, requiring
6466
6497
  // the main agent to validate it locally on its next model/tool turn.
6467
6498
  {
6468
- const { parseAdvisorCommand, executeAdvisorCommand } =
6469
- await import("./advisor-command.js");
6499
+ const { parseAdvisorCommand, executeAdvisorCommand } = await import(
6500
+ "./advisor-command.js"
6501
+ );
6470
6502
  const advisorCommand = parseAdvisorCommand(trimmed);
6471
6503
  if (advisorCommand) {
6472
6504
  const result = await executeAdvisorCommand(advisorCommand, {
@@ -6505,8 +6537,9 @@ async function startAgentReplInWorkspaceOwned(
6505
6537
  // Stash the conversation first so `/rewind clear` can restore it
6506
6538
  // (Claude-Code 2.1.191). A no-op /clear (nothing to stash) keeps any
6507
6539
  // existing restorable snapshot.
6508
- const { snapshotClearedConversation } =
6509
- await import("../lib/repl-rewind.js");
6540
+ const { snapshotClearedConversation } = await import(
6541
+ "../lib/repl-rewind.js"
6542
+ );
6510
6543
  const snap = snapshotClearedConversation(messages, _checkpointMarks);
6511
6544
  if (snap) _clearedConversation = snap;
6512
6545
  messages.length = 1; // Keep system prompt
@@ -6527,8 +6560,9 @@ async function startAgentReplInWorkspaceOwned(
6527
6560
  ) {
6528
6561
  try {
6529
6562
  const arg = trimmed.slice("/terminal-setup".length).trim();
6530
- const { runTerminalSetup } =
6531
- await import("../commands/terminal-setup.js");
6563
+ const { runTerminalSetup } = await import(
6564
+ "../commands/terminal-setup.js"
6565
+ );
6532
6566
  const res = runTerminalSetup({ apply: arg === "--apply" });
6533
6567
  for (const l of res.lines) logger.log(l);
6534
6568
  } catch (err) {
@@ -6832,8 +6866,9 @@ async function startAgentReplInWorkspaceOwned(
6832
6866
  if (trimmed === "/output-style" || trimmed.startsWith("/output-style ")) {
6833
6867
  const arg = trimmed.slice("/output-style".length).trim();
6834
6868
  try {
6835
- const { discoverOutputStyles, getOutputStyle } =
6836
- await import("../lib/output-styles.js");
6869
+ const { discoverOutputStyles, getOutputStyle } = await import(
6870
+ "../lib/output-styles.js"
6871
+ );
6837
6872
  if (!arg) {
6838
6873
  logger.log(chalk.bold("Output styles:"));
6839
6874
  for (const s of discoverOutputStyles(process.cwd())) {
@@ -6901,13 +6936,15 @@ async function startAgentReplInWorkspaceOwned(
6901
6936
  // (byte-unchanged) without a registered CwdChanged hook.
6902
6937
  if (_settingsHooks && oldCwd !== newCwd) {
6903
6938
  try {
6904
- const { runCwdChangedHooks, dispatchAsyncHooks } =
6905
- await import("../lib/settings-hook-events.js");
6939
+ const { runCwdChangedHooks, dispatchAsyncHooks } = await import(
6940
+ "../lib/settings-hook-events.js"
6941
+ );
6906
6942
  const payload = { oldCwd, newCwd, sessionId };
6907
6943
  await runCwdChangedHooks(_settingsHooks, payload);
6908
6944
  if (!_asyncHookSupervisor) {
6909
- const { AsyncHookSupervisor } =
6910
- await import("../lib/async-hook-supervisor.js");
6945
+ const { AsyncHookSupervisor } = await import(
6946
+ "../lib/async-hook-supervisor.js"
6947
+ );
6911
6948
  _asyncHookSupervisor = new AsyncHookSupervisor({
6912
6949
  persistStats: true,
6913
6950
  });
@@ -6967,8 +7004,9 @@ async function startAgentReplInWorkspaceOwned(
6967
7004
  (parsed.command === "turn" || parsed.command === "branch")
6968
7005
  ) {
6969
7006
  try {
6970
- const { loadTurnBindingLog } =
6971
- await import("../lib/turn-binding-store.js");
7007
+ const { loadTurnBindingLog } = await import(
7008
+ "../lib/turn-binding-store.js"
7009
+ );
6972
7010
  _persistedBinding = loadTurnBindingLog(sessionId);
6973
7011
  } catch {
6974
7012
  /* marks-only fallback */
@@ -7027,8 +7065,9 @@ async function startAgentReplInWorkspaceOwned(
7027
7065
  logger.error("Could not plan a branch from that turn.");
7028
7066
  } else {
7029
7067
  try {
7030
- const { createBranchSession } =
7031
- await import("../harness/jsonl-session-store.js");
7068
+ const { createBranchSession } = await import(
7069
+ "../harness/jsonl-session-store.js"
7070
+ );
7032
7071
  const res = createBranchSession({
7033
7072
  branchSessionId: plan.branchSessionId,
7034
7073
  parentSessionId: sessionId,
@@ -7162,8 +7201,9 @@ async function startAgentReplInWorkspaceOwned(
7162
7201
  .toLowerCase();
7163
7202
  if (ans === "" || ans === "y" || ans === "yes") {
7164
7203
  try {
7165
- const { rewindTo } =
7166
- await import("../lib/checkpoint-store.js");
7204
+ const { rewindTo } = await import(
7205
+ "../lib/checkpoint-store.js"
7206
+ );
7167
7207
  const r = rewindTo(process.cwd(), cp.id, {
7168
7208
  session: sessionId,
7169
7209
  });
@@ -7213,8 +7253,9 @@ async function startAgentReplInWorkspaceOwned(
7213
7253
  // window. Reuses the same categorizer + estimator as the archived view.
7214
7254
  try {
7215
7255
  const { categorizeContext } = await import("../commands/context.js");
7216
- const { estimateTokens } =
7217
- await import("../harness/prompt-compressor.js");
7256
+ const { estimateTokens } = await import(
7257
+ "../harness/prompt-compressor.js"
7258
+ );
7218
7259
  const { buckets, counts, total } = categorizeContext(
7219
7260
  messages,
7220
7261
  estimateTokens,
@@ -7247,13 +7288,32 @@ async function startAgentReplInWorkspaceOwned(
7247
7288
  : ""
7248
7289
  }`,
7249
7290
  );
7291
+ const { default: sourceLedger } = await import(
7292
+ "../lib/context-source-ledger.js"
7293
+ );
7294
+ const attribution = sourceLedger.getTokenReport({ sessionId });
7295
+ if (attribution.entries) {
7296
+ logger.log(
7297
+ chalk.bold(
7298
+ "\nRecorded context sources (separate from request usage):",
7299
+ ),
7300
+ );
7301
+ for (const [source, tokens] of Object.entries(attribution.bySource))
7302
+ logger.log(` ${source}: ${tokens} tok`);
7303
+ logger.log(
7304
+ chalk.gray(
7305
+ ` estimated ${attribution.byBasis.estimated} tok; observed ${attribution.byBasis.observed} tok`,
7306
+ ),
7307
+ );
7308
+ }
7250
7309
  // MCP tool-schema share of the window (gap-analysis 第二阶段 item 3):
7251
7310
  // the tools parameter rides along on EVERY request but isn't part of
7252
7311
  // `messages`, so it's invisible to the role buckets above. Show the
7253
7312
  // per-server schema cost + tool-search state + optimization advice.
7254
7313
  if (_adhocMcp?.extraToolDefinitions?.length) {
7255
- const { describeMcpToolContext } =
7256
- await import("../runtime/mcp-tool-search.js");
7314
+ const { describeMcpToolContext } = await import(
7315
+ "../runtime/mcp-tool-search.js"
7316
+ );
7257
7317
  const info = describeMcpToolContext(_adhocMcp, {
7258
7318
  estimate: estimateTokens,
7259
7319
  model,
@@ -7720,16 +7780,19 @@ async function startAgentReplInWorkspaceOwned(
7720
7780
  if (trimmed === "/reload-plugins") {
7721
7781
  try {
7722
7782
  const cwd = process.cwd();
7723
- const { reloadPluginRuntime } =
7724
- await import("../lib/plugin-runtime/reload.js");
7783
+ const { reloadPluginRuntime } = await import(
7784
+ "../lib/plugin-runtime/reload.js"
7785
+ );
7725
7786
  const sum = reloadPluginRuntime({ cwd });
7726
7787
 
7727
7788
  // Re-merge plugin hooks onto the user's settings hooks (live session).
7728
7789
  try {
7729
- const { loadHooks, attachAuthorityErrors } =
7730
- await import("../lib/settings-hooks.cjs");
7731
- const { mergePluginHooks } =
7732
- await import("../lib/plugin-runtime/hooks.js");
7790
+ const { loadHooks, attachAuthorityErrors } = await import(
7791
+ "../lib/settings-hooks.cjs"
7792
+ );
7793
+ const { mergePluginHooks } = await import(
7794
+ "../lib/plugin-runtime/hooks.js"
7795
+ );
7733
7796
  const loaded = loadHooks({ cwd });
7734
7797
  const merged = mergePluginHooks(
7735
7798
  attachAuthorityErrors(loaded.hooks, loaded.authorityErrors),
@@ -7758,8 +7821,9 @@ async function startAgentReplInWorkspaceOwned(
7758
7821
  // react (e.g. re-audit the newly-trusted config). Best-effort.
7759
7822
  if (_settingsHooks) {
7760
7823
  try {
7761
- const { runObserveHooks, dispatchAsyncHooks } =
7762
- await import("../lib/settings-hook-events.js");
7824
+ const { runObserveHooks, dispatchAsyncHooks } = await import(
7825
+ "../lib/settings-hook-events.js"
7826
+ );
7763
7827
  const payload = {
7764
7828
  session_id: sessionId || null,
7765
7829
  source: "reload-plugins",
@@ -7768,8 +7832,9 @@ async function startAgentReplInWorkspaceOwned(
7768
7832
  cwd,
7769
7833
  });
7770
7834
  if (!_asyncHookSupervisor) {
7771
- const { AsyncHookSupervisor } =
7772
- await import("../lib/async-hook-supervisor.js");
7835
+ const { AsyncHookSupervisor } = await import(
7836
+ "../lib/async-hook-supervisor.js"
7837
+ );
7773
7838
  _asyncHookSupervisor = new AsyncHookSupervisor({
7774
7839
  persistStats: true,
7775
7840
  });
@@ -7785,16 +7850,18 @@ async function startAgentReplInWorkspaceOwned(
7785
7850
 
7786
7851
  // Restart background monitors with the fresh, trust-gated set.
7787
7852
  try {
7788
- const { collectPluginMonitors } =
7789
- await import("../lib/plugin-runtime/monitors.js");
7853
+ const { collectPluginMonitors } = await import(
7854
+ "../lib/plugin-runtime/monitors.js"
7855
+ );
7790
7856
  if (_pluginMonitors) {
7791
7857
  _pluginMonitors.stopAll();
7792
7858
  _pluginMonitors = null;
7793
7859
  }
7794
7860
  const monitors = collectPluginMonitors({ cwd });
7795
7861
  if (monitors.length > 0) {
7796
- const { PluginMonitorSupervisor } =
7797
- await import("../lib/plugin-monitor-supervisor.js");
7862
+ const { PluginMonitorSupervisor } = await import(
7863
+ "../lib/plugin-monitor-supervisor.js"
7864
+ );
7798
7865
  _pluginMonitors = new PluginMonitorSupervisor();
7799
7866
  _pluginMonitors.start(monitors);
7800
7867
  }
@@ -7804,8 +7871,9 @@ async function startAgentReplInWorkspaceOwned(
7804
7871
 
7805
7872
  // Re-apply legacy plugin bin PATH; strict bins remain direct-only.
7806
7873
  try {
7807
- const { applyPluginBinPath } =
7808
- await import("../lib/plugin-runtime/bin.js");
7874
+ const { applyPluginBinPath } = await import(
7875
+ "../lib/plugin-runtime/bin.js"
7876
+ );
7809
7877
  if (_pluginBinRestore) _pluginBinRestore();
7810
7878
  const res = applyPluginBinPath({ cwd });
7811
7879
  _pluginBinRestore = res.restore;
@@ -7815,8 +7883,9 @@ async function startAgentReplInWorkspaceOwned(
7815
7883
 
7816
7884
  // Re-apply plugin default env vars (a newly-trusted plugin's settings).
7817
7885
  try {
7818
- const { applyPluginSettingsEnv } =
7819
- await import("../lib/plugin-runtime/settings.js");
7886
+ const { applyPluginSettingsEnv } = await import(
7887
+ "../lib/plugin-runtime/settings.js"
7888
+ );
7820
7889
  if (_pluginSettingsRestore) _pluginSettingsRestore();
7821
7890
  const res = applyPluginSettingsEnv({ cwd });
7822
7891
  _pluginSettingsRestore = res.restore;
@@ -7849,8 +7918,9 @@ async function startAgentReplInWorkspaceOwned(
7849
7918
  // cwd so it follows `/cd`, using this session's provider/model.
7850
7919
  if (trimmed === "/review" || trimmed.startsWith("/review ")) {
7851
7920
  const rest = trimmed.slice("/review".length).trim();
7852
- const { parseReviewReplArgs, describeReviewArgs } =
7853
- await import("./review-args.js");
7921
+ const { parseReviewReplArgs, describeReviewArgs } = await import(
7922
+ "./review-args.js"
7923
+ );
7854
7924
  const { opts: reviewOpts, errors } = parseReviewReplArgs(rest);
7855
7925
  if (errors.length) {
7856
7926
  for (const e of errors) logger.error(chalk.red(`/review: ${e}`));
@@ -8061,8 +8131,9 @@ async function startAgentReplInWorkspaceOwned(
8061
8131
  logger.log("");
8062
8132
  } else if (subCmd === "debate" && coworkInput) {
8063
8133
  try {
8064
- const { startDebate } =
8065
- await import("../lib/cowork/debate-review-cli.js");
8134
+ const { startDebate } = await import(
8135
+ "../lib/cowork/debate-review-cli.js"
8136
+ );
8066
8137
  let code = coworkInput;
8067
8138
  let targetLabel = coworkInput;
8068
8139
  const resolved = path.resolve(coworkInput);
@@ -8112,8 +8183,9 @@ async function startAgentReplInWorkspaceOwned(
8112
8183
  }
8113
8184
  } else if (subCmd === "compare" && coworkInput) {
8114
8185
  try {
8115
- const { compare } =
8116
- await import("../lib/cowork/ab-comparator-cli.js");
8186
+ const { compare } = await import(
8187
+ "../lib/cowork/ab-comparator-cli.js"
8188
+ );
8117
8189
  process.stdout.write(chalk.gray("\n Generating variants...\n"));
8118
8190
  const result = await compare({
8119
8191
  prompt: coworkInput,
@@ -8145,8 +8217,9 @@ async function startAgentReplInWorkspaceOwned(
8145
8217
  }
8146
8218
  } else if (subCmd === "graph" && coworkInput) {
8147
8219
  try {
8148
- const { buildKnowledgeGraph } =
8149
- await import("../lib/cowork/code-knowledge-graph-cli.js");
8220
+ const { buildKnowledgeGraph } = await import(
8221
+ "../lib/cowork/code-knowledge-graph-cli.js"
8222
+ );
8150
8223
  process.stdout.write(chalk.gray("\n Analyzing code graph...\n"));
8151
8224
  const result = await buildKnowledgeGraph({
8152
8225
  targetPath: path.resolve(coworkInput),
@@ -8183,8 +8256,9 @@ async function startAgentReplInWorkspaceOwned(
8183
8256
  }
8184
8257
  } else if (subCmd === "decision" && coworkInput) {
8185
8258
  try {
8186
- const { extractDecisions } =
8187
- await import("../lib/cowork/decision-kb-cli.js");
8259
+ const { extractDecisions } = await import(
8260
+ "../lib/cowork/decision-kb-cli.js"
8261
+ );
8188
8262
  process.stdout.write(chalk.gray("\n Analyzing decisions...\n"));
8189
8263
  const result = await extractDecisions({
8190
8264
  targetPath: path.resolve(coworkInput),
@@ -8450,8 +8524,9 @@ async function startAgentReplInWorkspaceOwned(
8450
8524
  { messages, signal: _turnAbort?.signal || null },
8451
8525
  );
8452
8526
  if (result.ok) {
8453
- const { renderAdvisorAdvice } =
8454
- await import("./advisor-command.js");
8527
+ const { renderAdvisorAdvice } = await import(
8528
+ "./advisor-command.js"
8529
+ );
8455
8530
  logger.log(renderAdvisorAdvice(result));
8456
8531
  } else if (result.effect !== "disabled") {
8457
8532
  logger.warn(result.error);
@@ -8553,10 +8628,12 @@ async function startAgentReplInWorkspaceOwned(
8553
8628
  const planRequest =
8554
8629
  subCmd.slice(11).trim() || "Help me with the current task";
8555
8630
  try {
8556
- const { CLIInteractivePlanner } =
8557
- await import("../lib/interactive-planner.js");
8558
- const { TerminalInteractionAdapter } =
8559
- await import("../lib/interaction-adapter.js");
8631
+ const { CLIInteractivePlanner } = await import(
8632
+ "../lib/interactive-planner.js"
8633
+ );
8634
+ const { TerminalInteractionAdapter } = await import(
8635
+ "../lib/interaction-adapter.js"
8636
+ );
8560
8637
  const chatFn = createChatFn({
8561
8638
  ...(evolutionIngress === null ? {} : { evolutionIngress }),
8562
8639
  provider,
@@ -8635,8 +8712,9 @@ async function startAgentReplInWorkspaceOwned(
8635
8712
  // a note) and `cc memory recall` (scoped store).
8636
8713
  if (trimmed === "/memory" || trimmed.startsWith("/memory ")) {
8637
8714
  try {
8638
- const { loadProjectInstructions } =
8639
- await import("../lib/project-instructions.js");
8715
+ const { loadProjectInstructions } = await import(
8716
+ "../lib/project-instructions.js"
8717
+ );
8640
8718
  const { renderMemoryFiles } = await import("./memory-status.js");
8641
8719
  const loaded = loadProjectInstructions({ cwd: process.cwd() });
8642
8720
  logger.log(
@@ -8728,8 +8806,9 @@ async function startAgentReplInWorkspaceOwned(
8728
8806
  } catch (_err) {
8729
8807
  // config read is best-effort; checks degrade gracefully
8730
8808
  }
8731
- const { buildDoctorChecks, renderDoctor } =
8732
- await import("./doctor-status.js");
8809
+ const { buildDoctorChecks, renderDoctor } = await import(
8810
+ "./doctor-status.js"
8811
+ );
8733
8812
  const { ideToolNames } = await import("./ide-status.js");
8734
8813
  const checks = buildDoctorChecks({
8735
8814
  config,
@@ -9202,8 +9281,9 @@ async function startAgentReplInWorkspaceOwned(
9202
9281
  // is observe-only). block → abort the turn; context → inject before the turn.
9203
9282
  if (_settingsHooks) {
9204
9283
  try {
9205
- const { runUserPromptSubmitHooks } =
9206
- await import("../lib/settings-hook-events.js");
9284
+ const { runUserPromptSubmitHooks } = await import(
9285
+ "../lib/settings-hook-events.js"
9286
+ );
9207
9287
  const ups = await runUserPromptSubmitHooks(_settingsHooks, {
9208
9288
  prompt: userContent,
9209
9289
  cwd: process.cwd(),
@@ -9225,11 +9305,13 @@ async function startAgentReplInWorkspaceOwned(
9225
9305
  // long-running check (background tests, CI status) runs ALONGSIDE this
9226
9306
  // turn without blocking it; its result/rewake surfaces on a later turn
9227
9307
  // via the async-hook drain below. Lazily create the supervisor.
9228
- const { dispatchAsyncHooks } =
9229
- await import("../lib/settings-hook-events.js");
9308
+ const { dispatchAsyncHooks } = await import(
9309
+ "../lib/settings-hook-events.js"
9310
+ );
9230
9311
  if (!_asyncHookSupervisor) {
9231
- const { AsyncHookSupervisor } =
9232
- await import("../lib/async-hook-supervisor.js");
9312
+ const { AsyncHookSupervisor } = await import(
9313
+ "../lib/async-hook-supervisor.js"
9314
+ );
9233
9315
  _asyncHookSupervisor = new AsyncHookSupervisor({
9234
9316
  persistStats: true,
9235
9317
  });
@@ -9317,8 +9399,9 @@ async function startAgentReplInWorkspaceOwned(
9317
9399
  // Ephemeral: persistence stores effectivePrompt, not this snapshot.
9318
9400
  // Best-effort; CC_IDE_CONTEXT=0 disables.
9319
9401
  try {
9320
- const { buildIdePromptContext, expandIdeMentions } =
9321
- await import("../lib/ide-context.js");
9402
+ const { buildIdePromptContext, expandIdeMentions } = await import(
9403
+ "../lib/ide-context.js"
9404
+ );
9322
9405
  const hostMcp = _getReplHostMcp();
9323
9406
  const ideCtx = await buildIdePromptContext(hostMcp);
9324
9407
  if (ideCtx) userContent += `\n\n${ideCtx}`;
@@ -9417,8 +9500,9 @@ async function startAgentReplInWorkspaceOwned(
9417
9500
  if (sessionId && useJsonl) {
9418
9501
  try {
9419
9502
  if (!_turnBindingProducer) {
9420
- const { createReplTurnBindingProducer } =
9421
- await import("./repl-turn-binding.js");
9503
+ const { createReplTurnBindingProducer } = await import(
9504
+ "./repl-turn-binding.js"
9505
+ );
9422
9506
  _turnBindingProducer = createReplTurnBindingProducer({
9423
9507
  sessionId,
9424
9508
  onError: (error, phase) => {
@@ -9452,8 +9536,9 @@ async function startAgentReplInWorkspaceOwned(
9452
9536
  const defs = CLISlotFiller.getSlotDefinitions(intent.type);
9453
9537
  const missing = defs.required.filter((s) => !intent.entities[s]);
9454
9538
  if (missing.length > 0) {
9455
- const { TerminalInteractionAdapter } =
9456
- await import("../lib/interaction-adapter.js");
9539
+ const { TerminalInteractionAdapter } = await import(
9540
+ "../lib/interaction-adapter.js"
9541
+ );
9457
9542
  const interaction = new TerminalInteractionAdapter();
9458
9543
  const filler = new CLISlotFiller({ interaction });
9459
9544
  const result = await filler.fillSlots(intent, {
@@ -9542,8 +9627,9 @@ async function startAgentReplInWorkspaceOwned(
9542
9627
  const { resolveActiveGoal } = await import("../lib/goal-store.js");
9543
9628
  const boundGoal = resolveActiveGoal({ sessionId });
9544
9629
  if (boundGoal) {
9545
- const { goalPrepareCall, composePrepareCall } =
9546
- await import("../lib/goal-context.js");
9630
+ const { goalPrepareCall, composePrepareCall } = await import(
9631
+ "../lib/goal-context.js"
9632
+ );
9547
9633
  prepareCall = composePrepareCall([
9548
9634
  defaultPrepareCall,
9549
9635
  goalPrepareCall(boundGoal),
@@ -9569,8 +9655,9 @@ async function startAgentReplInWorkspaceOwned(
9569
9655
  }
9570
9656
  return;
9571
9657
  }
9572
- const { renderAdvisorAdvice } =
9573
- await import("./advisor-command.js");
9658
+ const { renderAdvisorAdvice } = await import(
9659
+ "./advisor-command.js"
9660
+ );
9574
9661
  process.stderr.write(`\n${renderAdvisorAdvice(result)}\n`);
9575
9662
  },
9576
9663
  });
@@ -9631,8 +9718,9 @@ async function startAgentReplInWorkspaceOwned(
9631
9718
  // hooks (fired inside the loop, per tool call) can be dispatched
9632
9719
  // fire-and-forget; their results/rewakes drain into the next turn above.
9633
9720
  if (_settingsHooks && !_asyncHookSupervisor) {
9634
- const { AsyncHookSupervisor } =
9635
- await import("../lib/async-hook-supervisor.js");
9721
+ const { AsyncHookSupervisor } = await import(
9722
+ "../lib/async-hook-supervisor.js"
9723
+ );
9636
9724
  _asyncHookSupervisor = new AsyncHookSupervisor({
9637
9725
  persistStats: true,
9638
9726
  });
@@ -9704,6 +9792,7 @@ async function startAgentReplInWorkspaceOwned(
9704
9792
  thinkingBudget,
9705
9793
  baseUrl: _visionLlm ? _visionLlm.baseUrl : baseUrl,
9706
9794
  apiKey: _visionLlm ? _visionLlm.apiKey : apiKey,
9795
+ serviceTier: options.serviceTier,
9707
9796
  contextEngine,
9708
9797
  iterationBudget,
9709
9798
  sessionId,
@@ -9817,8 +9906,9 @@ async function startAgentReplInWorkspaceOwned(
9817
9906
  const fsMod = await import("node:fs");
9818
9907
  const judge = async (cond, { finalText }) => {
9819
9908
  const { chatWithTools } = await import("../runtime/agent-core.js");
9820
- const { firstBalancedJson } =
9821
- await import("../lib/json-schema-output.js");
9909
+ const { firstBalancedJson } = await import(
9910
+ "../lib/json-schema-output.js"
9911
+ );
9822
9912
  const p =
9823
9913
  `Judge whether this coding session met a completion condition.\n` +
9824
9914
  `Condition: ${cond.text || cond.source}\n\n` +
@@ -9920,8 +10010,9 @@ async function startAgentReplInWorkspaceOwned(
9920
10010
  } else {
9921
10011
  // Phase G #2 — route through StreamRouter so REPL / WS / future
9922
10012
  // streaming providers share one StreamEvent protocol.
9923
- const { streamAgentResponse } =
9924
- await import("../lib/agent-stream.js");
10013
+ const { streamAgentResponse } = await import(
10014
+ "../lib/agent-stream.js"
10015
+ );
9925
10016
  process.stdout.write("\n");
9926
10017
  const noStream = options.noStream === true;
9927
10018
  const streamResult = await streamAgentResponse(effectiveResponse, {
@@ -10078,8 +10169,9 @@ async function startAgentReplInWorkspaceOwned(
10078
10169
  // drain above). Best-effort — never break turn completion.
10079
10170
  if (_settingsHooks) {
10080
10171
  try {
10081
- const { runObserveHooks, dispatchAsyncHooks } =
10082
- await import("../lib/settings-hook-events.js");
10172
+ const { runObserveHooks, dispatchAsyncHooks } = await import(
10173
+ "../lib/settings-hook-events.js"
10174
+ );
10083
10175
  await runObserveHooks(
10084
10176
  _settingsHooks,
10085
10177
  "Stop",
@@ -10087,8 +10179,9 @@ async function startAgentReplInWorkspaceOwned(
10087
10179
  { cwd: process.cwd() },
10088
10180
  );
10089
10181
  if (!_asyncHookSupervisor) {
10090
- const { AsyncHookSupervisor } =
10091
- await import("../lib/async-hook-supervisor.js");
10182
+ const { AsyncHookSupervisor } = await import(
10183
+ "../lib/async-hook-supervisor.js"
10184
+ );
10092
10185
  _asyncHookSupervisor = new AsyncHookSupervisor({
10093
10186
  persistStats: true,
10094
10187
  });
@@ -10273,8 +10366,9 @@ async function startAgentReplInWorkspaceOwned(
10273
10366
  // settings.json SessionEnd hooks (observe-only) when the REPL exits.
10274
10367
  if (_settingsHooks) {
10275
10368
  try {
10276
- const { runObserveHooks } =
10277
- await import("../lib/settings-hook-events.js");
10369
+ const { runObserveHooks } = await import(
10370
+ "../lib/settings-hook-events.js"
10371
+ );
10278
10372
  await runObserveHooks(
10279
10373
  _settingsHooks,
10280
10374
  "SessionEnd",