@mastra/daytona 0.0.1 → 0.1.0
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/CHANGELOG.md +169 -0
- package/LICENSE.md +15 -0
- package/README.md +188 -2
- package/dist/index.cjs +694 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +695 -32
- package/dist/index.js.map +1 -1
- package/dist/sandbox/index.d.ts +63 -11
- package/dist/sandbox/index.d.ts.map +1 -1
- package/dist/sandbox/mounts/gcs.d.ts +20 -0
- package/dist/sandbox/mounts/gcs.d.ts.map +1 -0
- package/dist/sandbox/mounts/index.d.ts +4 -0
- package/dist/sandbox/mounts/index.d.ts.map +1 -0
- package/dist/sandbox/mounts/s3.d.ts +30 -0
- package/dist/sandbox/mounts/s3.d.ts.map +1 -0
- package/dist/sandbox/mounts/types.d.ts +59 -0
- package/dist/sandbox/mounts/types.d.ts.map +1 -0
- package/package.json +7 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# @mastra/daytona
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add DaytonaSandbox workspace provider — Daytona cloud sandbox integration for Mastra workspaces, implementing the WorkspaceSandbox interface with support for command execution, environment variables, resource configuration, snapshots, and Daytona volumes. ([#13112](https://github.com/mastra-ai/mastra/pull/13112))
|
|
8
|
+
|
|
9
|
+
**Basic usage**
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { Workspace } from '@mastra/core/workspace';
|
|
13
|
+
import { DaytonaSandbox } from '@mastra/daytona';
|
|
14
|
+
|
|
15
|
+
const sandbox = new DaytonaSandbox({
|
|
16
|
+
id: 'my-sandbox',
|
|
17
|
+
env: { NODE_ENV: 'production' },
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const workspace = new Workspace({ sandbox });
|
|
21
|
+
await workspace.init();
|
|
22
|
+
|
|
23
|
+
const result = await workspace.sandbox.executeCommand('echo', ['Hello!']);
|
|
24
|
+
console.log(result.stdout); // "Hello!"
|
|
25
|
+
|
|
26
|
+
await workspace.destroy();
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- Added S3 and GCS cloud filesystem mounting support via FUSE (s3fs-fuse, gcsfuse). Daytona sandboxes can now mount cloud storage as local directories, matching the mount capabilities of E2B and Blaxel providers. ([#13544](https://github.com/mastra-ai/mastra/pull/13544))
|
|
30
|
+
|
|
31
|
+
**New methods:**
|
|
32
|
+
- `mount(filesystem, mountPath)` — Mount an S3 or GCS filesystem at a path in the sandbox
|
|
33
|
+
- `unmount(mountPath)` — Unmount a previously mounted filesystem
|
|
34
|
+
|
|
35
|
+
**What changed:**
|
|
36
|
+
- Added S3 and GCS bucket mounts as local directories in Daytona sandboxes.
|
|
37
|
+
- Improved reconnect behavior so mounts are restored reliably.
|
|
38
|
+
- Added safety checks to prevent mounting into non-empty directories.
|
|
39
|
+
- Improved concurrent mount support by isolating credentials per mount.
|
|
40
|
+
|
|
41
|
+
**Usage:**
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { Workspace } from '@mastra/core/workspace';
|
|
45
|
+
import { S3Filesystem } from '@mastra/s3';
|
|
46
|
+
import { DaytonaSandbox } from '@mastra/daytona';
|
|
47
|
+
|
|
48
|
+
const workspace = new Workspace({
|
|
49
|
+
mounts: {
|
|
50
|
+
'/data': new S3Filesystem({
|
|
51
|
+
bucket: 'my-bucket',
|
|
52
|
+
region: 'us-east-1',
|
|
53
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
54
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
55
|
+
}),
|
|
56
|
+
},
|
|
57
|
+
sandbox: new DaytonaSandbox(),
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- Remove internal `processes` field from sandbox provider options ([#13597](https://github.com/mastra-ai/mastra/pull/13597))
|
|
64
|
+
|
|
65
|
+
The `processes` field is no longer exposed in constructor options for E2B, Daytona, and Blaxel sandbox providers. This field is managed internally and was not intended to be user-configurable.
|
|
66
|
+
|
|
67
|
+
- Improved S3/GCS FUSE mounting reliability and sandbox reconnection. ([#13543](https://github.com/mastra-ai/mastra/pull/13543))
|
|
68
|
+
|
|
69
|
+
**Mounting improvements**
|
|
70
|
+
- Replaced direct SDK coupling in mount helpers with callback-based context, making mount operations more testable and resilient
|
|
71
|
+
- Added tmpfs overlay to handle FUSE-on-FUSE remount scenarios that previously failed with ENOENT
|
|
72
|
+
- Added `mount --move` fallback when standard FUSE unmount fails on stuck mounts
|
|
73
|
+
- `stop()` now unmounts all filesystems before stopping the sandbox
|
|
74
|
+
- Added early connectivity check for GCS mounting that detects Daytona's restricted internet tiers and fails fast with an actionable error message instead of hanging
|
|
75
|
+
- Improved gcsfuse installation with distro-aware codename detection (bookworm for Debian, jammy for Ubuntu)
|
|
76
|
+
- Added input validation for bucket names, endpoints, and credentials before interpolating into shell commands
|
|
77
|
+
|
|
78
|
+
**Reconnection improvements**
|
|
79
|
+
- `findExistingSandbox` now looks up sandboxes by name first (works for stopped sandboxes), then falls back to label search
|
|
80
|
+
- Added transitional state handling that polls and waits when a sandbox is starting/stopping/restoring before attempting to start it, avoiding "State change in progress" errors
|
|
81
|
+
|
|
82
|
+
- Sandbox instructions no longer include a working directory path, keeping instructions stable across sessions. ([#13520](https://github.com/mastra-ai/mastra/pull/13520))
|
|
83
|
+
|
|
84
|
+
- Updated dependencies [[`504fc8b`](https://github.com/mastra-ai/mastra/commit/504fc8b9d0ddab717577ad3bf9c95ea4bd5377bd), [`f9c150b`](https://github.com/mastra-ai/mastra/commit/f9c150b7595ad05ad9cc9a11098e2944361e8c22), [`88de7e8`](https://github.com/mastra-ai/mastra/commit/88de7e8dfe4b7e1951a9e441bb33136e705ce24e), [`edee4b3`](https://github.com/mastra-ai/mastra/commit/edee4b37dff0af515fc7cc0e8d71ee39e6a762f0), [`3790c75`](https://github.com/mastra-ai/mastra/commit/3790c7578cc6a47d854eb12d89e6b1912867fe29), [`e7a235b`](https://github.com/mastra-ai/mastra/commit/e7a235be6472e0c870ed6c791ddb17c492dc188b), [`d51d298`](https://github.com/mastra-ai/mastra/commit/d51d298953967aab1f58ec965b644d109214f085), [`6dbeeb9`](https://github.com/mastra-ai/mastra/commit/6dbeeb94a8b1eebb727300d1a98961f882180794), [`d5f0d8d`](https://github.com/mastra-ai/mastra/commit/d5f0d8d6a03e515ddaa9b5da19b7e44b8357b07b), [`09c3b18`](https://github.com/mastra-ai/mastra/commit/09c3b1802ff14e243a8a8baea327440bc8cc2e32), [`b896379`](https://github.com/mastra-ai/mastra/commit/b8963791c6afa79484645fcec596a201f936b9a2), [`85c84eb`](https://github.com/mastra-ai/mastra/commit/85c84ebb78aebfcba9d209c8e152b16d7a00cb71), [`a89272a`](https://github.com/mastra-ai/mastra/commit/a89272a5d71939b9fcd284e6a6dc1dd091a6bdcf), [`ee9c8df`](https://github.com/mastra-ai/mastra/commit/ee9c8df644f19d055af5f496bf4942705f5a47b7), [`77b4a25`](https://github.com/mastra-ai/mastra/commit/77b4a254e51907f8ff3a3ba95596a18e93ae4b35), [`276246e`](https://github.com/mastra-ai/mastra/commit/276246e0b9066a1ea48bbc70df84dbe528daaf99), [`08ecfdb`](https://github.com/mastra-ai/mastra/commit/08ecfdbdad6fb8285deef86a034bdf4a6047cfca), [`d5f628c`](https://github.com/mastra-ai/mastra/commit/d5f628ca86c6f6f3ff1035d52f635df32dd81cab), [`524c0f3`](https://github.com/mastra-ai/mastra/commit/524c0f3c434c3d9d18f66338dcef383d6161b59c), [`c18a0e9`](https://github.com/mastra-ai/mastra/commit/c18a0e9cef1e4ca004b2963d35e4cfc031971eac), [`4bd21ea`](https://github.com/mastra-ai/mastra/commit/4bd21ea43d44d0a0427414fc047577f9f0aa3bec), [`115a7a4`](https://github.com/mastra-ai/mastra/commit/115a7a47db5e9896fec12ae6507501adb9ec89bf), [`22a48ae`](https://github.com/mastra-ai/mastra/commit/22a48ae2513eb54d8d79dad361fddbca97a155e8), [`3c6ef79`](https://github.com/mastra-ai/mastra/commit/3c6ef798481e00d6d22563be2de98818fd4dd5e0), [`9311c17`](https://github.com/mastra-ai/mastra/commit/9311c17d7a0640d9c4da2e71b814dc67c57c6369), [`7edf78f`](https://github.com/mastra-ai/mastra/commit/7edf78f80422c43e84585f08ba11df0d4d0b73c5), [`1c4221c`](https://github.com/mastra-ai/mastra/commit/1c4221cf6032ec98d0e094d4ee11da3e48490d96), [`d25b9ea`](https://github.com/mastra-ai/mastra/commit/d25b9eabd400167255a97b690ffbc4ee4097ded5), [`fe1ce5c`](https://github.com/mastra-ai/mastra/commit/fe1ce5c9211c03d561606fda95cbfe7df1d9a9b5), [`b03c0e0`](https://github.com/mastra-ai/mastra/commit/b03c0e0389a799523929a458b0509c9e4244d562), [`0a8366b`](https://github.com/mastra-ai/mastra/commit/0a8366b0a692fcdde56c4d526e4cf03c502ae4ac), [`85664e9`](https://github.com/mastra-ai/mastra/commit/85664e9fd857320fbc245e301f764f45f66f32a3), [`bc79650`](https://github.com/mastra-ai/mastra/commit/bc796500c6e0334faa158a96077e3fb332274869), [`9257d01`](https://github.com/mastra-ai/mastra/commit/9257d01d1366d81f84c582fe02b5e200cf9621f4), [`3a3a59e`](https://github.com/mastra-ai/mastra/commit/3a3a59e8ffaa6a985fe3d9a126a3f5ade11a6724), [`3108d4e`](https://github.com/mastra-ai/mastra/commit/3108d4e649c9fddbf03253a6feeb388a5fa9fa5a), [`0c33b2c`](https://github.com/mastra-ai/mastra/commit/0c33b2c9db537f815e1c59e2c898ffce2e395a79), [`191e5bd`](https://github.com/mastra-ai/mastra/commit/191e5bd29b82f5bda35243945790da7bc7b695c2), [`f77cd94`](https://github.com/mastra-ai/mastra/commit/f77cd94c44eabed490384e7d19232a865e13214c), [`e8135c7`](https://github.com/mastra-ai/mastra/commit/e8135c7e300dac5040670eec7eab896ac6092e30), [`daca48f`](https://github.com/mastra-ai/mastra/commit/daca48f0fb17b7ae0b62a2ac40cf0e491b2fd0b7), [`257d14f`](https://github.com/mastra-ai/mastra/commit/257d14faca5931f2e4186fc165b6f0b1f915deee), [`352f25d`](https://github.com/mastra-ai/mastra/commit/352f25da316b24cdd5b410fd8dddf6a8b763da2a), [`93477d0`](https://github.com/mastra-ai/mastra/commit/93477d0769b8a13ea5ed73d508d967fb23eaeed9), [`31c78b3`](https://github.com/mastra-ai/mastra/commit/31c78b3eb28f58a8017f1dcc795c33214d87feac), [`0bc0720`](https://github.com/mastra-ai/mastra/commit/0bc07201095791858087cc56f353fcd65e87ab54), [`36516ac`](https://github.com/mastra-ai/mastra/commit/36516aca1021cbeb42e74751b46a2614101f37c8), [`e947652`](https://github.com/mastra-ai/mastra/commit/e9476527fdecb4449e54570e80dfaf8466901254), [`3c6ef79`](https://github.com/mastra-ai/mastra/commit/3c6ef798481e00d6d22563be2de98818fd4dd5e0), [`9257d01`](https://github.com/mastra-ai/mastra/commit/9257d01d1366d81f84c582fe02b5e200cf9621f4), [`ec248f6`](https://github.com/mastra-ai/mastra/commit/ec248f6b56e8a037c066c49b2178e2507471d988)]:
|
|
85
|
+
- @mastra/core@1.9.0
|
|
86
|
+
|
|
87
|
+
## 0.1.0-alpha.0
|
|
88
|
+
|
|
89
|
+
### Minor Changes
|
|
90
|
+
|
|
91
|
+
- Add DaytonaSandbox workspace provider — Daytona cloud sandbox integration for Mastra workspaces, implementing the WorkspaceSandbox interface with support for command execution, environment variables, resource configuration, snapshots, and Daytona volumes. ([#13112](https://github.com/mastra-ai/mastra/pull/13112))
|
|
92
|
+
|
|
93
|
+
**Basic usage**
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
import { Workspace } from '@mastra/core/workspace';
|
|
97
|
+
import { DaytonaSandbox } from '@mastra/daytona';
|
|
98
|
+
|
|
99
|
+
const sandbox = new DaytonaSandbox({
|
|
100
|
+
id: 'my-sandbox',
|
|
101
|
+
env: { NODE_ENV: 'production' },
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const workspace = new Workspace({ sandbox });
|
|
105
|
+
await workspace.init();
|
|
106
|
+
|
|
107
|
+
const result = await workspace.sandbox.executeCommand('echo', ['Hello!']);
|
|
108
|
+
console.log(result.stdout); // "Hello!"
|
|
109
|
+
|
|
110
|
+
await workspace.destroy();
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
- Added S3 and GCS cloud filesystem mounting support via FUSE (s3fs-fuse, gcsfuse). Daytona sandboxes can now mount cloud storage as local directories, matching the mount capabilities of E2B and Blaxel providers. ([#13544](https://github.com/mastra-ai/mastra/pull/13544))
|
|
114
|
+
|
|
115
|
+
**New methods:**
|
|
116
|
+
- `mount(filesystem, mountPath)` — Mount an S3 or GCS filesystem at a path in the sandbox
|
|
117
|
+
- `unmount(mountPath)` — Unmount a previously mounted filesystem
|
|
118
|
+
|
|
119
|
+
**What changed:**
|
|
120
|
+
- Added S3 and GCS bucket mounts as local directories in Daytona sandboxes.
|
|
121
|
+
- Improved reconnect behavior so mounts are restored reliably.
|
|
122
|
+
- Added safety checks to prevent mounting into non-empty directories.
|
|
123
|
+
- Improved concurrent mount support by isolating credentials per mount.
|
|
124
|
+
|
|
125
|
+
**Usage:**
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import { Workspace } from '@mastra/core/workspace';
|
|
129
|
+
import { S3Filesystem } from '@mastra/s3';
|
|
130
|
+
import { DaytonaSandbox } from '@mastra/daytona';
|
|
131
|
+
|
|
132
|
+
const workspace = new Workspace({
|
|
133
|
+
mounts: {
|
|
134
|
+
'/data': new S3Filesystem({
|
|
135
|
+
bucket: 'my-bucket',
|
|
136
|
+
region: 'us-east-1',
|
|
137
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
138
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
139
|
+
}),
|
|
140
|
+
},
|
|
141
|
+
sandbox: new DaytonaSandbox(),
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Patch Changes
|
|
146
|
+
|
|
147
|
+
- Remove internal `processes` field from sandbox provider options ([#13597](https://github.com/mastra-ai/mastra/pull/13597))
|
|
148
|
+
|
|
149
|
+
The `processes` field is no longer exposed in constructor options for E2B, Daytona, and Blaxel sandbox providers. This field is managed internally and was not intended to be user-configurable.
|
|
150
|
+
|
|
151
|
+
- Improved S3/GCS FUSE mounting reliability and sandbox reconnection. ([#13543](https://github.com/mastra-ai/mastra/pull/13543))
|
|
152
|
+
|
|
153
|
+
**Mounting improvements**
|
|
154
|
+
- Replaced direct SDK coupling in mount helpers with callback-based context, making mount operations more testable and resilient
|
|
155
|
+
- Added tmpfs overlay to handle FUSE-on-FUSE remount scenarios that previously failed with ENOENT
|
|
156
|
+
- Added `mount --move` fallback when standard FUSE unmount fails on stuck mounts
|
|
157
|
+
- `stop()` now unmounts all filesystems before stopping the sandbox
|
|
158
|
+
- Added early connectivity check for GCS mounting that detects Daytona's restricted internet tiers and fails fast with an actionable error message instead of hanging
|
|
159
|
+
- Improved gcsfuse installation with distro-aware codename detection (bookworm for Debian, jammy for Ubuntu)
|
|
160
|
+
- Added input validation for bucket names, endpoints, and credentials before interpolating into shell commands
|
|
161
|
+
|
|
162
|
+
**Reconnection improvements**
|
|
163
|
+
- `findExistingSandbox` now looks up sandboxes by name first (works for stopped sandboxes), then falls back to label search
|
|
164
|
+
- Added transitional state handling that polls and waits when a sandbox is starting/stopping/restoring before attempting to start it, avoiding "State change in progress" errors
|
|
165
|
+
|
|
166
|
+
- Sandbox instructions no longer include a working directory path, keeping instructions stable across sessions. ([#13520](https://github.com/mastra-ai/mastra/pull/13520))
|
|
167
|
+
|
|
168
|
+
- Updated dependencies [[`504fc8b`](https://github.com/mastra-ai/mastra/commit/504fc8b9d0ddab717577ad3bf9c95ea4bd5377bd), [`f9c150b`](https://github.com/mastra-ai/mastra/commit/f9c150b7595ad05ad9cc9a11098e2944361e8c22), [`88de7e8`](https://github.com/mastra-ai/mastra/commit/88de7e8dfe4b7e1951a9e441bb33136e705ce24e), [`edee4b3`](https://github.com/mastra-ai/mastra/commit/edee4b37dff0af515fc7cc0e8d71ee39e6a762f0), [`3790c75`](https://github.com/mastra-ai/mastra/commit/3790c7578cc6a47d854eb12d89e6b1912867fe29), [`e7a235b`](https://github.com/mastra-ai/mastra/commit/e7a235be6472e0c870ed6c791ddb17c492dc188b), [`d51d298`](https://github.com/mastra-ai/mastra/commit/d51d298953967aab1f58ec965b644d109214f085), [`6dbeeb9`](https://github.com/mastra-ai/mastra/commit/6dbeeb94a8b1eebb727300d1a98961f882180794), [`d5f0d8d`](https://github.com/mastra-ai/mastra/commit/d5f0d8d6a03e515ddaa9b5da19b7e44b8357b07b), [`09c3b18`](https://github.com/mastra-ai/mastra/commit/09c3b1802ff14e243a8a8baea327440bc8cc2e32), [`b896379`](https://github.com/mastra-ai/mastra/commit/b8963791c6afa79484645fcec596a201f936b9a2), [`85c84eb`](https://github.com/mastra-ai/mastra/commit/85c84ebb78aebfcba9d209c8e152b16d7a00cb71), [`a89272a`](https://github.com/mastra-ai/mastra/commit/a89272a5d71939b9fcd284e6a6dc1dd091a6bdcf), [`ee9c8df`](https://github.com/mastra-ai/mastra/commit/ee9c8df644f19d055af5f496bf4942705f5a47b7), [`77b4a25`](https://github.com/mastra-ai/mastra/commit/77b4a254e51907f8ff3a3ba95596a18e93ae4b35), [`276246e`](https://github.com/mastra-ai/mastra/commit/276246e0b9066a1ea48bbc70df84dbe528daaf99), [`08ecfdb`](https://github.com/mastra-ai/mastra/commit/08ecfdbdad6fb8285deef86a034bdf4a6047cfca), [`d5f628c`](https://github.com/mastra-ai/mastra/commit/d5f628ca86c6f6f3ff1035d52f635df32dd81cab), [`524c0f3`](https://github.com/mastra-ai/mastra/commit/524c0f3c434c3d9d18f66338dcef383d6161b59c), [`c18a0e9`](https://github.com/mastra-ai/mastra/commit/c18a0e9cef1e4ca004b2963d35e4cfc031971eac), [`4bd21ea`](https://github.com/mastra-ai/mastra/commit/4bd21ea43d44d0a0427414fc047577f9f0aa3bec), [`115a7a4`](https://github.com/mastra-ai/mastra/commit/115a7a47db5e9896fec12ae6507501adb9ec89bf), [`22a48ae`](https://github.com/mastra-ai/mastra/commit/22a48ae2513eb54d8d79dad361fddbca97a155e8), [`3c6ef79`](https://github.com/mastra-ai/mastra/commit/3c6ef798481e00d6d22563be2de98818fd4dd5e0), [`9311c17`](https://github.com/mastra-ai/mastra/commit/9311c17d7a0640d9c4da2e71b814dc67c57c6369), [`7edf78f`](https://github.com/mastra-ai/mastra/commit/7edf78f80422c43e84585f08ba11df0d4d0b73c5), [`1c4221c`](https://github.com/mastra-ai/mastra/commit/1c4221cf6032ec98d0e094d4ee11da3e48490d96), [`d25b9ea`](https://github.com/mastra-ai/mastra/commit/d25b9eabd400167255a97b690ffbc4ee4097ded5), [`fe1ce5c`](https://github.com/mastra-ai/mastra/commit/fe1ce5c9211c03d561606fda95cbfe7df1d9a9b5), [`b03c0e0`](https://github.com/mastra-ai/mastra/commit/b03c0e0389a799523929a458b0509c9e4244d562), [`0a8366b`](https://github.com/mastra-ai/mastra/commit/0a8366b0a692fcdde56c4d526e4cf03c502ae4ac), [`85664e9`](https://github.com/mastra-ai/mastra/commit/85664e9fd857320fbc245e301f764f45f66f32a3), [`bc79650`](https://github.com/mastra-ai/mastra/commit/bc796500c6e0334faa158a96077e3fb332274869), [`9257d01`](https://github.com/mastra-ai/mastra/commit/9257d01d1366d81f84c582fe02b5e200cf9621f4), [`3a3a59e`](https://github.com/mastra-ai/mastra/commit/3a3a59e8ffaa6a985fe3d9a126a3f5ade11a6724), [`3108d4e`](https://github.com/mastra-ai/mastra/commit/3108d4e649c9fddbf03253a6feeb388a5fa9fa5a), [`0c33b2c`](https://github.com/mastra-ai/mastra/commit/0c33b2c9db537f815e1c59e2c898ffce2e395a79), [`191e5bd`](https://github.com/mastra-ai/mastra/commit/191e5bd29b82f5bda35243945790da7bc7b695c2), [`f77cd94`](https://github.com/mastra-ai/mastra/commit/f77cd94c44eabed490384e7d19232a865e13214c), [`e8135c7`](https://github.com/mastra-ai/mastra/commit/e8135c7e300dac5040670eec7eab896ac6092e30), [`daca48f`](https://github.com/mastra-ai/mastra/commit/daca48f0fb17b7ae0b62a2ac40cf0e491b2fd0b7), [`257d14f`](https://github.com/mastra-ai/mastra/commit/257d14faca5931f2e4186fc165b6f0b1f915deee), [`352f25d`](https://github.com/mastra-ai/mastra/commit/352f25da316b24cdd5b410fd8dddf6a8b763da2a), [`93477d0`](https://github.com/mastra-ai/mastra/commit/93477d0769b8a13ea5ed73d508d967fb23eaeed9), [`31c78b3`](https://github.com/mastra-ai/mastra/commit/31c78b3eb28f58a8017f1dcc795c33214d87feac), [`0bc0720`](https://github.com/mastra-ai/mastra/commit/0bc07201095791858087cc56f353fcd65e87ab54), [`36516ac`](https://github.com/mastra-ai/mastra/commit/36516aca1021cbeb42e74751b46a2614101f37c8), [`e947652`](https://github.com/mastra-ai/mastra/commit/e9476527fdecb4449e54570e80dfaf8466901254), [`3c6ef79`](https://github.com/mastra-ai/mastra/commit/3c6ef798481e00d6d22563be2de98818fd4dd5e0), [`9257d01`](https://github.com/mastra-ai/mastra/commit/9257d01d1366d81f84c582fe02b5e200cf9621f4), [`ec248f6`](https://github.com/mastra-ai/mastra/commit/ec248f6b56e8a037c066c49b2178e2507471d988)]:
|
|
169
|
+
- @mastra/core@1.9.0-alpha.0
|
package/LICENSE.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
Portions of this software are licensed as follows:
|
|
2
|
+
|
|
3
|
+
- All content that resides under any directory named "ee/" within this
|
|
4
|
+
repository, including but not limited to:
|
|
5
|
+
- `packages/core/src/auth/ee/`
|
|
6
|
+
- `packages/server/src/server/auth/ee/`
|
|
7
|
+
is licensed under the license defined in `ee/LICENSE`.
|
|
8
|
+
|
|
9
|
+
- All third-party components incorporated into the Mastra Software are
|
|
10
|
+
licensed under the original license provided by the owner of the
|
|
11
|
+
applicable component.
|
|
12
|
+
|
|
13
|
+
- Content outside of the above-mentioned directories or restrictions is
|
|
14
|
+
available under the "Apache License 2.0" as defined below.
|
|
15
|
+
|
|
1
16
|
# Apache License 2.0
|
|
2
17
|
|
|
3
18
|
Copyright (c) 2025 Kepler Software, Inc.
|
package/README.md
CHANGED
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Daytona cloud sandbox provider for [Mastra](https://mastra.ai) workspaces.
|
|
4
4
|
|
|
5
|
-
Implements the `WorkspaceSandbox` interface using [Daytona](https://www.daytona.io/) sandboxes. Supports multiple runtimes, resource configuration, volumes, snapshots, streaming output, and
|
|
5
|
+
Implements the `WorkspaceSandbox` interface using [Daytona](https://www.daytona.io/) sandboxes. Supports multiple runtimes, resource configuration, volumes, snapshots, streaming output, sandbox reconnection, and filesystem mounting (S3, GCS).
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
pnpm add @mastra/daytona @mastra/core
|
|
11
|
+
|
|
12
|
+
# For filesystem mounting (optional)
|
|
13
|
+
pnpm add @mastra/s3 @mastra/gcs
|
|
11
14
|
```
|
|
12
15
|
|
|
13
16
|
## Usage
|
|
@@ -50,7 +53,7 @@ Use a custom Docker image with specific resource allocation:
|
|
|
50
53
|
```typescript
|
|
51
54
|
const sandbox = new DaytonaSandbox({
|
|
52
55
|
image: 'node:20-slim',
|
|
53
|
-
resources: { cpu: 2, memory: 4, disk:
|
|
56
|
+
resources: { cpu: 2, memory: 4, disk: 6 },
|
|
54
57
|
language: 'typescript',
|
|
55
58
|
});
|
|
56
59
|
```
|
|
@@ -77,6 +80,120 @@ await sandbox.executeCommand('bash', ['-c', 'for i in 1 2 3; do echo "line $i";
|
|
|
77
80
|
});
|
|
78
81
|
```
|
|
79
82
|
|
|
83
|
+
### Reconnection
|
|
84
|
+
|
|
85
|
+
Reconnect to an existing sandbox by providing the same `id`. The sandbox resumes with its files and state intact:
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
const sandbox = new DaytonaSandbox({ id: 'my-persistent-sandbox' });
|
|
89
|
+
|
|
90
|
+
// First session
|
|
91
|
+
await sandbox._start();
|
|
92
|
+
await sandbox.executeCommand('sh', ['-c', 'echo "session 1" > /tmp/state.txt']);
|
|
93
|
+
await sandbox._stop();
|
|
94
|
+
|
|
95
|
+
// Later — reconnects to the same sandbox
|
|
96
|
+
const sandbox2 = new DaytonaSandbox({ id: 'my-persistent-sandbox' });
|
|
97
|
+
await sandbox2._start();
|
|
98
|
+
const result = await sandbox2.executeCommand('cat', ['/tmp/state.txt']);
|
|
99
|
+
console.log(result.stdout); // "session 1"
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Filesystem mounting
|
|
103
|
+
|
|
104
|
+
Mount S3 or GCS buckets as local directories inside the sandbox.
|
|
105
|
+
|
|
106
|
+
#### Via workspace mounts config
|
|
107
|
+
|
|
108
|
+
The simplest way — filesystems are mounted automatically when the sandbox starts:
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
import { Workspace } from '@mastra/core/workspace';
|
|
112
|
+
import { DaytonaSandbox } from '@mastra/daytona';
|
|
113
|
+
import { GCSFilesystem } from '@mastra/gcs';
|
|
114
|
+
import { S3Filesystem } from '@mastra/s3';
|
|
115
|
+
|
|
116
|
+
const workspace = new Workspace({
|
|
117
|
+
mounts: {
|
|
118
|
+
'/s3-data': new S3Filesystem({
|
|
119
|
+
bucket: process.env.S3_BUCKET!,
|
|
120
|
+
region: 'auto',
|
|
121
|
+
accessKeyId: process.env.S3_ACCESS_KEY_ID,
|
|
122
|
+
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
|
|
123
|
+
endpoint: process.env.S3_ENDPOINT, // e.g. https://<account-id>.r2.cloudflarestorage.com
|
|
124
|
+
}),
|
|
125
|
+
'/gcs-data': new GCSFilesystem({
|
|
126
|
+
bucket: process.env.GCS_BUCKET!,
|
|
127
|
+
projectId: 'my-project-id',
|
|
128
|
+
credentials: JSON.parse(process.env.GCS_SERVICE_ACCOUNT_KEY!),
|
|
129
|
+
}),
|
|
130
|
+
},
|
|
131
|
+
sandbox: new DaytonaSandbox({ language: 'python' }),
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
#### Via sandbox.mount()
|
|
136
|
+
|
|
137
|
+
Mount manually at any point after the sandbox has started:
|
|
138
|
+
|
|
139
|
+
#### S3
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
import { DaytonaSandbox } from '@mastra/daytona';
|
|
143
|
+
import { S3Filesystem } from '@mastra/s3';
|
|
144
|
+
|
|
145
|
+
const sandbox = new DaytonaSandbox({ language: 'python' });
|
|
146
|
+
await sandbox._start();
|
|
147
|
+
|
|
148
|
+
await sandbox.mount(
|
|
149
|
+
new S3Filesystem({
|
|
150
|
+
bucket: process.env.S3_BUCKET!,
|
|
151
|
+
region: 'us-east-1',
|
|
152
|
+
accessKeyId: process.env.S3_ACCESS_KEY_ID,
|
|
153
|
+
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
|
|
154
|
+
}),
|
|
155
|
+
'/data',
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
// Files in the bucket are now accessible at /data
|
|
159
|
+
const result = await sandbox.executeCommand('ls', ['/data']);
|
|
160
|
+
console.log(result.stdout);
|
|
161
|
+
|
|
162
|
+
await sandbox._stop(); // Unmounts automatically before stopping
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
#### S3-compatible (Cloudflare R2, MinIO)
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
import { S3Filesystem } from '@mastra/s3';
|
|
169
|
+
|
|
170
|
+
await sandbox.mount(
|
|
171
|
+
new S3Filesystem({
|
|
172
|
+
bucket: process.env.S3_BUCKET!,
|
|
173
|
+
region: 'auto',
|
|
174
|
+
accessKeyId: process.env.S3_ACCESS_KEY_ID,
|
|
175
|
+
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
|
|
176
|
+
endpoint: process.env.S3_ENDPOINT, // e.g. https://<account-id>.r2.cloudflarestorage.com
|
|
177
|
+
}),
|
|
178
|
+
'/data',
|
|
179
|
+
);
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
#### GCS
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
import { GCSFilesystem } from '@mastra/gcs';
|
|
186
|
+
|
|
187
|
+
await sandbox.mount(
|
|
188
|
+
new GCSFilesystem({
|
|
189
|
+
bucket: process.env.GCS_BUCKET!,
|
|
190
|
+
projectId: 'my-project-id',
|
|
191
|
+
credentials: JSON.parse(process.env.GCS_SERVICE_ACCOUNT_KEY!),
|
|
192
|
+
}),
|
|
193
|
+
'/data',
|
|
194
|
+
);
|
|
195
|
+
```
|
|
196
|
+
|
|
80
197
|
### Network isolation
|
|
81
198
|
|
|
82
199
|
Restrict outbound network access:
|
|
@@ -151,6 +268,75 @@ console.log(response.text);
|
|
|
151
268
|
| `networkBlockAll` | `boolean` | `false` | Block all network access |
|
|
152
269
|
| `networkAllowList` | `string` | — | Comma-separated allowed CIDR addresses |
|
|
153
270
|
|
|
271
|
+
## Mount Configuration
|
|
272
|
+
|
|
273
|
+
Pass `S3Filesystem` or `GCSFilesystem` instances via the workspace `mounts` config or directly to `sandbox.mount()`.
|
|
274
|
+
|
|
275
|
+
### S3 environment variables
|
|
276
|
+
|
|
277
|
+
| Variable | Description |
|
|
278
|
+
| ---------------------- | --------------------------------- |
|
|
279
|
+
| `S3_BUCKET` | Bucket name |
|
|
280
|
+
| `S3_REGION` | AWS region or `auto` for R2/MinIO |
|
|
281
|
+
| `S3_ACCESS_KEY_ID` | Access key ID |
|
|
282
|
+
| `S3_SECRET_ACCESS_KEY` | Secret access key |
|
|
283
|
+
| `S3_ENDPOINT` | Endpoint URL (S3-compatible only) |
|
|
284
|
+
|
|
285
|
+
### GCS environment variables
|
|
286
|
+
|
|
287
|
+
| Variable | Description |
|
|
288
|
+
| ------------------------- | ------------------------------------------------------- |
|
|
289
|
+
| `GCS_BUCKET` | Bucket name |
|
|
290
|
+
| `GCS_SERVICE_ACCOUNT_KEY` | Service account key JSON (full JSON string, not a path) |
|
|
291
|
+
|
|
292
|
+
### Reducing cold start latency with a snapshot
|
|
293
|
+
|
|
294
|
+
By default, `s3fs` and `gcsfuse` are installed at first mount via `apt`, which adds startup time. To eliminate this, prebake them into a Daytona snapshot and pass the snapshot name via the `snapshot` option.
|
|
295
|
+
|
|
296
|
+
Create the snapshot once:
|
|
297
|
+
|
|
298
|
+
```typescript
|
|
299
|
+
import { Daytona, Image } from '@daytonaio/sdk';
|
|
300
|
+
|
|
301
|
+
const template = Image.base('daytonaio/sandbox')
|
|
302
|
+
.runCommands('sudo apt-get update -qq')
|
|
303
|
+
.runCommands('sudo apt-get install -y s3fs')
|
|
304
|
+
// gcsfuse requires the Google Cloud apt repository
|
|
305
|
+
.runCommands(
|
|
306
|
+
'sudo mkdir -p /etc/apt/keyrings && ' +
|
|
307
|
+
'curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg -o /tmp/gcsfuse-key.gpg && ' +
|
|
308
|
+
'sudo gpg --batch --yes --dearmor -o /etc/apt/keyrings/gcsfuse.gpg /tmp/gcsfuse-key.gpg && ' +
|
|
309
|
+
// Use gcsfuse-jammy for Ubuntu, gcsfuse-bookworm for Debian
|
|
310
|
+
'echo "deb [signed-by=/etc/apt/keyrings/gcsfuse.gpg] https://packages.cloud.google.com/apt gcsfuse-jammy main" | sudo tee /etc/apt/sources.list.d/gcsfuse.list',
|
|
311
|
+
)
|
|
312
|
+
.runCommands('sudo apt-get update -qq && sudo apt-get install -y gcsfuse');
|
|
313
|
+
|
|
314
|
+
const daytona = new Daytona();
|
|
315
|
+
await daytona.snapshot.create(
|
|
316
|
+
{
|
|
317
|
+
name: 'cloud-fs-mounting',
|
|
318
|
+
image: template,
|
|
319
|
+
},
|
|
320
|
+
{ onLogs: console.log },
|
|
321
|
+
);
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Then use the snapshot name in your sandbox config:
|
|
325
|
+
|
|
326
|
+
```typescript
|
|
327
|
+
const workspace = new Workspace({
|
|
328
|
+
mounts: {
|
|
329
|
+
'/s3-data': new S3Filesystem({
|
|
330
|
+
/* ... */
|
|
331
|
+
}),
|
|
332
|
+
'/gcs-data': new GCSFilesystem({
|
|
333
|
+
/* ... */
|
|
334
|
+
}),
|
|
335
|
+
},
|
|
336
|
+
sandbox: new DaytonaSandbox({ snapshot: 'cloud-fs-mounting' }),
|
|
337
|
+
});
|
|
338
|
+
```
|
|
339
|
+
|
|
154
340
|
## Direct SDK Access
|
|
155
341
|
|
|
156
342
|
Access the underlying Daytona `Sandbox` instance for filesystem, git, and other operations not exposed through WorkspaceSandbox:
|