@mastra/docker 0.12.0-alpha.2 → 0.12.1-alpha.0

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
@@ -8,7 +8,7 @@ import posixPath from "path/posix";
8
8
  import { Server, ServerCredentials } from "@grpc/grpc-js";
9
9
  import { createHash } from "crypto";
10
10
  import { execFile } from "child_process";
11
- //#region src/abort.ts
11
+ // src/abort.ts
12
12
  function createAbortError(signal, operation) {
13
13
  return new SandboxAbortError(operation, signal.reason);
14
14
  }
@@ -39,8 +39,7 @@ function waitForAbortable(promise, signal, operation, onAbort) {
39
39
  });
40
40
  });
41
41
  }
42
- //#endregion
43
- //#region src/sandbox/process-manager.ts
42
+ // src/sandbox/process-manager.ts
44
43
  /**
45
44
  * Directory (inside the container) where each spawned process records the PGID
46
45
  * of its process group. Created with mode 700 so only the (root) exec user can
@@ -524,8 +523,7 @@ var DockerProcessManager = class extends SandboxProcessManager {
524
523
  return results;
525
524
  }
526
525
  };
527
- //#endregion
528
- //#region src/sandbox/index.ts
526
+ // src/sandbox/index.ts
529
527
  /**
530
528
  * Docker Sandbox Provider
531
529
  *
@@ -1145,8 +1143,7 @@ function toDockerSandboxOptionName(field) {
1145
1143
  Mounts: "mounts"
1146
1144
  }[field] ?? String(field);
1147
1145
  }
1148
- //#endregion
1149
- //#region src/provider.ts
1146
+ // src/provider.ts
1150
1147
  const dockerSandboxProvider = {
1151
1148
  id: "docker",
1152
1149
  name: "Docker Sandbox",
@@ -1339,8 +1336,7 @@ const dockerSandboxProvider = {
1339
1336
  },
1340
1337
  createSandbox: (config) => new DockerSandbox(config)
1341
1338
  };
1342
- //#endregion
1343
- //#region src/template/build-progress.ts
1339
+ // src/template/build-progress.ts
1344
1340
  /**
1345
1341
  * Build progress for `DockerTemplate.build()`.
1346
1342
  *
@@ -1350,7 +1346,7 @@ const dockerSandboxProvider = {
1350
1346
  * module normalizes both into {@link DockerTemplateBuildEvent}s and keeps a
1351
1347
  * bounded tail of raw output for failure diagnostics.
1352
1348
  */
1353
- const DEFAULT_MAX_OUTPUT_BYTES = 64 * 1024;
1349
+ const DEFAULT_MAX_OUTPUT_BYTES = 65536;
1354
1350
  /** Keeps at most `maxBytes` (UTF-8) of the most recent text. */
1355
1351
  var BoundedTail = class {
1356
1352
  #maxBytes;
@@ -1620,8 +1616,7 @@ function createBuildEventNormalizer(emit, tail) {
1620
1616
  failure: () => failure
1621
1617
  };
1622
1618
  }
1623
- //#endregion
1624
- //#region src/template/build-session.ts
1619
+ // src/template/build-session.ts
1625
1620
  /**
1626
1621
  * BuildKit session that serves build secrets to the daemon.
1627
1622
  *
@@ -1786,8 +1781,7 @@ const authService = { Credentials: {
1786
1781
  throw new Error("server does not deserialize responses");
1787
1782
  }
1788
1783
  } };
1789
- //#endregion
1790
- //#region src/template/dockerfile.ts
1784
+ // src/template/dockerfile.ts
1791
1785
  /**
1792
1786
  * Pure Dockerfile synthesis and content-addressed identity for DockerTemplate.
1793
1787
  *
@@ -1902,9 +1896,7 @@ function synthesizeDockerfile(definition) {
1902
1896
  case "pipInstall":
1903
1897
  lines.push(renderPipInstall(operation.args[0], operation.args[1]));
1904
1898
  break;
1905
- case "npmInstall":
1906
- lines.push(renderNpmInstall(operation.args[0], operation.args[1]));
1907
- break;
1899
+ case "npmInstall": lines.push(renderNpmInstall(operation.args[0], operation.args[1]));
1908
1900
  }
1909
1901
  });
1910
1902
  return `${lines.join("\n")}\n`;
@@ -1955,8 +1947,7 @@ function templateIdentity(definition) {
1955
1947
  function templateImageTag(definition) {
1956
1948
  return `${TEMPLATE_IMAGE_REPO}:${templateIdentity(definition)}`;
1957
1949
  }
1958
- //#endregion
1959
- //#region src/template/template.ts
1950
+ // src/template/template.ts
1960
1951
  /**
1961
1952
  * DockerTemplate — a reusable prepared baseline for the local Docker sandbox.
1962
1953
  *
@@ -1989,7 +1980,7 @@ function templateImageTag(definition) {
1989
1980
  * ```
1990
1981
  */
1991
1982
  const MAX_OPERATIONS = 256;
1992
- const MAX_STRING_LENGTH = 32 * 1024;
1983
+ const MAX_STRING_LENGTH = 32768;
1993
1984
  const MAX_COLLECTION_ITEMS = 512;
