@mastra/e2b 0.12.1-alpha.0 → 0.12.1-alpha.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/dist/index.cjs CHANGED
@@ -540,11 +540,12 @@ var E2BProcessHandle = class extends _mastra_core_workspace.ProcessHandle {
540
540
  throw new _mastra_core_workspace.UnsupportedStdinCloseError("E2B SDK does not expose a way to close stdin for a running command");
541
541
  }
542
542
  };
543
- /**
544
- * E2B implementation of SandboxProcessManager.
545
- * Uses the E2B SDK's commands.run() with background: true.
546
- */
547
543
  var E2BProcessManager = class extends _mastra_core_workspace.SandboxProcessManager {
544
+ _defaultTimeout;
545
+ constructor(opts = {}) {
546
+ super();
547
+ this._defaultTimeout = opts.defaultTimeout;
548
+ }
548
549
  async spawn(command, options = {}) {
549
550
  return this.sandbox.retryOnDead(async () => {
550
551
  const e2b = this.sandbox.e2b;
@@ -556,7 +557,7 @@ var E2BProcessManager = class extends _mastra_core_workspace.SandboxProcessManag
556
557
  stdin: options.stdinMode !== "ignore",
557
558
  cwd: options.cwd ?? this.sandbox.workingDirectory,
558
559
  envs,
559
- timeoutMs: options.timeout,
560
+ timeoutMs: options.timeout ?? this._defaultTimeout,
560
561
  onStdout: (data) => handle.emitStdout(data),
561
562
  onStderr: (data) => handle.emitStderr(data)
562
563
  }), e2b, Date.now(), options);
@@ -710,7 +711,7 @@ var E2BSandbox = class E2BSandbox extends _mastra_core_workspace.MastraSandbox {
710
711
  super({
711
712
  ...options,
712
713
  name: "E2BSandbox",
713
- processes: new E2BProcessManager()
714
+ processes: new E2BProcessManager({ defaultTimeout: options.timeout ?? 3e5 })
714
715
  });
715
716
  this.id = options.id ?? this.generateId();
716
717
  this.timeout = options.timeout ?? 3e5;
@@ -1262,7 +1263,10 @@ var E2BSandbox = class E2BSandbox extends _mastra_core_workspace.MastraSandbox {
1262
1263
  const owner = info.metadata?.["mastra-sandbox-id"];
1263
1264
  if (owner !== void 0 && owner !== this.id) throw new Error(`${LOG_PREFIX} Provider sandbox ${preferredSandboxId} belongs to logical sandbox id "${owner}", refusing to attach it to "${this.id}"`);
1264
1265
  try {
1265
- return await e2b.Sandbox.connect(preferredSandboxId, this.connectionOpts);
1266
+ return await e2b.Sandbox.connect(preferredSandboxId, {
1267
+ ...this.connectionOpts,
1268
+ timeoutMs: this.timeout
1269
+ });
1266
1270
  } catch (e) {
1267
1271
  if (this.isSandboxDeadError(e)) {
1268
1272
  this.logger.debug(`${LOG_PREFIX} Preferred sandbox ${preferredSandboxId} vanished before connect, falling back:`, e);
@@ -1280,7 +1284,10 @@ var E2BSandbox = class E2BSandbox extends _mastra_core_workspace.MastraSandbox {
1280
1284
  const info = await this.lookupExistingSandboxInfo();
1281
1285
  if (!info) return null;
1282
1286
  try {
1283
- return await this.connectSdkSandbox(info.sandboxId, this.connectionOpts);
1287
+ return await this.connectSdkSandbox(info.sandboxId, {
1288
+ ...this.connectionOpts,
1289
+ timeoutMs: this.timeout
1290
+ });
1284
1291
  } catch (e) {
1285
1292
  this.logger.debug(`${LOG_PREFIX} Error connecting to existing sandbox:`, e);
1286
1293
  return null;