@mastra/e2b 0.6.0 → 0.7.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 +77 -0
- package/dist/index.cjs +110 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +110 -16
- package/dist/index.js.map +1 -1
- package/dist/sandbox/index.d.ts +45 -3
- package/dist/sandbox/index.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/sandbox/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @see https://e2b.dev/docs
|
|
8
8
|
*/
|
|
9
9
|
import type { RequestContext } from '@mastra/core/di';
|
|
10
|
-
import type { SandboxInfo, WorkspaceFilesystem, MountResult, ProviderStatus, MountManager, MastraSandboxOptions } from '@mastra/core/workspace';
|
|
10
|
+
import type { SandboxInfo, WorkspaceFilesystem, MountResult, ProviderStatus, MountManager, MastraSandboxOptions, SandboxFileInput, SandboxNetworking, SandboxCloneOptions } from '@mastra/core/workspace';
|
|
11
11
|
/**
|
|
12
12
|
* Inlined from `@mastra/core/workspace` to avoid requiring a newer core peer dep.
|
|
13
13
|
*/
|
|
@@ -115,6 +115,16 @@ export declare class E2BSandbox extends MastraSandbox {
|
|
|
115
115
|
status: ProviderStatus;
|
|
116
116
|
readonly mounts: MountManager;
|
|
117
117
|
readonly processes: E2BProcessManager;
|
|
118
|
+
/**
|
|
119
|
+
* Networking capability: public HTTPS URLs for sandbox ports.
|
|
120
|
+
* E2B exposes every port via `getHost(port)` — no upfront declaration needed.
|
|
121
|
+
*
|
|
122
|
+
* When not attached in this process, the URL is resolved by looking up the
|
|
123
|
+
* existing sandbox by identity (without resuming it) and deriving the host
|
|
124
|
+
* (`{port}-{sandboxId}.{domain}`), so other processes can resolve
|
|
125
|
+
* deployments without waking a paused sandbox.
|
|
126
|
+
*/
|
|
127
|
+
readonly networking: SandboxNetworking;
|
|
118
128
|
private _sandbox;
|
|
119
129
|
private _createdAt;
|
|
120
130
|
private _isRetrying;
|
|
@@ -125,11 +135,26 @@ export declare class E2BSandbox extends MastraSandbox {
|
|
|
125
135
|
private readonly network?;
|
|
126
136
|
private readonly connectionOpts;
|
|
127
137
|
private readonly _instructionsOverride?;
|
|
138
|
+
private readonly _constructorOptions;
|
|
128
139
|
/** Resolved template ID after building (if needed) */
|
|
129
140
|
private _resolvedTemplateId?;
|
|
130
141
|
/** Promise for template preparation (started in constructor) */
|
|
131
142
|
private _templatePreparePromise?;
|
|
132
143
|
constructor(options?: E2BSandboxOptions);
|
|
144
|
+
/**
|
|
145
|
+
* Construct a sibling `E2BSandbox` that inherits this sandbox's
|
|
146
|
+
* configuration (credentials, template, network, metadata, instructions)
|
|
147
|
+
* with per-instance overrides.
|
|
148
|
+
*
|
|
149
|
+
* Performs no I/O — the sandbox clone provisions (or reconnects to an
|
|
150
|
+
* existing E2B sandbox with the same logical `id`) on its own `start()`.
|
|
151
|
+
* Use it when one configured sandbox acts as the template for a fleet of
|
|
152
|
+
* independent sandboxes (e.g. one per project).
|
|
153
|
+
*
|
|
154
|
+
* `options.idleTimeoutMinutes` maps to the E2B sandbox `timeout` (ms);
|
|
155
|
+
* `options.sandboxId` is ignored because E2B reconnects by logical `id`.
|
|
156
|
+
*/
|
|
157
|
+
clone(options?: SandboxCloneOptions): E2BSandbox;
|
|
133
158
|
/**
|
|
134
159
|
* Get the underlying E2B Sandbox instance for direct access to E2B APIs.
|
|
135
160
|
*
|
|
@@ -161,8 +186,13 @@ export declare class E2BSandbox extends MastraSandbox {
|
|
|
161
186
|
*/
|
|
162
187
|
start(): Promise<void>;
|
|
163
188
|
/**
|
|
164
|
-
* Stop the E2B sandbox.
|
|
165
|
-
*
|
|
189
|
+
* Stop the E2B sandbox by pausing it (snapshot-stop).
|
|
190
|
+
*
|
|
191
|
+
* Pausing freezes the whole VM — filesystem, memory, and running processes —
|
|
192
|
+
* and stops billing immediately. The next `start()` reconnects and resumes it,
|
|
193
|
+
* with background processes still running. Filesystem mounts are unmounted
|
|
194
|
+
* first (FUSE mounts don't survive pause) and reconciled again on start.
|
|
195
|
+
*
|
|
166
196
|
* Status management is handled by the base class.
|
|
167
197
|
*/
|
|
168
198
|
stop(): Promise<void>;
|
|
@@ -173,6 +203,10 @@ export declare class E2BSandbox extends MastraSandbox {
|
|
|
173
203
|
*/
|
|
174
204
|
destroy(): Promise<void>;
|
|
175
205
|
getInfo(): Promise<SandboxInfo>;
|
|
206
|
+
/**
|
|
207
|
+
* Bulk-write files into the sandbox filesystem via the SDK's native upload.
|
|
208
|
+
*/
|
|
209
|
+
writeFiles(files: SandboxFileInput[]): Promise<void>;
|
|
176
210
|
/**
|
|
177
211
|
* Get instructions describing this E2B sandbox.
|
|
178
212
|
* Used by agents to understand the execution environment.
|
|
@@ -201,9 +235,17 @@ export declare class E2BSandbox extends MastraSandbox {
|
|
|
201
235
|
/** @deprecated Use `status === 'running'` instead. */
|
|
202
236
|
isReady(): Promise<boolean>;
|
|
203
237
|
private generateId;
|
|
238
|
+
/** Domain used to derive public sandbox hosts (self-hosted E2B or e2b.app). */
|
|
239
|
+
private get sandboxDomain();
|
|
240
|
+
/**
|
|
241
|
+
* Look up an existing sandbox with matching mastra-sandbox-id metadata
|
|
242
|
+
* WITHOUT connecting or resuming it. Returns its list info or null.
|
|
243
|
+
*/
|
|
244
|
+
private lookupExistingSandboxInfo;
|
|
204
245
|
/**
|
|
205
246
|
* Find an existing sandbox with matching mastra-sandbox-id metadata.
|
|
206
247
|
* Returns the connected sandbox if found, null otherwise.
|
|
248
|
+
* Connecting to a paused sandbox resumes it.
|
|
207
249
|
*/
|
|
208
250
|
private findExistingSandbox;
|
|
209
251
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sandbox/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,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YACW,eAAe;IAyD7B;;OAEG;YACW,oBAAoB;IASlC;;;OAGG;YACW,eAAe;IAiB7B;;OAEG;YACW,kBAAkB;IA2ChC;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAW1B;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;IAa5B;;;;;;;OAOG;IACG,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAiBvD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/e2b",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "E2B cloud sandbox provider for Mastra workspaces",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,16 +28,16 @@
|
|
|
28
28
|
"@vitest/coverage-v8": "4.1.10",
|
|
29
29
|
"@vitest/ui": "4.1.10",
|
|
30
30
|
"dotenv": "^17.4.2",
|
|
31
|
-
"eslint": "^10.
|
|
31
|
+
"eslint": "^10.7.0",
|
|
32
32
|
"tsup": "^8.5.1",
|
|
33
33
|
"typescript": "^6.0.3",
|
|
34
34
|
"vitest": "4.1.10",
|
|
35
|
-
"@internal/
|
|
36
|
-
"@internal/
|
|
37
|
-
"@internal/
|
|
35
|
+
"@internal/types-builder": "0.0.90",
|
|
36
|
+
"@internal/workspace-test-utils": "0.0.59",
|
|
37
|
+
"@internal/lint": "0.0.115",
|
|
38
38
|
"@mastra/gcs": "0.3.1",
|
|
39
39
|
"@mastra/s3": "0.6.0",
|
|
40
|
-
"@mastra/core": "1.
|
|
40
|
+
"@mastra/core": "1.52.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@mastra/core": ">=1.12.0-0 <2.0.0-0"
|