@remnic/core 9.66.0 → 9.66.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access-admin-ops-surface.d.ts +11 -11
- package/dist/access-admin-ops-surface.js +31 -31
- package/dist/access-audit.js +2 -2
- package/dist/access-authorization-probe.d.ts +11 -11
- package/dist/access-authorization-probe.js +32 -32
- package/dist/access-boundary.d.ts +11 -11
- package/dist/access-boundary.js +31 -31
- package/dist/access-cli.js +105 -101
- package/dist/access-cli.js.map +1 -1
- package/dist/access-coding-context-resolution.d.ts +1 -1
- package/dist/access-extraction-force-flush.d.ts +11 -11
- package/dist/access-extraction-force-flush.js +31 -31
- package/dist/access-health-types.d.ts +1 -1
- package/dist/access-http-lcm-compaction.d.ts +11 -11
- package/dist/access-http-lifecycle-flush.d.ts +11 -11
- package/dist/access-http-offline-stream.d.ts +11 -11
- package/dist/access-http-query.d.ts +2 -2
- package/dist/access-http-query.js +33 -33
- package/dist/access-http.d.ts +12 -12
- package/dist/access-http.js +48 -48
- package/dist/access-identity-continuity-surface.d.ts +9 -9
- package/dist/access-identity-continuity-surface.js +31 -31
- package/dist/access-lcm-surface.d.ts +11 -11
- package/dist/access-lcm-surface.js +31 -31
- package/dist/access-mcp.d.ts +11 -11
- package/dist/access-mcp.js +39 -39
- package/dist/access-memory-search-fanout.d.ts +2 -2
- package/dist/{access-namespace-preflight-CLWUoMyW.d.ts → access-namespace-preflight-50VIkPhB.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +3 -3
- package/dist/access-namespace-preflight.js +31 -31
- package/dist/access-observe-write-surface.d.ts +11 -11
- package/dist/access-observe-write-surface.js +31 -31
- package/dist/access-offline-manifest.d.ts +9 -9
- package/dist/access-operations-batch.js +34 -34
- package/dist/access-operations.d.ts +11 -11
- package/dist/access-operations.js +38 -38
- package/dist/access-recall-concurrency.d.ts +11 -11
- package/dist/access-recall-concurrency.js +31 -31
- package/dist/access-recall-response.d.ts +11 -11
- package/dist/access-recall-response.js +31 -31
- package/dist/access-recall-surface.d.ts +11 -11
- package/dist/access-recall-surface.js +31 -31
- package/dist/access-schema.js +3 -3
- package/dist/{access-service-CEUE1Isj.d.ts → access-service-Dz6I9AZ-.d.ts} +13 -13
- package/dist/access-service-helpers.d.ts +11 -11
- package/dist/access-service.d.ts +11 -11
- package/dist/access-service.js +31 -31
- package/dist/access-surface-catalog.d.ts +11 -11
- package/dist/access-surface-catalog.js +33 -33
- package/dist/access-wearables-meetings-surface.d.ts +3 -3
- package/dist/action-confidence.d.ts +1 -1
- package/dist/active-memory-bridge.d.ts +1 -1
- package/dist/active-recall.d.ts +1 -1
- package/dist/active-recall.js +4 -4
- package/dist/adapters/index.js +4 -4
- package/dist/adapters/registry.js +2 -2
- package/dist/ambient-provenance.d.ts +1 -1
- package/dist/artifact-search.d.ts +1 -1
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +9 -9
- package/dist/briefing-window.d.ts +2 -2
- package/dist/briefing.d.ts +2 -2
- package/dist/briefing.js +10 -10
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer-turn-helpers.d.ts +1 -1
- package/dist/buffer.d.ts +2 -2
- package/dist/buffer.js +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-D1HgugTA.d.ts → catalog-C2jA-gLm.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-behavior.js +2 -2
- package/dist/causal-chain.js +2 -2
- package/dist/causal-consolidation.d.ts +1 -1
- package/dist/causal-consolidation.js +13 -13
- package/dist/causal-retrieval.js +2 -2
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/causal-trajectory-graph.js +2 -2
- package/dist/causal-trajectory.js +1 -1
- package/dist/{chunk-EZSCW4EM.js → chunk-25OLNWYG.js} +2 -2
- package/dist/{chunk-2LBAFHOQ.js → chunk-2QSGJTDG.js} +10 -10
- package/dist/{chunk-7UTDHQZ5.js → chunk-2VZHB5US.js} +2 -2
- package/dist/{chunk-VQNRICAQ.js → chunk-36HJ36FK.js} +3 -3
- package/dist/{chunk-XKNHFDTT.js → chunk-3A2Z4OOS.js} +2 -2
- package/dist/{chunk-KODXCHXJ.js → chunk-46XR5FNZ.js} +39 -3
- package/dist/chunk-46XR5FNZ.js.map +1 -0
- package/dist/{chunk-56IV4J5W.js → chunk-47WWTCJY.js} +1384 -99
- package/dist/chunk-47WWTCJY.js.map +1 -0
- package/dist/{chunk-RDGKVH6T.js → chunk-4NKIGSJM.js} +2 -2
- package/dist/{chunk-EFQCDJZ2.js → chunk-4PG2CKI6.js} +2 -2
- package/dist/{chunk-HJXA6ZM7.js → chunk-6545JDIM.js} +2 -2
- package/dist/{chunk-J3OND5QT.js → chunk-65HXVEVG.js} +2 -2
- package/dist/{chunk-HNPE66LB.js → chunk-6BYJQ3L2.js} +8 -8
- package/dist/{chunk-ZW4VXELZ.js → chunk-6PUF7LUO.js} +2 -2
- package/dist/{chunk-TVVEYCNW.js → chunk-7K5Q6COX.js} +4 -4
- package/dist/{chunk-MN5NOOI7.js → chunk-AI5M4FVQ.js} +2 -2
- package/dist/{chunk-IHGMRDEE.js → chunk-B4B3QDV3.js} +235 -151
- package/dist/chunk-B4B3QDV3.js.map +1 -0
- package/dist/{chunk-YMOPYG3K.js → chunk-BIJAWZYW.js} +6 -6
- package/dist/{chunk-I5VB44ZK.js → chunk-BLHKR4GJ.js} +2 -2
- package/dist/chunk-BLUYQFRH.js +36 -0
- package/dist/chunk-BLUYQFRH.js.map +1 -0
- package/dist/{chunk-CEH2AFXG.js → chunk-C24UZSFW.js} +6 -6
- package/dist/{chunk-MJRGVXPQ.js → chunk-C3ZYZKDJ.js} +2 -2
- package/dist/{chunk-QCRJMU5V.js → chunk-CDLPF3PX.js} +2 -2
- package/dist/{chunk-23CVL7HS.js → chunk-CQ6IWZDI.js} +2 -2
- package/dist/{chunk-KWIGDKM2.js → chunk-D2YNNDML.js} +2 -2
- package/dist/{chunk-FTTJRVB7.js → chunk-D3DUA64S.js} +2 -2
- package/dist/{chunk-7XOG75AU.js → chunk-D6Q5EPOV.js} +2 -2
- package/dist/{chunk-GEJKYA7D.js → chunk-DSEHPUID.js} +6 -6
- package/dist/chunk-E4X2YX2F.js +22 -0
- package/dist/chunk-E4X2YX2F.js.map +1 -0
- package/dist/{chunk-PEBH5DCK.js → chunk-EH7BNIUN.js} +101 -19
- package/dist/chunk-EH7BNIUN.js.map +1 -0
- package/dist/{chunk-OAJMQKQR.js → chunk-EQRD4NMH.js} +2 -2
- package/dist/{chunk-H7VDIF2V.js → chunk-ER2UPUMG.js} +2 -2
- package/dist/{chunk-4FHRZD5T.js → chunk-F2JXJABQ.js} +2 -2
- package/dist/{chunk-FKKGCGYL.js → chunk-F4W5HTED.js} +2 -2
- package/dist/{chunk-DMEHOEC7.js → chunk-FFWONAAW.js} +3 -3
- package/dist/chunk-FYDW33ZB.js +13 -0
- package/dist/chunk-FYDW33ZB.js.map +1 -0
- package/dist/{chunk-TNGH4ZYI.js → chunk-GNWLTCKC.js} +2 -2
- package/dist/{chunk-CFVTRUR3.js → chunk-H6RSANGQ.js} +2 -2
- package/dist/chunk-HVAEXYPL.js +98 -0
- package/dist/chunk-HVAEXYPL.js.map +1 -0
- package/dist/{chunk-CTCGHNWN.js → chunk-J2R275FN.js} +4 -4
- package/dist/{chunk-IVIAHQBR.js → chunk-JJ6ZEFXC.js} +2 -2
- package/dist/{chunk-KXIXO76C.js → chunk-JMXHVJ2V.js} +14 -14
- package/dist/{chunk-7LCGFUMB.js → chunk-KQAFEZQX.js} +4 -4
- package/dist/{chunk-NACLNNFQ.js → chunk-KSZKQTZS.js} +2 -2
- package/dist/{chunk-NPIBN2VL.js → chunk-LK4TOYPU.js} +2 -2
- package/dist/{chunk-K66OY4EI.js → chunk-LSR5LQXN.js} +2 -2
- package/dist/chunk-MAG6M3B6.js +51 -0
- package/dist/chunk-MAG6M3B6.js.map +1 -0
- package/dist/{chunk-6CEGSTBD.js → chunk-NTFXBILO.js} +5 -5
- package/dist/{chunk-2PSX5BJU.js → chunk-NZPFCP5A.js} +2 -2
- package/dist/{chunk-FYWLSFFS.js → chunk-OERZXNSK.js} +2 -2
- package/dist/{chunk-ZJPM7GZ3.js → chunk-OIDICRH7.js} +2 -2
- package/dist/{chunk-LTBKKSCX.js → chunk-OLBZ2WGG.js} +2 -2
- package/dist/{chunk-PD66CVSD.js → chunk-OUKBMQ2O.js} +2 -2
- package/dist/{chunk-GPFZFCRN.js → chunk-PP7R754B.js} +1 -1
- package/dist/{chunk-GX6FTSYH.js → chunk-PRRUK2ZH.js} +2 -2
- package/dist/{chunk-MAH64N55.js → chunk-PW3GKWH3.js} +4 -4
- package/dist/chunk-Q3SHEAXR.js +80 -0
- package/dist/chunk-Q3SHEAXR.js.map +1 -0
- package/dist/{chunk-33MFRY25.js → chunk-R2Q6FTOX.js} +2 -2
- package/dist/{chunk-VCKWULAK.js → chunk-RCPKBW7K.js} +5 -5
- package/dist/{chunk-CN4VKV3S.js → chunk-RH3XLQG4.js} +2 -2
- package/dist/{chunk-2QSZNTDO.js → chunk-RKNJBZ55.js} +4 -4
- package/dist/{chunk-YXFCALVT.js → chunk-U4HZEW2B.js} +8 -8
- package/dist/{chunk-RZ3IZIJG.js → chunk-UHQE37NI.js} +2 -2
- package/dist/{chunk-Z3YEGSR4.js → chunk-UMZUKOJU.js} +4 -4
- package/dist/{chunk-72OIT7KS.js → chunk-UVYL5G7A.js} +3 -3
- package/dist/{chunk-4STAANV7.js → chunk-VKDBDJIX.js} +3 -3
- package/dist/{chunk-WKJFIMVN.js → chunk-VSMSYDIH.js} +2 -2
- package/dist/{chunk-GSKINLAK.js → chunk-W5IYHQA5.js} +3 -3
- package/dist/{chunk-FESUGFIL.js → chunk-WKWY7YF3.js} +2 -2
- package/dist/{chunk-UNUMFURP.js → chunk-X5PIDJ3L.js} +3 -3
- package/dist/{chunk-MINHJ55X.js → chunk-XXW32OL7.js} +1 -1
- package/dist/{chunk-MINHJ55X.js.map → chunk-XXW32OL7.js.map} +1 -1
- package/dist/{chunk-6RUHELWR.js → chunk-Y2YM4C75.js} +2 -2
- package/dist/{chunk-L4X4PJYK.js → chunk-YZ5VC2JJ.js} +2 -2
- package/dist/{chunk-VQ4AMTGZ.js → chunk-ZBIEX4XN.js} +1 -1
- package/dist/{chunk-O57GM3FR.js → chunk-ZMVW2HJJ.js} +2 -2
- package/dist/{chunk-6QDXA26G.js → chunk-ZXROBS53.js} +68 -68
- package/dist/{cli-BEkm2MEf.d.ts → cli-BOuEb4Ia.d.ts} +5 -5
- package/dist/cli.d.ts +13 -13
- package/dist/cli.js +76 -76
- package/dist/coding/export-okf-codegraph.d.ts +1 -1
- package/dist/coding/export-okf-codegraph.js +10 -10
- package/dist/coding/pre-action-gate.d.ts +1 -1
- package/dist/coding/pre-action-gate.js +2 -2
- package/dist/compounding/engine.d.ts +2 -2
- package/dist/compounding/engine.js +10 -10
- package/dist/compounding/preference-consolidator.d.ts +1 -1
- package/dist/compression-optimizer.d.ts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +4 -4
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +10 -10
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +10 -10
- package/dist/consolidation-provenance-check.d.ts +2 -2
- package/dist/consolidation-undo.d.ts +2 -2
- package/dist/contradiction/index.d.ts +3 -3
- package/dist/converge-config.d.ts +1 -1
- package/dist/convergence-refresh.d.ts +2 -2
- package/dist/convergence-refresh.js +12 -12
- package/dist/conversation-index/backend.d.ts +1 -1
- package/dist/conversation-index/chunker.d.ts +1 -1
- package/dist/conversation-index/faiss-adapter.d.ts +1 -1
- package/dist/conversation-index/indexer.d.ts +1 -1
- package/dist/conversation-index/search.d.ts +1 -1
- package/dist/corpus-watermark.d.ts +1 -1
- package/dist/corpus-watermark.js +12 -12
- package/dist/cross-lingual-recall.d.ts +1 -1
- package/dist/day-summary.d.ts +1 -1
- package/dist/delinearize.d.ts +1 -1
- package/dist/dependency-propagation-config.d.ts +1 -1
- package/dist/{dependency-propagation-delivery-BCpeo14F.d.ts → dependency-propagation-delivery-D4WMbOwA.d.ts} +1 -1
- package/dist/direct-answer-wiring.d.ts +1 -1
- package/dist/direct-answer.d.ts +1 -1
- package/dist/embedding-fallback.d.ts +1 -1
- package/dist/enrichment/index.d.ts +1 -1
- package/dist/entity-origin-fields.d.ts +1 -1
- package/dist/entity-retrieval.d.ts +2 -2
- package/dist/entity-retrieval.js +10 -10
- package/dist/entity-schema.d.ts +1 -1
- package/dist/episodic-context.d.ts +1 -1
- package/dist/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 +9 -9
- package/dist/external-wiki-access.d.ts +11 -11
- package/dist/external-wiki-access.js +32 -32
- package/dist/external-wiki-collection-registration.d.ts +1 -1
- package/dist/external-wiki-collection.d.ts +1 -1
- package/dist/external-wiki-mcp-tools.d.ts +11 -11
- package/dist/extraction-error-classification.d.ts +1 -1
- package/dist/extraction-faithfulness.d.ts +1 -1
- package/dist/extraction-judge-telemetry.d.ts +1 -1
- package/dist/extraction-judge-training.d.ts +1 -1
- package/dist/extraction-judge.d.ts +1 -1
- package/dist/extraction-liveness.d.ts +1 -1
- package/dist/extraction-normalization.d.ts +1 -1
- package/dist/extraction-prompt.d.ts +1 -1
- package/dist/extraction-source-grounding-rules.d.ts +1 -1
- package/dist/extraction-source-grounding.d.ts +1 -1
- package/dist/extraction-span-wire.d.ts +17 -0
- package/dist/extraction-span-wire.js +13 -0
- package/dist/extraction-span-wire.js.map +1 -0
- package/dist/extraction-span.d.ts +17 -0
- package/dist/extraction-span.js +8 -0
- package/dist/extraction.d.ts +1 -1
- package/dist/extraction.js +13 -13
- package/dist/fallback-llm.d.ts +1 -1
- package/dist/graph-dashboard-diff.d.ts +1 -1
- package/dist/graph-dashboard-key.d.ts +1 -1
- package/dist/graph-dashboard-parser.d.ts +1 -1
- package/dist/{graph-edge-decay-A4SDFMMS.js → graph-edge-decay-FXGELBFA.js} +4 -4
- package/dist/graph-edge-decay-FXGELBFA.js.map +1 -0
- package/dist/graph-edge-reinforcement.d.ts +1 -1
- package/dist/graph-path-reconstruction.d.ts +1 -1
- package/dist/graph-path-scoring.d.ts +1 -1
- package/dist/graph-snapshot.d.ts +1 -1
- package/dist/graph-snapshot.js +3 -3
- package/dist/graph.d.ts +1 -1
- package/dist/graph.js +3 -3
- package/dist/harmonic-retrieval.js +1 -1
- package/dist/importance.d.ts +1 -1
- package/dist/importers/index.d.ts +1 -1
- package/dist/in-flight-reads.d.ts +1 -1
- package/dist/{index-D_pyMUaP.d.ts → index-DuJnzwHv.d.ts} +2 -2
- package/dist/index.d.ts +341 -26
- package/dist/index.js +195 -114
- package/dist/intent.d.ts +1 -1
- package/dist/lcm/engine.d.ts +1 -1
- package/dist/lcm/engine.js +2 -2
- package/dist/lcm/index.d.ts +1 -1
- package/dist/lcm/index.js +7 -7
- package/dist/lcm/tools.d.ts +1 -1
- package/dist/lifecycle.d.ts +1 -1
- package/dist/live-connectors-runner.d.ts +1 -1
- package/dist/local-llm.d.ts +1 -1
- package/dist/local-model-endpoint.d.ts +1 -1
- package/dist/location/index.d.ts +3 -3
- package/dist/location/index.js +12 -12
- package/dist/maintenance/memory-governance.d.ts +1 -1
- package/dist/maintenance/memory-governance.js +10 -10
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +10 -10
- package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-projection.js +11 -11
- package/dist/{maintenance-DDUX9d6D.d.ts → maintenance-BBeaeYRR.d.ts} +3 -3
- package/dist/mcp-memory-inspector-app.d.ts +11 -11
- package/dist/memory-action-policy.d.ts +1 -1
- package/dist/memory-cache.d.ts +1 -1
- package/dist/memory-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 +11 -11
- package/dist/memory-subject.d.ts +11 -11
- package/dist/memory-worth-outcomes.d.ts +2 -2
- package/dist/models-json.d.ts +1 -1
- package/dist/namespaces/migrate.d.ts +3 -3
- package/dist/namespaces/migrate.js +11 -11
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/search.js +6 -6
- package/dist/namespaces/storage.d.ts +3 -3
- package/dist/namespaces/storage.js +10 -10
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/offline-sync-impression-drain.d.ts +1 -1
- package/dist/operator-doctor-corpus.d.ts +1 -1
- package/dist/operator-doctor-corpus.js +13 -13
- package/dist/operator-doctor-replica.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +3 -3
- package/dist/operator-toolkit.js +24 -24
- 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-3F4jihCo.d.ts → orchestrator-CaqnwNwM.d.ts} +8 -8
- package/dist/orchestrator.d.ts +9 -9
- package/dist/orchestrator.js +105 -101
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/{pipeline-CB1dj6Uh.d.ts → pipeline-CrxVjlJr.d.ts} +1 -1
- package/dist/policy-runtime.d.ts +1 -1
- package/dist/proactive-contention.d.ts +1 -1
- package/dist/provenance.d.ts +1 -1
- package/dist/{public-http-34-JIAGQ.d.ts → public-http-CmQRjQCD.d.ts} +1 -1
- package/dist/{qmd-edLLZXc5.d.ts → qmd-BZgbJm0g.d.ts} +1 -1
- package/dist/qmd-preflight.d.ts +2 -2
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd.d.ts +2 -2
- package/dist/qmd.js +4 -4
- package/dist/recall-concurrency-config.d.ts +1 -1
- package/dist/recall-deep-access.d.ts +30 -0
- package/dist/recall-deep-access.js +50 -0
- package/dist/recall-deep-access.js.map +1 -0
- package/dist/recall-deep-render.d.ts +11 -0
- package/dist/recall-deep-render.js +28 -0
- package/dist/recall-deep-render.js.map +1 -0
- package/dist/recall-deep.d.ts +37 -0
- package/dist/recall-deep.js +14 -0
- package/dist/recall-deep.js.map +1 -0
- 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.d.ts +70 -0
- package/dist/recall-navigate.js +15 -0
- package/dist/recall-navigate.js.map +1 -0
- package/dist/recall-planner-llm.d.ts +1 -1
- package/dist/recall-state-view-render.d.ts +18 -0
- package/dist/recall-state-view-render.js +22 -0
- package/dist/recall-state-view-render.js.map +1 -0
- package/dist/recall-state-view-widen.d.ts +13 -0
- package/dist/recall-state-view-widen.js +11 -0
- package/dist/recall-state-view-widen.js.map +1 -0
- package/dist/recall-state-view-wire.d.ts +13 -0
- package/dist/recall-state-view-wire.js +12 -0
- package/dist/recall-state-view-wire.js.map +1 -0
- package/dist/recall-state-view.d.ts +25 -0
- package/dist/recall-state-view.js +22 -0
- package/dist/recall-state-view.js.map +1 -0
- package/dist/recall-state.d.ts +1 -1
- package/dist/recall-tag-filter.d.ts +1 -1
- package/dist/recall-timings.d.ts +1 -1
- package/dist/recall-xray-cli.d.ts +1 -1
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.d.ts +1 -1
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.d.ts +1 -1
- package/dist/recall-xray.js +2 -2
- package/dist/reconcile/cursor.d.ts +1 -1
- package/dist/reconcile/manifest.d.ts +1 -1
- package/dist/reconcile/plan.d.ts +1 -1
- package/dist/replay/normalizers/chatgpt.d.ts +1 -1
- package/dist/replay/normalizers/claude.d.ts +1 -1
- package/dist/replay/normalizers/openclaw.d.ts +1 -1
- package/dist/replay/normalizers/shared.d.ts +1 -1
- package/dist/replay/runner.d.ts +1 -1
- package/dist/replay/types.d.ts +1 -1
- package/dist/replica-divergence.d.ts +1 -1
- package/dist/replica-peers-config.d.ts +1 -1
- package/dist/resolve-auth-token.d.ts +1 -1
- package/dist/resume-bundles.js +5 -5
- 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 +42 -42
- package/dist/{scope-profiles-BF2lu81V.d.ts → scope-profiles-DFaojvoP.d.ts} +1 -1
- package/dist/search/embed-helper.d.ts +1 -1
- package/dist/search/factory.d.ts +1 -1
- package/dist/search/factory.js +5 -5
- package/dist/search/index.d.ts +1 -1
- package/dist/search/index.js +9 -9
- 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-5OuWXBRt.d.ts → semantic-consolidation-BiX68wZA.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +11 -11
- package/dist/semantic-rule-promotion.js +10 -10
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +10 -10
- package/dist/{service-CrqEhLXD.d.ts → service-D5h2zZ0M.d.ts} +2 -2
- package/dist/session-observer-bands.d.ts +1 -1
- package/dist/session-observer-state.d.ts +1 -1
- package/dist/shared-context/manager.d.ts +1 -1
- package/dist/signal.d.ts +1 -1
- package/dist/source-agent-qualifier.d.ts +1 -1
- package/dist/source-agent-qualifier.js +12 -12
- package/dist/{storage-BQn-xnxm.d.ts → storage-CtsaojWD.d.ts} +1 -1
- package/dist/storage.d.ts +2 -2
- package/dist/storage.js +9 -9
- package/dist/subject-config.d.ts +1 -1
- package/dist/summarizer.d.ts +1 -1
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/support-passport/index.d.ts +14 -14
- package/dist/support-passport/index.js +34 -34
- 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/capsule-export.js +2 -2
- package/dist/transfer/capsule-import.js +2 -2
- package/dist/transfer/export-okf.d.ts +1 -1
- package/dist/transfer/export-okf.js +11 -11
- package/dist/transfer/types.d.ts +12 -12
- package/dist/trust-score-stage.d.ts +1 -1
- package/dist/trust-score.d.ts +1 -1
- package/dist/{types-BRpcNjHZ.d.ts → types-CIpfYz1I.d.ts} +16 -11
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/utility-runtime.d.ts +1 -1
- package/dist/verified-recall.js +10 -10
- package/dist/who-knows-cli.d.ts +11 -11
- package/dist/who-knows-cli.js +11 -11
- package/dist/who-knows.d.ts +11 -11
- package/dist/who-knows.js +10 -10
- package/dist/write-envelope.d.ts +1 -1
- package/package.json +2 -2
- package/src/activity/config.test.ts +1 -1
- package/src/activity/config.ts +48 -3
- package/src/activity/index.ts +5 -0
- package/src/activity/journal-vault-read.test.ts +153 -0
- package/src/activity/journal-vault-read.ts +214 -0
- package/src/activity/journal.test.ts +97 -0
- package/src/activity/journal.ts +113 -0
- package/src/activity/privacy.test.ts +53 -0
- package/src/activity/privacy.ts +80 -0
- package/src/activity/timeline/analysis-batch.test.ts +56 -0
- package/src/activity/timeline/analysis-batch.ts +45 -0
- package/src/activity/timeline/analysis.test.ts +413 -0
- package/src/activity/timeline/analysis.ts +362 -0
- package/src/activity/timeline/index.ts +7 -0
- package/src/activity/timeline/journal-recap-persist.test.ts +148 -0
- package/src/activity/timeline/journal-recap-persist.ts +37 -0
- package/src/activity/timeline/journal-recap.test.ts +113 -0
- package/src/activity/timeline/journal-recap.ts +130 -0
- package/src/activity/timeline/query.test.ts +198 -0
- package/src/activity/timeline/query.ts +313 -0
- package/src/activity/timeline/weekly-persist.test.ts +121 -0
- package/src/activity/timeline/weekly-persist.ts +103 -0
- package/src/activity/timeline/weekly.test.ts +215 -0
- package/src/activity/timeline/weekly.ts +234 -0
- package/src/activity/types.ts +14 -0
- package/src/activity/vault-path.test.ts +38 -0
- package/src/activity/vault-path.ts +59 -0
- package/src/activity/vault-publish.test.ts +268 -0
- package/src/activity/vault-publish.ts +180 -0
- package/src/config.test.ts +1 -1
- package/src/config.ts +2 -22
- package/src/dedup/merge-on-write-wire.test.ts +101 -0
- package/src/dedup/merge-on-write-wire.ts +34 -0
- package/src/dedup/merge-on-write.test.ts +91 -0
- package/src/dedup/merge-on-write.ts +75 -0
- package/src/dedup/novelty-gate.test.ts +143 -0
- package/src/dedup/novelty-gate.ts +163 -0
- package/src/extraction-span-wire.test.ts +20 -0
- package/src/extraction-span-wire.ts +17 -0
- package/src/extraction-span.test.ts +59 -0
- package/src/extraction-span.ts +39 -0
- package/src/index.ts +1 -0
- package/src/location/recall-exclusion.test.ts +1 -0
- package/src/orchestration/extraction-persist.ts +22 -23
- package/src/orchestration/generic-recall-paths.ts +11 -0
- package/src/orchestration/recall-entry.ts +8 -3
- package/src/recall-deep-access.test.ts +58 -0
- package/src/recall-deep-access.ts +71 -0
- package/src/recall-deep-render.test.ts +68 -0
- package/src/recall-deep-render.ts +32 -0
- package/src/recall-deep.test.ts +72 -0
- package/src/recall-deep.ts +113 -0
- package/src/recall-navigate.test.ts +84 -0
- package/src/recall-navigate.ts +100 -0
- package/src/recall-state-view-render.test.ts +94 -0
- package/src/recall-state-view-render.ts +24 -0
- package/src/recall-state-view-widen.test.ts +66 -0
- package/src/recall-state-view-widen.ts +49 -0
- package/src/recall-state-view-wire.test.ts +35 -0
- package/src/recall-state-view-wire.ts +18 -0
- package/src/recall-state-view.test.ts +131 -0
- package/src/recall-state-view.ts +138 -0
- package/src/shared-context/governance.test.ts +53 -0
- package/src/shared-context/governance.ts +86 -0
- package/src/shared-context/staleness.test.ts +36 -0
- package/src/shared-context/staleness.ts +38 -0
- package/src/shared-context/trajectories.test.ts +77 -0
- package/src/shared-context/trajectories.ts +49 -0
- package/src/types.ts +3 -10
- package/dist/chunk-56IV4J5W.js.map +0 -1
- package/dist/chunk-IHGMRDEE.js.map +0 -1
- package/dist/chunk-KODXCHXJ.js.map +0 -1
- package/dist/chunk-PEBH5DCK.js.map +0 -1
- /package/dist/{chunk-EZSCW4EM.js.map → chunk-25OLNWYG.js.map} +0 -0
- /package/dist/{chunk-2LBAFHOQ.js.map → chunk-2QSGJTDG.js.map} +0 -0
- /package/dist/{chunk-7UTDHQZ5.js.map → chunk-2VZHB5US.js.map} +0 -0
- /package/dist/{chunk-VQNRICAQ.js.map → chunk-36HJ36FK.js.map} +0 -0
- /package/dist/{chunk-XKNHFDTT.js.map → chunk-3A2Z4OOS.js.map} +0 -0
- /package/dist/{chunk-RDGKVH6T.js.map → chunk-4NKIGSJM.js.map} +0 -0
- /package/dist/{chunk-EFQCDJZ2.js.map → chunk-4PG2CKI6.js.map} +0 -0
- /package/dist/{chunk-HJXA6ZM7.js.map → chunk-6545JDIM.js.map} +0 -0
- /package/dist/{chunk-J3OND5QT.js.map → chunk-65HXVEVG.js.map} +0 -0
- /package/dist/{chunk-HNPE66LB.js.map → chunk-6BYJQ3L2.js.map} +0 -0
- /package/dist/{chunk-ZW4VXELZ.js.map → chunk-6PUF7LUO.js.map} +0 -0
- /package/dist/{chunk-TVVEYCNW.js.map → chunk-7K5Q6COX.js.map} +0 -0
- /package/dist/{chunk-MN5NOOI7.js.map → chunk-AI5M4FVQ.js.map} +0 -0
- /package/dist/{chunk-YMOPYG3K.js.map → chunk-BIJAWZYW.js.map} +0 -0
- /package/dist/{chunk-I5VB44ZK.js.map → chunk-BLHKR4GJ.js.map} +0 -0
- /package/dist/{chunk-CEH2AFXG.js.map → chunk-C24UZSFW.js.map} +0 -0
- /package/dist/{chunk-MJRGVXPQ.js.map → chunk-C3ZYZKDJ.js.map} +0 -0
- /package/dist/{chunk-QCRJMU5V.js.map → chunk-CDLPF3PX.js.map} +0 -0
- /package/dist/{chunk-23CVL7HS.js.map → chunk-CQ6IWZDI.js.map} +0 -0
- /package/dist/{chunk-KWIGDKM2.js.map → chunk-D2YNNDML.js.map} +0 -0
- /package/dist/{chunk-FTTJRVB7.js.map → chunk-D3DUA64S.js.map} +0 -0
- /package/dist/{chunk-7XOG75AU.js.map → chunk-D6Q5EPOV.js.map} +0 -0
- /package/dist/{chunk-GEJKYA7D.js.map → chunk-DSEHPUID.js.map} +0 -0
- /package/dist/{chunk-OAJMQKQR.js.map → chunk-EQRD4NMH.js.map} +0 -0
- /package/dist/{chunk-H7VDIF2V.js.map → chunk-ER2UPUMG.js.map} +0 -0
- /package/dist/{chunk-4FHRZD5T.js.map → chunk-F2JXJABQ.js.map} +0 -0
- /package/dist/{chunk-FKKGCGYL.js.map → chunk-F4W5HTED.js.map} +0 -0
- /package/dist/{chunk-DMEHOEC7.js.map → chunk-FFWONAAW.js.map} +0 -0
- /package/dist/{chunk-TNGH4ZYI.js.map → chunk-GNWLTCKC.js.map} +0 -0
- /package/dist/{chunk-CFVTRUR3.js.map → chunk-H6RSANGQ.js.map} +0 -0
- /package/dist/{chunk-CTCGHNWN.js.map → chunk-J2R275FN.js.map} +0 -0
- /package/dist/{chunk-IVIAHQBR.js.map → chunk-JJ6ZEFXC.js.map} +0 -0
- /package/dist/{chunk-KXIXO76C.js.map → chunk-JMXHVJ2V.js.map} +0 -0
- /package/dist/{chunk-7LCGFUMB.js.map → chunk-KQAFEZQX.js.map} +0 -0
- /package/dist/{chunk-NACLNNFQ.js.map → chunk-KSZKQTZS.js.map} +0 -0
- /package/dist/{chunk-NPIBN2VL.js.map → chunk-LK4TOYPU.js.map} +0 -0
- /package/dist/{chunk-K66OY4EI.js.map → chunk-LSR5LQXN.js.map} +0 -0
- /package/dist/{chunk-6CEGSTBD.js.map → chunk-NTFXBILO.js.map} +0 -0
- /package/dist/{chunk-2PSX5BJU.js.map → chunk-NZPFCP5A.js.map} +0 -0
- /package/dist/{chunk-FYWLSFFS.js.map → chunk-OERZXNSK.js.map} +0 -0
- /package/dist/{chunk-ZJPM7GZ3.js.map → chunk-OIDICRH7.js.map} +0 -0
- /package/dist/{chunk-LTBKKSCX.js.map → chunk-OLBZ2WGG.js.map} +0 -0
- /package/dist/{chunk-PD66CVSD.js.map → chunk-OUKBMQ2O.js.map} +0 -0
- /package/dist/{chunk-GPFZFCRN.js.map → chunk-PP7R754B.js.map} +0 -0
- /package/dist/{chunk-GX6FTSYH.js.map → chunk-PRRUK2ZH.js.map} +0 -0
- /package/dist/{chunk-MAH64N55.js.map → chunk-PW3GKWH3.js.map} +0 -0
- /package/dist/{chunk-33MFRY25.js.map → chunk-R2Q6FTOX.js.map} +0 -0
- /package/dist/{chunk-VCKWULAK.js.map → chunk-RCPKBW7K.js.map} +0 -0
- /package/dist/{chunk-CN4VKV3S.js.map → chunk-RH3XLQG4.js.map} +0 -0
- /package/dist/{chunk-2QSZNTDO.js.map → chunk-RKNJBZ55.js.map} +0 -0
- /package/dist/{chunk-YXFCALVT.js.map → chunk-U4HZEW2B.js.map} +0 -0
- /package/dist/{chunk-RZ3IZIJG.js.map → chunk-UHQE37NI.js.map} +0 -0
- /package/dist/{chunk-Z3YEGSR4.js.map → chunk-UMZUKOJU.js.map} +0 -0
- /package/dist/{chunk-72OIT7KS.js.map → chunk-UVYL5G7A.js.map} +0 -0
- /package/dist/{chunk-4STAANV7.js.map → chunk-VKDBDJIX.js.map} +0 -0
- /package/dist/{chunk-WKJFIMVN.js.map → chunk-VSMSYDIH.js.map} +0 -0
- /package/dist/{chunk-GSKINLAK.js.map → chunk-W5IYHQA5.js.map} +0 -0
- /package/dist/{chunk-FESUGFIL.js.map → chunk-WKWY7YF3.js.map} +0 -0
- /package/dist/{chunk-UNUMFURP.js.map → chunk-X5PIDJ3L.js.map} +0 -0
- /package/dist/{chunk-6RUHELWR.js.map → chunk-Y2YM4C75.js.map} +0 -0
- /package/dist/{chunk-L4X4PJYK.js.map → chunk-YZ5VC2JJ.js.map} +0 -0
- /package/dist/{chunk-VQ4AMTGZ.js.map → chunk-ZBIEX4XN.js.map} +0 -0
- /package/dist/{chunk-O57GM3FR.js.map → chunk-ZMVW2HJJ.js.map} +0 -0
- /package/dist/{chunk-6QDXA26G.js.map → chunk-ZXROBS53.js.map} +0 -0
- /package/dist/{graph-edge-decay-A4SDFMMS.js.map → extraction-span.js.map} +0 -0
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import {
|
|
14
14
|
ActivityStore,
|
|
15
15
|
MaintenanceScheduler
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-U4HZEW2B.js";
|
|
17
17
|
import {
|
|
18
18
|
runPeerProfileReasoner
|
|
19
19
|
} from "./chunk-I74SUMNI.js";
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
} from "./chunk-7HYPN2GC.js";
|
|
23
23
|
import {
|
|
24
24
|
LcmEngine
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-UMZUKOJU.js";
|
|
26
26
|
import {
|
|
27
27
|
chunkTranscriptEntries
|
|
28
28
|
} from "./chunk-TECVW3JP.js";
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
import {
|
|
33
33
|
CompoundingEngine,
|
|
34
34
|
defaultTierMigrationCycleBudget
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-EQRD4NMH.js";
|
|
36
36
|
import {
|
|
37
37
|
SharedContextManager
|
|
38
38
|
} from "./chunk-VI637ILW.js";
|
|
@@ -44,6 +44,9 @@ import {
|
|
|
44
44
|
applyUtilityRankingRuntimeDelta,
|
|
45
45
|
loadUtilityRuntimeValues
|
|
46
46
|
} from "./chunk-SEF4IOFE.js";
|
|
47
|
+
import {
|
|
48
|
+
TmtBuilder
|
|
49
|
+
} from "./chunk-ECZU5BJH.js";
|
|
47
50
|
import {
|
|
48
51
|
extractTopics
|
|
49
52
|
} from "./chunk-KVDUKH5E.js";
|
|
@@ -59,9 +62,6 @@ import {
|
|
|
59
62
|
import {
|
|
60
63
|
decideTierTransition
|
|
61
64
|
} from "./chunk-DD5JFCWM.js";
|
|
62
|
-
import {
|
|
63
|
-
TmtBuilder
|
|
64
|
-
} from "./chunk-ECZU5BJH.js";
|
|
65
65
|
import {
|
|
66
66
|
HourlySummarizer
|
|
67
67
|
} from "./chunk-IEZ6CGTW.js";
|
|
@@ -72,6 +72,14 @@ import {
|
|
|
72
72
|
import {
|
|
73
73
|
SessionObserverState
|
|
74
74
|
} from "./chunk-ODZKV2F7.js";
|
|
75
|
+
import {
|
|
76
|
+
applyRuntimeRetrievalPolicy
|
|
77
|
+
} from "./chunk-5IZL4DCV.js";
|
|
78
|
+
import {
|
|
79
|
+
RerankCache,
|
|
80
|
+
reorderByRankedKeys,
|
|
81
|
+
rerankLocalOrNoop
|
|
82
|
+
} from "./chunk-LUDXM7MD.js";
|
|
75
83
|
import {
|
|
76
84
|
buildResponseGuidanceRecallSection,
|
|
77
85
|
shouldRecallResponseGuidance
|
|
@@ -97,9 +105,6 @@ import {
|
|
|
97
105
|
recencyWindowFromPrompt,
|
|
98
106
|
resolvePromptTagPrefilterAsync
|
|
99
107
|
} from "./chunk-ZOKZIR5K.js";
|
|
100
|
-
import {
|
|
101
|
-
applyRuntimeRetrievalPolicy
|
|
102
|
-
} from "./chunk-5IZL4DCV.js";
|
|
103
108
|
import {
|
|
104
109
|
findUnresolvedEntityRefs
|
|
105
110
|
} from "./chunk-X7XN6YU4.js";
|
|
@@ -107,10 +112,8 @@ import {
|
|
|
107
112
|
RelevanceStore
|
|
108
113
|
} from "./chunk-KATEWTQJ.js";
|
|
109
114
|
import {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
rerankLocalOrNoop
|
|
113
|
-
} from "./chunk-LUDXM7MD.js";
|
|
115
|
+
applyRecallStateViews
|
|
116
|
+
} from "./chunk-FYDW33ZB.js";
|
|
114
117
|
import {
|
|
115
118
|
dedupeResultsByNamespace,
|
|
116
119
|
hasMemoryForResult,
|
|
@@ -138,6 +141,9 @@ import {
|
|
|
138
141
|
import {
|
|
139
142
|
runLiveConnectorsOnce
|
|
140
143
|
} from "./chunk-HTIIXNJQ.js";
|
|
144
|
+
import {
|
|
145
|
+
classifyMemoryKind
|
|
146
|
+
} from "./chunk-YAZNBMNF.js";
|
|
141
147
|
import {
|
|
142
148
|
scoreEvidencePathDetail
|
|
143
149
|
} from "./chunk-XXSOVESA.js";
|
|
@@ -148,16 +154,13 @@ import {
|
|
|
148
154
|
normalizedHarmonicEntityIdentity,
|
|
149
155
|
persistHarmonicRecords
|
|
150
156
|
} from "./chunk-MEW53VQJ.js";
|
|
151
|
-
import {
|
|
152
|
-
classifyMemoryKind
|
|
153
|
-
} from "./chunk-YAZNBMNF.js";
|
|
154
157
|
import {
|
|
155
158
|
buildFocusedListRecallSection,
|
|
156
159
|
shouldRecallFocusedListEvidence
|
|
157
160
|
} from "./chunk-OH7QLI6W.js";
|
|
158
161
|
import {
|
|
159
162
|
ExtractionEngine
|
|
160
|
-
} from "./chunk-
|
|
163
|
+
} from "./chunk-3A2Z4OOS.js";
|
|
161
164
|
import {
|
|
162
165
|
parseMemoryActionEligibilityContext
|
|
163
166
|
} from "./chunk-AJTG3CP7.js";
|
|
@@ -191,7 +194,7 @@ import {
|
|
|
191
194
|
buildEntityRecallSection,
|
|
192
195
|
entityRecentTranscriptLookbackHours,
|
|
193
196
|
readRecentEntityTranscriptEntries
|
|
194
|
-
} from "./chunk-
|
|
197
|
+
} from "./chunk-25OLNWYG.js";
|
|
195
198
|
import {
|
|
196
199
|
planEpisodeWindowsWithFallback
|
|
197
200
|
} from "./chunk-T3GIETKV.js";
|
|
@@ -206,31 +209,31 @@ import {
|
|
|
206
209
|
} from "./chunk-LVXBC6YB.js";
|
|
207
210
|
import {
|
|
208
211
|
refreshConvergedNamespaces
|
|
209
|
-
} from "./chunk-
|
|
212
|
+
} from "./chunk-R2Q6FTOX.js";
|
|
210
213
|
import {
|
|
211
214
|
builtInConnectorPackageSpecifier,
|
|
212
215
|
ensureBuiltInWearableConnectors,
|
|
213
216
|
getWearableConnector,
|
|
214
217
|
listWearableConnectors,
|
|
215
218
|
screenCandidateFact
|
|
216
|
-
} from "./chunk-
|
|
217
|
-
import {
|
|
218
|
-
RoutingRulesStore
|
|
219
|
-
} from "./chunk-TBUEE7XF.js";
|
|
219
|
+
} from "./chunk-ZXROBS53.js";
|
|
220
220
|
import {
|
|
221
221
|
normalizeReplaySessionKey
|
|
222
222
|
} from "./chunk-AJVLDJU6.js";
|
|
223
|
+
import {
|
|
224
|
+
RoutingRulesStore
|
|
225
|
+
} from "./chunk-TBUEE7XF.js";
|
|
223
226
|
import {
|
|
224
227
|
compareVerifiedEpisodeResults,
|
|
225
228
|
searchVerifiedEpisodes
|
|
226
|
-
} from "./chunk-
|
|
229
|
+
} from "./chunk-OIDICRH7.js";
|
|
227
230
|
import {
|
|
228
231
|
ThreadingManager
|
|
229
232
|
} from "./chunk-OJP3N7UK.js";
|
|
230
233
|
import {
|
|
231
234
|
compareVerifiedSemanticRuleResults,
|
|
232
235
|
searchVerifiedSemanticRules
|
|
233
|
-
} from "./chunk-
|
|
236
|
+
} from "./chunk-BLHKR4GJ.js";
|
|
234
237
|
import {
|
|
235
238
|
searchWorkProductLedgerEntries
|
|
236
239
|
} from "./chunk-NRLELHAY.js";
|
|
@@ -243,17 +246,17 @@ import {
|
|
|
243
246
|
import {
|
|
244
247
|
runNamespaceMaintenanceFanout,
|
|
245
248
|
summarizeNamespaceMaintenanceHealth
|
|
246
|
-
} from "./chunk-
|
|
249
|
+
} from "./chunk-2QSGJTDG.js";
|
|
247
250
|
import {
|
|
248
251
|
planNamespaceMaintenance
|
|
249
|
-
} from "./chunk-
|
|
252
|
+
} from "./chunk-UVYL5G7A.js";
|
|
253
|
+
import {
|
|
254
|
+
searchHarmonicRetrieval
|
|
255
|
+
} from "./chunk-ZBIEX4XN.js";
|
|
250
256
|
import {
|
|
251
257
|
isAboveImportanceThreshold,
|
|
252
258
|
scoreImportance
|
|
253
259
|
} from "./chunk-UOBPK2OS.js";
|
|
254
|
-
import {
|
|
255
|
-
searchHarmonicRetrieval
|
|
256
|
-
} from "./chunk-VQ4AMTGZ.js";
|
|
257
260
|
import {
|
|
258
261
|
EXTRACTION_JUDGE_VERDICT_CATEGORY,
|
|
259
262
|
recordJudgeVerdict
|
|
@@ -281,7 +284,7 @@ import {
|
|
|
281
284
|
materializeAfterSemanticConsolidation,
|
|
282
285
|
parseConsolidationResponse,
|
|
283
286
|
parseOperatorAwareConsolidationResponse
|
|
284
|
-
} from "./chunk-
|
|
287
|
+
} from "./chunk-RH3XLQG4.js";
|
|
285
288
|
import {
|
|
286
289
|
semanticChunkContent
|
|
287
290
|
} from "./chunk-2GBFKHBZ.js";
|
|
@@ -290,7 +293,7 @@ import {
|
|
|
290
293
|
} from "./chunk-6TBIWIAG.js";
|
|
291
294
|
import {
|
|
292
295
|
SmartBuffer
|
|
293
|
-
} from "./chunk-
|
|
296
|
+
} from "./chunk-KSZKQTZS.js";
|
|
294
297
|
import {
|
|
295
298
|
buildRecallQueryPolicy
|
|
296
299
|
} from "./chunk-C6WMSXCJ.js";
|
|
@@ -311,8 +314,10 @@ import {
|
|
|
311
314
|
evaluateMemoryActionPolicy
|
|
312
315
|
} from "./chunk-MI2OTWV5.js";
|
|
313
316
|
import {
|
|
314
|
-
|
|
315
|
-
|
|
317
|
+
applyNoveltyGate,
|
|
318
|
+
detectMeetings,
|
|
319
|
+
embeddingsFromCosineHits
|
|
320
|
+
} from "./chunk-EH7BNIUN.js";
|
|
316
321
|
import {
|
|
317
322
|
compileCorrectionRule,
|
|
318
323
|
correctionsFilePath,
|
|
@@ -325,14 +330,14 @@ import {
|
|
|
325
330
|
} from "./chunk-QW27DOHG.js";
|
|
326
331
|
import {
|
|
327
332
|
MeetingsInputError
|
|
328
|
-
} from "./chunk-
|
|
333
|
+
} from "./chunk-JMXHVJ2V.js";
|
|
329
334
|
import {
|
|
330
335
|
WearablesInputError,
|
|
331
336
|
describeErrorForOperator
|
|
332
337
|
} from "./chunk-V7IZKJI3.js";
|
|
333
338
|
import {
|
|
334
339
|
NamespaceCatalog
|
|
335
|
-
} from "./chunk-
|
|
340
|
+
} from "./chunk-PRRUK2ZH.js";
|
|
336
341
|
import {
|
|
337
342
|
recordDreamsPhaseRun
|
|
338
343
|
} from "./chunk-EQWEIIKQ.js";
|
|
@@ -348,14 +353,20 @@ import {
|
|
|
348
353
|
detectPassiveCorrections,
|
|
349
354
|
filterRecallCandidates,
|
|
350
355
|
isGenericRecallExcludedPath,
|
|
351
|
-
isTopLevelArchivePath
|
|
352
|
-
|
|
356
|
+
isTopLevelArchivePath,
|
|
357
|
+
journalPath,
|
|
358
|
+
writeJournalFile
|
|
359
|
+
} from "./chunk-B4B3QDV3.js";
|
|
353
360
|
import {
|
|
354
361
|
importCapsule
|
|
355
|
-
} from "./chunk-
|
|
362
|
+
} from "./chunk-J2R275FN.js";
|
|
356
363
|
import {
|
|
357
364
|
isCodingGraphInstalled
|
|
358
365
|
} from "./chunk-VQ7B2Q6M.js";
|
|
366
|
+
import {
|
|
367
|
+
listTrustZoneRecords,
|
|
368
|
+
searchTrustZoneRecords
|
|
369
|
+
} from "./chunk-5QZR2RA3.js";
|
|
359
370
|
import {
|
|
360
371
|
applyTrustScoreStage,
|
|
361
372
|
buildTrustSignalsForRerank,
|
|
@@ -363,10 +374,6 @@ import {
|
|
|
363
374
|
trustResultFor,
|
|
364
375
|
trustResultKey
|
|
365
376
|
} from "./chunk-GNVZQ5JN.js";
|
|
366
|
-
import {
|
|
367
|
-
listTrustZoneRecords,
|
|
368
|
-
searchTrustZoneRecords
|
|
369
|
-
} from "./chunk-5QZR2RA3.js";
|
|
370
377
|
import {
|
|
371
378
|
LastRecallStore,
|
|
372
379
|
RecallHandleHistoryStore,
|
|
@@ -375,7 +382,7 @@ import {
|
|
|
375
382
|
} from "./chunk-ZVZHG7AI.js";
|
|
376
383
|
import {
|
|
377
384
|
buildXraySnapshot
|
|
378
|
-
} from "./chunk-
|
|
385
|
+
} from "./chunk-LK4TOYPU.js";
|
|
379
386
|
import {
|
|
380
387
|
objectiveStateStoreOverrideForNamespace,
|
|
381
388
|
searchObjectiveStateSnapshots
|
|
@@ -403,10 +410,10 @@ import {
|
|
|
403
410
|
} from "./chunk-7ZNJN5WZ.js";
|
|
404
411
|
import {
|
|
405
412
|
NamespaceStorageRouter
|
|
406
|
-
} from "./chunk-
|
|
413
|
+
} from "./chunk-6545JDIM.js";
|
|
407
414
|
import {
|
|
408
415
|
GraphIndex
|
|
409
|
-
} from "./chunk-
|
|
416
|
+
} from "./chunk-BIJAWZYW.js";
|
|
410
417
|
import {
|
|
411
418
|
BulkImportBatchPartialFailureError,
|
|
412
419
|
COMPACTION_SIGNAL_MAX_AGE_MS,
|
|
@@ -447,7 +454,7 @@ import {
|
|
|
447
454
|
throwIfRecallAborted,
|
|
448
455
|
tokenizeRecallQuery,
|
|
449
456
|
utcDateKeysForLocalDay
|
|
450
|
-
} from "./chunk-
|
|
457
|
+
} from "./chunk-4NKIGSJM.js";
|
|
451
458
|
import {
|
|
452
459
|
inferIntentFromText,
|
|
453
460
|
intentCompatibilityScore,
|
|
@@ -460,7 +467,7 @@ import {
|
|
|
460
467
|
} from "./chunk-TBBDFYXW.js";
|
|
461
468
|
import {
|
|
462
469
|
buildChainFollowupGenerator
|
|
463
|
-
} from "./chunk-
|
|
470
|
+
} from "./chunk-WKWY7YF3.js";
|
|
464
471
|
import {
|
|
465
472
|
QmdResultResolver,
|
|
466
473
|
StorageManager,
|
|
@@ -479,7 +486,7 @@ import {
|
|
|
479
486
|
reconstructFusionInputs,
|
|
480
487
|
selfDeps,
|
|
481
488
|
serializeFusionDay
|
|
482
|
-
} from "./chunk-
|
|
489
|
+
} from "./chunk-DSEHPUID.js";
|
|
483
490
|
import {
|
|
484
491
|
bodyIsEscaped,
|
|
485
492
|
decodeTranscriptBody,
|
|
@@ -496,12 +503,12 @@ import {
|
|
|
496
503
|
import {
|
|
497
504
|
NamespaceSearchRouter,
|
|
498
505
|
namespaceCollectionName
|
|
499
|
-
} from "./chunk-
|
|
506
|
+
} from "./chunk-OERZXNSK.js";
|
|
500
507
|
import {
|
|
501
508
|
createConversationIndexRuntime,
|
|
502
509
|
createSearchBackend,
|
|
503
510
|
isSearchBackendEnabled
|
|
504
|
-
} from "./chunk-
|
|
511
|
+
} from "./chunk-6BYJQ3L2.js";
|
|
505
512
|
import {
|
|
506
513
|
NoopSearchBackend
|
|
507
514
|
} from "./chunk-CYEPCZN5.js";
|
|
@@ -515,7 +522,7 @@ import {
|
|
|
515
522
|
} from "./chunk-S2V7RUCL.js";
|
|
516
523
|
import {
|
|
517
524
|
confidenceTier
|
|
518
|
-
} from "./chunk-
|
|
525
|
+
} from "./chunk-XXW32OL7.js";
|
|
519
526
|
import {
|
|
520
527
|
lintWorkspaceFiles,
|
|
521
528
|
rotateMarkdownFileToArchive
|
|
@@ -577,6 +584,9 @@ import {
|
|
|
577
584
|
fallbackLlmRuntimeContextFromConfig,
|
|
578
585
|
gatewayTaskChainOptions
|
|
579
586
|
} from "./chunk-JALOAKSZ.js";
|
|
587
|
+
import {
|
|
588
|
+
extractJsonCandidates
|
|
589
|
+
} from "./chunk-RGMVMVMF.js";
|
|
580
590
|
import {
|
|
581
591
|
estimateTokenCount
|
|
582
592
|
} from "./chunk-TOTT6S2V.js";
|
|
@@ -588,12 +598,14 @@ import {
|
|
|
588
598
|
} from "./chunk-QDW3E4RD.js";
|
|
589
599
|
import {
|
|
590
600
|
activityDayWindow,
|
|
601
|
+
assertValidTimezone,
|
|
602
|
+
hashActivityBody,
|
|
591
603
|
isValidActivityDate,
|
|
592
604
|
timezoneOffsetIso
|
|
593
605
|
} from "./chunk-M6L7HI7R.js";
|
|
594
606
|
import {
|
|
595
607
|
searchCausalTrajectories
|
|
596
|
-
} from "./chunk-
|
|
608
|
+
} from "./chunk-PP7R754B.js";
|
|
597
609
|
import {
|
|
598
610
|
evaluateSubjectGuard,
|
|
599
611
|
isSharedPromotionTarget,
|
|
@@ -606,7 +618,9 @@ import {
|
|
|
606
618
|
normalizeRecallTokenSet
|
|
607
619
|
} from "./chunk-YCVB7X56.js";
|
|
608
620
|
import {
|
|
609
|
-
coerceBool
|
|
621
|
+
coerceBool,
|
|
622
|
+
coerceBooleanLike,
|
|
623
|
+
coerceNumber
|
|
610
624
|
} from "./chunk-PQVCH2AE.js";
|
|
611
625
|
import {
|
|
612
626
|
graphemeUnits,
|
|
@@ -673,6 +687,9 @@ import {
|
|
|
673
687
|
assertIsDirectoryNotSymlink,
|
|
674
688
|
assertRealpathInsideRoot
|
|
675
689
|
} from "./chunk-GCGJW34D.js";
|
|
690
|
+
import {
|
|
691
|
+
parseFlexibleIsoTimestamp
|
|
692
|
+
} from "./chunk-P7FMDTKL.js";
|
|
676
693
|
import {
|
|
677
694
|
canReadNamespace,
|
|
678
695
|
defaultNamespaceForPrincipal,
|
|
@@ -2306,7 +2323,7 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
|
|
|
2306
2323
|
namespaces,
|
|
2307
2324
|
{
|
|
2308
2325
|
readNamespaceMemories: async (ns) => (await this.getStorage(ns)).readAllMemories(),
|
|
2309
|
-
readMemoryFrontmatter: async (
|
|
2326
|
+
readMemoryFrontmatter: async (path38, preferredNamespace) => {
|
|
2310
2327
|
if (!fallbackReader) {
|
|
2311
2328
|
for (const ns of namespaces) {
|
|
2312
2329
|
try {
|
|
@@ -2318,7 +2335,7 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
|
|
|
2318
2335
|
}
|
|
2319
2336
|
if (!fallbackReader) return null;
|
|
2320
2337
|
const memory = await this.readQmdResultMemory(
|
|
2321
|
-
|
|
2338
|
+
path38,
|
|
2322
2339
|
fallbackReader,
|
|
2323
2340
|
namespaces,
|
|
2324
2341
|
preferredNamespace
|
|
@@ -6072,8 +6089,23 @@ var ExtractionPersistCoordinator = class {
|
|
|
6072
6089
|
);
|
|
6073
6090
|
const requireSpansPendingStatus = this.deps.config.provenance?.requireSpans === true && fact.requireSpansPending === true ? "pending_review" : void 0;
|
|
6074
6091
|
const faithfulnessEnforceStatus = faithfulnessGateStatus ?? requireSpansPendingStatus ?? injectionScreenStatus;
|
|
6092
|
+
const novelty = await applyNoveltyGate({
|
|
6093
|
+
enabled: this.deps.config["noveltyGateEnabled"] === true,
|
|
6094
|
+
addThreshold: this.deps.config.noveltyAddThreshold,
|
|
6095
|
+
noopThreshold: this.deps.config.noveltyNoopThreshold,
|
|
6096
|
+
lookup: async () => embeddingsFromCosineHits(
|
|
6097
|
+
await this.deps.semanticDedupLookup(
|
|
6098
|
+
fact.content,
|
|
6099
|
+
this.deps.config.semanticDedupCandidates,
|
|
6100
|
+
targetStorage
|
|
6101
|
+
),
|
|
6102
|
+
// Same connector scoping as decideSemanticDedup below: a
|
|
6103
|
+
// cross-connector neighbor must not noop this candidate.
|
|
6104
|
+
{ candidateConnector: sourceContext?.sourceConnector }
|
|
6105
|
+
)
|
|
6106
|
+
});
|
|
6075
6107
|
let pendingSemanticSkip = null;
|
|
6076
|
-
if (resolvePipelineProcessingCapabilities(this.deps.config).semanticDedup && injectionScreenStatus !== "pending_review") {
|
|
6108
|
+
if (novelty.decision !== "add" && resolvePipelineProcessingCapabilities(this.deps.config).semanticDedup && injectionScreenStatus !== "pending_review") {
|
|
6077
6109
|
let semanticDecision;
|
|
6078
6110
|
if (batchBackendUnavailable) {
|
|
6079
6111
|
semanticDecision = { action: "keep", reason: "backend_unavailable" };
|
|
@@ -6149,11 +6181,11 @@ var ExtractionPersistCoordinator = class {
|
|
|
6149
6181
|
}
|
|
6150
6182
|
}
|
|
6151
6183
|
const isCorrection = writeCategory === "correction";
|
|
6152
|
-
if (pendingSemanticSkip && !contradictionDetected && !isCorrection && faithfulnessEnforceStatus !== "pending_review") {
|
|
6184
|
+
if ((pendingSemanticSkip || novelty.decision === "noop") && !contradictionDetected && !isCorrection && faithfulnessEnforceStatus !== "pending_review") {
|
|
6153
6185
|
log.debug(
|
|
6154
|
-
`dedup: skipping semantic near-duplicate fact "${fact.content.slice(0, 60).replace(/\s+/g, " ")}\u2026" score=${pendingSemanticSkip
|
|
6186
|
+
`dedup: skipping ${pendingSemanticSkip ? "semantic near-duplicate" : "novelty-noop"} fact "${fact.content.slice(0, 60).replace(/\s+/g, " ")}\u2026" score=${(pendingSemanticSkip?.topScore ?? novelty.score).toFixed(
|
|
6155
6187
|
3
|
|
6156
|
-
)} neighbor=${pendingSemanticSkip.
|
|
6188
|
+
)} neighbor=${pendingSemanticSkip?.topId ?? novelty.neighborId}`
|
|
6157
6189
|
);
|
|
6158
6190
|
dedupedCount++;
|
|
6159
6191
|
continue;
|
|
@@ -17058,8 +17090,8 @@ function fuseMeeting(input, config, options = {}) {
|
|
|
17058
17090
|
}
|
|
17059
17091
|
const clipped = [];
|
|
17060
17092
|
for (const conv of input.conversations) {
|
|
17061
|
-
const
|
|
17062
|
-
if (
|
|
17093
|
+
const clip2 = clipConversation(conv, windowStartMs, windowEndMs);
|
|
17094
|
+
if (clip2 !== null) clipped.push(clip2);
|
|
17063
17095
|
}
|
|
17064
17096
|
const fused = clipped.length > 0 ? fuseCluster(clipped, {
|
|
17065
17097
|
...options.sourceTrust !== void 0 ? { sourceTrust: options.sourceTrust } : {},
|
|
@@ -18959,14 +18991,14 @@ var NamespaceReadFanoutCoordinator = class {
|
|
|
18959
18991
|
for (const { memory, namespace } of memories) {
|
|
18960
18992
|
const status = memory.frontmatter.status ?? "active";
|
|
18961
18993
|
if (!options?.allowArchived && status !== "active") continue;
|
|
18962
|
-
const
|
|
18994
|
+
const haystack2 = [
|
|
18963
18995
|
memory.content,
|
|
18964
18996
|
memory.frontmatter.category,
|
|
18965
18997
|
...memory.frontmatter.tags ?? []
|
|
18966
18998
|
].join(" ").toLowerCase();
|
|
18967
18999
|
let hits = 0;
|
|
18968
19000
|
for (const token of tokens) {
|
|
18969
|
-
if (
|
|
19001
|
+
if (haystack2.includes(token)) hits += 1;
|
|
18970
19002
|
}
|
|
18971
19003
|
const score = tokens.length > 0 ? hits / tokens.length : 0.01;
|
|
18972
19004
|
if (tokens.length > 0 && hits === 0) continue;
|
|
@@ -19182,7 +19214,11 @@ var RecallEntryCoordinator = class {
|
|
|
19182
19214
|
publishRecallResults(options) {
|
|
19183
19215
|
const sectionId = "memories";
|
|
19184
19216
|
const trustByPath = options.trustByPath ?? null;
|
|
19185
|
-
const injectable =
|
|
19217
|
+
const injectable = applyRecallStateViews(
|
|
19218
|
+
trustByPath ? options.results.filter((r) => !trustResultFor(trustByPath, r)?.quarantined) : options.results,
|
|
19219
|
+
options.retrievalQuery,
|
|
19220
|
+
this.deps.config
|
|
19221
|
+
);
|
|
19186
19222
|
if (injectable.length === 0) return;
|
|
19187
19223
|
const formatted = this.deps.recallResultFormatter.formatQmdResultEntries(
|
|
19188
19224
|
options.title,
|
|
@@ -22301,9 +22337,9 @@ function readStructuralSymbol(entry) {
|
|
|
22301
22337
|
const rec = entry;
|
|
22302
22338
|
const symbol = typeof rec.symbol === "string" ? rec.symbol.trim() : "";
|
|
22303
22339
|
if (!symbol) return null;
|
|
22304
|
-
const
|
|
22340
|
+
const path38 = typeof rec.path === "string" && rec.path.length > 0 ? rec.path : void 0;
|
|
22305
22341
|
const kind = typeof rec.kind === "string" && rec.kind.length > 0 ? rec.kind : void 0;
|
|
22306
|
-
const item =
|
|
22342
|
+
const item = path38 !== void 0 && kind !== void 0 ? { symbol, path: path38, kind } : path38 !== void 0 ? { symbol, path: path38 } : kind !== void 0 ? { symbol, kind } : { symbol };
|
|
22307
22343
|
return item;
|
|
22308
22344
|
}
|
|
22309
22345
|
function classifySpawnError(err) {
|
|
@@ -26299,6 +26335,1000 @@ function applyTimelineCorrections(cards, corrections) {
|
|
|
26299
26335
|
});
|
|
26300
26336
|
}
|
|
26301
26337
|
|
|
26338
|
+
// src/activity/timeline/query.ts
|
|
26339
|
+
var RANGE_FORMATS = ["cards", "compact"];
|
|
26340
|
+
var MS_PER_DAY = 864e5;
|
|
26341
|
+
var DEFAULT_MAX_RANGE_DAYS = 31;
|
|
26342
|
+
var DEFAULT_SEARCH_LIMIT = 10;
|
|
26343
|
+
var MIN_SEARCH_LIMIT = 1;
|
|
26344
|
+
var MAX_SEARCH_LIMIT = 50;
|
|
26345
|
+
var USAGE = `Usage: timeline <command> [options]
|
|
26346
|
+
|
|
26347
|
+
Commands:
|
|
26348
|
+
range --from <ISO> --to <ISO> [--format cards|compact] [--categories id,id] [--include-distractions]
|
|
26349
|
+
search --query <text> [--from <ISO>] [--to <ISO>] [--limit N]
|
|
26350
|
+
`;
|
|
26351
|
+
var VALUE_FLAGS = {
|
|
26352
|
+
"--from": true,
|
|
26353
|
+
"--to": true,
|
|
26354
|
+
"--format": true,
|
|
26355
|
+
"--categories": true,
|
|
26356
|
+
"--query": true,
|
|
26357
|
+
"--limit": true
|
|
26358
|
+
};
|
|
26359
|
+
var BOOLEAN_FLAGS = { "--include-distractions": true };
|
|
26360
|
+
function parseInstant(value, label) {
|
|
26361
|
+
const ms = parseFlexibleIsoTimestamp(value);
|
|
26362
|
+
if (ms === null) {
|
|
26363
|
+
throw new TypeError(`${label} must be an ISO date or datetime`);
|
|
26364
|
+
}
|
|
26365
|
+
return ms;
|
|
26366
|
+
}
|
|
26367
|
+
function assertRange(fromMs, toMs, maxRangeDays) {
|
|
26368
|
+
if (fromMs > toMs) {
|
|
26369
|
+
throw new RangeError("reversed range: from must be <= to");
|
|
26370
|
+
}
|
|
26371
|
+
if (fromMs === toMs) return;
|
|
26372
|
+
if (toMs - fromMs > maxRangeDays * MS_PER_DAY) {
|
|
26373
|
+
throw new RangeError(`range exceeds timeline.qa.maxRangeDays (${maxRangeDays})`);
|
|
26374
|
+
}
|
|
26375
|
+
}
|
|
26376
|
+
function cardOverlaps(card, fromMs, toMs) {
|
|
26377
|
+
const start = Date.parse(card.startUtc);
|
|
26378
|
+
const end = Date.parse(card.endUtc);
|
|
26379
|
+
if (fromMs === toMs) return start <= fromMs && fromMs < end;
|
|
26380
|
+
return start < toMs && end > fromMs;
|
|
26381
|
+
}
|
|
26382
|
+
function passesFilters(card, categories, includeDistractions) {
|
|
26383
|
+
if (!includeDistractions && card.distraction === true) return false;
|
|
26384
|
+
if (categories && !categories.has(card.categoryId)) return false;
|
|
26385
|
+
return true;
|
|
26386
|
+
}
|
|
26387
|
+
function filterRange(cards, fromMs, toMs, categories, includeDistractions) {
|
|
26388
|
+
return cards.filter(
|
|
26389
|
+
(card) => cardOverlaps(card, fromMs, toMs) && passesFilters(card, categories, includeDistractions)
|
|
26390
|
+
);
|
|
26391
|
+
}
|
|
26392
|
+
function toCompact(cards, from) {
|
|
26393
|
+
const day = from.length >= 10 ? from.slice(0, 10) : cards[0]?.dayKey ?? from;
|
|
26394
|
+
return {
|
|
26395
|
+
day,
|
|
26396
|
+
cards: cards.map((card) => ({
|
|
26397
|
+
start: card.startUtc,
|
|
26398
|
+
end: card.endUtc,
|
|
26399
|
+
category: card.categoryId,
|
|
26400
|
+
title: card.title,
|
|
26401
|
+
summary: card.summary
|
|
26402
|
+
}))
|
|
26403
|
+
};
|
|
26404
|
+
}
|
|
26405
|
+
function queryTimelineRange(cards, query) {
|
|
26406
|
+
if (!RANGE_FORMATS.includes(query.format)) {
|
|
26407
|
+
throw new TypeError(`format must be one of: ${RANGE_FORMATS.join(", ")}`);
|
|
26408
|
+
}
|
|
26409
|
+
const maxRangeDays = query.maxRangeDays ?? DEFAULT_MAX_RANGE_DAYS;
|
|
26410
|
+
const fromMs = parseInstant(query.from, "from");
|
|
26411
|
+
const toMs = parseInstant(query.to, "to");
|
|
26412
|
+
assertRange(fromMs, toMs, maxRangeDays);
|
|
26413
|
+
const categories = query.categories ? new Set(query.categories) : void 0;
|
|
26414
|
+
const matched = filterRange(cards, fromMs, toMs, categories, query.includeDistractions === true);
|
|
26415
|
+
if (query.format === "compact") return toCompact(matched, query.from);
|
|
26416
|
+
return matched;
|
|
26417
|
+
}
|
|
26418
|
+
function haystack(card) {
|
|
26419
|
+
const parts = [card.title, card.summary];
|
|
26420
|
+
if (card.detailedSummary) parts.push(card.detailedSummary);
|
|
26421
|
+
return parts.join(" ").toLowerCase();
|
|
26422
|
+
}
|
|
26423
|
+
function tokenMatchCount(card, tokens) {
|
|
26424
|
+
const text = haystack(card);
|
|
26425
|
+
let count = 0;
|
|
26426
|
+
for (const token of tokens) {
|
|
26427
|
+
if (text.includes(token)) count += 1;
|
|
26428
|
+
}
|
|
26429
|
+
return count;
|
|
26430
|
+
}
|
|
26431
|
+
function queryTimelineSearch(cards, query) {
|
|
26432
|
+
if (!Array.isArray(cards)) return { ok: false, error: "store_unreadable" };
|
|
26433
|
+
const tokens = query.query.trim().toLowerCase().split(/\s+/).filter(Boolean);
|
|
26434
|
+
const limit = query.limit ?? DEFAULT_SEARCH_LIMIT;
|
|
26435
|
+
if (!Number.isInteger(limit) || limit < MIN_SEARCH_LIMIT || limit > MAX_SEARCH_LIMIT) {
|
|
26436
|
+
throw new RangeError(`limit must be an integer from ${MIN_SEARCH_LIMIT} to ${MAX_SEARCH_LIMIT}`);
|
|
26437
|
+
}
|
|
26438
|
+
let pool = cards;
|
|
26439
|
+
if (query.from !== void 0 || query.to !== void 0) {
|
|
26440
|
+
const fromMs = parseInstant(query.from ?? query.to, "from");
|
|
26441
|
+
const toMs = parseInstant(query.to ?? query.from, "to");
|
|
26442
|
+
assertRange(fromMs, toMs, DEFAULT_MAX_RANGE_DAYS);
|
|
26443
|
+
pool = filterRange(cards, fromMs, toMs, void 0, true);
|
|
26444
|
+
}
|
|
26445
|
+
if (tokens.length === 0) return { ok: true, results: [] };
|
|
26446
|
+
const ranked = pool.map((card) => ({ card, matches: tokenMatchCount(card, tokens) })).filter((row) => row.matches > 0).sort((a, b) => {
|
|
26447
|
+
if (a.matches !== b.matches) return b.matches - a.matches;
|
|
26448
|
+
const recency = Date.parse(b.card.endUtc) - Date.parse(a.card.endUtc);
|
|
26449
|
+
if (recency !== 0) return recency;
|
|
26450
|
+
return a.card.id < b.card.id ? -1 : a.card.id > b.card.id ? 1 : 0;
|
|
26451
|
+
}).slice(0, limit).map((row) => row.card);
|
|
26452
|
+
return { ok: true, results: ranked };
|
|
26453
|
+
}
|
|
26454
|
+
function parseFlags(args) {
|
|
26455
|
+
const flags = /* @__PURE__ */ new Map();
|
|
26456
|
+
const positional = [];
|
|
26457
|
+
for (let i = 0; i < args.length; i++) {
|
|
26458
|
+
const arg = args[i];
|
|
26459
|
+
if (!arg.startsWith("--")) {
|
|
26460
|
+
positional.push(arg);
|
|
26461
|
+
continue;
|
|
26462
|
+
}
|
|
26463
|
+
if (VALUE_FLAGS[arg] === true) {
|
|
26464
|
+
const value = args[i + 1];
|
|
26465
|
+
if (value === void 0 || value.startsWith("--")) {
|
|
26466
|
+
throw new TypeError(`flag ${arg} requires a value`);
|
|
26467
|
+
}
|
|
26468
|
+
flags.set(arg, value);
|
|
26469
|
+
i += 1;
|
|
26470
|
+
continue;
|
|
26471
|
+
}
|
|
26472
|
+
if (BOOLEAN_FLAGS[arg] === true) {
|
|
26473
|
+
flags.set(arg, true);
|
|
26474
|
+
continue;
|
|
26475
|
+
}
|
|
26476
|
+
const known = [...Object.keys(VALUE_FLAGS), ...Object.keys(BOOLEAN_FLAGS)].sort().join(", ");
|
|
26477
|
+
throw new TypeError(`unknown flag ${arg} (valid: ${known})`);
|
|
26478
|
+
}
|
|
26479
|
+
return { flags, positional };
|
|
26480
|
+
}
|
|
26481
|
+
function flagString(flags, name) {
|
|
26482
|
+
const value = flags.get(name);
|
|
26483
|
+
return typeof value === "string" ? value : void 0;
|
|
26484
|
+
}
|
|
26485
|
+
async function runTimelineCliCommand(deps, args, io) {
|
|
26486
|
+
const [command, ...rest] = args;
|
|
26487
|
+
try {
|
|
26488
|
+
if (command === void 0 || command === "help" || command === "--help") {
|
|
26489
|
+
io.stdout.write(USAGE);
|
|
26490
|
+
return command === void 0 ? 1 : 0;
|
|
26491
|
+
}
|
|
26492
|
+
if (deps.timelineEnabled === false || !deps.qa.enabled) {
|
|
26493
|
+
io.stderr.write("timeline qa disabled \u2014 set activity.timeline.qa.enabled=true\n");
|
|
26494
|
+
return 1;
|
|
26495
|
+
}
|
|
26496
|
+
const { flags } = parseFlags(rest);
|
|
26497
|
+
if (command === "range") {
|
|
26498
|
+
const from = flagString(flags, "--from");
|
|
26499
|
+
const to = flagString(flags, "--to");
|
|
26500
|
+
if (!from || !to) throw new TypeError("range requires --from and --to");
|
|
26501
|
+
if (!Array.isArray(deps.cards)) {
|
|
26502
|
+
io.stderr.write("store_unreadable\n");
|
|
26503
|
+
return 1;
|
|
26504
|
+
}
|
|
26505
|
+
const formatRaw = flagString(flags, "--format") ?? "compact";
|
|
26506
|
+
if (formatRaw !== "cards" && formatRaw !== "compact") {
|
|
26507
|
+
throw new TypeError("format must be one of: cards, compact");
|
|
26508
|
+
}
|
|
26509
|
+
const categoriesRaw = flagString(flags, "--categories");
|
|
26510
|
+
const result = queryTimelineRange(deps.cards, {
|
|
26511
|
+
from,
|
|
26512
|
+
to,
|
|
26513
|
+
format: formatRaw,
|
|
26514
|
+
categories: categoriesRaw ? categoriesRaw.split(",").filter(Boolean) : void 0,
|
|
26515
|
+
includeDistractions: flags.get("--include-distractions") === true,
|
|
26516
|
+
maxRangeDays: deps.qa.maxRangeDays
|
|
26517
|
+
});
|
|
26518
|
+
io.stdout.write(`${JSON.stringify(result)}
|
|
26519
|
+
`);
|
|
26520
|
+
return 0;
|
|
26521
|
+
}
|
|
26522
|
+
if (command === "search") {
|
|
26523
|
+
const q = flagString(flags, "--query");
|
|
26524
|
+
if (q === void 0) throw new TypeError("search requires --query");
|
|
26525
|
+
const limitRaw = flagString(flags, "--limit");
|
|
26526
|
+
const limit = limitRaw === void 0 ? void 0 : Number(limitRaw);
|
|
26527
|
+
if (limitRaw !== void 0 && !Number.isInteger(limit)) {
|
|
26528
|
+
throw new RangeError("limit must be an integer from 1 to 50");
|
|
26529
|
+
}
|
|
26530
|
+
const result = queryTimelineSearch(deps.cards, {
|
|
26531
|
+
query: q,
|
|
26532
|
+
from: flagString(flags, "--from"),
|
|
26533
|
+
to: flagString(flags, "--to"),
|
|
26534
|
+
limit
|
|
26535
|
+
});
|
|
26536
|
+
io.stdout.write(`${JSON.stringify(result)}
|
|
26537
|
+
`);
|
|
26538
|
+
return result.ok ? 0 : 1;
|
|
26539
|
+
}
|
|
26540
|
+
throw new TypeError(`unknown command ${command} (valid: range, search)`);
|
|
26541
|
+
} catch (err) {
|
|
26542
|
+
io.stderr.write(`${err instanceof Error ? err.message : String(err)}
|
|
26543
|
+
`);
|
|
26544
|
+
return 1;
|
|
26545
|
+
}
|
|
26546
|
+
}
|
|
26547
|
+
|
|
26548
|
+
// src/activity/timeline/journal-recap.ts
|
|
26549
|
+
function formatMinutes(ms) {
|
|
26550
|
+
return `${Math.round(ms / 6e4)}m`;
|
|
26551
|
+
}
|
|
26552
|
+
function clipToWindow(cards, winStart, winEnd) {
|
|
26553
|
+
const clipped = [];
|
|
26554
|
+
for (const card of cards) {
|
|
26555
|
+
const start = Date.parse(card.startUtc);
|
|
26556
|
+
const end = Date.parse(card.endUtc);
|
|
26557
|
+
if (!Number.isFinite(start) || !Number.isFinite(end)) continue;
|
|
26558
|
+
const startMs = Math.max(start, winStart);
|
|
26559
|
+
const endMs = Math.min(end, winEnd);
|
|
26560
|
+
if (endMs <= startMs) continue;
|
|
26561
|
+
clipped.push({ card, startMs, endMs, durationMs: endMs - startMs });
|
|
26562
|
+
}
|
|
26563
|
+
clipped.sort((left, right) => {
|
|
26564
|
+
const byStart = left.startMs - right.startMs;
|
|
26565
|
+
if (byStart !== 0) return byStart;
|
|
26566
|
+
const byTitle = left.card.title.localeCompare(right.card.title);
|
|
26567
|
+
if (byTitle !== 0) return byTitle;
|
|
26568
|
+
return left.card.id.localeCompare(right.card.id);
|
|
26569
|
+
});
|
|
26570
|
+
return clipped;
|
|
26571
|
+
}
|
|
26572
|
+
function categoryLines(clipped) {
|
|
26573
|
+
const totals = /* @__PURE__ */ new Map();
|
|
26574
|
+
for (const row of clipped) {
|
|
26575
|
+
totals.set(row.card.categoryId, (totals.get(row.card.categoryId) ?? 0) + row.durationMs);
|
|
26576
|
+
}
|
|
26577
|
+
const rows = [...totals.entries()].sort((left, right) => {
|
|
26578
|
+
const byDuration = right[1] - left[1];
|
|
26579
|
+
return byDuration !== 0 ? byDuration : left[0].localeCompare(right[0]);
|
|
26580
|
+
});
|
|
26581
|
+
if (rows.length === 0) return ["_No categories._"];
|
|
26582
|
+
return rows.map(([categoryId, durationMs]) => `- ${formatMinutes(durationMs)} ${categoryId}`);
|
|
26583
|
+
}
|
|
26584
|
+
function mergeIntervals(intervals) {
|
|
26585
|
+
const ordered = [...intervals].sort((left, right) => left[0] - right[0] || left[1] - right[1]);
|
|
26586
|
+
const merged = [];
|
|
26587
|
+
for (const [start, end] of ordered) {
|
|
26588
|
+
const last = merged[merged.length - 1];
|
|
26589
|
+
if (!last || start > last[1]) merged.push([start, end]);
|
|
26590
|
+
else last[1] = Math.max(last[1], end);
|
|
26591
|
+
}
|
|
26592
|
+
return merged;
|
|
26593
|
+
}
|
|
26594
|
+
function countGaps(winStart, winEnd, intervals) {
|
|
26595
|
+
const merged = mergeIntervals(intervals);
|
|
26596
|
+
let gaps = 0;
|
|
26597
|
+
let cursor = winStart;
|
|
26598
|
+
for (const [start, end] of merged) {
|
|
26599
|
+
if (start > cursor) gaps += 1;
|
|
26600
|
+
cursor = Math.max(cursor, end);
|
|
26601
|
+
}
|
|
26602
|
+
if (cursor < winEnd) gaps += 1;
|
|
26603
|
+
return gaps;
|
|
26604
|
+
}
|
|
26605
|
+
function renderDeterministicJournal(cards, options) {
|
|
26606
|
+
const window = activityDayWindow(options.date, options.timezone);
|
|
26607
|
+
const winStart = Date.parse(window.startUtc);
|
|
26608
|
+
const winEnd = Date.parse(window.endUtc);
|
|
26609
|
+
const clipped = clipToWindow(cards, winStart, winEnd);
|
|
26610
|
+
const idle = clipped.filter((row) => row.card.kind === "idle").length;
|
|
26611
|
+
const pause = clipped.filter((row) => row.card.kind === "pause").length;
|
|
26612
|
+
const gaps = countGaps(
|
|
26613
|
+
winStart,
|
|
26614
|
+
winEnd,
|
|
26615
|
+
clipped.map((row) => [row.startMs, row.endMs])
|
|
26616
|
+
);
|
|
26617
|
+
const cardLines = clipped.length === 0 ? ["_No cards._"] : clipped.map((row) => `- ${formatMinutes(row.durationMs)} ${row.card.title}`);
|
|
26618
|
+
return [
|
|
26619
|
+
`# Journal \u2014 ${options.date} (${options.timezone})`,
|
|
26620
|
+
"",
|
|
26621
|
+
"## Categories",
|
|
26622
|
+
"",
|
|
26623
|
+
...categoryLines(clipped),
|
|
26624
|
+
"",
|
|
26625
|
+
"## Cards",
|
|
26626
|
+
"",
|
|
26627
|
+
...cardLines,
|
|
26628
|
+
"",
|
|
26629
|
+
"## Gaps / idle / pause",
|
|
26630
|
+
"",
|
|
26631
|
+
`- Gaps: ${gaps}`,
|
|
26632
|
+
`- Idle: ${idle}`,
|
|
26633
|
+
`- Pause: ${pause}`,
|
|
26634
|
+
""
|
|
26635
|
+
].join("\n");
|
|
26636
|
+
}
|
|
26637
|
+
|
|
26638
|
+
// src/activity/timeline/journal-recap-persist.ts
|
|
26639
|
+
function persistDeterministicJournal(input) {
|
|
26640
|
+
const filePath = journalPath(input.memoryDir, input.date);
|
|
26641
|
+
const wrote = writeJournalFile(
|
|
26642
|
+
filePath,
|
|
26643
|
+
renderDeterministicJournal(input.cards, {
|
|
26644
|
+
date: input.date,
|
|
26645
|
+
timezone: input.timezone
|
|
26646
|
+
}),
|
|
26647
|
+
input.force === true
|
|
26648
|
+
);
|
|
26649
|
+
return { path: filePath, wrote };
|
|
26650
|
+
}
|
|
26651
|
+
|
|
26652
|
+
// src/activity/timeline/weekly.ts
|
|
26653
|
+
var WEEKLY_ACTIVITY_FORMAT_VERSION = 1;
|
|
26654
|
+
function parseBound(value, label) {
|
|
26655
|
+
const ms = parseFlexibleIsoTimestamp(value);
|
|
26656
|
+
if (ms === null) {
|
|
26657
|
+
throw new RangeError(`${label} is not a valid ISO timestamp`);
|
|
26658
|
+
}
|
|
26659
|
+
return ms;
|
|
26660
|
+
}
|
|
26661
|
+
function clip(start, end, winStart, winEnd) {
|
|
26662
|
+
const clippedStart = Math.max(start, winStart);
|
|
26663
|
+
const clippedEnd = Math.min(end, winEnd);
|
|
26664
|
+
return clippedEnd > clippedStart ? [clippedStart, clippedEnd] : null;
|
|
26665
|
+
}
|
|
26666
|
+
function unionDuration(intervals) {
|
|
26667
|
+
const sorted = [...intervals].sort((a, b) => a[0] - b[0] || a[1] - b[1]);
|
|
26668
|
+
let total = 0;
|
|
26669
|
+
let curStart = Number.NaN;
|
|
26670
|
+
let curEnd = Number.NaN;
|
|
26671
|
+
for (const [start, end] of sorted) {
|
|
26672
|
+
if (!Number.isFinite(curStart)) {
|
|
26673
|
+
curStart = start;
|
|
26674
|
+
curEnd = end;
|
|
26675
|
+
continue;
|
|
26676
|
+
}
|
|
26677
|
+
if (start <= curEnd) {
|
|
26678
|
+
curEnd = Math.max(curEnd, end);
|
|
26679
|
+
continue;
|
|
26680
|
+
}
|
|
26681
|
+
total += curEnd - curStart;
|
|
26682
|
+
curStart = start;
|
|
26683
|
+
curEnd = end;
|
|
26684
|
+
}
|
|
26685
|
+
if (Number.isFinite(curStart)) total += curEnd - curStart;
|
|
26686
|
+
return total;
|
|
26687
|
+
}
|
|
26688
|
+
function localDateOf(ms, timezone) {
|
|
26689
|
+
const parts = new Intl.DateTimeFormat("en-CA", {
|
|
26690
|
+
timeZone: timezone,
|
|
26691
|
+
year: "numeric",
|
|
26692
|
+
month: "2-digit",
|
|
26693
|
+
day: "2-digit"
|
|
26694
|
+
}).formatToParts(new Date(ms));
|
|
26695
|
+
const get = (type) => parts.find((part) => part.type === type)?.value ?? "";
|
|
26696
|
+
return `${get("year")}-${get("month")}-${get("day")}`;
|
|
26697
|
+
}
|
|
26698
|
+
function shiftIsoDate(date, days) {
|
|
26699
|
+
const parsed = /* @__PURE__ */ new Date(`${date}T00:00:00Z`);
|
|
26700
|
+
parsed.setUTCDate(parsed.getUTCDate() + days);
|
|
26701
|
+
return parsed.toISOString().slice(0, 10);
|
|
26702
|
+
}
|
|
26703
|
+
function daysOverlappingWeek(weekStartMs, weekEndMs, timezone) {
|
|
26704
|
+
if (weekEndMs <= weekStartMs) return [];
|
|
26705
|
+
let date = localDateOf(weekStartMs, timezone);
|
|
26706
|
+
let window = activityDayWindow(date, timezone);
|
|
26707
|
+
if (Date.parse(window.startUtc) > weekStartMs) {
|
|
26708
|
+
date = shiftIsoDate(date, -1);
|
|
26709
|
+
window = activityDayWindow(date, timezone);
|
|
26710
|
+
}
|
|
26711
|
+
const days = [];
|
|
26712
|
+
while (Date.parse(window.startUtc) < weekEndMs) {
|
|
26713
|
+
const startMs = Math.max(Date.parse(window.startUtc), weekStartMs);
|
|
26714
|
+
const endMs = Math.min(Date.parse(window.endUtc), weekEndMs);
|
|
26715
|
+
if (endMs > startMs) days.push({ date, startMs, endMs });
|
|
26716
|
+
date = shiftIsoDate(date, 1);
|
|
26717
|
+
window = activityDayWindow(date, timezone);
|
|
26718
|
+
}
|
|
26719
|
+
return days;
|
|
26720
|
+
}
|
|
26721
|
+
function emptyAcc(categoryIds) {
|
|
26722
|
+
return {
|
|
26723
|
+
activeMs: 0,
|
|
26724
|
+
idleMs: 0,
|
|
26725
|
+
pauseMs: 0,
|
|
26726
|
+
gapMs: 0,
|
|
26727
|
+
unclassifiedMs: 0,
|
|
26728
|
+
byCategory: new Map(categoryIds.map((id) => [id, 0])),
|
|
26729
|
+
intervals: []
|
|
26730
|
+
};
|
|
26731
|
+
}
|
|
26732
|
+
function addClipped(acc, kind, categoryId, known, start, end) {
|
|
26733
|
+
const duration = end - start;
|
|
26734
|
+
acc.intervals.push([start, end]);
|
|
26735
|
+
if (kind === "idle") acc.idleMs += duration;
|
|
26736
|
+
else if (kind === "pause") acc.pauseMs += duration;
|
|
26737
|
+
else acc.activeMs += duration;
|
|
26738
|
+
if (known.has(categoryId)) {
|
|
26739
|
+
acc.byCategory.set(categoryId, (acc.byCategory.get(categoryId) ?? 0) + duration);
|
|
26740
|
+
} else {
|
|
26741
|
+
acc.unclassifiedMs += duration;
|
|
26742
|
+
}
|
|
26743
|
+
}
|
|
26744
|
+
function sortCategoryTotals(byCategory) {
|
|
26745
|
+
return [...byCategory.entries()].map(([categoryId, durationMs]) => ({ categoryId, durationMs })).sort((a, b) => b.durationMs - a.durationMs || (a.categoryId < b.categoryId ? -1 : a.categoryId > b.categoryId ? 1 : 0));
|
|
26746
|
+
}
|
|
26747
|
+
function finish(acc, windowMs) {
|
|
26748
|
+
const covered = unionDuration(acc.intervals);
|
|
26749
|
+
return {
|
|
26750
|
+
activeMs: acc.activeMs,
|
|
26751
|
+
idleMs: acc.idleMs,
|
|
26752
|
+
pauseMs: acc.pauseMs,
|
|
26753
|
+
gapMs: Math.max(0, windowMs - covered),
|
|
26754
|
+
unclassifiedMs: acc.unclassifiedMs,
|
|
26755
|
+
categories: sortCategoryTotals(acc.byCategory)
|
|
26756
|
+
};
|
|
26757
|
+
}
|
|
26758
|
+
function buildWeeklyActivitySummary(cards, options) {
|
|
26759
|
+
assertValidTimezone(options.timezone);
|
|
26760
|
+
const weekStartMs = parseBound(options.weekStartUtc, "weekStartUtc");
|
|
26761
|
+
const weekEndMs = parseBound(options.weekEndUtc, "weekEndUtc");
|
|
26762
|
+
if (weekStartMs > weekEndMs) {
|
|
26763
|
+
throw new RangeError("reversed range: weekStartUtc must be <= weekEndUtc");
|
|
26764
|
+
}
|
|
26765
|
+
const categoryIds = options.categories.map((category) => category.id);
|
|
26766
|
+
const known = new Set(categoryIds);
|
|
26767
|
+
const week = emptyAcc(categoryIds);
|
|
26768
|
+
const dayWindows = daysOverlappingWeek(weekStartMs, weekEndMs, options.timezone);
|
|
26769
|
+
const dayAccs = dayWindows.map(() => emptyAcc(categoryIds));
|
|
26770
|
+
for (const card of cards) {
|
|
26771
|
+
const start = Date.parse(card.startUtc);
|
|
26772
|
+
const end = Date.parse(card.endUtc);
|
|
26773
|
+
if (!Number.isFinite(start) || !Number.isFinite(end) || end <= start) continue;
|
|
26774
|
+
const weekClip = clip(start, end, weekStartMs, weekEndMs);
|
|
26775
|
+
if (!weekClip) continue;
|
|
26776
|
+
addClipped(week, card.kind, card.categoryId, known, weekClip[0], weekClip[1]);
|
|
26777
|
+
for (let i = 0; i < dayWindows.length; i++) {
|
|
26778
|
+
const day = dayWindows[i];
|
|
26779
|
+
const dayClip = clip(start, end, day.startMs, day.endMs);
|
|
26780
|
+
if (dayClip) addClipped(dayAccs[i], card.kind, card.categoryId, known, dayClip[0], dayClip[1]);
|
|
26781
|
+
}
|
|
26782
|
+
}
|
|
26783
|
+
const weekTotals = finish(week, weekEndMs - weekStartMs);
|
|
26784
|
+
const days = dayWindows.map((day, i) => {
|
|
26785
|
+
const totals = finish(dayAccs[i], day.endMs - day.startMs);
|
|
26786
|
+
return {
|
|
26787
|
+
date: day.date,
|
|
26788
|
+
startUtc: new Date(day.startMs).toISOString(),
|
|
26789
|
+
endUtc: new Date(day.endMs).toISOString(),
|
|
26790
|
+
...totals
|
|
26791
|
+
};
|
|
26792
|
+
});
|
|
26793
|
+
return {
|
|
26794
|
+
formatVersion: WEEKLY_ACTIVITY_FORMAT_VERSION,
|
|
26795
|
+
timezone: options.timezone,
|
|
26796
|
+
weekStartUtc: new Date(weekStartMs).toISOString(),
|
|
26797
|
+
weekEndUtc: new Date(weekEndMs).toISOString(),
|
|
26798
|
+
...weekTotals,
|
|
26799
|
+
days,
|
|
26800
|
+
previousPeriod: { available: false }
|
|
26801
|
+
};
|
|
26802
|
+
}
|
|
26803
|
+
|
|
26804
|
+
// src/activity/timeline/weekly-persist.ts
|
|
26805
|
+
import { randomBytes as randomBytes3 } from "crypto";
|
|
26806
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync2, renameSync, unlinkSync, writeFileSync } from "fs";
|
|
26807
|
+
import path33 from "path";
|
|
26808
|
+
var WEEKLY_SNAPSHOT_FORMAT_VERSION = 1;
|
|
26809
|
+
var WEEKLY_SNAPSHOT_DIR = path33.join("activity", "weekly");
|
|
26810
|
+
function requireToken(value, name) {
|
|
26811
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
26812
|
+
throw new TypeError(`${name} must be a non-empty string`);
|
|
26813
|
+
}
|
|
26814
|
+
return value.trim();
|
|
26815
|
+
}
|
|
26816
|
+
function weeklySnapshotPath(input) {
|
|
26817
|
+
const memoryDir = requireToken(input.memoryDir, "memoryDir");
|
|
26818
|
+
const namespace = requireToken(input.namespace, "namespace");
|
|
26819
|
+
const sourceRevision = requireToken(input.sourceRevision, "sourceRevision");
|
|
26820
|
+
const configHash = requireToken(input.configHash, "configHash");
|
|
26821
|
+
const weekStartUtc = input.summary?.weekStartUtc;
|
|
26822
|
+
if (typeof weekStartUtc !== "string") {
|
|
26823
|
+
throw new TypeError("summary.weekStartUtc must be an ISO timestamp");
|
|
26824
|
+
}
|
|
26825
|
+
const weekDate = weekStartUtc.slice(0, 10);
|
|
26826
|
+
if (!isValidActivityDate(weekDate)) {
|
|
26827
|
+
throw new RangeError("summary.weekStartUtc must be an ISO timestamp");
|
|
26828
|
+
}
|
|
26829
|
+
const identity = hashActivityBody(
|
|
26830
|
+
`${input.summary.weekStartUtc}\0${input.summary.weekEndUtc}\0${sourceRevision}\0${configHash}`
|
|
26831
|
+
);
|
|
26832
|
+
return path33.join(
|
|
26833
|
+
path33.resolve(memoryDir),
|
|
26834
|
+
WEEKLY_SNAPSHOT_DIR,
|
|
26835
|
+
namespaceIdentityToken(namespace),
|
|
26836
|
+
`${weekDate}--${identity}.json`
|
|
26837
|
+
);
|
|
26838
|
+
}
|
|
26839
|
+
function persistWeeklySnapshot(input) {
|
|
26840
|
+
const namespace = requireToken(input.namespace, "namespace");
|
|
26841
|
+
const sourceRevision = requireToken(input.sourceRevision, "sourceRevision");
|
|
26842
|
+
const configHash = requireToken(input.configHash, "configHash");
|
|
26843
|
+
const filePath = weeklySnapshotPath(input);
|
|
26844
|
+
const payload = {
|
|
26845
|
+
formatVersion: WEEKLY_SNAPSHOT_FORMAT_VERSION,
|
|
26846
|
+
namespace,
|
|
26847
|
+
sourceRevision,
|
|
26848
|
+
configHash,
|
|
26849
|
+
summary: input.summary
|
|
26850
|
+
};
|
|
26851
|
+
const contentHash = hashActivityBody(JSON.stringify(payload));
|
|
26852
|
+
const text = `${JSON.stringify({ ...payload, contentHash })}
|
|
26853
|
+
`;
|
|
26854
|
+
try {
|
|
26855
|
+
if (readFileSync2(filePath, "utf8") === text) {
|
|
26856
|
+
return { path: filePath, written: false };
|
|
26857
|
+
}
|
|
26858
|
+
} catch (error) {
|
|
26859
|
+
if (!(typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT")) {
|
|
26860
|
+
throw error;
|
|
26861
|
+
}
|
|
26862
|
+
}
|
|
26863
|
+
mkdirSync2(path33.dirname(filePath), { recursive: true, mode: 448 });
|
|
26864
|
+
const tmpPath = `${filePath}.${process.pid}.${randomBytes3(8).toString("hex")}.tmp`;
|
|
26865
|
+
writeFileSync(tmpPath, text, { encoding: "utf8", mode: 384 });
|
|
26866
|
+
try {
|
|
26867
|
+
renameSync(tmpPath, filePath);
|
|
26868
|
+
} catch (error) {
|
|
26869
|
+
try {
|
|
26870
|
+
unlinkSync(tmpPath);
|
|
26871
|
+
} catch {
|
|
26872
|
+
}
|
|
26873
|
+
throw error;
|
|
26874
|
+
}
|
|
26875
|
+
return { path: filePath, written: true };
|
|
26876
|
+
}
|
|
26877
|
+
|
|
26878
|
+
// src/activity/timeline/analysis.ts
|
|
26879
|
+
var TIMELINE_ANALYSIS_PROMPT_VERSION = 1;
|
|
26880
|
+
var TIMELINE_ANALYSIS_BATCH_SIZE = 40;
|
|
26881
|
+
var TIMELINE_ANALYSIS_BATCH_OVERLAP = 2;
|
|
26882
|
+
var TIMELINE_ANALYSIS_DEFAULT_TIMEOUT_MS = 15e3;
|
|
26883
|
+
var TimelineAnalysisConfigError = class extends Error {
|
|
26884
|
+
name = "TimelineAnalysisConfigError";
|
|
26885
|
+
code = "invalid_config";
|
|
26886
|
+
constructor(message) {
|
|
26887
|
+
super(message);
|
|
26888
|
+
}
|
|
26889
|
+
};
|
|
26890
|
+
var INSTRUCTIONS = [
|
|
26891
|
+
"Use only supplied evidence.",
|
|
26892
|
+
"Preserve chronology.",
|
|
26893
|
+
"Do not invent people, places, or tasks.",
|
|
26894
|
+
"Avoid productivity or emotional claims.",
|
|
26895
|
+
"Merge adjacent activity only when the evidence justifies it.",
|
|
26896
|
+
'Return strict JSON: {"ops":[...]} with evidenceRange, title, summary, categoryId, confidence, uncertainty.',
|
|
26897
|
+
"Cite evidence ranges for every op. Empty ops is a valid no-op."
|
|
26898
|
+
].join(" ");
|
|
26899
|
+
function fail(status, cards, provider, model) {
|
|
26900
|
+
log.info(`timeline analysis status=${status} provider=${provider} model=${model} promptVersion=${TIMELINE_ANALYSIS_PROMPT_VERSION}`);
|
|
26901
|
+
return {
|
|
26902
|
+
status,
|
|
26903
|
+
cards,
|
|
26904
|
+
provider,
|
|
26905
|
+
model,
|
|
26906
|
+
promptVersion: TIMELINE_ANALYSIS_PROMPT_VERSION
|
|
26907
|
+
};
|
|
26908
|
+
}
|
|
26909
|
+
function requiredToken(value, name) {
|
|
26910
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
26911
|
+
throw new TimelineAnalysisConfigError(`${name} is required`);
|
|
26912
|
+
}
|
|
26913
|
+
return value.trim();
|
|
26914
|
+
}
|
|
26915
|
+
function evidenceKeyOf2(observation) {
|
|
26916
|
+
const parsed = Date.parse(observation.capturedAtUtc);
|
|
26917
|
+
const instant = Number.isFinite(parsed) ? new Date(parsed).toISOString() : observation.capturedAtUtc;
|
|
26918
|
+
return `${observation.machine}|${instant}|${observation.contentHash}`;
|
|
26919
|
+
}
|
|
26920
|
+
function sortObservations(observations) {
|
|
26921
|
+
return [...observations].sort((a, b) => {
|
|
26922
|
+
const time = Date.parse(a.capturedAtUtc) - Date.parse(b.capturedAtUtc);
|
|
26923
|
+
if (time !== 0) return time;
|
|
26924
|
+
if (a.contentHash !== b.contentHash) return a.contentHash < b.contentHash ? -1 : 1;
|
|
26925
|
+
return a.id - b.id;
|
|
26926
|
+
});
|
|
26927
|
+
}
|
|
26928
|
+
function batchObservations(observations) {
|
|
26929
|
+
if (observations.length === 0) return [[]];
|
|
26930
|
+
const size = TIMELINE_ANALYSIS_BATCH_SIZE;
|
|
26931
|
+
const overlap = TIMELINE_ANALYSIS_BATCH_OVERLAP;
|
|
26932
|
+
const step = size - overlap;
|
|
26933
|
+
const batches = [];
|
|
26934
|
+
for (let start = 0; start < observations.length; start += step) {
|
|
26935
|
+
batches.push(observations.slice(start, start + size));
|
|
26936
|
+
if (start + size >= observations.length) break;
|
|
26937
|
+
}
|
|
26938
|
+
return batches;
|
|
26939
|
+
}
|
|
26940
|
+
function safeObservation(observation) {
|
|
26941
|
+
return {
|
|
26942
|
+
id: observation.id,
|
|
26943
|
+
machine: observation.machine,
|
|
26944
|
+
capturedAtUtc: observation.capturedAtUtc,
|
|
26945
|
+
app: observation.app,
|
|
26946
|
+
windowTitle: observation.windowTitle,
|
|
26947
|
+
...observation.browserUrl ? { browserUrl: observation.browserUrl } : {},
|
|
26948
|
+
contentHash: observation.contentHash
|
|
26949
|
+
};
|
|
26950
|
+
}
|
|
26951
|
+
function safeCard(card) {
|
|
26952
|
+
return {
|
|
26953
|
+
id: card.id,
|
|
26954
|
+
kind: card.kind,
|
|
26955
|
+
title: card.title,
|
|
26956
|
+
summary: card.summary,
|
|
26957
|
+
categoryId: card.categoryId,
|
|
26958
|
+
confidence: card.confidence,
|
|
26959
|
+
startUtc: card.startUtc,
|
|
26960
|
+
endUtc: card.endUtc,
|
|
26961
|
+
machine: card.machine,
|
|
26962
|
+
evidenceIds: card.evidenceIds,
|
|
26963
|
+
evidenceRange: card.evidenceRange,
|
|
26964
|
+
...card.manualEdit ? { manualEdit: card.manualEdit } : {}
|
|
26965
|
+
};
|
|
26966
|
+
}
|
|
26967
|
+
function buildTimelineAnalysisPrompt(input) {
|
|
26968
|
+
const payload = {
|
|
26969
|
+
date: input.date ?? null,
|
|
26970
|
+
timezone: input.timezone ?? null,
|
|
26971
|
+
categories: input.categories.map((category) => ({ id: category.id, name: category.name })),
|
|
26972
|
+
preferences: input.preferences ?? [],
|
|
26973
|
+
priorEdits: input.priorEdits ?? [],
|
|
26974
|
+
cards: input.cards.map(safeCard),
|
|
26975
|
+
observations: input.observations.map(safeObservation)
|
|
26976
|
+
};
|
|
26977
|
+
return `${INSTRUCTIONS}
|
|
26978
|
+
${JSON.stringify(payload)}`;
|
|
26979
|
+
}
|
|
26980
|
+
async function callComplete(complete, prompt, provider, model, timeoutMs, parent) {
|
|
26981
|
+
const { promise: timeoutPromise, reject } = Promise.withResolvers();
|
|
26982
|
+
const failOnce = (message, name) => {
|
|
26983
|
+
reject(Object.assign(new Error(message), { name }));
|
|
26984
|
+
};
|
|
26985
|
+
const timer = setTimeout(() => failOnce("timeline analysis timed out", "TimeoutError"), timeoutMs);
|
|
26986
|
+
if (parent?.aborted) {
|
|
26987
|
+
clearTimeout(timer);
|
|
26988
|
+
throw Object.assign(new Error("timeline analysis aborted"), { name: "AbortError" });
|
|
26989
|
+
}
|
|
26990
|
+
const onAbort = () => failOnce("timeline analysis aborted", "AbortError");
|
|
26991
|
+
parent?.addEventListener("abort", onAbort, { once: true });
|
|
26992
|
+
const signal = parent ? AbortSignal.any([parent, AbortSignal.timeout(timeoutMs)]) : AbortSignal.timeout(timeoutMs);
|
|
26993
|
+
try {
|
|
26994
|
+
return await Promise.race([complete({ prompt, provider, model, signal }), timeoutPromise]);
|
|
26995
|
+
} finally {
|
|
26996
|
+
clearTimeout(timer);
|
|
26997
|
+
parent?.removeEventListener("abort", onAbort);
|
|
26998
|
+
}
|
|
26999
|
+
}
|
|
27000
|
+
function parseOps(raw) {
|
|
27001
|
+
if (typeof raw !== "string" || raw.trim().length === 0) return null;
|
|
27002
|
+
for (const candidate of extractJsonCandidates(raw)) {
|
|
27003
|
+
try {
|
|
27004
|
+
const parsed = JSON.parse(candidate);
|
|
27005
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed) || !("ops" in parsed)) continue;
|
|
27006
|
+
const ops = parsed.ops;
|
|
27007
|
+
if (!Array.isArray(ops)) continue;
|
|
27008
|
+
const out = [];
|
|
27009
|
+
let valid = true;
|
|
27010
|
+
for (const item of ops) {
|
|
27011
|
+
const op = asOp(item);
|
|
27012
|
+
if (!op) {
|
|
27013
|
+
valid = false;
|
|
27014
|
+
break;
|
|
27015
|
+
}
|
|
27016
|
+
out.push(op);
|
|
27017
|
+
}
|
|
27018
|
+
if (valid) return out;
|
|
27019
|
+
} catch {
|
|
27020
|
+
continue;
|
|
27021
|
+
}
|
|
27022
|
+
}
|
|
27023
|
+
return null;
|
|
27024
|
+
}
|
|
27025
|
+
function asOp(value) {
|
|
27026
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
27027
|
+
if (!("cardId" in value) || typeof value.cardId !== "string" || value.cardId.length === 0) return null;
|
|
27028
|
+
if (!("evidenceRange" in value)) return null;
|
|
27029
|
+
const range = value.evidenceRange;
|
|
27030
|
+
if (!range || typeof range !== "object" || Array.isArray(range)) return null;
|
|
27031
|
+
if (!("firstKey" in range) || typeof range.firstKey !== "string" || range.firstKey.length === 0) return null;
|
|
27032
|
+
if (!("lastKey" in range) || typeof range.lastKey !== "string" || range.lastKey.length === 0) return null;
|
|
27033
|
+
if ("title" in value && value.title !== void 0 && typeof value.title !== "string") return null;
|
|
27034
|
+
if ("summary" in value && value.summary !== void 0 && typeof value.summary !== "string") return null;
|
|
27035
|
+
if ("categoryId" in value && value.categoryId !== void 0 && typeof value.categoryId !== "string") return null;
|
|
27036
|
+
if ("uncertainty" in value && value.uncertainty !== void 0 && typeof value.uncertainty !== "string") return null;
|
|
27037
|
+
if ("confidence" in value && value.confidence !== void 0 && (typeof value.confidence !== "number" || value.confidence < 0 || value.confidence > 1)) {
|
|
27038
|
+
return null;
|
|
27039
|
+
}
|
|
27040
|
+
return {
|
|
27041
|
+
cardId: value.cardId,
|
|
27042
|
+
title: "title" in value && typeof value.title === "string" ? value.title : void 0,
|
|
27043
|
+
summary: "summary" in value && typeof value.summary === "string" ? value.summary : void 0,
|
|
27044
|
+
categoryId: "categoryId" in value && typeof value.categoryId === "string" ? value.categoryId : void 0,
|
|
27045
|
+
confidence: "confidence" in value && typeof value.confidence === "number" ? value.confidence : void 0,
|
|
27046
|
+
uncertainty: "uncertainty" in value && typeof value.uncertainty === "string" ? value.uncertainty : void 0,
|
|
27047
|
+
evidenceRange: { firstKey: range.firstKey, lastKey: range.lastKey }
|
|
27048
|
+
};
|
|
27049
|
+
}
|
|
27050
|
+
function knownEvidenceKeys(cards, observations) {
|
|
27051
|
+
const keys = /* @__PURE__ */ new Set();
|
|
27052
|
+
for (const observation of observations) keys.add(evidenceKeyOf2(observation));
|
|
27053
|
+
for (const card of cards) {
|
|
27054
|
+
if (card.evidenceRange) {
|
|
27055
|
+
keys.add(card.evidenceRange.firstKey);
|
|
27056
|
+
keys.add(card.evidenceRange.lastKey);
|
|
27057
|
+
}
|
|
27058
|
+
}
|
|
27059
|
+
return keys;
|
|
27060
|
+
}
|
|
27061
|
+
function applyOps(cards, ops, categories, evidenceKeys) {
|
|
27062
|
+
if (ops.length === 0) return cards;
|
|
27063
|
+
const byId = new Map(cards.map((card) => [card.id, card]));
|
|
27064
|
+
const allowedCategories = new Set(categories.map((category) => category.id));
|
|
27065
|
+
const next = /* @__PURE__ */ new Map();
|
|
27066
|
+
for (const op of ops) {
|
|
27067
|
+
const card = byId.get(op.cardId);
|
|
27068
|
+
if (!card) return null;
|
|
27069
|
+
if (!evidenceKeys.has(op.evidenceRange.firstKey) || !evidenceKeys.has(op.evidenceRange.lastKey)) return null;
|
|
27070
|
+
if (op.categoryId !== void 0 && !allowedCategories.has(op.categoryId)) return null;
|
|
27071
|
+
if (card.manualEdit) continue;
|
|
27072
|
+
next.set(card.id, {
|
|
27073
|
+
...card,
|
|
27074
|
+
...op.title !== void 0 ? { title: op.title } : {},
|
|
27075
|
+
...op.summary !== void 0 ? { summary: op.summary } : {},
|
|
27076
|
+
...op.categoryId !== void 0 ? { categoryId: op.categoryId } : {},
|
|
27077
|
+
...op.confidence !== void 0 ? { confidence: op.confidence } : {}
|
|
27078
|
+
});
|
|
27079
|
+
}
|
|
27080
|
+
if (next.size === 0) return cards;
|
|
27081
|
+
return cards.map((card) => next.get(card.id) ?? card);
|
|
27082
|
+
}
|
|
27083
|
+
async function analyzeTimelineCards(input) {
|
|
27084
|
+
const cards = input.cards;
|
|
27085
|
+
if (!input.enabled) {
|
|
27086
|
+
return { status: "disabled", cards };
|
|
27087
|
+
}
|
|
27088
|
+
const provider = requiredToken(input.provider, "provider");
|
|
27089
|
+
const model = requiredToken(input.model, "model");
|
|
27090
|
+
const complete = input.complete;
|
|
27091
|
+
if (typeof complete !== "function") {
|
|
27092
|
+
throw new TimelineAnalysisConfigError("complete is required");
|
|
27093
|
+
}
|
|
27094
|
+
const timeoutMs = input.timeoutMs ?? TIMELINE_ANALYSIS_DEFAULT_TIMEOUT_MS;
|
|
27095
|
+
if (!Number.isInteger(timeoutMs) || timeoutMs <= 0) {
|
|
27096
|
+
throw new TimelineAnalysisConfigError("timeoutMs must be a positive integer");
|
|
27097
|
+
}
|
|
27098
|
+
if (input.cards.length === 0 && input.observations.length === 0) {
|
|
27099
|
+
return fail("invalid_output", cards, provider, model);
|
|
27100
|
+
}
|
|
27101
|
+
const categories = input.categories ?? DEFAULT_TIMELINE_CATEGORIES;
|
|
27102
|
+
const ordered = sortObservations(input.observations);
|
|
27103
|
+
const batches = batchObservations(ordered);
|
|
27104
|
+
const merged = /* @__PURE__ */ new Map();
|
|
27105
|
+
try {
|
|
27106
|
+
for (const batch of batches) {
|
|
27107
|
+
const prompt = buildTimelineAnalysisPrompt({
|
|
27108
|
+
date: input.date,
|
|
27109
|
+
timezone: input.timezone,
|
|
27110
|
+
cards: input.cards,
|
|
27111
|
+
observations: batch,
|
|
27112
|
+
categories,
|
|
27113
|
+
preferences: input.preferences,
|
|
27114
|
+
priorEdits: input.priorEdits
|
|
27115
|
+
});
|
|
27116
|
+
const raw = await callComplete(complete, prompt, provider, model, timeoutMs, input.signal);
|
|
27117
|
+
const ops = parseOps(raw);
|
|
27118
|
+
if (!ops) return fail("invalid_output", cards, provider, model);
|
|
27119
|
+
for (const op of ops) merged.set(op.cardId, op);
|
|
27120
|
+
}
|
|
27121
|
+
} catch {
|
|
27122
|
+
return fail("provider_failed", cards, provider, model);
|
|
27123
|
+
}
|
|
27124
|
+
const applied = applyOps(cards, [...merged.values()], categories, knownEvidenceKeys(cards, ordered));
|
|
27125
|
+
if (!applied) return fail("invalid_output", cards, provider, model);
|
|
27126
|
+
log.info(`timeline analysis status=ok provider=${provider} model=${model} promptVersion=${TIMELINE_ANALYSIS_PROMPT_VERSION}`);
|
|
27127
|
+
return {
|
|
27128
|
+
status: "ok",
|
|
27129
|
+
cards: applied,
|
|
27130
|
+
provider,
|
|
27131
|
+
model,
|
|
27132
|
+
promptVersion: TIMELINE_ANALYSIS_PROMPT_VERSION
|
|
27133
|
+
};
|
|
27134
|
+
}
|
|
27135
|
+
|
|
27136
|
+
// src/activity/timeline/analysis-batch.ts
|
|
27137
|
+
function compareObservations(a, b) {
|
|
27138
|
+
const time = Date.parse(a.capturedAtUtc) - Date.parse(b.capturedAtUtc);
|
|
27139
|
+
if (time !== 0) return time;
|
|
27140
|
+
return a.id - b.id;
|
|
27141
|
+
}
|
|
27142
|
+
function batchObservations2(observations, options) {
|
|
27143
|
+
const { maxBatch, overlap } = options;
|
|
27144
|
+
if (!Number.isInteger(overlap) || overlap < 0) {
|
|
27145
|
+
throw new RangeError("overlap must be a non-negative integer");
|
|
27146
|
+
}
|
|
27147
|
+
if (maxBatch === 0) return [];
|
|
27148
|
+
if (!Number.isInteger(maxBatch) || maxBatch < 1) {
|
|
27149
|
+
throw new RangeError("maxBatch must be 0 or a positive integer");
|
|
27150
|
+
}
|
|
27151
|
+
if (overlap >= maxBatch) {
|
|
27152
|
+
throw new RangeError("overlap must be less than maxBatch");
|
|
27153
|
+
}
|
|
27154
|
+
if (observations.length === 0) return [];
|
|
27155
|
+
const ordered = [...observations].sort(compareObservations);
|
|
27156
|
+
const step = maxBatch - overlap;
|
|
27157
|
+
const batches = [];
|
|
27158
|
+
for (let start = 0; start < ordered.length; start += step) {
|
|
27159
|
+
batches.push(ordered.slice(start, start + maxBatch));
|
|
27160
|
+
if (start + maxBatch >= ordered.length) break;
|
|
27161
|
+
}
|
|
27162
|
+
return batches;
|
|
27163
|
+
}
|
|
27164
|
+
|
|
27165
|
+
// src/activity/journal-vault-read.ts
|
|
27166
|
+
var REMNIC_OPEN = "<!-- remnic:";
|
|
27167
|
+
function readVaultJournal(input) {
|
|
27168
|
+
if (input.fileText === null || input.fileText === void 0) {
|
|
27169
|
+
return { ok: true, exists: false, reason: "missing_file" };
|
|
27170
|
+
}
|
|
27171
|
+
if (input.journalSection.length === 0) {
|
|
27172
|
+
return { ok: true, exists: false, reason: "missing_heading" };
|
|
27173
|
+
}
|
|
27174
|
+
const lines = splitFileLines(input.fileText);
|
|
27175
|
+
const hits = [];
|
|
27176
|
+
const levels = [];
|
|
27177
|
+
for (let i = 0; i < lines.length; i++) {
|
|
27178
|
+
const heading = parseAtxHeading(lines[i]);
|
|
27179
|
+
if (heading && heading.text === input.journalSection) {
|
|
27180
|
+
hits.push(i + 1);
|
|
27181
|
+
levels.push(heading.level);
|
|
27182
|
+
}
|
|
27183
|
+
}
|
|
27184
|
+
if (hits.length === 0) return { ok: true, exists: false, reason: "missing_heading" };
|
|
27185
|
+
if (hits.length > 1) return { ok: false, reason: "duplicate_heading", lines: hits };
|
|
27186
|
+
const headingIndex = hits[0] - 1;
|
|
27187
|
+
const level = levels[0];
|
|
27188
|
+
let endIndex = lines.length;
|
|
27189
|
+
for (let i = headingIndex + 1; i < lines.length; i++) {
|
|
27190
|
+
const heading = parseAtxHeading(lines[i]);
|
|
27191
|
+
if (heading && heading.level <= level) {
|
|
27192
|
+
endIndex = i;
|
|
27193
|
+
break;
|
|
27194
|
+
}
|
|
27195
|
+
}
|
|
27196
|
+
const body = lines.slice(headingIndex + 1, endIndex).join("\n");
|
|
27197
|
+
const stripped = stripRemnicOwnedRegions(body, input.publishSectionNames ?? []);
|
|
27198
|
+
return {
|
|
27199
|
+
ok: true,
|
|
27200
|
+
exists: true,
|
|
27201
|
+
text: trimNewlines(stripped.text),
|
|
27202
|
+
heading: input.journalSection,
|
|
27203
|
+
warnings: stripped.warnings
|
|
27204
|
+
};
|
|
27205
|
+
}
|
|
27206
|
+
function stripRemnicOwnedRegions(text, publishSectionNames = []) {
|
|
27207
|
+
const marked = cutIntervals(text, remnicIntervals(text));
|
|
27208
|
+
return {
|
|
27209
|
+
text: stripPublishHeadings(marked.text, publishSectionNames),
|
|
27210
|
+
warnings: marked.warnings
|
|
27211
|
+
};
|
|
27212
|
+
}
|
|
27213
|
+
function splitFileLines(fileText) {
|
|
27214
|
+
const lines = fileText.split("\n");
|
|
27215
|
+
for (let i = 0; i < lines.length; i++) {
|
|
27216
|
+
const line = lines[i];
|
|
27217
|
+
if (line.endsWith("\r")) lines[i] = line.slice(0, -1);
|
|
27218
|
+
}
|
|
27219
|
+
return lines;
|
|
27220
|
+
}
|
|
27221
|
+
function parseAtxHeading(line) {
|
|
27222
|
+
let level = 0;
|
|
27223
|
+
while (level < line.length && level < 6 && line[level] === "#") level++;
|
|
27224
|
+
if (level === 0) return null;
|
|
27225
|
+
const after = line[level];
|
|
27226
|
+
if (after !== " " && after !== " ") return null;
|
|
27227
|
+
let start = level + 1;
|
|
27228
|
+
let end = line.length;
|
|
27229
|
+
while (start < end && (line[start] === " " || line[start] === " ")) start++;
|
|
27230
|
+
while (end > start && (line[end - 1] === " " || line[end - 1] === " ")) end--;
|
|
27231
|
+
let hashEnd = end;
|
|
27232
|
+
while (hashEnd > start && line[hashEnd - 1] === "#") hashEnd--;
|
|
27233
|
+
if (hashEnd < end && hashEnd > start && (line[hashEnd - 1] === " " || line[hashEnd - 1] === " ")) {
|
|
27234
|
+
end = hashEnd;
|
|
27235
|
+
while (end > start && (line[end - 1] === " " || line[end - 1] === " ")) end--;
|
|
27236
|
+
}
|
|
27237
|
+
return { level, text: line.slice(start, end) };
|
|
27238
|
+
}
|
|
27239
|
+
function remnicIntervals(text) {
|
|
27240
|
+
const starts = [];
|
|
27241
|
+
const ends = [];
|
|
27242
|
+
let from = 0;
|
|
27243
|
+
while (from < text.length) {
|
|
27244
|
+
const open = text.indexOf(REMNIC_OPEN, from);
|
|
27245
|
+
if (open === -1) break;
|
|
27246
|
+
const afterOpen = open + REMNIC_OPEN.length;
|
|
27247
|
+
const commentEnd = text.indexOf("-->", afterOpen);
|
|
27248
|
+
if (commentEnd === -1) break;
|
|
27249
|
+
const inner = text.slice(afterOpen, commentEnd).trim();
|
|
27250
|
+
if (inner.endsWith(":start")) {
|
|
27251
|
+
const name = inner.slice(0, -":start".length);
|
|
27252
|
+
if (name.length > 0) starts.push({ name, start: open, after: commentEnd + 3 });
|
|
27253
|
+
} else if (inner.endsWith(":end")) {
|
|
27254
|
+
const name = inner.slice(0, -":end".length);
|
|
27255
|
+
if (name.length > 0) ends.push({ name, start: open, end: commentEnd + 3 });
|
|
27256
|
+
}
|
|
27257
|
+
from = commentEnd + 3;
|
|
27258
|
+
}
|
|
27259
|
+
const usedEnds = /* @__PURE__ */ new Set();
|
|
27260
|
+
const intervals = [];
|
|
27261
|
+
const warnings = [];
|
|
27262
|
+
for (const start of starts) {
|
|
27263
|
+
const match = ends.find((end) => end.name === start.name && end.start >= start.after && !usedEnds.has(end.start));
|
|
27264
|
+
if (match) {
|
|
27265
|
+
usedEnds.add(match.start);
|
|
27266
|
+
intervals.push({ start: start.start, end: eatTrailingNewline(text, match.end) });
|
|
27267
|
+
} else {
|
|
27268
|
+
intervals.push({ start: start.start, end: text.length });
|
|
27269
|
+
warnings.push(`unclosed remnic region "${start.name}"`);
|
|
27270
|
+
}
|
|
27271
|
+
}
|
|
27272
|
+
for (const end of ends) {
|
|
27273
|
+
if (usedEnds.has(end.start)) continue;
|
|
27274
|
+
const startBefore = starts.some((start) => start.start < end.start);
|
|
27275
|
+
if (!startBefore) intervals.push({ start: 0, end: eatTrailingNewline(text, end.end) });
|
|
27276
|
+
}
|
|
27277
|
+
return { intervals: mergeIntervals2(intervals), warnings };
|
|
27278
|
+
}
|
|
27279
|
+
function eatTrailingNewline(text, index) {
|
|
27280
|
+
if (text[index] === "\n") return index + 1;
|
|
27281
|
+
if (text[index] === "\r" && text[index + 1] === "\n") return index + 2;
|
|
27282
|
+
if (text[index] === "\r") return index + 1;
|
|
27283
|
+
return index;
|
|
27284
|
+
}
|
|
27285
|
+
function mergeIntervals2(items) {
|
|
27286
|
+
if (items.length === 0) return [];
|
|
27287
|
+
const sorted = items.slice().sort((a, b) => a.start - b.start || a.end - b.end);
|
|
27288
|
+
const out = [{ start: sorted[0].start, end: sorted[0].end }];
|
|
27289
|
+
for (let i = 1; i < sorted.length; i++) {
|
|
27290
|
+
const cur = sorted[i];
|
|
27291
|
+
const last = out[out.length - 1];
|
|
27292
|
+
if (cur.start <= last.end) last.end = Math.max(last.end, cur.end);
|
|
27293
|
+
else out.push({ start: cur.start, end: cur.end });
|
|
27294
|
+
}
|
|
27295
|
+
return out;
|
|
27296
|
+
}
|
|
27297
|
+
function cutIntervals(text, found) {
|
|
27298
|
+
let out = "";
|
|
27299
|
+
let pos = 0;
|
|
27300
|
+
for (const interval of found.intervals) {
|
|
27301
|
+
if (interval.start > pos) out += text.slice(pos, interval.start);
|
|
27302
|
+
pos = Math.max(pos, interval.end);
|
|
27303
|
+
}
|
|
27304
|
+
if (pos < text.length) out += text.slice(pos);
|
|
27305
|
+
return { text: out, warnings: found.warnings };
|
|
27306
|
+
}
|
|
27307
|
+
function stripPublishHeadings(text, names) {
|
|
27308
|
+
if (names.length === 0 || text.length === 0) return text;
|
|
27309
|
+
const lines = text.split("\n");
|
|
27310
|
+
const keep = lines.map(() => true);
|
|
27311
|
+
for (let i = 0; i < lines.length; i++) {
|
|
27312
|
+
if (!keep[i]) continue;
|
|
27313
|
+
const heading = parseAtxHeading(lines[i]);
|
|
27314
|
+
if (!heading || !names.includes(heading.text)) continue;
|
|
27315
|
+
keep[i] = false;
|
|
27316
|
+
for (let j = i + 1; j < lines.length; j++) {
|
|
27317
|
+
const next = parseAtxHeading(lines[j]);
|
|
27318
|
+
if (next && next.level <= heading.level) break;
|
|
27319
|
+
keep[j] = false;
|
|
27320
|
+
}
|
|
27321
|
+
}
|
|
27322
|
+
return lines.filter((_, i) => keep[i]).join("\n");
|
|
27323
|
+
}
|
|
27324
|
+
function trimNewlines(text) {
|
|
27325
|
+
let start = 0;
|
|
27326
|
+
let end = text.length;
|
|
27327
|
+
while (start < end && (text[start] === "\n" || text[start] === "\r")) start++;
|
|
27328
|
+
while (end > start && (text[end - 1] === "\n" || text[end - 1] === "\r")) end--;
|
|
27329
|
+
return text.slice(start, end);
|
|
27330
|
+
}
|
|
27331
|
+
|
|
26302
27332
|
// src/activity/memory-gen.ts
|
|
26303
27333
|
var ACTIVITY_ALLOWED_CATEGORIES = {
|
|
26304
27334
|
decision: true,
|
|
@@ -26555,10 +27585,237 @@ async function generateActivityMemories(date, digestBody, config, deps) {
|
|
|
26555
27585
|
return result;
|
|
26556
27586
|
}
|
|
26557
27587
|
|
|
27588
|
+
// src/activity/privacy.ts
|
|
27589
|
+
var MS_PER_DAY2 = 864e5;
|
|
27590
|
+
function asRecord(value, name) {
|
|
27591
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
27592
|
+
throw new TypeError(`${name} must be an object`);
|
|
27593
|
+
}
|
|
27594
|
+
return value;
|
|
27595
|
+
}
|
|
27596
|
+
function parseGate(value, key, fallback) {
|
|
27597
|
+
if (value === void 0) return fallback;
|
|
27598
|
+
const parsed = coerceBooleanLike(value, key);
|
|
27599
|
+
if (parsed === void 0) throw new TypeError(`${key} must be a boolean`);
|
|
27600
|
+
return parsed;
|
|
27601
|
+
}
|
|
27602
|
+
function parseActivityPrivacy(raw) {
|
|
27603
|
+
if (raw === void 0 || raw === null) {
|
|
27604
|
+
return { enabled: false, retentionDays: 0, exportIncludeObservations: false };
|
|
27605
|
+
}
|
|
27606
|
+
const config = asRecord(raw, "activity");
|
|
27607
|
+
const enabled = parseGate(config.enabled, "activity.enabled", false);
|
|
27608
|
+
let retentionDays = 0;
|
|
27609
|
+
if (config.retentionDays !== void 0) {
|
|
27610
|
+
const parsed = coerceNumber(config.retentionDays, "activity.retentionDays");
|
|
27611
|
+
if (parsed === void 0 || !Number.isInteger(parsed) || parsed < 0) {
|
|
27612
|
+
throw new RangeError("activity.retentionDays must be a non-negative integer");
|
|
27613
|
+
}
|
|
27614
|
+
retentionDays = parsed;
|
|
27615
|
+
}
|
|
27616
|
+
const exportIncludeObservations = parseGate(
|
|
27617
|
+
config.exportIncludeObservations,
|
|
27618
|
+
"activity.exportIncludeObservations",
|
|
27619
|
+
false
|
|
27620
|
+
);
|
|
27621
|
+
return { enabled, retentionDays, exportIncludeObservations };
|
|
27622
|
+
}
|
|
27623
|
+
function shouldRetain(capturedAtMs, nowMs, retentionDays, enabled = true) {
|
|
27624
|
+
if (!enabled) return false;
|
|
27625
|
+
if (retentionDays < 0 || !Number.isInteger(retentionDays)) {
|
|
27626
|
+
throw new RangeError("activity.retentionDays must be a non-negative integer");
|
|
27627
|
+
}
|
|
27628
|
+
if (retentionDays === 0) return true;
|
|
27629
|
+
return nowMs - capturedAtMs < retentionDays * MS_PER_DAY2;
|
|
27630
|
+
}
|
|
27631
|
+
function observationsForExport(observations, policy) {
|
|
27632
|
+
if (!policy.enabled || !policy.exportIncludeObservations) return [];
|
|
27633
|
+
return observations;
|
|
27634
|
+
}
|
|
27635
|
+
|
|
27636
|
+
// src/activity/vault-path.ts
|
|
27637
|
+
import path34 from "path";
|
|
27638
|
+
var TOKEN_RE = /\{yyyy\}|\{yy\}|\{MM\}|\{dd\}|\{M\}|\{d\}|\{ww\}/g;
|
|
27639
|
+
function resolveVaultNotePath(template, date, options) {
|
|
27640
|
+
if (!isValidActivityDate(date)) {
|
|
27641
|
+
throw new RangeError(`Invalid vault date "${date}"; expected YYYY-MM-DD.`);
|
|
27642
|
+
}
|
|
27643
|
+
if (options?.timezone !== void 0) {
|
|
27644
|
+
assertValidTimezone(options.timezone);
|
|
27645
|
+
}
|
|
27646
|
+
if (typeof template !== "string" || template.length === 0) {
|
|
27647
|
+
throw new RangeError("Vault note path template must be a non-empty relative path.");
|
|
27648
|
+
}
|
|
27649
|
+
if (path34.posix.isAbsolute(template) || path34.win32.isAbsolute(template)) {
|
|
27650
|
+
throw new RangeError("Vault note path template must be relative; absolute templates are rejected.");
|
|
27651
|
+
}
|
|
27652
|
+
const [yyyy, mm, dd] = date.split("-");
|
|
27653
|
+
const tokens = {
|
|
27654
|
+
"{yyyy}": yyyy,
|
|
27655
|
+
"{yy}": yyyy.slice(2),
|
|
27656
|
+
"{MM}": mm,
|
|
27657
|
+
"{dd}": dd,
|
|
27658
|
+
"{M}": String(Number(mm)),
|
|
27659
|
+
"{d}": String(Number(dd)),
|
|
27660
|
+
"{ww}": isoWeekNumber(date)
|
|
27661
|
+
};
|
|
27662
|
+
const expanded = template.replace(TOKEN_RE, (token) => tokens[token] ?? token);
|
|
27663
|
+
if (expanded.split(/[\\/]/).some((segment) => segment === "..")) {
|
|
27664
|
+
throw new RangeError("Vault note path template must not contain `..` segments.");
|
|
27665
|
+
}
|
|
27666
|
+
if (path34.posix.isAbsolute(expanded) || path34.win32.isAbsolute(expanded)) {
|
|
27667
|
+
throw new RangeError("Vault note path template must be relative; absolute templates are rejected.");
|
|
27668
|
+
}
|
|
27669
|
+
return expanded;
|
|
27670
|
+
}
|
|
27671
|
+
function isoWeekNumber(date) {
|
|
27672
|
+
const [year, month, day] = date.split("-").map(Number);
|
|
27673
|
+
const utc = new Date(Date.UTC(year, month - 1, day));
|
|
27674
|
+
const dayNum = utc.getUTCDay() || 7;
|
|
27675
|
+
utc.setUTCDate(utc.getUTCDate() + 4 - dayNum);
|
|
27676
|
+
const yearStart = new Date(Date.UTC(utc.getUTCFullYear(), 0, 1));
|
|
27677
|
+
const weekNo = Math.ceil(((utc.getTime() - yearStart.getTime()) / 864e5 + 1) / 7);
|
|
27678
|
+
return String(weekNo).padStart(2, "0");
|
|
27679
|
+
}
|
|
27680
|
+
|
|
27681
|
+
// src/activity/vault-publish.ts
|
|
27682
|
+
import { createHash as createHash10, randomBytes as randomBytes4 } from "crypto";
|
|
27683
|
+
import { readFileSync as readFileSync3, renameSync as renameSync2, statSync as statSync2, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
27684
|
+
import path35 from "path";
|
|
27685
|
+
function applyManagedRegion(fileText, opts) {
|
|
27686
|
+
if (opts.strategy === "heading") return applyHeadingRegion(fileText, opts.name, opts.content);
|
|
27687
|
+
const startMarker = `<!-- remnic:${opts.name}:start -->`;
|
|
27688
|
+
const endMarker = `<!-- remnic:${opts.name}:end -->`;
|
|
27689
|
+
const startIdx = fileText.indexOf(startMarker);
|
|
27690
|
+
if (startIdx === -1) return { ok: false, reason: "no_marker", text: fileText };
|
|
27691
|
+
const endIdx = fileText.indexOf(endMarker, startIdx + startMarker.length);
|
|
27692
|
+
if (endIdx === -1) return { ok: false, reason: "no_marker", text: fileText };
|
|
27693
|
+
const { body, eol } = ownedBody(fileText, opts.content);
|
|
27694
|
+
return {
|
|
27695
|
+
ok: true,
|
|
27696
|
+
text: `${fileText.slice(0, startIdx + startMarker.length)}${eol}${body}${eol}${fileText.slice(endIdx)}`
|
|
27697
|
+
};
|
|
27698
|
+
}
|
|
27699
|
+
function applyHeadingRegion(fileText, name, content) {
|
|
27700
|
+
const wanted = name.trim();
|
|
27701
|
+
const hits = [];
|
|
27702
|
+
for (const row of fileLines(fileText)) {
|
|
27703
|
+
const heading = parseAtxHeading2(row.line);
|
|
27704
|
+
if (heading && heading.text === wanted) {
|
|
27705
|
+
hits.push({ line: row.number, level: heading.level, next: row.next });
|
|
27706
|
+
}
|
|
27707
|
+
}
|
|
27708
|
+
if (hits.length === 0) return { ok: false, reason: "no_heading", text: fileText };
|
|
27709
|
+
if (hits.length > 1) {
|
|
27710
|
+
return { ok: false, reason: "duplicate_heading", lines: hits.map((hit2) => hit2.line), text: fileText };
|
|
27711
|
+
}
|
|
27712
|
+
const hit = hits[0];
|
|
27713
|
+
let sectionEnd = fileText.length;
|
|
27714
|
+
for (const row of fileLines(fileText)) {
|
|
27715
|
+
if (row.start < hit.next) continue;
|
|
27716
|
+
const heading = parseAtxHeading2(row.line);
|
|
27717
|
+
if (heading && heading.level <= hit.level) {
|
|
27718
|
+
sectionEnd = row.start;
|
|
27719
|
+
break;
|
|
27720
|
+
}
|
|
27721
|
+
}
|
|
27722
|
+
const { body, eol } = ownedBody(fileText, content);
|
|
27723
|
+
const prefix = hit.next === fileText.length && !fileText.endsWith("\n") && !fileText.endsWith("\r") ? `${fileText}${eol}` : fileText.slice(0, hit.next);
|
|
27724
|
+
return { ok: true, text: `${prefix}${body}${eol}${fileText.slice(sectionEnd)}` };
|
|
27725
|
+
}
|
|
27726
|
+
function ownedBody(fileText, content) {
|
|
27727
|
+
const eol = fileText.includes("\r\n") ? "\r\n" : "\n";
|
|
27728
|
+
let body = content.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
27729
|
+
if (eol === "\r\n") body = body.replace(/\n/g, "\r\n");
|
|
27730
|
+
if (body.endsWith(eol)) body = body.slice(0, -eol.length);
|
|
27731
|
+
return { body, eol };
|
|
27732
|
+
}
|
|
27733
|
+
function fileLines(fileText) {
|
|
27734
|
+
const rows = [];
|
|
27735
|
+
let start = 0;
|
|
27736
|
+
let number = 1;
|
|
27737
|
+
while (start < fileText.length) {
|
|
27738
|
+
let i = start;
|
|
27739
|
+
while (i < fileText.length && fileText[i] !== "\n" && fileText[i] !== "\r") i++;
|
|
27740
|
+
let next = i;
|
|
27741
|
+
if (fileText[i] === "\r" && fileText[i + 1] === "\n") next = i + 2;
|
|
27742
|
+
else if (fileText[i] === "\n" || fileText[i] === "\r") next = i + 1;
|
|
27743
|
+
else next = fileText.length;
|
|
27744
|
+
rows.push({ line: fileText.slice(start, i), start, next, number });
|
|
27745
|
+
number += 1;
|
|
27746
|
+
start = next;
|
|
27747
|
+
}
|
|
27748
|
+
return rows;
|
|
27749
|
+
}
|
|
27750
|
+
function parseAtxHeading2(line) {
|
|
27751
|
+
let level = 0;
|
|
27752
|
+
while (level < line.length && level < 6 && line[level] === "#") level++;
|
|
27753
|
+
if (level === 0) return null;
|
|
27754
|
+
const after = line[level];
|
|
27755
|
+
if (after !== " " && after !== " ") return null;
|
|
27756
|
+
let start = level + 1;
|
|
27757
|
+
let end = line.length;
|
|
27758
|
+
while (start < end && (line[start] === " " || line[start] === " ")) start++;
|
|
27759
|
+
while (end > start && (line[end - 1] === " " || line[end - 1] === " ")) end--;
|
|
27760
|
+
let hashEnd = end;
|
|
27761
|
+
while (hashEnd > start && line[hashEnd - 1] === "#") hashEnd--;
|
|
27762
|
+
if (hashEnd < end && hashEnd > start && (line[hashEnd - 1] === " " || line[hashEnd - 1] === " ")) {
|
|
27763
|
+
end = hashEnd;
|
|
27764
|
+
while (end > start && (line[end - 1] === " " || line[end - 1] === " ")) end--;
|
|
27765
|
+
}
|
|
27766
|
+
return { level, text: line.slice(start, end) };
|
|
27767
|
+
}
|
|
27768
|
+
function publishVaultRegion(input) {
|
|
27769
|
+
const vault = expandTildePath(input.vaultPath);
|
|
27770
|
+
try {
|
|
27771
|
+
if (!statSync2(vault).isDirectory()) return { ok: false, reason: "not_directory" };
|
|
27772
|
+
} catch {
|
|
27773
|
+
return { ok: false, reason: "not_directory" };
|
|
27774
|
+
}
|
|
27775
|
+
if (input.relativeFile.length === 0 || path35.isAbsolute(input.relativeFile)) {
|
|
27776
|
+
return { ok: false, reason: "missing_file" };
|
|
27777
|
+
}
|
|
27778
|
+
const root = path35.resolve(vault);
|
|
27779
|
+
const dest = path35.resolve(root, input.relativeFile);
|
|
27780
|
+
const rel = path35.relative(root, dest);
|
|
27781
|
+
if (rel.length === 0 || rel.startsWith("..") || path35.isAbsolute(rel)) {
|
|
27782
|
+
return { ok: false, reason: "missing_file" };
|
|
27783
|
+
}
|
|
27784
|
+
let existing;
|
|
27785
|
+
try {
|
|
27786
|
+
if (!statSync2(dest).isFile()) return { ok: false, reason: "missing_file" };
|
|
27787
|
+
existing = readFileSync3(dest, "utf8");
|
|
27788
|
+
} catch (err) {
|
|
27789
|
+
if (err.code === "ENOENT") return { ok: false, reason: "missing_file" };
|
|
27790
|
+
throw err;
|
|
27791
|
+
}
|
|
27792
|
+
const applied = applyManagedRegion(existing, {
|
|
27793
|
+
strategy: "markers",
|
|
27794
|
+
name: input.name,
|
|
27795
|
+
content: input.content
|
|
27796
|
+
});
|
|
27797
|
+
if (!applied.ok) return { ok: false, reason: "no_marker" };
|
|
27798
|
+
const prevHash = createHash10("sha256").update(existing, "utf8").digest("hex");
|
|
27799
|
+
const nextHash = createHash10("sha256").update(applied.text, "utf8").digest("hex");
|
|
27800
|
+
if (prevHash === nextHash) return { ok: true, status: "unchanged" };
|
|
27801
|
+
const tmpPath = path35.join(path35.dirname(dest), `.remnic-vault-${randomBytes4(8).toString("hex")}.tmp`);
|
|
27802
|
+
writeFileSync2(tmpPath, applied.text);
|
|
27803
|
+
try {
|
|
27804
|
+
renameSync2(tmpPath, dest);
|
|
27805
|
+
} catch (renameErr) {
|
|
27806
|
+
try {
|
|
27807
|
+
unlinkSync2(tmpPath);
|
|
27808
|
+
} catch {
|
|
27809
|
+
}
|
|
27810
|
+
throw renameErr;
|
|
27811
|
+
}
|
|
27812
|
+
return { ok: true, status: "updated" };
|
|
27813
|
+
}
|
|
27814
|
+
|
|
26558
27815
|
// src/session-summaries/index.ts
|
|
26559
|
-
import { createHash as
|
|
27816
|
+
import { createHash as createHash11 } from "crypto";
|
|
26560
27817
|
import { lstat as lstat3, mkdir as mkdir7, readFile as readFile7, readdir as readdir4, rename, rm, stat as stat4, writeFile as writeFile7 } from "fs/promises";
|
|
26561
|
-
import
|
|
27818
|
+
import path36 from "path";
|
|
26562
27819
|
|
|
26563
27820
|
// src/session-summaries/adapters.ts
|
|
26564
27821
|
var VALID_ROLES = /* @__PURE__ */ new Set(["user", "assistant", "tool", "system", "other"]);
|
|
@@ -27058,12 +28315,12 @@ var DEFAULT_MAX_FILES = 5e3;
|
|
|
27058
28315
|
var DEFAULT_MAX_SESSIONS = 500;
|
|
27059
28316
|
var SUPPORTED_EXTENSIONS = /* @__PURE__ */ new Set([".json", ".jsonl"]);
|
|
27060
28317
|
function shortHash(value, length = 16) {
|
|
27061
|
-
return
|
|
28318
|
+
return createHash11("sha256").update(value).digest("hex").slice(0, length);
|
|
27062
28319
|
}
|
|
27063
28320
|
async function listTranscriptFiles(root, maxFiles) {
|
|
27064
28321
|
const out = [];
|
|
27065
28322
|
let truncated = false;
|
|
27066
|
-
const entrySortKey = (entryName, isDirectory) => isDirectory ? `${entryName}${
|
|
28323
|
+
const entrySortKey = (entryName, isDirectory) => isDirectory ? `${entryName}${path36.sep}` : entryName;
|
|
27067
28324
|
async function visit(dir) {
|
|
27068
28325
|
if (truncated) return;
|
|
27069
28326
|
const entries = (await readdir4(dir, { withFileTypes: true })).sort(
|
|
@@ -27073,13 +28330,13 @@ async function listTranscriptFiles(root, maxFiles) {
|
|
|
27073
28330
|
if (truncated) return;
|
|
27074
28331
|
if (entry.name.startsWith(".")) continue;
|
|
27075
28332
|
if (entry.isSymbolicLink()) continue;
|
|
27076
|
-
const fullPath =
|
|
28333
|
+
const fullPath = path36.join(dir, entry.name);
|
|
27077
28334
|
if (entry.isDirectory()) {
|
|
27078
28335
|
await visit(fullPath);
|
|
27079
28336
|
continue;
|
|
27080
28337
|
}
|
|
27081
28338
|
if (!entry.isFile()) continue;
|
|
27082
|
-
const ext =
|
|
28339
|
+
const ext = path36.extname(entry.name).toLowerCase();
|
|
27083
28340
|
if (!SUPPORTED_EXTENSIONS.has(ext)) continue;
|
|
27084
28341
|
out.push(fullPath);
|
|
27085
28342
|
if (out.length > maxFiles) {
|
|
@@ -27106,7 +28363,7 @@ function normalizeInputDir(inputDir) {
|
|
|
27106
28363
|
if (typeof inputDir !== "string" || inputDir.trim().length === 0) {
|
|
27107
28364
|
throw new Error("inputDir must be a non-empty string");
|
|
27108
28365
|
}
|
|
27109
|
-
return
|
|
28366
|
+
return path36.resolve(expandTildePath(inputDir.trim()));
|
|
27110
28367
|
}
|
|
27111
28368
|
function initRoleCounts() {
|
|
27112
28369
|
return {
|
|
@@ -27263,11 +28520,11 @@ async function collectLocalSessionSummaries(options) {
|
|
|
27263
28520
|
continue;
|
|
27264
28521
|
}
|
|
27265
28522
|
seenFileHashes.add(fileHash);
|
|
27266
|
-
const fileExtension =
|
|
28523
|
+
const fileExtension = path36.extname(filePath).toLowerCase();
|
|
27267
28524
|
const parsed = await adapter.parseFile(
|
|
27268
28525
|
{
|
|
27269
28526
|
content,
|
|
27270
|
-
fileName:
|
|
28527
|
+
fileName: path36.basename(filePath),
|
|
27271
28528
|
fileExtension,
|
|
27272
28529
|
fileRef: fileHash
|
|
27273
28530
|
},
|
|
@@ -27323,7 +28580,7 @@ async function collectLocalSessionSummaries(options) {
|
|
|
27323
28580
|
}
|
|
27324
28581
|
async function readRedactionConfig(pathLike) {
|
|
27325
28582
|
if (!pathLike) return void 0;
|
|
27326
|
-
const raw = await readFile7(
|
|
28583
|
+
const raw = await readFile7(path36.resolve(expandTildePath(pathLike)), "utf-8");
|
|
27327
28584
|
const parsed = JSON.parse(raw);
|
|
27328
28585
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
27329
28586
|
throw new Error("redaction config must be a JSON object");
|
|
@@ -27336,15 +28593,15 @@ function toJsonl(drafts) {
|
|
|
27336
28593
|
}
|
|
27337
28594
|
function defaultDraftOutputPath(memoryDir, generatedAt) {
|
|
27338
28595
|
const stamp = generatedAt.replace(/[:.]/g, "-");
|
|
27339
|
-
return
|
|
27340
|
-
|
|
28596
|
+
return path36.join(
|
|
28597
|
+
path36.resolve(expandTildePath(memoryDir)),
|
|
27341
28598
|
"state",
|
|
27342
28599
|
"session-summary-drafts",
|
|
27343
28600
|
`session-summaries-${stamp}.jsonl`
|
|
27344
28601
|
);
|
|
27345
28602
|
}
|
|
27346
28603
|
async function writeDrafts(filePath, drafts) {
|
|
27347
|
-
await mkdir7(
|
|
28604
|
+
await mkdir7(path36.dirname(filePath), { recursive: true });
|
|
27348
28605
|
const tempPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
27349
28606
|
try {
|
|
27350
28607
|
await writeFile7(tempPath, toJsonl(drafts), "utf-8");
|
|
@@ -27362,7 +28619,7 @@ async function runLocalSessionSummaryCliCommand(options) {
|
|
|
27362
28619
|
});
|
|
27363
28620
|
const wroteFiles = [];
|
|
27364
28621
|
if (options.output) {
|
|
27365
|
-
const outputPath =
|
|
28622
|
+
const outputPath = path36.resolve(expandTildePath(options.output));
|
|
27366
28623
|
await writeDrafts(outputPath, report.drafts);
|
|
27367
28624
|
wroteFiles.push(outputPath);
|
|
27368
28625
|
}
|
|
@@ -27397,19 +28654,19 @@ async function runLocalSessionSummaryCliCommand(options) {
|
|
|
27397
28654
|
|
|
27398
28655
|
// src/transfer/capsule-fork.ts
|
|
27399
28656
|
import { lstat as lstat4, mkdir as mkdir8, readFile as readFile8, realpath as realpath3, writeFile as writeFile8 } from "fs/promises";
|
|
27400
|
-
import
|
|
28657
|
+
import path37 from "path";
|
|
27401
28658
|
async function forkCapsule(opts) {
|
|
27402
28659
|
validateForkId(opts.forkId);
|
|
27403
|
-
const rootAbs =
|
|
28660
|
+
const rootAbs = path37.resolve(opts.targetRoot);
|
|
27404
28661
|
await assertIsDirectoryNotSymlink(rootAbs, "forkCapsule", "targetRoot");
|
|
27405
|
-
const forkDirAbs =
|
|
28662
|
+
const forkDirAbs = path37.join(rootAbs, "forks", opts.forkId);
|
|
27406
28663
|
const forkEntryExists = await pathEntryExists(forkDirAbs);
|
|
27407
28664
|
if (forkEntryExists) {
|
|
27408
28665
|
throw new Error(
|
|
27409
28666
|
`forkCapsule: fork path already exists \u2014 forkId "${opts.forkId}" is already in use at: ${forkDirAbs}`
|
|
27410
28667
|
);
|
|
27411
28668
|
}
|
|
27412
|
-
const archiveAbs =
|
|
28669
|
+
const archiveAbs = path37.resolve(opts.sourceArchive);
|
|
27413
28670
|
const importResult = await importCapsule({
|
|
27414
28671
|
archivePath: archiveAbs,
|
|
27415
28672
|
root: rootAbs,
|
|
@@ -27431,10 +28688,10 @@ async function forkCapsule(opts) {
|
|
|
27431
28688
|
importedRecords: importResult.imported.length,
|
|
27432
28689
|
skippedRecords: importResult.skipped.length
|
|
27433
28690
|
};
|
|
27434
|
-
const lineagePath =
|
|
28691
|
+
const lineagePath = path37.join(forkDirAbs, "lineage.json");
|
|
27435
28692
|
const rootReal = await realpath3(rootAbs);
|
|
27436
28693
|
await assertRealpathInsideRoot(rootReal, lineagePath, `forks/${opts.forkId}/lineage.json`, "forkCapsule");
|
|
27437
|
-
await mkdir8(
|
|
28694
|
+
await mkdir8(path37.dirname(lineagePath), { recursive: true });
|
|
27438
28695
|
await writeFile8(lineagePath, JSON.stringify(lineage, null, 2) + "\n", "utf-8");
|
|
27439
28696
|
return {
|
|
27440
28697
|
archivePath: archiveAbs,
|
|
@@ -27448,11 +28705,11 @@ async function readForkLineage(targetRoot, forkId) {
|
|
|
27448
28705
|
if (typeof forkId !== "string" || forkId.length === 0 || forkId.length > 64 || !CAPSULE_ID_PATTERN.test(forkId)) {
|
|
27449
28706
|
return null;
|
|
27450
28707
|
}
|
|
27451
|
-
const rootAbs =
|
|
28708
|
+
const rootAbs = path37.resolve(targetRoot);
|
|
27452
28709
|
const rootReal = await realpath3(rootAbs).catch(() => rootAbs);
|
|
27453
|
-
const lineagePath =
|
|
27454
|
-
const rel =
|
|
27455
|
-
if (rel.startsWith("..") ||
|
|
28710
|
+
const lineagePath = path37.join(rootReal, "forks", forkId, "lineage.json");
|
|
28711
|
+
const rel = path37.relative(rootReal, lineagePath);
|
|
28712
|
+
if (rel.startsWith("..") || path37.isAbsolute(rel)) {
|
|
27456
28713
|
return null;
|
|
27457
28714
|
}
|
|
27458
28715
|
if (!await isLineagePathContained(rootReal, lineagePath)) {
|
|
@@ -27493,19 +28750,19 @@ async function pathEntryExists(absPath) {
|
|
|
27493
28750
|
async function isLineagePathContained(rootReal, lineagePath) {
|
|
27494
28751
|
let existing = lineagePath;
|
|
27495
28752
|
const suffix = [];
|
|
27496
|
-
while (existing !==
|
|
28753
|
+
while (existing !== path37.dirname(existing)) {
|
|
27497
28754
|
const st = await lstat4(existing).catch(() => null);
|
|
27498
28755
|
if (st !== null) break;
|
|
27499
|
-
suffix.unshift(
|
|
27500
|
-
existing =
|
|
28756
|
+
suffix.unshift(path37.basename(existing));
|
|
28757
|
+
existing = path37.dirname(existing);
|
|
27501
28758
|
}
|
|
27502
28759
|
const existingReal = await realpath3(existing).catch(() => existing);
|
|
27503
|
-
const targetReal = suffix.length > 0 ?
|
|
27504
|
-
const rel =
|
|
28760
|
+
const targetReal = suffix.length > 0 ? path37.join(existingReal, ...suffix) : existingReal;
|
|
28761
|
+
const rel = path37.relative(rootReal, targetReal);
|
|
27505
28762
|
if (rel === "") return true;
|
|
27506
28763
|
if (rel === "..") return false;
|
|
27507
|
-
if (rel.startsWith(`..${
|
|
27508
|
-
if (
|
|
28764
|
+
if (rel.startsWith(`..${path37.sep}`)) return false;
|
|
28765
|
+
if (path37.isAbsolute(rel)) return false;
|
|
27509
28766
|
return true;
|
|
27510
28767
|
}
|
|
27511
28768
|
|
|
@@ -27605,8 +28862,36 @@ export {
|
|
|
27605
28862
|
timelineCorrectionDatabasePath,
|
|
27606
28863
|
TimelineCorrectionStore,
|
|
27607
28864
|
applyTimelineCorrections,
|
|
28865
|
+
queryTimelineRange,
|
|
28866
|
+
queryTimelineSearch,
|
|
28867
|
+
runTimelineCliCommand,
|
|
28868
|
+
renderDeterministicJournal,
|
|
28869
|
+
persistDeterministicJournal,
|
|
28870
|
+
WEEKLY_ACTIVITY_FORMAT_VERSION,
|
|
28871
|
+
buildWeeklyActivitySummary,
|
|
28872
|
+
WEEKLY_SNAPSHOT_FORMAT_VERSION,
|
|
28873
|
+
WEEKLY_SNAPSHOT_DIR,
|
|
28874
|
+
weeklySnapshotPath,
|
|
28875
|
+
persistWeeklySnapshot,
|
|
28876
|
+
TIMELINE_ANALYSIS_PROMPT_VERSION,
|
|
28877
|
+
TIMELINE_ANALYSIS_BATCH_SIZE,
|
|
28878
|
+
TIMELINE_ANALYSIS_BATCH_OVERLAP,
|
|
28879
|
+
TIMELINE_ANALYSIS_DEFAULT_TIMEOUT_MS,
|
|
28880
|
+
TimelineAnalysisConfigError,
|
|
28881
|
+
buildTimelineAnalysisPrompt,
|
|
28882
|
+
analyzeTimelineCards,
|
|
28883
|
+
batchObservations2 as batchObservations,
|
|
28884
|
+
readVaultJournal,
|
|
28885
|
+
stripRemnicOwnedRegions,
|
|
27608
28886
|
isEligibleActivityFact,
|
|
27609
28887
|
generateActivityMemories,
|
|
28888
|
+
MS_PER_DAY2 as MS_PER_DAY,
|
|
28889
|
+
parseActivityPrivacy,
|
|
28890
|
+
shouldRetain,
|
|
28891
|
+
observationsForExport,
|
|
28892
|
+
resolveVaultNotePath,
|
|
28893
|
+
applyManagedRegion,
|
|
28894
|
+
publishVaultRegion,
|
|
27610
28895
|
fuseMeeting,
|
|
27611
28896
|
buildMeetingRecordsForDay,
|
|
27612
28897
|
MeetingsBuilder,
|
|
@@ -27640,4 +28925,4 @@ export {
|
|
|
27640
28925
|
blendGraphExpandedRecallScore,
|
|
27641
28926
|
Orchestrator
|
|
27642
28927
|
};
|
|
27643
|
-
//# sourceMappingURL=chunk-
|
|
28928
|
+
//# sourceMappingURL=chunk-47WWTCJY.js.map
|