rice-node-sdk 1.0.2 → 1.0.3

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.
@@ -15,6 +15,7 @@ export interface SearchResultItem {
15
15
  id: Long;
16
16
  similarity: number;
17
17
  metadata: any;
18
+ data?: string;
18
19
  }
19
20
  export interface MemoryEntry {
20
21
  id: string;
@@ -98,10 +98,15 @@ class GrpcClient extends BaseClient_1.BaseRiceDBClient {
98
98
  async insert(nodeId, text, metadata, userId = 1, sessionId, embedding) {
99
99
  if (!this.client)
100
100
  throw new Error("Not connected");
101
+ // Automatically store text in metadata so it can be retrieved
102
+ const meta = { ...metadata };
103
+ if (text && !meta.stored_text) {
104
+ meta.stored_text = text;
105
+ }
101
106
  const req = {
102
107
  id: this.toLong(nodeId),
103
108
  text,
104
- metadata: Buffer.from(JSON.stringify(metadata)),
109
+ metadata: Buffer.from(JSON.stringify(meta)),
105
110
  userId: this.toLong(userId),
106
111
  sessionId,
107
112
  embedding: embedding || [],
@@ -121,11 +126,15 @@ class GrpcClient extends BaseClient_1.BaseRiceDBClient {
121
126
  queryEmbedding: queryEmbedding || [],
122
127
  };
123
128
  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
+ return res.results.map((r) => {
130
+ const meta = JSON.parse(r.metadata.toString());
131
+ return {
132
+ id: r.id,
133
+ similarity: r.similarity,
134
+ metadata: meta,
135
+ data: meta.stored_text,
136
+ };
137
+ });
129
138
  }
130
139
  async delete(nodeId, sessionId) {
131
140
  if (!this.client)
@@ -40,7 +40,8 @@ class HttpClient extends BaseClient_1.BaseRiceDBClient {
40
40
  }
41
41
  setAuthHeader() {
42
42
  if (this.token) {
43
- this.client.defaults.headers.common["Authorization"] = `Bearer ${this.token}`;
43
+ this.client.defaults.headers.common["Authorization"] =
44
+ `Bearer ${this.token}`;
44
45
  }
45
46
  }
46
47
  async request(method, url, data, params) {
@@ -79,10 +80,15 @@ class HttpClient extends BaseClient_1.BaseRiceDBClient {
79
80
  return this.request("GET", "/auth/users");
80
81
  }
81
82
  async insert(nodeId, text, metadata, userId = 1, sessionId, embedding) {
83
+ // Automatically store text in metadata so it can be retrieved
84
+ const meta = { ...metadata };
85
+ if (text && !meta.stored_text) {
86
+ meta.stored_text = text;
87
+ }
82
88
  const payload = {
83
89
  id: this.toLong(nodeId).toNumber(),
84
90
  text,
85
- metadata,
91
+ metadata: meta,
86
92
  user_id: this.toLong(userId).toNumber(),
87
93
  };
88
94
  if (sessionId)
@@ -117,12 +123,16 @@ class HttpClient extends BaseClient_1.BaseRiceDBClient {
117
123
  id: long_1.default.fromValue(r.id),
118
124
  similarity: r.similarity,
119
125
  metadata: r.metadata,
126
+ data: r.metadata ? r.metadata.stored_text : undefined,
120
127
  }));
121
128
  }
122
129
  async delete(nodeId, sessionId) {
123
- const params = {};
130
+ const params = {
131
+ node_id: this.toLong(nodeId).toNumber(), // Use number or string? Try number first as insert uses number
132
+ };
124
133
  if (sessionId)
125
134
  params.session_id = sessionId;
135
+ // Try /node/:id but include node_id in query params as well, as server seems to require it in query
126
136
  await this.request("DELETE", `/node/${this.toLong(nodeId).toString()}`, undefined, params);
127
137
  return true;
128
138
  }
@@ -9,6 +9,20 @@ export declare const state: ({
9
9
  description: string;
10
10
  };
11
11
  query?: undefined;
12
+ name?: undefined;
13
+ value?: undefined;
14
+ source?: undefined;
15
+ description?: undefined;
16
+ priority?: undefined;
17
+ parentId?: undefined;
18
+ goalId?: undefined;
19
+ status?: undefined;
20
+ statusFilter?: undefined;
21
+ agentId?: undefined;
22
+ actionType?: undefined;
23
+ actionDetails?: undefined;
24
+ limit?: undefined;
25
+ actionTypeFilter?: undefined;
12
26
  };
13
27
  required: string[];
14
28
  };
@@ -23,7 +37,264 @@ export declare const state: ({
23
37
  description: string;
24
38
  };
25
39
  content?: undefined;
40
+ name?: undefined;
41
+ value?: undefined;
42
+ source?: undefined;
43
+ description?: undefined;
44
+ priority?: undefined;
45
+ parentId?: undefined;
46
+ goalId?: undefined;
47
+ status?: undefined;
48
+ statusFilter?: undefined;
49
+ agentId?: undefined;
50
+ actionType?: undefined;
51
+ actionDetails?: undefined;
52
+ limit?: undefined;
53
+ actionTypeFilter?: undefined;
26
54
  };
27
55
  required: string[];
28
56
  };
57
+ } | {
58
+ name: string;
59
+ description: string;
60
+ input_schema: {
61
+ type: string;
62
+ properties: {
63
+ name: {
64
+ type: string;
65
+ description: string;
66
+ };
67
+ value: {
68
+ description: string;
69
+ };
70
+ source: {
71
+ type: string;
72
+ description: string;
73
+ };
74
+ content?: undefined;
75
+ query?: undefined;
76
+ description?: undefined;
77
+ priority?: undefined;
78
+ parentId?: undefined;
79
+ goalId?: undefined;
80
+ status?: undefined;
81
+ statusFilter?: undefined;
82
+ agentId?: undefined;
83
+ actionType?: undefined;
84
+ actionDetails?: undefined;
85
+ limit?: undefined;
86
+ actionTypeFilter?: undefined;
87
+ };
88
+ required: string[];
89
+ };
90
+ } | {
91
+ name: string;
92
+ description: string;
93
+ input_schema: {
94
+ type: string;
95
+ properties: {
96
+ name: {
97
+ type: string;
98
+ description: string;
99
+ };
100
+ content?: undefined;
101
+ query?: undefined;
102
+ value?: undefined;
103
+ source?: undefined;
104
+ description?: undefined;
105
+ priority?: undefined;
106
+ parentId?: undefined;
107
+ goalId?: undefined;
108
+ status?: undefined;
109
+ statusFilter?: undefined;
110
+ agentId?: undefined;
111
+ actionType?: undefined;
112
+ actionDetails?: undefined;
113
+ limit?: undefined;
114
+ actionTypeFilter?: undefined;
115
+ };
116
+ required: string[];
117
+ };
118
+ } | {
119
+ name: string;
120
+ description: string;
121
+ input_schema: {
122
+ type: string;
123
+ properties: {
124
+ content?: undefined;
125
+ query?: undefined;
126
+ name?: undefined;
127
+ value?: undefined;
128
+ source?: undefined;
129
+ description?: undefined;
130
+ priority?: undefined;
131
+ parentId?: undefined;
132
+ goalId?: undefined;
133
+ status?: undefined;
134
+ statusFilter?: undefined;
135
+ agentId?: undefined;
136
+ actionType?: undefined;
137
+ actionDetails?: undefined;
138
+ limit?: undefined;
139
+ actionTypeFilter?: undefined;
140
+ };
141
+ required?: undefined;
142
+ };
143
+ } | {
144
+ name: string;
145
+ description: string;
146
+ input_schema: {
147
+ type: string;
148
+ properties: {
149
+ description: {
150
+ type: string;
151
+ description: string;
152
+ };
153
+ priority: {
154
+ type: string;
155
+ description: string;
156
+ };
157
+ parentId: {
158
+ type: string;
159
+ description: string;
160
+ };
161
+ content?: undefined;
162
+ query?: undefined;
163
+ name?: undefined;
164
+ value?: undefined;
165
+ source?: undefined;
166
+ goalId?: undefined;
167
+ status?: undefined;
168
+ statusFilter?: undefined;
169
+ agentId?: undefined;
170
+ actionType?: undefined;
171
+ actionDetails?: undefined;
172
+ limit?: undefined;
173
+ actionTypeFilter?: undefined;
174
+ };
175
+ required: string[];
176
+ };
177
+ } | {
178
+ name: string;
179
+ description: string;
180
+ input_schema: {
181
+ type: string;
182
+ properties: {
183
+ goalId: {
184
+ type: string;
185
+ description: string;
186
+ };
187
+ status: {
188
+ type: string;
189
+ description: string;
190
+ };
191
+ content?: undefined;
192
+ query?: undefined;
193
+ name?: undefined;
194
+ value?: undefined;
195
+ source?: undefined;
196
+ description?: undefined;
197
+ priority?: undefined;
198
+ parentId?: undefined;
199
+ statusFilter?: undefined;
200
+ agentId?: undefined;
201
+ actionType?: undefined;
202
+ actionDetails?: undefined;
203
+ limit?: undefined;
204
+ actionTypeFilter?: undefined;
205
+ };
206
+ required: string[];
207
+ };
208
+ } | {
209
+ name: string;
210
+ description: string;
211
+ input_schema: {
212
+ type: string;
213
+ properties: {
214
+ statusFilter: {
215
+ type: string;
216
+ description: string;
217
+ };
218
+ content?: undefined;
219
+ query?: undefined;
220
+ name?: undefined;
221
+ value?: undefined;
222
+ source?: undefined;
223
+ description?: undefined;
224
+ priority?: undefined;
225
+ parentId?: undefined;
226
+ goalId?: undefined;
227
+ status?: undefined;
228
+ agentId?: undefined;
229
+ actionType?: undefined;
230
+ actionDetails?: undefined;
231
+ limit?: undefined;
232
+ actionTypeFilter?: undefined;
233
+ };
234
+ required?: undefined;
235
+ };
236
+ } | {
237
+ name: string;
238
+ description: string;
239
+ input_schema: {
240
+ type: string;
241
+ properties: {
242
+ agentId: {
243
+ type: string;
244
+ description: string;
245
+ };
246
+ actionType: {
247
+ type: string;
248
+ description: string;
249
+ };
250
+ actionDetails: {
251
+ description: string;
252
+ };
253
+ content?: undefined;
254
+ query?: undefined;
255
+ name?: undefined;
256
+ value?: undefined;
257
+ source?: undefined;
258
+ description?: undefined;
259
+ priority?: undefined;
260
+ parentId?: undefined;
261
+ goalId?: undefined;
262
+ status?: undefined;
263
+ statusFilter?: undefined;
264
+ limit?: undefined;
265
+ actionTypeFilter?: undefined;
266
+ };
267
+ required: string[];
268
+ };
269
+ } | {
270
+ name: string;
271
+ description: string;
272
+ input_schema: {
273
+ type: string;
274
+ properties: {
275
+ limit: {
276
+ type: string;
277
+ description: string;
278
+ };
279
+ actionTypeFilter: {
280
+ type: string;
281
+ description: string;
282
+ };
283
+ content?: undefined;
284
+ query?: undefined;
285
+ name?: undefined;
286
+ value?: undefined;
287
+ source?: undefined;
288
+ description?: undefined;
289
+ priority?: undefined;
290
+ parentId?: undefined;
291
+ goalId?: undefined;
292
+ status?: undefined;
293
+ statusFilter?: undefined;
294
+ agentId?: undefined;
295
+ actionType?: undefined;
296
+ actionDetails?: undefined;
297
+ };
298
+ required?: undefined;
299
+ };
29
300
  })[];
