@mastra/platform-workspace 1.2.0 → 1.2.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/CHANGELOG.md +36 -0
- package/README.md +2 -1
- package/dist/client.d.ts +3 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/index.cjs +9 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/provider.d.ts.map +1 -1
- package/dist/sandbox.d.ts.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @mastra/platform
|
|
2
2
|
|
|
3
|
+
## 1.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Send opaque acting-user subjects with Platform sandbox requests, including Factory creation and reattachment flows. ([#20754](https://github.com/mastra-ai/mastra/pull/20754))
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { PlatformSandbox } from '@mastra/platform-workspace';
|
|
11
|
+
|
|
12
|
+
const sandbox = new PlatformSandbox({
|
|
13
|
+
environmentId: 'env_abc',
|
|
14
|
+
actingUserId: auth.user.id,
|
|
15
|
+
});
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`088e41e`](https://github.com/mastra-ai/mastra/commit/088e41e434ed05f2c674b254f1034ec46a57a7be), [`aa3e7be`](https://github.com/mastra-ai/mastra/commit/aa3e7be30f8addb0278ea74429f4df054517a287), [`d118873`](https://github.com/mastra-ai/mastra/commit/d118873cfd5074b1f814a1c169a97ca7a3a29174), [`b2f0013`](https://github.com/mastra-ai/mastra/commit/b2f0013375588d40c03c13e843b99c0ff8872ca5), [`3b541ae`](https://github.com/mastra-ai/mastra/commit/3b541ae5d410c52b80a7e381d84d021cddb9a449), [`79dd7c2`](https://github.com/mastra-ai/mastra/commit/79dd7c261ee6be1fafedd4651959394db21d2cba), [`90822db`](https://github.com/mastra-ai/mastra/commit/90822dba08fb2169c518e4a6d7f127c098eb46b8), [`898bba4`](https://github.com/mastra-ai/mastra/commit/898bba46d4806dd255a44e5dc3a3d5827eaefdfe), [`b9a28ec`](https://github.com/mastra-ai/mastra/commit/b9a28ecf7acdc0cb7a543d5b660f9fbee301df9a), [`f9aab1c`](https://github.com/mastra-ai/mastra/commit/f9aab1cfc3fda03238a7fd7bd8b794e07497878c), [`3700208`](https://github.com/mastra-ai/mastra/commit/37002080c7838267803a7e579a7d58b908d62f36), [`e31421b`](https://github.com/mastra-ai/mastra/commit/e31421bc9c11c03c6e74f447ecb5820000e2b9d7), [`8b7131e`](https://github.com/mastra-ai/mastra/commit/8b7131eb0407f58f5205e68fb27b81f026488f28), [`161258b`](https://github.com/mastra-ai/mastra/commit/161258b3473a6d0fce00a43cab59d119a49a232f), [`aece0e7`](https://github.com/mastra-ai/mastra/commit/aece0e7cb124ae1eb1230689b887f5554b9a0bf0), [`ae79e34`](https://github.com/mastra-ai/mastra/commit/ae79e34c0bd8674fc24c7524217bfc4a051c6136), [`59d8898`](https://github.com/mastra-ai/mastra/commit/59d8898c8cb48b342fe5bcb5eee803cc8cc95060), [`a6c4399`](https://github.com/mastra-ai/mastra/commit/a6c4399763590b3dae21a2c81826e89a3b1deee4), [`a40f915`](https://github.com/mastra-ai/mastra/commit/a40f9157690d89ef13ce825cc88e30be581de5d4), [`8ea8038`](https://github.com/mastra-ai/mastra/commit/8ea80386fde53d26e2c0b2060c53bc9bd9be10f3), [`be31796`](https://github.com/mastra-ai/mastra/commit/be3179624ad5f77cff5fa342cd08046bf7605283), [`79c4f82`](https://github.com/mastra-ai/mastra/commit/79c4f8295f568752eeadf8a9b50010a7d9ec06ae), [`7dafa4f`](https://github.com/mastra-ai/mastra/commit/7dafa4f670fb16ec8ff07349645a00ca12bc5794)]:
|
|
19
|
+
- @mastra/core@1.59.0
|
|
20
|
+
|
|
21
|
+
## 1.2.1-alpha.0
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Send opaque acting-user subjects with Platform sandbox requests, including Factory creation and reattachment flows. ([#20754](https://github.com/mastra-ai/mastra/pull/20754))
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { PlatformSandbox } from '@mastra/platform-workspace';
|
|
29
|
+
|
|
30
|
+
const sandbox = new PlatformSandbox({
|
|
31
|
+
environmentId: 'env_abc',
|
|
32
|
+
actingUserId: auth.user.id,
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [[`79dd7c2`](https://github.com/mastra-ai/mastra/commit/79dd7c261ee6be1fafedd4651959394db21d2cba), [`b9a28ec`](https://github.com/mastra-ai/mastra/commit/b9a28ecf7acdc0cb7a543d5b660f9fbee301df9a), [`be31796`](https://github.com/mastra-ai/mastra/commit/be3179624ad5f77cff5fa342cd08046bf7605283)]:
|
|
37
|
+
- @mastra/core@1.59.0-alpha.4
|
|
38
|
+
|
|
3
39
|
## 1.2.0
|
|
4
40
|
|
|
5
41
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -17,11 +17,12 @@ All options can be passed to the constructor or read from environment variables:
|
|
|
17
17
|
| `accessToken` | `MASTRA_PLATFORM_ACCESS_TOKEN` | Yes |
|
|
18
18
|
| `projectId` | `MASTRA_PROJECT_ID` | Yes |
|
|
19
19
|
| `environmentId` | `MASTRA_ENVIRONMENT_ID` | Yes (sandbox) |
|
|
20
|
+
| `actingUserId` | — | No (sandbox) |
|
|
20
21
|
| `bucketName` | `MASTRA_PLATFORM_BUCKET_NAME` | Yes (filesystem) |
|
|
21
22
|
|
|
22
23
|
The proxy URL defaults to `https://workspaces.mastra.ai` and can be overridden with the `MASTRA_WORKSPACE_PROXY_URL` env var (useful for staging).
|
|
23
24
|
|
|
24
|
-
Requests to the proxy are authenticated with `Authorization: Bearer <accessToken>`.
|
|
25
|
+
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.
|
|
25
26
|
|
|
26
27
|
## Usage
|
|
27
28
|
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export interface PlatformClientOptions {
|
|
2
2
|
accessToken?: string;
|
|
3
3
|
projectId?: string;
|
|
4
|
+
actingUserId?: string;
|
|
4
5
|
/**
|
|
5
6
|
* Advisory correlation id for the factory session driving this client.
|
|
6
7
|
* Sent as `x-mastra-session-id` on every proxy request so proxy-side logs
|
|
@@ -23,6 +24,7 @@ export declare function requireOption(value: string | undefined, name: string):
|
|
|
23
24
|
export declare function resolvePlatformOptions(options: PlatformClientOptions): {
|
|
24
25
|
accessToken: string;
|
|
25
26
|
projectId: string;
|
|
27
|
+
actingUserId: string | undefined;
|
|
26
28
|
proxyUrl: string;
|
|
27
29
|
sessionId: string | undefined;
|
|
28
30
|
threadId: string | undefined;
|
|
@@ -51,6 +53,7 @@ export declare class PlatformApiError extends Error {
|
|
|
51
53
|
export declare class PlatformClient {
|
|
52
54
|
readonly accessToken: string;
|
|
53
55
|
readonly projectId: string;
|
|
56
|
+
readonly actingUserId: string | undefined;
|
|
54
57
|
readonly proxyUrl: string;
|
|
55
58
|
/** Advisory session correlation id — see {@link PlatformClientOptions.sessionId}. */
|
|
56
59
|
readonly sessionId: string | undefined;
|
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;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,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,2HAA2H;IAC3H,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,yGAAyG;IACzG,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;gBAE9B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAUzC;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,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;gBAEjB,OAAO,EAAE,qBAAqB;IAWpC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B,GAAG,OAAO,CAAC,QAAQ,CAAC;CA2BrF"}
|
package/dist/index.cjs
CHANGED
|
@@ -41,6 +41,7 @@ function resolvePlatformOptions(options) {
|
|
|
41
41
|
return {
|
|
42
42
|
accessToken: requireOption(options.accessToken ?? process.env.MASTRA_PLATFORM_ACCESS_TOKEN, "accessToken"),
|
|
43
43
|
projectId: requireOption(options.projectId ?? process.env.MASTRA_PROJECT_ID, "projectId"),
|
|
44
|
+
actingUserId: options.actingUserId?.trim() || void 0,
|
|
44
45
|
proxyUrl: (process.env.MASTRA_WORKSPACE_PROXY_URL ?? DEFAULT_PROXY_URL).replace(/\/$/, ""),
|
|
45
46
|
sessionId: options.sessionId,
|
|
46
47
|
threadId: options.threadId,
|
|
@@ -86,6 +87,7 @@ var PlatformApiError = class extends Error {
|
|
|
86
87
|
var PlatformClient = class {
|
|
87
88
|
accessToken;
|
|
88
89
|
projectId;
|
|
90
|
+
actingUserId;
|
|
89
91
|
proxyUrl;
|
|
90
92
|
/** Advisory session correlation id — see {@link PlatformClientOptions.sessionId}. */
|
|
91
93
|
sessionId;
|
|
@@ -96,6 +98,7 @@ var PlatformClient = class {
|
|
|
96
98
|
const resolved = resolvePlatformOptions(options);
|
|
97
99
|
this.accessToken = resolved.accessToken;
|
|
98
100
|
this.projectId = resolved.projectId;
|
|
101
|
+
this.actingUserId = resolved.actingUserId;
|
|
99
102
|
this.proxyUrl = resolved.proxyUrl;
|
|
100
103
|
this.sessionId = resolved.sessionId;
|
|
101
104
|
this.threadId = resolved.threadId;
|
|
@@ -106,6 +109,7 @@ var PlatformClient = class {
|
|
|
106
109
|
for (const [key, value] of Object.entries(options.query ?? {})) if (value !== void 0) url.searchParams.set(key, String(value));
|
|
107
110
|
const headers = new Headers(options.headers);
|
|
108
111
|
headers.set("authorization", `Bearer ${this.accessToken}`);
|
|
112
|
+
if (this.actingUserId) headers.set("x-acting-user-id", this.actingUserId);
|
|
109
113
|
if (this.sessionId) headers.set("x-mastra-session-id", this.sessionId);
|
|
110
114
|
if (this.threadId) headers.set("x-mastra-thread-id", this.threadId);
|
|
111
115
|
const { query: _query, ...fetchOptions } = options;
|
|
@@ -973,6 +977,7 @@ var PlatformSandbox = class PlatformSandbox extends _mastra_core_workspace.Mastr
|
|
|
973
977
|
...id !== void 0 && { id },
|
|
974
978
|
accessToken: this._client.accessToken,
|
|
975
979
|
projectId: this._client.projectId,
|
|
980
|
+
actingUserId: options.actingUserId ?? this._client.actingUserId,
|
|
976
981
|
...this._client.sessionId !== void 0 && { sessionId: this._client.sessionId },
|
|
977
982
|
...this._client.threadId !== void 0 && { threadId: this._client.threadId },
|
|
978
983
|
fetch: this._client.fetch,
|
|
@@ -1616,6 +1621,10 @@ const platformSandboxProvider = {
|
|
|
1616
1621
|
type: "string",
|
|
1617
1622
|
description: "Platform project ID (falls back to MASTRA_PROJECT_ID)"
|
|
1618
1623
|
},
|
|
1624
|
+
actingUserId: {
|
|
1625
|
+
type: "string",
|
|
1626
|
+
description: "Opaque user subject attributed to sandbox requests"
|
|
1627
|
+
},
|
|
1619
1628
|
environmentId: {
|
|
1620
1629
|
type: "string",
|
|
1621
1630
|
description: "Platform environment ID (falls back to MASTRA_ENVIRONMENT_ID)"
|