@e4779/pi-fabric 0.92.17-fork.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +181 -0
- package/THIRD_PARTY_NOTICES.md +33 -0
- package/dist/activity/store.d.ts +33 -0
- package/dist/activity/store.d.ts.map +1 -0
- package/dist/activity/types.d.ts +104 -0
- package/dist/activity/types.d.ts.map +1 -0
- package/dist/actors/binding-store.d.ts +17 -0
- package/dist/actors/binding-store.d.ts.map +1 -0
- package/dist/actors/context.d.ts +13 -0
- package/dist/actors/context.d.ts.map +1 -0
- package/dist/actors/delivery-policy.d.ts +8 -0
- package/dist/actors/delivery-policy.d.ts.map +1 -0
- package/dist/actors/directory.d.ts +47 -0
- package/dist/actors/directory.d.ts.map +1 -0
- package/dist/actors/global-registry.d.ts +47 -0
- package/dist/actors/global-registry.d.ts.map +1 -0
- package/dist/actors/host-event-observer.d.ts +5 -0
- package/dist/actors/host-event-observer.d.ts.map +1 -0
- package/dist/actors/host-event-payload.d.ts +14 -0
- package/dist/actors/host-event-payload.d.ts.map +1 -0
- package/dist/actors/log-store.d.ts +22 -0
- package/dist/actors/log-store.d.ts.map +1 -0
- package/dist/actors/manager.d.ts +175 -0
- package/dist/actors/manager.d.ts.map +1 -0
- package/dist/actors/mesh-monitor.d.ts +22 -0
- package/dist/actors/mesh-monitor.d.ts.map +1 -0
- package/dist/actors/predicate.d.ts +7 -0
- package/dist/actors/predicate.d.ts.map +1 -0
- package/dist/actors/registry-store.d.ts +15 -0
- package/dist/actors/registry-store.d.ts.map +1 -0
- package/dist/actors/types.d.ts +218 -0
- package/dist/actors/types.d.ts.map +1 -0
- package/dist/agents/bash-worktree-add.d.ts +24 -0
- package/dist/agents/bash-worktree-add.d.ts.map +1 -0
- package/dist/agents/budget-ledger.d.ts +88 -0
- package/dist/agents/budget-ledger.d.ts.map +1 -0
- package/dist/agents/claude-cli.d.ts +32 -0
- package/dist/agents/claude-cli.d.ts.map +1 -0
- package/dist/agents/claude-cli.js +17 -0
- package/dist/agents/claude-cli.js.map +7 -0
- package/dist/agents/clone-first-worktree.d.ts +17 -0
- package/dist/agents/clone-first-worktree.d.ts.map +1 -0
- package/dist/agents/compact-control.d.ts +32 -0
- package/dist/agents/compact-control.d.ts.map +1 -0
- package/dist/agents/compact-control.js +129 -0
- package/dist/agents/compact-control.js.map +7 -0
- package/dist/agents/constants.d.ts +9 -0
- package/dist/agents/constants.d.ts.map +1 -0
- package/dist/agents/cow-clone.d.ts +8 -0
- package/dist/agents/cow-clone.d.ts.map +1 -0
- package/dist/agents/handoff-completion.d.ts +4 -0
- package/dist/agents/handoff-completion.d.ts.map +1 -0
- package/dist/agents/handoff.d.ts +19 -0
- package/dist/agents/handoff.d.ts.map +1 -0
- package/dist/agents/lifecycle.d.ts +32 -0
- package/dist/agents/lifecycle.d.ts.map +1 -0
- package/dist/agents/manager.d.ts +75 -0
- package/dist/agents/manager.d.ts.map +1 -0
- package/dist/agents/pi-binary.d.ts +7 -0
- package/dist/agents/pi-binary.d.ts.map +1 -0
- package/dist/agents/request.d.ts +13 -0
- package/dist/agents/request.d.ts.map +1 -0
- package/dist/agents/result.d.ts +8 -0
- package/dist/agents/result.d.ts.map +1 -0
- package/dist/agents/result.js +9 -0
- package/dist/agents/result.js.map +7 -0
- package/dist/agents/rm.d.ts +15 -0
- package/dist/agents/rm.d.ts.map +1 -0
- package/dist/agents/semaphore.d.ts +7 -0
- package/dist/agents/semaphore.d.ts.map +1 -0
- package/dist/agents/service-provider.d.ts +9 -0
- package/dist/agents/service-provider.d.ts.map +1 -0
- package/dist/agents/service-schema.d.ts +6 -0
- package/dist/agents/service-schema.d.ts.map +1 -0
- package/dist/agents/service-types.d.ts +192 -0
- package/dist/agents/service-types.d.ts.map +1 -0
- package/dist/agents/service.d.ts +36 -0
- package/dist/agents/service.d.ts.map +1 -0
- package/dist/agents/session-export.d.ts +39 -0
- package/dist/agents/session-export.d.ts.map +1 -0
- package/dist/agents/session-pins.d.ts +24 -0
- package/dist/agents/session-pins.d.ts.map +1 -0
- package/dist/agents/thinking-transfer.d.ts +39 -0
- package/dist/agents/thinking-transfer.d.ts.map +1 -0
- package/dist/agents/transports/herdr-transport.d.ts +10 -0
- package/dist/agents/transports/herdr-transport.d.ts.map +1 -0
- package/dist/agents/transports/localterm-transport.d.ts +7 -0
- package/dist/agents/transports/localterm-transport.d.ts.map +1 -0
- package/dist/agents/transports/process-transport.d.ts +7 -0
- package/dist/agents/transports/process-transport.d.ts.map +1 -0
- package/dist/agents/transports/process-utils.d.ts +33 -0
- package/dist/agents/transports/process-utils.d.ts.map +1 -0
- package/dist/agents/transports/screen-transport.d.ts +7 -0
- package/dist/agents/transports/screen-transport.d.ts.map +1 -0
- package/dist/agents/transports/tmux-transport.d.ts +7 -0
- package/dist/agents/transports/tmux-transport.d.ts.map +1 -0
- package/dist/agents/types.d.ts +280 -0
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/agents/veda-cli.d.ts +22 -0
- package/dist/agents/veda-cli.d.ts.map +1 -0
- package/dist/agents/veda-cli.js +13 -0
- package/dist/agents/veda-cli.js.map +7 -0
- package/dist/agents/worktree-manager.d.ts +14 -0
- package/dist/agents/worktree-manager.d.ts.map +1 -0
- package/dist/agents/worktree-paths.d.ts +5 -0
- package/dist/agents/worktree-paths.d.ts.map +1 -0
- package/dist/agents.d.ts +8 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +761 -0
- package/dist/agents.js.map +7 -0
- package/dist/async-settlement.d.ts +4 -0
- package/dist/async-settlement.d.ts.map +1 -0
- package/dist/audit/details.d.ts +86 -0
- package/dist/audit/details.d.ts.map +1 -0
- package/dist/audit/index.d.ts +4 -0
- package/dist/audit/index.d.ts.map +1 -0
- package/dist/audit/projection.d.ts +20 -0
- package/dist/audit/projection.d.ts.map +1 -0
- package/dist/audit/trace.d.ts +99 -0
- package/dist/audit/trace.d.ts.map +1 -0
- package/dist/capture/catalog.d.ts +30 -0
- package/dist/capture/catalog.d.ts.map +1 -0
- package/dist/capture/interceptor.d.ts +20 -0
- package/dist/capture/interceptor.d.ts.map +1 -0
- package/dist/capture/wrapper.d.ts +15 -0
- package/dist/capture/wrapper.d.ts.map +1 -0
- package/dist/chunks/chunk-2DMJ7MEI.js +1984 -0
- package/dist/chunks/chunk-2DMJ7MEI.js.map +7 -0
- package/dist/chunks/chunk-2PZWDVJB.js +738 -0
- package/dist/chunks/chunk-2PZWDVJB.js.map +7 -0
- package/dist/chunks/chunk-2UQV52II.js +440 -0
- package/dist/chunks/chunk-2UQV52II.js.map +7 -0
- package/dist/chunks/chunk-32BNQ75J.js +1445 -0
- package/dist/chunks/chunk-32BNQ75J.js.map +7 -0
- package/dist/chunks/chunk-3H7SDWZI.js +467 -0
- package/dist/chunks/chunk-3H7SDWZI.js.map +7 -0
- package/dist/chunks/chunk-3MEHEH6B.js +41 -0
- package/dist/chunks/chunk-3MEHEH6B.js.map +7 -0
- package/dist/chunks/chunk-3QECYQGA.js +70 -0
- package/dist/chunks/chunk-3QECYQGA.js.map +7 -0
- package/dist/chunks/chunk-3WIGAX56.js +644 -0
- package/dist/chunks/chunk-3WIGAX56.js.map +7 -0
- package/dist/chunks/chunk-3YZUQESG.js +16 -0
- package/dist/chunks/chunk-3YZUQESG.js.map +7 -0
- package/dist/chunks/chunk-4JETKRFE.js +287 -0
- package/dist/chunks/chunk-4JETKRFE.js.map +7 -0
- package/dist/chunks/chunk-4SSMGBF4.js +93 -0
- package/dist/chunks/chunk-4SSMGBF4.js.map +7 -0
- package/dist/chunks/chunk-5SU3YXBS.js +15 -0
- package/dist/chunks/chunk-5SU3YXBS.js.map +7 -0
- package/dist/chunks/chunk-656HWVFU.js +409 -0
- package/dist/chunks/chunk-656HWVFU.js.map +7 -0
- package/dist/chunks/chunk-7A6NVHB5.js +1242 -0
- package/dist/chunks/chunk-7A6NVHB5.js.map +7 -0
- package/dist/chunks/chunk-7TB7NXSL.js +58 -0
- package/dist/chunks/chunk-7TB7NXSL.js.map +7 -0
- package/dist/chunks/chunk-AAHHYDTO.js +24 -0
- package/dist/chunks/chunk-AAHHYDTO.js.map +7 -0
- package/dist/chunks/chunk-ARLYAW2A.js +95 -0
- package/dist/chunks/chunk-ARLYAW2A.js.map +7 -0
- package/dist/chunks/chunk-AYBIR4YV.js +210 -0
- package/dist/chunks/chunk-AYBIR4YV.js.map +7 -0
- package/dist/chunks/chunk-BOTRGFQQ.js +87 -0
- package/dist/chunks/chunk-BOTRGFQQ.js.map +7 -0
- package/dist/chunks/chunk-CGPK5WHX.js +96 -0
- package/dist/chunks/chunk-CGPK5WHX.js.map +7 -0
- package/dist/chunks/chunk-CI56CW53.js +470 -0
- package/dist/chunks/chunk-CI56CW53.js.map +7 -0
- package/dist/chunks/chunk-CPSW2GW4.js +1466 -0
- package/dist/chunks/chunk-CPSW2GW4.js.map +7 -0
- package/dist/chunks/chunk-CQFP2RCP.js +64 -0
- package/dist/chunks/chunk-CQFP2RCP.js.map +7 -0
- package/dist/chunks/chunk-D5WKZONW.js +797 -0
- package/dist/chunks/chunk-D5WKZONW.js.map +7 -0
- package/dist/chunks/chunk-DLXPTBPL.js +151 -0
- package/dist/chunks/chunk-DLXPTBPL.js.map +7 -0
- package/dist/chunks/chunk-G4LADAYY.js +287 -0
- package/dist/chunks/chunk-G4LADAYY.js.map +7 -0
- package/dist/chunks/chunk-GXNR6NRU.js +447 -0
- package/dist/chunks/chunk-GXNR6NRU.js.map +7 -0
- package/dist/chunks/chunk-IGVDD2HT.js +10 -0
- package/dist/chunks/chunk-IGVDD2HT.js.map +7 -0
- package/dist/chunks/chunk-J2HV2URQ.js +1125 -0
- package/dist/chunks/chunk-J2HV2URQ.js.map +7 -0
- package/dist/chunks/chunk-KAD7UWT2.js +99 -0
- package/dist/chunks/chunk-KAD7UWT2.js.map +7 -0
- package/dist/chunks/chunk-KYXZJNV6.js +227 -0
- package/dist/chunks/chunk-KYXZJNV6.js.map +7 -0
- package/dist/chunks/chunk-LMAVZN7J.js +8 -0
- package/dist/chunks/chunk-LMAVZN7J.js.map +7 -0
- package/dist/chunks/chunk-M3S7XITB.js +110 -0
- package/dist/chunks/chunk-M3S7XITB.js.map +7 -0
- package/dist/chunks/chunk-MGDLRV2R.js +112 -0
- package/dist/chunks/chunk-MGDLRV2R.js.map +7 -0
- package/dist/chunks/chunk-MGWQOKBV.js +30 -0
- package/dist/chunks/chunk-MGWQOKBV.js.map +7 -0
- package/dist/chunks/chunk-N5GUXC6F.js +184 -0
- package/dist/chunks/chunk-N5GUXC6F.js.map +7 -0
- package/dist/chunks/chunk-NQOEHX62.js +215 -0
- package/dist/chunks/chunk-NQOEHX62.js.map +7 -0
- package/dist/chunks/chunk-OKOHRXGF.js +100 -0
- package/dist/chunks/chunk-OKOHRXGF.js.map +7 -0
- package/dist/chunks/chunk-OP2KTYQB.js +286 -0
- package/dist/chunks/chunk-OP2KTYQB.js.map +7 -0
- package/dist/chunks/chunk-OTCASLY2.js +52 -0
- package/dist/chunks/chunk-OTCASLY2.js.map +7 -0
- package/dist/chunks/chunk-PAN6C3JM.js +42 -0
- package/dist/chunks/chunk-PAN6C3JM.js.map +7 -0
- package/dist/chunks/chunk-PH7ZJ27F.js +6873 -0
- package/dist/chunks/chunk-PH7ZJ27F.js.map +7 -0
- package/dist/chunks/chunk-PM5I335G.js +225 -0
- package/dist/chunks/chunk-PM5I335G.js.map +7 -0
- package/dist/chunks/chunk-PSNXUZMY.js +218 -0
- package/dist/chunks/chunk-PSNXUZMY.js.map +7 -0
- package/dist/chunks/chunk-PXAICAUT.js +24 -0
- package/dist/chunks/chunk-PXAICAUT.js.map +7 -0
- package/dist/chunks/chunk-RERA6YWA.js +359 -0
- package/dist/chunks/chunk-RERA6YWA.js.map +7 -0
- package/dist/chunks/chunk-RNOPHITP.js +1720 -0
- package/dist/chunks/chunk-RNOPHITP.js.map +7 -0
- package/dist/chunks/chunk-RRGTKHXZ.js +931 -0
- package/dist/chunks/chunk-RRGTKHXZ.js.map +7 -0
- package/dist/chunks/chunk-SWB2OHYW.js +93 -0
- package/dist/chunks/chunk-SWB2OHYW.js.map +7 -0
- package/dist/chunks/chunk-T3A5GNCW.js +19 -0
- package/dist/chunks/chunk-T3A5GNCW.js.map +7 -0
- package/dist/chunks/chunk-TPLMVELH.js +118 -0
- package/dist/chunks/chunk-TPLMVELH.js.map +7 -0
- package/dist/chunks/chunk-TSRKCXNI.js +17 -0
- package/dist/chunks/chunk-TSRKCXNI.js.map +7 -0
- package/dist/chunks/chunk-U5FYOMG5.js +119 -0
- package/dist/chunks/chunk-U5FYOMG5.js.map +7 -0
- package/dist/chunks/chunk-U6CTHPZC.js +1924 -0
- package/dist/chunks/chunk-U6CTHPZC.js.map +7 -0
- package/dist/chunks/chunk-UDFDF7IY.js +1572 -0
- package/dist/chunks/chunk-UDFDF7IY.js.map +7 -0
- package/dist/chunks/chunk-UKMQK5VP.js +231 -0
- package/dist/chunks/chunk-UKMQK5VP.js.map +7 -0
- package/dist/chunks/chunk-UQ4LTUH4.js +2181 -0
- package/dist/chunks/chunk-UQ4LTUH4.js.map +7 -0
- package/dist/chunks/chunk-UTR3I23Z.js +65 -0
- package/dist/chunks/chunk-UTR3I23Z.js.map +7 -0
- package/dist/chunks/chunk-VPPIJRNZ.js +50 -0
- package/dist/chunks/chunk-VPPIJRNZ.js.map +7 -0
- package/dist/chunks/chunk-VRYEGVHR.js +195 -0
- package/dist/chunks/chunk-VRYEGVHR.js.map +7 -0
- package/dist/chunks/chunk-VRZNFNPB.js +4218 -0
- package/dist/chunks/chunk-VRZNFNPB.js.map +7 -0
- package/dist/chunks/chunk-VXZZJ44D.js +295 -0
- package/dist/chunks/chunk-VXZZJ44D.js.map +7 -0
- package/dist/chunks/chunk-W3FRE4VI.js +297 -0
- package/dist/chunks/chunk-W3FRE4VI.js.map +7 -0
- package/dist/chunks/chunk-WVH324VF.js +60 -0
- package/dist/chunks/chunk-WVH324VF.js.map +7 -0
- package/dist/chunks/chunk-X7G62ZGH.js +151 -0
- package/dist/chunks/chunk-X7G62ZGH.js.map +7 -0
- package/dist/chunks/chunk-XB3RJVT4.js +17 -0
- package/dist/chunks/chunk-XB3RJVT4.js.map +7 -0
- package/dist/chunks/chunk-XT4346N7.js +651 -0
- package/dist/chunks/chunk-XT4346N7.js.map +7 -0
- package/dist/chunks/chunk-Y7KNRAFL.js +1180 -0
- package/dist/chunks/chunk-Y7KNRAFL.js.map +7 -0
- package/dist/chunks/chunk-YK5AZ7CZ.js +692 -0
- package/dist/chunks/chunk-YK5AZ7CZ.js.map +7 -0
- package/dist/chunks/chunk-YU4O6SWQ.js +246 -0
- package/dist/chunks/chunk-YU4O6SWQ.js.map +7 -0
- package/dist/chunks/chunk-YU62DDKK.js +22 -0
- package/dist/chunks/chunk-YU62DDKK.js.map +7 -0
- package/dist/chunks/chunk-Z63R5GVN.js +121 -0
- package/dist/chunks/chunk-Z63R5GVN.js.map +7 -0
- package/dist/chunks/chunk-ZDNGXLEC.js +221 -0
- package/dist/chunks/chunk-ZDNGXLEC.js.map +7 -0
- package/dist/chunks/chunk-ZZ4LHQYJ.js +777 -0
- package/dist/chunks/chunk-ZZ4LHQYJ.js.map +7 -0
- package/dist/commands/fabric.d.ts +17 -0
- package/dist/commands/fabric.d.ts.map +1 -0
- package/dist/compaction/bounds.d.ts +23 -0
- package/dist/compaction/bounds.d.ts.map +1 -0
- package/dist/compaction/branch-details.d.ts +83 -0
- package/dist/compaction/branch-details.d.ts.map +1 -0
- package/dist/compaction/branch-summary.d.ts +9 -0
- package/dist/compaction/branch-summary.d.ts.map +1 -0
- package/dist/compaction/enrichers.d.ts +10 -0
- package/dist/compaction/enrichers.d.ts.map +1 -0
- package/dist/compaction/hook.d.ts +99 -0
- package/dist/compaction/hook.d.ts.map +1 -0
- package/dist/compaction/hook.js +22 -0
- package/dist/compaction/hook.js.map +7 -0
- package/dist/compaction/instructions.d.ts +38 -0
- package/dist/compaction/instructions.d.ts.map +1 -0
- package/dist/compaction/normalize.d.ts +83 -0
- package/dist/compaction/normalize.d.ts.map +1 -0
- package/dist/compaction/projections.d.ts +31 -0
- package/dist/compaction/projections.d.ts.map +1 -0
- package/dist/compaction/qa.d.ts +27 -0
- package/dist/compaction/qa.d.ts.map +1 -0
- package/dist/compaction/render.d.ts +10 -0
- package/dist/compaction/render.d.ts.map +1 -0
- package/dist/compaction/threshold.d.ts +5 -0
- package/dist/compaction/threshold.d.ts.map +1 -0
- package/dist/compaction/trace-events.d.ts +23 -0
- package/dist/compaction/trace-events.d.ts.map +1 -0
- package/dist/components/catalog.d.ts +25 -0
- package/dist/components/catalog.d.ts.map +1 -0
- package/dist/components/effect-policy.d.ts +21 -0
- package/dist/components/effect-policy.d.ts.map +1 -0
- package/dist/components/effect-scope.d.ts +31 -0
- package/dist/components/effect-scope.d.ts.map +1 -0
- package/dist/components/loader.d.ts +27 -0
- package/dist/components/loader.d.ts.map +1 -0
- package/dist/components/model-guidance.d.ts +48 -0
- package/dist/components/model-guidance.d.ts.map +1 -0
- package/dist/components/provider-component.d.ts +31 -0
- package/dist/components/provider-component.d.ts.map +1 -0
- package/dist/components/supervisor.d.ts +29 -0
- package/dist/components/supervisor.d.ts.map +1 -0
- package/dist/components/types.d.ts +140 -0
- package/dist/components/types.d.ts.map +1 -0
- package/dist/config-migrations.d.ts +11 -0
- package/dist/config-migrations.d.ts.map +1 -0
- package/dist/config.d.ts +282 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/core/action-arguments.d.ts +12 -0
- package/dist/core/action-arguments.d.ts.map +1 -0
- package/dist/core/action-registry.d.ts +170 -0
- package/dist/core/action-registry.d.ts.map +1 -0
- package/dist/core/action-registry.js +20 -0
- package/dist/core/action-registry.js.map +7 -0
- package/dist/core/action-repair.d.ts +15 -0
- package/dist/core/action-repair.d.ts.map +1 -0
- package/dist/core/action-result.d.ts +13 -0
- package/dist/core/action-result.d.ts.map +1 -0
- package/dist/core/agent-dir.d.ts +2 -0
- package/dist/core/agent-dir.d.ts.map +1 -0
- package/dist/core/approval-controller.d.ts +31 -0
- package/dist/core/approval-controller.d.ts.map +1 -0
- package/dist/core/atomic-write.d.ts +15 -0
- package/dist/core/atomic-write.d.ts.map +1 -0
- package/dist/core/auto-approval-classifier.d.ts +17 -0
- package/dist/core/auto-approval-classifier.d.ts.map +1 -0
- package/dist/core/call-preview.d.ts +8 -0
- package/dist/core/call-preview.d.ts.map +1 -0
- package/dist/core/child-tool-allowlist.d.ts +3 -0
- package/dist/core/child-tool-allowlist.d.ts.map +1 -0
- package/dist/core/compact-controller.d.ts +42 -0
- package/dist/core/compact-controller.d.ts.map +1 -0
- package/dist/core/core-override-guidance.d.ts +7 -0
- package/dist/core/core-override-guidance.d.ts.map +1 -0
- package/dist/core/damaged-file.d.ts +6 -0
- package/dist/core/damaged-file.d.ts.map +1 -0
- package/dist/core/direct-tool-approval.d.ts +19 -0
- package/dist/core/direct-tool-approval.d.ts.map +1 -0
- package/dist/core/effect-conflict.d.ts +3 -0
- package/dist/core/effect-conflict.d.ts.map +1 -0
- package/dist/core/file-lock.d.ts +12 -0
- package/dist/core/file-lock.d.ts.map +1 -0
- package/dist/core/kernel-skills.d.ts +3 -0
- package/dist/core/kernel-skills.d.ts.map +1 -0
- package/dist/core/model-resolution.d.ts +62 -0
- package/dist/core/model-resolution.d.ts.map +1 -0
- package/dist/core/model-usage.d.ts +8 -0
- package/dist/core/model-usage.d.ts.map +1 -0
- package/dist/core/pi-arguments.d.ts +3 -0
- package/dist/core/pi-arguments.d.ts.map +1 -0
- package/dist/core/pi-bash-error.d.ts +9 -0
- package/dist/core/pi-bash-error.d.ts.map +1 -0
- package/dist/core/pi-tools.d.ts +9 -0
- package/dist/core/pi-tools.d.ts.map +1 -0
- package/dist/core/provider-bindings.d.ts +47 -0
- package/dist/core/provider-bindings.d.ts.map +1 -0
- package/dist/core/proxy-contract.d.ts +18 -0
- package/dist/core/proxy-contract.d.ts.map +1 -0
- package/dist/core/session-context.d.ts +14 -0
- package/dist/core/session-context.d.ts.map +1 -0
- package/dist/core/shell-jobs.d.ts +99 -0
- package/dist/core/shell-jobs.d.ts.map +1 -0
- package/dist/core/skill-block.d.ts +10 -0
- package/dist/core/skill-block.d.ts.map +1 -0
- package/dist/core/skill-dir.d.ts +4 -0
- package/dist/core/skill-dir.d.ts.map +1 -0
- package/dist/core/skill-prompt.d.ts +3 -0
- package/dist/core/skill-prompt.d.ts.map +1 -0
- package/dist/core/skill-references.d.ts +7 -0
- package/dist/core/skill-references.d.ts.map +1 -0
- package/dist/core/stable-hash.d.ts +3 -0
- package/dist/core/stable-hash.d.ts.map +1 -0
- package/dist/core/system-guidance.d.ts +13 -0
- package/dist/core/system-guidance.d.ts.map +1 -0
- package/dist/core/token-math.d.ts +16 -0
- package/dist/core/token-math.d.ts.map +1 -0
- package/dist/core/tool-ownership.d.ts +47 -0
- package/dist/core/tool-ownership.d.ts.map +1 -0
- package/dist/core/tool-result-proxy.d.ts +18 -0
- package/dist/core/tool-result-proxy.d.ts.map +1 -0
- package/dist/entropy/active.d.ts +9 -0
- package/dist/entropy/active.d.ts.map +1 -0
- package/dist/entropy/compiled-store.d.ts +16 -0
- package/dist/entropy/compiled-store.d.ts.map +1 -0
- package/dist/entropy/compiled-surface.d.ts +57 -0
- package/dist/entropy/compiled-surface.d.ts.map +1 -0
- package/dist/entropy/compiler.d.ts +27 -0
- package/dist/entropy/compiler.d.ts.map +1 -0
- package/dist/entropy/corpus.d.ts +22 -0
- package/dist/entropy/corpus.d.ts.map +1 -0
- package/dist/entropy/fingerprint.d.ts +9 -0
- package/dist/entropy/fingerprint.d.ts.map +1 -0
- package/dist/entropy/index.d.ts +16 -0
- package/dist/entropy/index.d.ts.map +1 -0
- package/dist/entropy/index.js +194 -0
- package/dist/entropy/index.js.map +7 -0
- package/dist/entropy/meter.d.ts +10 -0
- package/dist/entropy/meter.d.ts.map +1 -0
- package/dist/entropy/normal-form.d.ts +40 -0
- package/dist/entropy/normal-form.d.ts.map +1 -0
- package/dist/entropy/passes.d.ts +13 -0
- package/dist/entropy/passes.d.ts.map +1 -0
- package/dist/entropy/pool-store.d.ts +15 -0
- package/dist/entropy/pool-store.d.ts.map +1 -0
- package/dist/entropy/pool.d.ts +41 -0
- package/dist/entropy/pool.d.ts.map +1 -0
- package/dist/entropy/presentation.d.ts +12 -0
- package/dist/entropy/presentation.d.ts.map +1 -0
- package/dist/entropy/sessions.d.ts +47 -0
- package/dist/entropy/sessions.d.ts.map +1 -0
- package/dist/entropy/surface.d.ts +30 -0
- package/dist/entropy/surface.d.ts.map +1 -0
- package/dist/entropy/trial.d.ts +38 -0
- package/dist/entropy/trial.d.ts.map +1 -0
- package/dist/entropy/types.d.ts +181 -0
- package/dist/entropy/types.d.ts.map +1 -0
- package/dist/execution-service.d.ts +66 -0
- package/dist/execution-service.d.ts.map +1 -0
- package/dist/fabric-exec-arguments.d.ts +7 -0
- package/dist/fabric-exec-arguments.d.ts.map +1 -0
- package/dist/fabric-exec-tool.d.ts +8 -0
- package/dist/fabric-exec-tool.d.ts.map +1 -0
- package/dist/fabric-runtime-state.d.ts +96 -0
- package/dist/fabric-runtime-state.d.ts.map +1 -0
- package/dist/fabric-runtime-state.js +11928 -0
- package/dist/fabric-runtime-state.js.map +7 -0
- package/dist/fabric-state.d.ts +95 -0
- package/dist/fabric-state.d.ts.map +1 -0
- package/dist/failure-progress.d.ts +3 -0
- package/dist/failure-progress.d.ts.map +1 -0
- package/dist/host-compatibility.d.ts +5 -0
- package/dist/host-compatibility.d.ts.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6094 -0
- package/dist/index.js.map +7 -0
- package/dist/jev/auth.d.ts +5 -0
- package/dist/jev/auth.d.ts.map +1 -0
- package/dist/jev/browser.d.ts +37 -0
- package/dist/jev/browser.d.ts.map +1 -0
- package/dist/jev/browser.js +13 -0
- package/dist/jev/browser.js.map +7 -0
- package/dist/jev/client.d.ts +29 -0
- package/dist/jev/client.d.ts.map +1 -0
- package/dist/jev/client.js +11 -0
- package/dist/jev/client.js.map +7 -0
- package/dist/jev/config.d.ts +17 -0
- package/dist/jev/config.d.ts.map +1 -0
- package/dist/jev/guest-types.d.ts +2 -0
- package/dist/jev/guest-types.d.ts.map +1 -0
- package/dist/jev/manager.d.ts +36 -0
- package/dist/jev/manager.d.ts.map +1 -0
- package/dist/jev/observation.d.ts +59 -0
- package/dist/jev/observation.d.ts.map +1 -0
- package/dist/jev/observation.js +20 -0
- package/dist/jev/observation.js.map +7 -0
- package/dist/jev/types.d.ts +142 -0
- package/dist/jev/types.d.ts.map +1 -0
- package/dist/jev/validation.d.ts +8 -0
- package/dist/jev/validation.d.ts.map +1 -0
- package/dist/jev.d.ts +9 -0
- package/dist/jev.d.ts.map +1 -0
- package/dist/jev.js +49 -0
- package/dist/jev.js.map +7 -0
- package/dist/lifecycle/broker.d.ts +30 -0
- package/dist/lifecycle/broker.d.ts.map +1 -0
- package/dist/lifecycle/delivery-scheduler.d.ts +30 -0
- package/dist/lifecycle/delivery-scheduler.d.ts.map +1 -0
- package/dist/lifecycle/types.d.ts +91 -0
- package/dist/lifecycle/types.d.ts.map +1 -0
- package/dist/log-tail.d.ts +11 -0
- package/dist/log-tail.d.ts.map +1 -0
- package/dist/main-agent.d.ts +70 -0
- package/dist/main-agent.d.ts.map +1 -0
- package/dist/managed-host.d.ts +22 -0
- package/dist/managed-host.d.ts.map +1 -0
- package/dist/mcp.d.ts +9 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +21 -0
- package/dist/mcp.js.map +7 -0
- package/dist/memory/client.d.ts +31 -0
- package/dist/memory/client.d.ts.map +1 -0
- package/dist/memory/context.d.ts +114 -0
- package/dist/memory/context.d.ts.map +1 -0
- package/dist/memory/digest.d.ts +48 -0
- package/dist/memory/digest.d.ts.map +1 -0
- package/dist/memory/digest.js +7 -0
- package/dist/memory/digest.js.map +7 -0
- package/dist/memory/discovery.d.ts +43 -0
- package/dist/memory/discovery.d.ts.map +1 -0
- package/dist/memory/discovery.js +25 -0
- package/dist/memory/discovery.js.map +7 -0
- package/dist/memory/expand-service.d.ts +4 -0
- package/dist/memory/expand-service.d.ts.map +1 -0
- package/dist/memory/host-source.d.ts +60 -0
- package/dist/memory/host-source.d.ts.map +1 -0
- package/dist/memory/index.d.ts +113 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/lineage.d.ts +25 -0
- package/dist/memory/lineage.d.ts.map +1 -0
- package/dist/memory/normalize.d.ts +188 -0
- package/dist/memory/normalize.d.ts.map +1 -0
- package/dist/memory/normalize.js +26 -0
- package/dist/memory/normalize.js.map +7 -0
- package/dist/memory/portable.d.ts +66 -0
- package/dist/memory/portable.d.ts.map +1 -0
- package/dist/memory/provider.d.ts +15 -0
- package/dist/memory/provider.d.ts.map +1 -0
- package/dist/memory/recall-service.d.ts +5 -0
- package/dist/memory/recall-service.d.ts.map +1 -0
- package/dist/memory/regex.d.ts +19 -0
- package/dist/memory/regex.d.ts.map +1 -0
- package/dist/memory/request-cache.d.ts +49 -0
- package/dist/memory/request-cache.d.ts.map +1 -0
- package/dist/memory/request-context.d.ts +57 -0
- package/dist/memory/request-context.d.ts.map +1 -0
- package/dist/memory/request-limits.d.ts +8 -0
- package/dist/memory/request-limits.d.ts.map +1 -0
- package/dist/memory/search.d.ts +98 -0
- package/dist/memory/search.d.ts.map +1 -0
- package/dist/memory/search.js +24 -0
- package/dist/memory/search.js.map +7 -0
- package/dist/memory/sessions-service.d.ts +3 -0
- package/dist/memory/sessions-service.d.ts.map +1 -0
- package/dist/memory/source-observation.d.ts +28 -0
- package/dist/memory/source-observation.d.ts.map +1 -0
- package/dist/memory/tokenize.d.ts +24 -0
- package/dist/memory/tokenize.d.ts.map +1 -0
- package/dist/memory.d.ts +8 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +119 -0
- package/dist/memory.js.map +7 -0
- package/dist/mesh/store.d.ts +78 -0
- package/dist/mesh/store.d.ts.map +1 -0
- package/dist/output-budget.d.ts +12 -0
- package/dist/output-budget.d.ts.map +1 -0
- package/dist/prewalk/arm.d.ts +8 -0
- package/dist/prewalk/arm.d.ts.map +1 -0
- package/dist/prewalk/controller.d.ts +66 -0
- package/dist/prewalk/controller.d.ts.map +1 -0
- package/dist/prewalk/fs-drift.d.ts +19 -0
- package/dist/prewalk/fs-drift.d.ts.map +1 -0
- package/dist/prewalk/handoff.d.ts +46 -0
- package/dist/prewalk/handoff.d.ts.map +1 -0
- package/dist/protocol.d.ts +275 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +46 -0
- package/dist/protocol.js.map +7 -0
- package/dist/providers/agents-actions.d.ts +3 -0
- package/dist/providers/agents-actions.d.ts.map +1 -0
- package/dist/providers/agents-message-router.d.ts +29 -0
- package/dist/providers/agents-message-router.d.ts.map +1 -0
- package/dist/providers/agents-progress.d.ts +18 -0
- package/dist/providers/agents-progress.d.ts.map +1 -0
- package/dist/providers/agents-provider.d.ts +51 -0
- package/dist/providers/agents-provider.d.ts.map +1 -0
- package/dist/providers/arg-normalization.d.ts +15 -0
- package/dist/providers/arg-normalization.d.ts.map +1 -0
- package/dist/providers/captured-tools-provider.d.ts +23 -0
- package/dist/providers/captured-tools-provider.d.ts.map +1 -0
- package/dist/providers/compact-provider.d.ts +14 -0
- package/dist/providers/compact-provider.d.ts.map +1 -0
- package/dist/providers/components-provider.d.ts +12 -0
- package/dist/providers/components-provider.d.ts.map +1 -0
- package/dist/providers/jev-provider.d.ts +70 -0
- package/dist/providers/jev-provider.d.ts.map +1 -0
- package/dist/providers/jev-provider.js +28 -0
- package/dist/providers/jev-provider.js.map +7 -0
- package/dist/providers/mcp-descriptor-cache.d.ts +47 -0
- package/dist/providers/mcp-descriptor-cache.d.ts.map +1 -0
- package/dist/providers/mcp-provider.d.ts +47 -0
- package/dist/providers/mcp-provider.d.ts.map +1 -0
- package/dist/providers/memory-provider.d.ts +32 -0
- package/dist/providers/memory-provider.d.ts.map +1 -0
- package/dist/providers/memory-provider.js +23 -0
- package/dist/providers/memory-provider.js.map +7 -0
- package/dist/providers/mesh-provider.d.ts +17 -0
- package/dist/providers/mesh-provider.d.ts.map +1 -0
- package/dist/providers/pi-bash-cwd.d.ts +49 -0
- package/dist/providers/pi-bash-cwd.d.ts.map +1 -0
- package/dist/providers/pi-tools-provider.d.ts +25 -0
- package/dist/providers/pi-tools-provider.d.ts.map +1 -0
- package/dist/providers/schema-provider.d.ts +15 -0
- package/dist/providers/schema-provider.d.ts.map +1 -0
- package/dist/providers/state-provider.d.ts +16 -0
- package/dist/providers/state-provider.d.ts.map +1 -0
- package/dist/providers/write-diff-limits.d.ts +5 -0
- package/dist/providers/write-diff-limits.d.ts.map +1 -0
- package/dist/providers/write-preview.d.ts +3 -0
- package/dist/providers/write-preview.d.ts.map +1 -0
- package/dist/ref-names.d.ts +2 -0
- package/dist/ref-names.d.ts.map +1 -0
- package/dist/repairs/active.d.ts +7 -0
- package/dist/repairs/active.d.ts.map +1 -0
- package/dist/repairs/apply.d.ts +7 -0
- package/dist/repairs/apply.d.ts.map +1 -0
- package/dist/repairs/catalog-digest.d.ts +5 -0
- package/dist/repairs/catalog-digest.d.ts.map +1 -0
- package/dist/repairs/classify.d.ts +10 -0
- package/dist/repairs/classify.d.ts.map +1 -0
- package/dist/repairs/compiler.d.ts +33 -0
- package/dist/repairs/compiler.d.ts.map +1 -0
- package/dist/repairs/promote.d.ts +4 -0
- package/dist/repairs/promote.d.ts.map +1 -0
- package/dist/repairs/store.d.ts +10 -0
- package/dist/repairs/store.d.ts.map +1 -0
- package/dist/repairs/types.d.ts +49 -0
- package/dist/repairs/types.d.ts.map +1 -0
- package/dist/repeat-guard.d.ts +25 -0
- package/dist/repeat-guard.d.ts.map +1 -0
- package/dist/residency/actor-client.d.ts +16 -0
- package/dist/residency/actor-client.d.ts.map +1 -0
- package/dist/residency/actor-client.js +9 -0
- package/dist/residency/actor-client.js.map +7 -0
- package/dist/residency/client.d.ts +44 -0
- package/dist/residency/client.d.ts.map +1 -0
- package/dist/residency/host.d.ts +3 -0
- package/dist/residency/host.d.ts.map +1 -0
- package/dist/residency/host.js +32 -0
- package/dist/residency/host.js.map +7 -0
- package/dist/residency/launcher-owner.d.ts +7 -0
- package/dist/residency/launcher-owner.d.ts.map +1 -0
- package/dist/residency/launcher.d.ts +3 -0
- package/dist/residency/launcher.d.ts.map +1 -0
- package/dist/residency/launcher.js +154 -0
- package/dist/residency/launcher.js.map +7 -0
- package/dist/residency/pi-entry.d.ts +3 -0
- package/dist/residency/pi-entry.d.ts.map +1 -0
- package/dist/residency/pi-entry.js +48 -0
- package/dist/residency/pi-entry.js.map +7 -0
- package/dist/residency/protocol.d.ts +122 -0
- package/dist/residency/protocol.d.ts.map +1 -0
- package/dist/run-display.d.ts +3 -0
- package/dist/run-display.d.ts.map +1 -0
- package/dist/runtime/core-override-guest-types.d.ts +15 -0
- package/dist/runtime/core-override-guest-types.d.ts.map +1 -0
- package/dist/runtime/core-override-guest-types.js +9 -0
- package/dist/runtime/core-override-guest-types.js.map +7 -0
- package/dist/runtime/core-tool-properties.d.ts +6 -0
- package/dist/runtime/core-tool-properties.d.ts.map +1 -0
- package/dist/runtime/cpython-child-source.d.ts +2 -0
- package/dist/runtime/cpython-child-source.d.ts.map +1 -0
- package/dist/runtime/cpython-linux-sandbox.d.ts +2 -0
- package/dist/runtime/cpython-linux-sandbox.d.ts.map +1 -0
- package/dist/runtime/cpython-runtime.d.ts +9 -0
- package/dist/runtime/cpython-runtime.d.ts.map +1 -0
- package/dist/runtime/cpython-runtime.js +677 -0
- package/dist/runtime/cpython-runtime.js.map +7 -0
- package/dist/runtime/dynamic-guest-types.d.ts +3 -0
- package/dist/runtime/dynamic-guest-types.d.ts.map +1 -0
- package/dist/runtime/dynamic-guest-types.js +8 -0
- package/dist/runtime/dynamic-guest-types.js.map +7 -0
- package/dist/runtime/guest-code-repair.d.ts +2 -0
- package/dist/runtime/guest-code-repair.d.ts.map +1 -0
- package/dist/runtime/guest-stack-map.d.ts +11 -0
- package/dist/runtime/guest-stack-map.d.ts.map +1 -0
- package/dist/runtime/guest-types.d.ts +40 -0
- package/dist/runtime/guest-types.d.ts.map +1 -0
- package/dist/runtime/guest-types.js +13 -0
- package/dist/runtime/guest-types.js.map +7 -0
- package/dist/runtime/kernel.d.ts +30 -0
- package/dist/runtime/kernel.d.ts.map +1 -0
- package/dist/runtime/monty-bridge.d.ts +4 -0
- package/dist/runtime/monty-bridge.d.ts.map +1 -0
- package/dist/runtime/monty-runtime.d.ts +6 -0
- package/dist/runtime/monty-runtime.d.ts.map +1 -0
- package/dist/runtime/monty-runtime.js +485 -0
- package/dist/runtime/monty-runtime.js.map +7 -0
- package/dist/runtime/monty-source.d.ts +10 -0
- package/dist/runtime/monty-source.d.ts.map +1 -0
- package/dist/runtime/monty-values.d.ts +7 -0
- package/dist/runtime/monty-values.d.ts.map +1 -0
- package/dist/runtime/node-process-child-source.d.ts +2 -0
- package/dist/runtime/node-process-child-source.d.ts.map +1 -0
- package/dist/runtime/node-process-runtime.d.ts +10 -0
- package/dist/runtime/node-process-runtime.d.ts.map +1 -0
- package/dist/runtime/node-process-runtime.js +16 -0
- package/dist/runtime/node-process-runtime.js.map +7 -0
- package/dist/runtime/orchestration.d.ts +3 -0
- package/dist/runtime/orchestration.d.ts.map +1 -0
- package/dist/runtime/python-arguments.d.ts +2 -0
- package/dist/runtime/python-arguments.d.ts.map +1 -0
- package/dist/runtime/python-error-guidance.d.ts +6 -0
- package/dist/runtime/python-error-guidance.d.ts.map +1 -0
- package/dist/runtime/quickjs-runtime.d.ts +8 -0
- package/dist/runtime/quickjs-runtime.d.ts.map +1 -0
- package/dist/runtime/quickjs-runtime.js +15 -0
- package/dist/runtime/quickjs-runtime.js.map +7 -0
- package/dist/runtime/type-checker.d.ts +18 -0
- package/dist/runtime/type-checker.d.ts.map +1 -0
- package/dist/runtime/type-checker.js +11 -0
- package/dist/runtime/type-checker.js.map +7 -0
- package/dist/runtime/typescript-kernel.d.ts +14 -0
- package/dist/runtime/typescript-kernel.d.ts.map +1 -0
- package/dist/runtime/typescript-kernel.js +53 -0
- package/dist/runtime/typescript-kernel.js.map +7 -0
- package/dist/runtime-paths.d.ts +7 -0
- package/dist/runtime-paths.d.ts.map +1 -0
- package/dist/runtime-state-builtins.d.ts +26 -0
- package/dist/runtime-state-builtins.d.ts.map +1 -0
- package/dist/runtime-state-speculation.d.ts +16 -0
- package/dist/runtime-state-speculation.d.ts.map +1 -0
- package/dist/schema/controller.d.ts +35 -0
- package/dist/schema/controller.d.ts.map +1 -0
- package/dist/schema/policy.d.ts +2 -0
- package/dist/schema/policy.d.ts.map +1 -0
- package/dist/schema/types.d.ts +86 -0
- package/dist/schema/types.d.ts.map +1 -0
- package/dist/schema/workspace.d.ts +19 -0
- package/dist/schema/workspace.d.ts.map +1 -0
- package/dist/speculation/eligibility.d.ts +22 -0
- package/dist/speculation/eligibility.d.ts.map +1 -0
- package/dist/speculation/freshness.d.ts +10 -0
- package/dist/speculation/freshness.d.ts.map +1 -0
- package/dist/speculation/partial-json.d.ts +9 -0
- package/dist/speculation/partial-json.d.ts.map +1 -0
- package/dist/speculation/python-scanner.d.ts +7 -0
- package/dist/speculation/python-scanner.d.ts.map +1 -0
- package/dist/speculation/python-scanner.js +166 -0
- package/dist/speculation/python-scanner.js.map +7 -0
- package/dist/speculation/scanner.d.ts +13 -0
- package/dist/speculation/scanner.d.ts.map +1 -0
- package/dist/speculation/scanner.js +182 -0
- package/dist/speculation/scanner.js.map +7 -0
- package/dist/speculation/store.d.ts +41 -0
- package/dist/speculation/store.d.ts.map +1 -0
- package/dist/speculation/stream-tap.d.ts +30 -0
- package/dist/speculation/stream-tap.d.ts.map +1 -0
- package/dist/speculation/types.d.ts +44 -0
- package/dist/speculation/types.d.ts.map +1 -0
- package/dist/state/complexity.d.ts +13 -0
- package/dist/state/complexity.d.ts.map +1 -0
- package/dist/state/evidence-runner.d.ts +17 -0
- package/dist/state/evidence-runner.d.ts.map +1 -0
- package/dist/state/store.d.ts +76 -0
- package/dist/state/store.d.ts.map +1 -0
- package/dist/state/types.d.ts +165 -0
- package/dist/state/types.d.ts.map +1 -0
- package/dist/storage/retention.d.ts +22 -0
- package/dist/storage/retention.d.ts.map +1 -0
- package/dist/thinking.d.ts +19 -0
- package/dist/thinking.d.ts.map +1 -0
- package/dist/topology/control-plane.d.ts +58 -0
- package/dist/topology/control-plane.d.ts.map +1 -0
- package/dist/topology/participant-directory.d.ts +33 -0
- package/dist/topology/participant-directory.d.ts.map +1 -0
- package/dist/topology/peer-settle.d.ts +51 -0
- package/dist/topology/peer-settle.d.ts.map +1 -0
- package/dist/topology/records.d.ts +6 -0
- package/dist/topology/records.d.ts.map +1 -0
- package/dist/topology/types.d.ts +89 -0
- package/dist/topology/types.d.ts.map +1 -0
- package/dist/type-error-guidance.d.ts +3 -0
- package/dist/type-error-guidance.d.ts.map +1 -0
- package/dist/ui/arc-group.d.ts +17 -0
- package/dist/ui/arc-group.d.ts.map +1 -0
- package/dist/ui/border-status-editor.d.ts +22 -0
- package/dist/ui/border-status-editor.d.ts.map +1 -0
- package/dist/ui/code-preview-shell.d.ts +11 -0
- package/dist/ui/code-preview-shell.d.ts.map +1 -0
- package/dist/ui/code-preview.d.ts +53 -0
- package/dist/ui/code-preview.d.ts.map +1 -0
- package/dist/ui/controller.d.ts +20 -0
- package/dist/ui/controller.d.ts.map +1 -0
- package/dist/ui/conversation-chrome.d.ts +16 -0
- package/dist/ui/conversation-chrome.d.ts.map +1 -0
- package/dist/ui/conversation-chrome.js +11 -0
- package/dist/ui/conversation-chrome.js.map +7 -0
- package/dist/ui/conversation-commands.d.ts +12 -0
- package/dist/ui/conversation-commands.d.ts.map +1 -0
- package/dist/ui/conversation-history.d.ts +6 -0
- package/dist/ui/conversation-history.d.ts.map +1 -0
- package/dist/ui/conversation-host.d.ts +7 -0
- package/dist/ui/conversation-host.d.ts.map +1 -0
- package/dist/ui/conversation-host.js +9 -0
- package/dist/ui/conversation-host.js.map +7 -0
- package/dist/ui/conversation-native-reader-checkpoint.d.ts +8 -0
- package/dist/ui/conversation-native-reader-checkpoint.d.ts.map +1 -0
- package/dist/ui/conversation-native-reader-replay.d.ts +10 -0
- package/dist/ui/conversation-native-reader-replay.d.ts.map +1 -0
- package/dist/ui/conversation-native-reader.d.ts +110 -0
- package/dist/ui/conversation-native-reader.d.ts.map +1 -0
- package/dist/ui/conversation-native-reader.js +1050 -0
- package/dist/ui/conversation-native-reader.js.map +7 -0
- package/dist/ui/conversation-queue-store.d.ts +14 -0
- package/dist/ui/conversation-queue-store.d.ts.map +1 -0
- package/dist/ui/conversation-queue.d.ts +244 -0
- package/dist/ui/conversation-queue.d.ts.map +1 -0
- package/dist/ui/conversation-render.d.ts +104 -0
- package/dist/ui/conversation-render.d.ts.map +1 -0
- package/dist/ui/conversation-selection.d.ts +18 -0
- package/dist/ui/conversation-selection.d.ts.map +1 -0
- package/dist/ui/conversation-shortcut.d.ts +3 -0
- package/dist/ui/conversation-shortcut.d.ts.map +1 -0
- package/dist/ui/conversation-targets.d.ts +7 -0
- package/dist/ui/conversation-targets.d.ts.map +1 -0
- package/dist/ui/conversation-targets.js +12 -0
- package/dist/ui/conversation-targets.js.map +7 -0
- package/dist/ui/conversation-transcript.d.ts +25 -0
- package/dist/ui/conversation-transcript.d.ts.map +1 -0
- package/dist/ui/conversation.d.ts +219 -0
- package/dist/ui/conversation.d.ts.map +1 -0
- package/dist/ui/conversation.js +2861 -0
- package/dist/ui/conversation.js.map +7 -0
- package/dist/ui/core-tool-render.d.ts +20 -0
- package/dist/ui/core-tool-render.d.ts.map +1 -0
- package/dist/ui/dashboard-detail.d.ts +68 -0
- package/dist/ui/dashboard-detail.d.ts.map +1 -0
- package/dist/ui/dashboard-fabric-graph.d.ts +50 -0
- package/dist/ui/dashboard-fabric-graph.d.ts.map +1 -0
- package/dist/ui/dashboard-graph-controller.d.ts +52 -0
- package/dist/ui/dashboard-graph-controller.d.ts.map +1 -0
- package/dist/ui/dashboard-modal-controller.d.ts +36 -0
- package/dist/ui/dashboard-modal-controller.d.ts.map +1 -0
- package/dist/ui/dashboard-model.d.ts +111 -0
- package/dist/ui/dashboard-model.d.ts.map +1 -0
- package/dist/ui/dashboard-presentation.d.ts +6 -0
- package/dist/ui/dashboard-presentation.d.ts.map +1 -0
- package/dist/ui/dashboard.d.ts +156 -0
- package/dist/ui/dashboard.d.ts.map +1 -0
- package/dist/ui/dashboard.js +4622 -0
- package/dist/ui/dashboard.js.map +7 -0
- package/dist/ui/diff-background.d.ts +12 -0
- package/dist/ui/diff-background.d.ts.map +1 -0
- package/dist/ui/dynamic-border.d.ts +8 -0
- package/dist/ui/dynamic-border.d.ts.map +1 -0
- package/dist/ui/escape-halt.d.ts +11 -0
- package/dist/ui/escape-halt.d.ts.map +1 -0
- package/dist/ui/fabric-actor-delivery-selector.d.ts +17 -0
- package/dist/ui/fabric-actor-delivery-selector.d.ts.map +1 -0
- package/dist/ui/fabric-actor-tool-selector.d.ts +22 -0
- package/dist/ui/fabric-actor-tool-selector.d.ts.map +1 -0
- package/dist/ui/fabric-code-parser.d.ts +9 -0
- package/dist/ui/fabric-code-parser.d.ts.map +1 -0
- package/dist/ui/fabric-host-event-selector.d.ts +29 -0
- package/dist/ui/fabric-host-event-selector.d.ts.map +1 -0
- package/dist/ui/fabric-model-selector.d.ts +64 -0
- package/dist/ui/fabric-model-selector.d.ts.map +1 -0
- package/dist/ui/fabric-render.d.ts +113 -0
- package/dist/ui/fabric-render.d.ts.map +1 -0
- package/dist/ui/fabric-thinking-selector.d.ts +26 -0
- package/dist/ui/fabric-thinking-selector.d.ts.map +1 -0
- package/dist/ui/fabric-title-hint.d.ts +3 -0
- package/dist/ui/fabric-title-hint.d.ts.map +1 -0
- package/dist/ui/format.d.ts +9 -0
- package/dist/ui/format.d.ts.map +1 -0
- package/dist/ui/handoff-completion.d.ts +3 -0
- package/dist/ui/handoff-completion.d.ts.map +1 -0
- package/dist/ui/highlight.d.ts +69 -0
- package/dist/ui/highlight.d.ts.map +1 -0
- package/dist/ui/model-picker.d.ts +46 -0
- package/dist/ui/model-picker.d.ts.map +1 -0
- package/dist/ui/model-picker.js +17 -0
- package/dist/ui/model-picker.js.map +7 -0
- package/dist/ui/preview-lines.d.ts +16 -0
- package/dist/ui/preview-lines.d.ts.map +1 -0
- package/dist/ui/row-balance.d.ts +29 -0
- package/dist/ui/row-balance.d.ts.map +1 -0
- package/dist/ui/settings-component.d.ts +26 -0
- package/dist/ui/settings-component.d.ts.map +1 -0
- package/dist/ui/settings-rpc.d.ts +15 -0
- package/dist/ui/settings-rpc.d.ts.map +1 -0
- package/dist/ui/settings-section-context.d.ts +18 -0
- package/dist/ui/settings-section-context.d.ts.map +1 -0
- package/dist/ui/settings-sections-agents.d.ts +5 -0
- package/dist/ui/settings-sections-agents.d.ts.map +1 -0
- package/dist/ui/settings-sections-execution.d.ts +8 -0
- package/dist/ui/settings-sections-execution.d.ts.map +1 -0
- package/dist/ui/settings-sections-lifecycle.d.ts +6 -0
- package/dist/ui/settings-sections-lifecycle.d.ts.map +1 -0
- package/dist/ui/settings-sections-presentation.d.ts +6 -0
- package/dist/ui/settings-sections-presentation.d.ts.map +1 -0
- package/dist/ui/settings-sections.d.ts +12 -0
- package/dist/ui/settings-sections.d.ts.map +1 -0
- package/dist/ui/settings-submenus.d.ts +74 -0
- package/dist/ui/settings-submenus.d.ts.map +1 -0
- package/dist/ui/settings-values.d.ts +63 -0
- package/dist/ui/settings-values.d.ts.map +1 -0
- package/dist/ui/settings.d.ts +21 -0
- package/dist/ui/settings.d.ts.map +1 -0
- package/dist/ui/settings.js +1985 -0
- package/dist/ui/settings.js.map +7 -0
- package/dist/ui/shell-hang-keys.d.ts +11 -0
- package/dist/ui/shell-hang-keys.d.ts.map +1 -0
- package/dist/ui/shiki-language.d.ts +7 -0
- package/dist/ui/shiki-language.d.ts.map +1 -0
- package/dist/ui/shiki-theme.d.ts +7 -0
- package/dist/ui/shiki-theme.d.ts.map +1 -0
- package/dist/ui/snapshot.d.ts +17 -0
- package/dist/ui/snapshot.d.ts.map +1 -0
- package/dist/ui/spinner.d.ts +6 -0
- package/dist/ui/spinner.d.ts.map +1 -0
- package/dist/ui/state-file-preview.d.ts +13 -0
- package/dist/ui/state-file-preview.d.ts.map +1 -0
- package/dist/ui/structured.d.ts +9 -0
- package/dist/ui/structured.d.ts.map +1 -0
- package/dist/ui/tool-call-timing.d.ts +2 -0
- package/dist/ui/tool-call-timing.d.ts.map +1 -0
- package/dist/ui/tool-display.d.ts +8 -0
- package/dist/ui/tool-display.d.ts.map +1 -0
- package/dist/ui/topology.d.ts +162 -0
- package/dist/ui/topology.d.ts.map +1 -0
- package/dist/ui/transcript-parser.d.ts +18 -0
- package/dist/ui/transcript-parser.d.ts.map +1 -0
- package/dist/ui/transcript-reader.d.ts +10 -0
- package/dist/ui/transcript-reader.d.ts.map +1 -0
- package/dist/ui/transcript-sanitization.d.ts +14 -0
- package/dist/ui/transcript-sanitization.d.ts.map +1 -0
- package/dist/ui/transcript.d.ts +52 -0
- package/dist/ui/transcript.d.ts.map +1 -0
- package/dist/ui/types.d.ts +84 -0
- package/dist/ui/types.d.ts.map +1 -0
- package/dist/ui/widget.d.ts +16 -0
- package/dist/ui/widget.d.ts.map +1 -0
- package/dist/ui/word-diff/alignment.d.ts +6 -0
- package/dist/ui/word-diff/alignment.d.ts.map +1 -0
- package/dist/ui/word-diff/change-block.d.ts +18 -0
- package/dist/ui/word-diff/change-block.d.ts.map +1 -0
- package/dist/ui/word-diff/changed-line.d.ts +14 -0
- package/dist/ui/word-diff/changed-line.d.ts.map +1 -0
- package/dist/ui/word-diff/emphasis.d.ts +9 -0
- package/dist/ui/word-diff/emphasis.d.ts.map +1 -0
- package/dist/ui/word-diff/line-emphasis.d.ts +7 -0
- package/dist/ui/word-diff/line-emphasis.d.ts.map +1 -0
- package/dist/ui/word-diff/line-matching.d.ts +10 -0
- package/dist/ui/word-diff/line-matching.d.ts.map +1 -0
- package/dist/ui/word-diff/line-similarity.d.ts +16 -0
- package/dist/ui/word-diff/line-similarity.d.ts.map +1 -0
- package/dist/ui/word-diff/normalize.d.ts +3 -0
- package/dist/ui/word-diff/normalize.d.ts.map +1 -0
- package/dist/ui/word-diff/parse.d.ts +17 -0
- package/dist/ui/word-diff/parse.d.ts.map +1 -0
- package/dist/ui/word-diff/range-refinement.d.ts +5 -0
- package/dist/ui/word-diff/range-refinement.d.ts.map +1 -0
- package/dist/ui/word-diff/ranges.d.ts +11 -0
- package/dist/ui/word-diff/ranges.d.ts.map +1 -0
- package/dist/ui/word-diff/smart-filter.d.ts +3 -0
- package/dist/ui/word-diff/smart-filter.d.ts.map +1 -0
- package/dist/ui/word-diff/sparse-line-matching.d.ts +25 -0
- package/dist/ui/word-diff/sparse-line-matching.d.ts.map +1 -0
- package/dist/ui/word-diff/text-boundaries.d.ts +11 -0
- package/dist/ui/word-diff/text-boundaries.d.ts.map +1 -0
- package/dist/ui/word-diff/token-alignment.d.ts +9 -0
- package/dist/ui/word-diff/token-alignment.d.ts.map +1 -0
- package/dist/ui/word-diff/token-text-refinement.d.ts +4 -0
- package/dist/ui/word-diff/token-text-refinement.d.ts.map +1 -0
- package/dist/ui/word-diff/tokens.d.ts +16 -0
- package/dist/ui/word-diff/tokens.d.ts.map +1 -0
- package/dist/ui/word-diff/types.d.ts +10 -0
- package/dist/ui/word-diff/types.d.ts.map +1 -0
- package/dist/util.d.ts +3 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/worker/model-control.d.ts +14 -0
- package/dist/worker/model-control.d.ts.map +1 -0
- package/dist/worker/model-control.js +118 -0
- package/dist/worker/model-control.js.map +7 -0
- package/dist/worker/options.d.ts +3 -0
- package/dist/worker/options.d.ts.map +1 -0
- package/dist/worker/options.js +156 -0
- package/dist/worker/options.js.map +7 -0
- package/dist/worker/run-record.d.ts +22 -0
- package/dist/worker/run-record.d.ts.map +1 -0
- package/dist/worker/run-record.js +124 -0
- package/dist/worker/run-record.js.map +7 -0
- package/dist/worker/session-export.d.ts +45 -0
- package/dist/worker/session-export.d.ts.map +1 -0
- package/dist/worker/session-export.js +91 -0
- package/dist/worker/session-export.js.map +7 -0
- package/dist/worker.d.ts +3 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +1074 -0
- package/dist/worker.js.map +7 -0
- package/docs/agents.md +618 -0
- package/docs/architecture.md +141 -0
- package/docs/audit-trace.md +116 -0
- package/docs/certification.md +166 -0
- package/docs/compaction.md +345 -0
- package/docs/component-calculus.md +191 -0
- package/docs/components.md +330 -0
- package/docs/configuration.md +529 -0
- package/docs/entropy.md +214 -0
- package/docs/interface.md +210 -0
- package/docs/jev.md +289 -0
- package/docs/kernels.md +186 -0
- package/docs/memory-recall.md +664 -0
- package/docs/programmatic-compaction.md +205 -0
- package/docs/provider-component-calculus.md +378 -0
- package/docs/providers.md +163 -0
- package/docs/repairs.md +90 -0
- package/docs/residency-runtime.md +82 -0
- package/docs/schema-enforcement.md +166 -0
- package/docs/skills.md +50 -0
- package/docs/speculation.md +171 -0
- package/docs/state-layer.md +197 -0
- package/package.json +135 -0
- package/skillsets/python/fabric-advisor/SKILL.md +29 -0
- package/skillsets/python/fabric-ambient/SKILL.md +44 -0
- package/skillsets/python/fabric-ambient/references/setup.md +67 -0
- package/skillsets/python/fabric-council/SKILL.md +54 -0
- package/skillsets/python/fabric-exec/SKILL.md +74 -0
- package/skillsets/python/fabric-exec/references/agents.md +65 -0
- package/skillsets/python/fabric-exec/references/mcp.md +23 -0
- package/skillsets/python/fabric-exec/references/mesh.md +27 -0
- package/skillsets/python/fabric-fusion/SKILL.md +112 -0
- package/skillsets/python/fabric-guide/SKILL.md +29 -0
- package/skillsets/python/fabric-jev/SKILL.md +162 -0
- package/skillsets/python/fabric-rlm/SKILL.md +120 -0
- package/skillsets/python/fabric-schema/SKILL.md +55 -0
- package/skillsets/python/fabric-spec/SKILL.md +42 -0
- package/skillsets/python/fabric-supervisor/SKILL.md +37 -0
- package/skillsets/python/fabric-swarm/SKILL.md +40 -0
- package/skillsets/python/fabric-workflow/SKILL.md +62 -0
- package/skillsets/typescript/fabric-advisor/SKILL.md +29 -0
- package/skillsets/typescript/fabric-ambient/SKILL.md +44 -0
- package/skillsets/typescript/fabric-ambient/references/setup.md +90 -0
- package/skillsets/typescript/fabric-council/SKILL.md +94 -0
- package/skillsets/typescript/fabric-exec/SKILL.md +142 -0
- package/skillsets/typescript/fabric-exec/references/agents.md +218 -0
- package/skillsets/typescript/fabric-exec/references/mcp.md +49 -0
- package/skillsets/typescript/fabric-exec/references/mesh.md +51 -0
- package/skillsets/typescript/fabric-fusion/SKILL.md +332 -0
- package/skillsets/typescript/fabric-guide/SKILL.md +29 -0
- package/skillsets/typescript/fabric-jev/SKILL.md +159 -0
- package/skillsets/typescript/fabric-rlm/SKILL.md +284 -0
- package/skillsets/typescript/fabric-schema/SKILL.md +121 -0
- package/skillsets/typescript/fabric-spec/SKILL.md +42 -0
- package/skillsets/typescript/fabric-supervisor/SKILL.md +37 -0
- package/skillsets/typescript/fabric-swarm/SKILL.md +80 -0
- package/skillsets/typescript/fabric-workflow/SKILL.md +133 -0
|
@@ -0,0 +1,1924 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fabricExecTitleHint
|
|
3
|
+
} from "./chunk-656HWVFU.js";
|
|
4
|
+
import {
|
|
5
|
+
FABRIC_BRANCH_RUN_DESCRIPTION_MAX_BYTES,
|
|
6
|
+
FABRIC_BRANCH_RUN_NAME_MAX_BYTES,
|
|
7
|
+
FABRIC_BRANCH_SUMMARY_KIND,
|
|
8
|
+
FABRIC_BRANCH_SUMMARY_MAX_BYTES,
|
|
9
|
+
FABRIC_BRANCH_SUMMARY_MAX_FACTS,
|
|
10
|
+
FABRIC_BRANCH_SUMMARY_VERSION,
|
|
11
|
+
readFabricBranchSummaryDetails,
|
|
12
|
+
readFabricProjectionTrace
|
|
13
|
+
} from "./chunk-ZDNGXLEC.js";
|
|
14
|
+
import {
|
|
15
|
+
MAX_SUMMARY_BYTES,
|
|
16
|
+
clipUtf8,
|
|
17
|
+
decodeCompactionInstructions,
|
|
18
|
+
omissionLine,
|
|
19
|
+
sampleAddressed,
|
|
20
|
+
sampleAddressedFrom,
|
|
21
|
+
utf8Bytes
|
|
22
|
+
} from "./chunk-3H7SDWZI.js";
|
|
23
|
+
|
|
24
|
+
// src/compaction/hook.ts
|
|
25
|
+
import "@earendil-works/pi-coding-agent";
|
|
26
|
+
|
|
27
|
+
// src/core/token-math.ts
|
|
28
|
+
var ESTIMATED_IMAGE_CHARS = 4800;
|
|
29
|
+
var DEFAULT_COMPACTION_SETTINGS = {
|
|
30
|
+
enabled: true,
|
|
31
|
+
reserveTokens: 16384,
|
|
32
|
+
keepRecentTokens: 2e4
|
|
33
|
+
};
|
|
34
|
+
var contentParts = (content) => {
|
|
35
|
+
if (typeof content !== "string") return content ?? [];
|
|
36
|
+
return [];
|
|
37
|
+
};
|
|
38
|
+
var estimateTextAndImageContentChars = (content) => {
|
|
39
|
+
if (typeof content === "string") {
|
|
40
|
+
return content.length;
|
|
41
|
+
}
|
|
42
|
+
let chars = 0;
|
|
43
|
+
for (const block of contentParts(content)) {
|
|
44
|
+
if (block.type === "text" && block.text) {
|
|
45
|
+
chars += block.text.length;
|
|
46
|
+
} else if (block.type === "image") {
|
|
47
|
+
chars += ESTIMATED_IMAGE_CHARS;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return chars;
|
|
51
|
+
};
|
|
52
|
+
var textLength = (value) => typeof value === "string" ? value.length : 0;
|
|
53
|
+
var estimateTokens = (message) => {
|
|
54
|
+
let chars = 0;
|
|
55
|
+
switch (message.role) {
|
|
56
|
+
case "user": {
|
|
57
|
+
chars = estimateTextAndImageContentChars(message.content);
|
|
58
|
+
return Math.ceil(chars / 4);
|
|
59
|
+
}
|
|
60
|
+
case "assistant": {
|
|
61
|
+
for (const block of contentParts(message.content)) {
|
|
62
|
+
if (block.type === "text") {
|
|
63
|
+
chars += textLength(block.text);
|
|
64
|
+
} else if (block.type === "thinking") {
|
|
65
|
+
chars += textLength(block.thinking);
|
|
66
|
+
} else if (block.type === "toolCall") {
|
|
67
|
+
chars += textLength(block.name) + JSON.stringify(block.arguments).length;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return Math.ceil(chars / 4);
|
|
71
|
+
}
|
|
72
|
+
case "custom":
|
|
73
|
+
case "toolResult": {
|
|
74
|
+
chars = estimateTextAndImageContentChars(message.content);
|
|
75
|
+
return Math.ceil(chars / 4);
|
|
76
|
+
}
|
|
77
|
+
case "bashExecution": {
|
|
78
|
+
chars = textLength(message.command) + textLength(message.output);
|
|
79
|
+
return Math.ceil(chars / 4);
|
|
80
|
+
}
|
|
81
|
+
case "branchSummary":
|
|
82
|
+
case "compactionSummary": {
|
|
83
|
+
chars = textLength(message.summary);
|
|
84
|
+
return Math.ceil(chars / 4);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return 0;
|
|
88
|
+
};
|
|
89
|
+
var calculateContextTokens = (usage) => {
|
|
90
|
+
if (typeof usage !== "object" || usage === null) return 0;
|
|
91
|
+
const record = usage;
|
|
92
|
+
const totalTokens = record.totalTokens;
|
|
93
|
+
if (typeof totalTokens === "number" && totalTokens > 0) return totalTokens;
|
|
94
|
+
const count = (value) => typeof value === "number" ? value : 0;
|
|
95
|
+
return count(record.input) + count(record.output) + count(record.cacheRead) + count(record.cacheWrite);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// src/core/session-context.ts
|
|
99
|
+
var buildEntryIndex = (entries, byId) => {
|
|
100
|
+
if (byId) return byId;
|
|
101
|
+
const index = /* @__PURE__ */ new Map();
|
|
102
|
+
for (const entry of entries) {
|
|
103
|
+
index.set(entry.id, entry);
|
|
104
|
+
}
|
|
105
|
+
return index;
|
|
106
|
+
};
|
|
107
|
+
var buildSessionPath = (entries, leafId, byId) => {
|
|
108
|
+
const index = buildEntryIndex(entries, byId);
|
|
109
|
+
let leaf = void 0;
|
|
110
|
+
if (leafId !== void 0) {
|
|
111
|
+
leaf = index.get(leafId);
|
|
112
|
+
}
|
|
113
|
+
leaf = leaf ?? entries[entries.length - 1];
|
|
114
|
+
if (!leaf) {
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
const path = [];
|
|
118
|
+
let current = leaf;
|
|
119
|
+
while (current) {
|
|
120
|
+
path.push(current);
|
|
121
|
+
const parent = current;
|
|
122
|
+
current = parent.parentId ? index.get(parent.parentId) : void 0;
|
|
123
|
+
}
|
|
124
|
+
path.reverse();
|
|
125
|
+
return path;
|
|
126
|
+
};
|
|
127
|
+
var getSessionContextSettings = (path) => {
|
|
128
|
+
let thinkingLevel = "off";
|
|
129
|
+
let model = null;
|
|
130
|
+
for (const entry of path) {
|
|
131
|
+
if (entry.type === "thinking_level_change") {
|
|
132
|
+
thinkingLevel = entry.thinkingLevel;
|
|
133
|
+
} else if (entry.type === "model_change") {
|
|
134
|
+
model = { provider: entry.provider, modelId: entry.modelId };
|
|
135
|
+
} else if (entry.type === "message" && entry.message.role === "assistant") {
|
|
136
|
+
model = { provider: entry.message.provider, modelId: entry.message.model };
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return { thinkingLevel, model };
|
|
140
|
+
};
|
|
141
|
+
var createBranchSummaryMessage = (summary, fromId, timestamp) => ({
|
|
142
|
+
role: "branchSummary",
|
|
143
|
+
summary,
|
|
144
|
+
fromId,
|
|
145
|
+
timestamp: new Date(timestamp).getTime()
|
|
146
|
+
});
|
|
147
|
+
var createCompactionSummaryMessage = (summary, tokensBefore, timestamp) => ({
|
|
148
|
+
role: "compactionSummary",
|
|
149
|
+
summary,
|
|
150
|
+
tokensBefore,
|
|
151
|
+
timestamp: new Date(timestamp).getTime()
|
|
152
|
+
});
|
|
153
|
+
var createCustomMessage = (customType, content, display, details, timestamp) => ({
|
|
154
|
+
role: "custom",
|
|
155
|
+
customType,
|
|
156
|
+
content,
|
|
157
|
+
display,
|
|
158
|
+
details,
|
|
159
|
+
timestamp: new Date(timestamp).getTime()
|
|
160
|
+
});
|
|
161
|
+
var sessionEntryToContextMessages = (entry) => {
|
|
162
|
+
if (entry.type === "message") {
|
|
163
|
+
const message = entry.message;
|
|
164
|
+
if ((message.role === "user" || message.role === "assistant" || message.role === "toolResult") && message.content == null) {
|
|
165
|
+
return [{ ...message, content: [] }];
|
|
166
|
+
}
|
|
167
|
+
return [message];
|
|
168
|
+
}
|
|
169
|
+
if (entry.type === "custom_message") {
|
|
170
|
+
return [
|
|
171
|
+
createCustomMessage(entry.customType, entry.content ?? [], entry.display, entry.details, entry.timestamp)
|
|
172
|
+
];
|
|
173
|
+
}
|
|
174
|
+
if (entry.type === "branch_summary" && entry.summary) {
|
|
175
|
+
return [createBranchSummaryMessage(entry.summary, entry.fromId, entry.timestamp)];
|
|
176
|
+
}
|
|
177
|
+
if (entry.type === "compaction") {
|
|
178
|
+
return [createCompactionSummaryMessage(entry.summary, entry.tokensBefore, entry.timestamp)];
|
|
179
|
+
}
|
|
180
|
+
return [];
|
|
181
|
+
};
|
|
182
|
+
var buildContextEntries = (entries, leafId, byId) => {
|
|
183
|
+
const path = buildSessionPath(entries, leafId, byId);
|
|
184
|
+
let compaction = void 0;
|
|
185
|
+
for (const entry of path) {
|
|
186
|
+
if (entry.type === "compaction") {
|
|
187
|
+
compaction = entry;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (!compaction) {
|
|
191
|
+
return path;
|
|
192
|
+
}
|
|
193
|
+
const compactionIdx = [...path].findIndex(
|
|
194
|
+
(entry) => entry.id === compaction?.id
|
|
195
|
+
);
|
|
196
|
+
if (compactionIdx < 0) {
|
|
197
|
+
return path;
|
|
198
|
+
}
|
|
199
|
+
const contextEntries = [compaction];
|
|
200
|
+
let foundFirstKept = false;
|
|
201
|
+
for (let i = 0; i < compactionIdx; i++) {
|
|
202
|
+
const entry = path[i];
|
|
203
|
+
if (!entry) continue;
|
|
204
|
+
if (entry.id === compaction.firstKeptEntryId) {
|
|
205
|
+
foundFirstKept = true;
|
|
206
|
+
}
|
|
207
|
+
if (foundFirstKept) {
|
|
208
|
+
contextEntries.push(entry);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
contextEntries.push(...path.slice(compactionIdx + 1));
|
|
212
|
+
return contextEntries;
|
|
213
|
+
};
|
|
214
|
+
var buildSessionContext = (entries, leafId, byId) => {
|
|
215
|
+
const path = buildSessionPath(entries, leafId, byId);
|
|
216
|
+
const { thinkingLevel, model } = getSessionContextSettings(path);
|
|
217
|
+
const messages = buildContextEntries(entries, leafId, byId).flatMap(sessionEntryToContextMessages);
|
|
218
|
+
return { messages, thinkingLevel, model };
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
// src/compaction/threshold.ts
|
|
222
|
+
var modelCompactionKey = (model) => model ? `${model.provider}/${model.id}` : void 0;
|
|
223
|
+
var configuredCompactionTokenThreshold = (config, modelKey) => modelKey === void 0 ? void 0 : config.compaction.tokenThresholds[modelKey];
|
|
224
|
+
var configuredCompactionThreshold = (config, modelKey) => modelKey === void 0 ? void 0 : config.compaction.thresholds[modelKey];
|
|
225
|
+
var runThresholdCompact = (context) => new Promise((resolve) => {
|
|
226
|
+
context.compact({
|
|
227
|
+
onComplete: () => resolve(true),
|
|
228
|
+
onError: (error) => {
|
|
229
|
+
if (context.hasUI) {
|
|
230
|
+
context.ui.notify(`Fabric threshold compaction failed: ${error.message}`, "warning");
|
|
231
|
+
}
|
|
232
|
+
resolve(false);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
var compactAtConfiguredThreshold = async (context, config) => {
|
|
237
|
+
const modelKey = modelCompactionKey(context.model);
|
|
238
|
+
const usage = context.getContextUsage();
|
|
239
|
+
if (usage === void 0) return false;
|
|
240
|
+
const tokenThreshold = configuredCompactionTokenThreshold(config, modelKey);
|
|
241
|
+
if (tokenThreshold !== void 0) {
|
|
242
|
+
if (usage.tokens === null || usage.tokens < tokenThreshold) return false;
|
|
243
|
+
return runThresholdCompact(context);
|
|
244
|
+
}
|
|
245
|
+
const threshold = configuredCompactionThreshold(config, modelKey);
|
|
246
|
+
if (threshold === void 0 || usage.percent === null) return false;
|
|
247
|
+
if (usage.percent / 100 < threshold) return false;
|
|
248
|
+
return runThresholdCompact(context);
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
// src/compaction/enrichers.ts
|
|
252
|
+
var NO_BUILTIN_ENRICHERS = Object.freeze([]);
|
|
253
|
+
var runEnrichers = (enrichers, events, sections) => {
|
|
254
|
+
for (const enricher of enrichers) {
|
|
255
|
+
if (!enricher.applies(events)) continue;
|
|
256
|
+
enricher.contribute(events, sections);
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
// src/run-display.ts
|
|
261
|
+
var recordDisplay = (record) => {
|
|
262
|
+
const display = {};
|
|
263
|
+
if (typeof record.name === "string") display.name = record.name;
|
|
264
|
+
if (typeof record.description === "string") display.description = record.description;
|
|
265
|
+
return display.name !== void 0 || display.description !== void 0 ? display : void 0;
|
|
266
|
+
};
|
|
267
|
+
var parseObjectString = (text) => {
|
|
268
|
+
if (!text.startsWith("{") || !text.endsWith("}")) return void 0;
|
|
269
|
+
try {
|
|
270
|
+
const parsed = JSON.parse(text);
|
|
271
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : void 0;
|
|
272
|
+
} catch {
|
|
273
|
+
return void 0;
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
var normalizeRunDisplay = (input) => {
|
|
277
|
+
if (typeof input === "string") {
|
|
278
|
+
const text = input.trim();
|
|
279
|
+
if (!text) return void 0;
|
|
280
|
+
const parsed = text.startsWith("{") ? parseObjectString(text) : void 0;
|
|
281
|
+
return (parsed && recordDisplay(parsed)) ?? { name: input };
|
|
282
|
+
}
|
|
283
|
+
if (typeof input === "object" && input !== null && !Array.isArray(input)) {
|
|
284
|
+
return recordDisplay(input);
|
|
285
|
+
}
|
|
286
|
+
return void 0;
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
// src/ui/fabric-title-hint.ts
|
|
290
|
+
var TITLE_HINT_CACHE_MAX = 256;
|
|
291
|
+
var titleHintCache = /* @__PURE__ */ new Map();
|
|
292
|
+
var fabricExecTitleHintCached = (code, kernel = "typescript") => {
|
|
293
|
+
const key = `${kernel}\0${code}`;
|
|
294
|
+
const hit = titleHintCache.get(key);
|
|
295
|
+
if (hit !== void 0 || titleHintCache.has(key)) return hit;
|
|
296
|
+
const hint = fabricExecTitleHint(code, kernel);
|
|
297
|
+
if (titleHintCache.size >= TITLE_HINT_CACHE_MAX) {
|
|
298
|
+
const oldest = titleHintCache.keys().next().value;
|
|
299
|
+
if (oldest !== void 0) titleHintCache.delete(oldest);
|
|
300
|
+
}
|
|
301
|
+
titleHintCache.set(key, hint);
|
|
302
|
+
return hint;
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
// src/compaction/normalize.ts
|
|
306
|
+
var isMessageEntry = (entry) => entry.type === "message";
|
|
307
|
+
var MAX_CUSTOM_DETAILS_DEPTH = 12;
|
|
308
|
+
var MAX_CUSTOM_DETAILS_NODES = 256;
|
|
309
|
+
var MAX_CUSTOM_DETAILS_COLLECTION = 64;
|
|
310
|
+
var MAX_CUSTOM_DETAILS_STRING_BYTES = 1024;
|
|
311
|
+
var MAX_CUSTOM_DETAILS_BYTES = 8 * 1024;
|
|
312
|
+
var boundedJsonValue = (value, state, depth = 0) => {
|
|
313
|
+
state.nodes += 1;
|
|
314
|
+
if (state.nodes > MAX_CUSTOM_DETAILS_NODES) return void 0;
|
|
315
|
+
if (value === null || typeof value === "boolean") return value;
|
|
316
|
+
if (typeof value === "string") return clipUtf8(value, MAX_CUSTOM_DETAILS_STRING_BYTES);
|
|
317
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : void 0;
|
|
318
|
+
if (typeof value !== "object" || depth > MAX_CUSTOM_DETAILS_DEPTH || state.ancestors.has(value)) return void 0;
|
|
319
|
+
state.ancestors.add(value);
|
|
320
|
+
try {
|
|
321
|
+
if (Array.isArray(value)) {
|
|
322
|
+
const output2 = [];
|
|
323
|
+
for (const item of value.slice(0, MAX_CUSTOM_DETAILS_COLLECTION)) {
|
|
324
|
+
const sanitized = boundedJsonValue(item, state, depth + 1);
|
|
325
|
+
if (sanitized === void 0) return void 0;
|
|
326
|
+
output2.push(sanitized);
|
|
327
|
+
}
|
|
328
|
+
return output2;
|
|
329
|
+
}
|
|
330
|
+
const output = /* @__PURE__ */ Object.create(null);
|
|
331
|
+
const keys = Object.keys(value).sort().slice(0, MAX_CUSTOM_DETAILS_COLLECTION);
|
|
332
|
+
for (const key of keys) {
|
|
333
|
+
const sanitized = boundedJsonValue(value[key], state, depth + 1);
|
|
334
|
+
if (sanitized === void 0) return void 0;
|
|
335
|
+
output[key] = sanitized;
|
|
336
|
+
}
|
|
337
|
+
return output;
|
|
338
|
+
} finally {
|
|
339
|
+
state.ancestors.delete(value);
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
var customDetails = (value) => {
|
|
343
|
+
if (value === void 0) return void 0;
|
|
344
|
+
try {
|
|
345
|
+
const sanitized = boundedJsonValue(value, { nodes: 0, ancestors: /* @__PURE__ */ new Set() });
|
|
346
|
+
if (sanitized === void 0 || utf8Bytes(JSON.stringify(sanitized)) > MAX_CUSTOM_DETAILS_BYTES) return void 0;
|
|
347
|
+
return sanitized;
|
|
348
|
+
} catch {
|
|
349
|
+
return void 0;
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
var isTypedCustomContent = (content) => {
|
|
353
|
+
if (typeof content === "string") return true;
|
|
354
|
+
if (!Array.isArray(content)) return false;
|
|
355
|
+
return content.every((part) => {
|
|
356
|
+
if (part === null || typeof part !== "object") return false;
|
|
357
|
+
const candidate = part;
|
|
358
|
+
if (candidate.type === "text") return typeof candidate.text === "string";
|
|
359
|
+
return candidate.type === "image";
|
|
360
|
+
});
|
|
361
|
+
};
|
|
362
|
+
var isPiCustomMessageEntry = (entry) => {
|
|
363
|
+
try {
|
|
364
|
+
if (entry.type !== "custom_message") return false;
|
|
365
|
+
const candidate = entry;
|
|
366
|
+
return typeof candidate.customType === "string" && typeof candidate.display === "boolean" && isTypedCustomContent(candidate.content);
|
|
367
|
+
} catch {
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
var textOfContent = (content) => {
|
|
372
|
+
if (typeof content === "string") return content;
|
|
373
|
+
if (!Array.isArray(content)) return "";
|
|
374
|
+
const parts = [];
|
|
375
|
+
for (const part of content) {
|
|
376
|
+
if (part && typeof part === "object" && "type" in part) {
|
|
377
|
+
if (part.type === "text" && typeof part.text === "string") parts.push(part.text);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return parts.join("\n");
|
|
381
|
+
};
|
|
382
|
+
var firstLine = (text) => {
|
|
383
|
+
const trimmed = text.trimStart();
|
|
384
|
+
const nl = trimmed.indexOf("\n");
|
|
385
|
+
return nl < 0 ? trimmed : trimmed.slice(0, nl);
|
|
386
|
+
};
|
|
387
|
+
var fabricRunIntent = (call, details) => {
|
|
388
|
+
const python = typeof details === "object" && details !== null && "kernel" in details && details.kernel === "python";
|
|
389
|
+
if (!call || call.name !== "fabric_exec") return void 0;
|
|
390
|
+
const display = normalizeRunDisplay(call.args.display);
|
|
391
|
+
const intentName = display?.name?.trim() ? display.name : typeof call.args.code === "string" ? fabricExecTitleHintCached(call.args.code, python ? "python" : "typescript") ?? (python ? "Python program" : void 0) : void 0;
|
|
392
|
+
if (intentName === void 0) return void 0;
|
|
393
|
+
const name = clipUtf8(intentName.trim(), FABRIC_BRANCH_RUN_NAME_MAX_BYTES);
|
|
394
|
+
if (!name) return void 0;
|
|
395
|
+
const description = display?.description !== void 0 ? clipUtf8(display.description.trim(), FABRIC_BRANCH_RUN_DESCRIPTION_MAX_BYTES) : "";
|
|
396
|
+
return { name, ...description ? { description } : {} };
|
|
397
|
+
};
|
|
398
|
+
var normalizeEntries = (entries) => {
|
|
399
|
+
const events = [];
|
|
400
|
+
const calls = /* @__PURE__ */ new Map();
|
|
401
|
+
let index = 0;
|
|
402
|
+
const push = (event) => {
|
|
403
|
+
index += 1;
|
|
404
|
+
events.push({ ...event, index });
|
|
405
|
+
};
|
|
406
|
+
const pushBranchFacts = (entry) => {
|
|
407
|
+
const details = readFabricBranchSummaryDetails(entry.details);
|
|
408
|
+
if (!details) return;
|
|
409
|
+
for (const fact of details.facts) {
|
|
410
|
+
if (fact.kind === "user") {
|
|
411
|
+
push({ kind: "user", entryId: fact.entryId, sourceEntryId: entry.id, text: fact.text });
|
|
412
|
+
} else if (fact.kind === "customMessage") {
|
|
413
|
+
push({
|
|
414
|
+
kind: "customMessage",
|
|
415
|
+
entryId: fact.entryId,
|
|
416
|
+
sourceEntryId: entry.id,
|
|
417
|
+
customType: fact.customType,
|
|
418
|
+
text: fact.text,
|
|
419
|
+
display: fact.display,
|
|
420
|
+
...fact.details !== void 0 ? { details: fact.details } : {}
|
|
421
|
+
});
|
|
422
|
+
} else if (fact.kind === "phase") {
|
|
423
|
+
push({
|
|
424
|
+
kind: "fabricPhase",
|
|
425
|
+
entryId: fact.entryId,
|
|
426
|
+
sourceEntryId: entry.id,
|
|
427
|
+
subordinal: fact.subordinal,
|
|
428
|
+
address: fact.address,
|
|
429
|
+
phase: fact.phase
|
|
430
|
+
});
|
|
431
|
+
} else if (fact.kind === "fabricRun") {
|
|
432
|
+
push({
|
|
433
|
+
kind: "fabricRun",
|
|
434
|
+
entryId: fact.entryId,
|
|
435
|
+
sourceEntryId: entry.id,
|
|
436
|
+
toolCallId: fact.subordinal.startsWith("call:") ? fact.subordinal.slice("call:".length) : fact.subordinal,
|
|
437
|
+
subordinal: fact.subordinal,
|
|
438
|
+
address: fact.address,
|
|
439
|
+
name: fact.name,
|
|
440
|
+
...fact.description !== void 0 ? { description: fact.description } : {},
|
|
441
|
+
outcome: fact.outcome,
|
|
442
|
+
source: "branch"
|
|
443
|
+
});
|
|
444
|
+
} else {
|
|
445
|
+
push({
|
|
446
|
+
kind: "fabricOperation",
|
|
447
|
+
entryId: fact.entryId,
|
|
448
|
+
sourceEntryId: entry.id,
|
|
449
|
+
subordinal: fact.subordinal,
|
|
450
|
+
address: fact.address,
|
|
451
|
+
ref: fact.ref,
|
|
452
|
+
...fact.provider ? { provider: fact.provider } : {},
|
|
453
|
+
...fact.action ? { action: fact.action } : {},
|
|
454
|
+
tool: fact.tool,
|
|
455
|
+
args: fact.args,
|
|
456
|
+
outcome: fact.outcome,
|
|
457
|
+
...fact.error !== void 0 ? { error: fact.error } : {},
|
|
458
|
+
...fact.result !== void 0 ? { result: fact.result } : {},
|
|
459
|
+
source: "branch"
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
for (const entry of entries) {
|
|
465
|
+
if (entry.type === "branch_summary") {
|
|
466
|
+
pushBranchFacts(entry);
|
|
467
|
+
continue;
|
|
468
|
+
}
|
|
469
|
+
if (entry.type === "custom_message") {
|
|
470
|
+
try {
|
|
471
|
+
if (!isPiCustomMessageEntry(entry)) continue;
|
|
472
|
+
const details = customDetails(entry.details);
|
|
473
|
+
push({
|
|
474
|
+
kind: "customMessage",
|
|
475
|
+
entryId: entry.id,
|
|
476
|
+
sourceEntryId: entry.id,
|
|
477
|
+
customType: entry.customType,
|
|
478
|
+
text: textOfContent(entry.content),
|
|
479
|
+
display: entry.display,
|
|
480
|
+
...details !== void 0 ? { details } : {}
|
|
481
|
+
});
|
|
482
|
+
} catch {
|
|
483
|
+
}
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
486
|
+
if (!isMessageEntry(entry)) continue;
|
|
487
|
+
const message = entry.message;
|
|
488
|
+
if (!message || typeof message !== "object") continue;
|
|
489
|
+
const role = message.role;
|
|
490
|
+
const entryId = entry.id;
|
|
491
|
+
if (role === "user") {
|
|
492
|
+
push({ kind: "user", entryId, sourceEntryId: entryId, text: textOfContent(message.content) });
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
if (role === "assistant") {
|
|
496
|
+
const content = message.content;
|
|
497
|
+
if (!Array.isArray(content)) continue;
|
|
498
|
+
for (const part of content) {
|
|
499
|
+
if (!part || typeof part !== "object" || !("type" in part)) continue;
|
|
500
|
+
if (part.type === "text" && typeof part.text === "string") {
|
|
501
|
+
push({ kind: "assistantText", entryId, sourceEntryId: entryId, text: part.text });
|
|
502
|
+
} else if (part.type === "toolCall" && typeof part.id === "string" && typeof part.name === "string") {
|
|
503
|
+
const args = part.arguments ?? {};
|
|
504
|
+
calls.set(part.id, { entryId, name: part.name, args });
|
|
505
|
+
push({ kind: "toolCall", entryId, sourceEntryId: entryId, toolCallId: part.id, name: part.name, args });
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
continue;
|
|
509
|
+
}
|
|
510
|
+
if (role === "toolResult") {
|
|
511
|
+
const toolResult = message;
|
|
512
|
+
const toolCallId = typeof toolResult.toolCallId === "string" ? toolResult.toolCallId : "";
|
|
513
|
+
const toolName = typeof toolResult.toolName === "string" ? toolResult.toolName : "";
|
|
514
|
+
const isError = toolResult.isError === true;
|
|
515
|
+
const text = textOfContent(toolResult.content);
|
|
516
|
+
const pending = toolCallId ? calls.get(toolCallId) : void 0;
|
|
517
|
+
if (toolName === "bash") {
|
|
518
|
+
const command = pending && typeof pending.args.command === "string" ? pending.args.command : "";
|
|
519
|
+
push({
|
|
520
|
+
kind: "bash",
|
|
521
|
+
entryId,
|
|
522
|
+
sourceEntryId: entryId,
|
|
523
|
+
toolCallId,
|
|
524
|
+
command,
|
|
525
|
+
isError,
|
|
526
|
+
exitCode: null,
|
|
527
|
+
...isError && text ? { error: text } : {}
|
|
528
|
+
});
|
|
529
|
+
} else {
|
|
530
|
+
push({ kind: "toolResult", entryId, sourceEntryId: entryId, toolCallId, toolName, isError, text });
|
|
531
|
+
}
|
|
532
|
+
if (toolName === "fabric_exec") {
|
|
533
|
+
const nested = readFabricProjectionTrace(toolResult.details);
|
|
534
|
+
const intent = fabricRunIntent(pending, toolResult.details);
|
|
535
|
+
if (intent && pending) {
|
|
536
|
+
const subordinal = `call:${toolCallId}`;
|
|
537
|
+
push({
|
|
538
|
+
kind: "fabricRun",
|
|
539
|
+
entryId: pending.entryId,
|
|
540
|
+
sourceEntryId: entryId,
|
|
541
|
+
toolCallId,
|
|
542
|
+
subordinal,
|
|
543
|
+
address: `${pending.entryId}/${subordinal}`,
|
|
544
|
+
name: intent.name,
|
|
545
|
+
...intent.description !== void 0 ? { description: intent.description } : {},
|
|
546
|
+
outcome: nested?.outcome ?? (isError ? "failed" : "succeeded"),
|
|
547
|
+
source: nested?.source ?? "result"
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
if (nested) {
|
|
551
|
+
for (let phaseIndex = 0; phaseIndex < nested.phases.length; phaseIndex++) {
|
|
552
|
+
const subordinal = `phase:${phaseIndex}`;
|
|
553
|
+
push({
|
|
554
|
+
kind: "fabricPhase",
|
|
555
|
+
entryId,
|
|
556
|
+
sourceEntryId: entryId,
|
|
557
|
+
subordinal,
|
|
558
|
+
address: `${entryId}/${subordinal}`,
|
|
559
|
+
phase: nested.phases[phaseIndex]
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
for (const operation of nested.operations) {
|
|
563
|
+
const subordinal = String(operation.sequence);
|
|
564
|
+
push({
|
|
565
|
+
kind: "fabricOperation",
|
|
566
|
+
entryId,
|
|
567
|
+
sourceEntryId: entryId,
|
|
568
|
+
subordinal,
|
|
569
|
+
address: `${entryId}/${subordinal}`,
|
|
570
|
+
ref: operation.ref,
|
|
571
|
+
...operation.provider ? { provider: operation.provider } : {},
|
|
572
|
+
...operation.action ? { action: operation.action } : {},
|
|
573
|
+
tool: operation.tool,
|
|
574
|
+
args: operation.args,
|
|
575
|
+
outcome: operation.outcome,
|
|
576
|
+
...operation.error !== void 0 ? { error: operation.error } : {},
|
|
577
|
+
...operation.result !== void 0 ? { result: operation.result } : {},
|
|
578
|
+
source: operation.source
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
continue;
|
|
584
|
+
}
|
|
585
|
+
if (role === "bashExecution") {
|
|
586
|
+
const bash = message;
|
|
587
|
+
const exitCode = typeof bash.exitCode === "number" ? bash.exitCode : null;
|
|
588
|
+
const isError = exitCode !== null && exitCode !== 0;
|
|
589
|
+
push({
|
|
590
|
+
kind: "bash",
|
|
591
|
+
entryId,
|
|
592
|
+
sourceEntryId: entryId,
|
|
593
|
+
toolCallId: "",
|
|
594
|
+
command: typeof bash.command === "string" ? bash.command : "",
|
|
595
|
+
isError,
|
|
596
|
+
exitCode,
|
|
597
|
+
...isError && typeof bash.output === "string" && bash.output ? { error: bash.output } : {}
|
|
598
|
+
});
|
|
599
|
+
continue;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
return events;
|
|
603
|
+
};
|
|
604
|
+
var countErasedThinkingBlocks = (entries) => {
|
|
605
|
+
let count = 0;
|
|
606
|
+
for (const entry of entries) {
|
|
607
|
+
if (!isMessageEntry(entry)) continue;
|
|
608
|
+
const message = entry.message;
|
|
609
|
+
if (message.role !== "assistant" || !Array.isArray(message.content)) continue;
|
|
610
|
+
for (const part of message.content) {
|
|
611
|
+
if (!part || typeof part !== "object" || !("type" in part)) continue;
|
|
612
|
+
if (part.type === "thinking" && typeof part.thinking === "string") count += 1;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return count;
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
// src/compaction/projections.ts
|
|
619
|
+
var MAX_LINE = 140;
|
|
620
|
+
var FILE_TOOLS = /* @__PURE__ */ new Set(["read", "edit", "write", "grep", "find", "ls"]);
|
|
621
|
+
var MODIFYING_TOOLS = /* @__PURE__ */ new Set(["edit", "write"]);
|
|
622
|
+
var MAX_USER_GOAL_LINES = 3;
|
|
623
|
+
var MAX_USER_GOAL_LINE = 1024;
|
|
624
|
+
var MAX_USER_ONELINER = 120;
|
|
625
|
+
var MAX_EARLIER_USER = 80;
|
|
626
|
+
var MAX_STATUS_LINE = 140;
|
|
627
|
+
var MAX_TRANSCRIPT_LINE = 100;
|
|
628
|
+
var MAX_TRANSCRIPT_CMD = 80;
|
|
629
|
+
var MAX_FABRIC_RUN_NAME = 80;
|
|
630
|
+
var MAX_FABRIC_RUN_DESCRIPTION = 180;
|
|
631
|
+
var MAX_FABRIC_RUN_TRANSCRIPT_NAME = 60;
|
|
632
|
+
var MAX_FABRIC_RUN_EARLIER_NAME = 48;
|
|
633
|
+
var MAX_FABRIC_RUN_STATUS_NAME = 96;
|
|
634
|
+
var MAX_LATER_GOALS = 24;
|
|
635
|
+
var MAX_FILES_PER_KIND = 24;
|
|
636
|
+
var MAX_OUTSTANDING = 32;
|
|
637
|
+
var MAX_ACTIVITY = 48;
|
|
638
|
+
var MAX_UNRESOLVED = 24;
|
|
639
|
+
var MAX_RESOLVED = MAX_OUTSTANDING - MAX_UNRESOLVED;
|
|
640
|
+
var MAX_EARLIER_TURNS = 32;
|
|
641
|
+
var TRANSCRIPT_WINDOW = 40;
|
|
642
|
+
var truncate = (text, max) => {
|
|
643
|
+
const flat = text.replace(/\s+/g, " ").trim();
|
|
644
|
+
return flat.length > max ? `${flat.slice(0, max - 1)}\u2026` : flat;
|
|
645
|
+
};
|
|
646
|
+
var quoted = (text, max) => JSON.stringify(truncate(text, max));
|
|
647
|
+
var customDetailsSuffix = (details, max = 160) => {
|
|
648
|
+
if (details === void 0) return "";
|
|
649
|
+
try {
|
|
650
|
+
return ` details=${truncate(JSON.stringify(details), max)}`;
|
|
651
|
+
} catch {
|
|
652
|
+
return "";
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
var customMessageLine = (event, maxText) => {
|
|
656
|
+
const visibility = event.display ? "visible" : "hidden";
|
|
657
|
+
return `custom ${quoted(event.customType, 80)} (${visibility}): ${quoted(event.text, maxText)}${customDetailsSuffix(event.details)}`;
|
|
658
|
+
};
|
|
659
|
+
var trailingEllipsis = (lines, max) => {
|
|
660
|
+
if (lines.length <= max) return lines;
|
|
661
|
+
return [...lines.slice(0, max), "\u2026"];
|
|
662
|
+
};
|
|
663
|
+
var pathOf = (args) => {
|
|
664
|
+
const value = args.path ?? args.file ?? args.dir;
|
|
665
|
+
return typeof value === "string" && value.trim() ? value : void 0;
|
|
666
|
+
};
|
|
667
|
+
var collectOperations = (events) => {
|
|
668
|
+
const calls = /* @__PURE__ */ new Map();
|
|
669
|
+
for (const event of events) {
|
|
670
|
+
if (event.kind === "toolCall") calls.set(event.toolCallId, event);
|
|
671
|
+
}
|
|
672
|
+
const operations = [];
|
|
673
|
+
for (const event of events) {
|
|
674
|
+
if (event.kind === "fabricOperation") {
|
|
675
|
+
operations.push({
|
|
676
|
+
index: event.index,
|
|
677
|
+
entryId: event.entryId,
|
|
678
|
+
address: event.address,
|
|
679
|
+
tool: event.tool,
|
|
680
|
+
ref: event.ref,
|
|
681
|
+
...event.provider ? { provider: event.provider } : {},
|
|
682
|
+
...event.action ? { action: event.action } : {},
|
|
683
|
+
args: event.args,
|
|
684
|
+
outcome: event.outcome,
|
|
685
|
+
...event.error !== void 0 ? { error: event.error } : {},
|
|
686
|
+
...event.result !== void 0 ? { result: event.result } : {},
|
|
687
|
+
nested: true
|
|
688
|
+
});
|
|
689
|
+
continue;
|
|
690
|
+
}
|
|
691
|
+
if (event.kind === "toolResult" && event.toolName !== "bash") {
|
|
692
|
+
const call = event.toolCallId ? calls.get(event.toolCallId) : void 0;
|
|
693
|
+
if (!call) continue;
|
|
694
|
+
operations.push({
|
|
695
|
+
index: event.index,
|
|
696
|
+
entryId: call.entryId,
|
|
697
|
+
address: call.entryId,
|
|
698
|
+
tool: call.name,
|
|
699
|
+
ref: call.name,
|
|
700
|
+
args: call.args,
|
|
701
|
+
outcome: event.isError ? "failed" : "succeeded",
|
|
702
|
+
...event.isError && event.text ? { error: event.text } : {},
|
|
703
|
+
nested: false
|
|
704
|
+
});
|
|
705
|
+
continue;
|
|
706
|
+
}
|
|
707
|
+
if (event.kind === "bash") {
|
|
708
|
+
operations.push({
|
|
709
|
+
index: event.index,
|
|
710
|
+
entryId: event.entryId,
|
|
711
|
+
address: event.entryId,
|
|
712
|
+
tool: "bash",
|
|
713
|
+
ref: "bash",
|
|
714
|
+
args: { command: event.command },
|
|
715
|
+
outcome: event.isError ? "failed" : "succeeded",
|
|
716
|
+
...event.error ? { error: event.error } : {},
|
|
717
|
+
nested: false
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
return operations.sort((left, right) => left.index - right.index);
|
|
722
|
+
};
|
|
723
|
+
var isFileOperation = (operation) => FILE_TOOLS.has(operation.tool) && (operation.ref === operation.tool || operation.ref === `pi.${operation.tool}`);
|
|
724
|
+
var isBashOperation = (operation) => operation.tool === "bash" && (operation.ref === "bash" || operation.ref === "pi.bash");
|
|
725
|
+
var resultProvesCreation = (result) => {
|
|
726
|
+
if (!result || typeof result !== "object" || Array.isArray(result)) return false;
|
|
727
|
+
const record = result;
|
|
728
|
+
if (record.created === true) return true;
|
|
729
|
+
const details = record.details;
|
|
730
|
+
return Boolean(details && typeof details === "object" && !Array.isArray(details) && details.created === true);
|
|
731
|
+
};
|
|
732
|
+
var commonRoot = (paths) => {
|
|
733
|
+
if (paths.length === 0) return "";
|
|
734
|
+
const split = paths.map((p) => p.split(/[\\/]/).filter(Boolean));
|
|
735
|
+
let common = 0;
|
|
736
|
+
const first = split[0];
|
|
737
|
+
loop: while (common < first.length) {
|
|
738
|
+
const segment = first[common];
|
|
739
|
+
for (let i = 1; i < split.length; i++) {
|
|
740
|
+
if (split[i].length <= common || split[i][common] !== segment) break loop;
|
|
741
|
+
}
|
|
742
|
+
common += 1;
|
|
743
|
+
}
|
|
744
|
+
if (common === 0) return "";
|
|
745
|
+
return `${first.slice(0, common).join("/")}/`;
|
|
746
|
+
};
|
|
747
|
+
var stripRoot = (root, path) => root ? path.replace(root, "") : path;
|
|
748
|
+
var projectGoal = (events) => {
|
|
749
|
+
const first = events.find(
|
|
750
|
+
(event) => event.kind === "user"
|
|
751
|
+
);
|
|
752
|
+
if (!first) return { lines: [], omitted: 0 };
|
|
753
|
+
const firstLines = first.text.split("\n").filter(
|
|
754
|
+
(line, i, arr) => line.trim() !== "" || i === 0 && arr.length === 1
|
|
755
|
+
).map((line) => truncate(line, MAX_USER_GOAL_LINE));
|
|
756
|
+
const lines = [...trailingEllipsis(firstLines, MAX_USER_GOAL_LINES)];
|
|
757
|
+
function* laterUsers() {
|
|
758
|
+
let skippedFirst = false;
|
|
759
|
+
for (const event of events) {
|
|
760
|
+
if (event.kind !== "user") continue;
|
|
761
|
+
if (!skippedFirst) {
|
|
762
|
+
skippedFirst = true;
|
|
763
|
+
continue;
|
|
764
|
+
}
|
|
765
|
+
yield event;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
const sampled = sampleAddressedFrom(laterUsers(), MAX_LATER_GOALS);
|
|
769
|
+
for (let index = 0; index < sampled.values.length; index++) {
|
|
770
|
+
if (sampled.omitted > 0 && index === sampled.splitIndex) {
|
|
771
|
+
lines.push(omissionLine(
|
|
772
|
+
sampled.omitted,
|
|
773
|
+
sampled.omittedFirstEntryId,
|
|
774
|
+
sampled.omittedLastEntryId,
|
|
775
|
+
"user scope changes"
|
|
776
|
+
));
|
|
777
|
+
}
|
|
778
|
+
const user = sampled.values[index];
|
|
779
|
+
const line = truncate(firstLine(user.text), MAX_USER_ONELINER);
|
|
780
|
+
if (line) lines.push(`- ${line} [entry ${user.entryId}]`);
|
|
781
|
+
}
|
|
782
|
+
return { lines, omitted: sampled.omitted };
|
|
783
|
+
};
|
|
784
|
+
var projectFiles = (events) => {
|
|
785
|
+
const read = /* @__PURE__ */ new Map();
|
|
786
|
+
const modified = /* @__PURE__ */ new Map();
|
|
787
|
+
const written = /* @__PURE__ */ new Map();
|
|
788
|
+
const created = /* @__PURE__ */ new Map();
|
|
789
|
+
for (const operation of collectOperations(events)) {
|
|
790
|
+
if (!isFileOperation(operation) || operation.outcome !== "succeeded") continue;
|
|
791
|
+
const path = pathOf(operation.args);
|
|
792
|
+
if (!path) continue;
|
|
793
|
+
const address = { path, entryId: operation.address };
|
|
794
|
+
if (operation.tool === "write") {
|
|
795
|
+
const target = resultProvesCreation(operation.result) ? created : written;
|
|
796
|
+
if (!target.has(path)) target.set(path, address);
|
|
797
|
+
} else if (operation.tool === "edit") {
|
|
798
|
+
if (!modified.has(path)) modified.set(path, address);
|
|
799
|
+
} else if (!read.has(path)) {
|
|
800
|
+
read.set(path, address);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
const modifiedSet = /* @__PURE__ */ new Set();
|
|
804
|
+
for (const path of modified.keys()) modifiedSet.add(path);
|
|
805
|
+
for (const path of written.keys()) modifiedSet.add(path);
|
|
806
|
+
for (const path of created.keys()) modifiedSet.add(path);
|
|
807
|
+
function* filteredRead() {
|
|
808
|
+
for (const item of read.values()) {
|
|
809
|
+
if (!modifiedSet.has(item.path)) yield item;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
const sampledCreated = sampleAddressedFrom(created.values(), MAX_FILES_PER_KIND);
|
|
813
|
+
const sampledWritten = sampleAddressedFrom(written.values(), MAX_FILES_PER_KIND);
|
|
814
|
+
const sampledModified = sampleAddressedFrom(modified.values(), MAX_FILES_PER_KIND);
|
|
815
|
+
const sampledRead = sampleAddressedFrom(filteredRead(), MAX_FILES_PER_KIND);
|
|
816
|
+
const allSampled = [
|
|
817
|
+
...sampledCreated.values,
|
|
818
|
+
...sampledWritten.values,
|
|
819
|
+
...sampledModified.values,
|
|
820
|
+
...sampledRead.values
|
|
821
|
+
];
|
|
822
|
+
if (allSampled.length === 0) return { lines: [], omitted: 0 };
|
|
823
|
+
const root = commonRoot(allSampled.map((item) => item.path));
|
|
824
|
+
const lines = [];
|
|
825
|
+
let omitted = 0;
|
|
826
|
+
if (root) lines.push(`(under ${root})`);
|
|
827
|
+
const appendKind = (header, sampled) => {
|
|
828
|
+
if (sampled.values.length === 0 && sampled.omitted === 0) return;
|
|
829
|
+
lines.push(header);
|
|
830
|
+
omitted += sampled.omitted;
|
|
831
|
+
for (let index = 0; index < sampled.values.length; index++) {
|
|
832
|
+
if (sampled.omitted > 0 && index === sampled.splitIndex) {
|
|
833
|
+
lines.push(` ${omissionLine(
|
|
834
|
+
sampled.omitted,
|
|
835
|
+
sampled.omittedFirstEntryId,
|
|
836
|
+
sampled.omittedLastEntryId,
|
|
837
|
+
"file addresses"
|
|
838
|
+
)}`);
|
|
839
|
+
}
|
|
840
|
+
const item = sampled.values[index];
|
|
841
|
+
lines.push(` ${stripRoot(root, item.path)} [entry ${item.entryId}]`);
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
appendKind("Created:", sampledCreated);
|
|
845
|
+
appendKind("Written:", sampledWritten);
|
|
846
|
+
appendKind("Modified:", sampledModified);
|
|
847
|
+
appendKind("Read:", sampledRead);
|
|
848
|
+
return { lines, omitted };
|
|
849
|
+
};
|
|
850
|
+
var fabricRunPointer = (event) => event.source === "branch" ? event.address : event.entryId;
|
|
851
|
+
var projectActivity = (events) => {
|
|
852
|
+
const items = [];
|
|
853
|
+
for (const event of events) {
|
|
854
|
+
if (event.kind === "fabricRun") {
|
|
855
|
+
const name = clipUtf8(truncate(event.name, MAX_FABRIC_RUN_NAME), 192);
|
|
856
|
+
const description = event.description ? clipUtf8(truncate(event.description, MAX_FABRIC_RUN_DESCRIPTION), 512) : "";
|
|
857
|
+
items.push({
|
|
858
|
+
entryId: fabricRunPointer(event),
|
|
859
|
+
line: `- ${name}${description ? ` \u2014 ${description}` : ""} \u2192 ${event.outcome}`
|
|
860
|
+
});
|
|
861
|
+
} else if (event.kind === "fabricPhase") {
|
|
862
|
+
items.push({ entryId: event.address, line: `- Phase: ${truncate(event.phase, MAX_LINE)}` });
|
|
863
|
+
} else if (event.kind === "fabricOperation") {
|
|
864
|
+
if (FILE_TOOLS.has(event.tool) && (event.ref === event.tool || event.ref === `pi.${event.tool}`)) continue;
|
|
865
|
+
const bash = event.tool === "bash" && (event.ref === "bash" || event.ref === "pi.bash");
|
|
866
|
+
const primary = bash ? event.args.command : event.args.id ?? event.args.name ?? event.args.query ?? event.args.action;
|
|
867
|
+
const detail = typeof primary === "string" && primary.trim() ? ` (${truncate(firstLine(primary), 72)})` : "";
|
|
868
|
+
items.push({
|
|
869
|
+
entryId: event.address,
|
|
870
|
+
line: `- ${event.ref}${detail} \u2192 ${event.outcome}`
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
const sampled = sampleAddressed(items, MAX_ACTIVITY);
|
|
875
|
+
const lines = [];
|
|
876
|
+
for (let index = 0; index < sampled.values.length; index++) {
|
|
877
|
+
if (sampled.omitted > 0 && index === sampled.splitIndex) {
|
|
878
|
+
lines.push(omissionLine(
|
|
879
|
+
sampled.omitted,
|
|
880
|
+
sampled.omittedFirstEntryId,
|
|
881
|
+
sampled.omittedLastEntryId,
|
|
882
|
+
"Fabric activity records"
|
|
883
|
+
));
|
|
884
|
+
}
|
|
885
|
+
const item = sampled.values[index];
|
|
886
|
+
lines.push(`${item.line} [entry ${item.entryId}]`);
|
|
887
|
+
}
|
|
888
|
+
return { lines, omitted: sampled.omitted };
|
|
889
|
+
};
|
|
890
|
+
var projectOutstandingWithMetadata = (events) => {
|
|
891
|
+
const operations = collectOperations(events);
|
|
892
|
+
const keyOf = (operation) => {
|
|
893
|
+
const path = isFileOperation(operation) ? pathOf(operation.args) : void 0;
|
|
894
|
+
if (path) return `file\0${operation.tool}\0${path}`;
|
|
895
|
+
const command = isBashOperation(operation) && typeof operation.args.command === "string" ? operation.args.command : void 0;
|
|
896
|
+
if (command !== void 0) return `bash\0${operation.tool}\0${command}`;
|
|
897
|
+
return `generic\0${operation.ref}\0${JSON.stringify(operation.args)}`;
|
|
898
|
+
};
|
|
899
|
+
const successes = operations.filter((operation) => operation.outcome === "succeeded").map((operation) => ({ index: operation.index, key: keyOf(operation) }));
|
|
900
|
+
const items = [];
|
|
901
|
+
for (const operation of operations) {
|
|
902
|
+
if (operation.outcome === "succeeded") continue;
|
|
903
|
+
const path = isFileOperation(operation) ? pathOf(operation.args) : void 0;
|
|
904
|
+
const command = isBashOperation(operation) && typeof operation.args.command === "string" ? operation.args.command : void 0;
|
|
905
|
+
const subject = path ? `${operation.ref} ${path}` : command !== void 0 ? `${operation.ref}: ${truncate(firstLine(command), MAX_LINE)}` : operation.ref;
|
|
906
|
+
const error = operation.error ? `: ${truncate(firstLine(operation.error), MAX_LINE)}` : `: ${operation.outcome}`;
|
|
907
|
+
const key = keyOf(operation);
|
|
908
|
+
const resolved2 = successes.some((success) => success.index > operation.index && success.key === key);
|
|
909
|
+
items.push({
|
|
910
|
+
index: operation.index,
|
|
911
|
+
entryId: operation.address,
|
|
912
|
+
description: `${subject}${error}`,
|
|
913
|
+
resolved: resolved2
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
if (items.length === 0) return { lines: [], omitted: 0 };
|
|
917
|
+
const unresolved = items.filter((i) => !i.resolved).sort((a, b) => a.index - b.index);
|
|
918
|
+
const resolved = items.filter((i) => i.resolved).sort((a, b) => a.index - b.index);
|
|
919
|
+
const sampledUnresolved = sampleAddressed(unresolved, MAX_UNRESOLVED);
|
|
920
|
+
const sampledResolved = sampleAddressed(resolved, MAX_RESOLVED);
|
|
921
|
+
const lines = [];
|
|
922
|
+
const append = (sampled, noun) => {
|
|
923
|
+
for (let index = 0; index < sampled.values.length; index++) {
|
|
924
|
+
if (sampled.omitted > 0 && index === sampled.splitIndex) {
|
|
925
|
+
lines.push(omissionLine(
|
|
926
|
+
sampled.omitted,
|
|
927
|
+
sampled.omittedFirstEntryId,
|
|
928
|
+
sampled.omittedLastEntryId,
|
|
929
|
+
noun
|
|
930
|
+
));
|
|
931
|
+
}
|
|
932
|
+
const item = sampled.values[index];
|
|
933
|
+
lines.push(`- ${item.description}${item.resolved ? " [RESOLVED]" : ""} [entry ${item.entryId}]`);
|
|
934
|
+
}
|
|
935
|
+
};
|
|
936
|
+
append(sampledUnresolved, "open error records");
|
|
937
|
+
append(sampledResolved, "resolved error records");
|
|
938
|
+
return { lines, omitted: sampledUnresolved.omitted + sampledResolved.omitted };
|
|
939
|
+
};
|
|
940
|
+
var projectEarlierTurns = (events) => {
|
|
941
|
+
function* earlierTurns() {
|
|
942
|
+
let currentContext;
|
|
943
|
+
let counts = /* @__PURE__ */ new Map();
|
|
944
|
+
let order = [];
|
|
945
|
+
let lastRun;
|
|
946
|
+
const completed = () => {
|
|
947
|
+
if (!currentContext) return void 0;
|
|
948
|
+
return {
|
|
949
|
+
entryId: currentContext.entryId,
|
|
950
|
+
contextLine: currentContext.kind === "user" ? quoted(firstLine(currentContext.text), MAX_EARLIER_USER) : customMessageLine(currentContext, MAX_EARLIER_USER),
|
|
951
|
+
tools: order.map((name) => `${name}:${counts.get(name) ?? 0}`).join(" "),
|
|
952
|
+
run: lastRun ? `fabric:${quoted(clipUtf8(lastRun.name, 128), MAX_FABRIC_RUN_EARLIER_NAME)}\u2192${lastRun.outcome}` : ""
|
|
953
|
+
};
|
|
954
|
+
};
|
|
955
|
+
for (const event of events) {
|
|
956
|
+
if (event.kind === "user" || event.kind === "customMessage") {
|
|
957
|
+
const turn = completed();
|
|
958
|
+
if (turn) yield turn;
|
|
959
|
+
currentContext = event;
|
|
960
|
+
counts = /* @__PURE__ */ new Map();
|
|
961
|
+
order = [];
|
|
962
|
+
lastRun = void 0;
|
|
963
|
+
continue;
|
|
964
|
+
}
|
|
965
|
+
if (!currentContext) continue;
|
|
966
|
+
if (event.kind === "fabricRun") lastRun = event;
|
|
967
|
+
const name = event.kind === "toolCall" ? event.name === "fabric_exec" ? void 0 : event.name : event.kind === "bash" ? "bash" : event.kind === "fabricOperation" ? event.tool : void 0;
|
|
968
|
+
if (!name) continue;
|
|
969
|
+
if (!counts.has(name)) order.push(name);
|
|
970
|
+
counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
const sampled = sampleAddressedFrom(earlierTurns(), MAX_EARLIER_TURNS);
|
|
974
|
+
const lines = [];
|
|
975
|
+
for (let index = 0; index < sampled.values.length; index++) {
|
|
976
|
+
if (sampled.omitted > 0 && index === sampled.splitIndex) {
|
|
977
|
+
lines.push(omissionLine(
|
|
978
|
+
sampled.omitted,
|
|
979
|
+
sampled.omittedFirstEntryId,
|
|
980
|
+
sampled.omittedLastEntryId,
|
|
981
|
+
"earlier turns"
|
|
982
|
+
));
|
|
983
|
+
}
|
|
984
|
+
const turn = sampled.values[index];
|
|
985
|
+
const metadata = [turn.tools, turn.run].filter(Boolean).join(" | ");
|
|
986
|
+
lines.push(`${turn.contextLine}${metadata ? ` | ${metadata}` : ""} [entry ${turn.entryId}]`);
|
|
987
|
+
}
|
|
988
|
+
return { lines, omitted: sampled.omitted };
|
|
989
|
+
};
|
|
990
|
+
var projectStatus = (events) => {
|
|
991
|
+
const lastContext = [...events].reverse().find(
|
|
992
|
+
(event) => event.kind === "user" || event.kind === "customMessage"
|
|
993
|
+
);
|
|
994
|
+
const lines = [];
|
|
995
|
+
if (lastContext?.kind === "user") {
|
|
996
|
+
lines.push(`Last request: ${truncate(firstLine(lastContext.text), MAX_STATUS_LINE)}`);
|
|
997
|
+
} else if (lastContext) {
|
|
998
|
+
lines.push(`Last context: ${customMessageLine(lastContext, MAX_STATUS_LINE)}`);
|
|
999
|
+
}
|
|
1000
|
+
let lastModify;
|
|
1001
|
+
for (const operation of collectOperations(events)) {
|
|
1002
|
+
if (isFileOperation(operation) && MODIFYING_TOOLS.has(operation.tool)) lastModify = operation;
|
|
1003
|
+
}
|
|
1004
|
+
if (lastModify) {
|
|
1005
|
+
const path = pathOf(lastModify.args) ?? "";
|
|
1006
|
+
lines.push(`Last change: ${lastModify.tool}${path ? ` ${path}` : ""}`);
|
|
1007
|
+
}
|
|
1008
|
+
const lastRun = [...events].reverse().find((event) => event.kind === "fabricRun");
|
|
1009
|
+
if (lastRun) {
|
|
1010
|
+
lines.push(
|
|
1011
|
+
`Last execution: ${clipUtf8(truncate(lastRun.name, MAX_FABRIC_RUN_STATUS_NAME), 256)} \u2192 ${lastRun.outcome} [entry ${fabricRunPointer(lastRun)}]`
|
|
1012
|
+
);
|
|
1013
|
+
}
|
|
1014
|
+
const lastAssistant = [...events].reverse().find((e) => e.kind === "assistantText");
|
|
1015
|
+
if (lastAssistant) {
|
|
1016
|
+
const text = truncate(firstLine(lastAssistant.text), MAX_STATUS_LINE);
|
|
1017
|
+
if (text) lines.push(`Last note: ${text}`);
|
|
1018
|
+
}
|
|
1019
|
+
return lines;
|
|
1020
|
+
};
|
|
1021
|
+
var summarizeArgs = (name, args) => {
|
|
1022
|
+
if (name === "fabric_exec") return "structured execution";
|
|
1023
|
+
const primary = name === "bash" ? args.command ?? args.cmd ?? args.shell : name === "grep" ? args.pattern ?? args.query ?? args.regex : name === "find" ? args.pattern : pathOf(args);
|
|
1024
|
+
if (typeof primary === "string" && primary.trim()) {
|
|
1025
|
+
return truncate(firstLine(primary), MAX_TRANSCRIPT_CMD);
|
|
1026
|
+
}
|
|
1027
|
+
const entries = Object.entries(args).slice(0, 2);
|
|
1028
|
+
return entries.map(([key, value]) => `${key}=${truncate(String(value), 40)}`).join(" ");
|
|
1029
|
+
};
|
|
1030
|
+
var projectTranscript = (events) => {
|
|
1031
|
+
const completedFabricCalls = new Set(
|
|
1032
|
+
events.filter((event) => event.kind === "fabricRun").map((event) => event.toolCallId)
|
|
1033
|
+
);
|
|
1034
|
+
const transcriptEvents = events.filter((event) => {
|
|
1035
|
+
if (event.kind === "toolCall") {
|
|
1036
|
+
return event.name !== "fabric_exec" || !completedFabricCalls.has(event.toolCallId);
|
|
1037
|
+
}
|
|
1038
|
+
if (event.kind === "toolResult") {
|
|
1039
|
+
return event.toolName !== "fabric_exec" || !completedFabricCalls.has(event.toolCallId);
|
|
1040
|
+
}
|
|
1041
|
+
return true;
|
|
1042
|
+
});
|
|
1043
|
+
const window = transcriptEvents.slice(-TRANSCRIPT_WINDOW);
|
|
1044
|
+
const lines = [];
|
|
1045
|
+
const omitted = transcriptEvents.length - window.length;
|
|
1046
|
+
if (omitted > 0) {
|
|
1047
|
+
lines.push(omissionLine(
|
|
1048
|
+
omitted,
|
|
1049
|
+
transcriptEvents[0]?.entryId,
|
|
1050
|
+
transcriptEvents[omitted - 1]?.entryId,
|
|
1051
|
+
"transcript events"
|
|
1052
|
+
));
|
|
1053
|
+
}
|
|
1054
|
+
for (const e of window) {
|
|
1055
|
+
const ref = `(#${e.index})`;
|
|
1056
|
+
if (e.kind === "user") {
|
|
1057
|
+
lines.push(`${ref} user: ${truncate(firstLine(e.text), MAX_TRANSCRIPT_LINE)}`);
|
|
1058
|
+
} else if (e.kind === "assistantText") {
|
|
1059
|
+
lines.push(`${ref} assistant: ${truncate(firstLine(e.text), MAX_TRANSCRIPT_LINE)}`);
|
|
1060
|
+
} else if (e.kind === "customMessage") {
|
|
1061
|
+
lines.push(`${ref} ${customMessageLine(e, MAX_TRANSCRIPT_LINE)}`);
|
|
1062
|
+
} else if (e.kind === "toolCall") {
|
|
1063
|
+
lines.push(`${ref} ${e.name}(${summarizeArgs(e.name, e.args)})`);
|
|
1064
|
+
} else if (e.kind === "toolResult") {
|
|
1065
|
+
const status = e.isError ? "error" : "ok";
|
|
1066
|
+
lines.push(`${ref} \u2192 ${status}: ${truncate(firstLine(e.text), MAX_TRANSCRIPT_LINE)}`);
|
|
1067
|
+
} else if (e.kind === "bash") {
|
|
1068
|
+
const status = e.isError ? "error" : "ok";
|
|
1069
|
+
lines.push(`${ref} bash(${truncate(firstLine(e.command), MAX_TRANSCRIPT_CMD)}) \u2192 ${status}`);
|
|
1070
|
+
} else if (e.kind === "fabricRun") {
|
|
1071
|
+
lines.push(
|
|
1072
|
+
`${ref} fabric_exec ${quoted(clipUtf8(e.name, 160), MAX_FABRIC_RUN_TRANSCRIPT_NAME)} \u2192 ${e.outcome} [entry ${fabricRunPointer(e)}]`
|
|
1073
|
+
);
|
|
1074
|
+
} else if (e.kind === "fabricPhase") {
|
|
1075
|
+
lines.push(`${ref} phase(${truncate(e.phase, MAX_TRANSCRIPT_CMD)}) [${e.address}]`);
|
|
1076
|
+
} else if (e.kind === "fabricOperation") {
|
|
1077
|
+
lines.push(`${ref} ${e.ref}(${summarizeArgs(e.tool, e.args)}) \u2192 ${e.outcome} [${e.address}]`);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
return { lines, omitted };
|
|
1081
|
+
};
|
|
1082
|
+
var projectWithMetadata = (events) => {
|
|
1083
|
+
const goal = projectGoal(events);
|
|
1084
|
+
const files = projectFiles(events);
|
|
1085
|
+
const activity = projectActivity(events);
|
|
1086
|
+
const outstanding = projectOutstandingWithMetadata(events);
|
|
1087
|
+
const earlierTurns = projectEarlierTurns(events);
|
|
1088
|
+
const transcript = projectTranscript(events);
|
|
1089
|
+
return {
|
|
1090
|
+
sections: {
|
|
1091
|
+
goal: goal.lines,
|
|
1092
|
+
files: files.lines,
|
|
1093
|
+
activity: activity.lines,
|
|
1094
|
+
outstanding: outstanding.lines,
|
|
1095
|
+
earlierTurns: earlierTurns.lines,
|
|
1096
|
+
status: projectStatus(events),
|
|
1097
|
+
transcript: transcript.lines
|
|
1098
|
+
},
|
|
1099
|
+
omittedCounts: {
|
|
1100
|
+
goal: goal.omitted,
|
|
1101
|
+
files: files.omitted,
|
|
1102
|
+
activity: activity.omitted,
|
|
1103
|
+
outstanding: outstanding.omitted,
|
|
1104
|
+
earlierTurns: earlierTurns.omitted,
|
|
1105
|
+
transcript: transcript.omitted
|
|
1106
|
+
}
|
|
1107
|
+
};
|
|
1108
|
+
};
|
|
1109
|
+
|
|
1110
|
+
// src/compaction/render.ts
|
|
1111
|
+
var SECTION_ORDER = [
|
|
1112
|
+
{ key: "goal", header: "[Session Goal]", maxBytes: 4096 },
|
|
1113
|
+
{ key: "files", header: "[Files And Changes]", maxBytes: 4608 },
|
|
1114
|
+
{ key: "activity", header: "[Fabric Activity]", maxBytes: 2048 },
|
|
1115
|
+
{ key: "outstanding", header: "[Outstanding Context]", maxBytes: 4608 },
|
|
1116
|
+
{ key: "earlierTurns", header: "[Earlier Turns]", maxBytes: 3072 },
|
|
1117
|
+
{ key: "status", header: "[Current Status]", maxBytes: 2048 }
|
|
1118
|
+
];
|
|
1119
|
+
var REQUEST_MAX_BYTES = 3072;
|
|
1120
|
+
var TRANSCRIPT_MAX_BYTES = 5120;
|
|
1121
|
+
var FOOTER_MAX_BYTES = 1536;
|
|
1122
|
+
var MAX_INPUT_LINES_PER_SECTION = 128;
|
|
1123
|
+
var MAX_RENDERED_LINE_BYTES = 1024;
|
|
1124
|
+
var POINTER_LINE = "For exact pre-summary history, use memory.recall on this range, then memory.expand by stable entry or operation address.";
|
|
1125
|
+
var sampledLines = (lines, keep) => {
|
|
1126
|
+
if (lines.length <= keep) return [...lines];
|
|
1127
|
+
const earliest = Math.ceil(keep / 2);
|
|
1128
|
+
const latest = Math.floor(keep / 2);
|
|
1129
|
+
return [
|
|
1130
|
+
...lines.slice(0, earliest),
|
|
1131
|
+
`\u2026 omitted ${lines.length - keep} rendered lines`,
|
|
1132
|
+
...lines.slice(lines.length - latest)
|
|
1133
|
+
];
|
|
1134
|
+
};
|
|
1135
|
+
var boundedBlock = (header, sourceLines, maxBytes) => {
|
|
1136
|
+
const clipped = sourceLines.map((line) => clipUtf8(line, MAX_RENDERED_LINE_BYTES));
|
|
1137
|
+
const capped = sampledLines(clipped, Math.min(clipped.length, MAX_INPUT_LINES_PER_SECTION));
|
|
1138
|
+
for (let keep = capped.length; keep >= 0; keep--) {
|
|
1139
|
+
const lines = sampledLines(capped, keep);
|
|
1140
|
+
const block = [header, ...lines].join("\n");
|
|
1141
|
+
if (utf8Bytes(block) <= maxBytes) return block;
|
|
1142
|
+
}
|
|
1143
|
+
return clipUtf8(header, maxBytes);
|
|
1144
|
+
};
|
|
1145
|
+
var renderSummary = (sections, options) => {
|
|
1146
|
+
const blocks = [];
|
|
1147
|
+
for (const { key, header, maxBytes } of SECTION_ORDER) {
|
|
1148
|
+
const lines = sections[key];
|
|
1149
|
+
if (lines.length === 0) continue;
|
|
1150
|
+
blocks.push(boundedBlock(header, lines, maxBytes));
|
|
1151
|
+
if (key === "goal" && options.requestLines && options.requestLines.length > 0) {
|
|
1152
|
+
blocks.push(boundedBlock("[Compaction Request]", options.requestLines, REQUEST_MAX_BYTES));
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
if (sections.goal.length === 0 && options.requestLines && options.requestLines.length > 0) {
|
|
1156
|
+
blocks.unshift(boundedBlock("[Compaction Request]", options.requestLines, REQUEST_MAX_BYTES));
|
|
1157
|
+
}
|
|
1158
|
+
if (sections.transcript.length > 0) {
|
|
1159
|
+
blocks.push(boundedBlock("---", sections.transcript, TRANSCRIPT_MAX_BYTES));
|
|
1160
|
+
}
|
|
1161
|
+
const timestamp = options.lastTimestamp || "(unknown time)";
|
|
1162
|
+
const range = options.firstEntryId || options.lastEntryId ? `${options.firstEntryId || "(start)"} \u2192 ${options.lastEntryId || "(end)"}` : "(no entries)";
|
|
1163
|
+
const footer = options.summaryKind === "branch" ? `[branch summarized ${timestamp}; structural source entries ${range}]` : `[compacted ${timestamp}; cumulative source entries ${range}]`;
|
|
1164
|
+
blocks.push(boundedBlock("---", [footer, POINTER_LINE], FOOTER_MAX_BYTES));
|
|
1165
|
+
const summary = `${blocks.join("\n\n")}
|
|
1166
|
+
`;
|
|
1167
|
+
if (utf8Bytes(summary) <= MAX_SUMMARY_BYTES) return summary;
|
|
1168
|
+
return `${clipUtf8(summary, MAX_SUMMARY_BYTES - 1, "")}
|
|
1169
|
+
`;
|
|
1170
|
+
};
|
|
1171
|
+
|
|
1172
|
+
// src/compaction/branch-summary.ts
|
|
1173
|
+
var SECTION_HEADERS = [
|
|
1174
|
+
{ key: "goal", header: "[Session Goal]" },
|
|
1175
|
+
{ key: "files", header: "[Files And Changes]" },
|
|
1176
|
+
{ key: "activity", header: "[Fabric Activity]" },
|
|
1177
|
+
{ key: "outstanding", header: "[Outstanding Context]" },
|
|
1178
|
+
{ key: "earlierTurns", header: "[Earlier Turns]" },
|
|
1179
|
+
{ key: "status", header: "[Current Status]" }
|
|
1180
|
+
];
|
|
1181
|
+
var asJsonObject = (value) => {
|
|
1182
|
+
try {
|
|
1183
|
+
const cloned = JSON.parse(JSON.stringify(value));
|
|
1184
|
+
return cloned && typeof cloned === "object" && !Array.isArray(cloned) ? cloned : void 0;
|
|
1185
|
+
} catch {
|
|
1186
|
+
return void 0;
|
|
1187
|
+
}
|
|
1188
|
+
};
|
|
1189
|
+
var directOperationFact = (call, outcome, error) => {
|
|
1190
|
+
if (call.name === "fabric_exec") return void 0;
|
|
1191
|
+
const args = asJsonObject(call.args);
|
|
1192
|
+
if (!args) return void 0;
|
|
1193
|
+
const subordinal = `call:${call.toolCallId}`;
|
|
1194
|
+
return {
|
|
1195
|
+
kind: "operation",
|
|
1196
|
+
entryId: call.entryId,
|
|
1197
|
+
subordinal,
|
|
1198
|
+
address: `${call.entryId}/${subordinal}`,
|
|
1199
|
+
ref: call.name,
|
|
1200
|
+
action: call.name,
|
|
1201
|
+
tool: call.name,
|
|
1202
|
+
args,
|
|
1203
|
+
outcome,
|
|
1204
|
+
...error ? { error: clipUtf8(error, 8 * 1024) } : {}
|
|
1205
|
+
};
|
|
1206
|
+
};
|
|
1207
|
+
var factsFromEvents = (events) => {
|
|
1208
|
+
const facts = [];
|
|
1209
|
+
const calls = /* @__PURE__ */ new Map();
|
|
1210
|
+
for (const event of events) {
|
|
1211
|
+
if (event.kind === "toolCall") calls.set(event.toolCallId, event);
|
|
1212
|
+
}
|
|
1213
|
+
for (const event of events) {
|
|
1214
|
+
if (event.kind === "user") {
|
|
1215
|
+
facts.push({
|
|
1216
|
+
kind: "user",
|
|
1217
|
+
entryId: event.entryId,
|
|
1218
|
+
subordinal: "user",
|
|
1219
|
+
address: `${event.entryId}/user`,
|
|
1220
|
+
text: clipUtf8(event.text, 2 * 1024)
|
|
1221
|
+
});
|
|
1222
|
+
} else if (event.kind === "customMessage") {
|
|
1223
|
+
facts.push({
|
|
1224
|
+
kind: "customMessage",
|
|
1225
|
+
entryId: event.entryId,
|
|
1226
|
+
subordinal: "custom-message",
|
|
1227
|
+
address: `${event.entryId}/custom-message`,
|
|
1228
|
+
customType: clipUtf8(event.customType, 256),
|
|
1229
|
+
text: clipUtf8(event.text, 4 * 1024),
|
|
1230
|
+
display: event.display,
|
|
1231
|
+
...event.details !== void 0 ? { details: event.details } : {}
|
|
1232
|
+
});
|
|
1233
|
+
} else if (event.kind === "fabricPhase") {
|
|
1234
|
+
facts.push({
|
|
1235
|
+
kind: "phase",
|
|
1236
|
+
entryId: event.entryId,
|
|
1237
|
+
subordinal: event.subordinal,
|
|
1238
|
+
address: event.address,
|
|
1239
|
+
phase: event.phase
|
|
1240
|
+
});
|
|
1241
|
+
} else if (event.kind === "fabricRun") {
|
|
1242
|
+
facts.push({
|
|
1243
|
+
kind: "fabricRun",
|
|
1244
|
+
entryId: event.entryId,
|
|
1245
|
+
subordinal: event.subordinal,
|
|
1246
|
+
address: event.address,
|
|
1247
|
+
name: clipUtf8(event.name, FABRIC_BRANCH_RUN_NAME_MAX_BYTES),
|
|
1248
|
+
...event.description !== void 0 ? { description: clipUtf8(event.description, FABRIC_BRANCH_RUN_DESCRIPTION_MAX_BYTES) } : {},
|
|
1249
|
+
outcome: event.outcome
|
|
1250
|
+
});
|
|
1251
|
+
} else if (event.kind === "fabricOperation") {
|
|
1252
|
+
facts.push({
|
|
1253
|
+
kind: "operation",
|
|
1254
|
+
entryId: event.entryId,
|
|
1255
|
+
subordinal: event.subordinal,
|
|
1256
|
+
address: event.address,
|
|
1257
|
+
ref: event.ref,
|
|
1258
|
+
...event.provider ? { provider: event.provider } : {},
|
|
1259
|
+
...event.action ? { action: event.action } : {},
|
|
1260
|
+
tool: event.tool,
|
|
1261
|
+
args: event.args,
|
|
1262
|
+
outcome: event.outcome,
|
|
1263
|
+
...event.error !== void 0 ? { error: event.error } : {},
|
|
1264
|
+
...event.result !== void 0 ? { result: event.result } : {}
|
|
1265
|
+
});
|
|
1266
|
+
} else if (event.kind === "toolResult" && event.toolName !== "bash") {
|
|
1267
|
+
const call = event.toolCallId ? calls.get(event.toolCallId) : void 0;
|
|
1268
|
+
if (!call) continue;
|
|
1269
|
+
const fact = directOperationFact(call, event.isError ? "failed" : "succeeded", event.isError ? event.text : void 0);
|
|
1270
|
+
if (fact) facts.push(fact);
|
|
1271
|
+
} else if (event.kind === "bash") {
|
|
1272
|
+
const call = event.toolCallId ? calls.get(event.toolCallId) : void 0;
|
|
1273
|
+
if (call) {
|
|
1274
|
+
const fact = directOperationFact(call, event.isError ? "failed" : "succeeded", event.error);
|
|
1275
|
+
if (fact) facts.push(fact);
|
|
1276
|
+
} else {
|
|
1277
|
+
const subordinal = "bash";
|
|
1278
|
+
facts.push({
|
|
1279
|
+
kind: "operation",
|
|
1280
|
+
entryId: event.entryId,
|
|
1281
|
+
subordinal,
|
|
1282
|
+
address: `${event.entryId}/${subordinal}`,
|
|
1283
|
+
ref: "bash",
|
|
1284
|
+
action: "bash",
|
|
1285
|
+
tool: "bash",
|
|
1286
|
+
args: { command: event.command },
|
|
1287
|
+
outcome: event.isError ? "failed" : "succeeded",
|
|
1288
|
+
...event.error ? { error: clipUtf8(event.error, 8 * 1024) } : {}
|
|
1289
|
+
});
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
return facts;
|
|
1294
|
+
};
|
|
1295
|
+
var serializedBytes = (value) => Buffer.byteLength(JSON.stringify(value), "utf8");
|
|
1296
|
+
var boundedDetails = (sourceEntries, facts, sections, request, oldLeafId) => {
|
|
1297
|
+
const sampled = sampleAddressed(facts, FABRIC_BRANCH_SUMMARY_MAX_FACTS);
|
|
1298
|
+
const details = {
|
|
1299
|
+
kind: FABRIC_BRANCH_SUMMARY_KIND,
|
|
1300
|
+
version: FABRIC_BRANCH_SUMMARY_VERSION,
|
|
1301
|
+
source: {
|
|
1302
|
+
firstEntryId: sourceEntries[0]?.id ?? "",
|
|
1303
|
+
lastEntryId: sourceEntries.at(-1)?.id ?? "",
|
|
1304
|
+
entryCount: sourceEntries.length,
|
|
1305
|
+
oldLeafId
|
|
1306
|
+
},
|
|
1307
|
+
facts: sampled.values,
|
|
1308
|
+
omittedFacts: sampled.omitted,
|
|
1309
|
+
sections,
|
|
1310
|
+
request: {
|
|
1311
|
+
text: request.text,
|
|
1312
|
+
sourceBytes: request.sourceBytes,
|
|
1313
|
+
truncated: request.truncated
|
|
1314
|
+
}
|
|
1315
|
+
};
|
|
1316
|
+
for (let index = details.facts.length - 1; serializedBytes(details) > FABRIC_BRANCH_SUMMARY_MAX_BYTES && index >= 0; index--) {
|
|
1317
|
+
const fact = details.facts[index];
|
|
1318
|
+
if (fact.kind === "operation" && fact.result !== void 0) delete fact.result;
|
|
1319
|
+
}
|
|
1320
|
+
while (serializedBytes(details) > FABRIC_BRANCH_SUMMARY_MAX_BYTES && details.facts.length > 0) {
|
|
1321
|
+
const middle = Math.floor(details.facts.length / 2);
|
|
1322
|
+
details.facts.splice(middle, 1);
|
|
1323
|
+
details.omittedFacts += 1;
|
|
1324
|
+
}
|
|
1325
|
+
return details;
|
|
1326
|
+
};
|
|
1327
|
+
var compileFabricBranchSummary = (entriesToSummarize, customInstructions, enrichers = NO_BUILTIN_ENRICHERS, oldLeafId = null) => {
|
|
1328
|
+
const instructions = decodeCompactionInstructions(customInstructions);
|
|
1329
|
+
if (!instructions.ok) return void 0;
|
|
1330
|
+
const events = normalizeEntries(entriesToSummarize);
|
|
1331
|
+
if (events.length === 0) return void 0;
|
|
1332
|
+
const projected = projectWithMetadata(events);
|
|
1333
|
+
runEnrichers(enrichers, events, projected.sections);
|
|
1334
|
+
const request = {
|
|
1335
|
+
text: instructions.requestLines.join("\n"),
|
|
1336
|
+
sourceBytes: instructions.policy.sourceBytes,
|
|
1337
|
+
truncated: instructions.policy.truncated
|
|
1338
|
+
};
|
|
1339
|
+
const sections = SECTION_HEADERS.filter(({ key }) => projected.sections[key].length > 0).map(({ header }) => header);
|
|
1340
|
+
if (request.text) sections.splice(1, 0, "[Compaction Request]");
|
|
1341
|
+
const summary = renderSummary(projected.sections, {
|
|
1342
|
+
firstEntryId: entriesToSummarize[0]?.id ?? "",
|
|
1343
|
+
lastEntryId: entriesToSummarize.at(-1)?.id ?? "",
|
|
1344
|
+
lastTimestamp: entriesToSummarize.at(-1)?.timestamp ?? "",
|
|
1345
|
+
...instructions.requestLines.length > 0 ? { requestLines: instructions.requestLines } : {},
|
|
1346
|
+
summaryKind: "branch"
|
|
1347
|
+
});
|
|
1348
|
+
return {
|
|
1349
|
+
summary,
|
|
1350
|
+
details: boundedDetails(entriesToSummarize, factsFromEvents(events), sections, request, oldLeafId)
|
|
1351
|
+
};
|
|
1352
|
+
};
|
|
1353
|
+
|
|
1354
|
+
// src/compaction/hook.ts
|
|
1355
|
+
var SUMMARY_RAW_TOKEN_BUDGET = Math.ceil(MAX_SUMMARY_BYTES / 4);
|
|
1356
|
+
var HARD_CEILING_SAFETY_RATIO = 0.9;
|
|
1357
|
+
var MAX_PRECOMPACTION_RATIO = 0.95;
|
|
1358
|
+
var OVERFLOW_WINDOW_EVIDENCE_RATIO = 0.9;
|
|
1359
|
+
var isMessageEntry2 = (entry) => entry.type === "message";
|
|
1360
|
+
var isHiddenEmptyCustom = (message) => {
|
|
1361
|
+
if (!message || typeof message !== "object") return false;
|
|
1362
|
+
const candidate = message;
|
|
1363
|
+
if (candidate.role !== "custom" || candidate.display !== false) return false;
|
|
1364
|
+
const content = candidate.content;
|
|
1365
|
+
return content === "" || Array.isArray(content) && content.length === 0;
|
|
1366
|
+
};
|
|
1367
|
+
var toolCallIdsOf = (message) => {
|
|
1368
|
+
const content = message.content;
|
|
1369
|
+
if (!Array.isArray(content)) return [];
|
|
1370
|
+
const ids = [];
|
|
1371
|
+
for (const part of content) {
|
|
1372
|
+
if (!part || typeof part !== "object" || !("type" in part) || part.type !== "toolCall") continue;
|
|
1373
|
+
const id = part.id;
|
|
1374
|
+
if (typeof id === "string") ids.push(id);
|
|
1375
|
+
}
|
|
1376
|
+
return ids;
|
|
1377
|
+
};
|
|
1378
|
+
var contextMessages = (entry) => {
|
|
1379
|
+
try {
|
|
1380
|
+
return sessionEntryToContextMessages(entry);
|
|
1381
|
+
} catch {
|
|
1382
|
+
return [];
|
|
1383
|
+
}
|
|
1384
|
+
};
|
|
1385
|
+
var findLastCompaction = (entries) => {
|
|
1386
|
+
for (let index = entries.length - 1; index >= 0; index--) {
|
|
1387
|
+
const entry = entries[index];
|
|
1388
|
+
if (entry.type === "compaction") {
|
|
1389
|
+
return { index, firstKeptEntryId: entry.firstKeptEntryId };
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
return void 0;
|
|
1393
|
+
};
|
|
1394
|
+
var collectContextEntries = (entries, startIndex) => {
|
|
1395
|
+
const contextEntries = [];
|
|
1396
|
+
for (let index = Math.max(0, startIndex); index < entries.length; index++) {
|
|
1397
|
+
const entry = entries[index];
|
|
1398
|
+
if (entry.type === "compaction") continue;
|
|
1399
|
+
if (entry.type === "custom_message" && !isPiCustomMessageEntry(entry)) continue;
|
|
1400
|
+
if (isMessageEntry2(entry) && isHiddenEmptyCustom(entry.message)) continue;
|
|
1401
|
+
const messages = contextMessages(entry);
|
|
1402
|
+
if (messages.length === 0) continue;
|
|
1403
|
+
const roles = messages.map((message) => message.role);
|
|
1404
|
+
const rawMessage = isMessageEntry2(entry) ? entry.message : void 0;
|
|
1405
|
+
contextEntries.push({
|
|
1406
|
+
entry,
|
|
1407
|
+
branchIndex: index,
|
|
1408
|
+
turnBoundary: roles.some((role) => role === "user" || role === "custom" || role === "bashExecution" || role === "branchSummary" || role === "compactionSummary"),
|
|
1409
|
+
cutPoint: roles.some((role) => role !== "toolResult"),
|
|
1410
|
+
estimatedTokens: messages.reduce((total, message) => total + estimateTokens(message), 0),
|
|
1411
|
+
...rawMessage ? { message: rawMessage } : {}
|
|
1412
|
+
});
|
|
1413
|
+
}
|
|
1414
|
+
return contextEntries;
|
|
1415
|
+
};
|
|
1416
|
+
var collectLive = (entries) => {
|
|
1417
|
+
const last = findLastCompaction(entries);
|
|
1418
|
+
if (!last) return collectContextEntries(entries, 0);
|
|
1419
|
+
if (last.firstKeptEntryId) {
|
|
1420
|
+
const keptIndex = entries.findIndex((entry) => entry.id === last.firstKeptEntryId);
|
|
1421
|
+
if (keptIndex >= 0) return collectContextEntries(entries, keptIndex);
|
|
1422
|
+
}
|
|
1423
|
+
return collectContextEntries(entries, last.index + 1);
|
|
1424
|
+
};
|
|
1425
|
+
var previousBoundaryAtOrBefore = (live, branchIndex) => {
|
|
1426
|
+
for (let index = live.length - 1; index >= 0; index--) {
|
|
1427
|
+
const item = live[index];
|
|
1428
|
+
if (item.branchIndex <= branchIndex && item.turnBoundary) return index;
|
|
1429
|
+
}
|
|
1430
|
+
return -1;
|
|
1431
|
+
};
|
|
1432
|
+
var lastBoundaryIndex = (live) => {
|
|
1433
|
+
for (let index = live.length - 1; index >= 0; index--) {
|
|
1434
|
+
if (live[index].turnBoundary) return index;
|
|
1435
|
+
}
|
|
1436
|
+
return -1;
|
|
1437
|
+
};
|
|
1438
|
+
var callResultSpans = (entries) => {
|
|
1439
|
+
const spans = /* @__PURE__ */ new Map();
|
|
1440
|
+
const record = (id, index, kind) => {
|
|
1441
|
+
if (!id) return;
|
|
1442
|
+
const span = spans.get(id) ?? {
|
|
1443
|
+
first: index,
|
|
1444
|
+
last: index,
|
|
1445
|
+
hasCall: false,
|
|
1446
|
+
hasResult: false
|
|
1447
|
+
};
|
|
1448
|
+
span.first = Math.min(span.first, index);
|
|
1449
|
+
span.last = Math.max(span.last, index);
|
|
1450
|
+
if (kind === "call") span.hasCall = true;
|
|
1451
|
+
else span.hasResult = true;
|
|
1452
|
+
spans.set(id, span);
|
|
1453
|
+
};
|
|
1454
|
+
for (let index = 0; index < entries.length; index++) {
|
|
1455
|
+
const entry = entries[index];
|
|
1456
|
+
if (!isMessageEntry2(entry)) continue;
|
|
1457
|
+
const message = entry.message;
|
|
1458
|
+
for (const id of toolCallIdsOf(message)) record(id, index, "call");
|
|
1459
|
+
if (message.role === "toolResult" && typeof message.toolCallId === "string") {
|
|
1460
|
+
record(message.toolCallId, index, "result");
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
return spans;
|
|
1464
|
+
};
|
|
1465
|
+
var spanCrosses = (span, boundaryIndex) => span.hasCall && span.hasResult && span.first < boundaryIndex && span.last >= boundaryIndex;
|
|
1466
|
+
var closureSafe = (spans, boundaryIndex) => [...spans.values()].every((span) => !spanCrosses(span, boundaryIndex));
|
|
1467
|
+
var closeCut = (branchEntries, live, candidateLiveIndex) => {
|
|
1468
|
+
const spans = callResultSpans(branchEntries);
|
|
1469
|
+
let liveIndex = candidateLiveIndex;
|
|
1470
|
+
while (liveIndex > 0) {
|
|
1471
|
+
const boundaryIndex = live[liveIndex].branchIndex;
|
|
1472
|
+
let earliestCrossing = boundaryIndex;
|
|
1473
|
+
for (const span of spans.values()) {
|
|
1474
|
+
if (spanCrosses(span, boundaryIndex)) {
|
|
1475
|
+
earliestCrossing = Math.min(earliestCrossing, span.first);
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
if (earliestCrossing === boundaryIndex) return liveIndex;
|
|
1479
|
+
const closed = previousBoundaryAtOrBefore(live, earliestCrossing);
|
|
1480
|
+
if (closed < 0 || closed >= liveIndex) return 0;
|
|
1481
|
+
liveIndex = closed;
|
|
1482
|
+
}
|
|
1483
|
+
return 0;
|
|
1484
|
+
};
|
|
1485
|
+
var rawContextTokens = (branchEntries) => buildSessionContext(branchEntries).messages.reduce(
|
|
1486
|
+
(total, message) => total + estimateTokens(message),
|
|
1487
|
+
0
|
|
1488
|
+
);
|
|
1489
|
+
var usageCheckpoints = (branchEntries) => {
|
|
1490
|
+
const lastCompaction = findLastCompaction(branchEntries);
|
|
1491
|
+
const startIndex = lastCompaction ? lastCompaction.index + 1 : 0;
|
|
1492
|
+
let rawTokens = lastCompaction ? rawContextTokens(branchEntries.slice(0, lastCompaction.index + 1)) : 0;
|
|
1493
|
+
const checkpoints = [];
|
|
1494
|
+
for (let index = startIndex; index < branchEntries.length; index++) {
|
|
1495
|
+
for (const message of contextMessages(branchEntries[index])) {
|
|
1496
|
+
rawTokens += estimateTokens(message);
|
|
1497
|
+
if (message.role !== "assistant") continue;
|
|
1498
|
+
const contextTokens = calculateContextTokens(message.usage);
|
|
1499
|
+
if (Number.isFinite(contextTokens) && contextTokens > 0) {
|
|
1500
|
+
checkpoints.push({ rawTokens, contextTokens });
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
return checkpoints;
|
|
1505
|
+
};
|
|
1506
|
+
var tokenCalibration = (branchEntries, tokensBefore, rawTokensBefore) => {
|
|
1507
|
+
const minimumDelta = Math.max(4096, Math.floor(rawTokensBefore * 0.1));
|
|
1508
|
+
const checkpoints = usageCheckpoints(branchEntries).filter(
|
|
1509
|
+
(checkpoint) => checkpoint.rawTokens < rawTokensBefore && checkpoint.contextTokens <= tokensBefore
|
|
1510
|
+
);
|
|
1511
|
+
const slopes = checkpoints.flatMap((checkpoint) => {
|
|
1512
|
+
const rawDelta = rawTokensBefore - checkpoint.rawTokens;
|
|
1513
|
+
const contextDelta = tokensBefore - checkpoint.contextTokens;
|
|
1514
|
+
return rawDelta >= minimumDelta && contextDelta >= 0 ? [contextDelta / rawDelta] : [];
|
|
1515
|
+
}).filter((slope) => Number.isFinite(slope) && slope >= 0);
|
|
1516
|
+
if (slopes.length === 0) {
|
|
1517
|
+
return {
|
|
1518
|
+
tokenScale: 1,
|
|
1519
|
+
fixedOverheadTokens: Math.max(0, tokensBefore - rawTokensBefore)
|
|
1520
|
+
};
|
|
1521
|
+
}
|
|
1522
|
+
const tokenScale = Math.max(1, ...slopes);
|
|
1523
|
+
const fixedOverheadTokens = Math.max(
|
|
1524
|
+
0,
|
|
1525
|
+
tokensBefore - tokenScale * rawTokensBefore,
|
|
1526
|
+
...checkpoints.map(
|
|
1527
|
+
(checkpoint) => checkpoint.contextTokens - tokenScale * checkpoint.rawTokens
|
|
1528
|
+
)
|
|
1529
|
+
);
|
|
1530
|
+
return { tokenScale, fixedOverheadTokens };
|
|
1531
|
+
};
|
|
1532
|
+
var continuityCutPlan = (branchEntries, tokensBefore, budget) => {
|
|
1533
|
+
if (!Number.isFinite(budget.contextWindow) || budget.contextWindow <= 0) return void 0;
|
|
1534
|
+
const contextWindow = Math.floor(budget.contextWindow);
|
|
1535
|
+
const reserveTokens = Math.max(0, Math.floor(budget.reserveTokens));
|
|
1536
|
+
const keepRecentTokens = Math.max(0, Math.floor(budget.keepRecentTokens));
|
|
1537
|
+
const targetContextRatio = Math.max(0.25, Math.min(0.85, budget.targetContextRatio));
|
|
1538
|
+
const rawTokensBefore = rawContextTokens(branchEntries);
|
|
1539
|
+
const { tokenScale, fixedOverheadTokens } = tokenCalibration(
|
|
1540
|
+
branchEntries,
|
|
1541
|
+
tokensBefore,
|
|
1542
|
+
rawTokensBefore
|
|
1543
|
+
);
|
|
1544
|
+
const continuityTargetTokens = Math.max(1, Math.ceil(
|
|
1545
|
+
fixedOverheadTokens + (keepRecentTokens + SUMMARY_RAW_TOKEN_BUDGET) * tokenScale
|
|
1546
|
+
));
|
|
1547
|
+
const occupancyCeilingTokens = Math.max(1, Math.floor(contextWindow * targetContextRatio));
|
|
1548
|
+
const hardCeiling = Math.max(1, contextWindow - reserveTokens);
|
|
1549
|
+
const safeCeilingTokens = Math.max(1, Math.floor(hardCeiling * HARD_CEILING_SAFETY_RATIO));
|
|
1550
|
+
const reductionCeilingTokens = Math.max(1, Math.floor(tokensBefore * MAX_PRECOMPACTION_RATIO));
|
|
1551
|
+
const constraints = [
|
|
1552
|
+
{ binding: "continuity", tokens: continuityTargetTokens },
|
|
1553
|
+
{ binding: "occupancy", tokens: occupancyCeilingTokens },
|
|
1554
|
+
{ binding: "reserve", tokens: safeCeilingTokens },
|
|
1555
|
+
{ binding: "reduction", tokens: reductionCeilingTokens }
|
|
1556
|
+
];
|
|
1557
|
+
const targetContextTokens = Math.min(...constraints.map(({ tokens }) => tokens));
|
|
1558
|
+
const bindingConstraint = constraints.find(
|
|
1559
|
+
({ tokens }) => tokens === targetContextTokens
|
|
1560
|
+
).binding;
|
|
1561
|
+
const rawPostBudget = Math.max(
|
|
1562
|
+
0,
|
|
1563
|
+
Math.floor((targetContextTokens - fixedOverheadTokens) / tokenScale)
|
|
1564
|
+
);
|
|
1565
|
+
return {
|
|
1566
|
+
contextWindow,
|
|
1567
|
+
targetContextRatio,
|
|
1568
|
+
targetContextTokens,
|
|
1569
|
+
reserveTokens,
|
|
1570
|
+
keepRecentTokens,
|
|
1571
|
+
rawTokensBefore,
|
|
1572
|
+
tokenScale,
|
|
1573
|
+
fixedOverheadTokens,
|
|
1574
|
+
continuityTargetTokens,
|
|
1575
|
+
occupancyCeilingTokens,
|
|
1576
|
+
safeCeilingTokens,
|
|
1577
|
+
reductionCeilingTokens,
|
|
1578
|
+
rawTailTokenBudget: Math.max(0, rawPostBudget - SUMMARY_RAW_TOKEN_BUDGET),
|
|
1579
|
+
bindingConstraint
|
|
1580
|
+
};
|
|
1581
|
+
};
|
|
1582
|
+
var boundary = (summarized, firstKeptEntryId, budget) => {
|
|
1583
|
+
if (summarized.length === 0) return { ok: false, reason: "empty" };
|
|
1584
|
+
const first = summarized[0];
|
|
1585
|
+
const last = summarized.at(-1);
|
|
1586
|
+
return {
|
|
1587
|
+
ok: true,
|
|
1588
|
+
summarized,
|
|
1589
|
+
firstKeptEntryId,
|
|
1590
|
+
firstSummarizedEntryId: first.id,
|
|
1591
|
+
lastSummarizedEntryId: last.id,
|
|
1592
|
+
lastTimestamp: last.timestamp,
|
|
1593
|
+
...budget ? { budget } : {}
|
|
1594
|
+
};
|
|
1595
|
+
};
|
|
1596
|
+
var computeContinuityCut = (branchEntries, live, plan) => {
|
|
1597
|
+
const suffixTokens = new Array(live.length + 1).fill(0);
|
|
1598
|
+
for (let index = live.length - 1; index >= 0; index--) {
|
|
1599
|
+
suffixTokens[index] = suffixTokens[index + 1] + live[index].estimatedTokens;
|
|
1600
|
+
}
|
|
1601
|
+
const spans = callResultSpans(branchEntries);
|
|
1602
|
+
const previousCompactionIndex = findLastCompaction(branchEntries)?.index ?? -1;
|
|
1603
|
+
let cutIndex = live.length;
|
|
1604
|
+
for (let index = 1; index < live.length; index++) {
|
|
1605
|
+
const item = live[index];
|
|
1606
|
+
if (item.branchIndex <= previousCompactionIndex) continue;
|
|
1607
|
+
if (!item.cutPoint || suffixTokens[index] > plan.rawTailTokenBudget) continue;
|
|
1608
|
+
if (!closureSafe(spans, item.branchIndex)) continue;
|
|
1609
|
+
cutIndex = index;
|
|
1610
|
+
break;
|
|
1611
|
+
}
|
|
1612
|
+
const retainedRawTokens = suffixTokens[cutIndex] ?? 0;
|
|
1613
|
+
const details = {
|
|
1614
|
+
strategy: "continuity",
|
|
1615
|
+
contextWindow: plan.contextWindow,
|
|
1616
|
+
targetContextRatio: plan.targetContextRatio,
|
|
1617
|
+
targetContextTokens: plan.targetContextTokens,
|
|
1618
|
+
reserveTokens: plan.reserveTokens,
|
|
1619
|
+
keepRecentTokens: plan.keepRecentTokens,
|
|
1620
|
+
rawTokensBefore: plan.rawTokensBefore,
|
|
1621
|
+
tokenScale: plan.tokenScale,
|
|
1622
|
+
fixedOverheadTokens: plan.fixedOverheadTokens,
|
|
1623
|
+
retainedRawTokens,
|
|
1624
|
+
continuityTargetTokens: plan.continuityTargetTokens,
|
|
1625
|
+
occupancyCeilingTokens: plan.occupancyCeilingTokens,
|
|
1626
|
+
safeCeilingTokens: plan.safeCeilingTokens,
|
|
1627
|
+
reductionCeilingTokens: plan.reductionCeilingTokens,
|
|
1628
|
+
rawTailTokenBudget: plan.rawTailTokenBudget,
|
|
1629
|
+
bindingConstraint: plan.bindingConstraint
|
|
1630
|
+
};
|
|
1631
|
+
if (cutIndex >= live.length) {
|
|
1632
|
+
return boundary(live.map((item) => item.entry), "", details);
|
|
1633
|
+
}
|
|
1634
|
+
return boundary(
|
|
1635
|
+
live.slice(0, cutIndex).map((item) => item.entry),
|
|
1636
|
+
live[cutIndex].entry.id,
|
|
1637
|
+
details
|
|
1638
|
+
);
|
|
1639
|
+
};
|
|
1640
|
+
var computeCut = (branchEntries, options) => {
|
|
1641
|
+
const live = collectLive(branchEntries);
|
|
1642
|
+
if (live.length === 0) return { ok: false, reason: "empty" };
|
|
1643
|
+
if (options) {
|
|
1644
|
+
const plan = continuityCutPlan(branchEntries, options.tokensBefore, options.budget);
|
|
1645
|
+
if (plan) return computeContinuityCut(branchEntries, live, plan);
|
|
1646
|
+
}
|
|
1647
|
+
const lastBoundary = lastBoundaryIndex(live);
|
|
1648
|
+
if (lastBoundary <= 0) return boundary(live.map((item) => item.entry), "");
|
|
1649
|
+
const closed = closeCut(branchEntries, live, lastBoundary);
|
|
1650
|
+
const previousCompactionIndex = findLastCompaction(branchEntries)?.index ?? -1;
|
|
1651
|
+
if (closed <= 0 || live[closed].branchIndex <= previousCompactionIndex) {
|
|
1652
|
+
return boundary(live.map((item) => item.entry), "");
|
|
1653
|
+
}
|
|
1654
|
+
return boundary(
|
|
1655
|
+
live.slice(0, closed).map((item) => item.entry),
|
|
1656
|
+
live[closed].entry.id
|
|
1657
|
+
);
|
|
1658
|
+
};
|
|
1659
|
+
var isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1660
|
+
var isEntryRange = (value) => isRecord(value) && typeof value.first === "string" && typeof value.last === "string";
|
|
1661
|
+
var isStringArray = (value) => Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
1662
|
+
var isFabricV1Details = (value) => isStringArray(value.sections) && isEntryRange(value.summarizedEntryRange) && typeof value.sourceEntryCount === "number" && Number.isFinite(value.sourceEntryCount) && typeof value.firstKeptEntryId === "string" && typeof value.timestamp === "string";
|
|
1663
|
+
var hasFiniteNumbers = (value, keys) => keys.every((key) => typeof value[key] === "number" && Number.isFinite(value[key]));
|
|
1664
|
+
var isCompactionBudgetDetails = (value) => {
|
|
1665
|
+
if (!isRecord(value) || value.strategy !== "adaptive" && value.strategy !== "continuity") {
|
|
1666
|
+
return false;
|
|
1667
|
+
}
|
|
1668
|
+
if (!hasFiniteNumbers(value, [
|
|
1669
|
+
"contextWindow",
|
|
1670
|
+
"targetContextRatio",
|
|
1671
|
+
"targetContextTokens",
|
|
1672
|
+
"reserveTokens",
|
|
1673
|
+
"keepRecentTokens",
|
|
1674
|
+
"rawTokensBefore",
|
|
1675
|
+
"tokenScale",
|
|
1676
|
+
"fixedOverheadTokens",
|
|
1677
|
+
"retainedRawTokens",
|
|
1678
|
+
"projectedTokensAfter"
|
|
1679
|
+
])) {
|
|
1680
|
+
return false;
|
|
1681
|
+
}
|
|
1682
|
+
if (value.strategy === "adaptive") return true;
|
|
1683
|
+
return hasFiniteNumbers(value, [
|
|
1684
|
+
"continuityTargetTokens",
|
|
1685
|
+
"occupancyCeilingTokens",
|
|
1686
|
+
"safeCeilingTokens",
|
|
1687
|
+
"reductionCeilingTokens",
|
|
1688
|
+
"rawTailTokenBudget"
|
|
1689
|
+
]) && (value.bindingConstraint === "continuity" || value.bindingConstraint === "occupancy" || value.bindingConstraint === "reserve" || value.bindingConstraint === "reduction");
|
|
1690
|
+
};
|
|
1691
|
+
var isFabricV2Details = (value) => {
|
|
1692
|
+
if (!isStringArray(value.sections) || !isRecord(value.coverage) || !isRecord(value.counts)) return false;
|
|
1693
|
+
if (!isRecord(value.omittedCounts) || !isRecord(value.instructionPolicy) || !isRecord(value.stableAddresses)) {
|
|
1694
|
+
return false;
|
|
1695
|
+
}
|
|
1696
|
+
const instructionModes = /* @__PURE__ */ new Set(["none", "plain", "typed-v1", "malformed-typed-prefix"]);
|
|
1697
|
+
return isEntryRange(value.coverage.cumulativeSourceRange) && isEntryRange(value.coverage.liveCutRange) && hasFiniteNumbers(value.counts, [
|
|
1698
|
+
"branchEntries",
|
|
1699
|
+
"cumulativeSourceEntries",
|
|
1700
|
+
"sourceEvents",
|
|
1701
|
+
"liveCutEntries",
|
|
1702
|
+
"priorFabricV1",
|
|
1703
|
+
"priorFabricV2"
|
|
1704
|
+
]) && hasFiniteNumbers(value.omittedCounts, [
|
|
1705
|
+
"goal",
|
|
1706
|
+
"files",
|
|
1707
|
+
"outstanding",
|
|
1708
|
+
"earlierTurns",
|
|
1709
|
+
"transcript",
|
|
1710
|
+
"preserve"
|
|
1711
|
+
]) && (value.omittedCounts.activity === void 0 || typeof value.omittedCounts.activity === "number" && Number.isFinite(value.omittedCounts.activity)) && (value.omittedCounts.commits === void 0 || typeof value.omittedCounts.commits === "number" && Number.isFinite(value.omittedCounts.commits)) && (value.omittedCounts.thinking === void 0 || typeof value.omittedCounts.thinking === "number" && Number.isFinite(value.omittedCounts.thinking)) && typeof value.instructionPolicy.mode === "string" && instructionModes.has(value.instructionPolicy.mode) && typeof value.instructionPolicy.canonicalized === "boolean" && typeof value.instructionPolicy.truncated === "boolean" && hasFiniteNumbers(value.instructionPolicy, [
|
|
1712
|
+
"sourceBytes",
|
|
1713
|
+
"preserveCount",
|
|
1714
|
+
"omittedPreserveCount"
|
|
1715
|
+
]) && typeof value.stableAddresses.firstKeptEntryId === "string" && isEntryRange(value.stableAddresses.cumulativeSourceRange) && value.stableAddresses.recall === "session-entry-id-range" && (value.budget === void 0 || isCompactionBudgetDetails(value.budget)) && typeof value.timestamp === "string";
|
|
1716
|
+
};
|
|
1717
|
+
var fabricCompactionVersion = (details) => {
|
|
1718
|
+
if (!isRecord(details) || details.compactor !== "fabric") return void 0;
|
|
1719
|
+
if (details.version === 1 && isFabricV1Details(details)) return 1;
|
|
1720
|
+
if (details.version === 2 && isFabricV2Details(details)) return 2;
|
|
1721
|
+
return void 0;
|
|
1722
|
+
};
|
|
1723
|
+
var cumulativeSource = (branchEntries, firstKeptEntryId) => {
|
|
1724
|
+
const boundaryIndex = firstKeptEntryId ? branchEntries.findIndex((entry) => entry.id === firstKeptEntryId) : branchEntries.length;
|
|
1725
|
+
const prefix = branchEntries.slice(0, boundaryIndex >= 0 ? boundaryIndex : branchEntries.length);
|
|
1726
|
+
const events = normalizeEntries(prefix);
|
|
1727
|
+
const contentEntryIds = new Set(events.map((event) => event.sourceEntryId));
|
|
1728
|
+
const entries = prefix.filter((entry) => contentEntryIds.has(entry.id));
|
|
1729
|
+
return {
|
|
1730
|
+
entries,
|
|
1731
|
+
prefixEntries: prefix,
|
|
1732
|
+
events,
|
|
1733
|
+
range: {
|
|
1734
|
+
first: entries[0]?.id ?? "",
|
|
1735
|
+
last: entries.at(-1)?.id ?? ""
|
|
1736
|
+
},
|
|
1737
|
+
timestamp: entries.at(-1)?.timestamp ?? ""
|
|
1738
|
+
};
|
|
1739
|
+
};
|
|
1740
|
+
var priorFabricVersions = (entries) => {
|
|
1741
|
+
let v1 = 0;
|
|
1742
|
+
let v2 = 0;
|
|
1743
|
+
for (const entry of entries) {
|
|
1744
|
+
if (entry.type !== "compaction") continue;
|
|
1745
|
+
const version = fabricCompactionVersion(entry.details);
|
|
1746
|
+
if (version === 1) v1 += 1;
|
|
1747
|
+
if (version === 2) v2 += 1;
|
|
1748
|
+
}
|
|
1749
|
+
return { v1, v2 };
|
|
1750
|
+
};
|
|
1751
|
+
var compileFabricSummary = (branchEntries, tokensBefore, enrichers = NO_BUILTIN_ENRICHERS, customInstructions, budget) => {
|
|
1752
|
+
const instructions = decodeCompactionInstructions(customInstructions);
|
|
1753
|
+
if (!instructions.ok) {
|
|
1754
|
+
return {
|
|
1755
|
+
cancel: true,
|
|
1756
|
+
reason: `fabric: ${instructions.error.code}: ${instructions.error.message}`,
|
|
1757
|
+
instructionError: instructions.error
|
|
1758
|
+
};
|
|
1759
|
+
}
|
|
1760
|
+
const cut = computeCut(
|
|
1761
|
+
branchEntries,
|
|
1762
|
+
budget ? { tokensBefore, budget } : void 0
|
|
1763
|
+
);
|
|
1764
|
+
if (!cut.ok) return { cancel: true, reason: "fabric: nothing to compact" };
|
|
1765
|
+
const source = cumulativeSource(branchEntries, cut.firstKeptEntryId);
|
|
1766
|
+
if (source.events.length === 0) return { cancel: true, reason: "fabric: no raw cumulative source" };
|
|
1767
|
+
const projected = projectWithMetadata(source.events);
|
|
1768
|
+
const sections = projected.sections;
|
|
1769
|
+
runEnrichers(enrichers, source.events, sections);
|
|
1770
|
+
const summary = renderSummary(sections, {
|
|
1771
|
+
firstEntryId: source.range.first,
|
|
1772
|
+
lastEntryId: source.range.last,
|
|
1773
|
+
lastTimestamp: source.timestamp,
|
|
1774
|
+
requestLines: instructions.requestLines
|
|
1775
|
+
});
|
|
1776
|
+
const projectedTokensAfter = cut.budget ? Math.ceil(
|
|
1777
|
+
cut.budget.fixedOverheadTokens + (cut.budget.retainedRawTokens + Math.ceil(summary.length / 4)) * cut.budget.tokenScale
|
|
1778
|
+
) : void 0;
|
|
1779
|
+
const budgetDetails = cut.budget && projectedTokensAfter !== void 0 ? { ...cut.budget, projectedTokensAfter } : void 0;
|
|
1780
|
+
if (budgetDetails && budgetDetails.projectedTokensAfter > budgetDetails.targetContextTokens) {
|
|
1781
|
+
return {
|
|
1782
|
+
cancel: true,
|
|
1783
|
+
reason: "fabric: no deterministic summary fits the continuity context target"
|
|
1784
|
+
};
|
|
1785
|
+
}
|
|
1786
|
+
const versions = priorFabricVersions(branchEntries);
|
|
1787
|
+
const sectionHeaders = SECTION_HEADERS2.filter(({ key }) => sections[key].length > 0).map(({ header }) => header);
|
|
1788
|
+
if (instructions.requestLines.length > 0) sectionHeaders.splice(1, 0, "[Compaction Request]");
|
|
1789
|
+
const details = {
|
|
1790
|
+
compactor: "fabric",
|
|
1791
|
+
version: 2,
|
|
1792
|
+
sections: sectionHeaders,
|
|
1793
|
+
coverage: {
|
|
1794
|
+
cumulativeSourceRange: source.range,
|
|
1795
|
+
liveCutRange: {
|
|
1796
|
+
first: cut.firstSummarizedEntryId,
|
|
1797
|
+
last: cut.lastSummarizedEntryId
|
|
1798
|
+
}
|
|
1799
|
+
},
|
|
1800
|
+
counts: {
|
|
1801
|
+
branchEntries: branchEntries.length,
|
|
1802
|
+
cumulativeSourceEntries: source.entries.length,
|
|
1803
|
+
sourceEvents: source.events.length,
|
|
1804
|
+
liveCutEntries: cut.summarized.length,
|
|
1805
|
+
priorFabricV1: versions.v1,
|
|
1806
|
+
priorFabricV2: versions.v2
|
|
1807
|
+
},
|
|
1808
|
+
omittedCounts: {
|
|
1809
|
+
...projected.omittedCounts,
|
|
1810
|
+
preserve: instructions.policy.omittedPreserveCount,
|
|
1811
|
+
// Thinking parts never survive normalization into a rendered summary;
|
|
1812
|
+
// the structural count keeps that erasure auditable against the raw
|
|
1813
|
+
// prefix instead of letting deliberation vanish untracked.
|
|
1814
|
+
thinking: countErasedThinkingBlocks(source.prefixEntries)
|
|
1815
|
+
},
|
|
1816
|
+
instructionPolicy: instructions.policy,
|
|
1817
|
+
stableAddresses: {
|
|
1818
|
+
firstKeptEntryId: cut.firstKeptEntryId,
|
|
1819
|
+
cumulativeSourceRange: source.range,
|
|
1820
|
+
recall: "session-entry-id-range"
|
|
1821
|
+
},
|
|
1822
|
+
...budgetDetails ? { budget: budgetDetails } : {},
|
|
1823
|
+
timestamp: source.timestamp
|
|
1824
|
+
};
|
|
1825
|
+
return {
|
|
1826
|
+
compaction: {
|
|
1827
|
+
summary,
|
|
1828
|
+
firstKeptEntryId: cut.firstKeptEntryId,
|
|
1829
|
+
tokensBefore,
|
|
1830
|
+
details
|
|
1831
|
+
}
|
|
1832
|
+
};
|
|
1833
|
+
};
|
|
1834
|
+
var SECTION_HEADERS2 = [
|
|
1835
|
+
{ key: "goal", header: "[Session Goal]" },
|
|
1836
|
+
{ key: "files", header: "[Files And Changes]" },
|
|
1837
|
+
{ key: "activity", header: "[Fabric Activity]" },
|
|
1838
|
+
{ key: "outstanding", header: "[Outstanding Context]" },
|
|
1839
|
+
{ key: "earlierTurns", header: "[Earlier Turns]" },
|
|
1840
|
+
{ key: "status", header: "[Current Status]" }
|
|
1841
|
+
];
|
|
1842
|
+
var notifyInstructionError = (context, error) => {
|
|
1843
|
+
if (!context?.hasUI) return;
|
|
1844
|
+
context.ui.notify(clipUtf8(`Fabric compaction rejected: ${error.code}: ${error.message}`, 512), "error");
|
|
1845
|
+
};
|
|
1846
|
+
var registerCompactionHook = (pi, options) => {
|
|
1847
|
+
pi.on("session_before_compact", (event, context) => {
|
|
1848
|
+
if (event.customInstructions === "__pi_vcc__") return;
|
|
1849
|
+
const { preparation, branchEntries } = event;
|
|
1850
|
+
const contextWindow = context?.model?.contextWindow;
|
|
1851
|
+
const modelKey = modelCompactionKey(context?.model);
|
|
1852
|
+
const thresholdTokens = modelKey === void 0 ? void 0 : options.getThresholdTokens?.(modelKey);
|
|
1853
|
+
if (event.reason === "threshold" && typeof thresholdTokens === "number" && preparation.tokensBefore < thresholdTokens) {
|
|
1854
|
+
return { cancel: true };
|
|
1855
|
+
}
|
|
1856
|
+
const threshold = modelKey === void 0 || typeof thresholdTokens === "number" ? void 0 : options.getThresholdContextRatio?.(modelKey);
|
|
1857
|
+
if (event.reason === "threshold" && typeof threshold === "number" && typeof contextWindow === "number" && preparation.tokensBefore / contextWindow < threshold) {
|
|
1858
|
+
return { cancel: true };
|
|
1859
|
+
}
|
|
1860
|
+
if (options.getEngine() !== "fabric") return;
|
|
1861
|
+
const targetContextRatio = options.getTargetContextRatio?.();
|
|
1862
|
+
const settings = preparation.settings ?? DEFAULT_COMPACTION_SETTINGS;
|
|
1863
|
+
const tokensBefore = preparation.tokensBefore;
|
|
1864
|
+
const evidenceWindow = event.reason === "overflow" && typeof tokensBefore === "number" && Number.isFinite(tokensBefore) && tokensBefore > 0 ? Math.max(1, Math.floor(tokensBefore * OVERFLOW_WINDOW_EVIDENCE_RATIO)) : void 0;
|
|
1865
|
+
const advertisedWindow = typeof contextWindow === "number" && Number.isFinite(contextWindow) && contextWindow > 0 ? contextWindow : void 0;
|
|
1866
|
+
const effectiveWindow = evidenceWindow === void 0 ? advertisedWindow : advertisedWindow === void 0 ? evidenceWindow : Math.min(advertisedWindow, evidenceWindow);
|
|
1867
|
+
const budget = effectiveWindow !== void 0 && typeof targetContextRatio === "number" && Number.isFinite(targetContextRatio) ? {
|
|
1868
|
+
contextWindow: effectiveWindow,
|
|
1869
|
+
targetContextRatio,
|
|
1870
|
+
reserveTokens: settings.reserveTokens,
|
|
1871
|
+
keepRecentTokens: settings.keepRecentTokens
|
|
1872
|
+
} : void 0;
|
|
1873
|
+
const result = compileFabricSummary(
|
|
1874
|
+
branchEntries ?? [],
|
|
1875
|
+
preparation.tokensBefore,
|
|
1876
|
+
options.enrichers,
|
|
1877
|
+
event.customInstructions,
|
|
1878
|
+
budget
|
|
1879
|
+
);
|
|
1880
|
+
if ("cancel" in result) {
|
|
1881
|
+
if (result.instructionError) {
|
|
1882
|
+
notifyInstructionError(context, result.instructionError);
|
|
1883
|
+
return { cancel: true };
|
|
1884
|
+
}
|
|
1885
|
+
if (event._piVccOverriding) {
|
|
1886
|
+
return;
|
|
1887
|
+
}
|
|
1888
|
+
return { cancel: true };
|
|
1889
|
+
}
|
|
1890
|
+
event._fabricCompaction = true;
|
|
1891
|
+
return { compaction: result.compaction };
|
|
1892
|
+
});
|
|
1893
|
+
pi.on("session_before_tree", (event, context) => {
|
|
1894
|
+
if (options.getEngine() !== "fabric") return;
|
|
1895
|
+
const { preparation } = event;
|
|
1896
|
+
if (!preparation.userWantsSummary) return;
|
|
1897
|
+
if (preparation.replaceInstructions === true) return;
|
|
1898
|
+
const instructions = decodeCompactionInstructions(preparation.customInstructions);
|
|
1899
|
+
if (!instructions.ok) {
|
|
1900
|
+
notifyInstructionError(context, instructions.error);
|
|
1901
|
+
return { cancel: true };
|
|
1902
|
+
}
|
|
1903
|
+
const compiled = compileFabricBranchSummary(
|
|
1904
|
+
preparation.entriesToSummarize,
|
|
1905
|
+
preparation.customInstructions,
|
|
1906
|
+
options.enrichers,
|
|
1907
|
+
preparation.oldLeafId
|
|
1908
|
+
);
|
|
1909
|
+
if (!compiled) return;
|
|
1910
|
+
return { summary: compiled };
|
|
1911
|
+
});
|
|
1912
|
+
};
|
|
1913
|
+
|
|
1914
|
+
export {
|
|
1915
|
+
compactAtConfiguredThreshold,
|
|
1916
|
+
normalizeRunDisplay,
|
|
1917
|
+
fabricExecTitleHintCached,
|
|
1918
|
+
rawContextTokens,
|
|
1919
|
+
computeCut,
|
|
1920
|
+
fabricCompactionVersion,
|
|
1921
|
+
compileFabricSummary,
|
|
1922
|
+
registerCompactionHook
|
|
1923
|
+
};
|
|
1924
|
+
//# sourceMappingURL=chunk-U6CTHPZC.js.map
|