@@ -41,4 +41,152 @@ exports.state = [
41
41
  required: ["content"],
42
42
  },
43
43
  },
44
+ // Working Memory (Structured Variables)
45
+ {
46
+ name: "setVariable",
47
+ description: "Sets a structured variable in working memory.",
48
+ input_schema: {
49
+ type: "object",
50
+ properties: {
51
+ name: { type: "string", description: "The name of the variable." },
52
+ value: {
53
+ description: "The value to store (any JSON-serializable type).",
54
+ },
55
+ source: {
56
+ type: "string",
57
+ description: "Source of the variable: 'system', 'reasoning', 'retrieval', 'perception', or 'explicit'.",
58
+ },
59
+ },
60
+ required: ["name", "value"],
61
+ },
62
+ },
63
+ {
64
+ name: "getVariable",
65
+ description: "Gets a structured variable from working memory.",
66
+ input_schema: {
67
+ type: "object",
68
+ properties: {
69
+ name: {
70
+ type: "string",
71
+ description: "The name of the variable to retrieve.",
72
+ },
73
+ },
74
+ required: ["name"],
75
+ },
76
+ },
77
+ {
78
+ name: "listVariables",
79
+ description: "Lists all variables in working memory.",
80
+ input_schema: {
81
+ type: "object",
82
+ properties: {},
83
+ },
84
+ },
85
+ {
86
+ name: "deleteVariable",
87
+ description: "Deletes a variable from working memory.",
88
+ input_schema: {
89
+ type: "object",
90
+ properties: {
91
+ name: {
92
+ type: "string",
93
+ description: "The name of the variable to delete.",
94
+ },
95
+ },
96
+ required: ["name"],
97
+ },
98
+ },
99
+ // Goals
100
+ {
101
+ name: "addGoal",
102
+ description: "Adds a new goal to the agent's goal stack.",
103
+ input_schema: {
104
+ type: "object",
105
+ properties: {
106
+ description: {
107
+ type: "string",
108
+ description: "The description of the goal.",
109
+ },
110
+ priority: {
111
+ type: "string",
112
+ description: "Priority level: 'low', 'medium', 'high', or 'critical'.",
113
+ },
114
+ parentId: {
115
+ type: "string",
116
+ description: "Optional parent goal ID for hierarchical goals.",
117
+ },
118
+ },
119
+ required: ["description"],
120
+ },
121
+ },
122
+ {
123
+ name: "updateGoal",
124
+ description: "Updates the status of an existing goal.",
125
+ input_schema: {
126
+ type: "object",
127
+ properties: {
128
+ goalId: {
129
+ type: "string",
130
+ description: "The ID of the goal to update.",
131
+ },
132
+ status: {
133
+ type: "string",
134
+ description: "New status: 'active', 'suspended', 'achieved', 'abandoned', or 'failed'.",
135
+ },
136
+ },
137
+ required: ["goalId", "status"],
138
+ },
139
+ },
140
+ {
141
+ name: "listGoals",
142
+ description: "Lists all goals, optionally filtered by status.",
143
+ input_schema: {
144
+ type: "object",
145
+ properties: {
146
+ statusFilter: {
147
+ type: "string",
148
+ description: "Optional status to filter by.",
149
+ },
150
+ },
151
+ },
152
+ },
153
+ // Actions
154
+ {
155
+ name: "submitAction",
156
+ description: "Submits an action for execution and logging.",
157
+ input_schema: {
158
+ type: "object",
159
+ properties: {
160
+ agentId: {
161
+ type: "string",
162
+ description: "The ID of the agent submitting the action.",
163
+ },
164
+ actionType: {
165
+ type: "string",
166
+ description: "Type of action: 'reason', 'retrieve', 'learn', or 'ground'.",
167
+ },
168
+ actionDetails: {
169
+ description: "The action details (any JSON-serializable object).",
170
+ },
171
+ },
172
+ required: ["agentId", "actionType", "actionDetails"],
173
+ },
174
+ },
175
+ {
176
+ name: "getActionLog",
177
+ description: "Gets the action log for the current run.",
178
+ input_schema: {
179
+ type: "object",
180
+ properties: {
181
+ limit: {
182
+ type: "number",
183
+ description: "Maximum number of entries to retrieve.",
184
+ },
185
+ actionTypeFilter: {
186
+ type: "string",
187
+ description: "Optional action type to filter by.",
188
+ },
189
+ },
190
+ },
191
+ },
44
192
  ];
