-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemory_api_openapi.json
More file actions
536 lines (536 loc) · 18.2 KB
/
memory_api_openapi.json
File metadata and controls
536 lines (536 loc) · 18.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
{
"openapi": "3.1.0",
"info": {
"title": "Persistent Memory API (Cloudflare Worker)",
"description": "Stores, retrieves, updates, and deletes persistent memories via Cloudflare KV. Includes AI summarization and placeholders for advanced features.",
"version": "1.0.0"
},
"servers": [
{
"url": "https://your-worker-subdomain.your-account.workers.dev",
"description": "Replace with your deployed Cloudflare Worker URL"
}
],
"paths": {
"/store-memory": {
"post": {
"summary": "Store a memory item",
"operationId": "storeMemory",
"tags": ["Memory"],
"requestBody": {
"description": "Memory item details",
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"user_id": {
"type": "string",
"description": "Identifier for the user."
},
"category": {
"type": "string",
"description": "Category to store the memory under."
},
"message": {
"type": "string",
"description": "The content of the memory."
},
"priority": {
"type": "integer",
"description": "Priority level (e.g., 1-5).",
"default": 2
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"description": "Optional list of tags.",
"default": []
}
},
"required": ["user_id", "category", "message"]
}
}
}
},
"responses": {
"201": {
"description": "Memory stored successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"status": { "type": "string" },
"memory_id": { "type": "string" },
"data": { "$ref": "#/components/schemas/MemoryItem" }
}
}
}
}
},
"400": { "description": "Bad Request - Missing parameters or invalid types" },
"500": { "description": "Internal Server Error - Failed to store memory" }
}
}
},
"/retrieve-memory": {
"get": {
"summary": "Retrieve memories by category",
"operationId": "retrieveMemoryByCategory",
"tags": ["Memory"],
"parameters": [
{ "$ref": "#/components/parameters/UserIdQuery" },
{ "$ref": "#/components/parameters/CategoryQueryRequired" },
{ "$ref": "#/components/parameters/LimitQuery" },
{ "$ref": "#/components/parameters/OffsetQuery" },
{ "$ref": "#/components/parameters/TagQuery" },
{ "$ref": "#/components/parameters/SortByQuery" },
{ "$ref": "#/components/parameters/SortOrderQuery" }
],
"responses": {
"200": {
"description": "List of memories in the specified category",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/MemoryListResponse" }
}
}
},
"400": { "description": "Bad Request - Missing parameters or invalid sort options" },
"500": { "description": "Internal Server Error - Failed to retrieve memories" }
}
}
},
"/retrieve-all-memories": {
"get": {
"summary": "Retrieve all memories for a user",
"operationId": "retrieveAllMemories",
"tags": ["Memory"],
"parameters": [
{ "$ref": "#/components/parameters/UserIdQuery" },
{ "$ref": "#/components/parameters/LimitQueryAll" },
{ "$ref": "#/components/parameters/OffsetQuery" },
{ "$ref": "#/components/parameters/TagQuery" },
{ "$ref": "#/components/parameters/SearchQuery" },
{ "$ref": "#/components/parameters/SortByQueryAll" },
{ "$ref": "#/components/parameters/SortOrderQueryDesc" }
],
"responses": {
"200": {
"description": "List of all memories for the user, optionally filtered and sorted",
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/AllMemoryListResponse" }
}
}
},
"400": { "description": "Bad Request - Missing parameters or invalid sort options" },
"500": { "description": "Internal Server Error - Failed to retrieve memories" }
}
}
},
"/update-memory": {
"patch": {
"summary": "Update a specific memory item",
"operationId": "updateMemory",
"tags": ["Memory"],
"requestBody": {
"description": "Fields to update for a specific memory item, identified by memory_id.",
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"user_id": {
"type": "string",
"description": "Identifier for the user."
},
"category": {
"type": "string",
"description": "Category containing the memory."
},
"memory_id": {
"type": "string",
"description": "The unique ID of the memory item to update."
},
"new_message": {
"type": "string",
"description": "Optional new content for the memory."
},
"new_priority": {
"type": "integer",
"description": "Optional new priority level."
},
"new_tags": {
"type": "array",
"items": { "type": "string" },
"description": "Optional new list of tags (replaces existing tags)."
}
},
"required": ["user_id", "category", "memory_id"]
}
}
}
},
"responses": {
"200": {
"description": "Memory updated successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"status": { "type": "string" },
"data": { "$ref": "#/components/schemas/MemoryItem" }
}
}
}
}
},
"400": { "description": "Bad Request - Missing parameters, invalid types, or no update fields provided" },
"404": { "description": "Not Found - Category or Memory ID not found" },
"500": { "description": "Internal Server Error - Failed to update memory" }
}
}
},
"/forget-memory": {
"delete": {
"summary": "Delete memory data",
"description": "Deletes a specific memory item (if memory_id provided), an entire category (if only category provided), or all data for a user (if only user_id provided).",
"operationId": "forgetMemory",
"tags": ["Memory"],
"parameters": [
{ "$ref": "#/components/parameters/UserIdQuery" },
{ "$ref": "#/components/parameters/CategoryQueryOptional" },
{ "$ref": "#/components/parameters/MemoryIdQuery" }
],
"responses": {
"200": {
"description": "Deletion successful",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"status": { "type": "string" }
}
}
}
}
},
"400": { "description": "Bad Request - Missing user_id or invalid parameter combination" },
"404": { "description": "Not Found - Category or Memory ID not found for deletion" },
"500": { "description": "Internal Server Error - Failed to delete memory" }
}
}
},
"/retrieve-memory-summary": {
"get": {
"summary": "Get AI summary of memories",
"operationId": "retrieveMemorySummary",
"tags": ["AI Features"],
"parameters": [
{ "$ref": "#/components/parameters/UserIdQuery" },
{ "$ref": "#/components/parameters/CategoryQueryOptional" }
],
"responses": {
"200": {
"description": "AI-generated summary",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"summary": { "type": "string" }
}
}
}
}
},
"400": { "description": "Bad Request - Missing user_id" },
"404": { "description": "Not Found - Category not found" },
"500": { "description": "Internal Server Error - Failed to generate summary" },
"501": { "description": "Not Implemented - Summarization feature not configured" },
"502": { "description": "Bad Gateway - OpenAI API call failed"}
}
}
},
"/retrieve-memory-semantic": {
"get": {
"summary": "Semantic search for memories (Placeholder)",
"operationId": "retrieveMemorySemantic",
"tags": ["AI Features", "Placeholders"],
"parameters": [
{ "$ref": "#/components/parameters/UserIdQuery" },
{
"name": "query",
"in": "query",
"required": true,
"schema": { "type": "string" },
"description": "The text query for semantic search."
}
],
"responses": {
"501": { "description": "Not Implemented" }
}
}
},
"/auto-link-memory": {
"post": {
"summary": "Auto-link memory to external tasks (Placeholder)",
"operationId": "autoLinkMemory",
"tags": ["AI Features", "Placeholders"],
"requestBody": {
"description": "Details for auto-linking",
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"user_id": { "type": "string" },
"message": { "type": "string" }
},
"required": ["user_id", "message"]
}
}
}
},
"responses": {
"501": { "description": "Not Implemented" }
}
}
},
"/trigger-memory-action": {
"post": {
"summary": "Trigger an action based on a memory (Placeholder)",
"operationId": "triggerMemoryAction",
"tags": ["AI Features", "Placeholders"],
"requestBody": {
"description": "Details for triggering an action",
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"user_id": { "type": "string" },
"memory_id": { "type": "string" },
"action": { "type": "string" }
},
"required": ["user_id", "memory_id", "action"]
}
}
}
},
"responses": {
"501": { "description": "Not Implemented" }
}
}
}
},
"components": {
"schemas": {
"MemoryMetadata": {
"type": "object",
"properties": {
"created_at": {
"type": "string",
"format": "date-time",
"description": "Timestamp when the memory item was created."
},
"last_modified": {
"type": "string",
"format": "date-time",
"description": "Timestamp when the memory item was last updated."
}
}
},
"MemoryItem": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "Unique identifier for the memory item."
},
"timestamp": {
"type": "string",
"format": "date-time",
"description": "Timestamp associated with the memory content (usually creation time)."
},
"message": {
"type": "string",
"description": "The content of the memory."
},
"priority": {
"type": "integer",
"description": "Priority level."
},
"tags": {
"type": "array",
"items": { "type": "string" },
"description": "List of tags associated with the memory."
},
"metadata": {
"$ref": "#/components/schemas/MemoryMetadata"
}
}
},
"MemoryItemWithCategory": {
"allOf": [
{ "$ref": "#/components/schemas/MemoryItem" },
{
"type": "object",
"properties": {
"category": {
"type": "string",
"description": "The category this memory belongs to."
}
}
}
]
},
"MemoryListResponse": {
"type": "object",
"properties": {
"history": {
"type": "array",
"items": { "$ref": "#/components/schemas/MemoryItem" }
},
"total": { "type": "integer", "description": "Total number of items matching the filter in this category." },
"limit": { "type": "integer", "description": "The limit used for pagination." },
"offset": { "type": "integer", "description": "The offset used for pagination." },
"remaining": { "type": "integer", "description": "Estimated number of items remaining after this page." }
}
},
"AllMemoryListResponse": {
"type": "object",
"properties": {
"memories": {
"type": "array",
"items": { "$ref": "#/components/schemas/MemoryItemWithCategory" }
},
"total": { "type": "integer", "description": "Total number of items matching the filter across all categories." },
"limit": { "type": "integer", "description": "The limit used for pagination (0 if no limit)." },
"offset": { "type": "integer", "description": "The offset used for pagination." },
"remaining": { "type": "integer", "description": "Estimated number of items remaining after this page (0 if no limit)." }
}
}
},
"parameters": {
"UserIdQuery": {
"name": "user_id",
"in": "query",
"required": true,
"schema": { "type": "string" },
"description": "Identifier for the user."
},
"CategoryQueryRequired": {
"name": "category",
"in": "query",
"required": true,
"schema": { "type": "string" },
"description": "The category to query."
},
"CategoryQueryOptional": {
"name": "category",
"in": "query",
"required": false,
"schema": { "type": "string" },
"description": "Optional category to filter by."
},
"MemoryIdQuery": {
"name": "memory_id",
"in": "query",
"required": false,
"schema": { "type": "string", "format": "uuid" },
"description": "The unique ID of a specific memory item."
},
"LimitQuery": {
"name": "limit",
"in": "query",
"required": false,
"schema": { "type": "integer", "default": 100, "minimum": 1 },
"description": "Maximum number of items to return."
},
"LimitQueryAll": {
"name": "limit",
"in": "query",
"required": false,
"schema": { "type": "integer", "default": 0, "minimum": 0 },
"description": "Maximum number of items to return (0 for no limit)."
},
"OffsetQuery": {
"name": "offset",
"in": "query",
"required": false,
"schema": { "type": "integer", "default": 0, "minimum": 0 },
"description": "Number of items to skip for pagination."
},
"TagQuery": {
"name": "tag",
"in": "query",
"required": false,
"schema": { "type": "string" },
"description": "Filter memories by a specific tag."
},
"SearchQuery": {
"name": "search",
"in": "query",
"required": false,
"schema": { "type": "string" },
"description": "Search term to filter memories by message content (case-insensitive)."
},
"SortByQuery": {
"name": "sort_by",
"in": "query",
"required": false,
"schema": {
"type": "string",
"enum": ["priority", "timestamp", "message", "created_at"],
"default": "priority"
},
"description": "Field to sort memories by."
},
"SortByQueryAll": {
"name": "sort_by",
"in": "query",
"required": false,
"schema": {
"type": "string",
"enum": ["priority", "timestamp", "message", "category", "created_at"],
"default": "timestamp"
},
"description": "Field to sort memories by."
},
"SortOrderQuery": {
"name": "sort_order",
"in": "query",
"required": false,
"schema": {
"type": "string",
"enum": ["asc", "desc"],
"default": "asc"
},
"description": "Sort order: ascending or descending."
},
"SortOrderQueryDesc": {
"name": "sort_order",
"in": "query",
"required": false,
"schema": {
"type": "string",
"enum": ["asc", "desc"],
"default": "desc"
},
"description": "Sort order: ascending or descending."
}
}
}
}