chainlesschain 0.162.48 → 0.162.60

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 (177) hide show
  1. package/bin/chainlesschain.js +1 -1
  2. package/package.json +2 -2
  3. package/src/assets/web-panel/assets/{AIOps-BeMOUkMq.js → AIOps-a2cSbSEu.js} +1 -1
  4. package/src/assets/web-panel/assets/{ActionButton-DrRegmIt.js → ActionButton-DwvSB5Pp.js} +1 -1
  5. package/src/assets/web-panel/assets/{Analytics-BM7hvUn8.js → Analytics-BqaRaBDD.js} +3 -3
  6. package/src/assets/web-panel/assets/{AppLayout-BfLLYSz_.js → AppLayout-Beck7v8t.js} +5 -5
  7. package/src/assets/web-panel/assets/{Audit-BpiPR-rs.js → Audit-UtJhPdXJ.js} +1 -1
  8. package/src/assets/web-panel/assets/{Backup-BLq4IRI9.js → Backup-HVZhcdll.js} +1 -1
  9. package/src/assets/web-panel/assets/{BaseInput-Bv89IFrM.js → BaseInput-DRY_ZGmj.js} +1 -1
  10. package/src/assets/web-panel/assets/{Chat-BUM9MdnH.js → Chat-D7Vuwfe2.js} +4 -4
  11. package/src/assets/web-panel/assets/{ChatBubbleRenderer-rH_t53ZW.js → ChatBubbleRenderer-BS2q_hPX.js} +1 -1
  12. package/src/assets/web-panel/assets/{Checkbox-82jih_zU.js → Checkbox-B406i7N1.js} +1 -1
  13. package/src/assets/web-panel/assets/{Codegen-ygmM1mNL.js → Codegen-BvTCqHi3.js} +1 -1
  14. package/src/assets/web-panel/assets/{Col-CqXc8_ft.js → Col-DRiyxTQP.js} +1 -1
  15. package/src/assets/web-panel/assets/{Community-CqPPfyR3.js → Community-DWmhxHQa.js} +1 -1
  16. package/src/assets/web-panel/assets/{Compact-LR8Z206-.js → Compact-DO1HBZEz.js} +1 -1
  17. package/src/assets/web-panel/assets/{Compliance-D4alm_Gx.js → Compliance-D4j-VHwS.js} +1 -1
  18. package/src/assets/web-panel/assets/{Cowork-D-DLVanT.js → Cowork-BGBkWtat.js} +3 -3
  19. package/src/assets/web-panel/assets/{Cron-UDtmjvd4.js → Cron-Xa9PtMUQ.js} +2 -2
  20. package/src/assets/web-panel/assets/{Crosschain-iqbVDPNE.js → Crosschain-wVWs4lqN.js} +1 -1
  21. package/src/assets/web-panel/assets/{DID-DzdUfzc9.js → DID-DTkqiRuT.js} +2 -2
  22. package/src/assets/web-panel/assets/{Dashboard-DvKp1skY.js → Dashboard-d9STUbrr.js} +2 -2
  23. package/src/assets/web-panel/assets/{Dropdown-S6ORlfef.js → Dropdown-CrdxS-C8.js} +1 -1
  24. package/src/assets/web-panel/assets/{EmailListRenderer-mJViHjiq.js → EmailListRenderer-D78XHUEp.js} +1 -1
  25. package/src/assets/web-panel/assets/{FamilyGuardDashboard-A4Lu5m_e.js → FamilyGuardDashboard-iAeSETIP.js} +1 -1
  26. package/src/assets/web-panel/assets/{Federation-Bv-6737r.js → Federation-CTV1Sxqs.js} +1 -1
  27. package/src/assets/web-panel/assets/{FormItemContext-DNcZoiWu.js → FormItemContext-BtwNuQKK.js} +1 -1
  28. package/src/assets/web-panel/assets/{GenericCardRenderer-B_a0l9U4.js → GenericCardRenderer-CdEgHjkl.js} +1 -1
  29. package/src/assets/web-panel/assets/{Git-BbVAsh_N.js → Git-BTo-PJr_.js} +2 -2
  30. package/src/assets/web-panel/assets/{Governance-ChxUMZEU.js → Governance-DquOG94r.js} +1 -1
  31. package/src/assets/web-panel/assets/{Inference-Buu_bAQ-.js → Inference-DDtcBxRB.js} +1 -1
  32. package/src/assets/web-panel/assets/{KnowledgeGraph-BMmMjxEu.js → KnowledgeGraph-KUOmNj5C.js} +1 -1
  33. package/src/assets/web-panel/assets/{Logs-BeGHcPEC.js → Logs-HKm7kRs7.js} +2 -2
  34. package/src/assets/web-panel/assets/{Marketplace-CP2Qg_xJ.js → Marketplace-IxrOcbFB.js} +1 -1
  35. package/src/assets/web-panel/assets/{McpTools-C42B4JYb.js → McpTools-D6a1LM3S.js} +4 -4
  36. package/src/assets/web-panel/assets/{Memory-D5VeitFY.js → Memory-lFkD2ZuM.js} +2 -2
  37. package/src/assets/web-panel/assets/{MobileBridge-BouoJ2FQ.js → MobileBridge-xwuQTps5.js} +2 -2
  38. package/src/assets/web-panel/assets/MobileProjects-BYr1D3WO.js +1 -0
  39. package/src/assets/web-panel/assets/{Mtc-Chn6ES5y.js → Mtc-BXpJGrjm.js} +6 -6
  40. package/src/assets/web-panel/assets/{MtcAudit-D0_Q6GEn.js → MtcAudit-CWttaim1.js} +2 -2
  41. package/src/assets/web-panel/assets/{Multisig-BWaCi_wo.js → Multisig-jKgTuVLS.js} +3 -3
  42. package/src/assets/web-panel/assets/{NLProgramming-CoSEiroa.js → NLProgramming-xl4RDzQj.js} +1 -1
  43. package/src/assets/web-panel/assets/{Notes-CiqCbDw3.js → Notes-DPBOvscE.js} +3 -3
  44. package/src/assets/web-panel/assets/{NotificationSettings-BXmzKL9F.js → NotificationSettings-8TkIkRo3.js} +1 -1
  45. package/src/assets/web-panel/assets/{OrderTableRenderer-BhlKyGrE.js → OrderTableRenderer-Dwa-XtoE.js} +1 -1
  46. package/src/assets/web-panel/assets/{Organization-CAVgSxyI.js → Organization-CJ0xVwZM.js} +4 -4
  47. package/src/assets/web-panel/assets/{Overflow-BIVUo8YB.js → Overflow-V7VuUslt.js} +1 -1
  48. package/src/assets/web-panel/assets/{P2P-DX-Ov-eJ.js → P2P-BxuccEGq.js} +2 -2
  49. package/src/assets/web-panel/assets/PdhVaultBrowser-DaP2Q5kU.js +7 -0
  50. package/src/assets/web-panel/assets/{Permissions-CANl-V55.js → Permissions-CPJFF0zU.js} +3 -3
  51. package/src/assets/web-panel/assets/{PersonalDataHub-BE90gjUO.js → PersonalDataHub-Cmn2uiuw.js} +4 -4
  52. package/src/assets/web-panel/assets/{Pipeline-Ck8lV8Pn.js → Pipeline-0zX89_iz.js} +1 -1
  53. package/src/assets/web-panel/assets/{Privacy-BBYUDK4T.js → Privacy-DROUg3XE.js} +1 -1
  54. package/src/assets/web-panel/assets/{ProjectInit-DcbOrnbt.js → ProjectInit-c5KESOK4.js} +2 -2
  55. package/src/assets/web-panel/assets/{ProjectSettings-DZ6-whxP.js → ProjectSettings-BfiCcnb_.js} +2 -2
  56. package/src/assets/web-panel/assets/Projects-BtZH5-Eh.js +1 -0
  57. package/src/assets/web-panel/assets/{Providers-VWoO_Y9u.js → Providers-C9Rr_dOk.js} +1 -1
  58. package/src/assets/web-panel/assets/{QuickAsk-RJfSXWYg.js → QuickAsk-Du4p90W6.js} +1 -1
  59. package/src/assets/web-panel/assets/{Recommend-Y7MWWkXa.js → Recommend-B-DQenTl.js} +1 -1
  60. package/src/assets/web-panel/assets/{Reputation-nG8nut3l.js → Reputation-DvwlAVRZ.js} +1 -1
  61. package/src/assets/web-panel/assets/{Row-DAio6Dx2.js → Row-rTnbvkP-.js} +1 -1
  62. package/src/assets/web-panel/assets/{RssFeed-DwY72Lc7.js → RssFeed-DwvsqWbB.js} +3 -3
  63. package/src/assets/web-panel/assets/{Search-qGG6AUWY.js → Search-U_Xj5SvF.js} +1 -1
  64. package/src/assets/web-panel/assets/{Security-Djsmom8n.js → Security-CdjsVDQ8.js} +4 -4
  65. package/src/assets/web-panel/assets/{Services-DTEgHkUO.js → Services-DUd3mFXk.js} +2 -2
  66. package/src/assets/web-panel/assets/{Skeleton-R5xY0J9Y.js → Skeleton-CA2gCJmY.js} +1 -1
  67. package/src/assets/web-panel/assets/{Skills-CFaRLO3o.js → Skills-BIw7Rb-m.js} +1 -1
  68. package/src/assets/web-panel/assets/{Sla-B5bzoY1I.js → Sla-vySPesC0.js} +1 -1
  69. package/src/assets/web-panel/assets/{SpeechSettings-B_al6SiQ.js → SpeechSettings-EniuTjBJ.js} +1 -1
  70. package/src/assets/web-panel/assets/{SyncSettings-DkUU63oJ.js → SyncSettings-DkrqbzYS.js} +2 -2
  71. package/src/assets/web-panel/assets/{Tasks-C2y4XdrQ.js → Tasks-oyPnWRbw.js} +1 -1
  72. package/src/assets/web-panel/assets/{Templates-CcYJxTNB.js → Templates-C2Kvn60U.js} +1 -1
  73. package/src/assets/web-panel/assets/{Tenant-B0_sIpl2.js → Tenant-x6jVMx4D.js} +1 -1
  74. package/src/assets/web-panel/assets/{Terminal-B_waZb0O.js → Terminal-C2nZbPBs.js} +2 -2
  75. package/src/assets/web-panel/assets/{TimelineRenderer-DuMkErBx.js → TimelineRenderer-BF6HAETd.js} +1 -1
  76. package/src/assets/web-panel/assets/{Tokens-BXjPA6rV.js → Tokens-B-KcVAin.js} +1 -1
  77. package/src/assets/web-panel/assets/{Trigger-BMAAx3Uu.js → Trigger-B-Caiptm.js} +1 -1
  78. package/src/assets/web-panel/assets/{Trust-BPeNXpsi.js → Trust-_8sq7pJp.js} +1 -1
  79. package/src/assets/web-panel/assets/{UkeySign-A0qabV14.js → UkeySign-CLveUEgo.js} +1 -1
  80. package/src/assets/web-panel/assets/{VideoEditing-BMLfYykd.js → VideoEditing-iVc9jxt9.js} +1 -1
  81. package/src/assets/web-panel/assets/{Wallet-BfDI3zjs.js → Wallet-D1n5pidD.js} +4 -4
  82. package/src/assets/web-panel/assets/{WebAuthn-BCnZEScW.js → WebAuthn-CA8kubXb.js} +4 -4
  83. package/src/assets/web-panel/assets/{WorkflowEditor-DvtS5Asf.js → WorkflowEditor-BXWwd_fB.js} +1 -1
  84. package/src/assets/web-panel/assets/{chat-CDJZtBM7.js → chat-DUNkQr1A.js} +1 -1
  85. package/src/assets/web-panel/assets/{colors-fbH1Saco.js → colors-Dz5ozTcp.js} +1 -1
  86. package/src/assets/web-panel/assets/{compact-item-CuZFa9l8.js → compact-item-CZ5-JSLh.js} +1 -1
  87. package/src/assets/web-panel/assets/{createContext-CQuPOqqD.js → createContext-CFxlcPug.js} +1 -1
  88. package/src/assets/web-panel/assets/devWarning-BMRVR8Xp.js +1 -0
  89. package/src/assets/web-panel/assets/{hasIn-CDZlDrhJ.js → hasIn-CqWIkHJm.js} +1 -1
  90. package/src/assets/web-panel/assets/{index-BivMeInw.js → index-3elHm6lI.js} +1 -1
  91. package/src/assets/web-panel/assets/{index-DvBgQoaw.js → index-8l5LLWxH.js} +1 -1
  92. package/src/assets/web-panel/assets/{index-BJCXJCUA.js → index-BBq1ySIt.js} +1 -1
  93. package/src/assets/web-panel/assets/{index-CNmJrCxV.js → index-BI2EU3hC.js} +1 -1
  94. package/src/assets/web-panel/assets/{index-BSy0noke.js → index-BJt6sNTF.js} +1 -1
  95. package/src/assets/web-panel/assets/{index-oe9ZPRtQ.js → index-BLLSLAC3.js} +1 -1
  96. package/src/assets/web-panel/assets/{index-C6epsHef.js → index-BLNgGXeg.js} +1 -1
  97. package/src/assets/web-panel/assets/{index-COSyGm80.js → index-BO-yo7Jv.js} +1 -1
  98. package/src/assets/web-panel/assets/index-BT2s_zxU.js +1 -0
  99. package/src/assets/web-panel/assets/{index-DGAK9Dj4.js → index-BiAcVeea.js} +1 -1
  100. package/src/assets/web-panel/assets/{index-DjgZRX0_.js → index-C2SoMbLc.js} +1 -1
  101. package/src/assets/web-panel/assets/{index-CQ5FVEji.js → index-C5XUilwu.js} +1 -1
  102. package/src/assets/web-panel/assets/{index-Bt1j0mjJ.js → index-C5zhjact.js} +1 -1
  103. package/src/assets/web-panel/assets/{index-BKaue5Pv.js → index-CBeASfAD.js} +1 -1
  104. package/src/assets/web-panel/assets/{index-Bz5_6E63.js → index-CD7UjlnE.js} +1 -1
  105. package/src/assets/web-panel/assets/{index-Cr_shi_7.js → index-CDq8IVvv.js} +1 -1
  106. package/src/assets/web-panel/assets/{index-Dkuecn17.js → index-CE-gpaY9.js} +1 -1
  107. package/src/assets/web-panel/assets/{index-CkhudJH0.js → index-CL6wt2JN.js} +1 -1
  108. package/src/assets/web-panel/assets/{index-kGzPbvry.js → index-CLu3Oyef.js} +1 -1
  109. package/src/assets/web-panel/assets/{index-D365qmj8.js → index-C_WWTpLE.js} +1 -1
  110. package/src/assets/web-panel/assets/{index-Deqod8La.js → index-CbcHBDYj.js} +1 -1
  111. package/src/assets/web-panel/assets/{index-DwAiu9LT.js → index-CguUaiiY.js} +1 -1
  112. package/src/assets/web-panel/assets/{index-WDQkyh-E.js → index-Ci1-8q-g.js} +1 -1
  113. package/src/assets/web-panel/assets/{index-BNEG9-EK.js → index-CvMZxZOn.js} +1 -1
  114. package/src/assets/web-panel/assets/{index-CnfR7qmj.js → index-D6Nkerss.js} +1 -1
  115. package/src/assets/web-panel/assets/{index-CdiNFWPp.js → index-DEzYXMgc.js} +1 -1
  116. package/src/assets/web-panel/assets/{index--SCX46Az.js → index-DF0hXW5L.js} +1 -1
  117. package/src/assets/web-panel/assets/{index-BhZkMMey.js → index-DGAjS_D9.js} +1 -1
  118. package/src/assets/web-panel/assets/{index-CD9ml9ZJ.js → index-DO6mf95c.js} +1 -1
  119. package/src/assets/web-panel/assets/index-DOTL6NDc.js +1 -0
  120. package/src/assets/web-panel/assets/{index-DNN-xBWV.js → index-DUyhvh0L.js} +1 -1
  121. package/src/assets/web-panel/assets/{index-ycBlRXAf.js → index-DW18L-o6.js} +1 -1
  122. package/src/assets/web-panel/assets/{index-CAzMdnkI.js → index-Dc-5Ulgt.js} +1 -1
  123. package/src/assets/web-panel/assets/{index-CzeRvhia.js → index-DvUlrMy-.js} +3 -3
  124. package/src/assets/web-panel/assets/{index-BdORz0iZ.js → index-FsYDYVUk.js} +1 -1
  125. package/src/assets/web-panel/assets/{index-CmeO_DfK.js → index-GVbsyUQm.js} +1 -1
  126. package/src/assets/web-panel/assets/{index-BzIDfObk.js → index-noQc_RpT.js} +1 -1
  127. package/src/assets/web-panel/assets/{index-14gri6Vh.js → index-rR060KAF.js} +1 -1
  128. package/src/assets/web-panel/assets/{index-DhFyStIG.js → index-xaZX6ZDL.js} +1 -1
  129. package/src/assets/web-panel/assets/{initDefaultProps-DHRWNV-y.js → initDefaultProps-PIetywTX.js} +1 -1
  130. package/src/assets/web-panel/assets/{motion-MJ2jhdVO.js → motion-gQJEK3wO.js} +1 -1
  131. package/src/assets/web-panel/assets/{move-Bly0QFE5.js → move-ML1nRxts.js} +1 -1
  132. package/src/assets/web-panel/assets/{omit-DkoMB0pZ.js → omit-wUWsw3YL.js} +1 -1
  133. package/src/assets/web-panel/assets/{pickAttrs-9M-gsXIc.js → pickAttrs-A0Wlomih.js} +1 -1
  134. package/src/assets/web-panel/assets/{placementArrow-Bnht1xci.js → placementArrow-C5RKYdxT.js} +1 -1
  135. package/src/assets/web-panel/assets/{responsiveObserve-B0Cn1i64.js → responsiveObserve-DIxNVSJl.js} +1 -1
  136. package/src/assets/web-panel/assets/{slide-BdI4DDyM.js → slide-B-tNesVu.js} +1 -1
  137. package/src/assets/web-panel/assets/{statusUtils-DdBktcMD.js → statusUtils-CftzO200.js} +1 -1
  138. package/src/assets/web-panel/assets/{styleChecker-aYEwS4Pw.js → styleChecker-CMgvWu90.js} +1 -1
  139. package/src/assets/web-panel/assets/{useFlexGapSupport-y8cUyKiP.js → useFlexGapSupport-sxqoDNhZ.js} +1 -1
  140. package/src/assets/web-panel/assets/{useFs-Bk1SrPFp.js → useFs-CowEXz4v.js} +1 -1
  141. package/src/assets/web-panel/assets/{usePersonalDataHub-Dp04zAB3.js → usePersonalDataHub-6ISRG7V-.js} +1 -1
  142. package/src/assets/web-panel/assets/{vnode-B52a38TC.js → vnode-C2mnXfmw.js} +1 -1
  143. package/src/assets/web-panel/assets/{zoom-DFwyL43U.js → zoom-DMsur0jx.js} +1 -1
  144. package/src/assets/web-panel/index.html +1 -1
  145. package/src/commands/agent.js +66 -28
  146. package/src/harness/mcp-client.js +48 -2
  147. package/src/lib/agent-core.js +2 -0
  148. package/src/lib/llm-pricing.js +9 -0
  149. package/src/lib/mcp-client.js +1 -0
  150. package/src/lib/permission-rules.cjs +11 -1
  151. package/src/lib/personal-data-hub-wiring.js +24 -0
  152. package/src/lib/repl-multiline.js +64 -0
  153. package/src/lib/repl-rewind.js +65 -2
  154. package/src/lib/repl-vim.js +445 -0
  155. package/src/lib/safe-mode.js +17 -3
  156. package/src/lib/skill-loader.js +45 -1
  157. package/src/lib/slash-commands.js +13 -3
  158. package/src/lib/status-line.cjs +33 -3
  159. package/src/repl/agent-repl.js +427 -23
  160. package/src/repl/config-summary.js +59 -0
  161. package/src/repl/conversation-export.js +133 -0
  162. package/src/repl/doctor-status.js +114 -0
  163. package/src/repl/memory-status.js +45 -0
  164. package/src/repl/permissions-status.js +51 -0
  165. package/src/repl/recent-sessions.js +46 -0
  166. package/src/repl/session-cost.js +216 -0
  167. package/src/runtime/agent-core.js +23 -8
  168. package/src/runtime/fallback-model.js +125 -30
  169. package/src/runtime/headless-runner.js +2 -0
  170. package/src/runtime/headless-stream.js +2 -0
  171. package/src/runtime/mcp-config.js +14 -3
  172. package/src/assets/web-panel/assets/MobileProjects-mAJsyk7U.js +0 -1
  173. package/src/assets/web-panel/assets/PdhVaultBrowser-6clRu-J6.js +0 -7
  174. package/src/assets/web-panel/assets/Projects-DO25SEFT.js +0 -1
  175. package/src/assets/web-panel/assets/devWarning-mhGhHpNs.js +0 -1
  176. package/src/assets/web-panel/assets/index-DGBjZXvW.js +0 -1
  177. package/src/assets/web-panel/assets/index-DujMkFuc.js +0 -1
