@prmichaelsen/remember-core 0.12.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/README.md +100 -0
- package/dist/collections/composite-ids.d.ts +47 -0
- package/dist/collections/composite-ids.d.ts.map +1 -0
- package/dist/collections/composite-ids.js +97 -0
- package/dist/collections/composite-ids.js.map +1 -0
- package/dist/collections/dot-notation.d.ts +37 -0
- package/dist/collections/dot-notation.d.ts.map +1 -0
- package/dist/collections/dot-notation.js +100 -0
- package/dist/collections/dot-notation.js.map +1 -0
- package/dist/collections/index.d.ts +7 -0
- package/dist/collections/index.d.ts.map +1 -0
- package/dist/collections/index.js +7 -0
- package/dist/collections/index.js.map +1 -0
- package/dist/collections/tracking-arrays.d.ts +28 -0
- package/dist/collections/tracking-arrays.d.ts.map +1 -0
- package/dist/collections/tracking-arrays.js +67 -0
- package/dist/collections/tracking-arrays.js.map +1 -0
- package/dist/config/debug.d.ts +36 -0
- package/dist/config/debug.d.ts.map +1 -0
- package/dist/config/debug.js +48 -0
- package/dist/config/debug.js.map +1 -0
- package/dist/config/environment.d.ts +71 -0
- package/dist/config/environment.d.ts.map +1 -0
- package/dist/config/environment.js +57 -0
- package/dist/config/environment.js.map +1 -0
- package/dist/config/index.d.ts +9 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +27 -0
- package/dist/config/index.js.map +1 -0
- package/dist/constants/content-types.d.ts +60 -0
- package/dist/constants/content-types.d.ts.map +1 -0
- package/dist/constants/content-types.js +450 -0
- package/dist/constants/content-types.js.map +1 -0
- package/dist/constants/index.d.ts +3 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +3 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/database/firestore/index.d.ts +8 -0
- package/dist/database/firestore/index.d.ts.map +1 -0
- package/dist/database/firestore/index.js +10 -0
- package/dist/database/firestore/index.js.map +1 -0
- package/dist/database/firestore/init.d.ts +51 -0
- package/dist/database/firestore/init.d.ts.map +1 -0
- package/dist/database/firestore/init.js +92 -0
- package/dist/database/firestore/init.js.map +1 -0
- package/dist/database/firestore/paths.d.ts +54 -0
- package/dist/database/firestore/paths.d.ts.map +1 -0
- package/dist/database/firestore/paths.js +103 -0
- package/dist/database/firestore/paths.js.map +1 -0
- package/dist/database/weaviate/client.d.ts +68 -0
- package/dist/database/weaviate/client.d.ts.map +1 -0
- package/dist/database/weaviate/client.js +157 -0
- package/dist/database/weaviate/client.js.map +1 -0
- package/dist/database/weaviate/index.d.ts +6 -0
- package/dist/database/weaviate/index.d.ts.map +1 -0
- package/dist/database/weaviate/index.js +9 -0
- package/dist/database/weaviate/index.js.map +1 -0
- package/dist/database/weaviate/schema.d.ts +22 -0
- package/dist/database/weaviate/schema.d.ts.map +1 -0
- package/dist/database/weaviate/schema.js +50 -0
- package/dist/database/weaviate/schema.js.map +1 -0
- package/dist/database/weaviate/space-schema.d.ts +36 -0
- package/dist/database/weaviate/space-schema.d.ts.map +1 -0
- package/dist/database/weaviate/space-schema.js +65 -0
- package/dist/database/weaviate/space-schema.js.map +1 -0
- package/dist/database/weaviate/v2-collections.d.ts +160 -0
- package/dist/database/weaviate/v2-collections.d.ts.map +1 -0
- package/dist/database/weaviate/v2-collections.js +275 -0
- package/dist/database/weaviate/v2-collections.js.map +1 -0
- package/dist/errors/app-errors.d.ts +64 -0
- package/dist/errors/app-errors.d.ts.map +1 -0
- package/dist/errors/app-errors.js +90 -0
- package/dist/errors/app-errors.js.map +1 -0
- package/dist/errors/base.error.d.ts +15 -0
- package/dist/errors/base.error.d.ts.map +1 -0
- package/dist/errors/base.error.js +25 -0
- package/dist/errors/base.error.js.map +1 -0
- package/dist/errors/index.d.ts +19 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +25 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/services/confirmation-token.service.d.ts +56 -0
- package/dist/services/confirmation-token.service.d.ts.map +1 -0
- package/dist/services/confirmation-token.service.js +118 -0
- package/dist/services/confirmation-token.service.js.map +1 -0
- package/dist/services/credentials-provider.d.ts +25 -0
- package/dist/services/credentials-provider.d.ts.map +1 -0
- package/dist/services/credentials-provider.js +31 -0
- package/dist/services/credentials-provider.js.map +1 -0
- package/dist/services/index.d.ts +11 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +17 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/memory.service.d.ts +129 -0
- package/dist/services/memory.service.d.ts.map +1 -0
- package/dist/services/memory.service.js +294 -0
- package/dist/services/memory.service.js.map +1 -0
- package/dist/services/preferences.service.d.ts +27 -0
- package/dist/services/preferences.service.d.ts.map +1 -0
- package/dist/services/preferences.service.js +106 -0
- package/dist/services/preferences.service.js.map +1 -0
- package/dist/services/relationship.service.d.ts +75 -0
- package/dist/services/relationship.service.d.ts.map +1 -0
- package/dist/services/relationship.service.js +211 -0
- package/dist/services/relationship.service.js.map +1 -0
- package/dist/services/space-config.service.d.ts +22 -0
- package/dist/services/space-config.service.d.ts.map +1 -0
- package/dist/services/space-config.service.js +50 -0
- package/dist/services/space-config.service.js.map +1 -0
- package/dist/services/space.service.d.ts +160 -0
- package/dist/services/space.service.d.ts.map +1 -0
- package/dist/services/space.service.js +815 -0
- package/dist/services/space.service.js.map +1 -0
- package/dist/testing/index.d.ts +8 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +8 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/test-data-generator.d.ts +100 -0
- package/dist/testing/test-data-generator.d.ts.map +1 -0
- package/dist/testing/test-data-generator.js +194 -0
- package/dist/testing/test-data-generator.js.map +1 -0
- package/dist/testing/weaviate-mock.d.ts +317 -0
- package/dist/testing/weaviate-mock.d.ts.map +1 -0
- package/dist/testing/weaviate-mock.js +233 -0
- package/dist/testing/weaviate-mock.js.map +1 -0
- package/dist/types/auth.types.d.ts +36 -0
- package/dist/types/auth.types.d.ts.map +1 -0
- package/dist/types/auth.types.js +9 -0
- package/dist/types/auth.types.js.map +1 -0
- package/dist/types/context.types.d.ts +78 -0
- package/dist/types/context.types.d.ts.map +1 -0
- package/dist/types/context.types.js +6 -0
- package/dist/types/context.types.js.map +1 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/llm.types.d.ts +8 -0
- package/dist/types/llm.types.d.ts.map +1 -0
- package/dist/types/llm.types.js +8 -0
- package/dist/types/llm.types.js.map +1 -0
- package/dist/types/memory.types.d.ts +83 -0
- package/dist/types/memory.types.d.ts.map +1 -0
- package/dist/types/memory.types.js +6 -0
- package/dist/types/memory.types.js.map +1 -0
- package/dist/types/preferences.types.d.ts +285 -0
- package/dist/types/preferences.types.d.ts.map +1 -0
- package/dist/types/preferences.types.js +195 -0
- package/dist/types/preferences.types.js.map +1 -0
- package/dist/types/result.types.d.ts +60 -0
- package/dist/types/result.types.d.ts.map +1 -0
- package/dist/types/result.types.js +82 -0
- package/dist/types/result.types.js.map +1 -0
- package/dist/types/search.types.d.ts +49 -0
- package/dist/types/search.types.d.ts.map +1 -0
- package/dist/types/search.types.js +6 -0
- package/dist/types/search.types.js.map +1 -0
- package/dist/types/shared.types.d.ts +91 -0
- package/dist/types/shared.types.d.ts.map +1 -0
- package/dist/types/shared.types.js +57 -0
- package/dist/types/shared.types.js.map +1 -0
- package/dist/types/space.types.d.ts +82 -0
- package/dist/types/space.types.d.ts.map +1 -0
- package/dist/types/space.types.js +18 -0
- package/dist/types/space.types.js.map +1 -0
- package/dist/types/utils.types.d.ts +51 -0
- package/dist/types/utils.types.d.ts.map +1 -0
- package/dist/types/utils.types.js +4 -0
- package/dist/types/utils.types.js.map +1 -0
- package/dist/utils/auth-helpers.d.ts +23 -0
- package/dist/utils/auth-helpers.d.ts.map +1 -0
- package/dist/utils/auth-helpers.js +31 -0
- package/dist/utils/auth-helpers.js.map +1 -0
- package/dist/utils/debug.d.ts +45 -0
- package/dist/utils/debug.d.ts.map +1 -0
- package/dist/utils/debug.js +112 -0
- package/dist/utils/debug.js.map +1 -0
- package/dist/utils/error-handler.d.ts +46 -0
- package/dist/utils/error-handler.d.ts.map +1 -0
- package/dist/utils/error-handler.js +63 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/filters.d.ts +42 -0
- package/dist/utils/filters.d.ts.map +1 -0
- package/dist/utils/filters.js +132 -0
- package/dist/utils/filters.js.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +22 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +68 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +100 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RelationshipService — CRUD + search for memory relationships.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from 4 remember-mcp tool handlers:
|
|
5
|
+
* create-relationship.ts, update-relationship.ts,
|
|
6
|
+
* search-relationship.ts, delete-relationship.ts
|
|
7
|
+
*
|
|
8
|
+
* Relationships are stored with doc_type='relationship' in the same
|
|
9
|
+
* Weaviate collection as memories (Memory_users_{userId}).
|
|
10
|
+
*/
|
|
11
|
+
import { Filters } from 'weaviate-client';
|
|
12
|
+
import { buildDeletedFilter, combineFiltersWithAnd, } from '../utils/filters.js';
|
|
13
|
+
// ─── Service ─────────────────────────────────────────────────────────────
|
|
14
|
+
export class RelationshipService {
|
|
15
|
+
collection;
|
|
16
|
+
userId;
|
|
17
|
+
logger;
|
|
18
|
+
constructor(collection, userId, logger) {
|
|
19
|
+
this.collection = collection;
|
|
20
|
+
this.userId = userId;
|
|
21
|
+
this.logger = logger;
|
|
22
|
+
}
|
|
23
|
+
// ── Create ──────────────────────────────────────────────────────────
|
|
24
|
+
async create(input) {
|
|
25
|
+
if (input.memory_ids.length < 2) {
|
|
26
|
+
throw new Error('At least 2 memory IDs are required to create a relationship');
|
|
27
|
+
}
|
|
28
|
+
// Validate all memories exist, belong to user, are memories, not deleted
|
|
29
|
+
const checks = await Promise.all(input.memory_ids.map(async (memoryId) => {
|
|
30
|
+
const memory = await this.collection.query.fetchObjectById(memoryId, {
|
|
31
|
+
returnProperties: ['user_id', 'doc_type', 'relationship_ids', 'deleted_at'],
|
|
32
|
+
});
|
|
33
|
+
if (!memory)
|
|
34
|
+
return { memoryId, error: 'Memory not found' };
|
|
35
|
+
if (memory.properties.user_id !== this.userId)
|
|
36
|
+
return { memoryId, error: 'Unauthorized' };
|
|
37
|
+
if (memory.properties.doc_type !== 'memory')
|
|
38
|
+
return { memoryId, error: 'Not a memory document' };
|
|
39
|
+
if (memory.properties.deleted_at)
|
|
40
|
+
return { memoryId, error: 'Memory is deleted' };
|
|
41
|
+
return { memoryId, memory, relationships: memory.properties.relationship_ids || [] };
|
|
42
|
+
}));
|
|
43
|
+
const errors = checks.filter((c) => c.error);
|
|
44
|
+
if (errors.length > 0) {
|
|
45
|
+
throw new Error(`Memory validation failed: ${errors.map((e) => `${e.memoryId}: ${e.error}`).join('; ')}`);
|
|
46
|
+
}
|
|
47
|
+
const now = new Date().toISOString();
|
|
48
|
+
const properties = {
|
|
49
|
+
user_id: this.userId,
|
|
50
|
+
doc_type: 'relationship',
|
|
51
|
+
related_memory_ids: input.memory_ids,
|
|
52
|
+
relationship_type: input.relationship_type,
|
|
53
|
+
observation: input.observation,
|
|
54
|
+
strength: input.strength ?? 0.5,
|
|
55
|
+
confidence: input.confidence ?? 0.8,
|
|
56
|
+
created_at: now,
|
|
57
|
+
updated_at: now,
|
|
58
|
+
version: 1,
|
|
59
|
+
tags: input.tags || [],
|
|
60
|
+
};
|
|
61
|
+
const relationshipId = await this.collection.data.insert({ properties });
|
|
62
|
+
// Update connected memories with bidirectional reference
|
|
63
|
+
await Promise.all(checks
|
|
64
|
+
.filter((c) => !c.error && c.memory)
|
|
65
|
+
.map(async (c) => {
|
|
66
|
+
try {
|
|
67
|
+
await this.collection.data.update({
|
|
68
|
+
id: c.memoryId,
|
|
69
|
+
properties: {
|
|
70
|
+
relationship_ids: [...(c.relationships || []), relationshipId],
|
|
71
|
+
updated_at: now,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
this.logger.warn(`Failed to update memory ${c.memoryId} with relationship`);
|
|
77
|
+
}
|
|
78
|
+
}));
|
|
79
|
+
this.logger.info('Relationship created', { relationshipId, memoryCount: input.memory_ids.length });
|
|
80
|
+
return { relationship_id: relationshipId, memory_ids: input.memory_ids, created_at: now };
|
|
81
|
+
}
|
|
82
|
+
// ── Update ──────────────────────────────────────────────────────────
|
|
83
|
+
async update(input) {
|
|
84
|
+
const existing = await this.collection.query.fetchObjectById(input.relationship_id, {
|
|
85
|
+
returnProperties: ['user_id', 'doc_type', 'version'],
|
|
86
|
+
});
|
|
87
|
+
if (!existing)
|
|
88
|
+
throw new Error(`Relationship not found: ${input.relationship_id}`);
|
|
89
|
+
if (existing.properties.user_id !== this.userId)
|
|
90
|
+
throw new Error('Unauthorized');
|
|
91
|
+
if (existing.properties.doc_type !== 'relationship')
|
|
92
|
+
throw new Error('Not a relationship document');
|
|
93
|
+
const updates = {};
|
|
94
|
+
const updatedFields = [];
|
|
95
|
+
if (input.relationship_type !== undefined) {
|
|
96
|
+
updates.relationship_type = input.relationship_type;
|
|
97
|
+
updatedFields.push('relationship_type');
|
|
98
|
+
}
|
|
99
|
+
if (input.observation !== undefined) {
|
|
100
|
+
updates.observation = input.observation;
|
|
101
|
+
updatedFields.push('observation');
|
|
102
|
+
}
|
|
103
|
+
if (input.strength !== undefined) {
|
|
104
|
+
if (input.strength < 0 || input.strength > 1)
|
|
105
|
+
throw new Error('Strength must be between 0 and 1');
|
|
106
|
+
updates.strength = input.strength;
|
|
107
|
+
updatedFields.push('strength');
|
|
108
|
+
}
|
|
109
|
+
if (input.confidence !== undefined) {
|
|
110
|
+
if (input.confidence < 0 || input.confidence > 1)
|
|
111
|
+
throw new Error('Confidence must be between 0 and 1');
|
|
112
|
+
updates.confidence = input.confidence;
|
|
113
|
+
updatedFields.push('confidence');
|
|
114
|
+
}
|
|
115
|
+
if (input.tags !== undefined) {
|
|
116
|
+
updates.tags = input.tags;
|
|
117
|
+
updatedFields.push('tags');
|
|
118
|
+
}
|
|
119
|
+
if (updatedFields.length === 0)
|
|
120
|
+
throw new Error('No fields provided for update');
|
|
121
|
+
const now = new Date().toISOString();
|
|
122
|
+
updates.updated_at = now;
|
|
123
|
+
updates.version = existing.properties.version + 1;
|
|
124
|
+
await this.collection.data.update({ id: input.relationship_id, properties: updates });
|
|
125
|
+
this.logger.info('Relationship updated', { relationshipId: input.relationship_id, updatedFields });
|
|
126
|
+
return {
|
|
127
|
+
relationship_id: input.relationship_id,
|
|
128
|
+
updated_at: now,
|
|
129
|
+
version: updates.version,
|
|
130
|
+
updated_fields: updatedFields,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
// ── Search ──────────────────────────────────────────────────────────
|
|
134
|
+
async search(input) {
|
|
135
|
+
const limit = input.limit ?? 10;
|
|
136
|
+
const offset = input.offset ?? 0;
|
|
137
|
+
const filterList = [];
|
|
138
|
+
const deletedFilter = buildDeletedFilter(this.collection, input.deleted_filter || 'exclude');
|
|
139
|
+
if (deletedFilter)
|
|
140
|
+
filterList.push(deletedFilter);
|
|
141
|
+
filterList.push(this.collection.filter.byProperty('doc_type').equal('relationship'));
|
|
142
|
+
if (input.relationship_types?.length) {
|
|
143
|
+
if (input.relationship_types.length === 1) {
|
|
144
|
+
filterList.push(this.collection.filter.byProperty('relationship_type').equal(input.relationship_types[0]));
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
filterList.push(Filters.or(...input.relationship_types.map((t) => this.collection.filter.byProperty('relationship_type').equal(t))));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (input.strength_min !== undefined) {
|
|
151
|
+
filterList.push(this.collection.filter.byProperty('strength').greaterOrEqual(input.strength_min));
|
|
152
|
+
}
|
|
153
|
+
if (input.confidence_min !== undefined) {
|
|
154
|
+
filterList.push(this.collection.filter.byProperty('confidence').greaterOrEqual(input.confidence_min));
|
|
155
|
+
}
|
|
156
|
+
if (input.tags?.length) {
|
|
157
|
+
filterList.push(this.collection.filter.byProperty('tags').containsAny(input.tags));
|
|
158
|
+
}
|
|
159
|
+
const combinedFilters = combineFiltersWithAnd(filterList);
|
|
160
|
+
const opts = { alpha: 1.0, limit: limit + offset };
|
|
161
|
+
if (combinedFilters)
|
|
162
|
+
opts.filters = combinedFilters;
|
|
163
|
+
const results = await this.collection.query.hybrid(input.query, opts);
|
|
164
|
+
const paginated = results.objects.slice(offset, offset + limit);
|
|
165
|
+
const relationships = paginated.map((obj) => ({
|
|
166
|
+
id: obj.uuid,
|
|
167
|
+
...obj.properties,
|
|
168
|
+
}));
|
|
169
|
+
return { relationships, total: results.objects.length, offset, limit };
|
|
170
|
+
}
|
|
171
|
+
// ── Delete ──────────────────────────────────────────────────────────
|
|
172
|
+
async delete(input) {
|
|
173
|
+
const existing = await this.collection.query.fetchObjectById(input.relationship_id, {
|
|
174
|
+
returnProperties: ['user_id', 'doc_type', 'related_memory_ids'],
|
|
175
|
+
});
|
|
176
|
+
if (!existing)
|
|
177
|
+
throw new Error(`Relationship not found: ${input.relationship_id}`);
|
|
178
|
+
if (existing.properties.user_id !== this.userId)
|
|
179
|
+
throw new Error('Unauthorized');
|
|
180
|
+
if (existing.properties.doc_type !== 'relationship')
|
|
181
|
+
throw new Error('Not a relationship document');
|
|
182
|
+
const memoryIds = existing.properties.related_memory_ids || [];
|
|
183
|
+
let memoriesUpdated = 0;
|
|
184
|
+
// Remove relationship reference from connected memories
|
|
185
|
+
await Promise.all(memoryIds.map(async (memoryId) => {
|
|
186
|
+
try {
|
|
187
|
+
const memory = await this.collection.query.fetchObjectById(memoryId, {
|
|
188
|
+
returnProperties: ['relationship_ids', 'doc_type'],
|
|
189
|
+
});
|
|
190
|
+
if (!memory || memory.properties.doc_type !== 'memory')
|
|
191
|
+
return;
|
|
192
|
+
const current = memory.properties.relationship_ids || [];
|
|
193
|
+
const updated = current.filter((id) => id !== input.relationship_id);
|
|
194
|
+
if (updated.length !== current.length) {
|
|
195
|
+
await this.collection.data.update({
|
|
196
|
+
id: memoryId,
|
|
197
|
+
properties: { relationship_ids: updated, updated_at: new Date().toISOString() },
|
|
198
|
+
});
|
|
199
|
+
memoriesUpdated++;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
this.logger.warn(`Failed to clean up memory ${memoryId}`);
|
|
204
|
+
}
|
|
205
|
+
}));
|
|
206
|
+
await this.collection.data.deleteById(input.relationship_id);
|
|
207
|
+
this.logger.info('Relationship deleted', { relationshipId: input.relationship_id, memoriesUpdated });
|
|
208
|
+
return { relationship_id: input.relationship_id, memories_updated: memoriesUpdated };
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=relationship.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relationship.service.js","sourceRoot":"","sources":["../../src/services/relationship.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EACL,kBAAkB,EAClB,qBAAqB,GAEtB,MAAM,qBAAqB,CAAC;AAgE7B,4EAA4E;AAE5E,MAAM,OAAO,mBAAmB;IAEpB;IACA;IACA;IAHV,YACU,UAAe,EACf,MAAc,EACd,MAAc;QAFd,eAAU,GAAV,UAAU,CAAK;QACf,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAQ;IACrB,CAAC;IAEJ,uEAAuE;IAEvE,KAAK,CAAC,MAA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AAE,eAAe,EAAE,CAAC;IACvF,CAAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Space/Group Configuration Service.
|
|
3
|
+
*
|
|
4
|
+
* Ported from remember-mcp/src/services/space-config.service.ts.
|
|
5
|
+
* Per-space and per-group behavioral configuration stored in Firestore.
|
|
6
|
+
*/
|
|
7
|
+
import type { Logger } from '../utils/logger.js';
|
|
8
|
+
import type { WriteMode } from '../types/auth.types.js';
|
|
9
|
+
export interface SpaceConfig {
|
|
10
|
+
require_moderation: boolean;
|
|
11
|
+
default_write_mode: WriteMode;
|
|
12
|
+
}
|
|
13
|
+
export declare const DEFAULT_SPACE_CONFIG: SpaceConfig;
|
|
14
|
+
/**
|
|
15
|
+
* Get configuration for a space or group. Returns defaults merged with stored config.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getSpaceConfig(id: string, type: 'space' | 'group', logger?: Logger): Promise<SpaceConfig>;
|
|
18
|
+
/**
|
|
19
|
+
* Set configuration for a space or group. Merges partial config with existing values.
|
|
20
|
+
*/
|
|
21
|
+
export declare function setSpaceConfig(id: string, type: 'space' | 'group', config: Partial<SpaceConfig>, logger?: Logger): Promise<void>;
|
|
22
|
+
//# sourceMappingURL=space-config.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"space-config.service.d.ts","sourceRoot":"","sources":["../../src/services/space-config.service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,WAAW,WAAW;IAC1B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,kBAAkB,EAAE,SAAS,CAAC;CAC/B;AAED,eAAO,MAAM,oBAAoB,EAAE,WAGlC,CAAC;AAOF;;GAEG;AACH,wBAAsB,cAAc,CAClC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,OAAO,GAAG,OAAO,EACvB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,WAAW,CAAC,CAetB;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,OAAO,GAAG,OAAO,EACvB,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,EAC5B,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CASf"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Space/Group Configuration Service.
|
|
3
|
+
*
|
|
4
|
+
* Ported from remember-mcp/src/services/space-config.service.ts.
|
|
5
|
+
* Per-space and per-group behavioral configuration stored in Firestore.
|
|
6
|
+
*/
|
|
7
|
+
import { getDocument, setDocument } from '../database/firestore/init.js';
|
|
8
|
+
export const DEFAULT_SPACE_CONFIG = {
|
|
9
|
+
require_moderation: false,
|
|
10
|
+
default_write_mode: 'owner_only',
|
|
11
|
+
};
|
|
12
|
+
function getConfigPath(id, type) {
|
|
13
|
+
const prefix = type === 'space' ? 'spaces' : 'groups';
|
|
14
|
+
return { collectionPath: `${prefix}/${id}/config`, docId: 'settings' };
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get configuration for a space or group. Returns defaults merged with stored config.
|
|
18
|
+
*/
|
|
19
|
+
export async function getSpaceConfig(id, type, logger) {
|
|
20
|
+
try {
|
|
21
|
+
const { collectionPath, docId } = getConfigPath(id, type);
|
|
22
|
+
const doc = await getDocument(collectionPath, docId);
|
|
23
|
+
if (!doc)
|
|
24
|
+
return { ...DEFAULT_SPACE_CONFIG };
|
|
25
|
+
return { ...DEFAULT_SPACE_CONFIG, ...doc };
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
logger?.error('Failed to get space config', {
|
|
29
|
+
service: 'SpaceConfigService',
|
|
30
|
+
id,
|
|
31
|
+
type,
|
|
32
|
+
error: error instanceof Error ? error.message : String(error),
|
|
33
|
+
});
|
|
34
|
+
return { ...DEFAULT_SPACE_CONFIG };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Set configuration for a space or group. Merges partial config with existing values.
|
|
39
|
+
*/
|
|
40
|
+
export async function setSpaceConfig(id, type, config, logger) {
|
|
41
|
+
const { collectionPath, docId } = getConfigPath(id, type);
|
|
42
|
+
await setDocument(collectionPath, docId, config, { merge: true });
|
|
43
|
+
logger?.info('Space config updated', {
|
|
44
|
+
service: 'SpaceConfigService',
|
|
45
|
+
id,
|
|
46
|
+
type,
|
|
47
|
+
updatedKeys: Object.keys(config),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=space-config.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"space-config.service.js","sourceRoot":"","sources":["../../src/services/space-config.service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AASzE,MAAM,CAAC,MAAM,oBAAoB,GAAgB;IAC/C,kBAAkB,EAAE,KAAK;IACzB,kBAAkB,EAAE,YAAY;CACjC,CAAC;AAEF,SAAS,aAAa,CAAC,EAAU,EAAE,IAAuB;IACxD,MAAM,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;IACtD,OAAO,EAAE,cAAc,EAAE,GAAG,MAAM,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AACzE,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,EAAU,EACV,IAAuB,EACvB,MAAe;IAEf,IAAI,CAAC;QACH,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAC1D,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;QACrD,IAAI,CAAC,GAAG;YAAE,OAAO,EAAE,GAAG,oBAAoB,EAAE,CAAC;QAC7C,OAAO,EAAE,GAAG,oBAAoB,EAAE,GAAG,GAAG,EAAE,CAAC;IAC7C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,EAAE,KAAK,CAAC,4BAA4B,EAAE;YAC1C,OAAO,EAAE,oBAAoB;YAC7B,EAAE;YACF,IAAI;YACJ,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC9D,CAAC,CAAC;QACH,OAAO,EAAE,GAAG,oBAAoB,EAAE,CAAC;IACrC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,EAAU,EACV,IAAuB,EACvB,MAA4B,EAC5B,MAAe;IAEf,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,GAAG,aAAa,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAC1D,MAAM,WAAW,CAAC,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAClE,MAAM,EAAE,IAAI,CAAC,sBAAsB,EAAE;QACnC,OAAO,EAAE,oBAAoB;QAC7B,EAAE;QACF,IAAI;QACJ,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;KACjC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SpaceService — publish/retract/revise/confirm/deny/moderate/search/query.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from 8 remember-mcp tool handlers:
|
|
5
|
+
* publish.ts, retract.ts, revise.ts, confirm.ts,
|
|
6
|
+
* deny.ts, moderate.ts, search-space.ts, query-space.ts
|
|
7
|
+
*
|
|
8
|
+
* Design: accepts Weaviate client + user collection + ConfirmationTokenService + Logger via constructor.
|
|
9
|
+
* No MCP-specific code.
|
|
10
|
+
*/
|
|
11
|
+
import type { Logger } from '../utils/logger.js';
|
|
12
|
+
import type { AuthContext } from '../types/auth.types.js';
|
|
13
|
+
import type { ConfirmationTokenService } from './confirmation-token.service.js';
|
|
14
|
+
export type ModerationAction = 'approve' | 'reject' | 'remove';
|
|
15
|
+
export type ModerationFilter = 'approved' | 'pending' | 'rejected' | 'removed' | 'all';
|
|
16
|
+
export interface RevisionEntry {
|
|
17
|
+
content: string;
|
|
18
|
+
revised_at: string;
|
|
19
|
+
}
|
|
20
|
+
export interface RevisionResult {
|
|
21
|
+
location: string;
|
|
22
|
+
status: 'success' | 'failed' | 'skipped';
|
|
23
|
+
error?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function parseRevisionHistory(raw: unknown): RevisionEntry[];
|
|
26
|
+
export declare function buildRevisionHistory(existing: RevisionEntry[], oldContent: string, revisedAt: string): RevisionEntry[];
|
|
27
|
+
export declare function buildModerationFilter(collection: any, moderationFilter?: ModerationFilter): any | null;
|
|
28
|
+
export interface PublishInput {
|
|
29
|
+
memory_id: string;
|
|
30
|
+
spaces?: string[];
|
|
31
|
+
groups?: string[];
|
|
32
|
+
additional_tags?: string[];
|
|
33
|
+
}
|
|
34
|
+
export interface PublishResult {
|
|
35
|
+
token: string;
|
|
36
|
+
}
|
|
37
|
+
export interface RetractInput {
|
|
38
|
+
memory_id: string;
|
|
39
|
+
spaces?: string[];
|
|
40
|
+
groups?: string[];
|
|
41
|
+
}
|
|
42
|
+
export interface RetractResult {
|
|
43
|
+
token: string;
|
|
44
|
+
}
|
|
45
|
+
export interface ReviseInput {
|
|
46
|
+
memory_id: string;
|
|
47
|
+
}
|
|
48
|
+
export interface ReviseResult {
|
|
49
|
+
token: string;
|
|
50
|
+
}
|
|
51
|
+
export interface ConfirmInput {
|
|
52
|
+
token: string;
|
|
53
|
+
}
|
|
54
|
+
export interface ConfirmResult {
|
|
55
|
+
action: string;
|
|
56
|
+
success: boolean;
|
|
57
|
+
composite_id?: string;
|
|
58
|
+
published_to?: string[];
|
|
59
|
+
retracted_from?: string[];
|
|
60
|
+
revised_at?: string;
|
|
61
|
+
space_ids?: string[];
|
|
62
|
+
group_ids?: string[];
|
|
63
|
+
failed?: string[];
|
|
64
|
+
results?: RevisionResult[];
|
|
65
|
+
memory_id?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface DenyInput {
|
|
68
|
+
token: string;
|
|
69
|
+
}
|
|
70
|
+
export interface DenyResult {
|
|
71
|
+
success: boolean;
|
|
72
|
+
}
|
|
73
|
+
export interface ModerateInput {
|
|
74
|
+
memory_id: string;
|
|
75
|
+
space_id?: string;
|
|
76
|
+
group_id?: string;
|
|
77
|
+
action: ModerationAction;
|
|
78
|
+
reason?: string;
|
|
79
|
+
}
|
|
80
|
+
export interface ModerateResult {
|
|
81
|
+
memory_id: string;
|
|
82
|
+
action: ModerationAction;
|
|
83
|
+
moderation_status: string;
|
|
84
|
+
moderated_by: string;
|
|
85
|
+
moderated_at: string;
|
|
86
|
+
location: string;
|
|
87
|
+
}
|
|
88
|
+
export interface SearchSpaceInput {
|
|
89
|
+
query: string;
|
|
90
|
+
spaces?: string[];
|
|
91
|
+
groups?: string[];
|
|
92
|
+
search_type?: 'hybrid' | 'bm25' | 'semantic';
|
|
93
|
+
content_type?: string;
|
|
94
|
+
tags?: string[];
|
|
95
|
+
min_weight?: number;
|
|
96
|
+
max_weight?: number;
|
|
97
|
+
date_from?: string;
|
|
98
|
+
date_to?: string;
|
|
99
|
+
moderation_filter?: ModerationFilter;
|
|
100
|
+
include_comments?: boolean;
|
|
101
|
+
limit?: number;
|
|
102
|
+
offset?: number;
|
|
103
|
+
}
|
|
104
|
+
export interface SearchSpaceResult {
|
|
105
|
+
spaces_searched: string[] | 'all_public';
|
|
106
|
+
groups_searched: string[];
|
|
107
|
+
memories: Record<string, unknown>[];
|
|
108
|
+
total: number;
|
|
109
|
+
offset: number;
|
|
110
|
+
limit: number;
|
|
111
|
+
}
|
|
112
|
+
export interface QuerySpaceInput {
|
|
113
|
+
question: string;
|
|
114
|
+
spaces: string[];
|
|
115
|
+
content_type?: string;
|
|
116
|
+
tags?: string[];
|
|
117
|
+
min_weight?: number;
|
|
118
|
+
date_from?: string;
|
|
119
|
+
date_to?: string;
|
|
120
|
+
moderation_filter?: ModerationFilter;
|
|
121
|
+
include_comments?: boolean;
|
|
122
|
+
limit?: number;
|
|
123
|
+
}
|
|
124
|
+
export interface QuerySpaceResult {
|
|
125
|
+
question: string;
|
|
126
|
+
spaces_queried: string[];
|
|
127
|
+
memories: Record<string, unknown>[];
|
|
128
|
+
total: number;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* SpaceService provides transport-agnostic space operations.
|
|
132
|
+
*
|
|
133
|
+
* @param weaviateClient - Weaviate client instance (for multi-collection access)
|
|
134
|
+
* @param userCollection - User's personal Weaviate collection
|
|
135
|
+
* @param userId - The owner user ID
|
|
136
|
+
* @param confirmationTokenService - ConfirmationTokenService instance
|
|
137
|
+
* @param logger - Logger instance
|
|
138
|
+
*/
|
|
139
|
+
export declare class SpaceService {
|
|
140
|
+
private weaviateClient;
|
|
141
|
+
private userCollection;
|
|
142
|
+
private userId;
|
|
143
|
+
private confirmationTokenService;
|
|
144
|
+
private logger;
|
|
145
|
+
constructor(weaviateClient: any, userCollection: any, userId: string, confirmationTokenService: ConfirmationTokenService, logger: Logger);
|
|
146
|
+
publish(input: PublishInput): Promise<PublishResult>;
|
|
147
|
+
retract(input: RetractInput): Promise<RetractResult>;
|
|
148
|
+
revise(input: ReviseInput): Promise<ReviseResult>;
|
|
149
|
+
confirm(input: ConfirmInput): Promise<ConfirmResult>;
|
|
150
|
+
deny(input: DenyInput): Promise<DenyResult>;
|
|
151
|
+
moderate(input: ModerateInput, authContext?: AuthContext): Promise<ModerateResult>;
|
|
152
|
+
search(input: SearchSpaceInput, authContext?: AuthContext): Promise<SearchSpaceResult>;
|
|
153
|
+
query(input: QuerySpaceInput, authContext?: AuthContext): Promise<QuerySpaceResult>;
|
|
154
|
+
private executePublish;
|
|
155
|
+
private executeRetract;
|
|
156
|
+
private executeRevise;
|
|
157
|
+
private buildBaseFilters;
|
|
158
|
+
private executeSearch;
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=space.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"space.service.d.ts","sourceRoot":"","sources":["../../src/services/space.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,wBAAwB,EAAuB,MAAM,iCAAiC,CAAC;AAUrG,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAC/D,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,KAAK,CAAC;AAYvF,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,aAAa,EAAE,CAelE;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,aAAa,EAAE,EACzB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,aAAa,EAAE,CAGjB;AAID,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,GAAG,EACf,gBAAgB,GAAE,gBAA6B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