@mastra/platform-workspace 1.10.0-alpha.0 → 1.10.0-alpha.2
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/factory-sandbox.d.ts +2 -0
- package/dist/factory-sandbox.d.ts.map +1 -1
- package/dist/index.cjs +33 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -33
- package/dist/index.js.map +1 -1
- package/dist/repo-template.d.ts +9 -3
- package/dist/repo-template.d.ts.map +1 -1
- package/dist/template.d.ts +7 -1
- package/dist/template.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -10,6 +10,8 @@ export interface PlatformFactorySandboxSettings extends Record<string, unknown>
|
|
|
10
10
|
cpuCount?: number;
|
|
11
11
|
/** Memory in MB for the sandbox template. Part of the template identity. */
|
|
12
12
|
memoryMb?: number;
|
|
13
|
+
/** Install Docker Engine and Compose, started on first use. Part of the template identity. */
|
|
14
|
+
docker?: boolean;
|
|
13
15
|
/** Minutes idle before the sandbox pauses. Runtime only. */
|
|
14
16
|
idleTimeoutMinutes?: number;
|
|
15
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory-sandbox.d.ts","sourceRoot":"","sources":["../src/factory-sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAIV,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAG3D,uHAAuH;AACvH,MAAM,WAAW,8BAA+B,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAA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;;GAIG;AACH,qBAAa,sBAAuB,SAAQ,cAAc,CAAC,8BAA8B,CAAC;;IACxF,QAAQ,CAAC,QAAQ,cAAc;IAC/B,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,8BAA8B,CAAC,CAAC;IAehE,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC,8BAA8B,CAAC,CAGnE;IAEF,YAAY,OAAO,GAAE,6BAAkC,EAOtD;IAED,QAAQ,CACN,GAAG,EAAE,qBAAqB,EAC1B,QAAQ,EAAE,8BAA8B,GACvC,4BAA4B,GAAG,SAAS,CAS1C;IAED,MAAM,CAAC,GAAG,EAAE,qBAAqB,EAAE,QAAQ,EAAE,8BAA8B,GAAG,eAAe,CAiB5F;CA4CF"}
|
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;
|
|
@@ -20,7 +20,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
20
20
|
value: mod,
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
|
-
//#endregion
|
|
24
23
|
let buffer = require("buffer");
|
|
25
24
|
let path = require("path");
|
|
26
25
|
path = __toESM(path, 1);
|
|
@@ -29,7 +28,7 @@ let crypto = require("crypto");
|
|
|
29
28
|
let e2b = require("e2b");
|
|
30
29
|
let child_process = require("child_process");
|
|
31
30
|
let util = require("util");
|
|
32
|
-
|
|
31
|
+
// src/client.ts
|
|
33
32
|
const DEFAULT_PROXY_URL = "https://workspaces.mastra.ai";
|
|
34
33
|
const REGIONAL_PROXY_URLS = {
|
|
35
34
|
us: "https://workspaces.us.mastra.ai",
|
|
@@ -160,8 +159,7 @@ var PlatformClient = class {
|
|
|
160
159
|
return response;
|
|
161
160
|
}
|
|
162
161
|
};
|
|
163
|
-
|
|
164
|
-
//#region src/filesystem.ts
|
|
162
|
+
// src/filesystem.ts
|
|
165
163
|
function normalizePath(input) {
|
|
166
164
|
if (!input || input === ".") return "/";
|
|
167
165
|
let normalized = input.startsWith("/") ? input : `/${input}`;
|
|
@@ -420,8 +418,7 @@ var PlatformFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
|
|
|
420
418
|
function matchesExtension$1(name, extension) {
|
|
421
419
|
return (Array.isArray(extension) ? extension : [extension]).some((ext) => name.endsWith(ext));
|
|
422
420
|
}
|
|
423
|
-
|
|
424
|
-
//#region src/template.ts
|
|
421
|
+
// src/template.ts
|
|
425
422
|
const SERIALIZE_TEMPLATE = Symbol("serializeTemplate");
|
|
426
423
|
const GET_TEMPLATE_BUILD_ENVS = Symbol("getTemplateBuildEnvs");
|
|
427
424
|
const MAX_OPERATIONS = 256;
|
|
@@ -444,6 +441,9 @@ var SerializableSandboxTemplateBuilder = class SerializableSandboxTemplateBuilde
|
|
|
444
441
|
memoryMB(memoryMB) {
|
|
445
442
|
return this.#append("memoryMB", [validateResourceValue(memoryMB, "memoryMB")]);
|
|
446
443
|
}
|
|
444
|
+
docker() {
|
|
445
|
+
return this.#append("docker", [true]);
|
|
446
|
+
}
|
|
447
447
|
async build(options = {}) {
|
|
448
448
|
return buildSandboxTemplate(this, options);
|
|
449
449
|
}
|
|
@@ -599,8 +599,7 @@ function cloneJson(value) {
|
|
|
599
599
|
if (typeof value === "number" && !Number.isFinite(value)) throw new TypeError("Sandbox template values must contain only finite numbers");
|
|
600
600
|
return value;
|
|
601
601
|
}
|
|
602
|
-
|
|
603
|
-
//#region ../../packages/_internals/workspace/dist/index.js
|
|
602
|
+
// ../../packages/_internals/workspace/dist/index.js
|
|
604
603
|
/** Directory, relative to the template's build cwd, that holds every marker below. */
|
|
605
604
|
const SETUP_MARKER_DIR = ".mastra-sandbox";
|
|
606
605
|
/**
|
|
@@ -1000,7 +999,8 @@ var FilesApiFilesystem = class extends _mastra_core_workspace.MastraFilesystem {
|
|
|
1000
999
|
type: info.type === "dir" ? "directory" : "file",
|
|
1001
1000
|
size: info.type === "dir" ? 0 : info.size,
|
|
1002
1001
|
createdAt: modifiedAt,
|
|
1003
|
-
modifiedAt
|
|
1002
|
+
modifiedAt,
|
|
1003
|
+
...info.type !== "dir" && { mimeType: (0, _mastra_core_workspace.getMimeType)(abs) }
|
|
1004
1004
|
};
|
|
1005
1005
|
});
|
|
1006
1006
|
}
|
|
@@ -1246,8 +1246,7 @@ var CommandsApiProcessManager = class extends _mastra_core_workspace.SandboxProc
|
|
|
1246
1246
|
}
|
|
1247
1247
|
}
|
|
1248
1248
|
};
|
|
1249
|
-
|
|
1250
|
-
//#region src/direct-exec.ts
|
|
1249
|
+
// src/direct-exec.ts
|
|
1251
1250
|
/**
|
|
1252
1251
|
* Direct exec client — opens Railway's tcp-proxy exec WebSocket directly using
|
|
1253
1252
|
* a short-lived JWT minted by the workspace proxy's exec-lease endpoint. This
|
|
@@ -1400,8 +1399,7 @@ function execViaLease(lease, options) {
|
|
|
1400
1399
|
}
|
|
1401
1400
|
});
|
|
1402
1401
|
}
|
|
1403
|
-
|
|
1404
|
-
//#region src/e2b-exec.ts
|
|
1402
|
+
// src/e2b-exec.ts
|
|
1405
1403
|
const E2B_ENVD_VERSION = "0.4.0";
|
|
1406
1404
|
const execViaE2BLease = async (lease, options) => {
|
|
1407
1405
|
const stdoutChunks = [];
|
|
@@ -1468,8 +1466,7 @@ const sandboxForLease = (lease) => new e2b.Sandbox({
|
|
|
1468
1466
|
const e2bFilesForLease = (lease) => sandboxForLease(lease).files;
|
|
1469
1467
|
/** Opens E2B's commands API directly against the VM, authenticated by the exec lease. */
|
|
1470
1468
|
const commandsForLease = (lease) => sandboxForLease(lease).commands;
|
|
1471
|
-
|
|
1472
|
-
//#region src/private-net-exec.ts
|
|
1469
|
+
// src/private-net-exec.ts
|
|
1473
1470
|
/**
|
|
1474
1471
|
* Thrown by {@link execViaPrivateNetwork} when the sidecar returns a non-2xx
|
|
1475
1472
|
* HTTP response. This is an *application* error, not a transport error — the
|
|
@@ -1637,8 +1634,7 @@ async function execViaPrivateNetwork(instanceUrl, options) {
|
|
|
1637
1634
|
status: response.status
|
|
1638
1635
|
};
|
|
1639
1636
|
}
|
|
1640
|
-
|
|
1641
|
-
//#region src/sandbox-filesystem.ts
|
|
1637
|
+
// src/sandbox-filesystem.ts
|
|
1642
1638
|
/**
|
|
1643
1639
|
* envd's edge answers a paused or missing sandbox with a 404 or 502 that the
|
|
1644
1640
|
* SDK reports as `FileNotFoundError` or `TimeoutError`. Same message pattern as
|
|
@@ -1678,8 +1674,7 @@ var PlatformSandboxFilesystem = class extends FilesApiFilesystem {
|
|
|
1678
1674
|
if (error instanceof e2b.InvalidArgumentError) return "invalid-argument";
|
|
1679
1675
|
}
|
|
1680
1676
|
};
|
|
1681
|
-
|
|
1682
|
-
//#region src/sandbox.ts
|
|
1677
|
+
// src/sandbox.ts
|
|
1683
1678
|
/**
|
|
1684
1679
|
* How long before a lease's stated `expiresAt` we should treat it as
|
|
1685
1680
|
* expired. Avoids a race where the JWT is valid at cache-hit time but the
|
|
@@ -2953,8 +2948,7 @@ function templateHash(definition) {
|
|
|
2953
2948
|
const { family: _family, ...content } = definition;
|
|
2954
2949
|
return (0, crypto.createHash)("sha256").update(JSON.stringify(content)).digest("hex").slice(0, 16);
|
|
2955
2950
|
}
|
|
2956
|
-
|
|
2957
|
-
//#region src/repo-template.ts
|
|
2951
|
+
// src/repo-template.ts
|
|
2958
2952
|
const execFileAsync = (0, util.promisify)(child_process.execFile);
|
|
2959
2953
|
const SHA_PATTERN = /^[0-9a-f]{7,40}$/i;
|
|
2960
2954
|
const BUILD_TOKEN_ENV = "MASTRA_REPOSITORY_ACCESS_TOKEN";
|
|
@@ -2989,9 +2983,9 @@ function rememberHead(cloneUrl, sha) {
|
|
|
2989
2983
|
* transient build envs; they never enter the serialized definition. A failed
|
|
2990
2984
|
* head lookup reuses the last head resolved for the same clone URL in this
|
|
2991
2985
|
* process. If the repository cannot be resolved, or no head has been resolved
|
|
2992
|
-
* yet, the resolver keeps `cpuCount` and
|
|
2993
|
-
* `
|
|
2994
|
-
* requested size, and the caller's runtime setup materializes the checkout.
|
|
2986
|
+
* yet, the resolver keeps `cpuCount`, `memoryMB` and
|
|
2987
|
+
* `docker` in a resources-only template so the sandbox still boots at the
|
|
2988
|
+
* requested size with Docker when asked, and the caller's runtime setup materializes the checkout.
|
|
2995
2989
|
*/
|
|
2996
2990
|
function createRepoTemplate(options) {
|
|
2997
2991
|
if (options.getRepositoryAccess && options.repos) throw new TypeError("createRepoTemplate: pass either getRepositoryAccess or repos, not both");
|
|
@@ -3002,7 +2996,7 @@ function createRepoTemplate(options) {
|
|
|
3002
2996
|
setupCommand: options.setupCommand
|
|
3003
2997
|
}] : [];
|
|
3004
2998
|
const resourcesOnly = () => {
|
|
3005
|
-
if (options.cpuCount === void 0 && options.memoryMB === void 0) return void 0;
|
|
2999
|
+
if (options.cpuCount === void 0 && options.memoryMB === void 0 && !options.docker) return void 0;
|
|
3006
3000
|
return withResources(Template(), options);
|
|
3007
3001
|
};
|
|
3008
3002
|
if (entries.length === 0) {
|
|
@@ -3120,6 +3114,7 @@ function createRepoTemplate(options) {
|
|
|
3120
3114
|
function withResources(template, options) {
|
|
3121
3115
|
if (options.cpuCount !== void 0) template = template.cpuCount(options.cpuCount);
|
|
3122
3116
|
if (options.memoryMB !== void 0) template = template.memoryMB(options.memoryMB);
|
|
3117
|
+
if (options.docker) template = template.docker();
|
|
3123
3118
|
return template;
|
|
3124
3119
|
}
|
|
3125
3120
|
function isValidCloneUrl(cloneUrl) {
|
|
@@ -3243,8 +3238,7 @@ async function resolveDefaultBranchHead(cloneUrl, token, execute = execFileAsync
|
|
|
3243
3238
|
throw new Error(`git ls-remote failed: ${detail}`);
|
|
3244
3239
|
}
|
|
3245
3240
|
}
|
|
3246
|
-
|
|
3247
|
-
//#region src/provider.ts
|
|
3241
|
+
// src/provider.ts
|
|
3248
3242
|
const platformSandboxProvider = {
|
|
3249
3243
|
id: "platform",
|
|
3250
3244
|
name: "Mastra Platform Sandbox",
|
|
@@ -3329,12 +3323,12 @@ const platformFilesystemProvider = {
|
|
|
3329
3323
|
},
|
|
3330
3324
|
createFilesystem: (config) => new PlatformFilesystem(config)
|
|
3331
3325
|
};
|
|
3332
|
-
|
|
3333
|
-
//#region src/factory-sandbox.ts
|
|
3326
|
+
// src/factory-sandbox.ts
|
|
3334
3327
|
/** Applied when neither the environment setting nor a host default is set. */
|
|
3335
3328
|
const DEFAULT_SETTINGS = {
|
|
3336
3329
|
cpuCount: 2,
|
|
3337
3330
|
memoryMb: 1024,
|
|
3331
|
+
docker: false,
|
|
3338
3332
|
idleTimeoutMinutes: 5
|
|
3339
3333
|
};
|
|
3340
3334
|
const SETTINGS_SCHEMA = {
|
|
@@ -3376,6 +3370,12 @@ const SETTINGS_SCHEMA = {
|
|
|
3376
3370
|
}
|
|
3377
3371
|
]
|
|
3378
3372
|
},
|
|
3373
|
+
docker: {
|
|
3374
|
+
type: "boolean",
|
|
3375
|
+
title: "Docker",
|
|
3376
|
+
description: "Install Docker Engine and Compose; the daemon starts on first use. E2B recommends at least 2 GB of memory for Docker.",
|
|
3377
|
+
default: DEFAULT_SETTINGS.docker
|
|
3378
|
+
},
|
|
3379
3379
|
idleTimeoutMinutes: {
|
|
3380
3380
|
type: "integer",
|
|
3381
3381
|
title: "Idle timeout (minutes)",
|
|
@@ -3445,7 +3445,8 @@ var PlatformFactorySandbox = class extends _mastra_core_workspace.FactorySandbox
|
|
|
3445
3445
|
...ctx,
|
|
3446
3446
|
...template?.buildEnv ? { buildEnv: template.buildEnv } : {},
|
|
3447
3447
|
cpuCount: settings.cpuCount ?? defaults?.cpuCount ?? DEFAULT_SETTINGS.cpuCount,
|
|
3448
|
-
memoryMB: settings.memoryMb ?? defaults?.memoryMb ?? DEFAULT_SETTINGS.memoryMb
|
|
3448
|
+
memoryMB: settings.memoryMb ?? defaults?.memoryMb ?? DEFAULT_SETTINGS.memoryMb,
|
|
3449
|
+
docker: settings.docker ?? defaults?.docker ?? DEFAULT_SETTINGS.docker
|
|
3449
3450
|
});
|
|
3450
3451
|
}
|
|
3451
3452
|
create(ctx, settings) {
|
|
@@ -3500,8 +3501,7 @@ function toBuild(result) {
|
|
|
3500
3501
|
...result.error ? { error: result.error } : {}
|
|
3501
3502
|
};
|
|
3502
3503
|
}
|
|
3503
|
-
|
|
3504
|
-
//#region src/address-registry.ts
|
|
3504
|
+
// src/address-registry.ts
|
|
3505
3505
|
/**
|
|
3506
3506
|
* Concrete in-process {@link SandboxAddressRegistry}. Backed by a `Map`; no
|
|
3507
3507
|
* eviction policy, no TTL — entries live until an observed transport failure
|
|
@@ -3533,7 +3533,6 @@ var InProcessSandboxAddressRegistry = class {
|
|
|
3533
3533
|
return this.#map.size;
|
|
3534
3534
|
}
|
|
3535
3535
|
};
|
|
3536
|
-
//#endregion
|
|
3537
3536
|
exports.InProcessSandboxAddressRegistry = InProcessSandboxAddressRegistry;
|
|
3538
3537
|
exports.PlatformApiError = PlatformApiError;
|
|
3539
3538
|
exports.PlatformClient = PlatformClient;
|