@e4779/pi-fabric 0.102.0-fork.16 → 0.105.0-fork.18
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 +44 -13
- package/THIRD_PARTY_NOTICES.md +10 -2
- package/dist/activity/store.d.ts +3 -0
- package/dist/activity/store.d.ts.map +1 -1
- package/dist/activity/workflow-items.d.ts +33 -0
- package/dist/activity/workflow-items.d.ts.map +1 -0
- package/dist/actors/binding-store.d.ts.map +1 -1
- package/dist/actors/manager.d.ts +6 -0
- package/dist/actors/manager.d.ts.map +1 -1
- package/dist/actors/mesh-monitor.d.ts +2 -2
- package/dist/actors/mesh-monitor.d.ts.map +1 -1
- package/dist/actors/registry-store.d.ts.map +1 -1
- package/dist/actors/types.d.ts +11 -0
- package/dist/actors/types.d.ts.map +1 -1
- package/dist/agents/child-env.d.ts +29 -0
- package/dist/agents/child-env.d.ts.map +1 -0
- package/dist/agents/fork-seed.d.ts +21 -0
- package/dist/agents/fork-seed.d.ts.map +1 -0
- package/dist/agents/handoff.d.ts +7 -1
- package/dist/agents/handoff.d.ts.map +1 -1
- package/dist/agents/hosted-run.d.ts +63 -0
- package/dist/agents/hosted-run.d.ts.map +1 -0
- package/dist/agents/manager.d.ts +21 -1
- package/dist/agents/manager.d.ts.map +1 -1
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents/runner-notice.d.ts +7 -0
- package/dist/agents/runner-notice.d.ts.map +1 -0
- package/dist/agents/runner-protocol.d.ts +158 -0
- package/dist/agents/runner-protocol.d.ts.map +1 -0
- package/dist/agents/runner-registry.d.ts +223 -0
- package/dist/agents/runner-registry.d.ts.map +1 -0
- package/dist/agents/transports/process-transport.d.ts.map +1 -1
- package/dist/agents/transports/process-utils.d.ts +4 -1
- package/dist/agents/transports/process-utils.d.ts.map +1 -1
- package/dist/agents/types.d.ts +89 -4
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/agents/worktree-manager.d.ts +21 -0
- package/dist/agents/worktree-manager.d.ts.map +1 -1
- package/dist/agents/write-guard.d.ts +16 -0
- package/dist/agents/write-guard.d.ts.map +1 -0
- package/dist/agents/write-guard.js +13 -0
- package/dist/agents/write-guard.js.map +7 -0
- package/dist/agents.js +13 -12
- package/dist/agents.js.map +1 -1
- package/dist/assessment.d.ts +3 -0
- package/dist/assessment.d.ts.map +1 -0
- package/dist/assessment.js +15 -0
- package/dist/assessment.js.map +7 -0
- package/dist/audit/assessment.d.ts +74 -0
- package/dist/audit/assessment.d.ts.map +1 -0
- package/dist/audit/details.d.ts +4 -0
- package/dist/audit/details.d.ts.map +1 -1
- package/dist/audit/index.d.ts +1 -0
- package/dist/audit/index.d.ts.map +1 -1
- package/dist/audit/projection.d.ts +2 -1
- package/dist/audit/projection.d.ts.map +1 -1
- package/dist/audit/trace.d.ts +16 -1
- package/dist/audit/trace.d.ts.map +1 -1
- package/dist/cache/leases.d.ts +2 -1
- package/dist/cache/leases.d.ts.map +1 -1
- package/dist/capture/interceptor.d.ts.map +1 -1
- package/dist/chunks/chunk-2USMWEE6.js +81 -0
- package/dist/chunks/chunk-2USMWEE6.js.map +7 -0
- package/dist/chunks/chunk-2Y24ML7H.js +115 -0
- package/dist/chunks/chunk-2Y24ML7H.js.map +7 -0
- package/dist/chunks/chunk-3GJJG2FV.js +1329 -0
- package/dist/chunks/chunk-3GJJG2FV.js.map +7 -0
- package/dist/chunks/{chunk-5VTBHJN3.js → chunk-3KDUMDPZ.js} +153 -29
- package/dist/chunks/chunk-3KDUMDPZ.js.map +7 -0
- package/dist/chunks/chunk-4RTHQGES.js +189 -0
- package/dist/chunks/chunk-4RTHQGES.js.map +7 -0
- package/dist/chunks/{chunk-ZZ66L3W5.js → chunk-5MNLVHF5.js} +30 -7
- package/dist/chunks/chunk-5MNLVHF5.js.map +7 -0
- package/dist/chunks/{chunk-RAO6TQFP.js → chunk-5XBYFSI5.js} +26 -6
- package/dist/chunks/chunk-5XBYFSI5.js.map +7 -0
- package/dist/chunks/chunk-6VXPACGC.js +6490 -0
- package/dist/chunks/chunk-6VXPACGC.js.map +7 -0
- package/dist/chunks/{chunk-J2HV2URQ.js → chunk-7EYJE4TW.js} +1 -1
- package/dist/chunks/{chunk-J2HV2URQ.js.map → chunk-7EYJE4TW.js.map} +2 -2
- package/dist/chunks/{chunk-57CMH4SW.js → chunk-7JU7Z4XQ.js} +2 -2
- package/dist/chunks/chunk-7QKKLBHJ.js +33 -0
- package/dist/chunks/chunk-7QKKLBHJ.js.map +7 -0
- package/dist/chunks/chunk-7XRUMDV7.js +235 -0
- package/dist/chunks/chunk-7XRUMDV7.js.map +7 -0
- package/dist/chunks/{chunk-DUJ46TIP.js → chunk-ABJCSNZO.js} +4 -4
- package/dist/chunks/chunk-B2Y4364O.js +78 -0
- package/dist/chunks/chunk-B2Y4364O.js.map +7 -0
- package/dist/chunks/{chunk-4TKPBEPB.js → chunk-BVJBYFHD.js} +9 -3
- package/dist/chunks/{chunk-4TKPBEPB.js.map → chunk-BVJBYFHD.js.map} +2 -2
- package/dist/chunks/{chunk-KP4ANT6L.js → chunk-C7EEG6SM.js} +2 -2
- package/dist/chunks/{chunk-NHMICIEU.js → chunk-CCHZXF6K.js} +3 -3
- package/dist/chunks/{chunk-W63E3WEO.js → chunk-CXTTLBUV.js} +3 -2
- package/dist/chunks/chunk-CXTTLBUV.js.map +7 -0
- package/dist/chunks/{chunk-HOX6VW45.js → chunk-CYMDX3XP.js} +1 -1
- package/dist/chunks/{chunk-HOX6VW45.js.map → chunk-CYMDX3XP.js.map} +1 -1
- package/dist/chunks/chunk-DK35W6U7.js +259 -0
- package/dist/chunks/chunk-DK35W6U7.js.map +7 -0
- package/dist/chunks/{chunk-5JN5AWNV.js → chunk-DZ4WN5XJ.js} +3 -3
- package/dist/chunks/{chunk-QHYBSIIO.js → chunk-FB24AOIJ.js} +39 -37
- package/dist/chunks/{chunk-QHYBSIIO.js.map → chunk-FB24AOIJ.js.map} +1 -1
- package/dist/chunks/chunk-FSB2VIRZ.js +435 -0
- package/dist/chunks/chunk-FSB2VIRZ.js.map +7 -0
- package/dist/chunks/{chunk-PNDYFU64.js → chunk-GJVPP3NN.js} +81 -11
- package/dist/chunks/chunk-GJVPP3NN.js.map +7 -0
- package/dist/chunks/{chunk-B5D6GA77.js → chunk-GYPDGW27.js} +100 -92
- package/dist/chunks/chunk-GYPDGW27.js.map +7 -0
- package/dist/chunks/{chunk-LEFBW2GK.js → chunk-IAFI4A2I.js} +44 -2
- package/dist/chunks/{chunk-LEFBW2GK.js.map → chunk-IAFI4A2I.js.map} +3 -3
- package/dist/chunks/{chunk-PWS2OXLV.js → chunk-IIPKG52D.js} +1 -1
- package/dist/chunks/chunk-IIPKG52D.js.map +7 -0
- package/dist/chunks/chunk-ITVLKXCI.js +266 -0
- package/dist/chunks/chunk-ITVLKXCI.js.map +7 -0
- package/dist/chunks/chunk-JKQARSWR.js +265 -0
- package/dist/chunks/chunk-JKQARSWR.js.map +7 -0
- package/dist/chunks/{chunk-AYBIR4YV.js → chunk-KJZAOENY.js} +6 -4
- package/dist/chunks/chunk-KJZAOENY.js.map +7 -0
- package/dist/chunks/{chunk-74BA4VSX.js → chunk-KQ6R5EWR.js} +1462 -1405
- package/dist/chunks/chunk-KQ6R5EWR.js.map +7 -0
- package/dist/chunks/chunk-L22K5BWU.js +180 -0
- package/dist/chunks/chunk-L22K5BWU.js.map +7 -0
- package/dist/chunks/{chunk-7XJB2USB.js → chunk-LOLCTWJF.js} +4 -4
- package/dist/chunks/{chunk-QETG2GVX.js → chunk-M5IN6DMF.js} +34 -31
- package/dist/chunks/chunk-M5IN6DMF.js.map +7 -0
- package/dist/chunks/{chunk-64O5L7EW.js → chunk-M6IRQ3QT.js} +2 -2
- package/dist/chunks/{chunk-TX6E5W7H.js → chunk-NTC2MCB6.js} +1 -1
- package/dist/chunks/chunk-NTC2MCB6.js.map +7 -0
- package/dist/chunks/{chunk-EPYLZWJV.js → chunk-OVBKQCYL.js} +2 -2
- package/dist/chunks/{chunk-YV2PHCDB.js → chunk-PYFJW3HC.js} +16 -2
- package/dist/chunks/{chunk-YV2PHCDB.js.map → chunk-PYFJW3HC.js.map} +3 -3
- package/dist/chunks/{chunk-Z5Y65YBX.js → chunk-PYQM7KPL.js} +3 -2
- package/dist/chunks/{chunk-BEJF2JX2.js → chunk-QLFDPXK7.js} +33 -2
- package/dist/chunks/chunk-QLFDPXK7.js.map +7 -0
- package/dist/chunks/chunk-QUWC6YCN.js +125 -0
- package/dist/chunks/chunk-QUWC6YCN.js.map +7 -0
- package/dist/chunks/{chunk-DKVJREDI.js → chunk-QY7YK7M6.js} +2 -2
- package/dist/chunks/{chunk-WMJ2AVQQ.js → chunk-R5F6CHW2.js} +34 -18
- package/dist/chunks/chunk-R5F6CHW2.js.map +7 -0
- package/dist/chunks/chunk-S3IRPDSO.js +57 -0
- package/dist/chunks/chunk-S3IRPDSO.js.map +7 -0
- package/dist/chunks/{chunk-7BG5COXB.js → chunk-SVDHQUTM.js} +21 -4
- package/dist/chunks/chunk-SVDHQUTM.js.map +7 -0
- package/dist/chunks/{chunk-HG4DMARW.js → chunk-T5CU2GPZ.js} +116 -26
- package/dist/chunks/chunk-T5CU2GPZ.js.map +7 -0
- package/dist/chunks/{chunk-RIFG4HS6.js → chunk-TFFZVLR2.js} +141 -9
- package/dist/chunks/chunk-TFFZVLR2.js.map +7 -0
- package/dist/chunks/{chunk-BUQZBG6O.js → chunk-U2UBUKNQ.js} +136 -136
- package/dist/chunks/chunk-U2UBUKNQ.js.map +7 -0
- package/dist/chunks/chunk-U366I5K2.js +363 -0
- package/dist/chunks/chunk-U366I5K2.js.map +7 -0
- package/dist/chunks/{chunk-4NF3S3NM.js → chunk-UTOBAZ5T.js} +1 -1
- package/dist/chunks/chunk-UTOBAZ5T.js.map +7 -0
- package/dist/chunks/chunk-V73NIH6B.js +127 -0
- package/dist/chunks/chunk-V73NIH6B.js.map +7 -0
- package/dist/chunks/{chunk-PN4EKNRE.js → chunk-VON4TSO3.js} +132 -12
- package/dist/chunks/chunk-VON4TSO3.js.map +7 -0
- package/dist/chunks/{chunk-5ZJV4LAX.js → chunk-VPRJOD4Y.js} +4 -4
- package/dist/chunks/{chunk-FDIEQEXS.js → chunk-VSDUSNIA.js} +4 -4
- package/dist/chunks/chunk-VSDUSNIA.js.map +7 -0
- package/dist/chunks/{chunk-RG22JKIC.js → chunk-W7X4XEQU.js} +2 -2
- package/dist/chunks/{chunk-LV4IT75S.js → chunk-WLLXKS6I.js} +2 -2
- package/dist/chunks/chunk-WOLUDZVR.js +197 -0
- package/dist/chunks/chunk-WOLUDZVR.js.map +7 -0
- package/dist/chunks/{chunk-YVDBHS4C.js → chunk-WREA4RNR.js} +3 -3
- package/dist/chunks/{chunk-QE2JFB7F.js → chunk-WYUV6WL3.js} +16 -6
- package/dist/chunks/chunk-WYUV6WL3.js.map +7 -0
- package/dist/chunks/{chunk-NGGI6LDC.js → chunk-X2TRSE7D.js} +2 -2
- package/dist/chunks/{chunk-VRAGOMN4.js → chunk-YRDCJZZW.js} +34 -1
- package/dist/chunks/chunk-YRDCJZZW.js.map +7 -0
- package/dist/chunks/{chunk-CC63CY6R.js → chunk-YYSZBD7S.js} +17 -261
- package/dist/chunks/chunk-YYSZBD7S.js.map +7 -0
- package/dist/chunks/{chunk-A4VP7HDF.js → chunk-ZLNJDTCN.js} +2 -2
- package/dist/chunks/{chunk-G4CSXNBT.js → chunk-ZXKYU6CH.js} +42 -5
- package/dist/chunks/chunk-ZXKYU6CH.js.map +7 -0
- package/dist/cli/decisions.d.ts +8 -0
- package/dist/cli/decisions.d.ts.map +1 -0
- package/dist/cli/decisions.js +131 -0
- package/dist/cli/decisions.js.map +7 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +56 -0
- package/dist/cli/index.js.map +7 -0
- package/dist/cli/mesh.d.ts +3 -0
- package/dist/cli/mesh.d.ts.map +1 -0
- package/dist/cli/mesh.js +126 -0
- package/dist/cli/mesh.js.map +7 -0
- package/dist/commands/fabric.d.ts.map +1 -1
- package/dist/compaction/carry.d.ts +23 -0
- package/dist/compaction/carry.d.ts.map +1 -0
- package/dist/compaction/hook.d.ts +9 -0
- package/dist/compaction/hook.d.ts.map +1 -1
- package/dist/compaction/hook.js +6 -6
- package/dist/compaction/orphan-repair.d.ts +11 -0
- package/dist/compaction/orphan-repair.d.ts.map +1 -0
- package/dist/compaction/orphan-repair.js +75 -0
- package/dist/compaction/orphan-repair.js.map +7 -0
- package/dist/compaction/owner.d.ts +26 -0
- package/dist/compaction/owner.d.ts.map +1 -0
- package/dist/compaction/owner.js +26 -0
- package/dist/compaction/owner.js.map +7 -0
- package/dist/compaction/pressure.d.ts +19 -0
- package/dist/compaction/pressure.d.ts.map +1 -0
- package/dist/compaction/render.d.ts +4 -0
- package/dist/compaction/render.d.ts.map +1 -1
- package/dist/compaction/threshold.d.ts +6 -1
- package/dist/compaction/threshold.d.ts.map +1 -1
- package/dist/components/configuration.js +6 -6
- package/dist/components/provider-component.d.ts +1 -1
- package/dist/components/provider-component.d.ts.map +1 -1
- package/dist/config.d.ts +45 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/core/action-registry.d.ts +5 -1
- package/dist/core/action-registry.d.ts.map +1 -1
- package/dist/core/action-registry.js +8 -8
- package/dist/core/approval-controller.d.ts +5 -1
- package/dist/core/approval-controller.d.ts.map +1 -1
- package/dist/core/approval-overrides.d.ts +11 -0
- package/dist/core/approval-overrides.d.ts.map +1 -0
- package/dist/core/atomic-write.d.ts +77 -0
- package/dist/core/atomic-write.d.ts.map +1 -1
- package/dist/core/compact-controller.d.ts +8 -0
- package/dist/core/compact-controller.d.ts.map +1 -1
- package/dist/core/file-lock.d.ts.map +1 -1
- package/dist/core/foreground-tools.d.ts +45 -0
- package/dist/core/foreground-tools.d.ts.map +1 -0
- package/dist/core/provider-bindings.d.ts +10 -1
- package/dist/core/provider-bindings.d.ts.map +1 -1
- package/dist/core/provider-operations.js.map +1 -1
- package/dist/core/tool-ownership.d.ts +18 -2
- package/dist/core/tool-ownership.d.ts.map +1 -1
- package/dist/decisions/command.d.ts +5 -0
- package/dist/decisions/command.d.ts.map +1 -0
- package/dist/decisions/command.js +74 -0
- package/dist/decisions/command.js.map +7 -0
- package/dist/decisions/host.d.ts +24 -0
- package/dist/decisions/host.d.ts.map +1 -0
- package/dist/decisions/store.d.ts +147 -0
- package/dist/decisions/store.d.ts.map +1 -0
- package/dist/durable.d.ts +38 -0
- package/dist/durable.d.ts.map +1 -0
- package/dist/durable.js +274 -0
- package/dist/durable.js.map +7 -0
- package/dist/entropy/index.js +10 -9
- package/dist/execution-service.d.ts +41 -1
- package/dist/execution-service.d.ts.map +1 -1
- package/dist/extension-bootstrap.d.ts +7 -0
- package/dist/extension-bootstrap.d.ts.map +1 -0
- package/dist/extension-bootstrap.js +51 -0
- package/dist/extension-bootstrap.js.map +7 -0
- package/dist/extension.d.ts +8 -0
- package/dist/extension.d.ts.map +1 -0
- package/dist/fabric-exec-tool.d.ts.map +1 -1
- package/dist/fabric-runtime-state.d.ts +8 -0
- package/dist/fabric-runtime-state.d.ts.map +1 -1
- package/dist/fabric-runtime-state.js +2372 -308
- package/dist/fabric-runtime-state.js.map +4 -4
- package/dist/fabric-state.d.ts +22 -0
- package/dist/fabric-state.d.ts.map +1 -1
- package/dist/host-compatibility.d.ts +1 -1
- package/dist/host-compatibility.d.ts.map +1 -1
- package/dist/index.d.ts +5 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +68 -6250
- package/dist/index.js.map +4 -4
- package/dist/jev/observation.js +5 -5
- package/dist/jev-fabric/bridge.d.ts +15 -0
- package/dist/jev-fabric/bridge.d.ts.map +1 -1
- package/dist/jev-fabric/client.js +1 -1
- package/dist/jev-fabric/client.js.map +2 -2
- package/dist/jev-fabric/operations.d.ts +2 -0
- package/dist/jev-fabric/operations.d.ts.map +1 -1
- package/dist/jev-fabric/operations.js +1 -1
- package/dist/jev-fabric/operations.js.map +2 -2
- package/dist/jev-fabric/resolve.js +1 -1
- package/dist/jev-fabric/resolve.js.map +2 -2
- package/dist/jev.js +9 -9
- package/dist/lifecycle/types.d.ts.map +1 -1
- package/dist/memory/client.d.ts +3 -0
- package/dist/memory/client.d.ts.map +1 -1
- package/dist/memory/digest.js +2 -2
- package/dist/memory/discovery.js +6 -6
- package/dist/memory/expand-service.d.ts.map +1 -1
- package/dist/memory/file-worker.d.ts.map +1 -1
- package/dist/memory/file-worker.js +10 -9
- package/dist/memory/file-worker.js.map +2 -2
- package/dist/memory/host-source.d.ts +2 -1
- package/dist/memory/host-source.d.ts.map +1 -1
- package/dist/memory/normalize.js +5 -5
- package/dist/memory/portable.d.ts +3 -1
- package/dist/memory/portable.d.ts.map +1 -1
- package/dist/memory/request-cache.d.ts +4 -2
- package/dist/memory/request-cache.d.ts.map +1 -1
- package/dist/memory/request-context.d.ts +3 -0
- package/dist/memory/request-context.d.ts.map +1 -1
- package/dist/memory/search.js +7 -7
- package/dist/memory/worker-provider.d.ts.map +1 -1
- package/dist/memory/worker-provider.js +10 -10
- package/dist/memory.js +14 -13
- package/dist/memory.js.map +2 -2
- package/dist/mesh/grants.d.ts +86 -0
- package/dist/mesh/grants.d.ts.map +1 -0
- package/dist/mesh/store.d.ts +89 -0
- package/dist/mesh/store.d.ts.map +1 -1
- package/dist/programs/host.d.ts +22 -0
- package/dist/programs/host.d.ts.map +1 -0
- package/dist/programs/host.js +171 -0
- package/dist/programs/host.js.map +7 -0
- package/dist/programs/source.d.ts +16 -0
- package/dist/programs/source.d.ts.map +1 -0
- package/dist/programs/store.d.ts +81 -0
- package/dist/programs/store.d.ts.map +1 -0
- package/dist/protocol.d.ts +153 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +15 -1
- package/dist/providers/agents-actions.d.ts.map +1 -1
- package/dist/providers/agents-message-router.d.ts.map +1 -1
- package/dist/providers/agents-progress.d.ts.map +1 -1
- package/dist/providers/agents-provider.d.ts +3 -0
- package/dist/providers/agents-provider.d.ts.map +1 -1
- package/dist/providers/cache-provider.d.ts +1 -1
- package/dist/providers/cache-provider.d.ts.map +1 -1
- package/dist/providers/compact-provider.d.ts +13 -1
- package/dist/providers/compact-provider.d.ts.map +1 -1
- package/dist/providers/decisions-provider.d.ts +17 -0
- package/dist/providers/decisions-provider.d.ts.map +1 -0
- package/dist/providers/jev-provider.js +9 -9
- package/dist/providers/memory-provider.d.ts.map +1 -1
- package/dist/providers/memory-provider.js +9 -9
- package/dist/providers/mesh-provider.d.ts +4 -0
- package/dist/providers/mesh-provider.d.ts.map +1 -1
- package/dist/providers/pi-tools-provider.d.ts.map +1 -1
- package/dist/providers/programs-provider.d.ts +18 -0
- package/dist/providers/programs-provider.d.ts.map +1 -0
- package/dist/providers/state-provider.d.ts +4 -1
- package/dist/providers/state-provider.d.ts.map +1 -1
- package/dist/providers/thinking-provider.d.ts +15 -0
- package/dist/providers/thinking-provider.d.ts.map +1 -0
- package/dist/residency/actor-client.js +3 -3
- package/dist/residency/client.d.ts.map +1 -1
- package/dist/residency/host.d.ts +21 -0
- package/dist/residency/host.d.ts.map +1 -1
- package/dist/residency/host.js +28 -22
- package/dist/residency/launcher-owner.d.ts +2 -0
- package/dist/residency/launcher-owner.d.ts.map +1 -1
- package/dist/residency/launcher.js +35 -20
- package/dist/residency/launcher.js.map +3 -3
- package/dist/residency/pi-entry.js +26 -22
- package/dist/residency/pi-entry.js.map +1 -1
- package/dist/residency/protocol.d.ts +12 -2
- package/dist/residency/protocol.d.ts.map +1 -1
- package/dist/runners.d.ts +9 -0
- package/dist/runners.d.ts.map +1 -0
- package/dist/runners.js +182 -0
- package/dist/runners.js.map +7 -0
- package/dist/runtime/core-override-guest-types.js +2 -2
- package/dist/runtime/cpython-child-source.d.ts.map +1 -1
- package/dist/runtime/cpython-runtime.d.ts.map +1 -1
- package/dist/runtime/cpython-runtime.js +35 -7
- package/dist/runtime/cpython-runtime.js.map +2 -2
- package/dist/runtime/deadline-pause.d.ts +26 -0
- package/dist/runtime/deadline-pause.d.ts.map +1 -0
- 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/kernel.d.ts +3 -0
- package/dist/runtime/kernel.d.ts.map +1 -1
- package/dist/runtime/monty-runtime.d.ts.map +1 -1
- package/dist/runtime/monty-runtime.js +33 -12
- package/dist/runtime/monty-runtime.js.map +2 -2
- package/dist/runtime/node-process-runtime.d.ts.map +1 -1
- package/dist/runtime/node-process-runtime.js +4 -3
- package/dist/runtime/orchestration.d.ts.map +1 -1
- package/dist/runtime/quickjs-runtime.d.ts.map +1 -1
- package/dist/runtime/quickjs-runtime.js +2 -1
- package/dist/runtime/typescript-kernel.js +8 -7
- package/dist/runtime/typescript-kernel.js.map +1 -1
- package/dist/runtime-state-builtins.d.ts.map +1 -1
- package/dist/schema/controller.d.ts.map +1 -1
- package/dist/schema/policy.d.ts.map +1 -1
- package/dist/scope.d.ts +69 -0
- package/dist/scope.d.ts.map +1 -0
- package/dist/scope.js +37 -0
- package/dist/scope.js.map +7 -0
- package/dist/speculation/eligibility.d.ts.map +1 -1
- package/dist/speculation/python-scanner.js +1 -1
- package/dist/speculation/python-scanner.js.map +2 -2
- package/dist/speculation/scanner.js +1 -1
- package/dist/speculation/scanner.js.map +2 -2
- package/dist/state/binding.d.ts +17 -0
- package/dist/state/binding.d.ts.map +1 -0
- package/dist/state/store.d.ts +8 -2
- package/dist/state/store.d.ts.map +1 -1
- package/dist/state/types.d.ts +23 -2
- package/dist/state/types.d.ts.map +1 -1
- package/dist/storage/retention.d.ts +7 -0
- package/dist/storage/retention.d.ts.map +1 -1
- package/dist/storage/scratch.d.ts.map +1 -1
- package/dist/thinking-control.d.ts +64 -0
- package/dist/thinking-control.d.ts.map +1 -0
- package/dist/thinking-control.js +15 -0
- package/dist/thinking-control.js.map +7 -0
- package/dist/thinking.d.ts +61 -0
- package/dist/thinking.d.ts.map +1 -1
- package/dist/topology/control-plane.d.ts +13 -0
- package/dist/topology/control-plane.d.ts.map +1 -1
- package/dist/topology/participant-directory.d.ts +2 -0
- package/dist/topology/participant-directory.d.ts.map +1 -1
- package/dist/topology/provider-participants.d.ts +72 -0
- package/dist/topology/provider-participants.d.ts.map +1 -0
- package/dist/topology/records.d.ts.map +1 -1
- package/dist/topology/types.d.ts +13 -3
- package/dist/topology/types.d.ts.map +1 -1
- package/dist/type-error-guidance.js +170 -0
- package/dist/type-error-guidance.js.map +7 -0
- package/dist/ui/controller.d.ts.map +1 -1
- package/dist/ui/conversation-chrome.d.ts +2 -0
- package/dist/ui/conversation-chrome.d.ts.map +1 -1
- package/dist/ui/conversation-chrome.js +1 -1
- package/dist/ui/conversation-latest.d.ts +10 -0
- package/dist/ui/conversation-latest.d.ts.map +1 -0
- package/dist/ui/conversation-native-reader.js +2 -1
- package/dist/ui/conversation-native-reader.js.map +1 -1
- package/dist/ui/conversation-render.d.ts +2 -1
- package/dist/ui/conversation-render.d.ts.map +1 -1
- package/dist/ui/conversation-scrollbar.d.ts +22 -0
- package/dist/ui/conversation-scrollbar.d.ts.map +1 -0
- package/dist/ui/conversation-selection.d.ts +2 -2
- package/dist/ui/conversation-selection.d.ts.map +1 -1
- package/dist/ui/conversation-targets.d.ts.map +1 -1
- package/dist/ui/conversation-targets.js +2 -2
- package/dist/ui/conversation.d.ts +3 -0
- package/dist/ui/conversation.d.ts.map +1 -1
- package/dist/ui/conversation.js +253 -34
- package/dist/ui/conversation.js.map +4 -4
- package/dist/ui/dashboard-fabric-graph.d.ts.map +1 -1
- package/dist/ui/dashboard.js +14 -15
- package/dist/ui/dashboard.js.map +2 -2
- package/dist/ui/image-overlays.d.ts +16 -0
- package/dist/ui/image-overlays.d.ts.map +1 -0
- package/dist/ui/image-overlays.js +10 -0
- package/dist/ui/image-overlays.js.map +7 -0
- package/dist/ui/kitty-viewport.d.ts +24 -0
- package/dist/ui/kitty-viewport.d.ts.map +1 -0
- package/dist/ui/retention.d.ts +14 -0
- package/dist/ui/retention.d.ts.map +1 -0
- package/dist/ui/settings-sections-execution.d.ts.map +1 -1
- package/dist/ui/settings.d.ts.map +1 -1
- package/dist/ui/settings.js +27 -16
- package/dist/ui/settings.js.map +2 -2
- package/dist/ui/transcript.d.ts +2 -1
- package/dist/ui/transcript.d.ts.map +1 -1
- package/dist/ui/types.d.ts +2 -1
- package/dist/ui/types.d.ts.map +1 -1
- package/dist/ui/widget.d.ts +4 -2
- package/dist/ui/widget.d.ts.map +1 -1
- package/dist/verified/generated/authority-kernel.js +1 -1
- package/dist/verified/generated/kernel.js +1 -1
- package/dist/verified/generated/lifecycle-kernel.js +1 -1
- package/dist/verified/generated/manifest.json +7 -7
- package/dist/verified/generated/provider-kernel.js +1 -1
- package/dist/verified/generated/storage-kernel.js +1 -1
- package/dist/worker/options.d.ts.map +1 -1
- package/dist/worker/options.js +14 -0
- package/dist/worker/options.js.map +2 -2
- package/dist/worker/questions.d.ts +46 -0
- package/dist/worker/questions.d.ts.map +1 -0
- package/dist/worker/questions.js +87 -0
- package/dist/worker/questions.js.map +7 -0
- package/dist/worker/result.d.ts +3 -0
- package/dist/worker/result.d.ts.map +1 -0
- package/dist/worker/result.js +7493 -0
- package/dist/worker/result.js.map +7 -0
- package/dist/worker/run-record.js +10 -113
- package/dist/worker/run-record.js.map +3 -3
- package/dist/worker/startup.d.ts +8 -0
- package/dist/worker/startup.d.ts.map +1 -0
- package/dist/worker.js +111 -22
- package/dist/worker.js.map +4 -4
- package/docs/agents.md +197 -3
- package/docs/architecture.md +8 -1
- package/docs/audit-trace.md +36 -1
- package/docs/background-tasks.md +25 -1
- package/docs/certification.md +1 -1
- package/docs/compaction.md +64 -0
- package/docs/components.md +1 -0
- package/docs/configuration.md +105 -10
- package/docs/decisions.md +144 -0
- package/docs/durable-pi.md +186 -0
- package/docs/interface.md +10 -1
- package/docs/kitty-images.md +89 -0
- package/docs/licenses/typebox-mit.txt +23 -0
- package/docs/memory-recall.md +5 -3
- package/docs/programmatic-compaction.md +67 -11
- package/docs/programs.md +137 -0
- package/docs/provider-capabilities.md +23 -1
- package/docs/providers.md +158 -0
- package/docs/residency-runtime.md +64 -0
- package/docs/schema-enforcement.md +5 -3
- package/docs/shell-composition.md +6 -6
- package/docs/skills.md +2 -1
- package/docs/speculation.md +2 -1
- package/docs/state-layer.md +26 -4
- package/docs/thinking.md +48 -0
- package/docs/verified-kernels.md +1 -1
- package/package.json +48 -12
- package/scripts/test-verified-kernels.mjs +1 -1
- package/scripts/verified-kernels.mjs +1 -1
- package/skillsets/python/fabric-exec/SKILL.md +2 -2
- package/skillsets/python/fabric-exec/references/agents.md +9 -4
- package/skillsets/python/fabric-exec/references/mesh.md +9 -0
- package/skillsets/python/fabric-graph/SKILL.md +109 -0
- package/skillsets/python/fabric-guide/SKILL.md +2 -1
- package/skillsets/typescript/fabric-exec/SKILL.md +20 -2
- package/skillsets/typescript/fabric-exec/references/agents.md +10 -4
- package/skillsets/typescript/fabric-exec/references/mesh.md +10 -0
- package/skillsets/typescript/fabric-graph/SKILL.md +112 -0
- package/skillsets/typescript/fabric-guide/SKILL.md +2 -1
- package/skillsets/typescript/fabric-workflow/SKILL.md +1 -1
- package/dist/chunks/chunk-4NF3S3NM.js.map +0 -7
- package/dist/chunks/chunk-5VTBHJN3.js.map +0 -7
- package/dist/chunks/chunk-74BA4VSX.js.map +0 -7
- package/dist/chunks/chunk-7BG5COXB.js.map +0 -7
- package/dist/chunks/chunk-AYBIR4YV.js.map +0 -7
- package/dist/chunks/chunk-B5D6GA77.js.map +0 -7
- package/dist/chunks/chunk-BEJF2JX2.js.map +0 -7
- package/dist/chunks/chunk-BUQZBG6O.js.map +0 -7
- package/dist/chunks/chunk-CC63CY6R.js.map +0 -7
- package/dist/chunks/chunk-FDIEQEXS.js.map +0 -7
- package/dist/chunks/chunk-G4CSXNBT.js.map +0 -7
- package/dist/chunks/chunk-HG4DMARW.js.map +0 -7
- package/dist/chunks/chunk-KAD7UWT2.js +0 -99
- package/dist/chunks/chunk-KAD7UWT2.js.map +0 -7
- package/dist/chunks/chunk-MGWQOKBV.js +0 -30
- package/dist/chunks/chunk-MGWQOKBV.js.map +0 -7
- package/dist/chunks/chunk-PN4EKNRE.js.map +0 -7
- package/dist/chunks/chunk-PNDYFU64.js.map +0 -7
- package/dist/chunks/chunk-PWS2OXLV.js.map +0 -7
- package/dist/chunks/chunk-QE2JFB7F.js.map +0 -7
- package/dist/chunks/chunk-QETG2GVX.js.map +0 -7
- package/dist/chunks/chunk-RAO6TQFP.js.map +0 -7
- package/dist/chunks/chunk-RIFG4HS6.js.map +0 -7
- package/dist/chunks/chunk-TX6E5W7H.js.map +0 -7
- package/dist/chunks/chunk-VRAGOMN4.js.map +0 -7
- package/dist/chunks/chunk-W63E3WEO.js.map +0 -7
- package/dist/chunks/chunk-WMJ2AVQQ.js.map +0 -7
- package/dist/chunks/chunk-ZZ66L3W5.js.map +0 -7
- /package/dist/chunks/{chunk-57CMH4SW.js.map → chunk-7JU7Z4XQ.js.map} +0 -0
- /package/dist/chunks/{chunk-DUJ46TIP.js.map → chunk-ABJCSNZO.js.map} +0 -0
- /package/dist/chunks/{chunk-KP4ANT6L.js.map → chunk-C7EEG6SM.js.map} +0 -0
- /package/dist/chunks/{chunk-NHMICIEU.js.map → chunk-CCHZXF6K.js.map} +0 -0
- /package/dist/chunks/{chunk-5JN5AWNV.js.map → chunk-DZ4WN5XJ.js.map} +0 -0
- /package/dist/chunks/{chunk-7XJB2USB.js.map → chunk-LOLCTWJF.js.map} +0 -0
- /package/dist/chunks/{chunk-64O5L7EW.js.map → chunk-M6IRQ3QT.js.map} +0 -0
- /package/dist/chunks/{chunk-EPYLZWJV.js.map → chunk-OVBKQCYL.js.map} +0 -0
- /package/dist/chunks/{chunk-Z5Y65YBX.js.map → chunk-PYQM7KPL.js.map} +0 -0
- /package/dist/chunks/{chunk-DKVJREDI.js.map → chunk-QY7YK7M6.js.map} +0 -0
- /package/dist/chunks/{chunk-5ZJV4LAX.js.map → chunk-VPRJOD4Y.js.map} +0 -0
- /package/dist/chunks/{chunk-RG22JKIC.js.map → chunk-W7X4XEQU.js.map} +0 -0
- /package/dist/chunks/{chunk-LV4IT75S.js.map → chunk-WLLXKS6I.js.map} +0 -0
- /package/dist/chunks/{chunk-YVDBHS4C.js.map → chunk-WREA4RNR.js.map} +0 -0
- /package/dist/chunks/{chunk-NGGI6LDC.js.map → chunk-X2TRSE7D.js.map} +0 -0
- /package/dist/chunks/{chunk-A4VP7HDF.js.map → chunk-ZLNJDTCN.js.map} +0 -0
|
@@ -13,13 +13,54 @@ import {
|
|
|
13
13
|
componentEntries,
|
|
14
14
|
validateComponentConfig,
|
|
15
15
|
watchComponentConfiguration
|
|
16
|
-
} from "./chunks/chunk-
|
|
16
|
+
} from "./chunks/chunk-OVBKQCYL.js";
|
|
17
|
+
import {
|
|
18
|
+
MAX_PROGRAM_CODE_CHARS,
|
|
19
|
+
MAX_PROGRAM_DESCRIPTION_CHARS,
|
|
20
|
+
MAX_PROGRAM_NAME_CHARS,
|
|
21
|
+
MAX_PROGRAM_REF_CHARS,
|
|
22
|
+
ProgramStore,
|
|
23
|
+
normalizeProgramInput,
|
|
24
|
+
programInputError,
|
|
25
|
+
programRef,
|
|
26
|
+
programSourceWithInput,
|
|
27
|
+
programsDirectory
|
|
28
|
+
} from "./chunks/chunk-U366I5K2.js";
|
|
17
29
|
import {
|
|
18
30
|
WorkerMemoryProvider
|
|
19
|
-
} from "./chunks/chunk-
|
|
31
|
+
} from "./chunks/chunk-BVJBYFHD.js";
|
|
20
32
|
import {
|
|
21
|
-
|
|
22
|
-
|
|
33
|
+
MESH_GRANT_MAX_TTL_MS,
|
|
34
|
+
MESH_GRANT_MAX_USES,
|
|
35
|
+
MESH_GRANT_MIN_TTL_MS,
|
|
36
|
+
createMeshGrant,
|
|
37
|
+
listMeshGrants,
|
|
38
|
+
meshCliArgv,
|
|
39
|
+
meshPostCommand,
|
|
40
|
+
revokeMeshGrant,
|
|
41
|
+
wrapDurableNotifyScript
|
|
42
|
+
} from "./chunks/chunk-7XRUMDV7.js";
|
|
43
|
+
import {
|
|
44
|
+
DecisionStore,
|
|
45
|
+
MAX_DECISION_BODY_CHARS,
|
|
46
|
+
MAX_DECISION_DEADLINE_MS,
|
|
47
|
+
MAX_DECISION_OPTIONS,
|
|
48
|
+
MAX_DECISION_TEXT_CHARS,
|
|
49
|
+
MAX_DECISION_TITLE_CHARS,
|
|
50
|
+
MAX_ESCALATION_HOPS,
|
|
51
|
+
MAX_ESCALATION_HOP_MS,
|
|
52
|
+
MAX_ESCALATION_REASON_CHARS,
|
|
53
|
+
MIN_ESCALATION_HOP_MS,
|
|
54
|
+
assertDecisionId
|
|
55
|
+
} from "./chunks/chunk-FSB2VIRZ.js";
|
|
56
|
+
import {
|
|
57
|
+
FabricThinkingController,
|
|
58
|
+
MAX_THINKING_OVERRIDE_TURNS,
|
|
59
|
+
MAX_THINKING_REASON_CHARS
|
|
60
|
+
} from "./chunks/chunk-L22K5BWU.js";
|
|
61
|
+
import {
|
|
62
|
+
ownerFromContext
|
|
63
|
+
} from "./chunks/chunk-S3IRPDSO.js";
|
|
23
64
|
import {
|
|
24
65
|
ActionRegistry,
|
|
25
66
|
FabricComponentIndependenceError,
|
|
@@ -32,10 +73,70 @@ import {
|
|
|
32
73
|
scoreActionSearch,
|
|
33
74
|
summarizeEffects,
|
|
34
75
|
trackedRegistration
|
|
35
|
-
} from "./chunks/chunk-
|
|
76
|
+
} from "./chunks/chunk-R5F6CHW2.js";
|
|
36
77
|
import {
|
|
37
78
|
formatFabricEffectConflict
|
|
38
79
|
} from "./chunks/chunk-LMAVZN7J.js";
|
|
80
|
+
import {
|
|
81
|
+
FabricAssessmentRecorder,
|
|
82
|
+
readFabricAssessmentUsage
|
|
83
|
+
} from "./chunks/chunk-WOLUDZVR.js";
|
|
84
|
+
import {
|
|
85
|
+
ActorDirectory,
|
|
86
|
+
ActorRegistryOwnershipError,
|
|
87
|
+
AgentManager,
|
|
88
|
+
FabricControlPlane,
|
|
89
|
+
LifecycleBroker,
|
|
90
|
+
ParticipantDirectory,
|
|
91
|
+
actorDeliveryNotice,
|
|
92
|
+
actorParticipantRecord,
|
|
93
|
+
addCloneFirstWorktree,
|
|
94
|
+
agentParticipantRecords,
|
|
95
|
+
buildThinkingDigest,
|
|
96
|
+
checkedHandoffCompaction,
|
|
97
|
+
effectiveAgentTimeoutMs,
|
|
98
|
+
isFabricWorktreePath,
|
|
99
|
+
loadModelUsage,
|
|
100
|
+
readAgentLineage,
|
|
101
|
+
resolveActorDeliveryPolicy,
|
|
102
|
+
resolveAgentCwd,
|
|
103
|
+
resolveInheritedSessionPins,
|
|
104
|
+
resolvePiBinary,
|
|
105
|
+
snapshotHandoffSession,
|
|
106
|
+
thinkingTransferPolicy,
|
|
107
|
+
withInheritedSessionPins
|
|
108
|
+
} from "./chunks/chunk-KQ6R5EWR.js";
|
|
109
|
+
import {
|
|
110
|
+
executeFile,
|
|
111
|
+
processIsAlive,
|
|
112
|
+
spawnDetached
|
|
113
|
+
} from "./chunks/chunk-SVDHQUTM.js";
|
|
114
|
+
import "./chunks/chunk-2USMWEE6.js";
|
|
115
|
+
import "./chunks/chunk-PM5I335G.js";
|
|
116
|
+
import "./chunks/chunk-VPPIJRNZ.js";
|
|
117
|
+
import {
|
|
118
|
+
MESH_MAX_PENDING_SCHEDULES,
|
|
119
|
+
MESH_MAX_SCHEDULE_AHEAD_MS,
|
|
120
|
+
MeshStore
|
|
121
|
+
} from "./chunks/chunk-3GJJG2FV.js";
|
|
122
|
+
import {
|
|
123
|
+
childScope,
|
|
124
|
+
sessionScope
|
|
125
|
+
} from "./chunks/chunk-JKQARSWR.js";
|
|
126
|
+
import {
|
|
127
|
+
ResidentActorClient
|
|
128
|
+
} from "./chunks/chunk-CCHZXF6K.js";
|
|
129
|
+
import {
|
|
130
|
+
RESIDENT_HOST_FORMAT,
|
|
131
|
+
abandonResidentRequest,
|
|
132
|
+
residentDeliveryPrefix,
|
|
133
|
+
residentHostId,
|
|
134
|
+
residentRoot,
|
|
135
|
+
sleepUnlessAborted
|
|
136
|
+
} from "./chunks/chunk-NTC2MCB6.js";
|
|
137
|
+
import {
|
|
138
|
+
loadCompiledSurface
|
|
139
|
+
} from "./chunks/chunk-YYSZBD7S.js";
|
|
39
140
|
import {
|
|
40
141
|
FABRIC_COMPONENT_PROVIDER_NAMES,
|
|
41
142
|
FABRIC_PROVIDER_COMPONENT_PREFIX,
|
|
@@ -45,82 +146,31 @@ import {
|
|
|
45
146
|
PREWALK_CONTINUE_MESSAGE_TYPE,
|
|
46
147
|
PrewalkController,
|
|
47
148
|
PrewalkDriftTracker,
|
|
149
|
+
WORKFLOW_ITEM_ID_MAX_CHARS,
|
|
48
150
|
builtinModelGuidance,
|
|
49
151
|
captureLoadedFileIdentity,
|
|
50
152
|
createProviderComponent,
|
|
51
153
|
deliverPrewalkPlanCheckpoint,
|
|
52
154
|
expandSkillDirMarkersForRead,
|
|
53
155
|
isSelectedNativeMcpTool,
|
|
156
|
+
isWorkflowItemId,
|
|
54
157
|
nativeMcpIdentity,
|
|
55
158
|
queueHandoffCompletion,
|
|
56
159
|
resolveFabricIdentity,
|
|
57
160
|
runtimeIdentityStatus,
|
|
58
161
|
setModelSafely
|
|
59
|
-
} from "./chunks/chunk-
|
|
162
|
+
} from "./chunks/chunk-GYPDGW27.js";
|
|
60
163
|
import {
|
|
61
164
|
AgentTranscriptReader,
|
|
62
165
|
MAX_WRITE_DIFF_BYTES,
|
|
63
166
|
countContentLines,
|
|
64
167
|
recentTranscriptTools,
|
|
65
168
|
writeContentForPreview
|
|
66
|
-
} from "./chunks/chunk-
|
|
169
|
+
} from "./chunks/chunk-7EYJE4TW.js";
|
|
67
170
|
import "./chunks/chunk-DLXPTBPL.js";
|
|
68
171
|
import {
|
|
69
|
-
loadCompiledSurface,
|
|
70
172
|
withExclusiveFileLockAsync
|
|
71
|
-
} from "./chunks/chunk-
|
|
72
|
-
import {
|
|
73
|
-
createConfiguredMemorySourceRegistry
|
|
74
|
-
} from "./chunks/chunk-5JN5AWNV.js";
|
|
75
|
-
import "./chunks/chunk-QETG2GVX.js";
|
|
76
|
-
import "./chunks/chunk-7XJB2USB.js";
|
|
77
|
-
import "./chunks/chunk-57CMH4SW.js";
|
|
78
|
-
import "./chunks/chunk-64O5L7EW.js";
|
|
79
|
-
import "./chunks/chunk-YVDBHS4C.js";
|
|
80
|
-
import {
|
|
81
|
-
McpProvider,
|
|
82
|
-
mcpToolDescriptor,
|
|
83
|
-
normalizeMcpResult
|
|
84
|
-
} from "./chunks/chunk-SGFH5PYA.js";
|
|
85
|
-
import {
|
|
86
|
-
McpDescriptorCacheStore,
|
|
87
|
-
mcpDescriptorCachePath
|
|
88
|
-
} from "./chunks/chunk-Z64PRP7A.js";
|
|
89
|
-
import {
|
|
90
|
-
sanitizeMcpRefPart
|
|
91
|
-
} from "./chunks/chunk-IGVDD2HT.js";
|
|
92
|
-
import {
|
|
93
|
-
AGENTS_ACTION_DESCRIPTORS,
|
|
94
|
-
normalizeAgentRunRequest
|
|
95
|
-
} from "./chunks/chunk-PNDYFU64.js";
|
|
96
|
-
import {
|
|
97
|
-
actionArgNormalizer,
|
|
98
|
-
uniqueDeclaredKeyForSpelling
|
|
99
|
-
} from "./chunks/chunk-NQOEHX62.js";
|
|
100
|
-
import {
|
|
101
|
-
prepareFabricActorHostPayload,
|
|
102
|
-
sanitizeFabricMediaText,
|
|
103
|
-
sanitizeFabricMediaValue
|
|
104
|
-
} from "./chunks/chunk-CGL7QP4A.js";
|
|
105
|
-
import {
|
|
106
|
-
validationMessage
|
|
107
|
-
} from "./chunks/chunk-KP4ANT6L.js";
|
|
108
|
-
import {
|
|
109
|
-
runAbortable,
|
|
110
|
-
throwIfAborted
|
|
111
|
-
} from "./chunks/chunk-7TB7NXSL.js";
|
|
112
|
-
import {
|
|
113
|
-
ApprovalController,
|
|
114
|
-
FabricAutoApprovalClassifier,
|
|
115
|
-
FabricSessionApprovals
|
|
116
|
-
} from "./chunks/chunk-QE2JFB7F.js";
|
|
117
|
-
import "./chunks/chunk-XB3RJVT4.js";
|
|
118
|
-
import {
|
|
119
|
-
clearActiveCompiledSurface,
|
|
120
|
-
clearActiveRepairCompiler,
|
|
121
|
-
setActiveCompiledSurface,
|
|
122
|
-
setActiveRepairCompiler
|
|
123
|
-
} from "./chunks/chunk-DKVJREDI.js";
|
|
173
|
+
} from "./chunks/chunk-DK35W6U7.js";
|
|
124
174
|
import {
|
|
125
175
|
FABRIC_BASH_MIDDLEWARE,
|
|
126
176
|
FABRIC_COMPONENT_DISCOVER_EVENT,
|
|
@@ -128,104 +178,149 @@ import {
|
|
|
128
178
|
FABRIC_PROVIDER_DISCOVER_EVENT,
|
|
129
179
|
FABRIC_SHELL_TIMING_EVENT,
|
|
130
180
|
FABRIC_TOOL_RESULT_PROXY_KIND,
|
|
181
|
+
FABRIC_WORKFLOW_ITEM_EVENT,
|
|
131
182
|
readFabricToolResultProxyDetailsV1
|
|
132
|
-
} from "./chunks/chunk-
|
|
183
|
+
} from "./chunks/chunk-YRDCJZZW.js";
|
|
133
184
|
import {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
AgentManager,
|
|
137
|
-
FabricControlPlane,
|
|
138
|
-
LifecycleBroker,
|
|
139
|
-
MeshStore,
|
|
140
|
-
ParticipantDirectory,
|
|
141
|
-
actorDeliveryNotice,
|
|
142
|
-
actorParticipantRecord,
|
|
143
|
-
addCloneFirstWorktree,
|
|
144
|
-
agentParticipantRecords,
|
|
145
|
-
buildThinkingDigest,
|
|
146
|
-
checkedHandoffCompaction,
|
|
147
|
-
effectiveAgentTimeoutMs,
|
|
148
|
-
isFabricWorktreePath,
|
|
149
|
-
loadModelUsage,
|
|
150
|
-
readChildToolAllowlist,
|
|
151
|
-
resolveActorDeliveryPolicy,
|
|
152
|
-
resolveAgentCwd,
|
|
153
|
-
resolveInheritedSessionPins,
|
|
154
|
-
resolvePiBinary,
|
|
155
|
-
snapshotHandoffSession,
|
|
156
|
-
thinkingTransferPolicy,
|
|
157
|
-
withInheritedSessionPins
|
|
158
|
-
} from "./chunks/chunk-74BA4VSX.js";
|
|
159
|
-
import {
|
|
160
|
-
executeFile,
|
|
161
|
-
processIsAlive,
|
|
162
|
-
spawnDetached
|
|
163
|
-
} from "./chunks/chunk-7BG5COXB.js";
|
|
164
|
-
import "./chunks/chunk-VPPIJRNZ.js";
|
|
165
|
-
import "./chunks/chunk-PM5I335G.js";
|
|
166
|
-
import {
|
|
167
|
-
RESIDENT_HOST_FORMAT,
|
|
168
|
-
abandonResidentRequest,
|
|
169
|
-
residentDeliveryPrefix,
|
|
170
|
-
residentHostId,
|
|
171
|
-
residentRoot,
|
|
172
|
-
sleepUnlessAborted
|
|
173
|
-
} from "./chunks/chunk-TX6E5W7H.js";
|
|
174
|
-
import "./chunks/chunk-YV2PHCDB.js";
|
|
185
|
+
readChildToolAllowlist
|
|
186
|
+
} from "./chunks/chunk-PYFJW3HC.js";
|
|
175
187
|
import {
|
|
176
188
|
resolveAgentDir
|
|
177
189
|
} from "./chunks/chunk-PXAICAUT.js";
|
|
178
190
|
import {
|
|
179
191
|
closeScratch,
|
|
180
192
|
createScratch
|
|
181
|
-
} from "./chunks/chunk-
|
|
182
|
-
import {
|
|
183
|
-
readJsonlPage
|
|
184
|
-
} from "./chunks/chunk-CGPK5WHX.js";
|
|
193
|
+
} from "./chunks/chunk-5XBYFSI5.js";
|
|
185
194
|
import {
|
|
186
195
|
DEFAULT_FABRIC_CONFIG,
|
|
187
196
|
DEFAULT_SHELL_HANG_MS,
|
|
188
197
|
MAX_AGENT_TIMEOUT_MS,
|
|
189
198
|
MIN_AGENT_TIMEOUT_MS,
|
|
190
199
|
loadFabricConfig
|
|
191
|
-
} from "./chunks/chunk-
|
|
200
|
+
} from "./chunks/chunk-VON4TSO3.js";
|
|
192
201
|
import "./chunks/chunk-OKOHRXGF.js";
|
|
193
202
|
import {
|
|
194
|
-
|
|
195
|
-
} from "./chunks/chunk-
|
|
203
|
+
readJsonlPage
|
|
204
|
+
} from "./chunks/chunk-CGPK5WHX.js";
|
|
205
|
+
import {
|
|
206
|
+
COMPACTION_CARRY_ENTRY_TYPE,
|
|
207
|
+
MAX_CARRY_ITEMS,
|
|
208
|
+
MAX_CARRY_ITEM_CHARS,
|
|
209
|
+
applyCarryUpdate,
|
|
210
|
+
fabricExecTitleHintCached,
|
|
211
|
+
isCarryUpdate,
|
|
212
|
+
latestCarryItems,
|
|
213
|
+
modelCompactionKey,
|
|
214
|
+
outputReserveBreached,
|
|
215
|
+
sameCarryItems
|
|
216
|
+
} from "./chunks/chunk-T5CU2GPZ.js";
|
|
196
217
|
import "./chunks/chunk-SZUXWOO7.js";
|
|
197
218
|
import {
|
|
219
|
+
MAX_FABRIC_MODEL_GUIDANCE_PER_COMPONENT,
|
|
220
|
+
MAX_FABRIC_MODEL_GUIDANCE_REGISTRATIONS,
|
|
221
|
+
MAX_FABRIC_MODEL_GUIDANCE_SNAPSHOT_CHARS,
|
|
222
|
+
MAX_FABRIC_MODEL_GUIDANCE_TOTAL_CHARS,
|
|
223
|
+
compareFabricOwnedModelGuidance,
|
|
224
|
+
fabricModelGuidanceInfo,
|
|
225
|
+
normalizeFabricModelGuidance,
|
|
226
|
+
resolveFabricModelGuidance
|
|
227
|
+
} from "./chunks/chunk-UKMQK5VP.js";
|
|
228
|
+
import {
|
|
229
|
+
ownerHeartbeatFields,
|
|
230
|
+
recordOwnerLiveness,
|
|
231
|
+
startOwnerHeartbeat,
|
|
232
|
+
writeFileAtomic,
|
|
198
233
|
writeJsonAtomic,
|
|
199
234
|
writeJsonAtomicAsync
|
|
200
|
-
} from "./chunks/chunk-
|
|
201
|
-
import
|
|
235
|
+
} from "./chunks/chunk-ITVLKXCI.js";
|
|
236
|
+
import {
|
|
237
|
+
createConfiguredMemorySourceRegistry
|
|
238
|
+
} from "./chunks/chunk-DZ4WN5XJ.js";
|
|
239
|
+
import "./chunks/chunk-M5IN6DMF.js";
|
|
240
|
+
import "./chunks/chunk-LOLCTWJF.js";
|
|
241
|
+
import "./chunks/chunk-7JU7Z4XQ.js";
|
|
242
|
+
import "./chunks/chunk-M6IRQ3QT.js";
|
|
243
|
+
import "./chunks/chunk-WREA4RNR.js";
|
|
244
|
+
import "./chunks/chunk-X2TRSE7D.js";
|
|
245
|
+
import {
|
|
246
|
+
McpProvider,
|
|
247
|
+
mcpToolDescriptor,
|
|
248
|
+
normalizeMcpResult
|
|
249
|
+
} from "./chunks/chunk-SGFH5PYA.js";
|
|
250
|
+
import {
|
|
251
|
+
McpDescriptorCacheStore,
|
|
252
|
+
mcpDescriptorCachePath
|
|
253
|
+
} from "./chunks/chunk-Z64PRP7A.js";
|
|
254
|
+
import {
|
|
255
|
+
sanitizeMcpRefPart
|
|
256
|
+
} from "./chunks/chunk-IGVDD2HT.js";
|
|
257
|
+
import {
|
|
258
|
+
AGENTS_ACTION_DESCRIPTORS,
|
|
259
|
+
normalizeAgentRunRequest
|
|
260
|
+
} from "./chunks/chunk-GJVPP3NN.js";
|
|
202
261
|
import {
|
|
203
262
|
FABRIC_PARTICIPANT_LIFECYCLE_TOPIC,
|
|
204
263
|
isFabricLifecycleEventType,
|
|
205
264
|
lifecycleSourceIdentity,
|
|
206
265
|
terminalAgentStatuses
|
|
207
|
-
} from "./chunks/chunk-
|
|
266
|
+
} from "./chunks/chunk-KJZAOENY.js";
|
|
208
267
|
import {
|
|
209
268
|
FABRIC_ACTOR_HOST_EVENTS,
|
|
210
269
|
isFabricActorHostEvent
|
|
211
|
-
} from "./chunks/chunk-
|
|
270
|
+
} from "./chunks/chunk-IIPKG52D.js";
|
|
212
271
|
import {
|
|
213
272
|
FUZZY_RESOLUTION_MARKERS,
|
|
214
273
|
aliasThinking,
|
|
215
274
|
resolveAvailablePiModel,
|
|
216
275
|
resolveFabricModel
|
|
217
|
-
} from "./chunks/chunk-
|
|
276
|
+
} from "./chunks/chunk-ZLNJDTCN.js";
|
|
218
277
|
import {
|
|
278
|
+
THINKING_LEVELS,
|
|
219
279
|
isFabricThinking
|
|
220
|
-
} from "./chunks/chunk-
|
|
280
|
+
} from "./chunks/chunk-V73NIH6B.js";
|
|
221
281
|
import {
|
|
222
282
|
MAX_COMPACTION_INSTRUCTIONS_CHARS,
|
|
223
283
|
MAX_PRESERVE_ITEMS,
|
|
224
284
|
MAX_PRESERVE_ITEM_CHARS,
|
|
225
285
|
compactionRequestBoundsError,
|
|
226
286
|
encodeCompactionRequest
|
|
227
|
-
} from "./chunks/chunk-
|
|
228
|
-
import
|
|
287
|
+
} from "./chunks/chunk-PYQM7KPL.js";
|
|
288
|
+
import {
|
|
289
|
+
actionArgNormalizer,
|
|
290
|
+
uniqueDeclaredKeyForSpelling
|
|
291
|
+
} from "./chunks/chunk-NQOEHX62.js";
|
|
292
|
+
import {
|
|
293
|
+
BUILT_IN_RUNNER_IDS,
|
|
294
|
+
isFabricRunnerId,
|
|
295
|
+
requireAgentRunner
|
|
296
|
+
} from "./chunks/chunk-4RTHQGES.js";
|
|
297
|
+
import {
|
|
298
|
+
prepareFabricActorHostPayload,
|
|
299
|
+
sanitizeFabricMediaText,
|
|
300
|
+
sanitizeFabricMediaValue
|
|
301
|
+
} from "./chunks/chunk-CGL7QP4A.js";
|
|
302
|
+
import {
|
|
303
|
+
validationMessage
|
|
304
|
+
} from "./chunks/chunk-C7EEG6SM.js";
|
|
305
|
+
import {
|
|
306
|
+
runAbortable,
|
|
307
|
+
throwIfAborted
|
|
308
|
+
} from "./chunks/chunk-7TB7NXSL.js";
|
|
309
|
+
import {
|
|
310
|
+
ApprovalController,
|
|
311
|
+
FabricAutoApprovalClassifier,
|
|
312
|
+
FabricSessionApprovals
|
|
313
|
+
} from "./chunks/chunk-WYUV6WL3.js";
|
|
314
|
+
import "./chunks/chunk-XB3RJVT4.js";
|
|
315
|
+
import {
|
|
316
|
+
clearActiveCompiledSurface,
|
|
317
|
+
clearActiveRepairCompiler,
|
|
318
|
+
setActiveCompiledSurface,
|
|
319
|
+
setActiveRepairCompiler
|
|
320
|
+
} from "./chunks/chunk-QY7YK7M6.js";
|
|
321
|
+
import {
|
|
322
|
+
actionApprovalOverride
|
|
323
|
+
} from "./chunks/chunk-IAFI4A2I.js";
|
|
229
324
|
import {
|
|
230
325
|
resolveJevModelRoute
|
|
231
326
|
} from "./chunks/chunk-B54Z662X.js";
|
|
@@ -233,14 +328,17 @@ import {
|
|
|
233
328
|
FabricExecutionTraceRecorder,
|
|
234
329
|
FabricTraceSafeError,
|
|
235
330
|
executionOutcomeFromError
|
|
236
|
-
} from "./chunks/chunk-
|
|
331
|
+
} from "./chunks/chunk-ZXKYU6CH.js";
|
|
237
332
|
import {
|
|
238
333
|
PI_CORE_TOOL_NAMES,
|
|
239
334
|
PI_CORE_TOOL_NAME_SET,
|
|
240
335
|
isPiShellRef,
|
|
241
336
|
isPiShellToolName
|
|
242
337
|
} from "./chunks/chunk-YU62DDKK.js";
|
|
243
|
-
import "./chunks/chunk-
|
|
338
|
+
import "./chunks/chunk-ABJCSNZO.js";
|
|
339
|
+
import {
|
|
340
|
+
stableJsonHash
|
|
341
|
+
} from "./chunks/chunk-3YZUQESG.js";
|
|
244
342
|
import {
|
|
245
343
|
$t,
|
|
246
344
|
De,
|
|
@@ -248,20 +346,7 @@ import {
|
|
|
248
346
|
assertCertificateFacts,
|
|
249
347
|
boundedEffectResources,
|
|
250
348
|
gt
|
|
251
|
-
} from "./chunks/chunk-
|
|
252
|
-
import {
|
|
253
|
-
MAX_FABRIC_MODEL_GUIDANCE_PER_COMPONENT,
|
|
254
|
-
MAX_FABRIC_MODEL_GUIDANCE_REGISTRATIONS,
|
|
255
|
-
MAX_FABRIC_MODEL_GUIDANCE_SNAPSHOT_CHARS,
|
|
256
|
-
MAX_FABRIC_MODEL_GUIDANCE_TOTAL_CHARS,
|
|
257
|
-
compareFabricOwnedModelGuidance,
|
|
258
|
-
fabricModelGuidanceInfo,
|
|
259
|
-
normalizeFabricModelGuidance,
|
|
260
|
-
resolveFabricModelGuidance
|
|
261
|
-
} from "./chunks/chunk-UKMQK5VP.js";
|
|
262
|
-
import {
|
|
263
|
-
stableJsonHash
|
|
264
|
-
} from "./chunks/chunk-3YZUQESG.js";
|
|
349
|
+
} from "./chunks/chunk-CYMDX3XP.js";
|
|
265
350
|
|
|
266
351
|
// src/fabric-runtime-state.ts
|
|
267
352
|
import path16 from "node:path";
|
|
@@ -3468,6 +3553,7 @@ var checkedPreserve = (value) => {
|
|
|
3468
3553
|
var CompactController = class {
|
|
3469
3554
|
#pending;
|
|
3470
3555
|
#last;
|
|
3556
|
+
#lastAuto;
|
|
3471
3557
|
#inFlight;
|
|
3472
3558
|
#hooks;
|
|
3473
3559
|
constructor(hooks = {}) {
|
|
@@ -3500,10 +3586,15 @@ var CompactController = class {
|
|
|
3500
3586
|
cancel() {
|
|
3501
3587
|
this.#pending = void 0;
|
|
3502
3588
|
}
|
|
3589
|
+
// Recorded by the host after a threshold or headroom compaction attempt.
|
|
3590
|
+
noteAutoCompaction(trigger, committed) {
|
|
3591
|
+
this.#lastAuto = { at: Date.now(), trigger, committed };
|
|
3592
|
+
}
|
|
3503
3593
|
status() {
|
|
3504
3594
|
return {
|
|
3505
3595
|
...this.#pending ? { pending: this.#pending } : {},
|
|
3506
|
-
...this.#last ? { last: this.#last } : {}
|
|
3596
|
+
...this.#last ? { last: this.#last } : {},
|
|
3597
|
+
...this.#lastAuto ? { lastAuto: this.#lastAuto } : {}
|
|
3507
3598
|
};
|
|
3508
3599
|
}
|
|
3509
3600
|
// Commit the pending intent at a safe boundary. Called and awaited from the
|
|
@@ -3651,6 +3742,109 @@ var FabricToolResultProxy = class {
|
|
|
3651
3742
|
}
|
|
3652
3743
|
};
|
|
3653
3744
|
|
|
3745
|
+
// src/activity/workflow-items.ts
|
|
3746
|
+
var WORKFLOW_ITEM_META_MAX_BYTES = 2 * 1024;
|
|
3747
|
+
var MAX_META_DEPTH = 8;
|
|
3748
|
+
var MAX_LABEL_CHARS = 120;
|
|
3749
|
+
var statuses = /* @__PURE__ */ new Set([
|
|
3750
|
+
"pending",
|
|
3751
|
+
"running",
|
|
3752
|
+
"completed",
|
|
3753
|
+
"failed",
|
|
3754
|
+
"blocked",
|
|
3755
|
+
"stopped"
|
|
3756
|
+
]);
|
|
3757
|
+
var legacyItemId = (value) => {
|
|
3758
|
+
if (typeof value !== "string") return void 0;
|
|
3759
|
+
const safe = value.trim().slice(0, WORKFLOW_ITEM_ID_MAX_CHARS).replace(/[^a-zA-Z0-9._:-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
3760
|
+
return safe || void 0;
|
|
3761
|
+
};
|
|
3762
|
+
var isPlainData = (value, depth) => {
|
|
3763
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return true;
|
|
3764
|
+
if (typeof value === "number") return Number.isFinite(value);
|
|
3765
|
+
if (typeof value !== "object" || depth >= MAX_META_DEPTH) return false;
|
|
3766
|
+
if (Array.isArray(value)) return value.every((entry) => isPlainData(entry, depth + 1));
|
|
3767
|
+
const prototype = Object.getPrototypeOf(value);
|
|
3768
|
+
if (prototype !== Object.prototype && prototype !== null) return false;
|
|
3769
|
+
return Object.values(value).every((entry) => isPlainData(entry, depth + 1));
|
|
3770
|
+
};
|
|
3771
|
+
var validateWorkflowItemInput = (args, defaultId) => {
|
|
3772
|
+
const id2 = isWorkflowItemId(args.id) ? args.id : legacyItemId(args.id) ?? defaultId();
|
|
3773
|
+
const status = args.status ?? "running";
|
|
3774
|
+
if (!statuses.has(status)) {
|
|
3775
|
+
throw new Error(`workflow.item status must be one of ${[...statuses].join(", ")}`);
|
|
3776
|
+
}
|
|
3777
|
+
if (args.meta === void 0) return { id: id2, status };
|
|
3778
|
+
const meta = args.meta;
|
|
3779
|
+
if (typeof meta !== "object" || meta === null || Array.isArray(meta) || !isPlainData(meta, 0)) {
|
|
3780
|
+
throw new Error("workflow.item meta must be a plain JSON object");
|
|
3781
|
+
}
|
|
3782
|
+
const serialized = JSON.stringify(meta);
|
|
3783
|
+
if (Buffer.byteLength(serialized, "utf8") > WORKFLOW_ITEM_META_MAX_BYTES) {
|
|
3784
|
+
throw new Error(
|
|
3785
|
+
`workflow.item meta must serialize to at most ${WORKFLOW_ITEM_META_MAX_BYTES} bytes`
|
|
3786
|
+
);
|
|
3787
|
+
}
|
|
3788
|
+
return {
|
|
3789
|
+
id: id2,
|
|
3790
|
+
status,
|
|
3791
|
+
meta: JSON.parse(serialized)
|
|
3792
|
+
};
|
|
3793
|
+
};
|
|
3794
|
+
var FabricWorkflowItemTransitions = class {
|
|
3795
|
+
constructor(invocationId, emit, sessionId) {
|
|
3796
|
+
this.invocationId = invocationId;
|
|
3797
|
+
this.emit = emit;
|
|
3798
|
+
this.sessionId = sessionId;
|
|
3799
|
+
}
|
|
3800
|
+
#statuses = /* @__PURE__ */ new Map();
|
|
3801
|
+
#labels = /* @__PURE__ */ new Map();
|
|
3802
|
+
/** Matches the activity store's historical `item-<n>` fallback. */
|
|
3803
|
+
nextDefaultId() {
|
|
3804
|
+
return `item-${this.#statuses.size + 1}`;
|
|
3805
|
+
}
|
|
3806
|
+
record(input, label) {
|
|
3807
|
+
const from = this.#statuses.get(input.id);
|
|
3808
|
+
this.#statuses.set(input.id, input.status);
|
|
3809
|
+
if (typeof label === "string" && label.trim()) {
|
|
3810
|
+
this.#labels.set(input.id, label.trim().slice(0, MAX_LABEL_CHARS));
|
|
3811
|
+
}
|
|
3812
|
+
if (from === input.status) return;
|
|
3813
|
+
this.#send(input.id, from, input.status, input.meta);
|
|
3814
|
+
}
|
|
3815
|
+
/** Mirrors the activity store: only running items settle with the run. */
|
|
3816
|
+
finish(success) {
|
|
3817
|
+
const to = success ? "completed" : "failed";
|
|
3818
|
+
for (const [id2, status] of this.#statuses) {
|
|
3819
|
+
if (status !== "running") continue;
|
|
3820
|
+
this.#statuses.set(id2, to);
|
|
3821
|
+
this.#send(id2, status, to);
|
|
3822
|
+
}
|
|
3823
|
+
}
|
|
3824
|
+
#send(itemId, from, to, meta) {
|
|
3825
|
+
if (!this.emit) return;
|
|
3826
|
+
const label = this.#labels.get(itemId);
|
|
3827
|
+
const event = {
|
|
3828
|
+
version: 1,
|
|
3829
|
+
invocationId: this.invocationId,
|
|
3830
|
+
...this.sessionId ? { sessionId: this.sessionId } : {},
|
|
3831
|
+
itemId,
|
|
3832
|
+
...label ? { label } : {},
|
|
3833
|
+
...from ? { from } : {},
|
|
3834
|
+
to,
|
|
3835
|
+
at: Date.now(),
|
|
3836
|
+
...meta ? { meta } : {}
|
|
3837
|
+
};
|
|
3838
|
+
try {
|
|
3839
|
+
this.emit(FABRIC_WORKFLOW_ITEM_EVENT, event);
|
|
3840
|
+
} catch (error) {
|
|
3841
|
+
console.warn(
|
|
3842
|
+
`[pi-fabric] workflow item event listener failed: ${error instanceof Error ? error.message : String(error)}`
|
|
3843
|
+
);
|
|
3844
|
+
}
|
|
3845
|
+
}
|
|
3846
|
+
};
|
|
3847
|
+
|
|
3654
3848
|
// src/runtime/python-error-guidance.ts
|
|
3655
3849
|
function pythonErrorRecoveryHint(code, error, backend) {
|
|
3656
3850
|
const text = error.slice(0, 8e3) + "\n" + error.slice(-8e3);
|
|
@@ -3906,12 +4100,358 @@ var BLOCKING_ORCHESTRATION_REFS = /* @__PURE__ */ new Set([
|
|
|
3906
4100
|
"agents.ask",
|
|
3907
4101
|
"jev.run",
|
|
3908
4102
|
"jev.wait",
|
|
3909
|
-
"jev.join"
|
|
4103
|
+
"jev.join",
|
|
4104
|
+
"programs.run"
|
|
3910
4105
|
]);
|
|
3911
4106
|
var isBlockingOrchestrationRef = (ref) => BLOCKING_ORCHESTRATION_REFS.has(ref);
|
|
3912
|
-
var ORCHESTRATION_RE = /\b(?:workflow\.agent|agents\.(?:run|wait|join|ask)|jev\.(?:run|wait|join)|council\.run|rlm\.query)\s*(?:<[^<>]*>)?\s*\(|(?<!\.)\bagent\s*(?:<[^<>]*>)?\s*\(/;
|
|
4107
|
+
var ORCHESTRATION_RE = /\b(?:workflow\.agent|agents\.(?:run|wait|join|ask)|jev\.(?:run|wait|join)|programs\.run|council\.run|rlm\.query)\s*(?:<[^<>]*>)?\s*\(|(?<!\.)\bagent\s*(?:<[^<>]*>)?\s*\(/;
|
|
3913
4108
|
var codeUsesOrchestration = (code) => ORCHESTRATION_RE.test(code);
|
|
3914
4109
|
|
|
4110
|
+
// src/topology/provider-participants.ts
|
|
4111
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
4112
|
+
var PROVIDER_PARTICIPANT_PREFIX = "provider:";
|
|
4113
|
+
var PROGRAM_CANCELLED_REASON = "program_cancelled";
|
|
4114
|
+
var OWNED_WORK_STOP_TIMEOUT_MS = 5e3;
|
|
4115
|
+
var ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/;
|
|
4116
|
+
var KIND_PATTERN = /^[a-z][a-z0-9._-]{0,31}$/;
|
|
4117
|
+
var MAX_LABEL_CHARS2 = 120;
|
|
4118
|
+
var MAX_PHASE_CHARS = 64;
|
|
4119
|
+
var MAX_MESSAGE_CHARS = 500;
|
|
4120
|
+
var MAX_SUMMARY_CHARS = 2e3;
|
|
4121
|
+
var MAX_CONTROL_MESSAGE_CHARS = 2e4;
|
|
4122
|
+
var MAX_ACTIVE = 256;
|
|
4123
|
+
var MAX_SETTLED = 64;
|
|
4124
|
+
var SETTLED_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "stopped"]);
|
|
4125
|
+
var isProviderParticipantRef = (value) => value.startsWith(PROVIDER_PARTICIPANT_PREFIX);
|
|
4126
|
+
var boundedText = (value, field, max, required = false) => {
|
|
4127
|
+
if (value === void 0 && !required) return void 0;
|
|
4128
|
+
if (typeof value !== "string") throw new TypeError(`Fabric participant ${field} must be a string`);
|
|
4129
|
+
const text = value.trim();
|
|
4130
|
+
if (required && !text) throw new TypeError(`Fabric participant ${field} must not be empty`);
|
|
4131
|
+
if (text.length > max) throw new RangeError(`Fabric participant ${field} exceeds ${max} characters`);
|
|
4132
|
+
return text || void 0;
|
|
4133
|
+
};
|
|
4134
|
+
var usageFrom = (value) => {
|
|
4135
|
+
if (value === void 0) return void 0;
|
|
4136
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
4137
|
+
throw new TypeError("Fabric participant usage must be an object");
|
|
4138
|
+
}
|
|
4139
|
+
const record = value;
|
|
4140
|
+
const usage = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0 };
|
|
4141
|
+
for (const key of Object.keys(record)) {
|
|
4142
|
+
if (!(key in usage)) throw new TypeError(`Unknown Fabric participant usage field: ${key}`);
|
|
4143
|
+
const amount = record[key];
|
|
4144
|
+
if (amount === void 0) continue;
|
|
4145
|
+
if (typeof amount !== "number" || !Number.isFinite(amount) || amount < 0) {
|
|
4146
|
+
throw new RangeError(`Fabric participant usage.${key} must be a non-negative finite number`);
|
|
4147
|
+
}
|
|
4148
|
+
usage[key] = amount;
|
|
4149
|
+
}
|
|
4150
|
+
return usage;
|
|
4151
|
+
};
|
|
4152
|
+
var capabilitiesOf = (entry) => entry.status !== "running" ? [] : [
|
|
4153
|
+
...entry.spec.steer ? ["steer"] : [],
|
|
4154
|
+
...entry.spec.followUp ? ["followUp"] : [],
|
|
4155
|
+
"stop"
|
|
4156
|
+
];
|
|
4157
|
+
var activityOf = (entry) => {
|
|
4158
|
+
const text = entry.status === "running" ? entry.phase && entry.message ? `${entry.phase}: ${entry.message}` : entry.phase ?? entry.message : entry.summary;
|
|
4159
|
+
return text ? text.slice(0, 160) : void 0;
|
|
4160
|
+
};
|
|
4161
|
+
var ProviderParticipantRegistry = class {
|
|
4162
|
+
#entries = /* @__PURE__ */ new Map();
|
|
4163
|
+
#listeners = /* @__PURE__ */ new Set();
|
|
4164
|
+
/** Per-invocation, provider-bound registration view handed to `invoke`. */
|
|
4165
|
+
view(provider, invocationId) {
|
|
4166
|
+
return Object.freeze({
|
|
4167
|
+
register: (spec) => this.#register(provider, invocationId, spec)
|
|
4168
|
+
});
|
|
4169
|
+
}
|
|
4170
|
+
subscribe(listener) {
|
|
4171
|
+
this.#listeners.add(listener);
|
|
4172
|
+
return () => this.#listeners.delete(listener);
|
|
4173
|
+
}
|
|
4174
|
+
has(ref) {
|
|
4175
|
+
return this.#entries.has(ref);
|
|
4176
|
+
}
|
|
4177
|
+
get(ref) {
|
|
4178
|
+
const entry = this.#entries.get(ref);
|
|
4179
|
+
return entry ? this.#info(entry) : void 0;
|
|
4180
|
+
}
|
|
4181
|
+
list() {
|
|
4182
|
+
return [...this.#entries.values()].map((entry) => this.#info(entry));
|
|
4183
|
+
}
|
|
4184
|
+
/** Directory records; the directory stamps owner host and identity on publish. */
|
|
4185
|
+
records(rootId, ownerHostId, ownerIdentityId) {
|
|
4186
|
+
return [...this.#entries.values()].map((entry) => {
|
|
4187
|
+
const activity = activityOf(entry);
|
|
4188
|
+
return {
|
|
4189
|
+
format: 1,
|
|
4190
|
+
id: entry.ref,
|
|
4191
|
+
kind: "provider",
|
|
4192
|
+
rootId,
|
|
4193
|
+
ownerHostId,
|
|
4194
|
+
ownerIdentityId,
|
|
4195
|
+
parentId: rootId,
|
|
4196
|
+
name: entry.label,
|
|
4197
|
+
status: entry.status,
|
|
4198
|
+
residency: "session",
|
|
4199
|
+
provider: entry.provider,
|
|
4200
|
+
transport: "host",
|
|
4201
|
+
capabilities: capabilitiesOf(entry),
|
|
4202
|
+
startedAt: entry.startedAt,
|
|
4203
|
+
updatedAt: entry.updatedAt,
|
|
4204
|
+
...entry.finishedAt !== void 0 ? { finishedAt: entry.finishedAt } : {},
|
|
4205
|
+
...activity ? { currentTool: activity } : {},
|
|
4206
|
+
...entry.usage ? { usage: { ...entry.usage } } : {},
|
|
4207
|
+
controlProtocol: "v1"
|
|
4208
|
+
};
|
|
4209
|
+
});
|
|
4210
|
+
}
|
|
4211
|
+
async stop(ref, reason = "stopped") {
|
|
4212
|
+
const entry = this.#require(ref);
|
|
4213
|
+
if (entry.status !== "running") throw new Error(`Fabric participant ${ref} is already ${entry.status}`);
|
|
4214
|
+
return this.#stop(entry, reason, void 0);
|
|
4215
|
+
}
|
|
4216
|
+
async deliver(ref, operation, message2) {
|
|
4217
|
+
const entry = this.#require(ref);
|
|
4218
|
+
if (entry.status !== "running") throw new Error(`Fabric participant ${ref} is already ${entry.status}`);
|
|
4219
|
+
const deliver = entry.spec[operation];
|
|
4220
|
+
if (!deliver) throw new Error(`Fabric participant ${ref} does not support ${operation}`);
|
|
4221
|
+
const text = boundedText(message2, "message", MAX_CONTROL_MESSAGE_CHARS, true);
|
|
4222
|
+
await deliver.call(entry.spec, text);
|
|
4223
|
+
}
|
|
4224
|
+
/**
|
|
4225
|
+
* Stop every unsettled, non-detached participant registered during the
|
|
4226
|
+
* invocation, in parallel, within one shared deadline.
|
|
4227
|
+
*/
|
|
4228
|
+
async cancelInvocation(invocationId, reason = PROGRAM_CANCELLED_REASON, timeoutMs = OWNED_WORK_STOP_TIMEOUT_MS) {
|
|
4229
|
+
const owned = [...this.#entries.values()].filter(
|
|
4230
|
+
(entry) => entry.invocationId === invocationId && !entry.detached && entry.status === "running"
|
|
4231
|
+
);
|
|
4232
|
+
if (owned.length === 0) return [];
|
|
4233
|
+
let timer;
|
|
4234
|
+
const deadline = new Promise((resolve2) => {
|
|
4235
|
+
timer = setTimeout(() => resolve2("timeout"), Math.max(0, timeoutMs));
|
|
4236
|
+
timer.unref?.();
|
|
4237
|
+
});
|
|
4238
|
+
try {
|
|
4239
|
+
return await Promise.all(owned.map((entry) => this.#stop(entry, reason, deadline)));
|
|
4240
|
+
} finally {
|
|
4241
|
+
if (timer) clearTimeout(timer);
|
|
4242
|
+
}
|
|
4243
|
+
}
|
|
4244
|
+
/** Forget a withdrawn provider's participants; their handles become inert. */
|
|
4245
|
+
releaseProvider(provider) {
|
|
4246
|
+
let released = 0;
|
|
4247
|
+
for (const [ref, entry] of this.#entries) {
|
|
4248
|
+
if (entry.provider !== provider) continue;
|
|
4249
|
+
this.#entries.delete(ref);
|
|
4250
|
+
released++;
|
|
4251
|
+
}
|
|
4252
|
+
if (released > 0) this.#notify();
|
|
4253
|
+
return released;
|
|
4254
|
+
}
|
|
4255
|
+
/** Session shutdown: forget every participant without calling providers. */
|
|
4256
|
+
releaseAll() {
|
|
4257
|
+
const had = this.#entries.size > 0;
|
|
4258
|
+
this.#entries.clear();
|
|
4259
|
+
if (had) this.#notify();
|
|
4260
|
+
this.#listeners.clear();
|
|
4261
|
+
}
|
|
4262
|
+
#register(provider, invocationId, spec) {
|
|
4263
|
+
if (typeof spec !== "object" || spec === null) throw new TypeError("Fabric participant spec must be an object");
|
|
4264
|
+
if (typeof spec.id !== "string" || !ID_PATTERN.test(spec.id)) {
|
|
4265
|
+
throw new TypeError("Fabric participant id must match [A-Za-z0-9][A-Za-z0-9._:-]{0,63}");
|
|
4266
|
+
}
|
|
4267
|
+
const label = boundedText(spec.label, "label", MAX_LABEL_CHARS2, true);
|
|
4268
|
+
if (spec.kind !== void 0 && (typeof spec.kind !== "string" || !KIND_PATTERN.test(spec.kind))) {
|
|
4269
|
+
throw new TypeError("Fabric participant kind must match [a-z][a-z0-9._-]{0,31}");
|
|
4270
|
+
}
|
|
4271
|
+
if (spec.detached !== void 0 && typeof spec.detached !== "boolean") {
|
|
4272
|
+
throw new TypeError("Fabric participant detached must be a boolean");
|
|
4273
|
+
}
|
|
4274
|
+
if (typeof spec.stop !== "function") throw new TypeError("Fabric participant stop must be a function");
|
|
4275
|
+
for (const optional of ["steer", "followUp"]) {
|
|
4276
|
+
if (spec[optional] !== void 0 && typeof spec[optional] !== "function") {
|
|
4277
|
+
throw new TypeError(`Fabric participant ${optional} must be a function`);
|
|
4278
|
+
}
|
|
4279
|
+
}
|
|
4280
|
+
const ref = `${PROVIDER_PARTICIPANT_PREFIX}${provider}:${spec.id}`;
|
|
4281
|
+
const existing = this.#entries.get(ref);
|
|
4282
|
+
if (existing?.status === "running") throw new Error(`Fabric participant ${ref} is already registered`);
|
|
4283
|
+
if (existing) this.#entries.delete(ref);
|
|
4284
|
+
const active = [...this.#entries.values()].filter((entry2) => entry2.status === "running").length;
|
|
4285
|
+
if (active >= MAX_ACTIVE) throw new Error(`Fabric participant limit reached (${MAX_ACTIVE} active)`);
|
|
4286
|
+
const now = Date.now();
|
|
4287
|
+
const entry = {
|
|
4288
|
+
ref,
|
|
4289
|
+
provider,
|
|
4290
|
+
id: spec.id,
|
|
4291
|
+
label,
|
|
4292
|
+
kind: spec.kind,
|
|
4293
|
+
detached: spec.detached === true,
|
|
4294
|
+
invocationId,
|
|
4295
|
+
// Freeze the callbacks at registration so later spec mutation cannot
|
|
4296
|
+
// change what a stop or steer reaches.
|
|
4297
|
+
spec: Object.freeze({
|
|
4298
|
+
id: spec.id,
|
|
4299
|
+
label,
|
|
4300
|
+
stop: spec.stop.bind(spec),
|
|
4301
|
+
...spec.steer ? { steer: spec.steer.bind(spec) } : {},
|
|
4302
|
+
...spec.followUp ? { followUp: spec.followUp.bind(spec) } : {}
|
|
4303
|
+
}),
|
|
4304
|
+
startedAt: now,
|
|
4305
|
+
status: "running",
|
|
4306
|
+
updatedAt: now
|
|
4307
|
+
};
|
|
4308
|
+
this.#entries.set(ref, entry);
|
|
4309
|
+
this.#notify();
|
|
4310
|
+
const live = () => this.#entries.get(ref) === entry;
|
|
4311
|
+
return Object.freeze({
|
|
4312
|
+
ref,
|
|
4313
|
+
update: (progress) => {
|
|
4314
|
+
if (!live() || entry.status !== "running") return;
|
|
4315
|
+
if (typeof progress !== "object" || progress === null) {
|
|
4316
|
+
throw new TypeError("Fabric participant progress must be an object");
|
|
4317
|
+
}
|
|
4318
|
+
const phase = boundedText(progress.phase, "phase", MAX_PHASE_CHARS);
|
|
4319
|
+
const message2 = boundedText(progress.message, "message", MAX_MESSAGE_CHARS);
|
|
4320
|
+
const usage = usageFrom(progress.usage);
|
|
4321
|
+
if (progress.phase !== void 0) {
|
|
4322
|
+
if (phase) entry.phase = phase;
|
|
4323
|
+
else delete entry.phase;
|
|
4324
|
+
}
|
|
4325
|
+
if (progress.message !== void 0) {
|
|
4326
|
+
if (message2) entry.message = message2;
|
|
4327
|
+
else delete entry.message;
|
|
4328
|
+
}
|
|
4329
|
+
if (usage) entry.usage = usage;
|
|
4330
|
+
entry.updatedAt = Date.now();
|
|
4331
|
+
this.#notify();
|
|
4332
|
+
},
|
|
4333
|
+
settle: (result) => {
|
|
4334
|
+
if (typeof result !== "object" || result === null || !SETTLED_STATUSES.has(result.status)) {
|
|
4335
|
+
throw new TypeError('Fabric participant settle status must be "completed", "failed", or "stopped"');
|
|
4336
|
+
}
|
|
4337
|
+
const summary = boundedText(result.summary, "summary", MAX_SUMMARY_CHARS);
|
|
4338
|
+
if (!live() || entry.status !== "running") return;
|
|
4339
|
+
this.#settle(entry, result.status, summary);
|
|
4340
|
+
},
|
|
4341
|
+
dispose: () => {
|
|
4342
|
+
if (!live()) return;
|
|
4343
|
+
this.#entries.delete(ref);
|
|
4344
|
+
this.#notify();
|
|
4345
|
+
}
|
|
4346
|
+
});
|
|
4347
|
+
}
|
|
4348
|
+
async #stop(entry, reason, deadline) {
|
|
4349
|
+
let settled;
|
|
4350
|
+
try {
|
|
4351
|
+
const request = Promise.resolve().then(() => entry.spec.stop(reason));
|
|
4352
|
+
settled = await (deadline ? Promise.race([request, deadline]) : request);
|
|
4353
|
+
} catch {
|
|
4354
|
+
settled = "error";
|
|
4355
|
+
}
|
|
4356
|
+
if (settled === "timeout" || settled === "error") {
|
|
4357
|
+
return { ref: entry.ref, outcome: "unconfirmed", detail: settled };
|
|
4358
|
+
}
|
|
4359
|
+
if (typeof settled !== "object" || settled === null || settled.confirmed !== true) {
|
|
4360
|
+
return { ref: entry.ref, outcome: "unconfirmed", detail: "declined" };
|
|
4361
|
+
}
|
|
4362
|
+
if (this.#entries.get(entry.ref) === entry && entry.status === "running") {
|
|
4363
|
+
this.#settle(entry, "stopped", void 0);
|
|
4364
|
+
}
|
|
4365
|
+
return { ref: entry.ref, outcome: "confirmed" };
|
|
4366
|
+
}
|
|
4367
|
+
#settle(entry, status, summary) {
|
|
4368
|
+
entry.status = status;
|
|
4369
|
+
if (summary) entry.summary = summary;
|
|
4370
|
+
entry.finishedAt = entry.updatedAt = Date.now();
|
|
4371
|
+
const settled = [...this.#entries.values()].filter((candidate) => candidate.status !== "running");
|
|
4372
|
+
for (const stale of settled.slice(0, Math.max(0, settled.length - MAX_SETTLED))) {
|
|
4373
|
+
this.#entries.delete(stale.ref);
|
|
4374
|
+
}
|
|
4375
|
+
this.#notify();
|
|
4376
|
+
}
|
|
4377
|
+
#require(ref) {
|
|
4378
|
+
const entry = this.#entries.get(ref);
|
|
4379
|
+
if (!entry) throw new Error(`Unknown Fabric participant: ${ref}`);
|
|
4380
|
+
return entry;
|
|
4381
|
+
}
|
|
4382
|
+
#info(entry) {
|
|
4383
|
+
return {
|
|
4384
|
+
ref: entry.ref,
|
|
4385
|
+
provider: entry.provider,
|
|
4386
|
+
id: entry.id,
|
|
4387
|
+
label: entry.label,
|
|
4388
|
+
...entry.kind ? { kind: entry.kind } : {},
|
|
4389
|
+
detached: entry.detached,
|
|
4390
|
+
status: entry.status,
|
|
4391
|
+
startedAt: entry.startedAt,
|
|
4392
|
+
updatedAt: entry.updatedAt,
|
|
4393
|
+
...entry.finishedAt !== void 0 ? { finishedAt: entry.finishedAt } : {},
|
|
4394
|
+
...entry.phase ? { phase: entry.phase } : {},
|
|
4395
|
+
...entry.message ? { message: entry.message } : {},
|
|
4396
|
+
...entry.summary ? { summary: entry.summary } : {},
|
|
4397
|
+
...entry.usage ? { usage: { ...entry.usage } } : {},
|
|
4398
|
+
capabilities: capabilitiesOf(entry)
|
|
4399
|
+
};
|
|
4400
|
+
}
|
|
4401
|
+
#notify() {
|
|
4402
|
+
for (const listener of this.#listeners) {
|
|
4403
|
+
try {
|
|
4404
|
+
listener();
|
|
4405
|
+
} catch {
|
|
4406
|
+
}
|
|
4407
|
+
}
|
|
4408
|
+
}
|
|
4409
|
+
};
|
|
4410
|
+
var controlProviderParticipant = async (registry, directory, control, ref, operation, message2, data) => {
|
|
4411
|
+
if (operation !== "stop" && data !== void 0) {
|
|
4412
|
+
throw new Error(`Fabric participant ${ref} does not accept message data`);
|
|
4413
|
+
}
|
|
4414
|
+
if (registry?.has(ref)) {
|
|
4415
|
+
if (operation === "stop") return registry.stop(ref);
|
|
4416
|
+
await registry.deliver(ref, operation, message2 ?? "");
|
|
4417
|
+
return { queued: true, messageId: randomUUID3(), routed: "local" };
|
|
4418
|
+
}
|
|
4419
|
+
const participant = directory.get(ref);
|
|
4420
|
+
if (!participant || participant.kind !== "provider" || participant.local) {
|
|
4421
|
+
throw new Error(`Unknown Fabric participant: ${ref}`);
|
|
4422
|
+
}
|
|
4423
|
+
if (!participant.capabilities.includes(operation)) {
|
|
4424
|
+
throw new Error(`Fabric participant ${ref} does not support ${operation}`);
|
|
4425
|
+
}
|
|
4426
|
+
if (!control) throw new Error("Fabric control plane is unavailable");
|
|
4427
|
+
return control.request(
|
|
4428
|
+
participant.ownerHostId,
|
|
4429
|
+
participant.id,
|
|
4430
|
+
operation,
|
|
4431
|
+
{
|
|
4432
|
+
...operation === "stop" ? {} : { message: message2 ?? "" },
|
|
4433
|
+
...participant.ownerIncarnation ? { ownerIncarnation: participant.ownerIncarnation } : {}
|
|
4434
|
+
},
|
|
4435
|
+
participant.ownerIdentityId
|
|
4436
|
+
);
|
|
4437
|
+
};
|
|
4438
|
+
var acceptProviderParticipantControl = async (registry, command) => {
|
|
4439
|
+
const ref = command.targetId;
|
|
4440
|
+
if (!registry?.has(ref)) return { accepted: false, error: `Owner does not control Fabric participant ${ref}` };
|
|
4441
|
+
try {
|
|
4442
|
+
if (command.operation === "stop") {
|
|
4443
|
+
return { accepted: true, messageId: command.commandId, result: await registry.stop(ref) };
|
|
4444
|
+
}
|
|
4445
|
+
if (command.operation === "steer" || command.operation === "followUp") {
|
|
4446
|
+
await registry.deliver(ref, command.operation, command.message ?? "");
|
|
4447
|
+
return { accepted: true, messageId: command.commandId };
|
|
4448
|
+
}
|
|
4449
|
+
return { accepted: false, error: `Fabric participant ${ref} does not support ${command.operation}` };
|
|
4450
|
+
} catch (error) {
|
|
4451
|
+
return { accepted: false, error: error instanceof Error ? error.message : String(error) };
|
|
4452
|
+
}
|
|
4453
|
+
};
|
|
4454
|
+
|
|
3915
4455
|
// src/execution-service.ts
|
|
3916
4456
|
var executionOutcomeFromTermination = (reason) => {
|
|
3917
4457
|
switch (reason) {
|
|
@@ -3941,6 +4481,16 @@ var aggregateUsage = (usages) => ({
|
|
|
3941
4481
|
total: usages.reduce((total, usage) => total + usage.cost.total, 0)
|
|
3942
4482
|
}
|
|
3943
4483
|
});
|
|
4484
|
+
var stopOwnedWork = async (participants, invocationId, trace) => {
|
|
4485
|
+
const outcomes = await participants.cancelInvocation(invocationId, PROGRAM_CANCELLED_REASON);
|
|
4486
|
+
for (const stop of outcomes) {
|
|
4487
|
+
const operation = trace.issueCall("fabric.participant.stop", { ref: stop.ref, reason: PROGRAM_CANCELLED_REASON });
|
|
4488
|
+
if (stop.outcome === "confirmed") operation.succeed(stop);
|
|
4489
|
+
else operation.fail("invoke", void 0, "failed", stop);
|
|
4490
|
+
}
|
|
4491
|
+
return outcomes;
|
|
4492
|
+
};
|
|
4493
|
+
var MAX_NESTED_PROGRAM_RUNS = 16;
|
|
3944
4494
|
var FabricExecutionService = class {
|
|
3945
4495
|
constructor(registry, config, activity, authorizer, autoApprovalClassifier = new FabricAutoApprovalClassifier(() => config.jev), sessionApprovals = new FabricSessionApprovals(), capturedTools, brokeredNetwork) {
|
|
3946
4496
|
this.registry = registry;
|
|
@@ -3955,12 +4505,51 @@ var FabricExecutionService = class {
|
|
|
3955
4505
|
#runtime;
|
|
3956
4506
|
#runtimeKind;
|
|
3957
4507
|
#capabilityView;
|
|
4508
|
+
#emitEvent;
|
|
4509
|
+
#headlessApproval;
|
|
4510
|
+
#participants;
|
|
4511
|
+
#nestedRunners = /* @__PURE__ */ new Map();
|
|
3958
4512
|
setCapabilityView(view) {
|
|
3959
4513
|
this.#capabilityView = view;
|
|
3960
4514
|
}
|
|
4515
|
+
/** Host event bus for observation-only events such as workflow item transitions. */
|
|
4516
|
+
setEventEmitter(emit) {
|
|
4517
|
+
this.#emitEvent = emit;
|
|
4518
|
+
}
|
|
4519
|
+
/** Session registry behind `context.participants` and owned-work cancellation. */
|
|
4520
|
+
setParticipantRegistry(registry) {
|
|
4521
|
+
this.#participants = registry;
|
|
4522
|
+
}
|
|
4523
|
+
/** The nested program runner of the active execution with this outer call id. */
|
|
4524
|
+
nestedProgramRunner(parentToolCallId) {
|
|
4525
|
+
return this.#nestedRunners.get(parentToolCallId);
|
|
4526
|
+
}
|
|
4527
|
+
/** No-UI approval fallback used when approvals.headless is "decision". */
|
|
4528
|
+
setHeadlessApproval(handler) {
|
|
4529
|
+
this.#headlessApproval = handler;
|
|
4530
|
+
}
|
|
3961
4531
|
async execute(options) {
|
|
4532
|
+
const executor = this.config.executor;
|
|
4533
|
+
if (process.env.PI_FABRIC_WRITE_POLICY && (executor.kernel === "python" ? executor.pythonRuntime !== "monty" : this.config.schema.mode !== "enforce" && executor.runtime !== "quickjs")) {
|
|
4534
|
+
const { readWritePolicy } = await import("./agents/write-guard.js");
|
|
4535
|
+
if (readWritePolicy()?.shell !== "unconfined") {
|
|
4536
|
+
throw new Error('Fabric write policy refuses native executors (CPython, node-process, bun-process); the parent must request shell: "unconfined"');
|
|
4537
|
+
}
|
|
4538
|
+
}
|
|
3962
4539
|
const startedAt = performance.now();
|
|
3963
|
-
const
|
|
4540
|
+
const assessment = this.config.trace.assessment ? new FabricAssessmentRecorder() : void 0;
|
|
4541
|
+
const traceRecorder = new FabricExecutionTraceRecorder(assessment);
|
|
4542
|
+
let sessionId;
|
|
4543
|
+
try {
|
|
4544
|
+
sessionId = options.context.sessionManager?.getSessionId?.() || void 0;
|
|
4545
|
+
} catch {
|
|
4546
|
+
sessionId = void 0;
|
|
4547
|
+
}
|
|
4548
|
+
const itemTransitions = new FabricWorkflowItemTransitions(
|
|
4549
|
+
options.parentToolCallId,
|
|
4550
|
+
this.#emitEvent,
|
|
4551
|
+
sessionId
|
|
4552
|
+
);
|
|
3964
4553
|
this.activity?.start(
|
|
3965
4554
|
options.parentToolCallId,
|
|
3966
4555
|
options.display,
|
|
@@ -3988,6 +4577,7 @@ var FabricExecutionService = class {
|
|
|
3988
4577
|
}
|
|
3989
4578
|
let code = options.code;
|
|
3990
4579
|
let checked2 = { errors: [] };
|
|
4580
|
+
let guestTypeSources = {};
|
|
3991
4581
|
const unavailable = new Map(
|
|
3992
4582
|
this.registry.unavailableProviders().map((entry) => [entry.name, entry.reason])
|
|
3993
4583
|
);
|
|
@@ -3997,7 +4587,7 @@ var FabricExecutionService = class {
|
|
|
3997
4587
|
})) ?? [];
|
|
3998
4588
|
const piToolCanonicalFields = Object.fromEntries(coreOverrides.filter((entry) => PI_CORE_TOOL_NAME_SET.has(entry.name)).map((entry) => [entry.name, Object.keys(entry.inputSchema.properties ?? {})]));
|
|
3999
4589
|
if (!python) {
|
|
4000
|
-
|
|
4590
|
+
guestTypeSources = await this.registry.guestTypeSources({
|
|
4001
4591
|
cwd: options.context.cwd,
|
|
4002
4592
|
signal: options.signal,
|
|
4003
4593
|
parentToolCallId: options.parentToolCallId,
|
|
@@ -4024,6 +4614,11 @@ var FabricExecutionService = class {
|
|
|
4024
4614
|
}
|
|
4025
4615
|
}
|
|
4026
4616
|
this.activity?.finish(options.parentToolCallId, false, "Type checking failed");
|
|
4617
|
+
const failedTrace = traceRecorder.seal(
|
|
4618
|
+
"failed",
|
|
4619
|
+
[],
|
|
4620
|
+
`Type checking failed (${checked2.errors.length} ${checked2.errors.length === 1 ? "error" : "errors"})`
|
|
4621
|
+
);
|
|
4027
4622
|
return {
|
|
4028
4623
|
success: false,
|
|
4029
4624
|
kernel: "typescript",
|
|
@@ -4031,11 +4626,8 @@ var FabricExecutionService = class {
|
|
|
4031
4626
|
logs: [],
|
|
4032
4627
|
audits: [],
|
|
4033
4628
|
phases: [],
|
|
4034
|
-
trace:
|
|
4035
|
-
|
|
4036
|
-
[],
|
|
4037
|
-
`Type checking failed (${checked2.errors.length} ${checked2.errors.length === 1 ? "error" : "errors"})`
|
|
4038
|
-
),
|
|
4629
|
+
trace: failedTrace,
|
|
4630
|
+
...assessment ? { assessment: assessment.seal("failed") } : {},
|
|
4039
4631
|
elapsedMs: performance.now() - startedAt,
|
|
4040
4632
|
typeErrors: checked2.errors
|
|
4041
4633
|
};
|
|
@@ -4047,7 +4639,15 @@ var FabricExecutionService = class {
|
|
|
4047
4639
|
risk: audit.risk
|
|
4048
4640
|
});
|
|
4049
4641
|
operation.succeed(audit);
|
|
4050
|
-
if (decision)
|
|
4642
|
+
if (decision) {
|
|
4643
|
+
classifierUsages.push(decision.usage);
|
|
4644
|
+
const usage = readFabricAssessmentUsage(decision.usage);
|
|
4645
|
+
assessment?.attribute(operation.sequence, {
|
|
4646
|
+
source: "classifier",
|
|
4647
|
+
...audit.model ? { model: audit.model } : {},
|
|
4648
|
+
...usage ? { usage } : {}
|
|
4649
|
+
});
|
|
4650
|
+
}
|
|
4051
4651
|
};
|
|
4052
4652
|
const approval = new ApprovalController(
|
|
4053
4653
|
this.config.approvals,
|
|
@@ -4055,7 +4655,8 @@ var FabricExecutionService = class {
|
|
|
4055
4655
|
this.sessionApprovals,
|
|
4056
4656
|
this.autoApprovalClassifier,
|
|
4057
4657
|
recordAutoDecision,
|
|
4058
|
-
this.brokeredNetwork
|
|
4658
|
+
this.brokeredNetwork,
|
|
4659
|
+
this.#headlessApproval ? (action, reason) => this.#headlessApproval(action, reason, options.signal) : void 0
|
|
4059
4660
|
);
|
|
4060
4661
|
const audits = [];
|
|
4061
4662
|
const phases = [];
|
|
@@ -4184,6 +4785,8 @@ var FabricExecutionService = class {
|
|
|
4184
4785
|
) : 0;
|
|
4185
4786
|
return Math.max(orchestrationTimeoutMs, requestedTimeoutMs2);
|
|
4186
4787
|
};
|
|
4788
|
+
const humanWaitRefs = new Set(this.config.executor.humanWaitRefs);
|
|
4789
|
+
const isHumanWaitHostCall = (ref, args) => humanWaitRefs.has(ref === "fabric.$call" && typeof args.ref === "string" ? args.ref : ref);
|
|
4187
4790
|
const traceAttempt = async (ref, args, signal, run) => {
|
|
4188
4791
|
const operation = traceRecorder.issueCall(ref, args);
|
|
4189
4792
|
let stage = "invoke";
|
|
@@ -4211,8 +4814,13 @@ var FabricExecutionService = class {
|
|
|
4211
4814
|
);
|
|
4212
4815
|
throw error;
|
|
4213
4816
|
}
|
|
4817
|
+
const participants = this.#participants;
|
|
4818
|
+
const separator = ref.indexOf(".");
|
|
4214
4819
|
return this.registry.invoke(ref, args, {
|
|
4215
4820
|
...callContext,
|
|
4821
|
+
// The registry resolves `provider.action` by this exact prefix, so the
|
|
4822
|
+
// view is bound to the provider that receives it.
|
|
4823
|
+
...participants && separator > 0 ? { participants: participants.view(ref.slice(0, separator), options.parentToolCallId) } : {},
|
|
4216
4824
|
...ref === "agents.handoff" ? {
|
|
4217
4825
|
deferHandoff(request) {
|
|
4218
4826
|
if (handoffRequest) {
|
|
@@ -4246,10 +4854,95 @@ var FabricExecutionService = class {
|
|
|
4246
4854
|
});
|
|
4247
4855
|
};
|
|
4248
4856
|
let sandboxResult;
|
|
4857
|
+
let hostCall;
|
|
4858
|
+
const sandboxBase = {
|
|
4859
|
+
cwd: options.context.cwd,
|
|
4860
|
+
memoryLimitBytes: this.config.executor.memoryLimitBytes,
|
|
4861
|
+
maxLogChars: this.config.executor.maxOutputChars,
|
|
4862
|
+
minimumTimeoutMsForHostCall,
|
|
4863
|
+
...humanWaitRefs.size > 0 ? { isHumanWaitHostCall } : {},
|
|
4864
|
+
...!python ? { piToolCanonicalFields } : {},
|
|
4865
|
+
...options.tokenBudget !== void 0 ? { tokenBudget: options.tokenBudget } : {}
|
|
4866
|
+
};
|
|
4867
|
+
const nestedLogs = [];
|
|
4868
|
+
let nestedLogChars = 0;
|
|
4869
|
+
let nestedRuns = 0;
|
|
4870
|
+
const preparedPrograms = /* @__PURE__ */ new Map();
|
|
4871
|
+
const runNestedProgram = async (request, signal) => {
|
|
4872
|
+
const bridge = hostCall;
|
|
4873
|
+
if (!bridge) throw new Error("Fabric program runs need an active execution");
|
|
4874
|
+
nestedRuns++;
|
|
4875
|
+
if (nestedRuns > MAX_NESTED_PROGRAM_RUNS) {
|
|
4876
|
+
throw new FabricTraceSafeError(`Fabric nested program budget exhausted (${MAX_NESTED_PROGRAM_RUNS} per execution)`);
|
|
4877
|
+
}
|
|
4878
|
+
const operation = traceRecorder.issueCall("fabric.program.run", {
|
|
4879
|
+
program: request.program,
|
|
4880
|
+
...options.invokedBy ? { invokedBy: options.invokedBy } : {}
|
|
4881
|
+
});
|
|
4882
|
+
const runSignal = signal ?? new AbortController().signal;
|
|
4883
|
+
let stage = "invoke";
|
|
4884
|
+
try {
|
|
4885
|
+
if (request.call) {
|
|
4886
|
+
const value = await bridge(request.call.ref, request.call.args, runSignal);
|
|
4887
|
+
operation.succeed(void 0);
|
|
4888
|
+
return value;
|
|
4889
|
+
}
|
|
4890
|
+
let source = request.code ?? "";
|
|
4891
|
+
let prepared = { errors: [] };
|
|
4892
|
+
if (!python) {
|
|
4893
|
+
stage = "prepare";
|
|
4894
|
+
const cached = preparedPrograms.get(source);
|
|
4895
|
+
const next = cached ?? runtime.prepare(
|
|
4896
|
+
source,
|
|
4897
|
+
effectiveFullCodeMode,
|
|
4898
|
+
[...unavailable.keys()],
|
|
4899
|
+
guestTypeSources,
|
|
4900
|
+
coreOverrides
|
|
4901
|
+
);
|
|
4902
|
+
if (!cached) preparedPrograms.set(source, next);
|
|
4903
|
+
({ code: source, checked: prepared } = next);
|
|
4904
|
+
if (prepared.errors.length > 0) {
|
|
4905
|
+
throw new Error(`Program ${request.program} has type errors: ${prepared.errors.slice(0, 5).map((error) => error.line > 0 ? `line ${error.line}:${error.column} ${error.message}` : error.message).join("; ")}`);
|
|
4906
|
+
}
|
|
4907
|
+
stage = "invoke";
|
|
4908
|
+
}
|
|
4909
|
+
const spanPrefix = `program-${nestedRuns}:`;
|
|
4910
|
+
const nestedBridge = (ref, args, callSignal) => (ref === "fabric.$spanStart" || ref === "fabric.$spanEnd") && typeof args.id === "string" ? bridge(ref, { ...args, id: `${spanPrefix}${args.id}` }, callSignal) : bridge(ref, args, callSignal);
|
|
4911
|
+
const result = await runtime.execute(source, nestedBridge, {
|
|
4912
|
+
...sandboxBase,
|
|
4913
|
+
timeoutMs: codeUsesOrchestration(source) ? orchestrationTimeoutMs : this.config.executor.timeoutMs,
|
|
4914
|
+
...prepared.javascript ? { transpiledCode: prepared.javascript } : {},
|
|
4915
|
+
...prepared.sourceMap ? { transpiledSourceMap: prepared.sourceMap } : {},
|
|
4916
|
+
signal: runSignal
|
|
4917
|
+
});
|
|
4918
|
+
for (const line of result.logs) {
|
|
4919
|
+
if (nestedLogChars > this.config.executor.maxOutputChars) break;
|
|
4920
|
+
nestedLogChars += line.length;
|
|
4921
|
+
nestedLogs.push(nestedLogChars > this.config.executor.maxOutputChars ? `[${request.program}] (nested program logs truncated)` : `[${request.program}] ${line}`);
|
|
4922
|
+
}
|
|
4923
|
+
if (result.terminationReason !== "completed") {
|
|
4924
|
+
const outcome = executionOutcomeFromTermination(result.terminationReason);
|
|
4925
|
+
throw Object.assign(
|
|
4926
|
+
new Error(`Program ${request.program} ${outcome.replace("_", " ")}: ${result.error ?? "no result"}`),
|
|
4927
|
+
{ programOutcome: outcome }
|
|
4928
|
+
);
|
|
4929
|
+
}
|
|
4930
|
+
operation.succeed(void 0);
|
|
4931
|
+
return result.value;
|
|
4932
|
+
} catch (error) {
|
|
4933
|
+
const outcome = error.programOutcome ?? executionOutcomeFromError(error, runSignal);
|
|
4934
|
+
operation.fail(stage, error, outcome);
|
|
4935
|
+
throw error;
|
|
4936
|
+
}
|
|
4937
|
+
};
|
|
4938
|
+
this.#nestedRunners.set(options.parentToolCallId, {
|
|
4939
|
+
kernel: python ? "python" : "typescript",
|
|
4940
|
+
run: runNestedProgram
|
|
4941
|
+
});
|
|
4249
4942
|
try {
|
|
4250
4943
|
sandboxResult = await runtime.execute(
|
|
4251
4944
|
code,
|
|
4252
|
-
async (ref, args, runtimeSignal) => {
|
|
4945
|
+
hostCall = async (ref, args, runtimeSignal) => {
|
|
4253
4946
|
const callContext = { ...baseContext, signal: runtimeSignal };
|
|
4254
4947
|
switch (ref) {
|
|
4255
4948
|
case "fabric.$providers":
|
|
@@ -4505,9 +5198,18 @@ var FabricExecutionService = class {
|
|
|
4505
5198
|
"fabric.workflow.item",
|
|
4506
5199
|
args,
|
|
4507
5200
|
runtimeSignal,
|
|
4508
|
-
() => {
|
|
4509
|
-
|
|
4510
|
-
|
|
5201
|
+
(setStage) => {
|
|
5202
|
+
setStage("validate");
|
|
5203
|
+
const transition = validateWorkflowItemInput(
|
|
5204
|
+
args,
|
|
5205
|
+
() => itemTransitions.nextDefaultId()
|
|
5206
|
+
);
|
|
5207
|
+
setStage("invoke");
|
|
5208
|
+
const { meta: _meta, ...rest } = args;
|
|
5209
|
+
const item = { ...rest, id: transition.id };
|
|
5210
|
+
const stored = this.activity?.upsertItem(options.parentToolCallId, item) ?? item;
|
|
5211
|
+
itemTransitions.record(transition, stored.label);
|
|
5212
|
+
return stored;
|
|
4511
5213
|
}
|
|
4512
5214
|
);
|
|
4513
5215
|
case "fabric.$event":
|
|
@@ -4551,24 +5253,24 @@ var FabricExecutionService = class {
|
|
|
4551
5253
|
}
|
|
4552
5254
|
},
|
|
4553
5255
|
{
|
|
5256
|
+
...sandboxBase,
|
|
4554
5257
|
timeoutMs: effectiveTimeoutMs,
|
|
4555
|
-
cwd: options.context.cwd,
|
|
4556
|
-
memoryLimitBytes: this.config.executor.memoryLimitBytes,
|
|
4557
|
-
maxLogChars: this.config.executor.maxOutputChars,
|
|
4558
|
-
minimumTimeoutMsForHostCall,
|
|
4559
|
-
...!python ? { piToolCanonicalFields } : {},
|
|
4560
5258
|
...checked2.javascript ? { transpiledCode: checked2.javascript } : {},
|
|
4561
5259
|
...checked2.sourceMap ? { transpiledSourceMap: checked2.sourceMap } : {},
|
|
4562
5260
|
...options.strings ? { strings: options.strings } : {},
|
|
4563
|
-
...options.tokenBudget !== void 0 ? { tokenBudget: options.tokenBudget } : {},
|
|
4564
5261
|
...options.signal ? { signal: options.signal } : {}
|
|
4565
5262
|
}
|
|
4566
5263
|
);
|
|
4567
5264
|
} catch (error) {
|
|
4568
5265
|
const message2 = error instanceof Error ? error.message : String(error);
|
|
4569
5266
|
this.activity?.finish(options.parentToolCallId, false, message2);
|
|
5267
|
+
itemTransitions.finish(false);
|
|
5268
|
+
if (options.signal?.aborted) {
|
|
5269
|
+
await this.#participants?.cancelInvocation(options.parentToolCallId).catch(() => void 0);
|
|
5270
|
+
}
|
|
4570
5271
|
throw error;
|
|
4571
5272
|
} finally {
|
|
5273
|
+
this.#nestedRunners.delete(options.parentToolCallId);
|
|
4572
5274
|
await this.registry.endInvocation(options.parentToolCallId);
|
|
4573
5275
|
flushEmit();
|
|
4574
5276
|
}
|
|
@@ -4580,22 +5282,31 @@ Recovery hint: ${hint}`;
|
|
|
4580
5282
|
}
|
|
4581
5283
|
const runOutcome = executionOutcomeFromTermination(sandboxResult.terminationReason);
|
|
4582
5284
|
const succeeded = runOutcome === "succeeded";
|
|
5285
|
+
const ownedWork = (runOutcome === "aborted" || runOutcome === "timed_out") && this.#participants ? await stopOwnedWork(this.#participants, options.parentToolCallId, traceRecorder) : [];
|
|
5286
|
+
if (ownedWork.length > 0) {
|
|
5287
|
+
const summary = `Owned work stopped: ${ownedWork.map((stop) => `${stop.ref} ${stop.outcome}${stop.detail ? ` (${stop.detail})` : ""}`).join("; ")}`;
|
|
5288
|
+
sandboxResult.error = sandboxResult.error ? `${sandboxResult.error}
|
|
5289
|
+
${summary}` : summary;
|
|
5290
|
+
}
|
|
4583
5291
|
this.activity?.finish(options.parentToolCallId, succeeded, sandboxResult.error);
|
|
5292
|
+
itemTransitions.finish(succeeded);
|
|
4584
5293
|
const sanitizedValue = sanitizeFabricMediaValue(sandboxResult.value);
|
|
4585
5294
|
return {
|
|
4586
5295
|
success: succeeded,
|
|
4587
5296
|
kernel: python ? "python" : "typescript",
|
|
4588
5297
|
value: sanitizedValue.value,
|
|
4589
|
-
logs: sandboxResult.logs.map(sanitizeFabricMediaText),
|
|
5298
|
+
logs: [...sandboxResult.logs, ...nestedLogs].map(sanitizeFabricMediaText),
|
|
4590
5299
|
...sanitizedValue.images.length > 0 ? { media: sanitizedValue.images } : {},
|
|
4591
5300
|
audits,
|
|
4592
5301
|
phases,
|
|
4593
5302
|
// Guest and provider error text may embed tool output or source
|
|
4594
5303
|
// literals, so the durable trace records only safe causes.
|
|
4595
5304
|
trace: traceRecorder.seal(runOutcome, phases),
|
|
5305
|
+
...assessment ? { assessment: assessment.seal(runOutcome) } : {},
|
|
4596
5306
|
elapsedMs: performance.now() - startedAt,
|
|
4597
5307
|
...sandboxResult.error ? { error: sanitizeFabricMediaText(sandboxResult.error) } : {},
|
|
4598
5308
|
...handoffRequest ? { handoffRequest } : {},
|
|
5309
|
+
...ownedWork.length > 0 ? { ownedWork } : {},
|
|
4599
5310
|
...classifierUsages.length > 0 ? { usage: aggregateUsage(classifierUsages) } : {}
|
|
4600
5311
|
};
|
|
4601
5312
|
}
|
|
@@ -5022,8 +5733,14 @@ var TIER_A_SPECULATION_REFS = /* @__PURE__ */ new Set([
|
|
|
5022
5733
|
"state.get",
|
|
5023
5734
|
"state.history",
|
|
5024
5735
|
"state.complexity",
|
|
5736
|
+
"mesh.scheduled",
|
|
5025
5737
|
"schema.status",
|
|
5026
5738
|
"compact.status",
|
|
5739
|
+
"compact.pressure",
|
|
5740
|
+
"thinking.status",
|
|
5741
|
+
"decisions.list",
|
|
5742
|
+
"programs.list",
|
|
5743
|
+
"programs.get",
|
|
5027
5744
|
"components.list",
|
|
5028
5745
|
"components.status",
|
|
5029
5746
|
"components.graph"
|
|
@@ -5560,8 +6277,15 @@ var allowedEnforceRefs = /* @__PURE__ */ new Set([
|
|
|
5560
6277
|
"mesh.members",
|
|
5561
6278
|
"mesh.get",
|
|
5562
6279
|
"mesh.list",
|
|
6280
|
+
"decisions.list",
|
|
6281
|
+
"programs.list",
|
|
6282
|
+
"programs.get",
|
|
6283
|
+
"mesh.scheduled",
|
|
6284
|
+
"mesh.grants",
|
|
5563
6285
|
"compact.status",
|
|
6286
|
+
"compact.pressure",
|
|
5564
6287
|
"cache.status",
|
|
6288
|
+
"thinking.status",
|
|
5565
6289
|
"components.list",
|
|
5566
6290
|
"components.describe",
|
|
5567
6291
|
"components.status",
|
|
@@ -5574,8 +6298,127 @@ var allowedEnforceRefs = /* @__PURE__ */ new Set([
|
|
|
5574
6298
|
]);
|
|
5575
6299
|
var schemaRefAllowedInEnforce = (ref) => allowedEnforceRefs.has(ref);
|
|
5576
6300
|
|
|
6301
|
+
// src/decisions/host.ts
|
|
6302
|
+
var DEFAULT_HEADLESS_APPROVAL_TIMEOUT_MS = 3e5;
|
|
6303
|
+
var DEFAULT_CHILD_QUESTION_TIMEOUT_MS = 6e5;
|
|
6304
|
+
var CANCELLED = { cancelled: true };
|
|
6305
|
+
var clip2 = (value, max) => value.length <= max ? value : `${value.slice(0, max - 1)}\u2026`;
|
|
6306
|
+
var raiseAndWait = async (store, input, raisedBy, signal, onRaised) => {
|
|
6307
|
+
const record = await store.raise(input, raisedBy);
|
|
6308
|
+
onRaised?.(record.id);
|
|
6309
|
+
try {
|
|
6310
|
+
return await store.wait(record.id, signal ? { signal } : {});
|
|
6311
|
+
} catch (error) {
|
|
6312
|
+
await store.cancel(record.id, { answeredBy: store.identity.id, via: "abort" }).catch(() => void 0);
|
|
6313
|
+
throw error;
|
|
6314
|
+
}
|
|
6315
|
+
};
|
|
6316
|
+
var requestHeadlessApproval = async (store, action, options = {}) => {
|
|
6317
|
+
const settled = await raiseAndWait(store, {
|
|
6318
|
+
kind: "approval",
|
|
6319
|
+
title: clip2(`${action.ref} requests ${action.risk} access`, MAX_DECISION_TITLE_CHARS),
|
|
6320
|
+
body: clip2([action.description, options.reason].filter(Boolean).join("\n\n"), MAX_DECISION_BODY_CHARS),
|
|
6321
|
+
options: [
|
|
6322
|
+
{ id: "approve", label: "Approve once" },
|
|
6323
|
+
{ id: "deny", label: "Deny" }
|
|
6324
|
+
],
|
|
6325
|
+
holder: "user",
|
|
6326
|
+
timeoutMs: options.timeoutMs ?? DEFAULT_HEADLESS_APPROVAL_TIMEOUT_MS,
|
|
6327
|
+
onExpire: "cancel"
|
|
6328
|
+
}, {}, options.signal);
|
|
6329
|
+
return settled.status === "answered" && settled.answer?.optionId === "approve";
|
|
6330
|
+
};
|
|
6331
|
+
var parseChildQuestion = (value) => {
|
|
6332
|
+
const method = value.method;
|
|
6333
|
+
if (method !== "select" && method !== "confirm" && method !== "input" && method !== "editor") return void 0;
|
|
6334
|
+
const options = Array.isArray(value.options) ? value.options.filter((option) => typeof option === "string") : void 0;
|
|
6335
|
+
if (method === "select" && !options?.length) return void 0;
|
|
6336
|
+
const string = (field) => typeof field === "string" ? field : void 0;
|
|
6337
|
+
const message2 = string(value.message);
|
|
6338
|
+
const placeholder = string(value.placeholder);
|
|
6339
|
+
const prefill = string(value.prefill);
|
|
6340
|
+
return {
|
|
6341
|
+
method,
|
|
6342
|
+
title: string(value.title) ?? "",
|
|
6343
|
+
...message2 !== void 0 ? { message: message2 } : {},
|
|
6344
|
+
...options && method === "select" ? { options } : {},
|
|
6345
|
+
...placeholder !== void 0 ? { placeholder } : {},
|
|
6346
|
+
...prefill !== void 0 ? { prefill } : {},
|
|
6347
|
+
timeout: typeof value.timeout === "number" && Number.isFinite(value.timeout) && value.timeout >= 1e3 ? Math.floor(value.timeout) : DEFAULT_CHILD_QUESTION_TIMEOUT_MS
|
|
6348
|
+
};
|
|
6349
|
+
};
|
|
6350
|
+
var askViaUi = async (ui, label, question, signal) => {
|
|
6351
|
+
const dialog = { signal, timeout: question.timeout };
|
|
6352
|
+
if (question.method === "select") {
|
|
6353
|
+
const value = await ui.select(label, question.options, dialog);
|
|
6354
|
+
return value !== void 0 && question.options.includes(value) ? { value } : CANCELLED;
|
|
6355
|
+
}
|
|
6356
|
+
if (question.method === "confirm") {
|
|
6357
|
+
return { confirmed: await ui.confirm(label, question.message ?? "", dialog) };
|
|
6358
|
+
}
|
|
6359
|
+
if (question.method === "input") {
|
|
6360
|
+
const value = await ui.input(label, question.placeholder, dialog);
|
|
6361
|
+
return value === void 0 ? CANCELLED : { value };
|
|
6362
|
+
}
|
|
6363
|
+
let timer;
|
|
6364
|
+
let onAbort;
|
|
6365
|
+
const stop = new Promise((resolve2) => {
|
|
6366
|
+
timer = setTimeout(() => resolve2(void 0), question.timeout);
|
|
6367
|
+
onAbort = () => resolve2(void 0);
|
|
6368
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
6369
|
+
});
|
|
6370
|
+
try {
|
|
6371
|
+
const value = await Promise.race([ui.editor(label, question.prefill), stop]);
|
|
6372
|
+
return value === void 0 ? CANCELLED : { value };
|
|
6373
|
+
} finally {
|
|
6374
|
+
clearTimeout(timer);
|
|
6375
|
+
if (onAbort) signal.removeEventListener("abort", onAbort);
|
|
6376
|
+
}
|
|
6377
|
+
};
|
|
6378
|
+
var responseFromDecision = (question, decision) => {
|
|
6379
|
+
if (decision.status !== "answered" || !decision.answer) return CANCELLED;
|
|
6380
|
+
const { optionId, text } = decision.answer;
|
|
6381
|
+
if (question.method === "confirm") return { confirmed: optionId === "yes" };
|
|
6382
|
+
if (question.method === "select") {
|
|
6383
|
+
const index = optionId?.startsWith("o") ? Number(optionId.slice(1)) - 1 : -1;
|
|
6384
|
+
const value = question.options?.[index];
|
|
6385
|
+
return value === void 0 ? CANCELLED : { value };
|
|
6386
|
+
}
|
|
6387
|
+
return text === void 0 ? CANCELLED : { value: text };
|
|
6388
|
+
};
|
|
6389
|
+
var routeChildQuestion = async (request, deps) => {
|
|
6390
|
+
const question = parseChildQuestion(request.question);
|
|
6391
|
+
if (!question || request.signal.aborted) return CANCELLED;
|
|
6392
|
+
const label = `${request.name}: ${question.title || "question"}`;
|
|
6393
|
+
if (deps.context.hasUI) return askViaUi(deps.context.ui, label, question, request.signal);
|
|
6394
|
+
if (!deps.store) return CANCELLED;
|
|
6395
|
+
const input = {
|
|
6396
|
+
kind: "question",
|
|
6397
|
+
title: clip2(label, MAX_DECISION_TITLE_CHARS),
|
|
6398
|
+
...question.message ? { body: clip2(question.message, MAX_DECISION_BODY_CHARS) } : {},
|
|
6399
|
+
...question.method === "select" ? {
|
|
6400
|
+
input: "select",
|
|
6401
|
+
options: question.options.slice(0, MAX_DECISION_OPTIONS).map((option, index) => ({
|
|
6402
|
+
id: `o${index + 1}`,
|
|
6403
|
+
label: clip2(option || `Option ${index + 1}`, MAX_DECISION_TITLE_CHARS)
|
|
6404
|
+
}))
|
|
6405
|
+
} : { input: question.method === "input" ? "text" : question.method },
|
|
6406
|
+
holder: "root",
|
|
6407
|
+
timeoutMs: Math.max(1e3, question.timeout),
|
|
6408
|
+
onExpire: "cancel"
|
|
6409
|
+
};
|
|
6410
|
+
const decision = await raiseAndWait(
|
|
6411
|
+
deps.store,
|
|
6412
|
+
input,
|
|
6413
|
+
{ participantId: request.actorId ?? request.runId, runId: request.runId },
|
|
6414
|
+
request.signal,
|
|
6415
|
+
request.onDecision
|
|
6416
|
+
);
|
|
6417
|
+
return responseFromDecision(question, decision);
|
|
6418
|
+
};
|
|
6419
|
+
|
|
5577
6420
|
// src/prewalk/handoff.ts
|
|
5578
|
-
import { randomUUID as
|
|
6421
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
5579
6422
|
|
|
5580
6423
|
// src/agents/handoff-continuation.ts
|
|
5581
6424
|
var HANDOFF_CONTINUATION_MESSAGE_TYPE = "pi-fabric-handoff-continuation";
|
|
@@ -5740,7 +6583,7 @@ var buildPrewalkPending = (claim, resultFormat) => {
|
|
|
5740
6583
|
claim.arm.task,
|
|
5741
6584
|
...!inPlace && readiness.kind === "planned" ? [prewalkPlanText(readiness.plan)] : []
|
|
5742
6585
|
].filter(Boolean).join("\n\n");
|
|
5743
|
-
const nestedToolCallId = `${FABRIC_NESTED_TOOL_CALL_ID_PREFIX}prewalk_${
|
|
6586
|
+
const nestedToolCallId = `${FABRIC_NESTED_TOOL_CALL_ID_PREFIX}prewalk_${randomUUID4()}`;
|
|
5744
6587
|
const args = {
|
|
5745
6588
|
model: claim.arm.model,
|
|
5746
6589
|
name: inPlace ? "In-place Prewalk" : "Prewalk trajectory executor",
|
|
@@ -5808,7 +6651,7 @@ var runInPlacePrewalk = async (controller, extension, pending, context) => {
|
|
|
5808
6651
|
const returnModel = context.model;
|
|
5809
6652
|
if (!returnModel) throw new Error("Prewalk cannot determine Main return model");
|
|
5810
6653
|
const returnModelKey = `${returnModel.provider}/${returnModel.id}`;
|
|
5811
|
-
const continuationId =
|
|
6654
|
+
const continuationId = randomUUID4();
|
|
5812
6655
|
const switched = await extension.setModel(model);
|
|
5813
6656
|
if (!switched) {
|
|
5814
6657
|
throw new Error(`No authentication configured for prewalk model: ${modelKey}`);
|
|
@@ -6063,8 +6906,77 @@ var LifecycleDeliveryScheduler = class {
|
|
|
6063
6906
|
}
|
|
6064
6907
|
};
|
|
6065
6908
|
|
|
6909
|
+
// src/agents/fork-seed.ts
|
|
6910
|
+
var DEFAULT_SEED_MESSAGES = 12;
|
|
6911
|
+
var MAX_SEED_MESSAGES = 50;
|
|
6912
|
+
var MAX_SNIPPET_MESSAGE_CHARS = 4e3;
|
|
6913
|
+
var checkedSeed = (seed, seedMessages) => {
|
|
6914
|
+
if (seed !== void 0 && seed !== "task" && seed !== "branch" && seed !== "snippet") {
|
|
6915
|
+
throw new Error('seed must be "task", "branch", or "snippet"');
|
|
6916
|
+
}
|
|
6917
|
+
if (seedMessages !== void 0) {
|
|
6918
|
+
if (seed !== "snippet") throw new Error('seedMessages applies only to seed: "snippet"');
|
|
6919
|
+
if (typeof seedMessages !== "number" || !Number.isInteger(seedMessages) || seedMessages < 1 || seedMessages > MAX_SEED_MESSAGES) {
|
|
6920
|
+
throw new Error(`seedMessages must be an integer from 1 to ${MAX_SEED_MESSAGES}`);
|
|
6921
|
+
}
|
|
6922
|
+
}
|
|
6923
|
+
return {
|
|
6924
|
+
seed: seed ?? "task",
|
|
6925
|
+
seedMessages: seedMessages ?? DEFAULT_SEED_MESSAGES
|
|
6926
|
+
};
|
|
6927
|
+
};
|
|
6928
|
+
var isMessage2 = (entry) => entry.type === "message";
|
|
6929
|
+
var toolCallIds = (entry) => {
|
|
6930
|
+
const message2 = entry.message;
|
|
6931
|
+
if (message2.role !== "assistant" || !Array.isArray(message2.content)) return [];
|
|
6932
|
+
return message2.content.filter((part) => typeof part === "object" && part !== null && part.type === "toolCall" && typeof part.id === "string").map((part) => part.id);
|
|
6933
|
+
};
|
|
6934
|
+
var completedBranchPrefix = (branch) => {
|
|
6935
|
+
const resolved = /* @__PURE__ */ new Set();
|
|
6936
|
+
for (let index = branch.length - 1; index >= 0; index--) {
|
|
6937
|
+
const entry = branch[index];
|
|
6938
|
+
if (!isMessage2(entry)) continue;
|
|
6939
|
+
const message2 = entry.message;
|
|
6940
|
+
if (message2.role === "user") break;
|
|
6941
|
+
if (message2.role === "toolResult" && typeof message2.toolCallId === "string") {
|
|
6942
|
+
resolved.add(message2.toolCallId);
|
|
6943
|
+
continue;
|
|
6944
|
+
}
|
|
6945
|
+
if (toolCallIds(entry).some((id2) => !resolved.has(id2))) return branch.slice(0, index);
|
|
6946
|
+
}
|
|
6947
|
+
return [...branch];
|
|
6948
|
+
};
|
|
6949
|
+
var messageText = (content) => {
|
|
6950
|
+
if (typeof content === "string") return content;
|
|
6951
|
+
if (!Array.isArray(content)) return "";
|
|
6952
|
+
return content.filter((part) => typeof part === "object" && part !== null && part.type === "text" && typeof part.text === "string").map((part) => part.text).join("\n");
|
|
6953
|
+
};
|
|
6954
|
+
var snippetTask = (branch, count2, task) => {
|
|
6955
|
+
const messages = [];
|
|
6956
|
+
for (const entry of completedBranchPrefix(branch)) {
|
|
6957
|
+
if (!isMessage2(entry)) continue;
|
|
6958
|
+
const message2 = entry.message;
|
|
6959
|
+
if (message2.role !== "user" && message2.role !== "assistant") continue;
|
|
6960
|
+
let text = messageText(message2.content).trim();
|
|
6961
|
+
if (!text) continue;
|
|
6962
|
+
if (text.length > MAX_SNIPPET_MESSAGE_CHARS) text = `${text.slice(0, MAX_SNIPPET_MESSAGE_CHARS)}\u2026`;
|
|
6963
|
+
messages.push(`[${message2.role}]
|
|
6964
|
+
${text}`);
|
|
6965
|
+
}
|
|
6966
|
+
const recent = messages.slice(-count2);
|
|
6967
|
+
if (recent.length === 0) return task;
|
|
6968
|
+
return [
|
|
6969
|
+
`<inherited-conversation messages="${recent.length}">`,
|
|
6970
|
+
recent.join("\n\n"),
|
|
6971
|
+
"</inherited-conversation>",
|
|
6972
|
+
"",
|
|
6973
|
+
"Task:",
|
|
6974
|
+
task
|
|
6975
|
+
].join("\n");
|
|
6976
|
+
};
|
|
6977
|
+
|
|
6066
6978
|
// src/residency/client.ts
|
|
6067
|
-
import { randomUUID as
|
|
6979
|
+
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
6068
6980
|
import fs5 from "node:fs";
|
|
6069
6981
|
import path5 from "node:path";
|
|
6070
6982
|
import { fileURLToPath } from "node:url";
|
|
@@ -6223,7 +7135,7 @@ var ResidencyClient = class {
|
|
|
6223
7135
|
const response = await this.#command({
|
|
6224
7136
|
format: RESIDENT_HOST_FORMAT,
|
|
6225
7137
|
operation: "createActor",
|
|
6226
|
-
requestId:
|
|
7138
|
+
requestId: randomUUID5(),
|
|
6227
7139
|
rootId: this.options.config.rootId,
|
|
6228
7140
|
request,
|
|
6229
7141
|
createdAt: Date.now()
|
|
@@ -6234,6 +7146,11 @@ var ResidencyClient = class {
|
|
|
6234
7146
|
}
|
|
6235
7147
|
async spawnAgent(request, signal) {
|
|
6236
7148
|
const resolvedRequest = request.cwd === void 0 ? request : { ...request, cwd: resolveAgentCwd(this.options.config.cwd, request.cwd) };
|
|
7149
|
+
const runner = request.runner ?? this.options.config.agents.runner;
|
|
7150
|
+
const runnerModule = BUILT_IN_RUNNER_IDS.has(runner) ? void 0 : requireAgentRunner(runner).residentModule;
|
|
7151
|
+
if (!BUILT_IN_RUNNER_IDS.has(runner) && !runnerModule) {
|
|
7152
|
+
throw new Error(`Fabric runner ${runner} declares no residentModule; durable residency needs one`);
|
|
7153
|
+
}
|
|
6237
7154
|
const allowedTools = this.#inheritedToolAllowlist;
|
|
6238
7155
|
const tools = allowedTools === void 0 ? void 0 : (request.tools ?? this.options.config.agents.defaultTools).filter((tool) => allowedTools.has(tool));
|
|
6239
7156
|
await this.ensureHost();
|
|
@@ -6241,9 +7158,10 @@ var ResidencyClient = class {
|
|
|
6241
7158
|
{
|
|
6242
7159
|
format: RESIDENT_HOST_FORMAT,
|
|
6243
7160
|
operation: "spawn",
|
|
6244
|
-
requestId:
|
|
7161
|
+
requestId: randomUUID5(),
|
|
6245
7162
|
rootId: this.options.config.rootId,
|
|
6246
7163
|
request: { ...resolvedRequest, ...tools ? { tools } : {}, residency: "durable" },
|
|
7164
|
+
...runnerModule ? { runnerModule } : {},
|
|
6247
7165
|
createdAt: Date.now()
|
|
6248
7166
|
},
|
|
6249
7167
|
signal
|
|
@@ -6326,7 +7244,7 @@ var ResidencyClient = class {
|
|
|
6326
7244
|
await this.#command({
|
|
6327
7245
|
format: RESIDENT_HOST_FORMAT,
|
|
6328
7246
|
operation: "removeActor",
|
|
6329
|
-
requestId:
|
|
7247
|
+
requestId: randomUUID5(),
|
|
6330
7248
|
rootId: this.options.config.rootId,
|
|
6331
7249
|
id: id2,
|
|
6332
7250
|
createdAt: Date.now()
|
|
@@ -6342,7 +7260,7 @@ var ResidencyClient = class {
|
|
|
6342
7260
|
response = await this.#command({
|
|
6343
7261
|
format: RESIDENT_HOST_FORMAT,
|
|
6344
7262
|
operation: "cleanup",
|
|
6345
|
-
requestId:
|
|
7263
|
+
requestId: randomUUID5(),
|
|
6346
7264
|
rootId: this.options.config.rootId,
|
|
6347
7265
|
id: id2,
|
|
6348
7266
|
deleteBranch,
|
|
@@ -6439,7 +7357,8 @@ var ResidencyClient = class {
|
|
|
6439
7357
|
}
|
|
6440
7358
|
#liveOwner() {
|
|
6441
7359
|
const owner = readJson(this.#ownerPath);
|
|
6442
|
-
if (owner?.format !== RESIDENT_HOST_FORMAT || owner.hostId !== this.hostId || !Number.isSafeInteger(owner.pid) ||
|
|
7360
|
+
if (owner?.format !== RESIDENT_HOST_FORMAT || owner.hostId !== this.hostId || !Number.isSafeInteger(owner.pid) || // A host in another PID namespace is judged by its heartbeat.
|
|
7361
|
+
recordOwnerLiveness(owner, { legacyAlive: processIsAlive }) === "dead") {
|
|
6443
7362
|
return void 0;
|
|
6444
7363
|
}
|
|
6445
7364
|
return owner;
|
|
@@ -6605,7 +7524,7 @@ var waitWithProgress = async (manager, transcripts, id2, context, agentToolPrevi
|
|
|
6605
7524
|
);
|
|
6606
7525
|
if (revision === lastPreviewRevision) return;
|
|
6607
7526
|
lastPreviewRevision = revision;
|
|
6608
|
-
const currentTool = "currentTool" in status && status.currentTool ? ` \xB7 ${status.currentTool}` : "";
|
|
7527
|
+
const currentTool = "blockedOn" in status && status.blockedOn ? " \xB7 waiting_for_answer" : "currentTool" in status && status.currentTool ? ` \xB7 ${status.currentTool}` : "";
|
|
6609
7528
|
const displayName = status.actorName ?? status.name;
|
|
6610
7529
|
context.update(`Agent ${displayName}: ${status.status}${currentTool}`);
|
|
6611
7530
|
if ("usage" in status) {
|
|
@@ -6701,7 +7620,8 @@ var AgentMessageRouter = class {
|
|
|
6701
7620
|
{
|
|
6702
7621
|
message: message2,
|
|
6703
7622
|
data,
|
|
6704
|
-
...typeof options.triggerTurn === "boolean" ? { triggerTurn: options.triggerTurn } : {}
|
|
7623
|
+
...typeof options.triggerTurn === "boolean" ? { triggerTurn: options.triggerTurn } : {},
|
|
7624
|
+
...participant2.ownerIncarnation ? { ownerIncarnation: participant2.ownerIncarnation } : {}
|
|
6705
7625
|
},
|
|
6706
7626
|
participant2.ownerIdentityId
|
|
6707
7627
|
);
|
|
@@ -6729,7 +7649,8 @@ var AgentMessageRouter = class {
|
|
|
6729
7649
|
{
|
|
6730
7650
|
message: message2,
|
|
6731
7651
|
data,
|
|
6732
|
-
...typeof options.triggerTurn === "boolean" ? { triggerTurn: options.triggerTurn } : {}
|
|
7652
|
+
...typeof options.triggerTurn === "boolean" ? { triggerTurn: options.triggerTurn } : {},
|
|
7653
|
+
...remoteRoot.ownerIncarnation ? { ownerIncarnation: remoteRoot.ownerIncarnation } : {}
|
|
6733
7654
|
},
|
|
6734
7655
|
remoteRoot.ownerIdentityId
|
|
6735
7656
|
);
|
|
@@ -6780,7 +7701,8 @@ var AgentMessageRouter = class {
|
|
|
6780
7701
|
message: message2,
|
|
6781
7702
|
data,
|
|
6782
7703
|
...typeof options.triggerTurn === "boolean" ? { triggerTurn: options.triggerTurn } : {},
|
|
6783
|
-
...needsBinding && resolvedBinding ? { binding: resolvedBinding } : {}
|
|
7704
|
+
...needsBinding && resolvedBinding ? { binding: resolvedBinding } : {},
|
|
7705
|
+
...participant.ownerIncarnation ? { ownerIncarnation: participant.ownerIncarnation } : {}
|
|
6784
7706
|
},
|
|
6785
7707
|
participant.ownerIdentityId
|
|
6786
7708
|
);
|
|
@@ -6832,7 +7754,7 @@ var AgentMessageRouter = class {
|
|
|
6832
7754
|
message2,
|
|
6833
7755
|
command.data,
|
|
6834
7756
|
signal,
|
|
6835
|
-
command.binding !== void 0 ? { binding: command.binding } : {}
|
|
7757
|
+
{ ...command.binding !== void 0 ? { binding: command.binding } : {}, sender: command.sender ?? null }
|
|
6836
7758
|
);
|
|
6837
7759
|
return { accepted: true, messageId: result.id, result };
|
|
6838
7760
|
} catch (error) {
|
|
@@ -6871,7 +7793,7 @@ var AgentMessageRouter = class {
|
|
|
6871
7793
|
actor.id,
|
|
6872
7794
|
message2,
|
|
6873
7795
|
command.data,
|
|
6874
|
-
command.binding !== void 0 ? { binding: command.binding } : {}
|
|
7796
|
+
{ ...command.binding !== void 0 ? { binding: command.binding } : {}, sender: command.sender ?? null }
|
|
6875
7797
|
);
|
|
6876
7798
|
return { accepted: true, messageId: result.messageId };
|
|
6877
7799
|
} catch (error) {
|
|
@@ -6946,6 +7868,11 @@ var longerTimeoutOverride = (value, manager) => {
|
|
|
6946
7868
|
const effective = effectiveAgentTimeoutMs(manager.config.timeoutMs, value);
|
|
6947
7869
|
return effective > manager.config.timeoutMs ? effective : void 0;
|
|
6948
7870
|
};
|
|
7871
|
+
var checkedRunner = (value, fallback) => {
|
|
7872
|
+
if (value === void 0) return fallback;
|
|
7873
|
+
if (!isFabricRunnerId(value)) throw new Error(`Invalid Fabric agent runner: ${JSON.stringify(value)}`);
|
|
7874
|
+
return value;
|
|
7875
|
+
};
|
|
6949
7876
|
var checkedKernel = (value) => {
|
|
6950
7877
|
if (value === void 0 || value === "inherit" || value === "typescript" || value === "python") return value;
|
|
6951
7878
|
throw new Error(`Invalid Fabric agent kernel: ${String(value)}`);
|
|
@@ -7011,10 +7938,11 @@ var actorRequest = (args, context, manager, inheritModel = true) => {
|
|
|
7011
7938
|
) : void 0;
|
|
7012
7939
|
const timeoutMs = longerTimeoutOverride(args.timeoutMs, manager);
|
|
7013
7940
|
const validWhile = typeof args.validWhile === "object" && args.validWhile !== null && !Array.isArray(args.validWhile) && args.validWhile.version === 1 && typeof args.validWhile.source === "string" ? { version: 1, source: args.validWhile.source } : void 0;
|
|
7014
|
-
const runner = args.runner
|
|
7015
|
-
|
|
7941
|
+
const runner = checkedRunner(args.runner, manager.config.runner);
|
|
7942
|
+
const runnerAdapter = requireAgentRunner(runner);
|
|
7943
|
+
if (!runnerAdapter.capabilities.persistentSessions) {
|
|
7016
7944
|
throw new Error(
|
|
7017
|
-
'The Veda runner does not support persistent actors: Veda executes one headless prompt per invocation. Use a Pi or Claude actor, or agents.run({ runner: "veda" }).'
|
|
7945
|
+
runner === "veda" ? 'The Veda runner does not support persistent actors: Veda executes one headless prompt per invocation. Use a Pi or Claude actor, or agents.run({ runner: "veda" }).' : `The ${runnerAdapter.label} runner does not declare persistentSessions; use agents.run() or a runner that supports persistent actors.`
|
|
7018
7946
|
);
|
|
7019
7947
|
}
|
|
7020
7948
|
const requestedKernel = checkedKernel(args.kernel);
|
|
@@ -7084,6 +8012,8 @@ var AgentsProvider = class {
|
|
|
7084
8012
|
#transcripts = new AgentTranscriptReader();
|
|
7085
8013
|
#router;
|
|
7086
8014
|
name = "agents";
|
|
8015
|
+
/** Session registry of `provider:` participants; stop/steer/followUp route there. */
|
|
8016
|
+
providerParticipants;
|
|
7087
8017
|
description = "The user-facing Main target, one-shot Pi or Claude Code agents, and persistent mailbox actors over process, tmux, screen, LocalTerm, or Herdr";
|
|
7088
8018
|
#lifecycleScheduler;
|
|
7089
8019
|
#lifecycleMessage(event) {
|
|
@@ -7129,7 +8059,7 @@ var AgentsProvider = class {
|
|
|
7129
8059
|
return `${resolved.provider}/${resolved.id}`;
|
|
7130
8060
|
}
|
|
7131
8061
|
#resolvePiModelArgs(args, context, runnerOverride) {
|
|
7132
|
-
const runner = runnerOverride ?? (args.runner
|
|
8062
|
+
const runner = runnerOverride ?? checkedRunner(args.runner, this.manager.config.runner);
|
|
7133
8063
|
if (runner !== "pi") return args;
|
|
7134
8064
|
const model = typeof args.model === "string" ? args.model.trim() : "";
|
|
7135
8065
|
if (!model) return args;
|
|
@@ -7238,7 +8168,11 @@ var AgentsProvider = class {
|
|
|
7238
8168
|
switch (actionName) {
|
|
7239
8169
|
case "run": {
|
|
7240
8170
|
const handle = await this.manager.spawn(
|
|
7241
|
-
|
|
8171
|
+
this.#applySeed(
|
|
8172
|
+
args,
|
|
8173
|
+
runRequest(this.#resolvePiModelArgs(args, context), context, this.manager, this.modelsConfig()),
|
|
8174
|
+
context
|
|
8175
|
+
),
|
|
7242
8176
|
context.signal
|
|
7243
8177
|
);
|
|
7244
8178
|
this.participants.scheduleRefresh();
|
|
@@ -7260,14 +8194,25 @@ var AgentsProvider = class {
|
|
|
7260
8194
|
case "handoff":
|
|
7261
8195
|
return this.handoff(args, context);
|
|
7262
8196
|
case "spawn": {
|
|
7263
|
-
const request =
|
|
8197
|
+
const request = this.#applySeed(
|
|
8198
|
+
args,
|
|
8199
|
+
runRequest(this.#resolvePiModelArgs(args, context), context, this.manager, this.modelsConfig()),
|
|
8200
|
+
context
|
|
8201
|
+
);
|
|
8202
|
+
if (request.residency === "durable") this.#assertUnconfinedDurable();
|
|
7264
8203
|
const kernel = this.manager.resolveKernel(request);
|
|
7265
|
-
const { kernel: _requestedKernel, ...
|
|
8204
|
+
const { kernel: _requestedKernel, ...requestWithScope } = request;
|
|
8205
|
+
const inheritedScope = request.residency === "durable" ? childScope(request.scope) : void 0;
|
|
8206
|
+
const { scope: _narrowing, ...unscopedRequest } = requestWithScope;
|
|
8207
|
+
const baseRequest = request.residency === "durable" ? unscopedRequest : requestWithScope;
|
|
7266
8208
|
const durableRequest = withInheritedSessionPins({
|
|
7267
8209
|
...baseRequest,
|
|
8210
|
+
...inheritedScope ? { inheritedScope } : {},
|
|
7268
8211
|
...kernel ? { kernel, pythonRuntime: this.manager.resolvePythonRuntime() } : {},
|
|
7269
8212
|
extensions: request.extensions ?? this.manager.config.extensions,
|
|
7270
|
-
...request.residency === "durable" && request.cwd !== void 0 ? { cwd: this.manager.resolveCwd(request.cwd) } : {}
|
|
8213
|
+
...request.residency === "durable" && request.cwd !== void 0 ? { cwd: this.manager.resolveCwd(request.cwd) } : {},
|
|
8214
|
+
// The resident host does not know this session's bounds: send them narrowed.
|
|
8215
|
+
...request.residency === "durable" ? { thinkingBounds: this.manager.childThinkingBounds(request.thinkingBounds) } : {}
|
|
7271
8216
|
}, context.extensionContext.sessionManager?.getEntries?.() ?? []);
|
|
7272
8217
|
const handle = durableRequest.residency === "durable" ? await this.#resident().spawnAgent(durableRequest, context.signal) : await this.manager.spawn(durableRequest, context.signal);
|
|
7273
8218
|
if (request.residency !== "durable") this.manager.detachSignal(handle.id);
|
|
@@ -7343,8 +8288,11 @@ var AgentsProvider = class {
|
|
|
7343
8288
|
...args.includeStale === true ? { includeStale: true } : {}
|
|
7344
8289
|
});
|
|
7345
8290
|
}
|
|
7346
|
-
case "self":
|
|
7347
|
-
|
|
8291
|
+
case "self": {
|
|
8292
|
+
const self = await this.participants.self();
|
|
8293
|
+
const lineage = readAgentLineage();
|
|
8294
|
+
return lineage ? { ...self, lineage } : self;
|
|
8295
|
+
}
|
|
7348
8296
|
case "main":
|
|
7349
8297
|
return this.mainAgent.info(context.extensionContext);
|
|
7350
8298
|
case "sessions":
|
|
@@ -7379,7 +8327,11 @@ var AgentsProvider = class {
|
|
|
7379
8327
|
case "unsubscribe":
|
|
7380
8328
|
return this.lifecycle.unsubscribe(String(args.id));
|
|
7381
8329
|
case "models": {
|
|
7382
|
-
const runner = args.runner
|
|
8330
|
+
const runner = checkedRunner(args.runner, this.manager.config.runner);
|
|
8331
|
+
const runnerAdapter = requireAgentRunner(runner);
|
|
8332
|
+
if (!BUILT_IN_RUNNER_IDS.has(runner)) {
|
|
8333
|
+
return runnerAdapter.models ? [...await runnerAdapter.models({ cwd: this.manager.cwd, refresh: args.refresh === true })] : [];
|
|
8334
|
+
}
|
|
7383
8335
|
if (runner === "veda") {
|
|
7384
8336
|
return [];
|
|
7385
8337
|
}
|
|
@@ -7545,7 +8497,8 @@ var AgentsProvider = class {
|
|
|
7545
8497
|
{
|
|
7546
8498
|
message: message2,
|
|
7547
8499
|
...args.data === void 0 ? {} : { data: args.data },
|
|
7548
|
-
...needsBinding ? { binding } : {}
|
|
8500
|
+
...needsBinding ? { binding } : {},
|
|
8501
|
+
...participant.ownerIncarnation ? { ownerIncarnation: participant.ownerIncarnation } : {}
|
|
7549
8502
|
},
|
|
7550
8503
|
participant.ownerIdentityId,
|
|
7551
8504
|
{
|
|
@@ -7724,6 +8677,17 @@ var AgentsProvider = class {
|
|
|
7724
8677
|
}
|
|
7725
8678
|
}
|
|
7726
8679
|
async routeMessage(id2, message2, data, kind, context, options = {}) {
|
|
8680
|
+
if (isProviderParticipantRef(id2)) {
|
|
8681
|
+
return controlProviderParticipant(
|
|
8682
|
+
this.providerParticipants,
|
|
8683
|
+
this.participants,
|
|
8684
|
+
this.control,
|
|
8685
|
+
id2,
|
|
8686
|
+
kind,
|
|
8687
|
+
message2,
|
|
8688
|
+
data
|
|
8689
|
+
);
|
|
8690
|
+
}
|
|
7727
8691
|
return this.#router.routeMessage(id2, message2, data, kind, context, options);
|
|
7728
8692
|
}
|
|
7729
8693
|
/** Flush pending coalesced lifecycle deliveries; used by tests and shutdown. */
|
|
@@ -7734,6 +8698,9 @@ var AgentsProvider = class {
|
|
|
7734
8698
|
this.#lifecycleScheduler.schedule(subscription.to, { subscription, event });
|
|
7735
8699
|
}
|
|
7736
8700
|
async acceptControl(command, from, signal) {
|
|
8701
|
+
if (isProviderParticipantRef(command.targetId)) {
|
|
8702
|
+
return acceptProviderParticipantControl(this.providerParticipants, command);
|
|
8703
|
+
}
|
|
7737
8704
|
return this.#router.acceptControl(command, from, signal);
|
|
7738
8705
|
}
|
|
7739
8706
|
#resolveActorTarget(id2) {
|
|
@@ -7742,14 +8709,17 @@ var AgentsProvider = class {
|
|
|
7742
8709
|
async #createActor(request) {
|
|
7743
8710
|
const extensions = request.extensions ?? true;
|
|
7744
8711
|
const kernel = this.manager.resolveKernel({ ...request, extensions });
|
|
7745
|
-
const { kernel: _requestedKernel, ...baseRequest } = request;
|
|
8712
|
+
const { kernel: _requestedKernel, principalScope: _forged, ...baseRequest } = request;
|
|
8713
|
+
const principalScope = sessionScope();
|
|
7746
8714
|
request = {
|
|
7747
8715
|
...baseRequest,
|
|
7748
8716
|
runner: request.runner ?? this.manager.config.runner,
|
|
7749
8717
|
extensions,
|
|
7750
|
-
...kernel ? { kernel, pythonRuntime: this.manager.resolvePythonRuntime(request.pythonRuntime) } : {}
|
|
8718
|
+
...kernel ? { kernel, pythonRuntime: this.manager.resolvePythonRuntime(request.pythonRuntime) } : {},
|
|
8719
|
+
...principalScope ? { principalScope } : {}
|
|
7751
8720
|
};
|
|
7752
8721
|
if (request.residency !== "durable") return this.actorManager.create(request);
|
|
8722
|
+
this.#assertUnconfinedDurable();
|
|
7753
8723
|
if (!this.residency) return this.#residentActorClient().createActor(request);
|
|
7754
8724
|
await this.residency.ensureHost();
|
|
7755
8725
|
let actor;
|
|
@@ -7762,6 +8732,44 @@ var AgentsProvider = class {
|
|
|
7762
8732
|
await this.#activateDurableActor(actor);
|
|
7763
8733
|
return actor;
|
|
7764
8734
|
}
|
|
8735
|
+
// The shared resident host cannot inherit this process's write confinement;
|
|
8736
|
+
// scope travels with the request (inheritedScope, principalScope) instead.
|
|
8737
|
+
#assertUnconfinedDurable() {
|
|
8738
|
+
if (process.env.PI_FABRIC_WRITE_POLICY) {
|
|
8739
|
+
throw new Error("A write-confined agent cannot start durable agents or actors");
|
|
8740
|
+
}
|
|
8741
|
+
}
|
|
8742
|
+
/** seed: "branch" forks the caller's completed turns; "snippet" prefixes recent text. */
|
|
8743
|
+
#applySeed(args, request, context) {
|
|
8744
|
+
const { seed, seedMessages } = checkedSeed(args.seed, args.seedMessages);
|
|
8745
|
+
if (seed === "task") return request;
|
|
8746
|
+
if ((request.runner ?? this.manager.config.runner) !== "pi") {
|
|
8747
|
+
throw new Error(`seed: "${seed}" requires the Pi runner`);
|
|
8748
|
+
}
|
|
8749
|
+
const session = context.extensionContext.sessionManager;
|
|
8750
|
+
const branch = session?.getBranch?.();
|
|
8751
|
+
if (!session || !branch) throw new Error(`seed: "${seed}" requires a Pi session`);
|
|
8752
|
+
if (seed === "snippet") return { ...request, task: snippetTask(branch, seedMessages, request.task) };
|
|
8753
|
+
if (request.residency === "durable") {
|
|
8754
|
+
throw new Error('seed: "branch" is unavailable for durable agents; use seed: "snippet"');
|
|
8755
|
+
}
|
|
8756
|
+
const model = context.extensionContext.model;
|
|
8757
|
+
const sourceSessionFile = session.getSessionFile?.();
|
|
8758
|
+
const thinkingTransfer = request.model ? resolveThinkingTransfer(
|
|
8759
|
+
context.extensionContext,
|
|
8760
|
+
request.model,
|
|
8761
|
+
model ? { provider: model.provider, modelId: model.id } : void 0
|
|
8762
|
+
) : void 0;
|
|
8763
|
+
return {
|
|
8764
|
+
...request,
|
|
8765
|
+
forkSeed: {
|
|
8766
|
+
sourceSessionId: session.getSessionId(),
|
|
8767
|
+
...sourceSessionFile ? { sourceSessionFile } : {},
|
|
8768
|
+
sourceBranch: completedBranchPrefix(branch)
|
|
8769
|
+
},
|
|
8770
|
+
...thinkingTransfer ? { thinkingTransfer } : {}
|
|
8771
|
+
};
|
|
8772
|
+
}
|
|
7765
8773
|
#residentActorClient() {
|
|
7766
8774
|
const client = ResidentActorClient.fromEnv();
|
|
7767
8775
|
if (client) return client;
|
|
@@ -7820,6 +8828,9 @@ var AgentsProvider = class {
|
|
|
7820
8828
|
return value === "local" || value === "lineage" || value === "project" ? value : fallback;
|
|
7821
8829
|
}
|
|
7822
8830
|
async stopParticipant(id2) {
|
|
8831
|
+
if (isProviderParticipantRef(id2)) {
|
|
8832
|
+
return controlProviderParticipant(this.providerParticipants, this.participants, this.control, id2, "stop");
|
|
8833
|
+
}
|
|
7823
8834
|
try {
|
|
7824
8835
|
const result2 = await this.manager.stop(id2);
|
|
7825
8836
|
this.participants.scheduleRefresh();
|
|
@@ -7848,7 +8859,7 @@ var AgentsProvider = class {
|
|
|
7848
8859
|
participant.ownerHostId,
|
|
7849
8860
|
participant.id,
|
|
7850
8861
|
"stop",
|
|
7851
|
-
{},
|
|
8862
|
+
participant.ownerIncarnation ? { ownerIncarnation: participant.ownerIncarnation } : {},
|
|
7852
8863
|
participant.ownerIdentityId
|
|
7853
8864
|
);
|
|
7854
8865
|
if (this.residency?.hasAgent(id2)) this.residency.acknowledgeCompletion(id2);
|
|
@@ -7875,6 +8886,39 @@ var AgentsProvider = class {
|
|
|
7875
8886
|
// src/providers/compact-provider.ts
|
|
7876
8887
|
import { Type } from "typebox";
|
|
7877
8888
|
import { Value as Value2 } from "typebox/value";
|
|
8889
|
+
|
|
8890
|
+
// src/compaction/pressure.ts
|
|
8891
|
+
var positiveWindow = (value) => typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
|
|
8892
|
+
var compactionPressure = (context, config) => {
|
|
8893
|
+
let usage;
|
|
8894
|
+
try {
|
|
8895
|
+
usage = context?.getContextUsage?.();
|
|
8896
|
+
} catch {
|
|
8897
|
+
usage = void 0;
|
|
8898
|
+
}
|
|
8899
|
+
const modelKey = modelCompactionKey(context?.model);
|
|
8900
|
+
const thresholdTokens = modelKey === void 0 ? void 0 : config.tokenThresholds[modelKey];
|
|
8901
|
+
const thresholdFraction = modelKey === void 0 || thresholdTokens !== void 0 ? void 0 : config.thresholds[modelKey];
|
|
8902
|
+
const contextWindow = positiveWindow(usage?.contextWindow) ?? positiveWindow(context?.model?.contextWindow);
|
|
8903
|
+
const tokens = typeof usage?.tokens === "number" && Number.isFinite(usage.tokens) ? usage.tokens : null;
|
|
8904
|
+
const known = tokens !== null && contextWindow !== void 0;
|
|
8905
|
+
const fraction = known ? tokens / contextWindow : null;
|
|
8906
|
+
const headroomTokens = known ? contextWindow - tokens : null;
|
|
8907
|
+
const band = fraction === null ? "unknown" : fraction >= config.pressureBands.urgent || outputReserveBreached({ tokens, contextWindow }, config.outputReserveTokens) ? "urgent" : fraction >= config.pressureBands.warn ? "warn" : "ok";
|
|
8908
|
+
return {
|
|
8909
|
+
tokens,
|
|
8910
|
+
contextWindow: contextWindow ?? null,
|
|
8911
|
+
fraction,
|
|
8912
|
+
headroomTokens,
|
|
8913
|
+
band,
|
|
8914
|
+
outputReserveTokens: config.outputReserveTokens,
|
|
8915
|
+
...thresholdFraction !== void 0 ? { thresholdFraction } : {},
|
|
8916
|
+
...thresholdTokens !== void 0 ? { thresholdTokens } : {},
|
|
8917
|
+
owner: ownerFromContext(context)
|
|
8918
|
+
};
|
|
8919
|
+
};
|
|
8920
|
+
|
|
8921
|
+
// src/providers/compact-provider.ts
|
|
7878
8922
|
var requestSchema = Type.Object({
|
|
7879
8923
|
reason: Type.Optional(Type.String({
|
|
7880
8924
|
maxLength: 1024,
|
|
@@ -7920,6 +8964,23 @@ var emptySchema = {
|
|
|
7920
8964
|
properties: {},
|
|
7921
8965
|
additionalProperties: false
|
|
7922
8966
|
};
|
|
8967
|
+
var carryItemsSchema = (description) => Type.Optional(Type.Array(
|
|
8968
|
+
Type.String({ minLength: 1, maxLength: MAX_CARRY_ITEM_CHARS }),
|
|
8969
|
+
{ maxItems: MAX_CARRY_ITEMS, description }
|
|
8970
|
+
));
|
|
8971
|
+
var carrySchema = Type.Object({
|
|
8972
|
+
items: carryItemsSchema("Replace the carry-forward list"),
|
|
8973
|
+
add: carryItemsSchema("Append items not already present"),
|
|
8974
|
+
remove: carryItemsSchema("Remove exact items"),
|
|
8975
|
+
clear: Type.Optional(Type.Boolean({ description: "Empty the list before applying items/add" }))
|
|
8976
|
+
}, { additionalProperties: false });
|
|
8977
|
+
var checkedCarryArguments = (args) => {
|
|
8978
|
+
if (!Value2.Check(carrySchema, args)) {
|
|
8979
|
+
const message2 = [...Value2.Errors(carrySchema, args)].slice(0, 5).map((error) => error.message).join("; ");
|
|
8980
|
+
throw new Error(`Invalid compact.carry arguments: ${message2}`);
|
|
8981
|
+
}
|
|
8982
|
+
return args;
|
|
8983
|
+
};
|
|
7923
8984
|
var descriptors = [
|
|
7924
8985
|
{
|
|
7925
8986
|
name: "request",
|
|
@@ -7933,6 +8994,20 @@ var descriptors = [
|
|
|
7933
8994
|
inputSchema: emptySchema,
|
|
7934
8995
|
risk: "read"
|
|
7935
8996
|
},
|
|
8997
|
+
{
|
|
8998
|
+
name: "pressure",
|
|
8999
|
+
description: "Read host context pressure: tokens, window, fraction, headroom, band (ok/warn/urgent/unknown), output reserve, configured threshold, and the observed compaction owner",
|
|
9000
|
+
inputSchema: emptySchema,
|
|
9001
|
+
risk: "read"
|
|
9002
|
+
},
|
|
9003
|
+
{
|
|
9004
|
+
name: "carry",
|
|
9005
|
+
description: "Read or update the persistent carry-forward focus list that Fabric's compactor renders in every summary until cleared. No arguments reads it.",
|
|
9006
|
+
inputSchema: carrySchema,
|
|
9007
|
+
// A persisted session entry that changes every later summary: a control
|
|
9008
|
+
// write, classified like request.
|
|
9009
|
+
risk: "write"
|
|
9010
|
+
},
|
|
7936
9011
|
{
|
|
7937
9012
|
name: "cancel",
|
|
7938
9013
|
description: "Clear a pending compaction intent before the host commits it",
|
|
@@ -7944,12 +9019,41 @@ var descriptors = [
|
|
|
7944
9019
|
}
|
|
7945
9020
|
];
|
|
7946
9021
|
var normalizeCompactArgs = actionArgNormalizer(() => descriptors);
|
|
9022
|
+
var branchOf = (context) => {
|
|
9023
|
+
try {
|
|
9024
|
+
const branch = context.extensionContext?.sessionManager?.getBranch?.();
|
|
9025
|
+
return Array.isArray(branch) ? branch : void 0;
|
|
9026
|
+
} catch {
|
|
9027
|
+
return void 0;
|
|
9028
|
+
}
|
|
9029
|
+
};
|
|
7947
9030
|
var CompactProvider = class {
|
|
7948
|
-
constructor(controller) {
|
|
9031
|
+
constructor(controller, options = {}) {
|
|
7949
9032
|
this.controller = controller;
|
|
9033
|
+
this.options = options;
|
|
7950
9034
|
}
|
|
7951
9035
|
name = "compact";
|
|
7952
9036
|
description = "Programmatic, advisory-then-committed context compaction for the host Pi session";
|
|
9037
|
+
#config() {
|
|
9038
|
+
return this.options.config?.() ?? DEFAULT_FABRIC_CONFIG.compaction;
|
|
9039
|
+
}
|
|
9040
|
+
#carry(update, context) {
|
|
9041
|
+
const branch = branchOf(context);
|
|
9042
|
+
const current = branch ? latestCarryItems(branch) : [];
|
|
9043
|
+
if (!isCarryUpdate(update)) return { items: current };
|
|
9044
|
+
if (!branch || !this.options.appendEntry) {
|
|
9045
|
+
throw new Error("compact.carry cannot persist: no host session is available");
|
|
9046
|
+
}
|
|
9047
|
+
const items = applyCarryUpdate(current, update);
|
|
9048
|
+
if (!sameCarryItems(current, items)) {
|
|
9049
|
+
this.options.appendEntry(COMPACTION_CARRY_ENTRY_TYPE, { version: 1, items });
|
|
9050
|
+
context.activity?.({
|
|
9051
|
+
type: "progress",
|
|
9052
|
+
message: items.length > 0 ? `Compaction carry-forward: ${items.length} item${items.length === 1 ? "" : "s"}` : "Compaction carry-forward cleared"
|
|
9053
|
+
});
|
|
9054
|
+
}
|
|
9055
|
+
return { items };
|
|
9056
|
+
}
|
|
7953
9057
|
async list(request, _context) {
|
|
7954
9058
|
const query = request.query?.toLowerCase();
|
|
7955
9059
|
return query ? descriptors.filter(
|
|
@@ -7985,7 +9089,15 @@ var CompactProvider = class {
|
|
|
7985
9089
|
return { requested: true, intent };
|
|
7986
9090
|
}
|
|
7987
9091
|
case "status":
|
|
7988
|
-
return
|
|
9092
|
+
return {
|
|
9093
|
+
...this.controller.status(),
|
|
9094
|
+
owner: ownerFromContext(context.extensionContext),
|
|
9095
|
+
outputReserveTokens: this.#config().outputReserveTokens
|
|
9096
|
+
};
|
|
9097
|
+
case "pressure":
|
|
9098
|
+
return compactionPressure(context.extensionContext, this.#config());
|
|
9099
|
+
case "carry":
|
|
9100
|
+
return this.#carry(checkedCarryArguments(args), context);
|
|
7989
9101
|
case "cancel":
|
|
7990
9102
|
this.controller.cancel();
|
|
7991
9103
|
context.activity?.({ type: "progress", message: "Compaction request cancelled" });
|
|
@@ -7997,13 +9109,16 @@ var CompactProvider = class {
|
|
|
7997
9109
|
};
|
|
7998
9110
|
|
|
7999
9111
|
// src/cache/leases.ts
|
|
8000
|
-
import { createHash as createHash2, randomUUID as
|
|
9112
|
+
import { createHash as createHash2, randomUUID as randomUUID6 } from "node:crypto";
|
|
8001
9113
|
var MAX_CACHE_LEASE_MS = 30 * 6e4;
|
|
8002
9114
|
var MAX_CACHE_LEASES = 128;
|
|
8003
9115
|
var CacheLeases = class {
|
|
8004
|
-
|
|
9116
|
+
// Full code mode keeps tools active but hides declarations, so the declared
|
|
9117
|
+
// foreground set is a fence input beside the active names.
|
|
9118
|
+
constructor(pi, sessionId, foregroundTools = () => []) {
|
|
8005
9119
|
this.pi = pi;
|
|
8006
9120
|
this.sessionId = sessionId;
|
|
9121
|
+
this.foregroundTools = foregroundTools;
|
|
8007
9122
|
}
|
|
8008
9123
|
#leases = /* @__PURE__ */ new Map();
|
|
8009
9124
|
#unsubscribe = [];
|
|
@@ -8028,7 +9143,8 @@ var CacheLeases = class {
|
|
|
8028
9143
|
context.model?.id,
|
|
8029
9144
|
context.thinkingLevel ?? this.pi.getThinkingLevel(),
|
|
8030
9145
|
context.getSystemPrompt(),
|
|
8031
|
-
[...this.pi.getActiveTools()].sort()
|
|
9146
|
+
[...this.pi.getActiveTools()].sort(),
|
|
9147
|
+
[...this.foregroundTools()].sort()
|
|
8032
9148
|
])).digest("hex");
|
|
8033
9149
|
}
|
|
8034
9150
|
reconcile(context) {
|
|
@@ -8087,7 +9203,7 @@ var CacheLeases = class {
|
|
|
8087
9203
|
}
|
|
8088
9204
|
}
|
|
8089
9205
|
const value = {
|
|
8090
|
-
id:
|
|
9206
|
+
id: randomUUID6(),
|
|
8091
9207
|
scope,
|
|
8092
9208
|
sessionId: this.sessionId,
|
|
8093
9209
|
model: `${context.model.provider}/${context.model.id}`,
|
|
@@ -8279,10 +9395,10 @@ function checked(action, args) {
|
|
|
8279
9395
|
if (error) throw new Error(`Invalid cache.${action} arguments: ${error}`);
|
|
8280
9396
|
}
|
|
8281
9397
|
var CacheProvider = class {
|
|
8282
|
-
constructor(pi, context, isMain) {
|
|
9398
|
+
constructor(pi, context, isMain, foregroundTools) {
|
|
8283
9399
|
this.isMain = isMain;
|
|
8284
9400
|
this.#sessionId = context.sessionManager.getSessionId();
|
|
8285
|
-
this.#leases = new CacheLeases(pi, this.#sessionId);
|
|
9401
|
+
this.#leases = new CacheLeases(pi, this.#sessionId, foregroundTools);
|
|
8286
9402
|
}
|
|
8287
9403
|
name = "cache";
|
|
8288
9404
|
description = "Observed prompt-cache usage and optional native scoped warming; not a key/value or tool-result cache";
|
|
@@ -8349,9 +9465,226 @@ var CacheProvider = class {
|
|
|
8349
9465
|
}
|
|
8350
9466
|
};
|
|
8351
9467
|
|
|
8352
|
-
// src/providers/
|
|
9468
|
+
// src/providers/thinking-provider.ts
|
|
8353
9469
|
var emptySchema2 = { type: "object", properties: {}, additionalProperties: false };
|
|
9470
|
+
var setSchema = {
|
|
9471
|
+
type: "object",
|
|
9472
|
+
required: ["level"],
|
|
9473
|
+
additionalProperties: false,
|
|
9474
|
+
properties: {
|
|
9475
|
+
level: { type: "string", enum: [...THINKING_LEVELS], description: "Requested level; clamped into thinking.bounds and the model's supported levels" },
|
|
9476
|
+
scope: {
|
|
9477
|
+
type: "string",
|
|
9478
|
+
enum: ["turn", "turns", "session"],
|
|
9479
|
+
description: "turn (default) reverts at the next agent_end; turns reverts after `turns` agent_end events (the current run counts); session lasts until thinking.reset()"
|
|
9480
|
+
},
|
|
9481
|
+
turns: { type: "integer", minimum: 1, maximum: MAX_THINKING_OVERRIDE_TURNS, description: 'Required with scope "turns"; invalid otherwise' },
|
|
9482
|
+
reason: { type: "string", maxLength: MAX_THINKING_REASON_CHARS }
|
|
9483
|
+
}
|
|
9484
|
+
};
|
|
9485
|
+
var resource = ["pi:thinking-level"];
|
|
8354
9486
|
var descriptors3 = [
|
|
9487
|
+
{
|
|
9488
|
+
name: "status",
|
|
9489
|
+
description: "Read the host session's thinking level, model-supported levels inside the effective bounds, the baseline, and any active Fabric override",
|
|
9490
|
+
inputSchema: emptySchema2,
|
|
9491
|
+
risk: "read",
|
|
9492
|
+
effect: { kind: "none", resources: resource, ordering: "commutative" }
|
|
9493
|
+
},
|
|
9494
|
+
{
|
|
9495
|
+
name: "set",
|
|
9496
|
+
description: "Temporarily change the host session's thinking level for this turn, N turns, or the session. Clamped into bounds and model support (reports clamped/requested). Reverts to the baseline at agent_end; restored after reload.",
|
|
9497
|
+
inputSchema: setSchema,
|
|
9498
|
+
risk: "write",
|
|
9499
|
+
effect: { kind: "emission", resources: resource, ordering: "ordered" }
|
|
9500
|
+
},
|
|
9501
|
+
{
|
|
9502
|
+
name: "reset",
|
|
9503
|
+
description: "End any Fabric thinking override and restore the baseline level",
|
|
9504
|
+
inputSchema: emptySchema2,
|
|
9505
|
+
risk: "write",
|
|
9506
|
+
effect: { kind: "emission", resources: resource, ordering: "ordered" }
|
|
9507
|
+
}
|
|
9508
|
+
];
|
|
9509
|
+
var normalizeThinkingArgs = actionArgNormalizer(() => descriptors3);
|
|
9510
|
+
var ThinkingProvider = class {
|
|
9511
|
+
constructor(controller, sessionId) {
|
|
9512
|
+
this.controller = controller;
|
|
9513
|
+
this.sessionId = sessionId;
|
|
9514
|
+
}
|
|
9515
|
+
name = "thinking";
|
|
9516
|
+
description = "Bounded host-session thinking (reasoning effort) control";
|
|
9517
|
+
async list(request) {
|
|
9518
|
+
const query = request.query?.toLowerCase();
|
|
9519
|
+
return descriptors3.filter((action) => !query || `${action.name} ${action.description}`.toLowerCase().includes(query));
|
|
9520
|
+
}
|
|
9521
|
+
async describe(name) {
|
|
9522
|
+
return descriptors3.find((action) => action.name === name);
|
|
9523
|
+
}
|
|
9524
|
+
prepareArguments(name, args) {
|
|
9525
|
+
return normalizeThinkingArgs(name, args);
|
|
9526
|
+
}
|
|
9527
|
+
async invoke(name, args, context) {
|
|
9528
|
+
const descriptor = descriptors3.find((action) => action.name === name);
|
|
9529
|
+
if (!descriptor) throw new Error(`Unknown thinking action: ${name}`);
|
|
9530
|
+
const error = validationMessage(descriptor.inputSchema, args);
|
|
9531
|
+
if (error) throw new Error(`Invalid thinking.${name} arguments: ${error}`);
|
|
9532
|
+
const host = context.extensionContext;
|
|
9533
|
+
if (host.sessionManager.getSessionId() !== this.sessionId) {
|
|
9534
|
+
throw new Error("Thinking provider belongs to a different session");
|
|
9535
|
+
}
|
|
9536
|
+
if (name === "status") return this.controller.status(host);
|
|
9537
|
+
if (name === "reset") {
|
|
9538
|
+
const status = this.controller.reset(host);
|
|
9539
|
+
context.activity?.({ type: "progress", message: `Thinking level reset to ${status.level}` });
|
|
9540
|
+
return status;
|
|
9541
|
+
}
|
|
9542
|
+
const result = this.controller.set(args, host);
|
|
9543
|
+
context.activity?.({
|
|
9544
|
+
type: "progress",
|
|
9545
|
+
message: result.clamped ? `Thinking level ${result.level} (requested ${result.requested}, clamped)` : `Thinking level ${result.level} (${result.override?.scope ?? "turn"})`
|
|
9546
|
+
});
|
|
9547
|
+
return result;
|
|
9548
|
+
}
|
|
9549
|
+
};
|
|
9550
|
+
|
|
9551
|
+
// src/providers/programs-provider.ts
|
|
9552
|
+
var resource2 = ["fabric:programs"];
|
|
9553
|
+
var refSchema = { type: "string", minLength: 1, maxLength: MAX_PROGRAM_REF_CHARS };
|
|
9554
|
+
var descriptors4 = [
|
|
9555
|
+
{
|
|
9556
|
+
name: "save",
|
|
9557
|
+
description: 'Save a program as a content-addressed candidate; identical content returns the same ref. Returns { ref: "name@digest12", digest }',
|
|
9558
|
+
inputSchema: {
|
|
9559
|
+
type: "object",
|
|
9560
|
+
required: ["name"],
|
|
9561
|
+
additionalProperties: false,
|
|
9562
|
+
properties: {
|
|
9563
|
+
name: { type: "string", minLength: 1, maxLength: MAX_PROGRAM_NAME_CHARS, pattern: "^[a-z0-9][a-z0-9._-]*$" },
|
|
9564
|
+
kind: { type: "string", enum: ["fabric", "jev"] },
|
|
9565
|
+
kernel: { type: "string", enum: ["typescript", "python"] },
|
|
9566
|
+
code: { type: "string", minLength: 1, maxLength: MAX_PROGRAM_CODE_CHARS },
|
|
9567
|
+
jevProgram: { type: "object" },
|
|
9568
|
+
description: { type: "string", maxLength: MAX_PROGRAM_DESCRIPTION_CHARS },
|
|
9569
|
+
inputSchema: { type: "object" }
|
|
9570
|
+
}
|
|
9571
|
+
},
|
|
9572
|
+
risk: "write",
|
|
9573
|
+
namespace: "programs",
|
|
9574
|
+
effect: { kind: "transactional", resources: resource2, ordering: "ordered" }
|
|
9575
|
+
},
|
|
9576
|
+
{
|
|
9577
|
+
name: "list",
|
|
9578
|
+
description: "List saved programs newest first per name, optionally by name and status (candidate, promoted, retired)",
|
|
9579
|
+
inputSchema: {
|
|
9580
|
+
type: "object",
|
|
9581
|
+
additionalProperties: false,
|
|
9582
|
+
properties: {
|
|
9583
|
+
name: { type: "string", minLength: 1, maxLength: MAX_PROGRAM_NAME_CHARS },
|
|
9584
|
+
status: { type: "string", enum: ["candidate", "promoted", "retired"] }
|
|
9585
|
+
}
|
|
9586
|
+
},
|
|
9587
|
+
risk: "read",
|
|
9588
|
+
namespace: "programs",
|
|
9589
|
+
effect: { kind: "none", resources: resource2, ordering: "commutative" }
|
|
9590
|
+
},
|
|
9591
|
+
{
|
|
9592
|
+
name: "get",
|
|
9593
|
+
description: "Read one saved program by ref: name (latest promoted, else latest candidate), name@<digest prefix \u226512>, or a full digest",
|
|
9594
|
+
inputSchema: {
|
|
9595
|
+
type: "object",
|
|
9596
|
+
required: ["ref"],
|
|
9597
|
+
additionalProperties: false,
|
|
9598
|
+
properties: { ref: refSchema }
|
|
9599
|
+
},
|
|
9600
|
+
risk: "read",
|
|
9601
|
+
namespace: "programs",
|
|
9602
|
+
effect: { kind: "none", resources: resource2, ordering: "commutative" }
|
|
9603
|
+
},
|
|
9604
|
+
{
|
|
9605
|
+
name: "run",
|
|
9606
|
+
description: "Run a saved program nested in this execution with the caller's capabilities and approvals; input becomes the program's `input` global. Returns the program's result",
|
|
9607
|
+
inputSchema: {
|
|
9608
|
+
type: "object",
|
|
9609
|
+
required: ["ref"],
|
|
9610
|
+
additionalProperties: false,
|
|
9611
|
+
properties: {
|
|
9612
|
+
ref: refSchema,
|
|
9613
|
+
input: {},
|
|
9614
|
+
requirePromoted: { type: "boolean" }
|
|
9615
|
+
}
|
|
9616
|
+
},
|
|
9617
|
+
risk: "execute",
|
|
9618
|
+
namespace: "programs"
|
|
9619
|
+
}
|
|
9620
|
+
];
|
|
9621
|
+
var normalizeProgramsArgs = actionArgNormalizer(() => descriptors4);
|
|
9622
|
+
var ProgramsProvider = class {
|
|
9623
|
+
constructor(store, defaultKernel, nestedRunner) {
|
|
9624
|
+
this.store = store;
|
|
9625
|
+
this.defaultKernel = defaultKernel;
|
|
9626
|
+
this.nestedRunner = nestedRunner;
|
|
9627
|
+
}
|
|
9628
|
+
name = "programs";
|
|
9629
|
+
description = "Content-addressed saved programs run nested in the caller's execution";
|
|
9630
|
+
async list(request) {
|
|
9631
|
+
const query = request.query?.toLowerCase();
|
|
9632
|
+
return descriptors4.filter((action) => !query || `${action.name} ${action.description}`.toLowerCase().includes(query));
|
|
9633
|
+
}
|
|
9634
|
+
async describe(name) {
|
|
9635
|
+
return descriptors4.find((action) => action.name === name);
|
|
9636
|
+
}
|
|
9637
|
+
prepareArguments(name, args) {
|
|
9638
|
+
return normalizeProgramsArgs(name, args);
|
|
9639
|
+
}
|
|
9640
|
+
async invoke(name, args, context) {
|
|
9641
|
+
const descriptor = descriptors4.find((action) => action.name === name);
|
|
9642
|
+
if (!descriptor) throw new Error(`Unknown programs action: ${name}`);
|
|
9643
|
+
const error = validationMessage(descriptor.inputSchema, args);
|
|
9644
|
+
if (error) throw new Error(`Invalid programs.${name} arguments: ${error}`);
|
|
9645
|
+
switch (name) {
|
|
9646
|
+
case "save": {
|
|
9647
|
+
const { record, created } = await this.store.save(args, this.defaultKernel());
|
|
9648
|
+
if (created) context.activity?.({ type: "progress", message: `Program saved: ${programRef(record)}` });
|
|
9649
|
+
return { ref: programRef(record), digest: record.digest };
|
|
9650
|
+
}
|
|
9651
|
+
case "list":
|
|
9652
|
+
return this.store.list({
|
|
9653
|
+
...typeof args.name === "string" ? { name: args.name } : {},
|
|
9654
|
+
...typeof args.status === "string" ? { status: args.status } : {}
|
|
9655
|
+
});
|
|
9656
|
+
case "get": {
|
|
9657
|
+
const record = await this.store.resolve(args.ref);
|
|
9658
|
+
return { ref: programRef(record), ...record };
|
|
9659
|
+
}
|
|
9660
|
+
case "run":
|
|
9661
|
+
return this.#run(args, context);
|
|
9662
|
+
default:
|
|
9663
|
+
throw new Error(`Unknown programs action: ${name}`);
|
|
9664
|
+
}
|
|
9665
|
+
}
|
|
9666
|
+
async #run(args, context) {
|
|
9667
|
+
const runner = this.nestedRunner(context.parentToolCallId);
|
|
9668
|
+
if (!runner) throw new Error("programs.run runs only inside a fabric_exec program or a host program run");
|
|
9669
|
+
const record = await this.store.resolve(args.ref, { requirePromoted: args.requirePromoted === true });
|
|
9670
|
+
const label = programRef(record, true);
|
|
9671
|
+
if (record.status === "retired") throw new Error(`Program ${label} is retired; a user can promote it again with /fabric programs promote`);
|
|
9672
|
+
const input = normalizeProgramInput(args.input);
|
|
9673
|
+
const invalid = programInputError(record, input);
|
|
9674
|
+
if (invalid) throw new Error(`Invalid input for program ${label}: ${invalid}`);
|
|
9675
|
+
if (record.kind === "jev") {
|
|
9676
|
+
return runner.run({ program: label, call: { ref: "jev.run", args: { program: record.jevProgram, input: input ?? null } } }, context.signal);
|
|
9677
|
+
}
|
|
9678
|
+
if (record.kernel !== runner.kernel) {
|
|
9679
|
+
throw new Error(`Program ${label} is a ${record.kernel} program; this session's kernel is ${runner.kernel}`);
|
|
9680
|
+
}
|
|
9681
|
+
return runner.run({ program: label, code: programSourceWithInput(record.code ?? "", runner.kernel, input) }, context.signal);
|
|
9682
|
+
}
|
|
9683
|
+
};
|
|
9684
|
+
|
|
9685
|
+
// src/providers/prewalk-provider.ts
|
|
9686
|
+
var emptySchema3 = { type: "object", properties: {}, additionalProperties: false };
|
|
9687
|
+
var descriptors5 = [
|
|
8355
9688
|
{
|
|
8356
9689
|
name: "plan",
|
|
8357
9690
|
description: "Submit the executor handoff plan only when this session is awaiting one and Fabric's armed advisory or checkpoint requests it. Not a general task planner, checklist, or acceptance-ledger store. Include the outcome, ordered steps with exact files and checks, verification, and risks. Fabric delivers the recorded plan directly to the executor even if this action's return is discarded.",
|
|
@@ -8361,11 +9694,11 @@ var descriptors3 = [
|
|
|
8361
9694
|
{
|
|
8362
9695
|
name: "status",
|
|
8363
9696
|
description: "Report the prewalk arm, plan readiness, the readiness kind claimed by an in-flight handoff, and the loaded build identity of the extension entry and lazy runtime versus the files currently on disk",
|
|
8364
|
-
inputSchema:
|
|
9697
|
+
inputSchema: emptySchema3,
|
|
8365
9698
|
risk: "read"
|
|
8366
9699
|
}
|
|
8367
9700
|
];
|
|
8368
|
-
var normalizePrewalkArgs = actionArgNormalizer(() =>
|
|
9701
|
+
var normalizePrewalkArgs = actionArgNormalizer(() => descriptors5);
|
|
8369
9702
|
var PrewalkProvider = class {
|
|
8370
9703
|
constructor(controller, options = {}) {
|
|
8371
9704
|
this.controller = controller;
|
|
@@ -8378,7 +9711,7 @@ var PrewalkProvider = class {
|
|
|
8378
9711
|
const planRequired = this.controller.planRequired(
|
|
8379
9712
|
context.extensionContext.sessionManager.getSessionId()
|
|
8380
9713
|
);
|
|
8381
|
-
return
|
|
9714
|
+
return descriptors5.filter(
|
|
8382
9715
|
(descriptor) => (descriptor.name !== "plan" || planRequired) && (!query || `${descriptor.name} ${descriptor.description}`.toLowerCase().includes(query))
|
|
8383
9716
|
);
|
|
8384
9717
|
}
|
|
@@ -8447,7 +9780,7 @@ var changeProperties = {
|
|
|
8447
9780
|
remove: { type: "array", items: { type: "string" }, maxItems: 256 },
|
|
8448
9781
|
reset: { type: "array", items: { type: "string" }, maxItems: 256, description: "Session only: remove overlays and use trusted file configuration for these IDs." }
|
|
8449
9782
|
};
|
|
8450
|
-
var
|
|
9783
|
+
var descriptors6 = [
|
|
8451
9784
|
{
|
|
8452
9785
|
name: "list",
|
|
8453
9786
|
description: "List registered component definitions and configured component instances.",
|
|
@@ -8523,16 +9856,16 @@ var ComponentsProvider = class {
|
|
|
8523
9856
|
description = "Supervised component lifecycle, exact capability dependencies, effect cleanup, and reload diagnostics.";
|
|
8524
9857
|
async list(request, _context) {
|
|
8525
9858
|
const query = request.query?.normalize("NFKC").trim().toLowerCase();
|
|
8526
|
-
const filtered = query ?
|
|
9859
|
+
const filtered = query ? descriptors6.filter(
|
|
8527
9860
|
(descriptor) => `${descriptor.name} ${descriptor.description}`.toLowerCase().includes(query)
|
|
8528
|
-
) :
|
|
9861
|
+
) : descriptors6;
|
|
8529
9862
|
return filtered.slice(0, Math.max(1, Math.min(request.limit ?? 100, 100)));
|
|
8530
9863
|
}
|
|
8531
9864
|
async describe(actionName, _context) {
|
|
8532
|
-
return
|
|
9865
|
+
return descriptors6.find((descriptor) => descriptor.name === actionName);
|
|
8533
9866
|
}
|
|
8534
9867
|
async invoke(actionName, args, context) {
|
|
8535
|
-
const descriptor =
|
|
9868
|
+
const descriptor = descriptors6.find((action) => action.name === actionName);
|
|
8536
9869
|
if (descriptor) {
|
|
8537
9870
|
const invalid = validationMessage(descriptor.inputSchema, args);
|
|
8538
9871
|
if (invalid) throw new Error(`Invalid components.${actionName} arguments: ${invalid}`);
|
|
@@ -8638,11 +9971,11 @@ var CapturedToolsProvider = class {
|
|
|
8638
9971
|
#allowedTools = readChildToolAllowlist();
|
|
8639
9972
|
async list(request, _context) {
|
|
8640
9973
|
const query = request.query?.trim().toLowerCase();
|
|
8641
|
-
const
|
|
9974
|
+
const descriptors13 = this.catalog.list().filter(
|
|
8642
9975
|
(entry) => (!this.#allowedTools || this.#allowedTools.has(entry.name)) && !this.omitFromDiscovery(entry)
|
|
8643
9976
|
).map(descriptorFrom);
|
|
8644
|
-
if (!query) return
|
|
8645
|
-
return
|
|
9977
|
+
if (!query) return descriptors13;
|
|
9978
|
+
return descriptors13.filter(
|
|
8646
9979
|
(descriptor) => `${descriptor.name} ${descriptor.description} ${descriptor.namespace ?? ""}`.toLowerCase().includes(query)
|
|
8647
9980
|
);
|
|
8648
9981
|
}
|
|
@@ -8966,11 +10299,35 @@ var PiNativeMcpTools = class {
|
|
|
8966
10299
|
};
|
|
8967
10300
|
|
|
8968
10301
|
// src/providers/mesh-provider.ts
|
|
8969
|
-
var
|
|
8970
|
-
var INTERNAL_STATE_PREFIXES = ["topology/", "sessions/", "actors/", "residency/"];
|
|
10302
|
+
var emptySchema4 = { type: "object", properties: {}, additionalProperties: false };
|
|
10303
|
+
var INTERNAL_STATE_PREFIXES = ["topology/", "sessions/", "actors/", "residency/", "decisions/"];
|
|
8971
10304
|
var PRIVATE_STATE_PREFIXES = ["residency/"];
|
|
8972
10305
|
var INTERNAL_CONTROL_PREFIX = "fabric.control.";
|
|
8973
10306
|
var INTERNAL_HOST_EVENT_TOPIC = "fabric.actor.host-event";
|
|
10307
|
+
var assertPublicMeshTopic = (topic) => {
|
|
10308
|
+
if (topic.startsWith(INTERNAL_CONTROL_PREFIX) || topic === INTERNAL_HOST_EVENT_TOPIC || topic === FABRIC_PARTICIPANT_LIFECYCLE_TOPIC) {
|
|
10309
|
+
throw new Error(`Fabric mesh topic is reserved for host coordination: ${topic}`);
|
|
10310
|
+
}
|
|
10311
|
+
return topic;
|
|
10312
|
+
};
|
|
10313
|
+
var meshScheduleDueAt = (args, now = Date.now()) => {
|
|
10314
|
+
if (args.notBefore !== void 0 && args.afterMs !== void 0) {
|
|
10315
|
+
throw new Error("mesh.publish accepts notBefore or afterMs, not both");
|
|
10316
|
+
}
|
|
10317
|
+
if (args.afterMs !== void 0) {
|
|
10318
|
+
const afterMs = args.afterMs;
|
|
10319
|
+
if (typeof afterMs !== "number" || !Number.isFinite(afterMs) || afterMs < 0) {
|
|
10320
|
+
throw new Error("mesh.publish afterMs must be a nonnegative number of milliseconds");
|
|
10321
|
+
}
|
|
10322
|
+
return now + Math.ceil(afterMs);
|
|
10323
|
+
}
|
|
10324
|
+
if (args.notBefore === void 0) return void 0;
|
|
10325
|
+
const dueAt = typeof args.notBefore === "number" ? args.notBefore : typeof args.notBefore === "string" && /^\d{4}-\d{2}-\d{2}T/.test(args.notBefore) ? Date.parse(args.notBefore) : Number.NaN;
|
|
10326
|
+
if (!Number.isFinite(dueAt) || dueAt < 0) {
|
|
10327
|
+
throw new Error("mesh.publish notBefore must be epoch milliseconds or an ISO 8601 date-time");
|
|
10328
|
+
}
|
|
10329
|
+
return Math.ceil(dueAt);
|
|
10330
|
+
};
|
|
8974
10331
|
var assertPublicStateKey = (key) => {
|
|
8975
10332
|
if (INTERNAL_STATE_PREFIXES.some((prefix) => key.startsWith(prefix))) {
|
|
8976
10333
|
throw new Error(`Fabric mesh key is reserved for host coordination: ${key}`);
|
|
@@ -8981,17 +10338,17 @@ var assertReadableStateKey = (key) => {
|
|
|
8981
10338
|
throw new Error(`Fabric mesh key is private host state: ${key}`);
|
|
8982
10339
|
}
|
|
8983
10340
|
};
|
|
8984
|
-
var
|
|
10341
|
+
var descriptors7 = [
|
|
8985
10342
|
{
|
|
8986
10343
|
name: "self",
|
|
8987
10344
|
description: "Return this Fabric participant's mesh identity",
|
|
8988
|
-
inputSchema:
|
|
10345
|
+
inputSchema: emptySchema4,
|
|
8989
10346
|
risk: "read",
|
|
8990
10347
|
namespace: "coordination"
|
|
8991
10348
|
},
|
|
8992
10349
|
{
|
|
8993
10350
|
name: "publish",
|
|
8994
|
-
description: "Append a durable event to a mesh topic, optionally addressed to one actor",
|
|
10351
|
+
description: "Append a durable event to a mesh topic, optionally addressed to one actor. notBefore (epoch ms or ISO) or afterMs schedules it instead; key makes the schedule replaceable",
|
|
8995
10352
|
inputSchema: {
|
|
8996
10353
|
type: "object",
|
|
8997
10354
|
properties: {
|
|
@@ -8999,7 +10356,10 @@ var descriptors5 = [
|
|
|
8999
10356
|
kind: { type: "string" },
|
|
9000
10357
|
to: { type: "string" },
|
|
9001
10358
|
text: { type: "string" },
|
|
9002
|
-
data: {}
|
|
10359
|
+
data: {},
|
|
10360
|
+
notBefore: { anyOf: [{ type: "number", minimum: 0 }, { type: "string", maxLength: 64 }] },
|
|
10361
|
+
afterMs: { type: "number", minimum: 0, maximum: MESH_MAX_SCHEDULE_AHEAD_MS },
|
|
10362
|
+
key: { type: "string", minLength: 1, maxLength: 128 }
|
|
9003
10363
|
},
|
|
9004
10364
|
required: ["topic"],
|
|
9005
10365
|
additionalProperties: false
|
|
@@ -9007,6 +10367,69 @@ var descriptors5 = [
|
|
|
9007
10367
|
risk: "agent",
|
|
9008
10368
|
namespace: "coordination"
|
|
9009
10369
|
},
|
|
10370
|
+
{
|
|
10371
|
+
name: "scheduled",
|
|
10372
|
+
description: "List pending scheduled mesh events by due time",
|
|
10373
|
+
inputSchema: {
|
|
10374
|
+
type: "object",
|
|
10375
|
+
properties: {
|
|
10376
|
+
topic: { type: "string" },
|
|
10377
|
+
limit: { type: "number", minimum: 1, maximum: MESH_MAX_PENDING_SCHEDULES }
|
|
10378
|
+
},
|
|
10379
|
+
additionalProperties: false
|
|
10380
|
+
},
|
|
10381
|
+
risk: "read",
|
|
10382
|
+
namespace: "coordination"
|
|
10383
|
+
},
|
|
10384
|
+
{
|
|
10385
|
+
name: "unschedule",
|
|
10386
|
+
description: "Cancel a pending scheduled mesh event by key",
|
|
10387
|
+
inputSchema: {
|
|
10388
|
+
type: "object",
|
|
10389
|
+
properties: { key: { type: "string", minLength: 1, maxLength: 128 } },
|
|
10390
|
+
required: ["key"],
|
|
10391
|
+
additionalProperties: false
|
|
10392
|
+
},
|
|
10393
|
+
risk: "agent",
|
|
10394
|
+
namespace: "coordination"
|
|
10395
|
+
},
|
|
10396
|
+
{
|
|
10397
|
+
name: "grant",
|
|
10398
|
+
description: "Mint a scoped token that lets an outside process post untrusted events to one topic through `pi-fabric mesh post`",
|
|
10399
|
+
inputSchema: {
|
|
10400
|
+
type: "object",
|
|
10401
|
+
properties: {
|
|
10402
|
+
topic: { type: "string" },
|
|
10403
|
+
ttlMs: { type: "number", minimum: MESH_GRANT_MIN_TTL_MS, maximum: MESH_GRANT_MAX_TTL_MS },
|
|
10404
|
+
uses: { type: "number", minimum: 1, maximum: MESH_GRANT_MAX_USES },
|
|
10405
|
+
kind: { type: "string", minLength: 1, maxLength: 128 }
|
|
10406
|
+
},
|
|
10407
|
+
required: ["topic", "ttlMs"],
|
|
10408
|
+
additionalProperties: false
|
|
10409
|
+
},
|
|
10410
|
+
// Opens an ingress for principals outside this session: the most conservative fitting class.
|
|
10411
|
+
risk: "network",
|
|
10412
|
+
namespace: "coordination"
|
|
10413
|
+
},
|
|
10414
|
+
{
|
|
10415
|
+
name: "revoke",
|
|
10416
|
+
description: "Revoke a scoped external mesh grant",
|
|
10417
|
+
inputSchema: {
|
|
10418
|
+
type: "object",
|
|
10419
|
+
properties: { grantId: { type: "string", minLength: 1, maxLength: 64 } },
|
|
10420
|
+
required: ["grantId"],
|
|
10421
|
+
additionalProperties: false
|
|
10422
|
+
},
|
|
10423
|
+
risk: "write",
|
|
10424
|
+
namespace: "coordination"
|
|
10425
|
+
},
|
|
10426
|
+
{
|
|
10427
|
+
name: "grants",
|
|
10428
|
+
description: "List unexpired external mesh grants (never tokens)",
|
|
10429
|
+
inputSchema: emptySchema4,
|
|
10430
|
+
risk: "read",
|
|
10431
|
+
namespace: "coordination"
|
|
10432
|
+
},
|
|
9010
10433
|
{
|
|
9011
10434
|
name: "read",
|
|
9012
10435
|
description: "Read durable mesh events after a sequence cursor",
|
|
@@ -9100,7 +10523,7 @@ var descriptors5 = [
|
|
|
9100
10523
|
namespace: "coordination"
|
|
9101
10524
|
}
|
|
9102
10525
|
];
|
|
9103
|
-
var normalizeMeshArgs = actionArgNormalizer(() =>
|
|
10526
|
+
var normalizeMeshArgs = actionArgNormalizer(() => descriptors7);
|
|
9104
10527
|
var MeshProvider = class {
|
|
9105
10528
|
constructor(store, identity, participants) {
|
|
9106
10529
|
this.store = store;
|
|
@@ -9111,12 +10534,12 @@ var MeshProvider = class {
|
|
|
9111
10534
|
description = "Durable topics and compare-and-swap shared state for emergent agent coordination";
|
|
9112
10535
|
async list(request, _context) {
|
|
9113
10536
|
const query = request.query?.toLowerCase();
|
|
9114
|
-
return query ?
|
|
10537
|
+
return query ? descriptors7.filter(
|
|
9115
10538
|
(descriptor) => `${descriptor.name} ${descriptor.description}`.toLowerCase().includes(query)
|
|
9116
|
-
) :
|
|
10539
|
+
) : descriptors7;
|
|
9117
10540
|
}
|
|
9118
10541
|
async describe(actionName, _context) {
|
|
9119
|
-
return
|
|
10542
|
+
return descriptors7.find((descriptor) => descriptor.name === actionName);
|
|
9120
10543
|
}
|
|
9121
10544
|
prepareArguments(actionName, args) {
|
|
9122
10545
|
return normalizeMeshArgs(actionName, args);
|
|
@@ -9126,20 +10549,59 @@ var MeshProvider = class {
|
|
|
9126
10549
|
case "self":
|
|
9127
10550
|
return this.identity;
|
|
9128
10551
|
case "publish": {
|
|
9129
|
-
const topic = String(args.topic);
|
|
9130
|
-
|
|
9131
|
-
throw new Error(`Fabric mesh topic is reserved for host coordination: ${topic}`);
|
|
9132
|
-
}
|
|
9133
|
-
return this.store.publish({
|
|
10552
|
+
const topic = assertPublicMeshTopic(String(args.topic));
|
|
10553
|
+
const message2 = {
|
|
9134
10554
|
topic,
|
|
9135
10555
|
from: this.identity,
|
|
9136
10556
|
...typeof args.kind === "string" ? { kind: args.kind } : {},
|
|
9137
10557
|
...typeof args.to === "string" ? { to: args.to } : {},
|
|
9138
10558
|
...typeof args.text === "string" ? { text: args.text } : {},
|
|
9139
10559
|
...args.data !== void 0 ? { data: args.data } : {}
|
|
10560
|
+
};
|
|
10561
|
+
const dueAt = meshScheduleDueAt(args);
|
|
10562
|
+
if (dueAt === void 0) {
|
|
10563
|
+
if (args.key !== void 0) throw new Error("mesh.publish key requires notBefore or afterMs");
|
|
10564
|
+
return this.store.publish(message2);
|
|
10565
|
+
}
|
|
10566
|
+
const schedule = await this.store.schedule({
|
|
10567
|
+
...message2,
|
|
10568
|
+
dueAt,
|
|
10569
|
+
...typeof args.key === "string" ? { key: args.key } : {}
|
|
10570
|
+
});
|
|
10571
|
+
return { scheduled: true, ...schedule };
|
|
10572
|
+
}
|
|
10573
|
+
case "scheduled":
|
|
10574
|
+
return this.store.scheduled({
|
|
10575
|
+
...typeof args.topic === "string" ? { topic: args.topic } : {},
|
|
10576
|
+
...typeof args.limit === "number" ? { limit: args.limit } : {}
|
|
10577
|
+
});
|
|
10578
|
+
case "unschedule":
|
|
10579
|
+
return this.store.unschedule(String(args.key));
|
|
10580
|
+
case "grant": {
|
|
10581
|
+
const topic = assertPublicMeshTopic(String(args.topic));
|
|
10582
|
+
const { grant, token } = await createMeshGrant(this.store, {
|
|
10583
|
+
topic,
|
|
10584
|
+
ttlMs: Number(args.ttlMs),
|
|
10585
|
+
...typeof args.uses === "number" ? { uses: args.uses } : {},
|
|
10586
|
+
...typeof args.kind === "string" ? { kind: args.kind } : {},
|
|
10587
|
+
createdBy: this.identity
|
|
9140
10588
|
});
|
|
10589
|
+
return {
|
|
10590
|
+
...grant,
|
|
10591
|
+
token,
|
|
10592
|
+
command: meshPostCommand(meshCliArgv(), {
|
|
10593
|
+
root: this.store.root,
|
|
10594
|
+
token,
|
|
10595
|
+
...grant.kind !== void 0 ? { kind: grant.kind } : {}
|
|
10596
|
+
})
|
|
10597
|
+
};
|
|
9141
10598
|
}
|
|
10599
|
+
case "revoke":
|
|
10600
|
+
return revokeMeshGrant(this.store, String(args.grantId));
|
|
10601
|
+
case "grants":
|
|
10602
|
+
return listMeshGrants(this.store);
|
|
9142
10603
|
case "read":
|
|
10604
|
+
await this.store.releaseDueSchedules().catch(() => void 0);
|
|
9143
10605
|
return this.store.read({
|
|
9144
10606
|
...typeof args.after === "number" ? { after: args.after } : {},
|
|
9145
10607
|
...typeof args.topic === "string" ? { topic: args.topic } : {},
|
|
@@ -9203,6 +10665,240 @@ var MeshProvider = class {
|
|
|
9203
10665
|
}
|
|
9204
10666
|
};
|
|
9205
10667
|
|
|
10668
|
+
// src/providers/decisions-provider.ts
|
|
10669
|
+
var resource3 = ["fabric:decisions"];
|
|
10670
|
+
var idSchema = { type: "string", minLength: 8, maxLength: 72 };
|
|
10671
|
+
var holderSchema = { type: "string", maxLength: 139 };
|
|
10672
|
+
var descriptors8 = [
|
|
10673
|
+
{
|
|
10674
|
+
name: "raise",
|
|
10675
|
+
description: "Create a durable open decision (approval, question, or escalation) for a human or holder to answer; returns { id }",
|
|
10676
|
+
inputSchema: {
|
|
10677
|
+
type: "object",
|
|
10678
|
+
required: ["title"],
|
|
10679
|
+
additionalProperties: false,
|
|
10680
|
+
properties: {
|
|
10681
|
+
kind: { type: "string", enum: ["approval", "question", "escalation"] },
|
|
10682
|
+
title: { type: "string", minLength: 1, maxLength: MAX_DECISION_TITLE_CHARS },
|
|
10683
|
+
body: { type: "string", maxLength: MAX_DECISION_BODY_CHARS },
|
|
10684
|
+
options: {
|
|
10685
|
+
type: "array",
|
|
10686
|
+
minItems: 1,
|
|
10687
|
+
maxItems: MAX_DECISION_OPTIONS,
|
|
10688
|
+
items: {
|
|
10689
|
+
type: "object",
|
|
10690
|
+
required: ["id", "label"],
|
|
10691
|
+
additionalProperties: false,
|
|
10692
|
+
properties: {
|
|
10693
|
+
id: { type: "string", minLength: 1, maxLength: 64 },
|
|
10694
|
+
label: { type: "string", minLength: 1, maxLength: MAX_DECISION_TITLE_CHARS }
|
|
10695
|
+
}
|
|
10696
|
+
}
|
|
10697
|
+
},
|
|
10698
|
+
input: { type: "string", enum: ["text", "confirm", "select", "editor"] },
|
|
10699
|
+
holder: {
|
|
10700
|
+
type: "string",
|
|
10701
|
+
maxLength: 139,
|
|
10702
|
+
description: '"user" (default, human only), "root" (root session), or "supervisor:<participantId>"'
|
|
10703
|
+
},
|
|
10704
|
+
deadline: { type: "number", description: "Epoch ms; at most 30 days ahead" },
|
|
10705
|
+
timeoutMs: { type: "integer", minimum: 1e3, maximum: MAX_DECISION_DEADLINE_MS },
|
|
10706
|
+
onExpire: { type: "string", enum: ["cancel", "default", "escalate"] },
|
|
10707
|
+
defaultOptionId: { type: "string", maxLength: 64 },
|
|
10708
|
+
escalation: {
|
|
10709
|
+
type: "object",
|
|
10710
|
+
additionalProperties: false,
|
|
10711
|
+
description: 'With onExpire "escalate": holders in order (default climbs supervisor -> root -> user), per-hop timeout, and what the last expiry does',
|
|
10712
|
+
properties: {
|
|
10713
|
+
chain: { type: "array", minItems: 1, maxItems: MAX_ESCALATION_HOPS, items: holderSchema },
|
|
10714
|
+
hopTimeoutMs: { type: "integer", minimum: MIN_ESCALATION_HOP_MS, maximum: MAX_ESCALATION_HOP_MS },
|
|
10715
|
+
onFinal: { type: "string", enum: ["cancel", "default"] }
|
|
10716
|
+
}
|
|
10717
|
+
}
|
|
10718
|
+
}
|
|
10719
|
+
},
|
|
10720
|
+
risk: "agent",
|
|
10721
|
+
namespace: "coordination",
|
|
10722
|
+
effect: { kind: "emission", resources: resource3, ordering: "ordered" }
|
|
10723
|
+
},
|
|
10724
|
+
{
|
|
10725
|
+
name: "wait",
|
|
10726
|
+
description: "Wait until a decision is answered, expires, or is cancelled (or timeoutMs passes) and return its record",
|
|
10727
|
+
inputSchema: {
|
|
10728
|
+
type: "object",
|
|
10729
|
+
required: ["id"],
|
|
10730
|
+
additionalProperties: false,
|
|
10731
|
+
properties: {
|
|
10732
|
+
id: idSchema,
|
|
10733
|
+
timeoutMs: { type: "integer", minimum: 0, maximum: MAX_DECISION_DEADLINE_MS }
|
|
10734
|
+
}
|
|
10735
|
+
},
|
|
10736
|
+
risk: "read",
|
|
10737
|
+
namespace: "coordination"
|
|
10738
|
+
},
|
|
10739
|
+
{
|
|
10740
|
+
name: "list",
|
|
10741
|
+
description: "List decisions newest first, optionally by status and current holder",
|
|
10742
|
+
inputSchema: {
|
|
10743
|
+
type: "object",
|
|
10744
|
+
additionalProperties: false,
|
|
10745
|
+
properties: {
|
|
10746
|
+
status: { type: "string", enum: ["open", "answered", "expired", "cancelled"] },
|
|
10747
|
+
holder: holderSchema,
|
|
10748
|
+
limit: { type: "integer", minimum: 1, maximum: 200 }
|
|
10749
|
+
}
|
|
10750
|
+
},
|
|
10751
|
+
risk: "read",
|
|
10752
|
+
namespace: "coordination",
|
|
10753
|
+
effect: { kind: "none", resources: resource3, ordering: "commutative" }
|
|
10754
|
+
},
|
|
10755
|
+
{
|
|
10756
|
+
name: "answer",
|
|
10757
|
+
description: 'Answer an open decision held by this participant (root or supervisor:<id>); never decisions held by "user"',
|
|
10758
|
+
inputSchema: {
|
|
10759
|
+
type: "object",
|
|
10760
|
+
required: ["id"],
|
|
10761
|
+
additionalProperties: false,
|
|
10762
|
+
properties: {
|
|
10763
|
+
id: idSchema,
|
|
10764
|
+
optionId: { type: "string", maxLength: 64 },
|
|
10765
|
+
text: { type: "string", maxLength: MAX_DECISION_TEXT_CHARS }
|
|
10766
|
+
}
|
|
10767
|
+
},
|
|
10768
|
+
risk: "agent",
|
|
10769
|
+
namespace: "coordination",
|
|
10770
|
+
effect: { kind: "emission", resources: resource3, ordering: "ordered" }
|
|
10771
|
+
},
|
|
10772
|
+
{
|
|
10773
|
+
name: "escalate",
|
|
10774
|
+
description: "Pass an open decision this participant holds to the next holder in its escalation chain now",
|
|
10775
|
+
inputSchema: {
|
|
10776
|
+
type: "object",
|
|
10777
|
+
required: ["id"],
|
|
10778
|
+
additionalProperties: false,
|
|
10779
|
+
properties: {
|
|
10780
|
+
id: idSchema,
|
|
10781
|
+
reason: { type: "string", maxLength: MAX_ESCALATION_REASON_CHARS }
|
|
10782
|
+
}
|
|
10783
|
+
},
|
|
10784
|
+
risk: "agent",
|
|
10785
|
+
namespace: "coordination",
|
|
10786
|
+
effect: { kind: "emission", resources: resource3, ordering: "ordered" }
|
|
10787
|
+
},
|
|
10788
|
+
{
|
|
10789
|
+
name: "cancel",
|
|
10790
|
+
description: "Cancel an open decision this participant raised or holds",
|
|
10791
|
+
inputSchema: {
|
|
10792
|
+
type: "object",
|
|
10793
|
+
required: ["id"],
|
|
10794
|
+
additionalProperties: false,
|
|
10795
|
+
properties: { id: idSchema }
|
|
10796
|
+
},
|
|
10797
|
+
risk: "agent",
|
|
10798
|
+
namespace: "coordination",
|
|
10799
|
+
effect: { kind: "emission", resources: resource3, ordering: "ordered" }
|
|
10800
|
+
}
|
|
10801
|
+
];
|
|
10802
|
+
var normalizeDecisionsArgs = actionArgNormalizer(() => descriptors8);
|
|
10803
|
+
var MAX_TRACKED_CALLS = 64;
|
|
10804
|
+
var DecisionsProvider = class {
|
|
10805
|
+
constructor(store, identity) {
|
|
10806
|
+
this.store = store;
|
|
10807
|
+
this.identity = identity;
|
|
10808
|
+
}
|
|
10809
|
+
name = "decisions";
|
|
10810
|
+
description = "Durable pending decisions answered by a human or an authorized holder";
|
|
10811
|
+
// fabric_exec call id -> decisions raised inside that call (self-answer guard).
|
|
10812
|
+
#raisedInCall = /* @__PURE__ */ new Map();
|
|
10813
|
+
async list(request) {
|
|
10814
|
+
const query = request.query?.toLowerCase();
|
|
10815
|
+
return descriptors8.filter((action) => !query || `${action.name} ${action.description}`.toLowerCase().includes(query));
|
|
10816
|
+
}
|
|
10817
|
+
async describe(name) {
|
|
10818
|
+
return descriptors8.find((action) => action.name === name);
|
|
10819
|
+
}
|
|
10820
|
+
prepareArguments(name, args) {
|
|
10821
|
+
return normalizeDecisionsArgs(name, args);
|
|
10822
|
+
}
|
|
10823
|
+
async invoke(name, args, context) {
|
|
10824
|
+
const descriptor = descriptors8.find((action) => action.name === name);
|
|
10825
|
+
if (!descriptor) throw new Error(`Unknown decisions action: ${name}`);
|
|
10826
|
+
const error = validationMessage(descriptor.inputSchema, args);
|
|
10827
|
+
if (error) throw new Error(`Invalid decisions.${name} arguments: ${error}`);
|
|
10828
|
+
switch (name) {
|
|
10829
|
+
case "raise": {
|
|
10830
|
+
const runId = process.env.PI_FABRIC_PARENT_RUN?.trim();
|
|
10831
|
+
const record = await this.store.raise(args, runId ? { runId } : {});
|
|
10832
|
+
this.#trackRaised(context.parentToolCallId, record.id);
|
|
10833
|
+
context.activity?.({ type: "progress", message: `Decision raised: ${record.title}` });
|
|
10834
|
+
return { id: record.id };
|
|
10835
|
+
}
|
|
10836
|
+
case "wait":
|
|
10837
|
+
return this.store.wait(assertDecisionId(args.id), {
|
|
10838
|
+
...typeof args.timeoutMs === "number" ? { timeoutMs: args.timeoutMs } : {},
|
|
10839
|
+
...context.signal ? { signal: context.signal } : {}
|
|
10840
|
+
});
|
|
10841
|
+
case "list":
|
|
10842
|
+
return this.store.list({
|
|
10843
|
+
...typeof args.status === "string" ? { status: args.status } : {},
|
|
10844
|
+
...typeof args.holder === "string" ? { holder: args.holder } : {},
|
|
10845
|
+
...typeof args.limit === "number" ? { limit: args.limit } : {}
|
|
10846
|
+
});
|
|
10847
|
+
case "answer": {
|
|
10848
|
+
const id2 = assertDecisionId(args.id);
|
|
10849
|
+
await this.#requireOpen(id2);
|
|
10850
|
+
this.#assertNotRaisedHere(id2, context, "answer");
|
|
10851
|
+
return this.store.answer(id2, args, { answeredBy: this.identity.id, via: "program" }, (record) => this.#assertHolder(record));
|
|
10852
|
+
}
|
|
10853
|
+
case "escalate": {
|
|
10854
|
+
const id2 = assertDecisionId(args.id);
|
|
10855
|
+
await this.#requireOpen(id2);
|
|
10856
|
+
this.#assertNotRaisedHere(id2, context, "escalate");
|
|
10857
|
+
return this.store.escalate(id2, args, { escalatedBy: this.identity.id }, (record) => this.#assertHolder(record));
|
|
10858
|
+
}
|
|
10859
|
+
case "cancel": {
|
|
10860
|
+
const id2 = assertDecisionId(args.id);
|
|
10861
|
+
await this.#requireOpen(id2);
|
|
10862
|
+
return this.store.cancel(id2, { answeredBy: this.identity.id, via: "program" }, (record) => {
|
|
10863
|
+
if (record.raisedBy.participantId !== this.identity.id) this.#assertHolder(record);
|
|
10864
|
+
});
|
|
10865
|
+
}
|
|
10866
|
+
default:
|
|
10867
|
+
throw new Error(`Unknown decisions action: ${name}`);
|
|
10868
|
+
}
|
|
10869
|
+
}
|
|
10870
|
+
async #requireOpen(id2) {
|
|
10871
|
+
const record = await this.store.get(id2);
|
|
10872
|
+
if (!record) throw new Error(`Unknown decision: ${id2}`);
|
|
10873
|
+
if (record.status !== "open") throw new Error(`Decision ${id2} is ${record.status}, not open`);
|
|
10874
|
+
return record;
|
|
10875
|
+
}
|
|
10876
|
+
#assertNotRaisedHere(id2, context, verb) {
|
|
10877
|
+
if (this.#raisedInCall.get(context.parentToolCallId)?.has(id2)) {
|
|
10878
|
+
throw new Error(`Decision ${id2} was raised by this same program; it cannot ${verb} it itself`);
|
|
10879
|
+
}
|
|
10880
|
+
}
|
|
10881
|
+
#assertHolder(record) {
|
|
10882
|
+
if (record.holder === "user") {
|
|
10883
|
+
throw new Error(`Decision ${record.id} is held by the user; answer it with /fabric decisions or the pi-fabric decisions CLI`);
|
|
10884
|
+
}
|
|
10885
|
+
if (record.holder === "root" && this.identity.kind === "main") return;
|
|
10886
|
+
if (record.holder === `supervisor:${this.identity.id}`) return;
|
|
10887
|
+
throw new Error(`Decision ${record.id} is held by ${record.holder}, not this participant`);
|
|
10888
|
+
}
|
|
10889
|
+
#trackRaised(callId, id2) {
|
|
10890
|
+
let raised = this.#raisedInCall.get(callId);
|
|
10891
|
+
if (!raised) {
|
|
10892
|
+
if (this.#raisedInCall.size >= MAX_TRACKED_CALLS) {
|
|
10893
|
+
this.#raisedInCall.delete(this.#raisedInCall.keys().next().value);
|
|
10894
|
+
}
|
|
10895
|
+
raised = /* @__PURE__ */ new Set();
|
|
10896
|
+
this.#raisedInCall.set(callId, raised);
|
|
10897
|
+
}
|
|
10898
|
+
raised.add(id2);
|
|
10899
|
+
}
|
|
10900
|
+
};
|
|
10901
|
+
|
|
9206
10902
|
// src/providers/pi-tools-provider.ts
|
|
9207
10903
|
import { readFileSync } from "node:fs";
|
|
9208
10904
|
import path9 from "node:path";
|
|
@@ -9535,6 +11231,16 @@ var closedPiInputSchema = (name, source) => {
|
|
|
9535
11231
|
type: "boolean",
|
|
9536
11232
|
description: "Run as a durable background task owned by jev-fabric (the user's install or the bundled package). It keeps running if Pi exits and reattaches to this session on resume; other harnesses sharing the store can see it. Implies background. Use for dev servers and long jobs that must outlive the session; stop explicitly with tasks.stop."
|
|
9537
11233
|
};
|
|
11234
|
+
properties.notify = {
|
|
11235
|
+
type: "object",
|
|
11236
|
+
description: "With durable:true: when the command exits, publish {kind (default task.completed), data:{taskId, exitCode, description?}} to this mesh topic, even if no session is attached.",
|
|
11237
|
+
properties: {
|
|
11238
|
+
topic: { type: "string", minLength: 1, maxLength: 128 },
|
|
11239
|
+
kind: { type: "string", minLength: 1, maxLength: 128 }
|
|
11240
|
+
},
|
|
11241
|
+
required: ["topic"],
|
|
11242
|
+
additionalProperties: false
|
|
11243
|
+
};
|
|
9538
11244
|
}
|
|
9539
11245
|
if (name === "edit") {
|
|
9540
11246
|
properties.all = { type: "boolean", description: "Apply every replacement to all matching occurrences." };
|
|
@@ -9550,6 +11256,18 @@ var closedPiInputSchema = (name, source) => {
|
|
|
9550
11256
|
}
|
|
9551
11257
|
return { ...schema, properties, additionalProperties: false };
|
|
9552
11258
|
};
|
|
11259
|
+
var NOTIFY_FIELD_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._:/-]{0,127}$/;
|
|
11260
|
+
var parseDurableNotify = (value) => {
|
|
11261
|
+
if (value === void 0) return void 0;
|
|
11262
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("notify must be an object");
|
|
11263
|
+
const input = value;
|
|
11264
|
+
if (Object.keys(input).some((key) => key !== "topic" && key !== "kind")) throw new Error("Unknown notify option");
|
|
11265
|
+
if (typeof input.topic !== "string" || !NOTIFY_FIELD_PATTERN.test(input.topic)) throw new Error("notify.topic must be a valid mesh topic");
|
|
11266
|
+
if (input.kind !== void 0 && (typeof input.kind !== "string" || !NOTIFY_FIELD_PATTERN.test(input.kind))) {
|
|
11267
|
+
throw new Error("notify.kind must be a mesh event kind of at most 128 characters");
|
|
11268
|
+
}
|
|
11269
|
+
return { topic: input.topic, ...typeof input.kind === "string" ? { kind: input.kind } : {} };
|
|
11270
|
+
};
|
|
9553
11271
|
var MAX_RENDERER_ARGUMENT_CHARS = 2e5;
|
|
9554
11272
|
var MAX_REPLACE_ALL_FILE_CHARS = 2e6;
|
|
9555
11273
|
var DEFAULT_HOST_CAPABILITIES = {
|
|
@@ -9693,10 +11411,10 @@ var PiToolsProvider = class {
|
|
|
9693
11411
|
}
|
|
9694
11412
|
async list(request, _context) {
|
|
9695
11413
|
const query = request.query?.toLowerCase();
|
|
9696
|
-
const
|
|
11414
|
+
const descriptors13 = await Promise.all(
|
|
9697
11415
|
PI_CORE_TOOL_NAMES.map((name) => this.describe(name, _context))
|
|
9698
11416
|
);
|
|
9699
|
-
return
|
|
11417
|
+
return descriptors13.filter((descriptor) => descriptor !== void 0).filter(
|
|
9700
11418
|
(descriptor) => query ? `${descriptor.name} ${descriptor.description}`.toLowerCase().includes(query) : true
|
|
9701
11419
|
);
|
|
9702
11420
|
}
|
|
@@ -9805,7 +11523,7 @@ var PiToolsProvider = class {
|
|
|
9805
11523
|
const value = this.#getShellHangMs?.() ?? DEFAULT_SHELL_HANG_MS;
|
|
9806
11524
|
return Number.isFinite(value) ? Math.max(0, Math.floor(value)) : DEFAULT_SHELL_HANG_MS;
|
|
9807
11525
|
}
|
|
9808
|
-
async #trackedShellDefinition(name, args, job, middleware) {
|
|
11526
|
+
async #trackedShellDefinition(name, args, job, middleware, notify) {
|
|
9809
11527
|
const cwd = typeof args[PI_BASH_CWD_KEY] === "string" ? args[PI_BASH_CWD_KEY] : this.#cwd;
|
|
9810
11528
|
if (name === "bash") {
|
|
9811
11529
|
const options = middleware?.options;
|
|
@@ -9815,7 +11533,8 @@ var PiToolsProvider = class {
|
|
|
9815
11533
|
filtered: middleware !== void 0,
|
|
9816
11534
|
command: typeof args.command === "string" ? args.command : "",
|
|
9817
11535
|
cwd,
|
|
9818
|
-
ownerId: job.options.ownerId
|
|
11536
|
+
ownerId: job.options.ownerId,
|
|
11537
|
+
notify
|
|
9819
11538
|
}) : createLocalBashOperations(options?.shellPath !== void 0 ? { shellPath: options.shellPath } : void 0);
|
|
9820
11539
|
const operations = middleware ? middleware.wrapOperations(local) : local;
|
|
9821
11540
|
if (!operations || typeof operations.exec !== "function") {
|
|
@@ -9862,8 +11581,10 @@ var PiToolsProvider = class {
|
|
|
9862
11581
|
if (args.background === false) throw new Error("durable runs in the background; omit background:false");
|
|
9863
11582
|
if (process.platform === "win32" || !this.#shellJobs.durable) throw new Error("Durable shell tasks need jev-fabric on macOS or Linux in a Fabric full-code session");
|
|
9864
11583
|
}
|
|
11584
|
+
const notify = parseDurableNotify(args.notify);
|
|
11585
|
+
if (notify && !durable) throw new Error("notify requires durable:true");
|
|
9865
11586
|
const background = args.background === true || monitor !== void 0 || durable;
|
|
9866
|
-
const { background: _background, monitor: _monitor, description: _description, durable: _durable, ...executeArgs } = args;
|
|
11587
|
+
const { background: _background, monitor: _monitor, description: _description, durable: _durable, notify: _notify, ...executeArgs } = args;
|
|
9867
11588
|
const job = this.#shellJobs.begin(name, command, {
|
|
9868
11589
|
...durable ? { durable: { home: this.#shellJobs.durable.home } } : {},
|
|
9869
11590
|
cwd: typeof args[PI_BASH_CWD_KEY] === "string" ? args[PI_BASH_CWD_KEY] : this.#cwd,
|
|
@@ -9873,7 +11594,7 @@ var PiToolsProvider = class {
|
|
|
9873
11594
|
});
|
|
9874
11595
|
let tool;
|
|
9875
11596
|
try {
|
|
9876
|
-
tool = await this.#trackedShellDefinition(name, executeArgs, job, middleware);
|
|
11597
|
+
tool = await this.#trackedShellDefinition(name, executeArgs, job, middleware, notify);
|
|
9877
11598
|
} catch (error) {
|
|
9878
11599
|
await job.finish(null);
|
|
9879
11600
|
throw error;
|
|
@@ -9932,18 +11653,36 @@ var PiToolsProvider = class {
|
|
|
9932
11653
|
async invoke(actionName, args, context) {
|
|
9933
11654
|
const name = actionName;
|
|
9934
11655
|
this.#assertAllowed(name);
|
|
11656
|
+
if (process.env.PI_FABRIC_WRITE_POLICY) {
|
|
11657
|
+
const guard = await import("./agents/write-guard.js");
|
|
11658
|
+
const policy = guard.readWritePolicy();
|
|
11659
|
+
const denial = policy && guard.writePolicyDenial(policy, name, args, context.extensionContext?.cwd || this.#cwd);
|
|
11660
|
+
if (denial) throw new Error(denial);
|
|
11661
|
+
}
|
|
9935
11662
|
if (!this.#requireCapturedOverrides && !this.#tools[name]) throw new Error(`Unknown Pi tool: ${actionName}`);
|
|
9936
|
-
|
|
11663
|
+
const middleware = this.#bashMiddleware(name);
|
|
11664
|
+
const runner = this.#catalog?.runner;
|
|
11665
|
+
if (this.#catalog && !runner && !this.#requireCapturedOverrides && riskForTool(name) !== "read") {
|
|
11666
|
+
throw new Error(
|
|
11667
|
+
`Pi tool ${name} is unavailable until extension tool hooks initialize; retry once tools are ready`
|
|
11668
|
+
);
|
|
11669
|
+
}
|
|
11670
|
+
let preflightEmitted = false;
|
|
11671
|
+
if (name === "bash" && !this.#requireCapturedOverrides && !this.#catalog?.get(name) && typeof args.command === "string" && parseGitWorktreeAdd(args.command) !== void 0) {
|
|
11672
|
+
if (runner) {
|
|
11673
|
+
await this.#emitToolCallPreflight(name, args, context, runner);
|
|
11674
|
+
preflightEmitted = true;
|
|
11675
|
+
}
|
|
9937
11676
|
const intercepted = await tryExecuteGitWorktreeAdd(args, this.#cwd);
|
|
9938
11677
|
if (intercepted) {
|
|
9939
11678
|
this.#attachPreview(name, intercepted, args, context);
|
|
9940
11679
|
return this.#normalizeResult(name, intercepted, args);
|
|
9941
11680
|
}
|
|
9942
11681
|
}
|
|
9943
|
-
const middleware = this.#bashMiddleware(name);
|
|
9944
11682
|
if (this.#catalog?.get(name) && !middleware) {
|
|
9945
11683
|
if (isPiShellToolName(name) && args.monitor !== void 0) throw new Error("Shell monitors are unavailable for opaque shell overrides; a Fabric-compatible middleware adapter is required");
|
|
9946
11684
|
if (isPiShellToolName(name) && args.durable === true) throw new Error("Durable shell tasks are unavailable for opaque shell overrides; a Fabric-compatible middleware adapter is required");
|
|
11685
|
+
if (isPiShellToolName(name) && args.notify !== void 0) throw new Error("notify requires durable:true");
|
|
9947
11686
|
const { durable: _durable, ...overrideArgs } = args;
|
|
9948
11687
|
const result = await this.#capturedTools.invoke(name, overrideArgs, context);
|
|
9949
11688
|
this.#attachReadMedia(name, result, context);
|
|
@@ -9952,7 +11691,6 @@ var PiToolsProvider = class {
|
|
|
9952
11691
|
return this.#normalizeResult(name, result, args);
|
|
9953
11692
|
}
|
|
9954
11693
|
const tool = this.#definitionFor(name, args);
|
|
9955
|
-
const runner = this.#catalog?.runner;
|
|
9956
11694
|
if (!runner) {
|
|
9957
11695
|
const result = await this.#runExecute(
|
|
9958
11696
|
name,
|
|
@@ -9971,7 +11709,22 @@ var PiToolsProvider = class {
|
|
|
9971
11709
|
this.#attachPreview(name, result, args, context);
|
|
9972
11710
|
return this.#normalizeResult(name, result, args);
|
|
9973
11711
|
}
|
|
9974
|
-
return this.#invokeWithEvents(name, tool, args, context, runner, middleware);
|
|
11712
|
+
return this.#invokeWithEvents(name, tool, args, context, runner, middleware, preflightEmitted);
|
|
11713
|
+
}
|
|
11714
|
+
// Emit the tool_call preflight for a nested pi.* call and enforce a block.
|
|
11715
|
+
// Shared by #invokeWithEvents and the git-worktree-add intercept so both obey
|
|
11716
|
+
// the same extension policy through one code path (no duplicated enforcement).
|
|
11717
|
+
async #emitToolCallPreflight(name, args, context, runner) {
|
|
11718
|
+
const preflight = await runAbortable(context.signal, () => runner.emitToolCall({
|
|
11719
|
+
type: "tool_call",
|
|
11720
|
+
toolName: name,
|
|
11721
|
+
toolCallId: context.nestedToolCallId,
|
|
11722
|
+
input: args
|
|
11723
|
+
}));
|
|
11724
|
+
context.updateArguments?.(args);
|
|
11725
|
+
if (preflight?.block) {
|
|
11726
|
+
throw new Error(preflight.reason || `Pi tool ${name} was blocked`);
|
|
11727
|
+
}
|
|
9975
11728
|
}
|
|
9976
11729
|
// Replay the agent-core tool-execution lifecycle for a nested pi.* call, so
|
|
9977
11730
|
// extensions that hook tool_call / tool_result / tool_execution_* see pi
|
|
@@ -9981,7 +11734,7 @@ var PiToolsProvider = class {
|
|
|
9981
11734
|
// tools. tool_result patches (content/details/isError) are applied, so
|
|
9982
11735
|
// extensions like pi-vision-handoff can replace image blocks with text
|
|
9983
11736
|
// descriptions before the result returns to the sandbox.
|
|
9984
|
-
async #invokeWithEvents(name, tool, args, context, runner, middleware) {
|
|
11737
|
+
async #invokeWithEvents(name, tool, args, context, runner, middleware, preflightEmitted = false) {
|
|
9985
11738
|
const toolCallId = context.nestedToolCallId;
|
|
9986
11739
|
await runAbortable(context.signal, () => runner.emit({
|
|
9987
11740
|
type: "tool_execution_start",
|
|
@@ -9995,16 +11748,7 @@ var PiToolsProvider = class {
|
|
|
9995
11748
|
let executionStarted = false;
|
|
9996
11749
|
let updateTail = Promise.resolve();
|
|
9997
11750
|
try {
|
|
9998
|
-
|
|
9999
|
-
type: "tool_call",
|
|
10000
|
-
toolName: name,
|
|
10001
|
-
toolCallId,
|
|
10002
|
-
input: args
|
|
10003
|
-
}));
|
|
10004
|
-
context.updateArguments?.(args);
|
|
10005
|
-
if (preflight?.block) {
|
|
10006
|
-
throw new Error(preflight.reason || `Pi tool ${name} was blocked`);
|
|
10007
|
-
}
|
|
11751
|
+
if (!preflightEmitted) await this.#emitToolCallPreflight(name, args, context, runner);
|
|
10008
11752
|
executionStarted = true;
|
|
10009
11753
|
result = await this.#runExecute(
|
|
10010
11754
|
name,
|
|
@@ -10175,7 +11919,7 @@ var DAY_MS = 24 * 36e5;
|
|
|
10175
11919
|
var id = { type: "string", minLength: 1, maxLength: 128, description: "Session ID from sessions.open (`s-\u2026` for session lifetime) or a durable jev-fabric job ID." };
|
|
10176
11920
|
var idOnly = { type: "object", properties: { id }, required: ["id"], additionalProperties: false };
|
|
10177
11921
|
var waitMs = { type: "integer", minimum: 1, maximum: 3e5, description: "Long-poll ceiling; ready evidence returns at once. Never stops the child." };
|
|
10178
|
-
var
|
|
11922
|
+
var descriptors9 = [
|
|
10179
11923
|
{
|
|
10180
11924
|
name: "open",
|
|
10181
11925
|
description: "Start an interactive child with its stdin kept open, owned by jev-fabric (macOS/Linux). Lifetime session (default) ends with this Pi session, or with the Jev program that opened it; durable: true keeps it in the jev-fabric store after Pi exits. Give argv (literal, no shell) or cmd (run by bash -c). Returns id, lifetime and state. Drive it with write/read; stop it explicitly.",
|
|
@@ -10242,10 +11986,10 @@ var SessionsProvider = class {
|
|
|
10242
11986
|
#closed = false;
|
|
10243
11987
|
async list(request) {
|
|
10244
11988
|
const query = request.query?.toLowerCase();
|
|
10245
|
-
return query ?
|
|
11989
|
+
return query ? descriptors9.filter((d) => `${d.name} ${d.description}`.toLowerCase().includes(query)) : descriptors9;
|
|
10246
11990
|
}
|
|
10247
11991
|
async describe(name) {
|
|
10248
|
-
return
|
|
11992
|
+
return descriptors9.find((d) => d.name === name);
|
|
10249
11993
|
}
|
|
10250
11994
|
#connect() {
|
|
10251
11995
|
if (this.#closed) return Promise.reject(new Error("Sessions provider is closed"));
|
|
@@ -10334,9 +12078,9 @@ var SessionsProvider = class {
|
|
|
10334
12078
|
var pick = (args, keys) => Object.fromEntries(keys.filter((key) => args[key] !== void 0).map((key) => [key, args[key]]));
|
|
10335
12079
|
|
|
10336
12080
|
// src/providers/tasks-provider.ts
|
|
10337
|
-
var
|
|
10338
|
-
var waitSchema = { ...
|
|
10339
|
-
...
|
|
12081
|
+
var idSchema2 = { type: "object", properties: { id: { type: "string", minLength: 1 } }, required: ["id"], additionalProperties: false };
|
|
12082
|
+
var waitSchema = { ...idSchema2, properties: {
|
|
12083
|
+
...idSchema2.properties,
|
|
10340
12084
|
timeoutMs: { type: "integer", minimum: 1, maximum: 3e5, description: "Observation ceiling in milliseconds, not a delay or process deadline. Timeout never cancels the task." }
|
|
10341
12085
|
} };
|
|
10342
12086
|
var watchSchema = { ...waitSchema, properties: {
|
|
@@ -10344,8 +12088,8 @@ var watchSchema = { ...waitSchema, properties: {
|
|
|
10344
12088
|
after: { type: "integer", minimum: 0, maximum: Number.MAX_SAFE_INTEGER, description: "Previously returned nextCursor; default 0. With match it is a byte offset; otherwise a monitor line cursor. Lost positions are disclosed." },
|
|
10345
12089
|
match: { type: "string", minLength: 1, maxLength: 256, description: "Case-sensitive literal chosen at watch time; works on any background task, like jev-fabric watch <id> <literal>. Omit to read a launch-time monitor." }
|
|
10346
12090
|
} };
|
|
10347
|
-
var readSchema = { ...
|
|
10348
|
-
...
|
|
12091
|
+
var readSchema = { ...idSchema2, properties: {
|
|
12092
|
+
...idSchema2.properties,
|
|
10349
12093
|
offset: { type: "integer", minimum: 0, maximum: Number.MAX_SAFE_INTEGER, description: "Byte offset into the task's combined output since launch; default 0. Pass the returned next." },
|
|
10350
12094
|
max: { type: "integer", minimum: 1, maximum: SHELL_READ_MAX_BYTES, description: "Largest page in bytes; default 65536." },
|
|
10351
12095
|
waitMs: { type: "integer", minimum: 1, maximum: 3e5, description: "Long-poll ceiling: return as soon as bytes past offset exist or the task ends. Never stops the task." },
|
|
@@ -10354,13 +12098,13 @@ var readSchema = { ...idSchema, properties: {
|
|
|
10354
12098
|
var WATCH_LINES = 64;
|
|
10355
12099
|
var WATCH_LINE_CHARS = 2048;
|
|
10356
12100
|
var clean = (line) => line.replace(/[\u0000-\u001f\u007f-\u009f]/g, " ").trim();
|
|
10357
|
-
var
|
|
12101
|
+
var descriptors10 = [
|
|
10358
12102
|
{ name: "list", description: "List this session's tracked shell tasks and monitors, with IDs, command, cwd, state, timestamps, and bounded monitor events. No output polling is needed: detached completions notify the owning agent.", inputSchema: { type: "object", properties: {}, additionalProperties: false }, risk: "read", effect: { kind: "none", ordering: "commutative" } },
|
|
10359
|
-
{ name: "get", description: "Inspect one shell task by ID, returning metadata and a bounded output tail. Acknowledges its pending notification after a successful read. Full retained output is at logPath (bounded, not an archive).", inputSchema:
|
|
12103
|
+
{ name: "get", description: "Inspect one shell task by ID, returning metadata and a bounded output tail. Acknowledges its pending notification after a successful read. Full retained output is at logPath (bounded, not an archive).", inputSchema: idSchema2, risk: "read", effect: { kind: "emission", ordering: "ordered" } },
|
|
10360
12104
|
{ name: "wait", description: "Wait without polling for a session-owned shell task to finish, default 30 seconds. Returns task metadata, a bounded output tail and timedOut. Inspect status and exitCode; an exited task is not goal verification. Timeout or cancellation stops only this wait.", inputSchema: waitSchema, risk: "read", effect: { kind: "emission", ordering: "ordered" } },
|
|
10361
12105
|
{ name: "read", description: "Read a background task's combined output by byte offset, in jev-fabric's read record shape: offset, bytes, omittedBytes, text (or base64 data), next, eof, state. Optional waitMs long-polls for new bytes. The live window is 1 MiB; 32 KiB stays readable after exit. Never consumes or stops anything.", inputSchema: readSchema, risk: "read", effect: { kind: "none", ordering: "commutative" } },
|
|
10362
12106
|
{ name: "watch", description: "Wait without polling for matching lines, task exit, or timeout (default 5 seconds). With match (any background task, chosen now): returns complete output lines containing that literal after the byte cursor, omittedBytes, more and nextCursor. Without match: reads a launch-time monitor (pi.bash monitor with delivery ui). Returns reason, up to 64 lines after the cursor, losses (burst/evicted cursor ranges), omitted, more and nextCursor with task metadata; pass nextCursor as after, immediately again while more is true. The latest 256 positions are replayable. No inference, wakeup, renewal or cancellation of the task. Not a lossless RPC stream.", inputSchema: watchSchema, risk: "read", effect: { kind: "none", ordering: "commutative" } },
|
|
10363
|
-
{ name: "stop", description: "Stop one session-owned shell task or monitor by ID using its existing abort controller, not an arbitrary PID. A durable task is stopped through jev-fabric. Cancellation does not wake the owning agent.", inputSchema:
|
|
12107
|
+
{ name: "stop", description: "Stop one session-owned shell task or monitor by ID using its existing abort controller, not an arbitrary PID. A durable task is stopped through jev-fabric. Cancellation does not wake the owning agent.", inputSchema: idSchema2, risk: "execute", effect: { kind: "emission", ordering: "ordered" } },
|
|
10364
12108
|
{ name: "external", description: "List jev-fabric jobs in this session's durable store that no task here tracks, for example dev servers started by another harness or an earlier session. Returns id, state, label and start time; read-only.", inputSchema: { type: "object", properties: {}, additionalProperties: false }, risk: "read", effect: { kind: "none", ordering: "commutative" } },
|
|
10365
12109
|
{ name: "adopt", description: "Attach an existing jev-fabric job from tasks.external to this session as a durable task: its output, completion notification, wait/stop and inspector row. Adopting does not restart or signal the process.", inputSchema: { type: "object", properties: { jobId: { type: "string", minLength: 1, maxLength: 128 }, description: { type: "string", minLength: 1, maxLength: 120 } }, required: ["jobId"], additionalProperties: false }, risk: "read", effect: { kind: "emission", ordering: "ordered" } }
|
|
10366
12110
|
];
|
|
@@ -10373,11 +12117,11 @@ var TasksProvider = class {
|
|
|
10373
12117
|
description = "Session-owned shell orchestration with bounded wait/watch and explicit stop";
|
|
10374
12118
|
async list(request) {
|
|
10375
12119
|
const query = request.query?.toLowerCase();
|
|
10376
|
-
const available = this.jobs.durable ?
|
|
12120
|
+
const available = this.jobs.durable ? descriptors10 : descriptors10.filter((d) => !durableOnly.has(d.name));
|
|
10377
12121
|
return query ? available.filter((d) => `${d.name} ${d.description}`.toLowerCase().includes(query)) : available;
|
|
10378
12122
|
}
|
|
10379
12123
|
async describe(name) {
|
|
10380
|
-
return this.jobs.durable || !durableOnly.has(name) ?
|
|
12124
|
+
return this.jobs.durable || !durableOnly.has(name) ? descriptors10.find((d) => d.name === name) : void 0;
|
|
10381
12125
|
}
|
|
10382
12126
|
async invoke(name, args, context) {
|
|
10383
12127
|
const descriptor = await this.describe(name);
|
|
@@ -10450,6 +12194,113 @@ var TasksProvider = class {
|
|
|
10450
12194
|
}
|
|
10451
12195
|
};
|
|
10452
12196
|
|
|
12197
|
+
// src/state/binding.ts
|
|
12198
|
+
import { execFile } from "node:child_process";
|
|
12199
|
+
var STATE_BINDING_MAX_KEYS = 16;
|
|
12200
|
+
var STATE_BINDING_VALUE_MAX_CHARS = 512;
|
|
12201
|
+
var STATE_BINDING_KEY = /^[a-z][a-zA-Z0-9_.-]{0,63}$/;
|
|
12202
|
+
var GIT_OBJECT_NAME = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
|
|
12203
|
+
var GIT_PROBE_TIMEOUT_MS = 5e3;
|
|
12204
|
+
var GIT_HEAD_MAX_BUFFER = 1024;
|
|
12205
|
+
var GIT_STATUS_MAX_BUFFER = 64 * 1024;
|
|
12206
|
+
var SCHEMA_MODES = /* @__PURE__ */ new Set(["off", "audit", "enforce"]);
|
|
12207
|
+
var normalizeStateBinding = (value) => {
|
|
12208
|
+
if (value === void 0) return void 0;
|
|
12209
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
12210
|
+
throw new Error("state.verify binding must be an object of string values");
|
|
12211
|
+
}
|
|
12212
|
+
const keys = Object.keys(value);
|
|
12213
|
+
if (keys.length > STATE_BINDING_MAX_KEYS) {
|
|
12214
|
+
throw new Error(
|
|
12215
|
+
`state.verify binding has ${keys.length} keys; at most ${STATE_BINDING_MAX_KEYS} are allowed`
|
|
12216
|
+
);
|
|
12217
|
+
}
|
|
12218
|
+
const binding = {};
|
|
12219
|
+
for (const key of keys.sort()) {
|
|
12220
|
+
if (!STATE_BINDING_KEY.test(key)) {
|
|
12221
|
+
throw new Error(
|
|
12222
|
+
`state.verify binding key ${JSON.stringify(key.slice(0, 80))} must match [a-z][a-zA-Z0-9_.-]{0,63}`
|
|
12223
|
+
);
|
|
12224
|
+
}
|
|
12225
|
+
const item = value[key];
|
|
12226
|
+
if (typeof item !== "string") {
|
|
12227
|
+
throw new Error(`state.verify binding.${key} must be a string`);
|
|
12228
|
+
}
|
|
12229
|
+
if (item.length > STATE_BINDING_VALUE_MAX_CHARS) {
|
|
12230
|
+
throw new Error(
|
|
12231
|
+
`state.verify binding.${key} exceeds ${STATE_BINDING_VALUE_MAX_CHARS} characters`
|
|
12232
|
+
);
|
|
12233
|
+
}
|
|
12234
|
+
binding[key] = item;
|
|
12235
|
+
}
|
|
12236
|
+
return keys.length > 0 ? binding : void 0;
|
|
12237
|
+
};
|
|
12238
|
+
var toStateBinding = (value) => {
|
|
12239
|
+
try {
|
|
12240
|
+
return normalizeStateBinding(value);
|
|
12241
|
+
} catch {
|
|
12242
|
+
return void 0;
|
|
12243
|
+
}
|
|
12244
|
+
};
|
|
12245
|
+
var toStateObserved = (value) => {
|
|
12246
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
12247
|
+
const raw = value;
|
|
12248
|
+
const observed = {
|
|
12249
|
+
...typeof raw.commit === "string" && GIT_OBJECT_NAME.test(raw.commit) ? { commit: raw.commit } : {},
|
|
12250
|
+
...typeof raw.dirty === "boolean" ? { dirty: raw.dirty } : {}
|
|
12251
|
+
};
|
|
12252
|
+
return observed.commit !== void 0 || observed.dirty !== void 0 ? observed : void 0;
|
|
12253
|
+
};
|
|
12254
|
+
var toStateRequester = (value) => value === "program" || value === "host" ? value : void 0;
|
|
12255
|
+
var toStateSchemaMode = (value) => typeof value === "string" && SCHEMA_MODES.has(value) ? value : void 0;
|
|
12256
|
+
var runGit = (cwd, args, maxBuffer, signal) => new Promise((resolve2) => {
|
|
12257
|
+
try {
|
|
12258
|
+
execFile(
|
|
12259
|
+
"git",
|
|
12260
|
+
["-C", cwd, ...args],
|
|
12261
|
+
{
|
|
12262
|
+
encoding: "utf8",
|
|
12263
|
+
maxBuffer,
|
|
12264
|
+
timeout: GIT_PROBE_TIMEOUT_MS,
|
|
12265
|
+
windowsHide: true,
|
|
12266
|
+
// Observation must not take the index lock or refresh stat data.
|
|
12267
|
+
env: { ...process.env, GIT_OPTIONAL_LOCKS: "0" },
|
|
12268
|
+
...signal ? { signal } : {}
|
|
12269
|
+
},
|
|
12270
|
+
(error, stdout) => {
|
|
12271
|
+
if (!error) {
|
|
12272
|
+
resolve2({ stdout, overflow: false });
|
|
12273
|
+
return;
|
|
12274
|
+
}
|
|
12275
|
+
const code = error.code;
|
|
12276
|
+
if (code === "ERR_CHILD_PROCESS_STDIO_MAXBUFFER") {
|
|
12277
|
+
resolve2({ stdout, overflow: true });
|
|
12278
|
+
return;
|
|
12279
|
+
}
|
|
12280
|
+
resolve2(void 0);
|
|
12281
|
+
}
|
|
12282
|
+
);
|
|
12283
|
+
} catch {
|
|
12284
|
+
resolve2(void 0);
|
|
12285
|
+
}
|
|
12286
|
+
});
|
|
12287
|
+
var observeGitWorkspace = async (cwd, signal) => {
|
|
12288
|
+
if (signal?.aborted) return void 0;
|
|
12289
|
+
const head = await runGit(cwd, ["rev-parse", "--verify", "--quiet", "HEAD"], GIT_HEAD_MAX_BUFFER, signal);
|
|
12290
|
+
const commit = head && !head.overflow ? head.stdout.trim().toLowerCase() : "";
|
|
12291
|
+
if (!GIT_OBJECT_NAME.test(commit)) return void 0;
|
|
12292
|
+
const status = await runGit(
|
|
12293
|
+
cwd,
|
|
12294
|
+
["status", "--porcelain", "--untracked-files=normal"],
|
|
12295
|
+
GIT_STATUS_MAX_BUFFER,
|
|
12296
|
+
signal
|
|
12297
|
+
);
|
|
12298
|
+
return {
|
|
12299
|
+
commit,
|
|
12300
|
+
...status ? { dirty: status.overflow || status.stdout.trim().length > 0 } : {}
|
|
12301
|
+
};
|
|
12302
|
+
};
|
|
12303
|
+
|
|
10453
12304
|
// src/state/store.ts
|
|
10454
12305
|
import { createHash as createHash4 } from "node:crypto";
|
|
10455
12306
|
import path12 from "node:path";
|
|
@@ -11047,6 +12898,19 @@ var latestTransitionOutcomes = (events) => {
|
|
|
11047
12898
|
}
|
|
11048
12899
|
return latest;
|
|
11049
12900
|
};
|
|
12901
|
+
var toBindingFields = (data) => {
|
|
12902
|
+
const binding = toStateBinding(data.binding);
|
|
12903
|
+
const observed = toStateObserved(data.observed);
|
|
12904
|
+
const requestedBy = toStateRequester(data.requestedBy);
|
|
12905
|
+
const schemaMode = toStateSchemaMode(data.schemaMode);
|
|
12906
|
+
return {
|
|
12907
|
+
...binding !== void 0 ? { binding } : {},
|
|
12908
|
+
...observed !== void 0 ? { observed } : {},
|
|
12909
|
+
...data.issuer === "host" ? { issuer: "host" } : {},
|
|
12910
|
+
...requestedBy !== void 0 ? { requestedBy } : {},
|
|
12911
|
+
...schemaMode !== void 0 ? { schemaMode } : {}
|
|
12912
|
+
};
|
|
12913
|
+
};
|
|
11050
12914
|
var toCertificate = (event, currentHead, latestOutcomes) => {
|
|
11051
12915
|
if (event.kind !== "state.certified") return void 0;
|
|
11052
12916
|
const data = event.data;
|
|
@@ -11068,7 +12932,8 @@ var toCertificate = (event, currentHead, latestOutcomes) => {
|
|
|
11068
12932
|
evidenceDigest: data.evidenceDigest,
|
|
11069
12933
|
resultDigest: data.resultDigest,
|
|
11070
12934
|
ts: typeof data.ts === "number" ? data.ts : event.createdAt,
|
|
11071
|
-
current
|
|
12935
|
+
current,
|
|
12936
|
+
...toBindingFields(data)
|
|
11072
12937
|
};
|
|
11073
12938
|
};
|
|
11074
12939
|
var durableCurrentCertificate = (head, latestOutcomes) => {
|
|
@@ -11085,11 +12950,20 @@ var durableCurrentCertificate = (head, latestOutcomes) => {
|
|
|
11085
12950
|
if (!target2 || certificateHead === null || certificateHead.transitionId !== head.transitionId || (certificateHead.labelDigest ? certificateHead.labelDigest !== digest(head.label) : certificateHead.label !== head.label) || (certificateHead.toDigest ? certificateHead.toDigest !== digest(head.to) : certificateHead.to !== head.to) || certificateHead.version !== head.version || latestOutcome !== void 0 && (latestOutcome.phase !== "certified" || latestOutcome.event.sequence !== certificate.sequence)) {
|
|
11086
12951
|
return void 0;
|
|
11087
12952
|
}
|
|
12953
|
+
const {
|
|
12954
|
+
binding: _binding,
|
|
12955
|
+
observed: _observed,
|
|
12956
|
+
issuer: _issuer,
|
|
12957
|
+
requestedBy: _requestedBy,
|
|
12958
|
+
schemaMode: _schemaMode,
|
|
12959
|
+
...baseCertificate
|
|
12960
|
+
} = certificate;
|
|
11088
12961
|
return {
|
|
11089
|
-
...
|
|
12962
|
+
...baseCertificate,
|
|
11090
12963
|
targets,
|
|
11091
12964
|
head: certificateHead,
|
|
11092
|
-
current: true
|
|
12965
|
+
current: true,
|
|
12966
|
+
...toBindingFields(certificate)
|
|
11093
12967
|
};
|
|
11094
12968
|
};
|
|
11095
12969
|
var toVerifyResult = (claim, command, result) => {
|
|
@@ -11759,6 +13633,16 @@ var StateStore = class {
|
|
|
11759
13633
|
}
|
|
11760
13634
|
}
|
|
11761
13635
|
async verify(input) {
|
|
13636
|
+
const binding = normalizeStateBinding(input.binding);
|
|
13637
|
+
const requestedBy = input.requestedBy ?? "host";
|
|
13638
|
+
const observed = await observeGitWorkspace(input.cwd, input.signal);
|
|
13639
|
+
const bindingFields = {
|
|
13640
|
+
...binding !== void 0 ? { binding } : {},
|
|
13641
|
+
...observed !== void 0 ? { observed } : {},
|
|
13642
|
+
issuer: "host",
|
|
13643
|
+
requestedBy,
|
|
13644
|
+
...input.schemaMode !== void 0 ? { schemaMode: input.schemaMode } : {}
|
|
13645
|
+
};
|
|
11762
13646
|
const verificationHead = this.getHead();
|
|
11763
13647
|
const boundedHeadLabel = verificationHead ? truncateUtf83(verificationHead.label, EVENT_TEXT_MAX_BYTES) : void 0;
|
|
11764
13648
|
const boundedHeadTo = verificationHead ? truncateUtf83(verificationHead.to, EVENT_TEXT_MAX_BYTES) : void 0;
|
|
@@ -11813,13 +13697,28 @@ var StateStore = class {
|
|
|
11813
13697
|
);
|
|
11814
13698
|
const results = [];
|
|
11815
13699
|
const failures = [];
|
|
13700
|
+
const boundCommit = binding?.commit;
|
|
13701
|
+
if (boundCommit !== void 0) {
|
|
13702
|
+
if (observed?.commit === void 0) {
|
|
13703
|
+
failures.push({
|
|
13704
|
+
reason: "binding-unobserved",
|
|
13705
|
+
message: "binding.commit cannot be checked: the verification cwd is not a git work tree with a HEAD commit"
|
|
13706
|
+
});
|
|
13707
|
+
} else if (boundCommit.trim().toLowerCase() !== observed.commit) {
|
|
13708
|
+
failures.push({
|
|
13709
|
+
reason: "binding-mismatch",
|
|
13710
|
+
message: `binding.commit ${truncateUtf83(boundCommit, 128).value} does not match observed HEAD ${observed.commit}`
|
|
13711
|
+
});
|
|
13712
|
+
}
|
|
13713
|
+
}
|
|
13714
|
+
const bindingFailed = failures.length > 0;
|
|
11816
13715
|
if (targets.length === 0) {
|
|
11817
13716
|
failures.push({
|
|
11818
13717
|
reason: "missing-target",
|
|
11819
13718
|
message: input.labels === void 0 ? "No current state transition is available to verify" : "No active state transitions matched the requested labels"
|
|
11820
13719
|
});
|
|
11821
13720
|
}
|
|
11822
|
-
for (const target2 of targets) {
|
|
13721
|
+
for (const target2 of bindingFailed ? [] : targets) {
|
|
11823
13722
|
const evidence = target2.evidence ?? [];
|
|
11824
13723
|
if (evidence.length === 0) {
|
|
11825
13724
|
failures.push({
|
|
@@ -11892,6 +13791,7 @@ var StateStore = class {
|
|
|
11892
13791
|
omittedResultCount: Math.max(0, nonConfirmed.length - EVENT_RESULT_LIMIT),
|
|
11893
13792
|
reasons: index === 0 ? failures.slice(0, EVENT_RESULT_LIMIT).map(toEventFailure) : [],
|
|
11894
13793
|
omittedReasonCount: Math.max(0, failures.length - EVENT_RESULT_LIMIT),
|
|
13794
|
+
...bindingFields,
|
|
11895
13795
|
ts: Date.now()
|
|
11896
13796
|
}
|
|
11897
13797
|
});
|
|
@@ -11913,6 +13813,11 @@ var StateStore = class {
|
|
|
11913
13813
|
const publishError = await publishViolation();
|
|
11914
13814
|
return [revocationError, publishError].filter((value) => value !== void 0).join("; ") || void 0;
|
|
11915
13815
|
};
|
|
13816
|
+
const reportBinding = {
|
|
13817
|
+
...binding !== void 0 ? { binding } : {},
|
|
13818
|
+
...observed !== void 0 ? { observed } : {},
|
|
13819
|
+
requestedBy
|
|
13820
|
+
};
|
|
11916
13821
|
if (!certified) {
|
|
11917
13822
|
const reportingError = await recordViolation();
|
|
11918
13823
|
return {
|
|
@@ -11923,7 +13828,8 @@ var StateStore = class {
|
|
|
11923
13828
|
evidenceDigest,
|
|
11924
13829
|
resultDigest,
|
|
11925
13830
|
failures,
|
|
11926
|
-
...reportingError ? { reportingError } : {}
|
|
13831
|
+
...reportingError ? { reportingError } : {},
|
|
13832
|
+
...reportBinding
|
|
11927
13833
|
};
|
|
11928
13834
|
}
|
|
11929
13835
|
const ts = Date.now();
|
|
@@ -11942,6 +13848,7 @@ var StateStore = class {
|
|
|
11942
13848
|
head: headIdentity,
|
|
11943
13849
|
evidenceDigest,
|
|
11944
13850
|
resultDigest,
|
|
13851
|
+
...bindingFields,
|
|
11945
13852
|
ts
|
|
11946
13853
|
}
|
|
11947
13854
|
});
|
|
@@ -11967,7 +13874,8 @@ var StateStore = class {
|
|
|
11967
13874
|
evidenceDigest,
|
|
11968
13875
|
resultDigest,
|
|
11969
13876
|
failures,
|
|
11970
|
-
certificate: durableCertificate
|
|
13877
|
+
certificate: durableCertificate,
|
|
13878
|
+
...reportBinding
|
|
11971
13879
|
};
|
|
11972
13880
|
} catch (error) {
|
|
11973
13881
|
certified = false;
|
|
@@ -11988,7 +13896,8 @@ var StateStore = class {
|
|
|
11988
13896
|
evidenceDigest,
|
|
11989
13897
|
resultDigest,
|
|
11990
13898
|
failures,
|
|
11991
|
-
reportingError
|
|
13899
|
+
reportingError,
|
|
13900
|
+
...reportBinding
|
|
11992
13901
|
};
|
|
11993
13902
|
}
|
|
11994
13903
|
}
|
|
@@ -12055,7 +13964,13 @@ var verifySchema = {
|
|
|
12055
13964
|
type: "boolean",
|
|
12056
13965
|
description: "Also replay evidence from labels before the last representation transition."
|
|
12057
13966
|
},
|
|
12058
|
-
timeoutMs: { type: "number", minimum: 1, description: "Per-command timeout (default 30s)" }
|
|
13967
|
+
timeoutMs: { type: "number", minimum: 1, description: "Per-command timeout (default 30s)" },
|
|
13968
|
+
binding: {
|
|
13969
|
+
type: "object",
|
|
13970
|
+
maxProperties: STATE_BINDING_MAX_KEYS,
|
|
13971
|
+
additionalProperties: { type: "string", maxLength: STATE_BINDING_VALUE_MAX_CHARS },
|
|
13972
|
+
description: "Claims the certificate is bound to; keys match [a-z][a-zA-Z0-9_.-]{0,63}. Well-known: commit (checked against the observed git HEAD; a mismatch fails closed), specDigest, nodeAddress, criteriaDigest."
|
|
13973
|
+
}
|
|
12059
13974
|
},
|
|
12060
13975
|
additionalProperties: false
|
|
12061
13976
|
};
|
|
@@ -12099,8 +14014,8 @@ var checkGoalSchema = {
|
|
|
12099
14014
|
properties: { timeoutMs: { type: "number", minimum: 1 } },
|
|
12100
14015
|
additionalProperties: false
|
|
12101
14016
|
};
|
|
12102
|
-
var
|
|
12103
|
-
var
|
|
14017
|
+
var emptySchema5 = { type: "object", properties: {}, additionalProperties: false };
|
|
14018
|
+
var descriptors11 = [
|
|
12104
14019
|
{
|
|
12105
14020
|
name: "transition",
|
|
12106
14021
|
description: "Append a labeled, validated state transition and compare-and-swap advance the head",
|
|
@@ -12111,7 +14026,7 @@ var descriptors8 = [
|
|
|
12111
14026
|
{
|
|
12112
14027
|
name: "get",
|
|
12113
14028
|
description: "Return the current state head, goal, compact complexity summary, recent labels, and current/recent certification state",
|
|
12114
|
-
inputSchema:
|
|
14029
|
+
inputSchema: emptySchema5,
|
|
12115
14030
|
risk: "read",
|
|
12116
14031
|
namespace: "state"
|
|
12117
14032
|
},
|
|
@@ -12151,27 +14066,29 @@ var descriptors8 = [
|
|
|
12151
14066
|
namespace: "state"
|
|
12152
14067
|
}
|
|
12153
14068
|
];
|
|
12154
|
-
var normalizeStateArgs = actionArgNormalizer(() =>
|
|
14069
|
+
var normalizeStateArgs = actionArgNormalizer(() => descriptors11);
|
|
12155
14070
|
var StateProvider = class {
|
|
12156
14071
|
name = "state";
|
|
12157
14072
|
description = "Schema-style labeled transition layer: an append-only timeline of validated transitions with a compare-and-swap head and evidence-based certification over mesh storage";
|
|
12158
14073
|
#store;
|
|
12159
14074
|
#identity;
|
|
12160
|
-
|
|
14075
|
+
#schemaMode;
|
|
14076
|
+
constructor(store, identity, options = {}) {
|
|
12161
14077
|
this.#store = new StateStore(store);
|
|
12162
14078
|
this.#identity = identity;
|
|
14079
|
+
this.#schemaMode = options.schemaMode;
|
|
12163
14080
|
}
|
|
12164
14081
|
get state() {
|
|
12165
14082
|
return this.#store;
|
|
12166
14083
|
}
|
|
12167
14084
|
async list(request, _context) {
|
|
12168
14085
|
const query = request.query?.toLowerCase();
|
|
12169
|
-
return query ?
|
|
14086
|
+
return query ? descriptors11.filter(
|
|
12170
14087
|
(descriptor) => `${descriptor.name} ${descriptor.description}`.toLowerCase().includes(query)
|
|
12171
|
-
) :
|
|
14088
|
+
) : descriptors11;
|
|
12172
14089
|
}
|
|
12173
14090
|
async describe(actionName, _context) {
|
|
12174
|
-
return
|
|
14091
|
+
return descriptors11.find((descriptor) => descriptor.name === actionName);
|
|
12175
14092
|
}
|
|
12176
14093
|
prepareArguments(actionName, args) {
|
|
12177
14094
|
return normalizeStateArgs(actionName, args);
|
|
@@ -12240,6 +14157,7 @@ var StateProvider = class {
|
|
|
12240
14157
|
const labels = Array.isArray(args.labels) ? args.labels.filter((item) => typeof item === "string") : void 0;
|
|
12241
14158
|
const timeoutMs = typeof args.timeoutMs === "number" ? args.timeoutMs : void 0;
|
|
12242
14159
|
const includeArchived = args.includeArchived === true;
|
|
14160
|
+
const binding = args.binding;
|
|
12243
14161
|
context.activity?.({
|
|
12244
14162
|
type: "entity",
|
|
12245
14163
|
id: STATE_ENTITY_ID,
|
|
@@ -12252,7 +14170,10 @@ var StateProvider = class {
|
|
|
12252
14170
|
cwd: context.cwd,
|
|
12253
14171
|
...timeoutMs !== void 0 ? { timeoutMs } : {},
|
|
12254
14172
|
...context.signal ? { signal: context.signal } : {},
|
|
12255
|
-
identity: this.#identity
|
|
14173
|
+
identity: this.#identity,
|
|
14174
|
+
...binding !== void 0 ? { binding } : {},
|
|
14175
|
+
requestedBy: "program",
|
|
14176
|
+
...this.#schemaMode !== void 0 ? { schemaMode: this.#schemaMode } : {}
|
|
12256
14177
|
});
|
|
12257
14178
|
context.update(
|
|
12258
14179
|
result.certified ? `State certified: ${result.results.length} evidence command(s) confirmed` : result.reportingError ? `State certification blocked; violation reporting failed: ${result.reportingError}` : "State certification blocked; violation details were published"
|
|
@@ -12392,12 +14313,19 @@ var RuntimeStateBuiltins = class {
|
|
|
12392
14313
|
provider: "state",
|
|
12393
14314
|
description: "Labeled world state over the project mesh",
|
|
12394
14315
|
requires: ["mesh.get"],
|
|
12395
|
-
create: () => new StateProvider(mesh, identity)
|
|
14316
|
+
create: () => new StateProvider(mesh, identity, { schemaMode: config.schema.mode })
|
|
14317
|
+
}));
|
|
14318
|
+
await this.install(createProviderComponent({
|
|
14319
|
+
provider: "decisions",
|
|
14320
|
+
description: "Durable pending decisions over the project mesh",
|
|
14321
|
+
requires: ["mesh.get"],
|
|
14322
|
+
create: () => new DecisionsProvider(new DecisionStore(mesh, identity), identity)
|
|
12396
14323
|
}));
|
|
12397
14324
|
} else {
|
|
12398
14325
|
const meshDisabled = 'disabled by configuration (mesh.enabled=false); set "mesh": { "enabled": true } in .pi/fabric.json or the agent fabric.json';
|
|
12399
14326
|
this.registry.markUnavailable("mesh", `${meshDisabled} to enable mesh.* actions`);
|
|
12400
14327
|
this.registry.markUnavailable("state", `${meshDisabled}; state.* actions run on the mesh`);
|
|
14328
|
+
this.registry.markUnavailable("decisions", `${meshDisabled}; decisions.* actions run on the mesh`);
|
|
12401
14329
|
}
|
|
12402
14330
|
}
|
|
12403
14331
|
async memory(context, config, sessionId) {
|
|
@@ -12437,9 +14365,10 @@ var RuntimeStateBuiltins = class {
|
|
|
12437
14365
|
...config.fullCodeMode && config.capture.enabled && config.schema.mode !== "enforce" ? ["extensions"] : [],
|
|
12438
14366
|
"mcp",
|
|
12439
14367
|
...config.mesh.enabled ? ["mesh", "state"] : ["mesh", "state"].filter((name) => this.managedHost?.has(name)),
|
|
14368
|
+
...config.mesh.enabled && !this.managedHost ? ["decisions"] : [],
|
|
12440
14369
|
"schema",
|
|
12441
14370
|
"compact",
|
|
12442
|
-
...!this.managedHost ? ["cache"] : [],
|
|
14371
|
+
...!this.managedHost ? ["cache", "thinking", "programs"] : [],
|
|
12443
14372
|
"prewalk",
|
|
12444
14373
|
"agents",
|
|
12445
14374
|
...!this.managedHost && config.jev.enabled && config.schema.mode !== "enforce" ? ["jev"] : [],
|
|
@@ -12451,7 +14380,7 @@ var RuntimeStateBuiltins = class {
|
|
|
12451
14380
|
|
|
12452
14381
|
// src/schema/controller.ts
|
|
12453
14382
|
import { spawn as spawn2 } from "node:child_process";
|
|
12454
|
-
import { createHash as createHash6, randomBytes, randomUUID as
|
|
14383
|
+
import { createHash as createHash6, randomBytes, randomUUID as randomUUID7 } from "node:crypto";
|
|
12455
14384
|
import fs10 from "node:fs";
|
|
12456
14385
|
import path14 from "node:path";
|
|
12457
14386
|
|
|
@@ -12713,7 +14642,7 @@ var SchemaController = class {
|
|
|
12713
14642
|
const generation = this.#generation();
|
|
12714
14643
|
const now = Date.now();
|
|
12715
14644
|
const record = {
|
|
12716
|
-
id:
|
|
14645
|
+
id: randomUUID7(),
|
|
12717
14646
|
label: input.label,
|
|
12718
14647
|
summary: input.summary,
|
|
12719
14648
|
evidence: input.evidence,
|
|
@@ -12855,7 +14784,7 @@ var SchemaController = class {
|
|
|
12855
14784
|
}
|
|
12856
14785
|
this.#assertPayloadBound(input);
|
|
12857
14786
|
const release = this.#acquireCommitLock();
|
|
12858
|
-
const transactionId =
|
|
14787
|
+
const transactionId = randomUUID7();
|
|
12859
14788
|
const journalPath = path14.join(this.#journalRoot, `${transactionId}.json`);
|
|
12860
14789
|
let journal;
|
|
12861
14790
|
let consumed = false;
|
|
@@ -13304,13 +15233,20 @@ var SchemaController = class {
|
|
|
13304
15233
|
#publish(kind, data) {
|
|
13305
15234
|
return this.mesh.publish({ topic: SCHEMA_TOPIC, kind, from: this.identity, data });
|
|
13306
15235
|
}
|
|
15236
|
+
// `pid\ncreated\n{identity, heartbeatAt}\n`: the third line is additive and
|
|
15237
|
+
// refreshed while the transaction runs, since postconditions can be slow.
|
|
13307
15238
|
#acquireCommitLock() {
|
|
13308
15239
|
fs10.mkdirSync(this.#journalRoot, { recursive: true, mode: 448 });
|
|
13309
|
-
|
|
13310
|
-
|
|
13311
|
-
fs10.writeFileSync(descriptor, `${process.pid}
|
|
15240
|
+
const lockPath = this.#lockPath;
|
|
15241
|
+
const prefix = `${process.pid}
|
|
13312
15242
|
${Date.now()}
|
|
13313
|
-
|
|
15243
|
+
`;
|
|
15244
|
+
const { identity, heartbeatAt } = ownerHeartbeatFields();
|
|
15245
|
+
const contents = (beat) => `${prefix}${JSON.stringify({ ...identity, heartbeatAt: beat })}
|
|
15246
|
+
`;
|
|
15247
|
+
try {
|
|
15248
|
+
const descriptor = fs10.openSync(lockPath, "wx", 384);
|
|
15249
|
+
fs10.writeFileSync(descriptor, contents(heartbeatAt));
|
|
13314
15250
|
fs10.closeSync(descriptor);
|
|
13315
15251
|
} catch (error) {
|
|
13316
15252
|
if (error instanceof Error && "code" in error && error.code === "EEXIST") {
|
|
@@ -13318,19 +15254,41 @@ ${Date.now()}
|
|
|
13318
15254
|
}
|
|
13319
15255
|
throw error;
|
|
13320
15256
|
}
|
|
13321
|
-
|
|
15257
|
+
const stopHeartbeat = startOwnerHeartbeat((beat) => {
|
|
15258
|
+
if (fs10.readFileSync(lockPath, "utf8").startsWith(prefix)) writeFileAtomic(lockPath, contents(beat));
|
|
15259
|
+
});
|
|
15260
|
+
return () => {
|
|
15261
|
+
stopHeartbeat();
|
|
15262
|
+
fs10.rmSync(lockPath, { force: true });
|
|
15263
|
+
};
|
|
13322
15264
|
}
|
|
13323
15265
|
#recoverJournals() {
|
|
13324
15266
|
fs10.mkdirSync(this.#journalRoot, { recursive: true, mode: 448 });
|
|
13325
15267
|
try {
|
|
13326
|
-
const [pidText] = fs10.readFileSync(this.#lockPath, "utf8").split("\n");
|
|
15268
|
+
const [pidText, , ownerLine] = fs10.readFileSync(this.#lockPath, "utf8").split("\n");
|
|
13327
15269
|
const pid = Number(pidText);
|
|
13328
15270
|
if (Number.isSafeInteger(pid) && pid > 0) {
|
|
15271
|
+
let owner;
|
|
13329
15272
|
try {
|
|
13330
|
-
|
|
13331
|
-
return;
|
|
15273
|
+
owner = ownerLine && ownerLine.length <= 2048 ? JSON.parse(ownerLine) : void 0;
|
|
13332
15274
|
} catch {
|
|
15275
|
+
owner = void 0;
|
|
13333
15276
|
}
|
|
15277
|
+
const liveness = recordOwnerLiveness({
|
|
15278
|
+
pid,
|
|
15279
|
+
identity: owner,
|
|
15280
|
+
...typeof owner === "object" && owner !== null && "heartbeatAt" in owner ? { heartbeatAt: owner.heartbeatAt } : {}
|
|
15281
|
+
}, {
|
|
15282
|
+
legacyAlive: (candidate) => {
|
|
15283
|
+
try {
|
|
15284
|
+
process.kill(candidate, 0);
|
|
15285
|
+
return true;
|
|
15286
|
+
} catch {
|
|
15287
|
+
return false;
|
|
15288
|
+
}
|
|
15289
|
+
}
|
|
15290
|
+
});
|
|
15291
|
+
if (liveness !== "dead") return;
|
|
13334
15292
|
}
|
|
13335
15293
|
fs10.rmSync(this.#lockPath, { force: true });
|
|
13336
15294
|
} catch (error) {
|
|
@@ -13458,7 +15416,7 @@ var operationSchema = {
|
|
|
13458
15416
|
}
|
|
13459
15417
|
]
|
|
13460
15418
|
};
|
|
13461
|
-
var
|
|
15419
|
+
var descriptors12 = [
|
|
13462
15420
|
{
|
|
13463
15421
|
name: "status",
|
|
13464
15422
|
description: "Read the fixed session Schema mode, transaction bounds, generation, and invocation hypotheses",
|
|
@@ -13528,7 +15486,7 @@ var descriptors9 = [
|
|
|
13528
15486
|
namespace: "schema"
|
|
13529
15487
|
}
|
|
13530
15488
|
];
|
|
13531
|
-
var normalizeSchemaArgs = actionArgNormalizer(() =>
|
|
15489
|
+
var normalizeSchemaArgs = actionArgNormalizer(() => descriptors12);
|
|
13532
15490
|
var SchemaProvider = class {
|
|
13533
15491
|
constructor(controller) {
|
|
13534
15492
|
this.controller = controller;
|
|
@@ -13537,12 +15495,12 @@ var SchemaProvider = class {
|
|
|
13537
15495
|
description = "Host-owned, opt-in Schema verification and bounded local-file transaction control plane";
|
|
13538
15496
|
async list(request, _context) {
|
|
13539
15497
|
const query = request.query?.toLowerCase();
|
|
13540
|
-
return query ?
|
|
15498
|
+
return query ? descriptors12.filter(
|
|
13541
15499
|
(descriptor) => `${descriptor.name} ${descriptor.description}`.toLowerCase().includes(query)
|
|
13542
|
-
) :
|
|
15500
|
+
) : descriptors12;
|
|
13543
15501
|
}
|
|
13544
15502
|
async describe(actionName, _context) {
|
|
13545
|
-
return
|
|
15503
|
+
return descriptors12.find((descriptor) => descriptor.name === actionName);
|
|
13546
15504
|
}
|
|
13547
15505
|
prepareArguments(actionName, args) {
|
|
13548
15506
|
return normalizeSchemaArgs(actionName, args);
|
|
@@ -13596,7 +15554,7 @@ var SUMMARY_CHARS = 4e3;
|
|
|
13596
15554
|
var BATCH_CHARS = 16e3;
|
|
13597
15555
|
var IDLE_BATCH_MS = 40;
|
|
13598
15556
|
var oneLine = (text) => text.replace(/[\u0000-\u001f\u007f]/g, " ");
|
|
13599
|
-
var
|
|
15557
|
+
var clip3 = (text, limit) => text.length > limit ? `${text.slice(0, limit)}
|
|
13600
15558
|
[truncated; use agents.wait({id}) for the full result]` : text;
|
|
13601
15559
|
var AgentCompletionInbox = class {
|
|
13602
15560
|
constructor(pi, context) {
|
|
@@ -13663,8 +15621,8 @@ var AgentCompletionInbox = class {
|
|
|
13663
15621
|
status: result.status,
|
|
13664
15622
|
startedAt: result.startedAt,
|
|
13665
15623
|
...result.finishedAt !== void 0 ? { finishedAt: result.finishedAt } : {},
|
|
13666
|
-
text:
|
|
13667
|
-
...result.error !== void 0 ? { error:
|
|
15624
|
+
text: clip3(result.text, SUMMARY_CHARS),
|
|
15625
|
+
...result.error !== void 0 ? { error: clip3(result.error, SUMMARY_CHARS) } : {}
|
|
13668
15626
|
},
|
|
13669
15627
|
delivered
|
|
13670
15628
|
});
|
|
@@ -13711,7 +15669,7 @@ var AgentCompletionInbox = class {
|
|
|
13711
15669
|
const seconds = Math.round(Math.max(0, (result.finishedAt ?? Date.now()) - result.startedAt) / 1e3);
|
|
13712
15670
|
const summary = [result.error, result.text].filter(Boolean).join("\n");
|
|
13713
15671
|
return `Agent ${oneLine(result.name).slice(0, 80)} (${result.id}) ${result.status} after ${seconds}s:
|
|
13714
|
-
${
|
|
15672
|
+
${clip3(summary || "no result", perResult)}`;
|
|
13715
15673
|
})
|
|
13716
15674
|
].join("\n\n");
|
|
13717
15675
|
deliver({
|
|
@@ -14004,6 +15962,16 @@ var DurableShellBridge = class _DurableShellBridge {
|
|
|
14004
15962
|
const settings = this.options.settings();
|
|
14005
15963
|
const home = this.home;
|
|
14006
15964
|
const scriptDirectory = path15.join(this.#stateDirectory, "durable-shell");
|
|
15965
|
+
let wrapScript;
|
|
15966
|
+
if (options.notify) {
|
|
15967
|
+
if (!this.options.notify) throw new Error("pi.bash notify requires an enabled Fabric mesh");
|
|
15968
|
+
wrapScript = await this.options.notify({
|
|
15969
|
+
topic: options.notify.topic,
|
|
15970
|
+
kind: options.notify.kind,
|
|
15971
|
+
taskId: job.id,
|
|
15972
|
+
description: options.label
|
|
15973
|
+
});
|
|
15974
|
+
}
|
|
14007
15975
|
return operations.createJevFabricBashOperations({
|
|
14008
15976
|
cli,
|
|
14009
15977
|
taskId: job.id,
|
|
@@ -14013,6 +15981,7 @@ var DurableShellBridge = class _DurableShellBridge {
|
|
|
14013
15981
|
defaultTimeoutMs: Math.min(settings.timeoutMs, JEV_FABRIC_START_MAX_MS),
|
|
14014
15982
|
maxTimeoutMs: JEV_FABRIC_START_MAX_MS,
|
|
14015
15983
|
label: options.label,
|
|
15984
|
+
wrapScript,
|
|
14016
15985
|
onStarted: async (jobId, scriptPath) => {
|
|
14017
15986
|
if (job.durable) job.durable.jobId = jobId;
|
|
14018
15987
|
if (!options.ownerId) return;
|
|
@@ -14070,9 +16039,9 @@ var DurableShellBridge = class _DurableShellBridge {
|
|
|
14070
16039
|
const existing = this.jobs.list().find((job) => job.durable?.jobId === jobId);
|
|
14071
16040
|
if (existing) return existing;
|
|
14072
16041
|
const status = await cli.status(jobId);
|
|
14073
|
-
const { randomUUID:
|
|
16042
|
+
const { randomUUID: randomUUID8 } = await import("node:crypto");
|
|
14074
16043
|
const record = {
|
|
14075
|
-
taskId:
|
|
16044
|
+
taskId: randomUUID8(),
|
|
14076
16045
|
jobId,
|
|
14077
16046
|
home: this.home,
|
|
14078
16047
|
ownerId: this.options.ownerId ?? "",
|
|
@@ -14159,9 +16128,11 @@ var FabricRuntimeState = class {
|
|
|
14159
16128
|
this.prewalk = options.prewalk ?? new PrewalkController();
|
|
14160
16129
|
this.prewalkDrift = options.prewalkDrift ?? new PrewalkDriftTracker();
|
|
14161
16130
|
this.sessionApprovals = options.sessionApprovals ?? new FabricSessionApprovals();
|
|
16131
|
+
this.thinking = options.thinking ?? new FabricThinkingController(pi, () => this.#config?.thinking?.bounds ?? {});
|
|
14162
16132
|
this.#paths = options.paths;
|
|
14163
16133
|
this.#managedHost = options.managedHost;
|
|
14164
16134
|
this.#entryIdentity = options.entryIdentity;
|
|
16135
|
+
this.#foregroundTools = options.foregroundTools;
|
|
14165
16136
|
}
|
|
14166
16137
|
#registry;
|
|
14167
16138
|
#config;
|
|
@@ -14177,8 +16148,11 @@ var FabricRuntimeState = class {
|
|
|
14177
16148
|
#globalActors;
|
|
14178
16149
|
#mesh;
|
|
14179
16150
|
#identity;
|
|
16151
|
+
/** Durable decisions for headless approvals and routed child dialogs; mesh-enabled sessions only. */
|
|
16152
|
+
#decisions;
|
|
14180
16153
|
#mainAgent;
|
|
14181
16154
|
#participants;
|
|
16155
|
+
#providerParticipants = new ProviderParticipantRegistry();
|
|
14182
16156
|
#control;
|
|
14183
16157
|
#lifecycle;
|
|
14184
16158
|
#residency;
|
|
@@ -14206,9 +16180,11 @@ var FabricRuntimeState = class {
|
|
|
14206
16180
|
prewalk;
|
|
14207
16181
|
prewalkDrift;
|
|
14208
16182
|
sessionApprovals;
|
|
16183
|
+
thinking;
|
|
14209
16184
|
#paths;
|
|
14210
16185
|
#managedHost;
|
|
14211
16186
|
#entryIdentity;
|
|
16187
|
+
#foregroundTools;
|
|
14212
16188
|
#widgetDismissedAt = 0;
|
|
14213
16189
|
#suppressResidentGuidanceSync = false;
|
|
14214
16190
|
get initialized() {
|
|
@@ -14338,7 +16314,29 @@ var FabricRuntimeState = class {
|
|
|
14338
16314
|
agentDir: resolveAgentDir(),
|
|
14339
16315
|
ownerId: context.sessionManager?.getSessionId?.(),
|
|
14340
16316
|
settings: () => (this.#config ?? DEFAULT_FABRIC_CONFIG).executor.jevFabric,
|
|
14341
|
-
middleware: () => readFabricBashMiddleware(this.capturedTools.get("bash")?.definition)
|
|
16317
|
+
middleware: () => readFabricBashMiddleware(this.capturedTools.get("bash")?.definition),
|
|
16318
|
+
notify: async ({ topic, kind, taskId, description }) => {
|
|
16319
|
+
const mesh = this.#mesh;
|
|
16320
|
+
if (!mesh || !this.#identity || !this.#config?.mesh.enabled) {
|
|
16321
|
+
throw new Error("pi.bash notify requires an enabled Fabric mesh");
|
|
16322
|
+
}
|
|
16323
|
+
const { token } = await createMeshGrant(mesh, {
|
|
16324
|
+
topic: assertPublicMeshTopic(topic),
|
|
16325
|
+
kind: kind ?? "task.completed",
|
|
16326
|
+
ttlMs: Math.max(JEV_FABRIC_START_MAX_MS, 7 * 24 * 36e5),
|
|
16327
|
+
uses: 1,
|
|
16328
|
+
createdBy: this.#identity
|
|
16329
|
+
});
|
|
16330
|
+
const argv = meshCliArgv();
|
|
16331
|
+
return (command) => wrapDurableNotifyScript(command, {
|
|
16332
|
+
argv,
|
|
16333
|
+
root: mesh.root,
|
|
16334
|
+
token,
|
|
16335
|
+
kind: kind ?? "task.completed",
|
|
16336
|
+
taskId,
|
|
16337
|
+
...description !== void 0 ? { description } : {}
|
|
16338
|
+
});
|
|
16339
|
+
}
|
|
14342
16340
|
});
|
|
14343
16341
|
}
|
|
14344
16342
|
this.#registry = new ActionRegistry(
|
|
@@ -14433,6 +16431,9 @@ var FabricRuntimeState = class {
|
|
|
14433
16431
|
if (this.#managedHost) {
|
|
14434
16432
|
this.#registry.markUnavailable("jev", "Jev programs are unavailable in managed hosts");
|
|
14435
16433
|
this.#registry.markUnavailable("cache", "Native prompt-cache access is unavailable in managed hosts");
|
|
16434
|
+
this.#registry.markUnavailable("thinking", "Host thinking control is unavailable in managed hosts");
|
|
16435
|
+
this.#registry.markUnavailable("decisions", "Durable decisions are unavailable in managed hosts");
|
|
16436
|
+
this.#registry.markUnavailable("programs", "Saved programs are unavailable in managed hosts");
|
|
14436
16437
|
for (const name of ["agents", "schema", "compact", "memory", "mesh", "state"]) {
|
|
14437
16438
|
if (["agents", "schema", "compact"].includes(name) || this.#managedHost.has(name)) {
|
|
14438
16439
|
await builtins.install(createProviderComponent({
|
|
@@ -14451,7 +16452,21 @@ var FabricRuntimeState = class {
|
|
|
14451
16452
|
await builtins.install(createProviderComponent({
|
|
14452
16453
|
provider: "cache",
|
|
14453
16454
|
description: "Local prompt-cache observations and scoped native warming",
|
|
14454
|
-
create: () => new CacheProvider(this.pi, context, identity.kind === "main")
|
|
16455
|
+
create: () => new CacheProvider(this.pi, context, identity.kind === "main", this.#foregroundTools)
|
|
16456
|
+
}));
|
|
16457
|
+
await builtins.install(createProviderComponent({
|
|
16458
|
+
provider: "thinking",
|
|
16459
|
+
description: "Bounded host-session thinking control",
|
|
16460
|
+
create: () => new ThinkingProvider(this.thinking, sessionId)
|
|
16461
|
+
}));
|
|
16462
|
+
await builtins.install(createProviderComponent({
|
|
16463
|
+
provider: "programs",
|
|
16464
|
+
description: "Content-addressed saved programs",
|
|
16465
|
+
create: () => new ProgramsProvider(
|
|
16466
|
+
new ProgramStore(programsDirectory(context.cwd)),
|
|
16467
|
+
() => (this.#config ?? DEFAULT_FABRIC_CONFIG).executor.kernel,
|
|
16468
|
+
(parentToolCallId) => this.#execution?.nestedProgramRunner(parentToolCallId)
|
|
16469
|
+
)
|
|
14455
16470
|
}));
|
|
14456
16471
|
const fabricSessionId = process.env.PI_FABRIC_SESSION_ID?.trim() || sessionId;
|
|
14457
16472
|
const ownsPersistentActorRegistry = identity.kind === "main" && !enforceSchema && projectTrusted && this.#config.mesh.enabled;
|
|
@@ -14472,20 +16487,22 @@ var FabricRuntimeState = class {
|
|
|
14472
16487
|
this.#config.mesh.maxReadEvents
|
|
14473
16488
|
);
|
|
14474
16489
|
const hostId = identity.kind === "main" ? mainAgentId : `runtime:${sessionId}`;
|
|
16490
|
+
this.#control = new FabricControlPlane(this.#mesh, identity, {
|
|
16491
|
+
enabled: this.#config.mesh.enabled,
|
|
16492
|
+
hostId,
|
|
16493
|
+
pollMs: this.#config.mesh.actorPollMs
|
|
16494
|
+
});
|
|
14475
16495
|
this.#participants = new ParticipantDirectory(this.#mesh, {
|
|
14476
16496
|
enabled: this.#config.mesh.enabled,
|
|
14477
16497
|
hostId,
|
|
14478
16498
|
rootId: mainAgentId,
|
|
14479
16499
|
identity,
|
|
16500
|
+
ownerIncarnation: this.#control.incarnation,
|
|
14480
16501
|
...process.env.PI_FABRIC_OWNER_HOST_ID ? { selfOwnerHostId: process.env.PI_FABRIC_OWNER_HOST_ID } : {},
|
|
14481
16502
|
...process.env.PI_FABRIC_OWNER_IDENTITY_ID ? { selfOwnerIdentityId: process.env.PI_FABRIC_OWNER_IDENTITY_ID } : {}
|
|
14482
16503
|
});
|
|
14483
|
-
this.#control = new FabricControlPlane(this.#mesh, identity, {
|
|
14484
|
-
enabled: this.#config.mesh.enabled,
|
|
14485
|
-
hostId,
|
|
14486
|
-
pollMs: this.#config.mesh.actorPollMs
|
|
14487
|
-
});
|
|
14488
16504
|
await builtins.mesh(this.#config, this.#mesh, identity, this.#participants);
|
|
16505
|
+
this.#decisions = this.#config.mesh.enabled ? new DecisionStore(this.#mesh, identity) : void 0;
|
|
14489
16506
|
this.#schema = new SchemaController(
|
|
14490
16507
|
context.cwd,
|
|
14491
16508
|
this.#config.schema,
|
|
@@ -14506,7 +16523,10 @@ var FabricRuntimeState = class {
|
|
|
14506
16523
|
await builtins.install(createProviderComponent({
|
|
14507
16524
|
provider: "compact",
|
|
14508
16525
|
description: "Host context compaction controller",
|
|
14509
|
-
create: () => new CompactProvider(this.#compact
|
|
16526
|
+
create: () => new CompactProvider(this.#compact, {
|
|
16527
|
+
config: () => (this.#config ?? DEFAULT_FABRIC_CONFIG).compaction,
|
|
16528
|
+
appendEntry: (customType, data) => this.pi.appendEntry(customType, data)
|
|
16529
|
+
})
|
|
14510
16530
|
}));
|
|
14511
16531
|
const agentConfig = enforceSchema ? { ...this.#config.agents, enabled: false } : this.#config.agents;
|
|
14512
16532
|
const modelsConfig = this.#config.models;
|
|
@@ -14567,6 +16587,9 @@ var FabricRuntimeState = class {
|
|
|
14567
16587
|
fabricExtensionPath: this.#paths.extension
|
|
14568
16588
|
} : {},
|
|
14569
16589
|
resolveInheritedSessionPins: () => resolveInheritedSessionPins(context.sessionManager?.getEntries?.() ?? []),
|
|
16590
|
+
thinkingBounds: () => this.#config?.thinking?.bounds ?? {},
|
|
16591
|
+
sessionId: () => context.sessionManager?.getSessionId?.(),
|
|
16592
|
+
executorRuntime: () => this.#config?.schema.mode === "enforce" ? "quickjs" : this.#config?.executor.runtime,
|
|
14570
16593
|
resolveParticipantGuidance: ({ model, runner }) => {
|
|
14571
16594
|
const targetModel = model ?? (runner === "pi" && context.model ? `${context.model.provider}/${context.model.id}` : void 0);
|
|
14572
16595
|
if (!targetModel) return void 0;
|
|
@@ -14600,7 +16623,8 @@ var FabricRuntimeState = class {
|
|
|
14600
16623
|
if (lifecycle) void lifecycle.publish(event).catch(() => void 0);
|
|
14601
16624
|
},
|
|
14602
16625
|
onBackgroundComplete: (result) => completionInbox.enqueue(result),
|
|
14603
|
-
onResultConsumed: (id2) => completionInbox.acknowledge(id2)
|
|
16626
|
+
onResultConsumed: (id2) => completionInbox.acknowledge(id2),
|
|
16627
|
+
onChildQuestion: (request) => routeChildQuestion(request, { context, ...this.#decisions ? { store: this.#decisions } : {} })
|
|
14604
16628
|
});
|
|
14605
16629
|
const canManageActor = (actorId) => {
|
|
14606
16630
|
const participant = this.#participants?.get(actorId);
|
|
@@ -14746,6 +16770,9 @@ ${escapeXmlText(text)}
|
|
|
14746
16770
|
);
|
|
14747
16771
|
this.#agents.subscribeUi(() => this.#participants?.scheduleRefresh());
|
|
14748
16772
|
this.#actors.subscribe(() => this.#participants?.scheduleRefresh());
|
|
16773
|
+
const providerParticipants = this.#providerParticipants;
|
|
16774
|
+
this.#participants.registerSource(() => providerParticipants.records(mainAgentId, hostId, identity.id));
|
|
16775
|
+
providerParticipants.subscribe(() => this.#participants?.scheduleRefresh());
|
|
14749
16776
|
const agentsProvider = new AgentsProvider(
|
|
14750
16777
|
this.#agents,
|
|
14751
16778
|
this.#actors,
|
|
@@ -14759,6 +16786,7 @@ ${escapeXmlText(text)}
|
|
|
14759
16786
|
false,
|
|
14760
16787
|
() => this.#config?.models ?? DEFAULT_FABRIC_CONFIG.models
|
|
14761
16788
|
);
|
|
16789
|
+
agentsProvider.providerParticipants = providerParticipants;
|
|
14762
16790
|
this.#agentsProvider = agentsProvider;
|
|
14763
16791
|
this.#control.start((command, from, signal) => agentsProvider.acceptControl(command, from, signal));
|
|
14764
16792
|
try {
|
|
@@ -14887,6 +16915,17 @@ ${escapeXmlText(advice.message)}
|
|
|
14887
16915
|
this.capturedTools,
|
|
14888
16916
|
this.#managedHost ? (name) => this.#managedHost.ownsProvider(name) : void 0
|
|
14889
16917
|
);
|
|
16918
|
+
this.#execution.setParticipantRegistry(this.#providerParticipants);
|
|
16919
|
+
const events = this.pi.events;
|
|
16920
|
+
if (events) this.#execution.setEventEmitter((channel, data) => events.emit(channel, data));
|
|
16921
|
+
const decisions = this.#decisions;
|
|
16922
|
+
if (decisions) {
|
|
16923
|
+
this.#execution.setHeadlessApproval((action, reason, signal) => requestHeadlessApproval(decisions, action, {
|
|
16924
|
+
...reason ? { reason } : {},
|
|
16925
|
+
...this.#config?.approvals.headlessTimeoutMs ? { timeoutMs: this.#config.approvals.headlessTimeoutMs } : {},
|
|
16926
|
+
...signal ? { signal } : {}
|
|
16927
|
+
}));
|
|
16928
|
+
}
|
|
14890
16929
|
const discovery = {
|
|
14891
16930
|
version: 1,
|
|
14892
16931
|
register: (provider, options) => this.registerExternal(provider, options)
|
|
@@ -14966,7 +17005,8 @@ ${escapeXmlText(advice.message)}
|
|
|
14966
17005
|
() => this.#sessionCapabilityLease?.view,
|
|
14967
17006
|
(ref) => {
|
|
14968
17007
|
const current = this.#config;
|
|
14969
|
-
|
|
17008
|
+
const mode = actionApprovalOverride(current.approvals.actions, ref) ?? current.approvals[ref.startsWith("mcp.") ? "network" : "read"];
|
|
17009
|
+
if (mode !== "allow") return false;
|
|
14970
17010
|
if (ref.startsWith("pi.") && !current.fullCodeMode && current.schema.mode !== "enforce") return false;
|
|
14971
17011
|
return current.schema.mode !== "enforce" || schemaRefAllowedInEnforce(ref);
|
|
14972
17012
|
},
|
|
@@ -15137,7 +17177,7 @@ ${escapeXmlText(advice.message)}
|
|
|
15137
17177
|
name: self.name,
|
|
15138
17178
|
kind: self.kind,
|
|
15139
17179
|
rootId: self.rootId,
|
|
15140
|
-
runner: self.runner,
|
|
17180
|
+
runner: self.runner ?? "pi",
|
|
15141
17181
|
ownerHostId: self.ownerHostId,
|
|
15142
17182
|
ownerIdentityId: self.ownerIdentityId
|
|
15143
17183
|
},
|
|
@@ -15160,6 +17200,23 @@ ${escapeXmlText(advice.message)}
|
|
|
15160
17200
|
this.#externalProviders.set(provider.name, provider);
|
|
15161
17201
|
if (this.#registry) this.#registry.register(provider, options);
|
|
15162
17202
|
}
|
|
17203
|
+
/** Withdraw a direct registration through the same retire/release path a
|
|
17204
|
+
* component lease uses. The host owns the instance, so it is not closed. */
|
|
17205
|
+
withdrawExternal(name, generation) {
|
|
17206
|
+
if (this.#managedHost) return false;
|
|
17207
|
+
const provider = this.#externalProviders.get(name);
|
|
17208
|
+
if (!provider) return false;
|
|
17209
|
+
const registry = this.#registry;
|
|
17210
|
+
const withdrawn = registry?.unregister(name, {
|
|
17211
|
+
provider,
|
|
17212
|
+
...generation !== void 0 ? { generation } : {},
|
|
17213
|
+
keepProviderOpen: true
|
|
17214
|
+
});
|
|
17215
|
+
if (!withdrawn && generation !== void 0) return false;
|
|
17216
|
+
this.#externalProviders.delete(name);
|
|
17217
|
+
this.#providerParticipants.releaseProvider(name);
|
|
17218
|
+
return true;
|
|
17219
|
+
}
|
|
15163
17220
|
registerExternalComponent(component, options = {}) {
|
|
15164
17221
|
if (this.#managedHost) throw new Error("Managed host component registration is disabled");
|
|
15165
17222
|
if (component.name.startsWith(FABRIC_PROVIDER_COMPONENT_PREFIX)) {
|
|
@@ -15181,6 +17238,7 @@ ${escapeXmlText(advice.message)}
|
|
|
15181
17238
|
this.#suppressResidentGuidanceSync = true;
|
|
15182
17239
|
await this.#deactivateRepairs();
|
|
15183
17240
|
clearActiveCompiledSurface();
|
|
17241
|
+
this.#releaseProviderParticipants();
|
|
15184
17242
|
await this.#participants?.quiesce().catch(() => void 0);
|
|
15185
17243
|
this.#stopComponentWatch?.();
|
|
15186
17244
|
this.#stopComponentWatch = void 0;
|
|
@@ -15257,6 +17315,11 @@ ${escapeXmlText(advice.message)}
|
|
|
15257
17315
|
capturedTools: this.capturedTools.list().map((entry) => entry.name)
|
|
15258
17316
|
});
|
|
15259
17317
|
}
|
|
17318
|
+
// Session teardown forgets provider participants; providers own their work.
|
|
17319
|
+
#releaseProviderParticipants() {
|
|
17320
|
+
this.#providerParticipants.releaseAll();
|
|
17321
|
+
this.#providerParticipants = new ProviderParticipantRegistry();
|
|
17322
|
+
}
|
|
15260
17323
|
async #deactivateRepairs() {
|
|
15261
17324
|
const repairs = this.#repairs;
|
|
15262
17325
|
this.#repairs = void 0;
|
|
@@ -15273,6 +17336,7 @@ ${escapeXmlText(advice.message)}
|
|
|
15273
17336
|
await this.shellJobs.close();
|
|
15274
17337
|
await this.#deactivateRepairs();
|
|
15275
17338
|
if (!this.#registry) return;
|
|
17339
|
+
this.#releaseProviderParticipants();
|
|
15276
17340
|
await this.#participants?.quiesce().catch(() => void 0);
|
|
15277
17341
|
this.#stopComponentWatch?.();
|
|
15278
17342
|
this.#stopComponentWatch = void 0;
|