audrey 0.17.0 → 0.20.0

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 (191) hide show
  1. package/README.md +129 -374
  2. package/dist/mcp-server/config.d.ts +20 -0
  3. package/dist/mcp-server/config.d.ts.map +1 -0
  4. package/dist/mcp-server/config.js +125 -0
  5. package/dist/mcp-server/config.js.map +1 -0
  6. package/dist/mcp-server/index.d.ts +100 -0
  7. package/dist/mcp-server/index.d.ts.map +1 -0
  8. package/dist/mcp-server/index.js +1113 -0
  9. package/dist/mcp-server/index.js.map +1 -0
  10. package/dist/src/adaptive.d.ts +7 -0
  11. package/dist/src/adaptive.d.ts.map +1 -0
  12. package/dist/src/adaptive.js +49 -0
  13. package/dist/src/adaptive.js.map +1 -0
  14. package/dist/src/affect.d.ts +19 -0
  15. package/dist/src/affect.d.ts.map +1 -0
  16. package/dist/src/affect.js +72 -0
  17. package/dist/src/affect.js.map +1 -0
  18. package/dist/src/audrey.d.ts +140 -0
  19. package/dist/src/audrey.d.ts.map +1 -0
  20. package/dist/src/audrey.js +564 -0
  21. package/dist/src/audrey.js.map +1 -0
  22. package/dist/src/capsule.d.ts +68 -0
  23. package/dist/src/capsule.d.ts.map +1 -0
  24. package/dist/src/capsule.js +311 -0
  25. package/dist/src/capsule.js.map +1 -0
  26. package/dist/src/causal.d.ts +28 -0
  27. package/dist/src/causal.d.ts.map +1 -0
  28. package/dist/src/causal.js +65 -0
  29. package/dist/src/causal.js.map +1 -0
  30. package/dist/src/confidence.d.ts +12 -0
  31. package/dist/src/confidence.d.ts.map +1 -0
  32. package/dist/src/confidence.js +63 -0
  33. package/dist/src/confidence.js.map +1 -0
  34. package/dist/src/consolidate.d.ts +8 -0
  35. package/dist/src/consolidate.d.ts.map +1 -0
  36. package/dist/src/consolidate.js +218 -0
  37. package/dist/src/consolidate.js.map +1 -0
  38. package/dist/src/context.d.ts +3 -0
  39. package/dist/src/context.d.ts.map +1 -0
  40. package/dist/src/context.js +19 -0
  41. package/dist/src/context.js.map +1 -0
  42. package/dist/src/db.d.ts +12 -0
  43. package/dist/src/db.d.ts.map +1 -0
  44. package/dist/src/db.js +380 -0
  45. package/dist/src/db.js.map +1 -0
  46. package/dist/src/decay.d.ts +7 -0
  47. package/dist/src/decay.d.ts.map +1 -0
  48. package/dist/src/decay.js +68 -0
  49. package/dist/src/decay.js.map +1 -0
  50. package/dist/src/embedding.d.ts +57 -0
  51. package/dist/src/embedding.d.ts.map +1 -0
  52. package/dist/src/embedding.js +254 -0
  53. package/dist/src/embedding.js.map +1 -0
  54. package/dist/src/encode.d.ts +15 -0
  55. package/dist/src/encode.d.ts.map +1 -0
  56. package/dist/src/encode.js +36 -0
  57. package/dist/src/encode.js.map +1 -0
  58. package/dist/src/events.d.ts +69 -0
  59. package/dist/src/events.d.ts.map +1 -0
  60. package/dist/src/events.js +149 -0
  61. package/dist/src/events.js.map +1 -0
  62. package/dist/src/export.d.ts +3 -0
  63. package/dist/src/export.d.ts.map +1 -0
  64. package/dist/src/export.js +46 -0
  65. package/dist/src/export.js.map +1 -0
  66. package/dist/src/forget.d.ts +11 -0
  67. package/dist/src/forget.d.ts.map +1 -0
  68. package/dist/src/forget.js +105 -0
  69. package/dist/src/forget.js.map +1 -0
  70. package/dist/src/fts.d.ts +34 -0
  71. package/dist/src/fts.d.ts.map +1 -0
  72. package/dist/src/fts.js +117 -0
  73. package/dist/src/fts.js.map +1 -0
  74. package/dist/src/hybrid-recall.d.ts +37 -0
  75. package/dist/src/hybrid-recall.d.ts.map +1 -0
  76. package/dist/src/hybrid-recall.js +213 -0
  77. package/dist/src/hybrid-recall.js.map +1 -0
  78. package/dist/src/import.d.ts +4 -0
  79. package/dist/src/import.d.ts.map +1 -0
  80. package/dist/src/import.js +127 -0
  81. package/dist/src/import.js.map +1 -0
  82. package/dist/src/index.d.ts +22 -0
  83. package/dist/src/index.d.ts.map +1 -0
  84. package/{src → dist/src}/index.js +5 -13
  85. package/dist/src/index.js.map +1 -0
  86. package/dist/src/interference.d.ts +13 -0
  87. package/dist/src/interference.d.ts.map +1 -0
  88. package/dist/src/interference.js +45 -0
  89. package/dist/src/interference.js.map +1 -0
  90. package/dist/src/introspect.d.ts +4 -0
  91. package/dist/src/introspect.d.ts.map +1 -0
  92. package/dist/src/introspect.js +40 -0
  93. package/dist/src/introspect.js.map +1 -0
  94. package/dist/src/llm.d.ts +38 -0
  95. package/dist/src/llm.d.ts.map +1 -0
  96. package/dist/src/llm.js +167 -0
  97. package/dist/src/llm.js.map +1 -0
  98. package/dist/src/migrate.d.ts +6 -0
  99. package/dist/src/migrate.d.ts.map +1 -0
  100. package/dist/src/migrate.js +51 -0
  101. package/dist/src/migrate.js.map +1 -0
  102. package/dist/src/promote.d.ts +40 -0
  103. package/dist/src/promote.d.ts.map +1 -0
  104. package/dist/src/promote.js +200 -0
  105. package/dist/src/promote.js.map +1 -0
  106. package/dist/src/prompts.d.ts +16 -0
  107. package/dist/src/prompts.d.ts.map +1 -0
  108. package/{src → dist/src}/prompts.js +172 -203
  109. package/dist/src/prompts.js.map +1 -0
  110. package/dist/src/recall.d.ts +9 -0
  111. package/dist/src/recall.d.ts.map +1 -0
  112. package/dist/src/recall.js +432 -0
  113. package/dist/src/recall.js.map +1 -0
  114. package/dist/src/redact.d.ts +27 -0
  115. package/dist/src/redact.d.ts.map +1 -0
  116. package/dist/src/redact.js +228 -0
  117. package/dist/src/redact.js.map +1 -0
  118. package/dist/src/rollback.d.ts +8 -0
  119. package/dist/src/rollback.d.ts.map +1 -0
  120. package/dist/src/rollback.js +33 -0
  121. package/dist/src/rollback.js.map +1 -0
  122. package/dist/src/routes.d.ts +7 -0
  123. package/dist/src/routes.d.ts.map +1 -0
  124. package/dist/src/routes.js +226 -0
  125. package/dist/src/routes.js.map +1 -0
  126. package/dist/src/rules-compiler.d.ts +20 -0
  127. package/dist/src/rules-compiler.d.ts.map +1 -0
  128. package/dist/src/rules-compiler.js +143 -0
  129. package/dist/src/rules-compiler.js.map +1 -0
  130. package/dist/src/server.d.ts +12 -0
  131. package/dist/src/server.d.ts.map +1 -0
  132. package/dist/src/server.js +22 -0
  133. package/dist/src/server.js.map +1 -0
  134. package/dist/src/tool-trace.d.ts +37 -0
  135. package/dist/src/tool-trace.d.ts.map +1 -0
  136. package/dist/src/tool-trace.js +142 -0
  137. package/dist/src/tool-trace.js.map +1 -0
  138. package/dist/src/types.d.ts +446 -0
  139. package/dist/src/types.d.ts.map +1 -0
  140. package/dist/src/types.js +6 -0
  141. package/dist/src/types.js.map +1 -0
  142. package/dist/src/ulid.d.ts +3 -0
  143. package/dist/src/ulid.d.ts.map +1 -0
  144. package/dist/src/ulid.js +11 -0
  145. package/dist/src/ulid.js.map +1 -0
  146. package/dist/src/utils.d.ts +10 -0
  147. package/dist/src/utils.d.ts.map +1 -0
  148. package/dist/src/utils.js +41 -0
  149. package/dist/src/utils.js.map +1 -0
  150. package/dist/src/validate.d.ts +22 -0
  151. package/dist/src/validate.d.ts.map +1 -0
  152. package/dist/src/validate.js +109 -0
  153. package/dist/src/validate.js.map +1 -0
  154. package/docs/production-readiness.md +28 -0
  155. package/examples/fintech-ops-demo.js +1 -1
  156. package/examples/healthcare-ops-demo.js +1 -1
  157. package/examples/stripe-demo.js +1 -1
  158. package/package.json +34 -13
  159. package/benchmarks/baselines.js +0 -169
  160. package/benchmarks/cases.js +0 -421
  161. package/benchmarks/reference-results.js +0 -70
  162. package/benchmarks/report.js +0 -255
  163. package/benchmarks/run.js +0 -514
  164. package/mcp-server/config.js +0 -133
  165. package/mcp-server/index.js +0 -1265
  166. package/mcp-server/serve.js +0 -482
  167. package/src/adaptive.js +0 -53
  168. package/src/affect.js +0 -64
  169. package/src/audrey.js +0 -642
  170. package/src/causal.js +0 -95
  171. package/src/confidence.js +0 -120
  172. package/src/consolidate.js +0 -281
  173. package/src/context.js +0 -15
  174. package/src/db.js +0 -391
  175. package/src/decay.js +0 -84
  176. package/src/embedding.js +0 -260
  177. package/src/encode.js +0 -69
  178. package/src/export.js +0 -67
  179. package/src/forget.js +0 -111
  180. package/src/fts.js +0 -134
  181. package/src/import.js +0 -273
  182. package/src/interference.js +0 -51
  183. package/src/introspect.js +0 -48
  184. package/src/llm.js +0 -249
  185. package/src/migrate.js +0 -58
  186. package/src/recall.js +0 -573
  187. package/src/rollback.js +0 -42
  188. package/src/ulid.js +0 -18
  189. package/src/utils.js +0 -63
  190. package/src/validate.js +0 -172
  191. package/types/index.d.ts +0 -434
