@agentmemory/agentmemory 0.7.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 (259) hide show
  1. package/.claude-plugin/marketplace.json +14 -0
  2. package/.github/workflows/ci.yml +22 -0
  3. package/.github/workflows/publish.yml +28 -0
  4. package/AGENTS.md +113 -0
  5. package/LICENSE +190 -0
  6. package/README.md +828 -0
  7. package/assets/banner.png +0 -0
  8. package/assets/demo.gif +0 -0
  9. package/assets/demo.mp4 +0 -0
  10. package/benchmark/QUALITY.md +73 -0
  11. package/benchmark/REAL-EMBEDDINGS.md +67 -0
  12. package/benchmark/SCALE.md +110 -0
  13. package/benchmark/dataset.ts +293 -0
  14. package/benchmark/quality-eval.ts +643 -0
  15. package/benchmark/real-embeddings-eval.ts +405 -0
  16. package/benchmark/scale-eval.ts +398 -0
  17. package/dist/cli.d.mts +1 -0
  18. package/dist/cli.mjs +137 -0
  19. package/dist/cli.mjs.map +1 -0
  20. package/dist/docker-compose.yml +14 -0
  21. package/dist/hooks/notification.d.mts +1 -0
  22. package/dist/hooks/notification.mjs +45 -0
  23. package/dist/hooks/notification.mjs.map +1 -0
  24. package/dist/hooks/post-tool-failure.d.mts +1 -0
  25. package/dist/hooks/post-tool-failure.mjs +45 -0
  26. package/dist/hooks/post-tool-failure.mjs.map +1 -0
  27. package/dist/hooks/post-tool-use.d.mts +1 -0
  28. package/dist/hooks/post-tool-use.mjs +53 -0
  29. package/dist/hooks/post-tool-use.mjs.map +1 -0
  30. package/dist/hooks/pre-compact.d.mts +1 -0
  31. package/dist/hooks/pre-compact.mjs +50 -0
  32. package/dist/hooks/pre-compact.mjs.map +1 -0
  33. package/dist/hooks/pre-tool-use.d.mts +1 -0
  34. package/dist/hooks/pre-tool-use.mjs +69 -0
  35. package/dist/hooks/pre-tool-use.mjs.map +1 -0
  36. package/dist/hooks/prompt-submit.d.mts +1 -0
  37. package/dist/hooks/prompt-submit.mjs +40 -0
  38. package/dist/hooks/prompt-submit.mjs.map +1 -0
  39. package/dist/hooks/session-end.d.mts +1 -0
  40. package/dist/hooks/session-end.mjs +61 -0
  41. package/dist/hooks/session-end.mjs.map +1 -0
  42. package/dist/hooks/session-start.d.mts +1 -0
  43. package/dist/hooks/session-start.mjs +42 -0
  44. package/dist/hooks/session-start.mjs.map +1 -0
  45. package/dist/hooks/stop.d.mts +1 -0
  46. package/dist/hooks/stop.mjs +33 -0
  47. package/dist/hooks/stop.mjs.map +1 -0
  48. package/dist/hooks/subagent-start.d.mts +1 -0
  49. package/dist/hooks/subagent-start.mjs +43 -0
  50. package/dist/hooks/subagent-start.mjs.map +1 -0
  51. package/dist/hooks/subagent-stop.d.mts +1 -0
  52. package/dist/hooks/subagent-stop.mjs +45 -0
  53. package/dist/hooks/subagent-stop.mjs.map +1 -0
  54. package/dist/hooks/task-completed.d.mts +1 -0
  55. package/dist/hooks/task-completed.mjs +46 -0
  56. package/dist/hooks/task-completed.mjs.map +1 -0
  57. package/dist/iii-config.yaml +51 -0
  58. package/dist/index.d.mts +2 -0
  59. package/dist/index.mjs +13776 -0
  60. package/dist/index.mjs.map +1 -0
  61. package/dist/src-QxitMPfJ.mjs +13775 -0
  62. package/dist/src-QxitMPfJ.mjs.map +1 -0
  63. package/dist/standalone.d.mts +1 -0
  64. package/dist/standalone.mjs +1155 -0
  65. package/dist/standalone.mjs.map +1 -0
  66. package/dist/transformers-BX_tgxdO.mjs +38684 -0
  67. package/dist/transformers-BX_tgxdO.mjs.map +1 -0
  68. package/dist/transformers-KMm1i9no.mjs +38683 -0
  69. package/dist/transformers-KMm1i9no.mjs.map +1 -0
  70. package/docker-compose.yml +14 -0
  71. package/iii-config.yaml +51 -0
  72. package/package.json +59 -0
  73. package/plugin/.claude-plugin/plugin.json +10 -0
  74. package/plugin/hooks/hooks.json +77 -0
  75. package/plugin/scripts/diagnostics.mjs +551 -0
  76. package/plugin/scripts/notification.mjs +45 -0
  77. package/plugin/scripts/post-tool-failure.mjs +45 -0
  78. package/plugin/scripts/post-tool-use.mjs +53 -0
  79. package/plugin/scripts/pre-compact.mjs +50 -0
  80. package/plugin/scripts/pre-tool-use.mjs +69 -0
  81. package/plugin/scripts/prompt-submit.mjs +40 -0
  82. package/plugin/scripts/session-end.mjs +61 -0
  83. package/plugin/scripts/session-start.mjs +42 -0
  84. package/plugin/scripts/stop.mjs +33 -0
  85. package/plugin/scripts/subagent-start.mjs +43 -0
  86. package/plugin/scripts/subagent-stop.mjs +45 -0
  87. package/plugin/scripts/task-completed.mjs +46 -0
  88. package/plugin/skills/forget/SKILL.md +32 -0
  89. package/plugin/skills/recall/SKILL.md +18 -0
  90. package/plugin/skills/remember/SKILL.md +25 -0
  91. package/plugin/skills/session-history/SKILL.md +17 -0
  92. package/src/auth.ts +12 -0
  93. package/src/cli.ts +159 -0
  94. package/src/config.ts +221 -0
  95. package/src/eval/metrics-store.ts +65 -0
  96. package/src/eval/quality.ts +51 -0
  97. package/src/eval/schemas.ts +124 -0
  98. package/src/eval/self-correct.ts +28 -0
  99. package/src/eval/validator.ts +31 -0
  100. package/src/functions/actions.ts +288 -0
  101. package/src/functions/audit.ts +61 -0
  102. package/src/functions/auto-forget.ts +169 -0
  103. package/src/functions/branch-aware.ts +169 -0
  104. package/src/functions/cascade.ts +80 -0
  105. package/src/functions/checkpoints.ts +209 -0
  106. package/src/functions/claude-bridge.ts +161 -0
  107. package/src/functions/compress.ts +194 -0
  108. package/src/functions/consolidate.ts +212 -0
  109. package/src/functions/consolidation-pipeline.ts +258 -0
  110. package/src/functions/context.ts +169 -0
  111. package/src/functions/crystallize.ts +293 -0
  112. package/src/functions/dedup.ts +57 -0
  113. package/src/functions/diagnostics.ts +785 -0
  114. package/src/functions/enrich.ts +132 -0
  115. package/src/functions/evict.ts +163 -0
  116. package/src/functions/export-import.ts +508 -0
  117. package/src/functions/facets.ts +248 -0
  118. package/src/functions/file-index.ts +106 -0
  119. package/src/functions/flow-compress.ts +214 -0
  120. package/src/functions/frontier.ts +196 -0
  121. package/src/functions/governance.ts +131 -0
  122. package/src/functions/graph-retrieval.ts +277 -0
  123. package/src/functions/graph.ts +275 -0
  124. package/src/functions/leases.ts +216 -0
  125. package/src/functions/lessons.ts +253 -0
  126. package/src/functions/mesh.ts +434 -0
  127. package/src/functions/migrate.ts +165 -0
  128. package/src/functions/observe.ts +144 -0
  129. package/src/functions/obsidian-export.ts +310 -0
  130. package/src/functions/patterns.ts +138 -0
  131. package/src/functions/privacy.ts +39 -0
  132. package/src/functions/profile.ts +155 -0
  133. package/src/functions/query-expansion.ts +186 -0
  134. package/src/functions/relations.ts +237 -0
  135. package/src/functions/remember.ts +162 -0
  136. package/src/functions/retention.ts +235 -0
  137. package/src/functions/routines.ts +289 -0
  138. package/src/functions/search.ts +80 -0
  139. package/src/functions/sentinels.ts +417 -0
  140. package/src/functions/signals.ts +186 -0
  141. package/src/functions/sketches.ts +274 -0
  142. package/src/functions/sliding-window.ts +257 -0
  143. package/src/functions/smart-search.ts +115 -0
  144. package/src/functions/snapshot.ts +219 -0
  145. package/src/functions/summarize.ts +155 -0
  146. package/src/functions/team.ts +147 -0
  147. package/src/functions/temporal-graph.ts +476 -0
  148. package/src/functions/timeline.ts +138 -0
  149. package/src/functions/verify.ts +117 -0
  150. package/src/health/monitor.ts +110 -0
  151. package/src/health/thresholds.ts +73 -0
  152. package/src/hooks/notification.ts +52 -0
  153. package/src/hooks/post-tool-failure.ts +58 -0
  154. package/src/hooks/post-tool-use.ts +62 -0
  155. package/src/hooks/pre-compact.ts +60 -0
  156. package/src/hooks/pre-tool-use.ts +72 -0
  157. package/src/hooks/prompt-submit.ts +46 -0
  158. package/src/hooks/session-end.ts +71 -0
  159. package/src/hooks/session-start.ts +48 -0
  160. package/src/hooks/stop.ts +39 -0
  161. package/src/hooks/subagent-start.ts +49 -0
  162. package/src/hooks/subagent-stop.ts +54 -0
  163. package/src/hooks/task-completed.ts +54 -0
  164. package/src/index.ts +342 -0
  165. package/src/mcp/in-memory-kv.ts +61 -0
  166. package/src/mcp/server.ts +1455 -0
  167. package/src/mcp/standalone.ts +177 -0
  168. package/src/mcp/tools-registry.ts +769 -0
  169. package/src/mcp/transport.ts +91 -0
  170. package/src/prompts/compression.ts +67 -0
  171. package/src/prompts/consolidation.ts +48 -0
  172. package/src/prompts/graph-extraction.ts +35 -0
  173. package/src/prompts/summary.ts +38 -0
  174. package/src/prompts/xml.ts +26 -0
  175. package/src/providers/agent-sdk.ts +34 -0
  176. package/src/providers/anthropic.ts +35 -0
  177. package/src/providers/circuit-breaker.ts +82 -0
  178. package/src/providers/embedding/cohere.ts +46 -0
  179. package/src/providers/embedding/gemini.ts +54 -0
  180. package/src/providers/embedding/index.ts +39 -0
  181. package/src/providers/embedding/local.ts +52 -0
  182. package/src/providers/embedding/openai.ts +45 -0
  183. package/src/providers/embedding/openrouter.ts +51 -0
  184. package/src/providers/embedding/voyage.ts +46 -0
  185. package/src/providers/fallback-chain.ts +31 -0
  186. package/src/providers/index.ts +84 -0
  187. package/src/providers/openrouter.ts +71 -0
  188. package/src/providers/resilient.ts +37 -0
  189. package/src/state/hybrid-search.ts +295 -0
  190. package/src/state/index-persistence.ts +63 -0
  191. package/src/state/keyed-mutex.ts +18 -0
  192. package/src/state/kv.ts +33 -0
  193. package/src/state/schema.ts +71 -0
  194. package/src/state/search-index.ts +245 -0
  195. package/src/state/stemmer.ts +104 -0
  196. package/src/state/synonyms.ts +63 -0
  197. package/src/state/vector-index.ts +130 -0
  198. package/src/telemetry/setup.ts +116 -0
  199. package/src/triggers/api.ts +1904 -0
  200. package/src/triggers/events.ts +71 -0
  201. package/src/types.ts +769 -0
  202. package/src/version.ts +1 -0
  203. package/src/viewer/index.html +2497 -0
  204. package/src/viewer/server.ts +207 -0
  205. package/src/xenova.d.ts +3 -0
  206. package/test/actions.test.ts +490 -0
  207. package/test/audit.test.ts +108 -0
  208. package/test/auto-forget.test.ts +188 -0
  209. package/test/cascade.test.ts +277 -0
  210. package/test/checkpoints.test.ts +493 -0
  211. package/test/circuit-breaker.test.ts +107 -0
  212. package/test/claude-bridge.test.ts +178 -0
  213. package/test/confidence.test.ts +247 -0
  214. package/test/consistency.test.ts +61 -0
  215. package/test/consolidation-pipeline.test.ts +251 -0
  216. package/test/crystallize.test.ts +521 -0
  217. package/test/diagnostics.test.ts +638 -0
  218. package/test/embedding-provider.test.ts +49 -0
  219. package/test/enrich.test.ts +209 -0
  220. package/test/eval.test.ts +300 -0
  221. package/test/export-import.test.ts +251 -0
  222. package/test/facets.test.ts +448 -0
  223. package/test/fallback-chain.test.ts +93 -0
  224. package/test/frontier.test.ts +485 -0
  225. package/test/governance.test.ts +147 -0
  226. package/test/graph-retrieval.test.ts +186 -0
  227. package/test/graph.test.ts +160 -0
  228. package/test/helpers/mocks.ts +40 -0
  229. package/test/hybrid-search.test.ts +145 -0
  230. package/test/index-persistence.test.ts +124 -0
  231. package/test/integration.test.ts +265 -0
  232. package/test/leases.test.ts +399 -0
  233. package/test/mcp-prompts.test.ts +218 -0
  234. package/test/mcp-resources.test.ts +286 -0
  235. package/test/mcp-standalone.test.ts +113 -0
  236. package/test/mesh.test.ts +700 -0
  237. package/test/privacy.test.ts +87 -0
  238. package/test/profile.test.ts +161 -0
  239. package/test/query-expansion.test.ts +154 -0
  240. package/test/relations.test.ts +198 -0
  241. package/test/retention.test.ts +245 -0
  242. package/test/routines.test.ts +497 -0
  243. package/test/schema-fingerprint.test.ts +81 -0
  244. package/test/schema.test.ts +42 -0
  245. package/test/search-index.test.ts +128 -0
  246. package/test/sentinels.test.ts +626 -0
  247. package/test/signals.test.ts +410 -0
  248. package/test/sketches.test.ts +549 -0
  249. package/test/sliding-window.test.ts +199 -0
  250. package/test/smart-search.test.ts +169 -0
  251. package/test/snapshot.test.ts +165 -0
  252. package/test/team.test.ts +156 -0
  253. package/test/temporal-graph.test.ts +378 -0
  254. package/test/timeline.test.ts +148 -0
  255. package/test/vector-index.test.ts +79 -0
  256. package/test/verify.test.ts +209 -0
  257. package/test/xml.test.ts +65 -0
  258. package/tsconfig.json +22 -0
  259. package/tsdown.config.ts +62 -0
