@remnic/core 9.15.3 → 9.16.1
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 +8 -8
- package/dist/access-admin-ops-surface.js +7 -7
- package/dist/access-boundary.d.ts +8 -8
- package/dist/access-boundary.js +7 -7
- package/dist/access-cli.js +31 -30
- package/dist/access-cli.js.map +1 -1
- package/dist/access-http.d.ts +8 -8
- package/dist/access-http.js +11 -11
- package/dist/access-identity-continuity-surface.d.ts +6 -6
- package/dist/access-identity-continuity-surface.js +7 -7
- package/dist/access-lcm-surface.d.ts +8 -8
- package/dist/access-lcm-surface.js +7 -7
- package/dist/access-mcp.d.ts +8 -8
- package/dist/access-mcp.js +10 -10
- package/dist/access-memory-search-fanout.d.ts +2 -2
- package/dist/{access-namespace-preflight-B9e5GnyZ.d.ts → access-namespace-preflight-DwhEFYy3.d.ts} +1 -1
- package/dist/access-namespace-preflight.d.ts +3 -3
- package/dist/access-namespace-preflight.js +7 -7
- package/dist/access-observe-write-surface.d.ts +8 -8
- package/dist/access-observe-write-surface.js +7 -7
- package/dist/access-operations-batch.js +8 -8
- package/dist/access-operations.d.ts +11 -11
- package/dist/access-operations.js +9 -9
- package/dist/access-recall-concurrency.d.ts +8 -8
- package/dist/access-recall-concurrency.js +7 -7
- package/dist/access-recall-response.d.ts +8 -8
- package/dist/access-recall-response.js +7 -7
- package/dist/access-recall-surface.d.ts +8 -8
- package/dist/access-recall-surface.js +7 -7
- package/dist/access-schema.d.ts +76 -76
- package/dist/{access-service-DgmJd_A-.d.ts → access-service-CSq1Wp2Z.d.ts} +6 -6
- package/dist/access-service.d.ts +8 -8
- package/dist/access-service.js +7 -7
- package/dist/access-surface-catalog.d.ts +8 -8
- 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 +2 -1
- package/dist/active-recall.js.map +1 -1
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +6 -6
- package/dist/briefing.d.ts +2 -2
- package/dist/briefing.js +3 -3
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer.d.ts +2 -2
- 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-g_dfT6oL.d.ts → catalog-B9uga4sG.d.ts} +1 -1
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-consolidation.d.ts +1 -1
- package/dist/causal-consolidation.js +4 -4
- package/dist/causal-trajectory-graph.d.ts +1 -1
- package/dist/{chunk-IRX5UCGN.js → chunk-2OH3ZRYH.js} +3 -3
- package/dist/{chunk-YXTSUIXC.js → chunk-5EKOBRCA.js} +6 -1
- package/dist/chunk-5EKOBRCA.js.map +1 -0
- package/dist/{chunk-42DJZZUB.js → chunk-7LXSPIVG.js} +2 -2
- package/dist/{chunk-47WFEKT7.js → chunk-7PK4W4RN.js} +2 -2
- package/dist/{chunk-O7ACJAHR.js → chunk-7YJLCNPF.js} +2 -2
- package/dist/{chunk-6EJL2O3G.js → chunk-AFH7PIFU.js} +2 -2
- package/dist/{chunk-JN4N2TMQ.js → chunk-ANGUOE2N.js} +7 -7
- package/dist/{chunk-GQOKO77V.js → chunk-AWT7SCWQ.js} +2 -2
- package/dist/{chunk-PXJEL55X.js → chunk-BIRPR5N7.js} +2 -2
- package/dist/{chunk-NAY25BGS.js → chunk-BTK2PIFL.js} +6 -6
- package/dist/{chunk-SYCVU556.js → chunk-C2RMQRPN.js} +3 -3
- package/dist/{chunk-T4EAQPQQ.js → chunk-G2WCVFDC.js} +2 -2
- package/dist/{chunk-UJIBXOJA.js → chunk-GEDBTSYU.js} +5 -5
- package/dist/{chunk-CXFVZ3PK.js → chunk-GRJ5UOFO.js} +84 -658
- package/dist/chunk-GRJ5UOFO.js.map +1 -0
- package/dist/chunk-GSQASASV.js +429 -0
- package/dist/chunk-GSQASASV.js.map +1 -0
- package/dist/{chunk-WIKOHCQZ.js → chunk-I6ODVWQB.js} +2 -2
- package/dist/{chunk-H4MDUPER.js → chunk-IZHXSLO7.js} +2 -2
- package/dist/{chunk-RRS5CDB6.js → chunk-JOCXI2O5.js} +2 -2
- package/dist/{chunk-EEUZQQRJ.js → chunk-KGKYTCDO.js} +2 -2
- package/dist/{chunk-JTW4TGPV.js → chunk-L3HAUO7K.js} +2 -2
- package/dist/{chunk-P53HGVJS.js → chunk-LMVAIZR5.js} +2 -2
- package/dist/{chunk-KLXG4BBO.js → chunk-M6TZQDTX.js} +2 -2
- package/dist/{chunk-FJ5IQ3SI.js → chunk-N7DK67GZ.js} +1 -1
- package/dist/chunk-N7DK67GZ.js.map +1 -0
- package/dist/{chunk-U6QWUFSM.js → chunk-OXT5TQDS.js} +2 -2
- package/dist/{chunk-T4OTDMX4.js → chunk-QDTEH6BS.js} +2 -2
- package/dist/{chunk-5MDE5MIC.js → chunk-SESF64QR.js} +2 -2
- package/dist/{chunk-4E5H4FPC.js → chunk-TUNI4GB3.js} +3 -3
- package/dist/{chunk-XJT6LNLY.js → chunk-V6LYAXGW.js} +834 -25
- package/dist/chunk-V6LYAXGW.js.map +1 -0
- package/dist/{chunk-5HFIHWOF.js → chunk-VLIY55Q5.js} +17 -17
- package/dist/{chunk-BNH2VVWP.js → chunk-WIS5JTJR.js} +2 -2
- package/dist/{chunk-OOGGUXAG.js → chunk-WQ2I6ODB.js} +2 -2
- package/dist/{cli-BXCd2cgK.d.ts → cli-DYLGXxuu.d.ts} +5 -5
- package/dist/cli.d.ts +10 -10
- package/dist/cli.js +25 -24
- package/dist/compounding/engine.d.ts +2 -2
- package/dist/compounding/engine.js +3 -3
- 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 +2 -1
- package/dist/connectors/codex-materialize-runner.d.ts +1 -1
- package/dist/connectors/codex-materialize-runner.js +3 -3
- package/dist/connectors/codex-materialize.d.ts +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.js +3 -3
- package/dist/consolidation-provenance-check.d.ts +2 -2
- package/dist/consolidation-undo.d.ts +2 -2
- package/dist/contradiction/index.d.ts +2 -2
- 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/day-summary.d.ts +1 -1
- package/dist/delinearize.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-retrieval.d.ts +2 -2
- package/dist/entity-retrieval.js +3 -3
- package/dist/entity-schema.d.ts +1 -1
- package/dist/explicit-capture.d.ts +6 -6
- 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.d.ts +1 -1
- 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-reinforcement.d.ts +1 -1
- package/dist/graph-snapshot.d.ts +1 -1
- package/dist/graph.d.ts +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.ts +693 -503
- package/dist/index.js +70 -45
- package/dist/intent.d.ts +1 -1
- package/dist/lcm/engine.d.ts +1 -1
- package/dist/lcm/index.d.ts +1 -1
- package/dist/lcm/tools.d.ts +1 -1
- package/dist/lifecycle.d.ts +1 -1
- package/dist/live-connectors-runner.d.ts +1 -1
- package/dist/local-llm.d.ts +1 -1
- package/dist/local-model-endpoint.d.ts +1 -1
- package/dist/maintenance/memory-governance.d.ts +1 -1
- package/dist/maintenance/memory-governance.js +3 -3
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
- package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +3 -3
- package/dist/maintenance/rebuild-memory-projection.js +4 -4
- package/dist/mcp-memory-inspector-app.d.ts +8 -8
- package/dist/memory-action-policy.d.ts +1 -1
- package/dist/memory-cache.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-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 +4 -4
- package/dist/namespaces/principal.d.ts +1 -1
- package/dist/namespaces/search.d.ts +1 -1
- package/dist/namespaces/storage.d.ts +3 -3
- package/dist/namespaces/storage.js +3 -3
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/offline-sync-impression-drain.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +2 -2
- package/dist/operator-toolkit.js +9 -8
- package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
- package/dist/orchestration/maintenance.d.ts +10 -7
- package/dist/orchestration/maintenance.js +7 -6
- package/dist/{orchestrator-BHfWtvEJ.d.ts → orchestrator-BHx-DWCa.d.ts} +7 -5
- package/dist/orchestrator.d.ts +6 -6
- package/dist/orchestrator.js +31 -30
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/{pipeline-CBYcnmDC.d.ts → pipeline-DDHSE876.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/{qmd-BIq-jrV4.d.ts → qmd-C4WVh6BM.d.ts} +1 -1
- package/dist/qmd-preflight.d.ts +2 -2
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd.d.ts +2 -2
- package/dist/recall-concurrency-config.d.ts +1 -1
- package/dist/recall-disclosure-escalation.d.ts +1 -1
- package/dist/recall-explain-renderer.d.ts +1 -1
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-memory-map.d.ts +1 -1
- package/dist/recall-planner-llm.d.ts +1 -1
- 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/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/resolve-auth-token.d.ts +1 -1
- package/dist/resume-bundles.js +3 -2
- package/dist/retrieval-agents.d.ts +2 -2
- package/dist/retrieval-tiers.d.ts +1 -1
- package/dist/routing/engine.d.ts +1 -1
- package/dist/routing/store.d.ts +1 -1
- package/dist/salvage-envelope.d.ts +1 -1
- package/dist/schemas.d.ts +76 -76
- package/dist/{scope-profiles-DDno-uvy.d.ts → scope-profiles-EqMXwzCz.d.ts} +1 -1
- package/dist/search/embed-helper.d.ts +1 -1
- package/dist/search/factory.d.ts +1 -1
- package/dist/search/index.d.ts +1 -1
- package/dist/search/lancedb-backend.d.ts +1 -1
- package/dist/search/meilisearch-backend.d.ts +1 -1
- package/dist/search/noop-backend.d.ts +1 -1
- package/dist/search/orama-backend.d.ts +1 -1
- package/dist/search/port.d.ts +1 -1
- package/dist/search/remote-backend.d.ts +1 -1
- package/dist/{semantic-consolidation-7RIJFDwY.d.ts → semantic-consolidation-CYpvwmQc.d.ts} +1 -1
- package/dist/semantic-consolidation.d.ts +2 -2
- package/dist/semantic-consolidation.js +4 -4
- package/dist/semantic-rule-promotion.js +3 -3
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +3 -3
- package/dist/session-observer-bands.d.ts +1 -1
- package/dist/session-observer-state.d.ts +1 -1
- package/dist/shared-context/manager.d.ts +9 -9
- package/dist/signal.d.ts +1 -1
- package/dist/{storage-DkphZiOJ.d.ts → storage-Dxd7zVZH.d.ts} +1 -1
- package/dist/storage.d.ts +2 -2
- package/dist/storage.js +2 -2
- package/dist/summarizer.d.ts +1 -1
- package/dist/summary-snapshot.d.ts +1 -1
- 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/types.d.ts +66 -66
- package/dist/trust-score-stage.d.ts +1 -1
- package/dist/trust-score.d.ts +1 -1
- package/dist/{types-2q_MRFcM.d.ts → types-OUCJALBK.d.ts} +98 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/utility-runtime.d.ts +1 -1
- package/dist/verified-recall.js +3 -3
- package/dist/write-envelope.d.ts +1 -1
- package/package.json +2 -2
- package/src/activity/config.test.ts +113 -0
- package/src/activity/config.ts +111 -0
- package/src/activity/digest.ts +2 -2
- package/src/activity/index.ts +6 -0
- package/src/activity/pipeline.test.ts +379 -0
- package/src/activity/pipeline.ts +223 -0
- package/src/activity/reindex.test.ts +97 -0
- package/src/activity/reindex.ts +40 -0
- package/src/activity/runner.test.ts +452 -0
- package/src/activity/runner.ts +237 -0
- package/src/activity/scheduler.test.ts +303 -0
- package/src/activity/scheduler.ts +147 -0
- package/src/activity/source-client.test.ts +208 -0
- package/src/activity/source-client.ts +159 -0
- package/src/activity/sync-registration.test.ts +134 -0
- package/src/activity/sync-registration.ts +139 -0
- package/src/activity/types.ts +17 -0
- package/src/config.test.ts +19 -0
- package/src/config.ts +3 -0
- package/src/orchestration/maintenance.test.ts +42 -42
- package/src/orchestration/maintenance.ts +37 -5
- package/src/orchestration/orchestrator-helpers.ts +36 -1
- package/src/orchestration/recall-internal.ts +6 -6
- package/src/orchestration/recall-search-pipeline.ts +15 -7
- package/src/orchestrator-background-writes.test.ts +2 -2
- package/src/orchestrator.ts +3 -3
- package/src/types.ts +4 -1
- package/dist/chunk-CXFVZ3PK.js.map +0 -1
- package/dist/chunk-FJ5IQ3SI.js.map +0 -1
- package/dist/chunk-XJT6LNLY.js.map +0 -1
- package/dist/chunk-YXTSUIXC.js.map +0 -1
- /package/dist/{chunk-IRX5UCGN.js.map → chunk-2OH3ZRYH.js.map} +0 -0
- /package/dist/{chunk-42DJZZUB.js.map → chunk-7LXSPIVG.js.map} +0 -0
- /package/dist/{chunk-47WFEKT7.js.map → chunk-7PK4W4RN.js.map} +0 -0
- /package/dist/{chunk-O7ACJAHR.js.map → chunk-7YJLCNPF.js.map} +0 -0
- /package/dist/{chunk-6EJL2O3G.js.map → chunk-AFH7PIFU.js.map} +0 -0
- /package/dist/{chunk-JN4N2TMQ.js.map → chunk-ANGUOE2N.js.map} +0 -0
- /package/dist/{chunk-GQOKO77V.js.map → chunk-AWT7SCWQ.js.map} +0 -0
- /package/dist/{chunk-PXJEL55X.js.map → chunk-BIRPR5N7.js.map} +0 -0
- /package/dist/{chunk-NAY25BGS.js.map → chunk-BTK2PIFL.js.map} +0 -0
- /package/dist/{chunk-SYCVU556.js.map → chunk-C2RMQRPN.js.map} +0 -0
- /package/dist/{chunk-T4EAQPQQ.js.map → chunk-G2WCVFDC.js.map} +0 -0
- /package/dist/{chunk-UJIBXOJA.js.map → chunk-GEDBTSYU.js.map} +0 -0
- /package/dist/{chunk-WIKOHCQZ.js.map → chunk-I6ODVWQB.js.map} +0 -0
- /package/dist/{chunk-H4MDUPER.js.map → chunk-IZHXSLO7.js.map} +0 -0
- /package/dist/{chunk-RRS5CDB6.js.map → chunk-JOCXI2O5.js.map} +0 -0
- /package/dist/{chunk-EEUZQQRJ.js.map → chunk-KGKYTCDO.js.map} +0 -0
- /package/dist/{chunk-JTW4TGPV.js.map → chunk-L3HAUO7K.js.map} +0 -0
- /package/dist/{chunk-P53HGVJS.js.map → chunk-LMVAIZR5.js.map} +0 -0
- /package/dist/{chunk-KLXG4BBO.js.map → chunk-M6TZQDTX.js.map} +0 -0
- /package/dist/{chunk-U6QWUFSM.js.map → chunk-OXT5TQDS.js.map} +0 -0
- /package/dist/{chunk-T4OTDMX4.js.map → chunk-QDTEH6BS.js.map} +0 -0
- /package/dist/{chunk-5MDE5MIC.js.map → chunk-SESF64QR.js.map} +0 -0
- /package/dist/{chunk-4E5H4FPC.js.map → chunk-TUNI4GB3.js.map} +0 -0
- /package/dist/{chunk-5HFIHWOF.js.map → chunk-VLIY55Q5.js.map} +0 -0
- /package/dist/{chunk-BNH2VVWP.js.map → chunk-WIS5JTJR.js.map} +0 -0
- /package/dist/{chunk-OOGGUXAG.js.map → chunk-WQ2I6ODB.js.map} +0 -0
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "./chunk-JECBQBEX.js";
|
|
11
11
|
import {
|
|
12
12
|
MaintenanceScheduler
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-V6LYAXGW.js";
|
|
14
14
|
import {
|
|
15
15
|
runPeerProfileReasoner
|
|
16
16
|
} from "./chunk-I74SUMNI.js";
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
import {
|
|
27
27
|
CompoundingEngine,
|
|
28
28
|
defaultTierMigrationCycleBudget
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-7LXSPIVG.js";
|
|
30
30
|
import {
|
|
31
31
|
SharedContextManager
|
|
32
32
|
} from "./chunk-RFDD3B7W.js";
|
|
@@ -208,7 +208,7 @@ import {
|
|
|
208
208
|
buildEntityRecallSection,
|
|
209
209
|
entityRecentTranscriptLookbackHours,
|
|
210
210
|
readRecentEntityTranscriptEntries
|
|
211
|
-
} from "./chunk-
|
|
211
|
+
} from "./chunk-7PK4W4RN.js";
|
|
212
212
|
import {
|
|
213
213
|
normalizeReplaySessionKey
|
|
214
214
|
} from "./chunk-AJVLDJU6.js";
|
|
@@ -218,14 +218,14 @@ import {
|
|
|
218
218
|
import {
|
|
219
219
|
compareVerifiedEpisodeResults,
|
|
220
220
|
searchVerifiedEpisodes
|
|
221
|
-
} from "./chunk-
|
|
221
|
+
} from "./chunk-AFH7PIFU.js";
|
|
222
222
|
import {
|
|
223
223
|
ThreadingManager
|
|
224
224
|
} from "./chunk-OJP3N7UK.js";
|
|
225
225
|
import {
|
|
226
226
|
compareVerifiedSemanticRuleResults,
|
|
227
227
|
searchVerifiedSemanticRules
|
|
228
|
-
} from "./chunk-
|
|
228
|
+
} from "./chunk-L3HAUO7K.js";
|
|
229
229
|
import {
|
|
230
230
|
searchWorkProductLedgerEntries
|
|
231
231
|
} from "./chunk-ZRWB5D4H.js";
|
|
@@ -238,14 +238,14 @@ import {
|
|
|
238
238
|
import {
|
|
239
239
|
runNamespaceMaintenanceFanout,
|
|
240
240
|
summarizeNamespaceMaintenanceHealth
|
|
241
|
-
} from "./chunk-
|
|
241
|
+
} from "./chunk-BTK2PIFL.js";
|
|
242
242
|
import {
|
|
243
243
|
NamespaceCatalog,
|
|
244
244
|
planNamespaceMaintenance
|
|
245
|
-
} from "./chunk-
|
|
245
|
+
} from "./chunk-SESF64QR.js";
|
|
246
246
|
import {
|
|
247
247
|
NamespaceStorageRouter
|
|
248
|
-
} from "./chunk-
|
|
248
|
+
} from "./chunk-WQ2I6ODB.js";
|
|
249
249
|
import {
|
|
250
250
|
searchHarmonicRetrieval
|
|
251
251
|
} from "./chunk-AV5ZEH4M.js";
|
|
@@ -280,7 +280,7 @@ import {
|
|
|
280
280
|
materializeAfterSemanticConsolidation,
|
|
281
281
|
parseConsolidationResponse,
|
|
282
282
|
parseOperatorAwareConsolidationResponse
|
|
283
|
-
} from "./chunk-
|
|
283
|
+
} from "./chunk-KGKYTCDO.js";
|
|
284
284
|
import {
|
|
285
285
|
BootstrapEngine
|
|
286
286
|
} from "./chunk-MYVPLJOO.js";
|
|
@@ -329,7 +329,7 @@ import {
|
|
|
329
329
|
clusterByKey,
|
|
330
330
|
createCorrectionService,
|
|
331
331
|
detectPassiveCorrections
|
|
332
|
-
} from "./chunk-
|
|
332
|
+
} from "./chunk-ANGUOE2N.js";
|
|
333
333
|
import {
|
|
334
334
|
importCapsule
|
|
335
335
|
} from "./chunk-7CPOZH6Y.js";
|
|
@@ -349,7 +349,7 @@ import {
|
|
|
349
349
|
} from "./chunk-JGSKJHF7.js";
|
|
350
350
|
import {
|
|
351
351
|
buildXraySnapshot
|
|
352
|
-
} from "./chunk-
|
|
352
|
+
} from "./chunk-BIRPR5N7.js";
|
|
353
353
|
import {
|
|
354
354
|
NamespaceSearchRouter
|
|
355
355
|
} from "./chunk-QDNE35FU.js";
|
|
@@ -395,7 +395,7 @@ import {
|
|
|
395
395
|
} from "./chunk-W4FBGYGK.js";
|
|
396
396
|
import {
|
|
397
397
|
buildChainFollowupGenerator
|
|
398
|
-
} from "./chunk-
|
|
398
|
+
} from "./chunk-QDTEH6BS.js";
|
|
399
399
|
import {
|
|
400
400
|
ContentHashIndex,
|
|
401
401
|
QmdResultResolver,
|
|
@@ -412,7 +412,7 @@ import {
|
|
|
412
412
|
reconstructFusionInputs,
|
|
413
413
|
selfDeps,
|
|
414
414
|
serializeFusionDay
|
|
415
|
-
} from "./chunk-
|
|
415
|
+
} from "./chunk-7YJLCNPF.js";
|
|
416
416
|
import {
|
|
417
417
|
bodyIsEscaped,
|
|
418
418
|
decodeTranscriptBody,
|
|
@@ -443,7 +443,7 @@ import {
|
|
|
443
443
|
} from "./chunk-J6A3CX5N.js";
|
|
444
444
|
import {
|
|
445
445
|
confidenceTier
|
|
446
|
-
} from "./chunk-
|
|
446
|
+
} from "./chunk-N7DK67GZ.js";
|
|
447
447
|
import {
|
|
448
448
|
namespaceIdentityFromToken,
|
|
449
449
|
namespaceIdentityToken,
|
|
@@ -456,9 +456,6 @@ import {
|
|
|
456
456
|
inferMemoryStatus,
|
|
457
457
|
isActiveMemoryStatus
|
|
458
458
|
} from "./chunk-ILGC6JH6.js";
|
|
459
|
-
import {
|
|
460
|
-
openBetterSqlite3
|
|
461
|
-
} from "./chunk-RL6NEVXT.js";
|
|
462
459
|
import {
|
|
463
460
|
lintWorkspaceFiles,
|
|
464
461
|
rotateMarkdownFileToArchive
|
|
@@ -2078,7 +2075,7 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
|
|
|
2078
2075
|
namespaces,
|
|
2079
2076
|
{
|
|
2080
2077
|
readNamespaceMemories: async (ns) => (await this.getStorage(ns)).readAllMemories(),
|
|
2081
|
-
readMemoryFrontmatter: async (
|
|
2078
|
+
readMemoryFrontmatter: async (path31, preferredNamespace) => {
|
|
2082
2079
|
if (!fallbackReader) {
|
|
2083
2080
|
for (const ns of namespaces) {
|
|
2084
2081
|
try {
|
|
@@ -2090,7 +2087,7 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
|
|
|
2090
2087
|
}
|
|
2091
2088
|
if (!fallbackReader) return null;
|
|
2092
2089
|
const memory = await this.readQmdResultMemory(
|
|
2093
|
-
|
|
2090
|
+
path31,
|
|
2094
2091
|
fallbackReader,
|
|
2095
2092
|
namespaces,
|
|
2096
2093
|
preferredNamespace
|
|
@@ -2993,6 +2990,18 @@ function splitTurnsBySourceValidAt(turns, options = {}) {
|
|
|
2993
2990
|
function isArtifactMemoryPath(filePath) {
|
|
2994
2991
|
return /(?:^|[\\/])artifacts(?:[\\/]|$)/i.test(filePath);
|
|
2995
2992
|
}
|
|
2993
|
+
var ACTIVITY_DIGEST_TOPLEVEL = /^activity[\\/]\d{4}-\d{2}-\d{2}\.md$/i;
|
|
2994
|
+
var ACTIVITY_DIGEST_ANYWHERE = /(?:^|[\\/])activity[\\/]\d{4}-\d{2}-\d{2}\.md$/i;
|
|
2995
|
+
function isActivityDigestPath(filePath, memoryRoot) {
|
|
2996
|
+
if (memoryRoot !== void 0 && memoryRoot.length > 0) {
|
|
2997
|
+
const relative = path4.relative(memoryRoot, path4.resolve(memoryRoot, filePath));
|
|
2998
|
+
return ACTIVITY_DIGEST_TOPLEVEL.test(relative);
|
|
2999
|
+
}
|
|
3000
|
+
return ACTIVITY_DIGEST_ANYWHERE.test(filePath);
|
|
3001
|
+
}
|
|
3002
|
+
function isGenericRecallExcludedPath(filePath, memoryRoot) {
|
|
3003
|
+
return isArtifactMemoryPath(filePath) || isActivityDigestPath(filePath, memoryRoot);
|
|
3004
|
+
}
|
|
2996
3005
|
function buildCompressionGuidelinesMarkdown2(events, generatedAtIso = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
2997
3006
|
return buildCompressionGuidelinesMarkdown(events, generatedAtIso);
|
|
2998
3007
|
}
|
|
@@ -3000,7 +3009,7 @@ function filterRecallCandidates(candidates, options) {
|
|
|
3000
3009
|
const scopedByNamespace = options.namespacesEnabled ? candidates.filter(
|
|
3001
3010
|
(r) => options.recallNamespaces.includes(r.namespace ?? options.resolveNamespace(r.path))
|
|
3002
3011
|
) : candidates;
|
|
3003
|
-
return scopedByNamespace.filter((r) => !
|
|
3012
|
+
return scopedByNamespace.filter((r) => !isGenericRecallExcludedPath(r.path, options.memoryRoot)).slice(0, Math.max(0, options.limit));
|
|
3004
3013
|
}
|
|
3005
3014
|
function applyQueryAwareCandidateFilter(candidates, candidatePaths) {
|
|
3006
3015
|
if (!candidatePaths) return candidates;
|
|
@@ -9344,9 +9353,7 @@ ${tmtNode.summary}`
|
|
|
9344
9353
|
if (resolveNamespaceCapabilities(this.deps.config).namespaces) {
|
|
9345
9354
|
memoryResults = memoryResults.filter((r) => recallNamespaces.includes(r.namespace ?? this.deps.namespaceFromPath(r.path)));
|
|
9346
9355
|
}
|
|
9347
|
-
memoryResults = memoryResults.filter(
|
|
9348
|
-
(r) => !isArtifactMemoryPath(r.path)
|
|
9349
|
-
);
|
|
9356
|
+
memoryResults = memoryResults.filter((r) => !isGenericRecallExcludedPath(r.path, this.deps.config.memoryDir));
|
|
9350
9357
|
const isFullModeGraphAssist = graphCaps.multiGraphMemory && caps.graphAssistInFullMode && recallMode === "full" && memoryResults.length >= Math.max(1, this.deps.config.graphAssistMinSeedResults ?? 3);
|
|
9351
9358
|
const shouldRunGraphExpansion = recallMode === "graph_mode" || isFullModeGraphAssist;
|
|
9352
9359
|
const graphShadowEvalEnabled = isFullModeGraphAssist && resolveRecallEnhancementCapabilities(this.deps.config).graphAssistShadowEval === true;
|
|
@@ -9631,7 +9638,8 @@ ${tmtNode.summary}`
|
|
|
9631
9638
|
namespacesEnabled: resolveNamespaceCapabilities(this.deps.config).namespaces,
|
|
9632
9639
|
recallNamespaces,
|
|
9633
9640
|
resolveNamespace: (p) => this.deps.namespaceFromPath(p),
|
|
9634
|
-
limit: embeddingFetchLimit
|
|
9641
|
+
limit: embeddingFetchLimit,
|
|
9642
|
+
memoryRoot: this.deps.config.memoryDir
|
|
9635
9643
|
}
|
|
9636
9644
|
);
|
|
9637
9645
|
const boostedScoped = await this.deps.boostSearchResults(
|
|
@@ -9805,7 +9813,8 @@ ${tmtNode.summary}`
|
|
|
9805
9813
|
namespacesEnabled: resolveNamespaceCapabilities(this.deps.config).namespaces,
|
|
9806
9814
|
recallNamespaces,
|
|
9807
9815
|
resolveNamespace: (p) => this.deps.namespaceFromPath(p),
|
|
9808
|
-
limit: embeddingFetchLimit
|
|
9816
|
+
limit: embeddingFetchLimit,
|
|
9817
|
+
memoryRoot: this.deps.config.memoryDir
|
|
9809
9818
|
}
|
|
9810
9819
|
);
|
|
9811
9820
|
const boostedScoped = await this.deps.boostSearchResults(
|
|
@@ -9894,7 +9903,7 @@ ${tmtNode.summary}`
|
|
|
9894
9903
|
const asOfActive = typeof asOfMs === "number" && Number.isFinite(asOfMs);
|
|
9895
9904
|
const activeMemories = memories.filter(
|
|
9896
9905
|
(m) => {
|
|
9897
|
-
if (
|
|
9906
|
+
if (isGenericRecallExcludedPath(m.path, this.deps.config.memoryDir)) return false;
|
|
9898
9907
|
const status = m.frontmatter.status;
|
|
9899
9908
|
if (!status || status === "active") return true;
|
|
9900
9909
|
if (status === "superseded") {
|
|
@@ -10993,7 +11002,8 @@ var RecallSearchPipelineCoordinator = class {
|
|
|
10993
11002
|
namespacesEnabled: options.namespacesEnabled,
|
|
10994
11003
|
recallNamespaces: options.recallNamespaces,
|
|
10995
11004
|
resolveNamespace: options.resolveNamespace,
|
|
10996
|
-
limit: qmdFetchLimit
|
|
11005
|
+
limit: qmdFetchLimit,
|
|
11006
|
+
memoryRoot: this.deps.config.memoryDir
|
|
10997
11007
|
});
|
|
10998
11008
|
const emitDebugSnapshot = async (results, currentFetchLimit) => {
|
|
10999
11009
|
if (!options.onDebugSnapshot) return;
|
|
@@ -11105,7 +11115,8 @@ var RecallSearchPipelineCoordinator = class {
|
|
|
11105
11115
|
namespacesEnabled: options.namespacesEnabled,
|
|
11106
11116
|
recallNamespaces: options.recallNamespaces,
|
|
11107
11117
|
resolveNamespace: options.resolveNamespace,
|
|
11108
|
-
limit: fetchLimit
|
|
11118
|
+
limit: fetchLimit,
|
|
11119
|
+
memoryRoot: this.deps.config.memoryDir
|
|
11109
11120
|
});
|
|
11110
11121
|
if (filteredResults.length >= qmdFetchLimit) {
|
|
11111
11122
|
const capped2 = filteredResults.slice(0, qmdFetchLimit);
|
|
@@ -11168,7 +11179,7 @@ var RecallSearchPipelineCoordinator = class {
|
|
|
11168
11179
|
{ allowArchived: true }
|
|
11169
11180
|
) : [];
|
|
11170
11181
|
if (scopedSeedResults.length >= cappedLimit) {
|
|
11171
|
-
return scopedSeedResults.filter((result) => !
|
|
11182
|
+
return scopedSeedResults.filter((result) => !isGenericRecallExcludedPath(result.path, this.deps.config.memoryDir)).slice(0, cappedLimit);
|
|
11172
11183
|
}
|
|
11173
11184
|
const tokens = Array.from(new Set(tokenizeRecallQuery(prompt)));
|
|
11174
11185
|
if (tokens.length === 0) return scopedSeedResults;
|
|
@@ -11189,7 +11200,7 @@ var RecallSearchPipelineCoordinator = class {
|
|
|
11189
11200
|
[...scopedSeedResults, ...scored],
|
|
11190
11201
|
this.deps.namespaceFromPath,
|
|
11191
11202
|
cappedLimit,
|
|
11192
|
-
{ filter: (result) => !
|
|
11203
|
+
{ filter: (result) => !isGenericRecallExcludedPath(result.path, this.deps.config.memoryDir) }
|
|
11193
11204
|
);
|
|
11194
11205
|
}
|
|
11195
11206
|
async applyColdFallbackPipeline(options) {
|
|
@@ -11361,7 +11372,7 @@ var RecallSearchPipelineCoordinator = class {
|
|
|
11361
11372
|
}
|
|
11362
11373
|
results = scopedResults;
|
|
11363
11374
|
}
|
|
11364
|
-
results = results.filter((r) => !
|
|
11375
|
+
results = results.filter((r) => !isGenericRecallExcludedPath(r.path, this.deps.config.memoryDir));
|
|
11365
11376
|
if (results.length === 0) return [];
|
|
11366
11377
|
const isFullModeGraphAssist = resolveQmdCapabilities(this.deps.config).qmdTierParityGraph && graphCaps.multiGraphMemory && caps.graphAssistInFullMode && options.recallMode === "full" && results.length >= Math.max(1, this.deps.config.graphAssistMinSeedResults ?? 3);
|
|
11367
11378
|
const shouldRunGraphExpansion = resolveQmdCapabilities(this.deps.config).qmdTierParityGraph && (options.recallMode === "graph_mode" || isFullModeGraphAssist);
|
|
@@ -11628,7 +11639,7 @@ var RecallSearchPipelineCoordinator = class {
|
|
|
11628
11639
|
biTemporalExpiredFilteredCount += 1;
|
|
11629
11640
|
continue;
|
|
11630
11641
|
}
|
|
11631
|
-
if (options?.allowDedicatedSurface !== true && (memory.frontmatter.memoryKind === "dream" || memory.frontmatter.memoryKind === "procedural")) {
|
|
11642
|
+
if (options?.allowDedicatedSurface !== true && (memory.frontmatter.memoryKind === "dream" || memory.frontmatter.memoryKind === "procedural" || isActivityDigestPath(memory.path, this.deps.config.memoryDir))) {
|
|
11632
11643
|
dedicatedSurfaceFilteredCount += 1;
|
|
11633
11644
|
continue;
|
|
11634
11645
|
}
|
|
@@ -11652,7 +11663,7 @@ var RecallSearchPipelineCoordinator = class {
|
|
|
11652
11663
|
}
|
|
11653
11664
|
if (dedicatedSurfaceFilteredCount > 0) {
|
|
11654
11665
|
log.debug(
|
|
11655
|
-
`dedicated surface filter removed ${dedicatedSurfaceFilteredCount} dream/procedural candidates from generic recall`
|
|
11666
|
+
`dedicated surface filter removed ${dedicatedSurfaceFilteredCount} dream/procedural/activity-digest candidates from generic recall`
|
|
11656
11667
|
);
|
|
11657
11668
|
}
|
|
11658
11669
|
if (forgottenFilteredCount > 0) {
|
|
@@ -16540,7 +16551,7 @@ var Orchestrator = class {
|
|
|
16540
16551
|
await this.wearablesAutoSyncHandle.stop();
|
|
16541
16552
|
this.wearablesAutoSyncHandle = null;
|
|
16542
16553
|
}
|
|
16543
|
-
this.maintenanceScheduler.dispose();
|
|
16554
|
+
await this.maintenanceScheduler.dispose();
|
|
16544
16555
|
await drainRecallWrites(this);
|
|
16545
16556
|
await this.persistenceIndexCoordinator.drainContentHashReconcileRetries().catch((err) => log.warn(`content-hash reconcile drain failed during destroy: ${err}`));
|
|
16546
16557
|
let bufferFlushError;
|
|
@@ -17592,7 +17603,7 @@ ${doc.content}` : doc.content,
|
|
|
17592
17603
|
if (!paths) return null;
|
|
17593
17604
|
const scoped = /* @__PURE__ */ new Set();
|
|
17594
17605
|
for (const memoryPath of paths) {
|
|
17595
|
-
if (!memoryPath ||
|
|
17606
|
+
if (!memoryPath || isGenericRecallExcludedPath(memoryPath, this.config.memoryDir)) continue;
|
|
17596
17607
|
if (resolveNamespaceCapabilities(this.config).namespaces && !recallNamespaces.includes(this.namespaceFromPath(memoryPath))) {
|
|
17597
17608
|
continue;
|
|
17598
17609
|
}
|
|
@@ -19168,9 +19179,9 @@ function readStructuralSymbol(entry) {
|
|
|
19168
19179
|
const rec = entry;
|
|
19169
19180
|
const symbol = typeof rec.symbol === "string" ? rec.symbol.trim() : "";
|
|
19170
19181
|
if (!symbol) return null;
|
|
19171
|
-
const
|
|
19182
|
+
const path31 = typeof rec.path === "string" && rec.path.length > 0 ? rec.path : void 0;
|
|
19172
19183
|
const kind = typeof rec.kind === "string" && rec.kind.length > 0 ? rec.kind : void 0;
|
|
19173
|
-
const item =
|
|
19184
|
+
const item = path31 !== void 0 && kind !== void 0 ? { symbol, path: path31, kind } : path31 !== void 0 ? { symbol, path: path31 } : kind !== void 0 ? { symbol, kind } : { symbol };
|
|
19174
19185
|
return item;
|
|
19175
19186
|
}
|
|
19176
19187
|
function classifySpawnError(err) {
|
|
@@ -22915,578 +22926,8 @@ function publisherForConnector(connectorId) {
|
|
|
22915
22926
|
return publisherFor(hostIdForConnector(connectorId));
|
|
22916
22927
|
}
|
|
22917
22928
|
|
|
22918
|
-
// src/activity/store.ts
|
|
22919
|
-
import { mkdirSync } from "fs";
|
|
22920
|
-
import { mkdir as mkdir7 } from "fs/promises";
|
|
22921
|
-
import path29 from "path";
|
|
22922
|
-
var ACTIVITY_SCHEMA_VERSION = 1;
|
|
22923
|
-
var MAX_SEARCH_RESULTS = 100;
|
|
22924
|
-
function activityDatabasePath(memoryDir) {
|
|
22925
|
-
return path29.join(memoryDir, "state", "activity.sqlite");
|
|
22926
|
-
}
|
|
22927
|
-
async function ensureActivityStateDir(memoryDir) {
|
|
22928
|
-
await mkdir7(path29.join(memoryDir, "state"), { recursive: true });
|
|
22929
|
-
}
|
|
22930
|
-
function openActivityDatabase(memoryDir) {
|
|
22931
|
-
mkdirSync(path29.join(memoryDir, "state"), { recursive: true });
|
|
22932
|
-
const db = openBetterSqlite3(activityDatabasePath(memoryDir));
|
|
22933
|
-
db.pragma("journal_mode = WAL");
|
|
22934
|
-
db.pragma("busy_timeout = 5000");
|
|
22935
|
-
db.pragma("synchronous = NORMAL");
|
|
22936
|
-
applySchema(db);
|
|
22937
|
-
return db;
|
|
22938
|
-
}
|
|
22939
|
-
function applyActivitySchema(db) {
|
|
22940
|
-
applySchema(db);
|
|
22941
|
-
}
|
|
22942
|
-
function applySchema(db) {
|
|
22943
|
-
db.exec(`
|
|
22944
|
-
CREATE TABLE IF NOT EXISTS activity_meta (
|
|
22945
|
-
key TEXT PRIMARY KEY,
|
|
22946
|
-
value TEXT NOT NULL
|
|
22947
|
-
);
|
|
22948
|
-
|
|
22949
|
-
CREATE TABLE IF NOT EXISTS activity_snapshots (
|
|
22950
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
22951
|
-
machine TEXT NOT NULL,
|
|
22952
|
-
captured_at_utc TEXT NOT NULL,
|
|
22953
|
-
app_name TEXT NOT NULL,
|
|
22954
|
-
window_title TEXT NOT NULL,
|
|
22955
|
-
browser_url TEXT,
|
|
22956
|
-
text TEXT NOT NULL,
|
|
22957
|
-
text_source TEXT NOT NULL,
|
|
22958
|
-
content_hash TEXT NOT NULL,
|
|
22959
|
-
simhash TEXT
|
|
22960
|
-
);
|
|
22961
|
-
CREATE UNIQUE INDEX IF NOT EXISTS idx_activity_snapshots_dedup
|
|
22962
|
-
ON activity_snapshots(machine, captured_at_utc, content_hash);
|
|
22963
|
-
CREATE INDEX IF NOT EXISTS idx_activity_snapshots_time
|
|
22964
|
-
ON activity_snapshots(captured_at_utc, id);
|
|
22965
|
-
|
|
22966
|
-
CREATE TABLE IF NOT EXISTS activity_sync_state (
|
|
22967
|
-
machine TEXT PRIMARY KEY,
|
|
22968
|
-
cursor TEXT,
|
|
22969
|
-
updated_at_utc TEXT NOT NULL
|
|
22970
|
-
);
|
|
22971
|
-
`);
|
|
22972
|
-
const hasFts = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='activity_snapshots_fts'").get();
|
|
22973
|
-
if (!hasFts) {
|
|
22974
|
-
db.exec(`
|
|
22975
|
-
CREATE VIRTUAL TABLE activity_snapshots_fts USING fts5(
|
|
22976
|
-
text, app_name, window_title, browser_url
|
|
22977
|
-
);
|
|
22978
|
-
`);
|
|
22979
|
-
}
|
|
22980
|
-
db.prepare("INSERT OR REPLACE INTO activity_meta (key, value) VALUES ('schema_version', ?)").run(
|
|
22981
|
-
String(ACTIVITY_SCHEMA_VERSION)
|
|
22982
|
-
);
|
|
22983
|
-
}
|
|
22984
|
-
function canonicalizeUtc(iso) {
|
|
22985
|
-
const parsed = Date.parse(iso);
|
|
22986
|
-
return Number.isFinite(parsed) ? new Date(parsed).toISOString() : iso;
|
|
22987
|
-
}
|
|
22988
|
-
function assertRequiredSnapshotFields(s) {
|
|
22989
|
-
const required = [
|
|
22990
|
-
["machine", s.machine],
|
|
22991
|
-
["app", s.app],
|
|
22992
|
-
["windowTitle", s.windowTitle],
|
|
22993
|
-
["text", s.text],
|
|
22994
|
-
["textSource", s.textSource],
|
|
22995
|
-
["contentHash", s.contentHash]
|
|
22996
|
-
];
|
|
22997
|
-
for (const [field, value] of required) {
|
|
22998
|
-
if (typeof value !== "string") {
|
|
22999
|
-
throw new RangeError(`activity: snapshot field "${field}" is required (got ${value === null ? "null" : typeof value}).`);
|
|
23000
|
-
}
|
|
23001
|
-
}
|
|
23002
|
-
if (s.machine.length === 0 || s.contentHash.length === 0) {
|
|
23003
|
-
throw new RangeError('activity: snapshot "machine" and "contentHash" must be non-empty.');
|
|
23004
|
-
}
|
|
23005
|
-
if (s.textSource !== "ax" && s.textSource !== "ocr") {
|
|
23006
|
-
throw new RangeError(`activity: snapshot "textSource" must be "ax" or "ocr" (got "${s.textSource}").`);
|
|
23007
|
-
}
|
|
23008
|
-
}
|
|
23009
|
-
function assertValidUtcInstant(iso, what) {
|
|
23010
|
-
const m = iso.match(
|
|
23011
|
-
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:Z|[+-](?:0\d:[0-5]\d|1[0-3]:[0-5]\d|14:00))$/
|
|
23012
|
-
);
|
|
23013
|
-
if (m === null || !Number.isFinite(Date.parse(iso))) {
|
|
23014
|
-
throw new RangeError(`activity: invalid ${what} "${iso}".`);
|
|
23015
|
-
}
|
|
23016
|
-
const [year, month, day, hour, minute, second] = m.slice(1).map(Number);
|
|
23017
|
-
const daysInMonth = month >= 1 && month <= 12 ? new Date(Date.UTC(year, month, 0)).getUTCDate() : 0;
|
|
23018
|
-
if (day < 1 || day > daysInMonth || hour > 23 || minute > 59 || second > 59) {
|
|
23019
|
-
throw new RangeError(`activity: ${what} "${iso}" is not a real calendar instant.`);
|
|
23020
|
-
}
|
|
23021
|
-
}
|
|
23022
|
-
function isRecord(value) {
|
|
23023
|
-
return typeof value === "object" && value !== null;
|
|
23024
|
-
}
|
|
23025
|
-
function str(value) {
|
|
23026
|
-
return typeof value === "string" ? value : "";
|
|
23027
|
-
}
|
|
23028
|
-
function optStr(value) {
|
|
23029
|
-
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
23030
|
-
}
|
|
23031
|
-
function ftsMatchFor(query) {
|
|
23032
|
-
if (typeof query !== "string") return null;
|
|
23033
|
-
const tokens = query.match(/[\p{L}\p{N}_]+/gu);
|
|
23034
|
-
if (!tokens || tokens.length === 0) return null;
|
|
23035
|
-
return tokens.map((token) => `"${token}"`).join(" ");
|
|
23036
|
-
}
|
|
23037
|
-
function rowToSnapshot(row) {
|
|
23038
|
-
if (!isRecord(row)) {
|
|
23039
|
-
throw new Error("activity store: unexpected non-object row");
|
|
23040
|
-
}
|
|
23041
|
-
const textSource = row.text_source === "ocr" ? "ocr" : "ax";
|
|
23042
|
-
return {
|
|
23043
|
-
id: typeof row.id === "number" ? row.id : void 0,
|
|
23044
|
-
machine: str(row.machine),
|
|
23045
|
-
capturedAtUtc: str(row.captured_at_utc),
|
|
23046
|
-
app: str(row.app_name),
|
|
23047
|
-
windowTitle: str(row.window_title),
|
|
23048
|
-
...optStr(row.browser_url) !== void 0 ? { browserUrl: optStr(row.browser_url) } : {},
|
|
23049
|
-
text: str(row.text),
|
|
23050
|
-
textSource,
|
|
23051
|
-
contentHash: str(row.content_hash),
|
|
23052
|
-
...optStr(row.simhash) !== void 0 ? { simhash: optStr(row.simhash) } : {}
|
|
23053
|
-
};
|
|
23054
|
-
}
|
|
23055
|
-
var ActivityStore = class _ActivityStore {
|
|
23056
|
-
db;
|
|
23057
|
-
constructor(db) {
|
|
23058
|
-
this.db = db;
|
|
23059
|
-
}
|
|
23060
|
-
static open(memoryDir) {
|
|
23061
|
-
return new _ActivityStore(openActivityDatabase(memoryDir));
|
|
23062
|
-
}
|
|
23063
|
-
/**
|
|
23064
|
-
* Insert a snapshot, idempotent on (machine, captured_at_utc, content_hash):
|
|
23065
|
-
* the same screen content recurring at a *different* time is kept; only an
|
|
23066
|
-
* exact re-ingestion of the same capture dedups. Returns `inserted: false`
|
|
23067
|
-
* for a duplicate. The FTS row is written only on a real insert (atomically),
|
|
23068
|
-
* so it never drifts from the base table.
|
|
23069
|
-
*/
|
|
23070
|
-
insertSnapshot(snapshot) {
|
|
23071
|
-
const runInsert = this.db.transaction((s) => {
|
|
23072
|
-
assertValidUtcInstant(s.capturedAtUtc, "capture timestamp");
|
|
23073
|
-
assertRequiredSnapshotFields(s);
|
|
23074
|
-
const capturedAtUtc = canonicalizeUtc(s.capturedAtUtc);
|
|
23075
|
-
const info = this.db.prepare(
|
|
23076
|
-
`INSERT OR IGNORE INTO activity_snapshots
|
|
23077
|
-
(machine, captured_at_utc, app_name, window_title, browser_url, text, text_source, content_hash, simhash)
|
|
23078
|
-
VALUES (@machine, @captured_at_utc, @app_name, @window_title, @browser_url, @text, @text_source, @content_hash, @simhash)`
|
|
23079
|
-
).run({
|
|
23080
|
-
machine: s.machine,
|
|
23081
|
-
captured_at_utc: capturedAtUtc,
|
|
23082
|
-
app_name: s.app,
|
|
23083
|
-
window_title: s.windowTitle,
|
|
23084
|
-
browser_url: s.browserUrl ?? null,
|
|
23085
|
-
text: s.text,
|
|
23086
|
-
text_source: s.textSource,
|
|
23087
|
-
content_hash: s.contentHash,
|
|
23088
|
-
simhash: s.simhash ?? null
|
|
23089
|
-
});
|
|
23090
|
-
if (info.changes === 0) {
|
|
23091
|
-
const existing = this.db.prepare("SELECT id FROM activity_snapshots WHERE machine = ? AND captured_at_utc = ? AND content_hash = ?").get(s.machine, capturedAtUtc, s.contentHash);
|
|
23092
|
-
const id2 = isRecord(existing) && typeof existing.id === "number" ? existing.id : -1;
|
|
23093
|
-
return { inserted: false, id: id2 };
|
|
23094
|
-
}
|
|
23095
|
-
const id = Number(info.lastInsertRowid);
|
|
23096
|
-
this.db.prepare(
|
|
23097
|
-
`INSERT INTO activity_snapshots_fts (rowid, text, app_name, window_title, browser_url)
|
|
23098
|
-
VALUES (?, ?, ?, ?, ?)`
|
|
23099
|
-
).run(id, s.text, s.app, s.windowTitle, s.browserUrl ?? "");
|
|
23100
|
-
return { inserted: true, id };
|
|
23101
|
-
});
|
|
23102
|
-
return runInsert(snapshot);
|
|
23103
|
-
}
|
|
23104
|
-
/** Snapshots whose capture instant is in the half-open [start, end) window. */
|
|
23105
|
-
listSnapshotsForDay(machine, startUtcInclusive, endUtcExclusive) {
|
|
23106
|
-
assertValidUtcInstant(startUtcInclusive, "range start");
|
|
23107
|
-
assertValidUtcInstant(endUtcExclusive, "range end");
|
|
23108
|
-
const start = canonicalizeUtc(startUtcInclusive);
|
|
23109
|
-
const end = canonicalizeUtc(endUtcExclusive);
|
|
23110
|
-
const rows = machine === null ? this.db.prepare(
|
|
23111
|
-
`SELECT * FROM activity_snapshots
|
|
23112
|
-
WHERE captured_at_utc >= ? AND captured_at_utc < ?
|
|
23113
|
-
ORDER BY captured_at_utc ASC, id ASC`
|
|
23114
|
-
).all(start, end) : this.db.prepare(
|
|
23115
|
-
`SELECT * FROM activity_snapshots
|
|
23116
|
-
WHERE machine = ? AND captured_at_utc >= ? AND captured_at_utc < ?
|
|
23117
|
-
ORDER BY captured_at_utc ASC, id ASC`
|
|
23118
|
-
).all(machine, start, end);
|
|
23119
|
-
return rows.map(rowToSnapshot);
|
|
23120
|
-
}
|
|
23121
|
-
getCursor(machine) {
|
|
23122
|
-
const row = this.db.prepare("SELECT cursor FROM activity_sync_state WHERE machine = ?").get(machine);
|
|
23123
|
-
return isRecord(row) && typeof row.cursor === "string" ? row.cursor : null;
|
|
23124
|
-
}
|
|
23125
|
-
setCursor(machine, cursor, updatedAtUtc = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
23126
|
-
this.db.prepare(
|
|
23127
|
-
`INSERT INTO activity_sync_state (machine, cursor, updated_at_utc)
|
|
23128
|
-
VALUES (?, ?, ?)
|
|
23129
|
-
ON CONFLICT(machine) DO UPDATE SET cursor = excluded.cursor, updated_at_utc = excluded.updated_at_utc`
|
|
23130
|
-
).run(machine, cursor, updatedAtUtc);
|
|
23131
|
-
}
|
|
23132
|
-
/** Full-text search over snapshot text/app/window/url; newest first. */
|
|
23133
|
-
searchSnapshots(query, limit) {
|
|
23134
|
-
const capped = Number.isInteger(limit) && limit > 0 ? Math.min(limit, MAX_SEARCH_RESULTS) : 20;
|
|
23135
|
-
const match = ftsMatchFor(query);
|
|
23136
|
-
if (match === null) return [];
|
|
23137
|
-
const rows = this.db.prepare(
|
|
23138
|
-
`SELECT s.* FROM activity_snapshots_fts f
|
|
23139
|
-
JOIN activity_snapshots s ON s.id = f.rowid
|
|
23140
|
-
WHERE activity_snapshots_fts MATCH ?
|
|
23141
|
-
ORDER BY s.captured_at_utc DESC, s.id DESC
|
|
23142
|
-
LIMIT ?`
|
|
23143
|
-
).all(match, capped);
|
|
23144
|
-
return rows.map(rowToSnapshot);
|
|
23145
|
-
}
|
|
23146
|
-
/** Retention: drop snapshots captured strictly before `cutoffUtc`. */
|
|
23147
|
-
pruneOlderThan(cutoffUtc) {
|
|
23148
|
-
assertValidUtcInstant(cutoffUtc, "prune cutoff");
|
|
23149
|
-
const ids = this.db.prepare("SELECT id FROM activity_snapshots WHERE captured_at_utc < ?").all(canonicalizeUtc(cutoffUtc)).map((row) => isRecord(row) && typeof row.id === "number" ? row.id : -1).filter((id) => id >= 0);
|
|
23150
|
-
const deleteFts = this.db.prepare("DELETE FROM activity_snapshots_fts WHERE rowid = ?");
|
|
23151
|
-
const deleteRow = this.db.prepare("DELETE FROM activity_snapshots WHERE id = ?");
|
|
23152
|
-
const tx = this.db.transaction((rowIds) => {
|
|
23153
|
-
for (const id of rowIds) {
|
|
23154
|
-
deleteFts.run(id);
|
|
23155
|
-
deleteRow.run(id);
|
|
23156
|
-
}
|
|
23157
|
-
});
|
|
23158
|
-
tx(ids);
|
|
23159
|
-
return ids.length;
|
|
23160
|
-
}
|
|
23161
|
-
close() {
|
|
23162
|
-
this.db.close();
|
|
23163
|
-
}
|
|
23164
|
-
};
|
|
23165
|
-
|
|
23166
|
-
// src/activity/digest.ts
|
|
23167
|
-
import { createHash as createHash9 } from "crypto";
|
|
23168
|
-
import path30 from "path";
|
|
23169
|
-
var ACTIVITY_DIGEST_FORMAT_VERSION = 1;
|
|
23170
|
-
var ACTIVITY_DIR_NAME = "activity";
|
|
23171
|
-
var MAX_DWELL_MS = 15 * 6e4;
|
|
23172
|
-
var NOTABLE_MAX_WINDOWS = 10;
|
|
23173
|
-
var NOTABLE_EXCERPT_CHARS = 280;
|
|
23174
|
-
var DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
|
|
23175
|
-
function isValidActivityDate(date) {
|
|
23176
|
-
if (typeof date !== "string" || !DATE_PATTERN.test(date)) return false;
|
|
23177
|
-
const parsed = /* @__PURE__ */ new Date(`${date}T00:00:00Z`);
|
|
23178
|
-
return Number.isFinite(parsed.getTime()) && parsed.toISOString().slice(0, 10) === date;
|
|
23179
|
-
}
|
|
23180
|
-
function activityDigestPath(memoryDir, date) {
|
|
23181
|
-
if (!isValidActivityDate(date)) {
|
|
23182
|
-
throw new RangeError(`Invalid activity date "${date}"; expected YYYY-MM-DD.`);
|
|
23183
|
-
}
|
|
23184
|
-
return path30.join(memoryDir, ACTIVITY_DIR_NAME, `${date}.md`);
|
|
23185
|
-
}
|
|
23186
|
-
function timezoneOffsetIso(instant, timezone) {
|
|
23187
|
-
const parts = new Intl.DateTimeFormat("en-US", {
|
|
23188
|
-
timeZone: timezone,
|
|
23189
|
-
timeZoneName: "longOffset"
|
|
23190
|
-
}).formatToParts(instant);
|
|
23191
|
-
const name = parts.find((part) => part.type === "timeZoneName")?.value ?? "GMT";
|
|
23192
|
-
const match = name.match(/GMT([+-]\d{2}:\d{2})?/);
|
|
23193
|
-
return match?.[1] ?? "+00:00";
|
|
23194
|
-
}
|
|
23195
|
-
function assertValidTimezone(timezone) {
|
|
23196
|
-
try {
|
|
23197
|
-
new Intl.DateTimeFormat("en-US", { timeZone: timezone });
|
|
23198
|
-
} catch {
|
|
23199
|
-
throw new RangeError(`Invalid IANA timezone "${timezone}" for the activity digest.`);
|
|
23200
|
-
}
|
|
23201
|
-
}
|
|
23202
|
-
function zonedDayStartIso(date, timezone) {
|
|
23203
|
-
const prevDate = shiftIsoDate(date, -1);
|
|
23204
|
-
const probeOffsets = new Set(
|
|
23205
|
-
[
|
|
23206
|
-
`${prevDate}T12:00:00Z`,
|
|
23207
|
-
`${prevDate}T23:00:00Z`,
|
|
23208
|
-
`${date}T00:00:00Z`,
|
|
23209
|
-
`${date}T12:00:00Z`,
|
|
23210
|
-
`${date}T23:00:00Z`
|
|
23211
|
-
].map((iso) => timezoneOffsetIso(new Date(iso), timezone))
|
|
23212
|
-
);
|
|
23213
|
-
let best = null;
|
|
23214
|
-
for (const offset of probeOffsets) {
|
|
23215
|
-
const candidate = Date.parse(`${date}T00:00:00${offset}`);
|
|
23216
|
-
if (!Number.isFinite(candidate)) continue;
|
|
23217
|
-
if (timezoneOffsetIso(new Date(candidate), timezone) !== offset) continue;
|
|
23218
|
-
if (best === null || candidate < best) best = candidate;
|
|
23219
|
-
}
|
|
23220
|
-
if (best === null) {
|
|
23221
|
-
for (let minute = 1; minute <= 180 && best === null; minute++) {
|
|
23222
|
-
const hh = String(Math.floor(minute / 60)).padStart(2, "0");
|
|
23223
|
-
const mm = String(minute % 60).padStart(2, "0");
|
|
23224
|
-
for (const offset of probeOffsets) {
|
|
23225
|
-
const candidate = Date.parse(`${date}T${hh}:${mm}:00${offset}`);
|
|
23226
|
-
if (!Number.isFinite(candidate)) continue;
|
|
23227
|
-
if (timezoneOffsetIso(new Date(candidate), timezone) !== offset) continue;
|
|
23228
|
-
if (best === null || candidate < best) best = candidate;
|
|
23229
|
-
}
|
|
23230
|
-
}
|
|
23231
|
-
}
|
|
23232
|
-
if (best === null) {
|
|
23233
|
-
const noon = timezoneOffsetIso(/* @__PURE__ */ new Date(`${date}T12:00:00Z`), timezone);
|
|
23234
|
-
best = Date.parse(`${date}T00:00:00${noon}`);
|
|
23235
|
-
}
|
|
23236
|
-
if (best === null || !Number.isFinite(best)) {
|
|
23237
|
-
throw new RangeError(`activity: could not resolve a local day start for "${date}" in "${timezone}".`);
|
|
23238
|
-
}
|
|
23239
|
-
return new Date(best).toISOString();
|
|
23240
|
-
}
|
|
23241
|
-
function shiftIsoDate(date, days) {
|
|
23242
|
-
const parsed = /* @__PURE__ */ new Date(`${date}T00:00:00Z`);
|
|
23243
|
-
parsed.setUTCDate(parsed.getUTCDate() + days);
|
|
23244
|
-
return parsed.toISOString().slice(0, 10);
|
|
23245
|
-
}
|
|
23246
|
-
function nextIsoDate(date) {
|
|
23247
|
-
return shiftIsoDate(date, 1);
|
|
23248
|
-
}
|
|
23249
|
-
function activityDayWindow(date, timezone) {
|
|
23250
|
-
if (!isValidActivityDate(date)) {
|
|
23251
|
-
throw new RangeError(`Invalid activity date "${date}"; expected a real YYYY-MM-DD day.`);
|
|
23252
|
-
}
|
|
23253
|
-
assertValidTimezone(timezone);
|
|
23254
|
-
return {
|
|
23255
|
-
startUtc: new Date(zonedDayStartIso(date, timezone)).toISOString(),
|
|
23256
|
-
endUtc: new Date(zonedDayStartIso(nextIsoDate(date), timezone)).toISOString()
|
|
23257
|
-
};
|
|
23258
|
-
}
|
|
23259
|
-
function sortedByTime(snapshots) {
|
|
23260
|
-
return [...snapshots].sort((a, b) => {
|
|
23261
|
-
const at2 = Date.parse(a.capturedAtUtc);
|
|
23262
|
-
const bt = Date.parse(b.capturedAtUtc);
|
|
23263
|
-
if (at2 !== bt && Number.isFinite(at2) && Number.isFinite(bt)) return at2 < bt ? -1 : 1;
|
|
23264
|
-
const aid = a.id ?? 0;
|
|
23265
|
-
const bid = b.id ?? 0;
|
|
23266
|
-
if (aid < bid) return -1;
|
|
23267
|
-
if (aid > bid) return 1;
|
|
23268
|
-
if (a.contentHash !== b.contentHash) return a.contentHash < b.contentHash ? -1 : 1;
|
|
23269
|
-
if (a.app !== b.app) return a.app < b.app ? -1 : 1;
|
|
23270
|
-
if (a.windowTitle !== b.windowTitle) return a.windowTitle < b.windowTitle ? -1 : 1;
|
|
23271
|
-
return 0;
|
|
23272
|
-
});
|
|
23273
|
-
}
|
|
23274
|
-
function computeDwell(snapshots) {
|
|
23275
|
-
const byMachine = /* @__PURE__ */ new Map();
|
|
23276
|
-
for (const snapshot of snapshots) {
|
|
23277
|
-
const list = byMachine.get(snapshot.machine);
|
|
23278
|
-
if (list === void 0) byMachine.set(snapshot.machine, [snapshot]);
|
|
23279
|
-
else list.push(snapshot);
|
|
23280
|
-
}
|
|
23281
|
-
const dwell = /* @__PURE__ */ new Map();
|
|
23282
|
-
for (const list of byMachine.values()) {
|
|
23283
|
-
const ordered = sortedByTime(list);
|
|
23284
|
-
for (let index = 0; index < ordered.length; index++) {
|
|
23285
|
-
const current = ordered[index];
|
|
23286
|
-
if (current === void 0) continue;
|
|
23287
|
-
const next = ordered[index + 1];
|
|
23288
|
-
let value = 0;
|
|
23289
|
-
if (next !== void 0) {
|
|
23290
|
-
const delta = Date.parse(next.capturedAtUtc) - Date.parse(current.capturedAtUtc);
|
|
23291
|
-
if (Number.isFinite(delta) && delta > 0) value = Math.min(delta, MAX_DWELL_MS);
|
|
23292
|
-
}
|
|
23293
|
-
dwell.set(current, value);
|
|
23294
|
-
}
|
|
23295
|
-
}
|
|
23296
|
-
return dwell;
|
|
23297
|
-
}
|
|
23298
|
-
function formatDurationMinutes(ms2) {
|
|
23299
|
-
return `${Math.round(ms2 / 6e4)}m`;
|
|
23300
|
-
}
|
|
23301
|
-
function clockHhMm(iso, timezone) {
|
|
23302
|
-
const ms2 = Date.parse(iso);
|
|
23303
|
-
if (!Number.isFinite(ms2)) return "??:??";
|
|
23304
|
-
const parts = new Intl.DateTimeFormat("en-GB", {
|
|
23305
|
-
timeZone: timezone,
|
|
23306
|
-
hour: "2-digit",
|
|
23307
|
-
minute: "2-digit",
|
|
23308
|
-
hour12: false
|
|
23309
|
-
}).formatToParts(new Date(ms2));
|
|
23310
|
-
const hour = parts.find((p) => p.type === "hour")?.value ?? "00";
|
|
23311
|
-
const minute = parts.find((p) => p.type === "minute")?.value ?? "00";
|
|
23312
|
-
return `${hour}:${minute}`;
|
|
23313
|
-
}
|
|
23314
|
-
function collapseWhitespace(text) {
|
|
23315
|
-
return text.replace(/\s+/g, " ").trim();
|
|
23316
|
-
}
|
|
23317
|
-
function perAppSection(ordered, dwell) {
|
|
23318
|
-
const totals = /* @__PURE__ */ new Map();
|
|
23319
|
-
for (const snapshot of ordered) {
|
|
23320
|
-
totals.set(snapshot.app, (totals.get(snapshot.app) ?? 0) + (dwell.get(snapshot) ?? 0));
|
|
23321
|
-
}
|
|
23322
|
-
const rows = [...totals.entries()].sort((a, b) => {
|
|
23323
|
-
if (b[1] !== a[1]) return b[1] - a[1];
|
|
23324
|
-
if (a[0] < b[0]) return -1;
|
|
23325
|
-
if (a[0] > b[0]) return 1;
|
|
23326
|
-
return 0;
|
|
23327
|
-
});
|
|
23328
|
-
const lines = ["## Per-app time", ""];
|
|
23329
|
-
if (rows.length === 0) {
|
|
23330
|
-
lines.push("_No activity recorded._");
|
|
23331
|
-
} else {
|
|
23332
|
-
for (const [app, ms2] of rows) {
|
|
23333
|
-
lines.push(`- ${app}: ${formatDurationMinutes(ms2)}`);
|
|
23334
|
-
}
|
|
23335
|
-
}
|
|
23336
|
-
return lines.join("\n");
|
|
23337
|
-
}
|
|
23338
|
-
function timelineSpans(ordered) {
|
|
23339
|
-
const spans = [];
|
|
23340
|
-
for (const snapshot of ordered) {
|
|
23341
|
-
const last = spans[spans.length - 1];
|
|
23342
|
-
if (last !== void 0 && last.machine === snapshot.machine && last.app === snapshot.app && last.windowTitle === snapshot.windowTitle && last.browserUrl === snapshot.browserUrl) {
|
|
23343
|
-
continue;
|
|
23344
|
-
}
|
|
23345
|
-
spans.push({
|
|
23346
|
-
startIso: snapshot.capturedAtUtc,
|
|
23347
|
-
machine: snapshot.machine,
|
|
23348
|
-
app: snapshot.app,
|
|
23349
|
-
windowTitle: snapshot.windowTitle,
|
|
23350
|
-
...snapshot.browserUrl !== void 0 ? { browserUrl: snapshot.browserUrl } : {}
|
|
23351
|
-
});
|
|
23352
|
-
}
|
|
23353
|
-
return spans;
|
|
23354
|
-
}
|
|
23355
|
-
function timelineSection(ordered, timezone) {
|
|
23356
|
-
const lines = ["## Timeline", ""];
|
|
23357
|
-
const spans = timelineSpans(ordered);
|
|
23358
|
-
if (spans.length === 0) {
|
|
23359
|
-
lines.push("_No activity recorded._");
|
|
23360
|
-
return lines.join("\n");
|
|
23361
|
-
}
|
|
23362
|
-
for (const span of spans) {
|
|
23363
|
-
const clock = clockHhMm(span.startIso, timezone);
|
|
23364
|
-
const window = collapseWhitespace(span.windowTitle);
|
|
23365
|
-
const url = span.browserUrl !== void 0 ? ` (${collapseWhitespace(span.browserUrl)})` : "";
|
|
23366
|
-
lines.push(`- [${clock}] ${span.app}${window.length > 0 ? ` \u2014 ${window}` : ""}${url}`);
|
|
23367
|
-
}
|
|
23368
|
-
return lines.join("\n");
|
|
23369
|
-
}
|
|
23370
|
-
function notableSection(ordered, dwell) {
|
|
23371
|
-
const withDwell = ordered.map((snapshot) => ({ snapshot, dwell: dwell.get(snapshot) ?? 0 }));
|
|
23372
|
-
const ranked = withDwell.filter((entry) => collapseWhitespace(entry.snapshot.text).length > 0).sort((a, b) => {
|
|
23373
|
-
if (b.dwell !== a.dwell) return b.dwell - a.dwell;
|
|
23374
|
-
const at2 = Date.parse(a.snapshot.capturedAtUtc);
|
|
23375
|
-
const bt = Date.parse(b.snapshot.capturedAtUtc);
|
|
23376
|
-
if (at2 !== bt && Number.isFinite(at2) && Number.isFinite(bt)) return at2 < bt ? -1 : 1;
|
|
23377
|
-
const idDelta = (a.snapshot.id ?? 0) - (b.snapshot.id ?? 0);
|
|
23378
|
-
if (idDelta !== 0) return idDelta;
|
|
23379
|
-
if (a.snapshot.contentHash !== b.snapshot.contentHash) {
|
|
23380
|
-
return a.snapshot.contentHash < b.snapshot.contentHash ? -1 : 1;
|
|
23381
|
-
}
|
|
23382
|
-
return 0;
|
|
23383
|
-
}).slice(0, NOTABLE_MAX_WINDOWS);
|
|
23384
|
-
const lines = ["## Notable", ""];
|
|
23385
|
-
if (ranked.length === 0) {
|
|
23386
|
-
lines.push("_No notable text captured._");
|
|
23387
|
-
return lines.join("\n");
|
|
23388
|
-
}
|
|
23389
|
-
for (const { snapshot } of ranked) {
|
|
23390
|
-
const excerpt = collapseWhitespace(snapshot.text).slice(0, NOTABLE_EXCERPT_CHARS);
|
|
23391
|
-
lines.push(`- **${snapshot.app}** \u2014 ${excerpt}`);
|
|
23392
|
-
}
|
|
23393
|
-
return lines.join("\n");
|
|
23394
|
-
}
|
|
23395
|
-
function composeActivityDigestBody(date, timezone, snapshots) {
|
|
23396
|
-
assertValidTimezone(timezone);
|
|
23397
|
-
const ordered = sortedByTime(snapshots);
|
|
23398
|
-
const dwell = computeDwell(ordered);
|
|
23399
|
-
return [
|
|
23400
|
-
`# Activity \u2014 ${date}`,
|
|
23401
|
-
"",
|
|
23402
|
-
perAppSection(ordered, dwell),
|
|
23403
|
-
"",
|
|
23404
|
-
timelineSection(ordered, timezone),
|
|
23405
|
-
"",
|
|
23406
|
-
notableSection(ordered, dwell),
|
|
23407
|
-
""
|
|
23408
|
-
].join("\n");
|
|
23409
|
-
}
|
|
23410
|
-
function hashActivityBody(body) {
|
|
23411
|
-
return createHash9("sha256").update(body, "utf8").digest("hex");
|
|
23412
|
-
}
|
|
23413
|
-
function composeActivityDigestMeta(date, machines, snapshots, body) {
|
|
23414
|
-
const uniqueMachines = [...new Set(machines)].sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
23415
|
-
return {
|
|
23416
|
-
kind: "activity-digest",
|
|
23417
|
-
date,
|
|
23418
|
-
machines: uniqueMachines,
|
|
23419
|
-
snapshotCount: snapshots.length,
|
|
23420
|
-
contentHash: hashActivityBody(body),
|
|
23421
|
-
formatVersion: ACTIVITY_DIGEST_FORMAT_VERSION
|
|
23422
|
-
};
|
|
23423
|
-
}
|
|
23424
|
-
function serializeActivityDigest(meta, body) {
|
|
23425
|
-
const frontmatter = [
|
|
23426
|
-
"---",
|
|
23427
|
-
`kind: ${meta.kind}`,
|
|
23428
|
-
`date: ${meta.date}`,
|
|
23429
|
-
`machines: ${JSON.stringify(meta.machines)}`,
|
|
23430
|
-
`snapshotCount: ${meta.snapshotCount}`,
|
|
23431
|
-
`contentHash: ${meta.contentHash}`,
|
|
23432
|
-
`formatVersion: ${meta.formatVersion}`,
|
|
23433
|
-
"---",
|
|
23434
|
-
""
|
|
23435
|
-
].join("\n");
|
|
23436
|
-
return `${frontmatter}${body}`;
|
|
23437
|
-
}
|
|
23438
|
-
function parseActivityDigest(raw) {
|
|
23439
|
-
if (typeof raw !== "string" || !raw.startsWith("---\n")) return null;
|
|
23440
|
-
const end = raw.indexOf("\n---\n", 4);
|
|
23441
|
-
if (end === -1) return null;
|
|
23442
|
-
const frontmatter = raw.slice(4, end);
|
|
23443
|
-
const body = raw.slice(end + 5).replace(/^\n/, "");
|
|
23444
|
-
const fields = /* @__PURE__ */ new Map();
|
|
23445
|
-
for (const line of frontmatter.split("\n")) {
|
|
23446
|
-
const idx = line.indexOf(":");
|
|
23447
|
-
if (idx === -1) continue;
|
|
23448
|
-
fields.set(line.slice(0, idx).trim(), line.slice(idx + 1).trim());
|
|
23449
|
-
}
|
|
23450
|
-
const date = fields.get("date");
|
|
23451
|
-
const contentHash = fields.get("contentHash");
|
|
23452
|
-
if (date === void 0 || !isValidActivityDate(date) || contentHash === void 0) return null;
|
|
23453
|
-
if (fields.get("kind") !== "activity-digest") return null;
|
|
23454
|
-
const machines = parseMachinesList(fields.get("machines") ?? "[]");
|
|
23455
|
-
const snapshotCount = parseNonNegativeInt(fields.get("snapshotCount"));
|
|
23456
|
-
const formatVersion = parseNonNegativeInt(fields.get("formatVersion"));
|
|
23457
|
-
if (snapshotCount === null || formatVersion === null) return null;
|
|
23458
|
-
return {
|
|
23459
|
-
meta: {
|
|
23460
|
-
kind: "activity-digest",
|
|
23461
|
-
date,
|
|
23462
|
-
machines,
|
|
23463
|
-
snapshotCount,
|
|
23464
|
-
contentHash,
|
|
23465
|
-
formatVersion
|
|
23466
|
-
},
|
|
23467
|
-
body
|
|
23468
|
-
};
|
|
23469
|
-
}
|
|
23470
|
-
function parseNonNegativeInt(value) {
|
|
23471
|
-
if (value === void 0) return null;
|
|
23472
|
-
const trimmed = value.trim();
|
|
23473
|
-
if (!/^\d+$/.test(trimmed)) return null;
|
|
23474
|
-
const parsed = Number(trimmed);
|
|
23475
|
-
return Number.isSafeInteger(parsed) ? parsed : null;
|
|
23476
|
-
}
|
|
23477
|
-
function parseMachinesList(raw) {
|
|
23478
|
-
try {
|
|
23479
|
-
const parsed = JSON.parse(raw);
|
|
23480
|
-
if (Array.isArray(parsed)) {
|
|
23481
|
-
return parsed.filter((entry) => typeof entry === "string");
|
|
23482
|
-
}
|
|
23483
|
-
} catch {
|
|
23484
|
-
}
|
|
23485
|
-
return raw.replace(/^\[/, "").replace(/\]$/, "").split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0);
|
|
23486
|
-
}
|
|
23487
|
-
|
|
23488
22929
|
// src/meetings/detect.ts
|
|
23489
|
-
import { createHash as
|
|
22930
|
+
import { createHash as createHash9 } from "crypto";
|
|
23490
22931
|
var DEFAULT_MEETING_APP_PATTERNS = [
|
|
23491
22932
|
"zoom.us",
|
|
23492
22933
|
"Zoom",
|
|
@@ -23528,7 +22969,7 @@ function meetingId(date, startUtc) {
|
|
|
23528
22969
|
throw new RangeError(`meetings: invalid meeting start "${startUtc}" for a meeting id.`);
|
|
23529
22970
|
}
|
|
23530
22971
|
const anchor = new Date(startMs).toISOString();
|
|
23531
|
-
const hash =
|
|
22972
|
+
const hash = createHash9("sha256").update(`${date}|${anchor}`, "utf8").digest("hex").slice(0, 8);
|
|
23532
22973
|
return `mtg-${date}-${hash}`;
|
|
23533
22974
|
}
|
|
23534
22975
|
function isFinitePair(a, b) {
|
|
@@ -23663,9 +23104,9 @@ function detectMeetings(input, config = DEFAULT_MEETINGS_DETECTION_CONFIG) {
|
|
|
23663
23104
|
}
|
|
23664
23105
|
|
|
23665
23106
|
// src/session-summaries/index.ts
|
|
23666
|
-
import { createHash as
|
|
23667
|
-
import { lstat as lstat2, mkdir as
|
|
23668
|
-
import
|
|
23107
|
+
import { createHash as createHash10 } from "crypto";
|
|
23108
|
+
import { lstat as lstat2, mkdir as mkdir7, readFile as readFile6, readdir as readdir4, rename, rm, stat as stat4, writeFile as writeFile7 } from "fs/promises";
|
|
23109
|
+
import path29 from "path";
|
|
23669
23110
|
|
|
23670
23111
|
// src/session-summaries/adapters.ts
|
|
23671
23112
|
var VALID_ROLES = /* @__PURE__ */ new Set(["user", "assistant", "tool", "system", "other"]);
|
|
@@ -24165,12 +23606,12 @@ var DEFAULT_MAX_FILES = 5e3;
|
|
|
24165
23606
|
var DEFAULT_MAX_SESSIONS = 500;
|
|
24166
23607
|
var SUPPORTED_EXTENSIONS = /* @__PURE__ */ new Set([".json", ".jsonl"]);
|
|
24167
23608
|
function shortHash(value, length = 16) {
|
|
24168
|
-
return
|
|
23609
|
+
return createHash10("sha256").update(value).digest("hex").slice(0, length);
|
|
24169
23610
|
}
|
|
24170
23611
|
async function listTranscriptFiles(root, maxFiles) {
|
|
24171
23612
|
const out = [];
|
|
24172
23613
|
let truncated = false;
|
|
24173
|
-
const entrySortKey = (entryName, isDirectory) => isDirectory ? `${entryName}${
|
|
23614
|
+
const entrySortKey = (entryName, isDirectory) => isDirectory ? `${entryName}${path29.sep}` : entryName;
|
|
24174
23615
|
async function visit(dir) {
|
|
24175
23616
|
if (truncated) return;
|
|
24176
23617
|
const entries = (await readdir4(dir, { withFileTypes: true })).sort(
|
|
@@ -24180,13 +23621,13 @@ async function listTranscriptFiles(root, maxFiles) {
|
|
|
24180
23621
|
if (truncated) return;
|
|
24181
23622
|
if (entry.name.startsWith(".")) continue;
|
|
24182
23623
|
if (entry.isSymbolicLink()) continue;
|
|
24183
|
-
const fullPath =
|
|
23624
|
+
const fullPath = path29.join(dir, entry.name);
|
|
24184
23625
|
if (entry.isDirectory()) {
|
|
24185
23626
|
await visit(fullPath);
|
|
24186
23627
|
continue;
|
|
24187
23628
|
}
|
|
24188
23629
|
if (!entry.isFile()) continue;
|
|
24189
|
-
const ext =
|
|
23630
|
+
const ext = path29.extname(entry.name).toLowerCase();
|
|
24190
23631
|
if (!SUPPORTED_EXTENSIONS.has(ext)) continue;
|
|
24191
23632
|
out.push(fullPath);
|
|
24192
23633
|
if (out.length > maxFiles) {
|
|
@@ -24213,7 +23654,7 @@ function normalizeInputDir(inputDir) {
|
|
|
24213
23654
|
if (typeof inputDir !== "string" || inputDir.trim().length === 0) {
|
|
24214
23655
|
throw new Error("inputDir must be a non-empty string");
|
|
24215
23656
|
}
|
|
24216
|
-
return
|
|
23657
|
+
return path29.resolve(expandTildePath(inputDir.trim()));
|
|
24217
23658
|
}
|
|
24218
23659
|
function initRoleCounts() {
|
|
24219
23660
|
return {
|
|
@@ -24370,11 +23811,11 @@ async function collectLocalSessionSummaries(options) {
|
|
|
24370
23811
|
continue;
|
|
24371
23812
|
}
|
|
24372
23813
|
seenFileHashes.add(fileHash);
|
|
24373
|
-
const fileExtension =
|
|
23814
|
+
const fileExtension = path29.extname(filePath).toLowerCase();
|
|
24374
23815
|
const parsed = await adapter.parseFile(
|
|
24375
23816
|
{
|
|
24376
23817
|
content,
|
|
24377
|
-
fileName:
|
|
23818
|
+
fileName: path29.basename(filePath),
|
|
24378
23819
|
fileExtension,
|
|
24379
23820
|
fileRef: fileHash
|
|
24380
23821
|
},
|
|
@@ -24430,7 +23871,7 @@ async function collectLocalSessionSummaries(options) {
|
|
|
24430
23871
|
}
|
|
24431
23872
|
async function readRedactionConfig(pathLike) {
|
|
24432
23873
|
if (!pathLike) return void 0;
|
|
24433
|
-
const raw = await readFile6(
|
|
23874
|
+
const raw = await readFile6(path29.resolve(expandTildePath(pathLike)), "utf-8");
|
|
24434
23875
|
const parsed = JSON.parse(raw);
|
|
24435
23876
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
24436
23877
|
throw new Error("redaction config must be a JSON object");
|
|
@@ -24443,15 +23884,15 @@ function toJsonl(drafts) {
|
|
|
24443
23884
|
}
|
|
24444
23885
|
function defaultDraftOutputPath(memoryDir, generatedAt) {
|
|
24445
23886
|
const stamp = generatedAt.replace(/[:.]/g, "-");
|
|
24446
|
-
return
|
|
24447
|
-
|
|
23887
|
+
return path29.join(
|
|
23888
|
+
path29.resolve(expandTildePath(memoryDir)),
|
|
24448
23889
|
"state",
|
|
24449
23890
|
"session-summary-drafts",
|
|
24450
23891
|
`session-summaries-${stamp}.jsonl`
|
|
24451
23892
|
);
|
|
24452
23893
|
}
|
|
24453
23894
|
async function writeDrafts(filePath, drafts) {
|
|
24454
|
-
await
|
|
23895
|
+
await mkdir7(path29.dirname(filePath), { recursive: true });
|
|
24455
23896
|
const tempPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
24456
23897
|
try {
|
|
24457
23898
|
await writeFile7(tempPath, toJsonl(drafts), "utf-8");
|
|
@@ -24469,7 +23910,7 @@ async function runLocalSessionSummaryCliCommand(options) {
|
|
|
24469
23910
|
});
|
|
24470
23911
|
const wroteFiles = [];
|
|
24471
23912
|
if (options.output) {
|
|
24472
|
-
const outputPath =
|
|
23913
|
+
const outputPath = path29.resolve(expandTildePath(options.output));
|
|
24473
23914
|
await writeDrafts(outputPath, report.drafts);
|
|
24474
23915
|
wroteFiles.push(outputPath);
|
|
24475
23916
|
}
|
|
@@ -24503,20 +23944,20 @@ async function runLocalSessionSummaryCliCommand(options) {
|
|
|
24503
23944
|
}
|
|
24504
23945
|
|
|
24505
23946
|
// src/transfer/capsule-fork.ts
|
|
24506
|
-
import { lstat as lstat3, mkdir as
|
|
24507
|
-
import
|
|
23947
|
+
import { lstat as lstat3, mkdir as mkdir8, readFile as readFile7, realpath as realpath2, writeFile as writeFile8 } from "fs/promises";
|
|
23948
|
+
import path30 from "path";
|
|
24508
23949
|
async function forkCapsule(opts) {
|
|
24509
23950
|
validateForkId(opts.forkId);
|
|
24510
|
-
const rootAbs =
|
|
23951
|
+
const rootAbs = path30.resolve(opts.targetRoot);
|
|
24511
23952
|
await assertIsDirectoryNotSymlink(rootAbs, "forkCapsule", "targetRoot");
|
|
24512
|
-
const forkDirAbs =
|
|
23953
|
+
const forkDirAbs = path30.join(rootAbs, "forks", opts.forkId);
|
|
24513
23954
|
const forkEntryExists = await pathEntryExists(forkDirAbs);
|
|
24514
23955
|
if (forkEntryExists) {
|
|
24515
23956
|
throw new Error(
|
|
24516
23957
|
`forkCapsule: fork path already exists \u2014 forkId "${opts.forkId}" is already in use at: ${forkDirAbs}`
|
|
24517
23958
|
);
|
|
24518
23959
|
}
|
|
24519
|
-
const archiveAbs =
|
|
23960
|
+
const archiveAbs = path30.resolve(opts.sourceArchive);
|
|
24520
23961
|
const importResult = await importCapsule({
|
|
24521
23962
|
archivePath: archiveAbs,
|
|
24522
23963
|
root: rootAbs,
|
|
@@ -24538,10 +23979,10 @@ async function forkCapsule(opts) {
|
|
|
24538
23979
|
importedRecords: importResult.imported.length,
|
|
24539
23980
|
skippedRecords: importResult.skipped.length
|
|
24540
23981
|
};
|
|
24541
|
-
const lineagePath =
|
|
23982
|
+
const lineagePath = path30.join(forkDirAbs, "lineage.json");
|
|
24542
23983
|
const rootReal = await realpath2(rootAbs);
|
|
24543
23984
|
await assertRealpathInsideRoot(rootReal, lineagePath, `forks/${opts.forkId}/lineage.json`, "forkCapsule");
|
|
24544
|
-
await
|
|
23985
|
+
await mkdir8(path30.dirname(lineagePath), { recursive: true });
|
|
24545
23986
|
await writeFile8(lineagePath, JSON.stringify(lineage, null, 2) + "\n", "utf-8");
|
|
24546
23987
|
return {
|
|
24547
23988
|
archivePath: archiveAbs,
|
|
@@ -24555,11 +23996,11 @@ async function readForkLineage(targetRoot, forkId) {
|
|
|
24555
23996
|
if (typeof forkId !== "string" || forkId.length === 0 || forkId.length > 64 || !CAPSULE_ID_PATTERN.test(forkId)) {
|
|
24556
23997
|
return null;
|
|
24557
23998
|
}
|
|
24558
|
-
const rootAbs =
|
|
23999
|
+
const rootAbs = path30.resolve(targetRoot);
|
|
24559
24000
|
const rootReal = await realpath2(rootAbs).catch(() => rootAbs);
|
|
24560
|
-
const lineagePath =
|
|
24561
|
-
const rel =
|
|
24562
|
-
if (rel.startsWith("..") ||
|
|
24001
|
+
const lineagePath = path30.join(rootReal, "forks", forkId, "lineage.json");
|
|
24002
|
+
const rel = path30.relative(rootReal, lineagePath);
|
|
24003
|
+
if (rel.startsWith("..") || path30.isAbsolute(rel)) {
|
|
24563
24004
|
return null;
|
|
24564
24005
|
}
|
|
24565
24006
|
if (!await isLineagePathContained(rootReal, lineagePath)) {
|
|
@@ -24600,19 +24041,19 @@ async function pathEntryExists(absPath) {
|
|
|
24600
24041
|
async function isLineagePathContained(rootReal, lineagePath) {
|
|
24601
24042
|
let existing = lineagePath;
|
|
24602
24043
|
const suffix = [];
|
|
24603
|
-
while (existing !==
|
|
24044
|
+
while (existing !== path30.dirname(existing)) {
|
|
24604
24045
|
const st = await lstat3(existing).catch(() => null);
|
|
24605
24046
|
if (st !== null) break;
|
|
24606
|
-
suffix.unshift(
|
|
24607
|
-
existing =
|
|
24047
|
+
suffix.unshift(path30.basename(existing));
|
|
24048
|
+
existing = path30.dirname(existing);
|
|
24608
24049
|
}
|
|
24609
24050
|
const existingReal = await realpath2(existing).catch(() => existing);
|
|
24610
|
-
const targetReal = suffix.length > 0 ?
|
|
24611
|
-
const rel =
|
|
24051
|
+
const targetReal = suffix.length > 0 ? path30.join(existingReal, ...suffix) : existingReal;
|
|
24052
|
+
const rel = path30.relative(rootReal, targetReal);
|
|
24612
24053
|
if (rel === "") return true;
|
|
24613
24054
|
if (rel === "..") return false;
|
|
24614
|
-
if (rel.startsWith(`..${
|
|
24615
|
-
if (
|
|
24055
|
+
if (rel.startsWith(`..${path30.sep}`)) return false;
|
|
24056
|
+
if (path30.isAbsolute(rel)) return false;
|
|
24616
24057
|
return true;
|
|
24617
24058
|
}
|
|
24618
24059
|
|
|
@@ -24739,21 +24180,6 @@ export {
|
|
|
24739
24180
|
ensureBuiltInWearableConnectors,
|
|
24740
24181
|
WearablesService,
|
|
24741
24182
|
locateTranscriptPath,
|
|
24742
|
-
activityDatabasePath,
|
|
24743
|
-
ensureActivityStateDir,
|
|
24744
|
-
openActivityDatabase,
|
|
24745
|
-
applyActivitySchema,
|
|
24746
|
-
ActivityStore,
|
|
24747
|
-
ACTIVITY_DIGEST_FORMAT_VERSION,
|
|
24748
|
-
ACTIVITY_DIR_NAME,
|
|
24749
|
-
isValidActivityDate,
|
|
24750
|
-
activityDigestPath,
|
|
24751
|
-
activityDayWindow,
|
|
24752
|
-
composeActivityDigestBody,
|
|
24753
|
-
hashActivityBody,
|
|
24754
|
-
composeActivityDigestMeta,
|
|
24755
|
-
serializeActivityDigest,
|
|
24756
|
-
parseActivityDigest,
|
|
24757
24183
|
DEFAULT_MEETING_APP_PATTERNS,
|
|
24758
24184
|
DEFAULT_MEETINGS_DETECTION_CONFIG,
|
|
24759
24185
|
meetingId,
|
|
@@ -24773,4 +24199,4 @@ export {
|
|
|
24773
24199
|
blendGraphExpandedRecallScore,
|
|
24774
24200
|
Orchestrator
|
|
24775
24201
|
};
|
|
24776
|
-
//# sourceMappingURL=chunk-
|
|
24202
|
+
//# sourceMappingURL=chunk-GRJ5UOFO.js.map
|