rice-node-sdk 1.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/README.md +270 -0
- package/dist/Client.d.ts +16 -0
- package/dist/Client.js +117 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.js +53 -0
- package/dist/index.d.ts +110 -0
- package/dist/index.js +34 -0
- package/dist/state/index.d.ts +62 -0
- package/dist/state/index.js +189 -0
- package/dist/state/proto/state.proto +100 -0
- package/dist/state/tools.d.ts +97 -0
- package/dist/state/tools.js +13 -0
- package/dist/storage/client/BaseClient.d.ts +133 -0
- package/dist/storage/client/BaseClient.js +81 -0
- package/dist/storage/client/GrpcClient.d.ts +87 -0
- package/dist/storage/client/GrpcClient.js +398 -0
- package/dist/storage/client/HttpClient.d.ts +87 -0
- package/dist/storage/client/HttpClient.js +335 -0
- package/dist/storage/client/RiceDBClient.d.ts +306 -0
- package/dist/storage/client/RiceDBClient.js +408 -0
- package/dist/storage/index.d.ts +8 -0
- package/dist/storage/index.js +29 -0
- package/dist/storage/proto/ricedb.d.ts +1183 -0
- package/dist/storage/proto/ricedb.js +4469 -0
- package/dist/storage/utils/BitVector.d.ts +10 -0
- package/dist/storage/utils/BitVector.js +54 -0
- package/dist/tools/anthropic.d.ts +29 -0
- package/dist/tools/anthropic.js +44 -0
- package/dist/tools/execute.d.ts +2 -0
- package/dist/tools/execute.js +22 -0
- package/dist/tools/google.d.ts +29 -0
- package/dist/tools/google.js +44 -0
- package/dist/tools/openai.d.ts +35 -0
- package/dist/tools/openai.js +53 -0
- package/package.json +58 -0
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.GrpcClient = void 0;
|
|
7
|
+
const grpc_js_1 = require("@grpc/grpc-js");
|
|
8
|
+
const BaseClient_1 = require("./BaseClient");
|
|
9
|
+
const ricedb_1 = require("../proto/ricedb");
|
|
10
|
+
const long_1 = __importDefault(require("long"));
|
|
11
|
+
const BitVector_1 = require("../utils/BitVector");
|
|
12
|
+
class GrpcClient extends BaseClient_1.BaseRiceDBClient {
|
|
13
|
+
constructor(host = "localhost", port = 50051, token) {
|
|
14
|
+
super(host, port);
|
|
15
|
+
this.client = null;
|
|
16
|
+
this.token = null;
|
|
17
|
+
if (token) {
|
|
18
|
+
this.token = token;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async connect() {
|
|
22
|
+
const address = `${this.host}:${this.port}`;
|
|
23
|
+
this.client = new ricedb_1.RiceDBClient(address, grpc_js_1.credentials.createInsecure(), {
|
|
24
|
+
"grpc.max_send_message_length": 50 * 1024 * 1024,
|
|
25
|
+
"grpc.max_receive_message_length": 50 * 1024 * 1024,
|
|
26
|
+
});
|
|
27
|
+
try {
|
|
28
|
+
await this.health();
|
|
29
|
+
this.connected = true;
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
this.connected = false;
|
|
34
|
+
throw e;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
disconnect() {
|
|
38
|
+
if (this.client) {
|
|
39
|
+
this.client.close();
|
|
40
|
+
this.client = null;
|
|
41
|
+
}
|
|
42
|
+
this.connected = false;
|
|
43
|
+
}
|
|
44
|
+
getMetadata() {
|
|
45
|
+
const metadata = new grpc_js_1.Metadata();
|
|
46
|
+
if (this.token) {
|
|
47
|
+
metadata.add("authorization", `Bearer ${this.token}`);
|
|
48
|
+
}
|
|
49
|
+
return metadata;
|
|
50
|
+
}
|
|
51
|
+
promisify(method, req) {
|
|
52
|
+
return new Promise((resolve, reject) => {
|
|
53
|
+
if (!this.client)
|
|
54
|
+
return reject(new Error("Not connected"));
|
|
55
|
+
method.call(this.client, req, this.getMetadata(), (err, res) => {
|
|
56
|
+
if (err)
|
|
57
|
+
reject(err);
|
|
58
|
+
else
|
|
59
|
+
resolve(res);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
async health() {
|
|
64
|
+
if (!this.client)
|
|
65
|
+
throw new Error("Not connected");
|
|
66
|
+
const res = await this.promisify(this.client.health, {});
|
|
67
|
+
return res;
|
|
68
|
+
}
|
|
69
|
+
async login(username, password) {
|
|
70
|
+
if (!this.client)
|
|
71
|
+
throw new Error("Not connected");
|
|
72
|
+
const res = await this.promisify(this.client.login, { username, password });
|
|
73
|
+
this.token = res.token;
|
|
74
|
+
return this.token;
|
|
75
|
+
}
|
|
76
|
+
async createUser(username, password, role = "user") {
|
|
77
|
+
if (!this.client)
|
|
78
|
+
throw new Error("Not connected");
|
|
79
|
+
const res = await this.promisify(this.client.createUser, {
|
|
80
|
+
username,
|
|
81
|
+
password,
|
|
82
|
+
role,
|
|
83
|
+
});
|
|
84
|
+
return res.userId;
|
|
85
|
+
}
|
|
86
|
+
async deleteUser(username) {
|
|
87
|
+
if (!this.client)
|
|
88
|
+
throw new Error("Not connected");
|
|
89
|
+
const res = await this.promisify(this.client.deleteUser, { username });
|
|
90
|
+
return res.success;
|
|
91
|
+
}
|
|
92
|
+
async getUser(username) {
|
|
93
|
+
throw new Error("Get user is not supported via gRPC transport. Use HTTP.");
|
|
94
|
+
}
|
|
95
|
+
async listUsers() {
|
|
96
|
+
throw new Error("List users is not supported via gRPC transport. Use HTTP.");
|
|
97
|
+
}
|
|
98
|
+
async insert(nodeId, text, metadata, userId = 1, sessionId, embedding) {
|
|
99
|
+
if (!this.client)
|
|
100
|
+
throw new Error("Not connected");
|
|
101
|
+
const req = {
|
|
102
|
+
id: this.toLong(nodeId),
|
|
103
|
+
text,
|
|
104
|
+
metadata: Buffer.from(JSON.stringify(metadata)),
|
|
105
|
+
userId: this.toLong(userId),
|
|
106
|
+
sessionId,
|
|
107
|
+
embedding: embedding || [],
|
|
108
|
+
};
|
|
109
|
+
const res = await this.promisify(this.client.insert, req);
|
|
110
|
+
return res;
|
|
111
|
+
}
|
|
112
|
+
async search(query, userId, k = 10, sessionId, filter, queryEmbedding) {
|
|
113
|
+
if (!this.client)
|
|
114
|
+
throw new Error("Not connected");
|
|
115
|
+
const req = {
|
|
116
|
+
queryText: query,
|
|
117
|
+
userId: this.toLong(userId),
|
|
118
|
+
k,
|
|
119
|
+
sessionId,
|
|
120
|
+
filter: filter ? JSON.stringify(filter) : "",
|
|
121
|
+
queryEmbedding: queryEmbedding || [],
|
|
122
|
+
};
|
|
123
|
+
const res = await this.promisify(this.client.search, req);
|
|
124
|
+
return res.results.map((r) => ({
|
|
125
|
+
id: r.id,
|
|
126
|
+
similarity: r.similarity,
|
|
127
|
+
metadata: JSON.parse(r.metadata.toString()),
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
async delete(nodeId, sessionId) {
|
|
131
|
+
if (!this.client)
|
|
132
|
+
throw new Error("Not connected");
|
|
133
|
+
const res = await this.promisify(this.client.deleteNode, {
|
|
134
|
+
nodeId: this.toLong(nodeId),
|
|
135
|
+
sessionId,
|
|
136
|
+
});
|
|
137
|
+
return res.success;
|
|
138
|
+
}
|
|
139
|
+
async createSession(parentSessionId) {
|
|
140
|
+
if (!this.client)
|
|
141
|
+
throw new Error("Not connected");
|
|
142
|
+
const res = await this.promisify(this.client.createSession, {
|
|
143
|
+
parentSessionId,
|
|
144
|
+
});
|
|
145
|
+
return res.sessionId;
|
|
146
|
+
}
|
|
147
|
+
async snapshotSession(sessionId, path) {
|
|
148
|
+
if (!this.client)
|
|
149
|
+
throw new Error("Not connected");
|
|
150
|
+
const res = await this.promisify(this.client.snapshotSession, {
|
|
151
|
+
sessionId,
|
|
152
|
+
path,
|
|
153
|
+
});
|
|
154
|
+
return res.success;
|
|
155
|
+
}
|
|
156
|
+
async loadSession(path) {
|
|
157
|
+
if (!this.client)
|
|
158
|
+
throw new Error("Not connected");
|
|
159
|
+
const res = await this.promisify(this.client.loadSession, { path });
|
|
160
|
+
return res.sessionId;
|
|
161
|
+
}
|
|
162
|
+
async commitSession(sessionId, mergeStrategy = "overwrite") {
|
|
163
|
+
if (!this.client)
|
|
164
|
+
throw new Error("Not connected");
|
|
165
|
+
const res = await this.promisify(this.client.commitSession, {
|
|
166
|
+
sessionId,
|
|
167
|
+
mergeStrategy,
|
|
168
|
+
});
|
|
169
|
+
return res.success;
|
|
170
|
+
}
|
|
171
|
+
async dropSession(sessionId) {
|
|
172
|
+
if (!this.client)
|
|
173
|
+
throw new Error("Not connected");
|
|
174
|
+
const res = await this.promisify(this.client.dropSession, {
|
|
175
|
+
sessionId,
|
|
176
|
+
});
|
|
177
|
+
return res.success;
|
|
178
|
+
}
|
|
179
|
+
async writeMemory(address, data, userId = 1) {
|
|
180
|
+
if (!this.client)
|
|
181
|
+
throw new Error("Not connected");
|
|
182
|
+
const req = {
|
|
183
|
+
address: { chunks: address.toList() },
|
|
184
|
+
data: { chunks: data.toList() },
|
|
185
|
+
userId: this.toLong(userId),
|
|
186
|
+
};
|
|
187
|
+
const res = await this.promisify(this.client.writeMemory, req);
|
|
188
|
+
return { success: res.success, message: res.message };
|
|
189
|
+
}
|
|
190
|
+
async readMemory(address, userId = 1) {
|
|
191
|
+
if (!this.client)
|
|
192
|
+
throw new Error("Not connected");
|
|
193
|
+
const req = {
|
|
194
|
+
address: { chunks: address.toList() },
|
|
195
|
+
userId: this.toLong(userId),
|
|
196
|
+
};
|
|
197
|
+
const res = await this.promisify(this.client.readMemory, req);
|
|
198
|
+
return new BitVector_1.BitVector(res.data.chunks);
|
|
199
|
+
}
|
|
200
|
+
async addMemory(sessionId, agentId, content, metadata = {}, ttlSeconds) {
|
|
201
|
+
if (!this.client)
|
|
202
|
+
throw new Error("Not connected");
|
|
203
|
+
const req = { sessionId, agentId, content, metadata, ttlSeconds };
|
|
204
|
+
const res = await this.promisify(this.client.addMemory, req);
|
|
205
|
+
return { success: res.success, message: res.message, entry: res.entry };
|
|
206
|
+
}
|
|
207
|
+
async getMemory(sessionId, limit = 50, after = 0, filter = {}) {
|
|
208
|
+
if (!this.client)
|
|
209
|
+
throw new Error("Not connected");
|
|
210
|
+
const req = {
|
|
211
|
+
sessionId,
|
|
212
|
+
limit,
|
|
213
|
+
afterTimestamp: long_1.default.fromValue(after),
|
|
214
|
+
filter,
|
|
215
|
+
};
|
|
216
|
+
const res = await this.promisify(this.client.getMemory, req);
|
|
217
|
+
return res.entries;
|
|
218
|
+
}
|
|
219
|
+
async clearMemory(sessionId) {
|
|
220
|
+
if (!this.client)
|
|
221
|
+
throw new Error("Not connected");
|
|
222
|
+
const res = await this.promisify(this.client.clearMemory, {
|
|
223
|
+
sessionId,
|
|
224
|
+
});
|
|
225
|
+
return { success: res.success, message: res.message };
|
|
226
|
+
}
|
|
227
|
+
async *watchMemory(sessionId) {
|
|
228
|
+
if (!this.client)
|
|
229
|
+
throw new Error("Not connected");
|
|
230
|
+
const stream = this.client.watchMemory({ sessionId }, this.getMetadata());
|
|
231
|
+
for await (const event of stream) {
|
|
232
|
+
yield event;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
async addEdge(fromNode, toNode, relation, weight = 1.0) {
|
|
236
|
+
if (!this.client)
|
|
237
|
+
throw new Error("Not connected");
|
|
238
|
+
const req = {
|
|
239
|
+
from: this.toLong(fromNode),
|
|
240
|
+
to: this.toLong(toNode),
|
|
241
|
+
relation,
|
|
242
|
+
weight,
|
|
243
|
+
};
|
|
244
|
+
const res = await this.promisify(this.client.addEdge, req);
|
|
245
|
+
return res.success;
|
|
246
|
+
}
|
|
247
|
+
async getNeighbors(nodeId, relation) {
|
|
248
|
+
if (!this.client)
|
|
249
|
+
throw new Error("Not connected");
|
|
250
|
+
const req = { nodeId: this.toLong(nodeId), relation };
|
|
251
|
+
const res = await this.promisify(this.client.getNeighbors, req);
|
|
252
|
+
return res.neighbors;
|
|
253
|
+
}
|
|
254
|
+
async traverse(startNode, maxDepth = 1) {
|
|
255
|
+
if (!this.client)
|
|
256
|
+
throw new Error("Not connected");
|
|
257
|
+
const req = { start: this.toLong(startNode), maxDepth };
|
|
258
|
+
const res = await this.promisify(this.client.traverseGraph, req);
|
|
259
|
+
return res.visited;
|
|
260
|
+
}
|
|
261
|
+
async sampleGraph(limit = 100) {
|
|
262
|
+
throw new Error("Sample graph is not supported via gRPC transport. Use HTTP.");
|
|
263
|
+
}
|
|
264
|
+
async *subscribe(filterType = "all", nodeId, queryText = "", threshold = 0.8) {
|
|
265
|
+
if (!this.client)
|
|
266
|
+
throw new Error("Not connected");
|
|
267
|
+
const req = {
|
|
268
|
+
filterType,
|
|
269
|
+
nodeId: nodeId ? this.toLong(nodeId) : undefined,
|
|
270
|
+
vector: [],
|
|
271
|
+
queryText,
|
|
272
|
+
threshold,
|
|
273
|
+
};
|
|
274
|
+
const stream = this.client.subscribe(req, this.getMetadata());
|
|
275
|
+
for await (const event of stream) {
|
|
276
|
+
const res = { type: event.type, nodeId: event.nodeId };
|
|
277
|
+
if (event.node) {
|
|
278
|
+
res.node = {
|
|
279
|
+
id: event.node.id,
|
|
280
|
+
metadata: JSON.parse(event.node.metadata.toString()),
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
yield res;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
async batchInsert(documents, userId = 1) {
|
|
287
|
+
if (!this.client)
|
|
288
|
+
throw new Error("Not connected");
|
|
289
|
+
return new Promise((resolve, reject) => {
|
|
290
|
+
if (!this.client)
|
|
291
|
+
return reject(new Error("Not connected"));
|
|
292
|
+
const stream = this.client.batchInsert(this.getMetadata(), (err, res) => {
|
|
293
|
+
if (err)
|
|
294
|
+
reject(err);
|
|
295
|
+
else
|
|
296
|
+
resolve({ count: res.count, nodeIds: res.nodeIds });
|
|
297
|
+
});
|
|
298
|
+
for (const doc of documents) {
|
|
299
|
+
const docUserId = doc.userId !== undefined
|
|
300
|
+
? this.toLong(doc.userId)
|
|
301
|
+
: this.toLong(userId);
|
|
302
|
+
const text = doc.text || "";
|
|
303
|
+
const metadata = Buffer.from(JSON.stringify(doc.metadata));
|
|
304
|
+
stream.write({
|
|
305
|
+
id: this.toLong(doc.id),
|
|
306
|
+
text,
|
|
307
|
+
metadata,
|
|
308
|
+
userId: docUserId,
|
|
309
|
+
sessionId: undefined,
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
stream.end();
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
async grantPermission(nodeId, userId, permissions) {
|
|
316
|
+
if (!this.client)
|
|
317
|
+
throw new Error("Not connected");
|
|
318
|
+
const req = {
|
|
319
|
+
nodeId: this.toLong(nodeId),
|
|
320
|
+
targetUserId: this.toLong(userId),
|
|
321
|
+
permissions: {
|
|
322
|
+
read: permissions.read || false,
|
|
323
|
+
write: permissions.write || false,
|
|
324
|
+
delete: permissions.delete || false,
|
|
325
|
+
},
|
|
326
|
+
};
|
|
327
|
+
const res = await this.promisify(this.client.grantPermission, req);
|
|
328
|
+
return res.success;
|
|
329
|
+
}
|
|
330
|
+
async revokePermission(nodeId, userId) {
|
|
331
|
+
if (!this.client)
|
|
332
|
+
throw new Error("Not connected");
|
|
333
|
+
const req = {
|
|
334
|
+
nodeId: this.toLong(nodeId),
|
|
335
|
+
targetUserId: this.toLong(userId),
|
|
336
|
+
};
|
|
337
|
+
const res = await this.promisify(this.client.revokePermission, req);
|
|
338
|
+
return res.success;
|
|
339
|
+
}
|
|
340
|
+
async checkPermission(nodeId, userId, permissionType) {
|
|
341
|
+
console.warn(`checkPermission not supported via gRPC, assuming false for ${nodeId}`);
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
async batchGrant(grants) {
|
|
345
|
+
const results = [];
|
|
346
|
+
const errors = [];
|
|
347
|
+
for (let i = 0; i < grants.length; i++) {
|
|
348
|
+
const grant = grants[i];
|
|
349
|
+
try {
|
|
350
|
+
const success = await this.grantPermission(grant.nodeId, grant.userId, grant.permissions);
|
|
351
|
+
results.push({
|
|
352
|
+
index: i,
|
|
353
|
+
nodeId: grant.nodeId,
|
|
354
|
+
userId: grant.userId,
|
|
355
|
+
success: true,
|
|
356
|
+
result: success,
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
catch (e) {
|
|
360
|
+
errors.push({
|
|
361
|
+
index: i,
|
|
362
|
+
nodeId: grant.nodeId,
|
|
363
|
+
userId: grant.userId,
|
|
364
|
+
error: e.message || String(e),
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return {
|
|
369
|
+
total: grants.length,
|
|
370
|
+
successful: results.length,
|
|
371
|
+
failed: errors.length,
|
|
372
|
+
results,
|
|
373
|
+
errors,
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
async insertWithAcl(nodeId, text, metadata, userPermissions) {
|
|
377
|
+
if (!userPermissions || userPermissions.length === 0) {
|
|
378
|
+
throw new Error("At least one user permission must be provided");
|
|
379
|
+
}
|
|
380
|
+
const primaryUser = userPermissions[0];
|
|
381
|
+
const primaryUserId = primaryUser.userId;
|
|
382
|
+
// 1. Insert for primary user
|
|
383
|
+
const insertRes = await this.insert(nodeId, text, metadata, primaryUserId);
|
|
384
|
+
// 2. Grant permissions for others
|
|
385
|
+
const additionalGrants = userPermissions.slice(1).map((p) => ({
|
|
386
|
+
nodeId: nodeId,
|
|
387
|
+
userId: p.userId,
|
|
388
|
+
permissions: p.permissions,
|
|
389
|
+
}));
|
|
390
|
+
if (additionalGrants.length > 0) {
|
|
391
|
+
const grantRes = await this.batchGrant(additionalGrants);
|
|
392
|
+
insertRes.aclGrants = grantRes;
|
|
393
|
+
}
|
|
394
|
+
insertRes.aclUsers = userPermissions;
|
|
395
|
+
return insertRes;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
exports.GrpcClient = GrpcClient;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { BaseRiceDBClient, HealthInfo, InsertResult, SearchResultItem, MemoryEntry } from "./BaseClient";
|
|
2
|
+
import Long from "long";
|
|
3
|
+
import { BitVector } from "../utils/BitVector";
|
|
4
|
+
export declare class HttpClient extends BaseRiceDBClient {
|
|
5
|
+
private client;
|
|
6
|
+
private token;
|
|
7
|
+
constructor(host?: string, port?: number, token?: string);
|
|
8
|
+
connect(): Promise<boolean>;
|
|
9
|
+
disconnect(): void;
|
|
10
|
+
private setAuthHeader;
|
|
11
|
+
private request;
|
|
12
|
+
health(): Promise<HealthInfo>;
|
|
13
|
+
login(username: string, password: string): Promise<string>;
|
|
14
|
+
createUser(username: string, password: string, role?: string): Promise<Long>;
|
|
15
|
+
deleteUser(username: string): Promise<boolean>;
|
|
16
|
+
getUser(username: string): Promise<any>;
|
|
17
|
+
listUsers(): Promise<any[]>;
|
|
18
|
+
insert(nodeId: Long | number | string, text: string, metadata: any, userId?: Long | number | string, sessionId?: string, embedding?: number[]): Promise<InsertResult>;
|
|
19
|
+
search(query: string, userId: Long | number | string, k?: number, sessionId?: string, filter?: {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}, queryEmbedding?: number[]): Promise<SearchResultItem[]>;
|
|
22
|
+
delete(nodeId: Long | number | string, sessionId?: string): Promise<boolean>;
|
|
23
|
+
createSession(parentSessionId?: string): Promise<string>;
|
|
24
|
+
snapshotSession(sessionId: string, path: string): Promise<boolean>;
|
|
25
|
+
loadSession(path: string): Promise<string>;
|
|
26
|
+
commitSession(sessionId: string, mergeStrategy?: string): Promise<boolean>;
|
|
27
|
+
dropSession(sessionId: string): Promise<boolean>;
|
|
28
|
+
writeMemory(address: BitVector, data: BitVector, userId?: Long | number | string): Promise<{
|
|
29
|
+
success: boolean;
|
|
30
|
+
message: string;
|
|
31
|
+
}>;
|
|
32
|
+
readMemory(address: BitVector, userId?: Long | number | string): Promise<BitVector>;
|
|
33
|
+
addMemory(sessionId: string, agentId: string, content: string, metadata?: {
|
|
34
|
+
[key: string]: string;
|
|
35
|
+
}, ttlSeconds?: number): Promise<{
|
|
36
|
+
success: boolean;
|
|
37
|
+
message: string;
|
|
38
|
+
entry: MemoryEntry;
|
|
39
|
+
}>;
|
|
40
|
+
getMemory(sessionId: string, limit?: number, after?: number | Long, filter?: {
|
|
41
|
+
[key: string]: string;
|
|
42
|
+
}): Promise<MemoryEntry[]>;
|
|
43
|
+
clearMemory(sessionId: string): Promise<{
|
|
44
|
+
success: boolean;
|
|
45
|
+
message: string;
|
|
46
|
+
}>;
|
|
47
|
+
watchMemory(sessionId: string): AsyncIterable<any>;
|
|
48
|
+
addEdge(fromNode: Long | number | string, toNode: Long | number | string, relation: string, weight?: number): Promise<boolean>;
|
|
49
|
+
getNeighbors(nodeId: Long | number | string, relation?: string): Promise<Long[]>;
|
|
50
|
+
traverse(startNode: Long | number | string, maxDepth?: number): Promise<Long[]>;
|
|
51
|
+
sampleGraph(limit?: number): Promise<any>;
|
|
52
|
+
subscribe(filterType?: string, nodeId?: Long | number | string, queryText?: string, threshold?: number): AsyncIterable<any>;
|
|
53
|
+
batchInsert(documents: any[], userId?: Long | number | string): Promise<{
|
|
54
|
+
count: number;
|
|
55
|
+
nodeIds: Long[];
|
|
56
|
+
}>;
|
|
57
|
+
grantPermission(nodeId: Long | number | string, userId: Long | number | string, permissions: {
|
|
58
|
+
read?: boolean;
|
|
59
|
+
write?: boolean;
|
|
60
|
+
delete?: boolean;
|
|
61
|
+
}): Promise<boolean>;
|
|
62
|
+
revokePermission(nodeId: Long | number | string, userId: Long | number | string): Promise<boolean>;
|
|
63
|
+
checkPermission(nodeId: Long | number | string, userId: Long | number | string, permissionType: string): Promise<boolean>;
|
|
64
|
+
batchGrant(grants: Array<{
|
|
65
|
+
nodeId: Long | number | string;
|
|
66
|
+
userId: Long | number | string;
|
|
67
|
+
permissions: {
|
|
68
|
+
read?: boolean;
|
|
69
|
+
write?: boolean;
|
|
70
|
+
delete?: boolean;
|
|
71
|
+
};
|
|
72
|
+
}>): Promise<{
|
|
73
|
+
total: number;
|
|
74
|
+
successful: number;
|
|
75
|
+
failed: number;
|
|
76
|
+
results: any[];
|
|
77
|
+
errors: any[];
|
|
78
|
+
}>;
|
|
79
|
+
insertWithAcl(nodeId: Long | number | string, text: string, metadata: any, userPermissions: Array<{
|
|
80
|
+
userId: Long | number | string;
|
|
81
|
+
permissions: {
|
|
82
|
+
read?: boolean;
|
|
83
|
+
write?: boolean;
|
|
84
|
+
delete?: boolean;
|
|
85
|
+
};
|
|
86
|
+
}>): Promise<InsertResult>;
|
|
87
|
+
}
|