@synth-coder/memhub 0.2.2 → 0.2.3

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 (71) hide show
  1. package/.eslintrc.cjs +45 -45
  2. package/.factory/commands/opsx-apply.md +150 -0
  3. package/.factory/commands/opsx-archive.md +155 -0
  4. package/.factory/commands/opsx-explore.md +171 -0
  5. package/.factory/commands/opsx-propose.md +104 -0
  6. package/.factory/skills/openspec-apply-change/SKILL.md +156 -0
  7. package/.factory/skills/openspec-archive-change/SKILL.md +114 -0
  8. package/.factory/skills/openspec-explore/SKILL.md +288 -0
  9. package/.factory/skills/openspec-propose/SKILL.md +110 -0
  10. package/.github/workflows/ci.yml +74 -74
  11. package/.iflow/commands/opsx-apply.md +152 -152
  12. package/.iflow/commands/opsx-archive.md +157 -157
  13. package/.iflow/commands/opsx-explore.md +173 -173
  14. package/.iflow/commands/opsx-propose.md +106 -106
  15. package/.iflow/skills/openspec-apply-change/SKILL.md +156 -156
  16. package/.iflow/skills/openspec-archive-change/SKILL.md +114 -114
  17. package/.iflow/skills/openspec-explore/SKILL.md +288 -288
  18. package/.iflow/skills/openspec-propose/SKILL.md +110 -110
  19. package/.prettierrc +11 -11
  20. package/AGENTS.md +169 -26
  21. package/README.md +195 -195
  22. package/README.zh-CN.md +193 -193
  23. package/dist/src/contracts/mcp.js +34 -34
  24. package/dist/src/server/mcp-server.d.ts +8 -0
  25. package/dist/src/server/mcp-server.d.ts.map +1 -1
  26. package/dist/src/server/mcp-server.js +23 -2
  27. package/dist/src/server/mcp-server.js.map +1 -1
  28. package/dist/src/services/memory-service.d.ts +1 -0
  29. package/dist/src/services/memory-service.d.ts.map +1 -1
  30. package/dist/src/services/memory-service.js +125 -82
  31. package/dist/src/services/memory-service.js.map +1 -1
  32. package/docs/architecture-diagrams.md +368 -0
  33. package/docs/architecture.md +381 -349
  34. package/docs/contracts.md +190 -119
  35. package/docs/prompt-template.md +33 -79
  36. package/docs/proposals/mcp-typescript-sdk-refactor.md +568 -568
  37. package/docs/proposals/proposal-close-gates.md +58 -58
  38. package/docs/tool-calling-policy.md +101 -107
  39. package/docs/vector-search.md +306 -0
  40. package/package.json +59 -58
  41. package/src/contracts/index.ts +12 -12
  42. package/src/contracts/mcp.ts +222 -222
  43. package/src/contracts/schemas.ts +307 -307
  44. package/src/contracts/types.ts +410 -410
  45. package/src/index.ts +8 -8
  46. package/src/server/index.ts +5 -5
  47. package/src/server/mcp-server.ts +185 -161
  48. package/src/services/embedding-service.ts +114 -114
  49. package/src/services/index.ts +5 -5
  50. package/src/services/memory-service.ts +663 -621
  51. package/src/storage/frontmatter-parser.ts +243 -243
  52. package/src/storage/index.ts +6 -6
  53. package/src/storage/markdown-storage.ts +236 -236
  54. package/src/storage/vector-index.ts +160 -160
  55. package/src/utils/index.ts +5 -5
  56. package/src/utils/slugify.ts +63 -63
  57. package/test/contracts/schemas.test.ts +313 -313
  58. package/test/contracts/types.test.ts +21 -21
  59. package/test/frontmatter-parser-more.test.ts +94 -94
  60. package/test/server/mcp-server.test.ts +210 -169
  61. package/test/services/memory-service-edge.test.ts +248 -248
  62. package/test/services/memory-service.test.ts +278 -278
  63. package/test/storage/frontmatter-parser.test.ts +222 -222
  64. package/test/storage/markdown-storage.test.ts +216 -216
  65. package/test/storage/storage-edge.test.ts +238 -238
  66. package/test/storage/vector-index.test.ts +153 -153
  67. package/test/utils/slugify-edge.test.ts +94 -94
  68. package/test/utils/slugify.test.ts +68 -68
  69. package/tsconfig.json +25 -25
  70. package/tsconfig.test.json +8 -8
  71. package/vitest.config.ts +29 -29
