@troykelly/openclaw-projects 0.0.1
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 +389 -0
- package/dist/api-client.d.ts +81 -0
- package/dist/api-client.d.ts.map +1 -0
- package/dist/api-client.js +216 -0
- package/dist/api-client.js.map +1 -0
- package/dist/cli.d.ts +112 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +233 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +324 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +287 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +87 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +144 -0
- package/dist/context.js.map +1 -0
- package/dist/gateway/rpc-methods.d.ts +93 -0
- package/dist/gateway/rpc-methods.d.ts.map +1 -0
- package/dist/gateway/rpc-methods.js +145 -0
- package/dist/gateway/rpc-methods.js.map +1 -0
- package/dist/hooks.d.ts +86 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +314 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +106 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +221 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +22 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +78 -0
- package/dist/logger.js.map +1 -0
- package/dist/register-openclaw.d.ts +43 -0
- package/dist/register-openclaw.d.ts.map +1 -0
- package/dist/register-openclaw.js +1838 -0
- package/dist/register-openclaw.js.map +1 -0
- package/dist/secrets.d.ts +56 -0
- package/dist/secrets.d.ts.map +1 -0
- package/dist/secrets.js +161 -0
- package/dist/secrets.js.map +1 -0
- package/dist/services/notification-service.d.ts +60 -0
- package/dist/services/notification-service.d.ts.map +1 -0
- package/dist/services/notification-service.js +145 -0
- package/dist/services/notification-service.js.map +1 -0
- package/dist/tools/contacts.d.ts +139 -0
- package/dist/tools/contacts.d.ts.map +1 -0
- package/dist/tools/contacts.js +333 -0
- package/dist/tools/contacts.js.map +1 -0
- package/dist/tools/email-send.d.ts +71 -0
- package/dist/tools/email-send.d.ts.map +1 -0
- package/dist/tools/email-send.js +132 -0
- package/dist/tools/email-send.js.map +1 -0
- package/dist/tools/file-share.d.ts +64 -0
- package/dist/tools/file-share.d.ts.map +1 -0
- package/dist/tools/file-share.js +133 -0
- package/dist/tools/file-share.js.map +1 -0
- package/dist/tools/index.d.ts +22 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +33 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/memory-forget.d.ts +69 -0
- package/dist/tools/memory-forget.d.ts.map +1 -0
- package/dist/tools/memory-forget.js +224 -0
- package/dist/tools/memory-forget.js.map +1 -0
- package/dist/tools/memory-recall.d.ts +82 -0
- package/dist/tools/memory-recall.d.ts.map +1 -0
- package/dist/tools/memory-recall.js +161 -0
- package/dist/tools/memory-recall.js.map +1 -0
- package/dist/tools/memory-store.d.ts +80 -0
- package/dist/tools/memory-store.d.ts.map +1 -0
- package/dist/tools/memory-store.js +172 -0
- package/dist/tools/memory-store.js.map +1 -0
- package/dist/tools/message-search.d.ts +85 -0
- package/dist/tools/message-search.d.ts.map +1 -0
- package/dist/tools/message-search.js +137 -0
- package/dist/tools/message-search.js.map +1 -0
- package/dist/tools/notebooks.d.ts +155 -0
- package/dist/tools/notebooks.d.ts.map +1 -0
- package/dist/tools/notebooks.js +287 -0
- package/dist/tools/notebooks.js.map +1 -0
- package/dist/tools/notes.d.ts +272 -0
- package/dist/tools/notes.d.ts.map +1 -0
- package/dist/tools/notes.js +530 -0
- package/dist/tools/notes.js.map +1 -0
- package/dist/tools/projects.d.ts +139 -0
- package/dist/tools/projects.d.ts.map +1 -0
- package/dist/tools/projects.js +280 -0
- package/dist/tools/projects.js.map +1 -0
- package/dist/tools/relationships.d.ts +133 -0
- package/dist/tools/relationships.d.ts.map +1 -0
- package/dist/tools/relationships.js +281 -0
- package/dist/tools/relationships.js.map +1 -0
- package/dist/tools/sms-send.d.ts +62 -0
- package/dist/tools/sms-send.d.ts.map +1 -0
- package/dist/tools/sms-send.js +121 -0
- package/dist/tools/sms-send.js.map +1 -0
- package/dist/tools/threads.d.ts +127 -0
- package/dist/tools/threads.d.ts.map +1 -0
- package/dist/tools/threads.js +202 -0
- package/dist/tools/threads.js.map +1 -0
- package/dist/tools/todos.d.ts +142 -0
- package/dist/tools/todos.d.ts.map +1 -0
- package/dist/tools/todos.js +308 -0
- package/dist/tools/todos.js.map +1 -0
- package/dist/types/openclaw-api.d.ts +215 -0
- package/dist/types/openclaw-api.d.ts.map +1 -0
- package/dist/types/openclaw-api.js +10 -0
- package/dist/types/openclaw-api.js.map +1 -0
- package/dist/utils/zod-to-json-schema.d.ts +19 -0
- package/dist/utils/zod-to-json-schema.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema.js +132 -0
- package/dist/utils/zod-to-json-schema.js.map +1 -0
- package/openclaw.plugin.json +229 -0
- package/package.json +69 -0
- package/skills/contact-lookup/SKILL.md +30 -0
- package/skills/daily-summary/SKILL.md +23 -0
- package/skills/project-status/SKILL.md +33 -0
- package/skills/send-reminder/SKILL.md +42 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* memory_forget tool implementation.
|
|
3
|
+
* Provides GDPR-compliant memory deletion.
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
/** Parameters for memory_forget tool */
|
|
7
|
+
export const MemoryForgetParamsSchema = z
|
|
8
|
+
.object({
|
|
9
|
+
memoryId: z.string().optional(),
|
|
10
|
+
query: z.string().max(1000, 'Query must be 1000 characters or less').optional(),
|
|
11
|
+
confirmBulkDelete: z.boolean().optional(),
|
|
12
|
+
})
|
|
13
|
+
.refine((data) => data.memoryId || data.query, {
|
|
14
|
+
message: 'Either memoryId or query is required',
|
|
15
|
+
});
|
|
16
|
+
/** Bulk delete threshold */
|
|
17
|
+
const BULK_DELETE_THRESHOLD = 5;
|
|
18
|
+
/**
|
|
19
|
+
* Sanitize query input to remove control characters.
|
|
20
|
+
*/
|
|
21
|
+
function sanitizeQuery(query) {
|
|
22
|
+
const sanitized = query.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g, '');
|
|
23
|
+
return sanitized.trim();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create a sanitized error message that doesn't expose internal details.
|
|
27
|
+
*/
|
|
28
|
+
function sanitizeErrorMessage(error) {
|
|
29
|
+
if (error instanceof Error) {
|
|
30
|
+
const message = error.message
|
|
31
|
+
.replace(/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/g, '[host]')
|
|
32
|
+
.replace(/:\d{2,5}\b/g, '')
|
|
33
|
+
.replace(/\b(?:localhost|internal[-\w]*)\b/gi, '[internal]');
|
|
34
|
+
if (message.includes('[internal]') || message.includes('[host]')) {
|
|
35
|
+
return 'Failed to delete memory. Please try again.';
|
|
36
|
+
}
|
|
37
|
+
return message;
|
|
38
|
+
}
|
|
39
|
+
return 'An unexpected error occurred while deleting memory.';
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Creates the memory_forget tool.
|
|
43
|
+
*/
|
|
44
|
+
export function createMemoryForgetTool(options) {
|
|
45
|
+
const { client, logger, userId } = options;
|
|
46
|
+
return {
|
|
47
|
+
name: 'memory_forget',
|
|
48
|
+
description: 'Delete specific memories. Use when the user explicitly requests to forget something. Can delete by ID or by search query.',
|
|
49
|
+
parameters: MemoryForgetParamsSchema,
|
|
50
|
+
async execute(params) {
|
|
51
|
+
// Validate parameters
|
|
52
|
+
const parseResult = MemoryForgetParamsSchema.safeParse(params);
|
|
53
|
+
if (!parseResult.success) {
|
|
54
|
+
const errorMessage = parseResult.error.errors
|
|
55
|
+
.map((e) => e.message)
|
|
56
|
+
.join(', ');
|
|
57
|
+
return { success: false, error: errorMessage };
|
|
58
|
+
}
|
|
59
|
+
const { memoryId, query, confirmBulkDelete } = parseResult.data;
|
|
60
|
+
// Log invocation
|
|
61
|
+
logger.info('memory_forget invoked', {
|
|
62
|
+
userId,
|
|
63
|
+
memoryId: memoryId ?? undefined,
|
|
64
|
+
hasQuery: !!query,
|
|
65
|
+
});
|
|
66
|
+
try {
|
|
67
|
+
// Delete by ID
|
|
68
|
+
if (memoryId) {
|
|
69
|
+
return await deleteById(client, logger, userId, memoryId);
|
|
70
|
+
}
|
|
71
|
+
// Delete by query
|
|
72
|
+
if (query) {
|
|
73
|
+
return await deleteByQuery(client, logger, userId, query, confirmBulkDelete);
|
|
74
|
+
}
|
|
75
|
+
// Should not reach here due to validation
|
|
76
|
+
return { success: false, error: 'Either memoryId or query is required' };
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
logger.error('memory_forget failed', {
|
|
80
|
+
userId,
|
|
81
|
+
error: error instanceof Error ? error.message : String(error),
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
success: false,
|
|
85
|
+
error: sanitizeErrorMessage(error),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Delete a memory by ID.
|
|
93
|
+
*/
|
|
94
|
+
async function deleteById(client, logger, userId, memoryId) {
|
|
95
|
+
const response = await client.delete(`/api/memories/${memoryId}`, { userId });
|
|
96
|
+
if (!response.success) {
|
|
97
|
+
// Handle not found gracefully
|
|
98
|
+
if (response.error.code === 'NOT_FOUND') {
|
|
99
|
+
logger.debug('memory_forget completed', {
|
|
100
|
+
userId,
|
|
101
|
+
deletedCount: 0,
|
|
102
|
+
reason: 'not found',
|
|
103
|
+
});
|
|
104
|
+
return {
|
|
105
|
+
success: true,
|
|
106
|
+
data: {
|
|
107
|
+
content: 'Memory not found or already deleted.',
|
|
108
|
+
details: {
|
|
109
|
+
deletedCount: 0,
|
|
110
|
+
deletedIds: [],
|
|
111
|
+
userId,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
logger.error('memory_forget API error', {
|
|
117
|
+
userId,
|
|
118
|
+
memoryId,
|
|
119
|
+
status: response.error.status,
|
|
120
|
+
code: response.error.code,
|
|
121
|
+
});
|
|
122
|
+
return {
|
|
123
|
+
success: false,
|
|
124
|
+
error: response.error.message || 'Failed to delete memory',
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
logger.debug('memory_forget completed', {
|
|
128
|
+
userId,
|
|
129
|
+
deletedCount: 1,
|
|
130
|
+
memoryId,
|
|
131
|
+
});
|
|
132
|
+
return {
|
|
133
|
+
success: true,
|
|
134
|
+
data: {
|
|
135
|
+
content: 'Deleted 1 memory.',
|
|
136
|
+
details: {
|
|
137
|
+
deletedCount: 1,
|
|
138
|
+
deletedIds: [memoryId],
|
|
139
|
+
userId,
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Delete memories by search query.
|
|
146
|
+
*/
|
|
147
|
+
async function deleteByQuery(client, logger, userId, query, confirmBulkDelete) {
|
|
148
|
+
const sanitizedQuery = sanitizeQuery(query);
|
|
149
|
+
if (sanitizedQuery.length === 0) {
|
|
150
|
+
return { success: false, error: 'Query cannot be empty' };
|
|
151
|
+
}
|
|
152
|
+
// Search for matching memories
|
|
153
|
+
const queryParams = new URLSearchParams({
|
|
154
|
+
q: sanitizedQuery,
|
|
155
|
+
limit: '100', // Max to find for deletion
|
|
156
|
+
});
|
|
157
|
+
const searchResponse = await client.get(`/api/memories/search?${queryParams.toString()}`, { userId });
|
|
158
|
+
if (!searchResponse.success) {
|
|
159
|
+
logger.error('memory_forget search error', {
|
|
160
|
+
userId,
|
|
161
|
+
status: searchResponse.error.status,
|
|
162
|
+
code: searchResponse.error.code,
|
|
163
|
+
});
|
|
164
|
+
return {
|
|
165
|
+
success: false,
|
|
166
|
+
error: searchResponse.error.message || 'Failed to search memories',
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
const memories = searchResponse.data.memories ?? [];
|
|
170
|
+
if (memories.length === 0) {
|
|
171
|
+
logger.debug('memory_forget completed', {
|
|
172
|
+
userId,
|
|
173
|
+
deletedCount: 0,
|
|
174
|
+
reason: 'no matches',
|
|
175
|
+
});
|
|
176
|
+
return {
|
|
177
|
+
success: true,
|
|
178
|
+
data: {
|
|
179
|
+
content: 'No matching memories found to delete.',
|
|
180
|
+
details: {
|
|
181
|
+
deletedCount: 0,
|
|
182
|
+
deletedIds: [],
|
|
183
|
+
userId,
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
// Check bulk delete threshold
|
|
189
|
+
if (memories.length > BULK_DELETE_THRESHOLD && !confirmBulkDelete) {
|
|
190
|
+
logger.warn('memory_forget bulk delete blocked', {
|
|
191
|
+
userId,
|
|
192
|
+
matchCount: memories.length,
|
|
193
|
+
});
|
|
194
|
+
return {
|
|
195
|
+
success: false,
|
|
196
|
+
error: `Found ${memories.length} matching memories. Set confirmBulkDelete: true to delete more than ${BULK_DELETE_THRESHOLD} memories at once.`,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
// Delete each memory
|
|
200
|
+
const deletedIds = [];
|
|
201
|
+
for (const memory of memories) {
|
|
202
|
+
const deleteResponse = await client.delete(`/api/memories/${memory.id}`, { userId });
|
|
203
|
+
if (deleteResponse.success) {
|
|
204
|
+
deletedIds.push(memory.id);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
logger.debug('memory_forget completed', {
|
|
208
|
+
userId,
|
|
209
|
+
deletedCount: deletedIds.length,
|
|
210
|
+
requestedCount: memories.length,
|
|
211
|
+
});
|
|
212
|
+
return {
|
|
213
|
+
success: true,
|
|
214
|
+
data: {
|
|
215
|
+
content: `Deleted ${deletedIds.length} ${deletedIds.length === 1 ? 'memory' : 'memories'}.`,
|
|
216
|
+
details: {
|
|
217
|
+
deletedCount: deletedIds.length,
|
|
218
|
+
deletedIds,
|
|
219
|
+
userId,
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=memory-forget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-forget.js","sourceRoot":"","sources":["../../src/tools/memory-forget.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,wCAAwC;AACxC,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC;KACtC,MAAM,CAAC;IACN,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,uCAAuC,CAAC,CAAC,QAAQ,EAAE;IAC/E,iBAAiB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CAC1C,CAAC;KACD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,EAAE;IAC7C,OAAO,EAAE,sCAAsC;CAChD,CAAC,CAAA;AAyCJ,4BAA4B;AAC5B,MAAM,qBAAqB,GAAG,CAAC,CAAA;AAE/B;;GAEG;AACH,SAAS,aAAa,CAAC,KAAa;IAClC,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,mCAAmC,EAAE,EAAE,CAAC,CAAA;IACxE,OAAO,SAAS,CAAC,IAAI,EAAE,CAAA;AACzB,CAAC;AAED;;GAEG;AACH,SAAS,oBAAoB,CAAC,KAAc;IAC1C,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO;aAC1B,OAAO,CAAC,yCAAyC,EAAE,QAAQ,CAAC;aAC5D,OAAO,CAAC,a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M,UAAU,GAAa,EAAE,CAAA;IAC/B,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC9B,MAAM,cAAc,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,iBAAiB,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;QACpF,IAAI,cAAc,CAAC,OAAO,EAAE,CAAC;YAC3B,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QAC5B,CAAC;IACH,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE;QACtC,MAAM;QACN,YAAY,EAAE,UAAU,CAAC,MAAM;QAC/B,cAAc,EAAE,QAAQ,CAAC,MAAM;KAChC,CAAC,CAAA;IAEF,OAAO;QACL,OAAO,EAAE,IAAI;QACb,IAAI,EAAE;YACJ,OAAO,EAAE,WAAW,UAAU,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,GAAG;YAC3F,OAAO,EAAE;gBACP,YAAY,EAAE,UAAU,CAAC,MAAM;gBAC/B,UAAU;gBACV,MAAM;aACP;SACF;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* memory_recall tool implementation.
|
|
3
|
+
* Provides semantic search through stored memories.
|
|
4
|
+
* Tags filtering support added in Issue #492.
|
|
5
|
+
* Relationship scope filtering added in Issue #493.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import type { ApiClient } from '../api-client.js';
|
|
9
|
+
import type { Logger } from '../logger.js';
|
|
10
|
+
import type { PluginConfig } from '../config.js';
|
|
11
|
+
/** Memory categories for filtering */
|
|
12
|
+
export declare const MemoryCategory: z.ZodEnum<["preference", "fact", "decision", "context", "other"]>;
|
|
13
|
+
export type MemoryCategory = z.infer<typeof MemoryCategory>;
|
|
14
|
+
/** Parameters for memory_recall tool */
|
|
15
|
+
export declare const MemoryRecallParamsSchema: z.ZodObject<{
|
|
16
|
+
query: z.ZodString;
|
|
17
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
category: z.ZodOptional<z.ZodEnum<["preference", "fact", "decision", "context", "other"]>>;
|
|
19
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
20
|
+
relationship_id: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
query: string;
|
|
23
|
+
limit?: number | undefined;
|
|
24
|
+
category?: "preference" | "fact" | "decision" | "context" | "other" | undefined;
|
|
25
|
+
tags?: string[] | undefined;
|
|
26
|
+
relationship_id?: string | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
query: string;
|
|
29
|
+
limit?: number | undefined;
|
|
30
|
+
category?: "preference" | "fact" | "decision" | "context" | "other" | undefined;
|
|
31
|
+
tags?: string[] | undefined;
|
|
32
|
+
relationship_id?: string | undefined;
|
|
33
|
+
}>;
|
|
34
|
+
export type MemoryRecallParams = z.infer<typeof MemoryRecallParamsSchema>;
|
|
35
|
+
/** Memory item returned from API */
|
|
36
|
+
export interface Memory {
|
|
37
|
+
id: string;
|
|
38
|
+
content: string;
|
|
39
|
+
category: string;
|
|
40
|
+
tags?: string[];
|
|
41
|
+
score?: number;
|
|
42
|
+
createdAt?: string;
|
|
43
|
+
updatedAt?: string;
|
|
44
|
+
}
|
|
45
|
+
/** Successful tool result */
|
|
46
|
+
export interface MemoryRecallSuccess {
|
|
47
|
+
success: true;
|
|
48
|
+
data: {
|
|
49
|
+
content: string;
|
|
50
|
+
details: {
|
|
51
|
+
count: number;
|
|
52
|
+
memories: Memory[];
|
|
53
|
+
userId: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/** Failed tool result */
|
|
58
|
+
export interface MemoryRecallFailure {
|
|
59
|
+
success: false;
|
|
60
|
+
error: string;
|
|
61
|
+
}
|
|
62
|
+
/** Tool result type */
|
|
63
|
+
export type MemoryRecallResult = MemoryRecallSuccess | MemoryRecallFailure;
|
|
64
|
+
/** Tool configuration */
|
|
65
|
+
export interface MemoryRecallToolOptions {
|
|
66
|
+
client: ApiClient;
|
|
67
|
+
logger: Logger;
|
|
68
|
+
config: PluginConfig;
|
|
69
|
+
userId: string;
|
|
70
|
+
}
|
|
71
|
+
/** Tool definition */
|
|
72
|
+
export interface MemoryRecallTool {
|
|
73
|
+
name: string;
|
|
74
|
+
description: string;
|
|
75
|
+
parameters: typeof MemoryRecallParamsSchema;
|
|
76
|
+
execute: (params: MemoryRecallParams) => Promise<MemoryRecallResult>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Creates the memory_recall tool.
|
|
80
|
+
*/
|
|
81
|
+
export declare function createMemoryRecallTool(options: MemoryRecallToolOptions): MemoryRecallTool;
|
|
82
|
+
//# sourceMappingURL=memory-recall.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-recall.d.ts","sourceRoot":"","sources":["../../src/tools/memory-recall.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAEhD,sCAAsC;AACtC,eAAO,MAAM,cAAc,mEAAiE,CAAA;AAC5F,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA;AAE3D,wCAAwC;AACxC,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;EAenC,CAAA;AACF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,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
|
|
1
|
+
/**
|
|
2
|
+
* memory_recall tool implementation.
|
|
3
|
+
* Provides semantic search through stored memories.
|
|
4
|
+
* Tags filtering support added in Issue #492.
|
|
5
|
+
* Relationship scope filtering added in Issue #493.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
/** Memory categories for filtering */
|
|
9
|
+
export const MemoryCategory = z.enum(['preference', 'fact', 'decision', 'context', 'other']);
|
|
10
|
+
/** Parameters for memory_recall tool */
|
|
11
|
+
export const MemoryRecallParamsSchema = z.object({
|
|
12
|
+
query: z
|
|
13
|
+
.string()
|
|
14
|
+
.min(1, 'Query cannot be empty')
|
|
15
|
+
.max(1000, 'Query must be 1000 characters or less'),
|
|
16
|
+
limit: z.number().int().min(1).max(20).optional(),
|
|
17
|
+
category: MemoryCategory.optional(),
|
|
18
|
+
tags: z
|
|
19
|
+
.array(z.string().min(1).max(100))
|
|
20
|
+
.max(20, 'Maximum 20 tags per filter')
|
|
21
|
+
.optional(),
|
|
22
|
+
relationship_id: z
|
|
23
|
+
.string()
|
|
24
|
+
.uuid('relationship_id must be a valid UUID')
|
|
25
|
+
.optional(),
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Sanitize query input to prevent injection and remove control characters.
|
|
29
|
+
*/
|
|
30
|
+
function sanitizeQuery(query) {
|
|
31
|
+
// Remove control characters (ASCII 0-31 except tab, newline, carriage return)
|
|
32
|
+
const sanitized = query.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g, '');
|
|
33
|
+
// Trim whitespace
|
|
34
|
+
return sanitized.trim();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Format memories as a bullet list with category and tag annotations.
|
|
38
|
+
*/
|
|
39
|
+
function formatMemoriesAsText(memories) {
|
|
40
|
+
if (memories.length === 0) {
|
|
41
|
+
return 'No relevant memories found.';
|
|
42
|
+
}
|
|
43
|
+
return memories
|
|
44
|
+
.map((m) => {
|
|
45
|
+
const tagSuffix = m.tags && m.tags.length > 0 ? ` {${m.tags.join(', ')}}` : '';
|
|
46
|
+
return `- [${m.category}]${tagSuffix} ${m.content}`;
|
|
47
|
+
})
|
|
48
|
+
.join('\n');
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Create a sanitized error message that doesn't expose internal details.
|
|
52
|
+
*/
|
|
53
|
+
function sanitizeErrorMessage(error) {
|
|
54
|
+
if (error instanceof Error) {
|
|
55
|
+
// Remove any internal hostnames, ports, or paths
|
|
56
|
+
const message = error.message
|
|
57
|
+
.replace(/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/g, '[host]')
|
|
58
|
+
.replace(/:\d{2,5}\b/g, '')
|
|
59
|
+
.replace(/\b(?:localhost|internal[-\w]*)\b/gi, '[internal]');
|
|
60
|
+
// If the message still looks like it contains internal details, use generic
|
|
61
|
+
if (message.includes('[internal]') || message.includes('[host]')) {
|
|
62
|
+
return 'Failed to search memories. Please try again.';
|
|
63
|
+
}
|
|
64
|
+
return message;
|
|
65
|
+
}
|
|
66
|
+
return 'An unexpected error occurred while searching memories.';
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Creates the memory_recall tool.
|
|
70
|
+
*/
|
|
71
|
+
export function createMemoryRecallTool(options) {
|
|
72
|
+
const { client, logger, config, userId } = options;
|
|
73
|
+
return {
|
|
74
|
+
name: 'memory_recall',
|
|
75
|
+
description: 'Search through long-term memories. Use when you need context about user preferences, past decisions, or previously discussed topics. Optionally filter by tags for categorical queries (e.g., ["music", "food"]). Use relationship_id to scope search to a specific relationship between contacts.',
|
|
76
|
+
parameters: MemoryRecallParamsSchema,
|
|
77
|
+
async execute(params) {
|
|
78
|
+
// Validate parameters
|
|
79
|
+
const parseResult = MemoryRecallParamsSchema.safeParse(params);
|
|
80
|
+
if (!parseResult.success) {
|
|
81
|
+
const errorMessage = parseResult.error.errors
|
|
82
|
+
.map((e) => `${e.path.join('.')}: ${e.message}`)
|
|
83
|
+
.join(', ');
|
|
84
|
+
return { success: false, error: errorMessage };
|
|
85
|
+
}
|
|
86
|
+
const { query, limit = config.maxRecallMemories, category, tags, relationship_id } = parseResult.data;
|
|
87
|
+
// Sanitize query
|
|
88
|
+
const sanitizedQuery = sanitizeQuery(query);
|
|
89
|
+
if (sanitizedQuery.length === 0) {
|
|
90
|
+
return { success: false, error: 'Query cannot be empty after sanitization' };
|
|
91
|
+
}
|
|
92
|
+
// Log invocation (without query content for privacy)
|
|
93
|
+
logger.info('memory_recall invoked', {
|
|
94
|
+
userId,
|
|
95
|
+
limit,
|
|
96
|
+
category: category ?? 'all',
|
|
97
|
+
tags: tags ?? [],
|
|
98
|
+
queryLength: sanitizedQuery.length,
|
|
99
|
+
});
|
|
100
|
+
try {
|
|
101
|
+
// Build API URL
|
|
102
|
+
const queryParams = new URLSearchParams({
|
|
103
|
+
q: sanitizedQuery,
|
|
104
|
+
limit: String(limit),
|
|
105
|
+
});
|
|
106
|
+
if (category) {
|
|
107
|
+
queryParams.set('category', category);
|
|
108
|
+
}
|
|
109
|
+
if (tags && tags.length > 0) {
|
|
110
|
+
queryParams.set('tags', tags.join(','));
|
|
111
|
+
}
|
|
112
|
+
if (relationship_id) {
|
|
113
|
+
queryParams.set('relationship_id', relationship_id);
|
|
114
|
+
}
|
|
115
|
+
const path = `/api/memories/search?${queryParams.toString()}`;
|
|
116
|
+
// Call API
|
|
117
|
+
const response = await client.get(path, { userId });
|
|
118
|
+
if (!response.success) {
|
|
119
|
+
logger.error('memory_recall API error', {
|
|
120
|
+
userId,
|
|
121
|
+
status: response.error.status,
|
|
122
|
+
code: response.error.code,
|
|
123
|
+
});
|
|
124
|
+
return {
|
|
125
|
+
success: false,
|
|
126
|
+
error: response.error.message || 'Failed to search memories',
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
const memories = response.data.memories ?? [];
|
|
130
|
+
// Format response
|
|
131
|
+
const content = formatMemoriesAsText(memories);
|
|
132
|
+
logger.debug('memory_recall completed', {
|
|
133
|
+
userId,
|
|
134
|
+
resultCount: memories.length,
|
|
135
|
+
});
|
|
136
|
+
return {
|
|
137
|
+
success: true,
|
|
138
|
+
data: {
|
|
139
|
+
content,
|
|
140
|
+
details: {
|
|
141
|
+
count: memories.length,
|
|
142
|
+
memories,
|
|
143
|
+
userId,
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
logger.error('memory_recall failed', {
|
|
150
|
+
userId,
|
|
151
|
+
error: error instanceof Error ? error.message : String(error),
|
|
152
|
+
});
|
|
153
|
+
return {
|
|
154
|
+
success: false,
|
|
155
|
+
error: sanitizeErrorMessage(error),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=memory-recall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-recall.js","sourceRoot":"","sources":["../../src/tools/memory-recall.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAKvB,sCAAsC;AACtC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAA;AAG5F,wCAAwC;AACxC,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,EAAE,uBAAuB,CAAC;SAC/B,GAAG,CAAC,IAAI,EAAE,uCAAuC,CAAC;IACrD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;IACjD,QAAQ,E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AC,yBAAyB,EAAE;wBACtC,MAAM;wBACN,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM;wBAC7B,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI;qBAC1B,CAAC,CAAA;oBACF,OAAO;wBACL,OAAO,EAAE,KAAK;wBACd,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAO,IAAI,2BAA2B;qBAC7D,CAAA;gBACH,CAAC;gBAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAA;gBAE7C,kBAAkB;gBAClB,MAAM,OAAO,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAA;gBAE9C,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE;oBACtC,MAAM;oBACN,WAAW,EAAE,QAAQ,CAAC,MAAM;iBAC7B,CAAC,CAAA;gBAEF,OAAO;oBACL,OAAO,EAAE,IAAI;oBACb,IAAI,EAAE;wBACJ,OAAO;wBACP,OAAO,EAAE;4BACP,KAAK,EAAE,QAAQ,CAAC,MAAM;4BACtB,QAAQ;4BACR,MAAM;yBACP;qBACF;iBACF,CAAA;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE;oBACnC,MAAM;oBACN,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;iBAC9D,CAAC,CAAA;gBAEF,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,oBAAoB,CAAC,KAAK,CAAC;iBACnC,CAAA;YACH,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* memory_store tool implementation.
|
|
3
|
+
* Persists important information to long-term memory.
|
|
4
|
+
* Tags support added in Issue #492.
|
|
5
|
+
* Relationship scope added in Issue #493.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import type { ApiClient } from '../api-client.js';
|
|
9
|
+
import type { Logger } from '../logger.js';
|
|
10
|
+
import type { PluginConfig } from '../config.js';
|
|
11
|
+
/** Parameters for memory_store tool */
|
|
12
|
+
export declare const MemoryStoreParamsSchema: z.ZodObject<{
|
|
13
|
+
text: z.ZodString;
|
|
14
|
+
category: z.ZodOptional<z.ZodEnum<["preference", "fact", "decision", "context", "other"]>>;
|
|
15
|
+
importance: z.ZodOptional<z.ZodNumber>;
|
|
16
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
17
|
+
relationship_id: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
text: string;
|
|
20
|
+
category?: "preference" | "fact" | "decision" | "context" | "other" | undefined;
|
|
21
|
+
tags?: string[] | undefined;
|
|
22
|
+
relationship_id?: string | undefined;
|
|
23
|
+
importance?: number | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
text: string;
|
|
26
|
+
category?: "preference" | "fact" | "decision" | "context" | "other" | undefined;
|
|
27
|
+
tags?: string[] | undefined;
|
|
28
|
+
relationship_id?: string | undefined;
|
|
29
|
+
importance?: number | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
export type MemoryStoreParams = z.infer<typeof MemoryStoreParamsSchema>;
|
|
32
|
+
/** Stored memory response from API */
|
|
33
|
+
export interface StoredMemory {
|
|
34
|
+
id: string;
|
|
35
|
+
content: string;
|
|
36
|
+
category?: string;
|
|
37
|
+
importance?: number;
|
|
38
|
+
tags?: string[];
|
|
39
|
+
createdAt?: string;
|
|
40
|
+
}
|
|
41
|
+
/** Successful tool result */
|
|
42
|
+
export interface MemoryStoreSuccess {
|
|
43
|
+
success: true;
|
|
44
|
+
data: {
|
|
45
|
+
content: string;
|
|
46
|
+
details: {
|
|
47
|
+
id: string;
|
|
48
|
+
category: string;
|
|
49
|
+
importance: number;
|
|
50
|
+
tags: string[];
|
|
51
|
+
userId: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** Failed tool result */
|
|
56
|
+
export interface MemoryStoreFailure {
|
|
57
|
+
success: false;
|
|
58
|
+
error: string;
|
|
59
|
+
}
|
|
60
|
+
/** Tool result type */
|
|
61
|
+
export type MemoryStoreResult = MemoryStoreSuccess | MemoryStoreFailure;
|
|
62
|
+
/** Tool configuration */
|
|
63
|
+
export interface MemoryStoreToolOptions {
|
|
64
|
+
client: ApiClient;
|
|
65
|
+
logger: Logger;
|
|
66
|
+
config: PluginConfig;
|
|
67
|
+
userId: string;
|
|
68
|
+
}
|
|
69
|
+
/** Tool definition */
|
|
70
|
+
export interface MemoryStoreTool {
|
|
71
|
+
name: string;
|
|
72
|
+
description: string;
|
|
73
|
+
parameters: typeof MemoryStoreParamsSchema;
|
|
74
|
+
execute: (params: MemoryStoreParams) => Promise<MemoryStoreResult>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Creates the memory_store tool.
|
|
78
|
+
*/
|
|
79
|
+
export declare function createMemoryStoreTool(options: MemoryStoreToolOptions): MemoryStoreTool;
|
|
80
|
+
//# sourceMappingURL=memory-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-store.d.ts","sourceRoot":"","sources":["../../src/tools/memory-store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAGhD,uCAAuC;AACvC,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;EAelC,CAAA;AACF,MAAM,MAAM,iBAAiB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