@mastra/platform-workspace 1.5.1-alpha.0 → 1.6.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/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
@@ -29,7 +46,7 @@ function resolvePlatformOptions(options) {
29
46
  accessToken: requireOption(options.accessToken ?? process.env.MASTRA_PLATFORM_ACCESS_TOKEN, "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,