@ai-sdk/code-mode 1.0.108 → 1.0.110
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 +3 -34
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -4,18 +4,12 @@
|
|
|
4
4
|
AI SDK tools. The code runs in an isolated QuickJS sandbox and returns a
|
|
5
5
|
JSON-serializable value.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
or run them concurrently. Only the tools you provide are available to the
|
|
9
|
-
generated code.
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
7
|
+
## Setup
|
|
12
8
|
|
|
13
9
|
```bash
|
|
14
|
-
|
|
10
|
+
npm i ai @ai-sdk/code-mode zod
|
|
15
11
|
```
|
|
16
12
|
|
|
17
|
-
This package runs on the server and requires Node.js 22.13 or newer.
|
|
18
|
-
|
|
19
13
|
## Usage
|
|
20
14
|
|
|
21
15
|
```ts
|
|
@@ -74,29 +68,4 @@ const result = await generateText({
|
|
|
74
68
|
});
|
|
75
69
|
```
|
|
76
70
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
```ts
|
|
80
|
-
const [inventory, demand] = await Promise.all([
|
|
81
|
-
tools.getInventory({ productId: 'sku_123' }),
|
|
82
|
-
tools.getDemand({ productId: 'sku_123' }),
|
|
83
|
-
]);
|
|
84
|
-
|
|
85
|
-
return {
|
|
86
|
-
sufficient: inventory.availableUnits >= demand.requestedUnits,
|
|
87
|
-
remaining: inventory.availableUnits - demand.requestedUnits,
|
|
88
|
-
};
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
## Direct Execution
|
|
92
|
-
|
|
93
|
-
Use `experimental_runCodeMode` to run code directly:
|
|
94
|
-
|
|
95
|
-
```ts
|
|
96
|
-
import { experimental_runCodeMode as runCodeMode } from '@ai-sdk/code-mode';
|
|
97
|
-
|
|
98
|
-
const result = await runCodeMode({
|
|
99
|
-
js: 'return await tools.getInventory({ productId: "sku_123" });',
|
|
100
|
-
tools: { getInventory },
|
|
101
|
-
});
|
|
102
|
-
```
|
|
71
|
+
See the [Code Mode documentation](https://ai-sdk.dev/docs/ai-sdk-core/code-mode) for more information.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/code-mode",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.110",
|
|
4
4
|
"description": "QuickJS-backed code mode tool for AI SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"README.md"
|
|
38
38
|
],
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"ai": "7.0.
|
|
40
|
+
"ai": "7.0.153"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "22.19.19",
|
|
44
44
|
"@vercel/ai-tsconfig": "0.0.0",
|
|
45
45
|
"@vercel/ai-tsdown-config": "0.0.0",
|
|
46
|
-
"ai": "7.0.
|
|
46
|
+
"ai": "7.0.153",
|
|
47
47
|
"tsdown": "^0.23.0",
|
|
48
48
|
"typescript": "6.0.3",
|
|
49
49
|
"zod": "3.25.76"
|