@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
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/audit/projection.ts", "../../src/audit/trace.ts"],
|
|
4
|
+
"sourcesContent": ["import type { FabricTraceJsonValue } from \"./trace.js\";\n\nexport interface FabricAuditProjection {\n value: { [key: string]: FabricTraceJsonValue };\n droppedValues: number;\n}\n\nconst emptyProjection = (args: Record<string, unknown>): FabricAuditProjection => ({\n value: {},\n droppedValues: topLevelKeyCount(args),\n});\n\nconst topLevelKeyCount = (value: Record<string, unknown>): number => {\n try {\n return Object.keys(value).length;\n } catch {\n return 1;\n }\n};\n\nconst finiteNumber = (value: unknown): number | undefined =>\n typeof value === \"number\" && Number.isFinite(value) ? value : undefined;\n\nconst stringValue = (value: unknown): string | undefined =>\n typeof value === \"string\" ? value : undefined;\n\nconst isWindowsDrivePath = (value: string): boolean => {\n if (value.length < 3 || value[1] !== \":\" || (value[2] !== \"\\\\\" && value[2] !== \"/\")) {\n return false;\n }\n const drive = value.charCodeAt(0);\n return (drive >= 65 && drive <= 90) || (drive >= 97 && drive <= 122);\n};\n\nconst localPath = (value: unknown): string | undefined => {\n if (typeof value !== \"string\" || value.includes(\"\\0\")) return undefined;\n if (!isWindowsDrivePath(value)) {\n try {\n // Absolute and network-path URLs are not local file addresses. In\n // particular, never retain URL userinfo or query credentials as a path.\n const absolute = new URL(value);\n if (absolute.protocol) return undefined;\n } catch {\n // Plain relative and absolute filesystem paths are expected to fail URL\n // construction without a base.\n }\n try {\n const based = new URL(value, \"https://fabric.invalid/\");\n if (based.hostname !== \"fabric.invalid\") return undefined;\n } catch {\n return undefined;\n }\n }\n const query = value.indexOf(\"?\");\n const fragment = value.indexOf(\"#\");\n const end = Math.min(\n query < 0 ? value.length : query,\n fragment < 0 ? value.length : fragment,\n );\n return value.slice(0, end) || undefined;\n};\n\nconst copyString = (\n output: Record<string, FabricTraceJsonValue>,\n args: Record<string, unknown>,\n key: string,\n): void => {\n const value = stringValue(args[key]);\n if (value !== undefined) output[key] = value;\n};\n\nconst copyNumber = (\n output: Record<string, FabricTraceJsonValue>,\n args: Record<string, unknown>,\n key: string,\n): void => {\n const value = finiteNumber(args[key]);\n if (value !== undefined) output[key] = value;\n};\n\nconst structuralIdentifier = (value: unknown): string | undefined => {\n if (typeof value !== \"string\" || value.length === 0) return undefined;\n for (let index = 0; index < value.length; index++) {\n const code = value.charCodeAt(index);\n const alphanumeric =\n (code >= 48 && code <= 57) ||\n (code >= 65 && code <= 90) ||\n (code >= 97 && code <= 122);\n if (alphanumeric) continue;\n if (index > 0 && (code === 45 || code === 46 || code === 47 || code === 58 || code === 95)) {\n continue;\n }\n return undefined;\n }\n return value;\n};\n\nconst copyIdentifier = (\n output: Record<string, FabricTraceJsonValue>,\n args: Record<string, unknown>,\n key: string,\n): void => {\n const value = structuralIdentifier(args[key]);\n if (value !== undefined) output[key] = value;\n};\n\nconst copyPath = (\n output: Record<string, FabricTraceJsonValue>,\n args: Record<string, unknown>,\n): void => {\n const value = localPath(args.path);\n if (value !== undefined) output.path = value;\n};\n\nconst projected = (\n args: Record<string, unknown>,\n build: (output: Record<string, FabricTraceJsonValue>) => void,\n): FabricAuditProjection => {\n const value: Record<string, FabricTraceJsonValue> = {};\n try {\n build(value);\n } catch {\n return emptyProjection(args);\n }\n return {\n value,\n droppedValues: Math.max(0, topLevelKeyCount(args) - Object.keys(value).length),\n };\n};\n\nconst idOnlyAgentActions = new Set([\n \"agents.wait\",\n \"agents.join\",\n \"agents.status\",\n \"agents.stop\",\n \"agents.cleanup\",\n \"agents.ask\",\n \"agents.tell\",\n \"agents.steer\",\n \"agents.followUp\",\n \"agents.setSteeringMode\",\n \"agents.setFollowUpMode\",\n \"agents.compact\",\n \"agents.actorStatus\",\n \"agents.setModel\",\n \"agents.setThinking\",\n \"agents.setTools\",\n \"agents.setEvents\",\n \"agents.setDeliveryPolicy\",\n \"agents.clearMessages\",\n \"agents.setInstructions\",\n \"agents.messages\",\n \"agents.remove\",\n \"agents.import\",\n \"agents.export\",\n \"agents.log\",\n]);\n\n/**\n * Projects invocation arguments by exact built-in reference. Unknown,\n * extension, MCP, schema, state, compact, and generic provider calls retain no\n * arguments. This allowlist, rather than secret-looking string matching, is\n * the durable trace's primary confidentiality boundary.\n */\nexport const projectFabricAuditArgs = (\n ref: string,\n args: Record<string, unknown>,\n): FabricAuditProjection => {\n switch (ref) {\n case \"fabric.discovery.providers\":\n case \"fabric.discovery.models\":\n case \"fabric.workflow.progress\":\n return emptyProjection(args);\n case \"fabric.approval.auto\":\n return projected(args, (output) => {\n copyIdentifier(output, args, \"action\");\n copyIdentifier(output, args, \"risk\");\n });\n case \"fabric.discovery.catalog\":\n return projected(args, (output) => {\n copyIdentifier(output, args, \"provider\");\n copyNumber(output, args, \"limit\");\n });\n case \"fabric.discovery.list\":\n return projected(args, (output) => {\n copyIdentifier(output, args, \"provider\");\n copyIdentifier(output, args, \"namespace\");\n copyNumber(output, args, \"limit\");\n });\n case \"fabric.discovery.search\":\n return projected(args, (output) => copyNumber(output, args, \"limit\"));\n case \"fabric.participant.stop\":\n return projected(args, (output) => {\n copyIdentifier(output, args, \"ref\");\n copyIdentifier(output, args, \"reason\");\n });\n case \"fabric.discovery.describe\":\n return projected(args, (output) => copyIdentifier(output, args, \"ref\"));\n case \"fabric.workflow.configure\":\n return projected(args, (output) => copyString(output, args, \"name\"));\n case \"agents.switchModel\":\n return projected(args, (output) => {\n copyIdentifier(output, args, \"model\");\n copyIdentifier(output, args, \"provider\");\n });\n case \"fabric.workflow.phase\":\n return projected(args, (output) => {\n copyString(output, args, \"name\");\n copyIdentifier(output, args, \"id\");\n copyNumber(output, args, \"total\");\n });\n case \"fabric.workflow.item\":\n return projected(args, (output) => {\n copyIdentifier(output, args, \"id\");\n copyIdentifier(output, args, \"status\");\n copyIdentifier(output, args, \"phase\");\n copyIdentifier(output, args, \"kind\");\n copyNumber(output, args, \"total\");\n copyNumber(output, args, \"completed\");\n });\n case \"fabric.workflow.event\":\n return projected(args, (output) => copyIdentifier(output, args, \"level\"));\n case \"fabric.program.run\":\n return projected(args, (output) => {\n copyString(output, args, \"program\");\n copyIdentifier(output, args, \"invokedBy\");\n });\n case \"fabric.workflow.parallel\":\n case \"fabric.workflow.pipeline\":\n return projected(args, (output) => {\n copyIdentifier(output, args, \"kind\");\n copyNumber(output, args, \"itemCount\");\n copyNumber(output, args, \"stageCount\");\n copyNumber(output, args, \"concurrency\");\n });\n case \"pi.read\":\n return projected(args, (output) => {\n copyPath(output, args);\n copyNumber(output, args, \"offset\");\n copyNumber(output, args, \"limit\");\n });\n case \"pi.grep\":\n return projected(args, (output) => {\n copyPath(output, args);\n copyNumber(output, args, \"context\");\n copyNumber(output, args, \"limit\");\n });\n case \"pi.find\":\n case \"pi.ls\":\n return projected(args, (output) => {\n copyPath(output, args);\n copyNumber(output, args, \"limit\");\n });\n case \"pi.edit\":\n case \"pi.write\":\n return projected(args, (output) => copyPath(output, args));\n case \"pi.bash\":\n case \"pi.powershell\":\n return projected(args, (output) => copyString(output, args, \"command\"));\n case \"mesh.publish\":\n return projected(args, (output) => {\n copyString(output, args, \"topic\");\n copyString(output, args, \"to\");\n });\n case \"mesh.read\":\n return projected(args, (output) => {\n copyString(output, args, \"topic\");\n copyString(output, args, \"to\");\n copyNumber(output, args, \"after\");\n copyNumber(output, args, \"limit\");\n });\n case \"mesh.get\":\n case \"mesh.put\":\n case \"mesh.delete\":\n return projected(args, (output) => copyString(output, args, \"key\"));\n case \"mesh.list\":\n return projected(args, (output) => {\n copyString(output, args, \"prefix\");\n copyNumber(output, args, \"limit\");\n });\n default:\n if (idOnlyAgentActions.has(ref)) {\n return projected(args, (output) => copyString(output, args, \"id\"));\n }\n return emptyProjection(args);\n }\n};\n\n/**\n * Results are omitted except for the exact boolean creation outcome emitted by\n * pi.write and Fabric's own auto-approval and owned-work stop outcomes. No\n * provider details or output text accompany them.\n */\nexport const projectFabricAuditResult = (\n ref: string,\n result: unknown,\n): FabricAuditProjection | undefined => {\n if (typeof result !== \"object\" || result === null || Array.isArray(result)) {\n return undefined;\n }\n const record = result as Record<string, unknown>;\n if (ref === \"fabric.approval.auto\") {\n return projected(record, (output) => {\n copyIdentifier(output, record, \"action\");\n copyIdentifier(output, record, \"risk\");\n copyIdentifier(output, record, \"decision\");\n copyIdentifier(output, record, \"model\");\n copyNumber(output, record, \"at\");\n });\n }\n if (ref === \"fabric.participant.stop\") {\n return projected(record, (output) => {\n copyIdentifier(output, record, \"outcome\");\n copyIdentifier(output, record, \"detail\");\n });\n }\n if (ref !== \"pi.write\") return undefined;\n const details =\n typeof record.details === \"object\" && record.details !== null && !Array.isArray(record.details)\n ? (record.details as Record<string, unknown>)\n : undefined;\n if (record.created !== true && details?.created !== true) return undefined;\n return {\n value: { created: true },\n droppedValues: Math.max(0, topLevelKeyCount(record) - 1),\n };\n};\n", "import { isPiShellRef } from \"../core/pi-tools.js\";\nimport { isNormalFormWitness, type NormalFormWitness } from \"../entropy/normal-form.js\";\nimport { projectFabricAuditArgs, projectFabricAuditResult } from \"./projection.js\";\n\nexport const FABRIC_EXECUTION_TRACE_KIND = \"pi-fabric.execution\" as const;\nexport const FABRIC_EXECUTION_TRACE_VERSION = 1 as const;\nexport const FABRIC_EXECUTION_TRACE_MAX_BYTES = 512 * 1024;\n\nconst MAX_IDENTIFIER_BYTES = 1_024;\nconst MAX_PHASE_BYTES = 1_024;\nconst MAX_STRING_BYTES = 16 * 1024;\nconst MAX_ERROR_BYTES = 8 * 1024;\nconst MAX_ARGS_BYTES = 64 * 1024;\nconst MAX_RESULT_BYTES = 64 * 1024;\nconst MAX_DEPTH = 12;\nconst MAX_KEYS = 128;\nconst MAX_ARRAY_ITEMS = 128;\nconst MAX_NODES = 8_192;\nconst MAX_RECORDED_OPERATIONS = 2_048;\nconst MAX_PHASES = 512;\nexport type FabricTraceJsonPrimitive = string | number | boolean | null;\nexport type FabricTraceJsonValue =\n | FabricTraceJsonPrimitive\n | FabricTraceJsonValue[]\n | { [key: string]: FabricTraceJsonValue };\n\nexport type FabricExecutionOutcomeV1 = \"succeeded\" | \"failed\" | \"aborted\" | \"timed_out\";\nexport type FabricExecutionFailureStageV1 =\n | \"resolve\"\n | \"prepare\"\n | \"validate\"\n | \"approve\"\n | \"invoke\"\n | \"guard\";\n\nexport interface FabricExecutionTraceOperationV1 {\n type: \"call\";\n sequence: number;\n ref: string;\n provider?: string;\n action?: string;\n args: { [key: string]: FabricTraceJsonValue };\n outcome: FabricExecutionOutcomeV1;\n normalization?: NormalFormWitness;\n failureStage?: FabricExecutionFailureStageV1;\n error?: string;\n result?: FabricTraceJsonValue;\n resultTruncated?: boolean;\n}\n\nexport interface FabricExecutionTraceCountsV1 {\n droppedValues: number;\n truncatedValues: number;\n redactedValues: number;\n droppedOperations: number;\n}\n\nexport interface FabricExecutionTraceV1 {\n kind: typeof FABRIC_EXECUTION_TRACE_KIND;\n version: typeof FABRIC_EXECUTION_TRACE_VERSION;\n outcome: FabricExecutionOutcomeV1;\n phases: string[];\n operations: FabricExecutionTraceOperationV1[];\n counts: FabricExecutionTraceCountsV1;\n error?: string;\n}\n\ninterface MutableCounts {\n droppedValues: number;\n truncatedValues: number;\n redactedValues: number;\n}\n\ninterface TraceResultMeta {\n resultTruncated?: boolean;\n}\n\ninterface Sanitized<T extends FabricTraceJsonValue> {\n value: T;\n counts: MutableCounts;\n}\n\ninterface MutableOperation {\n type: \"call\";\n sequence: number;\n ref: string;\n projectionRef: string;\n provider?: string;\n action?: string;\n causeSafe?: boolean;\n args: Sanitized<{ [key: string]: FabricTraceJsonValue }>;\n outcome?: FabricExecutionOutcomeV1;\n normalization?: NormalFormWitness;\n failureStage?: FabricExecutionFailureStageV1;\n error?: Sanitized<string>;\n result?: Sanitized<FabricTraceJsonValue>;\n resultTruncated?: boolean;\n droppedResultValues: number;\n}\n\nconst DROP = Symbol(\"drop\");\ntype SanitizedNode = FabricTraceJsonValue | typeof DROP;\n\nconst emptyCounts = (): MutableCounts => ({\n droppedValues: 0,\n truncatedValues: 0,\n redactedValues: 0,\n});\n\nconst byteLength = (value: string): number => Buffer.byteLength(value, \"utf8\");\nconst serializedBytes = (value: unknown): number => byteLength(JSON.stringify(value));\n\nconst truncateUtf8 = (value: string, maxBytes: number): string => {\n if (byteLength(value) <= maxBytes) return value;\n const suffix = \"\u2026[truncated]\";\n const available = Math.max(0, maxBytes - byteLength(suffix));\n let low = 0;\n let high = value.length;\n while (low < high) {\n const middle = Math.ceil((low + high) / 2);\n if (byteLength(value.slice(0, middle)) <= available) low = middle;\n else high = middle - 1;\n }\n return `${value.slice(0, low)}${suffix}`;\n};\n\nconst truncateUtf8Middle = (value: string, maxBytes: number): string => {\n if (byteLength(value) <= maxBytes) return value;\n const marker = \"\\n\u2026[truncated]\\n\";\n const available = Math.max(0, maxBytes - byteLength(marker));\n const headBytes = Math.floor(available / 2);\n const tailBytes = available - headBytes;\n const head = truncateUtf8(value, headBytes + byteLength(\"\u2026[truncated]\"))\n .replace(/\u2026\\[truncated\\]$/, \"\");\n let tailStart = value.length;\n while (tailStart > 0 && byteLength(value.slice(tailStart - 1)) <= tailBytes) tailStart--;\n return `${head}${marker}${value.slice(tailStart)}`;\n};\n\nconst boundedIdentifier = (value: string, maxBytes = MAX_IDENTIFIER_BYTES): string =>\n truncateUtf8(value, maxBytes);\n\nconst normalizedKey = (key: string): string => key.toLowerCase().replaceAll(/[^a-z0-9]/g, \"\");\n\nconst isSensitiveKey = (key: string): boolean => {\n const normalized = normalizedKey(key);\n return [\n \"password\",\n \"passwd\",\n \"secret\",\n \"token\",\n \"accesstoken\",\n \"refreshtoken\",\n \"authorization\",\n \"cookie\",\n \"credential\",\n \"credentials\",\n \"apikey\",\n \"privatekey\",\n \"clientsecret\",\n ].some((sensitive) => normalized === sensitive || normalized.endsWith(sensitive));\n};\n\nconst isMediaKey = (key: string): boolean =>\n [\"media\", \"image\", \"images\", \"audio\", \"video\", \"base64\"].includes(normalizedKey(key));\n\nconst isMediaObject = (value: Record<string, unknown>): boolean => {\n if (value.type === \"image\" || value.type === \"audio\" || value.type === \"video\") return true;\n const mimeType = value.mimeType ?? value.mime_type;\n return (\n typeof mimeType === \"string\" &&\n (mimeType.startsWith(\"image/\") || mimeType.startsWith(\"audio/\") || mimeType.startsWith(\"video/\"))\n );\n};\n\nconst looksLikeBase64 = (value: string): boolean => {\n if (value.startsWith(\"data:\") && value.includes(\";base64,\")) return true;\n if (value.length < 1_024 || value.length % 4 !== 0) return false;\n for (let index = 0; index < value.length; index++) {\n const code = value.charCodeAt(index);\n const valid =\n (code >= 65 && code <= 90) ||\n (code >= 97 && code <= 122) ||\n (code >= 48 && code <= 57) ||\n code === 43 ||\n code === 47 ||\n code === 61 ||\n code === 10 ||\n code === 13;\n if (!valid) return false;\n }\n return true;\n};\n\nconst sanitize = (input: unknown, maxBytes: number): Sanitized<FabricTraceJsonValue> => {\n const counts = emptyCounts();\n const ancestors = new Set<object>();\n let nodes = 0;\n\n const visit = (value: unknown, depth: number, key?: string): SanitizedNode => {\n nodes++;\n if (nodes > MAX_NODES) {\n counts.droppedValues++;\n return DROP;\n }\n if (key !== undefined && isSensitiveKey(key)) {\n counts.redactedValues++;\n return \"[REDACTED]\";\n }\n if (key !== undefined && isMediaKey(key)) {\n counts.droppedValues++;\n return DROP;\n }\n if (value === null || typeof value === \"boolean\") return value;\n if (typeof value === \"number\") {\n if (Number.isFinite(value)) return value;\n counts.truncatedValues++;\n return `[non-finite:${String(value)}]`;\n }\n if (typeof value === \"string\") {\n if (looksLikeBase64(value)) {\n counts.droppedValues++;\n return \"[OMITTED_BASE64]\";\n }\n const bounded = truncateUtf8(value, MAX_STRING_BYTES);\n if (bounded !== value) counts.truncatedValues++;\n return bounded;\n }\n if (typeof value === \"bigint\") {\n counts.truncatedValues++;\n return `${String(value)}n`;\n }\n if (typeof value === \"undefined\" || typeof value === \"function\" || typeof value === \"symbol\") {\n counts.droppedValues++;\n return DROP;\n }\n if (typeof value !== \"object\") {\n counts.droppedValues++;\n return DROP;\n }\n if (depth >= MAX_DEPTH) {\n counts.truncatedValues++;\n return \"[MAX_DEPTH]\";\n }\n if (ancestors.has(value)) {\n counts.droppedValues++;\n return \"[CIRCULAR]\";\n }\n const record = value as Record<string, unknown>;\n if (!Array.isArray(value) && isMediaObject(record)) {\n counts.droppedValues++;\n return \"[OMITTED_MEDIA]\";\n }\n ancestors.add(value);\n if (Array.isArray(value)) {\n const output: FabricTraceJsonValue[] = [];\n const limit = Math.min(value.length, MAX_ARRAY_ITEMS);\n for (let index = 0; index < limit; index++) {\n const item = visit(value[index], depth + 1);\n output.push(item === DROP ? \"[DROPPED]\" : item);\n }\n if (value.length > limit) {\n counts.droppedValues += value.length - limit;\n counts.truncatedValues++;\n }\n ancestors.delete(value);\n return output;\n }\n const output: { [key: string]: FabricTraceJsonValue } = {};\n const keys = Object.keys(record).sort();\n const limit = Math.min(keys.length, MAX_KEYS);\n for (let index = 0; index < limit; index++) {\n const childKey = keys[index]!;\n const child = visit(record[childKey], depth + 1, childKey);\n if (child !== DROP) output[childKey] = child;\n }\n if (keys.length > limit) {\n counts.droppedValues += keys.length - limit;\n counts.truncatedValues++;\n }\n ancestors.delete(value);\n return output;\n };\n\n let value = visit(input, 0);\n if (value === DROP) value = \"[DROPPED]\";\n const originalBytes = serializedBytes(value);\n if (originalBytes > maxBytes) {\n counts.truncatedValues++;\n if (Array.isArray(value)) {\n const output: FabricTraceJsonValue[] = [];\n for (const item of value) {\n const next = [...output, item];\n if (serializedBytes(next) > maxBytes - 128) break;\n output.push(item);\n }\n counts.droppedValues += value.length - output.length;\n value = output;\n } else if (typeof value === \"object\" && value !== null) {\n const output: { [key: string]: FabricTraceJsonValue } = {};\n const entries = Object.entries(value);\n let included = 0;\n for (const [childKey, child] of entries) {\n const next = { ...output, [childKey]: child };\n if (serializedBytes(next) > maxBytes - 128) break;\n output[childKey] = child;\n included++;\n }\n counts.droppedValues += entries.length - included;\n value = output;\n }\n }\n return { value, counts };\n};\n\nconst sanitizeObject = (\n value: Record<string, unknown>,\n droppedValues = 0,\n): Sanitized<{ [key: string]: FabricTraceJsonValue }> => {\n const sanitized = sanitize(value, MAX_ARGS_BYTES);\n sanitized.counts.droppedValues += droppedValues;\n if (typeof sanitized.value === \"object\" && sanitized.value !== null && !Array.isArray(sanitized.value)) {\n return sanitized as Sanitized<{ [key: string]: FabricTraceJsonValue }>;\n }\n sanitized.counts.droppedValues++;\n return { value: {}, counts: sanitized.counts };\n};\n\nconst projectedArgs = (\n ref: string,\n args: Record<string, unknown>,\n): Sanitized<{ [key: string]: FabricTraceJsonValue }> => {\n const projection = projectFabricAuditArgs(ref, args);\n return sanitizeObject(projection.value, projection.droppedValues);\n};\n\nconst sanitizeString = (value: string, maxBytes: number): Sanitized<string> => {\n const bounded = truncateUtf8(value, maxBytes);\n return {\n value: bounded,\n counts: {\n ...emptyCounts(),\n truncatedValues: bounded === value ? 0 : 1,\n },\n };\n};\n\nconst addCounts = (target: FabricExecutionTraceCountsV1, source: MutableCounts): void => {\n target.droppedValues += source.droppedValues;\n target.truncatedValues += source.truncatedValues;\n target.redactedValues += source.redactedValues;\n};\n\nconst lexicalIdentity = (ref: string): { provider?: string; action?: string } => {\n const separator = ref.indexOf(\".\");\n if (separator <= 0 || separator === ref.length - 1) return {};\n return {\n provider: ref.slice(0, separator),\n action: ref.slice(separator + 1),\n };\n};\n\n// Errors whose messages contain no tool output, argument payloads, or\n// user/source text and are safe to quote verbatim in durable traces: registry\n// resolution failures, policy denials, and Fabric-generated guard messages.\nexport class FabricTraceSafeError extends Error {}\n\n// Thrown by the registry when a provider or action cannot be resolved.\nexport class FabricResolutionError extends FabricTraceSafeError {}\n\nconst errorCause = (error: unknown): string | undefined => {\n const message = error instanceof Error ? error.message : typeof error === \"string\" ? error : undefined;\n const trimmed = message?.trim();\n return trimmed ? truncateUtf8Middle(trimmed, MAX_ERROR_BYTES - 256) : undefined;\n};\n\nconst failureMessage = (\n stage: FabricExecutionFailureStageV1,\n outcome: FabricExecutionOutcomeV1,\n cause?: string,\n): string => {\n if (outcome === \"timed_out\") return \"Call timed out\";\n if (outcome === \"aborted\") return \"Call aborted\";\n const summary = `Call failed during ${stage}`;\n return cause ? `${summary}: ${cause}` : summary;\n};\n\nconst executionErrorMessage = (outcome: FabricExecutionOutcomeV1): string | undefined => {\n if (outcome === \"succeeded\") return undefined;\n if (outcome === \"timed_out\") return \"Execution timed out\";\n if (outcome === \"aborted\") return \"Execution aborted\";\n return \"Execution failed\";\n};\n\n/**\n * Optional, non-deterministic side channel (the assessment projection). It\n * observes issue and settle events and never alters the deterministic trace.\n */\nexport interface FabricExecutionTraceObserver {\n issued(sequence: number, ref: string): void;\n settled(sequence: number, outcome: FabricExecutionOutcomeV1, result: unknown): void;\n}\n\nexport class FabricExecutionTraceOperationHandle {\n constructor(\n private readonly recorder: FabricExecutionTraceRecorder,\n private readonly operation: MutableOperation | undefined,\n /** Bridge issue order; shared with the trace operation when one is recorded. */\n readonly sequence = -1,\n ) {}\n\n resolved(provider: string, action: string): void {\n if (!this.operation || this.recorder.sealed) return;\n const boundedProvider = boundedIdentifier(provider);\n const boundedAction = boundedIdentifier(action);\n if (this.operation.provider !== boundedProvider) {\n this.operation.provider = this.recorder.snapshotIdentifier(provider);\n }\n if (this.operation.action !== boundedAction) {\n this.operation.action = this.recorder.snapshotIdentifier(action);\n }\n }\n\n prepared(args: Record<string, unknown>): void {\n if (!this.operation || this.recorder.sealed) return;\n this.operation.args = projectedArgs(this.operation.projectionRef, args);\n }\n\n normalized(witness: NormalFormWitness): void {\n if (!this.operation || this.recorder.sealed || !isNormalFormWitness(witness)) return;\n this.operation.normalization = { ...witness, rules: witness.rules.map((rule) => ({ ...rule })) };\n }\n\n succeed(result: unknown, meta?: TraceResultMeta): void {\n this.recorder.observeSettled(this.sequence, \"succeeded\", result);\n if (!this.operation || this.recorder.sealed) return;\n const projected = projectFabricAuditResult(this.operation.projectionRef, result);\n if (projected !== undefined) {\n this.operation.result = sanitize(projected.value, MAX_RESULT_BYTES);\n this.operation.result.counts.droppedValues += projected.droppedValues;\n } else if (result !== undefined) {\n this.operation.droppedResultValues++;\n }\n this.operation.outcome = \"succeeded\";\n if (meta?.resultTruncated === true) this.operation.resultTruncated = true;\n }\n\n fail(\n stage: FabricExecutionFailureStageV1,\n error: unknown,\n outcome: FabricExecutionOutcomeV1 = \"failed\",\n result?: unknown,\n meta?: TraceResultMeta,\n ): void {\n this.recorder.observeSettled(this.sequence, outcome, result);\n if (!this.operation || this.recorder.sealed) return;\n this.operation.failureStage = stage;\n if (error instanceof FabricTraceSafeError) this.operation.causeSafe = true;\n const cause =\n outcome === \"failed\" &&\n (this.operation.causeSafe === true ||\n (isPiShellRef(this.operation.projectionRef) && stage === \"invoke\"))\n ? errorCause(error)\n : undefined;\n this.operation.error = sanitizeString(\n failureMessage(stage, outcome, cause),\n MAX_ERROR_BYTES,\n );\n this.operation.outcome = outcome;\n if (meta?.resultTruncated === true) this.operation.resultTruncated = true;\n const projected = projectFabricAuditResult(this.operation.projectionRef, result);\n if (projected !== undefined) {\n this.operation.result = sanitize(projected.value, MAX_RESULT_BYTES);\n this.operation.result.counts.droppedValues += projected.droppedValues;\n } else if (result !== undefined) {\n this.operation.droppedResultValues++;\n }\n }\n}\n\nexport class FabricExecutionTraceRecorder {\n readonly #operations: MutableOperation[] = [];\n #nextSequence = 0;\n #droppedOperations = 0;\n #truncatedIdentifiers = 0;\n readonly #observer: FabricExecutionTraceObserver | undefined;\n sealed = false;\n\n constructor(observer?: FabricExecutionTraceObserver) {\n this.#observer = observer;\n }\n\n /** @internal Forwards a settle to the observer; observer faults never reach the program. */\n observeSettled(sequence: number, outcome: FabricExecutionOutcomeV1, result: unknown): void {\n if (!this.#observer || this.sealed || sequence < 0) return;\n try {\n this.#observer.settled(sequence, outcome, result);\n } catch {\n // Observation is best effort.\n }\n }\n\n snapshotIdentifier(value: string, maxBytes = MAX_IDENTIFIER_BYTES): string {\n const bounded = boundedIdentifier(value, maxBytes);\n if (bounded !== value) this.#truncatedIdentifiers++;\n return bounded;\n }\n\n issueCall(ref: string, args: Record<string, unknown>): FabricExecutionTraceOperationHandle {\n const sequence = this.#nextSequence++;\n if (this.#observer && !this.sealed) {\n try {\n this.#observer.issued(sequence, ref);\n } catch {\n // Observation is best effort.\n }\n }\n if (this.sealed || this.#operations.length >= MAX_RECORDED_OPERATIONS) {\n this.#droppedOperations++;\n return new FabricExecutionTraceOperationHandle(this, undefined, this.sealed ? -1 : sequence);\n }\n const identity = lexicalIdentity(ref);\n const operation: MutableOperation = {\n type: \"call\",\n sequence,\n ref: this.snapshotIdentifier(ref),\n projectionRef: ref,\n ...(identity.provider ? { provider: this.snapshotIdentifier(identity.provider) } : {}),\n ...(identity.action ? { action: this.snapshotIdentifier(identity.action) } : {}),\n args: projectedArgs(ref, args),\n droppedResultValues: 0,\n };\n this.#operations.push(operation);\n return new FabricExecutionTraceOperationHandle(this, operation, sequence);\n }\n\n // safeError must contain no guest source text, tool output, or argument\n // payloads \u2014 callers pass it only for Fabric-generated failure summaries\n // (for example the type-check stage). Guest and provider error text is\n // deliberately not persisted here.\n seal(\n outcome: FabricExecutionOutcomeV1,\n phases: readonly string[],\n safeError?: string,\n ): FabricExecutionTraceV1 {\n this.sealed = true;\n for (const operation of this.#operations) {\n if (!operation.outcome) {\n operation.outcome = outcome === \"timed_out\" ? \"timed_out\" : outcome === \"aborted\" ? \"aborted\" : \"failed\";\n operation.failureStage ??= \"invoke\";\n } else if (operation.outcome === \"aborted\" && outcome === \"timed_out\") {\n // Host calls observe an aborted bridge signal for both cancellation and\n // deadline expiry. The runtime's typed final termination is\n // authoritative when sealing the durable operation.\n operation.outcome = \"timed_out\";\n }\n if (operation.outcome !== \"succeeded\") {\n const preserveCause =\n operation.error !== undefined &&\n (operation.causeSafe === true ||\n (isPiShellRef(operation.projectionRef) && operation.outcome === \"failed\"));\n if (!preserveCause) {\n operation.error = sanitizeString(\n failureMessage(operation.failureStage ?? \"invoke\", operation.outcome),\n MAX_ERROR_BYTES,\n );\n }\n }\n }\n\n const counts: FabricExecutionTraceCountsV1 = {\n droppedValues: 0,\n truncatedValues: this.#truncatedIdentifiers,\n redactedValues: 0,\n droppedOperations: this.#droppedOperations,\n };\n const operations = this.#operations.map((operation): FabricExecutionTraceOperationV1 => {\n addCounts(counts, operation.args.counts);\n counts.droppedValues += operation.droppedResultValues;\n if (operation.error) addCounts(counts, operation.error.counts);\n if (operation.result) addCounts(counts, operation.result.counts);\n return {\n type: \"call\",\n sequence: operation.sequence,\n ref: operation.ref,\n ...(operation.provider ? { provider: operation.provider } : {}),\n ...(operation.action ? { action: operation.action } : {}),\n args: operation.args.value,\n outcome: operation.outcome!,\n ...(operation.normalization ? { normalization: operation.normalization } : {}),\n ...(operation.failureStage ? { failureStage: operation.failureStage } : {}),\n ...(operation.error ? { error: operation.error.value } : {}),\n ...(operation.result ? { result: operation.result.value } : {}),\n ...(operation.resultTruncated === true ? { resultTruncated: true as const } : {}),\n };\n });\n const boundedPhases = phases.slice(0, MAX_PHASES).map((phase) => {\n const bounded = boundedIdentifier(phase, MAX_PHASE_BYTES);\n if (bounded !== phase) counts.truncatedValues++;\n return bounded;\n });\n if (phases.length > boundedPhases.length) {\n counts.droppedValues += phases.length - boundedPhases.length;\n counts.truncatedValues++;\n }\n const safeRunError = safeError?.trim() || executionErrorMessage(outcome);\n const runError = safeRunError ? sanitizeString(safeRunError, MAX_ERROR_BYTES) : undefined;\n if (runError) addCounts(counts, runError.counts);\n const trace: FabricExecutionTraceV1 = {\n kind: FABRIC_EXECUTION_TRACE_KIND,\n version: FABRIC_EXECUTION_TRACE_VERSION,\n outcome,\n phases: boundedPhases,\n operations,\n counts,\n ...(runError ? { error: runError.value } : {}),\n };\n\n let traceBytes = serializedBytes(trace);\n const adjustMutation = (\n beforeValueBytes: number,\n afterValueBytes: number,\n beforeCountsBytes: number,\n ): void => {\n traceBytes +=\n afterValueBytes -\n beforeValueBytes +\n serializedBytes(trace.counts) -\n beforeCountsBytes;\n };\n for (\n let index = trace.operations.length - 1;\n traceBytes > FABRIC_EXECUTION_TRACE_MAX_BYTES && index >= 0;\n index--\n ) {\n const operation = trace.operations[index]!;\n if (operation.result === undefined) continue;\n const beforeOperationBytes = serializedBytes(operation);\n const beforeCountsBytes = serializedBytes(trace.counts);\n delete operation.result;\n trace.counts.droppedValues++;\n adjustMutation(\n beforeOperationBytes,\n serializedBytes(operation),\n beforeCountsBytes,\n );\n }\n for (\n let index = trace.operations.length - 1;\n traceBytes > FABRIC_EXECUTION_TRACE_MAX_BYTES && index >= 0;\n index--\n ) {\n const operation = trace.operations[index]!;\n if (Object.keys(operation.args).length === 0) continue;\n const beforeOperationBytes = serializedBytes(operation);\n const beforeCountsBytes = serializedBytes(trace.counts);\n operation.args = {};\n trace.counts.droppedValues++;\n trace.counts.truncatedValues++;\n adjustMutation(\n beforeOperationBytes,\n serializedBytes(operation),\n beforeCountsBytes,\n );\n }\n while (traceBytes > FABRIC_EXECUTION_TRACE_MAX_BYTES && trace.operations.length > 0) {\n const beforeCountsBytes = serializedBytes(trace.counts);\n const operation = trace.operations.pop()!;\n traceBytes -= serializedBytes(operation);\n if (trace.operations.length > 0) traceBytes--;\n trace.counts.droppedOperations++;\n traceBytes += serializedBytes(trace.counts) - beforeCountsBytes;\n }\n while (traceBytes > FABRIC_EXECUTION_TRACE_MAX_BYTES && trace.phases.length > 0) {\n const beforeCountsBytes = serializedBytes(trace.counts);\n const phase = trace.phases.pop()!;\n traceBytes -= serializedBytes(phase);\n if (trace.phases.length > 0) traceBytes--;\n trace.counts.droppedValues++;\n traceBytes += serializedBytes(trace.counts) - beforeCountsBytes;\n }\n return trace;\n }\n}\n\nexport const executionOutcomeFromError = (\n error: unknown,\n signal?: AbortSignal,\n): FabricExecutionOutcomeV1 => {\n if (signal?.aborted) return \"aborted\";\n return error === undefined ? \"succeeded\" : \"failed\";\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst hasOnlyKeys = (value: Record<string, unknown>, keys: readonly string[]): boolean =>\n Object.keys(value).every((key) => keys.includes(key));\n\nconst outcomes = new Set<FabricExecutionOutcomeV1>([\"succeeded\", \"failed\", \"aborted\", \"timed_out\"]);\nconst stages = new Set<FabricExecutionFailureStageV1>([\"resolve\", \"prepare\", \"validate\", \"approve\", \"invoke\", \"guard\"]);\n\nconst isJsonValue = (value: unknown, ancestors = new Set<object>(), depth = 0): value is FabricTraceJsonValue => {\n if (value === null || typeof value === \"string\" || typeof value === \"boolean\") return true;\n if (typeof value === \"number\") return Number.isFinite(value);\n if (typeof value !== \"object\" || depth > MAX_DEPTH + 2 || ancestors.has(value)) return false;\n ancestors.add(value);\n const valid = Array.isArray(value)\n ? value.every((item) => isJsonValue(item, ancestors, depth + 1))\n : Object.values(value as Record<string, unknown>).every((item) => isJsonValue(item, ancestors, depth + 1));\n ancestors.delete(value);\n return valid;\n};\n\nconst isFabricExecutionTraceOperationV1Unchecked = (\n value: unknown,\n): value is FabricExecutionTraceOperationV1 => {\n if (!isRecord(value)) return false;\n if (!hasOnlyKeys(value, [\"type\", \"sequence\", \"ref\", \"provider\", \"action\", \"args\", \"outcome\", \"normalization\", \"failureStage\", \"error\", \"result\", \"resultTruncated\"])) return false;\n if (value.type !== \"call\" || !Number.isSafeInteger(value.sequence) || (value.sequence as number) < 0) return false;\n if (typeof value.ref !== \"string\" || !isRecord(value.args) || !isJsonValue(value.args)) return false;\n if (!outcomes.has(value.outcome as FabricExecutionOutcomeV1)) return false;\n if (value.provider !== undefined && typeof value.provider !== \"string\") return false;\n if (value.action !== undefined && typeof value.action !== \"string\") return false;\n if (value.failureStage !== undefined && !stages.has(value.failureStage as FabricExecutionFailureStageV1)) return false;\n if (value.error !== undefined && typeof value.error !== \"string\") return false;\n if (value.normalization !== undefined && !isNormalFormWitness(value.normalization)) return false;\n if (value.resultTruncated !== undefined && typeof value.resultTruncated !== \"boolean\") return false;\n return value.result === undefined || isJsonValue(value.result);\n};\n\nexport const isFabricExecutionTraceOperationV1 = (\n value: unknown,\n): value is FabricExecutionTraceOperationV1 => {\n try {\n return isFabricExecutionTraceOperationV1Unchecked(value);\n } catch {\n return false;\n }\n};\n\nconst isFabricExecutionTraceV1Unchecked = (value: unknown): value is FabricExecutionTraceV1 => {\n if (!isRecord(value)) return false;\n if (!hasOnlyKeys(value, [\"kind\", \"version\", \"outcome\", \"phases\", \"operations\", \"counts\", \"error\"])) return false;\n if (value.kind !== FABRIC_EXECUTION_TRACE_KIND || value.version !== FABRIC_EXECUTION_TRACE_VERSION) return false;\n if (!outcomes.has(value.outcome as FabricExecutionOutcomeV1)) return false;\n if (!Array.isArray(value.phases) || !value.phases.every((phase) => typeof phase === \"string\")) return false;\n if (!Array.isArray(value.operations) || !value.operations.every(isFabricExecutionTraceOperationV1)) return false;\n if (!isRecord(value.counts) || !hasOnlyKeys(value.counts, [\"droppedValues\", \"truncatedValues\", \"redactedValues\", \"droppedOperations\"])) return false;\n const counts = value.counts;\n if (![\"droppedValues\", \"truncatedValues\", \"redactedValues\", \"droppedOperations\"].every((key) => Number.isSafeInteger(counts[key]) && (counts[key] as number) >= 0)) return false;\n if (value.error !== undefined && typeof value.error !== \"string\") return false;\n for (let index = 1; index < value.operations.length; index++) {\n if (value.operations[index]!.sequence <= value.operations[index - 1]!.sequence) return false;\n }\n return serializedBytes(value) <= FABRIC_EXECUTION_TRACE_MAX_BYTES;\n};\n\nexport const isFabricExecutionTraceV1 = (value: unknown): value is FabricExecutionTraceV1 => {\n try {\n return isFabricExecutionTraceV1Unchecked(value);\n } catch {\n return false;\n }\n};\n\nexport const readFabricExecutionTraceV1 = (value: unknown): FabricExecutionTraceV1 | undefined =>\n isFabricExecutionTraceV1(value) ? value : undefined;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAOA,IAAM,kBAAkB,CAAC,UAA0D;AAAA,EACjF,OAAO,CAAC;AAAA,EACR,eAAe,iBAAiB,IAAI;AACtC;AAEA,IAAM,mBAAmB,CAAC,UAA2C;AACnE,MAAI;AACF,WAAO,OAAO,KAAK,KAAK,EAAE;AAAA,EAC5B,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,IAAM,eAAe,CAAC,UACpB,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,IAAI,QAAQ;AAEhE,IAAM,cAAc,CAAC,UACnB,OAAO,UAAU,WAAW,QAAQ;AAEtC,IAAM,qBAAqB,CAAC,UAA2B;AACrD,MAAI,MAAM,SAAS,KAAK,MAAM,CAAC,MAAM,OAAQ,MAAM,CAAC,MAAM,QAAQ,MAAM,CAAC,MAAM,KAAM;AACnF,WAAO;AAAA,EACT;AACA,QAAM,QAAQ,MAAM,WAAW,CAAC;AAChC,SAAQ,SAAS,MAAM,SAAS,MAAQ,SAAS,MAAM,SAAS;AAClE;AAEA,IAAM,YAAY,CAAC,UAAuC;AACxD,MAAI,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI,EAAG,QAAO;AAC9D,MAAI,CAAC,mBAAmB,KAAK,GAAG;AAC9B,QAAI;AAGF,YAAM,WAAW,IAAI,IAAI,KAAK;AAC9B,UAAI,SAAS,SAAU,QAAO;AAAA,IAChC,QAAQ;AAAA,IAGR;AACA,QAAI;AACF,YAAM,QAAQ,IAAI,IAAI,OAAO,yBAAyB;AACtD,UAAI,MAAM,aAAa,iBAAkB,QAAO;AAAA,IAClD,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AACA,QAAM,QAAQ,MAAM,QAAQ,GAA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C,KAAK;AAAA,EAChD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,IAAM,6BAA6B,CAAC,UACzC,yBAAyB,KAAK,IAAI,QAAQ;",
|
|
6
|
+
"names": ["value", "output", "limit", "projected"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface CliIo {
|
|
2
|
+
stdout: Pick<NodeJS.WritableStream, "write">;
|
|
3
|
+
stderr: Pick<NodeJS.WritableStream, "write">;
|
|
4
|
+
env?: NodeJS.ProcessEnv;
|
|
5
|
+
}
|
|
6
|
+
export declare const runDecisionsCli: (argv: string[], io?: CliIo) => Promise<number>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=decisions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decisions.d.ts","sourceRoot":"","sources":["../../src/cli/decisions.ts"],"names":[],"mappings":"AAsBA,UAAU,KAAK;IACb,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAC7C,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAC7C,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACzB;AA6CD,eAAO,MAAM,eAAe,GAC1B,MAAM,MAAM,EAAE,EACd,KAAI,KAA0D,KAC7D,OAAO,CAAC,MAAM,CA2DhB,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DecisionStore,
|
|
3
|
+
decisionEscalation
|
|
4
|
+
} from "../chunks/chunk-FSB2VIRZ.js";
|
|
5
|
+
import {
|
|
6
|
+
MeshStore
|
|
7
|
+
} from "../chunks/chunk-3GJJG2FV.js";
|
|
8
|
+
import "../chunks/chunk-JKQARSWR.js";
|
|
9
|
+
import "../chunks/chunk-CGPK5WHX.js";
|
|
10
|
+
import "../chunks/chunk-ITVLKXCI.js";
|
|
11
|
+
|
|
12
|
+
// src/cli/decisions.ts
|
|
13
|
+
import fs from "node:fs";
|
|
14
|
+
import os from "node:os";
|
|
15
|
+
import path from "node:path";
|
|
16
|
+
var USAGE = `Usage:
|
|
17
|
+
pi-fabric decisions list --root <meshRoot> [--status open|answered|expired|cancelled|all] [--holder <h>] [--limit <n>] [--json]
|
|
18
|
+
pi-fabric decisions answer --root <meshRoot> <id> (--option <optionId> | --text <text>) [--json]
|
|
19
|
+
|
|
20
|
+
--root defaults to $PI_FABRIC_MESH_ROOT.`;
|
|
21
|
+
var MAX_EVENT_BYTES = 256 * 1024;
|
|
22
|
+
var MAX_READ_EVENTS = 500;
|
|
23
|
+
var STATUSES = /* @__PURE__ */ new Set(["open", "answered", "expired", "cancelled", "all"]);
|
|
24
|
+
var VALUE_FLAGS = /* @__PURE__ */ new Set(["root", "status", "holder", "limit", "option", "text"]);
|
|
25
|
+
var UsageError = class extends Error {
|
|
26
|
+
};
|
|
27
|
+
var parseArgs = (argv) => {
|
|
28
|
+
const positionals = [];
|
|
29
|
+
const flags = /* @__PURE__ */ new Map();
|
|
30
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
31
|
+
const arg = argv[index];
|
|
32
|
+
if (!arg.startsWith("--")) {
|
|
33
|
+
positionals.push(arg);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const name = arg.slice(2);
|
|
37
|
+
if (name === "json" || name === "help") {
|
|
38
|
+
flags.set(name, true);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (!VALUE_FLAGS.has(name)) throw new UsageError(`Unknown option: ${arg}`);
|
|
42
|
+
const value = argv[index + 1];
|
|
43
|
+
if (value === void 0) throw new UsageError(`Missing value for ${arg}`);
|
|
44
|
+
flags.set(name, value);
|
|
45
|
+
index += 1;
|
|
46
|
+
}
|
|
47
|
+
return { positionals, flags };
|
|
48
|
+
};
|
|
49
|
+
var operator = () => {
|
|
50
|
+
try {
|
|
51
|
+
return os.userInfo().username || "user";
|
|
52
|
+
} catch {
|
|
53
|
+
return "user";
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
var line = (record) => {
|
|
57
|
+
const options = record.options ? ` [${record.options.map((option) => `${option.id}=${option.label}`).join(", ")}]` : "";
|
|
58
|
+
const deadline = record.deadline ? ` deadline=${new Date(record.deadline).toISOString()}` : "";
|
|
59
|
+
const escalation = decisionEscalation(record);
|
|
60
|
+
const chain = escalation ? ` hop ${escalation.hop + 1}/${escalation.chain.length} chain=${escalation.chain.join(">")}` : "";
|
|
61
|
+
return `${record.id} ${record.status} ${record.kind} holder=${record.holder}${chain}${deadline} ${record.title}${options}`;
|
|
62
|
+
};
|
|
63
|
+
var runDecisionsCli = async (argv, io = { stdout: process.stdout, stderr: process.stderr }) => {
|
|
64
|
+
try {
|
|
65
|
+
const [command, ...rest] = argv;
|
|
66
|
+
const { positionals, flags } = parseArgs(rest);
|
|
67
|
+
if (!command || command === "help" || command === "--help" || flags.has("help")) {
|
|
68
|
+
io.stdout.write(`${USAGE}
|
|
69
|
+
`);
|
|
70
|
+
return command ? 0 : 2;
|
|
71
|
+
}
|
|
72
|
+
const rootFlag = flags.get("root");
|
|
73
|
+
const root = typeof rootFlag === "string" ? rootFlag : (io.env ?? process.env).PI_FABRIC_MESH_ROOT;
|
|
74
|
+
if (!root) throw new UsageError("Missing --root <meshRoot>");
|
|
75
|
+
const meshRoot = path.resolve(root);
|
|
76
|
+
if (!fs.statSync(meshRoot, { throwIfNoEntry: false })?.isDirectory()) throw new Error(`No Fabric mesh root at ${meshRoot}`);
|
|
77
|
+
const user = operator();
|
|
78
|
+
const store = new DecisionStore(
|
|
79
|
+
new MeshStore(meshRoot, MAX_EVENT_BYTES, MAX_READ_EVENTS),
|
|
80
|
+
{ id: `user:${user}`, name: user, kind: "main" }
|
|
81
|
+
);
|
|
82
|
+
const json = flags.get("json") === true;
|
|
83
|
+
if (command === "list") {
|
|
84
|
+
if (positionals.length > 0) throw new UsageError(`Unexpected argument: ${positionals[0]}`);
|
|
85
|
+
const status = flags.get("status") ?? "open";
|
|
86
|
+
if (typeof status !== "string" || !STATUSES.has(status)) throw new UsageError(`Invalid --status: ${String(status)}`);
|
|
87
|
+
const limitFlag = flags.get("limit");
|
|
88
|
+
const limit = limitFlag === void 0 ? 50 : Number(limitFlag);
|
|
89
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > 200) throw new UsageError("--limit must be 1..200");
|
|
90
|
+
const holder = flags.get("holder");
|
|
91
|
+
const records = await store.list({
|
|
92
|
+
...status !== "all" ? { status } : {},
|
|
93
|
+
...typeof holder === "string" ? { holder } : {},
|
|
94
|
+
limit
|
|
95
|
+
});
|
|
96
|
+
io.stdout.write(json ? `${JSON.stringify(records, null, 2)}
|
|
97
|
+
` : records.length > 0 ? `${records.map(line).join("\n")}
|
|
98
|
+
` : "No decisions\n");
|
|
99
|
+
return 0;
|
|
100
|
+
}
|
|
101
|
+
if (command === "answer") {
|
|
102
|
+
const [id, extra] = positionals;
|
|
103
|
+
if (!id || extra !== void 0) throw new UsageError("answer takes exactly one decision id");
|
|
104
|
+
const option = flags.get("option");
|
|
105
|
+
const text = flags.get("text");
|
|
106
|
+
if (option === void 0 && text === void 0) throw new UsageError("answer needs --option or --text");
|
|
107
|
+
const record = await store.answer(id, {
|
|
108
|
+
...typeof option === "string" ? { optionId: option } : {},
|
|
109
|
+
...typeof text === "string" ? { text } : {}
|
|
110
|
+
}, { answeredBy: user, via: "cli" });
|
|
111
|
+
io.stdout.write(json ? `${JSON.stringify(record, null, 2)}
|
|
112
|
+
` : `${line(record)}
|
|
113
|
+
`);
|
|
114
|
+
return 0;
|
|
115
|
+
}
|
|
116
|
+
throw new UsageError(`Unknown decisions command: ${command}`);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
io.stderr.write(`pi-fabric decisions: ${error instanceof Error ? error.message : String(error)}
|
|
119
|
+
`);
|
|
120
|
+
if (error instanceof UsageError) {
|
|
121
|
+
io.stderr.write(`${USAGE}
|
|
122
|
+
`);
|
|
123
|
+
return 2;
|
|
124
|
+
}
|
|
125
|
+
return 1;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
export {
|
|
129
|
+
runDecisionsCli
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=decisions.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/cli/decisions.ts"],
|
|
4
|
+
"sourcesContent": ["import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { MeshStore } from \"../mesh/store.js\";\nimport { decisionEscalation, DecisionStore, type DecisionRecord, type DecisionStatus } from \"../decisions/store.js\";\n\n// `pi-fabric decisions list|answer`: answer durable Fabric decisions from\n// outside any Pi session. Authority is local file access to the mesh root\n// (one OS user); answers record `via: \"cli\"` and the OS user name.\n\nconst USAGE = `Usage:\n pi-fabric decisions list --root <meshRoot> [--status open|answered|expired|cancelled|all] [--holder <h>] [--limit <n>] [--json]\n pi-fabric decisions answer --root <meshRoot> <id> (--option <optionId> | --text <text>) [--json]\n\n--root defaults to $PI_FABRIC_MESH_ROOT.`;\n\n// Mirrors the default mesh.maxEventBytes / mesh.maxReadEvents.\nconst MAX_EVENT_BYTES = 256 * 1024;\nconst MAX_READ_EVENTS = 500;\nconst STATUSES = new Set([\"open\", \"answered\", \"expired\", \"cancelled\", \"all\"]);\nconst VALUE_FLAGS = new Set([\"root\", \"status\", \"holder\", \"limit\", \"option\", \"text\"]);\n\ninterface CliIo {\n stdout: Pick<NodeJS.WritableStream, \"write\">;\n stderr: Pick<NodeJS.WritableStream, \"write\">;\n env?: NodeJS.ProcessEnv;\n}\n\nclass UsageError extends Error {}\n\nconst parseArgs = (argv: readonly string[]): { positionals: string[]; flags: Map<string, string | true> } => {\n const positionals: string[] = [];\n const flags = new Map<string, string | true>();\n for (let index = 0; index < argv.length; index += 1) {\n const arg = argv[index]!;\n if (!arg.startsWith(\"--\")) {\n positionals.push(arg);\n continue;\n }\n const name = arg.slice(2);\n if (name === \"json\" || name === \"help\") {\n flags.set(name, true);\n continue;\n }\n if (!VALUE_FLAGS.has(name)) throw new UsageError(`Unknown option: ${arg}`);\n const value = argv[index + 1];\n if (value === undefined) throw new UsageError(`Missing value for ${arg}`);\n flags.set(name, value);\n index += 1;\n }\n return { positionals, flags };\n};\n\nconst operator = (): string => {\n try {\n return os.userInfo().username || \"user\";\n } catch {\n return \"user\";\n }\n};\n\nconst line = (record: DecisionRecord): string => {\n const options = record.options ? ` [${record.options.map((option) => `${option.id}=${option.label}`).join(\", \")}]` : \"\";\n const deadline = record.deadline ? ` deadline=${new Date(record.deadline).toISOString()}` : \"\";\n const escalation = decisionEscalation(record);\n const chain = escalation\n ? ` hop ${escalation.hop + 1}/${escalation.chain.length} chain=${escalation.chain.join(\">\")}`\n : \"\";\n return `${record.id} ${record.status} ${record.kind} holder=${record.holder}${chain}${deadline} ${record.title}${options}`;\n};\n\nexport const runDecisionsCli = async (\n argv: string[],\n io: CliIo = { stdout: process.stdout, stderr: process.stderr },\n): Promise<number> => {\n try {\n const [command, ...rest] = argv;\n const { positionals, flags } = parseArgs(rest);\n if (!command || command === \"help\" || command === \"--help\" || flags.has(\"help\")) {\n io.stdout.write(`${USAGE}\\n`);\n return command ? 0 : 2;\n }\n const rootFlag = flags.get(\"root\");\n const root = typeof rootFlag === \"string\" ? rootFlag : (io.env ?? process.env).PI_FABRIC_MESH_ROOT;\n if (!root) throw new UsageError(\"Missing --root <meshRoot>\");\n const meshRoot = path.resolve(root);\n if (!fs.statSync(meshRoot, { throwIfNoEntry: false })?.isDirectory()) throw new Error(`No Fabric mesh root at ${meshRoot}`);\n const user = operator();\n const store = new DecisionStore(\n new MeshStore(meshRoot, MAX_EVENT_BYTES, MAX_READ_EVENTS),\n { id: `user:${user}`, name: user, kind: \"main\" },\n );\n const json = flags.get(\"json\") === true;\n if (command === \"list\") {\n if (positionals.length > 0) throw new UsageError(`Unexpected argument: ${positionals[0]}`);\n const status = flags.get(\"status\") ?? \"open\";\n if (typeof status !== \"string\" || !STATUSES.has(status)) throw new UsageError(`Invalid --status: ${String(status)}`);\n const limitFlag = flags.get(\"limit\");\n const limit = limitFlag === undefined ? 50 : Number(limitFlag);\n if (!Number.isInteger(limit) || limit < 1 || limit > 200) throw new UsageError(\"--limit must be 1..200\");\n const holder = flags.get(\"holder\");\n const records = await store.list({\n ...(status !== \"all\" ? { status: status as DecisionStatus } : {}),\n ...(typeof holder === \"string\" ? { holder } : {}),\n limit,\n });\n io.stdout.write(json\n ? `${JSON.stringify(records, null, 2)}\\n`\n : records.length > 0 ? `${records.map(line).join(\"\\n\")}\\n` : \"No decisions\\n\");\n return 0;\n }\n if (command === \"answer\") {\n const [id, extra] = positionals;\n if (!id || extra !== undefined) throw new UsageError(\"answer takes exactly one decision id\");\n const option = flags.get(\"option\");\n const text = flags.get(\"text\");\n if (option === undefined && text === undefined) throw new UsageError(\"answer needs --option or --text\");\n const record = await store.answer(id, {\n ...(typeof option === \"string\" ? { optionId: option } : {}),\n ...(typeof text === \"string\" ? { text } : {}),\n }, { answeredBy: user, via: \"cli\" });\n io.stdout.write(json ? `${JSON.stringify(record, null, 2)}\\n` : `${line(record)}\\n`);\n return 0;\n }\n throw new UsageError(`Unknown decisions command: ${command}`);\n } catch (error) {\n io.stderr.write(`pi-fabric decisions: ${error instanceof Error ? error.message : String(error)}\\n`);\n if (error instanceof UsageError) {\n io.stderr.write(`${USAGE}\\n`);\n return 2;\n }\n return 1;\n }\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AAQjB,IAAM,QAAQ;AAAA;AAAA;AAAA;AAAA;AAOd,IAAM,kBAAkB,MAAM;AAC9B,IAAM,kBAAkB;AACxB,IAAM,WAAW,oBAAI,IAAI,CAAC,QAAQ,YAAY,WAAW,aAAa,KAAK,CAAC;AAC5E,IAAM,cAAc,oBAAI,IAAI,CAAC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AAM,CAAC,CAAC;AAAA,IAAO,GAAG,KAAK,MAAM,CAAC;AAAA,CAAI;AACnF,aAAO;AAAA,IACT;AACA,UAAM,IAAI,WAAW,8BAA8B,OAAO,EAAE;AAAA,EAC9D,SAAS,OAAO;AACd,OAAG,OAAO,MAAM,wBAAwB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,CAAI;AAClG,QAAI,iBAAiB,YAAY;AAC/B,SAAG,OAAO,MAAM,GAAG,KAAK;AAAA,CAAI;AAC5B,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AA0BA,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAYlE"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli/index.ts
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
var commands = {
|
|
8
|
+
mesh: async () => (await import("./mesh.js")).runMeshCli,
|
|
9
|
+
decisions: async () => (await import("./decisions.js")).runDecisionsCli
|
|
10
|
+
};
|
|
11
|
+
var usage = () => [
|
|
12
|
+
"Usage: pi-fabric <command> [options]",
|
|
13
|
+
"",
|
|
14
|
+
"Commands:",
|
|
15
|
+
...Object.keys(commands).map((name) => ` ${name}`),
|
|
16
|
+
"",
|
|
17
|
+
"Run `pi-fabric <command> --help` for command options."
|
|
18
|
+
].join("\n");
|
|
19
|
+
async function runFabricCli(argv) {
|
|
20
|
+
const [name, ...rest] = argv;
|
|
21
|
+
if (!name || name === "--help" || name === "-h" || name === "help") {
|
|
22
|
+
process.stdout.write(`${usage()}
|
|
23
|
+
`);
|
|
24
|
+
return name ? 0 : 2;
|
|
25
|
+
}
|
|
26
|
+
const load = Object.hasOwn(commands, name) ? commands[name] : void 0;
|
|
27
|
+
if (!load) {
|
|
28
|
+
process.stderr.write(`pi-fabric: unknown command ${JSON.stringify(name)}
|
|
29
|
+
${usage()}
|
|
30
|
+
`);
|
|
31
|
+
return 2;
|
|
32
|
+
}
|
|
33
|
+
return (await load())(rest);
|
|
34
|
+
}
|
|
35
|
+
var invokedPath = process.argv[1];
|
|
36
|
+
var isMain = (() => {
|
|
37
|
+
if (!invokedPath) return false;
|
|
38
|
+
try {
|
|
39
|
+
return fs.realpathSync(path.resolve(invokedPath)) === fs.realpathSync(fileURLToPath(import.meta.url));
|
|
40
|
+
} catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
})();
|
|
44
|
+
if (isMain) {
|
|
45
|
+
try {
|
|
46
|
+
process.exitCode = await runFabricCli(process.argv.slice(2));
|
|
47
|
+
} catch (error) {
|
|
48
|
+
process.stderr.write(`pi-fabric: ${error instanceof Error ? error.message : String(error)}
|
|
49
|
+
`);
|
|
50
|
+
process.exitCode = 1;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
runFabricCli
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/cli/index.ts"],
|
|
4
|
+
"sourcesContent": ["#!/usr/bin/env node\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/**\n * `pi-fabric` out-of-process CLI. A standalone entry: it never imports the\n * extension graph, and each subcommand module loads only when invoked.\n * Subcommands take their remaining argv and return a process exit code.\n */\ntype FabricCliCommand = (argv: string[]) => Promise<number>;\n\nconst commands: Record<string, () => Promise<FabricCliCommand>> = {\n mesh: async () => (await import(\"./mesh.js\")).runMeshCli,\n decisions: async () => (await import(\"./decisions.js\")).runDecisionsCli,\n};\n\nconst usage = (): string => [\n \"Usage: pi-fabric <command> [options]\",\n \"\",\n \"Commands:\",\n ...Object.keys(commands).map((name) => ` ${name}`),\n \"\",\n \"Run `pi-fabric <command> --help` for command options.\",\n].join(\"\\n\");\n\nexport async function runFabricCli(argv: string[]): Promise<number> {\n const [name, ...rest] = argv;\n if (!name || name === \"--help\" || name === \"-h\" || name === \"help\") {\n process.stdout.write(`${usage()}\\n`);\n return name ? 0 : 2;\n }\n const load = Object.hasOwn(commands, name) ? commands[name] : undefined;\n if (!load) {\n process.stderr.write(`pi-fabric: unknown command ${JSON.stringify(name)}\\n${usage()}\\n`);\n return 2;\n }\n return (await load())(rest);\n}\n\nconst invokedPath = process.argv[1];\nconst isMain = (() => {\n if (!invokedPath) return false;\n try {\n // npm links bins through symlinks; compare canonical paths.\n return fs.realpathSync(path.resolve(invokedPath)) === fs.realpathSync(fileURLToPath(import.meta.url));\n } catch {\n return false;\n }\n})();\nif (isMain) {\n try {\n process.exitCode = await runFabricCli(process.argv.slice(2));\n } catch (error) {\n process.stderr.write(`pi-fabric: ${error instanceof Error ? error.message : String(error)}\\n`);\n process.exitCode = 1;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;AACA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAS9B,IAAM,WAA4D;AAAA,EAChE,MAAM,aAAa,MAAM,OAAO,WAAW,GAAG;AAAA,EAC9C,WAAW,aAAa,MAAM,OAAO,gBAAgB,GAAG;AAC1D;AAEA,IAAM,QAAQ,MAAc;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG,OAAO,KAAK,QAAQ,EAAE,IAAI,CAAC,SAAS,KAAK,IAAI,EAAE;AAAA,EAClD;AAAA,EACA;AACF,EAAE,KAAK,IAAI;AAEX,eAAsB,aAAa,MAAiC;AAClE,QAAM,CAAC,MAAM,GAAG,IAAI,IAAI;AACx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MAX_BYTES,
|
|
3
|
+
MESH_GRANT_TOKEN_ENV,
|
|
4
|
+
postWithMeshGrant
|
|
5
|
+
} from "../chunks/chunk-7XRUMDV7.js";
|
|
6
|
+
import {
|
|
7
|
+
MeshStore
|
|
8
|
+
} from "../chunks/chunk-3GJJG2FV.js";
|
|
9
|
+
import "../chunks/chunk-JKQARSWR.js";
|
|
10
|
+
import "../chunks/chunk-CGPK5WHX.js";
|
|
11
|
+
import "../chunks/chunk-ITVLKXCI.js";
|
|
12
|
+
|
|
13
|
+
// src/cli/mesh.ts
|
|
14
|
+
import fs from "node:fs";
|
|
15
|
+
import path from "node:path";
|
|
16
|
+
var USAGE = [
|
|
17
|
+
"Usage: pi-fabric mesh post --root <meshRoot> [--token <token>] [--topic <topic>] [--kind <kind>]",
|
|
18
|
+
" [--data '<json>' | --data-file <file> | --data-file -]",
|
|
19
|
+
"",
|
|
20
|
+
`Appends one untrusted event through a scoped grant from mesh.grant. Prefer the`,
|
|
21
|
+
`${MESH_GRANT_TOKEN_ENV} environment variable over --token so the token stays out of`,
|
|
22
|
+
"process listings. --topic, when given, must match the grant. --data-file - reads stdin.",
|
|
23
|
+
`Data is JSON of at most ${MESH_EXTERNAL_DATA_MAX_BYTES} bytes.`
|
|
24
|
+
].join("\n");
|
|
25
|
+
var CLI_MAX_EVENT_BYTES = 256 * 1024;
|
|
26
|
+
var CLI_MAX_READ_EVENTS = 100;
|
|
27
|
+
var VALUE_FLAGS = /* @__PURE__ */ new Set(["--root", "--token", "--topic", "--kind", "--data", "--data-file"]);
|
|
28
|
+
var UsageError = class extends Error {
|
|
29
|
+
};
|
|
30
|
+
var parseFlags = (argv) => {
|
|
31
|
+
const flags = /* @__PURE__ */ new Map();
|
|
32
|
+
for (let index = 0; index < argv.length; index++) {
|
|
33
|
+
const argument = argv[index];
|
|
34
|
+
const equals = argument.indexOf("=");
|
|
35
|
+
const name = argument.startsWith("--") && equals > 0 ? argument.slice(0, equals) : argument;
|
|
36
|
+
if (!VALUE_FLAGS.has(name)) throw new UsageError(`unknown option ${argument}`);
|
|
37
|
+
const value = equals > 0 && name !== argument ? argument.slice(equals + 1) : argv[++index];
|
|
38
|
+
if (value === void 0) throw new UsageError(`${name} requires a value`);
|
|
39
|
+
if (flags.has(name)) throw new UsageError(`${name} given more than once`);
|
|
40
|
+
flags.set(name, value);
|
|
41
|
+
}
|
|
42
|
+
return flags;
|
|
43
|
+
};
|
|
44
|
+
var readBounded = async (source) => {
|
|
45
|
+
const chunks = [];
|
|
46
|
+
let bytes = 0;
|
|
47
|
+
const stream = source === "-" ? process.stdin : fs.createReadStream(source);
|
|
48
|
+
for await (const chunk of stream) {
|
|
49
|
+
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk));
|
|
50
|
+
bytes += buffer.length;
|
|
51
|
+
if (bytes > MESH_EXTERNAL_DATA_MAX_BYTES) {
|
|
52
|
+
if (stream !== process.stdin) stream.destroy();
|
|
53
|
+
throw new Error(`External mesh data exceeds ${MESH_EXTERNAL_DATA_MAX_BYTES} bytes`);
|
|
54
|
+
}
|
|
55
|
+
chunks.push(buffer);
|
|
56
|
+
}
|
|
57
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
58
|
+
};
|
|
59
|
+
async function post(argv) {
|
|
60
|
+
const flags = parseFlags(argv);
|
|
61
|
+
const root = flags.get("--root");
|
|
62
|
+
if (!root) throw new UsageError("--root is required");
|
|
63
|
+
const token = flags.get("--token") ?? process.env[MESH_GRANT_TOKEN_ENV];
|
|
64
|
+
if (!token) throw new UsageError(`--token or ${MESH_GRANT_TOKEN_ENV} is required`);
|
|
65
|
+
if (flags.has("--data") && flags.has("--data-file")) throw new UsageError("use --data or --data-file, not both");
|
|
66
|
+
const resolvedRoot = path.resolve(root);
|
|
67
|
+
if (!fs.statSync(resolvedRoot, { throwIfNoEntry: false })?.isDirectory()) {
|
|
68
|
+
throw new Error(`Fabric mesh root does not exist: ${resolvedRoot}`);
|
|
69
|
+
}
|
|
70
|
+
const raw = flags.has("--data-file") ? await readBounded(flags.get("--data-file")) : flags.get("--data");
|
|
71
|
+
let data;
|
|
72
|
+
if (raw !== void 0) {
|
|
73
|
+
if (Buffer.byteLength(raw, "utf8") > MESH_EXTERNAL_DATA_MAX_BYTES) {
|
|
74
|
+
throw new Error(`External mesh data exceeds ${MESH_EXTERNAL_DATA_MAX_BYTES} bytes`);
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
data = JSON.parse(raw);
|
|
78
|
+
} catch {
|
|
79
|
+
throw new UsageError("--data must be valid JSON");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const store = new MeshStore(resolvedRoot, CLI_MAX_EVENT_BYTES, CLI_MAX_READ_EVENTS);
|
|
83
|
+
const { event, grant } = await postWithMeshGrant(store, {
|
|
84
|
+
token,
|
|
85
|
+
...flags.has("--topic") ? { topic: flags.get("--topic") } : {},
|
|
86
|
+
...flags.has("--kind") ? { kind: flags.get("--kind") } : {},
|
|
87
|
+
...data !== void 0 ? { data } : {}
|
|
88
|
+
});
|
|
89
|
+
process.stdout.write(`${JSON.stringify({
|
|
90
|
+
ok: true,
|
|
91
|
+
id: event.id,
|
|
92
|
+
sequence: event.sequence,
|
|
93
|
+
topic: event.topic,
|
|
94
|
+
kind: event.kind,
|
|
95
|
+
grantId: grant.grantId,
|
|
96
|
+
usesLeft: grant.uses
|
|
97
|
+
})}
|
|
98
|
+
`);
|
|
99
|
+
return 0;
|
|
100
|
+
}
|
|
101
|
+
async function runMeshCli(argv) {
|
|
102
|
+
const [subcommand, ...rest] = argv;
|
|
103
|
+
if (!subcommand || subcommand === "--help" || subcommand === "-h" || rest.includes("--help")) {
|
|
104
|
+
process.stdout.write(`${USAGE}
|
|
105
|
+
`);
|
|
106
|
+
return subcommand ? 0 : 2;
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
if (subcommand === "post") return await post(rest);
|
|
110
|
+
throw new UsageError(`unknown mesh subcommand ${JSON.stringify(subcommand)}`);
|
|
111
|
+
} catch (error) {
|
|
112
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
113
|
+
process.stderr.write(`pi-fabric mesh: ${message}
|
|
114
|
+
`);
|
|
115
|
+
if (error instanceof UsageError) {
|
|
116
|
+
process.stderr.write(`${USAGE}
|
|
117
|
+
`);
|
|
118
|
+
return 2;
|
|
119
|
+
}
|
|
120
|
+
return 1;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export {
|
|
124
|
+
runMeshCli
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=mesh.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/cli/mesh.ts"],
|
|
4
|
+
"sourcesContent": ["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { MESH_EXTERNAL_DATA_MAX_BYTES, MESH_GRANT_TOKEN_ENV, postWithMeshGrant } from \"../mesh/grants.js\";\nimport { MeshStore } from \"../mesh/store.js\";\n\nconst USAGE = [\n \"Usage: pi-fabric mesh post --root <meshRoot> [--token <token>] [--topic <topic>] [--kind <kind>]\",\n \" [--data '<json>' | --data-file <file> | --data-file -]\",\n \"\",\n `Appends one untrusted event through a scoped grant from mesh.grant. Prefer the`,\n `${MESH_GRANT_TOKEN_ENV} environment variable over --token so the token stays out of`,\n \"process listings. --topic, when given, must match the grant. --data-file - reads stdin.\",\n `Data is JSON of at most ${MESH_EXTERNAL_DATA_MAX_BYTES} bytes.`,\n].join(\"\\n\");\n\n// Generous store ceilings: the grant carries the minting mesh's event limit.\nconst CLI_MAX_EVENT_BYTES = 256 * 1024;\nconst CLI_MAX_READ_EVENTS = 100;\nconst VALUE_FLAGS = new Set([\"--root\", \"--token\", \"--topic\", \"--kind\", \"--data\", \"--data-file\"]);\n\nclass UsageError extends Error {}\n\nconst parseFlags = (argv: string[]): Map<string, string> => {\n const flags = new Map<string, string>();\n for (let index = 0; index < argv.length; index++) {\n const argument = argv[index]!;\n const equals = argument.indexOf(\"=\");\n const name = argument.startsWith(\"--\") && equals > 0 ? argument.slice(0, equals) : argument;\n if (!VALUE_FLAGS.has(name)) throw new UsageError(`unknown option ${argument}`);\n const value = equals > 0 && name !== argument ? argument.slice(equals + 1) : argv[++index];\n if (value === undefined) throw new UsageError(`${name} requires a value`);\n if (flags.has(name)) throw new UsageError(`${name} given more than once`);\n flags.set(name, value);\n }\n return flags;\n};\n\nconst readBounded = async (source: string): Promise<string> => {\n const chunks: Buffer[] = [];\n let bytes = 0;\n const stream = source === \"-\" ? process.stdin : fs.createReadStream(source);\n for await (const chunk of stream) {\n const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk));\n bytes += buffer.length;\n if (bytes > MESH_EXTERNAL_DATA_MAX_BYTES) {\n if (stream !== process.stdin) (stream as fs.ReadStream).destroy();\n throw new Error(`External mesh data exceeds ${MESH_EXTERNAL_DATA_MAX_BYTES} bytes`);\n }\n chunks.push(buffer);\n }\n return Buffer.concat(chunks).toString(\"utf8\");\n};\n\nasync function post(argv: string[]): Promise<number> {\n const flags = parseFlags(argv);\n const root = flags.get(\"--root\");\n if (!root) throw new UsageError(\"--root is required\");\n const token = flags.get(\"--token\") ?? process.env[MESH_GRANT_TOKEN_ENV];\n if (!token) throw new UsageError(`--token or ${MESH_GRANT_TOKEN_ENV} is required`);\n if (flags.has(\"--data\") && flags.has(\"--data-file\")) throw new UsageError(\"use --data or --data-file, not both\");\n const resolvedRoot = path.resolve(root);\n // Never create a mesh where none exists: a typo must not mint an empty root.\n if (!fs.statSync(resolvedRoot, { throwIfNoEntry: false })?.isDirectory()) {\n throw new Error(`Fabric mesh root does not exist: ${resolvedRoot}`);\n }\n const raw = flags.has(\"--data-file\") ? await readBounded(flags.get(\"--data-file\")!) : flags.get(\"--data\");\n let data: unknown;\n if (raw !== undefined) {\n if (Buffer.byteLength(raw, \"utf8\") > MESH_EXTERNAL_DATA_MAX_BYTES) {\n throw new Error(`External mesh data exceeds ${MESH_EXTERNAL_DATA_MAX_BYTES} bytes`);\n }\n try {\n data = JSON.parse(raw);\n } catch {\n throw new UsageError(\"--data must be valid JSON\");\n }\n }\n const store = new MeshStore(resolvedRoot, CLI_MAX_EVENT_BYTES, CLI_MAX_READ_EVENTS);\n const { event, grant } = await postWithMeshGrant(store, {\n token,\n ...(flags.has(\"--topic\") ? { topic: flags.get(\"--topic\")! } : {}),\n ...(flags.has(\"--kind\") ? { kind: flags.get(\"--kind\")! } : {}),\n ...(data !== undefined ? { data } : {}),\n });\n process.stdout.write(`${JSON.stringify({\n ok: true, id: event.id, sequence: event.sequence, topic: event.topic, kind: event.kind,\n grantId: grant.grantId, usesLeft: grant.uses,\n })}\\n`);\n return 0;\n}\n\n/** `pi-fabric mesh <subcommand>`; exit 0 on success, 1 on refusal, 2 on usage errors. */\nexport async function runMeshCli(argv: string[]): Promise<number> {\n const [subcommand, ...rest] = argv;\n if (!subcommand || subcommand === \"--help\" || subcommand === \"-h\" || rest.includes(\"--help\")) {\n process.stdout.write(`${USAGE}\\n`);\n return subcommand ? 0 : 2;\n }\n try {\n if (subcommand === \"post\") return await post(rest);\n throw new UsageError(`unknown mesh subcommand ${JSON.stringify(subcommand)}`);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n process.stderr.write(`pi-fabric mesh: ${message}\\n`);\n if (error instanceof UsageError) {\n process.stderr.write(`${USAGE}\\n`);\n return 2;\n }\n return 1;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AAIjB,IAAM,QAAQ;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG,oBAAoB;AAAA,EACvB;AAAA,EACA,2BAA2B,4BAA4B;AACzD,EAAE,KAAK,IAAI;AAGX,IAAM,sBAAsB,MAAM;AAClC,IAAM,sBAAsB;AAC5B,IAAM,cAAc,oBAAI,IAAI,CAAC,UAAU,WAAW,WAAW,UAAU,U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K,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"fabric.d.ts","sourceRoot":"","sources":["../../src/commands/fabric.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAE3F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAMtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAqB9D,UAAU,iBAAiB;IACzB,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,aAAa,EAAE,mBAAmB,CAAC;IACnC,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,0BAA0B,CAAC,EAAE,MAAM,IAAI,CAAC;IACxC,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;CACjC;AAgJD,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,iBAAiB,GAAG,IAAI,CAwhCrF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SessionEntry } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
export declare const COMPACTION_CARRY_ENTRY_TYPE = "pi-fabric-compact-carry";
|
|
3
|
+
export declare const MAX_CARRY_ITEMS = 16;
|
|
4
|
+
export declare const MAX_CARRY_ITEM_CHARS: number;
|
|
5
|
+
export interface CompactionCarryEntryData {
|
|
6
|
+
version: 1;
|
|
7
|
+
items: string[];
|
|
8
|
+
}
|
|
9
|
+
export interface CompactionCarryUpdate {
|
|
10
|
+
items?: string[];
|
|
11
|
+
add?: string[];
|
|
12
|
+
remove?: string[];
|
|
13
|
+
clear?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** Validates a persisted entry; a malformed one fails closed to no carry. */
|
|
16
|
+
export declare const decodeCarryEntryData: (data: unknown) => string[] | undefined;
|
|
17
|
+
export declare const latestCarryItems: (entries: readonly SessionEntry[]) => string[];
|
|
18
|
+
export declare const applyCarryUpdate: (current: readonly string[], update: CompactionCarryUpdate) => string[];
|
|
19
|
+
export declare const isCarryUpdate: (update: CompactionCarryUpdate) => boolean;
|
|
20
|
+
export declare const sameCarryItems: (left: readonly string[], right: readonly string[]) => boolean;
|
|
21
|
+
/** Summary lines for the protected `[Carry Forward]` block. */
|
|
22
|
+
export declare const carryRequestLines: (items: readonly string[]) => string[];
|
|
23
|
+
//# sourceMappingURL=carry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"carry.d.ts","sourceRoot":"","sources":["../../src/compaction/carry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAepE,eAAO,MAAM,2BAA2B,4BAA4B,CAAC;AACrE,eAAO,MAAM,eAAe,KAAqB,CAAC;AAClD,eAAO,MAAM,oBAAoB,QAA0B,CAAC;AAE5D,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,CAAC,CAAC;IACX,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAcD,6EAA6E;AAC7E,eAAO,MAAM,oBAAoB,GAAI,MAAM,OAAO,KAAG,MAAM,EAAE,GAAG,SAK/D,CAAC;AAKF,eAAO,MAAM,gBAAgB,GAAI,SAAS,SAAS,YAAY,EAAE,KAAG,MAAM,EAOzE,CAAC;AAIF,eAAO,MAAM,gBAAgB,GAC3B,SAAS,SAAS,MAAM,EAAE,EAC1B,QAAQ,qBAAqB,KAC5B,MAAM,EAcR,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,QAAQ,qBAAqB,KAAG,OAI9B,CAAC;AAEjC,eAAO,MAAM,cAAc,GAAI,MAAM,SAAS,MAAM,EAAE,EAAE,OAAO,SAAS,MAAM,EAAE,KAAG,OACC,CAAC;AAErF,+DAA+D;AAC/D,eAAO,MAAM,iBAAiB,GAAI,OAAO,SAAS,MAAM,EAAE,KAAG,MAAM,EAI/D,CAAC"}
|
|
@@ -81,6 +81,11 @@ export interface FabricCompactionDetailsV2 {
|
|
|
81
81
|
recall: "session-entry-id-range";
|
|
82
82
|
};
|
|
83
83
|
budget?: FabricCompactionBudgetDetails;
|
|
84
|
+
/** Carry-forward focus rendered into this summary (absent when the list is empty). */
|
|
85
|
+
carry?: {
|
|
86
|
+
count: number;
|
|
87
|
+
renderedOmittedBytes: number;
|
|
88
|
+
};
|
|
84
89
|
timestamp: string;
|
|
85
90
|
}
|
|
86
91
|
export declare const fabricCompactionVersion: (details: unknown) => 1 | 2 | undefined;
|
|
@@ -96,6 +101,10 @@ export interface CompactionHookOptions {
|
|
|
96
101
|
getTargetContextRatio?: () => number;
|
|
97
102
|
getThresholdContextRatio?: (modelKey: string) => number | undefined;
|
|
98
103
|
getThresholdTokens?: (modelKey: string) => number | undefined;
|
|
104
|
+
/** `compaction.outputReserveTokens`; a breached reserve never defers Pi's threshold compaction. */
|
|
105
|
+
getOutputReserveTokens?: () => number;
|
|
106
|
+
/** Fabric deliberately left this compaction to another owner (pi-vcc sentinel/override). */
|
|
107
|
+
onYield?: () => void;
|
|
99
108
|
enrichers?: readonly CompactionEnricher[];
|
|
100
109
|
}
|
|
101
110
|
export declare const registerCompactionHook: (pi: ExtensionAPI, options: CompactionHookOptions) => void;
|