@hasna/mementos 0.14.33 → 0.14.35

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 (241) hide show
  1. package/LICENSE +190 -3
  2. package/README.md +30 -41
  3. package/dashboard/dist/assets/index-DqyMbv89.js +270 -0
  4. package/dashboard/dist/assets/index-UBCddFo_.css +1 -0
  5. package/dashboard/dist/index.html +13 -0
  6. package/dist/cli/brains.d.ts +3 -0
  7. package/dist/cli/brains.d.ts.map +1 -0
  8. package/dist/cli/index.d.ts +3 -0
  9. package/dist/cli/index.d.ts.map +1 -0
  10. package/dist/cli/index.js +25767 -0
  11. package/dist/db/acl.d.ts +34 -0
  12. package/dist/db/acl.d.ts.map +1 -0
  13. package/dist/db/agents.d.ts +15 -0
  14. package/dist/db/agents.d.ts.map +1 -0
  15. package/dist/db/audit.d.ts +39 -0
  16. package/dist/db/audit.d.ts.map +1 -0
  17. package/dist/db/database.d.ts +10 -0
  18. package/dist/db/database.d.ts.map +1 -0
  19. package/dist/db/entities.d.ts +62 -0
  20. package/dist/db/entities.d.ts.map +1 -0
  21. package/dist/db/entity-memories.d.ts +34 -0
  22. package/dist/db/entity-memories.d.ts.map +1 -0
  23. package/dist/db/locks.d.ts +63 -0
  24. package/dist/db/locks.d.ts.map +1 -0
  25. package/dist/db/machines.d.ts +16 -0
  26. package/dist/db/machines.d.ts.map +1 -0
  27. package/dist/db/memories.d.ts +40 -0
  28. package/dist/db/memories.d.ts.map +1 -0
  29. package/dist/db/pg-migrations.d.ts +8 -0
  30. package/dist/db/pg-migrations.d.ts.map +1 -0
  31. package/dist/db/projects.d.ts +6 -0
  32. package/dist/db/projects.d.ts.map +1 -0
  33. package/dist/db/ratings.d.ts +23 -0
  34. package/dist/db/ratings.d.ts.map +1 -0
  35. package/dist/db/relations.d.ts +29 -0
  36. package/dist/db/relations.d.ts.map +1 -0
  37. package/dist/db/session-jobs.d.ts +49 -0
  38. package/dist/db/session-jobs.d.ts.map +1 -0
  39. package/dist/db/synthesis.d.ts +101 -0
  40. package/dist/db/synthesis.d.ts.map +1 -0
  41. package/dist/db/tool-events.d.ts +27 -0
  42. package/dist/db/tool-events.d.ts.map +1 -0
  43. package/dist/db/webhook_hooks.d.ts +25 -0
  44. package/dist/db/webhook_hooks.d.ts.map +1 -0
  45. package/dist/index.d.ts +27 -4
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +14642 -1018
  48. package/dist/lib/activation-matcher.d.ts +16 -0
  49. package/dist/lib/activation-matcher.d.ts.map +1 -0
  50. package/dist/lib/asmr/categorizer.d.ts +31 -0
  51. package/dist/lib/asmr/categorizer.d.ts.map +1 -0
  52. package/dist/lib/asmr/context-agent.d.ts +4 -0
  53. package/dist/lib/asmr/context-agent.d.ts.map +1 -0
  54. package/dist/lib/asmr/ensemble.d.ts +23 -0
  55. package/dist/lib/asmr/ensemble.d.ts.map +1 -0
  56. package/dist/lib/asmr/fact-agent.d.ts +4 -0
  57. package/dist/lib/asmr/fact-agent.d.ts.map +1 -0
  58. package/dist/lib/asmr/index.d.ts +7 -0
  59. package/dist/lib/asmr/index.d.ts.map +1 -0
  60. package/dist/lib/asmr/orchestrator.d.ts +4 -0
  61. package/dist/lib/asmr/orchestrator.d.ts.map +1 -0
  62. package/dist/lib/asmr/temporal-agent.d.ts +4 -0
  63. package/dist/lib/asmr/temporal-agent.d.ts.map +1 -0
  64. package/dist/lib/asmr/types.d.ts +27 -0
  65. package/dist/lib/asmr/types.d.ts.map +1 -0
  66. package/dist/lib/auto-inject-orchestrator.d.ts +57 -0
  67. package/dist/lib/auto-inject-orchestrator.d.ts.map +1 -0
  68. package/dist/lib/auto-memory-queue.d.ts +46 -0
  69. package/dist/lib/auto-memory-queue.d.ts.map +1 -0
  70. package/dist/lib/auto-memory.d.ts +18 -0
  71. package/dist/lib/auto-memory.d.ts.map +1 -0
  72. package/dist/lib/bench.d.ts +20 -0
  73. package/dist/lib/bench.d.ts.map +1 -0
  74. package/dist/lib/built-in-hooks.d.ts +12 -0
  75. package/dist/lib/built-in-hooks.d.ts.map +1 -0
  76. package/dist/lib/channel-pusher.d.ts +39 -0
  77. package/dist/lib/channel-pusher.d.ts.map +1 -0
  78. package/dist/lib/config.d.ts +9 -0
  79. package/dist/lib/config.d.ts.map +1 -0
  80. package/dist/lib/connectors/files.d.ts +8 -0
  81. package/dist/lib/connectors/files.d.ts.map +1 -0
  82. package/dist/lib/connectors/github.d.ts +7 -0
  83. package/dist/lib/connectors/github.d.ts.map +1 -0
  84. package/dist/lib/connectors/index.d.ts +12 -0
  85. package/dist/lib/connectors/index.d.ts.map +1 -0
  86. package/dist/lib/connectors/notion.d.ts +7 -0
  87. package/dist/lib/connectors/notion.d.ts.map +1 -0
  88. package/dist/lib/connectors/types.d.ts +27 -0
  89. package/dist/lib/connectors/types.d.ts.map +1 -0
  90. package/dist/lib/context-extractor.d.ts +14 -0
  91. package/dist/lib/context-extractor.d.ts.map +1 -0
  92. package/dist/lib/context.d.ts +35 -0
  93. package/dist/lib/context.d.ts.map +1 -0
  94. package/dist/lib/contradiction.d.ts +50 -0
  95. package/dist/lib/contradiction.d.ts.map +1 -0
  96. package/dist/lib/decay.d.ts +35 -0
  97. package/dist/lib/decay.d.ts.map +1 -0
  98. package/dist/lib/dedup.d.ts +33 -0
  99. package/dist/lib/dedup.d.ts.map +1 -0
  100. package/dist/lib/duration.d.ts +28 -0
  101. package/dist/lib/duration.d.ts.map +1 -0
  102. package/dist/lib/embeddings.d.ts +20 -0
  103. package/dist/lib/embeddings.d.ts.map +1 -0
  104. package/dist/lib/export-v1.d.ts +30 -0
  105. package/dist/lib/export-v1.d.ts.map +1 -0
  106. package/dist/lib/extractor.d.ts +9 -0
  107. package/dist/lib/extractor.d.ts.map +1 -0
  108. package/dist/lib/extractors/audio.d.ts +8 -0
  109. package/dist/lib/extractors/audio.d.ts.map +1 -0
  110. package/dist/lib/extractors/index.d.ts +12 -0
  111. package/dist/lib/extractors/index.d.ts.map +1 -0
  112. package/dist/lib/extractors/ocr.d.ts +7 -0
  113. package/dist/lib/extractors/ocr.d.ts.map +1 -0
  114. package/dist/lib/extractors/pdf.d.ts +7 -0
  115. package/dist/lib/extractors/pdf.d.ts.map +1 -0
  116. package/dist/lib/extractors/types.d.ts +12 -0
  117. package/dist/lib/extractors/types.d.ts.map +1 -0
  118. package/dist/lib/file-deps.d.ts +27 -0
  119. package/dist/lib/file-deps.d.ts.map +1 -0
  120. package/dist/lib/focus.d.ts +58 -0
  121. package/dist/lib/focus.d.ts.map +1 -0
  122. package/dist/lib/gatherer.d.ts +16 -0
  123. package/dist/lib/gatherer.d.ts.map +1 -0
  124. package/dist/lib/gdpr.d.ts +24 -0
  125. package/dist/lib/gdpr.d.ts.map +1 -0
  126. package/dist/lib/hooks.d.ts +50 -0
  127. package/dist/lib/hooks.d.ts.map +1 -0
  128. package/dist/lib/importers/index.d.ts +38 -0
  129. package/dist/lib/importers/index.d.ts.map +1 -0
  130. package/dist/lib/injector.d.ts +86 -0
  131. package/dist/lib/injector.d.ts.map +1 -0
  132. package/dist/lib/matryoshka.d.ts +50 -0
  133. package/dist/lib/matryoshka.d.ts.map +1 -0
  134. package/dist/lib/memory-lock.d.ts +58 -0
  135. package/dist/lib/memory-lock.d.ts.map +1 -0
  136. package/dist/lib/model-config.d.ts +14 -0
  137. package/dist/lib/model-config.d.ts.map +1 -0
  138. package/dist/lib/open-sessions-connector.d.ts +60 -0
  139. package/dist/lib/open-sessions-connector.d.ts.map +1 -0
  140. package/dist/lib/poisoning.d.ts +19 -0
  141. package/dist/lib/poisoning.d.ts.map +1 -0
  142. package/dist/lib/poll.d.ts +17 -0
  143. package/dist/lib/poll.d.ts.map +1 -0
  144. package/dist/lib/procedural-extractor.d.ts +21 -0
  145. package/dist/lib/procedural-extractor.d.ts.map +1 -0
  146. package/dist/lib/profile-sync.d.ts +20 -0
  147. package/dist/lib/profile-sync.d.ts.map +1 -0
  148. package/dist/lib/profile-synthesizer.d.ts +20 -0
  149. package/dist/lib/profile-synthesizer.d.ts.map +1 -0
  150. package/dist/lib/project-detect.d.ts +18 -0
  151. package/dist/lib/project-detect.d.ts.map +1 -0
  152. package/dist/lib/providers/anthropic.d.ts +21 -0
  153. package/dist/lib/providers/anthropic.d.ts.map +1 -0
  154. package/dist/lib/providers/base.d.ts +96 -0
  155. package/dist/lib/providers/base.d.ts.map +1 -0
  156. package/dist/lib/providers/cerebras.d.ts +20 -0
  157. package/dist/lib/providers/cerebras.d.ts.map +1 -0
  158. package/dist/lib/providers/grok.d.ts +19 -0
  159. package/dist/lib/providers/grok.d.ts.map +1 -0
  160. package/dist/lib/providers/index.d.ts +7 -0
  161. package/dist/lib/providers/index.d.ts.map +1 -0
  162. package/dist/lib/providers/openai-compat.d.ts +18 -0
  163. package/dist/lib/providers/openai-compat.d.ts.map +1 -0
  164. package/dist/lib/providers/openai.d.ts +20 -0
  165. package/dist/lib/providers/openai.d.ts.map +1 -0
  166. package/dist/lib/providers/registry.d.ts +38 -0
  167. package/dist/lib/providers/registry.d.ts.map +1 -0
  168. package/dist/lib/quality.d.ts +16 -0
  169. package/dist/lib/quality.d.ts.map +1 -0
  170. package/dist/lib/redact.d.ts +10 -0
  171. package/dist/lib/redact.d.ts.map +1 -0
  172. package/dist/lib/remote-sync.d.ts +49 -0
  173. package/dist/lib/remote-sync.d.ts.map +1 -0
  174. package/dist/lib/retention.d.ts +17 -0
  175. package/dist/lib/retention.d.ts.map +1 -0
  176. package/dist/lib/search.d.ts +52 -0
  177. package/dist/lib/search.d.ts.map +1 -0
  178. package/dist/lib/session-auto-resolve.d.ts +28 -0
  179. package/dist/lib/session-auto-resolve.d.ts.map +1 -0
  180. package/dist/lib/session-processor.d.ts +38 -0
  181. package/dist/lib/session-processor.d.ts.map +1 -0
  182. package/dist/lib/session-queue.d.ts +28 -0
  183. package/dist/lib/session-queue.d.ts.map +1 -0
  184. package/dist/lib/session-registry.d.ts +47 -0
  185. package/dist/lib/session-registry.d.ts.map +1 -0
  186. package/dist/lib/session-start-briefing.d.ts +10 -0
  187. package/dist/lib/session-start-briefing.d.ts.map +1 -0
  188. package/dist/lib/session-watcher.d.ts +30 -0
  189. package/dist/lib/session-watcher.d.ts.map +1 -0
  190. package/dist/lib/sync.d.ts +10 -0
  191. package/dist/lib/sync.d.ts.map +1 -0
  192. package/dist/lib/synthesis/corpus-builder.d.ts +30 -0
  193. package/dist/lib/synthesis/corpus-builder.d.ts.map +1 -0
  194. package/dist/lib/synthesis/executor.d.ts +14 -0
  195. package/dist/lib/synthesis/executor.d.ts.map +1 -0
  196. package/dist/lib/synthesis/index.d.ts +37 -0
  197. package/dist/lib/synthesis/index.d.ts.map +1 -0
  198. package/dist/lib/synthesis/llm-analyzer.d.ts +18 -0
  199. package/dist/lib/synthesis/llm-analyzer.d.ts.map +1 -0
  200. package/dist/lib/synthesis/metrics.d.ts +13 -0
  201. package/dist/lib/synthesis/metrics.d.ts.map +1 -0
  202. package/dist/lib/synthesis/scheduler.d.ts +18 -0
  203. package/dist/lib/synthesis/scheduler.d.ts.map +1 -0
  204. package/dist/lib/synthesis/validator.d.ts +19 -0
  205. package/dist/lib/synthesis/validator.d.ts.map +1 -0
  206. package/dist/lib/tool-lesson-extractor.d.ts +24 -0
  207. package/dist/lib/tool-lesson-extractor.d.ts.map +1 -0
  208. package/dist/lib/tool-memory-synthesizer.d.ts +28 -0
  209. package/dist/lib/tool-memory-synthesizer.d.ts.map +1 -0
  210. package/dist/lib/topic-clusterer.d.ts +21 -0
  211. package/dist/lib/topic-clusterer.d.ts.map +1 -0
  212. package/dist/lib/when-to-use-generator.d.ts +22 -0
  213. package/dist/lib/when-to-use-generator.d.ts.map +1 -0
  214. package/dist/mcp/index.d.ts +5 -0
  215. package/dist/mcp/index.d.ts.map +1 -0
  216. package/dist/mcp/index.js +30258 -0
  217. package/dist/mcp/memory-broadcast.d.ts +12 -0
  218. package/dist/mcp/memory-broadcast.d.ts.map +1 -0
  219. package/dist/sdk/index.js +397 -0
  220. package/dist/server/index.d.ts +7 -0
  221. package/dist/server/index.d.ts.map +1 -0
  222. package/dist/server/index.js +18250 -0
  223. package/dist/types/hooks.d.ts +136 -0
  224. package/dist/types/hooks.d.ts.map +1 -0
  225. package/dist/types/index.d.ts +345 -0
  226. package/dist/types/index.d.ts.map +1 -0
  227. package/package.json +53 -13
  228. package/dist/agent-setup.d.ts +0 -51
  229. package/dist/agent-setup.d.ts.map +0 -1
  230. package/dist/bridge.d.ts +0 -50
  231. package/dist/bridge.d.ts.map +0 -1
  232. package/dist/cli.d.ts +0 -3
  233. package/dist/cli.d.ts.map +0 -1
  234. package/dist/cli.js +0 -1434
  235. package/dist/mcp-runtime.d.ts +0 -24
  236. package/dist/mcp-runtime.d.ts.map +0 -1
  237. package/dist/mcp.d.ts +0 -3
  238. package/dist/mcp.d.ts.map +0 -1
  239. package/dist/mcp.js +0 -366
  240. package/dist/remote-client.d.ts +0 -51
  241. package/dist/remote-client.d.ts.map +0 -1
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Compute time decay factor (0–1).
3
+ * Uses exponential forgetting curve: exp(-lambda * days_since_access).
4
+ *
5
+ * Returns 1.0 for today, ~0.9 for 10 days, ~0.74 for 30 days, ~0.37 for 100 days.
6
+ *
7
+ * @param daysSinceAccess Non-negative number of days since last access.
8
+ * @param lambda Decay rate constant (default 0.01).
9
+ */
10
+ export declare function timeDecay(daysSinceAccess: number, lambda?: number): number;
11
+ /**
12
+ * Compute access frequency boost (>= 1.0).
13
+ * Formula: 1 + log(1 + access_count) * 0.1
14
+ *
15
+ * Returns 1.0 for 0 accesses, ~1.07 for 1, ~1.11 for 2, ~1.24 for 10.
16
+ *
17
+ * @param accessCount Non-negative number of times the memory was accessed.
18
+ */
19
+ export declare function accessBoost(accessCount: number): number;
20
+ /**
21
+ * Compute effective importance using a forgetting curve model.
22
+ *
23
+ * effective_importance = importance * time_decay(days_since_access) * access_boost(access_count)
24
+ *
25
+ * Pinned memories always return their raw importance (no decay).
26
+ * When accessed_at is null, falls back to created_at for age calculation.
27
+ */
28
+ export declare function computeDecayScore(memory: {
29
+ importance: number;
30
+ access_count: number;
31
+ accessed_at: string | null;
32
+ created_at: string;
33
+ pinned: boolean;
34
+ }): number;
35
+ //# sourceMappingURL=decay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decay.d.ts","sourceRoot":"","sources":["../../src/lib/decay.ts"],"names":[],"mappings":"AAUA;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,eAAe,EAAE,MAAM,EAAE,MAAM,GAAE,MAAa,GAAG,MAAM,CAGhF;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAGvD;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;CACjB,GAAG,MAAM,CAaT"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Smart deduplication for auto-extracted memories.
3
+ * FTS5-based similarity check — no LLM needed, pure SQLite.
4
+ * Prevents memory bloat from repeated similar extractions.
5
+ */
6
+ import type { MemoryFilter } from "../types/index.js";
7
+ export interface DedupConfig {
8
+ /** Jaccard similarity threshold 0-1. Above this = duplicate. Default: 0.8 */
9
+ threshold: number;
10
+ /** If near-duplicate found, keep the longer/more specific one. Default: true */
11
+ keepLonger: boolean;
12
+ }
13
+ export interface DedupStats {
14
+ checked: number;
15
+ skipped: number;
16
+ updated: number;
17
+ }
18
+ export declare function getDedupStats(): Readonly<DedupStats>;
19
+ export declare function resetDedupStats(): void;
20
+ /**
21
+ * Check if content is a near-duplicate of an existing memory.
22
+ * Returns: 'unique' | 'duplicate' | { updateId: string } (update existing with better content)
23
+ */
24
+ export declare function checkDuplicate(content: string, filter: Pick<MemoryFilter, "agent_id" | "project_id" | "scope">, config?: DedupConfig): "unique" | "duplicate" | {
25
+ updateId: string;
26
+ existingContent: string;
27
+ };
28
+ /**
29
+ * Full dedup pipeline: check and optionally update existing memory.
30
+ * Returns: null = save as new | string = skipped/updated (reason)
31
+ */
32
+ export declare function dedup(content: string, filter: Pick<MemoryFilter, "agent_id" | "project_id" | "scope">, config?: DedupConfig): "save" | "skip";
33
+ //# sourceMappingURL=dedup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dedup.d.ts","sourceRoot":"","sources":["../../src/lib/dedup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,WAAW,WAAW;IAC1B,6EAA6E;IAC7E,SAAS,EAAE,MAAM,CAAC;IAClB,gFAAgF;IAChF,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AASD,wBAAgB,aAAa,IAAI,QAAQ,CAAC,UAAU,CAAC,CAEpD;AAED,wBAAgB,eAAe,IAAI,IAAI,CAEtC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,UAAU,GAAG,YAAY,GAAG,OAAO,CAAC,EAC/D,MAAM,GAAE,WAA4B,GACnC,QAAQ,GAAG,WAAW,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,CAwCxE;AAED;;;GAGG;AACH,wBAAgB,KAAK,CACnB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,UAAU,GAAG,YAAY,GAAG,OAAO,CAAC,EAC/D,MAAM,GAAE,WAA4B,GACnC,MAAM,GAAG,MAAM,CAqBjB"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Human-readable duration parsing and formatting.
3
+ *
4
+ * Supported formats:
5
+ * Ns — seconds
6
+ * Nm — minutes
7
+ * Nh — hours
8
+ * Nd — days
9
+ * Nw — weeks
10
+ * Combinations: 1d12h, 2h30m
11
+ * Plain numbers: treated as milliseconds (backwards compat)
12
+ */
13
+ /**
14
+ * Parse a human-readable duration string into milliseconds.
15
+ *
16
+ * @param input - Duration string (e.g. "1d12h", "30m", "500") or numeric ms
17
+ * @returns milliseconds
18
+ * @throws Error on invalid format
19
+ */
20
+ export declare function parseDuration(input: string | number): number;
21
+ /**
22
+ * Format milliseconds into a human-readable duration string.
23
+ *
24
+ * @param ms - Duration in milliseconds
25
+ * @returns Human-readable string (e.g. "1d12h", "30m", "500ms")
26
+ */
27
+ export declare function formatDuration(ms: number): string;
28
+ //# sourceMappingURL=duration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/lib/duration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAaH;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAiC5D;AAWD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAoBjD"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Embedding generation and cosine similarity for semantic memory search.
3
+ *
4
+ * Uses OpenAI text-embedding-3-small if OPENAI_API_KEY is set,
5
+ * falls back to a simple TF-IDF term frequency vector otherwise.
6
+ */
7
+ export declare function cosineSimilarity(a: number[], b: number[]): number;
8
+ export interface EmbeddingResult {
9
+ embedding: number[];
10
+ model: string;
11
+ dimensions: number;
12
+ }
13
+ /**
14
+ * Generate an embedding for a text string.
15
+ * Uses OpenAI if OPENAI_API_KEY is available, otherwise uses TF-IDF hash trick.
16
+ */
17
+ export declare function generateEmbedding(text: string): Promise<EmbeddingResult>;
18
+ export declare function serializeEmbedding(embedding: number[]): string;
19
+ export declare function deserializeEmbedding(raw: string): number[];
20
+ //# sourceMappingURL=embeddings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embeddings.d.ts","sourceRoot":"","sources":["../../src/lib/embeddings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAUjE;AAwDD,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAY9E;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,CAE9D;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAE1D"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Mementos Export v1 — portable JSONL format.
3
+ * One JSON object per line. Includes all memory fields + entity links.
4
+ */
5
+ import type { Memory, MemoryFilter } from "../types/index.js";
6
+ import { Database } from "bun:sqlite";
7
+ export interface ExportV1Entry {
8
+ _format: "mementos-export-v1";
9
+ _exported_at: string;
10
+ memory: Memory;
11
+ entity_links: Array<{
12
+ entity_name: string;
13
+ entity_type: string;
14
+ role: string;
15
+ }>;
16
+ }
17
+ /**
18
+ * Export memories in mementos-export-v1 JSONL format.
19
+ * Returns an array of export entries (caller serializes to JSONL).
20
+ */
21
+ export declare function exportV1(filter?: MemoryFilter, db?: Database): ExportV1Entry[];
22
+ /**
23
+ * Serialize export entries to JSONL string (one JSON object per line).
24
+ */
25
+ export declare function toJsonl(entries: ExportV1Entry[]): string;
26
+ /**
27
+ * Parse JSONL string back to export entries.
28
+ */
29
+ export declare function fromJsonl(jsonl: string): ExportV1Entry[];
30
+ //# sourceMappingURL=export-v1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-v1.d.ts","sourceRoot":"","sources":["../../src/lib/export-v1.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAI9D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,oBAAoB,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,KAAK,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;CACJ;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CACtB,MAAM,CAAC,EAAE,YAAY,EACrB,EAAE,CAAC,EAAE,QAAQ,GACZ,aAAa,EAAE,CA6BjB;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,MAAM,CAExD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,EAAE,CAKxD"}
@@ -0,0 +1,9 @@
1
+ import { Database } from "bun:sqlite";
2
+ import type { EntityType, Memory } from "../types/index.js";
3
+ export interface ExtractedEntity {
4
+ name: string;
5
+ type: EntityType;
6
+ confidence: number;
7
+ }
8
+ export declare function extractEntities(memory: Memory, db?: Database): ExtractedEntity[];
9
+ //# sourceMappingURL=extractor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractor.d.ts","sourceRoot":"","sources":["../../src/lib/extractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE5D,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAuBD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,eAAe,EAAE,CA0EhF"}
@@ -0,0 +1,8 @@
1
+ import type { ExtractionResult } from "./types.js";
2
+ /**
3
+ * Transcribe an audio file using the OpenAI Whisper API.
4
+ * Requires the OPENAI_API_KEY environment variable.
5
+ * Returns empty result on failure — never throws.
6
+ */
7
+ export declare function transcribeAudio(filePath: string): Promise<ExtractionResult>;
8
+ //# sourceMappingURL=audio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audio.d.ts","sourceRoot":"","sources":["../../../src/lib/extractors/audio.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAqBnD;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA2EjF"}
@@ -0,0 +1,12 @@
1
+ import type { ExtractionResult } from "./types.js";
2
+ export type { ExtractionResult } from "./types.js";
3
+ export { emptyResult } from "./types.js";
4
+ export { extractPdf } from "./pdf.js";
5
+ export { extractImage } from "./ocr.js";
6
+ export { transcribeAudio } from "./audio.js";
7
+ /**
8
+ * Auto-detect file type by extension and route to the correct extractor.
9
+ * Returns an empty result for unsupported file types — never throws.
10
+ */
11
+ export declare function extractFile(filePath: string): Promise<ExtractionResult>;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/extractors/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAMnD,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAa7C;;;GAGG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAoB7E"}
@@ -0,0 +1,7 @@
1
+ import type { ExtractionResult } from "./types.js";
2
+ /**
3
+ * Extract text from an image file using Tesseract.js OCR.
4
+ * Returns empty result on failure — never throws.
5
+ */
6
+ export declare function extractImage(filePath: string): Promise<ExtractionResult>;
7
+ //# sourceMappingURL=ocr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ocr.d.ts","sourceRoot":"","sources":["../../../src/lib/extractors/ocr.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnD;;;GAGG;AACH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA2B9E"}
@@ -0,0 +1,7 @@
1
+ import type { ExtractionResult } from "./types.js";
2
+ /**
3
+ * Extract text from a PDF file using pdf-parse.
4
+ * Returns empty result on failure — never throws.
5
+ */
6
+ export declare function extractPdf(filePath: string): Promise<ExtractionResult>;
7
+ //# sourceMappingURL=pdf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdf.d.ts","sourceRoot":"","sources":["../../../src/lib/extractors/pdf.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnD;;;GAGG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA2B5E"}
@@ -0,0 +1,12 @@
1
+ export interface ExtractionResult {
2
+ text: string;
3
+ metadata: Record<string, unknown>;
4
+ pages?: number;
5
+ confidence?: number;
6
+ }
7
+ /**
8
+ * Returns an empty extraction result — used as a safe fallback when
9
+ * extraction fails or the file type is unsupported.
10
+ */
11
+ export declare function emptyResult(metadata?: Record<string, unknown>): ExtractionResult;
12
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/extractors/types.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,gBAAgB,CAMhF"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * File dependency graph builder for open-mementos.
3
+ * Scans a codebase, creates 'file' entities for each source file, and
4
+ * creates 'depends_on' relations between files based on import/require statements.
5
+ *
6
+ * Supports: TypeScript, JavaScript, Python, Go (basic), Rust (basic).
7
+ */
8
+ import type { Database } from "bun:sqlite";
9
+ export interface FileDepsOptions {
10
+ root_dir: string;
11
+ project_id?: string;
12
+ extensions?: string[];
13
+ exclude_patterns?: string[];
14
+ incremental?: boolean;
15
+ }
16
+ export interface FileDepsResult {
17
+ files_scanned: number;
18
+ entities_created: number;
19
+ entities_updated: number;
20
+ relations_created: number;
21
+ errors: string[];
22
+ }
23
+ /**
24
+ * Scan a codebase, create file entities and import-based depends_on relations.
25
+ */
26
+ export declare function buildFileDependencyGraph(opts: FileDepsOptions, db?: Database): Promise<FileDepsResult>;
27
+ //# sourceMappingURL=file-deps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-deps.d.ts","sourceRoot":"","sources":["../../src/lib/file-deps.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAK3C,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAgFD;;GAEG;AACH,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,eAAe,EACrB,EAAE,CAAC,EAAE,QAAQ,GACZ,OAAO,CAAC,cAAc,CAAC,CAwFzB"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Focus mode — agents can "focus" on a project, which auto-scopes
3
+ * memory operations to that project's shared memories + their own private
4
+ * memories + all global memories.
5
+ *
6
+ * Priority for project_id resolution:
7
+ * 1. Per-call param (explicit override)
8
+ * 2. Session focus (in-memory Map, fastest)
9
+ * 3. DB active_project_id on agent record
10
+ * 4. No filter
11
+ */
12
+ /**
13
+ * Set focus for an agent. Persists to DB + sets in-memory session focus.
14
+ * Pass project_id=null to unfocus.
15
+ */
16
+ export declare function setFocus(agentId: string, projectId: string | null): void;
17
+ /**
18
+ * Get the current focus project_id for an agent.
19
+ * Checks session cache first, then DB.
20
+ */
21
+ export declare function getFocus(agentId: string): string | null;
22
+ /**
23
+ * Remove focus for an agent (sets to null).
24
+ */
25
+ export declare function unfocus(agentId: string): void;
26
+ /**
27
+ * Resolve the effective project_id for a memory operation.
28
+ * Priority: explicit per-call param > session/DB focus > null
29
+ */
30
+ export declare function resolveProjectId(agentId: string | undefined | null, explicitProjectId: string | undefined | null): string | null;
31
+ /**
32
+ * Build the scope filter for memory queries when an agent is focused.
33
+ *
34
+ * When focused on project P:
35
+ * - private memories of this agent (scope=private, agent_id=agentId)
36
+ * - shared memories of project P (scope=shared, project_id=P)
37
+ * - global memories (scope=global)
38
+ *
39
+ * When not focused: no automatic scope restriction (existing behavior).
40
+ */
41
+ export interface FocusScopeFilter {
42
+ /** If set, apply this multi-scope filter instead of a single scope */
43
+ focusMode: true;
44
+ agentId: string;
45
+ projectId: string;
46
+ }
47
+ export declare function buildFocusFilter(agentId: string | undefined | null, explicitProjectId: string | undefined | null, explicitScope: string | undefined | null): FocusScopeFilter | null;
48
+ /**
49
+ * Apply focus filter to a SQL WHERE clause builder.
50
+ * Returns SQL fragment + params for the focused scope filter.
51
+ *
52
+ * Generates: (scope = 'global') OR (scope = 'private' AND agent_id = ?) OR (scope = 'shared' AND project_id = ?)
53
+ */
54
+ export declare function focusFilterSQL(agentId: string, projectId: string): {
55
+ sql: string;
56
+ params: string[];
57
+ };
58
+ //# sourceMappingURL=focus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focus.d.ts","sourceRoot":"","sources":["../../src/lib/focus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAQH;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAqBxE;AAOD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAWvD;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,EAClC,iBAAiB,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAC3C,MAAM,GAAG,IAAI,CAUf;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sEAAsE;IACtE,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,EAClC,iBAAiB,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,EAC5C,aAAa,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GACvC,gBAAgB,GAAG,IAAI,CAazB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAKnC"}
@@ -0,0 +1,16 @@
1
+ type GatherTrainingDataFn = (options?: {
2
+ limit?: number;
3
+ since?: Date;
4
+ }) => Promise<{
5
+ source: string;
6
+ examples: Array<{
7
+ messages: Array<{
8
+ role: "system" | "user" | "assistant";
9
+ content: string;
10
+ }>;
11
+ }>;
12
+ count: number;
13
+ }>;
14
+ export declare const gatherTrainingData: GatherTrainingDataFn;
15
+ export {};
16
+ //# sourceMappingURL=gatherer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gatherer.d.ts","sourceRoot":"","sources":["../../src/lib/gatherer.ts"],"names":[],"mappings":"AAMA,KAAK,oBAAoB,GAAG,CAAC,OAAO,CAAC,EAAE;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,IAAI,CAAC;CACd,KAAK,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,KAAK,CAAC;QACd,QAAQ,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KAC7E,CAAC,CAAC;IACH,KAAK,EAAE,MAAM,CAAC;CACf,CAAC,CAAC;AAyEH,eAAO,MAAM,kBAAkB,EAAE,oBAgDhC,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * GDPR-compliant erasure (right to be forgotten).
3
+ *
4
+ * Deletes PII from memory values while preserving anonymized audit trail.
5
+ * The audit log entries remain with hashes only (no content).
6
+ */
7
+ import { Database } from "bun:sqlite";
8
+ export interface GdprErasureResult {
9
+ erased_count: number;
10
+ memory_ids: string[];
11
+ timestamp: string;
12
+ }
13
+ /**
14
+ * Erase all memories containing the given PII identifier.
15
+ * Replaces value, summary, and key with "[REDACTED]".
16
+ * Clears tags and metadata that might contain PII.
17
+ * Preserves the audit trail (audit_log entries have hashes, not content).
18
+ */
19
+ export declare function gdprErase(identifier: string, options?: {
20
+ project_id?: string;
21
+ agent_id?: string;
22
+ dry_run?: boolean;
23
+ }, db?: Database): GdprErasureResult;
24
+ //# sourceMappingURL=gdpr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gdpr.d.ts","sourceRoot":"","sources":["../../src/lib/gdpr.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACvB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE;IACP,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;CACd,EACN,EAAE,CAAC,EAAE,QAAQ,GACZ,iBAAiB,CAwDnB"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Hook registry — the central nervous system connecting all memory operations.
3
+ *
4
+ * Blocking hooks: await handler, return false = cancel the operation.
5
+ * Non-blocking hooks: fire-and-forget in background, never delay caller.
6
+ *
7
+ * Hooks run in priority order (ascending — lower number first).
8
+ * Per-agent and per-project scoping supported.
9
+ */
10
+ import type { Hook, HookType, HookHandler, HookRegistration, HookContextMap } from "../types/hooks.js";
11
+ declare class HookRegistry {
12
+ private hooks;
13
+ /**
14
+ * Register a hook. Returns the assigned hookId.
15
+ * Built-in hooks (builtin: true) cannot be unregistered.
16
+ */
17
+ register<T extends HookType>(reg: HookRegistration<T>): string;
18
+ /**
19
+ * Unregister a hook by ID.
20
+ * Returns false if hook not found or is a built-in.
21
+ */
22
+ unregister(hookId: string): boolean;
23
+ /** List all hooks, optionally filtered by type */
24
+ list(type?: HookType): Hook[];
25
+ /**
26
+ * Run all hooks of a given type for a given context.
27
+ *
28
+ * Returns true if the operation should proceed.
29
+ * Returns false if any blocking hook cancelled it.
30
+ *
31
+ * Non-blocking hooks are fired async and never delay the return.
32
+ */
33
+ runHooks<T extends HookType>(type: T, context: HookContextMap[T]): Promise<boolean>;
34
+ /**
35
+ * Get hooks matching type + agent/project scope.
36
+ * A hook with no agentId/projectId matches everything.
37
+ */
38
+ private getMatchingHooks;
39
+ /** Get stats about registered hooks */
40
+ stats(): {
41
+ total: number;
42
+ byType: Record<string, number>;
43
+ blocking: number;
44
+ nonBlocking: number;
45
+ };
46
+ }
47
+ /** Singleton — shared across the whole process */
48
+ export declare const hookRegistry: HookRegistry;
49
+ export type { Hook, HookType, HookHandler, HookRegistration };
50
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/lib/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,cAAc,EACf,MAAM,mBAAmB,CAAC;AAO3B,cAAM,YAAY;IAChB,OAAO,CAAC,KAAK,CAA2B;IAExC;;;OAGG;IACH,QAAQ,CAAC,CAAC,SAAS,QAAQ,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,MAAM;IAW9D;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAQnC,kDAAkD;IAClD,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,EAAE;IAM7B;;;;;;;OAOG;IACG,QAAQ,CAAC,CAAC,SAAS,QAAQ,EAC/B,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,GACzB,OAAO,CAAC,OAAO,CAAC;IA8BnB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAaxB,uCAAuC;IACvC,KAAK,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE;CAalG;AAED,kDAAkD;AAClD,eAAO,MAAM,YAAY,cAAqB,CAAC;AAG/C,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Memory importers — parse export formats from Mem0, Zep, and LangMem into mementos memories.
3
+ */
4
+ import type { CreateMemoryInput } from "../../types/index.js";
5
+ export interface ImportResult {
6
+ memories: CreateMemoryInput[];
7
+ warnings: string[];
8
+ source_format: string;
9
+ }
10
+ interface Mem0Export {
11
+ id?: string;
12
+ memory?: string;
13
+ user_id?: string;
14
+ metadata?: Record<string, unknown>;
15
+ created_at?: string;
16
+ categories?: string[];
17
+ }
18
+ export declare function importMem0(data: Mem0Export[]): ImportResult;
19
+ interface ZepExport {
20
+ uuid?: string;
21
+ fact?: string;
22
+ rating?: number;
23
+ valid_at?: string;
24
+ invalid_at?: string;
25
+ source_node_name?: string;
26
+ target_node_name?: string;
27
+ }
28
+ export declare function importZep(data: ZepExport[]): ImportResult;
29
+ interface LangMemExport {
30
+ id?: string;
31
+ content?: string;
32
+ namespace?: string;
33
+ metadata?: Record<string, unknown>;
34
+ }
35
+ export declare function importLangMem(data: LangMemExport[]): ImportResult;
36
+ export declare function detectFormat(data: unknown[]): "mem0" | "zep" | "langmem" | "unknown";
37
+ export {};
38
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/importers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAM9D,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACvB;AAMD,UAAU,UAAU;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,YAAY,CAqB3D;AAMD,UAAU,SAAS;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,YAAY,CA8BzD;AAMD,UAAU,aAAa;IACrB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,EAAE,GAAG,YAAY,CAqBjE;AAMD,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,GAAG,SAAS,CAOpF"}
@@ -0,0 +1,86 @@
1
+ import { Database } from "bun:sqlite";
2
+ import type { MemoryCategory, MementosConfig } from "../types/index.js";
3
+ export type InjectionStrategy = "default" | "smart" | "smart-pipeline";
4
+ export interface InjectionOptions {
5
+ agent_id?: string;
6
+ project_id?: string;
7
+ session_id?: string;
8
+ max_tokens?: number;
9
+ categories?: MemoryCategory[];
10
+ min_importance?: number;
11
+ strategy?: InjectionStrategy;
12
+ query?: string;
13
+ db?: Database;
14
+ }
15
+ export interface SmartInjectionOptions {
16
+ /** Free-text description of what the agent is currently doing */
17
+ task_context: string;
18
+ /** Project to scope memories to */
19
+ project_id?: string;
20
+ /** Agent to scope private memories to */
21
+ agent_id?: string;
22
+ /** Session for working memory */
23
+ session_id?: string;
24
+ /** Max tokens for the entire output (~4 chars/token) */
25
+ max_tokens?: number;
26
+ /** Minimum importance threshold (before decay) */
27
+ min_importance?: number;
28
+ /** Force profile resynthesis even if cached */
29
+ force_profile_refresh?: boolean;
30
+ /** Optional DB handle */
31
+ db?: Database;
32
+ }
33
+ /** Structured result from the smart injection pipeline */
34
+ export interface SmartInjectionResult {
35
+ /** Formatted markdown string ready for system prompt */
36
+ output: string;
37
+ /** Token estimate of the output */
38
+ token_estimate: number;
39
+ /** Number of memories included */
40
+ memory_count: number;
41
+ /** Whether the profile was loaded from cache */
42
+ profile_from_cache: boolean;
43
+ /** Tool names detected in task_context */
44
+ detected_tools: string[];
45
+ }
46
+ export declare class MemoryInjector {
47
+ private config;
48
+ private injectedIds;
49
+ constructor(config?: MementosConfig);
50
+ /**
51
+ * Get formatted injection context suitable for system prompt insertion.
52
+ * Produces structured output with Key Memories and Recent Context sections.
53
+ * Token-budget aware.
54
+ */
55
+ getInjectionContext(options?: InjectionOptions): string;
56
+ /**
57
+ * Async smart injection: scores memories by embedding similarity + importance + recency.
58
+ * Falls back to default strategy if no embeddings exist or no query is provided.
59
+ */
60
+ getSmartInjectionContext(options?: InjectionOptions): Promise<string>;
61
+ /**
62
+ * Reset the deduplication window (call between refresh intervals)
63
+ */
64
+ resetDedup(): void;
65
+ /**
66
+ * Get count of memories injected so far in this session
67
+ */
68
+ getInjectedCount(): number;
69
+ }
70
+ /**
71
+ * Smart injection pipeline — the full-featured context injection strategy.
72
+ *
73
+ * Pipeline stages:
74
+ * 1. Parse task context — accept a task_context string describing what the agent is doing
75
+ * 2. Load or synthesize agent/project profile
76
+ * 3. Activation match — semantic search against task_context when embeddings exist
77
+ * 4. Tool guide retrieval — pull tool stats/lessons if task mentions tools
78
+ * 5. Decay scoring — apply forgetting curve to all candidate memories
79
+ * 6. Layer by type — Profile > Core Facts > Tool Guides > Procedural > Preferences > History
80
+ * 7. Token budgeting — fit into max_tokens, trimming lowest-relevance items first
81
+ *
82
+ * Falls back gracefully: no embeddings -> keyword matching, no profile -> skip section,
83
+ * no tool mentions -> skip tool guides.
84
+ */
85
+ export declare function smartInject(options: SmartInjectionOptions): Promise<SmartInjectionResult>;
86
+ //# sourceMappingURL=injector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"injector.d.ts","sourceRoot":"","sources":["../../src/lib/injector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAU,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAYhF,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,OAAO,GAAG,gBAAgB,CAAC;AAEvE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,QAAQ,CAAC;CACf;AAMD,MAAM,WAAW,qBAAqB;IACpC,iEAAiE;IACjE,YAAY,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+CAA+C;IAC/C,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,yBAAyB;IACzB,EAAE,CAAC,EAAE,QAAQ,CAAC;CACf;AAgBD,0DAA0D;AAC1D,MAAM,WAAW,oBAAoB;IACnC,wDAAwD;IACxD,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,kCAAkC;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,kBAAkB,EAAE,OAAO,CAAC;IAC5B,0CAA0C;IAC1C,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,WAAW,CAA0B;gBAEjC,MAAM,CAAC,EAAE,cAAc;IAInC;;;;OAIG;IACH,mBAAmB,CAAC,OAAO,GAAE,gBAAqB,GAAG,MAAM;IA0L3D;;;OAGG;IACG,wBAAwB,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC;IAuL/E;;OAEG;IACH,UAAU,IAAI,IAAI;IAIlB;;OAEG;IACH,gBAAgB,IAAI,MAAM;CAG3B;AAoJD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAyQ/F"}