@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/README.md +18 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/index.cjs +21 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -4
- package/dist/index.js.map +1 -1
- package/dist/provider.d.ts.map +1 -1
- package/package.json +2 -2
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` or `MASTRA_PLATFORM_SECRET_KEY` | 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
|
|
@@ -32,7 +49,7 @@ const agent = new Agent({
|
|
|
32
49
|
|
|
33
50
|
## Documentation
|
|
34
51
|
|
|
35
|
-
Both providers authenticate through the workspace proxy with `
|
|
52
|
+
Both providers authenticate through the workspace proxy with `MASTRA_PROJECT_ID` and a credential. Set `MASTRA_PLATFORM_SECRET_KEY` to your organization API key for local development. The deployed `MASTRA_PLATFORM_ACCESS_TOKEN` takes precedence when present; an explicit `accessToken` constructor option takes precedence over both. Blank environment credentials are ignored. `PlatformSandbox` also requires `MASTRA_ENVIRONMENT_ID`; `PlatformFilesystem` requires `MASTRA_PLATFORM_BUCKET_NAME`. Constructor values override environment variables, and `MASTRA_WORKSPACE_PROXY_URL` can point requests at a non-production proxy.
|
|
36
53
|
|
|
37
54
|
`PlatformFilesystem` implements the Mastra filesystem interface against a Platform bucket. It supports reading, writing, listing, moving, and deleting files, preserves reserved characters in object names, and can be mounted with `readOnly: true` to reject mutations.
|
|
38
55
|
|
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,CAA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;IAC3H,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,yGAAyG;IACzG,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IAE1C,YAAY,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EASvC;CACF;AAED,qBAAa,cAAc;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAC1C,qFAAqF;IACrF,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC;IAE7B,YAAY,OAAO,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
|
|
@@ -50,10 +67,10 @@ function resolvePlatformOptions(options) {
|
|
|
50
67
|
const environmentSandboxProvider = process.env.SANDBOX_PROVIDER?.trim();
|
|
51
68
|
const configuredSandboxProvider = options.sandboxProvider ?? environmentSandboxProvider;
|
|
52
69
|
return {
|
|
53
|
-
accessToken: requireOption(options.accessToken ?? process.env.MASTRA_PLATFORM_ACCESS_TOKEN, "accessToken"),
|
|
70
|
+
accessToken: requireOption(options.accessToken ?? (process.env.MASTRA_PLATFORM_ACCESS_TOKEN?.trim() || process.env.MASTRA_PLATFORM_SECRET_KEY?.trim()), "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,
|
|
@@ -2252,7 +2269,7 @@ const platformSandboxProvider = {
|
|
|
2252
2269
|
properties: {
|
|
2253
2270
|
accessToken: {
|
|
2254
2271
|
type: "string",
|
|
2255
|
-
description: "Mastra Platform
|
|
2272
|
+
description: "Mastra Platform credential (falls back to MASTRA_PLATFORM_ACCESS_TOKEN, then MASTRA_PLATFORM_SECRET_KEY)"
|
|
2256
2273
|
},
|
|
2257
2274
|
projectId: {
|
|
2258
2275
|
type: "string",
|
|
@@ -2308,7 +2325,7 @@ const platformFilesystemProvider = {
|
|
|
2308
2325
|
properties: {
|
|
2309
2326
|
accessToken: {
|
|
2310
2327
|
type: "string",
|
|
2311
|
-
description: "Mastra Platform
|
|
2328
|
+
description: "Mastra Platform credential (falls back to MASTRA_PLATFORM_ACCESS_TOKEN, then MASTRA_PLATFORM_SECRET_KEY)"
|
|
2312
2329
|
},
|
|
2313
2330
|
projectId: {
|
|
2314
2331
|
type: "string",
|