chainlesschain 0.166.143 → 0.166.146
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 +108 -10
- package/package.json +3 -3
- 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/.build-hash +1 -1
- package/src/assets/web-panel/assets/{AIOps-DNySV2Kf.js → AIOps-BjBY1txq.js} +1 -1
- package/src/assets/web-panel/assets/{ActionButton-ByFuxJsa.js → ActionButton-CS2ov4iK.js} +1 -1
- package/src/assets/web-panel/assets/{Analytics-ETbdywk5.js → Analytics-C9LS7ahG.js} +1 -1
- package/src/assets/web-panel/assets/{AppLayout-CuHekZaP.js → AppLayout-4_s9gBVg.js} +2 -2
- package/src/assets/web-panel/assets/{Artifacts-BJJq2BDq.js → Artifacts-CwS17ayg.js} +1 -1
- package/src/assets/web-panel/assets/{Audit-DXrietv8.js → Audit-D3QMRsd-.js} +1 -1
- package/src/assets/web-panel/assets/{BackgroundAgents-CFB1fxsr.js → BackgroundAgents-Bxau9H9Q.js} +1 -1
- package/src/assets/web-panel/assets/{Backup-VLtflRmp.js → Backup--YSJyAuP.js} +1 -1
- package/src/assets/web-panel/assets/{BaseInput-BbqBaS2r.js → BaseInput-DZolkmdu.js} +1 -1
- package/src/assets/web-panel/assets/{Chat-t0g7BXL8.js → Chat-DA-7fNKq.js} +1 -1
- package/src/assets/web-panel/assets/{ChatBubbleRenderer-JNFsjV0j.js → ChatBubbleRenderer-DniEWT5j.js} +1 -1
- package/src/assets/web-panel/assets/{Checkbox-BCSclHQb.js → Checkbox-B4hgbnOB.js} +1 -1
- package/src/assets/web-panel/assets/{Codegen-BcyINEHT.js → Codegen-BQ3HSq9S.js} +1 -1
- package/src/assets/web-panel/assets/{Col-C-0WNlwS.js → Col-DJwxq_Wu.js} +1 -1
- package/src/assets/web-panel/assets/{Community-DxZeoORX.js → Community-DZYVM_iz.js} +1 -1
- package/src/assets/web-panel/assets/{Compact-BNnX4jpz.js → Compact-1Yq5o53N.js} +1 -1
- package/src/assets/web-panel/assets/{Compliance-KnjHtn9C.js → Compliance-52Per8mR.js} +1 -1
- package/src/assets/web-panel/assets/{Cowork-CDyCrhbX.js → Cowork-BaCNxzo7.js} +1 -1
- package/src/assets/web-panel/assets/{Cron-DxpS3D1G.js → Cron-DADTMPPr.js} +1 -1
- package/src/assets/web-panel/assets/{Crosschain-BSzTZYyc.js → Crosschain-CS3rx96X.js} +1 -1
- package/src/assets/web-panel/assets/{DID-Bfj9Vdne.js → DID-B8eatIvd.js} +1 -1
- package/src/assets/web-panel/assets/{Dashboard-CcERVdgo.js → Dashboard-0vsurC1X.js} +2 -2
- package/src/assets/web-panel/assets/{Dropdown-BtYXAz6E.js → Dropdown-BULy3ccq.js} +1 -1
- package/src/assets/web-panel/assets/{EmailListRenderer-fdCMeGXU.js → EmailListRenderer-CcwgCUpu.js} +1 -1
- package/src/assets/web-panel/assets/{EvolutionSettings-LHxhcuF2.js → EvolutionSettings-DLs_6II3.js} +1 -1
- package/src/assets/web-panel/assets/{FamilyGuardDashboard-MIgtLsos.js → FamilyGuardDashboard-DpUpWwQP.js} +1 -1
- package/src/assets/web-panel/assets/{Federation-9-TOztwa.js → Federation-6hx8MMYA.js} +1 -1
- package/src/assets/web-panel/assets/{FormItemContext-BKcwEE6w.js → FormItemContext-CsdE-ZR5.js} +1 -1
- package/src/assets/web-panel/assets/{GenericCardRenderer-DJBPVUK2.js → GenericCardRenderer-DzXneQPV.js} +1 -1
- package/src/assets/web-panel/assets/{Git-C_XYISjG.js → Git-D_ThKL1Q.js} +1 -1
- package/src/assets/web-panel/assets/{Governance-DWsbPrwq.js → Governance-BFBSlr-9.js} +1 -1
- package/src/assets/web-panel/assets/{Inference-D0_bYket.js → Inference-BAI0b1Jl.js} +1 -1
- package/src/assets/web-panel/assets/{KnowledgeGraph-BoA3VQlw.js → KnowledgeGraph-CpO6Bdtr.js} +1 -1
- package/src/assets/web-panel/assets/{Logs-LEGItChf.js → Logs-BcRaS_HC.js} +1 -1
- package/src/assets/web-panel/assets/{MarkdownRenderer-DOHVc-Uw.js → MarkdownRenderer-CmZaA7Ct.js} +1 -1
- package/src/assets/web-panel/assets/{Marketplace-BKovl9NH.js → Marketplace-BpHBn0Nw.js} +1 -1
- package/src/assets/web-panel/assets/{McpTools-D61ktoGb.js → McpTools-auVxEYSE.js} +1 -1
- package/src/assets/web-panel/assets/{Memory-CllorS0l.js → Memory-DpCyb656.js} +1 -1
- package/src/assets/web-panel/assets/{MobileBridge-D-dJ78bk.js → MobileBridge-CEIGi769.js} +1 -1
- package/src/assets/web-panel/assets/{MobileProjects-CaxMKkd3.js → MobileProjects-pphH0a8n.js} +1 -1
- package/src/assets/web-panel/assets/{Mtc-qEc62Qsx.js → Mtc-CMJXBEp1.js} +1 -1
- package/src/assets/web-panel/assets/{MtcAudit-BY68jOZJ.js → MtcAudit-BI25yvzM.js} +1 -1
- package/src/assets/web-panel/assets/{Multisig-eCCR8ELt.js → Multisig-BhMDExsQ.js} +1 -1
- package/src/assets/web-panel/assets/{NLProgramming-VtGv8pky.js → NLProgramming-CatOR9Ez.js} +1 -1
- package/src/assets/web-panel/assets/{Notes-CPkYQySe.js → Notes-BHG6SBpu.js} +1 -1
- package/src/assets/web-panel/assets/{NotificationSettings-BuAvlHUu.js → NotificationSettings-BB-m0AbL.js} +1 -1
- package/src/assets/web-panel/assets/{OrderTableRenderer-CLf_HAGv.js → OrderTableRenderer-W-WReAih.js} +1 -1
- package/src/assets/web-panel/assets/{Organization-DjujhMbD.js → Organization-BkQCgon_.js} +1 -1
- package/src/assets/web-panel/assets/{Overflow-RznznTS4.js → Overflow-kCTwPrIc.js} +1 -1
- package/src/assets/web-panel/assets/{P2P-DSa5ot0t.js → P2P-CvOF8whc.js} +1 -1
- package/src/assets/web-panel/assets/{PdhVaultBrowser-oSEh6vkf.js → PdhVaultBrowser-DYkTzn6u.js} +2 -2
- package/src/assets/web-panel/assets/{Permissions-CdOZguX9.js → Permissions-F-UzeWVt.js} +1 -1
- package/src/assets/web-panel/assets/{PersonalDataHub-B4--6iEF.js → PersonalDataHub-BURpZBb6.js} +1 -1
- package/src/assets/web-panel/assets/{Pipeline-BnI57jE8.js → Pipeline-lZYx_7qc.js} +1 -1
- package/src/assets/web-panel/assets/{Privacy-C8MId3ad.js → Privacy-DdfYgt1_.js} +1 -1
- package/src/assets/web-panel/assets/{ProjectInit-DPGyYO8a.js → ProjectInit-DbMBCojn.js} +1 -1
- package/src/assets/web-panel/assets/{ProjectSettings-qBMqaJaO.js → ProjectSettings-DPGbzkyi.js} +1 -1
- package/src/assets/web-panel/assets/{Projects-Bq87Syce.js → Projects-B9-t2ofM.js} +1 -1
- package/src/assets/web-panel/assets/{Providers-CVuG9Ugf.js → Providers-q9dSBLsP.js} +1 -1
- package/src/assets/web-panel/assets/{QrScannerModal-C94c8m3q.js → QrScannerModal-BIth1Lij.js} +1 -1
- package/src/assets/web-panel/assets/{QuickAsk-BvfsXZ8s.js → QuickAsk-C928WbdK.js} +1 -1
- package/src/assets/web-panel/assets/{Recommend-CoezBYH9.js → Recommend-CzDNsNPZ.js} +1 -1
- package/src/assets/web-panel/assets/{RemoteSession-CcYC4v3u.js → RemoteSession-CedjOslI.js} +1 -1
- package/src/assets/web-panel/assets/{Reputation-diDbL4cO.js → Reputation-B8ggKVtj.js} +1 -1
- package/src/assets/web-panel/assets/{Row-5qp3_fNS.js → Row-Cx167nF6.js} +1 -1
- package/src/assets/web-panel/assets/{RssFeed-BCsMvpV4.js → RssFeed-Cj8hwiLP.js} +1 -1
- package/src/assets/web-panel/assets/{Search-Br9nVxOp.js → Search-Dsyrkogu.js} +1 -1
- package/src/assets/web-panel/assets/{Security-BdOUzRfA.js → Security-DfOcWFt-.js} +1 -1
- package/src/assets/web-panel/assets/{Services-Cp9TqzyN.js → Services-CSyv-JgS.js} +1 -1
- package/src/assets/web-panel/assets/{Skeleton-DSdWsUMR.js → Skeleton-B0chhFP5.js} +1 -1
- package/src/assets/web-panel/assets/{Skills-DRczAMTe.js → Skills-B_jrR_AF.js} +1 -1
- package/src/assets/web-panel/assets/{Sla-B6G_Vd8N.js → Sla-krP10aUI.js} +1 -1
- package/src/assets/web-panel/assets/{SpeechSettings-BCcLx5x4.js → SpeechSettings-Cm_Cjvf2.js} +1 -1
- package/src/assets/web-panel/assets/{SyncSettings-BFhwtxCp.js → SyncSettings-Cmb-KoqG.js} +1 -1
- package/src/assets/web-panel/assets/{Tasks-DGRE6VHO.js → Tasks-DUOiwTxY.js} +1 -1
- package/src/assets/web-panel/assets/{Templates-CJkJRFzd.js → Templates-DcEPspsP.js} +1 -1
- package/src/assets/web-panel/assets/{Tenant-CAOv6p00.js → Tenant-Dw93LtrE.js} +1 -1
- package/src/assets/web-panel/assets/{Terminal-CDrwwrKj.js → Terminal-B04i0AIG.js} +1 -1
- package/src/assets/web-panel/assets/{TimelineRenderer-DI0YE2SN.js → TimelineRenderer-C-aAORNK.js} +1 -1
- package/src/assets/web-panel/assets/{Tokens-DmqWTZSG.js → Tokens-W1RBfDKb.js} +1 -1
- package/src/assets/web-panel/assets/{Trigger-CkXkhmjk.js → Trigger-BuuH9sMn.js} +1 -1
- package/src/assets/web-panel/assets/{Trust-U8YJLcoJ.js → Trust-Bma-Vz-f.js} +1 -1
- package/src/assets/web-panel/assets/{UkeySign-BLTozMmr.js → UkeySign-CqWw3_ha.js} +1 -1
- package/src/assets/web-panel/assets/{VideoEditing-DHKyFlZa.js → VideoEditing-6NYmQRUe.js} +1 -1
- package/src/assets/web-panel/assets/{Wallet-DapBxIQt.js → Wallet-CTUuBxsr.js} +1 -1
- package/src/assets/web-panel/assets/{WebAuthn-CkvG3yOr.js → WebAuthn-D8mN5UQU.js} +1 -1
- package/src/assets/web-panel/assets/{WorkflowEditor-cNLsinXP.js → WorkflowEditor-DOB46XMH.js} +1 -1
- package/src/assets/web-panel/assets/{chat-BzgkgfMC.js → chat-BPNlNLwi.js} +1 -1
- package/src/assets/web-panel/assets/{colors-BPpVKQsb.js → colors-D-LNng0Q.js} +1 -1
- package/src/assets/web-panel/assets/{compact-item-zepznuTv.js → compact-item-Vkl3KOAb.js} +1 -1
- package/src/assets/web-panel/assets/{createContext-BRto-SQH.js → createContext-CFsJ9Bmp.js} +1 -1
- package/src/assets/web-panel/assets/{hasIn-CqsmU_n6.js → hasIn-C1v7eiIB.js} +1 -1
- package/src/assets/web-panel/assets/{index-DKa_jSfj.js → index-0oRhV07J.js} +1 -1
- package/src/assets/web-panel/assets/{index-wbvZayBb.js → index-5oK4ICcR.js} +1 -1
- package/src/assets/web-panel/assets/{index-CwkhrUmw.js → index-9JeeBF92.js} +1 -1
- package/src/assets/web-panel/assets/{index-B0Z6rfV-.js → index-BGyhWFpc.js} +1 -1
- package/src/assets/web-panel/assets/{index-DUclk35X.js → index-BH5PxoVq.js} +1 -1
- package/src/assets/web-panel/assets/{index-Z6DBe2RU.js → index-BMcTUbpz.js} +1 -1
- package/src/assets/web-panel/assets/{index-DXkw-nt5.js → index-BMsRfvkp.js} +1 -1
- package/src/assets/web-panel/assets/{index-BeBxP1M6.js → index-BObyCZ2w.js} +1 -1
- package/src/assets/web-panel/assets/{index-D_asIcU7.js → index-BPwv3l6X.js} +1 -1
- package/src/assets/web-panel/assets/{index-BeSzdB7x.js → index-BQr5mmyc.js} +1 -1
- package/src/assets/web-panel/assets/{index-w36TkwyO.js → index-BVHaJNpn.js} +1 -1
- package/src/assets/web-panel/assets/{index-D_-w4KkD.js → index-BefXafSw.js} +1 -1
- package/src/assets/web-panel/assets/{index-DvGttIXQ.js → index-BgvrlrtJ.js} +1 -1
- package/src/assets/web-panel/assets/{index-LVvzNdPa.js → index-BiPmMm38.js} +1 -1
- package/src/assets/web-panel/assets/{index-CdHXVSZ4.js → index-BoZnaD3Q.js} +1 -1
- package/src/assets/web-panel/assets/{index-Q5sAV7wp.js → index-BxJC59QT.js} +1 -1
- package/src/assets/web-panel/assets/{index-BGHd4D8F.js → index-CD8egQCF.js} +1 -1
- package/src/assets/web-panel/assets/index-CLafGdQC.js +1 -0
- package/src/assets/web-panel/assets/{index-JrVhUwyh.js → index-CaJvbmCw.js} +1 -1
- package/src/assets/web-panel/assets/{index-CTk9gY88.js → index-CfVl0Oqt.js} +1 -1
- package/src/assets/web-panel/assets/{index-DJSn3owP.js → index-ChGe005u.js} +1 -1
- package/src/assets/web-panel/assets/{index-DDPmr5Yr.js → index-Cjxxw-1P.js} +1 -1
- package/src/assets/web-panel/assets/{index-BEXKES7V.js → index-CmkppTkH.js} +1 -1
- package/src/assets/web-panel/assets/{index-CmPnDXx4.js → index-DFErisPY.js} +1 -1
- package/src/assets/web-panel/assets/{index-B_l6gfDh.js → index-DVfUt2bK.js} +1 -1
- package/src/assets/web-panel/assets/index-DYHw3Xoi.js +1 -0
- package/src/assets/web-panel/assets/{index-CnezE05k.js → index-DZ16Oxcu.js} +1 -1
- package/src/assets/web-panel/assets/{index-faHHtBKj.js → index-DbmhJVc3.js} +1 -1
- package/src/assets/web-panel/assets/{index-CzoKAiyT.js → index-Dd0OgZmt.js} +3 -3
- package/src/assets/web-panel/assets/{index-B-bNzvdU.js → index-DgYmI2pD.js} +1 -1
- package/src/assets/web-panel/assets/{index-B9_jRD2e.js → index-DmUZGqe2.js} +1 -1
- package/src/assets/web-panel/assets/{index-BuBnM6Kz.js → index-Dq9SDl82.js} +1 -1
- package/src/assets/web-panel/assets/{index-BLwY9y0X.js → index-DuIfomtv.js} +1 -1
- package/src/assets/web-panel/assets/{index-S8fkzbQ_.js → index-MGJzHAw_.js} +1 -1
- package/src/assets/web-panel/assets/{index-Df_CY0We.js → index-PCe8NA3J.js} +1 -1
- package/src/assets/web-panel/assets/{index-DEbAW3Ec.js → index-PiL6D-FC.js} +1 -1
- package/src/assets/web-panel/assets/{index-CBI-7Q3W.js → index-a_H30VZX.js} +1 -1
- package/src/assets/web-panel/assets/{index-Dnvj_XU-.js → index-hBzgHVea.js} +1 -1
- package/src/assets/web-panel/assets/{index-Bz7pG8z3.js → index-uDSUo2y2.js} +1 -1
- package/src/assets/web-panel/assets/{initDefaultProps-BlhbrsQk.js → initDefaultProps-CCYgHcTH.js} +1 -1
- package/src/assets/web-panel/assets/{motion-UZx12NPM.js → motion-4Yr4ZkjE.js} +1 -1
- package/src/assets/web-panel/assets/{move-BTby5W4q.js → move-ZP90E-ji.js} +1 -1
- package/src/assets/web-panel/assets/{mtc-parser-BOOaGiCg.js → mtc-parser-s0N3WyRA.js} +1 -1
- package/src/assets/web-panel/assets/{omit-BVylGzEr.js → omit-BZ6gx9Kf.js} +1 -1
- package/src/assets/web-panel/assets/{pickAttrs-Cp3Nflbr.js → pickAttrs-DxUtFOOQ.js} +1 -1
- package/src/assets/web-panel/assets/{placementArrow-BVXYvwH2.js → placementArrow-Btzjn1hK.js} +1 -1
- package/src/assets/web-panel/assets/{responsiveObserve-C67SbpBN.js → responsiveObserve-DYcoe1XJ.js} +1 -1
- package/src/assets/web-panel/assets/{slide-CnBvM22R.js → slide-BiBewdr4.js} +1 -1
- package/src/assets/web-panel/assets/{statusUtils-T8fy53tf.js → statusUtils-D9vt0dkG.js} +1 -1
- package/src/assets/web-panel/assets/{styleChecker-Bf7i4nlm.js → styleChecker-BXsm_vG0.js} +1 -1
- package/src/assets/web-panel/assets/{useFlexGapSupport-BUKk7jqw.js → useFlexGapSupport-CIG8zET4.js} +1 -1
- package/src/assets/web-panel/assets/{useFs-T5lg6SpD.js → useFs-ChFPF8GI.js} +1 -1
- package/src/assets/web-panel/assets/{usePersonalDataHub-Brvye8Tg.js → usePersonalDataHub-D4CzWJhY.js} +1 -1
- package/src/assets/web-panel/assets/{vnode-CK992ojP.js → vnode-6V5tphk5.js} +1 -1
- package/src/assets/web-panel/assets/{zoom-CcABB_97.js → zoom-B2H_VwfU.js} +1 -1
- package/src/assets/web-panel/index.html +1 -1
- package/src/command-help-index.json +4 -4
- package/src/commands/agent.js +64 -62
- package/src/commands/goal.js +79 -0
- package/src/commands/mcp-tasks.js +239 -0
- package/src/commands/mcp.js +58 -2
- package/src/commands/memory.js +131 -7
- package/src/commands/session-show.js +36 -1
- package/src/data/changelog.json +39 -0
- package/src/generated/cc-agent-protocol.schema.json +175 -69
- package/src/harness/jsonl-session-store.js +10 -0
- package/src/harness/mcp-client.js +701 -51
- package/src/harness/prompt-compressor.js +1 -0
- package/src/harness/session-index.js +8 -0
- package/src/harness/session-list-index.js +13 -58
- package/src/host/README.md +43 -0
- package/src/host/project-goal-graph.js +57 -0
- package/src/lib/agent-session-export.js +19 -0
- package/src/lib/app-server/context-memory-notifications.js +11 -2
- package/src/lib/app-server/server.js +1 -0
- package/src/lib/background-launch-profile.js +38 -6
- package/src/lib/codex-app-server-adapter.js +20 -0
- package/src/lib/codex-app-server-support.js +2 -2
- package/src/lib/context-memory-kernel/local-semantic-source.js +426 -0
- package/src/lib/context-memory-kernel/local-semantic-worker.py +109 -0
- package/src/lib/context-memory-kernel/memory-query-control.js +5 -1
- package/src/lib/context-memory-kernel/memory-query-index.js +37 -1
- package/src/lib/context-memory-kernel/memory-service.js +35 -2
- package/src/lib/context-memory-kernel/message-adapter.js +27 -5
- package/src/lib/context-memory-kernel/provider-context.js +197 -15
- package/src/lib/context-memory-kernel/runtime.js +40 -0
- package/src/lib/context-memory-kernel/segmented-memory-port.js +26 -1
- package/src/lib/evolution/agent-evolution-ingress.js +55 -1
- package/src/lib/evolution/evolution-artifact-ports.js +36 -1
- package/src/lib/evolution/skill-candidate-registry.js +3 -1
- package/src/lib/formal-budget-authority.js +56 -3
- package/src/lib/formal-budget-contract.js +90 -5
- package/src/lib/formal-budget-provider-scope.js +29 -7
- package/src/lib/formal-budget-transport.js +36 -5
- package/src/lib/goal-store.js +219 -0
- package/src/lib/graph-kernel/graph-runtime-surfaces.json +30 -0
- package/src/lib/graph-kernel/production-source-evidence.js +3 -3
- package/src/lib/graph-kernel/runtime-surface-manifest.js +46 -9
- package/src/lib/graph-kernel/runtime.js +12 -1
- package/src/lib/mcp-call-ledger-projection.js +1026 -0
- package/src/lib/mcp-call-ledger-store.js +19 -1024
- package/src/lib/mcp-client.js +1 -0
- package/src/lib/mcp-ledger-recovery-admission.js +25 -0
- package/src/lib/mcp-stateless-protocol.js +158 -0
- package/src/lib/mcp-task-continuation-contract.js +129 -0
- package/src/lib/mcp-task-continuation.js +147 -0
- package/src/lib/mcp-task-delivery-contract.js +190 -0
- package/src/lib/mcp-task-delivery.js +113 -0
- package/src/lib/mcp-task-journal-projection.js +495 -0
- package/src/lib/mcp-task-journal.js +57 -0
- package/src/lib/mcp-task-runtime.js +627 -0
- package/src/lib/mcp-tasks.js +217 -0
- package/src/lib/model-input-diagnostics.js +265 -0
- package/src/lib/model-input-source-mapping.js +343 -0
- package/src/lib/openai-responses.js +32 -9
- package/src/lib/provider-request-admission.js +181 -0
- package/src/lib/public-ide-capability-manifest.js +2 -0
- package/src/lib/scheduler-kernel/graph-authority-adapter.js +140 -15
- package/src/lib/session-generation-authority.js +58 -0
- package/src/lib/session-host-snapshot.js +37 -0
- package/src/lib/session-input-lifecycle.js +147 -0
- package/src/lib/session-input-receipt.js +64 -0
- package/src/lib/session-message-provenance.js +6 -5
- package/src/lib/session-model-input-diagnostics.js +262 -0
- package/src/lib/session-model-usage-recovery.js +115 -0
- package/src/lib/session-transcript-history.js +9 -0
- package/src/lib/session-transcript-page.js +7 -1
- package/src/lib/session-transcript-structure.js +45 -0
- package/src/lib/storage-failure-cause-codes.js +79 -0
- package/src/lib/sub-agent-context.js +7 -3
- package/src/repl/agent-repl.js +526 -253
- package/src/runtime/agent-core.js +296 -151
- package/src/runtime/headless-runner.js +58 -69
- package/src/runtime/headless-stream.js +40 -33
- package/src/runtime/mcp-config.js +5 -3
- package/src/runtime/policies/agent-policy.js +1 -0
- package/src/assets/web-panel/assets/index-DruOFzuF.js +0 -1
- package/src/assets/web-panel/assets/index-hhOrZ6HO.js +0 -1
|
@@ -435,20 +435,42 @@ function decodeBundle(item, expectedSessionId) {
|
|
|
435
435
|
});
|
|
436
436
|
}
|
|
437
437
|
|
|
438
|
-
/** Restore replay messages
|
|
439
|
-
export function
|
|
438
|
+
/** Restore replay messages and record provenance at the actual bundle expansion. */
|
|
439
|
+
export function contextItemsToMessagesWithSources(itemsInput, options = {}) {
|
|
440
440
|
if (!Array.isArray(itemsInput)) throw new TypeError("items must be an array");
|
|
441
441
|
const expectedSessionId =
|
|
442
442
|
options.sessionId == null ? undefined : String(options.sessionId);
|
|
443
|
-
|
|
443
|
+
const ordered = [...itemsInput]
|
|
444
444
|
.map(normalizeContextItem)
|
|
445
445
|
.sort(
|
|
446
446
|
(left, right) =>
|
|
447
447
|
(left.sourceRef.eventSequence ?? Number.MAX_SAFE_INTEGER) -
|
|
448
448
|
(right.sourceRef.eventSequence ?? Number.MAX_SAFE_INTEGER) ||
|
|
449
449
|
left.itemId.localeCompare(right.itemId, "en"),
|
|
450
|
-
)
|
|
451
|
-
|
|
450
|
+
);
|
|
451
|
+
const messages = [];
|
|
452
|
+
const sources = [];
|
|
453
|
+
for (const item of ordered) {
|
|
454
|
+
const bundle = decodeBundle(item, expectedSessionId);
|
|
455
|
+
const start = messages.length;
|
|
456
|
+
messages.push(...bundle);
|
|
457
|
+
sources.push(
|
|
458
|
+
Object.freeze({
|
|
459
|
+
digest: item.digest,
|
|
460
|
+
kind: item.kind,
|
|
461
|
+
messageIndexes: Object.freeze(bundle.map((_, index) => start + index)),
|
|
462
|
+
derived:
|
|
463
|
+
Array.isArray(item.provenance?.parentDigests) &&
|
|
464
|
+
item.provenance.parentDigests.length > 0,
|
|
465
|
+
}),
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
return { messages, sources: Object.freeze(sources) };
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/** Restore replay messages in transcript order, independent of planner rank. */
|
|
472
|
+
export function contextItemsToMessages(itemsInput, options = {}) {
|
|
473
|
+
return contextItemsToMessagesWithSources(itemsInput, options).messages;
|
|
452
474
|
}
|
|
453
475
|
|
|
454
476
|
function intersectAllowedSinks(items) {
|
|
@@ -9,7 +9,7 @@ import { resolveModelCapabilityProfile } from "../model-capabilities.js";
|
|
|
9
9
|
import { raceWithAbort } from "../abort-utils.js";
|
|
10
10
|
import { createCliContextMemoryRuntime } from "./runtime.js";
|
|
11
11
|
import {
|
|
12
|
-
|
|
12
|
+
contextItemsToMessagesWithSources,
|
|
13
13
|
memoryRecordsToContextItems,
|
|
14
14
|
messagesToContextItems,
|
|
15
15
|
} from "./message-adapter.js";
|
|
@@ -22,6 +22,34 @@ import {
|
|
|
22
22
|
export const SEMANTIC_CANDIDATE_REQUEST_SCHEMA =
|
|
23
23
|
"chainlesschain.context-memory-semantic-candidate-request/v1";
|
|
24
24
|
|
|
25
|
+
const PROVIDER_SOURCE_MAPPINGS = new WeakMap();
|
|
26
|
+
const PROVIDER_SOURCE_REQUEST_DOMAIN =
|
|
27
|
+
"chainlesschain.cli-provider-source-request/v1";
|
|
28
|
+
|
|
29
|
+
function freezeSourceSnapshot(value) {
|
|
30
|
+
if (value && typeof value === "object" && !Object.isFrozen(value)) {
|
|
31
|
+
for (const child of Object.values(value)) freezeSourceSnapshot(child);
|
|
32
|
+
Object.freeze(value);
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Only the actual planning exit can mint a mapping for an exact request. */
|
|
38
|
+
export function getCanonicalProviderSourceMapping(plan, request) {
|
|
39
|
+
const captured = PROVIDER_SOURCE_MAPPINGS.get(plan);
|
|
40
|
+
if (!captured) return null;
|
|
41
|
+
try {
|
|
42
|
+
if (
|
|
43
|
+
canonicalDigest(request, PROVIDER_SOURCE_REQUEST_DOMAIN) !==
|
|
44
|
+
captured.requestDigest
|
|
45
|
+
)
|
|
46
|
+
return null;
|
|
47
|
+
} catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return captured.rows;
|
|
51
|
+
}
|
|
52
|
+
|
|
25
53
|
function defaultAdmissions(sessionId, options) {
|
|
26
54
|
const candidates = [
|
|
27
55
|
{ scope: "session", scopeId: sessionId },
|
|
@@ -29,10 +57,15 @@ function defaultAdmissions(sessionId, options) {
|
|
|
29
57
|
{ scope: "user", scopeId: options.userId || "local-user" },
|
|
30
58
|
];
|
|
31
59
|
const configured = options.contextMemoryScopeAdmissions;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
60
|
+
if (
|
|
61
|
+
configured != null &&
|
|
62
|
+
(!Array.isArray(configured) || configured.length === 0)
|
|
63
|
+
) {
|
|
64
|
+
throw new TypeError(
|
|
65
|
+
"contextMemoryScopeAdmissions must contain at least one explicit scope",
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
const admissions = configured ?? candidates;
|
|
36
69
|
const seen = new Set();
|
|
37
70
|
return admissions.filter((entry) => {
|
|
38
71
|
const key = `${entry.scope}\0${entry.scopeId || ""}`;
|
|
@@ -240,7 +273,11 @@ export async function prepareCanonicalProviderContext(
|
|
|
240
273
|
|
|
241
274
|
// Review can exclude recalled author/session data while retaining the exact
|
|
242
275
|
// canonical context, tool and output-token planning boundary.
|
|
243
|
-
const recallEnabled =
|
|
276
|
+
const recallEnabled =
|
|
277
|
+
options.contextMemoryRecall !== false &&
|
|
278
|
+
options.memoryEnabled !== false &&
|
|
279
|
+
options.contextEngine?.memoryEnabled !== false &&
|
|
280
|
+
options.subAgentContract?.memory !== false;
|
|
244
281
|
const candidateProvider = recallEnabled
|
|
245
282
|
? semanticCandidateProvider(options)
|
|
246
283
|
: null;
|
|
@@ -268,7 +305,7 @@ export async function prepareCanonicalProviderContext(
|
|
|
268
305
|
});
|
|
269
306
|
options.signal?.throwIfAborted();
|
|
270
307
|
const recall = recallEnabled
|
|
271
|
-
? await runtime.
|
|
308
|
+
? await runtime.recallMemory(
|
|
272
309
|
{
|
|
273
310
|
query,
|
|
274
311
|
sink,
|
|
@@ -386,23 +423,168 @@ export async function prepareCanonicalProviderContext(
|
|
|
386
423
|
memoryRevision: recall.memoryRevision,
|
|
387
424
|
});
|
|
388
425
|
options.signal?.throwIfAborted();
|
|
389
|
-
const
|
|
426
|
+
const expanded = contextItemsToMessagesWithSources(
|
|
390
427
|
plan.selected.filter((item) => item.kind !== "tool-schema"),
|
|
391
428
|
{ sessionId },
|
|
392
429
|
);
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
.filter((item) =>
|
|
430
|
+
// Capture immutable authority facts before publishing the plan to a host.
|
|
431
|
+
// A generator consumer can pause for arbitrary work after context planning.
|
|
432
|
+
const expectedRevision = recall.memoryRevision;
|
|
433
|
+
const signal = options.signal;
|
|
434
|
+
const selectedMemoryIds = new Set(
|
|
435
|
+
plan.selected
|
|
436
|
+
.filter((item) => item.kind === "memory")
|
|
400
437
|
.map((item) => item.sourceRef.id),
|
|
438
|
+
);
|
|
439
|
+
const expirations = recall.results
|
|
440
|
+
.filter((entry) => selectedMemoryIds.has(entry.record.memoryId))
|
|
441
|
+
.map((entry) => entry.record.retentionPolicy.expiresAt)
|
|
442
|
+
.filter(Boolean)
|
|
443
|
+
.map(Date.parse);
|
|
444
|
+
const expiresAt = expirations.length ? Math.min(...expirations) : null;
|
|
445
|
+
const explicitSink = Boolean(options.contextMemorySink);
|
|
446
|
+
const dispatchSignal = (controls) =>
|
|
447
|
+
signal && controls?.signal
|
|
448
|
+
? AbortSignal.any([signal, controls.signal])
|
|
449
|
+
: signal || controls?.signal;
|
|
450
|
+
function assertDispatchOpen(destination, controls = {}) {
|
|
451
|
+
signal?.throwIfAborted();
|
|
452
|
+
controls.signal?.throwIfAborted();
|
|
453
|
+
if (!recallEnabled) return;
|
|
454
|
+
if (
|
|
455
|
+
(expiresAt !== null && Date.now() >= expiresAt) ||
|
|
456
|
+
(!explicitSink &&
|
|
457
|
+
destination?.provider != null &&
|
|
458
|
+
`provider.${destination.provider}` !== sink)
|
|
459
|
+
) {
|
|
460
|
+
const error = new Error(
|
|
461
|
+
"Memory authorization expired or its provider changed before dispatch",
|
|
462
|
+
);
|
|
463
|
+
error.code = "revision_conflict";
|
|
464
|
+
error.noReplay = true;
|
|
465
|
+
throw error;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
async function assertCurrent(destination, controls = {}) {
|
|
469
|
+
assertDispatchOpen(destination, controls);
|
|
470
|
+
if (!recallEnabled) return;
|
|
471
|
+
const currentRevision = await runtime.memoryPort.getRevision({
|
|
472
|
+
signal: dispatchSignal(controls),
|
|
473
|
+
});
|
|
474
|
+
assertDispatchOpen(destination, controls);
|
|
475
|
+
if (currentRevision !== expectedRevision) {
|
|
476
|
+
const error = new Error(
|
|
477
|
+
"Memory authorization changed before provider dispatch; prepare a fresh context",
|
|
478
|
+
);
|
|
479
|
+
error.code = "revision_conflict";
|
|
480
|
+
error.details = { expectedRevision, currentRevision };
|
|
481
|
+
error.noReplay = true;
|
|
482
|
+
throw error;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
// Image restoration replaces content only, preserving the expansion order.
|
|
486
|
+
const restoredMessages = restoreContextImageTransport(
|
|
487
|
+
expanded.messages,
|
|
488
|
+
imageTransport.captures,
|
|
489
|
+
);
|
|
490
|
+
const rows = plan.selected.map((item, selectedIndex) => ({
|
|
491
|
+
selectedIndex,
|
|
492
|
+
digest: item.digest,
|
|
493
|
+
kind: item.kind,
|
|
494
|
+
derived:
|
|
495
|
+
Array.isArray(item.provenance?.parentDigests) &&
|
|
496
|
+
item.provenance.parentDigests.length > 0,
|
|
497
|
+
slots: [],
|
|
498
|
+
}));
|
|
499
|
+
const matchedMessages = new Set();
|
|
500
|
+
for (const source of expanded.sources) {
|
|
501
|
+
const index = rows.findIndex(
|
|
502
|
+
(row) =>
|
|
503
|
+
row.kind !== "tool-schema" &&
|
|
504
|
+
row.digest === source.digest &&
|
|
505
|
+
row.kind === source.kind &&
|
|
506
|
+
!matchedMessages.has(row.selectedIndex),
|
|
507
|
+
);
|
|
508
|
+
if (index < 0)
|
|
509
|
+
throw new TypeError("Provider message source is outside its plan");
|
|
510
|
+
matchedMessages.add(index);
|
|
511
|
+
rows[index].slots = source.messageIndexes.map((index) => ({
|
|
512
|
+
kind: "message",
|
|
513
|
+
index,
|
|
514
|
+
}));
|
|
515
|
+
}
|
|
516
|
+
const selectedToolDefinitions = [];
|
|
517
|
+
const selectedToolNames = [];
|
|
518
|
+
const matchedTools = new Set();
|
|
519
|
+
// Match the selected item, not its callable name. Same-name definitions
|
|
520
|
+
// remain distinct, and transport definitions retain registry input order.
|
|
521
|
+
for (const item of toolItems) {
|
|
522
|
+
const index = rows.findIndex(
|
|
523
|
+
(row) =>
|
|
524
|
+
row.kind === "tool-schema" &&
|
|
525
|
+
row.digest === item.digest &&
|
|
526
|
+
!matchedTools.has(row.selectedIndex),
|
|
527
|
+
);
|
|
528
|
+
if (index < 0) continue;
|
|
529
|
+
matchedTools.add(index);
|
|
530
|
+
rows[index].slots.push({
|
|
531
|
+
kind: "tool",
|
|
532
|
+
index: selectedToolDefinitions.length,
|
|
533
|
+
});
|
|
534
|
+
selectedToolDefinitions.push(JSON.parse(item.content));
|
|
535
|
+
selectedToolNames.push(item.sourceRef.id);
|
|
536
|
+
}
|
|
537
|
+
if (rows.some((row) => row.slots.length === 0))
|
|
538
|
+
throw new TypeError("Provider source has no captured request slot");
|
|
539
|
+
const requestDigest = canonicalDigest(
|
|
540
|
+
{
|
|
541
|
+
messages: restoredMessages,
|
|
542
|
+
tools: selectedToolDefinitions,
|
|
543
|
+
},
|
|
544
|
+
PROVIDER_SOURCE_REQUEST_DOMAIN,
|
|
545
|
+
);
|
|
546
|
+
// Retain only the request commitment and source positions, not image/source bytes.
|
|
547
|
+
PROVIDER_SOURCE_MAPPINGS.set(
|
|
548
|
+
plan,
|
|
549
|
+
Object.freeze({
|
|
550
|
+
requestDigest,
|
|
551
|
+
rows: freezeSourceSnapshot(rows),
|
|
552
|
+
}),
|
|
553
|
+
);
|
|
554
|
+
const prepared = {
|
|
555
|
+
messages: restoredMessages,
|
|
556
|
+
selectedToolNames,
|
|
557
|
+
selectedToolDefinitions: freezeSourceSnapshot(selectedToolDefinitions),
|
|
401
558
|
plan,
|
|
402
559
|
recall,
|
|
403
560
|
decision: runtime.decision,
|
|
404
561
|
modelCapabilities,
|
|
405
562
|
};
|
|
563
|
+
// Keep host capabilities and authority paths out of serialized plan evidence.
|
|
564
|
+
return Object.defineProperties(prepared, {
|
|
565
|
+
admissionEnabled: { value: recallEnabled },
|
|
566
|
+
assertCurrent: { value: assertCurrent },
|
|
567
|
+
assertDispatchOpen: { value: assertDispatchOpen },
|
|
568
|
+
dispatchResource: {
|
|
569
|
+
value: recallEnabled
|
|
570
|
+
? Object.freeze({
|
|
571
|
+
key:
|
|
572
|
+
process.platform === "win32"
|
|
573
|
+
? runtime.memoryPort.filePath.toLowerCase()
|
|
574
|
+
: runtime.memoryPort.filePath,
|
|
575
|
+
revision: expectedRevision,
|
|
576
|
+
withLock: (operation, controls = {}) =>
|
|
577
|
+
runtime.memoryPort.withRevisionGuard(
|
|
578
|
+
expectedRevision,
|
|
579
|
+
operation,
|
|
580
|
+
{
|
|
581
|
+
signal: dispatchSignal(controls),
|
|
582
|
+
},
|
|
583
|
+
),
|
|
584
|
+
})
|
|
585
|
+
: null,
|
|
586
|
+
},
|
|
587
|
+
});
|
|
406
588
|
}
|
|
407
589
|
|
|
408
590
|
export { defaultAdmissions, toolDefinitionsToContextItems };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createLocalSemanticSource } from "./local-semantic-source.js";
|
|
1
2
|
import { ContextMemoryKernel } from "@chainlesschain/context-memory-kernel";
|
|
2
3
|
import { SegmentedMemoryPort } from "./segmented-memory-port.js";
|
|
3
4
|
import { JsonlSessionContextPort } from "./jsonl-session-context-port.js";
|
|
@@ -56,7 +57,46 @@ export function createCliContextMemoryRuntime(options = {}) {
|
|
|
56
57
|
...(options.randomUUID ? { randomUUID: options.randomUUID } : {}),
|
|
57
58
|
purgePorts,
|
|
58
59
|
});
|
|
60
|
+
const semanticSource = createLocalSemanticSource({
|
|
61
|
+
memoryPort,
|
|
62
|
+
env: options.env || process.env,
|
|
63
|
+
clock: options.clock || Date.now,
|
|
64
|
+
});
|
|
65
|
+
async function recallMemory(request, controls = {}) {
|
|
66
|
+
controls.signal?.throwIfAborted();
|
|
67
|
+
const useLocalSource =
|
|
68
|
+
decision.canonical &&
|
|
69
|
+
request.semanticCandidates === undefined &&
|
|
70
|
+
semanticSource.isEnabled() &&
|
|
71
|
+
request.query !== "*";
|
|
72
|
+
const sourceRevision = useLocalSource
|
|
73
|
+
? await memoryPort.getRevision(controls)
|
|
74
|
+
: null;
|
|
75
|
+
controls.signal?.throwIfAborted();
|
|
76
|
+
const candidates = useLocalSource
|
|
77
|
+
? await semanticSource.candidates(request, controls)
|
|
78
|
+
: undefined;
|
|
79
|
+
controls.signal?.throwIfAborted();
|
|
80
|
+
const result = await kernel.recallMemory(
|
|
81
|
+
{
|
|
82
|
+
...request,
|
|
83
|
+
...(candidates === undefined ? {} : { semanticCandidates: candidates }),
|
|
84
|
+
},
|
|
85
|
+
controls,
|
|
86
|
+
);
|
|
87
|
+
controls.signal?.throwIfAborted();
|
|
88
|
+
if (sourceRevision !== null && result.memoryRevision !== sourceRevision) {
|
|
89
|
+
const error = new Error(
|
|
90
|
+
"Memory changed during local semantic inference; prepare a fresh recall",
|
|
91
|
+
);
|
|
92
|
+
error.code = "revision_conflict";
|
|
93
|
+
error.noReplay = true;
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
59
98
|
return Object.freeze({
|
|
99
|
+
recallMemory,
|
|
60
100
|
decision,
|
|
61
101
|
kernel,
|
|
62
102
|
memoryPort,
|
|
@@ -801,7 +801,7 @@ export class SegmentedMemoryPort extends DurableJsonMemoryPort {
|
|
|
801
801
|
return cached.index;
|
|
802
802
|
let index;
|
|
803
803
|
try {
|
|
804
|
-
index = compileQueryIndex(bytes, descriptor);
|
|
804
|
+
index = compileQueryIndex(bytes, descriptor, { lazyPostings: true });
|
|
805
805
|
} catch (cause) {
|
|
806
806
|
throw corruptStore(
|
|
807
807
|
this.filePath,
|
|
@@ -1112,6 +1112,31 @@ export class SegmentedMemoryPort extends DurableJsonMemoryPort {
|
|
|
1112
1112
|
async getRevision({ signal } = {}) {
|
|
1113
1113
|
return this._locked(() => this._loadManifest().storeRevision, { signal });
|
|
1114
1114
|
}
|
|
1115
|
+
async withRevisionGuard(expectedRevision, operation, { signal } = {}) {
|
|
1116
|
+
if (
|
|
1117
|
+
!Number.isSafeInteger(expectedRevision) ||
|
|
1118
|
+
expectedRevision < 0 ||
|
|
1119
|
+
typeof operation !== "function"
|
|
1120
|
+
) {
|
|
1121
|
+
throw new TypeError("Memory dispatch requires a revision and operation");
|
|
1122
|
+
}
|
|
1123
|
+
return this._locked(
|
|
1124
|
+
() => {
|
|
1125
|
+
const currentRevision = this._loadManifest().storeRevision;
|
|
1126
|
+
if (currentRevision !== expectedRevision) {
|
|
1127
|
+
const error = new Error("Memory changed before provider dispatch");
|
|
1128
|
+
error.code = "revision_conflict";
|
|
1129
|
+
error.details = { expectedRevision, currentRevision };
|
|
1130
|
+
error.noReplay = true;
|
|
1131
|
+
throw error;
|
|
1132
|
+
}
|
|
1133
|
+
// The host operation returns a plain box containing the pending HTTP
|
|
1134
|
+
// Promise. Await lock acquisition/cleanup, never the network response.
|
|
1135
|
+
return operation();
|
|
1136
|
+
},
|
|
1137
|
+
{ signal },
|
|
1138
|
+
);
|
|
1139
|
+
}
|
|
1115
1140
|
async exportSnapshot() {
|
|
1116
1141
|
return this._locked(() => {
|
|
1117
1142
|
const manifest = this._loadManifest();
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
modelInputNodeDigest,
|
|
3
|
+
freezeModelInputMapping,
|
|
4
|
+
} from "../model-input-source-mapping.js";
|
|
1
5
|
import crypto from "node:crypto";
|
|
2
6
|
import { types } from "node:util";
|
|
3
7
|
import evolutionRun from "@chainlesschain/session-core/evolution-run";
|
|
@@ -45,6 +49,14 @@ const RESPONSE_CACHE_IDENTIFIER_BINDING_SCHEMA =
|
|
|
45
49
|
const HEX_ALPHA = "abcdefghijklmnop";
|
|
46
50
|
|
|
47
51
|
const INGRESSES = new WeakSet();
|
|
52
|
+
const MODEL_REQUEST_RECEIPTS = new WeakMap();
|
|
53
|
+
|
|
54
|
+
// Only requests released by this module after authenticated readback carry a
|
|
55
|
+
// receipt. Copied messages or provenance-looking text confer no authority.
|
|
56
|
+
export function getAgentModelRequestReceipt(request) {
|
|
57
|
+
return MODEL_REQUEST_RECEIPTS.get(request) ?? null;
|
|
58
|
+
}
|
|
59
|
+
|
|
48
60
|
const CORE_EVENT_KINDS = new Map([
|
|
49
61
|
["tool-executing", "tool-requested"],
|
|
50
62
|
["tool-result", "tool-completed"],
|
|
@@ -469,10 +481,52 @@ export function createAgentEvolutionIngress({
|
|
|
469
481
|
}),
|
|
470
482
|
});
|
|
471
483
|
}
|
|
472
|
-
|
|
484
|
+
const request = buildAgentModelRequest(
|
|
473
485
|
modelRequest,
|
|
474
486
|
resolved.bundle.modelProjection,
|
|
475
487
|
);
|
|
488
|
+
MODEL_REQUEST_RECEIPTS.set(
|
|
489
|
+
request,
|
|
490
|
+
Object.freeze({
|
|
491
|
+
tenantId: descriptor.tenantId,
|
|
492
|
+
runId: descriptor.runId,
|
|
493
|
+
eventId,
|
|
494
|
+
evidenceId: persisted.evidenceId,
|
|
495
|
+
manifestDigest: persisted.manifest.digest,
|
|
496
|
+
projectionDigest: resolved.bundle.modelProjection.projectionDigest,
|
|
497
|
+
rulesetDigest: resolved.bundle.modelProjection.rulesetDigest,
|
|
498
|
+
sourceMapping: freezeModelInputMapping({
|
|
499
|
+
inputDigest: modelInputNodeDigest(modelRequest),
|
|
500
|
+
outputDigest: modelInputNodeDigest(request),
|
|
501
|
+
slots: ["message", "tool"].flatMap((kind) => {
|
|
502
|
+
const key = kind === "message" ? "messages" : "tools";
|
|
503
|
+
return modelRequest[key].map((_, index) => {
|
|
504
|
+
const prefix = "$." + key + "." + index;
|
|
505
|
+
const belongs = (path) =>
|
|
506
|
+
path === prefix || path.startsWith(prefix + ".");
|
|
507
|
+
return {
|
|
508
|
+
kind,
|
|
509
|
+
index,
|
|
510
|
+
logicalIndex: index + (kind === "message" ? 1 : 0),
|
|
511
|
+
redactionTouched:
|
|
512
|
+
resolved.bundle.modelProjection.redactionSummary.paths.some(
|
|
513
|
+
belongs,
|
|
514
|
+
),
|
|
515
|
+
injectionTouched:
|
|
516
|
+
resolved.bundle.modelProjection.injectionFindings.some(
|
|
517
|
+
(finding) => belongs(finding.path),
|
|
518
|
+
),
|
|
519
|
+
};
|
|
520
|
+
});
|
|
521
|
+
}),
|
|
522
|
+
}),
|
|
523
|
+
redactionCount:
|
|
524
|
+
resolved.bundle.modelProjection.redactionSummary.total,
|
|
525
|
+
injectionCount:
|
|
526
|
+
resolved.bundle.modelProjection.injectionFindings.length,
|
|
527
|
+
}),
|
|
528
|
+
);
|
|
529
|
+
return request;
|
|
476
530
|
}),
|
|
477
531
|
);
|
|
478
532
|
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import crypto from "node:crypto";
|
|
12
12
|
import fs from "node:fs";
|
|
13
13
|
import path from "node:path";
|
|
14
|
+
import { performance } from "node:perf_hooks";
|
|
14
15
|
import { types as utilTypes } from "node:util";
|
|
15
16
|
import {
|
|
16
17
|
ArtifactStore,
|
|
@@ -27,6 +28,7 @@ import {
|
|
|
27
28
|
import {
|
|
28
29
|
recordStorageFailureReason,
|
|
29
30
|
recordStorageFailureStage,
|
|
31
|
+
recordStorageFailureClockWindow,
|
|
30
32
|
} from "../storage-failure-cause-codes.js";
|
|
31
33
|
import { artifactPhysicalIdentity as physicalIdentity } from "./evolution-artifact-identity.js";
|
|
32
34
|
import { withEvolutionFileIdentity } from "./evolution-file-identity.js";
|
|
@@ -4421,6 +4423,13 @@ export class EvolutionArtifactPorts {
|
|
|
4421
4423
|
chunks.push(frozenCanonicalClone(chunk));
|
|
4422
4424
|
}
|
|
4423
4425
|
const readHistory = (directoryScope) => {
|
|
4426
|
+
// Monotonic timing is observation only. Never substitute it for #clock().
|
|
4427
|
+
let observationStartedAt = null;
|
|
4428
|
+
try {
|
|
4429
|
+
observationStartedAt = performance.now();
|
|
4430
|
+
} catch {
|
|
4431
|
+
/* optional */
|
|
4432
|
+
}
|
|
4424
4433
|
const snapshot = readTrustedIndexSnapshot(this.#store.layout);
|
|
4425
4434
|
this.#indexLedgerBatchEntries(snapshot.entries);
|
|
4426
4435
|
const window = [];
|
|
@@ -4478,10 +4487,36 @@ export class EvolutionArtifactPorts {
|
|
|
4478
4487
|
completed < entry.checkedAt || completed >= entry.expiresAt,
|
|
4479
4488
|
)
|
|
4480
4489
|
) {
|
|
4481
|
-
|
|
4490
|
+
const error = artifactError(
|
|
4482
4491
|
EVOLUTION_ARTIFACT_EXPIRED_CODE,
|
|
4483
4492
|
"artifact authority expired before ledger history release",
|
|
4484
4493
|
);
|
|
4494
|
+
try {
|
|
4495
|
+
let elapsedMs = null;
|
|
4496
|
+
try {
|
|
4497
|
+
if (observationStartedAt !== null)
|
|
4498
|
+
elapsedMs = performance.now() - observationStartedAt;
|
|
4499
|
+
} catch {
|
|
4500
|
+
/* optional; retain the authoritative window observations */
|
|
4501
|
+
}
|
|
4502
|
+
recordStorageFailureClockWindow(error, {
|
|
4503
|
+
windowSize: window.length,
|
|
4504
|
+
backwardCount: window.filter((entry) => completed < entry.checkedAt)
|
|
4505
|
+
.length,
|
|
4506
|
+
expiredCount: window.filter((entry) => completed >= entry.expiresAt)
|
|
4507
|
+
.length,
|
|
4508
|
+
minRemainingMs: Math.min(
|
|
4509
|
+
...window.map((entry) => entry.expiresAt - completed),
|
|
4510
|
+
),
|
|
4511
|
+
maxReadAgeMs: Math.max(
|
|
4512
|
+
...window.map((entry) => completed - entry.checkedAt),
|
|
4513
|
+
),
|
|
4514
|
+
elapsedMs,
|
|
4515
|
+
});
|
|
4516
|
+
} catch {
|
|
4517
|
+
// Even a failed observer must preserve this exact rejection.
|
|
4518
|
+
}
|
|
4519
|
+
throw error;
|
|
4485
4520
|
}
|
|
4486
4521
|
return Object.freeze(results);
|
|
4487
4522
|
};
|
|
@@ -1484,7 +1484,9 @@ function normalizeRegistryOptions(options) {
|
|
|
1484
1484
|
options,
|
|
1485
1485
|
"rootDir",
|
|
1486
1486
|
"candidate registry options",
|
|
1487
|
-
|
|
1487
|
+
Object.hasOwn(options, "rootDir")
|
|
1488
|
+
? undefined
|
|
1489
|
+
: path.join(getHomeDir(), "evolution", "registry", "candidates"),
|
|
1488
1490
|
);
|
|
1489
1491
|
if (typeof rootDir !== "string" || rootDir.length < 1) {
|
|
1490
1492
|
throw registryError(
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
validateRequest,
|
|
13
13
|
validateResponse,
|
|
14
14
|
quoteNative,
|
|
15
|
+
nativePricingWindowAt,
|
|
15
16
|
convertToUsd,
|
|
16
17
|
} from "./formal-budget-contract.js";
|
|
17
18
|
|
|
@@ -107,7 +108,28 @@ export class FormalBudgetAuthority {
|
|
|
107
108
|
config.plan.digest === planDigest,
|
|
108
109
|
"Authority lineage/plan mismatch",
|
|
109
110
|
);
|
|
110
|
-
|
|
111
|
+
const activations = this.#db
|
|
112
|
+
.prepare("SELECT body FROM event WHERE kind='initialized'")
|
|
113
|
+
.all();
|
|
114
|
+
requireBudget(
|
|
115
|
+
activations.length === 1,
|
|
116
|
+
"Unique durable activation witness required",
|
|
117
|
+
);
|
|
118
|
+
const activation = JSON.parse(activations[0].body);
|
|
119
|
+
const openedAt = now();
|
|
120
|
+
requireBudget(
|
|
121
|
+
activation.activationDigest === row.digest &&
|
|
122
|
+
Number.isSafeInteger(activation.at) &&
|
|
123
|
+
activation.at >= 0 &&
|
|
124
|
+
Number.isSafeInteger(openedAt) &&
|
|
125
|
+
activation.at <= openedAt,
|
|
126
|
+
"Invalid durable activation time or identity",
|
|
127
|
+
);
|
|
128
|
+
// Reopening is also needed to settle an already dispatched request after
|
|
129
|
+
// its price/FX validity ends. Verify the original activation against its
|
|
130
|
+
// durable time, then recheck today's expiry in #contract before every
|
|
131
|
+
// new reservation/dispatch. No expired contract can start a new call.
|
|
132
|
+
this.#config = validateActivation(config, verifyEvidence, activation.at);
|
|
111
133
|
requireBudget(
|
|
112
134
|
this.#db.pragma("quick_check", { simple: true }) === "ok",
|
|
113
135
|
"Corrupt budget database",
|
|
@@ -509,10 +531,17 @@ export class FormalBudgetAuthority {
|
|
|
509
531
|
validateRequest(contract, body) === call.request_digest,
|
|
510
532
|
"Reserved request changed",
|
|
511
533
|
);
|
|
534
|
+
const dispatchedAt = this.#now();
|
|
535
|
+
const pricingWindow = nativePricingWindowAt(contract, dispatchedAt);
|
|
512
536
|
this.#db
|
|
513
537
|
.prepare("UPDATE call SET state='dispatched' WHERE id=?")
|
|
514
538
|
.run(callId);
|
|
515
|
-
this.#event("dispatch", {
|
|
539
|
+
this.#event("dispatch", {
|
|
540
|
+
callId,
|
|
541
|
+
...(pricingWindow
|
|
542
|
+
? { nativePricing: { dispatchedAt, windowId: pricingWindow.id } }
|
|
543
|
+
: {}),
|
|
544
|
+
});
|
|
516
545
|
return JSON.parse(canonical(contract));
|
|
517
546
|
});
|
|
518
547
|
}
|
|
@@ -590,7 +619,30 @@ export class FormalBudgetAuthority {
|
|
|
590
619
|
(rate) => rate.currency === contract.currency,
|
|
591
620
|
);
|
|
592
621
|
const usage = validateResponse(contract, receipt);
|
|
593
|
-
|
|
622
|
+
let nativePricing;
|
|
623
|
+
if (Object.hasOwn(contract, "pricingWindows")) {
|
|
624
|
+
const witnesses = this.#db
|
|
625
|
+
.prepare(
|
|
626
|
+
"SELECT body FROM event WHERE kind='dispatch' AND json_extract(body,'$.callId')=?",
|
|
627
|
+
)
|
|
628
|
+
.all(callId);
|
|
629
|
+
requireBudget(
|
|
630
|
+
witnesses.length === 1,
|
|
631
|
+
"A unique durable dispatch pricing witness is required",
|
|
632
|
+
);
|
|
633
|
+
nativePricing = JSON.parse(witnesses[0].body).nativePricing;
|
|
634
|
+
requireBudget(
|
|
635
|
+
nativePricing &&
|
|
636
|
+
Object.keys(nativePricing).length === 2 &&
|
|
637
|
+
Object.keys(nativePricing).every((key) =>
|
|
638
|
+
["dispatchedAt", "windowId"].includes(key),
|
|
639
|
+
) &&
|
|
640
|
+
nativePricingWindowAt(contract, nativePricing.dispatchedAt)
|
|
641
|
+
?.id === nativePricing.windowId,
|
|
642
|
+
"Dispatch pricing witness differs from the attested schedule",
|
|
643
|
+
);
|
|
644
|
+
}
|
|
645
|
+
const native = quoteNative(contract, usage, nativePricing),
|
|
594
646
|
usd = convertToUsd(native, fx);
|
|
595
647
|
requireBudget(
|
|
596
648
|
native <= call.reserved_native && usd <= call.reserved_usd,
|
|
@@ -612,6 +664,7 @@ export class FormalBudgetAuthority {
|
|
|
612
664
|
costUsdMicros: usd,
|
|
613
665
|
costNativeMicros: native,
|
|
614
666
|
currency: contract.currency,
|
|
667
|
+
...(nativePricing ? { nativePricing } : {}),
|
|
615
668
|
});
|
|
616
669
|
return {
|
|
617
670
|
costUsdMicros: usd,
|