@remnic/core 9.64.0 → 9.64.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 +12 -11
- package/dist/access-admin-ops-surface.js +24 -23
- package/dist/access-authorization-probe.d.ts +12 -11
- package/dist/access-authorization-probe.js +25 -24
- package/dist/access-boundary.d.ts +13 -12
- package/dist/access-boundary.js +24 -23
- package/dist/access-cli.js +74 -72
- 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 +12 -11
- package/dist/access-extraction-force-flush.js +24 -23
- package/dist/access-health-types.d.ts +1 -1
- package/dist/access-http-lcm-compaction.d.ts +12 -11
- package/dist/access-http-lifecycle-flush.d.ts +12 -11
- package/dist/access-http-offline-stream.d.ts +12 -11
- package/dist/access-http-query.d.ts +2 -2
- package/dist/access-http-query.js +26 -25
- package/dist/access-http.d.ts +13 -12
- package/dist/access-http.js +41 -40
- package/dist/access-identity-continuity-surface.d.ts +9 -9
- package/dist/access-identity-continuity-surface.js +24 -23
- package/dist/access-lcm-surface.d.ts +12 -11
- package/dist/access-lcm-surface.js +24 -23
- package/dist/access-mcp-output-schemas.js +1 -1
- package/dist/access-mcp.d.ts +12 -186
- package/dist/access-mcp.js +33 -32
- package/dist/access-memory-search-fanout.d.ts +2 -2
- package/dist/{access-namespace-preflight-CrF0FKaz.d.ts → access-namespace-preflight-CYeI1R2_.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +3 -3
- package/dist/access-namespace-preflight.js +24 -23
- package/dist/access-observe-write-surface.d.ts +12 -11
- package/dist/access-observe-write-surface.js +24 -23
- package/dist/access-offline-manifest.d.ts +9 -9
- package/dist/access-operations-batch.js +27 -26
- package/dist/access-operations.d.ts +13 -12
- package/dist/access-operations.js +30 -29
- package/dist/access-recall-concurrency.d.ts +12 -11
- package/dist/access-recall-concurrency.js +24 -23
- package/dist/access-recall-response.d.ts +12 -11
- package/dist/access-recall-response.js +24 -23
- package/dist/access-recall-surface.d.ts +12 -11
- package/dist/access-recall-surface.js +24 -23
- package/dist/access-schema.js +3 -3
- package/dist/{access-service-BqF4UK8Z.d.ts → access-service-BKtdXnyk.d.ts} +294 -12
- package/dist/access-service-helpers.d.ts +12 -11
- package/dist/access-service.d.ts +12 -11
- package/dist/access-service.js +24 -23
- package/dist/access-surface-catalog.d.ts +12 -11
- package/dist/access-surface-catalog.js +28 -25
- 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 +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 +10 -10
- 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 +2 -2
- 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-C0KIwZqR.d.ts → catalog-CLAqQO2L.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 +11 -11
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/{chunk-BTUIHRRR.js → chunk-246HFJVG.js} +2 -2
- package/dist/{chunk-OWHERGF2.js → chunk-2NLLXCJG.js} +2 -2
- package/dist/{chunk-5SZ6CLGJ.js → chunk-2QI2JBLQ.js} +360 -238
- package/dist/chunk-2QI2JBLQ.js.map +1 -0
- package/dist/{chunk-6NMZXEJ7.js → chunk-3A46U7XG.js} +2 -2
- package/dist/{chunk-S6KMN6MJ.js → chunk-3LOQN3TO.js} +10 -5
- package/dist/chunk-3LOQN3TO.js.map +1 -0
- package/dist/{chunk-Z3Q5I5F6.js → chunk-44DSGZFF.js} +2 -2
- package/dist/{chunk-VENMDW4U.js → chunk-55SJFHVD.js} +6 -6
- package/dist/{chunk-VCBG52MM.js → chunk-5HERQ5FX.js} +7 -7
- package/dist/{chunk-IRXMJLTW.js → chunk-5HK3CJAR.js} +2 -2
- package/dist/{chunk-KG2CT762.js → chunk-6LTCUN3T.js} +2 -2
- package/dist/{chunk-UUYQWKHO.js → chunk-7BVO64UC.js} +2 -2
- package/dist/{chunk-X6HNXVXS.js → chunk-7V3AZWWZ.js} +4 -4
- package/dist/{chunk-EHC3FIJ4.js → chunk-A2IBK3TG.js} +2 -2
- package/dist/{chunk-6BV6ZZZA.js → chunk-C6AKYOFO.js} +2 -2
- package/dist/{chunk-7ML7STOD.js → chunk-CKZHKFY3.js} +3 -3
- package/dist/{chunk-CUDSA46O.js → chunk-CUIAHZPZ.js} +2 -2
- package/dist/{chunk-QFPX7QZG.js → chunk-DA2O3F5V.js} +25 -11
- package/dist/chunk-DA2O3F5V.js.map +1 -0
- package/dist/{chunk-CTD5CPD2.js → chunk-DC4FJY2G.js} +22 -7
- package/dist/{chunk-CTD5CPD2.js.map → chunk-DC4FJY2G.js.map} +1 -1
- package/dist/{chunk-2BRCV2IV.js → chunk-DG6MJD7W.js} +2 -2
- package/dist/{chunk-YGSDWO3U.js → chunk-DHKV6E4A.js} +2 -2
- package/dist/{chunk-DZFPHARJ.js → chunk-EJDLQRUO.js} +2 -2
- package/dist/{chunk-VD2OT77P.js → chunk-GEULB2VI.js} +2 -1
- package/dist/chunk-GEULB2VI.js.map +1 -0
- package/dist/{chunk-BPLPGOUJ.js → chunk-GVRLED7R.js} +2 -2
- package/dist/{chunk-YINSSARY.js → chunk-H5CGAD7L.js} +1 -1
- package/dist/{chunk-QICOU4RY.js → chunk-IFK3PVM7.js} +2 -2
- package/dist/{chunk-E7MYSCSL.js → chunk-IJXECCUV.js} +2 -2
- package/dist/{chunk-RKNJBZ55.js → chunk-JBPKEARU.js} +4 -4
- package/dist/{chunk-WQ6TRWAE.js → chunk-JCSUNXYJ.js} +3 -3
- package/dist/{chunk-5W7CTZ2E.js → chunk-KQAFEZQX.js} +4 -4
- package/dist/{chunk-6IKXAAJI.js → chunk-KRPE7ANR.js} +2 -2
- package/dist/{chunk-FEP45MYY.js → chunk-LOETWOEB.js} +2 -2
- package/dist/{chunk-4IIDTPSK.js → chunk-LZKCMK3U.js} +2 -2
- package/dist/{chunk-ML4MI2RR.js → chunk-MJRVF7SF.js} +29 -28
- package/dist/chunk-MJRVF7SF.js.map +1 -0
- package/dist/{chunk-K547KS3X.js → chunk-ML3U4KPR.js} +4 -4
- package/dist/{chunk-HIEWDJ2O.js → chunk-MSTNSVXI.js} +2 -1
- package/dist/chunk-MSTNSVXI.js.map +1 -0
- package/dist/{chunk-BTBAHTQ5.js → chunk-NO7B6DRB.js} +2 -2
- package/dist/{chunk-G5F4MXXC.js → chunk-ON2P3SHG.js} +2 -2
- package/dist/{chunk-2Q4UAPLD.js → chunk-OQIRBGUU.js} +4 -4
- package/dist/{chunk-PQODT53H.js → chunk-PE76XIDM.js} +3 -3
- package/dist/{chunk-MVIYRRVJ.js → chunk-PMVPCZJZ.js} +5 -5
- package/dist/{chunk-CK3DZ6OE.js → chunk-PVIXAMWM.js} +2 -2
- package/dist/{chunk-BB2LH5JM.js → chunk-RNORDDD6.js} +11 -1
- package/dist/chunk-RNORDDD6.js.map +1 -0
- package/dist/{chunk-HZXO2CJ6.js → chunk-RWLRKMZK.js} +2 -2
- package/dist/{chunk-SYU5JOBQ.js → chunk-SB6YBB2V.js} +2 -2
- package/dist/{chunk-3F3CVVDS.js → chunk-SHQFYZTD.js} +2 -2
- package/dist/chunk-TKI2WOL5.js +256 -0
- package/dist/chunk-TKI2WOL5.js.map +1 -0
- package/dist/chunk-TY35YQ6E.js +77 -0
- package/dist/chunk-TY35YQ6E.js.map +1 -0
- package/dist/{chunk-R7XE5ZUR.js → chunk-UIYYS2YI.js} +2 -2
- package/dist/{chunk-ZWYXSF2T.js → chunk-UMDZXW5J.js} +118 -4
- package/dist/chunk-UMDZXW5J.js.map +1 -0
- package/dist/{chunk-G5OB4XZX.js → chunk-VANZKHTN.js} +4 -4
- package/dist/{chunk-QATILW4B.js → chunk-VLES5S4K.js} +271 -62
- package/dist/chunk-VLES5S4K.js.map +1 -0
- package/dist/{chunk-AR253JBM.js → chunk-VRYEXPRX.js} +1 -1
- package/dist/chunk-VRYEXPRX.js.map +1 -0
- package/dist/{chunk-7DRSWPUV.js → chunk-VUP47UJI.js} +3 -3
- package/dist/{chunk-65NQFK7D.js → chunk-WBM5NR4E.js} +2 -2
- package/dist/{chunk-UVYI6VIX.js → chunk-X7Y7WX73.js} +1 -1
- package/dist/{chunk-GIMQJ5RX.js → chunk-XACYILRA.js} +49 -14
- package/dist/chunk-XACYILRA.js.map +1 -0
- package/dist/{chunk-63JMI45N.js → chunk-XBRGJJK7.js} +2 -2
- package/dist/{chunk-WCWIV2JH.js → chunk-XH4IQVTN.js} +2 -2
- package/dist/{chunk-77E7LLMV.js → chunk-XZUCNVGE.js} +8 -8
- package/dist/{chunk-LJQGQUNS.js → chunk-YFQTDE7N.js} +2 -2
- package/dist/{chunk-5OOTHWGJ.js → chunk-YXGU3MDQ.js} +2 -2
- package/dist/{chunk-SRLQROQJ.js → chunk-Z6CJLYXT.js} +4 -4
- package/dist/{chunk-Z4UPRZR6.js → chunk-ZSYE2QVJ.js} +2 -2
- package/dist/{cli-BX0O688c.d.ts → cli-CLvBewKf.d.ts} +5 -5
- package/dist/cli.d.ts +13 -13
- package/dist/cli.js +57 -56
- package/dist/coding/pre-action-gate.d.ts +1 -1
- package/dist/compounding/engine.d.ts +2 -2
- package/dist/compounding/engine.js +10 -10
- 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 +1 -1
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +10 -10
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +10 -10
- 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 +12 -12
- 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 +12 -12
- 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-Cph4PnBe.d.ts → dependency-propagation-delivery-DMqIw9Zh.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 +1 -1
- package/dist/entity-retrieval.d.ts +2 -2
- package/dist/entity-retrieval.js +10 -10
- package/dist/entity-schema.d.ts +1 -1
- package/dist/episodic-context.d.ts +1 -1
- package/dist/explicit-capture.d.ts +9 -9
- package/dist/external-wiki-access.d.ts +12 -11
- package/dist/external-wiki-access.js +25 -24
- 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 +12 -13
- 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 +13 -13
- 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 +33 -24
- package/dist/index.js +120 -84
- 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 +11 -11
- 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 +10 -10
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +10 -10
- package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-projection.js +11 -11
- package/dist/{maintenance-BNq31xpo.d.ts → maintenance-DITiehFX.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +12 -11
- package/dist/mcp-read-only-tools.js +1 -1
- 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 +11 -11
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/search.js +7 -7
- package/dist/namespaces/storage.d.ts +3 -3
- package/dist/namespaces/storage.js +10 -10
- 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 +13 -13
- package/dist/operator-doctor-replica.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +3 -3
- package/dist/operator-toolkit.js +19 -19
- 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-CBuUOP2J.d.ts → orchestrator-6fPa2l9x.d.ts} +8 -8
- package/dist/orchestrator.d.ts +9 -9
- package/dist/orchestrator.js +74 -72
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/{pipeline-CW_Q4WvX.d.ts → pipeline-DHpYtfM3.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-BeJ1_JI1.d.ts → public-http-BT36aBb-.d.ts} +1 -1
- package/dist/{qmd-q-cAzYuC.d.ts → qmd-BaX31tM0.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/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/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-CIr4mXgp.d.ts → scope-profiles-1hYWJ9bM.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 +6 -6
- package/dist/search/index.d.ts +1 -1
- package/dist/search/index.js +10 -10
- 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-BZ6J46j-.d.ts → semantic-consolidation-Chmddvcg.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +11 -11
- package/dist/semantic-rule-promotion.js +10 -10
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +10 -10
- package/dist/{service-CCl4iyyY.d.ts → service-DMs_dCCg.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/source-agent-qualifier.d.ts +1 -1
- package/dist/source-agent-qualifier.js +12 -12
- package/dist/{storage-BPXmJKIt.d.ts → storage-CzorrpcN.d.ts} +12 -3
- package/dist/storage.d.ts +2 -2
- package/dist/storage.js +9 -9
- package/dist/summarizer.d.ts +1 -1
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/support-passport/index.d.ts +15 -14
- package/dist/support-passport/index.js +27 -26
- 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/trust-score-stage.d.ts +1 -1
- package/dist/trust-score.d.ts +1 -1
- package/dist/{types-CltSWcND.d.ts → types-BP5MC8UU.d.ts} +34 -8
- 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 +10 -10
- package/dist/who-knows-cli.d.ts +155 -0
- package/dist/who-knows-cli.js +109 -0
- package/dist/who-knows-cli.js.map +1 -0
- package/dist/who-knows.d.ts +127 -0
- package/dist/who-knows.js +118 -0
- package/dist/who-knows.js.map +1 -0
- package/dist/write-envelope.d.ts +1 -1
- package/package.json +2 -2
- package/src/access-boundary.ts +1 -0
- package/src/access-http.ts +15 -0
- package/src/access-mcp-output-schemas.ts +1 -0
- package/src/access-mcp.ts +3 -2
- package/src/access-operations-batch.ts +8 -0
- package/src/access-service.ts +26 -0
- package/src/access-surface-catalog.ts +2 -0
- package/src/cli/okf-commands.ts +23 -0
- package/src/cli.ts +2 -1
- package/src/config.ts +7 -7
- package/src/index.ts +3 -0
- package/src/location/cli.ts +163 -0
- package/src/location/config.test.ts +75 -0
- package/src/location/config.ts +105 -0
- package/src/location/intervals.test.ts +202 -0
- package/src/location/intervals.ts +221 -0
- package/src/location/parse-companions.ts +12 -0
- package/src/location/pipeline.test.ts +324 -0
- package/src/location/pipeline.ts +245 -0
- package/src/location/recall-exclusion.test.ts +36 -0
- package/src/location/registry.test.ts +74 -0
- package/src/location/registry.ts +54 -0
- package/src/location/store.test.ts +170 -0
- package/src/location/store.ts +478 -0
- package/src/location/types.ts +95 -0
- package/src/mcp-read-only-tools.ts +1 -0
- package/src/okf/cli.ts +42 -0
- package/src/okf/config.ts +34 -0
- package/src/okf/lint.ts +110 -0
- package/src/okf/sweep.ts +63 -0
- package/src/okf/type-mapping.test.ts +207 -0
- package/src/okf/type-mapping.ts +79 -0
- package/src/orchestration/generic-recall-paths.ts +17 -0
- package/src/orchestration/orchestrator-helpers.ts +22 -0
- package/src/orchestration/qmd-result-resolver.ts +1 -0
- package/src/orchestrator.ts +2 -0
- package/src/storage/entity-store.ts +9 -5
- package/src/storage/profile-header.ts +33 -9
- package/src/storage/questions-file.ts +50 -0
- package/src/storage.ts +76 -63
- package/src/types.ts +6 -8
- package/src/who-knows-cli.ts +96 -0
- package/src/who-knows.test.ts +257 -0
- package/src/who-knows.ts +364 -0
- package/dist/chunk-5SZ6CLGJ.js.map +0 -1
- package/dist/chunk-AR253JBM.js.map +0 -1
- package/dist/chunk-BB2LH5JM.js.map +0 -1
- package/dist/chunk-GIMQJ5RX.js.map +0 -1
- package/dist/chunk-HIEWDJ2O.js.map +0 -1
- package/dist/chunk-ML4MI2RR.js.map +0 -1
- package/dist/chunk-QATILW4B.js.map +0 -1
- package/dist/chunk-QFPX7QZG.js.map +0 -1
- package/dist/chunk-S6KMN6MJ.js.map +0 -1
- package/dist/chunk-VD2OT77P.js.map +0 -1
- package/dist/chunk-ZWYXSF2T.js.map +0 -1
- /package/dist/{capsule-crypto-GWVG7LGC.js.map → capsule-crypto-7FJQINUR.js.map} +0 -0
- /package/dist/{chunk-BTUIHRRR.js.map → chunk-246HFJVG.js.map} +0 -0
- /package/dist/{chunk-OWHERGF2.js.map → chunk-2NLLXCJG.js.map} +0 -0
- /package/dist/{chunk-6NMZXEJ7.js.map → chunk-3A46U7XG.js.map} +0 -0
- /package/dist/{chunk-Z3Q5I5F6.js.map → chunk-44DSGZFF.js.map} +0 -0
- /package/dist/{chunk-VENMDW4U.js.map → chunk-55SJFHVD.js.map} +0 -0
- /package/dist/{chunk-VCBG52MM.js.map → chunk-5HERQ5FX.js.map} +0 -0
- /package/dist/{chunk-IRXMJLTW.js.map → chunk-5HK3CJAR.js.map} +0 -0
- /package/dist/{chunk-KG2CT762.js.map → chunk-6LTCUN3T.js.map} +0 -0
- /package/dist/{chunk-UUYQWKHO.js.map → chunk-7BVO64UC.js.map} +0 -0
- /package/dist/{chunk-X6HNXVXS.js.map → chunk-7V3AZWWZ.js.map} +0 -0
- /package/dist/{chunk-EHC3FIJ4.js.map → chunk-A2IBK3TG.js.map} +0 -0
- /package/dist/{chunk-6BV6ZZZA.js.map → chunk-C6AKYOFO.js.map} +0 -0
- /package/dist/{chunk-7ML7STOD.js.map → chunk-CKZHKFY3.js.map} +0 -0
- /package/dist/{chunk-CUDSA46O.js.map → chunk-CUIAHZPZ.js.map} +0 -0
- /package/dist/{chunk-2BRCV2IV.js.map → chunk-DG6MJD7W.js.map} +0 -0
- /package/dist/{chunk-YGSDWO3U.js.map → chunk-DHKV6E4A.js.map} +0 -0
- /package/dist/{chunk-DZFPHARJ.js.map → chunk-EJDLQRUO.js.map} +0 -0
- /package/dist/{chunk-BPLPGOUJ.js.map → chunk-GVRLED7R.js.map} +0 -0
- /package/dist/{chunk-YINSSARY.js.map → chunk-H5CGAD7L.js.map} +0 -0
- /package/dist/{chunk-QICOU4RY.js.map → chunk-IFK3PVM7.js.map} +0 -0
- /package/dist/{chunk-E7MYSCSL.js.map → chunk-IJXECCUV.js.map} +0 -0
- /package/dist/{chunk-RKNJBZ55.js.map → chunk-JBPKEARU.js.map} +0 -0
- /package/dist/{chunk-WQ6TRWAE.js.map → chunk-JCSUNXYJ.js.map} +0 -0
- /package/dist/{chunk-5W7CTZ2E.js.map → chunk-KQAFEZQX.js.map} +0 -0
- /package/dist/{chunk-6IKXAAJI.js.map → chunk-KRPE7ANR.js.map} +0 -0
- /package/dist/{chunk-FEP45MYY.js.map → chunk-LOETWOEB.js.map} +0 -0
- /package/dist/{chunk-4IIDTPSK.js.map → chunk-LZKCMK3U.js.map} +0 -0
- /package/dist/{chunk-K547KS3X.js.map → chunk-ML3U4KPR.js.map} +0 -0
- /package/dist/{chunk-BTBAHTQ5.js.map → chunk-NO7B6DRB.js.map} +0 -0
- /package/dist/{chunk-G5F4MXXC.js.map → chunk-ON2P3SHG.js.map} +0 -0
- /package/dist/{chunk-2Q4UAPLD.js.map → chunk-OQIRBGUU.js.map} +0 -0
- /package/dist/{chunk-PQODT53H.js.map → chunk-PE76XIDM.js.map} +0 -0
- /package/dist/{chunk-MVIYRRVJ.js.map → chunk-PMVPCZJZ.js.map} +0 -0
- /package/dist/{chunk-CK3DZ6OE.js.map → chunk-PVIXAMWM.js.map} +0 -0
- /package/dist/{chunk-HZXO2CJ6.js.map → chunk-RWLRKMZK.js.map} +0 -0
- /package/dist/{chunk-SYU5JOBQ.js.map → chunk-SB6YBB2V.js.map} +0 -0
- /package/dist/{chunk-3F3CVVDS.js.map → chunk-SHQFYZTD.js.map} +0 -0
- /package/dist/{chunk-R7XE5ZUR.js.map → chunk-UIYYS2YI.js.map} +0 -0
- /package/dist/{chunk-G5OB4XZX.js.map → chunk-VANZKHTN.js.map} +0 -0
- /package/dist/{chunk-7DRSWPUV.js.map → chunk-VUP47UJI.js.map} +0 -0
- /package/dist/{chunk-65NQFK7D.js.map → chunk-WBM5NR4E.js.map} +0 -0
- /package/dist/{chunk-UVYI6VIX.js.map → chunk-X7Y7WX73.js.map} +0 -0
- /package/dist/{chunk-63JMI45N.js.map → chunk-XBRGJJK7.js.map} +0 -0
- /package/dist/{chunk-WCWIV2JH.js.map → chunk-XH4IQVTN.js.map} +0 -0
- /package/dist/{chunk-77E7LLMV.js.map → chunk-XZUCNVGE.js.map} +0 -0
- /package/dist/{chunk-LJQGQUNS.js.map → chunk-YFQTDE7N.js.map} +0 -0
- /package/dist/{chunk-5OOTHWGJ.js.map → chunk-YXGU3MDQ.js.map} +0 -0
- /package/dist/{chunk-SRLQROQJ.js.map → chunk-Z6CJLYXT.js.map} +0 -0
- /package/dist/{chunk-Z4UPRZR6.js.map → chunk-ZSYE2QVJ.js.map} +0 -0
|
@@ -17,14 +17,14 @@ import {
|
|
|
17
17
|
} from "./chunk-46WM6JX2.js";
|
|
18
18
|
import {
|
|
19
19
|
normalizeQmdResultPath
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-IJXECCUV.js";
|
|
21
21
|
import {
|
|
22
22
|
withholdToolScopedFromSharedNamespace
|
|
23
23
|
} from "./chunk-S2V7RUCL.js";
|
|
24
24
|
import {
|
|
25
25
|
SPECULATIVE_TTL_DAYS,
|
|
26
26
|
confidenceTier
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-VRYEXPRX.js";
|
|
28
28
|
import {
|
|
29
29
|
normalizeProjectionPreview,
|
|
30
30
|
normalizeProjectionTags
|
|
@@ -259,7 +259,7 @@ import {
|
|
|
259
259
|
} from "fs/promises";
|
|
260
260
|
import { appendFileSync, createReadStream, mkdirSync, statSync as statSync2 } from "fs";
|
|
261
261
|
import { createHash as createHash6 } from "crypto";
|
|
262
|
-
import
|
|
262
|
+
import path14 from "path";
|
|
263
263
|
|
|
264
264
|
// src/storage/tombstone-migration-sources.ts
|
|
265
265
|
import { statSync } from "fs";
|
|
@@ -1587,6 +1587,107 @@ function renderProfileWithLastUpdated(content, updatedAt) {
|
|
|
1587
1587
|
insertHeaderAfter(lines, titleIndex, header);
|
|
1588
1588
|
return renderProfileLines(lines);
|
|
1589
1589
|
}
|
|
1590
|
+
function withOkfProfileFrontmatter(content, timestamp, enabled) {
|
|
1591
|
+
if (!enabled || stripOkfProfileFrontmatter(content) !== content) return content;
|
|
1592
|
+
return `---
|
|
1593
|
+
type: Profile
|
|
1594
|
+
title: User Profile
|
|
1595
|
+
timestamp: ${timestamp}
|
|
1596
|
+
---
|
|
1597
|
+
${content}`;
|
|
1598
|
+
}
|
|
1599
|
+
function stripOkfProfileFrontmatter(content) {
|
|
1600
|
+
if (!content.startsWith("---\n") && !content.startsWith("---\r\n")) return content;
|
|
1601
|
+
const lines = content.split("\n");
|
|
1602
|
+
for (let index = 1; index < lines.length; index += 1) {
|
|
1603
|
+
const line = lines[index];
|
|
1604
|
+
if (line === "---" || line === "---\r") {
|
|
1605
|
+
return lines.slice(1, index).some((l) => l.startsWith("type: Profile")) ? lines.slice(index + 1).join("\n") : content;
|
|
1606
|
+
}
|
|
1607
|
+
if (line === "" || line === "\r" || line === "...") return content;
|
|
1608
|
+
}
|
|
1609
|
+
return content;
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
// src/storage/questions-file.ts
|
|
1613
|
+
import path4 from "path";
|
|
1614
|
+
function parseQuestionFile(raw, filePath) {
|
|
1615
|
+
if (!raw.startsWith("---\n")) return null;
|
|
1616
|
+
const close = raw.indexOf("\n---\n\n", 4);
|
|
1617
|
+
if (close === -1) return null;
|
|
1618
|
+
const frontmatterStr = raw.slice(4, close);
|
|
1619
|
+
const body = raw.slice(close + 6).trim();
|
|
1620
|
+
const id = extractFrontmatterValue(frontmatterStr, "id") ?? path4.basename(filePath, ".md");
|
|
1621
|
+
const created = extractFrontmatterValue(frontmatterStr, "created") ?? "";
|
|
1622
|
+
const priority = parseFloat(extractFrontmatterValue(frontmatterStr, "priority") ?? "0.5");
|
|
1623
|
+
const resolved = extractFrontmatterValue(frontmatterStr, "resolved") === "true";
|
|
1624
|
+
const contextMarker = "**Context:**";
|
|
1625
|
+
const contextAt = body.indexOf(contextMarker);
|
|
1626
|
+
const question = contextAt === -1 ? body : body.slice(0, contextAt).trim();
|
|
1627
|
+
const context = contextAt === -1 ? "" : body.slice(contextAt + contextMarker.length).trim();
|
|
1628
|
+
return { id, question, context, priority, resolved, created, filePath };
|
|
1629
|
+
}
|
|
1630
|
+
function extractFrontmatterValue(frontmatter, key) {
|
|
1631
|
+
const prefix = `${key}:`;
|
|
1632
|
+
for (const line of frontmatter.split("\n")) {
|
|
1633
|
+
if (!line.startsWith(prefix)) continue;
|
|
1634
|
+
let value = line.slice(prefix.length).trim();
|
|
1635
|
+
if (value.startsWith('"') && value.endsWith('"') && value.length >= 2) {
|
|
1636
|
+
value = value.slice(1, -1);
|
|
1637
|
+
}
|
|
1638
|
+
return value;
|
|
1639
|
+
}
|
|
1640
|
+
return null;
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
// src/okf/type-mapping.ts
|
|
1644
|
+
import path5 from "path";
|
|
1645
|
+
var OKF_TYPE_BY_CATEGORY = Object.freeze({
|
|
1646
|
+
fact: "Memory Fact",
|
|
1647
|
+
decision: "Decision",
|
|
1648
|
+
preference: "Preference",
|
|
1649
|
+
commitment: "Commitment",
|
|
1650
|
+
relationship: "Relationship",
|
|
1651
|
+
principle: "Principle",
|
|
1652
|
+
moment: "Moment",
|
|
1653
|
+
skill: "Skill",
|
|
1654
|
+
correction: "Correction",
|
|
1655
|
+
rule: "Rule"
|
|
1656
|
+
});
|
|
1657
|
+
var OKF_TYPE_FALLBACK = "Memory";
|
|
1658
|
+
function okfTypeForCategory(category) {
|
|
1659
|
+
return OKF_TYPE_BY_CATEGORY[category] ?? OKF_TYPE_FALLBACK;
|
|
1660
|
+
}
|
|
1661
|
+
function okfTypeForMemory(fm) {
|
|
1662
|
+
return fm.artifactType ? "Artifact" : okfTypeForCategory(fm.category);
|
|
1663
|
+
}
|
|
1664
|
+
var OKF_TYPE_BY_ENTITY_KIND = Object.freeze({
|
|
1665
|
+
person: "Person",
|
|
1666
|
+
company: "Company",
|
|
1667
|
+
organization: "Organization",
|
|
1668
|
+
project: "Project",
|
|
1669
|
+
topic: "Topic",
|
|
1670
|
+
technology: "Technology",
|
|
1671
|
+
place: "Place",
|
|
1672
|
+
event: "Event"
|
|
1673
|
+
});
|
|
1674
|
+
function okfTypeForEntityKind(kind) {
|
|
1675
|
+
const normalized = kind?.trim().toLowerCase();
|
|
1676
|
+
return normalized !== void 0 && OKF_TYPE_BY_ENTITY_KIND[normalized] || "Entity";
|
|
1677
|
+
}
|
|
1678
|
+
var OKF_QUESTION_TYPE = "Question";
|
|
1679
|
+
var OKF_RESERVED_BASENAMES = Object.freeze({
|
|
1680
|
+
"index.md": true,
|
|
1681
|
+
"log.md": true
|
|
1682
|
+
});
|
|
1683
|
+
function assertNotOkfReservedBasename(filePath) {
|
|
1684
|
+
const basename = path5.basename(filePath);
|
|
1685
|
+
if (OKF_RESERVED_BASENAMES[basename] === true) {
|
|
1686
|
+
throw new Error(
|
|
1687
|
+
`OKF reserved basename '${basename}' is not a valid memory file target (${filePath}); OKF \xA76/\xA77 reserves it for bundle-level files.`
|
|
1688
|
+
);
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1590
1691
|
|
|
1591
1692
|
// src/orchestration/self-deps.ts
|
|
1592
1693
|
function selfDeps(self) {
|
|
@@ -1609,7 +1710,7 @@ function selfDeps(self) {
|
|
|
1609
1710
|
|
|
1610
1711
|
// src/storage/entity-store.ts
|
|
1611
1712
|
import { readdir as readdir2, unlink } from "fs/promises";
|
|
1612
|
-
import
|
|
1713
|
+
import path6 from "path";
|
|
1613
1714
|
var EntityStore = class {
|
|
1614
1715
|
constructor(deps) {
|
|
1615
1716
|
this.deps = deps;
|
|
@@ -1629,7 +1730,7 @@ var EntityStore = class {
|
|
|
1629
1730
|
async readEntityForMutation(name, method, historicalIds) {
|
|
1630
1731
|
const canonical = resolveHistoricalEntityCanonicalId(name, historicalIds);
|
|
1631
1732
|
for (const candidate of canonical === name ? [name] : [canonical, name]) {
|
|
1632
|
-
const filePath =
|
|
1733
|
+
const filePath = path6.join(this.deps.entitiesDir, `${candidate}.md`);
|
|
1633
1734
|
try {
|
|
1634
1735
|
const entity = parseEntityFile(await this.deps.readStorageSecureFile(filePath), this.deps.entitySchemas);
|
|
1635
1736
|
return { filePath, entity };
|
|
@@ -1654,7 +1755,7 @@ var EntityStore = class {
|
|
|
1654
1755
|
* `mutate` returns false to skip the write. Resolves true when written.
|
|
1655
1756
|
*/
|
|
1656
1757
|
async mutateEntityFile(name, method, mutate) {
|
|
1657
|
-
const stateDir =
|
|
1758
|
+
const stateDir = path6.join(this.deps.baseDir, "state");
|
|
1658
1759
|
return withEntityCanonicalMutationLock(stateDir, async () => {
|
|
1659
1760
|
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
1660
1761
|
const idsAtResolve = this.deps.currentHistoricalIds();
|
|
@@ -1665,7 +1766,7 @@ var EntityStore = class {
|
|
|
1665
1766
|
located.entity.updated = (/* @__PURE__ */ new Date()).toISOString();
|
|
1666
1767
|
await this.deps.writeStorageSecureFile(
|
|
1667
1768
|
located.filePath,
|
|
1668
|
-
serializeEntityFile(located.entity, this.deps.entitySchemas)
|
|
1769
|
+
serializeEntityFile(located.entity, this.deps.entitySchemas, this.deps.okfConformanceEnabled())
|
|
1669
1770
|
);
|
|
1670
1771
|
reconcileIfJournalMovedSync(stateDir, idsAtResolve, this.deps.currentHistoricalIds());
|
|
1671
1772
|
this.deps.invalidateKnowledgeIndexCache();
|
|
@@ -1709,7 +1810,7 @@ var EntityStore = class {
|
|
|
1709
1810
|
async writeEntity(name, type, facts, options = {}) {
|
|
1710
1811
|
await this.deps.ensureDirectories();
|
|
1711
1812
|
return withEntityCanonicalMutationLock(
|
|
1712
|
-
|
|
1813
|
+
path6.join(this.deps.baseDir, "state"),
|
|
1713
1814
|
() => this.writeEntityUnlocked(name, type, facts, options)
|
|
1714
1815
|
);
|
|
1715
1816
|
}
|
|
@@ -1730,7 +1831,7 @@ var EntityStore = class {
|
|
|
1730
1831
|
log.debug(`fuzzy match: "${normalized}" \u2192 existing "${match}"`);
|
|
1731
1832
|
normalized = match;
|
|
1732
1833
|
}
|
|
1733
|
-
const filePath =
|
|
1834
|
+
const filePath = path6.join(this.deps.entitiesDir, `${normalized}.md`);
|
|
1734
1835
|
let entity = {
|
|
1735
1836
|
name,
|
|
1736
1837
|
type,
|
|
@@ -1819,7 +1920,7 @@ var EntityStore = class {
|
|
|
1819
1920
|
entity.created = entity.created || timestamp;
|
|
1820
1921
|
entity.updated = (/* @__PURE__ */ new Date()).toISOString();
|
|
1821
1922
|
await this.deps.snapshotBeforeWrite(filePath, "write");
|
|
1822
|
-
await this.deps.writeStorageSecureFile(filePath, serializeEntityFile(entity, this.deps.entitySchemas));
|
|
1923
|
+
await this.deps.writeStorageSecureFile(filePath, serializeEntityFile(entity, this.deps.entitySchemas, this.deps.okfConformanceEnabled()));
|
|
1823
1924
|
this.deps.invalidateKnowledgeIndexCache();
|
|
1824
1925
|
this.deps.bumpMemoryStatusVersion();
|
|
1825
1926
|
this.deps.bumpEntityMutationVersion();
|
|
@@ -1851,13 +1952,13 @@ var EntityStore = class {
|
|
|
1851
1952
|
/** Re-serialize every entity file into the compiled-truth timeline shape. */
|
|
1852
1953
|
async migrateEntityFilesToCompiledTruthTimeline() {
|
|
1853
1954
|
const entityNames = await this.listEntityNames();
|
|
1854
|
-
const stateDir =
|
|
1955
|
+
const stateDir = path6.join(this.deps.baseDir, "state");
|
|
1855
1956
|
let migrated = 0;
|
|
1856
1957
|
for (const entityName of entityNames) {
|
|
1857
1958
|
const wrote = await withEntityCanonicalMutationLock(stateDir, async () => {
|
|
1858
1959
|
const raw = await this.readEntity(entityName);
|
|
1859
1960
|
if (!raw) return false;
|
|
1860
|
-
const serialized = serializeEntityFile(parseEntityFile(raw, this.deps.entitySchemas), this.deps.entitySchemas);
|
|
1961
|
+
const serialized = serializeEntityFile(parseEntityFile(raw, this.deps.entitySchemas), this.deps.entitySchemas, this.deps.okfConformanceEnabled());
|
|
1861
1962
|
if (raw.trimEnd() === serialized.trimEnd()) return false;
|
|
1862
1963
|
const filePath = this.deps.resolveEntityFilePath(entityName);
|
|
1863
1964
|
if (filePath === null) return false;
|
|
@@ -1878,12 +1979,12 @@ var EntityStore = class {
|
|
|
1878
1979
|
*/
|
|
1879
1980
|
async updateEntitySynthesis(name, synthesis, options = {}) {
|
|
1880
1981
|
return withEntityCanonicalMutationLock(
|
|
1881
|
-
|
|
1982
|
+
path6.join(this.deps.baseDir, "state"),
|
|
1882
1983
|
() => this.updateEntitySynthesisUnlocked(name, synthesis, options)
|
|
1883
1984
|
);
|
|
1884
1985
|
}
|
|
1885
1986
|
async updateEntitySynthesisUnlocked(name, synthesis, options = {}) {
|
|
1886
|
-
const filePath =
|
|
1987
|
+
const filePath = path6.join(this.deps.entitiesDir, `${name}.md`);
|
|
1887
1988
|
let entity;
|
|
1888
1989
|
try {
|
|
1889
1990
|
const content = await this.deps.readStorageSecureFile(filePath);
|
|
@@ -1907,7 +2008,7 @@ var EntityStore = class {
|
|
|
1907
2008
|
entity.synthesisStructuredFactDigest = synthesisStructuredFactDigest;
|
|
1908
2009
|
entity.synthesisVersion = Math.max(0, entity.synthesisVersion ?? 0) + (options.incrementVersion === false ? 0 : 1);
|
|
1909
2010
|
entity.updated = entityUpdatedAt;
|
|
1910
|
-
await this.deps.writeStorageSecureFile(filePath, serializeEntityFile(entity, this.deps.entitySchemas));
|
|
2011
|
+
await this.deps.writeStorageSecureFile(filePath, serializeEntityFile(entity, this.deps.entitySchemas, this.deps.okfConformanceEnabled()));
|
|
1911
2012
|
await this.deps.removeEntitySynthesisQueueEntries([
|
|
1912
2013
|
.../* @__PURE__ */ new Set([name, this.deps.normalizeEntityName(entity.name, entity.type)])
|
|
1913
2014
|
]);
|
|
@@ -1941,7 +2042,7 @@ var EntityStore = class {
|
|
|
1941
2042
|
const results = await Promise.all(
|
|
1942
2043
|
batch.map(async (entry) => {
|
|
1943
2044
|
try {
|
|
1944
|
-
return await this.deps.readStorageSecureFile(
|
|
2045
|
+
return await this.deps.readStorageSecureFile(path6.join(this.deps.entitiesDir, entry));
|
|
1945
2046
|
} catch (err) {
|
|
1946
2047
|
if (err instanceof SecureStoreLockedError) throw err;
|
|
1947
2048
|
if (!isErrnoCode(err, "ENOENT")) throw err;
|
|
@@ -2016,7 +2117,7 @@ ${rows.join("\n")}
|
|
|
2016
2117
|
*/
|
|
2017
2118
|
async mergeFragmentedEntities() {
|
|
2018
2119
|
return withEntityCanonicalMutationLock(
|
|
2019
|
-
|
|
2120
|
+
path6.join(this.deps.baseDir, "state"),
|
|
2020
2121
|
() => this.mergeFragmentedEntitiesUnlocked()
|
|
2021
2122
|
);
|
|
2022
2123
|
}
|
|
@@ -2061,7 +2162,7 @@ ${rows.join("\n")}
|
|
|
2061
2162
|
extraSections: []
|
|
2062
2163
|
};
|
|
2063
2164
|
for (const file of files) {
|
|
2064
|
-
const filePath =
|
|
2165
|
+
const filePath = path6.join(this.deps.entitiesDir, file);
|
|
2065
2166
|
try {
|
|
2066
2167
|
const content = await this.deps.readStorageSecureFile(filePath);
|
|
2067
2168
|
const parsed = parseEntityFile(content, this.deps.entitySchemas);
|
|
@@ -2214,11 +2315,11 @@ ${rows.join("\n")}
|
|
|
2214
2315
|
}
|
|
2215
2316
|
mergedEntity.created = mergedEntity.created || mergedEntity.updated || (/* @__PURE__ */ new Date()).toISOString();
|
|
2216
2317
|
mergedEntity.updated = mergedEntity.updated || (/* @__PURE__ */ new Date()).toISOString();
|
|
2217
|
-
const canonicalPath =
|
|
2218
|
-
await this.deps.writeStorageSecureFile(canonicalPath, serializeEntityFile(mergedEntity, this.deps.entitySchemas));
|
|
2318
|
+
const canonicalPath = path6.join(this.deps.entitiesDir, `${canonical}.md`);
|
|
2319
|
+
await this.deps.writeStorageSecureFile(canonicalPath, serializeEntityFile(mergedEntity, this.deps.entitySchemas, this.deps.okfConformanceEnabled()));
|
|
2219
2320
|
this.deps.bumpEntityMutationVersion();
|
|
2220
2321
|
for (const file of files) {
|
|
2221
|
-
const filePath =
|
|
2322
|
+
const filePath = path6.join(this.deps.entitiesDir, file);
|
|
2222
2323
|
if (filePath !== canonicalPath) {
|
|
2223
2324
|
try {
|
|
2224
2325
|
await unlink(filePath);
|
|
@@ -2238,7 +2339,7 @@ ${rows.join("\n")}
|
|
|
2238
2339
|
|
|
2239
2340
|
// src/storage/identity-continuity-store.ts
|
|
2240
2341
|
import { readdir as readdir3 } from "fs/promises";
|
|
2241
|
-
import
|
|
2342
|
+
import path7 from "path";
|
|
2242
2343
|
var IdentityContinuityStore = class {
|
|
2243
2344
|
constructor(deps) {
|
|
2244
2345
|
this.deps = deps;
|
|
@@ -2263,7 +2364,7 @@ var IdentityContinuityStore = class {
|
|
|
2263
2364
|
const date = nowIso.slice(0, 10);
|
|
2264
2365
|
const id = this.deps.generateId("incident");
|
|
2265
2366
|
const incident = createContinuityIncidentRecord(id, input, nowIso);
|
|
2266
|
-
const filePath =
|
|
2367
|
+
const filePath = path7.join(this.deps.identityIncidentsDir, `${date}-${id}.md`);
|
|
2267
2368
|
await this.deps.writeStorageSecureFile(filePath, serializeContinuityIncident(incident));
|
|
2268
2369
|
return { ...incident, filePath };
|
|
2269
2370
|
}
|
|
@@ -2276,7 +2377,7 @@ var IdentityContinuityStore = class {
|
|
|
2276
2377
|
const incidents = [];
|
|
2277
2378
|
for (const file of candidates) {
|
|
2278
2379
|
if (incidents.length >= cappedLimit) break;
|
|
2279
|
-
const filePath =
|
|
2380
|
+
const filePath = path7.join(this.deps.identityIncidentsDir, file);
|
|
2280
2381
|
try {
|
|
2281
2382
|
const raw = await this.deps.readStorageSecureFile(filePath);
|
|
2282
2383
|
const parsed = parseContinuityIncident(raw);
|
|
@@ -2307,7 +2408,7 @@ var IdentityContinuityStore = class {
|
|
|
2307
2408
|
await this.deps.ensureDirectories();
|
|
2308
2409
|
const safeKey = this.sanitizeIdentityAuditKey(key);
|
|
2309
2410
|
const dir = period === "weekly" ? this.deps.identityAuditsWeeklyDir : this.deps.identityAuditsMonthlyDir;
|
|
2310
|
-
const filePath =
|
|
2411
|
+
const filePath = path7.join(dir, `${safeKey}.md`);
|
|
2311
2412
|
await this.deps.writeStorageSecureFile(filePath, content);
|
|
2312
2413
|
return filePath;
|
|
2313
2414
|
}
|
|
@@ -2315,7 +2416,7 @@ var IdentityContinuityStore = class {
|
|
|
2315
2416
|
try {
|
|
2316
2417
|
const safeKey = this.sanitizeIdentityAuditKey(key);
|
|
2317
2418
|
const dir = period === "weekly" ? this.deps.identityAuditsWeeklyDir : this.deps.identityAuditsMonthlyDir;
|
|
2318
|
-
return await this.deps.readStorageSecureFile(
|
|
2419
|
+
return await this.deps.readStorageSecureFile(path7.join(dir, `${safeKey}.md`));
|
|
2319
2420
|
} catch (err) {
|
|
2320
2421
|
if (err instanceof Error && err.message === "Invalid identity audit key") return null;
|
|
2321
2422
|
if (!isErrnoCode(err, "ENOENT")) throw err;
|
|
@@ -2371,12 +2472,12 @@ var IdentityContinuityStore = class {
|
|
|
2371
2472
|
const fileNames = await this.readContinuityIncidentFileNames();
|
|
2372
2473
|
const directMatch = fileNames.find((name) => name.endsWith(`-${id}.md`));
|
|
2373
2474
|
if (directMatch) {
|
|
2374
|
-
const directPath =
|
|
2475
|
+
const directPath = path7.join(this.deps.identityIncidentsDir, directMatch);
|
|
2375
2476
|
const parsed = await this.readContinuityIncidentFile(directPath);
|
|
2376
2477
|
if (parsed?.id === id) return directPath;
|
|
2377
2478
|
}
|
|
2378
2479
|
for (const fileName of fileNames) {
|
|
2379
|
-
const filePath =
|
|
2480
|
+
const filePath = path7.join(this.deps.identityIncidentsDir, fileName);
|
|
2380
2481
|
const parsed = await this.readContinuityIncidentFile(filePath);
|
|
2381
2482
|
if (parsed?.id === id) return filePath;
|
|
2382
2483
|
}
|
|
@@ -2404,7 +2505,7 @@ import {
|
|
|
2404
2505
|
unlink as unlink2,
|
|
2405
2506
|
writeFile
|
|
2406
2507
|
} from "fs/promises";
|
|
2407
|
-
import
|
|
2508
|
+
import path8 from "path";
|
|
2408
2509
|
import { z } from "zod";
|
|
2409
2510
|
var ENTITY_CANONICAL_ID_MIGRATION_VERSION = 1;
|
|
2410
2511
|
var ENTITY_CANONICAL_ID_MIGRATION_LOCK_STALE_MS = 6e4;
|
|
@@ -2438,7 +2539,7 @@ async function fingerprintPath(filePath) {
|
|
|
2438
2539
|
async function fingerprintEntityEntries(entitiesDir) {
|
|
2439
2540
|
let names;
|
|
2440
2541
|
try {
|
|
2441
|
-
names = (await readdir4(entitiesDir)).filter((name) =>
|
|
2542
|
+
names = (await readdir4(entitiesDir)).filter((name) => path8.extname(name) === ".md").sort();
|
|
2442
2543
|
} catch (error) {
|
|
2443
2544
|
if (isErrnoCode(error, "ENOENT")) return "missing";
|
|
2444
2545
|
throw error;
|
|
@@ -2447,7 +2548,7 @@ async function fingerprintEntityEntries(entitiesDir) {
|
|
|
2447
2548
|
for (const name of names) {
|
|
2448
2549
|
hash.update(`${name.length}:${name}:`);
|
|
2449
2550
|
try {
|
|
2450
|
-
const entry = await lstat2(
|
|
2551
|
+
const entry = await lstat2(path8.join(entitiesDir, name), { bigint: true });
|
|
2451
2552
|
hash.update(`${entry.dev}:${entry.ino}:${entry.size}:${entry.mtimeNs}:${entry.ctimeNs}`);
|
|
2452
2553
|
} catch (error) {
|
|
2453
2554
|
if (!isErrnoCode(error, "ENOENT")) throw error;
|
|
@@ -2467,9 +2568,9 @@ async function getFingerprint(baseDir, entitiesDir, getEntityMutationVersion) {
|
|
|
2467
2568
|
] = await Promise.all([
|
|
2468
2569
|
fingerprintPath(entitiesDir),
|
|
2469
2570
|
fingerprintEntityEntries(entitiesDir),
|
|
2470
|
-
fingerprintPath(
|
|
2471
|
-
fingerprintPath(
|
|
2472
|
-
fingerprintPath(
|
|
2571
|
+
fingerprintPath(path8.join(baseDir, "config", "aliases.json")),
|
|
2572
|
+
fingerprintPath(path8.join(baseDir, "state", ENTITY_CANONICAL_ID_RECONCILE_MARKER)),
|
|
2573
|
+
fingerprintPath(path8.join(baseDir, "state", ENTITY_CANONICAL_ID_RECONCILE_CONSUMING_MARKER))
|
|
2473
2574
|
]);
|
|
2474
2575
|
return [
|
|
2475
2576
|
entityDirectoryFingerprint,
|
|
@@ -2495,8 +2596,8 @@ async function validateRoots(baseDir, entitiesDir, stateDir, archiveDir) {
|
|
|
2495
2596
|
const roots = [
|
|
2496
2597
|
entitiesDir,
|
|
2497
2598
|
stateDir,
|
|
2498
|
-
...RECALL_FALLBACK_DIRS.map((directory) =>
|
|
2499
|
-
|
|
2599
|
+
...RECALL_FALLBACK_DIRS.map((directory) => path8.join(baseDir, directory)),
|
|
2600
|
+
path8.join(baseDir, "cold"),
|
|
2500
2601
|
archiveDir
|
|
2501
2602
|
];
|
|
2502
2603
|
for (const root of roots) {
|
|
@@ -2514,7 +2615,7 @@ async function validateRoots(baseDir, entitiesDir, stateDir, archiveDir) {
|
|
|
2514
2615
|
}
|
|
2515
2616
|
}
|
|
2516
2617
|
function statePath(deps) {
|
|
2517
|
-
return
|
|
2618
|
+
return path8.join(deps.stateDir, ENTITY_CANONICAL_ID_MIGRATION_FILE);
|
|
2518
2619
|
}
|
|
2519
2620
|
async function assertSafeMigrationStateFile(deps) {
|
|
2520
2621
|
const migrationStatePath = statePath(deps);
|
|
@@ -2557,7 +2658,7 @@ async function assertSafeTombstoneFile(deps, tombstonePath) {
|
|
|
2557
2658
|
return true;
|
|
2558
2659
|
}
|
|
2559
2660
|
function lockPath(deps) {
|
|
2560
|
-
return
|
|
2661
|
+
return path8.join(deps.stateDir, "entity-canonical-id-migration.lock");
|
|
2561
2662
|
}
|
|
2562
2663
|
async function readState(deps) {
|
|
2563
2664
|
await assertSafeMigrationStateFile(deps);
|
|
@@ -2655,7 +2756,7 @@ async function readSafeEntityEntries(entitiesDir) {
|
|
|
2655
2756
|
}
|
|
2656
2757
|
const entries = await readdir4(entitiesDir);
|
|
2657
2758
|
for (const entry of entries) {
|
|
2658
|
-
await assertNotSymlink(
|
|
2759
|
+
await assertNotSymlink(path8.join(entitiesDir, entry), entry);
|
|
2659
2760
|
}
|
|
2660
2761
|
return entries;
|
|
2661
2762
|
}
|
|
@@ -2717,7 +2818,7 @@ async function rewriteReferences(deps, mappings, refreshLock) {
|
|
|
2717
2818
|
const seenPaths = /* @__PURE__ */ new Set();
|
|
2718
2819
|
let rewroteAny = false;
|
|
2719
2820
|
for (const memory of [...hotMemories, ...coldMemories, ...archivedMemories]) {
|
|
2720
|
-
const memoryPath =
|
|
2821
|
+
const memoryPath = path8.resolve(memory.path);
|
|
2721
2822
|
if (seenPaths.has(memoryPath)) continue;
|
|
2722
2823
|
seenPaths.add(memoryPath);
|
|
2723
2824
|
const previousEntityRef = memory.frontmatter.entityRef;
|
|
@@ -2749,7 +2850,7 @@ async function rewriteReferences(deps, mappings, refreshLock) {
|
|
|
2749
2850
|
latestCanonicalId
|
|
2750
2851
|
);
|
|
2751
2852
|
rewroteAny = true;
|
|
2752
|
-
rewroteColdMemory ||= latestMemory.path.includes(`${
|
|
2853
|
+
rewroteColdMemory ||= latestMemory.path.includes(`${path8.sep}cold${path8.sep}`);
|
|
2753
2854
|
}
|
|
2754
2855
|
if (!rewroteAny) return { rewroteColdMemory };
|
|
2755
2856
|
}
|
|
@@ -2788,7 +2889,7 @@ function rewriteTombstoneLine(line, mappings, normalizedMappings) {
|
|
|
2788
2889
|
return changed ? JSON.stringify(tombstone) : line;
|
|
2789
2890
|
}
|
|
2790
2891
|
async function rewriteTombstoneReferences(deps, mappings, refreshLock) {
|
|
2791
|
-
const tombstonePath =
|
|
2892
|
+
const tombstonePath = path8.join(deps.stateDir, "tombstones.jsonl");
|
|
2792
2893
|
const normalizedMappings = /* @__PURE__ */ new Map();
|
|
2793
2894
|
for (const [legacyId, canonicalId] of Object.entries(mappings)) {
|
|
2794
2895
|
const normalizedLegacyId = normalizeSupersessionKey(legacyId);
|
|
@@ -2797,7 +2898,7 @@ async function rewriteTombstoneReferences(deps, mappings, refreshLock) {
|
|
|
2797
2898
|
}
|
|
2798
2899
|
}
|
|
2799
2900
|
await withHeldFileLock(
|
|
2800
|
-
|
|
2901
|
+
path8.join(deps.stateDir, "tombstones.lock"),
|
|
2801
2902
|
{
|
|
2802
2903
|
staleMs: TOMBSTONE_LOCK_STALE_MS,
|
|
2803
2904
|
maxWaitMs: TOMBSTONE_LOCK_MAX_WAIT_MS
|
|
@@ -3036,8 +3137,8 @@ async function migrateLegacyEntityCanonicalIds(deps) {
|
|
|
3036
3137
|
if (!acquired) throw new Error("Timed out waiting for active entity canonical-id migration.");
|
|
3037
3138
|
await deps.validateMemoryScanRoots?.();
|
|
3038
3139
|
await readSafeEntityEntries(deps.entitiesDir);
|
|
3039
|
-
const reconcileMarkerPath =
|
|
3040
|
-
const consumingMarkerPath =
|
|
3140
|
+
const reconcileMarkerPath = path8.join(deps.stateDir, ENTITY_CANONICAL_ID_RECONCILE_MARKER);
|
|
3141
|
+
const consumingMarkerPath = path8.join(deps.stateDir, ENTITY_CANONICAL_ID_RECONCILE_CONSUMING_MARKER);
|
|
3041
3142
|
let reconcileRequested = await fileExists(consumingMarkerPath);
|
|
3042
3143
|
if (await fileExists(reconcileMarkerPath)) {
|
|
3043
3144
|
try {
|
|
@@ -3433,7 +3534,7 @@ import {
|
|
|
3433
3534
|
readFileSync,
|
|
3434
3535
|
realpathSync
|
|
3435
3536
|
} from "fs";
|
|
3436
|
-
import
|
|
3537
|
+
import path9 from "path";
|
|
3437
3538
|
function resolveSafeAliasRoots(baseDir, configDir) {
|
|
3438
3539
|
let baseStat;
|
|
3439
3540
|
try {
|
|
@@ -3460,8 +3561,8 @@ function resolveSafeAliasRoots(baseDir, configDir) {
|
|
|
3460
3561
|
return memoryRoot;
|
|
3461
3562
|
}
|
|
3462
3563
|
function readEntityAliasConfigSync(baseDir) {
|
|
3463
|
-
const configDir =
|
|
3464
|
-
const aliasPath =
|
|
3564
|
+
const configDir = path9.join(baseDir, "config");
|
|
3565
|
+
const aliasPath = path9.join(configDir, "aliases.json");
|
|
3465
3566
|
let memoryRoot = resolveSafeAliasRoots(baseDir, configDir);
|
|
3466
3567
|
if (memoryRoot === void 0) return void 0;
|
|
3467
3568
|
let aliasPreflight;
|
|
@@ -3522,7 +3623,7 @@ function decodeYamlScalar(value) {
|
|
|
3522
3623
|
}
|
|
3523
3624
|
|
|
3524
3625
|
// src/orchestration/qmd-result-resolver.ts
|
|
3525
|
-
import
|
|
3626
|
+
import path10 from "path";
|
|
3526
3627
|
var INTERNAL_QMD_ROOTS = /* @__PURE__ */ new Set([
|
|
3527
3628
|
...ALL_CATEGORY_DIRS,
|
|
3528
3629
|
"activity",
|
|
@@ -3532,6 +3633,7 @@ var INTERNAL_QMD_ROOTS = /* @__PURE__ */ new Set([
|
|
|
3532
3633
|
"config",
|
|
3533
3634
|
"entities",
|
|
3534
3635
|
"identity",
|
|
3636
|
+
"locations",
|
|
3535
3637
|
"meetings",
|
|
3536
3638
|
"namespaces",
|
|
3537
3639
|
"state",
|
|
@@ -3543,7 +3645,7 @@ var INTERNAL_QMD_ROOTS = /* @__PURE__ */ new Set([
|
|
|
3543
3645
|
]);
|
|
3544
3646
|
var PRIVATE_RESULT_RESOLUTION_CONCURRENCY = 16;
|
|
3545
3647
|
function qmdCollectionPathParts(resultPath) {
|
|
3546
|
-
if (!resultPath ||
|
|
3648
|
+
if (!resultPath || path10.isAbsolute(resultPath)) return null;
|
|
3547
3649
|
if (resultPath.trim().startsWith("qmd://")) {
|
|
3548
3650
|
try {
|
|
3549
3651
|
const parsed = new URL(resultPath.trim());
|
|
@@ -3568,9 +3670,9 @@ function qmdCollectionPathParts(resultPath) {
|
|
|
3568
3670
|
}
|
|
3569
3671
|
function qmdResultPathCandidates(storageDir, resultPath) {
|
|
3570
3672
|
const candidates = /* @__PURE__ */ new Set();
|
|
3571
|
-
const storageRoot =
|
|
3673
|
+
const storageRoot = path10.resolve(storageDir);
|
|
3572
3674
|
const addCandidate = (candidate) => {
|
|
3573
|
-
const resolved =
|
|
3675
|
+
const resolved = path10.resolve(candidate);
|
|
3574
3676
|
if (isPathInsideStorageRoot(storageRoot, resolved)) {
|
|
3575
3677
|
candidates.add(resolved);
|
|
3576
3678
|
}
|
|
@@ -3578,18 +3680,18 @@ function qmdResultPathCandidates(storageDir, resultPath) {
|
|
|
3578
3680
|
const addRelativeCandidates = (relativePath) => {
|
|
3579
3681
|
const normalized = relativePath.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
3580
3682
|
if (!normalized) return;
|
|
3581
|
-
addCandidate(
|
|
3683
|
+
addCandidate(path10.join(storageRoot, normalized));
|
|
3582
3684
|
if (/^\d{4}-\d{2}-\d{2}\//.test(normalized)) {
|
|
3583
|
-
addCandidate(
|
|
3685
|
+
addCandidate(path10.join(storageRoot, "facts", normalized));
|
|
3584
3686
|
}
|
|
3585
3687
|
};
|
|
3586
|
-
if (
|
|
3688
|
+
if (path10.isAbsolute(resultPath)) {
|
|
3587
3689
|
addCandidate(resultPath);
|
|
3588
|
-
const relative2 =
|
|
3589
|
-
if (relative2 && !relative2.startsWith("..") && !
|
|
3590
|
-
const normalized = relative2.split(
|
|
3690
|
+
const relative2 = path10.relative(storageRoot, path10.resolve(resultPath));
|
|
3691
|
+
if (relative2 && !relative2.startsWith("..") && !path10.isAbsolute(relative2)) {
|
|
3692
|
+
const normalized = relative2.split(path10.sep).join("/");
|
|
3591
3693
|
if (/^\d{4}-\d{2}-\d{2}\//.test(normalized)) {
|
|
3592
|
-
addCandidate(
|
|
3694
|
+
addCandidate(path10.join(storageRoot, "facts", normalized));
|
|
3593
3695
|
}
|
|
3594
3696
|
}
|
|
3595
3697
|
} else {
|
|
@@ -3625,7 +3727,7 @@ var QmdResultResolver = class {
|
|
|
3625
3727
|
const seenStorageDirs = /* @__PURE__ */ new Set();
|
|
3626
3728
|
const addStorage = (storage) => {
|
|
3627
3729
|
const storageDir = storageDirOrNull(storage);
|
|
3628
|
-
const storageKey = storageDir ?
|
|
3730
|
+
const storageKey = storageDir ? path10.resolve(storageDir) : `storage-without-dir-${storages.length}`;
|
|
3629
3731
|
if (seenStorageDirs.has(storageKey)) return;
|
|
3630
3732
|
seenStorageDirs.add(storageKey);
|
|
3631
3733
|
storages.push(storage);
|
|
@@ -3655,7 +3757,7 @@ var QmdResultResolver = class {
|
|
|
3655
3757
|
continue;
|
|
3656
3758
|
}
|
|
3657
3759
|
try {
|
|
3658
|
-
const coldRoot =
|
|
3760
|
+
const coldRoot = path10.join(storageDir, "cold");
|
|
3659
3761
|
for (const candidate of qmdResultPathCandidates(coldRoot, parts.relativePath)) {
|
|
3660
3762
|
const memory = await storage.readMemoryByPath(candidate);
|
|
3661
3763
|
if (memory) return memory;
|
|
@@ -3705,9 +3807,9 @@ var QmdResultResolver = class {
|
|
|
3705
3807
|
error: err.message
|
|
3706
3808
|
});
|
|
3707
3809
|
}
|
|
3708
|
-
if (!
|
|
3810
|
+
if (!path10.isAbsolute(fallbackResultPath)) return null;
|
|
3709
3811
|
}
|
|
3710
|
-
if (
|
|
3812
|
+
if (path10.isAbsolute(fallbackResultPath)) {
|
|
3711
3813
|
if (!fallbackStorageDir) {
|
|
3712
3814
|
return await fallbackStorage.readMemoryByPath(fallbackResultPath);
|
|
3713
3815
|
}
|
|
@@ -3764,17 +3866,17 @@ var QmdResultResolver = class {
|
|
|
3764
3866
|
if (!memory && parts && !collectionIsKnownInternal && !collectionIsConfigured) {
|
|
3765
3867
|
memory = await this.readQmdResultMemory(parts.relativePath, fallbackStorage, namespaces, result.namespace);
|
|
3766
3868
|
}
|
|
3767
|
-
const absoluteInsideMemoryRoot =
|
|
3869
|
+
const absoluteInsideMemoryRoot = path10.isAbsolute(result.path) && isPathInsideStorageRoot(path10.resolve(config.memoryDir), path10.resolve(result.path));
|
|
3768
3870
|
const hasExplicitQmdCollection = result.path.trim().startsWith("qmd://");
|
|
3769
3871
|
const unresolvedInternalPath = !memory && (absoluteInsideMemoryRoot || collectionIsKnownInternal && (!preserveUnresolved || hasExplicitQmdCollection) || hasExplicitQmdCollection && collectionIsConfigured);
|
|
3770
|
-
const unresolvedExternalCollection = !memory && (parts !== null && !collectionIsKnownInternal && !collectionIsConfigured ||
|
|
3872
|
+
const unresolvedExternalCollection = !memory && (parts !== null && !collectionIsKnownInternal && !collectionIsConfigured || path10.isAbsolute(result.path) && !isPathInsideStorageRoot(path10.resolve(config.memoryDir), path10.resolve(result.path)));
|
|
3771
3873
|
return memory !== null && !isSupportPassportPrivateMemory(memory) || !memory && !unresolvedInternalPath && (preserveUnresolved || unresolvedExternalCollection);
|
|
3772
3874
|
}
|
|
3773
3875
|
async resolveColdQmdResultForRecall(result, fallbackStorage, recallNamespaces = []) {
|
|
3774
3876
|
const memory = await this.readQmdResultMemory(result.path, fallbackStorage, recallNamespaces, result.namespace);
|
|
3775
3877
|
if (!memory) return null;
|
|
3776
3878
|
let ownerNamespace = null;
|
|
3777
|
-
if (
|
|
3879
|
+
if (path10.isAbsolute(memory.path)) {
|
|
3778
3880
|
const ownerStorage = await this.storageForAbsoluteQmdResultPath(memory.path, fallbackStorage, recallNamespaces);
|
|
3779
3881
|
ownerNamespace = ownerStorage?.namespace ?? null;
|
|
3780
3882
|
if (!ownerNamespace && resolveNamespaceCapabilities(this.getConfig()).namespaces) return null;
|
|
@@ -3795,17 +3897,17 @@ var QmdResultResolver = class {
|
|
|
3795
3897
|
};
|
|
3796
3898
|
}
|
|
3797
3899
|
async storageForAbsoluteQmdResultPath(resultPath, fallbackStorage, recallNamespaces = []) {
|
|
3798
|
-
const resolvedPath =
|
|
3900
|
+
const resolvedPath = path10.resolve(resultPath);
|
|
3799
3901
|
const config = this.getConfig();
|
|
3800
|
-
const memoryRoot =
|
|
3801
|
-
const namespacesRoot =
|
|
3902
|
+
const memoryRoot = path10.resolve(config.memoryDir);
|
|
3903
|
+
const namespacesRoot = path10.join(memoryRoot, "namespaces");
|
|
3802
3904
|
const fallbackStorageDir = storageDirOrNull(fallbackStorage);
|
|
3803
3905
|
const matches = [];
|
|
3804
3906
|
const seenDirs = /* @__PURE__ */ new Set();
|
|
3805
3907
|
const maybeAddStorage = (storage, namespace) => {
|
|
3806
3908
|
const storageDir = storageDirOrNull(storage);
|
|
3807
3909
|
if (!storageDir) return;
|
|
3808
|
-
const candidateRoot =
|
|
3910
|
+
const candidateRoot = path10.resolve(storageDir);
|
|
3809
3911
|
if (seenDirs.has(candidateRoot)) return;
|
|
3810
3912
|
if (!isPathInsideStorageRoot(candidateRoot, resolvedPath)) return;
|
|
3811
3913
|
if (candidateRoot === memoryRoot && isPathInsideStorageRoot(namespacesRoot, resolvedPath)) {
|
|
@@ -3823,7 +3925,7 @@ var QmdResultResolver = class {
|
|
|
3823
3925
|
candidateNamespaces.add(ns);
|
|
3824
3926
|
}
|
|
3825
3927
|
if (isPathInsideStorageRoot(namespacesRoot, resolvedPath)) {
|
|
3826
|
-
const relativeToNamespaces =
|
|
3928
|
+
const relativeToNamespaces = path10.relative(namespacesRoot, resolvedPath);
|
|
3827
3929
|
const [namespaceSegment] = relativeToNamespaces.split(/[\\/]/);
|
|
3828
3930
|
if (namespaceSegment) {
|
|
3829
3931
|
candidateNamespaces.add(namespaceIdentityFromToken(namespaceSegment) ?? namespaceSegment);
|
|
@@ -4469,7 +4571,7 @@ function fuseDay(date, inputs, options = {}) {
|
|
|
4469
4571
|
|
|
4470
4572
|
// src/wearables/fusion/store.ts
|
|
4471
4573
|
import { createHash as createHash3 } from "crypto";
|
|
4472
|
-
import * as
|
|
4574
|
+
import * as path11 from "path";
|
|
4473
4575
|
var FUSION_KIND = "wearable-fusion";
|
|
4474
4576
|
function hashFusionBody(conversations) {
|
|
4475
4577
|
return createHash3("sha256").update(JSON.stringify(conversations), "utf-8").digest("hex");
|
|
@@ -4656,7 +4758,7 @@ var FusionArtifactStore = class {
|
|
|
4656
4758
|
`invalid wearable fusion date '${String(date)}' \u2014 expected YYYY-MM-DD`
|
|
4657
4759
|
);
|
|
4658
4760
|
}
|
|
4659
|
-
return
|
|
4761
|
+
return path11.join(this.wearablesDir, FUSION_DIR_NAME, `${date}.md`);
|
|
4660
4762
|
}
|
|
4661
4763
|
async writeFusedDay(date, serialized) {
|
|
4662
4764
|
const filePath = this.fusedDayPath(date);
|
|
@@ -4693,7 +4795,7 @@ var FusionArtifactStore = class {
|
|
|
4693
4795
|
}
|
|
4694
4796
|
/** List dates with stored fused artifacts, newest first. */
|
|
4695
4797
|
async listFusedDays() {
|
|
4696
|
-
const fusionDir =
|
|
4798
|
+
const fusionDir = path11.join(this.wearablesDir, FUSION_DIR_NAME);
|
|
4697
4799
|
await this.assertPathContained(fusionDir);
|
|
4698
4800
|
let entries;
|
|
4699
4801
|
try {
|
|
@@ -4737,10 +4839,10 @@ var FusionArtifactStore = class {
|
|
|
4737
4839
|
try {
|
|
4738
4840
|
rootReal = await this.io.realpath(this.memoryDir);
|
|
4739
4841
|
} catch {
|
|
4740
|
-
rootReal =
|
|
4842
|
+
rootReal = path11.resolve(this.memoryDir);
|
|
4741
4843
|
}
|
|
4742
4844
|
await this.assertNoEscape(rootReal, this.wearablesDir);
|
|
4743
|
-
await this.assertNoEscape(rootReal,
|
|
4845
|
+
await this.assertNoEscape(rootReal, path11.dirname(targetPath));
|
|
4744
4846
|
await this.assertNoEscape(rootReal, targetPath);
|
|
4745
4847
|
await this.assertFusionDirNotSymlinked();
|
|
4746
4848
|
}
|
|
@@ -4754,7 +4856,7 @@ var FusionArtifactStore = class {
|
|
|
4754
4856
|
* (a fresh write creates a real directory lexically under the root).
|
|
4755
4857
|
*/
|
|
4756
4858
|
async assertFusionDirNotSymlinked() {
|
|
4757
|
-
const fusionDir =
|
|
4859
|
+
const fusionDir = path11.join(this.wearablesDir, FUSION_DIR_NAME);
|
|
4758
4860
|
let stat4;
|
|
4759
4861
|
try {
|
|
4760
4862
|
stat4 = await this.io.lstat(fusionDir);
|
|
@@ -4890,7 +4992,7 @@ function reconstructFusionInputs(date, dayTranscripts) {
|
|
|
4890
4992
|
|
|
4891
4993
|
// src/meetings/store.ts
|
|
4892
4994
|
import { createHash as createHash4 } from "crypto";
|
|
4893
|
-
import * as
|
|
4995
|
+
import * as path12 from "path";
|
|
4894
4996
|
var MEETINGS_DIR_NAME = "meetings";
|
|
4895
4997
|
var MEETING_KIND = "meeting";
|
|
4896
4998
|
var MEETING_FORMAT_VERSION = 1;
|
|
@@ -5059,7 +5161,7 @@ var MeetingRecordStore = class {
|
|
|
5059
5161
|
constructor(memoryDir, io) {
|
|
5060
5162
|
this.memoryDir = memoryDir;
|
|
5061
5163
|
this.io = io;
|
|
5062
|
-
this.meetingsDir =
|
|
5164
|
+
this.meetingsDir = path12.join(memoryDir, MEETINGS_DIR_NAME);
|
|
5063
5165
|
}
|
|
5064
5166
|
memoryDir;
|
|
5065
5167
|
io;
|
|
@@ -5075,7 +5177,7 @@ var MeetingRecordStore = class {
|
|
|
5075
5177
|
if (idDate !== date) {
|
|
5076
5178
|
throw new Error(`meeting id '${id}' does not belong to date '${date}'`);
|
|
5077
5179
|
}
|
|
5078
|
-
return
|
|
5180
|
+
return path12.join(this.meetingsDir, date, `${id}.md`);
|
|
5079
5181
|
}
|
|
5080
5182
|
/** Idempotently persist a record: skip the write when contentHash is unchanged. */
|
|
5081
5183
|
async saveMeetingRecord(record) {
|
|
@@ -5106,7 +5208,7 @@ var MeetingRecordStore = class {
|
|
|
5106
5208
|
if (!isValidTranscriptDate(date)) {
|
|
5107
5209
|
throw new Error(`invalid meeting date '${String(date)}' \u2014 expected YYYY-MM-DD`);
|
|
5108
5210
|
}
|
|
5109
|
-
const dayDir =
|
|
5211
|
+
const dayDir = path12.join(this.meetingsDir, date);
|
|
5110
5212
|
await this.assertPathContained(dayDir);
|
|
5111
5213
|
let entries;
|
|
5112
5214
|
try {
|
|
@@ -5174,10 +5276,10 @@ var MeetingRecordStore = class {
|
|
|
5174
5276
|
try {
|
|
5175
5277
|
rootReal = await this.io.realpath(this.memoryDir);
|
|
5176
5278
|
} catch {
|
|
5177
|
-
rootReal =
|
|
5279
|
+
rootReal = path12.resolve(this.memoryDir);
|
|
5178
5280
|
}
|
|
5179
5281
|
await this.assertNoEscape(rootReal, this.meetingsDir);
|
|
5180
|
-
await this.assertNoEscape(rootReal,
|
|
5282
|
+
await this.assertNoEscape(rootReal, path12.dirname(targetPath));
|
|
5181
5283
|
await this.assertNoEscape(rootReal, targetPath);
|
|
5182
5284
|
await this.assertNotSymlink(this.meetingsDir, "directory");
|
|
5183
5285
|
const dayDir = this.dayDirWithin(targetPath);
|
|
@@ -5187,11 +5289,11 @@ var MeetingRecordStore = class {
|
|
|
5187
5289
|
/** The `<meetings>/<date>` directory on the path to `targetPath`, or null when
|
|
5188
5290
|
* `targetPath` is the meetings root itself. */
|
|
5189
5291
|
dayDirWithin(targetPath) {
|
|
5190
|
-
const rel =
|
|
5191
|
-
if (rel === "" || rel.startsWith("..") ||
|
|
5192
|
-
const first = rel.split(
|
|
5292
|
+
const rel = path12.relative(this.meetingsDir, targetPath);
|
|
5293
|
+
if (rel === "" || rel.startsWith("..") || path12.isAbsolute(rel)) return null;
|
|
5294
|
+
const first = rel.split(path12.sep)[0];
|
|
5193
5295
|
if (first === void 0 || first.length === 0) return null;
|
|
5194
|
-
return
|
|
5296
|
+
return path12.join(this.meetingsDir, first);
|
|
5195
5297
|
}
|
|
5196
5298
|
async assertNotSymlink(target, kind) {
|
|
5197
5299
|
let stat4;
|
|
@@ -5202,7 +5304,7 @@ var MeetingRecordStore = class {
|
|
|
5202
5304
|
throw err;
|
|
5203
5305
|
}
|
|
5204
5306
|
if (stat4.isSymbolicLink) {
|
|
5205
|
-
const label =
|
|
5307
|
+
const label = path12.relative(this.memoryDir, target) || MEETINGS_DIR_NAME;
|
|
5206
5308
|
throw new Error(
|
|
5207
5309
|
`meetings ${kind} '${label}' is a symbolic link \u2014 refusing to follow it even when it resolves inside the memory dir (AGENTS.md pattern #3)`
|
|
5208
5310
|
);
|
|
@@ -5226,7 +5328,7 @@ var SORT_STR = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
|
5226
5328
|
|
|
5227
5329
|
// src/storage/supersession-audit.ts
|
|
5228
5330
|
import { readdir as readdir5 } from "fs/promises";
|
|
5229
|
-
import
|
|
5331
|
+
import path13 from "path";
|
|
5230
5332
|
async function hasSupersessionAudit(lookup, oldMemoryId, newMemoryId, auditBody, structuredAttributes) {
|
|
5231
5333
|
let entries;
|
|
5232
5334
|
try {
|
|
@@ -5237,7 +5339,7 @@ async function hasSupersessionAudit(lookup, oldMemoryId, newMemoryId, auditBody,
|
|
|
5237
5339
|
}
|
|
5238
5340
|
for (const entry of entries) {
|
|
5239
5341
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
5240
|
-
const memory = await lookup.readMemoryByPath(
|
|
5342
|
+
const memory = await lookup.readMemoryByPath(path13.join(lookup.correctionsDir, entry.name));
|
|
5241
5343
|
if (memory?.frontmatter.category === "correction" && (memory.frontmatter.sourceMemoryId === oldMemoryId || memory.frontmatter.sourceMemoryId === void 0 && memory.frontmatter.lineage?.includes(oldMemoryId)) && memory.frontmatter.lineage?.includes(newMemoryId) && stripAttributesSuffix(memory.content) === auditBody && (structuredAttributes === void 0 || Object.entries(structuredAttributes).every(
|
|
5242
5344
|
([key, value]) => memory.frontmatter.structuredAttributes?.[key] === value
|
|
5243
5345
|
))) {
|
|
@@ -5827,6 +5929,7 @@ function serializeFrontmatter(fm) {
|
|
|
5827
5929
|
`confidenceTier: ${fm.confidenceTier}`,
|
|
5828
5930
|
`tags: [${fm.tags.map((t) => `"${t}"`).join(", ")}]`
|
|
5829
5931
|
];
|
|
5932
|
+
if (fm.type !== void 0) lines.push(`type: ${fm.type}`);
|
|
5830
5933
|
if (fm.origin) lines.push(`origin: ${/^[A-Za-z0-9:_.*-]+$/.test(fm.origin) ? fm.origin : JSON.stringify(fm.origin)}`);
|
|
5831
5934
|
if (fm.entityRef) lines.push(`entityRef: ${fm.entityRef}`);
|
|
5832
5935
|
if (fm.sourceConnector) {
|
|
@@ -6218,6 +6321,7 @@ function parseFrontmatter(raw) {
|
|
|
6218
6321
|
frontmatter: {
|
|
6219
6322
|
id: fm.id ?? "",
|
|
6220
6323
|
category: fm.category ?? "fact",
|
|
6324
|
+
type: parseFrontmatterStringValue(fm.type),
|
|
6221
6325
|
created: fm.created ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
6222
6326
|
updated: fm.updated ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
6223
6327
|
source: fm.source ?? "unknown",
|
|
@@ -6318,17 +6422,17 @@ function inferEntityTypeFromContent(content) {
|
|
|
6318
6422
|
}
|
|
6319
6423
|
var KNOWN_ENTITY_FILENAME_PREFIXES = /* @__PURE__ */ new Set(["company", "other", "person", "place", "project", "tool", "topic"]);
|
|
6320
6424
|
function inferEntityTypeFromFilename(pathRel) {
|
|
6321
|
-
const basename =
|
|
6425
|
+
const basename = path14.basename(pathRel, ".md").toLowerCase();
|
|
6322
6426
|
const separator = basename.indexOf("-");
|
|
6323
6427
|
if (separator <= 0) return void 0;
|
|
6324
6428
|
const candidate = basename.slice(0, separator);
|
|
6325
6429
|
return KNOWN_ENTITY_FILENAME_PREFIXES.has(candidate) ? candidate : void 0;
|
|
6326
6430
|
}
|
|
6327
6431
|
function normalizeFrontmatterForPath(frontmatter, pathRel, content = "") {
|
|
6328
|
-
const normalizedPath = pathRel.split(
|
|
6432
|
+
const normalizedPath = pathRel.split(path14.sep).join("/");
|
|
6329
6433
|
let normalizedFrontmatter = frontmatter;
|
|
6330
6434
|
if (normalizedPath === "entities" || normalizedPath.startsWith("entities/") || normalizedPath.includes("/entities/")) {
|
|
6331
|
-
const basename =
|
|
6435
|
+
const basename = path14.basename(pathRel, ".md");
|
|
6332
6436
|
const inferredType = inferEntityTypeFromContent(content) || inferEntityTypeFromFilename(pathRel) || "entity";
|
|
6333
6437
|
const existingTags = Array.isArray(frontmatter.tags) ? frontmatter.tags : [];
|
|
6334
6438
|
normalizedFrontmatter = {
|
|
@@ -6376,15 +6480,16 @@ function parseEntityFrontmatter(raw) {
|
|
|
6376
6480
|
}
|
|
6377
6481
|
const values = {};
|
|
6378
6482
|
const extraLines = [];
|
|
6379
|
-
const recognizedKeys =
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6483
|
+
const recognizedKeys = {
|
|
6484
|
+
created: true,
|
|
6485
|
+
updated: true,
|
|
6486
|
+
type: true,
|
|
6487
|
+
synthesis_updated_at: true,
|
|
6488
|
+
synthesis_timeline_count: true,
|
|
6489
|
+
synthesis_structured_fact_count: true,
|
|
6490
|
+
synthesis_structured_fact_digest: true,
|
|
6491
|
+
synthesis_version: true
|
|
6492
|
+
};
|
|
6388
6493
|
for (const line of match[1].split(/\r?\n/)) {
|
|
6389
6494
|
if (/^\s/.test(line)) {
|
|
6390
6495
|
extraLines.push(line);
|
|
@@ -6396,7 +6501,7 @@ function parseEntityFrontmatter(raw) {
|
|
|
6396
6501
|
continue;
|
|
6397
6502
|
}
|
|
6398
6503
|
const key = line.slice(0, colonIdx).trim();
|
|
6399
|
-
if (
|
|
6504
|
+
if (recognizedKeys[key] !== true) {
|
|
6400
6505
|
extraLines.push(line);
|
|
6401
6506
|
continue;
|
|
6402
6507
|
}
|
|
@@ -6625,7 +6730,7 @@ function parseEntityFile(content, entitySchemas) {
|
|
|
6625
6730
|
extraSections: remainingExtraSections
|
|
6626
6731
|
};
|
|
6627
6732
|
}
|
|
6628
|
-
function serializeEntityFile(entity, entitySchemas) {
|
|
6733
|
+
function serializeEntityFile(entity, entitySchemas, okfType) {
|
|
6629
6734
|
const synthesis = entity.synthesis || entity.summary || "";
|
|
6630
6735
|
const created = entity.created?.trim() || entity.updated || (/* @__PURE__ */ new Date()).toISOString();
|
|
6631
6736
|
const updated = entity.updated || created;
|
|
@@ -6660,7 +6765,8 @@ function serializeEntityFile(entity, entitySchemas) {
|
|
|
6660
6765
|
...synthesisStructuredFactCount === void 0 ? [] : [`synthesis_structured_fact_count: ${synthesisStructuredFactCount}`],
|
|
6661
6766
|
...synthesisStructuredFactDigest ? [`synthesis_structured_fact_digest: "${synthesisStructuredFactDigest}"`] : [],
|
|
6662
6767
|
`synthesis_version: ${synthesisVersion}`,
|
|
6663
|
-
...
|
|
6768
|
+
...okfType === false ? [] : [`type: ${okfTypeForEntityKind(entity.type)}`],
|
|
6769
|
+
...okfType === false ? entity.extraFrontmatterLines ?? [] : (entity.extraFrontmatterLines ?? []).filter((line) => !line.startsWith("type:")),
|
|
6664
6770
|
"---",
|
|
6665
6771
|
"",
|
|
6666
6772
|
`# ${entity.name}`,
|
|
@@ -6799,9 +6905,9 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
6799
6905
|
this.entitySchemas = entitySchemas;
|
|
6800
6906
|
this.deletionRevisionStore = new DeletionRevisionStore({
|
|
6801
6907
|
baseDir,
|
|
6802
|
-
deletionRevisionMetadataPath:
|
|
6803
|
-
invalidationCommitMetadataPath:
|
|
6804
|
-
deletionRevisionLockPath:
|
|
6908
|
+
deletionRevisionMetadataPath: path14.join(baseDir, ".offline-sync", "deletion-revisions.v1.json"),
|
|
6909
|
+
invalidationCommitMetadataPath: path14.join(baseDir, ".offline-sync", "invalidation-commits.v1.json"),
|
|
6910
|
+
deletionRevisionLockPath: path14.join(baseDir, ".offline-sync", "deletion-revisions.v1.json.lock"),
|
|
6805
6911
|
assertManagedStoragePath: (filePath, method) => this.assertManagedStoragePath(filePath, method)
|
|
6806
6912
|
});
|
|
6807
6913
|
this.hotMemoriesCacheEnabled = hotMemoriesCacheEnabledOverride ?? _StorageManager.hotMemoriesCacheDefaultByDir.get(baseDir) ?? _StorageManager.hotMemoriesCacheDefault;
|
|
@@ -6985,8 +7091,8 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
6985
7091
|
}
|
|
6986
7092
|
/** Whether `filePath` resolves to `stateDir` itself or a path contained in it. */
|
|
6987
7093
|
isStateFilePath(filePath) {
|
|
6988
|
-
const rel =
|
|
6989
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
7094
|
+
const rel = path14.relative(this.stateDir, path14.resolve(filePath));
|
|
7095
|
+
return rel === "" || !rel.startsWith("..") && !path14.isAbsolute(rel);
|
|
6990
7096
|
}
|
|
6991
7097
|
// ── Tombstone store (issue #1579) ───────────────────────────────────────
|
|
6992
7098
|
// Instance-scoped (rule 11) + namespace-scoped (rule 42) tombstone index.
|
|
@@ -7101,8 +7207,8 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7101
7207
|
* /srv/cold/remnic), skipping the patch and stranding a stale hot entry.
|
|
7102
7208
|
*/
|
|
7103
7209
|
isColdOrArchiveTierPath(p) {
|
|
7104
|
-
const rel =
|
|
7105
|
-
return rel === "cold" || rel === "archive" || rel.startsWith(`cold${
|
|
7210
|
+
const rel = path14.relative(this.baseDir, p);
|
|
7211
|
+
return rel === "cold" || rel === "archive" || rel.startsWith(`cold${path14.sep}`) || rel.startsWith(`archive${path14.sep}`);
|
|
7106
7212
|
}
|
|
7107
7213
|
/**
|
|
7108
7214
|
* Mark the secure-store as required for this storage instance.
|
|
@@ -7189,7 +7295,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7189
7295
|
void 0,
|
|
7190
7296
|
this.baseDir
|
|
7191
7297
|
);
|
|
7192
|
-
const rel =
|
|
7298
|
+
const rel = path14.relative(this.baseDir, filePath).split(path14.sep).join("/");
|
|
7193
7299
|
return `${rel}:${version.versionId}`;
|
|
7194
7300
|
} catch (err) {
|
|
7195
7301
|
log.warn(
|
|
@@ -7225,6 +7331,21 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7225
7331
|
static setScopedCacheInvalidationDefault(memoryDir, enabled) {
|
|
7226
7332
|
_StorageManager.scopedCacheInvalidationByDir.set(memoryDir, enabled !== false);
|
|
7227
7333
|
}
|
|
7334
|
+
/** OKF `type` emission gate registrations per memory dir (issue #1946). */
|
|
7335
|
+
static okfConformanceByDir = /* @__PURE__ */ new Map();
|
|
7336
|
+
/** Register the OKF conformance gate for a memory dir. Unregistered dirs default to
|
|
7337
|
+
* conformance-on; namespace child dirs (<memoryDir>/namespaces/<tok>) inherit the
|
|
7338
|
+
* nearest registered ancestor. Only an explicit `false` disables. */
|
|
7339
|
+
static setOkfConformanceDefault(memoryDir, enabled) {
|
|
7340
|
+
_StorageManager.okfConformanceByDir.set(memoryDir, enabled !== false);
|
|
7341
|
+
}
|
|
7342
|
+
okfConformanceEnabled() {
|
|
7343
|
+
for (let dir = this.baseDir; ; dir = path14.dirname(dir)) {
|
|
7344
|
+
const registered = _StorageManager.okfConformanceByDir.get(dir);
|
|
7345
|
+
if (registered !== void 0) return registered;
|
|
7346
|
+
if (dir === path14.dirname(dir)) return true;
|
|
7347
|
+
}
|
|
7348
|
+
}
|
|
7228
7349
|
/**
|
|
7229
7350
|
* The LIVE class object of this instance (issue #1809 review of the
|
|
7230
7351
|
* storage decomposition): extracted store modules must read/write the
|
|
@@ -7269,12 +7390,12 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7269
7390
|
}
|
|
7270
7391
|
identityFilePath(workspaceDir, namespace) {
|
|
7271
7392
|
const rawNamespace = typeof namespace === "string" ? namespace.trim() : "";
|
|
7272
|
-
if (!rawNamespace) return
|
|
7393
|
+
if (!rawNamespace) return path14.join(workspaceDir, "IDENTITY.md");
|
|
7273
7394
|
const safeNamespace = rawNamespace.replace(/[^a-zA-Z0-9._-]/g, "-");
|
|
7274
|
-
return
|
|
7395
|
+
return path14.join(workspaceDir, `IDENTITY.${safeNamespace}.md`);
|
|
7275
7396
|
}
|
|
7276
7397
|
versionFilePath(kind) {
|
|
7277
|
-
return
|
|
7398
|
+
return path14.join(this.stateDir, `.${kind}-version.log`);
|
|
7278
7399
|
}
|
|
7279
7400
|
bumpSharedVersion(kind, fallbackMap) {
|
|
7280
7401
|
const filePath = this.versionFilePath(kind);
|
|
@@ -7378,7 +7499,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7378
7499
|
// memories.
|
|
7379
7500
|
// -------------------------------------------------------------------------
|
|
7380
7501
|
get wearablesDir() {
|
|
7381
|
-
return
|
|
7502
|
+
return path14.join(this.baseDir, WEARABLES_DIR_NAME);
|
|
7382
7503
|
}
|
|
7383
7504
|
/**
|
|
7384
7505
|
* Resolve the on-disk path for a source/day transcript. Throws on
|
|
@@ -7394,7 +7515,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7394
7515
|
if (!isValidTranscriptDate(date)) {
|
|
7395
7516
|
throw new Error(`invalid wearable transcript date '${String(date)}' \u2014 expected YYYY-MM-DD`);
|
|
7396
7517
|
}
|
|
7397
|
-
return
|
|
7518
|
+
return path14.join(this.wearablesDir, sourceId, `${date}.md`);
|
|
7398
7519
|
}
|
|
7399
7520
|
async writeWearableDayTranscript(sourceId, date, serialized) {
|
|
7400
7521
|
const targetPath = this.wearableTranscriptPath(sourceId, date);
|
|
@@ -7510,25 +7631,25 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7510
7631
|
});
|
|
7511
7632
|
}
|
|
7512
7633
|
get factsDir() {
|
|
7513
|
-
return
|
|
7634
|
+
return path14.join(this.baseDir, "facts");
|
|
7514
7635
|
}
|
|
7515
7636
|
get correctionsDir() {
|
|
7516
|
-
return
|
|
7637
|
+
return path14.join(this.baseDir, "corrections");
|
|
7517
7638
|
}
|
|
7518
7639
|
get proceduresDir() {
|
|
7519
|
-
return
|
|
7640
|
+
return path14.join(this.baseDir, "procedures");
|
|
7520
7641
|
}
|
|
7521
7642
|
get reasoningTracesDir() {
|
|
7522
|
-
return
|
|
7643
|
+
return path14.join(this.baseDir, "reasoning-traces");
|
|
7523
7644
|
}
|
|
7524
7645
|
get entitiesDir() {
|
|
7525
|
-
return
|
|
7646
|
+
return path14.join(this.baseDir, "entities");
|
|
7526
7647
|
}
|
|
7527
7648
|
resolveEntityFilePath(name) {
|
|
7528
7649
|
if (typeof name !== "string") return null;
|
|
7529
|
-
const filePath =
|
|
7530
|
-
const relative2 =
|
|
7531
|
-
if (relative2 === "" || relative2.startsWith("..") ||
|
|
7650
|
+
const filePath = path14.resolve(this.entitiesDir, `${name}.md`);
|
|
7651
|
+
const relative2 = path14.relative(this.entitiesDir, filePath);
|
|
7652
|
+
if (relative2 === "" || relative2.startsWith("..") || path14.isAbsolute(relative2)) {
|
|
7532
7653
|
return null;
|
|
7533
7654
|
}
|
|
7534
7655
|
return filePath;
|
|
@@ -7539,7 +7660,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7539
7660
|
async readDependencyPropagationQueueFile(filePath) {
|
|
7540
7661
|
const target = await resolveSafeStoragePath(
|
|
7541
7662
|
this.baseDir,
|
|
7542
|
-
|
|
7663
|
+
path14.relative(
|
|
7543
7664
|
this.baseDir,
|
|
7544
7665
|
this.assertManagedStoragePath(filePath, "storage.readDependencyPropagationQueueFile")
|
|
7545
7666
|
)
|
|
@@ -7549,7 +7670,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7549
7670
|
async writeDependencyPropagationQueueFile(filePath, content) {
|
|
7550
7671
|
const target = await resolveSafeStoragePath(
|
|
7551
7672
|
this.baseDir,
|
|
7552
|
-
|
|
7673
|
+
path14.relative(
|
|
7553
7674
|
this.baseDir,
|
|
7554
7675
|
this.assertManagedStoragePath(filePath, "storage.writeDependencyPropagationQueueFile")
|
|
7555
7676
|
)
|
|
@@ -7557,16 +7678,17 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7557
7678
|
return this.writeStorageSecureFile(target, content);
|
|
7558
7679
|
}
|
|
7559
7680
|
writeStorageSecureFile(filePath, content, forceEncrypt = false) {
|
|
7681
|
+
assertNotOkfReservedBasename(filePath);
|
|
7560
7682
|
const writeKey = this.resolveWriteKey(forceEncrypt);
|
|
7561
7683
|
return writeMaybeEncryptedFile(filePath, content, writeKey, {}, this.baseDir).then(() => {
|
|
7562
7684
|
this.notifyCatalogWriteForPath(filePath);
|
|
7563
7685
|
});
|
|
7564
7686
|
}
|
|
7565
7687
|
assertManagedStoragePath(filePath, method) {
|
|
7566
|
-
const resolved =
|
|
7567
|
-
const base =
|
|
7568
|
-
const rel =
|
|
7569
|
-
if (rel === "" || rel === ".." || rel.startsWith(`..${
|
|
7688
|
+
const resolved = path14.resolve(filePath);
|
|
7689
|
+
const base = path14.resolve(this.baseDir);
|
|
7690
|
+
const rel = path14.relative(base, resolved);
|
|
7691
|
+
if (rel === "" || rel === ".." || rel.startsWith(`..${path14.sep}`) || path14.isAbsolute(rel)) {
|
|
7570
7692
|
throw new Error(`${method}: file path escapes memory dir`);
|
|
7571
7693
|
}
|
|
7572
7694
|
return resolved;
|
|
@@ -7599,7 +7721,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7599
7721
|
async digestOfflineSyncFile(filePath) {
|
|
7600
7722
|
const target = this.assertManagedStoragePath(filePath, "storage.digestOfflineSyncFile");
|
|
7601
7723
|
const st = await stat3(target);
|
|
7602
|
-
const relPath =
|
|
7724
|
+
const relPath = path14.relative(this.baseDir, target).split(path14.sep).join("/");
|
|
7603
7725
|
const cache = await this.loadOfflineSyncDigestCache();
|
|
7604
7726
|
const cached = cache.get(relPath);
|
|
7605
7727
|
if (cached && cached.statBytes === st.size && cached.mtimeMs === st.mtimeMs && cached.ctimeMs === st.ctimeMs && !cached.encrypted) {
|
|
@@ -7660,7 +7782,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7660
7782
|
const bytes = typeof record.bytes === "number" ? record.bytes : NaN;
|
|
7661
7783
|
const sha256 = typeof record.sha256 === "string" ? record.sha256 : "";
|
|
7662
7784
|
const encrypted = record.encrypted === true;
|
|
7663
|
-
if (cachePath.length === 0 || cachePath === ".." || cachePath.startsWith("../") ||
|
|
7785
|
+
if (cachePath.length === 0 || cachePath === ".." || cachePath.startsWith("../") || path14.isAbsolute(cachePath) || !Number.isFinite(statBytes) || !Number.isFinite(mtimeMs) || !Number.isFinite(ctimeMs) || !Number.isFinite(bytes) || !/^[a-f0-9]{64}$/i.test(sha256)) {
|
|
7664
7786
|
continue;
|
|
7665
7787
|
}
|
|
7666
7788
|
cache.set(cachePath, { statBytes, mtimeMs, ctimeMs, encrypted, sha256, bytes });
|
|
@@ -7702,7 +7824,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7702
7824
|
const cache = this.offlineSyncDigestCache;
|
|
7703
7825
|
if (!cache) return;
|
|
7704
7826
|
const entries = [...cache.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([entryPath, entry]) => ({ path: entryPath, ...entry }));
|
|
7705
|
-
await mkdir(
|
|
7827
|
+
await mkdir(path14.dirname(this.offlineSyncDigestCachePath), { recursive: true });
|
|
7706
7828
|
await writeFile2(this.offlineSyncDigestCachePath, `${JSON.stringify({ version: 1, entries })}
|
|
7707
7829
|
`, "utf-8");
|
|
7708
7830
|
}).catch((err) => {
|
|
@@ -7791,7 +7913,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7791
7913
|
}
|
|
7792
7914
|
async appendStorageSecureFileUnlocked(filePath, content) {
|
|
7793
7915
|
const writeKey = this.resolveWriteKey();
|
|
7794
|
-
await mkdir(
|
|
7916
|
+
await mkdir(path14.dirname(filePath), { recursive: true });
|
|
7795
7917
|
if (writeKey === null) {
|
|
7796
7918
|
try {
|
|
7797
7919
|
if (await this.isEncryptedFileHeader(filePath)) {
|
|
@@ -7817,13 +7939,13 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7817
7939
|
this.notifyCatalogWriteForPath(filePath);
|
|
7818
7940
|
}
|
|
7819
7941
|
get stateDir() {
|
|
7820
|
-
return
|
|
7942
|
+
return path14.join(this.baseDir, "state");
|
|
7821
7943
|
}
|
|
7822
7944
|
get offlineSyncDigestCachePath() {
|
|
7823
|
-
return
|
|
7945
|
+
return path14.join(this.baseDir, ".offline-sync", "digest-cache.v1.json");
|
|
7824
7946
|
}
|
|
7825
7947
|
get entitySynthesisQueuePath() {
|
|
7826
|
-
return
|
|
7948
|
+
return path14.join(this.stateDir, "entity-synthesis-queue.json");
|
|
7827
7949
|
}
|
|
7828
7950
|
// ── Tombstone store access (issue #1579) ─────────────────────────────────
|
|
7829
7951
|
/**
|
|
@@ -7833,7 +7955,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
7833
7955
|
* helpers are injected into the store).
|
|
7834
7956
|
*/
|
|
7835
7957
|
get tombstonesPath() {
|
|
7836
|
-
return
|
|
7958
|
+
return path14.join(this.stateDir, "tombstones.jsonl");
|
|
7837
7959
|
}
|
|
7838
7960
|
/**
|
|
7839
7961
|
* Configure the tombstone invariant for this storage instance. Installed
|
|
@@ -8135,55 +8257,55 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8135
8257
|
return legacyMatches.length > 0 ? [...new Set(legacyMatches.map((content) => ContentHashIndex.computeHash(content)))] : [persistedHash];
|
|
8136
8258
|
}
|
|
8137
8259
|
get questionsDir() {
|
|
8138
|
-
return
|
|
8260
|
+
return path14.join(this.baseDir, "questions");
|
|
8139
8261
|
}
|
|
8140
8262
|
get artifactsDir() {
|
|
8141
|
-
return
|
|
8263
|
+
return path14.join(this.baseDir, "artifacts");
|
|
8142
8264
|
}
|
|
8143
8265
|
get identityDir() {
|
|
8144
|
-
return
|
|
8266
|
+
return path14.join(this.baseDir, "identity");
|
|
8145
8267
|
}
|
|
8146
8268
|
get identityAnchorPath() {
|
|
8147
|
-
return
|
|
8269
|
+
return path14.join(this.identityDir, "identity-anchor.md");
|
|
8148
8270
|
}
|
|
8149
8271
|
get identityIncidentsDir() {
|
|
8150
|
-
return
|
|
8272
|
+
return path14.join(this.identityDir, "incidents");
|
|
8151
8273
|
}
|
|
8152
8274
|
get identityAuditsWeeklyDir() {
|
|
8153
|
-
return
|
|
8275
|
+
return path14.join(this.identityDir, "audits", "weekly");
|
|
8154
8276
|
}
|
|
8155
8277
|
get identityAuditsMonthlyDir() {
|
|
8156
|
-
return
|
|
8278
|
+
return path14.join(this.identityDir, "audits", "monthly");
|
|
8157
8279
|
}
|
|
8158
8280
|
get identityImprovementLoopsPath() {
|
|
8159
|
-
return
|
|
8281
|
+
return path14.join(this.identityDir, "improvement-loops.md");
|
|
8160
8282
|
}
|
|
8161
8283
|
get identityReflectionsPath() {
|
|
8162
|
-
return
|
|
8284
|
+
return path14.join(this.identityDir, "reflections.md");
|
|
8163
8285
|
}
|
|
8164
8286
|
get profilePath() {
|
|
8165
|
-
return
|
|
8287
|
+
return path14.join(this.baseDir, "profile.md");
|
|
8166
8288
|
}
|
|
8167
8289
|
get memoryActionsPath() {
|
|
8168
|
-
return
|
|
8290
|
+
return path14.join(this.stateDir, "memory-actions.jsonl");
|
|
8169
8291
|
}
|
|
8170
8292
|
get memoryLifecycleLedgerPath() {
|
|
8171
|
-
return
|
|
8293
|
+
return path14.join(this.stateDir, "memory-lifecycle-ledger.jsonl");
|
|
8172
8294
|
}
|
|
8173
8295
|
get compressionGuidelinesPath() {
|
|
8174
|
-
return
|
|
8296
|
+
return path14.join(this.stateDir, "compression-guidelines.md");
|
|
8175
8297
|
}
|
|
8176
8298
|
get compressionGuidelineDraftPath() {
|
|
8177
|
-
return
|
|
8299
|
+
return path14.join(this.stateDir, "compression-guidelines.draft.md");
|
|
8178
8300
|
}
|
|
8179
8301
|
get compressionGuidelineStatePath() {
|
|
8180
|
-
return
|
|
8302
|
+
return path14.join(this.stateDir, "compression-guideline-state.json");
|
|
8181
8303
|
}
|
|
8182
8304
|
get compressionGuidelineDraftStatePath() {
|
|
8183
|
-
return
|
|
8305
|
+
return path14.join(this.stateDir, "compression-guideline-draft-state.json");
|
|
8184
8306
|
}
|
|
8185
8307
|
get behaviorSignalsPath() {
|
|
8186
|
-
return
|
|
8308
|
+
return path14.join(this.stateDir, "behavior-signals.jsonl");
|
|
8187
8309
|
}
|
|
8188
8310
|
/**
|
|
8189
8311
|
* In-memory dedup key set for behavior-signals appends (issue #1909),
|
|
@@ -8215,7 +8337,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8215
8337
|
* governance sweeps can treat it uniformly.
|
|
8216
8338
|
*/
|
|
8217
8339
|
get bufferSurpriseLedgerPath() {
|
|
8218
|
-
return
|
|
8340
|
+
return path14.join(this.stateDir, "buffer-surprise-ledger.jsonl");
|
|
8219
8341
|
}
|
|
8220
8342
|
/**
|
|
8221
8343
|
* Entity alias table loaded from THIS store's config/aliases.json.
|
|
@@ -8276,7 +8398,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8276
8398
|
this.loadAliasesSync();
|
|
8277
8399
|
}
|
|
8278
8400
|
loadAliasesSync() {
|
|
8279
|
-
const aliasPath =
|
|
8401
|
+
const aliasPath = path14.join(this.baseDir, "config", "aliases.json");
|
|
8280
8402
|
this.userAliases = {};
|
|
8281
8403
|
const raw = readEntityAliasConfigSync(this.baseDir);
|
|
8282
8404
|
if (raw === void 0) return;
|
|
@@ -8305,7 +8427,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8305
8427
|
const completionFingerprint = await runLegacyEntityCanonicalIdMigration(
|
|
8306
8428
|
this,
|
|
8307
8429
|
(content) => parseEntityFile(content, this.entitySchemas),
|
|
8308
|
-
(entity) => serializeEntityFile(entity, this.entitySchemas),
|
|
8430
|
+
(entity) => serializeEntityFile(entity, this.entitySchemas, this.okfConformanceEnabled()),
|
|
8309
8431
|
createMemoryEntityRefSerializer(serializeFrontmatter)
|
|
8310
8432
|
);
|
|
8311
8433
|
return completionFingerprint;
|
|
@@ -8314,9 +8436,9 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8314
8436
|
await mkdir(this.baseDir, { recursive: true });
|
|
8315
8437
|
await validateRoots(this.baseDir, this.entitiesDir, this.stateDir, this.archiveDir);
|
|
8316
8438
|
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
8317
|
-
await mkdir(
|
|
8318
|
-
await mkdir(
|
|
8319
|
-
await mkdir(
|
|
8439
|
+
await mkdir(path14.join(this.factsDir, today), { recursive: true });
|
|
8440
|
+
await mkdir(path14.join(this.proceduresDir, today), { recursive: true });
|
|
8441
|
+
await mkdir(path14.join(this.reasoningTracesDir, today), { recursive: true });
|
|
8320
8442
|
await mkdir(this.correctionsDir, { recursive: true });
|
|
8321
8443
|
await mkdir(this.entitiesDir, { recursive: true });
|
|
8322
8444
|
await mkdir(this.stateDir, { recursive: true });
|
|
@@ -8326,7 +8448,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8326
8448
|
await mkdir(this.identityIncidentsDir, { recursive: true });
|
|
8327
8449
|
await mkdir(this.identityAuditsWeeklyDir, { recursive: true });
|
|
8328
8450
|
await mkdir(this.identityAuditsMonthlyDir, { recursive: true });
|
|
8329
|
-
await mkdir(
|
|
8451
|
+
await mkdir(path14.join(this.baseDir, "config"), { recursive: true });
|
|
8330
8452
|
await this.entityCanonicalIdMigration.ensure();
|
|
8331
8453
|
if (this.hotMemoriesCacheEnabled && this.getMemoryCorpusVersion() === 0) {
|
|
8332
8454
|
this.bumpMemoryCorpusVersion();
|
|
@@ -8348,11 +8470,11 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8348
8470
|
async resolveCategoryWritePath(category, id, today) {
|
|
8349
8471
|
if (category === "correction") {
|
|
8350
8472
|
await mkdir(this.correctionsDir, { recursive: true });
|
|
8351
|
-
return
|
|
8473
|
+
return path14.join(this.correctionsDir, `${id}.md`);
|
|
8352
8474
|
}
|
|
8353
|
-
const datedDir =
|
|
8475
|
+
const datedDir = path14.join(getCategoryDir(this.baseDir, category), today);
|
|
8354
8476
|
await mkdir(datedDir, { recursive: true });
|
|
8355
|
-
return
|
|
8477
|
+
return path14.join(datedDir, `${id}.md`);
|
|
8356
8478
|
}
|
|
8357
8479
|
async findExistingTombstoneBlockedMemory(content, category, sourceConnector) {
|
|
8358
8480
|
const identity = buildExplicitCaptureDedupKey(content, category, sourceConnector);
|
|
@@ -8366,6 +8488,12 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8366
8488
|
) === identity;
|
|
8367
8489
|
}) ?? null;
|
|
8368
8490
|
}
|
|
8491
|
+
/** Derive the inert OKF `type` at the serialization choke point when conformance is on
|
|
8492
|
+
* and the parsed frontmatter carried none (issue #1946). Never touches `category`. */
|
|
8493
|
+
withOkfType(fm) {
|
|
8494
|
+
if (this.okfConformanceEnabled() && fm.type === void 0) fm.type = okfTypeForMemory(fm);
|
|
8495
|
+
return fm;
|
|
8496
|
+
}
|
|
8369
8497
|
async writeMemory(category, content, options = {}) {
|
|
8370
8498
|
await this.ensureDirectories();
|
|
8371
8499
|
const rawEntityRef = options.entityRef;
|
|
@@ -8476,7 +8604,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
|
|
|
8476
8604
|
}
|
|
8477
8605
|
};
|
|
8478
8606
|
await applyTombstoneGate();
|
|
8479
|
-
const fileContent = `${serializeFrontmatter(fm)}
|
|
8607
|
+
const fileContent = `${serializeFrontmatter(this.withOkfType(fm))}
|
|
8480
8608
|
|
|
8481
8609
|
${sanitized.text}
|
|
8482
8610
|
`;
|
|
@@ -8503,7 +8631,7 @@ ${sanitized.text}
|
|
|
8503
8631
|
await applyTombstoneGate();
|
|
8504
8632
|
await this.writeTombstoneBlockedMemory(
|
|
8505
8633
|
filePath,
|
|
8506
|
-
`${serializeFrontmatter(fm)}
|
|
8634
|
+
`${serializeFrontmatter(this.withOkfType(fm))}
|
|
8507
8635
|
|
|
8508
8636
|
${sanitized.text}
|
|
8509
8637
|
`,
|
|
@@ -8719,7 +8847,7 @@ ${sanitized.text}
|
|
|
8719
8847
|
await this.ensureDirectories();
|
|
8720
8848
|
const now = /* @__PURE__ */ new Date();
|
|
8721
8849
|
const day = now.toISOString().slice(0, 10);
|
|
8722
|
-
const dir =
|
|
8850
|
+
const dir = path14.join(this.artifactsDir, day);
|
|
8723
8851
|
await mkdir(dir, { recursive: true });
|
|
8724
8852
|
const id = `artifact-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
8725
8853
|
const fm = {
|
|
@@ -8746,8 +8874,8 @@ ${sanitized.text}
|
|
|
8746
8874
|
log.warn(`artifact content rejected for ${id}; violations=${sanitized.violations.join(", ")}`);
|
|
8747
8875
|
return "";
|
|
8748
8876
|
}
|
|
8749
|
-
const filePath =
|
|
8750
|
-
await this.writeStorageSecureFile(filePath, `${serializeFrontmatter(fm)}
|
|
8877
|
+
const filePath = path14.join(dir, `${id}.md`);
|
|
8878
|
+
await this.writeStorageSecureFile(filePath, `${serializeFrontmatter(this.withOkfType(fm))}
|
|
8751
8879
|
|
|
8752
8880
|
${sanitized.text}
|
|
8753
8881
|
`);
|
|
@@ -8780,7 +8908,7 @@ ${sanitized.text}
|
|
|
8780
8908
|
}
|
|
8781
8909
|
async readProfile() {
|
|
8782
8910
|
try {
|
|
8783
|
-
return await readMaybeEncryptedFile(this.profilePath, this._secureStoreKey, this.baseDir);
|
|
8911
|
+
return stripOkfProfileFrontmatter(await readMaybeEncryptedFile(this.profilePath, this._secureStoreKey, this.baseDir));
|
|
8784
8912
|
} catch (error) {
|
|
8785
8913
|
if (error instanceof SecureStoreLockedError) {
|
|
8786
8914
|
throw error;
|
|
@@ -8790,7 +8918,12 @@ ${sanitized.text}
|
|
|
8790
8918
|
}
|
|
8791
8919
|
}
|
|
8792
8920
|
async writeProfile(content) {
|
|
8793
|
-
const
|
|
8921
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
8922
|
+
const stampedContent = withOkfProfileFrontmatter(
|
|
8923
|
+
renderProfileWithLastUpdated(content, timestamp),
|
|
8924
|
+
timestamp,
|
|
8925
|
+
this.okfConformanceEnabled()
|
|
8926
|
+
);
|
|
8794
8927
|
await this.ensureDirectories();
|
|
8795
8928
|
await this.snapshotBeforeWrite(this.profilePath, "consolidation");
|
|
8796
8929
|
await this.writeStorageSecureFile(this.profilePath, stampedContent);
|
|
@@ -9034,7 +9167,7 @@ ${sanitized.text}
|
|
|
9034
9167
|
* per-process in-memory cache safe across process boundaries.
|
|
9035
9168
|
*/
|
|
9036
9169
|
invalidateColdMemoriesCache() {
|
|
9037
|
-
const coldRoot =
|
|
9170
|
+
const coldRoot = path14.join(this.baseDir, "cold");
|
|
9038
9171
|
_StorageManager.coldMemoriesCache.delete(coldRoot);
|
|
9039
9172
|
this.bumpColdWriteVersion();
|
|
9040
9173
|
invalidateAllForDir(this.baseDir);
|
|
@@ -9154,7 +9287,7 @@ ${sanitized.text}
|
|
|
9154
9287
|
const correctionPaths = [];
|
|
9155
9288
|
const factPaths = [];
|
|
9156
9289
|
for (const filePath of filePaths) {
|
|
9157
|
-
if (filePath === this.correctionsDir || filePath.startsWith(`${this.correctionsDir}${
|
|
9290
|
+
if (filePath === this.correctionsDir || filePath.startsWith(`${this.correctionsDir}${path14.sep}`)) {
|
|
9158
9291
|
correctionPaths.push(filePath);
|
|
9159
9292
|
} else {
|
|
9160
9293
|
factPaths.push(filePath);
|
|
@@ -9217,7 +9350,7 @@ ${sanitized.text}
|
|
|
9217
9350
|
try {
|
|
9218
9351
|
const entries = await readdir6(dir, { withFileTypes: true });
|
|
9219
9352
|
for (const entry of entries) {
|
|
9220
|
-
const fullPath =
|
|
9353
|
+
const fullPath = path14.join(dir, entry.name);
|
|
9221
9354
|
if (entry.isDirectory()) {
|
|
9222
9355
|
await readDir(fullPath);
|
|
9223
9356
|
} else if (entry.name.endsWith(".md")) {
|
|
@@ -9260,7 +9393,7 @@ ${sanitized.text}
|
|
|
9260
9393
|
return this.rememberMemorySnapshot(await this.memoryReadStore.readMemoryByPath(filePath));
|
|
9261
9394
|
}
|
|
9262
9395
|
resolveTierRootDir(tier) {
|
|
9263
|
-
return tier === "cold" ?
|
|
9396
|
+
return tier === "cold" ? path14.join(this.baseDir, "cold") : this.baseDir;
|
|
9264
9397
|
}
|
|
9265
9398
|
resolveMemoryDateDir(memory) {
|
|
9266
9399
|
const preferred = memory.frontmatter.created || memory.frontmatter.updated;
|
|
@@ -9275,21 +9408,22 @@ ${sanitized.text}
|
|
|
9275
9408
|
buildTierMemoryPath(memory, tier) {
|
|
9276
9409
|
const root = this.resolveTierRootDir(tier);
|
|
9277
9410
|
if (this.isArtifactMemory(memory)) {
|
|
9278
|
-
return
|
|
9411
|
+
return path14.join(root, "artifacts", this.resolveMemoryDateDir(memory), `${memory.frontmatter.id}.md`);
|
|
9279
9412
|
}
|
|
9280
9413
|
if (memory.frontmatter.category === "correction") {
|
|
9281
|
-
return
|
|
9414
|
+
return path14.join(root, "corrections", `${memory.frontmatter.id}.md`);
|
|
9282
9415
|
}
|
|
9283
9416
|
const dir = categoryDirName(memory.frontmatter.category);
|
|
9284
|
-
return
|
|
9417
|
+
return path14.join(root, dir, this.resolveMemoryDateDir(memory), `${memory.frontmatter.id}.md`);
|
|
9285
9418
|
}
|
|
9286
9419
|
async writeMemoryFileAtomic(targetPath, memory) {
|
|
9420
|
+
assertNotOkfReservedBasename(targetPath);
|
|
9287
9421
|
const refIdsAtWrite = this.currentHistoricalIds();
|
|
9288
9422
|
const rawRef = memory.frontmatter.entityRef;
|
|
9289
9423
|
const frontmatter = canonicalizeEntityRefOption(memory.frontmatter, refIdsAtWrite);
|
|
9290
9424
|
const persist = () => writeMaybeEncryptedFile(
|
|
9291
9425
|
targetPath,
|
|
9292
|
-
`${serializeFrontmatter(frontmatter)}
|
|
9426
|
+
`${serializeFrontmatter(this.withOkfType(frontmatter))}
|
|
9293
9427
|
|
|
9294
9428
|
${memory.content}
|
|
9295
9429
|
`,
|
|
@@ -9359,8 +9493,8 @@ ${memory.content}
|
|
|
9359
9493
|
memory.frontmatter.entityRef = current.frontmatter.entityRef;
|
|
9360
9494
|
}
|
|
9361
9495
|
durable = true;
|
|
9362
|
-
const sourcePath =
|
|
9363
|
-
const destPath =
|
|
9496
|
+
const sourcePath = path14.resolve(current.path);
|
|
9497
|
+
const destPath = path14.resolve(targetPath);
|
|
9364
9498
|
if (sourcePath !== destPath) {
|
|
9365
9499
|
await recordArchiveDelete2(this.baseDir, current.path, () => this.deleteManagedStorageFile(current.path));
|
|
9366
9500
|
this.invalidateAllMemoriesCache();
|
|
@@ -9384,8 +9518,8 @@ ${memory.content}
|
|
|
9384
9518
|
}
|
|
9385
9519
|
async migrateMemoryToTier(memory, targetTier) {
|
|
9386
9520
|
const targetPath = this.buildTierMemoryPath(memory, targetTier);
|
|
9387
|
-
const sourcePath =
|
|
9388
|
-
const destPath =
|
|
9521
|
+
const sourcePath = path14.resolve(memory.path);
|
|
9522
|
+
const destPath = path14.resolve(targetPath);
|
|
9389
9523
|
if (sourcePath === destPath) {
|
|
9390
9524
|
return { changed: false, targetPath };
|
|
9391
9525
|
}
|
|
@@ -9395,7 +9529,7 @@ ${memory.content}
|
|
|
9395
9529
|
return { changed, targetPath };
|
|
9396
9530
|
}
|
|
9397
9531
|
get archiveDir() {
|
|
9398
|
-
return
|
|
9532
|
+
return path14.join(this.baseDir, "archive");
|
|
9399
9533
|
}
|
|
9400
9534
|
/**
|
|
9401
9535
|
* Archive a memory by moving it from facts/ to archive/YYYY-MM-DD/.
|
|
@@ -9408,7 +9542,7 @@ ${memory.content}
|
|
|
9408
9542
|
try {
|
|
9409
9543
|
const now = lifecycle?.at ?? /* @__PURE__ */ new Date();
|
|
9410
9544
|
const today = now.toISOString().slice(0, 10);
|
|
9411
|
-
const destDir =
|
|
9545
|
+
const destDir = path14.join(this.archiveDir, today);
|
|
9412
9546
|
await mkdir(destDir, { recursive: true });
|
|
9413
9547
|
const refIdsAtWrite = this.currentHistoricalIds();
|
|
9414
9548
|
const updatedFm = canonicalizeEntityRefOption(
|
|
@@ -9420,11 +9554,11 @@ ${memory.content}
|
|
|
9420
9554
|
},
|
|
9421
9555
|
refIdsAtWrite
|
|
9422
9556
|
);
|
|
9423
|
-
const fileContent = `${serializeFrontmatter(updatedFm)}
|
|
9557
|
+
const fileContent = `${serializeFrontmatter(this.withOkfType(updatedFm))}
|
|
9424
9558
|
|
|
9425
9559
|
${current.content}
|
|
9426
9560
|
`;
|
|
9427
|
-
const destPath =
|
|
9561
|
+
const destPath = path14.join(destDir, path14.basename(current.path));
|
|
9428
9562
|
const priorDest = await this.readStorageSecureFile(destPath).catch(() => null);
|
|
9429
9563
|
await recordArchiveWrite(this.baseDir, destPath, () => this.writeStorageSecureFile(destPath, fileContent));
|
|
9430
9564
|
if (typeof current.frontmatter.entityRef === "string") {
|
|
@@ -9577,7 +9711,7 @@ ${current.content}
|
|
|
9577
9711
|
if (!sanitized.clean) {
|
|
9578
9712
|
log.warn(`updated memory content sanitized for ${memory.frontmatter.id}; violations=${sanitized.violations.join(", ")}`);
|
|
9579
9713
|
}
|
|
9580
|
-
const fileContent = `${serializeFrontmatter(updated)}
|
|
9714
|
+
const fileContent = `${serializeFrontmatter(this.withOkfType(updated))}
|
|
9581
9715
|
|
|
9582
9716
|
${sanitized.text}
|
|
9583
9717
|
`;
|
|
@@ -9651,13 +9785,13 @@ ${sanitized.text}
|
|
|
9651
9785
|
);
|
|
9652
9786
|
const refIds = typeof updated.entityRef === "string" ? resolveIds : null;
|
|
9653
9787
|
const afterStatus = updated.status ?? "active";
|
|
9654
|
-
const fileContent = `${serializeFrontmatter(updated)}
|
|
9788
|
+
const fileContent = `${serializeFrontmatter(this.withOkfType(updated))}
|
|
9655
9789
|
|
|
9656
9790
|
${memory.content}
|
|
9657
9791
|
`;
|
|
9658
9792
|
await this.writeTombstoneBlockedFrontmatter(memory, fileContent, updated, async () => {
|
|
9659
9793
|
this.invalidateAllMemoriesCache();
|
|
9660
|
-
if (memory.path.includes(`${
|
|
9794
|
+
if (memory.path.includes(`${path14.sep}cold${path14.sep}`)) {
|
|
9661
9795
|
this.invalidateColdMemoriesCache();
|
|
9662
9796
|
}
|
|
9663
9797
|
});
|
|
@@ -9668,7 +9802,7 @@ ${memory.content}
|
|
|
9668
9802
|
});
|
|
9669
9803
|
}
|
|
9670
9804
|
await this.patchHotMemoriesCache({ addedPath: memory.path });
|
|
9671
|
-
if (memory.path.includes(`${
|
|
9805
|
+
if (memory.path.includes(`${path14.sep}cold${path14.sep}`)) {
|
|
9672
9806
|
this.invalidateColdMemoriesCache();
|
|
9673
9807
|
}
|
|
9674
9808
|
try {
|
|
@@ -9749,7 +9883,7 @@ ${memory.content}
|
|
|
9749
9883
|
return deleted;
|
|
9750
9884
|
}
|
|
9751
9885
|
async loadBuffer() {
|
|
9752
|
-
const bufferPath =
|
|
9886
|
+
const bufferPath = path14.join(this.stateDir, "buffer.json");
|
|
9753
9887
|
try {
|
|
9754
9888
|
const raw = await this.readStorageSecureFile(bufferPath);
|
|
9755
9889
|
return JSON.parse(raw);
|
|
@@ -9761,11 +9895,11 @@ ${memory.content}
|
|
|
9761
9895
|
}
|
|
9762
9896
|
async saveBuffer(state) {
|
|
9763
9897
|
await this.ensureDirectories();
|
|
9764
|
-
const bufferPath =
|
|
9898
|
+
const bufferPath = path14.join(this.stateDir, "buffer.json");
|
|
9765
9899
|
await this.writeStorageSecureFile(bufferPath, JSON.stringify(state, null, 2));
|
|
9766
9900
|
}
|
|
9767
9901
|
async loadMeta() {
|
|
9768
|
-
const metaPath =
|
|
9902
|
+
const metaPath = path14.join(this.stateDir, "meta.json");
|
|
9769
9903
|
try {
|
|
9770
9904
|
const raw = await this.readStorageSecureFile(metaPath);
|
|
9771
9905
|
const parsed = JSON.parse(raw);
|
|
@@ -9798,7 +9932,7 @@ ${memory.content}
|
|
|
9798
9932
|
}
|
|
9799
9933
|
async saveMeta(state) {
|
|
9800
9934
|
await this.ensureDirectories();
|
|
9801
|
-
const metaPath =
|
|
9935
|
+
const metaPath = path14.join(this.stateDir, "meta.json");
|
|
9802
9936
|
await this.writeStorageSecureFile(metaPath, JSON.stringify(state, null, 2));
|
|
9803
9937
|
}
|
|
9804
9938
|
async appendMemoryActionEvents(events) {
|
|
@@ -9862,7 +9996,7 @@ ${memory.content}
|
|
|
9862
9996
|
},
|
|
9863
9997
|
(payload) => this.appendStorageSecureFile(target, payload),
|
|
9864
9998
|
async () => {
|
|
9865
|
-
await mkdir(
|
|
9999
|
+
await mkdir(path14.dirname(target), { recursive: true });
|
|
9866
10000
|
}
|
|
9867
10001
|
);
|
|
9868
10002
|
}
|
|
@@ -9960,7 +10094,7 @@ ${memory.content}
|
|
|
9960
10094
|
async appendReextractJobs(events) {
|
|
9961
10095
|
if (events.length === 0) return 0;
|
|
9962
10096
|
await this.ensureDirectories();
|
|
9963
|
-
const filePath =
|
|
10097
|
+
const filePath = path14.join(this.stateDir, "reextract-jobs.jsonl");
|
|
9964
10098
|
const lines = events.map((event) => JSON.stringify(event)).join("\n") + "\n";
|
|
9965
10099
|
try {
|
|
9966
10100
|
await this.appendStorageSecureFile(filePath, lines);
|
|
@@ -9973,7 +10107,7 @@ ${memory.content}
|
|
|
9973
10107
|
}
|
|
9974
10108
|
async readReextractJobs(limit = 200) {
|
|
9975
10109
|
const safeLimit = Number.isFinite(limit) ? Math.max(1, Math.min(1e3, Math.floor(limit))) : 200;
|
|
9976
|
-
const filePath =
|
|
10110
|
+
const filePath = path14.join(this.stateDir, "reextract-jobs.jsonl");
|
|
9977
10111
|
try {
|
|
9978
10112
|
const raw = await this.readStorageSecureFile(filePath);
|
|
9979
10113
|
const lines = raw.split("\n").filter((line) => line.trim().length > 0);
|
|
@@ -10190,7 +10324,8 @@ ${memory.content}
|
|
|
10190
10324
|
id,
|
|
10191
10325
|
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10192
10326
|
priority,
|
|
10193
|
-
resolved: false
|
|
10327
|
+
resolved: false,
|
|
10328
|
+
...this.okfConformanceEnabled() ? { type: OKF_QUESTION_TYPE } : {}
|
|
10194
10329
|
};
|
|
10195
10330
|
const content = `---
|
|
10196
10331
|
${Object.entries(frontmatter).map(([k, v]) => `${k}: ${JSON.stringify(v)}`).join("\n")}
|
|
@@ -10200,7 +10335,7 @@ ${question}
|
|
|
10200
10335
|
|
|
10201
10336
|
**Context:** ${context}
|
|
10202
10337
|
`;
|
|
10203
|
-
const filePath =
|
|
10338
|
+
const filePath = path14.join(this.questionsDir, `${id}.md`);
|
|
10204
10339
|
await this.writeStorageSecureFile(filePath, content);
|
|
10205
10340
|
log.debug(`wrote question ${id} to ${filePath}`);
|
|
10206
10341
|
this.invalidateQuestionsCache();
|
|
@@ -10214,22 +10349,7 @@ ${question}
|
|
|
10214
10349
|
_StorageManager.questionsCache.delete(this.questionsDir);
|
|
10215
10350
|
}
|
|
10216
10351
|
parseQuestionFile(raw, filePath) {
|
|
10217
|
-
|
|
10218
|
-
if (!match) return null;
|
|
10219
|
-
const frontmatterStr = match[1];
|
|
10220
|
-
const body = match[2].trim();
|
|
10221
|
-
const id = this.extractFrontmatterValue(frontmatterStr, "id") ?? path12.basename(filePath, ".md");
|
|
10222
|
-
const created = this.extractFrontmatterValue(frontmatterStr, "created") ?? "";
|
|
10223
|
-
const priority = parseFloat(this.extractFrontmatterValue(frontmatterStr, "priority") ?? "0.5");
|
|
10224
|
-
const resolved = this.extractFrontmatterValue(frontmatterStr, "resolved") === "true";
|
|
10225
|
-
const contextMatch = body.match(/\*\*Context:\*\*\s*(.*)/);
|
|
10226
|
-
const question = contextMatch ? body.slice(0, contextMatch.index).trim() : body;
|
|
10227
|
-
const context = contextMatch ? contextMatch[1].trim() : "";
|
|
10228
|
-
return { id, question, context, priority, resolved, created, filePath };
|
|
10229
|
-
}
|
|
10230
|
-
extractFrontmatterValue(frontmatter, key) {
|
|
10231
|
-
const match = frontmatter.match(new RegExp(`^${key}:\\s*"?([^"\\n]*)"?`, "m"));
|
|
10232
|
-
return match ? match[1] : null;
|
|
10352
|
+
return parseQuestionFile(raw, filePath);
|
|
10233
10353
|
}
|
|
10234
10354
|
async resolveQuestion(id) {
|
|
10235
10355
|
const questions = await this.readQuestions();
|
|
@@ -10274,11 +10394,11 @@ ${question}
|
|
|
10274
10394
|
} catch {
|
|
10275
10395
|
}
|
|
10276
10396
|
const hygiene = opts?.hygiene;
|
|
10277
|
-
const rotateEnabled = hygiene?.enabled === true && hygiene.rotateEnabled === true && Array.isArray(hygiene.rotatePaths) && hygiene.rotatePaths.includes(
|
|
10397
|
+
const rotateEnabled = hygiene?.enabled === true && hygiene.rotateEnabled === true && Array.isArray(hygiene.rotatePaths) && hygiene.rotatePaths.includes(path14.basename(identityPath));
|
|
10278
10398
|
if (rotateEnabled) {
|
|
10279
10399
|
const maxBytes = hygiene.rotateMaxBytes;
|
|
10280
10400
|
if (existing.length > maxBytes) {
|
|
10281
|
-
const archiveDir =
|
|
10401
|
+
const archiveDir = path14.join(workspaceDir, hygiene.archiveDir);
|
|
10282
10402
|
const { newContent } = await rotateMarkdownFileToArchive({
|
|
10283
10403
|
filePath: identityPath,
|
|
10284
10404
|
archiveDir,
|
|
@@ -10538,14 +10658,14 @@ ${reflection}
|
|
|
10538
10658
|
if (entries.length === 0) return 0;
|
|
10539
10659
|
const memories = await this.readAllMemories();
|
|
10540
10660
|
const memoryMap = new Map(memories.map((m) => [m.frontmatter.id, m]));
|
|
10541
|
-
const memoryPathMap = new Map(memories.map((m) => [
|
|
10661
|
+
const memoryPathMap = new Map(memories.map((m) => [path14.resolve(m.path), m]));
|
|
10542
10662
|
let updated = 0;
|
|
10543
10663
|
const prevVersion = this.getMemoryCorpusVersion();
|
|
10544
10664
|
const keyId = this.hotCacheKeyId();
|
|
10545
10665
|
const warm = this.hotMemoriesCacheEnabled && getCachedMemories(this.baseDir, prevVersion, keyId, this.hotCacheTtlMs()) !== null;
|
|
10546
10666
|
const appliedPatches = /* @__PURE__ */ new Map();
|
|
10547
10667
|
for (const entry of entries) {
|
|
10548
|
-
const memory = entry.memoryPath ? memoryPathMap.get(
|
|
10668
|
+
const memory = entry.memoryPath ? memoryPathMap.get(path14.resolve(entry.memoryPath)) : memoryMap.get(entry.memoryId);
|
|
10549
10669
|
if (!memory) continue;
|
|
10550
10670
|
try {
|
|
10551
10671
|
const applied = await this.withTombstoneBlockedMemoryPathLock(memory.path, async (current) => {
|
|
@@ -10555,7 +10675,7 @@ ${reflection}
|
|
|
10555
10675
|
{ ...current.frontmatter, accessCount: entry.newCount, lastAccessed: entry.lastAccessed },
|
|
10556
10676
|
rowIds
|
|
10557
10677
|
);
|
|
10558
|
-
const fileContent = `${serializeFrontmatter(newFm)}
|
|
10678
|
+
const fileContent = `${serializeFrontmatter(this.withOkfType(newFm))}
|
|
10559
10679
|
|
|
10560
10680
|
${current.content}
|
|
10561
10681
|
`;
|
|
@@ -10576,7 +10696,7 @@ ${current.content}
|
|
|
10576
10696
|
if (warm) {
|
|
10577
10697
|
updateCacheOnWrite(this.baseDir, { ...applied.current, frontmatter: applied.newFm }, keyId);
|
|
10578
10698
|
}
|
|
10579
|
-
appliedPatches.set(
|
|
10699
|
+
appliedPatches.set(path14.resolve(memory.path), {
|
|
10580
10700
|
accessCount: entry.newCount,
|
|
10581
10701
|
lastAccessed: entry.lastAccessed
|
|
10582
10702
|
});
|
|
@@ -10592,7 +10712,7 @@ ${current.content}
|
|
|
10592
10712
|
const cur = getCachedMemories(this.baseDir, prevVersion, keyId);
|
|
10593
10713
|
if (cur) {
|
|
10594
10714
|
const reapplied = cur.map((m) => {
|
|
10595
|
-
const patch = appliedPatches.get(
|
|
10715
|
+
const patch = appliedPatches.get(path14.resolve(m.path));
|
|
10596
10716
|
return patch ? {
|
|
10597
10717
|
...m,
|
|
10598
10718
|
frontmatter: { ...m.frontmatter, accessCount: patch.accessCount, lastAccessed: patch.lastAccessed }
|
|
@@ -10622,7 +10742,7 @@ ${current.content}
|
|
|
10622
10742
|
const pathsById = /* @__PURE__ */ new Map();
|
|
10623
10743
|
const filePathsById = /* @__PURE__ */ new Map();
|
|
10624
10744
|
for (const filePath of filePaths) {
|
|
10625
|
-
const memoryId =
|
|
10745
|
+
const memoryId = path14.basename(filePath, ".md");
|
|
10626
10746
|
if (!wantedIds.has(memoryId)) continue;
|
|
10627
10747
|
const paths = filePathsById.get(memoryId) ?? [];
|
|
10628
10748
|
paths.push(filePath);
|
|
@@ -10634,7 +10754,7 @@ ${current.content}
|
|
|
10634
10754
|
const preferredMatches = [];
|
|
10635
10755
|
for (const preferredPath of preferred) {
|
|
10636
10756
|
const directCandidates = new Set(qmdResultPathCandidates(this.baseDir, preferredPath));
|
|
10637
|
-
const directMatch = existingPaths.find((filePath) => directCandidates.has(
|
|
10757
|
+
const directMatch = existingPaths.find((filePath) => directCandidates.has(path14.resolve(filePath)));
|
|
10638
10758
|
if (directMatch) {
|
|
10639
10759
|
preferredMatches.push(directMatch);
|
|
10640
10760
|
continue;
|
|
@@ -10646,7 +10766,7 @@ ${current.content}
|
|
|
10646
10766
|
candidates.add(candidate);
|
|
10647
10767
|
}
|
|
10648
10768
|
}
|
|
10649
|
-
const match = existingPaths.find((filePath) => candidates.has(
|
|
10769
|
+
const match = existingPaths.find((filePath) => candidates.has(path14.resolve(filePath)));
|
|
10650
10770
|
if (match) preferredMatches.push(match);
|
|
10651
10771
|
}
|
|
10652
10772
|
if (preferredMatches.length > 0) {
|
|
@@ -10777,7 +10897,7 @@ ${current.content}
|
|
|
10777
10897
|
}) ? { toolScoped: true } : {}
|
|
10778
10898
|
};
|
|
10779
10899
|
const filePath = await this.resolveCategoryWritePath(category, id, today);
|
|
10780
|
-
const fileContent = `${serializeFrontmatter(fm)}
|
|
10900
|
+
const fileContent = `${serializeFrontmatter(this.withOkfType(fm))}
|
|
10781
10901
|
|
|
10782
10902
|
${sanitized.text}
|
|
10783
10903
|
`;
|
|
@@ -10876,7 +10996,7 @@ ${sanitized.text}
|
|
|
10876
10996
|
},
|
|
10877
10997
|
refIdsAtWrite
|
|
10878
10998
|
);
|
|
10879
|
-
const fileContent = `${serializeFrontmatter(updatedFm)}
|
|
10999
|
+
const fileContent = `${serializeFrontmatter(this.withOkfType(updatedFm))}
|
|
10880
11000
|
|
|
10881
11001
|
${current.content}
|
|
10882
11002
|
`;
|
|
@@ -10966,11 +11086,11 @@ ${current.content}
|
|
|
10966
11086
|
}
|
|
10967
11087
|
}
|
|
10968
11088
|
get summariesDir() {
|
|
10969
|
-
return
|
|
11089
|
+
return path14.join(this.baseDir, "summaries");
|
|
10970
11090
|
}
|
|
10971
11091
|
async writeSummary(summary) {
|
|
10972
11092
|
await mkdir(this.summariesDir, { recursive: true });
|
|
10973
|
-
const filePath =
|
|
11093
|
+
const filePath = path14.join(this.summariesDir, `${summary.id}.json`);
|
|
10974
11094
|
await this.writeStorageSecureFile(filePath, JSON.stringify(summary, null, 2));
|
|
10975
11095
|
log.debug(`wrote summary ${summary.id}`);
|
|
10976
11096
|
}
|
|
@@ -10980,7 +11100,7 @@ ${current.content}
|
|
|
10980
11100
|
const summaries = [];
|
|
10981
11101
|
for (const file of files) {
|
|
10982
11102
|
if (!file.endsWith(".json")) continue;
|
|
10983
|
-
const filePath =
|
|
11103
|
+
const filePath = path14.join(this.summariesDir, file);
|
|
10984
11104
|
const raw = await this.readStorageSecureFile(filePath);
|
|
10985
11105
|
summaries.push(JSON.parse(raw));
|
|
10986
11106
|
}
|
|
@@ -11010,7 +11130,7 @@ ${current.content}
|
|
|
11010
11130
|
{ ...current.frontmatter, status: "archived", archivedAt: now, updated: now },
|
|
11011
11131
|
rowIds
|
|
11012
11132
|
);
|
|
11013
|
-
const fileContent = `${serializeFrontmatter(updatedFm)}
|
|
11133
|
+
const fileContent = `${serializeFrontmatter(this.withOkfType(updatedFm))}
|
|
11014
11134
|
|
|
11015
11135
|
${current.content}
|
|
11016
11136
|
`;
|
|
@@ -11050,7 +11170,7 @@ ${current.content}
|
|
|
11050
11170
|
return archived;
|
|
11051
11171
|
}
|
|
11052
11172
|
async saveTopics(topics) {
|
|
11053
|
-
const metaPath =
|
|
11173
|
+
const metaPath = path14.join(this.stateDir, "topics.json");
|
|
11054
11174
|
await mkdir(this.stateDir, { recursive: true });
|
|
11055
11175
|
await this.writeStorageSecureFile(
|
|
11056
11176
|
metaPath,
|
|
@@ -11059,7 +11179,7 @@ ${current.content}
|
|
|
11059
11179
|
log.debug(`saved ${topics.length} topic scores`);
|
|
11060
11180
|
}
|
|
11061
11181
|
async loadTopics() {
|
|
11062
|
-
const metaPath =
|
|
11182
|
+
const metaPath = path14.join(this.stateDir, "topics.json");
|
|
11063
11183
|
try {
|
|
11064
11184
|
const raw = await this.readStorageSecureFile(metaPath);
|
|
11065
11185
|
return JSON.parse(raw);
|
|
@@ -11134,6 +11254,8 @@ ${current.content}
|
|
|
11134
11254
|
};
|
|
11135
11255
|
|
|
11136
11256
|
export {
|
|
11257
|
+
okfTypeForCategory,
|
|
11258
|
+
OKF_RESERVED_BASENAMES,
|
|
11137
11259
|
selfDeps,
|
|
11138
11260
|
qmdCollectionPathParts,
|
|
11139
11261
|
qmdResultPathCandidates,
|
|
@@ -11175,4 +11297,4 @@ export {
|
|
|
11175
11297
|
isValidBufferSurpriseEvent,
|
|
11176
11298
|
StorageManager3 as StorageManager
|
|
11177
11299
|
};
|
|
11178
|
-
//# sourceMappingURL=chunk-
|
|
11300
|
+
//# sourceMappingURL=chunk-2QI2JBLQ.js.map
|