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