@prometheus-ai/memory 0.5.4 → 0.5.8

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 (50) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +4 -4
  3. package/dist/types/config.d.ts +13 -2
  4. package/dist/types/core/beam/store.d.ts +20 -0
  5. package/dist/types/core/embeddings.d.ts +2 -1
  6. package/dist/types/core/extraction/client.d.ts +11 -7
  7. package/dist/types/core/extraction.d.ts +2 -1
  8. package/dist/types/core/fastembed-runtime.d.ts +4 -0
  9. package/dist/types/core/index.d.ts +1 -0
  10. package/dist/types/core/llm-backends.d.ts +2 -0
  11. package/dist/types/core/local-llm.d.ts +8 -3
  12. package/dist/types/core/memory.d.ts +12 -3
  13. package/dist/types/core/query-cache.d.ts +1 -2
  14. package/dist/types/core/runtime-options.d.ts +10 -5
  15. package/dist/types/core/shmr.d.ts +11 -5
  16. package/dist/types/core/vector-index.d.ts +16 -0
  17. package/dist/types/index.d.ts +2 -1
  18. package/package.json +30 -7
  19. package/src/cli.ts +19 -19
  20. package/src/config.ts +98 -68
  21. package/src/core/banks.ts +2 -2
  22. package/src/core/beam/consolidate.ts +34 -5
  23. package/src/core/beam/helpers.ts +21 -28
  24. package/src/core/beam/index.ts +2 -2
  25. package/src/core/beam/recall.ts +98 -25
  26. package/src/core/beam/store.ts +96 -4
  27. package/src/core/binary-vectors.ts +1 -1
  28. package/src/core/content-sanitizer.ts +3 -3
  29. package/src/core/cost-log.ts +1 -1
  30. package/src/core/embeddings.ts +75 -50
  31. package/src/core/extraction/client.ts +44 -20
  32. package/src/core/extraction.ts +10 -9
  33. package/src/core/fastembed-runtime.ts +89 -0
  34. package/src/core/index.ts +1 -0
  35. package/src/core/llm-backends.ts +3 -0
  36. package/src/core/local-llm.ts +81 -43
  37. package/src/core/memory.ts +25 -5
  38. package/src/core/plugins.ts +1 -1
  39. package/src/core/polyphonic-recall.ts +4 -4
  40. package/src/core/query-cache.ts +2 -3
  41. package/src/core/runtime-options.ts +13 -5
  42. package/src/core/shmr.ts +141 -39
  43. package/src/core/streaming.ts +1 -1
  44. package/src/core/triples.ts +3 -3
  45. package/src/core/vector-index.ts +84 -0
  46. package/src/diagnose.ts +2 -2
  47. package/src/dr/recovery.ts +5 -5
  48. package/src/index.ts +1 -1
  49. package/src/mcp-server.ts +2 -2
  50. package/src/mcp-tools.ts +61 -61
package/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ ## [Unreleased]
4
+
5
+ ## [0.5.8] - 2026-06-14
6
+
7
+ - Centralize embedding-heavy test opt-in so normal memory tests stay lightweight by default.
8
+
9
+ ## [0.5.2] - 2026-06-12
10
+
11
+ - Clean up Prometheus package identity metadata.
12
+
13
+ ## [0.5.0] - 2026-06-11
14
+
15
+ - Establish Prometheus public baseline for the package.
package/README.md CHANGED
@@ -42,13 +42,13 @@ const ftsOnly = new PrometheusMemory({ noEmbeddings: true });
42
42
  const remoteEmbeddings = new PrometheusMemory({
43
43
  embeddingModel: "text-embedding-3-small",
44
44
  embeddingApiUrl: "https://api.openai.com/v1",
45
- embeddingApiKey: process.env.OPENAI_API_KEY,
45
+ embeddingApiKey: process.env.OPENAI_APROMETHEUS_KEY,
46
46
  });
47
47
 
