@remnic/core 9.66.1 → 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 +1 -1
- package/dist/access-admin-ops-surface.js +26 -26
- package/dist/access-audit.js +2 -2
- package/dist/access-authorization-probe.d.ts +1 -1
- package/dist/access-authorization-probe.js +27 -27
- package/dist/access-boundary.d.ts +1 -1
- package/dist/access-boundary.js +26 -26
- package/dist/access-cli.js +90 -88
- package/dist/access-cli.js.map +1 -1
- package/dist/access-extraction-force-flush.d.ts +1 -1
- package/dist/access-extraction-force-flush.js +26 -26
- package/dist/access-http-lcm-compaction.d.ts +1 -1
- package/dist/access-http-lifecycle-flush.d.ts +1 -1
- package/dist/access-http-offline-stream.d.ts +1 -1
- package/dist/access-http-query.js +28 -28
- package/dist/access-http.d.ts +2 -2
- package/dist/access-http.js +41 -41
- package/dist/access-identity-continuity-surface.js +26 -26
- package/dist/access-lcm-surface.d.ts +1 -1
- package/dist/access-lcm-surface.js +26 -26
- package/dist/access-mcp.d.ts +1 -1
- package/dist/access-mcp.js +33 -33
- package/dist/access-namespace-preflight.js +26 -26
- package/dist/access-observe-write-surface.d.ts +1 -1
- package/dist/access-observe-write-surface.js +26 -26
- package/dist/access-operations-batch.js +28 -28
- package/dist/access-operations.d.ts +6 -6
- package/dist/access-operations.js +32 -32
- package/dist/access-recall-concurrency.d.ts +1 -1
- package/dist/access-recall-concurrency.js +26 -26
- package/dist/access-recall-response.d.ts +1 -1
- package/dist/access-recall-response.js +26 -26
- package/dist/access-recall-surface.d.ts +1 -1
- package/dist/access-recall-surface.js +26 -26
- package/dist/access-schema.d.ts +89 -89
- package/dist/access-service-helpers.d.ts +1 -1
- package/dist/access-service.d.ts +1 -1
- package/dist/access-service.js +26 -26
- package/dist/access-surface-catalog.d.ts +1 -1
- package/dist/access-surface-catalog.js +28 -28
- package/dist/active-recall.js +3 -3
- package/dist/adapters/index.js +4 -4
- package/dist/adapters/registry.js +2 -2
- package/dist/briefing.js +10 -10
- package/dist/buffer.js +4 -4
- package/dist/causal-behavior.js +2 -2
- package/dist/causal-chain.js +2 -2
- package/dist/causal-consolidation.js +13 -13
- package/dist/causal-retrieval.js +2 -2
- package/dist/causal-trajectory-graph.js +2 -2
- package/dist/causal-trajectory.js +1 -1
- package/dist/{chunk-LYUUA6QB.js → chunk-25OLNWYG.js} +2 -2
- package/dist/{chunk-2X6BGKQL.js → chunk-2QSGJTDG.js} +10 -10
- package/dist/{chunk-ZZZWEDF4.js → chunk-2VZHB5US.js} +2 -2
- package/dist/{chunk-JKTV3JNX.js → chunk-36HJ36FK.js} +3 -3
- package/dist/{chunk-XKNHFDTT.js → chunk-3A2Z4OOS.js} +2 -2
- package/dist/{chunk-TCF4MU7L.js → chunk-47WWTCJY.js} +1001 -101
- package/dist/chunk-47WWTCJY.js.map +1 -0
- package/dist/{chunk-RDGKVH6T.js → chunk-4NKIGSJM.js} +2 -2
- package/dist/{chunk-QBNE55VA.js → chunk-4PG2CKI6.js} +2 -2
- package/dist/{chunk-S4CDUXQY.js → chunk-6545JDIM.js} +2 -2
- package/dist/{chunk-2FA7U5XY.js → chunk-65HXVEVG.js} +2 -2
- package/dist/{chunk-U6NGKS32.js → chunk-6BYJQ3L2.js} +8 -8
- package/dist/{chunk-OMX6TKXH.js → chunk-6PUF7LUO.js} +2 -2
- package/dist/{chunk-TVVEYCNW.js → chunk-7K5Q6COX.js} +4 -4
- package/dist/{chunk-VG4SSPAW.js → chunk-AI5M4FVQ.js} +2 -2
- package/dist/{chunk-MUEGIKKY.js → chunk-B4B3QDV3.js} +21 -20
- package/dist/chunk-B4B3QDV3.js.map +1 -0
- package/dist/{chunk-YMOPYG3K.js → chunk-BIJAWZYW.js} +6 -6
- package/dist/{chunk-M5ERTI4I.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-EH65UV2Z.js → chunk-C3ZYZKDJ.js} +2 -2
- package/dist/{chunk-NFP4KPTA.js → chunk-CDLPF3PX.js} +2 -2
- package/dist/{chunk-FFUMTH27.js → chunk-CQ6IWZDI.js} +2 -2
- package/dist/{chunk-KWIGDKM2.js → chunk-D2YNNDML.js} +2 -2
- package/dist/{chunk-65JOGLIS.js → chunk-D3DUA64S.js} +2 -2
- package/dist/{chunk-2ITZ74A6.js → chunk-DSEHPUID.js} +11 -11
- package/dist/chunk-E4X2YX2F.js +22 -0
- package/dist/chunk-E4X2YX2F.js.map +1 -0
- package/dist/{chunk-AF5H7TKI.js → chunk-EH7BNIUN.js} +2 -2
- package/dist/{chunk-IGZCAHFL.js → chunk-EQRD4NMH.js} +2 -2
- package/dist/{chunk-CX4OLNIH.js → chunk-ER2UPUMG.js} +2 -2
- package/dist/{chunk-SZMYGDSM.js → chunk-F2JXJABQ.js} +2 -2
- package/dist/{chunk-CHGG74CY.js → chunk-F4W5HTED.js} +2 -2
- package/dist/{chunk-H2IRSXZN.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-OJUEUQDJ.js → chunk-JJ6ZEFXC.js} +2 -2
- package/dist/{chunk-U65VJSCJ.js → chunk-JMXHVJ2V.js} +10 -10
- package/dist/{chunk-NACLNNFQ.js → chunk-KSZKQTZS.js} +2 -2
- package/dist/{chunk-TCQRIIIN.js → chunk-LSR5LQXN.js} +2 -2
- package/dist/chunk-MAG6M3B6.js +51 -0
- package/dist/chunk-MAG6M3B6.js.map +1 -0
- package/dist/{chunk-B4AOWRYF.js → chunk-NTFXBILO.js} +4 -4
- package/dist/{chunk-2PSX5BJU.js → chunk-NZPFCP5A.js} +2 -2
- package/dist/{chunk-C5IUOBCN.js → chunk-OERZXNSK.js} +2 -2
- package/dist/{chunk-ZPS724LT.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-GAJK3DQ5.js → chunk-PRRUK2ZH.js} +2 -2
- package/dist/{chunk-TBCDF556.js → chunk-PW3GKWH3.js} +3 -3
- package/dist/chunk-Q3SHEAXR.js +80 -0
- package/dist/chunk-Q3SHEAXR.js.map +1 -0
- package/dist/{chunk-KI64TTBL.js → chunk-R2Q6FTOX.js} +2 -2
- package/dist/{chunk-KJXCD7VR.js → chunk-RCPKBW7K.js} +4 -4
- package/dist/{chunk-INUBU6I5.js → chunk-RH3XLQG4.js} +2 -2
- package/dist/{chunk-JBPKEARU.js → chunk-RKNJBZ55.js} +4 -4
- package/dist/{chunk-NSTNGMSS.js → chunk-U4HZEW2B.js} +5 -5
- package/dist/{chunk-XOHYGIWF.js → chunk-UHQE37NI.js} +2 -2
- package/dist/{chunk-D3UXGE5D.js → chunk-UMZUKOJU.js} +7 -7
- package/dist/{chunk-S4Z2OBTX.js → chunk-UVYL5G7A.js} +3 -3
- package/dist/{chunk-4XLTUR6R.js → chunk-VKDBDJIX.js} +3 -3
- package/dist/{chunk-UW4RYPWC.js → chunk-VSMSYDIH.js} +2 -2
- package/dist/{chunk-LJABGXC4.js → chunk-W5IYHQA5.js} +3 -3
- package/dist/{chunk-7UOXCCCI.js → chunk-WKWY7YF3.js} +2 -2
- package/dist/{chunk-YWPLOJ7T.js → chunk-Y2YM4C75.js} +2 -2
- package/dist/{chunk-NUF7VSEX.js → chunk-YZ5VC2JJ.js} +2 -2
- package/dist/{chunk-EWKVYCFP.js → chunk-ZBIEX4XN.js} +1 -1
- package/dist/{chunk-GBEOUCBB.js → chunk-ZMVW2HJJ.js} +2 -2
- package/dist/{chunk-RPIS5FQ7.js → chunk-ZXROBS53.js} +44 -44
- package/dist/{cli-CsfFMe6n.d.ts → cli-BOuEb4Ia.d.ts} +1 -1
- package/dist/cli.d.ts +2 -2
- package/dist/cli.js +61 -61
- package/dist/coding/export-okf-codegraph.js +10 -10
- package/dist/coding/pre-action-gate.js +2 -2
- package/dist/compounding/engine.js +10 -10
- package/dist/config.js +3 -3
- package/dist/connectors/codex-materialize-runner.js +10 -10
- package/dist/connectors/index.js +10 -10
- package/dist/convergence-refresh.js +12 -12
- package/dist/corpus-watermark.js +12 -12
- package/dist/entity-retrieval.js +10 -10
- package/dist/external-wiki-access.d.ts +1 -1
- package/dist/external-wiki-access.js +27 -27
- package/dist/external-wiki-mcp-tools.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.js +13 -13
- 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-snapshot.js +3 -3
- package/dist/graph.js +3 -3
- package/dist/harmonic-retrieval.js +1 -1
- package/dist/index.d.ts +887 -681
- package/dist/index.js +161 -108
- package/dist/lcm/engine.js +3 -3
- package/dist/lcm/index.js +11 -11
- package/dist/location/index.js +12 -12
- package/dist/maintenance/memory-governance.js +10 -10
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +10 -10
- package/dist/maintenance/rebuild-memory-projection.js +11 -11
- package/dist/mcp-memory-inspector-app.d.ts +1 -1
- package/dist/memory-subject-cli.d.ts +1 -1
- package/dist/memory-subject.d.ts +1 -1
- package/dist/namespaces/migrate.js +11 -11
- package/dist/namespaces/search.js +6 -6
- package/dist/namespaces/storage.js +10 -10
- package/dist/operator-doctor-corpus.js +13 -13
- package/dist/operator-toolkit.js +23 -23
- package/dist/orchestration/maintenance.js +18 -18
- package/dist/orchestrator.js +90 -88
- package/dist/{public-http-Cwvl4QZr.d.ts → public-http-CmQRjQCD.d.ts} +1 -1
- package/dist/qmd.js +4 -4
- 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.js +6 -73
- package/dist/recall-deep.js.map +1 -1
- package/dist/recall-navigate.js +6 -42
- package/dist/recall-navigate.js.map +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 +3 -4
- package/dist/recall-state-view-wire.js +2 -1
- package/dist/resume-bundles.js +4 -4
- package/dist/schemas.d.ts +176 -176
- package/dist/search/factory.js +5 -5
- package/dist/search/index.js +9 -9
- package/dist/semantic-consolidation.js +11 -11
- package/dist/semantic-rule-promotion.js +10 -10
- package/dist/semantic-rule-verifier.js +10 -10
- package/dist/shared-context/manager.d.ts +6 -6
- package/dist/source-agent-qualifier.js +12 -12
- package/dist/storage.js +9 -9
- package/dist/support-passport/index.d.ts +4 -4
- package/dist/support-passport/index.js +29 -29
- package/dist/transfer/export-okf.js +11 -11
- package/dist/transfer/types.d.ts +78 -78
- package/dist/verified-recall.js +10 -10
- package/dist/who-knows-cli.d.ts +1 -1
- package/dist/who-knows-cli.js +11 -11
- package/dist/who-knows.d.ts +1 -1
- package/dist/who-knows.js +10 -10
- package/package.json +2 -2
- package/src/activity/index.ts +3 -0
- package/src/activity/journal-vault-read.test.ts +153 -0
- package/src/activity/journal-vault-read.ts +214 -0
- package/src/activity/journal.ts +1 -1
- 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 +5 -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/weekly-persist.test.ts +121 -0
- package/src/activity/timeline/weekly-persist.ts +103 -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 +102 -0
- package/src/activity/vault-publish.ts +92 -13
- package/src/dedup/merge-on-write-wire.test.ts +101 -0
- package/src/dedup/merge-on-write-wire.ts +34 -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/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-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.ts +6 -16
- 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/dist/chunk-MUEGIKKY.js.map +0 -1
- package/dist/chunk-TCF4MU7L.js.map +0 -1
- package/dist/chunk-WFCWP4XU.js +0 -17
- package/dist/chunk-WFCWP4XU.js.map +0 -1
- package/dist/{access-service-C2tV2-uL.d.ts → access-service-Dz6I9AZ-.d.ts} +64 -64
- /package/dist/{chunk-LYUUA6QB.js.map → chunk-25OLNWYG.js.map} +0 -0
- /package/dist/{chunk-2X6BGKQL.js.map → chunk-2QSGJTDG.js.map} +0 -0
- /package/dist/{chunk-ZZZWEDF4.js.map → chunk-2VZHB5US.js.map} +0 -0
- /package/dist/{chunk-JKTV3JNX.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-QBNE55VA.js.map → chunk-4PG2CKI6.js.map} +0 -0
- /package/dist/{chunk-S4CDUXQY.js.map → chunk-6545JDIM.js.map} +0 -0
- /package/dist/{chunk-2FA7U5XY.js.map → chunk-65HXVEVG.js.map} +0 -0
- /package/dist/{chunk-U6NGKS32.js.map → chunk-6BYJQ3L2.js.map} +0 -0
- /package/dist/{chunk-OMX6TKXH.js.map → chunk-6PUF7LUO.js.map} +0 -0
- /package/dist/{chunk-TVVEYCNW.js.map → chunk-7K5Q6COX.js.map} +0 -0
- /package/dist/{chunk-VG4SSPAW.js.map → chunk-AI5M4FVQ.js.map} +0 -0
- /package/dist/{chunk-YMOPYG3K.js.map → chunk-BIJAWZYW.js.map} +0 -0
- /package/dist/{chunk-M5ERTI4I.js.map → chunk-BLHKR4GJ.js.map} +0 -0
- /package/dist/{chunk-CEH2AFXG.js.map → chunk-C24UZSFW.js.map} +0 -0
- /package/dist/{chunk-EH65UV2Z.js.map → chunk-C3ZYZKDJ.js.map} +0 -0
- /package/dist/{chunk-NFP4KPTA.js.map → chunk-CDLPF3PX.js.map} +0 -0
- /package/dist/{chunk-FFUMTH27.js.map → chunk-CQ6IWZDI.js.map} +0 -0
- /package/dist/{chunk-KWIGDKM2.js.map → chunk-D2YNNDML.js.map} +0 -0
- /package/dist/{chunk-65JOGLIS.js.map → chunk-D3DUA64S.js.map} +0 -0
- /package/dist/{chunk-2ITZ74A6.js.map → chunk-DSEHPUID.js.map} +0 -0
- /package/dist/{chunk-AF5H7TKI.js.map → chunk-EH7BNIUN.js.map} +0 -0
- /package/dist/{chunk-IGZCAHFL.js.map → chunk-EQRD4NMH.js.map} +0 -0
- /package/dist/{chunk-CX4OLNIH.js.map → chunk-ER2UPUMG.js.map} +0 -0
- /package/dist/{chunk-SZMYGDSM.js.map → chunk-F2JXJABQ.js.map} +0 -0
- /package/dist/{chunk-CHGG74CY.js.map → chunk-F4W5HTED.js.map} +0 -0
- /package/dist/{chunk-H2IRSXZN.js.map → chunk-FFWONAAW.js.map} +0 -0
- /package/dist/{chunk-TNGH4ZYI.js.map → chunk-GNWLTCKC.js.map} +0 -0
- /package/dist/{chunk-OJUEUQDJ.js.map → chunk-JJ6ZEFXC.js.map} +0 -0
- /package/dist/{chunk-U65VJSCJ.js.map → chunk-JMXHVJ2V.js.map} +0 -0
- /package/dist/{chunk-NACLNNFQ.js.map → chunk-KSZKQTZS.js.map} +0 -0
- /package/dist/{chunk-TCQRIIIN.js.map → chunk-LSR5LQXN.js.map} +0 -0
- /package/dist/{chunk-B4AOWRYF.js.map → chunk-NTFXBILO.js.map} +0 -0
- /package/dist/{chunk-2PSX5BJU.js.map → chunk-NZPFCP5A.js.map} +0 -0
- /package/dist/{chunk-C5IUOBCN.js.map → chunk-OERZXNSK.js.map} +0 -0
- /package/dist/{chunk-ZPS724LT.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-GAJK3DQ5.js.map → chunk-PRRUK2ZH.js.map} +0 -0
- /package/dist/{chunk-TBCDF556.js.map → chunk-PW3GKWH3.js.map} +0 -0
- /package/dist/{chunk-KI64TTBL.js.map → chunk-R2Q6FTOX.js.map} +0 -0
- /package/dist/{chunk-KJXCD7VR.js.map → chunk-RCPKBW7K.js.map} +0 -0
- /package/dist/{chunk-INUBU6I5.js.map → chunk-RH3XLQG4.js.map} +0 -0
- /package/dist/{chunk-JBPKEARU.js.map → chunk-RKNJBZ55.js.map} +0 -0
- /package/dist/{chunk-NSTNGMSS.js.map → chunk-U4HZEW2B.js.map} +0 -0
- /package/dist/{chunk-XOHYGIWF.js.map → chunk-UHQE37NI.js.map} +0 -0
- /package/dist/{chunk-D3UXGE5D.js.map → chunk-UMZUKOJU.js.map} +0 -0
- /package/dist/{chunk-S4Z2OBTX.js.map → chunk-UVYL5G7A.js.map} +0 -0
- /package/dist/{chunk-4XLTUR6R.js.map → chunk-VKDBDJIX.js.map} +0 -0
- /package/dist/{chunk-UW4RYPWC.js.map → chunk-VSMSYDIH.js.map} +0 -0
- /package/dist/{chunk-LJABGXC4.js.map → chunk-W5IYHQA5.js.map} +0 -0
- /package/dist/{chunk-7UOXCCCI.js.map → chunk-WKWY7YF3.js.map} +0 -0
- /package/dist/{chunk-YWPLOJ7T.js.map → chunk-Y2YM4C75.js.map} +0 -0
- /package/dist/{chunk-NUF7VSEX.js.map → chunk-YZ5VC2JJ.js.map} +0 -0
- /package/dist/{chunk-EWKVYCFP.js.map → chunk-ZBIEX4XN.js.map} +0 -0
- /package/dist/{chunk-GBEOUCBB.js.map → chunk-ZMVW2HJJ.js.map} +0 -0
- /package/dist/{chunk-RPIS5FQ7.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,24 +32,18 @@ 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";
|
|
39
|
+
import {
|
|
40
|
+
cleanArchivedUserMessage
|
|
41
|
+
} from "./chunk-47DU4SGJ.js";
|
|
39
42
|
import {
|
|
40
43
|
applyUtilityPromotionRuntimePolicy,
|
|
41
44
|
applyUtilityRankingRuntimeDelta,
|
|
42
45
|
loadUtilityRuntimeValues
|
|
43
46
|
} from "./chunk-SEF4IOFE.js";
|
|
44
|
-
import {
|
|
45
|
-
cleanArchivedUserMessage
|
|
46
|
-
} from "./chunk-47DU4SGJ.js";
|
|
47
|
-
import {
|
|
48
|
-
TierMigrationExecutor
|
|
49
|
-
} from "./chunk-YRFAYOFQ.js";
|
|
50
|
-
import {
|
|
51
|
-
decideTierTransition
|
|
52
|
-
} from "./chunk-DD5JFCWM.js";
|
|
53
47
|
import {
|
|
54
48
|
TmtBuilder
|
|
55
49
|
} from "./chunk-ECZU5BJH.js";
|
|
@@ -62,6 +56,12 @@ import {
|
|
|
62
56
|
import {
|
|
63
57
|
CODEX_THREAD_KEY_PREFIX
|
|
64
58
|
} from "./chunk-4EX5WZ4M.js";
|
|
59
|
+
import {
|
|
60
|
+
TierMigrationExecutor
|
|
61
|
+
} from "./chunk-YRFAYOFQ.js";
|
|
62
|
+
import {
|
|
63
|
+
decideTierTransition
|
|
64
|
+
} from "./chunk-DD5JFCWM.js";
|
|
65
65
|
import {
|
|
66
66
|
HourlySummarizer
|
|
67
67
|
} from "./chunk-IEZ6CGTW.js";
|
|
@@ -72,6 +72,18 @@ 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";
|
|
83
|
+
import {
|
|
84
|
+
buildResponseGuidanceRecallSection,
|
|
85
|
+
shouldRecallResponseGuidance
|
|
86
|
+
} from "./chunk-6TCXIRP5.js";
|
|
75
87
|
import {
|
|
76
88
|
mergeWithAgentResults,
|
|
77
89
|
runDirectAgent,
|
|
@@ -94,26 +106,14 @@ import {
|
|
|
94
106
|
resolvePromptTagPrefilterAsync
|
|
95
107
|
} from "./chunk-ZOKZIR5K.js";
|
|
96
108
|
import {
|
|
97
|
-
|
|
98
|
-
} from "./chunk-
|
|
109
|
+
findUnresolvedEntityRefs
|
|
110
|
+
} from "./chunk-X7XN6YU4.js";
|
|
99
111
|
import {
|
|
100
112
|
RelevanceStore
|
|
101
113
|
} from "./chunk-KATEWTQJ.js";
|
|
102
|
-
import {
|
|
103
|
-
RerankCache,
|
|
104
|
-
reorderByRankedKeys,
|
|
105
|
-
rerankLocalOrNoop
|
|
106
|
-
} from "./chunk-LUDXM7MD.js";
|
|
107
|
-
import {
|
|
108
|
-
buildResponseGuidanceRecallSection,
|
|
109
|
-
shouldRecallResponseGuidance
|
|
110
|
-
} from "./chunk-6TCXIRP5.js";
|
|
111
|
-
import {
|
|
112
|
-
findUnresolvedEntityRefs
|
|
113
|
-
} from "./chunk-X7XN6YU4.js";
|
|
114
114
|
import {
|
|
115
115
|
applyRecallStateViews
|
|
116
|
-
} from "./chunk-
|
|
116
|
+
} from "./chunk-FYDW33ZB.js";
|
|
117
117
|
import {
|
|
118
118
|
dedupeResultsByNamespace,
|
|
119
119
|
hasMemoryForResult,
|
|
@@ -141,6 +141,9 @@ import {
|
|
|
141
141
|
import {
|
|
142
142
|
runLiveConnectorsOnce
|
|
143
143
|
} from "./chunk-HTIIXNJQ.js";
|
|
144
|
+
import {
|
|
145
|
+
classifyMemoryKind
|
|
146
|
+
} from "./chunk-YAZNBMNF.js";
|
|
144
147
|
import {
|
|
145
148
|
scoreEvidencePathDetail
|
|
146
149
|
} from "./chunk-XXSOVESA.js";
|
|
@@ -151,16 +154,13 @@ import {
|
|
|
151
154
|
normalizedHarmonicEntityIdentity,
|
|
152
155
|
persistHarmonicRecords
|
|
153
156
|
} from "./chunk-MEW53VQJ.js";
|
|
154
|
-
import {
|
|
155
|
-
classifyMemoryKind
|
|
156
|
-
} from "./chunk-YAZNBMNF.js";
|
|
157
157
|
import {
|
|
158
158
|
buildFocusedListRecallSection,
|
|
159
159
|
shouldRecallFocusedListEvidence
|
|
160
160
|
} from "./chunk-OH7QLI6W.js";
|
|
161
161
|
import {
|
|
162
162
|
ExtractionEngine
|
|
163
|
-
} from "./chunk-
|
|
163
|
+
} from "./chunk-3A2Z4OOS.js";
|
|
164
164
|
import {
|
|
165
165
|
parseMemoryActionEligibilityContext
|
|
166
166
|
} from "./chunk-AJTG3CP7.js";
|
|
@@ -194,7 +194,7 @@ import {
|
|
|
194
194
|
buildEntityRecallSection,
|
|
195
195
|
entityRecentTranscriptLookbackHours,
|
|
196
196
|
readRecentEntityTranscriptEntries
|
|
197
|
-
} from "./chunk-
|
|
197
|
+
} from "./chunk-25OLNWYG.js";
|
|
198
198
|
import {
|
|
199
199
|
planEpisodeWindowsWithFallback
|
|
200
200
|
} from "./chunk-T3GIETKV.js";
|
|
@@ -209,14 +209,14 @@ import {
|
|
|
209
209
|
} from "./chunk-LVXBC6YB.js";
|
|
210
210
|
import {
|
|
211
211
|
refreshConvergedNamespaces
|
|
212
|
-
} from "./chunk-
|
|
212
|
+
} from "./chunk-R2Q6FTOX.js";
|
|
213
213
|
import {
|
|
214
214
|
builtInConnectorPackageSpecifier,
|
|
215
215
|
ensureBuiltInWearableConnectors,
|
|
216
216
|
getWearableConnector,
|
|
217
217
|
listWearableConnectors,
|
|
218
218
|
screenCandidateFact
|
|
219
|
-
} from "./chunk-
|
|
219
|
+
} from "./chunk-ZXROBS53.js";
|
|
220
220
|
import {
|
|
221
221
|
normalizeReplaySessionKey
|
|
222
222
|
} from "./chunk-AJVLDJU6.js";
|
|
@@ -226,14 +226,14 @@ import {
|
|
|
226
226
|
import {
|
|
227
227
|
compareVerifiedEpisodeResults,
|
|
228
228
|
searchVerifiedEpisodes
|
|
229
|
-
} from "./chunk-
|
|
229
|
+
} from "./chunk-OIDICRH7.js";
|
|
230
230
|
import {
|
|
231
231
|
ThreadingManager
|
|
232
232
|
} from "./chunk-OJP3N7UK.js";
|
|
233
233
|
import {
|
|
234
234
|
compareVerifiedSemanticRuleResults,
|
|
235
235
|
searchVerifiedSemanticRules
|
|
236
|
-
} from "./chunk-
|
|
236
|
+
} from "./chunk-BLHKR4GJ.js";
|
|
237
237
|
import {
|
|
238
238
|
searchWorkProductLedgerEntries
|
|
239
239
|
} from "./chunk-NRLELHAY.js";
|
|
@@ -246,17 +246,17 @@ import {
|
|
|
246
246
|
import {
|
|
247
247
|
runNamespaceMaintenanceFanout,
|
|
248
248
|
summarizeNamespaceMaintenanceHealth
|
|
249
|
-
} from "./chunk-
|
|
249
|
+
} from "./chunk-2QSGJTDG.js";
|
|
250
250
|
import {
|
|
251
251
|
planNamespaceMaintenance
|
|
252
|
-
} from "./chunk-
|
|
252
|
+
} from "./chunk-UVYL5G7A.js";
|
|
253
|
+
import {
|
|
254
|
+
searchHarmonicRetrieval
|
|
255
|
+
} from "./chunk-ZBIEX4XN.js";
|
|
253
256
|
import {
|
|
254
257
|
isAboveImportanceThreshold,
|
|
255
258
|
scoreImportance
|
|
256
259
|
} from "./chunk-UOBPK2OS.js";
|
|
257
|
-
import {
|
|
258
|
-
searchHarmonicRetrieval
|
|
259
|
-
} from "./chunk-EWKVYCFP.js";
|
|
260
260
|
import {
|
|
261
261
|
EXTRACTION_JUDGE_VERDICT_CATEGORY,
|
|
262
262
|
recordJudgeVerdict
|
|
@@ -284,7 +284,7 @@ import {
|
|
|
284
284
|
materializeAfterSemanticConsolidation,
|
|
285
285
|
parseConsolidationResponse,
|
|
286
286
|
parseOperatorAwareConsolidationResponse
|
|
287
|
-
} from "./chunk-
|
|
287
|
+
} from "./chunk-RH3XLQG4.js";
|
|
288
288
|
import {
|
|
289
289
|
semanticChunkContent
|
|
290
290
|
} from "./chunk-2GBFKHBZ.js";
|
|
@@ -293,7 +293,7 @@ import {
|
|
|
293
293
|
} from "./chunk-6TBIWIAG.js";
|
|
294
294
|
import {
|
|
295
295
|
SmartBuffer
|
|
296
|
-
} from "./chunk-
|
|
296
|
+
} from "./chunk-KSZKQTZS.js";
|
|
297
297
|
import {
|
|
298
298
|
buildRecallQueryPolicy
|
|
299
299
|
} from "./chunk-C6WMSXCJ.js";
|
|
@@ -317,7 +317,7 @@ import {
|
|
|
317
317
|
applyNoveltyGate,
|
|
318
318
|
detectMeetings,
|
|
319
319
|
embeddingsFromCosineHits
|
|
320
|
-
} from "./chunk-
|
|
320
|
+
} from "./chunk-EH7BNIUN.js";
|
|
321
321
|
import {
|
|
322
322
|
compileCorrectionRule,
|
|
323
323
|
correctionsFilePath,
|
|
@@ -330,14 +330,14 @@ import {
|
|
|
330
330
|
} from "./chunk-QW27DOHG.js";
|
|
331
331
|
import {
|
|
332
332
|
MeetingsInputError
|
|
333
|
-
} from "./chunk-
|
|
333
|
+
} from "./chunk-JMXHVJ2V.js";
|
|
334
334
|
import {
|
|
335
335
|
WearablesInputError,
|
|
336
336
|
describeErrorForOperator
|
|
337
337
|
} from "./chunk-V7IZKJI3.js";
|
|
338
338
|
import {
|
|
339
339
|
NamespaceCatalog
|
|
340
|
-
} from "./chunk-
|
|
340
|
+
} from "./chunk-PRRUK2ZH.js";
|
|
341
341
|
import {
|
|
342
342
|
recordDreamsPhaseRun
|
|
343
343
|
} from "./chunk-EQWEIIKQ.js";
|
|
@@ -353,14 +353,20 @@ import {
|
|
|
353
353
|
detectPassiveCorrections,
|
|
354
354
|
filterRecallCandidates,
|
|
355
355
|
isGenericRecallExcludedPath,
|
|
356
|
-
isTopLevelArchivePath
|
|
357
|
-
|
|
356
|
+
isTopLevelArchivePath,
|
|
357
|
+
journalPath,
|
|
358
|
+
writeJournalFile
|
|
359
|
+
} from "./chunk-B4B3QDV3.js";
|
|
358
360
|
import {
|
|
359
361
|
importCapsule
|
|
360
362
|
} from "./chunk-J2R275FN.js";
|
|
361
363
|
import {
|
|
362
364
|
isCodingGraphInstalled
|
|
363
365
|
} from "./chunk-VQ7B2Q6M.js";
|
|
366
|
+
import {
|
|
367
|
+
listTrustZoneRecords,
|
|
368
|
+
searchTrustZoneRecords
|
|
369
|
+
} from "./chunk-5QZR2RA3.js";
|
|
364
370
|
import {
|
|
365
371
|
applyTrustScoreStage,
|
|
366
372
|
buildTrustSignalsForRerank,
|
|
@@ -368,10 +374,6 @@ import {
|
|
|
368
374
|
trustResultFor,
|
|
369
375
|
trustResultKey
|
|
370
376
|
} from "./chunk-GNVZQ5JN.js";
|
|
371
|
-
import {
|
|
372
|
-
listTrustZoneRecords,
|
|
373
|
-
searchTrustZoneRecords
|
|
374
|
-
} from "./chunk-5QZR2RA3.js";
|
|
375
377
|
import {
|
|
376
378
|
LastRecallStore,
|
|
377
379
|
RecallHandleHistoryStore,
|
|
@@ -408,10 +410,10 @@ import {
|
|
|
408
410
|
} from "./chunk-7ZNJN5WZ.js";
|
|
409
411
|
import {
|
|
410
412
|
NamespaceStorageRouter
|
|
411
|
-
} from "./chunk-
|
|
413
|
+
} from "./chunk-6545JDIM.js";
|
|
412
414
|
import {
|
|
413
415
|
GraphIndex
|
|
414
|
-
} from "./chunk-
|
|
416
|
+
} from "./chunk-BIJAWZYW.js";
|
|
415
417
|
import {
|
|
416
418
|
BulkImportBatchPartialFailureError,
|
|
417
419
|
COMPACTION_SIGNAL_MAX_AGE_MS,
|
|
@@ -452,7 +454,7 @@ import {
|
|
|
452
454
|
throwIfRecallAborted,
|
|
453
455
|
tokenizeRecallQuery,
|
|
454
456
|
utcDateKeysForLocalDay
|
|
455
|
-
} from "./chunk-
|
|
457
|
+
} from "./chunk-4NKIGSJM.js";
|
|
456
458
|
import {
|
|
457
459
|
inferIntentFromText,
|
|
458
460
|
intentCompatibilityScore,
|
|
@@ -465,7 +467,7 @@ import {
|
|
|
465
467
|
} from "./chunk-TBBDFYXW.js";
|
|
466
468
|
import {
|
|
467
469
|
buildChainFollowupGenerator
|
|
468
|
-
} from "./chunk-
|
|
470
|
+
} from "./chunk-WKWY7YF3.js";
|
|
469
471
|
import {
|
|
470
472
|
QmdResultResolver,
|
|
471
473
|
StorageManager,
|
|
@@ -484,10 +486,7 @@ import {
|
|
|
484
486
|
reconstructFusionInputs,
|
|
485
487
|
selfDeps,
|
|
486
488
|
serializeFusionDay
|
|
487
|
-
} from "./chunk-
|
|
488
|
-
import {
|
|
489
|
-
buildRetiredFactTombstoneInputs
|
|
490
|
-
} from "./chunk-4ZWCQJNM.js";
|
|
489
|
+
} from "./chunk-DSEHPUID.js";
|
|
491
490
|
import {
|
|
492
491
|
bodyIsEscaped,
|
|
493
492
|
decodeTranscriptBody,
|
|
@@ -498,15 +497,18 @@ import {
|
|
|
498
497
|
saveSpeakerRegistry,
|
|
499
498
|
speakerRegistryKey
|
|
500
499
|
} from "./chunk-UHVXE24Y.js";
|
|
500
|
+
import {
|
|
501
|
+
buildRetiredFactTombstoneInputs
|
|
502
|
+
} from "./chunk-4ZWCQJNM.js";
|
|
501
503
|
import {
|
|
502
504
|
NamespaceSearchRouter,
|
|
503
505
|
namespaceCollectionName
|
|
504
|
-
} from "./chunk-
|
|
506
|
+
} from "./chunk-OERZXNSK.js";
|
|
505
507
|
import {
|
|
506
508
|
createConversationIndexRuntime,
|
|
507
509
|
createSearchBackend,
|
|
508
510
|
isSearchBackendEnabled
|
|
509
|
-
} from "./chunk-
|
|
511
|
+
} from "./chunk-6BYJQ3L2.js";
|
|
510
512
|
import {
|
|
511
513
|
NoopSearchBackend
|
|
512
514
|
} from "./chunk-CYEPCZN5.js";
|
|
@@ -582,6 +584,9 @@ import {
|
|
|
582
584
|
fallbackLlmRuntimeContextFromConfig,
|
|
583
585
|
gatewayTaskChainOptions
|
|
584
586
|
} from "./chunk-JALOAKSZ.js";
|
|
587
|
+
import {
|
|
588
|
+
extractJsonCandidates
|
|
589
|
+
} from "./chunk-RGMVMVMF.js";
|
|
585
590
|
import {
|
|
586
591
|
estimateTokenCount
|
|
587
592
|
} from "./chunk-TOTT6S2V.js";
|
|
@@ -593,12 +598,14 @@ import {
|
|
|
593
598
|
} from "./chunk-QDW3E4RD.js";
|
|
594
599
|
import {
|
|
595
600
|
activityDayWindow,
|
|
601
|
+
assertValidTimezone,
|
|
602
|
+
hashActivityBody,
|
|
596
603
|
isValidActivityDate,
|
|
597
604
|
timezoneOffsetIso
|
|
598
605
|
} from "./chunk-M6L7HI7R.js";
|
|
599
606
|
import {
|
|
600
607
|
searchCausalTrajectories
|
|
601
|
-
} from "./chunk-
|
|
608
|
+
} from "./chunk-PP7R754B.js";
|
|
602
609
|
import {
|
|
603
610
|
evaluateSubjectGuard,
|
|
604
611
|
isSharedPromotionTarget,
|
|
@@ -2316,7 +2323,7 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
|
|
|
2316
2323
|
namespaces,
|
|
2317
2324
|
{
|
|
2318
2325
|
readNamespaceMemories: async (ns) => (await this.getStorage(ns)).readAllMemories(),
|
|
2319
|
-
readMemoryFrontmatter: async (
|
|
2326
|
+
readMemoryFrontmatter: async (path38, preferredNamespace) => {
|
|
2320
2327
|
if (!fallbackReader) {
|
|
2321
2328
|
for (const ns of namespaces) {
|
|
2322
2329
|
try {
|
|
@@ -2328,7 +2335,7 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
|
|
|
2328
2335
|
}
|
|
2329
2336
|
if (!fallbackReader) return null;
|
|
2330
2337
|
const memory = await this.readQmdResultMemory(
|
|
2331
|
-
|
|
2338
|
+
path38,
|
|
2332
2339
|
fallbackReader,
|
|
2333
2340
|
namespaces,
|
|
2334
2341
|
preferredNamespace
|
|
@@ -17083,8 +17090,8 @@ function fuseMeeting(input, config, options = {}) {
|
|
|
17083
17090
|
}
|
|
17084
17091
|
const clipped = [];
|
|
17085
17092
|
for (const conv of input.conversations) {
|
|
17086
|
-
const
|
|
17087
|
-
if (
|
|
17093
|
+
const clip2 = clipConversation(conv, windowStartMs, windowEndMs);
|
|
17094
|
+
if (clip2 !== null) clipped.push(clip2);
|
|
17088
17095
|
}
|
|
17089
17096
|
const fused = clipped.length > 0 ? fuseCluster(clipped, {
|
|
17090
17097
|
...options.sourceTrust !== void 0 ? { sourceTrust: options.sourceTrust } : {},
|
|
@@ -22330,9 +22337,9 @@ function readStructuralSymbol(entry) {
|
|
|
22330
22337
|
const rec = entry;
|
|
22331
22338
|
const symbol = typeof rec.symbol === "string" ? rec.symbol.trim() : "";
|
|
22332
22339
|
if (!symbol) return null;
|
|
22333
|
-
const
|
|
22340
|
+
const path38 = typeof rec.path === "string" && rec.path.length > 0 ? rec.path : void 0;
|
|
22334
22341
|
const kind = typeof rec.kind === "string" && rec.kind.length > 0 ? rec.kind : void 0;
|
|
22335
|
-
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 };
|
|
22336
22343
|
return item;
|
|
22337
22344
|
}
|
|
22338
22345
|
function classifySpawnError(err) {
|
|
@@ -26628,6 +26635,700 @@ function renderDeterministicJournal(cards, options) {
|
|
|
26628
26635
|
].join("\n");
|
|
26629
26636
|
}
|
|
26630
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
|
+
|
|
26631
27332
|
// src/activity/memory-gen.ts
|
|
26632
27333
|
var ACTIVITY_ALLOWED_CATEGORIES = {
|
|
26633
27334
|
decision: true,
|
|
@@ -26932,10 +27633,189 @@ function observationsForExport(observations, policy) {
|
|
|
26932
27633
|
return observations;
|
|
26933
27634
|
}
|
|
26934
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
|
+
|
|
26935
27815
|
// src/session-summaries/index.ts
|
|
26936
|
-
import { createHash as
|
|
27816
|
+
import { createHash as createHash11 } from "crypto";
|
|
26937
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";
|
|
26938
|
-
import
|
|
27818
|
+
import path36 from "path";
|
|
26939
27819
|
|
|
26940
27820
|
// src/session-summaries/adapters.ts
|
|
26941
27821
|
var VALID_ROLES = /* @__PURE__ */ new Set(["user", "assistant", "tool", "system", "other"]);
|
|
@@ -27435,12 +28315,12 @@ var DEFAULT_MAX_FILES = 5e3;
|
|
|
27435
28315
|
var DEFAULT_MAX_SESSIONS = 500;
|
|
27436
28316
|
var SUPPORTED_EXTENSIONS = /* @__PURE__ */ new Set([".json", ".jsonl"]);
|
|
27437
28317
|
function shortHash(value, length = 16) {
|
|
27438
|
-
return
|
|
28318
|
+
return createHash11("sha256").update(value).digest("hex").slice(0, length);
|
|
27439
28319
|
}
|
|
27440
28320
|
async function listTranscriptFiles(root, maxFiles) {
|
|
27441
28321
|
const out = [];
|
|
27442
28322
|
let truncated = false;
|
|
27443
|
-
const entrySortKey = (entryName, isDirectory) => isDirectory ? `${entryName}${
|
|
28323
|
+
const entrySortKey = (entryName, isDirectory) => isDirectory ? `${entryName}${path36.sep}` : entryName;
|
|
27444
28324
|
async function visit(dir) {
|
|
27445
28325
|
if (truncated) return;
|
|
27446
28326
|
const entries = (await readdir4(dir, { withFileTypes: true })).sort(
|
|
@@ -27450,13 +28330,13 @@ async function listTranscriptFiles(root, maxFiles) {
|
|
|
27450
28330
|
if (truncated) return;
|
|
27451
28331
|
if (entry.name.startsWith(".")) continue;
|
|
27452
28332
|
if (entry.isSymbolicLink()) continue;
|
|
27453
|
-
const fullPath =
|
|
28333
|
+
const fullPath = path36.join(dir, entry.name);
|
|
27454
28334
|
if (entry.isDirectory()) {
|
|
27455
28335
|
await visit(fullPath);
|
|
27456
28336
|
continue;
|
|
27457
28337
|
}
|
|
27458
28338
|
if (!entry.isFile()) continue;
|
|
27459
|
-
const ext =
|
|
28339
|
+
const ext = path36.extname(entry.name).toLowerCase();
|
|
27460
28340
|
if (!SUPPORTED_EXTENSIONS.has(ext)) continue;
|
|
27461
28341
|
out.push(fullPath);
|
|
27462
28342
|
if (out.length > maxFiles) {
|
|
@@ -27483,7 +28363,7 @@ function normalizeInputDir(inputDir) {
|
|
|
27483
28363
|
if (typeof inputDir !== "string" || inputDir.trim().length === 0) {
|
|
27484
28364
|
throw new Error("inputDir must be a non-empty string");
|
|
27485
28365
|
}
|
|
27486
|
-
return
|
|
28366
|
+
return path36.resolve(expandTildePath(inputDir.trim()));
|
|
27487
28367
|
}
|
|
27488
28368
|
function initRoleCounts() {
|
|
27489
28369
|
return {
|
|
@@ -27640,11 +28520,11 @@ async function collectLocalSessionSummaries(options) {
|
|
|
27640
28520
|
continue;
|
|
27641
28521
|
}
|
|
27642
28522
|
seenFileHashes.add(fileHash);
|
|
27643
|
-
const fileExtension =
|
|
28523
|
+
const fileExtension = path36.extname(filePath).toLowerCase();
|
|
27644
28524
|
const parsed = await adapter.parseFile(
|
|
27645
28525
|
{
|
|
27646
28526
|
content,
|
|
27647
|
-
fileName:
|
|
28527
|
+
fileName: path36.basename(filePath),
|
|
27648
28528
|
fileExtension,
|
|
27649
28529
|
fileRef: fileHash
|
|
27650
28530
|
},
|
|
@@ -27700,7 +28580,7 @@ async function collectLocalSessionSummaries(options) {
|
|
|
27700
28580
|
}
|
|
27701
28581
|
async function readRedactionConfig(pathLike) {
|
|
27702
28582
|
if (!pathLike) return void 0;
|
|
27703
|
-
const raw = await readFile7(
|
|
28583
|
+
const raw = await readFile7(path36.resolve(expandTildePath(pathLike)), "utf-8");
|
|
27704
28584
|
const parsed = JSON.parse(raw);
|
|
27705
28585
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
27706
28586
|
throw new Error("redaction config must be a JSON object");
|
|
@@ -27713,15 +28593,15 @@ function toJsonl(drafts) {
|
|
|
27713
28593
|
}
|
|
27714
28594
|
function defaultDraftOutputPath(memoryDir, generatedAt) {
|
|
27715
28595
|
const stamp = generatedAt.replace(/[:.]/g, "-");
|
|
27716
|
-
return
|
|
27717
|
-
|
|
28596
|
+
return path36.join(
|
|
28597
|
+
path36.resolve(expandTildePath(memoryDir)),
|
|
27718
28598
|
"state",
|
|
27719
28599
|
"session-summary-drafts",
|
|
27720
28600
|
`session-summaries-${stamp}.jsonl`
|
|
27721
28601
|
);
|
|
27722
28602
|
}
|
|
27723
28603
|
async function writeDrafts(filePath, drafts) {
|
|
27724
|
-
await mkdir7(
|
|
28604
|
+
await mkdir7(path36.dirname(filePath), { recursive: true });
|
|
27725
28605
|
const tempPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
27726
28606
|
try {
|
|
27727
28607
|
await writeFile7(tempPath, toJsonl(drafts), "utf-8");
|
|
@@ -27739,7 +28619,7 @@ async function runLocalSessionSummaryCliCommand(options) {
|
|
|
27739
28619
|
});
|
|
27740
28620
|
const wroteFiles = [];
|
|
27741
28621
|
if (options.output) {
|
|
27742
|
-
const outputPath =
|
|
28622
|
+
const outputPath = path36.resolve(expandTildePath(options.output));
|
|
27743
28623
|
await writeDrafts(outputPath, report.drafts);
|
|
27744
28624
|
wroteFiles.push(outputPath);
|
|
27745
28625
|
}
|
|
@@ -27774,19 +28654,19 @@ async function runLocalSessionSummaryCliCommand(options) {
|
|
|
27774
28654
|
|
|
27775
28655
|
// src/transfer/capsule-fork.ts
|
|
27776
28656
|
import { lstat as lstat4, mkdir as mkdir8, readFile as readFile8, realpath as realpath3, writeFile as writeFile8 } from "fs/promises";
|
|
27777
|
-
import
|
|
28657
|
+
import path37 from "path";
|
|
27778
28658
|
async function forkCapsule(opts) {
|
|
27779
28659
|
validateForkId(opts.forkId);
|
|
27780
|
-
const rootAbs =
|
|
28660
|
+
const rootAbs = path37.resolve(opts.targetRoot);
|
|
27781
28661
|
await assertIsDirectoryNotSymlink(rootAbs, "forkCapsule", "targetRoot");
|
|
27782
|
-
const forkDirAbs =
|
|
28662
|
+
const forkDirAbs = path37.join(rootAbs, "forks", opts.forkId);
|
|
27783
28663
|
const forkEntryExists = await pathEntryExists(forkDirAbs);
|
|
27784
28664
|
if (forkEntryExists) {
|
|
27785
28665
|
throw new Error(
|
|
27786
28666
|
`forkCapsule: fork path already exists \u2014 forkId "${opts.forkId}" is already in use at: ${forkDirAbs}`
|
|
27787
28667
|
);
|
|
27788
28668
|
}
|
|
27789
|
-
const archiveAbs =
|
|
28669
|
+
const archiveAbs = path37.resolve(opts.sourceArchive);
|
|
27790
28670
|
const importResult = await importCapsule({
|
|
27791
28671
|
archivePath: archiveAbs,
|
|
27792
28672
|
root: rootAbs,
|
|
@@ -27808,10 +28688,10 @@ async function forkCapsule(opts) {
|
|
|
27808
28688
|
importedRecords: importResult.imported.length,
|
|
27809
28689
|
skippedRecords: importResult.skipped.length
|
|
27810
28690
|
};
|
|
27811
|
-
const lineagePath =
|
|
28691
|
+
const lineagePath = path37.join(forkDirAbs, "lineage.json");
|
|
27812
28692
|
const rootReal = await realpath3(rootAbs);
|
|
27813
28693
|
await assertRealpathInsideRoot(rootReal, lineagePath, `forks/${opts.forkId}/lineage.json`, "forkCapsule");
|
|
27814
|
-
await mkdir8(
|
|
28694
|
+
await mkdir8(path37.dirname(lineagePath), { recursive: true });
|
|
27815
28695
|
await writeFile8(lineagePath, JSON.stringify(lineage, null, 2) + "\n", "utf-8");
|
|
27816
28696
|
return {
|
|
27817
28697
|
archivePath: archiveAbs,
|
|
@@ -27825,11 +28705,11 @@ async function readForkLineage(targetRoot, forkId) {
|
|
|
27825
28705
|
if (typeof forkId !== "string" || forkId.length === 0 || forkId.length > 64 || !CAPSULE_ID_PATTERN.test(forkId)) {
|
|
27826
28706
|
return null;
|
|
27827
28707
|
}
|
|
27828
|
-
const rootAbs =
|
|
28708
|
+
const rootAbs = path37.resolve(targetRoot);
|
|
27829
28709
|
const rootReal = await realpath3(rootAbs).catch(() => rootAbs);
|
|
27830
|
-
const lineagePath =
|
|
27831
|
-
const rel =
|
|
27832
|
-
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)) {
|
|
27833
28713
|
return null;
|
|
27834
28714
|
}
|
|
27835
28715
|
if (!await isLineagePathContained(rootReal, lineagePath)) {
|
|
@@ -27870,19 +28750,19 @@ async function pathEntryExists(absPath) {
|
|
|
27870
28750
|
async function isLineagePathContained(rootReal, lineagePath) {
|
|
27871
28751
|
let existing = lineagePath;
|
|
27872
28752
|
const suffix = [];
|
|
27873
|
-
while (existing !==
|
|
28753
|
+
while (existing !== path37.dirname(existing)) {
|
|
27874
28754
|
const st = await lstat4(existing).catch(() => null);
|
|
27875
28755
|
if (st !== null) break;
|
|
27876
|
-
suffix.unshift(
|
|
27877
|
-
existing =
|
|
28756
|
+
suffix.unshift(path37.basename(existing));
|
|
28757
|
+
existing = path37.dirname(existing);
|
|
27878
28758
|
}
|
|
27879
28759
|
const existingReal = await realpath3(existing).catch(() => existing);
|
|
27880
|
-
const targetReal = suffix.length > 0 ?
|
|
27881
|
-
const rel =
|
|
28760
|
+
const targetReal = suffix.length > 0 ? path37.join(existingReal, ...suffix) : existingReal;
|
|
28761
|
+
const rel = path37.relative(rootReal, targetReal);
|
|
27882
28762
|
if (rel === "") return true;
|
|
27883
28763
|
if (rel === "..") return false;
|
|
27884
|
-
if (rel.startsWith(`..${
|
|
27885
|
-
if (
|
|
28764
|
+
if (rel.startsWith(`..${path37.sep}`)) return false;
|
|
28765
|
+
if (path37.isAbsolute(rel)) return false;
|
|
27886
28766
|
return true;
|
|
27887
28767
|
}
|
|
27888
28768
|
|
|
@@ -27986,12 +28866,32 @@ export {
|
|
|
27986
28866
|
queryTimelineSearch,
|
|
27987
28867
|
runTimelineCliCommand,
|
|
27988
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,
|
|
27989
28886
|
isEligibleActivityFact,
|
|
27990
28887
|
generateActivityMemories,
|
|
27991
28888
|
MS_PER_DAY2 as MS_PER_DAY,
|
|
27992
28889
|
parseActivityPrivacy,
|
|
27993
28890
|
shouldRetain,
|
|
27994
28891
|
observationsForExport,
|
|
28892
|
+
resolveVaultNotePath,
|
|
28893
|
+
applyManagedRegion,
|
|
28894
|
+
publishVaultRegion,
|
|
27995
28895
|
fuseMeeting,
|
|
27996
28896
|
buildMeetingRecordsForDay,
|
|
27997
28897
|
MeetingsBuilder,
|
|
@@ -28025,4 +28925,4 @@ export {
|
|
|
28025
28925
|
blendGraphExpandedRecallScore,
|
|
28026
28926
|
Orchestrator
|
|
28027
28927
|
};
|
|
28028
|
-
//# sourceMappingURL=chunk-
|
|
28928
|
+
//# sourceMappingURL=chunk-47WWTCJY.js.map
|