@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/README.md +17 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/index.cjs +18 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -8,6 +8,23 @@ Mastra Platform workspace provider. It gives agents environment-scoped sandbox e
|
|
|
8
8
|
npm install @mastra/platform-workspace
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
## Configuration
|
|
12
|
+
|
|
13
|
+
All options can be passed to the constructor or read from environment variables:
|
|
14
|
+
|
|
15
|
+
| Option | Env var | Required |
|
|
16
|
+
| ----------------- | ------------------------------ | ------------------------------- |
|
|
17
|
+
| `accessToken` | `MASTRA_PLATFORM_ACCESS_TOKEN` | Yes |
|
|
18
|
+
| `projectId` | `MASTRA_PROJECT_ID` | Yes |
|
|
19
|
+
| `environmentId` | `MASTRA_ENVIRONMENT_ID` | Yes (sandbox) |
|
|
20
|
+
| `actingUserId` | — | No (sandbox) |
|
|
21
|
+
| `sandboxProvider` | `SANDBOX_PROVIDER` | No (sandbox, defaults to `e2b`) |
|
|
22
|
+
| `bucketName` | `MASTRA_PLATFORM_BUCKET_NAME` | Yes (filesystem) |
|
|
23
|
+
|
|
24
|
+
The proxy URL defaults to `https://workspaces.mastra.ai`. Set `MASTRA_PLATFORM_REGION` to `us` or `eu` (case-insensitive) to route to the regional replica at `https://workspaces.us.mastra.ai` or `https://workspaces.eu.mastra.ai`. An explicit `MASTRA_WORKSPACE_PROXY_URL` (useful for staging) overrides both.
|
|
25
|
+
|
|
26
|
+
Requests to the proxy are authenticated with `Authorization: Bearer <accessToken>`. For sandbox requests authenticated with a project access token, set `actingUserId` to the stable opaque user subject from your authentication system. It is sent as `x-acting-user-id` for token partitioning and attribution; it is not an authorization claim.
|
|
27
|
+
|
|
11
28
|
## Usage
|
|
12
29
|
|
|
13
30
|
```typescript
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;CAC/D;AAED,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,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O,EAAE,qBAAqB,EAUzC;IAEK,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B,GAAG,OAAO,CAAC,QAAQ,CAAC,CAEnF;IAEK,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B,GAAG,OAAO,CAAC,QAAQ,CAAC,CAE3F;YAEa,aAAa;CA2B5B"}
|
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,23 @@ let util = require("util");
|
|
|
31
31
|
let crypto = require("crypto");
|
|
32
32
|
//#region src/client.ts
|
|
33
33
|
const DEFAULT_PROXY_URL = "https://workspaces.mastra.ai";
|
|
34
|
+
const REGIONAL_PROXY_URLS = {
|
|
35
|
+
us: "https://workspaces.us.mastra.ai",
|
|
36
|
+
eu: "https://workspaces.eu.mastra.ai"
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Resolves the workspace proxy URL, preferring an explicit
|
|
40
|
+
* `MASTRA_WORKSPACE_PROXY_URL` override, then a regional replica selected by
|
|
41
|
+
* `MASTRA_PLATFORM_REGION` (case-insensitive `us` or `eu`), then the global
|
|
42
|
+
* default. Unknown region values fall through to the global default.
|
|
43
|
+
*/
|
|
44
|
+
function resolveProxyUrl() {
|
|
45
|
+
const override = process.env.MASTRA_WORKSPACE_PROXY_URL?.trim();
|
|
46
|
+
if (override) return override;
|
|
47
|
+
const region = process.env.MASTRA_PLATFORM_REGION?.trim().toLowerCase();
|
|
48
|
+
if (region === "us" || region === "eu") return REGIONAL_PROXY_URLS[region];
|
|
49
|
+
return DEFAULT_PROXY_URL;
|
|
50
|
+
}
|
|
34
51
|
/**
|
|
35
52
|
* Default per-request timeout for calls to the workspace proxy. Applied only
|
|
36
53
|
* when the caller doesn't already pass an `AbortSignal`. Long-running routes
|
|
@@ -53,7 +70,7 @@ function resolvePlatformOptions(options) {
|
|
|
53
70
|
accessToken: requireOption(options.accessToken ?? process.env.MASTRA_PLATFORM_ACCESS_TOKEN, "accessToken"),
|
|
54
71
|
projectId: requireOption(options.projectId ?? process.env.MASTRA_PROJECT_ID, "projectId"),
|
|
55
72
|
actingUserId: options.actingUserId?.trim() || void 0,
|
|
56
|
-
proxyUrl: (
|
|
73
|
+
proxyUrl: resolveProxyUrl().replace(/\/$/, ""),
|
|
57
74
|
sandboxProvider: resolveSandboxProvider(configuredSandboxProvider),
|
|
58
75
|
sessionId: options.sessionId,
|
|
59
76
|
threadId: options.threadId,
|