@mastra/platform-workspace 1.3.0-alpha.0 → 1.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @mastra/platform
2
2
 
3
+ ## 1.3.0-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - PlatformSandbox restarts use the current sandbox connection after the previous sandbox is deleted or the platform does not return an instance URL, so later commands do not hit a stale sidecar. ([#21798](https://github.com/mastra-ai/mastra/pull/21798))
8
+
9
+ - PlatformSandbox now restarts a timed-out sidecar health probe on the next command instead of falling back to the slower lease-based exec path for the sandbox's lifetime. If the in-sandbox sidecar was just slow to boot, later commands recover the fast private-network transport automatically. ([#21798](https://github.com/mastra-ai/mastra/pull/21798))
10
+
11
+ - Declared checkpoint support (`supportsCheckpoints`) so checkpoint-based features like warm base checkpoints and boot-from-checkpoint know snapshots are real. ([#21798](https://github.com/mastra-ai/mastra/pull/21798))
12
+
13
+ ```ts
14
+ // Gate checkpoint-dependent work on the provider's capability flag.
15
+ if (sandbox.supportsCheckpoints) {
16
+ await sandbox.snapshot(); // persists a checkpoint that can seed a later boot
17
+ }
18
+ ```
19
+
20
+ - Updated dependencies [[`c549e2f`](https://github.com/mastra-ai/mastra/commit/c549e2f40edc1cac5d9e74e82f90da22b48df084), [`c549e2f`](https://github.com/mastra-ai/mastra/commit/c549e2f40edc1cac5d9e74e82f90da22b48df084), [`2ef2f23`](https://github.com/mastra-ai/mastra/commit/2ef2f230a7aed342e7dc3b2000cd42e4c43e08a7), [`5740ec6`](https://github.com/mastra-ai/mastra/commit/5740ec60c760ffdfbfaa59d603d03b847c864e05)]:
21
+ - @mastra/core@1.60.0-alpha.13
22
+
3
23
  ## 1.3.0-alpha.0
4
24
 
5
25
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -938,6 +938,12 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
938
938
  * failed/timed out, but now coalesced via `_leaseInFlight`).
939
939
  */
940
940
  _transportReadyPromise = null;
941
+ /**
942
+ * The sidecar address of the most recent `start()`, kept so a timed-out
943
+ * probe can be restarted by a later exec ({@link _awaitTransportReady})
944
+ * instead of pinning the sandbox to the lease path for its lifetime.
945
+ */
946
+ _probeTarget = null;
941
947
  constructor(options = {}) {
942
948
  super({
943
949
  ...options,
@@ -1090,14 +1096,24 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
1090
1096
  * HTTP round-trip.
1091
1097
  *
1092
1098
  * `null`/absent `instanceUrl` (proxy discovery failed, or an older proxy
1093
- * that predates the field) leaves the registry untouched executes fall
1094
- * through to the lease path with no branch here.
1099
+ * that predates the field) evicts any stale registry address and leaves
1100
+ * executes on the lease path.
1095
1101
  */
1096
1102
  _populateAddressFromResponse(json) {
1097
1103
  if (!this._addressRegistry) return;
1098
- if (!json.instanceUrl) return;
1104
+ if (!json.instanceUrl) {
1105
+ this._probeGeneration++;
1106
+ this._probeTarget = null;
1107
+ this._transportReadyPromise = null;
1108
+ this._addressRegistry.delete(json.id);
1109
+ return;
1110
+ }
1099
1111
  this._addressRegistry.delete(json.id);
1100
1112
  const generation = ++this._probeGeneration;
1113
+ this._probeTarget = {
1114
+ sandboxId: json.id,
1115
+ instanceUrl: json.instanceUrl
1116
+ };
1101
1117
  this._transportReadyPromise = this._probeSidecarThenRegister(json.id, json.instanceUrl, generation);
1102
1118
  }
1103
1119
  /**
@@ -1107,8 +1123,9 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
1107
1123
  * fall back to the lease path until the probe succeeds.
1108
1124
  *
1109
1125
  * If the sidecar never comes up within {@link SIDECAR_PROBE_TIMEOUT_MS},
1110
- * the registry stays unpopulated and all execs go via lease for this
1111
- * sandbox's lifetime (or until a future `start()` re-runs the probe).
1126
+ * the registry stays unpopulated, `_transportReadyPromise` is cleared,
1127
+ * and a later {@link _awaitTransportReady} call restarts the probe
1128
+ * instead of pinning this sandbox to the lease path.
1112
1129
  *
1113
1130
  * @param generation - The probe generation captured at call time. If this
1114
1131
  * no longer matches `_probeGeneration` when the probe succeeds, the probe
@@ -1142,6 +1159,7 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
1142
1159
  } catch {}
1143
1160
  await new Promise((r) => setTimeout(r, SIDECAR_PROBE_INTERVAL_MS));
1144
1161
  }
1162
+ if (generation === this._probeGeneration && this._transportReadyPromise) this._transportReadyPromise = null;
1145
1163
  this.logger.warn("platform-workspace probe timed out", {
1146
1164
  sandboxId,
1147
1165
  sessionId: this._client.sessionId,
@@ -1162,7 +1180,12 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
1162
1180
  */
1163
1181
  async _awaitTransportReady() {
1164
1182
  if (this._sandboxId && this._addressRegistry?.get(this._sandboxId)) return;
1165
- if (!this._transportReadyPromise) return;
1183
+ if (!this._transportReadyPromise) {
1184
+ const target = this._probeTarget;
1185
+ if (!target || this._sandboxId !== target.sandboxId) return;
1186
+ const generation = ++this._probeGeneration;
1187
+ this._transportReadyPromise = this._probeSidecarThenRegister(target.sandboxId, target.instanceUrl, generation);
1188
+ }
1166
1189
  await Promise.race([this._transportReadyPromise, new Promise((r) => setTimeout(r, TRANSPORT_READY_WAIT_MS))]);
1167
1190
  }
1168
1191
  /**
@@ -1229,6 +1252,8 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
1229
1252
  if (!this._sandboxId) return;
1230
1253
  const destroyedSandboxId = this._sandboxId;
1231
1254
  this._probeGeneration++;
1255
+ this._probeTarget = null;
1256
+ this._transportReadyPromise = null;
1232
1257
  await this._client.request(`/sandbox/${encodeURIComponent(destroyedSandboxId)}`, { method: "DELETE" });
1233
1258
  this._sandboxId = void 0;
1234
1259
  this._createdAt = null;
@@ -1239,6 +1264,8 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
1239
1264
  async snapshot() {
1240
1265
  await this.captureCheckpoint();
1241
1266
  }
1267
+ /** Snapshots persist real checkpoints that can seed future sandboxes. */
1268
+ supportsCheckpoints = true;
1242
1269
  /**
1243
1270
  * Capture the sandbox's checkpoint on demand, outside any refresh timer the
1244
1271
  * workspace-proxy owns internally.
@@ -1358,6 +1385,9 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
1358
1385
  * the cached `'running'` state (see `MastraSandbox._start`).
1359
1386
  */
1360
1387
  _clearDestroyedState(destroyedSandboxId) {
1388
+ this._probeGeneration++;
1389
+ this._probeTarget = null;
1390
+ this._transportReadyPromise = null;
1361
1391
  this._sandboxId = void 0;
1362
1392
  this._createdAt = null;
1363
1393
  this._lease = null;