@remnic/core 9.69.51 → 9.69.53
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 +14 -14
- package/dist/access-admin-ops-surface.js +46 -46
- package/dist/access-authorization-probe.d.ts +14 -14
- package/dist/access-authorization-probe.js +47 -47
- package/dist/access-boundary.d.ts +14 -14
- package/dist/access-boundary.js +46 -46
- package/dist/access-cli.js +92 -92
- package/dist/access-coding-context-resolution.d.ts +1 -1
- package/dist/access-extraction-force-flush.d.ts +14 -14
- package/dist/access-extraction-force-flush.js +46 -46
- package/dist/access-health-types.d.ts +1 -1
- package/dist/access-http-briefing.d.ts +14 -14
- package/dist/access-http-briefing.js +47 -47
- package/dist/access-http-lcm-compaction.d.ts +14 -14
- package/dist/access-http-lifecycle-flush.d.ts +14 -14
- package/dist/access-http-offline-stream.d.ts +14 -14
- package/dist/access-http-query.d.ts +2 -2
- package/dist/access-http-query.js +48 -48
- package/dist/access-http.d.ts +15 -15
- package/dist/access-http.js +62 -62
- package/dist/access-identity-continuity-surface.d.ts +11 -11
- package/dist/access-identity-continuity-surface.js +46 -46
- package/dist/access-lcm-surface.d.ts +14 -14
- package/dist/access-lcm-surface.js +46 -46
- package/dist/access-mcp-shared-context-tools.d.ts +14 -14
- package/dist/access-mcp.d.ts +14 -14
- package/dist/access-mcp.js +55 -55
- package/dist/access-memory-search-fanout.d.ts +2 -2
- package/dist/{access-namespace-preflight-C1q3XuAc.d.ts → access-namespace-preflight-U9RAdxqZ.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +3 -3
- package/dist/access-namespace-preflight.js +46 -46
- package/dist/access-observe-transcript.d.ts +11 -11
- package/dist/access-observe-write-category.d.ts +3 -3
- package/dist/access-observe-write-category.js +2 -2
- package/dist/access-observe-write-surface.d.ts +14 -14
- package/dist/access-observe-write-surface.js +46 -46
- package/dist/access-offline-manifest.d.ts +11 -11
- package/dist/access-offline-manifest.js +5 -5
- package/dist/access-operations-batch.js +47 -47
- package/dist/access-operations.d.ts +14 -14
- package/dist/access-operations.js +54 -54
- package/dist/access-recall-concurrency.d.ts +14 -14
- package/dist/access-recall-concurrency.js +46 -46
- package/dist/access-recall-response.d.ts +14 -14
- package/dist/access-recall-response.js +46 -46
- package/dist/access-recall-surface.d.ts +14 -14
- package/dist/access-recall-surface.js +46 -46
- package/dist/access-schema.d.ts +114 -114
- package/dist/{access-service-BZaC-RZw.d.ts → access-service-H-qEdnSs.d.ts} +73 -73
- package/dist/access-service-helpers.d.ts +14 -14
- package/dist/access-service.d.ts +14 -14
- package/dist/access-service.js +46 -46
- package/dist/access-surface-catalog.d.ts +14 -14
- package/dist/access-surface-catalog.js +48 -48
- package/dist/access-wearables-meetings-surface.d.ts +4 -4
- package/dist/action-confidence.d.ts +1 -1
- package/dist/active-memory-bridge.d.ts +1 -1
- package/dist/active-recall.d.ts +1 -1
- package/dist/active-recall.js +72 -1
- package/dist/active-recall.js.map +1 -1
- package/dist/activity/digest.d.ts +1 -1
- package/dist/ambient-provenance.d.ts +1 -1
- package/dist/artifact-search.d.ts +1 -1
- package/dist/{auto-sync-DG5KEOF5.js → auto-sync-CWSZDLLW.js} +6 -6
- package/dist/background-generation.d.ts +1 -1
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +11 -11
- package/dist/briefing-window.d.ts +2 -2
- package/dist/briefing.d.ts +2 -2
- package/dist/briefing.js +9 -9
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer-turn-helpers.d.ts +1 -1
- package/dist/buffer.d.ts +2 -2
- package/dist/buffer.js +4 -4
- package/dist/bulk-import/index.d.ts +3 -3
- package/dist/calibration.d.ts +1 -1
- package/dist/capabilities.d.ts +1 -1
- package/dist/{catalog-DK2eHhax.d.ts → catalog-BuMyYPUn.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-consolidation.d.ts +1 -1
- package/dist/causal-consolidation.js +16 -16
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/{chunk-2ERLN25A.js → chunk-2HJKAVAS.js} +5 -5
- package/dist/{chunk-CKBA2MWS.js → chunk-2QZJ4P27.js} +2 -2
- package/dist/{chunk-ETNC6TT6.js → chunk-43IQRLEF.js} +2 -2
- package/dist/{chunk-PQWICTRO.js → chunk-4UVJ6EIT.js} +1 -1
- package/dist/chunk-4UVJ6EIT.js.map +1 -0
- package/dist/{chunk-DQSVGTKB.js → chunk-6UEM5EOB.js} +2 -2
- package/dist/{chunk-JGPG5UHM.js → chunk-7QVYVSEH.js} +2 -2
- package/dist/{chunk-HEKWNWNL.js → chunk-7RKAE6Y4.js} +3 -3
- package/dist/{chunk-UP3226JC.js → chunk-A4TQFNRX.js} +5 -5
- package/dist/{chunk-T73ZC7C5.js → chunk-AH44WTLJ.js} +2 -2
- package/dist/{chunk-SZ75IB2T.js → chunk-AQWGCHIV.js} +6 -6
- package/dist/{chunk-Q6OC4UUT.js → chunk-ARRKSBQU.js} +5 -5
- package/dist/{chunk-6Z4OLQUO.js → chunk-AYHNTYVG.js} +2 -2
- package/dist/{chunk-XHDQQ2TT.js → chunk-BCXZ4BDS.js} +2 -2
- package/dist/{chunk-VLR4S5GF.js → chunk-CO7KBRPF.js} +3 -3
- package/dist/{chunk-JHUODJRW.js → chunk-D2N3PMAE.js} +2 -2
- package/dist/{chunk-7SJCSDQ3.js → chunk-D7VT2LED.js} +2 -2
- package/dist/{chunk-X25NTN3W.js → chunk-DI52XAKG.js} +2 -2
- package/dist/{chunk-EUP4AXIW.js → chunk-DZP2XMZC.js} +2 -2
- package/dist/{chunk-BULK6DGB.js → chunk-EQNZC3BH.js} +2 -2
- package/dist/{chunk-OIK3YL2P.js → chunk-EVQ33D3N.js} +4 -4
- package/dist/{chunk-MNF6PTNL.js → chunk-EYK3UHAP.js} +2 -2
- package/dist/{chunk-VSN2DMQK.js → chunk-G2DF5MI7.js} +4 -4
- package/dist/{chunk-JIWZVOQM.js → chunk-G7S37WD4.js} +2 -2
- package/dist/{chunk-2G2CVN2T.js → chunk-HUQMVI3A.js} +147 -58
- package/dist/chunk-HUQMVI3A.js.map +1 -0
- package/dist/{chunk-6HCJWCA4.js → chunk-IEOBAOA6.js} +6 -6
- package/dist/{chunk-UDAUULK2.js → chunk-IGEZE6QB.js} +5 -5
- package/dist/{chunk-SGHGCFVV.js → chunk-JE334SIA.js} +10 -10
- package/dist/{chunk-XFXVIXDI.js → chunk-JE4H2QBO.js} +2 -2
- package/dist/{chunk-33SX6K3N.js → chunk-JMZQS6OS.js} +2 -2
- package/dist/{chunk-BMAYH7F4.js → chunk-K7FXR75S.js} +514 -381
- package/dist/chunk-K7FXR75S.js.map +1 -0
- package/dist/{chunk-3RABJOGD.js → chunk-KH2D26LQ.js} +5 -5
- package/dist/{chunk-AH3OIMS7.js → chunk-KQQEZTH6.js} +2 -2
- package/dist/{chunk-QRSC37NC.js → chunk-M7HFDWOS.js} +3 -3
- package/dist/{chunk-2EICZYIG.js → chunk-MTJUIIM4.js} +2 -2
- package/dist/{chunk-ST7FDKZT.js → chunk-MWVYHNSU.js} +2 -2
- package/dist/{chunk-NXSNFPYI.js → chunk-MXTCV3B5.js} +2 -2
- package/dist/{chunk-O4JFBEUL.js → chunk-O7OVWKT4.js} +2 -2
- package/dist/{chunk-RIP2AOZW.js → chunk-QWQB7TOB.js} +19 -19
- package/dist/{chunk-PYTSGD5M.js → chunk-RSMNPYBM.js} +2 -2
- package/dist/{chunk-MYDA2GA2.js → chunk-RUUJXAGT.js} +2 -2
- package/dist/{chunk-YJJMJH6J.js → chunk-SEQ6DWXD.js} +11 -11
- package/dist/{chunk-SCM4VYJW.js → chunk-SLGD36MM.js} +3 -3
- package/dist/{chunk-KAPYPTPS.js → chunk-SOOWBRMH.js} +13 -13
- package/dist/{chunk-JG4AP36X.js → chunk-SPFNGHHP.js} +2 -2
- package/dist/{chunk-7TTOX6NW.js → chunk-SPWNCGSM.js} +2 -2
- package/dist/{chunk-3QZRSEAM.js → chunk-SZ7IVZGD.js} +2 -2
- package/dist/{chunk-IGDEKECC.js → chunk-TQT4AOPO.js} +4 -4
- package/dist/{chunk-NVW5ISEJ.js → chunk-TS66MUUJ.js} +50 -50
- package/dist/{chunk-6ZMIASYT.js → chunk-U2SK45U3.js} +2 -2
- package/dist/{chunk-72AV2H3R.js → chunk-U3NBO4IX.js} +39 -3
- package/dist/chunk-U3NBO4IX.js.map +1 -0
- package/dist/{chunk-SMI2G3MA.js → chunk-UCH2RWFX.js} +2 -2
- package/dist/{chunk-A33DLYNY.js → chunk-UDJMJNBK.js} +2 -2
- package/dist/{chunk-DLXBMXIB.js → chunk-UJBIWY5M.js} +5 -5
- package/dist/{chunk-25HSEIEM.js → chunk-ULQVG6G3.js} +2 -2
- package/dist/{chunk-EBJL6HGR.js → chunk-UVZBDIJX.js} +211 -1
- package/dist/chunk-UVZBDIJX.js.map +1 -0
- package/dist/{chunk-XRUOO7OT.js → chunk-VGO57TU7.js} +5 -5
- package/dist/{chunk-LX7KIJQF.js → chunk-VMKAA5SU.js} +2 -2
- package/dist/{chunk-KBHDV7P3.js → chunk-VUV472VH.js} +12 -12
- package/dist/{chunk-LZI6FWZW.js → chunk-WH7RINGG.js} +4 -4
- package/dist/{chunk-FDDCZDBI.js → chunk-WN4HFL4K.js} +4 -4
- package/dist/{chunk-ISA5U5AP.js → chunk-WUJD4CHZ.js} +4 -4
- package/dist/{chunk-UVEBBXB5.js → chunk-X7WAM3IY.js} +2 -2
- package/dist/{chunk-NROI5XMG.js → chunk-XPFJSUOR.js} +5 -5
- package/dist/{chunk-2SZBCM2S.js → chunk-Y4G6LHJW.js} +2 -2
- package/dist/{chunk-JXSOB3SA.js → chunk-Y7LZ5V7N.js} +2 -2
- package/dist/{chunk-YSBYNCCN.js → chunk-YLPCEUXP.js} +3 -3
- package/dist/{chunk-RFIJH2OE.js → chunk-YUHGJBQK.js} +2 -2
- package/dist/{chunk-DX63RFDJ.js → chunk-ZADYEZY4.js} +2 -2
- package/dist/{chunk-TNFDWJRS.js → chunk-ZANEMAEV.js} +2 -2
- package/dist/{cli-BHDMJqJS.d.ts → cli-VGDSn2zY.d.ts} +5 -5
- package/dist/cli.d.ts +16 -16
- package/dist/cli.js +75 -75
- package/dist/coding/export-okf-codegraph.d.ts +1 -1
- package/dist/coding/export-okf-codegraph.js +9 -9
- package/dist/coding/pre-action-gate.d.ts +1 -1
- package/dist/compounding/engine.d.ts +2 -2
- package/dist/compounding/engine.js +8 -8
- package/dist/compounding/preference-consolidator.d.ts +1 -1
- package/dist/compression-optimizer.d.ts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +72 -1
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +12 -12
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +16 -16
- package/dist/consolidation-provenance-check.d.ts +2 -2
- package/dist/consolidation-undo.d.ts +2 -2
- package/dist/contradiction/index.d.ts +4 -4
- package/dist/converge-config.d.ts +1 -1
- package/dist/convergence-refresh.d.ts +2 -2
- package/dist/convergence-refresh.js +10 -10
- package/dist/conversation-index/backend.d.ts +1 -1
- package/dist/conversation-index/chunker.d.ts +1 -1
- package/dist/conversation-index/faiss-adapter.d.ts +1 -1
- package/dist/conversation-index/indexer.d.ts +1 -1
- package/dist/conversation-index/search.d.ts +1 -1
- package/dist/corpus-watermark.d.ts +1 -1
- package/dist/corpus-watermark.js +10 -10
- package/dist/cross-lingual-recall.d.ts +1 -1
- package/dist/day-summary.d.ts +1 -1
- package/dist/deep-recall-http-glue.d.ts +14 -14
- package/dist/deep-recall-mcp-tools.d.ts +14 -14
- package/dist/deep-recall-policy-llm.d.ts +2 -2
- package/dist/deep-recall-seeds.d.ts +1 -1
- package/dist/delinearize.d.ts +1 -1
- package/dist/dependency-propagation-config.d.ts +1 -1
- package/dist/{dependency-propagation-delivery-BMkR4gmY.d.ts → dependency-propagation-delivery-BrhPjAHQ.d.ts} +1 -1
- package/dist/direct-answer-wiring.d.ts +1 -1
- package/dist/direct-answer.d.ts +1 -1
- package/dist/directory-sidecars.d.ts +30 -7
- package/dist/directory-sidecars.js +5 -1
- package/dist/embedding-fallback.d.ts +1 -1
- package/dist/enrichment/index.d.ts +1 -1
- package/dist/entity-origin-fields.d.ts +1 -1
- package/dist/entity-retrieval.d.ts +2 -2
- package/dist/entity-retrieval.js +8 -8
- package/dist/entity-schema.d.ts +1 -1
- package/dist/episodic-context.d.ts +1 -1
- package/dist/eval-trajectory-contracts.d.ts +1 -1
- package/dist/eval-trajectory-store.d.ts +1 -1
- package/dist/eval-trajectory.d.ts +1 -1
- package/dist/explicit-capture.d.ts +11 -11
- package/dist/external-wiki-access.d.ts +14 -14
- package/dist/external-wiki-access.js +47 -47
- package/dist/external-wiki-collection-registration.d.ts +1 -1
- package/dist/external-wiki-collection.d.ts +1 -1
- package/dist/external-wiki-mcp-tools.d.ts +14 -14
- package/dist/extraction-error-classification.d.ts +1 -1
- package/dist/extraction-evidence-class.d.ts +1 -1
- package/dist/extraction-faithfulness.d.ts +2 -2
- package/dist/extraction-judge-telemetry.d.ts +2 -2
- package/dist/extraction-judge-training.d.ts +2 -2
- package/dist/extraction-judge.d.ts +2 -2
- package/dist/extraction-judge.js +2 -2
- package/dist/extraction-liveness.d.ts +1 -1
- package/dist/extraction-normalization.d.ts +1 -1
- package/dist/extraction-prompt.d.ts +1 -1
- package/dist/extraction-source-grounding-rules.d.ts +1 -1
- package/dist/extraction-source-grounding.d.ts +1 -1
- package/dist/extraction-span-config.d.ts +1 -1
- package/dist/extraction-span-materialize.d.ts +1 -1
- package/dist/extraction-span-wire.d.ts +1 -1
- package/dist/extraction.d.ts +2 -2
- package/dist/extraction.js +18 -18
- package/dist/fallback-llm-codex-subscription.d.ts +1 -1
- package/dist/fallback-llm.d.ts +1 -1
- package/dist/{generic-recall-paths-BCRtXU32.d.ts → generic-recall-paths-C0J1Oxb7.d.ts} +1 -1
- package/dist/graph-append-error.d.ts +1 -1
- package/dist/graph-dashboard-diff.d.ts +1 -1
- package/dist/graph-dashboard-key.d.ts +1 -1
- package/dist/graph-dashboard-parser.d.ts +1 -1
- package/dist/graph-edge-reinforcement.d.ts +1 -1
- package/dist/graph-jsonl.d.ts +1 -1
- package/dist/graph-path-reconstruction.d.ts +1 -1
- package/dist/graph-path-scoring.d.ts +1 -1
- package/dist/graph-snapshot.d.ts +1 -1
- package/dist/graph.d.ts +1 -1
- package/dist/harmonic-retrieval.js +2 -2
- package/dist/importance.d.ts +1 -1
- package/dist/importers/index.d.ts +1 -1
- package/dist/importers/test-utils.d.ts +1 -1
- package/dist/in-flight-reads.d.ts +1 -1
- package/dist/{index-DMNTW4W6.d.ts → index-B735x-tK.d.ts} +3 -3
- package/dist/index.d.ts +702 -702
- package/dist/index.js +165 -165
- package/dist/intent.d.ts +1 -1
- package/dist/lcm/engine.d.ts +1 -1
- package/dist/lcm/index.d.ts +1 -1
- package/dist/lcm/tools.d.ts +1 -1
- package/dist/lifecycle.d.ts +1 -1
- package/dist/live-connectors-runner.d.ts +1 -1
- package/dist/{local-llm-BXYC-mbU.d.ts → local-llm-BkkEK9rn.d.ts} +1 -1
- package/dist/local-llm-helpers.d.ts +2 -2
- package/dist/local-llm.d.ts +2 -2
- package/dist/local-model-endpoint.d.ts +1 -1
- package/dist/location/index.d.ts +5 -5
- package/dist/location/index.js +12 -12
- package/dist/maintenance/memory-governance.d.ts +1 -1
- package/dist/maintenance/memory-governance.js +8 -8
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +8 -8
- package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-projection.js +9 -9
- package/dist/{maintenance-zJiLsKBY.d.ts → maintenance-CLBIvVxg.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +14 -14
- package/dist/memory-action-policy.d.ts +1 -1
- package/dist/memory-browse-http-glue.d.ts +14 -14
- package/dist/memory-browse-mcp-tools.d.ts +14 -14
- package/dist/memory-browse-operations.js +47 -47
- package/dist/memory-browse.d.ts +1 -1
- package/dist/memory-browse.js +5 -5
- package/dist/memory-cache.d.ts +1 -1
- package/dist/memory-controller.d.ts +1 -1
- package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
- package/dist/memory-projection-store.d.ts +1 -1
- package/dist/memory-provenance.d.ts +1 -1
- package/dist/memory-snapshot.d.ts +1 -1
- package/dist/memory-subject-cli.d.ts +14 -14
- package/dist/memory-subject.d.ts +14 -14
- package/dist/memory-worth-outcomes.d.ts +2 -2
- package/dist/models-json.d.ts +1 -1
- package/dist/namespaces/migrate.d.ts +3 -3
- package/dist/namespaces/migrate.js +9 -9
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/storage.d.ts +3 -3
- package/dist/namespaces/storage.js +8 -8
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/offline-sync-impression-drain.d.ts +1 -1
- package/dist/offline-sync-impression-drain.js +3 -3
- package/dist/operator-doctor-corpus.d.ts +1 -1
- package/dist/operator-doctor-corpus.js +13 -13
- package/dist/operator-doctor-replica.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +3 -3
- package/dist/operator-toolkit.js +36 -36
- package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
- package/dist/orchestration/maintenance.d.ts +4 -4
- package/dist/orchestration/maintenance.js +19 -19
- package/dist/{orchestrator-BTqT3F6X.d.ts → orchestrator-iexgVLow.d.ts} +13 -11
- package/dist/orchestrator.d.ts +11 -11
- package/dist/orchestrator.js +92 -92
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/{pipeline-CgO2Sd4O.d.ts → pipeline-DvtDtyo9.d.ts} +1 -1
- package/dist/policy-runtime.d.ts +1 -1
- package/dist/proactive-contention.d.ts +2 -2
- package/dist/provenance.d.ts +1 -1
- package/dist/{public-http-Dk1EA9ix.d.ts → public-http-P0cnHzYB.d.ts} +1 -1
- package/dist/{qmd-CwxtVz64.d.ts → qmd-CBYBJ6HW.d.ts} +1 -1
- package/dist/qmd-preflight.d.ts +2 -2
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd.d.ts +2 -2
- package/dist/recall-concurrency-config.d.ts +1 -1
- package/dist/recall-disclosure-escalation.d.ts +1 -1
- package/dist/recall-explain-renderer.d.ts +1 -1
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-memory-map.d.ts +1 -1
- package/dist/recall-navigate-access.d.ts +1 -1
- package/dist/recall-navigate-access.js +2 -2
- package/dist/recall-navigate-disclosure.d.ts +1 -1
- package/dist/recall-navigate-disclosure.js +2 -2
- package/dist/recall-navigate.d.ts +1 -1
- package/dist/recall-navigate.js +2 -2
- package/dist/recall-navigation-http-glue.d.ts +14 -14
- package/dist/recall-navigation-mcp-tools.d.ts +14 -14
- package/dist/recall-navigation-operations.js +47 -47
- package/dist/recall-navigation-renderer.d.ts +1 -1
- package/dist/recall-navigation.d.ts +1 -1
- package/dist/recall-navigation.js +46 -46
- package/dist/recall-planner-llm.d.ts +1 -1
- package/dist/recall-state-view-admission.d.ts +2 -2
- package/dist/recall-state-view-admission.js +5 -5
- package/dist/recall-state-view-anchors.d.ts +1 -1
- package/dist/recall-state-view-anchors.js +2 -2
- package/dist/recall-state.d.ts +1 -1
- package/dist/recall-tag-filter.d.ts +1 -1
- package/dist/recall-timings.d.ts +1 -1
- package/dist/recall-xray-cli.d.ts +1 -1
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.d.ts +1 -1
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.d.ts +1 -1
- package/dist/recall-xray.js +2 -2
- package/dist/reconcile/cursor.d.ts +1 -1
- package/dist/reconcile/manifest.d.ts +1 -1
- package/dist/reconcile/manifest.js +1 -1
- package/dist/reconcile/plan.d.ts +1 -1
- package/dist/replay/normalizers/chatgpt.d.ts +1 -1
- package/dist/replay/normalizers/claude.d.ts +1 -1
- package/dist/replay/normalizers/openclaw.d.ts +1 -1
- package/dist/replay/normalizers/shared.d.ts +1 -1
- package/dist/replay/runner.d.ts +1 -1
- package/dist/replay/types.d.ts +1 -1
- package/dist/replica-divergence.d.ts +1 -1
- package/dist/replica-peers-config.d.ts +1 -1
- package/dist/resolve-auth-token.d.ts +1 -1
- package/dist/resume-bundles.js +72 -2
- package/dist/retrieval-agents.d.ts +2 -2
- package/dist/retrieval-tiers.d.ts +1 -1
- package/dist/routing/engine.d.ts +1 -1
- package/dist/routing/store.d.ts +1 -1
- package/dist/salvage-envelope.d.ts +1 -1
- package/dist/schemas.d.ts +160 -160
- package/dist/{scope-profiles-Bg1rB-Dp.d.ts → scope-profiles-BN1Dgfha.d.ts} +1 -1
- package/dist/search/embed-helper.d.ts +1 -1
- package/dist/search/factory.d.ts +1 -1
- package/dist/search/index.d.ts +1 -1
- package/dist/search/lancedb-backend.d.ts +1 -1
- package/dist/search/meilisearch-backend.d.ts +1 -1
- package/dist/search/noop-backend.d.ts +1 -1
- package/dist/search/orama-backend.d.ts +1 -1
- package/dist/search/port.d.ts +1 -1
- package/dist/search/remote-backend.d.ts +1 -1
- package/dist/{semantic-consolidation-DEzRyeyn.d.ts → semantic-consolidation-D--qe0eE.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +13 -13
- package/dist/semantic-rule-promotion.js +8 -8
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +8 -8
- package/dist/{service-DGEIDOeD.d.ts → service-VealHeqO.d.ts} +2 -2
- package/dist/session-observer-bands.d.ts +1 -1
- package/dist/session-observer-state.d.ts +1 -1
- package/dist/shared-context/manager.d.ts +9 -9
- package/dist/signal.d.ts +1 -1
- package/dist/source-agent-qualifier.d.ts +1 -1
- package/dist/source-agent-qualifier.js +17 -17
- package/dist/standup/build.js +9 -9
- package/dist/{storage-DNQWtOSM.d.ts → storage-CMm-3aD3.d.ts} +1 -1
- package/dist/storage.d.ts +2 -2
- package/dist/storage.js +7 -7
- package/dist/subject-config.d.ts +1 -1
- package/dist/summarizer.d.ts +1 -1
- package/dist/summarizer.js +1 -1
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/support-passport/index.d.ts +17 -17
- package/dist/support-passport/index.js +49 -49
- package/dist/{tagging-CPVwgadt.d.ts → tagging-BjsNFKWz.d.ts} +2 -2
- package/dist/temporal-supersession.d.ts +2 -2
- package/dist/temporal-timeline-recall.d.ts +1 -1
- package/dist/temporal-validity.d.ts +1 -1
- package/dist/threading.d.ts +1 -1
- package/dist/tier-migration.d.ts +2 -2
- package/dist/tier-routing.d.ts +1 -1
- package/dist/topics.d.ts +1 -1
- package/dist/transcript.d.ts +1 -1
- package/dist/transfer/export-okf.d.ts +1 -1
- package/dist/transfer/export-okf.js +8 -8
- package/dist/transfer/types.d.ts +78 -78
- package/dist/trust-score-stage.d.ts +1 -1
- package/dist/trust-score.d.ts +1 -1
- package/dist/{types-DCB90q3g.d.ts → types-Du6VdoAg.d.ts} +22 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/utility-runtime.d.ts +1 -1
- package/dist/verified-recall.js +8 -8
- package/dist/who-knows-cli.d.ts +14 -14
- package/dist/who-knows-cli.js +9 -9
- package/dist/who-knows.d.ts +14 -14
- package/dist/who-knows.js +8 -8
- package/dist/write-envelope.d.ts +1 -1
- package/package.json +2 -2
- package/src/config.ts +3 -4
- package/src/directory-sidecars.test.ts +113 -0
- package/src/directory-sidecars.ts +70 -8
- package/src/experience/session-experience-mining.test.ts +186 -0
- package/src/experience/session-experience-mining.ts +90 -0
- package/src/lifecycle/seed-graduation-config-types.ts +22 -0
- package/src/lifecycle/seed-graduation.test.ts +160 -1
- package/src/lifecycle/seed-graduation.ts +7 -9
- package/src/orchestration/lifecycle-policy-coordinator.ts +12 -0
- package/src/orchestration/persistence-index.ts +50 -0
- package/src/orchestration/recall-recognition-index.test.ts +249 -0
- package/src/orchestration/recall-recognition-index.ts +169 -0
- package/src/orchestrator.ts +1 -0
- package/src/procedural/procedure-miner.ts +8 -6
- package/src/testing/subjects/recall-recognition-index.test.ts +97 -0
- package/src/types.ts +4 -6
- package/dist/chunk-2G2CVN2T.js.map +0 -1
- package/dist/chunk-72AV2H3R.js.map +0 -1
- package/dist/chunk-BMAYH7F4.js.map +0 -1
- package/dist/chunk-EBJL6HGR.js.map +0 -1
- package/dist/chunk-PQWICTRO.js.map +0 -1
- /package/dist/{auto-sync-DG5KEOF5.js.map → auto-sync-CWSZDLLW.js.map} +0 -0
- /package/dist/{chunk-2ERLN25A.js.map → chunk-2HJKAVAS.js.map} +0 -0
- /package/dist/{chunk-CKBA2MWS.js.map → chunk-2QZJ4P27.js.map} +0 -0
- /package/dist/{chunk-ETNC6TT6.js.map → chunk-43IQRLEF.js.map} +0 -0
- /package/dist/{chunk-DQSVGTKB.js.map → chunk-6UEM5EOB.js.map} +0 -0
- /package/dist/{chunk-JGPG5UHM.js.map → chunk-7QVYVSEH.js.map} +0 -0
- /package/dist/{chunk-HEKWNWNL.js.map → chunk-7RKAE6Y4.js.map} +0 -0
- /package/dist/{chunk-UP3226JC.js.map → chunk-A4TQFNRX.js.map} +0 -0
- /package/dist/{chunk-T73ZC7C5.js.map → chunk-AH44WTLJ.js.map} +0 -0
- /package/dist/{chunk-SZ75IB2T.js.map → chunk-AQWGCHIV.js.map} +0 -0
- /package/dist/{chunk-Q6OC4UUT.js.map → chunk-ARRKSBQU.js.map} +0 -0
- /package/dist/{chunk-6Z4OLQUO.js.map → chunk-AYHNTYVG.js.map} +0 -0
- /package/dist/{chunk-XHDQQ2TT.js.map → chunk-BCXZ4BDS.js.map} +0 -0
- /package/dist/{chunk-VLR4S5GF.js.map → chunk-CO7KBRPF.js.map} +0 -0
- /package/dist/{chunk-JHUODJRW.js.map → chunk-D2N3PMAE.js.map} +0 -0
- /package/dist/{chunk-7SJCSDQ3.js.map → chunk-D7VT2LED.js.map} +0 -0
- /package/dist/{chunk-X25NTN3W.js.map → chunk-DI52XAKG.js.map} +0 -0
- /package/dist/{chunk-EUP4AXIW.js.map → chunk-DZP2XMZC.js.map} +0 -0
- /package/dist/{chunk-BULK6DGB.js.map → chunk-EQNZC3BH.js.map} +0 -0
- /package/dist/{chunk-OIK3YL2P.js.map → chunk-EVQ33D3N.js.map} +0 -0
- /package/dist/{chunk-MNF6PTNL.js.map → chunk-EYK3UHAP.js.map} +0 -0
- /package/dist/{chunk-VSN2DMQK.js.map → chunk-G2DF5MI7.js.map} +0 -0
- /package/dist/{chunk-JIWZVOQM.js.map → chunk-G7S37WD4.js.map} +0 -0
- /package/dist/{chunk-6HCJWCA4.js.map → chunk-IEOBAOA6.js.map} +0 -0
- /package/dist/{chunk-UDAUULK2.js.map → chunk-IGEZE6QB.js.map} +0 -0
- /package/dist/{chunk-SGHGCFVV.js.map → chunk-JE334SIA.js.map} +0 -0
- /package/dist/{chunk-XFXVIXDI.js.map → chunk-JE4H2QBO.js.map} +0 -0
- /package/dist/{chunk-33SX6K3N.js.map → chunk-JMZQS6OS.js.map} +0 -0
- /package/dist/{chunk-3RABJOGD.js.map → chunk-KH2D26LQ.js.map} +0 -0
- /package/dist/{chunk-AH3OIMS7.js.map → chunk-KQQEZTH6.js.map} +0 -0
- /package/dist/{chunk-QRSC37NC.js.map → chunk-M7HFDWOS.js.map} +0 -0
- /package/dist/{chunk-2EICZYIG.js.map → chunk-MTJUIIM4.js.map} +0 -0
- /package/dist/{chunk-ST7FDKZT.js.map → chunk-MWVYHNSU.js.map} +0 -0
- /package/dist/{chunk-NXSNFPYI.js.map → chunk-MXTCV3B5.js.map} +0 -0
- /package/dist/{chunk-O4JFBEUL.js.map → chunk-O7OVWKT4.js.map} +0 -0
- /package/dist/{chunk-RIP2AOZW.js.map → chunk-QWQB7TOB.js.map} +0 -0
- /package/dist/{chunk-PYTSGD5M.js.map → chunk-RSMNPYBM.js.map} +0 -0
- /package/dist/{chunk-MYDA2GA2.js.map → chunk-RUUJXAGT.js.map} +0 -0
- /package/dist/{chunk-YJJMJH6J.js.map → chunk-SEQ6DWXD.js.map} +0 -0
- /package/dist/{chunk-SCM4VYJW.js.map → chunk-SLGD36MM.js.map} +0 -0
- /package/dist/{chunk-KAPYPTPS.js.map → chunk-SOOWBRMH.js.map} +0 -0
- /package/dist/{chunk-JG4AP36X.js.map → chunk-SPFNGHHP.js.map} +0 -0
- /package/dist/{chunk-7TTOX6NW.js.map → chunk-SPWNCGSM.js.map} +0 -0
- /package/dist/{chunk-3QZRSEAM.js.map → chunk-SZ7IVZGD.js.map} +0 -0
- /package/dist/{chunk-IGDEKECC.js.map → chunk-TQT4AOPO.js.map} +0 -0
- /package/dist/{chunk-NVW5ISEJ.js.map → chunk-TS66MUUJ.js.map} +0 -0
- /package/dist/{chunk-6ZMIASYT.js.map → chunk-U2SK45U3.js.map} +0 -0
- /package/dist/{chunk-SMI2G3MA.js.map → chunk-UCH2RWFX.js.map} +0 -0
- /package/dist/{chunk-A33DLYNY.js.map → chunk-UDJMJNBK.js.map} +0 -0
- /package/dist/{chunk-DLXBMXIB.js.map → chunk-UJBIWY5M.js.map} +0 -0
- /package/dist/{chunk-25HSEIEM.js.map → chunk-ULQVG6G3.js.map} +0 -0
- /package/dist/{chunk-XRUOO7OT.js.map → chunk-VGO57TU7.js.map} +0 -0
- /package/dist/{chunk-LX7KIJQF.js.map → chunk-VMKAA5SU.js.map} +0 -0
- /package/dist/{chunk-KBHDV7P3.js.map → chunk-VUV472VH.js.map} +0 -0
- /package/dist/{chunk-LZI6FWZW.js.map → chunk-WH7RINGG.js.map} +0 -0
- /package/dist/{chunk-FDDCZDBI.js.map → chunk-WN4HFL4K.js.map} +0 -0
- /package/dist/{chunk-ISA5U5AP.js.map → chunk-WUJD4CHZ.js.map} +0 -0
- /package/dist/{chunk-UVEBBXB5.js.map → chunk-X7WAM3IY.js.map} +0 -0
- /package/dist/{chunk-NROI5XMG.js.map → chunk-XPFJSUOR.js.map} +0 -0
- /package/dist/{chunk-2SZBCM2S.js.map → chunk-Y4G6LHJW.js.map} +0 -0
- /package/dist/{chunk-JXSOB3SA.js.map → chunk-Y7LZ5V7N.js.map} +0 -0
- /package/dist/{chunk-YSBYNCCN.js.map → chunk-YLPCEUXP.js.map} +0 -0
- /package/dist/{chunk-RFIJH2OE.js.map → chunk-YUHGJBQK.js.map} +0 -0
- /package/dist/{chunk-DX63RFDJ.js.map → chunk-ZADYEZY4.js.map} +0 -0
- /package/dist/{chunk-TNFDWJRS.js.map → chunk-ZANEMAEV.js.map} +0 -0
|
@@ -6,14 +6,14 @@ import {
|
|
|
6
6
|
loadSyncState,
|
|
7
7
|
syncWearableSource,
|
|
8
8
|
wearableSourceLabel
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YLPCEUXP.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-IEOBAOA6.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-KQQEZTH6.js";
|
|
36
36
|
import {
|
|
37
37
|
SharedContextManager
|
|
38
38
|
} from "./chunk-Z22M4JCY.js";
|
|
@@ -111,7 +111,7 @@ import {
|
|
|
111
111
|
import {
|
|
112
112
|
indexStateViewAnnotatedResults,
|
|
113
113
|
resolveRecallStateViewActive
|
|
114
|
-
} from "./chunk-
|
|
114
|
+
} from "./chunk-ARRKSBQU.js";
|
|
115
115
|
import {
|
|
116
116
|
applyRecallStateViews
|
|
117
117
|
} from "./chunk-DBB5JPSL.js";
|
|
@@ -119,7 +119,7 @@ import {
|
|
|
119
119
|
StateViewAnchorTracker,
|
|
120
120
|
filterRecentScanMemories,
|
|
121
121
|
stateViewPacketActive
|
|
122
|
-
} from "./chunk-
|
|
122
|
+
} from "./chunk-G2DF5MI7.js";
|
|
123
123
|
import {
|
|
124
124
|
reorderRecallResultsWithMmr
|
|
125
125
|
} from "./chunk-YDBIWGNI.js";
|
|
@@ -172,7 +172,7 @@ import {
|
|
|
172
172
|
} from "./chunk-LS2FHUML.js";
|
|
173
173
|
import {
|
|
174
174
|
ExtractionEngine
|
|
175
|
-
} from "./chunk-
|
|
175
|
+
} from "./chunk-KH2D26LQ.js";
|
|
176
176
|
import {
|
|
177
177
|
parseMemoryActionEligibilityContext
|
|
178
178
|
} from "./chunk-JHU4EYDV.js";
|
|
@@ -189,7 +189,7 @@ import {
|
|
|
189
189
|
getVerdictKind,
|
|
190
190
|
judgeFactDurability,
|
|
191
191
|
validateProcedureExtraction
|
|
192
|
-
} from "./chunk-
|
|
192
|
+
} from "./chunk-WN4HFL4K.js";
|
|
193
193
|
import {
|
|
194
194
|
buildExplicitCueRecallSection
|
|
195
195
|
} from "./chunk-TVIVY7KU.js";
|
|
@@ -207,7 +207,7 @@ import {
|
|
|
207
207
|
buildEntityRecallSection,
|
|
208
208
|
entityRecentTranscriptLookbackHours,
|
|
209
209
|
readRecentEntityTranscriptEntries
|
|
210
|
-
} from "./chunk-
|
|
210
|
+
} from "./chunk-XPFJSUOR.js";
|
|
211
211
|
import {
|
|
212
212
|
planEpisodeWindowsWithFallback
|
|
213
213
|
} from "./chunk-T3GIETKV.js";
|
|
@@ -219,7 +219,7 @@ import {
|
|
|
219
219
|
} from "./chunk-V2HHAAPI.js";
|
|
220
220
|
import {
|
|
221
221
|
refreshConvergedNamespaces
|
|
222
|
-
} from "./chunk-
|
|
222
|
+
} from "./chunk-Y4G6LHJW.js";
|
|
223
223
|
import {
|
|
224
224
|
formatDaySummaryMemories
|
|
225
225
|
} from "./chunk-LVXBC6YB.js";
|
|
@@ -231,7 +231,7 @@ import {
|
|
|
231
231
|
runTimelinePublishCli,
|
|
232
232
|
screenCandidateFact,
|
|
233
233
|
summarizeVaultPublish
|
|
234
|
-
} from "./chunk-
|
|
234
|
+
} from "./chunk-TS66MUUJ.js";
|
|
235
235
|
import {
|
|
236
236
|
normalizeReplaySessionKey
|
|
237
237
|
} from "./chunk-AJVLDJU6.js";
|
|
@@ -241,14 +241,14 @@ import {
|
|
|
241
241
|
import {
|
|
242
242
|
compareVerifiedEpisodeResults,
|
|
243
243
|
searchVerifiedEpisodes
|
|
244
|
-
} from "./chunk-
|
|
244
|
+
} from "./chunk-SZ7IVZGD.js";
|
|
245
245
|
import {
|
|
246
246
|
ThreadingManager
|
|
247
247
|
} from "./chunk-OJP3N7UK.js";
|
|
248
248
|
import {
|
|
249
249
|
compareVerifiedSemanticRuleResults,
|
|
250
250
|
searchVerifiedSemanticRules
|
|
251
|
-
} from "./chunk-
|
|
251
|
+
} from "./chunk-RUUJXAGT.js";
|
|
252
252
|
import {
|
|
253
253
|
searchWorkProductLedgerEntries
|
|
254
254
|
} from "./chunk-G7NYVKD6.js";
|
|
@@ -261,10 +261,10 @@ import {
|
|
|
261
261
|
import {
|
|
262
262
|
runNamespaceMaintenanceFanout,
|
|
263
263
|
summarizeNamespaceMaintenanceHealth
|
|
264
|
-
} from "./chunk-
|
|
264
|
+
} from "./chunk-SEQ6DWXD.js";
|
|
265
265
|
import {
|
|
266
266
|
planNamespaceMaintenance
|
|
267
|
-
} from "./chunk-
|
|
267
|
+
} from "./chunk-7RKAE6Y4.js";
|
|
268
268
|
import {
|
|
269
269
|
isAboveImportanceThreshold,
|
|
270
270
|
scoreImportance
|
|
@@ -293,7 +293,7 @@ import {
|
|
|
293
293
|
materializeAfterSemanticConsolidation,
|
|
294
294
|
parseConsolidationResponse,
|
|
295
295
|
parseOperatorAwareConsolidationResponse
|
|
296
|
-
} from "./chunk-
|
|
296
|
+
} from "./chunk-DI52XAKG.js";
|
|
297
297
|
import {
|
|
298
298
|
semanticChunkContent
|
|
299
299
|
} from "./chunk-2GBFKHBZ.js";
|
|
@@ -302,7 +302,7 @@ import {
|
|
|
302
302
|
} from "./chunk-6TBIWIAG.js";
|
|
303
303
|
import {
|
|
304
304
|
SmartBuffer
|
|
305
|
-
} from "./chunk-
|
|
305
|
+
} from "./chunk-G7S37WD4.js";
|
|
306
306
|
import {
|
|
307
307
|
buildRecallQueryPolicy
|
|
308
308
|
} from "./chunk-C6WMSXCJ.js";
|
|
@@ -329,8 +329,9 @@ import {
|
|
|
329
329
|
decideSemanticMerge,
|
|
330
330
|
detectMeetings,
|
|
331
331
|
embeddingsFromCosineHits,
|
|
332
|
-
normalizeConnectorScope
|
|
333
|
-
|
|
332
|
+
normalizeConnectorScope,
|
|
333
|
+
runSeedGraduationPass
|
|
334
|
+
} from "./chunk-UVZBDIJX.js";
|
|
334
335
|
import {
|
|
335
336
|
compileCorrectionRule,
|
|
336
337
|
correctionsFilePath,
|
|
@@ -343,9 +344,12 @@ import {
|
|
|
343
344
|
resolveVaultNotePath
|
|
344
345
|
} from "./chunk-3KJTSCSX.js";
|
|
345
346
|
import {
|
|
347
|
+
buildRecognitionIndex,
|
|
346
348
|
decideRecognitionTier,
|
|
347
349
|
loadRecognitionIndex,
|
|
348
|
-
|
|
350
|
+
recognitionIndexPath,
|
|
351
|
+
runRecognitionTier,
|
|
352
|
+
saveRecognitionIndex
|
|
349
353
|
} from "./chunk-4KQIWY4A.js";
|
|
350
354
|
import {
|
|
351
355
|
AMBIENT_CAPTURE_PROMPT_RULE,
|
|
@@ -353,7 +357,7 @@ import {
|
|
|
353
357
|
} from "./chunk-QW27DOHG.js";
|
|
354
358
|
import {
|
|
355
359
|
MeetingsInputError
|
|
356
|
-
} from "./chunk-
|
|
360
|
+
} from "./chunk-SOOWBRMH.js";
|
|
357
361
|
import {
|
|
358
362
|
WearablesInputError,
|
|
359
363
|
describeErrorForOperator
|
|
@@ -371,14 +375,16 @@ import {
|
|
|
371
375
|
} from "./chunk-DGS34QSY.js";
|
|
372
376
|
import {
|
|
373
377
|
NamespaceCatalog
|
|
374
|
-
} from "./chunk-
|
|
378
|
+
} from "./chunk-U2SK45U3.js";
|
|
375
379
|
import {
|
|
376
380
|
RecallResultFormatter,
|
|
377
381
|
SessionContextCoordinator,
|
|
378
382
|
capturePassiveCorrections,
|
|
379
383
|
clusterByKey,
|
|
380
|
-
detectPassiveCorrections
|
|
381
|
-
|
|
384
|
+
detectPassiveCorrections,
|
|
385
|
+
renderSessionExperiencePreview,
|
|
386
|
+
scoreSessionExperienceForPrompt
|
|
387
|
+
} from "./chunk-HUQMVI3A.js";
|
|
382
388
|
import {
|
|
383
389
|
importCapsule
|
|
384
390
|
} from "./chunk-VVX5PZFS.js";
|
|
@@ -407,7 +413,7 @@ import {
|
|
|
407
413
|
} from "./chunk-5UBH37SL.js";
|
|
408
414
|
import {
|
|
409
415
|
buildXraySnapshot
|
|
410
|
-
} from "./chunk-
|
|
416
|
+
} from "./chunk-WH7RINGG.js";
|
|
411
417
|
import {
|
|
412
418
|
objectiveStateStoreOverrideForNamespace,
|
|
413
419
|
searchObjectiveStateSnapshots
|
|
@@ -418,10 +424,10 @@ import {
|
|
|
418
424
|
isTopLevelArchivePath,
|
|
419
425
|
journalPath,
|
|
420
426
|
writeJournalFile
|
|
421
|
-
} from "./chunk-
|
|
427
|
+
} from "./chunk-2HJKAVAS.js";
|
|
422
428
|
import {
|
|
423
429
|
searchHarmonicRetrieval
|
|
424
|
-
} from "./chunk-
|
|
430
|
+
} from "./chunk-TQT4AOPO.js";
|
|
425
431
|
import {
|
|
426
432
|
ProfilingCollector
|
|
427
433
|
} from "./chunk-NLE6TSLG.js";
|
|
@@ -447,7 +453,7 @@ import {
|
|
|
447
453
|
} from "./chunk-IHOXK2I6.js";
|
|
448
454
|
import {
|
|
449
455
|
NamespaceStorageRouter
|
|
450
|
-
} from "./chunk-
|
|
456
|
+
} from "./chunk-AH44WTLJ.js";
|
|
451
457
|
import {
|
|
452
458
|
pruneOrphanCueAnchors
|
|
453
459
|
} from "./chunk-BMWN7B3Y.js";
|
|
@@ -461,7 +467,7 @@ import {
|
|
|
461
467
|
ExtractionDeadlineError,
|
|
462
468
|
ExtractionRunCoordinator,
|
|
463
469
|
classifyExtractionOrigin
|
|
464
|
-
} from "./chunk-
|
|
470
|
+
} from "./chunk-DZP2XMZC.js";
|
|
465
471
|
import {
|
|
466
472
|
ARTIFACT_STATUS_CACHE_TTL_MS,
|
|
467
473
|
BulkImportBatchPartialFailureError,
|
|
@@ -514,7 +520,28 @@ import {
|
|
|
514
520
|
} from "./chunk-TBBDFYXW.js";
|
|
515
521
|
import {
|
|
516
522
|
buildChainFollowupGenerator
|
|
517
|
-
} from "./chunk-
|
|
523
|
+
} from "./chunk-VGO57TU7.js";
|
|
524
|
+
import {
|
|
525
|
+
estimateTokenCount
|
|
526
|
+
} from "./chunk-TOTT6S2V.js";
|
|
527
|
+
import {
|
|
528
|
+
capStateViewPackets,
|
|
529
|
+
reconcileStateViewPairs,
|
|
530
|
+
resultStateViewKey,
|
|
531
|
+
stateViewPacketKeys
|
|
532
|
+
} from "./chunk-EH3HNCAM.js";
|
|
533
|
+
import {
|
|
534
|
+
shouldRecordRecallAuthorityHistory
|
|
535
|
+
} from "./chunk-LVTT5AUG.js";
|
|
536
|
+
import {
|
|
537
|
+
assertExternalWikiRootOutsideMemoryDirCanonical
|
|
538
|
+
} from "./chunk-JV3C2MNQ.js";
|
|
539
|
+
import {
|
|
540
|
+
buildProcedurePersistBody
|
|
541
|
+
} from "./chunk-QDW3E4RD.js";
|
|
542
|
+
import {
|
|
543
|
+
searchCausalTrajectories
|
|
544
|
+
} from "./chunk-L63GFNKL.js";
|
|
518
545
|
import {
|
|
519
546
|
QmdResultResolver,
|
|
520
547
|
StorageManager,
|
|
@@ -533,7 +560,7 @@ import {
|
|
|
533
560
|
reconstructFusionInputs,
|
|
534
561
|
selfDeps,
|
|
535
562
|
serializeFusionDay
|
|
536
|
-
} from "./chunk-
|
|
563
|
+
} from "./chunk-QWQB7TOB.js";
|
|
537
564
|
import {
|
|
538
565
|
bodyIsEscaped,
|
|
539
566
|
decodeTranscriptBody,
|
|
@@ -569,7 +596,7 @@ import {
|
|
|
569
596
|
} from "./chunk-S2V7RUCL.js";
|
|
570
597
|
import {
|
|
571
598
|
confidenceTier
|
|
572
|
-
} from "./chunk-
|
|
599
|
+
} from "./chunk-4UVJ6EIT.js";
|
|
573
600
|
import {
|
|
574
601
|
lintWorkspaceFiles,
|
|
575
602
|
rotateMarkdownFileToArchive
|
|
@@ -628,6 +655,10 @@ import {
|
|
|
628
655
|
getCachedQmdRecall,
|
|
629
656
|
setCachedQmdRecall
|
|
630
657
|
} from "./chunk-42JKGUFJ.js";
|
|
658
|
+
import {
|
|
659
|
+
isUntrustedOrigin,
|
|
660
|
+
parseOriginClass
|
|
661
|
+
} from "./chunk-6Q3ZTEF6.js";
|
|
631
662
|
import {
|
|
632
663
|
FallbackLlmClient,
|
|
633
664
|
gatewayTaskChainOptions
|
|
@@ -635,31 +666,6 @@ import {
|
|
|
635
666
|
import {
|
|
636
667
|
fallbackLlmRuntimeContextFromConfig
|
|
637
668
|
} from "./chunk-EP6BA7VV.js";
|
|
638
|
-
import {
|
|
639
|
-
estimateTokenCount
|
|
640
|
-
} from "./chunk-TOTT6S2V.js";
|
|
641
|
-
import {
|
|
642
|
-
capStateViewPackets,
|
|
643
|
-
reconcileStateViewPairs,
|
|
644
|
-
resultStateViewKey,
|
|
645
|
-
stateViewPacketKeys
|
|
646
|
-
} from "./chunk-EH3HNCAM.js";
|
|
647
|
-
import {
|
|
648
|
-
shouldRecordRecallAuthorityHistory
|
|
649
|
-
} from "./chunk-LVTT5AUG.js";
|
|
650
|
-
import {
|
|
651
|
-
assertExternalWikiRootOutsideMemoryDirCanonical
|
|
652
|
-
} from "./chunk-JV3C2MNQ.js";
|
|
653
|
-
import {
|
|
654
|
-
buildProcedurePersistBody
|
|
655
|
-
} from "./chunk-QDW3E4RD.js";
|
|
656
|
-
import {
|
|
657
|
-
searchCausalTrajectories
|
|
658
|
-
} from "./chunk-L63GFNKL.js";
|
|
659
|
-
import {
|
|
660
|
-
isUntrustedOrigin,
|
|
661
|
-
parseOriginClass
|
|
662
|
-
} from "./chunk-6Q3ZTEF6.js";
|
|
663
669
|
import {
|
|
664
670
|
normalizeRecallTokenSet
|
|
665
671
|
} from "./chunk-YCVB7X56.js";
|
|
@@ -684,7 +690,14 @@ import {
|
|
|
684
690
|
import {
|
|
685
691
|
localDayKey,
|
|
686
692
|
renderDayLocationContext
|
|
687
|
-
} from "./chunk-
|
|
693
|
+
} from "./chunk-IGEZE6QB.js";
|
|
694
|
+
import {
|
|
695
|
+
activityDayWindow,
|
|
696
|
+
assertValidTimezone,
|
|
697
|
+
hashActivityBody,
|
|
698
|
+
isValidActivityDate,
|
|
699
|
+
timezoneOffsetIso
|
|
700
|
+
} from "./chunk-353C5UNV.js";
|
|
688
701
|
import {
|
|
689
702
|
TAG_LIMITS,
|
|
690
703
|
composeMemoryEnvelope,
|
|
@@ -693,13 +706,6 @@ import {
|
|
|
693
706
|
import {
|
|
694
707
|
normalizeTags
|
|
695
708
|
} from "./chunk-BT7NVCML.js";
|
|
696
|
-
import {
|
|
697
|
-
activityDayWindow,
|
|
698
|
-
assertValidTimezone,
|
|
699
|
-
hashActivityBody,
|
|
700
|
-
isValidActivityDate,
|
|
701
|
-
timezoneOffsetIso
|
|
702
|
-
} from "./chunk-353C5UNV.js";
|
|
703
709
|
import {
|
|
704
710
|
evaluateSubjectGuard,
|
|
705
711
|
isSharedPromotionTarget,
|
|
@@ -729,15 +735,15 @@ import {
|
|
|
729
735
|
stripCitationForTemplate,
|
|
730
736
|
stripRecognizedCitations
|
|
731
737
|
} from "./chunk-L272A5QW.js";
|
|
732
|
-
import {
|
|
733
|
-
excludeSupportPassportPrivateMemories,
|
|
734
|
-
isSupportPassportPrivateMemory
|
|
735
|
-
} from "./chunk-PWPIERBM.js";
|
|
736
738
|
import {
|
|
737
739
|
inferMemoryStatus,
|
|
738
740
|
isActiveMemoryStatus,
|
|
739
741
|
toMemoryPathRel
|
|
740
742
|
} from "./chunk-7RJUVTVF.js";
|
|
743
|
+
import {
|
|
744
|
+
excludeSupportPassportPrivateMemories,
|
|
745
|
+
isSupportPassportPrivateMemory
|
|
746
|
+
} from "./chunk-PWPIERBM.js";
|
|
741
747
|
import {
|
|
742
748
|
assertPathInsideRoot
|
|
743
749
|
} from "./chunk-C7HJ3NEI.js";
|
|
@@ -849,7 +855,7 @@ import {
|
|
|
849
855
|
} from "./chunk-3WCASNQZ.js";
|
|
850
856
|
|
|
851
857
|
// src/orchestrator.ts
|
|
852
|
-
import
|
|
858
|
+
import path23 from "path";
|
|
853
859
|
import { createHash as createHash9 } from "crypto";
|
|
854
860
|
|
|
855
861
|
// src/orchestration/tier-migration-coordinator.ts
|
|
@@ -1567,6 +1573,13 @@ var LifecyclePolicyCoordinator = class {
|
|
|
1567
1573
|
});
|
|
1568
1574
|
if (wrote) updatedCount += 1;
|
|
1569
1575
|
}
|
|
1576
|
+
const history = this.deps.getHandleHistory?.();
|
|
1577
|
+
await runSeedGraduationPass({
|
|
1578
|
+
memories: allMemories,
|
|
1579
|
+
storage,
|
|
1580
|
+
config: this.config.seedGraduation,
|
|
1581
|
+
recalledBySession: history ? (sessionKey) => history.recent(sessionKey) : void 0
|
|
1582
|
+
});
|
|
1570
1583
|
if (!lifecycleCaps.lifecycleMetrics) return updatedCount;
|
|
1571
1584
|
const total = evaluatedCount;
|
|
1572
1585
|
const metrics = {
|
|
@@ -2400,7 +2413,7 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
|
|
|
2400
2413
|
namespaces,
|
|
2401
2414
|
{
|
|
2402
2415
|
readNamespaceMemories: async (ns) => (await this.getStorage(ns)).readAllMemories(),
|
|
2403
|
-
readMemoryFrontmatter: async (
|
|
2416
|
+
readMemoryFrontmatter: async (path42, preferredNamespace) => {
|
|
2404
2417
|
if (!fallbackReader) {
|
|
2405
2418
|
for (const ns of namespaces) {
|
|
2406
2419
|
try {
|
|
@@ -2412,7 +2425,7 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
|
|
|
2412
2425
|
}
|
|
2413
2426
|
if (!fallbackReader) return null;
|
|
2414
2427
|
const memory = await this.readQmdResultMemory(
|
|
2415
|
-
|
|
2428
|
+
path42,
|
|
2416
2429
|
fallbackReader,
|
|
2417
2430
|
namespaces,
|
|
2418
2431
|
preferredNamespace
|
|
@@ -9889,44 +9902,8 @@ var GraphRecallCoordinator = class {
|
|
|
9889
9902
|
}
|
|
9890
9903
|
};
|
|
9891
9904
|
|
|
9892
|
-
// src/experience/session-experience-recall.ts
|
|
9893
|
-
function tokenOverlapScore(prompt, memoryText) {
|
|
9894
|
-
const norm = (s) => s.toLowerCase().split(/[^a-z0-9]+/).filter((t) => t.length > 2);
|
|
9895
|
-
const promptTokens = new Set(norm(prompt));
|
|
9896
|
-
const memTokens = new Set(norm(memoryText));
|
|
9897
|
-
if (promptTokens.size === 0 || memTokens.size === 0) return 0;
|
|
9898
|
-
let inter = 0;
|
|
9899
|
-
for (const t of promptTokens) {
|
|
9900
|
-
if (memTokens.has(t)) inter++;
|
|
9901
|
-
}
|
|
9902
|
-
const union = /* @__PURE__ */ new Set([...promptTokens, ...memTokens]);
|
|
9903
|
-
return inter / Math.max(1, union.size);
|
|
9904
|
-
}
|
|
9905
|
-
function isSessionExperienceMemory(memory) {
|
|
9906
|
-
const hash = memory.frontmatter.structuredAttributes?.experience_session_hash;
|
|
9907
|
-
return typeof hash === "string" && hash.length > 0;
|
|
9908
|
-
}
|
|
9909
|
-
function scoreSessionExperienceForPrompt(memory, prompt) {
|
|
9910
|
-
if (!isSessionExperienceMemory(memory)) return null;
|
|
9911
|
-
const situation = memory.frontmatter.structuredAttributes?.experience_situation ?? "";
|
|
9912
|
-
const situationScore = tokenOverlapScore(prompt, situation);
|
|
9913
|
-
const bodyScore = tokenOverlapScore(prompt, memory.content);
|
|
9914
|
-
return Math.min(1, situationScore * 0.75 + bodyScore * 0.25);
|
|
9915
|
-
}
|
|
9916
|
-
function renderSessionExperiencePreview(memory) {
|
|
9917
|
-
if (!isSessionExperienceMemory(memory)) return null;
|
|
9918
|
-
const attrs = memory.frontmatter.structuredAttributes ?? {};
|
|
9919
|
-
const situation = (attrs.experience_situation ?? "").trim();
|
|
9920
|
-
const approach = (attrs.experience_approach ?? "").trim();
|
|
9921
|
-
const reflection = (attrs.experience_reflection ?? "").trim();
|
|
9922
|
-
if (situation.length === 0 && approach.length === 0 && reflection.length === 0) {
|
|
9923
|
-
return `Experience. ${memory.content.replace(/\s+/g, " ").trim()}`;
|
|
9924
|
-
}
|
|
9925
|
-
return `Experience. Situation: ${situation} Approach: ${approach} Reflection: ${reflection}`.replace(/\s+/g, " ").trim();
|
|
9926
|
-
}
|
|
9927
|
-
|
|
9928
9905
|
// src/procedural/procedure-recall.ts
|
|
9929
|
-
function
|
|
9906
|
+
function tokenOverlapScore(prompt, memoryText) {
|
|
9930
9907
|
const norm = (s) => s.toLowerCase().split(/[^a-z0-9]+/).filter((t) => t.length > 2);
|
|
9931
9908
|
const promptTokens = new Set(norm(prompt));
|
|
9932
9909
|
const memTokens = new Set(norm(memoryText));
|
|
@@ -9941,7 +9918,7 @@ function tokenOverlapScore2(prompt, memoryText) {
|
|
|
9941
9918
|
function scoreProcedureForPrompt(m, prompt, queryIntent, experienceEnabled) {
|
|
9942
9919
|
const memText = `${m.content}
|
|
9943
9920
|
${(m.frontmatter.tags ?? []).join(" ")}`;
|
|
9944
|
-
const jaccard =
|
|
9921
|
+
const jaccard = tokenOverlapScore(prompt, memText);
|
|
9945
9922
|
const memIntent = inferIntentFromText(m.content.slice(0, 2e3));
|
|
9946
9923
|
const intentScore = intentCompatibilityScore(queryIntent, memIntent);
|
|
9947
9924
|
const base = jaccard * 0.55 + intentScore * 0.45;
|
|
@@ -17474,7 +17451,7 @@ var OrchestratorInitCoordinator = class {
|
|
|
17474
17451
|
if (signal.aborted || !this.isCurrentStartupEpoch(epoch)) return;
|
|
17475
17452
|
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)) {
|
|
17476
17453
|
try {
|
|
17477
|
-
const { startWearablesAutoSync } = await import("./auto-sync-
|
|
17454
|
+
const { startWearablesAutoSync } = await import("./auto-sync-CWSZDLLW.js");
|
|
17478
17455
|
if (signal.aborted || !this.isCurrentStartupEpoch(epoch)) return;
|
|
17479
17456
|
this.deps.wearablesAutoSyncHandle = startWearablesAutoSync(
|
|
17480
17457
|
{
|
|
@@ -17647,7 +17624,121 @@ var OrchestratorInitCoordinator = class {
|
|
|
17647
17624
|
};
|
|
17648
17625
|
|
|
17649
17626
|
// src/orchestration/persistence-index.ts
|
|
17627
|
+
import path19 from "path";
|
|
17628
|
+
|
|
17629
|
+
// src/orchestration/recall-recognition-index.ts
|
|
17630
|
+
import { promises as fsp } from "fs";
|
|
17650
17631
|
import path18 from "path";
|
|
17632
|
+
import { setTimeout as delay } from "timers/promises";
|
|
17633
|
+
var writeChains = /* @__PURE__ */ new Map();
|
|
17634
|
+
var LOCK_POLL_MS = 10;
|
|
17635
|
+
var LOCK_ATTEMPTS = 50;
|
|
17636
|
+
var LOCK_STALE_MS = 6e4;
|
|
17637
|
+
function recognitionDescriptionFromContent(content) {
|
|
17638
|
+
const trimmed = content.trim();
|
|
17639
|
+
if (trimmed.length === 0) return "";
|
|
17640
|
+
const newline = trimmed.indexOf("\n");
|
|
17641
|
+
return newline === -1 ? trimmed : trimmed.slice(0, newline).trimEnd();
|
|
17642
|
+
}
|
|
17643
|
+
function withIndexChain(indexPath, op) {
|
|
17644
|
+
const previous = writeChains.get(indexPath) ?? Promise.resolve();
|
|
17645
|
+
const run = previous.then(op, op);
|
|
17646
|
+
const tail = run.then(() => void 0, () => void 0);
|
|
17647
|
+
writeChains.set(indexPath, tail);
|
|
17648
|
+
void tail.then(() => {
|
|
17649
|
+
if (writeChains.get(indexPath) === tail) writeChains.delete(indexPath);
|
|
17650
|
+
});
|
|
17651
|
+
return run;
|
|
17652
|
+
}
|
|
17653
|
+
async function removeAbandonedRecognitionLock(lockDir) {
|
|
17654
|
+
try {
|
|
17655
|
+
const info = await fsp.lstat(lockDir);
|
|
17656
|
+
if (info.isSymbolicLink()) return "blocked";
|
|
17657
|
+
if (!info.isDirectory()) {
|
|
17658
|
+
await fsp.rm(lockDir, { force: true });
|
|
17659
|
+
return "removed";
|
|
17660
|
+
}
|
|
17661
|
+
if (Date.now() - info.mtimeMs < LOCK_STALE_MS) return "wait";
|
|
17662
|
+
await fsp.rm(lockDir, { recursive: true, force: true });
|
|
17663
|
+
return "removed";
|
|
17664
|
+
} catch (error) {
|
|
17665
|
+
if (error?.code === "ENOENT") return "removed";
|
|
17666
|
+
return "blocked";
|
|
17667
|
+
}
|
|
17668
|
+
}
|
|
17669
|
+
async function withRecognitionIndexLock(memoryDir, op) {
|
|
17670
|
+
const lockDir = `${recognitionIndexPath(memoryDir)}.lock.d`;
|
|
17671
|
+
for (let attempt = 0; attempt < LOCK_ATTEMPTS; attempt++) {
|
|
17672
|
+
try {
|
|
17673
|
+
await fsp.mkdir(lockDir);
|
|
17674
|
+
try {
|
|
17675
|
+
return await op();
|
|
17676
|
+
} finally {
|
|
17677
|
+
await fsp.rm(lockDir, { recursive: true, force: true }).catch(() => void 0);
|
|
17678
|
+
}
|
|
17679
|
+
} catch (error) {
|
|
17680
|
+
const code = error?.code;
|
|
17681
|
+
if (code === "ENOENT") {
|
|
17682
|
+
await fsp.mkdir(path18.dirname(lockDir), { recursive: true }).catch(() => void 0);
|
|
17683
|
+
continue;
|
|
17684
|
+
}
|
|
17685
|
+
if (code !== "EEXIST") throw error;
|
|
17686
|
+
const cleanup = await removeAbandonedRecognitionLock(lockDir);
|
|
17687
|
+
if (cleanup === "blocked") {
|
|
17688
|
+
throw new Error(`recognition index lock blocked at ${lockDir}`);
|
|
17689
|
+
}
|
|
17690
|
+
if (cleanup === "removed") continue;
|
|
17691
|
+
await delay(LOCK_POLL_MS);
|
|
17692
|
+
}
|
|
17693
|
+
}
|
|
17694
|
+
throw new Error(`recognition index lock timed out at ${lockDir}`);
|
|
17695
|
+
}
|
|
17696
|
+
function applyChanges(entries, changes) {
|
|
17697
|
+
const next = entries.map((entry) => ({ id: entry.id, description: entry.description }));
|
|
17698
|
+
const byId = new Map(next.map((entry, index) => [entry.id, index]));
|
|
17699
|
+
for (const change of changes) {
|
|
17700
|
+
const id = change.id.trim();
|
|
17701
|
+
if (id.length === 0) continue;
|
|
17702
|
+
if (change.action === "remove") {
|
|
17703
|
+
const index = byId.get(id);
|
|
17704
|
+
if (index === void 0) continue;
|
|
17705
|
+
next.splice(index, 1);
|
|
17706
|
+
byId.delete(id);
|
|
17707
|
+
for (const [key, value] of byId) {
|
|
17708
|
+
if (value > index) byId.set(key, value - 1);
|
|
17709
|
+
}
|
|
17710
|
+
continue;
|
|
17711
|
+
}
|
|
17712
|
+
const description = recognitionDescriptionFromContent(change.content);
|
|
17713
|
+
const existing = byId.get(id);
|
|
17714
|
+
if (existing !== void 0) {
|
|
17715
|
+
next[existing] = { id, description };
|
|
17716
|
+
} else {
|
|
17717
|
+
byId.set(id, next.length);
|
|
17718
|
+
next.push({ id, description });
|
|
17719
|
+
}
|
|
17720
|
+
}
|
|
17721
|
+
return next;
|
|
17722
|
+
}
|
|
17723
|
+
function meaningfulChanges(changes) {
|
|
17724
|
+
return changes.filter((change) => change.id.trim().length > 0);
|
|
17725
|
+
}
|
|
17726
|
+
async function maintainRecognitionIndexAfterWrite(args) {
|
|
17727
|
+
if (args.enabled !== true) return;
|
|
17728
|
+
const changes = meaningfulChanges(args.changes);
|
|
17729
|
+
if (changes.length === 0) return;
|
|
17730
|
+
const indexPath = recognitionIndexPath(args.memoryDir);
|
|
17731
|
+
await withIndexChain(
|
|
17732
|
+
indexPath,
|
|
17733
|
+
() => withRecognitionIndexLock(args.memoryDir, async () => {
|
|
17734
|
+
const loaded = await loadRecognitionIndex(args.memoryDir);
|
|
17735
|
+
const entries = applyChanges(loaded?.entries ?? [], changes);
|
|
17736
|
+
await saveRecognitionIndex(args.memoryDir, buildRecognitionIndex(entries));
|
|
17737
|
+
})
|
|
17738
|
+
);
|
|
17739
|
+
}
|
|
17740
|
+
|
|
17741
|
+
// src/orchestration/persistence-index.ts
|
|
17651
17742
|
var PersistenceIndexCoordinator = class {
|
|
17652
17743
|
constructor(deps) {
|
|
17653
17744
|
this.deps = deps;
|
|
@@ -17839,7 +17930,7 @@ var PersistenceIndexCoordinator = class {
|
|
|
17839
17930
|
const allMems = allMemsForGraph ?? [];
|
|
17840
17931
|
for (const m of allMems) {
|
|
17841
17932
|
if (m.frontmatter.entityRef === entityRef) {
|
|
17842
|
-
const rel =
|
|
17933
|
+
const rel = path19.relative(storage.dir, m.path);
|
|
17843
17934
|
if (rel !== memoryRelPath) entitySiblings.push(rel);
|
|
17844
17935
|
}
|
|
17845
17936
|
}
|
|
@@ -17890,6 +17981,7 @@ var PersistenceIndexCoordinator = class {
|
|
|
17890
17981
|
* Fail-open: any error is logged but does not abort extraction.
|
|
17891
17982
|
*/
|
|
17892
17983
|
async updateTemporalTagIndexes(storage, persistedIds) {
|
|
17984
|
+
await this.maintainRecognitionIndex(storage, persistedIds);
|
|
17893
17985
|
const caps = resolveCapabilities(this.deps.config);
|
|
17894
17986
|
if (!resolveIndexingCapabilities(this.deps.config).queryAwareIndexing && !caps.parallelRetrieval && !resolveRecallEnhancementCapabilities(this.deps.config).eventOrderRecall)
|
|
17895
17987
|
return;
|
|
@@ -17990,11 +18082,51 @@ var PersistenceIndexCoordinator = class {
|
|
|
17990
18082
|
);
|
|
17991
18083
|
return enriched;
|
|
17992
18084
|
}
|
|
18085
|
+
/**
|
|
18086
|
+
* Upsert persisted memories into the namespace recognition index.
|
|
18087
|
+
* `recallRecognitionTier !== true` returns before any index I/O.
|
|
18088
|
+
* A missing index is bootstrapped from the active corpus so the first
|
|
18089
|
+
* post-enable write cannot publish a partial index that recall would
|
|
18090
|
+
* treat as the full working set.
|
|
18091
|
+
*/
|
|
18092
|
+
async maintainRecognitionIndex(storage, persistedIds) {
|
|
18093
|
+
try {
|
|
18094
|
+
if (this.deps.config.recallRecognitionTier !== true) return;
|
|
18095
|
+
const indexMissing = await loadRecognitionIndex(storage.dir) === null;
|
|
18096
|
+
if (!indexMissing && persistedIds.length === 0) return;
|
|
18097
|
+
const changes = [];
|
|
18098
|
+
const pushUpsert = (memory) => {
|
|
18099
|
+
if (!isActiveMemoryStatus(memory.frontmatter.status)) return;
|
|
18100
|
+
const memoryId = memory.frontmatter.id;
|
|
18101
|
+
if (typeof memoryId !== "string" || memoryId.trim().length === 0) return;
|
|
18102
|
+
changes.push({ action: "upsert", id: memoryId, content: memory.content ?? "" });
|
|
18103
|
+
};
|
|
18104
|
+
if (indexMissing) {
|
|
18105
|
+
const corpus = await storage.readAllMemories().catch(() => []);
|
|
18106
|
+
for (const memory of corpus) pushUpsert(memory);
|
|
18107
|
+
}
|
|
18108
|
+
for (const id of persistedIds) {
|
|
18109
|
+
let memory = await storage.getMemoryById(id);
|
|
18110
|
+
if (!memory) {
|
|
18111
|
+
const cold = await storage.getMemoryByIdIncludingArchived(id).catch(() => null);
|
|
18112
|
+
if (cold && isActiveMemoryStatus(cold.frontmatter.status)) memory = cold;
|
|
18113
|
+
}
|
|
18114
|
+
if (memory) pushUpsert(memory);
|
|
18115
|
+
}
|
|
18116
|
+
await maintainRecognitionIndexAfterWrite({
|
|
18117
|
+
memoryDir: storage.dir,
|
|
18118
|
+
enabled: true,
|
|
18119
|
+
changes
|
|
18120
|
+
});
|
|
18121
|
+
} catch (err) {
|
|
18122
|
+
log.debug(`recognition-index update error (non-fatal): ${err}`);
|
|
18123
|
+
}
|
|
18124
|
+
}
|
|
17993
18125
|
};
|
|
17994
18126
|
|
|
17995
18127
|
// src/orchestration/workspace-ops.ts
|
|
17996
18128
|
import { lstat as lstat2, mkdir as mkdir6, readFile as readFile8, readdir as readdir3, realpath as realpath2, writeFile as writeFile6 } from "fs/promises";
|
|
17997
|
-
import
|
|
18129
|
+
import path20 from "path";
|
|
17998
18130
|
|
|
17999
18131
|
// src/maintenance/pattern-reinforcement.ts
|
|
18000
18132
|
function patternReinforcementKey(content) {
|
|
@@ -19898,8 +20030,8 @@ var MeetingsService = class {
|
|
|
19898
20030
|
// src/orchestration/workspace-ops.ts
|
|
19899
20031
|
var MEETINGS_BUILD_DEBOUNCE_MS = 5e3;
|
|
19900
20032
|
function matchesMemoryPath(candidatePath, requestedPath, memoryDir) {
|
|
19901
|
-
const normalizedCandidate =
|
|
19902
|
-
return normalizedCandidate ===
|
|
20033
|
+
const normalizedCandidate = path20.resolve(candidatePath);
|
|
20034
|
+
return normalizedCandidate === path20.resolve(requestedPath) || normalizedCandidate === path20.resolve(memoryDir, requestedPath);
|
|
19903
20035
|
}
|
|
19904
20036
|
function accessTrackingPathCandidates(storageDir, memoryPath) {
|
|
19905
20037
|
const candidates = qmdResultPathCandidates(storageDir, memoryPath);
|
|
@@ -19907,12 +20039,12 @@ function accessTrackingPathCandidates(storageDir, memoryPath) {
|
|
|
19907
20039
|
if (!parts) return candidates;
|
|
19908
20040
|
candidates.push(
|
|
19909
20041
|
...qmdResultPathCandidates(storageDir, parts.relativePath),
|
|
19910
|
-
...qmdResultPathCandidates(
|
|
20042
|
+
...qmdResultPathCandidates(path20.join(storageDir, "cold"), parts.relativePath)
|
|
19911
20043
|
);
|
|
19912
20044
|
return [...new Set(candidates)];
|
|
19913
20045
|
}
|
|
19914
20046
|
function canonicalMemoryPath(memoryPath, memoryDir) {
|
|
19915
|
-
return
|
|
20047
|
+
return path20.resolve(path20.isAbsolute(memoryPath) ? memoryPath : path20.resolve(memoryDir, memoryPath));
|
|
19916
20048
|
}
|
|
19917
20049
|
var WorkspaceOpsCoordinator = class {
|
|
19918
20050
|
constructor(deps) {
|
|
@@ -19994,15 +20126,15 @@ var WorkspaceOpsCoordinator = class {
|
|
|
19994
20126
|
this.deps.lastFileHygieneRunAtMs = now;
|
|
19995
20127
|
if (hygiene.rotateEnabled) {
|
|
19996
20128
|
for (const rel of hygiene.rotatePaths) {
|
|
19997
|
-
const abs =
|
|
20129
|
+
const abs = path20.isAbsolute(rel) ? rel : path20.join(this.deps.config.workspaceDir, rel);
|
|
19998
20130
|
try {
|
|
19999
20131
|
const raw = await readFile8(abs, "utf-8");
|
|
20000
20132
|
if (raw.length > hygiene.rotateMaxBytes) {
|
|
20001
|
-
const archiveDir =
|
|
20133
|
+
const archiveDir = path20.join(
|
|
20002
20134
|
this.deps.config.workspaceDir,
|
|
20003
20135
|
hygiene.archiveDir
|
|
20004
20136
|
);
|
|
20005
|
-
const base =
|
|
20137
|
+
const base = path20.basename(abs);
|
|
20006
20138
|
const prefix = base.toUpperCase().replace(/\.MD$/i, "").replace(/[^A-Z0-9]+/g, "-") || "FILE";
|
|
20007
20139
|
const { newContent } = await rotateMarkdownFileToArchive({
|
|
20008
20140
|
filePath: abs,
|
|
@@ -20027,8 +20159,8 @@ var WorkspaceOpsCoordinator = class {
|
|
|
20027
20159
|
log.warn(w.message);
|
|
20028
20160
|
}
|
|
20029
20161
|
if (hygiene.warningsLogEnabled && warnings.length > 0) {
|
|
20030
|
-
const fp =
|
|
20031
|
-
await mkdir6(
|
|
20162
|
+
const fp = path20.join(this.deps.config.memoryDir, hygiene.warningsLogPath);
|
|
20163
|
+
await mkdir6(path20.dirname(fp), { recursive: true });
|
|
20032
20164
|
const stamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
20033
20165
|
const block = `
|
|
20034
20166
|
|
|
@@ -20068,7 +20200,7 @@ var WorkspaceOpsCoordinator = class {
|
|
|
20068
20200
|
for (const categoryDir of RECALL_FALLBACK_DIRS) {
|
|
20069
20201
|
if (memoryRootReal === null) break;
|
|
20070
20202
|
for (const date of datesToScan) {
|
|
20071
|
-
const dateDir =
|
|
20203
|
+
const dateDir = path20.join(storage.dir, categoryDir, date);
|
|
20072
20204
|
try {
|
|
20073
20205
|
const dirStat = await lstat2(dateDir);
|
|
20074
20206
|
if (dirStat.isSymbolicLink() || !dirStat.isDirectory()) continue;
|
|
@@ -20077,7 +20209,7 @@ var WorkspaceOpsCoordinator = class {
|
|
|
20077
20209
|
for (const entry of entries) {
|
|
20078
20210
|
if (entry.isSymbolicLink()) continue;
|
|
20079
20211
|
if (!entry.name.endsWith(".md")) continue;
|
|
20080
|
-
const fullPath =
|
|
20212
|
+
const fullPath = path20.join(dateDir, entry.name);
|
|
20081
20213
|
try {
|
|
20082
20214
|
assertPathInsideRoot(memoryRootReal, await realpath2(fullPath), fullPath);
|
|
20083
20215
|
const memory = await storage.readMemoryByPath(fullPath);
|
|
@@ -20099,13 +20231,13 @@ var WorkspaceOpsCoordinator = class {
|
|
|
20099
20231
|
return a.frontmatter.created < b.frontmatter.created ? -1 : 1;
|
|
20100
20232
|
});
|
|
20101
20233
|
const hourlySummaries = [];
|
|
20102
|
-
const hourlyBaseDir =
|
|
20234
|
+
const hourlyBaseDir = path20.join(storage.dir, "summaries", "hourly");
|
|
20103
20235
|
try {
|
|
20104
20236
|
const sessionKeys = await readdir3(hourlyBaseDir, { withFileTypes: true });
|
|
20105
20237
|
for (const sk of sessionKeys) {
|
|
20106
20238
|
if (!sk.isDirectory()) continue;
|
|
20107
20239
|
for (const date of datesToScan) {
|
|
20108
|
-
const summaryFile =
|
|
20240
|
+
const summaryFile = path20.join(hourlyBaseDir, sk.name, `${date}.md`);
|
|
20109
20241
|
try {
|
|
20110
20242
|
const raw = await readFile8(summaryFile, "utf-8");
|
|
20111
20243
|
const filtered = filterHourlySummaryMarkdownForLocalDay(
|
|
@@ -20582,18 +20714,18 @@ ${reflectionsContent.trim()}
|
|
|
20582
20714
|
// src/orchestration/namespace-read-fanout.ts
|
|
20583
20715
|
import { existsSync, readFileSync } from "fs";
|
|
20584
20716
|
import { stat as stat3 } from "fs/promises";
|
|
20585
|
-
import
|
|
20717
|
+
import path22 from "path";
|
|
20586
20718
|
|
|
20587
20719
|
// src/orchestration/orchestrator-namespace-scope.ts
|
|
20588
|
-
import
|
|
20720
|
+
import path21 from "path";
|
|
20589
20721
|
function computeSemanticDedupScope(targetStorage, config) {
|
|
20590
20722
|
if (!resolveNamespaceCapabilities(config).namespaces) return {};
|
|
20591
|
-
const memoryDir =
|
|
20592
|
-
const storageDir =
|
|
20723
|
+
const memoryDir = path21.resolve(config.memoryDir);
|
|
20724
|
+
const storageDir = path21.resolve(targetStorage.dir);
|
|
20593
20725
|
if (storageDir === memoryDir) {
|
|
20594
20726
|
return { pathExcludePrefixes: ["namespaces/"] };
|
|
20595
20727
|
}
|
|
20596
|
-
let rel =
|
|
20728
|
+
let rel = path21.relative(memoryDir, storageDir);
|
|
20597
20729
|
if (!rel || rel.startsWith("..")) {
|
|
20598
20730
|
log.debug(
|
|
20599
20731
|
`semantic dedup: target storage dir ${storageDir} is outside memoryDir ${memoryDir}; scoping lookup to absolute path prefix`
|
|
@@ -20646,7 +20778,7 @@ var NamespaceReadFanoutCoordinator = class {
|
|
|
20646
20778
|
loadNamespaceStorageDirHintsFromCatalog() {
|
|
20647
20779
|
if (this.deps.namespaceStorageDirHintsLoaded || !this.deps.namespaceCatalog.enabled) return;
|
|
20648
20780
|
this.deps.namespaceStorageDirHintsLoaded = true;
|
|
20649
|
-
const catalogPath =
|
|
20781
|
+
const catalogPath = path22.join(this.deps.config.memoryDir, "state", "namespaces.jsonl");
|
|
20650
20782
|
if (!existsSync(catalogPath)) return;
|
|
20651
20783
|
let body;
|
|
20652
20784
|
try {
|
|
@@ -20683,7 +20815,7 @@ var NamespaceReadFanoutCoordinator = class {
|
|
|
20683
20815
|
if (!this.deps.storageDirMatchesNamespaceHint(record.namespace, record.storageDir)) {
|
|
20684
20816
|
continue;
|
|
20685
20817
|
}
|
|
20686
|
-
const resolvedStorageDir =
|
|
20818
|
+
const resolvedStorageDir = path22.resolve(record.storageDir);
|
|
20687
20819
|
const current = preferredByStorageDir.get(resolvedStorageDir);
|
|
20688
20820
|
preferredByStorageDir.set(
|
|
20689
20821
|
resolvedStorageDir,
|
|
@@ -20868,12 +21000,12 @@ var NamespaceReadFanoutCoordinator = class {
|
|
|
20868
21000
|
}
|
|
20869
21001
|
async resolveStateDirForNamespace(namespace) {
|
|
20870
21002
|
if (!resolveNamespaceCapabilities(this.deps.config).namespaces) {
|
|
20871
|
-
return
|
|
21003
|
+
return path22.join(this.deps.config.memoryDir, "state");
|
|
20872
21004
|
}
|
|
20873
21005
|
if (namespace !== this.deps.config.defaultNamespace) {
|
|
20874
|
-
return
|
|
21006
|
+
return path22.join(this.deps.config.memoryDir, "namespaces", namespace, "state");
|
|
20875
21007
|
}
|
|
20876
|
-
const candidate =
|
|
21008
|
+
const candidate = path22.join(
|
|
20877
21009
|
this.deps.config.memoryDir,
|
|
20878
21010
|
"namespaces",
|
|
20879
21011
|
this.deps.config.defaultNamespace
|
|
@@ -20881,11 +21013,11 @@ var NamespaceReadFanoutCoordinator = class {
|
|
|
20881
21013
|
try {
|
|
20882
21014
|
const candidateStat = await stat3(candidate);
|
|
20883
21015
|
if (candidateStat.isDirectory()) {
|
|
20884
|
-
return
|
|
21016
|
+
return path22.join(candidate, "state");
|
|
20885
21017
|
}
|
|
20886
21018
|
} catch {
|
|
20887
21019
|
}
|
|
20888
|
-
return
|
|
21020
|
+
return path22.join(this.deps.config.memoryDir, "state");
|
|
20889
21021
|
}
|
|
20890
21022
|
namespaceFromPath(p) {
|
|
20891
21023
|
if (!resolveNamespaceCapabilities(this.deps.config).namespaces) return this.deps.config.defaultNamespace;
|
|
@@ -21340,7 +21472,7 @@ var Orchestrator = class {
|
|
|
21340
21472
|
if (this.destroyed) throw new Error("orchestrator has been destroyed");
|
|
21341
21473
|
if (!this._dependencyPropagationDelivery) {
|
|
21342
21474
|
this._dependencyPropagationDelivery = new DependencyPropagationDelivery({
|
|
21343
|
-
queueRoot:
|
|
21475
|
+
queueRoot: path23.join(this.config.memoryDir, "state", "dependency-propagation"),
|
|
21344
21476
|
config: this.config,
|
|
21345
21477
|
extraction: this.extraction,
|
|
21346
21478
|
getStorage: (namespace) => this.getStorage(namespace),
|
|
@@ -21695,7 +21827,7 @@ var Orchestrator = class {
|
|
|
21695
21827
|
const defaultNs = normalizeNamespaceIdentity(this.config.defaultNamespace);
|
|
21696
21828
|
if (ns !== defaultNs && !isSafeRouteNamespace(ns)) return;
|
|
21697
21829
|
if (!this.storageDirMatchesNamespaceHint(ns, storageDir)) return;
|
|
21698
|
-
const resolvedStorageDir =
|
|
21830
|
+
const resolvedStorageDir = path23.resolve(storageDir);
|
|
21699
21831
|
let hints = this.namespaceStorageDirHints.get(resolvedStorageDir);
|
|
21700
21832
|
if (!hints) {
|
|
21701
21833
|
hints = /* @__PURE__ */ new Set();
|
|
@@ -21706,21 +21838,21 @@ var Orchestrator = class {
|
|
|
21706
21838
|
storageDirMatchesNamespaceHint(namespace, storageDir) {
|
|
21707
21839
|
const ns = normalizeNamespaceIdentity(namespace);
|
|
21708
21840
|
if (!ns) return false;
|
|
21709
|
-
const resolvedStorageDir =
|
|
21710
|
-
const resolvedMemoryDir =
|
|
21841
|
+
const resolvedStorageDir = path23.resolve(storageDir);
|
|
21842
|
+
const resolvedMemoryDir = path23.resolve(this.config.memoryDir);
|
|
21711
21843
|
const defaultNs = normalizeNamespaceIdentity(this.config.defaultNamespace);
|
|
21712
21844
|
if (resolvedStorageDir === resolvedMemoryDir) return ns === defaultNs;
|
|
21713
|
-
const resolvedNamespacesDir =
|
|
21845
|
+
const resolvedNamespacesDir = path23.join(resolvedMemoryDir, "namespaces");
|
|
21714
21846
|
if (!isPathInsideStorageRoot(resolvedNamespacesDir, resolvedStorageDir)) return false;
|
|
21715
|
-
const rawRoot =
|
|
21716
|
-
const tokenRoot =
|
|
21847
|
+
const rawRoot = path23.resolve(resolvedNamespacesDir, ns);
|
|
21848
|
+
const tokenRoot = path23.resolve(resolvedNamespacesDir, namespaceIdentityToken(ns));
|
|
21717
21849
|
return resolvedStorageDir === rawRoot || resolvedStorageDir === tokenRoot;
|
|
21718
21850
|
}
|
|
21719
21851
|
namespaceStorageDirHintOwnershipRank(record, resolvedStorageDir, configured) {
|
|
21720
|
-
if (resolvedStorageDir ===
|
|
21852
|
+
if (resolvedStorageDir === path23.resolve(this.config.memoryDir)) {
|
|
21721
21853
|
return record.namespace === normalizeNamespaceIdentity(this.config.defaultNamespace) ? 0 : 3;
|
|
21722
21854
|
}
|
|
21723
|
-
const leaf =
|
|
21855
|
+
const leaf = path23.basename(resolvedStorageDir);
|
|
21724
21856
|
const tokenOwnsRoot = namespaceIdentityToken(record.namespace) === leaf;
|
|
21725
21857
|
if (tokenOwnsRoot && configured.has(record.namespace)) return 0;
|
|
21726
21858
|
if (record.namespace === leaf) return 1;
|
|
@@ -21861,7 +21993,7 @@ var Orchestrator = class {
|
|
|
21861
21993
|
StorageManager.setOkfConformanceDefault(config.memoryDir, config.okf?.conformanceEnabled);
|
|
21862
21994
|
this.profiler = new ProfilingCollector({
|
|
21863
21995
|
enabled: resolvePipelineProcessingCapabilities(this.config).profiling,
|
|
21864
|
-
storageDir: config.profilingStorageDir ||
|
|
21996
|
+
storageDir: config.profilingStorageDir || path23.join(config.memoryDir, "profiling"),
|
|
21865
21997
|
maxTraces: config.profilingMaxTraces
|
|
21866
21998
|
});
|
|
21867
21999
|
this.namespaceCatalog = new NamespaceCatalog(config);
|
|
@@ -21948,7 +22080,7 @@ var Orchestrator = class {
|
|
|
21948
22080
|
this.compounding = resolveConsolidationCapabilities(config).compounding ? new CompoundingEngine(config, this.storage) : void 0;
|
|
21949
22081
|
this.buffer = new SmartBuffer(config, this.storage);
|
|
21950
22082
|
this.transcript = new TranscriptManager(config);
|
|
21951
|
-
this.conversationIndexDir =
|
|
22083
|
+
this.conversationIndexDir = path23.join(
|
|
21952
22084
|
config.memoryDir,
|
|
21953
22085
|
"conversation-index",
|
|
21954
22086
|
"chunks"
|
|
@@ -22095,10 +22227,11 @@ var Orchestrator = class {
|
|
|
22095
22227
|
embeddingFallback: this.embeddingFallback,
|
|
22096
22228
|
getEffectiveLifecycleThresholds: () => this.effectiveLifecycleThresholds(),
|
|
22097
22229
|
removeContentHashForMemory: (targetStorage, memory, context) => this.removeContentHashForMemory(targetStorage, memory, context),
|
|
22098
|
-
saveContentHashIndexes: () => this.saveContentHashIndexes()
|
|
22230
|
+
saveContentHashIndexes: () => this.saveContentHashIndexes(),
|
|
22231
|
+
getHandleHistory: () => this.handleHistory
|
|
22099
22232
|
});
|
|
22100
22233
|
this.threading = new ThreadingManager(
|
|
22101
|
-
|
|
22234
|
+
path23.join(config.memoryDir, "threads"),
|
|
22102
22235
|
config.threadingGapMinutes
|
|
22103
22236
|
);
|
|
22104
22237
|
const lifecycleCaps = resolveMemoryLifecycleCapabilities(config);
|
|
@@ -24191,9 +24324,9 @@ function readStructuralSymbol(entry) {
|
|
|
24191
24324
|
const rec = entry;
|
|
24192
24325
|
const symbol = typeof rec.symbol === "string" ? rec.symbol.trim() : "";
|
|
24193
24326
|
if (!symbol) return null;
|
|
24194
|
-
const
|
|
24327
|
+
const path42 = typeof rec.path === "string" && rec.path.length > 0 ? rec.path : void 0;
|
|
24195
24328
|
const kind = typeof rec.kind === "string" && rec.kind.length > 0 ? rec.kind : void 0;
|
|
24196
|
-
const item =
|
|
24329
|
+
const item = path42 !== void 0 && kind !== void 0 ? { symbol, path: path42, kind } : path42 !== void 0 ? { symbol, path: path42 } : kind !== void 0 ? { symbol, kind } : { symbol };
|
|
24197
24330
|
return item;
|
|
24198
24331
|
}
|
|
24199
24332
|
function classifySpawnError(err) {
|
|
@@ -24266,8 +24399,8 @@ var DEFAULT_MAX_BINARY_SIZE_BYTES = 50 * 1024 * 1024;
|
|
|
24266
24399
|
var DEFAULT_GRACE_PERIOD_DAYS = 7;
|
|
24267
24400
|
|
|
24268
24401
|
// src/binary-lifecycle/backend.ts
|
|
24269
|
-
import
|
|
24270
|
-
import
|
|
24402
|
+
import fsp2 from "fs/promises";
|
|
24403
|
+
import path24 from "path";
|
|
24271
24404
|
var FilesystemBackend = class {
|
|
24272
24405
|
type = "filesystem";
|
|
24273
24406
|
basePath;
|
|
@@ -24275,30 +24408,30 @@ var FilesystemBackend = class {
|
|
|
24275
24408
|
if (!basePath || basePath.trim().length === 0) {
|
|
24276
24409
|
throw new Error("FilesystemBackend requires a non-empty basePath");
|
|
24277
24410
|
}
|
|
24278
|
-
this.basePath =
|
|
24411
|
+
this.basePath = path24.resolve(basePath);
|
|
24279
24412
|
}
|
|
24280
24413
|
resolveRemotePath(remotePath) {
|
|
24281
|
-
const resolved =
|
|
24282
|
-
const relative =
|
|
24283
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
24414
|
+
const resolved = path24.isAbsolute(remotePath) ? path24.resolve(remotePath) : path24.resolve(this.basePath, remotePath);
|
|
24415
|
+
const relative = path24.relative(this.basePath, resolved);
|
|
24416
|
+
if (relative === ".." || relative.startsWith(`..${path24.sep}`) || path24.isAbsolute(relative)) {
|
|
24284
24417
|
throw new Error(`FilesystemBackend remotePath escapes basePath: ${JSON.stringify(remotePath)}`);
|
|
24285
24418
|
}
|
|
24286
24419
|
return resolved;
|
|
24287
24420
|
}
|
|
24288
24421
|
isInsideBase(candidate, realBase) {
|
|
24289
|
-
const relative =
|
|
24290
|
-
return relative === "" || relative !== ".." && !relative.startsWith(`..${
|
|
24422
|
+
const relative = path24.relative(realBase, candidate);
|
|
24423
|
+
return relative === "" || relative !== ".." && !relative.startsWith(`..${path24.sep}`) && !path24.isAbsolute(relative);
|
|
24291
24424
|
}
|
|
24292
24425
|
async realBasePathIfExists() {
|
|
24293
24426
|
try {
|
|
24294
|
-
const stat5 = await
|
|
24427
|
+
const stat5 = await fsp2.lstat(this.basePath);
|
|
24295
24428
|
if (stat5.isSymbolicLink()) {
|
|
24296
24429
|
throw new Error(`FilesystemBackend basePath must not be a symlink: ${this.basePath}`);
|
|
24297
24430
|
}
|
|
24298
24431
|
if (!stat5.isDirectory()) {
|
|
24299
24432
|
throw new Error(`FilesystemBackend basePath must be a directory: ${this.basePath}`);
|
|
24300
24433
|
}
|
|
24301
|
-
return await
|
|
24434
|
+
return await fsp2.realpath(this.basePath);
|
|
24302
24435
|
} catch (err) {
|
|
24303
24436
|
if (err.code === "ENOENT") {
|
|
24304
24437
|
return null;
|
|
@@ -24307,7 +24440,7 @@ var FilesystemBackend = class {
|
|
|
24307
24440
|
}
|
|
24308
24441
|
}
|
|
24309
24442
|
async ensureBaseDirectory() {
|
|
24310
|
-
await
|
|
24443
|
+
await fsp2.mkdir(this.basePath, { recursive: true });
|
|
24311
24444
|
const realBase = await this.realBasePathIfExists();
|
|
24312
24445
|
if (realBase === null) {
|
|
24313
24446
|
throw new Error(`FilesystemBackend failed to create basePath: ${this.basePath}`);
|
|
@@ -24316,15 +24449,15 @@ var FilesystemBackend = class {
|
|
|
24316
24449
|
}
|
|
24317
24450
|
async ensureSafeParentDirectory(dest) {
|
|
24318
24451
|
const realBase = await this.ensureBaseDirectory();
|
|
24319
|
-
const destDir =
|
|
24320
|
-
const relativeDir =
|
|
24321
|
-
const segments = relativeDir === "" ? [] : relativeDir.split(
|
|
24452
|
+
const destDir = path24.dirname(dest);
|
|
24453
|
+
const relativeDir = path24.relative(this.basePath, destDir);
|
|
24454
|
+
const segments = relativeDir === "" ? [] : relativeDir.split(path24.sep);
|
|
24322
24455
|
let current = this.basePath;
|
|
24323
24456
|
for (const segment of segments) {
|
|
24324
24457
|
if (segment === "." || segment === "") continue;
|
|
24325
|
-
current =
|
|
24458
|
+
current = path24.join(current, segment);
|
|
24326
24459
|
try {
|
|
24327
|
-
const stat5 = await
|
|
24460
|
+
const stat5 = await fsp2.lstat(current);
|
|
24328
24461
|
if (stat5.isSymbolicLink()) {
|
|
24329
24462
|
throw new Error(`FilesystemBackend remotePath traverses symlink: ${current}`);
|
|
24330
24463
|
}
|
|
@@ -24335,10 +24468,10 @@ var FilesystemBackend = class {
|
|
|
24335
24468
|
if (err.code !== "ENOENT") {
|
|
24336
24469
|
throw err;
|
|
24337
24470
|
}
|
|
24338
|
-
await
|
|
24471
|
+
await fsp2.mkdir(current);
|
|
24339
24472
|
}
|
|
24340
24473
|
}
|
|
24341
|
-
const realParent = await
|
|
24474
|
+
const realParent = await fsp2.realpath(destDir);
|
|
24342
24475
|
if (!this.isInsideBase(realParent, realBase)) {
|
|
24343
24476
|
throw new Error(`FilesystemBackend remotePath parent escapes basePath: ${dest}`);
|
|
24344
24477
|
}
|
|
@@ -24350,16 +24483,16 @@ var FilesystemBackend = class {
|
|
|
24350
24483
|
if (realBase === null) {
|
|
24351
24484
|
return null;
|
|
24352
24485
|
}
|
|
24353
|
-
const destDir =
|
|
24354
|
-
const relativeDir =
|
|
24355
|
-
const segments = relativeDir === "" ? [] : relativeDir.split(
|
|
24486
|
+
const destDir = path24.dirname(dest);
|
|
24487
|
+
const relativeDir = path24.relative(this.basePath, destDir);
|
|
24488
|
+
const segments = relativeDir === "" ? [] : relativeDir.split(path24.sep);
|
|
24356
24489
|
let current = this.basePath;
|
|
24357
24490
|
for (const segment of segments) {
|
|
24358
24491
|
if (segment === "." || segment === "") continue;
|
|
24359
|
-
current =
|
|
24492
|
+
current = path24.join(current, segment);
|
|
24360
24493
|
let stat5;
|
|
24361
24494
|
try {
|
|
24362
|
-
stat5 = await
|
|
24495
|
+
stat5 = await fsp2.lstat(current);
|
|
24363
24496
|
} catch (err) {
|
|
24364
24497
|
if (err.code === "ENOENT") {
|
|
24365
24498
|
return null;
|
|
@@ -24373,7 +24506,7 @@ var FilesystemBackend = class {
|
|
|
24373
24506
|
return null;
|
|
24374
24507
|
}
|
|
24375
24508
|
}
|
|
24376
|
-
const realParent = await
|
|
24509
|
+
const realParent = await fsp2.realpath(destDir).catch((err) => {
|
|
24377
24510
|
if (isErrnoCode(err, "ENOENT")) return null;
|
|
24378
24511
|
throw err;
|
|
24379
24512
|
});
|
|
@@ -24384,7 +24517,7 @@ var FilesystemBackend = class {
|
|
|
24384
24517
|
throw new Error(`FilesystemBackend remotePath parent escapes basePath: ${JSON.stringify(remotePath)}`);
|
|
24385
24518
|
}
|
|
24386
24519
|
try {
|
|
24387
|
-
const stat5 = await
|
|
24520
|
+
const stat5 = await fsp2.lstat(dest);
|
|
24388
24521
|
if (stat5.isSymbolicLink()) {
|
|
24389
24522
|
throw new Error(`FilesystemBackend remotePath points to symlink: ${dest}`);
|
|
24390
24523
|
}
|
|
@@ -24397,20 +24530,20 @@ var FilesystemBackend = class {
|
|
|
24397
24530
|
}
|
|
24398
24531
|
throw err;
|
|
24399
24532
|
}
|
|
24400
|
-
const realDest = await
|
|
24533
|
+
const realDest = await fsp2.realpath(dest);
|
|
24401
24534
|
if (!this.isInsideBase(realDest, realBase)) {
|
|
24402
24535
|
throw new Error(`FilesystemBackend remotePath escapes basePath: ${JSON.stringify(remotePath)}`);
|
|
24403
24536
|
}
|
|
24404
24537
|
return dest;
|
|
24405
24538
|
}
|
|
24406
24539
|
async upload(localPath, remotePath) {
|
|
24407
|
-
if (
|
|
24540
|
+
if (path24.isAbsolute(remotePath)) {
|
|
24408
24541
|
throw new Error(`FilesystemBackend upload remotePath must be relative: ${JSON.stringify(remotePath)}`);
|
|
24409
24542
|
}
|
|
24410
24543
|
const dest = this.resolveRemotePath(remotePath);
|
|
24411
24544
|
const realBase = await this.ensureSafeParentDirectory(dest);
|
|
24412
24545
|
try {
|
|
24413
|
-
const stat5 = await
|
|
24546
|
+
const stat5 = await fsp2.lstat(dest);
|
|
24414
24547
|
if (stat5.isSymbolicLink()) {
|
|
24415
24548
|
throw new Error(`FilesystemBackend remotePath points to symlink: ${dest}`);
|
|
24416
24549
|
}
|
|
@@ -24419,8 +24552,8 @@ var FilesystemBackend = class {
|
|
|
24419
24552
|
throw err;
|
|
24420
24553
|
}
|
|
24421
24554
|
}
|
|
24422
|
-
await
|
|
24423
|
-
const realDest = await
|
|
24555
|
+
await fsp2.copyFile(localPath, dest);
|
|
24556
|
+
const realDest = await fsp2.realpath(dest);
|
|
24424
24557
|
if (!this.isInsideBase(realDest, realBase)) {
|
|
24425
24558
|
throw new Error(`FilesystemBackend remotePath escapes basePath: ${JSON.stringify(remotePath)}`);
|
|
24426
24559
|
}
|
|
@@ -24436,7 +24569,7 @@ var FilesystemBackend = class {
|
|
|
24436
24569
|
return;
|
|
24437
24570
|
}
|
|
24438
24571
|
try {
|
|
24439
|
-
await
|
|
24572
|
+
await fsp2.unlink(dest);
|
|
24440
24573
|
} catch (err) {
|
|
24441
24574
|
if (err.code !== "ENOENT") throw err;
|
|
24442
24575
|
}
|
|
@@ -24476,8 +24609,8 @@ function createBackend(cfg) {
|
|
|
24476
24609
|
}
|
|
24477
24610
|
|
|
24478
24611
|
// src/binary-lifecycle/scanner.ts
|
|
24479
|
-
import
|
|
24480
|
-
import
|
|
24612
|
+
import fsp3 from "fs/promises";
|
|
24613
|
+
import path25 from "path";
|
|
24481
24614
|
import crypto from "crypto";
|
|
24482
24615
|
function matchesPatterns(filename, patterns) {
|
|
24483
24616
|
const lower = filename.toLowerCase();
|
|
@@ -24497,13 +24630,13 @@ async function scanForBinaries(memoryDir, config, manifest) {
|
|
|
24497
24630
|
async function walk(dir) {
|
|
24498
24631
|
let entries;
|
|
24499
24632
|
try {
|
|
24500
|
-
entries = await
|
|
24633
|
+
entries = await fsp3.readdir(dir, { withFileTypes: true });
|
|
24501
24634
|
} catch {
|
|
24502
24635
|
return;
|
|
24503
24636
|
}
|
|
24504
24637
|
for (const entry of entries) {
|
|
24505
|
-
const fullPath =
|
|
24506
|
-
const relativePath =
|
|
24638
|
+
const fullPath = path25.join(dir, entry.name);
|
|
24639
|
+
const relativePath = path25.relative(memoryDir, fullPath).split(path25.sep).join("/");
|
|
24507
24640
|
if (entry.isDirectory()) {
|
|
24508
24641
|
if (entry.name === ".binary-lifecycle") continue;
|
|
24509
24642
|
await walk(fullPath);
|
|
@@ -24512,7 +24645,7 @@ async function scanForBinaries(memoryDir, config, manifest) {
|
|
|
24512
24645
|
if (!entry.isFile()) continue;
|
|
24513
24646
|
if (!matchesPatterns(entry.name, config.scanPatterns)) continue;
|
|
24514
24647
|
try {
|
|
24515
|
-
const stat5 = await
|
|
24648
|
+
const stat5 = await fsp3.stat(fullPath);
|
|
24516
24649
|
if (stat5.size > config.maxBinarySizeBytes) continue;
|
|
24517
24650
|
if (stat5.size === 0) continue;
|
|
24518
24651
|
const existing = tracked.get(relativePath);
|
|
@@ -24537,27 +24670,27 @@ async function scanForBinaries(memoryDir, config, manifest) {
|
|
|
24537
24670
|
return results;
|
|
24538
24671
|
}
|
|
24539
24672
|
async function hashFile(filePath) {
|
|
24540
|
-
const content = await
|
|
24673
|
+
const content = await fsp3.readFile(filePath);
|
|
24541
24674
|
return crypto.createHash("sha256").update(content).digest("hex");
|
|
24542
24675
|
}
|
|
24543
24676
|
|
|
24544
24677
|
// src/binary-lifecycle/manifest.ts
|
|
24545
|
-
import
|
|
24546
|
-
import
|
|
24678
|
+
import fsp4 from "fs/promises";
|
|
24679
|
+
import path26 from "path";
|
|
24547
24680
|
import crypto2 from "crypto";
|
|
24548
24681
|
var MANIFEST_DIR = ".binary-lifecycle";
|
|
24549
24682
|
var MANIFEST_FILE = "manifest.json";
|
|
24550
24683
|
function manifestDir(memoryDir) {
|
|
24551
|
-
return
|
|
24684
|
+
return path26.join(memoryDir, MANIFEST_DIR);
|
|
24552
24685
|
}
|
|
24553
24686
|
function manifestPath(memoryDir) {
|
|
24554
|
-
return
|
|
24687
|
+
return path26.join(memoryDir, MANIFEST_DIR, MANIFEST_FILE);
|
|
24555
24688
|
}
|
|
24556
24689
|
async function readManifest(memoryDir) {
|
|
24557
24690
|
const filePath = manifestPath(memoryDir);
|
|
24558
24691
|
let raw;
|
|
24559
24692
|
try {
|
|
24560
|
-
raw = await
|
|
24693
|
+
raw = await fsp4.readFile(filePath, "utf-8");
|
|
24561
24694
|
} catch (err) {
|
|
24562
24695
|
if (err.code === "ENOENT") {
|
|
24563
24696
|
return emptyManifest();
|
|
@@ -24581,17 +24714,17 @@ async function readManifest(memoryDir) {
|
|
|
24581
24714
|
}
|
|
24582
24715
|
async function writeManifest(memoryDir, manifest) {
|
|
24583
24716
|
const dir = manifestDir(memoryDir);
|
|
24584
|
-
await
|
|
24717
|
+
await fsp4.mkdir(dir, { recursive: true });
|
|
24585
24718
|
const dest = manifestPath(memoryDir);
|
|
24586
24719
|
const tmpSuffix = crypto2.randomBytes(8).toString("hex");
|
|
24587
24720
|
const tmpPath = `${dest}.${tmpSuffix}.tmp`;
|
|
24588
24721
|
const content = JSON.stringify(manifest, null, 2) + "\n";
|
|
24589
|
-
await
|
|
24722
|
+
await fsp4.writeFile(tmpPath, content, "utf-8");
|
|
24590
24723
|
try {
|
|
24591
|
-
await
|
|
24724
|
+
await fsp4.rename(tmpPath, dest);
|
|
24592
24725
|
} catch (renameErr) {
|
|
24593
24726
|
try {
|
|
24594
|
-
await
|
|
24727
|
+
await fsp4.unlink(tmpPath);
|
|
24595
24728
|
} catch {
|
|
24596
24729
|
}
|
|
24597
24730
|
throw renameErr;
|
|
@@ -24602,18 +24735,18 @@ function emptyManifest() {
|
|
|
24602
24735
|
}
|
|
24603
24736
|
|
|
24604
24737
|
// src/binary-lifecycle/pipeline.ts
|
|
24605
|
-
import
|
|
24606
|
-
import
|
|
24738
|
+
import fsp5 from "fs/promises";
|
|
24739
|
+
import path27 from "path";
|
|
24607
24740
|
import crypto3 from "crypto";
|
|
24608
24741
|
var historicalIdCache = new HistoricalEntityCanonicalIdCache();
|
|
24609
24742
|
function isRecallCorpusMarkdown(mdPath, memoryDir) {
|
|
24610
|
-
const rel =
|
|
24611
|
-
if (rel.startsWith("..") ||
|
|
24612
|
-
const top = rel.split(
|
|
24743
|
+
const rel = path27.relative(memoryDir, mdPath);
|
|
24744
|
+
if (rel.startsWith("..") || path27.isAbsolute(rel)) return false;
|
|
24745
|
+
const top = rel.split(path27.sep)[0];
|
|
24613
24746
|
return RECALL_FALLBACK_DIRS.includes(top);
|
|
24614
24747
|
}
|
|
24615
24748
|
async function hashFile2(filePath) {
|
|
24616
|
-
const content = await
|
|
24749
|
+
const content = await fsp5.readFile(filePath);
|
|
24617
24750
|
return crypto3.createHash("sha256").update(content).digest("hex");
|
|
24618
24751
|
}
|
|
24619
24752
|
function guessMimeType(ext) {
|
|
@@ -24633,13 +24766,13 @@ function escapeRegex(s) {
|
|
|
24633
24766
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
24634
24767
|
}
|
|
24635
24768
|
function resolveManifestAssetPath(memoryDir, originalPath) {
|
|
24636
|
-
if (originalPath.length === 0 || originalPath.includes("\0") || originalPath.includes("\\") ||
|
|
24769
|
+
if (originalPath.length === 0 || originalPath.includes("\0") || originalPath.includes("\\") || path27.isAbsolute(originalPath) || path27.win32.isAbsolute(originalPath)) {
|
|
24637
24770
|
return null;
|
|
24638
24771
|
}
|
|
24639
|
-
const memoryRoot =
|
|
24640
|
-
const fullPath =
|
|
24641
|
-
const relative =
|
|
24642
|
-
if (relative === "" || relative === ".." || relative.startsWith(`..${
|
|
24772
|
+
const memoryRoot = path27.resolve(memoryDir);
|
|
24773
|
+
const fullPath = path27.resolve(memoryRoot, originalPath);
|
|
24774
|
+
const relative = path27.relative(memoryRoot, fullPath);
|
|
24775
|
+
if (relative === "" || relative === ".." || relative.startsWith(`..${path27.sep}`) || path27.isAbsolute(relative)) {
|
|
24643
24776
|
return null;
|
|
24644
24777
|
}
|
|
24645
24778
|
return fullPath;
|
|
@@ -24650,7 +24783,7 @@ function validateBinaryLifecycleConfig(config) {
|
|
|
24650
24783
|
}
|
|
24651
24784
|
}
|
|
24652
24785
|
function remotePathForAsset(backend, relPath) {
|
|
24653
|
-
const normalized = relPath.split(
|
|
24786
|
+
const normalized = relPath.split(path27.sep).join("/");
|
|
24654
24787
|
if (backend.type === "filesystem") {
|
|
24655
24788
|
return `.binary-lifecycle/mirrors/${normalized}`;
|
|
24656
24789
|
}
|
|
@@ -24663,11 +24796,11 @@ async function stageMirror(memoryDir, newPaths, backend, assets, log2, dryRun) {
|
|
|
24663
24796
|
let mirrored = 0;
|
|
24664
24797
|
const errors = [];
|
|
24665
24798
|
for (const relPath of newPaths) {
|
|
24666
|
-
const fullPath =
|
|
24799
|
+
const fullPath = path27.join(memoryDir, relPath);
|
|
24667
24800
|
try {
|
|
24668
|
-
const stat5 = await
|
|
24801
|
+
const stat5 = await fsp5.stat(fullPath);
|
|
24669
24802
|
const contentHash = await hashFile2(fullPath);
|
|
24670
|
-
const ext =
|
|
24803
|
+
const ext = path27.extname(relPath);
|
|
24671
24804
|
const mimeType = guessMimeType(ext);
|
|
24672
24805
|
const remotePath = remotePathForAsset(backend, relPath);
|
|
24673
24806
|
let backendLocation = remotePath;
|
|
@@ -24818,7 +24951,7 @@ async function stageRedirect(memoryDir, assets, log2, dryRun, readMarkdownFile,
|
|
|
24818
24951
|
for (const update of updates) {
|
|
24819
24952
|
try {
|
|
24820
24953
|
await withRawEntityPageMutation(memoryDir, update.mdPath, async () => {
|
|
24821
|
-
const stateDir =
|
|
24954
|
+
const stateDir = path27.join(memoryDir, "state");
|
|
24822
24955
|
const kind = classifyEntityRefWritePath(memoryDir, update.mdPath);
|
|
24823
24956
|
if (kind === "memory") {
|
|
24824
24957
|
const idsAtWrite = historicalIdCache.get(stateDir);
|
|
@@ -24911,10 +25044,10 @@ async function countRemainingLocalReferences(memoryDir, asset, assetAbsolute, md
|
|
|
24911
25044
|
return { remaining, errors };
|
|
24912
25045
|
}
|
|
24913
25046
|
function markdownReferencePattern(asset, assetAbsolute, mdPath) {
|
|
24914
|
-
const mdDir =
|
|
25047
|
+
const mdDir = path27.dirname(mdPath);
|
|
24915
25048
|
const candidates = /* @__PURE__ */ new Set();
|
|
24916
25049
|
const addCandidate = (candidate) => {
|
|
24917
|
-
const normalized = candidate.split(
|
|
25050
|
+
const normalized = candidate.split(path27.sep).join("/");
|
|
24918
25051
|
if (normalized.length === 0) return;
|
|
24919
25052
|
candidates.add(normalized);
|
|
24920
25053
|
const isParentTraversal = normalized === ".." || normalized.startsWith("../");
|
|
@@ -24922,10 +25055,10 @@ function markdownReferencePattern(asset, assetAbsolute, mdPath) {
|
|
|
24922
25055
|
candidates.add(`./${normalized}`);
|
|
24923
25056
|
}
|
|
24924
25057
|
};
|
|
24925
|
-
addCandidate(
|
|
24926
|
-
const originalPath = asset.originalPath.split(
|
|
24927
|
-
const originalAsFileRelative =
|
|
24928
|
-
if (
|
|
25058
|
+
addCandidate(path27.relative(mdDir, assetAbsolute));
|
|
25059
|
+
const originalPath = asset.originalPath.split(path27.sep).join("/");
|
|
25060
|
+
const originalAsFileRelative = path27.resolve(mdDir, ...originalPath.split("/"));
|
|
25061
|
+
if (path27.resolve(originalAsFileRelative) === path27.resolve(assetAbsolute)) {
|
|
24929
25062
|
addCandidate(originalPath);
|
|
24930
25063
|
}
|
|
24931
25064
|
addCandidate(`/${originalPath}`);
|
|
@@ -24989,7 +25122,7 @@ async function stageClean(memoryDir, assets, backend, gracePeriodDays, log2, dry
|
|
|
24989
25122
|
continue;
|
|
24990
25123
|
}
|
|
24991
25124
|
if (!dryRun) {
|
|
24992
|
-
await
|
|
25125
|
+
await fsp5.unlink(fullPath);
|
|
24993
25126
|
asset.status = "cleaned";
|
|
24994
25127
|
asset.cleanedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
24995
25128
|
}
|
|
@@ -25016,12 +25149,12 @@ async function findMarkdownFiles(dir) {
|
|
|
25016
25149
|
async function walk(current) {
|
|
25017
25150
|
let entries;
|
|
25018
25151
|
try {
|
|
25019
|
-
entries = await
|
|
25152
|
+
entries = await fsp5.readdir(current, { withFileTypes: true });
|
|
25020
25153
|
} catch {
|
|
25021
25154
|
return;
|
|
25022
25155
|
}
|
|
25023
25156
|
for (const entry of entries) {
|
|
25024
|
-
const full =
|
|
25157
|
+
const full = path27.join(current, entry.name);
|
|
25025
25158
|
if (entry.isDirectory()) {
|
|
25026
25159
|
if (entry.name === ".binary-lifecycle") continue;
|
|
25027
25160
|
await walk(full);
|
|
@@ -25063,8 +25196,8 @@ async function runBinaryLifecyclePipeline(memoryDir, config, backend, log2, opts
|
|
|
25063
25196
|
manifest.assets,
|
|
25064
25197
|
log2,
|
|
25065
25198
|
dryRun,
|
|
25066
|
-
opts?.readMarkdownFile ?? ((filePath) =>
|
|
25067
|
-
opts?.writeMarkdownFile ?? ((filePath, content) =>
|
|
25199
|
+
opts?.readMarkdownFile ?? ((filePath) => fsp5.readFile(filePath, "utf-8")),
|
|
25200
|
+
opts?.writeMarkdownFile ?? ((filePath, content) => fsp5.writeFile(filePath, content, "utf-8"))
|
|
25068
25201
|
);
|
|
25069
25202
|
const cleanResult = await stageClean(
|
|
25070
25203
|
memoryDir,
|
|
@@ -25096,7 +25229,7 @@ async function runBinaryLifecyclePipeline(memoryDir, config, backend, log2, opts
|
|
|
25096
25229
|
|
|
25097
25230
|
// src/projection/index.ts
|
|
25098
25231
|
import fs from "fs";
|
|
25099
|
-
import
|
|
25232
|
+
import path28 from "path";
|
|
25100
25233
|
var VALID_PROJECTION_CATEGORIES = new Set(ALL_CATEGORY_KEYS);
|
|
25101
25234
|
async function generateContextTree(options) {
|
|
25102
25235
|
const startTime = Date.now();
|
|
@@ -25111,8 +25244,8 @@ async function generateContextTree(options) {
|
|
|
25111
25244
|
let nodesGenerated = 0;
|
|
25112
25245
|
let nodesSkipped = 0;
|
|
25113
25246
|
const categoryCounts = {};
|
|
25114
|
-
const resolvedMemoryDir =
|
|
25115
|
-
const resolvedOutputDir =
|
|
25247
|
+
const resolvedMemoryDir = path28.resolve(memoryDir);
|
|
25248
|
+
const resolvedOutputDir = path28.resolve(outputDir);
|
|
25116
25249
|
const requestedCategories = validateProjectionCategories(filterCategories);
|
|
25117
25250
|
const realMemoryDir = assertSafeMemoryRoot(resolvedMemoryDir);
|
|
25118
25251
|
assertNotSymlink(resolvedOutputDir, "context tree outputDir");
|
|
@@ -25150,7 +25283,7 @@ async function generateContextTree(options) {
|
|
|
25150
25283
|
}
|
|
25151
25284
|
}
|
|
25152
25285
|
if (includeEntities) {
|
|
25153
|
-
const entitiesDir =
|
|
25286
|
+
const entitiesDir = path28.join(memoryDir, "entities");
|
|
25154
25287
|
if (fs.existsSync(entitiesDir)) {
|
|
25155
25288
|
assertSafeInputRoot(realMemoryDir, entitiesDir, "entities root");
|
|
25156
25289
|
categoryCounts["entity"] = 0;
|
|
@@ -25162,7 +25295,7 @@ async function generateContextTree(options) {
|
|
|
25162
25295
|
continue;
|
|
25163
25296
|
}
|
|
25164
25297
|
const content = fs.readFileSync(filePath, "utf8");
|
|
25165
|
-
const fileName =
|
|
25298
|
+
const fileName = path28.basename(filePath, ".md");
|
|
25166
25299
|
const node = projectEntityNode(fileName, content);
|
|
25167
25300
|
const outputPath = resolveContainedOutputPath(realOutputDir, "entities", `${fileName}.md`);
|
|
25168
25301
|
writeProjectedContent(realOutputDir, outputPath, node.content);
|
|
@@ -25174,7 +25307,7 @@ async function generateContextTree(options) {
|
|
|
25174
25307
|
}
|
|
25175
25308
|
const shouldIncludeQuestions = includeQuestions && (requestedCategories === void 0 || requestedCategories.includes("question"));
|
|
25176
25309
|
if (shouldIncludeQuestions) {
|
|
25177
|
-
const questionsDir =
|
|
25310
|
+
const questionsDir = path28.join(memoryDir, "questions");
|
|
25178
25311
|
if (fs.existsSync(questionsDir)) {
|
|
25179
25312
|
assertSafeInputRoot(realMemoryDir, questionsDir, "questions root");
|
|
25180
25313
|
categoryCounts["question"] = 0;
|
|
@@ -25215,8 +25348,8 @@ async function generateContextTree(options) {
|
|
|
25215
25348
|
};
|
|
25216
25349
|
}
|
|
25217
25350
|
function isPathInside(root, candidate) {
|
|
25218
|
-
const relative =
|
|
25219
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
25351
|
+
const relative = path28.relative(root, candidate);
|
|
25352
|
+
return relative === "" || !relative.startsWith("..") && !path28.isAbsolute(relative);
|
|
25220
25353
|
}
|
|
25221
25354
|
function assertNotSymlink(targetPath, label) {
|
|
25222
25355
|
try {
|
|
@@ -25253,12 +25386,12 @@ function assertSafeInputRoot(realMemoryDir, targetPath, label) {
|
|
|
25253
25386
|
}
|
|
25254
25387
|
function assertSafeOutputTarget(realOutputDir, outputPath) {
|
|
25255
25388
|
let current = realOutputDir;
|
|
25256
|
-
const relative =
|
|
25257
|
-
if (relative.startsWith("..") ||
|
|
25389
|
+
const relative = path28.relative(realOutputDir, outputPath);
|
|
25390
|
+
if (relative.startsWith("..") || path28.isAbsolute(relative)) {
|
|
25258
25391
|
throw new Error(`context tree output path escapes outputDir: ${outputPath}`);
|
|
25259
25392
|
}
|
|
25260
|
-
for (const segment of relative.split(
|
|
25261
|
-
current =
|
|
25393
|
+
for (const segment of relative.split(path28.sep).filter(Boolean)) {
|
|
25394
|
+
current = path28.join(current, segment);
|
|
25262
25395
|
try {
|
|
25263
25396
|
const stat5 = fs.lstatSync(current);
|
|
25264
25397
|
if (stat5.isSymbolicLink()) {
|
|
@@ -25288,17 +25421,17 @@ function validateProjectionCategories(categories) {
|
|
|
25288
25421
|
return validated;
|
|
25289
25422
|
}
|
|
25290
25423
|
function resolveContainedOutputPath(outputRoot, ...segments) {
|
|
25291
|
-
const resolved =
|
|
25292
|
-
const relative =
|
|
25293
|
-
if (relative === "" || !relative.startsWith("..") && !
|
|
25424
|
+
const resolved = path28.resolve(outputRoot, ...segments);
|
|
25425
|
+
const relative = path28.relative(outputRoot, resolved);
|
|
25426
|
+
if (relative === "" || !relative.startsWith("..") && !path28.isAbsolute(relative)) {
|
|
25294
25427
|
return resolved;
|
|
25295
25428
|
}
|
|
25296
25429
|
throw new Error(`context tree output path escapes outputDir: ${segments.join("/")}`);
|
|
25297
25430
|
}
|
|
25298
25431
|
function writeProjectedContent(realOutputDir, outputPath, generatedContent) {
|
|
25299
25432
|
assertSafeOutputTarget(realOutputDir, outputPath);
|
|
25300
|
-
fs.mkdirSync(
|
|
25301
|
-
const realParent = fs.realpathSync(
|
|
25433
|
+
fs.mkdirSync(path28.dirname(outputPath), { recursive: true });
|
|
25434
|
+
const realParent = fs.realpathSync(path28.dirname(outputPath));
|
|
25302
25435
|
if (!isPathInside(realOutputDir, realParent)) {
|
|
25303
25436
|
throw new Error(`context tree output path escapes outputDir: ${outputPath}`);
|
|
25304
25437
|
}
|
|
@@ -25337,7 +25470,7 @@ function walkR(dir, realMemoryDir) {
|
|
|
25337
25470
|
const results = [];
|
|
25338
25471
|
function walk(directory) {
|
|
25339
25472
|
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
25340
|
-
const fullPath =
|
|
25473
|
+
const fullPath = path28.join(directory, entry.name);
|
|
25341
25474
|
if (entry.isSymbolicLink()) {
|
|
25342
25475
|
throw new Error(`context tree input path contains symlink: ${fullPath}`);
|
|
25343
25476
|
}
|
|
@@ -25390,13 +25523,13 @@ function extractBody(content) {
|
|
|
25390
25523
|
}
|
|
25391
25524
|
function projectNode(filePath, category, fm, rawContent) {
|
|
25392
25525
|
const body = extractBody(rawContent);
|
|
25393
|
-
const fileName =
|
|
25394
|
-
const dateDir =
|
|
25526
|
+
const fileName = path28.basename(filePath, ".md");
|
|
25527
|
+
const dateDir = path28.basename(path28.dirname(filePath));
|
|
25395
25528
|
let relPath;
|
|
25396
25529
|
if (/^\d{4}-\d{2}-\d{2}$/.test(dateDir)) {
|
|
25397
|
-
relPath =
|
|
25530
|
+
relPath = path28.join(category, dateDir, `${fileName}.md`);
|
|
25398
25531
|
} else {
|
|
25399
|
-
relPath =
|
|
25532
|
+
relPath = path28.join(category, `${fileName}.md`);
|
|
25400
25533
|
}
|
|
25401
25534
|
const generatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
25402
25535
|
const md = `# ${fm.id}
|
|
@@ -25442,7 +25575,7 @@ function projectEntityNode(fileName, content) {
|
|
|
25442
25575
|
${content}
|
|
25443
25576
|
`;
|
|
25444
25577
|
return {
|
|
25445
|
-
path:
|
|
25578
|
+
path: path28.join("entities", `${fileName}.md`),
|
|
25446
25579
|
category: "entity",
|
|
25447
25580
|
title: fileName,
|
|
25448
25581
|
content: md,
|
|
@@ -25495,7 +25628,7 @@ function generateIndex(categoryCounts, outputDir) {
|
|
|
25495
25628
|
|
|
25496
25629
|
// src/onboarding/index.ts
|
|
25497
25630
|
import fs2 from "fs";
|
|
25498
|
-
import
|
|
25631
|
+
import path29 from "path";
|
|
25499
25632
|
var LANGUAGE_RULES = [
|
|
25500
25633
|
{
|
|
25501
25634
|
language: "TypeScript",
|
|
@@ -25597,7 +25730,7 @@ function onboard(options) {
|
|
|
25597
25730
|
maxDepth = 6,
|
|
25598
25731
|
excludeDirs = []
|
|
25599
25732
|
} = options;
|
|
25600
|
-
const directory =
|
|
25733
|
+
const directory = path29.resolve(options.directory ?? process.cwd());
|
|
25601
25734
|
let rootStat;
|
|
25602
25735
|
try {
|
|
25603
25736
|
rootStat = fs2.statSync(directory);
|
|
@@ -25639,7 +25772,7 @@ function walkDir(root, exclude, maxDepth) {
|
|
|
25639
25772
|
}
|
|
25640
25773
|
for (const entry of entries) {
|
|
25641
25774
|
if (exclude.has(entry.name)) continue;
|
|
25642
|
-
const fullPath =
|
|
25775
|
+
const fullPath = path29.join(dir, entry.name);
|
|
25643
25776
|
if (entry.isDirectory()) {
|
|
25644
25777
|
walk(fullPath, depth + 1);
|
|
25645
25778
|
} else if (entry.isFile()) {
|
|
@@ -25654,11 +25787,11 @@ function detectLanguages(files, root) {
|
|
|
25654
25787
|
const results = [];
|
|
25655
25788
|
const extCounts = /* @__PURE__ */ new Map();
|
|
25656
25789
|
for (const f of files) {
|
|
25657
|
-
const ext =
|
|
25790
|
+
const ext = path29.extname(f).toLowerCase();
|
|
25658
25791
|
if (ext) extCounts.set(ext, (extCounts.get(ext) ?? 0) + 1);
|
|
25659
25792
|
}
|
|
25660
25793
|
const rootFiles = new Set(
|
|
25661
|
-
files.filter((f) =>
|
|
25794
|
+
files.filter((f) => path29.dirname(f) === root).map((f) => path29.basename(f))
|
|
25662
25795
|
);
|
|
25663
25796
|
for (const rule of LANGUAGE_RULES) {
|
|
25664
25797
|
const evidence = [];
|
|
@@ -25702,7 +25835,7 @@ function detectLanguages(files, root) {
|
|
|
25702
25835
|
}
|
|
25703
25836
|
function detectShape(files, root) {
|
|
25704
25837
|
const rootFiles = new Set(
|
|
25705
|
-
files.filter((f) =>
|
|
25838
|
+
files.filter((f) => path29.dirname(f) === root).map((f) => path29.basename(f))
|
|
25706
25839
|
);
|
|
25707
25840
|
const rootDirs = /* @__PURE__ */ new Set();
|
|
25708
25841
|
try {
|
|
@@ -25713,7 +25846,7 @@ function detectShape(files, root) {
|
|
|
25713
25846
|
}
|
|
25714
25847
|
const evidence = [];
|
|
25715
25848
|
if (rootFiles.has("package.json")) {
|
|
25716
|
-
const pkg = readJsonSafe(
|
|
25849
|
+
const pkg = readJsonSafe(path29.join(root, "package.json"));
|
|
25717
25850
|
if (pkg?.workspaces) {
|
|
25718
25851
|
evidence.push("package.json has workspaces");
|
|
25719
25852
|
return { shape: "monorepo", evidence };
|
|
@@ -25727,13 +25860,13 @@ function detectShape(files, root) {
|
|
|
25727
25860
|
evidence.push("workspace manifest found");
|
|
25728
25861
|
return { shape: "workspace", evidence };
|
|
25729
25862
|
}
|
|
25730
|
-
const cargoToml = readTomlWorkspace(
|
|
25863
|
+
const cargoToml = readTomlWorkspace(path29.join(root, "Cargo.toml"));
|
|
25731
25864
|
if (cargoToml) {
|
|
25732
25865
|
evidence.push("Cargo.toml has workspace");
|
|
25733
25866
|
return { shape: "workspace", evidence };
|
|
25734
25867
|
}
|
|
25735
25868
|
if (rootFiles.has("package.json")) {
|
|
25736
|
-
const pkg = readJsonSafe(
|
|
25869
|
+
const pkg = readJsonSafe(path29.join(root, "package.json"));
|
|
25737
25870
|
if (pkg?.exports || pkg?.main) {
|
|
25738
25871
|
if (pkg?.bin) {
|
|
25739
25872
|
evidence.push("package.json has bin");
|
|
@@ -25767,8 +25900,8 @@ function discoverDocs(files, root) {
|
|
|
25767
25900
|
{ pattern: /^\.editorconfig$/i, kind: "config" }
|
|
25768
25901
|
];
|
|
25769
25902
|
for (const filePath of files) {
|
|
25770
|
-
const basename =
|
|
25771
|
-
const relPath =
|
|
25903
|
+
const basename = path29.basename(filePath).toLowerCase();
|
|
25904
|
+
const relPath = path29.relative(root, filePath);
|
|
25772
25905
|
let kind;
|
|
25773
25906
|
for (const { pattern, kind: k } of docPatterns) {
|
|
25774
25907
|
if (pattern.test(basename)) {
|
|
@@ -25780,7 +25913,7 @@ function discoverDocs(files, root) {
|
|
|
25780
25913
|
kind = "docs";
|
|
25781
25914
|
}
|
|
25782
25915
|
if (!kind && (basename.endsWith(".md") || basename.endsWith(".mdx"))) {
|
|
25783
|
-
if (
|
|
25916
|
+
if (path29.dirname(relPath) === "." || isUnderDocsDir(relPath)) {
|
|
25784
25917
|
kind = "docs";
|
|
25785
25918
|
}
|
|
25786
25919
|
}
|
|
@@ -25801,7 +25934,7 @@ function discoverDocs(files, root) {
|
|
|
25801
25934
|
return docs;
|
|
25802
25935
|
}
|
|
25803
25936
|
function isUnderDocsDir(relPath) {
|
|
25804
|
-
const parts = relPath.split(
|
|
25937
|
+
const parts = relPath.split(path29.sep);
|
|
25805
25938
|
return parts[0] === "docs" || parts[0] === "doc" || parts[0] === "documentation";
|
|
25806
25939
|
}
|
|
25807
25940
|
function buildPlan(languages, shape, docs, _root) {
|
|
@@ -25845,7 +25978,7 @@ function readTomlWorkspace(filePath) {
|
|
|
25845
25978
|
|
|
25846
25979
|
// src/curation/index.ts
|
|
25847
25980
|
import fs3 from "fs";
|
|
25848
|
-
import
|
|
25981
|
+
import path30 from "path";
|
|
25849
25982
|
import crypto4 from "crypto";
|
|
25850
25983
|
async function curate(options) {
|
|
25851
25984
|
const startTime = Date.now();
|
|
@@ -25936,12 +26069,12 @@ function resolveTargets(targetPath) {
|
|
|
25936
26069
|
const extensions = /* @__PURE__ */ new Set([".md", ".txt", ".mdx", ".rst"]);
|
|
25937
26070
|
function walk(dir) {
|
|
25938
26071
|
for (const entry of fs3.readdirSync(dir, { withFileTypes: true })) {
|
|
25939
|
-
const fullPath =
|
|
26072
|
+
const fullPath = path30.join(dir, entry.name);
|
|
25940
26073
|
if (entry.isDirectory()) {
|
|
25941
26074
|
if (entry.name !== "node_modules" && entry.name !== ".git") {
|
|
25942
26075
|
walk(fullPath);
|
|
25943
26076
|
}
|
|
25944
|
-
} else if (extensions.has(
|
|
26077
|
+
} else if (extensions.has(path30.extname(entry.name).toLowerCase())) {
|
|
25945
26078
|
results.push(fullPath);
|
|
25946
26079
|
}
|
|
25947
26080
|
}
|
|
@@ -25950,12 +26083,12 @@ function resolveTargets(targetPath) {
|
|
|
25950
26083
|
return results;
|
|
25951
26084
|
}
|
|
25952
26085
|
function resolveProvenanceRoot(targetPath) {
|
|
25953
|
-
const resolvedTarget =
|
|
26086
|
+
const resolvedTarget = path30.resolve(targetPath);
|
|
25954
26087
|
const stat5 = fs3.statSync(resolvedTarget);
|
|
25955
|
-
return stat5.isFile() ?
|
|
26088
|
+
return stat5.isFile() ? path30.dirname(resolvedTarget) : resolvedTarget;
|
|
25956
26089
|
}
|
|
25957
26090
|
function extractStatements(content, filePath, projectRoot, source, sourceFileHash, categoryOverride, confidence, entityRef, tags) {
|
|
25958
|
-
const relativePath =
|
|
26091
|
+
const relativePath = path30.relative(projectRoot, path30.resolve(filePath)) || path30.basename(filePath);
|
|
25959
26092
|
const statements = [];
|
|
25960
26093
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
25961
26094
|
const paragraphs = content.split(/\n{2,}/).map((p) => p.trim()).filter((p) => p.length > 20 && p.length < 2e3);
|
|
@@ -26049,7 +26182,7 @@ function loadExistingMemories(memoryDir) {
|
|
|
26049
26182
|
if (!fs3.existsSync(memoryDir)) return result;
|
|
26050
26183
|
const dirs = ALL_CATEGORY_DIRS;
|
|
26051
26184
|
for (const dir of dirs) {
|
|
26052
|
-
const fullDir =
|
|
26185
|
+
const fullDir = path30.join(memoryDir, dir);
|
|
26053
26186
|
if (!fs3.existsSync(fullDir)) continue;
|
|
26054
26187
|
walkFiles(fullDir, (filePath) => {
|
|
26055
26188
|
const content = readFileSafe(filePath);
|
|
@@ -26072,11 +26205,11 @@ function writeStatement(stmt, memoryDir) {
|
|
|
26072
26205
|
const now = /* @__PURE__ */ new Date();
|
|
26073
26206
|
const dateDir = now.toISOString().split("T")[0];
|
|
26074
26207
|
const categoryDir = getCategoryDir(memoryDir, stmt.category);
|
|
26075
|
-
const dir =
|
|
26208
|
+
const dir = path30.join(categoryDir, dateDir);
|
|
26076
26209
|
fs3.mkdirSync(dir, { recursive: true });
|
|
26077
26210
|
const fileName = `${stmt.category}-${Date.now()}-${stmt.id.slice(0, 8)}.md`;
|
|
26078
|
-
const filePath =
|
|
26079
|
-
const historicalIds = historicalIdCache2.get(
|
|
26211
|
+
const filePath = path30.join(dir, fileName);
|
|
26212
|
+
const historicalIds = historicalIdCache2.get(path30.join(memoryDir, "state"));
|
|
26080
26213
|
const rawBody = `${[
|
|
26081
26214
|
"---",
|
|
26082
26215
|
`id: ${stmt.id}`,
|
|
@@ -26099,7 +26232,7 @@ ${stmt.content}
|
|
|
26099
26232
|
fs3.writeFileSync(filePath, body);
|
|
26100
26233
|
try {
|
|
26101
26234
|
repairContentAfterJournalMoveSync({
|
|
26102
|
-
stateDir:
|
|
26235
|
+
stateDir: path30.join(memoryDir, "state"),
|
|
26103
26236
|
cache: historicalIdCache2,
|
|
26104
26237
|
idsAtWrite: historicalIds,
|
|
26105
26238
|
rawContent: rawBody,
|
|
@@ -26160,7 +26293,7 @@ function extractBody2(content) {
|
|
|
26160
26293
|
}
|
|
26161
26294
|
function walkFiles(dir, callback) {
|
|
26162
26295
|
for (const entry of fs3.readdirSync(dir, { withFileTypes: true })) {
|
|
26163
|
-
const fullPath =
|
|
26296
|
+
const fullPath = path30.join(dir, entry.name);
|
|
26164
26297
|
if (entry.isDirectory()) {
|
|
26165
26298
|
walkFiles(fullPath, callback);
|
|
26166
26299
|
} else if (entry.name.endsWith(".md")) {
|
|
@@ -26172,7 +26305,7 @@ function walkFiles(dir, callback) {
|
|
|
26172
26305
|
// src/dedup/index.ts
|
|
26173
26306
|
import crypto5 from "crypto";
|
|
26174
26307
|
import fs4 from "fs";
|
|
26175
|
-
import
|
|
26308
|
+
import path31 from "path";
|
|
26176
26309
|
var DEFAULT_DEDUP_THRESHOLD = 0.85;
|
|
26177
26310
|
var DEFAULT_MAX_LOAD = 1e4;
|
|
26178
26311
|
function normalizeThreshold(value, defaultValue) {
|
|
@@ -26379,7 +26512,7 @@ function loadMemories(memoryDir, categories, maxLoad = 1e4) {
|
|
|
26379
26512
|
const memoryRootReal = fs4.realpathSync(memoryDir);
|
|
26380
26513
|
for (const category of allCategories) {
|
|
26381
26514
|
if (result.length >= maxLoad) break;
|
|
26382
|
-
const dir =
|
|
26515
|
+
const dir = path31.join(memoryDir, category);
|
|
26383
26516
|
if (!fs4.existsSync(dir)) continue;
|
|
26384
26517
|
const categoryStat = fs4.lstatSync(dir);
|
|
26385
26518
|
if (categoryStat.isSymbolicLink()) {
|
|
@@ -26440,15 +26573,15 @@ function extractBody3(content) {
|
|
|
26440
26573
|
return match ? match[1].trim() : content.trim();
|
|
26441
26574
|
}
|
|
26442
26575
|
function assertPathInsideRoot2(rootReal, targetReal, sourcePath) {
|
|
26443
|
-
const rel =
|
|
26444
|
-
if (rel === "" || !rel.startsWith("..") && !
|
|
26576
|
+
const rel = path31.relative(rootReal, targetReal);
|
|
26577
|
+
if (rel === "" || !rel.startsWith("..") && !path31.isAbsolute(rel)) {
|
|
26445
26578
|
return;
|
|
26446
26579
|
}
|
|
26447
26580
|
throw new Error(`Refusing to scan memory path outside root: ${sourcePath}`);
|
|
26448
26581
|
}
|
|
26449
26582
|
function walkMdFiles(dir, memoryRootReal, categoryRootReal, callback) {
|
|
26450
26583
|
for (const entry of fs4.readdirSync(dir, { withFileTypes: true })) {
|
|
26451
|
-
const fullPath =
|
|
26584
|
+
const fullPath = path31.join(dir, entry.name);
|
|
26452
26585
|
const entryStat = fs4.lstatSync(fullPath);
|
|
26453
26586
|
if (entryStat.isSymbolicLink()) {
|
|
26454
26587
|
throw new Error(`Refusing to scan symlinked memory path: ${fullPath}`);
|
|
@@ -26466,7 +26599,7 @@ function walkMdFiles(dir, memoryRootReal, categoryRootReal, callback) {
|
|
|
26466
26599
|
|
|
26467
26600
|
// src/sync/index.ts
|
|
26468
26601
|
import fs5 from "fs";
|
|
26469
|
-
import
|
|
26602
|
+
import path32 from "path";
|
|
26470
26603
|
import crypto6 from "crypto";
|
|
26471
26604
|
var DEFAULT_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".txt", ".mdx", ".rst"]);
|
|
26472
26605
|
var DEFAULT_EXCLUDE2 = /* @__PURE__ */ new Set([
|
|
@@ -26488,7 +26621,7 @@ function syncChanges(options) {
|
|
|
26488
26621
|
} = options;
|
|
26489
26622
|
const extSet = new Set(extensions);
|
|
26490
26623
|
const excludeSet = /* @__PURE__ */ new Set([...DEFAULT_EXCLUDE2, ...excludeDirs]);
|
|
26491
|
-
const stateFilePath = options.stateFile ??
|
|
26624
|
+
const stateFilePath = options.stateFile ?? path32.join(memoryDir, ".sync-state.json");
|
|
26492
26625
|
const prevState = loadState(stateFilePath);
|
|
26493
26626
|
const currentFiles = scanFiles(sourceDir, extSet, excludeSet);
|
|
26494
26627
|
const changes = computeDiff(currentFiles, prevState.fileHashes, sourceDir);
|
|
@@ -26504,7 +26637,7 @@ function syncChanges(options) {
|
|
|
26504
26637
|
for (const [relPath, hash] of Object.entries(currentFiles)) {
|
|
26505
26638
|
newState.fileHashes[relPath] = hash;
|
|
26506
26639
|
}
|
|
26507
|
-
fs5.mkdirSync(
|
|
26640
|
+
fs5.mkdirSync(path32.dirname(stateFilePath), { recursive: true });
|
|
26508
26641
|
fs5.writeFileSync(stateFilePath, JSON.stringify(newState, null, 2));
|
|
26509
26642
|
}
|
|
26510
26643
|
return {
|
|
@@ -26570,13 +26703,13 @@ function scanFiles(root, extensions, exclude) {
|
|
|
26570
26703
|
}
|
|
26571
26704
|
for (const entry of entries) {
|
|
26572
26705
|
if (exclude.has(entry.name)) continue;
|
|
26573
|
-
const fullPath =
|
|
26706
|
+
const fullPath = path32.join(dir, entry.name);
|
|
26574
26707
|
if (entry.isDirectory()) {
|
|
26575
26708
|
walk(fullPath);
|
|
26576
26709
|
} else if (entry.isFile()) {
|
|
26577
|
-
const ext =
|
|
26710
|
+
const ext = path32.extname(entry.name).toLowerCase();
|
|
26578
26711
|
if (!extensions.has(ext)) continue;
|
|
26579
|
-
const relPath =
|
|
26712
|
+
const relPath = path32.relative(root, fullPath);
|
|
26580
26713
|
try {
|
|
26581
26714
|
const content = fs5.readFileSync(fullPath, "utf8");
|
|
26582
26715
|
result[relPath] = hashContent3(content);
|
|
@@ -26591,7 +26724,7 @@ function scanFiles(root, extensions, exclude) {
|
|
|
26591
26724
|
function computeDiff(current, previous, sourceDir) {
|
|
26592
26725
|
const changes = [];
|
|
26593
26726
|
for (const [relPath, hash] of Object.entries(current)) {
|
|
26594
|
-
const fullPath =
|
|
26727
|
+
const fullPath = path32.join(sourceDir, relPath);
|
|
26595
26728
|
if (!(relPath in previous)) {
|
|
26596
26729
|
let size = 0;
|
|
26597
26730
|
try {
|
|
@@ -26624,7 +26757,7 @@ function computeDiff(current, previous, sourceDir) {
|
|
|
26624
26757
|
for (const relPath of Object.keys(previous)) {
|
|
26625
26758
|
if (!(relPath in current)) {
|
|
26626
26759
|
changes.push({
|
|
26627
|
-
filePath:
|
|
26760
|
+
filePath: path32.join(sourceDir, relPath),
|
|
26628
26761
|
relativePath: relPath,
|
|
26629
26762
|
type: "deleted",
|
|
26630
26763
|
currentHash: "",
|
|
@@ -26654,21 +26787,21 @@ function hashContent3(content) {
|
|
|
26654
26787
|
import { spawnSync } from "child_process";
|
|
26655
26788
|
import crypto7 from "crypto";
|
|
26656
26789
|
import fs6 from "fs";
|
|
26657
|
-
import
|
|
26790
|
+
import path33 from "path";
|
|
26658
26791
|
var historicalIdCache3 = new HistoricalEntityCanonicalIdCache();
|
|
26659
26792
|
var MANIFEST_VERSION = 1;
|
|
26660
26793
|
var MANIFEST_LOCK_STALE_MS = 3e4;
|
|
26661
26794
|
var MANIFEST_LOCK_TIMEOUT_MS = MANIFEST_LOCK_STALE_MS + 1e4;
|
|
26662
26795
|
var MANIFEST_LOCK_SLEEP_MS = 20;
|
|
26663
26796
|
function normalizeSpaceMemoryDir(memoryDir) {
|
|
26664
|
-
return
|
|
26797
|
+
return path33.resolve(memoryDir);
|
|
26665
26798
|
}
|
|
26666
26799
|
function getSpacesDir(baseDir) {
|
|
26667
26800
|
const homeDir = baseDir ?? resolveHomeDir();
|
|
26668
|
-
return
|
|
26801
|
+
return path33.join(homeDir, ".config", "engram", "spaces");
|
|
26669
26802
|
}
|
|
26670
26803
|
function getManifestPath(baseDir) {
|
|
26671
|
-
return
|
|
26804
|
+
return path33.join(getSpacesDir(baseDir), "manifest.json");
|
|
26672
26805
|
}
|
|
26673
26806
|
function loadManifest(baseDir, memoryDirOverride) {
|
|
26674
26807
|
if (fs6.existsSync(getManifestPath(baseDir))) {
|
|
@@ -26715,9 +26848,9 @@ function readManifestUnlocked(baseDir, memoryDirOverride, options = {}) {
|
|
|
26715
26848
|
}
|
|
26716
26849
|
function saveManifestUnlocked(manifest, baseDir) {
|
|
26717
26850
|
const manifestPath2 = getManifestPath(baseDir);
|
|
26718
|
-
const manifestDir2 =
|
|
26851
|
+
const manifestDir2 = path33.dirname(manifestPath2);
|
|
26719
26852
|
fs6.mkdirSync(manifestDir2, { recursive: true });
|
|
26720
|
-
const tempPath =
|
|
26853
|
+
const tempPath = path33.join(manifestDir2, `.manifest.${process.pid}.${Date.now()}.${crypto7.randomUUID()}.tmp`);
|
|
26721
26854
|
try {
|
|
26722
26855
|
fs6.writeFileSync(tempPath, `${JSON.stringify(manifest, null, 2)}
|
|
26723
26856
|
`, { flag: "wx" });
|
|
@@ -26732,7 +26865,7 @@ function saveManifestUnlocked(manifest, baseDir) {
|
|
|
26732
26865
|
}
|
|
26733
26866
|
function withManifestLock(baseDir, operation) {
|
|
26734
26867
|
const lockDir = `${getManifestPath(baseDir)}.lock`;
|
|
26735
|
-
fs6.mkdirSync(
|
|
26868
|
+
fs6.mkdirSync(path33.dirname(lockDir), { recursive: true });
|
|
26736
26869
|
const lockOwner = acquireManifestLock(lockDir);
|
|
26737
26870
|
try {
|
|
26738
26871
|
return operation();
|
|
@@ -26758,7 +26891,7 @@ function acquireManifestLock(lockDir) {
|
|
|
26758
26891
|
try {
|
|
26759
26892
|
fs6.mkdirSync(lockDir, { recursive: false });
|
|
26760
26893
|
try {
|
|
26761
|
-
fs6.writeFileSync(
|
|
26894
|
+
fs6.writeFileSync(path33.join(lockDir, "owner"), `${owner}
|
|
26762
26895
|
`, { flag: "wx" });
|
|
26763
26896
|
} catch (error) {
|
|
26764
26897
|
fs6.rmSync(lockDir, { recursive: true, force: true });
|
|
@@ -26788,7 +26921,7 @@ function acquireManifestLock(lockDir) {
|
|
|
26788
26921
|
}
|
|
26789
26922
|
function releaseManifestLock(lockDir, owner) {
|
|
26790
26923
|
try {
|
|
26791
|
-
const ownerPath =
|
|
26924
|
+
const ownerPath = path33.join(lockDir, "owner");
|
|
26792
26925
|
if (fs6.readFileSync(ownerPath, "utf8").trim() === owner) {
|
|
26793
26926
|
fs6.rmSync(lockDir, { recursive: true, force: true });
|
|
26794
26927
|
}
|
|
@@ -26804,7 +26937,7 @@ function removeStaleManifestLock(lockDir) {
|
|
|
26804
26937
|
try {
|
|
26805
26938
|
fs6.mkdirSync(reclaimDir, { recursive: false });
|
|
26806
26939
|
try {
|
|
26807
|
-
fs6.writeFileSync(
|
|
26940
|
+
fs6.writeFileSync(path33.join(reclaimDir, "owner"), `${reclaimOwner}
|
|
26808
26941
|
`, { flag: "wx" });
|
|
26809
26942
|
} catch (error) {
|
|
26810
26943
|
fs6.rmSync(reclaimDir, { recursive: true, force: true });
|
|
@@ -26879,7 +27012,7 @@ function readManifestLockSnapshot(lockDir) {
|
|
|
26879
27012
|
throw error;
|
|
26880
27013
|
}
|
|
26881
27014
|
try {
|
|
26882
|
-
const owner = fs6.readFileSync(
|
|
27015
|
+
const owner = fs6.readFileSync(path33.join(lockDir, "owner"), "utf8").trim();
|
|
26883
27016
|
return { mtimeMs: stat5.mtimeMs, owner };
|
|
26884
27017
|
} catch (error) {
|
|
26885
27018
|
if (error.code === "ENOENT") {
|
|
@@ -26951,8 +27084,8 @@ function sleepSync(ms) {
|
|
|
26951
27084
|
}
|
|
26952
27085
|
function createPersonalSpace(baseDir, memoryDirOverride) {
|
|
26953
27086
|
const homeDir = baseDir ?? resolveHomeDir();
|
|
26954
|
-
const standalonePath =
|
|
26955
|
-
const openclawPath =
|
|
27087
|
+
const standalonePath = path33.join(homeDir, ".engram", "memory");
|
|
27088
|
+
const openclawPath = path33.join(homeDir, ".openclaw", "workspace", "memory", "local");
|
|
26956
27089
|
const memoryDir = memoryDirOverride ?? readEnvVar("REMNIC_MEMORY_DIR") ?? readEnvVar("ENGRAM_MEMORY_DIR") ?? (fs6.existsSync(standalonePath) ? standalonePath : fs6.existsSync(openclawPath) ? openclawPath : standalonePath);
|
|
26957
27090
|
const normalizedMemoryDir = normalizeSpaceMemoryDir(memoryDir);
|
|
26958
27091
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -26981,7 +27114,7 @@ function createSpace(options) {
|
|
|
26981
27114
|
const id = options.name.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-");
|
|
26982
27115
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
26983
27116
|
const memoryDir = normalizeSpaceMemoryDir(
|
|
26984
|
-
options.memoryDir ??
|
|
27117
|
+
options.memoryDir ?? path33.join(getSpacesDir(options.baseDir), id, "memory")
|
|
26985
27118
|
);
|
|
26986
27119
|
const space = updateManifest(options.baseDir, (manifest) => {
|
|
26987
27120
|
if (manifest.spaces.some((s) => s.id === id)) {
|
|
@@ -27227,14 +27360,14 @@ async function mergeSpaces(sourceSpaceId, targetSpaceId, options) {
|
|
|
27227
27360
|
};
|
|
27228
27361
|
}
|
|
27229
27362
|
function getAuditLog(baseDir) {
|
|
27230
|
-
const auditPath =
|
|
27363
|
+
const auditPath = path33.join(getSpacesDir(baseDir), "audit.jsonl");
|
|
27231
27364
|
if (!fs6.existsSync(auditPath)) return [];
|
|
27232
27365
|
const lines = fs6.readFileSync(auditPath, "utf8").trim().split("\n");
|
|
27233
27366
|
return lines.filter((l) => l.trim()).map((l) => JSON.parse(l));
|
|
27234
27367
|
}
|
|
27235
27368
|
function appendAudit(entry, baseDir) {
|
|
27236
|
-
const auditPath =
|
|
27237
|
-
fs6.mkdirSync(
|
|
27369
|
+
const auditPath = path33.join(getSpacesDir(baseDir), "audit.jsonl");
|
|
27370
|
+
fs6.mkdirSync(path33.dirname(auditPath), { recursive: true });
|
|
27238
27371
|
const full = {
|
|
27239
27372
|
id: crypto7.randomUUID(),
|
|
27240
27373
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -27255,11 +27388,11 @@ async function copyMemories(sourceDir, targetDir, options) {
|
|
|
27255
27388
|
sourceFiles.filter((p) => {
|
|
27256
27389
|
const rp = safeRealpath(p);
|
|
27257
27390
|
if (!rp || !isPathInsideRoot(rp, sourceRoot)) return false;
|
|
27258
|
-
const rel =
|
|
27259
|
-
const mapped =
|
|
27391
|
+
const rel = path33.relative(sourceRoot, rp);
|
|
27392
|
+
const mapped = path33.resolve(targetRoot, rel);
|
|
27260
27393
|
if (!isPathInsideRoot(mapped, targetRoot)) return false;
|
|
27261
27394
|
return classifyEntityRefWritePath(targetRoot, mapped) === "entity";
|
|
27262
|
-
}).map((p) =>
|
|
27395
|
+
}).map((p) => path33.basename(p, ".md"))
|
|
27263
27396
|
);
|
|
27264
27397
|
const firstEntityId = sourceEntityIds.values().next().value;
|
|
27265
27398
|
if (firstEntityId === void 0) {
|
|
@@ -27267,7 +27400,7 @@ async function copyMemories(sourceDir, targetDir, options) {
|
|
|
27267
27400
|
}
|
|
27268
27401
|
return withRawEntityPageMutation(
|
|
27269
27402
|
targetRoot,
|
|
27270
|
-
|
|
27403
|
+
path33.join(targetRoot, "entities", `${firstEntityId}.md`),
|
|
27271
27404
|
async () => copyPreparedMemories(
|
|
27272
27405
|
sourceFiles,
|
|
27273
27406
|
sourceRoot,
|
|
@@ -27294,14 +27427,14 @@ function copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityI
|
|
|
27294
27427
|
continue;
|
|
27295
27428
|
}
|
|
27296
27429
|
const content = fs6.readFileSync(sourcePath, "utf8");
|
|
27297
|
-
const relativePath =
|
|
27298
|
-
const targetPath =
|
|
27430
|
+
const relativePath = path33.relative(sourceRoot, sourceRealPath);
|
|
27431
|
+
const targetPath = path33.resolve(targetRoot, relativePath);
|
|
27299
27432
|
if (!isPathInsideRoot(targetPath, targetRoot)) {
|
|
27300
27433
|
skipped++;
|
|
27301
27434
|
continue;
|
|
27302
27435
|
}
|
|
27303
27436
|
const targetKind = classifyEntityRefWritePath(targetRoot, targetPath);
|
|
27304
|
-
const idsAtCompare = historicalIdCache3.get(
|
|
27437
|
+
const idsAtCompare = historicalIdCache3.get(path33.join(targetRoot, "state"));
|
|
27305
27438
|
const sourceRef = targetKind === "memory" ? readEntityRefFromFrontmatter(content) : null;
|
|
27306
27439
|
const refHasSourceClaimant = sourceRef !== null && sourceEntityIds.has(sourceRef);
|
|
27307
27440
|
const canonicalContent = targetKind === "memory" && !refHasSourceClaimant ? canonicalizeEntityRefFrontmatter(content, idsAtCompare) : content;
|
|
@@ -27328,7 +27461,7 @@ function copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityI
|
|
|
27328
27461
|
if (fs6.existsSync(targetPath) && !options?.force) {
|
|
27329
27462
|
const targetContent = fs6.readFileSync(targetPath, "utf8");
|
|
27330
27463
|
const targetHash = hashContent4(targetContent);
|
|
27331
|
-
if (hashContent4(canonicalContent) === targetHash && historicalIdCache3.get(
|
|
27464
|
+
if (hashContent4(canonicalContent) === targetHash && historicalIdCache3.get(path33.join(targetRoot, "state")) === idsAtCompare) {
|
|
27332
27465
|
skipped++;
|
|
27333
27466
|
continue;
|
|
27334
27467
|
}
|
|
@@ -27344,13 +27477,13 @@ function copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityI
|
|
|
27344
27477
|
continue;
|
|
27345
27478
|
}
|
|
27346
27479
|
}
|
|
27347
|
-
fs6.mkdirSync(
|
|
27348
|
-
const targetParentRealPath = safeRealpath(
|
|
27480
|
+
fs6.mkdirSync(path33.dirname(targetPath), { recursive: true });
|
|
27481
|
+
const targetParentRealPath = safeRealpath(path33.dirname(targetPath));
|
|
27349
27482
|
if (!targetParentRealPath || !isPathInsideRoot(targetParentRealPath, targetRoot)) {
|
|
27350
27483
|
skipped++;
|
|
27351
27484
|
continue;
|
|
27352
27485
|
}
|
|
27353
|
-
const stateDir =
|
|
27486
|
+
const stateDir = path33.join(targetRoot, "state");
|
|
27354
27487
|
if (targetKind === "memory" && !refHasSourceClaimant) {
|
|
27355
27488
|
const idsAtWrite = historicalIdCache3.get(stateDir);
|
|
27356
27489
|
const written = canonicalizeEntityRefFrontmatter(content, idsAtWrite);
|
|
@@ -27394,7 +27527,7 @@ function copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityI
|
|
|
27394
27527
|
bumpMemoryCorpusVersionForDir(targetRoot);
|
|
27395
27528
|
}
|
|
27396
27529
|
if (reconcileNeeded) {
|
|
27397
|
-
requestEntityCanonicalIdReconcileSync(
|
|
27530
|
+
requestEntityCanonicalIdReconcileSync(path33.join(targetRoot, "state"));
|
|
27398
27531
|
}
|
|
27399
27532
|
return { merged, conflicts, skipped };
|
|
27400
27533
|
}
|
|
@@ -27405,7 +27538,7 @@ function walkMd(dir) {
|
|
|
27405
27538
|
const results = [];
|
|
27406
27539
|
function walk(d) {
|
|
27407
27540
|
for (const entry of fs6.readdirSync(d, { withFileTypes: true })) {
|
|
27408
|
-
const fullPath =
|
|
27541
|
+
const fullPath = path33.join(d, entry.name);
|
|
27409
27542
|
if (entry.isSymbolicLink()) {
|
|
27410
27543
|
continue;
|
|
27411
27544
|
}
|
|
@@ -27434,8 +27567,8 @@ function safeRealpath(filePath) {
|
|
|
27434
27567
|
}
|
|
27435
27568
|
}
|
|
27436
27569
|
function isPathInsideRoot(candidatePath, rootPath) {
|
|
27437
|
-
const relative =
|
|
27438
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
27570
|
+
const relative = path33.relative(rootPath, candidatePath);
|
|
27571
|
+
return relative === "" || !relative.startsWith("..") && !path33.isAbsolute(relative);
|
|
27439
27572
|
}
|
|
27440
27573
|
function parseSimpleFrontmatter(content) {
|
|
27441
27574
|
const match = content.match(/^---\n([\s\S]*?)\n---/);
|
|
@@ -27556,7 +27689,7 @@ var REMNIC_RECALL_DECISION_RULES = `## When to Use Recall vs Direct Read
|
|
|
27556
27689
|
// src/memory-extension/codex-publisher.ts
|
|
27557
27690
|
import fs7 from "fs";
|
|
27558
27691
|
import os from "os";
|
|
27559
|
-
import
|
|
27692
|
+
import path34 from "path";
|
|
27560
27693
|
var REMNIC_EXTENSION_DIR_NAME = "remnic";
|
|
27561
27694
|
function resolveEnvHome(env) {
|
|
27562
27695
|
if (env === void 0) return resolveHomeDir();
|
|
@@ -27565,12 +27698,12 @@ function resolveEnvHome(env) {
|
|
|
27565
27698
|
function expandTildeWithHome(input, homeDir) {
|
|
27566
27699
|
if (input === "~") return homeDir;
|
|
27567
27700
|
if (input.startsWith("~/") || input.startsWith("~\\")) {
|
|
27568
|
-
return
|
|
27701
|
+
return path34.join(homeDir, input.slice(2));
|
|
27569
27702
|
}
|
|
27570
27703
|
return input;
|
|
27571
27704
|
}
|
|
27572
27705
|
function normalizeHostRoot(input, homeDir) {
|
|
27573
|
-
return
|
|
27706
|
+
return path34.resolve(expandTildeWithHome(input.trim(), homeDir));
|
|
27574
27707
|
}
|
|
27575
27708
|
var CodexMemoryExtensionPublisher = class {
|
|
27576
27709
|
hostId = "codex";
|
|
@@ -27584,12 +27717,12 @@ var CodexMemoryExtensionPublisher = class {
|
|
|
27584
27717
|
async resolveExtensionRoot(env) {
|
|
27585
27718
|
const homeDir = resolveEnvHome(env);
|
|
27586
27719
|
const codexHomeInput = env === void 0 ? readEnvVar("CODEX_HOME")?.trim() : env.CODEX_HOME?.trim();
|
|
27587
|
-
const codexHome = codexHomeInput ? normalizeHostRoot(codexHomeInput, homeDir) :
|
|
27588
|
-
return
|
|
27720
|
+
const codexHome = codexHomeInput ? normalizeHostRoot(codexHomeInput, homeDir) : path34.resolve(homeDir, ".codex");
|
|
27721
|
+
return path34.join(codexHome, "memories_extensions", REMNIC_EXTENSION_DIR_NAME);
|
|
27589
27722
|
}
|
|
27590
27723
|
async isHostAvailable() {
|
|
27591
27724
|
try {
|
|
27592
|
-
const home = readEnvVar("CODEX_HOME")?.trim() ||
|
|
27725
|
+
const home = readEnvVar("CODEX_HOME")?.trim() || path34.join(resolveHomeDir(), ".codex");
|
|
27593
27726
|
return fs7.existsSync(home);
|
|
27594
27727
|
} catch {
|
|
27595
27728
|
return false;
|
|
@@ -27640,7 +27773,7 @@ When running inside the Codex phase-2 consolidation sandbox:
|
|
|
27640
27773
|
}
|
|
27641
27774
|
async publish(ctx) {
|
|
27642
27775
|
const extensionRoot = await this.resolveExtensionRoot();
|
|
27643
|
-
const instructionsPath =
|
|
27776
|
+
const instructionsPath = path34.join(extensionRoot, "instructions.md");
|
|
27644
27777
|
const filesWritten = [];
|
|
27645
27778
|
const skipped = [];
|
|
27646
27779
|
ctx.log.info(`Publishing Codex memory extension to ${extensionRoot}`);
|
|
@@ -28272,9 +28405,9 @@ function buildWeeklyActivitySummary(cards, options) {
|
|
|
28272
28405
|
// src/activity/timeline/weekly-persist.ts
|
|
28273
28406
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
28274
28407
|
import { mkdirSync, readFileSync as readFileSync2, renameSync, unlinkSync, writeFileSync } from "fs";
|
|
28275
|
-
import
|
|
28408
|
+
import path35 from "path";
|
|
28276
28409
|
var WEEKLY_SNAPSHOT_FORMAT_VERSION = 1;
|
|
28277
|
-
var WEEKLY_SNAPSHOT_DIR =
|
|
28410
|
+
var WEEKLY_SNAPSHOT_DIR = path35.join("activity", "weekly");
|
|
28278
28411
|
function requireToken(value, name) {
|
|
28279
28412
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
28280
28413
|
throw new TypeError(`${name} must be a non-empty string`);
|
|
@@ -28297,8 +28430,8 @@ function weeklySnapshotPath(input) {
|
|
|
28297
28430
|
const identity = hashActivityBody(
|
|
28298
28431
|
`${input.summary.weekStartUtc}\0${input.summary.weekEndUtc}\0${sourceRevision}\0${configHash}`
|
|
28299
28432
|
);
|
|
28300
|
-
return
|
|
28301
|
-
|
|
28433
|
+
return path35.join(
|
|
28434
|
+
path35.resolve(memoryDir),
|
|
28302
28435
|
WEEKLY_SNAPSHOT_DIR,
|
|
28303
28436
|
namespaceIdentityToken(namespace),
|
|
28304
28437
|
`${weekDate}--${identity}.json`
|
|
@@ -28328,7 +28461,7 @@ function persistWeeklySnapshot(input) {
|
|
|
28328
28461
|
throw error;
|
|
28329
28462
|
}
|
|
28330
28463
|
}
|
|
28331
|
-
mkdirSync(
|
|
28464
|
+
mkdirSync(path35.dirname(filePath), { recursive: true, mode: 448 });
|
|
28332
28465
|
const tmpPath = `${filePath}.${process.pid}.${randomBytes3(8).toString("hex")}.tmp`;
|
|
28333
28466
|
writeFileSync(tmpPath, text, { encoding: "utf8", mode: 384 });
|
|
28334
28467
|
try {
|
|
@@ -28833,7 +28966,7 @@ function selectRecapForDay(input) {
|
|
|
28833
28966
|
|
|
28834
28967
|
// src/activity/journal-read.ts
|
|
28835
28968
|
import { closeSync, constants as fsConstants, fstatSync, lstatSync, openSync, readFileSync as readFileSync3, realpathSync, statSync as statSync2 } from "fs";
|
|
28836
|
-
import
|
|
28969
|
+
import path36 from "path";
|
|
28837
28970
|
|
|
28838
28971
|
// src/activity/journal-section.ts
|
|
28839
28972
|
function parseAtxHeading(line) {
|
|
@@ -29024,8 +29157,8 @@ function readJournalForDate(input) {
|
|
|
29024
29157
|
const relative = resolveVaultNotePath(input.vault.dailyNotePath, input.date, {
|
|
29025
29158
|
timezone: input.timezone
|
|
29026
29159
|
});
|
|
29027
|
-
const root =
|
|
29028
|
-
const filePath =
|
|
29160
|
+
const root = path36.resolve(expandTildePath(input.vault.vaultPath));
|
|
29161
|
+
const filePath = path36.join(root, relative);
|
|
29029
29162
|
try {
|
|
29030
29163
|
const rootStat = lstatSync(root);
|
|
29031
29164
|
if (rootStat.isSymbolicLink() || !rootStat.isDirectory()) {
|
|
@@ -29034,8 +29167,8 @@ function readJournalForDate(input) {
|
|
|
29034
29167
|
} catch {
|
|
29035
29168
|
return { ok: true, exists: false, reason: "missing_file", filePath };
|
|
29036
29169
|
}
|
|
29037
|
-
const lexical =
|
|
29038
|
-
if (lexical.length === 0 || lexical === ".." || lexical.startsWith(`..${
|
|
29170
|
+
const lexical = path36.relative(root, filePath);
|
|
29171
|
+
if (lexical.length === 0 || lexical === ".." || lexical.startsWith(`..${path36.sep}`) || path36.isAbsolute(lexical)) {
|
|
29039
29172
|
return { ok: false, reason: "path_escape", filePath };
|
|
29040
29173
|
}
|
|
29041
29174
|
if (!containedBySymlinks(root, filePath)) {
|
|
@@ -29068,11 +29201,11 @@ function containedBySymlinks(root, dest) {
|
|
|
29068
29201
|
try {
|
|
29069
29202
|
if (statSync2(probe).isFile() || statSync2(probe).isDirectory()) {
|
|
29070
29203
|
const real = realpathSync(probe);
|
|
29071
|
-
return real === realRoot || real.startsWith(`${realRoot}${
|
|
29204
|
+
return real === realRoot || real.startsWith(`${realRoot}${path36.sep}`);
|
|
29072
29205
|
}
|
|
29073
29206
|
} catch {
|
|
29074
29207
|
}
|
|
29075
|
-
const parent =
|
|
29208
|
+
const parent = path36.dirname(probe);
|
|
29076
29209
|
if (parent === probe) return false;
|
|
29077
29210
|
probe = parent;
|
|
29078
29211
|
}
|
|
@@ -29083,15 +29216,15 @@ function symlinkRejected() {
|
|
|
29083
29216
|
return err;
|
|
29084
29217
|
}
|
|
29085
29218
|
function readVerifiedDailyNote(root, filePath) {
|
|
29086
|
-
const relative =
|
|
29087
|
-
const parts = relative.split(
|
|
29219
|
+
const relative = path36.relative(root, filePath);
|
|
29220
|
+
const parts = relative.split(path36.sep).filter((part) => part.length > 0 && part !== ".");
|
|
29088
29221
|
let cursor = root;
|
|
29089
29222
|
for (const part of parts) {
|
|
29090
|
-
cursor =
|
|
29223
|
+
cursor = path36.join(cursor, part);
|
|
29091
29224
|
const st = lstatSync(cursor);
|
|
29092
29225
|
if (st.isSymbolicLink()) throw symlinkRejected();
|
|
29093
29226
|
}
|
|
29094
|
-
const parent =
|
|
29227
|
+
const parent = path36.dirname(filePath);
|
|
29095
29228
|
const parentLstat = lstatSync(parent);
|
|
29096
29229
|
if (parentLstat.isSymbolicLink() || !parentLstat.isDirectory()) throw symlinkRejected();
|
|
29097
29230
|
const nofollow = fsConstants.O_NOFOLLOW ?? 0;
|
|
@@ -29115,7 +29248,7 @@ function readVerifiedDailyNote(root, filePath) {
|
|
|
29115
29248
|
try {
|
|
29116
29249
|
const fdPath = realpathSync(`/proc/self/fd/${fd}`);
|
|
29117
29250
|
const realRoot = realpathSync(root);
|
|
29118
|
-
if (fdPath !== realRoot && !fdPath.startsWith(`${realRoot}${
|
|
29251
|
+
if (fdPath !== realRoot && !fdPath.startsWith(`${realRoot}${path36.sep}`)) {
|
|
29119
29252
|
throw symlinkRejected();
|
|
29120
29253
|
}
|
|
29121
29254
|
} catch (err) {
|
|
@@ -29130,11 +29263,11 @@ function readVerifiedDailyNote(root, filePath) {
|
|
|
29130
29263
|
// src/activity/journal-state.ts
|
|
29131
29264
|
import { createHash as createHash10, randomBytes as randomBytes4 } from "crypto";
|
|
29132
29265
|
import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
29133
|
-
import
|
|
29266
|
+
import path37 from "path";
|
|
29134
29267
|
var STATE_DIR_NAME = "state";
|
|
29135
29268
|
var STATE_FILE_NAME = "timeline.json";
|
|
29136
29269
|
function timelineStatePath(memoryDir) {
|
|
29137
|
-
return
|
|
29270
|
+
return path37.join(memoryDir, STATE_DIR_NAME, STATE_FILE_NAME);
|
|
29138
29271
|
}
|
|
29139
29272
|
function hashJournalText(text) {
|
|
29140
29273
|
return createHash10("sha256").update(text, "utf8").digest("hex");
|
|
@@ -29160,14 +29293,14 @@ function readTimelineState(memoryDir) {
|
|
|
29160
29293
|
}
|
|
29161
29294
|
function writeTimelineState(memoryDir, state) {
|
|
29162
29295
|
const filePath = timelineStatePath(memoryDir);
|
|
29163
|
-
mkdirSync2(
|
|
29296
|
+
mkdirSync2(path37.dirname(filePath), { recursive: true });
|
|
29164
29297
|
const tempPath = `${filePath}.${process.pid}.${randomBytes4(8).toString("hex")}.tmp`;
|
|
29165
29298
|
writeFileSync2(tempPath, `${JSON.stringify(state, null, 2)}
|
|
29166
29299
|
`);
|
|
29167
29300
|
renameSync2(tempPath, filePath);
|
|
29168
29301
|
}
|
|
29169
29302
|
function journalDateLockPath(memoryDir, date) {
|
|
29170
|
-
return
|
|
29303
|
+
return path37.join(memoryDir, STATE_DIR_NAME, `journal-extract-${date}.lock`);
|
|
29171
29304
|
}
|
|
29172
29305
|
function timelineStateLockPath(memoryDir) {
|
|
29173
29306
|
return `${timelineStatePath(memoryDir)}.lock`;
|
|
@@ -29859,7 +29992,7 @@ function filterPrivacyWindow(items, options) {
|
|
|
29859
29992
|
}
|
|
29860
29993
|
|
|
29861
29994
|
// src/activity/vault-wikilink.ts
|
|
29862
|
-
import
|
|
29995
|
+
import path38 from "path";
|
|
29863
29996
|
function formatVaultWikilink(notePath) {
|
|
29864
29997
|
if (typeof notePath !== "string" || notePath.trim().length === 0) {
|
|
29865
29998
|
throw new RangeError("Vault wikilink path must be a non-empty relative path.");
|
|
@@ -29867,7 +30000,7 @@ function formatVaultWikilink(notePath) {
|
|
|
29867
30000
|
if (notePath.includes("\n") || notePath.includes("\r")) {
|
|
29868
30001
|
throw new RangeError("Vault wikilink path must not contain newlines.");
|
|
29869
30002
|
}
|
|
29870
|
-
if (
|
|
30003
|
+
if (path38.posix.isAbsolute(notePath) || path38.win32.isAbsolute(notePath)) {
|
|
29871
30004
|
throw new RangeError("Vault wikilink path must be relative; absolute paths are rejected.");
|
|
29872
30005
|
}
|
|
29873
30006
|
if (notePath.split(/[\\/]/).some((segment) => segment === "..")) {
|
|
@@ -29889,7 +30022,7 @@ function stripVaultMdSuffix(notePath) {
|
|
|
29889
30022
|
}
|
|
29890
30023
|
|
|
29891
30024
|
// src/activity/vault-join.ts
|
|
29892
|
-
import
|
|
30025
|
+
import path39 from "path";
|
|
29893
30026
|
function joinVaultSegments(parts) {
|
|
29894
30027
|
if (parts.length === 0) {
|
|
29895
30028
|
throw new RangeError("Vault path parts must be a non-empty list.");
|
|
@@ -29904,7 +30037,7 @@ function joinVaultSegments(parts) {
|
|
|
29904
30037
|
if (part.includes("\n") || part.includes("\r")) {
|
|
29905
30038
|
throw new RangeError("Vault path part must not contain a newline.");
|
|
29906
30039
|
}
|
|
29907
|
-
if (
|
|
30040
|
+
if (path39.posix.isAbsolute(part) || path39.win32.isAbsolute(part)) {
|
|
29908
30041
|
throw new RangeError("Vault path part must be relative.");
|
|
29909
30042
|
}
|
|
29910
30043
|
if (part.split("/").includes("..")) {
|
|
@@ -29959,7 +30092,7 @@ function planVaultDryRun(inputs) {
|
|
|
29959
30092
|
// src/session-summaries/index.ts
|
|
29960
30093
|
import { createHash as createHash11 } from "crypto";
|
|
29961
30094
|
import { lstat as lstat3, mkdir as mkdir7, readFile as readFile9, readdir as readdir4, rename, rm, stat as stat4, writeFile as writeFile7 } from "fs/promises";
|
|
29962
|
-
import
|
|
30095
|
+
import path40 from "path";
|
|
29963
30096
|
|
|
29964
30097
|
// src/session-summaries/adapters.ts
|
|
29965
30098
|
var VALID_ROLES = /* @__PURE__ */ new Set(["user", "assistant", "tool", "system", "other"]);
|
|
@@ -30464,7 +30597,7 @@ function shortHash(value, length = 16) {
|
|
|
30464
30597
|
async function listTranscriptFiles(root, maxFiles) {
|
|
30465
30598
|
const out = [];
|
|
30466
30599
|
let truncated = false;
|
|
30467
|
-
const entrySortKey = (entryName, isDirectory) => isDirectory ? `${entryName}${
|
|
30600
|
+
const entrySortKey = (entryName, isDirectory) => isDirectory ? `${entryName}${path40.sep}` : entryName;
|
|
30468
30601
|
async function visit(dir) {
|
|
30469
30602
|
if (truncated) return;
|
|
30470
30603
|
const entries = (await readdir4(dir, { withFileTypes: true })).sort(
|
|
@@ -30474,13 +30607,13 @@ async function listTranscriptFiles(root, maxFiles) {
|
|
|
30474
30607
|
if (truncated) return;
|
|
30475
30608
|
if (entry.name.startsWith(".")) continue;
|
|
30476
30609
|
if (entry.isSymbolicLink()) continue;
|
|
30477
|
-
const fullPath =
|
|
30610
|
+
const fullPath = path40.join(dir, entry.name);
|
|
30478
30611
|
if (entry.isDirectory()) {
|
|
30479
30612
|
await visit(fullPath);
|
|
30480
30613
|
continue;
|
|
30481
30614
|
}
|
|
30482
30615
|
if (!entry.isFile()) continue;
|
|
30483
|
-
const ext =
|
|
30616
|
+
const ext = path40.extname(entry.name).toLowerCase();
|
|
30484
30617
|
if (!SUPPORTED_EXTENSIONS.has(ext)) continue;
|
|
30485
30618
|
out.push(fullPath);
|
|
30486
30619
|
if (out.length > maxFiles) {
|
|
@@ -30507,7 +30640,7 @@ function normalizeInputDir(inputDir) {
|
|
|
30507
30640
|
if (typeof inputDir !== "string" || inputDir.trim().length === 0) {
|
|
30508
30641
|
throw new Error("inputDir must be a non-empty string");
|
|
30509
30642
|
}
|
|
30510
|
-
return
|
|
30643
|
+
return path40.resolve(expandTildePath(inputDir.trim()));
|
|
30511
30644
|
}
|
|
30512
30645
|
function initRoleCounts() {
|
|
30513
30646
|
return {
|
|
@@ -30664,11 +30797,11 @@ async function collectLocalSessionSummaries(options) {
|
|
|
30664
30797
|
continue;
|
|
30665
30798
|
}
|
|
30666
30799
|
seenFileHashes.add(fileHash);
|
|
30667
|
-
const fileExtension =
|
|
30800
|
+
const fileExtension = path40.extname(filePath).toLowerCase();
|
|
30668
30801
|
const parsed = await adapter.parseFile(
|
|
30669
30802
|
{
|
|
30670
30803
|
content,
|
|
30671
|
-
fileName:
|
|
30804
|
+
fileName: path40.basename(filePath),
|
|
30672
30805
|
fileExtension,
|
|
30673
30806
|
fileRef: fileHash
|
|
30674
30807
|
},
|
|
@@ -30724,7 +30857,7 @@ async function collectLocalSessionSummaries(options) {
|
|
|
30724
30857
|
}
|
|
30725
30858
|
async function readRedactionConfig(pathLike) {
|
|
30726
30859
|
if (!pathLike) return void 0;
|
|
30727
|
-
const raw = await readFile9(
|
|
30860
|
+
const raw = await readFile9(path40.resolve(expandTildePath(pathLike)), "utf-8");
|
|
30728
30861
|
const parsed = JSON.parse(raw);
|
|
30729
30862
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
30730
30863
|
throw new Error("redaction config must be a JSON object");
|
|
@@ -30737,15 +30870,15 @@ function toJsonl(drafts) {
|
|
|
30737
30870
|
}
|
|
30738
30871
|
function defaultDraftOutputPath(memoryDir, generatedAt) {
|
|
30739
30872
|
const stamp = generatedAt.replace(/[:.]/g, "-");
|
|
30740
|
-
return
|
|
30741
|
-
|
|
30873
|
+
return path40.join(
|
|
30874
|
+
path40.resolve(expandTildePath(memoryDir)),
|
|
30742
30875
|
"state",
|
|
30743
30876
|
"session-summary-drafts",
|
|
30744
30877
|
`session-summaries-${stamp}.jsonl`
|
|
30745
30878
|
);
|
|
30746
30879
|
}
|
|
30747
30880
|
async function writeDrafts(filePath, drafts) {
|
|
30748
|
-
await mkdir7(
|
|
30881
|
+
await mkdir7(path40.dirname(filePath), { recursive: true });
|
|
30749
30882
|
const tempPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
30750
30883
|
try {
|
|
30751
30884
|
await writeFile7(tempPath, toJsonl(drafts), "utf-8");
|
|
@@ -30763,7 +30896,7 @@ async function runLocalSessionSummaryCliCommand(options) {
|
|
|
30763
30896
|
});
|
|
30764
30897
|
const wroteFiles = [];
|
|
30765
30898
|
if (options.output) {
|
|
30766
|
-
const outputPath =
|
|
30899
|
+
const outputPath = path40.resolve(expandTildePath(options.output));
|
|
30767
30900
|
await writeDrafts(outputPath, report.drafts);
|
|
30768
30901
|
wroteFiles.push(outputPath);
|
|
30769
30902
|
}
|
|
@@ -30798,19 +30931,19 @@ async function runLocalSessionSummaryCliCommand(options) {
|
|
|
30798
30931
|
|
|
30799
30932
|
// src/transfer/capsule-fork.ts
|
|
30800
30933
|
import { lstat as lstat4, mkdir as mkdir8, readFile as readFile10, realpath as realpath3, writeFile as writeFile8 } from "fs/promises";
|
|
30801
|
-
import
|
|
30934
|
+
import path41 from "path";
|
|
30802
30935
|
async function forkCapsule(opts) {
|
|
30803
30936
|
validateForkId(opts.forkId);
|
|
30804
|
-
const rootAbs =
|
|
30937
|
+
const rootAbs = path41.resolve(opts.targetRoot);
|
|
30805
30938
|
await assertIsDirectoryNotSymlink(rootAbs, "forkCapsule", "targetRoot");
|
|
30806
|
-
const forkDirAbs =
|
|
30939
|
+
const forkDirAbs = path41.join(rootAbs, "forks", opts.forkId);
|
|
30807
30940
|
const forkEntryExists = await pathEntryExists(forkDirAbs);
|
|
30808
30941
|
if (forkEntryExists) {
|
|
30809
30942
|
throw new Error(
|
|
30810
30943
|
`forkCapsule: fork path already exists \u2014 forkId "${opts.forkId}" is already in use at: ${forkDirAbs}`
|
|
30811
30944
|
);
|
|
30812
30945
|
}
|
|
30813
|
-
const archiveAbs =
|
|
30946
|
+
const archiveAbs = path41.resolve(opts.sourceArchive);
|
|
30814
30947
|
const importResult = await importCapsule({
|
|
30815
30948
|
archivePath: archiveAbs,
|
|
30816
30949
|
root: rootAbs,
|
|
@@ -30832,10 +30965,10 @@ async function forkCapsule(opts) {
|
|
|
30832
30965
|
importedRecords: importResult.imported.length,
|
|
30833
30966
|
skippedRecords: importResult.skipped.length
|
|
30834
30967
|
};
|
|
30835
|
-
const lineagePath =
|
|
30968
|
+
const lineagePath = path41.join(forkDirAbs, "lineage.json");
|
|
30836
30969
|
const rootReal = await realpath3(rootAbs);
|
|
30837
30970
|
await assertRealpathInsideRoot(rootReal, lineagePath, `forks/${opts.forkId}/lineage.json`, "forkCapsule");
|
|
30838
|
-
await mkdir8(
|
|
30971
|
+
await mkdir8(path41.dirname(lineagePath), { recursive: true });
|
|
30839
30972
|
await writeFile8(lineagePath, JSON.stringify(lineage, null, 2) + "\n", "utf-8");
|
|
30840
30973
|
return {
|
|
30841
30974
|
archivePath: archiveAbs,
|
|
@@ -30849,11 +30982,11 @@ async function readForkLineage(targetRoot, forkId) {
|
|
|
30849
30982
|
if (typeof forkId !== "string" || forkId.length === 0 || forkId.length > 64 || !CAPSULE_ID_PATTERN.test(forkId)) {
|
|
30850
30983
|
return null;
|
|
30851
30984
|
}
|
|
30852
|
-
const rootAbs =
|
|
30985
|
+
const rootAbs = path41.resolve(targetRoot);
|
|
30853
30986
|
const rootReal = await realpath3(rootAbs).catch(() => rootAbs);
|
|
30854
|
-
const lineagePath =
|
|
30855
|
-
const rel =
|
|
30856
|
-
if (rel.startsWith("..") ||
|
|
30987
|
+
const lineagePath = path41.join(rootReal, "forks", forkId, "lineage.json");
|
|
30988
|
+
const rel = path41.relative(rootReal, lineagePath);
|
|
30989
|
+
if (rel.startsWith("..") || path41.isAbsolute(rel)) {
|
|
30857
30990
|
return null;
|
|
30858
30991
|
}
|
|
30859
30992
|
if (!await isLineagePathContained(rootReal, lineagePath)) {
|
|
@@ -30894,19 +31027,19 @@ async function pathEntryExists(absPath) {
|
|
|
30894
31027
|
async function isLineagePathContained(rootReal, lineagePath) {
|
|
30895
31028
|
let existing = lineagePath;
|
|
30896
31029
|
const suffix = [];
|
|
30897
|
-
while (existing !==
|
|
31030
|
+
while (existing !== path41.dirname(existing)) {
|
|
30898
31031
|
const st = await lstat4(existing).catch(() => null);
|
|
30899
31032
|
if (st !== null) break;
|
|
30900
|
-
suffix.unshift(
|
|
30901
|
-
existing =
|
|
31033
|
+
suffix.unshift(path41.basename(existing));
|
|
31034
|
+
existing = path41.dirname(existing);
|
|
30902
31035
|
}
|
|
30903
31036
|
const existingReal = await realpath3(existing).catch(() => existing);
|
|
30904
|
-
const targetReal = suffix.length > 0 ?
|
|
30905
|
-
const rel =
|
|
31037
|
+
const targetReal = suffix.length > 0 ? path41.join(existingReal, ...suffix) : existingReal;
|
|
31038
|
+
const rel = path41.relative(rootReal, targetReal);
|
|
30906
31039
|
if (rel === "") return true;
|
|
30907
31040
|
if (rel === "..") return false;
|
|
30908
|
-
if (rel.startsWith(`..${
|
|
30909
|
-
if (
|
|
31041
|
+
if (rel.startsWith(`..${path41.sep}`)) return false;
|
|
31042
|
+
if (path41.isAbsolute(rel)) return false;
|
|
30910
31043
|
return true;
|
|
30911
31044
|
}
|
|
30912
31045
|
|
|
@@ -31095,4 +31228,4 @@ export {
|
|
|
31095
31228
|
qmdStartupCollectionChecksWithTimeout,
|
|
31096
31229
|
Orchestrator
|
|
31097
31230
|
};
|
|
31098
|
-
//# sourceMappingURL=chunk-
|
|
31231
|
+
//# sourceMappingURL=chunk-K7FXR75S.js.map
|