@@ -1,2 +1,2 @@
1
1
  import { StateClient } from "../state";
2
- export declare function execute(name: string, args: any, client: StateClient): Promise<string | boolean | any[]>;
2
+ export declare function execute(name: string, args: any, client: StateClient): Promise<any>;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.execute = execute;
4
4
  async function execute(name, args, client) {
5
5
  switch (name) {
6
+ // Core Memory Operations
6
7
  case "focus":
7
8
  return await client.focus(args.content);
8
9
  case "recall":
@@ -16,6 +17,27 @@ async function execute(name, args, client) {
16
17
  return await client.commit(args.input, args.outcome, {
17
18
  action: args.action,
18
19
  });
20
+ // Working Memory (Structured Variables)
21
+ case "setVariable":
22
+ return await client.setVariable(args.name, args.value, args.source);
23
+ case "getVariable":
24
+ return await client.getVariable(args.name);
25
+ case "listVariables":
26
+ return await client.listVariables();
27
+ case "deleteVariable":
28
+ return await client.deleteVariable(args.name);
29
+ // Goals
30
+ case "addGoal":
31
+ return await client.addGoal(args.description, args.priority, args.parentId);
32
+ case "updateGoal":
33
+ return await client.updateGoal(args.goalId, args.status);
34
+ case "listGoals":
35
+ return await client.listGoals(args.statusFilter);
36
+ // Actions
37
+ case "submitAction":
38
+ return await client.submitAction(args.agentId, args.actionType, args.actionDetails);
39
+ case "getActionLog":
40
+ return await client.getActionLog(args.limit, args.actionTypeFilter);
19
41
  default:
20
42
  throw new Error(`Unknown tool: ${name}`);
21
43
  }