chainlesschain 0.166.101 → 0.166.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/assets/linux-subreaper/linux-arm64/manifest.json +1 -1
- package/src/assets/linux-subreaper/linux-x64/manifest.json +1 -1
- package/src/assets/web-panel/assets/{AIOps-BjBS_29I.js → AIOps-BLrXpdnP.js} +1 -1
- package/src/assets/web-panel/assets/{ActionButton-CUnnQUaj.js → ActionButton-C0xy9uFy.js} +1 -1
- package/src/assets/web-panel/assets/{Analytics-BqYZxgnY.js → Analytics-C6EephQP.js} +3 -3
- package/src/assets/web-panel/assets/{AppLayout-m8B886ka.js → AppLayout-ZCXdOD9y.js} +5 -5
- package/src/assets/web-panel/assets/{Artifacts-JEOxU3Ug.js → Artifacts-D4MfZ-pl.js} +1 -1
- package/src/assets/web-panel/assets/{Audit-DAXS5c9J.js → Audit-BQ8c3bBu.js} +1 -1
- package/src/assets/web-panel/assets/{BackgroundAgents-e3a9XHw3.js → BackgroundAgents-BOA7_ljM.js} +1 -1
- package/src/assets/web-panel/assets/{Backup-D3Qmp68h.js → Backup-60uiQjGT.js} +1 -1
- package/src/assets/web-panel/assets/{BaseInput-C7CXyiUl.js → BaseInput-BDvEbGs_.js} +1 -1
- package/src/assets/web-panel/assets/{Chat-2AHlAGi8.js → Chat-B3IkAuFQ.js} +6 -6
- package/src/assets/web-panel/assets/ChatBubbleRenderer-n6BVStHf.js +1 -0
- package/src/assets/web-panel/assets/{Checkbox-YfBuQlBH.js → Checkbox-njGbfJWq.js} +1 -1
- package/src/assets/web-panel/assets/{Codegen-DCCQDfTL.js → Codegen-CF7DtdxC.js} +1 -1
- package/src/assets/web-panel/assets/{Col-03i2WfrV.js → Col-C_3Zix40.js} +1 -1
- package/src/assets/web-panel/assets/{Community-CJQIpng6.js → Community-CzU-ZC2d.js} +1 -1
- package/src/assets/web-panel/assets/{Compact-CCtcQ2pq.js → Compact-BgeqsPRh.js} +1 -1
- package/src/assets/web-panel/assets/{Compliance-Vxl7ZszJ.js → Compliance-6l7cwiqp.js} +1 -1
- package/src/assets/web-panel/assets/{Cowork-DN-BwA8I.js → Cowork-D4s905fI.js} +2 -2
- package/src/assets/web-panel/assets/{Cron-Dc2Q46X7.js → Cron-CGTYSxRS.js} +2 -2
- package/src/assets/web-panel/assets/{Crosschain-CQCblsl-.js → Crosschain-BnSo-Yt3.js} +1 -1
- package/src/assets/web-panel/assets/{DID-YYvqUR8C.js → DID-Dm4vk2X1.js} +2 -2
- package/src/assets/web-panel/assets/{Dashboard-Cafy3DZT.js → Dashboard-D7H-PZ_N.js} +2 -2
- package/src/assets/web-panel/assets/{Dropdown-BOyYpIpv.js → Dropdown-COslkgxn.js} +1 -1
- package/src/assets/web-panel/assets/{EmailListRenderer-B7NYjc1j.js → EmailListRenderer-CJWEetmk.js} +1 -1
- package/src/assets/web-panel/assets/{EvolutionSettings-C5wfxztf.js → EvolutionSettings-BbzebAWe.js} +1 -1
- package/src/assets/web-panel/assets/{FamilyGuardDashboard-aA7KnDGK.js → FamilyGuardDashboard-BsoTOXwk.js} +1 -1
- package/src/assets/web-panel/assets/{Federation-DlgXUu1L.js → Federation-Ck5kM_5H.js} +1 -1
- package/src/assets/web-panel/assets/{FormItemContext-B5YsrLDg.js → FormItemContext-gShxCqtF.js} +1 -1
- package/src/assets/web-panel/assets/{GenericCardRenderer-DaWojPFw.js → GenericCardRenderer-DarN1G-z.js} +1 -1
- package/src/assets/web-panel/assets/{Git-dkhh6Fx2.js → Git-CJfpLyP5.js} +2 -2
- package/src/assets/web-panel/assets/{Governance-Cz6vmkjc.js → Governance-CVcJmpQz.js} +1 -1
- package/src/assets/web-panel/assets/{Inference-DWt0hbh8.js → Inference-ComU_ig8.js} +1 -1
- package/src/assets/web-panel/assets/{KnowledgeGraph-BZJ0Z-nL.js → KnowledgeGraph-35hprFJy.js} +1 -1
- package/src/assets/web-panel/assets/{Logs-BaBBmL1A.js → Logs-BQDqBTz0.js} +2 -2
- package/src/assets/web-panel/assets/MarkdownRenderer-BpdGAVCC.js +1 -0
- package/src/assets/web-panel/assets/{Marketplace-ct8sgQ0s.js → Marketplace-B9O9OKnn.js} +1 -1
- package/src/assets/web-panel/assets/{McpTools-CXKCRGYQ.js → McpTools-VMKxA4Wc.js} +3 -3
- package/src/assets/web-panel/assets/{Memory-O7ZwlS6a.js → Memory-CcBbf3Bc.js} +2 -2
- package/src/assets/web-panel/assets/{MobileBridge-By12C-eC.js → MobileBridge-D7myz46N.js} +1 -1
- package/src/assets/web-panel/assets/{MobileProjects-Ba-EVdex.js → MobileProjects-Da5KBXyx.js} +1 -1
- package/src/assets/web-panel/assets/{Mtc-g-932zV2.js → Mtc-x3NPZfuL.js} +5 -5
- package/src/assets/web-panel/assets/{MtcAudit-BW8hB0ly.js → MtcAudit-CwnzptEC.js} +4 -4
- package/src/assets/web-panel/assets/{Multisig-zspLaMbT.js → Multisig-CCAxf4Ye.js} +3 -3
- package/src/assets/web-panel/assets/{NLProgramming-dJeUPDoq.js → NLProgramming-CptHKz-Q.js} +1 -1
- package/src/assets/web-panel/assets/{Notes-C4msiRQL.js → Notes-0uEp4DCJ.js} +3 -3
- package/src/assets/web-panel/assets/{NotificationSettings-MOCHM-qg.js → NotificationSettings-DthvrOLd.js} +1 -1
- package/src/assets/web-panel/assets/{OrderTableRenderer-CX0T66NM.js → OrderTableRenderer-CxXuPzZg.js} +1 -1
- package/src/assets/web-panel/assets/{Organization-DOZurBfk.js → Organization-BWf2tmQQ.js} +4 -4
- package/src/assets/web-panel/assets/{Overflow-qOT9BhUp.js → Overflow-BbvAtEth.js} +1 -1
- package/src/assets/web-panel/assets/{P2P-BMoy7Eo4.js → P2P-zBo6enit.js} +2 -2
- package/src/assets/web-panel/assets/{PdhVaultBrowser-ByyV1q-D.js → PdhVaultBrowser-D_LMQ4A4.js} +3 -3
- package/src/assets/web-panel/assets/{Permissions-6Qyro4ye.js → Permissions-C1ucb2ck.js} +4 -4
- package/src/assets/web-panel/assets/{PersonalDataHub-DR3DRNSX.js → PersonalDataHub-Bz64RddJ.js} +5 -5
- package/src/assets/web-panel/assets/{Pipeline-Cr6TTdud.js → Pipeline-DXJt3y3_.js} +1 -1
- package/src/assets/web-panel/assets/{Privacy-B70otG0l.js → Privacy-DiZ8b_ut.js} +1 -1
- package/src/assets/web-panel/assets/{ProjectInit-BHCqxoSk.js → ProjectInit-DfLKKrJ4.js} +2 -2
- package/src/assets/web-panel/assets/{ProjectSettings-B80GZpZk.js → ProjectSettings-Ct6kJuIY.js} +2 -2
- package/src/assets/web-panel/assets/{Projects-cq-b9-fQ.js → Projects-BBUMlZ3m.js} +1 -1
- package/src/assets/web-panel/assets/{Providers-dsVTimHa.js → Providers-DYVQPHvc.js} +1 -1
- package/src/assets/web-panel/assets/{QrScannerModal-DRJ8YepZ.js → QrScannerModal-23Il7iPp.js} +1 -1
- package/src/assets/web-panel/assets/{QuickAsk-BSXdEjIB.js → QuickAsk-WgOZKrv1.js} +1 -1
- package/src/assets/web-panel/assets/{Recommend-CQLJGyKC.js → Recommend-CRIka6xT.js} +1 -1
- package/src/assets/web-panel/assets/{RemoteSession-BF9WUFVZ.js → RemoteSession-DOy3GjVZ.js} +2 -2
- package/src/assets/web-panel/assets/{Reputation-Cy9o5tvW.js → Reputation-BXyi6xeR.js} +1 -1
- package/src/assets/web-panel/assets/{Row-BP346_3b.js → Row-CoMxuIcR.js} +1 -1
- package/src/assets/web-panel/assets/{RssFeed-BKulxXf3.js → RssFeed-87hPkoM6.js} +3 -3
- package/src/assets/web-panel/assets/{Search-EemQj2Dv.js → Search-B1EqFCO4.js} +1 -1
- package/src/assets/web-panel/assets/{Security-DcWPAwwk.js → Security-HcC41eGs.js} +4 -4
- package/src/assets/web-panel/assets/{Services-Bltqciay.js → Services-BqLwmvCM.js} +2 -2
- package/src/assets/web-panel/assets/{Skeleton-BwRyOGY8.js → Skeleton-CIMmjW4r.js} +1 -1
- package/src/assets/web-panel/assets/{Skills-D98qlvpJ.js → Skills-CgurezJU.js} +1 -1
- package/src/assets/web-panel/assets/{Sla-BUTtBMY0.js → Sla-CJuRuqPE.js} +1 -1
- package/src/assets/web-panel/assets/{SpeechSettings-C7kcY_98.js → SpeechSettings-BUwsbd1o.js} +1 -1
- package/src/assets/web-panel/assets/{SyncSettings-Bsk6lKvT.js → SyncSettings-qo04TOX-.js} +2 -2
- package/src/assets/web-panel/assets/Tasks-QEFENVsp.js +1 -0
- package/src/assets/web-panel/assets/{Templates-BUM6LwPs.js → Templates-D1PTczPW.js} +1 -1
- package/src/assets/web-panel/assets/{Tenant-D9TkOm7z.js → Tenant-Bi0FkEPR.js} +1 -1
- package/src/assets/web-panel/assets/{Terminal-CP8ZVErN.js → Terminal-DfSt3bIF.js} +2 -2
- package/src/assets/web-panel/assets/{TimelineRenderer-V3SoKZ1T.js → TimelineRenderer-B7bIVs4R.js} +1 -1
- package/src/assets/web-panel/assets/{Tokens-CCRlUTOA.js → Tokens-B6w5XrMb.js} +1 -1
- package/src/assets/web-panel/assets/{Trigger-CznUcPme.js → Trigger-XXVSDWiF.js} +1 -1
- package/src/assets/web-panel/assets/{Trust-D1GIk_NF.js → Trust-DYvlgcK-.js} +1 -1
- package/src/assets/web-panel/assets/{UkeySign-DHtvtyC-.js → UkeySign-XyYwJMBM.js} +1 -1
- package/src/assets/web-panel/assets/{VideoEditing-CVxdaJIq.js → VideoEditing-C47WbtHH.js} +1 -1
- package/src/assets/web-panel/assets/{Wallet-D221OjyE.js → Wallet-CYfqTj_C.js} +4 -4
- package/src/assets/web-panel/assets/{WebAuthn-Cw0-ESsq.js → WebAuthn-3AduFn1l.js} +3 -3
- package/src/assets/web-panel/assets/{WorkflowEditor-ZYScrBx3.js → WorkflowEditor-DHYEHjMJ.js} +1 -1
- package/src/assets/web-panel/assets/{chat-BU0e1obR.js → chat-AeehErSw.js} +1 -1
- package/src/assets/web-panel/assets/{colors-gzYweuha.js → colors-DKXJ8paX.js} +1 -1
- package/src/assets/web-panel/assets/{compact-item-ChAXal_k.js → compact-item-BOlCiomD.js} +1 -1
- package/src/assets/web-panel/assets/{createContext-of3FolD7.js → createContext-BAP6U85b.js} +1 -1
- package/src/assets/web-panel/assets/devWarning-rGldFhxo.js +1 -0
- package/src/assets/web-panel/assets/{hasIn-4PsK_Kx8.js → hasIn-BLmeL1Xe.js} +1 -1
- package/src/assets/web-panel/assets/{index-Cn1clrxx.js → index-B0IjlB9m.js} +1 -1
- package/src/assets/web-panel/assets/{index-BOeX7BzS.js → index-BAS2QqLn.js} +1 -1
- package/src/assets/web-panel/assets/{index-Cx4Z6nUl.js → index-BRcJlKSa.js} +1 -1
- package/src/assets/web-panel/assets/{index-DjRAIRX7.js → index-BSOenF5s.js} +1 -1
- package/src/assets/web-panel/assets/{index-Djfgsjfy.js → index-BTnp4Nt3.js} +1 -1
- package/src/assets/web-panel/assets/{index-BfI4dXbi.js → index-BhcpWl5z.js} +1 -1
- package/src/assets/web-panel/assets/{index-D_5LTPMH.js → index-Bn54FU3i.js} +1 -1
- package/src/assets/web-panel/assets/{index-CyDQNprx.js → index-Bpx54vfs.js} +1 -1
- package/src/assets/web-panel/assets/{index-DEXBckNR.js → index-Bs2O3f81.js} +1 -1
- package/src/assets/web-panel/assets/{index-Ef5YkVAn.js → index-Bt-FCVzh.js} +1 -1
- package/src/assets/web-panel/assets/{index-E8oDMSAo.js → index-BuUwKmEI.js} +1 -1
- package/src/assets/web-panel/assets/{index-BdxRVNPY.js → index-C5AKY6bJ.js} +1 -1
- package/src/assets/web-panel/assets/{index-Wr91cnWr.js → index-C8qi53Ki.js} +1 -1
- package/src/assets/web-panel/assets/{index-B5L7zddz.js → index-CFKzWIo8.js} +1 -1
- package/src/assets/web-panel/assets/{index-Dy0ojH6G.js → index-CRa4pAaM.js} +3 -3
- package/src/assets/web-panel/assets/{index-wo0De0iG.js → index-CaHhfpBi.js} +1 -1
- package/src/assets/web-panel/assets/{index-D-Zss5KL.js → index-CdNSmvog.js} +1 -1
- package/src/assets/web-panel/assets/{index-DEzjUgkl.js → index-CgtaOzMo.js} +1 -1
- package/src/assets/web-panel/assets/{index-DDYj14Q4.js → index-CiqeF0Pf.js} +1 -1
- package/src/assets/web-panel/assets/{index-D_9k680X.js → index-ClpwxOXo.js} +1 -1
- package/src/assets/web-panel/assets/{index-D1PGrfHE.js → index-Co7pjF53.js} +1 -1
- package/src/assets/web-panel/assets/index-Cw-lfvvV.js +1 -0
- package/src/assets/web-panel/assets/{index-CeEE_SGZ.js → index-DE7cbDDe.js} +1 -1
- package/src/assets/web-panel/assets/{index-CxzBcXOa.js → index-DQLQuwpA.js} +1 -1
- package/src/assets/web-panel/assets/{index-DEB5fQqG.js → index-DWYqOI1A.js} +1 -1
- package/src/assets/web-panel/assets/{index-CO2owKe0.js → index-De2fPxdb.js} +1 -1
- package/src/assets/web-panel/assets/{index-1dzYRBbg.js → index-DpZqbc4w.js} +1 -1
- package/src/assets/web-panel/assets/{index-CGFL59q4.js → index-DsQ38fVY.js} +1 -1
- package/src/assets/web-panel/assets/{index-DsoV9rzn.js → index-Dv8-g1pY.js} +1 -1
- package/src/assets/web-panel/assets/{index-yMf7zmWv.js → index-EKNODw4P.js} +1 -1
- package/src/assets/web-panel/assets/{index-CHv_63Cp.js → index-FPXLIXoy.js} +1 -1
- package/src/assets/web-panel/assets/{index-CCLsbul3.js → index-IlzfIRNh.js} +1 -1
- package/src/assets/web-panel/assets/{index-cFkMIx1x.js → index-OLKhib9T.js} +1 -1
- package/src/assets/web-panel/assets/{index-Bftq5rJR.js → index-PEe9OWEQ.js} +1 -1
- package/src/assets/web-panel/assets/index-QBXRSyoZ.js +1 -0
- package/src/assets/web-panel/assets/{index-DJVrzXtk.js → index-T28naovw.js} +1 -1
- package/src/assets/web-panel/assets/{index-By-pper5.js → index-ZMbXl5lo.js} +1 -1
- package/src/assets/web-panel/assets/{index-DZ0oKtBg.js → index-urPvyUVk.js} +1 -1
- package/src/assets/web-panel/assets/{index-D_ialOHx.js → index-wyKpTsGM.js} +1 -1
- package/src/assets/web-panel/assets/{initDefaultProps-D0Bx6pgr.js → initDefaultProps-CDWa1rnn.js} +1 -1
- package/src/assets/web-panel/assets/{motion-BnLuJqJ5.js → motion-CX2Cnsd5.js} +1 -1
- package/src/assets/web-panel/assets/{move-Bxpq9xgR.js → move-Bfe1NcEF.js} +1 -1
- package/src/assets/web-panel/assets/{mtc-parser-BdmrNhOs.js → mtc-parser-DbdqleHE.js} +1 -1
- package/src/assets/web-panel/assets/{omit-tjJD34BZ.js → omit-CE2K7NVv.js} +1 -1
- package/src/assets/web-panel/assets/{pickAttrs-CMFzLt7b.js → pickAttrs-y_bZgxWG.js} +1 -1
- package/src/assets/web-panel/assets/{placementArrow-BZf6O3cd.js → placementArrow-BOHR4zwr.js} +1 -1
- package/src/assets/web-panel/assets/{responsiveObserve-DFDLazsV.js → responsiveObserve-B8Jwq05-.js} +1 -1
- package/src/assets/web-panel/assets/{slide-CMbTvp4Y.js → slide-BD7RJ3Kn.js} +1 -1
- package/src/assets/web-panel/assets/{statusUtils-FOan8MI7.js → statusUtils-BuxDJeDx.js} +1 -1
- package/src/assets/web-panel/assets/{styleChecker-DTABspd4.js → styleChecker-DgYQ2Q0o.js} +1 -1
- package/src/assets/web-panel/assets/{useFlexGapSupport-CNHXWBpY.js → useFlexGapSupport-DAHF0Fwi.js} +1 -1
- package/src/assets/web-panel/assets/{useFs-5K-c_RoL.js → useFs-D4kDyLFp.js} +1 -1
- package/src/assets/web-panel/assets/{usePersonalDataHub-Di0hL4G-.js → usePersonalDataHub-BHtSxW4A.js} +1 -1
- package/src/assets/web-panel/assets/{vnode-DTyDv4ja.js → vnode-CHKtdqW0.js} +1 -1
- package/src/assets/web-panel/assets/{zoom-ontRt8ft.js → zoom-CIZAMma9.js} +1 -1
- package/src/assets/web-panel/index.html +1 -1
- package/src/command-help-index.json +1 -1
- package/src/commands/agent.js +64 -40
- package/src/commands/ask.js +6 -4
- package/src/commands/team.js +28 -19
- package/src/data/changelog.json +26 -0
- package/src/harness/prompt-compressor.js +2 -0
- package/src/lib/advisor-runtime.js +4 -2
- package/src/lib/agent-ipc-bus.js +2 -0
- package/src/lib/background-agent-keeper-client.js +3 -0
- package/src/lib/browser-automation.js +4 -0
- package/src/lib/cc-android-bridge.js +4 -0
- package/src/lib/chat-core.js +11 -9
- package/src/lib/cloud/cloud-client.js +10 -1
- package/src/lib/config-schema.js +18 -5
- package/src/lib/context-memory-kernel/memory-query-index.js +5 -2
- package/src/lib/context-memory-kernel/runtime.js +4 -0
- package/src/lib/context-memory-kernel/segmented-memory-port.js +28 -3
- package/src/lib/context-source-ledger.js +52 -9
- package/src/lib/cowork-adapter.js +4 -3
- package/src/lib/decision-layer/providers.js +16 -11
- package/src/lib/evolution/governed-hub-llm.js +31 -16
- package/src/lib/evolution/governed-hub-resolver.js +4 -0
- package/src/lib/evolution/governed-skill-synthesis-process-grader.js +4 -0
- package/src/lib/evomap-client.js +14 -2
- package/src/lib/formal-budget-authority.js +191 -59
- package/src/lib/formal-budget-contract.js +7 -13
- package/src/lib/formal-budget-errors.js +31 -0
- package/src/lib/formal-budget-lineage-registry.js +612 -0
- package/src/lib/formal-budget-provider-scope.js +143 -0
- package/src/lib/formal-budget-transport.js +235 -100
- package/src/lib/gateway-client-resilience.js +5 -0
- package/src/lib/goal-condition-engine.js +25 -2
- package/src/lib/hub-llm-client.js +25 -16
- package/src/lib/llm-config-defaults.js +10 -4
- package/src/lib/llm-connection-probe.js +17 -10
- package/src/lib/llm-pricing.js +16 -4
- package/src/lib/llm-providers.js +4 -1
- package/src/lib/model-capabilities.js +26 -0
- package/src/lib/model-catalog-review.js +18 -1
- package/src/lib/model-context-catalog.js +41 -1
- package/src/lib/model-failure-policy.js +2 -0
- package/src/lib/openai-responses.js +8 -0
- package/src/lib/plugin-runtime/marketplace-network.js +9 -5
- package/src/lib/process-execution-broker/credential-agent.js +7 -2
- package/src/lib/process-execution-broker/credential-transport.js +4 -0
- package/src/lib/process-execution-broker/index.js +8 -0
- package/src/lib/provider-stream.js +28 -13
- package/src/lib/sandbox-egress-worker.js +3 -0
- package/src/lib/skill-retrieval-router.js +1 -0
- package/src/lib/stream-retry.js +2 -0
- package/src/lib/sub-agent-context.js +6 -3
- package/src/lib/usage-pricing-context.js +33 -2
- package/src/lib/web-fetch.js +2 -0
- package/src/lib/web-search.js +5 -0
- package/src/repl/agent-repl.js +247 -153
- package/src/runtime/agent-core.js +228 -96
- package/src/runtime/coding-agent-contract-shared.cjs +14 -1
- package/src/runtime/headless-runner.js +1 -0
- package/src/runtime/headless-stream.js +1 -0
- package/src/runtime/mcp-tool-search.js +0 -0
- package/src/runtime/provider-stream-state.js +14 -1
- package/src/assets/web-panel/assets/ChatBubbleRenderer-D3KsyCUV.js +0 -1
- package/src/assets/web-panel/assets/MarkdownRenderer-C1yByobo.js +0 -1
- package/src/assets/web-panel/assets/Tasks-DvSrtz0P.js +0 -1
- package/src/assets/web-panel/assets/devWarning-Pa13TVrO.js +0 -1
- package/src/assets/web-panel/assets/index-BhQg-v6V.js +0 -1
- package/src/assets/web-panel/assets/index-DUD5o-vW.js +0 -1
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
providerFetch,
|
|
3
|
+
requireUnscopedToolExecution,
|
|
4
|
+
} from "../lib/formal-budget-provider-scope.js";
|
|
5
|
+
import { isFormalBudgetError } from "../lib/formal-budget-errors.js";
|
|
1
6
|
/**
|
|
2
7
|
* Agent Core — transport-independent agentic logic
|
|
3
8
|
*
|
|
@@ -61,7 +66,11 @@ import {
|
|
|
61
66
|
} from "../lib/task-progress-tracker.js";
|
|
62
67
|
import { TOOL_RECOVERY_PAUSED_CODE } from "../lib/tool-recovery-result.js";
|
|
63
68
|
import { haiku55ThinkingParams } from "../lib/provider-options.js";
|
|
64
|
-
import {
|
|
69
|
+
import {
|
|
70
|
+
projectUsagePricingContext,
|
|
71
|
+
projectEnvelopePricingContext,
|
|
72
|
+
preserveRequestedServiceTierEvidence,
|
|
73
|
+
} from "../lib/usage-pricing-context.js";
|
|
65
74
|
import broker from "../lib/process-execution-broker/index.js";
|
|
66
75
|
import os from "os";
|
|
67
76
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -88,6 +97,7 @@ import sharedHookEvents from "../lib/settings-hook-events.js";
|
|
|
88
97
|
import {
|
|
89
98
|
resolveAgentOutputBudget,
|
|
90
99
|
resolveModelCapabilityProfile,
|
|
100
|
+
resolveModelServiceTier,
|
|
91
101
|
} from "../lib/model-capabilities.js";
|
|
92
102
|
import {
|
|
93
103
|
createOpenAIResponsesBody,
|
|
@@ -1539,18 +1549,19 @@ function filesystemIdentity(stats) {
|
|
|
1539
1549
|
function sameFilesystemObjectIdentity(left, right) {
|
|
1540
1550
|
return Boolean(
|
|
1541
1551
|
left &&
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1552
|
+
right &&
|
|
1553
|
+
left.dev === right.dev &&
|
|
1554
|
+
left.ino === right.ino &&
|
|
1555
|
+
left.type === right.type,
|
|
1546
1556
|
);
|
|
1547
1557
|
}
|
|
1548
1558
|
|
|
1549
1559
|
function sameFilesystemIdentity(left, right, { content = false } = {}) {
|
|
1550
1560
|
return Boolean(
|
|
1551
1561
|
sameFilesystemObjectIdentity(left, right) &&
|
|
1552
|
-
|
|
1553
|
-
|
|
1562
|
+
left.nlink === right.nlink &&
|
|
1563
|
+
(!content ||
|
|
1564
|
+
(left.size === right.size && left.mtimeNs === right.mtimeNs)),
|
|
1554
1565
|
);
|
|
1555
1566
|
}
|
|
1556
1567
|
|
|
@@ -2607,6 +2618,7 @@ function snapshotApprovalPolicyAuthority(approvalGate, sessionId) {
|
|
|
2607
2618
|
* @returns {Promise<object>} tool result
|
|
2608
2619
|
*/
|
|
2609
2620
|
export async function executeTool(name, args, context = {}) {
|
|
2621
|
+
requireUnscopedToolExecution();
|
|
2610
2622
|
const liveExecutionContext = context;
|
|
2611
2623
|
try {
|
|
2612
2624
|
const executionPolicy = captureAgentExecutionPolicy(context);
|
|
@@ -3441,8 +3453,9 @@ export async function executeTool(name, args, context = {}) {
|
|
|
3441
3453
|
GUARDED_FILE_MUTATION_TOOLS.has(name) &&
|
|
3442
3454
|
settingsVerdict.decision !== "allow"
|
|
3443
3455
|
) {
|
|
3444
|
-
const { sensitiveFileReason, autoExecConfigReason } =
|
|
3445
|
-
|
|
3456
|
+
const { sensitiveFileReason, autoExecConfigReason } = await import(
|
|
3457
|
+
"../lib/sensitive-file-guard.js"
|
|
3458
|
+
);
|
|
3446
3459
|
const guarded = fileMutationPaths(name, args)
|
|
3447
3460
|
.map((candidatePath) => ({
|
|
3448
3461
|
path: candidatePath,
|
|
@@ -3477,8 +3490,9 @@ export async function executeTool(name, args, context = {}) {
|
|
|
3477
3490
|
GUARDED_FILE_MUTATION_TOOLS.has(name) &&
|
|
3478
3491
|
settingsVerdict.decision !== "allow"
|
|
3479
3492
|
) {
|
|
3480
|
-
const { sessionStorePathReason } =
|
|
3481
|
-
|
|
3493
|
+
const { sessionStorePathReason } = await import(
|
|
3494
|
+
"../lib/session-store-guard.js"
|
|
3495
|
+
);
|
|
3482
3496
|
const guarded = fileMutationPaths(name, args)
|
|
3483
3497
|
.map((candidatePath) => ({
|
|
3484
3498
|
path: candidatePath,
|
|
@@ -4223,8 +4237,9 @@ export async function executeTool(name, args, context = {}) {
|
|
|
4223
4237
|
context.externalToolExecutors
|
|
4224
4238
|
) {
|
|
4225
4239
|
try {
|
|
4226
|
-
const { collectIdeDiagnostics, formatIdeDiagnostics } =
|
|
4227
|
-
|
|
4240
|
+
const { collectIdeDiagnostics, formatIdeDiagnostics } = await import(
|
|
4241
|
+
"../lib/ide-context.js"
|
|
4242
|
+
);
|
|
4228
4243
|
const diags = await collectIdeDiagnostics(
|
|
4229
4244
|
{
|
|
4230
4245
|
mcpClient: context.mcpHostClient || context.mcpClient,
|
|
@@ -4766,8 +4781,9 @@ export async function _getSharedCodeIntel(cwd) {
|
|
|
4766
4781
|
const root = path.resolve(cwd || process.cwd());
|
|
4767
4782
|
let entry = _codeIntelPool.get(root);
|
|
4768
4783
|
if (!entry) {
|
|
4769
|
-
const { CodeIntelligence } =
|
|
4770
|
-
|
|
4784
|
+
const { CodeIntelligence } = await import(
|
|
4785
|
+
"../lib/lsp/code-intelligence.js"
|
|
4786
|
+
);
|
|
4771
4787
|
// Re-check AFTER the await: two concurrent callers (the parallel read-only
|
|
4772
4788
|
// batch runs several `code_intelligence` calls at once) both observed an
|
|
4773
4789
|
// empty pool before this `await import`, so without this guard both would
|
|
@@ -4856,8 +4872,9 @@ async function _postEditDiagnostics(filePath, cwd, additionalDirectories) {
|
|
|
4856
4872
|
}
|
|
4857
4873
|
let hasServer = false;
|
|
4858
4874
|
try {
|
|
4859
|
-
const { languageIdForFile, resolveServer } =
|
|
4860
|
-
|
|
4875
|
+
const { languageIdForFile, resolveServer } = await import(
|
|
4876
|
+
"../lib/lsp/lsp-server-registry.js"
|
|
4877
|
+
);
|
|
4861
4878
|
const languageId = languageIdForFile(filePath);
|
|
4862
4879
|
if (!languageId) return null; // unsupported file type — no LSP, no cost
|
|
4863
4880
|
hasServer = Boolean(resolveServer(languageId, root));
|
|
@@ -4880,8 +4897,9 @@ async function _postEditDiagnostics(filePath, cwd, additionalDirectories) {
|
|
|
4880
4897
|
// the model sees the most severe diagnostics first and can't be flooded by
|
|
4881
4898
|
// a pathological diagnostics dump. Budget is overridable via
|
|
4882
4899
|
// CC_EDIT_DIAGNOSTICS_TOKENS (default 2000).
|
|
4883
|
-
const { capDiagnostics } =
|
|
4884
|
-
|
|
4900
|
+
const { capDiagnostics } = await import(
|
|
4901
|
+
"../lib/lsp/diagnostics-scheduler.js"
|
|
4902
|
+
);
|
|
4885
4903
|
const budget = Number(process.env.CC_EDIT_DIAGNOSTICS_TOKENS) || 2000;
|
|
4886
4904
|
const { kept } = capDiagnostics(diags, { maxTokens: budget });
|
|
4887
4905
|
return kept.length ? kept : null;
|
|
@@ -4945,12 +4963,14 @@ async function _getSubtreeLoader(cwd, sessionScope = "__legacy__") {
|
|
|
4945
4963
|
}
|
|
4946
4964
|
let loader = scopedLoaders.get(sessionScope);
|
|
4947
4965
|
if (!loader) {
|
|
4948
|
-
const { SubtreeInstructionLoader } =
|
|
4949
|
-
|
|
4966
|
+
const { SubtreeInstructionLoader } = await import(
|
|
4967
|
+
"../lib/project-instructions.js"
|
|
4968
|
+
);
|
|
4950
4969
|
let instructionExcludes;
|
|
4951
4970
|
try {
|
|
4952
|
-
const { readStringArraySetting } =
|
|
4953
|
-
|
|
4971
|
+
const { readStringArraySetting } = await import(
|
|
4972
|
+
"../lib/settings-loader.cjs"
|
|
4973
|
+
);
|
|
4954
4974
|
instructionExcludes = readStringArraySetting("instructionExcludes", {
|
|
4955
4975
|
cwd: root,
|
|
4956
4976
|
});
|
|
@@ -4995,8 +5015,9 @@ async function _prepareSubtreeInstructions(
|
|
|
4995
5015
|
}
|
|
4996
5016
|
const fresh = [...discovered.values()];
|
|
4997
5017
|
if (!fresh || !fresh.length) return null;
|
|
4998
|
-
const { DEFAULT_MAX_FILE_BYTES } =
|
|
4999
|
-
|
|
5018
|
+
const { DEFAULT_MAX_FILE_BYTES } = await import(
|
|
5019
|
+
"../lib/project-instructions.js"
|
|
5020
|
+
);
|
|
5000
5021
|
const out = [];
|
|
5001
5022
|
const errors = [];
|
|
5002
5023
|
for (const f of fresh) {
|
|
@@ -5103,8 +5124,9 @@ async function _withSubtreeInstructions(
|
|
|
5103
5124
|
async function filterSkillsByCwd(skills, cwd) {
|
|
5104
5125
|
try {
|
|
5105
5126
|
if (!Array.isArray(skills) || skills.every((s) => !s?.paths)) return skills;
|
|
5106
|
-
const { filterSkillsByRelCwd, relCwdForCwd } =
|
|
5107
|
-
|
|
5127
|
+
const { filterSkillsByRelCwd, relCwdForCwd } = await import(
|
|
5128
|
+
"../lib/skill-path-scope.js"
|
|
5129
|
+
);
|
|
5108
5130
|
const { findProjectRoot } = await import("../lib/project-detector.js");
|
|
5109
5131
|
const root = (cwd && findProjectRoot(cwd)) || cwd || "";
|
|
5110
5132
|
return filterSkillsByRelCwd(skills, relCwdForCwd(cwd, root));
|
|
@@ -5119,8 +5141,9 @@ async function promoteBrowserGeneratedArtifact(
|
|
|
5119
5141
|
) {
|
|
5120
5142
|
if (!filePath) return { artifact: null, error: null };
|
|
5121
5143
|
try {
|
|
5122
|
-
const { ArtifactStore, publicArtifactMetadata } =
|
|
5123
|
-
|
|
5144
|
+
const { ArtifactStore, publicArtifactMetadata } = await import(
|
|
5145
|
+
"../lib/artifact-store.js"
|
|
5146
|
+
);
|
|
5124
5147
|
const entry = new ArtifactStore().publish({
|
|
5125
5148
|
filePath,
|
|
5126
5149
|
title,
|
|
@@ -5173,8 +5196,9 @@ async function promoteBrowserDownload(
|
|
|
5173
5196
|
async function publishBrowserEvidence(envelope, sessionId) {
|
|
5174
5197
|
if (!envelope?.envelopeDigest) return { artifact: null, error: null };
|
|
5175
5198
|
try {
|
|
5176
|
-
const { ArtifactStore, publicArtifactMetadata } =
|
|
5177
|
-
|
|
5199
|
+
const { ArtifactStore, publicArtifactMetadata } = await import(
|
|
5200
|
+
"../lib/artifact-store.js"
|
|
5201
|
+
);
|
|
5178
5202
|
const {
|
|
5179
5203
|
browserEvidenceDigest,
|
|
5180
5204
|
canonicalBrowserEvidenceJson,
|
|
@@ -5237,8 +5261,9 @@ async function publishBrowserEvidence(envelope, sessionId) {
|
|
|
5237
5261
|
}
|
|
5238
5262
|
|
|
5239
5263
|
async function resolveBrowserUploadArtifact(artifactId, sessionId) {
|
|
5240
|
-
const { ArtifactStore, publicArtifactMetadata } =
|
|
5241
|
-
|
|
5264
|
+
const { ArtifactStore, publicArtifactMetadata } = await import(
|
|
5265
|
+
"../lib/artifact-store.js"
|
|
5266
|
+
);
|
|
5242
5267
|
const store = new ArtifactStore();
|
|
5243
5268
|
return store.withIndexSnapshot((entries) => {
|
|
5244
5269
|
const matches = entries.filter((entry) => entry.id === artifactId);
|
|
@@ -6219,8 +6244,9 @@ async function executeToolInner(
|
|
|
6219
6244
|
// through PowerShell via explicit argv (`powershell.exe -NoProfile
|
|
6220
6245
|
// [-ExecutionPolicy <p>] -Command <cmd>`). The unconfigured path keeps
|
|
6221
6246
|
// the historical default shell byte-identical (useDefaultShell=true).
|
|
6222
|
-
const { resolveShellInvocation } =
|
|
6223
|
-
|
|
6247
|
+
const { resolveShellInvocation } = await import(
|
|
6248
|
+
"../lib/shell-selector.cjs"
|
|
6249
|
+
);
|
|
6224
6250
|
let shellInv = resolveShellInvocation({
|
|
6225
6251
|
command: args.command,
|
|
6226
6252
|
requested: args.shell,
|
|
@@ -6993,8 +7019,9 @@ async function executeToolInner(
|
|
|
6993
7019
|
let removeSettingsAuthorityListener = null;
|
|
6994
7020
|
if (needsEgress) {
|
|
6995
7021
|
try {
|
|
6996
|
-
const { startEgressProxyWorker } =
|
|
6997
|
-
|
|
7022
|
+
const { startEgressProxyWorker } = await import(
|
|
7023
|
+
"../lib/sandbox-egress-worker.js"
|
|
7024
|
+
);
|
|
6998
7025
|
if (dockerEgress) {
|
|
6999
7026
|
privateSocketDir = fs.mkdtempSync(
|
|
7000
7027
|
path.join(os.tmpdir(), "cc-egress-"),
|
|
@@ -7035,8 +7062,9 @@ async function executeToolInner(
|
|
|
7035
7062
|
// Proxy startup and dynamic imports are asynchronous. Re-read the
|
|
7036
7063
|
// live authority after they settle and before sandbox dispatch.
|
|
7037
7064
|
if (dockerEgress && proxyHandle?.socketPath) {
|
|
7038
|
-
const { createDockerEgressAuthorityMonitor } =
|
|
7039
|
-
|
|
7065
|
+
const { createDockerEgressAuthorityMonitor } = await import(
|
|
7066
|
+
"../lib/sandbox-egress-authority-monitor.js"
|
|
7067
|
+
);
|
|
7040
7068
|
authorityMonitor = createDockerEgressAuthorityMonitor({
|
|
7041
7069
|
sessionId: sessionId || null,
|
|
7042
7070
|
policyVersion:
|
|
@@ -7656,8 +7684,9 @@ async function executeToolInner(
|
|
|
7656
7684
|
!ruleAllowed &&
|
|
7657
7685
|
typeof approvalGate.decide === "function"
|
|
7658
7686
|
) {
|
|
7659
|
-
const { APPROVAL_RISK, APPROVAL_DECISION } =
|
|
7660
|
-
|
|
7687
|
+
const { APPROVAL_RISK, APPROVAL_DECISION } = await import(
|
|
7688
|
+
"@chainlesschain/session-core"
|
|
7689
|
+
);
|
|
7661
7690
|
const gate = await approvalGate.decide({
|
|
7662
7691
|
sessionId,
|
|
7663
7692
|
riskLevel: APPROVAL_RISK.HIGH,
|
|
@@ -7828,6 +7857,7 @@ async function executeToolInner(
|
|
|
7828
7857
|
});
|
|
7829
7858
|
return attachDescriptor(result);
|
|
7830
7859
|
} catch (err) {
|
|
7860
|
+
if (isFormalBudgetError(err)) throw err;
|
|
7831
7861
|
return attachDescriptor({ error: `web_search failed: ${err.message}` });
|
|
7832
7862
|
}
|
|
7833
7863
|
}
|
|
@@ -7868,8 +7898,9 @@ async function executeToolInner(
|
|
|
7868
7898
|
|
|
7869
7899
|
case "slash_command": {
|
|
7870
7900
|
try {
|
|
7871
|
-
const { getCommand, expandCommand, discoverCommands } =
|
|
7872
|
-
|
|
7901
|
+
const { getCommand, expandCommand, discoverCommands } = await import(
|
|
7902
|
+
"../lib/slash-commands.js"
|
|
7903
|
+
);
|
|
7873
7904
|
const raw = String(args.command || "").trim();
|
|
7874
7905
|
if (!raw) {
|
|
7875
7906
|
return attachDescriptor({
|
|
@@ -8080,8 +8111,9 @@ async function executeToolInner(
|
|
|
8080
8111
|
|
|
8081
8112
|
case "notify": {
|
|
8082
8113
|
try {
|
|
8083
|
-
const { sendAgentNotification } =
|
|
8084
|
-
|
|
8114
|
+
const { sendAgentNotification } = await import(
|
|
8115
|
+
"../lib/agent-notify.js"
|
|
8116
|
+
);
|
|
8085
8117
|
const outcome = await sendAgentNotification({
|
|
8086
8118
|
title: args.title,
|
|
8087
8119
|
body: args.body,
|
|
@@ -8095,8 +8127,9 @@ async function executeToolInner(
|
|
|
8095
8127
|
|
|
8096
8128
|
case "schedule": {
|
|
8097
8129
|
try {
|
|
8098
|
-
const { AgentScheduleStore } =
|
|
8099
|
-
|
|
8130
|
+
const { AgentScheduleStore } = await import(
|
|
8131
|
+
"../lib/agent-schedule-store.js"
|
|
8132
|
+
);
|
|
8100
8133
|
const { parseDuration } = await import("../lib/loop.js");
|
|
8101
8134
|
const store = new AgentScheduleStore();
|
|
8102
8135
|
const action = String(args.action || "").toLowerCase();
|
|
@@ -8219,8 +8252,9 @@ async function executeToolInner(
|
|
|
8219
8252
|
// Only METADATA returns to the conversation (the transcript never
|
|
8220
8253
|
// carries the file body); `cc artifacts` lists/inspects/cleans.
|
|
8221
8254
|
try {
|
|
8222
|
-
const { ArtifactStore, publicArtifactMetadata } =
|
|
8223
|
-
|
|
8255
|
+
const { ArtifactStore, publicArtifactMetadata } = await import(
|
|
8256
|
+
"../lib/artifact-store.js"
|
|
8257
|
+
);
|
|
8224
8258
|
const store = new ArtifactStore();
|
|
8225
8259
|
const entry = store.publish({
|
|
8226
8260
|
filePath: path.resolve(cwd, String(args.path || "")),
|
|
@@ -8310,8 +8344,9 @@ async function executeToolInner(
|
|
|
8310
8344
|
!ruleAllowed &&
|
|
8311
8345
|
typeof approvalGate.decide === "function"
|
|
8312
8346
|
) {
|
|
8313
|
-
const { APPROVAL_RISK, APPROVAL_DECISION } =
|
|
8314
|
-
|
|
8347
|
+
const { APPROVAL_RISK, APPROVAL_DECISION } = await import(
|
|
8348
|
+
"@chainlesschain/session-core"
|
|
8349
|
+
);
|
|
8315
8350
|
const summary = Array.isArray(args.actions)
|
|
8316
8351
|
? args.actions
|
|
8317
8352
|
.map((a) => a?.type)
|
|
@@ -8436,8 +8471,9 @@ async function executeToolInner(
|
|
|
8436
8471
|
case "search_files": {
|
|
8437
8472
|
if (typeof args.path === "string" && args.path.length > 0) {
|
|
8438
8473
|
const file = path.resolve(cwd, args.path);
|
|
8439
|
-
const { credentialFileReason } =
|
|
8440
|
-
|
|
8474
|
+
const { credentialFileReason } = await import(
|
|
8475
|
+
"../lib/credential-guard.js"
|
|
8476
|
+
);
|
|
8441
8477
|
const reason =
|
|
8442
8478
|
credentialFileReason(file) ||
|
|
8443
8479
|
(fs.existsSync(file)
|
|
@@ -9143,6 +9179,7 @@ async function executeToolInner(
|
|
|
9143
9179
|
} catch (err) {
|
|
9144
9180
|
if (
|
|
9145
9181
|
isEvolutionIngressFailure(err) ||
|
|
9182
|
+
isFormalBudgetError(err) ||
|
|
9146
9183
|
err?.runtimeLedgerPersistence === true ||
|
|
9147
9184
|
err?.workflowEffectOutcomeUnknown === true
|
|
9148
9185
|
) {
|
|
@@ -9182,6 +9219,22 @@ async function executeToolInner(
|
|
|
9182
9219
|
}
|
|
9183
9220
|
|
|
9184
9221
|
case "list_skills": {
|
|
9222
|
+
const limit = args.limit ?? 20;
|
|
9223
|
+
const offset = args.offset ?? 0;
|
|
9224
|
+
if (
|
|
9225
|
+
!Number.isSafeInteger(limit) ||
|
|
9226
|
+
limit < 1 ||
|
|
9227
|
+
limit > 64 ||
|
|
9228
|
+
!Number.isSafeInteger(offset) ||
|
|
9229
|
+
offset < 0 ||
|
|
9230
|
+
offset > 10_000
|
|
9231
|
+
) {
|
|
9232
|
+
return attachDescriptor({
|
|
9233
|
+
error:
|
|
9234
|
+
"Skill directory limit must be 1–64 and offset must be 0–10000.",
|
|
9235
|
+
code: "CC_SKILL_DIRECTORY_PAGE_INVALID",
|
|
9236
|
+
});
|
|
9237
|
+
}
|
|
9185
9238
|
let skills = await filterSkillsByCwd(
|
|
9186
9239
|
skillLoader.getResolvedSkills().filter(skillAllowed),
|
|
9187
9240
|
cwd,
|
|
@@ -9271,6 +9324,19 @@ async function executeToolInner(
|
|
|
9271
9324
|
}
|
|
9272
9325
|
}
|
|
9273
9326
|
}
|
|
9327
|
+
if (!routing) {
|
|
9328
|
+
const key = (skill) =>
|
|
9329
|
+
`${skill.id}\u0000${skill.source || ""}\u0000${skill.executionIdentity?.contentDigest || ""}`;
|
|
9330
|
+
skills = [...skills].sort((left, right) =>
|
|
9331
|
+
key(left) < key(right) ? -1 : key(left) > key(right) ? 1 : 0,
|
|
9332
|
+
);
|
|
9333
|
+
}
|
|
9334
|
+
const totalCount = routing?.matchedCount ?? skills.length;
|
|
9335
|
+
const candidateCount = skills.length;
|
|
9336
|
+
skills = skills.slice(offset, offset + limit);
|
|
9337
|
+
const nextOffset =
|
|
9338
|
+
offset + skills.length < candidateCount ? offset + skills.length : null;
|
|
9339
|
+
const hasMore = offset + skills.length < totalCount;
|
|
9274
9340
|
skillLoader.recordDescriptorUse?.(skills, {
|
|
9275
9341
|
sessionId,
|
|
9276
9342
|
turnId,
|
|
@@ -9278,6 +9344,19 @@ async function executeToolInner(
|
|
|
9278
9344
|
});
|
|
9279
9345
|
return attachDescriptor({
|
|
9280
9346
|
count: skills.length,
|
|
9347
|
+
totalCount,
|
|
9348
|
+
offset,
|
|
9349
|
+
limit,
|
|
9350
|
+
hasMore,
|
|
9351
|
+
nextOffset,
|
|
9352
|
+
...(hasMore
|
|
9353
|
+
? {
|
|
9354
|
+
hint:
|
|
9355
|
+
nextOffset == null
|
|
9356
|
+
? "Refine query or category to search beyond the top 64 matches."
|
|
9357
|
+
: "Use nextOffset for the next page, or query/category to narrow the directory.",
|
|
9358
|
+
}
|
|
9359
|
+
: {}),
|
|
9281
9360
|
...(routing
|
|
9282
9361
|
? {
|
|
9283
9362
|
routing: {
|
|
@@ -10572,6 +10651,7 @@ function _throwBackgroundSubAgentUsageFailure(entry) {
|
|
|
10572
10651
|
const error = entry?.outcome?.fatalError;
|
|
10573
10652
|
if (
|
|
10574
10653
|
isEvolutionIngressFailure(error) ||
|
|
10654
|
+
isFormalBudgetError(error) ||
|
|
10575
10655
|
error?.runtimeLedgerPersistence === true ||
|
|
10576
10656
|
error?.workflowEffectOutcomeUnknown === true
|
|
10577
10657
|
) {
|
|
@@ -10701,8 +10781,9 @@ async function _executeSpawnSubAgent(args, ctx) {
|
|
|
10701
10781
|
// the breadth counter increments so spawnedCount is this-spawn-exclusive.
|
|
10702
10782
|
if (ctx.subAgentContract) {
|
|
10703
10783
|
try {
|
|
10704
|
-
const { enforceRecursionLimits } =
|
|
10705
|
-
|
|
10784
|
+
const { enforceRecursionLimits } = await import(
|
|
10785
|
+
"../lib/subagent-contract.js"
|
|
10786
|
+
);
|
|
10706
10787
|
const recur = enforceRecursionLimits({
|
|
10707
10788
|
depth: currentDepth,
|
|
10708
10789
|
spawnedCount: ctx.subAgentBudget?.spawned || 0,
|
|
@@ -10888,8 +10969,9 @@ async function _executeSpawnSubAgent(args, ctx) {
|
|
|
10888
10969
|
let inheritedMcp = null;
|
|
10889
10970
|
let inheritedHooks = null;
|
|
10890
10971
|
try {
|
|
10891
|
-
const { filterInheritedMcp, filterInheritedHooks } =
|
|
10892
|
-
|
|
10972
|
+
const { filterInheritedMcp, filterInheritedHooks } = await import(
|
|
10973
|
+
"../lib/subagent-inheritance.js"
|
|
10974
|
+
);
|
|
10893
10975
|
inheritedMcp = filterInheritedMcp(
|
|
10894
10976
|
{
|
|
10895
10977
|
extraToolDefinitions: ctx.extraToolDefinitions,
|
|
@@ -10922,8 +11004,9 @@ async function _executeSpawnSubAgent(args, ctx) {
|
|
|
10922
11004
|
// repo, refuse the spawn instead of silently running in the parent checkout.
|
|
10923
11005
|
if (subIsolation === "worktree") {
|
|
10924
11006
|
try {
|
|
10925
|
-
const { resolveIsolationFailClosed } =
|
|
10926
|
-
|
|
11007
|
+
const { resolveIsolationFailClosed } = await import(
|
|
11008
|
+
"../lib/subagent-contract.js"
|
|
11009
|
+
);
|
|
10927
11010
|
const { isGitRepo } = await import("../lib/git-integration.js");
|
|
10928
11011
|
const iso = resolveIsolationFailClosed({
|
|
10929
11012
|
requested: "worktree",
|
|
@@ -10942,8 +11025,9 @@ async function _executeSpawnSubAgent(args, ctx) {
|
|
|
10942
11025
|
let profile = null;
|
|
10943
11026
|
if (profileName) {
|
|
10944
11027
|
try {
|
|
10945
|
-
const { getSubAgentProfile } =
|
|
10946
|
-
|
|
11028
|
+
const { getSubAgentProfile } = await import(
|
|
11029
|
+
"../lib/sub-agent-profiles.js"
|
|
11030
|
+
);
|
|
10947
11031
|
profile = getSubAgentProfile(profileName);
|
|
10948
11032
|
if (!profile) {
|
|
10949
11033
|
return {
|
|
@@ -11011,8 +11095,9 @@ async function _executeSpawnSubAgent(args, ctx) {
|
|
|
11011
11095
|
let childApprovalGate = null;
|
|
11012
11096
|
if (effectiveContract?.permissionMode) {
|
|
11013
11097
|
try {
|
|
11014
|
-
const { resolvePermissionMode, resolveEnabledTools } =
|
|
11015
|
-
|
|
11098
|
+
const { resolvePermissionMode, resolveEnabledTools } = await import(
|
|
11099
|
+
"./headless-runner.js"
|
|
11100
|
+
);
|
|
11016
11101
|
const perm = resolvePermissionMode(effectiveContract.permissionMode);
|
|
11017
11102
|
if (perm.readOnly) {
|
|
11018
11103
|
allowedTools = resolveEnabledTools({ allowedTools, readOnly: true });
|
|
@@ -11272,8 +11357,9 @@ async function _executeSpawnSubAgent(args, ctx) {
|
|
|
11272
11357
|
let subWorktreeOptions = null;
|
|
11273
11358
|
if (subIsolation === "worktree") {
|
|
11274
11359
|
try {
|
|
11275
|
-
const { normalizeSparsePaths } =
|
|
11276
|
-
|
|
11360
|
+
const { normalizeSparsePaths } = await import(
|
|
11361
|
+
"../lib/worktree-sparse.js"
|
|
11362
|
+
);
|
|
11277
11363
|
const sparse = normalizeSparsePaths(
|
|
11278
11364
|
args.sparsePaths ?? mdSparsePaths ?? null,
|
|
11279
11365
|
);
|
|
@@ -11475,10 +11561,11 @@ async function _executeSpawnSubAgent(args, ctx) {
|
|
|
11475
11561
|
|
|
11476
11562
|
// Resolve the registry ONCE before the try so the failure path can also move
|
|
11477
11563
|
// the sub-agent out of `_active` (the success path does this via complete()).
|
|
11478
|
-
const { SubAgentRegistry } =
|
|
11479
|
-
|
|
11480
|
-
|
|
11481
|
-
|
|
11564
|
+
const { SubAgentRegistry } = await import(
|
|
11565
|
+
"../lib/sub-agent-registry.js"
|
|
11566
|
+
).catch(() => ({
|
|
11567
|
+
SubAgentRegistry: null,
|
|
11568
|
+
}));
|
|
11482
11569
|
let registry = null;
|
|
11483
11570
|
if (SubAgentRegistry) {
|
|
11484
11571
|
try {
|
|
@@ -11543,6 +11630,7 @@ async function _executeSpawnSubAgent(args, ctx) {
|
|
|
11543
11630
|
result: subCtx.result,
|
|
11544
11631
|
error: err.message,
|
|
11545
11632
|
...(isEvolutionIngressFailure(err) ||
|
|
11633
|
+
isFormalBudgetError(err) ||
|
|
11546
11634
|
err?.runtimeLedgerPersistence === true ||
|
|
11547
11635
|
err?.workflowEffectOutcomeUnknown === true
|
|
11548
11636
|
? { fatalError: err }
|
|
@@ -11679,6 +11767,7 @@ async function _executeSpawnSubAgent(args, ctx) {
|
|
|
11679
11767
|
|
|
11680
11768
|
if (
|
|
11681
11769
|
isEvolutionIngressFailure(err) ||
|
|
11770
|
+
isFormalBudgetError(err) ||
|
|
11682
11771
|
err?.runtimeLedgerPersistence === true ||
|
|
11683
11772
|
err?.workflowEffectOutcomeUnknown === true
|
|
11684
11773
|
) {
|
|
@@ -11798,6 +11887,12 @@ function _openAIProviderRequestReceipt(response, data, clientRequestId) {
|
|
|
11798
11887
|
* @returns {Promise<object>} response with .message
|
|
11799
11888
|
*/
|
|
11800
11889
|
export async function chatWithTools(rawMessages, options) {
|
|
11890
|
+
if (options.serviceTier != null) {
|
|
11891
|
+
resolveModelServiceTier(
|
|
11892
|
+
resolveModelCapabilityProfile(options),
|
|
11893
|
+
options.serviceTier,
|
|
11894
|
+
);
|
|
11895
|
+
}
|
|
11801
11896
|
const evolutionIngress =
|
|
11802
11897
|
options.evolutionIngress == null
|
|
11803
11898
|
? null
|
|
@@ -11827,8 +11922,9 @@ export async function chatWithTools(rawMessages, options) {
|
|
|
11827
11922
|
options.contextMemoryPreplanned !== true &&
|
|
11828
11923
|
options.contextMemorySkipPlanning !== true
|
|
11829
11924
|
) {
|
|
11830
|
-
const { prepareCanonicalProviderContext } =
|
|
11831
|
-
|
|
11925
|
+
const { prepareCanonicalProviderContext } = await import(
|
|
11926
|
+
"../lib/context-memory-kernel/provider-context.js"
|
|
11927
|
+
);
|
|
11832
11928
|
const prepared = await prepareCanonicalProviderContext(rawMessages, {
|
|
11833
11929
|
...options,
|
|
11834
11930
|
contextMemoryToolDefinitions: tools,
|
|
@@ -11915,7 +12011,7 @@ export async function chatWithTools(rawMessages, options) {
|
|
|
11915
12011
|
},
|
|
11916
12012
|
);
|
|
11917
12013
|
}
|
|
11918
|
-
const response = await
|
|
12014
|
+
const response = await providerFetch(apiUrl, {
|
|
11919
12015
|
method: "POST",
|
|
11920
12016
|
headers: { "Content-Type": "application/json" },
|
|
11921
12017
|
signal,
|
|
@@ -12071,7 +12167,7 @@ export async function chatWithTools(rawMessages, options) {
|
|
|
12071
12167
|
);
|
|
12072
12168
|
}
|
|
12073
12169
|
|
|
12074
|
-
const response = await
|
|
12170
|
+
const response = await providerFetch(`${url}/messages`, {
|
|
12075
12171
|
method: "POST",
|
|
12076
12172
|
headers: {
|
|
12077
12173
|
"Content-Type": "application/json",
|
|
@@ -12190,6 +12286,7 @@ export async function chatWithTools(rawMessages, options) {
|
|
|
12190
12286
|
reasoning: _openAIResponsesReasoningParams(options, modelProfile),
|
|
12191
12287
|
stream: typeof options.onToken === "function",
|
|
12192
12288
|
modelProfile,
|
|
12289
|
+
serviceTier: options.serviceTier,
|
|
12193
12290
|
});
|
|
12194
12291
|
if (typeof options.onToken === "function") {
|
|
12195
12292
|
return await _retryStreamingChat(
|
|
@@ -12226,7 +12323,7 @@ export async function chatWithTools(rawMessages, options) {
|
|
|
12226
12323
|
);
|
|
12227
12324
|
}
|
|
12228
12325
|
|
|
12229
|
-
const response = await
|
|
12326
|
+
const response = await providerFetch(`${url}/responses`, {
|
|
12230
12327
|
method: "POST",
|
|
12231
12328
|
headers: {
|
|
12232
12329
|
"Content-Type": "application/json",
|
|
@@ -12243,6 +12340,11 @@ export async function chatWithTools(rawMessages, options) {
|
|
|
12243
12340
|
}
|
|
12244
12341
|
const data = await response.json();
|
|
12245
12342
|
const out = normalizeOpenAIResponsesResponse(data);
|
|
12343
|
+
if (out.usage)
|
|
12344
|
+
out.usage = preserveRequestedServiceTierEvidence(
|
|
12345
|
+
out.usage,
|
|
12346
|
+
options.serviceTier,
|
|
12347
|
+
);
|
|
12246
12348
|
delete out.responseId;
|
|
12247
12349
|
const providerReceipt = supportsOpenAIRequestIdentity
|
|
12248
12350
|
? _openAIProviderRequestReceipt(response, data, providerRequestId)
|
|
@@ -12299,7 +12401,7 @@ export async function chatWithTools(rawMessages, options) {
|
|
|
12299
12401
|
);
|
|
12300
12402
|
}
|
|
12301
12403
|
|
|
12302
|
-
const response = await
|
|
12404
|
+
const response = await providerFetch(`${url}/chat/completions`, {
|
|
12303
12405
|
method: "POST",
|
|
12304
12406
|
headers: {
|
|
12305
12407
|
"Content-Type": "application/json",
|
|
@@ -12379,6 +12481,7 @@ export async function chatWithTools(rawMessages, options) {
|
|
|
12379
12481
|
input_tokens: promptTokens - cached,
|
|
12380
12482
|
output_tokens: completionTokens,
|
|
12381
12483
|
cache_read_input_tokens: cached,
|
|
12484
|
+
...projectEnvelopePricingContext(data.usage, data),
|
|
12382
12485
|
};
|
|
12383
12486
|
}
|
|
12384
12487
|
}
|
|
@@ -12535,6 +12638,7 @@ export function _streamErrorDisposition(
|
|
|
12535
12638
|
partialText,
|
|
12536
12639
|
visible = false,
|
|
12537
12640
|
) {
|
|
12641
|
+
if (isFormalBudgetError(err)) return "rethrow";
|
|
12538
12642
|
if (err?.isOutputBackpressureFailure === true) return "rethrow";
|
|
12539
12643
|
if (isAbortError(err)) return "rethrow";
|
|
12540
12644
|
if (signal && signal.aborted) return "rethrow";
|
|
@@ -12779,7 +12883,7 @@ async function _chatOllamaStreaming(
|
|
|
12779
12883
|
stallMs,
|
|
12780
12884
|
stallTimeoutMs,
|
|
12781
12885
|
) {
|
|
12782
|
-
const response = await
|
|
12886
|
+
const response = await providerFetch(apiUrl, {
|
|
12783
12887
|
method: "POST",
|
|
12784
12888
|
headers: { "Content-Type": "application/json" },
|
|
12785
12889
|
signal,
|
|
@@ -12841,7 +12945,7 @@ async function _chatAnthropicStreaming(
|
|
|
12841
12945
|
stallMs,
|
|
12842
12946
|
stallTimeoutMs,
|
|
12843
12947
|
) {
|
|
12844
|
-
const response = await
|
|
12948
|
+
const response = await providerFetch(apiUrl, {
|
|
12845
12949
|
method: "POST",
|
|
12846
12950
|
headers: { "Content-Type": "application/json", ...extraHeaders },
|
|
12847
12951
|
signal,
|
|
@@ -12908,7 +13012,7 @@ async function _chatOpenAIStreaming(
|
|
|
12908
13012
|
stallTimeoutMs,
|
|
12909
13013
|
providerRequestId = null,
|
|
12910
13014
|
) {
|
|
12911
|
-
const response = await
|
|
13015
|
+
const response = await providerFetch(apiUrl, {
|
|
12912
13016
|
method: "POST",
|
|
12913
13017
|
headers: {
|
|
12914
13018
|
"Content-Type": "application/json",
|
|
@@ -12991,7 +13095,7 @@ async function _chatOpenAIResponsesStreaming(
|
|
|
12991
13095
|
stallTimeoutMs,
|
|
12992
13096
|
providerRequestId = null,
|
|
12993
13097
|
) {
|
|
12994
|
-
const response = await
|
|
13098
|
+
const response = await providerFetch(apiUrl, {
|
|
12995
13099
|
method: "POST",
|
|
12996
13100
|
headers: {
|
|
12997
13101
|
"Content-Type": "application/json",
|
|
@@ -13067,6 +13171,11 @@ async function _chatOpenAIResponsesStreaming(
|
|
|
13067
13171
|
return out;
|
|
13068
13172
|
}
|
|
13069
13173
|
const out = finalizeOpenAIResponsesStream(state);
|
|
13174
|
+
if (out.usage)
|
|
13175
|
+
out.usage = preserveRequestedServiceTierEvidence(
|
|
13176
|
+
out.usage,
|
|
13177
|
+
body.service_tier,
|
|
13178
|
+
);
|
|
13070
13179
|
const responseId = out.responseId || state.responseId;
|
|
13071
13180
|
delete out.responseId;
|
|
13072
13181
|
const providerReceipt = _openAIProviderRequestReceipt(
|
|
@@ -13988,8 +14097,9 @@ async function _getAutoCompactor(options) {
|
|
|
13988
14097
|
let canonicalRequired = false;
|
|
13989
14098
|
try {
|
|
13990
14099
|
const { feature } = await import("../lib/feature-flags.js");
|
|
13991
|
-
const { resolveCliContextMemoryCutover } =
|
|
13992
|
-
|
|
14100
|
+
const { resolveCliContextMemoryCutover } = await import(
|
|
14101
|
+
"../lib/context-memory-kernel/authority.js"
|
|
14102
|
+
);
|
|
13993
14103
|
const cutover = resolveCliContextMemoryCutover({
|
|
13994
14104
|
env: options.contextMemoryEnv || process.env,
|
|
13995
14105
|
scopeKey: options.sessionId
|
|
@@ -13998,8 +14108,9 @@ async function _getAutoCompactor(options) {
|
|
|
13998
14108
|
});
|
|
13999
14109
|
canonicalRequired = cutover.canonical;
|
|
14000
14110
|
if (feature("PROMPT_COMPRESSOR") || cutover.canonical) {
|
|
14001
|
-
const { PromptCompressor } =
|
|
14002
|
-
|
|
14111
|
+
const { PromptCompressor } = await import(
|
|
14112
|
+
"../harness/prompt-compressor.js"
|
|
14113
|
+
);
|
|
14003
14114
|
const llmQuery =
|
|
14004
14115
|
typeof options.compactionLlmQuery === "function"
|
|
14005
14116
|
? options.compactionLlmQuery
|
|
@@ -14049,8 +14160,9 @@ async function _getAutoCompactor(options) {
|
|
|
14049
14160
|
compressor = _instrumentAutoCompactorUsage(compressor, options);
|
|
14050
14161
|
if (cutover.canonical) {
|
|
14051
14162
|
const compatibilitySummarizer = compressor;
|
|
14052
|
-
const { compactLiveMessagesCanonical } =
|
|
14053
|
-
|
|
14163
|
+
const { compactLiveMessagesCanonical } = await import(
|
|
14164
|
+
"../lib/context-memory-kernel/live-compaction.js"
|
|
14165
|
+
);
|
|
14054
14166
|
compressor = {
|
|
14055
14167
|
canonicalKernel: true,
|
|
14056
14168
|
shouldAutoCompact: (messages) =>
|
|
@@ -14372,6 +14484,12 @@ function permissionDecision(callId, tool, result) {
|
|
|
14372
14484
|
}
|
|
14373
14485
|
|
|
14374
14486
|
export async function* agentLoop(messages, options) {
|
|
14487
|
+
if (options.serviceTier != null) {
|
|
14488
|
+
resolveModelServiceTier(
|
|
14489
|
+
resolveModelCapabilityProfile(options),
|
|
14490
|
+
options.serviceTier,
|
|
14491
|
+
);
|
|
14492
|
+
}
|
|
14375
14493
|
const executionPolicy = captureAgentExecutionPolicy(options, {
|
|
14376
14494
|
hermetic: true,
|
|
14377
14495
|
});
|
|
@@ -14386,8 +14504,9 @@ export async function* agentLoop(messages, options) {
|
|
|
14386
14504
|
: captureAgentEvolutionIngress(options.evolutionIngress);
|
|
14387
14505
|
let llmCall = configuredChatFn || chatWithTools;
|
|
14388
14506
|
if (evolutionIngress !== null && configuredChatFn) {
|
|
14389
|
-
const { captureCanonicalFallbackChatFn } =
|
|
14390
|
-
|
|
14507
|
+
const { captureCanonicalFallbackChatFn } = await import(
|
|
14508
|
+
"./fallback-model.js"
|
|
14509
|
+
);
|
|
14391
14510
|
llmCall = captureCanonicalFallbackChatFn(
|
|
14392
14511
|
configuredChatFn,
|
|
14393
14512
|
evolutionIngress,
|
|
@@ -14396,8 +14515,9 @@ export async function* agentLoop(messages, options) {
|
|
|
14396
14515
|
// Shared iteration budget — replaces hardcoded MAX_ITERATIONS.
|
|
14397
14516
|
// When options.iterationBudget is provided (e.g. from parent agent),
|
|
14398
14517
|
// the same budget instance is shared, so parent+child consume from one pool.
|
|
14399
|
-
const { IterationBudget, WarningLevel } =
|
|
14400
|
-
|
|
14518
|
+
const { IterationBudget, WarningLevel } = await import(
|
|
14519
|
+
"../lib/iteration-budget.js"
|
|
14520
|
+
);
|
|
14401
14521
|
const budget = options.iterationBudget || new IterationBudget();
|
|
14402
14522
|
const { HostResourceBudget } = await import("../lib/host-resource-budget.js");
|
|
14403
14523
|
const hostResourceBudget =
|
|
@@ -14747,8 +14867,9 @@ export async function* agentLoop(messages, options) {
|
|
|
14747
14867
|
options.strictUsageTelemetry !== true &&
|
|
14748
14868
|
workflowEffectId == null
|
|
14749
14869
|
) {
|
|
14750
|
-
const { makeRunnableProviderFallback } =
|
|
14751
|
-
|
|
14870
|
+
const { makeRunnableProviderFallback } = await import(
|
|
14871
|
+
"../lib/runnable-provider.js"
|
|
14872
|
+
);
|
|
14752
14873
|
llmCall = makeRunnableProviderFallback(llmCall, {
|
|
14753
14874
|
onFallback: ({ from, to, reason, fromModel, toModel }) => {
|
|
14754
14875
|
// Telemetry: a provider/model fallback is a reliability signal — count
|
|
@@ -15370,6 +15491,7 @@ export async function* agentLoop(messages, options) {
|
|
|
15370
15491
|
}
|
|
15371
15492
|
} catch (_e) {
|
|
15372
15493
|
if (isAbortError(_e) || signal?.aborted) throw _e;
|
|
15494
|
+
if (isFormalBudgetError(_e)) throw _e;
|
|
15373
15495
|
if (_e?.runtimeLedgerPersistence === true) throw _e;
|
|
15374
15496
|
if (_e?.code === "CC_AGENT_EVOLUTION_INGRESS_FAILED") throw _e;
|
|
15375
15497
|
if (
|
|
@@ -15388,8 +15510,9 @@ export async function* agentLoop(messages, options) {
|
|
|
15388
15510
|
}
|
|
15389
15511
|
compactionUsageCall =
|
|
15390
15512
|
compactionUsageCall || compactionUsageState?.calls?.at(-1) || null;
|
|
15391
|
-
const { getRejectedCompactionUsage } =
|
|
15392
|
-
|
|
15513
|
+
const { getRejectedCompactionUsage } = await import(
|
|
15514
|
+
"../lib/context-memory-kernel/live-compaction.js"
|
|
15515
|
+
);
|
|
15393
15516
|
const rejectedUsage = getRejectedCompactionUsage(_e);
|
|
15394
15517
|
const returnedUsage = compactionUsageCall?.returnedUsage;
|
|
15395
15518
|
const providerReceipt = _takeCompactionProviderReceipt(
|
|
@@ -15801,6 +15924,7 @@ export async function* agentLoop(messages, options) {
|
|
|
15801
15924
|
];
|
|
15802
15925
|
}
|
|
15803
15926
|
} catch (_e) {
|
|
15927
|
+
if (isFormalBudgetError(_e)) throw _e;
|
|
15804
15928
|
// prepareCall failures are non-critical — proceed with original messages
|
|
15805
15929
|
}
|
|
15806
15930
|
}
|
|
@@ -15830,8 +15954,9 @@ export async function* agentLoop(messages, options) {
|
|
|
15830
15954
|
// the run-level ids (turn.id correlates with the agent.iteration counter).
|
|
15831
15955
|
let canonicalProviderContext = null;
|
|
15832
15956
|
if (options.contextMemorySkipPlanning !== true) {
|
|
15833
|
-
const { prepareCanonicalProviderContext } =
|
|
15834
|
-
|
|
15957
|
+
const { prepareCanonicalProviderContext } = await import(
|
|
15958
|
+
"../lib/context-memory-kernel/provider-context.js"
|
|
15959
|
+
);
|
|
15835
15960
|
canonicalProviderContext = await prepareCanonicalProviderContext(
|
|
15836
15961
|
callMessages,
|
|
15837
15962
|
{
|
|
@@ -16400,6 +16525,7 @@ export async function* agentLoop(messages, options) {
|
|
|
16400
16525
|
: {}),
|
|
16401
16526
|
},
|
|
16402
16527
|
error: err.message,
|
|
16528
|
+
fatalError: isFormalBudgetError(err) ? err : null,
|
|
16403
16529
|
}),
|
|
16404
16530
|
);
|
|
16405
16531
|
return { call, toolArgs, workflowBinding, promise };
|
|
@@ -16407,7 +16533,12 @@ export async function* agentLoop(messages, options) {
|
|
|
16407
16533
|
for (const { call, toolArgs, workflowBinding, promise } of inflight) {
|
|
16408
16534
|
throwIfAborted(signal);
|
|
16409
16535
|
_throwBackgroundUsageFailureState(backgroundUsageFailureState);
|
|
16410
|
-
const {
|
|
16536
|
+
const {
|
|
16537
|
+
result: toolResult,
|
|
16538
|
+
error: toolError,
|
|
16539
|
+
fatalError,
|
|
16540
|
+
} = await promise;
|
|
16541
|
+
if (fatalError) throw fatalError;
|
|
16411
16542
|
throwIfAborted(signal);
|
|
16412
16543
|
const taskAdvanced = taskProgressTracker.record(
|
|
16413
16544
|
call.function.name,
|
|
@@ -16850,6 +16981,7 @@ export async function* agentLoop(messages, options) {
|
|
|
16850
16981
|
} catch (err) {
|
|
16851
16982
|
if (
|
|
16852
16983
|
isEvolutionIngressFailure(err) ||
|
|
16984
|
+
isFormalBudgetError(err) ||
|
|
16853
16985
|
err?.runtimeLedgerPersistence === true
|
|
16854
16986
|
)
|
|
16855
16987
|
throw err;
|