rice-node-sdk 1.0.5 → 1.0.6

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 CHANGED
@@ -272,9 +272,38 @@ The SDK provides pre-built tool definitions tailored for popular LLM providers.
272
272
 
273
273
  ### Available Imports
274
274
 
275
- - `rice-node-sdk/tools/anthropic`
276
- - `rice-node-sdk/tools/google`
277
- - `rice-node-sdk/tools/openai`
275
+ - `rice-node-sdk/tools/anthropic` - Anthropic Claude format
276
+ - `rice-node-sdk/tools/google` - Google Gemini format
277
+ - `rice-node-sdk/tools/openai` - OpenAI function calling format
278
+ - `rice-node-sdk/tools/vercel` - Vercel AI SDK format (with bound execute functions)
279
+
280
+ ### Example Usage (Vercel AI SDK)
281
+
282
+ The Vercel AI SDK tools come with execute functions pre-bound to your StateClient, making integration seamless.
283
+
284
+ ```typescript
285
+ import { generateText, stepCountIs } from "ai";
286
+ import { google } from "@ai-sdk/google";
287
+ import { Client, statetool } from "rice-node-sdk";
288
+
289
+ const client = new Client({ runId: "my-agent-session" });
290
+ await client.connect();
291
+
292
+ // Create tools bound to your StateClient
293
+ const tools = statetool.createVercelTools(client.state);
294
+
295
+ // Use with generateText - tools are auto-executed!
296
+ const result = await generateText({
297
+ model: google("gemini-2.0-flash"),
298
+ tools,
299
+ stopWhen: stepCountIs(5),
300
+ system: `You are an assistant with persistent memory.
301
+ Use 'remember' to store facts and 'recall' to search memories.`,
302
+ prompt: "Remember that I prefer Python for ML projects.",
303
+ });
304
+
305
+ console.log(result.text);
306
+ ```
278
307
 
279
308
  ### Example Usage (Anthropic)
280
309
 
@@ -359,20 +388,26 @@ if (call) {
359
388
 
360
389
  ### Tools Included
361
390
 
362
- | Tool | Purpose | SDK Method |
363
- | ---------------- | ------------------------------------------------ | ------------------------------- |
364
- | `focus` | Store information in short-term working memory | `client.state.focus()` |
365
- | `remember` | Store information in long-term persistent memory | `client.state.commit()` |
366
- | `recall` | Retrieve relevant memories from long-term memory | `client.state.reminisce()` |
367
- | `setVariable` | Set a structured variable in working memory | `client.state.setVariable()` |
368
- | `getVariable` | Get a structured variable from working memory | `client.state.getVariable()` |
369
- | `listVariables` | List all variables in working memory | `client.state.listVariables()` |
370
- | `deleteVariable` | Delete a variable from working memory | `client.state.deleteVariable()` |
371
- | `addGoal` | Add a new goal to the agent's goal stack | `client.state.addGoal()` |
372
- | `updateGoal` | Update the status of an existing goal | `client.state.updateGoal()` |
373
- | `listGoals` | List all goals, optionally filtered by status | `client.state.listGoals()` |
374
- | `submitAction` | Submit an action for execution and logging | `client.state.submitAction()` |
375
- | `getActionLog` | Get the action log for the current run | `client.state.getActionLog()` |
391
+ | Tool | Purpose | SDK Method |
392
+ | ----------------- | ------------------------------------------------ | -------------------------------- |
393
+ | `focus` | Store information in short-term working memory | `client.state.focus()` |
394
+ | `drift` | Read current items from short-term memory | `client.state.drift()` |
395
+ | `remember` | Store information in long-term persistent memory | `client.state.commit()` |
396
+ | `recall` | Retrieve relevant memories from long-term memory | `client.state.reminisce()` |
397
+ | `trigger` | Trigger a registered skill or procedure | `client.state.trigger()` |
398
+ | `setVariable` | Set a structured variable in working memory | `client.state.setVariable()` |
399
+ | `getVariable` | Get a structured variable from working memory | `client.state.getVariable()` |
400
+ | `listVariables` | List all variables in working memory | `client.state.listVariables()` |
401
+ | `deleteVariable` | Delete a variable from working memory | `client.state.deleteVariable()` |
402
+ | `defineConcept` | Define a concept with JSON schema | `client.state.defineConcept()` |
403
+ | `listConcepts` | List all defined concepts | `client.state.listConcepts()` |
404
+ | `addGoal` | Add a new goal to the agent's goal stack | `client.state.addGoal()` |
405
+ | `updateGoal` | Update the status of an existing goal | `client.state.updateGoal()` |
406
+ | `listGoals` | List all goals, optionally filtered by status | `client.state.listGoals()` |
407
+ | `submitAction` | Submit an action for execution and logging | `client.state.submitAction()` |
408
+ | `getActionLog` | Get the action log for the current run | `client.state.getActionLog()` |
409
+ | `runCycle` | Run a decision cycle with action candidates | `client.state.runCycle()` |
410
+ | `getCycleHistory` | Get history of decision cycles | `client.state.getCycleHistory()` |
376
411
 
377
412
  ## API Reference
378
413
 
package/dist/index.d.ts CHANGED
@@ -1474,6 +1474,7 @@ declare const _default: {
1474
1474
  };
1475
1475
  })[];
