@prmichaelsen/remember-mcp 3.19.3 → 4.0.0
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/AGENT.md +10 -3
- package/CHANGELOG.md +38 -0
- package/README.md +1 -1
- package/agent/commands/acp.artifact-glossary.md +530 -0
- package/agent/commands/acp.artifact-reference.md +591 -0
- package/agent/commands/acp.artifact-research.md +594 -0
- package/agent/commands/acp.audit.md +345 -0
- package/agent/commands/acp.clarification-address.md +185 -88
- package/agent/commands/acp.clarification-capture.md +44 -44
- package/agent/commands/acp.clarification-create.md +41 -42
- package/agent/commands/acp.command-create.md +49 -49
- package/agent/commands/acp.design-create.md +53 -35
- package/agent/commands/acp.design-reference.md +42 -42
- package/agent/commands/acp.handoff.md +35 -35
- package/agent/commands/acp.index.md +47 -47
- package/agent/commands/acp.init.md +105 -69
- package/agent/commands/acp.package-create.md +41 -41
- package/agent/commands/acp.package-info.md +40 -40
- package/agent/commands/acp.package-install.md +48 -48
- package/agent/commands/acp.package-list.md +40 -40
- package/agent/commands/acp.package-publish.md +62 -62
- package/agent/commands/acp.package-remove.md +41 -41
- package/agent/commands/acp.package-search.md +48 -48
- package/agent/commands/acp.package-update.md +50 -50
- package/agent/commands/acp.package-validate.md +52 -52
- package/agent/commands/acp.pattern-create.md +61 -43
- package/agent/commands/acp.plan.md +70 -47
- package/agent/commands/acp.proceed.md +188 -66
- package/agent/commands/acp.project-create.md +42 -42
- package/agent/commands/acp.project-info.md +46 -46
- package/agent/commands/acp.project-list.md +41 -41
- package/agent/commands/acp.project-remove.md +36 -36
- package/agent/commands/acp.project-set.md +33 -33
- package/agent/commands/acp.project-update.md +57 -57
- package/agent/commands/acp.projects-restore.md +37 -37
- package/agent/commands/acp.projects-sync.md +39 -39
- package/agent/commands/acp.report.md +50 -50
- package/agent/commands/acp.resume.md +36 -36
- package/agent/commands/acp.sessions.md +46 -46
- package/agent/commands/acp.status.md +43 -43
- package/agent/commands/acp.sync.md +109 -56
- package/agent/commands/acp.task-create.md +51 -49
- package/agent/commands/acp.update.md +66 -45
- package/agent/commands/acp.validate.md +110 -52
- package/agent/commands/acp.version-check-for-updates.md +40 -40
- package/agent/commands/acp.version-check.md +36 -36
- package/agent/commands/acp.version-update.md +43 -43
- package/agent/commands/command.template.md +40 -40
- package/agent/commands/git.commit.md +28 -28
- package/agent/commands/git.init.md +48 -48
- package/agent/design/design.template.md +9 -9
- package/agent/design/local.admin-debugging-tools.md +242 -0
- package/agent/design/requirements.template.md +8 -8
- package/agent/index/.gitkeep +0 -0
- package/agent/index/acp.core.yaml +137 -0
- package/agent/index/local.main.template.yaml +37 -0
- package/agent/index/local.main.yaml +48 -0
- package/agent/manifest.yaml +64 -0
- package/agent/milestones/milestone-1-{title}.template.md +8 -8
- package/agent/milestones/milestone-22-admin-debugging-tools.md +61 -0
- package/agent/milestones/milestone-23-trust-level-protection.md +122 -0
- package/agent/patterns/pattern.template.md +22 -22
- package/agent/progress.template.yaml +13 -3
- package/agent/progress.yaml +173 -3
- package/agent/schemas/package.schema.yaml +276 -0
- package/agent/scripts/acp.project-update.sh +5 -6
- package/agent/tasks/milestone-22-admin-debugging-tools/task-520-admin-gate-infrastructure.md +99 -0
- package/agent/tasks/milestone-22-admin-debugging-tools/task-521-schema-and-collection-tools.md +108 -0
- package/agent/tasks/milestone-22-admin-debugging-tools/task-522-memory-inspection-tools.md +120 -0
- package/agent/tasks/milestone-22-admin-debugging-tools/task-523-user-inspection-tools.md +126 -0
- package/agent/tasks/milestone-22-admin-debugging-tools/task-524-health-and-drift-tools.md +120 -0
- package/agent/tasks/milestone-23-trust-level-protection/task-525-remove-trust-from-create-update.md +69 -0
- package/agent/tasks/milestone-23-trust-level-protection/task-526-add-request-set-trust-level-tool.md +108 -0
- package/agent/tasks/milestone-23-trust-level-protection/task-527-update-confirm-deny-secret-token.md +60 -0
- package/agent/tasks/milestone-23-trust-level-protection/task-528-update-trust-scale-references.md +73 -0
- package/agent/tasks/milestone-23-trust-level-protection/task-529-version-bump-and-release.md +87 -0
- package/agent/tasks/task-1-{title}.template.md +18 -18
- package/dist/server-factory.js +779 -87
- package/dist/server.js +141 -41
- package/dist/services/trust-validator.d.ts +16 -14
- package/dist/tools/admin-collection-stats.d.ts +24 -0
- package/dist/tools/admin-detect-weaviate-drift.d.ts +26 -0
- package/dist/tools/admin-get-weaviate-schema.d.ts +24 -0
- package/dist/tools/admin-health-drift.spec.d.ts +5 -0
- package/dist/tools/admin-health.d.ts +15 -0
- package/dist/tools/admin-inspect-memory.d.ts +29 -0
- package/dist/tools/admin-inspect-user.d.ts +73 -0
- package/dist/tools/admin-inspect-user.spec.d.ts +5 -0
- package/dist/tools/admin-list-collections.d.ts +23 -0
- package/dist/tools/admin-memory-inspection.spec.d.ts +7 -0
- package/dist/tools/admin-schema-collection.spec.d.ts +8 -0
- package/dist/tools/admin-search-across-users.d.ts +42 -0
- package/dist/tools/confirm.d.ts +1 -0
- package/dist/tools/confirm.spec.d.ts +5 -0
- package/dist/tools/create-internal-memory.d.ts +0 -7
- package/dist/tools/create-memory.d.ts +0 -7
- package/dist/tools/deny.d.ts +1 -0
- package/dist/tools/deny.spec.d.ts +5 -0
- package/dist/tools/query-memory.d.ts +2 -0
- package/dist/tools/request-set-trust-level.d.ts +32 -0
- package/dist/tools/request-set-trust-level.spec.d.ts +2 -0
- package/dist/tools/search-memory.d.ts +2 -0
- package/dist/tools/update-internal-memory.d.ts +0 -6
- package/dist/tools/update-memory.d.ts +0 -7
- package/dist/utils/admin.d.ts +21 -0
- package/dist/utils/admin.spec.d.ts +2 -0
- package/package.json +2 -2
- package/src/server-factory.ts +137 -42
- package/src/server.ts +6 -0
- package/src/services/trust-validator.spec.ts +57 -51
- package/src/services/trust-validator.ts +28 -26
- package/src/tools/admin-collection-stats.ts +67 -0
- package/src/tools/admin-detect-weaviate-drift.ts +110 -0
- package/src/tools/admin-get-weaviate-schema.ts +68 -0
- package/src/tools/admin-health-drift.spec.ts +193 -0
- package/src/tools/admin-health.ts +88 -0
- package/src/tools/admin-inspect-memory.ts +86 -0
- package/src/tools/admin-inspect-user.spec.ts +130 -0
- package/src/tools/admin-inspect-user.ts +148 -0
- package/src/tools/admin-list-collections.ts +73 -0
- package/src/tools/admin-memory-inspection.spec.ts +206 -0
- package/src/tools/admin-schema-collection.spec.ts +167 -0
- package/src/tools/admin-search-across-users.ts +104 -0
- package/src/tools/confirm.spec.ts +108 -0
- package/src/tools/confirm.ts +24 -1
- package/src/tools/create-internal-memory.ts +0 -3
- package/src/tools/create-memory.spec.ts +6 -2
- package/src/tools/create-memory.ts +1 -9
- package/src/tools/deny.spec.ts +59 -0
- package/src/tools/deny.ts +6 -1
- package/src/tools/ghost-config.ts +19 -19
- package/src/tools/query-memory.ts +4 -2
- package/src/tools/request-set-trust-level.spec.ts +87 -0
- package/src/tools/request-set-trust-level.ts +107 -0
- package/src/tools/search-memory.ts +4 -2
- package/src/tools/update-internal-memory.ts +0 -3
- package/src/tools/update-memory.ts +0 -8
- package/src/types/memory.ts +1 -1
- package/src/utils/admin.spec.ts +70 -0
- package/src/utils/admin.ts +27 -0
package/dist/server-factory.js
CHANGED
|
@@ -726,6 +726,23 @@ function getWeaviateClient() {
|
|
|
726
726
|
}
|
|
727
727
|
return client;
|
|
728
728
|
}
|
|
729
|
+
async function testWeaviateConnection() {
|
|
730
|
+
try {
|
|
731
|
+
const weaviateClient = getWeaviateClient();
|
|
732
|
+
const isReady = await weaviateClient.isReady();
|
|
733
|
+
logger.info("Weaviate connection test successful", {
|
|
734
|
+
module: "weaviate-client",
|
|
735
|
+
isReady
|
|
736
|
+
});
|
|
737
|
+
return isReady;
|
|
738
|
+
} catch (error) {
|
|
739
|
+
logger.error("Weaviate connection test failed", {
|
|
740
|
+
module: "weaviate-client",
|
|
741
|
+
error: error instanceof Error ? error.message : String(error)
|
|
742
|
+
});
|
|
743
|
+
return false;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
729
746
|
function getMemoryCollectionName(userId) {
|
|
730
747
|
return `Memory_users_${userId}`;
|
|
731
748
|
}
|
|
@@ -940,7 +957,7 @@ var createMemoryTool = {
|
|
|
940
957
|
description: `Create a new memory with optional template.
|
|
941
958
|
|
|
942
959
|
Memories can store any type of information: notes, events, people, recipes, etc.
|
|
943
|
-
Each memory has a weight (significance 0-1)
|
|
960
|
+
Each memory has a weight (significance 0-1). Trust defaults to SECRET (level 5) and can be changed via remember_request_set_trust_level.
|
|
944
961
|
Location and context are automatically captured from the request.
|
|
945
962
|
|
|
946
963
|
**IMPORTANT - Content vs Summary**:
|
|
@@ -977,12 +994,6 @@ var createMemoryTool = {
|
|
|
977
994
|
minimum: 0,
|
|
978
995
|
maximum: 1
|
|
979
996
|
},
|
|
980
|
-
trust: {
|
|
981
|
-
type: "number",
|
|
982
|
-
description: "Access control level (0-1, default: 0.25)",
|
|
983
|
-
minimum: 0,
|
|
984
|
-
maximum: 1
|
|
985
|
-
},
|
|
986
997
|
tags: {
|
|
987
998
|
type: "array",
|
|
988
999
|
items: { type: "string" },
|
|
@@ -1078,7 +1089,6 @@ async function handleCreateMemory(args, userId, authContext, context) {
|
|
|
1078
1089
|
title: args.title,
|
|
1079
1090
|
type: args.type,
|
|
1080
1091
|
weight: args.weight,
|
|
1081
|
-
trust: args.trust,
|
|
1082
1092
|
tags: args.tags,
|
|
1083
1093
|
references: args.references,
|
|
1084
1094
|
template_id: args.template_id,
|
|
@@ -1199,8 +1209,10 @@ var searchMemoryTool = {
|
|
|
1199
1209
|
description: "Minimum weight (0-1)"
|
|
1200
1210
|
},
|
|
1201
1211
|
trust_min: {
|
|
1202
|
-
type: "
|
|
1203
|
-
description: "Minimum trust level (
|
|
1212
|
+
type: "integer",
|
|
1213
|
+
description: "Minimum trust level (1-5: 1=PUBLIC, 2=INTERNAL, 3=CONFIDENTIAL, 4=RESTRICTED, 5=SECRET)",
|
|
1214
|
+
minimum: 1,
|
|
1215
|
+
maximum: 5
|
|
1204
1216
|
},
|
|
1205
1217
|
date_from: {
|
|
1206
1218
|
type: "string",
|
|
@@ -1435,12 +1447,6 @@ var updateMemoryTool = {
|
|
|
1435
1447
|
minimum: 0,
|
|
1436
1448
|
maximum: 1
|
|
1437
1449
|
},
|
|
1438
|
-
trust: {
|
|
1439
|
-
type: "number",
|
|
1440
|
-
description: "Updated access control level (0-1)",
|
|
1441
|
-
minimum: 0,
|
|
1442
|
-
maximum: 1
|
|
1443
|
-
},
|
|
1444
1450
|
tags: {
|
|
1445
1451
|
type: "array",
|
|
1446
1452
|
items: { type: "string" },
|
|
@@ -1531,7 +1537,6 @@ async function handleUpdateMemory(args, userId, authContext) {
|
|
|
1531
1537
|
title: args.title,
|
|
1532
1538
|
type: args.type,
|
|
1533
1539
|
weight: args.weight,
|
|
1534
|
-
trust: args.trust,
|
|
1535
1540
|
tags: args.tags,
|
|
1536
1541
|
references: args.references,
|
|
1537
1542
|
parent_id: args.parent_id,
|
|
@@ -1735,8 +1740,10 @@ var queryMemoryTool = {
|
|
|
1735
1740
|
description: "Minimum weight (0-1)"
|
|
1736
1741
|
},
|
|
1737
1742
|
trust_min: {
|
|
1738
|
-
type: "
|
|
1739
|
-
description: "Minimum trust level (
|
|
1743
|
+
type: "integer",
|
|
1744
|
+
description: "Minimum trust level (1-5: 1=PUBLIC, 2=INTERNAL, 3=CONFIDENTIAL, 4=RESTRICTED, 5=SECRET)",
|
|
1745
|
+
minimum: 1,
|
|
1746
|
+
maximum: 5
|
|
1740
1747
|
},
|
|
1741
1748
|
date_from: {
|
|
1742
1749
|
type: "string",
|
|
@@ -2731,6 +2738,10 @@ Violating these requirements bypasses user consent and is a security violation.`
|
|
|
2731
2738
|
token: {
|
|
2732
2739
|
type: "string",
|
|
2733
2740
|
description: "The confirmation token from the action tool"
|
|
2741
|
+
},
|
|
2742
|
+
secret_token: {
|
|
2743
|
+
type: "string",
|
|
2744
|
+
description: "HMAC secret token for guard-protected operations. Only required when confirmation guard is enabled on the server."
|
|
2734
2745
|
}
|
|
2735
2746
|
},
|
|
2736
2747
|
required: ["token"]
|
|
@@ -2793,7 +2804,23 @@ async function handleConfirm(args, userId, authContext) {
|
|
|
2793
2804
|
2
|
|
2794
2805
|
);
|
|
2795
2806
|
}
|
|
2796
|
-
|
|
2807
|
+
if (request.action === "set_trust_level") {
|
|
2808
|
+
const { memory } = createCoreServices(userId);
|
|
2809
|
+
const result2 = await memory.confirmSetTrustLevel(args.token);
|
|
2810
|
+
return JSON.stringify(
|
|
2811
|
+
{
|
|
2812
|
+
success: true,
|
|
2813
|
+
memory_id: result2.memory_id,
|
|
2814
|
+
previous_trust_level: result2.previous_trust_level,
|
|
2815
|
+
new_trust_level: result2.new_trust_level,
|
|
2816
|
+
updated_at: result2.updated_at,
|
|
2817
|
+
message: `Trust level changed from ${result2.previous_trust_level} to ${result2.new_trust_level}`
|
|
2818
|
+
},
|
|
2819
|
+
null,
|
|
2820
|
+
2
|
|
2821
|
+
);
|
|
2822
|
+
}
|
|
2823
|
+
const result = await space.confirm({ token: args.token, secret_token: args.secret_token });
|
|
2797
2824
|
if (result.action === "retract_memory") {
|
|
2798
2825
|
return JSON.stringify(
|
|
2799
2826
|
{
|
|
@@ -2878,6 +2905,10 @@ This ensures proper user consent workflow is followed.`,
|
|
|
2878
2905
|
token: {
|
|
2879
2906
|
type: "string",
|
|
2880
2907
|
description: "The confirmation token from the action tool"
|
|
2908
|
+
},
|
|
2909
|
+
secret_token: {
|
|
2910
|
+
type: "string",
|
|
2911
|
+
description: "HMAC secret token for guard-protected operations. Only required when confirmation guard is enabled on the server."
|
|
2881
2912
|
}
|
|
2882
2913
|
},
|
|
2883
2914
|
required: ["token"]
|
|
@@ -2889,7 +2920,7 @@ async function handleDeny(args, userId, authContext) {
|
|
|
2889
2920
|
debug.info("Tool invoked");
|
|
2890
2921
|
debug.trace("Arguments", { args });
|
|
2891
2922
|
const { space } = createCoreServices(userId);
|
|
2892
|
-
const result = await space.deny({ token: args.token });
|
|
2923
|
+
const result = await space.deny({ token: args.token, secret_token: args.secret_token });
|
|
2893
2924
|
return JSON.stringify(
|
|
2894
2925
|
{
|
|
2895
2926
|
success: result.success
|
|
@@ -3468,17 +3499,17 @@ var ghostConfigTool = {
|
|
|
3468
3499
|
Actions:
|
|
3469
3500
|
- get: View current ghost configuration
|
|
3470
3501
|
- set: Update ghost settings (enabled, trust defaults, enforcement mode)
|
|
3471
|
-
- set_trust: Set a per-user trust level override (
|
|
3502
|
+
- set_trust: Set a per-user trust level override (1-5 integer)
|
|
3472
3503
|
- remove_trust: Remove a per-user trust override (revert to default)
|
|
3473
3504
|
- block: Block a user from ghost access entirely
|
|
3474
3505
|
- unblock: Unblock a previously blocked user
|
|
3475
3506
|
|
|
3476
|
-
Trust levels control what information your ghost can share:
|
|
3477
|
-
-
|
|
3478
|
-
-
|
|
3479
|
-
-
|
|
3480
|
-
-
|
|
3481
|
-
-
|
|
3507
|
+
Trust levels (1-5 integer scale) control what information your ghost can share:
|
|
3508
|
+
- 1 (PUBLIC): Full access (all content revealed)
|
|
3509
|
+
- 2 (INTERNAL): Partial access (content with sensitive fields redacted)
|
|
3510
|
+
- 3 (CONFIDENTIAL): Summary only (AI-generated summary, no raw content)
|
|
3511
|
+
- 4 (RESTRICTED): Metadata only (tags, type, dates \u2014 no content)
|
|
3512
|
+
- 5 (SECRET): Existence only ("A memory exists about this")
|
|
3482
3513
|
|
|
3483
3514
|
Ghost is disabled by default. Enable it to allow others to chat with your AI representation.`,
|
|
3484
3515
|
inputSchema: {
|
|
@@ -3499,16 +3530,16 @@ Ghost is disabled by default. Enable it to allow others to chat with your AI rep
|
|
|
3499
3530
|
description: 'Allow non-friends to chat with ghost (for "set" action)'
|
|
3500
3531
|
},
|
|
3501
3532
|
default_friend_trust: {
|
|
3502
|
-
type: "
|
|
3503
|
-
description: 'Default trust level for friends (
|
|
3504
|
-
minimum:
|
|
3505
|
-
maximum:
|
|
3533
|
+
type: "integer",
|
|
3534
|
+
description: 'Default trust level for friends (1-5 integer, for "set" action)',
|
|
3535
|
+
minimum: 1,
|
|
3536
|
+
maximum: 5
|
|
3506
3537
|
},
|
|
3507
3538
|
default_public_trust: {
|
|
3508
|
-
type: "
|
|
3509
|
-
description: 'Default trust level for strangers (
|
|
3510
|
-
minimum:
|
|
3511
|
-
maximum:
|
|
3539
|
+
type: "integer",
|
|
3540
|
+
description: 'Default trust level for strangers (1-5 integer, for "set" action)',
|
|
3541
|
+
minimum: 1,
|
|
3542
|
+
maximum: 5
|
|
3512
3543
|
},
|
|
3513
3544
|
enforcement_mode: {
|
|
3514
3545
|
type: "string",
|
|
@@ -3521,10 +3552,10 @@ Ghost is disabled by default. Enable it to allow others to chat with your AI rep
|
|
|
3521
3552
|
description: "Target user ID (for set_trust, remove_trust, block, unblock)"
|
|
3522
3553
|
},
|
|
3523
3554
|
trust_level: {
|
|
3524
|
-
type: "
|
|
3525
|
-
description: 'Trust level to assign (
|
|
3526
|
-
minimum:
|
|
3527
|
-
maximum:
|
|
3555
|
+
type: "integer",
|
|
3556
|
+
description: 'Trust level to assign (1-5 integer, for "set_trust" action)',
|
|
3557
|
+
minimum: 1,
|
|
3558
|
+
maximum: 5
|
|
3528
3559
|
}
|
|
3529
3560
|
},
|
|
3530
3561
|
required: ["action"]
|
|
@@ -3636,6 +3667,88 @@ async function handleGhostConfig(args, userId, authContext) {
|
|
|
3636
3667
|
}
|
|
3637
3668
|
}
|
|
3638
3669
|
|
|
3670
|
+
// src/tools/request-set-trust-level.ts
|
|
3671
|
+
var requestSetTrustLevelTool = {
|
|
3672
|
+
name: "remember_request_set_trust_level",
|
|
3673
|
+
description: `Request a trust level change for a memory. Returns a confirmation token.
|
|
3674
|
+
|
|
3675
|
+
Trust levels (1-5 integer scale):
|
|
3676
|
+
1 = PUBLIC \u2014 anyone can see
|
|
3677
|
+
2 = INTERNAL \u2014 friends/known users
|
|
3678
|
+
3 = CONFIDENTIAL \u2014 trusted friends
|
|
3679
|
+
4 = RESTRICTED \u2014 close/intimate contacts
|
|
3680
|
+
5 = SECRET \u2014 owner only (default for new memories)
|
|
3681
|
+
|
|
3682
|
+
After requesting, use remember_confirm with the returned token to apply the change.
|
|
3683
|
+
Lowering trust (e.g. 5\u21921) makes the memory MORE visible. Raising trust makes it LESS visible.
|
|
3684
|
+
|
|
3685
|
+
This is the ONLY way to change a memory's trust level. Trust cannot be set during creation or update.`,
|
|
3686
|
+
inputSchema: {
|
|
3687
|
+
type: "object",
|
|
3688
|
+
properties: {
|
|
3689
|
+
memory_id: {
|
|
3690
|
+
type: "string",
|
|
3691
|
+
description: "ID of the memory to change trust level for"
|
|
3692
|
+
},
|
|
3693
|
+
trust_level: {
|
|
3694
|
+
type: "integer",
|
|
3695
|
+
description: "New trust level (1-5)",
|
|
3696
|
+
minimum: 1,
|
|
3697
|
+
maximum: 5
|
|
3698
|
+
}
|
|
3699
|
+
},
|
|
3700
|
+
required: ["memory_id", "trust_level"]
|
|
3701
|
+
}
|
|
3702
|
+
};
|
|
3703
|
+
async function handleRequestSetTrustLevel(args, userId, authContext) {
|
|
3704
|
+
const debug = createDebugLogger({
|
|
3705
|
+
tool: "remember_request_set_trust_level",
|
|
3706
|
+
userId,
|
|
3707
|
+
operation: "request set trust level"
|
|
3708
|
+
});
|
|
3709
|
+
try {
|
|
3710
|
+
debug.info("Tool invoked");
|
|
3711
|
+
debug.trace("Arguments", { args });
|
|
3712
|
+
if (!Number.isInteger(args.trust_level) || args.trust_level < 1 || args.trust_level > 5) {
|
|
3713
|
+
return JSON.stringify({
|
|
3714
|
+
error: "Invalid trust level",
|
|
3715
|
+
message: "Trust level must be an integer from 1 (PUBLIC) to 5 (SECRET)."
|
|
3716
|
+
}, null, 2);
|
|
3717
|
+
}
|
|
3718
|
+
const { memory } = createCoreServices(userId);
|
|
3719
|
+
const result = await memory.requestSetTrustLevel({
|
|
3720
|
+
memory_id: args.memory_id,
|
|
3721
|
+
trust_level: args.trust_level
|
|
3722
|
+
});
|
|
3723
|
+
const TRUST_NAMES = {
|
|
3724
|
+
1: "PUBLIC",
|
|
3725
|
+
2: "INTERNAL",
|
|
3726
|
+
3: "CONFIDENTIAL",
|
|
3727
|
+
4: "RESTRICTED",
|
|
3728
|
+
5: "SECRET"
|
|
3729
|
+
};
|
|
3730
|
+
return JSON.stringify({
|
|
3731
|
+
token: result.token,
|
|
3732
|
+
memory_id: result.memory_id,
|
|
3733
|
+
current_trust_level: result.current_trust_level,
|
|
3734
|
+
requested_trust_level: result.requested_trust_level,
|
|
3735
|
+
current_trust_name: TRUST_NAMES[result.current_trust_level] || "UNKNOWN",
|
|
3736
|
+
requested_trust_name: TRUST_NAMES[result.requested_trust_level] || "UNKNOWN",
|
|
3737
|
+
expires_at: result.expires_at,
|
|
3738
|
+
message: `Trust level change requested: ${TRUST_NAMES[result.current_trust_level] || result.current_trust_level} (${result.current_trust_level}) \u2192 ${TRUST_NAMES[result.requested_trust_level] || result.requested_trust_level} (${result.requested_trust_level}). Confirm with token to apply.`
|
|
3739
|
+
}, null, 2);
|
|
3740
|
+
} catch (error) {
|
|
3741
|
+
debug.error("Tool failed", { error: error instanceof Error ? error.message : String(error) });
|
|
3742
|
+
handleToolError(error, {
|
|
3743
|
+
toolName: "remember_request_set_trust_level",
|
|
3744
|
+
operation: "request set trust level",
|
|
3745
|
+
userId,
|
|
3746
|
+
memoryId: args.memory_id
|
|
3747
|
+
});
|
|
3748
|
+
return JSON.stringify({ error: "Unexpected error" });
|
|
3749
|
+
}
|
|
3750
|
+
}
|
|
3751
|
+
|
|
3639
3752
|
// src/tools/search-by.ts
|
|
3640
3753
|
var searchByTool = {
|
|
3641
3754
|
name: "remember_search_by",
|
|
@@ -3928,7 +4041,6 @@ var createInternalMemoryTool = {
|
|
|
3928
4041
|
title: { type: "string", description: "Optional title" },
|
|
3929
4042
|
tags: { type: "array", items: { type: "string" }, description: "Additional tags (internal tags added automatically)" },
|
|
3930
4043
|
weight: { type: "number", minimum: 0, maximum: 1, description: "Significance (0-1)" },
|
|
3931
|
-
trust: { type: "number", minimum: 0, maximum: 1, description: "Trust level (0-1)" },
|
|
3932
4044
|
feel_salience: { type: "number", minimum: 0, maximum: 1 },
|
|
3933
4045
|
feel_social_weight: { type: "number", minimum: 0, maximum: 1 },
|
|
3934
4046
|
feel_narrative_importance: { type: "number", minimum: 0, maximum: 1 }
|
|
@@ -3959,7 +4071,6 @@ async function handleCreateInternalMemory(args, userId, authContext) {
|
|
|
3959
4071
|
title: args.title,
|
|
3960
4072
|
type: ctx.type,
|
|
3961
4073
|
weight: args.weight,
|
|
3962
|
-
trust: args.trust,
|
|
3963
4074
|
tags: mergedTags,
|
|
3964
4075
|
context_summary: `Internal memory created via MCP (${ctx.type})`,
|
|
3965
4076
|
...feelFields
|
|
@@ -3993,8 +4104,7 @@ var updateInternalMemoryTool = {
|
|
|
3993
4104
|
content: { type: "string" },
|
|
3994
4105
|
title: { type: "string" },
|
|
3995
4106
|
tags: { type: "array", items: { type: "string" } },
|
|
3996
|
-
weight: { type: "number", minimum: 0, maximum: 1 }
|
|
3997
|
-
trust: { type: "number", minimum: 0, maximum: 1 }
|
|
4107
|
+
weight: { type: "number", minimum: 0, maximum: 1 }
|
|
3998
4108
|
},
|
|
3999
4109
|
required: ["memory_id"]
|
|
4000
4110
|
}
|
|
@@ -4024,8 +4134,7 @@ async function handleUpdateInternalMemory(args, userId, authContext) {
|
|
|
4024
4134
|
content: args.content,
|
|
4025
4135
|
title: args.title,
|
|
4026
4136
|
tags: args.tags,
|
|
4027
|
-
weight: args.weight
|
|
4028
|
-
trust: args.trust
|
|
4137
|
+
weight: args.weight
|
|
4029
4138
|
});
|
|
4030
4139
|
return JSON.stringify({
|
|
4031
4140
|
memory_id: result.memory_id,
|
|
@@ -4504,6 +4613,532 @@ async function checkIfFriend(ownerUserId, accessorUserId) {
|
|
|
4504
4613
|
}
|
|
4505
4614
|
}
|
|
4506
4615
|
|
|
4616
|
+
// src/utils/admin.ts
|
|
4617
|
+
function isAdmin(userId) {
|
|
4618
|
+
const adminIds = (process.env.ADMIN_USER_IDS || "").split(",").map((id) => id.trim()).filter(Boolean);
|
|
4619
|
+
return adminIds.includes(userId);
|
|
4620
|
+
}
|
|
4621
|
+
function adminPermissionError() {
|
|
4622
|
+
return {
|
|
4623
|
+
content: [{ type: "text", text: "Permission denied: admin access required" }],
|
|
4624
|
+
isError: true
|
|
4625
|
+
};
|
|
4626
|
+
}
|
|
4627
|
+
|
|
4628
|
+
// src/tools/admin-get-weaviate-schema.ts
|
|
4629
|
+
var adminGetWeaviateSchemaTool = {
|
|
4630
|
+
name: "remember_admin_get_weaviate_schema",
|
|
4631
|
+
description: `[Admin] Inspect a Weaviate collection's schema \u2014 property names, types, and configuration.
|
|
4632
|
+
|
|
4633
|
+
Requires admin access (ADMIN_USER_IDS).`,
|
|
4634
|
+
inputSchema: {
|
|
4635
|
+
type: "object",
|
|
4636
|
+
properties: {
|
|
4637
|
+
collection_name: {
|
|
4638
|
+
type: "string",
|
|
4639
|
+
description: 'Collection name (e.g. "Memory_users_abc123", "Memory_spaces_public")'
|
|
4640
|
+
}
|
|
4641
|
+
},
|
|
4642
|
+
required: ["collection_name"]
|
|
4643
|
+
}
|
|
4644
|
+
};
|
|
4645
|
+
async function handleAdminGetWeaviateSchema(args, userId, _authContext) {
|
|
4646
|
+
const debug = createDebugLogger({ tool: "remember_admin_get_weaviate_schema", userId, operation: "get schema" });
|
|
4647
|
+
try {
|
|
4648
|
+
if (!isAdmin(userId)) {
|
|
4649
|
+
return JSON.stringify(adminPermissionError());
|
|
4650
|
+
}
|
|
4651
|
+
debug.info("Tool invoked", { collection_name: args.collection_name });
|
|
4652
|
+
const client2 = getWeaviateClient();
|
|
4653
|
+
const collection = client2.collections.get(args.collection_name);
|
|
4654
|
+
const config2 = await collection.config.get();
|
|
4655
|
+
return JSON.stringify({
|
|
4656
|
+
collection_name: args.collection_name,
|
|
4657
|
+
properties: config2.properties.map((p) => ({
|
|
4658
|
+
name: p.name,
|
|
4659
|
+
dataType: p.dataType,
|
|
4660
|
+
description: p.description,
|
|
4661
|
+
indexFilterable: p.indexFilterable,
|
|
4662
|
+
indexSearchable: p.indexSearchable,
|
|
4663
|
+
tokenization: p.tokenization
|
|
4664
|
+
})),
|
|
4665
|
+
vectorizers: config2.vectorizers,
|
|
4666
|
+
generative: config2.generative,
|
|
4667
|
+
multiTenancy: config2.multiTenancy,
|
|
4668
|
+
replication: config2.replication
|
|
4669
|
+
}, null, 2);
|
|
4670
|
+
} catch (error) {
|
|
4671
|
+
return handleToolError(error, { toolName: "remember_admin_get_weaviate_schema", userId, operation: "get schema" });
|
|
4672
|
+
}
|
|
4673
|
+
}
|
|
4674
|
+
|
|
4675
|
+
// src/tools/admin-list-collections.ts
|
|
4676
|
+
var adminListCollectionsTool = {
|
|
4677
|
+
name: "remember_admin_list_collections",
|
|
4678
|
+
description: `[Admin] List all Weaviate collections with type categorization (user, space, group).
|
|
4679
|
+
|
|
4680
|
+
Optionally filter by prefix (e.g. "Memory_users_", "Memory_spaces_").
|
|
4681
|
+
Requires admin access (ADMIN_USER_IDS).`,
|
|
4682
|
+
inputSchema: {
|
|
4683
|
+
type: "object",
|
|
4684
|
+
properties: {
|
|
4685
|
+
filter: {
|
|
4686
|
+
type: "string",
|
|
4687
|
+
description: 'Optional prefix filter (e.g. "Memory_users_", "Memory_spaces_")'
|
|
4688
|
+
}
|
|
4689
|
+
}
|
|
4690
|
+
}
|
|
4691
|
+
};
|
|
4692
|
+
function categorizeCollection(name) {
|
|
4693
|
+
if (name.startsWith("Memory_users_"))
|
|
4694
|
+
return "user";
|
|
4695
|
+
if (name.startsWith("Memory_spaces_"))
|
|
4696
|
+
return "space";
|
|
4697
|
+
if (name.startsWith("Memory_groups_"))
|
|
4698
|
+
return "group";
|
|
4699
|
+
if (name.startsWith("Memory_friends_"))
|
|
4700
|
+
return "friends";
|
|
4701
|
+
return "other";
|
|
4702
|
+
}
|
|
4703
|
+
async function handleAdminListCollections(args, userId, _authContext) {
|
|
4704
|
+
const debug = createDebugLogger({ tool: "remember_admin_list_collections", userId, operation: "list collections" });
|
|
4705
|
+
try {
|
|
4706
|
+
if (!isAdmin(userId)) {
|
|
4707
|
+
return JSON.stringify(adminPermissionError());
|
|
4708
|
+
}
|
|
4709
|
+
debug.info("Tool invoked", { filter: args.filter });
|
|
4710
|
+
const client2 = getWeaviateClient();
|
|
4711
|
+
const allCollections = await client2.collections.listAll();
|
|
4712
|
+
let collections = allCollections.map((c) => ({
|
|
4713
|
+
name: c.name,
|
|
4714
|
+
type: categorizeCollection(c.name)
|
|
4715
|
+
}));
|
|
4716
|
+
if (args.filter) {
|
|
4717
|
+
collections = collections.filter((c) => c.name.startsWith(args.filter));
|
|
4718
|
+
}
|
|
4719
|
+
return JSON.stringify({
|
|
4720
|
+
total: collections.length,
|
|
4721
|
+
collections
|
|
4722
|
+
}, null, 2);
|
|
4723
|
+
} catch (error) {
|
|
4724
|
+
return handleToolError(error, { toolName: "remember_admin_list_collections", userId, operation: "list collections" });
|
|
4725
|
+
}
|
|
4726
|
+
}
|
|
4727
|
+
|
|
4728
|
+
// src/tools/admin-collection-stats.ts
|
|
4729
|
+
var adminCollectionStatsTool = {
|
|
4730
|
+
name: "remember_admin_collection_stats",
|
|
4731
|
+
description: `[Admin] Get stats for a Weaviate collection \u2014 object count, property count, configuration.
|
|
4732
|
+
|
|
4733
|
+
Requires admin access (ADMIN_USER_IDS).`,
|
|
4734
|
+
inputSchema: {
|
|
4735
|
+
type: "object",
|
|
4736
|
+
properties: {
|
|
4737
|
+
collection_name: {
|
|
4738
|
+
type: "string",
|
|
4739
|
+
description: "Collection name to get stats for"
|
|
4740
|
+
}
|
|
4741
|
+
},
|
|
4742
|
+
required: ["collection_name"]
|
|
4743
|
+
}
|
|
4744
|
+
};
|
|
4745
|
+
async function handleAdminCollectionStats(args, userId, _authContext) {
|
|
4746
|
+
const debug = createDebugLogger({ tool: "remember_admin_collection_stats", userId, operation: "collection stats" });
|
|
4747
|
+
try {
|
|
4748
|
+
if (!isAdmin(userId)) {
|
|
4749
|
+
return JSON.stringify(adminPermissionError());
|
|
4750
|
+
}
|
|
4751
|
+
debug.info("Tool invoked", { collection_name: args.collection_name });
|
|
4752
|
+
const client2 = getWeaviateClient();
|
|
4753
|
+
const collection = client2.collections.get(args.collection_name);
|
|
4754
|
+
const [config2, objectCount] = await Promise.all([
|
|
4755
|
+
collection.config.get(),
|
|
4756
|
+
collection.length()
|
|
4757
|
+
]);
|
|
4758
|
+
return JSON.stringify({
|
|
4759
|
+
collection_name: args.collection_name,
|
|
4760
|
+
object_count: objectCount,
|
|
4761
|
+
property_count: config2.properties.length,
|
|
4762
|
+
properties: config2.properties.map((p) => p.name),
|
|
4763
|
+
vectorizers: config2.vectorizers,
|
|
4764
|
+
multiTenancy: config2.multiTenancy,
|
|
4765
|
+
replication: config2.replication
|
|
4766
|
+
}, null, 2);
|
|
4767
|
+
} catch (error) {
|
|
4768
|
+
return handleToolError(error, { toolName: "remember_admin_collection_stats", userId, operation: "collection stats" });
|
|
4769
|
+
}
|
|
4770
|
+
}
|
|
4771
|
+
|
|
4772
|
+
// src/tools/admin-inspect-memory.ts
|
|
4773
|
+
import { MemoryIndexService as MemoryIndexService2, createLogger as createLogger2 } from "@prmichaelsen/remember-core";
|
|
4774
|
+
var indexService = new MemoryIndexService2(createLogger2("info"));
|
|
4775
|
+
var adminInspectMemoryTool = {
|
|
4776
|
+
name: "remember_admin_inspect_memory",
|
|
4777
|
+
description: `[Admin] Fetch a raw memory object by UUID \u2014 all fields including internal metadata.
|
|
4778
|
+
|
|
4779
|
+
Uses the Firestore index to resolve which collection the memory lives in.
|
|
4780
|
+
Optionally includes the vector embedding.
|
|
4781
|
+
Requires admin access (ADMIN_USER_IDS).`,
|
|
4782
|
+
inputSchema: {
|
|
4783
|
+
type: "object",
|
|
4784
|
+
properties: {
|
|
4785
|
+
memory_id: {
|
|
4786
|
+
type: "string",
|
|
4787
|
+
description: "Memory UUID"
|
|
4788
|
+
},
|
|
4789
|
+
include_vector: {
|
|
4790
|
+
type: "boolean",
|
|
4791
|
+
description: "Include the vector embedding in the response. Default: false"
|
|
4792
|
+
}
|
|
4793
|
+
},
|
|
4794
|
+
required: ["memory_id"]
|
|
4795
|
+
}
|
|
4796
|
+
};
|
|
4797
|
+
async function handleAdminInspectMemory(args, userId, _authContext) {
|
|
4798
|
+
const debug = createDebugLogger({ tool: "remember_admin_inspect_memory", userId, operation: "inspect memory" });
|
|
4799
|
+
try {
|
|
4800
|
+
if (!isAdmin(userId)) {
|
|
4801
|
+
return JSON.stringify(adminPermissionError());
|
|
4802
|
+
}
|
|
4803
|
+
debug.info("Tool invoked", { memory_id: args.memory_id, include_vector: args.include_vector });
|
|
4804
|
+
const collectionName = await indexService.lookup(args.memory_id);
|
|
4805
|
+
if (!collectionName) {
|
|
4806
|
+
return JSON.stringify({ error: `Memory not found in index: ${args.memory_id}` });
|
|
4807
|
+
}
|
|
4808
|
+
const client2 = getWeaviateClient();
|
|
4809
|
+
const collection = client2.collections.get(collectionName);
|
|
4810
|
+
const result = await collection.query.fetchObjectById(args.memory_id, {
|
|
4811
|
+
includeVector: args.include_vector ?? false
|
|
4812
|
+
});
|
|
4813
|
+
if (!result) {
|
|
4814
|
+
return JSON.stringify({
|
|
4815
|
+
error: `Memory indexed in ${collectionName} but not found in Weaviate: ${args.memory_id}`,
|
|
4816
|
+
collection_name: collectionName
|
|
4817
|
+
});
|
|
4818
|
+
}
|
|
4819
|
+
return JSON.stringify({
|
|
4820
|
+
id: result.uuid,
|
|
4821
|
+
collection_name: collectionName,
|
|
4822
|
+
properties: result.properties,
|
|
4823
|
+
vectors: args.include_vector ? result.vectors : void 0,
|
|
4824
|
+
metadata: result.metadata
|
|
4825
|
+
}, null, 2);
|
|
4826
|
+
} catch (error) {
|
|
4827
|
+
return handleToolError(error, { toolName: "remember_admin_inspect_memory", userId, operation: "inspect memory" });
|
|
4828
|
+
}
|
|
4829
|
+
}
|
|
4830
|
+
|
|
4831
|
+
// src/tools/admin-search-across-users.ts
|
|
4832
|
+
var adminSearchAcrossUsersTool = {
|
|
4833
|
+
name: "remember_admin_search_across_users",
|
|
4834
|
+
description: `[Admin] Search memories across multiple user tenants.
|
|
4835
|
+
|
|
4836
|
+
Results include which user each memory belongs to.
|
|
4837
|
+
Requires explicit user_id array \u2014 no "all users" search.
|
|
4838
|
+
Requires admin access (ADMIN_USER_IDS).`,
|
|
4839
|
+
inputSchema: {
|
|
4840
|
+
type: "object",
|
|
4841
|
+
properties: {
|
|
4842
|
+
user_ids: {
|
|
4843
|
+
type: "array",
|
|
4844
|
+
items: { type: "string" },
|
|
4845
|
+
description: "User IDs to search across (required, 1 or more)"
|
|
4846
|
+
},
|
|
4847
|
+
query: {
|
|
4848
|
+
type: "string",
|
|
4849
|
+
description: "Search query (hybrid search)"
|
|
4850
|
+
},
|
|
4851
|
+
limit: {
|
|
4852
|
+
type: "number",
|
|
4853
|
+
description: "Max results across all users. Default: 10"
|
|
4854
|
+
},
|
|
4855
|
+
content_type: {
|
|
4856
|
+
type: "string",
|
|
4857
|
+
description: "Optional content type filter"
|
|
4858
|
+
}
|
|
4859
|
+
},
|
|
4860
|
+
required: ["user_ids", "query"]
|
|
4861
|
+
}
|
|
4862
|
+
};
|
|
4863
|
+
async function handleAdminSearchAcrossUsers(args, userId, _authContext) {
|
|
4864
|
+
const debug = createDebugLogger({ tool: "remember_admin_search_across_users", userId, operation: "search across users" });
|
|
4865
|
+
try {
|
|
4866
|
+
if (!isAdmin(userId)) {
|
|
4867
|
+
return JSON.stringify(adminPermissionError());
|
|
4868
|
+
}
|
|
4869
|
+
if (!args.user_ids || args.user_ids.length === 0) {
|
|
4870
|
+
return JSON.stringify({ error: "user_ids array is required and must not be empty" });
|
|
4871
|
+
}
|
|
4872
|
+
debug.info("Tool invoked", { user_ids: args.user_ids, query: args.query, limit: args.limit });
|
|
4873
|
+
const limit = args.limit ?? 10;
|
|
4874
|
+
const allResults = [];
|
|
4875
|
+
const warnings = [];
|
|
4876
|
+
for (const targetUserId of args.user_ids) {
|
|
4877
|
+
try {
|
|
4878
|
+
const services = createCoreServices(targetUserId);
|
|
4879
|
+
const searchResult = await services.memory.search({
|
|
4880
|
+
query: args.query,
|
|
4881
|
+
limit,
|
|
4882
|
+
filters: args.content_type ? { types: [args.content_type] } : void 0
|
|
4883
|
+
});
|
|
4884
|
+
for (const memory of searchResult.memories) {
|
|
4885
|
+
allResults.push({
|
|
4886
|
+
user_id: targetUserId,
|
|
4887
|
+
memory
|
|
4888
|
+
});
|
|
4889
|
+
}
|
|
4890
|
+
} catch (err) {
|
|
4891
|
+
warnings.push(`User ${targetUserId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
4892
|
+
}
|
|
4893
|
+
}
|
|
4894
|
+
const limited = allResults.slice(0, limit);
|
|
4895
|
+
return JSON.stringify({
|
|
4896
|
+
total: limited.length,
|
|
4897
|
+
results: limited,
|
|
4898
|
+
warnings: warnings.length > 0 ? warnings : void 0
|
|
4899
|
+
}, null, 2);
|
|
4900
|
+
} catch (error) {
|
|
4901
|
+
return handleToolError(error, { toolName: "remember_admin_search_across_users", userId, operation: "search across users" });
|
|
4902
|
+
}
|
|
4903
|
+
}
|
|
4904
|
+
|
|
4905
|
+
// src/tools/admin-inspect-user.ts
|
|
4906
|
+
init_init();
|
|
4907
|
+
var userIdSchema = {
|
|
4908
|
+
type: "object",
|
|
4909
|
+
properties: {
|
|
4910
|
+
user_id: { type: "string", description: "User ID to inspect" }
|
|
4911
|
+
},
|
|
4912
|
+
required: ["user_id"]
|
|
4913
|
+
};
|
|
4914
|
+
var adminInspectUserPreferencesTool = {
|
|
4915
|
+
name: "remember_admin_inspect_user_preferences",
|
|
4916
|
+
description: `[Admin] Inspect a user's preferences from Firestore. Requires admin access.`,
|
|
4917
|
+
inputSchema: userIdSchema
|
|
4918
|
+
};
|
|
4919
|
+
var adminInspectUserGhostConfigsTool = {
|
|
4920
|
+
name: "remember_admin_inspect_user_ghost_configs",
|
|
4921
|
+
description: `[Admin] Inspect a user's ghost configurations from Firestore. Requires admin access.`,
|
|
4922
|
+
inputSchema: userIdSchema
|
|
4923
|
+
};
|
|
4924
|
+
var adminInspectUserEscalationRecordsTool = {
|
|
4925
|
+
name: "remember_admin_inspect_user_escalation_records",
|
|
4926
|
+
description: `[Admin] Inspect a user's trust escalation records from Firestore. Requires admin access.`,
|
|
4927
|
+
inputSchema: userIdSchema
|
|
4928
|
+
};
|
|
4929
|
+
var adminInspectUserApiTokensTool = {
|
|
4930
|
+
name: "remember_admin_inspect_user_api_tokens",
|
|
4931
|
+
description: `[Admin] Inspect a user's API token metadata from Firestore (no hashes). Requires admin access.`,
|
|
4932
|
+
inputSchema: userIdSchema
|
|
4933
|
+
};
|
|
4934
|
+
async function handleAdminInspectUserPreferences(args, userId, _authContext) {
|
|
4935
|
+
const debug = createDebugLogger({ tool: "remember_admin_inspect_user_preferences", userId, operation: "inspect preferences" });
|
|
4936
|
+
try {
|
|
4937
|
+
if (!isAdmin(userId))
|
|
4938
|
+
return JSON.stringify(adminPermissionError());
|
|
4939
|
+
debug.info("Tool invoked", { target_user_id: args.user_id });
|
|
4940
|
+
const services = createCoreServices(args.user_id);
|
|
4941
|
+
const prefs = await services.preferences.getPreferences(args.user_id);
|
|
4942
|
+
return JSON.stringify({ user_id: args.user_id, preferences: prefs }, null, 2);
|
|
4943
|
+
} catch (error) {
|
|
4944
|
+
return handleToolError(error, { toolName: "remember_admin_inspect_user_preferences", userId });
|
|
4945
|
+
}
|
|
4946
|
+
}
|
|
4947
|
+
async function handleAdminInspectUserGhostConfigs(args, userId, _authContext) {
|
|
4948
|
+
const debug = createDebugLogger({ tool: "remember_admin_inspect_user_ghost_configs", userId, operation: "inspect ghost configs" });
|
|
4949
|
+
try {
|
|
4950
|
+
if (!isAdmin(userId))
|
|
4951
|
+
return JSON.stringify(adminPermissionError());
|
|
4952
|
+
debug.info("Tool invoked", { target_user_id: args.user_id });
|
|
4953
|
+
const config2 = await getGhostConfig(args.user_id);
|
|
4954
|
+
return JSON.stringify({ user_id: args.user_id, ghost_config: config2 }, null, 2);
|
|
4955
|
+
} catch (error) {
|
|
4956
|
+
return handleToolError(error, { toolName: "remember_admin_inspect_user_ghost_configs", userId });
|
|
4957
|
+
}
|
|
4958
|
+
}
|
|
4959
|
+
async function handleAdminInspectUserEscalationRecords(args, userId, _authContext) {
|
|
4960
|
+
const debug = createDebugLogger({ tool: "remember_admin_inspect_user_escalation_records", userId, operation: "inspect escalation records" });
|
|
4961
|
+
try {
|
|
4962
|
+
if (!isAdmin(userId))
|
|
4963
|
+
return JSON.stringify(adminPermissionError());
|
|
4964
|
+
debug.info("Tool invoked", { target_user_id: args.user_id });
|
|
4965
|
+
const collectionPath = `${BASE}.users/${args.user_id}/escalations`;
|
|
4966
|
+
const records = await queryDocuments(collectionPath);
|
|
4967
|
+
return JSON.stringify({
|
|
4968
|
+
user_id: args.user_id,
|
|
4969
|
+
escalation_records: records.map((r) => ({ id: r.id, ...r.data }))
|
|
4970
|
+
}, null, 2);
|
|
4971
|
+
} catch (error) {
|
|
4972
|
+
return handleToolError(error, { toolName: "remember_admin_inspect_user_escalation_records", userId });
|
|
4973
|
+
}
|
|
4974
|
+
}
|
|
4975
|
+
async function handleAdminInspectUserApiTokens(args, userId, _authContext) {
|
|
4976
|
+
const debug = createDebugLogger({ tool: "remember_admin_inspect_user_api_tokens", userId, operation: "inspect api tokens" });
|
|
4977
|
+
try {
|
|
4978
|
+
if (!isAdmin(userId))
|
|
4979
|
+
return JSON.stringify(adminPermissionError());
|
|
4980
|
+
debug.info("Tool invoked", { target_user_id: args.user_id });
|
|
4981
|
+
const collectionPath = `${BASE}.users/${args.user_id}/api_tokens`;
|
|
4982
|
+
const tokens = await queryDocuments(collectionPath);
|
|
4983
|
+
const sanitized = tokens.map((token) => {
|
|
4984
|
+
const { token_hash, ...metadata } = token.data;
|
|
4985
|
+
return { id: token.id, ...metadata };
|
|
4986
|
+
});
|
|
4987
|
+
return JSON.stringify({
|
|
4988
|
+
user_id: args.user_id,
|
|
4989
|
+
api_tokens: sanitized
|
|
4990
|
+
}, null, 2);
|
|
4991
|
+
} catch (error) {
|
|
4992
|
+
return handleToolError(error, { toolName: "remember_admin_inspect_user_api_tokens", userId });
|
|
4993
|
+
}
|
|
4994
|
+
}
|
|
4995
|
+
|
|
4996
|
+
// src/tools/admin-health.ts
|
|
4997
|
+
init_init();
|
|
4998
|
+
var adminHealthTool = {
|
|
4999
|
+
name: "remember_admin_health",
|
|
5000
|
+
description: `[Admin] Deep health check \u2014 Weaviate and Firestore connectivity with latency.
|
|
5001
|
+
|
|
5002
|
+
Returns overall status (healthy/degraded/unhealthy).
|
|
5003
|
+
Requires admin access (ADMIN_USER_IDS).`,
|
|
5004
|
+
inputSchema: {
|
|
5005
|
+
type: "object",
|
|
5006
|
+
properties: {}
|
|
5007
|
+
}
|
|
5008
|
+
};
|
|
5009
|
+
async function handleAdminHealth(_args, userId, _authContext) {
|
|
5010
|
+
const debug = createDebugLogger({ tool: "remember_admin_health", userId, operation: "health check" });
|
|
5011
|
+
try {
|
|
5012
|
+
if (!isAdmin(userId)) {
|
|
5013
|
+
return JSON.stringify(adminPermissionError());
|
|
5014
|
+
}
|
|
5015
|
+
debug.info("Tool invoked");
|
|
5016
|
+
const weaviateStart = Date.now();
|
|
5017
|
+
let weaviateOk;
|
|
5018
|
+
let weaviateError;
|
|
5019
|
+
try {
|
|
5020
|
+
weaviateOk = await testWeaviateConnection();
|
|
5021
|
+
} catch (err) {
|
|
5022
|
+
weaviateOk = false;
|
|
5023
|
+
weaviateError = err instanceof Error ? err.message : String(err);
|
|
5024
|
+
}
|
|
5025
|
+
const weaviateLatency = Date.now() - weaviateStart;
|
|
5026
|
+
const firestoreStart = Date.now();
|
|
5027
|
+
let firestoreOk;
|
|
5028
|
+
let firestoreError;
|
|
5029
|
+
try {
|
|
5030
|
+
firestoreOk = await testFirestoreConnection();
|
|
5031
|
+
} catch (err) {
|
|
5032
|
+
firestoreOk = false;
|
|
5033
|
+
firestoreError = err instanceof Error ? err.message : String(err);
|
|
5034
|
+
}
|
|
5035
|
+
const firestoreLatency = Date.now() - firestoreStart;
|
|
5036
|
+
let overall;
|
|
5037
|
+
if (weaviateOk && firestoreOk) {
|
|
5038
|
+
overall = "healthy";
|
|
5039
|
+
} else if (!weaviateOk && !firestoreOk) {
|
|
5040
|
+
overall = "unhealthy";
|
|
5041
|
+
} else {
|
|
5042
|
+
overall = "degraded";
|
|
5043
|
+
}
|
|
5044
|
+
return JSON.stringify({
|
|
5045
|
+
weaviate: {
|
|
5046
|
+
status: weaviateOk ? "ok" : "error",
|
|
5047
|
+
latency_ms: weaviateLatency,
|
|
5048
|
+
message: weaviateError
|
|
5049
|
+
},
|
|
5050
|
+
firestore: {
|
|
5051
|
+
status: firestoreOk ? "ok" : "error",
|
|
5052
|
+
latency_ms: firestoreLatency,
|
|
5053
|
+
message: firestoreError
|
|
5054
|
+
},
|
|
5055
|
+
overall
|
|
5056
|
+
}, null, 2);
|
|
5057
|
+
} catch (error) {
|
|
5058
|
+
return handleToolError(error, { toolName: "remember_admin_health", userId, operation: "health check" });
|
|
5059
|
+
}
|
|
5060
|
+
}
|
|
5061
|
+
|
|
5062
|
+
// src/tools/admin-detect-weaviate-drift.ts
|
|
5063
|
+
import {
|
|
5064
|
+
getUserCollectionProperties,
|
|
5065
|
+
getPublishedCollectionProperties
|
|
5066
|
+
} from "@prmichaelsen/remember-core/database/weaviate";
|
|
5067
|
+
var adminDetectWeaviateDriftTool = {
|
|
5068
|
+
name: "remember_admin_detect_weaviate_drift",
|
|
5069
|
+
description: `[Admin] Compare expected vs actual Weaviate schema properties per collection.
|
|
5070
|
+
|
|
5071
|
+
Reports missing properties, extra properties, and overall drift status.
|
|
5072
|
+
If no collection_ids provided, checks a sample of collections.
|
|
5073
|
+
Requires admin access (ADMIN_USER_IDS).`,
|
|
5074
|
+
inputSchema: {
|
|
5075
|
+
type: "object",
|
|
5076
|
+
properties: {
|
|
5077
|
+
collection_ids: {
|
|
5078
|
+
type: "array",
|
|
5079
|
+
items: { type: "string" },
|
|
5080
|
+
description: "Optional \u2014 specific collections to check. If omitted, samples available collections."
|
|
5081
|
+
}
|
|
5082
|
+
}
|
|
5083
|
+
}
|
|
5084
|
+
};
|
|
5085
|
+
function getExpectedProperties(collectionName) {
|
|
5086
|
+
if (collectionName.startsWith("Memory_users_")) {
|
|
5087
|
+
return getUserCollectionProperties();
|
|
5088
|
+
}
|
|
5089
|
+
return getPublishedCollectionProperties();
|
|
5090
|
+
}
|
|
5091
|
+
async function handleAdminDetectWeaviateDrift(args, userId, _authContext) {
|
|
5092
|
+
const debug = createDebugLogger({ tool: "remember_admin_detect_weaviate_drift", userId, operation: "detect drift" });
|
|
5093
|
+
try {
|
|
5094
|
+
if (!isAdmin(userId)) {
|
|
5095
|
+
return JSON.stringify(adminPermissionError());
|
|
5096
|
+
}
|
|
5097
|
+
debug.info("Tool invoked", { collection_ids: args.collection_ids });
|
|
5098
|
+
const client2 = getWeaviateClient();
|
|
5099
|
+
let collectionNames;
|
|
5100
|
+
if (args.collection_ids && args.collection_ids.length > 0) {
|
|
5101
|
+
collectionNames = args.collection_ids;
|
|
5102
|
+
} else {
|
|
5103
|
+
const all = await client2.collections.listAll();
|
|
5104
|
+
const names = all.map((c) => c.name).filter((n) => n.startsWith("Memory_"));
|
|
5105
|
+
collectionNames = names.slice(0, 5);
|
|
5106
|
+
}
|
|
5107
|
+
const results = [];
|
|
5108
|
+
for (const name of collectionNames) {
|
|
5109
|
+
try {
|
|
5110
|
+
const collection = client2.collections.get(name);
|
|
5111
|
+
const config2 = await collection.config.get();
|
|
5112
|
+
const actualProperties = config2.properties.map((p) => p.name);
|
|
5113
|
+
const expectedProperties = getExpectedProperties(name);
|
|
5114
|
+
const missing = expectedProperties.filter((p) => !actualProperties.includes(p));
|
|
5115
|
+
const extra = actualProperties.filter((p) => !expectedProperties.includes(p));
|
|
5116
|
+
const status = missing.length === 0 && extra.length === 0 ? "match" : "drift";
|
|
5117
|
+
results.push({
|
|
5118
|
+
collection: name,
|
|
5119
|
+
status,
|
|
5120
|
+
expected_count: expectedProperties.length,
|
|
5121
|
+
actual_count: actualProperties.length,
|
|
5122
|
+
missing_properties: missing,
|
|
5123
|
+
extra_properties: extra
|
|
5124
|
+
});
|
|
5125
|
+
} catch (err) {
|
|
5126
|
+
results.push({
|
|
5127
|
+
collection: name,
|
|
5128
|
+
status: "error",
|
|
5129
|
+
error: err instanceof Error ? err.message : String(err)
|
|
5130
|
+
});
|
|
5131
|
+
}
|
|
5132
|
+
}
|
|
5133
|
+
return JSON.stringify({
|
|
5134
|
+
collections_checked: results.length,
|
|
5135
|
+
results
|
|
5136
|
+
}, null, 2);
|
|
5137
|
+
} catch (error) {
|
|
5138
|
+
return handleToolError(error, { toolName: "remember_admin_detect_weaviate_drift", userId, operation: "detect drift" });
|
|
5139
|
+
}
|
|
5140
|
+
}
|
|
5141
|
+
|
|
4507
5142
|
// src/server-factory.ts
|
|
4508
5143
|
var databasesInitialized = false;
|
|
4509
5144
|
var initializationPromise = null;
|
|
@@ -4603,48 +5238,64 @@ async function createServer(accessToken, userId, options = {}) {
|
|
|
4603
5238
|
return server;
|
|
4604
5239
|
}
|
|
4605
5240
|
function registerHandlers(server, userId, accessToken, internalContext) {
|
|
5241
|
+
const adminTools = [
|
|
5242
|
+
adminGetWeaviateSchemaTool,
|
|
5243
|
+
adminListCollectionsTool,
|
|
5244
|
+
adminCollectionStatsTool,
|
|
5245
|
+
adminInspectMemoryTool,
|
|
5246
|
+
adminSearchAcrossUsersTool,
|
|
5247
|
+
adminInspectUserPreferencesTool,
|
|
5248
|
+
adminInspectUserGhostConfigsTool,
|
|
5249
|
+
adminInspectUserEscalationRecordsTool,
|
|
5250
|
+
adminInspectUserApiTokensTool,
|
|
5251
|
+
adminHealthTool,
|
|
5252
|
+
adminDetectWeaviateDriftTool
|
|
5253
|
+
];
|
|
4606
5254
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
4607
|
-
|
|
4608
|
-
tools
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
5255
|
+
const tools = [
|
|
5256
|
+
// Memory tools
|
|
5257
|
+
createMemoryTool,
|
|
5258
|
+
searchMemoryTool,
|
|
5259
|
+
deleteMemoryTool,
|
|
5260
|
+
updateMemoryTool,
|
|
5261
|
+
findSimilarTool,
|
|
5262
|
+
queryMemoryTool,
|
|
5263
|
+
// Relationship tools
|
|
5264
|
+
createRelationshipTool,
|
|
5265
|
+
updateRelationshipTool,
|
|
5266
|
+
searchRelationshipTool,
|
|
5267
|
+
deleteRelationshipTool,
|
|
5268
|
+
// Preference tools
|
|
5269
|
+
setPreferenceTool,
|
|
5270
|
+
getPreferencesTool,
|
|
5271
|
+
// Space tools
|
|
5272
|
+
publishTool,
|
|
5273
|
+
retractTool,
|
|
5274
|
+
reviseTool,
|
|
5275
|
+
confirmTool,
|
|
5276
|
+
denyTool,
|
|
5277
|
+
searchSpaceTool,
|
|
5278
|
+
querySpaceTool,
|
|
5279
|
+
moderateTool,
|
|
5280
|
+
ghostConfigTool,
|
|
5281
|
+
requestSetTrustLevelTool,
|
|
5282
|
+
// Search modes
|
|
5283
|
+
searchByTool,
|
|
5284
|
+
// Unified internal memory tools
|
|
5285
|
+
createInternalMemoryTool,
|
|
5286
|
+
updateInternalMemoryTool,
|
|
5287
|
+
searchInternalMemoryTool,
|
|
5288
|
+
queryInternalMemoryTool,
|
|
5289
|
+
searchInternalMemoryByTool,
|
|
5290
|
+
// Core introspection
|
|
5291
|
+
getCoreTool,
|
|
5292
|
+
// Space search modes
|
|
5293
|
+
searchSpaceByTool
|
|
5294
|
+
];
|
|
5295
|
+
if (isAdmin(userId)) {
|
|
5296
|
+
tools.push(...adminTools);
|
|
5297
|
+
}
|
|
5298
|
+
return { tools };
|
|
4648
5299
|
});
|
|
4649
5300
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
4650
5301
|
const { name, arguments: args } = request.params;
|
|
@@ -4716,6 +5367,9 @@ function registerHandlers(server, userId, accessToken, internalContext) {
|
|
|
4716
5367
|
case "remember_ghost_config":
|
|
4717
5368
|
result = await handleGhostConfig(args, userId, authContext);
|
|
4718
5369
|
break;
|
|
5370
|
+
case "remember_request_set_trust_level":
|
|
5371
|
+
result = await handleRequestSetTrustLevel(args, userId, authContext);
|
|
5372
|
+
break;
|
|
4719
5373
|
case "remember_search_by":
|
|
4720
5374
|
result = await handleSearchBy(args, userId, authContext);
|
|
4721
5375
|
break;
|
|
@@ -4740,7 +5394,45 @@ function registerHandlers(server, userId, accessToken, internalContext) {
|
|
|
4740
5394
|
case "remember_search_space_by":
|
|
4741
5395
|
result = await handleSearchSpaceBy(args, userId, authContext);
|
|
4742
5396
|
break;
|
|
5397
|
+
case "remember_admin_get_weaviate_schema":
|
|
5398
|
+
result = await handleAdminGetWeaviateSchema(args, userId, authContext);
|
|
5399
|
+
break;
|
|
5400
|
+
case "remember_admin_list_collections":
|
|
5401
|
+
result = await handleAdminListCollections(args, userId, authContext);
|
|
5402
|
+
break;
|
|
5403
|
+
case "remember_admin_collection_stats":
|
|
5404
|
+
result = await handleAdminCollectionStats(args, userId, authContext);
|
|
5405
|
+
break;
|
|
5406
|
+
case "remember_admin_inspect_memory":
|
|
5407
|
+
result = await handleAdminInspectMemory(args, userId, authContext);
|
|
5408
|
+
break;
|
|
5409
|
+
case "remember_admin_search_across_users":
|
|
5410
|
+
result = await handleAdminSearchAcrossUsers(args, userId, authContext);
|
|
5411
|
+
break;
|
|
5412
|
+
case "remember_admin_inspect_user_preferences":
|
|
5413
|
+
result = await handleAdminInspectUserPreferences(args, userId, authContext);
|
|
5414
|
+
break;
|
|
5415
|
+
case "remember_admin_inspect_user_ghost_configs":
|
|
5416
|
+
result = await handleAdminInspectUserGhostConfigs(args, userId, authContext);
|
|
5417
|
+
break;
|
|
5418
|
+
case "remember_admin_inspect_user_escalation_records":
|
|
5419
|
+
result = await handleAdminInspectUserEscalationRecords(args, userId, authContext);
|
|
5420
|
+
break;
|
|
5421
|
+
case "remember_admin_inspect_user_api_tokens":
|
|
5422
|
+
result = await handleAdminInspectUserApiTokens(args, userId, authContext);
|
|
5423
|
+
break;
|
|
5424
|
+
case "remember_admin_health":
|
|
5425
|
+
result = await handleAdminHealth(args, userId, authContext);
|
|
5426
|
+
break;
|
|
5427
|
+
case "remember_admin_detect_weaviate_drift":
|
|
5428
|
+
result = await handleAdminDetectWeaviateDrift(args, userId, authContext);
|
|
5429
|
+
break;
|
|
4743
5430
|
default:
|
|
5431
|
+
if (name.startsWith("remember_admin_")) {
|
|
5432
|
+
if (!isAdmin(userId)) {
|
|
5433
|
+
return adminPermissionError();
|
|
5434
|
+
}
|
|
5435
|
+
}
|
|
4744
5436
|
throw new McpError(
|
|
4745
5437
|
ErrorCode.MethodNotFound,
|
|
4746
5438
|
`Unknown tool: ${name}`
|