@mastra/platform-workspace 1.5.1-alpha.0 → 1.6.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/dist/index.js CHANGED
@@ -7,6 +7,23 @@ import { promisify } from "util";
7
7
  import { createHash } from "crypto";
8
8
  //#region src/client.ts
9
9
  const DEFAULT_PROXY_URL = "https://workspaces.mastra.ai";
10
+ const REGIONAL_PROXY_URLS = {
11
+ us: "https://workspaces.us.mastra.ai",
12
+ eu: "https://workspaces.eu.mastra.ai"
13
+ };
14
+ /**
15
+ * Resolves the workspace proxy URL, preferring an explicit
16
+ * `MASTRA_WORKSPACE_PROXY_URL` override, then a regional replica selected by
17
+ * `MASTRA_PLATFORM_REGION` (case-insensitive `us` or `eu`), then the global
18
+ * default. Unknown region values fall through to the global default.
19
+ */
20
+ function resolveProxyUrl() {
21
+ const override = process.env.MASTRA_WORKSPACE_PROXY_URL?.trim();
22
+ if (override) return override;
23
+ const region = process.env.MASTRA_PLATFORM_REGION?.trim().toLowerCase();
24
+ if (region === "us" || region === "eu") return REGIONAL_PROXY_URLS[region];
25
+ return DEFAULT_PROXY_URL;
26
+ }
10
27
  /**
11
28
  * Default per-request timeout for calls to the workspace proxy. Applied only
12
29
  * when the caller doesn't already pass an `AbortSignal`. Long-running routes
@@ -26,10 +43,10 @@ function resolvePlatformOptions(options) {
26
43
  const environmentSandboxProvider = process.env.SANDBOX_PROVIDER?.trim();
27
44
  const configuredSandboxProvider = options.sandboxProvider ?? environmentSandboxProvider;
28
45
  return {
29
- accessToken: requireOption(options.accessToken ?? process.env.MASTRA_PLATFORM_ACCESS_TOKEN, "accessToken"),
46
+ accessToken: requireOption(options.accessToken ?? (process.env.MASTRA_PLATFORM_ACCESS_TOKEN?.trim() || process.env.MASTRA_PLATFORM_SECRET_KEY?.trim()), "accessToken"),
30
47
  projectId: requireOption(options.projectId ?? process.env.MASTRA_PROJECT_ID, "projectId"),
31
48
  actingUserId: options.actingUserId?.trim() || void 0,
32
- proxyUrl: (process.env.MASTRA_WORKSPACE_PROXY_URL ?? DEFAULT_PROXY_URL).replace(/\/$/, ""),
49
+ proxyUrl: resolveProxyUrl().replace(/\/$/, ""),
33
50
  sandboxProvider: resolveSandboxProvider(configuredSandboxProvider),
34
51
  sessionId: options.sessionId,
35
52
  threadId: options.threadId,
@@ -2228,7 +2245,7 @@ const platformSandboxProvider = {
2228
2245
  properties: {
2229
2246
  accessToken: {
2230
2247
  type: "string",
2231
- description: "Mastra Platform access token (falls back to MASTRA_PLATFORM_ACCESS_TOKEN)"
2248
+ description: "Mastra Platform credential (falls back to MASTRA_PLATFORM_ACCESS_TOKEN, then MASTRA_PLATFORM_SECRET_KEY)"
2232
2249
  },
2233
2250
  projectId: {
2234
2251
  type: "string",
@@ -2284,7 +2301,7 @@ const platformFilesystemProvider = {
2284
2301
  properties: {
2285
2302
  accessToken: {
2286
2303
  type: "string",
2287
- description: "Mastra Platform access token (falls back to MASTRA_PLATFORM_ACCESS_TOKEN)"
2304
+ description: "Mastra Platform credential (falls back to MASTRA_PLATFORM_ACCESS_TOKEN, then MASTRA_PLATFORM_SECRET_KEY)"
2288
2305
  },
2289
2306
  projectId: {
2290
2307
  type: "string",