@remnic/core 9.3.743 → 9.3.745

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.
Files changed (242) hide show
  1. package/dist/access-boundary.d.ts +18 -16
  2. package/dist/access-boundary.js +14 -15
  3. package/dist/access-cli.js +92 -33
  4. package/dist/access-cli.js.map +1 -1
  5. package/dist/access-http.d.ts +18 -16
  6. package/dist/access-http.js +20 -21
  7. package/dist/access-mcp.d.ts +18 -16
  8. package/dist/access-mcp.js +18 -19
  9. package/dist/access-operations-batch.js +16 -17
  10. package/dist/access-operations.d.ts +18 -16
  11. package/dist/access-operations.js +17 -18
  12. package/dist/access-schema.js +3 -3
  13. package/dist/{access-service-BeW5GOg1.d.ts → access-service-CdY88L86.d.ts} +3 -30
  14. package/dist/access-service.d.ts +8 -6
  15. package/dist/access-service.js +13 -14
  16. package/dist/access-surface-catalog.d.ts +18 -16
  17. package/dist/action-confidence.d.ts +1 -1
  18. package/dist/active-memory-bridge.d.ts +1 -1
  19. package/dist/active-recall.d.ts +1 -1
  20. package/dist/{auto-sync-XHSKKQAH.js → auto-sync-IEBKPGAM.js} +2 -2
  21. package/dist/behavior-learner.d.ts +1 -1
  22. package/dist/behavior-signals.d.ts +1 -1
  23. package/dist/bootstrap.d.ts +7 -4
  24. package/dist/briefing.d.ts +1 -1
  25. package/dist/briefing.js +3 -3
  26. package/dist/buffer-surprise-report.d.ts +1 -1
  27. package/dist/buffer.d.ts +1 -1
  28. package/dist/calibration.d.ts +1 -1
  29. package/dist/capabilities.d.ts +1 -1
  30. package/dist/{catalog-CX0CjOaf.d.ts → catalog-D_ZDxu8Y.d.ts} +1 -1
  31. package/dist/causal-behavior.d.ts +1 -1
  32. package/dist/causal-consolidation.d.ts +1 -1
  33. package/dist/causal-consolidation.js +4 -4
  34. package/dist/causal-trajectory-graph.d.ts +1 -1
  35. package/dist/{chunk-WPLRJ4XM.js → chunk-24YDB5QP.js} +2098 -230
  36. package/dist/chunk-24YDB5QP.js.map +1 -0
  37. package/dist/{chunk-6XG3NQRC.js → chunk-3IJGF6K2.js} +2 -2
  38. package/dist/{chunk-U5WVRMCA.js → chunk-5IN26V6W.js} +2 -2
  39. package/dist/{chunk-XEADGIAA.js → chunk-DIHCFJVV.js} +7 -7
  40. package/dist/{chunk-C7LDPZJJ.js → chunk-EHYB325U.js} +227 -227
  41. package/dist/chunk-EHYB325U.js.map +1 -0
  42. package/dist/{chunk-E7RGJQWP.js → chunk-HIHCB2S6.js} +2 -2
  43. package/dist/{chunk-JFCS6PQU.js → chunk-JHQUIH3W.js} +5 -5
  44. package/dist/{chunk-MXDG6SRH.js → chunk-JRDPT6DA.js} +2 -2
  45. package/dist/{chunk-BYLC4DKI.js → chunk-KMNYXLPL.js} +2 -2
  46. package/dist/{chunk-TQPSOTC7.js → chunk-L4N7SVNN.js} +8 -10
  47. package/dist/{chunk-TQPSOTC7.js.map → chunk-L4N7SVNN.js.map} +1 -1
  48. package/dist/{chunk-DYK27X7V.js → chunk-LMFS64GY.js} +3 -3
  49. package/dist/{chunk-FWXLKH2H.js → chunk-NVYF5OB6.js} +3 -3
  50. package/dist/{chunk-G5FP7VSQ.js → chunk-P4FW3ZU5.js} +58 -60
  51. package/dist/{chunk-G5FP7VSQ.js.map → chunk-P4FW3ZU5.js.map} +1 -1
  52. package/dist/{chunk-56F6EAQ6.js → chunk-Q3X7GUAQ.js} +2 -2
  53. package/dist/{chunk-7N7S2RKF.js → chunk-R2OAN6IP.js} +2 -2
  54. package/dist/{chunk-CHELXDTO.js → chunk-RB6A7OUN.js} +2 -2
  55. package/dist/{chunk-3EA5LIFJ.js → chunk-SIV3JZPP.js} +2 -2
  56. package/dist/{chunk-IP5SANO2.js → chunk-UIKZZ242.js} +2 -2
  57. package/dist/{chunk-UGFPGWJB.js → chunk-URQLO7BX.js} +2 -2
  58. package/dist/{chunk-5UNSGRCR.js → chunk-WK3NK6SP.js} +162 -16
  59. package/dist/chunk-WK3NK6SP.js.map +1 -0
  60. package/dist/{chunk-VE54E6RP.js → chunk-WWVXXSLF.js} +4 -6
  61. package/dist/{chunk-VE54E6RP.js.map → chunk-WWVXXSLF.js.map} +1 -1
  62. package/dist/{chunk-WO22UEM3.js → chunk-XTEWVF3C.js} +2 -2
  63. package/dist/{chunk-VO4VARZL.js → chunk-YQX63P3W.js} +18033 -12571
  64. package/dist/chunk-YQX63P3W.js.map +1 -0
  65. package/dist/{chunk-FCQ7ZYCQ.js → chunk-ZGAJB74V.js} +2 -2
  66. package/dist/{chunk-NBP3YHHS.js → chunk-ZGZNLRKF.js} +2 -2
  67. package/dist/{chunk-C7C5WIIF.js → chunk-ZPZ4VVLT.js} +2 -2
  68. package/dist/{cli-BYad9YYY.d.ts → cli-BNJtn0R0.d.ts} +3 -3
  69. package/dist/cli.d.ts +9 -7
  70. package/dist/cli.js +44 -46
  71. package/dist/compounding/engine.d.ts +1 -1
  72. package/dist/compounding/engine.js +3 -3
  73. package/dist/compounding/preference-consolidator.d.ts +1 -1
  74. package/dist/compression-optimizer.d.ts +1 -1
  75. package/dist/config.d.ts +1 -1
  76. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  77. package/dist/connectors/codex-materialize-runner.js +3 -3
  78. package/dist/connectors/codex-materialize.d.ts +1 -1
  79. package/dist/connectors/index.d.ts +1 -1
  80. package/dist/connectors/index.js +3 -3
  81. package/dist/consolidation-provenance-check.d.ts +1 -1
  82. package/dist/consolidation-undo.d.ts +1 -1
  83. package/dist/contradiction/index.d.ts +1 -1
  84. package/dist/contradiction/index.js +4 -4
  85. package/dist/conversation-index/backend.d.ts +1 -1
  86. package/dist/conversation-index/chunker.d.ts +1 -1
  87. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  88. package/dist/conversation-index/indexer.d.ts +1 -1
  89. package/dist/conversation-index/search.d.ts +1 -1
  90. package/dist/day-summary.d.ts +1 -1
  91. package/dist/delinearize.d.ts +1 -1
  92. package/dist/direct-answer-wiring.d.ts +1 -1
  93. package/dist/direct-answer.d.ts +1 -1
  94. package/dist/embedding-fallback.d.ts +1 -1
  95. package/dist/enrichment/index.d.ts +1 -1
  96. package/dist/entity-retrieval.d.ts +1 -1
  97. package/dist/entity-retrieval.js +3 -3
  98. package/dist/entity-schema.d.ts +1 -1
  99. package/dist/explicit-capture.d.ts +7 -4
  100. package/dist/extraction-faithfulness.d.ts +1 -1
  101. package/dist/extraction-judge-telemetry.d.ts +1 -1
  102. package/dist/extraction-judge-training.d.ts +1 -1
  103. package/dist/extraction-judge.d.ts +1 -1
  104. package/dist/extraction.d.ts +1 -1
  105. package/dist/fallback-llm.d.ts +1 -1
  106. package/dist/graph-dashboard-diff.d.ts +1 -1
  107. package/dist/graph-dashboard-key.d.ts +1 -1
  108. package/dist/graph-dashboard-parser.d.ts +1 -1
  109. package/dist/graph-edge-reinforcement.d.ts +1 -1
  110. package/dist/graph-snapshot.d.ts +1 -1
  111. package/dist/graph.d.ts +1 -1
  112. package/dist/identity-continuity.d.ts +1 -1
  113. package/dist/importance.d.ts +1 -1
  114. package/dist/index.d.ts +13 -11
  115. package/dist/index.js +271 -5362
  116. package/dist/index.js.map +1 -1
  117. package/dist/intent.d.ts +1 -1
  118. package/dist/lcm/engine.d.ts +1 -1
  119. package/dist/lcm/index.d.ts +1 -1
  120. package/dist/lcm/tools.d.ts +1 -1
  121. package/dist/lifecycle.d.ts +1 -1
  122. package/dist/live-connectors-runner.d.ts +1 -1
  123. package/dist/local-llm.d.ts +1 -1
  124. package/dist/local-model-endpoint.d.ts +1 -1
  125. package/dist/maintenance/memory-governance.d.ts +1 -1
  126. package/dist/maintenance/memory-governance.js +3 -3
  127. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +3 -3
  128. package/dist/maintenance/rebuild-memory-projection.js +4 -4
  129. package/dist/mcp-memory-inspector-app.d.ts +17 -15
  130. package/dist/memory-action-policy.d.ts +1 -1
  131. package/dist/memory-cache.d.ts +1 -1
  132. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  133. package/dist/memory-projection-store.d.ts +1 -1
  134. package/dist/memory-provenance.d.ts +1 -1
  135. package/dist/memory-worth-outcomes.d.ts +1 -1
  136. package/dist/models-json.d.ts +1 -1
  137. package/dist/namespaces/migrate.d.ts +2 -2
  138. package/dist/namespaces/migrate.js +4 -4
  139. package/dist/namespaces/principal.d.ts +1 -1
  140. package/dist/namespaces/search.d.ts +1 -1
  141. package/dist/namespaces/storage.d.ts +2 -2
  142. package/dist/namespaces/storage.js +3 -3
  143. package/dist/native-knowledge.d.ts +1 -1
  144. package/dist/operator-toolkit.d.ts +1 -1
  145. package/dist/operator-toolkit.js +10 -11
  146. package/dist/orchestration/compression-guideline-coordinator.d.ts +1 -1
  147. package/dist/orchestration/maintenance.d.ts +2 -2
  148. package/dist/orchestration/maintenance.js +5 -5
  149. package/dist/{orchestrator-CupigmWu.d.ts → orchestrator-BBGXLd20.d.ts} +270 -32
  150. package/dist/orchestrator.d.ts +7 -4
  151. package/dist/orchestrator.js +119 -16
  152. package/dist/patterns-cli.d.ts +1 -1
  153. package/dist/policy-runtime.d.ts +1 -1
  154. package/dist/provenance.d.ts +1 -1
  155. package/dist/qmd-recall-cache.d.ts +1 -1
  156. package/dist/qmd.d.ts +1 -1
  157. package/dist/recall-disclosure-escalation.d.ts +1 -1
  158. package/dist/recall-explain-renderer.d.ts +1 -1
  159. package/dist/recall-planner-llm.d.ts +1 -1
  160. package/dist/recall-state.d.ts +1 -1
  161. package/dist/recall-tag-filter.d.ts +1 -1
  162. package/dist/recall-xray-cli.d.ts +1 -1
  163. package/dist/recall-xray-renderer.d.ts +1 -1
  164. package/dist/recall-xray.d.ts +1 -1
  165. package/dist/resolve-auth-token.d.ts +1 -1
  166. package/dist/retrieval-agents.d.ts +1 -1
  167. package/dist/retrieval-tiers.d.ts +1 -1
  168. package/dist/routing/engine.d.ts +1 -1
  169. package/dist/routing/store.d.ts +1 -1
  170. package/dist/search/embed-helper.d.ts +1 -1
  171. package/dist/search/factory.d.ts +1 -1
  172. package/dist/search/index.d.ts +1 -1
  173. package/dist/search/lancedb-backend.d.ts +1 -1
  174. package/dist/search/meilisearch-backend.d.ts +1 -1
  175. package/dist/search/noop-backend.d.ts +1 -1
  176. package/dist/search/orama-backend.d.ts +1 -1
  177. package/dist/search/port.d.ts +1 -1
  178. package/dist/search/remote-backend.d.ts +1 -1
  179. package/dist/{semantic-consolidation-ByzGwC9c.d.ts → semantic-consolidation-D3aSiu9t.d.ts} +1 -1
  180. package/dist/semantic-consolidation.d.ts +2 -2
  181. package/dist/semantic-consolidation.js +4 -4
  182. package/dist/semantic-rule-promotion.js +3 -3
  183. package/dist/semantic-rule-verifier.d.ts +1 -1
  184. package/dist/semantic-rule-verifier.js +3 -3
  185. package/dist/session-observer-bands.d.ts +1 -1
  186. package/dist/session-observer-state.d.ts +1 -1
  187. package/dist/shared-context/manager.d.ts +1 -1
  188. package/dist/signal.d.ts +1 -1
  189. package/dist/storage.d.ts +1 -1
  190. package/dist/storage.js +2 -2
  191. package/dist/summarizer.d.ts +1 -1
  192. package/dist/summary-snapshot.d.ts +1 -1
  193. package/dist/temporal-supersession.d.ts +1 -1
  194. package/dist/temporal-validity.d.ts +1 -1
  195. package/dist/threading.d.ts +1 -1
  196. package/dist/tier-migration.d.ts +1 -1
  197. package/dist/tier-routing.d.ts +1 -1
  198. package/dist/topics.d.ts +1 -1
  199. package/dist/transcript.d.ts +1 -1
  200. package/dist/transfer/backup.js +2 -2
  201. package/dist/transfer/capsule-export.js +2 -2
  202. package/dist/transfer/capsule-import.js +1 -1
  203. package/dist/trust-score-stage.d.ts +1 -1
  204. package/dist/trust-score.d.ts +1 -1
  205. package/dist/{types-5Jik3r4G.d.ts → types-CZm6rx9-.d.ts} +1 -1
  206. package/dist/types.d.ts +1 -1
  207. package/dist/utility-runtime.d.ts +1 -1
  208. package/dist/verified-recall.js +3 -3
  209. package/package.json +2 -2
  210. package/src/index.ts +2 -0
  211. package/src/orchestration/extraction-persist.ts +2785 -0
  212. package/src/orchestration/extraction-run.ts +874 -0
  213. package/src/orchestration/graph-recall-coordinator.ts +471 -0
  214. package/src/orchestrator.ts +200 -3621
  215. package/dist/chunk-5UNSGRCR.js.map +0 -1
  216. package/dist/chunk-A2KKLCOS.js +0 -1889
  217. package/dist/chunk-A2KKLCOS.js.map +0 -1
  218. package/dist/chunk-AVBT5WEW.js +0 -153
  219. package/dist/chunk-AVBT5WEW.js.map +0 -1
  220. package/dist/chunk-C7LDPZJJ.js.map +0 -1
  221. package/dist/chunk-VO4VARZL.js.map +0 -1
  222. package/dist/chunk-WPLRJ4XM.js.map +0 -1
  223. /package/dist/{auto-sync-XHSKKQAH.js.map → auto-sync-IEBKPGAM.js.map} +0 -0
  224. /package/dist/{chunk-6XG3NQRC.js.map → chunk-3IJGF6K2.js.map} +0 -0
  225. /package/dist/{chunk-U5WVRMCA.js.map → chunk-5IN26V6W.js.map} +0 -0
  226. /package/dist/{chunk-XEADGIAA.js.map → chunk-DIHCFJVV.js.map} +0 -0
  227. /package/dist/{chunk-E7RGJQWP.js.map → chunk-HIHCB2S6.js.map} +0 -0
  228. /package/dist/{chunk-JFCS6PQU.js.map → chunk-JHQUIH3W.js.map} +0 -0
  229. /package/dist/{chunk-MXDG6SRH.js.map → chunk-JRDPT6DA.js.map} +0 -0
  230. /package/dist/{chunk-BYLC4DKI.js.map → chunk-KMNYXLPL.js.map} +0 -0
  231. /package/dist/{chunk-DYK27X7V.js.map → chunk-LMFS64GY.js.map} +0 -0
  232. /package/dist/{chunk-FWXLKH2H.js.map → chunk-NVYF5OB6.js.map} +0 -0
  233. /package/dist/{chunk-56F6EAQ6.js.map → chunk-Q3X7GUAQ.js.map} +0 -0
  234. /package/dist/{chunk-7N7S2RKF.js.map → chunk-R2OAN6IP.js.map} +0 -0
  235. /package/dist/{chunk-CHELXDTO.js.map → chunk-RB6A7OUN.js.map} +0 -0
  236. /package/dist/{chunk-3EA5LIFJ.js.map → chunk-SIV3JZPP.js.map} +0 -0
  237. /package/dist/{chunk-IP5SANO2.js.map → chunk-UIKZZ242.js.map} +0 -0
  238. /package/dist/{chunk-UGFPGWJB.js.map → chunk-URQLO7BX.js.map} +0 -0
  239. /package/dist/{chunk-WO22UEM3.js.map → chunk-XTEWVF3C.js.map} +0 -0
  240. /package/dist/{chunk-FCQ7ZYCQ.js.map → chunk-ZGAJB74V.js.map} +0 -0
  241. /package/dist/{chunk-NBP3YHHS.js.map → chunk-ZGZNLRKF.js.map} +0 -0
  242. /package/dist/{chunk-C7C5WIIF.js.map → chunk-ZPZ4VVLT.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  StorageManager,
3
3
  normalizeEntityName
4
- } from "./chunk-JFCS6PQU.js";
4
+ } from "./chunk-JHQUIH3W.js";
5
5
  import {
6
6
  serializeMutations
7
7
  } from "./chunk-LTJAMRGI.js";
