@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 +20 -0
- package/dist/index.cjs +36 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -6
- package/dist/index.js.map +1 -1
- package/dist/sandbox.d.ts +13 -4
- package/dist/sandbox.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -914,6 +914,12 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
|
|
|
914
914
|
* failed/timed out, but now coalesced via `_leaseInFlight`).
|
|
915
915
|
*/
|
|
916
916
|
_transportReadyPromise = null;
|
|
917
|
+
/**
|
|
918
|
+
* The sidecar address of the most recent `start()`, kept so a timed-out
|
|
919
|
+
* probe can be restarted by a later exec ({@link _awaitTransportReady})
|
|
920
|
+
* instead of pinning the sandbox to the lease path for its lifetime.
|
|
921
|
+
*/
|
|
922
|
+
_probeTarget = null;
|
|
917
923
|
constructor(options = {}) {
|
|
918
924
|
super({
|
|
919
925
|
...options,
|
|
@@ -1066,14 +1072,24 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
|
|
|
1066
1072
|
* HTTP round-trip.
|
|
1067
1073
|
*
|
|
1068
1074
|
* `null`/absent `instanceUrl` (proxy discovery failed, or an older proxy
|
|
1069
|
-
* that predates the field)
|
|
1070
|
-
*
|
|
1075
|
+
* that predates the field) evicts any stale registry address and leaves
|
|
1076
|
+
* executes on the lease path.
|
|
1071
1077
|
*/
|
|
1072
1078
|
_populateAddressFromResponse(json) {
|
|
1073
1079
|
if (!this._addressRegistry) return;
|
|
1074
|
-
if (!json.instanceUrl)
|
|
1080
|
+
if (!json.instanceUrl) {
|
|
1081
|
+
this._probeGeneration++;
|
|
1082
|
+
this._probeTarget = null;
|
|
1083
|
+
this._transportReadyPromise = null;
|
|
1084
|
+
this._addressRegistry.delete(json.id);
|
|
1085
|
+
return;
|
|
1086
|
+
}
|
|
1075
1087
|
this._addressRegistry.delete(json.id);
|
|
1076
1088
|
const generation = ++this._probeGeneration;
|
|
1089
|
+
this._probeTarget = {
|
|
1090
|
+
sandboxId: json.id,
|
|
1091
|
+
instanceUrl: json.instanceUrl
|
|
1092
|
+
};
|
|
1077
1093
|
this._transportReadyPromise = this._probeSidecarThenRegister(json.id, json.instanceUrl, generation);
|
|
1078
1094
|
}
|
|
1079
1095
|
/**
|
|
@@ -1083,8 +1099,9 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
|
|
|
1083
1099
|
* fall back to the lease path until the probe succeeds.
|
|
1084
1100
|
*
|
|
1085
1101
|
* If the sidecar never comes up within {@link SIDECAR_PROBE_TIMEOUT_MS},
|
|
1086
|
-
* the registry stays unpopulated
|
|
1087
|
-
*
|
|
1102
|
+
* the registry stays unpopulated, `_transportReadyPromise` is cleared,
|
|
1103
|
+
* and a later {@link _awaitTransportReady} call restarts the probe
|
|
1104
|
+
* instead of pinning this sandbox to the lease path.
|
|
1088
1105
|
*
|
|
1089
1106
|
* @param generation - The probe generation captured at call time. If this
|
|
1090
1107
|
* no longer matches `_probeGeneration` when the probe succeeds, the probe
|
|
@@ -1118,6 +1135,7 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
|
|
|
1118
1135
|
} catch {}
|
|
1119
1136
|
await new Promise((r) => setTimeout(r, SIDECAR_PROBE_INTERVAL_MS));
|
|
1120
1137
|
}
|
|
1138
|
+
if (generation === this._probeGeneration && this._transportReadyPromise) this._transportReadyPromise = null;
|
|
1121
1139
|
this.logger.warn("platform-workspace probe timed out", {
|
|
1122
1140
|
sandboxId,
|
|
1123
1141
|
sessionId: this._client.sessionId,
|
|
@@ -1138,7 +1156,12 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
|
|
|
1138
1156
|
*/
|
|
1139
1157
|
async _awaitTransportReady() {
|
|
1140
1158
|
if (this._sandboxId && this._addressRegistry?.get(this._sandboxId)) return;
|
|
1141
|
-
if (!this._transportReadyPromise)
|
|
1159
|
+
if (!this._transportReadyPromise) {
|
|
1160
|
+
const target = this._probeTarget;
|
|
1161
|
+
if (!target || this._sandboxId !== target.sandboxId) return;
|
|
1162
|
+
const generation = ++this._probeGeneration;
|
|
1163
|
+
this._transportReadyPromise = this._probeSidecarThenRegister(target.sandboxId, target.instanceUrl, generation);
|
|
1164
|
+
}
|
|
1142
1165
|
await Promise.race([this._transportReadyPromise, new Promise((r) => setTimeout(r, TRANSPORT_READY_WAIT_MS))]);
|
|
1143
1166
|
}
|
|
1144
1167
|
/**
|
|
@@ -1205,6 +1228,8 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
|
|
|
1205
1228
|
if (!this._sandboxId) return;
|
|
1206
1229
|
const destroyedSandboxId = this._sandboxId;
|
|
1207
1230
|
this._probeGeneration++;
|
|
1231
|
+
this._probeTarget = null;
|
|
1232
|
+
this._transportReadyPromise = null;
|
|
1208
1233
|
await this._client.request(`/sandbox/${encodeURIComponent(destroyedSandboxId)}`, { method: "DELETE" });
|
|
1209
1234
|
this._sandboxId = void 0;
|
|
1210
1235
|
this._createdAt = null;
|
|
@@ -1215,6 +1240,8 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
|
|
|
1215
1240
|
async snapshot() {
|
|
1216
1241
|
await this.captureCheckpoint();
|
|
1217
1242
|
}
|
|
1243
|
+
/** Snapshots persist real checkpoints that can seed future sandboxes. */
|
|
1244
|
+
supportsCheckpoints = true;
|
|
1218
1245
|
/**
|
|
1219
1246
|
* Capture the sandbox's checkpoint on demand, outside any refresh timer the
|
|
1220
1247
|
* workspace-proxy owns internally.
|
|
@@ -1334,6 +1361,9 @@ var PlatformSandbox = class PlatformSandbox extends MastraSandbox {
|
|
|
1334
1361
|
* the cached `'running'` state (see `MastraSandbox._start`).
|
|
1335
1362
|
*/
|
|
1336
1363
|
_clearDestroyedState(destroyedSandboxId) {
|
|
1364
|
+
this._probeGeneration++;
|
|
1365
|
+
this._probeTarget = null;
|
|
1366
|
+
this._transportReadyPromise = null;
|
|
1337
1367
|
this._sandboxId = void 0;
|
|
1338
1368
|
this._createdAt = null;
|
|
1339
1369
|
this._lease = null;
|