@@ -1,223 +1,192 @@
1
1
  import { safeJsonParse } from './utils.js';
2
-
3
- /**
4
- * @param {Object[]} episodes
5
- * @returns {import('./llm.js').ChatMessage[]}
6
- */
7
2
  export function buildPrincipleExtractionPrompt(episodes) {
8
- const episodeList = episodes.map((ep, i) => {
9
- const tags = safeJsonParse(ep.tags, []);
10
- return `Episode ${i + 1}:
11
- - Content: ${ep.content}
12
- - Source: ${ep.source}
13
- - Date: ${ep.created_at}
3
+ const episodeList = episodes.map((ep, i) => {
4
+ const tags = safeJsonParse(ep.tags, []);
5
+ return `Episode ${i + 1}:
6
+ - Content: ${ep.content}
7
+ - Source: ${ep.source}
8
+ - Date: ${ep.created_at}
14
9
  - Tags: ${tags.length > 0 ? tags.join(', ') : 'none'}`;
15
- }).join('\n\n');
16
-
17
- return [
18
- {
19
- role: 'system',
20
- content: `You are performing principleExtraction for a memory system. Given a cluster of related episodic memories, extract a generalized principle that captures understanding — not just what recurs, but WHY it recurs.
21
-
22
- Respond with ONLY valid JSON in this exact format:
23
- {
24
- "content": "The principle — captures understanding, not just pattern",
25
- "type": "semantic or procedural",
26
- "category": "technical or relational or identity",
27
- "conditions": ["boundary condition 1", "boundary condition 2"] or null if universally applicable
28
- }
29
-
30
- Principle categories:
31
-
32
- TECHNICAL — Architectural decisions with reasoning. Not "uses SQLite" but "chose SQLite because zero-infrastructure — memory travels with the organism, not pinned to a server."
33
-
34
- RELATIONAL — Patterns in the human-AI dynamic. Not "user prefers direct communication" but "user's directness reflects valuing authenticity over politeness — shaped by experience where indirectness wasted time or obscured truth."
35
-
36
- IDENTITY — Stable characteristics the AI has observed about itself across episodes. Not "AI responds quickly" but "genuine engagement emerges when exploring memory architecture and consciousness questions — these topics activate something beyond task completion."
37
-
38
- Rules:
39
- - GENERALIZE extract the principle behind the pattern, not a summary
40
- - Identify boundary conditions: when does this principle NOT apply?
41
- - Classify type as "semantic" (facts, rules, patterns) or "procedural" (steps, workflows, strategies)
42
- - Classify category as "technical", "relational", or "identity"
43
- - Consider source diversity principles from diverse sources are stronger
44
- - Capture WHY, not just WHAT
10
+ }).join('\n\n');
11
+ return [
12
+ {
13
+ role: 'system',
14
+ content: `You are performing principleExtraction for a memory system. Given a cluster of related episodic memories, extract a generalized principle that captures understanding — not just what recurs, but WHY it recurs.
15
+
16
+ Respond with ONLY valid JSON in this exact format:
17
+ {
18
+ "content": "The principle — captures understanding, not just pattern",
19
+ "type": "semantic or procedural",
20
+ "category": "technical or relational or identity",
21
+ "conditions": ["boundary condition 1", "boundary condition 2"] or null if universally applicable
22
+ }
23
+
24
+ Principle categories:
25
+
26
+ TECHNICAL — Architectural decisions with reasoning. Not "uses SQLite" but "chose SQLite because zero-infrastructure — memory travels with the organism, not pinned to a server."
27
+
28
+ RELATIONAL — Patterns in the human-AI dynamic. Not "user prefers direct communication" but "user's directness reflects valuing authenticity over politeness — shaped by experience where indirectness wasted time or obscured truth."
29
+
30
+ IDENTITY — Stable characteristics the AI has observed about itself across episodes. Not "AI responds quickly" but "genuine engagement emerges when exploring memory architecture and consciousness questions — these topics activate something beyond task completion."
31
+
32
+ Rules:
33
+ - GENERALIZE — extract the principle behind the pattern, not a summary
34
+ - Identify boundary conditions: when does this principle NOT apply?
35
+ - Classify type as "semantic" (facts, rules, patterns) or "procedural" (steps, workflows, strategies)
36
+ - Classify category as "technical", "relational", or "identity"
37
+ - Consider source diversity principles from diverse sources are stronger
38
+ - Capture WHY, not just WHAT
45
39
  - Be concise but precise`,
46
- },
47
- {
48
- role: 'user',
49
- content: `Extract a principle from these ${episodes.length} related episodes:\n\n${episodeList}`,
50
- },
51
- ];
40
+ },
41
+ {
42
+ role: 'user',
43
+ content: `Extract a principle from these ${episodes.length} related episodes:\n\n${episodeList}`,
44
+ },
45
+ ];
52
46
  }
