jeopi-mnemopi 16.2.13

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 (135) hide show
  1. package/CHANGELOG.md +172 -0
  2. package/README.md +107 -0
  3. package/dist/types/cli.d.ts +35 -0
  4. package/dist/types/config.d.ts +108 -0
  5. package/dist/types/core/aaak.d.ts +55 -0
  6. package/dist/types/core/annotations.d.ts +75 -0
  7. package/dist/types/core/banks.d.ts +33 -0
  8. package/dist/types/core/beam/consolidate.d.ts +32 -0
  9. package/dist/types/core/beam/helpers.d.ts +69 -0
  10. package/dist/types/core/beam/index.d.ts +59 -0
  11. package/dist/types/core/beam/recall.d.ts +32 -0
  12. package/dist/types/core/beam/schema.d.ts +2 -0
  13. package/dist/types/core/beam/store.d.ts +56 -0
  14. package/dist/types/core/beam/types.d.ts +245 -0
  15. package/dist/types/core/binary-vectors.d.ts +54 -0
  16. package/dist/types/core/chat-normalize.d.ts +13 -0
  17. package/dist/types/core/content-sanitizer.d.ts +18 -0
  18. package/dist/types/core/cost-log.d.ts +13 -0
  19. package/dist/types/core/embeddings.d.ts +54 -0
  20. package/dist/types/core/entities.d.ts +9 -0
  21. package/dist/types/core/episodic-graph.d.ts +89 -0
  22. package/dist/types/core/extraction/client.d.ts +35 -0
  23. package/dist/types/core/extraction/diagnostics.d.ts +51 -0
  24. package/dist/types/core/extraction/prompts.d.ts +2 -0
  25. package/dist/types/core/extraction.d.ts +7 -0
  26. package/dist/types/core/fastembed-model-cache.d.ts +2 -0
  27. package/dist/types/core/fastembed-runtime.d.ts +14 -0
  28. package/dist/types/core/index.d.ts +6 -0
  29. package/dist/types/core/llm-backends.d.ts +23 -0
  30. package/dist/types/core/local-llm.d.ts +20 -0
  31. package/dist/types/core/memory.d.ts +178 -0
  32. package/dist/types/core/migrations/e6-triplestore-split.d.ts +17 -0
  33. package/dist/types/core/migrations/index.d.ts +1 -0
  34. package/dist/types/core/mmr.d.ts +8 -0
  35. package/dist/types/core/orchestrator.d.ts +20 -0
  36. package/dist/types/core/patterns.d.ts +61 -0
  37. package/dist/types/core/plugins.d.ts +109 -0
  38. package/dist/types/core/polyphonic-recall.d.ts +66 -0
  39. package/dist/types/core/query-cache.d.ts +45 -0
  40. package/dist/types/core/query-intent.d.ts +20 -0
  41. package/dist/types/core/recall-diagnostics.d.ts +48 -0
  42. package/dist/types/core/runtime-options.d.ts +76 -0
  43. package/dist/types/core/shmr.d.ts +62 -0
  44. package/dist/types/core/streaming.d.ts +136 -0
  45. package/dist/types/core/synonyms.d.ts +46 -0
  46. package/dist/types/core/temporal-parser.d.ts +16 -0
  47. package/dist/types/core/token-counter.d.ts +8 -0
  48. package/dist/types/core/triples.d.ts +63 -0
  49. package/dist/types/core/typed-memory.d.ts +39 -0
  50. package/dist/types/core/vector-index.d.ts +16 -0
  51. package/dist/types/core/vector-math.d.ts +1 -0
  52. package/dist/types/core/veracity-consolidation.d.ts +60 -0
  53. package/dist/types/core/weibull.d.ts +96 -0
  54. package/dist/types/db.d.ts +16 -0
  55. package/dist/types/diagnose.d.ts +24 -0
  56. package/dist/types/dr/index.d.ts +1 -0
  57. package/dist/types/dr/recovery.d.ts +68 -0
  58. package/dist/types/index.d.ts +6 -0
  59. package/dist/types/mcp-server.d.ts +40 -0
  60. package/dist/types/mcp-tools.d.ts +484 -0
  61. package/dist/types/migrations/e6-triplestore-split.d.ts +1 -0
  62. package/dist/types/migrations/index.d.ts +1 -0
  63. package/dist/types/types.d.ts +145 -0
  64. package/dist/types/util/datetime.d.ts +8 -0
  65. package/dist/types/util/env.d.ts +10 -0
  66. package/dist/types/util/ids.d.ts +3 -0
  67. package/dist/types/util/lru.d.ts +12 -0
  68. package/dist/types/util/regex.d.ts +11 -0
  69. package/package.json +108 -0
  70. package/src/cli.ts +398 -0
  71. package/src/config.ts +373 -0
  72. package/src/core/aaak.ts +142 -0
  73. package/src/core/annotations.ts +457 -0
  74. package/src/core/banks.ts +133 -0
  75. package/src/core/beam/consolidate.ts +1068 -0
  76. package/src/core/beam/helpers.ts +831 -0
  77. package/src/core/beam/index.ts +358 -0
  78. package/src/core/beam/recall.ts +1173 -0
  79. package/src/core/beam/schema.ts +423 -0
  80. package/src/core/beam/store.ts +936 -0
  81. package/src/core/beam/types.ts +280 -0
  82. package/src/core/binary-vectors.ts +317 -0
  83. package/src/core/chat-normalize.ts +160 -0
  84. package/src/core/content-sanitizer.ts +136 -0
  85. package/src/core/cost-log.ts +103 -0
  86. package/src/core/embeddings.ts +531 -0
  87. package/src/core/entities.ts +263 -0
  88. package/src/core/episodic-graph.ts +708 -0
  89. package/src/core/extraction/client.ts +187 -0
  90. package/src/core/extraction/diagnostics.ts +193 -0
  91. package/src/core/extraction/prompts.ts +31 -0
  92. package/src/core/extraction.ts +338 -0
  93. package/src/core/fastembed-model-cache.ts +39 -0
  94. package/src/core/fastembed-runtime.ts +108 -0
  95. package/src/core/index.ts +38 -0
  96. package/src/core/llm-backends.ts +54 -0
  97. package/src/core/local-llm.ts +474 -0
  98. package/src/core/memory.ts +667 -0
  99. package/src/core/migrations/e6-triplestore-split.ts +211 -0
  100. package/src/core/migrations/index.ts +1 -0
  101. package/src/core/mmr.ts +71 -0
  102. package/src/core/orchestrator.ts +62 -0
  103. package/src/core/patterns.ts +484 -0
  104. package/src/core/plugins.ts +375 -0
  105. package/src/core/polyphonic-recall.ts +563 -0
  106. package/src/core/query-cache.ts +353 -0
  107. package/src/core/query-intent.ts +139 -0
  108. package/src/core/recall-diagnostics.ts +157 -0
  109. package/src/core/runtime-options.ts +130 -0
  110. package/src/core/shmr.ts +560 -0
  111. package/src/core/streaming.ts +419 -0
  112. package/src/core/synonyms.ts +197 -0
  113. package/src/core/temporal-parser.ts +363 -0
  114. package/src/core/token-counter.ts +30 -0
  115. package/src/core/triples.ts +452 -0
  116. package/src/core/typed-memory.ts +407 -0
  117. package/src/core/vector-index.ts +84 -0
  118. package/src/core/vector-math.ts +23 -0
  119. package/src/core/veracity-consolidation.ts +477 -0
  120. package/src/core/weibull.ts +124 -0
  121. package/src/db.ts +128 -0
  122. package/src/diagnose.ts +174 -0
  123. package/src/dr/index.ts +1 -0
  124. package/src/dr/recovery.ts +405 -0
  125. package/src/index.ts +33 -0
  126. package/src/mcp-server.ts +155 -0
  127. package/src/mcp-tools.ts +970 -0
  128. package/src/migrations/e6-triplestore-split.ts +1 -0
  129. package/src/migrations/index.ts +1 -0
  130. package/src/types.ts +157 -0
  131. package/src/util/datetime.ts +69 -0
  132. package/src/util/env.ts +65 -0
  133. package/src/util/ids.ts +19 -0
  134. package/src/util/lru.ts +48 -0
  135. package/src/util/regex.ts +165 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,172 @@
