@mastra/platform-workspace 1.7.0-alpha.1 → 1.7.0
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.cjs +15 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -1
- package/dist/index.js.map +1 -1
- package/dist/sandbox.d.ts +11 -0
- package/dist/sandbox.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -1165,6 +1165,7 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
1165
1165
|
_usesProviderRoutes;
|
|
1166
1166
|
_environmentId;
|
|
1167
1167
|
_sandboxId;
|
|
1168
|
+
_reattach;
|
|
1168
1169
|
_seedCheckpointName;
|
|
1169
1170
|
_templateDefinition;
|
|
1170
1171
|
_templateBuildEnvs;
|
|
@@ -1256,6 +1257,7 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
1256
1257
|
this._environmentId = options.environmentId ?? process.env.MASTRA_ENVIRONMENT_ID ?? "";
|
|
1257
1258
|
if (!this._environmentId && !options.sandboxId) throw new Error("environmentId is required");
|
|
1258
1259
|
this._sandboxId = options.sandboxId;
|
|
1260
|
+
this._reattach = options.reattach ?? "best-effort";
|
|
1259
1261
|
this._seedCheckpointName = options.seedCheckpointName;
|
|
1260
1262
|
this._usesProviderRoutes = options.template !== void 0;
|
|
1261
1263
|
this._template = options.template;
|
|
@@ -1272,6 +1274,16 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
1272
1274
|
generateId() {
|
|
1273
1275
|
return `platform-sandbox-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
1274
1276
|
}
|
|
1277
|
+
_failIfReattachRequired(reason, cause) {
|
|
1278
|
+
if (this._reattach !== "required") return;
|
|
1279
|
+
throw new _mastra_core_workspace.SandboxError(`Platform sandbox ${this._sandboxId} could not be reattached (${reason}); refusing to provision a replacement because reattach is 'required'. Clear the persisted sandboxId to start a fresh sandbox.`, "SANDBOX_REATTACH_FAILED", {
|
|
1280
|
+
provider: "platform",
|
|
1281
|
+
sandboxId: this._sandboxId,
|
|
1282
|
+
logicalId: this.id,
|
|
1283
|
+
reason,
|
|
1284
|
+
...cause !== void 0 && { cause }
|
|
1285
|
+
});
|
|
1286
|
+
}
|
|
1275
1287
|
_request(path, options = {}) {
|
|
1276
1288
|
return this._usesProviderRoutes ? this._client.requestProvider(path, options) : this._client.request(path, options);
|
|
1277
1289
|
}
|
|
@@ -1301,6 +1313,7 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
1301
1313
|
fetch: this._client.fetch,
|
|
1302
1314
|
environmentId: this._environmentId,
|
|
1303
1315
|
...options.sandboxId !== void 0 && { sandboxId: options.sandboxId },
|
|
1316
|
+
reattach: this._reattach,
|
|
1304
1317
|
...seedCheckpointName !== void 0 && { seedCheckpointName },
|
|
1305
1318
|
...this._template !== void 0 && { template: this._template },
|
|
1306
1319
|
idleTimeoutMinutes: options.idleTimeoutMinutes ?? this._idleTimeoutMinutes,
|
|
@@ -1343,9 +1356,11 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
1343
1356
|
this._logStartComplete(json.id, startedAt, requestMs, "reattach");
|
|
1344
1357
|
return { outcome: "connected" };
|
|
1345
1358
|
}
|
|
1359
|
+
this._failIfReattachRequired("destroyed");
|
|
1346
1360
|
this._sandboxId = void 0;
|
|
1347
1361
|
} catch (error) {
|
|
1348
1362
|
if (!(error instanceof PlatformApiError) || error.status !== 404 && error.status !== 410) throw error;
|
|
1363
|
+
this._failIfReattachRequired(String(error.status), error);
|
|
1349
1364
|
this._sandboxId = void 0;
|
|
1350
1365
|
}
|
|
1351
1366
|
if (!this._environmentId) throw new Error("environmentId is required");
|