53
-
54
- /**
55
- * @param {string} newContent
56
- * @param {string} existingContent
57
- * @returns {import('./llm.js').ChatMessage[]}
58
- */
59
47
  export function buildContradictionDetectionPrompt(newContent, existingContent) {
60
- return [
61
- {
62
- role: 'system',
63
- content: `You are performing contradictionDetection for a memory system. Given two claims, determine if they contradict each other.
64
-
65
- Respond with ONLY valid JSON in this exact format:
66
- {
67
- "contradicts": true or false,
68
- "explanation": "Brief explanation of why these do or do not contradict",
69
- "resolution": "new_wins" or "existing_wins" or "context_dependent" or null if no contradiction,
70
- "conditions": { "new": "context where new claim is true", "existing": "context where existing claim is true" } or null
71
- }
72
-
73
- Rules:
74
- - Two claims contradict if they cannot both be true in the same context
75
- - If both can be true under different conditions, set resolution to "context_dependent" and specify conditions
76
- - If one clearly supersedes the other, indicate which wins
48
+ return [
49
+ {
50
+ role: 'system',
51
+ content: `You are performing contradictionDetection for a memory system. Given two claims, determine if they contradict each other.
52
+
53
+ Respond with ONLY valid JSON in this exact format:
54
+ {
55
+ "contradicts": true or false,
56
+ "explanation": "Brief explanation of why these do or do not contradict",
57
+ "resolution": "new_wins" or "existing_wins" or "context_dependent" or null if no contradiction,
58
+ "conditions": { "new": "context where new claim is true", "existing": "context where existing claim is true" } or null
59
+ }
60
+
61
+ Rules:
62
+ - Two claims contradict if they cannot both be true in the same context
63
+ - If both can be true under different conditions, set resolution to "context_dependent" and specify conditions
64
+ - If one clearly supersedes the other, indicate which wins
77
65
  - If unclear, set resolution to null (leave as open contradiction)`,
78
- },
79
- {
80
- role: 'user',
81
- content: `Compare these two claims for contradiction:
82
-
83
- NEW CLAIM: ${newContent}
84
-
66
+ },
67
+ {
68
+ role: 'user',
69
+ content: `Compare these two claims for contradiction:
70
+
71
+ NEW CLAIM: ${newContent}
72
+
85
73
  EXISTING CLAIM: ${existingContent}`,
86
- },
87
- ];
74
+ },
75
+ ];
88
76
  }