@@ -1,4 +1,4 @@
1
- import{K as o}from"./index-CzeRvhia.js";import{i as f}from"./motion-MJ2jhdVO.js";const c=new o("antZoomIn",{"0%":{transform:"scale(0.2)",opacity:0},"100%":{transform:"scale(1)",opacity:1}}),y=new o("antZoomOut",{"0%":{transform:"scale(1)"},"100%":{transform:"scale(0.2)",opacity:0}}),a=new o("antZoomBigIn",{"0%":{transform:"scale(0.8)",opacity:0},"100%":{transform:"scale(1)",opacity:1}}),s=new o("antZoomBigOut",{"0%":{transform:"scale(1)"},"100%":{transform:"scale(0.8)",opacity:0}}),g=new o("antZoomUpIn",{"0%":{transform:"scale(0.8)",transformOrigin:"50% 0%",opacity:0},"100%":{transform:"scale(1)",transformOrigin:"50% 0%"}}),O=new o("antZoomUpOut",{"0%":{transform:"scale(1)",transformOrigin:"50% 0%"},"100%":{transform:"scale(0.8)",transformOrigin:"50% 0%",opacity:0}}),l=new o("antZoomLeftIn",{"0%":{transform:"scale(0.8)",transformOrigin:"0% 50%",opacity:0},"100%":{transform:"scale(1)",transformOrigin:"0% 50%"}}),u=new o("antZoomLeftOut",{"0%":{transform:"scale(1)",transformOrigin:"0% 50%"},"100%":{transform:"scale(0.8)",transformOrigin:"0% 50%",opacity:0}}),p=new o("antZoomRightIn",{"0%":{transform:"scale(0.8)",transformOrigin:"100% 50%",opacity:0},"100%":{transform:"scale(1)",transformOrigin:"100% 50%"}}),z=new o("antZoomRightOut",{"0%":{transform:"scale(1)",transformOrigin:"100% 50%"},"100%":{transform:"scale(0.8)",transformOrigin:"100% 50%",opacity:0}}),K=new o("antZoomDownIn",{"0%":{transform:"scale(0.8)",transformOrigin:"50% 100%",opacity:0},"100%":{transform:"scale(1)",transformOrigin:"50% 100%"}}),w=new o("antZoomDownOut",{"0%":{transform:"scale(1)",transformOrigin:"50% 100%"},"100%":{transform:"scale(0.8)",transformOrigin:"50% 100%",opacity:0}}),I={zoom:{inKeyframes:c,outKeyframes:y},"zoom-big":{inKeyframes:a,outKeyframes:s},"zoom-big-fast":{inKeyframes:a,outKeyframes:s},"zoom-left":{inKeyframes:l,outKeyframes:u},"zoom-right":{inKeyframes:p,outKeyframes:z},"zoom-up":{inKeyframes:g,outKeyframes:O},"zoom-down":{inKeyframes:K,outKeyframes:w}},h=(n,r)=>{const{antCls:m}=n,t=`${m}-${r}`,{inKeyframes:i,outKeyframes:e}=I[r];return[f(t,i,e,r==="zoom-big-fast"?n.motionDurationFast:n.motionDurationMid),{[`
1
+ import{K as o}from"./index-DvUlrMy-.js";import{i as f}from"./motion-gQJEK3wO.js";const c=new o("antZoomIn",{"0%":{transform:"scale(0.2)",opacity:0},"100%":{transform:"scale(1)",opacity:1}}),y=new o("antZoomOut",{"0%":{transform:"scale(1)"},"100%":{transform:"scale(0.2)",opacity:0}}),a=new o("antZoomBigIn",{"0%":{transform:"scale(0.8)",opacity:0},"100%":{transform:"scale(1)",opacity:1}}),s=new o("antZoomBigOut",{"0%":{transform:"scale(1)"},"100%":{transform:"scale(0.8)",opacity:0}}),g=new o("antZoomUpIn",{"0%":{transform:"scale(0.8)",transformOrigin:"50% 0%",opacity:0},"100%":{transform:"scale(1)",transformOrigin:"50% 0%"}}),O=new o("antZoomUpOut",{"0%":{transform:"scale(1)",transformOrigin:"50% 0%"},"100%":{transform:"scale(0.8)",transformOrigin:"50% 0%",opacity:0}}),l=new o("antZoomLeftIn",{"0%":{transform:"scale(0.8)",transformOrigin:"0% 50%",opacity:0},"100%":{transform:"scale(1)",transformOrigin:"0% 50%"}}),u=new o("antZoomLeftOut",{"0%":{transform:"scale(1)",transformOrigin:"0% 50%"},"100%":{transform:"scale(0.8)",transformOrigin:"0% 50%",opacity:0}}),p=new o("antZoomRightIn",{"0%":{transform:"scale(0.8)",transformOrigin:"100% 50%",opacity:0},"100%":{transform:"scale(1)",transformOrigin:"100% 50%"}}),z=new o("antZoomRightOut",{"0%":{transform:"scale(1)",transformOrigin:"100% 50%"},"100%":{transform:"scale(0.8)",transformOrigin:"100% 50%",opacity:0}}),K=new o("antZoomDownIn",{"0%":{transform:"scale(0.8)",transformOrigin:"50% 100%",opacity:0},"100%":{transform:"scale(1)",transformOrigin:"50% 100%"}}),w=new o("antZoomDownOut",{"0%":{transform:"scale(1)",transformOrigin:"50% 100%"},"100%":{transform:"scale(0.8)",transformOrigin:"50% 100%",opacity:0}}),I={zoom:{inKeyframes:c,outKeyframes:y},"zoom-big":{inKeyframes:a,outKeyframes:s},"zoom-big-fast":{inKeyframes:a,outKeyframes:s},"zoom-left":{inKeyframes:l,outKeyframes:u},"zoom-right":{inKeyframes:p,outKeyframes:z},"zoom-up":{inKeyframes:g,outKeyframes:O},"zoom-down":{inKeyframes:K,outKeyframes:w}},h=(n,r)=>{const{antCls:m}=n,t=`${m}-${r}`,{inKeyframes:i,outKeyframes:e}=I[r];return[f(t,i,e,r==="zoom-big-fast"?n.motionDurationFast:n.motionDurationMid),{[`
2
2
  ${t}-enter,
3
3
  ${t}-appear
4
4
  `]:{transform:"scale(0)",opacity:0,animationTimingFunction:n.motionEaseOutCirc,"&-prepare":{transform:"none"}},[`${t}-leave`]:{animationTimingFunction:n.motionEaseInOutCirc}}]};export{h as i,c as z};
@@ -8,7 +8,7 @@
8
8
  // Injected by web-ui-server.js at serve time
9
9
  window.__CC_CONFIG__ = __CC_CONFIG_PLACEHOLDER__;
10
10
  </script>
11
- <script type="module" crossorigin src="./assets/index-CzeRvhia.js"></script>
11
+ <script type="module" crossorigin src="./assets/index-DvUlrMy-.js"></script>
12
12
  <link rel="modulepreload" crossorigin href="./assets/vendor-BvqAck49.js">
13
13
  <link rel="modulepreload" crossorigin href="./assets/icons-DP3uiYxy.js">
14
14
  <link rel="stylesheet" crossorigin href="./assets/index-Cq93VfoF.css">
@@ -10,7 +10,10 @@ import path from "node:path";
10
10
  import fs from "node:fs";
11
11
  import { createAgentRuntimeFactory } from "../runtime/runtime-factory.js";
12
12
  import { resolvePromptText } from "../runtime/system-prompt.js";
13
- import { makeFallbackChatFn } from "../runtime/fallback-model.js";
13
+ import {
14
+ makeFallbackChatFn,
15
+ normalizeFallbackModels,
16
+ } from "../runtime/fallback-model.js";
14
17
  import { resolveImages, resolveVisionLlm } from "../lib/image-input.js";
15
18
  import { loadConfig } from "../lib/config-manager.js";
16
19
 
@@ -56,6 +59,25 @@ export function resolveThinkingBudget(raw) {
56
59
  return Math.floor(n);
57
60
  }
58
61
 
62
+ /**
63
+ * Resolve the ordered fallback-model chain for a run. The `--fallback-model`
64
+ * flag (repeatable / comma-separated → array) takes precedence; otherwise the
65
+ * configured `llm.fallbackModels` (array or comma string) or legacy
66
+ * `llm.fallbackModel` (single) seeds the chain so unattended runs need no flag.
67
+ * Pure; exported for tests. Normalization (trim / dedupe / cap-at-3) is applied.
68
+ *
69
+ * @param {string[]|string|undefined} flagValue raw --fallback-model value
70
+ * @param {object} [llm] config.llm block
71
+ * @returns {string[]}
72
+ */
73
+ export function resolveFallbackModels(flagValue, llm = {}) {
74
+ const fromFlag = normalizeFallbackModels(flagValue);
75
+ if (fromFlag.length) return fromFlag;
76
+ const configured =
77
+ llm && llm.fallbackModels != null ? llm.fallbackModels : llm?.fallbackModel;
78
+ return normalizeFallbackModels(configured);
79
+ }
80
+
59
81
  /**
60
82
  * Read all of stdin as a UTF-8 string. Resolves "" immediately when stdin is a
61
83
  * TTY (nothing piped) so we never block an interactive invocation.
@@ -153,6 +175,10 @@ export function registerAgentCommand(program) {
153
175
  .option("--recall-limit <n>", "Top-K memories to inject into system prompt")
154
176
  .option("--recall-query <q>", "Query string for startup memory recall")
155
177
  .option("--no-recall-memory", "Disable startup memory recall")
178
+ .option(
179
+ "--vim",
180
+ "Start the interactive REPL in vim-mode line editing (toggle later with /vim; or CC_VIM=1)",
181
+ )
156
182
  .option("--no-stream", "Disable streamed response rendering")
157
183
  .option(
158
184
  "--no-park-on-exit",
@@ -212,7 +238,8 @@ export function registerAgentCommand(program) {
212
238
  )
213
239
  .option(
214
240
  "--fallback-model <model>",
215
- "Retry once on this model when the primary fails (overload/network)",
241
+ "Backup model(s) to try in order when the primary fails (transient error or model-not-found). Repeatable or comma-separated; up to 3. Defaults to config llm.fallbackModels. claude-code parity.",
242
+ (val, prev) => (prev || []).concat([val]),
216
243
  )
217
244
  .option(
218
245
  "--include-partial-messages",
@@ -252,14 +279,18 @@ export function registerAgentCommand(program) {
252
279
  "Merge an extra .claude/settings.json-shaped file for this run: permission rules (allow/ask/deny) + native config overrides (model, env)",
253
280
  )
254
281
  .action(async (task, options, command) => {
255
- // --safe-mode (Claude-Code 2.1.169 parity): flip every customization
256
- // kill-switch BEFORE anything loads. Permission rules stay active.
257
- if (options.safeMode) {
258
- const { applySafeMode } = await import("../lib/safe-mode.js");
259
- const applied = applySafeMode();
260
- process.stderr.write(
261
- `safe mode: customizations disabled (${applied.join(", ")}) — permission rules stay active.\n`,
262
- );
282
+ // --safe-mode flag OR CC_SAFE_MODE / CLAUDE_CODE_SAFE_MODE env (Claude-Code
283
+ // 2.1.169 parity): flip every customization kill-switch BEFORE anything
284
+ // loads. Permission rules stay active.
285
+ {
286
+ const { applySafeMode, safeModeRequested } =
287
+ await import("../lib/safe-mode.js");
288
+ if (safeModeRequested(options)) {
289
+ const applied = applySafeMode();
290
+ process.stderr.write(
291
+ `safe mode: customizations disabled (${applied.join(", ")}) — permission rules stay active.\n`,
292
+ );
293
+ }
263
294
  }
264
295
  // --worktree (Claude-Code 2.1.171 parity): run THIS session in a fresh
265
296
  // git worktree — edits land on an isolated branch, the main working
@@ -268,9 +299,8 @@ export function registerAgentCommand(program) {
268
299
  let _worktree = null;
269
300
  if (options.worktree) {
270
301
  try {
271
- const { setupAgentWorktree } = await import(
272
- "../lib/agent-worktree.js"
273
- );
302
+ const { setupAgentWorktree } =
303
+ await import("../lib/agent-worktree.js");
274
304
  _worktree = setupAgentWorktree({ cwd: process.cwd() });
275
305
  process.chdir(_worktree.path);
276
306
  process.stderr.write(
@@ -284,9 +314,8 @@ export function registerAgentCommand(program) {
284
314
  const _finishWorktree = async () => {
285
315
  if (!_worktree) return;
286
316
  try {
287
- const { finishAgentWorktree } = await import(
288
- "../lib/agent-worktree.js"
289
- );
317
+ const { finishAgentWorktree } =
318
+ await import("../lib/agent-worktree.js");
290
319
  process.chdir(_worktree.repoRoot); // release the dir before removal
291
320
  const fin = finishAgentWorktree(_worktree);
292
321
  process.stderr.write(
@@ -301,9 +330,8 @@ export function registerAgentCommand(program) {
301
330
  // Claude-Code parity: auto-checkpoint defaults ON inside a git repo
302
331
  // (shadow-commit engine, zero working-tree touch); explicit
303
332
  // --checkpoint / --no-checkpoint always wins.
304
- const { resolveAutoCheckpoint } = await import(
305
- "../lib/auto-checkpoint-default.js"
306
- );
333
+ const { resolveAutoCheckpoint } =
334
+ await import("../lib/auto-checkpoint-default.js");
307
335
  const autoCheckpoint = resolveAutoCheckpoint({
308
336
  flagValue: options.checkpoint,
309
337
  flagSource: command?.getOptionValueSource?.("checkpoint"),
@@ -485,16 +513,23 @@ export function registerAgentCommand(program) {
485
513
  // --think/--ultrathink and on adaptive models). undefined 鈫?engine default.
486
514
  const thinkingBudget = resolveThinkingBudget(options.thinkingBudget);
487
515
 
488
- // --fallback-model: a chatFn that retries once on the backup model when
489
- // the primary errors out (overload / rate-limit / network). Passed into
490
- // the headless runners via options.chatFn (the agent loop's seam), so no
491
- // runner changes are needed. Notice goes to stderr to keep stdout clean.
492
- const fallbackChatFn = options.fallbackModel
516
+ // --fallback-model: an ordered chain of backup models tried in turn when
517
+ // the primary errors out (transient overload / rate-limit / network) or
518
+ // the primary model id is not found. The flag (repeatable / comma-list)
519
+ // wins; otherwise config llm.fallbackModels (or llm.fallbackModel) seeds
520
+ // the chain so unattended runs need no flag. Passed into the headless
521
+ // runners via options.chatFn (the agent loop's seam), so no runner
522
+ // changes are needed. Notice goes to stderr to keep stdout clean.
523
+ const fallbackModels = resolveFallbackModels(
524
+ options.fallbackModel,
525
+ loadConfig().llm || {},
526
+ );
527
+ const fallbackChatFn = fallbackModels.length
493
528
  ? makeFallbackChatFn({
494
- fallbackModel: options.fallbackModel,
529
+ fallbackModels,
495
530
  onFallback: ({ from, to, error }) =>
496
531
  process.stderr.write(
497
- `Note: model "${from}" failed (${error}); retrying with --fallback-model "${to}".\n`,
532
+ `Note: model "${from}" failed (${error}); retrying with fallback model "${to}".\n`,
498
533
  ),
499
534
  })
500
535
  : undefined;
@@ -719,6 +754,8 @@ export function registerAgentCommand(program) {
719
754
  bundlePath: options.bundle || null,
720
755
  additionalDirectories,
721
756
  autoCheckpoint,
757
+ // --vim: start the REPL in vim-mode editing (also CC_VIM=1 or /vim).
758
+ vimMode: options.vim === true,
722
759
  // --system-prompt / --append-system-prompt (literal or @file) also
723
760
  // apply to interactive sessions, composed in startAgentRepl.
724
761
  systemPrompt: resolvePromptText(options.systemPrompt, {
@@ -727,8 +764,9 @@ export function registerAgentCommand(program) {
727
764
  appendSystemPrompt: resolvePromptText(options.appendSystemPrompt, {
728
765
  cwd: process.cwd(),
729
766
  }),
730
- // --fallback-model also applies interactively (wrapper built in the REPL)
731
- fallbackModel: options.fallbackModel || null,
767
+ // --fallback-model also applies interactively (wrapper built in the
768
+ // REPL). Pass the fully resolved chain (flag + config default).
769
+ fallbackModels: fallbackModels.length ? fallbackModels : null,
732
770
  // --mcp-config + registered (cc mcp add) servers also apply to the
733
771
  // interactive session (the REPL resolves both via the mcp-config engine).
734
772
  mcpConfig: options.mcpConfig || null,
@@ -91,12 +91,52 @@ export function isLikelyConnectionError(err) {
91
91
  * MCP Client — manages connections to MCP servers.
92
92
  */
93
93
  export class MCPClient extends EventEmitter {
94
- constructor() {
94
+ /**
95
+ * @param {object} [options]
96
+ * @param {string|null} [options.sessionId] agent session id advertised to
97
+ * spawned stdio MCP servers (CC_SESSION_ID / CLAUDE_CODE_SESSION_ID env).
98
+ */
99
+ constructor(options = {}) {
95
100
  super();
96
101
  this.servers = new Map(); // name → { process, state, tools, resources, config }
97
102
  this._nextId = 1;
98
103
  this._reconnectors = new Map(); // name → async () => config|null
99
104
  this._reconnecting = new Map(); // name → in-flight reconnect promise
105
+ this._sessionId =
106
+ options && options.sessionId != null ? String(options.sessionId) : null;
107
+ }
108
+
109
+ /**
110
+ * Set (or clear) the agent session id advertised to stdio MCP servers. Only
111
+ * servers connected *after* this call see the new value; already-spawned
112
+ * processes keep the env they were launched with.
113
+ * @param {string|null|undefined} id
114
+ */
115
+ setSessionId(id) {
116
+ this._sessionId = id != null && id !== "" ? String(id) : null;
117
+ }
118
+
119
+ /**
120
+ * Environment a spawned stdio MCP server inherits to identify the agent it
121
+ * runs under (Claude-Code 2.1.154 / 2.1.163 parity). `CLAUDECODE` (parity)
122
+ * and `CHAINLESSCHAIN` (native) mark "launched by the agent"; the session id —
123
+ * from the configured value or an ambient `CC_SESSION_ID` — lets a server
124
+ * correlate its work to the run. `CLAUDE_CODE_SESSION_ID` mirrors
125
+ * `CC_SESSION_ID` so servers written for Claude Code work unchanged.
126
+ * @returns {Record<string,string>}
127
+ */
128
+ _agentIdentityEnv() {
129
+ const env = { CLAUDECODE: "1", CHAINLESSCHAIN: "1" };
130
+ const sid =
131
+ this._sessionId ||
132
+ process.env.CC_SESSION_ID ||
133
+ process.env.CLAUDE_CODE_SESSION_ID ||
134
+ null;
135
+ if (sid) {
136
+ env.CC_SESSION_ID = String(sid);
137
+ env.CLAUDE_CODE_SESSION_ID = String(sid);
138
+ }
139
+ return env;
100
140
  }
101
141
 
102
142
  /**
@@ -159,7 +199,13 @@ export class MCPClient extends EventEmitter {
159
199
  }
160
200
  const proc = _deps.spawn(config.command, config.args || [], {
161
201
  stdio: ["pipe", "pipe", "pipe"],
162
- env: { ...process.env, ...(config.env || {}) },
202
+ // process.env < agent identity (CLAUDECODE / session id) < the
203
+ // server's own config.env, so an explicit per-server override wins.
204
+ env: {
205
+ ...process.env,
206
+ ...this._agentIdentityEnv(),
207
+ ...(config.env || {}),
208
+ },
163
209
  });
164
210
 
165
211
  entry.process = proc;
@@ -11,6 +11,8 @@
11
11
  export {
12
12
  AGENT_TOOLS,
13
13
  AGENT_TOOL_REGISTRY,
14
+ MAX_SUB_AGENT_DEPTH,
15
+ reloadSkills,
14
16
  getAgentToolDefinitions,
15
17
  getAgentToolDescriptors,
16
18
  getCachedPython,
@@ -35,6 +35,15 @@ export const PRICE_TABLE = Object.freeze({
35
35
  { match: "haiku", in: 1, out: 5 },
36
36
  ],
37
37
  openai: [
38
+ // GPT-5 family (2026). Matching is longest-pattern-first, so dated/variant
39
+ // ids (gpt-5.5, gpt-5.5-pro, gpt-5.5-instant, …) resolve to the most
40
+ // specific rate; bare "gpt-5" is the catch-all base rate.
41
+ { match: "gpt-5.5-pro", in: 30, out: 180 },
42
+ { match: "gpt-5.5", in: 5, out: 30 },
43
+ { match: "gpt-5.4", in: 2.5, out: 15 },
44
+ { match: "gpt-5-mini", in: 0.25, out: 2 },
45
+ { match: "gpt-5-nano", in: 0.05, out: 0.4 },
46
+ { match: "gpt-5", in: 1.25, out: 10 },
38
47
  { match: "gpt-4o-mini", in: 0.15, out: 0.6 },
39
48
  { match: "gpt-4o", in: 2.5, out: 10 },
40
49
  { match: "gpt-4-turbo", in: 10, out: 30 },
@@ -14,5 +14,6 @@ export {
14
14
  MCPServerConfig,
15
15
  inferTransport,
16
16
  isHttpTransport,
17
+ isLikelyConnectionError,
17
18
  _deps,
18
19
  } from "../harness/mcp-client.js";
@@ -14,6 +14,8 @@
14
14
  * Edit(//etc/**) → edit_file on an absolute path under /etc
15
15
  * WebFetch(domain:example.com) → web_fetch of https://example.com/…
16
16
  * Bash → every run_shell call
17
+ * * → every tool call (Claude-Code deny-all idiom)
18
+ * Bash(*) → every run_shell call (lone-`*` pattern = match-all)
17
19
  *
18
20
  * Pure + self-contained (no glob dependency — `globToRegExp` is built in, the
19
21
  * repo avoids pulling minimatch/picomatch). Decision precedence is
@@ -75,6 +77,8 @@ const URL_TOOLS = new Set(["web_fetch"]);
75
77
  function toolMatches(ruleTool, actualTool) {
76
78
  const r = String(ruleTool || "").toLowerCase();
77
79
  const a = String(actualTool || "");
80
+ // Claude-Code `*` deny-all: a bare-`*` tool token matches every tool.
81
+ if (r === "*") return true;
78
82
  if (Object.prototype.hasOwnProperty.call(TOOL_GROUPS, r)) {
79
83
  return TOOL_GROUPS[r].includes(a);
80
84
  }
@@ -88,7 +92,8 @@ function toolMatches(ruleTool, actualTool) {
88
92
  function parseRule(rule) {
89
93
  const raw = String(rule || "").trim();
90
94
  if (!raw) return null;
91
- const m = raw.match(/^([A-Za-z_][\w-]*)\s*(?:\(([\s\S]*)\))?$/);
95
+ // Tool token is an umbrella/CLI name OR a bare `*` (Claude-Code deny-all).
96
+ const m = raw.match(/^(\*|[A-Za-z_][\w-]*)\s*(?:\(([\s\S]*)\))?$/);
92
97
  if (!m) return null;
93
98
  const tool = m[1];
94
99
  const pattern = m[2] === undefined ? null : m[2].trim();
@@ -198,6 +203,11 @@ function matchUrl(pattern, url) {
198
203
  */
199
204
  function matchPattern(pattern, actualTool, args, cwd) {
200
205
  if (pattern === null) return true;
206
+ // A lone `*` / `**` pattern matches any target regardless of slashes — covers
207
+ // `Bash(*)`, `Read(**)`, `WebFetch(*)`, etc. Done before the glob path so a
208
+ // command/url/path containing `/` can't slip past a deny-all (globToRegExp's
209
+ // `*` → `[^/]*` otherwise excludes slashes).
210
+ if (pattern === "*" || pattern === "**") return true;
201
211
  const target = extractTarget(actualTool, args, cwd);
202
212
  if (target.kind === "command") {
203
213
  return target.value ? matchCommand(pattern, target.value) : false;
@@ -54,6 +54,9 @@ const {
54
54
  LocalFilesAdapter,
55
55
  BilibiliAdapter,
56
56
  WeiboAdapter,
57
+ ZhihuAdapter,
58
+ BossZhipinAdapter,
59
+ CsdnAdapter,
57
60
  DouyinAdapter,
58
61
  XiaohongshuAdapter,
59
62
  ToutiaoAdapter,
@@ -68,7 +71,13 @@ const {
68
71
  QQPcAdapter,
69
72
  AppleHealthAdapter,
70
73
  NeteaseMusicAdapter,
74
+ KugouMusicAdapter,
75
+ IqiyiVideoAdapter,
76
+ TencentVideoAdapter,
71
77
  WeReadAdapter,
78
+ WpsDocAdapter,
79
+ TencentDocsAdapter,
80
+ BaiduNetdiskAdapter,
72
81
  DingTalkPcAdapter,
73
82
  FeishuPcAdapter,
74
83
  BaiduMapAdapter,
@@ -76,9 +85,12 @@ const {
76
85
  JdAdapter,
77
86
  MeituanAdapter,
78
87
  PinduoduoAdapter,
88
+ DianpingAdapter,
79
89
  Train12306Adapter,
80
90
  TaobaoAdapter,
81
91
  CtripAdapter,
92
+ TongchengAdapter,
93
+ DidiAdapter,
82
94
  AmapAdapter,
83
95
  TelegramAdapter,
84
96
  WhatsAppAdapter,
@@ -514,6 +526,9 @@ async function initHub() {
514
526
  // accurate.
515
527
  for (const Cls of [
516
528
  WeiboAdapter,
529
+ ZhihuAdapter,
530
+ BossZhipinAdapter,
531
+ CsdnAdapter,
517
532
  DouyinAdapter,
518
533
  XiaohongshuAdapter,
519
534
  ToutiaoAdapter,
@@ -528,7 +543,13 @@ async function initHub() {
528
543
  QQPcAdapter,
529
544
  AppleHealthAdapter,
530
545
  NeteaseMusicAdapter,
546
+ KugouMusicAdapter,
547
+ IqiyiVideoAdapter,
548
+ TencentVideoAdapter,
531
549
  WeReadAdapter,
550
+ WpsDocAdapter,
551
+ TencentDocsAdapter,
552
+ BaiduNetdiskAdapter,
532
553
  DingTalkPcAdapter,
533
554
  FeishuPcAdapter,
534
555
  BaiduMapAdapter,
@@ -536,9 +557,12 @@ async function initHub() {
536
557
  JdAdapter,
537
558
  MeituanAdapter,
538
559
  PinduoduoAdapter,
560
+ DianpingAdapter,
539
561
  Train12306Adapter,
540
562
  TaobaoAdapter,
541
563
  CtripAdapter,
564
+ TongchengAdapter,
565
+ DidiAdapter,
542
566
  AmapAdapter,
543
567
  TelegramAdapter,
544
568
  WhatsAppAdapter,
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Multiline REPL input via backslash continuation (Claude-Code multiline parity).
3
+ *
4
+ * Node's readline submits on every Enter, so a single prompt is one line. This
5
+ * pure helper lets the REPL accumulate a multi-line prompt: a physical line that
6
+ * ends with a continuation backslash keeps the prompt open and the next line is
7
+ * appended (joined with "\n"), so code blocks / multi-paragraph prompts can be
8
+ * entered without a turn firing per line.
9
+ *
10
+ * The rule is shell-like but Windows-path-safe: a trailing backslash continues
11
+ * the line ONLY when it is a lone `\` or the backslash run is preceded by
12
+ * whitespace, and the run length is odd (so `\\` stays a literal backslash).
13
+ * That keeps a stray path like `dir C:\` from being swallowed as a continuation.
14
+ *
15
+ * analyzeContinuation("write a function \\") → { continued:true, text:"write a function" }
16
+ * analyzeContinuation("dir C:\\") → { continued:false, text:"dir C:\\" }
17
+ * analyzeContinuation("plain line") → { continued:false, text:"plain line" }
18
+ *
19
+ * The REPL keeps an array of `text` pieces and `joinContinuation()` stitches the
20
+ * final submission.
21
+ */
22
+
23
+ /** Count the run of backslashes at the very end of a string. */
24
+ function trailingBackslashes(s) {
25
+ let n = 0;
26
+ for (let i = s.length - 1; i >= 0 && s[i] === "\\"; i--) n++;
27
+ return n;
28
+ }
29
+
30
+ /**
31
+ * Decide whether a physical input line continues onto the next one.
32
+ *
33
+ * @param {string} line the raw line as readline delivered it
34
+ * @returns {{ continued:boolean, text:string }}
35
+ * continued → drop the trailing backslash (+ the space before it) and wait for
36
+ * more; not continued → the line stands as typed (text === line).
37
+ */
38
+ export function analyzeContinuation(line) {
39
+ const s = typeof line === "string" ? line : "";
40
+ const n = trailingBackslashes(s);
41
+ if (n === 0 || n % 2 === 0) return { continued: false, text: s };
42
+ // Odd trailing backslashes: gate on what precedes the run so Windows paths
43
+ // (no preceding whitespace) are not treated as continuations.
44
+ const before = s[s.length - n - 1]; // undefined when the run is the whole line
45
+ const gated = before === undefined || /\s/.test(before);
46
+ if (!gated) return { continued: false, text: s };
47
+ // Strip exactly one trailing backslash, then trim the now-trailing whitespace
48
+ // so the join reads cleanly.
49
+ const text = s.slice(0, s.length - 1).replace(/\s+$/, "");
50
+ return { continued: true, text };
51
+ }
52
+
53
+ /**
54
+ * Stitch accumulated continuation pieces plus the final line into one prompt.
55
+ *
56
+ * @param {string[]} pieces prior `text` values from continued lines
57
+ * @param {string} finalLine the line that ended the continuation (raw)
58
+ * @returns {string}
59
+ */
60
+ export function joinContinuation(pieces, finalLine) {
61
+ const parts = Array.isArray(pieces) ? pieces.slice() : [];
62
+ parts.push(typeof finalLine === "string" ? finalLine : "");
63
+ return parts.join("\n");
64
+ }
@@ -1,6 +1,8 @@
1
1
  /**
2
- * REPL conversation rewind — Claude-Code double-Esc parity (v1: conversation
3
- * state; file state stays on `cc checkpoint restore`, hinted alongside).
2
+ * REPL conversation rewind — Claude-Code double-Esc parity. Conversation state
3
+ * AND, when auto-checkpointing is on (git work tree), the file tree are rewound
4
+ * together — matching Claude Code's rewind, which restores code + conversation
5
+ * in one step instead of leaving files on a separate `cc checkpoint restore`.
4
6
  *
5
7
  * Pure helpers over the REPL's live `messages` array so the picker logic is
6
8
  * unit-testable without readline:
@@ -8,9 +10,19 @@
8
10
  * - rewindToTurn(): truncate the conversation BACK TO BEFORE turn #n and
9
11
  * return the original text so the caller can prefill the input line
10
12
  * (edit-and-resend, like Claude Code's rewind).
13
+ * - pickCheckpointForTurn(): map a rewound turn to the file checkpoint that
14
+ * captured the work tree just before that turn first mutated it.
15
+ * - pruneMarksAfter(): drop checkpoint marks for the turns that were dropped.
11
16
  *
12
17
  * Trigger surfaces (wired in agent-repl): `/rewind` lists, `/rewind <n>`
13
18
  * rewinds, and a double-Esc while idle prints the same list as a shortcut.
19
+ *
20
+ * Checkpoint marks: the REPL records `{ atMessageCount, id, tool }` for every
21
+ * `checkpoint` event the agent loop emits — `atMessageCount` is `messages.length`
22
+ * at the instant the snapshot was taken (always just AFTER the turn's user
23
+ * message was appended, so it is strictly greater than that turn's message
24
+ * index, and not-greater than any later turn's). That ordering is what lets a
25
+ * turn be matched to its pre-mutation snapshot purely from the count.
14
26
  */
15
27
 
16
28
  export const DEFAULT_LIST_LIMIT = 10;
@@ -64,10 +76,61 @@ export function rewindToTurn(messages, n) {
64
76
  messages.splice(turn.index);
65
77
  return {
66
78
  removed,
79
+ index: turn.index,
67
80
  text: typeof turn.content === "string" ? turn.content : null,
68
81
  };
69
82
  }
70
83
 
84
+ /**
85
+ * Map a rewound turn to the checkpoint that captured the work tree right BEFORE
86
+ * that turn first changed a file.
87
+ *
88
+ * A turn's auto-checkpoints are all taken with `atMessageCount` strictly greater
89
+ * than the turn's message index (the user message is appended first), while the
90
+ * previous turn's checkpoints have `atMessageCount <= turnIndex`. So the snapshot
91
+ * representing "state before turn N" is the one with the SMALLEST atMessageCount
92
+ * still greater than turnIndex.
93
+ *
94
+ * @param {Array<{atMessageCount:number,id:string,tool?:string}>} marks
95
+ * @param {number} turnIndex message index returned by rewindToTurn
96
+ * @returns {{atMessageCount:number,id:string,tool?:string}|null}
97
+ */
98
+ export function pickCheckpointForTurn(marks, turnIndex) {
99
+ if (!Array.isArray(marks) || marks.length === 0) return null;
100
+ const idx = Number(turnIndex);
101
+ if (!Number.isFinite(idx)) return null;
102
+ let best = null;
103
+ for (const m of marks) {
104
+ if (!m || typeof m.id !== "string") continue;
105
+ const c = Number(m.atMessageCount);
106
+ if (!Number.isFinite(c) || c <= idx) continue;
107
+ if (best === null || c < Number(best.atMessageCount)) best = m;
108
+ }
109
+ return best;
110
+ }
111
+
112
+ /**
113
+ * Drop checkpoint marks belonging to turns that were just rewound away (those
114
+ * with `atMessageCount` greater than the surviving message count). Mutates the
115
+ * array in place so the REPL's `const` marks array keeps its identity.
116
+ *
117
+ * @returns {number} how many marks were removed
118
+ */
119
+ export function pruneMarksAfter(marks, turnIndex) {
120
+ if (!Array.isArray(marks)) return 0;
121
+ const idx = Number(turnIndex);
122
+ if (!Number.isFinite(idx)) return 0;
123
+ let removed = 0;
124
+ for (let i = marks.length - 1; i >= 0; i--) {
125
+ const c = Number(marks[i]?.atMessageCount);
126
+ if (!Number.isFinite(c) || c > idx) {
127
+ marks.splice(i, 1);
128
+ removed += 1;
129
+ }
130
+ }
131
+ return removed;
132
+ }
133
+
71
134
  /**
72
135
  * Offline extractive recap for a resumed conversation ("where were we") —
73
136
  * no LLM call: turn counts + last ask + last reply previews.