@e4779/pi-fabric 0.117.2-fork.31 → 0.131.4-fork.33
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 +13 -6
- package/THIRD_PARTY_NOTICES.md +6 -14
- package/dist/activity/store.d.ts +2 -1
- package/dist/activity/store.d.ts.map +1 -1
- package/dist/actors/binding-store.d.ts +13 -0
- package/dist/actors/binding-store.d.ts.map +1 -1
- package/dist/actors/directory.d.ts.map +1 -1
- package/dist/actors/feedback.d.ts +5 -0
- package/dist/actors/feedback.d.ts.map +1 -0
- package/dist/actors/global-registry.d.ts +8 -0
- package/dist/actors/global-registry.d.ts.map +1 -1
- package/dist/actors/host-event-payload.d.ts +14 -0
- package/dist/actors/host-event-payload.d.ts.map +1 -1
- package/dist/actors/manager.d.ts +4 -3
- package/dist/actors/manager.d.ts.map +1 -1
- package/dist/actors/mesh-monitor.d.ts +2 -0
- package/dist/actors/mesh-monitor.d.ts.map +1 -1
- package/dist/actors/name-policy.d.ts +3 -0
- package/dist/actors/name-policy.d.ts.map +1 -0
- package/dist/actors/registry-store.d.ts +14 -5
- package/dist/actors/registry-store.d.ts.map +1 -1
- package/dist/actors/store-read.d.ts +16 -0
- package/dist/actors/store-read.d.ts.map +1 -0
- package/dist/agents/agent-files.d.ts +80 -0
- package/dist/agents/agent-files.d.ts.map +1 -0
- package/dist/agents/agent-files.js +327 -0
- package/dist/agents/agent-files.js.map +7 -0
- package/dist/agents/child-skills.d.ts +60 -0
- package/dist/agents/child-skills.d.ts.map +1 -0
- package/dist/agents/child-skills.js +94 -0
- package/dist/agents/child-skills.js.map +7 -0
- package/dist/agents/clone-first-worktree.d.ts +6 -0
- package/dist/agents/clone-first-worktree.d.ts.map +1 -1
- package/dist/agents/completion-inbox.d.ts.map +1 -1
- package/dist/agents/cow-clone.d.ts.map +1 -1
- package/dist/agents/handoff.d.ts +12 -2
- package/dist/agents/handoff.d.ts.map +1 -1
- package/dist/agents/herdr-status.d.ts +26 -0
- package/dist/agents/herdr-status.d.ts.map +1 -0
- package/dist/agents/herdr-status.js +161 -0
- package/dist/agents/herdr-status.js.map +7 -0
- package/dist/agents/hosted-run.d.ts +20 -4
- package/dist/agents/hosted-run.d.ts.map +1 -1
- package/dist/agents/manager.d.ts +18 -2
- package/dist/agents/manager.d.ts.map +1 -1
- package/dist/agents/model-pin-guard.d.ts +27 -0
- package/dist/agents/model-pin-guard.d.ts.map +1 -0
- package/dist/agents/model-pin-guard.js +86 -0
- package/dist/agents/model-pin-guard.js.map +7 -0
- package/dist/agents/model-pin.d.ts +25 -0
- package/dist/agents/model-pin.d.ts.map +1 -0
- package/dist/agents/provider-bridge.d.ts +7 -6
- package/dist/agents/provider-bridge.d.ts.map +1 -1
- package/dist/agents/provider-bridge.js +33 -5
- package/dist/agents/provider-bridge.js.map +3 -3
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents/result.d.ts.map +1 -1
- package/dist/agents/result.js +1 -1
- package/dist/agents/runner-notice.d.ts.map +1 -1
- package/dist/agents/runner-protocol.d.ts +8 -0
- package/dist/agents/runner-protocol.d.ts.map +1 -1
- package/dist/agents/service-schema.d.ts.map +1 -1
- package/dist/agents/transports/herdr-core-socket.d.ts +13 -0
- package/dist/agents/transports/herdr-core-socket.d.ts.map +1 -0
- package/dist/agents/transports/herdr-core-transport.d.ts +10 -0
- package/dist/agents/transports/herdr-core-transport.d.ts.map +1 -0
- package/dist/agents/transports/herdr-socket.d.ts +12 -0
- package/dist/agents/transports/herdr-socket.d.ts.map +1 -0
- package/dist/agents/transports/herdr-transport.d.ts.map +1 -1
- package/dist/agents/types.d.ts +51 -0
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/agents/worker-recovery.d.ts +75 -0
- package/dist/agents/worker-recovery.d.ts.map +1 -0
- package/dist/agents/worktree-manager.d.ts.map +1 -1
- package/dist/agents.js +12 -11
- package/dist/agents.js.map +2 -2
- package/dist/audit/details.d.ts +38 -1
- package/dist/audit/details.d.ts.map +1 -1
- package/dist/audit/projection.d.ts.map +1 -1
- package/dist/audit/trace-schema.d.ts +50 -0
- package/dist/audit/trace-schema.d.ts.map +1 -0
- package/dist/audit/trace.d.ts +2 -48
- package/dist/audit/trace.d.ts.map +1 -1
- package/dist/chunks/chunk-2RWNVCFD.js +483 -0
- package/dist/chunks/chunk-2RWNVCFD.js.map +7 -0
- package/dist/chunks/chunk-2SCMGO2Z.js +16 -0
- package/dist/chunks/chunk-2SCMGO2Z.js.map +7 -0
- package/dist/chunks/chunk-35EEGOH3.js +324 -0
- package/dist/chunks/chunk-35EEGOH3.js.map +7 -0
- package/dist/chunks/{chunk-UTOBAZ5T.js → chunk-37NIOSVU.js} +1 -1
- package/dist/chunks/chunk-37NIOSVU.js.map +7 -0
- package/dist/chunks/chunk-3IJEQBFS.js +25 -0
- package/dist/chunks/chunk-3IJEQBFS.js.map +7 -0
- package/dist/chunks/{chunk-EHQQ4KCX.js → chunk-3MOY6WIB.js} +84 -19
- package/dist/chunks/chunk-3MOY6WIB.js.map +7 -0
- package/dist/chunks/chunk-3VK6UGAN.js +64 -0
- package/dist/chunks/chunk-3VK6UGAN.js.map +7 -0
- package/dist/chunks/{chunk-ROTCDDOV.js → chunk-3XT5WHSG.js} +59 -119
- package/dist/chunks/chunk-3XT5WHSG.js.map +7 -0
- package/dist/chunks/{chunk-FIDUHKMM.js → chunk-4BYS4ZLY.js} +16 -16
- package/dist/chunks/chunk-4BYS4ZLY.js.map +7 -0
- package/dist/chunks/{chunk-UOM37PE4.js → chunk-4PBW54I2.js} +162 -92
- package/dist/chunks/chunk-4PBW54I2.js.map +7 -0
- package/dist/chunks/{chunk-ZEXCKK4K.js → chunk-4WKD3YM3.js} +3 -3
- package/dist/chunks/{chunk-PK4NIJEV.js → chunk-4XMXFHAR.js} +62 -3
- package/dist/chunks/chunk-4XMXFHAR.js.map +7 -0
- package/dist/chunks/{chunk-4EW7GVUR.js → chunk-56NMRVTV.js} +589 -377
- package/dist/chunks/chunk-56NMRVTV.js.map +7 -0
- package/dist/chunks/chunk-5QJFDKPN.js +179 -0
- package/dist/chunks/chunk-5QJFDKPN.js.map +7 -0
- package/dist/chunks/{chunk-P7CBPPHY.js → chunk-6GWDGTHC.js} +5 -5
- package/dist/chunks/{chunk-P7CBPPHY.js.map → chunk-6GWDGTHC.js.map} +1 -1
- package/dist/chunks/chunk-6HO2IUQ5.js +104 -0
- package/dist/chunks/chunk-6HO2IUQ5.js.map +7 -0
- package/dist/chunks/chunk-6OGYPHNQ.js +62 -0
- package/dist/chunks/chunk-6OGYPHNQ.js.map +7 -0
- package/dist/chunks/{chunk-G4TLWHRS.js → chunk-7N7IC3Z2.js} +4 -3
- package/dist/chunks/{chunk-G4TLWHRS.js.map → chunk-7N7IC3Z2.js.map} +2 -2
- package/dist/chunks/{chunk-5XBYFSI5.js → chunk-7YNE4NB2.js} +2 -2
- package/dist/chunks/chunk-ASOJYFKU.js +1316 -0
- package/dist/chunks/chunk-ASOJYFKU.js.map +7 -0
- package/dist/chunks/{chunk-NTC2MCB6.js → chunk-B5L3X3ID.js} +1 -1
- package/dist/chunks/{chunk-NTC2MCB6.js.map → chunk-B5L3X3ID.js.map} +1 -1
- package/dist/chunks/chunk-BIBRWZWQ.js +325 -0
- package/dist/chunks/chunk-BIBRWZWQ.js.map +7 -0
- package/dist/chunks/{chunk-K6QXUGS5.js → chunk-BMAEZNZ5.js} +2 -1
- package/dist/chunks/{chunk-FSB2VIRZ.js → chunk-CBIV747V.js} +14 -3
- package/dist/chunks/chunk-CBIV747V.js.map +7 -0
- package/dist/chunks/{chunk-CCHZXF6K.js → chunk-CXYJJ3HZ.js} +3 -3
- package/dist/chunks/{chunk-R2XQ6AHT.js → chunk-DGERP4VL.js} +22 -10
- package/dist/chunks/chunk-DGERP4VL.js.map +7 -0
- package/dist/chunks/{chunk-C7Z6F3SO.js → chunk-DGUXJSYA.js} +64 -33
- package/dist/chunks/chunk-DGUXJSYA.js.map +7 -0
- package/dist/chunks/chunk-F2LGSRIN.js +38 -0
- package/dist/chunks/chunk-F2LGSRIN.js.map +7 -0
- package/dist/chunks/chunk-F6A6MQ6G.js +609 -0
- package/dist/chunks/chunk-F6A6MQ6G.js.map +7 -0
- package/dist/chunks/{chunk-IR3PIHJM.js → chunk-FK73YJKV.js} +67 -2
- package/dist/chunks/chunk-FK73YJKV.js.map +7 -0
- package/dist/chunks/{chunk-XCEEQ5AB.js → chunk-G2DZJ5LK.js} +1607 -1567
- package/dist/chunks/chunk-G2DZJ5LK.js.map +7 -0
- package/dist/chunks/{chunk-VYQV5JRT.js → chunk-GJVKEHDL.js} +2 -2
- package/dist/chunks/chunk-GJVKEHDL.js.map +7 -0
- package/dist/chunks/{chunk-TIIIHPHF.js → chunk-GS67KDMV.js} +2 -2
- package/dist/chunks/{chunk-D5NYNIST.js → chunk-H57KPL3V.js} +5 -5
- package/dist/chunks/{chunk-KVYNGDGC.js → chunk-HFDJWLMS.js} +6 -6
- package/dist/chunks/{chunk-KVYNGDGC.js.map → chunk-HFDJWLMS.js.map} +1 -1
- package/dist/chunks/{chunk-INRXG4J5.js → chunk-HGD75NZY.js} +2 -2
- package/dist/chunks/{chunk-CRRUW26I.js → chunk-HRDMBGMY.js} +12 -12
- package/dist/chunks/{chunk-CRRUW26I.js.map → chunk-HRDMBGMY.js.map} +2 -2
- package/dist/chunks/{chunk-GO32KSEZ.js → chunk-HRVYXRWZ.js} +85 -10
- package/dist/chunks/chunk-HRVYXRWZ.js.map +7 -0
- package/dist/chunks/{chunk-MLLYR3Y6.js → chunk-HSEZPCL5.js} +19 -78
- package/dist/chunks/chunk-HSEZPCL5.js.map +7 -0
- package/dist/chunks/chunk-JMUUNW2H.js +65 -0
- package/dist/chunks/chunk-JMUUNW2H.js.map +7 -0
- package/dist/chunks/{chunk-UXIBKMUM.js → chunk-KIFOEBYJ.js} +4 -4
- package/dist/chunks/{chunk-3FJUP3GV.js → chunk-L6H46CPY.js} +2 -2
- package/dist/chunks/{chunk-SPCJXN4K.js → chunk-LKYLD5SN.js} +298 -65
- package/dist/chunks/chunk-LKYLD5SN.js.map +7 -0
- package/dist/chunks/{chunk-K7J2ABAZ.js → chunk-LRSZFYUC.js} +92 -32
- package/dist/chunks/chunk-LRSZFYUC.js.map +7 -0
- package/dist/chunks/{chunk-GIK2WNAK.js → chunk-LZ2ZXOCU.js} +112 -23
- package/dist/chunks/chunk-LZ2ZXOCU.js.map +7 -0
- package/dist/chunks/{chunk-FUY6XVRX.js → chunk-MPMEK3IQ.js} +2 -2
- package/dist/chunks/{chunk-HP5P7NBO.js → chunk-MSDL7U6Q.js} +4 -4
- package/dist/chunks/{chunk-ASSLHWZS.js → chunk-MX53BRAC.js} +2 -2
- package/dist/chunks/chunk-N7ZAK2PB.js +132 -0
- package/dist/chunks/chunk-N7ZAK2PB.js.map +7 -0
- package/dist/chunks/{chunk-VSDUSNIA.js → chunk-NBIYYMKS.js} +8 -2
- package/dist/chunks/chunk-NBIYYMKS.js.map +7 -0
- package/dist/chunks/chunk-NENQZCGW.js +45 -0
- package/dist/chunks/chunk-NENQZCGW.js.map +7 -0
- package/dist/chunks/chunk-NJHJKINP.js +47 -0
- package/dist/chunks/chunk-NJHJKINP.js.map +7 -0
- package/dist/chunks/{chunk-U366I5K2.js → chunk-NQ7IWEIF.js} +18 -6
- package/dist/chunks/chunk-NQ7IWEIF.js.map +7 -0
- package/dist/chunks/{chunk-ZQMBS5SH.js → chunk-OJ4HAALD.js} +15 -12
- package/dist/chunks/chunk-OJ4HAALD.js.map +7 -0
- package/dist/chunks/chunk-OZCJU3PZ.js +33 -0
- package/dist/chunks/chunk-OZCJU3PZ.js.map +7 -0
- package/dist/chunks/chunk-P3DCXKL3.js +40 -0
- package/dist/chunks/chunk-P3DCXKL3.js.map +7 -0
- package/dist/chunks/chunk-P7YSPKTM.js +294 -0
- package/dist/chunks/chunk-P7YSPKTM.js.map +7 -0
- package/dist/chunks/chunk-PQVUMJ5J.js +223 -0
- package/dist/chunks/chunk-PQVUMJ5J.js.map +7 -0
- package/dist/chunks/chunk-PUBHBEYO.js +84 -0
- package/dist/chunks/chunk-PUBHBEYO.js.map +7 -0
- package/dist/chunks/{chunk-P4KH4S4S.js → chunk-QGTD3LAZ.js} +5 -20
- package/dist/chunks/chunk-QGTD3LAZ.js.map +7 -0
- package/dist/chunks/{chunk-TIJ3YQXX.js → chunk-QOEOKW2X.js} +2 -2
- package/dist/chunks/{chunk-TIJ3YQXX.js.map → chunk-QOEOKW2X.js.map} +1 -1
- package/dist/chunks/{chunk-QT4W5YVB.js → chunk-RAA3FAYZ.js} +2 -2
- package/dist/chunks/{chunk-3UGN25XS.js → chunk-RKJPBTBB.js} +98 -1664
- package/dist/chunks/chunk-RKJPBTBB.js.map +7 -0
- package/dist/chunks/{chunk-WJJXODAB.js → chunk-RLKRZXSX.js} +8 -1
- package/dist/chunks/{chunk-WJJXODAB.js.map → chunk-RLKRZXSX.js.map} +2 -2
- package/dist/chunks/chunk-RWKQ5SRW.js +129 -0
- package/dist/chunks/chunk-RWKQ5SRW.js.map +7 -0
- package/dist/chunks/chunk-SW25R47N.js +71 -0
- package/dist/chunks/chunk-SW25R47N.js.map +7 -0
- package/dist/chunks/{chunk-EKODKR6Y.js → chunk-TEMKDJJY.js} +148 -72
- package/dist/chunks/chunk-TEMKDJJY.js.map +7 -0
- package/dist/chunks/{chunk-EFETPXU2.js → chunk-TJZYM2SP.js} +118 -237
- package/dist/chunks/chunk-TJZYM2SP.js.map +7 -0
- package/dist/chunks/{chunk-53N2I4QA.js → chunk-TXCNZCZP.js} +2 -2
- package/dist/chunks/{chunk-LNASO4VT.js → chunk-U6Y6TKJL.js} +45 -20
- package/dist/chunks/chunk-U6Y6TKJL.js.map +7 -0
- package/dist/chunks/chunk-UD7LFV43.js +28 -0
- package/dist/chunks/chunk-UD7LFV43.js.map +7 -0
- package/dist/chunks/{chunk-7QKKLBHJ.js → chunk-UPMWLOKL.js} +10 -1
- package/dist/chunks/{chunk-7QKKLBHJ.js.map → chunk-UPMWLOKL.js.map} +2 -2
- package/dist/chunks/chunk-V4OW2ULC.js +422 -0
- package/dist/chunks/chunk-V4OW2ULC.js.map +7 -0
- package/dist/chunks/{chunk-FE6NOAO7.js → chunk-VGRUWTMG.js} +1993 -659
- package/dist/chunks/chunk-VGRUWTMG.js.map +7 -0
- package/dist/chunks/{chunk-PYFJW3HC.js → chunk-W5FEHVZA.js} +2 -16
- package/dist/chunks/{chunk-PYFJW3HC.js.map → chunk-W5FEHVZA.js.map} +3 -3
- package/dist/chunks/chunk-WKFRGICG.js +101 -0
- package/dist/chunks/chunk-WKFRGICG.js.map +7 -0
- package/dist/chunks/{chunk-LEU5CDSL.js → chunk-XFOSUGLU.js} +5 -5
- package/dist/chunks/{chunk-MZUC6LLH.js → chunk-XMYG2TKR.js} +4 -4
- package/dist/chunks/{chunk-MZUC6LLH.js.map → chunk-XMYG2TKR.js.map} +1 -1
- package/dist/chunks/chunk-YC65P7ZO.js +57 -0
- package/dist/chunks/chunk-YC65P7ZO.js.map +7 -0
- package/dist/chunks/{chunk-5UBRGTVN.js → chunk-ZHROHNEE.js} +31 -15
- package/dist/chunks/chunk-ZHROHNEE.js.map +7 -0
- package/dist/cli/decisions.d.ts.map +1 -1
- package/dist/cli/decisions.js +15 -3
- package/dist/cli/decisions.js.map +2 -2
- package/dist/cli/mesh.js +4 -3
- package/dist/cli/mesh.js.map +1 -1
- package/dist/commands/fabric-handler.d.ts +7 -0
- package/dist/commands/fabric-handler.d.ts.map +1 -0
- package/dist/commands/fabric-handler.js +916 -0
- package/dist/commands/fabric-handler.js.map +7 -0
- package/dist/commands/fabric.d.ts +11 -1
- package/dist/commands/fabric.d.ts.map +1 -1
- package/dist/compaction/claim-events.d.ts +61 -0
- package/dist/compaction/claim-events.d.ts.map +1 -0
- package/dist/compaction/claim-events.js +210 -0
- package/dist/compaction/claim-events.js.map +7 -0
- package/dist/compaction/claim.d.ts +51 -0
- package/dist/compaction/claim.d.ts.map +1 -0
- package/dist/compaction/hook.d.ts +28 -2
- package/dist/compaction/hook.d.ts.map +1 -1
- package/dist/compaction/hook.js +12 -7
- package/dist/compaction/owner.js +9 -8
- package/dist/compaction/trace-events.d.ts +1 -1
- package/dist/compaction/trace-events.d.ts.map +1 -1
- package/dist/components/configuration.js +6 -6
- package/dist/components/effect-scope.d.ts.map +1 -1
- package/dist/config.d.ts +40 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/core/action-arguments.d.ts.map +1 -1
- package/dist/core/action-policy-hooks.d.ts +69 -0
- package/dist/core/action-policy-hooks.d.ts.map +1 -0
- package/dist/core/action-registry.d.ts +31 -10
- package/dist/core/action-registry.d.ts.map +1 -1
- package/dist/core/action-registry.js +12 -9
- package/dist/core/approval-controller.d.ts +23 -3
- package/dist/core/approval-controller.d.ts.map +1 -1
- package/dist/core/atomic-write.d.ts +164 -0
- package/dist/core/atomic-write.d.ts.map +1 -1
- package/dist/core/call-presentation.d.ts +14 -0
- package/dist/core/call-presentation.d.ts.map +1 -0
- package/dist/core/child-tool-allowlist.d.ts +17 -1
- package/dist/core/child-tool-allowlist.d.ts.map +1 -1
- package/dist/core/compact-controller.d.ts +34 -0
- package/dist/core/compact-controller.d.ts.map +1 -1
- package/dist/core/core-override-guidance.d.ts +3 -1
- package/dist/core/core-override-guidance.d.ts.map +1 -1
- package/dist/core/file-lock.d.ts.map +1 -1
- package/dist/core/foreground-tools.d.ts +4 -1
- package/dist/core/foreground-tools.d.ts.map +1 -1
- package/dist/core/host-policy.d.ts +43 -0
- package/dist/core/host-policy.d.ts.map +1 -0
- package/dist/core/host-sdk-runtime.d.ts.map +1 -1
- package/dist/core/host-sdk.d.ts.map +1 -1
- package/dist/core/host-sdk.js +1 -1
- package/dist/core/managed-host-guidance.d.ts +5 -0
- package/dist/core/managed-host-guidance.d.ts.map +1 -0
- package/dist/core/model-aliases.d.ts +22 -0
- package/dist/core/model-aliases.d.ts.map +1 -0
- package/dist/core/model-resolution.d.ts +41 -20
- package/dist/core/model-resolution.d.ts.map +1 -1
- package/dist/core/native-tool-result.d.ts +1 -0
- package/dist/core/native-tool-result.d.ts.map +1 -1
- package/dist/core/program-tasks.d.ts +52 -0
- package/dist/core/program-tasks.d.ts.map +1 -0
- package/dist/core/prompt-guidance.d.ts +5 -0
- package/dist/core/prompt-guidance.d.ts.map +1 -0
- package/dist/core/prompt-guidance.js +159 -0
- package/dist/core/prompt-guidance.js.map +7 -0
- package/dist/core/provider-operations.d.ts.map +1 -1
- package/dist/core/provider-operations.js +60 -108
- package/dist/core/provider-operations.js.map +3 -3
- package/dist/core/shell-inbox.d.ts.map +1 -1
- package/dist/core/shell-jobs.d.ts +7 -5
- package/dist/core/shell-jobs.d.ts.map +1 -1
- package/dist/core/shell-timing.d.ts.map +1 -1
- package/dist/core/skill-prompt.d.ts +1 -1
- package/dist/core/skill-prompt.d.ts.map +1 -1
- package/dist/core/skill-references.d.ts +1 -1
- package/dist/core/skill-references.d.ts.map +1 -1
- package/dist/core/system-guidance.d.ts.map +1 -1
- package/dist/core/tool-result-proxy.d.ts.map +1 -1
- package/dist/decisions/command.d.ts +2 -1
- package/dist/decisions/command.d.ts.map +1 -1
- package/dist/decisions/command.js +40 -12
- package/dist/decisions/command.js.map +2 -2
- package/dist/decisions/events.d.ts +12 -0
- package/dist/decisions/events.d.ts.map +1 -0
- package/dist/decisions/events.js +130 -0
- package/dist/decisions/events.js.map +7 -0
- package/dist/decisions/host.d.ts +31 -3
- package/dist/decisions/host.d.ts.map +1 -1
- package/dist/decisions/render.d.ts +44 -0
- package/dist/decisions/render.d.ts.map +1 -0
- package/dist/decisions/store.d.ts +8 -0
- package/dist/decisions/store.d.ts.map +1 -1
- package/dist/durable/agent.d.ts +8 -0
- package/dist/durable/agent.d.ts.map +1 -1
- package/dist/durable/extension-load-error.d.ts +8 -0
- package/dist/durable/extension-load-error.d.ts.map +1 -0
- package/dist/durable/session.d.ts +1 -0
- package/dist/durable/session.d.ts.map +1 -1
- package/dist/durable/worker-host.d.ts +10 -1
- package/dist/durable/worker-host.d.ts.map +1 -1
- package/dist/durable/worker-host.js +10 -1181
- package/dist/durable/worker-host.js.map +4 -4
- package/dist/durable/worker-options.d.ts +3 -0
- package/dist/durable/worker-options.d.ts.map +1 -1
- package/dist/durable/worker-role-seed.d.ts +82 -0
- package/dist/durable/worker-role-seed.d.ts.map +1 -0
- package/dist/durable/worker.js +43 -4
- package/dist/durable/worker.js.map +2 -2
- package/dist/durable-controls.d.ts.map +1 -1
- package/dist/durable-extension-wasm.d.ts +8 -0
- package/dist/durable-extension-wasm.d.ts.map +1 -0
- package/dist/durable-extension-wasm.js +32 -0
- package/dist/durable-extension-wasm.js.map +7 -0
- package/dist/durable-extension.d.ts +94 -0
- package/dist/durable-extension.d.ts.map +1 -0
- package/dist/durable-extension.js +649 -0
- package/dist/durable-extension.js.map +7 -0
- package/dist/durable-host.d.ts +8 -0
- package/dist/durable-host.d.ts.map +1 -0
- package/dist/durable-host.js +20 -0
- package/dist/durable-host.js.map +7 -0
- package/dist/durable-journal.d.ts +94 -0
- package/dist/durable-journal.d.ts.map +1 -0
- package/dist/durable.d.ts.map +1 -1
- package/dist/durable.js +13 -10
- package/dist/durable.js.map +2 -2
- package/dist/entropy/index.js +12 -10
- package/dist/entropy/pool-store.d.ts.map +1 -1
- package/dist/execution-service.d.ts +14 -0
- package/dist/execution-service.d.ts.map +1 -1
- package/dist/extension-bootstrap.d.ts.map +1 -1
- package/dist/extension-bootstrap.js +28 -27
- package/dist/extension-bootstrap.js.map +2 -2
- package/dist/extension-copy.d.ts +21 -0
- package/dist/extension-copy.d.ts.map +1 -0
- package/dist/extension-copy.js +90 -0
- package/dist/extension-copy.js.map +7 -0
- package/dist/extension.d.ts +1 -1
- package/dist/extension.d.ts.map +1 -1
- package/dist/fabric-exec-arguments.d.ts.map +1 -1
- package/dist/fabric-exec-tool.d.ts +2 -1
- package/dist/fabric-exec-tool.d.ts.map +1 -1
- package/dist/fabric-runtime-state.d.ts +19 -0
- package/dist/fabric-runtime-state.d.ts.map +1 -1
- package/dist/fabric-runtime-state.js +2205 -839
- package/dist/fabric-runtime-state.js.map +4 -4
- package/dist/fabric-state.d.ts +44 -1
- package/dist/fabric-state.d.ts.map +1 -1
- package/dist/feedback.d.ts +5 -0
- package/dist/feedback.d.ts.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +88 -53
- package/dist/index.js.map +2 -2
- package/dist/jev/client.js +2 -2
- package/dist/jev/manager.d.ts +3 -0
- package/dist/jev/manager.d.ts.map +1 -1
- package/dist/jev/observation.d.ts +1 -1
- package/dist/jev/observation.js +6 -6
- package/dist/jev-fabric/bridge.d.ts.map +1 -1
- package/dist/jev.js +11 -12
- package/dist/main-agent.d.ts +2 -1
- package/dist/main-agent.d.ts.map +1 -1
- package/dist/managed-host.d.ts +13 -0
- package/dist/managed-host.d.ts.map +1 -1
- package/dist/memory/digest.js +2 -2
- package/dist/memory/discovery.js +6 -7
- package/dist/memory/file-worker.js +10 -11
- package/dist/memory/file-worker.js.map +1 -1
- package/dist/memory/normalize.js +5 -6
- package/dist/memory/search.js +7 -8
- package/dist/memory/worker-provider.js +11 -12
- package/dist/memory.js +11 -12
- package/dist/memory.js.map +1 -1
- package/dist/mesh/grants.d.ts +3 -3
- package/dist/mesh/grants.d.ts.map +1 -1
- package/dist/mesh/store.d.ts +8 -0
- package/dist/mesh/store.d.ts.map +1 -1
- package/dist/native-codemode.d.ts.map +1 -1
- package/dist/native-tool-catalog.d.ts.map +1 -1
- package/dist/native-tool-catalog.js +12 -3
- package/dist/native-tool-catalog.js.map +2 -2
- package/dist/programs/host.d.ts +18 -6
- package/dist/programs/host.d.ts.map +1 -1
- package/dist/programs/host.js +71 -47
- package/dist/programs/host.js.map +2 -2
- package/dist/programs/source.d.ts +11 -0
- package/dist/programs/source.d.ts.map +1 -1
- package/dist/programs/store.d.ts.map +1 -1
- package/dist/protocol.d.ts +504 -8
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +41 -11
- package/dist/provider-globals.d.ts +13 -0
- package/dist/provider-globals.d.ts.map +1 -0
- package/dist/providers/agents-actions.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/captured-tools-provider.d.ts +5 -0
- package/dist/providers/captured-tools-provider.d.ts.map +1 -1
- package/dist/providers/compact-provider.d.ts +4 -1
- package/dist/providers/compact-provider.d.ts.map +1 -1
- package/dist/providers/components-provider.d.ts.map +1 -1
- package/dist/providers/decisions-provider.d.ts +9 -1
- package/dist/providers/decisions-provider.d.ts.map +1 -1
- package/dist/providers/jev-provider.d.ts +1 -1
- package/dist/providers/jev-provider.js +11 -12
- package/dist/providers/memory-provider.js +10 -11
- package/dist/providers/pi-tools-provider.d.ts +14 -0
- package/dist/providers/pi-tools-provider.d.ts.map +1 -1
- package/dist/providers/programs-provider.d.ts.map +1 -1
- package/dist/providers/sessions-provider.d.ts +7 -0
- package/dist/providers/sessions-provider.d.ts.map +1 -1
- package/dist/repeat-guard.d.ts +7 -6
- package/dist/repeat-guard.d.ts.map +1 -1
- package/dist/residency/actor-client.js +3 -3
- package/dist/residency/client.d.ts +15 -0
- package/dist/residency/client.d.ts.map +1 -1
- package/dist/residency/host.d.ts.map +1 -1
- package/dist/residency/host.js +34 -23
- package/dist/residency/launcher.js +1 -1
- package/dist/residency/pi-entry.js +34 -23
- package/dist/residency/pi-entry.js.map +1 -1
- package/dist/residency/protocol.d.ts +2 -0
- package/dist/residency/protocol.d.ts.map +1 -1
- package/dist/runners.js +11 -1
- package/dist/runners.js.map +2 -2
- 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 +51 -21
- package/dist/runtime/cpython-runtime.js.map +2 -2
- package/dist/runtime/deadline-pause.d.ts +2 -0
- package/dist/runtime/deadline-pause.d.ts.map +1 -1
- package/dist/runtime/dynamic-guest-types.d.ts.map +1 -1
- package/dist/runtime/dynamic-guest-types.js +2 -1
- package/dist/runtime/exec-journal.d.ts +73 -0
- package/dist/runtime/exec-journal.d.ts.map +1 -0
- package/dist/runtime/exec-journal.js +335 -0
- package/dist/runtime/exec-journal.js.map +7 -0
- package/dist/runtime/guest-types.d.ts +3 -2
- package/dist/runtime/guest-types.d.ts.map +1 -1
- package/dist/runtime/guest-types.js +1 -1
- package/dist/runtime/journal-shim.d.ts +3 -0
- package/dist/runtime/journal-shim.d.ts.map +1 -0
- package/dist/runtime/kernel.d.ts +95 -1
- package/dist/runtime/kernel.d.ts.map +1 -1
- package/dist/runtime/monty-bridge.d.ts +6 -2
- package/dist/runtime/monty-bridge.d.ts.map +1 -1
- package/dist/runtime/monty-runtime.d.ts.map +1 -1
- package/dist/runtime/monty-runtime.js +27 -15
- package/dist/runtime/monty-runtime.js.map +2 -2
- package/dist/runtime/native-codemode-guest.d.ts.map +1 -1
- package/dist/runtime/node-process-runtime.d.ts.map +1 -1
- package/dist/runtime/node-process-runtime.js +7 -5
- package/dist/runtime/quickjs-runtime.d.ts +7 -1
- package/dist/runtime/quickjs-runtime.d.ts.map +1 -1
- package/dist/runtime/quickjs-runtime.js +5 -4
- package/dist/runtime/sha256.d.ts +4 -0
- package/dist/runtime/sha256.d.ts.map +1 -0
- package/dist/runtime/transpile.d.ts +8 -0
- package/dist/runtime/transpile.d.ts.map +1 -0
- package/dist/runtime/type-checker.d.ts +1 -7
- package/dist/runtime/type-checker.d.ts.map +1 -1
- package/dist/runtime/type-checker.js +4 -2
- package/dist/runtime/typescript-kernel.js +13 -10
- package/dist/runtime/typescript-kernel.js.map +1 -1
- package/dist/runtime-state-builtins.d.ts.map +1 -1
- package/dist/speculation/scanner.js +1 -1
- package/dist/speculation/store.d.ts +7 -16
- package/dist/speculation/store.d.ts.map +1 -1
- package/dist/speculation/types.d.ts +1 -0
- package/dist/speculation/types.d.ts.map +1 -1
- package/dist/storage/retention.d.ts.map +1 -1
- package/dist/topology/participant-directory.d.ts +26 -1
- package/dist/topology/participant-directory.d.ts.map +1 -1
- package/dist/topology/peer-presence.d.ts.map +1 -1
- package/dist/topology/peer-settle.js +11 -0
- package/dist/topology/peer-settle.js.map +7 -0
- package/dist/topology/session-label-settings.d.ts +13 -0
- package/dist/topology/session-label-settings.d.ts.map +1 -0
- package/dist/topology/session-label.d.ts +60 -0
- package/dist/topology/session-label.d.ts.map +1 -0
- package/dist/topology/types.d.ts +27 -0
- package/dist/topology/types.d.ts.map +1 -1
- package/dist/type-error-guidance.js +1 -1
- package/dist/ui/controller.d.ts +1 -0
- package/dist/ui/controller.d.ts.map +1 -1
- package/dist/ui/conversation-chrome.d.ts.map +1 -1
- package/dist/ui/conversation-chrome.js +3 -2
- package/dist/ui/conversation-commands.d.ts +1 -1
- package/dist/ui/conversation-commands.d.ts.map +1 -1
- package/dist/ui/conversation-native-reader.js +2 -2
- package/dist/ui/conversation-selection.d.ts +4 -1
- 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 +25 -24
- package/dist/ui/conversation.d.ts.map +1 -1
- package/dist/ui/conversation.js +170 -339
- package/dist/ui/conversation.js.map +2 -2
- package/dist/ui/core-tool-render.d.ts +1 -0
- package/dist/ui/core-tool-render.d.ts.map +1 -1
- package/dist/ui/dashboard-model.d.ts.map +1 -1
- package/dist/ui/dashboard.d.ts.map +1 -1
- package/dist/ui/dashboard.js +23 -16
- package/dist/ui/dashboard.js.map +2 -2
- package/dist/ui/fabric-render.d.ts +7 -0
- package/dist/ui/fabric-render.d.ts.map +1 -1
- package/dist/ui/footer-dock.d.ts +48 -0
- package/dist/ui/footer-dock.d.ts.map +1 -0
- package/dist/ui/format.d.ts +7 -0
- package/dist/ui/format.d.ts.map +1 -1
- package/dist/ui/settings-sections-lifecycle.d.ts.map +1 -1
- package/dist/ui/settings-sections-presentation.d.ts.map +1 -1
- package/dist/ui/settings-values.d.ts +2 -1
- package/dist/ui/settings-values.d.ts.map +1 -1
- package/dist/ui/settings.js +60 -19
- package/dist/ui/settings.js.map +2 -2
- package/dist/ui/shell-hang-keys.d.ts +8 -1
- package/dist/ui/shell-hang-keys.d.ts.map +1 -1
- package/dist/ui/shell-tasks.d.ts +2 -2
- package/dist/ui/shell-tasks.d.ts.map +1 -1
- package/dist/ui/shell-tasks.js +27 -94
- package/dist/ui/shell-tasks.js.map +2 -2
- package/dist/ui/snapshot.d.ts.map +1 -1
- package/dist/ui/terminal-title.d.ts +41 -0
- package/dist/ui/terminal-title.d.ts.map +1 -0
- package/dist/ui/types.d.ts +4 -0
- package/dist/ui/types.d.ts.map +1 -1
- package/dist/ui/widget-keys.d.ts +5 -0
- package/dist/ui/widget-keys.d.ts.map +1 -0
- package/dist/ui/widget.d.ts +40 -18
- package/dist/ui/widget.d.ts.map +1 -1
- package/dist/ui/word-diff/line-emphasis.js +1603 -0
- package/dist/ui/word-diff/line-emphasis.js.map +7 -0
- package/dist/util.d.ts +2 -0
- package/dist/util.d.ts.map +1 -1
- package/dist/verified/authority.d.ts +2 -2
- package/dist/verified/authority.d.ts.map +1 -1
- package/dist/verified/budget.d.ts +4 -0
- package/dist/verified/budget.d.ts.map +1 -0
- package/dist/verified/generated/actor-name.d.ts +4 -0
- package/dist/verified/generated/actor-name.js +17 -0
- package/dist/verified/generated/authority.d.ts +4 -0
- package/dist/verified/generated/authority.js +28 -0
- package/dist/verified/generated/budget.d.ts +4 -0
- package/dist/verified/generated/budget.js +17 -0
- package/dist/verified/generated/compaction.d.ts +4 -0
- package/dist/verified/generated/compaction.js +19 -0
- package/dist/verified/generated/grants.d.ts +4 -0
- package/dist/verified/generated/grants.js +17 -0
- package/dist/verified/generated/lifecycle.d.ts +4 -0
- package/dist/verified/generated/lifecycle.js +50 -0
- package/dist/verified/generated/manifest.json +137 -48
- package/dist/verified/generated/policy.d.ts +17 -0
- package/dist/verified/generated/policy.js +211 -0
- package/dist/verified/generated/provider.d.ts +4 -0
- package/dist/verified/generated/provider.js +18 -0
- package/dist/verified/generated/resources.d.ts +6 -0
- package/dist/verified/generated/resources.js +73 -0
- package/dist/verified/generated/speculation.d.ts +6 -0
- package/dist/verified/generated/speculation.js +48 -0
- package/dist/verified/generated/storage.d.ts +4 -0
- package/dist/verified/generated/storage.js +18 -0
- package/dist/verified/grants.d.ts +22 -0
- package/dist/verified/grants.d.ts.map +1 -0
- package/dist/verified/lifecycle.d.ts +31 -0
- package/dist/verified/lifecycle.d.ts.map +1 -0
- package/dist/verified/machine.d.ts +18 -0
- package/dist/verified/machine.d.ts.map +1 -0
- package/dist/verified/memory.d.ts +1 -1
- package/dist/verified/memory.d.ts.map +1 -1
- package/dist/verified/nat.d.ts +1 -1
- package/dist/verified/nat.d.ts.map +1 -1
- package/dist/verified/policy.d.ts +17 -5
- package/dist/verified/policy.d.ts.map +1 -1
- package/dist/verified/provider.d.ts +22 -0
- package/dist/verified/provider.d.ts.map +1 -0
- package/dist/verified/resources.d.ts +21 -7
- package/dist/verified/resources.d.ts.map +1 -1
- package/dist/verified/speculation.d.ts +36 -0
- package/dist/verified/speculation.d.ts.map +1 -0
- package/dist/verified/storage.d.ts.map +1 -1
- package/dist/worker/missing-install.d.ts +8 -0
- package/dist/worker/missing-install.d.ts.map +1 -0
- package/dist/worker/options.d.ts.map +1 -1
- package/dist/worker/options.js +25 -0
- package/dist/worker/options.js.map +2 -2
- package/dist/worker/prompt-lifecycle.d.ts +16 -0
- package/dist/worker/prompt-lifecycle.d.ts.map +1 -0
- package/dist/worker/prompt-lifecycle.js +90 -0
- package/dist/worker/prompt-lifecycle.js.map +7 -0
- package/dist/worker/questions.d.ts +15 -3
- package/dist/worker/questions.d.ts.map +1 -1
- package/dist/worker/questions.js +53 -8
- package/dist/worker/questions.js.map +2 -2
- package/dist/worker/recovery-watchdog.d.ts +22 -0
- package/dist/worker/recovery-watchdog.d.ts.map +1 -1
- package/dist/worker/recovery-watchdog.js +116 -1
- package/dist/worker/recovery-watchdog.js.map +2 -2
- package/dist/worker/result.js +1 -1
- package/dist/worker/result.js.map +2 -2
- package/dist/worker.js +131 -21
- package/dist/worker.js.map +2 -2
- package/docs/actor-name-policy-handoff.md +5 -0
- package/docs/agents.md +172 -22
- package/docs/architecture.md +5 -1
- package/docs/audit-trace.md +2 -1
- package/docs/background-tasks.md +126 -28
- package/docs/codemode-parity.md +2 -2
- package/docs/compaction.md +21 -5
- package/docs/components.md +1 -1
- package/docs/configuration.md +113 -66
- package/docs/decisions.md +92 -10
- package/docs/durable-extension.md +121 -0
- package/docs/durable-pi.md +306 -6
- package/docs/extractive-history.md +3 -1
- package/docs/interface.md +22 -17
- package/docs/jev.md +2 -2
- package/docs/kernels.md +1 -1
- package/{node_modules/pi-coralbricks-provider/LICENSE → docs/licenses/gdp-wired-mit.txt} +1 -1
- package/docs/managed-host-migration.md +50 -0
- package/docs/programmatic-compaction.md +216 -6
- package/docs/programs.md +23 -1
- package/docs/prompt-cache.md +4 -2
- package/docs/provider-capabilities.md +15 -14
- package/docs/providers.md +99 -3
- package/docs/shell-composition.md +15 -0
- package/docs/short-lock-protocol.md +90 -0
- package/docs/skills.md +5 -1
- package/docs/speculation.md +6 -0
- package/docs/verified-kernels.md +309 -220
- package/package.json +45 -24
- package/proofs/actor-name.ts +27 -0
- package/proofs/authority.ts +62 -0
- package/proofs/budget.ts +24 -0
- package/proofs/compaction.ts +51 -0
- package/proofs/grants.ts +39 -0
- package/proofs/index.ts +40 -0
- package/proofs/kernel.ts +44 -0
- package/proofs/lifecycle.ts +128 -0
- package/proofs/policy.ts +195 -0
- package/proofs/provider.ts +52 -0
- package/proofs/resources.ts +160 -0
- package/proofs/speculation.ts +69 -0
- package/proofs/storage.ts +66 -0
- package/scripts/verified-kernels.ts +141 -0
- package/skillsets/python/fabric-council/SKILL.md +94 -20
- package/skillsets/python/fabric-exec/SKILL.md +2 -2
- package/skillsets/python/fabric-exec/references/agents.md +10 -4
- package/skillsets/python/fabric-fusion/SKILL.md +1 -1
- package/skillsets/python/fabric-guide/SKILL.md +1 -1
- package/skillsets/typescript/fabric-council/SKILL.md +110 -22
- package/skillsets/typescript/fabric-exec/SKILL.md +7 -7
- package/skillsets/typescript/fabric-exec/references/agents.md +17 -8
- package/skillsets/typescript/fabric-fusion/SKILL.md +1 -1
- package/skillsets/typescript/fabric-guide/SKILL.md +1 -1
- package/LAWS.bend +0 -502
- package/PROOF.bend +0 -452
- package/dist/chunks/chunk-3UGN25XS.js.map +0 -7
- package/dist/chunks/chunk-4EW7GVUR.js.map +0 -7
- package/dist/chunks/chunk-5UBRGTVN.js.map +0 -7
- package/dist/chunks/chunk-BN7F52EG.js +0 -525
- package/dist/chunks/chunk-BN7F52EG.js.map +0 -7
- package/dist/chunks/chunk-C7Z6F3SO.js.map +0 -7
- package/dist/chunks/chunk-DK35W6U7.js +0 -259
- package/dist/chunks/chunk-DK35W6U7.js.map +0 -7
- package/dist/chunks/chunk-EFETPXU2.js.map +0 -7
- package/dist/chunks/chunk-EHQQ4KCX.js.map +0 -7
- package/dist/chunks/chunk-EKODKR6Y.js.map +0 -7
- package/dist/chunks/chunk-FE6NOAO7.js.map +0 -7
- package/dist/chunks/chunk-FIDUHKMM.js.map +0 -7
- package/dist/chunks/chunk-FSB2VIRZ.js.map +0 -7
- package/dist/chunks/chunk-GIK2WNAK.js.map +0 -7
- package/dist/chunks/chunk-GO32KSEZ.js.map +0 -7
- package/dist/chunks/chunk-IR3PIHJM.js.map +0 -7
- package/dist/chunks/chunk-ITVLKXCI.js +0 -266
- package/dist/chunks/chunk-ITVLKXCI.js.map +0 -7
- package/dist/chunks/chunk-K7J2ABAZ.js.map +0 -7
- package/dist/chunks/chunk-KJZAOENY.js +0 -212
- package/dist/chunks/chunk-KJZAOENY.js.map +0 -7
- package/dist/chunks/chunk-LNASO4VT.js.map +0 -7
- package/dist/chunks/chunk-MLLYR3Y6.js.map +0 -7
- package/dist/chunks/chunk-P4KH4S4S.js.map +0 -7
- package/dist/chunks/chunk-PK4NIJEV.js.map +0 -7
- package/dist/chunks/chunk-Q2JQ3RYZ.js +0 -99
- package/dist/chunks/chunk-Q2JQ3RYZ.js.map +0 -7
- package/dist/chunks/chunk-R2XQ6AHT.js.map +0 -7
- package/dist/chunks/chunk-ROTCDDOV.js.map +0 -7
- package/dist/chunks/chunk-SPCJXN4K.js.map +0 -7
- package/dist/chunks/chunk-U366I5K2.js.map +0 -7
- package/dist/chunks/chunk-UKMQK5VP.js +0 -231
- package/dist/chunks/chunk-UKMQK5VP.js.map +0 -7
- package/dist/chunks/chunk-UOM37PE4.js.map +0 -7
- package/dist/chunks/chunk-UTOBAZ5T.js.map +0 -7
- package/dist/chunks/chunk-VSDUSNIA.js.map +0 -7
- package/dist/chunks/chunk-VTK2FEH7.js +0 -229
- package/dist/chunks/chunk-VTK2FEH7.js.map +0 -7
- package/dist/chunks/chunk-VYQV5JRT.js.map +0 -7
- package/dist/chunks/chunk-XCEEQ5AB.js.map +0 -7
- package/dist/chunks/chunk-ZLNJDTCN.js +0 -226
- package/dist/chunks/chunk-ZLNJDTCN.js.map +0 -7
- package/dist/chunks/chunk-ZQMBS5SH.js.map +0 -7
- package/dist/ui/conversation-shortcut.d.ts +0 -3
- package/dist/ui/conversation-shortcut.d.ts.map +0 -1
- package/dist/ui/widget-activity.d.ts +0 -21
- package/dist/ui/widget-activity.d.ts.map +0 -1
- package/dist/verified/generated/authority-kernel.d.ts +0 -10
- package/dist/verified/generated/authority-kernel.js +0 -127
- package/dist/verified/generated/kernel.d.ts +0 -31
- package/dist/verified/generated/kernel.js +0 -389
- package/dist/verified/generated/lifecycle-kernel.d.ts +0 -7
- package/dist/verified/generated/lifecycle-kernel.js +0 -164
- package/dist/verified/generated/provider-kernel.d.ts +0 -9
- package/dist/verified/generated/provider-kernel.js +0 -87
- package/dist/verified/generated/storage-kernel.d.ts +0 -11
- package/dist/verified/generated/storage-kernel.js +0 -107
- package/docs/licenses/bend-apache-2.0.txt +0 -202
- package/node_modules/pi-coralbricks-provider/README.md +0 -306
- package/node_modules/pi-coralbricks-provider/auth.ts +0 -30
- package/node_modules/pi-coralbricks-provider/custom-models.json +0 -1
- package/node_modules/pi-coralbricks-provider/deprecated-models.json +0 -1
- package/node_modules/pi-coralbricks-provider/guard.ts +0 -155
- package/node_modules/pi-coralbricks-provider/index.ts +0 -662
- package/node_modules/pi-coralbricks-provider/models.json +0 -88
- package/node_modules/pi-coralbricks-provider/package.json +0 -74
- package/node_modules/pi-coralbricks-provider/park.ts +0 -122
- package/node_modules/pi-coralbricks-provider/patch.json +0 -34
- package/node_modules/pi-coralbricks-provider/scripts/update-models.js +0 -658
- package/node_modules/pi-coralbricks-provider/settings.ts +0 -143
- package/node_modules/pi-coralbricks-provider/sync-policy.ts +0 -309
- package/proofs/abi.json +0 -308
- package/proofs/authority-abi.json +0 -7
- package/proofs/authority-kernel.bend +0 -23
- package/proofs/authority-proof.bend +0 -74
- package/proofs/authority-spec.bend +0 -30
- package/proofs/authority-state.bend +0 -43
- package/proofs/authority-types.d.ts +0 -3
- package/proofs/kernel.bend +0 -139
- package/proofs/lifecycle-abi.json +0 -3
- package/proofs/lifecycle-kernel.bend +0 -11
- package/proofs/lifecycle-proof.bend +0 -249
- package/proofs/lifecycle-spec.bend +0 -261
- package/proofs/lifecycle-types.d.ts +0 -4
- package/proofs/lifecycle.bend +0 -119
- package/proofs/provider-abi.json +0 -4
- package/proofs/provider-kernel.bend +0 -14
- package/proofs/provider-plans.bend +0 -28
- package/proofs/provider-spec.bend +0 -14
- package/proofs/provider-types.d.ts +0 -5
- package/proofs/resource-proof.bend +0 -633
- package/proofs/resource-spec.bend +0 -133
- package/proofs/resources.bend +0 -160
- package/proofs/state-kernel.bend +0 -17
- package/proofs/state-plans.bend +0 -40
- package/proofs/state-proof.bend +0 -42
- package/proofs/state-spec.bend +0 -26
- package/proofs/storage-abi.json +0 -3
- package/proofs/storage-kernel.bend +0 -11
- package/proofs/storage-plans.bend +0 -100
- package/proofs/storage-proof.bend +0 -176
- package/proofs/storage-spec.bend +0 -70
- package/proofs/storage-types.d.ts +0 -8
- package/proofs/types.d.ts +0 -7
- package/scripts/test-verified-kernels.mjs +0 -107
- package/scripts/verified-kernels.mjs +0 -176
- /package/dist/chunks/{chunk-ZEXCKK4K.js.map → chunk-4WKD3YM3.js.map} +0 -0
- /package/dist/chunks/{chunk-5XBYFSI5.js.map → chunk-7YNE4NB2.js.map} +0 -0
- /package/dist/chunks/{chunk-K6QXUGS5.js.map → chunk-BMAEZNZ5.js.map} +0 -0
- /package/dist/chunks/{chunk-CCHZXF6K.js.map → chunk-CXYJJ3HZ.js.map} +0 -0
- /package/dist/chunks/{chunk-TIIIHPHF.js.map → chunk-GS67KDMV.js.map} +0 -0
- /package/dist/chunks/{chunk-D5NYNIST.js.map → chunk-H57KPL3V.js.map} +0 -0
- /package/dist/chunks/{chunk-INRXG4J5.js.map → chunk-HGD75NZY.js.map} +0 -0
- /package/dist/chunks/{chunk-UXIBKMUM.js.map → chunk-KIFOEBYJ.js.map} +0 -0
- /package/dist/chunks/{chunk-3FJUP3GV.js.map → chunk-L6H46CPY.js.map} +0 -0
- /package/dist/chunks/{chunk-FUY6XVRX.js.map → chunk-MPMEK3IQ.js.map} +0 -0
- /package/dist/chunks/{chunk-HP5P7NBO.js.map → chunk-MSDL7U6Q.js.map} +0 -0
- /package/dist/chunks/{chunk-ASSLHWZS.js.map → chunk-MX53BRAC.js.map} +0 -0
- /package/dist/chunks/{chunk-QT4W5YVB.js.map → chunk-RAA3FAYZ.js.map} +0 -0
- /package/dist/chunks/{chunk-53N2I4QA.js.map → chunk-TXCNZCZP.js.map} +0 -0
- /package/dist/chunks/{chunk-LEU5CDSL.js.map → chunk-XFOSUGLU.js.map} +0 -0
|
@@ -26,11 +26,9 @@ import {
|
|
|
26
26
|
restoreFabricWritePreviews,
|
|
27
27
|
restoreLegacyBashCommands,
|
|
28
28
|
safeTerminalText,
|
|
29
|
+
shellBackgroundShortcut,
|
|
29
30
|
singleCallProgressLine
|
|
30
|
-
} from "./chunk-
|
|
31
|
-
import {
|
|
32
|
-
FabricModelSelector
|
|
33
|
-
} from "./chunk-J7ZQERKA.js";
|
|
31
|
+
} from "./chunk-RKJPBTBB.js";
|
|
34
32
|
import {
|
|
35
33
|
configureHighlighting,
|
|
36
34
|
highlightCode,
|
|
@@ -40,22 +38,19 @@ import {
|
|
|
40
38
|
activeStatuses,
|
|
41
39
|
isActiveStatus,
|
|
42
40
|
orderAgentsByCreation
|
|
43
|
-
} from "./chunk-
|
|
44
|
-
import {
|
|
45
|
-
buildModelSource
|
|
46
|
-
} from "./chunk-CQFP2RCP.js";
|
|
41
|
+
} from "./chunk-37NIOSVU.js";
|
|
47
42
|
import {
|
|
48
43
|
animationFitsViewport,
|
|
49
44
|
observeAnimationRows,
|
|
50
|
-
spinnerFrame,
|
|
51
45
|
updateSpinner
|
|
52
46
|
} from "./chunk-O4A5UOXU.js";
|
|
53
47
|
import {
|
|
48
|
+
borderBadge,
|
|
54
49
|
formatCost,
|
|
55
50
|
formatDuration,
|
|
56
51
|
formatTokens,
|
|
57
52
|
safeText
|
|
58
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-FK73YJKV.js";
|
|
59
54
|
import {
|
|
60
55
|
repairFabricGuestCode
|
|
61
56
|
} from "./chunk-VXZZJ44D.js";
|
|
@@ -83,76 +78,56 @@ import {
|
|
|
83
78
|
resolveFabricIdentity,
|
|
84
79
|
setModelSafely,
|
|
85
80
|
withTrajectoryRearmDirective
|
|
86
|
-
} from "./chunk-
|
|
81
|
+
} from "./chunk-DGUXJSYA.js";
|
|
87
82
|
import {
|
|
88
83
|
AgentTranscriptReader,
|
|
84
|
+
isRoutineInternalCall
|
|
85
|
+
} from "./chunk-TEMKDJJY.js";
|
|
86
|
+
import {
|
|
89
87
|
countNewlines,
|
|
88
|
+
editDistance,
|
|
90
89
|
truncateMiddle
|
|
91
|
-
} from "./chunk-
|
|
92
|
-
import {
|
|
93
|
-
FileLockTimeoutError
|
|
94
|
-
} from "./chunk-DK35W6U7.js";
|
|
95
|
-
import {
|
|
96
|
-
FABRIC_COMPONENT_REGISTER_EVENT,
|
|
97
|
-
FABRIC_NESTED_TOOL_CALL_ID_PREFIX,
|
|
98
|
-
FABRIC_PEER_AWAIT_SETTLE_EVENT,
|
|
99
|
-
FABRIC_PEER_CARDS_EVENT,
|
|
100
|
-
FABRIC_PREWALK_REQUEST_EVENT,
|
|
101
|
-
FABRIC_PROGRAM_RUN_EVENT,
|
|
102
|
-
FABRIC_PROVIDER_REGISTER_EVENT,
|
|
103
|
-
FABRIC_PROVIDER_WITHDRAW_EVENT,
|
|
104
|
-
FABRIC_TOOL_PLACEMENT_EVENT,
|
|
105
|
-
readFabricPeerAwaitSettleRequestV1,
|
|
106
|
-
readFabricPeerCardsRequestV1,
|
|
107
|
-
readFabricPrewalkRequestV1,
|
|
108
|
-
readFabricProviderWithdrawalV1,
|
|
109
|
-
readFabricToolPlacementRequestV1
|
|
110
|
-
} from "./chunk-Q2JQ3RYZ.js";
|
|
90
|
+
} from "./chunk-P3DCXKL3.js";
|
|
111
91
|
import {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
} from "./chunk-PYFJW3HC.js";
|
|
92
|
+
closeScratch,
|
|
93
|
+
createScratch
|
|
94
|
+
} from "./chunk-7YNE4NB2.js";
|
|
116
95
|
import {
|
|
117
96
|
resolveAgentDir
|
|
118
97
|
} from "./chunk-PBDDXBHY.js";
|
|
119
|
-
import {
|
|
120
|
-
closeScratch,
|
|
121
|
-
createScratch
|
|
122
|
-
} from "./chunk-5XBYFSI5.js";
|
|
123
98
|
import {
|
|
124
99
|
DEFAULT_FABRIC_CONFIG,
|
|
100
|
+
MAX_FOREGROUND_TOOLS,
|
|
125
101
|
NO_FOREGROUND,
|
|
126
102
|
effectiveToolCaptureConfig,
|
|
103
|
+
foregroundConfigValue,
|
|
127
104
|
formatForeground,
|
|
105
|
+
ineffectiveKeepVisible,
|
|
128
106
|
loadFabricConfig,
|
|
129
107
|
loadFabricConfigForScope,
|
|
130
|
-
resolveForegroundTools
|
|
131
|
-
|
|
132
|
-
} from "./chunk-K7J2ABAZ.js";
|
|
108
|
+
resolveForegroundTools
|
|
109
|
+
} from "./chunk-LRSZFYUC.js";
|
|
133
110
|
import {
|
|
134
111
|
defaultCodePreviewSettings
|
|
135
112
|
} from "./chunk-OKOHRXGF.js";
|
|
136
113
|
import {
|
|
137
114
|
compactAtConfiguredThreshold,
|
|
138
|
-
fabricExecTitleHintCached
|
|
139
|
-
|
|
140
|
-
registerCompactionHook
|
|
141
|
-
} from "./chunk-ROTCDDOV.js";
|
|
115
|
+
fabricExecTitleHintCached
|
|
116
|
+
} from "./chunk-3VK6UGAN.js";
|
|
142
117
|
import {
|
|
143
118
|
fabricWriteBindings
|
|
144
119
|
} from "./chunk-SZUXWOO7.js";
|
|
145
120
|
import {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
} from "./chunk-UKMQK5VP.js";
|
|
121
|
+
FileLockTimeoutError
|
|
122
|
+
} from "./chunk-WKFRGICG.js";
|
|
149
123
|
import {
|
|
150
|
-
|
|
151
|
-
|
|
124
|
+
ACTION_POLICY_HOOK_NAME_PATTERN,
|
|
125
|
+
FabricActionPolicyHooks
|
|
126
|
+
} from "./chunk-N7ZAK2PB.js";
|
|
152
127
|
import {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
} from "./chunk-
|
|
128
|
+
PI_CORE_TOOL_NAMES,
|
|
129
|
+
PI_CORE_TOOL_NAME_SET
|
|
130
|
+
} from "./chunk-YU62DDKK.js";
|
|
156
131
|
import {
|
|
157
132
|
registerJevAuth
|
|
158
133
|
} from "./chunk-5X35KXBV.js";
|
|
@@ -160,19 +135,62 @@ import {
|
|
|
160
135
|
ApprovalController,
|
|
161
136
|
FabricAutoApprovalClassifier,
|
|
162
137
|
FabricSessionApprovals
|
|
163
|
-
} from "./chunk-
|
|
138
|
+
} from "./chunk-4PBW54I2.js";
|
|
164
139
|
import {
|
|
165
140
|
getActiveRepairCompiler,
|
|
166
141
|
setActiveCompiledSurface
|
|
167
|
-
} from "./chunk-
|
|
142
|
+
} from "./chunk-TXCNZCZP.js";
|
|
143
|
+
import {
|
|
144
|
+
FABRIC_ACTION_POLICY_REGISTER_EVENT,
|
|
145
|
+
FABRIC_COMPACTION_OWNER_EVENT,
|
|
146
|
+
FABRIC_COMPONENT_REGISTER_EVENT,
|
|
147
|
+
FABRIC_DECISIONS_CAPABILITY_EVENT,
|
|
148
|
+
FABRIC_DECISION_REQUEST_EVENT,
|
|
149
|
+
FABRIC_EXECUTION_GUIDANCE_SLOT,
|
|
150
|
+
FABRIC_HOST_POLICY_EVENT,
|
|
151
|
+
FABRIC_HOST_POLICY_FIELDS,
|
|
152
|
+
FABRIC_NESTED_TOOL_CALL_ID_PREFIX,
|
|
153
|
+
FABRIC_PEER_AWAIT_SETTLE_EVENT,
|
|
154
|
+
FABRIC_PEER_CARDS_EVENT,
|
|
155
|
+
FABRIC_PREWALK_REQUEST_EVENT,
|
|
156
|
+
FABRIC_PROGRAM_RUN_EVENT,
|
|
157
|
+
FABRIC_PROVIDER_REGISTER_EVENT,
|
|
158
|
+
FABRIC_PROVIDER_WITHDRAW_EVENT,
|
|
159
|
+
FABRIC_QUESTION_RENDERER_REGISTER_EVENT,
|
|
160
|
+
FABRIC_TOOL_PLACEMENT_EVENT,
|
|
161
|
+
readFabricActionPolicyRegistrationV1,
|
|
162
|
+
readFabricDecisionRequestV1,
|
|
163
|
+
readFabricDecisionsCapabilityRequestV1,
|
|
164
|
+
readFabricHostPolicyRequestV1,
|
|
165
|
+
readFabricPeerAwaitSettleRequestV1,
|
|
166
|
+
readFabricPeerCardsRequestV1,
|
|
167
|
+
readFabricPrewalkRequestV1,
|
|
168
|
+
readFabricProviderWithdrawalV1,
|
|
169
|
+
readFabricQuestionRendererRegistrationV1,
|
|
170
|
+
readFabricToolPlacementRequestV1,
|
|
171
|
+
resolveFabricModelGuidance,
|
|
172
|
+
snapshotFabricProgramRunRequestV1
|
|
173
|
+
} from "./chunk-2RWNVCFD.js";
|
|
174
|
+
import {
|
|
175
|
+
normalizeRunDisplay
|
|
176
|
+
} from "./chunk-OZCJU3PZ.js";
|
|
168
177
|
import {
|
|
169
178
|
isFabricExecutionTraceV1,
|
|
170
179
|
readFabricExecutionTraceV1
|
|
171
|
-
} from "./chunk-
|
|
180
|
+
} from "./chunk-PUBHBEYO.js";
|
|
172
181
|
import {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
182
|
+
stableJsonHash
|
|
183
|
+
} from "./chunk-3YZUQESG.js";
|
|
184
|
+
import {
|
|
185
|
+
FABRIC_ACTOR_PI_HOST_EVENTS
|
|
186
|
+
} from "./chunk-IIPKG52D.js";
|
|
187
|
+
import {
|
|
188
|
+
FABRIC_THINKING_BOUNDS_ENV,
|
|
189
|
+
FABRIC_THINKING_ENTRY_TYPE
|
|
190
|
+
} from "./chunk-V73NIH6B.js";
|
|
191
|
+
import {
|
|
192
|
+
readChildToolAllowlist
|
|
193
|
+
} from "./chunk-6OGYPHNQ.js";
|
|
176
194
|
|
|
177
195
|
// src/audit/details.ts
|
|
178
196
|
var FABRIC_EXECUTION_DETAILS_MAX_BYTES = 512 * 1024;
|
|
@@ -207,7 +225,14 @@ var createFabricPersistedExecutionDetails = (input) => {
|
|
|
207
225
|
...input.outputFormatLines !== void 0 ? { outputFormatLines: Math.max(0, Math.floor(input.outputFormatLines)) } : {}
|
|
208
226
|
};
|
|
209
227
|
while (serializedBytes(details) > FABRIC_EXECUTION_DETAILS_MAX_BYTES && details.audits.length > 0) {
|
|
210
|
-
details.audits.pop();
|
|
228
|
+
const dropped = details.audits.pop();
|
|
229
|
+
const omitted = details.omittedCalls ?? { count: 0, done: 0 };
|
|
230
|
+
details.omittedCalls = {
|
|
231
|
+
count: omitted.count + 1,
|
|
232
|
+
done: omitted.done + (dropped.success !== void 0 ? 1 : 0),
|
|
233
|
+
...(omitted.internal ?? 0) + Number(isRoutineInternalCall(dropped)) > 0 ? { internal: (omitted.internal ?? 0) + Number(isRoutineInternalCall(dropped)) } : {},
|
|
234
|
+
...(omitted.failed ?? 0) + (dropped.success === false ? 1 : 0) > 0 ? { failed: (omitted.failed ?? 0) + (dropped.success === false ? 1 : 0) } : {}
|
|
235
|
+
};
|
|
211
236
|
}
|
|
212
237
|
while (serializedBytes(details) > FABRIC_EXECUTION_DETAILS_MAX_BYTES && details.assessment && details.assessment.operations.length > 0) {
|
|
213
238
|
details.assessment.operations.pop();
|
|
@@ -273,8 +298,101 @@ var readFabricExecutionRenderDetails = (value) => {
|
|
|
273
298
|
...typeof value.outputFormatStartLine === "number" && Number.isFinite(value.outputFormatStartLine) && value.outputFormatStartLine >= 0 ? { outputFormatStartLine: Math.floor(value.outputFormatStartLine) } : {},
|
|
274
299
|
...typeof value.outputFormatLines === "number" && Number.isFinite(value.outputFormatLines) && value.outputFormatLines >= 0 ? { outputFormatLines: Math.floor(value.outputFormatLines) } : {},
|
|
275
300
|
phases: oldPhases ?? trace?.phases ?? [],
|
|
276
|
-
audits: oldAudits ?? trace?.operations.map(auditFromOperation) ?? []
|
|
301
|
+
audits: oldAudits ?? trace?.operations.map(auditFromOperation) ?? [],
|
|
302
|
+
...omittedCalls(value.omittedCalls) ?? {}
|
|
303
|
+
};
|
|
304
|
+
};
|
|
305
|
+
var omittedCalls = (value) => {
|
|
306
|
+
if (!isRecord(value)) return void 0;
|
|
307
|
+
const { count, done, failed, internal } = value;
|
|
308
|
+
if (typeof count !== "number" || !Number.isInteger(count) || count <= 0) return void 0;
|
|
309
|
+
const finished = typeof done === "number" && Number.isInteger(done) ? Math.min(Math.max(0, done), count) : 0;
|
|
310
|
+
const failures = typeof failed === "number" && Number.isInteger(failed) ? Math.min(Math.max(0, failed), finished) : 0;
|
|
311
|
+
const plumbing = typeof internal === "number" && Number.isInteger(internal) ? Math.min(Math.max(0, internal), finished - failures) : 0;
|
|
312
|
+
return { omittedCalls: { count, done: finished, ...failures > 0 ? { failed: failures } : {}, ...plumbing > 0 ? { internal: plumbing } : {} } };
|
|
313
|
+
};
|
|
314
|
+
var FABRIC_PARTIAL_AUDITS_MAX_BYTES = 128 * 1024;
|
|
315
|
+
var FABRIC_PARTIAL_UPDATE_MAX_BYTES = 256 * 1024;
|
|
316
|
+
var PARTIAL_HEAD_AUDITS = 30;
|
|
317
|
+
var PARTIAL_TAIL_AUDITS = 30;
|
|
318
|
+
var PARTIAL_PHASES = 64;
|
|
319
|
+
var PARTIAL_PROGRESS_CHARS = 8e3;
|
|
320
|
+
var SLIM_ARG_KEYS = 8;
|
|
321
|
+
var SLIM_TEXT_CHARS = 240;
|
|
322
|
+
var clipText = (value, max) => value.length <= max ? value : `${value.slice(0, max)}\u2026`;
|
|
323
|
+
var slimAudit = (audit) => {
|
|
324
|
+
const args = {};
|
|
325
|
+
for (const [key, value] of Object.entries(audit.args ?? {}).slice(0, SLIM_ARG_KEYS)) {
|
|
326
|
+
if (typeof value === "string") args[key] = clipText(value, SLIM_TEXT_CHARS);
|
|
327
|
+
else if (typeof value === "number" || typeof value === "boolean" || value === null) args[key] = value;
|
|
328
|
+
}
|
|
329
|
+
return {
|
|
330
|
+
ref: audit.ref,
|
|
331
|
+
...audit.nestedToolCallId !== void 0 ? { nestedToolCallId: audit.nestedToolCallId } : {},
|
|
332
|
+
...audit.tool !== void 0 ? { tool: audit.tool } : {},
|
|
333
|
+
...audit.provider !== void 0 ? { provider: audit.provider } : {},
|
|
334
|
+
...audit.success !== void 0 ? { success: audit.success } : {},
|
|
335
|
+
...audit.error !== void 0 ? { error: clipText(audit.error, SLIM_TEXT_CHARS) } : {},
|
|
336
|
+
...Object.keys(args).length > 0 ? { args } : {},
|
|
337
|
+
...audit.startedAt !== void 0 ? { startedAt: audit.startedAt } : {},
|
|
338
|
+
...audit.endedAt !== void 0 ? { endedAt: audit.endedAt } : {}
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
var createFabricPartialExecutionDetails = (input) => {
|
|
342
|
+
const total = input.audits.length;
|
|
343
|
+
const running = [];
|
|
344
|
+
for (let index = 0; index < total; index++) {
|
|
345
|
+
if (input.audits[index].success === void 0) running.push(index);
|
|
346
|
+
}
|
|
347
|
+
const candidates = new Set(running.slice(-PARTIAL_TAIL_AUDITS).reverse());
|
|
348
|
+
for (let index = total - 1; index >= Math.max(0, total - PARTIAL_TAIL_AUDITS); index--) candidates.add(index);
|
|
349
|
+
for (let index = 0; index < Math.min(total, PARTIAL_HEAD_AUDITS); index++) candidates.add(index);
|
|
350
|
+
const kept = /* @__PURE__ */ new Map();
|
|
351
|
+
let used = 0;
|
|
352
|
+
for (const index of candidates) {
|
|
353
|
+
const full = persistableAudit(input.audits[index]);
|
|
354
|
+
const fullBytes = serializedBytes(full);
|
|
355
|
+
if (used + fullBytes <= FABRIC_PARTIAL_AUDITS_MAX_BYTES) {
|
|
356
|
+
kept.set(index, full);
|
|
357
|
+
used += fullBytes;
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
const slim = slimAudit(full);
|
|
361
|
+
const slimBytes = serializedBytes(slim);
|
|
362
|
+
if (used + slimBytes <= FABRIC_PARTIAL_AUDITS_MAX_BYTES) {
|
|
363
|
+
kept.set(index, slim);
|
|
364
|
+
used += slimBytes;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
const audits = [...kept.keys()].sort((left, right) => left - right).map((index) => kept.get(index));
|
|
368
|
+
let omittedDone = 0;
|
|
369
|
+
let omittedFailed = 0;
|
|
370
|
+
let omittedInternal = 0;
|
|
371
|
+
for (let index = 0; index < total; index++) {
|
|
372
|
+
if (!kept.has(index)) {
|
|
373
|
+
if (input.audits[index].success !== void 0) omittedDone++;
|
|
374
|
+
if (input.audits[index].success === false) omittedFailed++;
|
|
375
|
+
if (isRoutineInternalCall(input.audits[index])) omittedInternal++;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
const omitted = total - audits.length;
|
|
379
|
+
const progress = input.progress === void 0 || input.progress.length <= PARTIAL_PROGRESS_CHARS ? input.progress : `\u2026${input.progress.slice(-PARTIAL_PROGRESS_CHARS)}`;
|
|
380
|
+
const details = {
|
|
381
|
+
...progress !== void 0 ? { progress } : {},
|
|
382
|
+
...input.deadlineAt !== void 0 ? { deadlineAt: input.deadlineAt } : {},
|
|
383
|
+
phases: [],
|
|
384
|
+
audits,
|
|
385
|
+
...omitted > 0 ? { omittedCalls: { count: omitted, done: omittedDone, ...omittedFailed > 0 ? { failed: omittedFailed } : {}, ...omittedInternal > 0 ? { internal: omittedInternal } : {} } } : {}
|
|
277
386
|
};
|
|
387
|
+
let bytes = serializedBytes({ content: [{ type: "text", text: progress ?? "" }], details });
|
|
388
|
+
for (let index = input.phases.length - 1; index >= Math.max(0, input.phases.length - PARTIAL_PHASES); index--) {
|
|
389
|
+
const phase = clipText(input.phases[index], SLIM_TEXT_CHARS);
|
|
390
|
+
const extra = serializedBytes(phase) + (details.phases.length > 0 ? 1 : 0);
|
|
391
|
+
if (bytes + extra > FABRIC_PARTIAL_UPDATE_MAX_BYTES) break;
|
|
392
|
+
details.phases.unshift(phase);
|
|
393
|
+
bytes += extra;
|
|
394
|
+
}
|
|
395
|
+
return details;
|
|
278
396
|
};
|
|
279
397
|
|
|
280
398
|
// src/ui/code-preview-shell.ts
|
|
@@ -771,6 +889,10 @@ var installRegisteredToolCapture = async (options) => {
|
|
|
771
889
|
};
|
|
772
890
|
};
|
|
773
891
|
|
|
892
|
+
// src/ui/widget-keys.ts
|
|
893
|
+
var FABRIC_WIDGET_FOCUS_SHORTCUT = "ctrl+shift+e";
|
|
894
|
+
var FABRIC_WIDGET_FOCUS_HINT = "\u2193 to manage";
|
|
895
|
+
|
|
774
896
|
// src/prewalk/arm.ts
|
|
775
897
|
var armFabricPrewalkSession = async (state, context, pi, input) => {
|
|
776
898
|
const { prewalk } = state.config;
|
|
@@ -948,193 +1070,23 @@ var settleInPlacePrewalk = async (controller, extension, context, options) => {
|
|
|
948
1070
|
return true;
|
|
949
1071
|
};
|
|
950
1072
|
|
|
951
|
-
// src/ui/conversation-shortcut.ts
|
|
952
|
-
var FABRIC_CONVERSATION_SHORTCUT = "ctrl+shift+a";
|
|
953
|
-
var FABRIC_CONVERSATION_HINT = "ctrl+shift+a chat";
|
|
954
|
-
|
|
955
|
-
// src/ui/widget-activity.ts
|
|
956
|
-
import { truncateToWidth as truncateToWidth2, visibleWidth as visibleWidth2, wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
957
|
-
var FABRIC_WIDGET_FOCUS_SHORTCUT = "ctrl+shift+e";
|
|
958
|
-
var FABRIC_WIDGET_FOCUS_HINT = "ctrl+shift+e expand";
|
|
959
|
-
var WIDGET_ACTIVITY_ROWS = 12;
|
|
960
|
-
var WIDGET_ACTIVITY_LOG_LINES = 600;
|
|
961
|
-
var ENTRY_TEXT_LINES = 4;
|
|
962
|
-
var toolGlyph = (theme, status) => status === "running" ? theme.fg("accent", "\u25D0") : status === "failed" ? theme.fg("error", "\u2717") : theme.fg("success", "\u2713");
|
|
963
|
-
var oneLine = (value) => safeText(value ?? "").replace(/\s+/g, " ").trim();
|
|
964
|
-
var tailLines = (text, width, count) => {
|
|
965
|
-
const wrapped = text.split("\n").flatMap((paragraph) => wrapTextWithAnsi(paragraph, Math.max(1, width))).filter((line) => line.trim().length > 0);
|
|
966
|
-
return wrapped.slice(-count);
|
|
967
|
-
};
|
|
968
|
-
var entryLines = (theme, entry, width, hideThinking) => {
|
|
969
|
-
const inner = Math.max(1, width - 4);
|
|
970
|
-
const body = (text, color) => text ? tailLines(safeText(text), inner, ENTRY_TEXT_LINES).map((line) => ` ${theme.fg(color, line)}`) : [];
|
|
971
|
-
switch (entry.kind) {
|
|
972
|
-
case "thinking":
|
|
973
|
-
return [
|
|
974
|
-
` ${theme.fg("dim", entry.status === "running" ? "\u2234 thinking\u2026" : "\u2234 thinking")}`,
|
|
975
|
-
// Pi's hideThinkingBlock keeps the marker and drops the reasoning text, as in its own chat.
|
|
976
|
-
...hideThinking ? [] : body(entry.text, "dim")
|
|
977
|
-
];
|
|
978
|
-
case "tool": {
|
|
979
|
-
const args = oneLine(entry.text);
|
|
980
|
-
return [
|
|
981
|
-
` ${toolGlyph(theme, entry.status)} ${theme.fg("toolTitle", theme.bold(safeText(entry.toolName ?? entry.label)))}${args ? theme.fg("dim", ` ${args}`) : ""}`
|
|
982
|
-
];
|
|
983
|
-
}
|
|
984
|
-
case "assistant":
|
|
985
|
-
return [` ${theme.fg("accent", "\u25C6")} ${theme.fg("accent", safeText(entry.label))}`, ...body(entry.text, "muted")];
|
|
986
|
-
case "user":
|
|
987
|
-
return [` ${theme.fg("muted", "\u203A")} ${theme.fg("muted", oneLine(entry.text) || safeText(entry.label))}`];
|
|
988
|
-
case "error":
|
|
989
|
-
return [` ${theme.fg("error", "\u2717")} ${theme.fg("error", safeText(entry.label))}`, ...body(entry.text, "muted")];
|
|
990
|
-
default:
|
|
991
|
-
return [` ${theme.fg("dim", "\xB7")} ${theme.fg("dim", `${safeText(entry.label)}${entry.text ? ` ${oneLine(entry.text)}` : ""}`)}`];
|
|
992
|
-
}
|
|
993
|
-
};
|
|
994
|
-
var widgetActivityLines = (theme, transcript, width, rows, scroll, hideThinking = false) => {
|
|
995
|
-
if (!transcript || transcript.entries.length === 0) {
|
|
996
|
-
return { lines: [` ${theme.fg("dim", "Waiting for activity\u2026")}`], maxScroll: 0 };
|
|
997
|
-
}
|
|
998
|
-
const all = transcript.entries.flatMap((entry) => entryLines(theme, entry, width, hideThinking));
|
|
999
|
-
const maxScroll = Math.max(0, all.length - rows);
|
|
1000
|
-
const offset = Math.max(0, Math.min(scroll, maxScroll));
|
|
1001
|
-
const end = all.length - offset;
|
|
1002
|
-
const lines = all.slice(Math.max(0, end - rows), end).map((line) => truncateToWidth2(line, width, "\u2026"));
|
|
1003
|
-
return { lines, maxScroll };
|
|
1004
|
-
};
|
|
1005
|
-
var widgetDivider = (theme, width, label = "") => {
|
|
1006
|
-
const text = label ? ` ${label} ` : "";
|
|
1007
|
-
return theme.fg("border", `\u2500\u2500${text}${"\u2500".repeat(Math.max(0, width - 2 - visibleWidth2(text)))}`);
|
|
1008
|
-
};
|
|
1009
|
-
|
|
1010
1073
|
// src/commands/fabric.ts
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
return content.map((part) => {
|
|
1017
|
-
if (typeof part !== "object" || part === null) return "";
|
|
1018
|
-
const p = part;
|
|
1019
|
-
return typeof p.text === "string" ? p.text : typeof p.type === "string" ? p.type : "";
|
|
1020
|
-
}).filter(Boolean).join(" ");
|
|
1021
|
-
}
|
|
1022
|
-
return "";
|
|
1023
|
-
};
|
|
1024
|
-
var summarizeLogLine = (entry) => {
|
|
1025
|
-
if (typeof entry !== "object" || entry === null) return truncateMiddle(String(entry), 200);
|
|
1026
|
-
const record = entry;
|
|
1027
|
-
const type = typeof record.type === "string" ? record.type : void 0;
|
|
1028
|
-
const tool = typeof record.toolName === "string" ? record.toolName : void 0;
|
|
1029
|
-
const msg = record.message;
|
|
1030
|
-
if (typeof msg === "object" && msg !== null && !Array.isArray(msg)) {
|
|
1031
|
-
const m = msg;
|
|
1032
|
-
const role = typeof m.role === "string" ? m.role : "message";
|
|
1033
|
-
const model = typeof m.model === "string" ? m.model : void 0;
|
|
1034
|
-
const text = extractContentText(m.content);
|
|
1035
|
-
const body = (text || JSON.stringify(m)).replace(/\s+/g, " ");
|
|
1036
|
-
return `${role}${model ? ` [${model}]` : ""}: ${truncateMiddle(body, 160)}`;
|
|
1037
|
-
}
|
|
1038
|
-
if (type) {
|
|
1039
|
-
const bits = [type];
|
|
1040
|
-
if (tool) bits.push(tool);
|
|
1041
|
-
const model = typeof record.modelId === "string" ? record.modelId : void 0;
|
|
1042
|
-
const provider = typeof record.provider === "string" && !model ? record.provider : void 0;
|
|
1043
|
-
if (provider) bits.push(provider);
|
|
1044
|
-
if (model) bits.push(model);
|
|
1045
|
-
return bits.join(" ");
|
|
1046
|
-
}
|
|
1047
|
-
return truncateMiddle(JSON.stringify(record), 160);
|
|
1048
|
-
};
|
|
1049
|
-
var resolvePrewalkModel = async (state, context) => {
|
|
1050
|
-
const configured = state.config.prewalk.model?.trim();
|
|
1051
|
-
if (configured) {
|
|
1052
|
-
if (configured.includes("/")) return configured;
|
|
1053
|
-
context.ui.notify(
|
|
1054
|
-
"prewalk.model must use provider/model form.",
|
|
1055
|
-
"error"
|
|
1056
|
-
);
|
|
1057
|
-
return void 0;
|
|
1058
|
-
}
|
|
1059
|
-
let models = [];
|
|
1060
|
-
try {
|
|
1061
|
-
models = context.modelRegistry.getAvailable();
|
|
1062
|
-
} catch {
|
|
1063
|
-
models = [];
|
|
1064
|
-
}
|
|
1065
|
-
const keys = models.map((model) => `${model.provider}/${model.id}`).sort((left, right) => left.localeCompare(right));
|
|
1066
|
-
if (keys.length === 0) {
|
|
1067
|
-
context.ui.notify(
|
|
1068
|
-
"Prewalk needs an explicit Pi executor model. Configure prewalk.model in /fabric settings.",
|
|
1069
|
-
"error"
|
|
1070
|
-
);
|
|
1071
|
-
return void 0;
|
|
1072
|
-
}
|
|
1073
|
-
if (!context.hasUI) {
|
|
1074
|
-
context.ui.notify(
|
|
1075
|
-
"Prewalk needs prewalk.model in non-interactive mode.",
|
|
1076
|
-
"error"
|
|
1077
|
-
);
|
|
1078
|
-
return void 0;
|
|
1079
|
-
}
|
|
1080
|
-
if (typeof context.ui.custom === "function") {
|
|
1081
|
-
try {
|
|
1082
|
-
const picked = await context.ui.custom(
|
|
1083
|
-
(_tui, theme, _keybindings, done) => new FabricModelSelector({
|
|
1084
|
-
theme,
|
|
1085
|
-
source: buildModelSource(context.modelRegistry, resolveAgentDir()),
|
|
1086
|
-
currentValue: "",
|
|
1087
|
-
headerText: "Prewalk executor model. Fabric hands off at the next matching mutation boundary; Main continues on the picked model.",
|
|
1088
|
-
inheritRow: false,
|
|
1089
|
-
onSelect: (value) => done({ model: value }),
|
|
1090
|
-
onCancel: () => done({ model: void 0 })
|
|
1091
|
-
})
|
|
1092
|
-
);
|
|
1093
|
-
if (picked !== void 0) return picked.model;
|
|
1094
|
-
} catch {
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
return context.ui.select("Prewalk executor model", keys);
|
|
1098
|
-
};
|
|
1099
|
-
var armPrewalk = async (state, context, pi, task = "") => {
|
|
1100
|
-
if (state.config.prewalk.enabled === false) {
|
|
1101
|
-
const error = "Fabric prewalk is disabled; re-enable with /fabric prewalk --enable or /fabric settings.";
|
|
1102
|
-
context.ui.notify(error, "error");
|
|
1103
|
-
return { ok: false, error };
|
|
1104
|
-
}
|
|
1105
|
-
if (!state.config.fullCodeMode || state.config.schema.mode === "enforce") {
|
|
1106
|
-
const error = "Fabric prewalk requires full code mode and Schema enforce mode disabled.";
|
|
1107
|
-
context.ui.notify(error, "error");
|
|
1108
|
-
return { ok: false, error };
|
|
1109
|
-
}
|
|
1110
|
-
if (state.config.prewalk.mode === "trajectory" && !state.config.agents.enabled) {
|
|
1111
|
-
const error = "Trajectory prewalk requires enabled agents. Choose in-place mode or enable agents.";
|
|
1112
|
-
context.ui.notify(error, "error");
|
|
1113
|
-
return { ok: false, error };
|
|
1114
|
-
}
|
|
1115
|
-
const model = await resolvePrewalkModel(state, context);
|
|
1116
|
-
if (!model) return { ok: false, error: "Fabric prewalk was not armed." };
|
|
1117
|
-
await armFabricPrewalkSession(state, context, pi, {
|
|
1118
|
-
model,
|
|
1119
|
-
...task ? { task } : {}
|
|
1120
|
-
});
|
|
1121
|
-
const modeLabel = state.config.prewalk.mode === "in-place" ? "Main will continue in place" : "the trajectory will move to a visible child executor";
|
|
1122
|
-
context.ui.notify(
|
|
1123
|
-
task ? `Fabric prewalk armed for the next matching Fabric boundary; ${modeLabel} with ${model}${state.config.prewalk.alwaysRearm ? "; always re-arm enabled" : ""}` : `Fabric prewalk armed for the next task; ${modeLabel} with ${model}${state.config.prewalk.alwaysRearm ? "; always re-arm enabled" : ""}`,
|
|
1124
|
-
"info"
|
|
1125
|
-
);
|
|
1126
|
-
if (task) pi.sendUserMessage(task);
|
|
1127
|
-
return { ok: true };
|
|
1074
|
+
var commandHost = {
|
|
1075
|
+
armFabricPrewalkSession,
|
|
1076
|
+
restoreBorrowedInPlaceMain,
|
|
1077
|
+
setActiveCompiledSurface,
|
|
1078
|
+
truncateMiddle
|
|
1128
1079
|
};
|
|
1129
1080
|
function registerFabricCommand(pi, deps) {
|
|
1130
|
-
const { state, fabricUi
|
|
1081
|
+
const { state, fabricUi } = deps;
|
|
1131
1082
|
const unsubscribePrewalkRequests = pi.events?.on?.(FABRIC_PREWALK_REQUEST_EVENT, (value) => {
|
|
1132
1083
|
const request = readFabricPrewalkRequestV1(value);
|
|
1133
1084
|
if (!request || !request.claim()) return;
|
|
1134
1085
|
void (async () => {
|
|
1135
1086
|
try {
|
|
1136
1087
|
await state.ensure(request.context);
|
|
1137
|
-
|
|
1088
|
+
const { armPrewalk } = await import("../commands/fabric-handler.js");
|
|
1089
|
+
request.respond(await armPrewalk(commandHost, state, request.context, pi));
|
|
1138
1090
|
} catch (error) {
|
|
1139
1091
|
request.respond({
|
|
1140
1092
|
ok: false,
|
|
@@ -1152,6 +1104,7 @@ function registerFabricCommand(pi, deps) {
|
|
|
1152
1104
|
void (async () => {
|
|
1153
1105
|
try {
|
|
1154
1106
|
await state.ensure(request.context);
|
|
1107
|
+
const { buildPeerCards } = await import("../topology/peer-settle.js");
|
|
1155
1108
|
request.respond({ ok: true, cards: buildPeerCards(state.peerInfos()) });
|
|
1156
1109
|
} catch (error) {
|
|
1157
1110
|
request.respond({
|
|
@@ -1171,6 +1124,7 @@ function registerFabricCommand(pi, deps) {
|
|
|
1171
1124
|
request.respond({ ok: false, error: "Fabric mesh is disabled; peers cannot be observed" });
|
|
1172
1125
|
return;
|
|
1173
1126
|
}
|
|
1127
|
+
const { awaitPeerSettle } = await import("../topology/peer-settle.js");
|
|
1174
1128
|
request.respond(await awaitPeerSettle({
|
|
1175
1129
|
poll: () => state.peerInfos(),
|
|
1176
1130
|
...request.selector !== void 0 ? { selector: request.selector } : {},
|
|
@@ -1192,52 +1146,43 @@ function registerFabricCommand(pi, deps) {
|
|
|
1192
1146
|
unsubscribePeerAwait?.();
|
|
1193
1147
|
});
|
|
1194
1148
|
}
|
|
1195
|
-
const
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
return [
|
|
1201
|
-
`repairs: ${status.enabled ? "on" : "off"} \xB7 digest ${status.catalogDigest.slice(0, 12) || "none"}`,
|
|
1202
|
-
`table: ${status.repairCount} \xB7 apply hits ${status.applyHits} \xB7 invocation ${status.invocationErrors} \xB7 effect dropped ${status.effectDropped}`,
|
|
1203
|
-
status.repairs.length > 0 ? `current:
|
|
1204
|
-
${rows}` : "current: (empty)",
|
|
1205
|
-
...status.storeError ? [`store: ${status.storeError}`] : [],
|
|
1206
|
-
top ? `fingerprints:
|
|
1207
|
-
${top}` : "fingerprints: (none this session)"
|
|
1208
|
-
].join("\n");
|
|
1149
|
+
const resolveDecisions = async (context) => {
|
|
1150
|
+
await state.ensure(context);
|
|
1151
|
+
if (!state.config.mesh.enabled) return { reason: "Fabric mesh is disabled; durable decisions are unavailable" };
|
|
1152
|
+
const store = state.decisionStore();
|
|
1153
|
+
return store ? { store } : { reason: "Durable decisions are unavailable in this Fabric host" };
|
|
1209
1154
|
};
|
|
1210
|
-
pi.
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1155
|
+
const unsubscribeDecisionsCapability = pi.events?.on?.(FABRIC_DECISIONS_CAPABILITY_EVENT, (value) => {
|
|
1156
|
+
const request = readFabricDecisionsCapabilityRequestV1(value);
|
|
1157
|
+
if (!request || !request.claim()) return;
|
|
1158
|
+
void import("../decisions/events.js").then(
|
|
1159
|
+
({ answerFabricDecisionsCapability }) => answerFabricDecisionsCapability(request, resolveDecisions),
|
|
1160
|
+
(error) => request.respond({ ok: false, error: `Fabric decisions unavailable: ${String(error)}` })
|
|
1161
|
+
);
|
|
1162
|
+
});
|
|
1163
|
+
const decisionRequests = new AbortController();
|
|
1164
|
+
const unsubscribeDecisionRequest = pi.events?.on?.(FABRIC_DECISION_REQUEST_EVENT, (value) => {
|
|
1165
|
+
const request = readFabricDecisionRequestV1(value);
|
|
1166
|
+
if (!request || !request.claim()) return;
|
|
1167
|
+
void import("../decisions/events.js").then(
|
|
1168
|
+
({ answerFabricDecisionRequest }) => answerFabricDecisionRequest(request, resolveDecisions, decisionRequests.signal),
|
|
1169
|
+
(error) => request.respond({ ok: false, error: `Fabric decisions unavailable: ${String(error)}` })
|
|
1170
|
+
);
|
|
1221
1171
|
});
|
|
1172
|
+
if (unsubscribeDecisionsCapability || unsubscribeDecisionRequest) {
|
|
1173
|
+
pi.on("session_shutdown", () => {
|
|
1174
|
+
unsubscribeDecisionsCapability?.();
|
|
1175
|
+
unsubscribeDecisionRequest?.();
|
|
1176
|
+
decisionRequests.abort();
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1222
1179
|
pi.registerShortcut?.(FABRIC_WIDGET_FOCUS_SHORTCUT, {
|
|
1223
|
-
description: "Focus the Fabric
|
|
1180
|
+
description: "Focus the Fabric agent list",
|
|
1224
1181
|
handler: async (context) => {
|
|
1225
1182
|
if (context.mode !== "tui") return;
|
|
1226
1183
|
fabricUi.focusWidget(context);
|
|
1227
1184
|
}
|
|
1228
1185
|
});
|
|
1229
|
-
pi.registerShortcut?.("ctrl+alt+t", {
|
|
1230
|
-
description: "Inspect Fabric background shell tasks",
|
|
1231
|
-
handler: async (context) => {
|
|
1232
|
-
if (context.mode !== "tui") return;
|
|
1233
|
-
try {
|
|
1234
|
-
await state.ensure(context);
|
|
1235
|
-
await fabricUi.openTasks(context);
|
|
1236
|
-
} catch (error) {
|
|
1237
|
-
context.ui.notify(safeText(error instanceof Error ? error.message : String(error)), "error");
|
|
1238
|
-
}
|
|
1239
|
-
}
|
|
1240
|
-
});
|
|
1241
1186
|
pi.registerCommand("fabric", {
|
|
1242
1187
|
description: "Open Fabric dashboard, chat or tasks, arm prewalk, reload, or manage agents and actors",
|
|
1243
1188
|
getArgumentCompletions: (argumentPrefix) => {
|
|
@@ -1372,742 +1317,16 @@ ${top}` : "fingerprints: (none this session)"
|
|
|
1372
1317
|
const filtered = items.filter((item) => item.value.startsWith(idPrefix));
|
|
1373
1318
|
return filtered.length > 0 ? filtered : null;
|
|
1374
1319
|
},
|
|
1320
|
+
// The subcommands load at first use, not while registering the command.
|
|
1375
1321
|
async handler(argumentsText, context) {
|
|
1376
|
-
await
|
|
1377
|
-
|
|
1378
|
-
if (command === "reload") {
|
|
1379
|
-
fabricUi.stop();
|
|
1380
|
-
suspendToolCapture();
|
|
1381
|
-
try {
|
|
1382
|
-
await state.initialize(context);
|
|
1383
|
-
} catch (error) {
|
|
1384
|
-
fabricUi.stop();
|
|
1385
|
-
suspendToolCapture();
|
|
1386
|
-
throw error;
|
|
1387
|
-
}
|
|
1388
|
-
if (state.kernelReloadRequired) {
|
|
1389
|
-
await context.reload();
|
|
1390
|
-
return;
|
|
1391
|
-
}
|
|
1392
|
-
await restoreBorrowedInPlaceMain(state.prewalk, pi, context);
|
|
1393
|
-
context.ui.notify("Pi Fabric reloaded", "info");
|
|
1394
|
-
deps.refreshToolDisplay?.();
|
|
1395
|
-
return;
|
|
1396
|
-
}
|
|
1397
|
-
if (command === "settings") {
|
|
1398
|
-
const { openFabricSettings } = await import("../ui/settings.js");
|
|
1399
|
-
await openFabricSettings(context, {
|
|
1400
|
-
reloadResources: () => context.reload(),
|
|
1401
|
-
state,
|
|
1402
|
-
applyFabricMode,
|
|
1403
|
-
capturedTools,
|
|
1404
|
-
// Only card-affecting preferences pay for a transcript refresh:
|
|
1405
|
-
// refreshToolDisplay re-renders every fabric_exec card, so gating it
|
|
1406
|
-
// on the display sections keeps unrelated saves off the transcript.
|
|
1407
|
-
onConfigApplied: (id) => {
|
|
1408
|
-
if (id.startsWith("codePreview.")) {
|
|
1409
|
-
deps.refreshCodePreviewSettings?.();
|
|
1410
|
-
deps.refreshToolDisplay?.();
|
|
1411
|
-
} else if (id === "ui.toolDisplay" || id === "ui.showAgentToolPreview") {
|
|
1412
|
-
deps.refreshToolDisplay?.();
|
|
1413
|
-
}
|
|
1414
|
-
}
|
|
1415
|
-
});
|
|
1416
|
-
return;
|
|
1417
|
-
}
|
|
1418
|
-
if (command === "schema") {
|
|
1419
|
-
const requested = argumentsList[0];
|
|
1420
|
-
if (requested === void 0) {
|
|
1421
|
-
const status = state.schemaStatus(context);
|
|
1422
|
-
context.ui.notify(
|
|
1423
|
-
`Schema mode: ${status.mode} (${status.source}) \xB7 executor: ${status.executorRuntime} \xB7 /fabric schema [off|audit|enforce] overrides this session only`,
|
|
1424
|
-
"info"
|
|
1425
|
-
);
|
|
1426
|
-
return;
|
|
1427
|
-
}
|
|
1428
|
-
if (requested !== "off" && requested !== "audit" && requested !== "enforce") {
|
|
1429
|
-
context.ui.notify("Usage: /fabric schema [off|audit|enforce]", "warning");
|
|
1430
|
-
return;
|
|
1431
|
-
}
|
|
1432
|
-
try {
|
|
1433
|
-
state.setSchemaMode(context, requested);
|
|
1434
|
-
} catch (error) {
|
|
1435
|
-
context.ui.notify(
|
|
1436
|
-
error instanceof Error ? error.message : String(error),
|
|
1437
|
-
"error"
|
|
1438
|
-
);
|
|
1439
|
-
return;
|
|
1440
|
-
}
|
|
1441
|
-
context.ui.notify(
|
|
1442
|
-
`Schema mode set to ${requested} for this session (config file unchanged; the next session starts from the configured mode)`,
|
|
1443
|
-
"info"
|
|
1444
|
-
);
|
|
1445
|
-
return;
|
|
1446
|
-
}
|
|
1447
|
-
if (command === "prewalk") {
|
|
1448
|
-
const option = argumentsList[0];
|
|
1449
|
-
if (option === "--disable" || option === "--enable") {
|
|
1450
|
-
const enabled = option === "--enable";
|
|
1451
|
-
try {
|
|
1452
|
-
const projectTrusted = context.isProjectTrusted();
|
|
1453
|
-
const saved = saveFabricConfig(
|
|
1454
|
-
{
|
|
1455
|
-
cwd: context.cwd,
|
|
1456
|
-
agentDir: resolveAgentDir(),
|
|
1457
|
-
projectTrusted,
|
|
1458
|
-
scope: projectTrusted ? "project" : "global"
|
|
1459
|
-
},
|
|
1460
|
-
{ prewalk: { enabled } }
|
|
1461
|
-
);
|
|
1462
|
-
state.reloadConfig(context);
|
|
1463
|
-
if (!enabled) {
|
|
1464
|
-
state.prewalk.cancel();
|
|
1465
|
-
state.prewalkDrift.drop(context.sessionManager.getSessionId());
|
|
1466
|
-
context.ui.setStatus("fabric-prewalk", void 0);
|
|
1467
|
-
await restoreBorrowedInPlaceMain(state.prewalk, pi, context);
|
|
1468
|
-
}
|
|
1469
|
-
context.ui.notify(
|
|
1470
|
-
`Fabric prewalk ${enabled ? "enabled" : "disabled"} (${saved.scope}: ${saved.path})`,
|
|
1471
|
-
"info"
|
|
1472
|
-
);
|
|
1473
|
-
} catch (error) {
|
|
1474
|
-
context.ui.notify(
|
|
1475
|
-
`Failed to update Fabric prewalk setting: ${error instanceof Error ? error.message : String(error)}`,
|
|
1476
|
-
"error"
|
|
1477
|
-
);
|
|
1478
|
-
}
|
|
1479
|
-
return;
|
|
1480
|
-
}
|
|
1481
|
-
if (option === "--off" || option === "--cancel") {
|
|
1482
|
-
state.prewalk.cancel();
|
|
1483
|
-
state.prewalkDrift.drop(context.sessionManager.getSessionId());
|
|
1484
|
-
context.ui.setStatus("fabric-prewalk", void 0);
|
|
1485
|
-
await restoreBorrowedInPlaceMain(state.prewalk, pi, context);
|
|
1486
|
-
context.ui.notify("Fabric prewalk cancelled", "info");
|
|
1487
|
-
return;
|
|
1488
|
-
}
|
|
1489
|
-
if (option === "--status") {
|
|
1490
|
-
const status = state.prewalk.status();
|
|
1491
|
-
context.ui.notify(
|
|
1492
|
-
status.state === "idle" ? "Fabric prewalk is idle" : `Fabric prewalk ${status.state} (${status.mode}) \u2192 ${status.model}${status.task ? `
|
|
1493
|
-
Task: ${status.task}` : ""}`,
|
|
1494
|
-
"info"
|
|
1495
|
-
);
|
|
1496
|
-
return;
|
|
1497
|
-
}
|
|
1498
|
-
const task = argumentsText.trim().slice(command.length).trim();
|
|
1499
|
-
await armPrewalk(state, context, pi, task);
|
|
1500
|
-
return;
|
|
1501
|
-
}
|
|
1502
|
-
if (command === "tasks") {
|
|
1503
|
-
await fabricUi.openTasks(context, argumentsList[0]);
|
|
1504
|
-
return;
|
|
1505
|
-
}
|
|
1506
|
-
if (command === "chat") {
|
|
1507
|
-
await fabricUi.openConversation(context, argumentsList.join(" ") || void 0);
|
|
1508
|
-
return;
|
|
1509
|
-
}
|
|
1510
|
-
if (command === "focus") {
|
|
1511
|
-
fabricUi.focusWidget(context);
|
|
1512
|
-
return;
|
|
1513
|
-
}
|
|
1514
|
-
if (command === "decisions") {
|
|
1515
|
-
const { openFabricDecisions } = await import("../decisions/command.js");
|
|
1516
|
-
await openFabricDecisions(state.mesh, context, argumentsList[0]);
|
|
1517
|
-
return;
|
|
1518
|
-
}
|
|
1519
|
-
if (command === "programs" || command === "run") {
|
|
1520
|
-
const { runFabricProgramsCommand } = await import("../programs/host.js");
|
|
1521
|
-
await runFabricProgramsCommand({ state, pi }, context, command, argumentsText.trim().slice(command.length));
|
|
1522
|
-
return;
|
|
1523
|
-
}
|
|
1524
|
-
if (command === "dashboard" || command === "ui") {
|
|
1525
|
-
await fabricUi.openDashboard(context);
|
|
1526
|
-
return;
|
|
1527
|
-
}
|
|
1528
|
-
if (command === "providers") {
|
|
1529
|
-
const providers = state.registry.providers();
|
|
1530
|
-
context.ui.notify(
|
|
1531
|
-
providers.map((provider) => `${provider.name} \u2014 ${provider.description}`).join("\n"),
|
|
1532
|
-
"info"
|
|
1533
|
-
);
|
|
1534
|
-
return;
|
|
1535
|
-
}
|
|
1536
|
-
if (command === "captured") {
|
|
1537
|
-
const query = argumentsList.join(" ").toLowerCase();
|
|
1538
|
-
const tools = capturedTools.list().filter(
|
|
1539
|
-
(tool) => !query || `${tool.name} ${tool.definition.description} ${tool.sourceInfo.path}`.toLowerCase().includes(query)
|
|
1540
|
-
);
|
|
1541
|
-
const shown = tools.slice(0, 100);
|
|
1542
|
-
context.ui.notify(
|
|
1543
|
-
shown.length > 0 ? [
|
|
1544
|
-
...shown.map((tool) => `${tool.name} [${tool.risk}] \u2014 ${tool.sourceInfo.path}`),
|
|
1545
|
-
...tools.length > shown.length ? [`\u2026 ${tools.length - shown.length} more captured tools`] : []
|
|
1546
|
-
].join("\n") : query ? `No captured extension tools matching ${JSON.stringify(query)}` : "No extension tools captured",
|
|
1547
|
-
"info"
|
|
1548
|
-
);
|
|
1549
|
-
return;
|
|
1550
|
-
}
|
|
1551
|
-
if (command === "agents") {
|
|
1552
|
-
const agents = state.agents.list();
|
|
1553
|
-
context.ui.notify(
|
|
1554
|
-
agents.length > 0 ? agents.map(
|
|
1555
|
-
(agent) => `${agent.id.slice(0, 8)} ${agent.status} ${agent.runner}/${agent.transport} \u2014 ${agent.name}`
|
|
1556
|
-
).join("\n") : "No Fabric agents",
|
|
1557
|
-
"info"
|
|
1558
|
-
);
|
|
1559
|
-
return;
|
|
1560
|
-
}
|
|
1561
|
-
if (command === "actors") {
|
|
1562
|
-
const actors = state.actors.list();
|
|
1563
|
-
context.ui.notify(
|
|
1564
|
-
actors.length > 0 ? actors.map(
|
|
1565
|
-
(actor) => `${actor.id.slice(0, 8)} ${actor.status} ${actor.runner} q:${actor.queued} \u2014 ${actor.name}`
|
|
1566
|
-
).join("\n") : "No Fabric actors",
|
|
1567
|
-
"info"
|
|
1568
|
-
);
|
|
1569
|
-
return;
|
|
1570
|
-
}
|
|
1571
|
-
if (command === "messages") {
|
|
1572
|
-
const id = argumentsList[0];
|
|
1573
|
-
if (!id) {
|
|
1574
|
-
context.ui.notify("Usage: /fabric messages <actor-id>", "warning");
|
|
1575
|
-
return;
|
|
1576
|
-
}
|
|
1577
|
-
try {
|
|
1578
|
-
const actor = state.actors.status(id);
|
|
1579
|
-
const messages = state.actors.messages(actor.id, 20);
|
|
1580
|
-
const shortId = actor.id.slice(0, 8);
|
|
1581
|
-
const body = messages.length > 0 ? messages.map((message) => {
|
|
1582
|
-
const value = message.text ?? message.error ?? message.action ?? "data";
|
|
1583
|
-
const summary = truncateMiddle(value.replace(/\s+/g, " "), 500);
|
|
1584
|
-
const runTag = message.runId ? ` [${message.runId.slice(0, 8)}]` : "";
|
|
1585
|
-
const usageTag = message.usage ? ` \xB7 ${message.usage.input + message.usage.output} tok` : "";
|
|
1586
|
-
return `${message.direction === "in" ? "\u2192" : "\u2190"} ${message.source}${runTag}: ${summary}${usageTag}`;
|
|
1587
|
-
}).join("\n") : `No messages for ${actor.name}`;
|
|
1588
|
-
const footer = `
|
|
1589
|
-
Inspect LLM I/O: /fabric log ${shortId} \xB7 Export: /fabric export-log ${actor.name}`;
|
|
1590
|
-
context.ui.notify(`${body}${footer}`, "info");
|
|
1591
|
-
} catch (error) {
|
|
1592
|
-
context.ui.notify(error instanceof Error ? error.message : String(error), "error");
|
|
1593
|
-
}
|
|
1594
|
-
return;
|
|
1595
|
-
}
|
|
1596
|
-
if (command === "log") {
|
|
1597
|
-
const id = argumentsList[0];
|
|
1598
|
-
if (!id) {
|
|
1599
|
-
context.ui.notify(
|
|
1600
|
-
"Usage: /fabric log <id> [session|run|all] [--lines N] [--run <runId>]",
|
|
1601
|
-
"warning"
|
|
1602
|
-
);
|
|
1603
|
-
return;
|
|
1604
|
-
}
|
|
1605
|
-
let type = "session";
|
|
1606
|
-
let lines = 40;
|
|
1607
|
-
let runId;
|
|
1608
|
-
for (let i = 1; i < argumentsList.length; i++) {
|
|
1609
|
-
const arg = argumentsList[i];
|
|
1610
|
-
if (arg === "session" || arg === "run" || arg === "all") type = arg;
|
|
1611
|
-
else if ((arg === "--lines" || arg === "-n") && i + 1 < argumentsList.length) {
|
|
1612
|
-
const n = Number(argumentsList[++i]);
|
|
1613
|
-
if (n > 0) lines = Math.min(n, 5e3);
|
|
1614
|
-
} else if (arg === "--run" && i + 1 < argumentsList.length) {
|
|
1615
|
-
runId = argumentsList[++i];
|
|
1616
|
-
}
|
|
1617
|
-
}
|
|
1618
|
-
try {
|
|
1619
|
-
const actor = state.actors.status(id);
|
|
1620
|
-
const log = state.actors.readLog(actor.id, { type, lines, ...runId ? { runId } : {} });
|
|
1621
|
-
const parts = [`Actor ${actor.name} \xB7 ${log.sessionFile}`];
|
|
1622
|
-
if (log.session.length > 0) {
|
|
1623
|
-
parts.push(`\u2500\u2500 session (last ${log.session.length} lines) \u2500\u2500`);
|
|
1624
|
-
for (const line of log.session) parts.push(summarizeLogLine(line.parsed ?? line.raw));
|
|
1625
|
-
}
|
|
1626
|
-
if (log.run) {
|
|
1627
|
-
parts.push(
|
|
1628
|
-
`\u2500\u2500 run ${log.run.runId.slice(0, 8)} (${log.run.status?.status ?? "?"}) \u2500\u2500`
|
|
1629
|
-
);
|
|
1630
|
-
for (const line of log.run.events) parts.push(summarizeLogLine(line.parsed ?? line.raw));
|
|
1631
|
-
}
|
|
1632
|
-
if (log.retainedRuns.length > 0) {
|
|
1633
|
-
parts.push(
|
|
1634
|
-
`retained runs: ${log.retainedRuns.map((r) => r.slice(0, 8)).join(" ")}`
|
|
1635
|
-
);
|
|
1636
|
-
}
|
|
1637
|
-
context.ui.notify(
|
|
1638
|
-
parts.length > 1 ? truncateMiddle(parts.join("\n"), 8e3) : `No log found for ${actor.name}`,
|
|
1639
|
-
"info"
|
|
1640
|
-
);
|
|
1641
|
-
} catch (error) {
|
|
1642
|
-
context.ui.notify(error instanceof Error ? error.message : String(error), "error");
|
|
1643
|
-
}
|
|
1644
|
-
return;
|
|
1645
|
-
}
|
|
1646
|
-
if (command === "export-log") {
|
|
1647
|
-
const id = argumentsList[0];
|
|
1648
|
-
const destArg = argumentsList.slice(1).join(" ");
|
|
1649
|
-
if (!id) {
|
|
1650
|
-
context.ui.notify("Usage: /fabric export-log <id> [path]", "warning");
|
|
1651
|
-
return;
|
|
1652
|
-
}
|
|
1653
|
-
try {
|
|
1654
|
-
const dest = path2.resolve(
|
|
1655
|
-
destArg || path2.join("fabric-logs", `export-${Date.now()}`)
|
|
1656
|
-
);
|
|
1657
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
1658
|
-
const actor = state.actors.list().find((candidate) => candidate.id.startsWith(id) || candidate.name === id);
|
|
1659
|
-
let label;
|
|
1660
|
-
let copied = [];
|
|
1661
|
-
if (actor) {
|
|
1662
|
-
const full = state.actors.status(actor.id);
|
|
1663
|
-
label = actor.name;
|
|
1664
|
-
if (full.sessionFile && fs.existsSync(full.sessionFile)) {
|
|
1665
|
-
fs.copyFileSync(full.sessionFile, path2.join(dest, "session.jsonl"));
|
|
1666
|
-
copied.push("session.jsonl");
|
|
1667
|
-
}
|
|
1668
|
-
if (full.logDir && fs.existsSync(full.logDir)) {
|
|
1669
|
-
fs.cpSync(full.logDir, path2.join(dest, "runs"), { recursive: true });
|
|
1670
|
-
copied.push("runs/");
|
|
1671
|
-
}
|
|
1672
|
-
} else {
|
|
1673
|
-
const runDir = state.agents.runDirectory(id);
|
|
1674
|
-
const status = state.agents.status(id);
|
|
1675
|
-
label = status.name;
|
|
1676
|
-
if (runDir && fs.existsSync(runDir)) {
|
|
1677
|
-
fs.cpSync(runDir, dest, { recursive: true });
|
|
1678
|
-
copied.push("run/");
|
|
1679
|
-
}
|
|
1680
|
-
}
|
|
1681
|
-
if (copied.length === 0) {
|
|
1682
|
-
context.ui.notify(`No log files found for ${label}`, "warning");
|
|
1683
|
-
return;
|
|
1684
|
-
}
|
|
1685
|
-
context.ui.notify(`Exported ${label} log \u2192 ${dest} (${copied.join(", ")})`, "info");
|
|
1686
|
-
} catch (error) {
|
|
1687
|
-
context.ui.notify(error instanceof Error ? error.message : String(error), "error");
|
|
1688
|
-
}
|
|
1689
|
-
return;
|
|
1690
|
-
}
|
|
1691
|
-
if (command === "clear-messages") {
|
|
1692
|
-
const id = argumentsList[0];
|
|
1693
|
-
if (!id) {
|
|
1694
|
-
context.ui.notify("Usage: /fabric clear-messages <actor-id>", "warning");
|
|
1695
|
-
return;
|
|
1696
|
-
}
|
|
1697
|
-
try {
|
|
1698
|
-
const actor = state.actors.status(id);
|
|
1699
|
-
await state.actors.clearMessages(actor.id);
|
|
1700
|
-
context.ui.notify(`Cleared message history for ${actor.name}`, "info");
|
|
1701
|
-
} catch (error) {
|
|
1702
|
-
context.ui.notify(error instanceof Error ? error.message : String(error), "error");
|
|
1703
|
-
}
|
|
1704
|
-
return;
|
|
1705
|
-
}
|
|
1706
|
-
if (command === "events") {
|
|
1707
|
-
const id = argumentsList[0];
|
|
1708
|
-
if (!id) {
|
|
1709
|
-
context.ui.notify("Usage: /fabric events <actor-id> [event...]", "warning");
|
|
1710
|
-
return;
|
|
1711
|
-
}
|
|
1712
|
-
try {
|
|
1713
|
-
const actor = state.actors.status(id);
|
|
1714
|
-
const events = argumentsList.slice(1);
|
|
1715
|
-
await state.actors.setEvents(actor.id, events);
|
|
1716
|
-
context.ui.notify(
|
|
1717
|
-
`Set ${actor.name} events: ${events.join(", ") || "(none)"}`,
|
|
1718
|
-
"info"
|
|
1719
|
-
);
|
|
1720
|
-
} catch (error) {
|
|
1721
|
-
context.ui.notify(error instanceof Error ? error.message : String(error), "error");
|
|
1722
|
-
}
|
|
1723
|
-
return;
|
|
1724
|
-
}
|
|
1725
|
-
if (command === "stop") {
|
|
1726
|
-
const id = argumentsList[0];
|
|
1727
|
-
if (!id) {
|
|
1728
|
-
context.ui.notify("Usage: /fabric stop <id>", "warning");
|
|
1729
|
-
return;
|
|
1730
|
-
}
|
|
1731
|
-
const actor = state.actors.list().find((candidate) => candidate.id.startsWith(id) || candidate.name === id);
|
|
1732
|
-
if (actor) {
|
|
1733
|
-
await state.actors.stop(actor.id);
|
|
1734
|
-
context.ui.notify(`Stopped Fabric actor ${actor.id.slice(0, 8)}`, "info");
|
|
1735
|
-
return;
|
|
1736
|
-
}
|
|
1737
|
-
const agent = state.agents.list().find((candidate) => candidate.id.startsWith(id));
|
|
1738
|
-
if (!agent) {
|
|
1739
|
-
context.ui.notify(`Unknown Fabric actor or agent: ${id}`, "error");
|
|
1740
|
-
return;
|
|
1741
|
-
}
|
|
1742
|
-
await state.agents.stop(agent.id);
|
|
1743
|
-
context.ui.notify(`Stopped Fabric agent ${agent.id.slice(0, 8)}`, "info");
|
|
1744
|
-
return;
|
|
1745
|
-
}
|
|
1746
|
-
if (command === "remove" || command === "kill") {
|
|
1747
|
-
const id = argumentsList[0];
|
|
1748
|
-
if (!id) {
|
|
1749
|
-
context.ui.notify("Usage: /fabric remove <id>", "warning");
|
|
1750
|
-
return;
|
|
1751
|
-
}
|
|
1752
|
-
const actor = state.actors.list().find((candidate) => candidate.id.startsWith(id) || candidate.name === id);
|
|
1753
|
-
if (actor) {
|
|
1754
|
-
await state.actors.remove(actor.id);
|
|
1755
|
-
context.ui.notify(`Removed Fabric actor ${actor.id.slice(0, 8)} (${actor.name})`, "info");
|
|
1756
|
-
return;
|
|
1757
|
-
}
|
|
1758
|
-
const agent = state.agents.list().find((candidate) => candidate.id.startsWith(id));
|
|
1759
|
-
if (!agent) {
|
|
1760
|
-
context.ui.notify(`Unknown Fabric actor or agent: ${id}`, "error");
|
|
1761
|
-
return;
|
|
1762
|
-
}
|
|
1763
|
-
await state.agents.stop(agent.id);
|
|
1764
|
-
await state.agents.cleanup(agent.id);
|
|
1765
|
-
context.ui.notify(`Removed Fabric agent ${agent.id.slice(0, 8)}`, "info");
|
|
1766
|
-
return;
|
|
1767
|
-
}
|
|
1768
|
-
if (command === "attach") {
|
|
1769
|
-
const id = argumentsList[0];
|
|
1770
|
-
const agent = id ? state.agents.list().find((candidate) => candidate.id.startsWith(id)) : void 0;
|
|
1771
|
-
if (!agent?.attachCommand) {
|
|
1772
|
-
context.ui.notify("No attachable Fabric agent found", "warning");
|
|
1773
|
-
return;
|
|
1774
|
-
}
|
|
1775
|
-
context.ui.notify(agent.attachCommand, "info");
|
|
1776
|
-
return;
|
|
1777
|
-
}
|
|
1778
|
-
if (command === "global") {
|
|
1779
|
-
const templates = state.globalActors.list();
|
|
1780
|
-
context.ui.notify(
|
|
1781
|
-
templates.length > 0 ? templates.map((template) => `${template.id.slice(0, 8)} global ${template.runner} \u2014 ${template.name}`).join("\n") : "No global Fabric actor templates",
|
|
1782
|
-
"info"
|
|
1783
|
-
);
|
|
1784
|
-
return;
|
|
1785
|
-
}
|
|
1786
|
-
if (command === "import") {
|
|
1787
|
-
const key = argumentsList[0];
|
|
1788
|
-
if (!key) {
|
|
1789
|
-
context.ui.notify("Usage: /fabric import <global-actor-name-or-id> [as <new-name>]", "warning");
|
|
1790
|
-
return;
|
|
1791
|
-
}
|
|
1792
|
-
try {
|
|
1793
|
-
const def = state.globalActors.resolve(key);
|
|
1794
|
-
if (!def) {
|
|
1795
|
-
context.ui.notify(`Unknown global actor: ${key}`, "error");
|
|
1796
|
-
return;
|
|
1797
|
-
}
|
|
1798
|
-
const asIndex = argumentsList.indexOf("as");
|
|
1799
|
-
const as = asIndex >= 0 && argumentsList[asIndex + 1] ? argumentsList[asIndex + 1] : void 0;
|
|
1800
|
-
const actor = await state.actors.create(state.globalActors.toRequest(def, as));
|
|
1801
|
-
context.ui.notify(`Imported global actor "${def.name}" as ${actor.name}`, "info");
|
|
1802
|
-
} catch (error) {
|
|
1803
|
-
context.ui.notify(error instanceof Error ? error.message : String(error), "error");
|
|
1804
|
-
}
|
|
1805
|
-
return;
|
|
1806
|
-
}
|
|
1807
|
-
if (command === "export") {
|
|
1808
|
-
const id = argumentsList[0];
|
|
1809
|
-
const overwrite = argumentsList.includes("--overwrite") || argumentsList.includes("-f");
|
|
1810
|
-
if (!id) {
|
|
1811
|
-
context.ui.notify("Usage: /fabric export <actor-id> [--overwrite]", "warning");
|
|
1812
|
-
return;
|
|
1813
|
-
}
|
|
1814
|
-
try {
|
|
1815
|
-
const actor = state.actors.list().find((candidate) => candidate.id.startsWith(id) || candidate.name === id);
|
|
1816
|
-
if (!actor) {
|
|
1817
|
-
context.ui.notify(`Unknown Fabric actor: ${id}`, "error");
|
|
1818
|
-
return;
|
|
1819
|
-
}
|
|
1820
|
-
const def = state.actors.definition(actor.id);
|
|
1821
|
-
const template = state.globalActors.create(def, overwrite);
|
|
1822
|
-
context.ui.notify(`Exported "${template.name}" to global actors`, "info");
|
|
1823
|
-
} catch (error) {
|
|
1824
|
-
context.ui.notify(error instanceof Error ? error.message : String(error), "error");
|
|
1825
|
-
}
|
|
1826
|
-
return;
|
|
1827
|
-
}
|
|
1828
|
-
if (command === "repairs") {
|
|
1829
|
-
if (argumentsList[0] !== void 0) {
|
|
1830
|
-
context.ui.notify("Usage: /fabric repairs", "warning");
|
|
1831
|
-
return;
|
|
1832
|
-
}
|
|
1833
|
-
context.ui.notify(formatRepairStatus(state.repairs.status()), "info");
|
|
1834
|
-
return;
|
|
1835
|
-
}
|
|
1836
|
-
if (command === "entropy") {
|
|
1837
|
-
const {
|
|
1838
|
-
ENTROPY_METRIC_VERSION,
|
|
1839
|
-
entropySurfaceHash,
|
|
1840
|
-
liveSurfaceSnapshot,
|
|
1841
|
-
surfaceFreedomReport,
|
|
1842
|
-
machineSessionFilesAsync,
|
|
1843
|
-
measureSessionCorpusAsync,
|
|
1844
|
-
projectSessionFilesAsync,
|
|
1845
|
-
sessionWindowEvidenceAsync,
|
|
1846
|
-
measureEntropyAsync,
|
|
1847
|
-
entropyRepairRows,
|
|
1848
|
-
entropyReviewSignals,
|
|
1849
|
-
formatEntropyReviewSignal,
|
|
1850
|
-
loadObservationPoolAsync,
|
|
1851
|
-
mergeObservationWindowAsync,
|
|
1852
|
-
poolToValueObservations,
|
|
1853
|
-
applyCompiledSurface,
|
|
1854
|
-
normalFormEvidenceSummary,
|
|
1855
|
-
loadCompiledSurfaceAsync,
|
|
1856
|
-
parseCompiledSurfaceArtifact,
|
|
1857
|
-
saveCompiledSurfaceAsync,
|
|
1858
|
-
formatEntropyCommandHints,
|
|
1859
|
-
formatEntropyMetric,
|
|
1860
|
-
mergeCompiledSurfaces
|
|
1861
|
-
} = await import("../entropy/index.js");
|
|
1862
|
-
const exportArtifactIndex = argumentsList.indexOf("export-artifact");
|
|
1863
|
-
if (exportArtifactIndex >= 0) {
|
|
1864
|
-
const target = argumentsList[exportArtifactIndex + 1];
|
|
1865
|
-
try {
|
|
1866
|
-
const loaded = await loadCompiledSurfaceAsync(resolveAgentDir());
|
|
1867
|
-
if (loaded.error) {
|
|
1868
|
-
context.ui.notify(loaded.error, "error");
|
|
1869
|
-
return;
|
|
1870
|
-
}
|
|
1871
|
-
if (!loaded.file) {
|
|
1872
|
-
context.ui.notify(
|
|
1873
|
-
"No compiled surface to export; wait for a compile to pass its gate",
|
|
1874
|
-
"warning"
|
|
1875
|
-
);
|
|
1876
|
-
return;
|
|
1877
|
-
}
|
|
1878
|
-
const dest = path2.resolve(
|
|
1879
|
-
target ?? path2.join(resolveAgentDir(), "fabric", "entropy", "artifact.json")
|
|
1880
|
-
);
|
|
1881
|
-
await fs.promises.mkdir(path2.dirname(dest), { recursive: true });
|
|
1882
|
-
await fs.promises.writeFile(dest, `${JSON.stringify(loaded.file, null, 2)}
|
|
1883
|
-
`, {
|
|
1884
|
-
encoding: "utf-8",
|
|
1885
|
-
mode: 384
|
|
1886
|
-
});
|
|
1887
|
-
context.ui.notify(
|
|
1888
|
-
`Exported compiled surface (${loaded.file.normalizations?.length ?? 0} normal-form plans; legacy restrictions inert) \u2192 ${dest}`,
|
|
1889
|
-
"info"
|
|
1890
|
-
);
|
|
1891
|
-
} catch (error) {
|
|
1892
|
-
context.ui.notify(
|
|
1893
|
-
error instanceof Error ? error.message : String(error),
|
|
1894
|
-
"error"
|
|
1895
|
-
);
|
|
1896
|
-
}
|
|
1897
|
-
return;
|
|
1898
|
-
}
|
|
1899
|
-
const importIndex = argumentsList.indexOf("import");
|
|
1900
|
-
if (importIndex >= 0) {
|
|
1901
|
-
const source = argumentsList[importIndex + 1];
|
|
1902
|
-
if (!source) {
|
|
1903
|
-
context.ui.notify("Usage: /fabric entropy import <artifact.json>", "warning");
|
|
1904
|
-
return;
|
|
1905
|
-
}
|
|
1906
|
-
try {
|
|
1907
|
-
const raw = JSON.parse(
|
|
1908
|
-
await fs.promises.readFile(path2.resolve(source), "utf-8")
|
|
1909
|
-
);
|
|
1910
|
-
const incoming = parseCompiledSurfaceArtifact(raw);
|
|
1911
|
-
if (!incoming) {
|
|
1912
|
-
context.ui.notify(`Artifact is invalid: ${source}`, "error");
|
|
1913
|
-
return;
|
|
1914
|
-
}
|
|
1915
|
-
const agentDir = resolveAgentDir();
|
|
1916
|
-
const localLoaded = await loadCompiledSurfaceAsync(agentDir);
|
|
1917
|
-
if (localLoaded.error) {
|
|
1918
|
-
context.ui.notify(localLoaded.error, "error");
|
|
1919
|
-
return;
|
|
1920
|
-
}
|
|
1921
|
-
const live = await liveSurfaceSnapshot({
|
|
1922
|
-
registry: state.registry,
|
|
1923
|
-
extensionContext: context,
|
|
1924
|
-
cwd: state.cwd ?? context.cwd
|
|
1925
|
-
});
|
|
1926
|
-
const merged = mergeCompiledSurfaces(localLoaded.file, incoming, live);
|
|
1927
|
-
const saved = await saveCompiledSurfaceAsync(agentDir, merged.file);
|
|
1928
|
-
if (state.config.entropy.compile) setActiveCompiledSurface(saved.file);
|
|
1929
|
-
context.ui.notify(
|
|
1930
|
-
`Imported compiled surface: ${merged.file.normalizations?.length ?? 0} normal-form plans \xB7 ${merged.droppedOverlays + merged.droppedQuarantines + merged.droppedNormalizations} dropped (unproved rules or legacy restrictions)`,
|
|
1931
|
-
"info"
|
|
1932
|
-
);
|
|
1933
|
-
} catch (error) {
|
|
1934
|
-
context.ui.notify(
|
|
1935
|
-
error instanceof Error ? error.message : String(error),
|
|
1936
|
-
"error"
|
|
1937
|
-
);
|
|
1938
|
-
}
|
|
1939
|
-
return;
|
|
1940
|
-
}
|
|
1941
|
-
const exportIndex = argumentsList.indexOf("export");
|
|
1942
|
-
if (exportIndex >= 0) {
|
|
1943
|
-
const target = argumentsList[exportIndex + 1];
|
|
1944
|
-
try {
|
|
1945
|
-
const snapshot = await liveSurfaceSnapshot({
|
|
1946
|
-
registry: state.registry,
|
|
1947
|
-
extensionContext: context,
|
|
1948
|
-
cwd: state.cwd ?? context.cwd
|
|
1949
|
-
});
|
|
1950
|
-
const dest = path2.resolve(
|
|
1951
|
-
target ?? path2.join(resolveAgentDir(), "fabric", "entropy", "surface.json")
|
|
1952
|
-
);
|
|
1953
|
-
await fs.promises.mkdir(path2.dirname(dest), { recursive: true });
|
|
1954
|
-
await fs.promises.writeFile(dest, `${JSON.stringify(snapshot, null, 2)}
|
|
1955
|
-
`, {
|
|
1956
|
-
encoding: "utf8",
|
|
1957
|
-
mode: 384
|
|
1958
|
-
});
|
|
1959
|
-
context.ui.notify(
|
|
1960
|
-
`Exported ${snapshot.actions.length} surface actions \u2192 ${dest}`,
|
|
1961
|
-
"info"
|
|
1962
|
-
);
|
|
1963
|
-
} catch (error) {
|
|
1964
|
-
context.ui.notify(
|
|
1965
|
-
error instanceof Error ? error.message : String(error),
|
|
1966
|
-
"error"
|
|
1967
|
-
);
|
|
1968
|
-
}
|
|
1969
|
-
return;
|
|
1970
|
-
}
|
|
1971
|
-
const projectScope = argumentsList.includes("--project");
|
|
1972
|
-
const scopedArguments = argumentsList.filter((argument) => argument !== "--project");
|
|
1973
|
-
if (scopedArguments[0] !== void 0) {
|
|
1974
|
-
context.ui.notify(
|
|
1975
|
-
"Usage: /fabric entropy [--project] [export [path] | export-artifact [path] | import <path>]",
|
|
1976
|
-
"warning"
|
|
1977
|
-
);
|
|
1978
|
-
return;
|
|
1979
|
-
}
|
|
1980
|
-
try {
|
|
1981
|
-
const status = state.repairs.status();
|
|
1982
|
-
const agentDir = resolveAgentDir();
|
|
1983
|
-
const scopeCwd = state.cwd ?? context.cwd;
|
|
1984
|
-
const [loadedCompiled, live, files] = await Promise.all([
|
|
1985
|
-
loadCompiledSurfaceAsync(agentDir),
|
|
1986
|
-
liveSurfaceSnapshot({
|
|
1987
|
-
registry: state.registry,
|
|
1988
|
-
extensionContext: context,
|
|
1989
|
-
cwd: scopeCwd
|
|
1990
|
-
}),
|
|
1991
|
-
projectScope ? projectSessionFilesAsync(agentDir, scopeCwd) : machineSessionFilesAsync(agentDir, scopeCwd)
|
|
1992
|
-
]);
|
|
1993
|
-
const snapshot = loadedCompiled.file ? applyCompiledSurface(live, loadedCompiled.file) : live;
|
|
1994
|
-
const freedom = surfaceFreedomReport(snapshot);
|
|
1995
|
-
const surfaceDigest = entropySurfaceHash(snapshot);
|
|
1996
|
-
const corpus = await measureSessionCorpusAsync({
|
|
1997
|
-
files,
|
|
1998
|
-
surface: snapshot,
|
|
1999
|
-
catalogDigest: surfaceDigest
|
|
2000
|
-
});
|
|
2001
|
-
const formatFreedom = (value) => String(Math.round(value * 100) / 100);
|
|
2002
|
-
const worst = freedom.actions.slice(0, 4).map((action) => `${action.ref} ${formatFreedom(action.freedom)}`).join(" \xB7 ");
|
|
2003
|
-
const latest = corpus.latest;
|
|
2004
|
-
const sessionsLine = corpus.sessions.length === 0 || latest === void 0 ? `session entropy (observed): no fabric_exec traces in the latest ${files.length} ${projectScope ? "project" : "machine"} sessions` : `session entropy (observed): ${corpus.sessions.length} sessions \xB7 latest ${latest.totals.operations} ops \xB7 invocation rejection rate ${formatEntropyMetric(latest.score)} \xB7 ${formatEntropyMetric(latest.totals.invocationRejectionsPer1k)}/1k calls \xB7 lower is better \xB7 slope ${formatEntropyMetric(corpus.trend.slopePerStep)}/session \xB7 ${latest.totals.invocationRejectionsPer1k === 0 && corpus.trend.slopePerStep <= 0 ? "no invocation rejections" : "invocation friction remains"}`;
|
|
2005
|
-
const modelsLine = corpus.models.length > 1 ? `models: ${corpus.models.map(
|
|
2006
|
-
(model) => `${model.model} behavioral ${formatEntropyMetric(model.latestBehavioralScore)} \xB7 slope ${formatEntropyMetric(model.slopePerSession)}`
|
|
2007
|
-
).join(" \xB7 ")}` : void 0;
|
|
2008
|
-
const compiledLine = loadedCompiled.error ? `compiled: unavailable \u2014 ${loadedCompiled.error}` : loadedCompiled.file ? `compiled: artifact v${loadedCompiled.file.version} \xB7 ${loadedCompiled.file.normalizations?.length ?? 0} normal-form plans \xB7 canonical capabilities preserved${loadedCompiled.file.version === 1 ? " \xB7 legacy restrictions inert (migration pending)" : ""}` : "compiled: none";
|
|
2009
|
-
let reviewLine;
|
|
2010
|
-
let normalizationLine = "normal forms: no witness evidence";
|
|
2011
|
-
try {
|
|
2012
|
-
const [windowEvidence, poolLoaded] = await Promise.all([
|
|
2013
|
-
sessionWindowEvidenceAsync(files),
|
|
2014
|
-
loadObservationPoolAsync(agentDir)
|
|
2015
|
-
]);
|
|
2016
|
-
const normal = normalFormEvidenceSummary(windowEvidence.traces);
|
|
2017
|
-
normalizationLine = `normal forms: ${normal.normalizedCalls} calls normalized \xB7 ${normal.rulesApplied} rules applied \xB7 ${normal.succeeded} succeeded \xB7 ${normal.subsequentFailures} subsequent failures (not masked)`;
|
|
2018
|
-
if (poolLoaded.error) {
|
|
2019
|
-
reviewLine = `review: unavailable \u2014 ${poolLoaded.error}`;
|
|
2020
|
-
} else if (windowEvidence.traces.length === 0) {
|
|
2021
|
-
reviewLine = "review: no window evidence";
|
|
2022
|
-
} else {
|
|
2023
|
-
const mergedPool = await mergeObservationWindowAsync(
|
|
2024
|
-
poolLoaded.file,
|
|
2025
|
-
windowEvidence.observationWindows
|
|
2026
|
-
);
|
|
2027
|
-
const signals = entropyReviewSignals({
|
|
2028
|
-
report: await measureEntropyAsync({
|
|
2029
|
-
traces: windowEvidence.traces,
|
|
2030
|
-
surface: snapshot,
|
|
2031
|
-
catalogDigest: surfaceDigest
|
|
2032
|
-
}),
|
|
2033
|
-
traces: windowEvidence.traces,
|
|
2034
|
-
surface: snapshot,
|
|
2035
|
-
repairs: entropyRepairRows(state.repairs.repairs),
|
|
2036
|
-
valueObservations: poolToValueObservations(mergedPool.file)
|
|
2037
|
-
});
|
|
2038
|
-
reviewLine = signals.length === 0 ? "review: none" : `review: ${signals.length} suggestion${signals.length === 1 ? "" : "s"} \xB7 ${signals.slice(0, 4).map(formatEntropyReviewSignal).join(" \xB7 ")}${signals.length > 4 ? ` \xB7 +${signals.length - 4} more` : ""}`;
|
|
2039
|
-
}
|
|
2040
|
-
} catch {
|
|
2041
|
-
reviewLine = "review: unavailable";
|
|
2042
|
-
}
|
|
2043
|
-
context.ui.notify(
|
|
2044
|
-
[
|
|
2045
|
-
`entropy: metric v${ENTROPY_METRIC_VERSION} \xB7 surface ${surfaceDigest.slice(0, 12)} \xB7 ${freedom.actions.length} actions`,
|
|
2046
|
-
`live: invocation errors ${status.invocationErrors} \xB7 effect dropped ${status.effectDropped} \xB7 aliases ${status.repairCount} \xB7 alias hits ${status.applyHits}`,
|
|
2047
|
-
compiledLine,
|
|
2048
|
-
normalizationLine,
|
|
2049
|
-
reviewLine,
|
|
2050
|
-
`surface freedom (diagnostic, not objective): mean ${formatFreedom(freedom.mean)}${worst ? ` \xB7 worst ${worst}` : ""}`,
|
|
2051
|
-
sessionsLine,
|
|
2052
|
-
...modelsLine ? [modelsLine] : [],
|
|
2053
|
-
...formatEntropyCommandHints()
|
|
2054
|
-
].join("\n"),
|
|
2055
|
-
"info"
|
|
2056
|
-
);
|
|
2057
|
-
} catch (error) {
|
|
2058
|
-
context.ui.notify(
|
|
2059
|
-
error instanceof Error ? error.message : String(error),
|
|
2060
|
-
"error"
|
|
2061
|
-
);
|
|
2062
|
-
}
|
|
2063
|
-
return;
|
|
2064
|
-
}
|
|
2065
|
-
if (command !== "status") {
|
|
2066
|
-
context.ui.notify(
|
|
2067
|
-
"Usage: /fabric [status|dashboard|chat [id-or-name]|focus|prewalk [task]|prewalk --off|--disable|--enable|reload|providers|agents|actors|global|import <name> [as <new>]|export <id> [--overwrite]|messages <id>|clear-messages <id>|events <id> [event...]|log <id>|export-log <id>|attach <id>|stop <id>|remove <id>|kill <id>|repairs|entropy|decisions [id]|programs [promote|retire <ref>]|run <ref> [json]]",
|
|
2068
|
-
"warning"
|
|
2069
|
-
);
|
|
2070
|
-
return;
|
|
2071
|
-
}
|
|
2072
|
-
const config = state.config;
|
|
2073
|
-
context.ui.notify(
|
|
2074
|
-
[
|
|
2075
|
-
`cwd: ${state.cwd}`,
|
|
2076
|
-
`mode: ${config.fullCodeMode ? "full code (Fabric-owned core tools)" : "orchestration-only (native Pi tools)"}`,
|
|
2077
|
-
`providers: ${state.registry.providers().map((provider) => provider.name).join(", ")}`,
|
|
2078
|
-
`runner: ${config.agents.runner} \xB7 transport: ${config.agents.transport} \xB7 model: ${config.agents.runner === "claude" ? config.agents.claude.model || "Claude default" : config.agents.runner === "veda" ? `${config.agents.veda.model || "Veda default"} \xB7 backend ${config.agents.veda.backend} \xB7 persona ${config.agents.veda.persona}` : config.agents.model || "inherit"}`,
|
|
2079
|
-
`agent limits: concurrency ${config.agents.maxConcurrent}, per execution ${config.agents.maxPerExecution}, depth ${config.agents.maxDepth}`,
|
|
2080
|
-
(() => {
|
|
2081
|
-
const prewalk = state.prewalk.status();
|
|
2082
|
-
return prewalk.state === "idle" ? `prewalk: idle \xB7 ${config.prewalk.mode} \xB7 model ${config.prewalk.model || "Ask each time"} \xB7 auto-arm & re-arm ${config.prewalk.alwaysRearm ? "on" : "off"}` : `prewalk: ${prewalk.state} \xB7 ${prewalk.mode} \u2192 ${prewalk.model}${prewalk.alwaysRearm ? " \xB7 always re-arm" : ""}`;
|
|
2083
|
-
})(),
|
|
2084
|
-
config.fullCodeMode && config.capture.enabled ? `captured tools: ${capturedTools.size} \xB7 model visibility: ${config.capture.hideFromModel ? "hidden" : "visible"}` : "captured tools: disabled (native registry preserved)",
|
|
2085
|
-
...config.foreground.tools.length > 0 ? [`foreground: ${formatForeground(state.foregroundTools())}`] : [],
|
|
2086
|
-
`actors: ${state.actors.list().length} \xB7 mesh: ${config.mesh.enabled ? state.mesh.root : "disabled"}`,
|
|
2087
|
-
`MCP: ${config.mcp.enabled ? "enabled" : "disabled"}`,
|
|
2088
|
-
`UI: ${config.ui.enabled ? `${config.ui.widget} widget above chat` : "disabled"}`
|
|
2089
|
-
].join("\n"),
|
|
2090
|
-
"info"
|
|
2091
|
-
);
|
|
1322
|
+
const { runFabricCommand } = await import("../commands/fabric-handler.js");
|
|
1323
|
+
await runFabricCommand(pi, deps, commandHost, argumentsText, context);
|
|
2092
1324
|
}
|
|
2093
1325
|
});
|
|
2094
1326
|
}
|
|
2095
1327
|
|
|
2096
1328
|
// src/agents/runner-notice.ts
|
|
2097
1329
|
var BUILT_IN_RUNNERS = ["pi", "pi-durable", "claude", "veda"];
|
|
2098
|
-
var editDistance = (left, right) => {
|
|
2099
|
-
const row = Array.from({ length: right.length + 1 }, (_, index) => index);
|
|
2100
|
-
for (let i = 1; i <= left.length; i += 1) {
|
|
2101
|
-
let diagonal = row[0];
|
|
2102
|
-
row[0] = i;
|
|
2103
|
-
for (let j = 1; j <= right.length; j += 1) {
|
|
2104
|
-
const above = row[j];
|
|
2105
|
-
row[j] = Math.min(above + 1, row[j - 1] + 1, diagonal + (left[i - 1] === right[j - 1] ? 0 : 1));
|
|
2106
|
-
diagonal = above;
|
|
2107
|
-
}
|
|
2108
|
-
}
|
|
2109
|
-
return row[right.length];
|
|
2110
|
-
};
|
|
2111
1330
|
var unregisteredRunnerNotice = (runner, registered) => {
|
|
2112
1331
|
const known = [.../* @__PURE__ */ new Set([...BUILT_IN_RUNNERS, ...registered])];
|
|
2113
1332
|
if (known.includes(runner)) return void 0;
|
|
@@ -2120,7 +1339,7 @@ var unregisteredRunnerNotice = (runner, registered) => {
|
|
|
2120
1339
|
};
|
|
2121
1340
|
|
|
2122
1341
|
// src/core/tool-ownership.ts
|
|
2123
|
-
import
|
|
1342
|
+
import path2 from "node:path";
|
|
2124
1343
|
var fabricToolLoadout = (loadout, exclusive, foreground = []) => {
|
|
2125
1344
|
if (!exclusive) return void 0;
|
|
2126
1345
|
const hiddenDeclarations = loadout.registered.map((tool) => tool.name).filter((name) => name !== "fabric_exec" && !foreground.includes(name));
|
|
@@ -2177,7 +1396,7 @@ var fabricModelContext = (messages, tools) => {
|
|
|
2177
1396
|
var FABRIC_TOOL_NAME = "fabric_exec";
|
|
2178
1397
|
var TOP_LEVEL_SCHEMA_REF_PREFIX = "schema.top_level_tool.";
|
|
2179
1398
|
var ownsFabricToolSource = (tools, extensionEntryPath) => tools.some(
|
|
2180
|
-
(tool) => tool.name === FABRIC_TOOL_NAME &&
|
|
1399
|
+
(tool) => tool.name === FABRIC_TOOL_NAME && path2.resolve(tool.sourceInfo.path) === path2.resolve(extensionEntryPath)
|
|
2181
1400
|
);
|
|
2182
1401
|
var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2183
1402
|
var finalFabricDetailsFailed = (details) => {
|
|
@@ -2262,99 +1481,106 @@ var FabricToolOwnership = class {
|
|
|
2262
1481
|
}
|
|
2263
1482
|
};
|
|
2264
1483
|
|
|
2265
|
-
// src/core/
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
1484
|
+
// src/core/host-policy.ts
|
|
1485
|
+
import { createHash } from "node:crypto";
|
|
1486
|
+
var HOOKED_PROVIDERS = /* @__PURE__ */ new Set(["pi", "extensions"]);
|
|
1487
|
+
var FABRIC_BUILTIN_READ_REFS = /* @__PURE__ */ new Set([
|
|
1488
|
+
"cache.status",
|
|
1489
|
+
"compact.pressure",
|
|
1490
|
+
"compact.status",
|
|
1491
|
+
"components.describe",
|
|
1492
|
+
"components.graph",
|
|
1493
|
+
"components.list",
|
|
1494
|
+
"components.status",
|
|
1495
|
+
"memory.expand",
|
|
1496
|
+
"memory.recall",
|
|
1497
|
+
"memory.sessions",
|
|
1498
|
+
"programs.get",
|
|
1499
|
+
"programs.list",
|
|
1500
|
+
"schema.status",
|
|
1501
|
+
"state.get",
|
|
1502
|
+
"state.history",
|
|
1503
|
+
"thinking.status"
|
|
1504
|
+
]);
|
|
1505
|
+
var refMatches = (pattern, ref) => pattern.endsWith(".*") ? ref.startsWith(pattern.slice(0, -1)) : pattern === ref;
|
|
1506
|
+
var FabricHostPolicy = class {
|
|
1507
|
+
#policy;
|
|
1508
|
+
#sealed = false;
|
|
1509
|
+
/** True once a policy is in force. Does not seal. */
|
|
1510
|
+
get active() {
|
|
1511
|
+
return this.#policy !== void 0;
|
|
1512
|
+
}
|
|
1513
|
+
get sealed() {
|
|
1514
|
+
return this.#sealed;
|
|
1515
|
+
}
|
|
1516
|
+
/** Accept the policy only while nothing has run; otherwise refuse it. */
|
|
1517
|
+
apply(policy) {
|
|
1518
|
+
if (this.#sealed) {
|
|
1519
|
+
return { version: 1, accepted: false, reason: "Fabric host policy is sealed: this instance already ran a program or provider call" };
|
|
2274
1520
|
}
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
lines.push(`Guidelines for \`pi.${name}\`:`);
|
|
2278
|
-
lines.push(...guidelines.map((guideline) => `- ${guideline}`));
|
|
1521
|
+
if (this.#policy) {
|
|
1522
|
+
return { version: 1, accepted: false, reason: `Fabric host policy is already set by ${this.#policy.owner}` };
|
|
2279
1523
|
}
|
|
2280
|
-
|
|
1524
|
+
const copy = structuredClone(policy);
|
|
1525
|
+
this.#policy = copy;
|
|
1526
|
+
return { version: 1, accepted: true, digest: hostPolicyDigest(copy), enforced: [...FABRIC_HOST_POLICY_FIELDS] };
|
|
2281
1527
|
}
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
}
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
// caches stay warm.
|
|
2299
|
-
`Read every file the user provides (images, screenshots, code, text) with the ${fullCodeMode ? "`pi.read`" : "`read`"} tool before responding \u2014 never assume its contents.`
|
|
2300
|
-
].join(" ");
|
|
2301
|
-
var defaultFabricExecutionGuidance = (fullCodeMode, kernel = "typescript", pythonRuntime = "monty", profile = "additive") => kernel === "typescript" && profile === "native" ? "Native Pi codemode profile: tools.<name>(args) and nativeTools.<name>(args) use native results, including schema-backed error envelopes. searchTools/ALL_TOOLS return callable identifiers; describeTool returns a declaration string. image() emits images and saves host-side temporary artifacts. store/load share Pi codemode-store entries on this branch. Fabric discovery remains fabric.tools; pi.*, mcp.* and extensions.* keep Fabric result semantics. Policies and limits are unchanged. " + defaultFabricExecutionGuidance(fullCodeMode, kernel, pythonRuntime).replaceAll("tools.", "fabric.tools.").replaceAll("`tools`", "`fabric.tools`") : kernel === "python" ? (pythonRuntime === "monty" ? "Python backend: Monty sandboxed subset, not CPython. Native filesystem/network/environment access and arbitrary imports are unavailable; use host tools for effects. Supply acyclic JSON host arguments; recursive containers are unsupported. Underscore-prefixed direct capability attributes are unavailable: use tools.call with the exact discovered ref instead. \u03C0 is an attribute object; payloads is a dict, not the same identity. " : "Python backend: CPython; native standard-library imports are available. ") + 'Python fabric_exec: write an async function body with `await` and `return`; each invocation starts fresh. Use imports supported by the configured backend, such as `import asyncio`. Host methods accept one dict or keyword arguments: `await tools.search(query="example")`, `await tools.call(ref="provider.action", args={"key": "value"})`; discover with tools.search instead of enumerating: tools.list is a capped page (default 100, hard cap 1000) with no truncation marker, so a short result never proves an action is absent (tools.list(envelope=True) reports totals). Known actions use mcp.<server>.<tool>, memory.*, state.*, schema.*, compact.*, components.*, agents.*, or mesh.*. Responses are native Python dicts/lists, not attribute objects. Use `asyncio.gather` for independent calls. `\u03C0.key` and `payloads["key"]` contain only the exact top-level payload keys. Return JSON-compatible data (convert sets, bytes, paths, and datetimes explicitly); print output is bounded. JavaScript callback helpers (workflow, memory.walk, and predicate callbacks) are not Python APIs; page with ordinary await/loops instead. Provider argument validation and approvals remain host-enforced. Schema enforce retains host gates and requires the selected runtime\u2019s isolation; no unrestricted fallback.' + (fullCodeMode ? ` \`await pi.read("/x")\`, \`await pi.grep(pattern="TODO", path="src")\`, \`await pi.find(pattern="*.py", path="src")\`, and \`await pi.ls("src")\` return strings. \`await pi.bash(command="ls")\`, \`await pi.edit(path="/x", oldText="a", newText="b")\`, and \`await pi.write(path="/y", content=\u03C0.body)\` return dicts; read \`r["output"]\`. Shell nonzero exits raise; \`settle=True\` returns a failure dict instead. Cancellation, timeout, approval and security errors still raise. A nested shell that exceeds executor.shellHangMs still resolves ok with a still-running notice, pid, and live output path; background=True detaches immediately. Detached results include details.taskId; completion notifies this session. Use tools.call(ref='tasks.list', args={}), tasks.get or tasks.stop with {'id': taskId}; pi.read can read the bounded log. Bounded controllers can await tasks.wait or tasks.watch (monitor batches, after cursor) without polling; timeout/cancellation affects only the observation. Opt-in monitor={'delivery':'wake','match':'literal','timeoutMs':300000,'intervalMs':5000} (choose delivery 'ui' or 'wake') also detaches: UI-only never wakes the agent, wake sends coalesced line events. Monitors expire and are not automatically renewed.` + SHELL_COMPOSITION_GUIDANCE + " Captured tools are `await extensions.<name>(...)`." : " Pi core and extensions are unavailable inside fabric_exec in orchestration-only mode.") : fullCodeMode ? "Examples and returns: `pi.read('/x')`, `pi.grep('TODO','src')` / `pi.grep({pattern:'TODO', path:'src', ignoreCase:true, context:2})`, `pi.find({pattern:'*.ts', path:'src', limit:20})`, and `pi.ls('src')` return strings; `pi.bash({cmd:'ls'})` (or `pi.powershell` on Windows), `pi.edit({path:'/x', old:'a', new:'b'})`, and `pi.write({path:'/y', text:'z'})` return `{ok, output, details}` (read `.output`); failed core calls reject, including shell tools on an ordinary nonzero exit; pass `settle: true` to `pi.bash` or `pi.powershell` to get `{ ok: false, exitCode, output, error }` instead. Timeout, cancellation, approval, and security failures still reject. A nested shell that exceeds `executor.shellHangMs` still resolves `ok: true` with a still-running notice, pid, and live output path; `background: true` detaches immediately. Detached results include `details.taskId`; completion notifies this session, without polling. Use `tools.call({ref:'tasks.list',args:{}})` or `tasks.get`/`tasks.stop` with `{id: taskId}`; `pi.read` can read the bounded log. Bounded controllers can await `tasks.wait` or `tasks.watch` (monitor batches, `after` cursor) without polling; timeout/cancellation affects only the observation. Opt-in `monitor:{delivery:'ui'|'wake',match:'literal',timeoutMs:300000,intervalMs:5000}` also detaches: UI-only never wakes the agent, wake sends coalesced line events. Monitors expire and are not automatically renewed." + SHELL_COMPOSITION_GUIDANCE + "\n`tools` exposes discovery/generic calls (`providers`/`catalog`/`list`/`search`/`describe`/`call`) plus the native `models` namespace. `models === tools.models`; `tools.models()` retains legacy model listing. Use `await models.getAvailableOfType('classifier')` (or `'image'`), then `models.classify(model,{state,questions})` or `models.generateImages(model,{input})`. Check native `stopReason`/`errorMessage`; classifier yes/no questions use `type:'bool'` and return `probability`. Call known MCP tools as `mcp.<sanitized_server>.<sanitized_tool>(args)`, captured tools as `extensions.<tool>(args)`, and stable providers as `memory.*`, `state.*`, `schema.*`, or `compact.*`. Use `tools.call({ref,args})` for computed refs. `pi` is the core tools; `\u03C0.<key>` reads named `strings` (not a tool)." : "Call known actions through `mcp.<sanitized_server>.<sanitized_tool>(args)`, `memory.*`, `state.*`, `schema.*`, `components.*`, `compact.*`, `agents.*`, or `mesh.*`; use `tools.catalog`/`search`/`describe`/`list` for discovery and `tools.call({ref,args})` for computed refs. Other surfaces are opt-in via user-loaded skills.";
|
|
2302
|
-
var manifestNameCache = /* @__PURE__ */ new Map();
|
|
2303
|
-
var packageNameFromManifest = (startPath) => {
|
|
2304
|
-
if (!startPath) return void 0;
|
|
2305
|
-
let directory = path4.dirname(path4.resolve(startPath));
|
|
2306
|
-
while (true) {
|
|
2307
|
-
if (manifestNameCache.has(directory)) return manifestNameCache.get(directory);
|
|
2308
|
-
const manifestPath = path4.join(directory, "package.json");
|
|
2309
|
-
let name;
|
|
2310
|
-
if (existsSync2(manifestPath)) {
|
|
2311
|
-
try {
|
|
2312
|
-
const manifest = JSON.parse(readFileSync2(manifestPath, "utf8"));
|
|
2313
|
-
if (typeof manifest.name === "string" && manifest.name.trim()) name = manifest.name.trim();
|
|
2314
|
-
} catch {
|
|
2315
|
-
}
|
|
1528
|
+
/** Refusal message for `provider.name`, or undefined when the policy allows it. Seals. */
|
|
1529
|
+
refDenial(provider, name) {
|
|
1530
|
+
this.#sealed = true;
|
|
1531
|
+
return this.previewDenial(provider, name);
|
|
1532
|
+
}
|
|
1533
|
+
/**
|
|
1534
|
+
* The same decision as refDenial without sealing, for answers that admit no
|
|
1535
|
+
* work, such as which tools a program can reach.
|
|
1536
|
+
*/
|
|
1537
|
+
previewDenial(provider, name) {
|
|
1538
|
+
const policy = this.#policy;
|
|
1539
|
+
if (!policy) return void 0;
|
|
1540
|
+
const ref = `${provider}.${name}`;
|
|
1541
|
+
const prefix = `${ref} is refused by the Fabric host policy from ${policy.owner}`;
|
|
1542
|
+
if (policy.deniedProviders?.includes(provider)) {
|
|
1543
|
+
return `${prefix}: provider ${provider} is unavailable here (${policy.reason})`;
|
|
2316
1544
|
}
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
if (
|
|
2321
|
-
|
|
1545
|
+
if (HOOKED_PROVIDERS.has(provider)) {
|
|
1546
|
+
return policy.deniedTools?.includes(name) ? `${prefix}: tool ${name} is unavailable here (${policy.reason})` : void 0;
|
|
1547
|
+
}
|
|
1548
|
+
if (FABRIC_BUILTIN_READ_REFS.has(ref)) return void 0;
|
|
1549
|
+
if (policy.allowedRefs?.some((pattern) => refMatches(pattern, ref))) return void 0;
|
|
1550
|
+
return `${prefix}: actions outside pi.* and extensions.* need a host allowedRefs entry (${policy.reason})`;
|
|
2322
1551
|
}
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
const
|
|
2331
|
-
if (
|
|
2332
|
-
if (
|
|
2333
|
-
|
|
2334
|
-
const
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
const
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
else groups.set(label, [tool.name]);
|
|
1552
|
+
/** True when the policy refuses every action of a provider, so Fabric never lists it. Seals. */
|
|
1553
|
+
providerHidden(provider) {
|
|
1554
|
+
this.#sealed = true;
|
|
1555
|
+
return this.previewProviderHidden(provider);
|
|
1556
|
+
}
|
|
1557
|
+
/** Provider visibility without admitting work or sealing the policy. */
|
|
1558
|
+
previewProviderHidden(provider) {
|
|
1559
|
+
const policy = this.#policy;
|
|
1560
|
+
if (!policy) return false;
|
|
1561
|
+
if (policy.deniedProviders?.includes(provider)) return true;
|
|
1562
|
+
if (HOOKED_PROVIDERS.has(provider)) return false;
|
|
1563
|
+
const head = `${provider}.`;
|
|
1564
|
+
return ![...FABRIC_BUILTIN_READ_REFS].some((ref) => ref.startsWith(head)) && !(policy.allowedRefs ?? []).some((pattern) => pattern.startsWith(head));
|
|
1565
|
+
}
|
|
1566
|
+
/** Native executors run outside every tool hook, so any policy refuses them. Seals. */
|
|
1567
|
+
executorDenial() {
|
|
1568
|
+
this.#sealed = true;
|
|
1569
|
+
const policy = this.#policy;
|
|
1570
|
+
if (!policy) return void 0;
|
|
1571
|
+
return `Fabric host policy from ${policy.owner} refuses native executors (CPython, node-process, bun-process): ${policy.reason}`;
|
|
2344
1572
|
}
|
|
2345
|
-
return [
|
|
2346
|
-
`Registered extension tools are callable inside fabric_exec as \`extensions.<name>(args)\`; run \`${nativeProfile ? "fabric.tools" : "tools"}.list\` for full descriptions and schemas before re-implementing an effect with pi.bash.`,
|
|
2347
|
-
...[...groups.entries()].sort(([left], [right]) => left.localeCompare(right)).map(([label, names]) => "- " + label + ": " + names.join(", "))
|
|
2348
|
-
].join("\n");
|
|
2349
1573
|
};
|
|
2350
|
-
var
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
1574
|
+
var hostPolicyDigest = (policy) => {
|
|
1575
|
+
const sorted = (values) => values ? [...values].sort() : null;
|
|
1576
|
+
const canonical = JSON.stringify([
|
|
1577
|
+
policy.owner,
|
|
1578
|
+
policy.reason,
|
|
1579
|
+
sorted(policy.deniedTools),
|
|
1580
|
+
sorted(policy.deniedProviders),
|
|
1581
|
+
sorted(policy.allowedRefs)
|
|
1582
|
+
]);
|
|
1583
|
+
return `sha256:${createHash("sha256").update(canonical).digest("hex")}`;
|
|
2358
1584
|
};
|
|
2359
1585
|
|
|
2360
1586
|
// src/core/skill-prompt.ts
|
|
@@ -2362,10 +1588,10 @@ var SKILL_SECTION_HEADING = "The following skills provide specialized instructio
|
|
|
2362
1588
|
var PI_SKILL_LOAD_INSTRUCTION = "Use the read tool to load a skill's file when the task matches its description.";
|
|
2363
1589
|
var FABRIC_SKILL_LOAD_INSTRUCTION = "Use `pi.read` inside `fabric_exec` to load a skill's file when the task matches its description.";
|
|
2364
1590
|
var CWD_MARKER = "\nCurrent working directory:";
|
|
2365
|
-
var restoreSkillsForFullCodePrompt = (systemPrompt, skills, fullCodeMode = true) => {
|
|
1591
|
+
var restoreSkillsForFullCodePrompt = (systemPrompt, skills, fullCodeMode = true, skillReader = void 0) => {
|
|
2366
1592
|
const section = formatSkillsForPrompt([...skills]).replace(
|
|
2367
1593
|
PI_SKILL_LOAD_INSTRUCTION,
|
|
2368
|
-
fullCodeMode ? FABRIC_SKILL_LOAD_INSTRUCTION : PI_SKILL_LOAD_INSTRUCTION
|
|
1594
|
+
skillReader === null ? "" : skillReader !== void 0 ? `Use \`${skillReader}\` inside \`fabric_exec\` to load a skill's file when the task matches its description.` : fullCodeMode ? FABRIC_SKILL_LOAD_INSTRUCTION : PI_SKILL_LOAD_INSTRUCTION
|
|
2369
1595
|
);
|
|
2370
1596
|
const start = systemPrompt.indexOf(SKILL_SECTION_HEADING);
|
|
2371
1597
|
const end = start < 0 ? -1 : systemPrompt.indexOf("</available_skills>", start);
|
|
@@ -2380,9 +1606,9 @@ var restoreSkillsForFullCodePrompt = (systemPrompt, skills, fullCodeMode = true)
|
|
|
2380
1606
|
|
|
2381
1607
|
// src/core/kernel-skills.ts
|
|
2382
1608
|
import { statSync } from "node:fs";
|
|
2383
|
-
import
|
|
1609
|
+
import path3 from "node:path";
|
|
2384
1610
|
var fabricSkillPaths = (root, kernel) => {
|
|
2385
|
-
const selected =
|
|
1611
|
+
const selected = path3.join(root, kernel);
|
|
2386
1612
|
if (!statSync(selected, { throwIfNoEntry: false })?.isDirectory()) {
|
|
2387
1613
|
throw new Error(`Missing Fabric ${kernel} skill tree: ${selected}. Reinstall Fabric; no other-kernel fallback is available.`);
|
|
2388
1614
|
}
|
|
@@ -2523,38 +1749,6 @@ var FabricDirectToolApproval = class {
|
|
|
2523
1749
|
}
|
|
2524
1750
|
};
|
|
2525
1751
|
|
|
2526
|
-
// src/core/skill-references.ts
|
|
2527
|
-
var INVOCATION_VERB = /^\s*(?:[-*]\s*)?(?:(?:then|next|first|always|must|you must)\s+)?(?:run|invoke|load|start|follow|use)\b/i;
|
|
2528
|
-
var NEGATED_INVOCATION = /^\s*(?:[-*]\s*)?(?:do not|don't|never)\s+(?:run|invoke|load|start|follow|use)\b/i;
|
|
2529
|
-
var escapeRegex2 = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2530
|
-
var referencesSkill = (line, skillName) => {
|
|
2531
|
-
const name = escapeRegex2(skillName);
|
|
2532
|
-
return new RegExp(`/(?:skill:)?${name}(?=[\\s\`'".,;:!?<>)\\]}]|$)`, "i").test(line);
|
|
2533
|
-
};
|
|
2534
|
-
var buildSkillReferenceGuidance = (prompt, skills) => {
|
|
2535
|
-
const active = skills.find(
|
|
2536
|
-
(skill) => prompt.startsWith(`<skill name="${skill.name}" location="${skill.filePath}">`)
|
|
2537
|
-
);
|
|
2538
|
-
if (!active) return void 0;
|
|
2539
|
-
const closingTag = prompt.indexOf("</skill>");
|
|
2540
|
-
if (closingTag < 0) return void 0;
|
|
2541
|
-
const openingEnd = prompt.indexOf("\n\n");
|
|
2542
|
-
if (openingEnd < 0 || openingEnd >= closingTag) return void 0;
|
|
2543
|
-
const body = prompt.slice(openingEnd + 2, closingTag);
|
|
2544
|
-
const invocationLines = body.split("\n").filter((line) => INVOCATION_VERB.test(line) && !NEGATED_INVOCATION.test(line));
|
|
2545
|
-
const referenced = skills.filter(
|
|
2546
|
-
(skill) => skill.name !== active.name && skill.disableModelInvocation !== true && invocationLines.some((line) => referencesSkill(line, skill.name))
|
|
2547
|
-
);
|
|
2548
|
-
if (referenced.length === 0) return void 0;
|
|
2549
|
-
const mappings = referenced.map((skill) => `- /${skill.name} -> ${JSON.stringify(skill.filePath)}`).join("\n");
|
|
2550
|
-
return [
|
|
2551
|
-
`The active skill ${JSON.stringify(active.name)} is already expanded; do not reread ${JSON.stringify(active.filePath)}.`,
|
|
2552
|
-
"Resolve the skill invocations below before task exploration:",
|
|
2553
|
-
mappings,
|
|
2554
|
-
"Load each mapped SKILL.md through pi.read inside fabric_exec and follow it. Skill loading is a dependency, not task exploration. Continue the active workflow after tool results and later user replies until it completes."
|
|
2555
|
-
].join("\n");
|
|
2556
|
-
};
|
|
2557
|
-
|
|
2558
1752
|
// src/fabric-exec-tool.ts
|
|
2559
1753
|
import { Container as Container2, Text as Text2 } from "@earendil-works/pi-tui";
|
|
2560
1754
|
import { Type } from "typebox";
|
|
@@ -2574,8 +1768,8 @@ var formatFailureProgress = (trace) => {
|
|
|
2574
1768
|
);
|
|
2575
1769
|
if (completed.length === 0) return void 0;
|
|
2576
1770
|
const summaries = completed.slice(0, MAX_COMPLETED_CALLS).map((operation) => {
|
|
2577
|
-
const
|
|
2578
|
-
return typeof
|
|
1771
|
+
const path9 = operation.args.path;
|
|
1772
|
+
return typeof path9 === "string" ? `${operation.ref}(${compactPath(path9)})` : operation.ref;
|
|
2579
1773
|
});
|
|
2580
1774
|
const omitted = completed.length - summaries.length;
|
|
2581
1775
|
return [
|
|
@@ -2595,7 +1789,8 @@ var OPTIONAL_FABRIC_EXEC_KEYS = [
|
|
|
2595
1789
|
"timeout_ms",
|
|
2596
1790
|
"maxOutputTokens",
|
|
2597
1791
|
"max_output_tokens",
|
|
2598
|
-
"display"
|
|
1792
|
+
"display",
|
|
1793
|
+
"background"
|
|
2599
1794
|
];
|
|
2600
1795
|
var isRecord4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2601
1796
|
var looksLikeJsonObject = (text) => text.startsWith("{") && text.endsWith("}");
|
|
@@ -2694,17 +1889,18 @@ var FabricRepeatGuard = class {
|
|
|
2694
1889
|
this.warnAt = warnAt;
|
|
2695
1890
|
this.blockAt = blockAt;
|
|
2696
1891
|
}
|
|
2697
|
-
#
|
|
1892
|
+
#fingerprint;
|
|
2698
1893
|
#count = 0;
|
|
2699
|
-
observe(code) {
|
|
2700
|
-
|
|
2701
|
-
this.#
|
|
1894
|
+
observe(code, payloads) {
|
|
1895
|
+
const fingerprint = stableJsonHash([code, payloads ?? {}]);
|
|
1896
|
+
this.#count = fingerprint === this.#fingerprint ? this.#count + 1 : 1;
|
|
1897
|
+
this.#fingerprint = fingerprint;
|
|
2702
1898
|
return { count: this.#count, blocked: this.#count >= this.blockAt, warn: this.#count >= this.warnAt };
|
|
2703
1899
|
}
|
|
2704
1900
|
};
|
|
2705
1901
|
|
|
2706
1902
|
// src/ui/row-balance.ts
|
|
2707
|
-
import { truncateToWidth as
|
|
1903
|
+
import { truncateToWidth as truncateToWidth2 } from "@earendil-works/pi-tui";
|
|
2708
1904
|
var HiddenRowBorrowingComponent = class {
|
|
2709
1905
|
constructor(baseLimit, maxLimit, renderLimit, balance) {
|
|
2710
1906
|
this.baseLimit = baseLimit;
|
|
@@ -2736,7 +1932,7 @@ var HiddenRowBorrowingComponent = class {
|
|
|
2736
1932
|
}
|
|
2737
1933
|
this.#cachedWidth = width;
|
|
2738
1934
|
this.#cachedDeficit = deficit;
|
|
2739
|
-
this.#cachedRows = best.map((row) =>
|
|
1935
|
+
this.#cachedRows = best.map((row) => truncateToWidth2(row, Math.max(1, width)));
|
|
2740
1936
|
return this.#cachedRows;
|
|
2741
1937
|
}
|
|
2742
1938
|
invalidate() {
|
|
@@ -2785,19 +1981,19 @@ var PartialResultObserver = class {
|
|
|
2785
1981
|
};
|
|
2786
1982
|
|
|
2787
1983
|
// src/output-budget.ts
|
|
2788
|
-
import
|
|
2789
|
-
import
|
|
1984
|
+
import fs from "node:fs/promises";
|
|
1985
|
+
import path4 from "node:path";
|
|
2790
1986
|
var MAX_FAILURE_MODEL_OUTPUT_CHARS = 2e4;
|
|
2791
1987
|
var modelOutputBudget = (configuredMaxChars, success) => success ? configuredMaxChars : Math.min(configuredMaxChars, MAX_FAILURE_MODEL_OUTPUT_CHARS);
|
|
2792
1988
|
var writeOutputArtifact = async (content) => {
|
|
2793
1989
|
const directory = createScratch("output");
|
|
2794
1990
|
try {
|
|
2795
|
-
const artifactPath =
|
|
2796
|
-
await
|
|
1991
|
+
const artifactPath = path4.join(directory, "output.txt");
|
|
1992
|
+
await fs.writeFile(artifactPath, content, { encoding: "utf8", mode: 384, flag: "wx" });
|
|
2797
1993
|
closeScratch(directory);
|
|
2798
1994
|
return artifactPath;
|
|
2799
1995
|
} catch (error) {
|
|
2800
|
-
await
|
|
1996
|
+
await fs.rm(directory, { recursive: true, force: true }).catch(() => void 0);
|
|
2801
1997
|
throw error;
|
|
2802
1998
|
}
|
|
2803
1999
|
};
|
|
@@ -2840,16 +2036,19 @@ var RESULT_FORMATS = ["auto", "yaml", "json", "text"];
|
|
|
2840
2036
|
var MAX_FABRIC_CODE_TRANSFER_LINES = 12;
|
|
2841
2037
|
var toolDisplayMode = (state) => state.bootstrapped ? state.config.ui.toolDisplay : "full";
|
|
2842
2038
|
var toolKernel = (state) => state.bootstrapped ? state.config.executor?.kernel ?? "typescript" : "typescript";
|
|
2843
|
-
var compactResultHeader = (theme, audits, failed) => {
|
|
2844
|
-
const failedCalls = audits.filter((audit) => audit.success === false).length;
|
|
2039
|
+
var compactResultHeader = (theme, audits, failed, omittedCalls2 = 0, omittedFailed = 0) => {
|
|
2040
|
+
const failedCalls = audits.filter((audit) => audit.success === false).length + omittedFailed;
|
|
2845
2041
|
const isFailed = failed || failedCalls > 0;
|
|
2846
2042
|
return theme.fg(isFailed ? "error" : "success", `${isFailed ? "\u2717" : "\u2713"} Tools`) + theme.fg(
|
|
2847
2043
|
"dim",
|
|
2848
|
-
` \xB7 ${countLabel(audits.length, "call")}${failedCalls > 0 ? ` \xB7 ${failedCalls} failed` : ""}`
|
|
2044
|
+
` \xB7 ${countLabel(audits.length + omittedCalls2, "call")}${failedCalls > 0 ? ` \xB7 ${failedCalls} failed` : ""}`
|
|
2849
2045
|
);
|
|
2850
2046
|
};
|
|
2851
2047
|
var countLabel = (count, singular) => `${count} ${count === 1 ? singular : `${singular}s`}`;
|
|
2852
|
-
var
|
|
2048
|
+
var FABRIC_DETACHED_OUTPUT_CHARS = 6e3;
|
|
2049
|
+
var fabricDetachedText = (taskId, elapsedMs, requested) => `[fabric_exec ${requested ? "started in the background" : `moved to the background by the user after ${Math.max(1, Math.round(elapsedMs / 1e3))}s`} as task ${taskId}. It keeps running with its tools, child agents, and approvals; its result arrives automatically as a background task event when it finishes. Continue independent work, or end this turn if you need the result. Do not start the same program again. The user can now steer you while it runs. Inspect with tools.call({ref:'tasks.get',args:{id}}); stop with tasks.stop. Its child agents stay steerable with agents.steer.]`;
|
|
2050
|
+
var createFabricExecTool = (state, codePreviewSettings, pendingHandoffs, decorateShell = withCodePreviewShell, toolDisplay, terminalTitle) => {
|
|
2051
|
+
const managedHost = state.managedHostOptions;
|
|
2853
2052
|
const python = toolKernel(state) === "python";
|
|
2854
2053
|
const monty = python && state.config.executor.pythonRuntime === "monty";
|
|
2855
2054
|
const repeatGuard = new FabricRepeatGuard(FABRIC_REPEAT_WARN, FABRIC_REPEAT_BLOCK);
|
|
@@ -2867,9 +2066,11 @@ var createFabricExecTool = (state, codePreviewSettings, pendingHandoffs, decorat
|
|
|
2867
2066
|
);
|
|
2868
2067
|
},
|
|
2869
2068
|
label: "Fabric",
|
|
2870
|
-
description: python ? monty ? "Execute Python through Fabric's configured Monty sandbox. Monty runs a Python subset with VM resource limits, no native filesystem/network/environment access, and only host-mediated tools. Each invocation starts fresh. This is the exclusive model tool path in full code mode and Schema enforce mode." : "Execute Python through Fabric\u2019s configured CPython kernel for Pi core tools, MCP, providers, discovery, and extensions. Each call uses a fresh process. Native execution is trusted code; Schema enforce requires OS isolation. This is the exclusive model tool path in full code mode and Schema enforce mode." : "Execute code through Fabric's TypeScript kernel: type-checked TypeScript by default, unmodified JavaScript with executor.codemodeProfile native. Both support nativeTools; native mode places Pi-compatible calls on tools and Fabric discovery on fabric.tools. Compose Pi core tools, MCP, Fabric providers, discovery, and extensions. QuickJS is isolated by default; the optional Node/Bun process is an unsafe trusted-code escape hatch. In full code mode, and always in Schema enforce mode, this is the exclusive model tool path.",
|
|
2871
|
-
promptSnippet: "Pi core tools, MCP, Fabric providers, discovery, and extensions",
|
|
2872
|
-
promptGuidelines: [
|
|
2069
|
+
description: managedHost ? "Execute type-checked TypeScript in the managed QuickJS runtime. See the managed execution guidance for authorized tool contracts." : python ? monty ? "Execute Python through Fabric's configured Monty sandbox. Monty runs a Python subset with VM resource limits, no native filesystem/network/environment access, and only host-mediated tools. Each invocation starts fresh. This is the exclusive model tool path in full code mode and Schema enforce mode." : "Execute Python through Fabric\u2019s configured CPython kernel for Pi core tools, MCP, providers, discovery, and extensions. Each call uses a fresh process. Native execution is trusted code; Schema enforce requires OS isolation. This is the exclusive model tool path in full code mode and Schema enforce mode." : "Execute code through Fabric's TypeScript kernel: type-checked TypeScript by default, unmodified JavaScript with executor.codemodeProfile native. Both support nativeTools; native mode places Pi-compatible calls on tools and Fabric discovery on fabric.tools. Compose Pi core tools, MCP, Fabric providers, discovery, and extensions. QuickJS is isolated by default; the optional Node/Bun process is an unsafe trusted-code escape hatch. In full code mode, and always in Schema enforce mode, this is the exclusive model tool path.",
|
|
2070
|
+
promptSnippet: managedHost ? `Authorized host tools (${managedHost.providers.join(", ") || "none"}) and deterministic computation` : "Pi core tools, MCP, Fabric providers, discovery, and extensions",
|
|
2071
|
+
promptGuidelines: managedHost ? [
|
|
2072
|
+
"Batch independent operations with bounded concurrency, keep dependent calls ordered, inspect results, and return compact evidence."
|
|
2073
|
+
] : [
|
|
2873
2074
|
python ? "Batch independent operations in one `fabric_exec` Python program with `asyncio.gather`; await dependent/conditional steps sequentially. Coalesce independent replacements into one `await pi.edit(path=..., edits=[...])`. Return only the compact final JSON-compatible value." : "Batch independent operations in one `fabric_exec` program (`Promise.all` for parallel, sequential `await` for ordered), not one call per tool; keep dependent/conditional steps sequential. Coalesce non-dependent replacements from one file snapshot into one `pi.edit({path, edits:[...]})`; use `all:true` only for intentional repeated exact anchors. Return only the compact final value; intermediate results stay in the sandbox.",
|
|
2874
2075
|
python ? "Search before reading with `await pi.grep(pattern=..., path=...)` or `await pi.find(pattern=..., path=...)`, then `await pi.read(path=..., offset=..., limit=...)`. Use Python dict syntax, `True`/`False`/`None`, and bounded searches; unbounded reads cap at 2000 lines or 50KB. Read continuation notices when needed." : "Search before reading: use `pi.grep`/`pi.find` to locate relevant lines, then `pi.read({path, offset, limit})` that range. Escape regex metacharacters, or use `literal:true` for exact punctuated text. Keep fan-out search limits small and widen only on misses. An unbounded `pi.read` returns at most 2000 lines or 50KB and, when truncated, ends with a `Use offset=\u2026` continuation notice; reserve whole-file reads for small files you will use in full.",
|
|
2875
2076
|
"Keep the acceptance ledger in reasoning or concise progress notes (no tool call): define concrete checks, trace execution before editing, implement end to end, then run targeted tests and direct behavioral probes. Confirm requested public symbols, registrations, and configuration entries. Use the smallest checks that cover the ledger; escalate only for failures or cross-cutting risk. Inspect failures and iterate instead of rerunning unchanged passing checks. A build alone is not completion.",
|
|
@@ -2895,7 +2096,7 @@ var createFabricExecTool = (state, codePreviewSettings, pendingHandoffs, decorat
|
|
|
2895
2096
|
// back to Record<string, string> before Pi validates.
|
|
2896
2097
|
parameters: Type.Object({
|
|
2897
2098
|
code: Type.String({
|
|
2898
|
-
description: python ? monty ? "Python async function body executed by Monty, a sandboxed Python subset (not CPython). Top-level await/return and asyncio.gather are supported. Use only Monty's supported syntax/modules; native imports, filesystem, network, and environment are unavailable. Host globals: tools, mcp, memory, state, schema, compact, cache, thinking, components, agents, mesh; full-code mode adds pi and extensions. Await dict/keyword calls; use native dict results r['output']. Payloads: \u03C0.key or payloads['key']. Return JSON-compatible data; each invocation starts fresh." : "Python async function body executed by CPython. Top-level await and return are supported; standard-library imports are available. Globals: tools, mcp, memory, state, schema, compact, cache, thinking, components, agents, mesh; full-code mode adds pi and extensions. Await host calls using a dict or keyword arguments. Results are native dicts/lists: r['output'], not r.output. Use asyncio.gather for concurrency. Named payloads are \u03C0.key or payloads['key']. Return a JSON-compatible value. Each call starts fresh." : "TypeScript function body. Top-level await and return are supported. Globals include `tools`, `mcp`, `memory`, `state`, `schema`, `compact`, `cache`, `thinking`, `agents`, `mesh`, `print`, and `\u03C0`; full-code mode adds `pi` and `extensions`. `\u03C0` contains only the exact keys supplied by this call's `payloads`. See session guidance / `fabric-exec` skill for exact signatures."
|
|
2099
|
+
description: managedHost ? "TypeScript async function body. Top-level await and return are supported. Named payloads are available as \u03C0.key. Follow the managed execution guidance for discovery and tool calls." : python ? monty ? "Python async function body executed by Monty, a sandboxed Python subset (not CPython). Top-level await/return and asyncio.gather are supported. Use only Monty's supported syntax/modules; native imports, filesystem, network, and environment are unavailable. Host globals: tools, mcp, memory, state, schema, compact, cache, thinking, components, agents, mesh; full-code mode adds pi and extensions. Await dict/keyword calls; use native dict results r['output']. Payloads: \u03C0.key or payloads['key']. Return JSON-compatible data; each invocation starts fresh." : "Python async function body executed by CPython. Top-level await and return are supported; standard-library imports are available. Globals: tools, mcp, memory, state, schema, compact, cache, thinking, components, agents, mesh; full-code mode adds pi and extensions. Await host calls using a dict or keyword arguments. Results are native dicts/lists: r['output'], not r.output. Use asyncio.gather for concurrency. Named payloads are \u03C0.key or payloads['key']. Return a JSON-compatible value. Each call starts fresh." : "TypeScript function body. Top-level await and return are supported. Globals include `tools`, `mcp`, `memory`, `state`, `schema`, `compact`, `cache`, `thinking`, `agents`, `mesh`, `print`, and `\u03C0`; full-code mode adds `pi` and `extensions`. `\u03C0` contains only the exact keys supplied by this call's `payloads`. See session guidance / `fabric-exec` skill for exact signatures."
|
|
2899
2100
|
}),
|
|
2900
2101
|
payloads: Type.Optional(
|
|
2901
2102
|
Type.Record(Type.String(), Type.String(), {
|
|
@@ -2923,6 +2124,9 @@ var createFabricExecTool = (state, codePreviewSettings, pendingHandoffs, decorat
|
|
|
2923
2124
|
description: "Optional whole-program deadline in ms for this invocation; raises (never lowers) the configured executor.timeoutMs, capped by executor.maxTimeoutMs"
|
|
2924
2125
|
})
|
|
2925
2126
|
),
|
|
2127
|
+
background: Type.Optional(Type.Boolean({
|
|
2128
|
+
description: "Run the program as a background task and return at once; its result arrives as a background task event. Use for long workflows (many agents) whose result you do not need before continuing."
|
|
2129
|
+
})),
|
|
2926
2130
|
timeout_ms: Type.Optional(Type.Integer({ minimum: 1, description: "Hard whole-script deadline in milliseconds; cannot be extended or paused, capped by executor.maxTimeoutMs." })),
|
|
2927
2131
|
maxOutputTokens: Type.Optional(Type.Integer({ minimum: 1, description: "Per-call output token budget (estimated at four characters per token), capped by executor.maxOutputChars." })),
|
|
2928
2132
|
max_output_tokens: Type.Optional(Type.Integer({ minimum: 1, description: "Alias of maxOutputTokens." })),
|
|
@@ -3100,6 +2304,13 @@ ${preview}` : ""}${hiddenHint}`,
|
|
|
3100
2304
|
audits = restoreFabricWritePreviews(audits, rendererState.fabricWritePreviews);
|
|
3101
2305
|
}
|
|
3102
2306
|
}
|
|
2307
|
+
audits = audits.filter((audit) => !isRoutineInternalCall(audit));
|
|
2308
|
+
const internal = details.omittedCalls?.internal ?? 0;
|
|
2309
|
+
if (details.omittedCalls && internal > 0) {
|
|
2310
|
+
const count = details.omittedCalls.count - internal;
|
|
2311
|
+
if (count > 0) details.omittedCalls = { ...details.omittedCalls, count, done: details.omittedCalls.done - internal, internal: 0 };
|
|
2312
|
+
else delete details.omittedCalls;
|
|
2313
|
+
}
|
|
3103
2314
|
const phases = details.phases;
|
|
3104
2315
|
const nl = "\n";
|
|
3105
2316
|
const allRowIndexes = (lines, enabled) => enabled ? new Set(lines.map((_line, index) => index)) : void 0;
|
|
@@ -3133,16 +2344,19 @@ ${preview}` : ""}${hiddenHint}`,
|
|
|
3133
2344
|
};
|
|
3134
2345
|
if (isPartial) {
|
|
3135
2346
|
const progress = details.progress;
|
|
3136
|
-
if (audits.length === 0) {
|
|
2347
|
+
if (audits.length === 0 && !details.omittedCalls) {
|
|
3137
2348
|
const label = compact ? "Running\u2026" : progress ?? "Running Fabric program\u2026";
|
|
3138
2349
|
return trackRows(
|
|
3139
2350
|
new Text2(theme.fg("warning", `\u25C6 ${safeTerminalText(label)}`), 0, 0)
|
|
3140
2351
|
);
|
|
3141
2352
|
}
|
|
3142
|
-
if (audits.length === 1) {
|
|
2353
|
+
if (audits.length === 1 && !details.omittedCalls) {
|
|
3143
2354
|
const audit = audits[0];
|
|
3144
2355
|
const glyph = audit.success === void 0 ? theme.fg("warning", spinner) : audit.success === false ? theme.fg("error", "\u2717") : theme.fg("dim", "\u203A");
|
|
3145
2356
|
let text2 = `${glyph} ${nestedCallTitle(audit, theme, context?.invalidate, corePreviewContext)}`;
|
|
2357
|
+
if (shellBackgroundShortcut(audit)) {
|
|
2358
|
+
text2 += nl + theme.fg("dim", "Ctrl+B twice \xB7 background waiting shell");
|
|
2359
|
+
}
|
|
3146
2360
|
const previewLines = renderAgentToolPreviewLines(audit, theme, {
|
|
3147
2361
|
expanded,
|
|
3148
2362
|
showTools: showAgentToolPreview,
|
|
@@ -3203,6 +2417,7 @@ ${preview}` : ""}${hiddenHint}`,
|
|
|
3203
2417
|
progress,
|
|
3204
2418
|
expanded,
|
|
3205
2419
|
preview,
|
|
2420
|
+
omittedCalls: details.omittedCalls,
|
|
3206
2421
|
core: corePreviewContext,
|
|
3207
2422
|
showAgentToolPreview,
|
|
3208
2423
|
spinner,
|
|
@@ -3243,7 +2458,8 @@ ${preview}` : ""}${hiddenHint}`,
|
|
|
3243
2458
|
];
|
|
3244
2459
|
};
|
|
3245
2460
|
const failed = details.success === false;
|
|
3246
|
-
|
|
2461
|
+
const omittedCalls2 = details.omittedCalls?.count ?? 0;
|
|
2462
|
+
if (audits.length === 0 && omittedCalls2 === 0) {
|
|
3247
2463
|
if (failed && details.error) {
|
|
3248
2464
|
return trackRows(
|
|
3249
2465
|
new Text2(
|
|
@@ -3275,7 +2491,7 @@ ${preview}` : ""}${hiddenHint}`,
|
|
|
3275
2491
|
renderBoundedLines(text2.split(nl), theme, codePreviewSettings.diffIntensity)
|
|
3276
2492
|
);
|
|
3277
2493
|
}
|
|
3278
|
-
if (audits.length === 1) {
|
|
2494
|
+
if (audits.length === 1 && omittedCalls2 === 0) {
|
|
3279
2495
|
const audit = audits[0];
|
|
3280
2496
|
let text2 = compact ? `${compactResultHeader(theme, audits, failed)}${nl}${nestedCallTitle(
|
|
3281
2497
|
audit,
|
|
@@ -3333,15 +2549,15 @@ ${preview}` : ""}${hiddenHint}`,
|
|
|
3333
2549
|
}
|
|
3334
2550
|
const failedCalls = audits.filter(
|
|
3335
2551
|
(audit) => audit.success === false
|
|
3336
|
-
).length;
|
|
2552
|
+
).length + (details.omittedCalls?.failed ?? 0);
|
|
3337
2553
|
const status = failed ? "failed" : "complete";
|
|
3338
2554
|
const statusColor = failed ? "error" : "success";
|
|
3339
2555
|
const metadata = [
|
|
3340
|
-
countLabel(audits.length, "nested call"),
|
|
2556
|
+
countLabel(audits.length + omittedCalls2, "nested call"),
|
|
3341
2557
|
failedCalls > 0 ? `${failedCalls} failed` : void 0,
|
|
3342
2558
|
phases.length > 0 ? countLabel(phases.length, "phase") : void 0
|
|
3343
2559
|
].filter((value) => Boolean(value));
|
|
3344
|
-
let text = compact ? compactResultHeader(theme, audits, failed) : theme.fg(
|
|
2560
|
+
let text = compact ? compactResultHeader(theme, audits, failed, omittedCalls2, details.omittedCalls?.failed ?? 0) : theme.fg(
|
|
3345
2561
|
statusColor,
|
|
3346
2562
|
`${failed ? "\u2717" : "\u2713"} Fabric ${status}`
|
|
3347
2563
|
);
|
|
@@ -3350,7 +2566,7 @@ ${preview}` : ""}${hiddenHint}`,
|
|
|
3350
2566
|
text += nl + theme.fg("dim", phases.map((phase) => `\u25C6 ${phase}`).join(" "));
|
|
3351
2567
|
const callLimit = fabricMulticallCallLimit(expanded);
|
|
3352
2568
|
const callsShown = audits.slice(0, callLimit);
|
|
3353
|
-
const callsHidden = audits.length - callsShown.length;
|
|
2569
|
+
const callsHidden = audits.length + omittedCalls2 - callsShown.length;
|
|
3354
2570
|
let collapsedPreview;
|
|
3355
2571
|
if (!expanded) {
|
|
3356
2572
|
for (let index = callsShown.length - 1; index >= 0; index--) {
|
|
@@ -3444,7 +2660,8 @@ ${preview}` : ""}${hiddenHint}`,
|
|
|
3444
2660
|
await state.ensure(context);
|
|
3445
2661
|
const joined = Array.isArray(params.code) ? params.code.join("\n") : params.code;
|
|
3446
2662
|
const code = state.config.executor.kernel === "python" ? joined : repairFabricGuestCode(joined);
|
|
3447
|
-
const
|
|
2663
|
+
const strings = resolveFabricExecPayloads(params);
|
|
2664
|
+
const repeat = repeatGuard.observe(code, strings);
|
|
3448
2665
|
if (repeat.blocked) {
|
|
3449
2666
|
return {
|
|
3450
2667
|
content: [{ type: "text", text: fabricRepeatBlockText(repeat.count) }],
|
|
@@ -3453,12 +2670,20 @@ ${preview}` : ""}${hiddenHint}`,
|
|
|
3453
2670
|
};
|
|
3454
2671
|
}
|
|
3455
2672
|
const runDisplay = normalizeRunDisplay(params.display);
|
|
3456
|
-
const strings = resolveFabricExecPayloads(params);
|
|
3457
2673
|
const tokenBudget = "tokenBudget" in params && typeof params.tokenBudget === "number" ? params.tokenBudget : void 0;
|
|
3458
|
-
|
|
2674
|
+
terminalTitle?.show(context, runDisplay?.name);
|
|
2675
|
+
const program = state.programTasks?.begin({
|
|
2676
|
+
code,
|
|
2677
|
+
...runDisplay?.name ? { description: runDisplay.name } : {},
|
|
2678
|
+
cwd: context.cwd,
|
|
2679
|
+
...signal ? { parentSignal: signal } : {},
|
|
2680
|
+
jobs: () => state.shellJobs
|
|
2681
|
+
});
|
|
2682
|
+
if (params.background === true) program?.detach();
|
|
2683
|
+
const execution = state.execution.execute({
|
|
3459
2684
|
code,
|
|
3460
2685
|
...strings ? { strings } : {},
|
|
3461
|
-
signal,
|
|
2686
|
+
signal: program?.signal ?? signal,
|
|
3462
2687
|
parentToolCallId: toolCallId,
|
|
3463
2688
|
context,
|
|
3464
2689
|
...tokenBudget !== void 0 ? { tokenBudget } : {},
|
|
@@ -3472,132 +2697,157 @@ ${preview}` : ""}${hiddenHint}`,
|
|
|
3472
2697
|
}
|
|
3473
2698
|
} : {},
|
|
3474
2699
|
onPartial(snapshot) {
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
}
|
|
2700
|
+
program?.progress(snapshot.progress);
|
|
2701
|
+
if (program?.job || !onUpdate) return;
|
|
2702
|
+
const details = createFabricPartialExecutionDetails(snapshot);
|
|
2703
|
+
onUpdate({
|
|
2704
|
+
content: [{ type: "text", text: details.progress ?? "" }],
|
|
2705
|
+
details
|
|
3482
2706
|
});
|
|
3483
2707
|
}
|
|
3484
2708
|
});
|
|
3485
|
-
const
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
if (pendingHandoff) {
|
|
3494
|
-
pendingHandoffs.set(toolCallId, pendingHandoff);
|
|
3495
|
-
context.ui.setStatus(
|
|
3496
|
-
"fabric-prewalk",
|
|
3497
|
-
`waiting for fabric_exec boundary \u2192 ${String(pendingHandoff.args.model ?? "executor")}`
|
|
2709
|
+
const finishExecution = async (result, detached) => {
|
|
2710
|
+
const selectedResultFormat = params.resultFormat ?? state.config.executor.resultFormat;
|
|
2711
|
+
const boundarySessionId = context.sessionManager.getSessionId();
|
|
2712
|
+
const pendingHandoff = detached ? void 0 : await state.claimHandoff(
|
|
2713
|
+
result,
|
|
2714
|
+
boundarySessionId,
|
|
2715
|
+
selectedResultFormat,
|
|
2716
|
+
toolCallId
|
|
3498
2717
|
);
|
|
3499
|
-
if (pendingHandoff
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
"
|
|
2718
|
+
if (pendingHandoff) {
|
|
2719
|
+
pendingHandoffs.set(toolCallId, pendingHandoff);
|
|
2720
|
+
context.ui.setStatus(
|
|
2721
|
+
"fabric-prewalk",
|
|
2722
|
+
`waiting for fabric_exec boundary \u2192 ${String(pendingHandoff.args.model ?? "executor")}`
|
|
2723
|
+
);
|
|
2724
|
+
if (pendingHandoff.readiness?.kind === "unplanned") {
|
|
2725
|
+
context.ui.notify(
|
|
2726
|
+
`Prewalk: handing off without a recorded plan after ${pendingHandoff.readiness.prompts} reminders.`,
|
|
2727
|
+
"warning"
|
|
2728
|
+
);
|
|
2729
|
+
}
|
|
2730
|
+
} else if (!detached && state.prewalk.planRequired(boundarySessionId)) {
|
|
2731
|
+
const prewalkStatus = state.prewalk.status();
|
|
2732
|
+
context.ui.setStatus(
|
|
2733
|
+
"fabric-prewalk",
|
|
2734
|
+
prewalkStatus.state === "armed" ? `plan awaited \u2192 ${prewalkStatus.model}` : void 0
|
|
3503
2735
|
);
|
|
3504
2736
|
}
|
|
3505
|
-
|
|
3506
|
-
const
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
);
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
const recoveryHint = typeErrorRecoveryHint(code, result.typeErrors);
|
|
3552
|
-
const bounded = await boundModelOutput(
|
|
3553
|
-
`Type errors; code was not executed:
|
|
2737
|
+
const fullFormattedValue = formatFabricValue(result.value, selectedResultFormat);
|
|
2738
|
+
const failureProgress = formatFailureProgress(result.trace);
|
|
2739
|
+
const fullSections = [...result.logs];
|
|
2740
|
+
if (fullFormattedValue.text) fullSections.push(fullFormattedValue.text);
|
|
2741
|
+
if (result.error) fullSections.push(`Runtime error: ${result.error}`);
|
|
2742
|
+
if (failureProgress) fullSections.push(failureProgress);
|
|
2743
|
+
if (repeat.warn) fullSections.push(fabricRepeatWarnText(repeat.count, FABRIC_REPEAT_BLOCK));
|
|
2744
|
+
const fullRawOutput = fullSections.join("\n\n");
|
|
2745
|
+
const outputBudget = modelOutputBudget(
|
|
2746
|
+
Math.min(
|
|
2747
|
+
state.config.executor.maxOutputChars,
|
|
2748
|
+
(params.maxOutputTokens ?? params.max_output_tokens ?? Infinity) * 4,
|
|
2749
|
+
detached ? FABRIC_DETACHED_OUTPUT_CHARS : Infinity
|
|
2750
|
+
),
|
|
2751
|
+
result.success
|
|
2752
|
+
);
|
|
2753
|
+
const outputWillTruncate = fullRawOutput.length > outputBudget;
|
|
2754
|
+
const formattedValue = outputWillTruncate ? formatFabricValue(
|
|
2755
|
+
result.value,
|
|
2756
|
+
selectedResultFormat,
|
|
2757
|
+
outputBudget
|
|
2758
|
+
) : fullFormattedValue;
|
|
2759
|
+
const sections = [...result.logs];
|
|
2760
|
+
const logPrefix = result.logs.join("\n\n");
|
|
2761
|
+
if (formattedValue.text) sections.push(formattedValue.text);
|
|
2762
|
+
if (result.error) sections.push(`Runtime error: ${result.error}`);
|
|
2763
|
+
if (failureProgress) sections.push(failureProgress);
|
|
2764
|
+
if (repeat.warn) sections.push(fabricRepeatWarnText(repeat.count, FABRIC_REPEAT_BLOCK));
|
|
2765
|
+
const rawOutput = sections.join("\n\n");
|
|
2766
|
+
const outputFormat = formattedValue.language && formattedValue.text && (result.logs.length === 0 || !outputWillTruncate) ? formattedValue.language : void 0;
|
|
2767
|
+
const outputFormatStartLine = result.logs.length > 0 ? countNewlines(logPrefix) + 2 : 0;
|
|
2768
|
+
const persistedRenderDetails = () => createFabricPersistedExecutionDetails({
|
|
2769
|
+
...result,
|
|
2770
|
+
...outputFormat ? { outputFormat, outputFormatStartLine } : {},
|
|
2771
|
+
...outputFormat ? {
|
|
2772
|
+
outputFormatLines: formattedValue.highlightedLineCount ?? countNewlines(formattedValue.text) + 1
|
|
2773
|
+
} : {}
|
|
2774
|
+
});
|
|
2775
|
+
if (result.typeErrors) {
|
|
2776
|
+
const text = result.typeErrors.map(
|
|
2777
|
+
(error) => error.line > 0 ? `Line ${error.line}:${error.column} \u2014 ${error.message}` : error.message
|
|
2778
|
+
).join("\n");
|
|
2779
|
+
const { typeErrorRecoveryHint } = await import("../type-error-guidance.js");
|
|
2780
|
+
const recoveryHint = typeErrorRecoveryHint(code, result.typeErrors);
|
|
2781
|
+
const bounded = await boundModelOutput(
|
|
2782
|
+
`Type errors; code was not executed:
|
|
3554
2783
|
${text}${recoveryHint ? `
|
|
3555
2784
|
|
|
3556
2785
|
${recoveryHint}` : ""}`,
|
|
3557
|
-
|
|
3558
|
-
|
|
2786
|
+
outputBudget
|
|
2787
|
+
);
|
|
2788
|
+
return {
|
|
2789
|
+
content: [{ type: "text", text: bounded.text }],
|
|
2790
|
+
details: persistedRenderDetails(),
|
|
2791
|
+
isError: true
|
|
2792
|
+
};
|
|
2793
|
+
}
|
|
2794
|
+
const output = (await boundModelOutput(
|
|
2795
|
+
rawOutput || "(no output)",
|
|
2796
|
+
outputBudget,
|
|
2797
|
+
fullRawOutput || "(no output)"
|
|
2798
|
+
)).text;
|
|
2799
|
+
const inPlaceContinuation = pendingHandoff?.kind === "prewalk-in-place";
|
|
2800
|
+
const nestedTerminate = result.success && result.audits.some((audit) => audit.terminate === true && audit.success === true);
|
|
2801
|
+
const terminate = !inPlaceContinuation && (pendingHandoff !== void 0 || nestedTerminate || result.success && typeof result.value === "object" && result.value !== null && "terminate" in result.value && result.value.terminate === true);
|
|
2802
|
+
const mediaBlocks = [];
|
|
2803
|
+
for (const block of result.media ?? []) mediaBlocks.push(block);
|
|
2804
|
+
for (const audit of result.audits) {
|
|
2805
|
+
if (audit.media) mediaBlocks.push(...audit.media);
|
|
2806
|
+
}
|
|
2807
|
+
const singleAudit = result.audits.length === 1 ? result.audits[0] : void 0;
|
|
2808
|
+
const mediaNote = singleAudit?.mediaNote;
|
|
2809
|
+
for (const audit of result.audits) {
|
|
2810
|
+
delete audit.media;
|
|
2811
|
+
delete audit.mediaNote;
|
|
2812
|
+
}
|
|
2813
|
+
const content = [];
|
|
2814
|
+
if (mediaBlocks.length > 0) {
|
|
2815
|
+
const textOutput = singleAudit && mediaNote ? mediaNote : output === "(no output)" ? "" : output;
|
|
2816
|
+
if (textOutput) content.push({ type: "text", text: textOutput });
|
|
2817
|
+
for (const block of mediaBlocks) content.push(block);
|
|
2818
|
+
if (singleAudit && mediaNote) {
|
|
2819
|
+
singleAudit.result = mediaNote;
|
|
2820
|
+
}
|
|
2821
|
+
} else {
|
|
2822
|
+
content.push({ type: "text", text: output });
|
|
2823
|
+
}
|
|
3559
2824
|
return {
|
|
3560
|
-
content
|
|
2825
|
+
content,
|
|
3561
2826
|
details: persistedRenderDetails(),
|
|
3562
|
-
|
|
2827
|
+
...result.usage ? { usage: result.usage } : {},
|
|
2828
|
+
...terminate ? { terminate: true } : {},
|
|
2829
|
+
...result.success ? {} : { isError: true }
|
|
3563
2830
|
};
|
|
3564
|
-
}
|
|
3565
|
-
const output = (await boundModelOutput(
|
|
3566
|
-
rawOutput || "(no output)",
|
|
3567
|
-
outputBudget,
|
|
3568
|
-
fullRawOutput || "(no output)"
|
|
3569
|
-
)).text;
|
|
3570
|
-
const inPlaceContinuation = pendingHandoff?.kind === "prewalk-in-place";
|
|
3571
|
-
const terminate = !inPlaceContinuation && (pendingHandoff !== void 0 || result.success && typeof result.value === "object" && result.value !== null && "terminate" in result.value && result.value.terminate === true);
|
|
3572
|
-
const mediaBlocks = [];
|
|
3573
|
-
for (const block of result.media ?? []) mediaBlocks.push(block);
|
|
3574
|
-
for (const audit of result.audits) {
|
|
3575
|
-
if (audit.media) mediaBlocks.push(...audit.media);
|
|
3576
|
-
}
|
|
3577
|
-
const singleAudit = result.audits.length === 1 ? result.audits[0] : void 0;
|
|
3578
|
-
const mediaNote = singleAudit?.mediaNote;
|
|
3579
|
-
for (const audit of result.audits) {
|
|
3580
|
-
delete audit.media;
|
|
3581
|
-
delete audit.mediaNote;
|
|
3582
|
-
}
|
|
3583
|
-
const content = [];
|
|
3584
|
-
if (mediaBlocks.length > 0) {
|
|
3585
|
-
const textOutput = singleAudit && mediaNote ? mediaNote : output === "(no output)" ? "" : output;
|
|
3586
|
-
if (textOutput) content.push({ type: "text", text: textOutput });
|
|
3587
|
-
for (const block of mediaBlocks) content.push(block);
|
|
3588
|
-
if (singleAudit && mediaNote) {
|
|
3589
|
-
singleAudit.result = mediaNote;
|
|
3590
|
-
}
|
|
3591
|
-
} else {
|
|
3592
|
-
content.push({ type: "text", text: output });
|
|
3593
|
-
}
|
|
3594
|
-
return {
|
|
3595
|
-
content,
|
|
3596
|
-
details: persistedRenderDetails(),
|
|
3597
|
-
...result.usage ? { usage: result.usage } : {},
|
|
3598
|
-
...terminate ? { terminate: true } : {},
|
|
3599
|
-
...result.success ? {} : { isError: true }
|
|
3600
2831
|
};
|
|
2832
|
+
const raced = program ? await program.race(execution) : { detached: false, value: await execution };
|
|
2833
|
+
if (raced.detached) {
|
|
2834
|
+
void execution.then(
|
|
2835
|
+
async (result) => {
|
|
2836
|
+
const finished = await finishExecution(result, true);
|
|
2837
|
+
const text = finished.content.map((part) => part.type === "text" ? part.text : "[image omitted]").join("\n");
|
|
2838
|
+
await program.complete(text, !finished.isError);
|
|
2839
|
+
},
|
|
2840
|
+
(error) => program.complete(
|
|
2841
|
+
`Runtime error: ${error instanceof Error ? error.message : String(error)}`,
|
|
2842
|
+
false
|
|
2843
|
+
)
|
|
2844
|
+
).catch(() => void 0);
|
|
2845
|
+
return {
|
|
2846
|
+
content: [{ type: "text", text: fabricDetachedText(raced.job.id, raced.elapsedMs, params.background === true) }],
|
|
2847
|
+
details: void 0
|
|
2848
|
+
};
|
|
2849
|
+
}
|
|
2850
|
+
return finishExecution(raced.value, false);
|
|
3601
2851
|
}
|
|
3602
2852
|
}),
|
|
3603
2853
|
{
|
|
@@ -3608,18 +2858,28 @@ ${recoveryHint}` : ""}`,
|
|
|
3608
2858
|
};
|
|
3609
2859
|
|
|
3610
2860
|
// src/fabric-state.ts
|
|
3611
|
-
import
|
|
3612
|
-
import
|
|
2861
|
+
import fs2 from "node:fs";
|
|
2862
|
+
import path5 from "node:path";
|
|
3613
2863
|
|
|
3614
2864
|
// src/managed-host.ts
|
|
3615
2865
|
var REPLACEABLE = /* @__PURE__ */ new Set(["agents", "memory", "compact", "schema", "state", "mesh", "mcp"]);
|
|
3616
2866
|
var FabricManagedHost = class {
|
|
2867
|
+
options;
|
|
3617
2868
|
#allowed;
|
|
3618
2869
|
#providers = /* @__PURE__ */ new Map();
|
|
3619
2870
|
#retired = /* @__PURE__ */ new Set();
|
|
3620
2871
|
#sealed = false;
|
|
3621
2872
|
constructor(options) {
|
|
3622
|
-
|
|
2873
|
+
const foreground = options.foreground ?? [];
|
|
2874
|
+
foregroundConfigValue({ tools: foreground.map((name) => ({ name, owner: "managed-host", reason: "human-input" })), maxTools: MAX_FOREGROUND_TOOLS });
|
|
2875
|
+
if (foreground.length > MAX_FOREGROUND_TOOLS) throw new Error(`managedHost.foreground accepts at most ${MAX_FOREGROUND_TOOLS} tools`);
|
|
2876
|
+
if (options.skillReader !== void 0 && !/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)+$/.test(options.skillReader)) throw new Error("managedHost.skillReader must be a dotted callable name");
|
|
2877
|
+
if (options.guidance !== void 0 && typeof options.guidance !== "string") throw new Error("managedHost.guidance must be a string");
|
|
2878
|
+
if (options.compaction !== void 0 && !["fabric", "pi"].includes(options.compaction)) throw new Error("Invalid managedHost.compaction");
|
|
2879
|
+
const maxCpuSliceMs = options.executor?.maxCpuSliceMs ?? 1e3;
|
|
2880
|
+
if (!Number.isSafeInteger(maxCpuSliceMs) || maxCpuSliceMs <= 0) throw new Error("managedHost.executor.maxCpuSliceMs must be a positive safe integer");
|
|
2881
|
+
this.options = Object.freeze({ ...options, providers: Object.freeze([...options.providers]), foreground: Object.freeze([...foreground]), executor: Object.freeze({ maxCpuSliceMs }) });
|
|
2882
|
+
this.#allowed = new Set(this.options.providers);
|
|
3623
2883
|
for (const name of this.#allowed) if (!REPLACEABLE.has(name)) throw new Error(`Managed host cannot replace provider: ${name}`);
|
|
3624
2884
|
}
|
|
3625
2885
|
register(provider, overwrite = false) {
|
|
@@ -3669,6 +2929,8 @@ var FabricManagedHost = class {
|
|
|
3669
2929
|
config.fullCodeMode = true;
|
|
3670
2930
|
config.executor.kernel = "typescript";
|
|
3671
2931
|
config.executor.runtime = "quickjs";
|
|
2932
|
+
config.executor.maxCpuSliceMs = this.options.executor.maxCpuSliceMs;
|
|
2933
|
+
config.foreground = { tools: this.options.foreground.map((name) => ({ name, owner: "managed-host", reason: "human-input" })), maxTools: MAX_FOREGROUND_TOOLS };
|
|
3672
2934
|
config.mcp.enabled = false;
|
|
3673
2935
|
config.mcp.allowDynamicServers = false;
|
|
3674
2936
|
config.mesh.enabled = false;
|
|
@@ -3679,11 +2941,12 @@ var FabricManagedHost = class {
|
|
|
3679
2941
|
config.repairs.enabled = false;
|
|
3680
2942
|
config.entropy.compile = false;
|
|
3681
2943
|
config.speculation.enabled = false;
|
|
2944
|
+
config.jev.enabled = false;
|
|
3682
2945
|
config.ui.enabled = false;
|
|
3683
2946
|
config.schema.mode = "off";
|
|
3684
2947
|
config.schema.trustedCommands = {};
|
|
3685
2948
|
config.components = [];
|
|
3686
|
-
config.compaction.engine = "fabric";
|
|
2949
|
+
config.compaction.engine = this.options.compaction ?? "fabric";
|
|
3687
2950
|
config.approvals = { ...config.approvals, read: "allow", write: "allow", execute: "allow", agent: "allow", network: "deny" };
|
|
3688
2951
|
return config;
|
|
3689
2952
|
}
|
|
@@ -3695,6 +2958,114 @@ var FabricManagedHost = class {
|
|
|
3695
2958
|
}
|
|
3696
2959
|
};
|
|
3697
2960
|
|
|
2961
|
+
// src/core/program-tasks.ts
|
|
2962
|
+
var FabricProgramRun = class {
|
|
2963
|
+
constructor(owner, options) {
|
|
2964
|
+
this.owner = owner;
|
|
2965
|
+
this.options = options;
|
|
2966
|
+
const parent = options.parentSignal;
|
|
2967
|
+
if (parent?.aborted) this.#onParentAbort();
|
|
2968
|
+
else parent?.addEventListener("abort", this.#onParentAbort, { once: true });
|
|
2969
|
+
}
|
|
2970
|
+
#relay = new AbortController();
|
|
2971
|
+
#startedAt = Date.now();
|
|
2972
|
+
#onParentAbort = () => {
|
|
2973
|
+
if (!this.#job) this.#relay.abort(this.options.parentSignal?.reason ?? new Error("fabric_exec aborted"));
|
|
2974
|
+
};
|
|
2975
|
+
#job;
|
|
2976
|
+
#settled = false;
|
|
2977
|
+
#progress;
|
|
2978
|
+
#wake;
|
|
2979
|
+
get signal() {
|
|
2980
|
+
return this.#relay.signal;
|
|
2981
|
+
}
|
|
2982
|
+
get job() {
|
|
2983
|
+
return this.#job;
|
|
2984
|
+
}
|
|
2985
|
+
get waiting() {
|
|
2986
|
+
return !this.#job && !this.#settled && !this.#relay.signal.aborted;
|
|
2987
|
+
}
|
|
2988
|
+
/** Moves the program into the session task store; false when it cannot leave. */
|
|
2989
|
+
detach() {
|
|
2990
|
+
if (!this.waiting) return false;
|
|
2991
|
+
const jobs = this.options.jobs();
|
|
2992
|
+
if (!jobs) return false;
|
|
2993
|
+
let job;
|
|
2994
|
+
try {
|
|
2995
|
+
job = jobs.begin("fabric_exec", this.options.code, {
|
|
2996
|
+
...this.options.description ? { description: this.options.description } : {},
|
|
2997
|
+
...this.options.cwd ? { cwd: this.options.cwd } : {}
|
|
2998
|
+
});
|
|
2999
|
+
} catch {
|
|
3000
|
+
return false;
|
|
3001
|
+
}
|
|
3002
|
+
this.#job = job;
|
|
3003
|
+
this.options.parentSignal?.removeEventListener("abort", this.#onParentAbort);
|
|
3004
|
+
job.abort.signal.addEventListener("abort", () => this.#relay.abort(job.abort.signal.reason), { once: true });
|
|
3005
|
+
if (this.#progress) job.append(Buffer.from(`${this.#progress}
|
|
3006
|
+
`));
|
|
3007
|
+
job.spill();
|
|
3008
|
+
void job.persistLog().catch(() => void 0);
|
|
3009
|
+
this.owner.release(this);
|
|
3010
|
+
this.#wake?.();
|
|
3011
|
+
return true;
|
|
3012
|
+
}
|
|
3013
|
+
/** Mirrors changed progress into the task's output once detached. */
|
|
3014
|
+
progress(text) {
|
|
3015
|
+
if (!text || text === this.#progress) return;
|
|
3016
|
+
this.#progress = text;
|
|
3017
|
+
this.#job?.append(Buffer.from(`${text}
|
|
3018
|
+
`));
|
|
3019
|
+
}
|
|
3020
|
+
/** Settles with the program, or earlier when it is detached. */
|
|
3021
|
+
async race(work) {
|
|
3022
|
+
const detached = new Promise((resolve) => {
|
|
3023
|
+
this.#wake = () => resolve("detached");
|
|
3024
|
+
if (this.#job) resolve("detached");
|
|
3025
|
+
});
|
|
3026
|
+
const first = await Promise.race([
|
|
3027
|
+
work.then((value) => ({ value }), (error) => ({ error })),
|
|
3028
|
+
detached
|
|
3029
|
+
]);
|
|
3030
|
+
if (first === "detached") return { detached: true, job: this.#job, elapsedMs: Date.now() - this.#startedAt };
|
|
3031
|
+
this.#settled = true;
|
|
3032
|
+
this.owner.release(this);
|
|
3033
|
+
if ("error" in first) throw first.error;
|
|
3034
|
+
return { detached: false, value: first.value };
|
|
3035
|
+
}
|
|
3036
|
+
/** Records the program's final model-facing text and ends the task. */
|
|
3037
|
+
async complete(text, success) {
|
|
3038
|
+
this.#settled = true;
|
|
3039
|
+
const job = this.#job;
|
|
3040
|
+
if (!job || job.finished) return;
|
|
3041
|
+
job.append(Buffer.from(`${text}
|
|
3042
|
+
`));
|
|
3043
|
+
job.exitCode = success ? 0 : 1;
|
|
3044
|
+
await job.finish(job.exitCode);
|
|
3045
|
+
}
|
|
3046
|
+
};
|
|
3047
|
+
var FabricProgramTasks = class {
|
|
3048
|
+
#waiting = /* @__PURE__ */ new Set();
|
|
3049
|
+
begin(options) {
|
|
3050
|
+
const run = new FabricProgramRun(this, options);
|
|
3051
|
+
this.#waiting.add(run);
|
|
3052
|
+
return run;
|
|
3053
|
+
}
|
|
3054
|
+
release(run) {
|
|
3055
|
+
this.#waiting.delete(run);
|
|
3056
|
+
}
|
|
3057
|
+
waiting() {
|
|
3058
|
+
let count = 0;
|
|
3059
|
+
for (const run of this.#waiting) if (run.waiting) count++;
|
|
3060
|
+
return count;
|
|
3061
|
+
}
|
|
3062
|
+
detachWaiting() {
|
|
3063
|
+
let count = 0;
|
|
3064
|
+
for (const run of [...this.#waiting]) if (run.detach()) count++;
|
|
3065
|
+
return count;
|
|
3066
|
+
}
|
|
3067
|
+
};
|
|
3068
|
+
|
|
3698
3069
|
// src/fabric-state.ts
|
|
3699
3070
|
var FabricState = class {
|
|
3700
3071
|
constructor(pi, capturedTools, options = {}) {
|
|
@@ -3728,6 +3099,12 @@ var FabricState = class {
|
|
|
3728
3099
|
prewalk = new PrewalkController();
|
|
3729
3100
|
prewalkDrift = new PrewalkDriftTracker();
|
|
3730
3101
|
sessionApprovals = new FabricSessionApprovals();
|
|
3102
|
+
/** Extension hooks registered over pi.events; consulted only when approvals.policyHooks is true. */
|
|
3103
|
+
actionPolicyHooks = new FabricActionPolicyHooks();
|
|
3104
|
+
/** Question renderers registered over pi.events; consulted only when ui.questionRenderers is true. */
|
|
3105
|
+
questionRenderers = new FabricQuestionRenderers();
|
|
3106
|
+
/** Foreground `fabric_exec` programs the Ctrl+B chord can move to the background. */
|
|
3107
|
+
programTasks = new FabricProgramTasks();
|
|
3731
3108
|
// agent_end must revert an override even before activation; the controller
|
|
3732
3109
|
// itself loads only when an override can exist.
|
|
3733
3110
|
thinking;
|
|
@@ -3752,6 +3129,9 @@ var FabricState = class {
|
|
|
3752
3129
|
if (!this.#config) throw new Error("Pi Fabric has not bootstrapped");
|
|
3753
3130
|
return this.#config;
|
|
3754
3131
|
}
|
|
3132
|
+
get managedHostOptions() {
|
|
3133
|
+
return this.#managedHost?.options;
|
|
3134
|
+
}
|
|
3755
3135
|
get cwd() {
|
|
3756
3136
|
return this.#cwd;
|
|
3757
3137
|
}
|
|
@@ -3763,6 +3143,7 @@ var FabricState = class {
|
|
|
3763
3143
|
policy: config.foreground,
|
|
3764
3144
|
mode: config.schema.mode === "enforce" ? "enforce" : config.fullCodeMode ? "full-code" : "orchestration",
|
|
3765
3145
|
managedHost: this.#managedHost !== void 0,
|
|
3146
|
+
managedForeground: this.#managedHost?.options.foreground,
|
|
3766
3147
|
registered: this.pi.getAllTools(),
|
|
3767
3148
|
active: new Set(active ?? this.pi.getActiveTools()),
|
|
3768
3149
|
allowlist: readChildToolAllowlist()
|
|
@@ -3869,15 +3250,15 @@ var FabricState = class {
|
|
|
3869
3250
|
const sessionId = context.sessionManager.getSessionId();
|
|
3870
3251
|
if (resolveFabricIdentity(sessionId).identity.kind !== "main") return false;
|
|
3871
3252
|
const projectRoot = process.env.PI_FABRIC_PROJECT_ROOT ?? context.cwd;
|
|
3872
|
-
const meshRoot = process.env.PI_FABRIC_MESH_ROOT ?? (this.config.mesh.root ?
|
|
3253
|
+
const meshRoot = process.env.PI_FABRIC_MESH_ROOT ?? (this.config.mesh.root ? path5.resolve(projectRoot, this.config.mesh.root) : path5.join(projectRoot, ".pi", "fabric", "mesh"));
|
|
3873
3254
|
const fabricSessionId = process.env.PI_FABRIC_SESSION_ID?.trim() || sessionId;
|
|
3874
3255
|
const actorRoots = [
|
|
3875
|
-
|
|
3876
|
-
|
|
3256
|
+
path5.join(meshRoot, "actors"),
|
|
3257
|
+
path5.join(meshRoot, "actors", fabricSessionId)
|
|
3877
3258
|
];
|
|
3878
3259
|
return actorRoots.some((actorRoot) => {
|
|
3879
3260
|
try {
|
|
3880
|
-
const registry = JSON.parse(
|
|
3261
|
+
const registry = JSON.parse(fs2.readFileSync(path5.join(actorRoot, "actors.json"), "utf8"));
|
|
3881
3262
|
if (typeof registry !== "object" || registry === null || Array.isArray(registry)) return false;
|
|
3882
3263
|
const actors = registry.actors;
|
|
3883
3264
|
return Array.isArray(actors) && actors.some((value) => {
|
|
@@ -3896,6 +3277,16 @@ var FabricState = class {
|
|
|
3896
3277
|
peerInfos() {
|
|
3897
3278
|
return this.#current()?.peerInfos() ?? [];
|
|
3898
3279
|
}
|
|
3280
|
+
sessionLabel() {
|
|
3281
|
+
return this.#current()?.sessionLabel();
|
|
3282
|
+
}
|
|
3283
|
+
sessionLabelPending() {
|
|
3284
|
+
return this.#current()?.sessionLabelPending() ?? false;
|
|
3285
|
+
}
|
|
3286
|
+
/** Managed hosts do not expose decisions, matching the `decisions.*` provider. */
|
|
3287
|
+
decisionStore() {
|
|
3288
|
+
return this.#managedHost ? void 0 : this.#current()?.decisionStore();
|
|
3289
|
+
}
|
|
3899
3290
|
componentGraph() {
|
|
3900
3291
|
return this.#current()?.componentGraph() ?? { components: [], edges: [], cycles: [] };
|
|
3901
3292
|
}
|
|
@@ -3905,6 +3296,9 @@ var FabricState = class {
|
|
|
3905
3296
|
participantInfos(options = {}) {
|
|
3906
3297
|
return this.#current()?.participantInfos(options) ?? [];
|
|
3907
3298
|
}
|
|
3299
|
+
residentAgentForUi(id) {
|
|
3300
|
+
return this.#current()?.residentAgentForUi(id);
|
|
3301
|
+
}
|
|
3908
3302
|
queueUserMessage(targetId, message, delivery) {
|
|
3909
3303
|
return this.#required().queueUserMessage(targetId, message, delivery);
|
|
3910
3304
|
}
|
|
@@ -4141,10 +3535,14 @@ var FabricState = class {
|
|
|
4141
3535
|
prewalk: this.prewalk,
|
|
4142
3536
|
prewalkDrift: this.prewalkDrift,
|
|
4143
3537
|
sessionApprovals: this.sessionApprovals,
|
|
3538
|
+
actionPolicyHooks: this.actionPolicyHooks,
|
|
3539
|
+
questionRenderers: this.questionRenderers,
|
|
4144
3540
|
thinking: await this.thinking.load(),
|
|
4145
3541
|
...this.#options.paths ? { paths: this.#options.paths } : {},
|
|
4146
3542
|
...this.#entryIdentity ? { entryIdentity: this.#entryIdentity } : {},
|
|
4147
|
-
foregroundTools: () => this.foregroundTools().tools
|
|
3543
|
+
foregroundTools: () => this.foregroundTools().tools,
|
|
3544
|
+
compactionOwner: this.#options.compactionOwner,
|
|
3545
|
+
...this.#options.hostPolicy ? { hostPolicy: this.#options.hostPolicy } : {}
|
|
4148
3546
|
}
|
|
4149
3547
|
);
|
|
4150
3548
|
}
|
|
@@ -4157,6 +3555,39 @@ var FabricState = class {
|
|
|
4157
3555
|
return runtime;
|
|
4158
3556
|
}
|
|
4159
3557
|
};
|
|
3558
|
+
var FabricQuestionRenderers = class {
|
|
3559
|
+
#renderers = /* @__PURE__ */ new Map();
|
|
3560
|
+
get size() {
|
|
3561
|
+
return this.#renderers.size;
|
|
3562
|
+
}
|
|
3563
|
+
/**
|
|
3564
|
+
* Register `render` under `name`; the same name replaces an earlier
|
|
3565
|
+
* renderer in its original position, so a reloaded extension does not stack
|
|
3566
|
+
* copies. The returned function removes only this registration.
|
|
3567
|
+
*/
|
|
3568
|
+
register(name, render) {
|
|
3569
|
+
if (!ACTION_POLICY_HOOK_NAME_PATTERN.test(name)) {
|
|
3570
|
+
throw new Error("Question renderer name must match [A-Za-z0-9@][A-Za-z0-9@._/-]{0,63}");
|
|
3571
|
+
}
|
|
3572
|
+
if (typeof render !== "function") throw new Error("Question renderer must be a function");
|
|
3573
|
+
const registration = { render };
|
|
3574
|
+
this.#renderers.set(name, registration);
|
|
3575
|
+
return () => {
|
|
3576
|
+
if (this.#renderers.get(name) === registration) this.#renderers.delete(name);
|
|
3577
|
+
};
|
|
3578
|
+
}
|
|
3579
|
+
clear() {
|
|
3580
|
+
this.#renderers.clear();
|
|
3581
|
+
}
|
|
3582
|
+
/** A snapshot in registration order. */
|
|
3583
|
+
list() {
|
|
3584
|
+
return [...this.#renderers].map(([name, { render }]) => ({ name, render }));
|
|
3585
|
+
}
|
|
3586
|
+
/** This registry when `ui.questionRenderers` is true and a renderer is registered; otherwise undefined. */
|
|
3587
|
+
active(enabled) {
|
|
3588
|
+
return enabled === true && this.size > 0 ? this : void 0;
|
|
3589
|
+
}
|
|
3590
|
+
};
|
|
4160
3591
|
var branchHasThinkingOverride = (context) => {
|
|
4161
3592
|
const branch = context.sessionManager.getBranch();
|
|
4162
3593
|
for (let index = branch.length - 1; index >= 0; index -= 1) {
|
|
@@ -4365,8 +3796,8 @@ var classifyToolResult = (input) => {
|
|
|
4365
3796
|
};
|
|
4366
3797
|
|
|
4367
3798
|
// src/host-compatibility.ts
|
|
4368
|
-
import { existsSync as
|
|
4369
|
-
import
|
|
3799
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "node:fs";
|
|
3800
|
+
import path6 from "node:path";
|
|
4370
3801
|
var MINIMUM_PI_HOST_VERSION = "1.0.0";
|
|
4371
3802
|
var PI_HOST_PACKAGE_NAMES = /* @__PURE__ */ new Set([
|
|
4372
3803
|
"@earendil-works/pi-coding-agent",
|
|
@@ -4397,22 +3828,22 @@ var detectPiHostVersion = (cliPath = process.argv[1]) => {
|
|
|
4397
3828
|
if (!cliPath) return void 0;
|
|
4398
3829
|
let directory;
|
|
4399
3830
|
try {
|
|
4400
|
-
directory =
|
|
3831
|
+
directory = path6.dirname(realpathSync2(cliPath));
|
|
4401
3832
|
} catch {
|
|
4402
3833
|
return void 0;
|
|
4403
3834
|
}
|
|
4404
3835
|
while (true) {
|
|
4405
|
-
const manifestPath =
|
|
4406
|
-
if (
|
|
3836
|
+
const manifestPath = path6.join(directory, "package.json");
|
|
3837
|
+
if (existsSync2(manifestPath)) {
|
|
4407
3838
|
try {
|
|
4408
|
-
const manifest = JSON.parse(
|
|
3839
|
+
const manifest = JSON.parse(readFileSync2(manifestPath, "utf8"));
|
|
4409
3840
|
if (typeof manifest.name === "string" && PI_HOST_PACKAGE_NAMES.has(manifest.name) && typeof manifest.version === "string") {
|
|
4410
3841
|
return manifest.version;
|
|
4411
3842
|
}
|
|
4412
3843
|
} catch {
|
|
4413
3844
|
}
|
|
4414
3845
|
}
|
|
4415
|
-
const parent =
|
|
3846
|
+
const parent = path6.dirname(directory);
|
|
4416
3847
|
if (parent === directory) return void 0;
|
|
4417
3848
|
directory = parent;
|
|
4418
3849
|
}
|
|
@@ -4425,7 +3856,8 @@ var piHostCompatibilityWarning = (version = detectPiHostVersion()) => {
|
|
|
4425
3856
|
};
|
|
4426
3857
|
|
|
4427
3858
|
// src/ui/controller.ts
|
|
4428
|
-
import
|
|
3859
|
+
import path7 from "node:path";
|
|
3860
|
+
import { matchesKey as matchesKey2 } from "@earendil-works/pi-tui";
|
|
4429
3861
|
|
|
4430
3862
|
// src/ui/snapshot.ts
|
|
4431
3863
|
import { isDeepStrictEqual } from "node:util";
|
|
@@ -4491,15 +3923,30 @@ var createDashboardSnapshot = (state, events, context, activityRuns, cache, immu
|
|
|
4491
3923
|
const actorRecords = state.actors.list();
|
|
4492
3924
|
const main = state.mainAgentInfo(context);
|
|
4493
3925
|
const peers = typeof state.peerInfos === "function" ? state.peerInfos() : [];
|
|
4494
|
-
|
|
3926
|
+
let globalActors;
|
|
3927
|
+
try {
|
|
3928
|
+
globalActors = state.globalActors.list();
|
|
3929
|
+
} catch {
|
|
3930
|
+
globalActors = [];
|
|
3931
|
+
}
|
|
4495
3932
|
const componentGraph = typeof state.componentGraph === "function" ? state.componentGraph() : { components: [], edges: [], cycles: [] };
|
|
4496
3933
|
const meshEntries = state.config.mesh.enabled ? state.mesh.list("", 200) : [];
|
|
4497
3934
|
const shells = state.shellJobs?.list().filter((job) => job.spilledAt !== void 0 || job.monitor) ?? [];
|
|
3935
|
+
const sessionLabel = typeof state.sessionLabel === "function" ? state.sessionLabel() : void 0;
|
|
3936
|
+
const residentLogs = {};
|
|
3937
|
+
if (typeof state.residentAgentForUi === "function") {
|
|
3938
|
+
for (const participant of participants) {
|
|
3939
|
+
if (participant.kind !== "agent" || participant.rootId !== main.id || participant.residency !== "durable") continue;
|
|
3940
|
+
const record = state.residentAgentForUi(participant.id);
|
|
3941
|
+
if (record && isRunRecord(record) && record.logFile) residentLogs[participant.id] = record.logFile;
|
|
3942
|
+
}
|
|
3943
|
+
}
|
|
4498
3944
|
const inputs = {
|
|
4499
3945
|
runs,
|
|
4500
3946
|
agentRecords,
|
|
4501
3947
|
actorRecords,
|
|
4502
3948
|
participants,
|
|
3949
|
+
residentLogs,
|
|
4503
3950
|
main,
|
|
4504
3951
|
peers,
|
|
4505
3952
|
shells,
|
|
@@ -4507,7 +3954,8 @@ var createDashboardSnapshot = (state, events, context, activityRuns, cache, immu
|
|
|
4507
3954
|
componentGraph,
|
|
4508
3955
|
meshEntries,
|
|
4509
3956
|
events,
|
|
4510
|
-
widgetDismissedAt: state.widgetDismissedAt
|
|
3957
|
+
widgetDismissedAt: state.widgetDismissedAt,
|
|
3958
|
+
sessionLabel
|
|
4511
3959
|
};
|
|
4512
3960
|
const previous = cache?.get(inputs);
|
|
4513
3961
|
if (previous) return previous;
|
|
@@ -4556,6 +4004,7 @@ var createDashboardSnapshot = (state, events, context, activityRuns, cache, immu
|
|
|
4556
4004
|
updatedAt: record.updatedAt,
|
|
4557
4005
|
...record.finishedAt !== void 0 ? { finishedAt: record.finishedAt } : {},
|
|
4558
4006
|
...record.currentTool ? { currentTool: record.currentTool } : {},
|
|
4007
|
+
...record.milestone ? { milestone: record.milestone } : {},
|
|
4559
4008
|
turns: record.turns,
|
|
4560
4009
|
toolCalls: record.toolCalls,
|
|
4561
4010
|
usage: { ...record.usage },
|
|
@@ -4618,6 +4067,7 @@ var createDashboardSnapshot = (state, events, context, activityRuns, cache, immu
|
|
|
4618
4067
|
cwd: participant.cwd ?? "",
|
|
4619
4068
|
...participant.model ? { model: participant.model } : {},
|
|
4620
4069
|
...participant.thinking ? { thinking: participant.thinking } : {},
|
|
4070
|
+
...residentLogs[participant.id] ? { logFile: residentLogs[participant.id] } : {},
|
|
4621
4071
|
...participant.currentTool ? { currentTool: participant.currentTool } : {},
|
|
4622
4072
|
startedAt: participant.startedAt,
|
|
4623
4073
|
updatedAt: participant.updatedAt,
|
|
@@ -4658,6 +4108,7 @@ var createDashboardSnapshot = (state, events, context, activityRuns, cache, immu
|
|
|
4658
4108
|
main,
|
|
4659
4109
|
peers,
|
|
4660
4110
|
participants,
|
|
4111
|
+
...sessionLabel ? { sessionLabel } : {},
|
|
4661
4112
|
widgetDismissedAt: state.widgetDismissedAt,
|
|
4662
4113
|
globalActors,
|
|
4663
4114
|
agents: visibleAgents,
|
|
@@ -4675,7 +4126,7 @@ var createDashboardSnapshot = (state, events, context, activityRuns, cache, immu
|
|
|
4675
4126
|
};
|
|
4676
4127
|
|
|
4677
4128
|
// src/ui/widget.ts
|
|
4678
|
-
import { matchesKey, truncateToWidth as
|
|
4129
|
+
import { matchesKey, truncateToWidth as truncateToWidth3, visibleWidth as visibleWidth2 } from "@earendil-works/pi-tui";
|
|
4679
4130
|
|
|
4680
4131
|
// src/ui/retention.ts
|
|
4681
4132
|
var WIDGET_FINISHED_RETENTION_MS = 3e4;
|
|
@@ -4732,15 +4183,7 @@ var FabricWidgetRetention = class {
|
|
|
4732
4183
|
};
|
|
4733
4184
|
|
|
4734
4185
|
// src/ui/widget.ts
|
|
4735
|
-
var
|
|
4736
|
-
if (status === "completed" || status === "done" || status === "exited") return "\u2713";
|
|
4737
|
-
if (status === "failed" || status === "timed_out") return "\u2717";
|
|
4738
|
-
if (status === "blocked") return "!";
|
|
4739
|
-
if (status === "stopped" || status === "cancelled" || status === "killed") return "\u25A0";
|
|
4740
|
-
if (status === "queued" || status === "pending" || status === "ready") return "\u25CB";
|
|
4741
|
-
if (status === "idle" || status === "state") return "\xB7";
|
|
4742
|
-
return spinnerFrame();
|
|
4743
|
-
};
|
|
4186
|
+
var circle = (selected) => selected ? "\u25CF" : "\u25CB";
|
|
4744
4187
|
var colorStatus = (theme, status, value) => {
|
|
4745
4188
|
if (status === "completed" || status === "done" || status === "exited") return theme.fg("success", value);
|
|
4746
4189
|
if (status === "failed" || status === "timed_out") return theme.fg("error", value);
|
|
@@ -4751,7 +4194,7 @@ var colorStatus = (theme, status, value) => {
|
|
|
4751
4194
|
var phaseProgress = (run, phaseId) => {
|
|
4752
4195
|
const phase = run.phases.find((candidate) => candidate.id === phaseId);
|
|
4753
4196
|
const statuses = [
|
|
4754
|
-
...run.calls.filter((call) => call.phaseId === phaseId).map((call) => call.status),
|
|
4197
|
+
...run.calls.filter((call) => !isRoutineInternalCall(call) && call.phaseId === phaseId).map((call) => call.status),
|
|
4755
4198
|
...run.items.filter((item) => item.phaseId === phaseId).map((item) => item.status)
|
|
4756
4199
|
];
|
|
4757
4200
|
const completed = statuses.filter((status) => status === "completed").length;
|
|
@@ -4762,23 +4205,70 @@ var totalTokens = (snapshot, run) => snapshot.agents.filter((agent) => run ? age
|
|
|
4762
4205
|
0
|
|
4763
4206
|
);
|
|
4764
4207
|
var totalCost = (snapshot, run) => snapshot.agents.filter((agent) => run ? agent.runId === run.id : isActiveStatus(agent.status)).reduce((sum, agent) => sum + (agent.usage?.cost ?? 0), 0);
|
|
4765
|
-
var
|
|
4766
|
-
|
|
4767
|
-
const
|
|
4208
|
+
var modelName = (model) => model ? safeText(model.slice(model.lastIndexOf("/") + 1)).trim() || void 0 : void 0;
|
|
4209
|
+
var fitLine = (theme, width, lead, flexible, detail, hints) => {
|
|
4210
|
+
const separator = theme.fg("dim", " \xB7 ");
|
|
4211
|
+
const compose = (flex2, details2, hintCount2) => {
|
|
4212
|
+
const tail = [...detail.slice(0, details2), ...hints.slice(0, hintCount2)];
|
|
4213
|
+
return `${lead}${flex2 ? `${flexible.gap}${theme.fg(flexible.color, flex2)}` : ""}${tail.length > 0 ? `${separator}${tail.map((part) => theme.fg("dim", part)).join(separator)}` : ""}`;
|
|
4214
|
+
};
|
|
4215
|
+
let details = detail.length;
|
|
4216
|
+
let hintCount = hints.length;
|
|
4217
|
+
let flex = flexible?.text;
|
|
4218
|
+
while (details > 0 && visibleWidth2(compose(flex, details, hintCount)) > width) details--;
|
|
4219
|
+
if (flex && visibleWidth2(compose(flex, details, hintCount)) > width) {
|
|
4220
|
+
const room = width - visibleWidth2(compose(void 0, details, hintCount)) - visibleWidth2(flexible.gap);
|
|
4221
|
+
flex = room >= 6 ? truncateToWidth3(flex, room, "\u2026") : void 0;
|
|
4222
|
+
}
|
|
4223
|
+
while (hintCount > 0 && visibleWidth2(compose(flex, details, hintCount)) > width) hintCount--;
|
|
4224
|
+
return truncateToWidth3(compose(flex, details, hintCount), width, "\u2026");
|
|
4225
|
+
};
|
|
4226
|
+
var treeOrder = (agents) => {
|
|
4227
|
+
const ids = new Set(agents.map((agent) => agent.id));
|
|
4228
|
+
const children = /* @__PURE__ */ new Map();
|
|
4229
|
+
const roots = [];
|
|
4230
|
+
for (const agent of agents) {
|
|
4231
|
+
const parentId = agent.parentId;
|
|
4232
|
+
if (parentId && parentId !== agent.id && ids.has(parentId)) {
|
|
4233
|
+
children.set(parentId, [...children.get(parentId) ?? [], agent]);
|
|
4234
|
+
} else roots.push(agent);
|
|
4235
|
+
}
|
|
4236
|
+
const ordered = [];
|
|
4237
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4238
|
+
const visit = (agent, ancestors, last) => {
|
|
4239
|
+
if (seen.has(agent.id)) return;
|
|
4240
|
+
seen.add(agent.id);
|
|
4241
|
+
const depth = ancestors.length;
|
|
4242
|
+
const prefix = depth === 0 ? "" : `${ancestors.slice(1).map((more) => more ? "\u2502 " : " ").join("")}${last ? "\u2514\u2500 " : "\u251C\u2500 "}`;
|
|
4243
|
+
ordered.push({ agent, depth, prefix });
|
|
4244
|
+
const descendants = (children.get(agent.id) ?? []).filter((child) => !seen.has(child.id));
|
|
4245
|
+
descendants.forEach((child, index) => visit(child, [...ancestors, !last], index === descendants.length - 1));
|
|
4246
|
+
};
|
|
4247
|
+
for (const root of roots) visit(root, [], true);
|
|
4248
|
+
for (const agent of agents) visit(agent, [], true);
|
|
4249
|
+
return ordered;
|
|
4250
|
+
};
|
|
4251
|
+
var agentLine = (theme, agent, now, prefix, selected, width) => {
|
|
4252
|
+
const status = colorStatus(theme, agent.status, circle(selected));
|
|
4253
|
+
const live = isActiveStatus(agent.status);
|
|
4254
|
+
const activity = live ? agent.milestone ?? agent.currentTool ?? (agent.status === "running" ? "thinking" : agent.status) : agent.error ? `error: ${safeText(agent.error)}` : agent.text ? `result: ${safeText(agent.text)}` : agent.status;
|
|
4768
4255
|
const metrics = [
|
|
4769
|
-
agent.
|
|
4256
|
+
modelName(agent.model),
|
|
4257
|
+
agent.toolCalls !== void 0 ? `${agent.toolCalls} call${agent.toolCalls === 1 ? "" : "s"}` : void 0,
|
|
4770
4258
|
agent.usage ? `${formatTokens(agent.usage.input + agent.usage.output)} tok` : void 0,
|
|
4771
4259
|
agent.startedAt ? formatDuration((agent.finishedAt ?? now) - agent.startedAt) : void 0
|
|
4772
4260
|
].filter((value) => Boolean(value));
|
|
4773
|
-
const
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4261
|
+
const name = safeText(agent.name);
|
|
4262
|
+
const prefixBudget = Math.max(0, Math.floor(width / 3));
|
|
4263
|
+
const compactPrefix = prefix.length <= prefixBudget ? prefix : prefixBudget >= 4 ? `\u2026${prefix.slice(-(prefixBudget - 1))}` : "";
|
|
4264
|
+
const lead = `${theme.fg("dim", compactPrefix)}${status} ${selected ? theme.bold(name) : theme.fg("muted", name)}`;
|
|
4265
|
+
return fitLine(theme, width, lead, { text: safeText(activity).replace(/\s+/g, " ").trim(), gap: " ", color: "muted" }, metrics, []);
|
|
4777
4266
|
};
|
|
4778
4267
|
var shouldShowFabricWidget = (snapshot, mode, retention = new FabricWidgetRetention()) => {
|
|
4779
4268
|
if (mode === "hidden") return false;
|
|
4780
4269
|
if (mode === "always") return true;
|
|
4781
4270
|
retention.sync(snapshot);
|
|
4271
|
+
if (snapshot.sessionLabel) return true;
|
|
4782
4272
|
if (snapshot.shells?.some((job) => job.finishedAt === void 0 || isRecentWidgetCompletion(job.finishedAt, snapshot.now))) return true;
|
|
4783
4273
|
if (snapshot.agents.some((agent) => retention.visible(agent, snapshot))) return true;
|
|
4784
4274
|
if (snapshot.actors.some((actor) => actor.status !== "stopped")) return true;
|
|
@@ -4797,13 +4287,15 @@ var widgetRowLimit = (maxRows, terminalRows) => {
|
|
|
4797
4287
|
const paneShare = Math.floor(terminalRows * WIDGET_TERMINAL_ROW_SHARE);
|
|
4798
4288
|
return Math.max(1, Math.min(configured, paneShare));
|
|
4799
4289
|
};
|
|
4800
|
-
var
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4290
|
+
var widgetFocusedRowLimit = (maxRows, terminalRows) => widgetRowLimit(maxRows, terminalRows);
|
|
4291
|
+
var widgetViewport = (contentRows, budget, offset) => {
|
|
4292
|
+
const available = Math.max(0, Math.floor(budget));
|
|
4293
|
+
const hasCue = contentRows > available && available > 1;
|
|
4294
|
+
const windowRows = Math.max(0, available - Number(hasCue));
|
|
4295
|
+
const maxOffset = windowRows > 0 ? Math.max(0, contentRows - windowRows) : 0;
|
|
4296
|
+
return { windowRows, hasCue, maxOffset, offset: Math.max(0, Math.min(maxOffset, Math.floor(offset))) };
|
|
4806
4297
|
};
|
|
4298
|
+
var HEADER_ROW = "\0main";
|
|
4807
4299
|
var FabricWidget = class {
|
|
4808
4300
|
constructor(theme, snapshot, maxRows, terminalRows, retention = new FabricWidgetRetention(), interaction) {
|
|
4809
4301
|
this.theme = theme;
|
|
@@ -4816,51 +4308,57 @@ var FabricWidget = class {
|
|
|
4816
4308
|
/** Set by the TUI when the widget gains or loses keyboard focus. */
|
|
4817
4309
|
focused = false;
|
|
4818
4310
|
#selectedId;
|
|
4819
|
-
|
|
4820
|
-
#
|
|
4821
|
-
|
|
4822
|
-
#paneRows = WIDGET_ACTIVITY_ROWS;
|
|
4823
|
-
/** Participant rows of the last render, with their line index in the output. */
|
|
4311
|
+
/** Row under the pointer; it draws like the selection, as Claude Code's hover does. */
|
|
4312
|
+
#hoveredId;
|
|
4313
|
+
/** Selectable rows of the last render, with their line index below the spacer. */
|
|
4824
4314
|
#rows = [];
|
|
4825
|
-
|
|
4826
|
-
#
|
|
4827
|
-
#
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
/** Select the first participant row; used when focus arrives from the keyboard. */
|
|
4315
|
+
/** Rows above the header in the last render: the spacer, or none on a one-row budget. */
|
|
4316
|
+
#spacerRows = 1;
|
|
4317
|
+
#renderedInteraction;
|
|
4318
|
+
#scrollOffset = 0;
|
|
4319
|
+
#maxScrollOffset = 0;
|
|
4320
|
+
#followSelection = false;
|
|
4321
|
+
/** Select the row on screen, or the first row; used when focus arrives from the keyboard. */
|
|
4833
4322
|
selectDefault() {
|
|
4834
4323
|
const rows = this.#selectableRows();
|
|
4835
|
-
if (
|
|
4324
|
+
if (rows.some((row) => row.id === this.#selectedId)) return;
|
|
4325
|
+
const viewing = this.interaction?.viewing?.();
|
|
4326
|
+
this.#selectedId = rows.find((row) => row.id === viewing)?.id ?? rows[0]?.id;
|
|
4327
|
+
this.#followSelection = true;
|
|
4328
|
+
}
|
|
4329
|
+
/** Select the top row; ↓ from the editor lands on the row next to it. */
|
|
4330
|
+
selectFirst() {
|
|
4331
|
+
this.#selectedId = this.#selectableRows()[0]?.id;
|
|
4332
|
+
this.#followSelection = true;
|
|
4333
|
+
}
|
|
4334
|
+
/** True while at least one row can take focus. */
|
|
4335
|
+
hasRows() {
|
|
4336
|
+
return this.#selectableRows().length > 0;
|
|
4836
4337
|
}
|
|
4837
4338
|
#interactionKey() {
|
|
4838
|
-
return `${this.focused}|${this.#selectedId ?? ""}|${this.#
|
|
4339
|
+
return `${this.focused}|${this.#selectedId ?? ""}|${this.#hoveredId ?? ""}|${this.#scrollOffset}|${this.#followSelection}|${this.interaction?.viewing?.() ?? ""}|${this.interaction?.collapseIdle?.() ?? ""}`;
|
|
4839
4340
|
}
|
|
4840
4341
|
handleInput(data) {
|
|
4342
|
+
this.#hoveredId = void 0;
|
|
4841
4343
|
const rows = this.#selectableRows();
|
|
4842
4344
|
const index = Math.max(0, rows.findIndex((row) => row.id === this.#selectedId));
|
|
4843
4345
|
const select = (next) => {
|
|
4844
4346
|
const row = rows[Math.max(0, Math.min(rows.length - 1, next))];
|
|
4845
|
-
if (
|
|
4846
|
-
|
|
4847
|
-
|
|
4347
|
+
if (row) {
|
|
4348
|
+
this.#selectedId = row.id;
|
|
4349
|
+
this.#followSelection = true;
|
|
4350
|
+
}
|
|
4848
4351
|
};
|
|
4849
4352
|
if (matchesKey(data, "escape") || matchesKey(data, FABRIC_WIDGET_FOCUS_SHORTCUT)) {
|
|
4850
|
-
|
|
4851
|
-
else this.interaction?.release();
|
|
4353
|
+
this.interaction?.release();
|
|
4852
4354
|
} else if (matchesKey(data, "up") || data === "k") {
|
|
4853
|
-
|
|
4355
|
+
if (index === 0 && matchesKey(data, "up")) this.interaction?.release();
|
|
4356
|
+
else select(index - 1);
|
|
4854
4357
|
} else if (matchesKey(data, "down") || data === "j") {
|
|
4855
4358
|
select(index + 1);
|
|
4856
|
-
} else if (matchesKey(data, "enter")
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
this.#activityScroll = Math.min(this.#activityMaxScroll, this.#activityScroll + Math.max(1, this.#paneRows - 1));
|
|
4860
|
-
} else if (this.#expandedId && (matchesKey(data, "pageDown") || data === "J")) {
|
|
4861
|
-
this.#activityScroll = Math.max(0, this.#activityScroll - Math.max(1, this.#paneRows - 1));
|
|
4862
|
-
} else if (this.#expandedId && (matchesKey(data, "end") || data === "G")) {
|
|
4863
|
-
this.#activityScroll = 0;
|
|
4359
|
+
} else if (matchesKey(data, "enter")) {
|
|
4360
|
+
const row = rows[index];
|
|
4361
|
+
if (row) this.interaction?.open?.(row);
|
|
4864
4362
|
} else {
|
|
4865
4363
|
this.interaction?.release(data);
|
|
4866
4364
|
return;
|
|
@@ -4869,43 +4367,47 @@ var FabricWidget = class {
|
|
|
4869
4367
|
}
|
|
4870
4368
|
handleMouse(event) {
|
|
4871
4369
|
if (!this.interaction) return void 0;
|
|
4872
|
-
if (event.type === "wheel"
|
|
4873
|
-
|
|
4874
|
-
|
|
4370
|
+
if (event.type === "wheel") {
|
|
4371
|
+
if (event.x < 0 || event.x >= (this.#lastWidth ?? 0) || event.y < this.#spacerRows || event.y >= (this.#lastLines?.length ?? 0) || this.#maxScrollOffset === 0 || !Number.isFinite(event.wheelDelta) || !event.wheelDelta) return void 0;
|
|
4372
|
+
const offset = Math.max(0, Math.min(this.#maxScrollOffset, this.#scrollOffset + Math.trunc(event.wheelDelta)));
|
|
4373
|
+
const changed = offset !== this.#scrollOffset;
|
|
4374
|
+
this.#scrollOffset = offset;
|
|
4375
|
+
this.#followSelection = false;
|
|
4376
|
+
this.#hoveredId = void 0;
|
|
4377
|
+
return { handled: true, render: changed };
|
|
4378
|
+
}
|
|
4379
|
+
const row = this.#rows.find((candidate) => candidate.line === event.y - this.#spacerRows);
|
|
4380
|
+
if (event.type === "move") {
|
|
4381
|
+
const header = event.y === this.#spacerRows && (this.#lastLines?.length ?? 0) > this.#spacerRows;
|
|
4382
|
+
const hoveredId = row?.id ?? (header ? HEADER_ROW : void 0);
|
|
4383
|
+
if (hoveredId === this.#hoveredId) return { handled: true };
|
|
4384
|
+
this.#hoveredId = hoveredId;
|
|
4875
4385
|
return { handled: true, render: true };
|
|
4876
4386
|
}
|
|
4877
4387
|
if (event.type === "press") return { handled: true };
|
|
4878
4388
|
if (event.type !== "click" || event.button !== "left") return void 0;
|
|
4879
|
-
|
|
4389
|
+
this.#hoveredId = void 0;
|
|
4880
4390
|
if (!row) return void 0;
|
|
4881
4391
|
this.#selectedId = row.id;
|
|
4882
|
-
this
|
|
4392
|
+
if (this.interaction.open) {
|
|
4393
|
+
this.interaction.open(row);
|
|
4394
|
+
return { handled: true, render: true };
|
|
4395
|
+
}
|
|
4883
4396
|
return { focus: true, render: true };
|
|
4884
4397
|
}
|
|
4885
|
-
|
|
4886
|
-
if (this.#expandedId === id) this.#expandedId = void 0;
|
|
4887
|
-
else this.#expand(id);
|
|
4888
|
-
}
|
|
4889
|
-
#expand(id) {
|
|
4890
|
-
this.#expandedId = id;
|
|
4891
|
-
this.#activityScroll = 0;
|
|
4892
|
-
}
|
|
4893
|
-
/** Rows a user can select: the participant rows the widget shows, in drawing order. */
|
|
4398
|
+
/** Focused keyboard traversal can scroll; pointer targets remain viewport-only. */
|
|
4894
4399
|
#selectableRows() {
|
|
4895
|
-
const
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
const
|
|
4904
|
-
const
|
|
4905
|
-
return
|
|
4906
|
-
}
|
|
4907
|
-
#rowLimit() {
|
|
4908
|
-
return widgetRowLimit(this.maxRows, this.terminalRows?.());
|
|
4400
|
+
const budget = this.#rowLimit();
|
|
4401
|
+
if (budget === 0) return [];
|
|
4402
|
+
const { lines, rows } = this.#content(this.snapshot(), Number.MAX_SAFE_INTEGER);
|
|
4403
|
+
const body = Math.max(1, budget - (budget >= 2 ? 1 : 0));
|
|
4404
|
+
const viewport = widgetViewport(lines.length - 1, body - 1, this.#scrollOffset);
|
|
4405
|
+
return this.focused && body > 1 ? rows : rows.filter((row) => row.line === 0 || row.line > viewport.offset && row.line <= viewport.offset + viewport.windowRows);
|
|
4406
|
+
}
|
|
4407
|
+
#rowLimit(width = this.#lastWidth) {
|
|
4408
|
+
const limit = this.focused ? widgetFocusedRowLimit(this.maxRows, this.terminalRows?.()) : widgetRowLimit(this.maxRows, this.terminalRows?.());
|
|
4409
|
+
const available = width === void 0 ? void 0 : this.interaction?.availableRows?.(width);
|
|
4410
|
+
return available === void 0 || !Number.isFinite(available) ? limit : Math.min(limit, Math.max(0, Math.floor(available)));
|
|
4909
4411
|
}
|
|
4910
4412
|
#lastWidth;
|
|
4911
4413
|
#lastLimit;
|
|
@@ -4915,18 +4417,17 @@ var FabricWidget = class {
|
|
|
4915
4417
|
render(width) {
|
|
4916
4418
|
if (width <= 0) return [];
|
|
4917
4419
|
const snapshot = this.snapshot();
|
|
4918
|
-
const limit = this.#rowLimit();
|
|
4919
|
-
const interactionChanged = this.#
|
|
4420
|
+
const limit = this.#rowLimit(width);
|
|
4421
|
+
const interactionChanged = this.#renderedInteraction !== this.#interactionKey();
|
|
4920
4422
|
if (interactionChanged) this.#pending = void 0;
|
|
4921
|
-
const lines = !interactionChanged && this.#pending?.width === width && this.#pending.limit === limit && this.#pending.snapshot === snapshot ? this.#pending.lines : !interactionChanged &&
|
|
4423
|
+
const lines = !interactionChanged && this.#pending?.width === width && this.#pending.limit === limit && this.#pending.snapshot === snapshot ? this.#pending.lines : !interactionChanged && this.#lastWidth === width && this.#lastLimit === limit && this.#lastSnapshot === snapshot && this.#lastLines ? this.#lastLines : this.#renderLines(snapshot, width, limit);
|
|
4922
4424
|
this.#pending = void 0;
|
|
4923
|
-
this.#
|
|
4924
|
-
this.#renderedSelection = this.#selectedId;
|
|
4925
|
-
this.#renderedExpansion = this.#interactionKey();
|
|
4425
|
+
this.#renderedInteraction = this.#interactionKey();
|
|
4926
4426
|
this.#lastWidth = width;
|
|
4927
4427
|
this.#lastLimit = limit;
|
|
4928
4428
|
this.#lastSnapshot = snapshot;
|
|
4929
4429
|
this.#lastLines = lines;
|
|
4430
|
+
this.interaction?.rendered?.();
|
|
4930
4431
|
return lines;
|
|
4931
4432
|
}
|
|
4932
4433
|
hasChanged() {
|
|
@@ -4944,52 +4445,68 @@ var FabricWidget = class {
|
|
|
4944
4445
|
this.#lastSnapshot = void 0;
|
|
4945
4446
|
this.#lastLines = void 0;
|
|
4946
4447
|
}
|
|
4448
|
+
/**
|
|
4449
|
+
* A blank row separates the list from the footer above it, as in Claude
|
|
4450
|
+
* Code. It counts toward the row budget like any other row, so a one-row
|
|
4451
|
+
* budget drops it and keeps the header.
|
|
4452
|
+
*/
|
|
4947
4453
|
#renderLines(snapshot, width, limit) {
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
this.#
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
]
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
const
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4454
|
+
if (limit === 0) {
|
|
4455
|
+
this.#rows = [];
|
|
4456
|
+
this.#spacerRows = 0;
|
|
4457
|
+
return [];
|
|
4458
|
+
}
|
|
4459
|
+
const spacer = limit >= 2 ? 1 : 0;
|
|
4460
|
+
const body = Math.max(1, limit - spacer);
|
|
4461
|
+
let { lines, rows } = this.#content(snapshot, width);
|
|
4462
|
+
if (this.#selectedId !== void 0 && !rows.some((row) => row.id === this.#selectedId)) {
|
|
4463
|
+
this.#selectedId = rows[0]?.id;
|
|
4464
|
+
if (this.focused) ({ lines, rows } = this.#content(snapshot, width));
|
|
4465
|
+
}
|
|
4466
|
+
if (this.#hoveredId !== void 0 && this.#hoveredId !== HEADER_ROW && !rows.some((row) => row.id === this.#hoveredId)) {
|
|
4467
|
+
this.#hoveredId = void 0;
|
|
4468
|
+
}
|
|
4469
|
+
let viewport = widgetViewport(lines.length - 1, body - 1, this.#scrollOffset);
|
|
4470
|
+
if (this.focused && this.#followSelection && viewport.windowRows > 0) {
|
|
4471
|
+
const selected = (rows.find((row) => row.id === this.#selectedId)?.line ?? 0) - 1;
|
|
4472
|
+
let offset = viewport.offset;
|
|
4473
|
+
if (selected < offset) offset = Math.max(0, selected);
|
|
4474
|
+
else if (selected >= offset + viewport.windowRows) offset = selected - viewport.windowRows + 1;
|
|
4475
|
+
viewport = widgetViewport(lines.length - 1, body - 1, offset);
|
|
4476
|
+
}
|
|
4477
|
+
this.#followSelection = false;
|
|
4478
|
+
this.#scrollOffset = viewport.offset;
|
|
4479
|
+
this.#maxScrollOffset = viewport.maxOffset;
|
|
4480
|
+
const capacity = viewport.windowRows;
|
|
4481
|
+
const start = viewport.offset + 1;
|
|
4482
|
+
const below = Math.max(0, lines.length - start - capacity);
|
|
4483
|
+
const above = viewport.offset;
|
|
4484
|
+
const identityWidth = 2 + visibleWidth2(safeText(snapshot.sessionLabel ?? "Fabric"));
|
|
4485
|
+
const labels = above > 0 ? [`\u2191 ${above} more`, `\u2191 ${above}`] : [];
|
|
4486
|
+
const fits = (label2, identity) => visibleWidth2(label2) + 1 + identity <= width;
|
|
4487
|
+
const label = labels.find((label2) => fits(label2, identityWidth)) ?? labels.find((label2) => fits(label2, Math.min(identityWidth, 8)));
|
|
4488
|
+
const headerWidth = label && width >= visibleWidth2(label) + 2 ? width - visibleWidth2(label) - 1 : width;
|
|
4489
|
+
const header = headerWidth === width ? lines[0] ?? "" : this.#content(snapshot, width, headerWidth).lines[0] ?? "";
|
|
4490
|
+
const boundedHeader = label ? this.#withRightLabel(header, label, width) : truncateToWidth3(header, width);
|
|
4491
|
+
const visibleLines = [boundedHeader, ...lines.slice(start, start + capacity).map((line) => truncateToWidth3(line, width))];
|
|
4492
|
+
if (viewport.hasCue) visibleLines.push(below > 0 ? truncateToWidth3(this.theme.fg("dim", `\u2193 ${below} more`), width) : "");
|
|
4493
|
+
this.#rows = rows.filter((row) => row.line === 0 || row.line >= start && row.line < start + capacity).map((row) => ({ ...row, line: row.line === 0 ? 0 : row.line - start + 1 }));
|
|
4494
|
+
if (rows.length === 0 && this.interaction?.collapseIdle?.()) return [];
|
|
4495
|
+
this.#spacerRows = spacer;
|
|
4496
|
+
return [...spacer ? [""] : [], ...visibleLines];
|
|
4497
|
+
}
|
|
4498
|
+
/** Key hints for the header, most important first; the line fitter drops them from the end. */
|
|
4499
|
+
#hints(hasRows) {
|
|
4500
|
+
if (!this.interaction || this.interaction.hints === false) return [];
|
|
4501
|
+
if (this.focused) return [...this.interaction.open ? ["\u23CE open"] : [], "\u2191\u2193 select", "esc back"];
|
|
4502
|
+
return hasRows ? [FABRIC_WIDGET_FOCUS_HINT] : [];
|
|
4503
|
+
}
|
|
4504
|
+
#content(snapshot, width, headerWidth = width) {
|
|
4988
4505
|
const rows = [];
|
|
4989
|
-
const lines = this.#buildContent(snapshot, rows);
|
|
4506
|
+
const lines = this.#buildContent(snapshot, rows, width, headerWidth);
|
|
4990
4507
|
return { lines, rows };
|
|
4991
4508
|
}
|
|
4992
|
-
#buildContent(snapshot, rows
|
|
4509
|
+
#buildContent(snapshot, rows, width, headerWidth) {
|
|
4993
4510
|
const candidateRun = snapshot.runs[0];
|
|
4994
4511
|
const candidateFinishedAt = candidateRun?.finishedAt ?? candidateRun?.updatedAt ?? 0;
|
|
4995
4512
|
const run = candidateRun && (candidateRun.status === "running" || candidateFinishedAt > (snapshot.widgetDismissedAt ?? 0)) ? candidateRun : void 0;
|
|
@@ -5001,11 +4518,11 @@ var FabricWidget = class {
|
|
|
5001
4518
|
const visibleActors = snapshot.actors.filter((actor) => actor.status !== "stopped");
|
|
5002
4519
|
const activeActorWorkers = visibleActors.filter((actor) => actor.worker && isActiveStatus(actor.worker.status)).map((actor) => ({ ...actor.worker, name: actor.name, actorId: actor.id }));
|
|
5003
4520
|
const terminalActorWorkers = visibleActors.filter((actor) => actor.worker && !isActiveStatus(actor.worker.status)).map((actor) => ({ ...actor.worker, name: actor.name, actorId: actor.id }));
|
|
5004
|
-
const nestedCalls = run?.calls.filter((call) => call.kind !== "agent" && call.kind !== "actor") ?? [];
|
|
5005
|
-
const title = run?.name ?? "Fabric session";
|
|
4521
|
+
const nestedCalls = run?.calls.filter((call) => !isRoutineInternalCall(call) && call.kind !== "agent" && call.kind !== "actor") ?? [];
|
|
5006
4522
|
const shells = snapshot.shells ?? [];
|
|
5007
4523
|
const liveShells = shells.filter((job) => job.finishedAt === void 0);
|
|
5008
4524
|
const recentShells = shells.filter((job) => job.finishedAt !== void 0 && isRecentWidgetCompletion(job.finishedAt, snapshot.now));
|
|
4525
|
+
const listedShells = [...liveShells, ...recentShells];
|
|
5009
4526
|
const headerStatus = run?.status ?? (activeAgents.length > 0 || activeActorWorkers.length > 0 || liveShells.length > 0 ? "running" : "idle");
|
|
5010
4527
|
const parts = [];
|
|
5011
4528
|
const callTotal = nestedCalls.length;
|
|
@@ -5025,59 +4542,228 @@ var FabricWidget = class {
|
|
|
5025
4542
|
);
|
|
5026
4543
|
}
|
|
5027
4544
|
}
|
|
5028
|
-
if (liveShells.length > 0) parts.push(`${liveShells.length} shell${liveShells.length === 1 ? "" : "s"}`);
|
|
5029
4545
|
if (activeAgents.length > 0) parts.push(`${activeAgents.length} running`);
|
|
5030
4546
|
if (visibleActors.length > 0) parts.push(`${visibleActors.length} actor${visibleActors.length === 1 ? "" : "s"}`);
|
|
4547
|
+
if (liveShells.length > 0) parts.push(`${liveShells.length} shell${liveShells.length === 1 ? "" : "s"}`);
|
|
5031
4548
|
const tokens = totalTokens(snapshot, run);
|
|
5032
4549
|
if (tokens > 0) parts.push(`${formatTokens(tokens)} tok`);
|
|
5033
4550
|
const cost = totalCost(snapshot, run);
|
|
5034
4551
|
if (cost > 0) parts.push(formatCost(cost));
|
|
5035
4552
|
const elapsed = run && formatDuration((run.finishedAt ?? snapshot.now) - run.startedAt);
|
|
5036
4553
|
if (elapsed) parts.push(elapsed);
|
|
5037
|
-
const
|
|
5038
|
-
const
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
const
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
);
|
|
5054
|
-
}
|
|
5055
|
-
if (liveShells.length + recentShells.length > 3) lines.push(this.theme.fg("dim", ` +${liveShells.length + recentShells.length - 3} more shell tasks`));
|
|
5056
|
-
const pushParticipant = (agent, kind) => {
|
|
4554
|
+
const headerId = this.interaction?.mainId ?? HEADER_ROW;
|
|
4555
|
+
const marked = this.#hoveredId ?? (this.focused && this.#selectedId !== void 0 ? this.#selectedId : this.interaction?.viewing?.() ?? headerId);
|
|
4556
|
+
const participants = [...activeAgents, ...terminalAgents, ...activeActorWorkers, ...terminalActorWorkers];
|
|
4557
|
+
const lines = [];
|
|
4558
|
+
const label = safeText(snapshot.sessionLabel ?? "Fabric");
|
|
4559
|
+
if (this.interaction?.mainId !== void 0) rows.push({ id: headerId, kind: "main", name: label, line: 0 });
|
|
4560
|
+
const hasRows = participants.length > 0 || listedShells.length > 0 || this.interaction?.mainId !== void 0;
|
|
4561
|
+
lines.push(fitLine(
|
|
4562
|
+
this.theme,
|
|
4563
|
+
headerWidth,
|
|
4564
|
+
`${colorStatus(this.theme, headerStatus, circle(marked === headerId))} ${this.theme.fg("accent", this.theme.bold(label))}`,
|
|
4565
|
+
run?.name ? { text: safeText(run.name), gap: " ", color: "muted" } : void 0,
|
|
4566
|
+
parts,
|
|
4567
|
+
this.#hints(hasRows)
|
|
4568
|
+
));
|
|
4569
|
+
const pushParticipant = (agent, kind, prefix = "") => {
|
|
5057
4570
|
const id = kind === "actor" ? agent.actorId ?? agent.id : agent.id;
|
|
5058
|
-
rows.push({
|
|
5059
|
-
|
|
4571
|
+
rows.push({
|
|
4572
|
+
id,
|
|
4573
|
+
kind,
|
|
4574
|
+
name: agent.name,
|
|
4575
|
+
...agent.model ? { model: agent.model } : {},
|
|
4576
|
+
line: lines.length
|
|
4577
|
+
});
|
|
4578
|
+
lines.push(agentLine(this.theme, agent, snapshot.now, prefix, id === marked, width));
|
|
5060
4579
|
};
|
|
5061
|
-
|
|
4580
|
+
const liveTrees = [];
|
|
4581
|
+
const settledTrees = [];
|
|
4582
|
+
let liveRoot = false;
|
|
4583
|
+
for (const entry of treeOrder([...activeAgents, ...terminalAgents])) {
|
|
4584
|
+
if (entry.depth === 0) liveRoot = isActiveStatus(entry.agent.status);
|
|
4585
|
+
(liveRoot ? liveTrees : settledTrees).push(entry);
|
|
4586
|
+
}
|
|
4587
|
+
for (const { agent, prefix } of liveTrees) pushParticipant(agent, "agent", prefix);
|
|
5062
4588
|
for (const agent of activeActorWorkers) pushParticipant(agent, "actor");
|
|
5063
4589
|
for (const agent of terminalActorWorkers) pushParticipant(agent, "actor");
|
|
5064
|
-
for (const agent of
|
|
4590
|
+
for (const { agent, prefix } of settledTrees) pushParticipant(agent, "agent", prefix);
|
|
4591
|
+
const shellLine = (job, name, detail, id) => {
|
|
4592
|
+
const status = job.stopping ? "stopping" : job.status;
|
|
4593
|
+
const elapsed2 = formatDuration((job.finishedAt ?? snapshot.now) - job.startedAt) || "0s";
|
|
4594
|
+
const selected = id === marked;
|
|
4595
|
+
return fitLine(
|
|
4596
|
+
this.theme,
|
|
4597
|
+
width,
|
|
4598
|
+
`${colorStatus(this.theme, status, circle(selected))} ${selected ? this.theme.bold(name) : this.theme.fg("muted", name)}${detail ? ` ${this.theme.fg("muted", detail)}` : ""}`,
|
|
4599
|
+
{ text: safeText(job.description ?? job.command), gap: this.theme.fg("dim", ` \xB7 ${elapsed2} \xB7 `), color: "muted" },
|
|
4600
|
+
[],
|
|
4601
|
+
[]
|
|
4602
|
+
);
|
|
4603
|
+
};
|
|
4604
|
+
for (const job of listedShells) {
|
|
4605
|
+
const status = job.stopping ? "stopping" : job.status;
|
|
4606
|
+
const label2 = job.monitor && job.finishedAt === void 0 && !job.stopping ? `monitor:${job.monitor.delivery}` : status;
|
|
4607
|
+
rows.push({ id: job.id, kind: "shell", name: safeText(job.description ?? job.command), line: lines.length });
|
|
4608
|
+
lines.push(shellLine(job, job.id.slice(0, 8), label2, job.id));
|
|
4609
|
+
}
|
|
5065
4610
|
return lines;
|
|
5066
4611
|
}
|
|
5067
|
-
#
|
|
5068
|
-
const
|
|
5069
|
-
if (
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
4612
|
+
#withRightLabel(line, label, width) {
|
|
4613
|
+
const labelWidth = visibleWidth2(label);
|
|
4614
|
+
if (width < labelWidth + 2) return truncateToWidth3(line, width);
|
|
4615
|
+
const left = truncateToWidth3(line, width - labelWidth - 1, "");
|
|
4616
|
+
return `${left}${" ".repeat(width - visibleWidth2(left) - labelWidth)}${this.theme.fg("dim", label)}`;
|
|
4617
|
+
}
|
|
4618
|
+
};
|
|
4619
|
+
|
|
4620
|
+
// src/ui/footer-dock.ts
|
|
4621
|
+
import { stripVTControlCharacters } from "node:util";
|
|
4622
|
+
import { sliceByColumn, truncateToWidth as truncateToWidth4, visibleWidth as visibleWidth3 } from "@earendil-works/pi-tui";
|
|
4623
|
+
var childrenOf = (node) => {
|
|
4624
|
+
const children = node?.children;
|
|
4625
|
+
return Array.isArray(children) ? children : [];
|
|
4626
|
+
};
|
|
4627
|
+
var parentOf = (owner, nodes, target, depth) => {
|
|
4628
|
+
if (nodes.includes(target)) return owner;
|
|
4629
|
+
if (depth <= 0) return void 0;
|
|
4630
|
+
for (const node of nodes) {
|
|
4631
|
+
const found = parentOf(node, childrenOf(node), target, depth - 1);
|
|
4632
|
+
if (found) return found;
|
|
4633
|
+
}
|
|
4634
|
+
return void 0;
|
|
4635
|
+
};
|
|
4636
|
+
var withBorderBadge = (lines, label) => {
|
|
4637
|
+
if (!label) return lines;
|
|
4638
|
+
const index = lines.findIndex((line2) => stripVTControlCharacters(line2).startsWith("\u2500"));
|
|
4639
|
+
const line = lines[index];
|
|
4640
|
+
if (line === void 0) return lines;
|
|
4641
|
+
const badge = borderBadge(line, label);
|
|
4642
|
+
const width = visibleWidth3(line);
|
|
4643
|
+
const badgeWidth = visibleWidth3(badge);
|
|
4644
|
+
const plain = stripVTControlCharacters(line);
|
|
4645
|
+
if (badgeWidth + 6 > width || !/^─+$/.test(plain.slice(-(badgeWidth + 4)))) return lines;
|
|
4646
|
+
const next = [...lines];
|
|
4647
|
+
next[index] = truncateToWidth4(line, width - badgeWidth - 2, "") + badge + sliceByColumn(line, width - 2, 2);
|
|
4648
|
+
return next;
|
|
4649
|
+
};
|
|
4650
|
+
var FooterDock = class {
|
|
4651
|
+
constructor(tui, anchor, component, badge) {
|
|
4652
|
+
this.tui = tui;
|
|
4653
|
+
this.anchor = anchor;
|
|
4654
|
+
this.component = component;
|
|
4655
|
+
this.badge = badge;
|
|
4656
|
+
}
|
|
4657
|
+
#parent;
|
|
4658
|
+
#holder;
|
|
4659
|
+
/**
|
|
4660
|
+
* Pi's editor container while its render carries the badge: the render it
|
|
4661
|
+
* had, the wrapper installed over it, and whether that wrapper still badges.
|
|
4662
|
+
*/
|
|
4663
|
+
#editor;
|
|
4664
|
+
/** Pi's editor drew the badge in its last frame; a border too narrow or busy for it did not. */
|
|
4665
|
+
#badgeDrawn = false;
|
|
4666
|
+
/**
|
|
4667
|
+
* True while the editor border shows the badge. Pi renders its editor before
|
|
4668
|
+
* the docked list in every frame, so the list reads this frame's outcome.
|
|
4669
|
+
*/
|
|
4670
|
+
get badgeShown() {
|
|
4671
|
+
return this.#editor !== void 0 && this.#badgeDrawn;
|
|
4672
|
+
}
|
|
4673
|
+
/**
|
|
4674
|
+
* Fullscreen stacks shrink every input-dock child when overfull, including
|
|
4675
|
+
* one-line status widgets. Give our list only the rows left after Pi's own
|
|
4676
|
+
* editor, widgets and footer, reserving the transcript's native minimum row.
|
|
4677
|
+
* Regular mode scrolls the transcript instead and needs no extra cap.
|
|
4678
|
+
*/
|
|
4679
|
+
availableRows(width) {
|
|
4680
|
+
const parent = this.#parent;
|
|
4681
|
+
const rows = this.tui.terminal?.rows;
|
|
4682
|
+
if (!parent || parent === this.tui || !this.#docked(this.#roots()) || rows === void 0 || !Number.isFinite(rows) || rows <= 0) return;
|
|
4683
|
+
const occupied = childrenOf(parent).reduce((total, child) => {
|
|
4684
|
+
if (child === this.component) return total;
|
|
4685
|
+
const sibling = child;
|
|
4686
|
+
return total + (typeof sibling?.render === "function" ? sibling.render(width).length : 0);
|
|
4687
|
+
}, 0);
|
|
4688
|
+
return Math.max(0, Math.floor(rows) - 1 - occupied);
|
|
4689
|
+
}
|
|
4690
|
+
/**
|
|
4691
|
+
* Keep the component after the footer: `docked` when it already is, `moved`
|
|
4692
|
+
* when this call placed it, `unavailable` when the layout is not Pi's.
|
|
4693
|
+
*/
|
|
4694
|
+
sync() {
|
|
4695
|
+
const roots = this.#roots();
|
|
4696
|
+
if (this.#docked(roots)) {
|
|
4697
|
+
this.#decorateEditor();
|
|
4698
|
+
return "docked";
|
|
5074
4699
|
}
|
|
5075
|
-
|
|
4700
|
+
this.detach();
|
|
4701
|
+
const holder = parentOf(this.tui, roots, this.anchor, 3);
|
|
4702
|
+
const parent = holder === void 0 ? void 0 : parentOf(this.tui, roots, holder, 2);
|
|
4703
|
+
if (!parent || typeof parent.addChild !== "function") return "unavailable";
|
|
4704
|
+
const siblings = childrenOf(parent);
|
|
4705
|
+
if (siblings.indexOf(holder) !== siblings.length - 2) return "unavailable";
|
|
4706
|
+
parent.addChild(this.component, { shrink: 1, minSize: 0 });
|
|
4707
|
+
this.#parent = parent;
|
|
4708
|
+
this.#holder = holder;
|
|
4709
|
+
this.#decorateEditor();
|
|
4710
|
+
return "moved";
|
|
4711
|
+
}
|
|
4712
|
+
detach() {
|
|
4713
|
+
this.#restoreEditor();
|
|
4714
|
+
const parent = this.#parent;
|
|
4715
|
+
this.#parent = void 0;
|
|
4716
|
+
this.#holder = void 0;
|
|
4717
|
+
if (parent && childrenOf(parent).includes(this.component)) parent.removeChild?.(this.component);
|
|
4718
|
+
}
|
|
4719
|
+
/** Pi mounts its editor container straight before the below-editor widgets. */
|
|
4720
|
+
#decorateEditor() {
|
|
4721
|
+
if (!this.badge || !this.#parent) return;
|
|
4722
|
+
const siblings = childrenOf(this.#parent);
|
|
4723
|
+
const editor = siblings[siblings.indexOf(this.#holder) - 1];
|
|
4724
|
+
if (!editor || typeof editor.render !== "function") return this.#restoreEditor();
|
|
4725
|
+
if (this.#editor?.node === editor) return;
|
|
4726
|
+
this.#restoreEditor();
|
|
4727
|
+
const render = editor.render;
|
|
4728
|
+
const badge = this.badge;
|
|
4729
|
+
const live = { on: true };
|
|
4730
|
+
const wrapper = (width) => {
|
|
4731
|
+
const lines = render.call(editor, width);
|
|
4732
|
+
if (!live.on) return lines;
|
|
4733
|
+
const badged = withBorderBadge(lines, badge());
|
|
4734
|
+
this.#badgeDrawn = badged !== lines;
|
|
4735
|
+
return badged;
|
|
4736
|
+
};
|
|
4737
|
+
this.#editor = { node: editor, render, wrapper, live };
|
|
4738
|
+
editor.render = wrapper;
|
|
4739
|
+
}
|
|
4740
|
+
#restoreEditor() {
|
|
4741
|
+
const editor = this.#editor;
|
|
4742
|
+
this.#editor = void 0;
|
|
4743
|
+
this.#badgeDrawn = false;
|
|
4744
|
+
if (!editor) return;
|
|
4745
|
+
editor.live.on = false;
|
|
4746
|
+
if (editor.node.render === editor.wrapper) editor.node.render = editor.render;
|
|
4747
|
+
}
|
|
4748
|
+
#roots() {
|
|
4749
|
+
const tui = this.tui;
|
|
4750
|
+
return typeof tui.getMountedRoots === "function" ? tui.getMountedRoots() : childrenOf(this.tui);
|
|
4751
|
+
}
|
|
4752
|
+
/** Still last after the footer, beside the anchor's container, in a mounted tree. */
|
|
4753
|
+
#docked(roots) {
|
|
4754
|
+
const parent = this.#parent;
|
|
4755
|
+
if (!parent) return false;
|
|
4756
|
+
const siblings = childrenOf(parent);
|
|
4757
|
+
if (siblings.at(-1) !== this.component || siblings.at(-3) !== this.#holder) return false;
|
|
4758
|
+
if (!childrenOf(this.#holder).includes(this.anchor)) return false;
|
|
4759
|
+
return parent === this.tui || roots.some((root) => root === parent || childrenOf(root).includes(parent));
|
|
5076
4760
|
}
|
|
5077
4761
|
};
|
|
5078
4762
|
|
|
5079
4763
|
// src/ui/controller.ts
|
|
5080
4764
|
var WIDGET_ID = "pi-fabric";
|
|
4765
|
+
var WIDGET_PLACEMENT = { placement: "belowEditor" };
|
|
4766
|
+
var WIDGET_REORDER_INTERVAL_MS = 1e3;
|
|
5081
4767
|
var ACTIVITY_REFRESH_MS = 100;
|
|
5082
4768
|
var emptySnapshot = () => {
|
|
5083
4769
|
const now = Date.now();
|
|
@@ -5121,6 +4807,7 @@ var FabricUiController = class {
|
|
|
5121
4807
|
#actorUnsubscribe;
|
|
5122
4808
|
#agentUnsubscribe;
|
|
5123
4809
|
#shellUnsubscribe;
|
|
4810
|
+
#arrowEntryUnsubscribe;
|
|
5124
4811
|
#tasksOpen = false;
|
|
5125
4812
|
#tasksView;
|
|
5126
4813
|
#closeTasks;
|
|
@@ -5129,11 +4816,15 @@ var FabricUiController = class {
|
|
|
5129
4816
|
#dashboardTui;
|
|
5130
4817
|
#widgetMounted = false;
|
|
5131
4818
|
#widget;
|
|
4819
|
+
#widgetReorderedAt = 0;
|
|
4820
|
+
/** Row whose view is opening or open from the list; it keeps the filled circle meanwhile. */
|
|
4821
|
+
#widgetOpenRow;
|
|
4822
|
+
#widgetReorderPending = false;
|
|
4823
|
+
/** Places the list after Pi's footer; undefined once this mount fell back to the editor slot. */
|
|
4824
|
+
#footerDock;
|
|
4825
|
+
#footerDockPending = false;
|
|
5132
4826
|
/** Component that had focus before the widget took it (normally the editor). */
|
|
5133
4827
|
#widgetReturnFocus;
|
|
5134
|
-
/** Pi's hideThinkingBlock for the widget pane; read once, at the first expansion. */
|
|
5135
|
-
#widgetHideThinking;
|
|
5136
|
-
#widgetHideThinkingLoad;
|
|
5137
4828
|
#lastRefreshErrorAt = 0;
|
|
5138
4829
|
#lastRefreshAt = 0;
|
|
5139
4830
|
#dashboardOpen = false;
|
|
@@ -5152,8 +4843,6 @@ var FabricUiController = class {
|
|
|
5152
4843
|
#activityRuns = [];
|
|
5153
4844
|
#activityView;
|
|
5154
4845
|
#transcripts = new AgentTranscriptReader();
|
|
5155
|
-
/** Deeper pages for the widget's activity pane, so a turn's early thinking and tool calls stay visible. */
|
|
5156
|
-
#widgetTranscripts = new AgentTranscriptReader(WIDGET_ACTIVITY_LOG_LINES);
|
|
5157
4846
|
#conversationReaders = /* @__PURE__ */ new Map();
|
|
5158
4847
|
#activeConversationReader;
|
|
5159
4848
|
#snapshotCache = new FabricDashboardSnapshotCache();
|
|
@@ -5171,6 +4860,7 @@ var FabricUiController = class {
|
|
|
5171
4860
|
this.#actorUnsubscribe = this.state.actors.subscribe(() => this.#scheduleRefresh());
|
|
5172
4861
|
this.#agentUnsubscribe = this.state.agents.subscribeUi(() => this.#scheduleRefresh());
|
|
5173
4862
|
this.#shellUnsubscribe = this.state.shellJobs?.subscribe(() => this.#scheduleRefresh());
|
|
4863
|
+
this.#arrowEntryUnsubscribe = context.ui.onTerminalInput?.((data) => matchesKey2(data, "down") && this.#enterWidgetFromEditor() ? { consume: true } : void 0);
|
|
5174
4864
|
this.#refresh();
|
|
5175
4865
|
this.#schedulePoll();
|
|
5176
4866
|
}
|
|
@@ -5183,6 +4873,8 @@ var FabricUiController = class {
|
|
|
5183
4873
|
this.#tasksOpen = false;
|
|
5184
4874
|
this.#shellUnsubscribe?.();
|
|
5185
4875
|
this.#shellUnsubscribe = void 0;
|
|
4876
|
+
this.#arrowEntryUnsubscribe?.();
|
|
4877
|
+
this.#arrowEntryUnsubscribe = void 0;
|
|
5186
4878
|
this.#closeConversation?.();
|
|
5187
4879
|
this.#closeConversation = void 0;
|
|
5188
4880
|
this.#conversationView?.dispose();
|
|
@@ -5196,10 +4888,10 @@ var FabricUiController = class {
|
|
|
5196
4888
|
this.#timer = void 0;
|
|
5197
4889
|
this.#scheduledRefresh = void 0;
|
|
5198
4890
|
this.#releaseWidget();
|
|
4891
|
+
this.#undockWidget();
|
|
5199
4892
|
this.#widgetReturnFocus = void 0;
|
|
5200
|
-
this.#widgetHideThinking = void 0;
|
|
5201
|
-
this.#widgetHideThinkingLoad = void 0;
|
|
5202
4893
|
this.#widget = void 0;
|
|
4894
|
+
this.#footerDock = void 0;
|
|
5203
4895
|
this.#activityUnsubscribe?.();
|
|
5204
4896
|
this.#activityUnsubscribe = void 0;
|
|
5205
4897
|
this.#actorUnsubscribe?.();
|
|
@@ -5225,7 +4917,6 @@ var FabricUiController = class {
|
|
|
5225
4917
|
this.#activityRuns = [];
|
|
5226
4918
|
this.#activityView = void 0;
|
|
5227
4919
|
this.#transcripts.clear();
|
|
5228
|
-
this.#widgetTranscripts.clear();
|
|
5229
4920
|
for (const reader of this.#conversationReaders.values()) reader.clear();
|
|
5230
4921
|
this.#conversationReaders.clear();
|
|
5231
4922
|
this.#activeConversationReader = void 0;
|
|
@@ -5251,6 +4942,46 @@ var FabricUiController = class {
|
|
|
5251
4942
|
tui.setFocus(widget);
|
|
5252
4943
|
tui.requestRender();
|
|
5253
4944
|
}
|
|
4945
|
+
/**
|
|
4946
|
+
* ↓ in an empty editor moves into the participant list below it, as in Claude
|
|
4947
|
+
* Code. The editor has no use for ↓ there: history browsing ends at empty text.
|
|
4948
|
+
*/
|
|
4949
|
+
#enterWidgetFromEditor() {
|
|
4950
|
+
if (this.ownsInput) return false;
|
|
4951
|
+
const tui = this.#widgetTui;
|
|
4952
|
+
const widget = this.#widget;
|
|
4953
|
+
if (!tui || !widget || tui.hasOverlay() || !widget.hasRows()) return false;
|
|
4954
|
+
const editor = tui.getFocusedComponent?.();
|
|
4955
|
+
if (!editor || editor === widget || typeof editor.getText !== "function") return false;
|
|
4956
|
+
if (editor.getText() !== "" || editor.isShowingAutocomplete?.()) return false;
|
|
4957
|
+
this.#widgetReturnFocus = editor;
|
|
4958
|
+
widget.selectFirst();
|
|
4959
|
+
tui.setFocus(widget);
|
|
4960
|
+
tui.requestRender();
|
|
4961
|
+
return true;
|
|
4962
|
+
}
|
|
4963
|
+
/**
|
|
4964
|
+
* Enter on a widget row: open the participant's conversation, or the tasks
|
|
4965
|
+
* view for a shell row, then come back to the list.
|
|
4966
|
+
*/
|
|
4967
|
+
async #openFromWidget(context, row) {
|
|
4968
|
+
this.#widgetOpenRow = row.id;
|
|
4969
|
+
this.#releaseWidget();
|
|
4970
|
+
const epoch = this.#epoch;
|
|
4971
|
+
try {
|
|
4972
|
+
if (row.kind === "shell") await this.openTasks(context, row.id);
|
|
4973
|
+
else await this.openConversation(context, row.id);
|
|
4974
|
+
if (epoch !== this.#epoch || this.ownsInput) return;
|
|
4975
|
+
const tui = this.#widgetTui;
|
|
4976
|
+
const widget = this.#widget;
|
|
4977
|
+
if (!tui || !widget?.hasRows() || tui.getFocusedComponent?.() !== this.#widgetReturnFocus) return;
|
|
4978
|
+
widget.selectDefault();
|
|
4979
|
+
tui.setFocus(widget);
|
|
4980
|
+
tui.requestRender();
|
|
4981
|
+
} finally {
|
|
4982
|
+
if (epoch === this.#epoch && this.#widgetOpenRow === row.id) this.#widgetOpenRow = void 0;
|
|
4983
|
+
}
|
|
4984
|
+
}
|
|
5254
4985
|
/** Return focus to the editor; a `forward` key the widget did not use goes to the editor too. */
|
|
5255
4986
|
#releaseWidget(forward) {
|
|
5256
4987
|
const tui = this.#widgetTui;
|
|
@@ -5260,26 +4991,9 @@ var FabricUiController = class {
|
|
|
5260
4991
|
if (forward !== void 0) target?.handleInput?.(forward);
|
|
5261
4992
|
tui.requestRender();
|
|
5262
4993
|
}
|
|
5263
|
-
/**
|
|
5264
|
-
#widgetHidesThinking(context, tui) {
|
|
5265
|
-
if (this.#widgetHideThinking !== void 0) return this.#widgetHideThinking;
|
|
5266
|
-
const epoch = this.#epoch;
|
|
5267
|
-
this.#widgetHideThinkingLoad ??= (async () => {
|
|
5268
|
-
let hidden = false;
|
|
5269
|
-
try {
|
|
5270
|
-
const { loadHostSdk } = await import("../core/host-sdk.js");
|
|
5271
|
-
const { SettingsManager } = await loadHostSdk();
|
|
5272
|
-
hidden = SettingsManager.create(context.cwd, resolveAgentDir(), { projectTrusted: context.isProjectTrusted?.() ?? false }).getHideThinkingBlock();
|
|
5273
|
-
} catch {
|
|
5274
|
-
}
|
|
5275
|
-
if (epoch !== this.#epoch) return;
|
|
5276
|
-
this.#widgetHideThinking = hidden;
|
|
5277
|
-
tui.requestRender();
|
|
5278
|
-
})();
|
|
5279
|
-
return true;
|
|
5280
|
-
}
|
|
4994
|
+
/** Without an ID, focus the footer list; explicit IDs open single-task detail. */
|
|
5281
4995
|
async openTasks(context, query) {
|
|
5282
|
-
if (this
|
|
4996
|
+
if (this.#tasksOpen || this.#dashboardOpen || this.#widget?.focused === true) return;
|
|
5283
4997
|
const jobs = this.state.shellJobs;
|
|
5284
4998
|
if (!jobs) {
|
|
5285
4999
|
context.ui.notify("No shell task store in this session", "info");
|
|
@@ -5300,6 +5014,11 @@ var FabricUiController = class {
|
|
|
5300
5014
|
return;
|
|
5301
5015
|
}
|
|
5302
5016
|
if (!this.#context) this.start(context);
|
|
5017
|
+
if (!query) {
|
|
5018
|
+
this.focusWidget(context);
|
|
5019
|
+
return;
|
|
5020
|
+
}
|
|
5021
|
+
const id = candidates[0].id;
|
|
5303
5022
|
this.#tasksOpen = true;
|
|
5304
5023
|
const epoch = this.#epoch;
|
|
5305
5024
|
try {
|
|
@@ -5307,7 +5026,6 @@ var FabricUiController = class {
|
|
|
5307
5026
|
if (epoch !== this.#epoch) return;
|
|
5308
5027
|
await imageSafeCustom(context.ui, (tui, theme, keys, done) => {
|
|
5309
5028
|
this.#closeTasks = () => done();
|
|
5310
|
-
const id = candidates[0]?.id;
|
|
5311
5029
|
this.#tasksView = new ShellTasksView({
|
|
5312
5030
|
jobs,
|
|
5313
5031
|
theme,
|
|
@@ -5315,7 +5033,7 @@ var FabricUiController = class {
|
|
|
5315
5033
|
done: () => done(),
|
|
5316
5034
|
requestRender: () => tui.requestRender(),
|
|
5317
5035
|
rows: () => tui.terminal?.rows ?? 24,
|
|
5318
|
-
|
|
5036
|
+
id
|
|
5319
5037
|
});
|
|
5320
5038
|
return this.#tasksView;
|
|
5321
5039
|
}, { overlay: true, overlayOptions: { width: "94%", maxHeight: "90%", anchor: "center", margin: 1 } });
|
|
@@ -5451,6 +5169,16 @@ var FabricUiController = class {
|
|
|
5451
5169
|
this.#closeConversation = () => done(void 0);
|
|
5452
5170
|
const view = new FabricConversationView(tui, theme, {
|
|
5453
5171
|
targets,
|
|
5172
|
+
openTasks: (id) => void this.openTasks(context, id),
|
|
5173
|
+
// The same agent list as the main screen, at the bottom of the window.
|
|
5174
|
+
participants: (interaction) => new FabricWidget(
|
|
5175
|
+
theme,
|
|
5176
|
+
() => this.#snapshot,
|
|
5177
|
+
this.state.config.ui.maxRows,
|
|
5178
|
+
() => tui.terminal?.rows ?? process.stdout.rows,
|
|
5179
|
+
this.#widgetRetention,
|
|
5180
|
+
interaction
|
|
5181
|
+
),
|
|
5454
5182
|
onTargetChange: (id) => {
|
|
5455
5183
|
if (this.#activeConversationReader !== id) this.#suspendConversationReader();
|
|
5456
5184
|
},
|
|
@@ -5528,8 +5256,8 @@ var FabricUiController = class {
|
|
|
5528
5256
|
if (!this.#context) this.start(context);
|
|
5529
5257
|
this.#dashboardOpen = true;
|
|
5530
5258
|
this.#refresh();
|
|
5531
|
-
const [{ FabricDashboard }, { buildClaudeModelSource, buildModelSource
|
|
5532
|
-
const modelSource =
|
|
5259
|
+
const [{ FabricDashboard }, { buildClaudeModelSource, buildModelSource }, { imageSafeCustom }] = await Promise.all([import("../ui/dashboard.js"), import("../ui/model-picker.js"), import("../ui/image-overlays.js")]);
|
|
5260
|
+
const modelSource = buildModelSource(context.modelRegistry, resolveAgentDir());
|
|
5533
5261
|
let claudeModelSource;
|
|
5534
5262
|
if (this.#snapshot.actors.some((actor) => actor.runner === "claude")) {
|
|
5535
5263
|
try {
|
|
@@ -5617,14 +5345,18 @@ var FabricUiController = class {
|
|
|
5617
5345
|
}
|
|
5618
5346
|
};
|
|
5619
5347
|
const onImportActor = (globalActorId) => {
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5348
|
+
try {
|
|
5349
|
+
const def = this.state.globalActors.resolve(globalActorId);
|
|
5350
|
+
if (!def) return;
|
|
5351
|
+
this.state.actors.create(this.state.globalActors.toRequest(def)).then((actor) => {
|
|
5352
|
+
context.ui.notify(`Imported global actor "${def.name}" as ${actor.name}`, "info");
|
|
5353
|
+
this.#refresh();
|
|
5354
|
+
}).catch(
|
|
5355
|
+
(error) => context.ui.notify(error instanceof Error ? error.message : String(error), "error")
|
|
5356
|
+
);
|
|
5357
|
+
} catch (error) {
|
|
5358
|
+
context.ui.notify(error instanceof Error ? error.message : String(error), "error");
|
|
5359
|
+
}
|
|
5628
5360
|
};
|
|
5629
5361
|
const onExportActor = (actorId) => {
|
|
5630
5362
|
try {
|
|
@@ -5721,7 +5453,8 @@ var FabricUiController = class {
|
|
|
5721
5453
|
}
|
|
5722
5454
|
if (this.#timer || !this.#context) return;
|
|
5723
5455
|
const expiryDelay = this.#widgetRetention.nextExpiryDelay(this.#snapshot, Date.now());
|
|
5724
|
-
const
|
|
5456
|
+
const labelPending = this.#snapshot.sessionLabel === void 0 && typeof this.state.sessionLabelPending === "function" && this.state.sessionLabelPending();
|
|
5457
|
+
const active = labelPending || expiryDelay !== void 0 || this.#snapshot.shells?.some((job) => job.finishedAt === void 0) || this.#snapshot.runs.some((run) => run.status === "running") || this.#snapshot.peers.length > 0 || this.#snapshot.agents.some((agent) => isActiveStatus(agent.status)) || this.#snapshot.actors.some(
|
|
5725
5458
|
(actor) => isActiveStatus(actor.status) || Boolean(actor.worker && isActiveStatus(actor.worker.status))
|
|
5726
5459
|
);
|
|
5727
5460
|
if (!this.ownsInput && !active) return;
|
|
@@ -5757,7 +5490,7 @@ var FabricUiController = class {
|
|
|
5757
5490
|
logFile: actor.worker.logFile
|
|
5758
5491
|
};
|
|
5759
5492
|
}
|
|
5760
|
-
const retained = actor.lastRunId && actor.logDir ?
|
|
5493
|
+
const retained = actor.lastRunId && actor.logDir ? path7.join(actor.logDir, actor.lastRunId, "events.jsonl") : void 0;
|
|
5761
5494
|
if (retained) return { id: actor.id, status: actor.status, logFile: retained };
|
|
5762
5495
|
if (actor.sessionFile) {
|
|
5763
5496
|
return { id: actor.id, status: actor.status, logFile: actor.sessionFile };
|
|
@@ -5824,6 +5557,59 @@ var FabricUiController = class {
|
|
|
5824
5557
|
const limit = this.state.config.ui.eventHistory;
|
|
5825
5558
|
if (this.#events.length > limit) this.#events.splice(0, this.#events.length - limit);
|
|
5826
5559
|
}
|
|
5560
|
+
/**
|
|
5561
|
+
* Dock the list after the footer outside the render pass that found it
|
|
5562
|
+
* missing. When Pi's layout is not the one the dock knows, the list falls
|
|
5563
|
+
* back to the below-editor slot for the rest of this mount.
|
|
5564
|
+
*/
|
|
5565
|
+
#syncFooterDock(context, widget) {
|
|
5566
|
+
const dock = this.#footerDock;
|
|
5567
|
+
if (!dock || this.#footerDockPending || this.#widget !== widget) return;
|
|
5568
|
+
this.#footerDockPending = true;
|
|
5569
|
+
const epoch = this.#epoch;
|
|
5570
|
+
queueMicrotask(() => {
|
|
5571
|
+
this.#footerDockPending = false;
|
|
5572
|
+
if (epoch !== this.#epoch || this.#widget !== widget || this.#footerDock !== dock) return;
|
|
5573
|
+
const placement = dock.sync();
|
|
5574
|
+
if (placement === "moved") this.#widgetTui?.requestRender();
|
|
5575
|
+
if (placement === "unavailable") this.#fallBackToEditorSlot(context);
|
|
5576
|
+
});
|
|
5577
|
+
}
|
|
5578
|
+
/** Draw the list in the below-editor slot itself for the rest of this mount. */
|
|
5579
|
+
#fallBackToEditorSlot(context) {
|
|
5580
|
+
const widget = this.#widget;
|
|
5581
|
+
this.#footerDock = void 0;
|
|
5582
|
+
if (widget) context.ui.setWidget(WIDGET_ID, () => widget, WIDGET_PLACEMENT);
|
|
5583
|
+
}
|
|
5584
|
+
#undockWidget(widget = this.#widget) {
|
|
5585
|
+
if (widget !== this.#widget) return;
|
|
5586
|
+
this.#footerDock?.detach();
|
|
5587
|
+
}
|
|
5588
|
+
/**
|
|
5589
|
+
* Keep the list last among the widgets below the editor when it falls back
|
|
5590
|
+
* to that slot. Pi draws them in
|
|
5591
|
+
* the order they were last set, so a status line set after the list would
|
|
5592
|
+
* sit under it, and the dock clips from the bottom when it runs short of
|
|
5593
|
+
* rows. Setting the same component again moves it to the end and keeps its
|
|
5594
|
+
* focus and selection.
|
|
5595
|
+
*/
|
|
5596
|
+
#keepWidgetLast(context) {
|
|
5597
|
+
if (this.#widgetReorderPending) return;
|
|
5598
|
+
const tui = this.#widgetTui;
|
|
5599
|
+
const widget = this.#widget;
|
|
5600
|
+
if (!tui || !widget) return;
|
|
5601
|
+
const parent = tui.children?.find((child) => child.children?.includes(widget));
|
|
5602
|
+
if (!parent || parent.children.at(-1) === widget) return;
|
|
5603
|
+
const wait = this.#widgetReorderedAt + WIDGET_REORDER_INTERVAL_MS - Date.now();
|
|
5604
|
+
this.#widgetReorderPending = true;
|
|
5605
|
+
const epoch = this.#epoch;
|
|
5606
|
+
setTimeout(() => {
|
|
5607
|
+
this.#widgetReorderPending = false;
|
|
5608
|
+
if (epoch !== this.#epoch || this.#widget !== widget || !this.#widgetMounted) return;
|
|
5609
|
+
this.#widgetReorderedAt = Date.now();
|
|
5610
|
+
context.ui.setWidget(WIDGET_ID, () => widget, WIDGET_PLACEMENT);
|
|
5611
|
+
}, Math.max(0, wait)).unref?.();
|
|
5612
|
+
}
|
|
5827
5613
|
#renderWidget(context) {
|
|
5828
5614
|
const config = this.state.config.ui;
|
|
5829
5615
|
const shouldShow = context.mode === "tui" && shouldShowFabricWidget(this.#snapshot, config.widget, this.#widgetRetention);
|
|
@@ -5843,27 +5629,45 @@ var FabricUiController = class {
|
|
|
5843
5629
|
() => tui.terminal?.rows ?? process.stdout.rows,
|
|
5844
5630
|
this.#widgetRetention,
|
|
5845
5631
|
{
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5632
|
+
open: (row) => void this.#openFromWidget(context, row),
|
|
5633
|
+
viewing: () => this.#widgetOpenRow,
|
|
5634
|
+
// Nothing to select: collapse, unless a label would then have nowhere to show.
|
|
5635
|
+
collapseIdle: () => this.#snapshot.sessionLabel === void 0 || this.#footerDock?.badgeShown === true,
|
|
5850
5636
|
release: (forward) => this.#releaseWidget(forward),
|
|
5851
5637
|
requestRender: () => tui.requestRender(),
|
|
5852
|
-
|
|
5638
|
+
rendered: () => this.#keepWidgetLast(context),
|
|
5639
|
+
availableRows: (width) => this.#footerDock?.availableRows(width)
|
|
5853
5640
|
}
|
|
5854
5641
|
);
|
|
5855
|
-
|
|
5642
|
+
const widget = this.#widget;
|
|
5643
|
+
const anchor = {
|
|
5644
|
+
render: () => {
|
|
5645
|
+
this.#syncFooterDock(context, widget);
|
|
5646
|
+
return [];
|
|
5647
|
+
},
|
|
5648
|
+
invalidate: () => {
|
|
5649
|
+
},
|
|
5650
|
+
dispose: () => this.#undockWidget(widget)
|
|
5651
|
+
};
|
|
5652
|
+
this.#footerDock = new FooterDock(tui, anchor, widget, () => {
|
|
5653
|
+
const label = this.#snapshot.sessionLabel;
|
|
5654
|
+
return label ? safeText(label) : void 0;
|
|
5655
|
+
});
|
|
5656
|
+
return anchor;
|
|
5856
5657
|
},
|
|
5857
|
-
|
|
5658
|
+
WIDGET_PLACEMENT
|
|
5858
5659
|
);
|
|
5660
|
+
if (this.#footerDock?.sync() === "unavailable") this.#fallBackToEditorSlot(context);
|
|
5859
5661
|
return;
|
|
5860
5662
|
}
|
|
5861
5663
|
if (!this.#widgetMounted) return;
|
|
5862
5664
|
this.#releaseWidget();
|
|
5665
|
+
this.#undockWidget();
|
|
5863
5666
|
context.ui.setWidget(WIDGET_ID, void 0);
|
|
5864
5667
|
this.#widgetMounted = false;
|
|
5865
5668
|
this.#widgetTui = void 0;
|
|
5866
5669
|
this.#widget = void 0;
|
|
5670
|
+
this.#footerDock = void 0;
|
|
5867
5671
|
}
|
|
5868
5672
|
};
|
|
5869
5673
|
|
|
@@ -5929,7 +5733,9 @@ function installFabricShellHangKeys(context, options) {
|
|
|
5929
5733
|
return void 0;
|
|
5930
5734
|
}
|
|
5931
5735
|
const jobs = options.jobs();
|
|
5932
|
-
|
|
5736
|
+
const shells = jobs?.waiting().length ?? 0;
|
|
5737
|
+
const programs = shells === 0 && data === CTRL_B && editorEmpty(context) ? options.programs?.() : void 0;
|
|
5738
|
+
if (!jobs || shells === 0 && !programs?.waiting()) {
|
|
5933
5739
|
chordArmedAt = 0;
|
|
5934
5740
|
return void 0;
|
|
5935
5741
|
}
|
|
@@ -5937,6 +5743,16 @@ function installFabricShellHangKeys(context, options) {
|
|
|
5937
5743
|
const now = Date.now();
|
|
5938
5744
|
if (chordArmedAt > 0 && now - chordArmedAt <= CTRL_B_CHORD_MS) {
|
|
5939
5745
|
chordArmedAt = 0;
|
|
5746
|
+
if (programs) {
|
|
5747
|
+
const count2 = programs.detachWaiting();
|
|
5748
|
+
if (count2 > 0) {
|
|
5749
|
+
context.ui.notify(
|
|
5750
|
+
count2 === 1 ? "Fabric: program moved to the background \xB7 /fabric tasks" : `Fabric: ${count2} programs moved to the background \xB7 /fabric tasks`,
|
|
5751
|
+
"info"
|
|
5752
|
+
);
|
|
5753
|
+
}
|
|
5754
|
+
return { consume: true };
|
|
5755
|
+
}
|
|
5940
5756
|
const count = jobs.spillWaiting();
|
|
5941
5757
|
if (count > 0) {
|
|
5942
5758
|
context.ui.notify(
|
|
@@ -5947,6 +5763,7 @@ function installFabricShellHangKeys(context, options) {
|
|
|
5947
5763
|
return { consume: true };
|
|
5948
5764
|
}
|
|
5949
5765
|
chordArmedAt = now;
|
|
5766
|
+
if (shells > 0) context.ui.notify("Fabric: press Ctrl+B again to background the waiting shell", "info");
|
|
5950
5767
|
return { consume: true };
|
|
5951
5768
|
}
|
|
5952
5769
|
chordArmedAt = 0;
|
|
@@ -5967,6 +5784,13 @@ function installFabricShellHangKeys(context, options) {
|
|
|
5967
5784
|
unsubscribe();
|
|
5968
5785
|
};
|
|
5969
5786
|
}
|
|
5787
|
+
var editorEmpty = (context) => {
|
|
5788
|
+
try {
|
|
5789
|
+
return (context.ui.getEditorText?.() ?? "") === "";
|
|
5790
|
+
} catch {
|
|
5791
|
+
return false;
|
|
5792
|
+
}
|
|
5793
|
+
};
|
|
5970
5794
|
|
|
5971
5795
|
// src/ui/tool-display.ts
|
|
5972
5796
|
var FabricToolDisplayController = class {
|
|
@@ -6020,18 +5844,99 @@ var registerHandoffCompletionRenderer = (extension) => {
|
|
|
6020
5844
|
});
|
|
6021
5845
|
};
|
|
6022
5846
|
|
|
5847
|
+
// src/ui/terminal-title.ts
|
|
5848
|
+
var MAX_TERMINAL_TITLE_CHARS = 120;
|
|
5849
|
+
var terminalTitleText = (value) => {
|
|
5850
|
+
const text = safeText(value);
|
|
5851
|
+
if (text.length <= MAX_TERMINAL_TITLE_CHARS) return text;
|
|
5852
|
+
return `${Array.from(text).slice(0, MAX_TERMINAL_TITLE_CHARS - 1).join("").trimEnd()}\u2026`;
|
|
5853
|
+
};
|
|
5854
|
+
var TERMINAL_TITLE_ENTRY_TYPE = "pi-fabric-terminal-title";
|
|
5855
|
+
var recordedTitle = (context) => {
|
|
5856
|
+
const entries = context.sessionManager?.getEntries?.() ?? [];
|
|
5857
|
+
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
5858
|
+
const entry = entries[index];
|
|
5859
|
+
if (entry?.type !== "custom" || entry.customType !== TERMINAL_TITLE_ENTRY_TYPE) continue;
|
|
5860
|
+
const recorded = entry.data?.title;
|
|
5861
|
+
const text = typeof recorded === "string" ? terminalTitleText(recorded) : "";
|
|
5862
|
+
if (text) return text;
|
|
5863
|
+
}
|
|
5864
|
+
return void 0;
|
|
5865
|
+
};
|
|
5866
|
+
var FabricTerminalTitle = class {
|
|
5867
|
+
#host;
|
|
5868
|
+
#enabled;
|
|
5869
|
+
#title;
|
|
5870
|
+
constructor(host, enabled) {
|
|
5871
|
+
this.#host = host;
|
|
5872
|
+
this.#enabled = enabled;
|
|
5873
|
+
}
|
|
5874
|
+
/** Adopt the title this session recorded, after Pi applies its own. */
|
|
5875
|
+
resume(context) {
|
|
5876
|
+
if (!this.#enabled()) return;
|
|
5877
|
+
const recorded = recordedTitle(context);
|
|
5878
|
+
if (!recorded) return;
|
|
5879
|
+
this.#title = recorded;
|
|
5880
|
+
this.#write(context, recorded);
|
|
5881
|
+
}
|
|
5882
|
+
/** Show the declared display title for a run and record it for resumes. */
|
|
5883
|
+
show(context, title) {
|
|
5884
|
+
if (!this.#enabled()) return;
|
|
5885
|
+
const text = terminalTitleText(title);
|
|
5886
|
+
if (!text || text === this.#title) return;
|
|
5887
|
+
this.#title = text;
|
|
5888
|
+
this.#write(context, text);
|
|
5889
|
+
try {
|
|
5890
|
+
this.#host.appendEntry(TERMINAL_TITLE_ENTRY_TYPE, { version: 1, title: text });
|
|
5891
|
+
} catch {
|
|
5892
|
+
}
|
|
5893
|
+
}
|
|
5894
|
+
/** Put the sticky title back after Pi rewrites its own. */
|
|
5895
|
+
reassert(context) {
|
|
5896
|
+
if (!this.#enabled() || !this.#title) return;
|
|
5897
|
+
this.#write(context, this.#title);
|
|
5898
|
+
}
|
|
5899
|
+
/** The title currently held, for callers that need to compare. */
|
|
5900
|
+
current() {
|
|
5901
|
+
return this.#title;
|
|
5902
|
+
}
|
|
5903
|
+
#write(context, text) {
|
|
5904
|
+
if (context.mode !== "tui" || !context.hasUI) return;
|
|
5905
|
+
try {
|
|
5906
|
+
context.ui.setTitle(text);
|
|
5907
|
+
} catch {
|
|
5908
|
+
}
|
|
5909
|
+
}
|
|
5910
|
+
};
|
|
5911
|
+
var installTerminalTitle = (pi, title) => {
|
|
5912
|
+
const later = (action) => (_event, context) => {
|
|
5913
|
+
if (!context) return;
|
|
5914
|
+
setImmediate(() => {
|
|
5915
|
+
try {
|
|
5916
|
+
action(context);
|
|
5917
|
+
} catch {
|
|
5918
|
+
}
|
|
5919
|
+
});
|
|
5920
|
+
};
|
|
5921
|
+
pi.on("session_start", later((context) => title.resume(context)));
|
|
5922
|
+
pi.on("session_tree", later((context) => title.resume(context)));
|
|
5923
|
+
pi.on("session_info_changed", later((context) => title.reassert(context)));
|
|
5924
|
+
pi.on("agent_settled", later((context) => title.reassert(context)));
|
|
5925
|
+
};
|
|
5926
|
+
|
|
6023
5927
|
// src/extension.ts
|
|
6024
|
-
import
|
|
5928
|
+
import path8 from "node:path";
|
|
6025
5929
|
import { fileURLToPath } from "node:url";
|
|
6026
|
-
var FABRIC_MANAGED_HOST_VERSION =
|
|
5930
|
+
var FABRIC_MANAGED_HOST_VERSION = 2;
|
|
5931
|
+
var userPromptText = (event) => event.messageType === "custom" || typeof event.prompt !== "string" ? void 0 : event.prompt;
|
|
6027
5932
|
function createFabricExtension(entryUrl) {
|
|
6028
|
-
const FABRIC_EXTENSION_ENTRY_PATH =
|
|
6029
|
-
const FABRIC_ENTRY_DIR =
|
|
5933
|
+
const FABRIC_EXTENSION_ENTRY_PATH = path8.resolve(fileURLToPath(entryUrl));
|
|
5934
|
+
const FABRIC_ENTRY_DIR = path8.dirname(FABRIC_EXTENSION_ENTRY_PATH);
|
|
6030
5935
|
const FABRIC_RUNTIME_PATHS = {
|
|
6031
5936
|
extension: FABRIC_EXTENSION_ENTRY_PATH,
|
|
6032
|
-
worker:
|
|
6033
|
-
residentHost:
|
|
6034
|
-
skills:
|
|
5937
|
+
worker: path8.join(FABRIC_ENTRY_DIR, "worker.js"),
|
|
5938
|
+
residentHost: path8.join(FABRIC_ENTRY_DIR, "residency", "launcher.js"),
|
|
5939
|
+
skills: path8.resolve(FABRIC_ENTRY_DIR, "..", "skillsets")
|
|
6035
5940
|
};
|
|
6036
5941
|
const FABRIC_SKILLS_DIR = FABRIC_RUNTIME_PATHS.skills;
|
|
6037
5942
|
const FABRIC_ENTRY_IDENTITY = captureLoadedFileIdentity(entryUrl);
|
|
@@ -6055,6 +5960,14 @@ function createFabricExtension(entryUrl) {
|
|
|
6055
5960
|
};
|
|
6056
5961
|
const SKILL_REFERENCE_CUSTOM_TYPE = "pi-fabric-skill-reference";
|
|
6057
5962
|
return async function piFabric(pi, options = {}) {
|
|
5963
|
+
const namesExtension = process.argv.some((argument) => argument === "-e" || argument === "--extension");
|
|
5964
|
+
const preferredCopy = options.managedHost || !namesExtension ? void 0 : (await import("../extension-copy.js")).commandLineFabricCopy(FABRIC_EXTENSION_ENTRY_PATH);
|
|
5965
|
+
if (preferredCopy) {
|
|
5966
|
+
console.warn(
|
|
5967
|
+
`[pi-fabric] ${FABRIC_EXTENSION_ENTRY_PATH} is inactive: the command line loads Fabric from ${preferredCopy}`
|
|
5968
|
+
);
|
|
5969
|
+
return;
|
|
5970
|
+
}
|
|
6058
5971
|
if (!options.managedHost) registerJevAuth(pi);
|
|
6059
5972
|
const codePreviewSettings = defaultCodePreviewSettings();
|
|
6060
5973
|
const decorateShell = withCodePreviewShell;
|
|
@@ -6080,7 +5993,13 @@ function createFabricExtension(entryUrl) {
|
|
|
6080
5993
|
);
|
|
6081
5994
|
const capturedTools = new CapturedToolCatalog();
|
|
6082
5995
|
const proxyContract = new ProxyContractLedger();
|
|
5996
|
+
const ownerSlot = { closed: false, yielded: false };
|
|
5997
|
+
const compactionOwner = () => ownerSlot.host?.active;
|
|
5998
|
+
let ownerCode;
|
|
5999
|
+
const hostPolicy = new FabricHostPolicy();
|
|
6083
6000
|
const state = new FabricState(pi, capturedTools, {
|
|
6001
|
+
compactionOwner,
|
|
6002
|
+
hostPolicy,
|
|
6084
6003
|
paths: FABRIC_RUNTIME_PATHS,
|
|
6085
6004
|
...FABRIC_ENTRY_IDENTITY ? { entryIdentity: FABRIC_ENTRY_IDENTITY } : {},
|
|
6086
6005
|
...options.managedHost ? { managedHost: options.managedHost } : {}
|
|
@@ -6148,6 +6067,36 @@ function createFabricExtension(entryUrl) {
|
|
|
6148
6067
|
}
|
|
6149
6068
|
}
|
|
6150
6069
|
);
|
|
6070
|
+
const unsubscribeActionPolicyRegistration = pi.events.on(
|
|
6071
|
+
FABRIC_ACTION_POLICY_REGISTER_EVENT,
|
|
6072
|
+
(value) => {
|
|
6073
|
+
const registration = readFabricActionPolicyRegistrationV1(value);
|
|
6074
|
+
if (!registration) throw new Error("Invalid Pi Fabric action policy hook registration");
|
|
6075
|
+
let unregister;
|
|
6076
|
+
try {
|
|
6077
|
+
unregister = state.actionPolicyHooks.register(registration.name, registration.hook);
|
|
6078
|
+
} catch (error) {
|
|
6079
|
+
registration.respond?.({ ok: false, error: error instanceof Error ? error.message : String(error) });
|
|
6080
|
+
return;
|
|
6081
|
+
}
|
|
6082
|
+
registration.respond?.({ ok: true, unregister });
|
|
6083
|
+
}
|
|
6084
|
+
);
|
|
6085
|
+
const unsubscribeQuestionRendererRegistration = pi.events.on(
|
|
6086
|
+
FABRIC_QUESTION_RENDERER_REGISTER_EVENT,
|
|
6087
|
+
(value) => {
|
|
6088
|
+
const registration = readFabricQuestionRendererRegistrationV1(value);
|
|
6089
|
+
if (!registration) throw new Error("Invalid Pi Fabric question renderer registration");
|
|
6090
|
+
let unregister;
|
|
6091
|
+
try {
|
|
6092
|
+
unregister = state.questionRenderers.register(registration.name, registration.render);
|
|
6093
|
+
} catch (error) {
|
|
6094
|
+
registration.respond?.({ ok: false, error: error instanceof Error ? error.message : String(error) });
|
|
6095
|
+
return;
|
|
6096
|
+
}
|
|
6097
|
+
registration.respond?.({ ok: true, unregister });
|
|
6098
|
+
}
|
|
6099
|
+
);
|
|
6151
6100
|
const programReachable = (registered) => {
|
|
6152
6101
|
if (!state.initialized) return () => false;
|
|
6153
6102
|
const allowlist = readChildToolAllowlist();
|
|
@@ -6155,6 +6104,7 @@ function createFabricExtension(entryUrl) {
|
|
|
6155
6104
|
return (name) => {
|
|
6156
6105
|
if (allowlist && !allowlist.has(name)) return false;
|
|
6157
6106
|
const captured = capturedTools.get(name) !== void 0;
|
|
6107
|
+
if (hostPolicy.previewDenial(PI_CORE_TOOL_NAME_SET.has(name) ? "pi" : "extensions", name)) return false;
|
|
6158
6108
|
if (PI_CORE_TOOL_NAME_SET.has(name)) {
|
|
6159
6109
|
if (!registry.has("pi")) return false;
|
|
6160
6110
|
if (options.managedHost) return captured;
|
|
@@ -6181,25 +6131,53 @@ function createFabricExtension(entryUrl) {
|
|
|
6181
6131
|
}));
|
|
6182
6132
|
}
|
|
6183
6133
|
);
|
|
6134
|
+
const unsubscribeHostPolicy = pi.events.on(FABRIC_HOST_POLICY_EVENT, (value) => {
|
|
6135
|
+
const read = readFabricHostPolicyRequestV1(value);
|
|
6136
|
+
if (!read) return;
|
|
6137
|
+
if (!read.ok) {
|
|
6138
|
+
read.reply({ version: 1, accepted: false, reason: `Invalid Pi Fabric host policy: ${read.reason}` });
|
|
6139
|
+
return;
|
|
6140
|
+
}
|
|
6141
|
+
read.request.reply(hostPolicy.apply(read.request.policy));
|
|
6142
|
+
});
|
|
6184
6143
|
let programRunContext;
|
|
6185
6144
|
const unsubscribeProgramRun = pi.events.on(FABRIC_PROGRAM_RUN_EVENT, (value) => {
|
|
6186
|
-
const
|
|
6187
|
-
if (
|
|
6145
|
+
const request = snapshotFabricProgramRunRequestV1(value);
|
|
6146
|
+
if (!request) return;
|
|
6188
6147
|
void import("../programs/host.js").then(
|
|
6189
|
-
({ handleFabricProgramRunEvent }) => handleFabricProgramRunEvent(
|
|
6190
|
-
(error) =>
|
|
6148
|
+
({ handleFabricProgramRunEvent }) => handleFabricProgramRunEvent(request, { state, pi, context: programRunContext }),
|
|
6149
|
+
(error) => request.respond({ ok: false, error: `Fabric program host unavailable: ${String(error)}` })
|
|
6191
6150
|
);
|
|
6192
6151
|
});
|
|
6152
|
+
const unsubscribeOwner = pi.events.on(FABRIC_COMPACTION_OWNER_EVENT, (value) => (ownerCode ??= import("../compaction/claim-events.js")).then(
|
|
6153
|
+
({ handleCompactionOwnerMessage }) => handleCompactionOwnerMessage(ownerSlot, value, state, () => programRunContext),
|
|
6154
|
+
(error) => {
|
|
6155
|
+
ownerCode = void 0;
|
|
6156
|
+
try {
|
|
6157
|
+
value?.reply?.({
|
|
6158
|
+
ok: false,
|
|
6159
|
+
error: `Fabric compaction owner support failed to load: ${String(error)}`
|
|
6160
|
+
});
|
|
6161
|
+
} catch {
|
|
6162
|
+
}
|
|
6163
|
+
}
|
|
6164
|
+
));
|
|
6193
6165
|
pi.on("resources_discover", async (_event, context) => {
|
|
6194
6166
|
if (!state.bootstrapped) await state.bootstrap(context);
|
|
6167
|
+
if (state.managedHostOptions || process.env.PI_FABRIC_CHILD_SKILLS === "selected") return { skillPaths: [] };
|
|
6195
6168
|
return { skillPaths: fabricSkillPaths(FABRIC_SKILLS_DIR, state.config.executor.kernel) };
|
|
6196
6169
|
});
|
|
6170
|
+
const fabricTerminalTitle = new FabricTerminalTitle(pi, () => {
|
|
6171
|
+
const ui = state.bootstrapped ? state.config.ui : DEFAULT_FABRIC_CONFIG.ui;
|
|
6172
|
+
return ui.enabled && ui.terminalTitle;
|
|
6173
|
+
});
|
|
6197
6174
|
const fabricTool = createFabricExecTool(
|
|
6198
6175
|
state,
|
|
6199
6176
|
codePreviewSettings,
|
|
6200
6177
|
pendingHandoffs,
|
|
6201
6178
|
decorateShell,
|
|
6202
|
-
toolDisplay
|
|
6179
|
+
toolDisplay,
|
|
6180
|
+
fabricTerminalTitle
|
|
6203
6181
|
);
|
|
6204
6182
|
const refreshCodePreviewSettings = () => {
|
|
6205
6183
|
Object.assign(codePreviewSettings, state.config.codePreview);
|
|
@@ -6236,7 +6214,14 @@ function createFabricExtension(entryUrl) {
|
|
|
6236
6214
|
toolCapture.setPolicy(capturePolicy());
|
|
6237
6215
|
Object.assign(
|
|
6238
6216
|
fabricTool,
|
|
6239
|
-
createFabricExecTool(
|
|
6217
|
+
createFabricExecTool(
|
|
6218
|
+
state,
|
|
6219
|
+
codePreviewSettings,
|
|
6220
|
+
pendingHandoffs,
|
|
6221
|
+
decorateShell,
|
|
6222
|
+
toolDisplay,
|
|
6223
|
+
fabricTerminalTitle
|
|
6224
|
+
)
|
|
6240
6225
|
);
|
|
6241
6226
|
pi.registerTool(fabricTool);
|
|
6242
6227
|
toolOwnership.apply(
|
|
@@ -6274,7 +6259,8 @@ function createFabricExtension(entryUrl) {
|
|
|
6274
6259
|
shellHangKeysUnsubscribe = installFabricShellHangKeys(context, {
|
|
6275
6260
|
enabled: () => state.initialized,
|
|
6276
6261
|
ownsInput: () => fabricUi.ownsInput,
|
|
6277
|
-
jobs: () => state.shellJobs
|
|
6262
|
+
jobs: () => state.shellJobs,
|
|
6263
|
+
programs: () => state.programTasks
|
|
6278
6264
|
});
|
|
6279
6265
|
};
|
|
6280
6266
|
const refreshProxyLedger = (context) => {
|
|
@@ -6324,9 +6310,7 @@ function createFabricExtension(entryUrl) {
|
|
|
6324
6310
|
const entropy = await import("../entropy/index.js");
|
|
6325
6311
|
if (!current()) return false;
|
|
6326
6312
|
const {
|
|
6327
|
-
comparableCompiledSurfaceScore,
|
|
6328
6313
|
entropyRepairRows,
|
|
6329
|
-
formatEntropyCompileNotice,
|
|
6330
6314
|
liveSurfaceSnapshot,
|
|
6331
6315
|
loadCompiledSurfaceAsync,
|
|
6332
6316
|
saveCompiledSurfaceAsync,
|
|
@@ -6368,14 +6352,6 @@ function createFabricExtension(entryUrl) {
|
|
|
6368
6352
|
const saved = await saveCompiledSurfaceAsync(agentDir, outcome.artifact);
|
|
6369
6353
|
if (current()) {
|
|
6370
6354
|
setActiveCompiledSurface(saved.file);
|
|
6371
|
-
const previousScore = comparableCompiledSurfaceScore(loaded.file, saved.file.metricVersion);
|
|
6372
|
-
if (previousScore !== void 0 && outcome.report.score < previousScore && context.hasUI) {
|
|
6373
|
-
context.ui.notify(formatEntropyCompileNotice({
|
|
6374
|
-
beforeScore: previousScore,
|
|
6375
|
-
afterScore: outcome.report.score,
|
|
6376
|
-
normalizations: saved.file.normalizations?.length ?? 0
|
|
6377
|
-
}), "info");
|
|
6378
|
-
}
|
|
6379
6355
|
}
|
|
6380
6356
|
} catch (error) {
|
|
6381
6357
|
if (!(error instanceof FileLockTimeoutError)) throw error;
|
|
@@ -6390,7 +6366,7 @@ function createFabricExtension(entryUrl) {
|
|
|
6390
6366
|
const task = (async () => {
|
|
6391
6367
|
try {
|
|
6392
6368
|
if (request.delayMs > 0) {
|
|
6393
|
-
await new Promise((
|
|
6369
|
+
await new Promise((resolve) => setTimeout(resolve, request.delayMs));
|
|
6394
6370
|
}
|
|
6395
6371
|
retry = await compileEntropyNow(request.context, request.epoch);
|
|
6396
6372
|
} catch (error) {
|
|
@@ -6506,8 +6482,13 @@ function createFabricExtension(entryUrl) {
|
|
|
6506
6482
|
}
|
|
6507
6483
|
});
|
|
6508
6484
|
pi.on("agent_settled", async (event, context) => {
|
|
6485
|
+
if (state.managedHostOptions) {
|
|
6486
|
+
if (state.config.compaction.engine === "fabric") await compactAtConfiguredThreshold(context, state.config);
|
|
6487
|
+
if (state.initialized) await state.publishHostLifecycle("pi.agent_settled", event);
|
|
6488
|
+
return;
|
|
6489
|
+
}
|
|
6509
6490
|
if (!state.initialized) {
|
|
6510
|
-
await compactAtConfiguredThreshold(context, state.config);
|
|
6491
|
+
if (!compactionOwner()) await compactAtConfiguredThreshold(context, state.config);
|
|
6511
6492
|
return;
|
|
6512
6493
|
}
|
|
6513
6494
|
const sessionId = context.sessionManager.getSessionId();
|
|
@@ -6528,11 +6509,13 @@ function createFabricExtension(entryUrl) {
|
|
|
6528
6509
|
state.prewalkDrift.drop(sessionId);
|
|
6529
6510
|
}
|
|
6530
6511
|
await state.compact.maybeCommit(context);
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6512
|
+
if (!compactionOwner()) {
|
|
6513
|
+
await compactAtConfiguredThreshold(
|
|
6514
|
+
context,
|
|
6515
|
+
state.config,
|
|
6516
|
+
(trigger, committed) => state.compact.noteAutoCompaction(trigger, committed)
|
|
6517
|
+
);
|
|
6518
|
+
}
|
|
6536
6519
|
await state.publishHostLifecycle("pi.agent_settled", event);
|
|
6537
6520
|
});
|
|
6538
6521
|
pi.on("message_start", () => {
|
|
@@ -6629,14 +6612,13 @@ function createFabricExtension(entryUrl) {
|
|
|
6629
6612
|
}
|
|
6630
6613
|
});
|
|
6631
6614
|
let compactionOwners;
|
|
6632
|
-
let compactionYieldPending = false;
|
|
6633
6615
|
pi.on("session_compact", async (event, context) => {
|
|
6634
|
-
const fabricEngine = (state.bootstrapped ? state.config : DEFAULT_FABRIC_CONFIG).compaction.engine === "fabric";
|
|
6616
|
+
const fabricEngine = !compactionOwner() && (state.bootstrapped ? state.config : DEFAULT_FABRIC_CONFIG).compaction.engine === "fabric";
|
|
6635
6617
|
const observer = await (compactionOwners ??= import("../compaction/owner.js").then(
|
|
6636
6618
|
(module) => new module.CompactionOwnerObserver()
|
|
6637
6619
|
));
|
|
6638
|
-
if (
|
|
6639
|
-
|
|
6620
|
+
if (ownerSlot.yielded) {
|
|
6621
|
+
ownerSlot.yielded = false;
|
|
6640
6622
|
observer.noteDeliberateYield();
|
|
6641
6623
|
}
|
|
6642
6624
|
const { warning } = observer.observe(
|
|
@@ -6651,15 +6633,25 @@ function createFabricExtension(entryUrl) {
|
|
|
6651
6633
|
if (!state.initialized) return;
|
|
6652
6634
|
await state.publishHostLifecycle("pi.session_compact", event);
|
|
6653
6635
|
});
|
|
6654
|
-
|
|
6636
|
+
let compaction;
|
|
6637
|
+
const compactionHandlers = () => compaction ??= import("../compaction/hook.js").then((module) => module.compactionHandlers({
|
|
6655
6638
|
getEngine: () => state.cwd ? state.config.compaction.engine : DEFAULT_FABRIC_CONFIG.compaction.engine,
|
|
6656
6639
|
getTargetContextRatio: () => state.cwd ? state.config.compaction.targetContextRatio : DEFAULT_FABRIC_CONFIG.compaction.targetContextRatio,
|
|
6657
6640
|
getThresholdContextRatio: (modelKey) => state.cwd ? state.config.compaction.thresholds[modelKey] : DEFAULT_FABRIC_CONFIG.compaction.thresholds[modelKey],
|
|
6658
6641
|
getThresholdTokens: (modelKey) => state.cwd ? state.config.compaction.tokenThresholds[modelKey] : DEFAULT_FABRIC_CONFIG.compaction.tokenThresholds[modelKey],
|
|
6659
6642
|
getOutputReserveTokens: () => state.bootstrapped ? state.config.compaction.outputReserveTokens : DEFAULT_FABRIC_CONFIG.compaction.outputReserveTokens,
|
|
6660
6643
|
onYield: () => {
|
|
6661
|
-
|
|
6662
|
-
}
|
|
6644
|
+
ownerSlot.yielded = true;
|
|
6645
|
+
},
|
|
6646
|
+
getOwnerClaim: compactionOwner
|
|
6647
|
+
}));
|
|
6648
|
+
pi.on("session_before_compact", async (event, context) => {
|
|
6649
|
+
if (state.managedHostOptions?.compaction === "pi") return;
|
|
6650
|
+
return (await compactionHandlers()).beforeCompact(event, context);
|
|
6651
|
+
});
|
|
6652
|
+
pi.on("session_before_tree", async (event, context) => {
|
|
6653
|
+
if (state.managedHostOptions?.compaction === "pi") return;
|
|
6654
|
+
return (await compactionHandlers()).beforeTree(event, context);
|
|
6663
6655
|
});
|
|
6664
6656
|
let extractiveHistory;
|
|
6665
6657
|
let extractiveEpoch = 0;
|
|
@@ -6681,13 +6673,18 @@ function createFabricExtension(entryUrl) {
|
|
|
6681
6673
|
invalidateExtractive(true);
|
|
6682
6674
|
return;
|
|
6683
6675
|
}
|
|
6676
|
+
const prompt = userPromptText(event);
|
|
6677
|
+
if (prompt === void 0) {
|
|
6678
|
+
invalidateExtractive();
|
|
6679
|
+
return;
|
|
6680
|
+
}
|
|
6684
6681
|
const epoch = ++extractiveEpoch;
|
|
6685
6682
|
const sessionId = context.sessionManager.getSessionId();
|
|
6686
6683
|
const leaf = context.sessionManager.getLeafId();
|
|
6687
6684
|
const { ExtractiveHistory } = await import("../memory/extractive-history.js");
|
|
6688
6685
|
if (epoch !== extractiveEpoch || !extractiveConfig()?.enabled || context.signal?.aborted || context.sessionManager.getSessionId() !== sessionId || context.sessionManager.getLeafId() !== leaf) return;
|
|
6689
6686
|
extractiveHistory ??= new ExtractiveHistory(extractiveConfig);
|
|
6690
|
-
await extractiveHistory.prepare(context,
|
|
6687
|
+
await extractiveHistory.prepare(context, prompt);
|
|
6691
6688
|
});
|
|
6692
6689
|
pi.on("context", async (event, context) => {
|
|
6693
6690
|
const sessionId = context.sessionManager.getSessionId();
|
|
@@ -6736,46 +6733,65 @@ function createFabricExtension(entryUrl) {
|
|
|
6736
6733
|
const projected = extractiveHistory?.inject(context, messages) ?? messages;
|
|
6737
6734
|
return projected !== messages || messages.length !== event.messages.length ? { messages: projected } : void 0;
|
|
6738
6735
|
});
|
|
6736
|
+
let promptGuidance;
|
|
6739
6737
|
pi.on("before_agent_start", async (event, context) => {
|
|
6740
6738
|
const config = state.bootstrapped ? state.config : DEFAULT_FABRIC_CONFIG;
|
|
6741
6739
|
const fullCodeMode = config.fullCodeMode;
|
|
6742
6740
|
const schemaMode = config.schema.mode;
|
|
6743
6741
|
const effectiveFullCodeMode = fullCodeMode || schemaMode === "enforce";
|
|
6744
6742
|
if (!pi.getActiveTools().includes("fabric_exec")) return;
|
|
6743
|
+
const {
|
|
6744
|
+
buildSkillReferenceGuidance,
|
|
6745
|
+
coreOverridePromptGuidance,
|
|
6746
|
+
defaultFabricExecutionGuidance,
|
|
6747
|
+
extensionToolRosterGuidance,
|
|
6748
|
+
fabricExecutionKernelGuidance,
|
|
6749
|
+
managedHostExecutionGuidance,
|
|
6750
|
+
managedHostKernelGuidance,
|
|
6751
|
+
fabricSchemaGuidance
|
|
6752
|
+
} = await (promptGuidance ??= import("../core/prompt-guidance.js"));
|
|
6745
6753
|
const skills = event.systemPromptOptions.skills ?? [];
|
|
6746
6754
|
const captureSnapshot = state.bootstrapped ? capturePolicy() : void 0;
|
|
6747
|
-
const
|
|
6748
|
-
const
|
|
6755
|
+
const managedHost = state.managedHostOptions;
|
|
6756
|
+
const skillReader = managedHost ? managedHost.skillReader ?? null : void 0;
|
|
6757
|
+
const sections = event.systemPromptOptions.forceSystemPrompt === void 0 ? event.systemPromptOptions.sections : void 0;
|
|
6758
|
+
const systemPrompt = sections ? "" : restoreSkillsForFullCodePrompt(event.systemPrompt, skills, effectiveFullCodeMode, skillReader);
|
|
6759
|
+
const prompt = userPromptText(event);
|
|
6760
|
+
const skillReferenceGuidance = effectiveFullCodeMode && prompt !== void 0 ? buildSkillReferenceGuidance(prompt, skills, skillReader) : void 0;
|
|
6749
6761
|
const currentModel = context.model ? `${context.model.provider}/${context.model.id}` : void 0;
|
|
6750
6762
|
const resolvedGuidance = resolveFabricModelGuidance(state.modelGuidance(), {
|
|
6751
6763
|
...currentModel ? { model: currentModel } : {},
|
|
6752
6764
|
target: process.env.PI_FABRIC_PARENT_RUN ? "participant" : "main",
|
|
6753
6765
|
defaults: [{
|
|
6754
6766
|
slot: FABRIC_EXECUTION_GUIDANCE_SLOT,
|
|
6755
|
-
content: defaultFabricExecutionGuidance(effectiveFullCodeMode, config.executor.kernel, config.executor.pythonRuntime, config.executor.codemodeProfile)
|
|
6767
|
+
content: managedHost ? managedHostExecutionGuidance(managedHost) : defaultFabricExecutionGuidance(effectiveFullCodeMode, config.executor.kernel, config.executor.pythonRuntime, config.executor.codemodeProfile)
|
|
6756
6768
|
}]
|
|
6757
6769
|
});
|
|
6758
|
-
const
|
|
6759
|
-
const
|
|
6760
|
-
|
|
6770
|
+
const toolAllowlist = readChildToolAllowlist();
|
|
6771
|
+
const overrideGuidance = effectiveFullCodeMode && !managedHost ? coreOverridePromptGuidance(capturedTools, toolAllowlist).trim() : void 0;
|
|
6772
|
+
const extensionRoster = effectiveFullCodeMode && !managedHost ? extensionToolRosterGuidance(capturedTools.list().filter(
|
|
6773
|
+
(entry) => (toolAllowlist === void 0 || toolAllowlist.has(entry.name)) && (!config.mcp.enabled || !isSelectedNativeMcpTool(entry.definition, config.mcp.nativeServers))
|
|
6761
6774
|
), new Set(PI_CORE_TOOL_NAMES), config.executor.kernel === "typescript" && config.executor.codemodeProfile === "native") : void 0;
|
|
6762
6775
|
const guidance = [
|
|
6763
|
-
fabricExecutionKernelGuidance(effectiveFullCodeMode, config.executor.kernel, config.executor.pythonRuntime, config.executor.codemodeProfile),
|
|
6776
|
+
managedHost ? managedHostKernelGuidance(managedHost) : fabricExecutionKernelGuidance(effectiveFullCodeMode, config.executor.kernel, config.executor.pythonRuntime, config.executor.codemodeProfile),
|
|
6764
6777
|
resolvedGuidance.slotText,
|
|
6765
6778
|
fabricSchemaGuidance(schemaMode),
|
|
6766
6779
|
overrideGuidance,
|
|
6767
6780
|
extensionRoster,
|
|
6768
|
-
resolvedGuidance.appendText
|
|
6781
|
+
resolvedGuidance.appendText,
|
|
6782
|
+
managedHost?.guidance
|
|
6769
6783
|
].filter((section) => Boolean(section)).join("\n\n");
|
|
6770
|
-
if (
|
|
6771
|
-
|
|
6784
|
+
if (sections) {
|
|
6785
|
+
const catalog = restoreSkillsForFullCodePrompt("", skills, effectiveFullCodeMode, skillReader).trim();
|
|
6786
|
+
if (catalog) sections.skills = catalog;
|
|
6787
|
+
sections.fabric = guidance;
|
|
6788
|
+
}
|
|
6789
|
+
const forced = sections ? {} : { systemPrompt: `${systemPrompt}
|
|
6772
6790
|
|
|
6773
|
-
${guidance}`
|
|
6774
|
-
|
|
6791
|
+
${guidance}` };
|
|
6792
|
+
if (!skillReferenceGuidance) return sections ? void 0 : forced;
|
|
6775
6793
|
return {
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
${guidance}`,
|
|
6794
|
+
...forced,
|
|
6779
6795
|
message: {
|
|
6780
6796
|
customType: SKILL_REFERENCE_CUSTOM_TYPE,
|
|
6781
6797
|
content: skillReferenceGuidance,
|
|
@@ -6786,6 +6802,8 @@ ${guidance}`,
|
|
|
6786
6802
|
});
|
|
6787
6803
|
pi.on("before_agent_start", (event) => {
|
|
6788
6804
|
if (!pi.getActiveTools().includes("fabric_exec")) return;
|
|
6805
|
+
const prompt = userPromptText(event);
|
|
6806
|
+
if (prompt === void 0) return;
|
|
6789
6807
|
const captureSnapshot = state.cwd ? capturePolicy() : void 0;
|
|
6790
6808
|
if (!captureSnapshot?.enabled || !captureSnapshot.hideFromModel || !fabricOwnsModelTools()) {
|
|
6791
6809
|
return;
|
|
@@ -6793,7 +6811,7 @@ ${guidance}`,
|
|
|
6793
6811
|
const names = rewritableHiddenCapturedToolNames(hiddenCapturedToolNames());
|
|
6794
6812
|
if (names.length === 0) return;
|
|
6795
6813
|
const mentioned = proxyContractMentionsInSkills(
|
|
6796
|
-
|
|
6814
|
+
prompt,
|
|
6797
6815
|
event.systemPrompt,
|
|
6798
6816
|
names
|
|
6799
6817
|
);
|
|
@@ -6812,7 +6830,11 @@ ${guidance}`,
|
|
|
6812
6830
|
if (!state.initialized) return;
|
|
6813
6831
|
state.dispatchHostEvent(eventName, event, context);
|
|
6814
6832
|
});
|
|
6833
|
+
installTerminalTitle(pi, fabricTerminalTitle);
|
|
6815
6834
|
pi.on("session_shutdown", async (_event, context) => {
|
|
6835
|
+
unsubscribeOwner();
|
|
6836
|
+
ownerSlot.closed = true;
|
|
6837
|
+
ownerSlot.host?.clear();
|
|
6816
6838
|
entropyStopping = true;
|
|
6817
6839
|
clearEntropyRetry();
|
|
6818
6840
|
if (entropyEvidenceThisTurn) {
|
|
@@ -6827,7 +6849,12 @@ ${guidance}`,
|
|
|
6827
6849
|
unsubscribeProviderRegistration();
|
|
6828
6850
|
unsubscribeProviderWithdrawal();
|
|
6829
6851
|
unsubscribeToolPlacement();
|
|
6852
|
+
unsubscribeHostPolicy();
|
|
6830
6853
|
unsubscribeProgramRun();
|
|
6854
|
+
unsubscribeActionPolicyRegistration();
|
|
6855
|
+
state.actionPolicyHooks.clear();
|
|
6856
|
+
unsubscribeQuestionRendererRegistration();
|
|
6857
|
+
state.questionRenderers.clear();
|
|
6831
6858
|
programRunContext = void 0;
|
|
6832
6859
|
pendingHandoffs.clear();
|
|
6833
6860
|
directToolApproval.clear();
|
|
@@ -6856,6 +6883,19 @@ ${guidance}`,
|
|
|
6856
6883
|
if (context.hasUI) context.ui.notify(notice, "warning");
|
|
6857
6884
|
else console.warn(`[pi-fabric] ${notice}`);
|
|
6858
6885
|
});
|
|
6886
|
+
let keepVisibleNoticeKey;
|
|
6887
|
+
pi.on("before_agent_start", (_event, context) => {
|
|
6888
|
+
if (!state.bootstrapped) return;
|
|
6889
|
+
const ignored = ineffectiveKeepVisible(state.config, state.foregroundTools().tools);
|
|
6890
|
+
if (ignored.length === 0) return;
|
|
6891
|
+
const enforce = state.config.schema.mode === "enforce";
|
|
6892
|
+
const key = `${context.sessionManager?.getSessionId?.() ?? ""}\0${ignored.join(",")}`;
|
|
6893
|
+
if (keepVisibleNoticeKey === key) return;
|
|
6894
|
+
keepVisibleNoticeKey = key;
|
|
6895
|
+
const notice = `Fabric capture.keepVisible has no effect in ${enforce ? "Schema enforce" : "full code"} mode; ${ignored.join(", ")} stay hidden from the model${enforce ? "" : ". Use foreground.tools to declare a tool beside fabric_exec"}.`;
|
|
6896
|
+
if (context.hasUI) context.ui.notify(notice, "warning");
|
|
6897
|
+
else console.warn(`[pi-fabric] ${notice}`);
|
|
6898
|
+
});
|
|
6859
6899
|
let runnerNoticeKey;
|
|
6860
6900
|
pi.on("before_agent_start", (_event, context) => {
|
|
6861
6901
|
if (!state.bootstrapped) return;
|
|
@@ -6902,4 +6942,4 @@ export {
|
|
|
6902
6942
|
FABRIC_MANAGED_HOST_VERSION,
|
|
6903
6943
|
createFabricExtension
|
|
6904
6944
|
};
|
|
6905
|
-
//# sourceMappingURL=chunk-
|
|
6945
|
+
//# sourceMappingURL=chunk-G2DZJ5LK.js.map
|