@e4779/pi-fabric 0.109.2-fork.23 → 0.116.0-fork.25
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 +3 -1
- package/THIRD_PARTY_NOTICES.md +9 -2
- package/dist/agents/completion-inbox.d.ts.map +1 -1
- package/dist/agents/handoff.d.ts +1 -1
- package/dist/agents/handoff.d.ts.map +1 -1
- package/dist/agents/manager.d.ts +8 -0
- package/dist/agents/manager.d.ts.map +1 -1
- package/dist/agents/provider-bridge.d.ts +64 -0
- package/dist/agents/provider-bridge.d.ts.map +1 -0
- package/dist/agents/provider-bridge.js +117 -0
- package/dist/agents/provider-bridge.js.map +7 -0
- package/dist/agents/runner-registry.d.ts +3 -0
- package/dist/agents/runner-registry.d.ts.map +1 -1
- package/dist/agents/trace-context-request.d.ts +4 -0
- package/dist/agents/trace-context-request.d.ts.map +1 -0
- package/dist/agents/trace-context.d.ts +31 -0
- package/dist/agents/trace-context.d.ts.map +1 -0
- package/dist/agents/types.d.ts +13 -0
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/agents.js +7 -7
- package/dist/audit/details.d.ts +5 -2
- package/dist/audit/details.d.ts.map +1 -1
- package/dist/capture/interceptor.d.ts.map +1 -1
- package/dist/chunks/{chunk-X2TRSE7D.js → chunk-2YG4ZA2K.js} +2 -2
- package/dist/chunks/{chunk-WHBJDTCR.js → chunk-4GGBND7V.js} +37 -10
- package/dist/chunks/chunk-4GGBND7V.js.map +7 -0
- package/dist/chunks/{chunk-N2VKKA7O.js → chunk-4GNFBZPR.js} +2 -2
- package/dist/chunks/{chunk-M5IN6DMF.js → chunk-56RFFBBO.js} +6 -6
- package/dist/chunks/{chunk-J2HUD36Z.js → chunk-5X35KXBV.js} +14 -2
- package/dist/chunks/{chunk-J2HUD36Z.js.map → chunk-5X35KXBV.js.map} +2 -2
- package/dist/chunks/{chunk-DU6ZA44F.js → chunk-6EVAHJAR.js} +5 -5
- package/dist/chunks/{chunk-ST36EYHN.js → chunk-6QVQXGMR.js} +1 -1
- package/dist/chunks/chunk-6QVQXGMR.js.map +7 -0
- package/dist/chunks/chunk-7C5IEIQK.js +157 -0
- package/dist/chunks/chunk-7C5IEIQK.js.map +7 -0
- package/dist/chunks/{chunk-C7EEG6SM.js → chunk-A5XF3ZPJ.js} +19 -2
- package/dist/chunks/chunk-A5XF3ZPJ.js.map +7 -0
- package/dist/chunks/{chunk-CZPQTISQ.js → chunk-BQWJ5ZR7.js} +10 -6
- package/dist/chunks/chunk-BQWJ5ZR7.js.map +7 -0
- package/dist/chunks/{chunk-ABJCSNZO.js → chunk-D3IONBBJ.js} +2 -2
- package/dist/chunks/{chunk-7JU7Z4XQ.js → chunk-D3W6CBJZ.js} +2 -2
- package/dist/chunks/{chunk-3SHUUBZJ.js → chunk-DONS3EZH.js} +3 -3
- package/dist/chunks/{chunk-W5CHVJBR.js → chunk-EQYQICUY.js} +54 -8
- package/dist/chunks/chunk-EQYQICUY.js.map +7 -0
- package/dist/chunks/{chunk-FB24AOIJ.js → chunk-H3SGA7G7.js} +5 -5
- package/dist/chunks/{chunk-ZXKYU6CH.js → chunk-HCNHKJDA.js} +2 -2
- package/dist/chunks/{chunk-UXEMIWYI.js → chunk-HITKWKYD.js} +11 -9
- package/dist/chunks/chunk-HITKWKYD.js.map +7 -0
- package/dist/chunks/{chunk-YYSZBD7S.js → chunk-HQ5YW2OJ.js} +2 -2
- package/dist/chunks/{chunk-GC2AUXG6.js → chunk-HZGQ7XYM.js} +2 -2
- package/dist/chunks/{chunk-WREA4RNR.js → chunk-I2TK65VR.js} +3 -3
- package/dist/chunks/chunk-IQXNJNDI.js +854 -0
- package/dist/chunks/chunk-IQXNJNDI.js.map +7 -0
- package/dist/chunks/{chunk-DZ4WN5XJ.js → chunk-JV4JR6TT.js} +3 -3
- package/dist/chunks/{chunk-3GJJG2FV.js → chunk-KBYSGB7E.js} +2 -2
- package/dist/chunks/chunk-KBYSGB7E.js.map +7 -0
- package/dist/chunks/{chunk-PF27MQY5.js → chunk-MOJBW5X2.js} +42 -3
- package/dist/chunks/chunk-MOJBW5X2.js.map +7 -0
- package/dist/chunks/{chunk-YJX27XBO.js → chunk-O7IREHJI.js} +104 -46
- package/dist/chunks/chunk-O7IREHJI.js.map +7 -0
- package/dist/chunks/{chunk-FRPNQZV2.js → chunk-ODYU3IJU.js} +81 -18
- package/dist/chunks/chunk-ODYU3IJU.js.map +7 -0
- package/dist/chunks/{chunk-LOLCTWJF.js → chunk-OTHMEDN6.js} +4 -4
- package/dist/chunks/{chunk-PXAICAUT.js → chunk-PBDDXBHY.js} +2 -1
- package/dist/chunks/chunk-PBDDXBHY.js.map +7 -0
- package/dist/chunks/{chunk-M6IRQ3QT.js → chunk-PH4PT6R4.js} +2 -2
- package/dist/chunks/{chunk-B54Z662X.js → chunk-PTZ5DKAB.js} +25 -5
- package/dist/chunks/chunk-PTZ5DKAB.js.map +7 -0
- package/dist/chunks/{chunk-RUO6L7RM.js → chunk-Q2JQ3RYZ.js} +3 -1
- package/dist/chunks/chunk-Q2JQ3RYZ.js.map +7 -0
- package/dist/chunks/{chunk-WYUV6WL3.js → chunk-QCCPR3U5.js} +4 -4
- package/dist/chunks/{chunk-GYPDGW27.js → chunk-QGP7AY2R.js} +4 -2
- package/dist/chunks/{chunk-GYPDGW27.js.map → chunk-QGP7AY2R.js.map} +2 -2
- package/dist/chunks/{chunk-7XRUMDV7.js → chunk-QQ7D6UAM.js} +2 -2
- package/dist/chunks/chunk-QRN433TI.js +19 -0
- package/dist/chunks/chunk-QRN433TI.js.map +7 -0
- package/dist/chunks/{chunk-PYQM7KPL.js → chunk-R2MMPHR2.js} +2 -2
- package/dist/chunks/{chunk-CXTTLBUV.js → chunk-R2XQ6AHT.js} +2 -2
- package/dist/chunks/{chunk-DV2JZSCI.js → chunk-SPCJXN4K.js} +14 -4
- package/dist/chunks/{chunk-DV2JZSCI.js.map → chunk-SPCJXN4K.js.map} +2 -2
- package/dist/chunks/{chunk-T5CU2GPZ.js → chunk-TNPZBMYC.js} +34 -10
- package/dist/chunks/chunk-TNPZBMYC.js.map +7 -0
- package/dist/chunks/{chunk-5SU3YXBS.js → chunk-UGYCAG6O.js} +1 -1
- package/dist/chunks/{chunk-5SU3YXBS.js.map → chunk-UGYCAG6O.js.map} +1 -1
- package/dist/chunks/{chunk-X3CHSIL2.js → chunk-V2IV4LYW.js} +3 -3
- package/dist/chunks/{chunk-QY7YK7M6.js → chunk-VR2LV4CA.js} +2 -2
- package/dist/chunks/chunk-WJJXODAB.js +82 -0
- package/dist/chunks/chunk-WJJXODAB.js.map +7 -0
- package/dist/chunks/{chunk-S3IRPDSO.js → chunk-WQ6LC2KK.js} +2 -2
- package/dist/chunks/{chunk-CYMDX3XP.js → chunk-WTLH5RY4.js} +2 -2
- package/dist/chunks/chunk-WTLH5RY4.js.map +7 -0
- package/dist/chunks/{chunk-BVJBYFHD.js → chunk-ZPI4QTOX.js} +2 -2
- package/dist/chunks/{chunk-3DUKKQHN.js → chunk-ZQMBS5SH.js} +5 -5
- package/dist/cli/decisions.js +1 -1
- package/dist/cli/mesh.js +2 -2
- package/dist/commands/fabric.d.ts +1 -1
- package/dist/commands/fabric.d.ts.map +1 -1
- package/dist/compaction/hook.d.ts +1 -1
- package/dist/compaction/hook.d.ts.map +1 -1
- package/dist/compaction/hook.js +6 -6
- package/dist/compaction/owner.js +7 -7
- package/dist/components/configuration.js +4 -4
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/core/action-registry.d.ts.map +1 -1
- package/dist/core/action-registry.js +7 -7
- package/dist/core/action-result.d.ts +10 -0
- package/dist/core/action-result.d.ts.map +1 -1
- package/dist/core/agent-dir.d.ts +1 -0
- package/dist/core/agent-dir.d.ts.map +1 -1
- package/dist/core/fabric-state-paths.d.ts.map +1 -1
- package/dist/core/host-sdk-runtime.d.ts +8 -0
- package/dist/core/host-sdk-runtime.d.ts.map +1 -0
- package/dist/core/host-sdk.d.ts +28 -0
- package/dist/core/host-sdk.d.ts.map +1 -0
- package/dist/core/host-sdk.js +11 -0
- package/dist/core/host-sdk.js.map +7 -0
- package/dist/core/provider-operations.js +1 -1
- package/dist/core/provider-operations.js.map +2 -2
- package/dist/core/session-context.d.ts +5 -0
- package/dist/core/session-context.d.ts.map +1 -1
- package/dist/core/shell-inbox.d.ts.map +1 -1
- package/dist/core/shell-jobs.d.ts +2 -0
- package/dist/core/shell-jobs.d.ts.map +1 -1
- package/dist/core/tool-ownership.d.ts.map +1 -1
- package/dist/core/tool-result-proxy.d.ts +2 -0
- package/dist/core/tool-result-proxy.d.ts.map +1 -1
- package/dist/durable/agent.d.ts +6 -0
- package/dist/durable/agent.d.ts.map +1 -1
- package/dist/durable/worker-host.d.ts.map +1 -1
- package/dist/durable/worker-host.js +48 -10
- package/dist/durable/worker-host.js.map +2 -2
- package/dist/durable.js +2 -2
- package/dist/durable.js.map +1 -1
- package/dist/entropy/index.js +8 -8
- package/dist/extension-bootstrap.js +17 -17
- package/dist/fabric-runtime-state.d.ts +2 -0
- package/dist/fabric-runtime-state.d.ts.map +1 -1
- package/dist/fabric-runtime-state.js +362 -101
- package/dist/fabric-runtime-state.js.map +4 -4
- package/dist/fabric-state.d.ts +2 -0
- package/dist/fabric-state.d.ts.map +1 -1
- package/dist/index.js +23 -21
- package/dist/index.js.map +1 -1
- package/dist/jev/auth.d.ts +2 -0
- package/dist/jev/auth.d.ts.map +1 -1
- package/dist/jev/client.d.ts.map +1 -1
- package/dist/jev/client.js +3 -3
- package/dist/jev/config.d.ts +5 -0
- package/dist/jev/config.d.ts.map +1 -1
- package/dist/jev/decision-profiles.d.ts +8 -0
- package/dist/jev/decision-profiles.d.ts.map +1 -0
- package/dist/jev/decision-schema.d.ts +35 -0
- package/dist/jev/decision-schema.d.ts.map +1 -0
- package/dist/jev/decision-types.d.ts +139 -0
- package/dist/jev/decision-types.d.ts.map +1 -0
- package/dist/jev/decisions.d.ts +27 -0
- package/dist/jev/decisions.d.ts.map +1 -0
- package/dist/jev/guest-types.d.ts +1 -1
- package/dist/jev/guest-types.d.ts.map +1 -1
- package/dist/jev/manager.d.ts +7 -0
- package/dist/jev/manager.d.ts.map +1 -1
- package/dist/jev/model-key.d.ts +3 -2
- package/dist/jev/model-key.d.ts.map +1 -1
- package/dist/jev/observation.js +7 -7
- package/dist/jev/routes.d.ts +11 -1
- package/dist/jev/routes.d.ts.map +1 -1
- package/dist/jev/types.d.ts +3 -2
- package/dist/jev/types.d.ts.map +1 -1
- package/dist/jev/validation.d.ts +34 -0
- package/dist/jev/validation.d.ts.map +1 -1
- package/dist/jev-fabric/resolve.d.ts +4 -0
- package/dist/jev-fabric/resolve.d.ts.map +1 -1
- package/dist/jev-fabric/resolve.js +1 -0
- package/dist/jev-fabric/resolve.js.map +2 -2
- package/dist/jev-fabric/serve.d.ts +5 -15
- package/dist/jev-fabric/serve.d.ts.map +1 -1
- package/dist/jev-fabric/serve.js +87 -56
- package/dist/jev-fabric/serve.js.map +2 -2
- package/dist/jev.d.ts +6 -2
- package/dist/jev.d.ts.map +1 -1
- package/dist/jev.js +37 -15
- package/dist/memory/digest.js +2 -2
- package/dist/memory/discovery.js +6 -6
- package/dist/memory/extractive-history.d.ts +3 -0
- package/dist/memory/extractive-history.d.ts.map +1 -1
- package/dist/memory/extractive-history.js +36 -7
- package/dist/memory/extractive-history.js.map +3 -3
- package/dist/memory/extractive-index.d.ts.map +1 -1
- package/dist/memory/file-worker.js +9 -9
- package/dist/memory/normalize.js +5 -5
- package/dist/memory/search.js +7 -7
- package/dist/memory/worker-provider.js +10 -10
- package/dist/memory.js +10 -10
- package/dist/native-codemode.d.ts.map +1 -1
- package/dist/protocol.d.ts +3 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +3 -1
- package/dist/providers/agents-provider.d.ts.map +1 -1
- package/dist/providers/captured-tools-provider.d.ts.map +1 -1
- package/dist/providers/jev-provider.d.ts +2 -0
- package/dist/providers/jev-provider.d.ts.map +1 -1
- package/dist/providers/jev-provider.js +12 -12
- package/dist/providers/memory-provider.js +9 -9
- package/dist/providers/pi-bash-cwd.d.ts +1 -1
- package/dist/providers/pi-bash-cwd.d.ts.map +1 -1
- package/dist/providers/pi-tools-provider.d.ts.map +1 -1
- package/dist/providers/write-preview.d.ts +1 -1
- package/dist/providers/write-preview.d.ts.map +1 -1
- package/dist/residency/host.js +16 -14
- package/dist/residency/pi-entry.js +16 -14
- package/dist/residency/pi-entry.js.map +1 -1
- package/dist/runners.js +1 -1
- package/dist/runtime/core-override-guest-types.js +2 -2
- package/dist/runtime/guest-types.d.ts +1 -1
- package/dist/runtime/guest-types.d.ts.map +1 -1
- package/dist/runtime/guest-types.js +1 -1
- package/dist/runtime/monty-runtime.js +3 -3
- package/dist/runtime/native-codemode-types.d.ts +1 -1
- package/dist/runtime/native-codemode-types.d.ts.map +1 -1
- package/dist/runtime/node-process-runtime.js +3 -3
- package/dist/runtime/quickjs-runtime.d.ts.map +1 -1
- package/dist/runtime/quickjs-runtime.js +2 -2
- package/dist/runtime/typescript-kernel.js +5 -5
- package/dist/storage/retention.d.ts.map +1 -1
- package/dist/topology/peer-presence.d.ts +56 -0
- package/dist/topology/peer-presence.d.ts.map +1 -0
- package/dist/type-error-guidance.js +1 -1
- package/dist/ui/controller.d.ts.map +1 -1
- package/dist/ui/conversation-chrome.js +2 -2
- package/dist/ui/conversation-host.js +1 -1
- package/dist/ui/conversation-native-reader.js +1 -1
- package/dist/ui/conversation.js +6 -6
- package/dist/ui/dashboard.js +3 -3
- package/dist/ui/settings-decision-profiles.d.ts +24 -0
- package/dist/ui/settings-decision-profiles.d.ts.map +1 -0
- package/dist/ui/settings-section-context.d.ts +1 -1
- package/dist/ui/settings-section-context.d.ts.map +1 -1
- package/dist/ui/settings-sections-agents.d.ts.map +1 -1
- package/dist/ui/settings-sections-decisions.d.ts +4 -0
- package/dist/ui/settings-sections-decisions.d.ts.map +1 -0
- package/dist/ui/settings-sections-lifecycle.d.ts.map +1 -1
- package/dist/ui/settings-sections.d.ts +1 -1
- package/dist/ui/settings-sections.d.ts.map +1 -1
- package/dist/ui/settings-submenus.d.ts +3 -1
- package/dist/ui/settings-submenus.d.ts.map +1 -1
- package/dist/ui/settings-values.d.ts.map +1 -1
- package/dist/ui/settings.d.ts.map +1 -1
- package/dist/ui/settings.js +224 -45
- package/dist/ui/settings.js.map +4 -4
- package/dist/verified/generated/authority-kernel.js +2 -2
- package/dist/verified/generated/kernel.js +2 -2
- package/dist/verified/generated/lifecycle-kernel.js +2 -2
- package/dist/verified/generated/manifest.json +7 -7
- package/dist/verified/generated/provider-kernel.js +2 -2
- package/dist/verified/generated/storage-kernel.js +2 -2
- package/dist/worker/options.d.ts.map +1 -1
- package/dist/worker/options.js +15 -0
- package/dist/worker/options.js.map +2 -2
- package/dist/worker.js +11 -1
- package/dist/worker.js.map +2 -2
- package/docs/agents.md +49 -0
- package/docs/architecture.md +1 -1
- package/docs/audit-trace.md +3 -1
- package/docs/background-tasks.md +4 -0
- package/docs/codemode-parity.md +3 -1
- package/docs/compaction.md +1 -1
- package/docs/configuration.md +91 -8
- package/docs/decision-profiles.schema.json +52 -0
- package/docs/decision-test-coverage.md +77 -0
- package/docs/durable-pi.md +9 -2
- package/docs/extractive-history.md +17 -2
- package/docs/jev-decisions.md +150 -0
- package/docs/jev.md +18 -5
- package/docs/prompt-cache.md +1 -1
- package/docs/provider-capabilities.md +1 -1
- package/docs/providers.md +4 -1
- package/docs/verified-kernels.md +1 -1
- package/node_modules/pi-coralbricks-provider/LICENSE +21 -0
- package/node_modules/pi-coralbricks-provider/README.md +306 -0
- package/node_modules/pi-coralbricks-provider/auth.ts +30 -0
- package/node_modules/pi-coralbricks-provider/custom-models.json +1 -0
- package/node_modules/pi-coralbricks-provider/deprecated-models.json +1 -0
- package/node_modules/pi-coralbricks-provider/guard.ts +155 -0
- package/node_modules/pi-coralbricks-provider/index.ts +662 -0
- package/node_modules/pi-coralbricks-provider/models.json +88 -0
- package/node_modules/pi-coralbricks-provider/package.json +74 -0
- package/node_modules/pi-coralbricks-provider/park.ts +122 -0
- package/node_modules/pi-coralbricks-provider/patch.json +34 -0
- package/node_modules/pi-coralbricks-provider/scripts/update-models.js +658 -0
- package/node_modules/pi-coralbricks-provider/settings.ts +143 -0
- package/node_modules/pi-coralbricks-provider/sync-policy.ts +309 -0
- package/package.json +23 -15
- package/scripts/test-verified-kernels.mjs +1 -1
- package/scripts/verified-kernels.mjs +1 -1
- package/skillsets/python/fabric-exec/SKILL.md +1 -1
- package/skillsets/python/fabric-exec/references/agents.md +1 -1
- package/skillsets/python/fabric-foreman/SKILL.md +1 -1
- package/skillsets/python/fabric-jev/SKILL.md +2 -2
- package/skillsets/typescript/fabric-exec/SKILL.md +1 -1
- package/skillsets/typescript/fabric-exec/references/agents.md +1 -0
- package/skillsets/typescript/fabric-foreman/SKILL.md +1 -1
- package/skillsets/typescript/fabric-jev/SKILL.md +2 -2
- package/dist/chunks/chunk-3GJJG2FV.js.map +0 -7
- package/dist/chunks/chunk-B54Z662X.js.map +0 -7
- package/dist/chunks/chunk-C7EEG6SM.js.map +0 -7
- package/dist/chunks/chunk-CYMDX3XP.js.map +0 -7
- package/dist/chunks/chunk-CZPQTISQ.js.map +0 -7
- package/dist/chunks/chunk-FRPNQZV2.js.map +0 -7
- package/dist/chunks/chunk-IAFI4A2I.js +0 -92
- package/dist/chunks/chunk-IAFI4A2I.js.map +0 -7
- package/dist/chunks/chunk-LEDY5G2V.js +0 -515
- package/dist/chunks/chunk-LEDY5G2V.js.map +0 -7
- package/dist/chunks/chunk-PF27MQY5.js.map +0 -7
- package/dist/chunks/chunk-PXAICAUT.js.map +0 -7
- package/dist/chunks/chunk-RUO6L7RM.js.map +0 -7
- package/dist/chunks/chunk-ST36EYHN.js.map +0 -7
- package/dist/chunks/chunk-T5CU2GPZ.js.map +0 -7
- package/dist/chunks/chunk-UXEMIWYI.js.map +0 -7
- package/dist/chunks/chunk-W5CHVJBR.js.map +0 -7
- package/dist/chunks/chunk-WHBJDTCR.js.map +0 -7
- package/dist/chunks/chunk-YJX27XBO.js.map +0 -7
- /package/dist/chunks/{chunk-X2TRSE7D.js.map → chunk-2YG4ZA2K.js.map} +0 -0
- /package/dist/chunks/{chunk-N2VKKA7O.js.map → chunk-4GNFBZPR.js.map} +0 -0
- /package/dist/chunks/{chunk-M5IN6DMF.js.map → chunk-56RFFBBO.js.map} +0 -0
- /package/dist/chunks/{chunk-DU6ZA44F.js.map → chunk-6EVAHJAR.js.map} +0 -0
- /package/dist/chunks/{chunk-ABJCSNZO.js.map → chunk-D3IONBBJ.js.map} +0 -0
- /package/dist/chunks/{chunk-7JU7Z4XQ.js.map → chunk-D3W6CBJZ.js.map} +0 -0
- /package/dist/chunks/{chunk-3SHUUBZJ.js.map → chunk-DONS3EZH.js.map} +0 -0
- /package/dist/chunks/{chunk-FB24AOIJ.js.map → chunk-H3SGA7G7.js.map} +0 -0
- /package/dist/chunks/{chunk-ZXKYU6CH.js.map → chunk-HCNHKJDA.js.map} +0 -0
- /package/dist/chunks/{chunk-YYSZBD7S.js.map → chunk-HQ5YW2OJ.js.map} +0 -0
- /package/dist/chunks/{chunk-GC2AUXG6.js.map → chunk-HZGQ7XYM.js.map} +0 -0
- /package/dist/chunks/{chunk-WREA4RNR.js.map → chunk-I2TK65VR.js.map} +0 -0
- /package/dist/chunks/{chunk-DZ4WN5XJ.js.map → chunk-JV4JR6TT.js.map} +0 -0
- /package/dist/chunks/{chunk-LOLCTWJF.js.map → chunk-OTHMEDN6.js.map} +0 -0
- /package/dist/chunks/{chunk-M6IRQ3QT.js.map → chunk-PH4PT6R4.js.map} +0 -0
- /package/dist/chunks/{chunk-WYUV6WL3.js.map → chunk-QCCPR3U5.js.map} +0 -0
- /package/dist/chunks/{chunk-7XRUMDV7.js.map → chunk-QQ7D6UAM.js.map} +0 -0
- /package/dist/chunks/{chunk-PYQM7KPL.js.map → chunk-R2MMPHR2.js.map} +0 -0
- /package/dist/chunks/{chunk-CXTTLBUV.js.map → chunk-R2XQ6AHT.js.map} +0 -0
- /package/dist/chunks/{chunk-X3CHSIL2.js.map → chunk-V2IV4LYW.js.map} +0 -0
- /package/dist/chunks/{chunk-QY7YK7M6.js.map → chunk-VR2LV4CA.js.map} +0 -0
- /package/dist/chunks/{chunk-S3IRPDSO.js.map → chunk-WQ6LC2KK.js.map} +0 -0
- /package/dist/chunks/{chunk-BVJBYFHD.js.map → chunk-ZPI4QTOX.js.map} +0 -0
- /package/dist/chunks/{chunk-3DUKKQHN.js.map → chunk-ZQMBS5SH.js.map} +0 -0
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isJevModelId
|
|
3
|
-
} from "./chunk-B54Z662X.js";
|
|
4
|
-
|
|
5
|
-
// src/jev/config.ts
|
|
6
|
-
var DEFAULT_JEV_CONFIG = {
|
|
7
|
-
enabled: true,
|
|
8
|
-
model: "jev-latest",
|
|
9
|
-
autoApprovalThreshold: 0.5,
|
|
10
|
-
credentialCommand: [],
|
|
11
|
-
requestTimeoutMs: 15e3,
|
|
12
|
-
maxRequestBytes: 131072,
|
|
13
|
-
maxConcurrentRuns: 4,
|
|
14
|
-
maxRetainedRuns: 64,
|
|
15
|
-
maxDurationMs: 9e5,
|
|
16
|
-
maxEvaluations: 1e3,
|
|
17
|
-
maxToolCalls: 1e4,
|
|
18
|
-
maxTokens: 1e6,
|
|
19
|
-
transport: "fabric"
|
|
20
|
-
};
|
|
21
|
-
function normalizeJevConfig(value) {
|
|
22
|
-
const input = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
23
|
-
const integer = (key, max, min = 1) => {
|
|
24
|
-
const v = input[key];
|
|
25
|
-
return typeof v === "number" && Number.isFinite(v) ? Math.max(min, Math.min(max, Math.floor(v))) : DEFAULT_JEV_CONFIG[key];
|
|
26
|
-
};
|
|
27
|
-
const command = input.credentialCommand;
|
|
28
|
-
return {
|
|
29
|
-
enabled: typeof input.enabled === "boolean" ? input.enabled : true,
|
|
30
|
-
// Bare aliases use the direct route; `~typesafe/...` and `typesafe/...` select OpenRouter decisions.
|
|
31
|
-
model: typeof input.model === "string" && isJevModelId(input.model) ? input.model : DEFAULT_JEV_CONFIG.model,
|
|
32
|
-
autoApprovalThreshold: typeof input.autoApprovalThreshold === "number" && Number.isFinite(input.autoApprovalThreshold) && input.autoApprovalThreshold >= 0 && input.autoApprovalThreshold <= 1 ? input.autoApprovalThreshold : DEFAULT_JEV_CONFIG.autoApprovalThreshold,
|
|
33
|
-
credentialCommand: Array.isArray(command) && command.length <= 16 && command.every((v) => typeof v === "string" && v.length > 0 && v.length <= 4096 && !v.includes("\0")) ? [...command] : [],
|
|
34
|
-
requestTimeoutMs: integer("requestTimeoutMs", 12e4, 100),
|
|
35
|
-
maxRequestBytes: integer("maxRequestBytes", 1048576, 1024),
|
|
36
|
-
maxConcurrentRuns: integer("maxConcurrentRuns", 16),
|
|
37
|
-
maxRetainedRuns: integer("maxRetainedRuns", 256),
|
|
38
|
-
maxDurationMs: integer("maxDurationMs", 864e5, 100),
|
|
39
|
-
maxEvaluations: integer("maxEvaluations", 1e5),
|
|
40
|
-
maxToolCalls: integer("maxToolCalls", 1e6),
|
|
41
|
-
maxTokens: integer("maxTokens", 1e8),
|
|
42
|
-
transport: input.transport === "auto" || input.transport === "jev-fabric" ? input.transport : "fabric"
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// src/core/approval-overrides.ts
|
|
47
|
-
var MAX_APPROVAL_ACTION_OVERRIDES = 256;
|
|
48
|
-
var PROVIDER = "[a-z][a-z0-9_-]*";
|
|
49
|
-
var EXACT_ACTION_REF = new RegExp(`^${PROVIDER}\\.[^\\s*]{1,256}$`);
|
|
50
|
-
var PROVIDER_WILDCARD = new RegExp(`^${PROVIDER}\\.\\*$`);
|
|
51
|
-
var isMode = (value) => value === "allow" || value === "ask" || value === "deny";
|
|
52
|
-
var approvalActionOverridesValue = (value) => {
|
|
53
|
-
if (value === void 0) return void 0;
|
|
54
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
55
|
-
throw new Error("approvals.actions must be an object of action ref \u2192 allow | ask | deny");
|
|
56
|
-
}
|
|
57
|
-
const entries = Object.entries(value);
|
|
58
|
-
if (entries.length > MAX_APPROVAL_ACTION_OVERRIDES) {
|
|
59
|
-
throw new Error(`approvals.actions supports at most ${MAX_APPROVAL_ACTION_OVERRIDES} entries`);
|
|
60
|
-
}
|
|
61
|
-
const overrides = {};
|
|
62
|
-
for (const [key, mode] of entries) {
|
|
63
|
-
if (!PROVIDER_WILDCARD.test(key) && (key.includes("*") || !EXACT_ACTION_REF.test(key))) {
|
|
64
|
-
throw new Error(
|
|
65
|
-
`Invalid approvals.actions key ${JSON.stringify(key)}: use an exact provider.action ref or provider.*`
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
if (!isMode(mode)) {
|
|
69
|
-
throw new Error(
|
|
70
|
-
`Invalid approvals.actions[${JSON.stringify(key)}]: expected "allow", "ask", or "deny"`
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
overrides[key] = mode;
|
|
74
|
-
}
|
|
75
|
-
return entries.length > 0 ? overrides : void 0;
|
|
76
|
-
};
|
|
77
|
-
var actionApprovalOverride = (overrides, ref) => {
|
|
78
|
-
if (!overrides) return void 0;
|
|
79
|
-
if (Object.hasOwn(overrides, ref)) return overrides[ref];
|
|
80
|
-
const dot = ref.indexOf(".");
|
|
81
|
-
if (dot <= 0) return void 0;
|
|
82
|
-
const wildcard = `${ref.slice(0, dot)}.*`;
|
|
83
|
-
return Object.hasOwn(overrides, wildcard) ? overrides[wildcard] : void 0;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export {
|
|
87
|
-
DEFAULT_JEV_CONFIG,
|
|
88
|
-
normalizeJevConfig,
|
|
89
|
-
approvalActionOverridesValue,
|
|
90
|
-
actionApprovalOverride
|
|
91
|
-
};
|
|
92
|
-
//# sourceMappingURL=chunk-IAFI4A2I.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/jev/config.ts", "../../src/core/approval-overrides.ts"],
|
|
4
|
-
"sourcesContent": ["import { isJevModelId } from \"./routes.js\";\n\nexport interface FabricJevConfig {\n enabled: boolean;\n model: string;\n /** Minimum Noul safety probability for Jev auto approvals (0\u20131). */\n autoApprovalThreshold: number;\n /** Trusted host configuration only; argv, never a shell expression. */\n credentialCommand: string[];\n requestTimeoutMs: number;\n maxRequestBytes: number;\n maxConcurrentRuns: number;\n maxRetainedRuns: number;\n maxDurationMs: number;\n maxEvaluations: number;\n maxToolCalls: number;\n maxTokens: number;\n /**\n * Where Jev program decisions are dispatched. `fabric` (default) is always\n * in-process. `auto` opts into one jev-fabric `serve` connection per program\n * run when a compatible binary is available (macOS/Linux), else in-process;\n * `jev-fabric` requires it. Direct calls and auto approvals stay in-process.\n */\n transport: \"auto\" | \"fabric\" | \"jev-fabric\";\n}\nexport const DEFAULT_JEV_CONFIG: FabricJevConfig = {\n enabled: true,\n model: \"jev-latest\",\n autoApprovalThreshold: 0.5,\n credentialCommand: [],\n requestTimeoutMs: 15_000,\n maxRequestBytes: 131_072,\n maxConcurrentRuns: 4,\n maxRetainedRuns: 64,\n maxDurationMs: 900_000,\n maxEvaluations: 1_000,\n maxToolCalls: 10_000,\n maxTokens: 1_000_000,\n transport: \"fabric\",\n};\nexport function normalizeJevConfig(value: unknown): FabricJevConfig {\n const input = value && typeof value === \"object\" && !Array.isArray(value)\n ? value as Record<string, unknown> : {};\n const integer = (key: keyof FabricJevConfig, max: number, min = 1): number => {\n const v = input[key];\n return typeof v === \"number\" && Number.isFinite(v)\n ? Math.max(min, Math.min(max, Math.floor(v))) : DEFAULT_JEV_CONFIG[key] as number;\n };\n const command = input.credentialCommand;\n return {\n enabled: typeof input.enabled === \"boolean\" ? input.enabled : true,\n // Bare aliases use the direct route; `~typesafe/...` and `typesafe/...` select OpenRouter decisions.\n model: typeof input.model === \"string\" && isJevModelId(input.model)\n ? input.model : DEFAULT_JEV_CONFIG.model,\n autoApprovalThreshold: typeof input.autoApprovalThreshold === \"number\" &&\n Number.isFinite(input.autoApprovalThreshold) && input.autoApprovalThreshold >= 0 && input.autoApprovalThreshold <= 1\n ? input.autoApprovalThreshold : DEFAULT_JEV_CONFIG.autoApprovalThreshold,\n credentialCommand: Array.isArray(command) && command.length <= 16 &&\n command.every(v => typeof v === \"string\" && v.length > 0 && v.length <= 4096 && !v.includes(\"\\0\"))\n ? [...command] as string[] : [],\n requestTimeoutMs: integer(\"requestTimeoutMs\", 120_000, 100),\n maxRequestBytes: integer(\"maxRequestBytes\", 1_048_576, 1024),\n maxConcurrentRuns: integer(\"maxConcurrentRuns\", 16),\n maxRetainedRuns: integer(\"maxRetainedRuns\", 256),\n maxDurationMs: integer(\"maxDurationMs\", 86_400_000, 100),\n maxEvaluations: integer(\"maxEvaluations\", 100_000),\n maxToolCalls: integer(\"maxToolCalls\", 1_000_000),\n maxTokens: integer(\"maxTokens\", 100_000_000),\n transport: input.transport === \"auto\" || input.transport === \"jev-fabric\" ? input.transport : \"fabric\",\n };\n}\n", "/** Per-action approval override: replaces the risk-class mode for matching refs. */\nexport type FabricActionApprovalMode = \"allow\" | \"ask\" | \"deny\";\n\nconst MAX_APPROVAL_ACTION_OVERRIDES = 256;\n\nconst PROVIDER = \"[a-z][a-z0-9_-]*\";\n// Exact refs are provider.action (actions may contain further dots, e.g. MCP).\nconst EXACT_ACTION_REF = new RegExp(`^${PROVIDER}\\\\.[^\\\\s*]{1,256}$`);\nconst PROVIDER_WILDCARD = new RegExp(`^${PROVIDER}\\\\.\\\\*$`);\n\nconst isMode = (value: unknown): value is FabricActionApprovalMode =>\n value === \"allow\" || value === \"ask\" || value === \"deny\";\n\n/**\n * Parse `approvals.actions`. Keys are exact refs (`delegate.dispatch`) or a\n * provider wildcard (`delegate.*`); every other form is a hard config error,\n * because a silently dropped `deny` would widen authority.\n */\nexport const approvalActionOverridesValue = (\n value: unknown,\n): Record<string, FabricActionApprovalMode> | undefined => {\n if (value === undefined) return undefined;\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new Error(\"approvals.actions must be an object of action ref \u2192 allow | ask | deny\");\n }\n const entries = Object.entries(value as Record<string, unknown>);\n if (entries.length > MAX_APPROVAL_ACTION_OVERRIDES) {\n throw new Error(`approvals.actions supports at most ${MAX_APPROVAL_ACTION_OVERRIDES} entries`);\n }\n const overrides: Record<string, FabricActionApprovalMode> = {};\n for (const [key, mode] of entries) {\n if (!PROVIDER_WILDCARD.test(key) && (key.includes(\"*\") || !EXACT_ACTION_REF.test(key))) {\n throw new Error(\n `Invalid approvals.actions key ${JSON.stringify(key)}: use an exact provider.action ref or provider.*`,\n );\n }\n if (!isMode(mode)) {\n throw new Error(\n `Invalid approvals.actions[${JSON.stringify(key)}]: expected \"allow\", \"ask\", or \"deny\"`,\n );\n }\n overrides[key] = mode;\n }\n return entries.length > 0 ? overrides : undefined;\n};\n\n/** Exact ref beats provider wildcard; undefined falls back to the risk-class mode. */\nexport const actionApprovalOverride = (\n overrides: Readonly<Record<string, FabricActionApprovalMode>> | undefined,\n ref: string,\n): FabricActionApprovalMode | undefined => {\n if (!overrides) return undefined;\n if (Object.hasOwn(overrides, ref)) return overrides[ref];\n const dot = ref.indexOf(\".\");\n if (dot <= 0) return undefined;\n const wildcard = `${ref.slice(0, dot)}.*`;\n return Object.hasOwn(overrides, wildcard) ? overrides[wildcard] : undefined;\n};\n"],
|
|
5
|
-
"mappings": "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",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,515 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
JevClient,
|
|
3
|
-
JevCredentials
|
|
4
|
-
} from "./chunk-W5CHVJBR.js";
|
|
5
|
-
import {
|
|
6
|
-
checkObserve,
|
|
7
|
-
jevObserveSchema
|
|
8
|
-
} from "./chunk-DU6ZA44F.js";
|
|
9
|
-
import {
|
|
10
|
-
checkSchema,
|
|
11
|
-
checkValue,
|
|
12
|
-
jsonText,
|
|
13
|
-
object
|
|
14
|
-
} from "./chunk-WHBJDTCR.js";
|
|
15
|
-
import {
|
|
16
|
-
validationMessage
|
|
17
|
-
} from "./chunk-C7EEG6SM.js";
|
|
18
|
-
import {
|
|
19
|
-
runAbortable
|
|
20
|
-
} from "./chunk-7TB7NXSL.js";
|
|
21
|
-
import {
|
|
22
|
-
ApprovalController,
|
|
23
|
-
FabricAutoApprovalClassifier,
|
|
24
|
-
FabricSessionApprovals
|
|
25
|
-
} from "./chunk-WYUV6WL3.js";
|
|
26
|
-
import {
|
|
27
|
-
resolveJevModelRoute
|
|
28
|
-
} from "./chunk-B54Z662X.js";
|
|
29
|
-
|
|
30
|
-
// src/providers/jev-provider.ts
|
|
31
|
-
import { Type } from "typebox";
|
|
32
|
-
|
|
33
|
-
// src/jev/manager.ts
|
|
34
|
-
import { randomUUID } from "node:crypto";
|
|
35
|
-
import { setTimeout as delay } from "node:timers/promises";
|
|
36
|
-
var prelude = `const input = JSON.parse(\u03C0.__jevInput);
|
|
37
|
-
const program = Object.freeze({
|
|
38
|
-
sleep: (ms: number): Promise<unknown> => tools.call({ ref: "jev.$sleep", args: { ms } }),
|
|
39
|
-
emit: (value: unknown): Promise<unknown> => tools.call({ ref: "jev.$emit", args: { value } }),
|
|
40
|
-
nextEvent: (): Promise<FabricJevHostEvent> => tools.call({ ref: "jev.$nextEvent" }) as Promise<FabricJevHostEvent>,
|
|
41
|
-
advise: (args: {eventId: string; message: string}): Promise<FabricJevAdviceResult> => tools.call({ ref: "jev.advise", args: {...args, id: \u03C0.__jevRunId} }) as Promise<FabricJevAdviceResult>,
|
|
42
|
-
});
|
|
43
|
-
`;
|
|
44
|
-
var JevProgramManager = class {
|
|
45
|
-
constructor(options) {
|
|
46
|
-
this.options = options;
|
|
47
|
-
}
|
|
48
|
-
#runs = /* @__PURE__ */ new Map();
|
|
49
|
-
#approvals = new FabricSessionApprovals();
|
|
50
|
-
#closed = false;
|
|
51
|
-
#starting = 0;
|
|
52
|
-
list() {
|
|
53
|
-
return [...this.#runs.values()].map(({ info }) => ({
|
|
54
|
-
id: info.id,
|
|
55
|
-
name: info.name,
|
|
56
|
-
state: info.state,
|
|
57
|
-
background: info.background,
|
|
58
|
-
startedAt: info.startedAt,
|
|
59
|
-
evaluations: info.evaluations,
|
|
60
|
-
toolCalls: info.toolCalls,
|
|
61
|
-
...info.observation ? { observation: structuredClone(info.observation) } : {}
|
|
62
|
-
}));
|
|
63
|
-
}
|
|
64
|
-
#get(id) {
|
|
65
|
-
const run = this.#runs.get(id);
|
|
66
|
-
if (!run) throw new Error("Unknown or expired Jev run ID");
|
|
67
|
-
return run;
|
|
68
|
-
}
|
|
69
|
-
status(id, after = 0) {
|
|
70
|
-
const info = this.#get(id).info;
|
|
71
|
-
return structuredClone({ ...info, events: info.events.filter((e) => e.sequence > after) });
|
|
72
|
-
}
|
|
73
|
-
async wait(id, signal) {
|
|
74
|
-
return structuredClone(await runAbortable(signal, () => this.#get(id).done));
|
|
75
|
-
}
|
|
76
|
-
/** Alias for wait. */
|
|
77
|
-
join(id, signal) {
|
|
78
|
-
return this.wait(id, signal);
|
|
79
|
-
}
|
|
80
|
-
async stop(id) {
|
|
81
|
-
const run = this.#get(id);
|
|
82
|
-
if (run.info.state === "running") run.controller.abort(new Error("Jev run stopped"));
|
|
83
|
-
return structuredClone(await run.done);
|
|
84
|
-
}
|
|
85
|
-
advise(id, eventId, message) {
|
|
86
|
-
if (typeof message !== "string" || !message.trim() || message.length > 2e3 || typeof eventId !== "string" || eventId.length > 256)
|
|
87
|
-
throw new Error("Advice requires a current eventId and 1\u20132000 message characters");
|
|
88
|
-
const run = this.#get(id);
|
|
89
|
-
if (!run.observation) throw new Error("Jev run has no observation subscription");
|
|
90
|
-
return run.observation.advise(eventId, message);
|
|
91
|
-
}
|
|
92
|
-
async launch(request, context, background) {
|
|
93
|
-
const { config, registry } = this.options;
|
|
94
|
-
if (this.#closed) throw new Error("Jev program manager is closed");
|
|
95
|
-
if (this.#starting + [...this.#runs.values()].filter((r) => r.info.state === "running").length >= config.jev.maxConcurrentRuns)
|
|
96
|
-
throw new Error("Jev concurrent run limit reached");
|
|
97
|
-
context.signal?.throwIfAborted();
|
|
98
|
-
this.#starting++;
|
|
99
|
-
let lease;
|
|
100
|
-
let starting = true;
|
|
101
|
-
try {
|
|
102
|
-
const { program: definition, input, observe } = structuredClone(request);
|
|
103
|
-
const observationHost = this.options.observationHost;
|
|
104
|
-
const observationRevision = observationHost?.revision;
|
|
105
|
-
if (observe !== void 0) {
|
|
106
|
-
checkObserve(observe);
|
|
107
|
-
if (!background) throw new Error("Observation requires jev.spawn; foreground runs cannot wait for their own turn to end");
|
|
108
|
-
if (!observationHost) throw new Error("Main lifecycle observation is unavailable in this host");
|
|
109
|
-
if (context.extensionContext.sessionManager?.getSessionId() !== observationHost.sessionId)
|
|
110
|
-
throw new Error("Jev observation is scoped to its owning Main session");
|
|
111
|
-
}
|
|
112
|
-
checkSchema(definition.inputSchema);
|
|
113
|
-
checkSchema(definition.outputSchema);
|
|
114
|
-
checkValue(definition.inputSchema, input, "Program input");
|
|
115
|
-
const requires = [...new Set(definition.requires)];
|
|
116
|
-
for (const ref of requires) {
|
|
117
|
-
if (!/^[a-z][a-z0-9_-]*\.[a-zA-Z0-9_.$-]+$/.test(ref) || ref.startsWith("jev.") && ref !== "jev.evaluate" && ref !== "jev.advise")
|
|
118
|
-
throw new Error("Programs require exact action refs; recursive Jev lifecycle calls are not allowed");
|
|
119
|
-
if (context.capabilityView && !Object.hasOwn(context.capabilityView.bindings, ref))
|
|
120
|
-
throw new Error(`Jev program cannot widen its caller's capabilities: ${ref}`);
|
|
121
|
-
if (!config.fullCodeMode && (ref.startsWith("pi.") || ref.startsWith("extensions.")))
|
|
122
|
-
throw new Error("Full-code tool access is disabled");
|
|
123
|
-
}
|
|
124
|
-
lease = await registry.acquireCapabilityView(requires, context);
|
|
125
|
-
if (!lease.satisfied || !lease.view) throw new Error(`Missing Jev program capabilities: ${lease.missing.join(", ")}`);
|
|
126
|
-
if (context.capabilityView) for (const ref of requires) {
|
|
127
|
-
const before = context.capabilityView.bindings[ref];
|
|
128
|
-
const after = lease.view.bindings[ref];
|
|
129
|
-
if (before.providerBindingId !== after.providerBindingId || before.descriptorHash !== after.descriptorHash)
|
|
130
|
-
throw new Error("Caller capability generation changed; relaunch with a fresh commitment");
|
|
131
|
-
}
|
|
132
|
-
const { TypeScriptKernelRuntime } = await import("../runtime/typescript-kernel.js");
|
|
133
|
-
const runtime = new TypeScriptKernelRuntime("quickjs");
|
|
134
|
-
const sources = await registry.guestTypeSources({ ...context, capabilityView: lease.view });
|
|
135
|
-
const { code, checked } = runtime.prepare(prelude + definition.code, true, [], sources, [], true);
|
|
136
|
-
if (checked.errors.length) throw new Error(`Jev program typecheck failed: ${checked.errors.map((e) => e.message).join("; ").slice(0, 2e3)}`);
|
|
137
|
-
const approval = new ApprovalController(config.approvals, context.extensionContext, this.#approvals, new FabricAutoApprovalClassifier(() => config.jev));
|
|
138
|
-
if (observe) await approval.approve({
|
|
139
|
-
ref: "jev.spawn",
|
|
140
|
-
provider: "jev",
|
|
141
|
-
name: "spawn",
|
|
142
|
-
description: "Observe future Main lifecycle events and explicitly selected content for a bounded Jev program",
|
|
143
|
-
inputSchema: {},
|
|
144
|
-
risk: "read"
|
|
145
|
-
}, { observe });
|
|
146
|
-
if (this.#closed) throw new Error("Jev program manager is closed");
|
|
147
|
-
context.signal?.throwIfAborted();
|
|
148
|
-
if (observe && observationHost.revision !== observationRevision)
|
|
149
|
-
throw new Error("Main lifecycle changed while preparing the observer; relaunch explicitly with current context");
|
|
150
|
-
const limits = definition.limits ?? {};
|
|
151
|
-
const bounded = (value, fallback, ceiling) => Math.min(value ?? fallback, ceiling);
|
|
152
|
-
const timeoutMs = bounded(limits.timeoutMs, 6e4, config.jev.maxDurationMs);
|
|
153
|
-
const maxEvaluations = bounded(limits.maxEvaluations, 100, config.jev.maxEvaluations);
|
|
154
|
-
const maxToolCalls = bounded(limits.maxToolCalls, 1e3, config.jev.maxToolCalls);
|
|
155
|
-
const maxTokens = bounded(limits.maxTokens, 1e5, config.jev.maxTokens);
|
|
156
|
-
const id = randomUUID();
|
|
157
|
-
const controller = new AbortController();
|
|
158
|
-
const info = {
|
|
159
|
-
id,
|
|
160
|
-
name: definition.name,
|
|
161
|
-
state: "running",
|
|
162
|
-
background,
|
|
163
|
-
startedAt: Date.now(),
|
|
164
|
-
evaluations: 0,
|
|
165
|
-
toolCalls: 0,
|
|
166
|
-
usage: { input_tokens: 0, output_tokens: 0 },
|
|
167
|
-
events: [],
|
|
168
|
-
nextSequence: 1,
|
|
169
|
-
logs: []
|
|
170
|
-
};
|
|
171
|
-
let budgetFailure;
|
|
172
|
-
const failBudget = (message) => {
|
|
173
|
-
budgetFailure = message;
|
|
174
|
-
queueMicrotask(() => controller.abort(new Error(message)));
|
|
175
|
-
throw new Error(message);
|
|
176
|
-
};
|
|
177
|
-
const observation = observe ? observationHost.subscribe(observe, { id, name: definition.name }, controller) : void 0;
|
|
178
|
-
if (observation) info.observation = observation.stats;
|
|
179
|
-
const runLease = lease;
|
|
180
|
-
lease = void 0;
|
|
181
|
-
const abort = () => controller.abort(new Error("Foreground caller cancelled"));
|
|
182
|
-
if (!background) context.signal?.addEventListener("abort", abort, { once: true });
|
|
183
|
-
let timedOut = false;
|
|
184
|
-
const timer = setTimeout(() => {
|
|
185
|
-
timedOut = true;
|
|
186
|
-
controller.abort(new Error("Jev deadline exceeded"));
|
|
187
|
-
}, timeoutMs);
|
|
188
|
-
let evaluating = false;
|
|
189
|
-
const audits = [];
|
|
190
|
-
const emit = (value) => {
|
|
191
|
-
jsonText(value, 4096, "Program event");
|
|
192
|
-
info.events.push({ sequence: info.nextSequence++, at: Date.now(), value });
|
|
193
|
-
if (info.events.length > 64) info.events.shift();
|
|
194
|
-
};
|
|
195
|
-
const run = { info, controller, observation, done: void 0 };
|
|
196
|
-
this.#runs.set(id, run);
|
|
197
|
-
this.#starting--;
|
|
198
|
-
starting = false;
|
|
199
|
-
this.#prune();
|
|
200
|
-
run.done = (async () => {
|
|
201
|
-
try {
|
|
202
|
-
await delay(0, void 0, { signal: controller.signal });
|
|
203
|
-
const result = await runtime.execute(code, async (rawRef, rawArgs, signal) => {
|
|
204
|
-
signal.throwIfAborted();
|
|
205
|
-
controller.signal.throwIfAborted();
|
|
206
|
-
if (budgetFailure) throw new Error(budgetFailure);
|
|
207
|
-
if (++info.toolCalls > maxToolCalls) return failBudget("Jev tool-call budget exhausted");
|
|
208
|
-
const ref = rawRef === "fabric.$call" ? rawArgs.ref : rawRef;
|
|
209
|
-
const args = rawRef === "fabric.$call" ? rawArgs.args ?? {} : rawArgs;
|
|
210
|
-
if (typeof ref !== "string" || !object(args)) throw new Error("Invalid Jev program tool call");
|
|
211
|
-
if (ref === "jev.$sleep") {
|
|
212
|
-
if (typeof args.ms !== "number" || !Number.isFinite(args.ms) || args.ms < 0 || args.ms > timeoutMs) throw new Error("Invalid program.sleep duration");
|
|
213
|
-
await delay(args.ms, void 0, { signal });
|
|
214
|
-
return null;
|
|
215
|
-
}
|
|
216
|
-
if (ref === "jev.$emit") {
|
|
217
|
-
emit(args.value);
|
|
218
|
-
return null;
|
|
219
|
-
}
|
|
220
|
-
if (ref === "jev.$nextEvent") {
|
|
221
|
-
if (!observation) throw new Error("program.nextEvent requires observe on jev.spawn");
|
|
222
|
-
return observation.next();
|
|
223
|
-
}
|
|
224
|
-
if (ref === "jev.advise" && args.id !== id) throw new Error("A Jev program can only advise through its own run");
|
|
225
|
-
if (!Object.hasOwn(runLease.view.bindings, ref)) throw new Error(`Capability not granted to Jev program: ${ref}`);
|
|
226
|
-
if (ref === "jev.evaluate") {
|
|
227
|
-
if (evaluating) throw new Error("One Jev evaluation may be in flight per program; batch independent questions in one request");
|
|
228
|
-
if (info.evaluations >= maxEvaluations || info.usage.input_tokens + info.usage.output_tokens >= maxTokens)
|
|
229
|
-
return failBudget("Jev inference budget exhausted");
|
|
230
|
-
info.evaluations++;
|
|
231
|
-
evaluating = true;
|
|
232
|
-
}
|
|
233
|
-
try {
|
|
234
|
-
const value = await registry.invoke(ref, args, {
|
|
235
|
-
cwd: context.cwd,
|
|
236
|
-
extensionContext: context.extensionContext,
|
|
237
|
-
signal,
|
|
238
|
-
capabilityView: runLease.view,
|
|
239
|
-
...context.effectPolicy ? { effectPolicy: context.effectPolicy } : {},
|
|
240
|
-
parentToolCallId: `jev:${id}`,
|
|
241
|
-
nestedToolCallId: `jev:${id}:${info.toolCalls}`,
|
|
242
|
-
update() {
|
|
243
|
-
},
|
|
244
|
-
activity() {
|
|
245
|
-
},
|
|
246
|
-
attachMedia() {
|
|
247
|
-
},
|
|
248
|
-
attachPreview() {
|
|
249
|
-
},
|
|
250
|
-
authorize: async (action) => {
|
|
251
|
-
await this.options.authorize?.(action.ref, `jev:${id}`);
|
|
252
|
-
},
|
|
253
|
-
approve: async (action, prepared) => {
|
|
254
|
-
if (action.ref === "schema.commit") {
|
|
255
|
-
await approval.approve({ ...action, risk: "write" }, prepared);
|
|
256
|
-
await approval.approve({ ...action, risk: "execute" }, prepared);
|
|
257
|
-
} else await approval.approve(action, prepared);
|
|
258
|
-
},
|
|
259
|
-
audits,
|
|
260
|
-
maxResultChars: ref === "jev.evaluate" ? 1048576 : config.executor.maxNestedResultChars
|
|
261
|
-
});
|
|
262
|
-
if (ref === "jev.evaluate") {
|
|
263
|
-
const response = value;
|
|
264
|
-
info.usage.input_tokens += response.usage.input_tokens;
|
|
265
|
-
info.usage.output_tokens += response.usage.output_tokens;
|
|
266
|
-
if (info.usage.input_tokens + info.usage.output_tokens > maxTokens)
|
|
267
|
-
return failBudget("Jev reported-token budget exhausted");
|
|
268
|
-
}
|
|
269
|
-
return value;
|
|
270
|
-
} finally {
|
|
271
|
-
if (ref === "jev.evaluate") evaluating = false;
|
|
272
|
-
if (audits.length > 64) audits.splice(0, audits.length - 64);
|
|
273
|
-
}
|
|
274
|
-
}, {
|
|
275
|
-
timeoutMs,
|
|
276
|
-
memoryLimitBytes: Math.min(config.executor.memoryLimitBytes, 64 * 1024 * 1024),
|
|
277
|
-
maxCpuSliceMs: 100,
|
|
278
|
-
maxPendingTimers: 128,
|
|
279
|
-
maxLogChars: 4096,
|
|
280
|
-
strings: { __jevInput: JSON.stringify(input), __jevRunId: id },
|
|
281
|
-
signal: controller.signal
|
|
282
|
-
});
|
|
283
|
-
info.logs = result.logs;
|
|
284
|
-
if (budgetFailure) {
|
|
285
|
-
info.state = "failed";
|
|
286
|
-
info.error = budgetFailure;
|
|
287
|
-
} else if (timedOut || result.terminationReason === "timed_out") {
|
|
288
|
-
info.state = "timed_out";
|
|
289
|
-
info.error = result.error ?? "Jev deadline exceeded";
|
|
290
|
-
} else if (controller.signal.aborted || result.terminationReason === "aborted") {
|
|
291
|
-
info.state = "cancelled";
|
|
292
|
-
} else if (result.terminationReason !== "completed") {
|
|
293
|
-
info.state = "failed";
|
|
294
|
-
info.error = result.error ?? "Jev program failed";
|
|
295
|
-
} else {
|
|
296
|
-
checkValue(definition.outputSchema, result.value, "Program output");
|
|
297
|
-
info.result = result.value;
|
|
298
|
-
info.state = "completed";
|
|
299
|
-
}
|
|
300
|
-
} catch (error) {
|
|
301
|
-
info.state = budgetFailure ? "failed" : timedOut ? "timed_out" : controller.signal.aborted ? "cancelled" : "failed";
|
|
302
|
-
info.error = (budgetFailure ?? (error instanceof Error ? error.message : "Jev program failed")).slice(0, 2e3);
|
|
303
|
-
} finally {
|
|
304
|
-
clearTimeout(timer);
|
|
305
|
-
observation?.close();
|
|
306
|
-
context.signal?.removeEventListener("abort", abort);
|
|
307
|
-
await registry.endInvocation(`jev:${id}`).catch(() => void 0);
|
|
308
|
-
await runLease.release();
|
|
309
|
-
info.endedAt = Date.now();
|
|
310
|
-
this.#prune();
|
|
311
|
-
}
|
|
312
|
-
return info;
|
|
313
|
-
})();
|
|
314
|
-
return background ? this.status(id) : structuredClone(await run.done);
|
|
315
|
-
} finally {
|
|
316
|
-
if (starting) this.#starting--;
|
|
317
|
-
await lease?.release();
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
#prune() {
|
|
321
|
-
for (const [id, run] of this.#runs) {
|
|
322
|
-
if (this.#runs.size <= this.options.config.jev.maxRetainedRuns) break;
|
|
323
|
-
if (run.info.state !== "running") this.#runs.delete(id);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
stopAll() {
|
|
327
|
-
for (const run of this.#runs.values()) if (run.info.state === "running") run.controller.abort(new Error("Jev provider closed"));
|
|
328
|
-
}
|
|
329
|
-
async close() {
|
|
330
|
-
this.#closed = true;
|
|
331
|
-
const running = [...this.#runs.values()].filter((r) => r.info.state === "running");
|
|
332
|
-
this.stopAll();
|
|
333
|
-
await Promise.all(running.map((r) => r.done));
|
|
334
|
-
this.#runs.clear();
|
|
335
|
-
}
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
// src/providers/jev-provider.ts
|
|
339
|
-
var description = Type.Union([Type.String(), Type.Array(Type.Unknown()), Type.Record(Type.String(), Type.Unknown())]);
|
|
340
|
-
var question = Type.Union([
|
|
341
|
-
Type.Object({ type: Type.Literal("noul"), instructions: description, criteria: Type.Optional(Type.Object({ true: Type.Optional(description), false: Type.Optional(description) }, { additionalProperties: false })) }, { additionalProperties: false }),
|
|
342
|
-
Type.Object({ type: Type.Literal("choice"), instructions: description, criteria: Type.Record(Type.String(), Type.Union([description, Type.Null()]), { minProperties: 1, maxProperties: 255 }) }, { additionalProperties: false }),
|
|
343
|
-
Type.Object({ type: Type.Literal("score"), instructions: description, criteria: Type.Array(description, { minItems: 2, maxItems: 10 }) }, { additionalProperties: false })
|
|
344
|
-
]);
|
|
345
|
-
var jevRequestSchema = Type.Object({
|
|
346
|
-
state: description,
|
|
347
|
-
questions: Type.Record(Type.String(), question, { minProperties: 1, maxProperties: 128 }),
|
|
348
|
-
model: Type.Optional(Type.String({ minLength: 1, maxLength: 128 }))
|
|
349
|
-
}, { additionalProperties: false });
|
|
350
|
-
var jevLaunchSchema = Type.Object({
|
|
351
|
-
program: Type.Object({
|
|
352
|
-
name: Type.String({ minLength: 1, maxLength: 128 }),
|
|
353
|
-
code: Type.String({ minLength: 1, maxLength: 65536 }),
|
|
354
|
-
inputSchema: Type.Record(Type.String(), Type.Unknown()),
|
|
355
|
-
outputSchema: Type.Record(Type.String(), Type.Unknown()),
|
|
356
|
-
requires: Type.Array(Type.String({ minLength: 3, maxLength: 256 }), { maxItems: 64, uniqueItems: true }),
|
|
357
|
-
limits: Type.Optional(Type.Object({
|
|
358
|
-
timeoutMs: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
359
|
-
maxEvaluations: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
360
|
-
maxToolCalls: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
361
|
-
maxTokens: Type.Optional(Type.Integer({ minimum: 1 }))
|
|
362
|
-
}, { additionalProperties: false }))
|
|
363
|
-
}, { additionalProperties: false }),
|
|
364
|
-
input: Type.Unknown(),
|
|
365
|
-
observe: Type.Optional(jevObserveSchema)
|
|
366
|
-
}, { additionalProperties: false });
|
|
367
|
-
var idSchema = Type.Object({ id: Type.String({ minLength: 1, maxLength: 128 }) }, { additionalProperties: false });
|
|
368
|
-
var statusSchema = Type.Object({
|
|
369
|
-
id: Type.Optional(Type.String({ minLength: 1, maxLength: 128 })),
|
|
370
|
-
after: Type.Optional(Type.Integer({ minimum: 0 }))
|
|
371
|
-
}, { additionalProperties: false });
|
|
372
|
-
var jevAdviceSchema = Type.Object({
|
|
373
|
-
id: Type.String({ minLength: 1, maxLength: 128 }),
|
|
374
|
-
eventId: Type.String({ minLength: 1, maxLength: 256 }),
|
|
375
|
-
message: Type.String({ minLength: 1, maxLength: 2e3 })
|
|
376
|
-
}, { additionalProperties: false });
|
|
377
|
-
var JEV_ACTION_DESCRIPTORS = [
|
|
378
|
-
{ name: "evaluate", description: "Ask Jev typed Choice, Noul (probability of yes), and Score questions over shared state. No generated text. Batch independent questions. Sends state to TypeSafe and consumes API credits; no automatic retries.", inputSchema: jevRequestSchema, risk: "network", effect: { kind: "emission", resources: ["typesafe:inference"], ordering: "unknown" } },
|
|
379
|
-
{ name: "run", description: "Run a bounded TypeScript shell orchestrator or typed-decision program in the foreground. Returns a terminal run envelope with schema-validated result or error. Globals: input, jev.evaluate, program.sleep(ms), program.emit(value), and Fabric tools restricted to exact requires. Use granted pi.bash and tasks.wait/watch for shell orchestration; maxEvaluations:0 disables program inference. No automatic judgments, host imports or secrets.", inputSchema: jevLaunchSchema, risk: "execute" },
|
|
380
|
-
{ name: "spawn", description: "Launch a session-owned background Jev program. Optional observe requires read approval and subscribes to Main lifecycle events; program.nextEvent waits without polling and shares only explicitly selected bounded context. program.advise needs observe.delivery and requires jev.advise. Use status, wait/join, and stop; not restart-durable.", inputSchema: jevLaunchSchema, risk: "execute" },
|
|
381
|
-
{ name: "status", description: "Without id: credential configuration status (never retrieves secrets) and run summaries. With id: state, usage, bounded events after sequence, logs, result/error. Retains at most 64 events; nextSequence allows detecting gaps.", inputSchema: statusSchema, risk: "read" },
|
|
382
|
-
{ name: "wait", description: "Wait for a background Jev program's terminal run envelope. Cancelling the wait does not cancel the program.", inputSchema: idSchema, risk: "read" },
|
|
383
|
-
{ name: "join", description: "Alias for jev.wait: wait for a background Jev program's terminal run envelope without cancelling the program when the wait is cancelled.", inputSchema: idSchema, risk: "read" },
|
|
384
|
-
{ name: "advise", description: "Deliver bounded advice from an observing Jev run to Main. Requires its current consumed eventId, explicit observe.delivery, freshness, message budget, and the per-input feedback gate. The program helper program.advise supplies its own id. Subject to agent approvals; returns delivered and an optional suppression reason.", inputSchema: jevAdviceSchema, risk: "agent", effect: { kind: "emission", resources: ["main:messages"], ordering: "ordered" } },
|
|
385
|
-
{ name: "stop", description: "Cancel a Jev program and await sandbox cleanup. Idempotent for retained terminal runs; already-issued external effects cannot be undone.", inputSchema: idSchema, risk: "execute" }
|
|
386
|
-
];
|
|
387
|
-
var JevProvider = class {
|
|
388
|
-
name = "jev";
|
|
389
|
-
description = "Shell-first TypeScript orchestration with explicit typed Jev decisions";
|
|
390
|
-
manager;
|
|
391
|
-
client;
|
|
392
|
-
route;
|
|
393
|
-
/** One jev-fabric `serve` connection per program run: one client, one budget, like a Bend program. */
|
|
394
|
-
#runs = /* @__PURE__ */ new Map();
|
|
395
|
-
#transport;
|
|
396
|
-
#jevFabric;
|
|
397
|
-
constructor(options, client) {
|
|
398
|
-
this.#jevFabric = options.jevFabric;
|
|
399
|
-
this.manager = new JevProgramManager(options);
|
|
400
|
-
this.route = resolveJevModelRoute(options.config.jev.model).route;
|
|
401
|
-
this.client = client ?? new JevClient(
|
|
402
|
-
options.config.jev,
|
|
403
|
-
void 0,
|
|
404
|
-
new JevCredentials(options.config.jev.credentialCommand, process.env, options.credentialSource, this.route.envKeys),
|
|
405
|
-
this.route
|
|
406
|
-
);
|
|
407
|
-
}
|
|
408
|
-
async list(request) {
|
|
409
|
-
const query = request.query?.toLowerCase();
|
|
410
|
-
return JEV_ACTION_DESCRIPTORS.filter((d) => !query || `${d.name} ${d.description}`.toLowerCase().includes(query));
|
|
411
|
-
}
|
|
412
|
-
async describe(name) {
|
|
413
|
-
return JEV_ACTION_DESCRIPTORS.find((d) => d.name === name);
|
|
414
|
-
}
|
|
415
|
-
async invoke(name, args, context) {
|
|
416
|
-
const descriptor = await this.describe(name);
|
|
417
|
-
if (!descriptor) throw new Error(`Unknown Jev action: ${name}`);
|
|
418
|
-
const invalid = validationMessage(descriptor.inputSchema, args);
|
|
419
|
-
if (invalid) throw new Error(`Invalid jev.${name} arguments: ${invalid}`);
|
|
420
|
-
switch (name) {
|
|
421
|
-
case "evaluate": {
|
|
422
|
-
const dispatch = await this.#dispatchFor(context.parentToolCallId);
|
|
423
|
-
this.#transport = dispatch ? "jev-fabric" : "fabric";
|
|
424
|
-
return this.client.evaluate(args, context.signal ?? new AbortController().signal, dispatch);
|
|
425
|
-
}
|
|
426
|
-
case "run":
|
|
427
|
-
return this.manager.launch(args, context, false);
|
|
428
|
-
case "spawn":
|
|
429
|
-
return this.manager.launch(args, context, true);
|
|
430
|
-
case "status":
|
|
431
|
-
return typeof args.id === "string" ? this.manager.status(args.id, args.after) : {
|
|
432
|
-
credentials: this.client.credentials.status(),
|
|
433
|
-
model: this.client.config.model,
|
|
434
|
-
route: this.route.id,
|
|
435
|
-
runs: this.manager.list(),
|
|
436
|
-
transport: { configured: this.client.config.transport, ...this.#transport ? { last: this.#transport } : {} }
|
|
437
|
-
};
|
|
438
|
-
case "join":
|
|
439
|
-
case "wait":
|
|
440
|
-
return this.manager.wait(args.id, context.signal);
|
|
441
|
-
case "advise":
|
|
442
|
-
return this.manager.advise(args.id, args.eventId, args.message);
|
|
443
|
-
case "stop":
|
|
444
|
-
return this.manager.stop(args.id);
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
/**
|
|
448
|
-
* Program decisions go through the run's own jev-fabric connection when
|
|
449
|
-
* configured and available; direct calls stay in-process. `auto` falls back
|
|
450
|
-
* to in-process only when no suitable binary resolves, never after a request fails.
|
|
451
|
-
*/
|
|
452
|
-
async #dispatchFor(scope) {
|
|
453
|
-
const transport = this.client.config.transport;
|
|
454
|
-
if (transport === "fabric" || !scope?.startsWith("jev:")) return void 0;
|
|
455
|
-
const bridge = this.#jevFabric;
|
|
456
|
-
if (!bridge) {
|
|
457
|
-
if (transport === "jev-fabric") throw new Error("jev.transport jev-fabric needs jev-fabric, which runs on macOS and Linux outside managed hosts");
|
|
458
|
-
return void 0;
|
|
459
|
-
}
|
|
460
|
-
let pending = this.#runs.get(scope);
|
|
461
|
-
if (!pending) {
|
|
462
|
-
pending = (async () => {
|
|
463
|
-
let binary;
|
|
464
|
-
try {
|
|
465
|
-
binary = (await bridge.resolve("jev")).path;
|
|
466
|
-
} catch (error) {
|
|
467
|
-
if (transport === "jev-fabric") throw error;
|
|
468
|
-
return void 0;
|
|
469
|
-
}
|
|
470
|
-
const { JevFabricServe } = await import("../jev-fabric/serve.js");
|
|
471
|
-
return JevFabricServe.open(binary, {
|
|
472
|
-
home: bridge.home,
|
|
473
|
-
cwd: bridge.options.cwd,
|
|
474
|
-
timeoutMs: 864e5,
|
|
475
|
-
evaluations: this.client.config.maxEvaluations,
|
|
476
|
-
tokens: this.client.config.maxTokens
|
|
477
|
-
});
|
|
478
|
-
})();
|
|
479
|
-
pending.catch(() => this.#runs.delete(scope));
|
|
480
|
-
this.#runs.set(scope, pending);
|
|
481
|
-
}
|
|
482
|
-
const serve = await pending;
|
|
483
|
-
if (!serve) return void 0;
|
|
484
|
-
const provider = this.route.id === "vercel-ai-gateway" ? "vercel" : this.route.id;
|
|
485
|
-
return (request, credential, signal) => serve.request("jev", {
|
|
486
|
-
request,
|
|
487
|
-
provider,
|
|
488
|
-
credential,
|
|
489
|
-
timeoutMs: this.client.config.requestTimeoutMs
|
|
490
|
-
}, signal);
|
|
491
|
-
}
|
|
492
|
-
async invocationEnded(parentToolCallId) {
|
|
493
|
-
const pending = this.#runs.get(parentToolCallId);
|
|
494
|
-
if (!pending) return;
|
|
495
|
-
this.#runs.delete(parentToolCallId);
|
|
496
|
-
await (await pending.catch(() => void 0))?.close();
|
|
497
|
-
}
|
|
498
|
-
async close() {
|
|
499
|
-
await this.manager.close();
|
|
500
|
-
this.client.close();
|
|
501
|
-
const connections = [...this.#runs.values()];
|
|
502
|
-
this.#runs.clear();
|
|
503
|
-
await Promise.allSettled(connections.map(async (pending) => (await pending)?.close()));
|
|
504
|
-
}
|
|
505
|
-
};
|
|
506
|
-
|
|
507
|
-
export {
|
|
508
|
-
JevProgramManager,
|
|
509
|
-
jevRequestSchema,
|
|
510
|
-
jevLaunchSchema,
|
|
511
|
-
jevAdviceSchema,
|
|
512
|
-
JEV_ACTION_DESCRIPTORS,
|
|
513
|
-
JevProvider
|
|
514
|
-
};
|
|
515
|
-
//# sourceMappingURL=chunk-LEDY5G2V.js.map
|