@@ -956,4 +956,4 @@ export {
956
956
  resolveBriefingSaveDir,
957
957
  briefingFilename
958
958
  };
959
- //# sourceMappingURL=chunk-6XG3NQRC.js.map
959
+ //# sourceMappingURL=chunk-3IJGF6K2.js.map
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-ZFXCQPNO.js";
5
5
  import {
6
6
  StorageManager
7
- } from "./chunk-JFCS6PQU.js";
7
+ } from "./chunk-JHQUIH3W.js";
8
8
  import {
9
9
  MutationSerializer
10
10
  } from "./chunk-LTJAMRGI.js";
@@ -339,4 +339,4 @@ export {
339
339
  resolveNamespaceStorageRoot,
340
340
  NamespaceStorageRouter
341
341
  };
342
- //# sourceMappingURL=chunk-U5WVRMCA.js.map
342
+ //# sourceMappingURL=chunk-5IN26V6W.js.map
@@ -4,13 +4,13 @@ import {
4
4
  import {
5
5
  runGraphEdgeDecayMaintenanceAcrossNamespaces
6
6
  } from "./chunk-ZQNCHPTZ.js";
7
+ import {
8
+ runContradictionScan
9
+ } from "./chunk-EEKDRAWX.js";
7
10
  import {
8
11
  executeResolution,
9
12
  isValidResolutionVerb
10
13
  } from "./chunk-DJECGBBM.js";
11
- import {
12
- runContradictionScan
13
- } from "./chunk-EEKDRAWX.js";
14
14
  import {
15
15
  isDefaultReviewNamespace,
16
16
  listPairs
@@ -21,16 +21,16 @@ import {
21
21
  } from "./chunk-T4WDJPEZ.js";
22
22
  import {
23
23
  defineOperation
24
- } from "./chunk-BYLC4DKI.js";
24
+ } from "./chunk-KMNYXLPL.js";
25
25
  import {
26
26
  EngramAccessInputError
27
- } from "./chunk-WPLRJ4XM.js";
27
+ } from "./chunk-24YDB5QP.js";
28
28
  import {
29
29
  projectTagProjectId
30
30
  } from "./chunk-W3M34XT4.js";
