@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.cjs +30 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -32
- package/dist/index.js.map +1 -1
- package/dist/sandbox/index.d.ts.map +1 -1
- package/dist/template/template.d.ts.map +1 -1
- package/package.json +15 -16
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
// \0rolldown/runtime.js
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -16,11 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
20
20
|
value: mod,
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
|
-
//#endregion
|
|
24
23
|
let path = require("path");
|
|
25
24
|
let util = require("util");
|
|
26
25
|
let _mastra_core_workspace = require("@mastra/core/workspace");
|
|
@@ -33,7 +32,7 @@ path_posix = __toESM(path_posix, 1);
|
|
|
33
32
|
let _grpc_grpc_js = require("@grpc/grpc-js");
|
|
34
33
|
let crypto = require("crypto");
|
|
35
34
|
let child_process = require("child_process");
|
|
36
|
-
|
|
35
|
+
// src/abort.ts
|
|
37
36
|
function createAbortError(signal, operation) {
|
|
38
37
|
return new _mastra_core_workspace.SandboxAbortError(operation, signal.reason);
|
|
39
38
|
}
|
|
@@ -64,8 +63,7 @@ function waitForAbortable(promise, signal, operation, onAbort) {
|
|
|
64
63
|
});
|
|
65
64
|
});
|
|
66
65
|
}
|
|
67
|
-
|
|
68
|
-
//#region src/sandbox/process-manager.ts
|
|
66
|
+
// src/sandbox/process-manager.ts
|
|
69
67
|
/**
|
|
70
68
|
* Directory (inside the container) where each spawned process records the PGID
|
|
71
69
|
* of its process group. Created with mode 700 so only the (root) exec user can
|
|
@@ -549,8 +547,7 @@ var DockerProcessManager = class extends _mastra_core_workspace.SandboxProcessMa
|
|
|
549
547
|
return results;
|
|
550
548
|
}
|
|
551
549
|
};
|
|
552
|
-
|
|
553
|
-
//#region src/sandbox/index.ts
|
|
550
|
+
// src/sandbox/index.ts
|
|
554
551
|
/**
|
|
555
552
|
* Docker Sandbox Provider
|
|
556
553
|
*
|
|
@@ -1084,7 +1081,7 @@ function normalizeHostConfigValue(field, value) {
|
|
|
1084
1081
|
}
|
|
1085
1082
|
if (field === "Tmpfs" && value && typeof value === "object" && !Array.isArray(value)) {
|
|
1086
1083
|
if (Object.keys(value).length === 0) return void 0;
|
|
1087
|
-
return Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([path
|
|
1084
|
+
return Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([path, options]) => [path, typeof options === "string" ? normalizeTmpfsOptions(options) : options]));
|
|
1088
1085
|
}
|
|
1089
1086
|
if (Array.isArray(value)) {
|
|
1090
1087
|
if (field === "Ulimits" && value.length === 0) return void 0;
|
|
@@ -1170,8 +1167,7 @@ function toDockerSandboxOptionName(field) {
|
|
|
1170
1167
|
Mounts: "mounts"
|
|
1171
1168
|
}[field] ?? String(field);
|
|
1172
1169
|
}
|
|
1173
|
-
|
|
1174
|
-
//#region src/provider.ts
|
|
1170
|
+
// src/provider.ts
|
|
1175
1171
|
const dockerSandboxProvider = {
|
|
1176
1172
|
id: "docker",
|
|
1177
1173
|
name: "Docker Sandbox",
|
|
@@ -1364,8 +1360,7 @@ const dockerSandboxProvider = {
|
|
|
1364
1360
|
},
|
|
1365
1361
|
createSandbox: (config) => new DockerSandbox(config)
|
|
1366
1362
|
};
|
|
1367
|
-
|
|
1368
|
-
//#region src/template/build-progress.ts
|
|
1363
|
+
// src/template/build-progress.ts
|
|
1369
1364
|
/**
|
|
1370
1365
|
* Build progress for `DockerTemplate.build()`.
|
|
1371
1366
|
*
|
|
@@ -1375,7 +1370,7 @@ const dockerSandboxProvider = {
|
|
|
1375
1370
|
* module normalizes both into {@link DockerTemplateBuildEvent}s and keeps a
|
|
1376
1371
|
* bounded tail of raw output for failure diagnostics.
|
|
1377
1372
|
*/
|
|
1378
|
-
const DEFAULT_MAX_OUTPUT_BYTES =
|
|
1373
|
+
const DEFAULT_MAX_OUTPUT_BYTES = 65536;
|
|
1379
1374
|
/** Keeps at most `maxBytes` (UTF-8) of the most recent text. */
|
|
1380
1375
|
var BoundedTail = class {
|
|
1381
1376
|
#maxBytes;
|
|
@@ -1645,8 +1640,7 @@ function createBuildEventNormalizer(emit, tail) {
|
|
|
1645
1640
|
failure: () => failure
|
|
1646
1641
|
};
|
|
1647
1642
|
}
|
|
1648
|
-
|
|
1649
|
-
//#region src/template/build-session.ts
|
|
1643
|
+
// src/template/build-session.ts
|
|
1650
1644
|
/**
|
|
1651
1645
|
* BuildKit session that serves build secrets to the daemon.
|
|
1652
1646
|
*
|
|
@@ -1811,8 +1805,7 @@ const authService = { Credentials: {
|
|
|
1811
1805
|
throw new Error("server does not deserialize responses");
|
|
1812
1806
|
}
|
|
1813
1807
|
} };
|
|
1814
|
-
|
|
1815
|
-
//#region src/template/dockerfile.ts
|
|
1808
|
+
// src/template/dockerfile.ts
|
|
1816
1809
|
/**
|
|
1817
1810
|
* Pure Dockerfile synthesis and content-addressed identity for DockerTemplate.
|
|
1818
1811
|
*
|
|
@@ -1927,9 +1920,7 @@ function synthesizeDockerfile(definition) {
|
|
|
1927
1920
|
case "pipInstall":
|
|
1928
1921
|
lines.push(renderPipInstall(operation.args[0], operation.args[1]));
|
|
1929
1922
|
break;
|
|
1930
|
-
case "npmInstall":
|
|
1931
|
-
lines.push(renderNpmInstall(operation.args[0], operation.args[1]));
|
|
1932
|
-
break;
|
|
1923
|
+
case "npmInstall": lines.push(renderNpmInstall(operation.args[0], operation.args[1]));
|
|
1933
1924
|
}
|
|
1934
1925
|
});
|
|
1935
1926
|
return `${lines.join("\n")}\n`;
|
|
@@ -1980,8 +1971,7 @@ function templateIdentity(definition) {
|
|
|
1980
1971
|
function templateImageTag(definition) {
|
|
1981
1972
|
return `${TEMPLATE_IMAGE_REPO}:${templateIdentity(definition)}`;
|
|
1982
1973
|
}
|
|
1983
|
-
|
|
1984
|
-
//#region src/template/template.ts
|
|
1974
|
+
// src/template/template.ts
|
|
1985
1975
|
/**
|
|
1986
1976
|
* DockerTemplate — a reusable prepared baseline for the local Docker sandbox.
|
|
1987
1977
|
*
|
|
@@ -2014,7 +2004,7 @@ function templateImageTag(definition) {
|
|
|
2014
2004
|
* ```
|
|
2015
2005
|
*/
|
|
2016
2006
|
const MAX_OPERATIONS = 256;
|
|
2017
|
-
const MAX_STRING_LENGTH =
|
|
2007
|
+
const MAX_STRING_LENGTH = 32768;
|
|
2018
2008
|
const MAX_COLLECTION_ITEMS = 512;
|
|
2019
2009
|
/**
|
|
2020
2010
|
* Immutable, chainable builder + build/lifecycle for a local Docker template.
|
|
@@ -2254,6 +2244,7 @@ var DockerTemplate = class DockerTemplate {
|
|
|
2254
2244
|
const context = (0, tar_stream.pack)();
|
|
2255
2245
|
context.entry({ name: "Dockerfile" }, this.dockerfile);
|
|
2256
2246
|
context.finalize();
|
|
2247
|
+
const contextStream = context;
|
|
2257
2248
|
const tail = new BoundedTail(maxOutputBytes);
|
|
2258
2249
|
const normalizer = createBuildEventNormalizer(emit, tail);
|
|
2259
2250
|
emit({
|
|
@@ -2264,14 +2255,14 @@ var DockerTemplate = class DockerTemplate {
|
|
|
2264
2255
|
try {
|
|
2265
2256
|
const nocache = options.force === true;
|
|
2266
2257
|
if (secrets) {
|
|
2267
|
-
const { stream, session } = await this.#buildWithSecrets(docker,
|
|
2258
|
+
const { stream, session } = await this.#buildWithSecrets(docker, contextStream, tag, secrets, nocache, abortSignal);
|
|
2268
2259
|
try {
|
|
2269
2260
|
await this.#followBuild(docker, stream, normalizer, abortSignal);
|
|
2270
2261
|
} finally {
|
|
2271
2262
|
session.close();
|
|
2272
2263
|
}
|
|
2273
2264
|
} else {
|
|
2274
|
-
const stream = await waitForAbortable(docker.buildImage(
|
|
2265
|
+
const stream = await waitForAbortable(docker.buildImage(contextStream, {
|
|
2275
2266
|
t: tag,
|
|
2276
2267
|
nocache,
|
|
2277
2268
|
forcerm: true
|
|
@@ -2282,7 +2273,7 @@ var DockerTemplate = class DockerTemplate {
|
|
|
2282
2273
|
}
|
|
2283
2274
|
return stream;
|
|
2284
2275
|
}), abortSignal, "build Docker template", () => {
|
|
2285
|
-
context.destroy
|
|
2276
|
+
context.destroy();
|
|
2286
2277
|
});
|
|
2287
2278
|
await this.#followBuild(docker, stream, normalizer, abortSignal);
|
|
2288
2279
|
}
|
|
@@ -2500,8 +2491,7 @@ function isImageNotFoundError(error) {
|
|
|
2500
2491
|
}
|
|
2501
2492
|
return false;
|
|
2502
2493
|
}
|
|
2503
|
-
|
|
2504
|
-
//#region ../../packages/_internals/workspace/dist/index.js
|
|
2494
|
+
// ../../packages/_internals/workspace/dist/index.js
|
|
2505
2495
|
/** Directory, relative to the template's build cwd, that holds every marker below. */
|
|
2506
2496
|
const SETUP_MARKER_DIR = ".mastra-sandbox";
|
|
2507
2497
|
/**
|
|
@@ -2561,13 +2551,19 @@ const REPO_DIR_PATTERN = /^[\w.-]+$/;
|
|
|
2561
2551
|
function guardedSetupCommand({ repoDir, command, continueOnFailure }) {
|
|
2562
2552
|
if (!REPO_DIR_PATTERN.test(repoDir)) throw new TypeError(`Repository directory "${repoDir}" must match ${REPO_DIR_PATTERN}.`);
|
|
2563
2553
|
if (!continueOnFailure) return `cd "${repoDir}" && ${command}`;
|
|
2564
|
-
return `( cd "${repoDir}" && sh -c ${shellQuote$
|
|
2554
|
+
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}"; }`;
|
|
2565
2555
|
}
|
|
2566
|
-
function shellQuote$
|
|
2556
|
+
function shellQuote$2(value) {
|
|
2567
2557
|
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
2568
2558
|
}
|
|
2569
|
-
|
|
2570
|
-
|
|
2559
|
+
const { notFound, isDirectory, exists, notDirectory, destIsDirectory } = {
|
|
2560
|
+
notFound: 20,
|
|
2561
|
+
isDirectory: 21,
|
|
2562
|
+
exists: 22,
|
|
2563
|
+
notDirectory: 23,
|
|
2564
|
+
destIsDirectory: 24
|
|
2565
|
+
};
|
|
2566
|
+
// src/template/repo-template.ts
|
|
2571
2567
|
/**
|
|
2572
2568
|
* createDockerRepoTemplate — a repo checkout plus setup commands as a
|
|
2573
2569
|
* reusable, content-addressed local image, with the same contract as the
|
|
@@ -2839,8 +2835,7 @@ function trimTrailingSlashes(path) {
|
|
|
2839
2835
|
function shellQuote(value) {
|
|
2840
2836
|
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
2841
2837
|
}
|
|
2842
|
-
|
|
2843
|
-
//#region src/factory-sandbox.ts
|
|
2838
|
+
// src/factory-sandbox.ts
|
|
2844
2839
|
const SETTINGS_SCHEMA = {
|
|
2845
2840
|
type: "object",
|
|
2846
2841
|
properties: {
|
|
@@ -2951,7 +2946,6 @@ var DockerFactorySandbox = class extends _mastra_core_workspace.FactorySandbox {
|
|
|
2951
2946
|
});
|
|
2952
2947
|
}
|
|
2953
2948
|
};
|
|
2954
|
-
//#endregion
|
|
2955
2949
|
exports.DockerFactorySandbox = DockerFactorySandbox;
|
|
2956
2950
|
exports.DockerProcessManager = DockerProcessManager;
|
|
2957
2951
|
exports.DockerSandbox = DockerSandbox;
|