@remnic/core 9.65.2 → 9.65.4
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 +44 -44
- package/dist/access-admin-ops-surface.js +21 -19
- package/dist/access-authorization-probe.d.ts +38 -38
- package/dist/access-authorization-probe.js +22 -20
- package/dist/access-boundary.d.ts +40 -40
- package/dist/access-boundary.js +21 -19
- package/dist/access-cli.js +62 -60
- package/dist/access-cli.js.map +1 -1
- package/dist/access-coding-context-resolution.d.ts +3 -1
- package/dist/access-extraction-force-flush.d.ts +25 -25
- package/dist/access-extraction-force-flush.js +21 -19
- package/dist/access-health-types.d.ts +3 -1
- package/dist/access-http-lcm-compaction.d.ts +39 -39
- package/dist/access-http-lifecycle-flush.d.ts +39 -39
- package/dist/access-http-offline-stream.d.ts +25 -25
- package/dist/access-http-query.d.ts +4 -2
- package/dist/access-http-query.js +23 -21
- package/dist/access-http.d.ts +51 -44
- package/dist/access-http.js +37 -35
- package/dist/access-identity-continuity-surface.d.ts +12 -12
- package/dist/access-identity-continuity-surface.js +21 -19
- package/dist/access-lcm-surface.d.ts +27 -27
- package/dist/access-lcm-surface.js +21 -19
- package/dist/access-mcp-admin-tools.d.ts +9 -1
- package/dist/access-mcp-admin-tools.js +3 -1
- package/dist/access-mcp-output-schemas.js +1 -1
- package/dist/access-mcp.d.ts +39 -39
- package/dist/access-mcp.js +31 -29
- package/dist/access-memory-search-fanout.d.ts +4 -2
- package/dist/{access-namespace-preflight-Dhvcl-T0.d.ts → access-namespace-preflight-D_6mo8ms.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +5 -3
- package/dist/access-namespace-preflight.js +21 -19
- package/dist/access-observe-write-surface.d.ts +39 -39
- package/dist/access-observe-write-surface.js +21 -19
- package/dist/access-offline-manifest.d.ts +12 -12
- package/dist/access-offline-manifest.js +3 -3
- package/dist/access-operations-batch.js +25 -23
- package/dist/access-operations.d.ts +40 -40
- package/dist/access-operations.js +28 -26
- package/dist/access-recall-concurrency.d.ts +40 -40
- package/dist/access-recall-concurrency.js +21 -19
- package/dist/access-recall-response.d.ts +24 -24
- package/dist/access-recall-response.js +21 -19
- package/dist/access-recall-surface.d.ts +24 -24
- package/dist/access-recall-surface.js +21 -19
- package/dist/access-schema.d.ts +45 -45
- package/dist/{access-service-Bke1alZO.d.ts → access-service-DqPa3hy4.d.ts} +219 -75
- package/dist/access-service-helpers.d.ts +40 -40
- package/dist/access-service.d.ts +47 -47
- package/dist/access-service.js +21 -19
- package/dist/access-surface-catalog.d.ts +40 -40
- package/dist/access-surface-catalog.js +27 -21
- package/dist/access-surface-catalog.js.map +1 -1
- package/dist/access-wearables-meetings-surface.d.ts +5 -3
- package/dist/action-confidence.d.ts +3 -1
- package/dist/active-memory-bridge.d.ts +3 -1
- package/dist/active-recall.d.ts +3 -1
- package/dist/active-recall.js +10 -1
- package/dist/active-recall.js.map +1 -1
- package/dist/ambient-provenance.d.ts +3 -1
- package/dist/artifact-search.d.ts +3 -1
- package/dist/{auto-sync-H64ZCNIR.js → auto-sync-XVMLL2RH.js} +5 -5
- package/dist/behavior-learner.d.ts +3 -1
- package/dist/behavior-signals.d.ts +3 -1
- package/dist/bootstrap.d.ts +12 -12
- package/dist/briefing-window.d.ts +4 -2
- package/dist/briefing.d.ts +4 -2
- package/dist/briefing.js +4 -4
- package/dist/buffer-surprise-report.d.ts +3 -1
- package/dist/buffer-turn-helpers.d.ts +3 -1
- package/dist/buffer.d.ts +4 -2
- package/dist/bulk-import/index.d.ts +5 -3
- package/dist/calibration.d.ts +3 -1
- package/dist/capabilities.d.ts +3 -1
- package/dist/{catalog-DV6qnbr7.d.ts → catalog-DO_7zfkv.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-consolidation.d.ts +3 -1
- package/dist/causal-consolidation.js +12 -9
- package/dist/causal-consolidation.js.map +1 -1
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/chunk-236PXYG7.js +232 -0
- package/dist/chunk-236PXYG7.js.map +1 -0
- package/dist/{chunk-YB42WZCY.js → chunk-2IXQSGCU.js} +2 -2
- package/dist/{chunk-PE255F4T.js → chunk-2MVTAIL3.js} +2 -2
- package/dist/{chunk-LGO6A7GJ.js → chunk-3JZBPTLD.js} +338 -80
- package/dist/chunk-3JZBPTLD.js.map +1 -0
- package/dist/{chunk-GDFVPUJ5.js → chunk-3NH3VP3U.js} +2 -2
- package/dist/{chunk-TBOJ76ER.js → chunk-AB3A7EFH.js} +18 -2
- package/dist/{chunk-TBOJ76ER.js.map → chunk-AB3A7EFH.js.map} +1 -1
- package/dist/{chunk-GNCCUR6K.js → chunk-AXGFOFNY.js} +2 -2
- package/dist/{chunk-SB7D4BT7.js → chunk-AZLLH6YA.js} +1554 -114
- package/dist/chunk-AZLLH6YA.js.map +1 -0
- package/dist/{chunk-5YQ63T4B.js → chunk-BK5G2MHO.js} +2 -2
- package/dist/{chunk-LZH5FR2W.js → chunk-CQBIN77D.js} +2 -2
- package/dist/{chunk-35NN3ZFA.js → chunk-CTVWELNK.js} +21 -3
- package/dist/chunk-CTVWELNK.js.map +1 -0
- package/dist/{chunk-NKKD4ZAU.js → chunk-DORFF5N5.js} +2 -2
- package/dist/{chunk-BWLRUMOG.js → chunk-DPNXADEI.js} +441 -2
- package/dist/chunk-DPNXADEI.js.map +1 -0
- package/dist/{chunk-SQI57UCJ.js → chunk-DUEDOYZD.js} +2 -2
- package/dist/{chunk-5NM4OH4P.js → chunk-DUZARALI.js} +3 -3
- package/dist/{chunk-2E36UXVW.js → chunk-ECLJ4LA2.js} +2 -2
- package/dist/{chunk-TZNQUNKL.js → chunk-FC7TIRFS.js} +15 -1
- package/dist/chunk-FC7TIRFS.js.map +1 -0
- package/dist/{chunk-IID2CMUU.js → chunk-GHD2LLG4.js} +2 -2
- package/dist/{chunk-ZQHI2BZB.js → chunk-HF5BUTI6.js} +2 -2
- package/dist/{chunk-3DVBKTSO.js → chunk-HSZMX3ZJ.js} +4 -4
- package/dist/{chunk-S2DPMJXH.js → chunk-I23ZHYSL.js} +2 -2
- package/dist/{chunk-ODZG724P.js → chunk-I2HTKOOP.js} +2 -2
- package/dist/chunk-I32NKXE2.js +879 -0
- package/dist/chunk-I32NKXE2.js.map +1 -0
- package/dist/{chunk-NTWN6HB2.js → chunk-IURMJBGP.js} +2 -2
- package/dist/{chunk-OCZIYAE5.js → chunk-IWKGOCL6.js} +3 -3
- package/dist/{chunk-UXO5IMBK.js → chunk-J3ATBB7M.js} +2 -2
- package/dist/{chunk-Y7DK7HHJ.js → chunk-JPAKBNTM.js} +2 -2
- package/dist/{chunk-SPUJNJJC.js → chunk-KFIOPZ25.js} +2 -2
- package/dist/{chunk-JYYBA7TF.js → chunk-KOO37E4Y.js} +2 -2
- package/dist/{chunk-OTHZWLUD.js → chunk-KPB2QHJZ.js} +2 -2
- package/dist/{chunk-SBDCZ2AX.js → chunk-LBFFNDFM.js} +1 -1
- package/dist/chunk-LBFFNDFM.js.map +1 -0
- package/dist/{chunk-CT56C22C.js → chunk-LYBIHM4N.js} +4 -4
- package/dist/{chunk-3I7ASZN3.js → chunk-MFOSZUIT.js} +2 -2
- package/dist/{chunk-DZUJ46DO.js → chunk-NLEH4RTB.js} +2 -2
- package/dist/{chunk-ZO6AXLEH.js → chunk-OCCHUEZB.js} +2 -2
- package/dist/{chunk-EILZG5VC.js → chunk-OU34IQXV.js} +2 -2
- package/dist/{chunk-2XDWWPTN.js → chunk-OZDFB22S.js} +2 -2
- package/dist/{chunk-UIN2BWDD.js → chunk-PTZQYCJ4.js} +2 -2
- package/dist/{chunk-7BY7V4YX.js → chunk-Q4WONDMJ.js} +4 -3
- package/dist/{chunk-7BY7V4YX.js.map → chunk-Q4WONDMJ.js.map} +1 -1
- package/dist/{chunk-Z7PBQPJ4.js → chunk-QJW4MZSW.js} +2 -2
- package/dist/{chunk-R7JAM2XF.js → chunk-R2MZCYA6.js} +3 -3
- package/dist/{chunk-TF77C7SV.js → chunk-SR5LNI6Q.js} +7 -5
- package/dist/chunk-SR5LNI6Q.js.map +1 -0
- package/dist/{chunk-LBWQ65SX.js → chunk-T42L3S6A.js} +4 -4
- package/dist/{chunk-J275IYMG.js → chunk-THVI4Y7X.js} +34 -7
- package/dist/chunk-THVI4Y7X.js.map +1 -0
- package/dist/{chunk-QOS5LBZN.js → chunk-TJFI3K2O.js} +15 -3
- package/dist/chunk-TJFI3K2O.js.map +1 -0
- package/dist/{chunk-2YI72KM3.js → chunk-UCKG36HO.js} +2 -2
- package/dist/{chunk-SIHSCCUQ.js → chunk-UFR6HX7A.js} +1 -1
- package/dist/{chunk-CDUUDBWJ.js → chunk-VFYRYFLL.js} +2 -2
- package/dist/{chunk-XRYZRW54.js → chunk-WDXD6ITO.js} +2 -2
- package/dist/{chunk-4KYOLI6M.js → chunk-XGM3VQWG.js} +120 -14
- package/dist/chunk-XGM3VQWG.js.map +1 -0
- package/dist/{chunk-MN4KB2A4.js → chunk-YDKF4MSJ.js} +3 -3
- package/dist/{chunk-YLDXWCZP.js → chunk-YHGCT462.js} +14 -9
- package/dist/chunk-YHGCT462.js.map +1 -0
- package/dist/{chunk-7YQ4IYS2.js → chunk-YOXVZJFM.js} +2 -2
- package/dist/{chunk-ZWXJBFZU.js → chunk-YZJM6CLF.js} +8 -8
- package/dist/chunk-ZCUTSMR2.js +61 -0
- package/dist/chunk-ZCUTSMR2.js.map +1 -0
- package/dist/{chunk-LUNJ3WFO.js → chunk-ZK4BFABK.js} +4 -4
- package/dist/{chunk-V3MXUL3D.js → chunk-ZPOHEB5Z.js} +329 -653
- package/dist/chunk-ZPOHEB5Z.js.map +1 -0
- package/dist/{chunk-RDFF2NAU.js → chunk-ZXBTTMGZ.js} +184 -88
- package/dist/chunk-ZXBTTMGZ.js.map +1 -0
- package/dist/{cli-cShQ13XG.d.ts → cli-DO3i14pM.d.ts} +5 -5
- package/dist/cli.d.ts +25 -25
- package/dist/cli.js +51 -48
- package/dist/coding/pre-action-gate.d.ts +2 -60
- package/dist/compounding/engine.d.ts +4 -2
- package/dist/compounding/engine.js +4 -4
- package/dist/compounding/preference-consolidator.d.ts +3 -1
- package/dist/compression-optimizer.d.ts +3 -1
- package/dist/config.d.ts +3 -1
- package/dist/config.js +10 -1
- package/dist/connectors/codex-materialize-runner.d.ts +3 -1
- package/dist/connectors/codex-materialize-runner.js +8 -5
- package/dist/connectors/codex-materialize.d.ts +16 -1
- package/dist/connectors/codex-materialize.js +10 -1
- package/dist/connectors/index.d.ts +3 -1
- package/dist/connectors/index.js +8 -5
- package/dist/consolidation-provenance-check.d.ts +4 -2
- package/dist/consolidation-undo.d.ts +4 -2
- package/dist/contradiction/index.d.ts +10 -270
- package/dist/contradiction/index.js +12 -7
- package/dist/{contradiction-review-QKJH5DKD.js → contradiction-review-WRVLRWHS.js} +6 -2
- package/dist/{contradiction-scan-VOTQRRSX.js → contradiction-scan-AKUWPX5N.js} +5 -3
- package/dist/converge-config.d.ts +3 -1
- package/dist/convergence-refresh.d.ts +4 -2
- package/dist/convergence-refresh.js +6 -6
- package/dist/conversation-index/backend.d.ts +3 -1
- package/dist/conversation-index/chunker.d.ts +3 -1
- package/dist/conversation-index/faiss-adapter.d.ts +3 -1
- package/dist/conversation-index/indexer.d.ts +3 -1
- package/dist/conversation-index/search.d.ts +3 -1
- package/dist/corpus-watermark.d.ts +3 -1
- package/dist/corpus-watermark.js +6 -6
- package/dist/cross-lingual-recall.d.ts +3 -1
- package/dist/day-summary.d.ts +3 -1
- package/dist/delinearize.d.ts +3 -1
- package/dist/dependency-propagation-config.d.ts +3 -1
- package/dist/{dependency-propagation-delivery-CsGg-VwS.d.ts → dependency-propagation-delivery-D23_x-s5.d.ts} +1 -1
- package/dist/direct-answer-wiring.d.ts +3 -1
- package/dist/direct-answer.d.ts +3 -1
- package/dist/embedding-fallback.d.ts +3 -1
- package/dist/enrichment/index.d.ts +3 -1
- package/dist/entity-origin-fields.d.ts +3 -1
- package/dist/entity-retrieval.d.ts +4 -2
- package/dist/entity-retrieval.js +4 -4
- package/dist/entity-schema.d.ts +3 -1
- package/dist/episodic-context.d.ts +3 -1
- package/dist/explicit-capture.d.ts +12 -12
- package/dist/explicit-capture.js +1 -1
- package/dist/external-wiki-access.d.ts +40 -40
- package/dist/external-wiki-access.js +22 -20
- package/dist/external-wiki-collection-registration.d.ts +3 -1
- package/dist/external-wiki-collection.d.ts +3 -1
- package/dist/external-wiki-mcp-tools.d.ts +40 -40
- package/dist/extraction-error-classification.d.ts +3 -1
- package/dist/extraction-faithfulness.d.ts +3 -1
- package/dist/extraction-judge-telemetry.d.ts +3 -1
- package/dist/extraction-judge-training.d.ts +3 -1
- package/dist/extraction-judge.d.ts +3 -1
- package/dist/extraction-judge.js +2 -2
- package/dist/extraction-liveness.d.ts +3 -1
- package/dist/extraction-normalization.d.ts +3 -1
- package/dist/extraction-prompt.d.ts +3 -1
- package/dist/extraction-source-grounding-rules.d.ts +3 -1
- package/dist/extraction-source-grounding.d.ts +3 -1
- package/dist/extraction.d.ts +3 -1
- package/dist/extraction.js +9 -7
- package/dist/fallback-llm.d.ts +3 -1
- package/dist/graph-dashboard-diff.d.ts +3 -1
- package/dist/graph-dashboard-key.d.ts +3 -1
- package/dist/graph-dashboard-parser.d.ts +3 -1
- package/dist/graph-edge-reinforcement.d.ts +3 -1
- package/dist/graph-path-reconstruction.d.ts +3 -1
- package/dist/graph-path-scoring.d.ts +3 -1
- package/dist/graph-snapshot.d.ts +3 -1
- package/dist/graph.d.ts +3 -1
- package/dist/harmonic-retrieval.js +1 -1
- package/dist/importance.d.ts +3 -1
- package/dist/importers/index.d.ts +3 -1
- package/dist/in-flight-reads.d.ts +3 -1
- package/dist/index--QhGIXF2.d.ts +284 -0
- package/dist/index.d.ts +314 -45
- package/dist/index.js +163 -88
- package/dist/intent.d.ts +3 -1
- package/dist/lcm/engine.d.ts +3 -1
- package/dist/lcm/index.d.ts +3 -1
- package/dist/lcm/tools.d.ts +3 -1
- package/dist/lifecycle.d.ts +3 -1
- package/dist/live-connectors-runner.d.ts +3 -1
- package/dist/local-llm.d.ts +3 -1
- package/dist/local-model-endpoint.d.ts +3 -1
- package/dist/maintenance/memory-governance.d.ts +3 -1
- package/dist/maintenance/memory-governance.js +4 -4
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +4 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +4 -4
- package/dist/maintenance/rebuild-memory-projection.d.ts +4 -2
- package/dist/maintenance/rebuild-memory-projection.js +5 -5
- package/dist/{maintenance-jhMpeGne.d.ts → maintenance-PFvY1Pw_.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +37 -37
- package/dist/memory-action-policy.d.ts +3 -1
- package/dist/memory-cache.d.ts +3 -1
- package/dist/memory-lifecycle-ledger-utils.d.ts +3 -1
- package/dist/memory-projection-store.d.ts +3 -1
- package/dist/memory-provenance.d.ts +3 -1
- package/dist/memory-snapshot.d.ts +3 -1
- package/dist/memory-subject-cli.d.ts +40 -40
- package/dist/memory-subject.d.ts +42 -42
- package/dist/memory-worth-outcomes.d.ts +4 -2
- package/dist/models-json.d.ts +3 -1
- package/dist/namespaces/migrate.d.ts +5 -3
- package/dist/namespaces/migrate.js +5 -5
- package/dist/namespaces/principal.d.ts +3 -1
- package/dist/namespaces/search.d.ts +3 -1
- package/dist/namespaces/storage.d.ts +5 -3
- package/dist/namespaces/storage.js +4 -4
- package/dist/native-knowledge.d.ts +3 -1
- package/dist/offline-sync-impression-drain.d.ts +3 -1
- package/dist/operator-doctor-corpus.d.ts +3 -1
- package/dist/operator-doctor-corpus.js +7 -7
- package/dist/operator-doctor-replica.d.ts +3 -1
- package/dist/operator-toolkit.d.ts +5 -3
- package/dist/operator-toolkit.js +19 -13
- package/dist/orchestration/compression-guideline-coordinator.d.ts +4 -2
- package/dist/orchestration/maintenance.d.ts +6 -4
- package/dist/orchestration/maintenance.js +10 -10
- package/dist/{orchestrator-DyGUC7re.d.ts → orchestrator-4wzJrPVm.d.ts} +23 -9
- package/dist/orchestrator.d.ts +12 -12
- package/dist/orchestrator.js +62 -60
- package/dist/patterns-cli.d.ts +3 -1
- package/dist/{pipeline-C25Oxtp1.d.ts → pipeline-CgXgdIrF.d.ts} +1 -1
- package/dist/policy-runtime.d.ts +3 -1
- package/dist/proactive-contention.d.ts +3 -1
- package/dist/provenance.d.ts +3 -1
- package/dist/{public-http-CMe7NQzj.d.ts → public-http-DhIXYBYI.d.ts} +1 -1
- package/dist/{qmd-DkDVCbgF.d.ts → qmd-BppGGxsi.d.ts} +1 -1
- package/dist/qmd-preflight.d.ts +4 -2
- package/dist/qmd-recall-cache.d.ts +3 -1
- package/dist/qmd.d.ts +4 -2
- package/dist/recall-concurrency-config.d.ts +3 -1
- package/dist/recall-disclosure-escalation.d.ts +3 -1
- package/dist/recall-explain-renderer.d.ts +3 -1
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-memory-map.d.ts +3 -1
- package/dist/recall-planner-llm.d.ts +3 -1
- package/dist/recall-state.d.ts +3 -1
- package/dist/recall-tag-filter.d.ts +3 -1
- package/dist/recall-timings.d.ts +3 -1
- package/dist/recall-xray-cli.d.ts +3 -1
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.d.ts +3 -1
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.d.ts +3 -1
- package/dist/recall-xray.js +2 -2
- package/dist/reconcile/cursor.d.ts +3 -1
- package/dist/reconcile/manifest.d.ts +3 -1
- package/dist/reconcile/manifest.js +2 -2
- package/dist/reconcile/plan.d.ts +3 -1
- package/dist/replay/normalizers/chatgpt.d.ts +3 -1
- package/dist/replay/normalizers/claude.d.ts +3 -1
- package/dist/replay/normalizers/openclaw.d.ts +3 -1
- package/dist/replay/normalizers/shared.d.ts +3 -1
- package/dist/replay/runner.d.ts +3 -1
- package/dist/replay/types.d.ts +3 -1
- package/dist/replica-divergence.d.ts +3 -1
- package/dist/replica-peers-config.d.ts +3 -1
- package/dist/{resolution-MFY72STR.js → resolution-4552BNRV.js} +14 -4
- package/dist/resolve-auth-token.d.ts +3 -1
- package/dist/resume-bundles.js +8 -2
- package/dist/retrieval-agents.d.ts +4 -2
- package/dist/retrieval-tiers.d.ts +3 -1
- package/dist/routing/engine.d.ts +3 -1
- package/dist/routing/store.d.ts +3 -1
- package/dist/salvage-envelope.d.ts +3 -1
- package/dist/salvage-envelope.js +1 -1
- package/dist/schemas.d.ts +44 -44
- package/dist/{scope-profiles-B9xMoFO-.d.ts → scope-profiles-ChZUtxDU.d.ts} +1 -1
- package/dist/search/embed-helper.d.ts +3 -1
- package/dist/search/factory.d.ts +3 -1
- package/dist/search/index.d.ts +3 -1
- package/dist/search/lancedb-backend.d.ts +3 -1
- package/dist/search/meilisearch-backend.d.ts +3 -1
- package/dist/search/noop-backend.d.ts +3 -1
- package/dist/search/orama-backend.d.ts +3 -1
- package/dist/search/port.d.ts +3 -1
- package/dist/search/remote-backend.d.ts +3 -1
- package/dist/{semantic-TddhF0y7.d.ts → semantic-BalR6EXU.d.ts} +1 -1
- package/dist/{semantic-consolidation-C4uykW84.d.ts → semantic-consolidation-mSPwQSmF.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +4 -2
- package/dist/semantic-consolidation.js +9 -6
- package/dist/semantic-rule-promotion.js +4 -4
- package/dist/semantic-rule-verifier.d.ts +3 -1
- package/dist/semantic-rule-verifier.js +4 -4
- package/dist/{service-DCZDZNcV.d.ts → service-BICWLwSP.d.ts} +2 -2
- package/dist/session-observer-bands.d.ts +3 -1
- package/dist/session-observer-state.d.ts +3 -1
- package/dist/shared-context/manager.d.ts +3 -1
- package/dist/signal.d.ts +3 -1
- package/dist/skills-registry.js +4 -56
- package/dist/skills-registry.js.map +1 -1
- package/dist/source-agent-qualifier.d.ts +3 -1
- package/dist/source-agent-qualifier.js +8 -5
- package/dist/{storage-CcKmEjL8.d.ts → storage-B7urx1K3.d.ts} +1 -1
- package/dist/storage.d.ts +4 -2
- package/dist/storage.js +6 -6
- package/dist/subject-config.d.ts +3 -1
- package/dist/summarizer.d.ts +3 -1
- package/dist/summary-snapshot.d.ts +3 -1
- package/dist/support-passport/index.d.ts +43 -43
- package/dist/support-passport/index.js +24 -22
- package/dist/temporal-supersession.d.ts +4 -2
- package/dist/temporal-timeline-recall.d.ts +3 -1
- package/dist/temporal-validity.d.ts +3 -1
- package/dist/threading.d.ts +3 -1
- package/dist/tier-migration.d.ts +4 -2
- package/dist/tier-routing.d.ts +3 -1
- package/dist/topics.d.ts +3 -1
- package/dist/transcript.d.ts +3 -1
- package/dist/transfer/types.d.ts +20 -20
- package/dist/trust-score-stage.d.ts +3 -1
- package/dist/trust-score.d.ts +3 -1
- package/dist/{types-Pi0lfaEt.d.ts → types-ETU5N6nB.d.ts} +433 -7
- package/dist/types.d.ts +3 -1
- package/dist/types.js +1 -1
- package/dist/utility-runtime.d.ts +3 -1
- package/dist/verified-recall.js +4 -4
- package/dist/who-knows-cli.d.ts +40 -40
- package/dist/who-knows-cli.js +5 -5
- package/dist/who-knows.d.ts +42 -42
- package/dist/who-knows.js +4 -4
- package/dist/write-envelope.d.ts +3 -1
- package/dist/write-envelope.js +1 -1
- package/package.json +2 -2
- package/src/access-boundary.ts +4 -0
- package/src/access-http.ts +6 -5
- package/src/access-mcp-admin-tools.ts +24 -0
- package/src/access-mcp-output-schemas.ts +14 -0
- package/src/access-mcp.ts +2 -2
- package/src/access-operations-batch.ts +5 -0
- package/src/access-service.ts +27 -0
- package/src/access-surface-catalog.test.ts +24 -0
- package/src/access-surface-catalog.ts +4 -0
- package/src/cli/skills-commands.ts +150 -0
- package/src/cli.ts +4 -2
- package/src/coding/action-gate.test.ts +341 -0
- package/src/coding/action-gate.ts +556 -0
- package/src/config.ts +9 -2
- package/src/connectors/codex-materialize-runner.ts +16 -0
- package/src/connectors/codex-materialize-skills.test.ts +141 -0
- package/src/connectors/codex-materialize.ts +58 -40
- package/src/connectors/materialize-paths.ts +50 -0
- package/src/connectors/materialize-skills.ts +127 -0
- package/src/contradiction/contradiction-review.ts +50 -4
- package/src/contradiction/contradiction-scan.ts +14 -3
- package/src/contradiction/resolution.ts +50 -2
- package/src/index.ts +9 -13
- package/src/orchestration/recall-rerank-coordinator.ts +123 -4
- package/src/orchestration/recall-result-formatter.ts +6 -2
- package/src/orchestration/recall-search-pipeline.ts +14 -1
- package/src/preferences/drift-config.ts +118 -0
- package/src/preferences/drift-recall.ts +133 -0
- package/src/preferences/drift-types.ts +87 -0
- package/src/preferences/index.ts +12 -0
- package/src/preferences/preference-drift.test.ts +690 -0
- package/src/preferences/preference-drift.ts +724 -0
- package/src/procedural/skill-io.test.ts +190 -0
- package/src/procedural/skill-io.ts +220 -0
- package/src/procedural/skill-projection.test.ts +214 -0
- package/src/procedural/skill-projection.ts +356 -0
- package/src/review/review-deck-access.test.ts +325 -0
- package/src/review/review-deck-http-base.ts +133 -0
- package/src/review/review-deck-mutation.test.ts +417 -0
- package/src/review/review-deck-mutation.ts +677 -0
- package/src/review/review-deck-snapshot.ts +196 -0
- package/src/review/review-deck-surface.ts +117 -0
- package/src/review/review-deck.test.ts +347 -0
- package/src/review/review-deck.ts +311 -0
- package/src/storage.ts +4 -6
- package/src/types.ts +9 -6
- package/dist/chunk-35NN3ZFA.js.map +0 -1
- package/dist/chunk-4KYOLI6M.js.map +0 -1
- package/dist/chunk-BWLRUMOG.js.map +0 -1
- package/dist/chunk-J275IYMG.js.map +0 -1
- package/dist/chunk-LGO6A7GJ.js.map +0 -1
- package/dist/chunk-QOS5LBZN.js.map +0 -1
- package/dist/chunk-RDFF2NAU.js.map +0 -1
- package/dist/chunk-SB7D4BT7.js.map +0 -1
- package/dist/chunk-SBDCZ2AX.js.map +0 -1
- package/dist/chunk-TF77C7SV.js.map +0 -1
- package/dist/chunk-TZNQUNKL.js.map +0 -1
- package/dist/chunk-V3MXUL3D.js.map +0 -1
- package/dist/chunk-XCTXS7VY.js +0 -402
- package/dist/chunk-XCTXS7VY.js.map +0 -1
- package/dist/chunk-YLDXWCZP.js.map +0 -1
- /package/dist/{auto-sync-H64ZCNIR.js.map → auto-sync-XVMLL2RH.js.map} +0 -0
- /package/dist/{chunk-YB42WZCY.js.map → chunk-2IXQSGCU.js.map} +0 -0
- /package/dist/{chunk-PE255F4T.js.map → chunk-2MVTAIL3.js.map} +0 -0
- /package/dist/{chunk-GDFVPUJ5.js.map → chunk-3NH3VP3U.js.map} +0 -0
- /package/dist/{chunk-GNCCUR6K.js.map → chunk-AXGFOFNY.js.map} +0 -0
- /package/dist/{chunk-5YQ63T4B.js.map → chunk-BK5G2MHO.js.map} +0 -0
- /package/dist/{chunk-LZH5FR2W.js.map → chunk-CQBIN77D.js.map} +0 -0
- /package/dist/{chunk-NKKD4ZAU.js.map → chunk-DORFF5N5.js.map} +0 -0
- /package/dist/{chunk-SQI57UCJ.js.map → chunk-DUEDOYZD.js.map} +0 -0
- /package/dist/{chunk-5NM4OH4P.js.map → chunk-DUZARALI.js.map} +0 -0
- /package/dist/{chunk-2E36UXVW.js.map → chunk-ECLJ4LA2.js.map} +0 -0
- /package/dist/{chunk-IID2CMUU.js.map → chunk-GHD2LLG4.js.map} +0 -0
- /package/dist/{chunk-ZQHI2BZB.js.map → chunk-HF5BUTI6.js.map} +0 -0
- /package/dist/{chunk-3DVBKTSO.js.map → chunk-HSZMX3ZJ.js.map} +0 -0
- /package/dist/{chunk-S2DPMJXH.js.map → chunk-I23ZHYSL.js.map} +0 -0
- /package/dist/{chunk-ODZG724P.js.map → chunk-I2HTKOOP.js.map} +0 -0
- /package/dist/{chunk-NTWN6HB2.js.map → chunk-IURMJBGP.js.map} +0 -0
- /package/dist/{chunk-OCZIYAE5.js.map → chunk-IWKGOCL6.js.map} +0 -0
- /package/dist/{chunk-UXO5IMBK.js.map → chunk-J3ATBB7M.js.map} +0 -0
- /package/dist/{chunk-Y7DK7HHJ.js.map → chunk-JPAKBNTM.js.map} +0 -0
- /package/dist/{chunk-SPUJNJJC.js.map → chunk-KFIOPZ25.js.map} +0 -0
- /package/dist/{chunk-JYYBA7TF.js.map → chunk-KOO37E4Y.js.map} +0 -0
- /package/dist/{chunk-OTHZWLUD.js.map → chunk-KPB2QHJZ.js.map} +0 -0
- /package/dist/{chunk-CT56C22C.js.map → chunk-LYBIHM4N.js.map} +0 -0
- /package/dist/{chunk-3I7ASZN3.js.map → chunk-MFOSZUIT.js.map} +0 -0
- /package/dist/{chunk-DZUJ46DO.js.map → chunk-NLEH4RTB.js.map} +0 -0
- /package/dist/{chunk-ZO6AXLEH.js.map → chunk-OCCHUEZB.js.map} +0 -0
- /package/dist/{chunk-EILZG5VC.js.map → chunk-OU34IQXV.js.map} +0 -0
- /package/dist/{chunk-2XDWWPTN.js.map → chunk-OZDFB22S.js.map} +0 -0
- /package/dist/{chunk-UIN2BWDD.js.map → chunk-PTZQYCJ4.js.map} +0 -0
- /package/dist/{chunk-Z7PBQPJ4.js.map → chunk-QJW4MZSW.js.map} +0 -0
- /package/dist/{chunk-R7JAM2XF.js.map → chunk-R2MZCYA6.js.map} +0 -0
- /package/dist/{chunk-LBWQ65SX.js.map → chunk-T42L3S6A.js.map} +0 -0
- /package/dist/{chunk-2YI72KM3.js.map → chunk-UCKG36HO.js.map} +0 -0
- /package/dist/{chunk-SIHSCCUQ.js.map → chunk-UFR6HX7A.js.map} +0 -0
- /package/dist/{chunk-CDUUDBWJ.js.map → chunk-VFYRYFLL.js.map} +0 -0
- /package/dist/{chunk-XRYZRW54.js.map → chunk-WDXD6ITO.js.map} +0 -0
- /package/dist/{chunk-MN4KB2A4.js.map → chunk-YDKF4MSJ.js.map} +0 -0
- /package/dist/{chunk-7YQ4IYS2.js.map → chunk-YOXVZJFM.js.map} +0 -0
- /package/dist/{chunk-ZWXJBFZU.js.map → chunk-YZJM6CLF.js.map} +0 -0
- /package/dist/{chunk-LUNJ3WFO.js.map → chunk-ZK4BFABK.js.map} +0 -0
- /package/dist/{contradiction-review-QKJH5DKD.js.map → contradiction-review-WRVLRWHS.js.map} +0 -0
- /package/dist/{contradiction-scan-VOTQRRSX.js.map → contradiction-scan-AKUWPX5N.js.map} +0 -0
- /package/dist/{resolution-MFY72STR.js.map → resolution-4552BNRV.js.map} +0 -0
|
@@ -6,14 +6,14 @@ import {
|
|
|
6
6
|
loadSyncState,
|
|
7
7
|
syncWearableSource,
|
|
8
8
|
wearableSourceLabel
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-VFYRYFLL.js";
|
|
10
10
|
import {
|
|
11
11
|
CompressionGuidelineCoordinator
|
|
12
12
|
} from "./chunk-UXREWVW4.js";
|
|
13
13
|
import {
|
|
14
14
|
ActivityStore,
|
|
15
15
|
MaintenanceScheduler
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-LYBIHM4N.js";
|
|
17
17
|
import {
|
|
18
18
|
runPeerProfileReasoner
|
|
19
19
|
} from "./chunk-I74SUMNI.js";
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
import {
|
|
33
33
|
CompoundingEngine,
|
|
34
34
|
defaultTierMigrationCycleBudget
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-UCKG36HO.js";
|
|
36
36
|
import {
|
|
37
37
|
SharedContextManager
|
|
38
38
|
} from "./chunk-VI637ILW.js";
|
|
@@ -160,7 +160,7 @@ import {
|
|
|
160
160
|
} from "./chunk-OH7QLI6W.js";
|
|
161
161
|
import {
|
|
162
162
|
ExtractionEngine
|
|
163
|
-
} from "./chunk-
|
|
163
|
+
} from "./chunk-ZK4BFABK.js";
|
|
164
164
|
import {
|
|
165
165
|
parseMemoryActionEligibilityContext
|
|
166
166
|
} from "./chunk-7BDZTALN.js";
|
|
@@ -176,7 +176,7 @@ import {
|
|
|
176
176
|
getVerdictKind,
|
|
177
177
|
judgeFactDurability,
|
|
178
178
|
validateProcedureExtraction
|
|
179
|
-
} from "./chunk-
|
|
179
|
+
} from "./chunk-HSZMX3ZJ.js";
|
|
180
180
|
import {
|
|
181
181
|
buildExplicitCueRecallSection
|
|
182
182
|
} from "./chunk-TVIVY7KU.js";
|
|
@@ -184,7 +184,7 @@ import {
|
|
|
184
184
|
buildEntityRecallSection,
|
|
185
185
|
entityRecentTranscriptLookbackHours,
|
|
186
186
|
readRecentEntityTranscriptEntries
|
|
187
|
-
} from "./chunk-
|
|
187
|
+
} from "./chunk-NLEH4RTB.js";
|
|
188
188
|
import {
|
|
189
189
|
planEpisodeWindowsWithFallback
|
|
190
190
|
} from "./chunk-T3GIETKV.js";
|
|
@@ -209,14 +209,14 @@ import {
|
|
|
209
209
|
} from "./chunk-VY47VI2T.js";
|
|
210
210
|
import {
|
|
211
211
|
refreshConvergedNamespaces
|
|
212
|
-
} from "./chunk-
|
|
212
|
+
} from "./chunk-JPAKBNTM.js";
|
|
213
213
|
import {
|
|
214
214
|
builtInConnectorPackageSpecifier,
|
|
215
215
|
ensureBuiltInWearableConnectors,
|
|
216
216
|
getWearableConnector,
|
|
217
217
|
listWearableConnectors,
|
|
218
218
|
screenCandidateFact
|
|
219
|
-
} from "./chunk-
|
|
219
|
+
} from "./chunk-3JZBPTLD.js";
|
|
220
220
|
import {
|
|
221
221
|
RoutingRulesStore
|
|
222
222
|
} from "./chunk-TBUEE7XF.js";
|
|
@@ -226,14 +226,14 @@ import {
|
|
|
226
226
|
import {
|
|
227
227
|
compareVerifiedEpisodeResults,
|
|
228
228
|
searchVerifiedEpisodes
|
|
229
|
-
} from "./chunk-
|
|
229
|
+
} from "./chunk-ECLJ4LA2.js";
|
|
230
230
|
import {
|
|
231
231
|
ThreadingManager
|
|
232
232
|
} from "./chunk-OJP3N7UK.js";
|
|
233
233
|
import {
|
|
234
234
|
compareVerifiedSemanticRuleResults,
|
|
235
235
|
searchVerifiedSemanticRules
|
|
236
|
-
} from "./chunk-
|
|
236
|
+
} from "./chunk-OCCHUEZB.js";
|
|
237
237
|
import {
|
|
238
238
|
searchWorkProductLedgerEntries
|
|
239
239
|
} from "./chunk-NRLELHAY.js";
|
|
@@ -246,13 +246,13 @@ import {
|
|
|
246
246
|
import {
|
|
247
247
|
runNamespaceMaintenanceFanout,
|
|
248
248
|
summarizeNamespaceMaintenanceHealth
|
|
249
|
-
} from "./chunk-
|
|
249
|
+
} from "./chunk-YZJM6CLF.js";
|
|
250
250
|
import {
|
|
251
251
|
planNamespaceMaintenance
|
|
252
|
-
} from "./chunk-
|
|
252
|
+
} from "./chunk-YDKF4MSJ.js";
|
|
253
253
|
import {
|
|
254
254
|
searchHarmonicRetrieval
|
|
255
|
-
} from "./chunk-
|
|
255
|
+
} from "./chunk-UFR6HX7A.js";
|
|
256
256
|
import {
|
|
257
257
|
isAboveImportanceThreshold,
|
|
258
258
|
scoreImportance
|
|
@@ -287,7 +287,7 @@ import {
|
|
|
287
287
|
materializeAfterSemanticConsolidation,
|
|
288
288
|
parseConsolidationResponse,
|
|
289
289
|
parseOperatorAwareConsolidationResponse
|
|
290
|
-
} from "./chunk-
|
|
290
|
+
} from "./chunk-HF5BUTI6.js";
|
|
291
291
|
import {
|
|
292
292
|
BootstrapEngine
|
|
293
293
|
} from "./chunk-MYVPLJOO.js";
|
|
@@ -305,7 +305,7 @@ import {
|
|
|
305
305
|
} from "./chunk-6TBIWIAG.js";
|
|
306
306
|
import {
|
|
307
307
|
detectMeetings
|
|
308
|
-
} from "./chunk-
|
|
308
|
+
} from "./chunk-DPNXADEI.js";
|
|
309
309
|
import {
|
|
310
310
|
compileCorrectionRule,
|
|
311
311
|
correctionsFilePath,
|
|
@@ -330,14 +330,14 @@ import {
|
|
|
330
330
|
} from "./chunk-KD3QD3A5.js";
|
|
331
331
|
import {
|
|
332
332
|
MeetingsInputError
|
|
333
|
-
} from "./chunk-
|
|
333
|
+
} from "./chunk-XGM3VQWG.js";
|
|
334
334
|
import {
|
|
335
335
|
WearablesInputError,
|
|
336
336
|
describeErrorForOperator
|
|
337
337
|
} from "./chunk-V7IZKJI3.js";
|
|
338
338
|
import {
|
|
339
339
|
NamespaceCatalog
|
|
340
|
-
} from "./chunk-
|
|
340
|
+
} from "./chunk-DUEDOYZD.js";
|
|
341
341
|
import {
|
|
342
342
|
recordDreamsPhaseRun
|
|
343
343
|
} from "./chunk-EQWEIIKQ.js";
|
|
@@ -354,7 +354,7 @@ import {
|
|
|
354
354
|
filterRecallCandidates,
|
|
355
355
|
isGenericRecallExcludedPath,
|
|
356
356
|
isTopLevelArchivePath
|
|
357
|
-
} from "./chunk-
|
|
357
|
+
} from "./chunk-AZLLH6YA.js";
|
|
358
358
|
import {
|
|
359
359
|
importCapsule
|
|
360
360
|
} from "./chunk-6433HV72.js";
|
|
@@ -380,7 +380,7 @@ import {
|
|
|
380
380
|
} from "./chunk-ZVZHG7AI.js";
|
|
381
381
|
import {
|
|
382
382
|
buildXraySnapshot
|
|
383
|
-
} from "./chunk-
|
|
383
|
+
} from "./chunk-MFOSZUIT.js";
|
|
384
384
|
import {
|
|
385
385
|
objectiveStateStoreOverrideForNamespace,
|
|
386
386
|
searchObjectiveStateSnapshots
|
|
@@ -395,9 +395,6 @@ import {
|
|
|
395
395
|
import {
|
|
396
396
|
LocalLlmClient
|
|
397
397
|
} from "./chunk-IVKIODHO.js";
|
|
398
|
-
import {
|
|
399
|
-
buildProcedurePersistBody
|
|
400
|
-
} from "./chunk-QDW3E4RD.js";
|
|
401
398
|
import {
|
|
402
399
|
shouldSkipImplicitExtraction
|
|
403
400
|
} from "./chunk-7BEPVIH3.js";
|
|
@@ -411,7 +408,7 @@ import {
|
|
|
411
408
|
} from "./chunk-7ZNJN5WZ.js";
|
|
412
409
|
import {
|
|
413
410
|
NamespaceStorageRouter
|
|
414
|
-
} from "./chunk-
|
|
411
|
+
} from "./chunk-CQBIN77D.js";
|
|
415
412
|
import {
|
|
416
413
|
GraphIndex
|
|
417
414
|
} from "./chunk-BIJAWZYW.js";
|
|
@@ -462,12 +459,9 @@ import {
|
|
|
462
459
|
isTaskInitiationIntent,
|
|
463
460
|
planRecallMode
|
|
464
461
|
} from "./chunk-CSAKJVXW.js";
|
|
465
|
-
import {
|
|
466
|
-
searchCausalTrajectories
|
|
467
|
-
} from "./chunk-PP7R754B.js";
|
|
468
462
|
import {
|
|
469
463
|
buildChainFollowupGenerator
|
|
470
|
-
} from "./chunk-
|
|
464
|
+
} from "./chunk-IURMJBGP.js";
|
|
471
465
|
import {
|
|
472
466
|
QmdResultResolver,
|
|
473
467
|
StorageManager,
|
|
@@ -486,7 +480,7 @@ import {
|
|
|
486
480
|
reconstructFusionInputs,
|
|
487
481
|
selfDeps,
|
|
488
482
|
serializeFusionDay
|
|
489
|
-
} from "./chunk-
|
|
483
|
+
} from "./chunk-THVI4Y7X.js";
|
|
490
484
|
import {
|
|
491
485
|
bodyIsEscaped,
|
|
492
486
|
decodeTranscriptBody,
|
|
@@ -522,7 +516,7 @@ import {
|
|
|
522
516
|
} from "./chunk-S2V7RUCL.js";
|
|
523
517
|
import {
|
|
524
518
|
confidenceTier
|
|
525
|
-
} from "./chunk-
|
|
519
|
+
} from "./chunk-LBFFNDFM.js";
|
|
526
520
|
import {
|
|
527
521
|
lintWorkspaceFiles,
|
|
528
522
|
rotateMarkdownFileToArchive
|
|
@@ -590,6 +584,12 @@ import {
|
|
|
590
584
|
import {
|
|
591
585
|
assertExternalWikiRootOutsideMemoryDirCanonical
|
|
592
586
|
} from "./chunk-JV3C2MNQ.js";
|
|
587
|
+
import {
|
|
588
|
+
buildProcedurePersistBody
|
|
589
|
+
} from "./chunk-QDW3E4RD.js";
|
|
590
|
+
import {
|
|
591
|
+
searchCausalTrajectories
|
|
592
|
+
} from "./chunk-PP7R754B.js";
|
|
593
593
|
import {
|
|
594
594
|
evaluateSubjectGuard,
|
|
595
595
|
isSharedPromotionTarget,
|
|
@@ -650,13 +650,13 @@ import {
|
|
|
650
650
|
excludeSupportPassportPrivateMemories,
|
|
651
651
|
isSupportPassportPrivateMemory
|
|
652
652
|
} from "./chunk-XDL5CYZN.js";
|
|
653
|
+
import {
|
|
654
|
+
ContentHashIndex
|
|
655
|
+
} from "./chunk-JOEJG4SD.js";
|
|
653
656
|
import {
|
|
654
657
|
normalizeAttributePairs,
|
|
655
658
|
stripAttributesSuffix
|
|
656
659
|
} from "./chunk-JDSVLVCG.js";
|
|
657
|
-
import {
|
|
658
|
-
ContentHashIndex
|
|
659
|
-
} from "./chunk-JOEJG4SD.js";
|
|
660
660
|
import {
|
|
661
661
|
sanitizeMemoryContent
|
|
662
662
|
} from "./chunk-5GKPFL3S.js";
|
|
@@ -2061,6 +2061,49 @@ ${body}
|
|
|
2061
2061
|
}
|
|
2062
2062
|
};
|
|
2063
2063
|
|
|
2064
|
+
// src/preferences/drift-recall.ts
|
|
2065
|
+
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
2066
|
+
function isPreferenceDriftStageActive(config) {
|
|
2067
|
+
if (!config) return false;
|
|
2068
|
+
const damping = config.recallDamping && config.stalePenalty < 1;
|
|
2069
|
+
return damping || config.annotateAfterDays > 0;
|
|
2070
|
+
}
|
|
2071
|
+
function driftAgeNote(frontmatter, config, now) {
|
|
2072
|
+
if (config.annotateAfterDays <= 0) return void 0;
|
|
2073
|
+
if (!frontmatter || frontmatter.category !== "preference") return void 0;
|
|
2074
|
+
const anchor = frontmatter.lastCorroborated ?? frontmatter.created;
|
|
2075
|
+
if (typeof anchor !== "string") return void 0;
|
|
2076
|
+
const anchorMs = Date.parse(anchor);
|
|
2077
|
+
if (!Number.isFinite(anchorMs)) return void 0;
|
|
2078
|
+
const ageDays = Math.floor((now.getTime() - anchorMs) / DAY_MS);
|
|
2079
|
+
if (ageDays < config.annotateAfterDays) return void 0;
|
|
2080
|
+
const stated = new Date(anchorMs).toISOString().slice(0, 7);
|
|
2081
|
+
return frontmatter.lastCorroborated ? `(corroborated ${stated}; not since)` : `(stated ${stated}; not corroborated since)`;
|
|
2082
|
+
}
|
|
2083
|
+
function applyPreferenceDriftRanking(inputs, options) {
|
|
2084
|
+
const { config, now } = options;
|
|
2085
|
+
const damping = config.recallDamping && config.stalePenalty < 1;
|
|
2086
|
+
const scored = inputs.map((input, index) => {
|
|
2087
|
+
const fm = input.frontmatter;
|
|
2088
|
+
const isStalePreference = fm?.category === "preference" && fm.driftState === "stale";
|
|
2089
|
+
const multiplier = damping && isStalePreference ? config.stalePenalty : 1;
|
|
2090
|
+
return {
|
|
2091
|
+
key: input.key,
|
|
2092
|
+
index,
|
|
2093
|
+
multiplier,
|
|
2094
|
+
damped: input.rank * multiplier,
|
|
2095
|
+
note: driftAgeNote(fm, config, now)
|
|
2096
|
+
};
|
|
2097
|
+
});
|
|
2098
|
+
scored.sort((a, b) => {
|
|
2099
|
+
if (a.damped !== b.damped) return a.damped > b.damped ? -1 : 1;
|
|
2100
|
+
if (a.index !== b.index) return a.index < b.index ? -1 : 1;
|
|
2101
|
+
if (a.key !== b.key) return a.key < b.key ? -1 : 1;
|
|
2102
|
+
return 0;
|
|
2103
|
+
});
|
|
2104
|
+
return scored.map((s) => s.note ? { key: s.key, multiplier: s.multiplier, note: s.note } : { key: s.key, multiplier: s.multiplier });
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2064
2107
|
// src/orchestration/recall-rerank-coordinator.ts
|
|
2065
2108
|
function reconcileRecallResultPartition(partition, appliedResults) {
|
|
2066
2109
|
return partition ? { appliedResults, headroomResults: partition.headroomResults } : null;
|
|
@@ -2260,7 +2303,7 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
|
|
|
2260
2303
|
namespaces,
|
|
2261
2304
|
{
|
|
2262
2305
|
readNamespaceMemories: async (ns) => (await this.getStorage(ns)).readAllMemories(),
|
|
2263
|
-
readMemoryFrontmatter: async (
|
|
2306
|
+
readMemoryFrontmatter: async (path34, preferredNamespace) => {
|
|
2264
2307
|
if (!fallbackReader) {
|
|
2265
2308
|
for (const ns of namespaces) {
|
|
2266
2309
|
try {
|
|
@@ -2272,7 +2315,7 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
|
|
|
2272
2315
|
}
|
|
2273
2316
|
if (!fallbackReader) return null;
|
|
2274
2317
|
const memory = await this.readQmdResultMemory(
|
|
2275
|
-
|
|
2318
|
+
path34,
|
|
2276
2319
|
fallbackReader,
|
|
2277
2320
|
namespaces,
|
|
2278
2321
|
preferredNamespace
|
|
@@ -2337,9 +2380,13 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
|
|
|
2337
2380
|
* errors so a storage hiccup never breaks a fallback path.
|
|
2338
2381
|
*/
|
|
2339
2382
|
async applyTrustScoreToBranch(results, namespaces, caps, label, preloadedFrontmatter, abortSignal) {
|
|
2383
|
+
let staged = results;
|
|
2384
|
+
let trustByPath = null;
|
|
2340
2385
|
if (caps.recallTrustScore && results.length > 0) {
|
|
2341
2386
|
try {
|
|
2342
|
-
|
|
2387
|
+
const outcome = await this.applyTrustScoreRerank(results, namespaces, preloadedFrontmatter, abortSignal);
|
|
2388
|
+
staged = outcome.results;
|
|
2389
|
+
trustByPath = outcome.trustByPath;
|
|
2343
2390
|
} catch (err) {
|
|
2344
2391
|
log.debug(`trust-score stage (${label}) failed open`, {
|
|
2345
2392
|
error: err.message
|
|
@@ -2347,20 +2394,106 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
|
|
|
2347
2394
|
}
|
|
2348
2395
|
} else if (caps.recallMemoryWorthFilter && results.length > 0) {
|
|
2349
2396
|
try {
|
|
2350
|
-
|
|
2397
|
+
staged = await this.applyMemoryWorthRerank(
|
|
2351
2398
|
results,
|
|
2352
2399
|
namespaces,
|
|
2353
2400
|
preloadedFrontmatter,
|
|
2354
2401
|
abortSignal
|
|
2355
2402
|
);
|
|
2356
|
-
return { results: filtered, trustByPath: null };
|
|
2357
2403
|
} catch (err) {
|
|
2358
2404
|
log.debug(`memory-worth filter (${label}) failed open`, {
|
|
2359
2405
|
error: err.message
|
|
2360
2406
|
});
|
|
2361
2407
|
}
|
|
2362
2408
|
}
|
|
2363
|
-
|
|
2409
|
+
const damped = await this.applyPreferenceDriftStage(
|
|
2410
|
+
staged,
|
|
2411
|
+
namespaces,
|
|
2412
|
+
preloadedFrontmatter,
|
|
2413
|
+
abortSignal
|
|
2414
|
+
);
|
|
2415
|
+
return { results: damped, trustByPath };
|
|
2416
|
+
}
|
|
2417
|
+
/**
|
|
2418
|
+
* Issue #2371 — stale-preference damping + injection annotation.
|
|
2419
|
+
*
|
|
2420
|
+
* Runs immediately after the trust/Memory-Worth stage on EVERY recall branch
|
|
2421
|
+
* (hot QMD, embedding fallback, recent scan, cold fallback), so the feature
|
|
2422
|
+
* gate applies uniformly and fallback parity holds (§27, AGENTS.md retrieval
|
|
2423
|
+
* guardrails). Fully inert on the default config: when neither damping nor
|
|
2424
|
+
* annotation is active the input array is returned untouched and NO
|
|
2425
|
+
* frontmatter is read, so recall ordering and injected text stay
|
|
2426
|
+
* byte-identical to pre-#2371.
|
|
2427
|
+
*
|
|
2428
|
+
* Fail-open: any lookup error leaves the branch's results unchanged.
|
|
2429
|
+
*/
|
|
2430
|
+
async applyPreferenceDriftStage(results, namespaces, preloadedFrontmatter, abortSignal) {
|
|
2431
|
+
const config = this.getConfig();
|
|
2432
|
+
if (!isPreferenceDriftStageActive(config.driftDetection)) return results;
|
|
2433
|
+
if (results.length === 0) return results;
|
|
2434
|
+
try {
|
|
2435
|
+
const frontmatterByKey = /* @__PURE__ */ new Map();
|
|
2436
|
+
const missing = [];
|
|
2437
|
+
for (const r of results) {
|
|
2438
|
+
const key = memoryMapKey(r);
|
|
2439
|
+
const preloaded = preloadedFrontmatter?.get(key) ?? preloadedFrontmatter?.get(r.path);
|
|
2440
|
+
if (preloaded) {
|
|
2441
|
+
frontmatterByKey.set(key, preloaded.frontmatter);
|
|
2442
|
+
} else {
|
|
2443
|
+
missing.push(r);
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
if (missing.length > 0) {
|
|
2447
|
+
let reader = null;
|
|
2448
|
+
for (const ns of namespaces) {
|
|
2449
|
+
try {
|
|
2450
|
+
reader = await this.getStorage(ns);
|
|
2451
|
+
break;
|
|
2452
|
+
} catch {
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
if (reader) {
|
|
2456
|
+
const readerNn = reader;
|
|
2457
|
+
const BATCH = 16;
|
|
2458
|
+
for (let off = 0; off < missing.length; off += BATCH) {
|
|
2459
|
+
if (abortSignal?.aborted) break;
|
|
2460
|
+
await Promise.all(
|
|
2461
|
+
missing.slice(off, off + BATCH).map(async (r) => {
|
|
2462
|
+
try {
|
|
2463
|
+
const memory = await this.readQmdResultMemory(r.path, readerNn, namespaces, r.namespace);
|
|
2464
|
+
if (memory) frontmatterByKey.set(memoryMapKey(r), memory.frontmatter);
|
|
2465
|
+
} catch (err) {
|
|
2466
|
+
log.debug("preference-drift: direct path lookup failed", {
|
|
2467
|
+
path: r.path,
|
|
2468
|
+
error: err.message
|
|
2469
|
+
});
|
|
2470
|
+
}
|
|
2471
|
+
})
|
|
2472
|
+
);
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
const ranked = results.map((r, i) => ({
|
|
2477
|
+
key: memoryMapKey(r),
|
|
2478
|
+
rank: results.length - i,
|
|
2479
|
+
frontmatter: frontmatterByKey.get(memoryMapKey(r))
|
|
2480
|
+
}));
|
|
2481
|
+
const ordered = applyPreferenceDriftRanking(ranked, {
|
|
2482
|
+
config: config.driftDetection,
|
|
2483
|
+
now: /* @__PURE__ */ new Date()
|
|
2484
|
+
});
|
|
2485
|
+
const byKey = new Map(results.map((r) => [memoryMapKey(r), r]));
|
|
2486
|
+
const reordered = [];
|
|
2487
|
+
for (const item of ordered) {
|
|
2488
|
+
const original = byKey.get(item.key);
|
|
2489
|
+
if (!original) continue;
|
|
2490
|
+
reordered.push(item.note ? { ...original, driftNote: item.note } : original);
|
|
2491
|
+
}
|
|
2492
|
+
return reordered;
|
|
2493
|
+
} catch (err) {
|
|
2494
|
+
log.debug("preference-drift stage failed open", { error: err.message });
|
|
2495
|
+
return results;
|
|
2496
|
+
}
|
|
2364
2497
|
}
|
|
2365
2498
|
diversifyRecallResultsWithHeadroom(sectionId, results, limit, retrievalQuery, caps = resolveCapabilities(this.getConfig())) {
|
|
2366
2499
|
const safeLimit = typeof limit === "number" && Number.isFinite(limit) ? Math.max(0, Math.floor(limit)) : 0;
|
|
@@ -13491,6 +13624,13 @@ var RecallSearchPipelineCoordinator = class {
|
|
|
13491
13624
|
});
|
|
13492
13625
|
}
|
|
13493
13626
|
}
|
|
13627
|
+
if (results.length > 0) {
|
|
13628
|
+
results = await this.deps.recallRerankCoordinator.applyPreferenceDriftStage(
|
|
13629
|
+
results,
|
|
13630
|
+
options.recallNamespaces,
|
|
13631
|
+
boostInput.memoryByPath
|
|
13632
|
+
);
|
|
13633
|
+
}
|
|
13494
13634
|
if (options.xrayPoolSizeSink) {
|
|
13495
13635
|
options.xrayPoolSizeSink.size = Math.max(
|
|
13496
13636
|
options.xrayPoolSizeSink.size,
|
|
@@ -15512,7 +15652,7 @@ var OrchestratorInitCoordinator = class {
|
|
|
15512
15652
|
if (signal.aborted) return;
|
|
15513
15653
|
if (!this.deps.wearablesAutoSyncHandle && this.deps.config.wearables.enabled && this.deps.config.wearables.autoSyncEnabled && Object.values(this.deps.config.wearables.sources).some((source) => source.enabled)) {
|
|
15514
15654
|
try {
|
|
15515
|
-
const { startWearablesAutoSync } = await import("./auto-sync-
|
|
15655
|
+
const { startWearablesAutoSync } = await import("./auto-sync-XVMLL2RH.js");
|
|
15516
15656
|
if (signal.aborted) return;
|
|
15517
15657
|
this.deps.wearablesAutoSyncHandle = startWearablesAutoSync(
|
|
15518
15658
|
{
|
|
@@ -22158,9 +22298,9 @@ function readStructuralSymbol(entry) {
|
|
|
22158
22298
|
const rec = entry;
|
|
22159
22299
|
const symbol = typeof rec.symbol === "string" ? rec.symbol.trim() : "";
|
|
22160
22300
|
if (!symbol) return null;
|
|
22161
|
-
const
|
|
22301
|
+
const path34 = typeof rec.path === "string" && rec.path.length > 0 ? rec.path : void 0;
|
|
22162
22302
|
const kind = typeof rec.kind === "string" && rec.kind.length > 0 ? rec.kind : void 0;
|
|
22163
|
-
const item =
|
|
22303
|
+
const item = path34 !== void 0 && kind !== void 0 ? { symbol, path: path34, kind } : path34 !== void 0 ? { symbol, path: path34 } : kind !== void 0 ? { symbol, kind } : { symbol };
|
|
22164
22304
|
return item;
|
|
22165
22305
|
}
|
|
22166
22306
|
function classifySpawnError(err) {
|
|
@@ -24431,474 +24571,9 @@ function walkMdFiles(dir, memoryRootReal, categoryRootReal, callback) {
|
|
|
24431
24571
|
}
|
|
24432
24572
|
}
|
|
24433
24573
|
|
|
24434
|
-
// src/
|
|
24574
|
+
// src/sync/index.ts
|
|
24435
24575
|
import fs5 from "fs";
|
|
24436
24576
|
import path29 from "path";
|
|
24437
|
-
var historicalIdCache3 = new HistoricalEntityCanonicalIdCache();
|
|
24438
|
-
function writeReviewFileCanonicalized(memoryDir, filePath, content) {
|
|
24439
|
-
const stateDir = path29.join(memoryDir, "state");
|
|
24440
|
-
const idsAtWrite = historicalIdCache3.get(stateDir);
|
|
24441
|
-
let originalBytes = null;
|
|
24442
|
-
try {
|
|
24443
|
-
originalBytes = fs5.readFileSync(filePath, "utf8");
|
|
24444
|
-
} catch {
|
|
24445
|
-
originalBytes = null;
|
|
24446
|
-
}
|
|
24447
|
-
const written = canonicalizeEntityRefFrontmatter(content, idsAtWrite);
|
|
24448
|
-
fs5.writeFileSync(filePath, written, "utf8");
|
|
24449
|
-
try {
|
|
24450
|
-
repairContentAfterJournalMoveSync({
|
|
24451
|
-
stateDir,
|
|
24452
|
-
cache: historicalIdCache3,
|
|
24453
|
-
idsAtWrite,
|
|
24454
|
-
rawContent: content,
|
|
24455
|
-
lastWritten: written,
|
|
24456
|
-
rewrite: (next) => fs5.writeFileSync(filePath, next, "utf8")
|
|
24457
|
-
});
|
|
24458
|
-
} catch (err) {
|
|
24459
|
-
try {
|
|
24460
|
-
if (originalBytes === null) {
|
|
24461
|
-
fs5.unlinkSync(filePath);
|
|
24462
|
-
} else {
|
|
24463
|
-
fs5.writeFileSync(filePath, originalBytes, "utf8");
|
|
24464
|
-
}
|
|
24465
|
-
} catch {
|
|
24466
|
-
}
|
|
24467
|
-
throw err;
|
|
24468
|
-
}
|
|
24469
|
-
}
|
|
24470
|
-
var DEFAULT_CONFIDENCE_THRESHOLD = 0.7;
|
|
24471
|
-
function realMemoryRoot(memoryDir) {
|
|
24472
|
-
try {
|
|
24473
|
-
const stat5 = fs5.lstatSync(memoryDir);
|
|
24474
|
-
if (!stat5.isDirectory() || stat5.isSymbolicLink()) return null;
|
|
24475
|
-
return fs5.realpathSync(memoryDir);
|
|
24476
|
-
} catch {
|
|
24477
|
-
return null;
|
|
24478
|
-
}
|
|
24479
|
-
}
|
|
24480
|
-
function isPathInside2(rootReal, candidateReal) {
|
|
24481
|
-
const relative = path29.relative(rootReal, candidateReal);
|
|
24482
|
-
return relative === "" || !!relative && !relative.startsWith("..") && !path29.isAbsolute(relative);
|
|
24483
|
-
}
|
|
24484
|
-
function isSafeDirectory(rootReal, dir) {
|
|
24485
|
-
try {
|
|
24486
|
-
const stat5 = fs5.lstatSync(dir);
|
|
24487
|
-
if (!stat5.isDirectory() || stat5.isSymbolicLink()) return false;
|
|
24488
|
-
return isPathInside2(rootReal, fs5.realpathSync(dir));
|
|
24489
|
-
} catch {
|
|
24490
|
-
return false;
|
|
24491
|
-
}
|
|
24492
|
-
}
|
|
24493
|
-
function ensureSafeDirectory(rootReal, dir) {
|
|
24494
|
-
if (fs5.existsSync(dir)) {
|
|
24495
|
-
if (!isSafeDirectory(rootReal, dir)) {
|
|
24496
|
-
throw new Error(`Refusing to write through unsafe review path: ${dir}`);
|
|
24497
|
-
}
|
|
24498
|
-
return;
|
|
24499
|
-
}
|
|
24500
|
-
fs5.mkdirSync(dir, { recursive: true });
|
|
24501
|
-
if (!isSafeDirectory(rootReal, dir)) {
|
|
24502
|
-
throw new Error(`Refusing to write through unsafe review path: ${dir}`);
|
|
24503
|
-
}
|
|
24504
|
-
}
|
|
24505
|
-
function listReviewItems(options) {
|
|
24506
|
-
const startTime = Date.now();
|
|
24507
|
-
const {
|
|
24508
|
-
memoryDir,
|
|
24509
|
-
reason: filterReason,
|
|
24510
|
-
limit = 50,
|
|
24511
|
-
confidenceThreshold = DEFAULT_CONFIDENCE_THRESHOLD
|
|
24512
|
-
} = options;
|
|
24513
|
-
const maxItems = Math.max(0, limit);
|
|
24514
|
-
const rootReal = realMemoryRoot(memoryDir);
|
|
24515
|
-
if (!rootReal || maxItems === 0) {
|
|
24516
|
-
return { items: [], total: 0, durationMs: Date.now() - startTime };
|
|
24517
|
-
}
|
|
24518
|
-
const items = [];
|
|
24519
|
-
const isLimitReached = () => items.length >= maxItems;
|
|
24520
|
-
const addItem = (item) => {
|
|
24521
|
-
if (isLimitReached()) return;
|
|
24522
|
-
if (filterReason && item.reviewReason !== filterReason) return;
|
|
24523
|
-
items.push(item);
|
|
24524
|
-
};
|
|
24525
|
-
const suggestionsDir = path29.join(memoryDir, "suggestions");
|
|
24526
|
-
if (!isLimitReached() && fs5.existsSync(suggestionsDir) && isSafeDirectory(rootReal, suggestionsDir)) {
|
|
24527
|
-
walkMd(rootReal, suggestionsDir, (filePath, content) => {
|
|
24528
|
-
if (isLimitReached()) return true;
|
|
24529
|
-
const fm = parseFrontmatter4(content);
|
|
24530
|
-
const body = extractBody4(content);
|
|
24531
|
-
if (!fm?.id) return false;
|
|
24532
|
-
addItem({
|
|
24533
|
-
id: fm.id,
|
|
24534
|
-
content: body,
|
|
24535
|
-
category: fm.category ?? "suggestion",
|
|
24536
|
-
confidence: parseConfidence(fm.confidence, 0.5),
|
|
24537
|
-
confidenceTier: fm.confidenceTier ?? "low",
|
|
24538
|
-
source: fm.source ?? "unknown",
|
|
24539
|
-
filePath,
|
|
24540
|
-
created: fm.created ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
24541
|
-
reviewReason: "suggestion"
|
|
24542
|
-
});
|
|
24543
|
-
return isLimitReached();
|
|
24544
|
-
});
|
|
24545
|
-
}
|
|
24546
|
-
const reviewDir = path29.join(memoryDir, "review");
|
|
24547
|
-
if (!isLimitReached() && fs5.existsSync(reviewDir) && isSafeDirectory(rootReal, reviewDir)) {
|
|
24548
|
-
walkMd(rootReal, reviewDir, (filePath, content) => {
|
|
24549
|
-
if (isLimitReached()) return true;
|
|
24550
|
-
const fm = parseFrontmatter4(content);
|
|
24551
|
-
const body = extractBody4(content);
|
|
24552
|
-
if (!fm?.id) return false;
|
|
24553
|
-
addItem({
|
|
24554
|
-
id: fm.id,
|
|
24555
|
-
content: body,
|
|
24556
|
-
category: fm.category ?? "review",
|
|
24557
|
-
confidence: parseConfidence(fm.confidence, 0.5),
|
|
24558
|
-
confidenceTier: fm.confidenceTier ?? "low",
|
|
24559
|
-
source: fm.source ?? "unknown",
|
|
24560
|
-
filePath,
|
|
24561
|
-
created: fm.created ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
24562
|
-
reviewReason: fm.reviewReason ?? "low_confidence",
|
|
24563
|
-
context: fm.context
|
|
24564
|
-
});
|
|
24565
|
-
return isLimitReached();
|
|
24566
|
-
});
|
|
24567
|
-
}
|
|
24568
|
-
const categories = ALL_CATEGORY_DIRS;
|
|
24569
|
-
for (const category of categories) {
|
|
24570
|
-
if (isLimitReached()) break;
|
|
24571
|
-
const dir = path29.join(memoryDir, category);
|
|
24572
|
-
if (!fs5.existsSync(dir) || !isSafeDirectory(rootReal, dir)) continue;
|
|
24573
|
-
walkMd(rootReal, dir, (filePath, content) => {
|
|
24574
|
-
if (isLimitReached()) return true;
|
|
24575
|
-
const fm = parseFrontmatter4(content);
|
|
24576
|
-
const body = extractBody4(content);
|
|
24577
|
-
if (!fm?.id) return false;
|
|
24578
|
-
const confidence = parseConfidence(fm.confidence, 1);
|
|
24579
|
-
if (confidence >= confidenceThreshold && !(typeof fm.blockedBy === "string" && fm.blockedBy.length > 0)) return false;
|
|
24580
|
-
if (parseBoolean(fm.reviewDismissed)) return false;
|
|
24581
|
-
if (items.some((i) => i.id === fm.id)) return false;
|
|
24582
|
-
addItem({
|
|
24583
|
-
id: fm.id,
|
|
24584
|
-
content: body,
|
|
24585
|
-
category: fm.category ?? category.slice(0, -1),
|
|
24586
|
-
confidence,
|
|
24587
|
-
confidenceTier: fm.confidenceTier ?? "low",
|
|
24588
|
-
source: fm.source ?? "unknown",
|
|
24589
|
-
filePath,
|
|
24590
|
-
created: fm.created ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
24591
|
-
reviewReason: typeof fm.blockedBy === "string" && fm.blockedBy.length > 0 ? "tombstone_blocked" : "low_confidence"
|
|
24592
|
-
});
|
|
24593
|
-
return isLimitReached();
|
|
24594
|
-
});
|
|
24595
|
-
}
|
|
24596
|
-
return {
|
|
24597
|
-
items,
|
|
24598
|
-
total: items.length,
|
|
24599
|
-
durationMs: Date.now() - startTime
|
|
24600
|
-
};
|
|
24601
|
-
}
|
|
24602
|
-
function performReview(memoryDir, itemId, action, options = {}) {
|
|
24603
|
-
const result = action === "approve" ? approveItem(memoryDir, itemId, options) : action === "dismiss" ? dismissItem(memoryDir, itemId, options) : flagItem(memoryDir, itemId, options);
|
|
24604
|
-
if (result.updatedPath !== void 0) bumpMemoryCorpusVersionForDir(memoryDir);
|
|
24605
|
-
return result;
|
|
24606
|
-
}
|
|
24607
|
-
function approveItem(memoryDir, itemId, options) {
|
|
24608
|
-
const rootReal = realMemoryRoot(memoryDir);
|
|
24609
|
-
if (!rootReal) return { itemId, action: "approve", message: "Item not found" };
|
|
24610
|
-
const found = findReviewFileById(memoryDir, itemId, options);
|
|
24611
|
-
if (!found) {
|
|
24612
|
-
return { itemId, action: "approve", message: "Item not found" };
|
|
24613
|
-
}
|
|
24614
|
-
const content = fs5.readFileSync(found.filePath, "utf8");
|
|
24615
|
-
const fm = parseFrontmatter4(content);
|
|
24616
|
-
if (!fm) return { itemId, action: "approve", message: "Could not parse frontmatter" };
|
|
24617
|
-
const blockedBy = typeof fm.blockedBy === "string" ? fm.blockedBy : null;
|
|
24618
|
-
const fireBlockedRevocation = () => {
|
|
24619
|
-
if (!blockedBy || !options.onApproveBlockedMemory) return;
|
|
24620
|
-
try {
|
|
24621
|
-
const maybe = options.onApproveBlockedMemory(blockedBy, itemId);
|
|
24622
|
-
if (maybe && typeof maybe.then === "function") {
|
|
24623
|
-
void maybe.catch(() => void 0);
|
|
24624
|
-
}
|
|
24625
|
-
} catch {
|
|
24626
|
-
}
|
|
24627
|
-
};
|
|
24628
|
-
const updatedContent = updateFrontmatterFields(content, {
|
|
24629
|
-
confidence: "0.9",
|
|
24630
|
-
confidenceTier: "high",
|
|
24631
|
-
reviewDismissed: null,
|
|
24632
|
-
// Clear the tombstone-block markers so the promoted memory is active.
|
|
24633
|
-
// Clear the tombstone-block markers AND restore active status so the
|
|
24634
|
-
// promoted memory is fully active in recall + provenance (issue #1579
|
|
24635
|
-
// review: leaving status: pending_review kept it invisible to recall).
|
|
24636
|
-
...blockedBy ? { blockedBy: null, tombstoneBlockTier: null, status: "active" } : {}
|
|
24637
|
-
});
|
|
24638
|
-
if (found.location === "category") {
|
|
24639
|
-
writeReviewFileCanonicalized(memoryDir, found.filePath, updatedContent);
|
|
24640
|
-
fireBlockedRevocation();
|
|
24641
|
-
return {
|
|
24642
|
-
itemId,
|
|
24643
|
-
action: "approve",
|
|
24644
|
-
updatedPath: found.filePath,
|
|
24645
|
-
message: "Approved low-confidence memory in place with confidence 0.9",
|
|
24646
|
-
...blockedBy ? { clearedTombstoneId: blockedBy } : {}
|
|
24647
|
-
};
|
|
24648
|
-
}
|
|
24649
|
-
const category = fm.category ?? "fact";
|
|
24650
|
-
const targetDir = getCategoryDir(memoryDir, category);
|
|
24651
|
-
const dateDir = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
24652
|
-
ensureSafeDirectory(rootReal, targetDir);
|
|
24653
|
-
const outputPath = path29.join(targetDir, dateDir, path29.basename(found.filePath));
|
|
24654
|
-
ensureSafeDirectory(rootReal, path29.dirname(outputPath));
|
|
24655
|
-
const reviewStateDir = path29.join(memoryDir, "state");
|
|
24656
|
-
const idsAtWrite = historicalIdCache3.get(reviewStateDir);
|
|
24657
|
-
const promotedWritten = canonicalizeEntityRefFrontmatter(updatedContent, idsAtWrite);
|
|
24658
|
-
const promotedPath = writeFileWithoutClobber(outputPath, promotedWritten, itemId);
|
|
24659
|
-
try {
|
|
24660
|
-
repairContentAfterJournalMoveSync({
|
|
24661
|
-
stateDir: reviewStateDir,
|
|
24662
|
-
cache: historicalIdCache3,
|
|
24663
|
-
idsAtWrite,
|
|
24664
|
-
rawContent: updatedContent,
|
|
24665
|
-
lastWritten: promotedWritten,
|
|
24666
|
-
rewrite: (next) => fs5.writeFileSync(promotedPath, next, "utf8")
|
|
24667
|
-
});
|
|
24668
|
-
} catch (err) {
|
|
24669
|
-
try {
|
|
24670
|
-
fs5.unlinkSync(promotedPath);
|
|
24671
|
-
} catch {
|
|
24672
|
-
}
|
|
24673
|
-
throw err;
|
|
24674
|
-
}
|
|
24675
|
-
fs5.unlinkSync(found.filePath);
|
|
24676
|
-
fireBlockedRevocation();
|
|
24677
|
-
return {
|
|
24678
|
-
itemId,
|
|
24679
|
-
action: "approve",
|
|
24680
|
-
updatedPath: promotedPath,
|
|
24681
|
-
message: `Promoted to ${category} with confidence 0.9`,
|
|
24682
|
-
...blockedBy ? { clearedTombstoneId: blockedBy } : {}
|
|
24683
|
-
};
|
|
24684
|
-
}
|
|
24685
|
-
function dismissItem(memoryDir, itemId, options) {
|
|
24686
|
-
const found = findReviewFileById(memoryDir, itemId, options);
|
|
24687
|
-
if (!found) {
|
|
24688
|
-
return { itemId, action: "dismiss", message: "Item not found" };
|
|
24689
|
-
}
|
|
24690
|
-
if (found.location === "queue") {
|
|
24691
|
-
fs5.unlinkSync(found.filePath);
|
|
24692
|
-
return { itemId, action: "dismiss", message: "Dismissed and removed" };
|
|
24693
|
-
}
|
|
24694
|
-
const content = fs5.readFileSync(found.filePath, "utf8");
|
|
24695
|
-
writeReviewFileCanonicalized(
|
|
24696
|
-
memoryDir,
|
|
24697
|
-
found.filePath,
|
|
24698
|
-
updateFrontmatterFields(content, {
|
|
24699
|
-
reviewDismissed: "true",
|
|
24700
|
-
reviewDismissedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
24701
|
-
})
|
|
24702
|
-
);
|
|
24703
|
-
return {
|
|
24704
|
-
itemId,
|
|
24705
|
-
action: "dismiss",
|
|
24706
|
-
updatedPath: found.filePath,
|
|
24707
|
-
message: "Dismissed low-confidence memory in place"
|
|
24708
|
-
};
|
|
24709
|
-
}
|
|
24710
|
-
function flagItem(memoryDir, itemId, options) {
|
|
24711
|
-
const found = findReviewFileById(memoryDir, itemId, options);
|
|
24712
|
-
if (!found) {
|
|
24713
|
-
return { itemId, action: "flag", message: "Item not found" };
|
|
24714
|
-
}
|
|
24715
|
-
const content = fs5.readFileSync(found.filePath, "utf8");
|
|
24716
|
-
const fixed = updateFrontmatterFields(content, {
|
|
24717
|
-
flagged: "true",
|
|
24718
|
-
flaggedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
24719
|
-
});
|
|
24720
|
-
writeReviewFileCanonicalized(memoryDir, found.filePath, fixed);
|
|
24721
|
-
return {
|
|
24722
|
-
itemId,
|
|
24723
|
-
action: "flag",
|
|
24724
|
-
updatedPath: found.filePath,
|
|
24725
|
-
message: "Flagged for further review"
|
|
24726
|
-
};
|
|
24727
|
-
}
|
|
24728
|
-
function findReviewFileById(memoryDir, id, options = {}) {
|
|
24729
|
-
const rootReal = realMemoryRoot(memoryDir);
|
|
24730
|
-
if (!rootReal) return null;
|
|
24731
|
-
for (const loc of ["suggestions", "review"]) {
|
|
24732
|
-
const dir = path29.join(memoryDir, loc);
|
|
24733
|
-
if (!fs5.existsSync(dir) || !isSafeDirectory(rootReal, dir)) continue;
|
|
24734
|
-
const found = findFileById(rootReal, dir, id);
|
|
24735
|
-
if (found) return { filePath: found, location: "queue" };
|
|
24736
|
-
}
|
|
24737
|
-
for (const category of ALL_CATEGORY_DIRS) {
|
|
24738
|
-
const dir = path29.join(memoryDir, category);
|
|
24739
|
-
if (!fs5.existsSync(dir) || !isSafeDirectory(rootReal, dir)) continue;
|
|
24740
|
-
const found = findFileById(rootReal, dir, id, (fm) => isLowConfidenceReviewCandidate(fm, options));
|
|
24741
|
-
if (found) return { filePath: found, location: "category" };
|
|
24742
|
-
}
|
|
24743
|
-
return null;
|
|
24744
|
-
}
|
|
24745
|
-
function findFileById(rootReal, dir, id, include) {
|
|
24746
|
-
const files = walkMdPaths(rootReal, dir);
|
|
24747
|
-
for (const filePath of files) {
|
|
24748
|
-
const content = readFileSafe3(filePath);
|
|
24749
|
-
if (!content) continue;
|
|
24750
|
-
const fm = parseFrontmatter4(content);
|
|
24751
|
-
if (fm?.id === id && (!include || include(fm))) return filePath;
|
|
24752
|
-
}
|
|
24753
|
-
return null;
|
|
24754
|
-
}
|
|
24755
|
-
function isLowConfidenceReviewCandidate(fm, options) {
|
|
24756
|
-
const threshold = options.confidenceThreshold ?? DEFAULT_CONFIDENCE_THRESHOLD;
|
|
24757
|
-
if (typeof fm.blockedBy === "string" && fm.blockedBy.length > 0) {
|
|
24758
|
-
return !parseBoolean(fm.reviewDismissed);
|
|
24759
|
-
}
|
|
24760
|
-
return parseConfidence(fm.confidence, 1) < threshold && !parseBoolean(fm.reviewDismissed);
|
|
24761
|
-
}
|
|
24762
|
-
function parseBoolean(value) {
|
|
24763
|
-
if (typeof value === "boolean") return value;
|
|
24764
|
-
if (typeof value !== "string") return false;
|
|
24765
|
-
const normalized = value.trim().toLowerCase();
|
|
24766
|
-
return normalized === "true" || normalized === "1" || normalized === "yes";
|
|
24767
|
-
}
|
|
24768
|
-
function parseConfidence(value, fallback) {
|
|
24769
|
-
if (typeof value === "number") return Number.isFinite(value) ? value : fallback;
|
|
24770
|
-
if (typeof value === "string") {
|
|
24771
|
-
const n = parseFloat(value);
|
|
24772
|
-
return Number.isFinite(n) ? n : fallback;
|
|
24773
|
-
}
|
|
24774
|
-
return fallback;
|
|
24775
|
-
}
|
|
24776
|
-
function updateFrontmatterFields(content, fields) {
|
|
24777
|
-
const match = content.match(/^(---\n)([\s\S]*?)(\n---(?:\n|$))/);
|
|
24778
|
-
if (!match) return content;
|
|
24779
|
-
const seen = /* @__PURE__ */ new Set();
|
|
24780
|
-
const lines = match[2].split("\n");
|
|
24781
|
-
const nextLines = [];
|
|
24782
|
-
for (const line of lines) {
|
|
24783
|
-
const colonIdx = line.indexOf(":");
|
|
24784
|
-
if (colonIdx === -1) {
|
|
24785
|
-
nextLines.push(line);
|
|
24786
|
-
continue;
|
|
24787
|
-
}
|
|
24788
|
-
const key = line.slice(0, colonIdx).trim();
|
|
24789
|
-
if (!Object.prototype.hasOwnProperty.call(fields, key)) {
|
|
24790
|
-
nextLines.push(line);
|
|
24791
|
-
continue;
|
|
24792
|
-
}
|
|
24793
|
-
seen.add(key);
|
|
24794
|
-
const value = fields[key];
|
|
24795
|
-
if (value !== null) {
|
|
24796
|
-
nextLines.push(`${key}: ${value}`);
|
|
24797
|
-
}
|
|
24798
|
-
}
|
|
24799
|
-
for (const [key, value] of Object.entries(fields)) {
|
|
24800
|
-
if (value !== null && !seen.has(key)) {
|
|
24801
|
-
nextLines.push(`${key}: ${value}`);
|
|
24802
|
-
}
|
|
24803
|
-
}
|
|
24804
|
-
return `${match[1]}${nextLines.join("\n")}${match[3]}${content.slice(match[0].length)}`;
|
|
24805
|
-
}
|
|
24806
|
-
function readFileSafe3(filePath) {
|
|
24807
|
-
try {
|
|
24808
|
-
return fs5.readFileSync(filePath, "utf8");
|
|
24809
|
-
} catch {
|
|
24810
|
-
return null;
|
|
24811
|
-
}
|
|
24812
|
-
}
|
|
24813
|
-
function writeFileWithoutClobber(basePath, content, discriminator) {
|
|
24814
|
-
const parsed = path29.parse(basePath);
|
|
24815
|
-
const safeDiscriminator = sanitizeFilePart(discriminator);
|
|
24816
|
-
for (let attempt = 0; attempt < 1e3; attempt++) {
|
|
24817
|
-
const candidate = attempt === 0 ? basePath : path29.join(
|
|
24818
|
-
parsed.dir,
|
|
24819
|
-
`${parsed.name}-${safeDiscriminator}${attempt === 1 ? "" : `-${attempt}`}${parsed.ext || ".md"}`
|
|
24820
|
-
);
|
|
24821
|
-
try {
|
|
24822
|
-
fs5.writeFileSync(candidate, content, { encoding: "utf8", flag: "wx" });
|
|
24823
|
-
return candidate;
|
|
24824
|
-
} catch (error) {
|
|
24825
|
-
if (error.code === "EEXIST") continue;
|
|
24826
|
-
throw error;
|
|
24827
|
-
}
|
|
24828
|
-
}
|
|
24829
|
-
throw new Error(`Could not find a free review promotion path for ${basePath}`);
|
|
24830
|
-
}
|
|
24831
|
-
function sanitizeFilePart(value) {
|
|
24832
|
-
const chars = [];
|
|
24833
|
-
let previousWasDash = false;
|
|
24834
|
-
for (const char of value) {
|
|
24835
|
-
const next = isSafeFilePartChar(char) ? char : "-";
|
|
24836
|
-
if (next === "-" && previousWasDash) continue;
|
|
24837
|
-
chars.push(next);
|
|
24838
|
-
previousWasDash = next === "-";
|
|
24839
|
-
if (chars.length >= 64) break;
|
|
24840
|
-
}
|
|
24841
|
-
let start = 0;
|
|
24842
|
-
let end = chars.length;
|
|
24843
|
-
while (start < end && chars[start] === "-") start++;
|
|
24844
|
-
while (end > start && chars[end - 1] === "-") end--;
|
|
24845
|
-
const sanitized = chars.slice(start, end).join("");
|
|
24846
|
-
return sanitized || "review-item";
|
|
24847
|
-
}
|
|
24848
|
-
function isSafeFilePartChar(value) {
|
|
24849
|
-
if (value.length !== 1) return false;
|
|
24850
|
-
const code = value.charCodeAt(0);
|
|
24851
|
-
return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || value === "." || value === "_" || value === "-";
|
|
24852
|
-
}
|
|
24853
|
-
function parseFrontmatter4(content) {
|
|
24854
|
-
const match = content.match(/^---\n([\s\S]*?)\n---/);
|
|
24855
|
-
if (!match) return null;
|
|
24856
|
-
const fm = {};
|
|
24857
|
-
for (const line of match[1].split("\n")) {
|
|
24858
|
-
const colonIdx = line.indexOf(":");
|
|
24859
|
-
if (colonIdx === -1) continue;
|
|
24860
|
-
const key = line.slice(0, colonIdx).trim();
|
|
24861
|
-
const value = line.slice(colonIdx + 1).trim();
|
|
24862
|
-
fm[key] = value;
|
|
24863
|
-
}
|
|
24864
|
-
return fm;
|
|
24865
|
-
}
|
|
24866
|
-
function extractBody4(content) {
|
|
24867
|
-
const match = content.match(/^---\n[\s\S]*?\n---\n([\s\S]*)/);
|
|
24868
|
-
return match ? match[1].trim() : content.trim();
|
|
24869
|
-
}
|
|
24870
|
-
function walkMd(rootReal, dir, callback) {
|
|
24871
|
-
if (!isSafeDirectory(rootReal, dir)) return false;
|
|
24872
|
-
for (const entry of fs5.readdirSync(dir, { withFileTypes: true })) {
|
|
24873
|
-
const fullPath = path29.join(dir, entry.name);
|
|
24874
|
-
if (entry.isSymbolicLink()) continue;
|
|
24875
|
-
if (entry.isDirectory()) {
|
|
24876
|
-
if (walkMd(rootReal, fullPath, callback)) return true;
|
|
24877
|
-
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
24878
|
-
const content = readFileSafe3(fullPath);
|
|
24879
|
-
if (content && callback(fullPath, content) === true) return true;
|
|
24880
|
-
}
|
|
24881
|
-
}
|
|
24882
|
-
return false;
|
|
24883
|
-
}
|
|
24884
|
-
function walkMdPaths(rootReal, dir) {
|
|
24885
|
-
const results = [];
|
|
24886
|
-
if (!isSafeDirectory(rootReal, dir)) return results;
|
|
24887
|
-
for (const entry of fs5.readdirSync(dir, { withFileTypes: true })) {
|
|
24888
|
-
const fullPath = path29.join(dir, entry.name);
|
|
24889
|
-
if (entry.isSymbolicLink()) continue;
|
|
24890
|
-
if (entry.isDirectory()) {
|
|
24891
|
-
results.push(...walkMdPaths(rootReal, fullPath));
|
|
24892
|
-
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
24893
|
-
results.push(fullPath);
|
|
24894
|
-
}
|
|
24895
|
-
}
|
|
24896
|
-
return results;
|
|
24897
|
-
}
|
|
24898
|
-
|
|
24899
|
-
// src/sync/index.ts
|
|
24900
|
-
import fs6 from "fs";
|
|
24901
|
-
import path30 from "path";
|
|
24902
24577
|
import crypto6 from "crypto";
|
|
24903
24578
|
var DEFAULT_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".txt", ".mdx", ".rst"]);
|
|
24904
24579
|
var DEFAULT_EXCLUDE2 = /* @__PURE__ */ new Set([
|
|
@@ -24920,7 +24595,7 @@ function syncChanges(options) {
|
|
|
24920
24595
|
} = options;
|
|
24921
24596
|
const extSet = new Set(extensions);
|
|
24922
24597
|
const excludeSet = /* @__PURE__ */ new Set([...DEFAULT_EXCLUDE2, ...excludeDirs]);
|
|
24923
|
-
const stateFilePath = options.stateFile ??
|
|
24598
|
+
const stateFilePath = options.stateFile ?? path29.join(memoryDir, ".sync-state.json");
|
|
24924
24599
|
const prevState = loadState(stateFilePath);
|
|
24925
24600
|
const currentFiles = scanFiles(sourceDir, extSet, excludeSet);
|
|
24926
24601
|
const changes = computeDiff(currentFiles, prevState.fileHashes, sourceDir);
|
|
@@ -24936,8 +24611,8 @@ function syncChanges(options) {
|
|
|
24936
24611
|
for (const [relPath, hash] of Object.entries(currentFiles)) {
|
|
24937
24612
|
newState.fileHashes[relPath] = hash;
|
|
24938
24613
|
}
|
|
24939
|
-
|
|
24940
|
-
|
|
24614
|
+
fs5.mkdirSync(path29.dirname(stateFilePath), { recursive: true });
|
|
24615
|
+
fs5.writeFileSync(stateFilePath, JSON.stringify(newState, null, 2));
|
|
24941
24616
|
}
|
|
24942
24617
|
return {
|
|
24943
24618
|
scanned: Object.keys(currentFiles).length,
|
|
@@ -24991,7 +24666,7 @@ function scanFiles(root, extensions, exclude) {
|
|
|
24991
24666
|
function walk(dir, isRoot = false) {
|
|
24992
24667
|
let entries;
|
|
24993
24668
|
try {
|
|
24994
|
-
entries =
|
|
24669
|
+
entries = fs5.readdirSync(dir, { withFileTypes: true });
|
|
24995
24670
|
} catch (err) {
|
|
24996
24671
|
if (isRoot) {
|
|
24997
24672
|
throw new Error(
|
|
@@ -25002,15 +24677,15 @@ function scanFiles(root, extensions, exclude) {
|
|
|
25002
24677
|
}
|
|
25003
24678
|
for (const entry of entries) {
|
|
25004
24679
|
if (exclude.has(entry.name)) continue;
|
|
25005
|
-
const fullPath =
|
|
24680
|
+
const fullPath = path29.join(dir, entry.name);
|
|
25006
24681
|
if (entry.isDirectory()) {
|
|
25007
24682
|
walk(fullPath);
|
|
25008
24683
|
} else if (entry.isFile()) {
|
|
25009
|
-
const ext =
|
|
24684
|
+
const ext = path29.extname(entry.name).toLowerCase();
|
|
25010
24685
|
if (!extensions.has(ext)) continue;
|
|
25011
|
-
const relPath =
|
|
24686
|
+
const relPath = path29.relative(root, fullPath);
|
|
25012
24687
|
try {
|
|
25013
|
-
const content =
|
|
24688
|
+
const content = fs5.readFileSync(fullPath, "utf8");
|
|
25014
24689
|
result[relPath] = hashContent3(content);
|
|
25015
24690
|
} catch {
|
|
25016
24691
|
}
|
|
@@ -25023,11 +24698,11 @@ function scanFiles(root, extensions, exclude) {
|
|
|
25023
24698
|
function computeDiff(current, previous, sourceDir) {
|
|
25024
24699
|
const changes = [];
|
|
25025
24700
|
for (const [relPath, hash] of Object.entries(current)) {
|
|
25026
|
-
const fullPath =
|
|
24701
|
+
const fullPath = path29.join(sourceDir, relPath);
|
|
25027
24702
|
if (!(relPath in previous)) {
|
|
25028
24703
|
let size = 0;
|
|
25029
24704
|
try {
|
|
25030
|
-
size =
|
|
24705
|
+
size = fs5.statSync(fullPath).size;
|
|
25031
24706
|
} catch {
|
|
25032
24707
|
}
|
|
25033
24708
|
changes.push({
|
|
@@ -25040,7 +24715,7 @@ function computeDiff(current, previous, sourceDir) {
|
|
|
25040
24715
|
} else if (previous[relPath] !== hash) {
|
|
25041
24716
|
let size = 0;
|
|
25042
24717
|
try {
|
|
25043
|
-
size =
|
|
24718
|
+
size = fs5.statSync(fullPath).size;
|
|
25044
24719
|
} catch {
|
|
25045
24720
|
}
|
|
25046
24721
|
changes.push({
|
|
@@ -25056,7 +24731,7 @@ function computeDiff(current, previous, sourceDir) {
|
|
|
25056
24731
|
for (const relPath of Object.keys(previous)) {
|
|
25057
24732
|
if (!(relPath in current)) {
|
|
25058
24733
|
changes.push({
|
|
25059
|
-
filePath:
|
|
24734
|
+
filePath: path29.join(sourceDir, relPath),
|
|
25060
24735
|
relativePath: relPath,
|
|
25061
24736
|
type: "deleted",
|
|
25062
24737
|
currentHash: "",
|
|
@@ -25068,7 +24743,7 @@ function computeDiff(current, previous, sourceDir) {
|
|
|
25068
24743
|
}
|
|
25069
24744
|
function loadState(stateFilePath) {
|
|
25070
24745
|
try {
|
|
25071
|
-
const raw =
|
|
24746
|
+
const raw = fs5.readFileSync(stateFilePath, "utf8");
|
|
25072
24747
|
return JSON.parse(raw);
|
|
25073
24748
|
} catch {
|
|
25074
24749
|
return {
|
|
@@ -25085,25 +24760,25 @@ function hashContent3(content) {
|
|
|
25085
24760
|
// src/spaces/index.ts
|
|
25086
24761
|
import { spawnSync } from "child_process";
|
|
25087
24762
|
import crypto7 from "crypto";
|
|
25088
|
-
import
|
|
25089
|
-
import
|
|
25090
|
-
var
|
|
24763
|
+
import fs6 from "fs";
|
|
24764
|
+
import path30 from "path";
|
|
24765
|
+
var historicalIdCache3 = new HistoricalEntityCanonicalIdCache();
|
|
25091
24766
|
var MANIFEST_VERSION = 1;
|
|
25092
24767
|
var MANIFEST_LOCK_STALE_MS = 3e4;
|
|
25093
24768
|
var MANIFEST_LOCK_TIMEOUT_MS = MANIFEST_LOCK_STALE_MS + 1e4;
|
|
25094
24769
|
var MANIFEST_LOCK_SLEEP_MS = 20;
|
|
25095
24770
|
function normalizeSpaceMemoryDir(memoryDir) {
|
|
25096
|
-
return
|
|
24771
|
+
return path30.resolve(memoryDir);
|
|
25097
24772
|
}
|
|
25098
24773
|
function getSpacesDir(baseDir) {
|
|
25099
24774
|
const homeDir = baseDir ?? resolveHomeDir();
|
|
25100
|
-
return
|
|
24775
|
+
return path30.join(homeDir, ".config", "engram", "spaces");
|
|
25101
24776
|
}
|
|
25102
24777
|
function getManifestPath(baseDir) {
|
|
25103
|
-
return
|
|
24778
|
+
return path30.join(getSpacesDir(baseDir), "manifest.json");
|
|
25104
24779
|
}
|
|
25105
24780
|
function loadManifest(baseDir, memoryDirOverride) {
|
|
25106
|
-
if (
|
|
24781
|
+
if (fs6.existsSync(getManifestPath(baseDir))) {
|
|
25107
24782
|
try {
|
|
25108
24783
|
return readManifestUnlocked(baseDir, memoryDirOverride, { bootstrapIfMissing: false });
|
|
25109
24784
|
} catch (error) {
|
|
@@ -25129,7 +24804,7 @@ function updateManifest(baseDir, updater, memoryDirOverride) {
|
|
|
25129
24804
|
}
|
|
25130
24805
|
function readManifestUnlocked(baseDir, memoryDirOverride, options = {}) {
|
|
25131
24806
|
const manifestPath2 = getManifestPath(baseDir);
|
|
25132
|
-
if (!
|
|
24807
|
+
if (!fs6.existsSync(manifestPath2)) {
|
|
25133
24808
|
if (options.bootstrapIfMissing === false) {
|
|
25134
24809
|
const error = new Error(`Spaces manifest not found: ${manifestPath2}`);
|
|
25135
24810
|
error.code = "ENOENT";
|
|
@@ -25142,21 +24817,21 @@ function readManifestUnlocked(baseDir, memoryDirOverride, options = {}) {
|
|
|
25142
24817
|
version: MANIFEST_VERSION
|
|
25143
24818
|
};
|
|
25144
24819
|
}
|
|
25145
|
-
const raw = JSON.parse(
|
|
24820
|
+
const raw = JSON.parse(fs6.readFileSync(manifestPath2, "utf8"));
|
|
25146
24821
|
return raw;
|
|
25147
24822
|
}
|
|
25148
24823
|
function saveManifestUnlocked(manifest, baseDir) {
|
|
25149
24824
|
const manifestPath2 = getManifestPath(baseDir);
|
|
25150
|
-
const manifestDir2 =
|
|
25151
|
-
|
|
25152
|
-
const tempPath =
|
|
24825
|
+
const manifestDir2 = path30.dirname(manifestPath2);
|
|
24826
|
+
fs6.mkdirSync(manifestDir2, { recursive: true });
|
|
24827
|
+
const tempPath = path30.join(manifestDir2, `.manifest.${process.pid}.${Date.now()}.${crypto7.randomUUID()}.tmp`);
|
|
25153
24828
|
try {
|
|
25154
|
-
|
|
24829
|
+
fs6.writeFileSync(tempPath, `${JSON.stringify(manifest, null, 2)}
|
|
25155
24830
|
`, { flag: "wx" });
|
|
25156
|
-
|
|
24831
|
+
fs6.renameSync(tempPath, manifestPath2);
|
|
25157
24832
|
} catch (error) {
|
|
25158
24833
|
try {
|
|
25159
|
-
|
|
24834
|
+
fs6.rmSync(tempPath, { force: true });
|
|
25160
24835
|
} catch {
|
|
25161
24836
|
}
|
|
25162
24837
|
throw error;
|
|
@@ -25164,7 +24839,7 @@ function saveManifestUnlocked(manifest, baseDir) {
|
|
|
25164
24839
|
}
|
|
25165
24840
|
function withManifestLock(baseDir, operation) {
|
|
25166
24841
|
const lockDir = `${getManifestPath(baseDir)}.lock`;
|
|
25167
|
-
|
|
24842
|
+
fs6.mkdirSync(path30.dirname(lockDir), { recursive: true });
|
|
25168
24843
|
const lockOwner = acquireManifestLock(lockDir);
|
|
25169
24844
|
try {
|
|
25170
24845
|
return operation();
|
|
@@ -25177,10 +24852,10 @@ function acquireManifestLock(lockDir) {
|
|
|
25177
24852
|
const owner = createManifestLockOwner();
|
|
25178
24853
|
const reclaimDir = getManifestLockReclaimDir(lockDir);
|
|
25179
24854
|
while (true) {
|
|
25180
|
-
if (
|
|
24855
|
+
if (fs6.existsSync(reclaimDir)) {
|
|
25181
24856
|
removeStaleManifestReclaimLock(reclaimDir);
|
|
25182
24857
|
}
|
|
25183
|
-
if (
|
|
24858
|
+
if (fs6.existsSync(reclaimDir)) {
|
|
25184
24859
|
if (Date.now() >= deadline) {
|
|
25185
24860
|
throw new Error(`Timed out waiting for spaces manifest reclaim lock: ${reclaimDir}`);
|
|
25186
24861
|
}
|
|
@@ -25188,15 +24863,15 @@ function acquireManifestLock(lockDir) {
|
|
|
25188
24863
|
continue;
|
|
25189
24864
|
}
|
|
25190
24865
|
try {
|
|
25191
|
-
|
|
24866
|
+
fs6.mkdirSync(lockDir, { recursive: false });
|
|
25192
24867
|
try {
|
|
25193
|
-
|
|
24868
|
+
fs6.writeFileSync(path30.join(lockDir, "owner"), `${owner}
|
|
25194
24869
|
`, { flag: "wx" });
|
|
25195
24870
|
} catch (error) {
|
|
25196
|
-
|
|
24871
|
+
fs6.rmSync(lockDir, { recursive: true, force: true });
|
|
25197
24872
|
throw error;
|
|
25198
24873
|
}
|
|
25199
|
-
if (
|
|
24874
|
+
if (fs6.existsSync(reclaimDir)) {
|
|
25200
24875
|
releaseManifestLock(lockDir, owner);
|
|
25201
24876
|
if (Date.now() >= deadline) {
|
|
25202
24877
|
throw new Error(`Timed out waiting for spaces manifest reclaim lock: ${reclaimDir}`);
|
|
@@ -25220,9 +24895,9 @@ function acquireManifestLock(lockDir) {
|
|
|
25220
24895
|
}
|
|
25221
24896
|
function releaseManifestLock(lockDir, owner) {
|
|
25222
24897
|
try {
|
|
25223
|
-
const ownerPath =
|
|
25224
|
-
if (
|
|
25225
|
-
|
|
24898
|
+
const ownerPath = path30.join(lockDir, "owner");
|
|
24899
|
+
if (fs6.readFileSync(ownerPath, "utf8").trim() === owner) {
|
|
24900
|
+
fs6.rmSync(lockDir, { recursive: true, force: true });
|
|
25226
24901
|
}
|
|
25227
24902
|
} catch (error) {
|
|
25228
24903
|
if (error.code !== "ENOENT") {
|
|
@@ -25234,12 +24909,12 @@ function removeStaleManifestLock(lockDir) {
|
|
|
25234
24909
|
const reclaimDir = getManifestLockReclaimDir(lockDir);
|
|
25235
24910
|
const reclaimOwner = createManifestLockOwner();
|
|
25236
24911
|
try {
|
|
25237
|
-
|
|
24912
|
+
fs6.mkdirSync(reclaimDir, { recursive: false });
|
|
25238
24913
|
try {
|
|
25239
|
-
|
|
24914
|
+
fs6.writeFileSync(path30.join(reclaimDir, "owner"), `${reclaimOwner}
|
|
25240
24915
|
`, { flag: "wx" });
|
|
25241
24916
|
} catch (error) {
|
|
25242
|
-
|
|
24917
|
+
fs6.rmSync(reclaimDir, { recursive: true, force: true });
|
|
25243
24918
|
throw error;
|
|
25244
24919
|
}
|
|
25245
24920
|
} catch (error) {
|
|
@@ -25259,16 +24934,16 @@ function removeStaleManifestLock(lockDir) {
|
|
|
25259
24934
|
}
|
|
25260
24935
|
const tombstoneDir = `${lockDir}.stale.${process.pid}.${crypto7.randomUUID()}`;
|
|
25261
24936
|
try {
|
|
25262
|
-
|
|
24937
|
+
fs6.renameSync(lockDir, tombstoneDir);
|
|
25263
24938
|
} catch (error) {
|
|
25264
24939
|
if (error.code !== "ENOENT") {
|
|
25265
24940
|
throw error;
|
|
25266
24941
|
}
|
|
25267
24942
|
return;
|
|
25268
24943
|
}
|
|
25269
|
-
|
|
24944
|
+
fs6.rmSync(tombstoneDir, { recursive: true, force: true });
|
|
25270
24945
|
} finally {
|
|
25271
|
-
|
|
24946
|
+
fs6.rmSync(reclaimDir, { recursive: true, force: true });
|
|
25272
24947
|
}
|
|
25273
24948
|
}
|
|
25274
24949
|
function getManifestLockReclaimDir(lockDir) {
|
|
@@ -25291,19 +24966,19 @@ function removeStaleManifestReclaimLock(reclaimDir) {
|
|
|
25291
24966
|
}
|
|
25292
24967
|
const tombstoneDir = `${reclaimDir}.stale.${process.pid}.${crypto7.randomUUID()}`;
|
|
25293
24968
|
try {
|
|
25294
|
-
|
|
24969
|
+
fs6.renameSync(reclaimDir, tombstoneDir);
|
|
25295
24970
|
} catch (error) {
|
|
25296
24971
|
if (error.code !== "ENOENT") {
|
|
25297
24972
|
throw error;
|
|
25298
24973
|
}
|
|
25299
24974
|
return;
|
|
25300
24975
|
}
|
|
25301
|
-
|
|
24976
|
+
fs6.rmSync(tombstoneDir, { recursive: true, force: true });
|
|
25302
24977
|
}
|
|
25303
24978
|
function readManifestLockSnapshot(lockDir) {
|
|
25304
24979
|
let stat5;
|
|
25305
24980
|
try {
|
|
25306
|
-
stat5 =
|
|
24981
|
+
stat5 = fs6.statSync(lockDir);
|
|
25307
24982
|
} catch (error) {
|
|
25308
24983
|
if (error.code === "ENOENT") {
|
|
25309
24984
|
return void 0;
|
|
@@ -25311,7 +24986,7 @@ function readManifestLockSnapshot(lockDir) {
|
|
|
25311
24986
|
throw error;
|
|
25312
24987
|
}
|
|
25313
24988
|
try {
|
|
25314
|
-
const owner =
|
|
24989
|
+
const owner = fs6.readFileSync(path30.join(lockDir, "owner"), "utf8").trim();
|
|
25315
24990
|
return { mtimeMs: stat5.mtimeMs, owner };
|
|
25316
24991
|
} catch (error) {
|
|
25317
24992
|
if (error.code === "ENOENT") {
|
|
@@ -25383,9 +25058,9 @@ function sleepSync(ms) {
|
|
|
25383
25058
|
}
|
|
25384
25059
|
function createPersonalSpace(baseDir, memoryDirOverride) {
|
|
25385
25060
|
const homeDir = baseDir ?? resolveHomeDir();
|
|
25386
|
-
const standalonePath =
|
|
25387
|
-
const openclawPath =
|
|
25388
|
-
const memoryDir = memoryDirOverride ?? readEnvVar("REMNIC_MEMORY_DIR") ?? readEnvVar("ENGRAM_MEMORY_DIR") ?? (
|
|
25061
|
+
const standalonePath = path30.join(homeDir, ".engram", "memory");
|
|
25062
|
+
const openclawPath = path30.join(homeDir, ".openclaw", "workspace", "memory", "local");
|
|
25063
|
+
const memoryDir = memoryDirOverride ?? readEnvVar("REMNIC_MEMORY_DIR") ?? readEnvVar("ENGRAM_MEMORY_DIR") ?? (fs6.existsSync(standalonePath) ? standalonePath : fs6.existsSync(openclawPath) ? openclawPath : standalonePath);
|
|
25389
25064
|
const normalizedMemoryDir = normalizeSpaceMemoryDir(memoryDir);
|
|
25390
25065
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
25391
25066
|
return {
|
|
@@ -25413,7 +25088,7 @@ function createSpace(options) {
|
|
|
25413
25088
|
const id = options.name.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-");
|
|
25414
25089
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
25415
25090
|
const memoryDir = normalizeSpaceMemoryDir(
|
|
25416
|
-
options.memoryDir ??
|
|
25091
|
+
options.memoryDir ?? path30.join(getSpacesDir(options.baseDir), id, "memory")
|
|
25417
25092
|
);
|
|
25418
25093
|
const space = updateManifest(options.baseDir, (manifest) => {
|
|
25419
25094
|
if (manifest.spaces.some((s) => s.id === id)) {
|
|
@@ -25433,7 +25108,7 @@ function createSpace(options) {
|
|
|
25433
25108
|
owner: readEnvVar("USER"),
|
|
25434
25109
|
parentSpaceId: options.parentSpaceId
|
|
25435
25110
|
};
|
|
25436
|
-
|
|
25111
|
+
fs6.mkdirSync(memoryDir, { recursive: true });
|
|
25437
25112
|
manifest.spaces.push(created);
|
|
25438
25113
|
manifest.updatedAt = now;
|
|
25439
25114
|
return created;
|
|
@@ -25591,9 +25266,9 @@ async function promoteSpace(sourceSpaceId, targetSpaceId, options) {
|
|
|
25591
25266
|
const subjectWarnings = [];
|
|
25592
25267
|
const warnedMemoryIds = [];
|
|
25593
25268
|
if (target.kind === "team") {
|
|
25594
|
-
const sourceFiles =
|
|
25269
|
+
const sourceFiles = fs6.existsSync(source.memoryDir) ? walkMd(fs6.realpathSync(source.memoryDir)) : [];
|
|
25595
25270
|
for (const file of sourceFiles) {
|
|
25596
|
-
const fm = parseSimpleFrontmatter(
|
|
25271
|
+
const fm = parseSimpleFrontmatter(fs6.readFileSync(file, "utf8"));
|
|
25597
25272
|
if (!fm?.id) continue;
|
|
25598
25273
|
if (options?.memoryIds?.length && !options.memoryIds.includes(fm.id)) continue;
|
|
25599
25274
|
const decision = evaluateSubjectGuard({
|
|
@@ -25659,39 +25334,39 @@ async function mergeSpaces(sourceSpaceId, targetSpaceId, options) {
|
|
|
25659
25334
|
};
|
|
25660
25335
|
}
|
|
25661
25336
|
function getAuditLog(baseDir) {
|
|
25662
|
-
const auditPath =
|
|
25663
|
-
if (!
|
|
25664
|
-
const lines =
|
|
25337
|
+
const auditPath = path30.join(getSpacesDir(baseDir), "audit.jsonl");
|
|
25338
|
+
if (!fs6.existsSync(auditPath)) return [];
|
|
25339
|
+
const lines = fs6.readFileSync(auditPath, "utf8").trim().split("\n");
|
|
25665
25340
|
return lines.filter((l) => l.trim()).map((l) => JSON.parse(l));
|
|
25666
25341
|
}
|
|
25667
25342
|
function appendAudit(entry, baseDir) {
|
|
25668
|
-
const auditPath =
|
|
25669
|
-
|
|
25343
|
+
const auditPath = path30.join(getSpacesDir(baseDir), "audit.jsonl");
|
|
25344
|
+
fs6.mkdirSync(path30.dirname(auditPath), { recursive: true });
|
|
25670
25345
|
const full = {
|
|
25671
25346
|
id: crypto7.randomUUID(),
|
|
25672
25347
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
25673
25348
|
...entry
|
|
25674
25349
|
};
|
|
25675
|
-
|
|
25350
|
+
fs6.appendFileSync(auditPath, `${JSON.stringify(full)}
|
|
25676
25351
|
`);
|
|
25677
25352
|
}
|
|
25678
25353
|
async function copyMemories(sourceDir, targetDir, options) {
|
|
25679
|
-
if (!
|
|
25354
|
+
if (!fs6.existsSync(sourceDir)) {
|
|
25680
25355
|
return { merged: 0, conflicts: [], skipped: 0 };
|
|
25681
25356
|
}
|
|
25682
|
-
const sourceRoot =
|
|
25683
|
-
|
|
25684
|
-
const targetRoot =
|
|
25685
|
-
const sourceFiles =
|
|
25357
|
+
const sourceRoot = fs6.realpathSync(sourceDir);
|
|
25358
|
+
fs6.mkdirSync(targetDir, { recursive: true });
|
|
25359
|
+
const targetRoot = fs6.realpathSync(targetDir);
|
|
25360
|
+
const sourceFiles = walkMd(sourceRoot);
|
|
25686
25361
|
const sourceEntityIds = new Set(
|
|
25687
25362
|
sourceFiles.filter((p) => {
|
|
25688
25363
|
const rp = safeRealpath(p);
|
|
25689
25364
|
if (!rp || !isPathInsideRoot(rp, sourceRoot)) return false;
|
|
25690
|
-
const rel =
|
|
25691
|
-
const mapped =
|
|
25365
|
+
const rel = path30.relative(sourceRoot, rp);
|
|
25366
|
+
const mapped = path30.resolve(targetRoot, rel);
|
|
25692
25367
|
if (!isPathInsideRoot(mapped, targetRoot)) return false;
|
|
25693
25368
|
return classifyEntityRefWritePath(targetRoot, mapped) === "entity";
|
|
25694
|
-
}).map((p) =>
|
|
25369
|
+
}).map((p) => path30.basename(p, ".md"))
|
|
25695
25370
|
);
|
|
25696
25371
|
const firstEntityId = sourceEntityIds.values().next().value;
|
|
25697
25372
|
if (firstEntityId === void 0) {
|
|
@@ -25699,7 +25374,7 @@ async function copyMemories(sourceDir, targetDir, options) {
|
|
|
25699
25374
|
}
|
|
25700
25375
|
return withRawEntityPageMutation(
|
|
25701
25376
|
targetRoot,
|
|
25702
|
-
|
|
25377
|
+
path30.join(targetRoot, "entities", `${firstEntityId}.md`),
|
|
25703
25378
|
async () => copyPreparedMemories(
|
|
25704
25379
|
sourceFiles,
|
|
25705
25380
|
sourceRoot,
|
|
@@ -25725,15 +25400,15 @@ function copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityI
|
|
|
25725
25400
|
skipped++;
|
|
25726
25401
|
continue;
|
|
25727
25402
|
}
|
|
25728
|
-
const content =
|
|
25729
|
-
const relativePath =
|
|
25730
|
-
const targetPath =
|
|
25403
|
+
const content = fs6.readFileSync(sourcePath, "utf8");
|
|
25404
|
+
const relativePath = path30.relative(sourceRoot, sourceRealPath);
|
|
25405
|
+
const targetPath = path30.resolve(targetRoot, relativePath);
|
|
25731
25406
|
if (!isPathInsideRoot(targetPath, targetRoot)) {
|
|
25732
25407
|
skipped++;
|
|
25733
25408
|
continue;
|
|
25734
25409
|
}
|
|
25735
25410
|
const targetKind = classifyEntityRefWritePath(targetRoot, targetPath);
|
|
25736
|
-
const idsAtCompare =
|
|
25411
|
+
const idsAtCompare = historicalIdCache3.get(path30.join(targetRoot, "state"));
|
|
25737
25412
|
const sourceRef = targetKind === "memory" ? readEntityRefFromFrontmatter(content) : null;
|
|
25738
25413
|
const refHasSourceClaimant = sourceRef !== null && sourceEntityIds.has(sourceRef);
|
|
25739
25414
|
const canonicalContent = targetKind === "memory" && !refHasSourceClaimant ? canonicalizeEntityRefFrontmatter(content, idsAtCompare) : content;
|
|
@@ -25745,7 +25420,7 @@ function copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityI
|
|
|
25745
25420
|
continue;
|
|
25746
25421
|
}
|
|
25747
25422
|
}
|
|
25748
|
-
if (
|
|
25423
|
+
if (fs6.existsSync(targetPath)) {
|
|
25749
25424
|
const targetStat = safeLstat(targetPath);
|
|
25750
25425
|
if (!targetStat?.isFile() || targetStat.isSymbolicLink()) {
|
|
25751
25426
|
skipped++;
|
|
@@ -25757,10 +25432,10 @@ function copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityI
|
|
|
25757
25432
|
continue;
|
|
25758
25433
|
}
|
|
25759
25434
|
}
|
|
25760
|
-
if (
|
|
25761
|
-
const targetContent =
|
|
25435
|
+
if (fs6.existsSync(targetPath) && !options?.force) {
|
|
25436
|
+
const targetContent = fs6.readFileSync(targetPath, "utf8");
|
|
25762
25437
|
const targetHash = hashContent4(targetContent);
|
|
25763
|
-
if (hashContent4(canonicalContent) === targetHash &&
|
|
25438
|
+
if (hashContent4(canonicalContent) === targetHash && historicalIdCache3.get(path30.join(targetRoot, "state")) === idsAtCompare) {
|
|
25764
25439
|
skipped++;
|
|
25765
25440
|
continue;
|
|
25766
25441
|
}
|
|
@@ -25776,48 +25451,48 @@ function copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityI
|
|
|
25776
25451
|
continue;
|
|
25777
25452
|
}
|
|
25778
25453
|
}
|
|
25779
|
-
|
|
25780
|
-
const targetParentRealPath = safeRealpath(
|
|
25454
|
+
fs6.mkdirSync(path30.dirname(targetPath), { recursive: true });
|
|
25455
|
+
const targetParentRealPath = safeRealpath(path30.dirname(targetPath));
|
|
25781
25456
|
if (!targetParentRealPath || !isPathInsideRoot(targetParentRealPath, targetRoot)) {
|
|
25782
25457
|
skipped++;
|
|
25783
25458
|
continue;
|
|
25784
25459
|
}
|
|
25785
|
-
const stateDir =
|
|
25460
|
+
const stateDir = path30.join(targetRoot, "state");
|
|
25786
25461
|
if (targetKind === "memory" && !refHasSourceClaimant) {
|
|
25787
|
-
const idsAtWrite =
|
|
25462
|
+
const idsAtWrite = historicalIdCache3.get(stateDir);
|
|
25788
25463
|
const written = canonicalizeEntityRefFrontmatter(content, idsAtWrite);
|
|
25789
25464
|
let priorTarget = null;
|
|
25790
25465
|
try {
|
|
25791
|
-
priorTarget =
|
|
25466
|
+
priorTarget = fs6.readFileSync(targetPath, "utf8");
|
|
25792
25467
|
} catch {
|
|
25793
25468
|
priorTarget = null;
|
|
25794
25469
|
}
|
|
25795
|
-
|
|
25470
|
+
fs6.writeFileSync(targetPath, written);
|
|
25796
25471
|
try {
|
|
25797
25472
|
repairContentAfterJournalMoveSync({
|
|
25798
25473
|
stateDir,
|
|
25799
|
-
cache:
|
|
25474
|
+
cache: historicalIdCache3,
|
|
25800
25475
|
idsAtWrite,
|
|
25801
25476
|
rawContent: content,
|
|
25802
25477
|
lastWritten: written,
|
|
25803
|
-
rewrite: (next) =>
|
|
25478
|
+
rewrite: (next) => fs6.writeFileSync(targetPath, next)
|
|
25804
25479
|
});
|
|
25805
25480
|
} catch (err) {
|
|
25806
25481
|
try {
|
|
25807
25482
|
if (priorTarget === null) {
|
|
25808
|
-
|
|
25483
|
+
fs6.unlinkSync(targetPath);
|
|
25809
25484
|
} else {
|
|
25810
|
-
|
|
25485
|
+
fs6.writeFileSync(targetPath, priorTarget);
|
|
25811
25486
|
}
|
|
25812
25487
|
} catch {
|
|
25813
25488
|
}
|
|
25814
25489
|
throw err;
|
|
25815
25490
|
}
|
|
25816
25491
|
} else if (targetKind === "memory") {
|
|
25817
|
-
|
|
25492
|
+
fs6.writeFileSync(targetPath, content);
|
|
25818
25493
|
reconcileNeeded = true;
|
|
25819
25494
|
} else {
|
|
25820
|
-
|
|
25495
|
+
fs6.writeFileSync(targetPath, content);
|
|
25821
25496
|
if (targetKind === "entity") {
|
|
25822
25497
|
reconcileNeeded = true;
|
|
25823
25498
|
}
|
|
@@ -25826,18 +25501,18 @@ function copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityI
|
|
|
25826
25501
|
bumpMemoryCorpusVersionForDir(targetRoot);
|
|
25827
25502
|
}
|
|
25828
25503
|
if (reconcileNeeded) {
|
|
25829
|
-
requestEntityCanonicalIdReconcileSync(
|
|
25504
|
+
requestEntityCanonicalIdReconcileSync(path30.join(targetRoot, "state"));
|
|
25830
25505
|
}
|
|
25831
25506
|
return { merged, conflicts, skipped };
|
|
25832
25507
|
}
|
|
25833
25508
|
function hashContent4(content) {
|
|
25834
25509
|
return crypto7.createHash("sha256").update(content).digest("hex").slice(0, 16);
|
|
25835
25510
|
}
|
|
25836
|
-
function
|
|
25511
|
+
function walkMd(dir) {
|
|
25837
25512
|
const results = [];
|
|
25838
25513
|
function walk(d) {
|
|
25839
|
-
for (const entry of
|
|
25840
|
-
const fullPath =
|
|
25514
|
+
for (const entry of fs6.readdirSync(d, { withFileTypes: true })) {
|
|
25515
|
+
const fullPath = path30.join(d, entry.name);
|
|
25841
25516
|
if (entry.isSymbolicLink()) {
|
|
25842
25517
|
continue;
|
|
25843
25518
|
}
|
|
@@ -25853,21 +25528,21 @@ function walkMd2(dir) {
|
|
|
25853
25528
|
}
|
|
25854
25529
|
function safeLstat(filePath) {
|
|
25855
25530
|
try {
|
|
25856
|
-
return
|
|
25531
|
+
return fs6.lstatSync(filePath);
|
|
25857
25532
|
} catch {
|
|
25858
25533
|
return null;
|
|
25859
25534
|
}
|
|
25860
25535
|
}
|
|
25861
25536
|
function safeRealpath(filePath) {
|
|
25862
25537
|
try {
|
|
25863
|
-
return
|
|
25538
|
+
return fs6.realpathSync(filePath);
|
|
25864
25539
|
} catch {
|
|
25865
25540
|
return null;
|
|
25866
25541
|
}
|
|
25867
25542
|
}
|
|
25868
25543
|
function isPathInsideRoot(candidatePath, rootPath) {
|
|
25869
|
-
const relative =
|
|
25870
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
25544
|
+
const relative = path30.relative(rootPath, candidatePath);
|
|
25545
|
+
return relative === "" || !relative.startsWith("..") && !path30.isAbsolute(relative);
|
|
25871
25546
|
}
|
|
25872
25547
|
function parseSimpleFrontmatter(content) {
|
|
25873
25548
|
const match = content.match(/^---\n([\s\S]*?)\n---/);
|
|
@@ -25986,9 +25661,9 @@ var REMNIC_RECALL_DECISION_RULES = `## When to Use Recall vs Direct Read
|
|
|
25986
25661
|
`;
|
|
25987
25662
|
|
|
25988
25663
|
// src/memory-extension/codex-publisher.ts
|
|
25989
|
-
import
|
|
25664
|
+
import fs7 from "fs";
|
|
25990
25665
|
import os from "os";
|
|
25991
|
-
import
|
|
25666
|
+
import path31 from "path";
|
|
25992
25667
|
var REMNIC_EXTENSION_DIR_NAME = "remnic";
|
|
25993
25668
|
function resolveEnvHome(env) {
|
|
25994
25669
|
if (env === void 0) return resolveHomeDir();
|
|
@@ -25997,12 +25672,12 @@ function resolveEnvHome(env) {
|
|
|
25997
25672
|
function expandTildeWithHome(input, homeDir) {
|
|
25998
25673
|
if (input === "~") return homeDir;
|
|
25999
25674
|
if (input.startsWith("~/") || input.startsWith("~\\")) {
|
|
26000
|
-
return
|
|
25675
|
+
return path31.join(homeDir, input.slice(2));
|
|
26001
25676
|
}
|
|
26002
25677
|
return input;
|
|
26003
25678
|
}
|
|
26004
25679
|
function normalizeHostRoot(input, homeDir) {
|
|
26005
|
-
return
|
|
25680
|
+
return path31.resolve(expandTildeWithHome(input.trim(), homeDir));
|
|
26006
25681
|
}
|
|
26007
25682
|
var CodexMemoryExtensionPublisher = class {
|
|
26008
25683
|
hostId = "codex";
|
|
@@ -26016,13 +25691,13 @@ var CodexMemoryExtensionPublisher = class {
|
|
|
26016
25691
|
async resolveExtensionRoot(env) {
|
|
26017
25692
|
const homeDir = resolveEnvHome(env);
|
|
26018
25693
|
const codexHomeInput = env === void 0 ? readEnvVar("CODEX_HOME")?.trim() : env.CODEX_HOME?.trim();
|
|
26019
|
-
const codexHome = codexHomeInput ? normalizeHostRoot(codexHomeInput, homeDir) :
|
|
26020
|
-
return
|
|
25694
|
+
const codexHome = codexHomeInput ? normalizeHostRoot(codexHomeInput, homeDir) : path31.resolve(homeDir, ".codex");
|
|
25695
|
+
return path31.join(codexHome, "memories_extensions", REMNIC_EXTENSION_DIR_NAME);
|
|
26021
25696
|
}
|
|
26022
25697
|
async isHostAvailable() {
|
|
26023
25698
|
try {
|
|
26024
|
-
const home = readEnvVar("CODEX_HOME")?.trim() ||
|
|
26025
|
-
return
|
|
25699
|
+
const home = readEnvVar("CODEX_HOME")?.trim() || path31.join(resolveHomeDir(), ".codex");
|
|
25700
|
+
return fs7.existsSync(home);
|
|
26026
25701
|
} catch {
|
|
26027
25702
|
return false;
|
|
26028
25703
|
}
|
|
@@ -26072,22 +25747,22 @@ When running inside the Codex phase-2 consolidation sandbox:
|
|
|
26072
25747
|
}
|
|
26073
25748
|
async publish(ctx) {
|
|
26074
25749
|
const extensionRoot = await this.resolveExtensionRoot();
|
|
26075
|
-
const instructionsPath =
|
|
25750
|
+
const instructionsPath = path31.join(extensionRoot, "instructions.md");
|
|
26076
25751
|
const filesWritten = [];
|
|
26077
25752
|
const skipped = [];
|
|
26078
25753
|
ctx.log.info(`Publishing Codex memory extension to ${extensionRoot}`);
|
|
26079
|
-
|
|
25754
|
+
fs7.mkdirSync(extensionRoot, { recursive: true });
|
|
26080
25755
|
const content = await this.renderInstructions(ctx);
|
|
26081
25756
|
const tmpPath = `${instructionsPath}.tmp-${process.pid}-${Date.now()}`;
|
|
26082
25757
|
try {
|
|
26083
|
-
|
|
26084
|
-
|
|
25758
|
+
fs7.writeFileSync(tmpPath, content, "utf-8");
|
|
25759
|
+
fs7.renameSync(tmpPath, instructionsPath);
|
|
26085
25760
|
filesWritten.push(instructionsPath);
|
|
26086
25761
|
ctx.log.info(`Wrote ${instructionsPath}`);
|
|
26087
25762
|
} catch (err) {
|
|
26088
25763
|
try {
|
|
26089
|
-
if (
|
|
26090
|
-
|
|
25764
|
+
if (fs7.existsSync(tmpPath)) {
|
|
25765
|
+
fs7.unlinkSync(tmpPath);
|
|
26091
25766
|
}
|
|
26092
25767
|
} catch {
|
|
26093
25768
|
}
|
|
@@ -26102,8 +25777,8 @@ When running inside the Codex phase-2 consolidation sandbox:
|
|
|
26102
25777
|
}
|
|
26103
25778
|
async unpublish() {
|
|
26104
25779
|
const extensionRoot = await this.resolveExtensionRoot();
|
|
26105
|
-
if (
|
|
26106
|
-
|
|
25780
|
+
if (fs7.existsSync(extensionRoot)) {
|
|
25781
|
+
fs7.rmSync(extensionRoot, { recursive: true, force: true });
|
|
26107
25782
|
}
|
|
26108
25783
|
}
|
|
26109
25784
|
};
|
|
@@ -26448,7 +26123,7 @@ async function generateActivityMemories(date, digestBody, config, deps) {
|
|
|
26448
26123
|
// src/session-summaries/index.ts
|
|
26449
26124
|
import { createHash as createHash9 } from "crypto";
|
|
26450
26125
|
import { lstat as lstat3, mkdir as mkdir7, readFile as readFile7, readdir as readdir4, rename, rm, stat as stat4, writeFile as writeFile7 } from "fs/promises";
|
|
26451
|
-
import
|
|
26126
|
+
import path32 from "path";
|
|
26452
26127
|
|
|
26453
26128
|
// src/session-summaries/adapters.ts
|
|
26454
26129
|
var VALID_ROLES = /* @__PURE__ */ new Set(["user", "assistant", "tool", "system", "other"]);
|
|
@@ -26953,7 +26628,7 @@ function shortHash(value, length = 16) {
|
|
|
26953
26628
|
async function listTranscriptFiles(root, maxFiles) {
|
|
26954
26629
|
const out = [];
|
|
26955
26630
|
let truncated = false;
|
|
26956
|
-
const entrySortKey = (entryName, isDirectory) => isDirectory ? `${entryName}${
|
|
26631
|
+
const entrySortKey = (entryName, isDirectory) => isDirectory ? `${entryName}${path32.sep}` : entryName;
|
|
26957
26632
|
async function visit(dir) {
|
|
26958
26633
|
if (truncated) return;
|
|
26959
26634
|
const entries = (await readdir4(dir, { withFileTypes: true })).sort(
|
|
@@ -26963,13 +26638,13 @@ async function listTranscriptFiles(root, maxFiles) {
|
|
|
26963
26638
|
if (truncated) return;
|
|
26964
26639
|
if (entry.name.startsWith(".")) continue;
|
|
26965
26640
|
if (entry.isSymbolicLink()) continue;
|
|
26966
|
-
const fullPath =
|
|
26641
|
+
const fullPath = path32.join(dir, entry.name);
|
|
26967
26642
|
if (entry.isDirectory()) {
|
|
26968
26643
|
await visit(fullPath);
|
|
26969
26644
|
continue;
|
|
26970
26645
|
}
|
|
26971
26646
|
if (!entry.isFile()) continue;
|
|
26972
|
-
const ext =
|
|
26647
|
+
const ext = path32.extname(entry.name).toLowerCase();
|
|
26973
26648
|
if (!SUPPORTED_EXTENSIONS.has(ext)) continue;
|
|
26974
26649
|
out.push(fullPath);
|
|
26975
26650
|
if (out.length > maxFiles) {
|
|
@@ -26996,7 +26671,7 @@ function normalizeInputDir(inputDir) {
|
|
|
26996
26671
|
if (typeof inputDir !== "string" || inputDir.trim().length === 0) {
|
|
26997
26672
|
throw new Error("inputDir must be a non-empty string");
|
|
26998
26673
|
}
|
|
26999
|
-
return
|
|
26674
|
+
return path32.resolve(expandTildePath(inputDir.trim()));
|
|
27000
26675
|
}
|
|
27001
26676
|
function initRoleCounts() {
|
|
27002
26677
|
return {
|
|
@@ -27153,11 +26828,11 @@ async function collectLocalSessionSummaries(options) {
|
|
|
27153
26828
|
continue;
|
|
27154
26829
|
}
|
|
27155
26830
|
seenFileHashes.add(fileHash);
|
|
27156
|
-
const fileExtension =
|
|
26831
|
+
const fileExtension = path32.extname(filePath).toLowerCase();
|
|
27157
26832
|
const parsed = await adapter.parseFile(
|
|
27158
26833
|
{
|
|
27159
26834
|
content,
|
|
27160
|
-
fileName:
|
|
26835
|
+
fileName: path32.basename(filePath),
|
|
27161
26836
|
fileExtension,
|
|
27162
26837
|
fileRef: fileHash
|
|
27163
26838
|
},
|
|
@@ -27213,7 +26888,7 @@ async function collectLocalSessionSummaries(options) {
|
|
|
27213
26888
|
}
|
|
27214
26889
|
async function readRedactionConfig(pathLike) {
|
|
27215
26890
|
if (!pathLike) return void 0;
|
|
27216
|
-
const raw = await readFile7(
|
|
26891
|
+
const raw = await readFile7(path32.resolve(expandTildePath(pathLike)), "utf-8");
|
|
27217
26892
|
const parsed = JSON.parse(raw);
|
|
27218
26893
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
27219
26894
|
throw new Error("redaction config must be a JSON object");
|
|
@@ -27226,15 +26901,15 @@ function toJsonl(drafts) {
|
|
|
27226
26901
|
}
|
|
27227
26902
|
function defaultDraftOutputPath(memoryDir, generatedAt) {
|
|
27228
26903
|
const stamp = generatedAt.replace(/[:.]/g, "-");
|
|
27229
|
-
return
|
|
27230
|
-
|
|
26904
|
+
return path32.join(
|
|
26905
|
+
path32.resolve(expandTildePath(memoryDir)),
|
|
27231
26906
|
"state",
|
|
27232
26907
|
"session-summary-drafts",
|
|
27233
26908
|
`session-summaries-${stamp}.jsonl`
|
|
27234
26909
|
);
|
|
27235
26910
|
}
|
|
27236
26911
|
async function writeDrafts(filePath, drafts) {
|
|
27237
|
-
await mkdir7(
|
|
26912
|
+
await mkdir7(path32.dirname(filePath), { recursive: true });
|
|
27238
26913
|
const tempPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
27239
26914
|
try {
|
|
27240
26915
|
await writeFile7(tempPath, toJsonl(drafts), "utf-8");
|
|
@@ -27252,7 +26927,7 @@ async function runLocalSessionSummaryCliCommand(options) {
|
|
|
27252
26927
|
});
|
|
27253
26928
|
const wroteFiles = [];
|
|
27254
26929
|
if (options.output) {
|
|
27255
|
-
const outputPath =
|
|
26930
|
+
const outputPath = path32.resolve(expandTildePath(options.output));
|
|
27256
26931
|
await writeDrafts(outputPath, report.drafts);
|
|
27257
26932
|
wroteFiles.push(outputPath);
|
|
27258
26933
|
}
|
|
@@ -27287,19 +26962,19 @@ async function runLocalSessionSummaryCliCommand(options) {
|
|
|
27287
26962
|
|
|
27288
26963
|
// src/transfer/capsule-fork.ts
|
|
27289
26964
|
import { lstat as lstat4, mkdir as mkdir8, readFile as readFile8, realpath as realpath3, writeFile as writeFile8 } from "fs/promises";
|
|
27290
|
-
import
|
|
26965
|
+
import path33 from "path";
|
|
27291
26966
|
async function forkCapsule(opts) {
|
|
27292
26967
|
validateForkId(opts.forkId);
|
|
27293
|
-
const rootAbs =
|
|
26968
|
+
const rootAbs = path33.resolve(opts.targetRoot);
|
|
27294
26969
|
await assertIsDirectoryNotSymlink(rootAbs, "forkCapsule", "targetRoot");
|
|
27295
|
-
const forkDirAbs =
|
|
26970
|
+
const forkDirAbs = path33.join(rootAbs, "forks", opts.forkId);
|
|
27296
26971
|
const forkEntryExists = await pathEntryExists(forkDirAbs);
|
|
27297
26972
|
if (forkEntryExists) {
|
|
27298
26973
|
throw new Error(
|
|
27299
26974
|
`forkCapsule: fork path already exists \u2014 forkId "${opts.forkId}" is already in use at: ${forkDirAbs}`
|
|
27300
26975
|
);
|
|
27301
26976
|
}
|
|
27302
|
-
const archiveAbs =
|
|
26977
|
+
const archiveAbs = path33.resolve(opts.sourceArchive);
|
|
27303
26978
|
const importResult = await importCapsule({
|
|
27304
26979
|
archivePath: archiveAbs,
|
|
27305
26980
|
root: rootAbs,
|
|
@@ -27321,10 +26996,10 @@ async function forkCapsule(opts) {
|
|
|
27321
26996
|
importedRecords: importResult.imported.length,
|
|
27322
26997
|
skippedRecords: importResult.skipped.length
|
|
27323
26998
|
};
|
|
27324
|
-
const lineagePath =
|
|
26999
|
+
const lineagePath = path33.join(forkDirAbs, "lineage.json");
|
|
27325
27000
|
const rootReal = await realpath3(rootAbs);
|
|
27326
27001
|
await assertRealpathInsideRoot(rootReal, lineagePath, `forks/${opts.forkId}/lineage.json`, "forkCapsule");
|
|
27327
|
-
await mkdir8(
|
|
27002
|
+
await mkdir8(path33.dirname(lineagePath), { recursive: true });
|
|
27328
27003
|
await writeFile8(lineagePath, JSON.stringify(lineage, null, 2) + "\n", "utf-8");
|
|
27329
27004
|
return {
|
|
27330
27005
|
archivePath: archiveAbs,
|
|
@@ -27338,11 +27013,11 @@ async function readForkLineage(targetRoot, forkId) {
|
|
|
27338
27013
|
if (typeof forkId !== "string" || forkId.length === 0 || forkId.length > 64 || !CAPSULE_ID_PATTERN.test(forkId)) {
|
|
27339
27014
|
return null;
|
|
27340
27015
|
}
|
|
27341
|
-
const rootAbs =
|
|
27016
|
+
const rootAbs = path33.resolve(targetRoot);
|
|
27342
27017
|
const rootReal = await realpath3(rootAbs).catch(() => rootAbs);
|
|
27343
|
-
const lineagePath =
|
|
27344
|
-
const rel =
|
|
27345
|
-
if (rel.startsWith("..") ||
|
|
27018
|
+
const lineagePath = path33.join(rootReal, "forks", forkId, "lineage.json");
|
|
27019
|
+
const rel = path33.relative(rootReal, lineagePath);
|
|
27020
|
+
if (rel.startsWith("..") || path33.isAbsolute(rel)) {
|
|
27346
27021
|
return null;
|
|
27347
27022
|
}
|
|
27348
27023
|
if (!await isLineagePathContained(rootReal, lineagePath)) {
|
|
@@ -27383,23 +27058,26 @@ async function pathEntryExists(absPath) {
|
|
|
27383
27058
|
async function isLineagePathContained(rootReal, lineagePath) {
|
|
27384
27059
|
let existing = lineagePath;
|
|
27385
27060
|
const suffix = [];
|
|
27386
|
-
while (existing !==
|
|
27061
|
+
while (existing !== path33.dirname(existing)) {
|
|
27387
27062
|
const st = await lstat4(existing).catch(() => null);
|
|
27388
27063
|
if (st !== null) break;
|
|
27389
|
-
suffix.unshift(
|
|
27390
|
-
existing =
|
|
27064
|
+
suffix.unshift(path33.basename(existing));
|
|
27065
|
+
existing = path33.dirname(existing);
|
|
27391
27066
|
}
|
|
27392
27067
|
const existingReal = await realpath3(existing).catch(() => existing);
|
|
27393
|
-
const targetReal = suffix.length > 0 ?
|
|
27394
|
-
const rel =
|
|
27068
|
+
const targetReal = suffix.length > 0 ? path33.join(existingReal, ...suffix) : existingReal;
|
|
27069
|
+
const rel = path33.relative(rootReal, targetReal);
|
|
27395
27070
|
if (rel === "") return true;
|
|
27396
27071
|
if (rel === "..") return false;
|
|
27397
|
-
if (rel.startsWith(`..${
|
|
27398
|
-
if (
|
|
27072
|
+
if (rel.startsWith(`..${path33.sep}`)) return false;
|
|
27073
|
+
if (path33.isAbsolute(rel)) return false;
|
|
27399
27074
|
return true;
|
|
27400
27075
|
}
|
|
27401
27076
|
|
|
27402
27077
|
export {
|
|
27078
|
+
isPreferenceDriftStageActive,
|
|
27079
|
+
driftAgeNote,
|
|
27080
|
+
applyPreferenceDriftRanking,
|
|
27403
27081
|
buildProcedureRecallSection,
|
|
27404
27082
|
RELAY_DEMO_MISSION_ID,
|
|
27405
27083
|
RELAY_DEMO_NAMESPACE,
|
|
@@ -27438,8 +27116,6 @@ export {
|
|
|
27438
27116
|
findDuplicates,
|
|
27439
27117
|
findContradictions,
|
|
27440
27118
|
decideSemanticDedup,
|
|
27441
|
-
listReviewItems,
|
|
27442
|
-
performReview,
|
|
27443
27119
|
syncChanges,
|
|
27444
27120
|
watchForChanges,
|
|
27445
27121
|
getSpacesDir,
|
|
@@ -27514,4 +27190,4 @@ export {
|
|
|
27514
27190
|
blendGraphExpandedRecallScore,
|
|
27515
27191
|
Orchestrator
|
|
27516
27192
|
};
|
|
27517
|
-
//# sourceMappingURL=chunk-
|
|
27193
|
+
//# sourceMappingURL=chunk-ZPOHEB5Z.js.map
|