chainlesschain 0.162.188 → 0.162.193
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/README.md +61 -11
- package/bin/chainlesschain.js +7 -52
- package/completions/_cc +209 -0
- package/completions/cc.bash +18 -0
- package/completions/cc.fish +13 -0
- package/completions/cc.ps1 +226 -0
- package/package.json +10 -2
- package/src/assets/web-panel/assets/{AIOps-Brr1LVcE.js → AIOps-DBLkaTje.js} +1 -1
- package/src/assets/web-panel/assets/{ActionButton-DQU74DKG.js → ActionButton-BAy-Qebo.js} +1 -1
- package/src/assets/web-panel/assets/{Analytics-CYp9178y.js → Analytics-Dfb1Mlau.js} +3 -3
- package/src/assets/web-panel/assets/{AppLayout-DW4SCYsW.js → AppLayout-BbFkN8m0.js} +5 -5
- package/src/assets/web-panel/assets/{Artifacts-CYlD_ed1.js → Artifacts-kM4-cEEH.js} +1 -1
- package/src/assets/web-panel/assets/{Audit-CWl1rZOi.js → Audit-BSQfYWf3.js} +1 -1
- package/src/assets/web-panel/assets/{BackgroundAgents-BOR-LPsa.js → BackgroundAgents-CWDbI_fG.js} +1 -1
- package/src/assets/web-panel/assets/{Backup-DLpG7j1X.js → Backup-BxLPbq_Q.js} +1 -1
- package/src/assets/web-panel/assets/{BaseInput-B35K9wdr.js → BaseInput-DuIbdrp6.js} +1 -1
- package/src/assets/web-panel/assets/{Chat-CwUJb9gB.js → Chat-NEmjGahU.js} +5 -5
- package/src/assets/web-panel/assets/{ChatBubbleRenderer-1v6aMS1m.js → ChatBubbleRenderer-DfJEo-5_.js} +1 -1
- package/src/assets/web-panel/assets/{Checkbox-pi3-tPNW.js → Checkbox-CaoeG3Ns.js} +1 -1
- package/src/assets/web-panel/assets/{Codegen-FyNF35eL.js → Codegen-BFf_g3xY.js} +1 -1
- package/src/assets/web-panel/assets/{Col-tGt_JDEr.js → Col-CNOd8mdQ.js} +1 -1
- package/src/assets/web-panel/assets/{Community-CC7LonQX.js → Community-BhpDqz-i.js} +1 -1
- package/src/assets/web-panel/assets/{Compact-BGXrHHjE.js → Compact-CQ42T7Z6.js} +1 -1
- package/src/assets/web-panel/assets/{Compliance-DSW0TBZ8.js → Compliance-DI5PcLMN.js} +1 -1
- package/src/assets/web-panel/assets/{Cowork-Bhk7rbvE.js → Cowork-wYYZe0wR.js} +3 -3
- package/src/assets/web-panel/assets/{Cron-DxyiQ2NZ.js → Cron-Dlq03DD_.js} +2 -2
- package/src/assets/web-panel/assets/{Crosschain-B2ZkxHok.js → Crosschain-BzqS8PP3.js} +1 -1
- package/src/assets/web-panel/assets/{DID-yOJV99eJ.js → DID-It55Yem7.js} +2 -2
- package/src/assets/web-panel/assets/{Dashboard-CKsttz7D.js → Dashboard-9HkH6oxn.js} +2 -2
- package/src/assets/web-panel/assets/{Dropdown-CVFldXSL.js → Dropdown-00e2YWRB.js} +1 -1
- package/src/assets/web-panel/assets/{EmailListRenderer-Bufv638J.js → EmailListRenderer-By-ugRDL.js} +1 -1
- package/src/assets/web-panel/assets/{FamilyGuardDashboard-4ncjoIjL.js → FamilyGuardDashboard-C396yu5m.js} +1 -1
- package/src/assets/web-panel/assets/{Federation-DsknEDoX.js → Federation-BME5sbZY.js} +1 -1
- package/src/assets/web-panel/assets/{FormItemContext-Cqe5jWXA.js → FormItemContext-B4TEZCr-.js} +1 -1
- package/src/assets/web-panel/assets/{GenericCardRenderer-NAJaFKxc.js → GenericCardRenderer-_9CX9ieY.js} +1 -1
- package/src/assets/web-panel/assets/{Git-CszKQpnl.js → Git-BrS6WVSr.js} +2 -2
- package/src/assets/web-panel/assets/{Governance-BXGodXi6.js → Governance-BMdCWnKF.js} +1 -1
- package/src/assets/web-panel/assets/{Inference-CkoYuG2c.js → Inference-Bcp3vzcA.js} +1 -1
- package/src/assets/web-panel/assets/{KnowledgeGraph-DFlEr_T0.js → KnowledgeGraph-DlLuqGY5.js} +1 -1
- package/src/assets/web-panel/assets/{Logs-CVaENddA.js → Logs-D-W_6x09.js} +2 -2
- package/src/assets/web-panel/assets/MarkdownRenderer-DElGPxCZ.js +1 -0
- package/src/assets/web-panel/assets/{Marketplace-CDlLT0fw.js → Marketplace-Dzn2guvI.js} +1 -1
- package/src/assets/web-panel/assets/{McpTools-DdwOyszN.js → McpTools-uPict-KL.js} +6 -6
- package/src/assets/web-panel/assets/{Memory-DKQnkKuG.js → Memory-BCw43kOb.js} +2 -2
- package/src/assets/web-panel/assets/{MobileBridge-DGseqlzJ.js → MobileBridge-DmV8Wv7F.js} +1 -1
- package/src/assets/web-panel/assets/{MobileProjects-COBbEOlj.js → MobileProjects-C-HaCmSM.js} +1 -1
- package/src/assets/web-panel/assets/{Mtc-O61Vwyli.js → Mtc-C6jxJ34Y.js} +5 -5
- package/src/assets/web-panel/assets/{MtcAudit-Dw2SyasS.js → MtcAudit-Za8ExwhQ.js} +5 -5
- package/src/assets/web-panel/assets/{Multisig-hSu_l8kf.js → Multisig-KKDbuEgb.js} +3 -3
- package/src/assets/web-panel/assets/{NLProgramming-CX1Epurr.js → NLProgramming-Dj97zbCk.js} +1 -1
- package/src/assets/web-panel/assets/{Notes-R9xX8o8_.js → Notes-DBXvMraU.js} +4 -4
- package/src/assets/web-panel/assets/{NotificationSettings-jtSNLCuK.js → NotificationSettings-DOxITLYl.js} +1 -1
- package/src/assets/web-panel/assets/OrderTableRenderer-7DVjZwMM.js +1 -0
- package/src/assets/web-panel/assets/{Organization-Pu2WO-U3.js → Organization-D1i73mjb.js} +4 -4
- package/src/assets/web-panel/assets/{Overflow-BjnqUyFp.js → Overflow-kW6Q3rvg.js} +1 -1
- package/src/assets/web-panel/assets/{P2P-jjkvz44c.js → P2P-C-v_8p2v.js} +2 -2
- package/src/assets/web-panel/assets/PdhVaultBrowser-tUbbY64W.js +7 -0
- package/src/assets/web-panel/assets/{Permissions-D4yDpivd.js → Permissions-DkHxEZ58.js} +4 -4
- package/src/assets/web-panel/assets/{PersonalDataHub-0qsL6iH1.js → PersonalDataHub-DWuMPGrK.js} +5 -5
- package/src/assets/web-panel/assets/{Pipeline-Cx7Ybrk2.js → Pipeline-30IYXWWm.js} +1 -1
- package/src/assets/web-panel/assets/{Privacy-PbfR_M_V.js → Privacy-DZNQ4RrH.js} +1 -1
- package/src/assets/web-panel/assets/{ProjectInit-CyV6Gsub.js → ProjectInit-De2MCElf.js} +2 -2
- package/src/assets/web-panel/assets/{ProjectSettings-C7KZ2Wdk.js → ProjectSettings-5uHk9wsC.js} +2 -2
- package/src/assets/web-panel/assets/{Projects-DQDjO-yK.js → Projects-XjDfrFLb.js} +1 -1
- package/src/assets/web-panel/assets/{Providers-DyFVBBMX.js → Providers-Bgwj6gcE.js} +1 -1
- package/src/assets/web-panel/assets/{QrScannerModal-CzB1BC9_.js → QrScannerModal-gKql9umv.js} +1 -1
- package/src/assets/web-panel/assets/{QuickAsk-Bk636mC1.js → QuickAsk-BWvmwkh7.js} +1 -1
- package/src/assets/web-panel/assets/{Recommend-DoWxHIT3.js → Recommend-Uok4hZPd.js} +1 -1
- package/src/assets/web-panel/assets/{RemoteSession-oOVIv9wq.js → RemoteSession-DLJzTk9a.js} +3 -3
- package/src/assets/web-panel/assets/{Reputation-BucoReGG.js → Reputation-ZVwIPMSO.js} +1 -1
- package/src/assets/web-panel/assets/{Row-DzmOdJU7.js → Row-CN04HxWR.js} +1 -1
- package/src/assets/web-panel/assets/{RssFeed-C1tK7KGU.js → RssFeed-BdSrEG4g.js} +3 -3
- package/src/assets/web-panel/assets/{Search-CSnInOqk.js → Search-5PwVd0IR.js} +1 -1
- package/src/assets/web-panel/assets/{Security-dlejr15l.js → Security-DdBo4zjN.js} +3 -3
- package/src/assets/web-panel/assets/{Services-BioPZuNh.js → Services-D3letU7M.js} +2 -2
- package/src/assets/web-panel/assets/{Skeleton-DWMibwpC.js → Skeleton--Jb83f1v.js} +1 -1
- package/src/assets/web-panel/assets/{Skills-BAAnx1B2.js → Skills-Bg-CulHX.js} +1 -1
- package/src/assets/web-panel/assets/{Sla-jWNp4hNO.js → Sla-7QOa7S-X.js} +1 -1
- package/src/assets/web-panel/assets/{SpeechSettings-y5kqKha-.js → SpeechSettings-DQwppjRw.js} +1 -1
- package/src/assets/web-panel/assets/{SyncSettings-B9GNsc3e.js → SyncSettings-dNPQGL-s.js} +2 -2
- package/src/assets/web-panel/assets/{Tasks-BDBYKRen.js → Tasks-Ggs-Z48q.js} +1 -1
- package/src/assets/web-panel/assets/{Templates-DRiE5eaN.js → Templates-78TYHgRO.js} +1 -1
- package/src/assets/web-panel/assets/{Tenant-BGlAvExF.js → Tenant-xHwwv9vO.js} +1 -1
- package/src/assets/web-panel/assets/{Terminal-B8uzrbNY.js → Terminal-BJXSJfm4.js} +2 -2
- package/src/assets/web-panel/assets/{TimelineRenderer-Df48iveY.js → TimelineRenderer-fLbjRhJw.js} +1 -1
- package/src/assets/web-panel/assets/{Tokens-CcmHndN6.js → Tokens-oMSBSBmB.js} +1 -1
- package/src/assets/web-panel/assets/{Trigger-DPkWxmQ2.js → Trigger-CfnY_wX_.js} +1 -1
- package/src/assets/web-panel/assets/{Trust-DTb5a5AV.js → Trust-AdyTgYKO.js} +1 -1
- package/src/assets/web-panel/assets/{UkeySign-CBmg5vch.js → UkeySign-C5K_81dS.js} +1 -1
- package/src/assets/web-panel/assets/{VideoEditing-B0mZrz4O.js → VideoEditing-vcGVDqki.js} +1 -1
- package/src/assets/web-panel/assets/{Wallet-Bxs7_mpd.js → Wallet-hhOc3hlY.js} +4 -4
- package/src/assets/web-panel/assets/{WebAuthn-C8x3cMxU.js → WebAuthn-CVloC11s.js} +3 -3
- package/src/assets/web-panel/assets/{WorkflowEditor-DPrNznrP.js → WorkflowEditor-CYeE32R5.js} +1 -1
- package/src/assets/web-panel/assets/{chat-D3bYWu7S.js → chat-CNROR5bN.js} +1 -1
- package/src/assets/web-panel/assets/{colors-DY-PwMu4.js → colors-Cjx-cnwU.js} +1 -1
- package/src/assets/web-panel/assets/{compact-item-LDk10Kw6.js → compact-item-DOIfelvD.js} +1 -1
- package/src/assets/web-panel/assets/{createContext-C-2MZnFq.js → createContext-DfA7UZ8u.js} +1 -1
- package/src/assets/web-panel/assets/devWarning-ChcCBGs7.js +1 -0
- package/src/assets/web-panel/assets/{hasIn-BQIBjcnB.js → hasIn-BMSCzcfM.js} +1 -1
- package/src/assets/web-panel/assets/{index-CQVb2dWp.js → index-5-HXgOX5.js} +1 -1
- package/src/assets/web-panel/assets/{index-BdXnYMCZ.js → index-AWg-0M1S.js} +1 -1
- package/src/assets/web-panel/assets/{index-Cx6D_dx2.js → index-B4iYzpkL.js} +1 -1
- package/src/assets/web-panel/assets/{index-_HRO_cIu.js → index-B5Udeb_6.js} +1 -1
- package/src/assets/web-panel/assets/{index-DlRYqt3S.js → index-B7gf77CJ.js} +1 -1
- package/src/assets/web-panel/assets/{index-BrnRO9yE.js → index-BEMwBBHk.js} +1 -1
- package/src/assets/web-panel/assets/{index-VCh5zNJo.js → index-BM1y_9hM.js} +1 -1
- package/src/assets/web-panel/assets/{index-BRI3ngNg.js → index-BUonmKSE.js} +1 -1
- package/src/assets/web-panel/assets/{index-C3GNvExG.js → index-BbQ2eQ8H.js} +1 -1
- package/src/assets/web-panel/assets/{index-DSvo_bp0.js → index-BemJ2u_E.js} +1 -1
- package/src/assets/web-panel/assets/{index-L6qixyLc.js → index-BolaOQxx.js} +1 -1
- package/src/assets/web-panel/assets/{index-BI4KgcYC.js → index-BxOk9vkG.js} +1 -1
- package/src/assets/web-panel/assets/{index-CY4KnaO9.js → index-By61ojUx.js} +1 -1
- package/src/assets/web-panel/assets/{index-L3smcoQX.js → index-C2K9SNVX.js} +1 -1
- package/src/assets/web-panel/assets/{index-BX2b9Orc.js → index-C3L5gdiD.js} +1 -1
- package/src/assets/web-panel/assets/{index-Cz4b6Z_7.js → index-C7xn0Nub.js} +1 -1
- package/src/assets/web-panel/assets/{index-COG61sRv.js → index-CAnvhwg6.js} +1 -1
- package/src/assets/web-panel/assets/{index-C7FC8cP2.js → index-CEKMcOyU.js} +1 -1
- package/src/assets/web-panel/assets/{index-BN-xdSWZ.js → index-CNC5onm4.js} +1 -1
- package/src/assets/web-panel/assets/{index-DY2FIrmz.js → index-CVL27kXC.js} +1 -1
- package/src/assets/web-panel/assets/{index-CiTvBAr-.js → index-CVm1_i3t.js} +1 -1
- package/src/assets/web-panel/assets/{index-DhRt9cYJ.js → index-CdYBye8B.js} +1 -1
- package/src/assets/web-panel/assets/{index-B5pgtZnY.js → index-ClNMrqEY.js} +1 -1
- package/src/assets/web-panel/assets/{index-7xKu7Fns.js → index-Cs6l7uRu.js} +1 -1
- package/src/assets/web-panel/assets/{index-D4K1weKc.js → index-CshQbilz.js} +1 -1
- package/src/assets/web-panel/assets/{index-k7C_oDCO.js → index-Cyweh0Hy.js} +1 -1
- package/src/assets/web-panel/assets/{index-D3Oq-DLL.js → index-DBpWXFed.js} +3 -3
- package/src/assets/web-panel/assets/{index-DYyLJPlF.js → index-DHtpHZAQ.js} +1 -1
- package/src/assets/web-panel/assets/{index-Dh-tkpKQ.js → index-DLmn0BoK.js} +1 -1
- package/src/assets/web-panel/assets/{index-8JC9BJa1.js → index-DPAWBrMf.js} +1 -1
- package/src/assets/web-panel/assets/{index-Dd2Km97U.js → index-DjEsxO5h.js} +1 -1
- package/src/assets/web-panel/assets/{index-KFZO_lcx.js → index-FBc_CJBd.js} +1 -1
- package/src/assets/web-panel/assets/{index-DTIZpPtG.js → index-Icdoqmzt.js} +1 -1
- package/src/assets/web-panel/assets/index-Q2IajL54.js +1 -0
- package/src/assets/web-panel/assets/index-bRkHgOMc.js +1 -0
- package/src/assets/web-panel/assets/{index-lmm9p-jm.js → index-dCd8cSUq.js} +1 -1
- package/src/assets/web-panel/assets/{index-HasPt4-h.js → index-m2vG9gG_.js} +1 -1
- package/src/assets/web-panel/assets/{index-CaslYch6.js → index-mTpHoEzr.js} +1 -1
- package/src/assets/web-panel/assets/{index-CbR6ROOa.js → index-ti_lnTWl.js} +1 -1
- package/src/assets/web-panel/assets/{initDefaultProps-zQPSHf2C.js → initDefaultProps-Bu8k7H1Y.js} +1 -1
- package/src/assets/web-panel/assets/{motion-CKCStGVk.js → motion-s3iVK41k.js} +1 -1
- package/src/assets/web-panel/assets/{move-BufVDGYF.js → move-B6B-E5Jz.js} +1 -1
- package/src/assets/web-panel/assets/{mtc-parser-DcaFxy5D.js → mtc-parser-BiYgTidA.js} +1 -1
- package/src/assets/web-panel/assets/{omit-EScpkGdo.js → omit-pU1RdUDA.js} +1 -1
- package/src/assets/web-panel/assets/{pickAttrs-72hG_qfT.js → pickAttrs-Cdoq_SeM.js} +1 -1
- package/src/assets/web-panel/assets/{placementArrow-CMFWiH20.js → placementArrow-DIuvAn2K.js} +1 -1
- package/src/assets/web-panel/assets/{responsiveObserve-DKQHS41p.js → responsiveObserve-8w16YR2D.js} +1 -1
- package/src/assets/web-panel/assets/{slide-QVAFHTIQ.js → slide-VZ01cZe3.js} +1 -1
- package/src/assets/web-panel/assets/{statusUtils-DIz38e2G.js → statusUtils-lh8YMN8Z.js} +1 -1
- package/src/assets/web-panel/assets/{styleChecker-zK5cyLby.js → styleChecker-CmDyreec.js} +1 -1
- package/src/assets/web-panel/assets/{useFlexGapSupport-DhZngk62.js → useFlexGapSupport-hiJWMU5y.js} +1 -1
- package/src/assets/web-panel/assets/{useFs-BvV2cvkg.js → useFs-Thnu-Iaj.js} +1 -1
- package/src/assets/web-panel/assets/{usePersonalDataHub-CRmxb9l3.js → usePersonalDataHub-LBdOxjwY.js} +1 -1
- package/src/assets/web-panel/assets/{vnode-CgQIbobP.js → vnode-Cg6lFY_X.js} +1 -1
- package/src/assets/web-panel/assets/{zoom-D4XrrO0R.js → zoom-DVfsR1YO.js} +1 -1
- package/src/assets/web-panel/index.html +1 -1
- package/src/cli-help.js +181 -0
- package/src/command-help-index.json +181 -0
- package/src/command-manifest.json +1107 -175
- package/src/command-surface-policy.js +197 -0
- package/src/commands/agent.js +98 -33
- package/src/commands/artifacts.js +400 -2
- package/src/commands/background-session.js +41 -3
- package/src/commands/checkpoint-managed.js +1059 -0
- package/src/commands/checkpoint-restore-recovery.js +1476 -0
- package/src/commands/checkpoint.js +950 -22
- package/src/commands/compact.js +101 -25
- package/src/commands/config.js +506 -20
- package/src/commands/doctor.js +4 -1
- package/src/commands/hub.js +1 -1
- package/src/commands/mcp.js +688 -24
- package/src/commands/pack.js +16 -2
- package/src/commands/plugin.js +20 -12
- package/src/commands/session-mcp-recovery.js +218 -0
- package/src/commands/session.js +470 -110
- package/src/commands/setup.js +36 -10
- package/src/commands/skill.js +181 -110
- package/src/commands/status.js +21 -5
- package/src/commands/team-distributed.js +3324 -0
- package/src/commands/team.js +1130 -74
- package/src/commands/update.js +68 -6
- package/src/constants.js +11 -0
- package/src/data/changelog.json +26 -0
- package/src/gateways/ws/action-protocol.js +10 -0
- package/src/gateways/ws/session-protocol.js +555 -27
- package/src/gateways/ws/ws-agent-handler.js +541 -14
- package/src/gateways/ws/ws-session-gateway.js +129 -22
- package/src/gateways/ws/ws-session-state.js +431 -0
- package/src/harness/background-task-manager.js +233 -36
- package/src/harness/jsonl-session-store.js +2551 -167
- package/src/harness/mcp-client.js +802 -61
- package/src/harness/prompt-compressor.js +227 -27
- package/src/harness/session-index.js +89 -38
- package/src/harness/session-list-index.js +254 -0
- package/src/harness/structured-handoff.js +410 -0
- package/src/lazy-dispatch.js +747 -84
- package/src/lib/__tests__/logger.test.js +50 -2
- package/src/lib/advisor-runtime.js +1047 -0
- package/src/lib/agent-core.js +2 -0
- package/src/lib/agent-sandbox.js +120 -26
- package/src/lib/agent-session-export.js +20 -0
- package/src/lib/agent-team/task-lease.js +271 -3
- package/src/lib/agent-team/team-adjudication.js +1501 -0
- package/src/lib/agent-team/team-budget.js +4 -1
- package/src/lib/agent-team/team-control-store.js +582 -0
- package/src/lib/agent-team/team-distributed-queue.js +5246 -0
- package/src/lib/agent-team/team-process-checkpoint.js +211 -0
- package/src/lib/agent-team/team-runner.js +543 -24
- package/src/lib/agent-team/team-worktree.js +1403 -95
- package/src/lib/artifact-store.js +131 -8
- package/src/lib/background-agent-supervisor.js +185 -13
- package/src/lib/background-interaction-journal.js +37 -9
- package/src/lib/background-launch-profile.js +1058 -0
- package/src/lib/checkpoint-restore-already-completed-controller.js +902 -0
- package/src/lib/checkpoint-restore-orchestrator.js +987 -0
- package/src/lib/checkpoint-restore-partial-rollback-controller.js +1953 -0
- package/src/lib/checkpoint-restore-recovery-controller.js +689 -0
- package/src/lib/checkpoint-restore-recovery.js +884 -0
- package/src/lib/checkpoint-restore-retention.js +126 -0
- package/src/lib/checkpoint-restore-saga.js +5079 -0
- package/src/lib/checkpoint-restore-session-recovery.js +1178 -0
- package/src/lib/checkpoint-restore-workspace-target-verifier.js +270 -0
- package/src/lib/checkpoint-store.js +1688 -97
- package/src/lib/checkpoint-timeline-authority.js +522 -0
- package/src/lib/checkpoint-timeline.js +642 -0
- package/src/lib/config-keys.js +18 -119
- package/src/lib/config-manager.js +446 -27
- package/src/lib/config-redaction.js +57 -0
- package/src/lib/config-schema.js +853 -0
- package/src/lib/cowork-mcp-tools.js +5 -0
- package/src/lib/cowork-task-runner.js +458 -63
- package/src/lib/delivery-coordinator.js +1234 -0
- package/src/lib/delivery-evidence.js +450 -0
- package/src/lib/doctor-checkup.js +199 -14
- package/src/lib/executable-path.js +34 -0
- package/src/lib/fatal-handler.js +16 -0
- package/src/lib/file-checkpoint.js +4909 -186
- package/src/lib/file-lines.js +125 -0
- package/src/lib/headless-config-command.js +16 -5
- package/src/lib/hook-runner.cjs +139 -38
- package/src/lib/hooks-v2-workspace-context.js +10 -0
- package/src/lib/impacted-gate-selector.js +424 -0
- package/src/lib/interaction-adapter.js +62 -0
- package/src/lib/jsonl-session-store.js +1 -35
- package/src/lib/logger.js +66 -14
- package/src/lib/managed-checkpoint-render.js +60 -0
- package/src/lib/managed-tool-checkpoint.js +194 -0
- package/src/lib/mcp-call-ledger-store.js +1069 -0
- package/src/lib/mcp-call-ledger.js +747 -0
- package/src/lib/mcp-client.js +5 -0
- package/src/lib/mcp-conflict-scheduler.js +468 -0
- package/src/lib/mcp-effect-contract.js +102 -0
- package/src/lib/mcp-headers-helper-trust.js +145 -0
- package/src/lib/mcp-headers-helper.js +616 -0
- package/src/lib/mcp-host-recovery-runtime.js +131 -0
- package/src/lib/mcp-ledger-recovery-admission.js +1065 -0
- package/src/lib/mcp-recovery-adjudication.js +443 -0
- package/src/lib/output-context.js +86 -0
- package/src/lib/packer/file-identity.js +170 -0
- package/src/lib/packer/index.js +3 -0
- package/src/lib/packer/native-update-state.js +277 -0
- package/src/lib/packer/pack-update-applier.js +1983 -136
- package/src/lib/packer/pack-update-checker.js +34 -0
- package/src/lib/packer/pack-update-downloader.js +875 -86
- package/src/lib/packer/pack-update-signature.js +86 -0
- package/src/lib/packer/pkg-config-generator.js +6 -0
- package/src/lib/paths.js +65 -10
- package/src/lib/plan-mode.js +831 -14
- package/src/lib/plan-persistence.js +540 -0
- package/src/lib/plugin-runtime/hooks.js +227 -69
- package/src/lib/plugin-runtime/plugin-options.js +189 -44
- package/src/lib/pr-automation-policy.js +146 -8
- package/src/lib/process-execution-broker/credential-agent.js +7 -0
- package/src/lib/process-execution-broker/index.js +491 -13
- package/src/lib/process-execution-broker/linux-generic-bwrap-runtime.js +28 -1
- package/src/lib/process-execution-broker/linux-generic-bwrap.js +28 -4
- package/src/lib/process-execution-broker/platform-sandbox.js +92 -70
- package/src/lib/process-execution-broker/windows-sandbox-helper.dll +0 -0
- package/src/lib/process-execution-broker/windows-sandbox-helper.exe +0 -0
- package/src/lib/process-execution-broker/windows-sandbox.cs +284 -19
- package/src/lib/process-execution-broker/workspace-transaction.js +4459 -0
- package/src/lib/project-instructions.js +165 -29
- package/src/lib/project-mcp-trust.js +67 -0
- package/src/lib/public-ide-capability-manifest.js +272 -0
- package/src/lib/public-ide-capability-validation.js +351 -0
- package/src/lib/secret-store.js +267 -43
- package/src/lib/secure-file-identity.js +433 -0
- package/src/lib/secure-fs.js +1089 -0
- package/src/lib/security-audit.js +58 -0
- package/src/lib/service-manager.js +34 -13
- package/src/lib/session-budget-runtime.js +1452 -0
- package/src/lib/session-host-snapshot.js +388 -0
- package/src/lib/session-message-provenance.js +429 -0
- package/src/lib/session-projection.js +804 -0
- package/src/lib/session-resource-budget.js +1495 -0
- package/src/lib/settings-hooks.cjs +138 -22
- package/src/lib/settings-loader.cjs +25 -2
- package/src/lib/side-effect-ledger-store.js +45 -23
- package/src/lib/skill-execution-identity.js +217 -0
- package/src/lib/skill-loader.js +299 -18
- package/src/lib/sub-agent-context.js +236 -28
- package/src/lib/sub-agent-registry.js +5 -0
- package/src/lib/subagent-contract.js +94 -0
- package/src/lib/todo-manager.js +185 -18
- package/src/lib/todo-persistence.js +417 -0
- package/src/lib/turn-binding-store.js +41 -23
- package/src/lib/turn-binding.js +160 -2
- package/src/lib/with-file-lock.js +165 -24
- package/src/lib/ws-chat-handler.js +21 -0
- package/src/program-base.js +18 -0
- package/src/repl/advisor-command.js +103 -0
- package/src/repl/agent-repl.js +2175 -146
- package/src/repl/btw-command.js +93 -10
- package/src/repl/clipboard-image.js +119 -0
- package/src/repl/config-summary.js +64 -108
- package/src/repl/prompt-editor.js +233 -0
- package/src/repl/prompt-interactions.js +344 -0
- package/src/repl/prompt-stash.js +354 -0
- package/src/repl/prompt-suggestions.js +312 -0
- package/src/repl/repl-keybindings.js +227 -0
- package/src/repl/session-recap.js +217 -0
- package/src/repl/slash-command-registry.js +22 -0
- package/src/repl/terminal-layout.js +88 -0
- package/src/runtime/agent-core.js +1630 -447
- package/src/runtime/coding-agent-contract-shared.cjs +13 -1
- package/src/runtime/coding-agent-managed-tool-policy.cjs +7 -2
- package/src/runtime/diagnostics.js +32 -13
- package/src/runtime/headless-runner.js +310 -118
- package/src/runtime/headless-stream.js +356 -95
- package/src/runtime/mcp-config.js +148 -14
- package/src/runtime/policies/agent-policy.js +14 -0
- package/src/runtime/status-diagnostics-lite.js +137 -0
- package/src/assets/web-panel/assets/MarkdownRenderer-7iWGwZ-r.js +0 -1
- package/src/assets/web-panel/assets/OrderTableRenderer-BU2Yqq5H.js +0 -1
- package/src/assets/web-panel/assets/PdhVaultBrowser-69ca_WeR.js +0 -7
- package/src/assets/web-panel/assets/devWarning-B4dXIJqD.js +0 -1
- package/src/assets/web-panel/assets/index-C-C7DaG6.js +0 -1
- package/src/assets/web-panel/assets/index-DkfWzWtd.js +0 -1
|
@@ -0,0 +1,1058 @@
|
|
|
1
|
+
import {
|
|
2
|
+
existsSync,
|
|
3
|
+
lstatSync,
|
|
4
|
+
readFileSync,
|
|
5
|
+
readdirSync,
|
|
6
|
+
readlinkSync,
|
|
7
|
+
realpathSync,
|
|
8
|
+
} from "node:fs";
|
|
9
|
+
import { createHash } from "node:crypto";
|
|
10
|
+
import { homedir } from "node:os";
|
|
11
|
+
import { dirname, join, parse, resolve } from "node:path";
|
|
12
|
+
import { getConfigPath } from "./paths.js";
|
|
13
|
+
|
|
14
|
+
export const BACKGROUND_LAUNCH_PROFILE_VERSION = 1;
|
|
15
|
+
|
|
16
|
+
const PERMISSION_MODES = new Set([
|
|
17
|
+
"manual",
|
|
18
|
+
"auto",
|
|
19
|
+
"dontAsk",
|
|
20
|
+
"default",
|
|
21
|
+
"plan",
|
|
22
|
+
"acceptEdits",
|
|
23
|
+
"bypassPermissions",
|
|
24
|
+
]);
|
|
25
|
+
const SANDBOX_MODES = new Set(["off", "workspace-write", "strict"]);
|
|
26
|
+
const TRI_STATES = new Set(["auto", "enabled", "disabled"]);
|
|
27
|
+
const PERMISSION_RANK = new Map([
|
|
28
|
+
["plan", 0],
|
|
29
|
+
["manual", 1],
|
|
30
|
+
["default", 1],
|
|
31
|
+
["dontAsk", 2],
|
|
32
|
+
["acceptEdits", 3],
|
|
33
|
+
["auto", 4],
|
|
34
|
+
["bypassPermissions", 5],
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
function scalar(value, max = 1024) {
|
|
38
|
+
if (value === null || value === undefined) return null;
|
|
39
|
+
const text = String(value).trim();
|
|
40
|
+
return text ? text.slice(0, max) : null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function positive(value, integer = false) {
|
|
44
|
+
if (value === null || value === undefined || value === "") return null;
|
|
45
|
+
const number = Number(value);
|
|
46
|
+
if (!Number.isFinite(number) || number <= 0) return null;
|
|
47
|
+
return integer ? Math.floor(number) : number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function sortedStrings(values, { split = false, pathsFrom = null } = {}) {
|
|
51
|
+
const raw = Array.isArray(values) ? values : values ? [values] : [];
|
|
52
|
+
const expanded = split
|
|
53
|
+
? raw.flatMap((value) => String(value).split(/[\s,]+/))
|
|
54
|
+
: raw;
|
|
55
|
+
return [
|
|
56
|
+
...new Set(
|
|
57
|
+
expanded
|
|
58
|
+
.map((value) => scalar(value, 4096))
|
|
59
|
+
.filter(Boolean)
|
|
60
|
+
.map((value) => (pathsFrom ? resolve(pathsFrom, value) : value)),
|
|
61
|
+
),
|
|
62
|
+
].sort();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function orderedStrings(values, { split = false } = {}) {
|
|
66
|
+
const raw = Array.isArray(values) ? values : values ? [values] : [];
|
|
67
|
+
const expanded = split
|
|
68
|
+
? raw.flatMap((value) => String(value).split(/[\s,]+/))
|
|
69
|
+
: raw;
|
|
70
|
+
return [
|
|
71
|
+
...new Set(expanded.map((value) => scalar(value, 4096)).filter(Boolean)),
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function canonicalPath(value, cwd) {
|
|
76
|
+
const absolute = resolve(cwd || process.cwd(), String(value || ""));
|
|
77
|
+
try {
|
|
78
|
+
return realpathSync.native
|
|
79
|
+
? realpathSync.native(absolute)
|
|
80
|
+
: realpathSync(absolute);
|
|
81
|
+
} catch {
|
|
82
|
+
return absolute;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function hashPathEntry(hash, absolute, relative = ".") {
|
|
87
|
+
const stat = lstatSync(absolute);
|
|
88
|
+
if (stat.isSymbolicLink()) {
|
|
89
|
+
hash.update(`link\0${relative}\0${readlinkSync(absolute)}\0`);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (stat.isDirectory()) {
|
|
93
|
+
hash.update(`dir\0${relative}\0`);
|
|
94
|
+
for (const name of readdirSync(absolute).sort()) {
|
|
95
|
+
hashPathEntry(hash, join(absolute, name), `${relative}/${name}`);
|
|
96
|
+
}
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (stat.isFile()) {
|
|
100
|
+
hash.update(`file\0${relative}\0${stat.size}\0`);
|
|
101
|
+
hash.update(readFileSync(absolute));
|
|
102
|
+
hash.update("\0");
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
hash.update(`other\0${relative}\0${stat.mode}\0${stat.size}\0`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Describe a configuration input without storing its contents. The digest is
|
|
110
|
+
* deliberately content-addressed (rather than mtime-addressed), so touching a
|
|
111
|
+
* file does not make a compatible background session impossible to resume.
|
|
112
|
+
*/
|
|
113
|
+
export function describeBackgroundConfigSource(path, options = {}) {
|
|
114
|
+
const absolute = canonicalPath(path, options.cwd);
|
|
115
|
+
if (!existsSync(absolute)) {
|
|
116
|
+
return { path: absolute, kind: "missing", sha256: null };
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
const stat = lstatSync(absolute);
|
|
120
|
+
const kind = stat.isDirectory()
|
|
121
|
+
? "directory"
|
|
122
|
+
: stat.isFile()
|
|
123
|
+
? "file"
|
|
124
|
+
: stat.isSymbolicLink()
|
|
125
|
+
? "symlink"
|
|
126
|
+
: "other";
|
|
127
|
+
const hash = createHash("sha256");
|
|
128
|
+
hashPathEntry(hash, absolute);
|
|
129
|
+
return { path: absolute, kind, sha256: hash.digest("hex") };
|
|
130
|
+
} catch {
|
|
131
|
+
// Never serialize an exception message: filesystem errors can include
|
|
132
|
+
// credential-bearing paths supplied by external configuration.
|
|
133
|
+
return { path: absolute, kind: "unavailable", sha256: null };
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function findAncestorFile(cwd, ...parts) {
|
|
138
|
+
let current = resolve(cwd || process.cwd());
|
|
139
|
+
const root = parse(current).root;
|
|
140
|
+
for (let depth = 0; depth < 64; depth++) {
|
|
141
|
+
const candidate = join(current, ...parts);
|
|
142
|
+
if (existsSync(candidate)) return candidate;
|
|
143
|
+
if (current === root) break;
|
|
144
|
+
const parent = dirname(current);
|
|
145
|
+
if (parent === current) break;
|
|
146
|
+
current = parent;
|
|
147
|
+
}
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function findGitRoot(cwd) {
|
|
152
|
+
const marker = findAncestorFile(cwd, ".git");
|
|
153
|
+
return marker ? dirname(marker) : null;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function sourceList({ cwd, settingsFile, mcpConfig, bundle, projectMcp }) {
|
|
157
|
+
const files = [getConfigPath()];
|
|
158
|
+
const gitRoot = findGitRoot(cwd);
|
|
159
|
+
const projectConfig = findAncestorFile(cwd, ".chainlesschain", "config.json");
|
|
160
|
+
files.push(
|
|
161
|
+
projectConfig || join(gitRoot || cwd, ".chainlesschain", "config.json"),
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
files.push(join(homedir(), ".claude", "settings.json"));
|
|
165
|
+
if (gitRoot && canonicalPath(gitRoot) !== canonicalPath(cwd)) {
|
|
166
|
+
files.push(join(gitRoot, ".claude", "settings.json"));
|
|
167
|
+
files.push(join(gitRoot, ".claude", "settings.local.json"));
|
|
168
|
+
}
|
|
169
|
+
files.push(join(cwd, ".claude", "settings.json"));
|
|
170
|
+
files.push(join(cwd, ".claude", "settings.local.json"));
|
|
171
|
+
if (settingsFile) files.push(resolve(cwd, settingsFile));
|
|
172
|
+
|
|
173
|
+
const managed =
|
|
174
|
+
process.env.CC_MANAGED_SETTINGS ||
|
|
175
|
+
(process.platform === "win32"
|
|
176
|
+
? join(
|
|
177
|
+
process.env.ProgramData ||
|
|
178
|
+
process.env.PROGRAMDATA ||
|
|
179
|
+
"C:\\ProgramData",
|
|
180
|
+
"ChainlessChain",
|
|
181
|
+
"managed-settings.json",
|
|
182
|
+
)
|
|
183
|
+
: "/etc/chainlesschain/managed-settings.json");
|
|
184
|
+
files.push(resolve(managed));
|
|
185
|
+
if (mcpConfig) files.push(resolve(cwd, mcpConfig));
|
|
186
|
+
if (projectMcp) {
|
|
187
|
+
files.push(join(gitRoot || cwd, ".mcp.json"));
|
|
188
|
+
}
|
|
189
|
+
if (bundle) files.push(resolve(cwd, bundle));
|
|
190
|
+
|
|
191
|
+
const unique = [...new Set(files.map((file) => canonicalPath(file)))].sort();
|
|
192
|
+
return unique.map((file) => describeBackgroundConfigSource(file));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** Return a credential-free representation of a base URL. */
|
|
196
|
+
export function sanitizeBackgroundBaseUrl(value) {
|
|
197
|
+
const original = scalar(value, 8192);
|
|
198
|
+
if (!original) return { value: null, redacted: false };
|
|
199
|
+
try {
|
|
200
|
+
const url = new URL(original);
|
|
201
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
202
|
+
return { value: null, redacted: true };
|
|
203
|
+
}
|
|
204
|
+
const redacted = Boolean(
|
|
205
|
+
url.username || url.password || url.search || url.hash,
|
|
206
|
+
);
|
|
207
|
+
url.username = "";
|
|
208
|
+
url.password = "";
|
|
209
|
+
url.search = "";
|
|
210
|
+
url.hash = "";
|
|
211
|
+
return { value: url.toString(), redacted };
|
|
212
|
+
} catch {
|
|
213
|
+
return { value: null, redacted: true };
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function splitLongOption(token) {
|
|
218
|
+
const index = token.indexOf("=");
|
|
219
|
+
return index === -1
|
|
220
|
+
? { name: token, inline: null }
|
|
221
|
+
: { name: token.slice(0, index), inline: token.slice(index + 1) };
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function emptyParsedProfile(cwd, worktree, governance) {
|
|
225
|
+
return {
|
|
226
|
+
version: BACKGROUND_LAUNCH_PROFILE_VERSION,
|
|
227
|
+
command: "agent",
|
|
228
|
+
llm: {
|
|
229
|
+
provider: null,
|
|
230
|
+
model: null,
|
|
231
|
+
baseUrl: null,
|
|
232
|
+
baseUrlRedacted: false,
|
|
233
|
+
visionModel: null,
|
|
234
|
+
fallbackModels: [],
|
|
235
|
+
},
|
|
236
|
+
tools: { allowed: null, disallowed: [] },
|
|
237
|
+
permission: {
|
|
238
|
+
mode: scalar(governance?.permissionMode) || "default",
|
|
239
|
+
dangerousBypass: false,
|
|
240
|
+
unattended: false,
|
|
241
|
+
unattendedAllow: [],
|
|
242
|
+
interactiveApprovals: false,
|
|
243
|
+
promptTool: null,
|
|
244
|
+
remoteControl: false,
|
|
245
|
+
},
|
|
246
|
+
sandbox: { enabled: false, image: null, mode: null, network: false },
|
|
247
|
+
mcp: {
|
|
248
|
+
configFile: null,
|
|
249
|
+
disabled: false,
|
|
250
|
+
strict: false,
|
|
251
|
+
project: false,
|
|
252
|
+
ide: "auto",
|
|
253
|
+
pdh: "auto",
|
|
254
|
+
jetbrains: "auto",
|
|
255
|
+
},
|
|
256
|
+
settings: { file: null },
|
|
257
|
+
plugins: { bundle: null, disabled: false },
|
|
258
|
+
workspace: {
|
|
259
|
+
cwd: canonicalPath(cwd || process.cwd()),
|
|
260
|
+
addDirs: [],
|
|
261
|
+
worktree: worktree
|
|
262
|
+
? {
|
|
263
|
+
repoRoot: canonicalPath(worktree.repoRoot),
|
|
264
|
+
worktreePath: canonicalPath(worktree.worktreePath || worktree.path),
|
|
265
|
+
baseSha: scalar(worktree.baseSha),
|
|
266
|
+
branch: scalar(worktree.branch),
|
|
267
|
+
}
|
|
268
|
+
: null,
|
|
269
|
+
},
|
|
270
|
+
budget: {
|
|
271
|
+
maxTurns: positive(governance?.resourceBudget?.maxTurns, true),
|
|
272
|
+
maxCostUsd: positive(governance?.resourceBudget?.maxCostUsd),
|
|
273
|
+
thinkingTokens: null,
|
|
274
|
+
maxRewakes: null,
|
|
275
|
+
maxOuterTurns: null,
|
|
276
|
+
goalMaxTokens: null,
|
|
277
|
+
goalMaxCostUsd: null,
|
|
278
|
+
goalMaxTimeMs: null,
|
|
279
|
+
},
|
|
280
|
+
runtime: {
|
|
281
|
+
safeMode: false,
|
|
282
|
+
bare: false,
|
|
283
|
+
checkpoint: "default",
|
|
284
|
+
managedCheckpoint: false,
|
|
285
|
+
managedCheckpointState: null,
|
|
286
|
+
managedCheckpointExcludes: [],
|
|
287
|
+
noProjectMemory: false,
|
|
288
|
+
noFileRefs: false,
|
|
289
|
+
noSlashMacros: false,
|
|
290
|
+
noRecallMemory: false,
|
|
291
|
+
noMcpAutoConnect: false,
|
|
292
|
+
outputStyle: null,
|
|
293
|
+
outputFormat: "text",
|
|
294
|
+
inputFormat: "text",
|
|
295
|
+
thinking: null,
|
|
296
|
+
autoRewake: false,
|
|
297
|
+
autoPin: false,
|
|
298
|
+
noStream: false,
|
|
299
|
+
noParkOnExit: false,
|
|
300
|
+
},
|
|
301
|
+
credentials: { apiKey: "default" },
|
|
302
|
+
configuration: { sources: [] },
|
|
303
|
+
omitted: [],
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Capture the effective, resumable CLI envelope while intentionally omitting
|
|
309
|
+
* task/system prompts, API keys, images, trace ids and environment values.
|
|
310
|
+
*/
|
|
311
|
+
export function captureBackgroundLaunchProfile({
|
|
312
|
+
argv = [],
|
|
313
|
+
cwd = process.cwd(),
|
|
314
|
+
worktree = null,
|
|
315
|
+
governance = null,
|
|
316
|
+
} = {}) {
|
|
317
|
+
const profile = emptyParsedProfile(cwd, worktree, governance);
|
|
318
|
+
const omitted = new Set();
|
|
319
|
+
const addDirs = [];
|
|
320
|
+
const fallbackModels = [];
|
|
321
|
+
const managedExcludes = [];
|
|
322
|
+
let settingsFile = null;
|
|
323
|
+
let mcpConfig = null;
|
|
324
|
+
let bundle = null;
|
|
325
|
+
|
|
326
|
+
const args = Array.isArray(argv) ? argv.map(String) : [];
|
|
327
|
+
for (let index = 0; index < args.length; index++) {
|
|
328
|
+
const token = args[index];
|
|
329
|
+
if (token === "agent" || token === "a") continue;
|
|
330
|
+
if (token === "--") {
|
|
331
|
+
if (index + 1 < args.length) omitted.add("taskPrompt");
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
if (token === "-p") {
|
|
335
|
+
omitted.add("taskPrompt");
|
|
336
|
+
if (args[index + 1] && !args[index + 1].startsWith("-")) index++;
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
if (token === "-c") continue;
|
|
340
|
+
if (token === "-y") {
|
|
341
|
+
profile.permission.dangerousBypass = true;
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
if (!token.startsWith("--")) {
|
|
345
|
+
omitted.add("taskPrompt");
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
const { name, inline } = splitLongOption(token);
|
|
350
|
+
const take = (optional = false) => {
|
|
351
|
+
if (inline !== null) return inline;
|
|
352
|
+
const next = args[index + 1];
|
|
353
|
+
if (next === undefined || (optional && next.startsWith("-"))) return null;
|
|
354
|
+
index++;
|
|
355
|
+
return next;
|
|
356
|
+
};
|
|
357
|
+
switch (name) {
|
|
358
|
+
case "--provider":
|
|
359
|
+
profile.llm.provider = scalar(take());
|
|
360
|
+
break;
|
|
361
|
+
case "--model":
|
|
362
|
+
profile.llm.model = scalar(take());
|
|
363
|
+
break;
|
|
364
|
+
case "--base-url": {
|
|
365
|
+
const safe = sanitizeBackgroundBaseUrl(take());
|
|
366
|
+
profile.llm.baseUrl = safe.value;
|
|
367
|
+
profile.llm.baseUrlRedacted = safe.redacted;
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
case "--vision-model":
|
|
371
|
+
profile.llm.visionModel = scalar(take());
|
|
372
|
+
break;
|
|
373
|
+
case "--fallback-model":
|
|
374
|
+
fallbackModels.push(...orderedStrings(take(), { split: true }));
|
|
375
|
+
break;
|
|
376
|
+
case "--allowed-tools":
|
|
377
|
+
profile.tools.allowed = sortedStrings(take(), { split: true });
|
|
378
|
+
break;
|
|
379
|
+
case "--disallowed-tools":
|
|
380
|
+
profile.tools.disallowed = sortedStrings(take(), { split: true });
|
|
381
|
+
break;
|
|
382
|
+
case "--permission-mode": {
|
|
383
|
+
const mode = scalar(take());
|
|
384
|
+
profile.permission.mode = PERMISSION_MODES.has(mode) ? mode : "default";
|
|
385
|
+
break;
|
|
386
|
+
}
|
|
387
|
+
case "--allow-dangerous-bypass":
|
|
388
|
+
case "--dangerously-skip-permissions":
|
|
389
|
+
case "--yolo":
|
|
390
|
+
profile.permission.dangerousBypass = true;
|
|
391
|
+
break;
|
|
392
|
+
case "--unattended":
|
|
393
|
+
profile.permission.unattended = true;
|
|
394
|
+
break;
|
|
395
|
+
case "--unattended-allow":
|
|
396
|
+
profile.permission.unattendedAllow = sortedStrings(take(), {
|
|
397
|
+
split: true,
|
|
398
|
+
});
|
|
399
|
+
break;
|
|
400
|
+
case "--interactive-approvals":
|
|
401
|
+
profile.permission.interactiveApprovals = true;
|
|
402
|
+
break;
|
|
403
|
+
case "--permission-prompt-tool":
|
|
404
|
+
profile.permission.promptTool = scalar(take());
|
|
405
|
+
break;
|
|
406
|
+
case "--remote-control":
|
|
407
|
+
profile.permission.remoteControl = true;
|
|
408
|
+
break;
|
|
409
|
+
case "--sandbox":
|
|
410
|
+
profile.sandbox.enabled = true;
|
|
411
|
+
profile.sandbox.image = scalar(take(true));
|
|
412
|
+
break;
|
|
413
|
+
case "--sandbox-mode": {
|
|
414
|
+
const mode = scalar(take());
|
|
415
|
+
profile.sandbox.mode = SANDBOX_MODES.has(mode) ? mode : null;
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
case "--sandbox-network":
|
|
419
|
+
profile.sandbox.network = true;
|
|
420
|
+
break;
|
|
421
|
+
case "--mcp-config":
|
|
422
|
+
mcpConfig = scalar(take(), 4096);
|
|
423
|
+
break;
|
|
424
|
+
case "--no-mcp":
|
|
425
|
+
profile.mcp.disabled = true;
|
|
426
|
+
profile.runtime.noMcpAutoConnect = true;
|
|
427
|
+
break;
|
|
428
|
+
case "--strict-mcp-config":
|
|
429
|
+
profile.mcp.strict = true;
|
|
430
|
+
break;
|
|
431
|
+
case "--project-mcp":
|
|
432
|
+
profile.mcp.project = true;
|
|
433
|
+
break;
|
|
434
|
+
case "--ide":
|
|
435
|
+
profile.mcp.ide = "enabled";
|
|
436
|
+
break;
|
|
437
|
+
case "--no-ide":
|
|
438
|
+
profile.mcp.ide = "disabled";
|
|
439
|
+
break;
|
|
440
|
+
case "--pdh":
|
|
441
|
+
profile.mcp.pdh = "enabled";
|
|
442
|
+
break;
|
|
443
|
+
case "--no-pdh":
|
|
444
|
+
profile.mcp.pdh = "disabled";
|
|
445
|
+
break;
|
|
446
|
+
case "--jetbrains":
|
|
447
|
+
profile.mcp.jetbrains = "enabled";
|
|
448
|
+
break;
|
|
449
|
+
case "--no-jetbrains":
|
|
450
|
+
profile.mcp.jetbrains = "disabled";
|
|
451
|
+
break;
|
|
452
|
+
case "--settings":
|
|
453
|
+
settingsFile = scalar(take(), 4096);
|
|
454
|
+
break;
|
|
455
|
+
case "--bundle":
|
|
456
|
+
bundle = scalar(take(), 4096);
|
|
457
|
+
break;
|
|
458
|
+
case "--add-dir":
|
|
459
|
+
addDirs.push(take());
|
|
460
|
+
break;
|
|
461
|
+
case "--max-turns":
|
|
462
|
+
profile.budget.maxTurns = positive(take(), true);
|
|
463
|
+
break;
|
|
464
|
+
case "--max-budget-usd":
|
|
465
|
+
profile.budget.maxCostUsd = positive(take());
|
|
466
|
+
break;
|
|
467
|
+
case "--thinking-budget":
|
|
468
|
+
profile.budget.thinkingTokens = positive(take(), true);
|
|
469
|
+
break;
|
|
470
|
+
case "--max-rewakes":
|
|
471
|
+
profile.budget.maxRewakes = positive(take(), true);
|
|
472
|
+
break;
|
|
473
|
+
case "--max-outer-turns":
|
|
474
|
+
profile.budget.maxOuterTurns = positive(take(), true);
|
|
475
|
+
break;
|
|
476
|
+
case "--goal-max-tokens":
|
|
477
|
+
profile.budget.goalMaxTokens = positive(take(), true);
|
|
478
|
+
break;
|
|
479
|
+
case "--goal-max-cost":
|
|
480
|
+
profile.budget.goalMaxCostUsd = positive(take());
|
|
481
|
+
break;
|
|
482
|
+
case "--goal-max-time":
|
|
483
|
+
profile.budget.goalMaxTimeMs = positive(take(), true);
|
|
484
|
+
break;
|
|
485
|
+
case "--safe-mode":
|
|
486
|
+
profile.runtime.safeMode = true;
|
|
487
|
+
break;
|
|
488
|
+
case "--bare":
|
|
489
|
+
profile.runtime.bare = true;
|
|
490
|
+
profile.plugins.disabled = true;
|
|
491
|
+
break;
|
|
492
|
+
case "--checkpoint":
|
|
493
|
+
profile.runtime.checkpoint = "enabled";
|
|
494
|
+
break;
|
|
495
|
+
case "--no-checkpoint":
|
|
496
|
+
profile.runtime.checkpoint = "disabled";
|
|
497
|
+
break;
|
|
498
|
+
case "--managed-checkpoint":
|
|
499
|
+
profile.runtime.managedCheckpoint = true;
|
|
500
|
+
break;
|
|
501
|
+
case "--managed-checkpoint-state":
|
|
502
|
+
profile.runtime.managedCheckpointState = canonicalPath(take(), cwd);
|
|
503
|
+
break;
|
|
504
|
+
case "--managed-checkpoint-exclude":
|
|
505
|
+
managedExcludes.push(take());
|
|
506
|
+
break;
|
|
507
|
+
case "--no-project-memory":
|
|
508
|
+
profile.runtime.noProjectMemory = true;
|
|
509
|
+
break;
|
|
510
|
+
case "--no-file-refs":
|
|
511
|
+
profile.runtime.noFileRefs = true;
|
|
512
|
+
break;
|
|
513
|
+
case "--no-slash-macros":
|
|
514
|
+
profile.runtime.noSlashMacros = true;
|
|
515
|
+
break;
|
|
516
|
+
case "--no-recall-memory":
|
|
517
|
+
profile.runtime.noRecallMemory = true;
|
|
518
|
+
break;
|
|
519
|
+
case "--output-style":
|
|
520
|
+
profile.runtime.outputStyle = scalar(take());
|
|
521
|
+
break;
|
|
522
|
+
case "--output-format":
|
|
523
|
+
profile.runtime.outputFormat = scalar(take()) || "text";
|
|
524
|
+
break;
|
|
525
|
+
case "--input-format":
|
|
526
|
+
profile.runtime.inputFormat = scalar(take()) || "text";
|
|
527
|
+
break;
|
|
528
|
+
case "--think":
|
|
529
|
+
profile.runtime.thinking = scalar(take(true)) || "think";
|
|
530
|
+
break;
|
|
531
|
+
case "--ultrathink":
|
|
532
|
+
profile.runtime.thinking = "ultra";
|
|
533
|
+
break;
|
|
534
|
+
case "--auto-rewake":
|
|
535
|
+
profile.runtime.autoRewake = true;
|
|
536
|
+
break;
|
|
537
|
+
case "--auto-pin":
|
|
538
|
+
profile.runtime.autoPin = true;
|
|
539
|
+
break;
|
|
540
|
+
case "--no-stream":
|
|
541
|
+
profile.runtime.noStream = true;
|
|
542
|
+
break;
|
|
543
|
+
case "--no-park-on-exit":
|
|
544
|
+
profile.runtime.noParkOnExit = true;
|
|
545
|
+
break;
|
|
546
|
+
case "--api-key":
|
|
547
|
+
take();
|
|
548
|
+
profile.credentials.apiKey = "external";
|
|
549
|
+
omitted.add("apiKey");
|
|
550
|
+
break;
|
|
551
|
+
case "--print":
|
|
552
|
+
take(true);
|
|
553
|
+
omitted.add("taskPrompt");
|
|
554
|
+
break;
|
|
555
|
+
case "--system-prompt":
|
|
556
|
+
take();
|
|
557
|
+
omitted.add("systemPrompt");
|
|
558
|
+
break;
|
|
559
|
+
case "--append-system-prompt":
|
|
560
|
+
take();
|
|
561
|
+
omitted.add("appendSystemPrompt");
|
|
562
|
+
break;
|
|
563
|
+
case "--recall-query":
|
|
564
|
+
take();
|
|
565
|
+
omitted.add("recallQuery");
|
|
566
|
+
break;
|
|
567
|
+
case "--image":
|
|
568
|
+
take();
|
|
569
|
+
omitted.add("initialImage");
|
|
570
|
+
break;
|
|
571
|
+
case "--goal-condition":
|
|
572
|
+
take();
|
|
573
|
+
omitted.add("goalCondition");
|
|
574
|
+
break;
|
|
575
|
+
case "--trace-id":
|
|
576
|
+
case "--otlp":
|
|
577
|
+
case "--json-schema":
|
|
578
|
+
case "--channels":
|
|
579
|
+
case "--agent-id":
|
|
580
|
+
case "--recall-limit":
|
|
581
|
+
case "--goal":
|
|
582
|
+
take(name === "--goal");
|
|
583
|
+
omitted.add(name.slice(2));
|
|
584
|
+
break;
|
|
585
|
+
case "--session":
|
|
586
|
+
take();
|
|
587
|
+
break;
|
|
588
|
+
case "--resume":
|
|
589
|
+
take(true);
|
|
590
|
+
break;
|
|
591
|
+
case "--continue":
|
|
592
|
+
case "--fork-session":
|
|
593
|
+
case "--bg":
|
|
594
|
+
case "--background":
|
|
595
|
+
case "--worktree":
|
|
596
|
+
case "--ephemeral":
|
|
597
|
+
case "--capabilities":
|
|
598
|
+
case "--disable-slash-commands":
|
|
599
|
+
case "--ax-screen-reader":
|
|
600
|
+
case "--replay-user-messages":
|
|
601
|
+
case "--include-partial-messages":
|
|
602
|
+
case "--goal-assess":
|
|
603
|
+
case "--otlp-content":
|
|
604
|
+
break;
|
|
605
|
+
default:
|
|
606
|
+
// Unknown flags are never copied into persistent state: a future flag
|
|
607
|
+
// could carry a credential. Record only its option name for diagnosis.
|
|
608
|
+
omitted.add(`option:${name.slice(0, 96)}`);
|
|
609
|
+
break;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
profile.llm.fallbackModels = orderedStrings(fallbackModels);
|
|
614
|
+
profile.workspace.addDirs = sortedStrings(addDirs, {
|
|
615
|
+
pathsFrom: profile.workspace.cwd,
|
|
616
|
+
});
|
|
617
|
+
profile.runtime.managedCheckpointExcludes = sortedStrings(managedExcludes, {
|
|
618
|
+
pathsFrom: profile.workspace.cwd,
|
|
619
|
+
});
|
|
620
|
+
profile.settings.file = settingsFile
|
|
621
|
+
? canonicalPath(settingsFile, profile.workspace.cwd)
|
|
622
|
+
: null;
|
|
623
|
+
profile.mcp.configFile = mcpConfig
|
|
624
|
+
? canonicalPath(mcpConfig, profile.workspace.cwd)
|
|
625
|
+
: null;
|
|
626
|
+
profile.plugins.bundle = bundle
|
|
627
|
+
? canonicalPath(bundle, profile.workspace.cwd)
|
|
628
|
+
: null;
|
|
629
|
+
profile.configuration.sources = sourceList({
|
|
630
|
+
cwd: profile.workspace.cwd,
|
|
631
|
+
settingsFile,
|
|
632
|
+
mcpConfig,
|
|
633
|
+
bundle,
|
|
634
|
+
projectMcp: profile.mcp.project,
|
|
635
|
+
});
|
|
636
|
+
profile.omitted = [...omitted].sort();
|
|
637
|
+
return normalizeBackgroundLaunchProfile(profile);
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
function normalizeSource(source) {
|
|
641
|
+
const path = scalar(source?.path, 8192);
|
|
642
|
+
if (!path) return null;
|
|
643
|
+
const kind = new Set([
|
|
644
|
+
"missing",
|
|
645
|
+
"file",
|
|
646
|
+
"directory",
|
|
647
|
+
"symlink",
|
|
648
|
+
"other",
|
|
649
|
+
"unavailable",
|
|
650
|
+
]).has(source?.kind)
|
|
651
|
+
? source.kind
|
|
652
|
+
: "unavailable";
|
|
653
|
+
const sha256 = /^[a-f0-9]{64}$/.test(String(source?.sha256 || ""))
|
|
654
|
+
? String(source.sha256)
|
|
655
|
+
: null;
|
|
656
|
+
return { path: canonicalPath(path), kind, sha256 };
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
/** Whitelist and normalize a profile supplied across an API boundary. */
|
|
660
|
+
export function normalizeBackgroundLaunchProfile(input) {
|
|
661
|
+
if (!input || Number(input.version) !== BACKGROUND_LAUNCH_PROFILE_VERSION) {
|
|
662
|
+
throw new Error(
|
|
663
|
+
`Unsupported background launch profile version: ${input?.version ?? "missing"}`,
|
|
664
|
+
);
|
|
665
|
+
}
|
|
666
|
+
const cwd = canonicalPath(input.workspace?.cwd || process.cwd());
|
|
667
|
+
const safeBase = sanitizeBackgroundBaseUrl(input.llm?.baseUrl);
|
|
668
|
+
const permissionMode = PERMISSION_MODES.has(input.permission?.mode)
|
|
669
|
+
? input.permission.mode
|
|
670
|
+
: "default";
|
|
671
|
+
const sandboxMode = SANDBOX_MODES.has(input.sandbox?.mode)
|
|
672
|
+
? input.sandbox.mode
|
|
673
|
+
: null;
|
|
674
|
+
const tri = (value) => (TRI_STATES.has(value) ? value : "auto");
|
|
675
|
+
const pathOrNull = (value) =>
|
|
676
|
+
value ? canonicalPath(scalar(value, 8192), cwd) : null;
|
|
677
|
+
const sources = (
|
|
678
|
+
Array.isArray(input.configuration?.sources)
|
|
679
|
+
? input.configuration.sources
|
|
680
|
+
: []
|
|
681
|
+
)
|
|
682
|
+
.map(normalizeSource)
|
|
683
|
+
.filter(Boolean)
|
|
684
|
+
.sort((a, b) => a.path.localeCompare(b.path));
|
|
685
|
+
return {
|
|
686
|
+
version: BACKGROUND_LAUNCH_PROFILE_VERSION,
|
|
687
|
+
command: "agent",
|
|
688
|
+
llm: {
|
|
689
|
+
provider: scalar(input.llm?.provider),
|
|
690
|
+
model: scalar(input.llm?.model),
|
|
691
|
+
baseUrl: safeBase.value,
|
|
692
|
+
baseUrlRedacted: input.llm?.baseUrlRedacted === true || safeBase.redacted,
|
|
693
|
+
visionModel: scalar(input.llm?.visionModel),
|
|
694
|
+
fallbackModels: orderedStrings(input.llm?.fallbackModels),
|
|
695
|
+
},
|
|
696
|
+
tools: {
|
|
697
|
+
allowed: Array.isArray(input.tools?.allowed)
|
|
698
|
+
? sortedStrings(input.tools.allowed)
|
|
699
|
+
: null,
|
|
700
|
+
disallowed: sortedStrings(input.tools?.disallowed),
|
|
701
|
+
},
|
|
702
|
+
permission: {
|
|
703
|
+
mode: permissionMode,
|
|
704
|
+
dangerousBypass: input.permission?.dangerousBypass === true,
|
|
705
|
+
unattended: input.permission?.unattended === true,
|
|
706
|
+
unattendedAllow: sortedStrings(input.permission?.unattendedAllow),
|
|
707
|
+
interactiveApprovals: input.permission?.interactiveApprovals === true,
|
|
708
|
+
promptTool: scalar(input.permission?.promptTool),
|
|
709
|
+
remoteControl: input.permission?.remoteControl === true,
|
|
710
|
+
},
|
|
711
|
+
sandbox: {
|
|
712
|
+
enabled: input.sandbox?.enabled === true,
|
|
713
|
+
image: scalar(input.sandbox?.image),
|
|
714
|
+
mode: sandboxMode,
|
|
715
|
+
network: input.sandbox?.network === true,
|
|
716
|
+
},
|
|
717
|
+
mcp: {
|
|
718
|
+
configFile: pathOrNull(input.mcp?.configFile),
|
|
719
|
+
disabled: input.mcp?.disabled === true,
|
|
720
|
+
strict: input.mcp?.strict === true,
|
|
721
|
+
project: input.mcp?.project === true,
|
|
722
|
+
ide: tri(input.mcp?.ide),
|
|
723
|
+
pdh: tri(input.mcp?.pdh),
|
|
724
|
+
jetbrains: tri(input.mcp?.jetbrains),
|
|
725
|
+
},
|
|
726
|
+
settings: { file: pathOrNull(input.settings?.file) },
|
|
727
|
+
plugins: {
|
|
728
|
+
bundle: pathOrNull(input.plugins?.bundle),
|
|
729
|
+
disabled: input.plugins?.disabled === true,
|
|
730
|
+
},
|
|
731
|
+
workspace: {
|
|
732
|
+
cwd,
|
|
733
|
+
addDirs: sortedStrings(input.workspace?.addDirs, { pathsFrom: cwd }),
|
|
734
|
+
worktree: input.workspace?.worktree
|
|
735
|
+
? {
|
|
736
|
+
repoRoot: pathOrNull(input.workspace.worktree.repoRoot),
|
|
737
|
+
worktreePath: pathOrNull(input.workspace.worktree.worktreePath),
|
|
738
|
+
baseSha: scalar(input.workspace.worktree.baseSha),
|
|
739
|
+
branch: scalar(input.workspace.worktree.branch),
|
|
740
|
+
}
|
|
741
|
+
: null,
|
|
742
|
+
},
|
|
743
|
+
budget: {
|
|
744
|
+
maxTurns: positive(input.budget?.maxTurns, true),
|
|
745
|
+
maxCostUsd: positive(input.budget?.maxCostUsd),
|
|
746
|
+
thinkingTokens: positive(input.budget?.thinkingTokens, true),
|
|
747
|
+
maxRewakes: positive(input.budget?.maxRewakes, true),
|
|
748
|
+
maxOuterTurns: positive(input.budget?.maxOuterTurns, true),
|
|
749
|
+
goalMaxTokens: positive(input.budget?.goalMaxTokens, true),
|
|
750
|
+
goalMaxCostUsd: positive(input.budget?.goalMaxCostUsd),
|
|
751
|
+
goalMaxTimeMs: positive(input.budget?.goalMaxTimeMs, true),
|
|
752
|
+
},
|
|
753
|
+
runtime: {
|
|
754
|
+
safeMode: input.runtime?.safeMode === true,
|
|
755
|
+
bare: input.runtime?.bare === true,
|
|
756
|
+
checkpoint: new Set(["default", "enabled", "disabled"]).has(
|
|
757
|
+
input.runtime?.checkpoint,
|
|
758
|
+
)
|
|
759
|
+
? input.runtime.checkpoint
|
|
760
|
+
: "default",
|
|
761
|
+
managedCheckpoint: input.runtime?.managedCheckpoint === true,
|
|
762
|
+
managedCheckpointState: pathOrNull(input.runtime?.managedCheckpointState),
|
|
763
|
+
managedCheckpointExcludes: sortedStrings(
|
|
764
|
+
input.runtime?.managedCheckpointExcludes,
|
|
765
|
+
{ pathsFrom: cwd },
|
|
766
|
+
),
|
|
767
|
+
noProjectMemory: input.runtime?.noProjectMemory === true,
|
|
768
|
+
noFileRefs: input.runtime?.noFileRefs === true,
|
|
769
|
+
noSlashMacros: input.runtime?.noSlashMacros === true,
|
|
770
|
+
noRecallMemory: input.runtime?.noRecallMemory === true,
|
|
771
|
+
noMcpAutoConnect: input.runtime?.noMcpAutoConnect === true,
|
|
772
|
+
outputStyle: scalar(input.runtime?.outputStyle),
|
|
773
|
+
outputFormat: scalar(input.runtime?.outputFormat) || "text",
|
|
774
|
+
inputFormat: scalar(input.runtime?.inputFormat) || "text",
|
|
775
|
+
thinking: scalar(input.runtime?.thinking),
|
|
776
|
+
autoRewake: input.runtime?.autoRewake === true,
|
|
777
|
+
autoPin: input.runtime?.autoPin === true,
|
|
778
|
+
noStream: input.runtime?.noStream === true,
|
|
779
|
+
noParkOnExit: input.runtime?.noParkOnExit === true,
|
|
780
|
+
},
|
|
781
|
+
credentials: {
|
|
782
|
+
apiKey: input.credentials?.apiKey === "external" ? "external" : "default",
|
|
783
|
+
},
|
|
784
|
+
configuration: { sources },
|
|
785
|
+
omitted: sortedStrings(input.omitted),
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
function canonicalValue(value) {
|
|
790
|
+
if (Array.isArray(value)) return value.map(canonicalValue);
|
|
791
|
+
if (value && typeof value === "object") {
|
|
792
|
+
return Object.fromEntries(
|
|
793
|
+
Object.keys(value)
|
|
794
|
+
.sort()
|
|
795
|
+
.map((key) => [key, canonicalValue(value[key])]),
|
|
796
|
+
);
|
|
797
|
+
}
|
|
798
|
+
return value;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
export function canonicalBackgroundLaunchProfileJson(profile) {
|
|
802
|
+
return JSON.stringify(
|
|
803
|
+
canonicalValue(normalizeBackgroundLaunchProfile(profile)),
|
|
804
|
+
);
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
export function fingerprintBackgroundLaunchProfile(profile) {
|
|
808
|
+
return createHash("sha256")
|
|
809
|
+
.update(canonicalBackgroundLaunchProfileJson(profile))
|
|
810
|
+
.digest("hex");
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
export function refreshBackgroundLaunchProfileSources(profile) {
|
|
814
|
+
const normalized = normalizeBackgroundLaunchProfile(profile);
|
|
815
|
+
return normalizeBackgroundLaunchProfile({
|
|
816
|
+
...normalized,
|
|
817
|
+
configuration: {
|
|
818
|
+
sources: normalized.configuration.sources.map((source) =>
|
|
819
|
+
describeBackgroundConfigSource(source.path),
|
|
820
|
+
),
|
|
821
|
+
},
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
export function verifyBackgroundLaunchProfileSources(profile) {
|
|
826
|
+
const normalized = normalizeBackgroundLaunchProfile(profile);
|
|
827
|
+
const refreshed = refreshBackgroundLaunchProfileSources(normalized);
|
|
828
|
+
const issues = [];
|
|
829
|
+
for (
|
|
830
|
+
let index = 0;
|
|
831
|
+
index < normalized.configuration.sources.length;
|
|
832
|
+
index++
|
|
833
|
+
) {
|
|
834
|
+
const before = normalized.configuration.sources[index];
|
|
835
|
+
const after = refreshed.configuration.sources[index];
|
|
836
|
+
if (before.kind === "unavailable" || after.kind === "unavailable") {
|
|
837
|
+
issues.push(`configuration-source-unverifiable:${before.path}`);
|
|
838
|
+
} else if (
|
|
839
|
+
before.path !== after.path ||
|
|
840
|
+
before.kind !== after.kind ||
|
|
841
|
+
before.sha256 !== after.sha256
|
|
842
|
+
) {
|
|
843
|
+
issues.push(`configuration-source-changed:${before.path}`);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
if (normalized.llm.baseUrlRedacted) issues.push("base-url-redacted");
|
|
847
|
+
return { valid: issues.length === 0, issues, profile: refreshed };
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
function same(a, b) {
|
|
851
|
+
return (
|
|
852
|
+
JSON.stringify(canonicalValue(a)) === JSON.stringify(canonicalValue(b))
|
|
853
|
+
);
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
function isBudgetLooser(before, after) {
|
|
857
|
+
if (before === null) return false;
|
|
858
|
+
return after === null || Number(after) > Number(before);
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
function isToolPolicyLooser(before, after) {
|
|
862
|
+
if (
|
|
863
|
+
Array.isArray(before.allowed) &&
|
|
864
|
+
(after.allowed === null ||
|
|
865
|
+
after.allowed.some((tool) => !before.allowed.includes(tool)))
|
|
866
|
+
) {
|
|
867
|
+
return true;
|
|
868
|
+
}
|
|
869
|
+
return before.disallowed.some((tool) => !after.disallowed.includes(tool));
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
function sandboxRank(sandbox) {
|
|
873
|
+
if (sandbox.mode === "strict") return 0;
|
|
874
|
+
if (sandbox.mode === "workspace-write") return 1;
|
|
875
|
+
if (sandbox.mode === "off") return 3;
|
|
876
|
+
if (sandbox.enabled) return 0;
|
|
877
|
+
return 2;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
/** Explain why a proposed profile cannot silently replace the persisted one. */
|
|
881
|
+
export function assessBackgroundLaunchProfileCompatibility(original, proposed) {
|
|
882
|
+
const before = normalizeBackgroundLaunchProfile(original);
|
|
883
|
+
const after = normalizeBackgroundLaunchProfile(proposed);
|
|
884
|
+
if (
|
|
885
|
+
fingerprintBackgroundLaunchProfile(before) ===
|
|
886
|
+
fingerprintBackgroundLaunchProfile(after)
|
|
887
|
+
) {
|
|
888
|
+
return { compatible: true, reasons: [] };
|
|
889
|
+
}
|
|
890
|
+
const reasons = new Set();
|
|
891
|
+
if (before.llm.provider !== after.llm.provider)
|
|
892
|
+
reasons.add("provider-changed");
|
|
893
|
+
if (before.llm.model !== after.llm.model) reasons.add("model-changed");
|
|
894
|
+
if (before.llm.baseUrl !== after.llm.baseUrl) reasons.add("base-url-changed");
|
|
895
|
+
if (before.permission.mode !== after.permission.mode) {
|
|
896
|
+
reasons.add(
|
|
897
|
+
(PERMISSION_RANK.get(after.permission.mode) ?? 99) >
|
|
898
|
+
(PERMISSION_RANK.get(before.permission.mode) ?? 99)
|
|
899
|
+
? "permission-mode-loosened"
|
|
900
|
+
: "permission-mode-changed",
|
|
901
|
+
);
|
|
902
|
+
}
|
|
903
|
+
if (!before.permission.dangerousBypass && after.permission.dangerousBypass) {
|
|
904
|
+
reasons.add("permission-bypass-enabled");
|
|
905
|
+
}
|
|
906
|
+
if (!same(before.tools, after.tools)) {
|
|
907
|
+
reasons.add(
|
|
908
|
+
isToolPolicyLooser(before.tools, after.tools)
|
|
909
|
+
? "tool-policy-loosened"
|
|
910
|
+
: "tool-policy-changed",
|
|
911
|
+
);
|
|
912
|
+
}
|
|
913
|
+
if (!same(before.sandbox, after.sandbox)) {
|
|
914
|
+
reasons.add(
|
|
915
|
+
sandboxRank(after.sandbox) > sandboxRank(before.sandbox) ||
|
|
916
|
+
(!before.sandbox.network && after.sandbox.network)
|
|
917
|
+
? "sandbox-loosened"
|
|
918
|
+
: "sandbox-changed",
|
|
919
|
+
);
|
|
920
|
+
}
|
|
921
|
+
if (!same(before.mcp, after.mcp)) reasons.add("mcp-changed");
|
|
922
|
+
if (!same(before.settings, after.settings)) reasons.add("settings-changed");
|
|
923
|
+
if (!same(before.plugins, after.plugins)) reasons.add("plugin-changed");
|
|
924
|
+
if (!same(before.workspace, after.workspace))
|
|
925
|
+
reasons.add("workspace-changed");
|
|
926
|
+
if (!same(before.configuration, after.configuration)) {
|
|
927
|
+
reasons.add("configuration-changed");
|
|
928
|
+
}
|
|
929
|
+
if (
|
|
930
|
+
Object.keys(before.budget).some((key) =>
|
|
931
|
+
isBudgetLooser(before.budget[key], after.budget[key]),
|
|
932
|
+
)
|
|
933
|
+
) {
|
|
934
|
+
reasons.add("budget-loosened");
|
|
935
|
+
} else if (!same(before.budget, after.budget)) {
|
|
936
|
+
reasons.add("budget-changed");
|
|
937
|
+
}
|
|
938
|
+
if (!same(before.runtime, after.runtime)) reasons.add("runtime-changed");
|
|
939
|
+
if (!same(before.omitted, after.omitted)) reasons.add("redactions-changed");
|
|
940
|
+
if (reasons.size === 0) reasons.add("launch-profile-changed");
|
|
941
|
+
return { compatible: false, reasons: [...reasons].sort() };
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
function pushValue(argv, flag, value) {
|
|
945
|
+
if (value !== null && value !== undefined && value !== "") {
|
|
946
|
+
argv.push(flag, String(value));
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
function pushFlag(argv, flag, enabled) {
|
|
951
|
+
if (enabled) argv.push(flag);
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
/** Reconstruct a prompt-free argv template from a persisted profile. */
|
|
955
|
+
export function buildArgvFromBackgroundLaunchProfile(profile) {
|
|
956
|
+
const p = normalizeBackgroundLaunchProfile(profile);
|
|
957
|
+
const argv = ["agent"];
|
|
958
|
+
pushValue(argv, "--provider", p.llm.provider);
|
|
959
|
+
pushValue(argv, "--model", p.llm.model);
|
|
960
|
+
pushValue(argv, "--base-url", p.llm.baseUrl);
|
|
961
|
+
pushValue(argv, "--vision-model", p.llm.visionModel);
|
|
962
|
+
for (const model of p.llm.fallbackModels) {
|
|
963
|
+
pushValue(argv, "--fallback-model", model);
|
|
964
|
+
}
|
|
965
|
+
if (p.tools.allowed !== null) {
|
|
966
|
+
pushValue(argv, "--allowed-tools", p.tools.allowed.join(","));
|
|
967
|
+
}
|
|
968
|
+
pushValue(argv, "--disallowed-tools", p.tools.disallowed.join(","));
|
|
969
|
+
pushValue(argv, "--permission-mode", p.permission.mode);
|
|
970
|
+
pushFlag(argv, "--allow-dangerous-bypass", p.permission.dangerousBypass);
|
|
971
|
+
pushFlag(argv, "--unattended", p.permission.unattended);
|
|
972
|
+
pushValue(argv, "--unattended-allow", p.permission.unattendedAllow.join(","));
|
|
973
|
+
pushFlag(argv, "--interactive-approvals", p.permission.interactiveApprovals);
|
|
974
|
+
pushValue(argv, "--permission-prompt-tool", p.permission.promptTool);
|
|
975
|
+
pushFlag(argv, "--remote-control", p.permission.remoteControl);
|
|
976
|
+
if (p.sandbox.enabled) {
|
|
977
|
+
argv.push("--sandbox");
|
|
978
|
+
if (p.sandbox.image) argv.push(p.sandbox.image);
|
|
979
|
+
}
|
|
980
|
+
pushValue(argv, "--sandbox-mode", p.sandbox.mode);
|
|
981
|
+
pushFlag(argv, "--sandbox-network", p.sandbox.network);
|
|
982
|
+
pushValue(argv, "--mcp-config", p.mcp.configFile);
|
|
983
|
+
pushFlag(argv, "--no-mcp", p.mcp.disabled);
|
|
984
|
+
pushFlag(argv, "--strict-mcp-config", p.mcp.strict);
|
|
985
|
+
pushFlag(argv, "--project-mcp", p.mcp.project);
|
|
986
|
+
for (const [key, value] of [
|
|
987
|
+
["ide", p.mcp.ide],
|
|
988
|
+
["pdh", p.mcp.pdh],
|
|
989
|
+
["jetbrains", p.mcp.jetbrains],
|
|
990
|
+
]) {
|
|
991
|
+
if (value === "enabled") argv.push(`--${key}`);
|
|
992
|
+
if (value === "disabled") argv.push(`--no-${key}`);
|
|
993
|
+
}
|
|
994
|
+
pushValue(argv, "--settings", p.settings.file);
|
|
995
|
+
pushValue(argv, "--bundle", p.plugins.bundle);
|
|
996
|
+
for (const dir of p.workspace.addDirs) pushValue(argv, "--add-dir", dir);
|
|
997
|
+
pushValue(argv, "--max-turns", p.budget.maxTurns);
|
|
998
|
+
pushValue(argv, "--max-budget-usd", p.budget.maxCostUsd);
|
|
999
|
+
pushValue(argv, "--thinking-budget", p.budget.thinkingTokens);
|
|
1000
|
+
pushValue(argv, "--max-rewakes", p.budget.maxRewakes);
|
|
1001
|
+
pushValue(argv, "--max-outer-turns", p.budget.maxOuterTurns);
|
|
1002
|
+
pushValue(argv, "--goal-max-tokens", p.budget.goalMaxTokens);
|
|
1003
|
+
pushValue(argv, "--goal-max-cost", p.budget.goalMaxCostUsd);
|
|
1004
|
+
pushValue(argv, "--goal-max-time", p.budget.goalMaxTimeMs);
|
|
1005
|
+
pushFlag(argv, "--safe-mode", p.runtime.safeMode);
|
|
1006
|
+
pushFlag(argv, "--bare", p.runtime.bare);
|
|
1007
|
+
pushFlag(argv, "--checkpoint", p.runtime.checkpoint === "enabled");
|
|
1008
|
+
pushFlag(argv, "--no-checkpoint", p.runtime.checkpoint === "disabled");
|
|
1009
|
+
pushFlag(argv, "--managed-checkpoint", p.runtime.managedCheckpoint);
|
|
1010
|
+
pushValue(
|
|
1011
|
+
argv,
|
|
1012
|
+
"--managed-checkpoint-state",
|
|
1013
|
+
p.runtime.managedCheckpointState,
|
|
1014
|
+
);
|
|
1015
|
+
for (const excluded of p.runtime.managedCheckpointExcludes) {
|
|
1016
|
+
pushValue(argv, "--managed-checkpoint-exclude", excluded);
|
|
1017
|
+
}
|
|
1018
|
+
pushFlag(argv, "--no-project-memory", p.runtime.noProjectMemory);
|
|
1019
|
+
pushFlag(argv, "--no-file-refs", p.runtime.noFileRefs);
|
|
1020
|
+
pushFlag(argv, "--no-slash-macros", p.runtime.noSlashMacros);
|
|
1021
|
+
pushFlag(argv, "--no-recall-memory", p.runtime.noRecallMemory);
|
|
1022
|
+
pushValue(argv, "--output-style", p.runtime.outputStyle);
|
|
1023
|
+
pushValue(argv, "--output-format", p.runtime.outputFormat);
|
|
1024
|
+
pushValue(argv, "--input-format", p.runtime.inputFormat);
|
|
1025
|
+
if (p.runtime.thinking) {
|
|
1026
|
+
pushValue(argv, "--think", p.runtime.thinking);
|
|
1027
|
+
}
|
|
1028
|
+
pushFlag(argv, "--auto-rewake", p.runtime.autoRewake);
|
|
1029
|
+
pushFlag(argv, "--auto-pin", p.runtime.autoPin);
|
|
1030
|
+
pushFlag(argv, "--no-stream", p.runtime.noStream);
|
|
1031
|
+
pushFlag(argv, "--no-park-on-exit", p.runtime.noParkOnExit);
|
|
1032
|
+
return argv;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
/** Remove API key flags before argv is serialized into the transient job. */
|
|
1036
|
+
export function stripBackgroundLaunchSecrets(argv) {
|
|
1037
|
+
const clean = [];
|
|
1038
|
+
let apiKey = null;
|
|
1039
|
+
const args = Array.isArray(argv) ? argv.map(String) : [];
|
|
1040
|
+
for (let index = 0; index < args.length; index++) {
|
|
1041
|
+
const token = args[index];
|
|
1042
|
+
if (token === "--") {
|
|
1043
|
+
clean.push(...args.slice(index));
|
|
1044
|
+
break;
|
|
1045
|
+
}
|
|
1046
|
+
if (token === "--api-key") {
|
|
1047
|
+
apiKey = args[index + 1] ?? apiKey;
|
|
1048
|
+
if (index + 1 < args.length) index++;
|
|
1049
|
+
continue;
|
|
1050
|
+
}
|
|
1051
|
+
if (token.startsWith("--api-key=")) {
|
|
1052
|
+
apiKey = token.slice("--api-key=".length) || apiKey;
|
|
1053
|
+
continue;
|
|
1054
|
+
}
|
|
1055
|
+
clean.push(token);
|
|
1056
|
+
}
|
|
1057
|
+
return { argv: clean, apiKey };
|
|
1058
|
+
}
|