@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.js CHANGED
@@ -179,16 +179,20 @@ var DockerProcessHandle = class extends ProcessHandle {
179
179
  AttachStdout: false,
180
180
  AttachStderr: false
181
181
  });
182
- await killExec.start({});
183
- let killInfo = await killExec.inspect();
184
- while (killInfo.Running) {
185
- await new Promise((resolve) => setTimeout(resolve, 10));
186
- killInfo = await killExec.inspect();
182
+ const killStream = await killExec.start({});
183
+ try {
184
+ let killInfo = await killExec.inspect();
185
+ while (killInfo.Running) {
186
+ await new Promise((resolve) => setTimeout(resolve, 10));
187
+ killInfo = await killExec.inspect();
188
+ }
189
+ if (killInfo.ExitCode !== 0) throw new Error(`kill helper exited with code ${killInfo.ExitCode}`);
190
+ this._killed = true;
191
+ this._destroyStream();
192
+ return true;
193
+ } finally {
194
+ killStream.destroy();
187
195
  }
188
- if (killInfo.ExitCode !== 0) throw new Error(`kill helper exited with code ${killInfo.ExitCode}`);
189
- this._killed = true;
190
- this._destroyStream();
191
- return true;
192
196
  } catch (error) {
193
197
  const msg = error instanceof Error ? error.message.toLowerCase() : "";
194
198
  if (!msg.includes("no such process") && !msg.includes("esrch")) console.warn(`[DockerProcessManager] kill(${this.pid}) failed unexpectedly:`, error);
@@ -245,6 +249,7 @@ var DockerProcessManager = class extends SandboxProcessManager {
245
249
  const container = this.container;
246
250
  const pgidFile = `${PROC_DIR}/${randomUUID()}`;
247
251
  const envArray = Object.entries({ ...options.env }).filter((entry) => entry[1] !== void 0).map(([k, v]) => `${k}=${v}`);
252
+ const attachStdin = options.stdinMode !== "ignore";
248
253
  const exec = await container.exec({
249
254
  Cmd: [
250
255
  "sh",
@@ -256,17 +261,17 @@ var DockerProcessManager = class extends SandboxProcessManager {
256
261
  ],
257
262
  AttachStdout: true,
258
263
  AttachStderr: true,
259
- AttachStdin: true,
264
+ AttachStdin: attachStdin,
260
265
  Tty: false,
261
266
  Env: envArray.length > 0 ? envArray : void 0,
262
267
  WorkingDir: options.cwd
263
268
  });
264
269
  const stream = await exec.start({
265
270
  hijack: true,
266
- stdin: true
271
+ stdin: attachStdin
267
272
  });
268
273
  const startTime = Date.now();
269
- const handle = new DockerProcessHandle(exec, container, startTime, stream, pgidFile, options);
274
+ const handle = new DockerProcessHandle(exec, container, startTime, attachStdin ? stream : null, pgidFile, options);
270
275
  handle._setExecStream(stream);
271
276
  const waitPromise = new Promise((resolve) => {
272
277
  const buffer = [];