1
+ # Changelog
2
+
3
+ ## [Unreleased]
4
+
5
+ ## [16.2.2] - 2026-06-27
6
+
7
+ ### Fixed
8
+
9
+ - Improved resilience during API extraction calls by enhancing the handling of rate limits and transient errors.
10
+
11
+ ## [16.1.17] - 2026-06-24
12
+
13
+ ### Fixed
14
+
15
+ - Fixed `remember(..., { extract: true })` fact/entity extraction accepting an `extractText` override so hosts can store full transcripts while mining facts from a safer projection; also tightened deterministic `Instruction:` extraction to require an explicit `I`/`you` subject instead of treating every `always`/`never` clause as a user instruction. ([#3372](https://github.com/can1357/oh-my-pi/issues/3372))
16
+
17
+ ## [16.1.8] - 2026-06-20
18
+
19
+ ### Fixed
20
+
21
+ - Capped per-input length in `embed()` at `MNEMOPI_EMBEDDING_MAX_INPUT_CHARS` (default 8192 chars, override via the env var or `embeddings.maxInputChars` runtime option; `0` disables) so a long retention transcript can no longer overflow the embedding model's context window. Oversized inputs are clipped with a head/tail split so chronological transcripts keep both the opening setup and the most recent turns instead of losing the latest content under a naive prefix slice. llama.cpp's `/embeddings` server used to reject the request with `request (N tokens) exceeds the available context size`, silently dropping vector recall for that memory ([#3126](https://github.com/can1357/oh-my-pi/issues/3126)).
22
+ - Fixed the proactive-linking write path ignoring host configuration: `proactiveLinkIfEnabled` read `MNEMOPI_PROACTIVE_LINKING` directly, so a host that enabled proactive linking through `configureRecallFeatures()` had no effect unless the environment variable was also set. `proactiveLinking` is now a `RecallFeatureFlags` option resolved through a `proactiveLinkingEnabled()` fallback, matching the existing polyphonic and enhanced recall flags, with the `MNEMOPI_PROACTIVE_LINKING` environment variable still taking precedence whenever it is set. ([#2440](https://github.com/can1357/oh-my-pi/issues/2440))
23
+
24
+ ## [16.1.3] - 2026-06-19
25
+
26
+ ### Added
27
+
28
+ - Exposed `setLocalModelInitializer` (and the `LocalEmbeddingModel`, `LocalModelInitializer`, `LocalModelInitOptions`, `StandardEmbeddingModel` types) so hosts can route fastembed loads through a dedicated subprocess and keep `onnxruntime-node`'s NAPI constructor + finalizer out of their own address space. Same wipe semantics as the existing `setLocalModelInitializerForTests` seam; the agent CLI uses it to crash-proof Windows when `memory.backend: mnemopi` is enabled ([#3031](https://github.com/can1357/oh-my-pi/issues/3031)).
29
+
30
+ ### Fixed
31
+
32
+ - Fixed background fact extraction skipping runtime-configured remote LLM endpoints when `MNEMOPI_LLM_BASE_URL` was unset, so `remember(..., { extract: true })` now stores remote-distilled facts from `mnemopi.llm` config instead of falling back to regex heuristics. ([#3041](https://github.com/can1357/oh-my-pi/issues/3041))
33
+ - Fixed local fastembed startup on macOS ARM64 by letting `fastembed@2.1.0` install its matching `onnxruntime-node@1.21.0` native runtime instead of forcing `1.26.0`, and by repairing missing tokenizer sidecars from the upstream Hugging Face model cache when a stale fastembed archive lacks them. ([#3054](https://github.com/can1357/oh-my-pi/issues/3054))
34
+
35
+ ## [16.0.6] - 2026-06-18
36
+
37
+ ### Fixed
38
+
39
+ - Forced the on-demand fastembed runtime install to override fastembed's archived `onnxruntime-node@1.21.0` transitive pin with Mnemopi's `onnxruntime-node@1.26.0` pin, fixing local embedding startup on macOS ARM64. ([#2920](https://github.com/can1357/oh-my-pi/issues/2920))
40
+
41
+ ### Changed
42
+
43
+ - Updated OpenRouter request headers to use standard shared headers from the pi-ai package
44
+
45
+ ## [16.0.5] - 2026-06-17
46
+
47
+ ### Fixed
48
+
49
+ - Capped `sleep_consolidation` episodic rows at `maxEpisodeChars` (default 100KB, `MNEMOPI_MAX_EPISODE_CHARS`) so raw session transcripts cannot be stored and extracted as multi-megabyte episodes. ([#2869](https://github.com/can1357/oh-my-pi/issues/2869))
50
+ - Skipped regex-only entity and pattern fact extraction for oversized raw transcripts so progress/log noise cannot flood MEMORIA with junk facts. ([#2868](https://github.com/can1357/oh-my-pi/issues/2868))
51
+
52
+ ## [15.13.1] - 2026-06-15
53
+
54
+ ### Added
55
+
56
+ - Added a wipe-and-rebuild reconcile (`reconcileEmbeddingModel`) that runs when the configured embedding model changes. At store open, if the model stamped on stored `memory_embeddings` rows differs from the active `currentEmbeddingModel()`, the stale embeddings and their binary vectors are dropped and every existing memory is enqueued for background re-embedding (in bounded batches) at the new model/dimension. The destructive wipe is skipped whenever it could not be rebuilt — embeddings disabled via the runtime option or the `MNEMOPI_NO_EMBEDDINGS` env, an unresolved (empty) active model, or a read-only open (`reconcile: false`, used by ephemeral stats readers that would exit before the async rebuild finished) — so a stale-but-valid corpus is never destroyed without a replacement. Recall degrades gracefully (FTS-only) for memories whose vectors are not yet rebuilt ([#2476](https://github.com/can1357/oh-my-pi/issues/2476))
57
+
58
+ ### Fixed
59
+
60
+ - Normalized enhanced recall fact scoring against lexical coverage so high-confidence facts that only match generic query tokens no longer outrank exact working-memory hits. ([#2441](https://github.com/can1357/oh-my-pi/issues/2441))
61
+
62
+ ## [15.12.4] - 2026-06-13
63
+
64
+ ### Fixed
65
+
66
+ - Fixed `consolidateToEpisodic` (the function backing `sleep` / `sleepAllSessions`) never populating the episodic graph: the `gists` and `graph_edges` tables stayed at 0 rows across every bank even after multiple consolidation cycles, so Polyphonic Recall's `graph` voice (BFS over `findGistsByParticipant` / `findRelatedMemories`) always returned nothing. Consolidation now best-effort ingests the new episodic memory into `EpisodicGraph` so the gist row, gist→memory `ctx` edge, fact edges, and cross-memory similarity/entity/temporal edges land alongside the episodic row. Independent of the existing `MNEMOPI_PROACTIVE_LINKING` flag, which still gates the same enrichment on the `remember()` write path. ([#2435](https://github.com/can1357/oh-my-pi/issues/2435))
67
+
68
+ ## [15.12.0] - 2026-06-12
69
+
70
+ ### Changed
71
+
72
+ - Moved `fastembed` and `onnxruntime-node` from `dependencies` to optional `peerDependencies` pinned to exact versions. When the peers are absent (bundled CLI, compiled binary, or installs that skip optional peers), the local embedding path `bun install`s the pinned pair into `~/.omp/cache/fastembed-runtime/<version-key>` on first use and loads fastembed from there — restoring local embeddings in bundled distributions and removing ~270MB of eager native downloads from default installs ([#2389](https://github.com/can1357/oh-my-pi/issues/2389))
73
+
74
+ ## [15.11.4] - 2026-06-12
75
+
76
+ ### Added
77
+
78
+ - Added `configureRecallFeatures()` (exported from the package root, `core`, and `config`) so hosts can enable the polyphonic recall engine and the enhanced recall query cache programmatically. `polyphonicRecallEnabled()`, `enhancedRecallEnabled()`, and `isEnhancedRecallEnabled()` now fall back to these configured defaults, with the `MNEMOPI_POLYPHONIC_RECALL` / `MNEMOPI_ENHANCED_RECALL` environment variables still taking precedence whenever they are set. ([#2323](https://github.com/can1357/oh-my-pi/issues/2323))
79
+
80
+ ### Fixed
81
+
82
+ - Fixed the embedding pipeline's silent `catch {}` blocks (`runEmbedding()`, `getLocalModel()`, and the local-model path of `embed()`) swallowing failures with zero diagnostics. These best-effort paths still degrade gracefully (return `null` / skip the write), but now emit structured `logger.debug` entries with the error and per-site context (item count, model name). The `mnemopi.debug` config flag now propagates into the core library via runtime options (`MnemopiOptions.debug` → `ResolvedMnemopiRuntimeOptions.debug`) and escalates these logs to `warn` so they surface at the default log level. ([#2322](https://github.com/can1357/oh-my-pi/issues/2322))
83
+
84
+ ### Changed
85
+
86
+ - Extraction, embedding, and remote-LLM clients now accept an `ApiKey` (static string or resolver) and resolve it per request through `withAuth`, so 401s force-refresh and rotate credentials via the central auth-retry policy instead of failing with a stale key. Empty-key setups (local/proxy endpoints without `Authorization`) and pinned literal keys behave exactly as before.
87
+ - Embedding and remote-LLM 401 errors now throw pi-ai's typed `ProviderHttpError` instead of `Object.assign`-patched `Error`s, keeping the same structural `.status` contract for the auth-retry classifier.
88
+ - SHMR consolidation clustering (`core/shmr`) now uses the real embedding provider when one is configured instead of always hashing: `embed()`, the new `embedBatch()`, `clusterBySimilarity()`, `computeHarmonyScore()`, `harmonize()`, and `recallBeliefs()` are now async, batch-embed candidate texts in a single provider call, and reuse precomputed vectors from `memory_embeddings` for episodic candidates. The SHA1 bag-of-words hash remains as the deterministic fallback when no provider is available or embedding fails. ([#2324](https://github.com/can1357/oh-my-pi/issues/2324))
89
+
90
+ ## [15.10.12] - 2026-06-10
91
+
92
+ ### Changed
93
+
94
+ - Reworked the in-memory fallback vector search to build a normalized exact vector index per query, matching the shape needed for future quantized or TurboVec-style backends without adding a new dependency yet.
95
+
96
+ ## [15.10.11] - 2026-06-10
97
+
98
+ ### Fixed
99
+
100
+ - Fixed embedding provider detection to match `openrouter` by URL host, so custom embedding endpoints are now recognized correctly instead of being misclassified by substring matching
101
+ - Fixed the check for OpenRouter base URLs so only true `openrouter` hosts are treated as non-custom
102
+
103
+ ## [15.10.8] - 2026-06-09
104
+
105
+ ### Added
106
+
107
+ - Added a `fetch` option to `ExtractionClient` to inject a custom fetch implementation for remote LLM requests
108
+ - Added an optional `fetch` option to `extractFacts` to control the transport used for remote extraction calls
109
+ - Added support for passing a custom `fetch` implementation through `complete` and `summarizeMemories` via remote LLM options
110
+
111
+ ## [15.9.1] - 2026-06-04
112
+
113
+ ### Breaking Changes
114
+
115
+ - Changed `Mnemopi.recall()`, `Mnemopi.recallEnhanced()`, `Mnemopi.search()`, `Mnemopi.query()`, the module-level `recall`/`recallEnhanced`/`search`/`query` exports, the `BeamMemory.recall`/`recallEnhanced` methods, the free `recall`/`recallEnhanced` functions in `core/beam/recall`, and `orchestrateRecall` to return `Promise<RecallResult[]>` so the recall pipeline can auto-derive `queryEmbedding` from the query text via `embedQuery`. Callers must `await` recall calls; pass `queryEmbedding: null` to opt out of auto-embedding and stay on FTS-only.
116
+ - Changed the MCP entrypoints `handleToolCall`, `callToolJson`, and `handleJsonRpc` in `mcp-server`/`mcp-tools` to async so the recall/shared-recall handlers can await the new `Promise<ToolResult[]>` shape; external MCP transports must `await` these.
117
+
118
+ ### Fixed
119
+
120
+ - Fixed `memory_embeddings` never being populated by the production `remember`/`rememberBatch`/`updateWorking`/`consolidateToEpisodic` paths; embedding generation is now scheduled as a background task on `beam.pendingExtractions` (mirroring `scheduleFactExtraction`), so configured providers (fastembed, OpenAI-compatible API, custom) actually run and rows land in `memory_embeddings(memory_id, embedding_json, model)`. ([#1832](https://github.com/can1357/oh-my-pi/issues/1832))
121
+ - Fixed `recall()`/`recallEnhanced()` never deriving a query embedding from the query text, which silently degraded every deployment to FTS-only regardless of provider configuration. The recall pipeline now auto-calls `embedQuery(query)` when `options.queryEmbedding` is undefined; pass `null` to keep the old FTS-only behaviour. ([#1832](https://github.com/can1357/oh-my-pi/issues/1832))
122
+ - Fixed `toRecallOptions` dropping `queryEmbedding` between the `Mnemopi` facade and the beam layer, so callers can now explicitly pin or disable the query vector through the public API.
123
+ - Fixed `withMemory` (CLI) and `withBeam`/`withSharedBeam` (MCP) closing the SQLite handle before background fact-extraction and embedding tasks finished, so short-lived `mnemopi store`/`mnemopi sleep` and MCP `remember`/`update` paths now drain `flushExtractions` before close instead of silently dropping `memory_embeddings` rows. CLI handlers and MCP `handleRemember`/`handleUpdate`/`handleSleep`/etc. are async as a result. ([#1832](https://github.com/can1357/oh-my-pi/issues/1832), follow-up to [#1833](https://github.com/can1357/oh-my-pi/pull/1833) review)
124
+ - Fixed the process-wide `embedQuery()` cache in `core/embeddings.ts` keying by query text alone, which let two `Mnemopi` instances in the same process with different providers/models cross-contaminate their `dense_score` rankings. The cache key now includes a WeakMap-assigned provider identity, the resolved model name, and the configured `apiUrl`, so disjoint runtimes never read each other's cached vectors. ([#1832](https://github.com/can1357/oh-my-pi/issues/1832), follow-up to [#1833](https://github.com/can1357/oh-my-pi/pull/1833) review)
125
+
126
+ ## [15.7.4] - 2026-05-31
127
+
128
+ ### Fixed
129
+
130
+ - Fixed the `darwin-x64` release build failing in `bun build --compile` because the Windows ORT 1.24 preload pulled `onnxruntime-node` into the static graph and there is no `darwin/x64` prebuilt for that line. The preload is now guarded behind a `process.platform === "win32"` literal that Bun dead-code-eliminates on non-Windows targets; macOS/Linux load fastembed's bundled ORT 1.21 binding as before.
131
+
132
+ ## [15.7.3] - 2026-05-31
133
+
134
+ ### Changed
135
+
136
+ - Changed embedding result normalization to return `Float32Array` vectors so `embed` and `embedQuery` now cache and emit float32 rows
137
+ - Changed the embedding provider contract to a single typed `EmbeddingOutput` (`AsyncIterable<number[][]>`) instead of `unknown`, matching fastembed's `embed()`, so `EmbeddingProvider.embed` and the `provider` runtime option stream the embedding matrix as async batches (`async *embed(texts) { yield texts.map(embedOne); }`)
138
+ - Changed local model cache directory resolution for `fastembed` to use `getFastembedCacheDir` instead of the hard-coded `~/.hermes/cache/fastembed` path
139
+
140
+ ### Fixed
141
+
142
+ - Fixed cosine similarity behavior across retrieval, clustering, and caching to consistently handle mismatched vector lengths as zero-padded and ignore non-finite values
143
+ - Fixed embedding API requests to retry transient failures with backoff via shared retry logic before returning null
144
+ - Fixed compiled `omp` binaries losing local Mnemopi embeddings by keeping `fastembed` and `onnxruntime-node` reachable to Bun's static compiler while preserving lazy runtime loading.
145
+
146
+ ## [15.7.2] - 2026-05-31
147
+
148
+ ### Fixed
149
+
150
+ - Fixed Windows startup crashes by keeping fastembed's older ONNX Runtime binding lazy until local embeddings are used.
151
+ - Fixed a segfault at startup from eagerly loading fastembed: importing the embeddings module pulled in `fastembed`, which eagerly loads the `onnxruntime-node` native addon. The import is now deferred until a local fastembed model is actually initialized, so API-model, disabled-embeddings, and test runtimes never load the native addon.
152
+
153
+ ## [15.6.0] - 2026-05-30
154
+
155
+ ### Added
156
+
157
+ - Added `llm.extractionPrompt` runtime option to override the fact-extraction prompt template using `{text}` and `{lang}` placeholders
158
+ - Added `llm.consolidationPrompt` runtime option to override the consolidation sleep prompt template using `{memories}`, `{source}`, and `{memory_count}` placeholders
159
+ - Published `jeopi-mnemopi` to npm: the local SQLite memory engine is now built, checked, tested, and released through the monorepo CI pipeline alongside the other workspace packages.
160
+ - Exported the diagnostic inspector as the `jeopi-mnemopi/diagnose` subpath for coding-agent memory maintenance commands.
161
+ - Added `flushExtractions()` (on `Mnemopi`, `BeamMemory`, and as a module-level export) to drain in-flight background fact extraction; used by tests and graceful shutdown so facts are persisted before the database closes.
162
+
163
+ ### Changed
164
+
165
+ - Changed fact extraction to prefer a configured runtime LLM completion path before host extraction, with automatic fallback when the configured completion returns no output or fails
166
+
167
+ ### Fixed
168
+
169
+ - Fixed `rememberBatch(..., { extract: true })` to run background fact extraction for batch uploads (including per-item `extract` flags) so extracted facts are generated and recallable after extraction
170
+ - Fixed `extract: true` fact extraction to continue safely when no LLM is configured by turning extraction failures into no-op background tasks
171
+ - Fixed configured LLM fact extraction by using temperature 0 so re-ingesting the same text is deterministic and avoids near-duplicate extractions
172
+ - Fixed `remember(..., { extract: true })` silently dropping the flag: it now schedules the LLM fact extractor (`extractFactsSafe`) over the stored content and persists the extracted facts so they become recallable. Previously the LLM extractor had no production callers and `extract` was dead.
package/README.md ADDED
@@ -0,0 +1,107 @@
1
+ # jeopi-mnemopi
2
+
3
+ Local SQLite memory engine for Oh My Pi agents.
4
+
5
+ This package is the Bun/TypeScript port of the Mnemosyne memory engine. It provides:
6
+
7
+ - `Mnemopi`, a small facade for remember/recall/stats/sleep workflows.
8
+ - `BeamMemory`, the lower-level working/episodic memory engine.
9
+ - MCP tool definitions and a dispatcher for host integrations.
10
+ - Optional local ONNX embeddings through `fastembed` and optional OpenAI-compatible embedding/LLM endpoints.
11
+
12
+ The package does not bundle or download a local GGUF LLM. LLM paths are host-backend or OpenAI-compatible remote only; when no LLM is configured, deterministic heuristic paths are used.
13
+
14
+ ## Basic use
15
+
16
+ ```ts
17
+ import { Mnemopi } from "jeopi-mnemopi";
18
+
19
+ const memory = new Mnemopi({ dbPath: "./mnemopi.db", bank: "project" });
20
+ const id = memory.remember("The deployment target is stable-cluster.", {
21
+ source: "notes",
22
+ importance: 0.8,
23
+ veracity: "true",
24
+ });
25
+
26
+ const results = memory.recall("deployment target", 5);
27
+ console.log(id, results[0]?.content);
28
+
29
+ memory.close();
30
+ ```
31
+
32
+ ## Configuration
33
+
34
+ `Mnemopi` accepts LLM and embedding options directly. `MNEMOPI_*` environment variables remain fallbacks/defaults when the matching constructor option is omitted.
35
+
36
+ ```ts
37
+ import { Mnemopi } from "jeopi-mnemopi";
38
+ import type { Model } from "jeopi-ai";
39
+
40
+ const ftsOnly = new Mnemopi({ noEmbeddings: true });
41
+
42
+ const remoteEmbeddings = new Mnemopi({
43
+ embeddingModel: "text-embedding-3-small",
44
+ embeddingApiUrl: "https://api.openai.com/v1",
45
+ embeddingApiKey: process.env.OPENAI_API_KEY,
46
+ });
47
+
48
+ const remoteLlm = new Mnemopi({
49
+ llm: {
50
+ baseUrl: "https://api.openai.com/v1",
51
+ apiKey: process.env.OPENAI_API_KEY,
52
+ model: "gpt-4.1-mini",
53
+ },
54
+ // Equivalent aliases: llmBaseUrl, llmApiKey, llmModel.
55
+ });
56
+
57
+ declare const smolModel: Model;
58
+ const piAiLlm = new Mnemopi({ llm: smolModel });
59
+ const dynamicLlm = new Mnemopi({
60
+ llm: async (prompt, opts) => {
61
+ const token = await getFreshOauthToken();
62
+ return await completeWithPiAi(prompt, {
63
+ token,
64
+ maxTokens: opts?.maxTokens,
65
+ temperature: opts?.temperature,
66
+ });
67
+ },
68
+ });
69
+ ```
70
+
71
+ ### Banks and host scoping
72
+
73
+ `Mnemopi` itself exposes banks directly through constructor options such as `bank`; it does not hard-code coding-agent project scoping.
74
+
75
+ The Oh My Pi coding-agent wrapper adds `mnemopi.scoping` on top of those constructor options:
76
+
77
+ - `global`: one shared bank
78
+ - `per-project`: isolated project memory
79
+ - `per-project-tagged`: project-local writes plus global recall visibility
80
+
81
+ In `per-project-tagged`, the wrapper is responsible for combining project-local retention with global recall visibility. The package still just exposes banks plus constructor-level LLM and embedding options.
82
+
83
+ Common environment fallbacks:
84
+
85
+ - `MNEMOPI_DATA_DIR` / `MNEMOPI_DB_PATH`: default storage location.
86
+ - `MNEMOPI_NO_EMBEDDINGS=1`: force FTS-only recall.
87
+ - `MNEMOPI_EMBEDDING_MODEL`: defaults to `BAAI/bge-small-en-v1.5`.
88
+ - `MNEMOPI_EMBEDDING_API_URL` and `MNEMOPI_EMBEDDING_API_KEY`: OpenAI-compatible embedding endpoint.
89
+ - `MNEMOPI_LLM_ENABLED=1`, `MNEMOPI_LLM_BASE_URL`, `MNEMOPI_LLM_API_KEY`, `MNEMOPI_LLM_MODEL`: OpenAI-compatible LLM endpoint.
90
+
91
+ Local embeddings use the `fastembed` npm package. Its default `BGESmallENV15` model is 384-dimensional and uses the package's CLS pooling plus vector normalization path. Local GGUF LLMs are not available in this package.
92
+
93
+ ## Commands
94
+
95
+ ```sh
96
+ mnemopi remember "Use stable-cluster for production deploys"
97
+ mnemopi recall "production deploy target"
98
+ mnemopi stats
99
+ mnemopi sleep
100
+ ```
101
+
102
+ ## Tests
103
+
104
+ ```sh
105
+ bun --cwd packages/mnemopi test
106
+ bun --cwd packages/mnemopi run check
107
+ ```
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env bun
2
+ import { BeamMemory } from "./core/beam";
3
+ export interface CliIo {
4
+ write(data: string): void;
5
+ }
6
+ export interface CliContext {
7
+ readonly dataDir?: string;
8
+ readonly dbPath?: string;
9
+ readonly memory?: BeamMemory;
10
+ readonly createMemory?: () => BeamMemory;
11
+ readonly stdout?: CliIo;
12
+ readonly stderr?: CliIo;
13
+ }
14
+ export declare class CliError extends Error {
15
+ readonly exitCode: number;
16
+ constructor(message: string, exitCode?: number);
17
+ }
18
+ type CommandHandler = (args: readonly string[], context?: CliContext) => number | Promise<number>;
19
+ export declare function memoryStats(memory: BeamMemory, dataDir?: string): Record<string, unknown>;
20
+ export declare const cmdExport: CommandHandler;
21
+ export declare const cmdImport: CommandHandler;
22
+ export declare const cmdMcp: CommandHandler;
23
+ export declare const cmdRemember: CommandHandler;
24
+ export declare const cmdRecall: CommandHandler;
25
+ export declare const cmdUpdate: CommandHandler;
26
+ export declare const cmdDelete: CommandHandler;
27
+ export declare const cmdStats: CommandHandler;
28
+ export declare const cmdSleep: CommandHandler;
29
+ export declare const cmdScratchpad: CommandHandler;
30
+ export declare const cmdBank: CommandHandler;
31
+ export declare const cmdDiagnose: CommandHandler;
32
+ export declare const COMMANDS: Readonly<Record<string, CommandHandler>>;
33
+ export declare function printHelp(context?: CliContext): void;
34
+ export declare function runCli(args?: readonly string[], context?: CliContext): Promise<number>;
35
+ export {};
@@ -0,0 +1,108 @@
1
+ import { type Env, envBool, envDisabled, envFloat, envInt, envOneOf, envOptionalString, envString, envTruthy } from "./util/env";
2
+ export type { Env };
3
+ export { envBool, envDisabled, envFloat, envInt, envOneOf, envOptionalString, envString, envTruthy };
4
+ export declare const DEFAULT_DATA_DIR: string;
5
+ export declare const DEFAULT_DB_FILENAME = "mnemopi.db";
6
+ export declare const FASTEMBED_CACHE_DIR: string;
7
+ export declare const MODEL_CACHE_DIR: string;
8
+ export declare const DEFAULT_EMBEDDING_MODEL = "BAAI/bge-small-en-v1.5";
9
+ export declare const DEFAULT_EMBEDDING_API_URL = "https://openrouter.ai/api/v1";
10
+ export declare const DEFAULT_LLM_MODEL_REPO = "TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF";
11
+ export declare const DEFAULT_LLM_MODEL_FILE = "tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf";
12
+ export declare const HOST_LLM_TIMEOUT_SECONDS = 15;
13
+ export type VecType = "float32" | "int8" | "bit";
14
+ export declare const EMBEDDING_DIMS: Readonly<Record<string, number>>;
15
+ export declare const VERACITY_WEIGHT_DEFAULTS: {
16
+ readonly stated: 1;
17
+ readonly inferred: 0.7;
18
+ readonly tool: 0.5;
19
+ readonly imported: 0.6;
20
+ readonly unknown: 0.8;
21
+ };
22
+ export declare function dataDir(env?: Env): string;
23
+ export declare function dbPath(env?: Env): string;
24
+ export declare function beamOptimizationsEnabled(env?: Env): boolean;
25
+ export declare function embeddingModel(env?: Env): string;
26
+ export declare function embeddingDim(env?: Env): number;
27
+ export declare function embeddingApiKey(env?: Env): string;
28
+ export declare function embeddingApiUrl(env?: Env): string;
29
+ export declare function embeddingsViaApi(env?: Env): boolean;
30
+ export declare function embeddingsDisabled(env?: Env): boolean;
31
+ /**
32
+ * Per-input character cap applied inside `embed()` before any provider sees the text.
33
+ *
34
+ * Long retention transcripts (full multi-turn session windows) routinely outgrow
35
+ * embedding model context windows: BGE/E5 defaults are 512 tokens, bge-m3 is
36
+ * 8192, and OpenAI's text-embedding-3-* is 8192. llama.cpp's `/embeddings`
37
+ * server rejects oversized requests with `request (N tokens) exceeds the
38
+ * available context size`; OpenAI silently right-truncates. Capping at the
39
+ * source gives both backends deterministic behavior and prevents the silent
40
+ * recall degradation we saw in issue #3126.
41
+ *
42
+ * Default `8192` chars is intentionally conservative for 8192-token embedding
43
+ * contexts (bge-m3, OpenAI text-embedding-3) and CJK-heavy transcripts. Raise
44
+ * it for larger local contexts (for example Qwen3-Embedding with 32k ctx).
45
+ * `0` disables the cap.
46
+ */
47
+ export declare function embeddingMaxInputChars(env?: Env): number;
48
+ export declare function isApiEmbeddingModel(model?: string, env?: Env): boolean;
49
+ export declare function apiEmbeddingsAvailable(env?: Env): boolean;
50
+ export declare function workingMemoryMaxItems(env?: Env): number;
51
+ export declare function workingMemoryTtlHours(env?: Env): number;
52
+ export declare function episodicRecallLimit(env?: Env): number;
53
+ export declare function maxEpisodeChars(env?: Env): number;
54
+ export declare function sleepBatchSize(env?: Env): number;
55
+ export declare function scratchpadMaxItems(env?: Env): number;
56
+ export declare function recencyHalflifeHours(env?: Env): number;
57
+ export declare function tier2Days(env?: Env): number;
58
+ export declare function tier3Days(env?: Env): number;
59
+ export declare function tier1Weight(env?: Env): number;
60
+ export declare function tier2Weight(env?: Env): number;
61
+ export declare function tier3Weight(env?: Env): number;
62
+ export declare function degradeBatchSize(env?: Env): number;
63
+ export declare function smartCompressEnabled(env?: Env): boolean;
64
+ export declare function tier3MaxChars(env?: Env): number;
65
+ export declare function statedWeight(env?: Env): number;
66
+ export declare function inferredWeight(env?: Env): number;
67
+ export declare function toolWeight(env?: Env): number;
68
+ export declare function importedWeight(env?: Env): number;
69
+ export declare function unknownWeight(env?: Env): number;
70
+ export declare function veracityWeightOverrides(env?: Env): string[];
71
+ export declare function vecType(env?: Env): VecType;
72
+ export declare function vectorWeight(env?: Env): number;
73
+ export declare function ftsWeight(env?: Env): number;
74
+ export declare function importanceWeight(env?: Env): number;
75
+ export declare function normalizedRecallWeights(vec?: number, fts?: number, importance?: number): readonly [number, number, number];
76
+ export declare function autoMigrateEnabled(env?: Env): boolean;
77
+ export interface RecallFeatureFlags {
78
+ polyphonicRecall?: boolean;
79
+ enhancedRecall?: boolean;
80
+ proactiveLinking?: boolean;
81
+ }
82
+ /**
83
+ * Sets process-wide defaults for the env-gated recall features. Host configuration
84
+ * (e.g. the coding-agent `mnemopi.polyphonicRecall` / `mnemopi.enhancedRecall` /
85
+ * `mnemopi.proactiveLinking` settings) lands here; the `MNEMOPI_POLYPHONIC_RECALL` /
86
+ * `MNEMOPI_ENHANCED_RECALL` / `MNEMOPI_PROACTIVE_LINKING` environment variables still
87
+ * win whenever they are set.
88
+ */
89
+ export declare function configureRecallFeatures(flags: RecallFeatureFlags): void;
90
+ export declare function polyphonicRecallEnabled(env?: Env): boolean;
91
+ export declare function temporalHalflifeHours(env?: Env): number;
92
+ export declare function enhancedRecallEnabled(env?: Env): boolean;
93
+ export declare function proactiveLinkingEnabled(env?: Env): boolean;
94
+ export declare function llmEnabled(env?: Env): boolean;
95
+ export declare function llmMaxTokens(env?: Env): number;
96
+ export declare function llmThreads(env?: Env): number;
97
+ export declare function llmContext(env?: Env): number;
98
+ export declare function llmRepo(env?: Env): string;
99
+ export declare function llmFile(env?: Env): string;
100
+ export declare function llmModelFiles(env?: Env): readonly [repo: string, file: string];
101
+ export declare function llmBaseUrl(env?: Env): string;
102
+ export declare function llmApiKey(env?: Env): string;
103
+ export declare function llmModel(env?: Env): string;
104
+ export declare function hostLlmEnabled(env?: Env): boolean;
105
+ export declare function hostLlmProvider(env?: Env): string | undefined;
106
+ export declare function hostLlmModel(env?: Env): string | undefined;
107
+ export declare function hostLlmContext(env?: Env): number;
108
+ export declare function sleepPrompt(env?: Env): string;
@@ -0,0 +1,55 @@
1
+ export declare const CATEGORY_MAP: {
2
+ readonly PREFERENCE: "PREF";
3
+ readonly TRAIT: "TRAIT";
4
+ readonly STATUS: "STAT";
5
+ readonly INSTRUCTION: "INST";
6
+ readonly PROJECT: "PROJ";
7
+ readonly LOCATION: "LOC";
8
+ readonly FAMILY: "FAM";
9
+ readonly OCCUPATION: "OCC";
10
+ readonly DECISION: "DEC";
11
+ readonly EVENT: "EVT";
12
+ readonly TOOL: "TOOL";
13
+ readonly FACT: "FACT";
14
+ readonly OPINION: "OPN";
15
+ };
16
+ export declare const PHRASE_MAP: {
17
+ readonly "User asked ": "ASK ";
18
+ readonly "User wants ": "WANT ";
19
+ readonly "User prefers ": "PREF ";
20
+ readonly "User likes ": "LIKE ";
21
+ readonly "User dislikes ": "DISLIKE ";
22
+ readonly "User is ": "IS ";
23
+ readonly "User has ": "HAS ";
24
+ readonly "User built ": "BUILT ";
25
+ readonly "User asked for ": "ASK ";
26
+ readonly "User requested ": "REQ ";
27
+ readonly "Married to ": "MARRIED→";
28
+ readonly "Email: ": "@";
29
+ readonly "GitHub: ": "GH:";
30
+ readonly "Location: ": "LOC:";
31
+ readonly "Phone: ": "PH:";
32
+ readonly "User email is ": "@";
33
+ readonly "User voice message ": "VM ";
34
+ readonly "User stack: ": "STACK|";
35
+ readonly "Full-stack developer": "FSDEV";
36
+ readonly "Software Developer": "SDEV";
37
+ readonly "AI Systems Engineer": "AIENG";
38
+ readonly "real-time": "RT";
39
+ readonly "Real-time": "RT";
40
+ readonly bilingual: "bi";
41
+ readonly Bilingual: "bi";
42
+ readonly "self-hosted": "selfhost";
43
+ readonly automation: "auto";
44
+ readonly transcription: "transc";
45
+ readonly translation: "transl";
46
+ };
47
+ export declare const STRUCTURAL_REPLACEMENTS: readonly (readonly [pattern: string, replacement: string])[];
48
+ export declare const REV_CATEGORY: Record<"DEC" | "EVT" | "FACT" | "FAM" | "INST" | "LOC" | "OCC" | "OPN" | "PREF" | "PROJ" | "STAT" | "TOOL" | "TRAIT", "DECISION" | "EVENT" | "FACT" | "FAMILY" | "INSTRUCTION" | "LOCATION" | "OCCUPATION" | "OPINION" | "PREFERENCE" | "PROJECT" | "STATUS" | "TOOL" | "TRAIT">;
49
+ export declare const REV_PHRASE: Record<"@" | "AIENG" | "ASK " | "BUILT " | "DISLIKE " | "FSDEV" | "GH:" | "HAS " | "IS " | "LIKE " | "LOC:" | "MARRIED→" | "PH:" | "PREF " | "REQ " | "RT" | "SDEV" | "STACK|" | "VM " | "WANT " | "auto" | "bi" | "selfhost" | "transc" | "transl", "AI Systems Engineer" | "Bilingual" | "Email: " | "Full-stack developer" | "GitHub: " | "Location: " | "Married to " | "Phone: " | "Real-time" | "Software Developer" | "User asked " | "User asked for " | "User built " | "User dislikes " | "User email is " | "User has " | "User is " | "User likes " | "User prefers " | "User requested " | "User stack: " | "User voice message " | "User wants " | "automation" | "bilingual" | "real-time" | "self-hosted" | "transcription" | "translation">;
50
+ export declare function applyCategoryPrefixes(text: string): string;
51
+ export declare function applyPhrases(text: string): string;
52
+ export declare function applyStructural(text: string): string;
53
+ export declare function compactParens(text: string): string;
54
+ export declare function encode(text: string): string;
55
+ export declare const aaakEncode: typeof encode;
@@ -0,0 +1,75 @@
1
+ import type { Database } from "bun:sqlite";
2
+ declare const ANNOTATION_KIND_VALUES: readonly ["mentions", "fact", "occurred_on", "has_source"];
3
+ export type AnnotationKind = (typeof ANNOTATION_KIND_VALUES)[number] | (string & {});
4
+ export declare const ENTITY_STOP_WORDS: ReadonlySet<string>;
5
+ export declare const ANNOTATION_KINDS: ReadonlySet<string>;
6
+ export declare const MIN_FACT_LENGTH = 10;
7
+ export interface AnnotationRow {
8
+ readonly id: number;
9
+ readonly memory_id: string;
10
+ readonly kind: string;
11
+ readonly value: string;
12
+ readonly source: string | null;
13
+ readonly confidence: number | null;
14
+ readonly created_at: string | null;
15
+ }
16
+ export interface AnnotationInput {
17
+ readonly id?: number | bigint | null;
18
+ readonly memory_id: string;
19
+ readonly kind: string;
20
+ readonly value: string;
21
+ readonly source?: string | null;
22
+ readonly confidence?: number | null;
23
+ readonly created_at?: string | null;
24
+ }
25
+ export interface AnnotationImportStats {
26
+ inserted: number;
27
+ skipped: number;
28
+ overwritten: number;
29
+ imported_renumbered: number;
30
+ }
31
+ export interface AnnotationStoreOptions {
32
+ readonly dbPath?: string;
33
+ readonly db_path?: string;
34
+ readonly db?: Database;
35
+ readonly conn?: Database;
36
+ }
37
+ export declare function filterCleanMentions<T extends {
38
+ readonly value?: string | null;
39
+ }>(rows: readonly T[]): T[];
40
+ export declare function filterFacts(facts: readonly string[] | null | undefined): string[];
41
+ export declare function initAnnotations(path?: string): void;
42
+ export declare function initAnnotationsWithConn(db: Database): void;
43
+ export declare class AnnotationStore {
44
+ readonly dbPath: string;
45
+ readonly db: Database;
46
+ readonly conn: Database;
47
+ private readonly ownsConnection;
48
+ constructor(options?: AnnotationStoreOptions | string);
49
+ close(): void;
50
+ add(memoryId: string, kind: string, value: string, source?: string, confidence?: number): number;
51
+ addMany(memoryId: string, kind: string, values: readonly string[] | null | undefined, source?: string, confidence?: number): number;
52
+ queryByMemory(memoryId: string, kind?: string | null): AnnotationRow[];
53
+ queryByKind(kind: string, options?: {
54
+ readonly value?: string | null;
55
+ readonly memory_id?: string | null;
56
+ readonly memoryId?: string | null;
57
+ readonly filter_noise?: boolean;
58
+ readonly filterNoise?: boolean;
59
+ }): AnnotationRow[];
60
+ getDistinctValues(kind: string): string[];
61
+ exportAll(): AnnotationRow[];
62
+ importAll(annotations: readonly AnnotationInput[], force?: boolean): AnnotationImportStats;
63
+ }
64
+ export declare function addAnnotation(memoryId: string, kind: string, value: string, source?: string, confidence?: number, path?: string): number;
65
+ export interface QueryAnnotationsOptions {
66
+ readonly memory_id?: string | null;
67
+ readonly memoryId?: string | null;
68
+ readonly kind?: string | null;
69
+ readonly value?: string | null;
70
+ readonly db_path?: string | null;
71
+ readonly dbPath?: string | null;
72
+ }
73
+ export declare function queryAnnotations(options?: QueryAnnotationsOptions): AnnotationRow[];
74
+ export declare function queryAnnotations(memoryId?: string | null, kind?: string | null, value?: string | null, dbPath?: string | null): AnnotationRow[];
75
+ export {};
@@ -0,0 +1,33 @@
1
+ export declare const DEFAULT_DATA_DIR: string;
2
+ export declare const BANKS_DIR: string;
3
+ export declare class ValueError extends Error {
4
+ name: string;
5
+ }
6
+ export interface BankStats {
7
+ readonly name: string;
8
+ readonly exists: boolean;
9
+ readonly db_path: string;
10
+ readonly dbSizeBytes: number;
11
+ readonly db_size_bytes: number;
12
+ }
13
+ export declare class BankManager {
14
+ readonly dataDir: string;
15
+ readonly banksDir: string;
16
+ constructor(dataDir?: string);
17
+ createBank(name: string): string;
18
+ deleteBank(name: string, force?: boolean): boolean;
19
+ listBanks(): string[];
20
+ bankExists(name: string): boolean;
21
+ getBankDbPath(name: string): string;
22
+ renameBank(oldName: string, newName: string): string;
23
+ getBankStats(name: string): BankStats;
24
+ private validateName;
25
+ }
26
+ export declare function createBank(name: string, dataDir?: string): string;
27
+ export declare function deleteBank(name: string, dataDir?: string, force?: boolean): boolean;
28
+ export declare function listBanks(dataDir?: string): string[];
29
+ export declare function bankExists(name: string, dataDir?: string): boolean;
30
+ export declare function bankDbPath(name?: string, dataDir?: string): string;
31
+ export declare function setBank(bank: string): void;
32
+ export declare function getBank(): string;
33
+ export declare function resetBankForTests(): void;
@@ -0,0 +1,32 @@
1
+ import type { BeamMemoryState, BeamStats, JsonValue, MemoriaRetrieveResult, Metadata, SleepResult } from "./types";
2
+ type Row = Record<string, unknown>;
3
+ type FactCounts = {
4
+ metric: number;
5
+ date: number;
6
+ version: number;
7
+ entity: number;
8
+ sequence: number;
9
+ timeline: number;
10
+ negation: number;
11
+ decision: number;
12
+ };
13
+ type ConsolidateOptions = {
14
+ metadata?: Metadata | null;
15
+ validUntil?: string | null;
16
+ scope?: string;
17
+ veracity?: string | null;
18
+ };
19
+ export declare function consolidateToEpisodic(beam: BeamMemoryState, summary: string, sourceWmIds: readonly string[], source?: string, importance?: number, options?: ConsolidateOptions): string;
20
+ export declare function detectLanguage(_beam: BeamMemoryState, text: string): string;
21
+ export declare function storeFactStrings(beam: BeamMemoryState, facts: readonly string[], messageIdx?: number, sourceMemoryId?: string | null, importance?: number): number;
22
+ export declare function extractAndStoreFacts(beam: BeamMemoryState, content: string, messageIdx?: number, sourceMemoryId?: string | null): FactCounts;
23
+ export declare function memoriaRetrieve(beam: BeamMemoryState, query: string, ability?: string | null, topK?: number): MemoriaRetrieveResult;
24
+ export declare function getEpisodicStats(beam: BeamMemoryState, authorId?: string | null, authorType?: string | null, channelId?: string | null): BeamStats;
25
+ export declare function getMemoriaStats(beam: BeamMemoryState): BeamStats;
26
+ export declare function degradeEpisodic(beam: BeamMemoryState, dryRun?: boolean): Record<string, JsonValue>;
27
+ export declare function getContaminated(beam: BeamMemoryState, limit?: number, minImportance?: number): Row[];
28
+ export declare function health(beam: BeamMemoryState, staleThresholdHours?: number): Record<string, JsonValue | Record<string, JsonValue>>;
29
+ export declare function sleep(beam: BeamMemoryState, dryRun?: boolean): SleepResult;
30
+ export declare function sleepAllSessions(beam: BeamMemoryState, dryRun?: boolean): SleepResult;
31
+ export declare function getConsolidationLog(beam: BeamMemoryState, limit?: number): Row[];
32
+ export {};