48
48
  const remoteLlm = new PrometheusMemory({
49
49
  llm: {
50
50
  baseUrl: "https://api.openai.com/v1",
51
- apiKey: process.env.OPENAI_API_KEY,
51
+ apiKey: process.env.OPENAI_APROMETHEUS_KEY,
52
52
  model: "gpt-4.1-mini",
53
53
  },
54
54
  // Equivalent aliases: llmBaseUrl, llmApiKey, llmModel.
@@ -85,8 +85,8 @@ Common environment fallbacks:
85
85
  - `PROMETHEUS_MEMORY_DATA_DIR` / `PROMETHEUS_MEMORY_DB_PATH`: default storage location.
86
86
  - `PROMETHEUS_MEMORY_NO_EMBEDDINGS=1`: force FTS-only recall.
87
87
  - `PROMETHEUS_MEMORY_EMBEDDING_MODEL`: defaults to `BAAI/bge-small-en-v1.5`.
88
- - `PROMETHEUS_MEMORY_EMBEDDING_API_URL` and `PROMETHEUS_MEMORY_EMBEDDING_API_KEY`: OpenAI-compatible embedding endpoint.
89
- - `PROMETHEUS_MEMORY_LLM_ENABLED=1`, `PROMETHEUS_MEMORY_LLM_BASE_URL`, `PROMETHEUS_MEMORY_LLM_API_KEY`, `PROMETHEUS_MEMORY_LLM_MODEL`: OpenAI-compatible LLM endpoint.
88
+ - `PROMETHEUS_MEMORY_EMBEDDING_APROMETHEUS_URL` and `PROMETHEUS_MEMORY_EMBEDDING_APROMETHEUS_KEY`: OpenAI-compatible embedding endpoint.
89
+ - `PROMETHEUS_MEMORY_LLM_ENABLED=1`, `PROMETHEUS_MEMORY_LLM_BASE_URL`, `PROMETHEUS_MEMORY_LLM_APROMETHEUS_KEY`, `PROMETHEUS_MEMORY_LLM_MODEL`: OpenAI-compatible LLM endpoint.
90
90
 
91
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
92
 
@@ -2,11 +2,11 @@ import { type Env, envBool, envDisabled, envFloat, envInt, envOneOf, envOptional
2
2
  export type { Env };
3
3
  export { envBool, envDisabled, envFloat, envInt, envOneOf, envOptionalString, envString, envTruthy };
4
4
  export declare const DEFAULT_DATA_DIR: string;
5
- export declare const DEFAULT_DB_FILENAME = "prometheus-memory.db";
5
+ export declare const DEFAULT_DB_FILENAME = "mnemopi.db";
6
6
  export declare const FASTEMBED_CACHE_DIR: string;
7
7
  export declare const MODEL_CACHE_DIR: string;
8
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";
9
+ export declare const DEFAULT_EMBEDDING_APROMETHEUS_URL = "https://openrouter.ai/api/v1";
10
10
  export declare const DEFAULT_LLM_MODEL_REPO = "TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF";
11
11
  export declare const DEFAULT_LLM_MODEL_FILE = "tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf";
12
12
  export declare const HOST_LLM_TIMEOUT_SECONDS = 15;
@@ -57,6 +57,17 @@ export declare function importanceWeight(env?: Env): number;
57
57
  export declare function normalizedRecallWeights(vec?: number, fts?: number, importance?: number): readonly [number, number, number];
58
58
  export declare function autoMigrateEnabled(env?: Env): boolean;
59
59
  export declare function proactiveLinkingEnabled(env?: Env): boolean;
60
+ export interface RecallFeatureFlags {
61
+ polyphonicRecall?: boolean;
62
+ enhancedRecall?: boolean;
63
+ }
64
+ /**
65
+ * Sets process-wide defaults for the env-gated recall features. Host configuration
66
+ * (e.g. the coding-agent `mnemopi.polyphonicRecall` / `mnemopi.enhancedRecall`
67
+ * settings) lands here; the `MNEMOPROMETHEUS_POLYPHONIC_RECALL` / `MNEMOPROMETHEUS_ENHANCED_RECALL`
68
+ * environment variables still win whenever they are set.
69
+ */
70
+ export declare function configureRecallFeatures(flags: RecallFeatureFlags): void;
60
71
  export declare function polyphonicRecallEnabled(env?: Env): boolean;
61
72
  export declare function temporalHalflifeHours(env?: Env): number;
62
73
  export declare function enhancedRecallEnabled(env?: Env): boolean;
@@ -18,6 +18,26 @@ type StoreRememberBatchOptions = RememberBatchOptions & {
18
18
  forceVeracity?: boolean;
19
19
  force_veracity?: boolean;
20
20
  };
21
+ /**
22
+ * Reconcile stored embeddings against the active embedding model at store open.
23
+ *
24
+ * Every `memory_embeddings` row is stamped with the model that produced it (see
25
+ * `runEmbedding` in `helpers.ts`). When the configured embedding model changes,
26
+ * its vector dimension changes too, so the previously-stored vectors are no
27
+ * longer comparable. On a mismatch we wipe every stored vector — the
28
+ * `memory_embeddings` table, the `episodic_memory.binary_vector` column, and the
29
+ * sqlite-vec `vec_episodes` index — then enqueue all live memories for
30
+ * background re-embedding under the new model via `scheduleEmbedding`.
31
+ *
32
+ * Runs once per store open; a fresh store (no embeddings) or an already-current
33
+ * store is a no-op. The destructive wipe is skipped whenever it could not be
34
+ * rebuilt — embeddings disabled via the runtime option OR the
35
+ * `MNEMOPROMETHEUS_NO_EMBEDDINGS` env, or an unresolved (empty) active model — so a
36
+ * stale-but-valid corpus is never destroyed without a replacement. MUST run
37
+ * inside the active runtime-options scope so `currentEmbeddingModel()` /
38
+ * `embeddingsDisabled()` reflect the per-instance configuration.
39
+ */
40
+ export declare function reconcileEmbeddingModel(beam: BeamMemoryState): void;
21
41
  export declare function remember(beam: BeamMemoryState, content: string, options?: StoreRememberOptions): string;
22
42
  export declare function rememberBatch(beam: BeamMemoryState, items: readonly RememberBatchItem[], options?: StoreRememberBatchOptions): string[];
23
43
  export declare function getContext(beam: BeamMemoryState, limit?: number): Row[];
@@ -19,11 +19,12 @@ type LocalModelInitOptions = {
19
19
  showDownloadProgress?: boolean;
20
20
  };
21
21
  type LocalModelInitializer = (options: LocalModelInitOptions) => Promise<LocalEmbeddingModel>;
22
+ export declare function embeddingsDisabled(): boolean;
22
23
  /**
23
24
  * Resolve the embedding model name for the currently active runtime scope.
24
25
  *
25
26
  * Reads (in order): the active provider's `model` from `withMnemopiRuntimeOptions`,
26
- * the `PROMETHEUS_MEMORY_EMBEDDING_MODEL` env var, then the bundled fastembed default. Stored
27
+ * the `MNEMOPROMETHEUS_EMBEDDING_MODEL` env var, then the bundled fastembed default. Stored
27
28
  * alongside each row in `memory_embeddings.model` so migrations can re-embed when
28
29
  * the active model changes.
29
30
  */
@@ -1,3 +1,4 @@
1
+ import { type ApiKey, type FetchImpl } from "@prometheus-ai/ai";
1
2
  export declare const DEFAULT_EXTRACTION_MODEL: string;
2
3
  export declare const OPENROUTER_BASE_URL: string;
3
4
  export declare const FALLBACK_MODELS: readonly ["google/gemini-flash-latest"];
@@ -14,18 +15,21 @@ export interface ExtractedFact {
14
15
  confidence?: number;
15
16
  [key: string]: unknown;
16
17
  }
18
+ export interface ExtractionClientOptions {
19
+ model?: string | null;
20
+ apiKey?: ApiKey | null;
21
+ baseUrl?: string | null;
22
+ fetch?: FetchImpl;
23
+ }
17
24
  export declare class ExtractionClient {
18
25
  model: string;
19
- apiKey: string;
26
+ apiKey: ApiKey;
20
27
  baseUrl: string;
21
28
  callCount: number;
22
- constructor(opts?: {
23
- model?: string | null;
24
- apiKey?: string | null;
25
- baseUrl?: string | null;
26
- });
29
+ private readonly fetchImpl;
30
+ constructor(opts?: ExtractionClientOptions);
27
31
  chat(messages: readonly ChatMessage[], temperature?: number, maxTokens?: number): Promise<string>;
28
- callApi(model: string, messages: readonly ChatMessage[], temperature: number, maxTokens: number): Promise<string>;
32
+ callApi(model: string, messages: readonly ChatMessage[], temperature: number, maxTokens: number, apiKey?: string): Promise<string>;
29
33
  extractFacts(messages: readonly ChatMessage[]): Promise<ExtractedFact[]>;
30
34
  xtractFacts(messages: readonly ChatMessage[]): Promise<ExtractedFact[]>;
31
35
  }
@@ -1,6 +1,7 @@
1
+ import { type RemoteLlmOptions } from "./local-llm";
1
2
  export declare const EXTRACTION_PROMPT_TEMPLATE: string;
2
3
  export declare function buildExtractionPrompt(text: string, detectedLang?: string): string;
3
4
  export declare function parseFacts(rawOutput: string | null | undefined): string[];
4
5
  export declare function heuristicExtractFacts(text: string): string[];
5
- export declare function extractFacts(text: string | null | undefined): Promise<string[]>;
6
+ export declare function extractFacts(text: string | null | undefined, options?: RemoteLlmOptions): Promise<string[]>;
6
7
  export declare function extractFactsSafe(text: string | null | undefined): Promise<string[]>;
@@ -0,0 +1,4 @@
1
+ import type * as Fastembed from "fastembed";
2
+ type FastembedModule = typeof Fastembed;
3
+ export declare function loadFastembed(): Promise<FastembedModule>;
4
+ export {};
@@ -1,3 +1,4 @@
1
+ export { configureRecallFeatures, type RecallFeatureFlags } from "../config";
1
2
  export * from "./banks";
2
3
  export * from "./beam/index";
3
4
  export * from "./memory";
@@ -1,9 +1,11 @@
1
+ import type { FetchImpl } from "@prometheus-ai/ai";
1
2
  export interface CompleteOptions {
2
3
  maxTokens?: number;
3
4
  temperature?: number;
4
5
  timeout?: number;
5
6
  provider?: string | null;
6
7
  model?: string | null;
8
+ fetch?: FetchImpl;
7
9
  }
8
10
  export interface LlmBackend {
9
11
  name?: string;
@@ -1,4 +1,9 @@
1
+ import { type FetchImpl } from "@prometheus-ai/ai";
2
+ import { type CompleteOptions } from "./llm-backends";
1
3
  import { type MnemopiLlmCompleteOptions } from "./runtime-options";
4
+ export interface RemoteLlmOptions {
5
+ fetch?: FetchImpl;
6
+ }
2
7
  export declare const DEFAULT_MODEL_REPO: string;
3
8
  export declare const DEFAULT_MODEL_FILE: string;
4
9
  export declare function buildPrompt(memories: readonly string[], source?: string): string;
@@ -8,8 +13,8 @@ export declare function configuredLlmWillHandleCall(): boolean;
8
13
  export declare function cleanOutput(text: string): string;
9
14
  export declare function chunkMemoriesByBudget(memories: readonly string[], source?: string): string[][];
10
15
  export declare function llmAvailable(): boolean;
11
- export declare function callRemoteLlm(prompt: string, temperature?: number): Promise<string | null>;
16
+ export declare function callRemoteLlm(prompt: string, temperature?: number, options?: RemoteLlmOptions): Promise<string | null>;
12
17
  export declare function localGgufAvailable(): false;
13
18
  export declare function callLocalLlm(_prompt: string): Promise<string | null>;
14
- export declare function summarizeMemories(memories: readonly string[], source?: string): Promise<string | null>;
15
- export declare function complete(prompt: string, temperature?: number): Promise<string | null>;
19
+ export declare function summarizeMemories(memories: readonly string[], source?: string, options?: RemoteLlmOptions): Promise<string | null>;
20
+ export declare function complete(prompt: string, temperature?: number, options?: CompleteOptions): Promise<string | null>;
@@ -1,5 +1,5 @@
1
1
  import type { Database } from "bun:sqlite";
2
- import type { Api, Model } from "@prometheus-ai/ai";
2
+ import type { Api, ApiKey, Model } from "@prometheus-ai/ai";
3
3
  import type { MemoryInput, Metadata } from "../types";
4
4
  import { BeamMemory } from "./beam/index";
5
5
  import type { RecallEnhancedOptions, RecallOptions, RecallResult, SleepResult } from "./beam/types";
@@ -20,13 +20,22 @@ export interface MnemopiOptions {
20
20
  readonly noEmbeddings?: boolean;
21
21
  readonly embeddingModel?: string;
22
22
  readonly embeddingApiUrl?: string;
23
- readonly embeddingApiKey?: string;
23
+ readonly embeddingApiKey?: ApiKey;
24
24
  readonly embeddings?: false | MnemopiEmbeddingRuntimeOptions;
25
25
  readonly llmEnabled?: boolean;
26
26
  readonly llmBaseUrl?: string;
27
- readonly llmApiKey?: string;
27
+ readonly llmApiKey?: ApiKey;
28
28
  readonly llmModel?: string | Model<Api>;
29
29
  readonly llm?: false | MnemopiLlmRuntimeOptions | Model<Api> | MnemopiLlmCompletion;
30
+ /** Escalate best-effort failure logs (embedding pipeline) from debug to warn. */
31
+ readonly debug?: boolean;
32
+ /**
33
+ * When `false`, skip the embedding-model reconcile (wipe-and-rebuild) on open.
34
+ * Read-only / ephemeral consumers (e.g. a stats snapshot) set this so an open
35
+ * never triggers a destructive migration whose background rebuild the process
36
+ * would exit before completing. Defaults to `true`.
37
+ */
38
+ readonly reconcile?: boolean;
30
39
  }
31
40
  export interface RememberInput extends MemoryInput {
32
41
  readonly extract?: boolean;
@@ -1,3 +1,4 @@
1
+ import { type Env } from "../config";
1
2
  export type QueryCacheResult = Record<string, unknown>;
2
3
  export type QueryEmbedding = readonly number[];
3
4
  export interface QueryCacheOptions {
@@ -20,7 +21,6 @@ export interface QueryCacheStats {
20
21
  readonly max_size: number;
21
22
  readonly version: number;
22
23
  }
23
- type Env = Readonly<Record<string, string | undefined>>;
24
24
  export declare function isEnhancedRecallEnabled(env?: Env): boolean;
25
25
  export declare function isQueryCacheEnabled(useCache?: boolean, env?: Env): boolean;
26
26
  export declare class QueryCache {
@@ -43,4 +43,3 @@ export declare class QueryCache {
43
43
  normalize(query: string): string;
44
44
  jaccardWords(queryA: string, queryB: string): number;
45
45
  }
46
- export {};
@@ -1,4 +1,4 @@
1
- import type { Api, Model } from "@prometheus-ai/ai";
1
+ import type { Api, ApiKey, Model } from "@prometheus-ai/ai";
2
2
  export interface MnemopiLlmCompleteOptions {
3
3
  maxTokens?: number;
4
4
  temperature?: number;
@@ -22,13 +22,13 @@ export interface MnemopiEmbeddingRuntimeOptions {
22
22
  disabled?: boolean;
23
23
  model?: string;
24
24
  apiUrl?: string;
25
- apiKey?: string;
25
+ apiKey?: ApiKey;
26
26
  provider?: MnemopiEmbeddingProvider | ((texts: readonly string[]) => EmbeddingOutput | Promise<EmbeddingOutput>);
27
27
  }
28
28
  export interface MnemopiLlmRuntimeOptions {
29
29
  enabled?: boolean;
30
30
  baseUrl?: string;
31
- apiKey?: string;
31
+ apiKey?: ApiKey;
32
32
  model?: string | Model<Api>;
33
33
  maxTokens?: number;
34
34
  complete?: MnemopiLlmCompletion;
@@ -40,18 +40,20 @@ export interface MnemopiLlmRuntimeOptions {
40
40
  export interface MnemopiRuntimeOptions {
41
41
  embeddings?: false | MnemopiEmbeddingRuntimeOptions;
42
42
  llm?: false | MnemopiLlmRuntimeOptions | Model<Api> | MnemopiLlmCompletion;
43
+ /** Verbose diagnostics: escalates best-effort failure logs from debug to warn. */
44
+ debug?: boolean;
43
45
  }
44
46
  export interface ResolvedMnemopiEmbeddingRuntimeOptions {
45
47
  disabled?: boolean;
46
48
  model?: string;
47
49
  apiUrl?: string;
48
- apiKey?: string;
50
+ apiKey?: ApiKey;
49
51
  provider?: MnemopiEmbeddingProvider;
50
52
  }
51
53
  export interface ResolvedMnemopiLlmRuntimeOptions {
52
54
  enabled?: boolean;
53
55
  baseUrl?: string;
54
- apiKey?: string;
56
+ apiKey?: ApiKey;
55
57
  model?: string | Model<Api>;
56
58
  maxTokens?: number;
57
59
  complete?: MnemopiLlmCompletion;
@@ -61,8 +63,11 @@ export interface ResolvedMnemopiLlmRuntimeOptions {
61
63
  export interface ResolvedMnemopiRuntimeOptions {
62
64
  embeddings?: ResolvedMnemopiEmbeddingRuntimeOptions;
63
65
  llm?: ResolvedMnemopiLlmRuntimeOptions;
66
+ debug?: boolean;
64
67
  }
65
68
  export declare function withMnemopiRuntimeOptions<T>(options: ResolvedMnemopiRuntimeOptions | undefined, fn: () => T): T;
66
69
  export declare function getMnemopiRuntimeOptions(): ResolvedMnemopiRuntimeOptions | undefined;
70
+ /** Whether the active runtime scope requested verbose diagnostics (`mnemopi.debug`). */
71
+ export declare function mnemopiDebugEnabled(): boolean;
67
72
  export declare function resolveEmbeddingProvider(provider: MnemopiEmbeddingProvider | ((texts: readonly string[]) => EmbeddingOutput | Promise<EmbeddingOutput>) | undefined): MnemopiEmbeddingProvider | undefined;
68
73
  export declare function isPiAiModel(value: unknown): value is Model<Api>;
@@ -44,13 +44,19 @@ type BeamLike = {
44
44
  };
45
45
  export declare const FACTS_SCHEMA_SQL = "\nCREATE TABLE IF NOT EXISTS harmonic_beliefs (\n\tbelief_id TEXT PRIMARY KEY,\n\tsubject TEXT,\n\tpredicate TEXT,\n\tobject TEXT NOT NULL,\n\tconfidence REAL DEFAULT 0.5,\n\tprovenance TEXT,\n\tcluster_id TEXT,\n\titeration INTEGER DEFAULT 0,\n\tcreated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n\tupdated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n);\nCREATE TABLE IF NOT EXISTS memory_resonance_log (\n\tid INTEGER PRIMARY KEY AUTOINCREMENT,\n\tsession_id TEXT,\n\tcluster_count INTEGER,\n\tbeliefs_generated INTEGER,\n\tcontradictions_resolved INTEGER,\n\tharmony_score_avg REAL,\n\tduration_ms INTEGER,\n\tcreated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n);\nCREATE INDEX IF NOT EXISTS idx_beliefs_subject ON harmonic_beliefs(subject);\nCREATE INDEX IF NOT EXISTS idx_beliefs_predicate ON harmonic_beliefs(predicate);\nCREATE INDEX IF NOT EXISTS idx_beliefs_confidence ON harmonic_beliefs(confidence);\n";
46
46
  export declare function initSchema(db: Database): void;
47
- export declare function embed(text: string): Vector;
48
- export declare function clusterBySimilarity(items: readonly ShmrItem[], threshold: number): ShmrItem[][];
47
+ /**
48
+ * Embed a batch of texts with the configured embedding provider. Falls back to the
49
+ * deterministic SHA1 bag-of-words hash for the entire batch when no provider is
50
+ * available or the provider fails, so every returned vector shares one space.
51
+ */
52
+ export declare function embedBatch(texts: readonly string[]): Promise<Vector[]>;
53
+ export declare function embed(text: string): Promise<Vector>;
54
+ export declare function clusterBySimilarity(items: readonly ShmrItem[], threshold: number): Promise<ShmrItem[][]>;
49
55
  export declare function formatClusterForLlm(cluster: readonly ShmrItem[]): string;
50
56
  export declare function extractJsonFromLlmOutput(text: string): Belief[];
51
- export declare function computeHarmonyScore(beliefs: readonly Belief[], cluster: readonly ShmrItem[]): number;
57
+ export declare function computeHarmonyScore(beliefs: readonly Belief[], cluster: readonly ShmrItem[]): Promise<number>;
52
58
  export declare function applyBeliefs(db: Database, beliefs: readonly Belief[], cluster: readonly ShmrItem[], clusterId: string): void;
53
- export declare function harmonize(beam: BeamLike, batchSize?: number, maxIterations?: number, similarityThreshold?: number): HarmonizeStats;
54
- export declare function recallBeliefs(beam: BeamLike, query: string, topK?: number): Array<Record<string, unknown>>;
59
+ export declare function harmonize(beam: BeamLike, batchSize?: number, maxIterations?: number, similarityThreshold?: number): Promise<HarmonizeStats>;
60
+ export declare function recallBeliefs(beam: BeamLike, query: string, topK?: number): Promise<Array<Record<string, unknown>>>;
55
61
  export declare function reflect(_beam: BeamLike | null, _question: string, facts?: Array<Record<string, unknown>> | null, topK?: number): string | null;
56
62
  export declare function getResonanceLog(beam: BeamLike, limit?: number): Array<Record<string, unknown>>;
@@ -0,0 +1,16 @@
1
+ export interface ExactVectorSearchHit<TId> {
2
+ id: TId;
3
+ score: number;
4
+ }
5
+ export interface ExactVectorIndex<TId> {
6
+ readonly ids: readonly TId[];
7
+ readonly matrix: Float32Array;
8
+ readonly dimensions: number;
9
+ readonly count: number;
10
+ }
11
+ export interface VectorIndexRow<TId> {
12
+ id: TId;
13
+ vector: readonly number[] | null | undefined;
14
+ }
15
+ export declare function buildExactVectorIndex<TId>(rows: readonly VectorIndexRow<TId>[]): ExactVectorIndex<TId>;
16
+ export declare function searchExactVectorIndex<TId>(index: ExactVectorIndex<TId>, query: readonly number[], limit: number): ExactVectorSearchHit<TId>[];
@@ -1,5 +1,6 @@
1
+ export { configureRecallFeatures, type RecallFeatureFlags } from "./config";
1
2
  export * from "./core/beam/index";
2
3
  export * from "./core/embeddings";
3
4
  export * from "./core/llm-backends";
4
5
  export * from "./core/memory";
5
- export { addMemory, flushExtractions, forget, get, getBank, getContext, getDefaultInstance, getStats, Mnemopi, Mnemopi as PrometheusMemory, query, recall, recallEnhanced, remember, resetDefaultInstanceForTests, resetMemoryForTests, resetModuleStateForTests, saveMemory, scratchpadClear, scratchpadRead, scratchpadWrite, search, setBank, sleep, sleepAllSessions, storeMemory, update, } from "./core/memory";
6
+ export { addMemory, flushExtractions, forget, get, getBank, getContext, getDefaultInstance, getStats, Mnemopi, query, recall, recallEnhanced, remember, resetDefaultInstanceForTests, resetMemoryForTests, resetModuleStateForTests, saveMemory, scratchpadClear, scratchpadRead, scratchpadWrite, search, setBank, sleep, sleepAllSessions, storeMemory, update, } from "./core/memory";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@prometheus-ai/memory",
4
- "version": "0.5.4",
4
+ "version": "0.5.8",
5
5
  "description": "Local SQLite memory engine for Prometheus agents",
6
6
  "homepage": "https://prometheus.trivlab.com",
7
7
  "author": "Uttam Trivedi",
@@ -36,14 +36,27 @@
36
36
  "fmt": "biome format --write ."
37
37
  },
38
38
  "dependencies": {
39
- "@prometheus-ai/ai": "0.5.4",
40
- "@prometheus-ai/utils": "0.5.4",
39
+ "@prometheus-ai/ai": "0.5.8",
40
+ "@prometheus-ai/catalog": "0.5.8",
41
+ "@prometheus-ai/utils": "0.5.8",
42
+ "lru-cache": "11.5.1"
43
+ },
44
+ "peerDependencies": {
41
45
  "fastembed": "2.1.0",
42
- "lru-cache": "11.5.1",
43
- "onnxruntime-node": "1.24.3"
46
+ "onnxruntime-node": "1.26.0"
47
+ },
48
+ "peerDependenciesMeta": {
49
+ "fastembed": {
50
+ "optional": true
51
+ },
52
+ "onnxruntime-node": {
53
+ "optional": true
54
+ }
44
55
  },
45
56
  "devDependencies": {
46
- "@types/bun": "^1.3.14"
57
+ "@types/bun": "^1.3.14",
58
+ "fastembed": "2.1.0",
59
+ "onnxruntime-node": "1.26.0"
47
60
  },
48
61
  "engines": {
49
62
  "bun": ">=1.3.14"
@@ -51,6 +64,7 @@
51
64
  "files": [
52
65
  "src",
53
66
  "README.md",
67
+ "CHANGELOG.md",
54
68
  "dist/types"
55
69
  ],
56
70
  "exports": {
@@ -62,6 +76,10 @@
62
76
  "types": "./dist/types/core/index.d.ts",
63
77
  "import": "./src/core/index.ts"
64
78
  },
79
+ "./core/beam": {
80
+ "types": "./dist/types/core/beam/index.d.ts",
81
+ "import": "./src/core/beam/index.ts"
82
+ },
65
83
  "./beam": {
66
84
  "types": "./dist/types/core/beam/index.d.ts",
67
85
  "import": "./src/core/beam/index.ts"
@@ -77,6 +95,11 @@
77
95
  "./cli": {
78
96
  "types": "./dist/types/cli.d.ts",
79
97
  "import": "./src/cli.ts"
80
- }
98
+ },
99
+ "./*": {
100
+ "types": "./dist/types/*.d.ts",
101
+ "import": "./src/*.ts"
102
+ },
103
+ "./*.js": "./src/*.ts"
81
104
  }
82
105
  }
package/src/cli.ts CHANGED
@@ -68,7 +68,7 @@ function resolveDataDir(context?: CliContext): string {
68
68
  }
69
69
 
70
70
  function resolveDbPath(context?: CliContext): string {
71
- return context?.dbPath ?? (context?.dataDir ? join(context.dataDir, "prometheus-memory.db") : configuredDbPath());
71
+ return context?.dbPath ?? (context?.dataDir ? join(context.dataDir, "mnemopi.db") : configuredDbPath());
72
72
  }
73
73
 
74
74
  function getMemory(context?: CliContext): { memory: BeamMemory; owned: boolean } {
@@ -82,7 +82,7 @@ async function withMemory<T>(context: CliContext | undefined, fn: (memory: BeamM
82
82
  try {
83
83
  const result = await fn(memory);
84
84
  // Drain background fact-extraction and embedding tasks before close so
85
- // short-lived owners (e.g. `prometheus-memory store …` / `prometheus-memory sleep …`) don't
85
+ // short-lived owners (e.g. `mnemopi store …` / `mnemopi sleep …`) don't
86
86
  // race the SQLite handle shut from under in-flight `embed()` writes.
87
87
  if (owned) await memory.flushExtractions();
88
88
  return result;
@@ -130,7 +130,7 @@ function formatImportStats(stats: ImportStats): string {
130
130
  }
131
131
 
132
132
  export const cmdExport: CommandHandler = (args, context) => {
133
- if (args.length === 0) usage("Usage: prometheus-memory export <file.json>");
133
+ if (args.length === 0) usage("Usage: mnemopi export <file.json>");
134
134
  const outputPath = args[0] ?? "";
135
135
  return withMemory(context, memory => {
136
136
  mkdirSync(dirname(outputPath), { recursive: true });
@@ -149,7 +149,7 @@ export const cmdExport: CommandHandler = (args, context) => {
149
149
  };
150
150
 
151
151
  export const cmdImport: CommandHandler = (args, context) => {
152
- if (args.length === 0) usage("Usage: prometheus-memory import <file.json>");
152
+ if (args.length === 0) usage("Usage: mnemopi import <file.json>");
153
153
  const inputPath = args[0] ?? "";
154
154
  if (!existsSync(inputPath)) fail(`Import file not found: ${inputPath}`, 1);
155
155
  let parsed: unknown;
@@ -160,7 +160,7 @@ export const cmdImport: CommandHandler = (args, context) => {
160
160
  throw error;
161
161
  }
162
162
  if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
163
- fail("Import file must contain a Prometheus Memory export object", 1);
163
+ fail("Import file must contain a Mnemopi export object", 1);
164
164
  return withMemory(context, memory => {
165
165
  const stats = memory.importFromDict(parsed as Record<string, unknown>);
166
166
  out(context, `Imported ${formatImportStats(stats)} from ${inputPath}`);
@@ -174,7 +174,7 @@ export const cmdMcp: CommandHandler = async args => {
174
174
  };
175
175
 
176
176
  export const cmdRemember: CommandHandler = (args, context) => {
177
- if (args.length === 0) usage("Usage: prometheus-memory store <content> [source] [importance]");
177
+ if (args.length === 0) usage("Usage: mnemopi store <content> [source] [importance]");
178
178
  const content = args[0] ?? "";
179
179
  const source = args[1] ?? "cli";
180
180
  const importance = args[2] === undefined ? 0.5 : parseFloatArg(args[2], "importance");
@@ -186,7 +186,7 @@ export const cmdRemember: CommandHandler = (args, context) => {
186
186
  };
187
187
 
188
188
  export const cmdRecall: CommandHandler = async (args, context) => {
189
- if (args.length === 0) usage("Usage: prometheus-memory recall <query> [top_k]");
189
+ if (args.length === 0) usage("Usage: mnemopi recall <query> [top_k]");
190
190
  const query = args[0] ?? "";
191
191
  const topK = args[1] === undefined ? 5 : parseIntArg(args[1], "top_k");
192
192
  const { memory, owned } = getMemory(context);
@@ -209,7 +209,7 @@ export const cmdRecall: CommandHandler = async (args, context) => {
209
209
  };
210
210
 
211
211
  export const cmdUpdate: CommandHandler = (args, context) => {
212
- if (args.length < 2) usage("Usage: prometheus-memory update <memory_id> <new_content> [importance]");
212
+ if (args.length < 2) usage("Usage: mnemopi update <memory_id> <new_content> [importance]");
213
213
  const memoryId = args[0] ?? "";
214
214
  const content = args[1] ?? "";
215
215
  const importance = args[2] === undefined ? null : parseFloatArg(args[2], "importance");
@@ -221,7 +221,7 @@ export const cmdUpdate: CommandHandler = (args, context) => {
221
221
  };
222
222
 
223
223
  export const cmdDelete: CommandHandler = (args, context) => {
224
- if (args.length === 0) usage("Usage: prometheus-memory delete <memory_id>");
224
+ if (args.length === 0) usage("Usage: mnemopi delete <memory_id>");
225
225
  const memoryId = args[0] ?? "";
226
226
  return withMemory(context, memory => {
227
227
  if (!memory.forgetWorking(memoryId)) fail(`Memory not found: ${memoryId}`, 1);
@@ -237,7 +237,7 @@ export const cmdStats: CommandHandler = (_args, context) =>
237
237
  const wm = beam.working_memory ?? {};
238
238
  const ep = beam.episodic_memory ?? {};
239
239
  const triples = beam.triples ?? {};
240
- out(context, "\nPrometheus Memory Stats\n");
240
+ out(context, "\nMnemopi Stats\n");
241
241
  out(context, ` Total memories: ${asCount(stats.total_memories)}`);
242
242
  out(context, ` Working memory: ${asCount(wm.total)}`);
243
243
  out(context, ` Episodic memory: ${asCount(ep.total)}`);
@@ -256,7 +256,7 @@ export const cmdSleep: CommandHandler = (_args, context) =>
256
256
  });
257
257
 
258
258
  export const cmdScratchpad: CommandHandler = (args, context) => {
259
- if (args.length === 0) usage("Usage: prometheus-memory scratchpad <read|write|clear> [content]");
259
+ if (args.length === 0) usage("Usage: mnemopi scratchpad <read|write|clear> [content]");
260
260
  const subcmd = args[0];
261
261
  return withMemory(context, memory => {
262
262
  if (subcmd === "read") {
@@ -267,7 +267,7 @@ export const cmdScratchpad: CommandHandler = (args, context) => {
267
267
  return 0;
268
268
  }
269
269
  if (subcmd === "write") {
270
- if (args.length < 2) usage("Usage: prometheus-memory scratchpad write <content>");
270
+ if (args.length < 2) usage("Usage: mnemopi scratchpad write <content>");
271
271
  const id = memory.scratchpadWrite(args[1] ?? "");
272
272
  out(context, `Scratchpad stored: ${id}`);
273
273
  return 0;
@@ -282,7 +282,7 @@ export const cmdScratchpad: CommandHandler = (args, context) => {
282
282
  };
283
283
 
284
284
  export const cmdBank: CommandHandler = (args, context) => {
285
- if (args.length === 0) usage("Usage: prometheus-memory bank <list|create|delete> [name]");
285
+ if (args.length === 0) usage("Usage: mnemopi bank <list|create|delete> [name]");
286
286
  const manager = new BankManager(resolveDataDir(context));
287
287
  const subcmd = args[0];
288
288
  try {
@@ -292,14 +292,14 @@ export const cmdBank: CommandHandler = (args, context) => {
292
292
  return 0;
293
293
  }
294
294
  if (subcmd === "create") {
295
- if (args.length < 2) fail("Usage: prometheus-memory bank create <name>");
295
+ if (args.length < 2) fail("Usage: mnemopi bank create <name>");
296
296
  const name = args[1] ?? "";
297
297
  manager.createBank(name);
298
298
  out(context, `Created bank: ${name}`);
299
299
  return 0;
300
300
  }
301
301
  if (subcmd === "delete") {
302
- if (args.length < 2) fail("Usage: prometheus-memory bank delete <name>");
302
+ if (args.length < 2) fail("Usage: mnemopi bank delete <name>");
303
303
  const name = args[1] ?? "";
304
304
  if (!manager.deleteBank(name)) fail(`Bank not found: ${name}`, 1);
305
305
  out(context, `Deleted bank: ${name}`);
@@ -318,7 +318,7 @@ export const cmdDiagnose: CommandHandler = (_args, context) => {
318
318
  dbPath: resolveDbPath(context),
319
319
  dataDir: resolveDataDir(context),
320
320
  });
321
- out(context, "\nPrometheus Memory Diagnostics\n");
321
+ out(context, "\nMnemopi Diagnostics\n");
322
322
  out(context, ` Checks passed: ${result.checks_passed}/${result.checks_total}`);
323
323
  if (result.key_findings.length > 0) {
324
324
  out(context, "\n Key findings:");
@@ -352,8 +352,8 @@ export const COMMANDS: Readonly<Record<string, CommandHandler>> = {
352
352
  };
353
353
 
354
354
  export function printHelp(context?: CliContext): void {
355
- out(context, "Prometheus Memory - Local AI Memory System\n");
356
- out(context, "Usage: prometheus-memory <command> [args]\n");
355
+ out(context, "Mnemopi - Local AI Memory System\n");
356
+ out(context, "Usage: mnemopi <command> [args]\n");
357
357
  out(context, "Commands:");
358
358
  out(context, " store <content> [source] [importance] Store a memory");
359
359
  out(context, " recall <query> [top_k] Search memories");
@@ -378,7 +378,7 @@ export async function runCli(args: readonly string[] = Bun.argv.slice(2), contex
378
378
  const handler = COMMANDS[command];
379
379
  if (!handler) {
380
380
  err(context, `Unknown command: ${command}`);
381
- err(context, "Run 'prometheus-memory --help' for usage.");
381
+ err(context, "Run 'mnemopi --help' for usage.");
382
382
  return 2;
383
383
  }
384
384
  try {