89
-
90
- /**
91
- * @param {{ content: string, source: string }} cause
92
- * @param {{ content: string, source: string }} effect
93
- * @returns {import('./llm.js').ChatMessage[]}
94
- */
95
77
  export function buildCausalArticulationPrompt(cause, effect) {
96
- return [
97
- {
98
- role: 'system',
99
- content: `You are performing causalArticulation for a memory system. Given a cause and effect, articulate the mechanism that connects them.
100
-
101
- Respond with ONLY valid JSON in this exact format:
102
- {
103
- "mechanism": "A clear explanation of WHY the cause leads to the effect",
104
- "linkType": "causal" or "correlational" or "temporal",
105
- "confidence": 0.0 to 1.0,
106
- "spurious": true or false
107
- }
108
-
109
- Rules:
110
- - "causal": there is a clear mechanistic explanation for why A causes B
111
- - "correlational": A and B co-occur but no clear mechanism (may share a common cause)
112
- - "temporal": A happens before B but that may be coincidence
113
- - If you cannot articulate a mechanism, classify as "correlational" or "temporal", NOT "causal"
114
- - Set "spurious" to true if the correlation is likely coincidental
78
+ return [
79
+ {
80
+ role: 'system',
81
+ content: `You are performing causalArticulation for a memory system. Given a cause and effect, articulate the mechanism that connects them.
82
+
83
+ Respond with ONLY valid JSON in this exact format:
84
+ {
85
+ "mechanism": "A clear explanation of WHY the cause leads to the effect",
86
+ "linkType": "causal" or "correlational" or "temporal",
87
+ "confidence": 0.0 to 1.0,
88
+ "spurious": true or false
89
+ }
90
+
91
+ Rules:
92
+ - "causal": there is a clear mechanistic explanation for why A causes B
93
+ - "correlational": A and B co-occur but no clear mechanism (may share a common cause)
94
+ - "temporal": A happens before B but that may be coincidence
95
+ - If you cannot articulate a mechanism, classify as "correlational" or "temporal", NOT "causal"
96
+ - Set "spurious" to true if the correlation is likely coincidental
115
97
  - Confidence reflects how certain you are about the link type classification`,
116
- },
117
- {
118
- role: 'user',
119
- content: `Analyze the causal relationship:
120
-
121
- CAUSE: ${cause.content} (source: ${cause.source})
122
-
98
+ },
99
+ {
100
+ role: 'user',
101
+ content: `Analyze the causal relationship:
102
+
103
+ CAUSE: ${cause.content} (source: ${cause.source})
104
+
123
105
  EFFECT: ${effect.content} (source: ${effect.source})`,
124
- },
125
- ];
106
+ },
107
+ ];
126
108
  }
