chainlesschain 0.163.6 → 0.163.8
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.
- package/package.json +2 -1
- package/src/assets/web-panel/assets/{AIOps-DDIUofA8.js → AIOps-CavM7W3k.js} +1 -1
- package/src/assets/web-panel/assets/{ActionButton-Bm-5xYRn.js → ActionButton-CUvZGabQ.js} +1 -1
- package/src/assets/web-panel/assets/{Analytics-D5UH4ljI.js → Analytics-DeBnWnbe.js} +3 -3
- package/src/assets/web-panel/assets/{AppLayout-D_ifjOOP.js → AppLayout-DbI5kxvd.js} +4 -4
- package/src/assets/web-panel/assets/{Artifacts-BY1mXdC7.js → Artifacts-D93bigKm.js} +1 -1
- package/src/assets/web-panel/assets/{Audit-Bujr4Ml3.js → Audit-CBNvfUZa.js} +1 -1
- package/src/assets/web-panel/assets/{BackgroundAgents-sioKSTcC.js → BackgroundAgents-CJLyh_YU.js} +1 -1
- package/src/assets/web-panel/assets/{Backup-DDOAK8RK.js → Backup-D_0yoehD.js} +1 -1
- package/src/assets/web-panel/assets/{BaseInput-CtCsVVke.js → BaseInput-TJxmbObW.js} +1 -1
- package/src/assets/web-panel/assets/{Chat-DpNj0vnd.js → Chat-CE0dto1q.js} +5 -5
- package/src/assets/web-panel/assets/{ChatBubbleRenderer-CZta3Ftr.js → ChatBubbleRenderer-CZ5-yYiD.js} +1 -1
- package/src/assets/web-panel/assets/{Checkbox-DoHVNSXq.js → Checkbox-Ck1RVIVo.js} +1 -1
- package/src/assets/web-panel/assets/{Codegen-DlVl7Qmv.js → Codegen-qpoyf6DK.js} +1 -1
- package/src/assets/web-panel/assets/{Col-GIqoPYty.js → Col-DUyPWjIE.js} +1 -1
- package/src/assets/web-panel/assets/{Community-CIAPEVji.js → Community-D_S1BemS.js} +1 -1
- package/src/assets/web-panel/assets/{Compact-BN7JiI_h.js → Compact-BjxeK-Gc.js} +1 -1
- package/src/assets/web-panel/assets/{Compliance-CqUWCM9B.js → Compliance-Dd3CEJsu.js} +1 -1
- package/src/assets/web-panel/assets/{Cowork-A4iPp7A4.js → Cowork-B4QG7-ad.js} +3 -3
- package/src/assets/web-panel/assets/{Cron-B2zeXXWb.js → Cron-BtZnids5.js} +2 -2
- package/src/assets/web-panel/assets/{Crosschain-BR2xmWr8.js → Crosschain-CHPfCBFD.js} +1 -1
- package/src/assets/web-panel/assets/{DID-BzFDjrIv.js → DID-DT8DCEOK.js} +2 -2
- package/src/assets/web-panel/assets/{Dashboard-DKtDo3yA.js → Dashboard-COQab5_U.js} +2 -2
- package/src/assets/web-panel/assets/{Dropdown-RNx43_YG.js → Dropdown-BY1PsQuU.js} +1 -1
- package/src/assets/web-panel/assets/{EmailListRenderer-SwMt4Rcy.js → EmailListRenderer-CsuAuaq3.js} +1 -1
- package/src/assets/web-panel/assets/{FamilyGuardDashboard-CsYebZ4X.js → FamilyGuardDashboard-BqpinD-j.js} +1 -1
- package/src/assets/web-panel/assets/{Federation-BmRKvBTy.js → Federation-D0gkfQFv.js} +1 -1
- package/src/assets/web-panel/assets/{FormItemContext-CVxGTA-0.js → FormItemContext-BqgE-axK.js} +1 -1
- package/src/assets/web-panel/assets/{GenericCardRenderer-x2iXpyB7.js → GenericCardRenderer-D0hJ2KvC.js} +1 -1
- package/src/assets/web-panel/assets/{Git-DfqbkiOP.js → Git-CmMB0uPY.js} +2 -2
- package/src/assets/web-panel/assets/{Governance-RuHyyj5O.js → Governance-BnVEI0Dk.js} +1 -1
- package/src/assets/web-panel/assets/{Inference-Bn7uZ7rI.js → Inference-YTAMihRP.js} +1 -1
- package/src/assets/web-panel/assets/{KnowledgeGraph-DlP7XefZ.js → KnowledgeGraph-0ax7VHop.js} +1 -1
- package/src/assets/web-panel/assets/{Logs-BYNdOiCd.js → Logs-B9TRcokL.js} +2 -2
- package/src/assets/web-panel/assets/MarkdownRenderer-yySN5YNM.js +1 -0
- package/src/assets/web-panel/assets/{Marketplace-JQYmDqM8.js → Marketplace-B6CSuD_H.js} +1 -1
- package/src/assets/web-panel/assets/{McpTools-Cyx4yZ-9.js → McpTools-CjMXvOVU.js} +4 -4
- package/src/assets/web-panel/assets/{Memory-VDuGZTN2.js → Memory-CXRF71U3.js} +2 -2
- package/src/assets/web-panel/assets/{MobileBridge-_yKo97gi.js → MobileBridge-DQgNp_oS.js} +1 -1
- package/src/assets/web-panel/assets/{MobileProjects-CXRXW3q7.js → MobileProjects-DlPwcCbq.js} +1 -1
- package/src/assets/web-panel/assets/{Mtc-acTGtfLH.js → Mtc-6hDTRPe1.js} +5 -5
- package/src/assets/web-panel/assets/{MtcAudit-ClpjXfkY.js → MtcAudit-BlVHU1DS.js} +4 -4
- package/src/assets/web-panel/assets/{Multisig-_6Tn3o96.js → Multisig-DP9pzEbV.js} +3 -3
- package/src/assets/web-panel/assets/{NLProgramming-CK7pbZzP.js → NLProgramming-Djorh8EV.js} +1 -1
- package/src/assets/web-panel/assets/{Notes-Czy6V_P8.js → Notes-oLZ-JkUg.js} +4 -4
- package/src/assets/web-panel/assets/{NotificationSettings-Cqx-UVv3.js → NotificationSettings-Cg288VH3.js} +1 -1
- package/src/assets/web-panel/assets/{OrderTableRenderer-C69WDxGy.js → OrderTableRenderer-Bb1O3Ofr.js} +1 -1
- package/src/assets/web-panel/assets/{Organization-DFnA9vLQ.js → Organization-CBdo-bHs.js} +4 -4
- package/src/assets/web-panel/assets/{Overflow-ReZkk2yT.js → Overflow-qZdnVumx.js} +1 -1
- package/src/assets/web-panel/assets/{P2P-DzjSI0aI.js → P2P-D4kNfGNQ.js} +2 -2
- package/src/assets/web-panel/assets/PdhVaultBrowser-DnlMemM7.js +7 -0
- package/src/assets/web-panel/assets/{Permissions-DhQ5klhR.js → Permissions-DHucHFBJ.js} +3 -3
- package/src/assets/web-panel/assets/{PersonalDataHub-CUL1iHrW.js → PersonalDataHub-BovlOIPR.js} +4 -4
- package/src/assets/web-panel/assets/{Pipeline-DU88iu4N.js → Pipeline-Deru3CQY.js} +1 -1
- package/src/assets/web-panel/assets/{Privacy-Bw-sYfyK.js → Privacy-Bq5oTTbU.js} +1 -1
- package/src/assets/web-panel/assets/{ProjectInit-Bq3Q5y0z.js → ProjectInit-BfzxVWAz.js} +2 -2
- package/src/assets/web-panel/assets/{ProjectSettings-C8spzpho.js → ProjectSettings-CKC6XBtH.js} +2 -2
- package/src/assets/web-panel/assets/Projects-CMolGhae.js +1 -0
- package/src/assets/web-panel/assets/{Providers-Bf4eTP9W.js → Providers-C_jx4TWX.js} +1 -1
- package/src/assets/web-panel/assets/{QrScannerModal-Dme9BDU1.js → QrScannerModal-BdIHeVGC.js} +1 -1
- package/src/assets/web-panel/assets/{QuickAsk-CIXfv1rE.js → QuickAsk-BwZwAcPD.js} +1 -1
- package/src/assets/web-panel/assets/{Recommend-CIxvdeZ-.js → Recommend-BNTt0L-m.js} +1 -1
- package/src/assets/web-panel/assets/{RemoteSession-C6k7MExI.js → RemoteSession-Biyn2-Ro.js} +2 -2
- package/src/assets/web-panel/assets/{Reputation-CISDz2bl.js → Reputation-D6VpG32B.js} +1 -1
- package/src/assets/web-panel/assets/{Row-CdnDxXyf.js → Row-D_74OvQQ.js} +1 -1
- package/src/assets/web-panel/assets/{RssFeed-C-QpRHsl.js → RssFeed-BTr0a-BQ.js} +3 -3
- package/src/assets/web-panel/assets/{Search-DBjaGzSn.js → Search-C3MCFoNU.js} +1 -1
- package/src/assets/web-panel/assets/{Security-CQKukOeE.js → Security-CqW9aJ6s.js} +3 -3
- package/src/assets/web-panel/assets/{Services-DZz86jWb.js → Services-Cw5GNaHF.js} +2 -2
- package/src/assets/web-panel/assets/{Skeleton-jb8RMK0d.js → Skeleton-DZps5qeY.js} +1 -1
- package/src/assets/web-panel/assets/{Skills-CdY76fZG.js → Skills-C6NQ1znT.js} +1 -1
- package/src/assets/web-panel/assets/{Sla-C_CSiZX9.js → Sla-DFP8G2Sh.js} +1 -1
- package/src/assets/web-panel/assets/SpeechSettings-ESt6MB6v.js +1 -0
- package/src/assets/web-panel/assets/{SyncSettings-qvimGO0O.js → SyncSettings-BHnN98aM.js} +2 -2
- package/src/assets/web-panel/assets/{Tasks-Dng5LPJC.js → Tasks-NiSCaOf-.js} +1 -1
- package/src/assets/web-panel/assets/{Templates-Bwqq5Wll.js → Templates-DsKFhW2C.js} +1 -1
- package/src/assets/web-panel/assets/{Tenant-DNWuwP7Z.js → Tenant-CQ0E0ze5.js} +1 -1
- package/src/assets/web-panel/assets/{Terminal-B-6Othpp.js → Terminal-D_rBu_by.js} +2 -2
- package/src/assets/web-panel/assets/{TimelineRenderer-DKpKZfzx.js → TimelineRenderer-D3Vm4Po4.js} +1 -1
- package/src/assets/web-panel/assets/{Tokens-DzfGMd2J.js → Tokens-DNTxRH6q.js} +1 -1
- package/src/assets/web-panel/assets/{Trigger-BXwUi74J.js → Trigger-Dgprz1ms.js} +1 -1
- package/src/assets/web-panel/assets/{Trust-BNzUq4ui.js → Trust-B2rUnVBD.js} +1 -1
- package/src/assets/web-panel/assets/{UkeySign-BYugxww4.js → UkeySign-DEGQNc6_.js} +1 -1
- package/src/assets/web-panel/assets/{VideoEditing-DdauhtSJ.js → VideoEditing-jlsAx3Eh.js} +1 -1
- package/src/assets/web-panel/assets/{Wallet-CSC9bCe_.js → Wallet-8jQih1ij.js} +4 -4
- package/src/assets/web-panel/assets/{WebAuthn-Q8AN3bTO.js → WebAuthn-XLeO6xIB.js} +5 -5
- package/src/assets/web-panel/assets/{WorkflowEditor-d-LBGCuA.js → WorkflowEditor-De_dgDAG.js} +1 -1
- package/src/assets/web-panel/assets/{chat-BLVDCgsZ.js → chat-CI19R_Sk.js} +1 -1
- package/src/assets/web-panel/assets/{colors-BZlPSEHl.js → colors-DsYTOYN3.js} +1 -1
- package/src/assets/web-panel/assets/{compact-item-IWseP6R6.js → compact-item-CM3-t_Qr.js} +1 -1
- package/src/assets/web-panel/assets/{createContext-DnVRV3Ao.js → createContext-BjxlBRZv.js} +1 -1
- package/src/assets/web-panel/assets/devWarning-S1ld2LwU.js +1 -0
- package/src/assets/web-panel/assets/{hasIn-DLQZA_Wn.js → hasIn-RDaWX_4i.js} +1 -1
- package/src/assets/web-panel/assets/{index-BSjilZ9L.js → index-9R6BxAr0.js} +1 -1
- package/src/assets/web-panel/assets/{index-B_N4-Gq9.js → index-B-Z8eFUJ.js} +1 -1
- package/src/assets/web-panel/assets/{index-Dy0R5ZED.js → index-B0PMlbMs.js} +1 -1
- package/src/assets/web-panel/assets/{index-C1ifZtXo.js → index-B5REnKt8.js} +1 -1
- package/src/assets/web-panel/assets/{index-CINJQEj6.js → index-B7WBt_4T.js} +1 -1
- package/src/assets/web-panel/assets/{index-DocEhinm.js → index-B9O9YyWE.js} +1 -1
- package/src/assets/web-panel/assets/{index-DjWnONdy.js → index-BCnZyIMA.js} +1 -1
- package/src/assets/web-panel/assets/{index-hwVDeoC0.js → index-BGqqJfL0.js} +1 -1
- package/src/assets/web-panel/assets/{index-Bbj2NS_I.js → index-BHNYPO0b.js} +3 -3
- package/src/assets/web-panel/assets/{index-C5dgnilC.js → index-BKJr-TZp.js} +1 -1
- package/src/assets/web-panel/assets/{index-CT9vVN-X.js → index-BN6UPD2E.js} +1 -1
- package/src/assets/web-panel/assets/{index-DpVrK6fr.js → index-Bi46Xu4u.js} +1 -1
- package/src/assets/web-panel/assets/{index-CpBaJ3TD.js → index-BlT2VAEK.js} +1 -1
- package/src/assets/web-panel/assets/{index-1jeAudHd.js → index-C0yx-jtQ.js} +1 -1
- package/src/assets/web-panel/assets/{index-DOoQpuQY.js → index-C4gkzxkw.js} +1 -1
- package/src/assets/web-panel/assets/{index-DZpYeqrh.js → index-CVQMeiwH.js} +1 -1
- package/src/assets/web-panel/assets/{index-BhA3QEni.js → index-Cd3euP_4.js} +1 -1
- package/src/assets/web-panel/assets/{index-N_GoWZX4.js → index-Cd9OJhHG.js} +1 -1
- package/src/assets/web-panel/assets/{index-BOZJBTWZ.js → index-CiECJi-Q.js} +1 -1
- package/src/assets/web-panel/assets/{index-CarMTIyQ.js → index-CjTrRt13.js} +1 -1
- package/src/assets/web-panel/assets/{index-CZDekj7T.js → index-CnHH7bnD.js} +1 -1
- package/src/assets/web-panel/assets/{index-M7wxfAbm.js → index-Cpqm1qfU.js} +1 -1
- package/src/assets/web-panel/assets/{index-Bxp7uDD8.js → index-CyOGN6a5.js} +1 -1
- package/src/assets/web-panel/assets/{index-DalA0TKC.js → index-D0zcy54x.js} +1 -1
- package/src/assets/web-panel/assets/{index-COev0W2g.js → index-D6sm5-Xq.js} +1 -1
- package/src/assets/web-panel/assets/{index-DUq0c7gq.js → index-DIUnNOjG.js} +1 -1
- package/src/assets/web-panel/assets/{index-BZs5bBnk.js → index-DX7tuWVJ.js} +1 -1
- package/src/assets/web-panel/assets/{index-CbQNL0ue.js → index-DXXtGMUJ.js} +1 -1
- package/src/assets/web-panel/assets/{index-DTbxp4UH.js → index-DcPFB8qJ.js} +1 -1
- package/src/assets/web-panel/assets/{index-YSw_gxlZ.js → index-DoQA0-52.js} +1 -1
- package/src/assets/web-panel/assets/{index-D_LQodeJ.js → index-Drlnwr8F.js} +1 -1
- package/src/assets/web-panel/assets/index-Drz6yq0m.js +1 -0
- package/src/assets/web-panel/assets/{index-jWb70ZgZ.js → index-Dsij_KsN.js} +1 -1
- package/src/assets/web-panel/assets/{index-DB0MJgF_.js → index-Dxge-xWl.js} +1 -1
- package/src/assets/web-panel/assets/{index-BEu2lMBy.js → index-DyIWssPC.js} +1 -1
- package/src/assets/web-panel/assets/{index-C2FqfMvU.js → index-IeiL9RKc.js} +1 -1
- package/src/assets/web-panel/assets/{index-Dkwsi1Kn.js → index-nAH87mQP.js} +1 -1
- package/src/assets/web-panel/assets/{index-gt8bNefW.js → index-pPL66J85.js} +1 -1
- package/src/assets/web-panel/assets/index-uWiUs7S_.js +1 -0
- package/src/assets/web-panel/assets/{initDefaultProps-Co67Kqmb.js → initDefaultProps-BTL88of4.js} +1 -1
- package/src/assets/web-panel/assets/{motion-BMOxQSF_.js → motion-BUB2pXwB.js} +1 -1
- package/src/assets/web-panel/assets/{move-C5fWDw-N.js → move-egCkkOMm.js} +1 -1
- package/src/assets/web-panel/assets/{mtc-parser-BJevpL0e.js → mtc-parser-DAWhZC8c.js} +1 -1
- package/src/assets/web-panel/assets/{omit-BCzNU8s6.js → omit-CvOxe_6d.js} +1 -1
- package/src/assets/web-panel/assets/{pickAttrs-CybWvDPk.js → pickAttrs-DZUSLZ5Z.js} +1 -1
- package/src/assets/web-panel/assets/{placementArrow-BMWS9HnW.js → placementArrow-BERxGNMY.js} +1 -1
- package/src/assets/web-panel/assets/{responsiveObserve-BoL2UnGY.js → responsiveObserve-DZuDfZ9n.js} +1 -1
- package/src/assets/web-panel/assets/{slide-DWNfXraU.js → slide-DO756sgI.js} +1 -1
- package/src/assets/web-panel/assets/{statusUtils-BquTM3tX.js → statusUtils-BRQlIz28.js} +1 -1
- package/src/assets/web-panel/assets/{styleChecker-BEkCleim.js → styleChecker-DCSfdybl.js} +1 -1
- package/src/assets/web-panel/assets/{useFlexGapSupport-Oecnq7EA.js → useFlexGapSupport-LD8dWVve.js} +1 -1
- package/src/assets/web-panel/assets/{useFs-CkDffJ4F.js → useFs-BX9uW2LK.js} +1 -1
- package/src/assets/web-panel/assets/{usePersonalDataHub-qbvKXesB.js → usePersonalDataHub-BPSlPuHU.js} +1 -1
- package/src/assets/web-panel/assets/{vnode-C6v8n6mA.js → vnode-BmOILC9V.js} +1 -1
- package/src/assets/web-panel/assets/{zoom-4CTeFILV.js → zoom-1iKowKGg.js} +1 -1
- package/src/assets/web-panel/index.html +1 -1
- package/src/command-help-index.json +5 -5
- package/src/commands/agent.js +90 -1
- package/src/commands/automation.js +103 -1
- package/src/commands/chat.js +11 -2
- package/src/commands/compact.js +106 -23
- package/src/commands/loop.js +28 -10
- package/src/commands/routine.js +1 -1
- package/src/commands/scheduler-daemon.js +359 -2
- package/src/commands/session-observability.js +305 -0
- package/src/commands/session.js +38 -0
- package/src/commands/team-merge-review.js +937 -0
- package/src/commands/team.js +2 -0
- package/src/data/changelog.json +27 -1
- package/src/gateways/ws/ws-agent-handler.js +439 -5
- package/src/harness/jsonl-session-store.js +463 -125
- package/src/harness/prompt-compressor.js +86 -13
- package/src/harness/provider-backed-compaction.js +100 -27
- package/src/lib/advisor-runtime.js +3 -1
- package/src/lib/agent-schedule-store.js +549 -28
- package/src/lib/agent-team/team-adjudication.js +40 -1
- package/src/lib/agent-team/team-merge-review-store.js +765 -0
- package/src/lib/agent-team/team-merge-review-transaction.js +1223 -0
- package/src/lib/agent-team/team-merge-review.js +1847 -0
- package/src/lib/automation-center-incidents.js +314 -0
- package/src/lib/automation-center-runtime.js +448 -0
- package/src/lib/automation-center.js +182 -38
- package/src/lib/automation-engine.js +535 -0
- package/src/lib/automation-execution-authority.js +241 -12
- package/src/lib/automation-execution-incident.js +737 -0
- package/src/lib/background-agent-supervisor.js +793 -215
- package/src/lib/background-command-argv.js +24 -0
- package/src/lib/background-interaction-journal.js +361 -52
- package/src/lib/background-interaction-resolver.js +32 -0
- package/src/lib/background-launch-profile.js +2 -0
- package/src/lib/causal-observability.js +2661 -0
- package/src/lib/chat-session-admission.js +76 -0
- package/src/lib/cost-budget.js +5 -7
- package/src/lib/cowork/ab-comparator-cli.js +11 -0
- package/src/lib/cowork/debate-review-cli.js +12 -0
- package/src/lib/cowork-adapter.js +159 -38
- package/src/lib/cowork-cron.js +442 -15
- package/src/lib/cowork-task-runner.js +112 -17
- package/src/lib/delivery-coordinator.js +142 -0
- package/src/lib/direct-model-usage.js +121 -0
- package/src/lib/file-lines.js +183 -47
- package/src/lib/llm-pricing.js +12 -17
- package/src/lib/loop.js +26 -2
- package/src/lib/routine-store.js +380 -21
- package/src/lib/runtime-usage-ledger.js +182 -0
- package/src/lib/scheduler-kernel/agenda-adapter.js +325 -10
- package/src/lib/scheduler-kernel/automation-adapter.js +514 -18
- package/src/lib/scheduler-kernel/automation-event-adapter.js +123 -11
- package/src/lib/scheduler-kernel/contract.js +91 -0
- package/src/lib/scheduler-kernel/cowork-cron-adapter.js +297 -4
- package/src/lib/scheduler-kernel/loop-adapter.js +547 -6
- package/src/lib/scheduler-kernel/migration-admin.js +346 -0
- package/src/lib/scheduler-kernel/migration-rollback-admin.js +932 -0
- package/src/lib/scheduler-kernel/routine-adapter.js +400 -20
- package/src/lib/scheduler-kernel/runtime-control-capabilities.js +31 -0
- package/src/lib/scheduler-kernel/runtime.js +237 -2
- package/src/lib/scheduler-kernel/source-locator-path.js +142 -0
- package/src/lib/scheduler-kernel/store.js +3957 -248
- package/src/lib/session-host-lease.js +171 -2
- package/src/lib/session-host-snapshot.js +14 -3
- package/src/lib/session-persistence-failure.js +1 -0
- package/src/lib/session-tail.js +179 -34
- package/src/lib/session-transcript-structure.js +96 -0
- package/src/lib/sub-agent-context.js +328 -22
- package/src/lib/ws-agent-handler.js +4 -1
- package/src/repl/agent-repl.js +732 -91
- package/src/repl/chat-repl.js +5 -1
- package/src/runtime/agent-core.js +1282 -207
- package/src/runtime/fallback-model.js +5 -0
- package/src/runtime/headless-runner.js +324 -82
- package/src/runtime/headless-stream.js +232 -26
- package/src/runtime/mcp-config.js +81 -10
- package/src/runtime/policies/agent-policy.js +4 -0
- package/src/workers/background-agent-worker.js +403 -96
- package/src/assets/web-panel/assets/MarkdownRenderer-aMtgN-R6.js +0 -1
- package/src/assets/web-panel/assets/PdhVaultBrowser-DKTf5xIP.js +0 -7
- package/src/assets/web-panel/assets/Projects-Dd-xuPIc.js +0 -1
- package/src/assets/web-panel/assets/SpeechSettings-C7tT9iad.js +0 -1
- package/src/assets/web-panel/assets/devWarning-Jzu62CLC.js +0 -1
- package/src/assets/web-panel/assets/index-Zb2MeDSy.js +0 -1
- package/src/assets/web-panel/assets/index-fikqml4k.js +0 -1
package/src/commands/agent.js
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
import { appendSecurityAuditEvent } from "../lib/security-audit.js";
|
|
25
25
|
import {
|
|
26
26
|
agentPrintArgument,
|
|
27
|
+
BACKGROUND_EPHEMERAL_UNSUPPORTED_CODE,
|
|
27
28
|
canonicalizeBackgroundSessionArgv,
|
|
28
29
|
captureCommandArgvGrammar,
|
|
29
30
|
transformBackgroundLaunchArgv,
|
|
@@ -175,6 +176,52 @@ function readStdin() {
|
|
|
175
176
|
});
|
|
176
177
|
}
|
|
177
178
|
|
|
179
|
+
/** Normalize the three opt-in causal-report scope flags without losing empties. */
|
|
180
|
+
export function resolveAgentObservabilityScope(options = {}) {
|
|
181
|
+
const fields = [
|
|
182
|
+
["observabilityWorkspace", "workspaceId", "--observability-workspace"],
|
|
183
|
+
["observabilityTeam", "teamId", "--observability-team"],
|
|
184
|
+
["observabilityPolicy", "policyId", "--observability-policy"],
|
|
185
|
+
];
|
|
186
|
+
const providedFields = fields.filter(
|
|
187
|
+
([optionName]) => options[optionName] !== undefined,
|
|
188
|
+
);
|
|
189
|
+
if (providedFields.length > 0 && options.forkSession === true) {
|
|
190
|
+
throw new Error(
|
|
191
|
+
"observability scope flags cannot be combined with --fork-session; a fork inherits the source session's immutable observability scope",
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
let provided = false;
|
|
195
|
+
const scope = {};
|
|
196
|
+
for (const [optionName, scopeName, flag] of fields) {
|
|
197
|
+
const value = options[optionName];
|
|
198
|
+
if (value === undefined) {
|
|
199
|
+
scope[scopeName] = null;
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
provided = true;
|
|
203
|
+
if (typeof value !== "string") {
|
|
204
|
+
throw new TypeError(`${flag} requires a non-empty string id`);
|
|
205
|
+
}
|
|
206
|
+
const normalized = value.trim();
|
|
207
|
+
const hasControlCharacter = [...normalized].some((character) => {
|
|
208
|
+
const code = character.codePointAt(0);
|
|
209
|
+
return code <= 0x1f || code === 0x7f;
|
|
210
|
+
});
|
|
211
|
+
if (!normalized || normalized.length > 256 || hasControlCharacter) {
|
|
212
|
+
throw new TypeError(`${flag} requires a valid non-empty id`);
|
|
213
|
+
}
|
|
214
|
+
scope[scopeName] = normalized;
|
|
215
|
+
}
|
|
216
|
+
if (!provided) return undefined;
|
|
217
|
+
if (options.ephemeral === true) {
|
|
218
|
+
throw new Error(
|
|
219
|
+
"observability scope requires durable session persistence and cannot be combined with --ephemeral",
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
return scope;
|
|
223
|
+
}
|
|
224
|
+
|
|
178
225
|
export function registerAgentCommand(program) {
|
|
179
226
|
program
|
|
180
227
|
.command("agent")
|
|
@@ -496,6 +543,18 @@ export function registerAgentCommand(program) {
|
|
|
496
543
|
"--max-budget-usd <amount>",
|
|
497
544
|
"Hard USD spend cap: stop the run before the next paid LLM call once the estimated cost reaches this (headless; uses the cc cost price table)",
|
|
498
545
|
)
|
|
546
|
+
.option(
|
|
547
|
+
"--observability-workspace <id>",
|
|
548
|
+
"Persist a workspace scope on new session authority for causal reports",
|
|
549
|
+
)
|
|
550
|
+
.option(
|
|
551
|
+
"--observability-team <id>",
|
|
552
|
+
"Persist a team scope on new session authority for causal reports",
|
|
553
|
+
)
|
|
554
|
+
.option(
|
|
555
|
+
"--observability-policy <id>",
|
|
556
|
+
"Persist a policy scope on new session authority for causal reports",
|
|
557
|
+
)
|
|
499
558
|
.option(
|
|
500
559
|
"--strict-mcp-config",
|
|
501
560
|
"Use ONLY --mcp-config servers; ignore registered (cc mcp add) and IDE-bridge MCP for a reproducible tool surface",
|
|
@@ -520,6 +579,19 @@ export function registerAgentCommand(program) {
|
|
|
520
579
|
false,
|
|
521
580
|
)
|
|
522
581
|
.action(async (task, options, command) => {
|
|
582
|
+
// Scope is immutable session authority. Resolve every scope/fork
|
|
583
|
+
// conflict before worktree creation, session forking, bootstrap, or any
|
|
584
|
+
// other externally visible setup performed by this action.
|
|
585
|
+
let observabilityScope;
|
|
586
|
+
try {
|
|
587
|
+
observabilityScope = resolveAgentObservabilityScope(options);
|
|
588
|
+
} catch (error) {
|
|
589
|
+
process.stderr.write(`${error.message}\n`);
|
|
590
|
+
process.exitCode = 1;
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
const hasObservabilityScope = observabilityScope !== undefined;
|
|
594
|
+
|
|
523
595
|
// --capabilities: print the machine-readable manifest and exit — no
|
|
524
596
|
// config, no bootstrap, no network (gap-analysis 2026-07-11 快速收益 #6).
|
|
525
597
|
if (options.capabilities) {
|
|
@@ -625,6 +697,15 @@ export function registerAgentCommand(program) {
|
|
|
625
697
|
}
|
|
626
698
|
const backgroundRequested =
|
|
627
699
|
options.background === true || options.bg === true;
|
|
700
|
+
if (backgroundRequested && options.ephemeral === true) {
|
|
701
|
+
const error = new Error(
|
|
702
|
+
"--bg cannot be combined with --ephemeral because background sessions require durable session and interaction authority",
|
|
703
|
+
);
|
|
704
|
+
error.code = BACKGROUND_EPHEMERAL_UNSUPPORTED_CODE;
|
|
705
|
+
process.stderr.write(`${error.message}\n`);
|
|
706
|
+
process.exitCode = 1;
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
628
709
|
const invocationCwd = process.cwd();
|
|
629
710
|
let worktreeDecision = {
|
|
630
711
|
enabled: false,
|
|
@@ -1182,7 +1263,6 @@ export function registerAgentCommand(program) {
|
|
|
1182
1263
|
const { mergePricing } = await import("../lib/llm-pricing.js");
|
|
1183
1264
|
priceTable = mergePricing(loadConfig().llm?.pricing);
|
|
1184
1265
|
}
|
|
1185
|
-
|
|
1186
1266
|
// 鈹€鈹€ Streaming-input mode (--input-format stream-json) 鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€鈹€
|
|
1187
1267
|
// A persistent multi-turn conversation driven by NDJSON user events on
|
|
1188
1268
|
// stdin; output is always NDJSON. Routed before single-prompt handling
|
|
@@ -1248,6 +1328,9 @@ export function registerAgentCommand(program) {
|
|
|
1248
1328
|
maxCostUsd,
|
|
1249
1329
|
priceTable,
|
|
1250
1330
|
chatFn: fallbackChatFn,
|
|
1331
|
+
observabilityScope: hasObservabilityScope
|
|
1332
|
+
? observabilityScope
|
|
1333
|
+
: undefined,
|
|
1251
1334
|
// --json-schema: structured output for stream-INPUT mode. The schema
|
|
1252
1335
|
// is resolved + meta-validated up front, its output contract injected
|
|
1253
1336
|
// into the system prompt, and a per-turn `structured_result` event is
|
|
@@ -1544,6 +1627,9 @@ export function registerAgentCommand(program) {
|
|
|
1544
1627
|
// --max-budget-usd: hard spend cap (+ price table from config llm.pricing)
|
|
1545
1628
|
maxCostUsd,
|
|
1546
1629
|
priceTable,
|
|
1630
|
+
observabilityScope: hasObservabilityScope
|
|
1631
|
+
? observabilityScope
|
|
1632
|
+
: undefined,
|
|
1547
1633
|
// --fallback-model: retry once on a backup model on transient errors
|
|
1548
1634
|
chatFn: fallbackChatFn,
|
|
1549
1635
|
};
|
|
@@ -1701,6 +1787,9 @@ export function registerAgentCommand(program) {
|
|
|
1701
1787
|
// --channels: inbound channel listeners (webhook/telegram) whose
|
|
1702
1788
|
// events become user turns in this session.
|
|
1703
1789
|
channels: options.channels || null,
|
|
1790
|
+
observabilityScope: hasObservabilityScope
|
|
1791
|
+
? observabilityScope
|
|
1792
|
+
: undefined,
|
|
1704
1793
|
});
|
|
1705
1794
|
await runtime.startAgentSession();
|
|
1706
1795
|
// Interactive session ended (REPL closed) — settle the worktree.
|
|
@@ -12,6 +12,14 @@ import {
|
|
|
12
12
|
buildAutomationCenterProjection,
|
|
13
13
|
runAutomationCenterAction,
|
|
14
14
|
} from "../lib/automation-center.js";
|
|
15
|
+
import {
|
|
16
|
+
automationCenterIncidentActionErrorEnvelope,
|
|
17
|
+
runAutomationCenterIncidentAction,
|
|
18
|
+
} from "../lib/automation-center-incidents.js";
|
|
19
|
+
import {
|
|
20
|
+
automationCenterRuntimeActionErrorEnvelope,
|
|
21
|
+
runAutomationCenterRuntimeAction,
|
|
22
|
+
} from "../lib/automation-center-runtime.js";
|
|
15
23
|
import {
|
|
16
24
|
createAutomationCenterRoutine,
|
|
17
25
|
editAutomationCenterRoutine,
|
|
@@ -22,6 +30,7 @@ import { parseJsonOption } from "../lib/parse-json-option.js";
|
|
|
22
30
|
import { AutomationSchedulerBridge } from "../lib/scheduler-kernel/automation-adapter.js";
|
|
23
31
|
import { AutomationEventDispatcher } from "../lib/scheduler-kernel/automation-event-adapter.js";
|
|
24
32
|
import { openSchedulerStore } from "../lib/scheduler-kernel/store.js";
|
|
33
|
+
import { resolveAutomationCenterRuntimeControl } from "../lib/scheduler-kernel/runtime-control-capabilities.js";
|
|
25
34
|
import {
|
|
26
35
|
RoutineSchedulerBridge,
|
|
27
36
|
routineBridgeRunId,
|
|
@@ -288,7 +297,8 @@ export function registerAutomationCommand(program) {
|
|
|
288
297
|
if (
|
|
289
298
|
actionCommand &&
|
|
290
299
|
(actionCommand.name().endsWith("-v2") ||
|
|
291
|
-
actionCommand.name().startsWith("center-routine-")
|
|
300
|
+
actionCommand.name().startsWith("center-routine-") ||
|
|
301
|
+
actionCommand.name() === "center-runtime-action")
|
|
292
302
|
)
|
|
293
303
|
return;
|
|
294
304
|
const db = await _prepare(thisCommand);
|
|
@@ -446,9 +456,13 @@ function _wire(root) {
|
|
|
446
456
|
.option("--json", "Output as JSON")
|
|
447
457
|
.action(async (opts, cmd) => {
|
|
448
458
|
const db = _dbFromCtx(cmd);
|
|
459
|
+
let schedulerStore;
|
|
449
460
|
try {
|
|
461
|
+
schedulerStore = openSchedulerStore();
|
|
450
462
|
const projection = buildAutomationCenterProjection(db, {
|
|
451
463
|
limit: Number(opts.limit),
|
|
464
|
+
schedulerStore,
|
|
465
|
+
runtimeCapabilityForKind: resolveAutomationCenterRuntimeControl,
|
|
452
466
|
});
|
|
453
467
|
if (opts.json) console.log(JSON.stringify(projection, null, 2));
|
|
454
468
|
else {
|
|
@@ -465,6 +479,94 @@ function _wire(root) {
|
|
|
465
479
|
logger.error(e.message);
|
|
466
480
|
process.exitCode = 1;
|
|
467
481
|
} finally {
|
|
482
|
+
schedulerStore?.close();
|
|
483
|
+
await shutdown();
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
root
|
|
488
|
+
.command("center-runtime-action <occurrenceId> <pause|resume>")
|
|
489
|
+
.description("Pause or resume one exact fenced scheduler occurrence")
|
|
490
|
+
.requiredOption(
|
|
491
|
+
"--expected-fence <fence>",
|
|
492
|
+
"Exact scheduler fence shown by center-projection",
|
|
493
|
+
)
|
|
494
|
+
.requiredOption(
|
|
495
|
+
"--expected-control-revision <revision>",
|
|
496
|
+
"Exact runtime-control revision shown by center-projection",
|
|
497
|
+
)
|
|
498
|
+
.option("--json", "Output as JSON")
|
|
499
|
+
.action(async (occurrenceId, action, opts) => {
|
|
500
|
+
let schedulerStore;
|
|
501
|
+
try {
|
|
502
|
+
schedulerStore = openSchedulerStore();
|
|
503
|
+
const result = runAutomationCenterRuntimeAction(schedulerStore, {
|
|
504
|
+
capabilityForKind: resolveAutomationCenterRuntimeControl,
|
|
505
|
+
occurrenceId,
|
|
506
|
+
action,
|
|
507
|
+
expectedFence: Number(opts.expectedFence),
|
|
508
|
+
expectedControlRevision: Number(opts.expectedControlRevision),
|
|
509
|
+
});
|
|
510
|
+
if (opts.json) console.log(JSON.stringify(result, null, 2));
|
|
511
|
+
else logger.success(`${occurrenceId} ${action} completed`);
|
|
512
|
+
} catch (error) {
|
|
513
|
+
if (opts.json) {
|
|
514
|
+
console.log(
|
|
515
|
+
JSON.stringify(
|
|
516
|
+
automationCenterRuntimeActionErrorEnvelope(error, {
|
|
517
|
+
occurrenceId,
|
|
518
|
+
action,
|
|
519
|
+
}),
|
|
520
|
+
null,
|
|
521
|
+
2,
|
|
522
|
+
),
|
|
523
|
+
);
|
|
524
|
+
} else logger.error(error.message);
|
|
525
|
+
process.exitCode = 1;
|
|
526
|
+
} finally {
|
|
527
|
+
schedulerStore?.close();
|
|
528
|
+
await shutdown();
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
root
|
|
533
|
+
.command("center-incident-action <incidentId> <retry|cancel>")
|
|
534
|
+
.description("Retry or cancel a revision-gated Automation Center incident")
|
|
535
|
+
.requiredOption(
|
|
536
|
+
"--expected-revision <revision>",
|
|
537
|
+
"Exact incident revision shown by center-projection",
|
|
538
|
+
)
|
|
539
|
+
.option("--json", "Output as JSON")
|
|
540
|
+
.action(async (incidentId, action, opts, cmd) => {
|
|
541
|
+
const db = _dbFromCtx(cmd);
|
|
542
|
+
let schedulerStore;
|
|
543
|
+
try {
|
|
544
|
+
// Cancellation is incident-local. Retry alone needs the scheduler's
|
|
545
|
+
// dead-letter evidence and owns this short-lived handle.
|
|
546
|
+
if (action === "retry") schedulerStore = openSchedulerStore();
|
|
547
|
+
const result = runAutomationCenterIncidentAction(db, schedulerStore, {
|
|
548
|
+
incidentId,
|
|
549
|
+
action,
|
|
550
|
+
expectedRevision: opts.expectedRevision,
|
|
551
|
+
});
|
|
552
|
+
if (opts.json) console.log(JSON.stringify(result, null, 2));
|
|
553
|
+
else logger.success(`${incidentId} ${action} completed`);
|
|
554
|
+
} catch (error) {
|
|
555
|
+
if (opts.json) {
|
|
556
|
+
console.log(
|
|
557
|
+
JSON.stringify(
|
|
558
|
+
automationCenterIncidentActionErrorEnvelope(error, {
|
|
559
|
+
incidentId,
|
|
560
|
+
action,
|
|
561
|
+
}),
|
|
562
|
+
null,
|
|
563
|
+
2,
|
|
564
|
+
),
|
|
565
|
+
);
|
|
566
|
+
} else logger.error(error.message);
|
|
567
|
+
process.exitCode = 1;
|
|
568
|
+
} finally {
|
|
569
|
+
schedulerStore?.close();
|
|
468
570
|
await shutdown();
|
|
469
571
|
}
|
|
470
572
|
});
|
package/src/commands/chat.js
CHANGED
|
@@ -4,8 +4,16 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { createAgentRuntimeFactory } from "../runtime/runtime-factory.js";
|
|
7
|
+
import { assertChatSessionUsageAdmission } from "../lib/chat-session-admission.js";
|
|
7
8
|
|
|
8
|
-
export
|
|
9
|
+
export { assertChatSessionUsageAdmission } from "../lib/chat-session-admission.js";
|
|
10
|
+
|
|
11
|
+
export function registerChatCommand(program, dependencies = {}) {
|
|
12
|
+
const createRuntimeFactory =
|
|
13
|
+
dependencies.createAgentRuntimeFactory || createAgentRuntimeFactory;
|
|
14
|
+
const assertUsageAdmission =
|
|
15
|
+
dependencies.assertChatSessionUsageAdmission ||
|
|
16
|
+
assertChatSessionUsageAdmission;
|
|
9
17
|
program
|
|
10
18
|
.command("chat")
|
|
11
19
|
.description("Start an interactive AI chat session")
|
|
@@ -22,7 +30,8 @@ export function registerChatCommand(program) {
|
|
|
22
30
|
)
|
|
23
31
|
.option("--session <id>", "Resume a previous session (agent mode)")
|
|
24
32
|
.action(async (options) => {
|
|
25
|
-
|
|
33
|
+
if (!options.agent) assertUsageAdmission(options.session);
|
|
34
|
+
const factory = createRuntimeFactory();
|
|
26
35
|
const runtimeOptions = {
|
|
27
36
|
model: options.model,
|
|
28
37
|
provider: options.provider,
|
package/src/commands/compact.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* cc compact <session-id> compact and persist (writes a `compact`
|
|
7
7
|
* checkpoint event the resume path honors)
|
|
8
|
-
* cc compact <session-id> --dry-run preview
|
|
8
|
+
* cc compact <session-id> --dry-run offline preview; no provider call/write
|
|
9
9
|
*
|
|
10
10
|
* Engine: PromptCompressor with a bounded structured semantic handoff using the
|
|
11
11
|
* session's recorded provider. `--offline` explicitly selects deterministic
|
|
@@ -23,14 +23,17 @@ import chalk from "chalk";
|
|
|
23
23
|
import { logger } from "../lib/logger.js";
|
|
24
24
|
import {
|
|
25
25
|
appendAuthorityEventIfHead,
|
|
26
|
+
appendEventIfHead,
|
|
26
27
|
readVerifiedProjection,
|
|
27
28
|
sessionExists,
|
|
28
29
|
} from "../harness/jsonl-session-store.js";
|
|
29
30
|
import { PromptCompressor } from "../harness/prompt-compressor.js";
|
|
31
|
+
import { compactConversationWithProvider } from "../harness/provider-backed-compaction.js";
|
|
32
|
+
import { runMeteredDirectModelCall } from "../lib/direct-model-usage.js";
|
|
30
33
|
import { chatWithTools } from "../runtime/agent-core.js";
|
|
31
34
|
|
|
32
35
|
/** Build a compressor sized to the session (or explicit overrides). */
|
|
33
|
-
function buildCompressor(options, recorded) {
|
|
36
|
+
function buildCompressor(options, recorded, llmQuery) {
|
|
34
37
|
const maxTokens = options.maxTokens ? Number(options.maxTokens) : undefined;
|
|
35
38
|
const maxMessages = options.maxMessages
|
|
36
39
|
? Number(options.maxMessages)
|
|
@@ -40,7 +43,7 @@ function buildCompressor(options, recorded) {
|
|
|
40
43
|
return new PromptCompressor({
|
|
41
44
|
maxTokens,
|
|
42
45
|
maxMessages,
|
|
43
|
-
llmQuery
|
|
46
|
+
llmQuery,
|
|
44
47
|
});
|
|
45
48
|
}
|
|
46
49
|
const model = options.model || recorded.model || undefined;
|
|
@@ -49,32 +52,89 @@ function buildCompressor(options, recorded) {
|
|
|
49
52
|
return new PromptCompressor({
|
|
50
53
|
model,
|
|
51
54
|
provider,
|
|
52
|
-
llmQuery
|
|
55
|
+
llmQuery,
|
|
53
56
|
});
|
|
54
57
|
}
|
|
55
58
|
|
|
56
|
-
function
|
|
59
|
+
function attachMeteringMetadata(value, { callId, settled }) {
|
|
60
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
61
|
+
try {
|
|
62
|
+
Object.defineProperties(value, {
|
|
63
|
+
compactionCallId: {
|
|
64
|
+
configurable: true,
|
|
65
|
+
value: callId || undefined,
|
|
66
|
+
},
|
|
67
|
+
usageLedgerSettled: {
|
|
68
|
+
configurable: true,
|
|
69
|
+
value: settled === true,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
} catch {
|
|
73
|
+
// A frozen provider error still propagates. The durable started row remains
|
|
74
|
+
// authoritative if its unknown settlement could not be attached here.
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function buildSemanticQuery(options, recorded, sessionId, ledger) {
|
|
57
79
|
const provider = options.provider || recorded.provider || undefined;
|
|
58
80
|
const model = options.model || recorded.model || undefined;
|
|
59
|
-
|
|
81
|
+
// A preview must be both write-free and spend-free. It uses the same
|
|
82
|
+
// deterministic compressor thresholds, but never installs an LLM callback.
|
|
83
|
+
if (options.offline || options.dryRun || !provider) return null;
|
|
60
84
|
const baseUrl =
|
|
61
85
|
options.baseUrl ||
|
|
62
86
|
(provider === "ollama" ? "http://localhost:11434" : undefined);
|
|
63
87
|
return async (prompt) => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
88
|
+
let callId = null;
|
|
89
|
+
try {
|
|
90
|
+
const response = await runMeteredDirectModelCall({
|
|
91
|
+
sessionId,
|
|
92
|
+
provider,
|
|
93
|
+
model,
|
|
94
|
+
source: "semantic-compaction",
|
|
95
|
+
persist: async (type, data) => {
|
|
96
|
+
const appended = appendEventIfHead(
|
|
97
|
+
sessionId,
|
|
98
|
+
type,
|
|
99
|
+
data,
|
|
100
|
+
ledger.headHash,
|
|
101
|
+
);
|
|
102
|
+
ledger.headHash = appended.hash;
|
|
103
|
+
if (type === "model_usage_started") {
|
|
104
|
+
callId = data.callId;
|
|
105
|
+
ledger.callId = callId;
|
|
106
|
+
ledger.started = true;
|
|
107
|
+
} else {
|
|
108
|
+
ledger.settled = true;
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
call: () =>
|
|
112
|
+
chatWithTools([{ role: "user", content: prompt }], {
|
|
113
|
+
provider,
|
|
114
|
+
model,
|
|
115
|
+
baseUrl,
|
|
116
|
+
enabledToolNames: [],
|
|
117
|
+
extraToolDefinitions: [],
|
|
118
|
+
hostManagedToolPolicy: null,
|
|
119
|
+
contextEngine: null,
|
|
120
|
+
maxOutputTokens: 2048,
|
|
121
|
+
}),
|
|
122
|
+
});
|
|
123
|
+
return {
|
|
124
|
+
summary: response?.message?.content || "",
|
|
125
|
+
usage: response?.usage || null,
|
|
126
|
+
provider,
|
|
127
|
+
model,
|
|
128
|
+
callId,
|
|
129
|
+
usageLedgerSettled: true,
|
|
130
|
+
};
|
|
131
|
+
} catch (error) {
|
|
132
|
+
attachMeteringMetadata(error, {
|
|
133
|
+
callId: callId || ledger.callId,
|
|
134
|
+
settled: ledger.settled,
|
|
135
|
+
});
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
78
138
|
};
|
|
79
139
|
}
|
|
80
140
|
|
|
@@ -144,9 +204,32 @@ export function registerCompactCommand(program) {
|
|
|
144
204
|
|
|
145
205
|
const source = readCompactSource(sessionId);
|
|
146
206
|
const messages = source.messages;
|
|
147
|
-
const
|
|
207
|
+
const ledger = {
|
|
208
|
+
headHash: source.headHash,
|
|
209
|
+
callId: null,
|
|
210
|
+
started: false,
|
|
211
|
+
settled: false,
|
|
212
|
+
};
|
|
213
|
+
const llmQuery = buildSemanticQuery(
|
|
214
|
+
options,
|
|
215
|
+
source.recorded,
|
|
216
|
+
sessionId,
|
|
217
|
+
ledger,
|
|
218
|
+
);
|
|
219
|
+
const compressor = buildCompressor(options, source.recorded, llmQuery);
|
|
220
|
+
// llmQuery already persisted a complete call ledger. The provider
|
|
221
|
+
// helper only carries its metadata through stats; its projected usage
|
|
222
|
+
// event is intentionally not appended a second time here.
|
|
148
223
|
const { messages: compacted, stats } =
|
|
149
|
-
await
|
|
224
|
+
await compactConversationWithProvider(messages, {
|
|
225
|
+
compressor,
|
|
226
|
+
provider: options.provider || source.recorded.provider || undefined,
|
|
227
|
+
model: options.model || source.recorded.model || undefined,
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
if (ledger.started && !ledger.settled) {
|
|
231
|
+
throw new Error("semantic compaction usage ledger is unsettled");
|
|
232
|
+
}
|
|
150
233
|
|
|
151
234
|
const reduced = stats.saved > 0 || compacted.length < messages.length;
|
|
152
235
|
|
|
@@ -170,7 +253,7 @@ export function registerCompactCommand(program) {
|
|
|
170
253
|
sessionId,
|
|
171
254
|
"compact",
|
|
172
255
|
{ ...stats, messages: compacted },
|
|
173
|
-
|
|
256
|
+
ledger.headHash,
|
|
174
257
|
);
|
|
175
258
|
}
|
|
176
259
|
|
package/src/commands/loop.js
CHANGED
|
@@ -44,15 +44,20 @@ import {
|
|
|
44
44
|
appendEvent,
|
|
45
45
|
appendEventIfHead,
|
|
46
46
|
readEvents,
|
|
47
|
+
sessionPath,
|
|
47
48
|
sessionExists,
|
|
48
49
|
} from "../harness/jsonl-session-store.js";
|
|
49
50
|
import { openSchedulerStore } from "../lib/scheduler-kernel/store.js";
|
|
50
|
-
import {
|
|
51
|
+
import {
|
|
52
|
+
LoopSchedulerBridge,
|
|
53
|
+
migrateSavedLoopSession,
|
|
54
|
+
} from "../lib/scheduler-kernel/loop-adapter.js";
|
|
51
55
|
|
|
52
56
|
export const _deps = {
|
|
53
57
|
spawn: executionBroker.spawn.bind(executionBroker),
|
|
54
58
|
openSchedulerStore,
|
|
55
59
|
createLoopSchedulerBridge: (options) => new LoopSchedulerBridge(options),
|
|
60
|
+
migrateSavedLoopSession,
|
|
56
61
|
};
|
|
57
62
|
|
|
58
63
|
/**
|
|
@@ -395,7 +400,7 @@ export function registerLoopCommand(program) {
|
|
|
395
400
|
: null,
|
|
396
401
|
{ title: `loop: ${operands.join(" ")}`.slice(0, 80) },
|
|
397
402
|
);
|
|
398
|
-
|
|
403
|
+
savedConfig = {
|
|
399
404
|
execMode,
|
|
400
405
|
operands,
|
|
401
406
|
dynamic,
|
|
@@ -404,7 +409,8 @@ export function registerLoopCommand(program) {
|
|
|
404
409
|
untilExitZero,
|
|
405
410
|
until: untilRaw || null,
|
|
406
411
|
cwd: executionCwd,
|
|
407
|
-
}
|
|
412
|
+
};
|
|
413
|
+
appendEvent(sessionId, "loop_config", savedConfig);
|
|
408
414
|
}
|
|
409
415
|
|
|
410
416
|
// --- SIGINT → graceful stop after the current iteration ---
|
|
@@ -446,15 +452,27 @@ export function registerLoopCommand(program) {
|
|
|
446
452
|
try {
|
|
447
453
|
const executionId = sessionId || `loop-${randomUUID()}`;
|
|
448
454
|
schedulerStore = _deps.openSchedulerStore();
|
|
455
|
+
const definition = {
|
|
456
|
+
executionId,
|
|
457
|
+
cwd: executionCwd,
|
|
458
|
+
execMode,
|
|
459
|
+
operands,
|
|
460
|
+
dynamic,
|
|
461
|
+
};
|
|
462
|
+
if (persist) {
|
|
463
|
+
_deps.migrateSavedLoopSession({
|
|
464
|
+
schedulerStore,
|
|
465
|
+
sessionId,
|
|
466
|
+
config: savedConfig,
|
|
467
|
+
definition,
|
|
468
|
+
readEvents,
|
|
469
|
+
appendEventIfHead,
|
|
470
|
+
sessionFilePath: sessionPath,
|
|
471
|
+
});
|
|
472
|
+
}
|
|
449
473
|
const loopScheduler = _deps.createLoopSchedulerBridge({
|
|
450
474
|
schedulerStore,
|
|
451
|
-
definition
|
|
452
|
-
executionId,
|
|
453
|
-
cwd: executionCwd,
|
|
454
|
-
execMode,
|
|
455
|
-
operands,
|
|
456
|
-
dynamic,
|
|
457
|
-
},
|
|
475
|
+
definition,
|
|
458
476
|
runIteration: async (n, { signal } = {}) => {
|
|
459
477
|
logger.log(chalk.gray(`\n▸ iteration ${n} — ${label}`));
|
|
460
478
|
const t0 = Date.now();
|
package/src/commands/routine.js
CHANGED
|
@@ -345,7 +345,7 @@ export function registerRoutineCommand(program) {
|
|
|
345
345
|
runId,
|
|
346
346
|
});
|
|
347
347
|
}
|
|
348
|
-
for (const r of store.githubRoutines()) {
|
|
348
|
+
for (const r of store.githubRoutines({ schedulerMigration: true })) {
|
|
349
349
|
const github = await bridge.pollGithub(r, {
|
|
350
350
|
fetchEvents: defaultFetchEvents,
|
|
351
351
|
});
|