@mastra/platform-workspace 1.3.0-alpha.0 → 1.3.0-alpha.2
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 +36 -0
- package/dist/index.cjs +40 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +40 -6
- package/dist/index.js.map +1 -1
- package/dist/sandbox.d.ts +16 -4
- package/dist/sandbox.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @mastra/platform
|
|
2
2
|
|
|
3
|
+
## 1.3.0-alpha.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Added fallback checkpoint forwarding for Platform sandboxes so the workspace proxy can seed fresh sessions without changing their primary recovery key. ([#21803](https://github.com/mastra-ai/mastra/pull/21803))
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
const sandbox = new PlatformSandbox({
|
|
11
|
+
id: 'session-42',
|
|
12
|
+
seedCheckpointName: 'repo-base',
|
|
13
|
+
});
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [[`58c43d3`](https://github.com/mastra-ai/mastra/commit/58c43d3f7cb2eeaeb8ac733ae71dde822348e588)]:
|
|
17
|
+
- @mastra/core@1.60.0-alpha.14
|
|
18
|
+
|
|
19
|
+
## 1.3.0-alpha.1
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- 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))
|
|
24
|
+
|
|
25
|
+
- 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))
|
|
26
|
+
|
|
27
|
+
- 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))
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
// Gate checkpoint-dependent work on the provider's capability flag.
|
|
31
|
+
if (sandbox.supportsCheckpoints) {
|
|
32
|
+
await sandbox.snapshot(); // persists a checkpoint that can seed a later boot
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
- 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)]:
|
|
37
|
+
- @mastra/core@1.60.0-alpha.13
|
|
38
|
+
|
|
3
39
|
## 1.3.0-alpha.0
|
|
4
40
|
|
|
5
41
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -859,6 +859,7 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
859
859
|
_client;
|
|
860
860
|
_environmentId;
|
|
861
861
|
_sandboxId;
|
|
862
|
+
_seedCheckpointName;
|
|
862
863
|
_idleTimeoutMinutes;
|
|
863
864
|
_networkIsolation;
|
|
864
865
|
_env;
|
|
@@ -938,6 +939,12 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
938
939
|
* failed/timed out, but now coalesced via `_leaseInFlight`).
|
|
939
940
|
*/
|
|
940
941
|
_transportReadyPromise = null;
|
|
942
|
+
/**
|
|
943
|
+
* The sidecar address of the most recent `start()`, kept so a timed-out
|
|
944
|
+
* probe can be restarted by a later exec ({@link _awaitTransportReady})
|
|
945
|
+
* instead of pinning the sandbox to the lease path for its lifetime.
|
|
946
|
+
*/
|
|
947
|
+
_probeTarget = null;
|
|
941
948
|
constructor(options = {}) {
|
|
942
949
|
super({
|
|
943
950
|
...options,
|
|
@@ -950,6 +957,7 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
950
957
|
this._environmentId = options.environmentId ?? process.env.MASTRA_ENVIRONMENT_ID ?? "";
|
|
951
958
|
if (!this._environmentId && !options.sandboxId) throw new Error("environmentId is required");
|
|
952
959
|
this._sandboxId = options.sandboxId;
|
|
960
|
+
this._seedCheckpointName = options.seedCheckpointName;
|
|
953
961
|
this._idleTimeoutMinutes = options.idleTimeoutMinutes;
|
|
954
962
|
this._networkIsolation = options.networkIsolation;
|
|
955
963
|
this._env = options.env ?? {};
|
|
@@ -986,6 +994,7 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
986
994
|
fetch: this._client.fetch,
|
|
987
995
|
environmentId: this._environmentId,
|
|
988
996
|
...options.sandboxId !== void 0 && { sandboxId: options.sandboxId },
|
|
997
|
+
...(options.seedCheckpointName ?? this._seedCheckpointName) !== void 0 && { seedCheckpointName: options.seedCheckpointName ?? this._seedCheckpointName },
|
|
989
998
|
idleTimeoutMinutes: options.idleTimeoutMinutes ?? this._idleTimeoutMinutes,
|
|
990
999
|
...this._networkIsolation !== void 0 && { networkIsolation: this._networkIsolation },
|
|
991
1000
|
env: options.env ?? this._env,
|
|
@@ -1032,6 +1041,7 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
1032
1041
|
if (!this._environmentId) throw new Error("environmentId is required");
|
|
1033
1042
|
const body = JSON.stringify({
|
|
1034
1043
|
id: this.id,
|
|
1044
|
+
seedCheckpointName: this._seedCheckpointName,
|
|
1035
1045
|
environmentId: this._environmentId,
|
|
1036
1046
|
idleTimeoutMinutes: this._idleTimeoutMinutes,
|
|
1037
1047
|
networkIsolation: this._networkIsolation,
|
|
@@ -1090,14 +1100,24 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
1090
1100
|
* HTTP round-trip.
|
|
1091
1101
|
*
|
|
1092
1102
|
* `null`/absent `instanceUrl` (proxy discovery failed, or an older proxy
|
|
1093
|
-
* that predates the field)
|
|
1094
|
-
*
|
|
1103
|
+
* that predates the field) evicts any stale registry address and leaves
|
|
1104
|
+
* executes on the lease path.
|
|
1095
1105
|
*/
|
|
1096
1106
|
_populateAddressFromResponse(json) {
|
|
1097
1107
|
if (!this._addressRegistry) return;
|
|
1098
|
-
if (!json.instanceUrl)
|
|
1108
|
+
if (!json.instanceUrl) {
|
|
1109
|
+
this._probeGeneration++;
|
|
1110
|
+
this._probeTarget = null;
|
|
1111
|
+
this._transportReadyPromise = null;
|
|
1112
|
+
this._addressRegistry.delete(json.id);
|
|
1113
|
+
return;
|
|
1114
|
+
}
|
|
1099
1115
|
this._addressRegistry.delete(json.id);
|
|
1100
1116
|
const generation = ++this._probeGeneration;
|
|
1117
|
+
this._probeTarget = {
|
|
1118
|
+
sandboxId: json.id,
|
|
1119
|
+
instanceUrl: json.instanceUrl
|
|
1120
|
+
};
|
|
1101
1121
|
this._transportReadyPromise = this._probeSidecarThenRegister(json.id, json.instanceUrl, generation);
|
|
1102
1122
|
}
|
|
1103
1123
|
/**
|
|
@@ -1107,8 +1127,9 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
1107
1127
|
* fall back to the lease path until the probe succeeds.
|
|
1108
1128
|
*
|
|
1109
1129
|
* If the sidecar never comes up within {@link SIDECAR_PROBE_TIMEOUT_MS},
|
|
1110
|
-
* the registry stays unpopulated
|
|
1111
|
-
*
|
|
1130
|
+
* the registry stays unpopulated, `_transportReadyPromise` is cleared,
|
|
1131
|
+
* and a later {@link _awaitTransportReady} call restarts the probe
|
|
1132
|
+
* instead of pinning this sandbox to the lease path.
|
|
1112
1133
|
*
|
|
1113
1134
|
* @param generation - The probe generation captured at call time. If this
|
|
1114
1135
|
* no longer matches `_probeGeneration` when the probe succeeds, the probe
|
|
@@ -1142,6 +1163,7 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
1142
1163
|
} catch {}
|
|
1143
1164
|
await new Promise((r) => setTimeout(r, SIDECAR_PROBE_INTERVAL_MS));
|
|
1144
1165
|
}
|
|
1166
|
+
if (generation === this._probeGeneration && this._transportReadyPromise) this._transportReadyPromise = null;
|
|
1145
1167
|
this.logger.warn("platform-workspace probe timed out", {
|
|
1146
1168
|
sandboxId,
|
|
1147
1169
|
sessionId: this._client.sessionId,
|
|
@@ -1162,7 +1184,12 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
1162
1184
|
*/
|
|
1163
1185
|
async _awaitTransportReady() {
|
|
1164
1186
|
if (this._sandboxId && this._addressRegistry?.get(this._sandboxId)) return;
|
|
1165
|
-
if (!this._transportReadyPromise)
|
|
1187
|
+
if (!this._transportReadyPromise) {
|
|
1188
|
+
const target = this._probeTarget;
|
|
1189
|
+
if (!target || this._sandboxId !== target.sandboxId) return;
|
|
1190
|
+
const generation = ++this._probeGeneration;
|
|
1191
|
+
this._transportReadyPromise = this._probeSidecarThenRegister(target.sandboxId, target.instanceUrl, generation);
|
|
1192
|
+
}
|
|
1166
1193
|
await Promise.race([this._transportReadyPromise, new Promise((r) => setTimeout(r, TRANSPORT_READY_WAIT_MS))]);
|
|
1167
1194
|
}
|
|
1168
1195
|
/**
|
|
@@ -1229,6 +1256,8 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
1229
1256
|
if (!this._sandboxId) return;
|
|
1230
1257
|
const destroyedSandboxId = this._sandboxId;
|
|
1231
1258
|
this._probeGeneration++;
|
|
1259
|
+
this._probeTarget = null;
|
|
1260
|
+
this._transportReadyPromise = null;
|
|
1232
1261
|
await this._client.request(`/sandbox/${encodeURIComponent(destroyedSandboxId)}`, { method: "DELETE" });
|
|
1233
1262
|
this._sandboxId = void 0;
|
|
1234
1263
|
this._createdAt = null;
|
|
@@ -1239,6 +1268,8 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
1239
1268
|
async snapshot() {
|
|
1240
1269
|
await this.captureCheckpoint();
|
|
1241
1270
|
}
|
|
1271
|
+
/** Snapshots persist real checkpoints that can seed future sandboxes. */
|
|
1272
|
+
supportsCheckpoints = true;
|
|
1242
1273
|
/**
|
|
1243
1274
|
* Capture the sandbox's checkpoint on demand, outside any refresh timer the
|
|
1244
1275
|
* workspace-proxy owns internally.
|
|
@@ -1358,6 +1389,9 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
1358
1389
|
* the cached `'running'` state (see `MastraSandbox._start`).
|
|
1359
1390
|
*/
|
|
1360
1391
|
_clearDestroyedState(destroyedSandboxId) {
|
|
1392
|
+
this._probeGeneration++;
|
|
1393
|
+
this._probeTarget = null;
|
|
1394
|
+
this._transportReadyPromise = null;
|
|
1361
1395
|
this._sandboxId = void 0;
|
|
1362
1396
|
this._createdAt = null;
|
|
1363
1397
|
this._lease = null;
|