@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
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdtempSync, readFileSync, readdirSync, rmSync, statSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import test from "node:test";
|
|
6
|
+
|
|
7
|
+
import { RECALL_FALLBACK_DIRS } from "../../utils/category-dir.js";
|
|
8
|
+
import type { TimelineCategory } from "./types.js";
|
|
9
|
+
import { persistWeeklySnapshot } from "./weekly-persist.js";
|
|
10
|
+
import { buildWeeklyActivitySummary } from "./weekly.js";
|
|
11
|
+
|
|
12
|
+
const WEEK_START = "2026-07-13T00:00:00.000Z";
|
|
13
|
+
const WEEK_END = "2026-07-20T00:00:00.000Z";
|
|
14
|
+
const OTHER_WEEK_START = "2026-07-20T00:00:00.000Z";
|
|
15
|
+
const OTHER_WEEK_END = "2026-07-27T00:00:00.000Z";
|
|
16
|
+
|
|
17
|
+
const CATEGORIES: TimelineCategory[] = [
|
|
18
|
+
{ id: "development", name: "Development", color: "#333333", description: "d", order: 1 },
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
function summary(weekStartUtc = WEEK_START, weekEndUtc = WEEK_END) {
|
|
22
|
+
return buildWeeklyActivitySummary([], {
|
|
23
|
+
timezone: "UTC",
|
|
24
|
+
weekStartUtc,
|
|
25
|
+
weekEndUtc,
|
|
26
|
+
categories: CATEGORIES,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function withMemoryDir(fn: (memoryDir: string) => void): void {
|
|
31
|
+
const memoryDir = mkdtempSync(path.join(tmpdir(), "remnic-weekly-persist-"));
|
|
32
|
+
try {
|
|
33
|
+
fn(memoryDir);
|
|
34
|
+
} finally {
|
|
35
|
+
rmSync(memoryDir, { recursive: true, force: true });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function assertOutsideRecallRoots(filePath: string, memoryDir: string): void {
|
|
40
|
+
const relative = path.relative(memoryDir, filePath);
|
|
41
|
+
assert.ok(relative.startsWith(`activity${path.sep}weekly${path.sep}`));
|
|
42
|
+
assert.ok(
|
|
43
|
+
!RECALL_FALLBACK_DIRS.some((dir) => relative === dir || relative.startsWith(`${dir}${path.sep}`)),
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
test("same inputs skip rewrite by content hash", () => {
|
|
48
|
+
withMemoryDir((memoryDir) => {
|
|
49
|
+
const input = {
|
|
50
|
+
memoryDir,
|
|
51
|
+
namespace: "team",
|
|
52
|
+
summary: summary(),
|
|
53
|
+
sourceRevision: "rev-1",
|
|
54
|
+
configHash: "cfg-1",
|
|
55
|
+
};
|
|
56
|
+
const first = persistWeeklySnapshot(input);
|
|
57
|
+
assert.equal(first.written, true);
|
|
58
|
+
assertOutsideRecallRoots(first.path, memoryDir);
|
|
59
|
+
const firstBytes = readFileSync(first.path, "utf8");
|
|
60
|
+
const firstStat = statSync(first.path);
|
|
61
|
+
const snapshot = JSON.parse(firstBytes) as { contentHash: string };
|
|
62
|
+
assert.equal(typeof snapshot.contentHash, "string");
|
|
63
|
+
assert.equal(snapshot.contentHash.length, 64);
|
|
64
|
+
|
|
65
|
+
const second = persistWeeklySnapshot(input);
|
|
66
|
+
assert.equal(second.written, false);
|
|
67
|
+
assert.equal(second.path, first.path);
|
|
68
|
+
assert.equal(readFileSync(first.path, "utf8"), firstBytes);
|
|
69
|
+
assert.equal(statSync(first.path).mtimeMs, firstStat.mtimeMs);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test("changed sourceRevision or configHash writes a new file and leaves other weeks", () => {
|
|
74
|
+
withMemoryDir((memoryDir) => {
|
|
75
|
+
const base = {
|
|
76
|
+
memoryDir,
|
|
77
|
+
namespace: "team",
|
|
78
|
+
summary: summary(),
|
|
79
|
+
sourceRevision: "rev-1",
|
|
80
|
+
configHash: "cfg-1",
|
|
81
|
+
};
|
|
82
|
+
const original = persistWeeklySnapshot(base);
|
|
83
|
+
const originalBytes = readFileSync(original.path, "utf8");
|
|
84
|
+
|
|
85
|
+
const revised = persistWeeklySnapshot({ ...base, sourceRevision: "rev-2" });
|
|
86
|
+
assert.notEqual(revised.path, original.path);
|
|
87
|
+
assert.equal(revised.written, true);
|
|
88
|
+
assert.equal(readFileSync(original.path, "utf8"), originalBytes);
|
|
89
|
+
|
|
90
|
+
const reconfigured = persistWeeklySnapshot({ ...base, configHash: "cfg-2" });
|
|
91
|
+
assert.notEqual(reconfigured.path, original.path);
|
|
92
|
+
assert.notEqual(reconfigured.path, revised.path);
|
|
93
|
+
assert.equal(readFileSync(original.path, "utf8"), originalBytes);
|
|
94
|
+
|
|
95
|
+
const otherWeek = persistWeeklySnapshot({
|
|
96
|
+
...base,
|
|
97
|
+
summary: summary(OTHER_WEEK_START, OTHER_WEEK_END),
|
|
98
|
+
});
|
|
99
|
+
assert.notEqual(otherWeek.path, original.path);
|
|
100
|
+
assert.equal(readFileSync(original.path, "utf8"), originalBytes);
|
|
101
|
+
assert.equal(JSON.parse(readFileSync(otherWeek.path, "utf8")).summary.weekStartUtc, OTHER_WEEK_START);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test("snapshots are namespace scoped", () => {
|
|
106
|
+
withMemoryDir((memoryDir) => {
|
|
107
|
+
const shared = {
|
|
108
|
+
memoryDir,
|
|
109
|
+
summary: summary(),
|
|
110
|
+
sourceRevision: "rev-1",
|
|
111
|
+
configHash: "cfg-1",
|
|
112
|
+
};
|
|
113
|
+
const alpha = persistWeeklySnapshot({ ...shared, namespace: "alpha" });
|
|
114
|
+
const beta = persistWeeklySnapshot({ ...shared, namespace: "beta" });
|
|
115
|
+
assert.notEqual(alpha.path, beta.path);
|
|
116
|
+
assert.equal(JSON.parse(readFileSync(alpha.path, "utf8")).namespace, "alpha");
|
|
117
|
+
assert.equal(JSON.parse(readFileSync(beta.path, "utf8")).namespace, "beta");
|
|
118
|
+
assert.equal(readdirSync(path.dirname(alpha.path)).length, 1);
|
|
119
|
+
assert.equal(readdirSync(path.dirname(beta.path)).length, 1);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Versioned weekly time/activity snapshot store (issue #2052).
|
|
3
|
+
*
|
|
4
|
+
* Files live at `<memoryDir>/activity/weekly/<ns>/<week>--<identity>.json`,
|
|
5
|
+
* outside recall fallback dirs. Same inputs skip rewrite by content hash.
|
|
6
|
+
* A new sourceRevision or configHash is a new file.
|
|
7
|
+
*/
|
|
8
|
+
import { randomBytes } from "node:crypto";
|
|
9
|
+
import { mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
|
|
12
|
+
import { namespaceIdentityToken } from "../../namespaces/identity.js";
|
|
13
|
+
import { hashActivityBody, isValidActivityDate } from "../digest.js";
|
|
14
|
+
import type { WeeklyActivitySummary } from "./weekly.js";
|
|
15
|
+
|
|
16
|
+
export const WEEKLY_SNAPSHOT_FORMAT_VERSION = 1;
|
|
17
|
+
export const WEEKLY_SNAPSHOT_DIR = path.join("activity", "weekly");
|
|
18
|
+
|
|
19
|
+
export interface PersistWeeklySnapshotInput {
|
|
20
|
+
memoryDir: string;
|
|
21
|
+
namespace: string;
|
|
22
|
+
summary: WeeklyActivitySummary;
|
|
23
|
+
sourceRevision: string;
|
|
24
|
+
configHash: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface PersistWeeklySnapshotResult {
|
|
28
|
+
path: string;
|
|
29
|
+
written: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function requireToken(value: string, name: string): string {
|
|
33
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
34
|
+
throw new TypeError(`${name} must be a non-empty string`);
|
|
35
|
+
}
|
|
36
|
+
return value.trim();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function weeklySnapshotPath(input: PersistWeeklySnapshotInput): string {
|
|
40
|
+
const memoryDir = requireToken(input.memoryDir, "memoryDir");
|
|
41
|
+
const namespace = requireToken(input.namespace, "namespace");
|
|
42
|
+
const sourceRevision = requireToken(input.sourceRevision, "sourceRevision");
|
|
43
|
+
const configHash = requireToken(input.configHash, "configHash");
|
|
44
|
+
const weekStartUtc = input.summary?.weekStartUtc;
|
|
45
|
+
if (typeof weekStartUtc !== "string") {
|
|
46
|
+
throw new TypeError("summary.weekStartUtc must be an ISO timestamp");
|
|
47
|
+
}
|
|
48
|
+
const weekDate = weekStartUtc.slice(0, 10);
|
|
49
|
+
if (!isValidActivityDate(weekDate)) {
|
|
50
|
+
throw new RangeError("summary.weekStartUtc must be an ISO timestamp");
|
|
51
|
+
}
|
|
52
|
+
const identity = hashActivityBody(
|
|
53
|
+
`${input.summary.weekStartUtc}\0${input.summary.weekEndUtc}\0${sourceRevision}\0${configHash}`,
|
|
54
|
+
);
|
|
55
|
+
return path.join(
|
|
56
|
+
path.resolve(memoryDir),
|
|
57
|
+
WEEKLY_SNAPSHOT_DIR,
|
|
58
|
+
namespaceIdentityToken(namespace),
|
|
59
|
+
`${weekDate}--${identity}.json`,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Persist one weekly snapshot. Same bytes are a no-op. */
|
|
64
|
+
export function persistWeeklySnapshot(input: PersistWeeklySnapshotInput): PersistWeeklySnapshotResult {
|
|
65
|
+
const namespace = requireToken(input.namespace, "namespace");
|
|
66
|
+
const sourceRevision = requireToken(input.sourceRevision, "sourceRevision");
|
|
67
|
+
const configHash = requireToken(input.configHash, "configHash");
|
|
68
|
+
const filePath = weeklySnapshotPath(input);
|
|
69
|
+
const payload = {
|
|
70
|
+
formatVersion: WEEKLY_SNAPSHOT_FORMAT_VERSION,
|
|
71
|
+
namespace,
|
|
72
|
+
sourceRevision,
|
|
73
|
+
configHash,
|
|
74
|
+
summary: input.summary,
|
|
75
|
+
};
|
|
76
|
+
const contentHash = hashActivityBody(JSON.stringify(payload));
|
|
77
|
+
const text = `${JSON.stringify({ ...payload, contentHash })}\n`;
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
if (readFileSync(filePath, "utf8") === text) {
|
|
81
|
+
return { path: filePath, written: false };
|
|
82
|
+
}
|
|
83
|
+
} catch (error) {
|
|
84
|
+
if (!(typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT")) {
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
mkdirSync(path.dirname(filePath), { recursive: true, mode: 0o700 });
|
|
90
|
+
const tmpPath = `${filePath}.${process.pid}.${randomBytes(8).toString("hex")}.tmp`;
|
|
91
|
+
writeFileSync(tmpPath, text, { encoding: "utf8", mode: 0o600 });
|
|
92
|
+
try {
|
|
93
|
+
renameSync(tmpPath, filePath);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
try {
|
|
96
|
+
unlinkSync(tmpPath);
|
|
97
|
+
} catch {
|
|
98
|
+
// Best-effort cleanup of the temp file.
|
|
99
|
+
}
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
return { path: filePath, written: true };
|
|
103
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
|
|
4
|
+
import type { TimelineCard, TimelineCategory } from "./types.js";
|
|
5
|
+
import { buildWeeklyActivitySummary } from "./weekly.js";
|
|
6
|
+
|
|
7
|
+
const HOUR = 3_600_000;
|
|
8
|
+
const DAY = 86_400_000;
|
|
9
|
+
const WEEK_START = "2026-07-13T00:00:00.000Z";
|
|
10
|
+
const WEEK_END = "2026-07-20T00:00:00.000Z";
|
|
11
|
+
const WEEK_MS = 7 * DAY;
|
|
12
|
+
|
|
13
|
+
const CATEGORIES: TimelineCategory[] = [
|
|
14
|
+
{ id: "alpha", name: "Alpha", color: "#111111", description: "a", order: 1 },
|
|
15
|
+
{ id: "beta", name: "Beta", color: "#222222", description: "b", order: 2 },
|
|
16
|
+
{ id: "development", name: "Development", color: "#333333", description: "d", order: 3 },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
function card(
|
|
20
|
+
overrides: Partial<TimelineCard> & Pick<TimelineCard, "id" | "startUtc" | "endUtc">,
|
|
21
|
+
): TimelineCard {
|
|
22
|
+
return {
|
|
23
|
+
kind: "activity",
|
|
24
|
+
title: "Untitled",
|
|
25
|
+
summary: "none",
|
|
26
|
+
categoryId: "development",
|
|
27
|
+
confidence: 1,
|
|
28
|
+
dayKey: overrides.startUtc.slice(0, 10),
|
|
29
|
+
timezone: "UTC",
|
|
30
|
+
machine: "ws-a",
|
|
31
|
+
evidenceIds: [],
|
|
32
|
+
evidenceRange: null,
|
|
33
|
+
...overrides,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function options(overrides: Partial<Parameters<typeof buildWeeklyActivitySummary>[1]> = {}) {
|
|
38
|
+
return {
|
|
39
|
+
timezone: "UTC",
|
|
40
|
+
weekStartUtc: WEEK_START,
|
|
41
|
+
weekEndUtc: WEEK_END,
|
|
42
|
+
categories: CATEGORIES,
|
|
43
|
+
...overrides,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
test("empty week reports zeros, full gap, and previous period unavailable", () => {
|
|
48
|
+
const summary = buildWeeklyActivitySummary([], options());
|
|
49
|
+
assert.equal(summary.formatVersion, 1);
|
|
50
|
+
assert.equal(summary.activeMs, 0);
|
|
51
|
+
assert.equal(summary.idleMs, 0);
|
|
52
|
+
assert.equal(summary.pauseMs, 0);
|
|
53
|
+
assert.equal(summary.unclassifiedMs, 0);
|
|
54
|
+
assert.equal(summary.gapMs, WEEK_MS);
|
|
55
|
+
assert.deepEqual(
|
|
56
|
+
summary.categories.map((row) => row.durationMs),
|
|
57
|
+
[0, 0, 0],
|
|
58
|
+
);
|
|
59
|
+
assert.equal(summary.days.length, 7);
|
|
60
|
+
assert.ok(summary.days.every((day) => day.gapMs === DAY && day.activeMs === 0));
|
|
61
|
+
assert.deepEqual(summary.previousPeriod, { available: false });
|
|
62
|
+
assert.equal("durationMs" in summary.previousPeriod, false);
|
|
63
|
+
const blob = JSON.stringify(summary);
|
|
64
|
+
assert.equal(/productivity|mood|intent|score/i.test(blob), false);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test("exact midnight boundary is not double-counted", () => {
|
|
68
|
+
const summary = buildWeeklyActivitySummary(
|
|
69
|
+
[
|
|
70
|
+
card({
|
|
71
|
+
id: "ends-at-midnight",
|
|
72
|
+
categoryId: "alpha",
|
|
73
|
+
startUtc: "2026-07-13T23:00:00.000Z",
|
|
74
|
+
endUtc: "2026-07-14T00:00:00.000Z",
|
|
75
|
+
}),
|
|
76
|
+
card({
|
|
77
|
+
id: "starts-at-midnight",
|
|
78
|
+
categoryId: "beta",
|
|
79
|
+
startUtc: "2026-07-14T00:00:00.000Z",
|
|
80
|
+
endUtc: "2026-07-14T01:00:00.000Z",
|
|
81
|
+
}),
|
|
82
|
+
card({
|
|
83
|
+
id: "before-week",
|
|
84
|
+
categoryId: "development",
|
|
85
|
+
startUtc: "2026-07-12T23:00:00.000Z",
|
|
86
|
+
endUtc: WEEK_START,
|
|
87
|
+
}),
|
|
88
|
+
card({
|
|
89
|
+
id: "after-week",
|
|
90
|
+
categoryId: "development",
|
|
91
|
+
startUtc: WEEK_END,
|
|
92
|
+
endUtc: "2026-07-20T01:00:00.000Z",
|
|
93
|
+
}),
|
|
94
|
+
],
|
|
95
|
+
options(),
|
|
96
|
+
);
|
|
97
|
+
assert.equal(summary.categories.find((row) => row.categoryId === "alpha")?.durationMs, HOUR);
|
|
98
|
+
assert.equal(summary.categories.find((row) => row.categoryId === "beta")?.durationMs, HOUR);
|
|
99
|
+
assert.equal(summary.categories.find((row) => row.categoryId === "development")?.durationMs, 0);
|
|
100
|
+
assert.equal(summary.activeMs, 2 * HOUR);
|
|
101
|
+
|
|
102
|
+
const day13 = summary.days.find((day) => day.date === "2026-07-13");
|
|
103
|
+
const day14 = summary.days.find((day) => day.date === "2026-07-14");
|
|
104
|
+
assert.equal(day13?.categories.find((row) => row.categoryId === "alpha")?.durationMs, HOUR);
|
|
105
|
+
assert.equal(day13?.categories.find((row) => row.categoryId === "beta")?.durationMs, 0);
|
|
106
|
+
assert.equal(day14?.categories.find((row) => row.categoryId === "beta")?.durationMs, HOUR);
|
|
107
|
+
assert.equal(day14?.categories.find((row) => row.categoryId === "alpha")?.durationMs, 0);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test("idle and pause kinds are distinct from active", () => {
|
|
111
|
+
const summary = buildWeeklyActivitySummary(
|
|
112
|
+
[
|
|
113
|
+
card({
|
|
114
|
+
id: "work",
|
|
115
|
+
startUtc: "2026-07-13T10:00:00.000Z",
|
|
116
|
+
endUtc: "2026-07-13T11:00:00.000Z",
|
|
117
|
+
}),
|
|
118
|
+
card({
|
|
119
|
+
id: "idle",
|
|
120
|
+
kind: "idle",
|
|
121
|
+
categoryId: "alpha",
|
|
122
|
+
startUtc: "2026-07-13T11:00:00.000Z",
|
|
123
|
+
endUtc: "2026-07-13T11:30:00.000Z",
|
|
124
|
+
}),
|
|
125
|
+
card({
|
|
126
|
+
id: "pause",
|
|
127
|
+
kind: "pause",
|
|
128
|
+
categoryId: "beta",
|
|
129
|
+
startUtc: "2026-07-13T11:30:00.000Z",
|
|
130
|
+
endUtc: "2026-07-13T11:45:00.000Z",
|
|
131
|
+
}),
|
|
132
|
+
],
|
|
133
|
+
options(),
|
|
134
|
+
);
|
|
135
|
+
assert.equal(summary.activeMs, HOUR);
|
|
136
|
+
assert.equal(summary.idleMs, 30 * 60_000);
|
|
137
|
+
assert.equal(summary.pauseMs, 15 * 60_000);
|
|
138
|
+
assert.equal(summary.gapMs, WEEK_MS - HOUR - 30 * 60_000 - 15 * 60_000);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test("unknown category is unclassified, not a silent zero row", () => {
|
|
142
|
+
const summary = buildWeeklyActivitySummary(
|
|
143
|
+
[
|
|
144
|
+
card({
|
|
145
|
+
id: "mystery",
|
|
146
|
+
categoryId: "not-configured",
|
|
147
|
+
startUtc: "2026-07-15T08:00:00.000Z",
|
|
148
|
+
endUtc: "2026-07-15T09:00:00.000Z",
|
|
149
|
+
}),
|
|
150
|
+
],
|
|
151
|
+
options(),
|
|
152
|
+
);
|
|
153
|
+
assert.equal(summary.unclassifiedMs, HOUR);
|
|
154
|
+
assert.equal(summary.activeMs, HOUR);
|
|
155
|
+
assert.equal(summary.categories.some((row) => row.categoryId === "not-configured"), false);
|
|
156
|
+
assert.ok(summary.categories.every((row) => row.durationMs === 0));
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test("configured category with no cards stays at zero", () => {
|
|
160
|
+
const summary = buildWeeklyActivitySummary(
|
|
161
|
+
[
|
|
162
|
+
card({
|
|
163
|
+
id: "only-dev",
|
|
164
|
+
categoryId: "development",
|
|
165
|
+
startUtc: "2026-07-16T12:00:00.000Z",
|
|
166
|
+
endUtc: "2026-07-16T13:00:00.000Z",
|
|
167
|
+
}),
|
|
168
|
+
],
|
|
169
|
+
options(),
|
|
170
|
+
);
|
|
171
|
+
const byId = Object.fromEntries(summary.categories.map((row) => [row.categoryId, row.durationMs]));
|
|
172
|
+
assert.equal(byId.development, HOUR);
|
|
173
|
+
assert.equal(byId.alpha, 0);
|
|
174
|
+
assert.equal(byId.beta, 0);
|
|
175
|
+
assert.equal(summary.categories.length, 3);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
test("equal durations sort by categoryId ascending", () => {
|
|
179
|
+
const summary = buildWeeklyActivitySummary(
|
|
180
|
+
[
|
|
181
|
+
card({
|
|
182
|
+
id: "a",
|
|
183
|
+
categoryId: "alpha",
|
|
184
|
+
startUtc: "2026-07-13T09:00:00.000Z",
|
|
185
|
+
endUtc: "2026-07-13T10:00:00.000Z",
|
|
186
|
+
}),
|
|
187
|
+
card({
|
|
188
|
+
id: "b",
|
|
189
|
+
categoryId: "beta",
|
|
190
|
+
startUtc: "2026-07-13T10:00:00.000Z",
|
|
191
|
+
endUtc: "2026-07-13T12:00:00.000Z",
|
|
192
|
+
}),
|
|
193
|
+
card({
|
|
194
|
+
id: "d",
|
|
195
|
+
categoryId: "development",
|
|
196
|
+
startUtc: "2026-07-13T12:00:00.000Z",
|
|
197
|
+
endUtc: "2026-07-13T14:00:00.000Z",
|
|
198
|
+
}),
|
|
199
|
+
],
|
|
200
|
+
options(),
|
|
201
|
+
);
|
|
202
|
+
assert.deepEqual(
|
|
203
|
+
summary.categories.map((row) => row.categoryId),
|
|
204
|
+
["beta", "development", "alpha"],
|
|
205
|
+
);
|
|
206
|
+
assert.deepEqual(
|
|
207
|
+
summary.categories.map((row) => row.durationMs),
|
|
208
|
+
[2 * HOUR, 2 * HOUR, HOUR],
|
|
209
|
+
);
|
|
210
|
+
const day13 = summary.days.find((day) => day.date === "2026-07-13");
|
|
211
|
+
assert.deepEqual(
|
|
212
|
+
day13?.categories.map((row) => row.categoryId),
|
|
213
|
+
["beta", "development", "alpha"],
|
|
214
|
+
);
|
|
215
|
+
});
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic weekly time/activity summary over timeline cards (issue #2052).
|
|
3
|
+
*
|
|
4
|
+
* Pure: cards + week bounds + category registry in, snapshot out. Half-open
|
|
5
|
+
* UTC [weekStart, weekEnd). Previous-period comparison is omitted in this
|
|
6
|
+
* slice and marked unavailable, never a silent zero. Later surfaces
|
|
7
|
+
* (CLI/MCP/HTTP/UI) consume this shape; they are not built here.
|
|
8
|
+
*/
|
|
9
|
+
import { parseFlexibleIsoTimestamp } from "../../utils/iso-timestamp.js";
|
|
10
|
+
import { activityDayWindow, assertValidTimezone } from "../digest.js";
|
|
11
|
+
import type { TimelineCard, TimelineCardKind, TimelineCategory } from "./types.js";
|
|
12
|
+
|
|
13
|
+
export const WEEKLY_ACTIVITY_FORMAT_VERSION = 1;
|
|
14
|
+
|
|
15
|
+
export interface WeeklyActivityOptions {
|
|
16
|
+
timezone: string;
|
|
17
|
+
weekStartUtc: string;
|
|
18
|
+
weekEndUtc: string;
|
|
19
|
+
categories: readonly TimelineCategory[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface WeeklyCategoryTotal {
|
|
23
|
+
categoryId: string;
|
|
24
|
+
durationMs: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface WeeklyKindTotals {
|
|
28
|
+
activeMs: number;
|
|
29
|
+
idleMs: number;
|
|
30
|
+
pauseMs: number;
|
|
31
|
+
gapMs: number;
|
|
32
|
+
unclassifiedMs: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface WeeklyDayTotal extends WeeklyKindTotals {
|
|
36
|
+
date: string;
|
|
37
|
+
startUtc: string;
|
|
38
|
+
endUtc: string;
|
|
39
|
+
categories: WeeklyCategoryTotal[];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** First slice never computes a prior week; the field is present so callers cannot treat absence as zero. */
|
|
43
|
+
export interface WeeklyPreviousPeriodUnavailable {
|
|
44
|
+
available: false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface WeeklyActivitySummary extends WeeklyKindTotals {
|
|
48
|
+
formatVersion: number;
|
|
49
|
+
timezone: string;
|
|
50
|
+
weekStartUtc: string;
|
|
51
|
+
weekEndUtc: string;
|
|
52
|
+
categories: WeeklyCategoryTotal[];
|
|
53
|
+
days: WeeklyDayTotal[];
|
|
54
|
+
previousPeriod: WeeklyPreviousPeriodUnavailable;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface Acc extends WeeklyKindTotals {
|
|
58
|
+
byCategory: Map<string, number>;
|
|
59
|
+
intervals: Array<[number, number]>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function parseBound(value: string, label: string): number {
|
|
63
|
+
const ms = parseFlexibleIsoTimestamp(value);
|
|
64
|
+
if (ms === null) {
|
|
65
|
+
throw new RangeError(`${label} is not a valid ISO timestamp`);
|
|
66
|
+
}
|
|
67
|
+
return ms;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function clip(start: number, end: number, winStart: number, winEnd: number): [number, number] | null {
|
|
71
|
+
const clippedStart = Math.max(start, winStart);
|
|
72
|
+
const clippedEnd = Math.min(end, winEnd);
|
|
73
|
+
return clippedEnd > clippedStart ? [clippedStart, clippedEnd] : null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function unionDuration(intervals: readonly (readonly [number, number])[]): number {
|
|
77
|
+
const sorted = [...intervals].sort((a, b) => a[0] - b[0] || a[1] - b[1]);
|
|
78
|
+
let total = 0;
|
|
79
|
+
let curStart = Number.NaN;
|
|
80
|
+
let curEnd = Number.NaN;
|
|
81
|
+
for (const [start, end] of sorted) {
|
|
82
|
+
if (!Number.isFinite(curStart)) {
|
|
83
|
+
curStart = start;
|
|
84
|
+
curEnd = end;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (start <= curEnd) {
|
|
88
|
+
curEnd = Math.max(curEnd, end);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
total += curEnd - curStart;
|
|
92
|
+
curStart = start;
|
|
93
|
+
curEnd = end;
|
|
94
|
+
}
|
|
95
|
+
if (Number.isFinite(curStart)) total += curEnd - curStart;
|
|
96
|
+
return total;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function localDateOf(ms: number, timezone: string): string {
|
|
100
|
+
const parts = new Intl.DateTimeFormat("en-CA", {
|
|
101
|
+
timeZone: timezone,
|
|
102
|
+
year: "numeric",
|
|
103
|
+
month: "2-digit",
|
|
104
|
+
day: "2-digit",
|
|
105
|
+
}).formatToParts(new Date(ms));
|
|
106
|
+
const get = (type: string): string => parts.find((part) => part.type === type)?.value ?? "";
|
|
107
|
+
return `${get("year")}-${get("month")}-${get("day")}`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function shiftIsoDate(date: string, days: number): string {
|
|
111
|
+
const parsed = new Date(`${date}T00:00:00Z`);
|
|
112
|
+
parsed.setUTCDate(parsed.getUTCDate() + days);
|
|
113
|
+
return parsed.toISOString().slice(0, 10);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function daysOverlappingWeek(
|
|
117
|
+
weekStartMs: number,
|
|
118
|
+
weekEndMs: number,
|
|
119
|
+
timezone: string,
|
|
120
|
+
): Array<{ date: string; startMs: number; endMs: number }> {
|
|
121
|
+
if (weekEndMs <= weekStartMs) return [];
|
|
122
|
+
let date = localDateOf(weekStartMs, timezone);
|
|
123
|
+
let window = activityDayWindow(date, timezone);
|
|
124
|
+
if (Date.parse(window.startUtc) > weekStartMs) {
|
|
125
|
+
date = shiftIsoDate(date, -1);
|
|
126
|
+
window = activityDayWindow(date, timezone);
|
|
127
|
+
}
|
|
128
|
+
const days: Array<{ date: string; startMs: number; endMs: number }> = [];
|
|
129
|
+
while (Date.parse(window.startUtc) < weekEndMs) {
|
|
130
|
+
const startMs = Math.max(Date.parse(window.startUtc), weekStartMs);
|
|
131
|
+
const endMs = Math.min(Date.parse(window.endUtc), weekEndMs);
|
|
132
|
+
if (endMs > startMs) days.push({ date, startMs, endMs });
|
|
133
|
+
date = shiftIsoDate(date, 1);
|
|
134
|
+
window = activityDayWindow(date, timezone);
|
|
135
|
+
}
|
|
136
|
+
return days;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function emptyAcc(categoryIds: readonly string[]): Acc {
|
|
140
|
+
return {
|
|
141
|
+
activeMs: 0,
|
|
142
|
+
idleMs: 0,
|
|
143
|
+
pauseMs: 0,
|
|
144
|
+
gapMs: 0,
|
|
145
|
+
unclassifiedMs: 0,
|
|
146
|
+
byCategory: new Map(categoryIds.map((id) => [id, 0])),
|
|
147
|
+
intervals: [],
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function addClipped(acc: Acc, kind: TimelineCardKind, categoryId: string, known: ReadonlySet<string>, start: number, end: number): void {
|
|
152
|
+
const duration = end - start;
|
|
153
|
+
acc.intervals.push([start, end]);
|
|
154
|
+
if (kind === "idle") acc.idleMs += duration;
|
|
155
|
+
else if (kind === "pause") acc.pauseMs += duration;
|
|
156
|
+
else acc.activeMs += duration;
|
|
157
|
+
if (known.has(categoryId)) {
|
|
158
|
+
acc.byCategory.set(categoryId, (acc.byCategory.get(categoryId) ?? 0) + duration);
|
|
159
|
+
} else {
|
|
160
|
+
acc.unclassifiedMs += duration;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function sortCategoryTotals(byCategory: Map<string, number>): WeeklyCategoryTotal[] {
|
|
165
|
+
return [...byCategory.entries()]
|
|
166
|
+
.map(([categoryId, durationMs]) => ({ categoryId, durationMs }))
|
|
167
|
+
.sort((a, b) => b.durationMs - a.durationMs || (a.categoryId < b.categoryId ? -1 : a.categoryId > b.categoryId ? 1 : 0));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function finish(acc: Acc, windowMs: number): WeeklyKindTotals & { categories: WeeklyCategoryTotal[] } {
|
|
171
|
+
const covered = unionDuration(acc.intervals);
|
|
172
|
+
return {
|
|
173
|
+
activeMs: acc.activeMs,
|
|
174
|
+
idleMs: acc.idleMs,
|
|
175
|
+
pauseMs: acc.pauseMs,
|
|
176
|
+
gapMs: Math.max(0, windowMs - covered),
|
|
177
|
+
unclassifiedMs: acc.unclassifiedMs,
|
|
178
|
+
categories: sortCategoryTotals(acc.byCategory),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Build a time/activity summary for one half-open week. Pure. */
|
|
183
|
+
export function buildWeeklyActivitySummary(
|
|
184
|
+
cards: readonly TimelineCard[],
|
|
185
|
+
options: WeeklyActivityOptions,
|
|
186
|
+
): WeeklyActivitySummary {
|
|
187
|
+
assertValidTimezone(options.timezone);
|
|
188
|
+
const weekStartMs = parseBound(options.weekStartUtc, "weekStartUtc");
|
|
189
|
+
const weekEndMs = parseBound(options.weekEndUtc, "weekEndUtc");
|
|
190
|
+
if (weekStartMs > weekEndMs) {
|
|
191
|
+
throw new RangeError("reversed range: weekStartUtc must be <= weekEndUtc");
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const categoryIds = options.categories.map((category) => category.id);
|
|
195
|
+
const known = new Set(categoryIds);
|
|
196
|
+
const week = emptyAcc(categoryIds);
|
|
197
|
+
const dayWindows = daysOverlappingWeek(weekStartMs, weekEndMs, options.timezone);
|
|
198
|
+
const dayAccs = dayWindows.map(() => emptyAcc(categoryIds));
|
|
199
|
+
|
|
200
|
+
for (const card of cards) {
|
|
201
|
+
const start = Date.parse(card.startUtc);
|
|
202
|
+
const end = Date.parse(card.endUtc);
|
|
203
|
+
if (!Number.isFinite(start) || !Number.isFinite(end) || end <= start) continue;
|
|
204
|
+
const weekClip = clip(start, end, weekStartMs, weekEndMs);
|
|
205
|
+
if (!weekClip) continue;
|
|
206
|
+
addClipped(week, card.kind, card.categoryId, known, weekClip[0], weekClip[1]);
|
|
207
|
+
for (let i = 0; i < dayWindows.length; i++) {
|
|
208
|
+
const day = dayWindows[i];
|
|
209
|
+
const dayClip = clip(start, end, day.startMs, day.endMs);
|
|
210
|
+
if (dayClip) addClipped(dayAccs[i], card.kind, card.categoryId, known, dayClip[0], dayClip[1]);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const weekTotals = finish(week, weekEndMs - weekStartMs);
|
|
215
|
+
const days: WeeklyDayTotal[] = dayWindows.map((day, i) => {
|
|
216
|
+
const totals = finish(dayAccs[i], day.endMs - day.startMs);
|
|
217
|
+
return {
|
|
218
|
+
date: day.date,
|
|
219
|
+
startUtc: new Date(day.startMs).toISOString(),
|
|
220
|
+
endUtc: new Date(day.endMs).toISOString(),
|
|
221
|
+
...totals,
|
|
222
|
+
};
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
formatVersion: WEEKLY_ACTIVITY_FORMAT_VERSION,
|
|
227
|
+
timezone: options.timezone,
|
|
228
|
+
weekStartUtc: new Date(weekStartMs).toISOString(),
|
|
229
|
+
weekEndUtc: new Date(weekEndMs).toISOString(),
|
|
230
|
+
...weekTotals,
|
|
231
|
+
days,
|
|
232
|
+
previousPeriod: { available: false },
|
|
233
|
+
};
|
|
234
|
+
}
|
package/src/activity/types.ts
CHANGED
|
@@ -96,9 +96,23 @@ export interface ActivitySourceConfig {
|
|
|
96
96
|
token?: string;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
/** Opt-in daily journal settings (issue #1984). Default off. */
|
|
100
|
+
export interface ActivityTimelineJournalConfig {
|
|
101
|
+
enabled: boolean;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Opt-in timeline Q&A range/search settings (issue #1983 PR1). Default off. */
|
|
105
|
+
export interface ActivityTimelineQaConfig {
|
|
106
|
+
enabled: boolean;
|
|
107
|
+
/** Inclusive max half-open range length in 24h days. Integer 1..366. */
|
|
108
|
+
maxRangeDays: number;
|
|
109
|
+
}
|
|
110
|
+
|
|
99
111
|
/** Opt-in timeline-card derivation settings (issue #2049). Default off. */
|
|
100
112
|
export interface ActivityTimelineConfig {
|
|
101
113
|
enabled: boolean;
|
|
114
|
+
journal: ActivityTimelineJournalConfig;
|
|
115
|
+
qa: ActivityTimelineQaConfig;
|
|
102
116
|
}
|
|
103
117
|
|
|
104
118
|
/** Opt-in activity synchronization + trust-gated extraction settings. */
|