1476
1476
  execute: typeof import("./tools/execute").execute;
1477
+ createVercelTools: typeof import("./tools/vercel").createStateTools;
1477
1478
  };
1478
1479
  };
1479
1480
  export default _default;
@@ -1,4 +1,5 @@
1
1
  import { execute } from "../tools/execute";
2
+ import { createStateTools } from "../tools/vercel";
2
3
  export declare const statetool: {
3
4
  google: ({
4
5
  name: string;
@@ -1463,4 +1464,5 @@ export declare const statetool: {
1463
1464
  };
1464
1465
  })[];
1465
1466
  execute: typeof execute;
1467
+ createVercelTools: typeof createStateTools;
1466
1468
  };
@@ -5,9 +5,11 @@ const google_1 = require("../tools/google");
5
5
  const openai_1 = require("../tools/openai");
6
6
  const anthropic_1 = require("../tools/anthropic");
7
7
  const execute_1 = require("../tools/execute");
8
+ const vercel_1 = require("../tools/vercel");
8
9
  exports.statetool = {
9
10
  google: google_1.state,
10
11
  openai: openai_1.state,
11
12
  anthropic: anthropic_1.state,
12
13
  execute: execute_1.execute,
14
+ createVercelTools: vercel_1.createStateTools,
13
15
  };
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Vercel AI SDK v6 compatible tool definitions for Rice State service.
3
+ *
4
+ * Usage with Vercel AI SDK:
5
+ * ```typescript
6
+ * import { generateText } from 'ai';
7
+ * import { createStateTools } from 'rice-node-sdk/tools/vercel';
8
+ *
9
+ * const tools = createStateTools(client.state);
10
+ * const result = await generateText({
11
+ * model: yourModel,
12
+ * tools,
13
+ * prompt: 'Remember that I like TypeScript',
14
+ * });
15
+ * ```
16
+ */
17
+ import { StateClient } from "../state";
18
+ /**
19
+ * Creates Vercel AI SDK v6 compatible tools bound to a StateClient instance.
20
+ * Each tool uses the `tool()` helper from @ai-sdk/provider-utils for proper typing.
21
+ */
22
+ export declare function createStateTools(client: StateClient): {
23
+ focus: import("@ai-sdk/provider-utils").Tool<{
24
+ content: string;
25
+ }, string>;
26
+ drift: import("@ai-sdk/provider-utils").Tool<Record<string, never>, any[]>;
27
+ recall: import("@ai-sdk/provider-utils").Tool<{
28
+ query: string;
29
+ }, any[]>;
30
+ remember: import("@ai-sdk/provider-utils").Tool<{
31
+ content: string;
32
+ }, boolean>;
33
+ trigger: import("@ai-sdk/provider-utils").Tool<{
34
+ skillName: string;
35
+ }, number>;
36
+ setVariable: import("@ai-sdk/provider-utils").Tool<{
37
+ name: string;
38
+ value: any;
39
+ source?: string;
40
+ }, boolean>;
41
+ getVariable: import("@ai-sdk/provider-utils").Tool<{
42
+ name: string;
43
+ }, any>;
44
+ listVariables: import("@ai-sdk/provider-utils").Tool<Record<string, never>, any[]>;
45
+ deleteVariable: import("@ai-sdk/provider-utils").Tool<{
46
+ name: string;
47
+ }, boolean>;
48
+ defineConcept: import("@ai-sdk/provider-utils").Tool<{
49
+ name: string;
50
+ schema: Record<string, any>;
51
+ }, boolean>;
52
+ listConcepts: import("@ai-sdk/provider-utils").Tool<Record<string, never>, any[]>;
53
+ addGoal: import("@ai-sdk/provider-utils").Tool<{
54
+ description: string;
55
+ priority?: string;
56
+ parentId?: string;
57
+ }, any>;
58
+ updateGoal: import("@ai-sdk/provider-utils").Tool<{
59
+ goalId: string;
60
+ status: string;
61
+ }, boolean>;
62
+ listGoals: import("@ai-sdk/provider-utils").Tool<{
63
+ statusFilter?: string;
64
+ }, any[]>;
65
+ submitAction: import("@ai-sdk/provider-utils").Tool<{
66
+ agentId: string;
67
+ actionType: string;
68
+ actionDetails: Record<string, any>;
69
+ }, any>;
70
+ getActionLog: import("@ai-sdk/provider-utils").Tool<{
71
+ limit?: number;
72
+ actionTypeFilter?: string;
73
+ }, any[]>;
74
+ runCycle: import("@ai-sdk/provider-utils").Tool<{
75
+ agentId: string;
76
+ candidates?: Array<{
77
+ actionType: string;
78
+ action: Record<string, any>;
79
+ score: number;
80
+ rationale: string;
81
+ }>;
82
+ }, any>;
83
+ getCycleHistory: import("@ai-sdk/provider-utils").Tool<{
84
+ limit?: number;
85
+ }, any[]>;
86
+ };
87
+ /**
88
+ * Tool names available in the state tools.
89
+ */
90
+ export declare const stateToolNames: readonly ["focus", "drift", "recall", "remember", "trigger", "setVariable", "getVariable", "listVariables", "deleteVariable", "defineConcept", "listConcepts", "addGoal", "updateGoal", "listGoals", "submitAction", "getActionLog", "runCycle", "getCycleHistory"];
91
+ export type StateToolName = (typeof stateToolNames)[number];
@@ -0,0 +1,343 @@
1
+ "use strict";
2
+ /**
3
+ * Vercel AI SDK v6 compatible tool definitions for Rice State service.
4
+ *
5
+ * Usage with Vercel AI SDK:
6
+ * ```typescript
7
+ * import { generateText } from 'ai';
8
+ * import { createStateTools } from 'rice-node-sdk/tools/vercel';
9
+ *
10
+ * const tools = createStateTools(client.state);
11
+ * const result = await generateText({
12
+ * model: yourModel,
13
+ * tools,
14
+ * prompt: 'Remember that I like TypeScript',
15
+ * });
16
+ * ```
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.stateToolNames = void 0;
20
+ exports.createStateTools = createStateTools;
21
+ const provider_utils_1 = require("@ai-sdk/provider-utils");
22
+ /**
23
+ * Creates Vercel AI SDK v6 compatible tools bound to a StateClient instance.
24
+ * Each tool uses the `tool()` helper from @ai-sdk/provider-utils for proper typing.
25
+ */
26
+ function createStateTools(client) {
27
+ return {
28
+ // Core Memory Operations
29
+ focus: (0, provider_utils_1.tool)({
30
+ description: "Stores information in short-term working memory (Flux).",
31
+ inputSchema: (0, provider_utils_1.jsonSchema)({
32
+ type: "object",
33
+ properties: {
34
+ content: {
35
+ type: "string",
36
+ description: "The information to focus on.",
37
+ },
38
+ },
39
+ required: ["content"],
40
+ }),
41
+ execute: async ({ content }) => client.focus(content),
42
+ }),
43
+ drift: (0, provider_utils_1.tool)({
44
+ description: "Reads the current items in short-term working memory (Flux).",
45
+ inputSchema: (0, provider_utils_1.jsonSchema)({
46
+ type: "object",
47
+ properties: {},
48
+ }),
49
+ execute: async () => client.drift(),
50
+ }),
51
+ recall: (0, provider_utils_1.tool)({
52
+ description: "Recalls relevant memories from long-term memory based on a semantic query.",
53
+ inputSchema: (0, provider_utils_1.jsonSchema)({
54
+ type: "object",
55
+ properties: {
56
+ query: {
57
+ type: "string",
58
+ description: "The query to search for in memories.",
59
+ },
60
+ },
61
+ required: ["query"],
62
+ }),
63
+ execute: async ({ query }) => client.reminisce(query),
64
+ }),
65
+ remember: (0, provider_utils_1.tool)({
66
+ description: "Stores information in long-term memory for future recall.",
67
+ inputSchema: (0, provider_utils_1.jsonSchema)({
68
+ type: "object",
69
+ properties: {
70
+ content: {
71
+ type: "string",
72
+ description: "The information to remember.",
73
+ },
74
+ },
75
+ required: ["content"],
76
+ }),
77
+ execute: async ({ content }) => client.commit(content, "Stored in long-term memory", {
78
+ action: "remember",
79
+ }),
80
+ }),
81
+ trigger: (0, provider_utils_1.tool)({
82
+ description: "Triggers a registered skill or procedure by name.",
83
+ inputSchema: (0, provider_utils_1.jsonSchema)({
84
+ type: "object",
85
+ properties: {
86
+ skillName: {
87
+ type: "string",
88
+ description: "The name of the skill to trigger.",
89
+ },
90
+ },
91
+ required: ["skillName"],
92
+ }),
93
+ execute: async ({ skillName }) => client.trigger(skillName),
94
+ }),
95
+ // Working Memory (Structured Variables)
96
+ setVariable: (0, provider_utils_1.tool)({
97
+ description: "Sets a structured variable in working memory.",
98
+ inputSchema: (0, provider_utils_1.jsonSchema)({
99
+ type: "object",
100
+ properties: {
101
+ name: {
102
+ type: "string",
103
+ description: "The name of the variable.",
104
+ },
105
+ value: {
106
+ description: "The value to store (any JSON-serializable type).",
107
+ },
108
+ source: {
109
+ type: "string",
110
+ description: "Source: 'system', 'reasoning', 'retrieval', 'perception', or 'explicit'.",
111
+ },
112
+ },
113
+ required: ["name", "value"],
114
+ }),
115
+ execute: async ({ name, value, source }) => client.setVariable(name, value, source),
116
+ }),
117
+ getVariable: (0, provider_utils_1.tool)({
118
+ description: "Gets a structured variable from working memory.",
119
+ inputSchema: (0, provider_utils_1.jsonSchema)({
120
+ type: "object",
121
+ properties: {
122
+ name: {
123
+ type: "string",
124
+ description: "The name of the variable to retrieve.",
125
+ },
126
+ },
127
+ required: ["name"],
128
+ }),
129
+ execute: async ({ name }) => client.getVariable(name),
130
+ }),
131
+ listVariables: (0, provider_utils_1.tool)({
132
+ description: "Lists all variables in working memory.",
133
+ inputSchema: (0, provider_utils_1.jsonSchema)({
134
+ type: "object",
135
+ properties: {},
136
+ }),
137
+ execute: async () => client.listVariables(),
138
+ }),
139
+ deleteVariable: (0, provider_utils_1.tool)({
140
+ description: "Deletes a variable from working memory.",
141
+ inputSchema: (0, provider_utils_1.jsonSchema)({
142
+ type: "object",
143
+ properties: {
144
+ name: {
145
+ type: "string",
146
+ description: "The name of the variable to delete.",
147
+ },
148
+ },
149
+ required: ["name"],
150
+ }),
151
+ execute: async ({ name }) => client.deleteVariable(name),
152
+ }),
153
+ // Concepts
154
+ defineConcept: (0, provider_utils_1.tool)({
155
+ description: "Defines a concept with a JSON schema for structured knowledge.",
156
+ inputSchema: (0, provider_utils_1.jsonSchema)({
157
+ type: "object",
158
+ properties: {
159
+ name: {
160
+ type: "string",
161
+ description: "The name of the concept.",
162
+ },
163
+ schema: {
164
+ type: "object",
165
+ description: "The JSON schema defining the concept structure.",
166
+ },
167
+ },
168
+ required: ["name", "schema"],
169
+ }),
170
+ execute: async ({ name, schema }) => client.defineConcept(name, schema),
171
+ }),
172
+ listConcepts: (0, provider_utils_1.tool)({
173
+ description: "Lists all defined concepts and their schemas.",
174
+ inputSchema: (0, provider_utils_1.jsonSchema)({
175
+ type: "object",
176
+ properties: {},
177
+ }),
178
+ execute: async () => client.listConcepts(),
179
+ }),
180
+ // Goals
181
+ addGoal: (0, provider_utils_1.tool)({
182
+ description: "Adds a goal to the agent's goal stack.",
183
+ inputSchema: (0, provider_utils_1.jsonSchema)({
184
+ type: "object",
185
+ properties: {
186
+ description: {
187
+ type: "string",
188
+ description: "Description of the goal.",
189
+ },
190
+ priority: {
191
+ type: "string",
192
+ enum: ["low", "medium", "high", "critical"],
193
+ description: "Priority level of the goal.",
194
+ },
195
+ parentId: {
196
+ type: "string",
197
+ description: "Optional parent goal ID for hierarchical goals.",
198
+ },
199
+ },
200
+ required: ["description"],
201
+ }),
202
+ execute: async ({ description, priority, parentId }) => client.addGoal(description, priority, parentId),
203
+ }),
204
+ updateGoal: (0, provider_utils_1.tool)({
205
+ description: "Updates a goal's status.",
206
+ inputSchema: (0, provider_utils_1.jsonSchema)({
207
+ type: "object",
208
+ properties: {
209
+ goalId: {
210
+ type: "string",
211
+ description: "The ID of the goal to update.",
212
+ },
213
+ status: {
214
+ type: "string",
215
+ enum: ["active", "suspended", "achieved", "abandoned", "failed"],
216
+ description: "New status for the goal.",
217
+ },
218
+ },
219
+ required: ["goalId", "status"],
220
+ }),
221
+ execute: async ({ goalId, status }) => client.updateGoal(goalId, status),
222
+ }),
223
+ listGoals: (0, provider_utils_1.tool)({
224
+ description: "Lists all goals, optionally filtered by status.",
225
+ inputSchema: (0, provider_utils_1.jsonSchema)({
226
+ type: "object",
227
+ properties: {
228
+ statusFilter: {
229
+ type: "string",
230
+ enum: ["active", "suspended", "achieved", "abandoned", "failed"],
231
+ description: "Optional status to filter goals by.",
232
+ },
233
+ },
234
+ }),
235
+ execute: async ({ statusFilter }) => client.listGoals(statusFilter),
236
+ }),
237
+ // Actions
238
+ submitAction: (0, provider_utils_1.tool)({
239
+ description: "Submits an action for execution and logging.",
240
+ inputSchema: (0, provider_utils_1.jsonSchema)({
241
+ type: "object",
242
+ properties: {
243
+ agentId: {
244
+ type: "string",
245
+ description: "The ID of the agent submitting the action.",
246
+ },
247
+ actionType: {
248
+ type: "string",
249
+ enum: ["reason", "retrieve", "learn", "ground"],
250
+ description: "Type of action.",
251
+ },
252
+ actionDetails: {
253
+ type: "object",
254
+ description: "The action details.",
255
+ },
256
+ },
257
+ required: ["agentId", "actionType", "actionDetails"],
258
+ }),
259
+ execute: async ({ agentId, actionType, actionDetails }) => client.submitAction(agentId, actionType, actionDetails),
260
+ }),
261
+ getActionLog: (0, provider_utils_1.tool)({
262
+ description: "Gets the action log for the current run.",
263
+ inputSchema: (0, provider_utils_1.jsonSchema)({
264
+ type: "object",
265
+ properties: {
266
+ limit: {
267
+ type: "number",
268
+ description: "Maximum number of entries to retrieve.",
269
+ },
270
+ actionTypeFilter: {
271
+ type: "string",
272
+ description: "Optional action type to filter by.",
273
+ },
274
+ },
275
+ }),
276
+ execute: async ({ limit, actionTypeFilter }) => client.getActionLog(limit, actionTypeFilter),
277
+ }),
278
+ // Decision Cycles
279
+ runCycle: (0, provider_utils_1.tool)({
280
+ description: "Runs a decision cycle with optional action candidates.",
281
+ inputSchema: (0, provider_utils_1.jsonSchema)({
282
+ type: "object",
283
+ properties: {
284
+ agentId: {
285
+ type: "string",
286
+ description: "The ID of the agent running the cycle.",
287
+ },
288
+ candidates: {
289
+ type: "array",
290
+ description: "Optional array of action candidates with scores.",
291
+ items: {
292
+ type: "object",
293
+ properties: {
294
+ actionType: { type: "string" },
295
+ action: { type: "object" },
296
+ score: { type: "number" },
297
+ rationale: { type: "string" },
298
+ },
299
+ },
300
+ },
301
+ },
302
+ required: ["agentId"],
303
+ }),
304
+ execute: async ({ agentId, candidates }) => client.runCycle(agentId, candidates),
305
+ }),
306
+ getCycleHistory: (0, provider_utils_1.tool)({
307
+ description: "Gets the history of decision cycles for the current run.",
308
+ inputSchema: (0, provider_utils_1.jsonSchema)({
309
+ type: "object",
310
+ properties: {
311
+ limit: {
312
+ type: "number",
313
+ description: "Maximum number of cycles to retrieve.",
314
+ },
315
+ },
316
+ }),
317
+ execute: async ({ limit }) => client.getCycleHistory(limit),
318
+ }),
319
+ };
320
+ }
321
+ /**
322
+ * Tool names available in the state tools.
323
+ */
324
+ exports.stateToolNames = [
325
+ "focus",
326
+ "drift",
327
+ "recall",
328
+ "remember",
329
+ "trigger",
330
+ "setVariable",
331
+ "getVariable",
332
+ "listVariables",
333
+ "deleteVariable",
334
+ "defineConcept",
335
+ "listConcepts",
336
+ "addGoal",
337
+ "updateGoal",
338
+ "listGoals",
339
+ "submitAction",
340
+ "getActionLog",
341
+ "runCycle",
342
+ "getCycleHistory",
343
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rice-node-sdk",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "SDK for Rice",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,6 +29,10 @@
29
29
  "types": "./dist/tools/openai.d.ts",
30
30
  "default": "./dist/tools/openai.js"
31
31
  },
32
+ "./tools/vercel": {
33
+ "types": "./dist/tools/vercel.d.ts",
34
+ "default": "./dist/tools/vercel.js"
35
+ },
32
36
  "./tools/execute": {
33
37
  "types": "./dist/tools/execute.d.ts",
34
38
  "default": "./dist/tools/execute.js"
@@ -56,6 +60,7 @@
56
60
  "long": "^5.2.3"
57
61
  },
58
62
  "devDependencies": {
63
+ "@ai-sdk/provider-utils": "^4.0.8",
59
64
  "@types/jest": "^30.0.0",
60
65
  "@types/node": "^20.0.0",
61
66
  "dotenv": "^17.2.3",
@@ -63,4 +68,4 @@
63
68
  "ts-jest": "^29.4.6",
64
69
  "typescript": "^5.3.0"
65
70
  }
66
- }
71
+ }