@remnic/core 9.60.1 → 9.60.2
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 +11 -11
- package/dist/access-admin-ops-surface.js +25 -25
- package/dist/access-authorization-probe.d.ts +11 -11
- package/dist/access-authorization-probe.js +26 -26
- package/dist/access-boundary.d.ts +11 -11
- package/dist/access-boundary.js +25 -25
- package/dist/access-cli.js +75 -74
- package/dist/access-cli.js.map +1 -1
- package/dist/access-coding-context-resolution.d.ts +1 -1
- package/dist/access-extraction-force-flush.d.ts +11 -11
- package/dist/access-extraction-force-flush.js +25 -25
- package/dist/access-health-types.d.ts +1 -1
- package/dist/access-http-lcm-compaction.d.ts +11 -11
- package/dist/access-http-lifecycle-flush.d.ts +11 -11
- package/dist/access-http-offline-stream.d.ts +11 -11
- package/dist/access-http-query.js +25 -25
- package/dist/access-http.d.ts +12 -12
- package/dist/access-http.js +38 -38
- package/dist/access-identity-continuity-surface.d.ts +9 -9
- package/dist/access-identity-continuity-surface.js +25 -25
- package/dist/access-lcm-surface.d.ts +11 -11
- package/dist/access-lcm-surface.js +25 -25
- package/dist/access-mcp.d.ts +11 -11
- package/dist/access-mcp.js +32 -32
- package/dist/access-memory-search-fanout.d.ts +2 -2
- package/dist/{access-namespace-preflight-TBXz-8s_.d.ts → access-namespace-preflight-EMvicnrb.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +3 -3
- package/dist/access-namespace-preflight.js +25 -25
- package/dist/access-observe-write-surface.d.ts +11 -11
- package/dist/access-observe-write-surface.js +25 -25
- package/dist/access-offline-manifest.d.ts +9 -9
- package/dist/access-operations-batch.js +27 -27
- package/dist/access-operations.d.ts +14 -14
- package/dist/access-operations.js +31 -31
- package/dist/access-recall-concurrency.d.ts +11 -11
- package/dist/access-recall-concurrency.js +25 -25
- package/dist/access-recall-response.d.ts +11 -11
- package/dist/access-recall-response.js +25 -25
- package/dist/access-recall-surface.d.ts +11 -11
- package/dist/access-recall-surface.js +25 -25
- package/dist/access-schema.d.ts +88 -88
- package/dist/access-schema.js +3 -3
- package/dist/{access-service-BogiG4Dy.d.ts → access-service-BeDYQQ62.d.ts} +71 -71
- package/dist/access-service-helpers.d.ts +11 -11
- package/dist/access-service.d.ts +11 -11
- package/dist/access-service.js +25 -25
- package/dist/access-surface-catalog.d.ts +11 -11
- package/dist/access-surface-catalog.js +27 -27
- 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/adapters/index.js +4 -4
- package/dist/adapters/registry.js +2 -2
- package/dist/ambient-provenance.d.ts +1 -1
- package/dist/artifact-search.d.ts +1 -1
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +9 -9
- package/dist/briefing-window.d.ts +2 -2
- package/dist/briefing.d.ts +2 -2
- package/dist/briefing.js +11 -11
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer-turn-helpers.d.ts +1 -1
- package/dist/buffer.d.ts +2 -2
- package/dist/buffer.js +4 -4
- 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/{catalog-z1UerMbh.d.ts → catalog-B2SxZ6LU.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-consolidation.d.ts +1 -1
- package/dist/causal-consolidation.js +12 -12
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/{chunk-7DHFB5SG.js → chunk-2GRLJMKJ.js} +3 -3
- package/dist/{chunk-OWHERGF2.js → chunk-2NLLXCJG.js} +2 -2
- package/dist/{chunk-VUJN44CT.js → chunk-2RIDW23Y.js} +7 -7
- package/dist/{chunk-VOKK4WCG.js → chunk-3GPBFDXH.js} +2 -2
- package/dist/{chunk-KXYMU4IN.js → chunk-4JGSG7QN.js} +3 -3
- package/dist/{chunk-A7266TRJ.js → chunk-4XAVQLBR.js} +2 -2
- package/dist/{chunk-LLZKOSGM.js → chunk-5WVUO6QT.js} +1 -1
- package/dist/{chunk-LLZKOSGM.js.map → chunk-5WVUO6QT.js.map} +1 -1
- package/dist/{chunk-UBSM6TZP.js → chunk-76YNCJ5H.js} +2 -2
- package/dist/{chunk-JNWISMYG.js → chunk-7N7DB4L5.js} +5 -5
- package/dist/{chunk-6C7Q6NG3.js → chunk-AWRJBAIH.js} +16 -16
- package/dist/{chunk-GKHMV2KK.js → chunk-C3R732UY.js} +51 -32
- package/dist/chunk-C3R732UY.js.map +1 -0
- package/dist/{chunk-DE6YCZEE.js → chunk-CIA6ZUBA.js} +2 -2
- package/dist/{chunk-PEDYKCJI.js → chunk-CK3NQUSQ.js} +2 -2
- package/dist/{chunk-OU7RWWW6.js → chunk-CM4SZZBN.js} +2 -2
- package/dist/{chunk-ODAE36PG.js → chunk-D5HDJWNN.js} +2 -2
- package/dist/{chunk-4CLE2LXB.js → chunk-EGW4O32Z.js} +75 -38
- package/dist/chunk-EGW4O32Z.js.map +1 -0
- package/dist/{chunk-KF75ANST.js → chunk-EHMMRZOZ.js} +2 -2
- package/dist/{chunk-7G34CBKS.js → chunk-EIQFIJDM.js} +2 -2
- package/dist/{chunk-YNDLCWXS.js → chunk-EZ25VE3G.js} +4 -4
- package/dist/{chunk-G3JFFUKR.js → chunk-FW73HN33.js} +2 -2
- package/dist/{chunk-MMZK2DWN.js → chunk-G3YBWFUC.js} +1 -1
- package/dist/chunk-GKUA4MGB.js +40 -0
- package/dist/chunk-GKUA4MGB.js.map +1 -0
- package/dist/{chunk-I4BLRM7X.js → chunk-GN7HO2LA.js} +10 -10
- package/dist/{chunk-ZOGOOSB3.js → chunk-H32ANIFP.js} +2 -2
- package/dist/{chunk-AH2NX6S7.js → chunk-HEEEMJ26.js} +3 -3
- package/dist/{chunk-J65AKOD6.js → chunk-HQBVQICL.js} +2 -2
- package/dist/{chunk-VJXSAJFW.js → chunk-I67HKRBF.js} +2 -2
- package/dist/{chunk-RKNJBZ55.js → chunk-JBPKEARU.js} +4 -4
- package/dist/{chunk-R7IV3EUJ.js → chunk-JKW663ZN.js} +2 -2
- package/dist/{chunk-YBCZTBN2.js → chunk-KAB7TZN3.js} +2 -2
- package/dist/{chunk-4UUF2EX3.js → chunk-KPML4Q3M.js} +2 -2
- package/dist/{chunk-5W7CTZ2E.js → chunk-KQAFEZQX.js} +4 -4
- package/dist/{chunk-YKZFX2HQ.js → chunk-L33N3BCA.js} +2 -2
- package/dist/{chunk-PYHOAXTI.js → chunk-LRGSLV7M.js} +4 -4
- package/dist/{chunk-FI5EAP4N.js → chunk-MJ4UGUR6.js} +2 -2
- package/dist/{chunk-KBIIE57I.js → chunk-MU3TPZOV.js} +2 -2
- package/dist/{chunk-77DAFTUU.js → chunk-MYZ4NA43.js} +2 -2
- package/dist/{chunk-T2VJ2EO5.js → chunk-N4EPIKSY.js} +6 -6
- package/dist/{chunk-EZXGJJXM.js → chunk-N4OYPGZS.js} +2 -2
- package/dist/{chunk-L3JVAM5Q.js → chunk-PA5OPZX2.js} +2 -2
- package/dist/{chunk-RVO6TCTU.js → chunk-QCECHYZL.js} +6 -6
- package/dist/{chunk-2HGV44MM.js → chunk-QRKYABS6.js} +2 -2
- package/dist/{chunk-P6GOYLHN.js → chunk-QWPAQLYV.js} +2 -2
- package/dist/{chunk-BTHDQOF4.js → chunk-QYN5PXDZ.js} +5 -5
- package/dist/{chunk-MG7GI4TT.js → chunk-S3B3UIQ3.js} +2 -2
- package/dist/{chunk-6W2ISYUV.js → chunk-TE4MKFT2.js} +4 -4
- package/dist/{chunk-QUJC22CT.js → chunk-URN7XWGC.js} +2 -2
- package/dist/{chunk-G5OB4XZX.js → chunk-VANZKHTN.js} +4 -4
- package/dist/{chunk-BPM6UHUL.js → chunk-VWDTV6SH.js} +2 -2
- package/dist/{chunk-P5OYNV7B.js → chunk-W3Y6FYRK.js} +2 -2
- package/dist/{chunk-VIM6QH4D.js → chunk-W4Q54HM3.js} +2 -2
- package/dist/{chunk-UVYI6VIX.js → chunk-X7Y7WX73.js} +1 -1
- package/dist/{chunk-FUWS2MNJ.js → chunk-XBR5BAKW.js} +4 -4
- package/dist/{chunk-XU4OLEYW.js → chunk-XD4VGLDL.js} +45 -45
- package/dist/{chunk-OV36CROW.js → chunk-XDK6ZFLL.js} +3 -3
- package/dist/{chunk-JHMAYABJ.js → chunk-XL3TATMJ.js} +4 -4
- package/dist/{chunk-OLX2HJFW.js → chunk-YLHM5BQQ.js} +4 -4
- package/dist/{chunk-2VHCLHZ5.js → chunk-YUIBXMZY.js} +147 -40
- package/dist/chunk-YUIBXMZY.js.map +1 -0
- package/dist/{cli-CTgFjmDs.d.ts → cli-DB_uakTc.d.ts} +5 -5
- package/dist/cli.d.ts +13 -13
- package/dist/cli.js +58 -58
- package/dist/coding/pre-action-gate.d.ts +1 -1
- package/dist/compounding/engine.d.ts +2 -2
- package/dist/compounding/engine.js +11 -11
- 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/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +11 -11
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +11 -11
- package/dist/consolidation-provenance-check.d.ts +2 -2
- package/dist/consolidation-undo.d.ts +2 -2
- package/dist/contradiction/index.d.ts +2 -2
- package/dist/contradiction/index.js +4 -4
- package/dist/converge-config.d.ts +1 -1
- package/dist/convergence-refresh.d.ts +2 -2
- package/dist/convergence-refresh.js +13 -13
- package/dist/conversation-index/backend.d.ts +1 -1
- 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 +13 -13
- package/dist/dashboard-runtime.js +2 -2
- package/dist/day-summary.d.ts +1 -1
- package/dist/delinearize.d.ts +1 -1
- package/dist/dependency-propagation-config.d.ts +1 -1
- package/dist/{dependency-propagation-delivery-DdwSc1qh.d.ts → dependency-propagation-delivery-DcOVpK3y.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-origin-fields.d.ts +28 -0
- package/dist/entity-origin-fields.js +10 -0
- package/dist/entity-origin-fields.js.map +1 -0
- package/dist/entity-retrieval.d.ts +2 -2
- package/dist/entity-retrieval.js +12 -11
- package/dist/entity-schema.d.ts +1 -1
- package/dist/explicit-capture.d.ts +9 -9
- package/dist/external-wiki-access.d.ts +11 -11
- package/dist/external-wiki-access.js +26 -26
- package/dist/external-wiki-collection-registration.d.ts +1 -1
- package/dist/external-wiki-collection.d.ts +1 -1
- package/dist/external-wiki-mcp-tools.d.ts +11 -11
- 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-normalization.d.ts +1 -1
- package/dist/extraction-prompt.d.ts +1 -1
- package/dist/extraction-source-grounding-rules.d.ts +1 -1
- package/dist/extraction-source-grounding.d.ts +1 -1
- package/dist/extraction.d.ts +1 -1
- package/dist/extraction.js +15 -15
- 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-path-reconstruction.d.ts +1 -1
- package/dist/graph-path-scoring.d.ts +1 -1
- package/dist/graph-snapshot.d.ts +1 -1
- package/dist/graph.d.ts +1 -1
- package/dist/harmonic-retrieval.js +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 +697 -697
- package/dist/index.js +85 -84
- package/dist/intent.d.ts +1 -1
- package/dist/lcm/engine.d.ts +1 -1
- package/dist/lcm/index.d.ts +1 -1
- package/dist/lcm/index.js +3 -3
- 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.d.ts +1 -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 +11 -11
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +11 -11
- package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-projection.js +12 -12
- package/dist/{maintenance-DvkiF7fm.d.ts → maintenance-5c1olVtB.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +11 -11
- package/dist/memory-action-policy.d.ts +1 -1
- package/dist/memory-cache.d.ts +1 -1
- 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-snapshot.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 +12 -12
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/search.js +8 -8
- package/dist/namespaces/storage.d.ts +3 -3
- package/dist/namespaces/storage.js +11 -11
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/offline-sync-impression-drain.d.ts +1 -1
- package/dist/operator-doctor-corpus.d.ts +1 -1
- package/dist/operator-doctor-corpus.js +14 -14
- package/dist/operator-doctor-replica.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +3 -3
- package/dist/operator-toolkit.js +18 -18
- package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
- package/dist/orchestration/maintenance.d.ts +4 -4
- package/dist/orchestration/maintenance.js +16 -16
- package/dist/{orchestrator-CXPIzs3D.d.ts → orchestrator-HPuY6I4i.d.ts} +8 -8
- package/dist/orchestrator.d.ts +9 -9
- package/dist/orchestrator.js +75 -74
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/{pipeline-BuYWU9rt.d.ts → pipeline-CvVe1Q2_.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/{public-http-CEwDOGO7.d.ts → public-http-D0JKFkyf.d.ts} +1 -1
- package/dist/{qmd-DYnrPw-m.d.ts → qmd-Bd0Tp76_.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/reconcile/cursor.d.ts +1 -1
- package/dist/reconcile/manifest.d.ts +1 -1
- package/dist/reconcile/plan.d.ts +1 -1
- 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-peers-config.d.ts +1 -1
- package/dist/resolve-auth-token.d.ts +1 -1
- 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/schemas.d.ts +138 -138
- package/dist/{scope-profiles-C1QG4Cmv.d.ts → scope-profiles-ClLtm9gK.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 +7 -7
- package/dist/search/index.d.ts +1 -1
- package/dist/search/index.js +7 -7
- package/dist/search/lancedb-backend.d.ts +1 -1
- package/dist/search/lancedb-backend.js +2 -2
- package/dist/search/meilisearch-backend.d.ts +1 -1
- package/dist/search/meilisearch-backend.js +2 -2
- package/dist/search/noop-backend.d.ts +1 -1
- package/dist/search/orama-backend.d.ts +1 -1
- package/dist/search/orama-backend.js +2 -2
- package/dist/search/port.d.ts +1 -1
- package/dist/search/remote-backend.d.ts +1 -1
- package/dist/{semantic-consolidation-DMeX8XS0.d.ts → semantic-consolidation-B1EkeEDj.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +12 -12
- package/dist/semantic-rule-promotion.js +11 -11
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +11 -11
- package/dist/{service-CT3ENiTO.d.ts → service-Cf3ANQj9.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 +9 -9
- package/dist/signal.d.ts +1 -1
- package/dist/source-agent-qualifier.d.ts +1 -1
- package/dist/source-agent-qualifier.js +13 -13
- package/dist/{storage-B0L76y7N.d.ts → storage-DS2O_6Qt.d.ts} +4 -2
- package/dist/storage.d.ts +2 -2
- package/dist/storage.js +12 -10
- package/dist/summarizer.d.ts +1 -1
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/support-passport/index.d.ts +14 -14
- package/dist/support-passport/index.js +28 -28
- 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/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 +2 -2
- package/dist/transfer/import-sqlite.js +2 -2
- package/dist/transfer/types.d.ts +66 -66
- package/dist/trust-score-stage.d.ts +1 -1
- package/dist/trust-score.d.ts +1 -1
- package/dist/{types-D7pB0QwO.d.ts → types-BOANGhCJ.d.ts} +3 -1
- 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 +11 -11
- package/dist/write-envelope.d.ts +1 -1
- package/package.json +2 -2
- package/src/entity-origin-fields.ts +56 -0
- package/src/entity-retrieval.ts +84 -84
- package/src/orchestration/extraction-injection-gate.ts +17 -5
- package/src/orchestration/extraction-persist.ts +1 -1
- package/src/recall-authority-fence.test.ts +40 -0
- package/src/security/audit-memory.test.ts +24 -1
- package/src/storage/entity-store.ts +52 -17
- package/src/storage/entity-timeline.ts +96 -16
- package/src/storage.ts +18 -18
- package/src/types.ts +2 -2
- package/dist/chunk-2VHCLHZ5.js.map +0 -1
- package/dist/chunk-4CLE2LXB.js.map +0 -1
- package/dist/chunk-GKHMV2KK.js.map +0 -1
- /package/dist/{capsule-crypto-GWVG7LGC.js.map → capsule-crypto-7FJQINUR.js.map} +0 -0
- /package/dist/{chunk-7DHFB5SG.js.map → chunk-2GRLJMKJ.js.map} +0 -0
- /package/dist/{chunk-OWHERGF2.js.map → chunk-2NLLXCJG.js.map} +0 -0
- /package/dist/{chunk-VUJN44CT.js.map → chunk-2RIDW23Y.js.map} +0 -0
- /package/dist/{chunk-VOKK4WCG.js.map → chunk-3GPBFDXH.js.map} +0 -0
- /package/dist/{chunk-KXYMU4IN.js.map → chunk-4JGSG7QN.js.map} +0 -0
- /package/dist/{chunk-A7266TRJ.js.map → chunk-4XAVQLBR.js.map} +0 -0
- /package/dist/{chunk-UBSM6TZP.js.map → chunk-76YNCJ5H.js.map} +0 -0
- /package/dist/{chunk-JNWISMYG.js.map → chunk-7N7DB4L5.js.map} +0 -0
- /package/dist/{chunk-6C7Q6NG3.js.map → chunk-AWRJBAIH.js.map} +0 -0
- /package/dist/{chunk-DE6YCZEE.js.map → chunk-CIA6ZUBA.js.map} +0 -0
- /package/dist/{chunk-PEDYKCJI.js.map → chunk-CK3NQUSQ.js.map} +0 -0
- /package/dist/{chunk-OU7RWWW6.js.map → chunk-CM4SZZBN.js.map} +0 -0
- /package/dist/{chunk-ODAE36PG.js.map → chunk-D5HDJWNN.js.map} +0 -0
- /package/dist/{chunk-KF75ANST.js.map → chunk-EHMMRZOZ.js.map} +0 -0
- /package/dist/{chunk-7G34CBKS.js.map → chunk-EIQFIJDM.js.map} +0 -0
- /package/dist/{chunk-YNDLCWXS.js.map → chunk-EZ25VE3G.js.map} +0 -0
- /package/dist/{chunk-G3JFFUKR.js.map → chunk-FW73HN33.js.map} +0 -0
- /package/dist/{chunk-MMZK2DWN.js.map → chunk-G3YBWFUC.js.map} +0 -0
- /package/dist/{chunk-I4BLRM7X.js.map → chunk-GN7HO2LA.js.map} +0 -0
- /package/dist/{chunk-ZOGOOSB3.js.map → chunk-H32ANIFP.js.map} +0 -0
- /package/dist/{chunk-AH2NX6S7.js.map → chunk-HEEEMJ26.js.map} +0 -0
- /package/dist/{chunk-J65AKOD6.js.map → chunk-HQBVQICL.js.map} +0 -0
- /package/dist/{chunk-VJXSAJFW.js.map → chunk-I67HKRBF.js.map} +0 -0
- /package/dist/{chunk-RKNJBZ55.js.map → chunk-JBPKEARU.js.map} +0 -0
- /package/dist/{chunk-R7IV3EUJ.js.map → chunk-JKW663ZN.js.map} +0 -0
- /package/dist/{chunk-YBCZTBN2.js.map → chunk-KAB7TZN3.js.map} +0 -0
- /package/dist/{chunk-4UUF2EX3.js.map → chunk-KPML4Q3M.js.map} +0 -0
- /package/dist/{chunk-5W7CTZ2E.js.map → chunk-KQAFEZQX.js.map} +0 -0
- /package/dist/{chunk-YKZFX2HQ.js.map → chunk-L33N3BCA.js.map} +0 -0
- /package/dist/{chunk-PYHOAXTI.js.map → chunk-LRGSLV7M.js.map} +0 -0
- /package/dist/{chunk-FI5EAP4N.js.map → chunk-MJ4UGUR6.js.map} +0 -0
- /package/dist/{chunk-KBIIE57I.js.map → chunk-MU3TPZOV.js.map} +0 -0
- /package/dist/{chunk-77DAFTUU.js.map → chunk-MYZ4NA43.js.map} +0 -0
- /package/dist/{chunk-T2VJ2EO5.js.map → chunk-N4EPIKSY.js.map} +0 -0
- /package/dist/{chunk-EZXGJJXM.js.map → chunk-N4OYPGZS.js.map} +0 -0
- /package/dist/{chunk-L3JVAM5Q.js.map → chunk-PA5OPZX2.js.map} +0 -0
- /package/dist/{chunk-RVO6TCTU.js.map → chunk-QCECHYZL.js.map} +0 -0
- /package/dist/{chunk-2HGV44MM.js.map → chunk-QRKYABS6.js.map} +0 -0
- /package/dist/{chunk-P6GOYLHN.js.map → chunk-QWPAQLYV.js.map} +0 -0
- /package/dist/{chunk-BTHDQOF4.js.map → chunk-QYN5PXDZ.js.map} +0 -0
- /package/dist/{chunk-MG7GI4TT.js.map → chunk-S3B3UIQ3.js.map} +0 -0
- /package/dist/{chunk-6W2ISYUV.js.map → chunk-TE4MKFT2.js.map} +0 -0
- /package/dist/{chunk-QUJC22CT.js.map → chunk-URN7XWGC.js.map} +0 -0
- /package/dist/{chunk-G5OB4XZX.js.map → chunk-VANZKHTN.js.map} +0 -0
- /package/dist/{chunk-BPM6UHUL.js.map → chunk-VWDTV6SH.js.map} +0 -0
- /package/dist/{chunk-P5OYNV7B.js.map → chunk-W3Y6FYRK.js.map} +0 -0
- /package/dist/{chunk-VIM6QH4D.js.map → chunk-W4Q54HM3.js.map} +0 -0
- /package/dist/{chunk-UVYI6VIX.js.map → chunk-X7Y7WX73.js.map} +0 -0
- /package/dist/{chunk-FUWS2MNJ.js.map → chunk-XBR5BAKW.js.map} +0 -0
- /package/dist/{chunk-XU4OLEYW.js.map → chunk-XD4VGLDL.js.map} +0 -0
- /package/dist/{chunk-OV36CROW.js.map → chunk-XDK6ZFLL.js.map} +0 -0
- /package/dist/{chunk-JHMAYABJ.js.map → chunk-XL3TATMJ.js.map} +0 -0
- /package/dist/{chunk-OLX2HJFW.js.map → chunk-YLHM5BQQ.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveCorpusNamespaceRoots
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-I67HKRBF.js";
|
|
4
4
|
import {
|
|
5
5
|
capabilityAllowsNamespace
|
|
6
6
|
} from "./chunk-MZWSOLMT.js";
|
|
@@ -200,4 +200,4 @@ async function readAggregateExtractionWatermark(options) {
|
|
|
200
200
|
export {
|
|
201
201
|
readAggregateExtractionWatermark
|
|
202
202
|
};
|
|
203
|
-
//# sourceMappingURL=chunk-
|
|
203
|
+
//# sourceMappingURL=chunk-CIA6ZUBA.js.map
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from "./chunk-2AD5SXO4.js";
|
|
14
14
|
import {
|
|
15
15
|
ExtractionDeadlineError
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-KPML4Q3M.js";
|
|
17
17
|
import {
|
|
18
18
|
resolvePrincipal
|
|
19
19
|
} from "./chunk-MRV7VSQK.js";
|
|
@@ -792,4 +792,4 @@ var SmartBuffer = class {
|
|
|
792
792
|
export {
|
|
793
793
|
SmartBuffer
|
|
794
794
|
};
|
|
795
|
-
//# sourceMappingURL=chunk-
|
|
795
|
+
//# sourceMappingURL=chunk-CK3NQUSQ.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-KJTKLXTH.js";
|
|
4
4
|
import {
|
|
5
5
|
StorageManager
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YUIBXMZY.js";
|
|
7
7
|
import {
|
|
8
8
|
copyExistingFileToBackup,
|
|
9
9
|
writeFileAtomically
|
|
@@ -260,4 +260,4 @@ export {
|
|
|
260
260
|
backupExistingLedger,
|
|
261
261
|
rebuildMemoryLifecycleLedger
|
|
262
262
|
};
|
|
263
|
-
//# sourceMappingURL=chunk-
|
|
263
|
+
//# sourceMappingURL=chunk-CM4SZZBN.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
headerConnector,
|
|
7
7
|
renderExtractionConversation,
|
|
8
8
|
resolveSourceConnector
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4XAVQLBR.js";
|
|
10
10
|
import {
|
|
11
11
|
ConsolidationResultSchema,
|
|
12
12
|
DaySummaryResultSchema,
|
|
@@ -2442,4 +2442,4 @@ export {
|
|
|
2442
2442
|
shouldEnableLocalExtractionThinking,
|
|
2443
2443
|
ExtractionEngine
|
|
2444
2444
|
};
|
|
2445
|
-
//# sourceMappingURL=chunk-
|
|
2445
|
+
//# sourceMappingURL=chunk-D5HDJWNN.js.map
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildOriginStructuredSections,
|
|
3
|
+
sanitizeOriginatedFacts
|
|
4
|
+
} from "./chunk-GKUA4MGB.js";
|
|
1
5
|
import {
|
|
2
6
|
checkEntityRecallAbort,
|
|
3
7
|
entityRecallSectionAbsent,
|
|
@@ -15,7 +19,7 @@ import {
|
|
|
15
19
|
} from "./chunk-7ZNJN5WZ.js";
|
|
16
20
|
import {
|
|
17
21
|
compareEntityTimestamps
|
|
18
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-YUIBXMZY.js";
|
|
19
23
|
import {
|
|
20
24
|
normalizeEntityName
|
|
21
25
|
} from "./chunk-YXZG5TVN.js";
|
|
@@ -53,15 +57,19 @@ function compactLine(value, maxLength = 220) {
|
|
|
53
57
|
return `${normalized.slice(0, Math.max(0, maxLength - 1)).trimEnd()}\u2026`;
|
|
54
58
|
}
|
|
55
59
|
function dedupeHintSnippetsByText(snippets) {
|
|
56
|
-
const
|
|
57
|
-
const result = [];
|
|
60
|
+
const deduped = /* @__PURE__ */ new Map();
|
|
58
61
|
for (const snippet of snippets) {
|
|
59
62
|
const key = normalizeEntityText(snippet.text);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
const existing = deduped.get(key);
|
|
64
|
+
if (!existing) {
|
|
65
|
+
deduped.set(key, snippet);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (existing.origin !== snippet.origin) {
|
|
69
|
+
existing.origin = void 0;
|
|
70
|
+
}
|
|
63
71
|
}
|
|
64
|
-
return
|
|
72
|
+
return [...deduped.values()];
|
|
65
73
|
}
|
|
66
74
|
function isBeliefLedgerSection(section) {
|
|
67
75
|
return normalizeEntityText(section.key).replace(/\s+/g, "_") === BELIEF_LEDGER_SECTION_KEY;
|
|
@@ -77,12 +85,14 @@ function beliefLedgerFactKeys(sections) {
|
|
|
77
85
|
return keys;
|
|
78
86
|
}
|
|
79
87
|
function recallFactsForStructuredSection(section) {
|
|
80
|
-
if (!isBeliefLedgerSection(section))
|
|
88
|
+
if (!isBeliefLedgerSection(section)) {
|
|
89
|
+
return section.facts.map((text, sourceIndex) => ({ text, sourceIndex }));
|
|
90
|
+
}
|
|
81
91
|
return currentActiveBeliefLedgerFactTexts(section.facts);
|
|
82
92
|
}
|
|
83
93
|
function currentActiveBeliefLedgerFactTexts(facts) {
|
|
84
94
|
const byClaim = /* @__PURE__ */ new Map();
|
|
85
|
-
for (const fact of facts) {
|
|
95
|
+
for (const [sourceIndex, fact] of facts.entries()) {
|
|
86
96
|
const match = BELIEF_LEDGER_FACT_RE.exec(fact.trim());
|
|
87
97
|
if (!match) continue;
|
|
88
98
|
const [, claimId, status, updatedAt, text] = match;
|
|
@@ -93,20 +103,14 @@ function currentActiveBeliefLedgerFactTexts(facts) {
|
|
|
93
103
|
const current = byClaim.get(normalizedClaimId);
|
|
94
104
|
const inactiveTieWins = current && updatedAtMs === current.updatedAtMs && current.status === "active" && normalizedStatus !== "active";
|
|
95
105
|
if (!current || updatedAtMs > current.updatedAtMs || inactiveTieWins) {
|
|
96
|
-
byClaim.set(normalizedClaimId, { status: normalizedStatus, updatedAtMs, texts: [text.trim()] });
|
|
106
|
+
byClaim.set(normalizedClaimId, { status: normalizedStatus, updatedAtMs, texts: [{ text: text.trim(), sourceIndex }] });
|
|
97
107
|
continue;
|
|
98
108
|
}
|
|
99
109
|
if (updatedAtMs === current.updatedAtMs && current.status === normalizedStatus) {
|
|
100
|
-
current.texts.push(text.trim());
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
const result = [];
|
|
104
|
-
for (const current of byClaim.values()) {
|
|
105
|
-
if (current.status === "active") {
|
|
106
|
-
result.push(...current.texts);
|
|
110
|
+
current.texts.push({ text: text.trim(), sourceIndex });
|
|
107
111
|
}
|
|
108
112
|
}
|
|
109
|
-
return
|
|
113
|
+
return [...byClaim.values()].flatMap((current) => current.status === "active" ? current.texts : []);
|
|
110
114
|
}
|
|
111
115
|
function relationLine(entry, relationship) {
|
|
112
116
|
const normalizedLabel = relationship.label.replace(/\s+/g, " ").trim();
|
|
@@ -415,7 +419,18 @@ async function buildEntityMentionIndex(storage, config, recallNamespaces, namesp
|
|
|
415
419
|
const rawStructuredSections = entity.structuredSections ?? [];
|
|
416
420
|
const rawBeliefLedgerFactKeys = beliefLedgerFactKeys(rawStructuredSections);
|
|
417
421
|
const sanitizedFacts = entity.facts.map((fact) => sanitizeEntityFact(fact)).filter(Boolean).filter((fact) => !rawBeliefLedgerFactKeys.has(normalizeEntityText(fact))).map((fact) => compactLine(fact, 180));
|
|
418
|
-
const
|
|
422
|
+
const { facts: timelineFacts, origins: timelineFactOrigins } = sanitizeOriginatedFacts(
|
|
423
|
+
entity.timeline,
|
|
424
|
+
sanitizeEntityFact,
|
|
425
|
+
compactLine,
|
|
426
|
+
true
|
|
427
|
+
);
|
|
428
|
+
const structuredSections = buildOriginStructuredSections(
|
|
429
|
+
rawStructuredSections,
|
|
430
|
+
recallFactsForStructuredSection,
|
|
431
|
+
sanitizeEntityFact,
|
|
432
|
+
compactLine
|
|
433
|
+
);
|
|
419
434
|
entities.set(canonicalId, {
|
|
420
435
|
canonicalId,
|
|
421
436
|
name: entity.name,
|
|
@@ -423,12 +438,9 @@ async function buildEntityMentionIndex(storage, config, recallNamespaces, namesp
|
|
|
423
438
|
aliases: uniqueStrings(entity.aliases),
|
|
424
439
|
summary: entity.synthesis?.trim() || entity.summary?.trim() || void 0,
|
|
425
440
|
facts: sanitizedFacts,
|
|
426
|
-
timelineFacts
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
title: section.title,
|
|
430
|
-
facts: recallFactsForStructuredSection(section).map((fact) => sanitizeEntityFact(fact)).filter(Boolean).map((fact) => compactLine(fact, 180))
|
|
431
|
-
})).filter((section) => section.facts.length > 0),
|
|
441
|
+
timelineFacts,
|
|
442
|
+
...timelineFactOrigins.some((origin) => origin !== void 0) ? { timelineFactOrigins } : {},
|
|
443
|
+
structuredSections,
|
|
432
444
|
timeline: entity.timeline.map((entry) => ({ ...entry })),
|
|
433
445
|
relationships: entity.relationships.map((relationship) => ({ ...relationship })),
|
|
434
446
|
activity: entity.activity.map((activity) => ({ ...activity })),
|
|
@@ -637,16 +649,26 @@ async function buildHintSnippets(entry, queryTokens, mode, maxSupportingFacts, r
|
|
|
637
649
|
if (requestedSectionKeys.size > 0) {
|
|
638
650
|
for (const section of entry.structuredSections) {
|
|
639
651
|
if (!requestedSectionKeys.has(normalizeEntityText(section.key).replace(/\s+/g, "_"))) continue;
|
|
640
|
-
for (const fact of section.facts) {
|
|
641
|
-
snippets.push({
|
|
652
|
+
for (const [index, fact] of section.facts.entries()) {
|
|
653
|
+
snippets.push({
|
|
654
|
+
text: fact,
|
|
655
|
+
score: mode === "direct" ? 8 : 9,
|
|
656
|
+
kind: "section",
|
|
657
|
+
origin: section.factOrigins?.[index]
|
|
658
|
+
});
|
|
642
659
|
}
|
|
643
660
|
}
|
|
644
661
|
} else {
|
|
645
|
-
for (const fact of entry.timelineFacts) {
|
|
646
|
-
snippets.push({
|
|
662
|
+
for (const [index, fact] of entry.timelineFacts.entries()) {
|
|
663
|
+
snippets.push({
|
|
664
|
+
text: fact,
|
|
665
|
+
score: mode === "direct" ? 6 : 7,
|
|
666
|
+
kind: "fact",
|
|
667
|
+
origin: entry.timelineFactOrigins?.[index]
|
|
668
|
+
});
|
|
647
669
|
}
|
|
648
670
|
for (const section of entry.structuredSections) {
|
|
649
|
-
for (const fact of section.facts) {
|
|
671
|
+
for (const [index, fact] of section.facts.entries()) {
|
|
650
672
|
const normalizedFact = normalizeEntityText(fact);
|
|
651
673
|
const hasNonAliasQueryOverlap = queryTokens.some(
|
|
652
674
|
(token) => !aliasTokens.has(token) && normalizedFact.includes(token)
|
|
@@ -654,7 +676,12 @@ async function buildHintSnippets(entry, queryTokens, mode, maxSupportingFacts, r
|
|
|
654
676
|
if (entry.timelineFacts.length > 0 && !hasNonAliasQueryOverlap) {
|
|
655
677
|
continue;
|
|
656
678
|
}
|
|
657
|
-
snippets.push({
|
|
679
|
+
snippets.push({
|
|
680
|
+
text: fact,
|
|
681
|
+
score: mode === "direct" ? 6 : 7,
|
|
682
|
+
kind: "fact",
|
|
683
|
+
origin: section.factOrigins?.[index]
|
|
684
|
+
});
|
|
658
685
|
}
|
|
659
686
|
}
|
|
660
687
|
if (entry.timelineFacts.length === 0 && entry.structuredSections.length === 0) {
|
|
@@ -696,7 +723,13 @@ async function buildHintSnippets(entry, queryTokens, mode, maxSupportingFacts, r
|
|
|
696
723
|
if (!scored) continue;
|
|
697
724
|
const normalized = normalizeEntityText(scored.text);
|
|
698
725
|
const existing = deduped.get(normalized);
|
|
699
|
-
if (!existing
|
|
726
|
+
if (!existing) {
|
|
727
|
+
deduped.set(normalized, scored);
|
|
728
|
+
} else if (existing.origin !== scored.origin) {
|
|
729
|
+
deduped.set(normalized, { ...scored.score > existing.score ? scored : existing, origin: void 0 });
|
|
730
|
+
} else if (scored.score > existing.score) {
|
|
731
|
+
deduped.set(normalized, scored);
|
|
732
|
+
}
|
|
700
733
|
}
|
|
701
734
|
return [...deduped.values()].filter((snippet) => snippet.score > 0).sort((left, right) => right.score - left.score).slice(0, maxSupportingFacts);
|
|
702
735
|
}
|
|
@@ -724,11 +757,15 @@ function formatEntityHintSection(candidates, queryTokens, mode, maxRelatedEntiti
|
|
|
724
757
|
let topSnippets = (preferredTopSnippets.length > 0 ? preferredTopSnippets : snippets).slice(0, 3);
|
|
725
758
|
const buildTimelineSnippets = (seedExcludedTexts) => {
|
|
726
759
|
const explicitTimelinePool = dedupeHintSnippetsByText(
|
|
727
|
-
(candidate.entry.timeline ?? []).slice().sort(sortTimelineEntriesDesc).map((entry) =>
|
|
728
|
-
text
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
760
|
+
(candidate.entry.timeline ?? []).slice().sort(sortTimelineEntriesDesc).map((entry) => {
|
|
761
|
+
const text = sanitizeEntityFact(entry.text);
|
|
762
|
+
return text ? scoreHintSnippet({
|
|
763
|
+
text: compactLine(text, 180),
|
|
764
|
+
score: 7,
|
|
765
|
+
kind: "activity",
|
|
766
|
+
origin: entry.origin
|
|
767
|
+
}, queryTokens) : null;
|
|
768
|
+
}).filter((snippet) => snippet !== null).filter((snippet) => !seedExcludedTexts.has(normalizeEntityText(snippet.text)))
|
|
732
769
|
).slice(0, 2);
|
|
733
770
|
const activityTimelinePool = dedupeHintSnippetsByText(
|
|
734
771
|
snippets.filter((snippet) => (snippet.kind === "activity" || snippet.kind === "memory") && !seedExcludedTexts.has(normalizeEntityText(snippet.text)))
|
|
@@ -889,4 +926,4 @@ export {
|
|
|
889
926
|
entityIndexVersion,
|
|
890
927
|
entityRecentTranscriptLookbackHours
|
|
891
928
|
};
|
|
892
|
-
//# sourceMappingURL=chunk-
|
|
929
|
+
//# sourceMappingURL=chunk-EGW4O32Z.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/entity-retrieval.ts"],"sourcesContent":["import { resolveNamespaceCapabilities } from \"./capabilities.js\";\nimport { renderAuthorityBoundContent } from \"./recall-context-composition.js\";\nimport { createHash } from \"node:crypto\";\nimport { sanitizeMemoryContent } from \"./sanitize.js\";\nimport { mkdir, readFile, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { collectNativeKnowledgeChunks, type NativeKnowledgeChunk } from \"./native-knowledge.js\";\nimport { compareEntityTimestamps, normalizeEntityName, type StorageManager } from \"./storage.js\";\nimport { normalizeEntityText, resolveRequestedEntitySectionKeys } from \"./entity-schema.js\";\nimport type { EntityStructuredSection, MemoryFile, PluginConfig, TranscriptEntry } from \"./types.js\";\nimport { containsPhrase } from \"./entity-retrieval-boundaries.js\";\nimport {\n buildOriginStructuredSections,\n sanitizeOriginatedFacts,\n type EntityOriginStructuredSection,\n} from \"./entity-origin-fields.js\";\nimport {\n checkEntityRecallAbort,\n entityRecallSectionAbsent,\n yieldEntityRecallScan,\n yieldEntityRecallScanEvery,\n} from \"./entity-recall-cancellation.js\";\nconst ENTITY_INDEX_VERSION = 3;\nconst RECENT_TRANSCRIPT_LOOKBACK_HOURS = 24;\nconst INSTRUCTION_LIKE_RE = /\\b(always|never|must|should|remember to|do not|don't|process|workflow|template|checklist|instruction)\\b/i;\nconst METADATA_WRAPPER_RE = /^(source|context|metadata|notes?):/i;\nconst ENTITY_PRONOUN_RE = /\\b(he|him|his|she|her|they|them|their|it|its)\\b/i;\nconst BELIEF_LEDGER_SECTION_KEY = \"belief_ledger\";\nconst BELIEF_LEDGER_FACT_RE = /^claim=([^;]+);\\s*status=([^;]+);\\s*updatedAt=([^;]+);\\s*(.+)$/;\ntype EntityQueryMode = \"direct\" | \"timeline\" | \"follow_up\";\ntype EntityMentionIndexEntry = {\n canonicalId: string;\n name: string;\n type: string;\n summary?: string;\n aliases: string[];\n facts: string[];\n timelineFacts: string[];\n timelineFactOrigins?: Array<string | undefined>;\n structuredSections: EntityOriginStructuredSection[];\n timeline: Array<{\n timestamp: string;\n text: string;\n source?: string;\n sessionKey?: string;\n principal?: string;\n origin?: string;\n }>;\n relationships: Array<{ target: string; label: string }>;\n activity: Array<{ date: string; note: string }>;\n factCount: number;\n memorySnippets: string[]; memorySnippetOrigins?: Array<string | undefined>;\n nativeChunks: Array<{\n chunkId: string;\n title: string;\n sourceKind: NativeKnowledgeChunk[\"sourceKind\"];\n sourcePath: string;\n snippet: string;\n derivedDate?: string;\n }>;\n};\ntype EntityMentionIndex = {\n version: number;\n updatedAt: string;\n entityStatusVersion?: number;\n entities: EntityMentionIndexEntry[];\n};\ntype EntityCandidate = {\n entry: EntityMentionIndexEntry;\n alias: string;\n score: number;\n source: \"query\" | \"recent_turn\";\n};\ntype EntityHintSnippet = {\n text: string;\n score: number;\n kind: \"summary\" | \"fact\" | \"section\" | \"relationship\" | \"activity\" | \"memory\" | \"native\"; origin?: string;\n};\nexport interface BuildEntityRecallSectionOptions {\n config: PluginConfig;\n storage: StorageManager;\n namespaceStorage?: (namespace: string) => Promise<StorageManager>;\n query: string;\n recallNamespaces?: string[];\n recentTurns: number;\n maxHints: number;\n maxSupportingFacts: number;\n maxRelatedEntities: number;\n maxChars: number;\n transcriptEntries: TranscriptEntry[];\n originAuthorityEnabled?: boolean; untrustedOrigins?: readonly string[];\n /**\n * Cancels the build at its next checkpoint (issue #2291). Entity recall reads\n * every entity and memory file across the recalled namespaces, which is\n * minutes of work on a large or slow store; without this the scan kept running\n * after the recall that asked for it had been abandoned.\n */\n abortSignal?: AbortSignal;\n}\nfunction tokenize(value: string): string[] {\n return normalizeEntityText(value).split(/\\s+/).filter((token) => token.length >= 2);\n}\nfunction uniqueStrings(values: string[]): string[] {\n return [...new Set(values.map((value) => value.trim()).filter((value) => value.length > 0))];\n}\nfunction compactLine(value: string, maxLength: number = 220): string {\n const normalized = value.replace(/\\s+/g, \" \").trim();\n if (normalized.length <= maxLength) return normalized;\n return `${normalized.slice(0, Math.max(0, maxLength - 1)).trimEnd()}…`;\n}\nfunction dedupeHintSnippetsByText(snippets: EntityHintSnippet[]): EntityHintSnippet[] {\n const deduped = new Map<string, EntityHintSnippet>();\n for (const snippet of snippets) {\n const key = normalizeEntityText(snippet.text);\n const existing = deduped.get(key);\n if (!existing) {\n deduped.set(key, snippet);\n continue;\n }\n if (existing.origin !== snippet.origin) {\n existing.origin = undefined;\n }\n }\n return [...deduped.values()];\n}\nfunction isBeliefLedgerSection(section: Pick<EntityStructuredSection, \"key\">): boolean {\n return normalizeEntityText(section.key).replace(/\\s+/g, \"_\") === BELIEF_LEDGER_SECTION_KEY;\n}\nfunction beliefLedgerFactKeys(sections: EntityStructuredSection[]): Set<string> {\n const keys = new Set<string>();\n for (const section of sections) {\n if (!isBeliefLedgerSection(section)) continue;\n for (const fact of section.facts) {\n keys.add(normalizeEntityText(fact));\n }\n }\n return keys;\n}\ntype RecalledEntityFact = { text: string; sourceIndex: number };\nfunction recallFactsForStructuredSection(section: EntityStructuredSection): RecalledEntityFact[] {\n if (!isBeliefLedgerSection(section)) {\n return section.facts.map((text, sourceIndex) => ({ text, sourceIndex }));\n }\n return currentActiveBeliefLedgerFactTexts(section.facts);\n}\nfunction currentActiveBeliefLedgerFactTexts(facts: string[]): RecalledEntityFact[] {\n const byClaim = new Map<string, { status: string; updatedAtMs: number; texts: RecalledEntityFact[] }>();\n for (const [sourceIndex, fact] of facts.entries()) {\n const match = BELIEF_LEDGER_FACT_RE.exec(fact.trim());\n if (!match) continue;\n const [, claimId, status, updatedAt, text] = match;\n const updatedAtMs = Date.parse(updatedAt);\n if (!claimId?.trim() || !status?.trim() || !Number.isFinite(updatedAtMs) || !text?.trim()) continue;\n const normalizedStatus = status.trim().toLowerCase();\n const normalizedClaimId = claimId.trim();\n const current = byClaim.get(normalizedClaimId);\n const inactiveTieWins =\n current &&\n updatedAtMs === current.updatedAtMs &&\n current.status === \"active\" &&\n normalizedStatus !== \"active\";\n if (!current || updatedAtMs > current.updatedAtMs || inactiveTieWins) {\n byClaim.set(normalizedClaimId, { status: normalizedStatus, updatedAtMs, texts: [{ text: text.trim(), sourceIndex }] });\n continue;\n }\n if (updatedAtMs === current.updatedAtMs && current.status === normalizedStatus) {\n current.texts.push({ text: text.trim(), sourceIndex });\n }\n }\n return [...byClaim.values()].flatMap((current) => current.status === \"active\" ? current.texts : []);\n}\nfunction relationLine(entry: EntityMentionIndexEntry, relationship: { target: string; label: string }): string {\n const normalizedLabel = relationship.label.replace(/\\s+/g, \" \").trim();\n if (normalizedLabel.length === 0) return `${entry.name} is connected to ${relationship.target}`;\n return `${entry.name} ${normalizedLabel} ${relationship.target}`;\n}\nfunction detectEntityQueryMode(query: string): EntityQueryMode | null {\n const normalized = normalizeEntityText(query);\n if (!normalized) return null;\n if (\n /^(what about|and what about|how about|what happened (with|to) (he|him|his|she|her|they|them|their|it|its)|did (he|she|they|it)|is (he|she|they|it)|was (he|she|they|it))\\b/.test(normalized)\n ) {\n return \"follow_up\";\n }\n if (\n /^(who is|who s|what do we know about|what does|tell me about|what can you tell me about|what s new with|what happened with|what happened to|status of|where is|how is)\\b/.test(normalized)\n ) {\n if (/^what does\\b/.test(normalized)) {\n if (/^what does (?:this|that|it|the|a|an|my|our|your|their)\\b/.test(normalized)) {\n return null;\n }\n if (\n /^what does [a-z0-9-]+ (?:error|warning|exception|failure|stack|trace|code|message|log)\\b/.test(normalized)\n && /\\b(mean|means|indicate|indicates|imply|implies)\\b/.test(normalized)\n ) {\n return null;\n }\n }\n return /what happened|what s new|status of|how is|where is/.test(normalized) ? \"timeline\" : \"direct\";\n }\n if (ENTITY_PRONOUN_RE.test(normalized) && normalized.split(/\\s+/).length <= 8) {\n return \"follow_up\";\n }\n return null;\n}\nfunction scoreAliasMatch(query: string, alias: string): number {\n const normalizedQuery = normalizeEntityText(query);\n const normalizedAlias = normalizeEntityText(alias);\n if (!normalizedAlias) return 0;\n if (normalizedQuery === normalizedAlias) return 10;\n if (containsPhrase(normalizedQuery, normalizedAlias)) return 8 + Math.min(normalizedAlias.split(/\\s+/).length, 3);\n const queryTokens = new Set(tokenize(normalizedQuery));\n const aliasTokens = tokenize(normalizedAlias);\n if (aliasTokens.length === 0) return 0;\n const overlap = aliasTokens.filter((token) => queryTokens.has(token)).length;\n if (overlap === 0) return 0;\n // Cross-entity contamination guard (#682 PR 2/3 R-2). For multi-token\n // aliases, partial-token overlap that hits ONLY shared common tokens\n // (like \"person\" in \"Person-A1\" / \"Person-B1\") would surface every\n // similarly-prefixed entity for a query that named only one. Require\n // that the overlap include at least one DISTINCTIVE alias token —\n // i.e. a token that does not also appear in any other entity's\n // alias-token vocabulary. Since this function is pure / per-pair, we\n // approximate \"distinctive\" by requiring the overlap to include at\n // least one token that is not a substring-of common identifier\n // affixes. The aliasTokens with length > 1 must contribute at least\n // one non-affix overlap. \"Alice Example\" ([\"alice\", \"example\"])\n // matched by query \"Tell me about Alice\" → overlap = 1 on \"alice\",\n // and \"alice\" is not an affix → score = 1. \"Person-A1\" tokens\n // [\"person\", \"a1\"] matched by query \"Who is Person-B1?\" → overlap =\n // 1 on \"person\", and \"person\" IS an affix → score = 0.\n if (aliasTokens.length > 1) {\n const nonAffixOverlap = aliasTokens.filter(\n (token) => queryTokens.has(token) && !isAliasAffixToken(token),\n ).length;\n if (nonAffixOverlap === 0) return 0;\n }\n return overlap;\n}\n/**\n * Tokens that look like type prefixes / generic role identifiers and\n * therefore should not, on their own, count as evidence that a\n * multi-token alias matches a query (#682 PR 2/3 R-2).\n *\n * Kept as a small explicit list rather than a regex so additions are\n * deliberate. The list mirrors the entity types listed in\n * `entity-schema.ts` plus the most common generic role identifiers\n * that frequently appear as the leading token of a display name.\n */\nconst ALIAS_AFFIX_TOKENS = new Set<string>([\n \"person\", \"people\", \"user\", \"users\", \"team\", \"teams\",\n \"project\", \"projects\", \"topic\", \"topics\",\n \"org\", \"orgs\", \"organization\", \"organizations\", \"company\", \"companies\",\n \"place\", \"places\", \"tool\", \"tools\", \"service\", \"services\",\n \"system\", \"systems\", \"agent\", \"agents\", \"bot\", \"bots\",\n]);\nfunction isAliasAffixToken(token: string): boolean {\n return ALIAS_AFFIX_TOKENS.has(token);\n}\nfunction isLikelyInstructionLike(value: string): boolean {\n return INSTRUCTION_LIKE_RE.test(value) || METADATA_WRAPPER_RE.test(value);\n}\nfunction sanitizeEntityFact(fact: string): string {\n const sanitized = sanitizeMemoryContent(fact);\n const clean = sanitized.text.trim();\n if (!clean) return \"\";\n if (INSTRUCTION_LIKE_RE.test(clean) && clean.length > 100) return \"\";\n return clean;\n}\nfunction scoreHintSnippet(snippet: EntityHintSnippet, queryTokens: string[]): EntityHintSnippet | null {\n const normalized = normalizeEntityText(snippet.text);\n if (!normalized) return null;\n const scored = { ...snippet };\n if (isLikelyInstructionLike(scored.text) && scored.kind !== \"summary\") {\n scored.score -= 3;\n }\n const overlap = queryTokens.filter((token) => normalized.includes(token)).length;\n scored.score += overlap * 2;\n if (METADATA_WRAPPER_RE.test(scored.text)) scored.score -= 2;\n if (scored.text.length <= 160) scored.score += 1;\n return scored.score > 0 ? scored : null;\n}\nfunction sortTimelineEntriesDesc(\n left: EntityMentionIndexEntry[\"timeline\"][number],\n right: EntityMentionIndexEntry[\"timeline\"][number],\n): number {\n const timestampOrder = compareEntityTimestamps(right.timestamp, left.timestamp);\n if (timestampOrder !== 0) {\n return timestampOrder;\n }\n return right.text.localeCompare(left.text);\n}\nfunction jaccardSimilarity(a: string, b: string): number {\n const aTokens = new Set(tokenize(a));\n const bTokens = new Set(tokenize(b));\n if (aTokens.size === 0 || bTokens.size === 0) return 0;\n let intersection = 0;\n for (const token of aTokens) {\n if (bTokens.has(token)) intersection += 1;\n }\n const union = new Set([...aTokens, ...bTokens]).size;\n return union === 0 ? 0 : intersection / union;\n}\nfunction buildAliasIndex(entries: EntityMentionIndexEntry[]): Map<string, EntityMentionIndexEntry[]> {\n const index = new Map<string, EntityMentionIndexEntry[]>();\n for (const entry of entries) {\n const aliases = uniqueStrings([entry.name, ...entry.aliases]).map(normalizeEntityText).filter(Boolean);\n for (const alias of aliases) {\n const existing = index.get(alias) ?? [];\n existing.push(entry);\n index.set(alias, existing);\n }\n }\n return index;\n}\nasync function readNativeChunks(\n config: PluginConfig,\n recallNamespaces?: string[],\n): Promise<NativeKnowledgeChunk[]> {\n if (!config.nativeKnowledge?.enabled) return [];\n return collectNativeKnowledgeChunks({\n workspaceDir: config.workspaceDir,\n memoryDir: config.memoryDir,\n config: config.nativeKnowledge,\n recallNamespaces: resolveNamespaceCapabilities(config).namespaces ? recallNamespaces : undefined,\n defaultNamespace: config.defaultNamespace,\n }).catch(() => []);\n}\nasync function resolveEntityIndexStorages(\n storage: StorageManager,\n config: PluginConfig,\n recallNamespaces?: string[],\n namespaceStorage?: (namespace: string) => Promise<StorageManager>,\n): Promise<StorageManager[]> {\n if (\n !resolveNamespaceCapabilities(config).namespaces ||\n !namespaceStorage ||\n !recallNamespaces ||\n recallNamespaces.length === 0\n ) {\n return [storage];\n }\n const storages: StorageManager[] = [];\n const seenDirs = new Set<string>();\n for (const namespace of uniqueStrings(recallNamespaces)) {\n try {\n const scopedStorage = await namespaceStorage(namespace);\n const storageDir = path.resolve(scopedStorage.dir);\n if (seenDirs.has(storageDir)) continue;\n seenDirs.add(storageDir);\n storages.push(scopedStorage);\n } catch {\n continue;\n }\n }\n return storages.length > 0 ? storages : [storage];\n}\nfunction entityIndexStatePath(storage: StorageManager): string {\n return path.join(storage.dir, \"state\", \"entity-mention-index.json\");\n}\n\nasync function readEntityIndexState(storage: StorageManager): Promise<EntityMentionIndex | null> {\n const raw = await readFile(entityIndexStatePath(storage), \"utf-8\").catch(() => \"\");\n if (!raw) return null;\n try {\n const parsed = JSON.parse(raw) as Partial<EntityMentionIndex>;\n if (parsed.version !== ENTITY_INDEX_VERSION || !Array.isArray(parsed.entities)) return null;\n return parsed as EntityMentionIndex;\n } catch {\n return null;\n }\n}\nasync function readCurrentPersistedEntityIndex(\n storage: StorageManager,\n config: PluginConfig,\n recallNamespaces?: string[],\n namespaceStorage?: (namespace: string) => Promise<StorageManager>,\n): Promise<EntityMentionIndex | null> {\n if (\n resolveNamespaceCapabilities(config).namespaces &&\n namespaceStorage &&\n recallNamespaces &&\n recallNamespaces.length > 0\n ) {\n return null;\n }\n const index = await readEntityIndexState(storage);\n if (!index || index.entityStatusVersion !== storage.getMemoryStatusVersion()) {\n return null;\n }\n return index;\n}\nconst namespaceEntityIndexCache = new Map<string, EntityMentionIndex>();\nconst MAX_NAMESPACE_ENTITY_INDEX_CACHE_ENTRIES = 32;\n\nfunction nativeEntityIndexRevision(chunks: NativeKnowledgeChunk[]): string {\n const projection = chunks.map((chunk) => [\n chunk.chunkId,\n chunk.sourcePath,\n chunk.title,\n chunk.sourceKind,\n uniqueStrings(chunk.aliases ?? []),\n compactLine(chunk.content, 180),\n chunk.derivedDate ?? null,\n ]);\n return createHash(\"sha256\").update(JSON.stringify(projection)).digest(\"hex\");\n}\nfunction namespaceEntityIndexCacheKey(\n storages: StorageManager[],\n recallNamespaces: string[],\n nativeRevision: string,\n): string {\n const namespaceKey = uniqueStrings(recallNamespaces).join(\"\\u001f\");\n const storageKey = storages\n .map((scopedStorage) => {\n const aliases = Object.entries(scopedStorage.entityAliases)\n .sort(([left], [right]) => left.localeCompare(right));\n return (\n `${path.resolve(scopedStorage.dir)}@${scopedStorage.getMemoryStatusVersion()}` +\n `:${scopedStorage.getMemoryCorpusVersion()}:${scopedStorage.getEntityMutationVersion()}` +\n `:${scopedStorage.hotCacheKeyId()}:${JSON.stringify(aliases)}`\n );\n })\n .join(\"\\u001f\");\n return `${namespaceKey}\\u001e${storageKey}\\u001e${nativeRevision}`;\n}\nfunction rememberNamespaceEntityIndex(key: string, index: EntityMentionIndex): void {\n if (namespaceEntityIndexCache.size >= MAX_NAMESPACE_ENTITY_INDEX_CACHE_ENTRIES) {\n const oldestKey = namespaceEntityIndexCache.keys().next().value;\n if (typeof oldestKey === \"string\") namespaceEntityIndexCache.delete(oldestKey);\n }\n namespaceEntityIndexCache.set(key, index);\n}\n\nasync function writeEntityIndexState(storage: StorageManager, index: EntityMentionIndex): Promise<void> {\n const statePath = entityIndexStatePath(storage);\n await mkdir(path.dirname(statePath), { recursive: true });\n const nextContent = JSON.stringify(index, null, 2) + \"\\n\";\n const currentContent = await readFile(statePath, \"utf-8\").catch(() => \"\");\n if (currentContent === nextContent) return;\n await writeFile(statePath, nextContent, \"utf-8\");\n}\n\nfunction nativePseudoCanonicalId(chunk: NativeKnowledgeChunk): string {\n return `native:${createHash(\"sha256\").update(chunk.sourcePath).digest(\"hex\").slice(0, 12)}`;\n}\n\nfunction createPseudoNativeEntry(chunk: NativeKnowledgeChunk): EntityMentionIndexEntry {\n const canonicalId = nativePseudoCanonicalId(chunk);\n return {\n canonicalId,\n name: chunk.title,\n type: chunk.sourceKind,\n aliases: uniqueStrings(chunk.aliases ?? []),\n facts: [],\n structuredSections: [],\n timelineFacts: [],\n timeline: [],\n relationships: [],\n activity: [],\n factCount: 0,\n memorySnippets: [],\n nativeChunks: [\n {\n chunkId: chunk.chunkId,\n title: chunk.title,\n sourceKind: chunk.sourceKind,\n sourcePath: chunk.sourcePath,\n snippet: compactLine(chunk.content, 180),\n derivedDate: chunk.derivedDate,\n },\n ],\n };\n}\n\nfunction mergeNativeChunk(entry: EntityMentionIndexEntry, chunk: NativeKnowledgeChunk): void {\n const existing = entry.nativeChunks.find((item) => item.chunkId === chunk.chunkId);\n if (existing) return;\n entry.nativeChunks.push({\n chunkId: chunk.chunkId,\n title: chunk.title,\n sourceKind: chunk.sourceKind,\n sourcePath: chunk.sourcePath,\n snippet: compactLine(chunk.content, 180),\n derivedDate: chunk.derivedDate,\n });\n entry.aliases = uniqueStrings([...entry.aliases, ...(chunk.aliases ?? [])]);\n}\n\nfunction hasFreshNativeExplicitMention(\n index: EntityMentionIndex,\n nativeChunks: NativeKnowledgeChunk[],\n query: string,\n): boolean {\n if (nativeChunks.length === 0) return false;\n const nativeCanonicalIds = new Set(nativeChunks.map(nativePseudoCanonicalId));\n const freshNativeIndex: EntityMentionIndex = {\n ...index,\n entities: [\n ...index.entities.filter((entry) => !nativeCanonicalIds.has(entry.canonicalId)),\n ...nativeChunks.map(createPseudoNativeEntry),\n ],\n };\n return resolveLanguageIndependentExplicitCandidates(freshNativeIndex, query).length > 0;\n}\n\nasync function buildEntityMentionIndex(\n storage: StorageManager,\n config: PluginConfig,\n recallNamespaces?: string[],\n namespaceStorage?: (namespace: string) => Promise<StorageManager>,\n nativeChunksOverride?: NativeKnowledgeChunk[],\n resolvedStorages?: StorageManager[],\n abortSignal?: AbortSignal,\n): Promise<EntityMentionIndex> {\n checkEntityRecallAbort(abortSignal);\n const storages = resolvedStorages ?? await resolveEntityIndexStorages(\n storage,\n config,\n recallNamespaces,\n namespaceStorage,\n );\n const shouldPersistIndex =\n storages.length === 1 && path.resolve(storages[0]!.dir) === path.resolve(storage.dir);\n const entityStatusVersionBefore = shouldPersistIndex ? storage.getMemoryStatusVersion() : undefined;\n const [previousIndex, entityFileSets, memorySets, nativeChunks] = await Promise.all([\n shouldPersistIndex ? readEntityIndexState(storage) : Promise.resolve(null),\n Promise.all(storages.map((scopedStorage) => scopedStorage.readAllEntityFiles({ abortSignal }))),\n Promise.all(storages.map((scopedStorage) => scopedStorage.readAllMemories({ abortSignal }))),\n nativeChunksOverride ? Promise.resolve(nativeChunksOverride) : readNativeChunks(config, recallNamespaces),\n ]);\n // The bulk reads now stop at their own scan boundaries (issue #2307); this\n // checkpoint still guards the (larger) indexing pass over their results.\n checkEntityRecallAbort(abortSignal);\n // Pair each entity with the storage that owns it (#1534): canonical ids must\n // reflect that store's aliases and historical migration mappings, never another\n // namespace's.\n const entityRecords = entityFileSets.flatMap((set, index) =>\n set.map((entity) => ({ entity, storage: storages[index]! })),\n );\n const memories = memorySets.flat();\n\n // The two passes over the corpus below never await real I/O, so without an\n // explicit yield they hold the event loop and no recall section deadline can\n // fire during them (issue #2291).\n let scanned = 0;\n const entities = new Map<string, EntityMentionIndexEntry>();\n for (const { entity, storage: entityStorage } of entityRecords) {\n scanned += 1;\n await yieldEntityRecallScanEvery(scanned, abortSignal);\n const canonicalId =\n typeof entityStorage.normalizeEntityName === \"function\"\n ? entityStorage.normalizeEntityName(entity.name, entity.type)\n : normalizeEntityName(entity.name, entity.type, entityStorage.entityAliases);\n const rawStructuredSections = entity.structuredSections ?? [];\n const rawBeliefLedgerFactKeys = beliefLedgerFactKeys(rawStructuredSections);\n const sanitizedFacts = entity.facts\n .map((fact) => sanitizeEntityFact(fact))\n .filter(Boolean)\n .filter((fact) => !rawBeliefLedgerFactKeys.has(normalizeEntityText(fact)))\n .map((fact) => compactLine(fact, 180));\n const { facts: timelineFacts, origins: timelineFactOrigins } = sanitizeOriginatedFacts(\n entity.timeline,\n sanitizeEntityFact,\n compactLine,\n true,\n );\n const structuredSections = buildOriginStructuredSections(\n rawStructuredSections,\n recallFactsForStructuredSection,\n sanitizeEntityFact,\n compactLine,\n );\n entities.set(canonicalId, {\n canonicalId,\n name: entity.name,\n type: entity.type,\n aliases: uniqueStrings(entity.aliases),\n summary: entity.synthesis?.trim() || entity.summary?.trim() || undefined,\n facts: sanitizedFacts,\n timelineFacts,\n ...(timelineFactOrigins.some((origin) => origin !== undefined) ? { timelineFactOrigins } : {}),\n structuredSections,\n timeline: entity.timeline.map((entry) => ({ ...entry })),\n relationships: entity.relationships.map((relationship) => ({ ...relationship })),\n activity: entity.activity.map((activity) => ({ ...activity })),\n factCount: sanitizedFacts.length,\n memorySnippets: [],\n nativeChunks: [],\n });\n }\n\n scanned = 0;\n for (const memory of memories) {\n scanned += 1;\n await yieldEntityRecallScanEvery(scanned, abortSignal);\n const entry = typeof memory.frontmatter.entityRef === \"string\" ? entities.get(memory.frontmatter.entityRef) : undefined;\n if (!entry) continue;\n const snippet = await readMemorySnippet(memory);\n if (entry.memorySnippets.includes(snippet)) continue;\n entry.memorySnippets.push(snippet);\n entry.memorySnippetOrigins = [...(entry.memorySnippetOrigins ?? []), memory.frontmatter.origin];\n }\n // Each remaining phase is another synchronous pass over the whole index\n // (alias map, native-chunk merge, sort, two full serializations). Yield between\n // them so a section deadline can fire between passes instead of only after all\n // of them (issue #2291).\n await yieldEntityRecallScan(abortSignal);\n const aliasIndex = buildAliasIndex([...entities.values()]);\n for (const chunk of nativeChunks) {\n const existingPseudo = entities.get(nativePseudoCanonicalId(chunk));\n if (existingPseudo) {\n mergeNativeChunk(existingPseudo, chunk);\n continue;\n }\n const candidateAliases = uniqueStrings([chunk.title, ...(chunk.aliases ?? [])]).map(normalizeEntityText).filter(Boolean);\n let matched = false;\n for (const alias of candidateAliases) {\n for (const entry of aliasIndex.get(alias) ?? []) {\n mergeNativeChunk(entry, chunk);\n matched = true;\n }\n }\n if (matched) continue;\n const pseudoEntry = createPseudoNativeEntry(chunk);\n entities.set(pseudoEntry.canonicalId, pseudoEntry);\n }\n\n await yieldEntityRecallScan(abortSignal);\n const sortedEntities = [...entities.values()].sort((left, right) => left.name.localeCompare(right.name));\n await yieldEntityRecallScan(abortSignal);\n const previousEntities = previousIndex ? JSON.stringify(previousIndex.entities) : \"\";\n await yieldEntityRecallScan(abortSignal);\n const nextEntities = JSON.stringify(sortedEntities);\n const entityStatusVersionAfter = shouldPersistIndex ? storage.getMemoryStatusVersion() : undefined;\n const canPersistIndex = shouldPersistIndex && entityStatusVersionBefore === entityStatusVersionAfter;\n const index: EntityMentionIndex = {\n version: ENTITY_INDEX_VERSION,\n updatedAt:\n previousIndex && previousEntities === nextEntities\n ? previousIndex.updatedAt\n : new Date().toISOString(),\n entityStatusVersion: canPersistIndex ? entityStatusVersionAfter : undefined,\n entities: sortedEntities,\n };\n if (canPersistIndex) {\n // A build the caller has abandoned must not leave a persisted index behind:\n // the write is I/O the timed-out recall no longer needs, and the next recall\n // is already competing for the same disk.\n checkEntityRecallAbort(abortSignal);\n await writeEntityIndexState(storage, index);\n }\n return index;\n}\n\nfunction resolveExplicitCandidates(\n index: EntityMentionIndex,\n query: string,\n): EntityCandidate[] {\n const candidates: EntityCandidate[] = [];\n for (const entry of index.entities) {\n const aliases = uniqueStrings([entry.name, ...entry.aliases]);\n let bestAlias = \"\";\n let bestScore = 0;\n for (const alias of aliases) {\n const score = scoreAliasMatch(query, alias);\n if (score > bestScore) {\n bestAlias = alias;\n bestScore = score;\n }\n }\n if (bestScore <= 0) continue;\n candidates.push({ entry, alias: bestAlias, score: bestScore, source: \"query\" });\n }\n return candidates.sort((left, right) => right.score - left.score);\n}\n\nconst EXPLICIT_ENTITY_MENTION_SCORE = 9;\n\nconst IMPLICIT_ENTITY_STOP_WORDS = new Set([\n \"a\",\n \"an\",\n \"and\",\n \"are\",\n \"as\",\n \"at\",\n \"be\",\n \"by\",\n \"can\",\n \"do\",\n \"for\",\n \"from\",\n \"has\",\n \"how\",\n \"i\",\n \"if\",\n \"in\",\n \"is\",\n \"it\",\n \"me\",\n \"my\",\n \"of\",\n \"on\",\n \"or\",\n \"the\",\n \"to\",\n \"was\",\n \"what\",\n \"when\",\n \"where\",\n \"who\",\n \"why\",\n \"with\",\n \"you\",\n \"your\",\n]);\n\nfunction isDistinctiveImplicitAlias(normalizedAlias: string): boolean {\n const tokens = normalizedAlias.split(/\\s+/).filter(Boolean);\n if (tokens.length > 1 && tokens.every((token) => IMPLICIT_ENTITY_STOP_WORDS.has(token))) return false;\n if (tokens.length !== 1) return true;\n const token = tokens[0]!;\n return Array.from(token).length > 1 && !IMPLICIT_ENTITY_STOP_WORDS.has(token);\n}\n\nfunction isShortLatinAlias(alias: string): boolean {\n return /^[A-Za-z]{2,3}$/.test(alias.trim());\n}\n\nfunction hasStrongShortLatinAliasMention(query: string, alias: string): boolean {\n const normalizedAlias = alias.trim();\n const titleCaseAlias = `${normalizedAlias[0]!.toUpperCase()}${normalizedAlias.slice(1).toLowerCase()}`;\n const forms = new Set([normalizedAlias, normalizedAlias.toUpperCase(), titleCaseAlias]);\n return [...forms].some((form) => {\n if (form === form.toLowerCase()) return false;\n const escaped = form.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n return new RegExp(`(?:^|[^A-Za-z0-9])${escaped}(?:$|[^A-Za-z0-9])`).test(query);\n });\n}\n\nfunction resolveLanguageIndependentExplicitCandidates(\n index: EntityMentionIndex,\n query: string,\n): EntityCandidate[] {\n const canonicalIdsByAlias = new Map<string, Set<string>>();\n for (const entry of index.entities) {\n for (const alias of uniqueStrings([entry.name, ...entry.aliases])) {\n const normalizedAlias = normalizeEntityText(alias);\n if (!normalizedAlias) continue;\n const canonicalIds = canonicalIdsByAlias.get(normalizedAlias) ?? new Set<string>();\n canonicalIds.add(entry.canonicalId);\n canonicalIdsByAlias.set(normalizedAlias, canonicalIds);\n }\n }\n\n const candidates: EntityCandidate[] = [];\n for (const entry of index.entities) {\n let bestAlias = \"\";\n let bestScore = 0;\n for (const alias of uniqueStrings([entry.name, ...entry.aliases])) {\n const normalizedAlias = normalizeEntityText(alias);\n const score = scoreAliasMatch(query, alias);\n if (\n !normalizedAlias ||\n !isDistinctiveImplicitAlias(normalizedAlias) ||\n (isShortLatinAlias(alias) && !hasStrongShortLatinAliasMention(query, alias)) ||\n canonicalIdsByAlias.get(normalizedAlias)?.size !== 1 ||\n score < EXPLICIT_ENTITY_MENTION_SCORE ||\n score <= bestScore\n ) {\n continue;\n }\n bestAlias = alias;\n bestScore = score;\n }\n if (bestAlias) {\n candidates.push({ entry, alias: bestAlias, score: bestScore, source: \"query\" });\n }\n }\n\n return candidates.sort(\n (left, right) => right.score - left.score || left.entry.name.localeCompare(right.entry.name),\n );\n}\n\nfunction resolveRecentTurnCandidates(\n index: EntityMentionIndex,\n transcriptEntries: TranscriptEntry[],\n recentTurns: number,\n): EntityCandidate[] {\n if (recentTurns <= 0 || transcriptEntries.length === 0) return [];\n const recentEntries = transcriptEntries.slice(-recentTurns);\n const candidates = new Map<string, EntityCandidate>();\n for (let indexOffset = recentEntries.length - 1; indexOffset >= 0; indexOffset -= 1) {\n const turn = recentEntries[indexOffset];\n const recencyBoost = recentEntries.length - indexOffset;\n const roleWeight = turn.role === \"user\" ? 2 : turn.role === \"assistant\" ? -1 : 0;\n for (const entry of index.entities) {\n const aliases = uniqueStrings([entry.name, ...entry.aliases]);\n for (const alias of aliases) {\n const score = scoreAliasMatch(turn.content, alias);\n if (score <= 0) continue;\n const current = candidates.get(entry.canonicalId);\n const weightedScore = score + Math.max(0, 6 - recencyBoost) + roleWeight;\n if (!current || weightedScore > current.score) {\n candidates.set(entry.canonicalId, {\n entry,\n alias,\n score: weightedScore,\n source: \"recent_turn\",\n });\n }\n }\n }\n }\n return [...candidates.values()].sort((left, right) => right.score - left.score);\n}\n\nasync function readMemorySnippet(memory: MemoryFile): Promise<string> {\n const content = memory.content.replace(/\\s+/g, \" \").trim();\n return compactLine(content, 180);\n}\n\nasync function buildHintSnippets(\n entry: EntityMentionIndexEntry,\n queryTokens: string[],\n mode: EntityQueryMode,\n maxSupportingFacts: number,\n requestedSectionKeys: Set<string>,\n): Promise<EntityHintSnippet[]> {\n const snippets: EntityHintSnippet[] = [];\n const aliasTokens = new Set(tokenize(uniqueStrings([entry.name, ...entry.aliases]).join(\" \")));\n if (entry.summary) {\n snippets.push({ text: compactLine(entry.summary, 180), score: 10, kind: \"summary\" });\n }\n if (requestedSectionKeys.size > 0) {\n for (const section of entry.structuredSections) {\n if (!requestedSectionKeys.has(normalizeEntityText(section.key).replace(/\\s+/g, \"_\"))) continue;\n for (const [index, fact] of section.facts.entries()) {\n snippets.push({\n text: fact,\n score: mode === \"direct\" ? 8 : 9,\n kind: \"section\",\n origin: section.factOrigins?.[index],\n });\n }\n }\n } else {\n for (const [index, fact] of entry.timelineFacts.entries()) {\n snippets.push({\n text: fact,\n score: mode === \"direct\" ? 6 : 7,\n kind: \"fact\",\n origin: entry.timelineFactOrigins?.[index],\n });\n }\n for (const section of entry.structuredSections) {\n for (const [index, fact] of section.facts.entries()) {\n const normalizedFact = normalizeEntityText(fact);\n const hasNonAliasQueryOverlap = queryTokens.some((token) =>\n !aliasTokens.has(token) && normalizedFact.includes(token)\n );\n if (entry.timelineFacts.length > 0 && !hasNonAliasQueryOverlap) {\n continue;\n }\n snippets.push({\n text: fact,\n score: mode === \"direct\" ? 6 : 7,\n kind: \"fact\",\n origin: section.factOrigins?.[index],\n });\n }\n }\n if (entry.timelineFacts.length === 0 && entry.structuredSections.length === 0) {\n for (const fact of entry.facts) {\n if (!fact.trim()) continue;\n snippets.push({ text: fact, score: mode === \"direct\" ? 6 : 7, kind: \"fact\" });\n }\n }\n }\n\n if (requestedSectionKeys.size === 0) {\n for (const relationship of entry.relationships) {\n snippets.push({\n text: compactLine(relationLine(entry, relationship), 180),\n score: mode === \"direct\" && entry.type.toLowerCase() === \"person\" ? 6 : 4,\n kind: \"relationship\",\n });\n }\n\n for (const activity of entry.activity) {\n snippets.push({\n text: compactLine(`${activity.date}: ${activity.note}`, 180),\n score: 4,\n kind: \"activity\",\n });\n }\n\n for (const [index, memorySnippet] of entry.memorySnippets.slice(0, Math.min(maxSupportingFacts, 4)).entries()) {\n snippets.push({ text: memorySnippet, score: 5, kind: \"memory\", origin: entry.memorySnippetOrigins?.[index] });\n }\n\n for (const chunk of entry.nativeChunks) {\n snippets.push({\n text: compactLine(chunk.snippet, 180),\n score: 3,\n kind: \"native\",\n });\n }\n }\n\n const deduped = new Map<string, EntityHintSnippet>();\n for (const snippet of snippets) {\n const scored = scoreHintSnippet(snippet, queryTokens);\n if (!scored) continue;\n const normalized = normalizeEntityText(scored.text);\n const existing = deduped.get(normalized);\n if (!existing) {\n deduped.set(normalized, scored);\n } else if (existing.origin !== scored.origin) {\n deduped.set(normalized, { ...(scored.score > existing.score ? scored : existing), origin: undefined });\n } else if (scored.score > existing.score) {\n deduped.set(normalized, scored);\n }\n }\n\n return [...deduped.values()]\n .filter((snippet) => snippet.score > 0)\n .sort((left, right) => right.score - left.score)\n .slice(0, maxSupportingFacts);\n}\n\nfunction summarizeUncertainty(snippets: EntityHintSnippet[]): string | null {\n const direct = snippets.filter((snippet) =>\n snippet.kind === \"summary\"\n || snippet.kind === \"fact\"\n || snippet.kind === \"section\"\n || snippet.kind === \"memory\"\n );\n if (direct.length < 2) return null;\n for (let index = 0; index < direct.length; index += 1) {\n for (let compare = index + 1; compare < direct.length; compare += 1) {\n if (jaccardSimilarity(direct[index].text, direct[compare].text) < 0.2) {\n return \"Evidence is mixed across stored facts; treat the hints below as partial and verify before answering definitively.\";\n }\n }\n }\n return null;\n}\n\nfunction formatEntityHintSection(\n candidates: Array<{\n candidate: EntityCandidate;\n snippets: EntityHintSnippet[];\n uncertainty: string | null;\n }>,\n queryTokens: string[],\n mode: EntityQueryMode,\n maxRelatedEntities: number,\n maxChars: number,\n originAuthorityEnabled: boolean, untrustedOrigins: readonly string[],\n): string | null {\n if (candidates.length === 0) return null;\n const lines: string[] = [\"## entity_answer_hints\", \"\"];\n // #1955 review: non-native snippet kinds may embed extraction-written content\n // without per-field origin — fence as unknown (least privilege; plumbing #2397).\n const renderSnippet = (snippet: EntityHintSnippet): string => snippet.kind !== \"native\"\n ? renderAuthorityBoundContent(snippet.text, snippet.origin, { enabled: originAuthorityEnabled, untrustedOrigins }) : snippet.text;\n // (see comment above)\n // #1955 review: inline fields (names/types/aliases/targets) cannot carry the\n // multi-line block fence without collapsing the hint list structure —\n // per-field origin plumbing is tracked in #2397.\n for (const { candidate, snippets, uncertainty } of candidates) {\n const hasSummary = Boolean(candidate.entry.summary?.trim());\n const preferredTopSnippets = hasSummary\n ? snippets.filter((snippet) => snippet.kind !== \"fact\")\n : snippets;\n let topSnippets = (\n preferredTopSnippets.length > 0 ? preferredTopSnippets : snippets\n ).slice(0, 3);\n const buildTimelineSnippets = (seedExcludedTexts: Set<string>): EntityHintSnippet[] => {\n const explicitTimelinePool = dedupeHintSnippetsByText(\n (candidate.entry.timeline ?? [])\n .slice()\n .sort(sortTimelineEntriesDesc)\n .map((entry) => {\n const text = sanitizeEntityFact(entry.text);\n return text\n ? scoreHintSnippet({\n text: compactLine(text, 180),\n score: 7,\n kind: \"activity\" as const,\n origin: entry.origin,\n }, queryTokens)\n : null;\n })\n .filter((snippet): snippet is EntityHintSnippet => snippet !== null)\n .filter((snippet) => !seedExcludedTexts.has(normalizeEntityText(snippet.text))),\n ).slice(0, 2);\n const activityTimelinePool = dedupeHintSnippetsByText(\n snippets\n .filter((snippet) => (\n snippet.kind === \"activity\" || snippet.kind === \"memory\"\n ) && !seedExcludedTexts.has(normalizeEntityText(snippet.text))),\n ).slice(0, 2);\n return explicitTimelinePool.length > 0\n ? explicitTimelinePool\n : activityTimelinePool.length > 0\n ? activityTimelinePool\n : dedupeHintSnippetsByText(\n snippets\n .filter((snippet) => (\n snippet.kind === \"fact\" || snippet.kind === \"summary\"\n ) && !seedExcludedTexts.has(normalizeEntityText(snippet.text))),\n ).slice(0, 2);\n };\n const baseTopSnippetTexts = new Set(topSnippets.map((snippet) => normalizeEntityText(snippet.text)));\n const timelinePool = mode !== \"direct\" ? buildTimelineSnippets(baseTopSnippetTexts) : [];\n if (mode !== \"direct\" && hasSummary && topSnippets.length < 2) {\n if (timelinePool.length > 0) {\n topSnippets = [...topSnippets, timelinePool[0]!].slice(0, 3);\n }\n }\n const topSnippetTexts = new Set(topSnippets.map((snippet) => normalizeEntityText(snippet.text)));\n lines.push(`- target: ${candidate.entry.name} (${candidate.entry.type})`);\n lines.push(`- resolution: ${candidate.source === \"recent_turn\" ? \"carried forward from recent turns via alias\" : \"matched alias\"} \"${candidate.alias}\"${candidate.source === \"recent_turn\" ? \"\" : \" in the query\"}`);\n if (uncertainty) lines.push(`- uncertainty: ${uncertainty}`);\n if (topSnippets.length > 0) {\n lines.push(\"- likely answer:\");\n for (const snippet of topSnippets) {\n lines.push(` - ${renderSnippet(snippet)}`);\n }\n }\n if (mode !== \"direct\") {\n const fallbackTimeline = timelinePool.filter(\n (snippet) => !topSnippetTexts.has(normalizeEntityText(snippet.text)),\n );\n if (fallbackTimeline.length > 0) {\n lines.push(\"- recent timeline:\");\n for (const snippet of fallbackTimeline) {\n lines.push(` - ${renderSnippet(snippet)}`);\n }\n }\n }\n const related = candidate.entry.relationships.slice(0, maxRelatedEntities).map((relationship) => relationship.target);\n if (related.length > 0) {\n lines.push(`- related entities: ${related.join(\", \")}`);\n }\n lines.push(`- support counts: facts=${candidate.entry.factCount}, memories=${candidate.entry.memorySnippets.length}, native=${candidate.entry.nativeChunks.length}`);\n lines.push(\"\");\n }\n\n let result = lines.join(\"\\n\");\n if (result.length > maxChars) {\n result = `${result.slice(0, Math.max(0, maxChars - 15)).trimEnd()}\\n\\n...(trimmed)\\n`;\n }\n return result.trim().length > 0 ? result.trimEnd() : null;\n}\n\nexport async function buildEntityRecallSection(options: BuildEntityRecallSectionOptions): Promise<string | null> {\n // Checkpoints sit at the real I/O boundaries below (persisted-index read,\n // native-chunk read, storage resolution, index build). The per-candidate\n // formatting that follows never awaits real I/O, so a deadline that fires\n // during a scan is observed here (issue #2291).\n checkEntityRecallAbort(options.abortSignal);\n const prefixedMode = detectEntityQueryMode(options.query);\n const persistedIndex = prefixedMode\n ? null\n : await readCurrentPersistedEntityIndex(\n options.storage,\n options.config,\n options.recallNamespaces,\n options.namespaceStorage,\n );\n checkEntityRecallAbort(options.abortSignal);\n let nativeChunks: NativeKnowledgeChunk[] | undefined;\n if (\n !prefixedMode &&\n persistedIndex &&\n resolveLanguageIndependentExplicitCandidates(persistedIndex, options.query).length === 0\n ) {\n nativeChunks = await readNativeChunks(options.config, options.recallNamespaces);\n if (!hasFreshNativeExplicitMention(persistedIndex, nativeChunks, options.query)) {\n return entityRecallSectionAbsent(options.abortSignal);\n }\n }\n const namespaceScoped =\n resolveNamespaceCapabilities(options.config).namespaces &&\n options.namespaceStorage !== undefined &&\n (options.recallNamespaces?.length ?? 0) > 0;\n if (namespaceScoped) {\n nativeChunks = await readNativeChunks(options.config, options.recallNamespaces);\n }\n const resolvedStorages = namespaceScoped\n ? await resolveEntityIndexStorages(\n options.storage,\n options.config,\n options.recallNamespaces,\n options.namespaceStorage,\n )\n : undefined;\n const namespaceCacheKey =\n resolvedStorages && options.recallNamespaces && nativeChunks\n ? namespaceEntityIndexCacheKey(\n resolvedStorages,\n options.recallNamespaces,\n nativeEntityIndexRevision(nativeChunks),\n )\n : undefined;\n let index: EntityMentionIndex | undefined = namespaceCacheKey\n ? namespaceEntityIndexCache.get(namespaceCacheKey)\n : undefined;\n checkEntityRecallAbort(options.abortSignal);\n if (!index) {\n index = await buildEntityMentionIndex(\n options.storage,\n options.config,\n options.recallNamespaces,\n options.namespaceStorage,\n nativeChunks,\n resolvedStorages,\n options.abortSignal,\n );\n if (namespaceCacheKey) rememberNamespaceEntityIndex(namespaceCacheKey, index);\n }\n // Candidate resolution is another synchronous pass over every entity and alias,\n // reached even on a cache hit that did no I/O at all — so yield here too, or a\n // cached corpus could still hold the loop past the section budget (issue #2291).\n await yieldEntityRecallScan(options.abortSignal);\n const explicitCandidates = resolveExplicitCandidates(index, options.query);\n await yieldEntityRecallScan(options.abortSignal);\n const queryCandidates = prefixedMode\n ? explicitCandidates\n : resolveLanguageIndependentExplicitCandidates(index, options.query);\n const mode = prefixedMode ?? (queryCandidates.length > 0 ? \"direct\" : null);\n if (!mode) return entityRecallSectionAbsent(options.abortSignal);\n\n const candidates = queryCandidates.length > 0\n ? queryCandidates\n : resolveRecentTurnCandidates(index, options.transcriptEntries, options.recentTurns);\n\n if (candidates.length === 0) return entityRecallSectionAbsent(options.abortSignal);\n\n const queryTokens = tokenize(options.query);\n const candidateLimit = queryCandidates.length === 0 && mode === \"follow_up\"\n ? 1\n : options.maxHints;\n const rankedCandidates = candidates.slice(0, candidateLimit);\n const enriched = await Promise.all(\n rankedCandidates.map(async (candidate) => {\n const requestedSectionKeys = new Set(\n resolveRequestedEntitySectionKeys(\n options.query,\n candidate.entry.type,\n candidate.entry.structuredSections,\n options.config.entitySchemas,\n ),\n );\n const snippets = await buildHintSnippets(\n candidate.entry,\n queryTokens,\n mode,\n options.maxSupportingFacts,\n requestedSectionKeys,\n );\n return {\n candidate,\n snippets,\n uncertainty: summarizeUncertainty(snippets),\n };\n }),\n );\n\n const section = formatEntityHintSection(\n enriched,\n queryTokens,\n mode,\n options.maxRelatedEntities,\n options.maxChars,\n options.originAuthorityEnabled === true,\n options.untrustedOrigins ?? [],\n );\n // `entityRecallSectionAbsent` so a cancelled build is not recorded as a\n // successful section that simply found no entities.\n if (!section) return entityRecallSectionAbsent(options.abortSignal);\n return section;\n}\n\nexport async function readRecentEntityTranscriptEntries(\n transcriptEntriesPromise: Promise<TranscriptEntry[]>,\n recentTurns: number,\n): Promise<TranscriptEntry[]> {\n if (recentTurns <= 0) return [];\n const transcriptEntries = await transcriptEntriesPromise.catch(() => []);\n if (transcriptEntries.length === 0) return [];\n return transcriptEntries.slice(-Math.max(1, recentTurns * 2));\n}\n\nexport const entityIndexVersion = ENTITY_INDEX_VERSION;\nexport const entityRecentTranscriptLookbackHours = RECENT_TRANSCRIPT_LOOKBACK_HOURS;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,kBAAkB;AAE3B,SAAS,OAAO,UAAU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CAAC,KAAK,IAAI,GAAG,cAAc,CAAC,CAAC;AAC9D;AAEO,IAAM,qBAAqB;AAC3B,IAAM,sCAAsC;","names":["index","token"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isRecallDisclosure
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5WVUO6QT.js";
|
|
4
4
|
import {
|
|
5
5
|
estimateTokenCount
|
|
6
6
|
} from "./chunk-TOTT6S2V.js";
|
|
@@ -304,4 +304,4 @@ export {
|
|
|
304
304
|
RecallXrayBuilder,
|
|
305
305
|
summarizeDisclosureTokens
|
|
306
306
|
};
|
|
307
|
-
//# sourceMappingURL=chunk-
|
|
307
|
+
//# sourceMappingURL=chunk-EHMMRZOZ.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
SupportPassportError,
|
|
3
3
|
SupportPassportOwnerCreateGrantRequestSchema,
|
|
4
4
|
getOperation
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-AWRJBAIH.js";
|
|
6
6
|
|
|
7
7
|
// src/support-passport/access-http.ts
|
|
8
8
|
var OWNER_ROOT = "/engram/v1/support-passport";
|
|
@@ -137,4 +137,4 @@ export {
|
|
|
137
137
|
SUPPORT_PASSPORT_OWNER_HTTP_ROUTES,
|
|
138
138
|
handleSupportPassportOwnerHttp
|
|
139
139
|
};
|
|
140
|
-
//# sourceMappingURL=chunk-
|
|
140
|
+
//# sourceMappingURL=chunk-EIQFIJDM.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
diffGraphSnapshots
|
|
3
|
-
} from "./chunk-AUDJPF4N.js";
|
|
4
1
|
import {
|
|
5
2
|
graphSnapshotFromMemoryDir
|
|
6
3
|
} from "./chunk-44442YCH.js";
|
|
4
|
+
import {
|
|
5
|
+
diffGraphSnapshots
|
|
6
|
+
} from "./chunk-AUDJPF4N.js";
|
|
7
7
|
|
|
8
8
|
// src/dashboard-runtime.ts
|
|
9
9
|
import { createHash, timingSafeEqual } from "crypto";
|
|
@@ -370,4 +370,4 @@ var GraphDashboardServer = class {
|
|
|
370
370
|
export {
|
|
371
371
|
GraphDashboardServer
|
|
372
372
|
};
|
|
373
|
-
//# sourceMappingURL=chunk-
|
|
373
|
+
//# sourceMappingURL=chunk-EZ25VE3G.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
StorageManager
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YUIBXMZY.js";
|
|
4
4
|
import {
|
|
5
5
|
bumpMemoryCorpusVersionForDir
|
|
6
6
|
} from "./chunk-KMAP7SNQ.js";
|
|
@@ -765,4 +765,4 @@ export {
|
|
|
765
765
|
listMemoryGovernanceRuns,
|
|
766
766
|
readMemoryGovernanceRunArtifact
|
|
767
767
|
};
|
|
768
|
-
//# sourceMappingURL=chunk-
|
|
768
|
+
//# sourceMappingURL=chunk-FW73HN33.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/entity-origin-fields.ts
|
|
2
|
+
function sanitizeOriginatedFacts(entries, sanitize, compact, deduplicate) {
|
|
3
|
+
const result = { facts: [], origins: [] };
|
|
4
|
+
const indexes = /* @__PURE__ */ new Map();
|
|
5
|
+
for (const entry of entries) {
|
|
6
|
+
const clean = sanitize(entry.text);
|
|
7
|
+
if (!clean) continue;
|
|
8
|
+
const fact = compact(clean, 180);
|
|
9
|
+
const index = deduplicate ? indexes.get(fact) ?? -1 : -1;
|
|
10
|
+
if (index < 0) {
|
|
11
|
+
indexes.set(fact, result.facts.length);
|
|
12
|
+
result.facts.push(fact);
|
|
13
|
+
result.origins.push(entry.origin);
|
|
14
|
+
} else if (result.origins[index] !== entry.origin) {
|
|
15
|
+
result.origins[index] = void 0;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
function buildOriginStructuredSections(sections, recallFacts, sanitize, compact) {
|
|
21
|
+
return sections.map((section) => {
|
|
22
|
+
const entries = recallFacts(section).map(({ text, sourceIndex }) => ({
|
|
23
|
+
text,
|
|
24
|
+
origin: section.factOrigins?.[sourceIndex]
|
|
25
|
+
}));
|
|
26
|
+
const result = sanitizeOriginatedFacts(entries, sanitize, compact, false);
|
|
27
|
+
return {
|
|
28
|
+
key: section.key,
|
|
29
|
+
title: section.title,
|
|
30
|
+
facts: result.facts,
|
|
31
|
+
...result.origins.some((origin) => origin !== void 0) ? { factOrigins: result.origins } : {}
|
|
32
|
+
};
|
|
33
|
+
}).filter((section) => section.facts.length > 0);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
sanitizeOriginatedFacts,
|
|
38
|
+
buildOriginStructuredSections
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=chunk-GKUA4MGB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/entity-origin-fields.ts"],"sourcesContent":["import type { EntityStructuredSection } from \"./types.js\";\n\ntype OriginatedEntry = { text: string; origin?: string };\ntype RecalledFact = { text: string; sourceIndex: number };\ntype SanitizedFacts = { facts: string[]; origins: Array<string | undefined> };\n\nexport type EntityOriginStructuredSection = EntityStructuredSection & {\n factOrigins?: Array<string | undefined>;\n};\n\nexport function sanitizeOriginatedFacts(\n entries: readonly OriginatedEntry[],\n sanitize: (value: string) => string,\n compact: (value: string, maxLength: number) => string,\n deduplicate: boolean,\n): SanitizedFacts {\n const result: SanitizedFacts = { facts: [], origins: [] };\n const indexes = new Map<string, number>();\n for (const entry of entries) {\n const clean = sanitize(entry.text);\n if (!clean) continue;\n const fact = compact(clean, 180);\n const index = deduplicate ? indexes.get(fact) ?? -1 : -1;\n if (index < 0) {\n indexes.set(fact, result.facts.length);\n result.facts.push(fact);\n result.origins.push(entry.origin);\n } else if (result.origins[index] !== entry.origin) {\n result.origins[index] = undefined;\n }\n }\n return result;\n}\n\nexport function buildOriginStructuredSections(\n sections: readonly EntityStructuredSection[],\n recallFacts: (section: EntityStructuredSection) => RecalledFact[],\n sanitize: (value: string) => string,\n compact: (value: string, maxLength: number) => string,\n): EntityOriginStructuredSection[] {\n return sections\n .map((section) => {\n const entries = recallFacts(section).map(({ text, sourceIndex }) => ({\n text,\n origin: section.factOrigins?.[sourceIndex],\n }));\n const result = sanitizeOriginatedFacts(entries, sanitize, compact, false);\n return {\n key: section.key,\n title: section.title,\n facts: result.facts,\n ...(result.origins.some((origin) => origin !== undefined) ? { factOrigins: result.origins } : {}),\n };\n })\n .filter((section) => section.facts.length > 0);\n}\n"],"mappings":";AAUO,SAAS,wBACd,SACA,UACA,SACA,aACgB;AAChB,QAAM,SAAyB,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,EAAE;AACxD,QAAM,UAAU,oBAAI,IAAoB;AACxC,aAAW,SAAS,SAAS;AAC3B,UAAM,QAAQ,SAAS,MAAM,IAAI;AACjC,QAAI,CAAC,MAAO;AACZ,UAAM,OAAO,QAAQ,OAAO,GAAG;AAC/B,UAAM,QAAQ,cAAc,QAAQ,IAAI,IAAI,KAAK,KAAK;AACtD,QAAI,QAAQ,GAAG;AACb,cAAQ,IAAI,MAAM,OAAO,MAAM,MAAM;AACrC,aAAO,MAAM,KAAK,IAAI;AACtB,aAAO,QAAQ,KAAK,MAAM,MAAM;AAAA,IAClC,WAAW,OAAO,QAAQ,KAAK,MAAM,MAAM,QAAQ;AACjD,aAAO,QAAQ,KAAK,IAAI;AAAA,IAC1B;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,8BACd,UACA,aACA,UACA,SACiC;AACjC,SAAO,SACJ,IAAI,CAAC,YAAY;AAChB,UAAM,UAAU,YAAY,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,YAAY,OAAO;AAAA,MACnE;AAAA,MACA,QAAQ,QAAQ,cAAc,WAAW;AAAA,IAC3C,EAAE;AACF,UAAM,SAAS,wBAAwB,SAAS,UAAU,SAAS,KAAK;AACxE,WAAO;AAAA,MACL,KAAK,QAAQ;AAAA,MACb,OAAO,QAAQ;AAAA,MACf,OAAO,OAAO;AAAA,MACd,GAAI,OAAO,QAAQ,KAAK,CAAC,WAAW,WAAW,MAAS,IAAI,EAAE,aAAa,OAAO,QAAQ,IAAI,CAAC;AAAA,IACjG;AAAA,EACF,CAAC,EACA,OAAO,CAAC,YAAY,QAAQ,MAAM,SAAS,CAAC;AACjD;","names":[]}
|
|
@@ -6,16 +6,16 @@ import {
|
|
|
6
6
|
} from "./chunk-TB6CBZ5V.js";
|
|
7
7
|
import {
|
|
8
8
|
AdapterRegistry
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JBPKEARU.js";
|
|
10
10
|
import {
|
|
11
11
|
serializeInlineScriptValue
|
|
12
12
|
} from "./chunk-3HSRWJTC.js";
|
|
13
13
|
import {
|
|
14
14
|
handleSupportPassportOwnerHttp
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-EIQFIJDM.js";
|
|
16
16
|
import {
|
|
17
17
|
buildSupportPassportPublicRequestHandler
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-KAB7TZN3.js";
|
|
19
19
|
import {
|
|
20
20
|
nonEmptyQueryParam,
|
|
21
21
|
optionalQueryString,
|
|
@@ -30,13 +30,13 @@ import {
|
|
|
30
30
|
processChatMessage,
|
|
31
31
|
sessionBelongsToPrincipal,
|
|
32
32
|
subscribeChatTranscript
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-4JGSG7QN.js";
|
|
34
34
|
import {
|
|
35
35
|
RelayMissionStoreError
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-XBR5BAKW.js";
|
|
37
37
|
import {
|
|
38
38
|
validateRequest
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-JKW663ZN.js";
|
|
40
40
|
import {
|
|
41
41
|
executeResolution,
|
|
42
42
|
isValidResolutionVerb
|
|
@@ -60,12 +60,12 @@ import {
|
|
|
60
60
|
authorizationProbeNamespaces,
|
|
61
61
|
authorizationProbeRequiresPrincipalNamespace,
|
|
62
62
|
probeOperationAuthorization
|
|
63
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-PA5OPZX2.js";
|
|
64
64
|
import {
|
|
65
65
|
CorrectionContractError,
|
|
66
66
|
getOperation,
|
|
67
67
|
resolveQueryNamespaceWritablePreflight
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-AWRJBAIH.js";
|
|
69
69
|
import {
|
|
70
70
|
isTrustZoneName
|
|
71
71
|
} from "./chunk-KQS72GCR.js";
|
|
@@ -74,7 +74,7 @@ import {
|
|
|
74
74
|
} from "./chunk-DEUNUKTD.js";
|
|
75
75
|
import {
|
|
76
76
|
isRecallDisclosure
|
|
77
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-5WVUO6QT.js";
|
|
78
78
|
import {
|
|
79
79
|
OFFLINE_SYNC_APPLY_MAX_BODY_BYTES,
|
|
80
80
|
OFFLINE_SYNC_FILE_CONTENT_MAX_CHUNK_BYTES,
|
|
@@ -3397,4 +3397,4 @@ export {
|
|
|
3397
3397
|
resolveDefaultAdminConsolePublicDir,
|
|
3398
3398
|
EngramAccessHttpServer
|
|
3399
3399
|
};
|
|
3400
|
-
//# sourceMappingURL=chunk-
|
|
3400
|
+
//# sourceMappingURL=chunk-GN7HO2LA.js.map
|