@mastra/isolated-vm 0.1.2-alpha.0 → 0.1.2
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 +53 -0
- package/package.json +4 -4
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @mastra/isolated-vm
|
|
2
|
+
|
|
3
|
+
`IsolatedVmCodeModeTransport` runs model-authored Code Mode programs inside an in-process V8 isolate. Use it when you need a strong execution boundary without starting a separate sandbox process; the isolate has no direct filesystem, network, or process access.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @mastra/isolated-vm
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
On Node.js 20 and later, start the host process with `--no-node-snapshot` because `isolated-vm` is a native addon.
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { Agent } from '@mastra/core/agent';
|
|
17
|
+
import { createCodeMode, createTool } from '@mastra/core/tools';
|
|
18
|
+
import { IsolatedVmCodeModeTransport } from '@mastra/isolated-vm';
|
|
19
|
+
import { z } from 'zod';
|
|
20
|
+
|
|
21
|
+
const getPrice = createTool({
|
|
22
|
+
id: 'getPrice',
|
|
23
|
+
description: 'Get the price of a product',
|
|
24
|
+
inputSchema: z.object({ productId: z.string() }),
|
|
25
|
+
outputSchema: z.object({ price: z.number() }),
|
|
26
|
+
execute: async ({ productId }) => ({ price: productId === 'pro' ? 49 : 19 }),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const { tool, instructions } = createCodeMode(
|
|
30
|
+
{ tools: { getPrice } },
|
|
31
|
+
new IsolatedVmCodeModeTransport({ memoryLimitMb: 128 }),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const agent = new Agent({
|
|
35
|
+
id: 'pricing-agent',
|
|
36
|
+
name: 'Pricing agent',
|
|
37
|
+
instructions: ['Answer pricing questions.', instructions],
|
|
38
|
+
model: 'openai/gpt-5.6-sol',
|
|
39
|
+
tools: { execute_typescript: tool },
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Documentation
|
|
44
|
+
|
|
45
|
+
- [Reference: IsolatedVmCodeModeTransport](https://mastra.ai/reference/tools/isolated-vm-transport)
|
|
46
|
+
|
|
47
|
+
## Changelog
|
|
48
|
+
|
|
49
|
+
See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/code-mode/isolated-vm/CHANGELOG.md) for version history and release notes.
|
|
50
|
+
|
|
51
|
+
## Support
|
|
52
|
+
|
|
53
|
+
We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/isolated-vm",
|
|
3
|
-
"version": "0.1.2
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "In-process V8 isolate Code Mode transport for Mastra, backed by isolated-vm",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"tsdown": "0.22.9",
|
|
31
31
|
"typescript": "^7.0.2",
|
|
32
32
|
"vitest": "4.1.10",
|
|
33
|
-
"@internal/
|
|
34
|
-
"@internal/
|
|
35
|
-
"@mastra/core": "1.64.0
|
|
33
|
+
"@internal/lint": "0.0.130",
|
|
34
|
+
"@internal/types-builder": "0.0.105",
|
|
35
|
+
"@mastra/core": "1.64.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@mastra/core": ">=1.55.0-0 <2.0.0-0"
|