@frontmcp/plugin-remember 1.8.5 → 1.8.7
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/esm/index.mjs +295 -215
- package/esm/package.json +4 -4
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js +320 -239
- package/package.json +4 -4
- package/providers/remember-accessor.provider.d.ts.map +1 -1
- package/remember.errors.d.ts +13 -2
- package/remember.errors.d.ts.map +1 -1
- package/remember.plugin.d.ts +6 -1
- package/remember.plugin.d.ts.map +1 -1
- package/tools/forget.tool.d.ts +24 -0
- package/tools/forget.tool.d.ts.map +1 -1
- package/tools/index.d.ts +2 -0
- package/tools/index.d.ts.map +1 -1
- package/tools/list-memories.tool.d.ts +25 -0
- package/tools/list-memories.tool.d.ts.map +1 -1
- package/tools/recall.tool.d.ts +26 -0
- package/tools/recall.tool.d.ts.map +1 -1
- package/tools/remember-scope.description.d.ts +10 -0
- package/tools/remember-scope.description.d.ts.map +1 -0
- package/tools/remember-this.tool.d.ts +33 -0
- package/tools/remember-this.tool.d.ts.map +1 -1
- package/tools/remember-tool-names.d.ts +9 -0
- package/tools/remember-tool-names.d.ts.map +1 -0
- package/tools/remember-tools.factory.d.ts +8 -0
- package/tools/remember-tools.factory.d.ts.map +1 -0
package/esm/index.mjs
CHANGED
|
@@ -282,10 +282,21 @@ async function deserializeAndDecrypt(str, keySource) {
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
// plugins/plugin-remember/src/remember.errors.ts
|
|
285
|
-
|
|
285
|
+
import { PublicMcpError } from "@frontmcp/sdk";
|
|
286
|
+
var RememberIdentityError = class extends PublicMcpError {
|
|
286
287
|
name = "RememberIdentityError";
|
|
287
288
|
constructor(message) {
|
|
288
|
-
super(message);
|
|
289
|
+
super(message, "REMEMBER_IDENTITY_REQUIRED", 403);
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
var RememberScopeNotAllowedError = class extends PublicMcpError {
|
|
293
|
+
name = "RememberScopeNotAllowedError";
|
|
294
|
+
constructor(scope, allowedScopes) {
|
|
295
|
+
super(
|
|
296
|
+
`Scope '${scope}' is not allowed. Allowed scopes: ${allowedScopes.join(", ")}`,
|
|
297
|
+
"REMEMBER_SCOPE_NOT_ALLOWED",
|
|
298
|
+
400
|
|
299
|
+
);
|
|
289
300
|
}
|
|
290
301
|
};
|
|
291
302
|
|
|
@@ -623,7 +634,7 @@ var RememberAccessor = class {
|
|
|
623
634
|
return `${this.keyPrefix}${STORAGE_LAYOUT_VERSION}:session:${encodeKeyPart(this.resolveSessionIdentity())}:`;
|
|
624
635
|
case "user": {
|
|
625
636
|
const userId = this.userId;
|
|
626
|
-
if (!userId) {
|
|
637
|
+
if (!userId || isAnonymousSubject(userId)) {
|
|
627
638
|
throw new RememberIdentityError(
|
|
628
639
|
"Remember cannot use user scope without an authenticated user: all unauthenticated callers would share one namespace. Authenticate the request or use the 'global' scope."
|
|
629
640
|
);
|
|
@@ -1128,6 +1139,265 @@ var RememberAccessorToken = /* @__PURE__ */ Symbol(
|
|
|
1128
1139
|
"plugin:remember:accessor"
|
|
1129
1140
|
);
|
|
1130
1141
|
|
|
1142
|
+
// plugins/plugin-remember/src/tools/remember-tools.factory.ts
|
|
1143
|
+
import { Tool as Tool5 } from "@frontmcp/sdk";
|
|
1144
|
+
|
|
1145
|
+
// plugins/plugin-remember/src/tools/forget.tool.ts
|
|
1146
|
+
import { z as z2 } from "@frontmcp/lazy-zod";
|
|
1147
|
+
import { Tool, ToolContext } from "@frontmcp/sdk";
|
|
1148
|
+
|
|
1149
|
+
// plugins/plugin-remember/src/tools/remember-scope.description.ts
|
|
1150
|
+
var REMEMBER_SCOPE_DESCRIPTION = "Whose memory to use (default: session). session: this session; without one (stateless HTTP, MCP 2026-07-28), the signed-in caller across its requests. user: the signed-in caller, across all of its sessions. tool: the tool running the call, for the same caller as session; each memory tool has its own, so the other memory tools do not see what one of them stores in tool scope. global: shared by every caller. An anonymous caller cannot use user scope, nor session or tool scope without a session.";
|
|
1151
|
+
|
|
1152
|
+
// plugins/plugin-remember/src/tools/remember-tool-names.ts
|
|
1153
|
+
function rememberToolNames(prefix = "") {
|
|
1154
|
+
return {
|
|
1155
|
+
rememberThis: `${prefix}remember_this`,
|
|
1156
|
+
recall: `${prefix}recall`,
|
|
1157
|
+
forget: `${prefix}forget`,
|
|
1158
|
+
listMemories: `${prefix}list_memories`
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
// plugins/plugin-remember/src/tools/forget.tool.ts
|
|
1163
|
+
var forgetInputSchema = {
|
|
1164
|
+
key: z2.string().min(1).describe("What memory to forget"),
|
|
1165
|
+
scope: z2.enum(["session", "user", "tool", "global"]).optional().describe(REMEMBER_SCOPE_DESCRIPTION)
|
|
1166
|
+
};
|
|
1167
|
+
var forgetOutputSchema = z2.object({
|
|
1168
|
+
success: z2.boolean(),
|
|
1169
|
+
key: z2.string(),
|
|
1170
|
+
scope: z2.string(),
|
|
1171
|
+
existed: z2.boolean()
|
|
1172
|
+
});
|
|
1173
|
+
function forgetDescription() {
|
|
1174
|
+
return "Forget a previously remembered value. Use this when the user wants to delete stored preferences or information.";
|
|
1175
|
+
}
|
|
1176
|
+
function forgetToolMetadata(names = rememberToolNames()) {
|
|
1177
|
+
return {
|
|
1178
|
+
name: names.forget,
|
|
1179
|
+
description: forgetDescription(),
|
|
1180
|
+
inputSchema: forgetInputSchema,
|
|
1181
|
+
outputSchema: forgetOutputSchema,
|
|
1182
|
+
annotations: { readOnlyHint: false }
|
|
1183
|
+
};
|
|
1184
|
+
}
|
|
1185
|
+
var ForgetTool = class extends ToolContext {
|
|
1186
|
+
async execute(input) {
|
|
1187
|
+
const remember = this.get(RememberAccessorToken);
|
|
1188
|
+
const config = this.get(RememberConfigToken);
|
|
1189
|
+
const scope = input.scope ?? "session";
|
|
1190
|
+
const allowedScopes = config.tools?.allowedScopes ?? ["session", "user", "tool", "global"];
|
|
1191
|
+
if (!allowedScopes.includes(scope)) {
|
|
1192
|
+
throw this.fail(new RememberScopeNotAllowedError(scope, allowedScopes));
|
|
1193
|
+
}
|
|
1194
|
+
const existed = await remember.knows(input.key, { scope });
|
|
1195
|
+
await remember.forget(input.key, { scope });
|
|
1196
|
+
return {
|
|
1197
|
+
success: true,
|
|
1198
|
+
key: input.key,
|
|
1199
|
+
scope,
|
|
1200
|
+
existed
|
|
1201
|
+
};
|
|
1202
|
+
}
|
|
1203
|
+
};
|
|
1204
|
+
ForgetTool = __decorateClass([
|
|
1205
|
+
Tool(forgetToolMetadata())
|
|
1206
|
+
], ForgetTool);
|
|
1207
|
+
|
|
1208
|
+
// plugins/plugin-remember/src/tools/list-memories.tool.ts
|
|
1209
|
+
import { z as z3 } from "@frontmcp/lazy-zod";
|
|
1210
|
+
import { Tool as Tool2, ToolContext as ToolContext2 } from "@frontmcp/sdk";
|
|
1211
|
+
var listMemoriesInputSchema = {
|
|
1212
|
+
scope: z3.enum(["session", "user", "tool", "global"]).optional().describe(REMEMBER_SCOPE_DESCRIPTION),
|
|
1213
|
+
pattern: z3.string().optional().describe('Pattern to filter keys (e.g., "user_*")'),
|
|
1214
|
+
limit: z3.number().positive().max(100).optional().describe("Maximum number of keys to return (default: 50)")
|
|
1215
|
+
};
|
|
1216
|
+
var listMemoriesOutputSchema = z3.object({
|
|
1217
|
+
keys: z3.array(z3.string()),
|
|
1218
|
+
scope: z3.string(),
|
|
1219
|
+
count: z3.number(),
|
|
1220
|
+
truncated: z3.boolean()
|
|
1221
|
+
});
|
|
1222
|
+
function listMemoriesDescription(names = rememberToolNames()) {
|
|
1223
|
+
return `List the remembered keys in one scope (default: session). Use this to see what memories are stored before you ${names.recall} or ${names.forget} one.`;
|
|
1224
|
+
}
|
|
1225
|
+
function listMemoriesToolMetadata(names = rememberToolNames()) {
|
|
1226
|
+
return {
|
|
1227
|
+
name: names.listMemories,
|
|
1228
|
+
description: listMemoriesDescription(names),
|
|
1229
|
+
inputSchema: listMemoriesInputSchema,
|
|
1230
|
+
outputSchema: listMemoriesOutputSchema,
|
|
1231
|
+
annotations: { readOnlyHint: true }
|
|
1232
|
+
};
|
|
1233
|
+
}
|
|
1234
|
+
var ListMemoriesTool = class extends ToolContext2 {
|
|
1235
|
+
async execute(input) {
|
|
1236
|
+
const remember = this.get(RememberAccessorToken);
|
|
1237
|
+
const config = this.get(RememberConfigToken);
|
|
1238
|
+
const scope = input.scope ?? "session";
|
|
1239
|
+
const allowedScopes = config.tools?.allowedScopes ?? ["session", "user", "tool", "global"];
|
|
1240
|
+
if (!allowedScopes.includes(scope)) {
|
|
1241
|
+
throw this.fail(new RememberScopeNotAllowedError(scope, allowedScopes));
|
|
1242
|
+
}
|
|
1243
|
+
const limit = input.limit ?? 50;
|
|
1244
|
+
let keys = await remember.list({ scope, pattern: input.pattern });
|
|
1245
|
+
const truncated = keys.length > limit;
|
|
1246
|
+
if (truncated) {
|
|
1247
|
+
keys = keys.slice(0, limit);
|
|
1248
|
+
}
|
|
1249
|
+
return {
|
|
1250
|
+
keys,
|
|
1251
|
+
scope,
|
|
1252
|
+
count: keys.length,
|
|
1253
|
+
truncated
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
};
|
|
1257
|
+
ListMemoriesTool = __decorateClass([
|
|
1258
|
+
Tool2(listMemoriesToolMetadata())
|
|
1259
|
+
], ListMemoriesTool);
|
|
1260
|
+
|
|
1261
|
+
// plugins/plugin-remember/src/tools/recall.tool.ts
|
|
1262
|
+
import { z as z4 } from "@frontmcp/lazy-zod";
|
|
1263
|
+
import { Tool as Tool3, ToolContext as ToolContext3 } from "@frontmcp/sdk";
|
|
1264
|
+
var recallInputSchema = {
|
|
1265
|
+
key: z4.string().min(1).describe("What memory to recall"),
|
|
1266
|
+
scope: z4.enum(["session", "user", "tool", "global"]).optional().describe(REMEMBER_SCOPE_DESCRIPTION)
|
|
1267
|
+
};
|
|
1268
|
+
var recallOutputSchema = z4.object({
|
|
1269
|
+
found: z4.boolean(),
|
|
1270
|
+
key: z4.string(),
|
|
1271
|
+
value: z4.unknown().optional(),
|
|
1272
|
+
scope: z4.string(),
|
|
1273
|
+
createdAt: z4.number().optional(),
|
|
1274
|
+
expiresAt: z4.number().optional()
|
|
1275
|
+
});
|
|
1276
|
+
function recallDescription(names = rememberToolNames()) {
|
|
1277
|
+
return `Recall something that was previously remembered. Use this to retrieve stored preferences, settings, or any information that was saved with ${names.rememberThis}.`;
|
|
1278
|
+
}
|
|
1279
|
+
function recallToolMetadata(names = rememberToolNames()) {
|
|
1280
|
+
return {
|
|
1281
|
+
name: names.recall,
|
|
1282
|
+
description: recallDescription(names),
|
|
1283
|
+
inputSchema: recallInputSchema,
|
|
1284
|
+
outputSchema: recallOutputSchema,
|
|
1285
|
+
annotations: { readOnlyHint: true }
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
1288
|
+
var RecallTool = class extends ToolContext3 {
|
|
1289
|
+
async execute(input) {
|
|
1290
|
+
const remember = this.get(RememberAccessorToken);
|
|
1291
|
+
const config = this.get(RememberConfigToken);
|
|
1292
|
+
const scope = input.scope ?? "session";
|
|
1293
|
+
const allowedScopes = config.tools?.allowedScopes ?? ["session", "user", "tool", "global"];
|
|
1294
|
+
if (!allowedScopes.includes(scope)) {
|
|
1295
|
+
throw this.fail(new RememberScopeNotAllowedError(scope, allowedScopes));
|
|
1296
|
+
}
|
|
1297
|
+
const entry = await remember.getEntry(input.key, { scope });
|
|
1298
|
+
if (!entry) {
|
|
1299
|
+
return {
|
|
1300
|
+
found: false,
|
|
1301
|
+
key: input.key,
|
|
1302
|
+
scope
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1305
|
+
return {
|
|
1306
|
+
found: true,
|
|
1307
|
+
key: input.key,
|
|
1308
|
+
value: entry.value,
|
|
1309
|
+
scope,
|
|
1310
|
+
createdAt: entry.createdAt,
|
|
1311
|
+
expiresAt: entry.expiresAt
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
1314
|
+
};
|
|
1315
|
+
RecallTool = __decorateClass([
|
|
1316
|
+
Tool3(recallToolMetadata())
|
|
1317
|
+
], RecallTool);
|
|
1318
|
+
|
|
1319
|
+
// plugins/plugin-remember/src/tools/remember-this.tool.ts
|
|
1320
|
+
import { z as z5 } from "@frontmcp/lazy-zod";
|
|
1321
|
+
import { Tool as Tool4, ToolContext as ToolContext4 } from "@frontmcp/sdk";
|
|
1322
|
+
var rememberThisInputSchema = {
|
|
1323
|
+
key: z5.string().min(1).describe('What to call this memory (e.g., "user_preference", "last_action")'),
|
|
1324
|
+
value: z5.unknown().describe("The value to remember (any JSON-serializable data)"),
|
|
1325
|
+
scope: z5.enum(["session", "user", "tool", "global"]).optional().describe(REMEMBER_SCOPE_DESCRIPTION),
|
|
1326
|
+
ttl: z5.number().positive().optional().describe("Forget after this many seconds"),
|
|
1327
|
+
brand: z5.enum(["preference", "cache", "state", "conversation", "custom"]).optional().describe("Type hint for the stored value")
|
|
1328
|
+
};
|
|
1329
|
+
var rememberThisOutputSchema = z5.object({
|
|
1330
|
+
success: z5.boolean(),
|
|
1331
|
+
key: z5.string(),
|
|
1332
|
+
scope: z5.string(),
|
|
1333
|
+
expiresAt: z5.number().optional()
|
|
1334
|
+
});
|
|
1335
|
+
function rememberThisDescription(names = rememberToolNames()) {
|
|
1336
|
+
return `Remember something for later: store a value under a key that ${names.recall} can read back, in the scope you choose (this session by default; user scope for the signed-in user across sessions). It lasts until it is forgotten or its ttl runs out. Use this when the user asks you to remember preferences, settings, or any information they want to persist.`;
|
|
1337
|
+
}
|
|
1338
|
+
function rememberThisToolMetadata(names = rememberToolNames()) {
|
|
1339
|
+
return {
|
|
1340
|
+
name: names.rememberThis,
|
|
1341
|
+
description: rememberThisDescription(names),
|
|
1342
|
+
inputSchema: rememberThisInputSchema,
|
|
1343
|
+
outputSchema: rememberThisOutputSchema,
|
|
1344
|
+
annotations: { readOnlyHint: false }
|
|
1345
|
+
};
|
|
1346
|
+
}
|
|
1347
|
+
var RememberThisTool = class extends ToolContext4 {
|
|
1348
|
+
async execute(input) {
|
|
1349
|
+
const remember = this.get(RememberAccessorToken);
|
|
1350
|
+
const config = this.get(RememberConfigToken);
|
|
1351
|
+
const scope = input.scope ?? "session";
|
|
1352
|
+
const allowedScopes = config.tools?.allowedScopes ?? ["session", "user", "tool", "global"];
|
|
1353
|
+
if (!allowedScopes.includes(scope)) {
|
|
1354
|
+
throw this.fail(new RememberScopeNotAllowedError(scope, allowedScopes));
|
|
1355
|
+
}
|
|
1356
|
+
await remember.set(input.key, input.value, {
|
|
1357
|
+
scope,
|
|
1358
|
+
ttl: input.ttl,
|
|
1359
|
+
brand: input.brand
|
|
1360
|
+
});
|
|
1361
|
+
const expiresAt = input.ttl ? Date.now() + input.ttl * 1e3 : void 0;
|
|
1362
|
+
return {
|
|
1363
|
+
success: true,
|
|
1364
|
+
key: input.key,
|
|
1365
|
+
scope,
|
|
1366
|
+
expiresAt
|
|
1367
|
+
};
|
|
1368
|
+
}
|
|
1369
|
+
};
|
|
1370
|
+
RememberThisTool = __decorateClass([
|
|
1371
|
+
Tool4(rememberThisToolMetadata())
|
|
1372
|
+
], RememberThisTool);
|
|
1373
|
+
|
|
1374
|
+
// plugins/plugin-remember/src/tools/remember-tools.factory.ts
|
|
1375
|
+
function createRememberTools(prefix = "") {
|
|
1376
|
+
if (!prefix) return [RememberThisTool, RecallTool, ForgetTool, ListMemoriesTool];
|
|
1377
|
+
const names = rememberToolNames(prefix);
|
|
1378
|
+
let PrefixedRememberThisTool = class extends RememberThisTool {
|
|
1379
|
+
};
|
|
1380
|
+
PrefixedRememberThisTool = __decorateClass([
|
|
1381
|
+
Tool5(rememberThisToolMetadata(names))
|
|
1382
|
+
], PrefixedRememberThisTool);
|
|
1383
|
+
let PrefixedRecallTool = class extends RecallTool {
|
|
1384
|
+
};
|
|
1385
|
+
PrefixedRecallTool = __decorateClass([
|
|
1386
|
+
Tool5(recallToolMetadata(names))
|
|
1387
|
+
], PrefixedRecallTool);
|
|
1388
|
+
let PrefixedForgetTool = class extends ForgetTool {
|
|
1389
|
+
};
|
|
1390
|
+
PrefixedForgetTool = __decorateClass([
|
|
1391
|
+
Tool5(forgetToolMetadata(names))
|
|
1392
|
+
], PrefixedForgetTool);
|
|
1393
|
+
let PrefixedListMemoriesTool = class extends ListMemoriesTool {
|
|
1394
|
+
};
|
|
1395
|
+
PrefixedListMemoriesTool = __decorateClass([
|
|
1396
|
+
Tool5(listMemoriesToolMetadata(names))
|
|
1397
|
+
], PrefixedListMemoriesTool);
|
|
1398
|
+
return [PrefixedRememberThisTool, PrefixedRecallTool, PrefixedForgetTool, PrefixedListMemoriesTool];
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1131
1401
|
// plugins/plugin-remember/src/remember.plugin.ts
|
|
1132
1402
|
var RememberPlugin = class extends DynamicPlugin {
|
|
1133
1403
|
options;
|
|
@@ -1144,6 +1414,11 @@ __publicField(RememberPlugin, "defaultOptions", {
|
|
|
1144
1414
|
keyPrefix: "remember:",
|
|
1145
1415
|
encryption: { enabled: true }
|
|
1146
1416
|
});
|
|
1417
|
+
/**
|
|
1418
|
+
* The memory tools, when `tools.enabled` is set: `remember_this`, `recall`, `forget` and
|
|
1419
|
+
* `list_memories`, under `tools.prefix`.
|
|
1420
|
+
*/
|
|
1421
|
+
__publicField(RememberPlugin, "dynamicTools", (options) => options.tools?.enabled ? createRememberTools(options.tools.prefix) : []);
|
|
1147
1422
|
/**
|
|
1148
1423
|
* Dynamic providers based on plugin options.
|
|
1149
1424
|
*/
|
|
@@ -1228,7 +1503,9 @@ __publicField(RememberPlugin, "dynamicProviders", (options) => {
|
|
|
1228
1503
|
providers.push({
|
|
1229
1504
|
name: "remember:store:memory",
|
|
1230
1505
|
provide: RememberStoreToken,
|
|
1231
|
-
|
|
1506
|
+
// Built per server: `init()` runs once, so a value here would be shared by every server using it.
|
|
1507
|
+
inject: () => [],
|
|
1508
|
+
useFactory: () => new RememberMemoryProvider()
|
|
1232
1509
|
});
|
|
1233
1510
|
break;
|
|
1234
1511
|
}
|
|
@@ -1251,11 +1528,13 @@ RememberPlugin = __decorateClass([
|
|
|
1251
1528
|
name: "remember",
|
|
1252
1529
|
description: "Help your LLM remember things across sessions",
|
|
1253
1530
|
providers: [
|
|
1254
|
-
// Default in-memory provider (overridden by dynamicProviders if configured)
|
|
1531
|
+
// Default in-memory provider (overridden by dynamicProviders if configured). A factory, so each
|
|
1532
|
+
// server gets its own store: a value built here is one store for every server in the process.
|
|
1255
1533
|
{
|
|
1256
1534
|
name: "remember:store:memory",
|
|
1257
1535
|
provide: RememberStoreToken,
|
|
1258
|
-
|
|
1536
|
+
inject: () => [],
|
|
1537
|
+
useFactory: () => new RememberMemoryProvider()
|
|
1259
1538
|
}
|
|
1260
1539
|
],
|
|
1261
1540
|
// Context extensions - SDK handles runtime installation
|
|
@@ -1271,219 +1550,19 @@ RememberPlugin = __decorateClass([
|
|
|
1271
1550
|
], RememberPlugin);
|
|
1272
1551
|
|
|
1273
1552
|
// plugins/plugin-remember/src/remember.types.ts
|
|
1274
|
-
import { z as
|
|
1275
|
-
var rememberScopeSchema =
|
|
1553
|
+
import { z as z6 } from "@frontmcp/lazy-zod";
|
|
1554
|
+
var rememberScopeSchema = z6.enum(["session", "user", "tool", "global"]);
|
|
1276
1555
|
function brand(data, _brand) {
|
|
1277
1556
|
return data;
|
|
1278
1557
|
}
|
|
1279
|
-
var rememberEntrySchema =
|
|
1280
|
-
value:
|
|
1281
|
-
brand:
|
|
1282
|
-
createdAt:
|
|
1283
|
-
updatedAt:
|
|
1284
|
-
expiresAt:
|
|
1285
|
-
metadata:
|
|
1286
|
-
});
|
|
1287
|
-
|
|
1288
|
-
// plugins/plugin-remember/src/tools/remember-this.tool.ts
|
|
1289
|
-
import { z as z3 } from "@frontmcp/lazy-zod";
|
|
1290
|
-
import { Tool, ToolContext } from "@frontmcp/sdk";
|
|
1291
|
-
var rememberThisInputSchema = {
|
|
1292
|
-
key: z3.string().min(1).describe('What to call this memory (e.g., "user_preference", "last_action")'),
|
|
1293
|
-
value: z3.unknown().describe("The value to remember (any JSON-serializable data)"),
|
|
1294
|
-
scope: z3.enum(["session", "user", "tool", "global"]).optional().describe(
|
|
1295
|
-
"How long to remember: session (until disconnect), user (forever), tool (for this tool), global (shared)"
|
|
1296
|
-
),
|
|
1297
|
-
ttl: z3.number().positive().optional().describe("Forget after this many seconds"),
|
|
1298
|
-
brand: z3.enum(["preference", "cache", "state", "conversation", "custom"]).optional().describe("Type hint for the stored value")
|
|
1299
|
-
};
|
|
1300
|
-
var rememberThisOutputSchema = z3.object({
|
|
1301
|
-
success: z3.boolean(),
|
|
1302
|
-
key: z3.string(),
|
|
1303
|
-
scope: z3.string(),
|
|
1304
|
-
expiresAt: z3.number().optional()
|
|
1305
|
-
});
|
|
1306
|
-
var RememberThisTool = class extends ToolContext {
|
|
1307
|
-
async execute(input) {
|
|
1308
|
-
const remember = this.get(RememberAccessorToken);
|
|
1309
|
-
const config = this.get(RememberConfigToken);
|
|
1310
|
-
const scope = input.scope ?? "session";
|
|
1311
|
-
const allowedScopes = config.tools?.allowedScopes ?? ["session", "user", "tool", "global"];
|
|
1312
|
-
if (!allowedScopes.includes(scope)) {
|
|
1313
|
-
throw this.fail(new Error(`Scope '${scope}' is not allowed. Allowed scopes: ${allowedScopes.join(", ")}`));
|
|
1314
|
-
}
|
|
1315
|
-
await remember.set(input.key, input.value, {
|
|
1316
|
-
scope,
|
|
1317
|
-
ttl: input.ttl,
|
|
1318
|
-
brand: input.brand
|
|
1319
|
-
});
|
|
1320
|
-
const expiresAt = input.ttl ? Date.now() + input.ttl * 1e3 : void 0;
|
|
1321
|
-
return {
|
|
1322
|
-
success: true,
|
|
1323
|
-
key: input.key,
|
|
1324
|
-
scope,
|
|
1325
|
-
expiresAt
|
|
1326
|
-
};
|
|
1327
|
-
}
|
|
1328
|
-
};
|
|
1329
|
-
RememberThisTool = __decorateClass([
|
|
1330
|
-
Tool({
|
|
1331
|
-
name: "remember_this",
|
|
1332
|
-
description: "Remember something for later. Store a value that can be recalled in future conversations. Use this when the user asks you to remember preferences, settings, or any information they want to persist.",
|
|
1333
|
-
inputSchema: rememberThisInputSchema,
|
|
1334
|
-
outputSchema: rememberThisOutputSchema,
|
|
1335
|
-
annotations: {
|
|
1336
|
-
readOnlyHint: false
|
|
1337
|
-
}
|
|
1338
|
-
})
|
|
1339
|
-
], RememberThisTool);
|
|
1340
|
-
|
|
1341
|
-
// plugins/plugin-remember/src/tools/recall.tool.ts
|
|
1342
|
-
import { z as z4 } from "@frontmcp/lazy-zod";
|
|
1343
|
-
import { Tool as Tool2, ToolContext as ToolContext2 } from "@frontmcp/sdk";
|
|
1344
|
-
var recallInputSchema = {
|
|
1345
|
-
key: z4.string().min(1).describe("What memory to recall"),
|
|
1346
|
-
scope: z4.enum(["session", "user", "tool", "global"]).optional().describe("Which scope to look in (default: session)")
|
|
1347
|
-
};
|
|
1348
|
-
var recallOutputSchema = z4.object({
|
|
1349
|
-
found: z4.boolean(),
|
|
1350
|
-
key: z4.string(),
|
|
1351
|
-
value: z4.unknown().optional(),
|
|
1352
|
-
scope: z4.string(),
|
|
1353
|
-
createdAt: z4.number().optional(),
|
|
1354
|
-
expiresAt: z4.number().optional()
|
|
1355
|
-
});
|
|
1356
|
-
var RecallTool = class extends ToolContext2 {
|
|
1357
|
-
async execute(input) {
|
|
1358
|
-
const remember = this.get(RememberAccessorToken);
|
|
1359
|
-
const config = this.get(RememberConfigToken);
|
|
1360
|
-
const scope = input.scope ?? "session";
|
|
1361
|
-
const allowedScopes = config.tools?.allowedScopes ?? ["session", "user", "tool", "global"];
|
|
1362
|
-
if (!allowedScopes.includes(scope)) {
|
|
1363
|
-
this.fail(new Error(`Scope '${scope}' is not allowed. Allowed scopes: ${allowedScopes.join(", ")}`));
|
|
1364
|
-
}
|
|
1365
|
-
const entry = await remember.getEntry(input.key, { scope });
|
|
1366
|
-
if (!entry) {
|
|
1367
|
-
return {
|
|
1368
|
-
found: false,
|
|
1369
|
-
key: input.key,
|
|
1370
|
-
scope
|
|
1371
|
-
};
|
|
1372
|
-
}
|
|
1373
|
-
return {
|
|
1374
|
-
found: true,
|
|
1375
|
-
key: input.key,
|
|
1376
|
-
value: entry.value,
|
|
1377
|
-
scope,
|
|
1378
|
-
createdAt: entry.createdAt,
|
|
1379
|
-
expiresAt: entry.expiresAt
|
|
1380
|
-
};
|
|
1381
|
-
}
|
|
1382
|
-
};
|
|
1383
|
-
RecallTool = __decorateClass([
|
|
1384
|
-
Tool2({
|
|
1385
|
-
name: "recall",
|
|
1386
|
-
description: "Recall something that was previously remembered. Use this to retrieve stored preferences, settings, or any information that was saved with remember_this.",
|
|
1387
|
-
inputSchema: recallInputSchema,
|
|
1388
|
-
outputSchema: recallOutputSchema,
|
|
1389
|
-
annotations: {
|
|
1390
|
-
readOnlyHint: true
|
|
1391
|
-
}
|
|
1392
|
-
})
|
|
1393
|
-
], RecallTool);
|
|
1394
|
-
|
|
1395
|
-
// plugins/plugin-remember/src/tools/forget.tool.ts
|
|
1396
|
-
import { z as z5 } from "@frontmcp/lazy-zod";
|
|
1397
|
-
import { Tool as Tool3, ToolContext as ToolContext3 } from "@frontmcp/sdk";
|
|
1398
|
-
var forgetInputSchema = {
|
|
1399
|
-
key: z5.string().min(1).describe("What memory to forget"),
|
|
1400
|
-
scope: z5.enum(["session", "user", "tool", "global"]).optional().describe("Which scope to forget from (default: session)")
|
|
1401
|
-
};
|
|
1402
|
-
var forgetOutputSchema = z5.object({
|
|
1403
|
-
success: z5.boolean(),
|
|
1404
|
-
key: z5.string(),
|
|
1405
|
-
scope: z5.string(),
|
|
1406
|
-
existed: z5.boolean()
|
|
1558
|
+
var rememberEntrySchema = z6.object({
|
|
1559
|
+
value: z6.unknown(),
|
|
1560
|
+
brand: z6.enum(["approval", "preference", "cache", "state", "conversation", "custom"]).optional(),
|
|
1561
|
+
createdAt: z6.number(),
|
|
1562
|
+
updatedAt: z6.number(),
|
|
1563
|
+
expiresAt: z6.number().optional(),
|
|
1564
|
+
metadata: z6.record(z6.string(), z6.unknown()).optional()
|
|
1407
1565
|
});
|
|
1408
|
-
var ForgetTool = class extends ToolContext3 {
|
|
1409
|
-
async execute(input) {
|
|
1410
|
-
const remember = this.get(RememberAccessorToken);
|
|
1411
|
-
const config = this.get(RememberConfigToken);
|
|
1412
|
-
const scope = input.scope ?? "session";
|
|
1413
|
-
const allowedScopes = config.tools?.allowedScopes ?? ["session", "user", "tool", "global"];
|
|
1414
|
-
if (!allowedScopes.includes(scope)) {
|
|
1415
|
-
throw this.fail(new Error(`Scope '${scope}' is not allowed. Allowed scopes: ${allowedScopes.join(", ")}`));
|
|
1416
|
-
}
|
|
1417
|
-
const existed = await remember.knows(input.key, { scope });
|
|
1418
|
-
await remember.forget(input.key, { scope });
|
|
1419
|
-
return {
|
|
1420
|
-
success: true,
|
|
1421
|
-
key: input.key,
|
|
1422
|
-
scope,
|
|
1423
|
-
existed
|
|
1424
|
-
};
|
|
1425
|
-
}
|
|
1426
|
-
};
|
|
1427
|
-
ForgetTool = __decorateClass([
|
|
1428
|
-
Tool3({
|
|
1429
|
-
name: "forget",
|
|
1430
|
-
description: "Forget a previously remembered value. Use this when the user wants to delete stored preferences or information.",
|
|
1431
|
-
inputSchema: forgetInputSchema,
|
|
1432
|
-
outputSchema: forgetOutputSchema,
|
|
1433
|
-
annotations: {
|
|
1434
|
-
readOnlyHint: false
|
|
1435
|
-
}
|
|
1436
|
-
})
|
|
1437
|
-
], ForgetTool);
|
|
1438
|
-
|
|
1439
|
-
// plugins/plugin-remember/src/tools/list-memories.tool.ts
|
|
1440
|
-
import { z as z6 } from "@frontmcp/lazy-zod";
|
|
1441
|
-
import { Tool as Tool4, ToolContext as ToolContext4 } from "@frontmcp/sdk";
|
|
1442
|
-
var listMemoriesInputSchema = {
|
|
1443
|
-
scope: z6.enum(["session", "user", "tool", "global"]).optional().describe("Which scope to list from (default: session)"),
|
|
1444
|
-
pattern: z6.string().optional().describe('Pattern to filter keys (e.g., "user_*")'),
|
|
1445
|
-
limit: z6.number().positive().max(100).optional().describe("Maximum number of keys to return (default: 50)")
|
|
1446
|
-
};
|
|
1447
|
-
var listMemoriesOutputSchema = z6.object({
|
|
1448
|
-
keys: z6.array(z6.string()),
|
|
1449
|
-
scope: z6.string(),
|
|
1450
|
-
count: z6.number(),
|
|
1451
|
-
truncated: z6.boolean()
|
|
1452
|
-
});
|
|
1453
|
-
var ListMemoriesTool = class extends ToolContext4 {
|
|
1454
|
-
async execute(input) {
|
|
1455
|
-
const remember = this.get(RememberAccessorToken);
|
|
1456
|
-
const config = this.get(RememberConfigToken);
|
|
1457
|
-
const scope = input.scope ?? "session";
|
|
1458
|
-
const allowedScopes = config.tools?.allowedScopes ?? ["session", "user", "tool", "global"];
|
|
1459
|
-
if (!allowedScopes.includes(scope)) {
|
|
1460
|
-
throw this.fail(new Error(`Scope '${scope}' is not allowed. Allowed scopes: ${allowedScopes.join(", ")}`));
|
|
1461
|
-
}
|
|
1462
|
-
const limit = input.limit ?? 50;
|
|
1463
|
-
let keys = await remember.list({ scope, pattern: input.pattern });
|
|
1464
|
-
const truncated = keys.length > limit;
|
|
1465
|
-
if (truncated) {
|
|
1466
|
-
keys = keys.slice(0, limit);
|
|
1467
|
-
}
|
|
1468
|
-
return {
|
|
1469
|
-
keys,
|
|
1470
|
-
scope,
|
|
1471
|
-
count: keys.length,
|
|
1472
|
-
truncated
|
|
1473
|
-
};
|
|
1474
|
-
}
|
|
1475
|
-
};
|
|
1476
|
-
ListMemoriesTool = __decorateClass([
|
|
1477
|
-
Tool4({
|
|
1478
|
-
name: "list_memories",
|
|
1479
|
-
description: "List all remembered keys in a scope. Use this to see what memories are stored for the current session or user.",
|
|
1480
|
-
inputSchema: listMemoriesInputSchema,
|
|
1481
|
-
outputSchema: listMemoriesOutputSchema,
|
|
1482
|
-
annotations: {
|
|
1483
|
-
readOnlyHint: true
|
|
1484
|
-
}
|
|
1485
|
-
})
|
|
1486
|
-
], ListMemoriesTool);
|
|
1487
1566
|
|
|
1488
1567
|
// plugins/plugin-remember/src/remember.context-extension.ts
|
|
1489
1568
|
function getRemember(ctx) {
|
|
@@ -1506,6 +1585,7 @@ export {
|
|
|
1506
1585
|
RememberMemoryProvider,
|
|
1507
1586
|
RememberPlugin,
|
|
1508
1587
|
RememberRedisProvider,
|
|
1588
|
+
RememberScopeNotAllowedError,
|
|
1509
1589
|
RememberStoreToken,
|
|
1510
1590
|
RememberThisTool,
|
|
1511
1591
|
RememberVercelKvProvider,
|
package/esm/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontmcp/plugin-remember",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.7",
|
|
4
4
|
"description": "Remember plugin for FrontMCP - encrypted session memory with approval system for secure tool authorization",
|
|
5
5
|
"author": "AgentFront <info@agentfront.dev>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@frontmcp/sdk": "1.8.
|
|
53
|
-
"@frontmcp/utils": "1.8.
|
|
52
|
+
"@frontmcp/sdk": "1.8.7",
|
|
53
|
+
"@frontmcp/utils": "1.8.7",
|
|
54
54
|
"ioredis": "^5.8.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@frontmcp/lazy-zod": "1.8.
|
|
57
|
+
"@frontmcp/lazy-zod": "1.8.7",
|
|
58
58
|
"@vercel/kv": "^2.0.0 || ^3.0.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependenciesMeta": {
|
package/index.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export type { RememberScope, RememberEntry, RememberPluginOptions, RememberPlugi
|
|
|
45
45
|
export { brand } from './remember.types';
|
|
46
46
|
export type { RememberStoreInterface } from './providers/remember-store.interface';
|
|
47
47
|
export { RememberAccessor } from './providers/remember-accessor.provider';
|
|
48
|
-
export { RememberIdentityError } from './remember.errors';
|
|
48
|
+
export { RememberIdentityError, RememberScopeNotAllowedError } from './remember.errors';
|
|
49
49
|
export { default as RememberMemoryProvider } from './providers/remember-memory.provider';
|
|
50
50
|
export { default as RememberRedisProvider } from './providers/remember-redis.provider';
|
|
51
51
|
export { default as RememberVercelKvProvider } from './providers/remember-vercel-kv.provider';
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAGH,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGvE,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAGpG,YAAY,EACV,aAAa,EACb,aAAa,EACb,qBAAqB,EACrB,0BAA0B,EAC1B,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC,YAAY,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAGH,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGvE,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAGpG,YAAY,EACV,aAAa,EACb,aAAa,EACb,qBAAqB,EACrB,0BAA0B,EAC1B,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC,YAAY,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AACzF,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AACvF,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AAG9F,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAKrF,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC"}
|