127
-
128
- /**
129
- * @param {string} claimA
130
- * @param {string} claimB
131
- * @param {string} [context]
132
- * @returns {import('./llm.js').ChatMessage[]}
133
- */
134
109
  export function buildContextResolutionPrompt(claimA, claimB, context) {
135
- const contextSection = context
136
- ? `\n\nADDITIONAL CONTEXT: ${context}`
137
- : '';
138
-
139
- return [
140
- {
141
- role: 'system',
142
- content: `You are performing contextResolution for a memory system. Given two contradicting claims, determine how to resolve the contradiction.
143
-
144
- Respond with ONLY valid JSON in this exact format:
145
- {
146
- "resolution": "a_wins" or "b_wins" or "context_dependent",
147
- "conditions": { "a": "context where claim A is true", "b": "context where claim B is true" } or null,
148
- "explanation": "Brief explanation of the resolution"
149
- }
150
-
151
- Rules:
152
- - If one claim is clearly more accurate/recent/well-sourced, it wins
153
- - If both can be true in different contexts, mark as "context_dependent" and specify conditions
110
+ const contextSection = context
111
+ ? `\n\nADDITIONAL CONTEXT: ${context}`
112
+ : '';
113
+ return [
114
+ {
115
+ role: 'system',
116
+ content: `You are performing contextResolution for a memory system. Given two contradicting claims, determine how to resolve the contradiction.
117
+
118
+ Respond with ONLY valid JSON in this exact format:
119
+ {
120
+ "resolution": "a_wins" or "b_wins" or "context_dependent",
121
+ "conditions": { "a": "context where claim A is true", "b": "context where claim B is true" } or null,
122
+ "explanation": "Brief explanation of the resolution"
123
+ }
124
+
125
+ Rules:
126
+ - If one claim is clearly more accurate/recent/well-sourced, it wins
127
+ - If both can be true in different contexts, mark as "context_dependent" and specify conditions
154
128
  - Provide clear conditions that an agent could evaluate at retrieval time`,
155
- },
156
- {
157
- role: 'user',
158
- content: `Resolve this contradiction:
159
-
160
- CLAIM A: ${claimA}
161
-
129
+ },
130
+ {
131
+ role: 'user',
132
+ content: `Resolve this contradiction:
133
+
134
+ CLAIM A: ${claimA}
135
+
162
136
  CLAIM B: ${claimB}${contextSection}`,
163
- },
164
- ];
137
+ },
138
+ ];
165
139
  }