1994
1985
  /**
1995
1986
  * Immutable, chainable builder + build/lifecycle for a local Docker template.
@@ -2229,6 +2220,7 @@ var DockerTemplate = class DockerTemplate {
2229
2220
  const context = pack();
2230
2221
  context.entry({ name: "Dockerfile" }, this.dockerfile);
2231
2222
  context.finalize();
2223
+ const contextStream = context;
2232
2224
  const tail = new BoundedTail(maxOutputBytes);
2233
2225
  const normalizer = createBuildEventNormalizer(emit, tail);
2234
2226
  emit({
@@ -2239,14 +2231,14 @@ var DockerTemplate = class DockerTemplate {
2239
2231
  try {
2240
2232
  const nocache = options.force === true;
2241
2233
  if (secrets) {
2242
- const { stream, session } = await this.#buildWithSecrets(docker, context, tag, secrets, nocache, abortSignal);
2234
+ const { stream, session } = await this.#buildWithSecrets(docker, contextStream, tag, secrets, nocache, abortSignal);
2243
2235
  try {
2244
2236
  await this.#followBuild(docker, stream, normalizer, abortSignal);
2245
2237
  } finally {
2246
2238
  session.close();
2247
2239
  }
2248
2240
  } else {
2249
- const stream = await waitForAbortable(docker.buildImage(context, {
2241
+ const stream = await waitForAbortable(docker.buildImage(contextStream, {
2250
2242
  t: tag,
2251
2243
  nocache,
2252
2244
  forcerm: true
@@ -2257,7 +2249,7 @@ var DockerTemplate = class DockerTemplate {
2257
2249
  }
2258
2250
  return stream;
2259
2251
  }), abortSignal, "build Docker template", () => {
2260
- context.destroy?.();
2252
+ context.destroy();
2261
2253
  });
2262
2254
  await this.#followBuild(docker, stream, normalizer, abortSignal);
2263
2255
  }
@@ -2475,8 +2467,7 @@ function isImageNotFoundError(error) {
2475
2467
  }
2476
2468
  return false;
2477
2469
  }
2478
- //#endregion
2479
- //#region ../../packages/_internals/workspace/dist/index.js
2470
+ // ../../packages/_internals/workspace/dist/index.js
2480
2471
  /** Directory, relative to the template's build cwd, that holds every marker below. */
2481
2472
  const SETUP_MARKER_DIR = ".mastra-sandbox";
2482
2473
  /**
@@ -2536,13 +2527,19 @@ const REPO_DIR_PATTERN = /^[\w.-]+$/;
2536
2527
  function guardedSetupCommand({ repoDir, command, continueOnFailure }) {
2537
2528
  if (!REPO_DIR_PATTERN.test(repoDir)) throw new TypeError(`Repository directory "${repoDir}" must match ${REPO_DIR_PATTERN}.`);
2538
2529
  if (!continueOnFailure) return `cd "${repoDir}" && ${command}`;
2539
- return `( cd "${repoDir}" && sh -c ${shellQuote$1(command)} ) || { mkdir -p "${SETUP_MARKER_DIR}" && grep -qxF -- '${repoDir}' "${SETUP_FAILED_MARKER_PATH}" 2>/dev/null || printf '%s\\n' '${repoDir}' >> "${SETUP_FAILED_MARKER_PATH}"; }`;
2530
+ return `( cd "${repoDir}" && sh -c ${shellQuote$2(command)} ) || { mkdir -p "${SETUP_MARKER_DIR}" && grep -qxF -- '${repoDir}' "${SETUP_FAILED_MARKER_PATH}" 2>/dev/null || printf '%s\\n' '${repoDir}' >> "${SETUP_FAILED_MARKER_PATH}"; }`;
2540
2531
  }
2541
- function shellQuote$1(value) {
2532
+ function shellQuote$2(value) {
2542
2533
  return `'${value.replace(/'/g, `'\\''`)}'`;
2543
2534
  }
2544
- //#endregion
2545
- //#region src/template/repo-template.ts
2535
+ const { notFound, isDirectory, exists, notDirectory, destIsDirectory } = {
2536
+ notFound: 20,
2537
+ isDirectory: 21,
2538
+ exists: 22,
2539
+ notDirectory: 23,
2540
+ destIsDirectory: 24
2541
+ };
2542
+ // src/template/repo-template.ts
2546
2543
  /**
2547
2544
  * createDockerRepoTemplate — a repo checkout plus setup commands as a
2548
2545
  * reusable, content-addressed local image, with the same contract as the
@@ -2814,8 +2811,7 @@ function trimTrailingSlashes(path) {
2814
2811
  function shellQuote(value) {
2815
2812
  return `'${value.replace(/'/g, `'\\''`)}'`;
2816
2813
  }
2817
- //#endregion
2818
- //#region src/factory-sandbox.ts
2814
+ // src/factory-sandbox.ts
2819
2815
  const SETTINGS_SCHEMA = {
2820
2816
  type: "object",
2821
2817
  properties: {
@@ -2926,7 +2922,6 @@ var DockerFactorySandbox = class extends FactorySandbox {
2926
2922
  });
2927
2923
  }
2928
2924
  };
2929
- //#endregion
2930
2925
  export { DockerFactorySandbox, DockerProcessManager, DockerSandbox, DockerTemplate, TEMPLATE_IMAGE_REPO, createDockerRepoTemplate, dockerSandboxProvider, secretNames, synthesizeDockerfile, templateIdentity, templateImageTag };
2931
2926
 
2932
2927
  //# sourceMappingURL=index.js.map