@mastra/cloudflare-sandbox 0.0.0-aggregate-trace-20261015182851

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/LICENSE.md ADDED
@@ -0,0 +1,32 @@
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
+ - `@mastra/core/auth/ee`
6
+ - `@mastra/core/agent-builder/ee`
7
+ - `@mastra/editor/ee`
8
+
9
+ is licensed under the license defined in [`ee/LICENSE`](https://github.com/mastra-ai/mastra/blob/main/ee/LICENSE).
10
+
11
+ - All third-party components incorporated into the Mastra Software are
12
+ licensed under the original license provided by the owner of the
13
+ applicable component.
14
+
15
+ - Content outside of the above-mentioned directories or restrictions is
16
+ available under the "Apache License 2.0" as defined below.
17
+
18
+ # Apache License 2.0
19
+
20
+ Copyright (c) 2025 Kepler Software, Inc.
21
+
22
+ Licensed under the Apache License, Version 2.0 (the "License");
23
+ you may not use this file except in compliance with the License.
24
+ You may obtain a copy of the License at
25
+
26
+ http://www.apache.org/licenses/LICENSE-2.0
27
+
28
+ Unless required by applicable law or agreed to in writing, software
29
+ distributed under the License is distributed on an "AS IS" BASIS,
30
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31
+ See the License for the specific language governing permissions and
32
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # @mastra/cloudflare-sandbox
2
+
3
+ Cloudflare Sandbox provider for Mastra workspaces. It talks to a deployed [Cloudflare Sandbox Bridge Worker](https://developers.cloudflare.com/sandbox/bridge/) over the documented [`/v1/sandbox` HTTP API](https://developers.cloudflare.com/sandbox/bridge/http-api/).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @mastra/cloudflare-sandbox
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { Workspace } from '@mastra/core/workspace';
15
+ import { CloudflareSandbox } from '@mastra/cloudflare-sandbox';
16
+
17
+ const sandbox = new CloudflareSandbox({
18
+ baseUrl: process.env.CLOUDFLARE_SANDBOX_BRIDGE_URL!,
19
+ apiToken: process.env.CLOUDFLARE_SANDBOX_API_KEY,
20
+ });
21
+
22
+ const workspace = new Workspace({ sandbox });
23
+ ```
24
+
25
+ ## Documentation
26
+
27
+ - [Cloudflare Sandbox integration guide](https://mastra.ai/integrations/sandboxes/cloudflare-sandbox)
28
+ - [Workspace documentation](https://mastra.ai/docs/mastra-platform/workspaces)
29
+
30
+ ## Changelog
31
+
32
+ See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/workspaces/cloudflare-sandbox/CHANGELOG.md) for version history and release notes.
33
+
34
+ ## Support
35
+
36
+ We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
@@ -0,0 +1,112 @@
1
+ export interface CloudflareSandboxBridgeClientOptions {
2
+ baseUrl: string;
3
+ apiToken?: string;
4
+ fetch?: typeof globalThis.fetch;
5
+ }
6
+ /** Terminal and streaming events emitted by `POST /v1/sandbox/:id/exec`. */
7
+ export type CloudflareCommandEvent = {
8
+ type: 'stdout';
9
+ data: Uint8Array;
10
+ } | {
11
+ type: 'stderr';
12
+ data: Uint8Array;
13
+ } | {
14
+ type: 'exit';
15
+ exitCode: number;
16
+ } | {
17
+ type: 'error';
18
+ message: string;
19
+ code?: string;
20
+ };
21
+ export interface CloudflareExecRequest {
22
+ /** Command and arguments. The bridge applies ANSI-C quoting to each element. */
23
+ argv: string[];
24
+ timeoutMs?: number;
25
+ cwd?: string;
26
+ }
27
+ export interface CloudflarePersistWorkspaceOptions {
28
+ /** Relative paths (under /workspace) to exclude from the archive. */
29
+ excludes?: string[];
30
+ }
31
+ export interface CloudflareMountBucketCredentials {
32
+ accessKeyId: string;
33
+ secretAccessKey: string;
34
+ }
35
+ export interface CloudflareMountBucketOptions {
36
+ /** S3-compatible endpoint, e.g. `https://<account>.r2.cloudflarestorage.com`. */
37
+ endpoint?: string;
38
+ /** Mount the bucket read-only. */
39
+ readOnly?: boolean;
40
+ /** Only expose objects under this bucket prefix at the mount point. */
41
+ prefix?: string;
42
+ /** Storage provider hint, e.g. `r2`. */
43
+ provider?: string;
44
+ /** Explicit credentials; omitted when the Worker resolves them from secrets. */
45
+ credentials?: CloudflareMountBucketCredentials;
46
+ }
47
+ export interface CloudflareMountBucketRequest {
48
+ /** Bucket name, e.g. `my-r2-bucket`. */
49
+ bucket: string;
50
+ /** Local filesystem path to mount at, e.g. `/mnt/data`. */
51
+ mountPath: string;
52
+ options?: CloudflareMountBucketOptions;
53
+ }
54
+ export interface CloudflareCreateSessionRequest {
55
+ /** Working directory the session starts in. */
56
+ cwd?: string;
57
+ /** Environment variables seeded into the session. */
58
+ env?: Record<string, string>;
59
+ /** Caller-chosen session id; must match `^[a-zA-Z0-9._-]{1,128}$`. Generated when omitted. */
60
+ sessionId?: string;
61
+ }
62
+ export interface CloudflareSession {
63
+ id: string;
64
+ }
65
+ export declare class CloudflareSandboxBridgeError extends Error {
66
+ readonly status: number;
67
+ readonly body: string;
68
+ constructor(status: number, body: string);
69
+ }
70
+ /**
71
+ * Client for the Cloudflare Sandbox Bridge Worker.
72
+ *
73
+ * @see https://developers.cloudflare.com/sandbox/bridge/http-api/
74
+ */
75
+ export declare class CloudflareSandboxBridgeClient {
76
+ readonly baseUrl: string;
77
+ private readonly apiToken?;
78
+ private readonly fetchImpl;
79
+ constructor(options: CloudflareSandboxBridgeClientOptions);
80
+ /** `POST /v1/sandbox` */
81
+ createSandbox(): Promise<string>;
82
+ /** `GET /v1/sandbox/:id/running` */
83
+ isRunning(id: string): Promise<boolean>;
84
+ /** `DELETE /v1/sandbox/:id` */
85
+ deleteSandbox(id: string): Promise<void>;
86
+ /** `PUT /v1/sandbox/:id/file/*` — one file per request, raw bytes as the body. */
87
+ writeFile(id: string, absolutePath: string, content: Uint8Array | string): Promise<void>;
88
+ /** `GET /v1/sandbox/:id/file/*` — reads one file, returning its raw bytes. */
89
+ readFile(id: string, absolutePath: string): Promise<Uint8Array>;
90
+ /** `GET /v1/sandbox/:id/persist` — archives `/workspace`, returning raw tar bytes. */
91
+ persistWorkspace(id: string, options?: CloudflarePersistWorkspaceOptions): Promise<Uint8Array>;
92
+ /** `POST /v1/sandbox/:id/hydrate` — restores `/workspace` from a raw tar payload. */
93
+ hydrateWorkspace(id: string, tar: Uint8Array): Promise<void>;
94
+ /** `POST /v1/sandbox/:id/mount` — mounts an S3-compatible bucket as a local directory. */
95
+ mountBucket(id: string, request: CloudflareMountBucketRequest): Promise<void>;
96
+ /** `POST /v1/sandbox/:id/unmount` — unmounts a previously mounted bucket. */
97
+ unmountBucket(id: string, mountPath: string): Promise<void>;
98
+ /** `POST /v1/sandbox/:id/session` — creates an execution session, returning its id. */
99
+ createSession(id: string, request?: CloudflareCreateSessionRequest): Promise<CloudflareSession>;
100
+ /** `DELETE /v1/sandbox/:id/session/:sessionId` — tears down an execution session. */
101
+ deleteSession(id: string, sessionId: string): Promise<void>;
102
+ /** `POST /v1/sandbox/:id/exec` — streams SSE events until `exit` or `error`. */
103
+ exec(id: string, request: CloudflareExecRequest, options: {
104
+ signal?: AbortSignal;
105
+ onEvent: (event: CloudflareCommandEvent) => void;
106
+ }): Promise<void>;
107
+ private emitBlock;
108
+ private headers;
109
+ private request;
110
+ private requestBytes;
111
+ }
112
+ //# sourceMappingURL=bridge-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge-client.d.ts","sourceRoot":"","sources":["../src/bridge-client.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oCAAoC;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC;AAED,4EAA4E;AAC5E,MAAM,MAAM,sBAAsB,GAC9B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,G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