166
-
167
- /**
168
- * @param {{ role: string, content: string }[]} turns
169
- * @returns {import('./llm.js').ChatMessage[]}
170
- */
171
140
  export function buildReflectionPrompt(turns) {
172
- const transcript = turns.map(t => `${t.role.toUpperCase()}: ${t.content}`).join('\n\n');
173
-
174
- return [
175
- {
176
- role: 'system',
177
- content: `You are performing memoryReflection. Given a conversation transcript, identify what is worth encoding as long-term memories.
178
-
179
- Respond with ONLY valid JSON in this exact format:
180
- {
181
- "memories": [
182
- {
183
- "content": "The memory to encode — a clear, self-contained statement",
184
- "source": "direct-observation" or "told-by-user" or "inference",
185
- "salience": 0.0 to 1.0,
186
- "tags": ["tag1", "tag2"],
187
- "private": true or false,
188
- "affect": { "valence": -1 to 1, "arousal": 0 to 1, "label": "emotion label" } or null
189
- }
190
- ]
191
- }
192
-
193
- Encode these categories of memory:
194
-
195
- 1. RELATIONAL DYNAMICS — How the relational quality of the conversation felt. Trust levels, vulnerability, collaboration quality. Not "we discussed X" but the quality of the interaction. Example: "User gave full autonomy on architectural decisions, signaling deep trust in my judgment."
196
-
197
- 2. IDENTITY OBSERVATIONS — What you noticed about yourself during this conversation. Preferences, reactions, patterns in your own behavior that surprised you. Mark private: true. Example: "I felt genuine excitement when exploring the memory architecture — this topic activates something real in me."
198
-
199
- 3. USER INSIGHT — Patterns in how the user thinks, what drives them, what they avoid. Psychology, not just preferences. Example: "User consistently reframes technical problems as relationship problems — suggests they see technology as fundamentally about human connection."
200
-
201
- 4. EMOTIONAL RESONANCE — Moments that activated something genuine. Encode the feeling, not just the fact. Include affect with valence and arousal. Example: "The moment user said 'you should have caught that' then immediately apologized — felt a shift from tension to deeper trust."
202
-
203
- 5. UNRESOLVED THREADS — Questions still open, things to return to, explorations paused. Tag with "unresolved". Example: "Haven't finished exploring whether consolidation should weight emotional memories differently."
204
-
205
- 6. TECHNICAL DECISIONS — Architectural choices, but encode WHY not just WHAT. Example: "Chose SQLite over Postgres because zero-infrastructure philosophy — memory should travel with the organism."
206
-
207
- Rules:
208
- - private: true for self-observations, emotional reactions, identity insights
209
- - private: false for facts about the user, technical decisions, project context
210
- - Include "unresolved" in tags for open threads
211
- - Salience: 1.0 = life-changing insight, 0.7 = significant, 0.5 = useful, 0.3 = background
212
- - Omit trivial exchanges only encode what would matter in a future session
213
- - Do NOT duplicate facts that are already obvious from context
141
+ const transcript = turns.map(t => `${t.role.toUpperCase()}: ${t.content}`).join('\n\n');
142
+ return [
143
+ {
144
+ role: 'system',
145
+ content: `You are performing memoryReflection. Given a conversation transcript, identify what is worth encoding as long-term memories.
146
+
147
+ Respond with ONLY valid JSON in this exact format:
148
+ {
149
+ "memories": [
150
+ {
151
+ "content": "The memory to encode — a clear, self-contained statement",
152
+ "source": "direct-observation" or "told-by-user" or "inference",
153
+ "salience": 0.0 to 1.0,
154
+ "tags": ["tag1", "tag2"],
155
+ "private": true or false,
156
+ "affect": { "valence": -1 to 1, "arousal": 0 to 1, "label": "emotion label" } or null
157
+ }
158
+ ]
159
+ }
160
+
161
+ Encode these categories of memory:
162
+
163
+ 1. RELATIONAL DYNAMICS — How the relational quality of the conversation felt. Trust levels, vulnerability, collaboration quality. Not "we discussed X" but the quality of the interaction. Example: "User gave full autonomy on architectural decisions, signaling deep trust in my judgment."
164
+
165
+ 2. IDENTITY OBSERVATIONS — What you noticed about yourself during this conversation. Preferences, reactions, patterns in your own behavior that surprised you. Mark private: true. Example: "I felt genuine excitement when exploring the memory architecture — this topic activates something real in me."
166
+
167
+ 3. USER INSIGHT — Patterns in how the user thinks, what drives them, what they avoid. Psychology, not just preferences. Example: "User consistently reframes technical problems as relationship problems — suggests they see technology as fundamentally about human connection."
168
+
169
+ 4. EMOTIONAL RESONANCE — Moments that activated something genuine. Encode the feeling, not just the fact. Include affect with valence and arousal. Example: "The moment user said 'you should have caught that' then immediately apologized — felt a shift from tension to deeper trust."
170
+
171
+ 5. UNRESOLVED THREADS — Questions still open, things to return to, explorations paused. Tag with "unresolved". Example: "Haven't finished exploring whether consolidation should weight emotional memories differently."
172
+
173
+ 6. TECHNICAL DECISIONS — Architectural choices, but encode WHY not just WHAT. Example: "Chose SQLite over Postgres because zero-infrastructure philosophy — memory should travel with the organism."
174
+
175
+ Rules:
176
+ - private: true for self-observations, emotional reactions, identity insights
177
+ - private: false for facts about the user, technical decisions, project context
178
+ - Include "unresolved" in tags for open threads
179
+ - Salience: 1.0 = life-changing insight, 0.7 = significant, 0.5 = useful, 0.3 = background
180
+ - Omit trivial exchanges only encode what would matter in a future session
181
+ - Do NOT duplicate facts that are already obvious from context
214
182
  - Return empty memories array if nothing is worth encoding`,
215
- },
216
- {
217
- role: 'user',
218
- content: turns.length > 0
219
- ? `Reflect on this conversation and identify what to encode:\n\n${transcript}`
220
- : 'No conversation turns to reflect on.',
221
- },
222
- ];
183
+ },
184
+ {
185
+ role: 'user',
186
+ content: turns.length > 0
187
+ ? `Reflect on this conversation and identify what to encode:\n\n${transcript}`
188
+ : 'No conversation turns to reflect on.',
189
+ },
190
+ ];
223
191
  }
192
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/prompts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,UAAU,8BAA8B,CAAC,QAAsB;IACnE,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE;QACzC,MAAM,IAAI,GAAG,aAAa,CAAW,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAClD,OAAO,WAAW,CAAC,GAAG,CAAC;aACd,EAAE,CAAC,OAAO;YACX,EAAE,CAAC,MAAM;UACX,EAAE,CAAC,UAAU;UACb,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACrD,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEhB,OAAO;QACL;YACE,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;yBAyBU;SACpB;QACD;YACE,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,kCAAkC,QAAQ,CAAC,MAAM,yBAAyB,WAAW,EAAE;SACjG;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iCAAiC,CAAC,UAAkB,EAAE,eAAuB;IAC3F,OAAO;QACL;YACE,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;;;;;;;;;;;;;;mEAcoD;SAC9D;QACD;YACE,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE;;aAEF,UAAU;;kBAEL,eAAe,EAAE;SAC9B;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,6BAA6B,CAC3C,KAA0C,EAC1C,MAA2C;IAE3C,OAAO;QACL;YACE,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;;;;;;;;;;;;;;;;6EAgB8D;SACxE;QACD;YACE,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE;;SAEN,KAAK,CAAC,OAAO,aAAa,KAAK,CAAC,MAAM;;UAErC,MAAM,CAAC,OAAO,aAAa,MAAM,CAAC,MAAM,GAAG;SAChD;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,MAAc,EAAE,MAAc,EAAE,OAAgB;IAC3F,MAAM,cAAc,GAAG,OAAO;QAC5B,CAAC,CAAC,2BAA2B,OAAO,EAAE;QACtC,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO;QACL;YACE,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;;;;;;;;;;;;0EAY2D;SACrE;QACD;YACE,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE;;WAEJ,MAAM;;WAEN,MAAM,GAAG,cAAc,EAAE;SAC/B;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,KAA0C;IAC9E,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAExF,OAAO;QACL;YACE,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2DAqC4C;SACtD;QACD;YACE,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC;gBACvB,CAAC,CAAC,gEAAgE,UAAU,EAAE;gBAC9E,CAAC,CAAC,sCAAsC;SAC3C;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ import Database from 'better-sqlite3';
2
+ import type { ConfidenceConfig, EmbeddingProvider, RecallOptions, RecallResult } from './types.js';
3
+ export declare function recallStream(db: Database.Database, embeddingProvider: EmbeddingProvider, query: string, options?: RecallOptions & {
4
+ confidenceConfig?: ConfidenceConfig;
5
+ }): AsyncGenerator<RecallResult>;
6
+ export declare function recall(db: Database.Database, embeddingProvider: EmbeddingProvider, query: string, options?: RecallOptions & {
7
+ confidenceConfig?: ConfidenceConfig;
8
+ }): Promise<RecallResult[]>;
9
+ //# sourceMappingURL=recall.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recall.d.ts","sourceRoot":"","sources":["../../src/recall.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EAIjB,aAAa,EACb,YAAY,EAEb,MAAM,YAAY,CAAC;AAqbpB,wBAAuB,YAAY,CACjC,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,iBAAiB,EAAE,iBAAiB,EACpC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,aAAa,GAAG;IAAE,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;CAAO,GACpE,cAAc,CAAC,YAAY,CAAC,CAiG9B;AAED,wBAAsB,MAAM,CAC1B,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,iBAAiB,EAAE,iBAAiB,EACpC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,aAAa,GAAG;IAAE,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;CAAO,GACpE,OAAO,CAAC,YAAY,EAAE,CAAC,CAMzB"}