omp-fabric 0.85.0
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 +170 -0
- package/THIRD_PARTY_NOTICES.md +33 -0
- package/dist/activity/store.d.ts +32 -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/manager.d.ts +175 -0
- package/dist/actors/manager.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/types.d.ts +211 -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 +127 -0
- package/dist/agents/compact-control.js.map +7 -0
- package/dist/agents/constants.d.ts +5 -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.d.ts +19 -0
- package/dist/agents/handoff.d.ts.map +1 -0
- package/dist/agents/manager.d.ts +68 -0
- package/dist/agents/manager.d.ts.map +1 -0
- package/dist/agents/omp-binary.d.ts +7 -0
- package/dist/agents/omp-binary.d.ts.map +1 -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/session-export.d.ts +9 -0
- package/dist/agents/session-export.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 +29 -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 +251 -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/async-settlement.d.ts +4 -0
- package/dist/async-settlement.d.ts.map +1 -0
- package/dist/audit/details.d.ts +82 -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 +95 -0
- package/dist/audit/trace.d.ts.map +1 -0
- package/dist/capture/catalog.d.ts +29 -0
- package/dist/capture/catalog.d.ts.map +1 -0
- package/dist/capture/interceptor.d.ts +21 -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-2GQC324T.js +5001 -0
- package/dist/chunks/chunk-2GQC324T.js.map +7 -0
- package/dist/chunks/chunk-2KEWFW56.js +1229 -0
- package/dist/chunks/chunk-2KEWFW56.js.map +7 -0
- package/dist/chunks/chunk-3J7BKUNG.js +354 -0
- package/dist/chunks/chunk-3J7BKUNG.js.map +7 -0
- package/dist/chunks/chunk-4A4MVZQW.js +253 -0
- package/dist/chunks/chunk-4A4MVZQW.js.map +7 -0
- package/dist/chunks/chunk-4HQDSTHN.js +221 -0
- package/dist/chunks/chunk-4HQDSTHN.js.map +7 -0
- package/dist/chunks/chunk-4LEDA76O.js +688 -0
- package/dist/chunks/chunk-4LEDA76O.js.map +7 -0
- package/dist/chunks/chunk-5GTPD4BA.js +1318 -0
- package/dist/chunks/chunk-5GTPD4BA.js.map +7 -0
- package/dist/chunks/chunk-5IWFSDU5.js +87 -0
- package/dist/chunks/chunk-5IWFSDU5.js.map +7 -0
- package/dist/chunks/chunk-6N4XGAZY.js +21 -0
- package/dist/chunks/chunk-6N4XGAZY.js.map +7 -0
- package/dist/chunks/chunk-6QBPSZJ5.js +647 -0
- package/dist/chunks/chunk-6QBPSZJ5.js.map +7 -0
- package/dist/chunks/chunk-6X6WUU2K.js +73 -0
- package/dist/chunks/chunk-6X6WUU2K.js.map +7 -0
- package/dist/chunks/chunk-7363CD5A.js +38 -0
- package/dist/chunks/chunk-7363CD5A.js.map +7 -0
- package/dist/chunks/chunk-77FQHHZD.js +231 -0
- package/dist/chunks/chunk-77FQHHZD.js.map +7 -0
- package/dist/chunks/chunk-7BIA5BJN.js +112 -0
- package/dist/chunks/chunk-7BIA5BJN.js.map +7 -0
- package/dist/chunks/chunk-7BOAOKWH.js +64 -0
- package/dist/chunks/chunk-7BOAOKWH.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-7VIQNUPS.js +17 -0
- package/dist/chunks/chunk-7VIQNUPS.js.map +7 -0
- package/dist/chunks/chunk-CT2AJ2UI.js +225 -0
- package/dist/chunks/chunk-CT2AJ2UI.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-ED3BRM6P.js +17 -0
- package/dist/chunks/chunk-ED3BRM6P.js.map +7 -0
- package/dist/chunks/chunk-G2IBGGBM.js +42 -0
- package/dist/chunks/chunk-G2IBGGBM.js.map +7 -0
- package/dist/chunks/chunk-GKOFZ76R.js +1596 -0
- package/dist/chunks/chunk-GKOFZ76R.js.map +7 -0
- package/dist/chunks/chunk-HDJBUXDX.js +1102 -0
- package/dist/chunks/chunk-HDJBUXDX.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-JHKOG5GS.js +187 -0
- package/dist/chunks/chunk-JHKOG5GS.js.map +7 -0
- package/dist/chunks/chunk-JP4LIZFT.js +1334 -0
- package/dist/chunks/chunk-JP4LIZFT.js.map +7 -0
- package/dist/chunks/chunk-JSBTB3P6.js +127 -0
- package/dist/chunks/chunk-JSBTB3P6.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-KIH3KLZU.js +95 -0
- package/dist/chunks/chunk-KIH3KLZU.js.map +7 -0
- package/dist/chunks/chunk-KIREBD2V.js +2208 -0
- package/dist/chunks/chunk-KIREBD2V.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-NCPJZXLM.js +57 -0
- package/dist/chunks/chunk-NCPJZXLM.js.map +7 -0
- package/dist/chunks/chunk-OJZNMROB.js +195 -0
- package/dist/chunks/chunk-OJZNMROB.js.map +7 -0
- package/dist/chunks/chunk-OPTP4PSE.js +469 -0
- package/dist/chunks/chunk-OPTP4PSE.js.map +7 -0
- package/dist/chunks/chunk-QPXSCMTG.js +24 -0
- package/dist/chunks/chunk-QPXSCMTG.js.map +7 -0
- package/dist/chunks/chunk-ROKMBLGN.js +1265 -0
- package/dist/chunks/chunk-ROKMBLGN.js.map +7 -0
- package/dist/chunks/chunk-SXMWV447.js +2445 -0
- package/dist/chunks/chunk-SXMWV447.js.map +7 -0
- package/dist/chunks/chunk-T5ZA5YRU.js +786 -0
- package/dist/chunks/chunk-T5ZA5YRU.js.map +7 -0
- package/dist/chunks/chunk-T6OAX4FO.js +1835 -0
- package/dist/chunks/chunk-T6OAX4FO.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-UOSJZXJV.js +142 -0
- package/dist/chunks/chunk-UOSJZXJV.js.map +7 -0
- package/dist/chunks/chunk-UPCARIJP.js +6627 -0
- package/dist/chunks/chunk-UPCARIJP.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-XU5Z4JCQ.js +297 -0
- package/dist/chunks/chunk-XU5Z4JCQ.js.map +7 -0
- package/dist/chunks/chunk-YWEXP724.js +427 -0
- package/dist/chunks/chunk-YWEXP724.js.map +7 -0
- package/dist/chunks/chunk-YZZIKJX6.js +60 -0
- package/dist/chunks/chunk-YZZIKJX6.js.map +7 -0
- package/dist/chunks/chunk-ZNAJDPT7.js +2203 -0
- package/dist/chunks/chunk-ZNAJDPT7.js.map +7 -0
- package/dist/chunks/chunk-ZTM45GH5.js +163 -0
- package/dist/chunks/chunk-ZTM45GH5.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 +98 -0
- package/dist/compaction/hook.d.ts.map +1 -0
- package/dist/compaction/hook.js +19 -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-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 +269 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/core/action-registry.d.ts +159 -0
- package/dist/core/action-registry.d.ts.map +1 -0
- package/dist/core/action-registry.js +17 -0
- package/dist/core/action-registry.js.map +7 -0
- package/dist/core/action-repair.d.ts +20 -0
- package/dist/core/action-repair.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 +30 -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 +13 -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/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/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/omp-bash-error.d.ts +11 -0
- package/dist/core/omp-bash-error.d.ts.map +1 -0
- package/dist/core/omp-tools.d.ts +9 -0
- package/dist/core/omp-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 +6 -0
- package/dist/core/session-context.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 +12 -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 +52 -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 +7 -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 +51 -0
- package/dist/entropy/compiled-surface.d.ts.map +1 -0
- package/dist/entropy/compiler.d.ts +28 -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 +15 -0
- package/dist/entropy/index.d.ts.map +1 -0
- package/dist/entropy/index.js +172 -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/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 +13 -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 +35 -0
- package/dist/entropy/trial.d.ts.map +1 -0
- package/dist/entropy/types.d.ts +158 -0
- package/dist/entropy/types.d.ts.map +1 -0
- package/dist/execution-service.d.ts +63 -0
- package/dist/execution-service.d.ts.map +1 -0
- package/dist/fabric-exec-arguments.d.ts +5 -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 +90 -0
- package/dist/fabric-runtime-state.d.ts.map +1 -0
- package/dist/fabric-runtime-state.js +13060 -0
- package/dist/fabric-runtime-state.js.map +7 -0
- package/dist/fabric-state.d.ts +89 -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 +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5719 -0
- package/dist/index.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/memory/context.d.ts +112 -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 +23 -0
- package/dist/memory/discovery.js.map +7 -0
- package/dist/memory/index.d.ts +107 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/lineage.d.ts +20 -0
- package/dist/memory/lineage.d.ts.map +1 -0
- package/dist/memory/normalize.d.ts +170 -0
- package/dist/memory/normalize.d.ts.map +1 -0
- package/dist/memory/normalize.js +22 -0
- package/dist/memory/normalize.js.map +7 -0
- package/dist/memory/regex.d.ts +19 -0
- package/dist/memory/regex.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 +22 -0
- package/dist/memory/search.js.map +7 -0
- package/dist/memory/tokenize.d.ts +24 -0
- package/dist/memory/tokenize.d.ts.map +1 -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 +60 -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 +45 -0
- package/dist/prewalk/handoff.d.ts.map +1 -0
- package/dist/protocol.d.ts +273 -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-provider.d.ts +59 -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/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 +27 -0
- package/dist/providers/mcp-provider.d.ts.map +1 -0
- package/dist/providers/memory-provider.d.ts +35 -0
- package/dist/providers/memory-provider.d.ts.map +1 -0
- package/dist/providers/memory-provider.js +16 -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/omp-bash-cwd.d.ts +31 -0
- package/dist/providers/omp-bash-cwd.d.ts.map +1 -0
- package/dist/providers/omp-tools-provider.d.ts +15 -0
- package/dist/providers/omp-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/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 +25 -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 +152 -0
- package/dist/residency/launcher.js.map +7 -0
- package/dist/residency/omp-entry.d.ts +3 -0
- package/dist/residency/omp-entry.d.ts.map +1 -0
- package/dist/residency/omp-entry.js +41 -0
- package/dist/residency/omp-entry.js.map +7 -0
- package/dist/residency/protocol.d.ts +119 -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 +291 -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/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 +226 -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 +35 -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/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 +319 -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/quickjs-runtime.d.ts +24 -0
- package/dist/runtime/quickjs-runtime.d.ts.map +1 -0
- package/dist/runtime/quickjs-runtime.js +12 -0
- package/dist/runtime/quickjs-runtime.js.map +7 -0
- package/dist/runtime/type-checker.d.ts +21 -0
- package/dist/runtime/type-checker.d.ts.map +1 -0
- package/dist/runtime/type-checker.js +15 -0
- package/dist/runtime/type-checker.js.map +7 -0
- package/dist/runtime-paths.d.ts +7 -0
- package/dist/runtime-paths.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/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/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 +39 -0
- package/dist/speculation/store.d.ts.map +1 -0
- package/dist/speculation/stream-tap.d.ts +27 -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/code-preview-shell.d.ts +26 -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 +15 -0
- package/dist/ui/conversation-chrome.d.ts.map +1 -0
- package/dist/ui/conversation-chrome.js +10 -0
- package/dist/ui/conversation-chrome.js.map +7 -0
- package/dist/ui/conversation-native-reader.d.ts +106 -0
- package/dist/ui/conversation-native-reader.d.ts.map +1 -0
- package/dist/ui/conversation-native-reader.js +784 -0
- package/dist/ui/conversation-native-reader.js.map +7 -0
- package/dist/ui/conversation-queue-store.d.ts +12 -0
- package/dist/ui/conversation-queue-store.d.ts.map +1 -0
- package/dist/ui/conversation-queue.d.ts +242 -0
- package/dist/ui/conversation-queue.d.ts.map +1 -0
- package/dist/ui/conversation-render.d.ts +45 -0
- package/dist/ui/conversation-render.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 +170 -0
- package/dist/ui/conversation.d.ts.map +1 -0
- package/dist/ui/conversation.js +1868 -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-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 +188 -0
- package/dist/ui/dashboard.d.ts.map +1 -0
- package/dist/ui/dashboard.js +4604 -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 +8 -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 +2 -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/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.d.ts +57 -0
- package/dist/ui/settings.d.ts.map +1 -0
- package/dist/ui/settings.js +1908 -0
- package/dist/ui/settings.js.map +7 -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 +7 -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/symbol-theme.d.ts +3 -0
- package/dist/ui/symbol-theme.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/options.d.ts +3 -0
- package/dist/worker/options.d.ts.map +1 -0
- package/dist/worker/options.js +104 -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 +123 -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 +1061 -0
- package/dist/worker.js.map +7 -0
- package/docs/agents.md +564 -0
- package/docs/architecture.md +139 -0
- package/docs/audit-trace.md +116 -0
- package/docs/certification.md +134 -0
- package/docs/compaction.md +332 -0
- package/docs/component-calculus.md +191 -0
- package/docs/components.md +329 -0
- package/docs/configuration.md +478 -0
- package/docs/entropy.md +396 -0
- package/docs/interface.md +149 -0
- package/docs/memory-recall.md +614 -0
- package/docs/programmatic-compaction.md +207 -0
- package/docs/provider-component-calculus.md +378 -0
- package/docs/providers.md +109 -0
- package/docs/repairs.md +69 -0
- package/docs/residency-runtime.md +82 -0
- package/docs/schema-enforcement.md +166 -0
- package/docs/skills.md +48 -0
- package/docs/speculation.md +132 -0
- package/docs/state-layer.md +197 -0
- package/package.json +116 -0
- package/skills/fabric-advisor/SKILL.md +29 -0
- package/skills/fabric-ambient/SKILL.md +44 -0
- package/skills/fabric-ambient/references/setup.md +90 -0
- package/skills/fabric-council/SKILL.md +94 -0
- package/skills/fabric-exec/SKILL.md +123 -0
- package/skills/fabric-exec/references/agents.md +211 -0
- package/skills/fabric-exec/references/mcp.md +49 -0
- package/skills/fabric-exec/references/mesh.md +51 -0
- package/skills/fabric-fusion/SKILL.md +332 -0
- package/skills/fabric-guide/SKILL.md +28 -0
- package/skills/fabric-rlm/SKILL.md +284 -0
- package/skills/fabric-schema/SKILL.md +121 -0
- package/skills/fabric-spec/SKILL.md +42 -0
- package/skills/fabric-supervisor/SKILL.md +37 -0
- package/skills/fabric-swarm/SKILL.md +80 -0
- package/skills/fabric-workflow/SKILL.md +133 -0
|
@@ -0,0 +1,1835 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_HOT_SESSIONS,
|
|
3
|
+
DEFAULT_REGEX_MAX_HAYSTACK_BYTES,
|
|
4
|
+
DEFAULT_REGEX_MAX_HAYSTACK_TERMS,
|
|
5
|
+
DEFAULT_REGEX_MAX_PATTERN_BYTES,
|
|
6
|
+
DEFAULT_REGEX_TIMEOUT_MS,
|
|
7
|
+
fingerprintSource,
|
|
8
|
+
loadTieredIndex,
|
|
9
|
+
reconstructSessionLineage,
|
|
10
|
+
searchMemoryIndex
|
|
11
|
+
} from "./chunk-2KEWFW56.js";
|
|
12
|
+
import {
|
|
13
|
+
compareLexical,
|
|
14
|
+
normalizeMemoryPhrase,
|
|
15
|
+
tokenizeLexical
|
|
16
|
+
} from "./chunk-U5FYOMG5.js";
|
|
17
|
+
import {
|
|
18
|
+
AmbiguousSessionError,
|
|
19
|
+
enumerateAllSessions,
|
|
20
|
+
resolveScope,
|
|
21
|
+
resolveSessionTarget
|
|
22
|
+
} from "./chunk-7BIA5BJN.js";
|
|
23
|
+
import {
|
|
24
|
+
expandSessionEntriesChecked,
|
|
25
|
+
normalizeSession
|
|
26
|
+
} from "./chunk-6QBPSZJ5.js";
|
|
27
|
+
|
|
28
|
+
// src/providers/memory-provider.ts
|
|
29
|
+
import fs from "node:fs";
|
|
30
|
+
import path from "node:path";
|
|
31
|
+
|
|
32
|
+
// src/memory/context.ts
|
|
33
|
+
var RECALL_DEFAULT_PAGE_SIZE = 10;
|
|
34
|
+
var RECALL_MAX_PAGE_SIZE = 50;
|
|
35
|
+
var RECALL_DEFAULT_SNIPPET_CHARS = 480;
|
|
36
|
+
var RECALL_MAX_SNIPPET_CHARS = 2e3;
|
|
37
|
+
var RECALL_MAX_RESPONSE_CHARS = 3e4;
|
|
38
|
+
var boundedMetadata = (value, max = 512) => {
|
|
39
|
+
if (value === void 0 || value === null) return null;
|
|
40
|
+
return value.length <= max ? value : `${value.slice(0, Math.max(1, max - 1))}\u2026`;
|
|
41
|
+
};
|
|
42
|
+
var safeSlice = (text, start, end) => {
|
|
43
|
+
let safeStart = Math.max(0, start);
|
|
44
|
+
let safeEnd = Math.min(text.length, end);
|
|
45
|
+
const startCode = text.charCodeAt(safeStart);
|
|
46
|
+
if (safeStart > 0 && startCode >= 56320 && startCode <= 57343) safeStart += 1;
|
|
47
|
+
const endCode = text.charCodeAt(safeEnd - 1);
|
|
48
|
+
if (safeEnd < text.length && endCode >= 55296 && endCode <= 56319) safeEnd -= 1;
|
|
49
|
+
return text.slice(safeStart, safeEnd);
|
|
50
|
+
};
|
|
51
|
+
var snippetAnchor = (text, query, queryMode) => {
|
|
52
|
+
if (!query) return 0;
|
|
53
|
+
const normalized = normalizeMemoryPhrase(text);
|
|
54
|
+
if (queryMode === "phrase") {
|
|
55
|
+
const phrase = normalizeMemoryPhrase(query.trim());
|
|
56
|
+
return Math.max(0, normalized.indexOf(phrase));
|
|
57
|
+
}
|
|
58
|
+
if (queryMode === "literal") {
|
|
59
|
+
const terms = [...new Set(tokenizeLexical(query))].sort(
|
|
60
|
+
(left, right) => right.length - left.length || left.localeCompare(right)
|
|
61
|
+
);
|
|
62
|
+
for (const term of terms) {
|
|
63
|
+
const index = normalized.indexOf(term);
|
|
64
|
+
if (index >= 0) return index;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return 0;
|
|
68
|
+
};
|
|
69
|
+
var makeSnippet = (text, query, queryMode, maxChars) => {
|
|
70
|
+
if (text.length <= maxChars) return { text, truncated: false };
|
|
71
|
+
const anchor = snippetAnchor(text, query, queryMode);
|
|
72
|
+
const leadingContext = Math.floor(maxChars / 3);
|
|
73
|
+
let start = Math.max(0, anchor - leadingContext);
|
|
74
|
+
let end = Math.min(text.length, start + maxChars);
|
|
75
|
+
if (end - start < maxChars) start = Math.max(0, end - maxChars);
|
|
76
|
+
const body = safeSlice(text, start, end);
|
|
77
|
+
return {
|
|
78
|
+
text: `${start > 0 ? "\u2026" : ""}${body}${end < text.length ? "\u2026" : ""}`,
|
|
79
|
+
truncated: true
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
var sourceFromSegment = (segment) => ({
|
|
83
|
+
sessionId: boundedMetadata(segment.sessionId) ?? "",
|
|
84
|
+
sessionFile: segment.sessionFile,
|
|
85
|
+
sourceHash: segment.sourceHash,
|
|
86
|
+
branches: segment.branches,
|
|
87
|
+
lineageFingerprint: segment.lineageFingerprint,
|
|
88
|
+
tier: segment.tier
|
|
89
|
+
});
|
|
90
|
+
var sourceFromDigest = (digest) => ({
|
|
91
|
+
sessionId: boundedMetadata(digest.sessionId) ?? "",
|
|
92
|
+
sessionFile: digest.sessionFile,
|
|
93
|
+
sourceHash: digest.sourceHash,
|
|
94
|
+
branches: digest.branches,
|
|
95
|
+
lineageFingerprint: digest.lineageFingerprint,
|
|
96
|
+
tier: "cold"
|
|
97
|
+
});
|
|
98
|
+
var expandArgs = (source, entry) => ({
|
|
99
|
+
session: source.sessionFile,
|
|
100
|
+
expectedSourceHash: source.sourceHash,
|
|
101
|
+
expectedLineageFingerprint: source.lineageFingerprint,
|
|
102
|
+
branches: source.branches,
|
|
103
|
+
indices: [entry.index]
|
|
104
|
+
});
|
|
105
|
+
var entryHit = (segment, item, query, queryMode, snippetChars) => {
|
|
106
|
+
const entry = item.entry;
|
|
107
|
+
const source = sourceFromSegment(segment);
|
|
108
|
+
const snippet = makeSnippet(entry.text, query, queryMode, snippetChars);
|
|
109
|
+
return {
|
|
110
|
+
kind: "entry",
|
|
111
|
+
sessionId: source.sessionId,
|
|
112
|
+
tier: source.tier,
|
|
113
|
+
index: entry.index,
|
|
114
|
+
entryId: boundedMetadata(entry.entryId),
|
|
115
|
+
parentId: boundedMetadata(entry.parentId),
|
|
116
|
+
operationAddress: boundedMetadata(entry.operationAddress),
|
|
117
|
+
type: boundedMetadata(entry.type) ?? "entry",
|
|
118
|
+
role: boundedMetadata(entry.role),
|
|
119
|
+
tool: boundedMetadata(entry.toolName),
|
|
120
|
+
ref: boundedMetadata(entry.ref),
|
|
121
|
+
provider: boundedMetadata(entry.provider),
|
|
122
|
+
action: boundedMetadata(entry.action),
|
|
123
|
+
timestamp: entry.timestamp,
|
|
124
|
+
isError: entry.isError,
|
|
125
|
+
...entry.outcome ? { outcome: entry.outcome } : {},
|
|
126
|
+
score: item.score,
|
|
127
|
+
snippet: snippet.text,
|
|
128
|
+
truncated: snippet.truncated || entry.truncated,
|
|
129
|
+
follow: { ref: "memory.expand", args: expandArgs(source, entry) }
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
var hydrationArgs = (digest, request) => {
|
|
133
|
+
const { offset: _offset, entryRange: _entryRange, ...base } = request;
|
|
134
|
+
return {
|
|
135
|
+
...base,
|
|
136
|
+
scope: `session:${digest.sessionFile}`,
|
|
137
|
+
branches: digest.branches,
|
|
138
|
+
expectedSourceHash: digest.sourceHash,
|
|
139
|
+
expectedLineageFingerprint: digest.lineageFingerprint
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
var sessionHit = (digest, request) => {
|
|
143
|
+
const source = sourceFromDigest(digest);
|
|
144
|
+
return {
|
|
145
|
+
kind: "session",
|
|
146
|
+
sessionId: source.sessionId,
|
|
147
|
+
tier: "cold",
|
|
148
|
+
cwd: boundedMetadata(digest.cwd, 2048) ?? "",
|
|
149
|
+
lastTimestamp: digest.lastTs,
|
|
150
|
+
score: digest.score,
|
|
151
|
+
matchedTerms: digest.matchedTerms,
|
|
152
|
+
matchedStructuralEntries: digest.matchedStructuralEntries,
|
|
153
|
+
follow: { ref: "memory.recall", args: hydrationArgs(digest, request) }
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
var recallCandidateCache = /* @__PURE__ */ new WeakMap();
|
|
157
|
+
var flattenCandidates = (result) => {
|
|
158
|
+
const cached = recallCandidateCache.get(result);
|
|
159
|
+
if (cached) return cached;
|
|
160
|
+
const candidates = [];
|
|
161
|
+
for (const item of result.items) {
|
|
162
|
+
if (item.kind === "digest") {
|
|
163
|
+
candidates.push({ kind: "session", digest: item.digest });
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
for (const entry of item.segment.entries) {
|
|
167
|
+
if (entry.matched) candidates.push({ kind: "entry", segment: item.segment, item: entry });
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
candidates.sort((left, right) => {
|
|
171
|
+
const leftScore = left.kind === "entry" ? left.item.score : left.digest.score;
|
|
172
|
+
const rightScore = right.kind === "entry" ? right.item.score : right.digest.score;
|
|
173
|
+
if (rightScore !== leftScore) return rightScore - leftScore;
|
|
174
|
+
const leftMtime = left.kind === "entry" ? left.segment.sessionMtime : left.digest.sessionMtime;
|
|
175
|
+
const rightMtime = right.kind === "entry" ? right.segment.sessionMtime : right.digest.sessionMtime;
|
|
176
|
+
if (rightMtime !== leftMtime) return rightMtime - leftMtime;
|
|
177
|
+
if (left.kind !== right.kind) return left.kind === "entry" ? -1 : 1;
|
|
178
|
+
if (left.kind === "entry" && right.kind === "entry") {
|
|
179
|
+
if (left.item.entry.index !== right.item.entry.index) {
|
|
180
|
+
return left.item.entry.index - right.item.entry.index;
|
|
181
|
+
}
|
|
182
|
+
return compareLexical(left.segment.sessionFile, right.segment.sessionFile);
|
|
183
|
+
}
|
|
184
|
+
if (left.kind === "session" && right.kind === "session") {
|
|
185
|
+
return compareLexical(left.digest.sessionFile, right.digest.sessionFile);
|
|
186
|
+
}
|
|
187
|
+
return 0;
|
|
188
|
+
});
|
|
189
|
+
recallCandidateCache.set(result, candidates);
|
|
190
|
+
return candidates;
|
|
191
|
+
};
|
|
192
|
+
var materializeCandidate = (candidate, query, queryMode, snippetChars, request) => candidate.kind === "session" ? sessionHit(candidate.digest, request) : entryHit(candidate.segment, candidate.item, query, queryMode, snippetChars);
|
|
193
|
+
var canonicalNextArgs = (request, offset) => {
|
|
194
|
+
const { offset: _offset, ...base } = request;
|
|
195
|
+
return { ...base, offset };
|
|
196
|
+
};
|
|
197
|
+
var presentRecall = (input) => {
|
|
198
|
+
const candidates = flattenCandidates(input.result);
|
|
199
|
+
const start = input.offset ?? 0;
|
|
200
|
+
let selected = candidates.slice(start, start + input.pageSize);
|
|
201
|
+
const build = (pageCandidates) => {
|
|
202
|
+
const hits = pageCandidates.map(
|
|
203
|
+
(candidate) => materializeCandidate(
|
|
204
|
+
candidate,
|
|
205
|
+
input.query,
|
|
206
|
+
input.queryMode,
|
|
207
|
+
input.snippetChars,
|
|
208
|
+
input.requestArgs
|
|
209
|
+
)
|
|
210
|
+
);
|
|
211
|
+
return {
|
|
212
|
+
total: candidates.length,
|
|
213
|
+
hits,
|
|
214
|
+
next: start + hits.length < candidates.length ? { ref: "memory.recall", args: canonicalNextArgs(input.requestArgs, start + hits.length) } : null,
|
|
215
|
+
coverage: input.coverage
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
let response = build(selected);
|
|
219
|
+
while (selected.length > 1 && JSON.stringify(response).length > RECALL_MAX_RESPONSE_CHARS) {
|
|
220
|
+
selected = selected.slice(0, -1);
|
|
221
|
+
response = build(selected);
|
|
222
|
+
}
|
|
223
|
+
return response;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// src/providers/arg-normalization.ts
|
|
227
|
+
var normalizeForm = (key) => key.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
228
|
+
var KEY_SYNONYM_CLASSES = [
|
|
229
|
+
["session", "sessionId", "id", "file", "path"],
|
|
230
|
+
["hypothesisId", "id"],
|
|
231
|
+
["id", "agentId", "actorId", "runId"],
|
|
232
|
+
["query", "q"],
|
|
233
|
+
["limit", "max", "pageSize"],
|
|
234
|
+
["task", "prompt", "instructions"],
|
|
235
|
+
["label", "labels", "name", "title"],
|
|
236
|
+
["summary", "description"],
|
|
237
|
+
["text", "message", "body"],
|
|
238
|
+
["check", "command", "cmd", "script", "predicate"],
|
|
239
|
+
["files", "paths"],
|
|
240
|
+
["ifVersion", "versionRef", "version"],
|
|
241
|
+
["indices", "index"]
|
|
242
|
+
];
|
|
243
|
+
var KEY_CLASS_FORMS = KEY_SYNONYM_CLASSES.map(
|
|
244
|
+
(cls) => new Set(cls.map(normalizeForm))
|
|
245
|
+
);
|
|
246
|
+
var ENUM_VALUE_CLASSES = [
|
|
247
|
+
["project", "cwd", "repo", "repository", "workspace", "checkout", "tree"],
|
|
248
|
+
["global", "all"],
|
|
249
|
+
["permanent", "pinned", "sticky", "durable"]
|
|
250
|
+
];
|
|
251
|
+
var VALUE_CLASS_FORMS = ENUM_VALUE_CLASSES.map(
|
|
252
|
+
(cls) => new Set(cls.map(normalizeForm))
|
|
253
|
+
);
|
|
254
|
+
var numericKind = (property) => {
|
|
255
|
+
if (!property || typeof property !== "object") return void 0;
|
|
256
|
+
const schema = property;
|
|
257
|
+
if (schema.type === "number" || schema.type === "integer") return "scalar";
|
|
258
|
+
if (schema.type === "array") {
|
|
259
|
+
const items = schema.items;
|
|
260
|
+
if (items && typeof items === "object" && (items.type === "number" || items.type === "integer")) {
|
|
261
|
+
return "array";
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return void 0;
|
|
265
|
+
};
|
|
266
|
+
var stringEnumValues = (property) => {
|
|
267
|
+
if (!property || typeof property !== "object") return void 0;
|
|
268
|
+
const schema = property;
|
|
269
|
+
if (Array.isArray(schema.enum)) {
|
|
270
|
+
const values = schema.enum.filter(
|
|
271
|
+
(entry) => typeof entry === "string"
|
|
272
|
+
);
|
|
273
|
+
return values.length > 0 ? values : void 0;
|
|
274
|
+
}
|
|
275
|
+
for (const branch of [schema.oneOf, schema.anyOf]) {
|
|
276
|
+
if (!Array.isArray(branch)) continue;
|
|
277
|
+
const consts = branch.map(
|
|
278
|
+
(entry) => entry && typeof entry === "object" ? entry.const : void 0
|
|
279
|
+
).filter((entry) => typeof entry === "string");
|
|
280
|
+
if (consts.length > 0) return consts;
|
|
281
|
+
}
|
|
282
|
+
return void 0;
|
|
283
|
+
};
|
|
284
|
+
var deriveEnumValueMap = (values) => {
|
|
285
|
+
const map = /* @__PURE__ */ new Map();
|
|
286
|
+
const seen = /* @__PURE__ */ new Map();
|
|
287
|
+
for (const value of values) {
|
|
288
|
+
const form = normalizeForm(value);
|
|
289
|
+
seen.set(form, seen.has(form) ? void 0 : value);
|
|
290
|
+
}
|
|
291
|
+
for (const [form, value] of seen) if (value !== void 0) map.set(form, value);
|
|
292
|
+
for (const classForms of VALUE_CLASS_FORMS) {
|
|
293
|
+
const members = values.filter((value) => classForms.has(normalizeForm(value)));
|
|
294
|
+
if (members.length !== 1) continue;
|
|
295
|
+
const [hit] = members;
|
|
296
|
+
for (const form of classForms) {
|
|
297
|
+
if (form !== normalizeForm(hit) && !map.has(form)) map.set(form, hit);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return map;
|
|
301
|
+
};
|
|
302
|
+
var deriveAction = (inputSchema, explicit) => {
|
|
303
|
+
const properties = inputSchema && typeof inputSchema === "object" && inputSchema.properties && typeof inputSchema.properties === "object" ? inputSchema.properties : void 0;
|
|
304
|
+
const declared = new Set(Object.keys(properties ?? {}));
|
|
305
|
+
const declaredForms = /* @__PURE__ */ new Map();
|
|
306
|
+
const ambiguousForms = /* @__PURE__ */ new Set();
|
|
307
|
+
for (const key of declared) {
|
|
308
|
+
const form = normalizeForm(key);
|
|
309
|
+
if (declaredForms.has(form)) {
|
|
310
|
+
ambiguousForms.add(form);
|
|
311
|
+
declaredForms.delete(form);
|
|
312
|
+
} else if (!ambiguousForms.has(form)) {
|
|
313
|
+
declaredForms.set(form, key);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
const singulars = /* @__PURE__ */ new Map();
|
|
317
|
+
for (const key of declared) {
|
|
318
|
+
const form = normalizeForm(key);
|
|
319
|
+
if (!form.endsWith("s")) continue;
|
|
320
|
+
const singular = form.slice(0, -1);
|
|
321
|
+
if (!singular || declaredForms.has(singular) || singular === form) continue;
|
|
322
|
+
if (singulars.get(singular) !== void 0) singulars.delete(singular);
|
|
323
|
+
else singulars.set(singular, key);
|
|
324
|
+
}
|
|
325
|
+
for (const form of ambiguousForms) singulars.delete(form);
|
|
326
|
+
const numerics = new Set(explicit?.numerics ?? []);
|
|
327
|
+
const numericArrays = new Set(explicit?.numericArrays ?? []);
|
|
328
|
+
const values = /* @__PURE__ */ new Map();
|
|
329
|
+
if (properties) {
|
|
330
|
+
for (const [key, property] of Object.entries(properties)) {
|
|
331
|
+
const kind = numericKind(property);
|
|
332
|
+
if (kind === "scalar") numerics.add(key);
|
|
333
|
+
else if (kind === "array") numericArrays.add(key);
|
|
334
|
+
const enumValues = stringEnumValues(property);
|
|
335
|
+
if (enumValues) values.set(key, new Map(deriveEnumValueMap(enumValues)));
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
for (const [key, remaps] of Object.entries(explicit?.values ?? {})) {
|
|
339
|
+
const map = values.get(key) ?? /* @__PURE__ */ new Map();
|
|
340
|
+
for (const [spelling, target] of Object.entries(remaps)) {
|
|
341
|
+
map.set(normalizeForm(spelling), target);
|
|
342
|
+
}
|
|
343
|
+
values.set(key, map);
|
|
344
|
+
}
|
|
345
|
+
return { declared, declaredForms, singulars, numerics, numericArrays, values, aliases: explicit?.aliases };
|
|
346
|
+
};
|
|
347
|
+
var lexiconRepair = (form, declaredForms) => {
|
|
348
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
349
|
+
for (const classForms of KEY_CLASS_FORMS) {
|
|
350
|
+
if (!classForms.has(form)) continue;
|
|
351
|
+
for (const [declaredForm, declaredKey] of declaredForms) {
|
|
352
|
+
if (declaredForm !== form && classForms.has(declaredForm)) {
|
|
353
|
+
candidates.add(declaredKey);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return candidates.size === 1 ? [...candidates][0] : void 0;
|
|
358
|
+
};
|
|
359
|
+
var uniqueDeclaredKeyForSpelling = (spilled, declared) => {
|
|
360
|
+
if (declared.includes(spilled)) return void 0;
|
|
361
|
+
const derived = deriveAction(
|
|
362
|
+
{
|
|
363
|
+
type: "object",
|
|
364
|
+
properties: Object.fromEntries(declared.map((key) => [key, {}]))
|
|
365
|
+
},
|
|
366
|
+
void 0
|
|
367
|
+
);
|
|
368
|
+
const form = normalizeForm(spilled);
|
|
369
|
+
const canonical = derived.declaredForms.get(form) ?? derived.singulars.get(form) ?? lexiconRepair(form, derived.declaredForms);
|
|
370
|
+
return canonical && canonical !== spilled ? canonical : void 0;
|
|
371
|
+
};
|
|
372
|
+
var applyDerived = (args, derived) => {
|
|
373
|
+
const out = { ...args };
|
|
374
|
+
const repair = (alias, canonical) => {
|
|
375
|
+
if (!(alias in out) || alias === canonical) return;
|
|
376
|
+
if (!(canonical in out)) out[canonical] = out[alias];
|
|
377
|
+
delete out[alias];
|
|
378
|
+
};
|
|
379
|
+
for (const [alias, canonical] of Object.entries(derived.aliases ?? {})) {
|
|
380
|
+
repair(alias, canonical);
|
|
381
|
+
}
|
|
382
|
+
for (const key of [...Object.keys(out)]) {
|
|
383
|
+
if (derived.declared.has(key)) continue;
|
|
384
|
+
const form = normalizeForm(key);
|
|
385
|
+
const canonical = derived.declaredForms.get(form) ?? derived.singulars.get(form) ?? lexiconRepair(form, derived.declaredForms);
|
|
386
|
+
if (canonical && canonical !== key) repair(key, canonical);
|
|
387
|
+
}
|
|
388
|
+
for (const key of derived.numerics) {
|
|
389
|
+
const value = out[key];
|
|
390
|
+
if (typeof value === "string" && value.trim() !== "" && !Number.isNaN(Number(value))) {
|
|
391
|
+
out[key] = Number(value);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
for (const key of derived.numericArrays) {
|
|
395
|
+
const value = out[key];
|
|
396
|
+
if (Array.isArray(value)) {
|
|
397
|
+
out[key] = value.map(
|
|
398
|
+
(entry) => typeof entry === "string" && entry.trim() !== "" && !Number.isNaN(Number(entry)) ? Number(entry) : entry
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
for (const [key, remaps] of derived.values) {
|
|
403
|
+
const value = out[key];
|
|
404
|
+
if (typeof value === "string") {
|
|
405
|
+
const next = remaps.get(normalizeForm(value));
|
|
406
|
+
if (next !== void 0) out[key] = next;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
if (derived.declared.size > 0) {
|
|
410
|
+
for (const key of Object.keys(out)) {
|
|
411
|
+
if (derived.declared.has(key) && (out[key] === null || out[key] === void 0)) {
|
|
412
|
+
delete out[key];
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return out;
|
|
417
|
+
};
|
|
418
|
+
var actionArgNormalizer = (describeActions, table = {}) => {
|
|
419
|
+
const derived = /* @__PURE__ */ new Map();
|
|
420
|
+
for (const descriptor of describeActions()) {
|
|
421
|
+
derived.set(
|
|
422
|
+
descriptor.name,
|
|
423
|
+
deriveAction(
|
|
424
|
+
descriptor.inputSchema,
|
|
425
|
+
table[descriptor.name]
|
|
426
|
+
)
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
return (actionName, args) => {
|
|
430
|
+
if (!args || typeof args !== "object" || Array.isArray(args)) return args;
|
|
431
|
+
const action = derived.get(actionName);
|
|
432
|
+
return action ? applyDerived(args, action) : args;
|
|
433
|
+
};
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
// src/providers/memory-provider.ts
|
|
437
|
+
var EXPAND_DEFAULT_MAX_CHARS = 2e4;
|
|
438
|
+
var EXPAND_MAX_CHARS = 24e3;
|
|
439
|
+
var EXPAND_DEFAULT_MAX_ENTRIES = 10;
|
|
440
|
+
var EXPAND_MAX_ENTRIES = 20;
|
|
441
|
+
var EXPAND_MAX_CONTEXT = 100;
|
|
442
|
+
var EXPAND_MAX_EXACT_SELECTORS = 100;
|
|
443
|
+
var SESSIONS_MAX = 500;
|
|
444
|
+
var CONTINUATION_CACHE_TTL_MS = 5 * 6e4;
|
|
445
|
+
var EXPANSION_SNAPSHOT_LIMIT = 2;
|
|
446
|
+
var EXPANSION_SELECTION_LIMIT = 16;
|
|
447
|
+
var sourceIdentity = (file) => {
|
|
448
|
+
try {
|
|
449
|
+
const stat = fs.statSync(file, { bigint: true });
|
|
450
|
+
if (!stat.isFile()) return null;
|
|
451
|
+
return {
|
|
452
|
+
device: stat.dev,
|
|
453
|
+
inode: stat.ino,
|
|
454
|
+
size: stat.size,
|
|
455
|
+
modifiedAt: stat.mtimeNs,
|
|
456
|
+
changedAt: stat.ctimeNs
|
|
457
|
+
};
|
|
458
|
+
} catch {
|
|
459
|
+
return null;
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
var sameSourceIdentity = (left, right) => left.device === right.device && left.inode === right.inode && left.size === right.size && left.modifiedAt === right.modifiedAt && left.changedAt === right.changedAt;
|
|
463
|
+
var liveBranchSignature = (branch) => branch ? `${branch.leafId ?? ""}\0${branch.entries.length}` : null;
|
|
464
|
+
var observeSource = (file, branches, liveBranch) => {
|
|
465
|
+
const identity = sourceIdentity(file);
|
|
466
|
+
if (!identity) return null;
|
|
467
|
+
return {
|
|
468
|
+
file: path.resolve(file),
|
|
469
|
+
identity,
|
|
470
|
+
liveBranchSignature: branches === "active" ? liveBranchSignature(liveBranch) : null
|
|
471
|
+
};
|
|
472
|
+
};
|
|
473
|
+
var observeSources = (refs, branches, liveResolver) => {
|
|
474
|
+
const observations = [];
|
|
475
|
+
for (const ref of refs) {
|
|
476
|
+
const liveBranch = branches === "active" ? liveResolver?.(ref.file) : void 0;
|
|
477
|
+
const observation = observeSource(ref.file, branches, liveBranch);
|
|
478
|
+
if (!observation) return null;
|
|
479
|
+
observations.push(observation);
|
|
480
|
+
}
|
|
481
|
+
return observations;
|
|
482
|
+
};
|
|
483
|
+
var sameSourceObservation = (left, right) => left.file === right.file && sameSourceIdentity(left.identity, right.identity) && left.liveBranchSignature === right.liveBranchSignature;
|
|
484
|
+
var sameSourceObservations = (left, right) => left.length === right.length && left.every(
|
|
485
|
+
(item, index) => sameSourceObservation(item, right[index])
|
|
486
|
+
);
|
|
487
|
+
var recallContinuationKey = (args) => JSON.stringify([
|
|
488
|
+
args.query ?? null,
|
|
489
|
+
args.queryMode ?? "literal",
|
|
490
|
+
args.queryMatch ?? null,
|
|
491
|
+
args.expectedSourceHash ?? null,
|
|
492
|
+
args.expectedLineageFingerprint ?? null,
|
|
493
|
+
args.branches ?? "active",
|
|
494
|
+
args.scope ?? "session",
|
|
495
|
+
args.pageSize ?? RECALL_DEFAULT_PAGE_SIZE,
|
|
496
|
+
args.snippetChars ?? RECALL_DEFAULT_SNIPPET_CHARS,
|
|
497
|
+
args.role ?? null,
|
|
498
|
+
args.tool ?? null,
|
|
499
|
+
args.ref ?? null,
|
|
500
|
+
args.provider ?? null,
|
|
501
|
+
args.action ?? null,
|
|
502
|
+
args.outcome ?? null,
|
|
503
|
+
args.since ?? null,
|
|
504
|
+
args.until ?? null,
|
|
505
|
+
args.entryRange ? [args.entryRange.first, args.entryRange.last] : null
|
|
506
|
+
]);
|
|
507
|
+
var expansionSnapshotKey = (file, branches) => `${path.resolve(file)}\0${branches}`;
|
|
508
|
+
var expansionSelectionKey = (selection) => JSON.stringify([
|
|
509
|
+
selection.indices ?? null,
|
|
510
|
+
selection.entryIds ?? null,
|
|
511
|
+
selection.operationAddresses ?? null,
|
|
512
|
+
selection.entryRange ? [selection.entryRange.first, selection.entryRange.last] : null,
|
|
513
|
+
selection.before ?? 0,
|
|
514
|
+
selection.after ?? 0
|
|
515
|
+
]);
|
|
516
|
+
var errorOutputSchema = {
|
|
517
|
+
type: "object",
|
|
518
|
+
properties: {
|
|
519
|
+
code: { type: "string" },
|
|
520
|
+
message: { type: "string" }
|
|
521
|
+
},
|
|
522
|
+
required: ["code", "message"]
|
|
523
|
+
};
|
|
524
|
+
var coverageOutputSchema = {
|
|
525
|
+
type: "object",
|
|
526
|
+
properties: {
|
|
527
|
+
complete: { type: "boolean" },
|
|
528
|
+
indexedSessions: { type: "number" },
|
|
529
|
+
eligibleSessions: { type: "number" },
|
|
530
|
+
staleSessions: { type: "number" },
|
|
531
|
+
incompleteSessions: { type: "number" },
|
|
532
|
+
reasons: {
|
|
533
|
+
type: "array",
|
|
534
|
+
items: { type: "string" },
|
|
535
|
+
description: "Stable machine-readable incompleteness codes; empty when complete is true."
|
|
536
|
+
},
|
|
537
|
+
error: errorOutputSchema
|
|
538
|
+
},
|
|
539
|
+
required: [
|
|
540
|
+
"complete",
|
|
541
|
+
"indexedSessions",
|
|
542
|
+
"eligibleSessions",
|
|
543
|
+
"staleSessions",
|
|
544
|
+
"incompleteSessions",
|
|
545
|
+
"reasons"
|
|
546
|
+
]
|
|
547
|
+
};
|
|
548
|
+
var callOutputSchema = (ref) => ({
|
|
549
|
+
type: "object",
|
|
550
|
+
properties: {
|
|
551
|
+
ref: { const: ref },
|
|
552
|
+
args: { type: "object" }
|
|
553
|
+
},
|
|
554
|
+
required: ["ref", "args"]
|
|
555
|
+
});
|
|
556
|
+
var recallEntryOutputSchema = {
|
|
557
|
+
type: "object",
|
|
558
|
+
properties: {
|
|
559
|
+
kind: { const: "entry" },
|
|
560
|
+
sessionId: { type: "string" },
|
|
561
|
+
tier: { type: "string", enum: ["hot", "cold"] },
|
|
562
|
+
index: { type: "number" },
|
|
563
|
+
entryId: { type: ["string", "null"] },
|
|
564
|
+
parentId: { type: ["string", "null"] },
|
|
565
|
+
operationAddress: { type: ["string", "null"] },
|
|
566
|
+
type: { type: "string" },
|
|
567
|
+
role: { type: ["string", "null"] },
|
|
568
|
+
tool: { type: ["string", "null"] },
|
|
569
|
+
ref: { type: ["string", "null"] },
|
|
570
|
+
provider: { type: ["string", "null"] },
|
|
571
|
+
action: { type: ["string", "null"] },
|
|
572
|
+
timestamp: { type: ["number", "null"] },
|
|
573
|
+
isError: { type: "boolean" },
|
|
574
|
+
outcome: { type: "string", enum: ["succeeded", "failed", "aborted", "timed_out"] },
|
|
575
|
+
score: { type: "number" },
|
|
576
|
+
snippet: { type: "string" },
|
|
577
|
+
truncated: { type: "boolean" },
|
|
578
|
+
follow: callOutputSchema("memory.expand")
|
|
579
|
+
},
|
|
580
|
+
required: [
|
|
581
|
+
"kind",
|
|
582
|
+
"sessionId",
|
|
583
|
+
"tier",
|
|
584
|
+
"index",
|
|
585
|
+
"entryId",
|
|
586
|
+
"parentId",
|
|
587
|
+
"operationAddress",
|
|
588
|
+
"type",
|
|
589
|
+
"role",
|
|
590
|
+
"tool",
|
|
591
|
+
"ref",
|
|
592
|
+
"provider",
|
|
593
|
+
"action",
|
|
594
|
+
"timestamp",
|
|
595
|
+
"isError",
|
|
596
|
+
"score",
|
|
597
|
+
"snippet",
|
|
598
|
+
"truncated",
|
|
599
|
+
"follow"
|
|
600
|
+
]
|
|
601
|
+
};
|
|
602
|
+
var recallSessionOutputSchema = {
|
|
603
|
+
type: "object",
|
|
604
|
+
properties: {
|
|
605
|
+
kind: { const: "session" },
|
|
606
|
+
sessionId: { type: "string" },
|
|
607
|
+
tier: { const: "cold" },
|
|
608
|
+
cwd: { type: "string" },
|
|
609
|
+
lastTimestamp: { type: ["number", "null"] },
|
|
610
|
+
score: { type: "number" },
|
|
611
|
+
matchedTerms: { type: "number" },
|
|
612
|
+
matchedStructuralEntries: { type: "number" },
|
|
613
|
+
follow: callOutputSchema("memory.recall")
|
|
614
|
+
},
|
|
615
|
+
required: [
|
|
616
|
+
"kind",
|
|
617
|
+
"sessionId",
|
|
618
|
+
"tier",
|
|
619
|
+
"cwd",
|
|
620
|
+
"lastTimestamp",
|
|
621
|
+
"score",
|
|
622
|
+
"matchedTerms",
|
|
623
|
+
"matchedStructuralEntries",
|
|
624
|
+
"follow"
|
|
625
|
+
]
|
|
626
|
+
};
|
|
627
|
+
var recallOutputSchema = {
|
|
628
|
+
type: "object",
|
|
629
|
+
description: "Bounded ranked memory hits with uniform follow and pagination calls.",
|
|
630
|
+
properties: {
|
|
631
|
+
total: { type: "number" },
|
|
632
|
+
hits: {
|
|
633
|
+
type: "array",
|
|
634
|
+
description: "Call tools.call(hit.follow) to expand an entry or resolve a cold session.",
|
|
635
|
+
items: { oneOf: [recallEntryOutputSchema, recallSessionOutputSchema] }
|
|
636
|
+
},
|
|
637
|
+
next: {
|
|
638
|
+
oneOf: [callOutputSchema("memory.recall"), { type: "null" }],
|
|
639
|
+
description: "When non-null, call tools.call(next)."
|
|
640
|
+
},
|
|
641
|
+
coverage: coverageOutputSchema,
|
|
642
|
+
error: errorOutputSchema
|
|
643
|
+
},
|
|
644
|
+
required: ["total", "hits", "next", "coverage"]
|
|
645
|
+
};
|
|
646
|
+
var expandOutputSchema = {
|
|
647
|
+
type: "object",
|
|
648
|
+
description: "Integrity-bound session entries returned as lossless bounded text chunks.",
|
|
649
|
+
properties: {
|
|
650
|
+
session: { type: "string" },
|
|
651
|
+
sourceHash: { type: "string" },
|
|
652
|
+
branches: { type: "string", enum: ["active", "all"] },
|
|
653
|
+
lineageFingerprint: { type: "string" },
|
|
654
|
+
entryCount: { type: "number" },
|
|
655
|
+
entries: {
|
|
656
|
+
type: "array",
|
|
657
|
+
items: {
|
|
658
|
+
type: "object",
|
|
659
|
+
properties: {
|
|
660
|
+
index: { type: "number" },
|
|
661
|
+
entryId: { type: ["string", "null"] },
|
|
662
|
+
parentId: { type: ["string", "null"] },
|
|
663
|
+
type: { type: ["string", "null"] },
|
|
664
|
+
role: { type: ["string", "null"] },
|
|
665
|
+
timestamp: { type: ["number", "null"] },
|
|
666
|
+
isError: { type: "boolean" },
|
|
667
|
+
text: { type: "string" },
|
|
668
|
+
textRange: {
|
|
669
|
+
type: "object",
|
|
670
|
+
properties: {
|
|
671
|
+
start: { type: "number" },
|
|
672
|
+
end: { type: "number" },
|
|
673
|
+
total: { type: "number" },
|
|
674
|
+
complete: { type: "boolean" }
|
|
675
|
+
},
|
|
676
|
+
required: ["start", "end", "total", "complete"]
|
|
677
|
+
},
|
|
678
|
+
anchor: { type: "boolean" },
|
|
679
|
+
parentEntryId: { type: ["string", "null"] },
|
|
680
|
+
operationAddress: { type: ["string", "null"] },
|
|
681
|
+
tool: { type: ["string", "null"] },
|
|
682
|
+
ref: { type: ["string", "null"] },
|
|
683
|
+
provider: { type: ["string", "null"] },
|
|
684
|
+
action: { type: ["string", "null"] },
|
|
685
|
+
outcome: { type: "string", enum: ["succeeded", "failed", "aborted", "timed_out"] },
|
|
686
|
+
filesTouched: { type: "array", items: { type: ["string", "null"] } },
|
|
687
|
+
operation: { type: "object" },
|
|
688
|
+
branchFact: { type: "object" },
|
|
689
|
+
structuredTruncated: { type: "boolean" },
|
|
690
|
+
factAddress: { type: ["string", "null"] },
|
|
691
|
+
carrierEntryId: { type: ["string", "null"] },
|
|
692
|
+
carrierParentId: { type: ["string", "null"] },
|
|
693
|
+
carrierFromId: { type: ["string", "null"] }
|
|
694
|
+
},
|
|
695
|
+
required: ["index", "entryId", "parentId", "type", "role", "timestamp", "isError", "text", "textRange"]
|
|
696
|
+
}
|
|
697
|
+
},
|
|
698
|
+
next: {
|
|
699
|
+
oneOf: [callOutputSchema("memory.expand"), { type: "null" }],
|
|
700
|
+
description: "When non-null, call tools.call(next)."
|
|
701
|
+
},
|
|
702
|
+
error: errorOutputSchema
|
|
703
|
+
},
|
|
704
|
+
required: ["entries"]
|
|
705
|
+
};
|
|
706
|
+
var sessionsOutputSchema = {
|
|
707
|
+
type: "object",
|
|
708
|
+
properties: {
|
|
709
|
+
scope: { type: "string" },
|
|
710
|
+
branches: { type: "string", enum: ["active", "all"] },
|
|
711
|
+
sessions: {
|
|
712
|
+
type: "array",
|
|
713
|
+
items: {
|
|
714
|
+
type: "object",
|
|
715
|
+
properties: {
|
|
716
|
+
id: { type: "string" },
|
|
717
|
+
file: { type: "string" },
|
|
718
|
+
cwd: { type: "string" },
|
|
719
|
+
mtime: { type: "number" },
|
|
720
|
+
entryCount: { type: "number" },
|
|
721
|
+
tier: { type: "string", enum: ["hot", "cold"] },
|
|
722
|
+
branches: { type: "string", enum: ["active", "all"] },
|
|
723
|
+
lineageFingerprint: { type: ["string", "null"] }
|
|
724
|
+
},
|
|
725
|
+
required: [
|
|
726
|
+
"id",
|
|
727
|
+
"file",
|
|
728
|
+
"cwd",
|
|
729
|
+
"mtime",
|
|
730
|
+
"entryCount",
|
|
731
|
+
"tier",
|
|
732
|
+
"branches",
|
|
733
|
+
"lineageFingerprint"
|
|
734
|
+
]
|
|
735
|
+
}
|
|
736
|
+
},
|
|
737
|
+
error: errorOutputSchema
|
|
738
|
+
}
|
|
739
|
+
};
|
|
740
|
+
var descriptors = [
|
|
741
|
+
{
|
|
742
|
+
name: "recall",
|
|
743
|
+
description: "Search session memory as bounded ranked snippets. Literal queries rank any matching term by default; queryMatch all narrows to co-located terms. Call tools.call(hit.follow) for either an exact entry or a cold-session candidate, and tools.call(next) to continue.",
|
|
744
|
+
inputSchema: {
|
|
745
|
+
type: "object",
|
|
746
|
+
properties: {
|
|
747
|
+
query: { type: "string", maxLength: 4096 },
|
|
748
|
+
queryMode: {
|
|
749
|
+
type: "string",
|
|
750
|
+
enum: ["literal", "phrase", "regex"],
|
|
751
|
+
default: "literal",
|
|
752
|
+
description: "Canonical tokens (default), one case-insensitive exact phrase, or explicitly bounded regex."
|
|
753
|
+
},
|
|
754
|
+
queryMatch: {
|
|
755
|
+
type: "string",
|
|
756
|
+
enum: ["all", "any"],
|
|
757
|
+
default: "any",
|
|
758
|
+
description: "For literal mode, accept any term (default) or require all terms in one hot entry."
|
|
759
|
+
},
|
|
760
|
+
expectedSourceHash: {
|
|
761
|
+
type: "string",
|
|
762
|
+
description: "SHA-256 from a prior pointer; stale sources are refused."
|
|
763
|
+
},
|
|
764
|
+
expectedLineageFingerprint: {
|
|
765
|
+
type: "string",
|
|
766
|
+
description: "Active-lineage fingerprint from a prior pointer; changed leaves are refused."
|
|
767
|
+
},
|
|
768
|
+
branches: {
|
|
769
|
+
type: "string",
|
|
770
|
+
enum: ["active", "all"],
|
|
771
|
+
description: "Search the active parent-linked path (default) or every branch."
|
|
772
|
+
},
|
|
773
|
+
scope: {
|
|
774
|
+
type: "string",
|
|
775
|
+
description: "session | project | global | session:<id-or-path>. Defaults to session."
|
|
776
|
+
},
|
|
777
|
+
offset: {
|
|
778
|
+
type: "number",
|
|
779
|
+
minimum: 0,
|
|
780
|
+
description: "Exact ranked-hit offset, normally copied from next.args."
|
|
781
|
+
},
|
|
782
|
+
pageSize: { type: "number", minimum: 1, maximum: RECALL_MAX_PAGE_SIZE, default: RECALL_DEFAULT_PAGE_SIZE },
|
|
783
|
+
snippetChars: {
|
|
784
|
+
type: "number",
|
|
785
|
+
minimum: 80,
|
|
786
|
+
maximum: RECALL_MAX_SNIPPET_CHARS,
|
|
787
|
+
default: RECALL_DEFAULT_SNIPPET_CHARS,
|
|
788
|
+
description: "Maximum indexed-text characters shown per hit; full text remains in memory.expand."
|
|
789
|
+
},
|
|
790
|
+
role: {
|
|
791
|
+
type: "string",
|
|
792
|
+
enum: [
|
|
793
|
+
"assistant",
|
|
794
|
+
"bashExecution",
|
|
795
|
+
"branchCustomMessage",
|
|
796
|
+
"branchSummary",
|
|
797
|
+
"branchUser",
|
|
798
|
+
"compaction",
|
|
799
|
+
"compactionSummary",
|
|
800
|
+
"custom",
|
|
801
|
+
"fabricOperation",
|
|
802
|
+
"fabricPhase",
|
|
803
|
+
"fabricRun",
|
|
804
|
+
"toolResult",
|
|
805
|
+
"user"
|
|
806
|
+
],
|
|
807
|
+
description: "Exact normalized entry role to filter by: the closed set the session normalizer can produce."
|
|
808
|
+
},
|
|
809
|
+
tool: { type: "string" },
|
|
810
|
+
ref: {
|
|
811
|
+
type: "string",
|
|
812
|
+
minLength: 1,
|
|
813
|
+
description: "Exact persisted Fabric action ref, such as omp.grep. This is structural selection, not lexical expansion."
|
|
814
|
+
},
|
|
815
|
+
provider: {
|
|
816
|
+
type: "string",
|
|
817
|
+
minLength: 1,
|
|
818
|
+
description: "Exact persisted Fabric provider identity."
|
|
819
|
+
},
|
|
820
|
+
action: {
|
|
821
|
+
type: "string",
|
|
822
|
+
minLength: 1,
|
|
823
|
+
description: "Exact persisted Fabric action name."
|
|
824
|
+
},
|
|
825
|
+
outcome: {
|
|
826
|
+
type: "string",
|
|
827
|
+
enum: ["succeeded", "failed", "aborted", "timed_out"],
|
|
828
|
+
description: "Exact persisted Fabric execution outcome."
|
|
829
|
+
},
|
|
830
|
+
since: { type: "number" },
|
|
831
|
+
until: { type: "number" },
|
|
832
|
+
entryRange: {
|
|
833
|
+
type: "object",
|
|
834
|
+
description: "Inclusive normalized-entry range for an explicit session:<id> resolution.",
|
|
835
|
+
properties: {
|
|
836
|
+
first: { type: "number", minimum: 0 },
|
|
837
|
+
last: { type: "number", minimum: 0 }
|
|
838
|
+
},
|
|
839
|
+
required: ["first", "last"],
|
|
840
|
+
additionalProperties: false
|
|
841
|
+
}
|
|
842
|
+
},
|
|
843
|
+
additionalProperties: false
|
|
844
|
+
},
|
|
845
|
+
outputSchema: recallOutputSchema,
|
|
846
|
+
risk: "read",
|
|
847
|
+
namespace: "memory"
|
|
848
|
+
},
|
|
849
|
+
{
|
|
850
|
+
name: "expand",
|
|
851
|
+
description: "Read exact normalized session entries and nearby context as bounded lossless chunks. Call tools.call(next) to continue, or use guest-side memory.walk(args, visitor) to traverse complete reassembled entries.",
|
|
852
|
+
inputSchema: {
|
|
853
|
+
type: "object",
|
|
854
|
+
properties: {
|
|
855
|
+
session: { type: "string", description: "Exact session file path or unambiguous id." },
|
|
856
|
+
expectedSourceHash: {
|
|
857
|
+
type: "string",
|
|
858
|
+
description: "SHA-256 from a prior pointer; stale sources are refused."
|
|
859
|
+
},
|
|
860
|
+
expectedLineageFingerprint: {
|
|
861
|
+
type: "string",
|
|
862
|
+
description: "Active-lineage fingerprint from a prior pointer; changed leaves are refused."
|
|
863
|
+
},
|
|
864
|
+
branches: {
|
|
865
|
+
type: "string",
|
|
866
|
+
enum: ["active", "all"],
|
|
867
|
+
description: "Expand on the active parent-linked path (default) or across every branch."
|
|
868
|
+
},
|
|
869
|
+
indices: { type: "array", maxItems: EXPAND_MAX_EXACT_SELECTORS, items: { type: "number", minimum: 0 } },
|
|
870
|
+
entryIds: { type: "array", maxItems: EXPAND_MAX_EXACT_SELECTORS, items: { type: "string", maxLength: 512 } },
|
|
871
|
+
operationAddresses: { type: "array", maxItems: EXPAND_MAX_EXACT_SELECTORS, items: { type: "string", maxLength: 512 } },
|
|
872
|
+
entryRange: {
|
|
873
|
+
type: "object",
|
|
874
|
+
properties: {
|
|
875
|
+
first: { type: "number", minimum: 0 },
|
|
876
|
+
last: { type: "number", minimum: 0 }
|
|
877
|
+
},
|
|
878
|
+
required: ["first", "last"],
|
|
879
|
+
additionalProperties: false
|
|
880
|
+
},
|
|
881
|
+
before: {
|
|
882
|
+
type: "number",
|
|
883
|
+
minimum: 0,
|
|
884
|
+
maximum: EXPAND_MAX_CONTEXT,
|
|
885
|
+
default: 0,
|
|
886
|
+
description: "Entries before one exact selected anchor."
|
|
887
|
+
},
|
|
888
|
+
after: {
|
|
889
|
+
type: "number",
|
|
890
|
+
minimum: 0,
|
|
891
|
+
maximum: EXPAND_MAX_CONTEXT,
|
|
892
|
+
default: 0,
|
|
893
|
+
description: "Entries after one exact selected anchor."
|
|
894
|
+
},
|
|
895
|
+
entryOffset: {
|
|
896
|
+
type: "number",
|
|
897
|
+
minimum: 0,
|
|
898
|
+
description: "Continuation offset within the resolved selection; copy from next.args."
|
|
899
|
+
},
|
|
900
|
+
textOffset: {
|
|
901
|
+
type: "number",
|
|
902
|
+
minimum: 0,
|
|
903
|
+
description: "Continuation offset within the first returned entry; copy from next.args."
|
|
904
|
+
},
|
|
905
|
+
maxChars: {
|
|
906
|
+
type: "number",
|
|
907
|
+
minimum: 256,
|
|
908
|
+
maximum: EXPAND_MAX_CHARS,
|
|
909
|
+
default: EXPAND_DEFAULT_MAX_CHARS,
|
|
910
|
+
description: "Total entry-text characters returned in this chunk."
|
|
911
|
+
},
|
|
912
|
+
maxEntries: {
|
|
913
|
+
type: "number",
|
|
914
|
+
minimum: 1,
|
|
915
|
+
maximum: EXPAND_MAX_ENTRIES,
|
|
916
|
+
default: EXPAND_DEFAULT_MAX_ENTRIES,
|
|
917
|
+
description: "Maximum complete or partial entries returned in this chunk."
|
|
918
|
+
}
|
|
919
|
+
},
|
|
920
|
+
required: ["session"],
|
|
921
|
+
additionalProperties: false
|
|
922
|
+
},
|
|
923
|
+
outputSchema: expandOutputSchema,
|
|
924
|
+
risk: "read",
|
|
925
|
+
namespace: "memory"
|
|
926
|
+
},
|
|
927
|
+
{
|
|
928
|
+
name: "sessions",
|
|
929
|
+
description: "List known sessions in scope with id, file, cwd, mtime, entry count, and hot/cold tier.",
|
|
930
|
+
inputSchema: {
|
|
931
|
+
type: "object",
|
|
932
|
+
properties: {
|
|
933
|
+
scope: { type: "string" },
|
|
934
|
+
branches: {
|
|
935
|
+
type: "string",
|
|
936
|
+
enum: ["active", "all"],
|
|
937
|
+
description: "Count the active parent-linked path (default) or every branch."
|
|
938
|
+
},
|
|
939
|
+
limit: {
|
|
940
|
+
type: "number",
|
|
941
|
+
minimum: 1,
|
|
942
|
+
description: "Maximum sessions returned; capped at the internal session ceiling."
|
|
943
|
+
}
|
|
944
|
+
},
|
|
945
|
+
additionalProperties: false
|
|
946
|
+
},
|
|
947
|
+
outputSchema: sessionsOutputSchema,
|
|
948
|
+
risk: "read",
|
|
949
|
+
namespace: "memory"
|
|
950
|
+
}
|
|
951
|
+
];
|
|
952
|
+
var MEMORY_SCOPE_VALUE_ALIASES = {
|
|
953
|
+
cwd: "project",
|
|
954
|
+
repo: "project",
|
|
955
|
+
directory: "project",
|
|
956
|
+
folder: "project",
|
|
957
|
+
all: "global",
|
|
958
|
+
current: "session"
|
|
959
|
+
};
|
|
960
|
+
var MEMORY_ARG_NORMALIZATION = {
|
|
961
|
+
recall: { values: { scope: MEMORY_SCOPE_VALUE_ALIASES } },
|
|
962
|
+
sessions: { values: { scope: MEMORY_SCOPE_VALUE_ALIASES } }
|
|
963
|
+
};
|
|
964
|
+
var normalizeMemoryArgs = actionArgNormalizer(
|
|
965
|
+
() => descriptors,
|
|
966
|
+
MEMORY_ARG_NORMALIZATION
|
|
967
|
+
);
|
|
968
|
+
var parseBranches = (value, action) => {
|
|
969
|
+
if (value === void 0) return "active";
|
|
970
|
+
if (value === "active" || value === "all") return value;
|
|
971
|
+
throw new Error(`${action} branches must be "active" or "all"`);
|
|
972
|
+
};
|
|
973
|
+
var resolveIndexOptions = (config, agentDir, branches, liveBranchForFile) => ({
|
|
974
|
+
indexDir: config.indexDir ?? `${agentDir}/fabric/memory-index`,
|
|
975
|
+
maxEntryChars: config.maxEntryChars,
|
|
976
|
+
branches,
|
|
977
|
+
indexThinking: config.indexThinking ?? false,
|
|
978
|
+
indexToolOutput: config.indexToolOutput ?? true,
|
|
979
|
+
...liveBranchForFile ? { liveBranchForFile } : {},
|
|
980
|
+
hotSessions: config.hotSessions ?? DEFAULT_HOT_SESSIONS,
|
|
981
|
+
digestTerms: config.digestTerms ?? 200,
|
|
982
|
+
...config.maxColdVocabularyBytes === void 0 ? {} : { maxColdVocabularyBytes: config.maxColdVocabularyBytes },
|
|
983
|
+
...config.maxColdCacheBytes === void 0 ? {} : { maxColdCacheBytes: config.maxColdCacheBytes },
|
|
984
|
+
...config.maxSyncSessions === void 0 ? {} : { maxSyncSessions: config.maxSyncSessions },
|
|
985
|
+
...config.maxSyncSourceBytes === void 0 ? {} : { maxSyncSourceBytes: config.maxSyncSourceBytes },
|
|
986
|
+
...config.maxCacheCleanupFiles === void 0 ? {} : { maxCacheCleanupFiles: config.maxCacheCleanupFiles }
|
|
987
|
+
});
|
|
988
|
+
var resolveTierRefs = (refs, context) => {
|
|
989
|
+
const all = enumerateAllSessions(context.agentDir, Number.MAX_SAFE_INTEGER);
|
|
990
|
+
const known = new Set(all.map((ref) => ref.file));
|
|
991
|
+
for (const ref of refs) {
|
|
992
|
+
if (!known.has(ref.file)) all.push(ref);
|
|
993
|
+
}
|
|
994
|
+
return all;
|
|
995
|
+
};
|
|
996
|
+
var resolveRefs = (scope, context, boundedBrowse) => {
|
|
997
|
+
const effectiveScope = scope ?? "session";
|
|
998
|
+
const input = {
|
|
999
|
+
agentDir: context.agentDir,
|
|
1000
|
+
cwd: context.cwd,
|
|
1001
|
+
scope: effectiveScope,
|
|
1002
|
+
maxSessions: boundedBrowse ? context.config.maxSessions : Number.MAX_SAFE_INTEGER
|
|
1003
|
+
};
|
|
1004
|
+
if (context.sessionId) input.sessionId = context.sessionId;
|
|
1005
|
+
if (context.sessionFile) input.sessionFile = context.sessionFile;
|
|
1006
|
+
return resolveScope(input);
|
|
1007
|
+
};
|
|
1008
|
+
var liveBranchResolver = (context) => {
|
|
1009
|
+
if (!context.sessionFile || !context.getLiveBranch) return void 0;
|
|
1010
|
+
const current = path.resolve(context.sessionFile);
|
|
1011
|
+
return (sessionFile) => path.resolve(sessionFile) === current ? context.getLiveBranch?.() : void 0;
|
|
1012
|
+
};
|
|
1013
|
+
var stalePointerError = (sessionFile, expectedSourceHash, actualSourceHash, expectedLineageFingerprint, actualLineageFingerprint) => ({
|
|
1014
|
+
code: "stale_pointer",
|
|
1015
|
+
message: expectedLineageFingerprint !== void 0 && expectedLineageFingerprint !== actualLineageFingerprint ? "Session active lineage changed after the pointer was issued." : "Session source changed after the pointer was issued.",
|
|
1016
|
+
sessionFile,
|
|
1017
|
+
...expectedSourceHash === void 0 ? {} : { expectedSourceHash },
|
|
1018
|
+
actualSourceHash,
|
|
1019
|
+
...expectedLineageFingerprint === void 0 ? {} : { expectedLineageFingerprint },
|
|
1020
|
+
...actualLineageFingerprint === void 0 ? {} : { actualLineageFingerprint }
|
|
1021
|
+
});
|
|
1022
|
+
var addressError = (message, entryCount) => ({
|
|
1023
|
+
code: "index_out_of_bounds",
|
|
1024
|
+
message,
|
|
1025
|
+
...entryCount === void 0 ? {} : { entryCount }
|
|
1026
|
+
});
|
|
1027
|
+
var recallFailure = (error) => ({
|
|
1028
|
+
total: 0,
|
|
1029
|
+
hits: [],
|
|
1030
|
+
next: null,
|
|
1031
|
+
coverage: {
|
|
1032
|
+
complete: false,
|
|
1033
|
+
indexedSessions: 0,
|
|
1034
|
+
eligibleSessions: 0,
|
|
1035
|
+
staleSessions: 0,
|
|
1036
|
+
incompleteSessions: 0,
|
|
1037
|
+
reasons: [error.code]
|
|
1038
|
+
},
|
|
1039
|
+
error
|
|
1040
|
+
});
|
|
1041
|
+
var MemoryProvider = class {
|
|
1042
|
+
constructor(context) {
|
|
1043
|
+
this.context = context;
|
|
1044
|
+
}
|
|
1045
|
+
name = "memory";
|
|
1046
|
+
description = "Cross-session memory: a search engine over every OMP session timeline on this machine";
|
|
1047
|
+
recallContinuation;
|
|
1048
|
+
expansionSnapshots = /* @__PURE__ */ new Map();
|
|
1049
|
+
cachedRecallContinuation(key, observations) {
|
|
1050
|
+
const cached = this.recallContinuation;
|
|
1051
|
+
if (!cached || cached.key !== key) return void 0;
|
|
1052
|
+
if (!observations || Date.now() - cached.touchedAt > CONTINUATION_CACHE_TTL_MS || !sameSourceObservations(cached.observations, observations)) {
|
|
1053
|
+
this.recallContinuation = void 0;
|
|
1054
|
+
return void 0;
|
|
1055
|
+
}
|
|
1056
|
+
cached.touchedAt = Date.now();
|
|
1057
|
+
return cached;
|
|
1058
|
+
}
|
|
1059
|
+
rememberRecallContinuation(cached) {
|
|
1060
|
+
this.recallContinuation = cached;
|
|
1061
|
+
}
|
|
1062
|
+
forgetRecallContinuation(cached) {
|
|
1063
|
+
if (this.recallContinuation === cached) this.recallContinuation = void 0;
|
|
1064
|
+
}
|
|
1065
|
+
cachedExpansionSnapshot(file, branches, observation) {
|
|
1066
|
+
const key = expansionSnapshotKey(file, branches);
|
|
1067
|
+
const cached = this.expansionSnapshots.get(key);
|
|
1068
|
+
if (!cached) return void 0;
|
|
1069
|
+
if (!observation || Date.now() - cached.touchedAt > CONTINUATION_CACHE_TTL_MS || !sameSourceObservation(cached.observation, observation)) {
|
|
1070
|
+
this.expansionSnapshots.delete(key);
|
|
1071
|
+
return void 0;
|
|
1072
|
+
}
|
|
1073
|
+
cached.touchedAt = Date.now();
|
|
1074
|
+
this.expansionSnapshots.delete(key);
|
|
1075
|
+
this.expansionSnapshots.set(key, cached);
|
|
1076
|
+
return cached;
|
|
1077
|
+
}
|
|
1078
|
+
rememberExpansionSnapshot(snapshot) {
|
|
1079
|
+
const key = expansionSnapshotKey(snapshot.file, snapshot.branches);
|
|
1080
|
+
this.expansionSnapshots.delete(key);
|
|
1081
|
+
this.expansionSnapshots.set(key, snapshot);
|
|
1082
|
+
while (this.expansionSnapshots.size > EXPANSION_SNAPSHOT_LIMIT) {
|
|
1083
|
+
const oldest = this.expansionSnapshots.keys().next().value;
|
|
1084
|
+
if (oldest === void 0) break;
|
|
1085
|
+
this.expansionSnapshots.delete(oldest);
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
rememberExpansionSelection(snapshot, keys, selection) {
|
|
1089
|
+
for (const key of new Set(keys)) {
|
|
1090
|
+
snapshot.selections.delete(key);
|
|
1091
|
+
snapshot.selections.set(key, selection);
|
|
1092
|
+
}
|
|
1093
|
+
while (snapshot.selections.size > EXPANSION_SELECTION_LIMIT) {
|
|
1094
|
+
const oldest = snapshot.selections.keys().next().value;
|
|
1095
|
+
if (oldest === void 0) break;
|
|
1096
|
+
snapshot.selections.delete(oldest);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
forgetExpansionSnapshot(snapshot) {
|
|
1100
|
+
const key = expansionSnapshotKey(snapshot.file, snapshot.branches);
|
|
1101
|
+
if (this.expansionSnapshots.get(key) === snapshot) this.expansionSnapshots.delete(key);
|
|
1102
|
+
}
|
|
1103
|
+
async list(request, _context) {
|
|
1104
|
+
const query = request.query?.toLowerCase();
|
|
1105
|
+
return query ? descriptors.filter(
|
|
1106
|
+
(descriptor) => `${descriptor.name} ${descriptor.description}`.toLowerCase().includes(query)
|
|
1107
|
+
) : descriptors;
|
|
1108
|
+
}
|
|
1109
|
+
async describe(actionName, _context) {
|
|
1110
|
+
return descriptors.find((descriptor) => descriptor.name === actionName);
|
|
1111
|
+
}
|
|
1112
|
+
prepareArguments(actionName, args) {
|
|
1113
|
+
return normalizeMemoryArgs(actionName, args);
|
|
1114
|
+
}
|
|
1115
|
+
async invoke(actionName, args, invocationContext) {
|
|
1116
|
+
try {
|
|
1117
|
+
switch (actionName) {
|
|
1118
|
+
case "recall":
|
|
1119
|
+
return await this.recall(args, invocationContext);
|
|
1120
|
+
case "expand":
|
|
1121
|
+
return await this.expand(args);
|
|
1122
|
+
case "sessions":
|
|
1123
|
+
return await this.sessions(args);
|
|
1124
|
+
default:
|
|
1125
|
+
throw new Error(`Unknown memory action: ${actionName}`);
|
|
1126
|
+
}
|
|
1127
|
+
} catch (error) {
|
|
1128
|
+
if (error instanceof AmbiguousSessionError) {
|
|
1129
|
+
const detail = {
|
|
1130
|
+
code: error.code,
|
|
1131
|
+
message: error.message,
|
|
1132
|
+
session: error.session,
|
|
1133
|
+
candidates: error.candidates
|
|
1134
|
+
};
|
|
1135
|
+
if (actionName === "recall") return recallFailure(detail);
|
|
1136
|
+
if (actionName === "expand") return { entries: [], next: null, error: detail };
|
|
1137
|
+
return { error: detail };
|
|
1138
|
+
}
|
|
1139
|
+
throw error;
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
async recall(args, invocationContext) {
|
|
1143
|
+
const query = typeof args.query === "string" ? args.query : void 0;
|
|
1144
|
+
const rawQueryMode = args.queryMode;
|
|
1145
|
+
if (rawQueryMode !== void 0 && rawQueryMode !== "literal" && rawQueryMode !== "phrase" && rawQueryMode !== "regex") {
|
|
1146
|
+
throw new Error('memory.recall queryMode must be "literal", "phrase", or "regex"');
|
|
1147
|
+
}
|
|
1148
|
+
const queryMode = rawQueryMode === "phrase" ? "phrase" : rawQueryMode === "regex" ? "regex" : "literal";
|
|
1149
|
+
const rawQueryMatch = args.queryMatch;
|
|
1150
|
+
if (rawQueryMatch !== void 0 && rawQueryMatch !== "all" && rawQueryMatch !== "any") {
|
|
1151
|
+
throw new Error('memory.recall queryMatch must be "all" or "any"');
|
|
1152
|
+
}
|
|
1153
|
+
if (queryMode !== "literal" && rawQueryMatch !== void 0) {
|
|
1154
|
+
throw new Error("memory.recall queryMatch is only valid with literal queryMode");
|
|
1155
|
+
}
|
|
1156
|
+
const queryMatch = rawQueryMatch === "all" ? "all" : "any";
|
|
1157
|
+
const expectedSourceHash = typeof args.expectedSourceHash === "string" ? args.expectedSourceHash : void 0;
|
|
1158
|
+
const expectedLineageFingerprint = typeof args.expectedLineageFingerprint === "string" ? args.expectedLineageFingerprint : void 0;
|
|
1159
|
+
const branches = parseBranches(args.branches, "memory.recall");
|
|
1160
|
+
const scope = typeof args.scope === "string" ? args.scope : void 0;
|
|
1161
|
+
const role = typeof args.role === "string" ? args.role : void 0;
|
|
1162
|
+
const tool = typeof args.tool === "string" ? args.tool : void 0;
|
|
1163
|
+
const ref = typeof args.ref === "string" ? args.ref : void 0;
|
|
1164
|
+
const provider = typeof args.provider === "string" ? args.provider : void 0;
|
|
1165
|
+
const action = typeof args.action === "string" ? args.action : void 0;
|
|
1166
|
+
const rawOutcome = args.outcome;
|
|
1167
|
+
if (rawOutcome !== void 0 && rawOutcome !== "succeeded" && rawOutcome !== "failed" && rawOutcome !== "aborted" && rawOutcome !== "timed_out") {
|
|
1168
|
+
throw new Error("memory.recall outcome must be succeeded, failed, aborted, or timed_out");
|
|
1169
|
+
}
|
|
1170
|
+
const outcome = rawOutcome;
|
|
1171
|
+
const since = typeof args.since === "number" ? args.since : void 0;
|
|
1172
|
+
const until = typeof args.until === "number" ? args.until : void 0;
|
|
1173
|
+
const offset = typeof args.offset === "number" && args.offset >= 0 ? Math.floor(args.offset) : void 0;
|
|
1174
|
+
const pageSize = typeof args.pageSize === "number" && args.pageSize >= 1 ? Math.min(Math.floor(args.pageSize), RECALL_MAX_PAGE_SIZE) : RECALL_DEFAULT_PAGE_SIZE;
|
|
1175
|
+
const snippetChars = typeof args.snippetChars === "number" && args.snippetChars >= 80 ? Math.min(Math.floor(args.snippetChars), RECALL_MAX_SNIPPET_CHARS) : RECALL_DEFAULT_SNIPPET_CHARS;
|
|
1176
|
+
const refs = resolveRefs(scope, this.context, false);
|
|
1177
|
+
const liveResolver = liveBranchResolver(this.context);
|
|
1178
|
+
const options = resolveIndexOptions(
|
|
1179
|
+
this.context.config,
|
|
1180
|
+
this.context.agentDir,
|
|
1181
|
+
branches,
|
|
1182
|
+
liveResolver
|
|
1183
|
+
);
|
|
1184
|
+
const hydrate = scope?.trim().startsWith("session:") ?? false;
|
|
1185
|
+
if ((expectedSourceHash !== void 0 || expectedLineageFingerprint !== void 0) && !hydrate) {
|
|
1186
|
+
throw new Error("memory.recall integrity expectations require scope session:<id-or-path>");
|
|
1187
|
+
}
|
|
1188
|
+
const rawRange = args.entryRange;
|
|
1189
|
+
const entryRange = rawRange && typeof rawRange === "object" && !Array.isArray(rawRange) ? rawRange : void 0;
|
|
1190
|
+
const first = entryRange?.first;
|
|
1191
|
+
const last = entryRange?.last;
|
|
1192
|
+
if (first === void 0 !== (last === void 0)) {
|
|
1193
|
+
throw new Error("memory.recall entryRange requires both first and last");
|
|
1194
|
+
}
|
|
1195
|
+
if ((first !== void 0 || last !== void 0) && !hydrate) {
|
|
1196
|
+
throw new Error("memory.recall entryRange requires scope session:<id-or-path>");
|
|
1197
|
+
}
|
|
1198
|
+
if (first !== void 0 && (typeof first !== "number" || typeof last !== "number" || !Number.isSafeInteger(first) || !Number.isSafeInteger(last) || first < 0 || last < first)) {
|
|
1199
|
+
return recallFailure(addressError("Entry range requires safe integers with 0 <= first <= last."));
|
|
1200
|
+
}
|
|
1201
|
+
const selectedRange = typeof first === "number" && typeof last === "number" ? { first, last } : void 0;
|
|
1202
|
+
const filters = {};
|
|
1203
|
+
if (role) filters.role = role;
|
|
1204
|
+
if (tool) filters.tool = tool;
|
|
1205
|
+
if (ref) filters.ref = ref;
|
|
1206
|
+
if (provider) filters.provider = provider;
|
|
1207
|
+
if (action) filters.action = action;
|
|
1208
|
+
if (outcome) filters.outcome = outcome;
|
|
1209
|
+
if (since !== void 0) filters.since = since;
|
|
1210
|
+
if (until !== void 0) filters.until = until;
|
|
1211
|
+
const baseRequestArgs = {
|
|
1212
|
+
...query === void 0 ? {} : { query },
|
|
1213
|
+
queryMode,
|
|
1214
|
+
...queryMode === "literal" ? { queryMatch } : {},
|
|
1215
|
+
...expectedSourceHash ? { expectedSourceHash } : {},
|
|
1216
|
+
...expectedLineageFingerprint ? { expectedLineageFingerprint } : {},
|
|
1217
|
+
branches,
|
|
1218
|
+
scope: scope ?? "session",
|
|
1219
|
+
...offset === void 0 ? {} : { offset },
|
|
1220
|
+
pageSize,
|
|
1221
|
+
snippetChars,
|
|
1222
|
+
...role ? { role } : {},
|
|
1223
|
+
...tool ? { tool } : {},
|
|
1224
|
+
...ref ? { ref } : {},
|
|
1225
|
+
...provider ? { provider } : {},
|
|
1226
|
+
...action ? { action } : {},
|
|
1227
|
+
...outcome ? { outcome } : {},
|
|
1228
|
+
...since !== void 0 ? { since } : {},
|
|
1229
|
+
...until !== void 0 ? { until } : {},
|
|
1230
|
+
...selectedRange ? { entryRange: selectedRange } : {}
|
|
1231
|
+
};
|
|
1232
|
+
const updateProgress = (searchResult) => {
|
|
1233
|
+
invocationContext.update(
|
|
1234
|
+
searchResult.matchMode === "structural" ? `memory.recall: ${searchResult.matchedCount} structural matches` : searchResult.matchMode === "combined" ? `memory.recall: ${searchResult.matchedCount} filtered matches` : query ? `memory.recall: ${searchResult.matchedCount} matches` : `memory.recall: ${searchResult.matchedCount} recent entries`
|
|
1235
|
+
);
|
|
1236
|
+
};
|
|
1237
|
+
const observationsBefore = observeSources(refs, branches, liveResolver);
|
|
1238
|
+
const cached = offset === void 0 ? void 0 : this.cachedRecallContinuation(
|
|
1239
|
+
recallContinuationKey(baseRequestArgs),
|
|
1240
|
+
observationsBefore
|
|
1241
|
+
);
|
|
1242
|
+
if (cached) {
|
|
1243
|
+
const response2 = presentRecall({
|
|
1244
|
+
result: cached.result,
|
|
1245
|
+
...query === void 0 ? {} : { query },
|
|
1246
|
+
queryMode,
|
|
1247
|
+
coverage: cached.coverage,
|
|
1248
|
+
...offset === void 0 ? {} : { offset },
|
|
1249
|
+
pageSize,
|
|
1250
|
+
snippetChars,
|
|
1251
|
+
requestArgs: cached.requestArgs
|
|
1252
|
+
});
|
|
1253
|
+
const observationsAfterCachedPage = observeSources(refs, branches, liveResolver);
|
|
1254
|
+
if (observationsBefore && observationsAfterCachedPage && sameSourceObservations(observationsBefore, observationsAfterCachedPage)) {
|
|
1255
|
+
if (response2.next === null) this.forgetRecallContinuation(cached);
|
|
1256
|
+
updateProgress(cached.result);
|
|
1257
|
+
return response2;
|
|
1258
|
+
}
|
|
1259
|
+
this.forgetRecallContinuation(cached);
|
|
1260
|
+
}
|
|
1261
|
+
if (hydrate && refs[0]) {
|
|
1262
|
+
const state = fingerprintSource(refs[0].file);
|
|
1263
|
+
const lineage = reconstructSessionLineage(
|
|
1264
|
+
refs[0].file,
|
|
1265
|
+
branches,
|
|
1266
|
+
liveResolver?.(refs[0].file)
|
|
1267
|
+
);
|
|
1268
|
+
const sourceChanged = expectedSourceHash !== void 0 && state?.sourceHash !== expectedSourceHash;
|
|
1269
|
+
const lineageChanged = expectedLineageFingerprint !== void 0 && lineage.fingerprint !== expectedLineageFingerprint;
|
|
1270
|
+
if (state && (sourceChanged || lineageChanged)) {
|
|
1271
|
+
return recallFailure(stalePointerError(
|
|
1272
|
+
refs[0].file,
|
|
1273
|
+
expectedSourceHash,
|
|
1274
|
+
state.sourceHash,
|
|
1275
|
+
expectedLineageFingerprint,
|
|
1276
|
+
lineage.fingerprint
|
|
1277
|
+
));
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
const index = loadTieredIndex(
|
|
1281
|
+
refs,
|
|
1282
|
+
resolveTierRefs(refs, this.context),
|
|
1283
|
+
options,
|
|
1284
|
+
hydrate,
|
|
1285
|
+
selectedRange
|
|
1286
|
+
);
|
|
1287
|
+
const hydratedShard = index.shards[0];
|
|
1288
|
+
const hydratedSourceChanged = expectedSourceHash !== void 0 && hydratedShard?.sourceHash !== expectedSourceHash;
|
|
1289
|
+
const hydratedLineageChanged = expectedLineageFingerprint !== void 0 && hydratedShard?.lineageFingerprint !== expectedLineageFingerprint;
|
|
1290
|
+
if (hydrate && hydratedShard && (hydratedSourceChanged || hydratedLineageChanged)) {
|
|
1291
|
+
return recallFailure(stalePointerError(
|
|
1292
|
+
hydratedShard.sessionFile,
|
|
1293
|
+
expectedSourceHash,
|
|
1294
|
+
hydratedShard.sourceHash,
|
|
1295
|
+
expectedLineageFingerprint,
|
|
1296
|
+
hydratedShard.lineageFingerprint
|
|
1297
|
+
));
|
|
1298
|
+
}
|
|
1299
|
+
if (hydrate && selectedRange && index.shards[0] && selectedRange.last >= index.shards[0].totalEntryCount) {
|
|
1300
|
+
return recallFailure(addressError(
|
|
1301
|
+
`Entry range ends at ${selectedRange.last}, but the session has ${index.shards[0].totalEntryCount} entries.`,
|
|
1302
|
+
index.shards[0].totalEntryCount
|
|
1303
|
+
));
|
|
1304
|
+
}
|
|
1305
|
+
const searchQuery = {
|
|
1306
|
+
...query === void 0 ? {} : { query },
|
|
1307
|
+
queryMode,
|
|
1308
|
+
queryMatch,
|
|
1309
|
+
filters,
|
|
1310
|
+
regexLimits: {
|
|
1311
|
+
maxPatternBytes: this.context.config.regexMaxPatternBytes ?? DEFAULT_REGEX_MAX_PATTERN_BYTES,
|
|
1312
|
+
maxHaystackTerms: this.context.config.regexMaxHaystackTerms ?? DEFAULT_REGEX_MAX_HAYSTACK_TERMS,
|
|
1313
|
+
maxHaystackBytes: this.context.config.regexMaxHaystackBytes ?? DEFAULT_REGEX_MAX_HAYSTACK_BYTES,
|
|
1314
|
+
timeoutMs: this.context.config.regexTimeoutMs ?? DEFAULT_REGEX_TIMEOUT_MS
|
|
1315
|
+
}
|
|
1316
|
+
};
|
|
1317
|
+
const result = await searchMemoryIndex(index.shards, index.digests, searchQuery);
|
|
1318
|
+
const coverage = {
|
|
1319
|
+
...index.coverage,
|
|
1320
|
+
complete: index.coverage.complete && result.queryCoverage.complete,
|
|
1321
|
+
reasons: [.../* @__PURE__ */ new Set([...index.coverage.reasons, ...result.queryCoverage.reasons])].sort(),
|
|
1322
|
+
...result.queryCoverage.error ? { error: result.queryCoverage.error } : {}
|
|
1323
|
+
};
|
|
1324
|
+
const soleRef = refs.length === 1 ? refs[0] : void 0;
|
|
1325
|
+
const soleShard = soleRef ? index.shards.find((candidate) => candidate.sessionFile === soleRef.file) : void 0;
|
|
1326
|
+
const soleDigest = soleRef ? index.digests.find((candidate) => candidate.file === soleRef.file) : void 0;
|
|
1327
|
+
const continuationBinding = soleRef && (soleShard?.sourceHash || soleDigest?.sourceHash) ? {
|
|
1328
|
+
file: soleRef.file,
|
|
1329
|
+
sourceHash: soleShard?.sourceHash ?? soleDigest.sourceHash,
|
|
1330
|
+
lineageFingerprint: soleShard?.lineageFingerprint ?? soleDigest.lineageFingerprint
|
|
1331
|
+
} : void 0;
|
|
1332
|
+
const requestArgs = {
|
|
1333
|
+
...baseRequestArgs,
|
|
1334
|
+
...expectedSourceHash ?? continuationBinding?.sourceHash ? { expectedSourceHash: expectedSourceHash ?? continuationBinding.sourceHash } : {},
|
|
1335
|
+
...expectedLineageFingerprint ?? continuationBinding?.lineageFingerprint ? {
|
|
1336
|
+
expectedLineageFingerprint: expectedLineageFingerprint ?? continuationBinding.lineageFingerprint
|
|
1337
|
+
} : {},
|
|
1338
|
+
scope: continuationBinding ? `session:${continuationBinding.file}` : baseRequestArgs.scope ?? "session"
|
|
1339
|
+
};
|
|
1340
|
+
const response = presentRecall({
|
|
1341
|
+
result,
|
|
1342
|
+
...query === void 0 ? {} : { query },
|
|
1343
|
+
queryMode,
|
|
1344
|
+
coverage,
|
|
1345
|
+
...offset === void 0 ? {} : { offset },
|
|
1346
|
+
pageSize,
|
|
1347
|
+
snippetChars,
|
|
1348
|
+
requestArgs
|
|
1349
|
+
});
|
|
1350
|
+
const observationsAfter = observeSources(refs, branches, liveResolver);
|
|
1351
|
+
if (response.next !== null && observationsBefore && observationsAfter && sameSourceObservations(observationsBefore, observationsAfter)) {
|
|
1352
|
+
this.rememberRecallContinuation({
|
|
1353
|
+
key: recallContinuationKey(requestArgs),
|
|
1354
|
+
result,
|
|
1355
|
+
coverage,
|
|
1356
|
+
requestArgs,
|
|
1357
|
+
observations: observationsAfter,
|
|
1358
|
+
touchedAt: Date.now()
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
updateProgress(result);
|
|
1362
|
+
return response;
|
|
1363
|
+
}
|
|
1364
|
+
async expand(args) {
|
|
1365
|
+
const session = typeof args.session === "string" ? args.session : "";
|
|
1366
|
+
const expectedSourceHash = typeof args.expectedSourceHash === "string" ? args.expectedSourceHash : void 0;
|
|
1367
|
+
const expectedLineageFingerprint = typeof args.expectedLineageFingerprint === "string" ? args.expectedLineageFingerprint : void 0;
|
|
1368
|
+
const branches = parseBranches(args.branches, "memory.expand");
|
|
1369
|
+
const rawIndices = args.indices;
|
|
1370
|
+
if (rawIndices !== void 0 && !Array.isArray(rawIndices)) {
|
|
1371
|
+
throw new Error("memory.expand indices must be an array");
|
|
1372
|
+
}
|
|
1373
|
+
if (Array.isArray(rawIndices) && !rawIndices.every((index) => typeof index === "number" && Number.isSafeInteger(index) && index >= 0)) {
|
|
1374
|
+
return { session, error: addressError("Every entry index must be a non-negative safe integer."), entries: [] };
|
|
1375
|
+
}
|
|
1376
|
+
const indices = rawIndices ?? [];
|
|
1377
|
+
const entryIds = Array.isArray(args.entryIds) ? args.entryIds.filter(
|
|
1378
|
+
(entryId) => typeof entryId === "string" && entryId.length > 0
|
|
1379
|
+
) : [];
|
|
1380
|
+
const operationAddresses = Array.isArray(args.operationAddresses) ? args.operationAddresses.filter(
|
|
1381
|
+
(address) => typeof address === "string" && address.length > 0
|
|
1382
|
+
) : [];
|
|
1383
|
+
if (indices.length + entryIds.length + operationAddresses.length > EXPAND_MAX_EXACT_SELECTORS) {
|
|
1384
|
+
throw new Error(`memory.expand accepts at most ${EXPAND_MAX_EXACT_SELECTORS} exact selectors per call`);
|
|
1385
|
+
}
|
|
1386
|
+
const rawRange = args.entryRange;
|
|
1387
|
+
const rangeRecord = rawRange && typeof rawRange === "object" && !Array.isArray(rawRange) ? rawRange : void 0;
|
|
1388
|
+
const first = rangeRecord?.first;
|
|
1389
|
+
const last = rangeRecord?.last;
|
|
1390
|
+
if (!session) throw new Error("memory.expand requires a session");
|
|
1391
|
+
if (first === void 0 !== (last === void 0)) {
|
|
1392
|
+
throw new Error("memory.expand entryRange requires both first and last");
|
|
1393
|
+
}
|
|
1394
|
+
if (first !== void 0 && (typeof first !== "number" || typeof last !== "number" || !Number.isSafeInteger(first) || !Number.isSafeInteger(last) || first < 0 || last < first)) {
|
|
1395
|
+
return { session, error: addressError("Entry range requires safe integers with 0 <= first <= last."), entries: [] };
|
|
1396
|
+
}
|
|
1397
|
+
const numeric = (value, fallback, maximum) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? Math.min(value, maximum) : fallback;
|
|
1398
|
+
const before = numeric(args.before, 0, EXPAND_MAX_CONTEXT);
|
|
1399
|
+
const after = numeric(args.after, 0, EXPAND_MAX_CONTEXT);
|
|
1400
|
+
const entryOffset = numeric(args.entryOffset, 0, Number.MAX_SAFE_INTEGER);
|
|
1401
|
+
const textOffset = numeric(args.textOffset, 0, Number.MAX_SAFE_INTEGER);
|
|
1402
|
+
const maxChars = Math.max(256, numeric(args.maxChars, EXPAND_DEFAULT_MAX_CHARS, EXPAND_MAX_CHARS));
|
|
1403
|
+
const maxEntries = Math.max(1, numeric(args.maxEntries, EXPAND_DEFAULT_MAX_ENTRIES, EXPAND_MAX_ENTRIES));
|
|
1404
|
+
const ref = resolveSessionTarget(this.context.agentDir, session);
|
|
1405
|
+
if (!ref) {
|
|
1406
|
+
return {
|
|
1407
|
+
session,
|
|
1408
|
+
error: { code: "session_not_found", message: `Session not found: ${session}` },
|
|
1409
|
+
entries: []
|
|
1410
|
+
};
|
|
1411
|
+
}
|
|
1412
|
+
const liveResolver = liveBranchResolver(this.context);
|
|
1413
|
+
const observedLiveBranch = branches === "active" ? liveResolver?.(ref.file) : void 0;
|
|
1414
|
+
const observedSource = observeSource(ref.file, branches, observedLiveBranch);
|
|
1415
|
+
let snapshot = this.cachedExpansionSnapshot(ref.file, branches, observedSource);
|
|
1416
|
+
if (snapshot) {
|
|
1417
|
+
const sourceChanged = expectedSourceHash !== void 0 && snapshot.sourceHash !== expectedSourceHash;
|
|
1418
|
+
const lineageChanged = expectedLineageFingerprint !== void 0 && snapshot.lineageFingerprint !== expectedLineageFingerprint;
|
|
1419
|
+
if (sourceChanged || lineageChanged) {
|
|
1420
|
+
return {
|
|
1421
|
+
session: ref.file,
|
|
1422
|
+
branches,
|
|
1423
|
+
error: stalePointerError(
|
|
1424
|
+
ref.file,
|
|
1425
|
+
expectedSourceHash,
|
|
1426
|
+
snapshot.sourceHash,
|
|
1427
|
+
expectedLineageFingerprint,
|
|
1428
|
+
snapshot.lineageFingerprint
|
|
1429
|
+
),
|
|
1430
|
+
entries: []
|
|
1431
|
+
};
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
if (!snapshot) {
|
|
1435
|
+
const initialState = fingerprintSource(ref.file);
|
|
1436
|
+
if (!initialState) {
|
|
1437
|
+
return {
|
|
1438
|
+
session: ref.file,
|
|
1439
|
+
error: { code: "source_unavailable", message: `Session source is unavailable: ${ref.file}` },
|
|
1440
|
+
entries: []
|
|
1441
|
+
};
|
|
1442
|
+
}
|
|
1443
|
+
const initialLiveBranch = branches === "active" ? liveResolver?.(ref.file) : void 0;
|
|
1444
|
+
const initialLineage = reconstructSessionLineage(
|
|
1445
|
+
ref.file,
|
|
1446
|
+
branches,
|
|
1447
|
+
initialLiveBranch
|
|
1448
|
+
);
|
|
1449
|
+
const sourceChanged = expectedSourceHash !== void 0 && initialState.sourceHash !== expectedSourceHash;
|
|
1450
|
+
const lineageChanged = expectedLineageFingerprint !== void 0 && initialLineage.fingerprint !== expectedLineageFingerprint;
|
|
1451
|
+
if (sourceChanged || lineageChanged) {
|
|
1452
|
+
return {
|
|
1453
|
+
session: ref.file,
|
|
1454
|
+
branches,
|
|
1455
|
+
error: stalePointerError(
|
|
1456
|
+
ref.file,
|
|
1457
|
+
expectedSourceHash,
|
|
1458
|
+
initialState.sourceHash,
|
|
1459
|
+
expectedLineageFingerprint,
|
|
1460
|
+
initialLineage.fingerprint
|
|
1461
|
+
),
|
|
1462
|
+
entries: []
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
const normalized = normalizeSession(
|
|
1466
|
+
ref.file,
|
|
1467
|
+
Number.MAX_SAFE_INTEGER,
|
|
1468
|
+
{
|
|
1469
|
+
lineage: initialLineage,
|
|
1470
|
+
indexThinking: true,
|
|
1471
|
+
indexToolOutput: true
|
|
1472
|
+
}
|
|
1473
|
+
).entries;
|
|
1474
|
+
const finalState2 = fingerprintSource(ref.file);
|
|
1475
|
+
const finalLiveBranch = branches === "active" ? liveResolver?.(ref.file) : void 0;
|
|
1476
|
+
const finalLineage2 = reconstructSessionLineage(
|
|
1477
|
+
ref.file,
|
|
1478
|
+
branches,
|
|
1479
|
+
finalLiveBranch
|
|
1480
|
+
);
|
|
1481
|
+
const finalObservation = observeSource(ref.file, branches, finalLiveBranch);
|
|
1482
|
+
if (!finalState2 || !finalObservation || finalState2.sourceHash !== initialState.sourceHash || finalLineage2.fingerprint !== initialLineage.fingerprint) {
|
|
1483
|
+
return {
|
|
1484
|
+
session: ref.file,
|
|
1485
|
+
error: stalePointerError(
|
|
1486
|
+
ref.file,
|
|
1487
|
+
expectedSourceHash ?? initialState.sourceHash,
|
|
1488
|
+
finalState2?.sourceHash ?? "",
|
|
1489
|
+
expectedLineageFingerprint ?? initialLineage.fingerprint,
|
|
1490
|
+
finalLineage2.fingerprint
|
|
1491
|
+
),
|
|
1492
|
+
entries: []
|
|
1493
|
+
};
|
|
1494
|
+
}
|
|
1495
|
+
snapshot = {
|
|
1496
|
+
file: ref.file,
|
|
1497
|
+
branches,
|
|
1498
|
+
sourceHash: finalState2.sourceHash,
|
|
1499
|
+
lineageFingerprint: finalLineage2.fingerprint,
|
|
1500
|
+
observation: finalObservation,
|
|
1501
|
+
entries: normalized,
|
|
1502
|
+
selections: /* @__PURE__ */ new Map(),
|
|
1503
|
+
touchedAt: Date.now()
|
|
1504
|
+
};
|
|
1505
|
+
}
|
|
1506
|
+
const entryCount = snapshot.entries.length;
|
|
1507
|
+
const outOfBounds = indices.find((index) => index >= entryCount);
|
|
1508
|
+
if (outOfBounds !== void 0) {
|
|
1509
|
+
return {
|
|
1510
|
+
session: ref.file,
|
|
1511
|
+
error: addressError(`Entry index ${outOfBounds} is outside 0..${Math.max(0, entryCount - 1)}.`, entryCount),
|
|
1512
|
+
entries: []
|
|
1513
|
+
};
|
|
1514
|
+
}
|
|
1515
|
+
if (typeof last === "number" && last >= entryCount) {
|
|
1516
|
+
return {
|
|
1517
|
+
session: ref.file,
|
|
1518
|
+
error: addressError(`Entry range ends at ${last}, but the session has ${entryCount} entries.`, entryCount),
|
|
1519
|
+
entries: []
|
|
1520
|
+
};
|
|
1521
|
+
}
|
|
1522
|
+
if (indices.length === 0 && entryIds.length === 0 && operationAddresses.length === 0 && (first === void 0 || last === void 0)) {
|
|
1523
|
+
if (before > 0 || after > 0) {
|
|
1524
|
+
throw new Error("memory.expand before/after requires one selected anchor");
|
|
1525
|
+
}
|
|
1526
|
+
this.forgetExpansionSnapshot(snapshot);
|
|
1527
|
+
return {
|
|
1528
|
+
session: ref.file,
|
|
1529
|
+
sourceHash: snapshot.sourceHash,
|
|
1530
|
+
branches,
|
|
1531
|
+
lineageFingerprint: snapshot.lineageFingerprint,
|
|
1532
|
+
entryCount,
|
|
1533
|
+
entries: [],
|
|
1534
|
+
next: null
|
|
1535
|
+
};
|
|
1536
|
+
}
|
|
1537
|
+
const requestedSelection = {};
|
|
1538
|
+
if (indices.length > 0) requestedSelection.indices = indices;
|
|
1539
|
+
if (entryIds.length > 0) requestedSelection.entryIds = entryIds;
|
|
1540
|
+
if (operationAddresses.length > 0) requestedSelection.operationAddresses = operationAddresses;
|
|
1541
|
+
if (typeof first === "number" && typeof last === "number") {
|
|
1542
|
+
requestedSelection.entryRange = { first, last };
|
|
1543
|
+
}
|
|
1544
|
+
const requestedWithContext = {
|
|
1545
|
+
...requestedSelection,
|
|
1546
|
+
...before > 0 ? { before } : {},
|
|
1547
|
+
...after > 0 ? { after } : {}
|
|
1548
|
+
};
|
|
1549
|
+
const requestedKey = expansionSelectionKey(requestedWithContext);
|
|
1550
|
+
let resolved = snapshot.selections.get(requestedKey);
|
|
1551
|
+
if (!resolved) {
|
|
1552
|
+
let expansion = expandSessionEntriesChecked(snapshot.entries, requestedSelection);
|
|
1553
|
+
if ("error" in expansion) {
|
|
1554
|
+
return {
|
|
1555
|
+
session: ref.file,
|
|
1556
|
+
sourceHash: snapshot.sourceHash,
|
|
1557
|
+
branches,
|
|
1558
|
+
lineageFingerprint: snapshot.lineageFingerprint,
|
|
1559
|
+
error: expansion.error,
|
|
1560
|
+
entries: []
|
|
1561
|
+
};
|
|
1562
|
+
}
|
|
1563
|
+
let anchorIndex2 = null;
|
|
1564
|
+
let canonical;
|
|
1565
|
+
if (before > 0 || after > 0) {
|
|
1566
|
+
if (expansion.expanded.length !== 1) {
|
|
1567
|
+
throw new Error("memory.expand before/after requires exactly one resolved anchor");
|
|
1568
|
+
}
|
|
1569
|
+
anchorIndex2 = expansion.expanded[0].index;
|
|
1570
|
+
const contextRange = {
|
|
1571
|
+
first: Math.max(0, anchorIndex2 - before),
|
|
1572
|
+
last: Math.min(Math.max(0, entryCount - 1), anchorIndex2 + after)
|
|
1573
|
+
};
|
|
1574
|
+
canonical = requestedWithContext;
|
|
1575
|
+
expansion = expandSessionEntriesChecked(snapshot.entries, { entryRange: contextRange });
|
|
1576
|
+
if ("error" in expansion) {
|
|
1577
|
+
return {
|
|
1578
|
+
session: ref.file,
|
|
1579
|
+
sourceHash: snapshot.sourceHash,
|
|
1580
|
+
branches,
|
|
1581
|
+
lineageFingerprint: snapshot.lineageFingerprint,
|
|
1582
|
+
error: expansion.error,
|
|
1583
|
+
entries: []
|
|
1584
|
+
};
|
|
1585
|
+
}
|
|
1586
|
+
} else if (requestedSelection.entryRange) {
|
|
1587
|
+
canonical = { entryRange: requestedSelection.entryRange };
|
|
1588
|
+
} else {
|
|
1589
|
+
canonical = { indices: expansion.expanded.map((entry) => entry.index) };
|
|
1590
|
+
}
|
|
1591
|
+
resolved = { entries: expansion.expanded, canonical, anchorIndex: anchorIndex2 };
|
|
1592
|
+
this.rememberExpansionSelection(
|
|
1593
|
+
snapshot,
|
|
1594
|
+
[requestedKey, expansionSelectionKey(canonical)],
|
|
1595
|
+
resolved
|
|
1596
|
+
);
|
|
1597
|
+
}
|
|
1598
|
+
const selected = resolved.entries;
|
|
1599
|
+
const canonicalSelection = resolved.canonical;
|
|
1600
|
+
const anchorIndex = resolved.anchorIndex;
|
|
1601
|
+
const finalState = snapshot;
|
|
1602
|
+
const finalLineage = { fingerprint: snapshot.lineageFingerprint };
|
|
1603
|
+
if (entryOffset > selected.length) {
|
|
1604
|
+
return {
|
|
1605
|
+
session: ref.file,
|
|
1606
|
+
error: addressError(`Entry offset ${entryOffset} is outside 0..${selected.length}.`, selected.length),
|
|
1607
|
+
entries: []
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1610
|
+
if (entryOffset < selected.length && textOffset > selected[entryOffset].text.length) {
|
|
1611
|
+
return {
|
|
1612
|
+
session: ref.file,
|
|
1613
|
+
error: {
|
|
1614
|
+
code: "text_offset_out_of_bounds",
|
|
1615
|
+
message: `Text offset ${textOffset} exceeds entry #${selected[entryOffset].index} length ${selected[entryOffset].text.length}.`,
|
|
1616
|
+
textLength: selected[entryOffset].text.length
|
|
1617
|
+
},
|
|
1618
|
+
entries: []
|
|
1619
|
+
};
|
|
1620
|
+
}
|
|
1621
|
+
const bounded = (value, maximum = 512) => value === null || value.length <= maximum ? value : `${value.slice(0, Math.max(1, maximum - 1))}\u2026`;
|
|
1622
|
+
const compactStructure = (value) => {
|
|
1623
|
+
if (value === void 0) return void 0;
|
|
1624
|
+
const serialized = JSON.stringify(value);
|
|
1625
|
+
return serialized.length <= 2e3 ? value : void 0;
|
|
1626
|
+
};
|
|
1627
|
+
const output = [];
|
|
1628
|
+
const cursors = [];
|
|
1629
|
+
let position = entryOffset;
|
|
1630
|
+
let currentTextOffset = textOffset;
|
|
1631
|
+
let remainingChars = maxChars;
|
|
1632
|
+
while (position < selected.length && output.length < maxEntries && remainingChars > 0) {
|
|
1633
|
+
const entry = selected[position];
|
|
1634
|
+
let end = Math.min(entry.text.length, currentTextOffset + remainingChars);
|
|
1635
|
+
if (end < entry.text.length && end > currentTextOffset && entry.text.charCodeAt(end) >= 56320 && entry.text.charCodeAt(end) <= 57343) {
|
|
1636
|
+
end -= 1;
|
|
1637
|
+
}
|
|
1638
|
+
if (end === currentTextOffset && currentTextOffset < entry.text.length) {
|
|
1639
|
+
end = Math.min(entry.text.length, currentTextOffset + 2);
|
|
1640
|
+
}
|
|
1641
|
+
const chunk = entry.text.slice(currentTextOffset, end);
|
|
1642
|
+
const textComplete = end >= entry.text.length;
|
|
1643
|
+
const operation = compactStructure(entry.operation);
|
|
1644
|
+
const branchFact = compactStructure(entry.branchFact);
|
|
1645
|
+
output.push({
|
|
1646
|
+
index: entry.index,
|
|
1647
|
+
entryId: bounded(entry.entryId),
|
|
1648
|
+
parentId: bounded(entry.parentId),
|
|
1649
|
+
type: bounded(entry.type),
|
|
1650
|
+
role: bounded(entry.role),
|
|
1651
|
+
timestamp: entry.timestamp,
|
|
1652
|
+
isError: entry.isError,
|
|
1653
|
+
...anchorIndex !== null ? { anchor: entry.index === anchorIndex } : {},
|
|
1654
|
+
text: chunk,
|
|
1655
|
+
textRange: {
|
|
1656
|
+
start: currentTextOffset,
|
|
1657
|
+
end,
|
|
1658
|
+
total: entry.text.length,
|
|
1659
|
+
complete: textComplete
|
|
1660
|
+
},
|
|
1661
|
+
...entry.parentEntryId !== void 0 ? { parentEntryId: bounded(entry.parentEntryId) } : {},
|
|
1662
|
+
...entry.operationAddress ? { operationAddress: bounded(entry.operationAddress) } : {},
|
|
1663
|
+
...entry.toolName ? { tool: bounded(entry.toolName) } : {},
|
|
1664
|
+
...entry.ref ? { ref: bounded(entry.ref) } : {},
|
|
1665
|
+
...entry.provider ? { provider: bounded(entry.provider) } : {},
|
|
1666
|
+
...entry.action ? { action: bounded(entry.action) } : {},
|
|
1667
|
+
...entry.outcome ? { outcome: entry.outcome } : {},
|
|
1668
|
+
...entry.filesTouched ? { filesTouched: entry.filesTouched.slice(0, 20).map((file) => bounded(file, 1024)) } : {},
|
|
1669
|
+
...operation !== void 0 ? { operation } : {},
|
|
1670
|
+
...branchFact !== void 0 ? { branchFact } : {},
|
|
1671
|
+
...entry.operation !== void 0 && operation === void 0 || entry.branchFact !== void 0 && branchFact === void 0 ? { structuredTruncated: true } : {},
|
|
1672
|
+
...entry.factAddress ? { factAddress: bounded(entry.factAddress) } : {},
|
|
1673
|
+
...entry.carrierEntryId ? { carrierEntryId: bounded(entry.carrierEntryId) } : {},
|
|
1674
|
+
...entry.carrierParentId !== void 0 ? { carrierParentId: bounded(entry.carrierParentId) } : {},
|
|
1675
|
+
...entry.carrierFromId !== void 0 ? { carrierFromId: bounded(entry.carrierFromId) } : {}
|
|
1676
|
+
});
|
|
1677
|
+
remainingChars -= chunk.length;
|
|
1678
|
+
if (!textComplete) {
|
|
1679
|
+
currentTextOffset = end;
|
|
1680
|
+
cursors.push({ position, textOffset: currentTextOffset });
|
|
1681
|
+
break;
|
|
1682
|
+
}
|
|
1683
|
+
position += 1;
|
|
1684
|
+
currentTextOffset = 0;
|
|
1685
|
+
cursors.push({ position, textOffset: 0 });
|
|
1686
|
+
}
|
|
1687
|
+
const responseAt = (records, cursor2) => {
|
|
1688
|
+
const hasNext = cursor2.position < selected.length;
|
|
1689
|
+
const nextArgs = hasNext ? {
|
|
1690
|
+
session: ref.file,
|
|
1691
|
+
expectedSourceHash: finalState.sourceHash,
|
|
1692
|
+
expectedLineageFingerprint: finalLineage.fingerprint,
|
|
1693
|
+
branches,
|
|
1694
|
+
...canonicalSelection,
|
|
1695
|
+
entryOffset: cursor2.position,
|
|
1696
|
+
...cursor2.textOffset > 0 ? { textOffset: cursor2.textOffset } : {},
|
|
1697
|
+
maxChars,
|
|
1698
|
+
maxEntries
|
|
1699
|
+
} : null;
|
|
1700
|
+
return {
|
|
1701
|
+
session: ref.file,
|
|
1702
|
+
sourceHash: finalState.sourceHash,
|
|
1703
|
+
branches,
|
|
1704
|
+
lineageFingerprint: finalLineage.fingerprint,
|
|
1705
|
+
entryCount,
|
|
1706
|
+
entries: records,
|
|
1707
|
+
next: nextArgs ? { ref: "memory.expand", args: nextArgs } : null
|
|
1708
|
+
};
|
|
1709
|
+
};
|
|
1710
|
+
let cursor = { position, textOffset: currentTextOffset };
|
|
1711
|
+
let response = responseAt(output, cursor);
|
|
1712
|
+
while (output.length > 1 && JSON.stringify(response).length > RECALL_MAX_RESPONSE_CHARS) {
|
|
1713
|
+
output.pop();
|
|
1714
|
+
cursors.pop();
|
|
1715
|
+
cursor = cursors.at(-1) ?? { position: entryOffset, textOffset };
|
|
1716
|
+
response = responseAt(output, cursor);
|
|
1717
|
+
}
|
|
1718
|
+
if (output.length === 1 && JSON.stringify(response).length > RECALL_MAX_RESPONSE_CHARS) {
|
|
1719
|
+
const record = output[0];
|
|
1720
|
+
const range = record.textRange;
|
|
1721
|
+
const chunk = record.text;
|
|
1722
|
+
const excess = JSON.stringify(response).length - RECALL_MAX_RESPONSE_CHARS;
|
|
1723
|
+
let keep = Math.max(1, chunk.length - excess - 256);
|
|
1724
|
+
if (keep < chunk.length && keep > 0 && chunk.charCodeAt(keep) >= 56320 && chunk.charCodeAt(keep) <= 57343) {
|
|
1725
|
+
keep -= 1;
|
|
1726
|
+
}
|
|
1727
|
+
if (keep > 0 && keep < chunk.length) {
|
|
1728
|
+
record.text = chunk.slice(0, keep);
|
|
1729
|
+
range.end = range.start + keep;
|
|
1730
|
+
range.complete = false;
|
|
1731
|
+
cursor = { position: entryOffset, textOffset: range.end };
|
|
1732
|
+
response = responseAt(output, cursor);
|
|
1733
|
+
}
|
|
1734
|
+
if (JSON.stringify(response).length > RECALL_MAX_RESPONSE_CHARS) {
|
|
1735
|
+
delete record.operation;
|
|
1736
|
+
delete record.branchFact;
|
|
1737
|
+
if (Array.isArray(record.filesTouched)) {
|
|
1738
|
+
record.filesTouched = record.filesTouched.slice(0, 4).map((file) => bounded(String(file), 256));
|
|
1739
|
+
}
|
|
1740
|
+
record.structuredTruncated = true;
|
|
1741
|
+
response = responseAt(output, cursor);
|
|
1742
|
+
}
|
|
1743
|
+
if (JSON.stringify(response).length > RECALL_MAX_RESPONSE_CHARS) {
|
|
1744
|
+
const current = String(record.text);
|
|
1745
|
+
const firstCodePointChars = (current.codePointAt(0) ?? 0) > 65535 ? 2 : 1;
|
|
1746
|
+
const minimalText = current.slice(0, Math.min(current.length, firstCodePointChars));
|
|
1747
|
+
const minimalRange = record.textRange;
|
|
1748
|
+
minimalRange.end = minimalRange.start + minimalText.length;
|
|
1749
|
+
minimalRange.complete = minimalRange.end >= minimalRange.total;
|
|
1750
|
+
output[0] = {
|
|
1751
|
+
index: record.index,
|
|
1752
|
+
entryId: record.entryId,
|
|
1753
|
+
parentId: record.parentId,
|
|
1754
|
+
type: record.type,
|
|
1755
|
+
role: record.role,
|
|
1756
|
+
timestamp: record.timestamp,
|
|
1757
|
+
isError: record.isError,
|
|
1758
|
+
...record.anchor !== void 0 ? { anchor: record.anchor } : {},
|
|
1759
|
+
text: minimalText,
|
|
1760
|
+
textRange: minimalRange,
|
|
1761
|
+
structuredTruncated: true
|
|
1762
|
+
};
|
|
1763
|
+
cursor = minimalRange.complete ? { position: entryOffset + 1, textOffset: 0 } : { position: entryOffset, textOffset: minimalRange.end };
|
|
1764
|
+
response = responseAt(output, cursor);
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
const endingLiveBranch = branches === "active" ? liveResolver?.(ref.file) : void 0;
|
|
1768
|
+
const endingObservation = observeSource(ref.file, branches, endingLiveBranch);
|
|
1769
|
+
if (!endingObservation || !sameSourceObservation(snapshot.observation, endingObservation)) {
|
|
1770
|
+
this.forgetExpansionSnapshot(snapshot);
|
|
1771
|
+
const actualState = fingerprintSource(ref.file);
|
|
1772
|
+
const actualLineage = reconstructSessionLineage(ref.file, branches, endingLiveBranch);
|
|
1773
|
+
if (!actualState || !endingObservation || actualState.sourceHash !== snapshot.sourceHash || actualLineage.fingerprint !== snapshot.lineageFingerprint) {
|
|
1774
|
+
return {
|
|
1775
|
+
session: ref.file,
|
|
1776
|
+
error: stalePointerError(
|
|
1777
|
+
ref.file,
|
|
1778
|
+
expectedSourceHash ?? snapshot.sourceHash,
|
|
1779
|
+
actualState?.sourceHash ?? "",
|
|
1780
|
+
expectedLineageFingerprint ?? snapshot.lineageFingerprint,
|
|
1781
|
+
actualLineage.fingerprint
|
|
1782
|
+
),
|
|
1783
|
+
entries: []
|
|
1784
|
+
};
|
|
1785
|
+
}
|
|
1786
|
+
snapshot.observation = endingObservation;
|
|
1787
|
+
}
|
|
1788
|
+
if (response.next === null) {
|
|
1789
|
+
this.forgetExpansionSnapshot(snapshot);
|
|
1790
|
+
} else {
|
|
1791
|
+
snapshot.touchedAt = Date.now();
|
|
1792
|
+
this.rememberExpansionSnapshot(snapshot);
|
|
1793
|
+
}
|
|
1794
|
+
return response;
|
|
1795
|
+
}
|
|
1796
|
+
async sessions(args) {
|
|
1797
|
+
const scope = typeof args.scope === "string" ? args.scope : void 0;
|
|
1798
|
+
const branches = parseBranches(args.branches, "memory.sessions");
|
|
1799
|
+
const limit = typeof args.limit === "number" && Number.isSafeInteger(args.limit) && args.limit >= 1 ? Math.min(args.limit, SESSIONS_MAX) : SESSIONS_MAX;
|
|
1800
|
+
const refs = resolveRefs(scope, this.context, true).slice(0, limit);
|
|
1801
|
+
const options = resolveIndexOptions(
|
|
1802
|
+
this.context.config,
|
|
1803
|
+
this.context.agentDir,
|
|
1804
|
+
branches,
|
|
1805
|
+
liveBranchResolver(this.context)
|
|
1806
|
+
);
|
|
1807
|
+
const index = loadTieredIndex(refs, resolveTierRefs(refs, this.context), options);
|
|
1808
|
+
const shards = new Map(index.shards.map((shard) => [shard.sessionFile, shard]));
|
|
1809
|
+
const digests = new Map(index.digests.map((digest) => [digest.file, digest]));
|
|
1810
|
+
const sessions = refs.map((ref) => {
|
|
1811
|
+
const tier = index.tiers.get(ref.file) ?? "cold";
|
|
1812
|
+
const shard = shards.get(ref.file);
|
|
1813
|
+
const digest = digests.get(ref.file);
|
|
1814
|
+
return {
|
|
1815
|
+
id: shard?.sessionId ?? digest?.sessionId ?? ref.id,
|
|
1816
|
+
file: ref.file,
|
|
1817
|
+
cwd: digest?.cwd ?? ref.cwd,
|
|
1818
|
+
mtime: ref.mtime,
|
|
1819
|
+
entryCount: shard?.entries.length ?? digest?.entryCount ?? 0,
|
|
1820
|
+
tier,
|
|
1821
|
+
branches,
|
|
1822
|
+
lineageFingerprint: shard?.lineageFingerprint ?? digest?.lineageFingerprint ?? null
|
|
1823
|
+
};
|
|
1824
|
+
});
|
|
1825
|
+
return { scope: scope ?? "session", branches, sessions };
|
|
1826
|
+
}
|
|
1827
|
+
};
|
|
1828
|
+
|
|
1829
|
+
export {
|
|
1830
|
+
uniqueDeclaredKeyForSpelling,
|
|
1831
|
+
actionArgNormalizer,
|
|
1832
|
+
normalizeMemoryArgs,
|
|
1833
|
+
MemoryProvider
|
|
1834
|
+
};
|
|
1835
|
+
//# sourceMappingURL=chunk-T6OAX4FO.js.map
|