@remnic/core 9.65.7 → 9.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access-admin-ops-surface.d.ts +15 -14
- package/dist/access-admin-ops-surface.js +65 -62
- package/dist/access-authorization-probe.d.ts +15 -14
- package/dist/access-authorization-probe.js +66 -63
- package/dist/access-boundary.d.ts +15 -14
- package/dist/access-boundary.js +65 -62
- package/dist/access-citation-namespace.js +3 -3
- package/dist/access-cli.js +182 -174
- package/dist/access-cli.js.map +1 -1
- package/dist/access-coding-context-resolution.d.ts +2 -2
- package/dist/access-coding-context-resolution.js +2 -2
- package/dist/access-extraction-force-flush.d.ts +15 -14
- package/dist/access-extraction-force-flush.js +65 -62
- package/dist/access-health-types.d.ts +2 -2
- package/dist/access-http-lcm-compaction.d.ts +15 -14
- package/dist/access-http-lifecycle-flush.d.ts +15 -14
- package/dist/access-http-offline-stream.d.ts +15 -14
- package/dist/access-http-query.d.ts +3 -3
- package/dist/access-http-query.js +67 -64
- package/dist/access-http.d.ts +16 -15
- package/dist/access-http.js +87 -84
- package/dist/access-identity-continuity-surface.d.ts +13 -12
- package/dist/access-identity-continuity-surface.js +65 -62
- package/dist/access-lcm-surface.d.ts +15 -14
- package/dist/access-lcm-surface.js +65 -62
- package/dist/access-mcp-output-schemas.js +1 -1
- package/dist/access-mcp.d.ts +15 -14
- package/dist/access-mcp.js +77 -74
- package/dist/access-memory-search-fanout.d.ts +3 -3
- package/dist/{access-namespace-preflight-8VYKmRX0.d.ts → access-namespace-preflight-CLWUoMyW.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +4 -4
- package/dist/access-namespace-preflight.js +65 -62
- package/dist/access-observe-write-surface.d.ts +15 -14
- package/dist/access-observe-write-surface.js +65 -62
- package/dist/access-offline-manifest.d.ts +13 -12
- package/dist/access-offline-manifest.js +16 -16
- package/dist/access-operations-batch.js +69 -66
- package/dist/access-operations.d.ts +16 -15
- package/dist/access-operations.js +74 -71
- package/dist/access-recall-concurrency.d.ts +15 -14
- package/dist/access-recall-concurrency.js +65 -62
- package/dist/access-recall-response.d.ts +15 -14
- package/dist/access-recall-response.js +65 -62
- package/dist/access-recall-surface.d.ts +15 -14
- package/dist/access-recall-surface.js +65 -62
- package/dist/access-schema.js +7 -7
- package/dist/{access-service-Crk__Git.d.ts → access-service-CEUE1Isj.d.ts} +14 -14
- package/dist/access-service-helpers.d.ts +15 -14
- package/dist/access-service.d.ts +15 -14
- package/dist/access-service.js +65 -62
- package/dist/access-surface-catalog.d.ts +15 -14
- package/dist/access-surface-catalog.js +69 -64
- package/dist/access-surface-catalog.js.map +1 -1
- package/dist/access-wearables-meetings-surface.d.ts +6 -4
- package/dist/action-confidence.d.ts +2 -2
- package/dist/active-context-config.d.ts +27 -0
- package/dist/active-context-config.js +14 -0
- package/dist/active-context-transform.d.ts +267 -0
- package/dist/active-context-transform.js +31 -0
- package/dist/active-memory-bridge.d.ts +2 -2
- package/dist/active-memory-bridge.js +2 -2
- package/dist/active-recall.d.ts +2 -2
- package/dist/active-recall.js +17 -16
- package/dist/active-recall.js.map +1 -1
- package/dist/adapters/index.js +7 -7
- package/dist/adapters/registry.js +3 -3
- package/dist/ambient-provenance.d.ts +2 -2
- package/dist/artifact-search.d.ts +2 -2
- package/dist/{auto-sync-XVMLL2RH.js → auto-sync-Q6Q2FVSC.js} +10 -10
- package/dist/behavior-learner.d.ts +2 -2
- package/dist/behavior-signals.d.ts +2 -2
- package/dist/bootstrap.d.ts +13 -12
- package/dist/briefing-window.d.ts +5 -3
- package/dist/briefing.d.ts +5 -3
- package/dist/briefing.js +33 -33
- package/dist/buffer-surprise-report.d.ts +2 -2
- package/dist/buffer-turn-helpers.d.ts +2 -2
- package/dist/buffer.d.ts +5 -3
- package/dist/buffer.js +24 -8
- package/dist/bulk-import/index.d.ts +4 -4
- package/dist/calibration.d.ts +2 -2
- package/dist/calibration.js +1 -1
- package/dist/capabilities.d.ts +2 -2
- package/dist/{capsule-merge-SGIVB3WA.js → capsule-merge-SEHERWWP.js} +4 -4
- package/dist/{catalog-DybwVNW3.d.ts → catalog-D1HgugTA.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +4 -4
- package/dist/causal-consolidation.d.ts +2 -2
- package/dist/causal-consolidation.js +34 -34
- package/dist/causal-trajectory-graph.d.ts +2 -2
- package/dist/{chunk-CFGU52XJ.js → chunk-23CVL7HS.js} +2 -2
- package/dist/{chunk-PO7NXBG2.js → chunk-2GF27PGH.js} +5 -5
- package/dist/{chunk-6CPUQ5D6.js → chunk-2LBAFHOQ.js} +15 -15
- package/dist/{chunk-JBPKEARU.js → chunk-2QSZNTDO.js} +7 -7
- package/dist/{chunk-IP4ZNT4U.js → chunk-33MFRY25.js} +2 -2
- package/dist/{chunk-VFYRYFLL.js → chunk-3TSU662L.js} +3 -3
- package/dist/chunk-43HUVDTD.js +114 -0
- package/dist/chunk-43HUVDTD.js.map +1 -0
- package/dist/{chunk-VXVZ2GM3.js → chunk-4FHRZD5T.js} +2 -2
- package/dist/{chunk-FP7YTTVO.js → chunk-4OFKZAJG.js} +2 -1
- package/dist/chunk-4OFKZAJG.js.map +1 -0
- package/dist/{chunk-5VPQSRQO.js → chunk-4STAANV7.js} +3 -3
- package/dist/{chunk-46WM6JX2.js → chunk-4ZWCQJNM.js} +5 -5
- package/dist/{chunk-LLQCM2U2.js → chunk-56IV4J5W.js} +617 -167
- package/dist/chunk-56IV4J5W.js.map +1 -0
- package/dist/{chunk-52II7PB6.js → chunk-645WOU5I.js} +4 -4
- package/dist/{chunk-YKWFK7XA.js → chunk-6CEGSTBD.js} +7 -7
- package/dist/{chunk-I7EX6KSH.js → chunk-6QDXA26G.js} +264 -210
- package/dist/chunk-6QDXA26G.js.map +1 -0
- package/dist/{chunk-GEPACVWN.js → chunk-6RUHELWR.js} +3 -3
- package/dist/{chunk-ZAOHJDKH.js → chunk-72OIT7KS.js} +4 -4
- package/dist/{chunk-KQAFEZQX.js → chunk-7LCGFUMB.js} +4 -4
- package/dist/{chunk-7TCGNUVP.js → chunk-7UTDHQZ5.js} +3 -3
- package/dist/{chunk-5HK3CJAR.js → chunk-7XOG75AU.js} +3 -3
- package/dist/{chunk-7BDZTALN.js → chunk-AJTG3CP7.js} +12 -2
- package/dist/chunk-AJTG3CP7.js.map +1 -0
- package/dist/{chunk-2LWQSV6A.js → chunk-AL3UYZ5N.js} +3 -2
- package/dist/chunk-AL3UYZ5N.js.map +1 -0
- package/dist/chunk-B32WYRXX.js +77 -0
- package/dist/chunk-B32WYRXX.js.map +1 -0
- package/dist/{chunk-C24UZSFW.js → chunk-CEH2AFXG.js} +6 -6
- package/dist/{chunk-YOXVZJFM.js → chunk-CFVTRUR3.js} +2 -2
- package/dist/{chunk-ACOC27BB.js → chunk-CN4VKV3S.js} +2 -2
- package/dist/{chunk-PMVPCZJZ.js → chunk-CTCGHNWN.js} +6 -6
- package/dist/{chunk-EGBDFJ36.js → chunk-DD5JFCWM.js} +2 -2
- package/dist/{chunk-T42L3S6A.js → chunk-DDX6KIXF.js} +2 -2
- package/dist/{chunk-JIYDRBVZ.js → chunk-DJORULH3.js} +2 -2
- package/dist/{chunk-WTOZBZNN.js → chunk-DMEHOEC7.js} +6 -6
- package/dist/{chunk-OPPBTPUU.js → chunk-DUAJKRR2.js} +4 -4
- package/dist/{chunk-XDL5CYZN.js → chunk-EEOUMG3J.js} +2 -1
- package/dist/{chunk-XDL5CYZN.js.map → chunk-EEOUMG3J.js.map} +1 -1
- package/dist/{chunk-SVVIASVX.js → chunk-EFQCDJZ2.js} +7 -7
- package/dist/{chunk-Q57GOHLF.js → chunk-EGALNSZ4.js} +3 -3
- package/dist/{chunk-KCT36JAW.js → chunk-ESNFSSO4.js} +2 -2
- package/dist/{chunk-XQ3HXAQH.js → chunk-ET2CNMLD.js} +4 -4
- package/dist/{chunk-Z4U3UN56.js → chunk-EZSCW4EM.js} +6 -6
- package/dist/{chunk-F6QHHRWP.js → chunk-FESUGFIL.js} +3 -3
- package/dist/{chunk-S3K2CIK5.js → chunk-FKKGCGYL.js} +3 -3
- package/dist/{chunk-BWGCOLEL.js → chunk-FTTJRVB7.js} +2 -2
- package/dist/{chunk-JAQXUGLN.js → chunk-FYWLSFFS.js} +2 -2
- package/dist/{chunk-BJTHRFFC.js → chunk-GEJKYA7D.js} +77 -36
- package/dist/chunk-GEJKYA7D.js.map +1 -0
- package/dist/chunk-GSKINLAK.js +267 -0
- package/dist/chunk-GSKINLAK.js.map +1 -0
- package/dist/{chunk-OPGL46PX.js → chunk-GX6FTSYH.js} +2 -2
- package/dist/{chunk-A32YEQAM.js → chunk-H7VDIF2V.js} +2 -2
- package/dist/{chunk-PDDSFELN.js → chunk-HJXA6ZM7.js} +2 -2
- package/dist/{chunk-RGCF4XNH.js → chunk-HNPE66LB.js} +8 -8
- package/dist/{chunk-SEA6M7SS.js → chunk-I5VB44ZK.js} +2 -2
- package/dist/{chunk-SDEPLF7V.js → chunk-IBJ6U753.js} +2 -2
- package/dist/{chunk-EUYWQ7TS.js → chunk-IEZ6CGTW.js} +2 -2
- package/dist/{chunk-RQE4TITU.js → chunk-IHGMRDEE.js} +431 -1834
- package/dist/chunk-IHGMRDEE.js.map +1 -0
- package/dist/{chunk-3RI5Y7KU.js → chunk-IVIAHQBR.js} +2 -2
- package/dist/{chunk-7WR462EM.js → chunk-J3OND5QT.js} +4 -4
- package/dist/{chunk-UW5NPZJ2.js → chunk-JALOAKSZ.js} +59 -7
- package/dist/chunk-JALOAKSZ.js.map +1 -0
- package/dist/{chunk-T3JQTCCO.js → chunk-JI7U6AS3.js} +4 -4
- package/dist/{chunk-DVYRD4HY.js → chunk-JRRQ747T.js} +36 -7
- package/dist/chunk-JRRQ747T.js.map +1 -0
- package/dist/{chunk-I32NKXE2.js → chunk-JTWZKNUH.js} +5 -5
- package/dist/chunk-K66OY4EI.js +202 -0
- package/dist/chunk-K66OY4EI.js.map +1 -0
- package/dist/{chunk-XAB6STPO.js → chunk-KODXCHXJ.js} +17 -3
- package/dist/chunk-KODXCHXJ.js.map +1 -0
- package/dist/{chunk-ZPUIRTIZ.js → chunk-KOLJJN5G.js} +12 -75
- package/dist/chunk-KOLJJN5G.js.map +1 -0
- package/dist/{chunk-FMQ4MOQO.js → chunk-KXIXO76C.js} +32 -19
- package/dist/chunk-KXIXO76C.js.map +1 -0
- package/dist/{chunk-VKCAHCBI.js → chunk-L4X4PJYK.js} +2 -2
- package/dist/chunk-LB7WCZHY.js +553 -0
- package/dist/chunk-LB7WCZHY.js.map +1 -0
- package/dist/{chunk-W4BMEGQA.js → chunk-LUDBXTBJ.js} +8 -8
- package/dist/{chunk-I4343FIA.js → chunk-MAH64N55.js} +28 -10
- package/dist/chunk-MAH64N55.js.map +1 -0
- package/dist/{chunk-RIAM7DND.js → chunk-ME35HVDJ.js} +2 -2
- package/dist/{chunk-H63EDPFJ.js → chunk-MI2OTWV5.js} +15 -2
- package/dist/{chunk-H63EDPFJ.js.map → chunk-MI2OTWV5.js.map} +1 -1
- package/dist/{chunk-LBFFNDFM.js → chunk-MINHJ55X.js} +1 -1
- package/dist/chunk-MINHJ55X.js.map +1 -0
- package/dist/{chunk-NG3MBQV4.js → chunk-MJRGVXPQ.js} +2 -2
- package/dist/{chunk-773TRRGT.js → chunk-MJUCDM3C.js} +2 -2
- package/dist/{chunk-7F27PCSN.js → chunk-MN5NOOI7.js} +2 -2
- package/dist/{chunk-JCWY73FK.js → chunk-N4F7ZSSG.js} +2 -2
- package/dist/{chunk-TR7DGXGI.js → chunk-NACLNNFQ.js} +5 -5
- package/dist/{chunk-LC2BDILZ.js → chunk-NBP4EX5N.js} +2 -2
- package/dist/{chunk-ZVPVTPGI.js → chunk-NNZFPYYX.js} +4 -4
- package/dist/{chunk-MFOSZUIT.js → chunk-NPIBN2VL.js} +2 -2
- package/dist/{chunk-IY7UXD3J.js → chunk-O57GM3FR.js} +2 -2
- package/dist/{chunk-I2HTKOOP.js → chunk-O7ERGZDA.js} +5 -5
- package/dist/{chunk-GTSVEEP3.js → chunk-OAJMQKQR.js} +3 -3
- package/dist/{chunk-HSZMX3ZJ.js → chunk-ODW5GDFE.js} +2 -2
- package/dist/{chunk-D4QVPP3G.js → chunk-PEBH5DCK.js} +18 -11
- package/dist/chunk-PEBH5DCK.js.map +1 -0
- package/dist/{chunk-J2WC5LF4.js → chunk-QBC33MPY.js} +2 -1
- package/dist/{chunk-EOHKUWXW.js → chunk-QCRJMU5V.js} +2 -2
- package/dist/chunk-QJCWK2A7.js +1466 -0
- package/dist/chunk-QJCWK2A7.js.map +1 -0
- package/dist/{chunk-THG4GYIE.js → chunk-RDGKVH6T.js} +11 -7
- package/dist/{chunk-THG4GYIE.js.map → chunk-RDGKVH6T.js.map} +1 -1
- package/dist/{chunk-5DH6PG4B.js → chunk-RZ3IZIJG.js} +3 -3
- package/dist/{chunk-AAXJNINV.js → chunk-SN4JXNLL.js} +2 -2
- package/dist/chunk-TB2MJRI6.js +866 -0
- package/dist/chunk-TB2MJRI6.js.map +1 -0
- package/dist/{chunk-7PHI6GUI.js → chunk-TEZ2HTC7.js} +42 -2
- package/dist/chunk-TEZ2HTC7.js.map +1 -0
- package/dist/{chunk-SVSRPG6M.js → chunk-TNGH4ZYI.js} +2 -2
- package/dist/{chunk-HZNYJN77.js → chunk-TNXNECAN.js} +6 -6
- package/dist/{chunk-JOEJG4SD.js → chunk-TVW4C7PV.js} +5 -5
- package/dist/{chunk-UFKPQBXH.js → chunk-U62OK7BB.js} +2 -2
- package/dist/{chunk-R2MZCYA6.js → chunk-UNUMFURP.js} +3 -3
- package/dist/{chunk-AX7UXCHJ.js → chunk-UYA36DQ7.js} +2 -1
- package/dist/chunk-UYA36DQ7.js.map +1 -0
- package/dist/{chunk-AFR6AIM4.js → chunk-VCKWULAK.js} +112 -87
- package/dist/chunk-VCKWULAK.js.map +1 -0
- package/dist/chunk-VOSWUO3K.js +100 -0
- package/dist/chunk-VOSWUO3K.js.map +1 -0
- package/dist/{chunk-YRVAKONL.js → chunk-VQ4AMTGZ.js} +1 -1
- package/dist/{chunk-3BCULS4U.js → chunk-VQNRICAQ.js} +145 -507
- package/dist/chunk-VQNRICAQ.js.map +1 -0
- package/dist/{chunk-RAIUTAZZ.js → chunk-WKAXBXVA.js} +2 -2
- package/dist/{chunk-ZIJDI4CP.js → chunk-WKJFIMVN.js} +2 -2
- package/dist/{chunk-SXIMQLGV.js → chunk-WVGXCBOC.js} +2 -2
- package/dist/{chunk-7BEPVIH3.js → chunk-X5YYSAZX.js} +4 -4
- package/dist/{chunk-FZEEWOI2.js → chunk-XJJYSX6F.js} +2 -2
- package/dist/{chunk-F635GAL7.js → chunk-XKNHFDTT.js} +33 -13
- package/dist/chunk-XKNHFDTT.js.map +1 -0
- package/dist/{chunk-UG6VXIOK.js → chunk-XSTNGNJP.js} +2 -2
- package/dist/{chunk-YDPAE2RD.js → chunk-YFLLGRXO.js} +2 -2
- package/dist/{chunk-EZ25VE3G.js → chunk-YNDLCWXS.js} +4 -4
- package/dist/{chunk-ANJXPFRS.js → chunk-YXFCALVT.js} +14 -14
- package/dist/{chunk-Q4WONDMJ.js → chunk-YYGZJPOK.js} +2 -2
- package/dist/{chunk-5HERQ5FX.js → chunk-Z3YEGSR4.js} +10 -10
- package/dist/{chunk-YWSQD2IB.js → chunk-ZJPM7GZ3.js} +2 -2
- package/dist/{chunk-5S4LQOPE.js → chunk-ZW4VXELZ.js} +2 -2
- package/dist/{cli-B322UMvB.d.ts → cli-BEkm2MEf.d.ts} +5 -5
- package/dist/cli.d.ts +17 -16
- package/dist/cli.js +126 -120
- package/dist/coding/export-okf-codegraph.d.ts +56 -0
- package/dist/coding/export-okf-codegraph.js +526 -0
- package/dist/coding/export-okf-codegraph.js.map +1 -0
- package/dist/coding/pre-action-gate.d.ts +2 -2
- package/dist/compounding/engine.d.ts +5 -3
- package/dist/compounding/engine.js +34 -34
- package/dist/compounding/preference-consolidator.d.ts +4 -4
- package/dist/compression-optimizer.d.ts +2 -2
- package/dist/config-security.js +2 -2
- package/dist/config.d.ts +2 -2
- package/dist/config.js +17 -16
- package/dist/connectors/codex-materialize-runner.d.ts +2 -2
- package/dist/connectors/codex-materialize-runner.js +33 -33
- package/dist/connectors/codex-materialize.d.ts +2 -2
- package/dist/connectors/index.d.ts +2 -2
- package/dist/connectors/index.js +33 -33
- package/dist/consolidation-provenance-check.d.ts +5 -3
- package/dist/consolidation-provenance-check.js +5 -5
- package/dist/consolidation-undo.d.ts +5 -3
- package/dist/consolidation-undo.js +3 -3
- package/dist/context-summary.d.ts +43 -0
- package/dist/context-summary.js +14 -0
- package/dist/context-summary.js.map +1 -0
- package/dist/contradiction/index.d.ts +6 -4
- package/dist/contradiction/index.js +10 -10
- package/dist/{contradiction-scan-AKUWPX5N.js → contradiction-scan-NOYMFG66.js} +3 -3
- package/dist/contradiction-scan-NOYMFG66.js.map +1 -0
- package/dist/converge-config.d.ts +2 -2
- package/dist/convergence-refresh.d.ts +5 -3
- package/dist/convergence-refresh.js +36 -36
- package/dist/conversation-index/backend.d.ts +2 -2
- package/dist/conversation-index/chunker.d.ts +2 -2
- package/dist/conversation-index/faiss-adapter.d.ts +2 -2
- package/dist/conversation-index/indexer.d.ts +2 -2
- package/dist/conversation-index/search.d.ts +2 -2
- package/dist/corpus-watermark.d.ts +2 -2
- package/dist/corpus-watermark.js +35 -35
- package/dist/cross-lingual-recall.d.ts +2 -2
- package/dist/dashboard-runtime.js +2 -2
- package/dist/day-summary.d.ts +2 -2
- package/dist/delinearize.d.ts +2 -2
- package/dist/dependency-propagation-config.d.ts +2 -2
- package/dist/{dependency-propagation-delivery-BGcNairQ.d.ts → dependency-propagation-delivery-BCpeo14F.d.ts} +1 -1
- package/dist/direct-answer-wiring.d.ts +2 -2
- package/dist/direct-answer.d.ts +2 -2
- package/dist/embedding-fallback.d.ts +2 -2
- package/dist/enrichment/index.d.ts +2 -2
- package/dist/entity-origin-fields.d.ts +2 -2
- package/dist/entity-retrieval.d.ts +5 -3
- package/dist/entity-retrieval.js +34 -34
- package/dist/entity-schema.d.ts +2 -2
- package/dist/episodic-context.d.ts +2 -2
- package/dist/eval-trajectory-contracts.d.ts +2 -2
- package/dist/eval-trajectory-store.d.ts +2 -2
- package/dist/eval-trajectory.d.ts +2 -2
- package/dist/event-order-recall.js +3 -3
- package/dist/explicit-capture.d.ts +13 -12
- package/dist/explicit-capture.js +12 -12
- package/dist/external-wiki-access.d.ts +15 -14
- package/dist/external-wiki-access.js +66 -63
- package/dist/external-wiki-collection-registration.d.ts +2 -2
- package/dist/external-wiki-collection.d.ts +2 -2
- package/dist/external-wiki-mcp-tools.d.ts +15 -14
- package/dist/extraction-error-classification.d.ts +2 -2
- package/dist/extraction-faithfulness.d.ts +2 -2
- package/dist/extraction-faithfulness.js +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 +2 -2
- package/dist/extraction-normalization.d.ts +2 -2
- package/dist/extraction-prompt.d.ts +2 -2
- package/dist/extraction-source-grounding-rules.d.ts +2 -2
- package/dist/extraction-source-grounding.d.ts +2 -2
- package/dist/extraction.d.ts +2 -2
- package/dist/extraction.js +47 -44
- package/dist/fallback-llm.d.ts +8 -2
- package/dist/fallback-llm.js +1 -1
- package/dist/{first-start-migration-4NETATFF.js → first-start-migration-KHIMCBIC.js} +3 -3
- package/dist/{forget-SZ2BXDGF.js → forget-2AE4MDK3.js} +3 -3
- package/dist/graph-dashboard-diff.d.ts +2 -2
- package/dist/graph-dashboard-key.d.ts +2 -2
- package/dist/graph-dashboard-parser.d.ts +2 -2
- package/dist/graph-edge-reinforcement.d.ts +2 -2
- package/dist/graph-path-reconstruction.d.ts +2 -2
- package/dist/graph-path-scoring.d.ts +2 -2
- package/dist/graph-snapshot.d.ts +2 -2
- package/dist/graph.d.ts +2 -2
- package/dist/harmonic-retrieval.js +1 -1
- package/dist/importance.d.ts +2 -2
- package/dist/importers/index.d.ts +2 -2
- package/dist/in-flight-reads.d.ts +2 -2
- package/dist/{index-By2QUAMh.d.ts → index-D_pyMUaP.d.ts} +2 -2
- package/dist/index.d.ts +261 -30
- package/dist/index.js +321 -257
- package/dist/intent.d.ts +2 -2
- package/dist/lcm/engine.d.ts +3 -3
- package/dist/lcm/engine.js +5 -4
- package/dist/lcm/index.d.ts +4 -3
- package/dist/lcm/index.js +12 -11
- package/dist/lcm/summarizer.d.ts +4 -6
- package/dist/lcm/summarizer.js +2 -1
- package/dist/lcm/tools.d.ts +4 -4
- package/dist/lifecycle.d.ts +2 -2
- package/dist/live-connectors-runner.d.ts +2 -2
- package/dist/local-llm.d.ts +2 -2
- package/dist/local-model-endpoint.d.ts +2 -2
- package/dist/location/index.d.ts +315 -6
- package/dist/location/index.js +151 -19
- package/dist/maintenance/memory-governance.d.ts +2 -2
- package/dist/maintenance/memory-governance.js +34 -34
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +5 -3
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +33 -33
- package/dist/maintenance/rebuild-memory-projection.d.ts +5 -3
- package/dist/maintenance/rebuild-memory-projection.js +35 -35
- package/dist/{maintenance-Dm2McrIx.d.ts → maintenance-DDUX9d6D.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +15 -14
- package/dist/mcp-read-only-tools.js +1 -1
- package/dist/memory-action-policy.d.ts +18 -3
- package/dist/memory-action-policy.js +3 -1
- package/dist/memory-cache.d.ts +2 -2
- package/dist/memory-controller.d.ts +2 -2
- package/dist/memory-controller.js +2 -2
- package/dist/memory-lifecycle-ledger-utils.d.ts +2 -2
- package/dist/memory-projection-mutations.js +3 -3
- package/dist/memory-projection-store.d.ts +2 -2
- package/dist/memory-projection-store.js +1 -1
- package/dist/memory-provenance.d.ts +2 -2
- package/dist/memory-snapshot.d.ts +2 -2
- package/dist/memory-subject-cli.d.ts +15 -14
- package/dist/memory-subject.d.ts +15 -14
- package/dist/memory-subject.js +5 -5
- package/dist/memory-worth-outcomes.d.ts +5 -3
- package/dist/models-json.d.ts +2 -2
- package/dist/namespaces/migrate.d.ts +6 -4
- package/dist/namespaces/migrate.js +34 -34
- package/dist/namespaces/principal.d.ts +2 -2
- package/dist/namespaces/search.d.ts +2 -2
- package/dist/namespaces/search.js +8 -8
- package/dist/namespaces/storage.d.ts +6 -4
- package/dist/namespaces/storage.js +33 -33
- package/dist/native-knowledge.d.ts +2 -2
- package/dist/offline-sync-file-io.js +3 -3
- package/dist/offline-sync-impression-drain.d.ts +2 -2
- package/dist/offline-sync-impression-drain.js +9 -9
- package/dist/offline-sync.js +4 -4
- package/dist/operator-doctor-corpus.d.ts +2 -2
- package/dist/operator-doctor-corpus.js +36 -36
- package/dist/operator-doctor-replica.d.ts +2 -2
- package/dist/operator-toolkit.d.ts +6 -4
- package/dist/operator-toolkit.js +56 -55
- package/dist/orchestration/compression-guideline-coordinator.d.ts +5 -3
- package/dist/orchestration/maintenance.d.ts +7 -5
- package/dist/orchestration/maintenance.js +48 -47
- package/dist/{orchestrator-Co1DyfuP.d.ts → orchestrator-3F4jihCo.d.ts} +8 -8
- package/dist/orchestrator.d.ts +13 -12
- package/dist/orchestrator.js +182 -174
- package/dist/page-versioning.js +3 -3
- package/dist/patterns-cli.d.ts +2 -2
- package/dist/{pipeline-DotMnb6y.d.ts → pipeline-CB1dj6Uh.d.ts} +1 -1
- package/dist/policy-runtime.d.ts +2 -2
- package/dist/proactive-contention.d.ts +2 -2
- package/dist/provenance.d.ts +2 -2
- package/dist/{public-http-PJRtnSi-.d.ts → public-http-34-JIAGQ.d.ts} +1 -1
- package/dist/{purge-GB7PZHT2.js → purge-OP6BEDFY.js} +2 -2
- package/dist/{qmd-BP0n11fR.d.ts → qmd-edLLZXc5.d.ts} +1 -1
- package/dist/qmd-preflight.d.ts +3 -3
- package/dist/qmd-recall-cache.d.ts +2 -2
- package/dist/qmd.d.ts +3 -3
- package/dist/qmd.js +4 -4
- package/dist/recall-concurrency-config.d.ts +2 -2
- package/dist/recall-disclosure-escalation.d.ts +2 -2
- package/dist/recall-explain-renderer.d.ts +2 -2
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-memory-map.d.ts +2 -2
- package/dist/recall-planner-llm.d.ts +2 -2
- package/dist/recall-planner-llm.js +1 -1
- package/dist/recall-state.d.ts +2 -2
- package/dist/recall-tag-filter.d.ts +2 -2
- package/dist/recall-timings.d.ts +2 -2
- package/dist/recall-xray-cli.d.ts +2 -2
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.d.ts +2 -2
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.d.ts +2 -2
- package/dist/recall-xray.js +2 -2
- package/dist/reconcile/cursor.d.ts +2 -2
- package/dist/reconcile/manifest.d.ts +2 -2
- package/dist/reconcile/manifest.js +5 -5
- package/dist/reconcile/plan.d.ts +2 -2
- package/dist/replay/normalizers/chatgpt.d.ts +2 -2
- package/dist/replay/normalizers/claude.d.ts +2 -2
- package/dist/replay/normalizers/openclaw.d.ts +2 -2
- package/dist/replay/normalizers/shared.d.ts +2 -2
- package/dist/replay/runner.d.ts +2 -2
- package/dist/replay/types.d.ts +2 -2
- package/dist/replica-divergence.d.ts +2 -2
- package/dist/replica-peers-config.d.ts +2 -2
- package/dist/{resolution-4552BNRV.js → resolution-4DLI3IOR.js} +11 -11
- package/dist/resolution-4DLI3IOR.js.map +1 -0
- package/dist/resolve-auth-token.d.ts +2 -2
- package/dist/resume-bundles.js +18 -17
- package/dist/retrieval-agents.d.ts +3 -3
- package/dist/retrieval-tiers.d.ts +2 -2
- package/dist/routing/engine.d.ts +2 -2
- package/dist/routing/store.d.ts +2 -2
- package/dist/salvage-envelope.d.ts +2 -2
- package/dist/salvage-envelope.js +7 -7
- package/dist/schemas.d.ts +572 -107
- package/dist/schemas.js +3 -1
- package/dist/{scope-profiles-6ChZKTy-.d.ts → scope-profiles-BF2lu81V.d.ts} +1 -1
- package/dist/search/document-scanner.js +1 -1
- package/dist/search/embed-helper.d.ts +2 -2
- package/dist/search/factory.d.ts +2 -2
- package/dist/search/factory.js +7 -7
- package/dist/search/index.d.ts +2 -2
- package/dist/search/index.js +13 -13
- package/dist/search/lancedb-backend.d.ts +2 -2
- package/dist/search/lancedb-backend.js +1 -1
- package/dist/search/meilisearch-backend.d.ts +2 -2
- package/dist/search/meilisearch-backend.js +1 -1
- package/dist/search/noop-backend.d.ts +2 -2
- package/dist/search/orama-backend.d.ts +2 -2
- package/dist/search/orama-backend.js +1 -1
- package/dist/search/port.d.ts +2 -2
- package/dist/search/remote-backend.d.ts +2 -2
- package/dist/secure-store/index.js +3 -3
- package/dist/{semantic-consolidation-DziYcW5J.d.ts → semantic-consolidation-5OuWXBRt.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +3 -3
- package/dist/semantic-consolidation.js +37 -37
- package/dist/semantic-rule-promotion.js +33 -33
- package/dist/semantic-rule-verifier.d.ts +2 -2
- package/dist/semantic-rule-verifier.js +33 -33
- package/dist/{service-C7rIBuK_.d.ts → service-CrqEhLXD.d.ts} +2 -2
- package/dist/session-observer-bands.d.ts +2 -2
- package/dist/session-observer-state.d.ts +2 -2
- package/dist/shared-context/manager.d.ts +2 -2
- package/dist/signal.d.ts +2 -2
- package/dist/source-agent-qualifier.d.ts +2 -2
- package/dist/source-agent-qualifier.js +42 -39
- package/dist/standup/build.d.ts +16 -0
- package/dist/standup/build.js +17 -0
- package/dist/standup/build.js.map +1 -0
- package/dist/{storage-B1hEx8Xg.d.ts → storage-BQn-xnxm.d.ts} +4 -1
- package/dist/storage.d.ts +5 -3
- package/dist/storage.js +32 -32
- package/dist/subject-config.d.ts +2 -2
- package/dist/subject-config.js +6 -6
- package/dist/summarizer.d.ts +2 -2
- package/dist/summarizer.js +2 -2
- package/dist/summary-snapshot.d.ts +2 -2
- package/dist/support-passport/index.d.ts +20 -19
- package/dist/support-passport/index.js +68 -65
- package/dist/temporal-supersession.d.ts +3 -3
- package/dist/temporal-timeline-recall.d.ts +2 -2
- package/dist/temporal-validity.d.ts +2 -2
- package/dist/threading.d.ts +2 -2
- package/dist/tier-migration.d.ts +5 -3
- package/dist/tier-routing.d.ts +2 -2
- package/dist/tier-routing.js +2 -2
- package/dist/{tier-stats-4B5IJ3NE.js → tier-stats-2TOW3QNL.js} +3 -3
- package/dist/topics.d.ts +2 -2
- package/dist/transcript.d.ts +2 -2
- package/dist/transfer/capsule-export.js +2 -2
- package/dist/transfer/capsule-import.js +5 -5
- package/dist/transfer/export-okf.d.ts +39 -0
- package/dist/transfer/export-okf.js +112 -0
- package/dist/transfer/export-okf.js.map +1 -0
- package/dist/transfer/types.d.ts +12 -12
- package/dist/trust-score-stage.d.ts +2 -2
- package/dist/trust-score.d.ts +2 -2
- package/dist/{types-BHDNxGTT.d.ts → types-BRpcNjHZ.d.ts} +119 -3
- package/dist/types.d.ts +2 -2
- package/dist/types.js +1 -1
- package/dist/utility-runtime.d.ts +2 -2
- package/dist/verified-recall.js +33 -33
- package/dist/who-knows-cli.d.ts +15 -14
- package/dist/who-knows-cli.js +34 -34
- package/dist/who-knows.d.ts +15 -14
- package/dist/who-knows.js +33 -33
- package/dist/write-envelope.d.ts +2 -2
- package/dist/write-envelope.js +6 -6
- package/package.json +54 -3
- package/src/access-admin-ops-surface.ts +6 -1
- package/src/access-boundary.ts +1 -0
- package/src/access-http.ts +3 -1
- package/src/access-mcp-output-schemas.ts +1 -0
- package/src/access-mcp.ts +3 -3
- package/src/access-operations.ts +1 -0
- package/src/access-service-offline-file-content.test.ts +63 -0
- package/src/access-surface-catalog.ts +2 -0
- package/src/active-context-config.ts +98 -0
- package/src/active-context-transform.test.ts +533 -0
- package/src/active-context-transform.ts +981 -0
- package/src/activity/config.test.ts +1 -0
- package/src/activity/config.ts +21 -1
- package/src/activity/index.ts +1 -0
- package/src/activity/timeline/build.ts +279 -0
- package/src/activity/timeline/categories.ts +111 -0
- package/src/activity/timeline/classify.ts +110 -0
- package/src/activity/timeline/corrections.ts +145 -0
- package/src/activity/timeline/index.ts +6 -0
- package/src/activity/timeline/timeline.test.ts +277 -0
- package/src/activity/timeline/types.ts +106 -0
- package/src/activity/types.ts +6 -0
- package/src/cli/okf-commands.ts +45 -0
- package/src/cli.ts +2 -2
- package/src/coding/export-okf-codegraph.test.ts +381 -0
- package/src/coding/export-okf-codegraph.ts +565 -0
- package/src/config.test.ts +1 -0
- package/src/config.ts +3 -5
- package/src/context-summary.ts +182 -0
- package/src/extraction-prompt-safety.test.ts +14 -2
- package/src/extraction.ts +21 -1
- package/src/fallback-llm.test.ts +134 -0
- package/src/fallback-llm.ts +77 -5
- package/src/index.ts +4 -11
- package/src/lcm/summarizer.ts +14 -93
- package/src/location/access-operations.ts +17 -8
- package/src/location/backfill.ts +137 -0
- package/src/location/config.test.ts +3 -0
- package/src/location/config.ts +46 -2
- package/src/location/http-glue.ts +1 -1
- package/src/location/index.ts +3 -0
- package/src/location/intervals.ts +1 -0
- package/src/location/matching.test.ts +65 -0
- package/src/location/matching.ts +354 -0
- package/src/location/mcp-tools.ts +2 -1
- package/src/location/surfaces.test.ts +15 -2
- package/src/location/surfaces.ts +95 -18
- package/src/location/tagging.test.ts +119 -0
- package/src/location/tagging.ts +277 -0
- package/src/location/types.ts +23 -1
- package/src/mcp-read-only-tools.ts +1 -0
- package/src/memory-action-policy.ts +28 -0
- package/src/memory-projection-store.ts +3 -1
- package/src/okf/cli.ts +18 -5
- package/src/okf/config.ts +5 -0
- package/src/okf/index-files.test.ts +60 -0
- package/src/okf/index-files.ts +114 -0
- package/src/okf/render.ts +133 -0
- package/src/okf/type-mapping.test.ts +3 -0
- package/src/okf/type-mapping.ts +2 -0
- package/src/orchestration/extraction-run.ts +2 -1
- package/src/orchestration/generic-recall-paths.ts +4 -3
- package/src/schemas.ts +17 -1
- package/src/standup/access-operations.ts +14 -0
- package/src/standup/build.test.ts +34 -0
- package/src/standup/build.ts +115 -0
- package/src/standup/http-glue.ts +15 -0
- package/src/standup/mcp-tools.ts +16 -0
- package/src/storage/context-transform-ledger.ts +39 -0
- package/src/storage/secure-line-reader.ts +50 -1
- package/src/storage.ts +4 -1
- package/src/support-passport/card-projection.ts +1 -0
- package/src/support-passport/card-service-commit-forwarding.test.ts +1 -0
- package/src/support-passport/card-service.test.ts +75 -1
- package/src/support-passport/card-service.ts +6 -3
- package/src/support-passport/card-state.ts +5 -1
- package/src/support-passport/offline-sync-guard.ts +14 -1
- package/src/transfer/export-okf.test.ts +164 -0
- package/src/transfer/export-okf.ts +286 -0
- package/src/types.ts +2 -3
- package/dist/chunk-2LWQSV6A.js.map +0 -1
- package/dist/chunk-3BCULS4U.js.map +0 -1
- package/dist/chunk-7BDZTALN.js.map +0 -1
- package/dist/chunk-7PHI6GUI.js.map +0 -1
- package/dist/chunk-AFR6AIM4.js.map +0 -1
- package/dist/chunk-AX7UXCHJ.js.map +0 -1
- package/dist/chunk-BJTHRFFC.js.map +0 -1
- package/dist/chunk-D4QVPP3G.js.map +0 -1
- package/dist/chunk-DVYRD4HY.js.map +0 -1
- package/dist/chunk-F635GAL7.js.map +0 -1
- package/dist/chunk-FMQ4MOQO.js.map +0 -1
- package/dist/chunk-FP7YTTVO.js.map +0 -1
- package/dist/chunk-I4343FIA.js.map +0 -1
- package/dist/chunk-I7EX6KSH.js.map +0 -1
- package/dist/chunk-LBFFNDFM.js.map +0 -1
- package/dist/chunk-LLQCM2U2.js.map +0 -1
- package/dist/chunk-RQE4TITU.js.map +0 -1
- package/dist/chunk-UW5NPZJ2.js.map +0 -1
- package/dist/chunk-XAB6STPO.js.map +0 -1
- package/dist/chunk-ZPUIRTIZ.js.map +0 -1
- package/dist/types-CM86alG1.d.ts +0 -89
- /package/dist/{contradiction-scan-AKUWPX5N.js.map → active-context-config.js.map} +0 -0
- /package/dist/{resolution-4552BNRV.js.map → active-context-transform.js.map} +0 -0
- /package/dist/{auto-sync-XVMLL2RH.js.map → auto-sync-Q6Q2FVSC.js.map} +0 -0
- /package/dist/{capsule-merge-SGIVB3WA.js.map → capsule-merge-SEHERWWP.js.map} +0 -0
- /package/dist/{chunk-CFGU52XJ.js.map → chunk-23CVL7HS.js.map} +0 -0
- /package/dist/{chunk-PO7NXBG2.js.map → chunk-2GF27PGH.js.map} +0 -0
- /package/dist/{chunk-6CPUQ5D6.js.map → chunk-2LBAFHOQ.js.map} +0 -0
- /package/dist/{chunk-JBPKEARU.js.map → chunk-2QSZNTDO.js.map} +0 -0
- /package/dist/{chunk-IP4ZNT4U.js.map → chunk-33MFRY25.js.map} +0 -0
- /package/dist/{chunk-VFYRYFLL.js.map → chunk-3TSU662L.js.map} +0 -0
- /package/dist/{chunk-VXVZ2GM3.js.map → chunk-4FHRZD5T.js.map} +0 -0
- /package/dist/{chunk-5VPQSRQO.js.map → chunk-4STAANV7.js.map} +0 -0
- /package/dist/{chunk-46WM6JX2.js.map → chunk-4ZWCQJNM.js.map} +0 -0
- /package/dist/{chunk-52II7PB6.js.map → chunk-645WOU5I.js.map} +0 -0
- /package/dist/{chunk-YKWFK7XA.js.map → chunk-6CEGSTBD.js.map} +0 -0
- /package/dist/{chunk-GEPACVWN.js.map → chunk-6RUHELWR.js.map} +0 -0
- /package/dist/{chunk-ZAOHJDKH.js.map → chunk-72OIT7KS.js.map} +0 -0
- /package/dist/{chunk-KQAFEZQX.js.map → chunk-7LCGFUMB.js.map} +0 -0
- /package/dist/{chunk-7TCGNUVP.js.map → chunk-7UTDHQZ5.js.map} +0 -0
- /package/dist/{chunk-5HK3CJAR.js.map → chunk-7XOG75AU.js.map} +0 -0
- /package/dist/{chunk-C24UZSFW.js.map → chunk-CEH2AFXG.js.map} +0 -0
- /package/dist/{chunk-YOXVZJFM.js.map → chunk-CFVTRUR3.js.map} +0 -0
- /package/dist/{chunk-ACOC27BB.js.map → chunk-CN4VKV3S.js.map} +0 -0
- /package/dist/{chunk-PMVPCZJZ.js.map → chunk-CTCGHNWN.js.map} +0 -0
- /package/dist/{chunk-EGBDFJ36.js.map → chunk-DD5JFCWM.js.map} +0 -0
- /package/dist/{chunk-T42L3S6A.js.map → chunk-DDX6KIXF.js.map} +0 -0
- /package/dist/{chunk-JIYDRBVZ.js.map → chunk-DJORULH3.js.map} +0 -0
- /package/dist/{chunk-WTOZBZNN.js.map → chunk-DMEHOEC7.js.map} +0 -0
- /package/dist/{chunk-OPPBTPUU.js.map → chunk-DUAJKRR2.js.map} +0 -0
- /package/dist/{chunk-SVVIASVX.js.map → chunk-EFQCDJZ2.js.map} +0 -0
- /package/dist/{chunk-Q57GOHLF.js.map → chunk-EGALNSZ4.js.map} +0 -0
- /package/dist/{chunk-KCT36JAW.js.map → chunk-ESNFSSO4.js.map} +0 -0
- /package/dist/{chunk-XQ3HXAQH.js.map → chunk-ET2CNMLD.js.map} +0 -0
- /package/dist/{chunk-Z4U3UN56.js.map → chunk-EZSCW4EM.js.map} +0 -0
- /package/dist/{chunk-F6QHHRWP.js.map → chunk-FESUGFIL.js.map} +0 -0
- /package/dist/{chunk-S3K2CIK5.js.map → chunk-FKKGCGYL.js.map} +0 -0
- /package/dist/{chunk-BWGCOLEL.js.map → chunk-FTTJRVB7.js.map} +0 -0
- /package/dist/{chunk-JAQXUGLN.js.map → chunk-FYWLSFFS.js.map} +0 -0
- /package/dist/{chunk-OPGL46PX.js.map → chunk-GX6FTSYH.js.map} +0 -0
- /package/dist/{chunk-A32YEQAM.js.map → chunk-H7VDIF2V.js.map} +0 -0
- /package/dist/{chunk-PDDSFELN.js.map → chunk-HJXA6ZM7.js.map} +0 -0
- /package/dist/{chunk-RGCF4XNH.js.map → chunk-HNPE66LB.js.map} +0 -0
- /package/dist/{chunk-SEA6M7SS.js.map → chunk-I5VB44ZK.js.map} +0 -0
- /package/dist/{chunk-SDEPLF7V.js.map → chunk-IBJ6U753.js.map} +0 -0
- /package/dist/{chunk-EUYWQ7TS.js.map → chunk-IEZ6CGTW.js.map} +0 -0
- /package/dist/{chunk-3RI5Y7KU.js.map → chunk-IVIAHQBR.js.map} +0 -0
- /package/dist/{chunk-7WR462EM.js.map → chunk-J3OND5QT.js.map} +0 -0
- /package/dist/{chunk-T3JQTCCO.js.map → chunk-JI7U6AS3.js.map} +0 -0
- /package/dist/{chunk-I32NKXE2.js.map → chunk-JTWZKNUH.js.map} +0 -0
- /package/dist/{chunk-VKCAHCBI.js.map → chunk-L4X4PJYK.js.map} +0 -0
- /package/dist/{chunk-W4BMEGQA.js.map → chunk-LUDBXTBJ.js.map} +0 -0
- /package/dist/{chunk-RIAM7DND.js.map → chunk-ME35HVDJ.js.map} +0 -0
- /package/dist/{chunk-NG3MBQV4.js.map → chunk-MJRGVXPQ.js.map} +0 -0
- /package/dist/{chunk-773TRRGT.js.map → chunk-MJUCDM3C.js.map} +0 -0
- /package/dist/{chunk-7F27PCSN.js.map → chunk-MN5NOOI7.js.map} +0 -0
- /package/dist/{chunk-JCWY73FK.js.map → chunk-N4F7ZSSG.js.map} +0 -0
- /package/dist/{chunk-TR7DGXGI.js.map → chunk-NACLNNFQ.js.map} +0 -0
- /package/dist/{chunk-LC2BDILZ.js.map → chunk-NBP4EX5N.js.map} +0 -0
- /package/dist/{chunk-ZVPVTPGI.js.map → chunk-NNZFPYYX.js.map} +0 -0
- /package/dist/{chunk-MFOSZUIT.js.map → chunk-NPIBN2VL.js.map} +0 -0
- /package/dist/{chunk-IY7UXD3J.js.map → chunk-O57GM3FR.js.map} +0 -0
- /package/dist/{chunk-I2HTKOOP.js.map → chunk-O7ERGZDA.js.map} +0 -0
- /package/dist/{chunk-GTSVEEP3.js.map → chunk-OAJMQKQR.js.map} +0 -0
- /package/dist/{chunk-HSZMX3ZJ.js.map → chunk-ODW5GDFE.js.map} +0 -0
- /package/dist/{chunk-J2WC5LF4.js.map → chunk-QBC33MPY.js.map} +0 -0
- /package/dist/{chunk-EOHKUWXW.js.map → chunk-QCRJMU5V.js.map} +0 -0
- /package/dist/{chunk-5DH6PG4B.js.map → chunk-RZ3IZIJG.js.map} +0 -0
- /package/dist/{chunk-AAXJNINV.js.map → chunk-SN4JXNLL.js.map} +0 -0
- /package/dist/{chunk-SVSRPG6M.js.map → chunk-TNGH4ZYI.js.map} +0 -0
- /package/dist/{chunk-HZNYJN77.js.map → chunk-TNXNECAN.js.map} +0 -0
- /package/dist/{chunk-JOEJG4SD.js.map → chunk-TVW4C7PV.js.map} +0 -0
- /package/dist/{chunk-UFKPQBXH.js.map → chunk-U62OK7BB.js.map} +0 -0
- /package/dist/{chunk-R2MZCYA6.js.map → chunk-UNUMFURP.js.map} +0 -0
- /package/dist/{chunk-YRVAKONL.js.map → chunk-VQ4AMTGZ.js.map} +0 -0
- /package/dist/{chunk-RAIUTAZZ.js.map → chunk-WKAXBXVA.js.map} +0 -0
- /package/dist/{chunk-ZIJDI4CP.js.map → chunk-WKJFIMVN.js.map} +0 -0
- /package/dist/{chunk-SXIMQLGV.js.map → chunk-WVGXCBOC.js.map} +0 -0
- /package/dist/{chunk-7BEPVIH3.js.map → chunk-X5YYSAZX.js.map} +0 -0
- /package/dist/{chunk-FZEEWOI2.js.map → chunk-XJJYSX6F.js.map} +0 -0
- /package/dist/{chunk-UG6VXIOK.js.map → chunk-XSTNGNJP.js.map} +0 -0
- /package/dist/{chunk-YDPAE2RD.js.map → chunk-YFLLGRXO.js.map} +0 -0
- /package/dist/{chunk-EZ25VE3G.js.map → chunk-YNDLCWXS.js.map} +0 -0
- /package/dist/{chunk-ANJXPFRS.js.map → chunk-YXFCALVT.js.map} +0 -0
- /package/dist/{chunk-Q4WONDMJ.js.map → chunk-YYGZJPOK.js.map} +0 -0
- /package/dist/{chunk-5HERQ5FX.js.map → chunk-Z3YEGSR4.js.map} +0 -0
- /package/dist/{chunk-YWSQD2IB.js.map → chunk-ZJPM7GZ3.js.map} +0 -0
- /package/dist/{chunk-5S4LQOPE.js.map → chunk-ZW4VXELZ.js.map} +0 -0
- /package/dist/{first-start-migration-4NETATFF.js.map → first-start-migration-KHIMCBIC.js.map} +0 -0
- /package/dist/{forget-SZ2BXDGF.js.map → forget-2AE4MDK3.js.map} +0 -0
- /package/dist/{purge-GB7PZHT2.js.map → purge-OP6BEDFY.js.map} +0 -0
- /package/dist/{tier-stats-4B5IJ3NE.js.map → tier-stats-2TOW3QNL.js.map} +0 -0
|
@@ -0,0 +1,866 @@
|
|
|
1
|
+
import {
|
|
2
|
+
STRUCTURED_ATTRIBUTE_LIMITS,
|
|
3
|
+
TAG_LIMITS
|
|
4
|
+
} from "./chunk-WKAXBXVA.js";
|
|
5
|
+
import {
|
|
6
|
+
activityDayWindow,
|
|
7
|
+
isValidActivityDate
|
|
8
|
+
} from "./chunk-M6L7HI7R.js";
|
|
9
|
+
import {
|
|
10
|
+
writeFileAtomically
|
|
11
|
+
} from "./chunk-AW4QUFQF.js";
|
|
12
|
+
import {
|
|
13
|
+
pathIsInside
|
|
14
|
+
} from "./chunk-GCASGYIO.js";
|
|
15
|
+
import {
|
|
16
|
+
log
|
|
17
|
+
} from "./chunk-3WCASNQZ.js";
|
|
18
|
+
|
|
19
|
+
// src/location/intervals.ts
|
|
20
|
+
function isValidLocationDate(date) {
|
|
21
|
+
return isValidActivityDate(date);
|
|
22
|
+
}
|
|
23
|
+
function locationDayWindow(date, timezone) {
|
|
24
|
+
if (!isValidActivityDate(date)) {
|
|
25
|
+
throw new RangeError(`Invalid location date "${date}"; expected a real YYYY-MM-DD day.`);
|
|
26
|
+
}
|
|
27
|
+
return activityDayWindow(date, timezone);
|
|
28
|
+
}
|
|
29
|
+
function assertFiniteInstant(iso, what) {
|
|
30
|
+
const ms = Date.parse(iso);
|
|
31
|
+
if (typeof iso !== "string" || !Number.isFinite(ms)) {
|
|
32
|
+
throw new RangeError(`${what} must be a UTC ISO-8601 instant; got "${String(iso)}"`);
|
|
33
|
+
}
|
|
34
|
+
return ms;
|
|
35
|
+
}
|
|
36
|
+
function localDayKey(instantUtc, timezone) {
|
|
37
|
+
assertFiniteInstant(instantUtc, "instantUtc");
|
|
38
|
+
return new Intl.DateTimeFormat("en-CA", {
|
|
39
|
+
timeZone: timezone,
|
|
40
|
+
year: "numeric",
|
|
41
|
+
month: "2-digit",
|
|
42
|
+
day: "2-digit"
|
|
43
|
+
}).format(new Date(instantUtc));
|
|
44
|
+
}
|
|
45
|
+
function compareObservations(a, b) {
|
|
46
|
+
if (a.observedAtUtc !== b.observedAtUtc) {
|
|
47
|
+
return a.observedAtUtc < b.observedAtUtc ? -1 : 1;
|
|
48
|
+
}
|
|
49
|
+
if (a.place.id !== b.place.id) {
|
|
50
|
+
return a.place.id < b.place.id ? -1 : 1;
|
|
51
|
+
}
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
function bucketObservationsByDay(observations, timezone) {
|
|
55
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
56
|
+
for (const observation of observations) {
|
|
57
|
+
assertFiniteInstant(observation.observedAtUtc, "observation observedAtUtc");
|
|
58
|
+
const key = localDayKey(observation.observedAtUtc, timezone);
|
|
59
|
+
const bucket = buckets.get(key);
|
|
60
|
+
if (bucket === void 0) buckets.set(key, [observation]);
|
|
61
|
+
else bucket.push(observation);
|
|
62
|
+
}
|
|
63
|
+
for (const bucket of buckets.values()) bucket.sort(compareObservations);
|
|
64
|
+
return buckets;
|
|
65
|
+
}
|
|
66
|
+
function intervalOverlapMs(a, b) {
|
|
67
|
+
const overlap = Math.min(Date.parse(a.endUtc), Date.parse(b.endUtc)) - Math.max(Date.parse(a.startUtc), Date.parse(b.startUtc));
|
|
68
|
+
return Math.max(0, overlap);
|
|
69
|
+
}
|
|
70
|
+
function placeForSegment(place, retainCoordinates) {
|
|
71
|
+
if (retainCoordinates || place.latitude === void 0 || place.longitude === void 0) {
|
|
72
|
+
return place;
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
id: place.id,
|
|
76
|
+
label: place.label,
|
|
77
|
+
...place.kind === void 0 ? {} : { kind: place.kind }
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function observationSegments(observations, window, options) {
|
|
81
|
+
const startMs = assertFiniteInstant(window.startUtc, "window startUtc");
|
|
82
|
+
const endMs = assertFiniteInstant(window.endUtc, "window endUtc");
|
|
83
|
+
if (startMs >= endMs) {
|
|
84
|
+
throw new RangeError("location window must satisfy startUtc < endUtc");
|
|
85
|
+
}
|
|
86
|
+
const ordered = [...observations].sort(compareObservations);
|
|
87
|
+
const segments = [];
|
|
88
|
+
for (let index = 0; index < ordered.length; index += 1) {
|
|
89
|
+
const current = ordered[index];
|
|
90
|
+
const currentMs = Date.parse(current.observedAtUtc);
|
|
91
|
+
if (currentMs < startMs || currentMs >= endMs) {
|
|
92
|
+
throw new RangeError(
|
|
93
|
+
`location observation at "${current.observedAtUtc}" falls outside the requested [${window.startUtc}, ${window.endUtc}) window`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
const nextMs = index + 1 < ordered.length ? Date.parse(ordered[index + 1].observedAtUtc) : endMs;
|
|
97
|
+
const segmentEndMs = Math.min(nextMs, endMs);
|
|
98
|
+
if (currentMs >= segmentEndMs) continue;
|
|
99
|
+
segments.push({
|
|
100
|
+
startUtc: new Date(currentMs).toISOString(),
|
|
101
|
+
endUtc: new Date(segmentEndMs).toISOString(),
|
|
102
|
+
place: placeForSegment(current.place, options.retainCoordinates),
|
|
103
|
+
...current.confidence !== void 0 ? { confidence: current.confidence } : {}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return segments;
|
|
107
|
+
}
|
|
108
|
+
function unionIntervalMs(segments) {
|
|
109
|
+
const bounds = segments.map((segment) => ({ start: Date.parse(segment.startUtc), end: Date.parse(segment.endUtc) })).sort((a, b) => a.start !== b.start ? a.start - b.start : a.end - b.end);
|
|
110
|
+
let total = 0;
|
|
111
|
+
let sweepStart = null;
|
|
112
|
+
let sweepEnd = 0;
|
|
113
|
+
for (const bound of bounds) {
|
|
114
|
+
if (sweepStart === null || bound.start > sweepEnd) {
|
|
115
|
+
if (sweepStart !== null) total += sweepEnd - sweepStart;
|
|
116
|
+
sweepStart = bound.start;
|
|
117
|
+
sweepEnd = bound.end;
|
|
118
|
+
} else if (bound.end > sweepEnd) {
|
|
119
|
+
sweepEnd = bound.end;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (sweepStart !== null) total += sweepEnd - sweepStart;
|
|
123
|
+
return total;
|
|
124
|
+
}
|
|
125
|
+
function placeDurations(segments) {
|
|
126
|
+
const byPlace = /* @__PURE__ */ new Map();
|
|
127
|
+
for (const segment of segments) {
|
|
128
|
+
const existing = byPlace.get(segment.place.id);
|
|
129
|
+
if (existing === void 0) {
|
|
130
|
+
byPlace.set(segment.place.id, { place: segment.place, segments: [segment], firstStartUtc: segment.startUtc });
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
existing.segments.push(segment);
|
|
134
|
+
if (segment.startUtc < existing.firstStartUtc) existing.firstStartUtc = segment.startUtc;
|
|
135
|
+
if (segment.place.label < existing.place.label) existing.place = segment.place;
|
|
136
|
+
}
|
|
137
|
+
const durations = [...byPlace.values()].map((entry) => ({
|
|
138
|
+
place: entry.place,
|
|
139
|
+
totalMs: unionIntervalMs(entry.segments),
|
|
140
|
+
firstStartUtc: entry.firstStartUtc
|
|
141
|
+
}));
|
|
142
|
+
durations.sort((a, b) => {
|
|
143
|
+
if (a.place.id !== b.place.id) return a.place.id < b.place.id ? -1 : 1;
|
|
144
|
+
return 0;
|
|
145
|
+
});
|
|
146
|
+
return durations;
|
|
147
|
+
}
|
|
148
|
+
function dominantPlace(segments) {
|
|
149
|
+
const durations = placeDurations(segments);
|
|
150
|
+
let best = null;
|
|
151
|
+
for (const duration of durations) {
|
|
152
|
+
if (best === null) {
|
|
153
|
+
best = duration;
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (duration.totalMs !== best.totalMs) {
|
|
157
|
+
if (duration.totalMs > best.totalMs) best = duration;
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
if (duration.firstStartUtc !== best.firstStartUtc) {
|
|
161
|
+
if (duration.firstStartUtc < best.firstStartUtc) best = duration;
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (duration.place.id < best.place.id) best = duration;
|
|
165
|
+
}
|
|
166
|
+
return best === null ? null : { place: best.place, totalMs: best.totalMs };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// src/location/matching.ts
|
|
170
|
+
var LOCATION_MATCH_MAX_MEMORY_SPAN_MS = 24 * 60 * 60 * 1e3;
|
|
171
|
+
var LOCATION_TAG_PREFIX = "location:";
|
|
172
|
+
var LOCATION_ATTRIBUTE_KEYS = [
|
|
173
|
+
"locationSource",
|
|
174
|
+
"locationPlaceId",
|
|
175
|
+
"locationPlace",
|
|
176
|
+
"locationConfidence",
|
|
177
|
+
"locationVisitStart",
|
|
178
|
+
"locationVisitEnd",
|
|
179
|
+
"locationLatitude",
|
|
180
|
+
"locationLongitude"
|
|
181
|
+
];
|
|
182
|
+
var TAGGABLE_PLACE_KINDS = { home: true, work: true, poi: true };
|
|
183
|
+
function memoryLocationWindow(frontmatter, localDay) {
|
|
184
|
+
const start = frontmatter.valid_at ?? frontmatter.observedAt;
|
|
185
|
+
if (start === void 0 || Number.isNaN(Date.parse(start))) {
|
|
186
|
+
return { rejected: "untimed" };
|
|
187
|
+
}
|
|
188
|
+
const end = frontmatter.invalid_at;
|
|
189
|
+
if (end === void 0 || Number.isNaN(Date.parse(end)) || Date.parse(end) <= Date.parse(start)) {
|
|
190
|
+
return { window: { kind: "instant", atUtc: start }, days: [localDay(start)] };
|
|
191
|
+
}
|
|
192
|
+
if (Date.parse(end) - Date.parse(start) > LOCATION_MATCH_MAX_MEMORY_SPAN_MS) {
|
|
193
|
+
return { rejected: "span-too-long" };
|
|
194
|
+
}
|
|
195
|
+
const lastInstant = new Date(Date.parse(end) - 1).toISOString();
|
|
196
|
+
const days = [localDay(start)];
|
|
197
|
+
const endDay = localDay(lastInstant);
|
|
198
|
+
if (endDay !== days[0]) days.push(endDay);
|
|
199
|
+
return { window: { kind: "interval", startUtc: start, endUtc: end }, days };
|
|
200
|
+
}
|
|
201
|
+
function overlapMsOf(window, segment) {
|
|
202
|
+
if (window.kind === "instant") {
|
|
203
|
+
const at = Date.parse(window.atUtc);
|
|
204
|
+
return at >= Date.parse(segment.startUtc) && at < Date.parse(segment.endUtc) ? 1 : 0;
|
|
205
|
+
}
|
|
206
|
+
return Math.max(
|
|
207
|
+
0,
|
|
208
|
+
Math.min(Date.parse(window.endUtc), Date.parse(segment.endUtc)) - Math.max(Date.parse(window.startUtc), Date.parse(segment.startUtc))
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
function matchDominantPlace(window, sources, policy) {
|
|
212
|
+
const byPlace = /* @__PURE__ */ new Map();
|
|
213
|
+
for (const source of sources) {
|
|
214
|
+
for (const segment of source.segments) {
|
|
215
|
+
if (TAGGABLE_PLACE_KINDS[segment.place.kind ?? ""] !== true) continue;
|
|
216
|
+
const overlap = overlapMsOf(window, segment);
|
|
217
|
+
if (overlap <= 0) continue;
|
|
218
|
+
const duration = Date.parse(segment.endUtc) - Date.parse(segment.startUtc);
|
|
219
|
+
const existing = byPlace.get(segment.place.id);
|
|
220
|
+
if (existing === void 0) {
|
|
221
|
+
byPlace.set(segment.place.id, {
|
|
222
|
+
sourceId: source.sourceId,
|
|
223
|
+
place: segment.place,
|
|
224
|
+
overlapMs: overlap,
|
|
225
|
+
visitMs: duration,
|
|
226
|
+
confidence: segment.confidence,
|
|
227
|
+
startUtc: segment.startUtc,
|
|
228
|
+
endUtc: segment.endUtc
|
|
229
|
+
});
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
existing.overlapMs += overlap;
|
|
233
|
+
existing.visitMs += duration;
|
|
234
|
+
existing.confidence = existing.confidence === void 0 ? segment.confidence : segment.confidence === void 0 ? existing.confidence : Math.min(existing.confidence, segment.confidence);
|
|
235
|
+
if (segment.startUtc < existing.startUtc) existing.startUtc = segment.startUtc;
|
|
236
|
+
if (segment.endUtc > existing.endUtc) existing.endUtc = segment.endUtc;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (byPlace.size === 0) return { status: "unmatched", reason: "no-overlap" };
|
|
240
|
+
let best = null;
|
|
241
|
+
let tie = false;
|
|
242
|
+
for (const candidate of byPlace.values()) {
|
|
243
|
+
if (best === null || candidate.overlapMs > best.overlapMs) {
|
|
244
|
+
best = candidate;
|
|
245
|
+
tie = false;
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
if (candidate.overlapMs === best.overlapMs) tie = true;
|
|
249
|
+
}
|
|
250
|
+
if (best === null || tie) return { status: "unmatched", reason: "ambiguous" };
|
|
251
|
+
const overlapForThreshold = window.kind === "instant" ? best.visitMs : best.overlapMs;
|
|
252
|
+
if (policy.minimumOverlapSeconds > 0 && overlapForThreshold < policy.minimumOverlapSeconds * 1e3) {
|
|
253
|
+
return { status: "unmatched", reason: "below-minimum-overlap" };
|
|
254
|
+
}
|
|
255
|
+
if (best.confidence !== void 0 && best.confidence < policy.minimumConfidence) {
|
|
256
|
+
return { status: "unmatched", reason: "below-minimum-confidence" };
|
|
257
|
+
}
|
|
258
|
+
return {
|
|
259
|
+
status: "matched",
|
|
260
|
+
match: {
|
|
261
|
+
sourceId: best.sourceId,
|
|
262
|
+
place: best.place,
|
|
263
|
+
overlapMs: best.overlapMs,
|
|
264
|
+
visitMs: best.visitMs,
|
|
265
|
+
...best.confidence !== void 0 ? { confidence: best.confidence } : {},
|
|
266
|
+
visitStartUtc: best.startUtc,
|
|
267
|
+
visitEndUtc: best.endUtc
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
function locationTagSlug(placeId) {
|
|
272
|
+
const slug = placeId.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
273
|
+
return slug.slice(0, TAG_LIMITS.maxTagLength - LOCATION_TAG_PREFIX.length);
|
|
274
|
+
}
|
|
275
|
+
function locationTagForPlace(placeId) {
|
|
276
|
+
return `${LOCATION_TAG_PREFIX}${locationTagSlug(placeId)}`;
|
|
277
|
+
}
|
|
278
|
+
function boundedAttributeValue(value) {
|
|
279
|
+
return value.slice(0, STRUCTURED_ATTRIBUTE_LIMITS.maxValueLength);
|
|
280
|
+
}
|
|
281
|
+
function locationAttributesForMatch(match, policy) {
|
|
282
|
+
const attributes = {
|
|
283
|
+
locationSource: match.sourceId,
|
|
284
|
+
locationPlaceId: boundedAttributeValue(match.place.id),
|
|
285
|
+
locationPlace: boundedAttributeValue(match.place.label),
|
|
286
|
+
...match.confidence !== void 0 ? { locationConfidence: match.confidence.toFixed(3) } : {},
|
|
287
|
+
locationVisitStart: match.visitStartUtc,
|
|
288
|
+
locationVisitEnd: match.visitEndUtc
|
|
289
|
+
};
|
|
290
|
+
if (policy.retainCoordinates && match.place.latitude !== void 0 && match.place.longitude !== void 0) {
|
|
291
|
+
attributes.locationLatitude = String(match.place.latitude);
|
|
292
|
+
attributes.locationLongitude = String(match.place.longitude);
|
|
293
|
+
}
|
|
294
|
+
return attributes;
|
|
295
|
+
}
|
|
296
|
+
function frontmatterHasLocationMetadata(frontmatter) {
|
|
297
|
+
if ((frontmatter.tags ?? []).some((tag) => tag.startsWith(LOCATION_TAG_PREFIX))) return true;
|
|
298
|
+
return Object.keys(frontmatter.structuredAttributes ?? {}).some(
|
|
299
|
+
(key) => LOCATION_ATTRIBUTE_KEYS.includes(key)
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
function isProviderOwned(frontmatter) {
|
|
303
|
+
const source = frontmatter.structuredAttributes?.locationSource;
|
|
304
|
+
return typeof source === "string" && source.length > 0;
|
|
305
|
+
}
|
|
306
|
+
function planLocationUpdate(frontmatter, outcome, policy) {
|
|
307
|
+
if (frontmatterHasLocationMetadata(frontmatter) && !isProviderOwned(frontmatter)) {
|
|
308
|
+
return { outcome: "manual-metadata" };
|
|
309
|
+
}
|
|
310
|
+
const tags = [...frontmatter.tags ?? []];
|
|
311
|
+
const attributes = { ...frontmatter.structuredAttributes ?? {} };
|
|
312
|
+
const providerTagIndex = tags.findIndex((tag) => tag.startsWith(LOCATION_TAG_PREFIX));
|
|
313
|
+
const stripProviderFields = () => {
|
|
314
|
+
if (providerTagIndex >= 0) tags.splice(providerTagIndex, 1);
|
|
315
|
+
for (const key of LOCATION_ATTRIBUTE_KEYS) delete attributes[key];
|
|
316
|
+
};
|
|
317
|
+
if (outcome.status !== "matched") {
|
|
318
|
+
if (!isProviderOwned(frontmatter)) return { outcome: "unmatched" };
|
|
319
|
+
if (providerTagIndex < 0 && !("locationPlaceId" in attributes)) {
|
|
320
|
+
return { outcome: "unchanged" };
|
|
321
|
+
}
|
|
322
|
+
stripProviderFields();
|
|
323
|
+
return { patch: { tags, structuredAttributes: attributes }, outcome: "removed" };
|
|
324
|
+
}
|
|
325
|
+
const desiredTag = locationTagForPlace(outcome.match.place.id);
|
|
326
|
+
const desiredAttributes = locationAttributesForMatch(outcome.match, policy);
|
|
327
|
+
if (tags.length >= TAG_LIMITS.maxTags && providerTagIndex < 0) {
|
|
328
|
+
return { outcome: "unchanged" };
|
|
329
|
+
}
|
|
330
|
+
const alreadyCurrent = providerTagIndex >= 0 && tags[providerTagIndex] === desiredTag && LOCATION_ATTRIBUTE_KEYS.every((key) => {
|
|
331
|
+
const want = desiredAttributes[key];
|
|
332
|
+
const have = attributes[key];
|
|
333
|
+
return want === void 0 ? have === void 0 : have === want;
|
|
334
|
+
});
|
|
335
|
+
if (alreadyCurrent) return { outcome: "unchanged" };
|
|
336
|
+
if (providerTagIndex >= 0) tags[providerTagIndex] = desiredTag;
|
|
337
|
+
else tags.push(desiredTag);
|
|
338
|
+
for (const key of LOCATION_ATTRIBUTE_KEYS) delete attributes[key];
|
|
339
|
+
Object.assign(attributes, desiredAttributes);
|
|
340
|
+
const wasProviderOwned = isProviderOwned(frontmatter);
|
|
341
|
+
return {
|
|
342
|
+
patch: { tags, structuredAttributes: attributes },
|
|
343
|
+
outcome: wasProviderOwned ? "updated" : "tagged"
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// src/location/store.ts
|
|
348
|
+
import { createHash } from "crypto";
|
|
349
|
+
import { lstat, mkdir, readFile, readdir, realpath } from "fs/promises";
|
|
350
|
+
import path from "path";
|
|
351
|
+
var LOCATIONS_DIR_NAME = "locations";
|
|
352
|
+
var LOCATION_DAY_KIND = "location-day";
|
|
353
|
+
var LOCATION_DAY_FORMAT_VERSION = 1;
|
|
354
|
+
var MAX_TRACKED_LOCATION_DAYS = 90;
|
|
355
|
+
var DAY_FILE_NAME_PATTERN = /^\d{4}-\d{2}-\d{2}\.md$/;
|
|
356
|
+
var stateLocks = /* @__PURE__ */ new Map();
|
|
357
|
+
function withStateLock(key, fn) {
|
|
358
|
+
const prior = stateLocks.get(key) ?? Promise.resolve();
|
|
359
|
+
const next = prior.then(fn, fn);
|
|
360
|
+
const tail = next.then(
|
|
361
|
+
() => void 0,
|
|
362
|
+
() => void 0
|
|
363
|
+
);
|
|
364
|
+
stateLocks.set(key, tail);
|
|
365
|
+
void tail.then(() => {
|
|
366
|
+
if (stateLocks.get(key) === tail) stateLocks.delete(key);
|
|
367
|
+
});
|
|
368
|
+
return next;
|
|
369
|
+
}
|
|
370
|
+
function locationDayFilePath(memoryDir, date) {
|
|
371
|
+
if (!isValidLocationDate(date)) {
|
|
372
|
+
throw new RangeError(`Invalid location date "${date}"; expected a real YYYY-MM-DD day.`);
|
|
373
|
+
}
|
|
374
|
+
return path.join(memoryDir, LOCATIONS_DIR_NAME, `${date}.md`);
|
|
375
|
+
}
|
|
376
|
+
function locationSyncStateFilePath(memoryDir) {
|
|
377
|
+
return path.join(memoryDir, "state", "locations", "sync.json");
|
|
378
|
+
}
|
|
379
|
+
function emptyLocationSyncState() {
|
|
380
|
+
return { version: 1, sources: {} };
|
|
381
|
+
}
|
|
382
|
+
async function loadLocationSyncState(memoryDir) {
|
|
383
|
+
let raw;
|
|
384
|
+
try {
|
|
385
|
+
raw = await readFile(locationSyncStateFilePath(memoryDir), "utf-8");
|
|
386
|
+
} catch (err) {
|
|
387
|
+
if (err.code === "ENOENT") return emptyLocationSyncState();
|
|
388
|
+
throw err;
|
|
389
|
+
}
|
|
390
|
+
let parsed;
|
|
391
|
+
try {
|
|
392
|
+
parsed = JSON.parse(raw);
|
|
393
|
+
} catch {
|
|
394
|
+
return emptyLocationSyncState();
|
|
395
|
+
}
|
|
396
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed) || typeof parsed.sources !== "object" || parsed.sources === null) {
|
|
397
|
+
return emptyLocationSyncState();
|
|
398
|
+
}
|
|
399
|
+
return { version: 1, sources: parsed.sources };
|
|
400
|
+
}
|
|
401
|
+
async function saveLocationSyncState(memoryDir, state) {
|
|
402
|
+
await mkdir(path.dirname(locationSyncStateFilePath(memoryDir)), { recursive: true, mode: 448 });
|
|
403
|
+
await writeFileAtomically(
|
|
404
|
+
locationSyncStateFilePath(memoryDir),
|
|
405
|
+
`${JSON.stringify(state, null, 2)}
|
|
406
|
+
`
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
function pruneSourceDays(source) {
|
|
410
|
+
const days = source.days;
|
|
411
|
+
if (days === void 0) return;
|
|
412
|
+
const keys = Object.keys(days).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
413
|
+
for (const key of keys.slice(0, Math.max(0, keys.length - MAX_TRACKED_LOCATION_DAYS))) {
|
|
414
|
+
delete days[key];
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
async function updateLocationSourceDay(memoryDir, sourceId, date, payload, completedAtUtc) {
|
|
418
|
+
if (!isValidLocationDate(date)) {
|
|
419
|
+
throw new RangeError(`Invalid location date "${date}"; expected a real YYYY-MM-DD day.`);
|
|
420
|
+
}
|
|
421
|
+
return withStateLock(locationSyncStateFilePath(memoryDir), async () => {
|
|
422
|
+
const state = await loadLocationSyncState(memoryDir);
|
|
423
|
+
const source = state.sources[sourceId] ?? {};
|
|
424
|
+
const days = source.days ?? {};
|
|
425
|
+
days[date] = payload;
|
|
426
|
+
source.days = days;
|
|
427
|
+
source.lastSyncedAtUtc = completedAtUtc;
|
|
428
|
+
state.sources[sourceId] = source;
|
|
429
|
+
for (const candidate of Object.values(state.sources)) pruneSourceDays(candidate);
|
|
430
|
+
await saveLocationSyncState(memoryDir, state);
|
|
431
|
+
return state;
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
function hashLocationBody(body) {
|
|
435
|
+
return createHash("sha256").update(body, "utf8").digest("hex");
|
|
436
|
+
}
|
|
437
|
+
function clockHhMm(iso, timezone) {
|
|
438
|
+
return new Intl.DateTimeFormat("en-GB", {
|
|
439
|
+
timeZone: timezone,
|
|
440
|
+
hour: "2-digit",
|
|
441
|
+
minute: "2-digit",
|
|
442
|
+
hour12: false
|
|
443
|
+
}).format(new Date(iso));
|
|
444
|
+
}
|
|
445
|
+
function formatDuration(ms) {
|
|
446
|
+
const totalMinutes = Math.round(ms / 6e4);
|
|
447
|
+
const hours = Math.floor(totalMinutes / 60);
|
|
448
|
+
const minutes = totalMinutes % 60;
|
|
449
|
+
if (hours <= 0) return `${minutes}m`;
|
|
450
|
+
return `${hours}h ${String(minutes).padStart(2, "0")}m`;
|
|
451
|
+
}
|
|
452
|
+
function safeLabel(label) {
|
|
453
|
+
return label.replace(/\s+/g, " ").replace(/[`*_]/g, "").trim();
|
|
454
|
+
}
|
|
455
|
+
function formatPlaceLabel(segment) {
|
|
456
|
+
const label = safeLabel(segment.place.label);
|
|
457
|
+
return segment.place.kind === void 0 ? label : `${label} (${segment.place.kind})`;
|
|
458
|
+
}
|
|
459
|
+
function formatCoordinates(segment) {
|
|
460
|
+
if (segment.place.latitude === void 0 || segment.place.longitude === void 0) return "";
|
|
461
|
+
return ` @ ${segment.place.latitude.toFixed(4)},${segment.place.longitude.toFixed(4)}`;
|
|
462
|
+
}
|
|
463
|
+
function composeLocationDayBody(date, timezone, sources) {
|
|
464
|
+
const lines = [`# Location day \u2014 ${date} (${timezone})`, ""];
|
|
465
|
+
const allSegments = [];
|
|
466
|
+
let observationCount = 0;
|
|
467
|
+
for (const entry of Object.values(sources)) {
|
|
468
|
+
allSegments.push(...entry.segments);
|
|
469
|
+
observationCount += entry.observationCount;
|
|
470
|
+
}
|
|
471
|
+
lines.push("## Summary", "");
|
|
472
|
+
if (observationCount === 0) {
|
|
473
|
+
lines.push("No location observations recorded.", "");
|
|
474
|
+
} else {
|
|
475
|
+
const durations = placeDurations(allSegments).sort((a, b) => b.totalMs - a.totalMs);
|
|
476
|
+
lines.push(
|
|
477
|
+
`- Places visited: ${durations.length}`,
|
|
478
|
+
...durations.map(
|
|
479
|
+
(duration) => `- ${safeLabel(duration.place.label)}: ${formatDuration(duration.totalMs)}`
|
|
480
|
+
),
|
|
481
|
+
""
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
const sourceIds = Object.keys(sources).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
485
|
+
for (const sourceId of sourceIds) {
|
|
486
|
+
const entry = sources[sourceId];
|
|
487
|
+
lines.push(`## Timeline \u2014 ${safeLabel(entry.providerDisplayName ?? sourceId)}`, "");
|
|
488
|
+
if (entry.segments.length === 0) {
|
|
489
|
+
lines.push("No observations.", "");
|
|
490
|
+
continue;
|
|
491
|
+
}
|
|
492
|
+
for (const segment of entry.segments) {
|
|
493
|
+
lines.push(
|
|
494
|
+
`- ${clockHhMm(segment.startUtc, timezone)}\u2013${clockHhMm(segment.endUtc, timezone)} \u2014 ${formatPlaceLabel(segment)}${formatCoordinates(segment)}`
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
lines.push("");
|
|
498
|
+
}
|
|
499
|
+
return `${lines.join("\n").trimEnd()}
|
|
500
|
+
`;
|
|
501
|
+
}
|
|
502
|
+
function composeLocationDayMeta(date, timezone, sources, body) {
|
|
503
|
+
let observationCount = 0;
|
|
504
|
+
for (const entry of Object.values(sources)) observationCount += entry.observationCount;
|
|
505
|
+
return {
|
|
506
|
+
kind: LOCATION_DAY_KIND,
|
|
507
|
+
date,
|
|
508
|
+
timezone,
|
|
509
|
+
formatVersion: LOCATION_DAY_FORMAT_VERSION,
|
|
510
|
+
sources: Object.keys(sources).sort((a, b) => a < b ? -1 : a > b ? 1 : 0),
|
|
511
|
+
observationCount,
|
|
512
|
+
contentHash: hashLocationBody(body)
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
function frontmatterScalar(key, value) {
|
|
516
|
+
return `${key}: ${typeof value === "number" ? value : JSON.stringify(value)}`;
|
|
517
|
+
}
|
|
518
|
+
function frontmatterList(key, values) {
|
|
519
|
+
if (values.length === 0) return [`${key}: []`];
|
|
520
|
+
const lines = [`${key}:`];
|
|
521
|
+
for (const value of values) lines.push(` - ${JSON.stringify(value)}`);
|
|
522
|
+
return lines;
|
|
523
|
+
}
|
|
524
|
+
function serializeLocationDay(meta, body) {
|
|
525
|
+
const lines = ["---"];
|
|
526
|
+
lines.push(frontmatterScalar("kind", meta.kind));
|
|
527
|
+
lines.push(frontmatterScalar("date", meta.date));
|
|
528
|
+
lines.push(frontmatterScalar("timezone", meta.timezone));
|
|
529
|
+
lines.push(frontmatterScalar("formatVersion", meta.formatVersion));
|
|
530
|
+
lines.push(...frontmatterList("sources", meta.sources));
|
|
531
|
+
lines.push(frontmatterScalar("observationCount", meta.observationCount));
|
|
532
|
+
lines.push(frontmatterScalar("contentHash", meta.contentHash));
|
|
533
|
+
lines.push("---", "", body);
|
|
534
|
+
return lines.join("\n");
|
|
535
|
+
}
|
|
536
|
+
function parseScalar(raw) {
|
|
537
|
+
try {
|
|
538
|
+
const parsed = JSON.parse(raw);
|
|
539
|
+
return typeof parsed === "string" ? parsed : raw;
|
|
540
|
+
} catch {
|
|
541
|
+
return raw;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
function parseLocationDaySummary(raw) {
|
|
545
|
+
if (!raw.startsWith("---\n")) return null;
|
|
546
|
+
const closeIndex = raw.indexOf("\n---\n", 4);
|
|
547
|
+
if (closeIndex === -1) return null;
|
|
548
|
+
const scalars = {};
|
|
549
|
+
const lists = {};
|
|
550
|
+
let currentList = null;
|
|
551
|
+
for (const line of raw.slice(4, closeIndex).split("\n")) {
|
|
552
|
+
const listItem = /^ {2}- (.*)$/.exec(line);
|
|
553
|
+
if (listItem !== null && currentList !== null) {
|
|
554
|
+
lists[currentList].push(parseScalar(listItem[1]));
|
|
555
|
+
continue;
|
|
556
|
+
}
|
|
557
|
+
currentList = null;
|
|
558
|
+
const separator = line.indexOf(":");
|
|
559
|
+
if (separator === -1) continue;
|
|
560
|
+
const key = line.slice(0, separator);
|
|
561
|
+
const value = line.slice(separator + 1).trim();
|
|
562
|
+
if (value === "" || value === "[]") {
|
|
563
|
+
lists[key] = [];
|
|
564
|
+
currentList = key;
|
|
565
|
+
continue;
|
|
566
|
+
}
|
|
567
|
+
if (value.startsWith("[")) {
|
|
568
|
+
lists[key] = [parseScalar(value)];
|
|
569
|
+
currentList = key;
|
|
570
|
+
continue;
|
|
571
|
+
}
|
|
572
|
+
scalars[key] = value;
|
|
573
|
+
}
|
|
574
|
+
if (scalars.kind === void 0 || parseScalar(scalars.kind) !== LOCATION_DAY_KIND) return null;
|
|
575
|
+
if (scalars.date === void 0 || scalars.contentHash === void 0) return null;
|
|
576
|
+
return {
|
|
577
|
+
date: parseScalar(scalars.date),
|
|
578
|
+
timezone: scalars.timezone === void 0 ? "UTC" : parseScalar(scalars.timezone),
|
|
579
|
+
sources: lists.sources ?? [],
|
|
580
|
+
observationCount: scalars.observationCount === void 0 ? 0 : Number(scalars.observationCount) || 0,
|
|
581
|
+
contentHash: parseScalar(scalars.contentHash)
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
function isErrnoCode(err, code) {
|
|
585
|
+
return err instanceof Error && err.code === code;
|
|
586
|
+
}
|
|
587
|
+
async function assertNotSymlink(target, kind) {
|
|
588
|
+
let stat;
|
|
589
|
+
try {
|
|
590
|
+
stat = await lstat(target);
|
|
591
|
+
} catch (err) {
|
|
592
|
+
if (isErrnoCode(err, "ENOENT")) return;
|
|
593
|
+
throw err;
|
|
594
|
+
}
|
|
595
|
+
if (stat.isSymbolicLink()) {
|
|
596
|
+
throw new Error(
|
|
597
|
+
`locations ${kind} '${path.basename(target)}' is a symbolic link \u2014 refusing to follow it even when it resolves inside the memory dir (AGENTS.md pattern #3)`
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
async function assertNoEscape(rootReal, candidate) {
|
|
602
|
+
let candidateReal;
|
|
603
|
+
try {
|
|
604
|
+
candidateReal = await realpath(candidate);
|
|
605
|
+
} catch {
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
if (!pathIsInside(rootReal, candidateReal)) {
|
|
609
|
+
throw new Error(
|
|
610
|
+
"location day path resolves outside the memory dir \u2014 refusing to follow a symlink/traversal (AGENTS.md pattern #3)"
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
async function assertDayPathContained(memoryDir, targetPath) {
|
|
615
|
+
let rootReal;
|
|
616
|
+
try {
|
|
617
|
+
rootReal = await realpath(memoryDir);
|
|
618
|
+
} catch {
|
|
619
|
+
rootReal = path.resolve(memoryDir);
|
|
620
|
+
}
|
|
621
|
+
const locationsDir = path.join(memoryDir, LOCATIONS_DIR_NAME);
|
|
622
|
+
await assertNoEscape(rootReal, locationsDir);
|
|
623
|
+
await assertNoEscape(rootReal, targetPath);
|
|
624
|
+
await assertNotSymlink(locationsDir, "directory");
|
|
625
|
+
await assertNotSymlink(targetPath, "day file");
|
|
626
|
+
}
|
|
627
|
+
async function writeLocationDay(memoryDir, date, serialized) {
|
|
628
|
+
const target = locationDayFilePath(memoryDir, date);
|
|
629
|
+
await assertDayPathContained(memoryDir, target);
|
|
630
|
+
try {
|
|
631
|
+
if (await readFile(target, "utf-8") === serialized) return false;
|
|
632
|
+
} catch (err) {
|
|
633
|
+
if (!isErrnoCode(err, "ENOENT")) throw err;
|
|
634
|
+
}
|
|
635
|
+
await mkdir(path.dirname(target), { recursive: true, mode: 448 });
|
|
636
|
+
await writeFileAtomically(target, serialized);
|
|
637
|
+
return true;
|
|
638
|
+
}
|
|
639
|
+
async function readLocationDay(memoryDir, date) {
|
|
640
|
+
const target = locationDayFilePath(memoryDir, date);
|
|
641
|
+
await assertDayPathContained(memoryDir, target);
|
|
642
|
+
try {
|
|
643
|
+
return await readFile(target, "utf-8");
|
|
644
|
+
} catch (err) {
|
|
645
|
+
if (isErrnoCode(err, "ENOENT")) return null;
|
|
646
|
+
throw err;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
async function listLocationDayDates(memoryDir) {
|
|
650
|
+
const locationsDir = path.join(memoryDir, LOCATIONS_DIR_NAME);
|
|
651
|
+
await assertDayPathContained(memoryDir, locationsDir);
|
|
652
|
+
let entries;
|
|
653
|
+
try {
|
|
654
|
+
entries = await readdir(locationsDir);
|
|
655
|
+
} catch (err) {
|
|
656
|
+
if (isErrnoCode(err, "ENOENT")) return [];
|
|
657
|
+
throw err;
|
|
658
|
+
}
|
|
659
|
+
const dates = entries.filter((entry) => DAY_FILE_NAME_PATTERN.test(entry)).map((entry) => entry.slice(0, -3));
|
|
660
|
+
dates.sort((a, b) => a > b ? -1 : a < b ? 1 : 0);
|
|
661
|
+
return dates;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
// src/location/tagging.ts
|
|
665
|
+
async function loadDaySegmentIndex(memoryDir) {
|
|
666
|
+
const state = await loadLocationSyncState(memoryDir);
|
|
667
|
+
const index = /* @__PURE__ */ new Map();
|
|
668
|
+
for (const [sourceId, source] of Object.entries(state.sources)) {
|
|
669
|
+
for (const [date, payload] of Object.entries(source.days ?? {})) {
|
|
670
|
+
const entry = { sourceId, segments: payload.segments ?? [] };
|
|
671
|
+
const existing = index.get(date);
|
|
672
|
+
if (existing === void 0) index.set(date, [entry]);
|
|
673
|
+
else existing.push(entry);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
return index;
|
|
677
|
+
}
|
|
678
|
+
function locationTagPolicy(config) {
|
|
679
|
+
return {
|
|
680
|
+
minimumOverlapSeconds: config.minimumOverlapSeconds,
|
|
681
|
+
minimumConfidence: config.minimumConfidence,
|
|
682
|
+
retainCoordinates: config.retainCoordinates
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
function locationTaggingEnabled(config) {
|
|
686
|
+
return config.enabled && config.tagging.enabled;
|
|
687
|
+
}
|
|
688
|
+
async function tagPersistedMemories(storage, memoryIds, config) {
|
|
689
|
+
if (memoryIds.length === 0 || !config.location || !locationTaggingEnabled(config.location)) return;
|
|
690
|
+
try {
|
|
691
|
+
await enrichMemoriesWithLocation({
|
|
692
|
+
storage,
|
|
693
|
+
memoryIds,
|
|
694
|
+
memoryDir: config.memoryDir,
|
|
695
|
+
config: config.location
|
|
696
|
+
});
|
|
697
|
+
} catch (locationError) {
|
|
698
|
+
log.warn("[location] post-write tagging failed (non-fatal)", locationError);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
function segmentsForDays(index, days) {
|
|
702
|
+
const merged = /* @__PURE__ */ new Map();
|
|
703
|
+
for (const day of days) {
|
|
704
|
+
for (const entry of index.get(day) ?? []) {
|
|
705
|
+
const existing = merged.get(entry.sourceId);
|
|
706
|
+
if (existing === void 0) {
|
|
707
|
+
merged.set(entry.sourceId, { sourceId: entry.sourceId, segments: [...entry.segments] });
|
|
708
|
+
continue;
|
|
709
|
+
}
|
|
710
|
+
existing.segments.push(...entry.segments);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
return [...merged.values()];
|
|
714
|
+
}
|
|
715
|
+
function planForMemory(frontmatter, index, config) {
|
|
716
|
+
const policy = locationTagPolicy(config);
|
|
717
|
+
const result = memoryLocationWindow(frontmatter, (instant) => localDayKey(instant, config.timezone));
|
|
718
|
+
if (result.rejected === "span-too-long") return { outcome: "span-too-long" };
|
|
719
|
+
if (result.rejected === "untimed" || result.window === void 0 || result.days === void 0) {
|
|
720
|
+
return { outcome: "untimed" };
|
|
721
|
+
}
|
|
722
|
+
const sources = segmentsForDays(index, result.days);
|
|
723
|
+
return planLocationUpdate(frontmatter, matchDominantPlace(result.window, sources, policy), policy);
|
|
724
|
+
}
|
|
725
|
+
function emptyEnrichmentCounts() {
|
|
726
|
+
return {
|
|
727
|
+
tagged: 0,
|
|
728
|
+
updated: 0,
|
|
729
|
+
removed: 0,
|
|
730
|
+
unchanged: 0,
|
|
731
|
+
unmatched: 0,
|
|
732
|
+
manual: 0,
|
|
733
|
+
untimed: 0,
|
|
734
|
+
spanTooLong: 0,
|
|
735
|
+
failed: 0
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
function countOutcome(counts, outcome) {
|
|
739
|
+
if (outcome === "tagged") counts.tagged += 1;
|
|
740
|
+
else if (outcome === "updated") counts.updated += 1;
|
|
741
|
+
else if (outcome === "removed") counts.removed += 1;
|
|
742
|
+
else if (outcome === "unchanged") counts.unchanged += 1;
|
|
743
|
+
else if (outcome === "manual-metadata") counts.manual += 1;
|
|
744
|
+
else if (outcome === "unmatched") counts.unmatched += 1;
|
|
745
|
+
else if (outcome === "untimed") counts.untimed += 1;
|
|
746
|
+
else if (outcome === "span-too-long") counts.spanTooLong += 1;
|
|
747
|
+
}
|
|
748
|
+
async function enrichMemoriesWithLocation(options) {
|
|
749
|
+
if (!locationTaggingEnabled(options.config)) return emptyEnrichmentCounts();
|
|
750
|
+
const counts = emptyEnrichmentCounts();
|
|
751
|
+
const index = options.index ?? await loadDaySegmentIndex(options.memoryDir);
|
|
752
|
+
let memories = options.memories;
|
|
753
|
+
if (memories === void 0 && options.memoryIds !== void 0) {
|
|
754
|
+
memories = [];
|
|
755
|
+
for (const id of options.memoryIds) {
|
|
756
|
+
const memory = await options.storage.getMemoryById(id);
|
|
757
|
+
if (memory !== null) memories.push(memory);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
if (memories === void 0) return counts;
|
|
761
|
+
for (const memory of memories) {
|
|
762
|
+
try {
|
|
763
|
+
const plan = planForMemory(memory.frontmatter, index, options.config);
|
|
764
|
+
if (plan.patch === void 0 || options.dryRun === true) {
|
|
765
|
+
countOutcome(counts, plan.outcome);
|
|
766
|
+
continue;
|
|
767
|
+
}
|
|
768
|
+
await options.storage.writeMemoryFrontmatter(memory, plan.patch, { actor: "location-tagging" });
|
|
769
|
+
countOutcome(counts, plan.outcome);
|
|
770
|
+
} catch {
|
|
771
|
+
counts.failed += 1;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
return counts;
|
|
775
|
+
}
|
|
776
|
+
async function fillWearableConversationLocations(conversations, deps) {
|
|
777
|
+
if (!locationTaggingEnabled(deps.config) || conversations.length === 0) return;
|
|
778
|
+
let index;
|
|
779
|
+
try {
|
|
780
|
+
index = await loadDaySegmentIndex(deps.memoryDir);
|
|
781
|
+
} catch {
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
const policy = locationTagPolicy(deps.config);
|
|
785
|
+
for (const conversation of conversations) {
|
|
786
|
+
if (conversation.location !== void 0 && conversation.location.length > 0) continue;
|
|
787
|
+
try {
|
|
788
|
+
const startMs = Date.parse(conversation.startIso);
|
|
789
|
+
const endMs = conversation.endIso !== void 0 ? Date.parse(conversation.endIso) : Number.NaN;
|
|
790
|
+
const window = Number.isFinite(startMs) && Number.isFinite(endMs) && endMs > startMs ? { kind: "interval", startUtc: conversation.startIso, endUtc: conversation.endIso } : { kind: "instant", atUtc: conversation.startIso };
|
|
791
|
+
const anchor = window.kind === "interval" ? new Date(Date.parse(window.endUtc) - 1).toISOString() : window.atUtc;
|
|
792
|
+
const days = [.../* @__PURE__ */ new Set([localDayKey(anchor, deps.config.timezone), localDayKey(conversation.startIso, deps.config.timezone)])];
|
|
793
|
+
const outcome = matchDominantPlace(window, segmentsForDays(index, days), policy);
|
|
794
|
+
if (outcome.status === "matched") {
|
|
795
|
+
conversation.location = outcome.match.place.label;
|
|
796
|
+
}
|
|
797
|
+
} catch {
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
async function renderDayLocationContext(memoryDir, date, config) {
|
|
802
|
+
if (!locationTaggingEnabled(config)) return null;
|
|
803
|
+
const state = await loadLocationSyncState(memoryDir);
|
|
804
|
+
const segments = [];
|
|
805
|
+
for (const source of Object.values(state.sources)) {
|
|
806
|
+
for (const segment of source.days?.[date]?.segments ?? []) segments.push(segment);
|
|
807
|
+
}
|
|
808
|
+
if (segments.length === 0) return null;
|
|
809
|
+
const durations = placeDurations(segments).filter((duration) => ["home", "work", "poi"].includes(duration.place.kind ?? "poi")).sort((a, b) => a.totalMs !== b.totalMs ? b.totalMs - a.totalMs : a.place.id < b.place.id ? -1 : 1);
|
|
810
|
+
if (durations.length === 0) return null;
|
|
811
|
+
const lines = durations.map((duration) => {
|
|
812
|
+
const minutes = Math.round(duration.totalMs / 6e4);
|
|
813
|
+
const hours = Math.floor(minutes / 60);
|
|
814
|
+
const rendered = hours <= 0 ? `${minutes}m` : `${hours}h ${String(minutes % 60).padStart(2, "0")}m`;
|
|
815
|
+
return `- ${duration.place.label.replace(/\s+/g, " ").replace(/[`*_]/g, "").trim()}: ${rendered}`;
|
|
816
|
+
});
|
|
817
|
+
return `## Location context
|
|
818
|
+
|
|
819
|
+
${lines.join("\n")}`;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
export {
|
|
823
|
+
isValidLocationDate,
|
|
824
|
+
locationDayWindow,
|
|
825
|
+
localDayKey,
|
|
826
|
+
bucketObservationsByDay,
|
|
827
|
+
intervalOverlapMs,
|
|
828
|
+
observationSegments,
|
|
829
|
+
placeDurations,
|
|
830
|
+
dominantPlace,
|
|
831
|
+
LOCATION_MATCH_MAX_MEMORY_SPAN_MS,
|
|
832
|
+
LOCATION_TAG_PREFIX,
|
|
833
|
+
LOCATION_ATTRIBUTE_KEYS,
|
|
834
|
+
memoryLocationWindow,
|
|
835
|
+
matchDominantPlace,
|
|
836
|
+
locationTagSlug,
|
|
837
|
+
locationTagForPlace,
|
|
838
|
+
locationAttributesForMatch,
|
|
839
|
+
planLocationUpdate,
|
|
840
|
+
LOCATIONS_DIR_NAME,
|
|
841
|
+
LOCATION_DAY_KIND,
|
|
842
|
+
LOCATION_DAY_FORMAT_VERSION,
|
|
843
|
+
locationDayFilePath,
|
|
844
|
+
locationSyncStateFilePath,
|
|
845
|
+
emptyLocationSyncState,
|
|
846
|
+
loadLocationSyncState,
|
|
847
|
+
saveLocationSyncState,
|
|
848
|
+
updateLocationSourceDay,
|
|
849
|
+
hashLocationBody,
|
|
850
|
+
composeLocationDayBody,
|
|
851
|
+
composeLocationDayMeta,
|
|
852
|
+
serializeLocationDay,
|
|
853
|
+
parseLocationDaySummary,
|
|
854
|
+
writeLocationDay,
|
|
855
|
+
readLocationDay,
|
|
856
|
+
listLocationDayDates,
|
|
857
|
+
loadDaySegmentIndex,
|
|
858
|
+
locationTagPolicy,
|
|
859
|
+
locationTaggingEnabled,
|
|
860
|
+
tagPersistedMemories,
|
|
861
|
+
emptyEnrichmentCounts,
|
|
862
|
+
enrichMemoriesWithLocation,
|
|
863
|
+
fillWearableConversationLocations,
|
|
864
|
+
renderDayLocationContext
|
|
865
|
+
};
|
|
866
|
+
//# sourceMappingURL=chunk-TB2MJRI6.js.map
|