@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.js CHANGED
@@ -1127,6 +1127,16 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
1127
1127
  * on a later start.
1128
1128
  */
1129
1129
  templatePending;
1130
+ /**
1131
+ * The platform's id for the provisioned sandbox, as returned by the create
1132
+ * or reattach response. Persist this to reattach later via the `sandboxId`
1133
+ * option. Undefined until the sandbox has been started in this process; a
1134
+ * `sandboxId` passed to the constructor is only a hint for `start()` and is
1135
+ * not reported here until the proxy confirms it.
1136
+ */
1137
+ get sandboxId() {
1138
+ return this.status === "running" ? this._sandboxId : void 0;
1139
+ }
1130
1140
  _client;
1131
1141
  _usesProviderRoutes;
1132
1142
  _environmentId;
@@ -1311,7 +1321,7 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
1311
1321
  }
1312
1322
  this._sandboxId = void 0;
1313
1323
  } catch (error) {
1314
- if (!(error instanceof PlatformApiError) || error.status !== 404) throw error;
1324
+ if (!(error instanceof PlatformApiError) || error.status !== 404 && error.status !== 410) throw error;
1315
1325
  this._sandboxId = void 0;
1316
1326
  }
1317
1327
  if (!this._environmentId) throw new Error("environmentId is required");
@@ -1494,23 +1504,28 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
1494
1504
  await Promise.race([this._transportReadyPromise, new Promise((r) => setTimeout(r, TRANSPORT_READY_WAIT_MS))]);
1495
1505
  }
1496
1506
  /**
1497
- * Stop the sandbox while **preserving its recovery checkpoint**.
1507
+ * Stop this process's use of the sandbox without touching the remote one.
1498
1508
  *
1499
- * Semantic parity with `@mastra/railway` `RailwaySandbox.stop()`: the VM
1500
- * is released but the on-provider checkpoint survives, so a subsequent
1501
- * `start()` on a sandbox constructed with the same `id` can restore from
1502
- * it. Any in-flight capture is awaited first so the preserved checkpoint
1503
- * reflects the latest disk state we asked for.
1509
+ * Nothing is sent to workspace-proxy. The VM keeps running and idles out
1510
+ * under the environment's own idle policy, the recovery checkpoint stays,
1511
+ * and `_sandboxId` is kept so a later `start()` on this instance, or on a
1512
+ * new instance constructed with the same `id` or `sandboxId`, reattaches
1513
+ * instead of provisioning. `Mastra.shutdown()` stops every registered
1514
+ * workspace on SIGINT; releasing the VM here would destroy every live
1515
+ * session on a host restart. Use {@link destroy} to release the VM and
1516
+ * its checkpoint.
1504
1517
  *
1505
- * Corresponds to `DELETE /v1/:provider/projects/:pid/sandbox/:sandboxId` on
1506
- * workspace-proxy, which by contract does not touch the checkpoint. Use
1507
- * {@link destroy} when you want the checkpoint released too.
1518
+ * Any in-flight capture is awaited first so the checkpoint reflects the
1519
+ * latest disk state the caller asked for.
1508
1520
  */
1509
1521
  async stop() {
1510
1522
  if (this._captureInFlight) await this._captureInFlight.catch((error) => {
1511
- this.logger.warn(`stop(): failed to flush in-flight capture before teardown:`, error);
1523
+ this.logger.warn(`stop(): failed to flush in-flight capture before stop:`, error);
1512
1524
  });
1513
- await this._teardownSandbox();
1525
+ this._probeGeneration++;
1526
+ this._probeTarget = null;
1527
+ this._transportReadyPromise = null;
1528
+ this._lease = null;
1514
1529
  }
1515
1530
  /**
1516
1531
  * Destroy the sandbox **and release its recovery checkpoint**.
@@ -1547,12 +1562,9 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
1547
1562
  /**
1548
1563
  * Release the remote sandbox VM and clear the local state pointing at it.
1549
1564
  *
1550
- * Shared body of {@link stop} and {@link destroy} — both funnel through
1551
- * here after they've dealt with the checkpoint (preserve vs release).
1552
- * The VM DELETE is safe to issue in either mode: the proxy's DELETE
1553
- * route does not touch the checkpoint on its own, so `stop()` correctly
1554
- * leaves the checkpoint intact and `destroy()` has already removed it
1555
- * before this call.
1565
+ * Body of {@link destroy}, called after the checkpoint has been released.
1566
+ * The proxy's DELETE route releases the VM (on E2B that kills it), so
1567
+ * only destroy() may reach here; stop() never does.
1556
1568
  */
1557
1569
  async _teardownSandbox() {
1558
1570
  if (!this._sandboxId) return;
@@ -1931,7 +1943,7 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
1931
1943
  }
1932
1944
  }
1933
1945
  async getInfo() {
1934
- if (!this._sandboxId) return {
1946
+ if (!this._sandboxId || this.status !== "running") return {
1935
1947
  id: this.id,
1936
1948
  name: this.name,
1937
1949
  provider: this.provider,