@mastra/platform-workspace 1.14.0 → 1.15.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/client.d.ts +2 -0
- package/dist/index.cjs +23 -3
- package/dist/index.js +23 -3
- package/package.json +3 -3
package/dist/client.d.ts
CHANGED
|
@@ -71,6 +71,8 @@ export declare class PlatformClient {
|
|
|
71
71
|
constructor(options: PlatformClientOptions);
|
|
72
72
|
request(path: string, options?: PlatformRequestOptions): Promise<Response>;
|
|
73
73
|
requestProvider(path: string, options?: PlatformRequestOptions): Promise<Response>;
|
|
74
|
+
/** Calls a project route that belongs to no sandbox provider, e.g. `/browsers`. */
|
|
75
|
+
requestProject(path: string, options?: PlatformRequestOptions): Promise<Response>;
|
|
74
76
|
private requestAtPath;
|
|
75
77
|
}
|
|
76
78
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/index.cjs
CHANGED
|
@@ -141,6 +141,10 @@ var PlatformClient = class {
|
|
|
141
141
|
async requestProvider(path, options = {}) {
|
|
142
142
|
return this.requestAtPath(`/${this.sandboxProvider}`, path, options);
|
|
143
143
|
}
|
|
144
|
+
/** Calls a project route that belongs to no sandbox provider, e.g. `/browsers`. */
|
|
145
|
+
async requestProject(path, options = {}) {
|
|
146
|
+
return this.requestAtPath("", path, options);
|
|
147
|
+
}
|
|
144
148
|
async requestAtPath(providerPath, path, options) {
|
|
145
149
|
const url = new URL(`${this.proxyUrl}/v1${providerPath}/projects/${encodeURIComponent(this.projectId)}${path}`);
|
|
146
150
|
for (const [key, value] of Object.entries(options.query ?? {})) if (value !== void 0) url.searchParams.set(key, String(value));
|
|
@@ -3445,6 +3449,22 @@ const platformFilesystemProvider = {
|
|
|
3445
3449
|
createFilesystem: (config) => new PlatformFilesystem(config)
|
|
3446
3450
|
};
|
|
3447
3451
|
// src/factory-sandbox.ts
|
|
3452
|
+
/** vCPU counts a sandbox can be created with: one, or an even number up to 8. Any other count fails at creation. */
|
|
3453
|
+
const CPU_COUNTS = [
|
|
3454
|
+
1,
|
|
3455
|
+
2,
|
|
3456
|
+
4,
|
|
3457
|
+
6,
|
|
3458
|
+
8
|
|
3459
|
+
];
|
|
3460
|
+
/**
|
|
3461
|
+
* The first of `counts` that is offered, else the built-in default. A count saved
|
|
3462
|
+
* before the list existed, or passed as a default, may not be on it; a saved one
|
|
3463
|
+
* falls back to the configured default, the same as once Factory drops it.
|
|
3464
|
+
*/
|
|
3465
|
+
function offeredCpuCount(...counts) {
|
|
3466
|
+
return counts.find((count) => count !== void 0 && CPU_COUNTS.includes(count)) ?? DEFAULT_SETTINGS.cpuCount;
|
|
3467
|
+
}
|
|
3448
3468
|
/** Applied when neither the environment setting nor a host default is set. */
|
|
3449
3469
|
const DEFAULT_SETTINGS = {
|
|
3450
3470
|
cpuCount: 2,
|
|
@@ -3461,8 +3481,7 @@ const SETTINGS_SCHEMA = {
|
|
|
3461
3481
|
title: "CPU",
|
|
3462
3482
|
description: "vCPUs for the sandbox template",
|
|
3463
3483
|
default: DEFAULT_SETTINGS.cpuCount,
|
|
3464
|
-
|
|
3465
|
-
maximum: 64
|
|
3484
|
+
oneOf: CPU_COUNTS.map((count) => ({ const: count }))
|
|
3466
3485
|
},
|
|
3467
3486
|
memoryMb: {
|
|
3468
3487
|
type: "integer",
|
|
@@ -3527,6 +3546,7 @@ function settingsSchema(defaults) {
|
|
|
3527
3546
|
...DEFAULT_SETTINGS,
|
|
3528
3547
|
...defaults
|
|
3529
3548
|
};
|
|
3549
|
+
effective.cpuCount = offeredCpuCount(effective.cpuCount);
|
|
3530
3550
|
const properties = Object.fromEntries(Object.entries(SETTINGS_SCHEMA.properties).map(([key, property]) => [key, {
|
|
3531
3551
|
...property,
|
|
3532
3552
|
default: effective[key]
|
|
@@ -3579,7 +3599,7 @@ var PlatformFactorySandbox = class extends _mastra_core_workspace.FactorySandbox
|
|
|
3579
3599
|
...rest,
|
|
3580
3600
|
...Object.keys(mergedBuildEnv).length > 0 ? { buildEnv: mergedBuildEnv } : {},
|
|
3581
3601
|
...buildEnvRevision ? { buildEnvRevision } : {},
|
|
3582
|
-
cpuCount: settings.cpuCount
|
|
3602
|
+
cpuCount: offeredCpuCount(settings.cpuCount, defaults?.cpuCount),
|
|
3583
3603
|
memoryMB: settings.memoryMb ?? defaults?.memoryMb ?? DEFAULT_SETTINGS.memoryMb,
|
|
3584
3604
|
docker: settings.docker ?? defaults?.docker ?? DEFAULT_SETTINGS.docker
|
|
3585
3605
|
});
|
package/dist/index.js
CHANGED
|
@@ -118,6 +118,10 @@ var PlatformClient = class {
|
|
|
118
118
|
async requestProvider(path, options = {}) {
|
|
119
119
|
return this.requestAtPath(`/${this.sandboxProvider}`, path, options);
|
|
120
120
|
}
|
|
121
|
+
/** Calls a project route that belongs to no sandbox provider, e.g. `/browsers`. */
|
|
122
|
+
async requestProject(path, options = {}) {
|
|
123
|
+
return this.requestAtPath("", path, options);
|
|
124
|
+
}
|
|
121
125
|
async requestAtPath(providerPath, path, options) {
|
|
122
126
|
const url = new URL(`${this.proxyUrl}/v1${providerPath}/projects/${encodeURIComponent(this.projectId)}${path}`);
|
|
123
127
|
for (const [key, value] of Object.entries(options.query ?? {})) if (value !== void 0) url.searchParams.set(key, String(value));
|
|
@@ -3422,6 +3426,22 @@ const platformFilesystemProvider = {
|
|
|
3422
3426
|
createFilesystem: (config) => new PlatformFilesystem(config)
|
|
3423
3427
|
};
|
|
3424
3428
|
// src/factory-sandbox.ts
|
|
3429
|
+
/** vCPU counts a sandbox can be created with: one, or an even number up to 8. Any other count fails at creation. */
|
|
3430
|
+
const CPU_COUNTS = [
|
|
3431
|
+
1,
|
|
3432
|
+
2,
|
|
3433
|
+
4,
|
|
3434
|
+
6,
|
|
3435
|
+
8
|
|
3436
|
+
];
|
|
3437
|
+
/**
|
|
3438
|
+
* The first of `counts` that is offered, else the built-in default. A count saved
|
|
3439
|
+
* before the list existed, or passed as a default, may not be on it; a saved one
|
|
3440
|
+
* falls back to the configured default, the same as once Factory drops it.
|
|
3441
|
+
*/
|
|
3442
|
+
function offeredCpuCount(...counts) {
|
|
3443
|
+
return counts.find((count) => count !== void 0 && CPU_COUNTS.includes(count)) ?? DEFAULT_SETTINGS.cpuCount;
|
|
3444
|
+
}
|
|
3425
3445
|
/** Applied when neither the environment setting nor a host default is set. */
|
|
3426
3446
|
const DEFAULT_SETTINGS = {
|
|
3427
3447
|
cpuCount: 2,
|
|
@@ -3438,8 +3458,7 @@ const SETTINGS_SCHEMA = {
|
|
|
3438
3458
|
title: "CPU",
|
|
3439
3459
|
description: "vCPUs for the sandbox template",
|
|
3440
3460
|
default: DEFAULT_SETTINGS.cpuCount,
|
|
3441
|
-
|
|
3442
|
-
maximum: 64
|
|
3461
|
+
oneOf: CPU_COUNTS.map((count) => ({ const: count }))
|
|
3443
3462
|
},
|
|
3444
3463
|
memoryMb: {
|
|
3445
3464
|
type: "integer",
|
|
@@ -3504,6 +3523,7 @@ function settingsSchema(defaults) {
|
|
|
3504
3523
|
...DEFAULT_SETTINGS,
|
|
3505
3524
|
...defaults
|
|
3506
3525
|
};
|
|
3526
|
+
effective.cpuCount = offeredCpuCount(effective.cpuCount);
|
|
3507
3527
|
const properties = Object.fromEntries(Object.entries(SETTINGS_SCHEMA.properties).map(([key, property]) => [key, {
|
|
3508
3528
|
...property,
|
|
3509
3529
|
default: effective[key]
|
|
@@ -3556,7 +3576,7 @@ var PlatformFactorySandbox = class extends FactorySandbox {
|
|
|
3556
3576
|
...rest,
|
|
3557
3577
|
...Object.keys(mergedBuildEnv).length > 0 ? { buildEnv: mergedBuildEnv } : {},
|
|
3558
3578
|
...buildEnvRevision ? { buildEnvRevision } : {},
|
|
3559
|
-
cpuCount: settings.cpuCount
|
|
3579
|
+
cpuCount: offeredCpuCount(settings.cpuCount, defaults?.cpuCount),
|
|
3560
3580
|
memoryMB: settings.memoryMb ?? defaults?.memoryMb ?? DEFAULT_SETTINGS.memoryMb,
|
|
3561
3581
|
docker: settings.docker ?? defaults?.docker ?? DEFAULT_SETTINGS.docker
|
|
3562
3582
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/platform-workspace",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0-alpha.1",
|
|
4
4
|
"description": "Mastra Platform workspace sandbox and filesystem providers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"tsdown": "0.23.1",
|
|
27
27
|
"typescript": "^7.0.2",
|
|
28
28
|
"vitest": "5.1.0",
|
|
29
|
-
"@internal/workspace": "0.0.24",
|
|
30
29
|
"@internal/lint": "0.0.152",
|
|
31
30
|
"@internal/types-builder": "0.0.127",
|
|
32
|
-
"@
|
|
31
|
+
"@internal/workspace": "0.0.24",
|
|
32
|
+
"@mastra/core": "1.87.0-alpha.9"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@mastra/core": ">=1.80.0-0 <2.0.0-0"
|