@graphrefly/ts 0.0.1 → 0.0.3
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 +197 -117
- package/dist/actions-types-CH-XCU9O.d.cts +657 -0
- package/dist/actions-types-w2iPQTkv.d.ts +657 -0
- package/dist/adapters/index.cjs +5157 -2951
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +207 -70
- package/dist/adapters/index.d.ts +207 -70
- package/dist/adapters/index.js +3738 -1688
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/nestjs/microservices.cjs +841 -0
- package/dist/adapters/nestjs/microservices.cjs.map +1 -0
- package/dist/adapters/nestjs/microservices.d.cts +45 -0
- package/dist/adapters/nestjs/microservices.d.ts +45 -0
- package/dist/adapters/nestjs/microservices.js +206 -0
- package/dist/adapters/nestjs/microservices.js.map +1 -0
- package/dist/adapters/nestjs/native.cjs +1391 -0
- package/dist/adapters/nestjs/native.cjs.map +1 -0
- package/dist/adapters/nestjs/native.d.cts +111 -0
- package/dist/adapters/nestjs/native.d.ts +111 -0
- package/dist/adapters/nestjs/native.js +577 -0
- package/dist/adapters/nestjs/native.js.map +1 -0
- package/dist/adapters/nestjs/websockets.cjs +924 -0
- package/dist/adapters/nestjs/websockets.cjs.map +1 -0
- package/dist/adapters/nestjs/websockets.d.cts +47 -0
- package/dist/adapters/nestjs/websockets.d.ts +47 -0
- package/dist/adapters/nestjs/websockets.js +286 -0
- package/dist/adapters/nestjs/websockets.js.map +1 -0
- package/dist/adapters/nestjs.cjs +1085 -0
- package/dist/adapters/nestjs.cjs.map +1 -0
- package/dist/adapters/nestjs.d.cts +385 -0
- package/dist/adapters/nestjs.d.ts +385 -0
- package/dist/adapters/nestjs.js +112 -0
- package/dist/adapters/nestjs.js.map +1 -0
- package/dist/adapters/observe-storage.d.cts +3 -3
- package/dist/adapters/observe-storage.d.ts +3 -3
- package/dist/adapters/observe-storage.js +4 -4
- package/dist/adapters/react.cjs.map +1 -1
- package/dist/adapters/react.d.cts +2 -2
- package/dist/adapters/react.d.ts +2 -2
- package/dist/adapters/react.js +1 -1
- package/dist/adapters/solid.cjs.map +1 -1
- package/dist/adapters/solid.d.cts +2 -2
- package/dist/adapters/solid.d.ts +2 -2
- package/dist/adapters/solid.js +1 -1
- package/dist/adapters/svelte.cjs.map +1 -1
- package/dist/adapters/svelte.d.cts +2 -2
- package/dist/adapters/svelte.d.ts +2 -2
- package/dist/adapters/svelte.js +1 -1
- package/dist/adapters/vue.cjs.map +1 -1
- package/dist/adapters/vue.d.cts +2 -2
- package/dist/adapters/vue.d.ts +2 -2
- package/dist/adapters/vue.js +1 -1
- package/dist/{agent-runtime-BesGDZcB.d.ts → agent-runtime-types-core-CKwrBDyi.d.ts} +171 -320
- package/dist/{agent-runtime-DZTJ3C-p.d.cts → agent-runtime-types-core-bfl4m0vM.d.cts} +171 -320
- package/dist/agent-runtime-types-tool-BLPV3azj.d.cts +695 -0
- package/dist/agent-runtime-types-tool-hwqvVqNt.d.ts +695 -0
- package/dist/agentic-memory-retention-CLwI76JK.d.ts +14 -0
- package/dist/agentic-memory-retention-Cz8GR6ie.d.cts +14 -0
- package/dist/{agentic-memory-DfuVZ-lY.d.cts → agentic-memory-types-JDr7MPhh.d.cts} +13 -57
- package/dist/{agentic-memory-BmRCvh0d.d.ts → agentic-memory-types-khYJgzKL.d.ts} +13 -57
- package/dist/{capability-admission-B0BzqAm5.d.cts → capability-admission-B8RNFyaZ.d.cts} +3 -3
- package/dist/{capability-admission-g0mn9hpq.d.ts → capability-admission-Dkw1Xz3r.d.ts} +3 -3
- package/dist/chunk-2KUAG2GZ.js +9693 -0
- package/dist/chunk-2KUAG2GZ.js.map +1 -0
- package/dist/{chunk-CZNV3VXM.js → chunk-3J7UPZL5.js} +11 -11
- package/dist/{chunk-HKK2JD7Z.js → chunk-3LYI6ADX.js} +12 -125
- package/dist/chunk-3LYI6ADX.js.map +1 -0
- package/dist/{chunk-YXMZ2N6J.js → chunk-4M37FH2I.js} +1071 -1025
- package/dist/chunk-4M37FH2I.js.map +1 -0
- package/dist/{chunk-YDSIVHRR.js → chunk-4NWSNI4K.js} +1598 -1584
- package/dist/chunk-4NWSNI4K.js.map +1 -0
- package/dist/{chunk-Z2ANQ6JW.js → chunk-4Q77MMJY.js} +2 -2
- package/dist/{chunk-SS2A464I.js → chunk-54WPEODM.js} +3 -3
- package/dist/chunk-54WPEODM.js.map +1 -0
- package/dist/chunk-6E76H4OU.js +132 -0
- package/dist/chunk-6E76H4OU.js.map +1 -0
- package/dist/chunk-7GOTIIQ7.js +819 -0
- package/dist/chunk-7GOTIIQ7.js.map +1 -0
- package/dist/{chunk-V7CIJE4B.js → chunk-DKFWDTVY.js} +92 -9
- package/dist/chunk-DKFWDTVY.js.map +1 -0
- package/dist/{chunk-FBUU43PM.js → chunk-E4QCH32M.js} +448 -446
- package/dist/chunk-E4QCH32M.js.map +1 -0
- package/dist/{chunk-XKXWK2KP.js → chunk-GXU6WFEJ.js} +1157 -1021
- package/dist/chunk-GXU6WFEJ.js.map +1 -0
- package/dist/{chunk-K3FXTC3I.js → chunk-HJACH5PU.js} +3 -3
- package/dist/{chunk-GTPCOEOZ.js → chunk-IDMLXLLG.js} +3 -3
- package/dist/{chunk-DKP56CSW.js → chunk-JKAYLDQV.js} +2 -2
- package/dist/{chunk-4VLAQHZI.js → chunk-K7FB3JTD.js} +17 -1
- package/dist/chunk-K7FB3JTD.js.map +1 -0
- package/dist/{chunk-43BKLFZU.js → chunk-KFURM6FM.js} +10 -10
- package/dist/{chunk-H75VXTGT.js → chunk-L6LDXRWE.js} +3 -3
- package/dist/{chunk-H75VXTGT.js.map → chunk-L6LDXRWE.js.map} +1 -1
- package/dist/chunk-MCOFHMUU.js +4131 -0
- package/dist/chunk-MCOFHMUU.js.map +1 -0
- package/dist/chunk-MQEQMS7B.js +1009 -0
- package/dist/chunk-MQEQMS7B.js.map +1 -0
- package/dist/chunk-MTELVIYR.js +1421 -0
- package/dist/chunk-MTELVIYR.js.map +1 -0
- package/dist/{chunk-3JR3EDB2.js → chunk-NNDIFUKX.js} +121 -115
- package/dist/chunk-NNDIFUKX.js.map +1 -0
- package/dist/{chunk-2747WN4Y.js → chunk-PUSRRALM.js} +3 -3
- package/dist/{chunk-QFY4AFY4.js → chunk-PVC7WDKI.js} +58 -52
- package/dist/chunk-PVC7WDKI.js.map +1 -0
- package/dist/{chunk-VTHLCFN4.js → chunk-RAHNUYA5.js} +2 -2
- package/dist/chunk-TQPCAIQI.js +612 -0
- package/dist/chunk-TQPCAIQI.js.map +1 -0
- package/dist/{chunk-IXZBUWSP.js → chunk-UEMN5URK.js} +2 -2
- package/dist/chunk-WOS7RJYZ.js +1320 -0
- package/dist/chunk-WOS7RJYZ.js.map +1 -0
- package/dist/{chunk-6PHB5CJS.js → chunk-ZLFRB6FI.js} +2 -2
- package/dist/composition/index.cjs +1228 -1076
- package/dist/composition/index.cjs.map +1 -1
- package/dist/composition/index.d.cts +3 -3
- package/dist/composition/index.d.ts +3 -3
- package/dist/composition/index.js +4 -4
- package/dist/core/index.cjs +1198 -1046
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +23 -2
- package/dist/core/index.d.ts +23 -2
- package/dist/core/index.js +2 -2
- package/dist/cqrs/index.d.cts +3 -3
- package/dist/cqrs/index.d.ts +3 -3
- package/dist/cqrs/messaging.d.cts +4 -4
- package/dist/cqrs/messaging.d.ts +4 -4
- package/dist/cqrs/work-queue.d.cts +5 -5
- package/dist/cqrs/work-queue.d.ts +5 -5
- package/dist/data-structures/index.cjs +1226 -1074
- package/dist/data-structures/index.cjs.map +1 -1
- package/dist/data-structures/index.d.cts +8 -7
- package/dist/data-structures/index.d.ts +8 -7
- package/dist/data-structures/index.js +6 -5
- package/dist/{describe-DYMw_l1C.d.cts → describe-BumQ-3_0.d.cts} +1 -1
- package/dist/{describe-BpyJuWkw.d.ts → describe-cYr_Z5zm.d.ts} +1 -1
- package/dist/executors/tool-provider-adapters.cjs +3091 -0
- package/dist/executors/tool-provider-adapters.cjs.map +1 -0
- package/dist/executors/tool-provider-adapters.d.cts +174 -0
- package/dist/executors/tool-provider-adapters.d.ts +174 -0
- package/dist/executors/tool-provider-adapters.js +1336 -0
- package/dist/executors/tool-provider-adapters.js.map +1 -0
- package/dist/executors/tool-provider-runtime.cjs +5178 -0
- package/dist/executors/tool-provider-runtime.cjs.map +1 -0
- package/dist/executors/tool-provider-runtime.d.cts +17 -0
- package/dist/executors/tool-provider-runtime.d.ts +17 -0
- package/dist/executors/tool-provider-runtime.js +15 -0
- package/dist/executors/tool-provider-runtime.js.map +1 -0
- package/dist/executors/tool-provider.cjs +6392 -0
- package/dist/executors/tool-provider.cjs.map +1 -0
- package/dist/executors/tool-provider.d.cts +60 -0
- package/dist/executors/tool-provider.d.ts +60 -0
- package/dist/executors/tool-provider.js +89 -0
- package/dist/executors/tool-provider.js.map +1 -0
- package/dist/executors/work-queue.d.cts +6 -6
- package/dist/executors/work-queue.d.ts +6 -6
- package/dist/graph/index.cjs +1499 -1341
- package/dist/graph/index.cjs.map +1 -1
- package/dist/graph/index.d.cts +9 -8
- package/dist/graph/index.d.ts +9 -8
- package/dist/graph/index.js +23 -22
- package/dist/{graph-DCEWh4T2.d.cts → graph-C1C-wb0L.d.cts} +266 -137
- package/dist/{graph-D-1-SQeC.d.ts → graph-CS0b4V9B.d.ts} +266 -137
- package/dist/{index-72VZC0-E.d.cts → index-DLrNopda.d.cts} +151 -10
- package/dist/{index-Bmxeu0nK.d.ts → index-DzJni3_6.d.ts} +151 -10
- package/dist/index.cjs +3397 -3140
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -9
- package/dist/index.d.ts +12 -9
- package/dist/index.js +110 -109
- package/dist/inspection/boundary.d.cts +4 -4
- package/dist/inspection/boundary.d.ts +4 -4
- package/dist/measurements-BWAnochv.d.ts +294 -0
- package/dist/measurements-B_gJfD8h.d.cts +294 -0
- package/dist/messaging/index.cjs +57 -51
- package/dist/messaging/index.cjs.map +1 -1
- package/dist/messaging/index.d.cts +11 -276
- package/dist/messaging/index.d.ts +11 -276
- package/dist/messaging/index.js +1 -1
- package/dist/operators/index.cjs +1228 -1076
- package/dist/operators/index.cjs.map +1 -1
- package/dist/operators/index.d.cts +5 -5
- package/dist/operators/index.d.ts +5 -5
- package/dist/operators/index.js +5 -5
- package/dist/orchestration/index.cjs +8844 -6071
- package/dist/orchestration/index.cjs.map +1 -1
- package/dist/orchestration/index.d.cts +171 -224
- package/dist/orchestration/index.d.ts +171 -224
- package/dist/orchestration/index.js +42 -991
- package/dist/orchestration/index.js.map +1 -1
- package/dist/orchestration/messaging.d.cts +5 -8
- package/dist/orchestration/messaging.d.ts +5 -8
- package/dist/orchestration/work-queue.cjs +1243 -5
- package/dist/orchestration/work-queue.cjs.map +1 -1
- package/dist/orchestration/work-queue.d.cts +121 -10
- package/dist/orchestration/work-queue.d.ts +121 -10
- package/dist/orchestration/work-queue.js +1067 -4
- package/dist/orchestration/work-queue.js.map +1 -1
- package/dist/patterns/event-flow.cjs +6 -20
- package/dist/patterns/event-flow.cjs.map +1 -1
- package/dist/patterns/event-flow.d.cts +4 -4
- package/dist/patterns/event-flow.d.ts +4 -4
- package/dist/patterns/event-flow.js +2 -2
- package/dist/patterns/index.cjs +453 -465
- package/dist/patterns/index.cjs.map +1 -1
- package/dist/patterns/index.d.cts +6 -5
- package/dist/patterns/index.d.ts +6 -5
- package/dist/patterns/index.js +3 -3
- package/dist/process-types-BB7oRhX3.d.cts +200 -0
- package/dist/process-types-QNhyoYJ8.d.ts +200 -0
- package/dist/{reactive-collection-DNV0-gFi.d.cts → reactive-collection-BYlWvtnp.d.cts} +4 -34
- package/dist/{reactive-collection-BAmfrGjd.d.ts → reactive-collection-efOEdGFN.d.ts} +4 -34
- package/dist/{reactive-collection-storage-BNEldDyi.d.cts → reactive-collection-storage-BjoLsoiC.d.cts} +5 -5
- package/dist/{reactive-collection-storage-YZsAQsWK.d.ts → reactive-collection-storage-DwW6UuK_.d.ts} +5 -5
- package/dist/{reactive-map-DRD1LJ2H.d.cts → reactive-map-BHacbIqz.d.cts} +7 -2
- package/dist/{reactive-map-EsDiCmJk.d.ts → reactive-map-DN4Jyqnf.d.ts} +7 -2
- package/dist/render/index.d.cts +2 -2
- package/dist/render/index.d.ts +2 -2
- package/dist/scheduled-readiness-BmqXxnzX.d.ts +91 -0
- package/dist/scheduled-readiness-CYSw7KDE.d.cts +91 -0
- package/dist/semantic-memory-graph-B_LwbM-E.d.cts +30 -0
- package/dist/semantic-memory-graph-rsFNNhwn.d.ts +30 -0
- package/dist/{semantic-memory-graph-DKuNzuWw.d.cts → semantic-memory-graph-types-Y73bbwVI.d.cts} +2 -28
- package/dist/{semantic-memory-graph-uwbwJdhe.d.ts → semantic-memory-graph-types-safmPkuX.d.ts} +2 -28
- package/dist/solutions/index.cjs +6353 -6169
- package/dist/solutions/index.cjs.map +1 -1
- package/dist/solutions/index.d.cts +12 -10
- package/dist/solutions/index.d.ts +12 -10
- package/dist/solutions/index.js +5 -5
- package/dist/solutions/reactive-layout/browser/index.cjs +116 -108
- package/dist/solutions/reactive-layout/browser/index.cjs.map +1 -1
- package/dist/solutions/reactive-layout/browser/index.d.cts +4 -4
- package/dist/solutions/reactive-layout/browser/index.d.ts +4 -4
- package/dist/solutions/reactive-layout/browser/index.js +3 -3
- package/dist/solutions/reactive-layout/index.cjs +3578 -3350
- package/dist/solutions/reactive-layout/index.cjs.map +1 -1
- package/dist/solutions/reactive-layout/index.d.cts +32 -576
- package/dist/solutions/reactive-layout/index.d.ts +32 -576
- package/dist/solutions/reactive-layout/index.js +65 -5
- package/dist/solutions/reactive-layout/node-canvas/index.cjs +127 -117
- package/dist/solutions/reactive-layout/node-canvas/index.cjs.map +1 -1
- package/dist/solutions/reactive-layout/node-canvas/index.d.cts +4 -4
- package/dist/solutions/reactive-layout/node-canvas/index.d.ts +4 -4
- package/dist/solutions/reactive-layout/node-canvas/index.js +3 -3
- package/dist/solutions/reactive-layout/react-native/index.cjs +127 -117
- package/dist/solutions/reactive-layout/react-native/index.cjs.map +1 -1
- package/dist/solutions/reactive-layout/react-native/index.d.cts +4 -4
- package/dist/solutions/reactive-layout/react-native/index.d.ts +4 -4
- package/dist/solutions/reactive-layout/react-native/index.js +3 -3
- package/dist/solutions/reactive-layout/skia/index.cjs +127 -117
- package/dist/solutions/reactive-layout/skia/index.cjs.map +1 -1
- package/dist/solutions/reactive-layout/skia/index.d.cts +4 -4
- package/dist/solutions/reactive-layout/skia/index.d.ts +4 -4
- package/dist/solutions/reactive-layout/skia/index.js +3 -3
- package/dist/solutions/work-item/actions.cjs +1609 -1428
- package/dist/solutions/work-item/actions.cjs.map +1 -1
- package/dist/solutions/work-item/actions.d.cts +23 -184
- package/dist/solutions/work-item/actions.d.ts +23 -184
- package/dist/solutions/work-item/actions.js +1558 -934
- package/dist/solutions/work-item/actions.js.map +1 -1
- package/dist/solutions/work-item/scheduling.cjs +9181 -1838
- package/dist/solutions/work-item/scheduling.cjs.map +1 -1
- package/dist/solutions/work-item/scheduling.d.cts +1763 -328
- package/dist/solutions/work-item/scheduling.d.ts +1763 -328
- package/dist/solutions/work-item/scheduling.js +117 -3
- package/dist/solutions/work-item/work-queue.d.cts +7 -7
- package/dist/solutions/work-item/work-queue.d.ts +7 -7
- package/dist/sources/browser.cjs +1318 -1083
- package/dist/sources/browser.cjs.map +1 -1
- package/dist/sources/browser.d.cts +22 -6
- package/dist/sources/browser.d.ts +22 -6
- package/dist/sources/browser.js +4 -4
- package/dist/sources/browser.js.map +1 -1
- package/dist/sources/index.cjs +1318 -1083
- package/dist/sources/index.cjs.map +1 -1
- package/dist/sources/index.d.cts +4 -4
- package/dist/sources/index.d.ts +4 -4
- package/dist/sources/index.js +4 -4
- package/dist/sources/node.d.cts +3 -3
- package/dist/sources/node.d.ts +3 -3
- package/dist/storage/browser.cjs +16 -0
- package/dist/storage/browser.cjs.map +1 -1
- package/dist/storage/browser.js +3 -3
- package/dist/storage/index.cjs +16 -0
- package/dist/storage/index.cjs.map +1 -1
- package/dist/storage/index.d.cts +5 -4
- package/dist/storage/index.d.ts +5 -4
- package/dist/storage/index.js +6 -6
- package/dist/storage/node.cjs +16 -0
- package/dist/storage/node.cjs.map +1 -1
- package/dist/storage/node.js +3 -3
- package/dist/{store-C-joM4gh.d.ts → store-6_CHF6Ge.d.ts} +1 -1
- package/dist/{store-CNJwmT-h.d.cts → store-BljX8RkQ.d.cts} +1 -1
- package/dist/types-BAw2QVVE.d.cts +274 -0
- package/dist/types-BUbbbh4f.d.cts +34 -0
- package/dist/types-CMnzoL54.d.cts +457 -0
- package/dist/{types-CcPIn7sy.d.cts → types-CTN3XoMl.d.cts} +57 -108
- package/dist/types-CV_ohy5T.d.cts +357 -0
- package/dist/{types-BsJvElYZ.d.ts → types-DChxk1vK.d.ts} +57 -108
- package/dist/types-DRu7SnLV.d.ts +274 -0
- package/dist/types-DeID_FRl.d.ts +34 -0
- package/dist/types-IhKH0hGW.d.ts +357 -0
- package/dist/types-ePlD2uyT.d.ts +457 -0
- package/dist/{work-item-runtime-qaVgsL0T.d.cts → work-item-runtime-types-BTxLskN5.d.cts} +3 -93
- package/dist/{work-item-runtime-C3M79vE9.d.ts → work-item-runtime-types-DAsZbb2y.d.ts} +3 -93
- package/dist/work-queue/index.cjs +957 -953
- package/dist/work-queue/index.cjs.map +1 -1
- package/dist/work-queue/index.d.cts +9 -357
- package/dist/work-queue/index.d.ts +9 -357
- package/dist/work-queue/index.js +957 -953
- package/dist/work-queue/index.js.map +1 -1
- package/package.json +611 -513
- package/dist/chunk-3JR3EDB2.js.map +0 -1
- package/dist/chunk-4VLAQHZI.js.map +0 -1
- package/dist/chunk-6XAIOL3X.js +0 -2407
- package/dist/chunk-6XAIOL3X.js.map +0 -1
- package/dist/chunk-FBUU43PM.js.map +0 -1
- package/dist/chunk-HKK2JD7Z.js.map +0 -1
- package/dist/chunk-PC3BTTBE.js +0 -3217
- package/dist/chunk-PC3BTTBE.js.map +0 -1
- package/dist/chunk-QFY4AFY4.js.map +0 -1
- package/dist/chunk-SS2A464I.js.map +0 -1
- package/dist/chunk-V7CIJE4B.js.map +0 -1
- package/dist/chunk-XKXWK2KP.js.map +0 -1
- package/dist/chunk-YDSIVHRR.js.map +0 -1
- package/dist/chunk-YXMZ2N6J.js.map +0 -1
- /package/dist/{chunk-CZNV3VXM.js.map → chunk-3J7UPZL5.js.map} +0 -0
- /package/dist/{chunk-Z2ANQ6JW.js.map → chunk-4Q77MMJY.js.map} +0 -0
- /package/dist/{chunk-K3FXTC3I.js.map → chunk-HJACH5PU.js.map} +0 -0
- /package/dist/{chunk-GTPCOEOZ.js.map → chunk-IDMLXLLG.js.map} +0 -0
- /package/dist/{chunk-DKP56CSW.js.map → chunk-JKAYLDQV.js.map} +0 -0
- /package/dist/{chunk-43BKLFZU.js.map → chunk-KFURM6FM.js.map} +0 -0
- /package/dist/{chunk-2747WN4Y.js.map → chunk-PUSRRALM.js.map} +0 -0
- /package/dist/{chunk-VTHLCFN4.js.map → chunk-RAHNUYA5.js.map} +0 -0
- /package/dist/{chunk-IXZBUWSP.js.map → chunk-UEMN5URK.js.map} +0 -0
- /package/dist/{chunk-6PHB5CJS.js.map → chunk-ZLFRB6FI.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/executors/tool-provider-adapters.ts","../../src/protocol/messages.ts","../../src/ctx/types.ts","../../src/orchestration/agent-runtime-common.ts","../../src/orchestration/agent-runtime-adapter-run.ts","../../src/orchestration/agent-runtime-executor-outcome.ts","../../src/orchestration/agent-runtime-tool-provider-policy.ts"],"sourcesContent":["/**\n * Concrete Layer C tool-provider adapter pack v0 (D283/D359-D362).\n *\n * Adapter factories return graph-visible catalog DATA plus runtime-private\n * bindings. Permission checks are enforced by the binding closure; catalog\n * policy remains descriptive admission/routing/audit material, not a security\n * boundary.\n */\n\nimport { spawnSync } from \"node:child_process\";\nimport { realpathSync } from \"node:fs\";\nimport { isAbsolute, relative, resolve } from \"node:path\";\nimport type { DataIssue } from \"../data/index.js\";\nimport type { Graph } from \"../graph/graph.js\";\nimport type { Node } from \"../node/node.js\";\nimport {\n\ttype AgentRequestStatusChanged,\n\ttype AgentRuntimeAuditRecord,\n\tbuildToolProviderExecutorOutcome,\n\ttype ExecutorArtifactMaterial,\n\ttype ExecutorOutcome,\n\tlocalBuiltinToolProviderCatalog,\n\ttype SizeCapacityEvidence,\n\ttype SourceRef,\n\ttype ToolProviderAdapterInput,\n\ttype ToolProviderAdapterRunRequested,\n\ttype ToolProviderAdapterRunStatus,\n\ttype ToolProviderCatalog,\n\ttype ToolProviderCatalogEntry,\n\ttype ToolProviderExecutionPolicy,\n\ttype ToolProviderPublicTextPolicy,\n\ttype ToolProviderSizeLimit,\n\ttoolProviderAdapterRunProjector,\n} from \"../orchestration/index.js\";\nimport type {\n\tToolProviderAdapterBinding,\n\tToolProviderAdapterRunContext,\n\tToolProviderAdapterRunResult,\n} from \"./tool-provider-runtime.js\";\n\nexport interface ToolProviderAdapterPack<TArguments = unknown, TResult = unknown> {\n\treadonly catalogs: readonly ToolProviderCatalog[];\n\treadonly bindings: readonly ToolProviderAdapterBinding<TArguments, TResult>[];\n}\n\nexport type LocalBuiltinToolName = \"date.now\" | \"json.parse\" | \"text.concat\";\n\nexport interface LocalBuiltinToolArguments {\n\treadonly text?: string;\n\treadonly parts?: readonly unknown[];\n\treadonly separator?: string;\n}\n\nexport type LocalBuiltinToolResult =\n\t| { readonly toolName: \"date.now\"; readonly epochMs: number; readonly iso: string }\n\t| { readonly toolName: \"json.parse\"; readonly value: unknown }\n\t| { readonly toolName: \"text.concat\"; readonly text: string };\n\nexport interface LocalBuiltinToolProviderBindingOptions {\n\treadonly providerId?: string;\n\treadonly now?: () => number;\n\treadonly maxTextChars?: number;\n}\n\nexport interface LocalBuiltinToolProviderAdapterPackOptions\n\textends LocalBuiltinToolProviderBindingOptions {\n\treadonly executorId?: string;\n\treadonly profileId?: string;\n\treadonly publicText?: ToolProviderPublicTextPolicy;\n}\n\nexport interface ProcessToolArguments {\n\treadonly command?: string;\n\treadonly args?: readonly string[];\n\treadonly cwd?: string;\n\treadonly env?: Readonly<Record<string, string | number | boolean | undefined>>;\n\treadonly input?: string;\n}\n\nexport interface ProcessToolResult {\n\treadonly command: string;\n\treadonly args: readonly string[];\n\treadonly cwd: string;\n\treadonly exitCode: number | null;\n\treadonly signal?: string;\n\treadonly outputPreview?: string;\n\treadonly errorPreview?: string;\n\treadonly outputBytes: number;\n\treadonly errorOutputBytes: number;\n\treadonly truncated: boolean;\n}\n\nexport interface ProcessToolAllowedCommand {\n\t/** Public command key accepted in tool arguments. */\n\treadonly command: string;\n\t/** Runtime executable. Defaults to `command`. This stays binding-private. */\n\treadonly executable?: string;\n\treadonly fixedArgs?: readonly string[];\n\t/** Explicit argv policy. `true` allows any argv array; omitted means no extra args. */\n\treadonly allowArgs?: true | readonly string[] | ((args: readonly string[]) => boolean);\n\treadonly cwd?: string;\n}\n\nexport interface ProcessToolProviderBindingOptions {\n\treadonly providerId?: string;\n\treadonly allowedCommands?: readonly ProcessToolAllowedCommand[];\n\treadonly workingDirectory?: string;\n\treadonly allowedWorkingDirectories?: readonly string[];\n\treadonly baseEnv?: Readonly<Record<string, string>>;\n\treadonly allowedEnvKeys?: readonly string[];\n\treadonly timeoutMs?: number;\n\treadonly maxOutputBytes?: number;\n\treadonly maxSummaryChars?: number;\n}\n\nexport interface ProcessToolProviderAdapterPackOptions extends ProcessToolProviderBindingOptions {\n\treadonly executorId?: string;\n\treadonly profileId?: string;\n}\n\nexport interface HttpToolArguments {\n\treadonly url?: string;\n\treadonly method?: string;\n\treadonly headers?: Readonly<Record<string, string | number | boolean | undefined>>;\n\treadonly body?: string;\n}\n\nexport interface HttpToolResult {\n\treadonly url: string;\n\treadonly method: string;\n\treadonly status: number;\n\treadonly statusText: string;\n\treadonly headers?: Readonly<Record<string, string>>;\n\treadonly bodyPreview?: string;\n\treadonly bodyText?: string;\n\treadonly bodyBytes: number;\n\treadonly bodyTruncated: boolean;\n\treadonly dataMode: \"inline\" | \"summary\" | \"ref\";\n\treadonly bodyRef?: SourceRef;\n}\n\nexport interface HttpToolProviderDriverRequest {\n\treadonly url: string;\n\treadonly method: string;\n\treadonly headers: Readonly<Record<string, string>>;\n\treadonly body?: string;\n\treadonly signal?: AbortSignal;\n}\n\nexport interface HttpToolProviderDriverResponse {\n\treadonly url?: string;\n\treadonly status: number;\n\treadonly statusText?: string;\n\treadonly headers?: Readonly<Record<string, string>>;\n\treadonly bodyText?: string;\n\treadonly bodyBytes?: number;\n\treadonly bodyRef?: SourceRef;\n}\n\nexport interface HttpToolProviderDriver {\n\tfetch(\n\t\trequest: HttpToolProviderDriverRequest,\n\t): HttpToolProviderDriverResponse | PromiseLike<HttpToolProviderDriverResponse>;\n}\n\nexport interface HttpToolProviderRuntimeOptions {\n\treadonly name?: string;\n\treadonly providerId?: string;\n\treadonly executorId?: string;\n\treadonly profileId?: string;\n\treadonly inputs: Node<ToolProviderAdapterInput<HttpToolArguments>>;\n\treadonly runRequests?: readonly Node<ToolProviderAdapterRunRequested>[];\n\treadonly autoRunReadyInputs?: boolean;\n\treadonly allowedOrigins?: readonly string[];\n\treadonly allowedMethods?: readonly string[];\n\treadonly allowedRequestHeaders?: readonly string[];\n\treadonly exposedResponseHeaders?: readonly string[];\n\treadonly timeoutMs?: number;\n\treadonly maxResponseBytes?: number;\n\treadonly maxInlineBodyChars?: number;\n\treadonly approvalMode?: \"auto\" | \"require\" | \"never\";\n\treadonly driver?: HttpToolProviderDriver;\n\treadonly now?: () => number;\n\treadonly publicText?: ToolProviderPublicTextPolicy;\n}\n\nexport interface HttpToolProviderRuntimeBundle {\n\treadonly catalogs: readonly ToolProviderCatalog[];\n\treadonly runRequests: Node<ToolProviderAdapterRunRequested>;\n\treadonly runStatus: Node<ToolProviderAdapterRunStatus>;\n\treadonly outcomes: Node<ExecutorOutcome<HttpToolResult>>;\n\treadonly status: Node<AgentRequestStatusChanged>;\n\treadonly issues: Node<DataIssue>;\n\treadonly audit: Node<AgentRuntimeAuditRecord>;\n\tdispose(): void;\n}\n\nconst LOCAL_BUILTIN_TOOLS = Object.freeze([\n\tObject.freeze({\n\t\ttoolName: \"date.now\",\n\t\toperation: \"read\",\n\t\tresultKinds: Object.freeze([\"json\"]),\n\t\tcapabilities: Object.freeze({ deterministicWithInjectedClock: true }),\n\t}),\n\tObject.freeze({\n\t\ttoolName: \"json.parse\",\n\t\toperation: \"parse\",\n\t\tresultKinds: Object.freeze([\"json\"]),\n\t\tcapabilities: Object.freeze({ externalSideEffects: false }),\n\t}),\n\tObject.freeze({\n\t\ttoolName: \"text.concat\",\n\t\toperation: \"transform\",\n\t\tresultKinds: Object.freeze([\"text\"]),\n\t\tcapabilities: Object.freeze({ externalSideEffects: false }),\n\t}),\n] satisfies readonly Omit<\n\tToolProviderCatalogEntry,\n\t\"kind\" | \"providerId\" | \"inputKind\" | \"profileId\" | \"executorId\"\n>[]);\n\nexport function localBuiltinToolProviderBinding(\n\topts: LocalBuiltinToolProviderBindingOptions = {},\n): ToolProviderAdapterBinding<LocalBuiltinToolArguments, LocalBuiltinToolResult> {\n\tconst providerId = opts.providerId ?? \"local-builtin\";\n\tconst maxTextChars = nonNegativeFinite(opts.maxTextChars, 16_384);\n\treturn Object.freeze({\n\t\tproviderId,\n\t\trun(input, ctx) {\n\t\t\tconst toolName = input.toolName as LocalBuiltinToolName | undefined;\n\t\t\tswitch (toolName) {\n\t\t\t\tcase \"date.now\":\n\t\t\t\t\treturn localDateNow(input, ctx, opts.now);\n\t\t\t\tcase \"json.parse\":\n\t\t\t\t\treturn localJsonParse(input, maxTextChars);\n\t\t\t\tcase \"text.concat\":\n\t\t\t\t\treturn localTextConcat(input, maxTextChars);\n\t\t\t\tdefault:\n\t\t\t\t\treturn blocked(\n\t\t\t\t\t\tinput,\n\t\t\t\t\t\t\"local-builtin-unsupported-tool\",\n\t\t\t\t\t\t\"Local builtin tool is not supported.\",\n\t\t\t\t\t);\n\t\t\t}\n\t\t},\n\t} satisfies ToolProviderAdapterBinding<LocalBuiltinToolArguments, LocalBuiltinToolResult>);\n}\n\nexport function localBuiltinToolProviderAdapterPack(\n\topts: LocalBuiltinToolProviderAdapterPackOptions = {},\n): ToolProviderAdapterPack<LocalBuiltinToolArguments, LocalBuiltinToolResult> {\n\tconst providerId = opts.providerId ?? \"local-builtin\";\n\tconst catalog = localBuiltinToolProviderCatalog({\n\t\tproviderId,\n\t\texecutorId: opts.executorId ?? `${providerId}:tool-executor`,\n\t\tprofileId: opts.profileId ?? `${providerId}:tool-profile`,\n\t\ttools: LOCAL_BUILTIN_TOOLS,\n\t\tpolicyOverrides: {\n\t\t\toperations: Object.freeze([\"read\", \"parse\", \"transform\"]),\n\t\t\tredaction: Object.freeze({\n\t\t\t\tmode: \"summary\",\n\t\t\t\tsummaryMaxChars: opts.publicText?.maxSummaryChars ?? 512,\n\t\t\t}),\n\t\t},\n\t\tmetadata: Object.freeze({ adapterPack: \"local-builtin-v0\" }),\n\t});\n\treturn Object.freeze({\n\t\tcatalogs: Object.freeze([catalog]),\n\t\tbindings: Object.freeze([\n\t\t\tlocalBuiltinToolProviderBinding({\n\t\t\t\tproviderId,\n\t\t\t\tnow: opts.now,\n\t\t\t\tmaxTextChars: opts.maxTextChars ?? opts.publicText?.maxSummaryChars,\n\t\t\t}),\n\t\t]),\n\t});\n}\n\nexport function processToolProviderBinding(\n\topts: ProcessToolProviderBindingOptions = {},\n): ToolProviderAdapterBinding<ProcessToolArguments, ProcessToolResult> {\n\tconst providerId = opts.providerId ?? \"process\";\n\tconst config = processConfig(opts);\n\treturn Object.freeze({\n\t\tproviderId,\n\t\trun(input) {\n\t\t\tconst args = processArguments(input);\n\t\t\tif (args === undefined) {\n\t\t\t\treturn blocked(input, \"process-invalid-arguments\", \"Process tool requires argv arguments.\");\n\t\t\t}\n\t\t\tconst allowed = config.allowedCommands.get(args.command);\n\t\t\tif (allowed === undefined) {\n\t\t\t\tif (config.duplicateCommands.has(args.command)) {\n\t\t\t\t\treturn blocked(\n\t\t\t\t\t\tinput,\n\t\t\t\t\t\t\"process-command-duplicate-allowlist\",\n\t\t\t\t\t\t\"Process command has duplicate allowlist entries.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (config.invalidCommands.has(args.command)) {\n\t\t\t\t\treturn blocked(\n\t\t\t\t\t\tinput,\n\t\t\t\t\t\t\"process-command-invalid-allowlist\",\n\t\t\t\t\t\t\"Process command has an invalid allowlist entry.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn blocked(input, \"process-command-not-allowed\", \"Process command is not allowlisted.\");\n\t\t\t}\n\t\t\tif (!argsAllowed(allowed, args.args)) {\n\t\t\t\treturn blocked(input, \"process-argv-not-allowed\", \"Process argv is not allowlisted.\");\n\t\t\t}\n\t\t\tconst cwd = resolveProcessCwd(args.cwd, allowed, config);\n\t\t\tif (cwd === undefined) {\n\t\t\t\treturn blocked(\n\t\t\t\t\tinput,\n\t\t\t\t\t\"process-cwd-not-allowed\",\n\t\t\t\t\t\"Process cwd is outside the allowed policy.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst env = processEnv(args.env, config);\n\t\t\tif (env === undefined) {\n\t\t\t\treturn blocked(\n\t\t\t\t\tinput,\n\t\t\t\t\t\"process-env-not-allowed\",\n\t\t\t\t\t\"Process env contains non-allowlisted keys.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn runProcessTool(input, allowed, args, cwd, env, config);\n\t\t},\n\t} satisfies ToolProviderAdapterBinding<ProcessToolArguments, ProcessToolResult>);\n}\n\nexport function processToolProviderAdapterPack(\n\topts: ProcessToolProviderAdapterPackOptions = {},\n): ToolProviderAdapterPack<ProcessToolArguments, ProcessToolResult> {\n\tconst providerId = opts.providerId ?? \"process\";\n\tconst executorId = opts.executorId ?? `${providerId}:tool-executor`;\n\tconst profileId = opts.profileId ?? `${providerId}:tool-profile`;\n\treturn Object.freeze({\n\t\tcatalogs: Object.freeze([\n\t\t\tprocessToolProviderCatalog({ ...opts, providerId, executorId, profileId }),\n\t\t]),\n\t\tbindings: Object.freeze([processToolProviderBinding({ ...opts, providerId })]),\n\t});\n}\n\nexport function processToolProviderCatalog(\n\topts: ProcessToolProviderAdapterPackOptions = {},\n): ToolProviderCatalog {\n\tconst providerId = opts.providerId ?? \"process\";\n\tconst executorId = opts.executorId ?? `${providerId}:tool-executor`;\n\tconst profileId = opts.profileId ?? `${providerId}:tool-profile`;\n\tconst normalized = normalizeAllowedCommands(opts.allowedCommands ?? []);\n\tconst allowedCommands = Object.freeze([...normalized.commands.values()]);\n\tconst issueList = [\n\t\t...(allowedCommands.length === 0\n\t\t\t? [\n\t\t\t\t\tissue(\n\t\t\t\t\t\t\"process-tool-provider-empty-allowlist\",\n\t\t\t\t\t\t\"Process tool provider has no allowlisted commands and will deny execution.\",\n\t\t\t\t\t\t\"warning\",\n\t\t\t\t\t),\n\t\t\t\t]\n\t\t\t: []),\n\t\t...[...normalized.duplicates].map((command) =>\n\t\t\tissue(\n\t\t\t\t\"process-tool-provider-duplicate-allowlist\",\n\t\t\t\t\"Process tool provider has duplicate command allowlist entries.\",\n\t\t\t\t\"error\",\n\t\t\t\t{ command },\n\t\t\t),\n\t\t),\n\t\t...[...normalized.invalids].map((command) =>\n\t\t\tissue(\n\t\t\t\t\"process-tool-provider-invalid-allowlist\",\n\t\t\t\t\"Process tool provider has invalid command allowlist entries.\",\n\t\t\t\t\"error\",\n\t\t\t\t{ command },\n\t\t\t),\n\t\t),\n\t];\n\tconst issues = issueList.length === 0 ? undefined : Object.freeze(issueList);\n\tconst policy = processToolProviderExecutionPolicy(providerId, profileId, opts);\n\tconst tool = Object.freeze({\n\t\tkind: \"tool-catalog-entry\",\n\t\tproviderId,\n\t\ttoolName: \"process.execFile\",\n\t\toperation: \"run\",\n\t\tinputKind: \"tool-call\",\n\t\tprofileId,\n\t\texecutorId,\n\t\tresultKinds: Object.freeze([\"process-result\"]),\n\t\tcapabilities: Object.freeze({\n\t\t\targv: true,\n\t\t\tshell: false,\n\t\t\tcommands: Object.freeze(allowedCommands.map((cmd) => cmd.command)),\n\t\t\tenv: Object.freeze({ allowedKeys: Object.freeze([...(opts.allowedEnvKeys ?? [])]) }),\n\t\t}),\n\t\tpolicyRefs: Object.freeze([{ kind: \"tool-provider-execution-policy\", id: policy.policyId }]),\n\t} satisfies ToolProviderCatalogEntry);\n\treturn Object.freeze({\n\t\tkind: \"tool-provider-catalog\",\n\t\tproviderId,\n\t\tproviderKind: \"process\",\n\t\tstatus: issues === undefined ? \"ready\" : \"misconfigured\",\n\t\tprofiles: Object.freeze([\n\t\t\tObject.freeze({\n\t\t\t\tprofileId,\n\t\t\t\texecutorId,\n\t\t\t\tkind: \"tool\",\n\t\t\t\tacceptedInputKinds: Object.freeze([\"tool-call\"]),\n\t\t\t\tacceptedResultKinds: Object.freeze([\"process-result\"]),\n\t\t\t\tcapabilities: Object.freeze({\n\t\t\t\t\ttoolNames: Object.freeze([tool.toolName]),\n\t\t\t\t\targv: true,\n\t\t\t\t\tshell: false,\n\t\t\t\t}),\n\t\t\t\tpolicyRefs: Object.freeze([\n\t\t\t\t\t{ kind: \"tool-provider-execution-policy\", id: policy.policyId },\n\t\t\t\t]),\n\t\t\t}),\n\t\t]),\n\t\ttools: Object.freeze([tool]),\n\t\tpolicies: Object.freeze([policy]),\n\t\tpolicyRefs: Object.freeze([{ kind: \"tool-provider-execution-policy\", id: policy.policyId }]),\n\t\tissues,\n\t\tmetadata: Object.freeze({ adapterPack: \"process-v0\" }),\n\t} satisfies ToolProviderCatalog);\n}\n\nexport function httpToolProviderCatalog(\n\topts: Omit<HttpToolProviderRuntimeOptions, \"inputs\" | \"runRequests\" | \"driver\"> = {},\n): ToolProviderCatalog {\n\tconst providerId = opts.providerId ?? \"http\";\n\tconst executorId = opts.executorId ?? `${providerId}:tool-executor`;\n\tconst profileId = opts.profileId ?? `${providerId}:tool-profile`;\n\tconst allowedOrigins = Object.freeze([...(opts.allowedOrigins ?? [])]);\n\tconst allowedMethods = Object.freeze(normalizeMethods(opts.allowedMethods ?? [\"GET\"]));\n\tconst maxResponseBytes = Math.max(1, nonNegativeFinite(opts.maxResponseBytes, 64 * 1024));\n\tconst policy = httpToolProviderExecutionPolicy(providerId, profileId, opts);\n\tconst issues = Object.freeze([\n\t\t...(allowedOrigins.length === 0\n\t\t\t? [\n\t\t\t\t\tissue(\n\t\t\t\t\t\t\"http-tool-provider-empty-origin-allowlist\",\n\t\t\t\t\t\t\"HTTP tool provider has no allowlisted origins and will deny execution.\",\n\t\t\t\t\t\t\"warning\",\n\t\t\t\t\t),\n\t\t\t\t]\n\t\t\t: []),\n\t\t...(allowedMethods.length === 0\n\t\t\t? [\n\t\t\t\t\tissue(\n\t\t\t\t\t\t\"http-tool-provider-empty-method-allowlist\",\n\t\t\t\t\t\t\"HTTP tool provider has no allowlisted methods and will deny execution.\",\n\t\t\t\t\t),\n\t\t\t\t]\n\t\t\t: []),\n\t]);\n\tconst tool = Object.freeze({\n\t\tkind: \"tool-catalog-entry\",\n\t\tproviderId,\n\t\ttoolName: \"http.fetch\",\n\t\toperation: \"fetch\",\n\t\tinputKind: \"tool-call\",\n\t\tprofileId,\n\t\texecutorId,\n\t\tresultKinds: Object.freeze([\"http-result\"]),\n\t\tcapabilities: Object.freeze({\n\t\t\torigins: allowedOrigins,\n\t\t\tmethods: allowedMethods,\n\t\t\tmaxResponseBytes,\n\t\t\tasyncRuntime: true,\n\t\t}),\n\t\tpolicyRefs: Object.freeze([{ kind: \"tool-provider-execution-policy\", id: policy.policyId }]),\n\t} satisfies ToolProviderCatalogEntry);\n\treturn Object.freeze({\n\t\tkind: \"tool-provider-catalog\",\n\t\tproviderId,\n\t\tproviderKind: \"http\",\n\t\tstatus: issues.length === 0 ? \"ready\" : \"misconfigured\",\n\t\tprofiles: Object.freeze([\n\t\t\tObject.freeze({\n\t\t\t\tprofileId,\n\t\t\t\texecutorId,\n\t\t\t\tkind: \"tool\",\n\t\t\t\tacceptedInputKinds: Object.freeze([\"tool-call\"]),\n\t\t\t\tacceptedResultKinds: Object.freeze([\"http-result\"]),\n\t\t\t\tcapabilities: Object.freeze({\n\t\t\t\t\ttoolNames: Object.freeze([tool.toolName]),\n\t\t\t\t\tasyncRuntime: true,\n\t\t\t\t}),\n\t\t\t\tpolicyRefs: Object.freeze([\n\t\t\t\t\t{ kind: \"tool-provider-execution-policy\", id: policy.policyId },\n\t\t\t\t]),\n\t\t\t}),\n\t\t]),\n\t\ttools: Object.freeze([tool]),\n\t\tpolicies: Object.freeze([policy]),\n\t\tpolicyRefs: Object.freeze([{ kind: \"tool-provider-execution-policy\", id: policy.policyId }]),\n\t\tissues: issues.length === 0 ? undefined : issues,\n\t\tmetadata: Object.freeze({ adapterPack: \"http-v0\", asyncRuntime: true }),\n\t} satisfies ToolProviderCatalog);\n}\n\nexport function httpToolProviderRuntime(\n\tgraph: Graph,\n\topts: HttpToolProviderRuntimeOptions,\n): HttpToolProviderRuntimeBundle {\n\tconst name = opts.name ?? \"httpToolProviderRuntime\";\n\tconst providerId = opts.providerId ?? \"http\";\n\tconst catalog = httpToolProviderCatalog(opts);\n\tconst outcomes = graph.node<ExecutorOutcome<HttpToolResult>>([], null, {\n\t\tname: `${name}/outcomes`,\n\t});\n\tconst runStatus = graph.node<ToolProviderAdapterRunStatus>([], null, {\n\t\tname: `${name}/runStatus`,\n\t});\n\tconst status = graph.node<AgentRequestStatusChanged>([], null, { name: `${name}/status` });\n\tconst issues = graph.node<DataIssue>([], null, { name: `${name}/issues` });\n\tconst audit = graph.node<AgentRuntimeAuditRecord>([], null, { name: `${name}/audit` });\n\tconst inputs = new Map<string, ToolProviderAdapterInput<HttpToolArguments>>();\n\tconst executions = new Set<string>();\n\tconst active = new Set<AbortController>();\n\tconst config = httpRuntimeConfig(opts);\n\tconst driver = opts.driver ?? defaultHttpToolProviderDriver(config.maxResponseBytes);\n\tconst forwardedRunStatusKeys = new Set<string>();\n\tlet auditSeq = 0;\n\tlet disposed = false;\n\n\tfunction nowMs(): number | undefined {\n\t\treturn opts.now?.();\n\t}\n\n\tfunction publishIssue(nextIssue: DataIssue): void {\n\t\tissues.down([[\"DATA\", nextIssue]]);\n\t}\n\n\tfunction publishAudit(\n\t\tkind: string,\n\t\tsubjectId: string,\n\t\tmetadata?: Record<string, unknown>,\n\t\tissueCode?: string,\n\t): void {\n\t\tauditSeq += 1;\n\t\taudit.down([\n\t\t\t[\n\t\t\t\t\"DATA\",\n\t\t\t\t{\n\t\t\t\t\tid: `${name}:audit:${auditSeq}`,\n\t\t\t\t\tkind,\n\t\t\t\t\tsubjectId,\n\t\t\t\t\t...(issueCode === undefined ? {} : { issueCode }),\n\t\t\t\t\t...(metadata === undefined ? {} : { metadata }),\n\t\t\t\t} satisfies AgentRuntimeAuditRecord,\n\t\t\t],\n\t\t]);\n\t}\n\n\tfunction publishRunStatus(\n\t\trequest: ToolProviderAdapterRunRequested,\n\t\tnextStatus: ToolProviderAdapterRunStatus[\"status\"],\n\t\tstatusIssues?: readonly DataIssue[],\n\t\toutcomeId?: string,\n\t): void {\n\t\tforwardedRunStatusKeys.add(`${request.runId}:${nextStatus}`);\n\t\trunStatus.down([\n\t\t\t[\n\t\t\t\t\"DATA\",\n\t\t\t\t{\n\t\t\t\t\tkind: \"tool-provider-adapter-run-status\",\n\t\t\t\t\trunId: request.runId,\n\t\t\t\t\tadapterInputId: request.adapterInputId,\n\t\t\t\t\trequestId: request.requestId,\n\t\t\t\t\toperationId: request.operationId,\n\t\t\t\t\tstatus: nextStatus,\n\t\t\t\t\tattempt: request.attempt,\n\t\t\t\t\t...(outcomeId === undefined ? {} : { outcomeId }),\n\t\t\t\t\t...(statusIssues === undefined ? {} : { issues: statusIssues }),\n\t\t\t\t\tsourceRefs: request.sourceRefs,\n\t\t\t\t\tmetadata: Object.freeze({ providerId, reason: request.reason }),\n\t\t\t\t} satisfies ToolProviderAdapterRunStatus,\n\t\t\t],\n\t\t]);\n\t}\n\n\tfunction publishRequestStatus(\n\t\tinput: ToolProviderAdapterInput<HttpToolArguments>,\n\t\tnextStatus: AgentRequestStatusChanged[\"status\"],\n\t\tstatusIssues?: readonly DataIssue[],\n\t): void {\n\t\tif (input.effectRunId === undefined) return;\n\t\tstatus.down([\n\t\t\t[\n\t\t\t\t\"DATA\",\n\t\t\t\t{\n\t\t\t\t\tkind: \"status\",\n\t\t\t\t\trequestId: input.requestId,\n\t\t\t\t\toperationId: input.operationId,\n\t\t\t\t\teffectRunId: input.effectRunId,\n\t\t\t\t\tstatus: nextStatus,\n\t\t\t\t\tsourceRefs: defaultEvidenceRefs(input),\n\t\t\t\t\t...(statusIssues === undefined ? {} : { issues: statusIssues }),\n\t\t\t\t\tmetadata: Object.freeze({\n\t\t\t\t\t\tadapterInputId: input.adapterInputId,\n\t\t\t\t\t\tproviderId: input.providerId,\n\t\t\t\t\t\ttoolName: input.toolName,\n\t\t\t\t\t}),\n\t\t\t\t} satisfies AgentRequestStatusChanged,\n\t\t\t],\n\t\t]);\n\t}\n\n\tfunction publishOutcome(\n\t\tinput: ToolProviderAdapterInput<HttpToolArguments>,\n\t\trequest: ToolProviderAdapterRunRequested,\n\t\tresult: ToolProviderAdapterRunResult<HttpToolResult>,\n\t): void {\n\t\tconst outcome = buildToolProviderExecutorOutcome(input, result, {\n\t\t\trunId: request.runId,\n\t\t\tattempt: request.attempt,\n\t\t\toccurredAtMs: nowMs(),\n\t\t\tpublicText: opts.publicText,\n\t\t});\n\t\toutcomes.down([[\"DATA\", outcome]]);\n\t\tconst statusIssues = outcomeIssues(outcome);\n\t\tfor (const statusIssue of statusIssues) publishIssue(statusIssue);\n\t\tpublishRequestStatus(input, agentStatusForOutcome(outcome), statusIssues);\n\t\tpublishRunStatus(request, outcome.kind, statusIssues, outcome.outcomeId);\n\t\tpublishAudit(\"http-tool-provider-runtime-finished\", input.requestId, {\n\t\t\trunId: request.runId,\n\t\t\tattempt: request.attempt,\n\t\t\tstatus: outcome.kind,\n\t\t\toutcomeId: outcome.outcomeId,\n\t\t});\n\t}\n\n\tfunction execute(request: ToolProviderAdapterRunRequested): void {\n\t\tif (disposed || (request.providerId !== undefined && request.providerId !== providerId)) return;\n\t\tconst input = inputs.get(request.adapterInputId);\n\t\tif (input === undefined || input.providerId !== providerId) return;\n\t\tconst coordinate = `${request.runId}:${request.adapterInputId}:${request.attempt}`;\n\t\tif (executions.has(coordinate)) return;\n\t\texecutions.add(coordinate);\n\t\tpublishRunStatus(request, \"requested\");\n\t\tif (input.status !== \"ready\") {\n\t\t\tconst inputIssue = issue(\n\t\t\t\t\"http-tool-provider-input-not-ready\",\n\t\t\t\t\"HTTP tool provider runtime requires a ready adapter input.\",\n\t\t\t);\n\t\t\tpublishIssue(inputIssue);\n\t\t\tpublishRunStatus(request, \"stale-request\", [inputIssue]);\n\t\t\tpublishRequestStatus(input, \"blocked\", [inputIssue]);\n\t\t\treturn;\n\t\t}\n\t\tif (!requestMatchesInput(request, input)) {\n\t\t\tconst mismatch = issue(\n\t\t\t\t\"http-tool-provider-run-request-mismatched-input\",\n\t\t\t\t\"HTTP tool provider run request does not match its adapter input.\",\n\t\t\t);\n\t\t\tpublishIssue(mismatch);\n\t\t\tpublishRunStatus(request, \"mismatched-request\", [mismatch]);\n\t\t\tpublishRequestStatus(input, \"blocked\", [mismatch]);\n\t\t\treturn;\n\t\t}\n\t\tconst prepared = prepareHttpRequest(input, config);\n\t\tif (prepared.kind === \"blocked\") {\n\t\t\tpublishOutcome(input, request, {\n\t\t\t\tkind: \"blocked\",\n\t\t\t\tneeds: Object.freeze([\n\t\t\t\t\tObject.freeze({\n\t\t\t\t\t\tkind: prepared.issue.code,\n\t\t\t\t\t\tmessage: prepared.issue.message,\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t\tissues: Object.freeze([prepared.issue]),\n\t\t\t\tevidenceRefs: defaultEvidenceRefs(input),\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tif (config.approvalMode === \"never\") {\n\t\t\tpublishOutcome(input, request, {\n\t\t\t\tkind: \"blocked\",\n\t\t\t\tneeds: Object.freeze([\n\t\t\t\t\tObject.freeze({\n\t\t\t\t\t\tkind: \"tool-provider-approval-disabled\",\n\t\t\t\t\t\tmessage: \"HTTP tool provider policy disallows execution.\",\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t\tissues: Object.freeze([\n\t\t\t\t\tissue(\"http-tool-provider-approval-never\", \"HTTP tool provider execution is disabled.\"),\n\t\t\t\t]),\n\t\t\t\tevidenceRefs: defaultEvidenceRefs(input),\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tif (config.approvalMode === \"require\" && !requestApproved(request)) {\n\t\t\tpublishOutcome(input, request, {\n\t\t\t\tkind: \"blocked\",\n\t\t\t\tneeds: Object.freeze([\n\t\t\t\t\tObject.freeze({\n\t\t\t\t\t\tkind: \"tool-provider-approval\",\n\t\t\t\t\t\tmessage: \"HTTP tool provider execution requires a visible approval run request.\",\n\t\t\t\t\t}),\n\t\t\t\t]),\n\t\t\t\tissues: Object.freeze([\n\t\t\t\t\tissue(\n\t\t\t\t\t\t\"http-tool-provider-approval-required\",\n\t\t\t\t\t\t\"HTTP tool provider execution requires approval.\",\n\t\t\t\t\t),\n\t\t\t\t]),\n\t\t\t\tevidenceRefs: defaultEvidenceRefs(input),\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tconst controller = new AbortController();\n\t\tactive.add(controller);\n\t\tpublishRunStatus(request, \"started\");\n\t\tpublishRequestStatus(input, \"in-flight\");\n\t\tpublishAudit(\"http-tool-provider-runtime-started\", input.requestId, {\n\t\t\trunId: request.runId,\n\t\t\tattempt: request.attempt,\n\t\t\tmethod: prepared.request.method,\n\t\t\torigin: new URL(prepared.request.url).origin,\n\t\t});\n\t\tconst timeout = setTimeout(() => controller.abort(), config.timeoutMs);\n\t\tPromise.resolve(driver.fetch({ ...prepared.request, signal: controller.signal })).then(\n\t\t\t(response) => {\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\tactive.delete(controller);\n\t\t\t\tif (disposed) return;\n\t\t\t\tpublishOutcome(input, request, httpResponseResult(prepared.request, response, config));\n\t\t\t},\n\t\t\t(error: unknown) => {\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\tactive.delete(controller);\n\t\t\t\tif (disposed) return;\n\t\t\t\tpublishOutcome(input, request, httpErrorResult(error, config));\n\t\t\t},\n\t\t);\n\t}\n\n\tconst unsubscribeInputs = opts.inputs.subscribe((msg) => {\n\t\tif (msg[0] !== \"DATA\") return;\n\t\tconst input = msg[1] as ToolProviderAdapterInput<HttpToolArguments>;\n\t\tif (input.providerId === providerId) inputs.set(input.adapterInputId, input);\n\t});\n\tconst autoRunReadyInputs =\n\t\topts.autoRunReadyInputs ?? (opts.runRequests === undefined || opts.runRequests.length === 0);\n\tconst runProjector = toolProviderAdapterRunProjector(graph, {\n\t\tname: `${name}/runs`,\n\t\tinputs: opts.inputs,\n\t\trunRequests: opts.runRequests,\n\t\tautoRunReadyInputs,\n\t\tnow: opts.now,\n\t});\n\tconst unsubscribeRunStatus = runProjector.status.subscribe((msg) => {\n\t\tif (msg[0] !== \"DATA\") return;\n\t\tconst nextStatus = msg[1] as ToolProviderAdapterRunStatus;\n\t\tconst statusKey = `${nextStatus.runId}:${nextStatus.status}`;\n\t\tif (forwardedRunStatusKeys.has(statusKey)) return;\n\t\tforwardedRunStatusKeys.add(statusKey);\n\t\trunStatus.down([[\"DATA\", nextStatus]]);\n\t});\n\tconst unsubscribeRunIssues = runProjector.issues.subscribe((msg) => {\n\t\tif (msg[0] === \"DATA\") publishIssue(msg[1] as DataIssue);\n\t});\n\tconst unsubscribeRunAudit = runProjector.audit.subscribe((msg) => {\n\t\tif (msg[0] === \"DATA\") audit.down([[\"DATA\", msg[1] as AgentRuntimeAuditRecord]]);\n\t});\n\tconst unsubscribeRunRequests = runProjector.requests.subscribe((msg) => {\n\t\tif (msg[0] === \"DATA\") execute(msg[1] as ToolProviderAdapterRunRequested);\n\t});\n\treturn Object.freeze({\n\t\tcatalogs: Object.freeze([catalog]),\n\t\trunRequests: runProjector.requests,\n\t\trunStatus,\n\t\toutcomes,\n\t\tstatus,\n\t\tissues,\n\t\taudit,\n\t\tdispose() {\n\t\t\tif (disposed) return;\n\t\t\tdisposed = true;\n\t\t\tunsubscribeInputs();\n\t\t\tunsubscribeRunStatus();\n\t\t\tunsubscribeRunIssues();\n\t\t\tunsubscribeRunAudit();\n\t\t\tunsubscribeRunRequests();\n\t\t\tfor (const controller of active) controller.abort();\n\t\t\tactive.clear();\n\t\t},\n\t} satisfies HttpToolProviderRuntimeBundle);\n}\n\nfunction localDateNow(\n\tinput: ToolProviderAdapterInput<LocalBuiltinToolArguments>,\n\tctx: ToolProviderAdapterRunContext,\n\tnow: (() => number) | undefined,\n): ToolProviderAdapterRunResult<LocalBuiltinToolResult> {\n\tconst epochMs = now?.() ?? ctx.now?.() ?? Date.now();\n\treturn Object.freeze({\n\t\tkind: \"result\",\n\t\tresult: Object.freeze({\n\t\t\tkind: \"json\",\n\t\t\tvalue: Object.freeze({\n\t\t\t\ttoolName: \"date.now\" as const,\n\t\t\t\tepochMs,\n\t\t\t\tiso: new Date(epochMs).toISOString(),\n\t\t\t}),\n\t\t\tsummary: String(epochMs),\n\t\t}),\n\t\toccurredAtMs: epochMs,\n\t\tevidenceRefs: input.sourceRefs,\n\t} satisfies ToolProviderAdapterRunResult<LocalBuiltinToolResult>);\n}\n\nfunction localJsonParse(\n\tinput: ToolProviderAdapterInput<LocalBuiltinToolArguments>,\n\tmaxTextChars: number,\n): ToolProviderAdapterRunResult<LocalBuiltinToolResult> {\n\tconst text = input.toolCall?.arguments?.text;\n\tif (typeof text !== \"string\") {\n\t\treturn failure(\n\t\t\tinput,\n\t\t\t\"local-json-parse-missing-text\",\n\t\t\t\"json.parse requires a string text argument.\",\n\t\t);\n\t}\n\tif (text.length > maxTextChars) {\n\t\treturn failure(\n\t\t\tinput,\n\t\t\t\"local-json-parse-text-too-large\",\n\t\t\t\"json.parse text exceeds maxTextChars.\",\n\t\t);\n\t}\n\ttry {\n\t\tconst value = JSON.parse(text) as unknown;\n\t\treturn Object.freeze({\n\t\t\tkind: \"result\",\n\t\t\tresult: Object.freeze({\n\t\t\t\tkind: \"json\",\n\t\t\t\tvalue: Object.freeze({ toolName: \"json.parse\" as const, value }),\n\t\t\t\tsummary: \"parsed JSON\",\n\t\t\t}),\n\t\t\tevidenceRefs: input.sourceRefs,\n\t\t} satisfies ToolProviderAdapterRunResult<LocalBuiltinToolResult>);\n\t} catch {\n\t\treturn failure(input, \"local-json-parse-invalid-json\", \"json.parse received invalid JSON.\");\n\t}\n}\n\nfunction localTextConcat(\n\tinput: ToolProviderAdapterInput<LocalBuiltinToolArguments>,\n\tmaxTextChars: number,\n): ToolProviderAdapterRunResult<LocalBuiltinToolResult> {\n\tconst parts = input.toolCall?.arguments?.parts;\n\tif (!Array.isArray(parts)) {\n\t\treturn failure(input, \"local-text-concat-missing-parts\", \"text.concat requires a parts array.\");\n\t}\n\tconst separator = input.toolCall?.arguments?.separator ?? \"\";\n\tif (typeof separator !== \"string\") {\n\t\treturn failure(\n\t\t\tinput,\n\t\t\t\"local-text-concat-invalid-separator\",\n\t\t\t\"text.concat separator must be a string.\",\n\t\t);\n\t}\n\tconst text = parts.map((part) => String(part)).join(separator);\n\tif (text.length > maxTextChars) {\n\t\treturn failure(\n\t\t\tinput,\n\t\t\t\"local-text-concat-too-large\",\n\t\t\t\"text.concat result exceeds maxTextChars.\",\n\t\t);\n\t}\n\treturn Object.freeze({\n\t\tkind: \"result\",\n\t\tresult: Object.freeze({\n\t\t\tkind: \"text\",\n\t\t\tvalue: Object.freeze({ toolName: \"text.concat\" as const, text }),\n\t\t\tsummary: text,\n\t\t}),\n\t\tevidenceRefs: input.sourceRefs,\n\t} satisfies ToolProviderAdapterRunResult<LocalBuiltinToolResult>);\n}\n\ninterface ProcessConfig {\n\treadonly allowedCommands: ReadonlyMap<string, ProcessToolAllowedCommand>;\n\treadonly duplicateCommands: ReadonlySet<string>;\n\treadonly invalidCommands: ReadonlySet<string>;\n\treadonly workingDirectory: string;\n\treadonly allowedWorkingDirectories: readonly string[];\n\treadonly baseEnv: Readonly<Record<string, string>>;\n\treadonly allowedEnvKeys: ReadonlySet<string>;\n\treadonly timeoutMs: number;\n\treadonly maxOutputBytes: number;\n\treadonly maxSummaryChars: number;\n}\n\nfunction processConfig(opts: ProcessToolProviderBindingOptions): ProcessConfig {\n\tconst workingDirectory = resolve(opts.workingDirectory ?? \".\");\n\tconst allowedWorkingDirectories = Object.freeze(\n\t\t(opts.allowedWorkingDirectories ?? [workingDirectory]).map((dir) => resolve(dir)),\n\t);\n\tconst allowed = normalizeAllowedCommands(opts.allowedCommands ?? []);\n\treturn {\n\t\tallowedCommands: allowed.commands,\n\t\tduplicateCommands: allowed.duplicates,\n\t\tinvalidCommands: allowed.invalids,\n\t\tworkingDirectory,\n\t\tallowedWorkingDirectories,\n\t\tbaseEnv: Object.freeze({ ...(opts.baseEnv ?? {}) }),\n\t\tallowedEnvKeys: new Set(opts.allowedEnvKeys ?? []),\n\t\ttimeoutMs: positiveFinite(opts.timeoutMs, 10_000),\n\t\tmaxOutputBytes: Math.max(1, nonNegativeFinite(opts.maxOutputBytes, 64 * 1024)),\n\t\tmaxSummaryChars: Math.max(1, nonNegativeFinite(opts.maxSummaryChars, 512)),\n\t};\n}\n\nfunction processArguments(\n\tinput: ToolProviderAdapterInput<ProcessToolArguments>,\n):\n\t| (Required<Pick<ProcessToolArguments, \"command\" | \"args\">> &\n\t\t\tPick<ProcessToolArguments, \"cwd\" | \"env\" | \"input\">)\n\t| undefined {\n\tconst raw = input.toolCall?.arguments;\n\tif (!isRecord(raw) || typeof raw.command !== \"string\" || raw.command.length === 0) {\n\t\treturn undefined;\n\t}\n\tconst rawArgs = raw.args === undefined ? Object.freeze([]) : stringArray(raw.args);\n\tif (rawArgs === undefined) return undefined;\n\tif (raw.cwd !== undefined && typeof raw.cwd !== \"string\") return undefined;\n\tif (raw.input !== undefined && typeof raw.input !== \"string\") return undefined;\n\tconst rawEnv = raw.env === undefined ? undefined : processArgumentEnv(raw.env);\n\tif (raw.env !== undefined && rawEnv === undefined) return undefined;\n\treturn {\n\t\tcommand: raw.command,\n\t\targs: rawArgs,\n\t\t...(raw.cwd === undefined ? {} : { cwd: raw.cwd }),\n\t\t...(rawEnv === undefined ? {} : { env: rawEnv }),\n\t\t...(raw.input === undefined ? {} : { input: raw.input }),\n\t};\n}\n\nfunction argsAllowed(command: ProcessToolAllowedCommand, args: readonly string[]): boolean {\n\tif (command.allowArgs === true) return true;\n\tif (typeof command.allowArgs === \"function\") return command.allowArgs(args);\n\tif (command.allowArgs === undefined) return args.length === 0;\n\treturn arraysEqual(command.allowArgs, args);\n}\n\nfunction resolveProcessCwd(\n\trequestedCwd: string | undefined,\n\tcommand: ProcessToolAllowedCommand,\n\tconfig: ProcessConfig,\n): string | undefined {\n\tconst rawCwd = command.cwd ?? requestedCwd;\n\tconst cwd =\n\t\trawCwd === undefined\n\t\t\t? config.workingDirectory\n\t\t\t: isAbsolute(rawCwd)\n\t\t\t\t? resolve(rawCwd)\n\t\t\t\t: resolve(config.workingDirectory, rawCwd);\n\tconst realCwd = realpath(cwd);\n\tif (realCwd === undefined) return undefined;\n\treturn config.allowedWorkingDirectories.some((allowed) => {\n\t\tconst realAllowed = realpath(allowed);\n\t\treturn realAllowed !== undefined && isPathInside(realCwd, realAllowed);\n\t})\n\t\t? cwd\n\t\t: undefined;\n}\n\nfunction processEnv(\n\tinputEnv: ProcessToolArguments[\"env\"],\n\tconfig: ProcessConfig,\n): Readonly<Record<string, string>> | undefined {\n\tconst env: Record<string, string> = { ...config.baseEnv };\n\tfor (const [key, value] of Object.entries(inputEnv ?? {})) {\n\t\tif (!config.allowedEnvKeys.has(key)) return undefined;\n\t\tif (value !== undefined) env[key] = String(value);\n\t}\n\treturn Object.freeze(env);\n}\n\nfunction processArgumentEnv(value: unknown): ProcessToolArguments[\"env\"] | undefined {\n\tif (!isRecord(value)) return undefined;\n\tconst env: Record<string, string | number | boolean | undefined> = {};\n\tfor (const [key, entry] of Object.entries(value)) {\n\t\tif (\n\t\t\tentry !== undefined &&\n\t\t\ttypeof entry !== \"string\" &&\n\t\t\ttypeof entry !== \"number\" &&\n\t\t\ttypeof entry !== \"boolean\"\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\t\tenv[key] = entry;\n\t}\n\treturn Object.freeze(env);\n}\n\nfunction runProcessTool(\n\tinput: ToolProviderAdapterInput<ProcessToolArguments>,\n\tallowed: ProcessToolAllowedCommand,\n\targs: Required<Pick<ProcessToolArguments, \"command\" | \"args\">> &\n\t\tPick<ProcessToolArguments, \"input\">,\n\tcwd: string,\n\tenv: Readonly<Record<string, string>>,\n\tconfig: ProcessConfig,\n): ToolProviderAdapterRunResult<ProcessToolResult> {\n\tconst executable = allowed.executable ?? args.command;\n\tconst argv = Object.freeze([...(allowed.fixedArgs ?? []), ...args.args]);\n\tconst result = spawnSync(executable, argv, {\n\t\tcwd,\n\t\tenv,\n\t\tinput: args.input,\n\t\tencoding: \"buffer\",\n\t\tshell: false,\n\t\ttimeout: config.timeoutMs,\n\t\tmaxBuffer: config.maxOutputBytes + 1,\n\t});\n\tconst stdout = result.stdout ?? Buffer.alloc(0);\n\tconst stderr = result.stderr ?? Buffer.alloc(0);\n\tconst truncated = stdout.length + stderr.length > config.maxOutputBytes;\n\tif (result.error !== undefined && isTimeoutError(result.error)) {\n\t\treturn Object.freeze({\n\t\t\tkind: \"timeout\",\n\t\t\ttimeoutMs: config.timeoutMs,\n\t\t\tretryable: true,\n\t\t\tevidenceRefs: input.sourceRefs,\n\t\t} satisfies ToolProviderAdapterRunResult<ProcessToolResult>);\n\t}\n\tif (result.error !== undefined || truncated) {\n\t\treturn failure(\n\t\t\tinput,\n\t\t\ttruncated || isOutputLimitError(result.error)\n\t\t\t\t? \"process-output-limit-exceeded\"\n\t\t\t\t: \"process-spawn-failed\",\n\t\t\ttruncated || isOutputLimitError(result.error)\n\t\t\t\t? \"Process output exceeded maxOutputBytes.\"\n\t\t\t\t: \"Process execution failed before producing an exit result.\",\n\t\t);\n\t}\n\tconst value = processResult(\n\t\targs.command,\n\t\targv,\n\t\tcwd,\n\t\tresult.status,\n\t\tresult.signal,\n\t\tstdout,\n\t\tstderr,\n\t\tconfig,\n\t);\n\tif ((result.status ?? 1) !== 0) {\n\t\treturn Object.freeze({\n\t\t\tkind: \"failure\",\n\t\t\terror: issue(\"process-exit-nonzero\", \"Process exited with a non-zero status.\", \"error\", {\n\t\t\t\texitCode: result.status,\n\t\t\t\tsignal: result.signal ?? undefined,\n\t\t\t}),\n\t\t\tretryable: false,\n\t\t\tevidenceRefs: input.sourceRefs,\n\t\t\tmetadata: Object.freeze({\n\t\t\t\tcommand: args.command,\n\t\t\t\texitCode: result.status,\n\t\t\t\tsignal: result.signal ?? undefined,\n\t\t\t\toutputBytes: value.outputBytes,\n\t\t\t\terrorOutputBytes: value.errorOutputBytes,\n\t\t\t}),\n\t\t} satisfies ToolProviderAdapterRunResult<ProcessToolResult>);\n\t}\n\treturn Object.freeze({\n\t\tkind: \"result\",\n\t\tresult: Object.freeze({\n\t\t\tkind: \"process-result\",\n\t\t\tvalue,\n\t\t\tsummary: value.outputPreview ?? `process exited ${value.exitCode ?? 0}`,\n\t\t\tartifacts: processArtifacts(stdout, stderr, config, input.sourceRefs),\n\t\t}),\n\t\tevidenceRefs: input.sourceRefs,\n\t} satisfies ToolProviderAdapterRunResult<ProcessToolResult>);\n}\n\nfunction processResult(\n\tcommand: string,\n\targs: readonly string[],\n\tcwd: string,\n\texitCode: number | null,\n\tsignal: NodeJS.Signals | null,\n\tstdout: Buffer,\n\tstderr: Buffer,\n\tconfig: ProcessConfig,\n): ProcessToolResult {\n\treturn Object.freeze({\n\t\tcommand,\n\t\targs,\n\t\tcwd,\n\t\texitCode,\n\t\t...(signal === null ? {} : { signal }),\n\t\toutputPreview: preview(stdout, config.maxSummaryChars),\n\t\terrorPreview: preview(stderr, config.maxSummaryChars),\n\t\toutputBytes: stdout.length,\n\t\terrorOutputBytes: stderr.length,\n\t\ttruncated: false,\n\t});\n}\n\nfunction processArtifacts(\n\tstdout: Buffer,\n\tstderr: Buffer,\n\tconfig: ProcessConfig,\n\tsourceRefs: readonly SourceRef[] | undefined,\n): readonly ExecutorArtifactMaterial<string>[] | undefined {\n\tconst artifacts = [\n\t\tprocessTextArtifact(\"process-stdout\", stdout, config, sourceRefs),\n\t\tprocessTextArtifact(\"process-stderr\", stderr, config, sourceRefs),\n\t].filter((artifact): artifact is ExecutorArtifactMaterial<string> => artifact !== undefined);\n\treturn artifacts.length === 0 ? undefined : Object.freeze(artifacts);\n}\n\nfunction processTextArtifact(\n\tkind: \"process-stdout\" | \"process-stderr\",\n\tbytes: Buffer,\n\tconfig: ProcessConfig,\n\tsourceRefs: readonly SourceRef[] | undefined,\n): ExecutorArtifactMaterial<string> | undefined {\n\tif (bytes.length === 0) return undefined;\n\tconst text = bytes.toString(\"utf8\");\n\tconst inline = text.length <= config.maxSummaryChars;\n\treturn Object.freeze({\n\t\tkind,\n\t\tformat: \"text\",\n\t\tmediaType: \"text/plain\",\n\t\tencoding: \"utf8\",\n\t\tbyteLength: bytes.length,\n\t\tdataMode: inline ? \"inline\" : \"summary\",\n\t\tsummary: preview(bytes, config.maxSummaryChars),\n\t\t...(inline ? { value: text } : {}),\n\t\t...(sourceRefs === undefined ? {} : { sourceRefs }),\n\t\tsizeEvidence: Object.freeze([\n\t\t\tsizeEvidence(bytes.length, \"adapter-measured-process-output\", sourceRefs),\n\t\t]),\n\t} satisfies ExecutorArtifactMaterial<string>);\n}\n\nfunction processToolProviderExecutionPolicy(\n\tproviderId: string,\n\tprofileId: string,\n\topts: ProcessToolProviderBindingOptions,\n): ToolProviderExecutionPolicy {\n\tconst maxOutputBytes = Math.max(1, nonNegativeFinite(opts.maxOutputBytes, 64 * 1024));\n\treturn Object.freeze({\n\t\tkind: \"tool-provider-execution-policy\",\n\t\tpolicyId: `${providerId}:policy:process-v0`,\n\t\tproviderId,\n\t\tprofileIds: Object.freeze([profileId]),\n\t\ttoolNames: Object.freeze([\"process.execFile\"]),\n\t\toperations: Object.freeze([\"run\"]),\n\t\tsizeCapacity: Object.freeze({\n\t\t\tlimits: Object.freeze([\n\t\t\t\tObject.freeze({\n\t\t\t\t\tunit: \"bytes\",\n\t\t\t\t\thardLimit: maxOutputBytes,\n\t\t\t\t\tperRequest: true,\n\t\t\t\t\tmeasurementSource: \"adapter-measured\",\n\t\t\t\t} satisfies ToolProviderSizeLimit),\n\t\t\t]),\n\t\t}),\n\t\ttimeout: Object.freeze({ timeoutMs: positiveFinite(opts.timeoutMs, 10_000) }),\n\t\tredaction: Object.freeze({\n\t\t\tmode: \"summary\",\n\t\t\tsummaryMaxChars: nonNegativeFinite(opts.maxSummaryChars, 512),\n\t\t}),\n\t\tfilesystem: Object.freeze({\n\t\t\tcwd: opts.workingDirectory ?? \".\",\n\t\t\tallowRead: false,\n\t\t\tallowWrite: false,\n\t\t\tfollowSymlinks: false,\n\t\t\tpathRules: Object.freeze(\n\t\t\t\t(opts.allowedWorkingDirectories ?? [opts.workingDirectory ?? \".\"]).map((path) =>\n\t\t\t\t\tObject.freeze({\n\t\t\t\t\t\teffect: \"allow\",\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\toperation: \"run\",\n\t\t\t\t\t\treason: \"Process adapter cwd allowlist.\",\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t),\n\t\t}),\n\t\tapproval: Object.freeze({ mode: \"auto\" }),\n\t\tmetadata: Object.freeze({\n\t\t\targv: true,\n\t\t\tshell: false,\n\t\t\tallowedEnvKeys: Object.freeze([...(opts.allowedEnvKeys ?? [])]),\n\t\t}),\n\t} satisfies ToolProviderExecutionPolicy);\n}\n\ninterface HttpRuntimeConfig {\n\treadonly allowedOrigins: ReadonlySet<string>;\n\treadonly allowedMethods: ReadonlySet<string>;\n\treadonly allowedRequestHeaders: ReadonlySet<string>;\n\treadonly exposedResponseHeaders: ReadonlySet<string>;\n\treadonly timeoutMs: number;\n\treadonly maxResponseBytes: number;\n\treadonly maxInlineBodyChars: number;\n\treadonly approvalMode: \"auto\" | \"require\" | \"never\";\n}\n\nfunction httpRuntimeConfig(opts: HttpToolProviderRuntimeOptions): HttpRuntimeConfig {\n\treturn {\n\t\tallowedOrigins: new Set(opts.allowedOrigins ?? []),\n\t\tallowedMethods: new Set(normalizeMethods(opts.allowedMethods ?? [\"GET\"])),\n\t\tallowedRequestHeaders: new Set(normalizeHeaderNames(opts.allowedRequestHeaders ?? [])),\n\t\texposedResponseHeaders: new Set(normalizeHeaderNames(opts.exposedResponseHeaders ?? [])),\n\t\ttimeoutMs: positiveFinite(opts.timeoutMs, 10_000),\n\t\tmaxResponseBytes: Math.max(1, nonNegativeFinite(opts.maxResponseBytes, 64 * 1024)),\n\t\tmaxInlineBodyChars: Math.max(1, nonNegativeFinite(opts.maxInlineBodyChars, 4_096)),\n\t\tapprovalMode: opts.approvalMode ?? \"auto\",\n\t};\n}\n\nfunction httpToolProviderExecutionPolicy(\n\tproviderId: string,\n\tprofileId: string,\n\topts: Omit<HttpToolProviderRuntimeOptions, \"inputs\" | \"runRequests\" | \"driver\">,\n): ToolProviderExecutionPolicy {\n\tconst allowedOrigins = Object.freeze([...(opts.allowedOrigins ?? [])]);\n\tconst allowedMethods = Object.freeze(normalizeMethods(opts.allowedMethods ?? [\"GET\"]));\n\tconst maxResponseBytes = Math.max(1, nonNegativeFinite(opts.maxResponseBytes, 64 * 1024));\n\treturn Object.freeze({\n\t\tkind: \"tool-provider-execution-policy\",\n\t\tpolicyId: `${providerId}:policy:http-v0`,\n\t\tproviderId,\n\t\tprofileIds: Object.freeze([profileId]),\n\t\ttoolNames: Object.freeze([\"http.fetch\"]),\n\t\toperations: Object.freeze([\"fetch\"]),\n\t\tsizeCapacity: Object.freeze({\n\t\t\tlimits: Object.freeze([\n\t\t\t\tObject.freeze({\n\t\t\t\t\tunit: \"bytes\",\n\t\t\t\t\thardLimit: maxResponseBytes,\n\t\t\t\t\tperRequest: true,\n\t\t\t\t\tmeasurementSource: \"adapter-measured-response-body\",\n\t\t\t\t} satisfies ToolProviderSizeLimit),\n\t\t\t]),\n\t\t}),\n\t\ttimeout: Object.freeze({ timeoutMs: positiveFinite(opts.timeoutMs, 10_000) }),\n\t\tredaction: Object.freeze({\n\t\t\tmode: \"summary\",\n\t\t\tsummaryMaxChars: nonNegativeFinite(opts.maxInlineBodyChars, 4_096),\n\t\t}),\n\t\tnetwork: Object.freeze({\n\t\t\tmode: \"allowlist\",\n\t\t\tprotocols: Object.freeze([\"http:\", \"https:\"]),\n\t\t\tallowedHosts: allowedOrigins,\n\t\t\tmetadata: Object.freeze({ allowlistKind: \"origin\" }),\n\t\t}),\n\t\tapproval: Object.freeze({ mode: opts.approvalMode ?? \"auto\" }),\n\t\tartifacts: Object.freeze({\n\t\t\tdefaultDataMode: \"summary\",\n\t\t\tinlineLimits: Object.freeze([\n\t\t\t\tObject.freeze({\n\t\t\t\t\tunit: \"chars\",\n\t\t\t\t\thardLimit: Math.max(1, nonNegativeFinite(opts.maxInlineBodyChars, 4_096)),\n\t\t\t\t\tperArtifact: true,\n\t\t\t\t\tmeasurementSource: \"js-string-length\",\n\t\t\t\t} satisfies ToolProviderSizeLimit),\n\t\t\t]),\n\t\t\tartifactKinds: Object.freeze([\"http-response-body\"]),\n\t\t}),\n\t\tmetadata: Object.freeze({\n\t\t\tallowedOrigins,\n\t\t\tallowedMethods,\n\t\t\tallowedRequestHeaders: Object.freeze([...(opts.allowedRequestHeaders ?? [])]),\n\t\t\texposedResponseHeaders: Object.freeze([...(opts.exposedResponseHeaders ?? [])]),\n\t\t\tasyncRuntime: true,\n\t\t}),\n\t} satisfies ToolProviderExecutionPolicy);\n}\n\nfunction prepareHttpRequest(\n\tinput: ToolProviderAdapterInput<HttpToolArguments>,\n\tconfig: HttpRuntimeConfig,\n):\n\t| { readonly kind: \"ready\"; readonly request: HttpToolProviderDriverRequest }\n\t| { readonly kind: \"blocked\"; readonly issue: DataIssue } {\n\tconst raw = input.toolCall?.arguments;\n\tif (!isRecord(raw) || typeof raw.url !== \"string\") {\n\t\treturn {\n\t\t\tkind: \"blocked\",\n\t\t\tissue: issue(\"http-invalid-arguments\", \"http.fetch requires a string url argument.\"),\n\t\t};\n\t}\n\tlet url: URL;\n\ttry {\n\t\turl = new URL(raw.url);\n\t} catch {\n\t\treturn { kind: \"blocked\", issue: issue(\"http-invalid-url\", \"http.fetch url is invalid.\") };\n\t}\n\tif (url.protocol !== \"http:\" && url.protocol !== \"https:\") {\n\t\treturn {\n\t\t\tkind: \"blocked\",\n\t\t\tissue: issue(\"http-protocol-not-allowed\", \"http.fetch only allows http and https URLs.\"),\n\t\t};\n\t}\n\tif (!config.allowedOrigins.has(url.origin)) {\n\t\treturn {\n\t\t\tkind: \"blocked\",\n\t\t\tissue: issue(\"http-origin-not-allowed\", \"http.fetch origin is not allowlisted.\"),\n\t\t};\n\t}\n\tconst method = normalizeMethod(raw.method ?? \"GET\");\n\tif (method === undefined || !config.allowedMethods.has(method)) {\n\t\treturn {\n\t\t\tkind: \"blocked\",\n\t\t\tissue: issue(\"http-method-not-allowed\", \"http.fetch method is not allowlisted.\"),\n\t\t};\n\t}\n\tif (raw.body !== undefined && typeof raw.body !== \"string\") {\n\t\treturn {\n\t\t\tkind: \"blocked\",\n\t\t\tissue: issue(\"http-invalid-body\", \"http.fetch body must be a string when provided.\"),\n\t\t};\n\t}\n\tconst headers = httpArgumentHeaders(raw.headers, config);\n\tif (headers === undefined) {\n\t\treturn {\n\t\t\tkind: \"blocked\",\n\t\t\tissue: issue(\"http-request-header-not-allowed\", \"http.fetch header is not allowlisted.\"),\n\t\t};\n\t}\n\treturn {\n\t\tkind: \"ready\",\n\t\trequest: Object.freeze({\n\t\t\turl: url.toString(),\n\t\t\tmethod,\n\t\t\theaders,\n\t\t\t...(raw.body === undefined ? {} : { body: raw.body }),\n\t\t}),\n\t};\n}\n\nfunction httpArgumentHeaders(\n\tvalue: unknown,\n\tconfig: HttpRuntimeConfig,\n): Readonly<Record<string, string>> | undefined {\n\tif (value === undefined) return Object.freeze({});\n\tif (!isRecord(value)) return undefined;\n\tconst headers: Record<string, string> = {};\n\tfor (const [key, entry] of Object.entries(value)) {\n\t\tconst normalized = key.toLowerCase();\n\t\tif (!config.allowedRequestHeaders.has(normalized)) return undefined;\n\t\tif (\n\t\t\tentry !== undefined &&\n\t\t\ttypeof entry !== \"string\" &&\n\t\t\ttypeof entry !== \"number\" &&\n\t\t\ttypeof entry !== \"boolean\"\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\t\tif (entry !== undefined) headers[key] = String(entry);\n\t}\n\treturn Object.freeze(headers);\n}\n\nfunction httpResponseResult(\n\trequest: HttpToolProviderDriverRequest,\n\tresponse: HttpToolProviderDriverResponse,\n\tconfig: HttpRuntimeConfig,\n): ToolProviderAdapterRunResult<HttpToolResult> {\n\tconst hasInlineBody = response.bodyText !== undefined;\n\tconst bodyText = response.bodyText ?? \"\";\n\tconst bodyBytes = response.bodyBytes ?? textBytes(bodyText);\n\tconst hasBodyRef = response.bodyRef !== undefined;\n\tif (bodyBytes > config.maxResponseBytes && !hasBodyRef) {\n\t\treturn {\n\t\t\tkind: \"failure\",\n\t\t\terror: issue(\"http-response-too-large\", \"HTTP response body exceeded maxResponseBytes.\"),\n\t\t\tretryable: false,\n\t\t\tmetadata: Object.freeze({ bodyBytes, maxResponseBytes: config.maxResponseBytes }),\n\t\t};\n\t}\n\tconst inline =\n\t\thasInlineBody &&\n\t\tbodyBytes <= config.maxResponseBytes &&\n\t\tbodyText.length <= config.maxInlineBodyChars;\n\tconst result: HttpToolResult = Object.freeze({\n\t\turl: response.url ?? request.url,\n\t\tmethod: request.method,\n\t\tstatus: response.status,\n\t\tstatusText: response.statusText ?? \"\",\n\t\theaders: filterResponseHeaders(response.headers, config.exposedResponseHeaders),\n\t\tbodyPreview: hasInlineBody ? previewText(bodyText, config.maxInlineBodyChars) : undefined,\n\t\t...(inline ? { bodyText } : {}),\n\t\tbodyBytes,\n\t\tbodyTruncated:\n\t\t\tbodyBytes > config.maxResponseBytes || bodyText.length > config.maxInlineBodyChars,\n\t\tdataMode: inline ? \"inline\" : hasBodyRef ? \"ref\" : \"summary\",\n\t\t...(response.bodyRef === undefined ? {} : { bodyRef: response.bodyRef }),\n\t});\n\treturn {\n\t\tkind: \"result\",\n\t\tresult: Object.freeze({\n\t\t\tkind: \"http-result\",\n\t\t\tvalue: result,\n\t\t\tsummary: `${request.method} ${response.status} ${response.url ?? request.url}`,\n\t\t\trefs: response.bodyRef === undefined ? undefined : Object.freeze([response.bodyRef]),\n\t\t\tartifacts: Object.freeze([httpBodyArtifact(result, response.bodyRef)]),\n\t\t}),\n\t\tissues:\n\t\t\t!inline && !hasBodyRef\n\t\t\t\t? Object.freeze([\n\t\t\t\t\t\tissue(\n\t\t\t\t\t\t\t\"http-response-body-summary-only\",\n\t\t\t\t\t\t\t\"HTTP response body was summarized without a durable body ref.\",\n\t\t\t\t\t\t\t\"warning\",\n\t\t\t\t\t\t),\n\t\t\t\t\t])\n\t\t\t\t: undefined,\n\t\tmetadata: Object.freeze({ status: response.status, bodyBytes }),\n\t};\n}\n\nfunction httpBodyArtifact(\n\tresult: HttpToolResult,\n\tbodyRef: SourceRef | undefined,\n): ExecutorArtifactMaterial<string> {\n\treturn Object.freeze({\n\t\tkind: \"http-response-body\",\n\t\tformat: \"text\",\n\t\tbyteLength: result.bodyBytes,\n\t\tdataMode: result.dataMode,\n\t\t...(result.bodyPreview === undefined ? {} : { summary: result.bodyPreview }),\n\t\t...(result.dataMode === \"inline\" && result.bodyText !== undefined\n\t\t\t? { value: result.bodyText }\n\t\t\t: {}),\n\t\t...(bodyRef === undefined ? {} : { ref: bodyRef, refs: Object.freeze([bodyRef]) }),\n\t\tsizeEvidence: Object.freeze([\n\t\t\tsizeEvidence(result.bodyBytes, \"adapter-measured-http-response-body\", undefined),\n\t\t]),\n\t} satisfies ExecutorArtifactMaterial<string>);\n}\n\nfunction httpErrorResult(\n\terror: unknown,\n\tconfig: HttpRuntimeConfig,\n): ToolProviderAdapterRunResult<HttpToolResult> {\n\tconst aborted = error instanceof Error && error.name === \"AbortError\";\n\tif (aborted) {\n\t\treturn { kind: \"timeout\", timeoutMs: config.timeoutMs, retryable: true };\n\t}\n\treturn {\n\t\tkind: \"failure\",\n\t\terror: issue(\"http-fetch-failed\", \"HTTP fetch failed before producing a response.\"),\n\t\tretryable: true,\n\t\tmetadata: Object.freeze({ errorType: error instanceof Error ? error.name : typeof error }),\n\t};\n}\n\nfunction defaultHttpToolProviderDriver(maxResponseBytes: number): HttpToolProviderDriver {\n\treturn Object.freeze({\n\t\tfetch(request: HttpToolProviderDriverRequest) {\n\t\t\tconst fetchImpl = globalThis.fetch;\n\t\t\tif (typeof fetchImpl !== \"function\") {\n\t\t\t\tthrow new Error(\"global fetch is unavailable\");\n\t\t\t}\n\t\t\treturn fetchImpl(request.url, {\n\t\t\t\tmethod: request.method,\n\t\t\t\theaders: request.headers,\n\t\t\t\tbody: request.body,\n\t\t\t\tredirect: \"manual\",\n\t\t\t\tsignal: request.signal,\n\t\t\t}).then((response) =>\n\t\t\t\treadResponseBody(response, maxResponseBytes).then((body) =>\n\t\t\t\t\tObject.freeze({\n\t\t\t\t\t\turl: response.url,\n\t\t\t\t\t\tstatus: response.status,\n\t\t\t\t\t\tstatusText: response.statusText,\n\t\t\t\t\t\theaders: responseHeaders(response.headers),\n\t\t\t\t\t\tbodyText: body.text,\n\t\t\t\t\t\tbodyBytes: body.bytes,\n\t\t\t\t\t} satisfies HttpToolProviderDriverResponse),\n\t\t\t\t),\n\t\t\t);\n\t\t},\n\t});\n}\n\nfunction readResponseBody(\n\tresponse: Response,\n\tmaxBytes: number,\n): Promise<{ readonly text: string; readonly bytes: number }> {\n\tconst body = response.body;\n\tif (body === null) return Promise.resolve({ text: \"\", bytes: 0 });\n\tconst reader = body.getReader();\n\tconst decoder = new TextDecoder();\n\tconst chunks: string[] = [];\n\tlet bytes = 0;\n\tfunction pump(): Promise<{ readonly text: string; readonly bytes: number }> {\n\t\treturn reader.read().then((next) => {\n\t\t\tif (next.done) {\n\t\t\t\tchunks.push(decoder.decode());\n\t\t\t\treturn { text: chunks.join(\"\"), bytes };\n\t\t\t}\n\t\t\tbytes += next.value.byteLength;\n\t\t\tif (bytes > maxBytes) {\n\t\t\t\treader.cancel().catch(() => {});\n\t\t\t\treturn { text: chunks.join(\"\"), bytes };\n\t\t\t}\n\t\t\tchunks.push(decoder.decode(next.value, { stream: true }));\n\t\t\treturn pump();\n\t\t});\n\t}\n\treturn pump();\n}\n\nfunction responseHeaders(headers: Headers): Readonly<Record<string, string>> {\n\tconst out: Record<string, string> = {};\n\theaders.forEach((value, key) => {\n\t\tout[key] = value;\n\t});\n\treturn Object.freeze(out);\n}\n\nfunction filterResponseHeaders(\n\theaders: Readonly<Record<string, string>> | undefined,\n\texposed: ReadonlySet<string>,\n): Readonly<Record<string, string>> | undefined {\n\tif (headers === undefined || exposed.size === 0) return undefined;\n\tconst out: Record<string, string> = {};\n\tfor (const [key, value] of Object.entries(headers)) {\n\t\tif (exposed.has(key.toLowerCase())) out[key] = value;\n\t}\n\treturn Object.keys(out).length === 0 ? undefined : Object.freeze(out);\n}\n\nfunction requestMatchesInput(\n\trequest: ToolProviderAdapterRunRequested,\n\tinput: ToolProviderAdapterInput,\n): boolean {\n\treturn (\n\t\trequest.adapterInputId === input.adapterInputId &&\n\t\trequest.requestId === input.requestId &&\n\t\trequest.operationId === input.operationId &&\n\t\t(request.routeId === undefined || request.routeId === input.routeId) &&\n\t\t(request.executorId === undefined || request.executorId === input.executorId) &&\n\t\t(request.profileId === undefined || request.profileId === input.profileId)\n\t);\n}\n\nfunction requestApproved(request: ToolProviderAdapterRunRequested): boolean {\n\tconst metadata = request.metadata;\n\treturn (\n\t\tisRecord(metadata) &&\n\t\t(metadata.approval === \"granted\" ||\n\t\t\tmetadata.approvalGranted === true ||\n\t\t\t(isAdmissionApprovedMetadata(metadata) && hasAdmissionSourceRef(request.sourceRefs)))\n\t);\n}\n\nfunction isAdmissionApprovedMetadata(metadata: Record<string, unknown>): boolean {\n\treturn (\n\t\ttypeof metadata.admissionId === \"string\" &&\n\t\tmetadata.admissionId.length > 0 &&\n\t\ttypeof metadata.proposalId === \"string\" &&\n\t\tmetadata.proposalId.length > 0 &&\n\t\ttypeof metadata.approvedFromRunId === \"string\" &&\n\t\tmetadata.approvedFromRunId.length > 0\n\t);\n}\n\nfunction hasAdmissionSourceRef(sourceRefs: readonly SourceRef[] | undefined): boolean {\n\treturn (sourceRefs ?? []).some(\n\t\t(sourceRef) =>\n\t\t\tsourceRef.kind === \"tool-provider-run-admission\" ||\n\t\t\tsourceRef.kind === \"tool-provider-run-admission-decision\",\n\t);\n}\n\nfunction defaultEvidenceRefs(input: ToolProviderAdapterInput): readonly SourceRef[] {\n\treturn Object.freeze([\n\t\t{ kind: \"tool-provider-adapter-input\", id: input.adapterInputId },\n\t\t...(input.sourceRefs ?? []),\n\t]);\n}\n\nfunction outcomeIssues(outcome: ExecutorOutcome): readonly DataIssue[] {\n\tif (outcome.kind === \"failure\") return Object.freeze([outcome.error, ...(outcome.issues ?? [])]);\n\treturn outcome.issues ?? [];\n}\n\nfunction agentStatusForOutcome(outcome: ExecutorOutcome): AgentRequestStatusChanged[\"status\"] {\n\tswitch (outcome.kind) {\n\t\tcase \"result\":\n\t\t\treturn \"completed\";\n\t\tcase \"failure\":\n\t\t\treturn \"failed\";\n\t\tcase \"blocked\":\n\t\t\treturn \"blocked\";\n\t\tcase \"canceled\":\n\t\t\treturn \"canceled\";\n\t\tcase \"timeout\":\n\t\t\treturn \"timeout\";\n\t}\n}\n\nfunction normalizeMethods(methods: readonly string[]): readonly string[] {\n\treturn Object.freeze(\n\t\tmethods\n\t\t\t.map((method) => normalizeMethod(method))\n\t\t\t.filter((method): method is string => method !== undefined),\n\t);\n}\n\nfunction normalizeMethod(method: unknown): string | undefined {\n\treturn typeof method === \"string\" && method.length > 0 ? method.toUpperCase() : undefined;\n}\n\nfunction normalizeHeaderNames(headers: readonly string[]): readonly string[] {\n\treturn Object.freeze(\n\t\theaders\n\t\t\t.filter((header) => typeof header === \"string\" && header.length > 0)\n\t\t\t.map((header) => header.toLowerCase()),\n\t);\n}\n\nfunction textBytes(text: string): number {\n\treturn new TextEncoder().encode(text).byteLength;\n}\n\nfunction previewText(text: string, maxChars: number): string | undefined {\n\tif (text.length === 0) return undefined;\n\treturn text.length <= maxChars ? text : text.slice(0, maxChars);\n}\n\nfunction blocked<T>(\n\tinput: ToolProviderAdapterInput,\n\tcode: string,\n\tmessage: string,\n): ToolProviderAdapterRunResult<T> {\n\treturn Object.freeze({\n\t\tkind: \"blocked\",\n\t\tneeds: Object.freeze([\n\t\t\tObject.freeze({\n\t\t\t\tkind: code,\n\t\t\t\tmessage,\n\t\t\t\trefs:\n\t\t\t\t\tinput.providerId === undefined\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: Object.freeze([{ kind: \"tool-provider\", id: input.providerId }]),\n\t\t\t}),\n\t\t]),\n\t\tissues: Object.freeze([issue(code, message, \"error\")]),\n\t\tevidenceRefs: input.sourceRefs,\n\t} satisfies ToolProviderAdapterRunResult<T>);\n}\n\nfunction failure<T>(\n\tinput: ToolProviderAdapterInput,\n\tcode: string,\n\tmessage: string,\n): ToolProviderAdapterRunResult<T> {\n\treturn Object.freeze({\n\t\tkind: \"failure\",\n\t\terror: issue(code, message, \"error\"),\n\t\tretryable: false,\n\t\tevidenceRefs: input.sourceRefs,\n\t} satisfies ToolProviderAdapterRunResult<T>);\n}\n\nfunction issue(\n\tcode: string,\n\tmessage: string,\n\tseverity: DataIssue[\"severity\"] = \"error\",\n\tdetails?: unknown,\n): DataIssue {\n\treturn Object.freeze({\n\t\tkind: \"issue\",\n\t\tcode,\n\t\tmessage,\n\t\tseverity,\n\t\t...(details === undefined ? {} : { details }),\n\t} satisfies DataIssue);\n}\n\nfunction sizeEvidence(\n\tquantity: number,\n\tmeasurementSource: string,\n\tsourceRefs: readonly SourceRef[] | undefined,\n): SizeCapacityEvidence {\n\treturn Object.freeze({\n\t\tkind: \"size-capacity-evidence\",\n\t\tunit: \"bytes\",\n\t\tquantity,\n\t\tmeasurementSource,\n\t\t...(sourceRefs === undefined ? {} : { sourceRefs }),\n\t} satisfies SizeCapacityEvidence);\n}\n\nfunction nonNegativeFinite(value: number | undefined, fallback: number): number {\n\treturn typeof value === \"number\" && Number.isFinite(value) && value >= 0 ? value : fallback;\n}\n\nfunction positiveFinite(value: number | undefined, fallback: number): number {\n\treturn typeof value === \"number\" && Number.isFinite(value) && value > 0 ? value : fallback;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction stringArray(value: unknown): readonly string[] | undefined {\n\tif (!Array.isArray(value)) return undefined;\n\tconst entries = Array.from(value);\n\tif (!entries.every((entry) => typeof entry === \"string\")) return undefined;\n\treturn Object.freeze(entries);\n}\n\nfunction arraysEqual(a: readonly string[], b: readonly string[]): boolean {\n\treturn a.length === b.length && a.every((value, index) => value === b[index]);\n}\n\nfunction normalizeAllowedCommands(commands: readonly ProcessToolAllowedCommand[]): {\n\treadonly commands: ReadonlyMap<string, ProcessToolAllowedCommand>;\n\treadonly duplicates: ReadonlySet<string>;\n\treadonly invalids: ReadonlySet<string>;\n} {\n\tconst out = new Map<string, ProcessToolAllowedCommand>();\n\tconst duplicates = new Set<string>();\n\tconst invalids = new Set<string>();\n\tfor (const command of commands) {\n\t\tif (typeof command.command !== \"string\" || command.command.length === 0) {\n\t\t\tinvalids.add(\"<invalid-command>\");\n\t\t\tcontinue;\n\t\t}\n\t\tconst frozen = freezeAllowedCommand(command);\n\t\tif (frozen === undefined) {\n\t\t\tout.delete(command.command);\n\t\t\tinvalids.add(command.command);\n\t\t\tcontinue;\n\t\t}\n\t\tif (out.has(command.command)) {\n\t\t\tout.delete(command.command);\n\t\t\tduplicates.add(command.command);\n\t\t\tcontinue;\n\t\t}\n\t\tif (duplicates.has(command.command) || invalids.has(command.command)) continue;\n\t\tout.set(command.command, frozen);\n\t}\n\treturn { commands: out, duplicates, invalids };\n}\n\nfunction freezeAllowedCommand(\n\tcommand: ProcessToolAllowedCommand,\n): ProcessToolAllowedCommand | undefined {\n\tconst fixedArgs = command.fixedArgs === undefined ? undefined : stringArray(command.fixedArgs);\n\tif (command.fixedArgs !== undefined && fixedArgs === undefined) return undefined;\n\tconst allowArgs = Array.isArray(command.allowArgs)\n\t\t? stringArray(command.allowArgs)\n\t\t: command.allowArgs;\n\tif (Array.isArray(command.allowArgs) && allowArgs === undefined) return undefined;\n\treturn Object.freeze({\n\t\tcommand: command.command,\n\t\t...(command.executable === undefined ? {} : { executable: command.executable }),\n\t\t...(fixedArgs === undefined ? {} : { fixedArgs }),\n\t\t...(allowArgs === undefined ? {} : { allowArgs }),\n\t\t...(command.cwd === undefined ? {} : { cwd: command.cwd }),\n\t});\n}\n\nfunction realpath(path: string): string | undefined {\n\ttry {\n\t\treturn realpathSync.native(path);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction isPathInside(path: string, root: string): boolean {\n\tconst normalizedPath = resolve(path);\n\tconst normalizedRoot = resolve(root);\n\tconst rel = relative(normalizedRoot, normalizedPath);\n\treturn rel === \"\" || (rel.length > 0 && !rel.startsWith(\"..\") && !isAbsolute(rel));\n}\n\nfunction isTimeoutError(error: Error): boolean {\n\treturn (error as Error & { readonly code?: unknown }).code === \"ETIMEDOUT\";\n}\n\nfunction isOutputLimitError(error: Error | undefined): boolean {\n\treturn (error as (Error & { readonly code?: unknown }) | undefined)?.code === \"ENOBUFS\";\n}\n\nfunction preview(buffer: Buffer, maxChars: number): string | undefined {\n\tif (buffer.length === 0) return undefined;\n\tconst text = buffer.toString(\"utf8\");\n\treturn text.length <= maxChars ? text : text.slice(0, maxChars);\n}\n","/**\n * Wave-protocol message types and the tier const table.\n *\n * Canonical authority: ~/src/graphrefly/spec/rules.jsonl\n * R-msg-format, R-msg-closed-set, R-tier (D34), R-data-payload, R-sentinel.\n */\n\n/** Opaque pause-lock / pull identifier (R-pause-lockset, R-pull). */\nexport type LockId = string | symbol;\n\n/** Explicit pull demand payload (D269/D272). Params are holder-visible context, never DATA-up. */\nexport interface PullDemand {\n\treadonly pullId: LockId;\n\treadonly params?: unknown;\n}\n\n/**\n * The CLOSED set of 11 message types (R-msg-closed-set / D9 + D269 + START handshake).\n * No open set, no user-defined custom types. Adding a type is a spec change.\n */\nexport type Message =\n\t| readonly [\"START\"]\n\t| readonly [\"DIRTY\"]\n\t| readonly [\"DATA\", unknown]\n\t| readonly [\"RESOLVED\"]\n\t| readonly [\"INVALIDATE\"]\n\t| readonly [\"COMPLETE\"]\n\t| readonly [\"ERROR\", unknown]\n\t| readonly [\"TEARDOWN\"]\n\t| readonly [\"PAUSE\", LockId]\n\t| readonly [\"RESUME\", LockId]\n\t| readonly [\"PULL\", PullDemand];\n\n/** One array of messages delivered in one call = one Wave (R-wave-boundary). */\nexport type Wave = readonly Message[];\n\n/** The message-type tag (the first tuple element). */\nexport type MessageType = Message[0];\n\n/**\n * SENTINEL = absence-of-DATA (R-sentinel / D16). TS representation is `undefined`.\n * Never a valid DATA payload; `null` IS a valid DATA value (domain-level absence).\n */\nexport const SENTINEL = undefined;\n\n/** R-data-payload: ERROR payloads must not collide with terminal metadata shorthand. */\nexport function isInvalidErrorPayload(v: unknown): boolean {\n\treturn v === SENTINEL || typeof v === \"boolean\";\n}\n\n/** R-data-payload / D78: host-language failures that collide with ctx.terminal shorthand become diagnostics. */\nexport function errorPayload(reason: unknown, fallback = \"error without a valid payload\"): unknown {\n\treturn isInvalidErrorPayload(reason) ? new Error(fallback) : reason;\n}\n\nexport const TIER_START = 0;\nexport const TIER_CONTROL = 1;\nexport const TIER_NOTIFICATION = 2;\nexport const TIER_VALUE = 3;\nexport const TIER_SETTLE = 4;\nexport const TIER_TERMINAL = 5;\nexport const TIER_TEARDOWN = 6;\n\n/**\n * Tier const table (R-tier / D34). Tiers below value dispatch immediately; value\n * and above are batch-deferred. This is a compile-time const table (D18), not runtime config.\n */\nconst TIER: Record<MessageType, number> = {\n\tSTART: TIER_START,\n\tPAUSE: TIER_CONTROL,\n\tRESUME: TIER_CONTROL,\n\tPULL: TIER_CONTROL,\n\tDIRTY: TIER_NOTIFICATION,\n\tDATA: TIER_VALUE,\n\tRESOLVED: TIER_VALUE,\n\tINVALIDATE: TIER_SETTLE,\n\tCOMPLETE: TIER_TERMINAL,\n\tERROR: TIER_TERMINAL,\n\tTEARDOWN: TIER_TEARDOWN,\n};\n\nexport function messageTier(t: MessageType): number {\n\treturn TIER[t];\n}\n\n/** Value and above are deferred inside a batch (DATA/RESOLVED/INVALIDATE/terminal/teardown). */\nexport function isDeferredTier(t: MessageType): boolean {\n\treturn TIER[t] >= TIER_VALUE;\n}\n\n/** Value-tier messages (DATA/RESOLVED) occupy the tier-3 slot. */\nexport function isValueTier(t: MessageType): boolean {\n\treturn TIER[t] === TIER_VALUE;\n}\n\n/** The pause buffer holds the settle slice only: value-tier DATA/RESOLVED plus INVALIDATE. */\nexport function isPauseBufferedTier(t: MessageType): boolean {\n\tconst tier = TIER[t];\n\treturn tier === TIER_VALUE || tier === TIER_SETTLE;\n}\n\n/**\n * A TERMINAL message = tier 5 (COMPLETE | ERROR), R-tier / D34. Detected via the CENTRAL tier\n * table, NOT a per-variant `=== \"COMPLETE\" || === \"ERROR\"` check — so terminal routing stays\n * driven by the one const table (feedback_use_tier_for_signal_routing); discriminate COMPLETE vs\n * ERROR within the tier by the message type only where the handling actually differs.\n */\nexport function isTerminal(t: MessageType): boolean {\n\treturn TIER[t] === TIER_TERMINAL;\n}\n\n/**\n * ctx.up carries control/demand tiers only (R-ctx-up / D269): DIRTY, PAUSE, RESUME, PULL,\n * INVALIDATE, TEARDOWN. DATA/RESOLVED (tier 3) and COMPLETE/ERROR (tier 5) are\n * down-only.\n */\nexport function isUpAllowed(t: MessageType): boolean {\n\tconst tier = TIER[t];\n\treturn tier !== TIER_VALUE && tier !== TIER_TERMINAL;\n}\n","/**\n * The fn-invocation context and per-dep input shapes.\n *\n * Canonical authority: ~/src/graphrefly/spec/rules.jsonl\n * R-fn-contract (D8/D27), R-ctx-state (D23/D29), R-cleanup-hooks (D28), R-ctx-up.\n */\n\nimport type { Dispatcher } from \"../dispatcher/index.js\";\nimport type { EnvironmentDrivers } from \"../graph/environment.js\";\nimport type { Node } from \"../node/node.js\";\nimport { type Message, type PullDemand, SENTINEL, type Wave } from \"../protocol/messages.js\";\n\n/** A downstream sink callback (the only way to connect to a node's output). */\nexport type Sink = (msg: Message, delivery?: DeliveryMeta) => void;\n\n/** Internal delivery metadata used to preserve the upstream `ctx.down(msgs)` wave boundary. */\nexport interface DeliveryMeta {\n\treadonly wave: object;\n\treadonly last: boolean;\n}\n\n/**\n * Internal current-value reader. It is deliberately a symbol-backed implementation detail:\n * raw ctx exposes `waveData` + `terminal`; helpers below derive from that plus this dep cache.\n */\nexport const CTX_DEP_CACHE: unique symbol = Symbol(\"graphrefly.ctx.depCache\");\n\nexport interface CtxDepCache {\n\treadonly latest: readonly unknown[];\n}\n\n/** Internal node-construction binding for graph-local helper-created deps. */\nexport const CTX_NODE_BINDING: unique symbol = Symbol(\"graphrefly.ctx.nodeBinding\");\n\nexport interface CtxNodeBinding {\n\treadonly dispatcher: Dispatcher;\n\tcreate<T>(factory: () => Node<T>): Node<T>;\n}\n\n/** Per-dep wave projections: dep -> waves -> values/SENTINEL markers. */\nexport type WaveData = readonly (readonly (readonly unknown[])[])[];\n\n/** Terminal metadata parallel to `waveData`: false = none, true = COMPLETE, otherwise ERROR payload. */\nexport type TerminalData = readonly unknown[];\n\nexport function isTerminalNone(t: unknown): boolean {\n\treturn t === false || t === undefined;\n}\n\nexport function isTerminalComplete(t: unknown): t is true {\n\treturn t === true;\n}\n\nexport function isTerminalError(t: unknown): boolean {\n\treturn !isTerminalNone(t) && !isTerminalComplete(t);\n}\n\nexport function terminalErrorValue(t: unknown): unknown {\n\treturn isTerminalError(t) ? t : undefined;\n}\n\n/**\n * Per-node private cross-wave state (R-ctx-state / D23,D29). Default fresh-lifecycle\n * wipe; `persist(true)` keeps it across lifecycle transitions.\n */\nexport interface CtxState {\n\tget<S = unknown>(): S | undefined;\n\tset<S = unknown>(v: S): void;\n\tpersist(on?: boolean): void;\n}\n\n/**\n * Deferred SELF-rewire (R-rewire-deferred / D47). A node fn may, DURING its run, request a\n * mutation of its OWN dep set; the request is QUEUED and applied at the committed wave boundary\n * (after the current wave settles / batch commit / final-lock RESUME) as a fresh wave, reusing\n * R-rewire surgical/Option-C semantics (D42). This is the ONLY legal self-triggered rewire — an\n * IMMEDIATE in-fn `node.subscribeDep/unsubscribeDep/replaceDeps` is the D37 mid-fn feedback-cycle ERROR. An\n * added cached dep pushes `[DIRTY,DATA]` on the boundary wave (R-push-subscribe); a removed dep\n * is drained and, if it loses its last subscriber, `_deactivate`s + fires `onDeactivation`\n * (input-side teardown — the basis for higher-order operator cancellation / abortInFlight).\n */\nexport interface RewireNext {\n\t/** Defer subscribing to a dep (paired with the re-supplied fn — positional fn-deps lock, SD-1). */\n\tsubscribeDep(dep: Node<unknown>, fn: NodeFn): void;\n\t/** Defer unsubscribing from a dep (its source is torn down if it loses its last subscriber). */\n\tunsubscribeDep(dep: Node<unknown>, fn: NodeFn): void;\n\t/** Defer replacing the whole dep set (surgical: kept deps untouched, removed drained, added fresh-subscribe). */\n\treplaceDeps(deps: Node<unknown>[], fn: NodeFn): void;\n}\n\n/**\n * The single argument to a node fn: `(ctx) => void` (R-fn-contract / D8). All emission\n * is explicit via `ctx.down`; there is no return-value framing.\n */\nexport interface Ctx {\n\t/**\n\t * Emit upstream toward deps — control tiers only (R-ctx-up). IMMEDIATE. `towardDep` (a dep index)\n\t * routes the wave up ONE declared edge (R-up-routing directed-up); omitted = broadcast up all deps.\n\t * A pull DEMAND is `up([[PULL, { pullId, params }]])` — but for a SELF-demand (demanding a dep\n\t * this fn also reads) use {@link Ctx.upNext} instead, since an immediate demand whose delivery loops back\n\t * re-enters this fn mid-wave (D37 / R-reentrancy).\n\t */\n\tup(msgs: Wave, towardDep?: number): void;\n\t/** Emit downstream toward sinks. */\n\tdown(msgs: Wave): void;\n\t/**\n\t * The single raw dep-value input surface (R-ctx-wave-data / D77): dep -> upstream waves ->\n\t * per-wave DATA payloads and INVALIDATE/SENTINEL markers. `waveData[i] = []` means dep i\n\t * delivered no wave to this invocation; `waveData[i] = [[]]` means RESOLVED-only.\n\t */\n\twaveData: WaveData;\n\t/** Terminal metadata for the same invocation; terminal values never enter `waveData`. */\n\tterminal: TerminalData;\n\tstate: CtxState;\n\t/** Release external resources on deactivation (R-cleanup-hooks). */\n\tonDeactivation(fn: () => void): void;\n\t/** Flush on INVALIDATE (R-cleanup-hooks). */\n\tonInvalidate(fn: () => void): void;\n\t/** Graph-owned environment drivers for source/adapter boundaries (D130/D131). */\n\tenvironment(): EnvironmentDrivers;\n\t/** Holder-visible context for a PULL-caused invocation (D272); absent for ordinary waves. */\n\treadonly pull?: PullDemand;\n\t/**\n\t * Deferred SELF-rewire (R-rewire-deferred / D47) — the substrate affordance higher-order\n\t * operators (switchMap/mergeMap/concatMap/exhaustMap/flatMap) use to grow/shrink their own\n\t * inner-source dep set in response to their own data. Always present; see {@link RewireNext}.\n\t */\n\trewireNext: RewireNext;\n\t/**\n\t * Deferred up — the boundary-deferred form of {@link Ctx.up} (R-up-routing / R-pull / D59). Routes\n\t * `msgs` up from this node at the COMMITTED wave boundary (broadcast, or up the single `towardDep`\n\t * edge), riding the same R-rewire-deferred (D47) drain as {@link RewireNext}. This is the\n\t * SELF-DEMAND path: a consumer issues `ctx.upNext([[PULL, { pullId, params }]])` to demand a pull\n\t * dep it ALSO reads — the cone-routed PULL reaches the pullId-holder, whose delivery loops back as a\n\t * FRESH wave (not a mid-fn re-entry → no D37). The consumer accepts one-wave latency (the\n\t * HTTP-request model). No node reference needed: the author writes the pullId verbatim.\n\t */\n\tupNext(msgs: Wave, towardDep?: number): void;\n\t/**\n\t * Read a dep's latest value by index (dynamicNode only, R-dynamic-node / D35).\n\t * Present only on dynamicNode fns; all declared deps still participate in wave\n\t * tracking. Under D49/R-resolved-undirty an unread dep's change still fires the fn,\n\t * which re-emits its (unchanged) output as a DATA occurrence — there is NO equals-\n\t * absorption; pair with distinctUntilChanged to suppress unchanged re-emits (opt-in).\n\t */\n\ttrack?(depIndex: number): unknown;\n\t[CTX_DEP_CACHE]?: CtxDepCache;\n\t[CTX_NODE_BINDING]?: CtxNodeBinding;\n}\n\n/** A node fn (R-fn-contract). Registered in a dispatcher pool, indexed by Handle. */\nexport type NodeFn = (ctx: Ctx) => void;\n\n/** Number of declared dep slots visible in this invocation. */\nexport function depCount(ctx: Ctx): number {\n\treturn ctx.waveData.length;\n}\n\n/** DATA/SENTINEL projection batches delivered by one dep in this invocation. */\nexport function depWaves(ctx: Ctx, depIndex: number): readonly (readonly unknown[])[] {\n\treturn ctx.waveData[depIndex] ?? [];\n}\n\n/** Flattened DATA projection for old event-counting operator bodies; null = no wave. */\nexport function depBatch(ctx: Ctx, depIndex: number): readonly unknown[] | null {\n\tconst waves = depWaves(ctx, depIndex);\n\tif (waves.length === 0) return null;\n\tconst flattened = waves.flat().filter((v) => v !== SENTINEL);\n\treturn flattened.length === 0 ? [] : flattened;\n}\n\n/** Latest cached DATA for a dep, derived from implementation-owned dep cache. */\nexport function depLatest(ctx: Ctx, depIndex: number): unknown {\n\treturn ctx[CTX_DEP_CACHE]?.latest[depIndex];\n}\n\n/** Terminal metadata for one dep: false = none, true = COMPLETE, otherwise ERROR payload. */\nexport function depTerminal(ctx: Ctx, depIndex: number): unknown {\n\tconst t = ctx.terminal[depIndex];\n\treturn t === undefined ? false : t;\n}\n","import { type Ctx, depBatch } from \"../ctx/types.js\";\nimport type { DataIssue } from \"../data/index.js\";\nimport type { Graph } from \"../graph/graph.js\";\nimport type { Node } from \"../node/node.js\";\nimport type { AgentNeed } from \"./agent-runtime-types-agent.js\";\nimport type {\n\tAgentOutputEnvelope,\n\tExecutorArtifactMaterial,\n\tSizeCapacityEvidence,\n\tSourceRef,\n} from \"./agent-runtime-types-core.js\";\nimport type {\n\tToolProviderAdapterInput,\n\tToolProviderExecutionPolicy,\n\tToolProviderPublicTextPolicy,\n} from \"./agent-runtime-types-tool.js\";\n\nexport function uniqueSourceRefs(sourceRefs: readonly SourceRef[]): readonly SourceRef[] {\n\tconst seen = new Set<string>();\n\tconst unique: SourceRef[] = [];\n\tfor (const sourceRef of sourceRefs) {\n\t\tconst key = `${sourceRef.kind}:${sourceRef.id}:${JSON.stringify(sourceRef.metadata ?? {})}`;\n\t\tif (seen.has(key)) continue;\n\t\tseen.add(key);\n\t\tunique.push(sourceRef);\n\t}\n\treturn Object.freeze(unique);\n}\n\nexport function stableJsonStringify(value: unknown): string {\n\tconst seen = new WeakSet<object>();\n\treturn JSON.stringify(value, (_key, child) => {\n\t\tif (typeof child === \"bigint\") return child.toString();\n\t\tif (typeof child === \"function\") return \"[Function]\";\n\t\tif (!isRecord(child) && !Array.isArray(child)) return child;\n\t\tif (seen.has(child)) return \"[Circular]\";\n\t\tseen.add(child);\n\t\tif (Array.isArray(child)) return child;\n\t\treturn Object.keys(child)\n\t\t\t.sort()\n\t\t\t.reduce<Record<string, unknown>>((out, key) => {\n\t\t\t\tout[key] = child[key];\n\t\t\t\treturn out;\n\t\t\t}, {});\n\t});\n}\n\nexport function stableStringHash(value: string): string {\n\tlet hash = 0x811c9dc5;\n\tfor (let i = 0; i < value.length; i += 1) {\n\t\thash ^= value.charCodeAt(i);\n\t\thash = Math.imul(hash, 0x01000193);\n\t}\n\treturn (hash >>> 0).toString(36);\n}\n\nexport function cloneGraphVisibleMaterial(value: unknown): unknown {\n\tif (!isRecord(value) && !Array.isArray(value)) return value;\n\tif (Array.isArray(value))\n\t\treturn Object.freeze(value.map((item) => cloneGraphVisibleMaterial(item)));\n\treturn Object.freeze(\n\t\tObject.entries(value).reduce<Record<string, unknown>>((record, [key, child]) => {\n\t\t\trecord[key] = cloneGraphVisibleMaterial(child);\n\t\t\treturn record;\n\t\t}, {}),\n\t);\n}\n\nexport function projectRuntimeFact<T, TOut>(\n\tgraph: Graph,\n\truntime: Node<T>,\n\tname: string,\n\tfactory: string,\n\tpick: (fact: T) => TOut | undefined,\n): Node<TOut> {\n\treturn graph.node<TOut>(\n\t\t[runtime],\n\t\t(ctx) => {\n\t\t\tfor (const fact of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst typed = fact as T;\n\t\t\t\tconst value = pick(typed);\n\t\t\t\tif (value !== undefined) ctx.down([[\"DATA\", value]]);\n\t\t\t}\n\t\t},\n\t\t{ name, factory },\n\t);\n}\n\nexport function forEachDepBatch(\n\tctx: Ctx,\n\tstart: number,\n\tcount: number,\n\tfn: (value: unknown) => void,\n): void {\n\tfor (let i = 0; i < count; i += 1) {\n\t\tfor (const value of depBatch(ctx, start + i) ?? []) fn(value);\n\t}\n}\n\nexport function forbiddenDataKeys(\n\tvalue: unknown,\n\tpath: readonly (string | number)[] = [],\n\tseen: WeakSet<object> = new WeakSet(),\n): readonly { readonly path: readonly (string | number)[]; readonly reason: string }[] {\n\tif (typeof value === \"function\") return [{ path, reason: \"function-value\" }];\n\tif (typeof value === \"symbol\" || typeof value === \"bigint\") {\n\t\treturn [{ path, reason: \"non-graph-visible-primitive\" }];\n\t}\n\tif (!isRecord(value) && !Array.isArray(value)) return [];\n\tif (typeof value === \"object\" && value !== null) {\n\t\tif (seen.has(value)) return [];\n\t\tseen.add(value);\n\t}\n\tconst issues: { readonly path: readonly (string | number)[]; readonly reason: string }[] = [];\n\tif (Array.isArray(value)) {\n\t\tvalue.forEach((item, index) => {\n\t\t\tissues.push(...forbiddenDataKeys(item, [...path, index], seen));\n\t\t});\n\t\treturn issues;\n\t}\n\tif (!isPlainRecord(value)) return [{ path, reason: \"non-plain-runtime-object\" }];\n\tconst symbolKeys = Object.getOwnPropertySymbols(value);\n\tif (symbolKeys.length > 0) {\n\t\tissues.push({ path, reason: \"symbol-key\" });\n\t}\n\tfor (const [key, child] of Object.entries(value)) {\n\t\tconst nextPath = [...path, key];\n\t\tif (\n\t\t\t/^(apiKey|api_key|secret|client|transport|subprocess|sdk|oauth|credential|credentials|accessToken|access_token|refreshToken|refresh_token|idToken|id_token|token|password|passphrase|authorization|authHeader|auth_header|bearer|privateKey|private_key|sessionCookie|session_cookie|cookie)$/i.test(\n\t\t\t\tkey,\n\t\t\t)\n\t\t) {\n\t\t\tissues.push({ path: nextPath, reason: \"forbidden-runtime-key\" });\n\t\t}\n\t\tissues.push(...forbiddenDataKeys(child, nextPath, seen));\n\t}\n\treturn issues;\n}\n\nexport function forbiddenGraphVisibleMaterialIssues(\n\tvalue: unknown,\n\tsubjectRef: SourceRef,\n\tarea: string,\n): readonly DataIssue[] {\n\tif (value === undefined) return [];\n\tconst forbidden = publicMaterialForbiddenKeys(value, \"provider\");\n\tif (forbidden.length === 0) return [];\n\treturn Object.freeze(\n\t\tforbidden.map((entry) =>\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-catalog-forbidden-runtime-material\",\n\t\t\t\t\"Tool provider catalog material must not contain runtime-private adapter material.\",\n\t\t\t\t{ subjectId: subjectRef.id, refs: [subjectRef], details: { area, reason: entry.reason } },\n\t\t\t),\n\t\t),\n\t);\n}\n\nexport function forbiddenAdapterInputMaterialIssues(\n\tvalue: unknown,\n\tsubjectRef: SourceRef,\n\tarea: string,\n): readonly DataIssue[] {\n\tif (value === undefined) return [];\n\tconst forbidden = publicMaterialForbiddenKeys(value, \"provider\");\n\tif (forbidden.length === 0) return [];\n\treturn Object.freeze(\n\t\tforbidden.map((entry) =>\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-input-forbidden-runtime-material\",\n\t\t\t\t\"Tool provider adapter input material must not contain runtime-private adapter material.\",\n\t\t\t\t{ subjectId: subjectRef.id, refs: [subjectRef], details: { area, reason: entry.reason } },\n\t\t\t),\n\t\t),\n\t);\n}\n\nexport type PublicMaterialMode = \"graph\" | \"provider\";\n\nexport function sanitizeAdapterInputSourceRefs(\n\tsourceRefs: readonly SourceRef[],\n): readonly SourceRef[] {\n\treturn canonicalPublicSourceRefs(sourceRefs);\n}\n\nexport function sanitizeGraphVisibleRecord<T extends Record<string, unknown> | undefined>(\n\tvalue: T,\n\tpolicy?: ToolProviderPublicTextPolicy,\n): T | undefined {\n\treturn sanitizePublicRecord(value, { mode: \"graph\", policy });\n}\n\nexport function sanitizeProviderGraphVisibleRecord<T extends Record<string, unknown> | undefined>(\n\tvalue: T,\n\tpolicy?: ToolProviderPublicTextPolicy,\n): T | undefined {\n\treturn sanitizePublicRecord(value, { mode: \"provider\", policy });\n}\n\nexport function canonicalPublicSourceRefs(sourceRefs: readonly SourceRef[]): readonly SourceRef[] {\n\treturn uniqueSourceRefs(\n\t\tsourceRefs.map((sourceRef) => {\n\t\t\tconst metadata = sanitizePublicRecord(sourceRef.metadata, { mode: \"provider\" });\n\t\t\treturn metadata === undefined\n\t\t\t\t? { kind: sourceRef.kind, id: sourceRef.id }\n\t\t\t\t: { kind: sourceRef.kind, id: sourceRef.id, metadata };\n\t\t}),\n\t);\n}\n\nexport function sanitizePublicRecord<T extends Record<string, unknown> | undefined>(\n\tvalue: T,\n\topts: {\n\t\treadonly mode: PublicMaterialMode;\n\t\treadonly policy?: ToolProviderPublicTextPolicy;\n\t},\n): T | undefined {\n\tif (value === undefined || publicMaterialForbiddenKeys(value, opts.mode).length > 0) {\n\t\treturn undefined;\n\t}\n\treturn Object.freeze(boundRecordStrings(value, maxPublicMetadataStringChars(opts.policy))) as T;\n}\n\nexport function publicMaterialForbiddenKeys(\n\tvalue: unknown,\n\tmode: PublicMaterialMode,\n): readonly { readonly path: readonly (string | number)[]; readonly reason: string }[] {\n\tconst forbidden = [...forbiddenDataKeys(value)];\n\tif (mode === \"provider\") forbidden.push(...forbiddenProviderRawMaterialKeys(value));\n\treturn forbidden;\n}\n\nexport function unlockedToolProviderPolicyOverrides(\n\toverrides:\n\t\t| Partial<Omit<ToolProviderExecutionPolicy, \"kind\" | \"policyId\" | \"providerId\">>\n\t\t| undefined,\n): Partial<Omit<ToolProviderExecutionPolicy, \"kind\" | \"policyId\" | \"providerId\">> | undefined {\n\tif (overrides === undefined) return undefined;\n\tconst rest = { ...(overrides as Record<string, unknown>) };\n\tdelete rest.kind;\n\tdelete rest.policyId;\n\tdelete rest.providerId;\n\treturn rest as Partial<Omit<ToolProviderExecutionPolicy, \"kind\" | \"policyId\" | \"providerId\">>;\n}\n\nexport function sanitizeAgentOutputEnvelope<T>(\n\tenvelope: AgentOutputEnvelope<T>,\n\tinput: ToolProviderAdapterInput,\n\tpolicy: ToolProviderPublicTextPolicy | undefined,\n\tissues: DataIssue[],\n): AgentOutputEnvelope<T> {\n\tconst summary =\n\t\tenvelope.summary === undefined\n\t\t\t? undefined\n\t\t\t: boundedPublicText(envelope.summary, \"summary\", input, policy, issues);\n\tconst metadata = sanitizeRuntimeMetadata(envelope.metadata, input, policy, issues);\n\tif (metadata === undefined && envelope.metadata !== undefined) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-runtime-metadata-redacted\",\n\t\t\t\t\"Tool provider adapter runtime metadata was omitted because it contained runtime-private material.\",\n\t\t\t\t{\n\t\t\t\t\tsubjectId: input.requestId,\n\t\t\t\t\trefs: [ref(\"tool-provider-adapter-input\", input.adapterInputId)],\n\t\t\t\t\tseverity: \"warning\",\n\t\t\t\t},\n\t\t\t),\n\t\t);\n\t}\n\tconst value = sanitizeInlineOutputValue(envelope.value, input, policy, issues);\n\treturn Object.freeze({\n\t\tkind: envelope.kind,\n\t\tvalue: value as T | undefined,\n\t\trefs: envelope.refs === undefined ? undefined : sanitizeAdapterInputSourceRefs(envelope.refs),\n\t\tsummary,\n\t\tartifacts:\n\t\t\tenvelope.artifacts === undefined\n\t\t\t\t? undefined\n\t\t\t\t: Object.freeze(\n\t\t\t\t\t\tenvelope.artifacts.map((artifact) =>\n\t\t\t\t\t\t\tsanitizeExecutorArtifactMaterial(artifact, input, policy, issues),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\tmetadata,\n\t} satisfies AgentOutputEnvelope<T>);\n}\n\nexport function sanitizeExecutorArtifactMaterial(\n\tartifact: ExecutorArtifactMaterial,\n\tinput: ToolProviderAdapterInput,\n\tpolicy: ToolProviderPublicTextPolicy | undefined,\n\tissues: DataIssue[],\n): ExecutorArtifactMaterial {\n\tconst metadata = sanitizeRuntimeMetadata(artifact.metadata, input, policy, issues);\n\tconst redaction = sanitizeRuntimeMetadata(artifact.redaction, input, policy, issues);\n\treturn Object.freeze({\n\t\tkind: artifact.kind,\n\t\t...(artifact.format === undefined ? {} : { format: artifact.format }),\n\t\t...(artifact.schemaRef === undefined ? {} : { schemaRef: artifact.schemaRef }),\n\t\t...(artifact.schemaKind === undefined ? {} : { schemaKind: artifact.schemaKind }),\n\t\t...(artifact.mimeType === undefined ? {} : { mimeType: artifact.mimeType }),\n\t\t...(artifact.mediaType === undefined ? {} : { mediaType: artifact.mediaType }),\n\t\t...(artifact.filename === undefined ? {} : { filename: artifact.filename }),\n\t\t...(artifact.byteLength === undefined ? {} : { byteLength: artifact.byteLength }),\n\t\t...(artifact.digest === undefined ? {} : { digest: artifact.digest }),\n\t\t...(artifact.encoding === undefined ? {} : { encoding: artifact.encoding }),\n\t\tdataMode: artifact.dataMode,\n\t\t...(artifact.summary === undefined\n\t\t\t? {}\n\t\t\t: { summary: boundedPublicText(artifact.summary, \"summary\", input, policy, issues) }),\n\t\t...(artifact.value === undefined\n\t\t\t? {}\n\t\t\t: { value: sanitizeInlineOutputValue(artifact.value, input, policy, issues) }),\n\t\t...(artifact.ref === undefined\n\t\t\t? {}\n\t\t\t: { ref: sanitizeAdapterInputSourceRefs([artifact.ref])[0] }),\n\t\t...(artifact.refs === undefined ? {} : { refs: sanitizeAdapterInputSourceRefs(artifact.refs) }),\n\t\t...(artifact.sourceRefs === undefined\n\t\t\t? {}\n\t\t\t: { sourceRefs: sanitizeAdapterInputSourceRefs(artifact.sourceRefs) }),\n\t\t...(artifact.sizeEvidence === undefined\n\t\t\t? {}\n\t\t\t: {\n\t\t\t\t\tsizeEvidence: Object.freeze(\n\t\t\t\t\t\tartifact.sizeEvidence.map((evidence) =>\n\t\t\t\t\t\t\tsanitizeSizeCapacityEvidence(evidence, input, policy, issues),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t}),\n\t\t...(artifact.sensitivity === undefined\n\t\t\t? {}\n\t\t\t: { sensitivity: Object.freeze([...artifact.sensitivity]) }),\n\t\t...(redaction === undefined ? {} : { redaction }),\n\t\t...(metadata === undefined ? {} : { metadata }),\n\t} satisfies ExecutorArtifactMaterial);\n}\n\nfunction sanitizeSizeCapacityEvidence(\n\tevidence: SizeCapacityEvidence,\n\tinput: ToolProviderAdapterInput,\n\tpolicy: ToolProviderPublicTextPolicy | undefined,\n\tissues: DataIssue[],\n): SizeCapacityEvidence {\n\tconst metadata = sanitizeRuntimeMetadata(evidence.metadata, input, policy, issues);\n\tconst redaction = sanitizeRuntimeMetadata(evidence.redaction, input, policy, issues);\n\treturn Object.freeze({\n\t\tkind: \"size-capacity-evidence\",\n\t\tunit: evidence.unit,\n\t\tquantity: evidence.quantity,\n\t\tmeasurementSource: evidence.measurementSource,\n\t\t...(evidence.estimated === undefined ? {} : { estimated: evidence.estimated }),\n\t\t...(evidence.encoding === undefined ? {} : { encoding: evidence.encoding }),\n\t\t...(evidence.mediaType === undefined ? {} : { mediaType: evidence.mediaType }),\n\t\t...(evidence.sourceRefs === undefined\n\t\t\t? {}\n\t\t\t: { sourceRefs: sanitizeAdapterInputSourceRefs(evidence.sourceRefs) }),\n\t\t...(evidence.refs === undefined ? {} : { refs: sanitizeAdapterInputSourceRefs(evidence.refs) }),\n\t\t...(evidence.issues === undefined\n\t\t\t? {}\n\t\t\t: {\n\t\t\t\t\tissues: Object.freeze(evidence.issues.map((issue) => sanitizeAdapterInputIssue(issue))),\n\t\t\t\t}),\n\t\t...(evidence.sensitivity === undefined\n\t\t\t? {}\n\t\t\t: { sensitivity: Object.freeze([...evidence.sensitivity]) }),\n\t\t...(redaction === undefined ? {} : { redaction }),\n\t\t...(metadata === undefined ? {} : { metadata }),\n\t} satisfies SizeCapacityEvidence);\n}\n\nexport function sanitizeAgentNeed(\n\tneed: AgentNeed,\n\tinput: ToolProviderAdapterInput,\n\tpolicy: ToolProviderPublicTextPolicy | undefined,\n\tissues: DataIssue[],\n): AgentNeed {\n\tconst metadata = sanitizeRuntimeMetadata(need.metadata, input, policy, issues);\n\tif (metadata === undefined && need.metadata !== undefined) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-runtime-metadata-redacted\",\n\t\t\t\t\"Tool provider adapter runtime metadata was omitted because it contained runtime-private material.\",\n\t\t\t\t{\n\t\t\t\t\tsubjectId: input.requestId,\n\t\t\t\t\trefs: [ref(\"tool-provider-adapter-input\", input.adapterInputId)],\n\t\t\t\t\tseverity: \"warning\",\n\t\t\t\t},\n\t\t\t),\n\t\t);\n\t}\n\treturn Object.freeze({\n\t\tkind: need.kind,\n\t\tmessage:\n\t\t\tneed.message === undefined\n\t\t\t\t? undefined\n\t\t\t\t: boundedPublicText(need.message, \"message\", input, policy, issues),\n\t\trefs: need.refs === undefined ? undefined : sanitizeAdapterInputSourceRefs(need.refs),\n\t\tmetadata,\n\t} satisfies AgentNeed);\n}\n\nexport function sanitizeRuntimeMetadata<T extends Record<string, unknown> | undefined>(\n\tvalue: T,\n\tinput: ToolProviderAdapterInput,\n\tpolicy: ToolProviderPublicTextPolicy | undefined,\n\tissues: DataIssue[],\n): T | undefined {\n\tif (value === undefined) return undefined;\n\tconst bounded = sanitizePublicRecordWithEvidence(value, { mode: \"provider\", policy });\n\tif (bounded === undefined) return undefined;\n\tfor (const entry of bounded.truncated) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-runtime-public-text-truncated\",\n\t\t\t\t\"Tool provider adapter runtime public text was truncated; large/raw material must use artifact summary/ref envelopes.\",\n\t\t\t\t{\n\t\t\t\t\tsubjectId: input.requestId,\n\t\t\t\t\trefs: [ref(\"tool-provider-adapter-input\", input.adapterInputId)],\n\t\t\t\t\tseverity: \"warning\",\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\tfield: \"metadata\",\n\t\t\t\t\t\tpath: entry.path.join(\".\"),\n\t\t\t\t\t\toriginalChars: entry.originalChars,\n\t\t\t\t\t\tlimitChars: entry.limitChars,\n\t\t\t\t\t\tunit: \"chars\",\n\t\t\t\t\t\tmeasurementSource: \"js-string-length\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t),\n\t\t);\n\t}\n\treturn Object.freeze(bounded.value) as T;\n}\n\nexport function sanitizePublicRecordWithEvidence(\n\tvalue: Record<string, unknown>,\n\topts: {\n\t\treadonly mode: PublicMaterialMode;\n\t\treadonly policy?: ToolProviderPublicTextPolicy;\n\t},\n):\n\t| {\n\t\t\treadonly value: Record<string, unknown>;\n\t\t\treadonly truncated: readonly {\n\t\t\t\treadonly path: readonly (string | number)[];\n\t\t\t\treadonly originalChars: number;\n\t\t\t\treadonly limitChars: number;\n\t\t\t}[];\n\t }\n\t| undefined {\n\tif (publicMaterialForbiddenKeys(value, opts.mode).length > 0) return undefined;\n\treturn boundRecordStringsWithEvidence(value, maxPublicMetadataStringChars(opts.policy));\n}\n\nexport function sanitizeInlineOutputValue(\n\tvalue: unknown,\n\tinput: ToolProviderAdapterInput,\n\tpolicy: ToolProviderPublicTextPolicy | undefined,\n\tissues: DataIssue[],\n): unknown {\n\tif (value === undefined) return undefined;\n\tconst forbidden = [\n\t\t...publicMaterialForbiddenKeys(value, \"provider\"),\n\t\t...oversizedInlineTextKeys(value, maxPublicSummaryChars(policy)),\n\t];\n\tif (forbidden.length === 0) return cloneGraphVisibleMaterial(value);\n\tfor (const entry of forbidden) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-runtime-forbidden-runtime-material\",\n\t\t\t\t\"Tool provider adapter runtime output value must not inline runtime-private, raw, or oversized provider material.\",\n\t\t\t\t{\n\t\t\t\t\tsubjectId: input.requestId,\n\t\t\t\t\trefs: [ref(\"tool-provider-adapter-input\", input.adapterInputId)],\n\t\t\t\t\tdetails: { reason: entry.reason },\n\t\t\t\t},\n\t\t\t),\n\t\t);\n\t}\n\treturn undefined;\n}\n\nexport function boundedPublicText(\n\ttext: string,\n\tfield: \"message\" | \"reason\" | \"summary\",\n\tinput: ToolProviderAdapterInput,\n\tpolicy: ToolProviderPublicTextPolicy | undefined,\n\tissues: DataIssue[],\n): string {\n\tconst limit =\n\t\tfield === \"summary\"\n\t\t\t? maxPublicSummaryChars(policy)\n\t\t\t: field === \"reason\"\n\t\t\t\t? maxPublicReasonChars(policy)\n\t\t\t\t: maxPublicMessageChars(policy);\n\tconst bounded = boundPublicText(text, limit);\n\tif (!bounded.truncated) return bounded.text;\n\tissues.push(\n\t\tdataIssue(\n\t\t\t\"tool-provider-adapter-runtime-public-text-truncated\",\n\t\t\t\"Tool provider adapter runtime public text was truncated; large/raw material must use artifact summary/ref envelopes.\",\n\t\t\t{\n\t\t\t\tsubjectId: input.requestId,\n\t\t\t\trefs: [ref(\"tool-provider-adapter-input\", input.adapterInputId)],\n\t\t\t\tseverity: \"warning\",\n\t\t\t\tdetails: {\n\t\t\t\t\tfield,\n\t\t\t\t\toriginalChars: bounded.originalChars,\n\t\t\t\t\tlimitChars: bounded.limitChars,\n\t\t\t\t\tunit: \"chars\",\n\t\t\t\t\tmeasurementSource: \"js-string-length\",\n\t\t\t\t},\n\t\t\t},\n\t\t),\n\t);\n\treturn bounded.text;\n}\n\nexport function boundPublicText(\n\ttext: string,\n\tlimitChars: number,\n): {\n\treadonly text: string;\n\treadonly truncated: boolean;\n\treadonly originalChars: number;\n\treadonly limitChars: number;\n} {\n\tconst limit = Math.max(0, limitChars);\n\tif (text.length <= limit) {\n\t\treturn { text, truncated: false, originalChars: text.length, limitChars: limit };\n\t}\n\tconst bounded =\n\t\tlimit <= 1\n\t\t\t? text.slice(0, limit)\n\t\t\t: limit <= 3\n\t\t\t\t? text.slice(0, limit)\n\t\t\t\t: `${text.slice(0, limit - 3)}...`;\n\treturn { text: bounded, truncated: true, originalChars: text.length, limitChars: limit };\n}\n\nexport function boundRecordStrings(\n\tvalue: Record<string, unknown>,\n\tlimitChars: number,\n\tseen: WeakSet<object> = new WeakSet(),\n): Record<string, unknown> {\n\tif (seen.has(value)) return {};\n\tseen.add(value);\n\treturn Object.entries(value).reduce<Record<string, unknown>>((out, [key, child]) => {\n\t\tif (typeof child === \"string\") {\n\t\t\tout[key] = boundPublicText(child, limitChars).text;\n\t\t} else if (Array.isArray(child)) {\n\t\t\tout[key] = child.map((item) =>\n\t\t\t\ttypeof item === \"string\"\n\t\t\t\t\t? boundPublicText(item, limitChars).text\n\t\t\t\t\t: isPlainRecord(item)\n\t\t\t\t\t\t? boundRecordStrings(item, limitChars, seen)\n\t\t\t\t\t\t: item,\n\t\t\t);\n\t\t} else if (isPlainRecord(child)) {\n\t\t\tout[key] = boundRecordStrings(child, limitChars, seen);\n\t\t} else {\n\t\t\tout[key] = child;\n\t\t}\n\t\treturn out;\n\t}, {});\n}\n\nexport function boundRecordStringsWithEvidence(\n\tvalue: Record<string, unknown>,\n\tlimitChars: number,\n\tpath: readonly (string | number)[] = [],\n\tseen: WeakSet<object> = new WeakSet(),\n): {\n\treadonly value: Record<string, unknown>;\n\treadonly truncated: readonly {\n\t\treadonly path: readonly (string | number)[];\n\t\treadonly originalChars: number;\n\t\treadonly limitChars: number;\n\t}[];\n} {\n\tif (seen.has(value)) return { value: {}, truncated: [] };\n\tseen.add(value);\n\tconst truncated: {\n\t\treadonly path: readonly (string | number)[];\n\t\treadonly originalChars: number;\n\t\treadonly limitChars: number;\n\t}[] = [];\n\tconst out = Object.entries(value).reduce<Record<string, unknown>>((record, [key, child]) => {\n\t\tconst childPath = [...path, key];\n\t\tif (typeof child === \"string\") {\n\t\t\tconst bounded = boundPublicText(child, limitChars);\n\t\t\trecord[key] = bounded.text;\n\t\t\tif (bounded.truncated) {\n\t\t\t\ttruncated.push({\n\t\t\t\t\tpath: childPath,\n\t\t\t\t\toriginalChars: bounded.originalChars,\n\t\t\t\t\tlimitChars: bounded.limitChars,\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (Array.isArray(child)) {\n\t\t\trecord[key] = child.map((item, index) => {\n\t\t\t\tconst itemPath = [...childPath, index];\n\t\t\t\tif (typeof item === \"string\") {\n\t\t\t\t\tconst bounded = boundPublicText(item, limitChars);\n\t\t\t\t\tif (bounded.truncated) {\n\t\t\t\t\t\ttruncated.push({\n\t\t\t\t\t\t\tpath: itemPath,\n\t\t\t\t\t\t\toriginalChars: bounded.originalChars,\n\t\t\t\t\t\t\tlimitChars: bounded.limitChars,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn bounded.text;\n\t\t\t\t}\n\t\t\t\tif (isPlainRecord(item)) {\n\t\t\t\t\tconst nested = boundRecordStringsWithEvidence(item, limitChars, itemPath, seen);\n\t\t\t\t\ttruncated.push(...nested.truncated);\n\t\t\t\t\treturn nested.value;\n\t\t\t\t}\n\t\t\t\treturn item;\n\t\t\t});\n\t\t} else if (isPlainRecord(child)) {\n\t\t\tconst nested = boundRecordStringsWithEvidence(child, limitChars, childPath, seen);\n\t\t\trecord[key] = nested.value;\n\t\t\ttruncated.push(...nested.truncated);\n\t\t} else {\n\t\t\trecord[key] = child;\n\t\t}\n\t\treturn record;\n\t}, {});\n\treturn { value: out, truncated };\n}\n\nexport function sanitizeIssueDetails(\n\tdetails: unknown,\n\tpolicy?: ToolProviderPublicTextPolicy,\n): unknown {\n\tif (details === undefined) return undefined;\n\tif (publicMaterialForbiddenKeys(details, \"provider\").length > 0) {\n\t\treturn { redacted: true, reason: \"forbidden-runtime-material\" };\n\t}\n\tconst bounded = boundUnknownStringsWithEvidence(details, maxPublicMetadataStringChars(policy));\n\tif (bounded.truncated.length === 0) return bounded.value;\n\tconst detailsTruncated = {\n\t\tdetailsTruncated: true,\n\t\tdetailsTruncatedPaths: bounded.truncated.map((entry) => entry.path.join(\".\")),\n\t\tmeasurementSource: \"js-string-length\",\n\t};\n\tif (isPlainRecord(bounded.value)) {\n\t\treturn Object.freeze({ ...bounded.value, ...detailsTruncated });\n\t}\n\treturn Object.freeze({ value: bounded.value, ...detailsTruncated });\n}\n\nexport function boundUnknownStringsWithEvidence(\n\tvalue: unknown,\n\tlimitChars: number,\n\tpath: readonly (string | number)[] = [],\n\tseen: WeakSet<object> = new WeakSet(),\n): {\n\treadonly value: unknown;\n\treadonly truncated: readonly {\n\t\treadonly path: readonly (string | number)[];\n\t\treadonly originalChars: number;\n\t\treadonly limitChars: number;\n\t}[];\n} {\n\tif (typeof value === \"string\") {\n\t\tconst bounded = boundPublicText(value, limitChars);\n\t\treturn {\n\t\t\tvalue: bounded.text,\n\t\t\ttruncated: bounded.truncated\n\t\t\t\t? [{ path, originalChars: bounded.originalChars, limitChars: bounded.limitChars }]\n\t\t\t\t: [],\n\t\t};\n\t}\n\tif (!isRecord(value) && !Array.isArray(value)) return { value, truncated: [] };\n\tif (typeof value === \"object\" && value !== null) {\n\t\tif (seen.has(value)) return { value: Array.isArray(value) ? [] : {}, truncated: [] };\n\t\tseen.add(value);\n\t}\n\tconst truncated: {\n\t\treadonly path: readonly (string | number)[];\n\t\treadonly originalChars: number;\n\t\treadonly limitChars: number;\n\t}[] = [];\n\tif (Array.isArray(value)) {\n\t\tconst out = value.map((item, index) => {\n\t\t\tconst bounded = boundUnknownStringsWithEvidence(item, limitChars, [...path, index], seen);\n\t\t\ttruncated.push(...bounded.truncated);\n\t\t\treturn bounded.value;\n\t\t});\n\t\treturn { value: out, truncated };\n\t}\n\tconst out = Object.entries(value).reduce<Record<string, unknown>>((record, [key, child]) => {\n\t\tconst bounded = boundUnknownStringsWithEvidence(child, limitChars, [...path, key], seen);\n\t\trecord[key] = bounded.value;\n\t\ttruncated.push(...bounded.truncated);\n\t\treturn record;\n\t}, {});\n\treturn { value: out, truncated };\n}\n\nexport function oversizedInlineTextKeys(\n\tvalue: unknown,\n\tlimitChars: number,\n\tpath: readonly (string | number)[] = [],\n\tseen: WeakSet<object> = new WeakSet(),\n): readonly { readonly path: readonly (string | number)[]; readonly reason: string }[] {\n\tif (typeof value === \"string\") {\n\t\treturn value.length > Math.max(0, limitChars)\n\t\t\t? [{ path, reason: \"oversized-inline-text\" }]\n\t\t\t: [];\n\t}\n\tif (!isRecord(value) && !Array.isArray(value)) return [];\n\tif (typeof value === \"object\" && value !== null) {\n\t\tif (seen.has(value)) return [];\n\t\tseen.add(value);\n\t}\n\tconst issues: { readonly path: readonly (string | number)[]; readonly reason: string }[] = [];\n\tif (Array.isArray(value)) {\n\t\tvalue.forEach((item, index) => {\n\t\t\tissues.push(...oversizedInlineTextKeys(item, limitChars, [...path, index], seen));\n\t\t});\n\t\treturn issues;\n\t}\n\tfor (const [key, child] of Object.entries(value)) {\n\t\tissues.push(...oversizedInlineTextKeys(child, limitChars, [...path, key], seen));\n\t}\n\treturn issues;\n}\n\nexport function maxPublicMessageChars(policy?: ToolProviderPublicTextPolicy): number {\n\treturn normalizedPublicTextLimit(policy?.maxMessageChars, 512);\n}\n\nexport function maxPublicSummaryChars(policy?: ToolProviderPublicTextPolicy): number {\n\treturn normalizedPublicTextLimit(policy?.maxSummaryChars, 512);\n}\n\nexport function maxPublicReasonChars(policy?: ToolProviderPublicTextPolicy): number {\n\treturn normalizedPublicTextLimit(policy?.maxReasonChars, 512);\n}\n\nexport function maxPublicMetadataStringChars(policy?: ToolProviderPublicTextPolicy): number {\n\treturn normalizedPublicTextLimit(policy?.maxMetadataStringChars, 256);\n}\n\nexport function normalizedPublicTextLimit(value: number | undefined, fallback: number): number {\n\tif (value === undefined || !Number.isFinite(value)) return fallback;\n\treturn Math.max(0, Math.floor(value));\n}\n\nexport function sanitizeAdapterInputIssue(\n\tissue: DataIssue,\n\tpolicy?: ToolProviderPublicTextPolicy,\n): DataIssue {\n\tconst boundedMessage = boundPublicText(issue.message, maxPublicMessageChars(policy));\n\tconst details = sanitizeIssueDetails(issue.details, policy);\n\tconst metadata = sanitizeProviderGraphVisibleRecord(issue.metadata, policy);\n\tconst refs =\n\t\tissue.refs === undefined\n\t\t\t? undefined\n\t\t\t: Object.freeze(issue.refs.filter((entry): entry is string => typeof entry === \"string\"));\n\treturn Object.freeze({\n\t\tkind: issue.kind,\n\t\tcode: issue.code,\n\t\t...(issue.source === undefined ? {} : { source: issue.source }),\n\t\tmessage: boundedMessage.text,\n\t\tseverity: issue.severity,\n\t\tsubjectId: issue.subjectId,\n\t\t...(issue.correlationId === undefined ? {} : { correlationId: issue.correlationId }),\n\t\t...(issue.causationId === undefined ? {} : { causationId: issue.causationId }),\n\t\t...(issue.path === undefined ? {} : { path: Object.freeze([...issue.path]) }),\n\t\t...(refs === undefined || refs.length === 0 ? {} : { refs }),\n\t\t...(issue.retryable === undefined ? {} : { retryable: issue.retryable }),\n\t\tdetails:\n\t\t\tboundedMessage.truncated || details !== issue.details\n\t\t\t\t? {\n\t\t\t\t\t\t...(isRecord(details) ? details : {}),\n\t\t\t\t\t\t...(boundedMessage.truncated\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\ttruncated: true,\n\t\t\t\t\t\t\t\t\toriginalChars: boundedMessage.originalChars,\n\t\t\t\t\t\t\t\t\tlimitChars: boundedMessage.limitChars,\n\t\t\t\t\t\t\t\t\tmeasurementSource: \"js-string-length\",\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t}\n\t\t\t\t: details,\n\t\t...(metadata === undefined ? {} : { metadata }),\n\t} satisfies DataIssue);\n}\n\nexport function forbiddenProviderRawMaterialKeys(\n\tvalue: unknown,\n\tpath: readonly (string | number)[] = [],\n\tseen: WeakSet<object> = new WeakSet(),\n): readonly { readonly path: readonly (string | number)[]; readonly reason: string }[] {\n\tif (!isRecord(value) && !Array.isArray(value)) return [];\n\tif (typeof value === \"object\" && value !== null) {\n\t\tif (seen.has(value)) return [];\n\t\tseen.add(value);\n\t}\n\tconst issues: { readonly path: readonly (string | number)[]; readonly reason: string }[] = [];\n\tif (Array.isArray(value)) {\n\t\tvalue.forEach((item, index) => {\n\t\t\tissues.push(...forbiddenProviderRawMaterialKeys(item, [...path, index], seen));\n\t\t});\n\t\treturn issues;\n\t}\n\tfor (const [key, child] of Object.entries(value)) {\n\t\tconst nextPath = [...path, key];\n\t\tif (\n\t\t\t/^(stdout|stderr|stack|stackTrace|stack_trace|providerRaw|provider_raw|rawResponse|raw_response|diff|patch|fileContents|file_contents|binary|media)$/i.test(\n\t\t\t\tkey,\n\t\t\t)\n\t\t) {\n\t\t\tissues.push({ path: nextPath, reason: \"raw-provider-material\" });\n\t\t}\n\t\tissues.push(...forbiddenProviderRawMaterialKeys(child, nextPath, seen));\n\t}\n\treturn issues;\n}\n\nexport function dataIssue(\n\tcode: string,\n\tmessage: string,\n\topts: {\n\t\treadonly subjectId?: string;\n\t\treadonly refs?: readonly SourceRef[];\n\t\treadonly severity?: DataIssue[\"severity\"];\n\t\treadonly details?: unknown;\n\t} = {},\n): DataIssue {\n\treturn {\n\t\tkind: \"issue\",\n\t\tcode,\n\t\tmessage,\n\t\tseverity: opts.severity ?? \"error\",\n\t\tsubjectId: opts.subjectId,\n\t\trefs: opts.refs?.map((r) => `${r.kind}:${r.id}`),\n\t\tdetails: opts.details,\n\t};\n}\n\nexport function ref(kind: string, id: string): SourceRef {\n\treturn { kind, id };\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nexport function isPlainRecord(value: unknown): value is Record<string, unknown> {\n\tif (!isRecord(value)) return false;\n\tconst proto = Object.getPrototypeOf(value);\n\treturn proto === Object.prototype || proto === null;\n}\n","import { type Ctx, depBatch } from \"../ctx/types.js\";\nimport type { DataIssue } from \"../data/index.js\";\nimport type { Graph } from \"../graph/graph.js\";\nimport type { Node } from \"../node/node.js\";\nimport type { ToolProviderAdapterRunProjectorPrivateRetentionHooks } from \"./agent-runtime-adapter-retention.js\";\nimport {\n\tboundPublicText,\n\tdataIssue,\n\tforbiddenDataKeys,\n\tforbiddenProviderRawMaterialKeys,\n\tforEachDepBatch,\n\tisRecord,\n\tmaxPublicReasonChars,\n\tprojectRuntimeFact,\n\tref,\n\tsanitizeAdapterInputIssue,\n\tsanitizeAdapterInputSourceRefs,\n\tsanitizeProviderGraphVisibleRecord,\n\tstableJsonStringify,\n\tstableStringHash,\n} from \"./agent-runtime-common.js\";\nimport type { AgentRuntimeAuditRecord } from \"./agent-runtime-types-agent.js\";\nimport type { SourceRef } from \"./agent-runtime-types-core.js\";\nimport type {\n\tToolProviderAdapterBinding,\n\tToolProviderAdapterInput,\n\tToolProviderAdapterRunBundle,\n\tToolProviderAdapterRunReason,\n\tToolProviderAdapterRunRequested,\n\tToolProviderAdapterRunStatus,\n\tToolProviderPublicTextPolicy,\n} from \"./agent-runtime-types-tool.js\";\n\nexport function normalizeToolProviderAdapterBindings<TArguments, TResult>(\n\tbindings:\n\t\t| readonly ToolProviderAdapterBinding<TArguments, TResult>[]\n\t\t| ReadonlyMap<string, ToolProviderAdapterBinding<TArguments, TResult>>,\n): ReadonlyMap<string, ToolProviderAdapterBinding<TArguments, TResult>> {\n\tconst result = new Map<string, ToolProviderAdapterBinding<TArguments, TResult>>();\n\tconst bindingList = Array.isArray(bindings)\n\t\t? (bindings as readonly ToolProviderAdapterBinding<TArguments, TResult>[])\n\t\t: undefined;\n\tif (bindingList === undefined) {\n\t\tconst bindingMap = bindings as ReadonlyMap<\n\t\t\tstring,\n\t\t\tToolProviderAdapterBinding<TArguments, TResult>\n\t\t>;\n\t\tfor (const [providerId, binding] of bindingMap.entries()) {\n\t\t\tif (providerId !== binding.providerId) {\n\t\t\t\tthrow new RangeError(\n\t\t\t\t\t`attachToolProviderAdapterRuntime: binding key '${providerId}' must match provider '${binding.providerId}'`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tresult.set(providerId, binding);\n\t\t}\n\t\treturn result;\n\t}\n\tfor (const binding of bindingList) {\n\t\tif (result.has(binding.providerId)) {\n\t\t\tthrow new RangeError(\n\t\t\t\t`attachToolProviderAdapterRuntime: duplicate binding for provider '${binding.providerId}'`,\n\t\t\t);\n\t\t}\n\t\tresult.set(binding.providerId, binding);\n\t}\n\treturn result;\n}\n\nexport function requestToolProviderAdapterRun(\n\tinput: ToolProviderAdapterInput,\n\topts: {\n\t\treadonly runId?: string;\n\t\treadonly attempt?: number;\n\t\treadonly reason?: ToolProviderAdapterRunReason;\n\t\treadonly retryOfOutcomeId?: string;\n\t\treadonly policyRefs?: readonly SourceRef[];\n\t\treadonly sourceRefs?: readonly SourceRef[];\n\t\treadonly metadata?: Record<string, unknown>;\n\t\treadonly requestedAtMs?: number;\n\t} = {},\n): ToolProviderAdapterRunRequested {\n\tconst attempt = opts.attempt ?? 1;\n\treturn Object.freeze({\n\t\tkind: \"tool-provider-adapter-run-requested\",\n\t\trunId: opts.runId ?? defaultToolProviderAdapterRunId(input.adapterInputId, attempt, input),\n\t\tadapterInputId: input.adapterInputId,\n\t\trequestId: input.requestId,\n\t\toperationId: input.operationId,\n\t\trouteId: input.routeId,\n\t\tproviderId: input.providerId,\n\t\texecutorId: input.executorId,\n\t\tprofileId: input.profileId,\n\t\tattempt,\n\t\treason: sanitizeToolProviderAdapterRunReason(opts.reason, attempt),\n\t\tretryOfOutcomeId: opts.retryOfOutcomeId,\n\t\tpolicyRefs: sanitizeAdapterInputSourceRefs(opts.policyRefs ?? input.policyRefs ?? []),\n\t\tsourceRefs: sanitizeAdapterInputSourceRefs([\n\t\t\tref(\"tool-provider-adapter-input\", input.adapterInputId),\n\t\t\t...(input.sourceRefs ?? []),\n\t\t\t...(opts.sourceRefs ?? []),\n\t\t]),\n\t\tmetadata: sanitizeProviderGraphVisibleRecord(opts.metadata),\n\t\trequestedAtMs: opts.requestedAtMs,\n\t} satisfies ToolProviderAdapterRunRequested);\n}\n\nexport function toolProviderAdapterRunProjector(\n\tgraph: Graph,\n\topts: {\n\t\treadonly name?: string;\n\t\treadonly inputs: Node<ToolProviderAdapterInput>;\n\t\treadonly runRequests?: readonly Node<ToolProviderAdapterRunRequested>[];\n\t\treadonly autoRunReadyInputs?: boolean;\n\t\treadonly now?: () => number;\n\t},\n): ToolProviderAdapterRunBundle {\n\treturn toolProviderAdapterRunProjectorInternal(graph, opts);\n}\n\nexport function toolProviderAdapterRunProjectorInternal(\n\tgraph: Graph,\n\topts: {\n\t\treadonly name?: string;\n\t\treadonly inputs: Node<ToolProviderAdapterInput>;\n\t\treadonly runRequests?: readonly Node<ToolProviderAdapterRunRequested>[];\n\t\treadonly autoRunReadyInputs?: boolean;\n\t\treadonly now?: () => number;\n\t\treadonly publicText?: ToolProviderPublicTextPolicy;\n\t\treadonly privateRetentionHooks?: ToolProviderAdapterRunProjectorPrivateRetentionHooks;\n\t},\n): ToolProviderAdapterRunBundle {\n\tconst name = opts.name ?? \"toolProviderAdapterRun\";\n\tconst explicitRunDeps = opts.runRequests ?? [];\n\tconst autoRunReadyInputs = opts.autoRunReadyInputs ?? true;\n\tconst runtime = graph.node<ToolProviderAdapterRunFact>(\n\t\t[opts.inputs, ...explicitRunDeps],\n\t\t(ctx) => {\n\t\t\tconst state = ctx.state.get<ToolProviderAdapterRunProjectorState>() ?? {\n\t\t\t\tinputs: new Map<string, ToolProviderAdapterInput>(),\n\t\t\t\temittedKeys: new Set<string>(),\n\t\t\t\tstatusKeys: new Set<string>(),\n\t\t\t\tissueKeys: new Set<string>(),\n\t\t\t\tauditSeq: 0,\n\t\t\t};\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst input = raw as ToolProviderAdapterInput;\n\t\t\t\tstate.inputs.set(input.adapterInputId, input);\n\t\t\t\topts.privateRetentionHooks?.onAdapterInputKey?.({\n\t\t\t\t\tadapterInputId: input.adapterInputId,\n\t\t\t\t\tdropInput: () => {\n\t\t\t\t\t\tstate.inputs.delete(input.adapterInputId);\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tif (input.status !== \"ready\") continue;\n\t\t\t\tif (autoRunReadyInputs) {\n\t\t\t\t\temitRunRequested(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\trequestToolProviderAdapterRun(input, {\n\t\t\t\t\t\t\trequestedAtMs: opts.now?.(),\n\t\t\t\t\t\t}),\n\t\t\t\t\t\topts.privateRetentionHooks,\n\t\t\t\t\t);\n\t\t\t\t} else if (explicitRunDeps.length === 0) {\n\t\t\t\t\temitRunIssue(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\"tool-provider-adapter-run-request-missing\",\n\t\t\t\t\t\t\"Ready tool provider adapter input has no visible run request.\",\n\t\t\t\t\t\tinput.adapterInputId,\n\t\t\t\t\t\t[ref(\"tool-provider-adapter-input\", input.adapterInputId)],\n\t\t\t\t\t\topts.privateRetentionHooks,\n\t\t\t\t\t);\n\t\t\t\t\temitRunStatus(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkind: \"tool-provider-adapter-run-status\",\n\t\t\t\t\t\t\trunId: defaultToolProviderAdapterRunId(input.adapterInputId, 1, input),\n\t\t\t\t\t\t\tadapterInputId: input.adapterInputId,\n\t\t\t\t\t\t\trequestId: input.requestId,\n\t\t\t\t\t\t\toperationId: input.operationId,\n\t\t\t\t\t\t\tstatus: \"missing-request\",\n\t\t\t\t\t\t\tattempt: 1,\n\t\t\t\t\t\t\tsourceRefs: [ref(\"tool-provider-adapter-input\", input.adapterInputId)],\n\t\t\t\t\t\t},\n\t\t\t\t\t\topts.privateRetentionHooks,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tforEachDepBatch(ctx, 1, explicitRunDeps.length, (raw) => {\n\t\t\t\tif (!isToolProviderAdapterRunRequestedLike(raw)) {\n\t\t\t\t\tconst request = fallbackToolProviderAdapterRunRequest(raw, opts.publicText);\n\t\t\t\t\tconst issue = dataIssue(\n\t\t\t\t\t\t\"tool-provider-adapter-run-request-invalid-shape\",\n\t\t\t\t\t\t\"Tool provider adapter run request must be a data object with runId, adapterInputId, requestId, operationId, and attempt.\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsubjectId: request.adapterInputId,\n\t\t\t\t\t\t\trefs: [ref(\"tool-provider-adapter-run\", request.runId)],\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\temitRunIssueFact(ctx, state, issue, opts.privateRetentionHooks);\n\t\t\t\t\temitRunStatus(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkind: \"tool-provider-adapter-run-status\",\n\t\t\t\t\t\t\trunId: request.runId,\n\t\t\t\t\t\t\tadapterInputId: request.adapterInputId,\n\t\t\t\t\t\t\trequestId: request.requestId,\n\t\t\t\t\t\t\toperationId: request.operationId,\n\t\t\t\t\t\t\tstatus: \"mismatched-request\",\n\t\t\t\t\t\t\tattempt: request.attempt,\n\t\t\t\t\t\t\tissues: [issue],\n\t\t\t\t\t\t\tsourceRefs: request.sourceRefs,\n\t\t\t\t\t\t},\n\t\t\t\t\t\topts.privateRetentionHooks,\n\t\t\t\t\t);\n\t\t\t\t\temitRunAudit(ctx, state, \"tool-provider-adapter-run-request-invalid-shape\", request, {\n\t\t\t\t\t\tissueCode: issue.code,\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst request = raw;\n\t\t\t\tconst input = state.inputs.get(request.adapterInputId);\n\t\t\t\tif (input === undefined) {\n\t\t\t\t\tconst replayClassification =\n\t\t\t\t\t\topts.privateRetentionHooks?.classifyRetainedRunRequestReplayEvidence?.(request);\n\t\t\t\t\tif (replayClassification?.kind === \"retention-gap\") {\n\t\t\t\t\t\temitRunRequested(\n\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tsanitizeRetainedToolProviderAdapterRunRequest(request, opts.publicText),\n\t\t\t\t\t\t\topts.privateRetentionHooks,\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst issue = dataIssue(\n\t\t\t\t\t\t\"tool-provider-adapter-run-request-missing-input\",\n\t\t\t\t\t\t\"Tool provider adapter run request references an unknown adapter input.\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsubjectId: request.adapterInputId,\n\t\t\t\t\t\t\trefs: sanitizeAdapterInputSourceRefs([\n\t\t\t\t\t\t\t\tref(\"tool-provider-adapter-run\", request.runId),\n\t\t\t\t\t\t\t\t...(request.sourceRefs ?? []),\n\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\temitRunIssueFact(ctx, state, issue, opts.privateRetentionHooks);\n\t\t\t\t\temitRunStatus(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkind: \"tool-provider-adapter-run-status\",\n\t\t\t\t\t\t\trunId: request.runId,\n\t\t\t\t\t\t\tadapterInputId: request.adapterInputId,\n\t\t\t\t\t\t\trequestId: request.requestId,\n\t\t\t\t\t\t\toperationId: request.operationId,\n\t\t\t\t\t\t\tstatus: \"missing-input\",\n\t\t\t\t\t\t\tattempt: request.attempt,\n\t\t\t\t\t\t\tissues: [issue],\n\t\t\t\t\t\t\tsourceRefs: sanitizeAdapterInputSourceRefs(request.sourceRefs ?? []),\n\t\t\t\t\t\t},\n\t\t\t\t\t\topts.privateRetentionHooks,\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst issues = runRequestIdentityIssues(request, input);\n\t\t\t\tif (input.status !== \"ready\") {\n\t\t\t\t\tissues.push(\n\t\t\t\t\t\tdataIssue(\n\t\t\t\t\t\t\t\"tool-provider-adapter-run-request-input-not-ready\",\n\t\t\t\t\t\t\t\"Tool provider adapter run request requires a ready adapter input.\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tsubjectId: input.requestId,\n\t\t\t\t\t\t\t\trefs: [ref(\"tool-provider-adapter-input\", input.adapterInputId)],\n\t\t\t\t\t\t\t\tdetails: { status: input.status },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (issues.length > 0) {\n\t\t\t\t\tfor (const issue of issues)\n\t\t\t\t\t\temitRunIssueFact(ctx, state, issue, opts.privateRetentionHooks);\n\t\t\t\t\temitRunStatus(\n\t\t\t\t\t\tctx,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkind: \"tool-provider-adapter-run-status\",\n\t\t\t\t\t\t\trunId: request.runId,\n\t\t\t\t\t\t\tadapterInputId: request.adapterInputId,\n\t\t\t\t\t\t\trequestId: request.requestId,\n\t\t\t\t\t\t\toperationId: request.operationId,\n\t\t\t\t\t\t\tstatus: \"mismatched-request\",\n\t\t\t\t\t\t\tattempt: request.attempt,\n\t\t\t\t\t\t\tissues: Object.freeze(issues),\n\t\t\t\t\t\t\tsourceRefs: sanitizeAdapterInputSourceRefs(request.sourceRefs ?? []),\n\t\t\t\t\t\t},\n\t\t\t\t\t\topts.privateRetentionHooks,\n\t\t\t\t\t);\n\t\t\t\t\temitRunAudit(ctx, state, \"tool-provider-adapter-run-request-rejected\", request, {\n\t\t\t\t\t\tissueCodes: issues.map((issue) => issue.code),\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\temitRunRequested(\n\t\t\t\t\tctx,\n\t\t\t\t\tstate,\n\t\t\t\t\tsanitizeToolProviderAdapterRunRequest(request, input, opts.publicText),\n\t\t\t\t\topts.privateRetentionHooks,\n\t\t\t\t);\n\t\t\t});\n\t\t\tctx.state.set(state);\n\t\t},\n\t\t{ name: `${name}/runtime`, factory: \"toolProviderAdapterRunProjector\", partial: true },\n\t);\n\treturn {\n\t\trequests: projectRuntimeFact(\n\t\t\tgraph,\n\t\t\truntime,\n\t\t\t`${name}/requests`,\n\t\t\t\"toolProviderAdapterRunRequests\",\n\t\t\t(fact) => (fact.kind === \"request\" ? fact.request : undefined),\n\t\t),\n\t\tstatus: projectRuntimeFact(\n\t\t\tgraph,\n\t\t\truntime,\n\t\t\t`${name}/status`,\n\t\t\t\"toolProviderAdapterRunStatus\",\n\t\t\t(fact) => (fact.kind === \"status\" ? fact.status : undefined),\n\t\t),\n\t\tissues: projectRuntimeFact(\n\t\t\tgraph,\n\t\t\truntime,\n\t\t\t`${name}/issues`,\n\t\t\t\"toolProviderAdapterRunIssues\",\n\t\t\t(fact) => (fact.kind === \"issue\" ? fact.issue : undefined),\n\t\t),\n\t\taudit: projectRuntimeFact(\n\t\t\tgraph,\n\t\t\truntime,\n\t\t\t`${name}/audit`,\n\t\t\t\"toolProviderAdapterRunAudit\",\n\t\t\t(fact) => (fact.kind === \"audit\" ? fact.audit : undefined),\n\t\t),\n\t};\n}\n\nexport type ToolProviderAdapterRunFact =\n\t| { readonly kind: \"request\"; readonly request: ToolProviderAdapterRunRequested }\n\t| { readonly kind: \"status\"; readonly status: ToolProviderAdapterRunStatus }\n\t| { readonly kind: \"issue\"; readonly issue: DataIssue }\n\t| { readonly kind: \"audit\"; readonly audit: AgentRuntimeAuditRecord };\n\nexport interface ToolProviderAdapterRunProjectorState {\n\tinputs: Map<string, ToolProviderAdapterInput>;\n\temittedKeys: Set<string>;\n\tstatusKeys: Set<string>;\n\tissueKeys: Set<string>;\n\tauditSeq: number;\n}\n\nexport function defaultToolProviderAdapterRunId(\n\tadapterInputId: string,\n\tattempt: number,\n\tinput?: ToolProviderAdapterInput,\n): string {\n\tconst suffix = input === undefined ? \"\" : `:${stableStringHash(stableJsonStringify(input))}`;\n\treturn `${adapterInputId}:run-${attempt}${suffix}`;\n}\n\nexport function sanitizeToolProviderAdapterRunReason(\n\treason: ToolProviderAdapterRunReason | undefined,\n\tattempt: number,\n\tpolicy?: ToolProviderPublicTextPolicy,\n): ToolProviderAdapterRunReason {\n\tconst value = reason ?? (attempt === 1 ? \"initial\" : \"retry\");\n\treturn boundPublicText(value, maxPublicReasonChars(policy)).text as ToolProviderAdapterRunReason;\n}\n\nexport function sanitizeToolProviderAdapterRunRequest(\n\trequest: ToolProviderAdapterRunRequested,\n\tinput: ToolProviderAdapterInput,\n\tpolicy?: ToolProviderPublicTextPolicy,\n): ToolProviderAdapterRunRequested {\n\treturn Object.freeze({\n\t\t...request,\n\t\treason: sanitizeToolProviderAdapterRunReason(request.reason, request.attempt, policy),\n\t\tpolicyRefs: sanitizeAdapterInputSourceRefs(request.policyRefs ?? input.policyRefs ?? []),\n\t\tsourceRefs: sanitizeAdapterInputSourceRefs([\n\t\t\tref(\"tool-provider-adapter-input\", input.adapterInputId),\n\t\t\t...(input.sourceRefs ?? []),\n\t\t\t...(request.sourceRefs ?? []),\n\t\t]),\n\t\tmetadata: sanitizeProviderGraphVisibleRecord(request.metadata),\n\t} satisfies ToolProviderAdapterRunRequested);\n}\n\nexport function sanitizeRetainedToolProviderAdapterRunRequest(\n\trequest: ToolProviderAdapterRunRequested,\n\tpolicy?: ToolProviderPublicTextPolicy,\n): ToolProviderAdapterRunRequested {\n\tconst policyRefs = sanitizeAdapterInputSourceRefs(request.policyRefs ?? []);\n\tconst sourceRefs = sanitizeAdapterInputSourceRefs(request.sourceRefs ?? []);\n\tconst metadata = sanitizeProviderGraphVisibleRecord(request.metadata);\n\treturn Object.freeze({\n\t\tkind: \"tool-provider-adapter-run-requested\",\n\t\trunId: request.runId,\n\t\tadapterInputId: request.adapterInputId,\n\t\trequestId: request.requestId,\n\t\toperationId: request.operationId,\n\t\t...(request.routeId === undefined ? {} : { routeId: request.routeId }),\n\t\t...(request.providerId === undefined ? {} : { providerId: request.providerId }),\n\t\t...(request.executorId === undefined ? {} : { executorId: request.executorId }),\n\t\t...(request.profileId === undefined ? {} : { profileId: request.profileId }),\n\t\tattempt: request.attempt,\n\t\treason: sanitizeToolProviderAdapterRunReason(request.reason, request.attempt, policy),\n\t\t...(request.retryOfOutcomeId === undefined\n\t\t\t? {}\n\t\t\t: { retryOfOutcomeId: request.retryOfOutcomeId }),\n\t\t...(policyRefs.length === 0 ? {} : { policyRefs }),\n\t\t...(sourceRefs.length === 0 ? {} : { sourceRefs }),\n\t\t...(metadata === undefined ? {} : { metadata }),\n\t\t...(request.requestedAtMs === undefined ? {} : { requestedAtMs: request.requestedAtMs }),\n\t} satisfies ToolProviderAdapterRunRequested);\n}\n\nexport function isToolProviderAdapterRunRequestedLike(\n\tvalue: unknown,\n): value is ToolProviderAdapterRunRequested {\n\tconst attempt = isRecord(value) ? value.attempt : undefined;\n\treturn (\n\t\tisRecord(value) &&\n\t\tvalue.kind === \"tool-provider-adapter-run-requested\" &&\n\t\ttypeof value.runId === \"string\" &&\n\t\tvalue.runId.length > 0 &&\n\t\ttypeof value.adapterInputId === \"string\" &&\n\t\tvalue.adapterInputId.length > 0 &&\n\t\ttypeof value.requestId === \"string\" &&\n\t\tvalue.requestId.length > 0 &&\n\t\ttypeof value.operationId === \"string\" &&\n\t\tvalue.operationId.length > 0 &&\n\t\ttypeof attempt === \"number\" &&\n\t\tNumber.isInteger(attempt) &&\n\t\tattempt > 0 &&\n\t\ttypeof value.reason === \"string\" &&\n\t\tvalue.reason.length > 0\n\t);\n}\n\nexport function fallbackToolProviderAdapterRunRequest(\n\traw: unknown,\n\tpolicy?: ToolProviderPublicTextPolicy,\n): ToolProviderAdapterRunRequested {\n\tconst record = isRecord(raw) ? raw : {};\n\tconst adapterInputId =\n\t\ttypeof record.adapterInputId === \"string\" && record.adapterInputId.length > 0\n\t\t\t? record.adapterInputId\n\t\t\t: \"<invalid-adapter-input>\";\n\tconst runId =\n\t\ttypeof record.runId === \"string\" && record.runId.length > 0\n\t\t\t? record.runId\n\t\t\t: `${adapterInputId}:invalid-run`;\n\tconst attempt =\n\t\ttypeof record.attempt === \"number\" && Number.isInteger(record.attempt) && record.attempt > 0\n\t\t\t? record.attempt\n\t\t\t: 1;\n\tconst metadata = isRecord(record.metadata)\n\t\t? sanitizeProviderGraphVisibleRecord(record.metadata, policy)\n\t\t: undefined;\n\treturn Object.freeze({\n\t\tkind: \"tool-provider-adapter-run-requested\",\n\t\trunId,\n\t\tadapterInputId,\n\t\trequestId:\n\t\t\ttypeof record.requestId === \"string\" && record.requestId.length > 0\n\t\t\t\t? record.requestId\n\t\t\t\t: \"<invalid-request>\",\n\t\toperationId:\n\t\t\ttypeof record.operationId === \"string\" && record.operationId.length > 0\n\t\t\t\t? record.operationId\n\t\t\t\t: \"<invalid-operation>\",\n\t\tattempt,\n\t\treason: sanitizeToolProviderAdapterRunReason(\n\t\t\ttypeof record.reason === \"string\" && record.reason.length > 0 ? record.reason : \"manual\",\n\t\t\tattempt,\n\t\t\tpolicy,\n\t\t),\n\t\tsourceRefs: sanitizeAdapterInputSourceRefs([\n\t\t\tref(\"tool-provider-adapter-run\", runId),\n\t\t\t...sanitizeUntrustedSourceRefs(record.sourceRefs),\n\t\t]),\n\t\t...(metadata === undefined ? {} : { metadata }),\n\t} satisfies ToolProviderAdapterRunRequested);\n}\n\nexport function sanitizeUntrustedSourceRefs(value: unknown): readonly SourceRef[] {\n\tif (!Array.isArray(value)) return [];\n\treturn Object.freeze(\n\t\tvalue\n\t\t\t.filter(\n\t\t\t\t(sourceRef): sourceRef is SourceRef =>\n\t\t\t\t\tisRecord(sourceRef) &&\n\t\t\t\t\ttypeof sourceRef.kind === \"string\" &&\n\t\t\t\t\tsourceRef.kind.length > 0 &&\n\t\t\t\t\ttypeof sourceRef.id === \"string\" &&\n\t\t\t\t\tsourceRef.id.length > 0,\n\t\t\t)\n\t\t\t.map((sourceRef) => ({\n\t\t\t\tkind: sourceRef.kind,\n\t\t\t\tid: sourceRef.id,\n\t\t\t\t...(isRecord(sourceRef.metadata) ? { metadata: sourceRef.metadata } : {}),\n\t\t\t})),\n\t);\n}\n\nexport function runRequestIdentityIssues(\n\trequest: ToolProviderAdapterRunRequested,\n\tinput: ToolProviderAdapterInput,\n): DataIssue[] {\n\tconst refs = sanitizeAdapterInputSourceRefs([\n\t\tref(\"tool-provider-adapter-run\", request.runId),\n\t\tref(\"tool-provider-adapter-input\", input.adapterInputId),\n\t\t...(request.sourceRefs ?? []),\n\t]);\n\tconst issues: DataIssue[] = [];\n\tif (request.kind !== \"tool-provider-adapter-run-requested\") {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-run-request-invalid-kind\",\n\t\t\t\t\"Tool provider adapter run request kind must be tool-provider-adapter-run-requested.\",\n\t\t\t\t{ subjectId: request.adapterInputId, refs },\n\t\t\t),\n\t\t);\n\t}\n\tif (request.runId.length === 0) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-run-request-missing-run-id\",\n\t\t\t\t\"Tool provider adapter run request requires runId.\",\n\t\t\t\t{\n\t\t\t\t\tsubjectId: request.adapterInputId,\n\t\t\t\t\trefs,\n\t\t\t\t},\n\t\t\t),\n\t\t);\n\t}\n\tif (!Number.isInteger(request.attempt) || request.attempt < 1) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-run-request-invalid-attempt\",\n\t\t\t\t\"Tool provider adapter run request attempt must be a positive integer.\",\n\t\t\t\t{ subjectId: request.adapterInputId, refs },\n\t\t\t),\n\t\t);\n\t}\n\tif (request.requestId !== input.requestId) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-run-request-stale-request\",\n\t\t\t\t\"Tool provider adapter run request requestId does not match the adapter input.\",\n\t\t\t\t{ subjectId: input.requestId, refs },\n\t\t\t),\n\t\t);\n\t}\n\tif (request.operationId !== input.operationId) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-run-request-stale-operation\",\n\t\t\t\t\"Tool provider adapter run request operationId does not match the adapter input.\",\n\t\t\t\t{ subjectId: input.requestId, refs },\n\t\t\t),\n\t\t);\n\t}\n\tif (request.routeId !== undefined && request.routeId !== input.routeId) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-run-request-stale-route\",\n\t\t\t\t\"Tool provider adapter run request routeId does not match the adapter input.\",\n\t\t\t\t{ subjectId: input.requestId, refs },\n\t\t\t),\n\t\t);\n\t}\n\tif (request.providerId !== undefined && request.providerId !== input.providerId) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-run-request-stale-provider\",\n\t\t\t\t\"Tool provider adapter run request providerId does not match the adapter input.\",\n\t\t\t\t{ subjectId: input.requestId, refs },\n\t\t\t),\n\t\t);\n\t}\n\tif (request.executorId !== undefined && request.executorId !== input.executorId) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-run-request-stale-executor\",\n\t\t\t\t\"Tool provider adapter run request executorId does not match the adapter input.\",\n\t\t\t\t{ subjectId: input.requestId, refs },\n\t\t\t),\n\t\t);\n\t}\n\tif (request.profileId !== undefined && request.profileId !== input.profileId) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-run-request-stale-profile\",\n\t\t\t\t\"Tool provider adapter run request profileId does not match the adapter input.\",\n\t\t\t\t{ subjectId: input.requestId, refs },\n\t\t\t),\n\t\t);\n\t}\n\tfor (const forbidden of [\n\t\t...forbiddenDataKeys(request),\n\t\t...forbiddenProviderRawMaterialKeys(request),\n\t]) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-run-request-forbidden-runtime-material\",\n\t\t\t\t\"Tool provider adapter run request must not contain runtime-private adapter material.\",\n\t\t\t\t{ subjectId: input.requestId, refs, details: { reason: forbidden.reason } },\n\t\t\t),\n\t\t);\n\t}\n\treturn issues;\n}\n\nexport function emitRunRequested(\n\tctx: Ctx,\n\tstate: ToolProviderAdapterRunProjectorState,\n\trequest: ToolProviderAdapterRunRequested,\n\tprivateRetentionHooks?: ToolProviderAdapterRunProjectorPrivateRetentionHooks,\n): void {\n\tconst key = `${request.runId}:${request.adapterInputId}:${request.attempt}`;\n\tif (state.emittedKeys.has(key)) return;\n\tstate.emittedKeys.add(key);\n\tctx.down([[\"DATA\", { kind: \"request\", request } satisfies ToolProviderAdapterRunFact]]);\n\tprivateRetentionHooks?.onRunRequestKey?.({\n\t\tkey,\n\t\trequest,\n\t\tdropKey: () => state.emittedKeys.delete(key),\n\t});\n\temitRunStatus(\n\t\tctx,\n\t\tstate,\n\t\t{\n\t\t\tkind: \"tool-provider-adapter-run-status\",\n\t\t\trunId: request.runId,\n\t\t\tadapterInputId: request.adapterInputId,\n\t\t\trequestId: request.requestId,\n\t\t\toperationId: request.operationId,\n\t\t\tstatus: \"requested\",\n\t\t\tattempt: request.attempt,\n\t\t\tsourceRefs: request.sourceRefs,\n\t\t},\n\t\tprivateRetentionHooks,\n\t);\n\temitRunAudit(ctx, state, \"tool-provider-adapter-run-requested\", request, {\n\t\treason: request.reason,\n\t\tattempt: request.attempt,\n\t});\n}\n\nexport function emitRunStatus(\n\tctx: Ctx,\n\tstate: ToolProviderAdapterRunProjectorState,\n\tstatus: ToolProviderAdapterRunStatus,\n\tprivateRetentionHooks?: ToolProviderAdapterRunProjectorPrivateRetentionHooks,\n): void {\n\tconst cleanSourceRefs =\n\t\tstatus.sourceRefs === undefined ? undefined : sanitizeAdapterInputSourceRefs(status.sourceRefs);\n\tconst cleanIssues =\n\t\tstatus.issues === undefined\n\t\t\t? undefined\n\t\t\t: Object.freeze(status.issues.map((issue) => sanitizeAdapterInputIssue(issue)));\n\tconst cleanMetadata = sanitizeProviderGraphVisibleRecord(status.metadata);\n\tconst cleanStatus = Object.freeze({\n\t\tkind: status.kind,\n\t\trunId: status.runId,\n\t\tadapterInputId: status.adapterInputId,\n\t\t...(status.requestId === undefined ? {} : { requestId: status.requestId }),\n\t\t...(status.operationId === undefined ? {} : { operationId: status.operationId }),\n\t\tstatus: status.status,\n\t\t...(status.attempt === undefined ? {} : { attempt: status.attempt }),\n\t\t...(status.outcomeId === undefined ? {} : { outcomeId: status.outcomeId }),\n\t\t...(cleanIssues === undefined || cleanIssues.length === 0 ? {} : { issues: cleanIssues }),\n\t\t...(cleanSourceRefs === undefined || cleanSourceRefs.length === 0\n\t\t\t? {}\n\t\t\t: { sourceRefs: cleanSourceRefs }),\n\t\t...(cleanMetadata === undefined ? {} : { metadata: cleanMetadata }),\n\t} satisfies ToolProviderAdapterRunStatus);\n\tconst key = stableJsonStringify({\n\t\trunId: cleanStatus.runId,\n\t\tadapterInputId: cleanStatus.adapterInputId,\n\t\trequestId: cleanStatus.requestId,\n\t\tattempt: cleanStatus.attempt,\n\t\tstatus: cleanStatus.status,\n\t\toutcomeId: cleanStatus.outcomeId,\n\t});\n\tif (state.statusKeys.has(key)) return;\n\tstate.statusKeys.add(key);\n\tctx.down([\n\t\t[\"DATA\", { kind: \"status\", status: cleanStatus } satisfies ToolProviderAdapterRunFact],\n\t]);\n\tprivateRetentionHooks?.onRunStatusKey?.({\n\t\tkey,\n\t\tstatus: cleanStatus,\n\t\tdropKey: () => state.statusKeys.delete(key),\n\t});\n}\n\nexport function emitRunIssue(\n\tctx: Ctx,\n\tstate: ToolProviderAdapterRunProjectorState,\n\tcode: string,\n\tmessage: string,\n\tsubjectId: string,\n\trefs?: readonly SourceRef[],\n\tprivateRetentionHooks?: ToolProviderAdapterRunProjectorPrivateRetentionHooks,\n): void {\n\temitRunIssueFact(\n\t\tctx,\n\t\tstate,\n\t\tdataIssue(code, message, { subjectId, refs }),\n\t\tprivateRetentionHooks,\n\t);\n}\n\nexport function emitRunIssueFact(\n\tctx: Ctx,\n\tstate: ToolProviderAdapterRunProjectorState,\n\tissue: DataIssue,\n\tprivateRetentionHooks?: ToolProviderAdapterRunProjectorPrivateRetentionHooks,\n): void {\n\tconst key = stableJsonStringify({\n\t\tcode: issue.code,\n\t\tsubjectId: issue.subjectId,\n\t\trefs: issue.refs ?? [],\n\t\tdetails: issue.details,\n\t});\n\tif (state.issueKeys.has(key)) return;\n\tstate.issueKeys.add(key);\n\tctx.down([[\"DATA\", { kind: \"issue\", issue } satisfies ToolProviderAdapterRunFact]]);\n\tprivateRetentionHooks?.onRunIssueKey?.({\n\t\tkey,\n\t\tissue,\n\t\tdropKey: () => state.issueKeys.delete(key),\n\t});\n}\n\nexport function emitRunAudit(\n\tctx: Ctx,\n\tstate: ToolProviderAdapterRunProjectorState,\n\tkind: string,\n\trequest: ToolProviderAdapterRunRequested,\n\tmetadata?: Record<string, unknown>,\n): void {\n\tstate.auditSeq += 1;\n\tctx.down([\n\t\t[\n\t\t\t\"DATA\",\n\t\t\t{\n\t\t\t\tkind: \"audit\",\n\t\t\t\taudit: {\n\t\t\t\t\tid: `${request.runId}:audit:${state.auditSeq}`,\n\t\t\t\t\tkind,\n\t\t\t\t\tsubjectId: request.requestId,\n\t\t\t\t\tsourceRefs: sanitizeAdapterInputSourceRefs(request.sourceRefs ?? []),\n\t\t\t\t\tmetadata: sanitizeProviderGraphVisibleRecord({\n\t\t\t\t\t\trunId: request.runId,\n\t\t\t\t\t\tadapterInputId: request.adapterInputId,\n\t\t\t\t\t\t...metadata,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t} satisfies ToolProviderAdapterRunFact,\n\t\t],\n\t]);\n}\n","import type { DataIssue } from \"../data/index.js\";\nimport {\n\tboundedPublicText,\n\tdataIssue,\n\tpublicMaterialForbiddenKeys,\n\tref,\n\tsanitizeAdapterInputIssue,\n\tsanitizeAdapterInputSourceRefs,\n\tsanitizeAgentNeed,\n\tsanitizeAgentOutputEnvelope,\n\tsanitizeGraphVisibleRecord,\n\tsanitizeRuntimeMetadata,\n} from \"./agent-runtime-common.js\";\nimport type { AgentRequestStatus, ExecutorOutcome, SourceRef } from \"./agent-runtime-types-core.js\";\nimport type {\n\tToolProviderAdapterInput,\n\tToolProviderAdapterRunResult,\n\tToolProviderPublicTextPolicy,\n} from \"./agent-runtime-types-tool.js\";\n\nexport function adapterRuntimeIdentity(input: ToolProviderAdapterInput): {\n\treadonly routeId: string;\n\treadonly executorId: string;\n\treadonly profileId: string;\n} {\n\tif (input.status !== \"ready\") {\n\t\tthrow new RangeError(\"buildToolProviderExecutorOutcome: adapter input must be ready\");\n\t}\n\tif (\n\t\tinput.routeId === undefined ||\n\t\tinput.executorId === undefined ||\n\t\tinput.profileId === undefined\n\t) {\n\t\tthrow new RangeError(\n\t\t\t\"buildToolProviderExecutorOutcome: ready adapter input is missing route/executor/profile identity\",\n\t\t);\n\t}\n\treturn {\n\t\trouteId: input.routeId,\n\t\texecutorId: input.executorId,\n\t\tprofileId: input.profileId,\n\t};\n}\n\nexport function defaultToolProviderAdapterEvidenceRefs(\n\tinput: ToolProviderAdapterInput,\n): readonly SourceRef[] {\n\treturn sanitizeAdapterInputSourceRefs([\n\t\tref(\"tool-provider-adapter-input\", input.adapterInputId),\n\t\t...(input.sourceRefs ?? []),\n\t]);\n}\n\nexport function buildToolProviderExecutorOutcome<T = unknown>(\n\tinput: ToolProviderAdapterInput,\n\tresult: ToolProviderAdapterRunResult<T>,\n\topts: {\n\t\treadonly attempt?: number;\n\t\treadonly outcomeId?: string;\n\t\treadonly occurredAtMs?: number;\n\t\treadonly runId?: string;\n\t\treadonly publicText?: ToolProviderPublicTextPolicy;\n\t} = {},\n): ExecutorOutcome<T> {\n\tconst ids = adapterRuntimeIdentity(input);\n\tconst attempt = opts.attempt ?? 1;\n\tconst occurredAtMs = result.occurredAtMs ?? opts.occurredAtMs;\n\tconst evidenceRefs =\n\t\tresult.evidenceRefs === undefined\n\t\t\t? defaultToolProviderAdapterEvidenceRefs(input)\n\t\t\t: sanitizeAdapterInputSourceRefs(result.evidenceRefs);\n\tconst issues =\n\t\tresult.issues === undefined\n\t\t\t? undefined\n\t\t\t: Object.freeze(\n\t\t\t\t\tresult.issues.map((issue) => sanitizeAdapterInputIssue(issue, opts.publicText)),\n\t\t\t\t);\n\tconst textIssues: DataIssue[] = [];\n\tconst metadata = sanitizeRuntimeMetadata(\n\t\t{\n\t\t\t...(result.metadata ?? {}),\n\t\t\tadapterInputId: input.adapterInputId,\n\t\t\t...(opts.runId === undefined ? {} : { runId: opts.runId }),\n\t\t\tproviderId: input.providerId,\n\t\t\ttoolName: input.toolName,\n\t\t\toperation: input.operation,\n\t\t},\n\t\tinput,\n\t\topts.publicText,\n\t\ttextIssues,\n\t);\n\tif (metadata === undefined && result.metadata !== undefined) {\n\t\ttextIssues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-runtime-metadata-redacted\",\n\t\t\t\t\"Tool provider adapter runtime metadata was omitted because it contained runtime-private material.\",\n\t\t\t\t{\n\t\t\t\t\tsubjectId: input.requestId,\n\t\t\t\t\trefs: [ref(\"tool-provider-adapter-input\", input.adapterInputId)],\n\t\t\t\t\tseverity: \"warning\",\n\t\t\t\t},\n\t\t\t),\n\t\t);\n\t}\n\tconst base = {\n\t\toutcomeId:\n\t\t\topts.outcomeId ??\n\t\t\t`${input.adapterInputId}:${toolProviderOutcomeRunSegment(opts.runId, attempt)}:${\n\t\t\t\tresult.kind\n\t\t\t}`,\n\t\trequestId: input.requestId,\n\t\toperationId: input.operationId,\n\t\trouteId: ids.routeId,\n\t\texecutorId: ids.executorId,\n\t\tprofileId: ids.profileId,\n\t\tattempt,\n\t\tevidenceRefs,\n\t\t...(input.input?.inputId === undefined ? {} : { inputId: input.input.inputId }),\n\t\t...(input.input?.inputKind === undefined ? {} : { inputKind: input.input.inputKind }),\n\t\t...(occurredAtMs === undefined ? {} : { occurredAtMs }),\n\t\t...(issues === undefined ? {} : { issues }),\n\t\t...(result.usage === undefined ? {} : { usage: result.usage }),\n\t\t...(metadata === undefined ? {} : { metadata }),\n\t};\n\tconst candidate = (() => {\n\t\tswitch (result.kind) {\n\t\t\tcase \"result\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\tkind: \"result\",\n\t\t\t\t\tresult: sanitizeAgentOutputEnvelope(result.result, input, opts.publicText, textIssues),\n\t\t\t\t} satisfies ExecutorOutcome<T>;\n\t\t\tcase \"failure\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\tkind: \"failure\",\n\t\t\t\t\terror: sanitizeAdapterInputIssue(result.error, opts.publicText),\n\t\t\t\t\t...(result.retryable === undefined ? {} : { retryable: result.retryable }),\n\t\t\t\t} satisfies ExecutorOutcome<T>;\n\t\t\tcase \"canceled\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\tkind: \"canceled\",\n\t\t\t\t\t...(result.reason === undefined\n\t\t\t\t\t\t? {}\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\treason: boundedPublicText(\n\t\t\t\t\t\t\t\t\tresult.reason,\n\t\t\t\t\t\t\t\t\t\"reason\",\n\t\t\t\t\t\t\t\t\tinput,\n\t\t\t\t\t\t\t\t\topts.publicText,\n\t\t\t\t\t\t\t\t\ttextIssues,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t}),\n\t\t\t\t} satisfies ExecutorOutcome<T>;\n\t\t\tcase \"timeout\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\tkind: \"timeout\",\n\t\t\t\t\t...(result.timeoutMs === undefined ? {} : { timeoutMs: result.timeoutMs }),\n\t\t\t\t\t...(result.retryable === undefined ? {} : { retryable: result.retryable }),\n\t\t\t\t} satisfies ExecutorOutcome<T>;\n\t\t\tcase \"blocked\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\tkind: \"blocked\",\n\t\t\t\t\tneeds: Object.freeze(\n\t\t\t\t\t\tresult.needs.map((need) => sanitizeAgentNeed(need, input, opts.publicText, textIssues)),\n\t\t\t\t\t),\n\t\t\t\t} satisfies ExecutorOutcome<T>;\n\t\t}\n\t})();\n\tconst boundedCandidate =\n\t\ttextIssues.length === 0\n\t\t\t? candidate\n\t\t\t: ({\n\t\t\t\t\t...candidate,\n\t\t\t\t\tissues: Object.freeze([...(candidate.issues ?? []), ...textIssues]),\n\t\t\t\t} satisfies ExecutorOutcome<T>);\n\tconst materialIssues = (boundedCandidate.issues ?? []).filter(\n\t\t(issue) => issue.code === \"tool-provider-adapter-runtime-forbidden-runtime-material\",\n\t);\n\tconst leakIssues = forbiddenAdapterRuntimeMaterialIssues(\n\t\tboundedCandidate,\n\t\tref(\"executor-outcome\", boundedCandidate.outcomeId),\n\t\t\"executor-outcome\",\n\t);\n\tif (leakIssues.length === 0 && materialIssues.length === 0)\n\t\treturn Object.freeze(boundedCandidate);\n\tconst allLeakIssues = Object.freeze([...materialIssues, ...leakIssues]);\n\tconst issue = allLeakIssues[0] ?? dataIssue(\"tool-provider-adapter-runtime-invalid\", \"invalid\");\n\tconst failureMetadata = sanitizeGraphVisibleRecord({\n\t\tadapterInputId: input.adapterInputId,\n\t\t...(opts.runId === undefined ? {} : { runId: opts.runId }),\n\t\tproviderId: input.providerId,\n\t\ttoolName: input.toolName,\n\t\toperation: input.operation,\n\t});\n\treturn Object.freeze({\n\t\tkind: \"failure\",\n\t\toutcomeId: `${input.adapterInputId}:${toolProviderOutcomeRunSegment(\n\t\t\topts.runId,\n\t\t\tattempt,\n\t\t)}:failure`,\n\t\trequestId: input.requestId,\n\t\toperationId: input.operationId,\n\t\trouteId: ids.routeId,\n\t\texecutorId: ids.executorId,\n\t\tprofileId: ids.profileId,\n\t\tattempt,\n\t\tevidenceRefs,\n\t\t...(input.input?.inputId === undefined ? {} : { inputId: input.input.inputId }),\n\t\t...(input.input?.inputKind === undefined ? {} : { inputKind: input.input.inputKind }),\n\t\t...(occurredAtMs === undefined ? {} : { occurredAtMs }),\n\t\t...(failureMetadata === undefined ? {} : { metadata: failureMetadata }),\n\t\terror: issue,\n\t\tretryable: false,\n\t\tissues: allLeakIssues,\n\t} as ExecutorOutcome<T>);\n}\n\nexport function agentRequestStatusForExecutorOutcome(outcome: ExecutorOutcome): AgentRequestStatus {\n\tswitch (outcome.kind) {\n\t\tcase \"result\":\n\t\t\treturn \"completed\";\n\t\tcase \"failure\":\n\t\t\treturn \"failed\";\n\t\tcase \"canceled\":\n\t\t\treturn \"canceled\";\n\t\tcase \"timeout\":\n\t\t\treturn \"timeout\";\n\t\tcase \"blocked\":\n\t\t\treturn \"blocked\";\n\t}\n}\n\nexport function toolProviderOutcomeRunSegment(runId: string | undefined, attempt: number): string {\n\treturn runId === undefined ? `attempt-${attempt}` : `${runId}:attempt-${attempt}`;\n}\n\nexport function adapterRuntimeIssue(\n\tinput: ToolProviderAdapterInput,\n\tcode: string,\n\terror: unknown,\n): DataIssue {\n\treturn dataIssue(code, \"Tool provider adapter runtime failed.\", {\n\t\tsubjectId: input.requestId,\n\t\trefs: [ref(\"tool-provider-adapter-input\", input.adapterInputId)],\n\t\tdetails: { errorType: error instanceof Error ? error.name : typeof error },\n\t});\n}\n\nexport function forbiddenAdapterRuntimeMaterialIssues(\n\tvalue: unknown,\n\tsubjectRef: SourceRef,\n\tarea: string,\n): readonly DataIssue[] {\n\tif (value === undefined) return [];\n\tconst forbidden = publicMaterialForbiddenKeys(value, \"provider\");\n\tif (forbidden.length === 0) return [];\n\treturn Object.freeze(\n\t\tforbidden.map((entry) =>\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-adapter-runtime-forbidden-runtime-material\",\n\t\t\t\t\"Tool provider adapter runtime output must not contain runtime-private adapter material.\",\n\t\t\t\t{ subjectId: subjectRef.id, refs: [subjectRef], details: { area, reason: entry.reason } },\n\t\t\t),\n\t\t),\n\t);\n}\n\nexport function readThenable<T>(value: T | PromiseLike<T>): {\n\treadonly subscribe?: PromiseLike<T>[\"then\"];\n\treadonly error?: unknown;\n} {\n\tif ((typeof value !== \"object\" && typeof value !== \"function\") || value === null) return {};\n\ttry {\n\t\tconst then = (value as { then?: unknown }).then;\n\t\tif (typeof then !== \"function\") return {};\n\t\treturn { subscribe: then.bind(value) as PromiseLike<T>[\"then\"] };\n\t} catch (error) {\n\t\treturn { error };\n\t}\n}\n\nexport function outcomeIssues(outcome: ExecutorOutcome): readonly DataIssue[] {\n\tif (outcome.kind === \"failure\") return Object.freeze([outcome.error, ...(outcome.issues ?? [])]);\n\treturn outcome.issues ?? [];\n}\n","import { depBatch } from \"../ctx/types.js\";\nimport type { DataIssue } from \"../data/index.js\";\nimport type { Graph } from \"../graph/graph.js\";\nimport type { Node } from \"../node/node.js\";\nimport {\n\tdataIssue,\n\tforbiddenDataKeys,\n\tforbiddenGraphVisibleMaterialIssues,\n\tforbiddenProviderRawMaterialKeys,\n\tforEachDepBatch,\n\tisRecord,\n\tprojectRuntimeFact,\n\tref,\n\tsanitizeProviderGraphVisibleRecord,\n\tunlockedToolProviderPolicyOverrides,\n} from \"./agent-runtime-common.js\";\nimport type { AgentRuntimeAuditRecord } from \"./agent-runtime-types-agent.js\";\nimport type {\n\tAgentRequestFact,\n\tAgentRequestIssued,\n\tExecutorProfile,\n\tExecutorRoute,\n\tSourceRef,\n} from \"./agent-runtime-types-core.js\";\nimport type {\n\tLocalBuiltinToolProviderCatalogOptions,\n\tToolCallInput,\n\tToolProviderApprovalPolicy,\n\tToolProviderArtifactPolicy,\n\tToolProviderCatalog,\n\tToolProviderCatalogEntry,\n\tToolProviderExecutionPolicy,\n\tToolProviderFilesystemPolicy,\n\tToolProviderNetworkPolicy,\n\tToolProviderPathRule,\n\tToolProviderPolicyResolution,\n\tToolProviderPolicyResolutionBundle,\n\tToolProviderPolicyResolutionStatus,\n\tToolProviderRedactionPolicy,\n\tToolProviderSizeCapacityPolicy,\n\tToolProviderSizeLimit,\n\tToolProviderTimeoutPolicy,\n} from \"./agent-runtime-types-tool.js\";\n\nexport function localBuiltinToolProviderCatalog(\n\topts: LocalBuiltinToolProviderCatalogOptions = {},\n): ToolProviderCatalog {\n\tconst providerId = opts.providerId ?? \"local-builtin\";\n\tconst executorId = opts.executorId ?? `${providerId}:tool-executor`;\n\tconst profileId = opts.profileId ?? `${providerId}:tool-profile`;\n\tconst tools =\n\t\topts.tools ??\n\t\t([\n\t\t\t{ toolName: \"document/read-doc\", operation: \"read\" },\n\t\t\t{ toolName: \"file.read\", operation: \"read\" },\n\t\t\t{ toolName: \"file.edit/apply-patch\", operation: \"edit\" },\n\t\t\t{ toolName: \"bash.run\", operation: \"run\" },\n\t\t\t{ toolName: \"url.fetch\", operation: \"fetch\" },\n\t\t\t{ toolName: \"date.now\", operation: \"read\" },\n\t\t\t{ toolName: \"weather.fetch\", operation: \"fetch\" },\n\t\t\t{ toolName: \"calculator/eval\", operation: \"eval\" },\n\t\t] satisfies readonly Omit<\n\t\t\tToolProviderCatalogEntry,\n\t\t\t\"kind\" | \"providerId\" | \"inputKind\" | \"profileId\" | \"executorId\"\n\t\t>[]);\n\tconst candidatePolicies: readonly unknown[] = opts.policies?.map((policy) =>\n\t\tObject.freeze(policy),\n\t) ?? [\n\t\tdefaultLocalBuiltinToolProviderExecutionPolicy({\n\t\t\tproviderId,\n\t\t\tprofileId,\n\t\t\ttools,\n\t\t\toverrides: opts.policyOverrides,\n\t\t}),\n\t];\n\tconst policyIssues = Object.freeze(\n\t\tcandidatePolicies.flatMap((policy) => [\n\t\t\t...validateToolProviderExecutionPolicy(policy),\n\t\t\t...validateToolProviderPolicyProviderScope(policy, providerId),\n\t\t]),\n\t);\n\tconst policies = Object.freeze(\n\t\tcandidatePolicies\n\t\t\t.filter((policy) => isPublishableToolProviderExecutionPolicy(policy, providerId))\n\t\t\t.map((policy) => Object.freeze(policy)),\n\t);\n\tconst policyRefs = Object.freeze(\n\t\tpolicies.map((policy) => ref(\"tool-provider-execution-policy\", policy.policyId)),\n\t);\n\tconst catalogInputIssues = Object.freeze([\n\t\t...forbiddenGraphVisibleMaterialIssues(\n\t\t\topts.metadata,\n\t\t\tref(\"tool-provider-catalog\", providerId),\n\t\t\t\"catalog-metadata\",\n\t\t),\n\t\t...forbiddenGraphVisibleMaterialIssues(\n\t\t\topts.capabilities,\n\t\t\tref(\"executor-profile\", profileId),\n\t\t\t\"profile-capabilities\",\n\t\t),\n\t\t...forbiddenGraphVisibleMaterialIssues(\n\t\t\topts.limits,\n\t\t\tref(\"executor-profile\", profileId),\n\t\t\t\"profile-limits\",\n\t\t),\n\t\t...tools.flatMap((tool) => [\n\t\t\t...forbiddenGraphVisibleMaterialIssues(\n\t\t\t\ttool.metadata,\n\t\t\t\tref(\"tool\", tool.toolName),\n\t\t\t\t\"tool-metadata\",\n\t\t\t),\n\t\t\t...forbiddenGraphVisibleMaterialIssues(\n\t\t\t\ttool.capabilities,\n\t\t\t\tref(\"tool\", tool.toolName),\n\t\t\t\t\"tool-capabilities\",\n\t\t\t),\n\t\t\t...forbiddenGraphVisibleMaterialIssues(\n\t\t\t\ttool.limits,\n\t\t\t\tref(\"tool\", tool.toolName),\n\t\t\t\t\"tool-limits\",\n\t\t\t),\n\t\t]),\n\t]);\n\tconst toolEntries = tools.map((tool) => {\n\t\tconst toolPolicyRefs = policyRefsForTool(policies, profileId, tool);\n\t\treturn Object.freeze({\n\t\t\t...tool,\n\t\t\tkind: \"tool-catalog-entry\",\n\t\t\tproviderId,\n\t\t\tinputKind: \"tool-call\",\n\t\t\tprofileId,\n\t\t\texecutorId,\n\t\t\tcapabilities: sanitizeProviderGraphVisibleRecord(tool.capabilities),\n\t\t\tlimits: sanitizeProviderGraphVisibleRecord(tool.limits),\n\t\t\tpolicyRefs: toolPolicyRefs,\n\t\t\tmetadata: sanitizeProviderGraphVisibleRecord(tool.metadata),\n\t\t} satisfies ToolProviderCatalogEntry);\n\t});\n\tconst profilePolicyRefs = policyRefsForProfile(policies, profileId);\n\tconst issues = Object.freeze([...policyIssues, ...catalogInputIssues]);\n\treturn Object.freeze({\n\t\tkind: \"tool-provider-catalog\",\n\t\tproviderId,\n\t\tproviderKind: \"local-builtin\",\n\t\tstatus: issues.length === 0 ? \"ready\" : \"misconfigured\",\n\t\tprofiles: Object.freeze([\n\t\t\tObject.freeze({\n\t\t\t\tprofileId,\n\t\t\t\texecutorId,\n\t\t\t\tkind: \"tool\",\n\t\t\t\tacceptedInputKinds: Object.freeze([\"tool-call\"]),\n\t\t\t\tacceptedResultKinds: Object.freeze(\n\t\t\t\t\tArray.from(new Set(toolEntries.flatMap((tool) => tool.resultKinds ?? []))),\n\t\t\t\t),\n\t\t\t\tcapabilities: Object.freeze({\n\t\t\t\t\ttoolNames: Object.freeze(toolEntries.map((tool) => tool.toolName)),\n\t\t\t\t\t...(sanitizeProviderGraphVisibleRecord(opts.capabilities) ?? {}),\n\t\t\t\t}),\n\t\t\t\tlimits: sanitizeProviderGraphVisibleRecord(opts.limits),\n\t\t\t\tpolicyRefs: profilePolicyRefs,\n\t\t\t\tmetadata: sanitizeProviderGraphVisibleRecord(opts.metadata),\n\t\t\t} satisfies ExecutorProfile),\n\t\t]),\n\t\ttools: Object.freeze(toolEntries),\n\t\tpolicies,\n\t\tpolicyRefs,\n\t\tissues: issues.length === 0 ? undefined : issues,\n\t\tmetadata: sanitizeProviderGraphVisibleRecord(opts.metadata),\n\t});\n}\n\nexport function validateToolProviderExecutionPolicy(policy: unknown): readonly DataIssue[] {\n\tconst issues: DataIssue[] = [];\n\tif (!isRecord(policy)) {\n\t\treturn Object.freeze([\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-policy-invalid-shape\",\n\t\t\t\t\"Tool provider policy must be a data object.\",\n\t\t\t\t{ refs: [ref(\"tool-provider-execution-policy\", \"<invalid>\")] },\n\t\t\t),\n\t\t]);\n\t}\n\tconst policyId = typeof policy.policyId === \"string\" ? policy.policyId : \"\";\n\tconst providerId = typeof policy.providerId === \"string\" ? policy.providerId : \"\";\n\tconst policyRef = ref(\"tool-provider-execution-policy\", policyId || \"<missing>\");\n\tif (policy.kind !== \"tool-provider-execution-policy\") {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-policy-invalid-kind\",\n\t\t\t\t\"ToolProviderExecutionPolicy.kind must be tool-provider-execution-policy.\",\n\t\t\t\t{ subjectId: policyId, refs: [policyRef] },\n\t\t\t),\n\t\t);\n\t}\n\tif (!policyId) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-policy-missing-policy-id\",\n\t\t\t\t\"Tool provider policy is missing policyId.\",\n\t\t\t\t{\n\t\t\t\t\trefs: [policyRef],\n\t\t\t\t},\n\t\t\t),\n\t\t);\n\t}\n\tif (!providerId) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-policy-missing-provider-id\",\n\t\t\t\t\"Tool provider policy is missing providerId.\",\n\t\t\t\t{ subjectId: policyId, refs: [policyRef] },\n\t\t\t),\n\t\t);\n\t}\n\tif (\n\t\tpolicy.sizeCapacity === undefined &&\n\t\tpolicy.timeout === undefined &&\n\t\tpolicy.redaction === undefined &&\n\t\tpolicy.filesystem === undefined &&\n\t\tpolicy.approval === undefined &&\n\t\tpolicy.artifacts === undefined &&\n\t\tpolicy.network === undefined\n\t) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-policy-missing-material\",\n\t\t\t\t\"Tool provider policy has no D360 policy material sections.\",\n\t\t\t\t{ subjectId: policyId, refs: [policyRef] },\n\t\t\t),\n\t\t);\n\t}\n\tif (policy.sizeCapacity !== undefined && !isRecord(policy.sizeCapacity)) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-policy-invalid-size-capacity\",\n\t\t\t\t\"Tool provider size-capacity policy must be a data object.\",\n\t\t\t\t{ subjectId: policyId, refs: [policyRef] },\n\t\t\t),\n\t\t);\n\t}\n\tconst limits = isRecord(policy.sizeCapacity) ? policy.sizeCapacity.limits : undefined;\n\tif (isRecord(policy.sizeCapacity) && !Array.isArray(limits)) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-policy-invalid-size-capacity\",\n\t\t\t\t\"Tool provider size-capacity limits must be an array.\",\n\t\t\t\t{ subjectId: policyId, refs: [policyRef] },\n\t\t\t),\n\t\t);\n\t}\n\tfor (const [index, rawLimit] of (Array.isArray(limits) ? limits : []).entries()) {\n\t\tif (!isRecord(rawLimit)) {\n\t\t\tissues.push(\n\t\t\t\tdataIssue(\n\t\t\t\t\t\"tool-provider-policy-invalid-size-limit\",\n\t\t\t\t\t\"Tool provider size-capacity limit must be a data object.\",\n\t\t\t\t\t{ subjectId: policyId, refs: [policyRef], details: { index } },\n\t\t\t\t),\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\tconst limit = rawLimit as Partial<ToolProviderSizeLimit>;\n\t\tif (typeof limit.unit !== \"string\" || limit.unit.length === 0) {\n\t\t\tissues.push(\n\t\t\t\tdataIssue(\n\t\t\t\t\t\"tool-provider-policy-invalid-size-limit\",\n\t\t\t\t\t\"Tool provider size-capacity limit unit must be a non-empty string.\",\n\t\t\t\t\t{ subjectId: policyId, refs: [policyRef], details: { index } },\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\tlimit.softLimit !== undefined &&\n\t\t\t(typeof limit.softLimit !== \"number\" ||\n\t\t\t\t!Number.isFinite(limit.softLimit) ||\n\t\t\t\tlimit.softLimit < 0)\n\t\t) {\n\t\t\tissues.push(\n\t\t\t\tdataIssue(\n\t\t\t\t\t\"tool-provider-policy-invalid-size-limit\",\n\t\t\t\t\t\"Tool provider size-capacity softLimit must be a finite non-negative number.\",\n\t\t\t\t\t{ subjectId: policyId, refs: [policyRef], details: { index, unit: limit.unit } },\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\tlimit.hardLimit !== undefined &&\n\t\t\t(typeof limit.hardLimit !== \"number\" ||\n\t\t\t\t!Number.isFinite(limit.hardLimit) ||\n\t\t\t\tlimit.hardLimit < 0)\n\t\t) {\n\t\t\tissues.push(\n\t\t\t\tdataIssue(\n\t\t\t\t\t\"tool-provider-policy-invalid-size-limit\",\n\t\t\t\t\t\"Tool provider size-capacity hardLimit must be a finite non-negative number.\",\n\t\t\t\t\t{ subjectId: policyId, refs: [policyRef], details: { index, unit: limit.unit } },\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\ttypeof limit.softLimit === \"number\" &&\n\t\t\tNumber.isFinite(limit.softLimit) &&\n\t\t\ttypeof limit.hardLimit === \"number\" &&\n\t\t\tNumber.isFinite(limit.hardLimit) &&\n\t\t\tlimit.softLimit > limit.hardLimit\n\t\t) {\n\t\t\tissues.push(\n\t\t\t\tdataIssue(\n\t\t\t\t\t\"tool-provider-policy-invalid-size-limit\",\n\t\t\t\t\t\"Tool provider size-capacity softLimit must not exceed hardLimit.\",\n\t\t\t\t\t{ subjectId: policyId, refs: [policyRef], details: { index, unit: limit.unit } },\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n\tif (policy.timeout !== undefined && !isRecord(policy.timeout)) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-policy-invalid-timeout\",\n\t\t\t\t\"Tool provider timeout policy must be a data object.\",\n\t\t\t\t{ subjectId: policyId, refs: [policyRef] },\n\t\t\t),\n\t\t);\n\t}\n\tfor (const [field, value] of Object.entries(isRecord(policy.timeout) ? policy.timeout : {})) {\n\t\tif (field.endsWith(\"TimeoutMs\") || field === \"timeoutMs\") {\n\t\t\tif (typeof value !== \"number\" || !Number.isFinite(value) || value < 0) {\n\t\t\t\tissues.push(\n\t\t\t\t\tdataIssue(\n\t\t\t\t\t\t\"tool-provider-policy-invalid-timeout\",\n\t\t\t\t\t\t\"Tool provider timeout values must be finite non-negative numbers.\",\n\t\t\t\t\t\t{ subjectId: policyId, refs: [policyRef], details: { field } },\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\tfor (const forbidden of [\n\t\t...forbiddenDataKeys(policy),\n\t\t...forbiddenProviderRawMaterialKeys(policy),\n\t]) {\n\t\tissues.push(\n\t\t\tdataIssue(\n\t\t\t\t\"tool-provider-policy-forbidden-runtime-material\",\n\t\t\t\t\"Tool provider policy must not contain runtime-private adapter material.\",\n\t\t\t\t{ subjectId: policyId, refs: [policyRef], details: { reason: forbidden.reason } },\n\t\t\t),\n\t\t);\n\t}\n\treturn Object.freeze(issues);\n}\n\nexport function resolveToolProviderExecutionPolicies(opts: {\n\treadonly request: AgentRequestIssued;\n\treadonly routes?: readonly ExecutorRoute[];\n\treadonly catalogs?: readonly ToolProviderCatalog[];\n}): readonly ToolProviderPolicyResolution[] {\n\tconst request = opts.request;\n\tconst toolCall = toolCallFromRequest(request);\n\tconst baseSourceRefs = Object.freeze([ref(\"agent-request\", request.requestId)]);\n\tif (toolCall === undefined) {\n\t\treturn Object.freeze([\n\t\t\tObject.freeze({\n\t\t\t\tkind: \"tool-provider-policy-resolution\",\n\t\t\t\tresolutionId: `${request.requestId}:${request.operationId}:tool-policy:missing-tool-call`,\n\t\t\t\tstatus: \"missing-tool-call\",\n\t\t\t\trequestId: request.requestId,\n\t\t\t\toperationId: request.operationId,\n\t\t\t\tissues: Object.freeze([\n\t\t\t\t\tdataIssue(\n\t\t\t\t\t\t\"tool-provider-policy-missing-tool-call\",\n\t\t\t\t\t\t\"Tool provider policy resolution requires AgentRequest input.value to be a ToolCallInput.\",\n\t\t\t\t\t\t{ subjectId: request.requestId, refs: baseSourceRefs },\n\t\t\t\t\t),\n\t\t\t\t]),\n\t\t\t\tsourceRefs: baseSourceRefs,\n\t\t\t} satisfies ToolProviderPolicyResolution),\n\t\t]);\n\t}\n\tconst routes = (opts.routes ?? []).filter(\n\t\t(route) => route.requestId === request.requestId && route.operationId === request.operationId,\n\t);\n\tif (routes.length === 0) {\n\t\treturn Object.freeze([\n\t\t\tObject.freeze({\n\t\t\t\tkind: \"tool-provider-policy-resolution\",\n\t\t\t\tresolutionId: `${request.requestId}:${request.operationId}:tool-policy:pending-route`,\n\t\t\t\tstatus: \"pending-route\",\n\t\t\t\trequestId: request.requestId,\n\t\t\t\toperationId: request.operationId,\n\t\t\t\ttoolName: toolCall.toolName,\n\t\t\t\toperation: toolCall.operation,\n\t\t\t\tsourceRefs: baseSourceRefs,\n\t\t\t} satisfies ToolProviderPolicyResolution),\n\t\t]);\n\t}\n\treturn Object.freeze(\n\t\troutes.map((route) =>\n\t\t\tObject.freeze(\n\t\t\t\tresolveToolProviderPolicyForRoute(request, route, toolCall, opts.catalogs ?? []),\n\t\t\t),\n\t\t),\n\t);\n}\n\nexport function toolProviderPolicyResolutionProjector(\n\tgraph: Graph,\n\topts: {\n\t\treadonly name?: string;\n\t\treadonly requestFacts: Node<AgentRequestFact>;\n\t\treadonly executorRoutes?: readonly Node<ExecutorRoute>[];\n\t\treadonly toolProviderCatalogs?: readonly Node<ToolProviderCatalog>[];\n\t},\n): ToolProviderPolicyResolutionBundle {\n\tconst name = opts.name ?? \"toolProviderPolicyResolution\";\n\tconst routeDeps = opts.executorRoutes ?? [];\n\tconst catalogDeps = opts.toolProviderCatalogs ?? [];\n\tconst routeStart = 1;\n\tconst catalogStart = routeStart + routeDeps.length;\n\tconst runtime = graph.node<ToolProviderPolicyResolutionFact>(\n\t\t[opts.requestFacts, ...routeDeps, ...catalogDeps],\n\t\t(ctx) => {\n\t\t\tconst state = ctx.state.get<ToolProviderPolicyResolutionState>() ?? {\n\t\t\t\trequests: new Map<string, AgentRequestIssued>(),\n\t\t\t\troutes: new Map<string, ExecutorRoute>(),\n\t\t\t\tcatalogs: new Map<string, ToolProviderCatalog>(),\n\t\t\t\temittedKeys: new Set<string>(),\n\t\t\t\tauditSeq: 0,\n\t\t\t};\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst fact = raw as AgentRequestFact;\n\t\t\t\tif (fact.kind === \"issued\" && fact.input?.inputKind === \"tool-call\") {\n\t\t\t\t\tstate.requests.set(fact.requestId, fact);\n\t\t\t\t}\n\t\t\t}\n\t\t\tforEachDepBatch(ctx, routeStart, routeDeps.length, (raw) => {\n\t\t\t\tconst route = raw as ExecutorRoute;\n\t\t\t\tstate.routes.set(route.routeId, route);\n\t\t\t});\n\t\t\tforEachDepBatch(ctx, catalogStart, catalogDeps.length, (raw) => {\n\t\t\t\tconst catalog = raw as ToolProviderCatalog;\n\t\t\t\tstate.catalogs.set(catalog.providerId, catalog);\n\t\t\t});\n\t\t\tfor (const request of state.requests.values()) {\n\t\t\t\tconst resolutions = resolveToolProviderExecutionPolicies({\n\t\t\t\t\trequest,\n\t\t\t\t\troutes: Array.from(state.routes.values()),\n\t\t\t\t\tcatalogs: Array.from(state.catalogs.values()),\n\t\t\t\t});\n\t\t\t\tfor (const resolution of resolutions) {\n\t\t\t\t\tconst key = stableToolProviderPolicyResolutionKey(resolution);\n\t\t\t\t\tif (state.emittedKeys.has(key)) continue;\n\t\t\t\t\tstate.emittedKeys.add(key);\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\"DATA\", { kind: \"resolution\", resolution } satisfies ToolProviderPolicyResolutionFact],\n\t\t\t\t\t]);\n\t\t\t\t\tfor (const issue of resolution.issues ?? []) {\n\t\t\t\t\t\tctx.down([\n\t\t\t\t\t\t\t[\"DATA\", { kind: \"issue\", issue } satisfies ToolProviderPolicyResolutionFact],\n\t\t\t\t\t\t]);\n\t\t\t\t\t}\n\t\t\t\t\tstate.auditSeq += 1;\n\t\t\t\t\tctx.down([\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"DATA\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tkind: \"audit\",\n\t\t\t\t\t\t\t\taudit: {\n\t\t\t\t\t\t\t\t\tid: `${name}:audit:${state.auditSeq}`,\n\t\t\t\t\t\t\t\t\tkind: \"tool-provider-policy-resolution\",\n\t\t\t\t\t\t\t\t\tsubjectId: request.requestId,\n\t\t\t\t\t\t\t\t\tsourceRefs: resolution.sourceRefs,\n\t\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\t\tstatus: resolution.status,\n\t\t\t\t\t\t\t\t\t\trouteId: resolution.routeId,\n\t\t\t\t\t\t\t\t\t\tproviderId: resolution.providerId,\n\t\t\t\t\t\t\t\t\t\tprofileId: resolution.profileId,\n\t\t\t\t\t\t\t\t\t\ttoolName: resolution.toolName,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t} satisfies ToolProviderPolicyResolutionFact,\n\t\t\t\t\t\t],\n\t\t\t\t\t]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.state.set(state);\n\t\t},\n\t\t{ name: `${name}/runtime`, factory: \"toolProviderPolicyResolutionProjector\", partial: true },\n\t);\n\tconst resolutions = projectRuntimeFact(\n\t\tgraph,\n\t\truntime,\n\t\t`${name}/resolutions`,\n\t\t\"toolProviderPolicyResolutions\",\n\t\t(fact) => (fact.kind === \"resolution\" ? fact.resolution : undefined),\n\t);\n\tconst issues = projectRuntimeFact(\n\t\tgraph,\n\t\truntime,\n\t\t`${name}/issues`,\n\t\t\"toolProviderPolicyResolutionIssues\",\n\t\t(fact) => (fact.kind === \"issue\" ? fact.issue : undefined),\n\t);\n\tconst audit = projectRuntimeFact(\n\t\tgraph,\n\t\truntime,\n\t\t`${name}/audit`,\n\t\t\"toolProviderPolicyResolutionAudit\",\n\t\t(fact) => (fact.kind === \"audit\" ? fact.audit : undefined),\n\t);\n\treturn { resolutions, issues, audit };\n}\n\nexport type ToolProviderPolicyResolutionFact =\n\t| { readonly kind: \"resolution\"; readonly resolution: ToolProviderPolicyResolution }\n\t| { readonly kind: \"issue\"; readonly issue: DataIssue }\n\t| { readonly kind: \"audit\"; readonly audit: AgentRuntimeAuditRecord };\n\nexport interface ToolProviderPolicyResolutionState {\n\trequests: Map<string, AgentRequestIssued>;\n\troutes: Map<string, ExecutorRoute>;\n\tcatalogs: Map<string, ToolProviderCatalog>;\n\temittedKeys: Set<string>;\n\tauditSeq: number;\n}\n\nexport function isPublishableToolProviderExecutionPolicy(\n\tpolicy: unknown,\n\tproviderId?: string,\n): policy is ToolProviderExecutionPolicy {\n\treturn (\n\t\tisRecord(policy) &&\n\t\tpolicy.kind === \"tool-provider-execution-policy\" &&\n\t\ttypeof policy.policyId === \"string\" &&\n\t\tpolicy.policyId.length > 0 &&\n\t\ttypeof policy.providerId === \"string\" &&\n\t\tpolicy.providerId.length > 0 &&\n\t\t(providerId === undefined || policy.providerId === providerId) &&\n\t\tvalidateToolProviderExecutionPolicy(policy).length === 0\n\t);\n}\n\nexport function validateToolProviderPolicyProviderScope(\n\tpolicy: unknown,\n\tproviderId: string,\n): readonly DataIssue[] {\n\tif (!isRecord(policy)) return [];\n\tif (policy.providerId === undefined || policy.providerId === providerId) return [];\n\treturn Object.freeze([\n\t\tdataIssue(\n\t\t\t\"tool-provider-policy-provider-mismatch\",\n\t\t\t\"Tool provider policy providerId must match the catalog providerId.\",\n\t\t\t{\n\t\t\t\tsubjectId: typeof policy.policyId === \"string\" ? policy.policyId : undefined,\n\t\t\t\trefs: [\n\t\t\t\t\tref(\n\t\t\t\t\t\t\"tool-provider-execution-policy\",\n\t\t\t\t\t\ttypeof policy.policyId === \"string\" && policy.policyId.length > 0\n\t\t\t\t\t\t\t? policy.policyId\n\t\t\t\t\t\t\t: \"<missing>\",\n\t\t\t\t\t),\n\t\t\t\t\tref(\"tool-provider-catalog\", providerId),\n\t\t\t\t],\n\t\t\t},\n\t\t),\n\t]);\n}\n\nexport function policyRefsForProfile(\n\tpolicies: readonly ToolProviderExecutionPolicy[],\n\tprofileId: string,\n): readonly SourceRef[] {\n\treturn Object.freeze(\n\t\tpolicies\n\t\t\t.filter((policy) => policyAppliesToProfile(policy, profileId))\n\t\t\t.map((policy) => ref(\"tool-provider-execution-policy\", policy.policyId)),\n\t);\n}\n\nexport function policyRefsForTool(\n\tpolicies: readonly ToolProviderExecutionPolicy[],\n\tprofileId: string,\n\ttool: Omit<\n\t\tToolProviderCatalogEntry,\n\t\t\"kind\" | \"providerId\" | \"inputKind\" | \"profileId\" | \"executorId\"\n\t>,\n): readonly SourceRef[] {\n\treturn Object.freeze(\n\t\tpolicies\n\t\t\t.filter((policy) => policyAppliesToProfile(policy, profileId))\n\t\t\t.filter((policy) => policyAppliesToOptionalScope(policy.toolNames, tool.toolName))\n\t\t\t.filter((policy) => policyAppliesToOptionalScope(policy.operations, tool.operation))\n\t\t\t.map((policy) => ref(\"tool-provider-execution-policy\", policy.policyId)),\n\t);\n}\n\nexport function policyAppliesToProfile(\n\tpolicy: ToolProviderExecutionPolicy,\n\tprofileId: string,\n): boolean {\n\treturn policyAppliesToOptionalScope(policy.profileIds, profileId);\n}\n\nexport function policyAppliesToOptionalScope(\n\tscope: readonly string[] | undefined,\n\tvalue: string | undefined,\n): boolean {\n\treturn (\n\t\tscope === undefined || scope.length === 0 || (value !== undefined && scope.includes(value))\n\t);\n}\n\nexport function toolCallFromRequest(request: AgentRequestIssued): ToolCallInput | undefined {\n\tconst value = request.input?.value;\n\tif (request.input?.inputKind !== \"tool-call\" || !isRecord(value)) return undefined;\n\tif (\n\t\tvalue.kind !== \"tool-call\" ||\n\t\ttypeof value.toolName !== \"string\" ||\n\t\tvalue.toolName.length === 0\n\t) {\n\t\treturn undefined;\n\t}\n\treturn value as unknown as ToolCallInput;\n}\n\nexport function resolveToolProviderPolicyForRoute(\n\trequest: AgentRequestIssued,\n\troute: ExecutorRoute,\n\ttoolCall: ToolCallInput,\n\tcatalogs: readonly ToolProviderCatalog[],\n): ToolProviderPolicyResolution {\n\tconst sourceRefs = Object.freeze([\n\t\tref(\"agent-request\", request.requestId),\n\t\tref(\"executor-route\", route.routeId),\n\t]);\n\tconst matchingCatalogs = catalogs.filter((catalog) => catalogHasRouteProfile(catalog, route));\n\tif (matchingCatalogs.length === 0) {\n\t\treturn policyResolutionWithIssue({\n\t\t\trequest,\n\t\t\troute,\n\t\t\ttoolCall,\n\t\t\tstatus: \"missing-catalog\",\n\t\t\tsourceRefs,\n\t\t\tissue: dataIssue(\n\t\t\t\t\"tool-provider-policy-missing-catalog\",\n\t\t\t\t`No tool provider catalog exposes route profile '${route.profileId}'.`,\n\t\t\t\t{ subjectId: request.requestId, refs: sourceRefs },\n\t\t\t),\n\t\t});\n\t}\n\tif (matchingCatalogs.length > 1) {\n\t\treturn policyResolutionWithIssue({\n\t\t\trequest,\n\t\t\troute,\n\t\t\ttoolCall,\n\t\t\tstatus: \"ambiguous-catalog\",\n\t\t\tsourceRefs,\n\t\t\tissue: dataIssue(\n\t\t\t\t\"tool-provider-policy-ambiguous-catalog\",\n\t\t\t\t`Multiple tool provider catalogs expose route profile '${route.profileId}'.`,\n\t\t\t\t{\n\t\t\t\t\tsubjectId: request.requestId,\n\t\t\t\t\trefs: [\n\t\t\t\t\t\t...sourceRefs,\n\t\t\t\t\t\t...matchingCatalogs.map((catalog) => ref(\"tool-provider-catalog\", catalog.providerId)),\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t),\n\t\t});\n\t}\n\tconst catalog = matchingCatalogs[0];\n\tif (catalog === undefined) throw new Error(\"unreachable catalog match\");\n\tconst tool = catalog.tools.find(\n\t\t(entry) =>\n\t\t\tentry.profileId === route.profileId &&\n\t\t\tentry.executorId === route.executorId &&\n\t\t\tentry.toolName === toolCall.toolName &&\n\t\t\t(entry.operation === undefined ||\n\t\t\t\ttoolCall.operation === undefined ||\n\t\t\t\tentry.operation === toolCall.operation),\n\t);\n\tif (tool === undefined) {\n\t\treturn policyResolutionWithIssue({\n\t\t\trequest,\n\t\t\troute,\n\t\t\ttoolCall,\n\t\t\tstatus: \"missing-tool\",\n\t\t\tsourceRefs,\n\t\t\tproviderId: catalog.providerId,\n\t\t\tissue: dataIssue(\n\t\t\t\t\"tool-provider-policy-missing-tool\",\n\t\t\t\t`Tool provider catalog '${catalog.providerId}' does not expose requested tool '${toolCall.toolName}'.`,\n\t\t\t\t{\n\t\t\t\t\tsubjectId: request.requestId,\n\t\t\t\t\trefs: [...sourceRefs, ref(\"tool-provider-catalog\", catalog.providerId)],\n\t\t\t\t},\n\t\t\t),\n\t\t});\n\t}\n\tconst policyRefs = policyRefsForResolution(catalog, route, tool);\n\tif (policyRefs.length === 0) {\n\t\treturn policyResolutionWithIssue({\n\t\t\trequest,\n\t\t\troute,\n\t\t\ttoolCall,\n\t\t\tstatus: \"missing-policy\",\n\t\t\tsourceRefs,\n\t\t\tproviderId: catalog.providerId,\n\t\t\tissue: dataIssue(\n\t\t\t\t\"tool-provider-policy-missing-policy-ref\",\n\t\t\t\t`Tool '${tool.toolName}' has no D360 policy refs on its entry, profile, or catalog.`,\n\t\t\t\t{\n\t\t\t\t\tsubjectId: request.requestId,\n\t\t\t\t\trefs: [...sourceRefs, ref(\"tool-provider-catalog\", catalog.providerId)],\n\t\t\t\t},\n\t\t\t),\n\t\t});\n\t}\n\tconst issues = policyIssuesForRefs(catalog, policyRefs, request, sourceRefs);\n\tconst status = issues.length === 0 ? \"resolved\" : \"invalid-policy\";\n\treturn Object.freeze({\n\t\tkind: \"tool-provider-policy-resolution\",\n\t\tresolutionId: `${request.requestId}:${request.operationId}:${route.routeId}:tool-policy`,\n\t\tstatus,\n\t\trequestId: request.requestId,\n\t\toperationId: request.operationId,\n\t\trouteId: route.routeId,\n\t\tproviderId: catalog.providerId,\n\t\texecutorId: route.executorId,\n\t\tprofileId: route.profileId,\n\t\ttoolName: toolCall.toolName,\n\t\toperation: toolCall.operation,\n\t\tpolicyRefs,\n\t\tissues: issues.length === 0 ? undefined : Object.freeze(issues),\n\t\tsourceRefs: Object.freeze([...sourceRefs, ref(\"tool-provider-catalog\", catalog.providerId)]),\n\t} satisfies ToolProviderPolicyResolution);\n}\n\nexport function catalogHasRouteProfile(\n\tcatalog: ToolProviderCatalog,\n\troute: ExecutorRoute,\n): boolean {\n\treturn catalog.profiles.some(\n\t\t(profile) => profile.profileId === route.profileId && profile.executorId === route.executorId,\n\t);\n}\n\nexport function policyRefsForResolution(\n\tcatalog: ToolProviderCatalog,\n\troute: ExecutorRoute,\n\ttool: ToolProviderCatalogEntry,\n): readonly SourceRef[] {\n\tconst profile = catalog.profiles.find(\n\t\t(candidate) =>\n\t\t\tcandidate.profileId === route.profileId && candidate.executorId === route.executorId,\n\t);\n\treturn Object.freeze([\n\t\t...(tool.policyRefs ?? []),\n\t\t...((tool.policyRefs?.length ?? 0) === 0 ? (profile?.policyRefs ?? []) : []),\n\t\t...((tool.policyRefs?.length ?? 0) === 0 && (profile?.policyRefs?.length ?? 0) === 0\n\t\t\t? (catalog.policyRefs ?? [])\n\t\t\t: []),\n\t]);\n}\n\nexport function policyIssuesForRefs(\n\tcatalog: ToolProviderCatalog,\n\tpolicyRefs: readonly SourceRef[],\n\trequest: AgentRequestIssued,\n\tsourceRefs: readonly SourceRef[],\n): readonly DataIssue[] {\n\tconst policiesById = new Map((catalog.policies ?? []).map((policy) => [policy.policyId, policy]));\n\tconst issues: DataIssue[] = [];\n\tfor (const policyRef of policyRefs) {\n\t\tif (policyRef.kind !== \"tool-provider-execution-policy\") {\n\t\t\tissues.push(\n\t\t\t\tdataIssue(\n\t\t\t\t\t\"tool-provider-policy-invalid-ref-kind\",\n\t\t\t\t\t\"Tool provider policy refs must point at ToolProviderExecutionPolicy facts.\",\n\t\t\t\t\t{ subjectId: request.requestId, refs: [...sourceRefs, policyRef] },\n\t\t\t\t),\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\tconst policy = policiesById.get(policyRef.id);\n\t\tif (policy === undefined) {\n\t\t\tissues.push(\n\t\t\t\tdataIssue(\n\t\t\t\t\t\"tool-provider-policy-ref-missing-material\",\n\t\t\t\t\t`Tool provider policy ref '${policyRef.id}' has no policy material in catalog '${catalog.providerId}'.`,\n\t\t\t\t\t{ subjectId: request.requestId, refs: [...sourceRefs, policyRef] },\n\t\t\t\t),\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\tissues.push(...validateToolProviderExecutionPolicy(policy));\n\t\tissues.push(...validateToolProviderPolicyProviderScope(policy, catalog.providerId));\n\t}\n\treturn Object.freeze(issues);\n}\n\nexport function policyResolutionWithIssue(opts: {\n\treadonly request: AgentRequestIssued;\n\treadonly route: ExecutorRoute;\n\treadonly toolCall: ToolCallInput;\n\treadonly status: ToolProviderPolicyResolutionStatus;\n\treadonly sourceRefs: readonly SourceRef[];\n\treadonly issue: DataIssue;\n\treadonly providerId?: string;\n}): ToolProviderPolicyResolution {\n\treturn Object.freeze({\n\t\tkind: \"tool-provider-policy-resolution\",\n\t\tresolutionId: `${opts.request.requestId}:${opts.request.operationId}:${opts.route.routeId}:tool-policy:${opts.status}`,\n\t\tstatus: opts.status,\n\t\trequestId: opts.request.requestId,\n\t\toperationId: opts.request.operationId,\n\t\trouteId: opts.route.routeId,\n\t\tproviderId: opts.providerId,\n\t\texecutorId: opts.route.executorId,\n\t\tprofileId: opts.route.profileId,\n\t\ttoolName: opts.toolCall.toolName,\n\t\toperation: opts.toolCall.operation,\n\t\tissues: Object.freeze([opts.issue]),\n\t\tsourceRefs: opts.sourceRefs,\n\t} satisfies ToolProviderPolicyResolution);\n}\n\nexport function stableToolProviderPolicyResolutionKey(\n\tresolution: ToolProviderPolicyResolution,\n): string {\n\treturn JSON.stringify({\n\t\tid: resolution.resolutionId,\n\t\tstatus: resolution.status,\n\t\tpolicyRefs:\n\t\t\tresolution.policyRefs?.map((policyRef) => `${policyRef.kind}:${policyRef.id}`) ?? [],\n\t\tissues: resolution.issues?.map((issue) => issue.code) ?? [],\n\t});\n}\n\nexport function defaultLocalBuiltinToolProviderExecutionPolicy(opts: {\n\treadonly providerId: string;\n\treadonly profileId: string;\n\treadonly tools: readonly Omit<\n\t\tToolProviderCatalogEntry,\n\t\t\"kind\" | \"providerId\" | \"inputKind\" | \"profileId\" | \"executorId\"\n\t>[];\n\treadonly overrides?: Partial<\n\t\tOmit<ToolProviderExecutionPolicy, \"kind\" | \"policyId\" | \"providerId\">\n\t>;\n}): ToolProviderExecutionPolicy {\n\tconst toolNames = Object.freeze(Array.from(new Set(opts.tools.map((tool) => tool.toolName))));\n\tconst operations = Object.freeze(\n\t\tArray.from(new Set(opts.tools.map((tool) => tool.operation).filter((op) => op !== undefined))),\n\t);\n\tconst hasUrlFetch = toolNames.includes(\"url.fetch\");\n\tconst filesystemToolNames = toolNames.filter(\n\t\t(toolName) =>\n\t\t\ttoolName.startsWith(\"file.\") || toolName.startsWith(\"document/\") || toolName === \"bash.run\",\n\t);\n\tconst approvalToolNames = toolNames.filter(\n\t\t(toolName) => toolName === \"file.edit/apply-patch\" || toolName === \"bash.run\",\n\t);\n\tconst approvalOperations = operations.filter(\n\t\t(operation) => operation === \"edit\" || operation === \"run\",\n\t);\n\tconst policy = {\n\t\tkind: \"tool-provider-execution-policy\",\n\t\tpolicyId: `${opts.providerId}:policy:default`,\n\t\tproviderId: opts.providerId,\n\t\tprofileIds: Object.freeze([opts.profileId]),\n\t\ttoolNames,\n\t\toperations,\n\t\tsizeCapacity: Object.freeze({\n\t\t\tlimits: Object.freeze([\n\t\t\t\tObject.freeze({\n\t\t\t\t\tunit: \"chars\",\n\t\t\t\t\tsoftLimit: 16_384,\n\t\t\t\t\thardLimit: 65_536,\n\t\t\t\t\tperRequest: true,\n\t\t\t\t\tmeasurementSource: \"adapter-estimated\",\n\t\t\t\t} satisfies ToolProviderSizeLimit),\n\t\t\t\tObject.freeze({\n\t\t\t\t\tunit: \"bytes\",\n\t\t\t\t\tsoftLimit: 1_048_576,\n\t\t\t\t\thardLimit: 8_388_608,\n\t\t\t\t\tperArtifact: true,\n\t\t\t\t\tmeasurementSource: \"adapter-measured\",\n\t\t\t\t} satisfies ToolProviderSizeLimit),\n\t\t\t\tObject.freeze({\n\t\t\t\t\tunit: \"lines\",\n\t\t\t\t\tsoftLimit: 2_000,\n\t\t\t\t\thardLimit: 10_000,\n\t\t\t\t\tperStream: true,\n\t\t\t\t\tmeasurementSource: \"adapter-measured\",\n\t\t\t\t} satisfies ToolProviderSizeLimit),\n\t\t\t]),\n\t\t} satisfies ToolProviderSizeCapacityPolicy),\n\t\ttimeout: Object.freeze({\n\t\t\ttimeoutMs: 30_000,\n\t\t\tidleTimeoutMs: 5_000,\n\t\t} satisfies ToolProviderTimeoutPolicy),\n\t\tredaction: Object.freeze({\n\t\t\tmode: \"summary\",\n\t\t\tsensitivity: Object.freeze([\"private-material\", \"auth-material\", \"personal-data\"]),\n\t\t\tsummaryMaxChars: 512,\n\t\t} satisfies ToolProviderRedactionPolicy),\n\t\t...(filesystemToolNames.length > 0\n\t\t\t? {\n\t\t\t\t\tfilesystem: Object.freeze({\n\t\t\t\t\t\tcwd: \".\",\n\t\t\t\t\t\tallowRead: true,\n\t\t\t\t\t\tallowWrite: false,\n\t\t\t\t\t\tfollowSymlinks: false,\n\t\t\t\t\t\tsourceRefs: Object.freeze(filesystemToolNames.map((toolName) => ref(\"tool\", toolName))),\n\t\t\t\t\t\tpathRules: Object.freeze([\n\t\t\t\t\t\t\tObject.freeze({\n\t\t\t\t\t\t\t\teffect: \"allow\",\n\t\t\t\t\t\t\t\tpath: \".\",\n\t\t\t\t\t\t\t\toperation: \"read\",\n\t\t\t\t\t\t\t\treason: \"Default local builtin catalog is workspace-relative data material.\",\n\t\t\t\t\t\t\t} satisfies ToolProviderPathRule),\n\t\t\t\t\t\t\tObject.freeze({\n\t\t\t\t\t\t\t\teffect: \"deny\",\n\t\t\t\t\t\t\t\tglob: \"**/.env*\",\n\t\t\t\t\t\t\t\treason: \"D360 policies keep private material outside catalog DATA.\",\n\t\t\t\t\t\t\t} satisfies ToolProviderPathRule),\n\t\t\t\t\t\t]),\n\t\t\t\t\t} satisfies ToolProviderFilesystemPolicy),\n\t\t\t\t}\n\t\t\t: {}),\n\t\t...(hasUrlFetch\n\t\t\t? {\n\t\t\t\t\tnetwork: Object.freeze({\n\t\t\t\t\t\tmode: \"custom\",\n\t\t\t\t\t\tprotocols: Object.freeze([\"https:\"]),\n\t\t\t\t\t\tallowedHosts: Object.freeze([\"*\"]),\n\t\t\t\t\t\tsourceRefs: Object.freeze([ref(\"tool\", \"url.fetch\")]),\n\t\t\t\t\t} satisfies ToolProviderNetworkPolicy),\n\t\t\t\t}\n\t\t\t: {}),\n\t\tapproval: Object.freeze({\n\t\t\tmode: approvalToolNames.length > 0 ? \"require\" : \"auto\",\n\t\t\t...(approvalToolNames.length > 0\n\t\t\t\t? { requiredForToolNames: Object.freeze(approvalToolNames) }\n\t\t\t\t: {}),\n\t\t\t...(approvalOperations.length > 0\n\t\t\t\t? { requiredForOperations: Object.freeze(approvalOperations) }\n\t\t\t\t: {}),\n\t\t} satisfies ToolProviderApprovalPolicy),\n\t\tartifacts: Object.freeze({\n\t\t\tdefaultDataMode: \"summary\",\n\t\t\tartifactKinds: Object.freeze([\n\t\t\t\t\"text\",\n\t\t\t\t\"markdown\",\n\t\t\t\t\"file\",\n\t\t\t\t\"stdout\",\n\t\t\t\t\"stderr\",\n\t\t\t\t\"tool-output\",\n\t\t\t\t\"provider-raw\",\n\t\t\t]),\n\t\t\tinlineLimits: Object.freeze([\n\t\t\t\tObject.freeze({\n\t\t\t\t\tunit: \"chars\",\n\t\t\t\t\thardLimit: 4_096,\n\t\t\t\t\tperArtifact: true,\n\t\t\t\t\tmeasurementSource: \"adapter-estimated\",\n\t\t\t\t} satisfies ToolProviderSizeLimit),\n\t\t\t]),\n\t\t\trequireDigest: false,\n\t\t} satisfies ToolProviderArtifactPolicy),\n\t\tsourceRefs: Object.freeze([ref(\"decision\", \"D360\"), ref(\"tool-provider\", opts.providerId)]),\n\t\tmetadata: Object.freeze({\n\t\t\tdescription: \"Default data-only policy material for local builtin tools.\",\n\t\t}),\n\t\t...unlockedToolProviderPolicyOverrides(opts.overrides),\n\t} satisfies ToolProviderExecutionPolicy;\n\treturn Object.freeze(policy);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,gCAA0B;AAC1B,qBAA6B;AAC7B,uBAA8C;;;ACgCvC,IAAM,WAAW;;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