@mastra/docker 0.9.1 → 0.9.2-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
@@ -3,9 +3,9 @@ import { isDeepStrictEqual, promisify } from "util";
3
3
  import { MastraSandbox, ProcessHandle, SandboxAbortError, SandboxError, SandboxNotReadyError, SandboxProcessManager, validateSandboxFileMode } from "@mastra/core/workspace";
4
4
  import Docker from "dockerode";
5
5
  import { pack } from "tar-stream";
6
- import { createHash, randomUUID } from "crypto";
7
6
  import posixPath from "path/posix";
8
7
  import { Server, ServerCredentials } from "@grpc/grpc-js";
8
+ import { createHash } from "crypto";
9
9
  import { execFile } from "child_process";
10
10
  //#region src/abort.ts
11
11
  function createAbortError(signal, operation) {
@@ -41,14 +41,6 @@ function waitForAbortable(promise, signal, operation, onAbort) {
41
41
  //#endregion
42
42
  //#region src/sandbox/process-manager.ts
43
43
  /**
44
- * Docker Process Manager
45
- *
46
- * Implements SandboxProcessManager for Docker containers.
47
- * Uses `container.exec()` to run commands inside a long-lived container.
48
- * Each spawned process gets a dedicated exec instance with separate
49
- * stdout/stderr streams.
50
- */
51
- /**
52
44
  * Directory (inside the container) where each spawned process records the PGID
53
45
  * of its process group. Created with mode 700 so only the (root) exec user can
54
46
  * write the PGID files.
@@ -354,7 +346,7 @@ var DockerProcessManager = class extends SandboxProcessManager {
354
346
  }
355
347
  async spawn(command, options = {}) {
356
348
  const container = this.container;
357
- const pgidFile = `${PROC_DIR}/${randomUUID()}`;
349
+ const pgidFile = `${PROC_DIR}/${globalThis.crypto.randomUUID()}`;
358
350
  const envArray = Object.entries({ ...options.env }).filter((entry) => entry[1] !== void 0).map(([k, v]) => `${k}=${v}`);
359
351
  const attachStdin = options.stdinMode !== "ignore";
360
352
  const exec = await container.exec({
@@ -685,6 +677,7 @@ var DockerSandbox = class DockerSandbox extends MastraSandbox {
685
677
  }
686
678
  const reconnectedWorkingDir = info.Config?.WorkingDir;
687
679
  if (!this._workingDirectoryWasSet && reconnectedWorkingDir) this.setWorkingDirectory(reconnectedWorkingDir);
680
+ if (info.Config?.Image) this._image = info.Config.Image;
688
681
  this.processes.setContainer(this._container);
689
682
  this.logger.debug(`${LOG_PREFIX} Reconnected to container ${existing.Id}`);
690
683
  return;
@@ -1338,7 +1331,7 @@ const AUTH_CREDENTIALS_METHOD = "/moby.filesync.v1.Auth/Credentials";
1338
1331
  */
1339
1332
  function openBuildSession(docker, secrets, abortSignal) {
1340
1333
  throwIfAborted(abortSignal, "build Docker template");
1341
- const id = randomUUID();
1334
+ const id = globalThis.crypto.randomUUID();
1342
1335
  return new Promise((resolve, reject) => {
1343
1336
  let settled = false;
1344
1337
  const abort = () => {