@mastra/docker 0.9.0-alpha.0 → 0.9.0-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
@@ -204,16 +204,20 @@ var DockerProcessHandle = class extends _mastra_core_workspace.ProcessHandle {
204
204
  AttachStdout: false,
205
205
  AttachStderr: false
206
206
  });
207
- await killExec.start({});
208
- let killInfo = await killExec.inspect();
209
- while (killInfo.Running) {
210
- await new Promise((resolve) => setTimeout(resolve, 10));
211
- killInfo = await killExec.inspect();
207
+ const killStream = await killExec.start({});
208
+ try {
209
+ let killInfo = await killExec.inspect();
210
+ while (killInfo.Running) {
211
+ await new Promise((resolve) => setTimeout(resolve, 10));
212
+ killInfo = await killExec.inspect();
213
+ }
214
+ if (killInfo.ExitCode !== 0) throw new Error(`kill helper exited with code ${killInfo.ExitCode}`);
215
+ this._killed = true;
216
+ this._destroyStream();
217
+ return true;
218
+ } finally {
219
+ killStream.destroy();
212
220
  }
213
- if (killInfo.ExitCode !== 0) throw new Error(`kill helper exited with code ${killInfo.ExitCode}`);
214
- this._killed = true;
215
- this._destroyStream();
216
- return true;
217
221
  } catch (error) {
218
222
  const msg = error instanceof Error ? error.message.toLowerCase() : "";
219
223
  if (!msg.includes("no such process") && !msg.includes("esrch")) console.warn(`[DockerProcessManager] kill(${this.pid}) failed unexpectedly:`, error);
@@ -270,6 +274,7 @@ var DockerProcessManager = class extends _mastra_core_workspace.SandboxProcessMa
270
274
  const container = this.container;
271
275
  const pgidFile = `${PROC_DIR}/${(0, crypto.randomUUID)()}`;
272
276
  const envArray = Object.entries({ ...options.env }).filter((entry) => entry[1] !== void 0).map(([k, v]) => `${k}=${v}`);
277
+ const attachStdin = options.stdinMode !== "ignore";
273
278
  const exec = await container.exec({
274
279
  Cmd: [
275
280
  "sh",
@@ -281,17 +286,17 @@ var DockerProcessManager = class extends _mastra_core_workspace.SandboxProcessMa
281
286
  ],
282
287
  AttachStdout: true,
283
288
  AttachStderr: true,
284
- AttachStdin: true,
289
+ AttachStdin: attachStdin,
285
290
  Tty: false,
286
291
  Env: envArray.length > 0 ? envArray : void 0,
287
292
  WorkingDir: options.cwd
288
293
  });
289
294
  const stream = await exec.start({
290
295
  hijack: true,
291
- stdin: true
296
+ stdin: attachStdin
292
297
  });
293
298
  const startTime = Date.now();
294
- const handle = new DockerProcessHandle(exec, container, startTime, stream, pgidFile, options);
299
+ const handle = new DockerProcessHandle(exec, container, startTime, attachStdin ? stream : null, pgidFile, options);
295
300
  handle._setExecStream(stream);
296
301
  const waitPromise = new Promise((resolve) => {
297
302
  const buffer = [];