@getplumb/core 0.4.3 → 0.4.5

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 (44) hide show
  1. package/dist/chunker.d.ts +2 -27
  2. package/dist/chunker.d.ts.map +1 -1
  3. package/dist/chunker.js +2 -36
  4. package/dist/chunker.js.map +1 -1
  5. package/dist/context-builder.d.ts +18 -6
  6. package/dist/context-builder.d.ts.map +1 -1
  7. package/dist/context-builder.js +48 -24
  8. package/dist/context-builder.js.map +1 -1
  9. package/dist/embedder.d.ts.map +1 -1
  10. package/dist/embedder.js +6 -0
  11. package/dist/embedder.js.map +1 -1
  12. package/dist/index.d.ts +4 -8
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +1 -3
  15. package/dist/index.js.map +1 -1
  16. package/dist/local-store.d.ts +24 -31
  17. package/dist/local-store.d.ts.map +1 -1
  18. package/dist/local-store.js +81 -331
  19. package/dist/local-store.js.map +1 -1
  20. package/dist/memory-facts-search.d.ts +33 -0
  21. package/dist/memory-facts-search.d.ts.map +1 -0
  22. package/dist/memory-facts-search.js +143 -0
  23. package/dist/memory-facts-search.js.map +1 -0
  24. package/dist/read-path.d.ts +22 -13
  25. package/dist/read-path.d.ts.map +1 -1
  26. package/dist/read-path.js +19 -15
  27. package/dist/read-path.js.map +1 -1
  28. package/dist/schema.d.ts +13 -8
  29. package/dist/schema.d.ts.map +1 -1
  30. package/dist/schema.js +63 -83
  31. package/dist/schema.js.map +1 -1
  32. package/dist/scorer.d.ts +12 -10
  33. package/dist/scorer.d.ts.map +1 -1
  34. package/dist/scorer.js +13 -10
  35. package/dist/scorer.js.map +1 -1
  36. package/dist/store.d.ts +1 -6
  37. package/dist/store.d.ts.map +1 -1
  38. package/dist/types.d.ts +27 -1
  39. package/dist/types.d.ts.map +1 -1
  40. package/dist/wasm-db.d.ts +17 -20
  41. package/dist/wasm-db.d.ts.map +1 -1
  42. package/dist/wasm-db.js +51 -56
  43. package/dist/wasm-db.js.map +1 -1
  44. package/package.json +5 -6
package/dist/chunker.d.ts CHANGED
@@ -1,35 +1,10 @@
1
1
  /**
2
- * Chunker — splits a MessageExchange into overlapping text chunks for indexing.
3
- *
4
- * Design (T-004):
5
- * - Each exchange is formatted as "User: {msg}\nAgent: {response}"
6
- * - Short exchanges (≤ CHUNK_WORDS words) produce one chunk
7
- * - Long exchanges are split with OVERLAP_WORDS word overlap to preserve
8
- * context at chunk boundaries
9
- *
10
- * Word-based splitting is used (not token-based) to avoid a tokenizer
11
- * dependency at ingest time. At 384-dim bge-small, 300 words ≈ 400 tokens
12
- * which is within the model's 512-token limit.
2
+ * Chunker — exchange formatting for indexing.
13
3
  */
14
4
  import type { MessageExchange } from './types.js';
15
- export declare const CHUNK_WORDS = 300;
16
- export declare const OVERLAP_WORDS = 50;
17
- export interface Chunk {
18
- /** Full formatted text of this chunk. */
19
- readonly text: string;
20
- /** 0-based index within this exchange's chunk sequence. */
21
- readonly chunkIndex: number;
22
- /** Total chunks produced from this exchange. */
23
- readonly totalChunks: number;
24
- }
25
5
  /**
26
6
  * Format a MessageExchange into its canonical chunk text.
27
- * Used both by the chunker and by ingest() for the stored chunk_text column.
7
+ * Used by ingest() for the stored chunk_text column.
28
8
  */
