@mastra/platform-workspace 1.4.1-alpha.0 → 1.4.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.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
- * The single `start` attempt behind {@link start}'s coalescing wrapper.
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.
1049
+ *
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.
1066
1054
  *
1067
- * Split out so the wrapper can install a shared in-flight promise
1068
- * synchronously (before the first `await`) without inlining the reattach
1069
- * / retry logic. Joined callers observe whatever outcome this method
1070
- * produces — success returns normally, failures propagate to every
1071
- * awaiter.
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 _doStart() {
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
@@ -1544,6 +1531,7 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
1544
1531
  this._lease = null;
1545
1532
  const priorSandboxId = this._sandboxId;
1546
1533
  this._sandboxId = void 0;
1534
+ this.status = "stopped";
1547
1535
  throw new SandboxDestroyedError(`Sandbox ${priorSandboxId ?? "(unknown)"} was destroyed; /exec-lease returned 410`, {
1548
1536
  ...priorSandboxId && { sandboxId: priorSandboxId },
1549
1537
  command: fullCommand,