@mastra/platform-workspace 1.2.1 → 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,36 @@
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
+
23
+ ## 1.3.0-alpha.0
24
+
25
+ ### Minor Changes
26
+
27
+ - Added `ProcessHandle.closeStdin()` to signal end-of-file to background processes. Local and Docker sandboxes support closing stdin, while providers without an available stdin-close API return a provider-specific unsupported-operation error. Providers signal the unsupported case with the new `UnsupportedStdinCloseError`, and the base class supplies that behavior by default so existing `ProcessHandle` subclasses keep compiling. Calling `handle.writer.end()` also closes stdin, and finishes without an error when the provider cannot close stdin. ([#21606](https://github.com/mastra-ai/mastra/pull/21606))
28
+
29
+ ### Patch Changes
30
+
31
+ - Updated dependencies [[`4e7a421`](https://github.com/mastra-ai/mastra/commit/4e7a421dce8a48742f785d1e93ad2f43a572b282), [`242e324`](https://github.com/mastra-ai/mastra/commit/242e3241e73cbd5c9bb86a31ebb49ca0256488d4), [`217e967`](https://github.com/mastra-ai/mastra/commit/217e9672d8b3160eb729d8e9f0044949e88da239), [`d774e89`](https://github.com/mastra-ai/mastra/commit/d774e8930c781df8c9effe3763e6b501c099b6cc), [`9c27a53`](https://github.com/mastra-ai/mastra/commit/9c27a53cd9d3de4f3f025bc387d94ce371c33f95), [`dff25a1`](https://github.com/mastra-ai/mastra/commit/dff25a1103fa72ee082a9b6f805ebeb5ce400753), [`217e967`](https://github.com/mastra-ai/mastra/commit/217e9672d8b3160eb729d8e9f0044949e88da239), [`7f78585`](https://github.com/mastra-ai/mastra/commit/7f785857e401570e2ffb316911f126ed363aa537), [`f2a4afd`](https://github.com/mastra-ai/mastra/commit/f2a4afd7e37e809669001ed17724b341a5c1f45e), [`d438148`](https://github.com/mastra-ai/mastra/commit/d438148e222c1e2fb3c652725ce75680962ebec4), [`ba05fe0`](https://github.com/mastra-ai/mastra/commit/ba05fe0738f70cb686777546e968237d09269142), [`d26a8d4`](https://github.com/mastra-ai/mastra/commit/d26a8d4281f28414715b333c85bedaf70d0b2890), [`677cdc6`](https://github.com/mastra-ai/mastra/commit/677cdc6af564dec29a13464d12b7ab2a4efc22e9), [`a318490`](https://github.com/mastra-ai/mastra/commit/a318490e17da32f338d50929c770d901a9b3dd72), [`763e0c6`](https://github.com/mastra-ai/mastra/commit/763e0c61e04d76ad9a9efd301aa57525ca0cbea9), [`23e0be2`](https://github.com/mastra-ai/mastra/commit/23e0be261381e49534b4ff3101c60ee64a946cbf), [`7fc8806`](https://github.com/mastra-ai/mastra/commit/7fc880627d3cbf995d31ea0e8b807bf15417e651), [`0e02eac`](https://github.com/mastra-ai/mastra/commit/0e02eacdb2e30e1697a41910b41163742a181dc1), [`4df174c`](https://github.com/mastra-ai/mastra/commit/4df174c32bddf093a82f273070b8380aef7c9e90), [`f7c25b5`](https://github.com/mastra-ai/mastra/commit/f7c25b5106ddfb48e591f98df7a51e0f2dd01dba), [`dc09cc1`](https://github.com/mastra-ai/mastra/commit/dc09cc1083d861cde192c1cd235324dc75b8c731), [`36b4649`](https://github.com/mastra-ai/mastra/commit/36b4649045a3a380cbab8ceca866db4086223aff), [`377eb81`](https://github.com/mastra-ai/mastra/commit/377eb81ce43b964e3a6b541df172da74a8ff3716)]:
32
+ - @mastra/core@1.60.0-alpha.8
33
+
3
34
  ## 1.2.1
4
35
 
5
36
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -824,6 +824,9 @@ var PlatformProcessHandle = class extends _mastra_core_workspace.ProcessHandle {
824
824
  async sendStdin() {
825
825
  throw new Error("Platform sandbox command execution does not support stdin");
826
826
  }
827
+ async closeStdin() {
828
+ throw new _mastra_core_workspace.UnsupportedStdinCloseError("Platform sandbox command execution does not support closing stdin");
829
+ }
827
830
  };
828
831
  var PlatformProcessManager = class extends _mastra_core_workspace.SandboxProcessManager {
829
832
  spawnCounter = 0;
@@ -935,6 +938,12 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
935
938
  * failed/timed out, but now coalesced via `_leaseInFlight`).
936
939
  */
937
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;
938
947
  constructor(options = {}) {
939
948
  super({
940
949
  ...options,
@@ -1087,14 +1096,24 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
1087
1096
  * HTTP round-trip.
1088
1097
  *
1089
1098
  * `null`/absent `instanceUrl` (proxy discovery failed, or an older proxy
1090
- * that predates the field) leaves the registry untouched executes fall
1091
- * 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.
1092
1101
  */
1093
1102
  _populateAddressFromResponse(json) {
1094
1103
  if (!this._addressRegistry) return;
1095
- 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
+ }
1096
1111
  this._addressRegistry.delete(json.id);
1097
1112
  const generation = ++this._probeGeneration;
1113
+ this._probeTarget = {
1114
+ sandboxId: json.id,
1115
+ instanceUrl: json.instanceUrl
1116
+ };
1098
1117
  this._transportReadyPromise = this._probeSidecarThenRegister(json.id, json.instanceUrl, generation);
1099
1118
  }
1100
1119
  /**
@@ -1104,8 +1123,9 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
1104
1123
  * fall back to the lease path until the probe succeeds.
1105
1124
  *
1106
1125
  * If the sidecar never comes up within {@link SIDECAR_PROBE_TIMEOUT_MS},
1107
- * the registry stays unpopulated and all execs go via lease for this
1108
- * 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.
1109
1129
  *
1110
1130
  * @param generation - The probe generation captured at call time. If this
1111
1131
  * no longer matches `_probeGeneration` when the probe succeeds, the probe
@@ -1139,6 +1159,7 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
1139
1159
  } catch {}
1140
1160
  await new Promise((r) => setTimeout(r, SIDECAR_PROBE_INTERVAL_MS));
1141
1161
  }
1162
+ if (generation === this._probeGeneration && this._transportReadyPromise) this._transportReadyPromise = null;
1142
1163
  this.logger.warn("platform-workspace probe timed out", {
1143
1164
  sandboxId,
1144
1165
  sessionId: this._client.sessionId,
@@ -1159,7 +1180,12 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
1159
1180
  */
1160
1181
  async _awaitTransportReady() {
1161
1182
  if (this._sandboxId && this._addressRegistry?.get(this._sandboxId)) return;
1162
- 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
+ }
1163
1189
  await Promise.race([this._transportReadyPromise, new Promise((r) => setTimeout(r, TRANSPORT_READY_WAIT_MS))]);
1164
1190
  }
1165
1191
  /**
@@ -1226,6 +1252,8 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
1226
1252
  if (!this._sandboxId) return;
1227
1253
  const destroyedSandboxId = this._sandboxId;
1228
1254
  this._probeGeneration++;
1255
+ this._probeTarget = null;
1256
+ this._transportReadyPromise = null;
1229
1257
  await this._client.request(`/sandbox/${encodeURIComponent(destroyedSandboxId)}`, { method: "DELETE" });
1230
1258
  this._sandboxId = void 0;
1231
1259
  this._createdAt = null;
@@ -1236,6 +1264,8 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
1236
1264
  async snapshot() {
1237
1265
  await this.captureCheckpoint();
1238
1266
  }
1267
+ /** Snapshots persist real checkpoints that can seed future sandboxes. */
1268
+ supportsCheckpoints = true;
1239
1269
  /**
1240
1270
  * Capture the sandbox's checkpoint on demand, outside any refresh timer the
1241
1271
  * workspace-proxy owns internally.
@@ -1355,6 +1385,9 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
1355
1385
  * the cached `'running'` state (see `MastraSandbox._start`).
1356
1386
  */
1357
1387
  _clearDestroyedState(destroyedSandboxId) {
1388
+ this._probeGeneration++;
1389
+ this._probeTarget = null;
1390
+ this._transportReadyPromise = null;
1358
1391
  this._sandboxId = void 0;
1359
1392
  this._createdAt = null;
1360
1393
  this._lease = null;