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
|
@@ -47,6 +47,7 @@ import {
|
|
|
47
47
|
import { consumeIssuedPluginSandboxExecutionContract } from "../plugin-runtime/bin.js";
|
|
48
48
|
import runtimeProvenanceLedger from "../runtime-provenance-ledger.js";
|
|
49
49
|
import { credentialAgent } from "./credential-agent.js";
|
|
50
|
+
import { WorkspaceTransactionManager } from "./workspace-transaction.js";
|
|
50
51
|
|
|
51
52
|
const SUPPORTED_SANDBOX_BOUNDARIES = new Set(Object.values(SANDBOX_BOUNDARIES));
|
|
52
53
|
const SUPPORTED_SANDBOX_PROFILES = new Set([
|
|
@@ -537,6 +538,7 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
537
538
|
};
|
|
538
539
|
this._ptyAdapter = createNativePtyAdapter();
|
|
539
540
|
this._hooksEventSink = null;
|
|
541
|
+
this._workspaceTransactionManagers = new Map();
|
|
540
542
|
|
|
541
543
|
this._ensureLogDir();
|
|
542
544
|
this._loadPermissions();
|
|
@@ -868,7 +870,8 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
868
870
|
requiredBoundaries.some(
|
|
869
871
|
(boundary) =>
|
|
870
872
|
boundary !== SANDBOX_BOUNDARIES.FILESYSTEM &&
|
|
871
|
-
boundary !== SANDBOX_BOUNDARIES.NETWORK
|
|
873
|
+
boundary !== SANDBOX_BOUNDARIES.NETWORK &&
|
|
874
|
+
boundary !== SANDBOX_BOUNDARIES.PROCESS_TREE,
|
|
872
875
|
)
|
|
873
876
|
) {
|
|
874
877
|
return null;
|
|
@@ -986,6 +989,12 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
986
989
|
delete options.sandboxExecutionContract;
|
|
987
990
|
}
|
|
988
991
|
|
|
992
|
+
_stripWorkspaceTransactionOptions(options) {
|
|
993
|
+
delete options.workspaceTransactionId;
|
|
994
|
+
delete options.workspaceTransactionStateDir;
|
|
995
|
+
delete options.workspaceTransactionCapture;
|
|
996
|
+
}
|
|
997
|
+
|
|
989
998
|
_sandboxUnavailablePlan(command, args, options, reason, sandboxPolicy = {}) {
|
|
990
999
|
return {
|
|
991
1000
|
contractVersion: 1,
|
|
@@ -1124,6 +1133,7 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
1124
1133
|
let genericWorkspaceProbe = false;
|
|
1125
1134
|
let sanitizedFilesystemPolicy = null;
|
|
1126
1135
|
let sanitizedNetworkPolicy = null;
|
|
1136
|
+
let sanitizedProcessTreePolicy = null;
|
|
1127
1137
|
let sanitizedPtyPolicy = null;
|
|
1128
1138
|
if (plan.runtimeProbe !== null && plan.runtimeProbe !== undefined) {
|
|
1129
1139
|
if (
|
|
@@ -1515,6 +1525,12 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
1515
1525
|
"outsideMarkerHidden",
|
|
1516
1526
|
"networkNamespace",
|
|
1517
1527
|
"networkNamespaceChanged",
|
|
1528
|
+
"pidNamespace",
|
|
1529
|
+
"pidNamespaceChanged",
|
|
1530
|
+
"processTreeCloseProbe",
|
|
1531
|
+
"bubblewrapPid1Reaper",
|
|
1532
|
+
"dieWithParent",
|
|
1533
|
+
"closeImpliesProcessTreeClosed",
|
|
1518
1534
|
"socketCreationDenied",
|
|
1519
1535
|
"descriptorMounts",
|
|
1520
1536
|
"mountTopologyAtomic",
|
|
@@ -1564,6 +1580,7 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
1564
1580
|
if (genericWorkspaceKind) {
|
|
1565
1581
|
const filesystemPolicy = plan.filesystemPolicy;
|
|
1566
1582
|
const networkPolicy = plan.networkPolicy;
|
|
1583
|
+
const processTreePolicy = plan.processTreePolicy;
|
|
1567
1584
|
const ptyPolicy = plan.ptyPolicy ?? null;
|
|
1568
1585
|
const ptyPlan =
|
|
1569
1586
|
ptyPolicy !== null &&
|
|
@@ -1607,6 +1624,7 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
1607
1624
|
/^[a-f0-9]{64}$/.test(plan.runtimeProbe.contractDigest || "") &&
|
|
1608
1625
|
guarantees.includes(SANDBOX_BOUNDARIES.FILESYSTEM) &&
|
|
1609
1626
|
guarantees.includes(SANDBOX_BOUNDARIES.NETWORK) &&
|
|
1627
|
+
guarantees.includes(SANDBOX_BOUNDARIES.PROCESS_TREE) &&
|
|
1610
1628
|
plan.runtimeProbe.attempted === true &&
|
|
1611
1629
|
plan.runtimeProbe.runnable === true &&
|
|
1612
1630
|
plan.runtimeProbe.reason === null &&
|
|
@@ -1633,6 +1651,12 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
1633
1651
|
"outsideMarkerHidden",
|
|
1634
1652
|
"networkNamespace",
|
|
1635
1653
|
"networkNamespaceChanged",
|
|
1654
|
+
"pidNamespace",
|
|
1655
|
+
"pidNamespaceChanged",
|
|
1656
|
+
"processTreeCloseProbe",
|
|
1657
|
+
"bubblewrapPid1Reaper",
|
|
1658
|
+
"dieWithParent",
|
|
1659
|
+
"closeImpliesProcessTreeClosed",
|
|
1636
1660
|
"socketCreationDenied",
|
|
1637
1661
|
"descriptorMounts",
|
|
1638
1662
|
].every((field) => plan.runtimeProbe[field] === true) &&
|
|
@@ -1670,14 +1694,24 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
1670
1694
|
networkPolicy?.namespace === "new" &&
|
|
1671
1695
|
networkPolicy?.namespaceIdentityChanged === true &&
|
|
1672
1696
|
networkPolicy?.seccomp === "deny-network-creation" &&
|
|
1697
|
+
processTreePolicy?.namespace === "new" &&
|
|
1698
|
+
processTreePolicy?.namespaceIdentityChanged === true &&
|
|
1699
|
+
processTreePolicy?.init === "bubblewrap-pid1-reaper" &&
|
|
1700
|
+
processTreePolicy?.parentDeathSignal === "SIGKILL" &&
|
|
1701
|
+
processTreePolicy?.asPid1 === false &&
|
|
1702
|
+
processTreePolicy?.closeFence === "pid-namespace-empty-or-killed" &&
|
|
1673
1703
|
plan.command.startsWith("/proc/self/fd/") &&
|
|
1674
1704
|
plan.options?.cwd === "/" &&
|
|
1675
1705
|
plan.options?.shell === false &&
|
|
1706
|
+
plan.options?.detached === false &&
|
|
1676
1707
|
Array.isArray(plan.options?.stdio) &&
|
|
1677
1708
|
plan.args.includes("--bind-fd") &&
|
|
1678
1709
|
plan.args.includes("--ro-bind-fd") &&
|
|
1679
1710
|
plan.args.includes("--remount-ro") &&
|
|
1680
1711
|
plan.args.includes("--unshare-net") &&
|
|
1712
|
+
plan.args.includes("--unshare-pid") &&
|
|
1713
|
+
plan.args.includes("--die-with-parent") &&
|
|
1714
|
+
!plan.args.includes("--as-pid-1") &&
|
|
1681
1715
|
plan.args.includes("--seccomp") &&
|
|
1682
1716
|
!plan.args.includes("--ro-bind") &&
|
|
1683
1717
|
ptyPlanValid;
|
|
@@ -1715,6 +1749,14 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
1715
1749
|
namespaceIdentityChanged: networkPolicy.namespaceIdentityChanged,
|
|
1716
1750
|
seccomp: networkPolicy.seccomp,
|
|
1717
1751
|
});
|
|
1752
|
+
sanitizedProcessTreePolicy = Object.freeze({
|
|
1753
|
+
namespace: processTreePolicy.namespace,
|
|
1754
|
+
namespaceIdentityChanged: processTreePolicy.namespaceIdentityChanged,
|
|
1755
|
+
init: processTreePolicy.init,
|
|
1756
|
+
parentDeathSignal: processTreePolicy.parentDeathSignal,
|
|
1757
|
+
asPid1: processTreePolicy.asPid1,
|
|
1758
|
+
closeFence: processTreePolicy.closeFence,
|
|
1759
|
+
});
|
|
1718
1760
|
sanitizedPtyPolicy = ptyPlan
|
|
1719
1761
|
? Object.freeze({
|
|
1720
1762
|
mode: ptyPolicy.mode,
|
|
@@ -1835,6 +1877,7 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
1835
1877
|
? {
|
|
1836
1878
|
filesystemPolicy: sanitizedFilesystemPolicy,
|
|
1837
1879
|
networkPolicy: sanitizedNetworkPolicy,
|
|
1880
|
+
processTreePolicy: sanitizedProcessTreePolicy,
|
|
1838
1881
|
ptyPolicy: sanitizedPtyPolicy,
|
|
1839
1882
|
}
|
|
1840
1883
|
: {}),
|
|
@@ -2038,6 +2081,17 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2038
2081
|
seccomp: plan.networkPolicy.seccomp,
|
|
2039
2082
|
}
|
|
2040
2083
|
: null;
|
|
2084
|
+
auditEntry.sandboxProcessTreePolicy = genericPolicy
|
|
2085
|
+
? {
|
|
2086
|
+
namespace: plan.processTreePolicy.namespace,
|
|
2087
|
+
namespaceIdentityChanged:
|
|
2088
|
+
plan.processTreePolicy.namespaceIdentityChanged,
|
|
2089
|
+
init: plan.processTreePolicy.init,
|
|
2090
|
+
parentDeathSignal: plan.processTreePolicy.parentDeathSignal,
|
|
2091
|
+
asPid1: plan.processTreePolicy.asPid1,
|
|
2092
|
+
closeFence: plan.processTreePolicy.closeFence,
|
|
2093
|
+
}
|
|
2094
|
+
: null;
|
|
2041
2095
|
auditEntry.sandboxPtyPolicy =
|
|
2042
2096
|
genericPolicy && plan.ptyPolicy
|
|
2043
2097
|
? {
|
|
@@ -2115,6 +2169,34 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2115
2169
|
return run;
|
|
2116
2170
|
}
|
|
2117
2171
|
|
|
2172
|
+
_createWorkspaceProcessCloseFence(auditEntry, proc) {
|
|
2173
|
+
if (
|
|
2174
|
+
!Array.isArray(auditEntry.workspaceTransactionIds) ||
|
|
2175
|
+
auditEntry.workspaceTransactionIds.length === 0
|
|
2176
|
+
) {
|
|
2177
|
+
return null;
|
|
2178
|
+
}
|
|
2179
|
+
return new Promise((resolve) => {
|
|
2180
|
+
if (typeof proc?.once === "function") {
|
|
2181
|
+
proc.once("close", (exitCode, signal) => {
|
|
2182
|
+
resolve({ observed: true, exitCode, signal });
|
|
2183
|
+
});
|
|
2184
|
+
return;
|
|
2185
|
+
}
|
|
2186
|
+
if (typeof proc?.onExit === "function") {
|
|
2187
|
+
proc.onExit((event = {}) => {
|
|
2188
|
+
resolve({
|
|
2189
|
+
observed: true,
|
|
2190
|
+
exitCode: event.exitCode ?? null,
|
|
2191
|
+
signal: event.signal ?? null,
|
|
2192
|
+
});
|
|
2193
|
+
});
|
|
2194
|
+
return;
|
|
2195
|
+
}
|
|
2196
|
+
resolve({ observed: false, exitCode: null, signal: null });
|
|
2197
|
+
});
|
|
2198
|
+
}
|
|
2199
|
+
|
|
2118
2200
|
_runPostSpawnSandbox(proc, plan, auditEntry) {
|
|
2119
2201
|
if (!plan.applied || !plan.postSpawn.required) {
|
|
2120
2202
|
this._applySandboxAudit(auditEntry, plan, plan.applied);
|
|
@@ -2142,10 +2224,12 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2142
2224
|
} catch {
|
|
2143
2225
|
// The sandbox failure remains fatal even if the child already exited.
|
|
2144
2226
|
}
|
|
2145
|
-
|
|
2227
|
+
const failure = this._sandboxError(
|
|
2146
2228
|
"post_spawn_failed",
|
|
2147
2229
|
`Post-spawn sandbox setup failed: ${error.message}`,
|
|
2148
2230
|
);
|
|
2231
|
+
failure.processTerminationRequested = true;
|
|
2232
|
+
throw failure;
|
|
2149
2233
|
}
|
|
2150
2234
|
process.emitWarning(
|
|
2151
2235
|
`Post-spawn sandbox setup failed (continuing without): ${error.message}`,
|
|
@@ -2163,10 +2247,12 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2163
2247
|
} catch {
|
|
2164
2248
|
// The sandbox failure remains fatal even if the child already exited.
|
|
2165
2249
|
}
|
|
2166
|
-
|
|
2250
|
+
const failure = this._sandboxError(
|
|
2167
2251
|
"async_post_spawn_contract_violation",
|
|
2168
2252
|
"Strict sandbox adapter returned an asynchronous post-spawn result",
|
|
2169
2253
|
);
|
|
2254
|
+
failure.processTerminationRequested = true;
|
|
2255
|
+
throw failure;
|
|
2170
2256
|
}
|
|
2171
2257
|
auditEntry.sandboxed = false;
|
|
2172
2258
|
auditEntry.sandboxState = "pending";
|
|
@@ -2222,6 +2308,33 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2222
2308
|
}
|
|
2223
2309
|
}
|
|
2224
2310
|
|
|
2311
|
+
_normalizeAuditRedactArgIndexes(value, argCount) {
|
|
2312
|
+
if (value === undefined) return new Set();
|
|
2313
|
+
if (!Array.isArray(value)) {
|
|
2314
|
+
throw new TypeError("auditRedactArgIndexes must be an array");
|
|
2315
|
+
}
|
|
2316
|
+
const indexes = new Set();
|
|
2317
|
+
for (const index of value) {
|
|
2318
|
+
if (!Number.isInteger(index) || index < 0 || index >= argCount) {
|
|
2319
|
+
throw new TypeError("auditRedactArgIndexes contains an invalid index");
|
|
2320
|
+
}
|
|
2321
|
+
indexes.add(index);
|
|
2322
|
+
}
|
|
2323
|
+
return indexes;
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
_auditArgs(args, redactIndexes = new Set()) {
|
|
2327
|
+
const sanitized = this._sanitizeAuditArgs(args);
|
|
2328
|
+
for (const index of redactIndexes) {
|
|
2329
|
+
sanitized[index] = "***REDACTED***";
|
|
2330
|
+
}
|
|
2331
|
+
return sanitized;
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2334
|
+
_stripAuditControlOptions(options) {
|
|
2335
|
+
delete options.auditRedactArgIndexes;
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2225
2338
|
_applyCredentialBoundary(command, args, spawnOptions, origin) {
|
|
2226
2339
|
const originalArgs = Array.isArray(args) ? [...args] : [];
|
|
2227
2340
|
const originalEnv = spawnOptions.env || process.env;
|
|
@@ -2349,6 +2462,7 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2349
2462
|
policyDigest: auditEntry.sandboxPolicyDigest || null,
|
|
2350
2463
|
filesystemPolicy: auditEntry.sandboxFilesystemPolicy || null,
|
|
2351
2464
|
networkPolicy: auditEntry.sandboxNetworkPolicy || null,
|
|
2465
|
+
processTreePolicy: auditEntry.sandboxProcessTreePolicy || null,
|
|
2352
2466
|
},
|
|
2353
2467
|
traceId:
|
|
2354
2468
|
traceCtx?.traceId || auditEntry.traceId || `trace-${Date.now()}`,
|
|
@@ -2380,11 +2494,235 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2380
2494
|
this._hooksEventSink = hooks;
|
|
2381
2495
|
}
|
|
2382
2496
|
|
|
2497
|
+
_workspaceTransactionManager(stateDir, _lockDir) {
|
|
2498
|
+
const stateKey =
|
|
2499
|
+
typeof stateDir === "string" && stateDir.trim()
|
|
2500
|
+
? path.resolve(stateDir)
|
|
2501
|
+
: "<default>";
|
|
2502
|
+
// Lock authority is intentionally not caller-selectable. Keep accepting
|
|
2503
|
+
// legacy lockDir-bearing option objects at the Broker boundary, but route
|
|
2504
|
+
// every one of them to the same canonical manager.
|
|
2505
|
+
const key = `${stateKey}\0<default>`;
|
|
2506
|
+
let manager = this._workspaceTransactionManagers.get(key);
|
|
2507
|
+
if (!manager) {
|
|
2508
|
+
manager = new WorkspaceTransactionManager({
|
|
2509
|
+
...(stateKey === "<default>" ? {} : { stateDir: stateKey }),
|
|
2510
|
+
});
|
|
2511
|
+
this._workspaceTransactionManagers.set(key, manager);
|
|
2512
|
+
}
|
|
2513
|
+
return manager;
|
|
2514
|
+
}
|
|
2515
|
+
|
|
2516
|
+
_workspaceTransactionMembershipForCwd(cwd) {
|
|
2517
|
+
const memberships = [];
|
|
2518
|
+
for (const manager of this._workspaceTransactionManagers.values()) {
|
|
2519
|
+
const membership = manager.activeWorkspaceMembershipForCwd(cwd);
|
|
2520
|
+
if (!membership) continue;
|
|
2521
|
+
const key =
|
|
2522
|
+
process.platform === "win32"
|
|
2523
|
+
? path.resolve(membership.workspaceRoot).toLowerCase()
|
|
2524
|
+
: path.resolve(membership.workspaceRoot);
|
|
2525
|
+
if (!memberships.some((entry) => entry.key === key)) {
|
|
2526
|
+
memberships.push({ key, ...membership });
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
if (memberships.length > 1) {
|
|
2530
|
+
const error = new Error(
|
|
2531
|
+
"multiple workspace transactions claim the same process cwd",
|
|
2532
|
+
);
|
|
2533
|
+
error.code = "WORKSPACE_TRANSACTION_OVERLAPPING_WORKSPACE";
|
|
2534
|
+
error.workspaceRoots = memberships.map((entry) => entry.workspaceRoot);
|
|
2535
|
+
throw error;
|
|
2536
|
+
}
|
|
2537
|
+
return memberships[0] || null;
|
|
2538
|
+
}
|
|
2539
|
+
|
|
2540
|
+
_workspaceTransactionRequiredBoundaries(cwd, membership = undefined) {
|
|
2541
|
+
const resolved =
|
|
2542
|
+
membership === undefined
|
|
2543
|
+
? this._workspaceTransactionMembershipForCwd(cwd)
|
|
2544
|
+
: membership;
|
|
2545
|
+
return resolved ? [SANDBOX_BOUNDARIES.PROCESS_TREE] : [];
|
|
2546
|
+
}
|
|
2547
|
+
|
|
2548
|
+
_workspaceTransactionRootForCwd(cwd, membership = undefined) {
|
|
2549
|
+
const resolved =
|
|
2550
|
+
membership === undefined
|
|
2551
|
+
? this._workspaceTransactionMembershipForCwd(cwd)
|
|
2552
|
+
: membership;
|
|
2553
|
+
return resolved?.workspaceRoot || null;
|
|
2554
|
+
}
|
|
2555
|
+
|
|
2556
|
+
_withWorkspaceTransactionBoundaries(
|
|
2557
|
+
options,
|
|
2558
|
+
cwd,
|
|
2559
|
+
{ command, args = [], sync = false, pty = false } = {},
|
|
2560
|
+
) {
|
|
2561
|
+
const membership = this._workspaceTransactionMembershipForCwd(cwd);
|
|
2562
|
+
const required = this._workspaceTransactionRequiredBoundaries(
|
|
2563
|
+
cwd,
|
|
2564
|
+
membership,
|
|
2565
|
+
);
|
|
2566
|
+
if (required.length === 0) return options;
|
|
2567
|
+
if (
|
|
2568
|
+
options.requiredBoundaries !== undefined &&
|
|
2569
|
+
!Array.isArray(options.requiredBoundaries)
|
|
2570
|
+
) {
|
|
2571
|
+
// Preserve the invalid value so normal policy validation rejects it.
|
|
2572
|
+
return options;
|
|
2573
|
+
}
|
|
2574
|
+
const nextOptions = {
|
|
2575
|
+
...options,
|
|
2576
|
+
...(membership?.cwd ? { cwd: membership.cwd } : {}),
|
|
2577
|
+
requiredBoundaries: [
|
|
2578
|
+
...new Set([...(options.requiredBoundaries || []), ...required]),
|
|
2579
|
+
],
|
|
2580
|
+
};
|
|
2581
|
+
const workspaceRoot = this._workspaceTransactionRootForCwd(cwd, membership);
|
|
2582
|
+
// Transaction preflight always rejects detached writers. Do not let a
|
|
2583
|
+
// platform contract fail first and hide that stable, typed denial.
|
|
2584
|
+
if (
|
|
2585
|
+
workspaceRoot &&
|
|
2586
|
+
nextOptions.detached !== true &&
|
|
2587
|
+
nextOptions.sandboxExecutionContract === undefined
|
|
2588
|
+
) {
|
|
2589
|
+
const contract = this.issueLinuxWorkspaceSandboxExecutionContract(
|
|
2590
|
+
command,
|
|
2591
|
+
args,
|
|
2592
|
+
nextOptions,
|
|
2593
|
+
workspaceRoot,
|
|
2594
|
+
{ sync, pty },
|
|
2595
|
+
);
|
|
2596
|
+
if (contract) nextOptions.sandboxExecutionContract = contract;
|
|
2597
|
+
}
|
|
2598
|
+
return nextOptions;
|
|
2599
|
+
}
|
|
2600
|
+
|
|
2601
|
+
_requiresExplicitLinuxWorkspaceShell(cwd) {
|
|
2602
|
+
return (
|
|
2603
|
+
process.platform === "linux" &&
|
|
2604
|
+
this._workspaceTransactionRequiredBoundaries(cwd).length > 0
|
|
2605
|
+
);
|
|
2606
|
+
}
|
|
2607
|
+
|
|
2608
|
+
_explicitLinuxShellInvocation(command, options = {}) {
|
|
2609
|
+
return {
|
|
2610
|
+
command:
|
|
2611
|
+
typeof options.shell === "string" && options.shell.trim()
|
|
2612
|
+
? options.shell
|
|
2613
|
+
: "/bin/sh",
|
|
2614
|
+
args: ["-c", String(command)],
|
|
2615
|
+
};
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
/**
|
|
2619
|
+
* Start a fail-closed, content-addressed workspace checkpoint transaction.
|
|
2620
|
+
*
|
|
2621
|
+
* Active transactions automatically bind every Broker spawn whose canonical
|
|
2622
|
+
* cwd is inside their workspace. The transaction itself owns accept/rollback
|
|
2623
|
+
* and durable evidence APIs.
|
|
2624
|
+
*/
|
|
2625
|
+
beginWorkspaceTransaction(options = {}) {
|
|
2626
|
+
return this._workspaceTransactionManager(
|
|
2627
|
+
options.stateDir,
|
|
2628
|
+
options.lockDir,
|
|
2629
|
+
).begin(options);
|
|
2630
|
+
}
|
|
2631
|
+
|
|
2632
|
+
recoverWorkspaceTransactions(options = {}) {
|
|
2633
|
+
return this._workspaceTransactionManager(
|
|
2634
|
+
options.stateDir,
|
|
2635
|
+
options.lockDir,
|
|
2636
|
+
).recoverPending(options);
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
inspectWorkspaceTransaction(id, options = {}) {
|
|
2640
|
+
return this._workspaceTransactionManager(
|
|
2641
|
+
options.stateDir,
|
|
2642
|
+
options.lockDir,
|
|
2643
|
+
).inspect(id);
|
|
2644
|
+
}
|
|
2645
|
+
|
|
2646
|
+
listWorkspaceTransactions(options = {}) {
|
|
2647
|
+
return this._workspaceTransactionManager(
|
|
2648
|
+
options.stateDir,
|
|
2649
|
+
options.lockDir,
|
|
2650
|
+
).list(options);
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2653
|
+
restoreWorkspaceTransaction(id, options = {}) {
|
|
2654
|
+
return this._workspaceTransactionManager(
|
|
2655
|
+
options.stateDir,
|
|
2656
|
+
options.lockDir,
|
|
2657
|
+
).restore(id, options);
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2660
|
+
undoWorkspaceTransactionRestore(id, options = {}) {
|
|
2661
|
+
return this._workspaceTransactionManager(
|
|
2662
|
+
options.stateDir,
|
|
2663
|
+
options.lockDir,
|
|
2664
|
+
).undoRestore(id, options);
|
|
2665
|
+
}
|
|
2666
|
+
|
|
2667
|
+
getWorkspaceTransaction(id) {
|
|
2668
|
+
for (const manager of this._workspaceTransactionManagers.values()) {
|
|
2669
|
+
const transaction = manager.get(id);
|
|
2670
|
+
if (transaction) return transaction;
|
|
2671
|
+
}
|
|
2672
|
+
return null;
|
|
2673
|
+
}
|
|
2674
|
+
|
|
2675
|
+
_prepareWorkspaceTransactionAudit(auditEntry) {
|
|
2676
|
+
const transactionIds = [];
|
|
2677
|
+
for (const manager of this._workspaceTransactionManagers.values()) {
|
|
2678
|
+
transactionIds.push(...manager.prepareSpawn(auditEntry));
|
|
2679
|
+
}
|
|
2680
|
+
auditEntry.workspaceTransactionIds = [...new Set(transactionIds)].sort();
|
|
2681
|
+
return auditEntry.workspaceTransactionIds;
|
|
2682
|
+
}
|
|
2683
|
+
|
|
2684
|
+
_preflightWorkspaceTransactionAudit(auditEntry) {
|
|
2685
|
+
const transactionIds = [];
|
|
2686
|
+
try {
|
|
2687
|
+
for (const manager of this._workspaceTransactionManagers.values()) {
|
|
2688
|
+
transactionIds.push(...manager.preflightSpawn(auditEntry));
|
|
2689
|
+
}
|
|
2690
|
+
} catch (error) {
|
|
2691
|
+
error.auditEntry = auditEntry;
|
|
2692
|
+
throw error;
|
|
2693
|
+
}
|
|
2694
|
+
return [...new Set(transactionIds)].sort();
|
|
2695
|
+
}
|
|
2696
|
+
|
|
2697
|
+
_bindWorkspaceTransactionProcess(auditEntry, proc) {
|
|
2698
|
+
for (const manager of this._workspaceTransactionManagers.values()) {
|
|
2699
|
+
manager.bindProcess(auditEntry, proc);
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2702
|
+
|
|
2703
|
+
_updateWorkspaceTransactionProcessGuarantees(auditEntry) {
|
|
2704
|
+
for (const manager of this._workspaceTransactionManagers.values()) {
|
|
2705
|
+
manager.updateProcessGuarantees(auditEntry);
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
|
|
2709
|
+
_settleWorkspaceTransactionSpawn(auditEntry, outcome = {}) {
|
|
2710
|
+
for (const manager of this._workspaceTransactionManagers.values()) {
|
|
2711
|
+
manager.settleSpawn(auditEntry, outcome);
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
|
|
2383
2715
|
spawn(command, args, options = {}) {
|
|
2384
2716
|
const executionId = crypto.randomUUID();
|
|
2385
2717
|
const startTime = Date.now();
|
|
2386
2718
|
const origin = options.origin || "unknown";
|
|
2387
|
-
const
|
|
2719
|
+
const requestedCwd = options.cwd || process.cwd();
|
|
2720
|
+
options = this._withWorkspaceTransactionBoundaries(options, requestedCwd, {
|
|
2721
|
+
command,
|
|
2722
|
+
args,
|
|
2723
|
+
sync: false,
|
|
2724
|
+
});
|
|
2725
|
+
const cwd = options.cwd || requestedCwd;
|
|
2388
2726
|
const scope = options.scope || "default";
|
|
2389
2727
|
const policy = options.policy || this._checkPermission(origin, command);
|
|
2390
2728
|
const isDangerous = this._isDangerousCommand(
|
|
@@ -2393,6 +2731,10 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2393
2731
|
let decision = policy;
|
|
2394
2732
|
if (isDangerous && policy !== "deny") decision = "deny";
|
|
2395
2733
|
if (options.forceAllow) decision = "elevated";
|
|
2734
|
+
const auditRedactArgIndexes = this._normalizeAuditRedactArgIndexes(
|
|
2735
|
+
options.auditRedactArgIndexes,
|
|
2736
|
+
Array.isArray(args) ? args.length : 0,
|
|
2737
|
+
);
|
|
2396
2738
|
|
|
2397
2739
|
const traceCtx = this._getTraceContext();
|
|
2398
2740
|
const auditEntry = {
|
|
@@ -2401,13 +2743,14 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2401
2743
|
origin,
|
|
2402
2744
|
scope,
|
|
2403
2745
|
command,
|
|
2404
|
-
args: this.
|
|
2746
|
+
args: this._auditArgs(args, auditRedactArgIndexes),
|
|
2405
2747
|
cwd,
|
|
2406
2748
|
startTime,
|
|
2407
2749
|
permissionDecision: decision,
|
|
2408
2750
|
policy,
|
|
2409
2751
|
isDangerous,
|
|
2410
2752
|
shell: !!options.shell,
|
|
2753
|
+
detached: options.detached === true,
|
|
2411
2754
|
pid: null,
|
|
2412
2755
|
exitCode: null,
|
|
2413
2756
|
endTime: null,
|
|
@@ -2463,9 +2806,13 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2463
2806
|
}
|
|
2464
2807
|
|
|
2465
2808
|
// 传播traceparent环境变量
|
|
2809
|
+
this._preflightWorkspaceTransactionAudit(auditEntry);
|
|
2810
|
+
|
|
2466
2811
|
const spawnOpts = this._sanitizeOptions(options);
|
|
2467
2812
|
this._stripSandboxControlOptions(spawnOpts);
|
|
2468
2813
|
this._stripPluginControlOptions(spawnOpts);
|
|
2814
|
+
this._stripWorkspaceTransactionOptions(spawnOpts);
|
|
2815
|
+
this._stripAuditControlOptions(spawnOpts);
|
|
2469
2816
|
if (traceCtx) {
|
|
2470
2817
|
spawnOpts.env = { ...(spawnOpts.env || process.env) };
|
|
2471
2818
|
spawnOpts.env.TRACEPARENT = traceCtx.traceparent;
|
|
@@ -2487,7 +2834,7 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2487
2834
|
);
|
|
2488
2835
|
spawnOpts.env = credentialBoundary.env;
|
|
2489
2836
|
args = credentialBoundary.args;
|
|
2490
|
-
auditEntry.args =
|
|
2837
|
+
auditEntry.args = this._auditArgs(args, auditRedactArgIndexes);
|
|
2491
2838
|
this._recordCredentialReport(auditEntry, credentialBoundary.report);
|
|
2492
2839
|
this._stripCredentialControlOptions(spawnOpts);
|
|
2493
2840
|
}
|
|
@@ -2527,17 +2874,45 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2527
2874
|
sandboxPlan,
|
|
2528
2875
|
sandboxPlan.applied && !sandboxPlan.postSpawn.required,
|
|
2529
2876
|
);
|
|
2877
|
+
try {
|
|
2878
|
+
this._prepareWorkspaceTransactionAudit(auditEntry);
|
|
2879
|
+
} catch (transactionError) {
|
|
2880
|
+
sandboxPlan.cleanup?.();
|
|
2881
|
+
transactionError.auditEntry = auditEntry;
|
|
2882
|
+
throw transactionError;
|
|
2883
|
+
}
|
|
2530
2884
|
|
|
2531
2885
|
// Use native spawn from _native (set by patch-child-process.js)
|
|
2532
2886
|
const nativeSpawnFn = this._native?.spawn || nativeSpawn;
|
|
2533
2887
|
let proc;
|
|
2534
2888
|
try {
|
|
2535
2889
|
proc = nativeSpawnFn(command, args, optsForSpawn);
|
|
2890
|
+
this._bindWorkspaceTransactionProcess(auditEntry, proc);
|
|
2536
2891
|
} catch (spawnError) {
|
|
2892
|
+
if (proc && typeof proc.kill === "function") {
|
|
2893
|
+
try {
|
|
2894
|
+
proc.kill("SIGKILL");
|
|
2895
|
+
} catch {
|
|
2896
|
+
// The transaction remains unsettled if shutdown cannot be proven.
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
if (!proc) {
|
|
2900
|
+
try {
|
|
2901
|
+
this._settleWorkspaceTransactionSpawn(auditEntry, {
|
|
2902
|
+
error: spawnError.message,
|
|
2903
|
+
});
|
|
2904
|
+
} catch {
|
|
2905
|
+
// An unsettled durable execution keeps the transaction fail-closed.
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2537
2908
|
sandboxPlan.cleanup?.();
|
|
2538
2909
|
throw spawnError;
|
|
2539
2910
|
}
|
|
2540
2911
|
auditEntry.pid = proc.pid;
|
|
2912
|
+
const workspaceProcessClosed = this._createWorkspaceProcessCloseFence(
|
|
2913
|
+
auditEntry,
|
|
2914
|
+
proc,
|
|
2915
|
+
);
|
|
2541
2916
|
const cleanupSandbox = this._scheduleSandboxCleanup(
|
|
2542
2917
|
proc,
|
|
2543
2918
|
sandboxPlan.cleanup,
|
|
@@ -2558,6 +2933,7 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2558
2933
|
}
|
|
2559
2934
|
try {
|
|
2560
2935
|
this._runPostSpawnSandbox(proc, sandboxPlan, auditEntry);
|
|
2936
|
+
this._updateWorkspaceTransactionProcessGuarantees(auditEntry);
|
|
2561
2937
|
auditEntry.pid = proc.pid;
|
|
2562
2938
|
if (Number.isSafeInteger(proc.sandboxWrapperPid)) {
|
|
2563
2939
|
auditEntry.sandboxWrapperPid = proc.sandboxWrapperPid;
|
|
@@ -2566,9 +2942,19 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2566
2942
|
auditEntry.sandboxTargetPid = proc.sandboxTargetPid;
|
|
2567
2943
|
}
|
|
2568
2944
|
} catch (postSpawnError) {
|
|
2945
|
+
if (postSpawnError.processTerminationRequested !== true) {
|
|
2946
|
+
try {
|
|
2947
|
+
proc.kill?.("SIGKILL");
|
|
2948
|
+
} catch {
|
|
2949
|
+
// The close fence remains pending and recovery stays fail-closed.
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2569
2952
|
cleanupSandbox();
|
|
2570
2953
|
this._recordSandboxDenial(auditEntry, postSpawnError, startTime);
|
|
2571
2954
|
postSpawnError.auditEntry = auditEntry;
|
|
2955
|
+
postSpawnError.spawnedProcess = proc;
|
|
2956
|
+
postSpawnError.workspaceProcessClosed = workspaceProcessClosed;
|
|
2957
|
+
postSpawnError.workspaceTerminationRequested = true;
|
|
2572
2958
|
throw postSpawnError;
|
|
2573
2959
|
}
|
|
2574
2960
|
|
|
@@ -2578,7 +2964,7 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2578
2964
|
executionId,
|
|
2579
2965
|
toolName: origin,
|
|
2580
2966
|
command,
|
|
2581
|
-
args,
|
|
2967
|
+
args: [...auditEntry.args],
|
|
2582
2968
|
cwd,
|
|
2583
2969
|
pid: proc.pid,
|
|
2584
2970
|
component: origin,
|
|
@@ -2624,7 +3010,13 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2624
3010
|
const executionId = crypto.randomUUID();
|
|
2625
3011
|
const startTime = Date.now();
|
|
2626
3012
|
const origin = options.origin || "unknown";
|
|
2627
|
-
const
|
|
3013
|
+
const requestedCwd = options.cwd || process.cwd();
|
|
3014
|
+
options = this._withWorkspaceTransactionBoundaries(options, requestedCwd, {
|
|
3015
|
+
command,
|
|
3016
|
+
args,
|
|
3017
|
+
sync: true,
|
|
3018
|
+
});
|
|
3019
|
+
const cwd = options.cwd || requestedCwd;
|
|
2628
3020
|
const scope = options.scope || "default";
|
|
2629
3021
|
const policy = options.policy || this._checkPermission(origin, command);
|
|
2630
3022
|
const isDangerous = this._isDangerousCommand(
|
|
@@ -2633,6 +3025,10 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2633
3025
|
let decision = policy;
|
|
2634
3026
|
if (isDangerous && policy !== "deny") decision = "deny";
|
|
2635
3027
|
if (options.forceAllow) decision = "elevated";
|
|
3028
|
+
const auditRedactArgIndexes = this._normalizeAuditRedactArgIndexes(
|
|
3029
|
+
options.auditRedactArgIndexes,
|
|
3030
|
+
Array.isArray(args) ? args.length : 0,
|
|
3031
|
+
);
|
|
2636
3032
|
|
|
2637
3033
|
const traceCtx = this._getTraceContext();
|
|
2638
3034
|
const auditEntry = {
|
|
@@ -2641,13 +3037,14 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2641
3037
|
origin,
|
|
2642
3038
|
scope,
|
|
2643
3039
|
command,
|
|
2644
|
-
args: this.
|
|
3040
|
+
args: this._auditArgs(args, auditRedactArgIndexes),
|
|
2645
3041
|
cwd,
|
|
2646
3042
|
startTime,
|
|
2647
3043
|
permissionDecision: decision,
|
|
2648
3044
|
policy,
|
|
2649
3045
|
isDangerous,
|
|
2650
3046
|
shell: !!options.shell,
|
|
3047
|
+
detached: options.detached === true,
|
|
2651
3048
|
sync: true,
|
|
2652
3049
|
pluginId: options.pluginId || null,
|
|
2653
3050
|
pluginVersion: options.pluginVersion || null,
|
|
@@ -2693,9 +3090,13 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2693
3090
|
throw err;
|
|
2694
3091
|
}
|
|
2695
3092
|
|
|
3093
|
+
this._preflightWorkspaceTransactionAudit(auditEntry);
|
|
3094
|
+
|
|
2696
3095
|
const spawnOpts = this._sanitizeOptions(options);
|
|
2697
3096
|
this._stripSandboxControlOptions(spawnOpts);
|
|
2698
3097
|
this._stripPluginControlOptions(spawnOpts);
|
|
3098
|
+
this._stripWorkspaceTransactionOptions(spawnOpts);
|
|
3099
|
+
this._stripAuditControlOptions(spawnOpts);
|
|
2699
3100
|
if (traceCtx) {
|
|
2700
3101
|
spawnOpts.env = { ...(spawnOpts.env || process.env) };
|
|
2701
3102
|
spawnOpts.env.TRACEPARENT = traceCtx.traceparent;
|
|
@@ -2717,7 +3118,7 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2717
3118
|
);
|
|
2718
3119
|
spawnOpts.env = credentialBoundary.env;
|
|
2719
3120
|
args = credentialBoundary.args;
|
|
2720
|
-
auditEntry.args =
|
|
3121
|
+
auditEntry.args = this._auditArgs(args, auditRedactArgIndexes);
|
|
2721
3122
|
this._recordCredentialReport(auditEntry, credentialBoundary.report);
|
|
2722
3123
|
this._stripCredentialControlOptions(spawnOpts);
|
|
2723
3124
|
}
|
|
@@ -2754,10 +3155,22 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2754
3155
|
args = [...sandboxPlan.args];
|
|
2755
3156
|
const optsForSync = { ...sandboxPlan.options };
|
|
2756
3157
|
this._applySandboxAudit(auditEntry, sandboxPlan, sandboxPlan.applied);
|
|
3158
|
+
try {
|
|
3159
|
+
this._prepareWorkspaceTransactionAudit(auditEntry);
|
|
3160
|
+
} catch (transactionError) {
|
|
3161
|
+
sandboxPlan.cleanup?.();
|
|
3162
|
+
transactionError.auditEntry = auditEntry;
|
|
3163
|
+
throw transactionError;
|
|
3164
|
+
}
|
|
2757
3165
|
|
|
2758
3166
|
const nativeSpawnSyncFn = this._native?.spawnSync || nativeSpawnSync;
|
|
2759
3167
|
try {
|
|
2760
3168
|
const result = nativeSpawnSyncFn(command, args, optsForSync);
|
|
3169
|
+
this._settleWorkspaceTransactionSpawn(auditEntry, {
|
|
3170
|
+
exitCode: result.status,
|
|
3171
|
+
signal: result.signal,
|
|
3172
|
+
error: result.error?.message || null,
|
|
3173
|
+
});
|
|
2761
3174
|
if (sandboxPlan.applied) this._stats.sandboxed++;
|
|
2762
3175
|
auditEntry.exitCode = result.status;
|
|
2763
3176
|
auditEntry.endTime = Date.now();
|
|
@@ -2766,6 +3179,14 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2766
3179
|
this._writeRplEntry(auditEntry, "completed");
|
|
2767
3180
|
return result;
|
|
2768
3181
|
} catch (err) {
|
|
3182
|
+
try {
|
|
3183
|
+
this._settleWorkspaceTransactionSpawn(auditEntry, {
|
|
3184
|
+
error: err.message,
|
|
3185
|
+
});
|
|
3186
|
+
} catch {
|
|
3187
|
+
// Preserve the primary spawn failure; transaction settlement remains
|
|
3188
|
+
// fail-closed and blocks accept/rollback.
|
|
3189
|
+
}
|
|
2769
3190
|
auditEntry.error = err.message;
|
|
2770
3191
|
auditEntry.endTime = Date.now();
|
|
2771
3192
|
auditEntry.durationMs = auditEntry.endTime - startTime;
|
|
@@ -2788,24 +3209,34 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2788
3209
|
if (!ptyModule || typeof ptyModule.spawn !== "function") {
|
|
2789
3210
|
throw new TypeError("pty_module_spawn_unavailable");
|
|
2790
3211
|
}
|
|
3212
|
+
options = this._withWorkspaceTransactionBoundaries(
|
|
3213
|
+
options,
|
|
3214
|
+
options.cwd || process.cwd(),
|
|
3215
|
+
{ command, args, sync: false, pty: true },
|
|
3216
|
+
);
|
|
2791
3217
|
const executionId = crypto.randomUUID();
|
|
2792
3218
|
const startTime = Date.now();
|
|
2793
3219
|
const origin = options.origin || "terminal:pty";
|
|
2794
3220
|
const scope = options.scope || "terminal";
|
|
2795
3221
|
const policy = options.policy || "allow";
|
|
3222
|
+
const auditRedactArgIndexes = this._normalizeAuditRedactArgIndexes(
|
|
3223
|
+
options.auditRedactArgIndexes,
|
|
3224
|
+
Array.isArray(args) ? args.length : 0,
|
|
3225
|
+
);
|
|
2796
3226
|
const auditEntry = {
|
|
2797
3227
|
executionId,
|
|
2798
3228
|
traceId: this._getTraceContext()?.traceId || null,
|
|
2799
3229
|
origin,
|
|
2800
3230
|
scope,
|
|
2801
3231
|
command,
|
|
2802
|
-
args: this.
|
|
3232
|
+
args: this._auditArgs(args, auditRedactArgIndexes),
|
|
2803
3233
|
cwd: options.cwd || process.cwd(),
|
|
2804
3234
|
startTime,
|
|
2805
3235
|
permissionDecision: policy,
|
|
2806
3236
|
policy,
|
|
2807
3237
|
operation: "pty.spawn",
|
|
2808
3238
|
pty: true,
|
|
3239
|
+
detached: options.detached === true,
|
|
2809
3240
|
sandboxed: false,
|
|
2810
3241
|
sandboxReason: "native_pty_host_boundary",
|
|
2811
3242
|
sandboxRequired: [],
|
|
@@ -2847,9 +3278,11 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2847
3278
|
throw error;
|
|
2848
3279
|
}
|
|
2849
3280
|
|
|
2850
|
-
const spawnOptions = { ...options, args: [...
|
|
3281
|
+
const spawnOptions = { ...options, args: [...args] };
|
|
2851
3282
|
this._stripSandboxControlOptions(spawnOptions);
|
|
2852
3283
|
this._stripPluginControlOptions(spawnOptions);
|
|
3284
|
+
this._stripWorkspaceTransactionOptions(spawnOptions);
|
|
3285
|
+
this._stripAuditControlOptions(spawnOptions);
|
|
2853
3286
|
try {
|
|
2854
3287
|
const terminalName =
|
|
2855
3288
|
typeof options.name === "string" && options.name
|
|
@@ -2874,18 +3307,32 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2874
3307
|
);
|
|
2875
3308
|
spawnOptions.env = credentialBoundary.env;
|
|
2876
3309
|
spawnOptions.args = credentialBoundary.args;
|
|
2877
|
-
auditEntry.args =
|
|
3310
|
+
auditEntry.args = this._auditArgs(
|
|
3311
|
+
credentialBoundary.args,
|
|
3312
|
+
auditRedactArgIndexes,
|
|
3313
|
+
);
|
|
2878
3314
|
this._recordCredentialReport(auditEntry, credentialBoundary.report);
|
|
2879
3315
|
this._stripCredentialControlOptions(spawnOptions);
|
|
2880
3316
|
}
|
|
2881
3317
|
const filteredArgs = spawnOptions.args || [];
|
|
2882
3318
|
delete spawnOptions.args;
|
|
3319
|
+
this._prepareWorkspaceTransactionAudit(auditEntry);
|
|
2883
3320
|
|
|
2884
3321
|
if (sandboxPolicy.requiredBoundaries.length === 0) {
|
|
2885
3322
|
delete spawnOptions.origin;
|
|
2886
3323
|
delete spawnOptions.policy;
|
|
2887
3324
|
delete spawnOptions.scope;
|
|
2888
3325
|
const proc = ptyModule.spawn(command, filteredArgs, spawnOptions);
|
|
3326
|
+
try {
|
|
3327
|
+
this._bindWorkspaceTransactionProcess(auditEntry, proc);
|
|
3328
|
+
} catch (transactionError) {
|
|
3329
|
+
try {
|
|
3330
|
+
proc.kill?.();
|
|
3331
|
+
} catch {
|
|
3332
|
+
// The durable execution remains unsettled and blocks recovery.
|
|
3333
|
+
}
|
|
3334
|
+
throw transactionError;
|
|
3335
|
+
}
|
|
2889
3336
|
auditEntry.pid = proc?.pid ?? null;
|
|
2890
3337
|
auditEntry.endTime = Date.now();
|
|
2891
3338
|
auditEntry.durationMs = auditEntry.endTime - startTime;
|
|
@@ -2966,6 +3413,7 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
2966
3413
|
],
|
|
2967
3414
|
});
|
|
2968
3415
|
proc = wrapSandboxedPty(terminal, child, command, this._ptyAdapter);
|
|
3416
|
+
this._bindWorkspaceTransactionProcess(auditEntry, proc);
|
|
2969
3417
|
} catch (ptyError) {
|
|
2970
3418
|
if (child && typeof child.kill === "function") {
|
|
2971
3419
|
try {
|
|
@@ -3025,6 +3473,7 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
3025
3473
|
}
|
|
3026
3474
|
sandboxPlan.cleanup?.();
|
|
3027
3475
|
this._applySandboxAudit(auditEntry, sandboxPlan, true);
|
|
3476
|
+
this._updateWorkspaceTransactionProcessGuarantees(auditEntry);
|
|
3028
3477
|
this._stats.sandboxed++;
|
|
3029
3478
|
|
|
3030
3479
|
child.once("exit", (code, signal) => {
|
|
@@ -3064,6 +3513,14 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
3064
3513
|
exec(command, options, callback) {
|
|
3065
3514
|
const opts = typeof options === "function" ? {} : options;
|
|
3066
3515
|
const cb = typeof options === "function" ? options : callback;
|
|
3516
|
+
if (this._requiresExplicitLinuxWorkspaceShell(opts.cwd || process.cwd())) {
|
|
3517
|
+
const invocation = this._explicitLinuxShellInvocation(command, opts);
|
|
3518
|
+
return this.spawn(invocation.command, invocation.args, {
|
|
3519
|
+
...opts,
|
|
3520
|
+
shell: false,
|
|
3521
|
+
origin: opts.origin || "shell:exec",
|
|
3522
|
+
});
|
|
3523
|
+
}
|
|
3067
3524
|
return this.spawn(command, [], {
|
|
3068
3525
|
...opts,
|
|
3069
3526
|
shell: true,
|
|
@@ -3072,6 +3529,27 @@ class ProcessExecutionBroker extends EventEmitter {
|
|
|
3072
3529
|
}
|
|
3073
3530
|
|
|
3074
3531
|
execSync(command, options = {}) {
|
|
3532
|
+
if (
|
|
3533
|
+
this._requiresExplicitLinuxWorkspaceShell(options.cwd || process.cwd())
|
|
3534
|
+
) {
|
|
3535
|
+
const invocation = this._explicitLinuxShellInvocation(command, options);
|
|
3536
|
+
const result = this.spawnSync(invocation.command, invocation.args, {
|
|
3537
|
+
...options,
|
|
3538
|
+
shell: false,
|
|
3539
|
+
origin: options.origin || "shell:execSync",
|
|
3540
|
+
});
|
|
3541
|
+
if (result?.error) throw result.error;
|
|
3542
|
+
if (result?.status != null && result.status !== 0) {
|
|
3543
|
+
const error = new Error(
|
|
3544
|
+
`Command failed (exit ${result.status}): ${command}`,
|
|
3545
|
+
);
|
|
3546
|
+
error.status = result.status;
|
|
3547
|
+
error.stdout = result.stdout;
|
|
3548
|
+
error.stderr = result.stderr;
|
|
3549
|
+
throw error;
|
|
3550
|
+
}
|
|
3551
|
+
return result?.stdout ?? "";
|
|
3552
|
+
}
|
|
3075
3553
|
const spawnOpts = {
|
|
3076
3554
|
...options,
|
|
3077
3555
|
shell: true,
|