31
31
  import {
32
32
  validateBriefingFormat
33
- } from "./chunk-6XG3NQRC.js";
33
+ } from "./chunk-3IJGF6K2.js";
34
34
  import {
35
35
  resolvePrincipal
36
36
  } from "./chunk-PE6XR4GG.js";
@@ -417,4 +417,4 @@ defineOperation({ name: "offline_sync_snapshot_stream", description: "SSE stream
417
417
  defineOperation({ name: "graph_events", description: "SSE graph events.", schema: strictSchema({}), handler: async (_i, _ctx) => ({ result: { stream: "sse" } }) });
418
418
  defineOperation({ name: "chat_message", description: "Chat message.", schema: strictSchema({ message: S.str, chatSessionId: S.str }), handler: async (_i, _ctx) => ({ result: { ok: true } }) });
419
419
  defineOperation({ name: "chat_events", description: "SSE chat events.", schema: strictSchema({}), handler: async (_i, _ctx) => ({ result: { stream: "sse" } }) });
420
- //# sourceMappingURL=chunk-XEADGIAA.js.map
420
+ //# sourceMappingURL=chunk-DIHCFJVV.js.map
@@ -30,6 +30,224 @@ import {
30
30
  serializeDayTranscript
31
31
  } from "./chunk-M7XQSUBB.js";
32
32
 
33
+ // src/wearables/cleanup.ts
34
+ var MERGE_GAP_MS = 3e4;
35
+ var FILLER_TOKENS = ["um", "uh", "uhm", "umm", "uhh", "erm", "hmm", "mhm"];
36
+ var FILLER_PATTERN = new RegExp(
37
+ // Leading/trailing punctuation around the filler collapses with it so
38
+ // "Um, so we should" -> "so we should" rather than ", so we should".
39
+ `(?:^|\\s)(?:${FILLER_TOKENS.join("|")})[,.]?(?=\\s|$)`,
40
+ "gi"
41
+ );
42
+ function cleanConversation(conversation, settings) {
43
+ let segments = conversation.segments.map((segment) => ({ ...segment }));
44
+ let droppedSegments = 0;
45
+ let mergedSegments = 0;
46
+ if (settings.stripFillers) {
47
+ for (const segment of segments) {
48
+ segment.text = stripFillerTokens(segment.text);
49
+ }
50
+ }
51
+ if (settings.collapseRepeats) {
52
+ for (const segment of segments) {
53
+ segment.text = collapseImmediateRepeats(segment.text);
54
+ }
55
+ }
56
+ for (const segment of segments) {
57
+ segment.text = normalizeWhitespace(segment.text);
58
+ }
59
+ if (settings.dropLowQuality) {
60
+ const kept = [];
61
+ for (const segment of segments) {
62
+ if (isLowQualitySegment(segment.text)) {
63
+ droppedSegments += 1;
64
+ } else {
65
+ kept.push(segment);
66
+ }
67
+ }
68
+ segments = kept;
69
+ } else {
70
+ const kept = segments.filter((segment) => segment.text.length > 0);
71
+ droppedSegments += segments.length - kept.length;
72
+ segments = kept;
73
+ }
74
+ if (settings.mergeSameSpeaker) {
75
+ const merged = [];
76
+ for (const segment of segments) {
77
+ const previous = merged[merged.length - 1];
78
+ if (previous && canMerge(previous, segment)) {
79
+ previous.text = `${previous.text} ${segment.text}`.trim();
80
+ if (segment.endIso) previous.endIso = segment.endIso;
81
+ mergedSegments += 1;
82
+ } else {
83
+ merged.push(segment);
84
+ }
85
+ }
86
+ segments = merged;
87
+ }
88
+ return {
89
+ conversation: { ...conversation, segments },
90
+ droppedSegments,
91
+ mergedSegments
92
+ };
93
+ }
94
+ function canMerge(previous, next) {
95
+ if (previous.speakerKey !== next.speakerKey) return false;
96
+ const previousEnd = previous.endIso ? Date.parse(previous.endIso) : NaN;
97
+ const nextStart = next.startIso ? Date.parse(next.startIso) : NaN;
98
+ if (Number.isNaN(previousEnd) || Number.isNaN(nextStart)) return true;
99
+ return nextStart - previousEnd <= MERGE_GAP_MS;
100
+ }
101
+ function stripFillerTokens(text) {
102
+ return normalizeWhitespace(text.replace(FILLER_PATTERN, " "));
103
+ }
104
+ function collapseImmediateRepeats(text) {
105
+ const words = text.split(/\s+/).filter((word) => word.length > 0);
106
+ if (words.length < 2) return text.trim();
107
+ const out = [];
108
+ let index = 0;
109
+ while (index < words.length) {
110
+ out.push(words[index]);
111
+ index += 1;
112
+ let matched = true;
113
+ while (matched) {
114
+ matched = false;
115
+ for (let size = 4; size >= 1; size--) {
116
+ if (out.length < size || index + size > words.length) continue;
117
+ const tail = out.slice(-size).join(" ").toLowerCase();
118
+ if (!/\p{L}/u.test(tail)) continue;
119
+ const ahead = words.slice(index, index + size).join(" ").toLowerCase();
120
+ if (tail === ahead) {
121
+ index += size;
122
+ matched = true;
123
+ break;
124
+ }
125
+ }
126
+ }
127
+ }
128
+ return out.join(" ");
129
+ }
130
+ function isLowQualitySegment(text) {
131
+ const trimmed = text.trim();
132
+ if (trimmed.length === 0) return true;
133
+ if (/^(.)\1{4,}$/.test(trimmed)) return true;
134
+ const letters = trimmed.replace(/[^\p{L}\p{N}]/gu, "");
135
+ if (letters.length === 0) return true;
136
+ if (trimmed.length >= 12 && letters.length / trimmed.length < 0.3) {
137
+ return true;
138
+ }
139
+ const words = trimmed.toLowerCase().split(/\s+/);
140
+ if (words.length >= 5) {
141
+ const unique = new Set(words);
142
+ if (unique.size === 1) return true;
143
+ }
144
+ return false;
145
+ }
146
+ function normalizeWhitespace(text) {
147
+ return text.replace(/\s+/g, " ").trim();
148
+ }
149
+
150
+ // src/wearables/sync-state.ts
151
+ import { promises as fsPromises } from "fs";
152
+ import * as path from "path";
153
+ var MAX_TRACKED_NATIVE_IDS = 5e3;
154
+ var MAX_TRACKED_DAY_HASHES = 800;
155
+ function syncStateFilePath(memoryDir) {
156
+ return path.join(memoryDir, "state", "wearables", "sync.json");
157
+ }
158
+ function emptySyncState() {
159
+ return { version: 1, sources: {} };
160
+ }
161
+ async function loadSyncState(memoryDir) {
162
+ const filePath = syncStateFilePath(memoryDir);
163
+ let raw;
164
+ try {
165
+ raw = await fsPromises.readFile(filePath, "utf-8");
166
+ } catch (err) {
167
+ if (err.code === "ENOENT") {
168
+ return emptySyncState();
169
+ }
170
+ throw err;
171
+ }
172
+ let parsed;
173
+ try {
174
+ parsed = JSON.parse(raw);
175
+ } catch {
176
+ return emptySyncState();
177
+ }
178
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed) || typeof parsed.sources !== "object" || parsed.sources === null) {
179
+ return emptySyncState();
180
+ }
181
+ return { version: 1, sources: parsed.sources };
182
+ }
183
+ async function saveSyncState(memoryDir, state) {
184
+ const filePath = syncStateFilePath(memoryDir);
185
+ await fsPromises.mkdir(path.dirname(filePath), { recursive: true });
186
+ const tmpPath = `${filePath}.tmp-${process.pid}-${Date.now().toString(36)}`;
187
+ await fsPromises.writeFile(
188
+ tmpPath,
189
+ `${JSON.stringify(state, null, 2)}
190
+ `,
191
+ "utf-8"
192
+ );
193
+ try {
194
+ await fsPromises.rename(tmpPath, filePath);
195
+ } catch (err) {
196
+ await fsPromises.unlink(tmpPath).catch(() => void 0);
197
+ throw err;
198
+ }
199
+ }
200
+ function updateSourceSyncState(state, sourceId, update) {
201
+ const previous = state.sources[sourceId];
202
+ const mergedHashes = {
203
+ ...previous?.dayHashes ?? {},
204
+ ...update.dayHashes
205
+ };
206
+ const hashKeys = Object.keys(mergedHashes).sort();
207
+ while (hashKeys.length > MAX_TRACKED_DAY_HASHES) {
208
+ const oldest = hashKeys.shift();
209
+ if (oldest === void 0) break;
210
+ delete mergedHashes[oldest];
211
+ }
212
+ const mergedMemoryHashes = {
213
+ ...previous?.memoryDayHashes ?? {},
214
+ ...update.memoryDayHashes ?? {}
215
+ };
216
+ for (const day of update.clearMemoryDays ?? []) {
217
+ if (!(day in (update.memoryDayHashes ?? {}))) {
218
+ delete mergedMemoryHashes[day];
219
+ }
220
+ }
221
+ const memoryHashKeys = Object.keys(mergedMemoryHashes).sort();
222
+ while (memoryHashKeys.length > MAX_TRACKED_DAY_HASHES) {
223
+ const oldest = memoryHashKeys.shift();
224
+ if (oldest === void 0) break;
225
+ delete mergedMemoryHashes[oldest];
226
+ }
227
+ const mergedNativeIds = [
228
+ ...previous?.importedNativeMemoryIds ?? [],
229
+ ...update.importedNativeMemoryIds ?? []
230
+ ];
231
+ const dedupedNativeIds = [...new Set(mergedNativeIds)];
232
+ const boundedNativeIds = dedupedNativeIds.length > MAX_TRACKED_NATIVE_IDS ? dedupedNativeIds.slice(dedupedNativeIds.length - MAX_TRACKED_NATIVE_IDS) : dedupedNativeIds;
233
+ const sortedDays = [...update.days].sort();
234
+ const latestDay = sortedDays[sortedDays.length - 1];
235
+ const lastDateSynced = latestDay !== void 0 && (!previous || previous.lastDateSynced < latestDay) ? latestDay : previous?.lastDateSynced ?? latestDay ?? "";
236
+ return {
237
+ version: 1,
238
+ sources: {
239
+ ...state.sources,
240
+ [sourceId]: {
241
+ lastSyncAt: update.syncedAt,
242
+ lastDateSynced,
243
+ dayHashes: mergedHashes,
244
+ memoryDayHashes: mergedMemoryHashes,
245
+ importedNativeMemoryIds: boundedNativeIds
246
+ }
247
+ }
248
+ };
249
+ }
250
+
33
251
  // src/wearables/trust.ts
