@prmichaelsen/remember-mcp 2.3.1 → 2.5.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 +20 -2
- package/CHANGELOG.md +69 -0
- package/README.md +50 -5
- package/agent/commands/acp.commit.md +511 -0
- package/agent/design/comment-memory-type.md +556 -0
- package/agent/design/unified-public-collection.md +545 -0
- package/agent/milestones/milestone-11-unified-public-collection.md +205 -0
- package/agent/progress.yaml +26 -0
- package/agent/scripts/install.sh +25 -1
- package/agent/scripts/update.sh +37 -0
- package/agent/tasks/task-46-update-spacememory-types.md +94 -0
- package/agent/tasks/task-47-update-space-schema.md +102 -0
- package/agent/tasks/task-48-create-memory-public-collection.md +96 -0
- package/agent/tasks/task-49-update-remember-publish.md +153 -0
- package/agent/tasks/task-50-update-remember-confirm.md +111 -0
- package/agent/tasks/task-51-update-remember-search-space.md +154 -0
- package/agent/tasks/task-52-update-remember-query-space.md +142 -0
- package/agent/tasks/task-53-add-multispace-tests.md +193 -0
- package/agent/tasks/task-54-update-documentation-multispace.md +191 -0
- package/dist/server-factory.js +140 -83
- package/dist/server.js +140 -83
- package/dist/tools/publish.d.ts +1 -1
- package/dist/tools/query-space.d.ts +1 -1
- package/dist/tools/search-space.d.ts +1 -1
- package/dist/types/space-memory.d.ts +5 -3
- package/dist/weaviate/space-schema.d.ts +16 -0
- package/package.json +1 -1
- package/src/tools/confirm.ts +20 -19
- package/src/tools/publish.ts +42 -20
- package/src/tools/query-space.ts +38 -24
- package/src/tools/search-space.ts +51 -28
- package/src/types/space-memory.ts +5 -3
- package/src/weaviate/space-schema.spec.ts +55 -0
- package/src/weaviate/space-schema.ts +45 -6
package/dist/server-factory.js
CHANGED
|
@@ -3404,6 +3404,7 @@ var confirmationTokenService = new ConfirmationTokenService();
|
|
|
3404
3404
|
// src/weaviate/space-schema.ts
|
|
3405
3405
|
init_space_memory();
|
|
3406
3406
|
import weaviate3 from "weaviate-client";
|
|
3407
|
+
var PUBLIC_COLLECTION_NAME = "Memory_public";
|
|
3407
3408
|
function getSpaceCollectionName(spaceId) {
|
|
3408
3409
|
return `Memory_${spaceId}`;
|
|
3409
3410
|
}
|
|
@@ -3411,7 +3412,7 @@ function isValidSpaceId(spaceId) {
|
|
|
3411
3412
|
return SUPPORTED_SPACES.includes(spaceId);
|
|
3412
3413
|
}
|
|
3413
3414
|
async function createSpaceCollection(client2, spaceId) {
|
|
3414
|
-
const collectionName = getSpaceCollectionName(spaceId);
|
|
3415
|
+
const collectionName = spaceId === "public" ? PUBLIC_COLLECTION_NAME : getSpaceCollectionName(spaceId);
|
|
3415
3416
|
console.log(`[Weaviate] Creating space collection ${collectionName}...`);
|
|
3416
3417
|
await client2.collections.create({
|
|
3417
3418
|
name: collectionName,
|
|
@@ -3429,10 +3430,15 @@ async function createSpaceCollection(client2, spaceId) {
|
|
|
3429
3430
|
description: 'Document type: "space_memory"'
|
|
3430
3431
|
},
|
|
3431
3432
|
// Space identity
|
|
3433
|
+
{
|
|
3434
|
+
name: "spaces",
|
|
3435
|
+
dataType: "text[]",
|
|
3436
|
+
description: 'Spaces this memory is published to (e.g., ["the_void", "dogs"])'
|
|
3437
|
+
},
|
|
3432
3438
|
{
|
|
3433
3439
|
name: "space_id",
|
|
3434
3440
|
dataType: "text",
|
|
3435
|
-
description:
|
|
3441
|
+
description: "DEPRECATED: Use spaces array instead. Will be removed in v3.0.0."
|
|
3436
3442
|
},
|
|
3437
3443
|
{
|
|
3438
3444
|
name: "author_id",
|
|
@@ -3566,14 +3572,11 @@ async function createSpaceCollection(client2, spaceId) {
|
|
|
3566
3572
|
});
|
|
3567
3573
|
console.log(`[Weaviate] Space collection ${collectionName} created successfully`);
|
|
3568
3574
|
}
|
|
3569
|
-
async function
|
|
3570
|
-
|
|
3571
|
-
throw new Error(`Invalid space ID: ${spaceId}. Supported spaces: ${SUPPORTED_SPACES.join(", ")}`);
|
|
3572
|
-
}
|
|
3573
|
-
const collectionName = getSpaceCollectionName(spaceId);
|
|
3575
|
+
async function ensurePublicCollection(client2) {
|
|
3576
|
+
const collectionName = PUBLIC_COLLECTION_NAME;
|
|
3574
3577
|
const exists = await client2.collections.exists(collectionName);
|
|
3575
3578
|
if (!exists) {
|
|
3576
|
-
await createSpaceCollection(client2,
|
|
3579
|
+
await createSpaceCollection(client2, "public");
|
|
3577
3580
|
}
|
|
3578
3581
|
return client2.collections.get(collectionName);
|
|
3579
3582
|
}
|
|
@@ -3582,7 +3585,7 @@ async function ensureSpaceCollection(client2, spaceId) {
|
|
|
3582
3585
|
init_space_memory();
|
|
3583
3586
|
var publishTool = {
|
|
3584
3587
|
name: "remember_publish",
|
|
3585
|
-
description: 'Publish a memory to
|
|
3588
|
+
description: 'Publish a memory to one or more shared spaces (like "The Void"). The memory will be COPIED (not moved) from your personal collection. Generates a confirmation token. Use remember_confirm to execute.',
|
|
3586
3589
|
inputSchema: {
|
|
3587
3590
|
type: "object",
|
|
3588
3591
|
properties: {
|
|
@@ -3590,11 +3593,15 @@ var publishTool = {
|
|
|
3590
3593
|
type: "string",
|
|
3591
3594
|
description: "ID of the memory from your personal collection to publish"
|
|
3592
3595
|
},
|
|
3593
|
-
|
|
3594
|
-
type: "
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3596
|
+
spaces: {
|
|
3597
|
+
type: "array",
|
|
3598
|
+
items: {
|
|
3599
|
+
type: "string",
|
|
3600
|
+
enum: SUPPORTED_SPACES
|
|
3601
|
+
},
|
|
3602
|
+
description: 'Spaces to publish to (e.g., ["the_void", "dogs"]). Can publish to multiple spaces at once.',
|
|
3603
|
+
minItems: 1,
|
|
3604
|
+
default: ["the_void"]
|
|
3598
3605
|
},
|
|
3599
3606
|
additional_tags: {
|
|
3600
3607
|
type: "array",
|
|
@@ -3603,7 +3610,7 @@ var publishTool = {
|
|
|
3603
3610
|
default: []
|
|
3604
3611
|
}
|
|
3605
3612
|
},
|
|
3606
|
-
required: ["memory_id", "
|
|
3613
|
+
required: ["memory_id", "spaces"]
|
|
3607
3614
|
}
|
|
3608
3615
|
};
|
|
3609
3616
|
async function handlePublish(args, userId) {
|
|
@@ -3611,18 +3618,21 @@ async function handlePublish(args, userId) {
|
|
|
3611
3618
|
console.log("[remember_publish] Starting publish request:", {
|
|
3612
3619
|
userId,
|
|
3613
3620
|
memoryId: args.memory_id,
|
|
3614
|
-
|
|
3621
|
+
spaces: args.spaces,
|
|
3622
|
+
spaceCount: args.spaces.length,
|
|
3615
3623
|
additionalTags: args.additional_tags?.length || 0
|
|
3616
3624
|
});
|
|
3617
|
-
|
|
3618
|
-
|
|
3625
|
+
const invalidSpaces = args.spaces.filter((s) => !isValidSpaceId(s));
|
|
3626
|
+
if (invalidSpaces.length > 0) {
|
|
3627
|
+
console.log("[remember_publish] Invalid space IDs:", invalidSpaces);
|
|
3619
3628
|
return JSON.stringify(
|
|
3620
3629
|
{
|
|
3621
3630
|
success: false,
|
|
3622
|
-
error: "Invalid space
|
|
3623
|
-
message: `
|
|
3631
|
+
error: "Invalid space IDs",
|
|
3632
|
+
message: `Invalid spaces: ${invalidSpaces.join(", ")}. Supported spaces: ${SUPPORTED_SPACES.join(", ")}`,
|
|
3624
3633
|
context: {
|
|
3625
|
-
|
|
3634
|
+
invalid_spaces: invalidSpaces,
|
|
3635
|
+
provided_spaces: args.spaces,
|
|
3626
3636
|
supported_spaces: SUPPORTED_SPACES
|
|
3627
3637
|
}
|
|
3628
3638
|
},
|
|
@@ -3630,6 +3640,18 @@ async function handlePublish(args, userId) {
|
|
|
3630
3640
|
2
|
|
3631
3641
|
);
|
|
3632
3642
|
}
|
|
3643
|
+
if (args.spaces.length === 0) {
|
|
3644
|
+
console.log("[remember_publish] Empty spaces array");
|
|
3645
|
+
return JSON.stringify(
|
|
3646
|
+
{
|
|
3647
|
+
success: false,
|
|
3648
|
+
error: "Empty spaces array",
|
|
3649
|
+
message: "Must specify at least one space to publish to"
|
|
3650
|
+
},
|
|
3651
|
+
null,
|
|
3652
|
+
2
|
|
3653
|
+
);
|
|
3654
|
+
}
|
|
3633
3655
|
const weaviateClient = getWeaviateClient();
|
|
3634
3656
|
const collectionName = getMemoryCollectionName(userId);
|
|
3635
3657
|
console.log("[remember_publish] Fetching memory from collection:", collectionName);
|
|
@@ -3688,6 +3710,7 @@ async function handlePublish(args, userId) {
|
|
|
3688
3710
|
}
|
|
3689
3711
|
const payload = {
|
|
3690
3712
|
memory_id: args.memory_id,
|
|
3713
|
+
spaces: args.spaces,
|
|
3691
3714
|
additional_tags: args.additional_tags || []
|
|
3692
3715
|
};
|
|
3693
3716
|
console.log("[remember_publish] Generating confirmation token");
|
|
@@ -3695,7 +3718,8 @@ async function handlePublish(args, userId) {
|
|
|
3695
3718
|
userId,
|
|
3696
3719
|
"publish_memory",
|
|
3697
3720
|
payload,
|
|
3698
|
-
|
|
3721
|
+
void 0
|
|
3722
|
+
// No single target_collection anymore
|
|
3699
3723
|
);
|
|
3700
3724
|
console.log("[remember_publish] Token generated:", {
|
|
3701
3725
|
requestId,
|
|
@@ -3711,12 +3735,12 @@ async function handlePublish(args, userId) {
|
|
|
3711
3735
|
2
|
|
3712
3736
|
);
|
|
3713
3737
|
} catch (error) {
|
|
3714
|
-
handleToolError(error, {
|
|
3738
|
+
return handleToolError(error, {
|
|
3715
3739
|
toolName: "remember_publish",
|
|
3716
3740
|
userId,
|
|
3717
3741
|
operation: "publish memory",
|
|
3718
3742
|
memory_id: args.memory_id,
|
|
3719
|
-
|
|
3743
|
+
spaces: args.spaces
|
|
3720
3744
|
});
|
|
3721
3745
|
}
|
|
3722
3746
|
}
|
|
@@ -3778,7 +3802,8 @@ async function executePublishMemory(request, userId) {
|
|
|
3778
3802
|
console.log("[executePublishMemory] Starting execution:", {
|
|
3779
3803
|
userId,
|
|
3780
3804
|
memoryId: request.payload.memory_id,
|
|
3781
|
-
|
|
3805
|
+
spaces: request.payload.spaces,
|
|
3806
|
+
spaceCount: request.payload.spaces?.length || 0
|
|
3782
3807
|
});
|
|
3783
3808
|
const weaviateClient = getWeaviateClient();
|
|
3784
3809
|
const userCollection = weaviateClient.collections.get(
|
|
@@ -3816,20 +3841,18 @@ async function executePublishMemory(request, userId) {
|
|
|
3816
3841
|
2
|
|
3817
3842
|
);
|
|
3818
3843
|
}
|
|
3819
|
-
console.log("[executePublishMemory] Ensuring
|
|
3820
|
-
const
|
|
3821
|
-
|
|
3822
|
-
request.target_collection || "the_void"
|
|
3823
|
-
);
|
|
3824
|
-
console.log("[executePublishMemory] Space collection ready");
|
|
3844
|
+
console.log("[executePublishMemory] Ensuring public collection");
|
|
3845
|
+
const publicCollection = await ensurePublicCollection(weaviateClient);
|
|
3846
|
+
console.log("[executePublishMemory] Public collection ready");
|
|
3825
3847
|
const originalTags = Array.isArray(originalMemory.properties.tags) ? originalMemory.properties.tags : [];
|
|
3826
3848
|
const additionalTags = Array.isArray(request.payload.additional_tags) ? request.payload.additional_tags : [];
|
|
3827
3849
|
const publishedMemory = {
|
|
3828
3850
|
...originalMemory.properties,
|
|
3829
|
-
//
|
|
3830
|
-
|
|
3851
|
+
// Add space-specific fields
|
|
3852
|
+
spaces: request.payload.spaces || ["the_void"],
|
|
3853
|
+
// ✅ Array of spaces!
|
|
3831
3854
|
author_id: userId,
|
|
3832
|
-
//
|
|
3855
|
+
// Track original author
|
|
3833
3856
|
published_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3834
3857
|
discovery_count: 0,
|
|
3835
3858
|
doc_type: "space_memory",
|
|
@@ -3841,14 +3864,14 @@ async function executePublishMemory(request, userId) {
|
|
|
3841
3864
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3842
3865
|
version: 1
|
|
3843
3866
|
};
|
|
3844
|
-
console.log("[executePublishMemory] Inserting into
|
|
3845
|
-
|
|
3867
|
+
console.log("[executePublishMemory] Inserting into Memory_public:", {
|
|
3868
|
+
spaces: request.payload.spaces,
|
|
3869
|
+
spaceCount: request.payload.spaces?.length || 0,
|
|
3846
3870
|
memoryId: request.payload.memory_id,
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
const result = await targetCollection.data.insert({
|
|
3850
|
-
properties: publishedMemory
|
|
3871
|
+
hasUserId: !!publishedMemory.user_id,
|
|
3872
|
+
hasAuthorId: !!publishedMemory.author_id
|
|
3851
3873
|
});
|
|
3874
|
+
const result = await publicCollection.data.insert(publishedMemory);
|
|
3852
3875
|
console.log("[executePublishMemory] Insert result:", {
|
|
3853
3876
|
success: !!result,
|
|
3854
3877
|
spaceMemoryId: result
|
|
@@ -3856,7 +3879,8 @@ async function executePublishMemory(request, userId) {
|
|
|
3856
3879
|
return JSON.stringify(
|
|
3857
3880
|
{
|
|
3858
3881
|
success: true,
|
|
3859
|
-
space_memory_id: result
|
|
3882
|
+
space_memory_id: result,
|
|
3883
|
+
spaces: request.payload.spaces || ["the_void"]
|
|
3860
3884
|
},
|
|
3861
3885
|
null,
|
|
3862
3886
|
2
|
|
@@ -3922,7 +3946,7 @@ import { Filters as Filters3 } from "weaviate-client";
|
|
|
3922
3946
|
init_space_memory();
|
|
3923
3947
|
var searchSpaceTool = {
|
|
3924
3948
|
name: "remember_search_space",
|
|
3925
|
-
description: "Search shared spaces to discover thoughts, ideas, and memories. Works like remember_search_memory but searches shared spaces instead of personal memories.",
|
|
3949
|
+
description: "Search one or more shared spaces to discover thoughts, ideas, and memories. Works like remember_search_memory but searches shared spaces instead of personal memories. Can search multiple spaces in a single query.",
|
|
3926
3950
|
inputSchema: {
|
|
3927
3951
|
type: "object",
|
|
3928
3952
|
properties: {
|
|
@@ -3930,11 +3954,15 @@ var searchSpaceTool = {
|
|
|
3930
3954
|
type: "string",
|
|
3931
3955
|
description: "Search query (semantic + keyword hybrid)"
|
|
3932
3956
|
},
|
|
3933
|
-
|
|
3934
|
-
type: "
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3957
|
+
spaces: {
|
|
3958
|
+
type: "array",
|
|
3959
|
+
items: {
|
|
3960
|
+
type: "string",
|
|
3961
|
+
enum: SUPPORTED_SPACES
|
|
3962
|
+
},
|
|
3963
|
+
description: 'Spaces to search (e.g., ["the_void", "dogs"]). Can search multiple spaces at once.',
|
|
3964
|
+
minItems: 1,
|
|
3965
|
+
default: ["the_void"]
|
|
3938
3966
|
},
|
|
3939
3967
|
content_type: {
|
|
3940
3968
|
type: "string",
|
|
@@ -3976,49 +4004,66 @@ var searchSpaceTool = {
|
|
|
3976
4004
|
description: "Offset for pagination"
|
|
3977
4005
|
}
|
|
3978
4006
|
},
|
|
3979
|
-
required: ["query", "
|
|
4007
|
+
required: ["query", "spaces"]
|
|
3980
4008
|
}
|
|
3981
4009
|
};
|
|
3982
4010
|
async function handleSearchSpace(args, userId) {
|
|
3983
4011
|
try {
|
|
3984
|
-
|
|
4012
|
+
const invalidSpaces = args.spaces.filter((s) => !isValidSpaceId(s));
|
|
4013
|
+
if (invalidSpaces.length > 0) {
|
|
3985
4014
|
return JSON.stringify(
|
|
3986
4015
|
{
|
|
3987
4016
|
success: false,
|
|
3988
|
-
error: "Invalid space
|
|
3989
|
-
message: `
|
|
4017
|
+
error: "Invalid space IDs",
|
|
4018
|
+
message: `Invalid spaces: ${invalidSpaces.join(", ")}. Supported spaces: ${SUPPORTED_SPACES.join(", ")}`,
|
|
4019
|
+
context: {
|
|
4020
|
+
invalid_spaces: invalidSpaces,
|
|
4021
|
+
provided_spaces: args.spaces,
|
|
4022
|
+
supported_spaces: SUPPORTED_SPACES
|
|
4023
|
+
}
|
|
4024
|
+
},
|
|
4025
|
+
null,
|
|
4026
|
+
2
|
|
4027
|
+
);
|
|
4028
|
+
}
|
|
4029
|
+
if (args.spaces.length === 0) {
|
|
4030
|
+
return JSON.stringify(
|
|
4031
|
+
{
|
|
4032
|
+
success: false,
|
|
4033
|
+
error: "Empty spaces array",
|
|
4034
|
+
message: "Must specify at least one space to search"
|
|
3990
4035
|
},
|
|
3991
4036
|
null,
|
|
3992
4037
|
2
|
|
3993
4038
|
);
|
|
3994
4039
|
}
|
|
3995
4040
|
const weaviateClient = getWeaviateClient();
|
|
3996
|
-
const
|
|
4041
|
+
const publicCollection = await ensurePublicCollection(weaviateClient);
|
|
3997
4042
|
const filterList = [];
|
|
3998
|
-
filterList.push(
|
|
3999
|
-
filterList.push(
|
|
4043
|
+
filterList.push(publicCollection.filter.byProperty("spaces").containsAny(args.spaces));
|
|
4044
|
+
filterList.push(publicCollection.filter.byProperty("doc_type").equal("space_memory"));
|
|
4000
4045
|
if (args.content_type) {
|
|
4001
|
-
filterList.push(
|
|
4046
|
+
filterList.push(publicCollection.filter.byProperty("type").equal(args.content_type));
|
|
4002
4047
|
}
|
|
4003
4048
|
if (args.tags && args.tags.length > 0) {
|
|
4004
4049
|
args.tags.forEach((tag) => {
|
|
4005
|
-
filterList.push(
|
|
4050
|
+
filterList.push(publicCollection.filter.byProperty("tags").containsAny([tag]));
|
|
4006
4051
|
});
|
|
4007
4052
|
}
|
|
4008
4053
|
if (args.min_weight !== void 0) {
|
|
4009
|
-
filterList.push(
|
|
4054
|
+
filterList.push(publicCollection.filter.byProperty("weight").greaterOrEqual(args.min_weight));
|
|
4010
4055
|
}
|
|
4011
4056
|
if (args.max_weight !== void 0) {
|
|
4012
|
-
filterList.push(
|
|
4057
|
+
filterList.push(publicCollection.filter.byProperty("weight").lessOrEqual(args.max_weight));
|
|
4013
4058
|
}
|
|
4014
4059
|
if (args.date_from) {
|
|
4015
|
-
filterList.push(
|
|
4060
|
+
filterList.push(publicCollection.filter.byProperty("created_at").greaterOrEqual(new Date(args.date_from)));
|
|
4016
4061
|
}
|
|
4017
4062
|
if (args.date_to) {
|
|
4018
|
-
filterList.push(
|
|
4063
|
+
filterList.push(publicCollection.filter.byProperty("created_at").lessOrEqual(new Date(args.date_to)));
|
|
4019
4064
|
}
|
|
4020
4065
|
const whereFilter = filterList.length > 0 ? Filters3.and(...filterList) : void 0;
|
|
4021
|
-
const searchResults = await
|
|
4066
|
+
const searchResults = await publicCollection.query.hybrid(args.query, {
|
|
4022
4067
|
limit: args.limit || 10,
|
|
4023
4068
|
offset: args.offset || 0,
|
|
4024
4069
|
...whereFilter && { where: whereFilter }
|
|
@@ -4029,7 +4074,7 @@ async function handleSearchSpace(args, userId) {
|
|
|
4029
4074
|
_score: obj.metadata?.score
|
|
4030
4075
|
}));
|
|
4031
4076
|
const result = {
|
|
4032
|
-
|
|
4077
|
+
spaces_searched: args.spaces,
|
|
4033
4078
|
query: args.query,
|
|
4034
4079
|
memories,
|
|
4035
4080
|
total: memories.length,
|
|
@@ -4038,10 +4083,10 @@ async function handleSearchSpace(args, userId) {
|
|
|
4038
4083
|
};
|
|
4039
4084
|
return JSON.stringify(result, null, 2);
|
|
4040
4085
|
} catch (error) {
|
|
4041
|
-
handleToolError(error, {
|
|
4086
|
+
return handleToolError(error, {
|
|
4042
4087
|
toolName: "remember_search_space",
|
|
4043
|
-
operation: "search
|
|
4044
|
-
|
|
4088
|
+
operation: "search spaces",
|
|
4089
|
+
spaces: args.spaces,
|
|
4045
4090
|
query: args.query
|
|
4046
4091
|
});
|
|
4047
4092
|
}
|
|
@@ -4101,46 +4146,58 @@ var querySpaceTool = {
|
|
|
4101
4146
|
description: "Output format: detailed (full objects) or compact (text summary)"
|
|
4102
4147
|
}
|
|
4103
4148
|
},
|
|
4104
|
-
required: ["question", "
|
|
4149
|
+
required: ["question", "spaces"]
|
|
4105
4150
|
}
|
|
4106
4151
|
};
|
|
4107
4152
|
async function handleQuerySpace(args, userId) {
|
|
4108
4153
|
try {
|
|
4109
|
-
|
|
4154
|
+
const invalidSpaces = args.spaces.filter((s) => !isValidSpaceId(s));
|
|
4155
|
+
if (invalidSpaces.length > 0) {
|
|
4110
4156
|
return JSON.stringify(
|
|
4111
4157
|
{
|
|
4112
4158
|
success: false,
|
|
4113
|
-
error: "Invalid space
|
|
4114
|
-
message: `
|
|
4159
|
+
error: "Invalid space IDs",
|
|
4160
|
+
message: `Invalid spaces: ${invalidSpaces.join(", ")}. Supported spaces: ${SUPPORTED_SPACES.join(", ")}`
|
|
4161
|
+
},
|
|
4162
|
+
null,
|
|
4163
|
+
2
|
|
4164
|
+
);
|
|
4165
|
+
}
|
|
4166
|
+
if (args.spaces.length === 0) {
|
|
4167
|
+
return JSON.stringify(
|
|
4168
|
+
{
|
|
4169
|
+
success: false,
|
|
4170
|
+
error: "Empty spaces array",
|
|
4171
|
+
message: "Must specify at least one space to query"
|
|
4115
4172
|
},
|
|
4116
4173
|
null,
|
|
4117
4174
|
2
|
|
4118
4175
|
);
|
|
4119
4176
|
}
|
|
4120
4177
|
const weaviateClient = getWeaviateClient();
|
|
4121
|
-
const
|
|
4178
|
+
const publicCollection = await ensurePublicCollection(weaviateClient);
|
|
4122
4179
|
const filterList = [];
|
|
4123
|
-
filterList.push(
|
|
4124
|
-
filterList.push(
|
|
4180
|
+
filterList.push(publicCollection.filter.byProperty("spaces").containsAny(args.spaces));
|
|
4181
|
+
filterList.push(publicCollection.filter.byProperty("doc_type").equal("space_memory"));
|
|
4125
4182
|
if (args.content_type) {
|
|
4126
|
-
filterList.push(
|
|
4183
|
+
filterList.push(publicCollection.filter.byProperty("type").equal(args.content_type));
|
|
4127
4184
|
}
|
|
4128
4185
|
if (args.tags && args.tags.length > 0) {
|
|
4129
4186
|
args.tags.forEach((tag) => {
|
|
4130
|
-
filterList.push(
|
|
4187
|
+
filterList.push(publicCollection.filter.byProperty("tags").containsAny([tag]));
|
|
4131
4188
|
});
|
|
4132
4189
|
}
|
|
4133
4190
|
if (args.min_weight !== void 0) {
|
|
4134
|
-
filterList.push(
|
|
4191
|
+
filterList.push(publicCollection.filter.byProperty("weight").greaterOrEqual(args.min_weight));
|
|
4135
4192
|
}
|
|
4136
4193
|
if (args.date_from) {
|
|
4137
|
-
filterList.push(
|
|
4194
|
+
filterList.push(publicCollection.filter.byProperty("created_at").greaterOrEqual(new Date(args.date_from)));
|
|
4138
4195
|
}
|
|
4139
4196
|
if (args.date_to) {
|
|
4140
|
-
filterList.push(
|
|
4197
|
+
filterList.push(publicCollection.filter.byProperty("created_at").lessOrEqual(new Date(args.date_to)));
|
|
4141
4198
|
}
|
|
4142
4199
|
const whereFilter = filterList.length > 0 ? Filters4.and(...filterList) : void 0;
|
|
4143
|
-
const searchResults = await
|
|
4200
|
+
const searchResults = await publicCollection.query.nearText(args.question, {
|
|
4144
4201
|
limit: args.limit || 10,
|
|
4145
4202
|
...whereFilter && { where: whereFilter }
|
|
4146
4203
|
});
|
|
@@ -4152,7 +4209,7 @@ async function handleQuerySpace(args, userId) {
|
|
|
4152
4209
|
});
|
|
4153
4210
|
const result = {
|
|
4154
4211
|
question: args.question,
|
|
4155
|
-
|
|
4212
|
+
spaces_queried: args.spaces,
|
|
4156
4213
|
format: "compact",
|
|
4157
4214
|
summary: summaries.join("\n"),
|
|
4158
4215
|
count: searchResults.objects.length
|
|
@@ -4166,7 +4223,7 @@ async function handleQuerySpace(args, userId) {
|
|
|
4166
4223
|
}));
|
|
4167
4224
|
const result = {
|
|
4168
4225
|
question: args.question,
|
|
4169
|
-
|
|
4226
|
+
spaces_queried: args.spaces,
|
|
4170
4227
|
format: "detailed",
|
|
4171
4228
|
memories,
|
|
4172
4229
|
total: memories.length
|
|
@@ -4174,10 +4231,10 @@ async function handleQuerySpace(args, userId) {
|
|
|
4174
4231
|
return JSON.stringify(result, null, 2);
|
|
4175
4232
|
}
|
|
4176
4233
|
} catch (error) {
|
|
4177
|
-
handleToolError(error, {
|
|
4234
|
+
return handleToolError(error, {
|
|
4178
4235
|
toolName: "remember_query_space",
|
|
4179
|
-
operation: "query
|
|
4180
|
-
|
|
4236
|
+
operation: "query spaces",
|
|
4237
|
+
spaces: args.spaces,
|
|
4181
4238
|
question: args.question
|
|
4182
4239
|
});
|
|
4183
4240
|
}
|