package/src/types.ts ADDED
@@ -0,0 +1,769 @@
1
+ export interface Session {
2
+ id: string;
3
+ project: string;
4
+ cwd: string;
5
+ startedAt: string;
6
+ endedAt?: string;
7
+ status: "active" | "completed" | "abandoned";
8
+ observationCount: number;
9
+ model?: string;
10
+ tags?: string[];
11
+ }
12
+
13
+ export interface RawObservation {
14
+ id: string;
15
+ sessionId: string;
16
+ timestamp: string;
17
+ hookType: HookType;
18
+ toolName?: string;
19
+ toolInput?: unknown;
20
+ toolOutput?: unknown;
21
+ userPrompt?: string;
22
+ assistantResponse?: string;
23
+ raw: unknown;
24
+ }
25
+
26
+ export interface CompressedObservation {
27
+ id: string;
28
+ sessionId: string;
29
+ timestamp: string;
30
+ type: ObservationType;
31
+ title: string;
32
+ subtitle?: string;
33
+ facts: string[];
34
+ narrative: string;
35
+ concepts: string[];
36
+ files: string[];
37
+ importance: number;
38
+ confidence?: number;
39
+ }
40
+
41
+ export type ObservationType =
42
+ | "file_read"
43
+ | "file_write"
44
+ | "file_edit"
45
+ | "command_run"
46
+ | "search"
47
+ | "web_fetch"
48
+ | "conversation"
49
+ | "error"
50
+ | "decision"
51
+ | "discovery"
52
+ | "subagent"
53
+ | "notification"
54
+ | "task"
55
+ | "other";
56
+
57
+ export interface Memory {
58
+ id: string;
59
+ createdAt: string;
60
+ updatedAt: string;
61
+ type: "pattern" | "preference" | "architecture" | "bug" | "workflow" | "fact";
62
+ title: string;
63
+ content: string;
64
+ concepts: string[];
65
+ files: string[];
66
+ sessionIds: string[];
67
+ strength: number;
68
+ version: number;
69
+ parentId?: string;
70
+ supersedes?: string[];
71
+ relatedIds?: string[];
72
+ sourceObservationIds?: string[];
73
+ isLatest: boolean;
74
+ forgetAfter?: string;
75
+ }
76
+
77
+ export interface SessionSummary {
78
+ sessionId: string;
79
+ project: string;
80
+ createdAt: string;
81
+ title: string;
82
+ narrative: string;
83
+ keyDecisions: string[];
84
+ filesModified: string[];
85
+ concepts: string[];
86
+ observationCount: number;
87
+ }
88
+
89
+ export type HookType =
90
+ | "session_start"
91
+ | "prompt_submit"
92
+ | "pre_tool_use"
93
+ | "post_tool_use"
94
+ | "post_tool_failure"
95
+ | "pre_compact"
96
+ | "subagent_start"
97
+ | "subagent_stop"
98
+ | "notification"
99
+ | "task_completed"
100
+ | "stop"
101
+ | "session_end";
102
+
103
+ export interface HookPayload {
104
+ hookType: HookType;
105
+ sessionId: string;
106
+ project: string;
107
+ cwd: string;
108
+ timestamp: string;
109
+ data: unknown;
110
+ }
111
+
112
+ export interface ProviderConfig {
113
+ provider: ProviderType;
114
+ model: string;
115
+ maxTokens: number;
116
+ }
117
+
118
+ export type ProviderType = "agent-sdk" | "anthropic" | "gemini" | "openrouter";
119
+
120
+ export interface MemoryProvider {
121
+ name: string;
122
+ compress(systemPrompt: string, userPrompt: string): Promise<string>;
123
+ summarize(systemPrompt: string, userPrompt: string): Promise<string>;
124
+ }
125
+
126
+ export interface AgentMemoryConfig {
127
+ engineUrl: string;
128
+ restPort: number;
129
+ streamsPort: number;
130
+ provider: ProviderConfig;
131
+ tokenBudget: number;
132
+ maxObservationsPerSession: number;
133
+ compressionModel: string;
134
+ dataDir: string;
135
+ }
136
+
137
+ export interface SearchResult {
138
+ observation: CompressedObservation;
139
+ score: number;
140
+ sessionId: string;
141
+ }
142
+
143
+ export interface ContextBlock {
144
+ type: "summary" | "observation" | "memory";
145
+ content: string;
146
+ tokens: number;
147
+ recency: number;
148
+ }
149
+
150
+ export interface EvalResult {
151
+ valid: boolean;
152
+ errors: string[];
153
+ qualityScore: number;
154
+ latencyMs: number;
155
+ functionId: string;
156
+ }
157
+
158
+ export interface FunctionMetrics {
159
+ functionId: string;
160
+ totalCalls: number;
161
+ successCount: number;
162
+ failureCount: number;
163
+ avgLatencyMs: number;
164
+ avgQualityScore: number;
165
+ }
166
+
167
+ export interface HealthSnapshot {
168
+ connectionState: string;
169
+ workers: Array<{ id: string; name: string; status: string }>;
170
+ memory: {
171
+ heapUsed: number;
172
+ heapTotal: number;
173
+ rss: number;
174
+ external: number;
175
+ };
176
+ cpu: { userMicros: number; systemMicros: number; percent: number };
177
+ eventLoopLagMs: number;
178
+ uptimeSeconds: number;
179
+ kvConnectivity?: { status: string; latencyMs?: number; error?: string };
180
+ status: "healthy" | "degraded" | "critical";
181
+ alerts: string[];
182
+ }
183
+
184
+ export interface CircuitBreakerState {
185
+ state: "closed" | "open" | "half-open";
186
+ failures: number;
187
+ lastFailureAt: number | null;
188
+ openedAt: number | null;
189
+ }
190
+
191
+ export interface EmbeddingProvider {
192
+ name: string;
193
+ dimensions: number;
194
+ embed(text: string): Promise<Float32Array>;
195
+ embedBatch(texts: string[]): Promise<Float32Array[]>;
196
+ }
197
+
198
+ export interface MemoryRelation {
199
+ type: "supersedes" | "extends" | "derives" | "contradicts" | "related";
200
+ sourceId: string;
201
+ targetId: string;
202
+ createdAt: string;
203
+ confidence?: number;
204
+ }
205
+
206
+ export interface HybridSearchResult {
207
+ observation: CompressedObservation;
208
+ bm25Score: number;
209
+ vectorScore: number;
210
+ graphScore: number;
211
+ combinedScore: number;
212
+ sessionId: string;
213
+ graphContext?: string;
214
+ }
215
+
216
+ export interface CompactSearchResult {
217
+ obsId: string;
218
+ sessionId: string;
219
+ title: string;
220
+ type: ObservationType;
221
+ score: number;
222
+ timestamp: string;
223
+ }
224
+
225
+ export interface TimelineEntry {
226
+ observation: CompressedObservation;
227
+ sessionId: string;
228
+ relativePosition: number;
229
+ }
230
+
231
+ export interface ProjectProfile {
232
+ project: string;
233
+ updatedAt: string;
234
+ topConcepts: Array<{ concept: string; frequency: number }>;
235
+ topFiles: Array<{ file: string; frequency: number }>;
236
+ conventions: string[];
237
+ commonErrors: string[];
238
+ recentActivity: string[];
239
+ sessionCount: number;
240
+ totalObservations: number;
241
+ summary?: string;
242
+ }
243
+
244
+ export interface ExportPagination {
245
+ offset: number;
246
+ limit: number;
247
+ total: number;
248
+ hasMore: boolean;
249
+ }
250
+
251
+ export interface ExportData {
252
+ version: "0.3.0" | "0.4.0" | "0.5.0" | "0.6.0" | "0.6.1" | "0.7.0";
253
+ exportedAt: string;
254
+ sessions: Session[];
255
+ observations: Record<string, CompressedObservation[]>;
256
+ memories: Memory[];
257
+ summaries: SessionSummary[];
258
+ profiles?: ProjectProfile[];
259
+ graphNodes?: GraphNode[];
260
+ graphEdges?: GraphEdge[];
261
+ semanticMemories?: SemanticMemory[];
262
+ proceduralMemories?: ProceduralMemory[];
263
+ actions?: Action[];
264
+ actionEdges?: ActionEdge[];
265
+ routines?: Routine[];
266
+ signals?: Signal[];
267
+ checkpoints?: Checkpoint[];
268
+ sentinels?: Sentinel[];
269
+ sketches?: Sketch[];
270
+ crystals?: Crystal[];
271
+ facets?: Facet[];
272
+ lessons?: Lesson[];
273
+ pagination?: ExportPagination;
274
+ }
275
+
276
+ export interface EmbeddingConfig {
277
+ provider?: string;
278
+ bm25Weight: number;
279
+ vectorWeight: number;
280
+ }
281
+
282
+ export interface FallbackConfig {
283
+ providers: ProviderType[];
284
+ }
285
+
286
+ export interface ClaudeBridgeConfig {
287
+ enabled: boolean;
288
+ projectPath: string;
289
+ memoryFilePath: string;
290
+ lineBudget: number;
291
+ }
292
+
293
+ export interface StandaloneConfig {
294
+ dataDir: string;
295
+ persistPath: string;
296
+ agentType?: string;
297
+ }
298
+
299
+ export type GraphNodeType =
300
+ | "file"
301
+ | "function"
302
+ | "concept"
303
+ | "error"
304
+ | "decision"
305
+ | "pattern"
306
+ | "library"
307
+ | "person"
308
+ | "project"
309
+ | "preference"
310
+ | "location"
311
+ | "organization"
312
+ | "event";
313
+
314
+ export interface GraphNode {
315
+ id: string;
316
+ type: GraphNodeType;
317
+ name: string;
318
+ properties: Record<string, unknown>;
319
+ sourceObservationIds: string[];
320
+ createdAt: string;
321
+ updatedAt?: string;
322
+ aliases?: string[];
323
+ stale?: boolean;
324
+ }
325
+
326
+ export type GraphEdgeType =
327
+ | "uses"
328
+ | "imports"
329
+ | "modifies"
330
+ | "causes"
331
+ | "fixes"
332
+ | "depends_on"
333
+ | "related_to"
334
+ | "works_at"
335
+ | "prefers"
336
+ | "blocked_by"
337
+ | "caused_by"
338
+ | "optimizes_for"
339
+ | "rejected"
340
+ | "avoids"
341
+ | "located_in"
342
+ | "succeeded_by";
343
+
344
+ export interface GraphEdge {
345
+ id: string;
346
+ type: GraphEdgeType;
347
+ sourceNodeId: string;
348
+ targetNodeId: string;
349
+ weight: number;
350
+ sourceObservationIds: string[];
351
+ createdAt: string;
352
+ tcommit?: string;
353
+ tvalid?: string;
354
+ tvalidEnd?: string;
355
+ context?: EdgeContext;
356
+ version?: number;
357
+ supersededBy?: string;
358
+ isLatest?: boolean;
359
+ stale?: boolean;
360
+ }
361
+
362
+ export interface EdgeContext {
363
+ reasoning?: string;
364
+ sentiment?: string;
365
+ alternatives?: string[];
366
+ situationalFactors?: string[];
367
+ confidence?: number;
368
+ }
369
+
370
+ export interface GraphQueryResult {
371
+ nodes: GraphNode[];
372
+ edges: GraphEdge[];
373
+ depth: number;
374
+ }
375
+
376
+ export type ConsolidationTier =
377
+ | "working"
378
+ | "episodic"
379
+ | "semantic"
380
+ | "procedural";
381
+
382
+ export interface SemanticMemory {
383
+ id: string;
384
+ fact: string;
385
+ confidence: number;
386
+ sourceSessionIds: string[];
387
+ sourceMemoryIds: string[];
388
+ accessCount: number;
389
+ lastAccessedAt: string;
390
+ strength: number;
391
+ createdAt: string;
392
+ updatedAt: string;
393
+ }
394
+
395
+ export interface ProceduralMemory {
396
+ id: string;
397
+ name: string;
398
+ steps: string[];
399
+ triggerCondition: string;
400
+ frequency: number;
401
+ sourceSessionIds: string[];
402
+ strength: number;
403
+ createdAt: string;
404
+ updatedAt: string;
405
+ }
406
+
407
+ export interface TeamConfig {
408
+ teamId: string;
409
+ userId: string;
410
+ mode: "shared" | "private";
411
+ }
412
+
413
+ export interface TeamSharedItem {
414
+ id: string;
415
+ sharedBy: string;
416
+ sharedAt: string;
417
+ type: "observation" | "memory" | "pattern";
418
+ content: unknown;
419
+ project: string;
420
+ visibility: "shared" | "private";
421
+ }
422
+
423
+ export interface TeamProfile {
424
+ teamId: string;
425
+ members: string[];
426
+ topConcepts: Array<{ concept: string; frequency: number }>;
427
+ topFiles: Array<{ file: string; frequency: number }>;
428
+ sharedPatterns: string[];
429
+ totalSharedItems: number;
430
+ updatedAt: string;
431
+ }
432
+
433
+ export interface AuditEntry {
434
+ id: string;
435
+ timestamp: string;
436
+ operation:
437
+ | "observe"
438
+ | "compress"
439
+ | "remember"
440
+ | "forget"
441
+ | "evolve"
442
+ | "consolidate"
443
+ | "share"
444
+ | "delete"
445
+ | "import"
446
+ | "export"
447
+ | "action_create"
448
+ | "action_update"
449
+ | "lease_acquire"
450
+ | "lease_release"
451
+ | "routine_run"
452
+ | "signal_send"
453
+ | "checkpoint_resolve"
454
+ | "mesh_sync"
455
+ | "sentinel_create"
456
+ | "sentinel_trigger"
457
+ | "sketch_create"
458
+ | "sketch_promote"
459
+ | "sketch_discard"
460
+ | "crystallize"
461
+ | "diagnose"
462
+ | "heal"
463
+ | "facet_tag"
464
+ | "lesson_save"
465
+ | "lesson_recall"
466
+ | "lesson_strengthen"
467
+ | "obsidian_export";
468
+ userId?: string;
469
+ functionId: string;
470
+ targetIds: string[];
471
+ details: Record<string, unknown>;
472
+ qualityScore?: number;
473
+ }
474
+
475
+ export interface GovernanceFilter {
476
+ type?: string[];
477
+ dateFrom?: string;
478
+ dateTo?: string;
479
+ project?: string;
480
+ qualityBelow?: number;
481
+ }
482
+
483
+ export interface SnapshotMeta {
484
+ id: string;
485
+ commitHash: string;
486
+ createdAt: string;
487
+ message: string;
488
+ stats: {
489
+ sessions: number;
490
+ observations: number;
491
+ memories: number;
492
+ graphNodes: number;
493
+ };
494
+ }
495
+
496
+ export interface SnapshotDiff {
497
+ fromCommit: string;
498
+ toCommit: string;
499
+ added: { memories: number; observations: number; graphNodes: number };
500
+ removed: { memories: number; observations: number; graphNodes: number };
501
+ }
502
+
503
+ export interface Action {
504
+ id: string;
505
+ title: string;
506
+ description: string;
507
+ status: "pending" | "active" | "done" | "blocked" | "cancelled";
508
+ priority: number;
509
+ createdAt: string;
510
+ updatedAt: string;
511
+ createdBy: string;
512
+ assignedTo?: string;
513
+ project?: string;
514
+ tags: string[];
515
+ sourceObservationIds: string[];
516
+ sourceMemoryIds: string[];
517
+ result?: string;
518
+ parentId?: string;
519
+ metadata?: Record<string, unknown>;
520
+ sketchId?: string;
521
+ crystallizedInto?: string;
522
+ }
523
+
524
+ export type ActionEdgeType =
525
+ | "requires"
526
+ | "unlocks"
527
+ | "spawned_by"
528
+ | "gated_by"
529
+ | "conflicts_with";
530
+
531
+ export interface ActionEdge {
532
+ id: string;
533
+ type: ActionEdgeType;
534
+ sourceActionId: string;
535
+ targetActionId: string;
536
+ createdAt: string;
537
+ metadata?: Record<string, unknown>;
538
+ }
539
+
540
+ export interface Lease {
541
+ id: string;
542
+ actionId: string;
543
+ agentId: string;
544
+ acquiredAt: string;
545
+ expiresAt: string;
546
+ renewedAt?: string;
547
+ status: "active" | "expired" | "released";
548
+ }
549
+
550
+ export interface Routine {
551
+ id: string;
552
+ name: string;
553
+ description: string;
554
+ steps: RoutineStep[];
555
+ createdAt: string;
556
+ updatedAt: string;
557
+ frozen: boolean;
558
+ tags: string[];
559
+ sourceProceduralIds: string[];
560
+ }
561
+
562
+ export interface RoutineStep {
563
+ order: number;
564
+ title: string;
565
+ description: string;
566
+ actionTemplate: Partial<Action>;
567
+ dependsOn: number[];
568
+ }
569
+
570
+ export interface RoutineRun {
571
+ id: string;
572
+ routineId: string;
573
+ status: "running" | "completed" | "failed" | "paused";
574
+ startedAt: string;
575
+ completedAt?: string;
576
+ actionIds: string[];
577
+ stepStatus: Record<number, "pending" | "active" | "done" | "failed">;
578
+ initiatedBy: string;
579
+ }
580
+
581
+ export interface Signal {
582
+ id: string;
583
+ from: string;
584
+ to?: string;
585
+ threadId?: string;
586
+ replyTo?: string;
587
+ type: "info" | "request" | "response" | "alert" | "handoff";
588
+ content: string;
589
+ metadata?: Record<string, unknown>;
590
+ createdAt: string;
591
+ readAt?: string;
592
+ expiresAt?: string;
593
+ }
594
+
595
+ export interface Checkpoint {
596
+ id: string;
597
+ name: string;
598
+ description: string;
599
+ status: "pending" | "passed" | "failed" | "expired";
600
+ type: "ci" | "approval" | "deploy" | "external" | "timer";
601
+ createdAt: string;
602
+ resolvedAt?: string;
603
+ resolvedBy?: string;
604
+ result?: unknown;
605
+ expiresAt?: string;
606
+ linkedActionIds: string[];
607
+ }
608
+
609
+ export interface Sketch {
610
+ id: string;
611
+ title: string;
612
+ description: string;
613
+ status: "active" | "promoted" | "discarded";
614
+ actionIds: string[];
615
+ project?: string;
616
+ createdAt: string;
617
+ expiresAt: string;
618
+ promotedAt?: string;
619
+ discardedAt?: string;
620
+ }
621
+
622
+ export interface Facet {
623
+ id: string;
624
+ targetId: string;
625
+ targetType: "action" | "memory" | "observation";
626
+ dimension: string;
627
+ value: string;
628
+ createdAt: string;
629
+ }
630
+
631
+ export interface Sentinel {
632
+ id: string;
633
+ name: string;
634
+ type: "webhook" | "timer" | "threshold" | "pattern" | "approval" | "custom";
635
+ status: "watching" | "triggered" | "cancelled" | "expired";
636
+ config: Record<string, unknown>;
637
+ result?: unknown;
638
+ createdAt: string;
639
+ triggeredAt?: string;
640
+ expiresAt?: string;
641
+ linkedActionIds: string[];
642
+ escalatedAt?: string;
643
+ }
644
+
645
+ export interface Crystal {
646
+ id: string;
647
+ narrative: string;
648
+ keyOutcomes: string[];
649
+ filesAffected: string[];
650
+ lessons: string[];
651
+ sourceActionIds: string[];
652
+ sessionId?: string;
653
+ project?: string;
654
+ createdAt: string;
655
+ }
656
+
657
+ export interface Lesson {
658
+ id: string;
659
+ content: string;
660
+ context: string;
661
+ confidence: number;
662
+ reinforcements: number;
663
+ source: "crystal" | "manual" | "consolidation";
664
+ sourceIds: string[];
665
+ project?: string;
666
+ tags: string[];
667
+ createdAt: string;
668
+ updatedAt: string;
669
+ lastReinforcedAt?: string;
670
+ lastDecayedAt?: string;
671
+ decayRate: number;
672
+ deleted?: boolean;
673
+ }
674
+
675
+ export interface DiagnosticCheck {
676
+ name: string;
677
+ category: string;
678
+ status: "pass" | "warn" | "fail";
679
+ message: string;
680
+ fixable: boolean;
681
+ }
682
+
683
+ export interface MeshPeer {
684
+ id: string;
685
+ url: string;
686
+ name: string;
687
+ lastSyncAt?: string;
688
+ status: "connected" | "disconnected" | "syncing" | "error";
689
+ sharedScopes: string[];
690
+ syncFilter?: { project?: string };
691
+ }
692
+
693
+
694
+ export interface EnrichedChunk {
695
+ id: string;
696
+ originalObsId: string;
697
+ sessionId: string;
698
+ content: string;
699
+ resolvedEntities: Record<string, string>;
700
+ preferences: string[];
701
+ contextBridges: string[];
702
+ windowStart: number;
703
+ windowEnd: number;
704
+ createdAt: string;
705
+ }
706
+
707
+ export interface LatentEmbedding {
708
+ obsId: string;
709
+ contentEmbedding: string;
710
+ latentEmbedding: string;
711
+ sessionId: string;
712
+ }
713
+
714
+ export interface QueryExpansion {
715
+ original: string;
716
+ reformulations: string[];
717
+ temporalConcretizations: string[];
718
+ entityExtractions: string[];
719
+ }
720
+
721
+ export interface TripleStreamResult {
722
+ observation: CompressedObservation;
723
+ vectorScore: number;
724
+ bm25Score: number;
725
+ graphScore: number;
726
+ combinedScore: number;
727
+ sessionId: string;
728
+ graphContext?: string;
729
+ }
730
+
731
+ export interface TemporalQuery {
732
+ entityName: string;
733
+ asOf?: string;
734
+ from?: string;
735
+ to?: string;
736
+ includeHistory?: boolean;
737
+ }
738
+
739
+ export interface TemporalState {
740
+ entity: GraphNode;
741
+ currentEdges: GraphEdge[];
742
+ historicalEdges: GraphEdge[];
743
+ timeline: Array<{
744
+ edge: GraphEdge;
745
+ validFrom: string;
746
+ validTo?: string;
747
+ context?: EdgeContext;
748
+ }>;
749
+ }
750
+
751
+ export interface RetentionScore {
752
+ memoryId: string;
753
+ score: number;
754
+ salience: number;
755
+ temporalDecay: number;
756
+ reinforcementBoost: number;
757
+ lastAccessed: string;
758
+ accessCount: number;
759
+ }
760
+
761
+ export interface DecayConfig {
762
+ lambda: number;
763
+ sigma: number;
764
+ tierThresholds: {
765
+ hot: number;
766
+ warm: number;
767
+ cold: number;
768
+ };
769
+ }