simple-memory-mcp 1.1.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.
- package/LICENSE +21 -0
- package/README.md +742 -0
- package/dist/cli/arg-parser.d.ts +9 -0
- package/dist/cli/arg-parser.d.ts.map +1 -0
- package/dist/cli/arg-parser.js +68 -0
- package/dist/cli/arg-parser.js.map +1 -0
- package/dist/cli/help-generator.d.ts +8 -0
- package/dist/cli/help-generator.d.ts.map +1 -0
- package/dist/cli/help-generator.js +89 -0
- package/dist/cli/help-generator.js.map +1 -0
- package/dist/cli/index.d.ts +27 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +56 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/query-builder.d.ts +8 -0
- package/dist/cli/query-builder.d.ts.map +1 -0
- package/dist/cli/query-builder.js +63 -0
- package/dist/cli/query-builder.js.map +1 -0
- package/dist/cli/shortcuts-config.d.ts +26 -0
- package/dist/cli/shortcuts-config.d.ts.map +1 -0
- package/dist/cli/shortcuts-config.js +94 -0
- package/dist/cli/shortcuts-config.js.map +1 -0
- package/dist/graphql/resolvers.d.ts +101 -0
- package/dist/graphql/resolvers.d.ts.map +1 -0
- package/dist/graphql/resolvers.js +98 -0
- package/dist/graphql/resolvers.js.map +1 -0
- package/dist/graphql/schema.d.ts +13 -0
- package/dist/graphql/schema.d.ts.map +1 -0
- package/dist/graphql/schema.js +314 -0
- package/dist/graphql/schema.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +573 -0
- package/dist/index.js.map +1 -0
- package/dist/services/backup-service.d.ts +57 -0
- package/dist/services/backup-service.d.ts.map +1 -0
- package/dist/services/backup-service.js +191 -0
- package/dist/services/backup-service.js.map +1 -0
- package/dist/services/database-optimizer.d.ts +15 -0
- package/dist/services/database-optimizer.d.ts.map +1 -0
- package/dist/services/database-optimizer.js +45 -0
- package/dist/services/database-optimizer.js.map +1 -0
- package/dist/services/memory-service.d.ts +126 -0
- package/dist/services/memory-service.d.ts.map +1 -0
- package/dist/services/memory-service.js +862 -0
- package/dist/services/memory-service.js.map +1 -0
- package/dist/services/migrations.d.ts +17 -0
- package/dist/services/migrations.d.ts.map +1 -0
- package/dist/services/migrations.js +273 -0
- package/dist/services/migrations.js.map +1 -0
- package/dist/tests/backup-export-test.d.ts +2 -0
- package/dist/tests/backup-export-test.d.ts.map +1 -0
- package/dist/tests/backup-export-test.js +162 -0
- package/dist/tests/backup-export-test.js.map +1 -0
- package/dist/tests/backup-test.d.ts +14 -0
- package/dist/tests/backup-test.d.ts.map +1 -0
- package/dist/tests/backup-test.js +209 -0
- package/dist/tests/backup-test.js.map +1 -0
- package/dist/tests/export-import-test.d.ts +15 -0
- package/dist/tests/export-import-test.d.ts.map +1 -0
- package/dist/tests/export-import-test.js +227 -0
- package/dist/tests/export-import-test.js.map +1 -0
- package/dist/tests/graphql-comprehensive-test.d.ts +6 -0
- package/dist/tests/graphql-comprehensive-test.d.ts.map +1 -0
- package/dist/tests/graphql-comprehensive-test.js +342 -0
- package/dist/tests/graphql-comprehensive-test.js.map +1 -0
- package/dist/tests/graphql-performance-test.d.ts +6 -0
- package/dist/tests/graphql-performance-test.d.ts.map +1 -0
- package/dist/tests/graphql-performance-test.js +141 -0
- package/dist/tests/graphql-performance-test.js.map +1 -0
- package/dist/tests/graphql-test.d.ts +5 -0
- package/dist/tests/graphql-test.d.ts.map +1 -0
- package/dist/tests/graphql-test.js +47 -0
- package/dist/tests/graphql-test.js.map +1 -0
- package/dist/tests/memory-server-tests.d.ts +7 -0
- package/dist/tests/memory-server-tests.d.ts.map +1 -0
- package/dist/tests/memory-server-tests.js +466 -0
- package/dist/tests/memory-server-tests.js.map +1 -0
- package/dist/tests/migration-test.d.ts +2 -0
- package/dist/tests/migration-test.d.ts.map +1 -0
- package/dist/tests/migration-test.js +270 -0
- package/dist/tests/migration-test.js.map +1 -0
- package/dist/tests/performance-benchmark.d.ts +7 -0
- package/dist/tests/performance-benchmark.d.ts.map +1 -0
- package/dist/tests/performance-benchmark.js +234 -0
- package/dist/tests/performance-benchmark.js.map +1 -0
- package/dist/tests/performance-test.d.ts +3 -0
- package/dist/tests/performance-test.d.ts.map +1 -0
- package/dist/tests/performance-test.js +61 -0
- package/dist/tests/performance-test.js.map +1 -0
- package/dist/tests/time-range-test.d.ts +7 -0
- package/dist/tests/time-range-test.d.ts.map +1 -0
- package/dist/tests/time-range-test.js +169 -0
- package/dist/tests/time-range-test.js.map +1 -0
- package/dist/tools/delete-memory/cli-parser.d.ts +2 -0
- package/dist/tools/delete-memory/cli-parser.d.ts.map +1 -0
- package/dist/tools/delete-memory/cli-parser.js +13 -0
- package/dist/tools/delete-memory/cli-parser.js.map +1 -0
- package/dist/tools/delete-memory/executor.d.ts +13 -0
- package/dist/tools/delete-memory/executor.d.ts.map +1 -0
- package/dist/tools/delete-memory/executor.js +40 -0
- package/dist/tools/delete-memory/executor.js.map +1 -0
- package/dist/tools/delete-memory/index.d.ts +3 -0
- package/dist/tools/delete-memory/index.d.ts.map +1 -0
- package/dist/tools/delete-memory/index.js +24 -0
- package/dist/tools/delete-memory/index.js.map +1 -0
- package/dist/tools/export-memory/cli-parser.d.ts +2 -0
- package/dist/tools/export-memory/cli-parser.d.ts.map +1 -0
- package/dist/tools/export-memory/cli-parser.js +34 -0
- package/dist/tools/export-memory/cli-parser.js.map +1 -0
- package/dist/tools/export-memory/executor.d.ts +10 -0
- package/dist/tools/export-memory/executor.d.ts.map +1 -0
- package/dist/tools/export-memory/executor.js +41 -0
- package/dist/tools/export-memory/executor.js.map +1 -0
- package/dist/tools/export-memory/index.d.ts +4 -0
- package/dist/tools/export-memory/index.d.ts.map +1 -0
- package/dist/tools/export-memory/index.js +99 -0
- package/dist/tools/export-memory/index.js.map +1 -0
- package/dist/tools/import-memory/cli-parser.d.ts +2 -0
- package/dist/tools/import-memory/cli-parser.d.ts.map +1 -0
- package/dist/tools/import-memory/cli-parser.js +25 -0
- package/dist/tools/import-memory/cli-parser.js.map +1 -0
- package/dist/tools/import-memory/executor.d.ts +8 -0
- package/dist/tools/import-memory/executor.d.ts.map +1 -0
- package/dist/tools/import-memory/executor.js +31 -0
- package/dist/tools/import-memory/executor.js.map +1 -0
- package/dist/tools/import-memory/index.d.ts +4 -0
- package/dist/tools/import-memory/index.d.ts.map +1 -0
- package/dist/tools/import-memory/index.js +70 -0
- package/dist/tools/import-memory/index.js.map +1 -0
- package/dist/tools/index.d.ts +14 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +48 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/memory-graphql/cli-parser.d.ts +6 -0
- package/dist/tools/memory-graphql/cli-parser.d.ts.map +1 -0
- package/dist/tools/memory-graphql/cli-parser.js +24 -0
- package/dist/tools/memory-graphql/cli-parser.js.map +1 -0
- package/dist/tools/memory-graphql/executor.d.ts +18 -0
- package/dist/tools/memory-graphql/executor.d.ts.map +1 -0
- package/dist/tools/memory-graphql/executor.js +53 -0
- package/dist/tools/memory-graphql/executor.js.map +1 -0
- package/dist/tools/memory-graphql/index.d.ts +3 -0
- package/dist/tools/memory-graphql/index.d.ts.map +1 -0
- package/dist/tools/memory-graphql/index.js +73 -0
- package/dist/tools/memory-graphql/index.js.map +1 -0
- package/dist/tools/memory-stats/cli-parser.d.ts +2 -0
- package/dist/tools/memory-stats/cli-parser.d.ts.map +1 -0
- package/dist/tools/memory-stats/cli-parser.js +8 -0
- package/dist/tools/memory-stats/cli-parser.js.map +1 -0
- package/dist/tools/memory-stats/executor.d.ts +4 -0
- package/dist/tools/memory-stats/executor.d.ts.map +1 -0
- package/dist/tools/memory-stats/executor.js +4 -0
- package/dist/tools/memory-stats/executor.js.map +1 -0
- package/dist/tools/memory-stats/index.d.ts +3 -0
- package/dist/tools/memory-stats/index.d.ts.map +1 -0
- package/dist/tools/memory-stats/index.js +15 -0
- package/dist/tools/memory-stats/index.js.map +1 -0
- package/dist/tools/search-memory/cli-parser.d.ts +2 -0
- package/dist/tools/search-memory/cli-parser.d.ts.map +1 -0
- package/dist/tools/search-memory/cli-parser.js +56 -0
- package/dist/tools/search-memory/cli-parser.js.map +1 -0
- package/dist/tools/search-memory/executor.d.ts +36 -0
- package/dist/tools/search-memory/executor.d.ts.map +1 -0
- package/dist/tools/search-memory/executor.js +83 -0
- package/dist/tools/search-memory/executor.js.map +1 -0
- package/dist/tools/search-memory/index.d.ts +3 -0
- package/dist/tools/search-memory/index.d.ts.map +1 -0
- package/dist/tools/search-memory/index.js +89 -0
- package/dist/tools/search-memory/index.js.map +1 -0
- package/dist/tools/store-memory/cli-parser.d.ts +2 -0
- package/dist/tools/store-memory/cli-parser.d.ts.map +1 -0
- package/dist/tools/store-memory/cli-parser.js +21 -0
- package/dist/tools/store-memory/cli-parser.js.map +1 -0
- package/dist/tools/store-memory/executor.d.ts +16 -0
- package/dist/tools/store-memory/executor.d.ts.map +1 -0
- package/dist/tools/store-memory/executor.js +100 -0
- package/dist/tools/store-memory/executor.js.map +1 -0
- package/dist/tools/store-memory/index.d.ts +3 -0
- package/dist/tools/store-memory/index.d.ts.map +1 -0
- package/dist/tools/store-memory/index.js +68 -0
- package/dist/tools/store-memory/index.js.map +1 -0
- package/dist/tools/sync-memory/cli-parser.d.ts +1 -0
- package/dist/tools/sync-memory/cli-parser.d.ts.map +1 -0
- package/dist/tools/sync-memory/cli-parser.js +2 -0
- package/dist/tools/sync-memory/cli-parser.js.map +1 -0
- package/dist/tools/sync-memory/executor.d.ts +1 -0
- package/dist/tools/sync-memory/executor.d.ts.map +1 -0
- package/dist/tools/sync-memory/executor.js +2 -0
- package/dist/tools/sync-memory/executor.js.map +1 -0
- package/dist/tools/sync-memory/index.d.ts +1 -0
- package/dist/tools/sync-memory/index.d.ts.map +1 -0
- package/dist/tools/sync-memory/index.js +2 -0
- package/dist/tools/sync-memory/index.js.map +1 -0
- package/dist/tools/update-memory/cli-parser.d.ts +2 -0
- package/dist/tools/update-memory/cli-parser.d.ts.map +1 -0
- package/dist/tools/update-memory/cli-parser.js +17 -0
- package/dist/tools/update-memory/cli-parser.js.map +1 -0
- package/dist/tools/update-memory/executor.d.ts +16 -0
- package/dist/tools/update-memory/executor.d.ts.map +1 -0
- package/dist/tools/update-memory/executor.js +59 -0
- package/dist/tools/update-memory/executor.js.map +1 -0
- package/dist/tools/update-memory/index.d.ts +3 -0
- package/dist/tools/update-memory/index.d.ts.map +1 -0
- package/dist/tools/update-memory/index.js +30 -0
- package/dist/tools/update-memory/index.js.map +1 -0
- package/dist/transports/streamable-http.d.ts +38 -0
- package/dist/transports/streamable-http.d.ts.map +1 -0
- package/dist/transports/streamable-http.js +209 -0
- package/dist/transports/streamable-http.js.map +1 -0
- package/dist/types/tools.d.ts +79 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +3 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/utils/cli-parser.d.ts +12 -0
- package/dist/utils/cli-parser.d.ts.map +1 -0
- package/dist/utils/cli-parser.js +43 -0
- package/dist/utils/cli-parser.js.map +1 -0
- package/dist/utils/config.d.ts +95 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +176 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/db-integrity-check.d.ts +22 -0
- package/dist/utils/db-integrity-check.d.ts.map +1 -0
- package/dist/utils/db-integrity-check.js +69 -0
- package/dist/utils/db-integrity-check.js.map +1 -0
- package/dist/utils/debug.d.ts +25 -0
- package/dist/utils/debug.d.ts.map +1 -0
- package/dist/utils/debug.js +67 -0
- package/dist/utils/debug.js.map +1 -0
- package/dist/utils/help-generator.d.ts +18 -0
- package/dist/utils/help-generator.d.ts.map +1 -0
- package/dist/utils/help-generator.js +81 -0
- package/dist/utils/help-generator.js.map +1 -0
- package/dist/utils/json-parser.d.ts +12 -0
- package/dist/utils/json-parser.d.ts.map +1 -0
- package/dist/utils/json-parser.js +52 -0
- package/dist/utils/json-parser.js.map +1 -0
- package/dist/utils/mcp-config.d.ts +12 -0
- package/dist/utils/mcp-config.d.ts.map +1 -0
- package/dist/utils/mcp-config.js +64 -0
- package/dist/utils/mcp-config.js.map +1 -0
- package/dist/web-server.d.ts +3 -0
- package/dist/web-server.d.ts.map +1 -0
- package/dist/web-server.js +265 -0
- package/dist/web-server.js.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/search-memory/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAIjD,eAAO,MAAM,gBAAgB,EAAE,IAqF9B,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { execute } from './executor.js';
|
|
2
|
+
import { parseCliArgs } from './cli-parser.js';
|
|
3
|
+
export const searchMemoryTool = {
|
|
4
|
+
definition: {
|
|
5
|
+
name: 'search-memory',
|
|
6
|
+
description: `Search stored memories by content or tags, with optional relationship traversal.
|
|
7
|
+
|
|
8
|
+
💡 PROACTIVE USAGE: Search memories at the START of conversations or when relevant topics arise to provide personalized, context-aware responses.
|
|
9
|
+
|
|
10
|
+
When to search:
|
|
11
|
+
• Beginning of new conversation - check for relevant context
|
|
12
|
+
• User asks about their preferences or past decisions
|
|
13
|
+
• Discussing topics that might have stored information
|
|
14
|
+
• Before making recommendations - check what user likes/dislikes
|
|
15
|
+
• When user mentions a person, project, or tool previously discussed
|
|
16
|
+
|
|
17
|
+
Search silently and incorporate findings naturally into responses.`,
|
|
18
|
+
inputSchema: {
|
|
19
|
+
type: 'object',
|
|
20
|
+
properties: {
|
|
21
|
+
hash: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
description: 'Retrieve a specific memory by its MD5 hash (32 char hex). When provided, ignores all other search parameters.'
|
|
24
|
+
},
|
|
25
|
+
query: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
description: 'Text to search for in memory content using full-text search.'
|
|
28
|
+
},
|
|
29
|
+
tags: {
|
|
30
|
+
type: 'array',
|
|
31
|
+
items: { type: 'string' },
|
|
32
|
+
description: 'Array of tags to filter results by. Matches memories that have these exact tags.'
|
|
33
|
+
},
|
|
34
|
+
limit: {
|
|
35
|
+
type: 'number',
|
|
36
|
+
description: 'Maximum number of results to return',
|
|
37
|
+
default: 10,
|
|
38
|
+
minimum: 1
|
|
39
|
+
},
|
|
40
|
+
includeRelated: {
|
|
41
|
+
type: 'boolean',
|
|
42
|
+
description: 'Include related memories in results (default: false)',
|
|
43
|
+
default: false
|
|
44
|
+
},
|
|
45
|
+
relationshipDepth: {
|
|
46
|
+
type: 'number',
|
|
47
|
+
description: 'Depth of relationship traversal when includeRelated is true (default: 1)',
|
|
48
|
+
default: 1,
|
|
49
|
+
minimum: 1,
|
|
50
|
+
maximum: 3
|
|
51
|
+
},
|
|
52
|
+
daysAgo: {
|
|
53
|
+
type: 'number',
|
|
54
|
+
description: 'Filter memories created within the last N days. Example: 7 for last week, 30 for last month.',
|
|
55
|
+
minimum: 0
|
|
56
|
+
},
|
|
57
|
+
startDate: {
|
|
58
|
+
type: 'string',
|
|
59
|
+
description: 'Filter memories created on or after this date (ISO 8601 format: YYYY-MM-DD or full ISO string).'
|
|
60
|
+
},
|
|
61
|
+
endDate: {
|
|
62
|
+
type: 'string',
|
|
63
|
+
description: 'Filter memories created on or before this date (ISO 8601 format: YYYY-MM-DD or full ISO string).'
|
|
64
|
+
},
|
|
65
|
+
minRelevance: {
|
|
66
|
+
type: 'number',
|
|
67
|
+
description: 'Minimum relevance score (0-1). Filters results by BM25 ranking. Higher values (e.g., 0.7-0.9) return only highly relevant matches.',
|
|
68
|
+
minimum: 0,
|
|
69
|
+
maximum: 1
|
|
70
|
+
},
|
|
71
|
+
summaryOnly: {
|
|
72
|
+
type: 'boolean',
|
|
73
|
+
description: 'Return compact summaries instead of full content. Reduces token usage by ~75%. Use hash parameter to retrieve full content.',
|
|
74
|
+
default: false
|
|
75
|
+
},
|
|
76
|
+
contentPreview: {
|
|
77
|
+
type: 'number',
|
|
78
|
+
description: 'Number of characters to include in preview when summaryOnly=true (default: 100)',
|
|
79
|
+
default: 100,
|
|
80
|
+
minimum: 0,
|
|
81
|
+
maximum: 500
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
handler: execute,
|
|
87
|
+
cliParser: parseCliArgs
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/search-memory/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,CAAC,MAAM,gBAAgB,GAAS;IACpC,UAAU,EAAE;QACV,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE;;;;;;;;;;;mEAWkD;QAC/D,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,+GAA+G;iBAC7H;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,8DAA8D;iBAC5E;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACzB,WAAW,EAAE,kFAAkF;iBAChG;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,qCAAqC;oBAClD,OAAO,EAAE,EAAE;oBACX,OAAO,EAAE,CAAC;iBACX;gBACD,cAAc,EAAE;oBACd,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,sDAAsD;oBACnE,OAAO,EAAE,KAAK;iBACf;gBACD,iBAAiB,EAAE;oBACjB,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,0EAA0E;oBACvF,OAAO,EAAE,CAAC;oBACV,OAAO,EAAE,CAAC;oBACV,OAAO,EAAE,CAAC;iBACX;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,8FAA8F;oBAC3G,OAAO,EAAE,CAAC;iBACX;gBACD,SAAS,EAAE;oBACT,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,iGAAiG;iBAC/G;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,kGAAkG;iBAChH;gBACD,YAAY,EAAE;oBACZ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,oIAAoI;oBACjJ,OAAO,EAAE,CAAC;oBACV,OAAO,EAAE,CAAC;iBACX;gBACD,WAAW,EAAE;oBACX,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,6HAA6H;oBAC1I,OAAO,EAAE,KAAK;iBACf;gBACD,cAAc,EAAE;oBACd,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,iFAAiF;oBAC9F,OAAO,EAAE,GAAG;oBACZ,OAAO,EAAE,CAAC;oBACV,OAAO,EAAE,GAAG;iBACb;aACF;SACF;KACF;IACD,OAAO,EAAE,OAAO;IAChB,SAAS,EAAE,YAAY;CACxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-parser.d.ts","sourceRoot":"","sources":["../../../src/tools/store-memory/cli-parser.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAqB1C"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { parseCommandLineArgs } from '../../utils/cli-parser.js';
|
|
2
|
+
export function parseCliArgs(args) {
|
|
3
|
+
// PHASE 1: Convert string array to object (shared utility)
|
|
4
|
+
const rawArgs = parseCommandLineArgs(args);
|
|
5
|
+
// PHASE 2: Validate and transform (command-specific logic)
|
|
6
|
+
const result = {
|
|
7
|
+
autoLink: true // Default to true
|
|
8
|
+
};
|
|
9
|
+
if (rawArgs.content)
|
|
10
|
+
result.content = rawArgs.content;
|
|
11
|
+
if (rawArgs.tags)
|
|
12
|
+
result.tags = rawArgs.tags.split(',').map((tag) => tag.trim());
|
|
13
|
+
if (typeof rawArgs.autoLink !== 'undefined') {
|
|
14
|
+
result.autoLink = rawArgs.autoLink;
|
|
15
|
+
}
|
|
16
|
+
if (rawArgs.relateTo) {
|
|
17
|
+
result.relateTo = rawArgs.relateTo.split(',').map((tag) => tag.trim());
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=cli-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-parser.js","sourceRoot":"","sources":["../../../src/tools/store-memory/cli-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,MAAM,UAAU,YAAY,CAAC,IAAc;IACzC,2DAA2D;IAC3D,MAAM,OAAO,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAE3C,2DAA2D;IAC3D,MAAM,MAAM,GAAQ;QAClB,QAAQ,EAAE,IAAI,CAAC,kBAAkB;KAClC,CAAC;IAEF,IAAI,OAAO,CAAC,OAAO;QAAE,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IACtD,IAAI,OAAO,CAAC,IAAI;QAAE,MAAM,CAAC,IAAI,GAAI,OAAO,CAAC,IAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAErG,IAAI,OAAO,OAAO,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;QAC1C,MAAM,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IACvC,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,MAAM,CAAC,QAAQ,GAAI,OAAO,CAAC,QAAmB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7F,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ToolContext } from '../../types/tools.js';
|
|
2
|
+
interface StoreMemoryArgs {
|
|
3
|
+
content: string;
|
|
4
|
+
tags?: string[];
|
|
5
|
+
autoLink?: boolean;
|
|
6
|
+
relateTo?: string[];
|
|
7
|
+
}
|
|
8
|
+
interface StoreMemoryResult {
|
|
9
|
+
success: boolean;
|
|
10
|
+
hash: string;
|
|
11
|
+
message: string;
|
|
12
|
+
relationshipsCreated?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function execute(args: StoreMemoryArgs, context: ToolContext): Promise<StoreMemoryResult>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/tools/store-memory/executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGxD,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,UAAU,iBAAiB;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA2CrG"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { debugLog, formatHash } from '../../utils/debug.js';
|
|
2
|
+
export async function execute(args, context) {
|
|
3
|
+
try {
|
|
4
|
+
// Validate content
|
|
5
|
+
if (!args.content || args.content.trim().length === 0) {
|
|
6
|
+
throw new Error('Content cannot be empty');
|
|
7
|
+
}
|
|
8
|
+
// Log content size for large memories
|
|
9
|
+
const contentSize = args.content.length;
|
|
10
|
+
if (contentSize > 100000) {
|
|
11
|
+
debugLog(`Storing large memory: ${contentSize} characters`);
|
|
12
|
+
}
|
|
13
|
+
const hash = context.memoryService.store(args.content, args.tags || []);
|
|
14
|
+
let relationshipsCreated = 0;
|
|
15
|
+
// Handle automatic relationship creation
|
|
16
|
+
if (args.autoLink !== false) { // Default to true
|
|
17
|
+
relationshipsCreated += await createAutoRelationships(hash, args, context);
|
|
18
|
+
}
|
|
19
|
+
// Handle explicit relationships
|
|
20
|
+
if (args.relateTo && args.relateTo.length > 0) {
|
|
21
|
+
relationshipsCreated += await createExplicitRelationships(hash, args.relateTo, context);
|
|
22
|
+
}
|
|
23
|
+
const message = relationshipsCreated > 0
|
|
24
|
+
? `Memory stored successfully with hash: ${formatHash(hash)} (${relationshipsCreated} relationships created)`
|
|
25
|
+
: `Memory stored successfully with hash: ${formatHash(hash)}...`;
|
|
26
|
+
return {
|
|
27
|
+
success: true,
|
|
28
|
+
hash,
|
|
29
|
+
message,
|
|
30
|
+
relationshipsCreated
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
return {
|
|
35
|
+
success: false,
|
|
36
|
+
hash: '',
|
|
37
|
+
message: `Failed to store memory: ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Create automatic relationships based on similar tags and content
|
|
43
|
+
*/
|
|
44
|
+
async function createAutoRelationships(hash, args, context) {
|
|
45
|
+
if (!args.tags || args.tags.length === 0) {
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
// Find memories with similar tags
|
|
50
|
+
const similarMemories = context.memoryService.search(undefined, args.tags, 5);
|
|
51
|
+
// Build array of relationships to create
|
|
52
|
+
const relationships = similarMemories
|
|
53
|
+
.filter(memory => memory.hash !== hash) // Don't link to self
|
|
54
|
+
.filter(memory => {
|
|
55
|
+
const commonTags = args.tags.filter(tag => memory.tags.includes(tag));
|
|
56
|
+
return commonTags.length > 0;
|
|
57
|
+
})
|
|
58
|
+
.map(memory => ({
|
|
59
|
+
fromHash: hash,
|
|
60
|
+
toHash: memory.hash,
|
|
61
|
+
relationshipType: 'similar'
|
|
62
|
+
}));
|
|
63
|
+
// Use bulk insert for better performance
|
|
64
|
+
if (relationships.length > 0) {
|
|
65
|
+
return context.memoryService.linkMemoriesBulk(relationships);
|
|
66
|
+
}
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
console.error('Auto-relationship creation failed:', error);
|
|
71
|
+
return 0;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Create explicit relationships based on relateTo tags
|
|
76
|
+
*/
|
|
77
|
+
async function createExplicitRelationships(hash, relateTo, context) {
|
|
78
|
+
try {
|
|
79
|
+
// Find memories with the specified tags
|
|
80
|
+
const relatedMemories = context.memoryService.search(undefined, relateTo, 10);
|
|
81
|
+
// Build array of relationships to create
|
|
82
|
+
const relationships = relatedMemories
|
|
83
|
+
.filter(memory => memory.hash !== hash) // Don't link to self
|
|
84
|
+
.map(memory => ({
|
|
85
|
+
fromHash: hash,
|
|
86
|
+
toHash: memory.hash,
|
|
87
|
+
relationshipType: 'related'
|
|
88
|
+
}));
|
|
89
|
+
// Use bulk insert for better performance
|
|
90
|
+
if (relationships.length > 0) {
|
|
91
|
+
return context.memoryService.linkMemoriesBulk(relationships);
|
|
92
|
+
}
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
console.error('Explicit relationship creation failed:', error);
|
|
97
|
+
return 0;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../src/tools/store-memory/executor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAgB5D,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAAqB,EAAE,OAAoB;IACvE,IAAI,CAAC;QACH,mBAAmB;QACnB,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtD,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC7C,CAAC;QAED,sCAAsC;QACtC,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;QACxC,IAAI,WAAW,GAAG,MAAM,EAAE,CAAC;YACzB,QAAQ,CAAC,yBAAyB,WAAW,aAAa,CAAC,CAAC;QAC9D,CAAC;QAED,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QACxE,IAAI,oBAAoB,GAAG,CAAC,CAAC;QAE7B,yCAAyC;QACzC,IAAI,IAAI,CAAC,QAAQ,KAAK,KAAK,EAAE,CAAC,CAAC,kBAAkB;YAC/C,oBAAoB,IAAI,MAAM,uBAAuB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7E,CAAC;QAED,gCAAgC;QAChC,IAAI,IAAI,CAAC,QAAQ,IA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C,EAAE,CAAC;YAC7B,OAAO,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;QAC/D,CAAC;QAED,OAAO,CAAC,CAAC;IACX,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC;QAC/D,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/store-memory/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAIjD,eAAO,MAAM,eAAe,EAAE,IAgE7B,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { execute } from './executor.js';
|
|
2
|
+
import { parseCliArgs } from './cli-parser.js';
|
|
3
|
+
export const storeMemoryTool = {
|
|
4
|
+
definition: {
|
|
5
|
+
name: 'store-memory',
|
|
6
|
+
description: `Store a memory with optional tags and automatic relationship detection.
|
|
7
|
+
|
|
8
|
+
🧠 AUTO-CAPTURE MODE: Use this tool proactively during conversations to capture important information WITHOUT waiting for explicit user requests.
|
|
9
|
+
|
|
10
|
+
ALWAYS CAPTURE (automatically):
|
|
11
|
+
✓ User preferences, opinions, likes/dislikes ("I prefer X", "I like Y")
|
|
12
|
+
✓ Decisions made during conversation ("Let's go with option A")
|
|
13
|
+
✓ Facts about people mentioned (names, roles, relationships)
|
|
14
|
+
✓ Facts about projects or work (names, status, goals, technologies)
|
|
15
|
+
✓ Learnings, insights, realizations ("I learned that...", "I discovered...")
|
|
16
|
+
✓ Action items, commitments, TODOs ("I need to...", "Remember to...")
|
|
17
|
+
✓ Technical knowledge or discoveries
|
|
18
|
+
✓ User corrections or clarifications about past information
|
|
19
|
+
|
|
20
|
+
NEVER CAPTURE (skip these):
|
|
21
|
+
✗ Casual greetings, small talk, farewells
|
|
22
|
+
✗ Temporary information (current weather, time, date)
|
|
23
|
+
✗ Purely transactional exchanges
|
|
24
|
+
✗ Simple questions or clarifications
|
|
25
|
+
✗ Sensitive personal data (unless explicitly requested by user)
|
|
26
|
+
|
|
27
|
+
BEHAVIOR:
|
|
28
|
+
• Store SILENTLY - don't announce "I've saved that to memory"
|
|
29
|
+
• Use clear, descriptive tags for easy retrieval (e.g., "preferences", "decisions", "project-name")
|
|
30
|
+
• Link related memories using autoLink or relateTo parameters
|
|
31
|
+
• Be thoughtful about long-term value - not everything needs storage
|
|
32
|
+
|
|
33
|
+
EXAMPLE:
|
|
34
|
+
User: "I really prefer TypeScript over JavaScript for its type safety"
|
|
35
|
+
You: [Continue conversation naturally about TypeScript...]
|
|
36
|
+
Background action: store-memory("User prefers TypeScript over JavaScript for type safety", tags: ["preferences", "typescript", "javascript"])`,
|
|
37
|
+
inputSchema: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
content: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
description: 'The content to store in memory'
|
|
43
|
+
},
|
|
44
|
+
tags: {
|
|
45
|
+
type: 'array',
|
|
46
|
+
items: { type: 'string' },
|
|
47
|
+
description: 'Optional tags to associate with this memory',
|
|
48
|
+
default: []
|
|
49
|
+
},
|
|
50
|
+
autoLink: {
|
|
51
|
+
type: 'boolean',
|
|
52
|
+
description: 'Automatically create relationships with similar memories (default: true)',
|
|
53
|
+
default: true
|
|
54
|
+
},
|
|
55
|
+
relateTo: {
|
|
56
|
+
type: 'array',
|
|
57
|
+
items: { type: 'string' },
|
|
58
|
+
description: 'Tags to explicitly link this memory to existing memories with matching tags',
|
|
59
|
+
default: []
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
required: ['content']
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
handler: execute,
|
|
66
|
+
cliParser: parseCliArgs
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/store-memory/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,CAAC,MAAM,eAAe,GAAS;IACnC,UAAU,EAAE;QACV,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8IA8B6H;QAC1I,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,gCAAgC;iBAC9C;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACzB,WAAW,EAAE,6CAA6C;oBAC1D,OAAO,EAAE,EAAE;iBACZ;gBACD,QAAQ,EAAE;oBACR,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,0EAA0E;oBACvF,OAAO,EAAE,IAAI;iBACd;gBACD,QAAQ,EAAE;oBACR,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACzB,WAAW,EAAE,6EAA6E;oBAC1F,OAAO,EAAE,EAAE;iBACZ;aACF;YACD,QAAQ,EAAE,CAAC,SAAS,CAAC;SACtB;KACF;IACD,OAAO,EAAE,OAAO;IAChB,SAAS,EAAE,YAAY;CACxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=cli-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-parser.d.ts","sourceRoot":"","sources":["../../../src/tools/sync-memory/cli-parser.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-parser.js","sourceRoot":"","sources":["../../../src/tools/sync-memory/cli-parser.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/tools/sync-memory/executor.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../src/tools/sync-memory/executor.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/sync-memory/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/sync-memory/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-parser.d.ts","sourceRoot":"","sources":["../../../src/tools/update-memory/cli-parser.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAgB1C"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { parseCommandLineArgs } from '../../utils/cli-parser.js';
|
|
2
|
+
export function parseCliArgs(args) {
|
|
3
|
+
// PHASE 1: Convert string array to object (shared utility)
|
|
4
|
+
const rawArgs = parseCommandLineArgs(args);
|
|
5
|
+
// PHASE 2: Validate and transform (command-specific logic)
|
|
6
|
+
const result = {};
|
|
7
|
+
if (rawArgs.hash)
|
|
8
|
+
result.hash = rawArgs.hash;
|
|
9
|
+
if (rawArgs.content)
|
|
10
|
+
result.content = rawArgs.content;
|
|
11
|
+
// Tags are optional - if provided, they replace existing tags
|
|
12
|
+
if (rawArgs.tags) {
|
|
13
|
+
result.tags = rawArgs.tags.split(',').map((tag) => tag.trim());
|
|
14
|
+
}
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=cli-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-parser.js","sourceRoot":"","sources":["../../../src/tools/update-memory/cli-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,MAAM,UAAU,YAAY,CAAC,IAAc;IACzC,2DAA2D;IAC3D,MAAM,OAAO,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAE3C,2DAA2D;IAC3D,MAAM,MAAM,GAAQ,EAAE,CAAC;IAEvB,IAAI,OAAO,CAAC,IAAI;QAAE,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC7C,IAAI,OAAO,CAAC,OAAO;QAAE,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAEtD,8DAA8D;IAC9D,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,MAAM,CAAC,IAAI,GAAI,OAAO,CAAC,IAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IACrF,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ToolContext } from '../../types/tools.js';
|
|
2
|
+
interface UpdateMemoryArgs {
|
|
3
|
+
hash: string;
|
|
4
|
+
content: string;
|
|
5
|
+
tags?: string[];
|
|
6
|
+
}
|
|
7
|
+
interface UpdateMemoryResult {
|
|
8
|
+
success: boolean;
|
|
9
|
+
oldHash?: string;
|
|
10
|
+
newHash?: string;
|
|
11
|
+
message: string;
|
|
12
|
+
tagsUpdated?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function execute(args: UpdateMemoryArgs, context: ToolContext): Promise<UpdateMemoryResult>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/tools/update-memory/executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGxD,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,UAAU,kBAAkB;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA8DvG"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { debugLog, formatHash } from '../../utils/debug.js';
|
|
2
|
+
export async function execute(args, context) {
|
|
3
|
+
try {
|
|
4
|
+
// Validate inputs
|
|
5
|
+
if (!args.hash || args.hash.trim().length === 0) {
|
|
6
|
+
throw new Error('Hash cannot be empty');
|
|
7
|
+
}
|
|
8
|
+
if (!args.content || args.content.trim().length === 0) {
|
|
9
|
+
throw new Error('Content cannot be empty');
|
|
10
|
+
}
|
|
11
|
+
// Log content size for large memories
|
|
12
|
+
const contentSize = args.content.length;
|
|
13
|
+
if (contentSize > 100000) {
|
|
14
|
+
debugLog(`Updating with large content: ${contentSize} characters`);
|
|
15
|
+
}
|
|
16
|
+
// Check if memory exists before updating
|
|
17
|
+
const existing = context.memoryService.getByHash(args.hash);
|
|
18
|
+
if (!existing) {
|
|
19
|
+
return {
|
|
20
|
+
success: false,
|
|
21
|
+
message: `Memory not found with hash: ${formatHash(args.hash)}...`
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
// Perform the update
|
|
25
|
+
const newHash = context.memoryService.update(args.hash, args.content, args.tags);
|
|
26
|
+
if (!newHash) {
|
|
27
|
+
return {
|
|
28
|
+
success: false,
|
|
29
|
+
message: `Failed to update memory with hash: ${formatHash(args.hash)}...`
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const hashChanged = newHash !== args.hash;
|
|
33
|
+
const tagsUpdated = args.tags !== undefined;
|
|
34
|
+
let message = `Memory updated successfully.`;
|
|
35
|
+
if (hashChanged) {
|
|
36
|
+
message += ` New hash: ${formatHash(newHash)}...`;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
message += ` Hash unchanged: ${formatHash(newHash)}...`;
|
|
40
|
+
}
|
|
41
|
+
if (tagsUpdated) {
|
|
42
|
+
message += ` (tags updated)`;
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
success: true,
|
|
46
|
+
oldHash: args.hash,
|
|
47
|
+
newHash,
|
|
48
|
+
message,
|
|
49
|
+
tagsUpdated
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
return {
|
|
54
|
+
success: false,
|
|
55
|
+
message: `Failed to update memory: ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../src/tools/update-memory/executor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAgB5D,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAAsB,EAAE,OAAoB;IACxE,IAAI,CAAC;QACH,kBAAkB;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AAS,CAAC;QAE5C,IAAI,OAAO,GAAG,8BAA8B,CAAC;QAC7C,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,IAAI,cAAc,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,oBAAoB,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC;QAC1D,CAAC;QACD,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,IAAI,iBAAiB,CAAC;QAC/B,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI,CAAC,IAAI;YAClB,OAAO;YACP,OAAO;YACP,WAAW;SACZ,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,4BAA4B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE;SAChG,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/update-memory/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAIjD,eAAO,MAAM,gBAAgB,EAAE,IA0B9B,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { execute } from './executor.js';
|
|
2
|
+
import { parseCliArgs } from './cli-parser.js';
|
|
3
|
+
export const updateMemoryTool = {
|
|
4
|
+
definition: {
|
|
5
|
+
name: 'update-memory',
|
|
6
|
+
description: 'Update an existing memory with new content and/or tags. The hash will change if content changes. If tags are provided, they replace all existing tags; if omitted, existing tags are preserved.',
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
hash: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
description: 'The hash of the memory to update'
|
|
13
|
+
},
|
|
14
|
+
content: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
description: 'The new content for the memory'
|
|
17
|
+
},
|
|
18
|
+
tags: {
|
|
19
|
+
type: 'array',
|
|
20
|
+
items: { type: 'string' },
|
|
21
|
+
description: 'New tags to replace existing tags (optional - if omitted, existing tags are preserved)'
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
required: ['hash', 'content']
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
handler: execute,
|
|
28
|
+
cliParser: parseCliArgs
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/update-memory/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,CAAC,MAAM,gBAAgB,GAAS;IACpC,UAAU,EAAE;QACV,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,iMAAiM;QAC9M,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,kCAAkC;iBAChD;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,gCAAgC;iBAC9C;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACzB,WAAW,EAAE,wFAAwF;iBACtG;aACF;YACD,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;SAC9B;KACF;IACD,OAAO,EAAE,OAAO;IAChB,SAAS,EAAE,YAAY;CACxB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StreamableHTTPServerTransport - MCP transport over HTTP
|
|
3
|
+
*
|
|
4
|
+
* Implements the MCP Server transport interface using HTTP instead of stdio.
|
|
5
|
+
* Properly handles the async nature of MCP over synchronous HTTP.
|
|
6
|
+
*/
|
|
7
|
+
import { JSONRPCMessage } from '@modelcontextprotocol/sdk/types.js';
|
|
8
|
+
interface HTTPTransportOptions {
|
|
9
|
+
port?: number;
|
|
10
|
+
host?: string;
|
|
11
|
+
timeout?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class StreamableHTTPServerTransport {
|
|
14
|
+
private port;
|
|
15
|
+
private host;
|
|
16
|
+
private timeout;
|
|
17
|
+
private httpServer;
|
|
18
|
+
private pendingResponses;
|
|
19
|
+
onmessage?: (message: JSONRPCMessage) => void;
|
|
20
|
+
onclose?: () => void;
|
|
21
|
+
onerror?: (error: Error) => void;
|
|
22
|
+
constructor(options?: HTTPTransportOptions);
|
|
23
|
+
start(): Promise<void>;
|
|
24
|
+
close(): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Send a message (response) back to the waiting HTTP request
|
|
27
|
+
*/
|
|
28
|
+
send(message: JSONRPCMessage): Promise<void>;
|
|
29
|
+
private handleRequest;
|
|
30
|
+
private handleMCPRequest;
|
|
31
|
+
private waitForResponse;
|
|
32
|
+
private readBody;
|
|
33
|
+
private parseRequest;
|
|
34
|
+
private sendJSON;
|
|
35
|
+
private sendError;
|
|
36
|
+
}
|
|
37
|
+
export default StreamableHTTPServerTransport;
|
|
38
|
+
//# sourceMappingURL=streamable-http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamable-http.d.ts","sourceRoot":"","sources":["../../src/transports/streamable-http.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGpE,UAAU,oBAAoB;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,6BAA6B;IACxC,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,UAAU,CAAa;IAG/B,OAAO,CAAC,gBAAgB,CAGnB;IAGL,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;IAC9C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;gBAErB,OAAO,GAAE,oBAAyB;IAMxC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA0BtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAwB5B;;OAEG;IACG,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;YAiBpC,aAAa;YA6Bb,gBAAgB;YAiChB,eAAe;YAiCf,QAAQ;IAmBtB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,SAAS;CAOlB;AAED,eAAe,6BAA6B,CAAC"}
|