@@ -1,307 +1,307 @@
1
- /**
2
- * Zod schemas for runtime validation
3
- * All schemas correspond to types defined in types.ts
4
- */
5
-
6
- import { z } from 'zod';
7
-
8
- // ============================================================================
9
- // Primitive Schemas
10
- // ============================================================================
11
-
12
- /** UUID v4 validation schema */
13
- export const UUIDSchema = z.string().uuid().brand<'UUID'>();
14
-
15
- /** ISO 8601 timestamp validation */
16
- export const ISO8601TimestampSchema = z.string().datetime().brand<'ISO8601'>();
17
-
18
- /** Slug validation (URL-friendly string) */
19
- export const SlugSchema = z
20
- .string()
21
- .min(1)
22
- .max(100)
23
- .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, 'Must be a valid URL slug');
24
-
25
- /** Tag name validation */
26
- export const TagSchema = z
27
- .string()
28
- .min(1)
29
- .max(50)
30
- .regex(/^[a-z0-9-]+$/, 'Tags can only contain lowercase letters, numbers, and hyphens');
31
-
32
- /** Category name validation */
33
- export const CategorySchema = z
34
- .string()
35
- .min(1)
36
- .max(50)
37
- .regex(/^[a-z0-9-]+$/, 'Category can only contain lowercase letters, numbers, and hyphens');
38
-
39
- /** Importance level validation (1-5) */
40
- export const ImportanceSchema = z.number().int().min(1).max(5);
41
-
42
- /** STM memory entry type */
43
- export const MemoryEntryTypeSchema = z.enum([
44
- 'preference', // User likes/dislikes
45
- 'decision', // Technical choices with reasoning
46
- 'context', // Project/environment information
47
- 'fact', // Objective knowledge
48
- ]);
49
-
50
- // ============================================================================
51
- // Memory Schemas
52
- // ============================================================================
53
-
54
- /** Memory front matter schema (YAML portion) */
55
- export const MemoryFrontMatterSchema = z.object({
56
- id: UUIDSchema,
57
- created_at: ISO8601TimestampSchema,
58
- updated_at: ISO8601TimestampSchema,
59
- session_id: UUIDSchema.optional(),
60
- entry_type: MemoryEntryTypeSchema.optional(),
61
- tags: z.array(TagSchema).default([]),
62
- category: CategorySchema.default('general'),
63
- importance: ImportanceSchema.default(3),
64
- });
65
-
66
- /** Complete memory schema */
67
- export const MemorySchema = z.object({
68
- id: UUIDSchema,
69
- createdAt: ISO8601TimestampSchema,
70
- updatedAt: ISO8601TimestampSchema,
71
- sessionId: UUIDSchema.optional(),
72
- entryType: MemoryEntryTypeSchema.optional(),
73
- tags: z.array(z.string()).readonly(),
74
- category: CategorySchema,
75
- importance: ImportanceSchema,
76
- title: z.string().min(1).max(200),
77
- content: z.string().max(100000),
78
- });
79
-
80
- /** Memory file schema */
81
- export const MemoryFileSchema = z.object({
82
- path: z.string().min(1),
83
- filename: z.string().min(1),
84
- content: z.string(),
85
- modifiedAt: ISO8601TimestampSchema,
86
- });
87
-
88
- // ============================================================================
89
- // Result Schemas
90
- // ============================================================================
91
-
92
- /** Search result schema */
93
- export const SearchResultSchema = z.object({
94
- memory: MemorySchema,
95
- score: z.number().min(0).max(1),
96
- matches: z.array(z.string()),
97
- });
98
-
99
- /** List result schema */
100
- export const ListResultSchema = z.object({
101
- memories: z.array(MemorySchema),
102
- total: z.number().int().nonnegative(),
103
- hasMore: z.boolean(),
104
- });
105
-
106
- /** Create result schema */
107
- export const CreateResultSchema = z.object({
108
- id: UUIDSchema,
109
- filePath: z.string().min(1),
110
- memory: MemorySchema,
111
- });
112
-
113
- /** Update result schema */
114
- export const UpdateResultSchema = z.object({
115
- memory: MemorySchema,
116
- });
117
-
118
- /** Delete result schema */
119
- export const DeleteResultSchema = z.object({
120
- success: z.boolean(),
121
- filePath: z.string().min(1),
122
- });
123
-
124
- // ============================================================================
125
- // Filter and Query Schemas
126
- // ============================================================================
127
-
128
- /** Sort field enum */
129
- export const SortFieldSchema = z.enum(['createdAt', 'updatedAt', 'title', 'importance']);
130
-
131
- /** Sort order enum */
132
- export const SortOrderSchema = z.enum(['asc', 'desc']);
133
-
134
- /** Memory filter schema */
135
- export const MemoryFilterSchema = z.object({
136
- category: CategorySchema.optional(),
137
- tags: z.array(TagSchema).optional(),
138
- fromDate: ISO8601TimestampSchema.optional(),
139
- toDate: ISO8601TimestampSchema.optional(),
140
- });
141
-
142
- /** Pagination options schema */
143
- export const PaginationOptionsSchema = z.object({
144
- limit: z.number().int().min(1).max(100).default(20),
145
- offset: z.number().int().min(0).default(0),
146
- });
147
-
148
- /** Sort options schema */
149
- export const SortOptionsSchema = z.object({
150
- sortBy: SortFieldSchema.default('createdAt'),
151
- sortOrder: SortOrderSchema.default('desc'),
152
- });
153
-
154
- // ============================================================================
155
- // MCP Tool Input Schemas
156
- // ============================================================================
157
-
158
- /** Create memory input schema */
159
- export const CreateMemoryInputSchema = z.object({
160
- title: z.string().min(1).max(200),
161
- content: z.string().max(100000),
162
- tags: z.array(TagSchema).default([]),
163
- category: CategorySchema.default('general'),
164
- importance: ImportanceSchema.default(3),
165
- });
166
-
167
- /** Read memory input schema */
168
- export const ReadMemoryInputSchema = z.object({
169
- id: UUIDSchema,
170
- });
171
-
172
- /** Update memory input schema */
173
- export const UpdateMemoryInputSchema = z.object({
174
- id: UUIDSchema,
175
- title: z.string().min(1).max(200).optional(),
176
- content: z.string().max(100000).optional(),
177
- tags: z.array(TagSchema).optional(),
178
- category: CategorySchema.optional(),
179
- importance: ImportanceSchema.optional(),
180
- });
181
-
182
- /** Delete memory input schema */
183
- export const DeleteMemoryInputSchema = z.object({
184
- id: UUIDSchema,
185
- });
186
-
187
- /** List memory input schema */
188
- export const ListMemoryInputSchema = z.object({
189
- category: CategorySchema.optional(),
190
- tags: z.array(TagSchema).optional(),
191
- fromDate: ISO8601TimestampSchema.optional(),
192
- toDate: ISO8601TimestampSchema.optional(),
193
- limit: z.number().int().min(1).max(100).optional(),
194
- offset: z.number().int().min(0).optional(),
195
- sortBy: SortFieldSchema.optional(),
196
- sortOrder: SortOrderSchema.optional(),
197
- });
198
-
199
- /** Search memory input schema */
200
- export const SearchMemoryInputSchema = z.object({
201
- query: z.string().min(1).max(1000),
202
- limit: z.number().int().min(1).max(100).optional(),
203
- category: CategorySchema.optional(),
204
- tags: z.array(TagSchema).optional(),
205
- });
206
-
207
- /** memory_load input schema */
208
- export const MemoryLoadInputSchema = z.object({
209
- id: UUIDSchema.optional(),
210
- query: z.string().min(1).max(1000).optional(),
211
- category: CategorySchema.optional(),
212
- tags: z.array(TagSchema).optional(),
213
- limit: z.number().int().min(1).max(100).optional(),
214
- });
215
-
216
- /** memory_update (upsert/append) input schema */
217
- export const MemoryUpdateInputV2Schema = z.object({
218
- id: UUIDSchema.optional(),
219
- sessionId: UUIDSchema.optional(),
220
- mode: z.enum(['append', 'upsert']).default('append'),
221
- entryType: MemoryEntryTypeSchema.optional(),
222
- title: z.string().min(1).max(200).optional(),
223
- content: z.string().min(1).max(100000),
224
- tags: z.array(TagSchema).optional(),
225
- category: CategorySchema.optional(),
226
- importance: ImportanceSchema.optional(),
227
- });
228
-
229
- // ============================================================================
230
- // MCP Tool Output Schemas
231
- // ============================================================================
232
-
233
- /** Create memory output schema */
234
- export const CreateMemoryOutputSchema = CreateResultSchema;
235
-
236
- /** Read memory output schema */
237
- export const ReadMemoryOutputSchema = z.object({
238
- memory: MemorySchema,
239
- });
240
-
241
- /** Update memory output schema */
242
- export const UpdateMemoryOutputSchema = UpdateResultSchema;
243
-
244
- export const MemoryLoadOutputSchema = z.object({
245
- items: z.array(MemorySchema),
246
- total: z.number().int().nonnegative(),
247
- });
248
-
249
- export const MemoryUpdateOutputSchema = z.object({
250
- id: UUIDSchema,
251
- sessionId: UUIDSchema,
252
- filePath: z.string().min(1),
253
- created: z.boolean(),
254
- updated: z.boolean(),
255
- memory: MemorySchema,
256
- });
257
-
258
- /** Delete memory output schema */
259
- export const DeleteMemoryOutputSchema = DeleteResultSchema;
260
-
261
- /** List memory output schema */
262
- export const ListMemoryOutputSchema = ListResultSchema;
263
-
264
- /** Search memory output schema */
265
- export const SearchMemoryOutputSchema = z.object({
266
- results: z.array(SearchResultSchema),
267
- total: z.number().int().nonnegative(),
268
- });
269
-
270
- /** Get categories output schema */
271
- export const GetCategoriesOutputSchema = z.object({
272
- categories: z.array(CategorySchema),
273
- });
274
-
275
- /** Get tags output schema */
276
- export const GetTagsOutputSchema = z.object({
277
- tags: z.array(TagSchema),
278
- });
279
-
280
- // ============================================================================
281
- // Configuration Schemas
282
- // ============================================================================
283
-
284
- /** Configuration schema */
285
- export const ConfigSchema = z.object({
286
- storagePath: z.string().min(1),
287
- logLevel: z.enum(['debug', 'info', 'warn', 'error']).default('info'),
288
- });
289
-
290
- // ============================================================================
291
- // Type Extraction from Schemas
292
- // ============================================================================
293
-
294
- /** Inferred Memory type from schema */
295
- export type MemoryFromSchema = z.infer<typeof MemorySchema>;
296
-
297
- /** Inferred CreateInput type from schema */
298
- export type CreateMemoryInputFromSchema = z.infer<typeof CreateMemoryInputSchema>;
299
-
300
- /** Inferred UpdateInput type from schema */
301
- export type UpdateMemoryInputFromSchema = z.infer<typeof UpdateMemoryInputSchema>;
302
-
303
- /** Inferred ListInput type from schema */
304
- export type ListMemoryInputFromSchema = z.infer<typeof ListMemoryInputSchema>;
305
-
306
- /** Inferred SearchInput type from schema */
307
- export type SearchMemoryInputFromSchema = z.infer<typeof SearchMemoryInputSchema>;
1
+ /**
2
+ * Zod schemas for runtime validation
3
+ * All schemas correspond to types defined in types.ts
4
+ */
5
+
6
+ import { z } from 'zod';
7
+
8
+ // ============================================================================
9
+ // Primitive Schemas
10
+ // ============================================================================
11
+
12
+ /** UUID v4 validation schema */
13
+ export const UUIDSchema = z.string().uuid().brand<'UUID'>();
14
+
15
+ /** ISO 8601 timestamp validation */
16
+ export const ISO8601TimestampSchema = z.string().datetime().brand<'ISO8601'>();
17
+
18
+ /** Slug validation (URL-friendly string) */
19
+ export const SlugSchema = z
20
+ .string()
21
+ .min(1)
22
+ .max(100)
23
+ .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, 'Must be a valid URL slug');
24
+
25
+ /** Tag name validation */
26
+ export const TagSchema = z
27
+ .string()
28
+ .min(1)
29
+ .max(50)
30
+ .regex(/^[a-z0-9-]+$/, 'Tags can only contain lowercase letters, numbers, and hyphens');
31
+
32
+ /** Category name validation */
33
+ export const CategorySchema = z
34
+ .string()
35
+ .min(1)
36
+ .max(50)
37
+ .regex(/^[a-z0-9-]+$/, 'Category can only contain lowercase letters, numbers, and hyphens');
38
+
39
+ /** Importance level validation (1-5) */
40
+ export const ImportanceSchema = z.number().int().min(1).max(5);
41
+
42
+ /** STM memory entry type */
43
+ export const MemoryEntryTypeSchema = z.enum([
44
+ 'preference', // User likes/dislikes
45
+ 'decision', // Technical choices with reasoning
46
+ 'context', // Project/environment information
47
+ 'fact', // Objective knowledge
48
+ ]);
49
+
50
+ // ============================================================================
51
+ // Memory Schemas
52
+ // ============================================================================
53
+
54
+ /** Memory front matter schema (YAML portion) */
55
+ export const MemoryFrontMatterSchema = z.object({
56
+ id: UUIDSchema,
57
+ created_at: ISO8601TimestampSchema,
58
+ updated_at: ISO8601TimestampSchema,
59
+ session_id: UUIDSchema.optional(),
60
+ entry_type: MemoryEntryTypeSchema.optional(),
61
+ tags: z.array(TagSchema).default([]),
62
+ category: CategorySchema.default('general'),
63
+ importance: ImportanceSchema.default(3),
64
+ });
65
+
66
+ /** Complete memory schema */
67
+ export const MemorySchema = z.object({
68
+ id: UUIDSchema,
69
+ createdAt: ISO8601TimestampSchema,
70
+ updatedAt: ISO8601TimestampSchema,
71
+ sessionId: UUIDSchema.optional(),
72
+ entryType: MemoryEntryTypeSchema.optional(),
73
+ tags: z.array(z.string()).readonly(),
74
+ category: CategorySchema,
75
+ importance: ImportanceSchema,
76
+ title: z.string().min(1).max(200),
77
+ content: z.string().max(100000),
78
+ });
79
+
80
+ /** Memory file schema */
81
+ export const MemoryFileSchema = z.object({
82
+ path: z.string().min(1),
83
+ filename: z.string().min(1),
84
+ content: z.string(),
85
+ modifiedAt: ISO8601TimestampSchema,
86
+ });
87
+
88
+ // ============================================================================
89
+ // Result Schemas
90
+ // ============================================================================
91
+
92
+ /** Search result schema */
93
+ export const SearchResultSchema = z.object({
94
+ memory: MemorySchema,
95
+ score: z.number().min(0).max(1),
96
+ matches: z.array(z.string()),
97
+ });
98
+
99
+ /** List result schema */
100
+ export const ListResultSchema = z.object({
101
+ memories: z.array(MemorySchema),
102
+ total: z.number().int().nonnegative(),
103
+ hasMore: z.boolean(),
104
+ });
105
+
106
+ /** Create result schema */
107
+ export const CreateResultSchema = z.object({
108
+ id: UUIDSchema,
109
+ filePath: z.string().min(1),
110
+ memory: MemorySchema,
111
+ });
112
+
113
+ /** Update result schema */
114
+ export const UpdateResultSchema = z.object({
115
+ memory: MemorySchema,
116
+ });
117
+
118
+ /** Delete result schema */
119
+ export const DeleteResultSchema = z.object({
120
+ success: z.boolean(),
121
+ filePath: z.string().min(1),
122
+ });
123
+
124
+ // ============================================================================
125
+ // Filter and Query Schemas
126
+ // ============================================================================
127
+
128
+ /** Sort field enum */
129
+ export const SortFieldSchema = z.enum(['createdAt', 'updatedAt', 'title', 'importance']);
130
+
131
+ /** Sort order enum */
132
+ export const SortOrderSchema = z.enum(['asc', 'desc']);
133
+
134
+ /** Memory filter schema */
135
+ export const MemoryFilterSchema = z.object({
136
+ category: CategorySchema.optional(),
137
+ tags: z.array(TagSchema).optional(),
138
+ fromDate: ISO8601TimestampSchema.optional(),
139
+ toDate: ISO8601TimestampSchema.optional(),
140
+ });
141
+
142
+ /** Pagination options schema */
143
+ export const PaginationOptionsSchema = z.object({
144
+ limit: z.number().int().min(1).max(100).default(20),
145
+ offset: z.number().int().min(0).default(0),
146
+ });
147
+
148
+ /** Sort options schema */
149
+ export const SortOptionsSchema = z.object({
150
+ sortBy: SortFieldSchema.default('createdAt'),
151
+ sortOrder: SortOrderSchema.default('desc'),
152
+ });
153
+
154
+ // ============================================================================
155
+ // MCP Tool Input Schemas
156
+ // ============================================================================
157
+
158
+ /** Create memory input schema */
159
+ export const CreateMemoryInputSchema = z.object({
160
+ title: z.string().min(1).max(200),
161
+ content: z.string().max(100000),
162
+ tags: z.array(TagSchema).default([]),
163
+ category: CategorySchema.default('general'),
164
+ importance: ImportanceSchema.default(3),
165
+ });
166
+
167
+ /** Read memory input schema */
168
+ export const ReadMemoryInputSchema = z.object({
169
+ id: UUIDSchema,
170
+ });
171
+
172
+ /** Update memory input schema */
173
+ export const UpdateMemoryInputSchema = z.object({
174
+ id: UUIDSchema,
175
+ title: z.string().min(1).max(200).optional(),
176
+ content: z.string().max(100000).optional(),
177
+ tags: z.array(TagSchema).optional(),
178
+ category: CategorySchema.optional(),
179
+ importance: ImportanceSchema.optional(),
180
+ });
181
+
182
+ /** Delete memory input schema */
183
+ export const DeleteMemoryInputSchema = z.object({
184
+ id: UUIDSchema,
185
+ });
186
+
187
+ /** List memory input schema */
188
+ export const ListMemoryInputSchema = z.object({
189
+ category: CategorySchema.optional(),
190
+ tags: z.array(TagSchema).optional(),
191
+ fromDate: ISO8601TimestampSchema.optional(),
192
+ toDate: ISO8601TimestampSchema.optional(),
193
+ limit: z.number().int().min(1).max(100).optional(),
194
+ offset: z.number().int().min(0).optional(),
195
+ sortBy: SortFieldSchema.optional(),
196
+ sortOrder: SortOrderSchema.optional(),
197
+ });
198
+
199
+ /** Search memory input schema */
200
+ export const SearchMemoryInputSchema = z.object({
201
+ query: z.string().min(1).max(1000),
202
+ limit: z.number().int().min(1).max(100).optional(),
203
+ category: CategorySchema.optional(),
204
+ tags: z.array(TagSchema).optional(),
205
+ });
206
+
207
+ /** memory_load input schema */
208
+ export const MemoryLoadInputSchema = z.object({
209
+ id: UUIDSchema.optional(),
210
+ query: z.string().min(1).max(1000).optional(),
211
+ category: CategorySchema.optional(),
212
+ tags: z.array(TagSchema).optional(),
213
+ limit: z.number().int().min(1).max(100).optional(),
214
+ });
215
+
216
+ /** memory_update (upsert/append) input schema */
217
+ export const MemoryUpdateInputV2Schema = z.object({
218
+ id: UUIDSchema.optional(),
219
+ sessionId: UUIDSchema.optional(),
220
+ mode: z.enum(['append', 'upsert']).default('append'),
221
+ entryType: MemoryEntryTypeSchema.optional(),
222
+ title: z.string().min(1).max(200).optional(),
223
+ content: z.string().min(1).max(100000),
224
+ tags: z.array(TagSchema).optional(),
225
+ category: CategorySchema.optional(),
226
+ importance: ImportanceSchema.optional(),
227
+ });
228
+
229
+ // ============================================================================
230
+ // MCP Tool Output Schemas
231
+ // ============================================================================
232
+
233
+ /** Create memory output schema */
234
+ export const CreateMemoryOutputSchema = CreateResultSchema;
235
+
236
+ /** Read memory output schema */
237
+ export const ReadMemoryOutputSchema = z.object({
238
+ memory: MemorySchema,
239
+ });
240
+
241
+ /** Update memory output schema */
242
+ export const UpdateMemoryOutputSchema = UpdateResultSchema;
243
+
244
+ export const MemoryLoadOutputSchema = z.object({
245
+ items: z.array(MemorySchema),
246
+ total: z.number().int().nonnegative(),
247
+ });
248
+
249
+ export const MemoryUpdateOutputSchema = z.object({
250
+ id: UUIDSchema,
251
+ sessionId: UUIDSchema,
252
+ filePath: z.string().min(1),
253
+ created: z.boolean(),
254
+ updated: z.boolean(),
255
+ memory: MemorySchema,
256
+ });
257
+
258
+ /** Delete memory output schema */
259
+ export const DeleteMemoryOutputSchema = DeleteResultSchema;
260
+
261
+ /** List memory output schema */
262
+ export const ListMemoryOutputSchema = ListResultSchema;
263
+
264
+ /** Search memory output schema */
265
+ export const SearchMemoryOutputSchema = z.object({
266
+ results: z.array(SearchResultSchema),
267
+ total: z.number().int().nonnegative(),
268
+ });
269
+
270
+ /** Get categories output schema */
271
+ export const GetCategoriesOutputSchema = z.object({
272
+ categories: z.array(CategorySchema),
273
+ });
274
+
275
+ /** Get tags output schema */
276
+ export const GetTagsOutputSchema = z.object({
277
+ tags: z.array(TagSchema),
278
+ });
279
+
280
+ // ============================================================================
281
+ // Configuration Schemas
282
+ // ============================================================================
283
+
284
+ /** Configuration schema */
285
+ export const ConfigSchema = z.object({
286
+ storagePath: z.string().min(1),
287
+ logLevel: z.enum(['debug', 'info', 'warn', 'error']).default('info'),
288
+ });
289
+
290
+ // ============================================================================
291
+ // Type Extraction from Schemas
292
+ // ============================================================================
293
+
294
+ /** Inferred Memory type from schema */
295
+ export type MemoryFromSchema = z.infer<typeof MemorySchema>;
296
+
297
+ /** Inferred CreateInput type from schema */
298
+ export type CreateMemoryInputFromSchema = z.infer<typeof CreateMemoryInputSchema>;
299
+
300
+ /** Inferred UpdateInput type from schema */
301
+ export type UpdateMemoryInputFromSchema = z.infer<typeof UpdateMemoryInputSchema>;
302
+
303
+ /** Inferred ListInput type from schema */
304
+ export type ListMemoryInputFromSchema = z.infer<typeof ListMemoryInputSchema>;
305
+
306
+ /** Inferred SearchInput type from schema */
307
+ export type SearchMemoryInputFromSchema = z.infer<typeof SearchMemoryInputSchema>;