@mastra/platform-workspace 0.0.0 → 0.1.0-alpha.0
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/LICENSE.md +30 -0
- package/dist/client.d.ts +44 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/filesystem.d.ts +62 -0
- package/dist/filesystem.d.ts.map +1 -0
- package/dist/index.cjs +599 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +588 -0
- package/dist/index.js.map +1 -0
- package/dist/provider.d.ts +6 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/sandbox.d.ts +72 -0
- package/dist/sandbox.d.ts.map +1 -0
- package/package.json +19 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @mastra/platform
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added Mastra Platform workspace providers for connecting agents to Platform sandboxes and bucket-backed filesystems. ([#18908](https://github.com/mastra-ai/mastra/pull/18908))
|
|
8
|
+
|
|
9
|
+
`PlatformFilesystem` and `PlatformSandbox` extend `MastraFilesystem` / `MastraSandbox` from `@mastra/core/workspace` and speak the workspace-proxy wire format (`Authorization: Bearer sk_*`, project-scoped routes at `/v1/projects/:projectId/...`). Both accept config directly and fall back to env vars (`MASTRA_PLATFORM_ACCESS_TOKEN`, `MASTRA_PROJECT_ID`, `MASTRA_ENVIRONMENT_ID`, `MASTRA_PLATFORM_BUCKET_NAME`, `MASTRA_WORKSPACE_PROXY_URL`).
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { Workspace } from '@mastra/core/workspace';
|
|
13
|
+
import { PlatformFilesystem, PlatformSandbox } from '@mastra/platform-workspace';
|
|
14
|
+
|
|
15
|
+
const workspace = new Workspace({
|
|
16
|
+
filesystem: new PlatformFilesystem({ bucketName: 'dev-bucket' }),
|
|
17
|
+
sandbox: new PlatformSandbox({
|
|
18
|
+
environmentId: 'env_123',
|
|
19
|
+
idleTimeoutMinutes: 30,
|
|
20
|
+
networkIsolation: 'ISOLATED',
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Also exports `platformFilesystemProvider` and `platformSandboxProvider` descriptors for hosts that register providers dynamically through the editor's `FilesystemProvider` / `SandboxProvider` registries:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { platformFilesystemProvider, platformSandboxProvider } from '@mastra/platform-workspace';
|
|
29
|
+
|
|
30
|
+
registry.registerFilesystem(platformFilesystemProvider);
|
|
31
|
+
registry.registerSandbox(platformSandboxProvider);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [[`45a8e65`](https://github.com/mastra-ai/mastra/commit/45a8e65e1556d1362cb3f25187023c36de26661d), [`c8ed116`](https://github.com/mastra-ai/mastra/commit/c8ed11699f62bcac70102ab4ec84d80d20541da6), [`33f2b88`](https://github.com/mastra-ai/mastra/commit/33f2b88842c09a567f906fac4cb61cd5277ced59)]:
|
|
37
|
+
- @mastra/core@1.51.0-alpha.11
|
|
38
|
+
|
|
3
39
|
## 0.0.1-alpha.0
|
|
4
40
|
|
|
5
41
|
### Patch Changes
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Portions of this software are licensed as follows:
|
|
2
|
+
|
|
3
|
+
- All content that resides under any directory named "ee/" within this
|
|
4
|
+
repository, including but not limited to:
|
|
5
|
+
- `packages/core/src/auth/ee/`
|
|
6
|
+
- `packages/server/src/server/auth/ee/`
|
|
7
|
+
is licensed under the license defined in `ee/LICENSE`.
|
|
8
|
+
|
|
9
|
+
- All third-party components incorporated into the Mastra Software are
|
|
10
|
+
licensed under the original license provided by the owner of the
|
|
11
|
+
applicable component.
|
|
12
|
+
|
|
13
|
+
- Content outside of the above-mentioned directories or restrictions is
|
|
14
|
+
available under the "Apache License 2.0" as defined below.
|
|
15
|
+
|
|
16
|
+
# Apache License 2.0
|
|
17
|
+
|
|
18
|
+
Copyright (c) 2025 Kepler Software, Inc.
|
|
19
|
+
|
|
20
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
21
|
+
you may not use this file except in compliance with the License.
|
|
22
|
+
You may obtain a copy of the License at
|
|
23
|
+
|
|
24
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
25
|
+
|
|
26
|
+
Unless required by applicable law or agreed to in writing, software
|
|
27
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
28
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
29
|
+
See the License for the specific language governing permissions and
|
|
30
|
+
limitations under the License.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface PlatformClientOptions {
|
|
2
|
+
accessToken?: string;
|
|
3
|
+
projectId?: string;
|
|
4
|
+
fetch?: typeof fetch;
|
|
5
|
+
}
|
|
6
|
+
export interface PlatformRequestOptions extends RequestInit {
|
|
7
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
8
|
+
}
|
|
9
|
+
export declare function requireOption(value: string | undefined, name: string): string;
|
|
10
|
+
export declare function resolvePlatformOptions(options: PlatformClientOptions): {
|
|
11
|
+
accessToken: string;
|
|
12
|
+
projectId: string;
|
|
13
|
+
proxyUrl: string;
|
|
14
|
+
fetch: typeof fetch;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Structured error shape returned by the workspace proxy. All routes emit
|
|
18
|
+
* `{ error: { message, type } }` on failure — see servers/workspace-proxy in
|
|
19
|
+
* the Platform repo. Kept as a wire-level type so callers can switch on
|
|
20
|
+
* `error.code` without re-parsing `error.body`.
|
|
21
|
+
*/
|
|
22
|
+
export interface PlatformProxyError {
|
|
23
|
+
message: string;
|
|
24
|
+
/** Machine-readable error kind, e.g. `not_found`, `invalid_request`, `authentication_error`. */
|
|
25
|
+
type: string;
|
|
26
|
+
}
|
|
27
|
+
export declare class PlatformApiError extends Error {
|
|
28
|
+
readonly status: number;
|
|
29
|
+
readonly body: string;
|
|
30
|
+
/** Machine-readable proxy error kind (e.g. `not_found`), when the response body matches `{ error: { message, type } }`. */
|
|
31
|
+
readonly code: string | undefined;
|
|
32
|
+
/** Human-readable proxy error message, when the response body matches `{ error: { message, type } }`. */
|
|
33
|
+
readonly proxyMessage: string | undefined;
|
|
34
|
+
constructor(status: number, body: string);
|
|
35
|
+
}
|
|
36
|
+
export declare class PlatformClient {
|
|
37
|
+
readonly accessToken: string;
|
|
38
|
+
readonly projectId: string;
|
|
39
|
+
readonly proxyUrl: string;
|
|
40
|
+
readonly fetch: typeof fetch;
|
|
41
|
+
constructor(options: PlatformClientOptions);
|
|
42
|
+
request(path: string, options?: PlatformRequestOptions): Promise<Response>;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +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,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;AAWD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAG7E;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,qBAAqB;;;;;EAOpE;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,gGAAgG;IAChG,IAAI,EAAE,MAAM,CAAC;CACd;AAkBD,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,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,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC;gBAEjB,OAAO,EAAE,qBAAqB;IAQpC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B,GAAG,OAAO,CAAC,QAAQ,CAAC;CAoBrF"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
import type { RequestContext } from '@mastra/core/request-context';
|
|
3
|
+
import type { CopyOptions, FileContent, FileEntry, FileStat, FilesystemIcon, FilesystemInfo, InstructionsOption, ListOptions, MastraFilesystemOptions, ProviderStatus, ReadOptions, RemoveOptions, WriteOptions } from '@mastra/core/workspace';
|
|
4
|
+
import { MastraFilesystem } from '@mastra/core/workspace';
|
|
5
|
+
import type { PlatformClientOptions } from './client.js';
|
|
6
|
+
export interface PlatformFilesystemOptions extends PlatformClientOptions, MastraFilesystemOptions {
|
|
7
|
+
id?: string;
|
|
8
|
+
bucketName?: string;
|
|
9
|
+
readOnly?: boolean;
|
|
10
|
+
displayName?: string;
|
|
11
|
+
icon?: FilesystemIcon;
|
|
12
|
+
description?: string;
|
|
13
|
+
instructions?: InstructionsOption;
|
|
14
|
+
}
|
|
15
|
+
export declare class PlatformFilesystem extends MastraFilesystem {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly name = "PlatformFilesystem";
|
|
18
|
+
readonly provider = "platform";
|
|
19
|
+
readonly readOnly?: boolean;
|
|
20
|
+
readonly displayName?: string;
|
|
21
|
+
readonly icon: FilesystemIcon;
|
|
22
|
+
readonly description?: string;
|
|
23
|
+
status: ProviderStatus;
|
|
24
|
+
private readonly _client;
|
|
25
|
+
private readonly _bucketName;
|
|
26
|
+
private readonly _instructionsOverride?;
|
|
27
|
+
constructor(options?: PlatformFilesystemOptions);
|
|
28
|
+
private generateId;
|
|
29
|
+
readFile(path: string, options?: ReadOptions): Promise<string | Buffer>;
|
|
30
|
+
writeFile(path: string, content: FileContent, options?: WriteOptions): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Append bytes to a file.
|
|
33
|
+
*
|
|
34
|
+
* **Not atomic.** Object storage behind the workspace proxy has no native
|
|
35
|
+
* append or compare-and-swap primitive, so this implementation is a
|
|
36
|
+
* read-modify-write: it reads the current contents, concatenates the new
|
|
37
|
+
* bytes, and PUTs the whole object back. Concurrent `appendFile` calls to
|
|
38
|
+
* the same path can overwrite each other's writes ("last write wins").
|
|
39
|
+
* Use `writeFile` with distinct keys for concurrent writers.
|
|
40
|
+
*/
|
|
41
|
+
appendFile(path: string, content: FileContent): Promise<void>;
|
|
42
|
+
deleteFile(path: string, options?: RemoveOptions): Promise<void>;
|
|
43
|
+
copyFile(src: string, dest: string, options?: CopyOptions): Promise<void>;
|
|
44
|
+
moveFile(src: string, dest: string, options?: CopyOptions): Promise<void>;
|
|
45
|
+
mkdir(path: string, _options?: {
|
|
46
|
+
recursive?: boolean;
|
|
47
|
+
}): Promise<void>;
|
|
48
|
+
rmdir(path: string, options?: RemoveOptions): Promise<void>;
|
|
49
|
+
readdir(path: string, options?: ListOptions): Promise<FileEntry[]>;
|
|
50
|
+
exists(path: string): Promise<boolean>;
|
|
51
|
+
stat(path: string): Promise<FileStat>;
|
|
52
|
+
realpath(path: string): Promise<string>;
|
|
53
|
+
getInstructions(opts?: {
|
|
54
|
+
requestContext?: RequestContext;
|
|
55
|
+
}): string;
|
|
56
|
+
getInfo(): FilesystemInfo<{
|
|
57
|
+
bucketName: string;
|
|
58
|
+
displayName?: string;
|
|
59
|
+
description?: string;
|
|
60
|
+
}>;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=filesystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystem.d.ts","sourceRoot":"","sources":["../src/filesystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,QAAQ,EACR,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,uBAAuB,EACvB,cAAc,EACd,WAAW,EACX,aAAa,EACb,YAAY,EACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAsC,gBAAgB,EAA0B,MAAM,wBAAwB,CAAC;AACtH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAQzD,MAAM,WAAW,yBAA0B,SAAQ,qBAAqB,EAAE,uBAAuB;IAC/F,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,kBAAkB,CAAC;CACnC;AAiDD,qBAAa,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