34
252
  var TRUST_JUDGE_ACCEPT_BOOST = 0.15;
35
253
  var TRUST_CROSS_SOURCE_BOOST = 0.15;
@@ -543,224 +761,6 @@ async function importNativeMemories(sourceId, memories, alreadyImportedIds, sett
543
761
  return { imported, tombstoneBlocked, importedIds, warnings };
544
762
  }
545
763
 
546
- // src/wearables/cleanup.ts
547
- var MERGE_GAP_MS = 3e4;
548
- var FILLER_TOKENS = ["um", "uh", "uhm", "umm", "uhh", "erm", "hmm", "mhm"];
549
- var FILLER_PATTERN = new RegExp(
550
- // Leading/trailing punctuation around the filler collapses with it so
551
- // "Um, so we should" -> "so we should" rather than ", so we should".
552
- `(?:^|\\s)(?:${FILLER_TOKENS.join("|")})[,.]?(?=\\s|$)`,
553
- "gi"
554
- );
555
- function cleanConversation(conversation, settings) {
556
- let segments = conversation.segments.map((segment) => ({ ...segment }));
557
- let droppedSegments = 0;
558
- let mergedSegments = 0;
559
- if (settings.stripFillers) {
560
- for (const segment of segments) {
561
- segment.text = stripFillerTokens(segment.text);
562
- }
563
- }
564
- if (settings.collapseRepeats) {
565
- for (const segment of segments) {
566
- segment.text = collapseImmediateRepeats(segment.text);
567
- }
568
- }
569
- for (const segment of segments) {
570
- segment.text = normalizeWhitespace(segment.text);
571
- }
572
- if (settings.dropLowQuality) {
573
- const kept = [];
574
- for (const segment of segments) {
575
- if (isLowQualitySegment(segment.text)) {
576
- droppedSegments += 1;
577
- } else {
578
- kept.push(segment);
579
- }
580
- }
581
- segments = kept;
582
- } else {
583
- const kept = segments.filter((segment) => segment.text.length > 0);
584
- droppedSegments += segments.length - kept.length;
585
- segments = kept;
586
- }
587
- if (settings.mergeSameSpeaker) {
588
- const merged = [];
589
- for (const segment of segments) {
590
- const previous = merged[merged.length - 1];
591
- if (previous && canMerge(previous, segment)) {
592
- previous.text = `${previous.text} ${segment.text}`.trim();
593
- if (segment.endIso) previous.endIso = segment.endIso;
594
- mergedSegments += 1;
595
- } else {
596
- merged.push(segment);
597
- }
598
- }
599
- segments = merged;
600
- }
601
- return {
602
- conversation: { ...conversation, segments },
603
- droppedSegments,
604
- mergedSegments
605
- };
606
- }
607
- function canMerge(previous, next) {
608
- if (previous.speakerKey !== next.speakerKey) return false;
609
- const previousEnd = previous.endIso ? Date.parse(previous.endIso) : NaN;
610
- const nextStart = next.startIso ? Date.parse(next.startIso) : NaN;
611
- if (Number.isNaN(previousEnd) || Number.isNaN(nextStart)) return true;
612
- return nextStart - previousEnd <= MERGE_GAP_MS;
613
- }
614
- function stripFillerTokens(text) {
615
- return normalizeWhitespace(text.replace(FILLER_PATTERN, " "));
616
- }
617
- function collapseImmediateRepeats(text) {
618
- const words = text.split(/\s+/).filter((word) => word.length > 0);
619
- if (words.length < 2) return text.trim();
620
- const out = [];
621
- let index = 0;
622
- while (index < words.length) {
623
- out.push(words[index]);
624
- index += 1;
625
- let matched = true;
626
- while (matched) {
627
- matched = false;
628
- for (let size = 4; size >= 1; size--) {
629
- if (out.length < size || index + size > words.length) continue;
630
- const tail = out.slice(-size).join(" ").toLowerCase();
631
- if (!/\p{L}/u.test(tail)) continue;
632
- const ahead = words.slice(index, index + size).join(" ").toLowerCase();
633
- if (tail === ahead) {
634
- index += size;
635
- matched = true;
636
- break;
637
- }
638
- }
639
- }
640
- }
641
- return out.join(" ");
642
- }
643
- function isLowQualitySegment(text) {
644
- const trimmed = text.trim();
645
- if (trimmed.length === 0) return true;
646
- if (/^(.)\1{4,}$/.test(trimmed)) return true;
647
- const letters = trimmed.replace(/[^\p{L}\p{N}]/gu, "");
648
- if (letters.length === 0) return true;
649
- if (trimmed.length >= 12 && letters.length / trimmed.length < 0.3) {
650
- return true;
651
- }
652
- const words = trimmed.toLowerCase().split(/\s+/);
653
- if (words.length >= 5) {
654
- const unique = new Set(words);
655
- if (unique.size === 1) return true;
656
- }
657
- return false;
658
- }
659
- function normalizeWhitespace(text) {
660
- return text.replace(/\s+/g, " ").trim();
661
- }
662
-
663
- // src/wearables/sync-state.ts
664
- import { promises as fsPromises } from "fs";
665
- import * as path from "path";
666
- var MAX_TRACKED_NATIVE_IDS = 5e3;
667
- var MAX_TRACKED_DAY_HASHES = 800;
668
- function syncStateFilePath(memoryDir) {
669
- return path.join(memoryDir, "state", "wearables", "sync.json");
670
- }
671
- function emptySyncState() {
672
- return { version: 1, sources: {} };
673
- }
674
- async function loadSyncState(memoryDir) {
675
- const filePath = syncStateFilePath(memoryDir);
676
- let raw;
677
- try {
678
- raw = await fsPromises.readFile(filePath, "utf-8");
679
- } catch (err) {
680
- if (err.code === "ENOENT") {
681
- return emptySyncState();
682
- }
683
- throw err;
684
- }
685
- let parsed;
686
- try {
687
- parsed = JSON.parse(raw);
688
- } catch {
689
- return emptySyncState();
690
- }
691
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed) || typeof parsed.sources !== "object" || parsed.sources === null) {
692
- return emptySyncState();
693
- }
694
- return { version: 1, sources: parsed.sources };
695
- }
696
- async function saveSyncState(memoryDir, state) {
697
- const filePath = syncStateFilePath(memoryDir);
698
- await fsPromises.mkdir(path.dirname(filePath), { recursive: true });
699
- const tmpPath = `${filePath}.tmp-${process.pid}-${Date.now().toString(36)}`;
700
- await fsPromises.writeFile(
701
- tmpPath,
702
- `${JSON.stringify(state, null, 2)}
703
- `,
704
- "utf-8"
705
- );
706
- try {
707
- await fsPromises.rename(tmpPath, filePath);
708
- } catch (err) {
709
- await fsPromises.unlink(tmpPath).catch(() => void 0);
710
- throw err;
711
- }
712
- }
713
- function updateSourceSyncState(state, sourceId, update) {
714
- const previous = state.sources[sourceId];
715
- const mergedHashes = {
716
- ...previous?.dayHashes ?? {},
717
- ...update.dayHashes
718
- };
719
- const hashKeys = Object.keys(mergedHashes).sort();
720
- while (hashKeys.length > MAX_TRACKED_DAY_HASHES) {
721
- const oldest = hashKeys.shift();
722
- if (oldest === void 0) break;
723
- delete mergedHashes[oldest];
724
- }
725
- const mergedMemoryHashes = {
726
- ...previous?.memoryDayHashes ?? {},
727
- ...update.memoryDayHashes ?? {}
728
- };
729
- for (const day of update.clearMemoryDays ?? []) {
730
- if (!(day in (update.memoryDayHashes ?? {}))) {
731
- delete mergedMemoryHashes[day];
732
- }
733
- }
734
- const memoryHashKeys = Object.keys(mergedMemoryHashes).sort();
735
- while (memoryHashKeys.length > MAX_TRACKED_DAY_HASHES) {
736
- const oldest = memoryHashKeys.shift();
737
- if (oldest === void 0) break;
738
- delete mergedMemoryHashes[oldest];
739
- }
740
- const mergedNativeIds = [
741
- ...previous?.importedNativeMemoryIds ?? [],
742
- ...update.importedNativeMemoryIds ?? []
743
- ];
744
- const dedupedNativeIds = [...new Set(mergedNativeIds)];
745
- const boundedNativeIds = dedupedNativeIds.length > MAX_TRACKED_NATIVE_IDS ? dedupedNativeIds.slice(dedupedNativeIds.length - MAX_TRACKED_NATIVE_IDS) : dedupedNativeIds;
746
- const sortedDays = [...update.days].sort();
747
- const latestDay = sortedDays[sortedDays.length - 1];
748
- const lastDateSynced = latestDay !== void 0 && (!previous || previous.lastDateSynced < latestDay) ? latestDay : previous?.lastDateSynced ?? latestDay ?? "";
749
- return {
750
- version: 1,
751
- sources: {
752
- ...state.sources,
753
- [sourceId]: {
754
- lastSyncAt: update.syncedAt,
755
- lastDateSynced,
756
- dayHashes: mergedHashes,
757
- memoryDayHashes: mergedMemoryHashes,
758
- importedNativeMemoryIds: boundedNativeIds
759
- }
760
- }
761
- };
762
- }
763
-
764
764
  // src/wearables/pipeline.ts
