@mastra/platform-workspace 1.4.0 → 1.4.1-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/CHANGELOG.md +34 -0
- package/dist/index.cjs +24 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -28
- package/dist/index.js.map +1 -1
- package/dist/sandbox.d.ts +12 -21
- package/dist/sandbox.d.ts.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @mastra/platform
|
|
2
2
|
|
|
3
|
+
## 1.4.1-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Starting a sandbox now reports whether it created a fresh sandbox or reconnected to an existing one, so an `onStart` handler can run first-time setup only when it's actually needed: ([#21984](https://github.com/mastra-ai/mastra/pull/21984))
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
new E2BSandbox({
|
|
11
|
+
id: 'session-1',
|
|
12
|
+
onStart: async ({ outcome }) => {
|
|
13
|
+
if (outcome === 'created') await cloneRepo();
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`4ff3ee2`](https://github.com/mastra-ai/mastra/commit/4ff3ee2bff7ed07528b4817f8f49639031c72a4d), [`c24754c`](https://github.com/mastra-ai/mastra/commit/c24754c1fb6fe144e5051e536e98c8a18b0214ac), [`45dd6ee`](https://github.com/mastra-ai/mastra/commit/45dd6ee089bd7df0d0c98a10098e483fd388e04a), [`32d3583`](https://github.com/mastra-ai/mastra/commit/32d358332cb8ac2306b83b73cf3536e74dbd435e), [`aca2869`](https://github.com/mastra-ai/mastra/commit/aca2869b2031982f3c4a2f52525c9be7cf123ef8)]:
|
|
19
|
+
- @mastra/core@1.62.0-alpha.11
|
|
20
|
+
|
|
21
|
+
## 1.4.1-alpha.0
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Honor the sandbox runtime environment (`setEnv()`/`getEnv()` from `@mastra/core`) in every workspace sandbox provider. Environment variables set after construction now reach subsequent commands on all providers: ([#22250](https://github.com/mastra-ai/mastra/pull/22250))
|
|
26
|
+
|
|
27
|
+
- Process-manager-routed providers (E2B, Blaxel, Cloudflare, Daytona, Docker, Modal, Vercel microVM spawns) inherit the merge from the core spawn wrapper; their duplicated per-manager env plumbing is removed.
|
|
28
|
+
- Providers with their own exec transports (AgentCore, Apple Container, Railway, Vercel microVM and serverless `executeCommand`, Platform's private-network, WebSocket lease, and E2B lease paths) now merge `getEnv()` under per-call env.
|
|
29
|
+
|
|
30
|
+
Constructor `env` continues to behave as before: it seeds the sandbox runtime environment, and providers that bake env into the VM or container at creation time (Docker, Modal, Railway, Apple Container, Vercel, Platform) still do so. Per-call `env` on `executeCommand` still takes precedence for that command only.
|
|
31
|
+
|
|
32
|
+
Removed exported types (minor bump for these two packages): `BlaxelProcessManagerOptions` from `@mastra/blaxel` and `RailwayProcessManagerOptions` from `@mastra/railway`. Both existed only to pass `env` into a process manager constructed by hand; the core spawn wrapper now owns that merge, so the option and its type are gone.
|
|
33
|
+
|
|
34
|
+
- Updated dependencies [[`aa3a85d`](https://github.com/mastra-ai/mastra/commit/aa3a85daf094c683bb97efdf4b6a696d2e474af5), [`d29d06f`](https://github.com/mastra-ai/mastra/commit/d29d06fe00bbd35b4571150ea04c59d2ed783c71), [`e6516df`](https://github.com/mastra-ai/mastra/commit/e6516dfcdae4f4ac0e7971d84359a81385ee602f), [`0b2a3d1`](https://github.com/mastra-ai/mastra/commit/0b2a3d1783875c5b97b7b36ab3d03d7360e0dde7), [`6bb5d71`](https://github.com/mastra-ai/mastra/commit/6bb5d7193fe9166b219f0fccae17db7a5ae86e65), [`57de7d6`](https://github.com/mastra-ai/mastra/commit/57de7d644ba7146edb4e9e6111ec4fa98c3a59e9), [`e8e299c`](https://github.com/mastra-ai/mastra/commit/e8e299cc6abdfc39947e2fec25803493015d3882), [`edfc548`](https://github.com/mastra-ai/mastra/commit/edfc548886bc7bae17b681f8b6b41a47eb32bcd2), [`a8a4871`](https://github.com/mastra-ai/mastra/commit/a8a4871215f51da95c47129602157ce5372f634a), [`5165cdc`](https://github.com/mastra-ai/mastra/commit/5165cdcdcf50e144bb8113278535196cc9b07065), [`6bb5d71`](https://github.com/mastra-ai/mastra/commit/6bb5d7193fe9166b219f0fccae17db7a5ae86e65), [`9ee8120`](https://github.com/mastra-ai/mastra/commit/9ee8120ce17f76b9f617489e05a283353742690a), [`d975e92`](https://github.com/mastra-ai/mastra/commit/d975e924d4936f46c386bd3dee39c671720289f6), [`1cfa878`](https://github.com/mastra-ai/mastra/commit/1cfa8784d8da0dfaa0317e5048bc48b6084a5ea5), [`c118318`](https://github.com/mastra-ai/mastra/commit/c1183181c9804303db4b511c2e2648f8b714712b), [`fc07c64`](https://github.com/mastra-ai/mastra/commit/fc07c6465043e08e99193a6751a01c56ffc2e7a1), [`542dee2`](https://github.com/mastra-ai/mastra/commit/542dee254167f974ff8cbbbfc0ce10f9a2616a7b), [`a58483c`](https://github.com/mastra-ai/mastra/commit/a58483cff1a9d41fce7c931843f48cb0ac450f64), [`a58483c`](https://github.com/mastra-ai/mastra/commit/a58483cff1a9d41fce7c931843f48cb0ac450f64), [`895e9df`](https://github.com/mastra-ai/mastra/commit/895e9dfc17d6f34299eca64e317ded9e5f5e5ef8)]:
|
|
35
|
+
- @mastra/core@1.62.0-alpha.8
|
|
36
|
+
|
|
3
37
|
## 1.4.0
|
|
4
38
|
|
|
5
39
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -983,18 +983,6 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
983
983
|
*/
|
|
984
984
|
_captureInFlight = null;
|
|
985
985
|
/**
|
|
986
|
-
* In-flight `start()` attempt. Concurrent callers on a fresh instance
|
|
987
|
-
* coalesce onto this single promise so a `POST /sandbox` is not fired
|
|
988
|
-
* N times when N fleet callers race to bring the same logical sandbox
|
|
989
|
-
* up. Published **synchronously** with `??=` before the first `await`
|
|
990
|
-
* so a later caller cannot slip through the null check while the
|
|
991
|
-
* originator is mid-round-trip. Cleared when the shared attempt
|
|
992
|
-
* settles (success or failure) so the next call sees a clean slot.
|
|
993
|
-
*
|
|
994
|
-
* Mirrors OSS `@mastra/railway` `RailwaySandbox._startInFlight`.
|
|
995
|
-
*/
|
|
996
|
-
_startInFlight = null;
|
|
997
|
-
/**
|
|
998
986
|
* Generation token for the sidecar probe. Incremented on every `start()`
|
|
999
987
|
* and on teardown. The probe captures this value when it begins; if the
|
|
1000
988
|
* generation has changed by the time the probe succeeds, the probe skips
|
|
@@ -1079,22 +1067,20 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
1079
1067
|
...this._addressRegistry !== void 0 && { addressRegistry: this._addressRegistry }
|
|
1080
1068
|
});
|
|
1081
1069
|
}
|
|
1082
|
-
async start() {
|
|
1083
|
-
this._startInFlight ??= this._doStart().finally(() => {
|
|
1084
|
-
this._startInFlight = null;
|
|
1085
|
-
});
|
|
1086
|
-
return this._startInFlight;
|
|
1087
|
-
}
|
|
1088
1070
|
/**
|
|
1089
|
-
*
|
|
1071
|
+
* Start the sandbox: reattach to a known provider `sandboxId` when one is
|
|
1072
|
+
* set and still live, otherwise provision a fresh sandbox via the proxy.
|
|
1090
1073
|
*
|
|
1091
|
-
*
|
|
1092
|
-
*
|
|
1093
|
-
*
|
|
1094
|
-
*
|
|
1095
|
-
*
|
|
1074
|
+
* Concurrent-caller coalescing lives in the `MastraSandbox` base class
|
|
1075
|
+
* (constructor-wrapped `start()`): joined callers share one attempt and
|
|
1076
|
+
* observe its result; the in-flight slot is cleared on settle so a failed
|
|
1077
|
+
* attempt is not a permanent latch.
|
|
1078
|
+
*
|
|
1079
|
+
* Reports `outcome: 'connected'` on reattach and `outcome: 'created'` on provision.
|
|
1080
|
+
* Note: a `POST /sandbox` seeded from an id-keyed checkpoint is still a
|
|
1081
|
+
* fresh VM and reports `outcome: 'created'`.
|
|
1096
1082
|
*/
|
|
1097
|
-
async
|
|
1083
|
+
async start() {
|
|
1098
1084
|
const startedAt = Date.now();
|
|
1099
1085
|
if (this._sandboxId) try {
|
|
1100
1086
|
const requestStartedAt = Date.now();
|
|
@@ -1105,7 +1091,7 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
1105
1091
|
this._createdAt = json.createdAt ? new Date(json.createdAt) : /* @__PURE__ */ new Date();
|
|
1106
1092
|
this._populateAddressFromResponse(json);
|
|
1107
1093
|
this._logStartComplete(json.id, startedAt, requestMs, "reattach");
|
|
1108
|
-
return;
|
|
1094
|
+
return { outcome: "connected" };
|
|
1109
1095
|
}
|
|
1110
1096
|
this._sandboxId = void 0;
|
|
1111
1097
|
} catch (error) {
|
|
@@ -1140,6 +1126,7 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
1140
1126
|
this._createdAt = json.createdAt ? new Date(json.createdAt) : /* @__PURE__ */ new Date();
|
|
1141
1127
|
this._populateAddressFromResponse(json);
|
|
1142
1128
|
this._logStartComplete(json.id, startedAt, requestMs, "provision");
|
|
1129
|
+
return { outcome: "created" };
|
|
1143
1130
|
}
|
|
1144
1131
|
/**
|
|
1145
1132
|
* One timing summary per completed `start()` — the whole
|
|
@@ -1495,10 +1482,18 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
1495
1482
|
const started = Date.now();
|
|
1496
1483
|
const fullCommand = buildCommand(command, args);
|
|
1497
1484
|
const effectiveTimeout = options?.timeout ?? this._timeout;
|
|
1485
|
+
const sandboxEnv = this.getEnv();
|
|
1486
|
+
const execCallOptions = Object.keys(sandboxEnv).length > 0 ? {
|
|
1487
|
+
...options,
|
|
1488
|
+
env: {
|
|
1489
|
+
...sandboxEnv,
|
|
1490
|
+
...options?.env
|
|
1491
|
+
}
|
|
1492
|
+
} : options;
|
|
1498
1493
|
await this._awaitTransportReady();
|
|
1499
1494
|
const instanceUrl = this._addressRegistry?.get(this._sandboxId);
|
|
1500
1495
|
if (instanceUrl) {
|
|
1501
|
-
const privateNet = await this._tryExecViaPrivateNetwork(instanceUrl, fullCommand, effectiveTimeout,
|
|
1496
|
+
const privateNet = await this._tryExecViaPrivateNetwork(instanceUrl, fullCommand, effectiveTimeout, execCallOptions);
|
|
1502
1497
|
if (privateNet) {
|
|
1503
1498
|
const privateExit = privateNet.exitCode ?? 124;
|
|
1504
1499
|
return {
|
|
@@ -1512,7 +1507,7 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
1512
1507
|
};
|
|
1513
1508
|
}
|
|
1514
1509
|
}
|
|
1515
|
-
const result = await this._runDirectExec(fullCommand, effectiveTimeout,
|
|
1510
|
+
const result = await this._runDirectExec(fullCommand, effectiveTimeout, execCallOptions);
|
|
1516
1511
|
const exitCode = result.exitCode ?? 124;
|
|
1517
1512
|
return {
|
|
1518
1513
|
success: exitCode === 0,
|
|
@@ -1560,6 +1555,7 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
1560
1555
|
this._lease = null;
|
|
1561
1556
|
const priorSandboxId = this._sandboxId;
|
|
1562
1557
|
this._sandboxId = void 0;
|
|
1558
|
+
this.status = "stopped";
|
|
1563
1559
|
throw new SandboxDestroyedError(`Sandbox ${priorSandboxId ?? "(unknown)"} was destroyed; /exec-lease returned 410`, {
|
|
1564
1560
|
...priorSandboxId && { sandboxId: priorSandboxId },
|
|
1565
1561
|
command: fullCommand,
|