@mastra/platform-workspace 1.10.0-alpha.0 → 1.10.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.cjs +16 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -28
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Buffer as Buffer$1 } from "buffer";
|
|
2
2
|
import nodePath, { posix } from "path";
|
|
3
|
-
import { DirectoryNotEmptyError, DirectoryNotFoundError, FactorySandbox, FileExistsError, FileNotFoundError, IsDirectoryError, MastraFilesystem, MastraSandbox, NotDirectoryError, ProcessHandle, SandboxError, SandboxNotReadyError, SandboxProcessManager, UnsupportedStdinCloseError, WorkspaceReadOnlyError } from "@mastra/core/workspace";
|
|
3
|
+
import { DirectoryNotEmptyError, DirectoryNotFoundError, FactorySandbox, FileExistsError, FileNotFoundError, IsDirectoryError, MastraFilesystem, MastraSandbox, NotDirectoryError, ProcessHandle, SandboxError, SandboxNotReadyError, SandboxProcessManager, UnsupportedStdinCloseError, WorkspaceReadOnlyError, getMimeType } from "@mastra/core/workspace";
|
|
4
4
|
import { createHash } from "crypto";
|
|
5
5
|
import { AuthenticationError, CommandExitError, InvalidArgumentError, NotFoundError, Sandbox, SandboxError as SandboxError$1, SandboxNotFoundError, TimeoutError } from "e2b";
|
|
6
6
|
import { execFile } from "child_process";
|
|
7
7
|
import { promisify } from "util";
|
|
8
|
-
|
|
8
|
+
// src/client.ts
|
|
9
9
|
const DEFAULT_PROXY_URL = "https://workspaces.mastra.ai";
|
|
10
10
|
const REGIONAL_PROXY_URLS = {
|
|
11
11
|
us: "https://workspaces.us.mastra.ai",
|
|
@@ -136,8 +136,7 @@ var PlatformClient = class {
|
|
|
136
136
|
return response;
|
|
137
137
|
}
|
|
138
138
|
};
|
|
139
|
-
|
|
140
|
-
//#region src/filesystem.ts
|
|
139
|
+
// src/filesystem.ts
|
|
141
140
|
function normalizePath(input) {
|
|
142
141
|
if (!input || input === ".") return "/";
|
|
143
142
|
let normalized = input.startsWith("/") ? input : `/${input}`;
|
|
@@ -396,8 +395,7 @@ var PlatformFilesystem = class extends MastraFilesystem {
|
|
|
396
395
|
function matchesExtension$1(name, extension) {
|
|
397
396
|
return (Array.isArray(extension) ? extension : [extension]).some((ext) => name.endsWith(ext));
|
|
398
397
|
}
|
|
399
|
-
|
|
400
|
-
//#region src/template.ts
|
|
398
|
+
// src/template.ts
|
|
401
399
|
const SERIALIZE_TEMPLATE = Symbol("serializeTemplate");
|
|
402
400
|
const GET_TEMPLATE_BUILD_ENVS = Symbol("getTemplateBuildEnvs");
|
|
403
401
|
const MAX_OPERATIONS = 256;
|
|
@@ -575,8 +573,7 @@ function cloneJson(value) {
|
|
|
575
573
|
if (typeof value === "number" && !Number.isFinite(value)) throw new TypeError("Sandbox template values must contain only finite numbers");
|
|
576
574
|
return value;
|
|
577
575
|
}
|
|
578
|
-
|
|
579
|
-
//#region ../../packages/_internals/workspace/dist/index.js
|
|
576
|
+
// ../../packages/_internals/workspace/dist/index.js
|
|
580
577
|
/** Directory, relative to the template's build cwd, that holds every marker below. */
|
|
581
578
|
const SETUP_MARKER_DIR = ".mastra-sandbox";
|
|
582
579
|
/**
|
|
@@ -976,7 +973,8 @@ var FilesApiFilesystem = class extends MastraFilesystem {
|
|
|
976
973
|
type: info.type === "dir" ? "directory" : "file",
|
|
977
974
|
size: info.type === "dir" ? 0 : info.size,
|
|
978
975
|
createdAt: modifiedAt,
|
|
979
|
-
modifiedAt
|
|
976
|
+
modifiedAt,
|
|
977
|
+
...info.type !== "dir" && { mimeType: getMimeType(abs) }
|
|
980
978
|
};
|
|
981
979
|
});
|
|
982
980
|
}
|
|
@@ -1222,8 +1220,7 @@ var CommandsApiProcessManager = class extends SandboxProcessManager {
|
|
|
1222
1220
|
}
|
|
1223
1221
|
}
|
|
1224
1222
|
};
|
|
1225
|
-
|
|
1226
|
-
//#region src/direct-exec.ts
|
|
1223
|
+
// src/direct-exec.ts
|
|
1227
1224
|
/**
|
|
1228
1225
|
* Direct exec client — opens Railway's tcp-proxy exec WebSocket directly using
|
|
1229
1226
|
* a short-lived JWT minted by the workspace proxy's exec-lease endpoint. This
|
|
@@ -1376,8 +1373,7 @@ function execViaLease(lease, options) {
|
|
|
1376
1373
|
}
|
|
1377
1374
|
});
|
|
1378
1375
|
}
|
|
1379
|
-
|
|
1380
|
-
//#region src/e2b-exec.ts
|
|
1376
|
+
// src/e2b-exec.ts
|
|
1381
1377
|
const E2B_ENVD_VERSION = "0.4.0";
|
|
1382
1378
|
const execViaE2BLease = async (lease, options) => {
|
|
1383
1379
|
const stdoutChunks = [];
|
|
@@ -1444,8 +1440,7 @@ const sandboxForLease = (lease) => new Sandbox({
|
|
|
1444
1440
|
const e2bFilesForLease = (lease) => sandboxForLease(lease).files;
|
|
1445
1441
|
/** Opens E2B's commands API directly against the VM, authenticated by the exec lease. */
|
|
1446
1442
|
const commandsForLease = (lease) => sandboxForLease(lease).commands;
|
|
1447
|
-
|
|
1448
|
-
//#region src/private-net-exec.ts
|
|
1443
|
+
// src/private-net-exec.ts
|
|
1449
1444
|
/**
|
|
1450
1445
|
* Thrown by {@link execViaPrivateNetwork} when the sidecar returns a non-2xx
|
|
1451
1446
|
* HTTP response. This is an *application* error, not a transport error — the
|
|
@@ -1613,8 +1608,7 @@ async function execViaPrivateNetwork(instanceUrl, options) {
|
|
|
1613
1608
|
status: response.status
|
|
1614
1609
|
};
|
|
1615
1610
|
}
|
|
1616
|
-
|
|
1617
|
-
//#region src/sandbox-filesystem.ts
|
|
1611
|
+
// src/sandbox-filesystem.ts
|
|
1618
1612
|
/**
|
|
1619
1613
|
* envd's edge answers a paused or missing sandbox with a 404 or 502 that the
|
|
1620
1614
|
* SDK reports as `FileNotFoundError` or `TimeoutError`. Same message pattern as
|
|
@@ -1654,8 +1648,7 @@ var PlatformSandboxFilesystem = class extends FilesApiFilesystem {
|
|
|
1654
1648
|
if (error instanceof InvalidArgumentError) return "invalid-argument";
|
|
1655
1649
|
}
|
|
1656
1650
|
};
|
|
1657
|
-
|
|
1658
|
-
//#region src/sandbox.ts
|
|
1651
|
+
// src/sandbox.ts
|
|
1659
1652
|
/**
|
|
1660
1653
|
* How long before a lease's stated `expiresAt` we should treat it as
|
|
1661
1654
|
* expired. Avoids a race where the JWT is valid at cache-hit time but the
|
|
@@ -2929,8 +2922,7 @@ function templateHash(definition) {
|
|
|
2929
2922
|
const { family: _family, ...content } = definition;
|
|
2930
2923
|
return createHash("sha256").update(JSON.stringify(content)).digest("hex").slice(0, 16);
|
|
2931
2924
|
}
|
|
2932
|
-
|
|
2933
|
-
//#region src/repo-template.ts
|
|
2925
|
+
// src/repo-template.ts
|
|
2934
2926
|
const execFileAsync = promisify(execFile);
|
|
2935
2927
|
const SHA_PATTERN = /^[0-9a-f]{7,40}$/i;
|
|
2936
2928
|
const BUILD_TOKEN_ENV = "MASTRA_REPOSITORY_ACCESS_TOKEN";
|
|
@@ -3219,8 +3211,7 @@ async function resolveDefaultBranchHead(cloneUrl, token, execute = execFileAsync
|
|
|
3219
3211
|
throw new Error(`git ls-remote failed: ${detail}`);
|
|
3220
3212
|
}
|
|
3221
3213
|
}
|
|
3222
|
-
|
|
3223
|
-
//#region src/provider.ts
|
|
3214
|
+
// src/provider.ts
|
|
3224
3215
|
const platformSandboxProvider = {
|
|
3225
3216
|
id: "platform",
|
|
3226
3217
|
name: "Mastra Platform Sandbox",
|
|
@@ -3305,8 +3296,7 @@ const platformFilesystemProvider = {
|
|
|
3305
3296
|
},
|
|
3306
3297
|
createFilesystem: (config) => new PlatformFilesystem(config)
|
|
3307
3298
|
};
|
|
3308
|
-
|
|
3309
|
-
//#region src/factory-sandbox.ts
|
|
3299
|
+
// src/factory-sandbox.ts
|
|
3310
3300
|
/** Applied when neither the environment setting nor a host default is set. */
|
|
3311
3301
|
const DEFAULT_SETTINGS = {
|
|
3312
3302
|
cpuCount: 2,
|
|
@@ -3476,8 +3466,7 @@ function toBuild(result) {
|
|
|
3476
3466
|
...result.error ? { error: result.error } : {}
|
|
3477
3467
|
};
|
|
3478
3468
|
}
|
|
3479
|
-
|
|
3480
|
-
//#region src/address-registry.ts
|
|
3469
|
+
// src/address-registry.ts
|
|
3481
3470
|
/**
|
|
3482
3471
|
* Concrete in-process {@link SandboxAddressRegistry}. Backed by a `Map`; no
|
|
3483
3472
|
* eviction policy, no TTL — entries live until an observed transport failure
|
|
@@ -3509,7 +3498,6 @@ var InProcessSandboxAddressRegistry = class {
|
|
|
3509
3498
|
return this.#map.size;
|
|
3510
3499
|
}
|
|
3511
3500
|
};
|
|
3512
|
-
//#endregion
|
|
3513
3501
|
export { InProcessSandboxAddressRegistry, PlatformApiError, PlatformClient, PlatformFactorySandbox, PlatformFilesystem, PlatformSandbox, PlatformSandboxFilesystem, PrivateNetExecHttpError, SandboxDestroyedError, SandboxExecTransportError, Template, createRepoTemplate, execViaPrivateNetwork, platformFilesystemProvider, platformSandboxProvider };
|
|
3514
3502
|
|
|
3515
3503
|
//# sourceMappingURL=index.js.map
|