765
765
  var PAGE_SAFETY_CEILING = 1e4;
766
766
  var DEFAULT_SYNC_DAYS = 2;
@@ -1154,14 +1154,6 @@ function defaultTimezone() {
1154
1154
  }
1155
1155
 
1156
1156
  export {
1157
- memoryStatusForMode,
1158
- WEARABLE_SOURCE_PREFIX,
1159
- wearableSourceLabel,
1160
- wearableDayTag,
1161
- buildExtractionTurns,
1162
- generateWearableMemories,
1163
- writeDailyDigestMemory,
1164
- importNativeMemories,
1165
1157
  cleanConversation,
1166
1158
  stripFillerTokens,
1167
1159
  collapseImmediateRepeats,
@@ -1171,9 +1163,17 @@ export {
1171
1163
  loadSyncState,
1172
1164
  saveSyncState,
1173
1165
  updateSourceSyncState,
1166
+ memoryStatusForMode,
1167
+ WEARABLE_SOURCE_PREFIX,
1168
+ wearableSourceLabel,
1169
+ wearableDayTag,
1170
+ buildExtractionTurns,
1171
+ generateWearableMemories,
1172
+ writeDailyDigestMemory,
1173
+ importNativeMemories,
1174
1174
  dateInTimezone,
1175
1175
  resolveSyncDates,
1176
1176
  syncWearableSource,
1177
1177
  defaultTimezone
1178
1178
  };
1179
- //# sourceMappingURL=chunk-C7LDPZJJ.js.map
1179
+ //# sourceMappingURL=chunk-EHYB325U.js.map