@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/dist/index.js
CHANGED
|
@@ -959,18 +959,6 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
|
|
|
959
959
|
*/
|
|
960
960
|
_captureInFlight = null;
|
|
961
961
|
/**
|
|
962
|
-
* In-flight `start()` attempt. Concurrent callers on a fresh instance
|
|
963
|
-
* coalesce onto this single promise so a `POST /sandbox` is not fired
|
|
964
|
-
* N times when N fleet callers race to bring the same logical sandbox
|
|
965
|
-
* up. Published **synchronously** with `??=` before the first `await`
|
|
966
|
-
* so a later caller cannot slip through the null check while the
|
|
967
|
-
* originator is mid-round-trip. Cleared when the shared attempt
|
|
968
|
-
* settles (success or failure) so the next call sees a clean slot.
|
|
969
|
-
*
|
|
970
|
-
* Mirrors OSS `@mastra/railway` `RailwaySandbox._startInFlight`.
|
|
971
|
-
*/
|
|
972
|
-
_startInFlight = null;
|
|
973
|
-
/**
|
|
974
962
|
* Generation token for the sidecar probe. Incremented on every `start()`
|
|
975
963
|
* and on teardown. The probe captures this value when it begins; if the
|
|
976
964
|
* generation has changed by the time the probe succeeds, the probe skips
|
|
@@ -1055,22 +1043,20 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
|
|
|
1055
1043
|
...this._addressRegistry !== void 0 && { addressRegistry: this._addressRegistry }
|
|
1056
1044
|
});
|
|
1057
1045
|
}
|
|
1058
|
-
async start() {
|
|
1059
|
-
this._startInFlight ??= this._doStart().finally(() => {
|
|
1060
|
-
this._startInFlight = null;
|
|
1061
|
-
});
|
|
1062
|
-
return this._startInFlight;
|
|
1063
|
-
}
|
|
1064
1046
|
/**
|
|
1065
|
-
*
|
|
1047
|
+
* Start the sandbox: reattach to a known provider `sandboxId` when one is
|
|
1048
|
+
* set and still live, otherwise provision a fresh sandbox via the proxy.
|
|
1066
1049
|
*
|
|
1067
|
-
*
|
|
1068
|
-
*
|
|
1069
|
-
*
|
|
1070
|
-
*
|
|
1071
|
-
*
|
|
1050
|
+
* Concurrent-caller coalescing lives in the `MastraSandbox` base class
|
|
1051
|
+
* (constructor-wrapped `start()`): joined callers share one attempt and
|
|
1052
|
+
* observe its result; the in-flight slot is cleared on settle so a failed
|
|
1053
|
+
* attempt is not a permanent latch.
|
|
1054
|
+
*
|
|
1055
|
+
* Reports `outcome: 'connected'` on reattach and `outcome: 'created'` on provision.
|
|
1056
|
+
* Note: a `POST /sandbox` seeded from an id-keyed checkpoint is still a
|
|
1057
|
+
* fresh VM and reports `outcome: 'created'`.
|
|
1072
1058
|
*/
|
|
1073
|
-
async
|
|
1059
|
+
async start() {
|
|
1074
1060
|
const startedAt = Date.now();
|
|
1075
1061
|
if (this._sandboxId) try {
|
|
1076
1062
|
const requestStartedAt = Date.now();
|
|
@@ -1081,7 +1067,7 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
|
|
|
1081
1067
|
this._createdAt = json.createdAt ? new Date(json.createdAt) : /* @__PURE__ */ new Date();
|
|
1082
1068
|
this._populateAddressFromResponse(json);
|
|
1083
1069
|
this._logStartComplete(json.id, startedAt, requestMs, "reattach");
|
|
1084
|
-
return;
|
|
1070
|
+
return { outcome: "connected" };
|
|
1085
1071
|
}
|
|
1086
1072
|
this._sandboxId = void 0;
|
|
1087
1073
|
} catch (error) {
|
|
@@ -1116,6 +1102,7 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
|
|
|
1116
1102
|
this._createdAt = json.createdAt ? new Date(json.createdAt) : /* @__PURE__ */ new Date();
|
|
1117
1103
|
this._populateAddressFromResponse(json);
|
|
1118
1104
|
this._logStartComplete(json.id, startedAt, requestMs, "provision");
|
|
1105
|
+
return { outcome: "created" };
|
|
1119
1106
|
}
|
|
1120
1107
|
/**
|
|
1121
1108
|
* One timing summary per completed `start()` — the whole
|
|
@@ -1471,10 +1458,18 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
|
|
|
1471
1458
|
const started = Date.now();
|
|
1472
1459
|
const fullCommand = buildCommand(command, args);
|
|
1473
1460
|
const effectiveTimeout = options?.timeout ?? this._timeout;
|
|
1461
|
+
const sandboxEnv = this.getEnv();
|
|
1462
|
+
const execCallOptions = Object.keys(sandboxEnv).length > 0 ? {
|
|
1463
|
+
...options,
|
|
1464
|
+
env: {
|
|
1465
|
+
...sandboxEnv,
|
|
1466
|
+
...options?.env
|
|
1467
|
+
}
|
|
1468
|
+
} : options;
|
|
1474
1469
|
await this._awaitTransportReady();
|
|
1475
1470
|
const instanceUrl = this._addressRegistry?.get(this._sandboxId);
|
|
1476
1471
|
if (instanceUrl) {
|
|
1477
|
-
const privateNet = await this._tryExecViaPrivateNetwork(instanceUrl, fullCommand, effectiveTimeout,
|
|
1472
|
+
const privateNet = await this._tryExecViaPrivateNetwork(instanceUrl, fullCommand, effectiveTimeout, execCallOptions);
|
|
1478
1473
|
if (privateNet) {
|
|
1479
1474
|
const privateExit = privateNet.exitCode ?? 124;
|
|
1480
1475
|
return {
|
|
@@ -1488,7 +1483,7 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
|
|
|
1488
1483
|
};
|
|
1489
1484
|
}
|
|
1490
1485
|
}
|
|
1491
|
-
const result = await this._runDirectExec(fullCommand, effectiveTimeout,
|
|
1486
|
+
const result = await this._runDirectExec(fullCommand, effectiveTimeout, execCallOptions);
|
|
1492
1487
|
const exitCode = result.exitCode ?? 124;
|
|
1493
1488
|
return {
|
|
1494
1489
|
success: exitCode === 0,
|
|
@@ -1536,6 +1531,7 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
|
|
|
1536
1531
|
this._lease = null;
|
|
1537
1532
|
const priorSandboxId = this._sandboxId;
|
|
1538
1533
|
this._sandboxId = void 0;
|
|
1534
|
+
this.status = "stopped";
|
|
1539
1535
|
throw new SandboxDestroyedError(`Sandbox ${priorSandboxId ?? "(unknown)"} was destroyed; /exec-lease returned 410`, {
|
|
1540
1536
|
...priorSandboxId && { sandboxId: priorSandboxId },
|
|
1541
1537
|
command: fullCommand,
|