@synth-coder/memhub 0.2.3 → 0.2.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 (118) hide show
  1. package/.github/workflows/ci.yml +48 -12
  2. package/.github/workflows/release.yml +70 -0
  3. package/AGENTS.md +71 -73
  4. package/README.md +284 -195
  5. package/README.zh-CN.md +90 -30
  6. package/dist/src/cli/agents/claude-code.d.ts +5 -0
  7. package/dist/src/cli/agents/claude-code.d.ts.map +1 -0
  8. package/dist/src/cli/agents/claude-code.js +14 -0
  9. package/dist/src/cli/agents/claude-code.js.map +1 -0
  10. package/dist/src/cli/agents/cline.d.ts +5 -0
  11. package/dist/src/cli/agents/cline.d.ts.map +1 -0
  12. package/dist/src/cli/agents/cline.js +14 -0
  13. package/dist/src/cli/agents/cline.js.map +1 -0
  14. package/dist/src/cli/agents/cursor.d.ts +5 -0
  15. package/dist/src/cli/agents/cursor.d.ts.map +1 -0
  16. package/dist/src/cli/agents/cursor.js +14 -0
  17. package/dist/src/cli/agents/cursor.js.map +1 -0
  18. package/dist/src/cli/agents/factory-droid.d.ts +5 -0
  19. package/dist/src/cli/agents/factory-droid.d.ts.map +1 -0
  20. package/dist/src/cli/agents/factory-droid.js +14 -0
  21. package/dist/src/cli/agents/factory-droid.js.map +1 -0
  22. package/dist/src/cli/agents/gemini-cli.d.ts +5 -0
  23. package/dist/src/cli/agents/gemini-cli.d.ts.map +1 -0
  24. package/dist/src/cli/agents/gemini-cli.js +14 -0
  25. package/dist/src/cli/agents/gemini-cli.js.map +1 -0
  26. package/dist/src/cli/agents/index.d.ts +13 -0
  27. package/dist/src/cli/agents/index.d.ts.map +1 -0
  28. package/dist/src/cli/agents/index.js +27 -0
  29. package/dist/src/cli/agents/index.js.map +1 -0
  30. package/dist/src/cli/agents/windsurf.d.ts +5 -0
  31. package/dist/src/cli/agents/windsurf.d.ts.map +1 -0
  32. package/dist/src/cli/agents/windsurf.js +14 -0
  33. package/dist/src/cli/agents/windsurf.js.map +1 -0
  34. package/dist/src/cli/index.d.ts +8 -0
  35. package/dist/src/cli/index.d.ts.map +1 -0
  36. package/dist/src/cli/index.js +168 -0
  37. package/dist/src/cli/index.js.map +1 -0
  38. package/dist/src/cli/init.d.ts +34 -0
  39. package/dist/src/cli/init.d.ts.map +1 -0
  40. package/dist/src/cli/init.js +140 -0
  41. package/dist/src/cli/init.js.map +1 -0
  42. package/dist/src/cli/instructions.d.ts +29 -0
  43. package/dist/src/cli/instructions.d.ts.map +1 -0
  44. package/dist/src/cli/instructions.js +141 -0
  45. package/dist/src/cli/instructions.js.map +1 -0
  46. package/dist/src/cli/types.d.ts +22 -0
  47. package/dist/src/cli/types.d.ts.map +1 -0
  48. package/dist/src/cli/types.js +75 -0
  49. package/dist/src/cli/types.js.map +1 -0
  50. package/dist/src/contracts/mcp.js +34 -34
  51. package/dist/src/contracts/schemas.js.map +1 -1
  52. package/dist/src/server/mcp-server.d.ts.map +1 -1
  53. package/dist/src/server/mcp-server.js +7 -14
  54. package/dist/src/server/mcp-server.js.map +1 -1
  55. package/dist/src/services/embedding-service.d.ts.map +1 -1
  56. package/dist/src/services/embedding-service.js +1 -1
  57. package/dist/src/services/embedding-service.js.map +1 -1
  58. package/dist/src/services/memory-service.d.ts.map +1 -1
  59. package/dist/src/services/memory-service.js.map +1 -1
  60. package/dist/src/storage/markdown-storage.d.ts.map +1 -1
  61. package/dist/src/storage/markdown-storage.js +1 -1
  62. package/dist/src/storage/markdown-storage.js.map +1 -1
  63. package/dist/src/storage/vector-index.d.ts.map +1 -1
  64. package/dist/src/storage/vector-index.js +4 -5
  65. package/dist/src/storage/vector-index.js.map +1 -1
  66. package/docs/README.md +21 -0
  67. package/docs/mcp-tools.md +136 -0
  68. package/docs/user-guide.md +184 -0
  69. package/package.json +61 -59
  70. package/src/cli/agents/claude-code.ts +14 -0
  71. package/src/cli/agents/cline.ts +14 -0
  72. package/src/cli/agents/codex.ts +14 -0
  73. package/src/cli/agents/cursor.ts +14 -0
  74. package/src/cli/agents/factory-droid.ts +14 -0
  75. package/src/cli/agents/gemini-cli.ts +14 -0
  76. package/src/cli/agents/index.ts +36 -0
  77. package/src/cli/agents/windsurf.ts +14 -0
  78. package/src/cli/index.ts +192 -0
  79. package/src/cli/init.ts +218 -0
  80. package/src/cli/instructions.ts +156 -0
  81. package/src/cli/types.ts +112 -0
  82. package/src/contracts/index.ts +12 -12
  83. package/src/contracts/mcp.ts +223 -223
  84. package/src/contracts/schemas.ts +307 -307
  85. package/src/contracts/types.ts +410 -410
  86. package/src/index.ts +8 -8
  87. package/src/server/index.ts +5 -5
  88. package/src/server/mcp-server.ts +169 -186
  89. package/src/services/embedding-service.ts +114 -114
  90. package/src/services/index.ts +5 -5
  91. package/src/services/memory-service.ts +656 -663
  92. package/src/storage/frontmatter-parser.ts +243 -243
  93. package/src/storage/index.ts +6 -6
  94. package/src/storage/markdown-storage.ts +228 -236
  95. package/src/storage/vector-index.ts +159 -160
  96. package/src/utils/index.ts +5 -5
  97. package/src/utils/slugify.ts +63 -63
  98. package/test/cli/init.test.ts +402 -0
  99. package/test/contracts/schemas.test.ts +313 -313
  100. package/test/contracts/types.test.ts +21 -21
  101. package/test/frontmatter-parser-more.test.ts +94 -94
  102. package/test/server/mcp-server.test.ts +211 -210
  103. package/test/services/memory-service-edge.test.ts +248 -248
  104. package/test/services/memory-service.test.ts +291 -279
  105. package/test/storage/frontmatter-parser.test.ts +223 -223
  106. package/test/storage/markdown-storage.test.ts +226 -217
  107. package/test/storage/storage-edge.test.ts +238 -238
  108. package/test/storage/vector-index.test.ts +149 -153
  109. package/test/utils/slugify-edge.test.ts +94 -94
  110. package/test/utils/slugify.test.ts +72 -68
  111. package/docs/architecture-diagrams.md +0 -368
  112. package/docs/architecture.md +0 -381
  113. package/docs/contracts.md +0 -190
  114. package/docs/prompt-template.md +0 -33
  115. package/docs/proposals/mcp-typescript-sdk-refactor.md +0 -568
  116. package/docs/proposals/proposal-close-gates.md +0 -58
  117. package/docs/tool-calling-policy.md +0 -101
  118. package/docs/vector-search.md +0 -306
@@ -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>;