rice-node-sdk 1.0.6 → 1.0.8
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 +49 -8
- package/dist/Client.d.ts +2 -0
- package/dist/Client.js +10 -4
- package/dist/state/index.d.ts +9 -0
- package/dist/state/index.js +20 -0
- package/dist/state/proto/state.proto +17 -0
- package/dist/storage/client/BaseClient.d.ts +7 -2
- package/dist/storage/client/GrpcClient.d.ts +7 -2
- package/dist/storage/client/GrpcClient.js +20 -2
- package/dist/storage/client/HttpClient.d.ts +7 -2
- package/dist/storage/client/HttpClient.js +16 -2
- package/dist/storage/client/RiceDBClient.d.ts +11 -3
- package/dist/storage/client/RiceDBClient.js +18 -5
- package/dist/storage/proto/ricedb.d.ts +48 -0
- package/dist/storage/proto/ricedb.js +272 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -106,19 +106,31 @@ You can load a specific config file by passing the path to the `Client` construc
|
|
|
106
106
|
const client = new Client({ configPath: "./config/prod.rice.config.js" });
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
-
#### Managing Run IDs (
|
|
109
|
+
#### Managing Run IDs (State Isolation Boundary)
|
|
110
110
|
|
|
111
|
-
For State memory,
|
|
111
|
+
For State memory, `runId` is the isolation boundary. Use one unique run ID per execution/session/test, perform all state operations with that run, then clean up with `deleteRun()`.
|
|
112
112
|
|
|
113
113
|
```typescript
|
|
114
|
-
|
|
115
|
-
const client = new Client({ runId
|
|
114
|
+
const runId = `session-${Date.now()}`;
|
|
115
|
+
const client = new Client({ runId });
|
|
116
|
+
await client.connect();
|
|
117
|
+
|
|
118
|
+
await client.state.focus("working memory item");
|
|
119
|
+
await client.state.commit("input", "outcome");
|
|
120
|
+
await client.state.setVariable("k", { v: 1 });
|
|
121
|
+
await client.state.addGoal("Do X", "high");
|
|
122
|
+
await client.state.defineConcept("Profile", { type: "object" });
|
|
116
123
|
|
|
117
|
-
//
|
|
118
|
-
client.state.
|
|
119
|
-
await client.state.focus("New task for user 456");
|
|
124
|
+
// cleanup this run
|
|
125
|
+
await client.state.deleteRun();
|
|
120
126
|
```
|
|
121
127
|
|
|
128
|
+
Practical rule: use `runId` for isolation. Do not emulate run isolation with metadata filters.
|
|
129
|
+
|
|
130
|
+
Reference examples:
|
|
131
|
+
- `examples/check_state_run_isolation.ts`
|
|
132
|
+
- `examples/check_state_all_memory_isolation.ts`
|
|
133
|
+
|
|
122
134
|
## State Features
|
|
123
135
|
|
|
124
136
|
The State service provides comprehensive AI agent memory and cognition capabilities.
|
|
@@ -266,6 +278,25 @@ console.log(cycleResult.planningTimeMs);
|
|
|
266
278
|
const history = await client.state.getCycleHistory(10);
|
|
267
279
|
```
|
|
268
280
|
|
|
281
|
+
### Pub/Sub (Real-time Events)
|
|
282
|
+
|
|
283
|
+
Subscribe to real-time events from the State service, such as variable updates or memory commits. This is useful for multi-agent coordination.
|
|
284
|
+
|
|
285
|
+
```typescript
|
|
286
|
+
// Subscribe to variable updates
|
|
287
|
+
const stream = client.state.subscribe(["VariableUpdate"]);
|
|
288
|
+
|
|
289
|
+
stream.on("data", (event) => {
|
|
290
|
+
console.log("Received event:", event.type);
|
|
291
|
+
if (event.type === "VariableUpdate") {
|
|
292
|
+
const variable = JSON.parse(event.payload);
|
|
293
|
+
console.log(`Variable ${variable.name} updated to:`, variable.value_json);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
stream.on("error", (err) => console.error("Stream error:", err));
|
|
298
|
+
```
|
|
299
|
+
|
|
269
300
|
## AI Tool Definitions
|
|
270
301
|
|
|
271
302
|
The SDK provides pre-built tool definitions tailored for popular LLM providers. These tools map directly to State memory operations.
|
|
@@ -408,6 +439,7 @@ if (call) {
|
|
|
408
439
|
| `getActionLog` | Get the action log for the current run | `client.state.getActionLog()` |
|
|
409
440
|
| `runCycle` | Run a decision cycle with action candidates | `client.state.runCycle()` |
|
|
410
441
|
| `getCycleHistory` | Get history of decision cycles | `client.state.getCycleHistory()` |
|
|
442
|
+
| `subscribe` | Subscribe to real-time state events | `client.state.subscribe()` |
|
|
411
443
|
|
|
412
444
|
## API Reference
|
|
413
445
|
|
|
@@ -415,7 +447,12 @@ if (call) {
|
|
|
415
447
|
|
|
416
448
|
```typescript
|
|
417
449
|
class Client {
|
|
418
|
-
constructor(options?: {
|
|
450
|
+
constructor(options?: {
|
|
451
|
+
configPath?: string;
|
|
452
|
+
runId?: string;
|
|
453
|
+
stateRunId?: string;
|
|
454
|
+
storageRunId?: string;
|
|
455
|
+
});
|
|
419
456
|
async connect(): Promise<void>;
|
|
420
457
|
get storage(): StorageClient;
|
|
421
458
|
get state(): StateClient;
|
|
@@ -489,8 +526,12 @@ interface StateClient {
|
|
|
489
526
|
): Promise<CycleResult>;
|
|
490
527
|
getCycleHistory(limit?: number): Promise<CycleResult[]>;
|
|
491
528
|
|
|
529
|
+
// Events
|
|
530
|
+
subscribe(eventTypes?: string[]): NodeJS.EventEmitter;
|
|
531
|
+
|
|
492
532
|
// Session Management
|
|
493
533
|
setRunId(runId: string): void;
|
|
534
|
+
|
|
494
535
|
deleteRun(): Promise<boolean>;
|
|
495
536
|
|
|
496
537
|
// Skills
|
package/dist/Client.d.ts
CHANGED
package/dist/Client.js
CHANGED
|
@@ -77,9 +77,12 @@ class Client {
|
|
|
77
77
|
const httpPort = process.env.STORAGE_HTTP_PORT
|
|
78
78
|
? parseInt(process.env.STORAGE_HTTP_PORT, 10)
|
|
79
79
|
: 3000;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
const storageRunId = this.options.storageRunId ||
|
|
81
|
+
this.options.runId ||
|
|
82
|
+
process.env.STORAGE_RUN_ID;
|
|
83
|
+
// We assume STORAGE_INSTANCE_URL points to the gRPC port.
|
|
84
|
+
// Pass token to constructor initially (if it's a valid token, it works; if it's a password, we login).
|
|
85
|
+
this._storage = new RiceDBClient_1.RiceDBClient(host, "auto", port, httpPort, token, storageRunId);
|
|
83
86
|
await this._storage.connect();
|
|
84
87
|
if (token) {
|
|
85
88
|
try {
|
|
@@ -100,7 +103,10 @@ class Client {
|
|
|
100
103
|
if (this._config.state?.enabled) {
|
|
101
104
|
const address = process.env.STATE_INSTANCE_URL || "localhost:50051";
|
|
102
105
|
const token = process.env.STATE_AUTH_TOKEN;
|
|
103
|
-
const runId = this.options.
|
|
106
|
+
const runId = this.options.stateRunId ||
|
|
107
|
+
this.options.runId ||
|
|
108
|
+
process.env.STATE_RUN_ID ||
|
|
109
|
+
"default";
|
|
104
110
|
this._state = new state_1.StateClient(address, token, runId);
|
|
105
111
|
}
|
|
106
112
|
}
|
package/dist/state/index.d.ts
CHANGED
|
@@ -148,4 +148,13 @@ export declare class StateClient {
|
|
|
148
148
|
* @returns A promise that resolves to an array of cycle records.
|
|
149
149
|
*/
|
|
150
150
|
getCycleHistory(limit?: number): Promise<any[]>;
|
|
151
|
+
/**
|
|
152
|
+
* Subscribe to real-time events for the current run_id.
|
|
153
|
+
* Returns a gRPC ClientReadableStream that emits 'data', 'error', and 'end' events.
|
|
154
|
+
*
|
|
155
|
+
* usage:
|
|
156
|
+
* const stream = client.subscribe();
|
|
157
|
+
* stream.on('data', (event: any) => { ... });
|
|
158
|
+
*/
|
|
159
|
+
subscribe(eventTypes?: string[]): any;
|
|
151
160
|
}
|
package/dist/state/index.js
CHANGED
|
@@ -506,5 +506,25 @@ class StateClient {
|
|
|
506
506
|
});
|
|
507
507
|
});
|
|
508
508
|
}
|
|
509
|
+
// ==========================================================================
|
|
510
|
+
// Events (Pub/Sub)
|
|
511
|
+
// ==========================================================================
|
|
512
|
+
/**
|
|
513
|
+
* Subscribe to real-time events for the current run_id.
|
|
514
|
+
* Returns a gRPC ClientReadableStream that emits 'data', 'error', and 'end' events.
|
|
515
|
+
*
|
|
516
|
+
* usage:
|
|
517
|
+
* const stream = client.subscribe();
|
|
518
|
+
* stream.on('data', (event: any) => { ... });
|
|
519
|
+
*/
|
|
520
|
+
subscribe(eventTypes = []) {
|
|
521
|
+
const request = {
|
|
522
|
+
run_id: this.runId,
|
|
523
|
+
event_types: eventTypes,
|
|
524
|
+
};
|
|
525
|
+
// For streaming RPCs, we don't provide a callback.
|
|
526
|
+
// The call object itself is the stream.
|
|
527
|
+
return this.client.Subscribe(request, this.metadata);
|
|
528
|
+
}
|
|
509
529
|
}
|
|
510
530
|
exports.StateClient = StateClient;
|
|
@@ -41,6 +41,9 @@ service Cortex {
|
|
|
41
41
|
|
|
42
42
|
// Management
|
|
43
43
|
rpc DeleteRun(RunRequest) returns (Ack);
|
|
44
|
+
|
|
45
|
+
// Events
|
|
46
|
+
rpc Subscribe(SubscribeRequest) returns (stream Event);
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
message FocusRequest {
|
|
@@ -292,3 +295,17 @@ message CycleHistoryRequest {
|
|
|
292
295
|
message CycleHistoryResponse {
|
|
293
296
|
repeated CycleResponse cycles = 1;
|
|
294
297
|
}
|
|
298
|
+
|
|
299
|
+
message SubscribeRequest {
|
|
300
|
+
string run_id = 1;
|
|
301
|
+
repeated string event_types = 2; // Optional filter e.g. ["Focus", "Commit"]
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
message Event {
|
|
305
|
+
string id = 1;
|
|
306
|
+
string type = 2; // "Focus", "Commit", "VariableUpdate", "GoalUpdate"
|
|
307
|
+
string run_id = 3;
|
|
308
|
+
string agent_id = 4;
|
|
309
|
+
string payload = 5; // JSON string of the object involved
|
|
310
|
+
string created_at = 6;
|
|
311
|
+
}
|
|
@@ -41,11 +41,16 @@ export declare abstract class BaseRiceDBClient {
|
|
|
41
41
|
abstract deleteUser(username: string): Promise<boolean>;
|
|
42
42
|
abstract getUser(username: string): Promise<any>;
|
|
43
43
|
abstract listUsers(): Promise<any[]>;
|
|
44
|
-
abstract insert(nodeId: Long | number | string, text: string, metadata: any, userId?: Long | number | string, sessionId?: string, embedding?: number[]): Promise<InsertResult>;
|
|
44
|
+
abstract insert(nodeId: Long | number | string, text: string, metadata: any, userId?: Long | number | string, sessionId?: string, embedding?: number[], runId?: string): Promise<InsertResult>;
|
|
45
45
|
abstract search(query: string, userId: Long | number | string, k?: number, sessionId?: string, filter?: {
|
|
46
46
|
[key: string]: any;
|
|
47
|
-
}, queryEmbedding?: number[]): Promise<SearchResultItem[]>;
|
|
47
|
+
}, queryEmbedding?: number[], runId?: string): Promise<SearchResultItem[]>;
|
|
48
48
|
abstract delete(nodeId: Long | number | string, sessionId?: string): Promise<boolean>;
|
|
49
|
+
abstract deleteRun(runId?: string): Promise<{
|
|
50
|
+
success: boolean;
|
|
51
|
+
message: string;
|
|
52
|
+
count: Long;
|
|
53
|
+
}>;
|
|
49
54
|
abstract createSession(parentSessionId?: string): Promise<string>;
|
|
50
55
|
abstract snapshotSession(sessionId: string, path: string): Promise<boolean>;
|
|
51
56
|
abstract loadSession(path: string): Promise<string>;
|
|
@@ -15,11 +15,16 @@ export declare class GrpcClient extends BaseRiceDBClient {
|
|
|
15
15
|
deleteUser(username: string): Promise<boolean>;
|
|
16
16
|
getUser(username: string): Promise<any>;
|
|
17
17
|
listUsers(): Promise<any[]>;
|
|
18
|
-
insert(nodeId: Long | number | string, text: string, metadata: any, userId?: Long | number | string, sessionId?: string, embedding?: number[]): Promise<InsertResult>;
|
|
18
|
+
insert(nodeId: Long | number | string, text: string, metadata: any, userId?: Long | number | string, sessionId?: string, embedding?: number[], runId?: string): Promise<InsertResult>;
|
|
19
19
|
search(query: string, userId: Long | number | string, k?: number, sessionId?: string, filter?: {
|
|
20
20
|
[key: string]: any;
|
|
21
|
-
}, queryEmbedding?: number[]): Promise<SearchResultItem[]>;
|
|
21
|
+
}, queryEmbedding?: number[], runId?: string): Promise<SearchResultItem[]>;
|
|
22
22
|
delete(nodeId: Long | number | string, sessionId?: string): Promise<boolean>;
|
|
23
|
+
deleteRun(runId?: string): Promise<{
|
|
24
|
+
success: boolean;
|
|
25
|
+
message: string;
|
|
26
|
+
count: Long;
|
|
27
|
+
}>;
|
|
23
28
|
createSession(parentSessionId?: string): Promise<string>;
|
|
24
29
|
snapshotSession(sessionId: string, path: string): Promise<boolean>;
|
|
25
30
|
loadSession(path: string): Promise<string>;
|
|
@@ -95,7 +95,7 @@ class GrpcClient extends BaseClient_1.BaseRiceDBClient {
|
|
|
95
95
|
async listUsers() {
|
|
96
96
|
throw new Error("List users is not supported via gRPC transport. Use HTTP.");
|
|
97
97
|
}
|
|
98
|
-
async insert(nodeId, text, metadata, userId = 1, sessionId, embedding) {
|
|
98
|
+
async insert(nodeId, text, metadata, userId = 1, sessionId, embedding, runId) {
|
|
99
99
|
if (!this.client)
|
|
100
100
|
throw new Error("Not connected");
|
|
101
101
|
// Automatically store text in metadata so it can be retrieved
|
|
@@ -110,11 +110,12 @@ class GrpcClient extends BaseClient_1.BaseRiceDBClient {
|
|
|
110
110
|
userId: this.toLong(userId),
|
|
111
111
|
sessionId,
|
|
112
112
|
embedding: embedding || [],
|
|
113
|
+
runId,
|
|
113
114
|
};
|
|
114
115
|
const res = await this.promisify(this.client.insert, req);
|
|
115
116
|
return res;
|
|
116
117
|
}
|
|
117
|
-
async search(query, userId, k = 10, sessionId, filter, queryEmbedding) {
|
|
118
|
+
async search(query, userId, k = 10, sessionId, filter, queryEmbedding, runId) {
|
|
118
119
|
if (!this.client)
|
|
119
120
|
throw new Error("Not connected");
|
|
120
121
|
const req = {
|
|
@@ -124,6 +125,7 @@ class GrpcClient extends BaseClient_1.BaseRiceDBClient {
|
|
|
124
125
|
sessionId,
|
|
125
126
|
filter: filter ? JSON.stringify(filter) : "",
|
|
126
127
|
queryEmbedding: queryEmbedding || [],
|
|
128
|
+
runId,
|
|
127
129
|
};
|
|
128
130
|
const res = await this.promisify(this.client.search, req);
|
|
129
131
|
return res.results.map((r) => {
|
|
@@ -145,6 +147,21 @@ class GrpcClient extends BaseClient_1.BaseRiceDBClient {
|
|
|
145
147
|
});
|
|
146
148
|
return res.success;
|
|
147
149
|
}
|
|
150
|
+
async deleteRun(runId) {
|
|
151
|
+
if (!this.client)
|
|
152
|
+
throw new Error("Not connected");
|
|
153
|
+
if (!runId)
|
|
154
|
+
throw new Error("runId is required for deleteRun");
|
|
155
|
+
const res = await this.promisify(this.client.deleteRun, {
|
|
156
|
+
runId,
|
|
157
|
+
userId: this.toLong(1),
|
|
158
|
+
});
|
|
159
|
+
return {
|
|
160
|
+
success: res.success,
|
|
161
|
+
message: res.message,
|
|
162
|
+
count: res.count,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
148
165
|
async createSession(parentSessionId) {
|
|
149
166
|
if (!this.client)
|
|
150
167
|
throw new Error("Not connected");
|
|
@@ -316,6 +333,7 @@ class GrpcClient extends BaseClient_1.BaseRiceDBClient {
|
|
|
316
333
|
metadata,
|
|
317
334
|
userId: docUserId,
|
|
318
335
|
sessionId: undefined,
|
|
336
|
+
embedding: [],
|
|
319
337
|
});
|
|
320
338
|
}
|
|
321
339
|
stream.end();
|
|
@@ -15,11 +15,16 @@ export declare class HttpClient extends BaseRiceDBClient {
|
|
|
15
15
|
deleteUser(username: string): Promise<boolean>;
|
|
16
16
|
getUser(username: string): Promise<any>;
|
|
17
17
|
listUsers(): Promise<any[]>;
|
|
18
|
-
insert(nodeId: Long | number | string, text: string, metadata: any, userId?: Long | number | string, sessionId?: string, embedding?: number[]): Promise<InsertResult>;
|
|
18
|
+
insert(nodeId: Long | number | string, text: string, metadata: any, userId?: Long | number | string, sessionId?: string, embedding?: number[], runId?: string): Promise<InsertResult>;
|
|
19
19
|
search(query: string, userId: Long | number | string, k?: number, sessionId?: string, filter?: {
|
|
20
20
|
[key: string]: any;
|
|
21
|
-
}, queryEmbedding?: number[]): Promise<SearchResultItem[]>;
|
|
21
|
+
}, queryEmbedding?: number[], runId?: string): Promise<SearchResultItem[]>;
|
|
22
22
|
delete(nodeId: Long | number | string, sessionId?: string): Promise<boolean>;
|
|
23
|
+
deleteRun(runId?: string): Promise<{
|
|
24
|
+
success: boolean;
|
|
25
|
+
message: string;
|
|
26
|
+
count: Long;
|
|
27
|
+
}>;
|
|
23
28
|
createSession(parentSessionId?: string): Promise<string>;
|
|
24
29
|
snapshotSession(sessionId: string, path: string): Promise<boolean>;
|
|
25
30
|
loadSession(path: string): Promise<string>;
|
|
@@ -79,7 +79,7 @@ class HttpClient extends BaseClient_1.BaseRiceDBClient {
|
|
|
79
79
|
async listUsers() {
|
|
80
80
|
return this.request("GET", "/auth/users");
|
|
81
81
|
}
|
|
82
|
-
async insert(nodeId, text, metadata, userId = 1, sessionId, embedding) {
|
|
82
|
+
async insert(nodeId, text, metadata, userId = 1, sessionId, embedding, runId) {
|
|
83
83
|
// Automatically store text in metadata so it can be retrieved
|
|
84
84
|
const meta = { ...metadata };
|
|
85
85
|
if (text && !meta.stored_text) {
|
|
@@ -95,6 +95,8 @@ class HttpClient extends BaseClient_1.BaseRiceDBClient {
|
|
|
95
95
|
payload.session_id = sessionId;
|
|
96
96
|
if (embedding)
|
|
97
97
|
payload.embedding = embedding;
|
|
98
|
+
if (runId)
|
|
99
|
+
payload.run_id = runId;
|
|
98
100
|
const res = await this.request("POST", "/insert", payload);
|
|
99
101
|
if (!res.success) {
|
|
100
102
|
throw new Error(res.message || "Insert failed");
|
|
@@ -105,7 +107,7 @@ class HttpClient extends BaseClient_1.BaseRiceDBClient {
|
|
|
105
107
|
message: res.message,
|
|
106
108
|
};
|
|
107
109
|
}
|
|
108
|
-
async search(query, userId, k = 10, sessionId, filter, queryEmbedding) {
|
|
110
|
+
async search(query, userId, k = 10, sessionId, filter, queryEmbedding, runId) {
|
|
109
111
|
const payload = {
|
|
110
112
|
query,
|
|
111
113
|
user_id: this.toLong(userId).toNumber(),
|
|
@@ -117,6 +119,8 @@ class HttpClient extends BaseClient_1.BaseRiceDBClient {
|
|
|
117
119
|
payload.filter = filter;
|
|
118
120
|
if (queryEmbedding)
|
|
119
121
|
payload.query_embedding = queryEmbedding;
|
|
122
|
+
if (runId)
|
|
123
|
+
payload.run_id = runId;
|
|
120
124
|
const res = await this.request("POST", "/search", payload);
|
|
121
125
|
const results = Array.isArray(res) ? res : res.results || [];
|
|
122
126
|
return results.map((r) => ({
|
|
@@ -136,6 +140,16 @@ class HttpClient extends BaseClient_1.BaseRiceDBClient {
|
|
|
136
140
|
await this.request("DELETE", `/node/${this.toLong(nodeId).toString()}`, undefined, params);
|
|
137
141
|
return true;
|
|
138
142
|
}
|
|
143
|
+
async deleteRun(runId) {
|
|
144
|
+
if (!runId)
|
|
145
|
+
throw new Error("runId is required for deleteRun");
|
|
146
|
+
const res = await this.request("DELETE", `/run/${runId}`);
|
|
147
|
+
return {
|
|
148
|
+
success: res.success,
|
|
149
|
+
message: res.message,
|
|
150
|
+
count: long_1.default.fromValue(res.count),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
139
153
|
// Cortex
|
|
140
154
|
async createSession(parentSessionId) {
|
|
141
155
|
const payload = {};
|
|
@@ -11,6 +11,7 @@ export declare class RiceDBClient extends BaseRiceDBClient {
|
|
|
11
11
|
private _grpcPort;
|
|
12
12
|
private _httpPort;
|
|
13
13
|
private token;
|
|
14
|
+
private runId;
|
|
14
15
|
/**
|
|
15
16
|
* Creates a new RiceDB client instance.
|
|
16
17
|
* @param host - The hostname of the RiceDB server (default: "localhost").
|
|
@@ -18,8 +19,10 @@ export declare class RiceDBClient extends BaseRiceDBClient {
|
|
|
18
19
|
* @param grpcPort - The port for gRPC connections (default: 50051).
|
|
19
20
|
* @param httpPort - The port for HTTP connections (default: 3000).
|
|
20
21
|
* @param token - Optional authentication token.
|
|
22
|
+
* @param runId - Optional run identifier for storage data isolation.
|
|
21
23
|
*/
|
|
22
|
-
constructor(host?: string, transport?: "grpc" | "http" | "auto", grpcPort?: number, httpPort?: number, token?: string);
|
|
24
|
+
constructor(host?: string, transport?: "grpc" | "http" | "auto", grpcPort?: number, httpPort?: number, token?: string, runId?: string);
|
|
25
|
+
setRunId(runId: string): void;
|
|
23
26
|
/**
|
|
24
27
|
* Connects to the RiceDB server.
|
|
25
28
|
* If transport is "auto", tries gRPC first, then falls back to HTTP.
|
|
@@ -78,7 +81,7 @@ export declare class RiceDBClient extends BaseRiceDBClient {
|
|
|
78
81
|
* @param embedding - Optional pre-computed embedding vector.
|
|
79
82
|
* @returns Result of the insertion.
|
|
80
83
|
*/
|
|
81
|
-
insert(nodeId: Long | number | string, text: string, metadata: any, userId?: Long | number | string, sessionId?: string, embedding?: number[]): Promise<InsertResult>;
|
|
84
|
+
insert(nodeId: Long | number | string, text: string, metadata: any, userId?: Long | number | string, sessionId?: string, embedding?: number[], runId?: string): Promise<InsertResult>;
|
|
82
85
|
/**
|
|
83
86
|
* Searches for similar documents/nodes.
|
|
84
87
|
* @param query - The query text.
|
|
@@ -91,7 +94,7 @@ export declare class RiceDBClient extends BaseRiceDBClient {
|
|
|
91
94
|
*/
|
|
92
95
|
search(query: string, userId: Long | number | string, k?: number, sessionId?: string, filter?: {
|
|
93
96
|
[key: string]: any;
|
|
94
|
-
}, queryEmbedding?: number[]): Promise<SearchResultItem[]>;
|
|
97
|
+
}, queryEmbedding?: number[], runId?: string): Promise<SearchResultItem[]>;
|
|
95
98
|
/**
|
|
96
99
|
* Deletes a document/node.
|
|
97
100
|
* @param nodeId - The ID of the node to delete.
|
|
@@ -99,6 +102,11 @@ export declare class RiceDBClient extends BaseRiceDBClient {
|
|
|
99
102
|
* @returns True if successful.
|
|
100
103
|
*/
|
|
101
104
|
delete(nodeId: Long | number | string, sessionId?: string): Promise<boolean>;
|
|
105
|
+
deleteRun(runId?: string): Promise<{
|
|
106
|
+
success: boolean;
|
|
107
|
+
message: string;
|
|
108
|
+
count: Long;
|
|
109
|
+
}>;
|
|
102
110
|
/**
|
|
103
111
|
* Creates a new session.
|
|
104
112
|
* @param parentSessionId - Optional parent session ID to fork from.
|
|
@@ -20,14 +20,19 @@ class RiceDBClient extends BaseClient_1.BaseRiceDBClient {
|
|
|
20
20
|
* @param grpcPort - The port for gRPC connections (default: 50051).
|
|
21
21
|
* @param httpPort - The port for HTTP connections (default: 3000).
|
|
22
22
|
* @param token - Optional authentication token.
|
|
23
|
+
* @param runId - Optional run identifier for storage data isolation.
|
|
23
24
|
*/
|
|
24
|
-
constructor(host = "localhost", transport = "auto", grpcPort = 50051, httpPort = 3000, token) {
|
|
25
|
+
constructor(host = "localhost", transport = "auto", grpcPort = 50051, httpPort = 3000, token, runId) {
|
|
25
26
|
super(host, 0);
|
|
26
27
|
this.client = null;
|
|
27
28
|
this.transport = transport;
|
|
28
29
|
this._grpcPort = grpcPort;
|
|
29
30
|
this._httpPort = httpPort;
|
|
30
31
|
this.token = token;
|
|
32
|
+
this.runId = runId;
|
|
33
|
+
}
|
|
34
|
+
setRunId(runId) {
|
|
35
|
+
this.runId = runId;
|
|
31
36
|
}
|
|
32
37
|
/**
|
|
33
38
|
* Connects to the RiceDB server.
|
|
@@ -145,9 +150,9 @@ class RiceDBClient extends BaseClient_1.BaseRiceDBClient {
|
|
|
145
150
|
* @param embedding - Optional pre-computed embedding vector.
|
|
146
151
|
* @returns Result of the insertion.
|
|
147
152
|
*/
|
|
148
|
-
async insert(nodeId, text, metadata, userId = 1, sessionId, embedding) {
|
|
153
|
+
async insert(nodeId, text, metadata, userId = 1, sessionId, embedding, runId) {
|
|
149
154
|
this.checkConnected();
|
|
150
|
-
return this.client.insert(nodeId, text, metadata, userId, sessionId, embedding);
|
|
155
|
+
return this.client.insert(nodeId, text, metadata, userId, sessionId, embedding, runId || this.runId);
|
|
151
156
|
}
|
|
152
157
|
/**
|
|
153
158
|
* Searches for similar documents/nodes.
|
|
@@ -159,9 +164,9 @@ class RiceDBClient extends BaseClient_1.BaseRiceDBClient {
|
|
|
159
164
|
* @param queryEmbedding - Optional query embedding vector.
|
|
160
165
|
* @returns An array of search results.
|
|
161
166
|
*/
|
|
162
|
-
async search(query, userId, k = 10, sessionId, filter, queryEmbedding) {
|
|
167
|
+
async search(query, userId, k = 10, sessionId, filter, queryEmbedding, runId) {
|
|
163
168
|
this.checkConnected();
|
|
164
|
-
return this.client.search(query, userId, k, sessionId, filter, queryEmbedding);
|
|
169
|
+
return this.client.search(query, userId, k, sessionId, filter, queryEmbedding, runId || this.runId);
|
|
165
170
|
}
|
|
166
171
|
/**
|
|
167
172
|
* Deletes a document/node.
|
|
@@ -173,6 +178,14 @@ class RiceDBClient extends BaseClient_1.BaseRiceDBClient {
|
|
|
173
178
|
this.checkConnected();
|
|
174
179
|
return this.client.delete(nodeId, sessionId);
|
|
175
180
|
}
|
|
181
|
+
async deleteRun(runId) {
|
|
182
|
+
this.checkConnected();
|
|
183
|
+
const targetRunId = runId || this.runId;
|
|
184
|
+
if (!targetRunId) {
|
|
185
|
+
throw new Error("runId is required for deleteRun");
|
|
186
|
+
}
|
|
187
|
+
return this.client.deleteRun(targetRunId);
|
|
188
|
+
}
|
|
176
189
|
/**
|
|
177
190
|
* Creates a new session.
|
|
178
191
|
* @param parentSessionId - Optional parent session ID to fork from.
|
|
@@ -44,6 +44,7 @@ export interface Node {
|
|
|
44
44
|
* repeated float vector = 2; // Deprecated
|
|
45
45
|
*/
|
|
46
46
|
metadata: Buffer;
|
|
47
|
+
runId?: string | undefined;
|
|
47
48
|
}
|
|
48
49
|
/** Insert operations */
|
|
49
50
|
export interface InsertRequest {
|
|
@@ -54,6 +55,9 @@ export interface InsertRequest {
|
|
|
54
55
|
metadata: Buffer;
|
|
55
56
|
userId: Long;
|
|
56
57
|
sessionId?: string | undefined;
|
|
58
|
+
/** Pre-computed embedding (optional) */
|
|
59
|
+
embedding: number[];
|
|
60
|
+
runId?: string | undefined;
|
|
57
61
|
}
|
|
58
62
|
export interface InsertResponse {
|
|
59
63
|
success: boolean;
|
|
@@ -79,6 +83,15 @@ export interface DeleteNodeResponse {
|
|
|
79
83
|
success: boolean;
|
|
80
84
|
message: string;
|
|
81
85
|
}
|
|
86
|
+
export interface DeleteRunRequest {
|
|
87
|
+
runId: string;
|
|
88
|
+
userId: Long;
|
|
89
|
+
}
|
|
90
|
+
export interface DeleteRunResponse {
|
|
91
|
+
success: boolean;
|
|
92
|
+
message: string;
|
|
93
|
+
count: Long;
|
|
94
|
+
}
|
|
82
95
|
/** Search operations */
|
|
83
96
|
export interface SearchRequest {
|
|
84
97
|
/** Raw text query for HDC encoding */
|
|
@@ -88,6 +101,9 @@ export interface SearchRequest {
|
|
|
88
101
|
sessionId?: string | undefined;
|
|
89
102
|
/** JSON-encoded metadata filter */
|
|
90
103
|
filter: string;
|
|
104
|
+
/** Pre-computed embedding (optional) */
|
|
105
|
+
queryEmbedding: number[];
|
|
106
|
+
runId?: string | undefined;
|
|
91
107
|
}
|
|
92
108
|
export interface SearchResponse {
|
|
93
109
|
results: SearchResult[];
|
|
@@ -413,6 +429,22 @@ export declare const DeleteNodeResponse: {
|
|
|
413
429
|
create<I extends Exact<DeepPartial<DeleteNodeResponse>, I>>(base?: I): DeleteNodeResponse;
|
|
414
430
|
fromPartial<I extends Exact<DeepPartial<DeleteNodeResponse>, I>>(object: I): DeleteNodeResponse;
|
|
415
431
|
};
|
|
432
|
+
export declare const DeleteRunRequest: {
|
|
433
|
+
encode(message: DeleteRunRequest, writer?: _m0.Writer): _m0.Writer;
|
|
434
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): DeleteRunRequest;
|
|
435
|
+
fromJSON(object: any): DeleteRunRequest;
|
|
436
|
+
toJSON(message: DeleteRunRequest): unknown;
|
|
437
|
+
create<I extends Exact<DeepPartial<DeleteRunRequest>, I>>(base?: I): DeleteRunRequest;
|
|
438
|
+
fromPartial<I extends Exact<DeepPartial<DeleteRunRequest>, I>>(object: I): DeleteRunRequest;
|
|
439
|
+
};
|
|
440
|
+
export declare const DeleteRunResponse: {
|
|
441
|
+
encode(message: DeleteRunResponse, writer?: _m0.Writer): _m0.Writer;
|
|
442
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): DeleteRunResponse;
|
|
443
|
+
fromJSON(object: any): DeleteRunResponse;
|
|
444
|
+
toJSON(message: DeleteRunResponse): unknown;
|
|
445
|
+
create<I extends Exact<DeepPartial<DeleteRunResponse>, I>>(base?: I): DeleteRunResponse;
|
|
446
|
+
fromPartial<I extends Exact<DeepPartial<DeleteRunResponse>, I>>(object: I): DeleteRunResponse;
|
|
447
|
+
};
|
|
416
448
|
export declare const SearchRequest: {
|
|
417
449
|
encode(message: SearchRequest, writer?: _m0.Writer): _m0.Writer;
|
|
418
450
|
decode(input: _m0.Reader | Uint8Array, length?: number): SearchRequest;
|
|
@@ -830,6 +862,16 @@ export declare const RiceDBService: {
|
|
|
830
862
|
readonly responseSerialize: (value: DeleteNodeResponse) => Buffer<ArrayBuffer>;
|
|
831
863
|
readonly responseDeserialize: (value: Buffer) => DeleteNodeResponse;
|
|
832
864
|
};
|
|
865
|
+
/** Delete all documents in a run */
|
|
866
|
+
readonly deleteRun: {
|
|
867
|
+
readonly path: "/ricedb.RiceDB/DeleteRun";
|
|
868
|
+
readonly requestStream: false;
|
|
869
|
+
readonly responseStream: false;
|
|
870
|
+
readonly requestSerialize: (value: DeleteRunRequest) => Buffer<ArrayBuffer>;
|
|
871
|
+
readonly requestDeserialize: (value: Buffer) => DeleteRunRequest;
|
|
872
|
+
readonly responseSerialize: (value: DeleteRunResponse) => Buffer<ArrayBuffer>;
|
|
873
|
+
readonly responseDeserialize: (value: Buffer) => DeleteRunResponse;
|
|
874
|
+
};
|
|
833
875
|
/** Search for similar documents */
|
|
834
876
|
readonly search: {
|
|
835
877
|
readonly path: "/ricedb.RiceDB/Search";
|
|
@@ -1036,6 +1078,8 @@ export interface RiceDBServer extends UntypedServiceImplementation {
|
|
|
1036
1078
|
getNode: handleUnaryCall<GetNodeRequest, GetNodeResponse>;
|
|
1037
1079
|
/** Delete a document */
|
|
1038
1080
|
deleteNode: handleUnaryCall<DeleteNodeRequest, DeleteNodeResponse>;
|
|
1081
|
+
/** Delete all documents in a run */
|
|
1082
|
+
deleteRun: handleUnaryCall<DeleteRunRequest, DeleteRunResponse>;
|
|
1039
1083
|
/** Search for similar documents */
|
|
1040
1084
|
search: handleUnaryCall<SearchRequest, SearchResponse>;
|
|
1041
1085
|
/** Batch insert (streaming) */
|
|
@@ -1096,6 +1140,10 @@ export interface RiceDBClient extends Client {
|
|
|
1096
1140
|
deleteNode(request: DeleteNodeRequest, callback: (error: ServiceError | null, response: DeleteNodeResponse) => void): ClientUnaryCall;
|
|
1097
1141
|
deleteNode(request: DeleteNodeRequest, metadata: Metadata, callback: (error: ServiceError | null, response: DeleteNodeResponse) => void): ClientUnaryCall;
|
|
1098
1142
|
deleteNode(request: DeleteNodeRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: DeleteNodeResponse) => void): ClientUnaryCall;
|
|
1143
|
+
/** Delete all documents in a run */
|
|
1144
|
+
deleteRun(request: DeleteRunRequest, callback: (error: ServiceError | null, response: DeleteRunResponse) => void): ClientUnaryCall;
|
|
1145
|
+
deleteRun(request: DeleteRunRequest, metadata: Metadata, callback: (error: ServiceError | null, response: DeleteRunResponse) => void): ClientUnaryCall;
|
|
1146
|
+
deleteRun(request: DeleteRunRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: DeleteRunResponse) => void): ClientUnaryCall;
|
|
1099
1147
|
/** Search for similar documents */
|
|
1100
1148
|
search(request: SearchRequest, callback: (error: ServiceError | null, response: SearchResponse) => void): ClientUnaryCall;
|
|
1101
1149
|
search(request: SearchRequest, metadata: Metadata, callback: (error: ServiceError | null, response: SearchResponse) => void): ClientUnaryCall;
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
4
|
// protoc-gen-ts_proto v1.181.2
|
|
5
|
-
// protoc v6.33.
|
|
5
|
+
// protoc v6.33.4
|
|
6
6
|
// source: ricedb.proto
|
|
7
7
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
8
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.
|
|
12
|
-
exports.RiceDBClient = exports.RiceDBService = exports.DropSessionResponse = exports.DropSessionRequest = exports.CommitSessionResponse = exports.CommitSessionRequest = exports.LoadSessionResponse = exports.LoadSessionRequest = exports.SnapshotSessionResponse = exports.SnapshotSessionRequest = exports.CreateSessionResponse = exports.CreateSessionRequest = void 0;
|
|
11
|
+
exports.ClearMemoryResponse = exports.ClearMemoryRequest = exports.GetMemoryResponse = exports.GetMemoryRequest_FilterEntry = exports.GetMemoryRequest = exports.AddMemoryResponse = exports.AddMemoryRequest_MetadataEntry = exports.AddMemoryRequest = exports.MemoryEntry_MetadataEntry = exports.MemoryEntry = exports.ReadMemoryResponse = exports.ReadMemoryRequest = exports.WriteMemoryResponse = exports.WriteMemoryRequest = exports.BitVector = exports.PubSubEvent = exports.SubscribeRequest = exports.TraverseGraphResponse = exports.TraverseGraphRequest = exports.GetNeighborsResponse = exports.GetNeighborsRequest = exports.AddEdgeResponse = exports.AddEdgeRequest = exports.RevokePermissionResponse = exports.RevokePermissionRequest = exports.GrantPermissionResponse = exports.GrantPermissionRequest = exports.Permissions = exports.SearchResult = exports.SearchResponse = exports.SearchRequest = exports.DeleteRunResponse = exports.DeleteRunRequest = exports.DeleteNodeResponse = exports.DeleteNodeRequest = exports.GetNodeResponse = exports.GetNodeRequest = exports.BatchInsertResponse = exports.InsertResponse = exports.InsertRequest = exports.Node = exports.HealthResponse = exports.HealthRequest = exports.DeleteUserResponse = exports.DeleteUserRequest = exports.CreateUserResponse = exports.CreateUserRequest = exports.LoginResponse = exports.LoginRequest = exports.protobufPackage = void 0;
|
|
12
|
+
exports.RiceDBClient = exports.RiceDBService = exports.DropSessionResponse = exports.DropSessionRequest = exports.CommitSessionResponse = exports.CommitSessionRequest = exports.LoadSessionResponse = exports.LoadSessionRequest = exports.SnapshotSessionResponse = exports.SnapshotSessionRequest = exports.CreateSessionResponse = exports.CreateSessionRequest = exports.MemoryEvent = exports.WatchMemoryRequest = void 0;
|
|
13
13
|
/* eslint-disable */
|
|
14
14
|
const grpc_js_1 = require("@grpc/grpc-js");
|
|
15
15
|
const long_1 = __importDefault(require("long"));
|
|
@@ -531,7 +531,7 @@ exports.HealthResponse = {
|
|
|
531
531
|
},
|
|
532
532
|
};
|
|
533
533
|
function createBaseNode() {
|
|
534
|
-
return { id: long_1.default.UZERO, metadata: Buffer.alloc(0) };
|
|
534
|
+
return { id: long_1.default.UZERO, metadata: Buffer.alloc(0), runId: undefined };
|
|
535
535
|
}
|
|
536
536
|
exports.Node = {
|
|
537
537
|
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
@@ -541,6 +541,9 @@ exports.Node = {
|
|
|
541
541
|
if (message.metadata.length !== 0) {
|
|
542
542
|
writer.uint32(26).bytes(message.metadata);
|
|
543
543
|
}
|
|
544
|
+
if (message.runId !== undefined) {
|
|
545
|
+
writer.uint32(34).string(message.runId);
|
|
546
|
+
}
|
|
544
547
|
return writer;
|
|
545
548
|
},
|
|
546
549
|
decode(input, length) {
|
|
@@ -562,6 +565,12 @@ exports.Node = {
|
|
|
562
565
|
}
|
|
563
566
|
message.metadata = reader.bytes();
|
|
564
567
|
continue;
|
|
568
|
+
case 4:
|
|
569
|
+
if (tag !== 34) {
|
|
570
|
+
break;
|
|
571
|
+
}
|
|
572
|
+
message.runId = reader.string();
|
|
573
|
+
continue;
|
|
565
574
|
}
|
|
566
575
|
if ((tag & 7) === 4 || tag === 0) {
|
|
567
576
|
break;
|
|
@@ -574,6 +583,7 @@ exports.Node = {
|
|
|
574
583
|
return {
|
|
575
584
|
id: isSet(object.id) ? long_1.default.fromValue(object.id) : long_1.default.UZERO,
|
|
576
585
|
metadata: isSet(object.metadata) ? Buffer.from(bytesFromBase64(object.metadata)) : Buffer.alloc(0),
|
|
586
|
+
runId: isSet(object.runId) ? globalThis.String(object.runId) : undefined,
|
|
577
587
|
};
|
|
578
588
|
},
|
|
579
589
|
toJSON(message) {
|
|
@@ -584,6 +594,9 @@ exports.Node = {
|
|
|
584
594
|
if (message.metadata.length !== 0) {
|
|
585
595
|
obj.metadata = base64FromBytes(message.metadata);
|
|
586
596
|
}
|
|
597
|
+
if (message.runId !== undefined) {
|
|
598
|
+
obj.runId = message.runId;
|
|
599
|
+
}
|
|
587
600
|
return obj;
|
|
588
601
|
},
|
|
589
602
|
create(base) {
|
|
@@ -593,11 +606,20 @@ exports.Node = {
|
|
|
593
606
|
const message = createBaseNode();
|
|
594
607
|
message.id = (object.id !== undefined && object.id !== null) ? long_1.default.fromValue(object.id) : long_1.default.UZERO;
|
|
595
608
|
message.metadata = object.metadata ?? Buffer.alloc(0);
|
|
609
|
+
message.runId = object.runId ?? undefined;
|
|
596
610
|
return message;
|
|
597
611
|
},
|
|
598
612
|
};
|
|
599
613
|
function createBaseInsertRequest() {
|
|
600
|
-
return {
|
|
614
|
+
return {
|
|
615
|
+
id: long_1.default.UZERO,
|
|
616
|
+
text: "",
|
|
617
|
+
metadata: Buffer.alloc(0),
|
|
618
|
+
userId: long_1.default.UZERO,
|
|
619
|
+
sessionId: undefined,
|
|
620
|
+
embedding: [],
|
|
621
|
+
runId: undefined,
|
|
622
|
+
};
|
|
601
623
|
}
|
|
602
624
|
exports.InsertRequest = {
|
|
603
625
|
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
@@ -616,6 +638,14 @@ exports.InsertRequest = {
|
|
|
616
638
|
if (message.sessionId !== undefined) {
|
|
617
639
|
writer.uint32(42).string(message.sessionId);
|
|
618
640
|
}
|
|
641
|
+
writer.uint32(50).fork();
|
|
642
|
+
for (const v of message.embedding) {
|
|
643
|
+
writer.float(v);
|
|
644
|
+
}
|
|
645
|
+
writer.ldelim();
|
|
646
|
+
if (message.runId !== undefined) {
|
|
647
|
+
writer.uint32(58).string(message.runId);
|
|
648
|
+
}
|
|
619
649
|
return writer;
|
|
620
650
|
},
|
|
621
651
|
decode(input, length) {
|
|
@@ -655,6 +685,25 @@ exports.InsertRequest = {
|
|
|
655
685
|
}
|
|
656
686
|
message.sessionId = reader.string();
|
|
657
687
|
continue;
|
|
688
|
+
case 6:
|
|
689
|
+
if (tag === 53) {
|
|
690
|
+
message.embedding.push(reader.float());
|
|
691
|
+
continue;
|
|
692
|
+
}
|
|
693
|
+
if (tag === 50) {
|
|
694
|
+
const end2 = reader.uint32() + reader.pos;
|
|
695
|
+
while (reader.pos < end2) {
|
|
696
|
+
message.embedding.push(reader.float());
|
|
697
|
+
}
|
|
698
|
+
continue;
|
|
699
|
+
}
|
|
700
|
+
break;
|
|
701
|
+
case 7:
|
|
702
|
+
if (tag !== 58) {
|
|
703
|
+
break;
|
|
704
|
+
}
|
|
705
|
+
message.runId = reader.string();
|
|
706
|
+
continue;
|
|
658
707
|
}
|
|
659
708
|
if ((tag & 7) === 4 || tag === 0) {
|
|
660
709
|
break;
|
|
@@ -670,6 +719,10 @@ exports.InsertRequest = {
|
|
|
670
719
|
metadata: isSet(object.metadata) ? Buffer.from(bytesFromBase64(object.metadata)) : Buffer.alloc(0),
|
|
671
720
|
userId: isSet(object.userId) ? long_1.default.fromValue(object.userId) : long_1.default.UZERO,
|
|
672
721
|
sessionId: isSet(object.sessionId) ? globalThis.String(object.sessionId) : undefined,
|
|
722
|
+
embedding: globalThis.Array.isArray(object?.embedding)
|
|
723
|
+
? object.embedding.map((e) => globalThis.Number(e))
|
|
724
|
+
: [],
|
|
725
|
+
runId: isSet(object.runId) ? globalThis.String(object.runId) : undefined,
|
|
673
726
|
};
|
|
674
727
|
},
|
|
675
728
|
toJSON(message) {
|
|
@@ -689,6 +742,12 @@ exports.InsertRequest = {
|
|
|
689
742
|
if (message.sessionId !== undefined) {
|
|
690
743
|
obj.sessionId = message.sessionId;
|
|
691
744
|
}
|
|
745
|
+
if (message.embedding?.length) {
|
|
746
|
+
obj.embedding = message.embedding;
|
|
747
|
+
}
|
|
748
|
+
if (message.runId !== undefined) {
|
|
749
|
+
obj.runId = message.runId;
|
|
750
|
+
}
|
|
692
751
|
return obj;
|
|
693
752
|
},
|
|
694
753
|
create(base) {
|
|
@@ -703,6 +762,8 @@ exports.InsertRequest = {
|
|
|
703
762
|
? long_1.default.fromValue(object.userId)
|
|
704
763
|
: long_1.default.UZERO;
|
|
705
764
|
message.sessionId = object.sessionId ?? undefined;
|
|
765
|
+
message.embedding = object.embedding?.map((e) => e) || [];
|
|
766
|
+
message.runId = object.runId ?? undefined;
|
|
706
767
|
return message;
|
|
707
768
|
},
|
|
708
769
|
};
|
|
@@ -1099,8 +1160,164 @@ exports.DeleteNodeResponse = {
|
|
|
1099
1160
|
return message;
|
|
1100
1161
|
},
|
|
1101
1162
|
};
|
|
1163
|
+
function createBaseDeleteRunRequest() {
|
|
1164
|
+
return { runId: "", userId: long_1.default.UZERO };
|
|
1165
|
+
}
|
|
1166
|
+
exports.DeleteRunRequest = {
|
|
1167
|
+
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
1168
|
+
if (message.runId !== "") {
|
|
1169
|
+
writer.uint32(10).string(message.runId);
|
|
1170
|
+
}
|
|
1171
|
+
if (!message.userId.equals(long_1.default.UZERO)) {
|
|
1172
|
+
writer.uint32(16).uint64(message.userId);
|
|
1173
|
+
}
|
|
1174
|
+
return writer;
|
|
1175
|
+
},
|
|
1176
|
+
decode(input, length) {
|
|
1177
|
+
const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input);
|
|
1178
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
1179
|
+
const message = createBaseDeleteRunRequest();
|
|
1180
|
+
while (reader.pos < end) {
|
|
1181
|
+
const tag = reader.uint32();
|
|
1182
|
+
switch (tag >>> 3) {
|
|
1183
|
+
case 1:
|
|
1184
|
+
if (tag !== 10) {
|
|
1185
|
+
break;
|
|
1186
|
+
}
|
|
1187
|
+
message.runId = reader.string();
|
|
1188
|
+
continue;
|
|
1189
|
+
case 2:
|
|
1190
|
+
if (tag !== 16) {
|
|
1191
|
+
break;
|
|
1192
|
+
}
|
|
1193
|
+
message.userId = reader.uint64();
|
|
1194
|
+
continue;
|
|
1195
|
+
}
|
|
1196
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
1197
|
+
break;
|
|
1198
|
+
}
|
|
1199
|
+
reader.skipType(tag & 7);
|
|
1200
|
+
}
|
|
1201
|
+
return message;
|
|
1202
|
+
},
|
|
1203
|
+
fromJSON(object) {
|
|
1204
|
+
return {
|
|
1205
|
+
runId: isSet(object.runId) ? globalThis.String(object.runId) : "",
|
|
1206
|
+
userId: isSet(object.userId) ? long_1.default.fromValue(object.userId) : long_1.default.UZERO,
|
|
1207
|
+
};
|
|
1208
|
+
},
|
|
1209
|
+
toJSON(message) {
|
|
1210
|
+
const obj = {};
|
|
1211
|
+
if (message.runId !== "") {
|
|
1212
|
+
obj.runId = message.runId;
|
|
1213
|
+
}
|
|
1214
|
+
if (!message.userId.equals(long_1.default.UZERO)) {
|
|
1215
|
+
obj.userId = (message.userId || long_1.default.UZERO).toString();
|
|
1216
|
+
}
|
|
1217
|
+
return obj;
|
|
1218
|
+
},
|
|
1219
|
+
create(base) {
|
|
1220
|
+
return exports.DeleteRunRequest.fromPartial(base ?? {});
|
|
1221
|
+
},
|
|
1222
|
+
fromPartial(object) {
|
|
1223
|
+
const message = createBaseDeleteRunRequest();
|
|
1224
|
+
message.runId = object.runId ?? "";
|
|
1225
|
+
message.userId = (object.userId !== undefined && object.userId !== null)
|
|
1226
|
+
? long_1.default.fromValue(object.userId)
|
|
1227
|
+
: long_1.default.UZERO;
|
|
1228
|
+
return message;
|
|
1229
|
+
},
|
|
1230
|
+
};
|
|
1231
|
+
function createBaseDeleteRunResponse() {
|
|
1232
|
+
return { success: false, message: "", count: long_1.default.UZERO };
|
|
1233
|
+
}
|
|
1234
|
+
exports.DeleteRunResponse = {
|
|
1235
|
+
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
1236
|
+
if (message.success !== false) {
|
|
1237
|
+
writer.uint32(8).bool(message.success);
|
|
1238
|
+
}
|
|
1239
|
+
if (message.message !== "") {
|
|
1240
|
+
writer.uint32(18).string(message.message);
|
|
1241
|
+
}
|
|
1242
|
+
if (!message.count.equals(long_1.default.UZERO)) {
|
|
1243
|
+
writer.uint32(24).uint64(message.count);
|
|
1244
|
+
}
|
|
1245
|
+
return writer;
|
|
1246
|
+
},
|
|
1247
|
+
decode(input, length) {
|
|
1248
|
+
const reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input);
|
|
1249
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
1250
|
+
const message = createBaseDeleteRunResponse();
|
|
1251
|
+
while (reader.pos < end) {
|
|
1252
|
+
const tag = reader.uint32();
|
|
1253
|
+
switch (tag >>> 3) {
|
|
1254
|
+
case 1:
|
|
1255
|
+
if (tag !== 8) {
|
|
1256
|
+
break;
|
|
1257
|
+
}
|
|
1258
|
+
message.success = reader.bool();
|
|
1259
|
+
continue;
|
|
1260
|
+
case 2:
|
|
1261
|
+
if (tag !== 18) {
|
|
1262
|
+
break;
|
|
1263
|
+
}
|
|
1264
|
+
message.message = reader.string();
|
|
1265
|
+
continue;
|
|
1266
|
+
case 3:
|
|
1267
|
+
if (tag !== 24) {
|
|
1268
|
+
break;
|
|
1269
|
+
}
|
|
1270
|
+
message.count = reader.uint64();
|
|
1271
|
+
continue;
|
|
1272
|
+
}
|
|
1273
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
1274
|
+
break;
|
|
1275
|
+
}
|
|
1276
|
+
reader.skipType(tag & 7);
|
|
1277
|
+
}
|
|
1278
|
+
return message;
|
|
1279
|
+
},
|
|
1280
|
+
fromJSON(object) {
|
|
1281
|
+
return {
|
|
1282
|
+
success: isSet(object.success) ? globalThis.Boolean(object.success) : false,
|
|
1283
|
+
message: isSet(object.message) ? globalThis.String(object.message) : "",
|
|
1284
|
+
count: isSet(object.count) ? long_1.default.fromValue(object.count) : long_1.default.UZERO,
|
|
1285
|
+
};
|
|
1286
|
+
},
|
|
1287
|
+
toJSON(message) {
|
|
1288
|
+
const obj = {};
|
|
1289
|
+
if (message.success !== false) {
|
|
1290
|
+
obj.success = message.success;
|
|
1291
|
+
}
|
|
1292
|
+
if (message.message !== "") {
|
|
1293
|
+
obj.message = message.message;
|
|
1294
|
+
}
|
|
1295
|
+
if (!message.count.equals(long_1.default.UZERO)) {
|
|
1296
|
+
obj.count = (message.count || long_1.default.UZERO).toString();
|
|
1297
|
+
}
|
|
1298
|
+
return obj;
|
|
1299
|
+
},
|
|
1300
|
+
create(base) {
|
|
1301
|
+
return exports.DeleteRunResponse.fromPartial(base ?? {});
|
|
1302
|
+
},
|
|
1303
|
+
fromPartial(object) {
|
|
1304
|
+
const message = createBaseDeleteRunResponse();
|
|
1305
|
+
message.success = object.success ?? false;
|
|
1306
|
+
message.message = object.message ?? "";
|
|
1307
|
+
message.count = (object.count !== undefined && object.count !== null) ? long_1.default.fromValue(object.count) : long_1.default.UZERO;
|
|
1308
|
+
return message;
|
|
1309
|
+
},
|
|
1310
|
+
};
|
|
1102
1311
|
function createBaseSearchRequest() {
|
|
1103
|
-
return {
|
|
1312
|
+
return {
|
|
1313
|
+
queryText: "",
|
|
1314
|
+
userId: long_1.default.UZERO,
|
|
1315
|
+
k: 0,
|
|
1316
|
+
sessionId: undefined,
|
|
1317
|
+
filter: "",
|
|
1318
|
+
queryEmbedding: [],
|
|
1319
|
+
runId: undefined,
|
|
1320
|
+
};
|
|
1104
1321
|
}
|
|
1105
1322
|
exports.SearchRequest = {
|
|
1106
1323
|
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
@@ -1119,6 +1336,14 @@ exports.SearchRequest = {
|
|
|
1119
1336
|
if (message.filter !== "") {
|
|
1120
1337
|
writer.uint32(42).string(message.filter);
|
|
1121
1338
|
}
|
|
1339
|
+
writer.uint32(50).fork();
|
|
1340
|
+
for (const v of message.queryEmbedding) {
|
|
1341
|
+
writer.float(v);
|
|
1342
|
+
}
|
|
1343
|
+
writer.ldelim();
|
|
1344
|
+
if (message.runId !== undefined) {
|
|
1345
|
+
writer.uint32(58).string(message.runId);
|
|
1346
|
+
}
|
|
1122
1347
|
return writer;
|
|
1123
1348
|
},
|
|
1124
1349
|
decode(input, length) {
|
|
@@ -1158,6 +1383,25 @@ exports.SearchRequest = {
|
|
|
1158
1383
|
}
|
|
1159
1384
|
message.filter = reader.string();
|
|
1160
1385
|
continue;
|
|
1386
|
+
case 6:
|
|
1387
|
+
if (tag === 53) {
|
|
1388
|
+
message.queryEmbedding.push(reader.float());
|
|
1389
|
+
continue;
|
|
1390
|
+
}
|
|
1391
|
+
if (tag === 50) {
|
|
1392
|
+
const end2 = reader.uint32() + reader.pos;
|
|
1393
|
+
while (reader.pos < end2) {
|
|
1394
|
+
message.queryEmbedding.push(reader.float());
|
|
1395
|
+
}
|
|
1396
|
+
continue;
|
|
1397
|
+
}
|
|
1398
|
+
break;
|
|
1399
|
+
case 7:
|
|
1400
|
+
if (tag !== 58) {
|
|
1401
|
+
break;
|
|
1402
|
+
}
|
|
1403
|
+
message.runId = reader.string();
|
|
1404
|
+
continue;
|
|
1161
1405
|
}
|
|
1162
1406
|
if ((tag & 7) === 4 || tag === 0) {
|
|
1163
1407
|
break;
|
|
@@ -1173,6 +1417,10 @@ exports.SearchRequest = {
|
|
|
1173
1417
|
k: isSet(object.k) ? globalThis.Number(object.k) : 0,
|
|
1174
1418
|
sessionId: isSet(object.sessionId) ? globalThis.String(object.sessionId) : undefined,
|
|
1175
1419
|
filter: isSet(object.filter) ? globalThis.String(object.filter) : "",
|
|
1420
|
+
queryEmbedding: globalThis.Array.isArray(object?.queryEmbedding)
|
|
1421
|
+
? object.queryEmbedding.map((e) => globalThis.Number(e))
|
|
1422
|
+
: [],
|
|
1423
|
+
runId: isSet(object.runId) ? globalThis.String(object.runId) : undefined,
|
|
1176
1424
|
};
|
|
1177
1425
|
},
|
|
1178
1426
|
toJSON(message) {
|
|
@@ -1192,6 +1440,12 @@ exports.SearchRequest = {
|
|
|
1192
1440
|
if (message.filter !== "") {
|
|
1193
1441
|
obj.filter = message.filter;
|
|
1194
1442
|
}
|
|
1443
|
+
if (message.queryEmbedding?.length) {
|
|
1444
|
+
obj.queryEmbedding = message.queryEmbedding;
|
|
1445
|
+
}
|
|
1446
|
+
if (message.runId !== undefined) {
|
|
1447
|
+
obj.runId = message.runId;
|
|
1448
|
+
}
|
|
1195
1449
|
return obj;
|
|
1196
1450
|
},
|
|
1197
1451
|
create(base) {
|
|
@@ -1206,6 +1460,8 @@ exports.SearchRequest = {
|
|
|
1206
1460
|
message.k = object.k ?? 0;
|
|
1207
1461
|
message.sessionId = object.sessionId ?? undefined;
|
|
1208
1462
|
message.filter = object.filter ?? "";
|
|
1463
|
+
message.queryEmbedding = object.queryEmbedding?.map((e) => e) || [];
|
|
1464
|
+
message.runId = object.runId ?? undefined;
|
|
1209
1465
|
return message;
|
|
1210
1466
|
},
|
|
1211
1467
|
};
|
|
@@ -4259,6 +4515,16 @@ exports.RiceDBService = {
|
|
|
4259
4515
|
responseSerialize: (value) => Buffer.from(exports.DeleteNodeResponse.encode(value).finish()),
|
|
4260
4516
|
responseDeserialize: (value) => exports.DeleteNodeResponse.decode(value),
|
|
4261
4517
|
},
|
|
4518
|
+
/** Delete all documents in a run */
|
|
4519
|
+
deleteRun: {
|
|
4520
|
+
path: "/ricedb.RiceDB/DeleteRun",
|
|
4521
|
+
requestStream: false,
|
|
4522
|
+
responseStream: false,
|
|
4523
|
+
requestSerialize: (value) => Buffer.from(exports.DeleteRunRequest.encode(value).finish()),
|
|
4524
|
+
requestDeserialize: (value) => exports.DeleteRunRequest.decode(value),
|
|
4525
|
+
responseSerialize: (value) => Buffer.from(exports.DeleteRunResponse.encode(value).finish()),
|
|
4526
|
+
responseDeserialize: (value) => exports.DeleteRunResponse.decode(value),
|
|
4527
|
+
},
|
|
4262
4528
|
/** Search for similar documents */
|
|
4263
4529
|
search: {
|
|
4264
4530
|
path: "/ricedb.RiceDB/Search",
|