@mastra/e2b 0.12.0 → 0.12.1-alpha.1
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/dist/index.cjs
CHANGED
|
@@ -485,12 +485,14 @@ var E2BProcessHandle = class extends _mastra_core_workspace.ProcessHandle {
|
|
|
485
485
|
_e2bHandle;
|
|
486
486
|
_sandbox;
|
|
487
487
|
_startTime;
|
|
488
|
+
_stdinMode;
|
|
488
489
|
constructor(e2bHandle, sandbox, startTime, options) {
|
|
489
490
|
super(options);
|
|
490
491
|
this.pid = String(e2bHandle.pid);
|
|
491
492
|
this._e2bHandle = e2bHandle;
|
|
492
493
|
this._sandbox = sandbox;
|
|
493
494
|
this._startTime = startTime;
|
|
495
|
+
this._stdinMode = options?.stdinMode;
|
|
494
496
|
}
|
|
495
497
|
/** Delegates to E2B's handle so exitCode reflects server-side state without needing wait(). */
|
|
496
498
|
get exitCode() {
|
|
@@ -531,17 +533,19 @@ var E2BProcessHandle = class extends _mastra_core_workspace.ProcessHandle {
|
|
|
531
533
|
}
|
|
532
534
|
async sendStdin(data) {
|
|
533
535
|
if (this.exitCode !== void 0) throw new Error(`Process ${this.pid} has already exited with code ${this.exitCode}`);
|
|
536
|
+
if (this._stdinMode === "ignore") throw new Error(`Process ${this.pid} was not started with stdin support`);
|
|
534
537
|
await this._sandbox.commands.sendStdin(this._e2bHandle.pid, data);
|
|
535
538
|
}
|
|
536
539
|
async closeStdin() {
|
|
537
540
|
throw new _mastra_core_workspace.UnsupportedStdinCloseError("E2B SDK does not expose a way to close stdin for a running command");
|
|
538
541
|
}
|
|
539
542
|
};
|
|
540
|
-
/**
|
|
541
|
-
* E2B implementation of SandboxProcessManager.
|
|
542
|
-
* Uses the E2B SDK's commands.run() with background: true.
|
|
543
|
-
*/
|
|
544
543
|
var E2BProcessManager = class extends _mastra_core_workspace.SandboxProcessManager {
|
|
544
|
+
_defaultTimeout;
|
|
545
|
+
constructor(opts = {}) {
|
|
546
|
+
super();
|
|
547
|
+
this._defaultTimeout = opts.defaultTimeout;
|
|
548
|
+
}
|
|
545
549
|
async spawn(command, options = {}) {
|
|
546
550
|
return this.sandbox.retryOnDead(async () => {
|
|
547
551
|
const e2b = this.sandbox.e2b;
|
|
@@ -550,10 +554,10 @@ var E2BProcessManager = class extends _mastra_core_workspace.SandboxProcessManag
|
|
|
550
554
|
let handle;
|
|
551
555
|
handle = new E2BProcessHandle(await e2b.commands.run(command, {
|
|
552
556
|
background: true,
|
|
553
|
-
stdin:
|
|
557
|
+
stdin: options.stdinMode !== "ignore",
|
|
554
558
|
cwd: options.cwd ?? this.sandbox.workingDirectory,
|
|
555
559
|
envs,
|
|
556
|
-
timeoutMs: options.timeout,
|
|
560
|
+
timeoutMs: options.timeout ?? this._defaultTimeout,
|
|
557
561
|
onStdout: (data) => handle.emitStdout(data),
|
|
558
562
|
onStderr: (data) => handle.emitStderr(data)
|
|
559
563
|
}), e2b, Date.now(), options);
|
|
@@ -707,7 +711,7 @@ var E2BSandbox = class E2BSandbox extends _mastra_core_workspace.MastraSandbox {
|
|
|
707
711
|
super({
|
|
708
712
|
...options,
|
|
709
713
|
name: "E2BSandbox",
|
|
710
|
-
processes: new E2BProcessManager()
|
|
714
|
+
processes: new E2BProcessManager({ defaultTimeout: options.timeout ?? 3e5 })
|
|
711
715
|
});
|
|
712
716
|
this.id = options.id ?? this.generateId();
|
|
713
717
|
this.timeout = options.timeout ?? 3e5;
|