@remnic/core 9.30.1 → 9.32.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/dist/access-admin-ops-surface.d.ts +10 -10
- package/dist/access-admin-ops-surface.js +55 -44
- package/dist/access-authorization-probe.d.ts +10 -10
- package/dist/access-authorization-probe.js +56 -45
- package/dist/access-boundary.d.ts +13 -11
- package/dist/access-boundary.js +55 -44
- package/dist/access-cli.js +170 -126
- package/dist/access-cli.js.map +1 -1
- package/dist/access-extraction-force-flush.d.ts +119 -0
- package/dist/access-extraction-force-flush.js +171 -0
- package/dist/access-health-types.d.ts +1 -1
- package/dist/access-http-lcm-compaction.d.ts +47 -13
- package/dist/access-http-lcm-compaction.js +7 -3
- package/dist/access-http-lifecycle-flush.d.ts +132 -0
- package/dist/access-http-lifecycle-flush.js +9 -0
- package/dist/access-http-lifecycle-flush.js.map +1 -0
- package/dist/access-http.d.ts +11 -10
- package/dist/access-http.js +71 -59
- package/dist/access-identity-continuity-surface.d.ts +8 -8
- package/dist/access-identity-continuity-surface.js +55 -44
- package/dist/access-lcm-surface.d.ts +10 -10
- package/dist/access-lcm-surface.js +55 -44
- package/dist/access-mcp-output-schemas.js +1 -1
- package/dist/access-mcp.d.ts +16 -10
- package/dist/access-mcp.js +63 -52
- package/dist/access-memory-search-fanout.d.ts +2 -2
- package/dist/{access-namespace-preflight-VfXssvoI.d.ts → access-namespace-preflight-COhbXBqS.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +3 -3
- package/dist/access-namespace-preflight.js +55 -44
- package/dist/access-observe-helpers.d.ts +22 -0
- package/dist/access-observe-helpers.js +10 -0
- package/dist/access-observe-helpers.js.map +1 -0
- package/dist/access-observe-write-surface.d.ts +51 -47
- package/dist/access-observe-write-surface.js +55 -44
- package/dist/access-operations-batch.js +58 -47
- package/dist/access-operations.d.ts +11 -11
- package/dist/access-operations.js +60 -49
- package/dist/access-recall-concurrency.d.ts +10 -10
- package/dist/access-recall-concurrency.js +55 -44
- package/dist/access-recall-response.d.ts +10 -10
- package/dist/access-recall-response.js +55 -44
- package/dist/access-recall-surface.d.ts +10 -10
- package/dist/access-recall-surface.js +55 -44
- package/dist/access-schema.d.ts +37 -7
- package/dist/access-schema.js +5 -3
- package/dist/{access-service-B5RwVsTV.d.ts → access-service-BmBTtEKO.d.ts} +44 -20
- package/dist/access-service-helpers.d.ts +113 -0
- package/dist/access-service-helpers.js +8 -0
- package/dist/access-service-helpers.js.map +1 -0
- package/dist/access-service.d.ts +10 -10
- package/dist/access-service.js +55 -44
- package/dist/access-surface-catalog.d.ts +10 -10
- package/dist/access-surface-catalog.js +2 -0
- package/dist/access-surface-catalog.js.map +1 -1
- package/dist/access-wearables-meetings-surface.d.ts +3 -3
- package/dist/action-confidence.d.ts +1 -1
- package/dist/active-memory-bridge.d.ts +1 -1
- package/dist/active-recall.d.ts +1 -1
- package/dist/active-recall.js +2 -2
- package/dist/adapters/index.js +7 -7
- package/dist/adapters/registry.js +3 -3
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +8 -8
- package/dist/briefing.d.ts +2 -2
- package/dist/briefing.js +14 -14
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer-turn-helpers.d.ts +5 -0
- package/dist/buffer-turn-helpers.js +24 -0
- package/dist/buffer-turn-helpers.js.map +1 -0
- package/dist/buffer.d.ts +17 -4
- package/dist/buffer.js +21 -1
- package/dist/bulk-import/index.d.ts +3 -3
- package/dist/calibration.d.ts +1 -1
- package/dist/capabilities.d.ts +1 -1
- package/dist/{capsule-crypto-GWVG7LGC.js → capsule-crypto-7FJQINUR.js} +2 -2
- package/dist/capsule-crypto-7FJQINUR.js.map +1 -0
- package/dist/{capsule-merge-5KKJQBWQ.js → capsule-merge-2H2IUTBT.js} +4 -4
- package/dist/{catalog-V7inUQdp.d.ts → catalog-Dm-DvNBY.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-behavior.js +2 -2
- package/dist/causal-chain.js +2 -2
- package/dist/causal-consolidation.d.ts +1 -1
- package/dist/causal-consolidation.js +21 -22
- package/dist/causal-consolidation.js.map +1 -1
- package/dist/causal-retrieval.js +2 -2
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/causal-trajectory.js +1 -1
- package/dist/{chunk-LEPOP46W.js → chunk-227UFSEQ.js} +4 -4
- package/dist/{chunk-I5NLEENJ.js → chunk-27HHNYSQ.js} +3 -3
- package/dist/{chunk-2SA56WMI.js → chunk-2LTDWSR6.js} +4 -4
- package/dist/{chunk-OWHERGF2.js → chunk-2NLLXCJG.js} +2 -2
- package/dist/{chunk-SPJXKAVF.js → chunk-2NTGBZLZ.js} +14 -13
- package/dist/chunk-2NTGBZLZ.js.map +1 -0
- package/dist/{chunk-P5PXWTW7.js → chunk-2Q4JJ3FZ.js} +3 -3
- package/dist/{chunk-G5R3D5UP.js → chunk-2QIMTVEJ.js} +6 -5
- package/dist/chunk-2QIMTVEJ.js.map +1 -0
- package/dist/{chunk-H5CPS5JP.js → chunk-35IVNNRK.js} +3 -3
- package/dist/{chunk-LBOD4U5B.js → chunk-3EQ2XB3W.js} +6 -6
- package/dist/{chunk-YTSNAUXN.js → chunk-3F2LKUMU.js} +22 -8
- package/dist/chunk-3F2LKUMU.js.map +1 -0
- package/dist/chunk-3QL24R5Y.js +9 -0
- package/dist/chunk-3QL24R5Y.js.map +1 -0
- package/dist/chunk-4RNZMRAV.js +60 -0
- package/dist/chunk-4RNZMRAV.js.map +1 -0
- package/dist/chunk-5IVLTFOV.js +65 -0
- package/dist/chunk-5IVLTFOV.js.map +1 -0
- package/dist/{chunk-2EUVEDF5.js → chunk-5WZVQRHV.js} +2 -2
- package/dist/{chunk-ALSGMEJR.js → chunk-65ZPVYTA.js} +7 -7
- package/dist/{chunk-GIBMDSJ2.js → chunk-6P7MTSU5.js} +2 -2
- package/dist/{chunk-5VQJBH2G.js → chunk-6TAUHL33.js} +2 -2
- package/dist/{chunk-WVO4G37W.js → chunk-7TEZUUGM.js} +3 -3
- package/dist/{chunk-MJCGLM25.js → chunk-7VUAG236.js} +5 -5
- package/dist/{chunk-CZRYLSSW.js → chunk-AJL6NNX6.js} +2 -2
- package/dist/{chunk-LGHKJABJ.js → chunk-AQEJE3WO.js} +40 -18
- package/dist/chunk-AQEJE3WO.js.map +1 -0
- package/dist/{chunk-66772WBP.js → chunk-AQWVJURR.js} +5 -5
- package/dist/{chunk-RKNJBZ55.js → chunk-AU7Q3LSC.js} +7 -7
- package/dist/{chunk-IYZ5K7MU.js → chunk-BUE5E2HL.js} +4 -187
- package/dist/chunk-BUE5E2HL.js.map +1 -0
- package/dist/{chunk-NHWB6HG2.js → chunk-CE5355TT.js} +21 -5
- package/dist/chunk-CE5355TT.js.map +1 -0
- package/dist/{chunk-M3C2V3PV.js → chunk-CJDNT45S.js} +12 -12
- package/dist/{chunk-D2ANTDGO.js → chunk-E6BMSH7U.js} +2 -2
- package/dist/{chunk-CKMO4RDY.js → chunk-EMDLM3LW.js} +4 -4
- package/dist/chunk-ER7W6H4T.js +112 -0
- package/dist/chunk-ER7W6H4T.js.map +1 -0
- package/dist/{chunk-RGIWINDN.js → chunk-FHBITMRY.js} +30 -30
- package/dist/{chunk-6FUPCJUL.js → chunk-FMFLGS5Z.js} +54 -54
- package/dist/chunk-FMFLGS5Z.js.map +1 -0
- package/dist/{chunk-FDAMS4PK.js → chunk-G2YQ57YO.js} +4 -4
- package/dist/{chunk-6U7F52DE.js → chunk-HFQQWAMS.js} +62 -62
- package/dist/{chunk-5W4ZLBEZ.js → chunk-HKPJPOW7.js} +2 -2
- package/dist/{chunk-JCBWCYEJ.js → chunk-IGWFKW4B.js} +2 -2
- package/dist/{chunk-AITCS2RC.js → chunk-IJ7HK452.js} +4 -4
- package/dist/{chunk-4WKA6I65.js → chunk-J3ZGPYXB.js} +1135 -311
- package/dist/chunk-J3ZGPYXB.js.map +1 -0
- package/dist/{chunk-D3LMYTBV.js → chunk-J7WZUL2K.js} +9 -9
- package/dist/{chunk-5W7CTZ2E.js → chunk-KQAFEZQX.js} +4 -4
- package/dist/{chunk-YNQBRLC5.js → chunk-LUQ443JP.js} +520 -2011
- package/dist/chunk-LUQ443JP.js.map +1 -0
- package/dist/{chunk-Z54EM5YZ.js → chunk-MAXVH44E.js} +7 -7
- package/dist/{chunk-WZFAPHIK.js → chunk-MU7ZHSZE.js} +2 -2
- package/dist/chunk-N5Z4EVOR.js +123 -0
- package/dist/chunk-N5Z4EVOR.js.map +1 -0
- package/dist/{chunk-AZ5BTEKX.js → chunk-NQUF7XKR.js} +2 -2
- package/dist/{chunk-W4FBGYGK.js → chunk-NRV4Y3PM.js} +1 -1
- package/dist/{chunk-62U4J2GN.js → chunk-ODGOP7P2.js} +2 -2
- package/dist/{chunk-QJAQNXWI.js → chunk-ONHRRJZM.js} +6 -6
- package/dist/{chunk-ACXPX4AG.js → chunk-OPBTPRGY.js} +2 -2
- package/dist/{chunk-XOZ4ALGB.js → chunk-QDTZ2HF7.js} +3 -3
- package/dist/{chunk-GBJ4RDFR.js → chunk-QIHIHZYC.js} +66 -91
- package/dist/chunk-QIHIHZYC.js.map +1 -0
- package/dist/{chunk-ZPSVBSOF.js → chunk-QMWFQBIL.js} +3 -3
- package/dist/{chunk-W5EG6LE3.js → chunk-THCPRMRF.js} +3 -3
- package/dist/{chunk-4A6YGWQN.js → chunk-TL4TO3EA.js} +115 -120
- package/dist/chunk-TL4TO3EA.js.map +1 -0
- package/dist/{chunk-VI2JQPNQ.js → chunk-U7QYBSQJ.js} +2 -2
- package/dist/chunk-ULARSG5Z.js +203 -0
- package/dist/chunk-ULARSG5Z.js.map +1 -0
- package/dist/{chunk-TH2LSRMG.js → chunk-UORKJ34C.js} +2 -2
- package/dist/{chunk-4Z4XNEWZ.js → chunk-VCD4PSK2.js} +56 -12
- package/dist/chunk-VCD4PSK2.js.map +1 -0
- package/dist/{chunk-K5GB36ME.js → chunk-VMZ56EE3.js} +2 -2
- package/dist/{chunk-HUHX2OCX.js → chunk-VVDPPDDF.js} +1 -1
- package/dist/chunk-VVDPPDDF.js.map +1 -0
- package/dist/{chunk-RMMVQQA6.js → chunk-WDISJRMG.js} +2 -2
- package/dist/{chunk-B6JDYXL7.js → chunk-WWUVONGW.js} +7 -1
- package/dist/chunk-WWUVONGW.js.map +1 -0
- package/dist/{chunk-UVYI6VIX.js → chunk-X7Y7WX73.js} +1 -1
- package/dist/{chunk-CVILPI77.js → chunk-XOQSEF7X.js} +6 -6
- package/dist/{chunk-RPW2NOU6.js → chunk-YIAA2X3D.js} +41 -1
- package/dist/chunk-YIAA2X3D.js.map +1 -0
- package/dist/chunk-YPC7W6GA.js +1604 -0
- package/dist/chunk-YPC7W6GA.js.map +1 -0
- package/dist/{chunk-YTQNQ4KB.js → chunk-YX5LN6JR.js} +3 -3
- package/dist/{chunk-IC6CBHCA.js → chunk-Z7XKUWYS.js} +2 -2
- package/dist/{chunk-PHWUFPCO.js → chunk-ZCPP5OW6.js} +61 -53
- package/dist/chunk-ZCPP5OW6.js.map +1 -0
- package/dist/{cli-C4GbETPC.d.ts → cli-DRJLv1Xt.d.ts} +5 -5
- package/dist/cli.d.ts +12 -12
- package/dist/cli.js +96 -86
- package/dist/compounding/engine.d.ts +2 -2
- package/dist/compounding/engine.js +14 -14
- package/dist/compounding/preference-consolidator.d.ts +1 -1
- package/dist/compression-optimizer.d.ts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +2 -2
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +14 -15
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +3 -2
- package/dist/connectors/index.js +24 -23
- package/dist/consolidation-provenance-check.d.ts +2 -2
- package/dist/consolidation-provenance-check.js +5 -5
- package/dist/consolidation-undo.d.ts +2 -2
- package/dist/consolidation-undo.js +3 -3
- package/dist/contradiction/index.d.ts +2 -2
- package/dist/contradiction/index.js +4 -4
- package/dist/conversation-index/backend.d.ts +1 -1
- package/dist/conversation-index/backend.js +2 -2
- package/dist/conversation-index/chunker.d.ts +1 -1
- package/dist/conversation-index/faiss-adapter.d.ts +1 -1
- package/dist/conversation-index/indexer.d.ts +1 -1
- package/dist/conversation-index/search.d.ts +1 -1
- package/dist/corpus-watermark.d.ts +1 -1
- package/dist/corpus-watermark.js +26 -26
- package/dist/day-summary.d.ts +1 -1
- package/dist/delinearize.d.ts +1 -1
- package/dist/direct-answer-wiring.d.ts +1 -1
- package/dist/direct-answer.d.ts +1 -1
- package/dist/embedding-fallback.d.ts +1 -1
- package/dist/enrichment/index.d.ts +1 -1
- package/dist/entity-retrieval.d.ts +2 -2
- package/dist/entity-retrieval.js +14 -14
- package/dist/entity-schema.d.ts +1 -1
- package/dist/explicit-capture.d.ts +8 -8
- package/dist/extraction-error-classification.d.ts +1 -1
- package/dist/extraction-faithfulness.d.ts +1 -1
- package/dist/extraction-judge-telemetry.d.ts +1 -1
- package/dist/extraction-judge-training.d.ts +1 -1
- package/dist/extraction-judge.d.ts +1 -1
- package/dist/extraction-liveness.d.ts +1 -1
- package/dist/extraction-source-grounding-rules.d.ts +1 -1
- package/dist/extraction-source-grounding.d.ts +15 -2
- package/dist/extraction-source-grounding.js +10 -1
- package/dist/extraction.d.ts +2 -15
- package/dist/extraction.js +5 -4
- package/dist/fallback-llm.d.ts +1 -1
- package/dist/graph-dashboard-diff.d.ts +1 -1
- package/dist/graph-dashboard-key.d.ts +1 -1
- package/dist/graph-dashboard-parser.d.ts +1 -1
- package/dist/graph-edge-reinforcement.d.ts +1 -1
- package/dist/graph-snapshot.d.ts +1 -1
- package/dist/graph.d.ts +1 -1
- package/dist/importance.d.ts +1 -1
- package/dist/importers/index.d.ts +1 -1
- package/dist/in-flight-reads.d.ts +1 -1
- package/dist/index.d.ts +19 -19
- package/dist/index.js +253 -246
- package/dist/intent.d.ts +1 -1
- package/dist/lcm/engine.d.ts +1 -1
- package/dist/lcm/engine.js +3 -3
- package/dist/lcm/index.d.ts +1 -1
- package/dist/lcm/index.js +6 -6
- package/dist/lcm/tools.d.ts +1 -1
- package/dist/lifecycle.d.ts +1 -1
- package/dist/live-connectors-runner.d.ts +1 -1
- package/dist/local-llm-helpers.d.ts +7 -0
- package/dist/local-llm-helpers.js +16 -0
- package/dist/local-llm-helpers.js.map +1 -0
- package/dist/local-llm.d.ts +3 -6
- package/dist/local-llm.js +2 -1
- package/dist/local-model-endpoint.d.ts +1 -1
- package/dist/maintenance/memory-governance.d.ts +1 -1
- package/dist/maintenance/memory-governance.js +14 -14
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +14 -14
- package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-projection.js +15 -15
- package/dist/{maintenance-CL30NWtc.d.ts → maintenance-C6Pffz30.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +10 -10
- package/dist/memory-action-policy.d.ts +1 -1
- package/dist/memory-cache.d.ts +1 -1
- package/dist/memory-corpus-version.js +2 -2
- package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
- package/dist/memory-projection-store.d.ts +1 -1
- package/dist/memory-provenance.d.ts +1 -1
- package/dist/memory-worth-outcomes.d.ts +2 -2
- package/dist/models-json.d.ts +1 -1
- package/dist/namespaces/migrate.d.ts +3 -3
- package/dist/namespaces/migrate.js +24 -24
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/search.js +9 -9
- package/dist/namespaces/storage.d.ts +3 -3
- package/dist/namespaces/storage.js +14 -14
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/offline-sync-impression-drain.d.ts +1 -1
- package/dist/offline-sync-impression-drain.js +6 -5
- package/dist/operator-doctor-corpus.d.ts +1 -1
- package/dist/operator-doctor-corpus.js +29 -29
- package/dist/operator-doctor-replica.d.ts +1 -1
- package/dist/operator-doctor-replica.js +3 -3
- package/dist/operator-toolkit.d.ts +3 -3
- package/dist/operator-toolkit.js +39 -38
- package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
- package/dist/orchestration/maintenance.d.ts +4 -4
- package/dist/orchestration/maintenance.js +22 -21
- package/dist/{orchestrator-CKTCRwWV.d.ts → orchestrator-eQlmasno.d.ts} +72 -34
- package/dist/orchestrator.d.ts +8 -8
- package/dist/orchestrator.js +169 -162
- package/dist/page-versioning.js +3 -3
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/{pipeline-B7wj4rRZ.d.ts → pipeline-CZGmAMQ2.d.ts} +1 -1
- package/dist/policy-runtime.d.ts +1 -1
- package/dist/proactive-contention.d.ts +1 -1
- package/dist/provenance.d.ts +1 -1
- package/dist/{qmd-q9tg4dHp.d.ts → qmd-DBj4MF8T.d.ts} +1 -1
- package/dist/qmd-preflight.d.ts +2 -2
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd.d.ts +2 -2
- package/dist/qmd.js +4 -4
- package/dist/recall-concurrency-config.d.ts +1 -1
- package/dist/recall-disclosure-escalation.d.ts +1 -1
- package/dist/recall-explain-renderer.d.ts +1 -1
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-memory-map.d.ts +1 -1
- package/dist/recall-planner-llm.d.ts +1 -1
- package/dist/recall-state.d.ts +1 -1
- package/dist/recall-tag-filter.d.ts +1 -1
- package/dist/recall-timings.d.ts +1 -1
- package/dist/recall-xray-cli.d.ts +1 -1
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.d.ts +1 -1
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.d.ts +1 -1
- package/dist/recall-xray.js +2 -2
- package/dist/replay/normalizers/chatgpt.d.ts +1 -1
- package/dist/replay/normalizers/claude.d.ts +1 -1
- package/dist/replay/normalizers/openclaw.d.ts +1 -1
- package/dist/replay/normalizers/shared.d.ts +1 -1
- package/dist/replay/runner.d.ts +1 -1
- package/dist/replay/types.d.ts +1 -1
- package/dist/replica-divergence.d.ts +1 -1
- package/dist/replica-divergence.js +2 -2
- package/dist/replica-peers-config.d.ts +1 -1
- package/dist/resolve-auth-token.d.ts +1 -1
- package/dist/resume-bundles.js +2 -2
- package/dist/retrieval-agents.d.ts +2 -2
- package/dist/retrieval-tiers.d.ts +1 -1
- package/dist/routing/engine.d.ts +1 -1
- package/dist/routing/store.d.ts +1 -1
- package/dist/salvage-envelope.d.ts +1 -1
- package/dist/{scope-profiles-CWDyglPM.d.ts → scope-profiles-S85lrsUn.d.ts} +1 -1
- package/dist/search/embed-helper.d.ts +1 -1
- package/dist/search/factory.d.ts +1 -1
- package/dist/search/factory.js +8 -8
- package/dist/search/index.d.ts +1 -1
- package/dist/search/index.js +12 -12
- package/dist/search/lancedb-backend.d.ts +1 -1
- package/dist/search/meilisearch-backend.d.ts +1 -1
- package/dist/search/noop-backend.d.ts +1 -1
- package/dist/search/orama-backend.d.ts +1 -1
- package/dist/search/port.d.ts +1 -1
- package/dist/search/remote-backend.d.ts +1 -1
- package/dist/{semantic-consolidation-BUE3deLn.d.ts → semantic-consolidation-DVzDcV6x.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +17 -18
- package/dist/semantic-rule-promotion.js +14 -14
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +14 -14
- package/dist/{service-CXgM0bQG.d.ts → service-C2M-wD4W.d.ts} +2 -2
- package/dist/session-observer-bands.d.ts +1 -1
- package/dist/session-observer-state.d.ts +1 -1
- package/dist/shared-context/manager.d.ts +1 -1
- package/dist/signal.d.ts +1 -1
- package/dist/{storage-DysJq-XH.d.ts → storage-dyBC3Q84.d.ts} +1 -1
- package/dist/storage.d.ts +2 -2
- package/dist/storage.js +13 -13
- package/dist/summarizer.d.ts +1 -1
- package/dist/summarizer.js +3 -2
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/temporal-supersession.d.ts +2 -2
- package/dist/temporal-timeline-recall.d.ts +1 -1
- package/dist/temporal-validity.d.ts +1 -1
- package/dist/threading.d.ts +1 -1
- package/dist/tier-migration.d.ts +2 -2
- package/dist/tier-routing.d.ts +1 -1
- package/dist/tokens.js +2 -2
- package/dist/topics.d.ts +1 -1
- package/dist/transcript.d.ts +1 -1
- package/dist/transfer/backup.js +2 -2
- package/dist/transfer/capsule-export.js +2 -2
- package/dist/transfer/capsule-import.js +5 -5
- package/dist/trust-score-stage.d.ts +1 -1
- package/dist/trust-score.d.ts +1 -1
- package/dist/{types-aPPzhnjT.d.ts → types-D63ZI--P.d.ts} +23 -2
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/utility-runtime.d.ts +1 -1
- package/dist/verified-recall.js +14 -14
- package/dist/write-envelope.d.ts +1 -1
- package/package.json +2 -2
- package/src/access-boundary.ts +3 -0
- package/src/access-cli.test.ts +93 -0
- package/src/access-cli.ts +56 -2
- package/src/access-extraction-force-flush.ts +177 -0
- package/src/access-http-extraction-force-flush.test.ts +132 -0
- package/src/access-http-lcm-compaction.ts +99 -22
- package/src/access-http-lifecycle-flush.ts +81 -0
- package/src/access-http.test.ts +227 -0
- package/src/access-http.ts +33 -40
- package/src/access-mcp-output-schemas.ts +6 -0
- package/src/access-mcp.test.ts +40 -0
- package/src/access-mcp.ts +32 -1
- package/src/access-observe-helpers.ts +180 -0
- package/src/access-observe-write-surface.ts +78 -19
- package/src/access-operations-batch.ts +2 -1
- package/src/access-schema-pi.test.ts +17 -0
- package/src/access-schema.ts +28 -11
- package/src/access-service-helpers.ts +46 -0
- package/src/access-service-observe-lcm-parity.test.ts +781 -31
- package/src/access-service-observe-scope.test.ts +88 -0
- package/src/access-service.ts +46 -128
- package/src/access-surface-catalog.test.ts +32 -0
- package/src/access-surface-catalog.ts +2 -0
- package/src/buffer-session.test.ts +148 -0
- package/src/buffer-turn-helpers.ts +152 -0
- package/src/buffer.ts +126 -201
- package/src/connectors/index.ts +1 -1
- package/src/connectors/label.ts +18 -0
- package/src/correction/correction-access-wiring.ts +79 -27
- package/src/correction/correction-executor.test.ts +542 -1
- package/src/correction/correction-executor.ts +309 -89
- package/src/correction/correction-planner.test.ts +35 -1
- package/src/correction/correction-planner.ts +50 -3
- package/src/correction/correction-service.ts +12 -7
- package/src/correction/correction-storage-integration.test.ts +172 -1
- package/src/correction/passive-capture.test.ts +35 -0
- package/src/correction/passive-capture.ts +17 -3
- package/src/extraction-source-grounding.ts +55 -1
- package/src/extraction-timeout.test.ts +51 -0
- package/src/extraction.ts +64 -90
- package/src/local-llm-headers-timeout.test.ts +48 -0
- package/src/local-llm-helpers.ts +58 -0
- package/src/local-llm.ts +62 -58
- package/src/orchestration/extraction-run-helpers.ts +309 -0
- package/src/orchestration/extraction-run.test.ts +350 -7
- package/src/orchestration/extraction-run.ts +327 -250
- package/src/orchestration/recall-result-formatter.ts +21 -2
- package/src/orchestration/recall-search-pipeline.test.ts +34 -0
- package/src/orchestration/recall-search-pipeline.ts +9 -1
- package/src/orchestration/session-context.ts +193 -18
- package/src/orchestration/turn-ingestion.ts +61 -11
- package/src/orchestrator-flush.test.ts +511 -5
- package/src/orchestrator.ts +8 -6
- package/src/recall-source-connector-label.test.ts +300 -0
- package/src/types.ts +3 -3
- package/dist/chunk-3UXOZBHV.js +0 -20
- package/dist/chunk-3UXOZBHV.js.map +0 -1
- package/dist/chunk-4A6YGWQN.js.map +0 -1
- package/dist/chunk-4WKA6I65.js.map +0 -1
- package/dist/chunk-4Z4XNEWZ.js.map +0 -1
- package/dist/chunk-6FUPCJUL.js.map +0 -1
- package/dist/chunk-B6JDYXL7.js.map +0 -1
- package/dist/chunk-G5R3D5UP.js.map +0 -1
- package/dist/chunk-GBJ4RDFR.js.map +0 -1
- package/dist/chunk-HUHX2OCX.js.map +0 -1
- package/dist/chunk-IYZ5K7MU.js.map +0 -1
- package/dist/chunk-LGHKJABJ.js.map +0 -1
- package/dist/chunk-NHWB6HG2.js.map +0 -1
- package/dist/chunk-PHWUFPCO.js.map +0 -1
- package/dist/chunk-RPW2NOU6.js.map +0 -1
- package/dist/chunk-SPJXKAVF.js.map +0 -1
- package/dist/chunk-YNQBRLC5.js.map +0 -1
- package/dist/chunk-YTSNAUXN.js.map +0 -1
- /package/dist/{capsule-crypto-GWVG7LGC.js.map → access-extraction-force-flush.js.map} +0 -0
- /package/dist/{capsule-merge-5KKJQBWQ.js.map → capsule-merge-2H2IUTBT.js.map} +0 -0
- /package/dist/{chunk-LEPOP46W.js.map → chunk-227UFSEQ.js.map} +0 -0
- /package/dist/{chunk-I5NLEENJ.js.map → chunk-27HHNYSQ.js.map} +0 -0
- /package/dist/{chunk-2SA56WMI.js.map → chunk-2LTDWSR6.js.map} +0 -0
- /package/dist/{chunk-OWHERGF2.js.map → chunk-2NLLXCJG.js.map} +0 -0
- /package/dist/{chunk-P5PXWTW7.js.map → chunk-2Q4JJ3FZ.js.map} +0 -0
- /package/dist/{chunk-H5CPS5JP.js.map → chunk-35IVNNRK.js.map} +0 -0
- /package/dist/{chunk-LBOD4U5B.js.map → chunk-3EQ2XB3W.js.map} +0 -0
- /package/dist/{chunk-2EUVEDF5.js.map → chunk-5WZVQRHV.js.map} +0 -0
- /package/dist/{chunk-ALSGMEJR.js.map → chunk-65ZPVYTA.js.map} +0 -0
- /package/dist/{chunk-GIBMDSJ2.js.map → chunk-6P7MTSU5.js.map} +0 -0
- /package/dist/{chunk-5VQJBH2G.js.map → chunk-6TAUHL33.js.map} +0 -0
- /package/dist/{chunk-WVO4G37W.js.map → chunk-7TEZUUGM.js.map} +0 -0
- /package/dist/{chunk-MJCGLM25.js.map → chunk-7VUAG236.js.map} +0 -0
- /package/dist/{chunk-CZRYLSSW.js.map → chunk-AJL6NNX6.js.map} +0 -0
- /package/dist/{chunk-66772WBP.js.map → chunk-AQWVJURR.js.map} +0 -0
- /package/dist/{chunk-RKNJBZ55.js.map → chunk-AU7Q3LSC.js.map} +0 -0
- /package/dist/{chunk-M3C2V3PV.js.map → chunk-CJDNT45S.js.map} +0 -0
- /package/dist/{chunk-D2ANTDGO.js.map → chunk-E6BMSH7U.js.map} +0 -0
- /package/dist/{chunk-CKMO4RDY.js.map → chunk-EMDLM3LW.js.map} +0 -0
- /package/dist/{chunk-RGIWINDN.js.map → chunk-FHBITMRY.js.map} +0 -0
- /package/dist/{chunk-FDAMS4PK.js.map → chunk-G2YQ57YO.js.map} +0 -0
- /package/dist/{chunk-6U7F52DE.js.map → chunk-HFQQWAMS.js.map} +0 -0
- /package/dist/{chunk-5W4ZLBEZ.js.map → chunk-HKPJPOW7.js.map} +0 -0
- /package/dist/{chunk-JCBWCYEJ.js.map → chunk-IGWFKW4B.js.map} +0 -0
- /package/dist/{chunk-AITCS2RC.js.map → chunk-IJ7HK452.js.map} +0 -0
- /package/dist/{chunk-D3LMYTBV.js.map → chunk-J7WZUL2K.js.map} +0 -0
- /package/dist/{chunk-5W7CTZ2E.js.map → chunk-KQAFEZQX.js.map} +0 -0
- /package/dist/{chunk-Z54EM5YZ.js.map → chunk-MAXVH44E.js.map} +0 -0
- /package/dist/{chunk-WZFAPHIK.js.map → chunk-MU7ZHSZE.js.map} +0 -0
- /package/dist/{chunk-AZ5BTEKX.js.map → chunk-NQUF7XKR.js.map} +0 -0
- /package/dist/{chunk-W4FBGYGK.js.map → chunk-NRV4Y3PM.js.map} +0 -0
- /package/dist/{chunk-62U4J2GN.js.map → chunk-ODGOP7P2.js.map} +0 -0
- /package/dist/{chunk-QJAQNXWI.js.map → chunk-ONHRRJZM.js.map} +0 -0
- /package/dist/{chunk-ACXPX4AG.js.map → chunk-OPBTPRGY.js.map} +0 -0
- /package/dist/{chunk-XOZ4ALGB.js.map → chunk-QDTZ2HF7.js.map} +0 -0
- /package/dist/{chunk-ZPSVBSOF.js.map → chunk-QMWFQBIL.js.map} +0 -0
- /package/dist/{chunk-W5EG6LE3.js.map → chunk-THCPRMRF.js.map} +0 -0
- /package/dist/{chunk-VI2JQPNQ.js.map → chunk-U7QYBSQJ.js.map} +0 -0
- /package/dist/{chunk-TH2LSRMG.js.map → chunk-UORKJ34C.js.map} +0 -0
- /package/dist/{chunk-K5GB36ME.js.map → chunk-VMZ56EE3.js.map} +0 -0
- /package/dist/{chunk-RMMVQQA6.js.map → chunk-WDISJRMG.js.map} +0 -0
- /package/dist/{chunk-UVYI6VIX.js.map → chunk-X7Y7WX73.js.map} +0 -0
- /package/dist/{chunk-CVILPI77.js.map → chunk-XOQSEF7X.js.map} +0 -0
- /package/dist/{chunk-YTQNQ4KB.js.map → chunk-YX5LN6JR.js.map} +0 -0
- /package/dist/{chunk-IC6CBHCA.js.map → chunk-Z7XKUWYS.js.map} +0 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { BufferEntryState, BufferTurn } from "./types.js";
|
|
2
|
+
|
|
3
|
+
export interface BufferTurnOwner {
|
|
4
|
+
/**
|
|
5
|
+
* Server-resolved principal that owns this session at the authenticated
|
|
6
|
+
* observe/write boundary. Persisted with the buffered turn so lifecycle
|
|
7
|
+
* flushes do not have to infer ownership from a client-chosen session key.
|
|
8
|
+
*/
|
|
9
|
+
sessionOwnerPrincipal?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function describeError(err: unknown): string {
|
|
13
|
+
if (err instanceof Error) return err.message;
|
|
14
|
+
if (err === null) return "null";
|
|
15
|
+
if (err === undefined) return "undefined";
|
|
16
|
+
if (typeof err === "string") return err;
|
|
17
|
+
try {
|
|
18
|
+
return JSON.stringify(err);
|
|
19
|
+
} catch {
|
|
20
|
+
return String(err);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function copyBufferTurn(turn: BufferTurn): BufferTurn {
|
|
25
|
+
const copy: BufferTurn = {
|
|
26
|
+
role: turn.role,
|
|
27
|
+
content: turn.content,
|
|
28
|
+
timestamp: turn.timestamp,
|
|
29
|
+
};
|
|
30
|
+
if (typeof turn.sessionKey === "string") copy.sessionKey = turn.sessionKey;
|
|
31
|
+
if (typeof turn.logicalSessionKey === "string") {
|
|
32
|
+
copy.logicalSessionKey = turn.logicalSessionKey;
|
|
33
|
+
}
|
|
34
|
+
if (turn.providerThreadId === null || typeof turn.providerThreadId === "string") {
|
|
35
|
+
copy.providerThreadId = turn.providerThreadId;
|
|
36
|
+
}
|
|
37
|
+
if (typeof turn.sessionOwnerPrincipal === "string") {
|
|
38
|
+
copy.sessionOwnerPrincipal = turn.sessionOwnerPrincipal;
|
|
39
|
+
}
|
|
40
|
+
if (typeof turn.turnFingerprint === "string") {
|
|
41
|
+
copy.turnFingerprint = turn.turnFingerprint;
|
|
42
|
+
}
|
|
43
|
+
if (typeof turn.persistProcessedFingerprint === "boolean") {
|
|
44
|
+
copy.persistProcessedFingerprint = turn.persistProcessedFingerprint;
|
|
45
|
+
}
|
|
46
|
+
if (typeof turn.sourceConnector === "string") {
|
|
47
|
+
copy.sourceConnector = turn.sourceConnector;
|
|
48
|
+
}
|
|
49
|
+
return copy;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function bufferTurnsEqual(left: BufferTurn | undefined, right: BufferTurn): boolean {
|
|
53
|
+
if (!left) return false;
|
|
54
|
+
return (
|
|
55
|
+
left.role === right.role &&
|
|
56
|
+
left.content === right.content &&
|
|
57
|
+
left.timestamp === right.timestamp &&
|
|
58
|
+
left.sessionKey === right.sessionKey &&
|
|
59
|
+
left.sessionOwnerPrincipal === right.sessionOwnerPrincipal &&
|
|
60
|
+
left.logicalSessionKey === right.logicalSessionKey &&
|
|
61
|
+
left.providerThreadId === right.providerThreadId &&
|
|
62
|
+
left.turnFingerprint === right.turnFingerprint &&
|
|
63
|
+
left.persistProcessedFingerprint === right.persistProcessedFingerprint &&
|
|
64
|
+
left.sourceConnector === right.sourceConnector
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function bufferTurnArraysEqual(
|
|
69
|
+
left: readonly BufferTurn[],
|
|
70
|
+
right: readonly BufferTurn[],
|
|
71
|
+
): boolean {
|
|
72
|
+
return left.length === right.length && left.every((turn, index) => bufferTurnsEqual(turn, right[index]));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function bufferTurnArrayIsSuffixOfSnapshot(
|
|
76
|
+
liveTurns: readonly BufferTurn[],
|
|
77
|
+
snapshot: readonly BufferTurn[],
|
|
78
|
+
): boolean {
|
|
79
|
+
if (liveTurns.length === 0 || liveTurns.length > snapshot.length) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
const offset = snapshot.length - liveTurns.length;
|
|
83
|
+
return liveTurns.every((turn, index) => bufferTurnsEqual(turn, snapshot[offset + index]));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function liveTurnsFromExtractionSnapshot(
|
|
87
|
+
entry: BufferEntryState,
|
|
88
|
+
extractedTurns: readonly BufferTurn[],
|
|
89
|
+
): readonly BufferTurn[] {
|
|
90
|
+
const retainedTurns = entry.retainedTurns ?? [];
|
|
91
|
+
if (
|
|
92
|
+
retainedTurns.length > 0 &&
|
|
93
|
+
extractedTurns.length >= retainedTurns.length &&
|
|
94
|
+
retainedTurns.every((turn, index) => bufferTurnsEqual(extractedTurns[index], turn))
|
|
95
|
+
) {
|
|
96
|
+
const withoutRetainedPrefix = extractedTurns.slice(retainedTurns.length);
|
|
97
|
+
if (withoutRetainedPrefix.length > 0 && matchingPrefixLength(entry.turns, withoutRetainedPrefix) > 0) {
|
|
98
|
+
return withoutRetainedPrefix;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return extractedTurns;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function matchingPrefixLength(
|
|
105
|
+
liveTurns: readonly BufferTurn[],
|
|
106
|
+
extractedTurns: readonly BufferTurn[],
|
|
107
|
+
): number {
|
|
108
|
+
let index = 0;
|
|
109
|
+
while (
|
|
110
|
+
index < liveTurns.length &&
|
|
111
|
+
index < extractedTurns.length &&
|
|
112
|
+
bufferTurnsEqual(liveTurns[index], extractedTurns[index])
|
|
113
|
+
) {
|
|
114
|
+
index += 1;
|
|
115
|
+
}
|
|
116
|
+
return index;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function matchingQueuedExtractionPrefixLength(
|
|
120
|
+
liveTurns: readonly BufferTurn[],
|
|
121
|
+
extractedTurns: readonly BufferTurn[],
|
|
122
|
+
): number {
|
|
123
|
+
let bestMatchedCount = 0;
|
|
124
|
+
for (let start = 0; start < extractedTurns.length; start += 1) {
|
|
125
|
+
const matchedCount = matchingPrefixLength(liveTurns, extractedTurns.slice(start));
|
|
126
|
+
if (matchedCount > bestMatchedCount) {
|
|
127
|
+
bestMatchedCount = matchedCount;
|
|
128
|
+
if (bestMatchedCount === liveTurns.length) break;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return bestMatchedCount;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export class ProbeTimeoutError extends Error {
|
|
135
|
+
constructor(timeoutMs: number) {
|
|
136
|
+
super(`probe exceeded ${timeoutMs}ms`);
|
|
137
|
+
this.name = "ProbeTimeoutError";
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function probeWithTimeout<T>(inflight: Promise<T>, timeoutMs: number): Promise<T> {
|
|
142
|
+
let timer: NodeJS.Timeout | null = null;
|
|
143
|
+
const timeout = new Promise<T>((_, reject) => {
|
|
144
|
+
timer = setTimeout(() => reject(new ProbeTimeoutError(timeoutMs)), timeoutMs);
|
|
145
|
+
if (typeof (timer as NodeJS.Timeout).unref === "function") {
|
|
146
|
+
(timer as NodeJS.Timeout).unref();
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
return Promise.race([inflight, timeout]).finally(() => {
|
|
150
|
+
if (timer) clearTimeout(timer);
|
|
151
|
+
});
|
|
152
|
+
}
|
package/src/buffer.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { log } from "./logger.js";
|
|
2
|
+
import { throwIfAborted } from "./abort-error.js";
|
|
2
3
|
import { scanSignals } from "./signal.js";
|
|
3
4
|
import type { StorageManager } from "./storage.js";
|
|
4
5
|
import type {
|
|
@@ -10,7 +11,19 @@ import type {
|
|
|
10
11
|
SignalLevel,
|
|
11
12
|
} from "./types.js";
|
|
12
13
|
import { resolvePresentationCapabilities } from "./capabilities.js";
|
|
14
|
+
import { resolvePrincipal } from "./namespaces/principal.js";
|
|
15
|
+
import { ExtractionDeadlineError } from "./orchestration/extraction-run.js";
|
|
13
16
|
import type { ExtractionBufferSnapshot } from "./extraction-liveness.js";
|
|
17
|
+
import {
|
|
18
|
+
bufferTurnArrayIsSuffixOfSnapshot,
|
|
19
|
+
bufferTurnArraysEqual,
|
|
20
|
+
bufferTurnsEqual,
|
|
21
|
+
copyBufferTurn,
|
|
22
|
+
describeError,
|
|
23
|
+
liveTurnsFromExtractionSnapshot,
|
|
24
|
+
matchingQueuedExtractionPrefixLength,
|
|
25
|
+
probeWithTimeout,
|
|
26
|
+
} from "./buffer-turn-helpers.js";
|
|
14
27
|
|
|
15
28
|
export type TriggerDecision = "extract_now" | "extract_batch" | "keep_buffering";
|
|
16
29
|
|
|
@@ -19,6 +32,11 @@ export interface AddTurnOutcome {
|
|
|
19
32
|
extractionTurns?: BufferTurn[];
|
|
20
33
|
}
|
|
21
34
|
|
|
35
|
+
export interface RetainedTurnCleanupOptions {
|
|
36
|
+
abortSignal?: AbortSignal;
|
|
37
|
+
deadlineMs?: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
22
40
|
/**
|
|
23
41
|
* Optional surprise probe injected into `SmartBuffer`.
|
|
24
42
|
*
|
|
@@ -875,6 +893,9 @@ export class SmartBuffer {
|
|
|
875
893
|
: new Date().toISOString(),
|
|
876
894
|
};
|
|
877
895
|
if (typeof t.sessionKey === "string") copy.sessionKey = t.sessionKey;
|
|
896
|
+
if (typeof t.sessionOwnerPrincipal === "string") {
|
|
897
|
+
copy.sessionOwnerPrincipal = t.sessionOwnerPrincipal;
|
|
898
|
+
}
|
|
878
899
|
if (typeof t.logicalSessionKey === "string") {
|
|
879
900
|
copy.logicalSessionKey = t.logicalSessionKey;
|
|
880
901
|
}
|
|
@@ -898,6 +919,7 @@ export class SmartBuffer {
|
|
|
898
919
|
});
|
|
899
920
|
}
|
|
900
921
|
|
|
922
|
+
|
|
901
923
|
/**
|
|
902
924
|
* Return the current retention window (issue #562, PR 2). Primarily for
|
|
903
925
|
* tests and diagnostics.
|
|
@@ -907,31 +929,92 @@ export class SmartBuffer {
|
|
|
907
929
|
return entry?.retainedTurns ? [...entry.retainedTurns] : [];
|
|
908
930
|
}
|
|
909
931
|
|
|
932
|
+
/**
|
|
933
|
+
* Clear deferred retention copies for a force-flushed session. Normal
|
|
934
|
+
* extraction preserves these copies so a deferred candidate can be retried;
|
|
935
|
+
* an explicit force flush is the caller's request to drain that context.
|
|
936
|
+
*/
|
|
937
|
+
async clearRetainedTurnsForSession(
|
|
938
|
+
sessionKey: string,
|
|
939
|
+
ownerPrincipal?: string,
|
|
940
|
+
options: RetainedTurnCleanupOptions = {},
|
|
941
|
+
): Promise<void> {
|
|
942
|
+
if (typeof sessionKey !== "string" || sessionKey.length === 0) return;
|
|
943
|
+
const normalizedOwnerPrincipal =
|
|
944
|
+
typeof ownerPrincipal === "string" && ownerPrincipal.trim().length > 0
|
|
945
|
+
? ownerPrincipal.trim()
|
|
946
|
+
: undefined;
|
|
947
|
+
const assertLifecycle = (): void => {
|
|
948
|
+
throwIfAborted(options.abortSignal, "extraction force-flush aborted");
|
|
949
|
+
if (typeof options.deadlineMs === "number" && Date.now() >= options.deadlineMs) {
|
|
950
|
+
throw new ExtractionDeadlineError("retained_turn_cleanup");
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
assertLifecycle();
|
|
954
|
+
await this.enqueueMutation(async () => {
|
|
955
|
+
assertLifecycle();
|
|
956
|
+
const hadPendingSave = this.pendingSave;
|
|
957
|
+
if (this.saveTimer) {
|
|
958
|
+
clearTimeout(this.saveTimer);
|
|
959
|
+
this.saveTimer = null;
|
|
960
|
+
}
|
|
961
|
+
await this.loadUnlocked();
|
|
962
|
+
assertLifecycle();
|
|
963
|
+
const bufferKeys = this.matchingSessionBufferKeysUnlocked(sessionKey);
|
|
964
|
+
if (bufferKeys.length === 0) {
|
|
965
|
+
if (hadPendingSave) {
|
|
966
|
+
assertLifecycle();
|
|
967
|
+
await this.saveNowRetainingPendingOnFailure("clearRetainedTurnsForSession");
|
|
968
|
+
}
|
|
969
|
+
return;
|
|
970
|
+
}
|
|
971
|
+
let changed = false;
|
|
972
|
+
const belongsToOwner = (turn: BufferTurn): boolean => {
|
|
973
|
+
if (turn.sessionKey !== sessionKey) return false;
|
|
974
|
+
if (normalizedOwnerPrincipal === undefined) return true;
|
|
975
|
+
if (turn.sessionOwnerPrincipal === normalizedOwnerPrincipal) return true;
|
|
976
|
+
return (
|
|
977
|
+
turn.sessionOwnerPrincipal === undefined &&
|
|
978
|
+
resolvePrincipal(turn.sessionKey, this.config) === normalizedOwnerPrincipal
|
|
979
|
+
);
|
|
980
|
+
};
|
|
981
|
+
for (const bufferKey of bufferKeys) {
|
|
982
|
+
const entry = this.entryFor(bufferKey);
|
|
983
|
+
const retainedTurns = entry.retainedTurns ?? [];
|
|
984
|
+
const remainingTurns = retainedTurns.filter((turn) => !belongsToOwner(turn));
|
|
985
|
+
if (remainingTurns.length === retainedTurns.length) continue;
|
|
986
|
+
changed = true;
|
|
987
|
+
if (remainingTurns.length > 0) entry.retainedTurns = remainingTurns;
|
|
988
|
+
else delete entry.retainedTurns;
|
|
989
|
+
if (bufferKey === "default") this.state.turns = entry.turns;
|
|
990
|
+
}
|
|
991
|
+
if (changed || hadPendingSave) {
|
|
992
|
+
assertLifecycle();
|
|
993
|
+
await this.saveNowRetainingPendingOnFailure("clearRetainedTurnsForSession");
|
|
994
|
+
}
|
|
995
|
+
assertLifecycle();
|
|
996
|
+
});
|
|
997
|
+
}
|
|
998
|
+
|
|
910
999
|
async findBufferKeyForSession(sessionKey: string): Promise<string | null> {
|
|
911
1000
|
const bufferKeys = await this.findBufferKeysForSession(sessionKey);
|
|
912
1001
|
return bufferKeys[0] ?? null;
|
|
913
1002
|
}
|
|
914
1003
|
|
|
915
|
-
|
|
916
|
-
if (typeof sessionKey !== "string" || sessionKey.length === 0) return [];
|
|
917
|
-
await this.mutationChain.catch(() => {});
|
|
918
|
-
await this.load();
|
|
919
|
-
|
|
1004
|
+
private matchingSessionBufferKeysUnlocked(sessionKey: string): string[] {
|
|
920
1005
|
const matches: string[] = [];
|
|
1006
|
+
const hasSessionTurns = (entry: BufferEntryState | null | undefined): boolean =>
|
|
1007
|
+
[...(entry?.turns ?? []), ...(entry?.retainedTurns ?? [])].some(
|
|
1008
|
+
(turn) => typeof turn.sessionKey === "string" && turn.sessionKey === sessionKey,
|
|
1009
|
+
);
|
|
921
1010
|
const directEntry = this.peekEntry(sessionKey);
|
|
922
|
-
if ((directEntry
|
|
1011
|
+
if (hasSessionTurns(directEntry)) {
|
|
923
1012
|
matches.push(sessionKey);
|
|
924
1013
|
}
|
|
925
1014
|
|
|
926
1015
|
const entries = this.state.entries ?? {};
|
|
927
1016
|
for (const [bufferKey, entry] of Object.entries(entries)) {
|
|
928
|
-
if (
|
|
929
|
-
!matches.includes(bufferKey) &&
|
|
930
|
-
entry.turns.some(
|
|
931
|
-
(turn) =>
|
|
932
|
-
typeof turn.sessionKey === "string" && turn.sessionKey === sessionKey,
|
|
933
|
-
)
|
|
934
|
-
) {
|
|
1017
|
+
if (!matches.includes(bufferKey) && hasSessionTurns(entry)) {
|
|
935
1018
|
matches.push(bufferKey);
|
|
936
1019
|
}
|
|
937
1020
|
}
|
|
@@ -939,9 +1022,17 @@ export class SmartBuffer {
|
|
|
939
1022
|
return matches;
|
|
940
1023
|
}
|
|
941
1024
|
|
|
1025
|
+
async findBufferKeysForSession(sessionKey: string): Promise<string[]> {
|
|
1026
|
+
if (typeof sessionKey !== "string" || sessionKey.length === 0) return [];
|
|
1027
|
+
await this.mutationChain.catch(() => {});
|
|
1028
|
+
await this.load();
|
|
1029
|
+
return this.matchingSessionBufferKeysUnlocked(sessionKey);
|
|
1030
|
+
}
|
|
1031
|
+
|
|
942
1032
|
async clearAfterExtraction(
|
|
943
1033
|
bufferKey = "default",
|
|
944
1034
|
extractedTurns?: readonly BufferTurn[],
|
|
1035
|
+
options?: { allowNonPrefix?: boolean },
|
|
945
1036
|
): Promise<void> {
|
|
946
1037
|
await this.enqueueMutation(async () => {
|
|
947
1038
|
// Drop any armed debounce TIMER so it cannot fire mid-mutation and race
|
|
@@ -964,14 +1055,29 @@ export class SmartBuffer {
|
|
|
964
1055
|
);
|
|
965
1056
|
let clearedLiveTurns = false;
|
|
966
1057
|
if (liveExtractedTurns.length > 0) {
|
|
967
|
-
|
|
968
|
-
entry.turns
|
|
969
|
-
liveExtractedTurns
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
1058
|
+
if (options?.allowNonPrefix === true) {
|
|
1059
|
+
const remainingTurns = [...entry.turns];
|
|
1060
|
+
for (const extractedTurn of liveExtractedTurns) {
|
|
1061
|
+
const matchingIndex = remainingTurns.findIndex((liveTurn) =>
|
|
1062
|
+
bufferTurnsEqual(liveTurn, extractedTurn),
|
|
1063
|
+
);
|
|
1064
|
+
if (matchingIndex >= 0) {
|
|
1065
|
+
remainingTurns.splice(matchingIndex, 1);
|
|
1066
|
+
clearedLiveTurns = true;
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
if (clearedLiveTurns) entry.turns = remainingTurns;
|
|
974
1070
|
} else {
|
|
1071
|
+
const matchedCount = matchingQueuedExtractionPrefixLength(
|
|
1072
|
+
entry.turns,
|
|
1073
|
+
liveExtractedTurns,
|
|
1074
|
+
);
|
|
1075
|
+
if (matchedCount > 0) {
|
|
1076
|
+
entry.turns = entry.turns.slice(matchedCount);
|
|
1077
|
+
clearedLiveTurns = true;
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
if (!clearedLiveTurns) {
|
|
975
1081
|
log.debug(
|
|
976
1082
|
`buffer[${bufferKey}]: extraction clear skipped because live turns changed before clear`,
|
|
977
1083
|
);
|
|
@@ -1016,184 +1122,3 @@ export class SmartBuffer {
|
|
|
1016
1122
|
await this.surpriseTelemetryWriteChain;
|
|
1017
1123
|
}
|
|
1018
1124
|
}
|
|
1019
|
-
|
|
1020
|
-
/**
|
|
1021
|
-
* Render an arbitrary thrown value as a short string for debug logging.
|
|
1022
|
-
*
|
|
1023
|
-
* JavaScript permits throwing *any* value (`throw null`,
|
|
1024
|
-
* `Promise.reject("x")`, `throw { reason: "timeout" }`) — not just
|
|
1025
|
-
* `Error` instances. The defensive catch blocks in `SmartBuffer` must
|
|
1026
|
-
* never themselves throw while trying to log the failure, or they
|
|
1027
|
-
* would defeat the whole point of isolating the surprise path from the
|
|
1028
|
-
* core extraction decision.
|
|
1029
|
-
*/
|
|
1030
|
-
function describeError(err: unknown): string {
|
|
1031
|
-
if (err instanceof Error) return err.message;
|
|
1032
|
-
if (err === null) return "null";
|
|
1033
|
-
if (err === undefined) return "undefined";
|
|
1034
|
-
if (typeof err === "string") return err;
|
|
1035
|
-
try {
|
|
1036
|
-
return JSON.stringify(err);
|
|
1037
|
-
} catch {
|
|
1038
|
-
return String(err);
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
function copyBufferTurn(turn: BufferTurn): BufferTurn {
|
|
1043
|
-
const copy: BufferTurn = {
|
|
1044
|
-
role: turn.role,
|
|
1045
|
-
content: turn.content,
|
|
1046
|
-
timestamp: turn.timestamp,
|
|
1047
|
-
};
|
|
1048
|
-
if (typeof turn.sessionKey === "string") copy.sessionKey = turn.sessionKey;
|
|
1049
|
-
if (typeof turn.logicalSessionKey === "string") {
|
|
1050
|
-
copy.logicalSessionKey = turn.logicalSessionKey;
|
|
1051
|
-
}
|
|
1052
|
-
if (
|
|
1053
|
-
turn.providerThreadId === null ||
|
|
1054
|
-
typeof turn.providerThreadId === "string"
|
|
1055
|
-
) {
|
|
1056
|
-
copy.providerThreadId = turn.providerThreadId;
|
|
1057
|
-
}
|
|
1058
|
-
if (typeof turn.turnFingerprint === "string") {
|
|
1059
|
-
copy.turnFingerprint = turn.turnFingerprint;
|
|
1060
|
-
}
|
|
1061
|
-
if (typeof turn.persistProcessedFingerprint === "boolean") {
|
|
1062
|
-
copy.persistProcessedFingerprint = turn.persistProcessedFingerprint;
|
|
1063
|
-
}
|
|
1064
|
-
if (typeof turn.sourceConnector === "string") {
|
|
1065
|
-
copy.sourceConnector = turn.sourceConnector;
|
|
1066
|
-
}
|
|
1067
|
-
return copy;
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
function bufferTurnsEqual(left: BufferTurn | undefined, right: BufferTurn): boolean {
|
|
1071
|
-
if (!left) return false;
|
|
1072
|
-
return (
|
|
1073
|
-
left.role === right.role &&
|
|
1074
|
-
left.content === right.content &&
|
|
1075
|
-
left.timestamp === right.timestamp &&
|
|
1076
|
-
left.sessionKey === right.sessionKey &&
|
|
1077
|
-
left.logicalSessionKey === right.logicalSessionKey &&
|
|
1078
|
-
left.providerThreadId === right.providerThreadId &&
|
|
1079
|
-
left.turnFingerprint === right.turnFingerprint &&
|
|
1080
|
-
left.persistProcessedFingerprint === right.persistProcessedFingerprint &&
|
|
1081
|
-
left.sourceConnector === right.sourceConnector
|
|
1082
|
-
);
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
|
-
function bufferTurnArraysEqual(
|
|
1086
|
-
left: readonly BufferTurn[],
|
|
1087
|
-
right: readonly BufferTurn[],
|
|
1088
|
-
): boolean {
|
|
1089
|
-
return (
|
|
1090
|
-
left.length === right.length &&
|
|
1091
|
-
left.every((turn, index) => bufferTurnsEqual(turn, right[index]))
|
|
1092
|
-
);
|
|
1093
|
-
}
|
|
1094
|
-
|
|
1095
|
-
function bufferTurnArrayIsSuffixOfSnapshot(
|
|
1096
|
-
liveTurns: readonly BufferTurn[],
|
|
1097
|
-
snapshot: readonly BufferTurn[],
|
|
1098
|
-
): boolean {
|
|
1099
|
-
if (liveTurns.length === 0 || liveTurns.length > snapshot.length) {
|
|
1100
|
-
return false;
|
|
1101
|
-
}
|
|
1102
|
-
const offset = snapshot.length - liveTurns.length;
|
|
1103
|
-
return liveTurns.every((turn, index) =>
|
|
1104
|
-
bufferTurnsEqual(turn, snapshot[offset + index]),
|
|
1105
|
-
);
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
function liveTurnsFromExtractionSnapshot(
|
|
1109
|
-
entry: BufferEntryState,
|
|
1110
|
-
extractedTurns: readonly BufferTurn[],
|
|
1111
|
-
): readonly BufferTurn[] {
|
|
1112
|
-
const retainedTurns = entry.retainedTurns ?? [];
|
|
1113
|
-
if (
|
|
1114
|
-
retainedTurns.length > 0 &&
|
|
1115
|
-
extractedTurns.length >= retainedTurns.length &&
|
|
1116
|
-
retainedTurns.every((turn, index) =>
|
|
1117
|
-
bufferTurnsEqual(extractedTurns[index], turn),
|
|
1118
|
-
)
|
|
1119
|
-
) {
|
|
1120
|
-
const withoutRetainedPrefix = extractedTurns.slice(retainedTurns.length);
|
|
1121
|
-
if (
|
|
1122
|
-
withoutRetainedPrefix.length > 0 &&
|
|
1123
|
-
matchingPrefixLength(entry.turns, withoutRetainedPrefix) > 0
|
|
1124
|
-
) {
|
|
1125
|
-
return withoutRetainedPrefix;
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
return extractedTurns;
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
function matchingPrefixLength(
|
|
1132
|
-
liveTurns: readonly BufferTurn[],
|
|
1133
|
-
extractedTurns: readonly BufferTurn[],
|
|
1134
|
-
): number {
|
|
1135
|
-
let index = 0;
|
|
1136
|
-
while (
|
|
1137
|
-
index < liveTurns.length &&
|
|
1138
|
-
index < extractedTurns.length &&
|
|
1139
|
-
bufferTurnsEqual(liveTurns[index], extractedTurns[index])
|
|
1140
|
-
) {
|
|
1141
|
-
index += 1;
|
|
1142
|
-
}
|
|
1143
|
-
return index;
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
function matchingQueuedExtractionPrefixLength(
|
|
1147
|
-
liveTurns: readonly BufferTurn[],
|
|
1148
|
-
extractedTurns: readonly BufferTurn[],
|
|
1149
|
-
): number {
|
|
1150
|
-
let bestMatchedCount = 0;
|
|
1151
|
-
for (let start = 0; start < extractedTurns.length; start += 1) {
|
|
1152
|
-
const matchedCount = matchingPrefixLength(
|
|
1153
|
-
liveTurns,
|
|
1154
|
-
extractedTurns.slice(start),
|
|
1155
|
-
);
|
|
1156
|
-
if (matchedCount > bestMatchedCount) {
|
|
1157
|
-
bestMatchedCount = matchedCount;
|
|
1158
|
-
if (bestMatchedCount === liveTurns.length) break;
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1161
|
-
return bestMatchedCount;
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
/**
|
|
1165
|
-
* Sentinel error class for the probe timeout path. Catching it via
|
|
1166
|
-
* `instanceof` lets the buffer's surprise helper distinguish a timeout
|
|
1167
|
-
* from a probe rejection (which could carry operational context the
|
|
1168
|
-
* operator wants to see).
|
|
1169
|
-
*/
|
|
1170
|
-
class ProbeTimeoutError extends Error {
|
|
1171
|
-
constructor(timeoutMs: number) {
|
|
1172
|
-
super(`probe exceeded ${timeoutMs}ms`);
|
|
1173
|
-
this.name = "ProbeTimeoutError";
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
/**
|
|
1178
|
-
* Race `inflight` against a timeout clock. Resolves with `inflight`'s
|
|
1179
|
-
* value if it settles first, otherwise rejects with `ProbeTimeoutError`.
|
|
1180
|
-
* The timer is cleared in both branches so a fast-resolving probe does
|
|
1181
|
-
* not leak a handle that would keep the Node event loop alive.
|
|
1182
|
-
*/
|
|
1183
|
-
function probeWithTimeout<T>(
|
|
1184
|
-
inflight: Promise<T>,
|
|
1185
|
-
timeoutMs: number,
|
|
1186
|
-
): Promise<T> {
|
|
1187
|
-
let timer: NodeJS.Timeout | null = null;
|
|
1188
|
-
const timeout = new Promise<T>((_, reject) => {
|
|
1189
|
-
timer = setTimeout(() => reject(new ProbeTimeoutError(timeoutMs)), timeoutMs);
|
|
1190
|
-
// `.unref()` so the timer does not hold the event loop open if the
|
|
1191
|
-
// caller decides the probe result is no longer interesting.
|
|
1192
|
-
if (typeof (timer as NodeJS.Timeout).unref === "function") {
|
|
1193
|
-
(timer as NodeJS.Timeout).unref();
|
|
1194
|
-
}
|
|
1195
|
-
});
|
|
1196
|
-
return Promise.race([inflight, timeout]).finally(() => {
|
|
1197
|
-
if (timer) clearTimeout(timer);
|
|
1198
|
-
});
|
|
1199
|
-
}
|
package/src/connectors/index.ts
CHANGED
|
@@ -569,7 +569,7 @@ const BUILTIN_CONNECTORS: ConnectorManifest[] = [
|
|
|
569
569
|
|
|
570
570
|
// ── Registry management ───────────────────────────────────────────────────
|
|
571
571
|
|
|
572
|
-
const CONNECTOR_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
572
|
+
export const CONNECTOR_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
573
573
|
|
|
574
574
|
function isValidConnectorId(connectorId: unknown): connectorId is string {
|
|
575
575
|
return typeof connectorId === "string" && CONNECTOR_ID_PATTERN.test(connectorId);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* connectors/label.ts — shared constants for rendering a connector identity
|
|
3
|
+
* into model-visible surfaces (issue #2183).
|
|
4
|
+
*
|
|
5
|
+
* `CONNECTOR_ID_PATTERN` is the canonical persisted-ID charset (re-exported from
|
|
6
|
+
* index.ts so callers don't depend on the registry module's internals).
|
|
7
|
+
* `CONNECTOR_LABEL_MAX_LENGTH` is the display bound shared by the recall
|
|
8
|
+
* renderer and the extraction-side helper (#2184) so the two cannot drift.
|
|
9
|
+
*
|
|
10
|
+
* The recall renderer TRUNCATES past the bound (attribution survives); #2184
|
|
11
|
+
* SUPPRESSES instead, because a truncated id in a prompt could collide with a
|
|
12
|
+
* different connector whereas a truncated display label cannot mislead the same
|
|
13
|
+
* way. Kept in its own module so the capped registry file (connectors/index.ts)
|
|
14
|
+
* stays at its ratchet ceiling.
|
|
15
|
+
*/
|
|
16
|
+
export { CONNECTOR_ID_PATTERN } from "./index.js";
|
|
17
|
+
|
|
18
|
+
export const CONNECTOR_LABEL_MAX_LENGTH = 64;
|