29
9
  export declare function formatExchange(exchange: MessageExchange): string;
30
- /**
31
- * Split a MessageExchange into one or more overlapping text chunks.
32
- * Returns at least one chunk (even for empty exchanges).
33
- */
34
- export declare function chunkExchange(exchange: MessageExchange): Chunk[];
35
10
  //# sourceMappingURL=chunker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chunker.d.ts","sourceRoot":"","sources":["../src/chunker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,eAAO,MAAM,WAAW,MAAM,CAAC;AAC/B,eAAO,MAAM,aAAa,KAAK,CAAC;AAEhC,MAAM,WAAW,KAAK;IACpB,yCAAyC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2DAA2D;IAC3D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,gDAAgD;IAChD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,CAEhE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,eAAe,GAAG,KAAK,EAAE,CAmBhE"}
1
+ {"version":3,"file":"chunker.d.ts","sourceRoot":"","sources":["../src/chunker.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,CAEhE"}
package/dist/chunker.js CHANGED
@@ -1,45 +1,11 @@
1
1
  /**
2
- * Chunker — splits a MessageExchange into overlapping text chunks for indexing.
3
- *
4
- * Design (T-004):
5
- * - Each exchange is formatted as "User: {msg}\nAgent: {response}"
6
- * - Short exchanges (≤ CHUNK_WORDS words) produce one chunk
7
- * - Long exchanges are split with OVERLAP_WORDS word overlap to preserve
8
- * context at chunk boundaries
9
- *
10
- * Word-based splitting is used (not token-based) to avoid a tokenizer
11
- * dependency at ingest time. At 384-dim bge-small, 300 words ≈ 400 tokens
12
- * which is within the model's 512-token limit.
2
+ * Chunker — exchange formatting for indexing.
13
3
  */
14
- export const CHUNK_WORDS = 300;
15
- export const OVERLAP_WORDS = 50;
16
4
  /**
17
5
  * Format a MessageExchange into its canonical chunk text.
18
- * Used both by the chunker and by ingest() for the stored chunk_text column.
6
+ * Used by ingest() for the stored chunk_text column.
19
7
  */
20
8
  export function formatExchange(exchange) {
21
9
  return `User: ${exchange.userMessage}\nAgent: ${exchange.agentResponse}`;
22
10
  }
23
- /**
24
- * Split a MessageExchange into one or more overlapping text chunks.
25
- * Returns at least one chunk (even for empty exchanges).
26
- */
27
- export function chunkExchange(exchange) {
28
- const text = formatExchange(exchange);
29
- const words = text.split(/\s+/).filter((w) => w.length > 0);
30
- if (words.length <= CHUNK_WORDS) {
31
- return [{ text, chunkIndex: 0, totalChunks: 1 }];
32
- }
33
- const chunks = [];
34
- let start = 0;
35
- while (start < words.length) {
36
- const end = Math.min(start + CHUNK_WORDS, words.length);
37
- chunks.push(words.slice(start, end).join(' '));
38
- if (end >= words.length)
39
- break;
40
- start += CHUNK_WORDS - OVERLAP_WORDS;
41
- }
42
- const totalChunks = chunks.length;
43
- return chunks.map((chunkText, chunkIndex) => ({ text: chunkText, chunkIndex, totalChunks }));
44
- }
45
11
  //# sourceMappingURL=chunker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chunker.js","sourceRoot":"","sources":["../src/chunker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAC;AAC/B,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC;AAWhC;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,QAAyB;IACtD,OAAO,SAAS,QAAQ,CAAC,WAAW,YAAY,QAAQ,CAAC,aAAa,EAAE,CAAC;AAC3E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,QAAyB;IACrD,MAAM,IAAI,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IACtC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE5D,IAAI,KAAK,CAAC,MAAM,IAAI,WAAW,EAAE,CAAC;QAChC,OAAO,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,OAAO,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QACxD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAC/C,IAAI,GAAG,IAAI,KAAK,CAAC,MAAM;YAAE,MAAM;QAC/B,KAAK,IAAI,WAAW,GAAG,aAAa,CAAC;IACvC,CAAC;IAED,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;IAClC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;AAC/F,CAAC"}
1
+ {"version":3,"file":"chunker.js","sourceRoot":"","sources":["../src/chunker.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,QAAyB;IACtD,OAAO,SAAS,QAAQ,CAAC,WAAW,YAAY,QAAQ,CAAC,aAAa,EAAE,CAAC;AAC3E,CAAC"}
@@ -1,17 +1,29 @@
1
1
  /**
2
- * Context builder — formats a MemoryContext into a [MEMORY CONTEXT] string
2
+ * Context builder — formats a MemoryContext into a [PLUMB MEMORY] string
3
3
  * suitable for injection into an agent's system prompt.
4
4
  *
5
5
  * Output format (example):
6
6
  *
7
- * [MEMORY CONTEXT]
7
+ * [PLUMB MEMORY]
8
8
  *
9
- * ## Related conversations
10
- * - [tech-planning] today: "Let me help you design the memory system..."
9
+ * ## Remembered facts
10
+ * [HIGH] [tech-planning] today: "User prefers TypeScript for all new code"
11
+ * [MED] [plumb-dev] 3 days ago: "Plumb uses BM25 + vector KNN..."
11
12
  *
12
- * Empty MemoryContext returns an empty string no block is injected.
13
+ * Tier labels: [HIGH] = strong match (treat as fact), [MED] = likely, [LOW] = hint.
14
+ * Always includes a tool hint section. Returns empty string only when
15
+ * relatedMemories is empty.
13
16
  */
14
17
  import type { MemoryContext } from './read-path.js';
18
+ /**
19
+ * Maps a boosted memory fact score to a display tier label.
20
+ * Thresholds are calibrated for RRF hybrid scores (BM25 + vector KNN) after
21
+ * MEMORY_FACT_BOOST (2.0×) is applied. Observed boosted score range: 0.044–0.066.
22
+ * [HIGH] ≥ 0.062 — top ~10%: strong match, treat as ground truth
23
+ * [MED] 0.054–0.062 — middle band: likely relevant
24
+ * [LOW] < 0.054 — bottom half: weak signal, treat as hint
25
+ */
26
+ export declare function scoreFactTier(boostedScore: number): '[HIGH]' | '[MED] ' | '[LOW] ';
15
27
  /**
16
28
  * Converts an age in fractional days to a human-readable string.
17
29
  * Examples: 'today', 'yesterday', '3 days ago', '2 weeks ago', '1 month ago'.
@@ -21,7 +33,7 @@ export declare function formatAge(ageInDays: number): string;
21
33
  * Formats a MemoryContext into a [MEMORY CONTEXT] prompt block.
22
34
  *
23
35
  * Always returns a non-empty string with a tool hint section,
24
- * even when there are no related conversations.
36
+ * even when there are no related memories.
25
37
  */
26
38
  export declare function formatContextBlock(context: MemoryContext): string;
27
39
  //# sourceMappingURL=context-builder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-builder.d.ts","sourceRoot":"","sources":["../src/context-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,gBAAgB,CAAC;AAI9D;;;GAGG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAUnD;AAcD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAsBjE"}
1
+ {"version":3,"file":"context-builder.d.ts","sourceRoot":"","sources":["../src/context-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAmB,MAAM,gBAAgB,CAAC;AAIrE;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAIlF;AAID;;;GAGG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAUnD;AAeD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CA0BjE"}
@@ -1,16 +1,35 @@
1
1
  /**
2
- * Context builder — formats a MemoryContext into a [MEMORY CONTEXT] string
2
+ * Context builder — formats a MemoryContext into a [PLUMB MEMORY] string
3
3
  * suitable for injection into an agent's system prompt.
4
4
  *
5
5
  * Output format (example):
6
6
  *
7
- * [MEMORY CONTEXT]
7
+ * [PLUMB MEMORY]
8
8
  *
9
- * ## Related conversations
10
- * - [tech-planning] today: "Let me help you design the memory system..."
9
+ * ## Remembered facts
10
+ * [HIGH] [tech-planning] today: "User prefers TypeScript for all new code"
11
+ * [MED] [plumb-dev] 3 days ago: "Plumb uses BM25 + vector KNN..."
11
12
  *
12
- * Empty MemoryContext returns an empty string no block is injected.
13
+ * Tier labels: [HIGH] = strong match (treat as fact), [MED] = likely, [LOW] = hint.
14
+ * Always includes a tool hint section. Returns empty string only when
15
+ * relatedMemories is empty.
13
16
  */
17
+ // ─── Confidence tier helpers ──────────────────────────────────────────────────
18
+ /**
19
+ * Maps a boosted memory fact score to a display tier label.
20
+ * Thresholds are calibrated for RRF hybrid scores (BM25 + vector KNN) after
21
+ * MEMORY_FACT_BOOST (2.0×) is applied. Observed boosted score range: 0.044–0.066.
22
+ * [HIGH] ≥ 0.062 — top ~10%: strong match, treat as ground truth
23
+ * [MED] 0.054–0.062 — middle band: likely relevant
24
+ * [LOW] < 0.054 — bottom half: weak signal, treat as hint
25
+ */
26
+ export function scoreFactTier(boostedScore) {
27
+ if (boostedScore >= 0.062)
28
+ return '[HIGH]';
29
+ if (boostedScore >= 0.054)
30
+ return '[MED] ';
31
+ return '[LOW] ';
32
+ }
14
33
  // ─── Age formatting ───────────────────────────────────────────────────────────
15
34
  /**
16
35
  * Converts an age in fractional days to a human-readable string.
@@ -36,38 +55,43 @@ export function formatAge(ageInDays) {
36
55
  return `${Math.floor(ageInDays / 365)} years ago`;
37
56
  }
38
57
  // ─── Line formatters ──────────────────────────────────────────────────────────
39
- function formatChunkLine(chunk) {
40
- const excerpt = chunk.chunkText.slice(0, 200);
41
- const sessionLabel = chunk.sessionLabel ?? chunk.sessionId;
42
- const ageInDays = (Date.now() - chunk.timestamp.getTime()) / (1_000 * 60 * 60 * 24);
58
+ function formatMemoryLine(memory) {
59
+ const tier = scoreFactTier(memory.score);
60
+ const excerpt = memory.content.slice(0, 200);
61
+ const sessionLabel = memory.sourceSessionLabel ?? memory.sourceSessionId;
62
+ const ageInDays = (Date.now() - memory.timestamp.getTime()) / (1_000 * 60 * 60 * 24);
43
63
  const age = formatAge(ageInDays);
44
- return `- [${sessionLabel}] ${age}: "${excerpt}"`;
64
+ return `${tier} [${sessionLabel}] ${age}: "${excerpt}"`;
45
65
  }
46
66
  // ─── Public API ───────────────────────────────────────────────────────────────
47
67
  /**
48
68
  * Formats a MemoryContext into a [MEMORY CONTEXT] prompt block.
49
69
  *
50
70
  * Always returns a non-empty string with a tool hint section,
51
- * even when there are no related conversations.
71
+ * even when there are no related memories.
52
72
  */
53
73
  export function formatContextBlock(context) {
54
- const { relatedConversations } = context;
55
- const lines = ['[MEMORY CONTEXT]'];
56
- if (relatedConversations.length > 0) {
57
- // Show related conversations section
74
+ const { relatedMemories } = context;
75
+ const lines = ['[PLUMB MEMORY]'];
76
+ // ── Render ## Remembered facts section (memory_facts, Layer 2) ──────────
77
+ if (relatedMemories.length > 0) {
58
78
  lines.push('');
59
- lines.push('## Related conversations');
60
- for (const chunk of relatedConversations)
61
- lines.push(formatChunkLine(chunk));
62
- // Append tool hint
79
+ lines.push('## Remembered facts');
80
+ for (const memory of relatedMemories)
81
+ lines.push(formatMemoryLine(memory));
82
+ }
83
+ // ── Append tool hints ─────────────────────────────────────────────────────
84
+ if (relatedMemories.length > 0) {
63
85
  lines.push('');
64
- lines.push('## Memory search available');
65
- lines.push('Use the `plumb_search` tool to look up specific subtopics not covered above.');
86
+ lines.push('## Memory tools available');
87
+ lines.push('- `plumb_search` search for specific subtopics not covered above');
88
+ lines.push('- `plumb_remember` — store a new fact for future sessions');
66
89
  }
67
90
  else {
68
- // No related conversations - show only tool hint with alternate text
69
- lines.push('## Memory search available');
70
- lines.push('Use the `plumb_search` tool to look up relevant context from memory.');
91
+ // No memories show only tool hints with alternate text
92
+ lines.push('## Memory tools available');
93
+ lines.push('- `plumb_search` look up relevant context from memory');
94
+ lines.push('- `plumb_remember` — store a new fact for future sessions');
71
95
  }
72
96
  return lines.join('\n');
73
97
  }
@@ -1 +1 @@
1
- {"version":3,"file":"context-builder.js","sourceRoot":"","sources":["../src/context-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,iFAAiF;AAEjF;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,SAAiB;IACzC,IAAI,SAAS,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC;IAClC,IAAI,SAAS,GAAG,CAAC;QAAE,OAAO,WAAW,CAAC;IACtC,IAAI,SAAS,GAAG,CAAC;QAAE,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC;IAC9D,IAAI,SAAS,GAAG,EAAE;QAAE,OAAO,YAAY,CAAC;IACxC,IAAI,SAAS,GAAG,EAAE;QAAE,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,YAAY,CAAC;IACpE,IAAI,SAAS,GAAG,EAAE;QAAE,OAAO,aAAa,C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;IAED,6EAA6E;IAC7E,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QACxC,KAAK,CAAC,IAAI,CAAC,oEAAoE,CAAC,CAAC;QACjF,KAAK,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAC;IAC1E,CAAC;SAAM,CAAC;QACN,yDAAyD;QACzD,KAAK,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QACxC,KAAK,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC;QACtE,KAAK,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"embedder.d.ts","sourceRoot":"","sources":["../src/embedder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,sDAAsD;AACtD,eAAO,MAAM,SAAS,MAAM,CAAC;AA2B7B;;;;GAIG;AACH,wBAAsB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAO/D;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAKrE;AA+BD;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAKvF;AAED;;;;GAIG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAElD;AAED;;;;GAIG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAElD"}
1
+ {"version":3,"file":"embedder.d.ts","sourceRoot":"","sources":["../src/embedder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,sDAAsD;AACtD,eAAO,MAAM,SAAS,MAAM,CAAC;AAiC7B;;;;GAIG;AACH,wBAAsB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAO/D;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAKrE;AA+BD;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAKvF;AAED;;;;GAIG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAElD;AAED;;;;GAIG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAElD"}
package/dist/embedder.js CHANGED
@@ -28,6 +28,12 @@ async function getEmbedPipeline() {
28
28
  // @ts-ignore — @xenova/transformers has incomplete typings
29
29
  const { pipeline, env } = await import('@xenova/transformers');
30
30
  env.allowLocalModels = true;
31
+ // Limit ONNX WASM to 1 thread so embedding doesn't peg all CPU cores.
32
+ // Without this, Xenova spawns up to N worker threads (one per core),
33
+ // making OpenClaw unusable during seeding or heavy ingest.
34
+ // 1 thread = ~2–4× slower embeddings but the gateway stays responsive.
35
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
+ env.backends.onnx.wasm.numThreads = 1;
31
37
  _embedPipeline = (await pipeline('feature-extraction', 'Xenova/bge-small-en-v1.5'));
32
38
  }
33
39
  catch {
@@ -1 +1 @@
1
- {"version":3,"file":"embedder.js","sourceRoot":"","sources":["../src/embedder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,sDAAsD;AACtD,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC;AAI7B,IAAI,cAAc,GAAoB,IAAI,CAA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Y;IAChC,MAAM,gBAAgB,EAAE,CAAC;AAC3B,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,2BAA2B;AAC7B,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,15 +1,11 @@
1
- export type { IngestResult, MessageExchange, StoreStatus } from './types.js';
1
+ export type { StoreStatus, MemoryFact, IngestMemoryFactInput } from './types.js';
2
2
  export type { MemoryStore } from './store.js';
3
- export type { RawLogChunk, ScoreResult } from './scorer.js';
4
- export { scoreRawLog } from './scorer.js';
3
+ export { scoreMemoryFact, computeDecay } from './scorer.js';
5
4
  export { LocalStore } from './local-store.js';
6
- export type { LocalStoreOptions, RawLogSearchResult, RawLogEntry, ExportData } from './local-store.js';
5
+ export type { LocalStoreOptions, MemoryFactSearchResult } from './local-store.js';
7
6
  export { embed, embedQuery, rerankScores, EMBED_DIM } from './embedder.js';
8
7
  export { Bm25, tokenize } from './bm25.js';
9
- export { chunkExchange, formatExchange, CHUNK_WORDS, OVERLAP_WORDS } from './chunker.js';
10
- export type { Chunk } from './chunker.js';
11
- export { searchRawLog } from './raw-log-search.js';
12
- export type { RawChunk, MemoryContext, ReadPathOptions, ReadPathStore } from './read-path.js';
8
+ export type { MemoryFactChunk, MemoryContext, ReadPathOptions, ReadPathStore } from './read-path.js';
13
9
  export { buildMemoryContext } from './read-path.js';
14
10
  export { formatContextBlock, formatAge } from './context-builder.js';
15
11
  export { openDb } from './wasm-db.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC7E,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAA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,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACrG,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,YAAY,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -1,9 +1,7 @@
1
- export { scoreRawLog } from './scorer.js';
1
+ export { scoreMemoryFact, computeDecay } from './scorer.js';
2
2
  export { LocalStore } from './local-store.js';
3
3
  export { embed, embedQuery, rerankScores, EMBED_DIM } from './embedder.js';
4
4
  export { Bm25, tokenize } from './bm25.js';
5
- export { chunkExchange, formatExchange, CHUNK_WORDS, OVERLAP_WORDS } from './chunker.js';
6
- export { searchRawLog } from './raw-log-search.js';
7
5
  export { buildMemoryContext } from './read-path.js';
8
6
  export { formatContextBlock, formatAge } from './context-builder.js';
9
7
  export { openDb } from './wasm-db.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEzF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -1,27 +1,8 @@
1
1
  import { type WasmDb } from './wasm-db.js';
2
2
  import type { MemoryStore } from './store.js';
3
- import type { IngestResult, MessageExchange, StoreStatus } from './types.js';
4
- import { type RawLogSearchResult } from './raw-log-search.js';
5
- export type { RawLogSearchResult };
6
- export interface RawLogEntry {
7
- readonly id: string;
8
- readonly userId: string;
9
- readonly sessionId: string;
10
- readonly sessionLabel: string | null;
11
- readonly userMessage: string;
12
- readonly agentResponse: string;
13
- readonly timestamp: string;
14
- readonly source: string;
15
- readonly chunkText: string;
16
- readonly chunkIndex: number;
17
- readonly contentHash: string | null;
18
- readonly embedStatus: string;
19
- readonly embedError: string | null;
20
- readonly embedModel: string | null;
21
- }
22
- export interface ExportData {
23
- readonly rawLog: readonly RawLogEntry[];
24
- }
3
+ import type { StoreStatus, IngestMemoryFactInput } from './types.js';
4
+ import { type MemoryFactSearchResult } from './memory-facts-search.js';
5
+ export type { MemoryFactSearchResult };
25
6
  export interface LocalStoreOptions {
26
7
  /** Absolute path to the SQLite database file. Defaults to ~/.plumb/memory.db */
27
8
  dbPath?: string;
@@ -35,11 +16,16 @@ export interface LocalStoreOptions {
35
16
  /** Sleep duration when embed queue is empty (default 5000ms) */
36
17
  embedIdleMs?: number;
37
18
  };
19
+ /**
20
+ * Skip pre-warming the embedder/reranker pipelines at init time.
21
+ * Use in CLI tools (e.g. seed-dev.mjs) where startup latency matters and
22
+ * the model will load on first embed() call anyway.
23
+ * Default: false (warm at init for consistent query latency in the gateway).
24
+ */
25
+ skipWarm?: boolean;
38
26
  }
39
27
  export declare class LocalStore implements MemoryStore {
40
28
  #private;
41
- static readonly MAX_CACHE_ENTRIES = 10000;
42
- static readonly HEAP_GUARD_THRESHOLD = 1500000000;
43
29
  /** Expose database for plugin use (e.g., NudgeManager) */
44
30
  get db(): WasmDb;
45
31
  /** Expose userId for plugin use */
@@ -51,17 +37,24 @@ export declare class LocalStore implements MemoryStore {
51
37
  */
52
38
  static create(options?: LocalStoreOptions): Promise<LocalStore>;
53
39
  status(): Promise<StoreStatus>;
54
- ingest(exchange: MessageExchange): Promise<IngestResult>;
55
40
  /**
56
- * Hybrid search over raw_log (Layer 1 retrieval).
57
- * See raw-log-search.ts for the full pipeline description.
41
+ * Ingest a curated memory fact (T-118).
42
+ * Facts are stored as single chunks (no splitting) with embed_status='pending'.
43
+ * Accepts optional confidence (0–1) and decayRate ('slow'|'medium'|'fast').
44
+ */
45
+ ingestMemoryFact(input: IngestMemoryFactInput): Promise<{
46
+ factId: string;
47
+ }>;
48
+ /**
49
+ * Hybrid search over memory_facts (Layer 2 retrieval).
50
+ * See memory-facts-search.ts for the full pipeline description.
58
51
  */
59
- searchRawLog(query: string, limit?: number): Promise<readonly RawLogSearchResult[]>;
52
+ searchMemoryFacts(query: string, limit?: number): Promise<readonly MemoryFactSearchResult[]>;
60
53
  /**
61
- * Export all data for a user (for plumb export command).
62
- * Returns raw database rows (no vector data).
54
+ * Soft-delete a memory fact by id (sets deleted_at timestamp).
55
+ * Soft-deleted facts are excluded from search results.
63
56
  */
64
- exportAll(userId: string): ExportData;
57
+ delete(factId: string): Promise<void>;
65
58
  /**
66
59
  * Start background backlog processor drain loop (T-095).
67
60
  * Launches continuous async loop for embed backlog.
@@ -1 +1 @@
1
- {"version":3,"file":"local-store.d.ts","sourceRoot":"","sources":["../src/local-store.ts"],"names":[],"mappings":"AAIA,OAAO,EAAU,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG7E,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAG5E,YAAY,EAAE,kBAAkB,EAAE,CAAC;AAEnC,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,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