@mastra/platform-workspace 1.7.0-alpha.0 → 1.7.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 CHANGED
@@ -1151,6 +1151,16 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
1151
1151
  * on a later start.
1152
1152
  */
1153
1153
  templatePending;
1154
+ /**
1155
+ * The platform's id for the provisioned sandbox, as returned by the create
1156
+ * or reattach response. Persist this to reattach later via the `sandboxId`
1157
+ * option. Undefined until the sandbox has been started in this process; a
1158
+ * `sandboxId` passed to the constructor is only a hint for `start()` and is
1159
+ * not reported here until the proxy confirms it.
1160
+ */
1161
+ get sandboxId() {
1162
+ return this.status === "running" ? this._sandboxId : void 0;
1163
+ }
1154
1164
  _client;
1155
1165
  _usesProviderRoutes;
1156
1166
  _environmentId;
@@ -1335,7 +1345,7 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
1335
1345
  }
1336
1346
  this._sandboxId = void 0;
1337
1347
  } catch (error) {
1338
- if (!(error instanceof PlatformApiError) || error.status !== 404) throw error;
1348
+ if (!(error instanceof PlatformApiError) || error.status !== 404 && error.status !== 410) throw error;
1339
1349
  this._sandboxId = void 0;
1340
1350
  }
1341
1351
  if (!this._environmentId) throw new Error("environmentId is required");
@@ -1518,23 +1528,28 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
1518
1528
  await Promise.race([this._transportReadyPromise, new Promise((r) => setTimeout(r, TRANSPORT_READY_WAIT_MS))]);
1519
1529
  }
1520
1530
  /**
1521
- * Stop the sandbox while **preserving its recovery checkpoint**.
1531
+ * Stop this process's use of the sandbox without touching the remote one.
1522
1532
  *
1523
- * Semantic parity with `@mastra/railway` `RailwaySandbox.stop()`: the VM
1524
- * is released but the on-provider checkpoint survives, so a subsequent
1525
- * `start()` on a sandbox constructed with the same `id` can restore from
1526
- * it. Any in-flight capture is awaited first so the preserved checkpoint
1527
- * reflects the latest disk state we asked for.
1533
+ * Nothing is sent to workspace-proxy. The VM keeps running and idles out
1534
+ * under the environment's own idle policy, the recovery checkpoint stays,
1535
+ * and `_sandboxId` is kept so a later `start()` on this instance, or on a
1536
+ * new instance constructed with the same `id` or `sandboxId`, reattaches
1537
+ * instead of provisioning. `Mastra.shutdown()` stops every registered
1538
+ * workspace on SIGINT; releasing the VM here would destroy every live
1539
+ * session on a host restart. Use {@link destroy} to release the VM and
1540
+ * its checkpoint.
1528
1541
  *
1529
- * Corresponds to `DELETE /v1/:provider/projects/:pid/sandbox/:sandboxId` on
1530
- * workspace-proxy, which by contract does not touch the checkpoint. Use
1531
- * {@link destroy} when you want the checkpoint released too.
1542
+ * Any in-flight capture is awaited first so the checkpoint reflects the
1543
+ * latest disk state the caller asked for.
1532
1544
  */
1533
1545
  async stop() {
1534
1546
  if (this._captureInFlight) await this._captureInFlight.catch((error) => {
1535
- this.logger.warn(`stop(): failed to flush in-flight capture before teardown:`, error);
1547
+ this.logger.warn(`stop(): failed to flush in-flight capture before stop:`, error);
1536
1548
  });
1537
- await this._teardownSandbox();
1549
+ this._probeGeneration++;
1550
+ this._probeTarget = null;
1551
+ this._transportReadyPromise = null;
1552
+ this._lease = null;
1538
1553
  }
1539
1554
  /**
1540
1555
  * Destroy the sandbox **and release its recovery checkpoint**.
@@ -1571,12 +1586,9 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
1571
1586
  /**
1572
1587
  * Release the remote sandbox VM and clear the local state pointing at it.
1573
1588
  *
1574
- * Shared body of {@link stop} and {@link destroy} — both funnel through
1575
- * here after they've dealt with the checkpoint (preserve vs release).
1576
- * The VM DELETE is safe to issue in either mode: the proxy's DELETE
1577
- * route does not touch the checkpoint on its own, so `stop()` correctly
1578
- * leaves the checkpoint intact and `destroy()` has already removed it
1579
- * before this call.
1589
+ * Body of {@link destroy}, called after the checkpoint has been released.
1590
+ * The proxy's DELETE route releases the VM (on E2B that kills it), so
1591
+ * only destroy() may reach here; stop() never does.
1580
1592
  */
1581
1593
  async _teardownSandbox() {
1582
1594
  if (!this._sandboxId) return;
@@ -1955,7 +1967,7 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
1955
1967
  }
1956
1968
  }
1957
1969
  async getInfo() {
1958
- if (!this._sandboxId) return {
1970
+ if (!this._sandboxId || this.status !== "running") return {
1959
1971
  id: this.id,
1960
1972
  name: this.name,
1961
1973
  provider: this.provider,