@5ss/ai-tools 3.2.0 → 3.3.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 +2 -0
- package/dist/{cloudflare-sandbox-BPXbaBOp.js → cloudflare-sandbox-D3rAu9bN.js} +179 -35
- package/dist/cloudflare-sandbox-D3rAu9bN.js.map +1 -0
- package/dist/modules/code-sandbox/index.js +13 -4
- package/dist/modules/code-sandbox/index.js.map +1 -1
- package/dist/vendors/cloudflare-sandbox/index.d.ts +72 -11
- package/dist/vendors/cloudflare-sandbox/index.d.ts.map +1 -1
- package/dist/vendors/cloudflare-sandbox/index.js +2 -2
- package/package.json +1 -1
- package/dist/cloudflare-sandbox-BPXbaBOp.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,8 @@ All notable changes to `@5ss/ai-tools` are documented here.
|
|
|
4
4
|
|
|
5
5
|
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Releases are cut by [semantic-release](https://semantic-release.gitbook.io/) from [conventional commits](https://www.conventionalcommits.org/).
|
|
6
6
|
|
|
7
|
+
## [3.3.0](https://github.com/five-star-solutions-co/ai-tools/compare/v3.2.0...v3.3.0) (2026-08-25)
|
|
8
|
+
|
|
7
9
|
## [3.2.0](https://github.com/five-star-solutions-co/ai-tools/compare/v3.1.0...v3.2.0) (2026-08-24)
|
|
8
10
|
|
|
9
11
|
## [3.1.0](https://github.com/five-star-solutions-co/ai-tools/compare/v3.0.3...v3.1.0) (2026-08-24)
|
|
@@ -186,17 +186,54 @@ const deleteBridgeSessionOutputSchema = z.object({
|
|
|
186
186
|
session_id: z.string(),
|
|
187
187
|
deleted: z.literal(true)
|
|
188
188
|
});
|
|
189
|
+
const interpreterLanguageSchema = z.enum([
|
|
190
|
+
"python",
|
|
191
|
+
"javascript",
|
|
192
|
+
"typescript"
|
|
193
|
+
]);
|
|
189
194
|
const executeCodeInputSchema = z.object({
|
|
190
195
|
sandbox_id: sandboxId,
|
|
191
196
|
code: z.string().min(1).max(MAX_ARG_CHARS).describe("Source code to run"),
|
|
192
|
-
language:
|
|
193
|
-
"python",
|
|
194
|
-
"javascript",
|
|
195
|
-
"typescript",
|
|
196
|
-
"shell"
|
|
197
|
-
]).optional().describe("Runtime language (default python)"),
|
|
197
|
+
language: interpreterLanguageSchema.optional().describe("Interpreter language (default python)"),
|
|
198
198
|
timeout_ms: z.int().min(1).max(MAX_EXEC_TIMEOUT_MS).optional().describe(`Exec timeout in ms (default ${DEFAULT_EXEC_TIMEOUT_MS})`),
|
|
199
|
-
|
|
199
|
+
context_id: z.string().min(1).max(200).optional().describe("Optional interpreter context id; omit to reuse the sandbox language context")
|
|
200
|
+
});
|
|
201
|
+
const createCodeContextInputSchema = z.object({
|
|
202
|
+
sandbox_id: sandboxId,
|
|
203
|
+
language: interpreterLanguageSchema.optional().describe("Interpreter language (default python)"),
|
|
204
|
+
cwd: z.string().min(1).max(MAX_FILE_PATH).optional().describe("Working directory (default /workspace)"),
|
|
205
|
+
env: z.record(z.string().min(1).max(128), z.string().max(8192)).optional().describe("Environment variables for the interpreter context"),
|
|
206
|
+
timeout_ms: z.int().min(1).max(MAX_EXEC_TIMEOUT_MS).optional().describe(`Context create timeout in ms (default ${DEFAULT_EXEC_TIMEOUT_MS})`)
|
|
207
|
+
});
|
|
208
|
+
const createCodeContextOutputSchema = z.object({
|
|
209
|
+
sandbox_id: z.string(),
|
|
210
|
+
context_id: z.string().describe("Persistent interpreter context id"),
|
|
211
|
+
language: interpreterLanguageSchema.optional(),
|
|
212
|
+
cwd: z.string().optional()
|
|
213
|
+
});
|
|
214
|
+
const listCodeContextsOutputSchema = z.object({
|
|
215
|
+
sandbox_id: z.string(),
|
|
216
|
+
contexts: z.array(z.object({
|
|
217
|
+
context_id: z.string(),
|
|
218
|
+
language: z.string().optional(),
|
|
219
|
+
cwd: z.string().optional()
|
|
220
|
+
}))
|
|
221
|
+
});
|
|
222
|
+
const deleteCodeContextInputSchema = z.object({
|
|
223
|
+
sandbox_id: sandboxId,
|
|
224
|
+
context_id: z.string().min(1).max(200).describe("Interpreter context id to delete")
|
|
225
|
+
});
|
|
226
|
+
const deleteCodeContextOutputSchema = z.object({
|
|
227
|
+
sandbox_id: z.string(),
|
|
228
|
+
context_id: z.string(),
|
|
229
|
+
deleted: z.literal(true)
|
|
230
|
+
});
|
|
231
|
+
const runCodeInputSchema = z.object({
|
|
232
|
+
sandbox_id: sandboxId,
|
|
233
|
+
code: z.string().min(1).max(MAX_ARG_CHARS).describe("Source to run in the interpreter context"),
|
|
234
|
+
context_id: z.string().min(1).max(200).optional().describe("Interpreter context id; omit for the language default"),
|
|
235
|
+
language: interpreterLanguageSchema.optional().describe("Interpreter language when creating a default context"),
|
|
236
|
+
timeout_ms: z.int().min(1).max(MAX_EXEC_TIMEOUT_MS).optional().describe(`Run timeout in ms (default ${DEFAULT_EXEC_TIMEOUT_MS})`)
|
|
200
237
|
});
|
|
201
238
|
/**
|
|
202
239
|
* Mount an S3-compatible bucket into the sandbox filesystem.
|
|
@@ -362,26 +399,55 @@ function safeJson(text) {
|
|
|
362
399
|
return;
|
|
363
400
|
}
|
|
364
401
|
}
|
|
365
|
-
/**
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
402
|
+
/** Cloudflare interpreter `runCode` JSON. https://developers.cloudflare.com/sandbox/api/interpreter/ */
|
|
403
|
+
const runCodePayloadSchema = z.object({
|
|
404
|
+
logs: z.object({
|
|
405
|
+
stdout: z.array(z.string()),
|
|
406
|
+
stderr: z.array(z.string())
|
|
407
|
+
}),
|
|
408
|
+
error: z.object({
|
|
409
|
+
name: z.string(),
|
|
410
|
+
value: z.string()
|
|
411
|
+
}).optional()
|
|
412
|
+
});
|
|
413
|
+
function parseRunCodePayload(data) {
|
|
414
|
+
const parsed = runCodePayloadSchema.safeParse(data);
|
|
415
|
+
if (!parsed.success) throw new ToolError("Unexpected run-code response", { code: "upstream" });
|
|
416
|
+
const { logs, error } = parsed.data;
|
|
417
|
+
const out = {
|
|
418
|
+
stdout: logs.stdout.join(""),
|
|
419
|
+
stderr: logs.stderr.join(""),
|
|
420
|
+
success: error === void 0,
|
|
421
|
+
exit_code: error === void 0 ? 0 : 1
|
|
422
|
+
};
|
|
423
|
+
if (error) out.error = error.value;
|
|
424
|
+
return out;
|
|
425
|
+
}
|
|
426
|
+
const createCodeContextPayloadSchema = z.object({
|
|
427
|
+
id: z.string().min(1),
|
|
428
|
+
cwd: z.string().min(1).optional()
|
|
429
|
+
});
|
|
430
|
+
function parseCreateCodeContextPayload(data) {
|
|
431
|
+
const parsed = createCodeContextPayloadSchema.safeParse(data);
|
|
432
|
+
if (!parsed.success) throw new ToolError("Unexpected create code context response", { code: "upstream" });
|
|
433
|
+
return {
|
|
434
|
+
id: parsed.data.id,
|
|
435
|
+
...parsed.data.cwd && { cwd: parsed.data.cwd }
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
const listCodeContextsPayloadSchema = z.object({ contexts: z.array(z.object({
|
|
439
|
+
id: z.string().min(1),
|
|
440
|
+
language: z.string().min(1).optional(),
|
|
441
|
+
cwd: z.string().min(1).optional()
|
|
442
|
+
})) });
|
|
443
|
+
function parseListCodeContextsPayload(data) {
|
|
444
|
+
const parsed = listCodeContextsPayloadSchema.safeParse(data);
|
|
445
|
+
if (!parsed.success) throw new ToolError("Unexpected list code contexts response", { code: "upstream" });
|
|
446
|
+
return parsed.data.contexts.map((row) => ({
|
|
447
|
+
context_id: row.id,
|
|
448
|
+
...row.language && { language: row.language },
|
|
449
|
+
...row.cwd && { cwd: row.cwd }
|
|
450
|
+
}));
|
|
385
451
|
}
|
|
386
452
|
//#endregion
|
|
387
453
|
//#region src/vendors/cloudflare-sandbox/client.ts
|
|
@@ -396,6 +462,9 @@ var CloudflareSandboxClient = class CloudflareSandboxClient {
|
|
|
396
462
|
#storage;
|
|
397
463
|
/** Optional S3 auth fields for endpoint mount credential fallback (Mastra workspace FS). */
|
|
398
464
|
#storageAuth;
|
|
465
|
+
/** sandbox_id:language → interpreter context id (Node/Python stay loaded). */
|
|
466
|
+
#contexts = /* @__PURE__ */ new Map();
|
|
467
|
+
#pendingContexts = /* @__PURE__ */ new Map();
|
|
399
468
|
constructor(auth, options = {}) {
|
|
400
469
|
const parsed = cloudflareSandboxAuthSchema.safeParse(auth);
|
|
401
470
|
if (!parsed.success) throw new ToolError("Invalid Cloudflare Sandbox auth credentials", {
|
|
@@ -440,6 +509,7 @@ var CloudflareSandboxClient = class CloudflareSandboxClient {
|
|
|
440
509
|
}
|
|
441
510
|
async destroy(input) {
|
|
442
511
|
await this.#http.delete(`/v1/sandbox/${encodeURIComponent(input.sandbox_id)}`, { label: "Cloudflare Sandbox destroy" });
|
|
512
|
+
this.#forgetSandboxContexts(input.sandbox_id);
|
|
443
513
|
return {
|
|
444
514
|
sandbox_id: input.sandbox_id,
|
|
445
515
|
destroyed: true
|
|
@@ -498,16 +568,67 @@ var CloudflareSandboxClient = class CloudflareSandboxClient {
|
|
|
498
568
|
if (parsed.error_code) out.error_code = parsed.error_code;
|
|
499
569
|
return out;
|
|
500
570
|
}
|
|
501
|
-
/** Execute source via python3/node/sh on the bridge (no native runCode route). */
|
|
502
571
|
async executeCode(input) {
|
|
503
572
|
const language = input.language ?? "python";
|
|
504
|
-
|
|
573
|
+
const context_id = input.context_id ?? await this.#ensureCodeContext(input.sandbox_id, language);
|
|
574
|
+
return this.runCode({
|
|
505
575
|
sandbox_id: input.sandbox_id,
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
576
|
+
code: input.code,
|
|
577
|
+
context_id,
|
|
578
|
+
language,
|
|
579
|
+
...input.timeout_ms !== void 0 && { timeout_ms: input.timeout_ms }
|
|
509
580
|
});
|
|
510
581
|
}
|
|
582
|
+
async createCodeContext(input) {
|
|
583
|
+
const language = input.language ?? "python";
|
|
584
|
+
const { data } = await this.#http.post(`/v1/sandbox/${encodeURIComponent(input.sandbox_id)}/context`, {
|
|
585
|
+
language,
|
|
586
|
+
...input.cwd && { cwd: input.cwd },
|
|
587
|
+
...input.env && Object.keys(input.env).length > 0 && { env: input.env },
|
|
588
|
+
...input.timeout_ms !== void 0 && { timeout_ms: input.timeout_ms }
|
|
589
|
+
}, { label: "Cloudflare Sandbox createCodeContext" });
|
|
590
|
+
const row = parseCreateCodeContextPayload(data);
|
|
591
|
+
return {
|
|
592
|
+
sandbox_id: input.sandbox_id,
|
|
593
|
+
context_id: row.id,
|
|
594
|
+
language,
|
|
595
|
+
...row.cwd && { cwd: row.cwd }
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
async listCodeContexts(input) {
|
|
599
|
+
const { data } = await this.#http.get(`/v1/sandbox/${encodeURIComponent(input.sandbox_id)}/context`, { label: "Cloudflare Sandbox listCodeContexts" });
|
|
600
|
+
return {
|
|
601
|
+
sandbox_id: input.sandbox_id,
|
|
602
|
+
contexts: parseListCodeContextsPayload(data)
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
async deleteCodeContext(input) {
|
|
606
|
+
await this.#http.delete(`/v1/sandbox/${encodeURIComponent(input.sandbox_id)}/context/${encodeURIComponent(input.context_id)}`, { label: "Cloudflare Sandbox deleteCodeContext" });
|
|
607
|
+
const prefix = `${input.sandbox_id}:`;
|
|
608
|
+
for (const [key, contextId] of this.#contexts) if (contextId === input.context_id && key.startsWith(prefix)) this.#contexts.delete(key);
|
|
609
|
+
return {
|
|
610
|
+
sandbox_id: input.sandbox_id,
|
|
611
|
+
context_id: input.context_id,
|
|
612
|
+
deleted: true
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
async runCode(input) {
|
|
616
|
+
const { data } = await this.#http.post(`/v1/sandbox/${encodeURIComponent(input.sandbox_id)}/run-code`, {
|
|
617
|
+
code: input.code,
|
|
618
|
+
...input.context_id && { context_id: input.context_id },
|
|
619
|
+
...input.language && { language: input.language },
|
|
620
|
+
...input.timeout_ms !== void 0 && { timeout_ms: input.timeout_ms }
|
|
621
|
+
}, { label: "Cloudflare Sandbox runCode" });
|
|
622
|
+
const parsed = parseRunCodePayload(data);
|
|
623
|
+
return {
|
|
624
|
+
sandbox_id: input.sandbox_id,
|
|
625
|
+
stdout: parsed.stdout,
|
|
626
|
+
stderr: parsed.stderr,
|
|
627
|
+
exit_code: parsed.exit_code,
|
|
628
|
+
success: parsed.success,
|
|
629
|
+
...parsed.error && { error: parsed.error }
|
|
630
|
+
};
|
|
631
|
+
}
|
|
511
632
|
async writeFile(input) {
|
|
512
633
|
const bytes = resolveWriteFileBytes(input);
|
|
513
634
|
await this.#putFileBytes(input.sandbox_id, input.path, bytes, input.session_id);
|
|
@@ -727,6 +848,29 @@ var CloudflareSandboxClient = class CloudflareSandboxClient {
|
|
|
727
848
|
ok: true
|
|
728
849
|
};
|
|
729
850
|
}
|
|
851
|
+
async #ensureCodeContext(sandboxId, language) {
|
|
852
|
+
const key = `${sandboxId}:${language}`;
|
|
853
|
+
const cached = this.#contexts.get(key);
|
|
854
|
+
if (cached) return cached;
|
|
855
|
+
const pending = this.#pendingContexts.get(key);
|
|
856
|
+
if (pending) return pending;
|
|
857
|
+
const created = this.createCodeContext({
|
|
858
|
+
sandbox_id: sandboxId,
|
|
859
|
+
language
|
|
860
|
+
}).then((row) => {
|
|
861
|
+
this.#contexts.set(key, row.context_id);
|
|
862
|
+
return row.context_id;
|
|
863
|
+
}).finally(() => {
|
|
864
|
+
this.#pendingContexts.delete(key);
|
|
865
|
+
});
|
|
866
|
+
this.#pendingContexts.set(key, created);
|
|
867
|
+
return created;
|
|
868
|
+
}
|
|
869
|
+
#forgetSandboxContexts(sandboxId) {
|
|
870
|
+
const prefix = `${sandboxId}:`;
|
|
871
|
+
for (const key of this.#contexts.keys()) if (key.startsWith(prefix)) this.#contexts.delete(key);
|
|
872
|
+
for (const key of this.#pendingContexts.keys()) if (key.startsWith(prefix)) this.#pendingContexts.delete(key);
|
|
873
|
+
}
|
|
730
874
|
#requireStorage(op) {
|
|
731
875
|
if (!this.#storage) throw new ToolError(`${op} requires storage credentials on sandbox auth`, { code: "bad_auth" });
|
|
732
876
|
return this.#storage;
|
|
@@ -820,7 +964,7 @@ const cloudflareSandboxExecTool = defineTool({
|
|
|
820
964
|
const cloudflareSandboxExecuteCodeTool = defineTool({
|
|
821
965
|
id: `${id}-execute-code`,
|
|
822
966
|
name: "cloudflareSandboxExecuteCode",
|
|
823
|
-
description: "Execute Python, JavaScript, or
|
|
967
|
+
description: "Execute Python, JavaScript, or TypeScript in a Cloudflare sandbox interpreter context. Imports and variables stay loaded on later calls. Use exec for shell. Use as a fallback for computation or automation with no dedicated tool. Do not generate or edit supported documents, spreadsheets, presentations, PDFs, or images here when a purpose-built tool is available.",
|
|
824
968
|
inputSchema: executeCodeInputSchema,
|
|
825
969
|
outputSchema: execOutputSchema,
|
|
826
970
|
sideEffect: "write",
|
|
@@ -978,6 +1122,6 @@ const cloudflareSandboxModule = defineModule({
|
|
|
978
1122
|
]
|
|
979
1123
|
});
|
|
980
1124
|
//#endregion
|
|
981
|
-
export {
|
|
1125
|
+
export { listCodeContextsOutputSchema as $, MAX_FILE_PATH as A, deleteBridgeSessionInputSchema as B, workspaceAbsolutePath as C, MAX_ARG_CHARS as D, MAX_ARGV as E, cloudflareSandboxAuthSchema as F, execInputSchema as G, deleteCodeContextInputSchema as H, createBridgeSessionOutputSchema as I, exportArtifactInputSchema as J, execOutputSchema as K, createCodeContextInputSchema as L, MAX_LIST_FILES as M, MAX_READ_PATHS as N, MAX_EXEC_TIMEOUT_MS as O, MAX_WRITE_FILES as P, importArtifactOutputSchema as Q, createCodeContextOutputSchema as R, shellQuote as S, DEFAULT_EXEC_TIMEOUT_MS as T, deleteCodeContextOutputSchema as U, deleteBridgeSessionOutputSchema as V, destroySandboxOutputSchema as W, healthOutputSchema as X, exportArtifactOutputSchema as Y, importArtifactInputSchema as Z, cloudflareSandboxWriteFilesTool as _, writeFileOutputSchema as _t, cloudflareSandboxExecTool as a, readFileOutputSchema as at, parseRunCodePayload as b, cloudflareSandboxHealthTool as c, removeFilesInputSchema as ct, cloudflareSandboxModule as d, runningOutputSchema as dt, listFilesInputSchema as et, cloudflareSandboxReadFileTool as f, sandboxIdInputSchema as ft, cloudflareSandboxWriteFileTool as g, writeFileInputSchema as gt, cloudflareSandboxRunningTool as h, unmountBucketOutputSchema as ht, cloudflareSandboxDestroyTool as i, readFileInputSchema as it, MAX_FILE_TEXT as j, MAX_FILE_BYTES as k, cloudflareSandboxImportArtifactTool as l, removeFilesOutputSchema as lt, cloudflareSandboxRemoveFilesTool as m, unmountBucketInputSchema as mt, cloudflareSandboxCreateTool as n, mountBucketInputSchema as nt, cloudflareSandboxExecuteCodeTool as o, readFilesInputSchema as ot, cloudflareSandboxReadFilesTool as p, sandboxObjectArtifactRefSchema as pt, executeCodeInputSchema as q, cloudflareSandboxDeleteSessionTool as r, mountBucketOutputSchema as rt, cloudflareSandboxExportArtifactTool as s, readFilesOutputSchema as st, cloudflareSandboxCreateSessionTool as t, listFilesOutputSchema as tt, cloudflareSandboxListFilesTool as u, runCodeInputSchema as ut, CloudflareSandboxClient as v, writeFilesInputSchema as vt, workspaceFileKey as w, resolveWriteFileBytes as x, parseExecSse as y, writeFilesOutputSchema as yt, createSandboxOutputSchema as z };
|
|
982
1126
|
|
|
983
|
-
//# sourceMappingURL=cloudflare-sandbox-
|
|
1127
|
+
//# sourceMappingURL=cloudflare-sandbox-D3rAu9bN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudflare-sandbox-D3rAu9bN.js","names":["#http","#storage","#storageAuth","#contexts","#pendingContexts","#forgetSandboxContexts","#ensureCodeContext","#putFileBytes","#getFileBytes","#requireStorage"],"sources":["../src/vendors/cloudflare-sandbox/contracts.ts","../src/vendors/cloudflare-sandbox/domain.ts","../src/vendors/cloudflare-sandbox/client.ts","../src/vendors/cloudflare-sandbox/module.ts"],"sourcesContent":["/**\n * Cloudflare Sandbox Bridge HTTP API contracts.\n * Host deploys the bridge Worker; this pack is a Bearer client.\n * @see https://developers.cloudflare.com/sandbox/bridge/http-api/\n */\n\nimport { z } from 'zod'\n\nimport { s3AuthSchema } from '../s3/contracts'\n\nexport const MAX_ARGV = 64\nexport const MAX_ARG_CHARS = 100_000\nexport const MAX_FILE_PATH = 1024\nexport const MAX_FILE_TEXT = 2_000_000\n/** Bridge hard cap is 32 MiB; package tool path uses the same bound. */\nexport const MAX_FILE_BYTES = 32 * 1024 * 1024\nexport const MAX_WRITE_FILES = 20\nexport const MAX_READ_PATHS = 50\nexport const MAX_LIST_FILES = 500\nexport const DEFAULT_EXEC_TIMEOUT_MS = 30_000\nexport const MAX_EXEC_TIMEOUT_MS = 600_000\n\nexport const cloudflareSandboxAuthSchema = z.object({\n\tbase_url: z\n\t\t.string()\n\t\t.min(1)\n\t\t.describe('Sandbox bridge Worker origin, for example https://sandbox-bridge.example.workers.dev'),\n\tapi_key: z.string().min(1).describe('Bridge SANDBOX_API_KEY Bearer token'),\n\tstorage: s3AuthSchema\n\t\t.optional()\n\t\t.describe('Optional S3-compatible storage for importArtifact / exportArtifact (ArtifactRef)')\n})\n\nexport type CloudflareSandboxAuth = z.infer<typeof cloudflareSandboxAuthSchema>\n\n/** Object-store ArtifactRef for sandbox import/export. */\nexport const sandboxObjectArtifactRefSchema = z.object({\n\tstore: z.literal('object').describe('Object store containing the artifact'),\n\tkey: z.string().min(1).describe('Object key'),\n\tmedia_type: z.string().min(1).optional().describe('MIME or format hint when known'),\n\tfilename: z.string().min(1).optional().describe('Original or display file name'),\n\tbyte_length: z.int().min(0).optional().describe('Size in bytes when known')\n})\n\nexport type SandboxObjectArtifactRef = z.infer<typeof sandboxObjectArtifactRefSchema>\n\nconst sandboxId = z.string().min(1).max(200).describe('Sandbox id returned by create')\n\nexport const sandboxIdInputSchema = z.object({\n\tsandbox_id: sandboxId\n})\n\nexport const createSandboxOutputSchema = z.object({\n\tsandbox_id: z.string().describe('Created sandbox id')\n})\n\nexport const destroySandboxOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tdestroyed: z.literal(true)\n})\n\nexport const runningOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\trunning: z.boolean().describe('Whether the container is live')\n})\n\nexport const healthOutputSchema = z.object({\n\tok: z.boolean()\n})\n\nexport const execInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\targv: z\n\t\t.array(z.string().min(1).max(MAX_ARG_CHARS))\n\t\t.min(1)\n\t\t.max(MAX_ARGV)\n\t\t.describe('Command argv array (not a shell string). Example: [\"python3\",\"-c\",\"print(1)\"]'),\n\ttimeout_ms: z\n\t\t.int()\n\t\t.min(1)\n\t\t.max(MAX_EXEC_TIMEOUT_MS)\n\t\t.optional()\n\t\t.describe(`Exec timeout in ms (default ${DEFAULT_EXEC_TIMEOUT_MS})`),\n\tcwd: z.string().min(1).max(MAX_FILE_PATH).optional().describe('Working directory (default /workspace)'),\n\tsession_id: z\n\t\t.string()\n\t\t.min(1)\n\t\t.max(200)\n\t\t.optional()\n\t\t.describe('Optional bridge session id for isolated working directory and runtime state'),\n\tenv: z\n\t\t.record(z.string().min(1).max(128), z.string().max(8_192))\n\t\t.optional()\n\t\t.describe('Optional environment variables for the process when the bridge supports env')\n})\n\nexport const execOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tstdout: z.string().describe('Decoded standard output'),\n\tstderr: z.string().describe('Decoded standard error'),\n\texit_code: z.number().int().optional().describe('Process exit code when the stream ends with exit'),\n\tsuccess: z.boolean().describe('True when exit_code is 0'),\n\terror: z.string().optional().describe('Bridge error message when the stream ends with error'),\n\terror_code: z.string().optional().describe('Bridge error code when present')\n})\n\nconst filePathField = z\n\t.string()\n\t.min(1)\n\t.max(MAX_FILE_PATH)\n\t.describe('Path under workspace (with or without /workspace/ prefix)')\n\nconst sessionIdField = z.string().min(1).max(200).optional().describe('Optional Session-Id header')\n\nconst writeFileBodyFields = {\n\ttext: z.string().max(MAX_FILE_TEXT).optional().describe('Utf-8 file contents (omit when body_base64 is set)'),\n\tbody_base64: z\n\t\t.string()\n\t\t.min(1)\n\t\t.optional()\n\t\t.describe('Base64 file bytes for binary content (omit when text is set; max 32 MiB decoded)')\n}\n\nfunction refineExactlyOneBody(\n\tval: { text?: string | undefined; body_base64?: string | undefined },\n\tctx: z.RefinementCtx\n): void {\n\tconst hasText = val.text !== undefined\n\tconst hasB64 = val.body_base64 !== undefined\n\tif (hasText === hasB64) {\n\t\tctx.addIssue({\n\t\t\tcode: 'custom',\n\t\t\tmessage: 'Provide exactly one of text or body_base64'\n\t\t})\n\t}\n}\n\nexport const writeFileInputSchema = z\n\t.object({\n\t\tsandbox_id: sandboxId,\n\t\tpath: filePathField,\n\t\t...writeFileBodyFields,\n\t\tsession_id: sessionIdField\n\t})\n\t.superRefine(refineExactlyOneBody)\n\nexport const writeFileOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tpath: z.string(),\n\tok: z.literal(true),\n\tbyte_length: z.number().int().nonnegative().optional().describe('Decoded byte length written when known')\n})\n\nexport const readFileInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tpath: filePathField,\n\tencoding: z\n\t\t.enum(['utf8', 'base64'])\n\t\t.optional()\n\t\t.describe('Response encoding (default utf8 for text; use base64 for binary)'),\n\tsession_id: sessionIdField\n})\n\nexport const readFileOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tpath: z.string(),\n\ttext: z.string().optional().describe('Utf-8 contents when encoding is utf8 (default)'),\n\tbody_base64: z.string().optional().describe('Base64 contents when encoding is base64'),\n\tbyte_length: z.number().int().nonnegative().optional().describe('Decoded byte length')\n})\n\nexport const writeFilesInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tfiles: z\n\t\t.array(\n\t\t\tz\n\t\t\t\t.object({\n\t\t\t\t\tpath: z.string().min(1).max(MAX_FILE_PATH).describe('Path under workspace'),\n\t\t\t\t\t...writeFileBodyFields\n\t\t\t\t})\n\t\t\t\t.superRefine(refineExactlyOneBody)\n\t\t)\n\t\t.min(1)\n\t\t.max(MAX_WRITE_FILES)\n\t\t.describe('Files to write under workspace (text or body_base64 each)'),\n\tsession_id: sessionIdField\n})\n\nexport const writeFilesOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tpaths: z.array(z.string()),\n\tok: z.literal(true)\n})\n\nexport const readFilesInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tpaths: z\n\t\t.array(z.string().min(1).max(MAX_FILE_PATH).describe('Path under workspace'))\n\t\t.min(1)\n\t\t.max(MAX_READ_PATHS)\n\t\t.describe('Paths to read under workspace'),\n\tencoding: z.enum(['utf8', 'base64']).optional().describe('Response encoding for all files (default utf8)'),\n\tsession_id: sessionIdField\n})\n\nexport const readFilesOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tfiles: z.array(\n\t\tz.object({\n\t\t\tpath: z.string(),\n\t\t\ttext: z.string().optional(),\n\t\t\tbody_base64: z.string().optional(),\n\t\t\tbyte_length: z.number().int().nonnegative().optional()\n\t\t})\n\t)\n})\n\nexport const listFilesInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tdirectory_path: z.string().max(MAX_FILE_PATH).optional().describe('Directory to list (default /workspace)'),\n\tsession_id: sessionIdField\n})\n\nexport const listFilesOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tpaths: z.array(z.string()).describe('Absolute or workspace-relative file paths found'),\n\traw: z.unknown().optional().describe('Provider listing payload when available')\n})\n\nexport const removeFilesInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tpaths: z\n\t\t.array(z.string().min(1).max(MAX_FILE_PATH))\n\t\t.min(1)\n\t\t.max(MAX_READ_PATHS)\n\t\t.describe('Paths to remove under workspace'),\n\tsession_id: sessionIdField\n})\n\nexport const removeFilesOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tpaths: z.array(z.string()),\n\tok: z.literal(true)\n})\n\nexport const importArtifactInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tpath: filePathField,\n\tsource: sandboxObjectArtifactRefSchema.describe('Object-store ArtifactRef to copy into the sandbox'),\n\tsession_id: sessionIdField\n})\n\nexport const importArtifactOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tpath: z.string(),\n\tok: z.literal(true),\n\tbyte_length: z.number().int().nonnegative()\n})\n\nexport const exportArtifactInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tpath: filePathField,\n\tdestination_key: z.string().min(1).describe('Object key to write under bound storage'),\n\tsession_id: sessionIdField\n})\n\nexport const exportArtifactOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tpath: z.string(),\n\tartifact: sandboxObjectArtifactRefSchema\n})\n\nexport const createBridgeSessionOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tsession_id: z.string().describe('Bridge session id for Session-Id header')\n})\n\nexport const deleteBridgeSessionInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tsession_id: z.string().min(1).max(200).describe('Bridge session id to delete')\n})\n\nexport const deleteBridgeSessionOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tsession_id: z.string(),\n\tdeleted: z.literal(true)\n})\n\nconst interpreterLanguageSchema = z.enum(['python', 'javascript', 'typescript'])\n\nexport const executeCodeInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tcode: z.string().min(1).max(MAX_ARG_CHARS).describe('Source code to run'),\n\tlanguage: interpreterLanguageSchema.optional().describe('Interpreter language (default python)'),\n\ttimeout_ms: z\n\t\t.int()\n\t\t.min(1)\n\t\t.max(MAX_EXEC_TIMEOUT_MS)\n\t\t.optional()\n\t\t.describe(`Exec timeout in ms (default ${DEFAULT_EXEC_TIMEOUT_MS})`),\n\tcontext_id: z\n\t\t.string()\n\t\t.min(1)\n\t\t.max(200)\n\t\t.optional()\n\t\t.describe('Optional interpreter context id; omit to reuse the sandbox language context')\n})\n\nexport const createCodeContextInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tlanguage: interpreterLanguageSchema.optional().describe('Interpreter language (default python)'),\n\tcwd: z.string().min(1).max(MAX_FILE_PATH).optional().describe('Working directory (default /workspace)'),\n\tenv: z\n\t\t.record(z.string().min(1).max(128), z.string().max(8_192))\n\t\t.optional()\n\t\t.describe('Environment variables for the interpreter context'),\n\ttimeout_ms: z\n\t\t.int()\n\t\t.min(1)\n\t\t.max(MAX_EXEC_TIMEOUT_MS)\n\t\t.optional()\n\t\t.describe(`Context create timeout in ms (default ${DEFAULT_EXEC_TIMEOUT_MS})`)\n})\n\nexport const createCodeContextOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tcontext_id: z.string().describe('Persistent interpreter context id'),\n\tlanguage: interpreterLanguageSchema.optional(),\n\tcwd: z.string().optional()\n})\n\nexport const listCodeContextsOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tcontexts: z.array(\n\t\tz.object({\n\t\t\tcontext_id: z.string(),\n\t\t\tlanguage: z.string().optional(),\n\t\t\tcwd: z.string().optional()\n\t\t})\n\t)\n})\n\nexport const deleteCodeContextInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tcontext_id: z.string().min(1).max(200).describe('Interpreter context id to delete')\n})\n\nexport const deleteCodeContextOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tcontext_id: z.string(),\n\tdeleted: z.literal(true)\n})\n\nexport const runCodeInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tcode: z.string().min(1).max(MAX_ARG_CHARS).describe('Source to run in the interpreter context'),\n\tcontext_id: z.string().min(1).max(200).optional().describe('Interpreter context id; omit for the language default'),\n\tlanguage: interpreterLanguageSchema.optional().describe('Interpreter language when creating a default context'),\n\ttimeout_ms: z\n\t\t.int()\n\t\t.min(1)\n\t\t.max(MAX_EXEC_TIMEOUT_MS)\n\t\t.optional()\n\t\t.describe(`Run timeout in ms (default ${DEFAULT_EXEC_TIMEOUT_MS})`)\n})\n\n/**\n * Mount an S3-compatible bucket into the sandbox filesystem.\n * @see https://developers.cloudflare.com/sandbox/bridge/http-api/#bucket-mounts\n *\n * Two bridge modes:\n * - **R2 binding:** omit `endpoint`; `bucket` is the Worker R2 binding name.\n * - **Remote S3/R2/GCS:** set `endpoint` (+ optional credentials; bridge may use Worker secrets).\n */\nexport const mountBucketInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tbucket: z\n\t\t.string()\n\t\t.min(1)\n\t\t.max(256)\n\t\t.describe(\n\t\t\t'R2 Worker binding name when endpoint is omitted; otherwise the remote bucket name (e.g. for S3/R2 endpoint mounts)'\n\t\t),\n\tmount_path: z\n\t\t.string()\n\t\t.min(1)\n\t\t.max(MAX_FILE_PATH)\n\t\t.refine((p) => p.startsWith('/'), { message: 'mount_path must be an absolute path (start with /)' })\n\t\t.describe('Absolute path inside the sandbox to mount at (e.g. /data or /mnt/workspace)'),\n\tendpoint: z\n\t\t.url()\n\t\t.optional()\n\t\t.describe(\n\t\t\t'S3-compatible endpoint URL (e.g. https://s3.amazonaws.com or https://ACCOUNT.r2.cloudflarestorage.com). Omit for Worker R2 binding mounts'\n\t\t),\n\tprovider: z\n\t\t.enum(['r2', 's3', 'gcs'])\n\t\t.optional()\n\t\t.describe('Provider hint for s3fs optimizations when using endpoint mounts'),\n\tread_only: z.boolean().optional().describe('Mount read-only (default false)'),\n\tprefix: z\n\t\t.string()\n\t\t.min(1)\n\t\t.max(MAX_FILE_PATH)\n\t\t.optional()\n\t\t.describe('Bucket prefix/subdirectory to expose at the mount (must start with / when set)'),\n\taccess_key_id: z\n\t\t.string()\n\t\t.min(1)\n\t\t.optional()\n\t\t.describe('Access key for endpoint mounts (maps to bridge credentials.accessKeyId)'),\n\tsecret_access_key: z\n\t\t.string()\n\t\t.min(1)\n\t\t.optional()\n\t\t.describe('Secret key for endpoint mounts (maps to bridge credentials.secretAccessKey)'),\n\tcredential_proxy: z\n\t\t.boolean()\n\t\t.optional()\n\t\t.describe(\n\t\t\t'When true, bridge keeps credentials out of the container (egress signing). Endpoint mounts only; requires ContainerProxy on the bridge Worker'\n\t\t),\n\tlocal_bucket: z\n\t\t.boolean()\n\t\t.optional()\n\t\t.describe('When true, use local R2 binding sync (wrangler dev). Mutually exclusive with endpoint'),\n\ts3fs_options: z\n\t\t.array(z.string().min(1).max(256))\n\t\t.max(32)\n\t\t.optional()\n\t\t.describe('Advanced s3fs mount flags (e.g. use_cache=/tmp/cache)')\n})\n\nexport const mountBucketOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tbucket: z.string(),\n\tmount_path: z.string(),\n\tok: z.literal(true)\n})\n\nexport const unmountBucketInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tmount_path: z\n\t\t.string()\n\t\t.min(1)\n\t\t.max(MAX_FILE_PATH)\n\t\t.refine((p) => p.startsWith('/'), { message: 'mount_path must be an absolute path (start with /)' })\n\t\t.describe('Absolute mount path previously passed to mount')\n})\n\nexport const unmountBucketOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tmount_path: z.string(),\n\tok: z.literal(true)\n})\n\nexport type SandboxIdInput = z.infer<typeof sandboxIdInputSchema>\nexport type CreateSandboxOutput = z.infer<typeof createSandboxOutputSchema>\nexport type DestroySandboxOutput = z.infer<typeof destroySandboxOutputSchema>\nexport type RunningOutput = z.infer<typeof runningOutputSchema>\nexport type HealthOutput = z.infer<typeof healthOutputSchema>\nexport type ExecInput = z.infer<typeof execInputSchema>\nexport type ExecOutput = z.infer<typeof execOutputSchema>\nexport type WriteFileInput = z.infer<typeof writeFileInputSchema>\nexport type WriteFileOutput = z.infer<typeof writeFileOutputSchema>\nexport type ReadFileInput = z.infer<typeof readFileInputSchema>\nexport type ReadFileOutput = z.infer<typeof readFileOutputSchema>\nexport type WriteFilesInput = z.infer<typeof writeFilesInputSchema>\nexport type WriteFilesOutput = z.infer<typeof writeFilesOutputSchema>\nexport type ReadFilesInput = z.infer<typeof readFilesInputSchema>\nexport type ReadFilesOutput = z.infer<typeof readFilesOutputSchema>\nexport type ListFilesInput = z.infer<typeof listFilesInputSchema>\nexport type ListFilesOutput = z.infer<typeof listFilesOutputSchema>\nexport type RemoveFilesInput = z.infer<typeof removeFilesInputSchema>\nexport type RemoveFilesOutput = z.infer<typeof removeFilesOutputSchema>\nexport type ImportArtifactInput = z.infer<typeof importArtifactInputSchema>\nexport type ImportArtifactOutput = z.infer<typeof importArtifactOutputSchema>\nexport type ExportArtifactInput = z.infer<typeof exportArtifactInputSchema>\nexport type ExportArtifactOutput = z.infer<typeof exportArtifactOutputSchema>\nexport type CreateBridgeSessionOutput = z.infer<typeof createBridgeSessionOutputSchema>\nexport type DeleteBridgeSessionInput = z.infer<typeof deleteBridgeSessionInputSchema>\nexport type DeleteBridgeSessionOutput = z.infer<typeof deleteBridgeSessionOutputSchema>\nexport type ExecuteCodeInput = z.infer<typeof executeCodeInputSchema>\nexport type CreateCodeContextInput = z.infer<typeof createCodeContextInputSchema>\nexport type CreateCodeContextOutput = z.infer<typeof createCodeContextOutputSchema>\nexport type ListCodeContextsOutput = z.infer<typeof listCodeContextsOutputSchema>\nexport type DeleteCodeContextInput = z.infer<typeof deleteCodeContextInputSchema>\nexport type DeleteCodeContextOutput = z.infer<typeof deleteCodeContextOutputSchema>\nexport type RunCodeInput = z.infer<typeof runCodeInputSchema>\nexport type MountBucketInput = z.infer<typeof mountBucketInputSchema>\nexport type MountBucketOutput = z.infer<typeof mountBucketOutputSchema>\nexport type UnmountBucketInput = z.infer<typeof unmountBucketInputSchema>\nexport type UnmountBucketOutput = z.infer<typeof unmountBucketOutputSchema>\n","/**\n * Cloudflare Sandbox Bridge pure helpers (no HTTP).\n */\n\nimport { isPlainObject, isString } from 'es-toolkit'\nimport { z } from 'zod'\n\nimport { ToolError } from '../../core/errors'\nimport { base64ToBytes, utf8ToBytes } from '../../shared/bytes'\nimport { MAX_FILE_BYTES } from './contracts'\nimport type { ListCodeContextsOutput } from './contracts'\n\n/** Normalize a host path to the bridge URL segment under /file/… (no leading slash). */\nexport function workspaceFileKey(path: string): string {\n\tconst trimmed = path.trim()\n\tif (!trimmed) {\n\t\tthrow new ToolError('File path is empty', { code: 'bad_input' })\n\t}\n\tconst noLead = trimmed.replace(/^\\/+/, '')\n\tconst under = noLead.startsWith('workspace/') ? noLead : `workspace/${noLead}`\n\t// Reject traversal\n\tconst parts = under.split('/')\n\tif (parts.some((p) => p === '..' || p === '')) {\n\t\tthrow new ToolError('File path must stay under workspace', {\n\t\t\tcode: 'bad_input',\n\t\t\tdetails: { path: trimmed }\n\t\t})\n\t}\n\treturn under\n}\n\n/** Absolute workspace path for shell list/rm (leading slash). */\nexport function workspaceAbsolutePath(path: string): string {\n\tconst key = workspaceFileKey(path)\n\treturn `/${key}`\n}\n\n/** Shell-safe single-quoted string. */\nexport function shellQuote(value: string): string {\n\treturn `'${value.replaceAll(\"'\", `'\\\\''`)}'`\n}\n\n/**\n * Resolve write-file body to raw bytes (text UTF-8 or base64).\n * Enforces MAX_FILE_BYTES (bridge limit).\n */\nexport function resolveWriteFileBytes(input: {\n\ttext?: string | undefined\n\tbody_base64?: string | undefined\n}): Uint8Array {\n\tif (input.body_base64 !== undefined && input.text !== undefined) {\n\t\tthrow new ToolError('Provide exactly one of text or body_base64', { code: 'bad_input' })\n\t}\n\tif (input.body_base64 !== undefined) {\n\t\tconst bytes = base64ToBytes(input.body_base64)\n\t\tif (bytes.byteLength > MAX_FILE_BYTES) {\n\t\t\tthrow new ToolError('Sandbox file exceeds max byte limit', {\n\t\t\t\tcode: 'too_large',\n\t\t\t\tdetails: { max_bytes: MAX_FILE_BYTES, content_length: bytes.byteLength }\n\t\t\t})\n\t\t}\n\t\treturn bytes\n\t}\n\tif (input.text !== undefined) {\n\t\tconst bytes = utf8ToBytes(input.text)\n\t\tif (bytes.byteLength > MAX_FILE_BYTES) {\n\t\t\tthrow new ToolError('Sandbox file exceeds max byte limit', {\n\t\t\t\tcode: 'too_large',\n\t\t\t\tdetails: { max_bytes: MAX_FILE_BYTES, content_length: bytes.byteLength }\n\t\t\t})\n\t\t}\n\t\treturn bytes\n\t}\n\tthrow new ToolError('Provide exactly one of text or body_base64', { code: 'bad_input' })\n}\n\nexport type ParsedExecStream = {\n\tstdout: string\n\tstderr: string\n\texit_code?: number\n\terror?: string\n\terror_code?: string\n}\n\nexport type ParseExecSseOptions = {\n\t/** Called for each stdout chunk as the SSE body is walked (buffer may still be complete). */\n\tonStdout?: (chunk: string) => void\n\t/** Called for each stderr chunk as the SSE body is walked. */\n\tonStderr?: (chunk: string) => void\n}\n\n/**\n * Parse bridge /exec text/event-stream body.\n * Events: stdout/stderr (base64 data), exit ({\"exit_code\":N}), error ({\"error\",\"code\"}).\n */\nexport function parseExecSse(body: string, options: ParseExecSseOptions = {}): ParsedExecStream {\n\tconst stdoutChunks: string[] = []\n\tconst stderrChunks: string[] = []\n\tlet exit_code: number | undefined\n\tlet error: string | undefined\n\tlet error_code: string | undefined\n\n\tconst blocks = body.replaceAll('\\r\\n', '\\n').split('\\n\\n')\n\tfor (const block of blocks) {\n\t\tconst lines = block.split('\\n').filter((line) => line.length > 0)\n\t\tif (lines.length === 0) continue\n\t\tlet event = 'message'\n\t\tconst dataLines: string[] = []\n\t\tfor (const line of lines) {\n\t\t\tif (line.startsWith('event:')) {\n\t\t\t\tevent = line.slice(6).trim()\n\t\t\t} else if (line.startsWith('data:')) {\n\t\t\t\tdataLines.push(line.slice(5).trimStart())\n\t\t\t}\n\t\t}\n\t\tconst data = dataLines.join('\\n')\n\t\tif (event === 'stdout' && data.length > 0) {\n\t\t\tconst chunk = decodeBase64Chunk(data)\n\t\t\tstdoutChunks.push(chunk)\n\t\t\toptions.onStdout?.(chunk)\n\t\t} else if (event === 'stderr' && data.length > 0) {\n\t\t\tconst chunk = decodeBase64Chunk(data)\n\t\t\tstderrChunks.push(chunk)\n\t\t\toptions.onStderr?.(chunk)\n\t\t} else if (event === 'exit' && data.length > 0) {\n\t\t\tconst parsed = safeJson(data)\n\t\t\tif (isPlainObject(parsed)) {\n\t\t\t\tconst code = parsed['exit_code']\n\t\t\t\tif (typeof code === 'number' && Number.isFinite(code)) exit_code = code\n\t\t\t}\n\t\t} else if (event === 'error' && data.length > 0) {\n\t\t\tconst parsed = safeJson(data)\n\t\t\tif (isPlainObject(parsed)) {\n\t\t\t\tif (isString(parsed['error'])) error = parsed['error']\n\t\t\t\tif (isString(parsed['code'])) error_code = parsed['code']\n\t\t\t} else {\n\t\t\t\terror = data\n\t\t\t}\n\t\t}\n\t}\n\n\tconst out: ParsedExecStream = {\n\t\tstdout: stdoutChunks.join(''),\n\t\tstderr: stderrChunks.join('')\n\t}\n\tif (exit_code !== undefined) out.exit_code = exit_code\n\tif (error !== undefined) out.error = error\n\tif (error_code !== undefined) out.error_code = error_code\n\treturn out\n}\n\nfunction decodeBase64Chunk(data: string): string {\n\ttry {\n\t\t// Bun/Node Buffer or atob\n\t\tif (typeof Buffer !== 'undefined') {\n\t\t\treturn Buffer.from(data, 'base64').toString('utf8')\n\t\t}\n\t\tconst binary = atob(data)\n\t\tconst bytes = new Uint8Array(binary.length)\n\t\tfor (let i = 0; i < binary.length; i += 1) bytes[i] = binary.charCodeAt(i)\n\t\treturn new TextDecoder().decode(bytes)\n\t} catch {\n\t\treturn data\n\t}\n}\n\nfunction safeJson(text: string): unknown {\n\ttry {\n\t\tconst value: unknown = JSON.parse(text)\n\t\treturn value\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\nexport type InterpreterLanguage = 'python' | 'javascript' | 'typescript'\n\n/** Cloudflare interpreter `runCode` JSON. https://developers.cloudflare.com/sandbox/api/interpreter/ */\nconst runCodePayloadSchema = z.object({\n\tlogs: z.object({\n\t\tstdout: z.array(z.string()),\n\t\tstderr: z.array(z.string())\n\t}),\n\terror: z\n\t\t.object({\n\t\t\tname: z.string(),\n\t\t\tvalue: z.string()\n\t\t})\n\t\t.optional()\n})\n\nexport type ParsedRunCode = {\n\tstdout: string\n\tstderr: string\n\tsuccess: boolean\n\texit_code: number\n\terror?: string\n}\n\nexport function parseRunCodePayload(data: unknown): ParsedRunCode {\n\tconst parsed = runCodePayloadSchema.safeParse(data)\n\tif (!parsed.success) {\n\t\tthrow new ToolError('Unexpected run-code response', { code: 'upstream' })\n\t}\n\tconst { logs, error } = parsed.data\n\tconst out: ParsedRunCode = {\n\t\tstdout: logs.stdout.join(''),\n\t\tstderr: logs.stderr.join(''),\n\t\tsuccess: error === undefined,\n\t\texit_code: error === undefined ? 0 : 1\n\t}\n\tif (error) out.error = error.value\n\treturn out\n}\n\nconst createCodeContextPayloadSchema = z.object({\n\tid: z.string().min(1),\n\tcwd: z.string().min(1).optional()\n})\n\nexport function parseCreateCodeContextPayload(data: unknown): { id: string; cwd?: string } {\n\tconst parsed = createCodeContextPayloadSchema.safeParse(data)\n\tif (!parsed.success) {\n\t\tthrow new ToolError('Unexpected create code context response', { code: 'upstream' })\n\t}\n\treturn {\n\t\tid: parsed.data.id,\n\t\t...(parsed.data.cwd && { cwd: parsed.data.cwd })\n\t}\n}\n\nconst listCodeContextsPayloadSchema = z.object({\n\tcontexts: z.array(\n\t\tz.object({\n\t\t\tid: z.string().min(1),\n\t\t\tlanguage: z.string().min(1).optional(),\n\t\t\tcwd: z.string().min(1).optional()\n\t\t})\n\t)\n})\n\nexport function parseListCodeContextsPayload(data: unknown): ListCodeContextsOutput['contexts'] {\n\tconst parsed = listCodeContextsPayloadSchema.safeParse(data)\n\tif (!parsed.success) {\n\t\tthrow new ToolError('Unexpected list code contexts response', { code: 'upstream' })\n\t}\n\treturn parsed.data.contexts.map((row) => ({\n\t\tcontext_id: row.id,\n\t\t...(row.language && { language: row.language }),\n\t\t...(row.cwd && { cwd: row.cwd })\n\t}))\n}\n","/**\n * Cloudflare Sandbox Bridge vendor client (HttpService + Bearer).\n * Host: `new CloudflareSandboxClient(auth)`. Agent: `fromContext(ctx)`.\n * Gold: `src/vendors/resend/client.ts` + messaging ArtifactRef storage pattern.\n * @see https://developers.cloudflare.com/sandbox/bridge/http-api/\n */\n\nimport { isPlainObject, isString, trimEnd } from 'es-toolkit'\n\nimport { ToolError } from '../../core/errors'\nimport { requireAuth } from '../../core/provider'\nimport type { ToolContext } from '../../core/types'\nimport { bytesToBase64, bytesToUtf8, toArrayBuffer } from '../../shared/bytes'\nimport { HttpService } from '../../transport/http-service'\nimport type { HttpServiceOptions } from '../../transport/http-service'\nimport { S3Client } from '../s3'\nimport type {\n\tCloudflareSandboxAuth,\n\tCreateBridgeSessionOutput,\n\tCreateCodeContextInput,\n\tCreateCodeContextOutput,\n\tCreateSandboxOutput,\n\tDeleteBridgeSessionInput,\n\tDeleteBridgeSessionOutput,\n\tDeleteCodeContextInput,\n\tDeleteCodeContextOutput,\n\tDestroySandboxOutput,\n\tExecInput,\n\tExecOutput,\n\tExecuteCodeInput,\n\tExportArtifactInput,\n\tExportArtifactOutput,\n\tHealthOutput,\n\tImportArtifactInput,\n\tImportArtifactOutput,\n\tListCodeContextsOutput,\n\tListFilesInput,\n\tListFilesOutput,\n\tMountBucketInput,\n\tMountBucketOutput,\n\tReadFileInput,\n\tReadFileOutput,\n\tReadFilesInput,\n\tReadFilesOutput,\n\tRemoveFilesInput,\n\tRemoveFilesOutput,\n\tRunCodeInput,\n\tRunningOutput,\n\tSandboxIdInput,\n\tUnmountBucketInput,\n\tUnmountBucketOutput,\n\tWriteFileInput,\n\tWriteFileOutput,\n\tWriteFilesInput,\n\tWriteFilesOutput\n} from './contracts'\nimport {\n\tDEFAULT_EXEC_TIMEOUT_MS,\n\tMAX_FILE_BYTES,\n\tMAX_LIST_FILES,\n\tcloudflareSandboxAuthSchema,\n\tmountBucketInputSchema,\n\tunmountBucketInputSchema\n} from './contracts'\nimport {\n\tparseCreateCodeContextPayload,\n\tparseExecSse,\n\tparseListCodeContextsPayload,\n\tparseRunCodePayload,\n\tresolveWriteFileBytes,\n\tshellQuote,\n\tworkspaceAbsolutePath,\n\tworkspaceFileKey\n} from './domain'\nimport type { InterpreterLanguage } from './domain'\n\nexport type CloudflareSandboxClientOptions = Pick<HttpServiceOptions, 'fetch' | 'signal'>\n\nexport class CloudflareSandboxClient {\n\treadonly #http: HttpService\n\treadonly #storage: S3Client | undefined\n\t/** Optional S3 auth fields for endpoint mount credential fallback (Mastra workspace FS). */\n\treadonly #storageAuth:\n\t\t| {\n\t\t\t\taccess_key_id: string\n\t\t\t\tsecret_access_key: string\n\t\t\t\tendpoint?: string | undefined\n\t\t }\n\t\t| undefined\n\t/** sandbox_id:language → interpreter context id (Node/Python stay loaded). */\n\treadonly #contexts = new Map<string, string>()\n\treadonly #pendingContexts = new Map<string, Promise<string>>()\n\n\tconstructor(auth: CloudflareSandboxAuth, options: CloudflareSandboxClientOptions = {}) {\n\t\tconst parsed = cloudflareSandboxAuthSchema.safeParse(auth)\n\t\tif (!parsed.success) {\n\t\t\tthrow new ToolError('Invalid Cloudflare Sandbox auth credentials', {\n\t\t\t\tcode: 'bad_auth',\n\t\t\t\tdetails: { issues: parsed.error.issues.map((issue) => issue.message) }\n\t\t\t})\n\t\t}\n\t\tthis.#http = new HttpService({\n\t\t\tbaseURL: trimEnd(parsed.data.base_url, '/'),\n\t\t\theaders: {\n\t\t\t\tAuthorization: `Bearer ${parsed.data.api_key}`\n\t\t\t},\n\t\t\ttimeout: 120_000,\n\t\t\tlabel: 'Cloudflare Sandbox',\n\t\t\t...(options.fetch && { fetch: options.fetch }),\n\t\t\t...(options.signal && { signal: options.signal })\n\t\t})\n\t\tthis.#storage = parsed.data.storage\n\t\t\t? new S3Client(parsed.data.storage, {\n\t\t\t\t\t...(options.fetch && { fetch: options.fetch }),\n\t\t\t\t\t...(options.signal && { signal: options.signal })\n\t\t\t\t})\n\t\t\t: undefined\n\t\tthis.#storageAuth = parsed.data.storage\n\t\t\t? {\n\t\t\t\t\taccess_key_id: parsed.data.storage.access_key_id,\n\t\t\t\t\tsecret_access_key: parsed.data.storage.secret_access_key,\n\t\t\t\t\t...(parsed.data.storage.endpoint && { endpoint: parsed.data.storage.endpoint })\n\t\t\t\t}\n\t\t\t: undefined\n\t}\n\n\tstatic fromContext(ctx: ToolContext): CloudflareSandboxClient {\n\t\treturn new CloudflareSandboxClient(requireAuth(ctx, cloudflareSandboxAuthSchema), {\n\t\t\t...(ctx.fetch && { fetch: ctx.fetch }),\n\t\t\t...(ctx.signal && { signal: ctx.signal })\n\t\t})\n\t}\n\n\t/** Liveness probe on the bridge. */\n\tasync health(): Promise<HealthOutput> {\n\t\tconst { data } = await this.#http.get('/health', {\n\t\t\tlabel: 'Cloudflare Sandbox health'\n\t\t})\n\t\tif (isPlainObject(data) && data['ok'] === true) return { ok: true }\n\t\tif (isPlainObject(data) && data['ok'] === false) return { ok: false }\n\t\treturn { ok: true }\n\t}\n\n\tasync create(): Promise<CreateSandboxOutput> {\n\t\tconst { data } = await this.#http.post('/v1/sandbox', undefined, {\n\t\t\tlabel: 'Cloudflare Sandbox create'\n\t\t})\n\t\tif (!isPlainObject(data) || !isString(data['id'])) {\n\t\t\tthrow new ToolError('Unexpected create sandbox response', { code: 'upstream' })\n\t\t}\n\t\treturn { sandbox_id: data['id'] }\n\t}\n\n\tasync destroy(input: SandboxIdInput): Promise<DestroySandboxOutput> {\n\t\tawait this.#http.delete(`/v1/sandbox/${encodeURIComponent(input.sandbox_id)}`, {\n\t\t\tlabel: 'Cloudflare Sandbox destroy'\n\t\t})\n\t\tthis.#forgetSandboxContexts(input.sandbox_id)\n\t\treturn { sandbox_id: input.sandbox_id, destroyed: true }\n\t}\n\n\tasync running(input: SandboxIdInput): Promise<RunningOutput> {\n\t\tconst { data } = await this.#http.get(`/v1/sandbox/${encodeURIComponent(input.sandbox_id)}/running`, {\n\t\t\tlabel: 'Cloudflare Sandbox running'\n\t\t})\n\t\tif (!isPlainObject(data) || typeof data['running'] !== 'boolean') {\n\t\t\tthrow new ToolError('Unexpected running response', { code: 'upstream' })\n\t\t}\n\t\treturn { sandbox_id: input.sandbox_id, running: data['running'] }\n\t}\n\n\t/**\n\t * Run a command. Bridge returns text/event-stream (stdout/stderr base64 + exit).\n\t * Uses HttpService.bytes so ofetch does not try to JSON-parse the SSE body.\n\t * Optional onStdout/onStderr fire while walking the buffered SSE (not true wire streaming).\n\t */\n\tasync exec(\n\t\tinput: ExecInput,\n\t\tstream: { onStdout?: (chunk: string) => void; onStderr?: (chunk: string) => void } = {}\n\t): Promise<ExecOutput> {\n\t\tconst body: Record<string, unknown> = {\n\t\t\targv: input.argv,\n\t\t\ttimeout_ms: input.timeout_ms ?? DEFAULT_EXEC_TIMEOUT_MS\n\t\t}\n\t\tif (input.cwd) body['cwd'] = input.cwd\n\t\tif (input.env && Object.keys(input.env).length > 0) body['env'] = input.env\n\n\t\tconst headers: Record<string, string> = {\n\t\t\t'Content-Type': 'application/json',\n\t\t\tAccept: 'text/event-stream'\n\t\t}\n\t\tif (input.session_id) headers['Session-Id'] = input.session_id\n\n\t\tconst { bytes } = await this.#http.bytes('POST', `/v1/sandbox/${encodeURIComponent(input.sandbox_id)}/exec`, {\n\t\t\tbody,\n\t\t\theaders,\n\t\t\tlabel: 'Cloudflare Sandbox exec'\n\t\t})\n\t\tconst text = new TextDecoder().decode(bytes)\n\t\tconst parsed = parseExecSse(text, {\n\t\t\t...(stream.onStdout && { onStdout: stream.onStdout }),\n\t\t\t...(stream.onStderr && { onStderr: stream.onStderr })\n\t\t})\n\t\tif (parsed.error && parsed.exit_code === undefined) {\n\t\t\tthrow new ToolError(parsed.error, {\n\t\t\t\tcode: 'upstream',\n\t\t\t\tdetails: {\n\t\t\t\t\t...(parsed.error_code && { error_code: parsed.error_code }),\n\t\t\t\t\tsandbox_id: input.sandbox_id\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t\tconst exit_code = parsed.exit_code ?? (parsed.error ? 1 : 0)\n\t\tconst out: ExecOutput = {\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\tstdout: parsed.stdout,\n\t\t\tstderr: parsed.stderr,\n\t\t\texit_code,\n\t\t\tsuccess: exit_code === 0\n\t\t}\n\t\tif (parsed.error) out.error = parsed.error\n\t\tif (parsed.error_code) out.error_code = parsed.error_code\n\t\treturn out\n\t}\n\n\tasync executeCode(input: ExecuteCodeInput): Promise<ExecOutput> {\n\t\tconst language = input.language ?? 'python'\n\t\tconst context_id = input.context_id ?? (await this.#ensureCodeContext(input.sandbox_id, language))\n\t\treturn this.runCode({\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\tcode: input.code,\n\t\t\tcontext_id,\n\t\t\tlanguage,\n\t\t\t...(input.timeout_ms !== undefined && { timeout_ms: input.timeout_ms })\n\t\t})\n\t}\n\n\tasync createCodeContext(input: CreateCodeContextInput): Promise<CreateCodeContextOutput> {\n\t\tconst language = input.language ?? 'python'\n\t\tconst { data } = await this.#http.post(\n\t\t\t`/v1/sandbox/${encodeURIComponent(input.sandbox_id)}/context`,\n\t\t\t{\n\t\t\t\tlanguage,\n\t\t\t\t...(input.cwd && { cwd: input.cwd }),\n\t\t\t\t...(input.env && Object.keys(input.env).length > 0 && { env: input.env }),\n\t\t\t\t...(input.timeout_ms !== undefined && { timeout_ms: input.timeout_ms })\n\t\t\t},\n\t\t\t{ label: 'Cloudflare Sandbox createCodeContext' }\n\t\t)\n\t\tconst row = parseCreateCodeContextPayload(data)\n\t\treturn {\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\tcontext_id: row.id,\n\t\t\tlanguage,\n\t\t\t...(row.cwd && { cwd: row.cwd })\n\t\t}\n\t}\n\n\tasync listCodeContexts(input: SandboxIdInput): Promise<ListCodeContextsOutput> {\n\t\tconst { data } = await this.#http.get(`/v1/sandbox/${encodeURIComponent(input.sandbox_id)}/context`, {\n\t\t\tlabel: 'Cloudflare Sandbox listCodeContexts'\n\t\t})\n\t\treturn {\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\tcontexts: parseListCodeContextsPayload(data)\n\t\t}\n\t}\n\n\tasync deleteCodeContext(input: DeleteCodeContextInput): Promise<DeleteCodeContextOutput> {\n\t\tawait this.#http.delete(\n\t\t\t`/v1/sandbox/${encodeURIComponent(input.sandbox_id)}/context/${encodeURIComponent(input.context_id)}`,\n\t\t\t{ label: 'Cloudflare Sandbox deleteCodeContext' }\n\t\t)\n\t\tconst prefix = `${input.sandbox_id}:`\n\t\tfor (const [key, contextId] of this.#contexts) {\n\t\t\tif (contextId === input.context_id && key.startsWith(prefix)) this.#contexts.delete(key)\n\t\t}\n\t\treturn { sandbox_id: input.sandbox_id, context_id: input.context_id, deleted: true }\n\t}\n\n\tasync runCode(input: RunCodeInput): Promise<ExecOutput> {\n\t\tconst { data } = await this.#http.post(\n\t\t\t`/v1/sandbox/${encodeURIComponent(input.sandbox_id)}/run-code`,\n\t\t\t{\n\t\t\t\tcode: input.code,\n\t\t\t\t...(input.context_id && { context_id: input.context_id }),\n\t\t\t\t...(input.language && { language: input.language }),\n\t\t\t\t...(input.timeout_ms !== undefined && { timeout_ms: input.timeout_ms })\n\t\t\t},\n\t\t\t{ label: 'Cloudflare Sandbox runCode' }\n\t\t)\n\t\tconst parsed = parseRunCodePayload(data)\n\t\treturn {\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\tstdout: parsed.stdout,\n\t\t\tstderr: parsed.stderr,\n\t\t\texit_code: parsed.exit_code,\n\t\t\tsuccess: parsed.success,\n\t\t\t...(parsed.error && { error: parsed.error })\n\t\t}\n\t}\n\n\tasync writeFile(input: WriteFileInput): Promise<WriteFileOutput> {\n\t\tconst bytes = resolveWriteFileBytes(input)\n\t\tawait this.#putFileBytes(input.sandbox_id, input.path, bytes, input.session_id)\n\t\treturn {\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\tpath: input.path,\n\t\t\tok: true,\n\t\t\tbyte_length: bytes.byteLength\n\t\t}\n\t}\n\n\tasync readFile(input: ReadFileInput): Promise<ReadFileOutput> {\n\t\tconst bytes = await this.#getFileBytes(input.sandbox_id, input.path, input.session_id)\n\t\tconst encoding = input.encoding ?? 'utf8'\n\t\tconst out: ReadFileOutput = {\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\tpath: input.path,\n\t\t\tbyte_length: bytes.byteLength\n\t\t}\n\t\tif (encoding === 'base64') {\n\t\t\tout.body_base64 = bytesToBase64(bytes)\n\t\t} else {\n\t\t\tout.text = bytesToUtf8(bytes)\n\t\t}\n\t\treturn out\n\t}\n\n\tasync writeFiles(input: WriteFilesInput): Promise<WriteFilesOutput> {\n\t\tconst paths: string[] = []\n\t\tfor (const file of input.files) {\n\t\t\tawait this.writeFile({\n\t\t\t\tsandbox_id: input.sandbox_id,\n\t\t\t\tpath: file.path,\n\t\t\t\t...(file.text !== undefined && { text: file.text }),\n\t\t\t\t...(file.body_base64 !== undefined && { body_base64: file.body_base64 }),\n\t\t\t\t...(input.session_id && { session_id: input.session_id })\n\t\t\t})\n\t\t\tpaths.push(file.path)\n\t\t}\n\t\treturn { sandbox_id: input.sandbox_id, paths, ok: true }\n\t}\n\n\tasync readFiles(input: ReadFilesInput): Promise<ReadFilesOutput> {\n\t\tconst files: ReadFilesOutput['files'] = []\n\t\tfor (const path of input.paths) {\n\t\t\tconst row = await this.readFile({\n\t\t\t\tsandbox_id: input.sandbox_id,\n\t\t\t\tpath,\n\t\t\t\t...(input.encoding && { encoding: input.encoding }),\n\t\t\t\t...(input.session_id && { session_id: input.session_id })\n\t\t\t})\n\t\t\tfiles.push({\n\t\t\t\tpath: row.path,\n\t\t\t\t...(row.text !== undefined && { text: row.text }),\n\t\t\t\t...(row.body_base64 !== undefined && { body_base64: row.body_base64 }),\n\t\t\t\t...(row.byte_length !== undefined && { byte_length: row.byte_length })\n\t\t\t})\n\t\t}\n\t\treturn { sandbox_id: input.sandbox_id, files }\n\t}\n\n\t/** List files via find in the workspace (bridge has no list route). */\n\tasync listFiles(input: ListFilesInput): Promise<ListFilesOutput> {\n\t\tconst dir = input.directory_path?.trim() || '/workspace'\n\t\tconst abs = dir.startsWith('/') ? dir : workspaceAbsolutePath(dir)\n\t\tconst out = await this.exec({\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\targv: ['sh', '-lc', `find ${shellQuote(abs)} -maxdepth 4 -type f 2>/dev/null | head -n ${MAX_LIST_FILES}`],\n\t\t\t...(input.session_id && { session_id: input.session_id })\n\t\t})\n\t\tconst paths = out.stdout\n\t\t\t.split('\\n')\n\t\t\t.map((line) => line.trim())\n\t\t\t.filter((line) => line.length > 0)\n\t\treturn {\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\tpaths,\n\t\t\traw: { stdout: out.stdout, stderr: out.stderr, exit_code: out.exit_code }\n\t\t}\n\t}\n\n\t/** Remove files via rm (bridge has no delete-file route). */\n\tasync removeFiles(input: RemoveFilesInput): Promise<RemoveFilesOutput> {\n\t\tfor (const path of input.paths) {\n\t\t\tconst abs = path.startsWith('/') ? path : workspaceAbsolutePath(path)\n\t\t\tawait this.exec({\n\t\t\t\tsandbox_id: input.sandbox_id,\n\t\t\t\targv: ['rm', '-f', '--', abs],\n\t\t\t\t...(input.session_id && { session_id: input.session_id })\n\t\t\t})\n\t\t}\n\t\treturn { sandbox_id: input.sandbox_id, paths: input.paths, ok: true }\n\t}\n\n\t/**\n\t * Copy an object-store ArtifactRef into the sandbox workspace.\n\t * Requires auth.storage.\n\t */\n\tasync importArtifact(input: ImportArtifactInput): Promise<ImportArtifactOutput> {\n\t\tconst storage = this.#requireStorage('importArtifact')\n\t\tif (input.source.store !== 'object') {\n\t\t\tthrow new ToolError('Sandbox importArtifact only supports store=object ArtifactRefs', {\n\t\t\t\tcode: 'bad_input'\n\t\t\t})\n\t\t}\n\t\tconst bytes = await storage.getBytes(input.source.key, { maxBytes: MAX_FILE_BYTES })\n\t\tawait this.#putFileBytes(input.sandbox_id, input.path, bytes, input.session_id)\n\t\treturn {\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\tpath: input.path,\n\t\t\tok: true,\n\t\t\tbyte_length: bytes.byteLength\n\t\t}\n\t}\n\n\t/**\n\t * Copy a sandbox workspace file to object storage and return an ArtifactRef.\n\t * Requires auth.storage.\n\t */\n\tasync exportArtifact(input: ExportArtifactInput): Promise<ExportArtifactOutput> {\n\t\tconst storage = this.#requireStorage('exportArtifact')\n\t\tconst bytes = await this.#getFileBytes(input.sandbox_id, input.path, input.session_id)\n\t\tawait storage.putBytes(input.destination_key, bytes)\n\t\treturn {\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\tpath: input.path,\n\t\t\tartifact: {\n\t\t\t\tstore: 'object',\n\t\t\t\tkey: input.destination_key,\n\t\t\t\tbyte_length: bytes.byteLength\n\t\t\t}\n\t\t}\n\t}\n\n\tasync createSession(input: SandboxIdInput): Promise<CreateBridgeSessionOutput> {\n\t\tconst { data } = await this.#http.post(`/v1/sandbox/${encodeURIComponent(input.sandbox_id)}/session`, undefined, {\n\t\t\tlabel: 'Cloudflare Sandbox createSession'\n\t\t})\n\t\tif (!isPlainObject(data) || !isString(data['id'])) {\n\t\t\tthrow new ToolError('Unexpected create session response', { code: 'upstream' })\n\t\t}\n\t\treturn { sandbox_id: input.sandbox_id, session_id: data['id'] }\n\t}\n\n\tasync deleteSession(input: DeleteBridgeSessionInput): Promise<DeleteBridgeSessionOutput> {\n\t\tawait this.#http.delete(\n\t\t\t`/v1/sandbox/${encodeURIComponent(input.sandbox_id)}/session/${encodeURIComponent(input.session_id)}`,\n\t\t\t{ label: 'Cloudflare Sandbox deleteSession' }\n\t\t)\n\t\treturn { sandbox_id: input.sandbox_id, session_id: input.session_id, deleted: true }\n\t}\n\n\t/**\n\t * Mount an S3-compatible bucket (or Worker R2 binding) at an absolute path in the sandbox.\n\t * Bridge: `POST /v1/sandbox/:id/mount`.\n\t * For Mastra / host workspace S3 FS: pass `endpoint` + credentials (or rely on auth.storage).\n\t * @see https://developers.cloudflare.com/sandbox/bridge/http-api/#bucket-mounts\n\t */\n\tasync mount(input: MountBucketInput): Promise<MountBucketOutput> {\n\t\tconst parsed = mountBucketInputSchema.safeParse(input)\n\t\tif (!parsed.success) {\n\t\t\tthrow new ToolError('Invalid sandbox mount input', {\n\t\t\t\tcode: 'bad_input',\n\t\t\t\tdetails: { issues: parsed.error.issues.map((issue) => issue.message) }\n\t\t\t})\n\t\t}\n\t\tconst data = parsed.data\n\t\tif (data.local_bucket && data.endpoint) {\n\t\t\tthrow new ToolError('local_bucket and endpoint are mutually exclusive on mount', { code: 'bad_input' })\n\t\t}\n\t\tif (data.prefix !== undefined && !data.prefix.startsWith('/')) {\n\t\t\tthrow new ToolError('mount prefix must start with /', { code: 'bad_input' })\n\t\t}\n\n\t\t// Endpoint mounts only: omit endpoint for Worker R2 binding mounts.\n\t\tconst endpoint = data.local_bucket ? undefined : data.endpoint\n\t\t// Credentials: explicit input, else auth.storage when doing an endpoint mount (Mastra S3 FS).\n\t\tconst accessKeyId = data.access_key_id ?? (endpoint !== undefined ? this.#storageAuth?.access_key_id : undefined)\n\t\tconst secretAccessKey =\n\t\t\tdata.secret_access_key ?? (endpoint !== undefined ? this.#storageAuth?.secret_access_key : undefined)\n\n\t\tconst options: Record<string, unknown> = {}\n\t\tif (endpoint) options['endpoint'] = endpoint\n\t\tif (data.provider) options['provider'] = data.provider\n\t\tif (data.read_only !== undefined) options['readOnly'] = data.read_only\n\t\tif (data.prefix) options['prefix'] = data.prefix\n\t\tif (data.credential_proxy !== undefined) options['credentialProxy'] = data.credential_proxy\n\t\tif (data.local_bucket) options['localBucket'] = true\n\t\tif (data.s3fs_options && data.s3fs_options.length > 0) options['s3fsOptions'] = data.s3fs_options\n\t\tif (endpoint && accessKeyId && secretAccessKey) {\n\t\t\toptions['credentials'] = {\n\t\t\t\taccessKeyId,\n\t\t\t\tsecretAccessKey\n\t\t\t}\n\t\t}\n\n\t\tconst body: Record<string, unknown> = {\n\t\t\tmountPath: data.mount_path,\n\t\t\toptions\n\t\t}\n\t\tif (endpoint) body['bucket'] = data.bucket\n\t\telse body['binding'] = data.bucket\n\n\t\tawait this.#http.post(`/v1/sandbox/${encodeURIComponent(data.sandbox_id)}/mount`, body, {\n\t\t\tlabel: 'Cloudflare Sandbox mount'\n\t\t})\n\t\treturn {\n\t\t\tsandbox_id: data.sandbox_id,\n\t\t\tbucket: data.bucket,\n\t\t\tmount_path: data.mount_path,\n\t\t\tok: true\n\t\t}\n\t}\n\n\t/**\n\t * Unmount a previously mounted bucket path.\n\t * Bridge: `POST /v1/sandbox/:id/unmount` with `{ mountPath }`.\n\t * Mounts are also cleared when the sandbox is destroyed.\n\t */\n\tasync unmount(input: UnmountBucketInput): Promise<UnmountBucketOutput> {\n\t\tconst parsed = unmountBucketInputSchema.safeParse(input)\n\t\tif (!parsed.success) {\n\t\t\tthrow new ToolError('Invalid sandbox unmount input', {\n\t\t\t\tcode: 'bad_input',\n\t\t\t\tdetails: { issues: parsed.error.issues.map((issue) => issue.message) }\n\t\t\t})\n\t\t}\n\t\tconst data = parsed.data\n\t\tawait this.#http.post(\n\t\t\t`/v1/sandbox/${encodeURIComponent(data.sandbox_id)}/unmount`,\n\t\t\t{ mountPath: data.mount_path },\n\t\t\t{ label: 'Cloudflare Sandbox unmount' }\n\t\t)\n\t\treturn {\n\t\t\tsandbox_id: data.sandbox_id,\n\t\t\tmount_path: data.mount_path,\n\t\t\tok: true\n\t\t}\n\t}\n\n\tasync #ensureCodeContext(sandboxId: string, language: InterpreterLanguage): Promise<string> {\n\t\tconst key = `${sandboxId}:${language}`\n\t\tconst cached = this.#contexts.get(key)\n\t\tif (cached) return cached\n\t\tconst pending = this.#pendingContexts.get(key)\n\t\tif (pending) return pending\n\t\tconst created = this.createCodeContext({ sandbox_id: sandboxId, language })\n\t\t\t.then((row) => {\n\t\t\t\tthis.#contexts.set(key, row.context_id)\n\t\t\t\treturn row.context_id\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tthis.#pendingContexts.delete(key)\n\t\t\t})\n\t\tthis.#pendingContexts.set(key, created)\n\t\treturn created\n\t}\n\n\t#forgetSandboxContexts(sandboxId: string): void {\n\t\tconst prefix = `${sandboxId}:`\n\t\tfor (const key of this.#contexts.keys()) {\n\t\t\tif (key.startsWith(prefix)) this.#contexts.delete(key)\n\t\t}\n\t\tfor (const key of this.#pendingContexts.keys()) {\n\t\t\tif (key.startsWith(prefix)) this.#pendingContexts.delete(key)\n\t\t}\n\t}\n\n\t#requireStorage(op: string): S3Client {\n\t\tif (!this.#storage) {\n\t\t\tthrow new ToolError(`${op} requires storage credentials on sandbox auth`, {\n\t\t\t\tcode: 'bad_auth'\n\t\t\t})\n\t\t}\n\t\treturn this.#storage\n\t}\n\n\tasync #putFileBytes(\n\t\tsandboxId: string,\n\t\tpath: string,\n\t\tbytes: Uint8Array,\n\t\tsessionId: string | undefined\n\t): Promise<void> {\n\t\tconst key = workspaceFileKey(path)\n\t\tconst headers: Record<string, string> = {\n\t\t\t'Content-Type': 'application/octet-stream'\n\t\t}\n\t\tif (sessionId) headers['Session-Id'] = sessionId\n\t\tconst { data } = await this.#http.put(\n\t\t\t`/v1/sandbox/${encodeURIComponent(sandboxId)}/file/${key.split('/').map(encodeURIComponent).join('/')}`,\n\t\t\ttoArrayBuffer(bytes),\n\t\t\t{ headers, label: 'Cloudflare Sandbox writeFile' }\n\t\t)\n\t\tif (isPlainObject(data) && data['ok'] === false) {\n\t\t\tthrow new ToolError('Sandbox writeFile failed', { code: 'upstream' })\n\t\t}\n\t}\n\n\tasync #getFileBytes(sandboxId: string, path: string, sessionId: string | undefined): Promise<Uint8Array> {\n\t\tconst key = workspaceFileKey(path)\n\t\tconst headers: Record<string, string> = {}\n\t\tif (sessionId) headers['Session-Id'] = sessionId\n\t\tconst { bytes } = await this.#http.bytes(\n\t\t\t'GET',\n\t\t\t`/v1/sandbox/${encodeURIComponent(sandboxId)}/file/${key.split('/').map(encodeURIComponent).join('/')}`,\n\t\t\t{ headers, label: 'Cloudflare Sandbox readFile', maxBytes: MAX_FILE_BYTES }\n\t\t)\n\t\treturn bytes\n\t}\n}\n","import { z } from 'zod'\n\nimport { defineModule, defineTool } from '../../core/define'\nimport { CloudflareSandboxClient } from './client'\nimport {\n\tcloudflareSandboxAuthSchema,\n\tcreateBridgeSessionOutputSchema,\n\tcreateSandboxOutputSchema,\n\tdeleteBridgeSessionInputSchema,\n\tdeleteBridgeSessionOutputSchema,\n\tdestroySandboxOutputSchema,\n\texecInputSchema,\n\texecOutputSchema,\n\texecuteCodeInputSchema,\n\texportArtifactInputSchema,\n\texportArtifactOutputSchema,\n\thealthOutputSchema,\n\timportArtifactInputSchema,\n\timportArtifactOutputSchema,\n\tlistFilesInputSchema,\n\tlistFilesOutputSchema,\n\treadFileInputSchema,\n\treadFileOutputSchema,\n\treadFilesInputSchema,\n\treadFilesOutputSchema,\n\tremoveFilesInputSchema,\n\tremoveFilesOutputSchema,\n\trunningOutputSchema,\n\tsandboxIdInputSchema,\n\twriteFileInputSchema,\n\twriteFileOutputSchema,\n\twriteFilesInputSchema,\n\twriteFilesOutputSchema\n} from './contracts'\n\nconst id = 'cloudflare-sandbox'\nconst emptyInputSchema = z.object({})\n\nexport const cloudflareSandboxHealthTool = defineTool({\n\tid: `${id}-health`,\n\tname: 'cloudflareSandboxHealth',\n\tdescription:\n\t\t'Check whether the Cloudflare Sandbox bridge is reachable. Use only for explicit availability diagnostics; ordinary sandbox work should begin with cloudflare-sandbox-create.',\n\tinputSchema: emptyInputSchema,\n\toutputSchema: healthOutputSchema,\n\tsideEffect: 'read',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (_input, ctx) => CloudflareSandboxClient.fromContext(ctx).health()\n})\n\nexport const cloudflareSandboxCreateTool = defineTool({\n\tid: `${id}-create`,\n\tname: 'cloudflareSandboxCreate',\n\tdescription:\n\t\t'Create an isolated Cloudflare sandbox and return sandbox_id. Use only when arbitrary code, commands, or temporary files are required and no purpose-built tool covers the task. Do not create a sandbox to build or edit supported deliverables.',\n\tinputSchema: emptyInputSchema,\n\toutputSchema: createSandboxOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (_input, ctx) => CloudflareSandboxClient.fromContext(ctx).create()\n})\n\nexport const cloudflareSandboxDestroyTool = defineTool({\n\tid: `${id}-destroy`,\n\tname: 'cloudflareSandboxDestroy',\n\tdescription:\n\t\t'Destroy a Cloudflare sandbox by sandbox_id and release its temporary files and resources. Call after the sandbox workflow is complete and any required output file has been exported.',\n\tinputSchema: sandboxIdInputSchema,\n\toutputSchema: destroySandboxOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).destroy(input)\n})\n\nexport const cloudflareSandboxRunningTool = defineTool({\n\tid: `${id}-running`,\n\tname: 'cloudflareSandboxRunning',\n\tdescription:\n\t\t'Check whether a Cloudflare sandbox is currently running. Use before continuing work on an existing sandbox_id; this does not execute code or inspect files.',\n\tinputSchema: sandboxIdInputSchema,\n\toutputSchema: runningOutputSchema,\n\tsideEffect: 'read',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).running(input)\n})\n\nexport const cloudflareSandboxExecTool = defineTool({\n\tid: `${id}-exec`,\n\tname: 'cloudflareSandboxExec',\n\tdescription:\n\t\t'One-shot argv exec in a Cloudflare sandbox (stdout/stderr/exit_code). Prefer a host workspace agent for multi-step shell; use tools for workflow one-shots. Optional env when the bridge supports it.',\n\tinputSchema: execInputSchema,\n\toutputSchema: execOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\ttags: ['exec', 'one-shot', 'compute'],\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).exec(input)\n})\n\nexport const cloudflareSandboxExecuteCodeTool = defineTool({\n\tid: `${id}-execute-code`,\n\tname: 'cloudflareSandboxExecuteCode',\n\tdescription:\n\t\t'Execute Python, JavaScript, or TypeScript in a Cloudflare sandbox interpreter context. Imports and variables stay loaded on later calls. Use exec for shell. Use as a fallback for computation or automation with no dedicated tool. Do not generate or edit supported documents, spreadsheets, presentations, PDFs, or images here when a purpose-built tool is available.',\n\tinputSchema: executeCodeInputSchema,\n\toutputSchema: execOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).executeCode(input)\n})\n\nexport const cloudflareSandboxWriteFileTool = defineTool({\n\tid: `${id}-write-file`,\n\tname: 'cloudflareSandboxWriteFile',\n\tdescription:\n\t\t'Write one temporary file under the Cloudflare sandbox workspace from UTF-8 text or base64 bytes, up to 32 MiB decoded. Use for sandbox intermediates. This is not durable delivery; export a genuinely sandbox-produced final file with cloudflare-sandbox-export-artifact.',\n\tinputSchema: writeFileInputSchema,\n\toutputSchema: writeFileOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).writeFile(input)\n})\n\nexport const cloudflareSandboxReadFileTool = defineTool({\n\tid: `${id}-read-file`,\n\tname: 'cloudflareSandboxReadFile',\n\tdescription:\n\t\t'Read one temporary file from the Cloudflare sandbox workspace as UTF-8 or base64. Use for sandbox intermediates; use format-aware readers for supported ArtifactRefs.',\n\tinputSchema: readFileInputSchema,\n\toutputSchema: readFileOutputSchema,\n\tsideEffect: 'read',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).readFile(input)\n})\n\nexport const cloudflareSandboxWriteFilesTool = defineTool({\n\tid: `${id}-write-files`,\n\tname: 'cloudflareSandboxWriteFiles',\n\tdescription:\n\t\t'Write multiple temporary files under the Cloudflare sandbox workspace from text or base64. Use for sandbox intermediates, not final document generation. Export only a final file that the sandbox genuinely had to produce.',\n\tinputSchema: writeFilesInputSchema,\n\toutputSchema: writeFilesOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).writeFiles(input)\n})\n\nexport const cloudflareSandboxReadFilesTool = defineTool({\n\tid: `${id}-read-files`,\n\tname: 'cloudflareSandboxReadFiles',\n\tdescription:\n\t\t'Read multiple temporary files from the Cloudflare sandbox workspace as UTF-8 or base64. Use only within an active sandbox workflow; use format-aware readers for supported ArtifactRefs.',\n\tinputSchema: readFilesInputSchema,\n\toutputSchema: readFilesOutputSchema,\n\tsideEffect: 'read',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).readFiles(input)\n})\n\nexport const cloudflareSandboxListFilesTool = defineTool({\n\tid: `${id}-list-files`,\n\tname: 'cloudflareSandboxListFiles',\n\tdescription:\n\t\t'List temporary files under a Cloudflare sandbox directory, defaulting to /workspace. Use to locate sandbox intermediates, not durable workspace files or ArtifactRefs.',\n\tinputSchema: listFilesInputSchema,\n\toutputSchema: listFilesOutputSchema,\n\tsideEffect: 'read',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).listFiles(input)\n})\n\nexport const cloudflareSandboxRemoveFilesTool = defineTool({\n\tid: `${id}-remove-files`,\n\tname: 'cloudflareSandboxRemoveFiles',\n\tdescription:\n\t\t'Remove temporary files from the Cloudflare sandbox workspace by path. Use only for sandbox cleanup; this does not delete durable workspace files or ArtifactRefs.',\n\tinputSchema: removeFilesInputSchema,\n\toutputSchema: removeFilesOutputSchema,\n\tsideEffect: 'delete',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).removeFiles(input)\n})\n\nexport const cloudflareSandboxImportArtifactTool = defineTool({\n\tid: `${id}-import-artifact`,\n\tname: 'cloudflareSandboxImportArtifact',\n\tdescription:\n\t\t'Copy an existing object-store ArtifactRef into a Cloudflare sandbox workspace. Use only when arbitrary sandbox computation must consume that file. Do not import a supported document merely to read or edit it with general code.',\n\tinputSchema: importArtifactInputSchema,\n\toutputSchema: importArtifactOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).importArtifact(input)\n})\n\nexport const cloudflareSandboxExportArtifactTool = defineTool({\n\tid: `${id}-export-artifact`,\n\tname: 'cloudflareSandboxExportArtifact',\n\tdescription:\n\t\t'Persist a final file that was genuinely created inside the Cloudflare sandbox and return its ArtifactRef for delivery. Use only after sandbox work. Do not call for files returned by document, presentation, PDF, image, render, or conversion tools; those ArtifactRefs are already final.',\n\tinputSchema: exportArtifactInputSchema,\n\toutputSchema: exportArtifactOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).exportArtifact(input)\n})\n\nexport const cloudflareSandboxCreateSessionTool = defineTool({\n\tid: `${id}-create-session`,\n\tname: 'cloudflareSandboxCreateSession',\n\tdescription:\n\t\t'Create an isolated execution session inside an existing Cloudflare sandbox and return session_id. Use only when separate working directories or runtime state are needed; pass the id to later command and file calls.',\n\tinputSchema: sandboxIdInputSchema,\n\toutputSchema: createBridgeSessionOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).createSession(input)\n})\n\nexport const cloudflareSandboxDeleteSessionTool = defineTool({\n\tid: `${id}-delete-session`,\n\tname: 'cloudflareSandboxDeleteSession',\n\tdescription:\n\t\t'Delete an isolated execution session inside a Cloudflare sandbox. Use after session-specific work is complete; this does not destroy the parent sandbox.',\n\tinputSchema: deleteBridgeSessionInputSchema,\n\toutputSchema: deleteBridgeSessionOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).deleteSession(input)\n})\n\nexport const cloudflareSandboxModule = defineModule({\n\tid,\n\ttitle: 'Cloudflare Sandbox',\n\tdescription:\n\t\t'Cloudflare sandbox bridge: one-shot exec/files/sessions for workflows. Prefer a host workspace agent for multi-step shell. Client export remains first-class for Workspace hybrids. Prefer purpose-built document tools over sandbox for office formats.',\n\truntime: 'both',\n\tauth: { type: 'custom', schema: cloudflareSandboxAuthSchema },\n\tcategories: ['compute', 'sandbox', 'cloudflare'],\n\tclassification: 'standard',\n\ttags: ['exec', 'workspace', 'bridge'],\n\ttools: [\n\t\tcloudflareSandboxHealthTool,\n\t\tcloudflareSandboxCreateTool,\n\t\tcloudflareSandboxDestroyTool,\n\t\tcloudflareSandboxRunningTool,\n\t\tcloudflareSandboxExecTool,\n\t\tcloudflareSandboxExecuteCodeTool,\n\t\tcloudflareSandboxWriteFileTool,\n\t\tcloudflareSandboxReadFileTool,\n\t\tcloudflareSandboxWriteFilesTool,\n\t\tcloudflareSandboxReadFilesTool,\n\t\tcloudflareSandboxListFilesTool,\n\t\tcloudflareSandboxRemoveFilesTool,\n\t\tcloudflareSandboxImportArtifactTool,\n\t\tcloudflareSandboxExportArtifactTool,\n\t\tcloudflareSandboxCreateSessionTool,\n\t\tcloudflareSandboxDeleteSessionTool\n\t]\n})\n"],"mappings":";;;;;;;;;;;;;;AAUA,MAAa,WAAW;AACxB,MAAa,gBAAgB;AAC7B,MAAa,gBAAgB;AAC7B,MAAa,gBAAgB;;AAE7B,MAAa,iBAAiB,KAAK,OAAO;AAC1C,MAAa,kBAAkB;AAC/B,MAAa,iBAAiB;AAC9B,MAAa,iBAAiB;AAC9B,MAAa,0BAA0B;AACvC,MAAa,sBAAsB;AAEnC,MAAa,8BAA8B,EAAE,OAAO;CACnD,UAAU,EACR,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,SAAS,sFAAsF;CACjG,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,qCAAqC;CACzE,SAAS,aACP,SAAS,CAAC,CACV,SAAS,kFAAkF;AAC9F,CAAC;;AAKD,MAAa,iCAAiC,EAAE,OAAO;CACtD,OAAO,EAAE,QAAQ,QAAQ,CAAC,CAAC,SAAS,sCAAsC;CAC1E,KAAK,EAAE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AAS;CACT,SAAS;CACT,SAAS,OAAO,OAAO,QAAQ,wBAAwB,YAAY,GAAG,CAAC,CAAC,cAAc,KAAK;AAC5F,CAAC;AAED,MAAa,qCAAqC,WAAW;CAC5D,IAAI,GAAG,GAAG;CACV,MAAM;CACN,aACC;CACD,aAAa;CACb,cAAc;CACd,YAAY;CACZ,SAAS;CACT,SAAS;CACT,SAAS,OAAO,OAAO,QAAQ,wBAAwB,YAAY,GAAG,CAAC,CAAC,cAAc,KAAK;AAC5F,CAAC;AAED,MAAa,0BAA0B,aAAa;CACnD;CACA,OAAO;CACP,aACC;CACD,SAAS;CACT,MAAM;EAAE,MAAM;EAAU,QAAQ;CAA4B;CAC5D,YAAY;EAAC;EAAW;EAAW;CAAY;CAC/C,gBAAgB;CAChB,MAAM;EAAC;EAAQ;EAAa;CAAQ;CACpC,OAAO;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;AACD,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { t as ToolError } from "../../errors-DoSpNHvs.js";
|
|
1
2
|
import { n as defineModule, r as defineTool } from "../../define-ieoksEQ0.js";
|
|
2
3
|
import { n as requireAuth } from "../../provider-CgDAlg6K.js";
|
|
3
4
|
import { _ as MAX_COMMAND_CHARS, g as MAX_CODE_CHARS, m as BedrockAgentCoreCodeInterpreterClient, x as bedrockAgentCoreCodeInterpreterAuthSchema, y as MAX_FILE_TEXT } from "../../bedrock-agentcore-code-interpreter-F0dnrAm4.js";
|
|
4
|
-
import { F as cloudflareSandboxAuthSchema, v as CloudflareSandboxClient } from "../../cloudflare-sandbox-
|
|
5
|
+
import { F as cloudflareSandboxAuthSchema, v as CloudflareSandboxClient } from "../../cloudflare-sandbox-D3rAu9bN.js";
|
|
5
6
|
import { isPlainObject, isString } from "es-toolkit";
|
|
6
7
|
import { z } from "zod";
|
|
7
8
|
//#region src/modules/code-sandbox/contracts.ts
|
|
@@ -348,9 +349,17 @@ function mapExec(session_id, out) {
|
|
|
348
349
|
}
|
|
349
350
|
function normalizeLanguage(language) {
|
|
350
351
|
const raw = (language ?? "python").toLowerCase();
|
|
351
|
-
if (
|
|
352
|
-
|
|
353
|
-
|
|
352
|
+
if ([
|
|
353
|
+
"js",
|
|
354
|
+
"javascript",
|
|
355
|
+
"node"
|
|
356
|
+
].includes(raw)) return "javascript";
|
|
357
|
+
if (["ts", "typescript"].includes(raw)) return "typescript";
|
|
358
|
+
if ([
|
|
359
|
+
"sh",
|
|
360
|
+
"bash",
|
|
361
|
+
"shell"
|
|
362
|
+
].includes(raw)) throw new ToolError("Use executeCommand for shell", { code: "bad_input" });
|
|
354
363
|
return "python";
|
|
355
364
|
}
|
|
356
365
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["#client","#client","#ops"],"sources":["../../../src/modules/code-sandbox/contracts.ts","../../../src/modules/code-sandbox/providers/bedrock-agentcore.ts","../../../src/modules/code-sandbox/providers/cloudflare-sandbox.ts","../../../src/modules/code-sandbox/client.ts","../../../src/modules/code-sandbox/module.ts"],"sourcesContent":["/**\n * Code sandbox capability seam — execute code and commands in an isolated sandbox.\n * Providers: cloudflare-sandbox (bridge), bedrock-agentcore.\n */\n\nimport { z } from 'zod'\n\nimport {\n\tbedrockAgentCoreCodeInterpreterAuthSchema,\n\tMAX_CODE_CHARS,\n\tMAX_COMMAND_CHARS,\n\tMAX_FILE_PATHS,\n\tMAX_FILE_TEXT,\n\tMAX_WRITE_FILES\n} from '../../vendors/bedrock-agentcore-code-interpreter'\nimport { cloudflareSandboxAuthSchema } from '../../vendors/cloudflare-sandbox'\n\nexport const MAX_SEAM_CODE_CHARS = MAX_CODE_CHARS\nexport const MAX_SEAM_COMMAND_CHARS = MAX_COMMAND_CHARS\n\n/** Bridge host credentials; provider id matches email/browser gold (`cloudflare`). */\nexport const cloudflareCodeSandboxAuthSchema = cloudflareSandboxAuthSchema.extend({\n\tprovider: z.literal('cloudflare')\n})\n\nexport const agentCoreCodeSandboxAuthSchema = bedrockAgentCoreCodeInterpreterAuthSchema.extend({\n\tprovider: z.literal('bedrock-agentcore')\n})\n\nexport const codeSandboxAuthSchema = z.discriminatedUnion('provider', [\n\tcloudflareCodeSandboxAuthSchema,\n\tagentCoreCodeSandboxAuthSchema\n])\n\nexport type CloudflareCodeSandboxAuth = z.infer<typeof cloudflareCodeSandboxAuthSchema>\nexport type AgentCoreCodeSandboxAuth = z.infer<typeof agentCoreCodeSandboxAuthSchema>\nexport type CodeSandboxAuth = z.infer<typeof codeSandboxAuthSchema>\n\nconst sessionId = z.string().min(1).max(200).describe('Sandbox session id from start-session')\n\nexport const codeSandboxStartSessionInputSchema = z.object({\n\tname: z.string().min(1).max(100).optional().describe('Optional session name when the bound provider supports it'),\n\tsession_timeout_seconds: z\n\t\t.int()\n\t\t.min(1)\n\t\t.max(28_800)\n\t\t.optional()\n\t\t.describe('Session TTL in seconds when the bound provider supports it')\n})\n\nexport const codeSandboxSessionIdInputSchema = z.object({\n\tsession_id: sessionId\n})\n\nexport const codeSandboxSessionOutputSchema = z.object({\n\tsession_id: z.string().describe('Sandbox session id'),\n\tstatus: z.string().optional().describe('Provider session status when available'),\n\trunning: z.boolean().optional().describe('Whether the sandbox is running when reported')\n})\n\nexport const codeSandboxExecuteCodeInputSchema = z.object({\n\tsession_id: sessionId,\n\tcode: z.string().min(1).max(MAX_SEAM_CODE_CHARS).describe('Source code to execute'),\n\tlanguage: z.string().min(1).max(40).optional().describe('Language when supported (default python)')\n})\n\nexport const codeSandboxExecuteCommandInputSchema = z.object({\n\tsession_id: sessionId,\n\tcommand: z.string().min(1).max(MAX_SEAM_COMMAND_CHARS).describe('Shell command to run')\n})\n\nexport const codeSandboxExecResultSchema = z.object({\n\tsession_id: z.string(),\n\tstdout: z.string().optional().describe('Standard output when available'),\n\tstderr: z.string().optional().describe('Standard error when available'),\n\texit_code: z.number().int().optional().describe('Process exit code when available'),\n\tsuccess: z.boolean().optional().describe('True when the run completed successfully'),\n\tresult: z.unknown().optional().describe('Provider-specific result payload when structured')\n})\n\nexport const codeSandboxWriteFilesInputSchema = z.object({\n\tsession_id: sessionId,\n\tfiles: z\n\t\t.array(\n\t\t\tz.object({\n\t\t\t\tpath: z.string().min(1).max(1024).describe('Path to write'),\n\t\t\t\ttext: z.string().max(MAX_FILE_TEXT).describe('Utf8 file contents')\n\t\t\t})\n\t\t)\n\t\t.min(1)\n\t\t.max(MAX_WRITE_FILES)\n\t\t.describe('Files to write in the sandbox')\n})\n\nexport const codeSandboxWriteFilesOutputSchema = z.object({\n\tsession_id: z.string(),\n\tpaths: z.array(z.string()),\n\tok: z.literal(true)\n})\n\nexport const codeSandboxReadFilesInputSchema = z.object({\n\tsession_id: sessionId,\n\tpaths: z.array(z.string().min(1).max(1024)).min(1).max(MAX_FILE_PATHS).describe('Paths to read')\n})\n\nexport const codeSandboxReadFilesOutputSchema = z.object({\n\tsession_id: z.string(),\n\tfiles: z.array(\n\t\tz.object({\n\t\t\tpath: z.string(),\n\t\t\ttext: z.string()\n\t\t})\n\t)\n})\n\nexport const codeSandboxListFilesInputSchema = z.object({\n\tsession_id: sessionId,\n\tdirectory_path: z.string().max(1024).optional().describe('Directory to list (default sandbox root)')\n})\n\nexport const codeSandboxListFilesOutputSchema = z.object({\n\tsession_id: z.string(),\n\tpaths: z.array(z.string()).describe('Relative paths found'),\n\traw: z.unknown().optional().describe('Provider listing payload when available')\n})\n\nexport const codeSandboxRemoveFilesInputSchema = z.object({\n\tsession_id: sessionId,\n\tpaths: z.array(z.string().min(1).max(1024)).min(1).max(MAX_FILE_PATHS).describe('Paths to remove')\n})\n\nexport const codeSandboxRemoveFilesOutputSchema = z.object({\n\tsession_id: z.string(),\n\tpaths: z.array(z.string()),\n\tok: z.literal(true)\n})\n\nexport type CodeSandboxStartSessionInput = z.infer<typeof codeSandboxStartSessionInputSchema>\nexport type CodeSandboxSessionIdInput = z.infer<typeof codeSandboxSessionIdInputSchema>\nexport type CodeSandboxSessionOutput = z.infer<typeof codeSandboxSessionOutputSchema>\nexport type CodeSandboxExecuteCodeInput = z.infer<typeof codeSandboxExecuteCodeInputSchema>\nexport type CodeSandboxExecuteCommandInput = z.infer<typeof codeSandboxExecuteCommandInputSchema>\nexport type CodeSandboxExecResult = z.infer<typeof codeSandboxExecResultSchema>\nexport type CodeSandboxWriteFilesInput = z.infer<typeof codeSandboxWriteFilesInputSchema>\nexport type CodeSandboxWriteFilesOutput = z.infer<typeof codeSandboxWriteFilesOutputSchema>\nexport type CodeSandboxReadFilesInput = z.infer<typeof codeSandboxReadFilesInputSchema>\nexport type CodeSandboxReadFilesOutput = z.infer<typeof codeSandboxReadFilesOutputSchema>\nexport type CodeSandboxListFilesInput = z.infer<typeof codeSandboxListFilesInputSchema>\nexport type CodeSandboxListFilesOutput = z.infer<typeof codeSandboxListFilesOutputSchema>\nexport type CodeSandboxRemoveFilesInput = z.infer<typeof codeSandboxRemoveFilesInputSchema>\nexport type CodeSandboxRemoveFilesOutput = z.infer<typeof codeSandboxRemoveFilesOutputSchema>\n\nexport type CodeSandboxOps = {\n\tstartSession(input?: CodeSandboxStartSessionInput): Promise<CodeSandboxSessionOutput>\n\tgetSession(input: CodeSandboxSessionIdInput): Promise<CodeSandboxSessionOutput>\n\tstopSession(input: CodeSandboxSessionIdInput): Promise<CodeSandboxSessionOutput>\n\texecuteCode(input: CodeSandboxExecuteCodeInput): Promise<CodeSandboxExecResult>\n\texecuteCommand(input: CodeSandboxExecuteCommandInput): Promise<CodeSandboxExecResult>\n\twriteFiles(input: CodeSandboxWriteFilesInput): Promise<CodeSandboxWriteFilesOutput>\n\treadFiles(input: CodeSandboxReadFilesInput): Promise<CodeSandboxReadFilesOutput>\n\tlistFiles(input: CodeSandboxListFilesInput): Promise<CodeSandboxListFilesOutput>\n\tremoveFiles(input: CodeSandboxRemoveFilesInput): Promise<CodeSandboxRemoveFilesOutput>\n}\n","import { isPlainObject, isString } from 'es-toolkit'\n\nimport type { HttpServiceOptions } from '../../../transport/http-service'\nimport { BedrockAgentCoreCodeInterpreterClient } from '../../../vendors/bedrock-agentcore-code-interpreter'\nimport type {\n\tAgentCoreCodeSandboxAuth,\n\tCodeSandboxExecResult,\n\tCodeSandboxExecuteCodeInput,\n\tCodeSandboxExecuteCommandInput,\n\tCodeSandboxListFilesInput,\n\tCodeSandboxListFilesOutput,\n\tCodeSandboxOps,\n\tCodeSandboxReadFilesInput,\n\tCodeSandboxReadFilesOutput,\n\tCodeSandboxRemoveFilesInput,\n\tCodeSandboxSessionIdInput,\n\tCodeSandboxSessionOutput,\n\tCodeSandboxStartSessionInput,\n\tCodeSandboxWriteFilesInput\n} from '../contracts'\n\nexport type AgentCoreCodeSandboxProviderOptions = Pick<HttpServiceOptions, 'fetch' | 'signal'>\n\nexport class AgentCoreCodeSandboxProvider implements CodeSandboxOps {\n\treadonly #client: BedrockAgentCoreCodeInterpreterClient\n\n\tconstructor(auth: AgentCoreCodeSandboxAuth, options: AgentCoreCodeSandboxProviderOptions = {}) {\n\t\tconst { provider: _provider, ...vendorAuth } = auth\n\t\tthis.#client = new BedrockAgentCoreCodeInterpreterClient(vendorAuth, options)\n\t}\n\n\tasync startSession(input: CodeSandboxStartSessionInput = {}): Promise<CodeSandboxSessionOutput> {\n\t\tconst out = await this.#client.startSession({\n\t\t\t...(input.name && { name: input.name }),\n\t\t\t...(input.session_timeout_seconds !== undefined && {\n\t\t\t\tsession_timeout_seconds: input.session_timeout_seconds\n\t\t\t})\n\t\t})\n\t\treturn {\n\t\t\tsession_id: out.session_id,\n\t\t\t...(out.status && { status: out.status }),\n\t\t\trunning: true\n\t\t}\n\t}\n\n\tasync getSession(input: CodeSandboxSessionIdInput): Promise<CodeSandboxSessionOutput> {\n\t\tconst out = await this.#client.getSession({ session_id: input.session_id })\n\t\treturn {\n\t\t\tsession_id: out.session_id,\n\t\t\t...(out.status && { status: out.status }),\n\t\t\trunning: out.status ? out.status.toUpperCase() !== 'TERMINATED' : true\n\t\t}\n\t}\n\n\tasync stopSession(input: CodeSandboxSessionIdInput): Promise<CodeSandboxSessionOutput> {\n\t\tconst out = await this.#client.stopSession({ session_id: input.session_id })\n\t\treturn {\n\t\t\tsession_id: out.session_id,\n\t\t\t...(out.status && { status: out.status }),\n\t\t\trunning: false\n\t\t}\n\t}\n\n\tasync executeCode(input: CodeSandboxExecuteCodeInput): Promise<CodeSandboxExecResult> {\n\t\tconst out = await this.#client.executeCode({\n\t\t\tsession_id: input.session_id,\n\t\t\tcode: input.code,\n\t\t\t...(input.language && { language: input.language })\n\t\t})\n\t\treturn mapInvoke(input.session_id, out.result, out.raw)\n\t}\n\n\tasync executeCommand(input: CodeSandboxExecuteCommandInput): Promise<CodeSandboxExecResult> {\n\t\tconst out = await this.#client.executeCommand({\n\t\t\tsession_id: input.session_id,\n\t\t\tcommand: input.command\n\t\t})\n\t\treturn mapInvoke(input.session_id, out.result, out.raw)\n\t}\n\n\tasync writeFiles(input: CodeSandboxWriteFilesInput) {\n\t\tawait this.#client.writeFiles({\n\t\t\tsession_id: input.session_id,\n\t\t\tfiles: input.files\n\t\t})\n\t\treturn {\n\t\t\tsession_id: input.session_id,\n\t\t\tpaths: input.files.map((f) => f.path),\n\t\t\tok: true as const\n\t\t}\n\t}\n\n\tasync readFiles(input: CodeSandboxReadFilesInput): Promise<CodeSandboxReadFilesOutput> {\n\t\tconst out = await this.#client.readFiles({\n\t\t\tsession_id: input.session_id,\n\t\t\tpaths: input.paths\n\t\t})\n\t\tconst files = extractFiles(out.result ?? out.raw, input.paths)\n\t\treturn { session_id: input.session_id, files }\n\t}\n\n\tasync listFiles(input: CodeSandboxListFilesInput): Promise<CodeSandboxListFilesOutput> {\n\t\tconst out = await this.#client.listFiles({\n\t\t\tsession_id: input.session_id,\n\t\t\t...(input.directory_path !== undefined && { directory_path: input.directory_path })\n\t\t})\n\t\tconst paths = extractPaths(out.result ?? out.raw)\n\t\treturn { session_id: input.session_id, paths, raw: out.result ?? out.raw }\n\t}\n\n\tasync removeFiles(input: CodeSandboxRemoveFilesInput) {\n\t\tawait this.#client.removeFiles({\n\t\t\tsession_id: input.session_id,\n\t\t\tpaths: input.paths\n\t\t})\n\t\treturn { session_id: input.session_id, paths: input.paths, ok: true as const }\n\t}\n}\n\nfunction mapInvoke(session_id: string, result: unknown, raw: unknown): CodeSandboxExecResult {\n\tconst out: CodeSandboxExecResult = { session_id, result: result ?? raw, success: true }\n\tif (isPlainObject(result)) {\n\t\tif (isString(result['stdout'])) out.stdout = result['stdout']\n\t\tif (isString(result['stderr'])) out.stderr = result['stderr']\n\t\tif (typeof result['exitCode'] === 'number') out.exit_code = result['exitCode']\n\t\tif (typeof result['exit_code'] === 'number') out.exit_code = result['exit_code']\n\t\tif (typeof result['success'] === 'boolean') out.success = result['success']\n\t}\n\treturn out\n}\n\nfunction extractFiles(payload: unknown, fallbackPaths: string[]): { path: string; text: string }[] {\n\tif (isPlainObject(payload)) {\n\t\tconst content = payload['content'] ?? payload['files']\n\t\tif (Array.isArray(content)) {\n\t\t\tconst files: { path: string; text: string }[] = []\n\t\t\tfor (const row of content) {\n\t\t\t\tif (!isPlainObject(row)) continue\n\t\t\t\tconst path = row['path']\n\t\t\t\tconst text = row['text'] ?? row['content'] ?? ''\n\t\t\t\tif (isString(path) && isString(text)) files.push({ path, text })\n\t\t\t}\n\t\t\tif (files.length > 0) return files\n\t\t}\n\t}\n\t// Best-effort: single string body for first path\n\tif (isString(payload) && fallbackPaths[0]) {\n\t\treturn [{ path: fallbackPaths[0], text: payload }]\n\t}\n\treturn fallbackPaths.map((path) => ({ path, text: '' }))\n}\n\nfunction extractPaths(payload: unknown): string[] {\n\tif (!isPlainObject(payload)) return []\n\tconst list = payload['files'] ?? payload['paths'] ?? payload['entries']\n\tif (!Array.isArray(list)) return []\n\tconst paths: string[] = []\n\tfor (const row of list) {\n\t\tif (isString(row)) {\n\t\t\tpaths.push(row)\n\t\t\tcontinue\n\t\t}\n\t\tif (isPlainObject(row)) {\n\t\t\tconst path = row['path'] ?? row['name']\n\t\t\tif (isString(path)) paths.push(path)\n\t\t}\n\t}\n\treturn paths\n}\n","import type { HttpServiceOptions } from '../../../transport/http-service'\nimport { CloudflareSandboxClient } from '../../../vendors/cloudflare-sandbox'\nimport type {\n\tCodeSandboxExecResult,\n\tCodeSandboxExecuteCodeInput,\n\tCodeSandboxExecuteCommandInput,\n\tCodeSandboxListFilesInput,\n\tCodeSandboxListFilesOutput,\n\tCodeSandboxOps,\n\tCodeSandboxReadFilesInput,\n\tCodeSandboxRemoveFilesInput,\n\tCodeSandboxSessionIdInput,\n\tCodeSandboxSessionOutput,\n\tCodeSandboxStartSessionInput,\n\tCodeSandboxWriteFilesInput,\n\tCloudflareCodeSandboxAuth\n} from '../contracts'\n\nexport type CloudflareCodeSandboxProviderOptions = Pick<HttpServiceOptions, 'fetch' | 'signal'>\n\nexport class CloudflareCodeSandboxProvider implements CodeSandboxOps {\n\treadonly #client: CloudflareSandboxClient\n\n\tconstructor(auth: CloudflareCodeSandboxAuth, options: CloudflareCodeSandboxProviderOptions = {}) {\n\t\tconst { provider: _provider, ...vendorAuth } = auth\n\t\tthis.#client = new CloudflareSandboxClient(vendorAuth, options)\n\t}\n\n\tasync startSession(_input: CodeSandboxStartSessionInput = {}): Promise<CodeSandboxSessionOutput> {\n\t\t// Bridge create has no name/timeout fields; ignore optional start metadata.\n\t\tconst created = await this.#client.create()\n\t\treturn { session_id: created.sandbox_id, status: 'running', running: true }\n\t}\n\n\tasync getSession(input: CodeSandboxSessionIdInput): Promise<CodeSandboxSessionOutput> {\n\t\tconst row = await this.#client.running({ sandbox_id: input.session_id })\n\t\treturn {\n\t\t\tsession_id: input.session_id,\n\t\t\trunning: row.running,\n\t\t\tstatus: row.running ? 'running' : 'stopped'\n\t\t}\n\t}\n\n\tasync stopSession(input: CodeSandboxSessionIdInput): Promise<CodeSandboxSessionOutput> {\n\t\tawait this.#client.destroy({ sandbox_id: input.session_id })\n\t\treturn { session_id: input.session_id, status: 'stopped', running: false }\n\t}\n\n\tasync executeCode(input: CodeSandboxExecuteCodeInput): Promise<CodeSandboxExecResult> {\n\t\tconst language = normalizeLanguage(input.language)\n\t\tconst out = await this.#client.executeCode({\n\t\t\tsandbox_id: input.session_id,\n\t\t\tcode: input.code,\n\t\t\tlanguage\n\t\t})\n\t\treturn mapExec(input.session_id, out)\n\t}\n\n\tasync executeCommand(input: CodeSandboxExecuteCommandInput): Promise<CodeSandboxExecResult> {\n\t\tconst out = await this.#client.exec({\n\t\t\tsandbox_id: input.session_id,\n\t\t\targv: ['sh', '-lc', input.command]\n\t\t})\n\t\treturn mapExec(input.session_id, out)\n\t}\n\n\tasync writeFiles(input: CodeSandboxWriteFilesInput) {\n\t\tconst out = await this.#client.writeFiles({\n\t\t\tsandbox_id: input.session_id,\n\t\t\tfiles: input.files\n\t\t})\n\t\treturn { session_id: input.session_id, paths: out.paths, ok: true as const }\n\t}\n\n\tasync readFiles(input: CodeSandboxReadFilesInput) {\n\t\tconst out = await this.#client.readFiles({\n\t\t\tsandbox_id: input.session_id,\n\t\t\tpaths: input.paths\n\t\t})\n\t\t// Seam contract is utf-8 text only; vendor defaults encoding to utf8.\n\t\treturn {\n\t\t\tsession_id: input.session_id,\n\t\t\tfiles: out.files.map((file) => ({\n\t\t\t\tpath: file.path,\n\t\t\t\ttext: file.text ?? ''\n\t\t\t}))\n\t\t}\n\t}\n\n\tasync listFiles(input: CodeSandboxListFilesInput): Promise<CodeSandboxListFilesOutput> {\n\t\tconst out = await this.#client.listFiles({\n\t\t\tsandbox_id: input.session_id,\n\t\t\t...(input.directory_path !== undefined && { directory_path: input.directory_path })\n\t\t})\n\t\treturn {\n\t\t\tsession_id: input.session_id,\n\t\t\tpaths: out.paths,\n\t\t\t...(out.raw !== undefined && { raw: out.raw })\n\t\t}\n\t}\n\n\tasync removeFiles(input: CodeSandboxRemoveFilesInput) {\n\t\tconst out = await this.#client.removeFiles({\n\t\t\tsandbox_id: input.session_id,\n\t\t\tpaths: input.paths\n\t\t})\n\t\treturn { session_id: input.session_id, paths: out.paths, ok: true as const }\n\t}\n}\n\nfunction mapExec(\n\tsession_id: string,\n\tout: { stdout: string; stderr: string; exit_code?: number | undefined; success: boolean }\n): CodeSandboxExecResult {\n\tconst result: CodeSandboxExecResult = {\n\t\tsession_id,\n\t\tstdout: out.stdout,\n\t\tstderr: out.stderr,\n\t\tsuccess: out.success\n\t}\n\tif (out.exit_code !== undefined) result.exit_code = out.exit_code\n\treturn result\n}\n\nfunction normalizeLanguage(language: string | undefined): 'python' | 'javascript' | 'typescript' | 'shell' {\n\tconst raw = (language ?? 'python').toLowerCase()\n\tif (raw === 'js' || raw === 'javascript' || raw === 'node') return 'javascript'\n\tif (raw === 'ts' || raw === 'typescript') return 'typescript'\n\tif (raw === 'sh' || raw === 'bash' || raw === 'shell') return 'shell'\n\treturn 'python'\n}\n","import { requireAuth } from '../../core/provider'\nimport type { ToolContext } from '../../core/types'\nimport type {\n\tCodeSandboxAuth,\n\tCodeSandboxExecuteCodeInput,\n\tCodeSandboxExecuteCommandInput,\n\tCodeSandboxListFilesInput,\n\tCodeSandboxOps,\n\tCodeSandboxReadFilesInput,\n\tCodeSandboxRemoveFilesInput,\n\tCodeSandboxSessionIdInput,\n\tCodeSandboxStartSessionInput,\n\tCodeSandboxWriteFilesInput\n} from './contracts'\nimport { codeSandboxAuthSchema } from './contracts'\nimport { AgentCoreCodeSandboxProvider } from './providers/bedrock-agentcore'\nimport { CloudflareCodeSandboxProvider } from './providers/cloudflare-sandbox'\n\nfunction providerFor(auth: CodeSandboxAuth, ctx: ToolContext): CodeSandboxOps {\n\tswitch (auth.provider) {\n\t\tcase 'cloudflare':\n\t\t\treturn new CloudflareCodeSandboxProvider(auth, {\n\t\t\t\t...(ctx.fetch && { fetch: ctx.fetch }),\n\t\t\t\t...(ctx.signal && { signal: ctx.signal })\n\t\t\t})\n\t\tcase 'bedrock-agentcore':\n\t\t\treturn new AgentCoreCodeSandboxProvider(auth, {\n\t\t\t\t...(ctx.fetch && { fetch: ctx.fetch }),\n\t\t\t\t...(ctx.signal && { signal: ctx.signal })\n\t\t\t})\n\t}\n}\n\nexport class CodeSandboxClient implements CodeSandboxOps {\n\treadonly #ops: CodeSandboxOps\n\n\tconstructor(ops: CodeSandboxOps) {\n\t\tthis.#ops = ops\n\t}\n\n\tstatic fromContext(ctx: ToolContext): CodeSandboxClient {\n\t\treturn new CodeSandboxClient(providerFor(requireAuth(ctx, codeSandboxAuthSchema), ctx))\n\t}\n\n\tstatic fromAuth(auth: CodeSandboxAuth, ctx: ToolContext = {}): CodeSandboxClient {\n\t\treturn new CodeSandboxClient(providerFor(auth, ctx))\n\t}\n\n\tstartSession(input: CodeSandboxStartSessionInput = {}) {\n\t\treturn this.#ops.startSession(input)\n\t}\n\n\tgetSession(input: CodeSandboxSessionIdInput) {\n\t\treturn this.#ops.getSession(input)\n\t}\n\n\tstopSession(input: CodeSandboxSessionIdInput) {\n\t\treturn this.#ops.stopSession(input)\n\t}\n\n\texecuteCode(input: CodeSandboxExecuteCodeInput) {\n\t\treturn this.#ops.executeCode(input)\n\t}\n\n\texecuteCommand(input: CodeSandboxExecuteCommandInput) {\n\t\treturn this.#ops.executeCommand(input)\n\t}\n\n\twriteFiles(input: CodeSandboxWriteFilesInput) {\n\t\treturn this.#ops.writeFiles(input)\n\t}\n\n\treadFiles(input: CodeSandboxReadFilesInput) {\n\t\treturn this.#ops.readFiles(input)\n\t}\n\n\tlistFiles(input: CodeSandboxListFilesInput) {\n\t\treturn this.#ops.listFiles(input)\n\t}\n\n\tremoveFiles(input: CodeSandboxRemoveFilesInput) {\n\t\treturn this.#ops.removeFiles(input)\n\t}\n}\n","import { defineModule, defineTool } from '../../core/define'\nimport { CodeSandboxClient } from './client'\nimport {\n\tcodeSandboxAuthSchema,\n\tcodeSandboxExecResultSchema,\n\tcodeSandboxExecuteCodeInputSchema,\n\tcodeSandboxExecuteCommandInputSchema,\n\tcodeSandboxListFilesInputSchema,\n\tcodeSandboxListFilesOutputSchema,\n\tcodeSandboxReadFilesInputSchema,\n\tcodeSandboxReadFilesOutputSchema,\n\tcodeSandboxRemoveFilesInputSchema,\n\tcodeSandboxRemoveFilesOutputSchema,\n\tcodeSandboxSessionIdInputSchema,\n\tcodeSandboxSessionOutputSchema,\n\tcodeSandboxStartSessionInputSchema,\n\tcodeSandboxWriteFilesInputSchema,\n\tcodeSandboxWriteFilesOutputSchema\n} from './contracts'\n\nexport const codeSandboxStartSessionTool = defineTool({\n\tid: 'code-sandbox-start-session',\n\tname: 'startCodeSandboxSession',\n\tdescription:\n\t\t'Start an isolated sandbox session and return session_id. Use only when the task requires arbitrary code, shell commands, or temporary files that no purpose-built tool covers. Do not start a sandbox to build or edit supported documents, spreadsheets, presentations, PDFs, or images.',\n\tinputSchema: codeSandboxStartSessionInputSchema,\n\toutputSchema: codeSandboxSessionOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CodeSandboxClient.fromContext(ctx).startSession(input)\n})\n\nexport const codeSandboxGetSessionTool = defineTool({\n\tid: 'code-sandbox-get-session',\n\tname: 'getCodeSandboxSession',\n\tdescription:\n\t\t'Get status for a sandbox session created by code-sandbox-start-session. Use when execution may still be running or session availability must be checked; this does not execute work.',\n\tinputSchema: codeSandboxSessionIdInputSchema,\n\toutputSchema: codeSandboxSessionOutputSchema,\n\tsideEffect: 'read',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CodeSandboxClient.fromContext(ctx).getSession(input)\n})\n\nexport const codeSandboxStopSessionTool = defineTool({\n\tid: 'code-sandbox-stop-session',\n\tname: 'stopCodeSandboxSession',\n\tdescription:\n\t\t'Stop a sandbox session created by code-sandbox-start-session and release its temporary resources. Call after sandbox work is complete when the session is no longer needed.',\n\tinputSchema: codeSandboxSessionIdInputSchema,\n\toutputSchema: codeSandboxSessionOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CodeSandboxClient.fromContext(ctx).stopSession(input)\n})\n\nexport const codeSandboxExecuteCodeTool = defineTool({\n\tid: 'code-sandbox-execute-code',\n\tname: 'executeCodeInSandbox',\n\tdescription:\n\t\t'Execute source code in an active sandbox session. Use as a fallback for computation or automation that no purpose-built tool covers. Do not use to build or edit supported documents, spreadsheets, presentations, PDFs, or images.',\n\tinputSchema: codeSandboxExecuteCodeInputSchema,\n\toutputSchema: codeSandboxExecResultSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CodeSandboxClient.fromContext(ctx).executeCode(input)\n})\n\nexport const codeSandboxExecuteCommandTool = defineTool({\n\tid: 'code-sandbox-execute-command',\n\tname: 'executeCommandInSandbox',\n\tdescription:\n\t\t'Run a shell command in an active sandbox session. Use as a fallback for command-line work that no purpose-built tool covers. Do not use command-line libraries to replace dedicated document, spreadsheet, presentation, PDF, or image tools.',\n\tinputSchema: codeSandboxExecuteCommandInputSchema,\n\toutputSchema: codeSandboxExecResultSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CodeSandboxClient.fromContext(ctx).executeCommand(input)\n})\n\nexport const codeSandboxWriteFilesTool = defineTool({\n\tid: 'code-sandbox-write-files',\n\tname: 'writeSandboxFiles',\n\tdescription:\n\t\t'Write one or more UTF-8 files into an active sandbox session for intermediate computation. Sandbox files are temporary and this tool does not return ArtifactRefs. Use a purpose-built builder for final deliverables.',\n\tinputSchema: codeSandboxWriteFilesInputSchema,\n\toutputSchema: codeSandboxWriteFilesOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CodeSandboxClient.fromContext(ctx).writeFiles(input)\n})\n\nexport const codeSandboxReadFilesTool = defineTool({\n\tid: 'code-sandbox-read-files',\n\tname: 'readSandboxFiles',\n\tdescription:\n\t\t'Read one or more UTF-8 files from an active sandbox session. Use only for files produced or imported during the same sandbox workflow; use a format-aware reader for supported user artifacts.',\n\tinputSchema: codeSandboxReadFilesInputSchema,\n\toutputSchema: codeSandboxReadFilesOutputSchema,\n\tsideEffect: 'read',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CodeSandboxClient.fromContext(ctx).readFiles(input)\n})\n\nexport const codeSandboxListFilesTool = defineTool({\n\tid: 'code-sandbox-list-files',\n\tname: 'listSandboxFiles',\n\tdescription:\n\t\t'List temporary files in an active sandbox directory when supported. Use to locate sandbox intermediates, not to discover files in the durable workspace or artifact store.',\n\tinputSchema: codeSandboxListFilesInputSchema,\n\toutputSchema: codeSandboxListFilesOutputSchema,\n\tsideEffect: 'read',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CodeSandboxClient.fromContext(ctx).listFiles(input)\n})\n\nexport const codeSandboxRemoveFilesTool = defineTool({\n\tid: 'code-sandbox-remove-files',\n\tname: 'removeSandboxFiles',\n\tdescription:\n\t\t'Remove temporary files from an active sandbox session. Use only for sandbox cleanup; this does not delete durable workspace files or ArtifactRefs.',\n\tinputSchema: codeSandboxRemoveFilesInputSchema,\n\toutputSchema: codeSandboxRemoveFilesOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CodeSandboxClient.fromContext(ctx).removeFiles(input)\n})\n\nexport const codeSandboxModule = defineModule({\n\tid: 'code-sandbox',\n\ttitle: 'Code Sandbox',\n\tdescription:\n\t\t'General-purpose fallback for arbitrary code, commands, and temporary files when no dedicated tool covers the task. Do not use it instead of purpose-built document, spreadsheet, presentation, PDF, image, or render tools.',\n\truntime: 'both',\n\tauth: { type: 'custom', schema: codeSandboxAuthSchema },\n\tcategories: ['compute', 'sandbox'],\n\tclassification: 'standard',\n\ttags: ['exec', 'workspace'],\n\ttools: [\n\t\tcodeSandboxStartSessionTool,\n\t\tcodeSandboxGetSessionTool,\n\t\tcodeSandboxStopSessionTool,\n\t\tcodeSandboxExecuteCode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,CAAC,UAAU,KAAK;AAClF,CAAC;AAED,MAAa,2BAA2B,WAAW;CAClD,IAAI;CACJ,MAAM;CACN,aACC;CACD,aAAa;CACb,cAAc;CACd,YAAY;CACZ,SAAS;CACT,SAAS;CACT,SAAS,OAAO,OAAO,QAAQ,kBAAkB,YAAY,GAAG,CAAC,CAAC,UAAU,KAAK;AAClF,CAAC;AAED,MAAa,6BAA6B,WAAW;CACpD,IAAI;CACJ,MAAM;CACN,aACC;CACD,aAAa;CACb,cAAc;CACd,YAAY;CACZ,SAAS;CACT,SAAS;CACT,SAAS,OAAO,OAAO,QAAQ,kBAAkB,YAAY,GAAG,CAAC,CAAC,YAAY,KAAK;AACpF,CAAC;AAED,MAAa,oBAAoB,aAAa;CAC7C,IAAI;CACJ,OAAO;CACP,aACC;CACD,SAAS;CACT,MAAM;EAAE,MAAM;EAAU,QAAQ;CAAsB;CACtD,YAAY,CAAC,WAAW,SAAS;CACjC,gBAAgB;CAChB,MAAM,CAAC,QAAQ,WAAW;CAC1B,OAAO;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;AACD,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["#client","#client","#ops"],"sources":["../../../src/modules/code-sandbox/contracts.ts","../../../src/modules/code-sandbox/providers/bedrock-agentcore.ts","../../../src/modules/code-sandbox/providers/cloudflare-sandbox.ts","../../../src/modules/code-sandbox/client.ts","../../../src/modules/code-sandbox/module.ts"],"sourcesContent":["/**\n * Code sandbox capability seam — execute code and commands in an isolated sandbox.\n * Providers: cloudflare-sandbox (bridge), bedrock-agentcore.\n */\n\nimport { z } from 'zod'\n\nimport {\n\tbedrockAgentCoreCodeInterpreterAuthSchema,\n\tMAX_CODE_CHARS,\n\tMAX_COMMAND_CHARS,\n\tMAX_FILE_PATHS,\n\tMAX_FILE_TEXT,\n\tMAX_WRITE_FILES\n} from '../../vendors/bedrock-agentcore-code-interpreter'\nimport { cloudflareSandboxAuthSchema } from '../../vendors/cloudflare-sandbox'\n\nexport const MAX_SEAM_CODE_CHARS = MAX_CODE_CHARS\nexport const MAX_SEAM_COMMAND_CHARS = MAX_COMMAND_CHARS\n\n/** Bridge host credentials; provider id matches email/browser gold (`cloudflare`). */\nexport const cloudflareCodeSandboxAuthSchema = cloudflareSandboxAuthSchema.extend({\n\tprovider: z.literal('cloudflare')\n})\n\nexport const agentCoreCodeSandboxAuthSchema = bedrockAgentCoreCodeInterpreterAuthSchema.extend({\n\tprovider: z.literal('bedrock-agentcore')\n})\n\nexport const codeSandboxAuthSchema = z.discriminatedUnion('provider', [\n\tcloudflareCodeSandboxAuthSchema,\n\tagentCoreCodeSandboxAuthSchema\n])\n\nexport type CloudflareCodeSandboxAuth = z.infer<typeof cloudflareCodeSandboxAuthSchema>\nexport type AgentCoreCodeSandboxAuth = z.infer<typeof agentCoreCodeSandboxAuthSchema>\nexport type CodeSandboxAuth = z.infer<typeof codeSandboxAuthSchema>\n\nconst sessionId = z.string().min(1).max(200).describe('Sandbox session id from start-session')\n\nexport const codeSandboxStartSessionInputSchema = z.object({\n\tname: z.string().min(1).max(100).optional().describe('Optional session name when the bound provider supports it'),\n\tsession_timeout_seconds: z\n\t\t.int()\n\t\t.min(1)\n\t\t.max(28_800)\n\t\t.optional()\n\t\t.describe('Session TTL in seconds when the bound provider supports it')\n})\n\nexport const codeSandboxSessionIdInputSchema = z.object({\n\tsession_id: sessionId\n})\n\nexport const codeSandboxSessionOutputSchema = z.object({\n\tsession_id: z.string().describe('Sandbox session id'),\n\tstatus: z.string().optional().describe('Provider session status when available'),\n\trunning: z.boolean().optional().describe('Whether the sandbox is running when reported')\n})\n\nexport const codeSandboxExecuteCodeInputSchema = z.object({\n\tsession_id: sessionId,\n\tcode: z.string().min(1).max(MAX_SEAM_CODE_CHARS).describe('Source code to execute'),\n\tlanguage: z.string().min(1).max(40).optional().describe('Language when supported (default python)')\n})\n\nexport const codeSandboxExecuteCommandInputSchema = z.object({\n\tsession_id: sessionId,\n\tcommand: z.string().min(1).max(MAX_SEAM_COMMAND_CHARS).describe('Shell command to run')\n})\n\nexport const codeSandboxExecResultSchema = z.object({\n\tsession_id: z.string(),\n\tstdout: z.string().optional().describe('Standard output when available'),\n\tstderr: z.string().optional().describe('Standard error when available'),\n\texit_code: z.number().int().optional().describe('Process exit code when available'),\n\tsuccess: z.boolean().optional().describe('True when the run completed successfully'),\n\tresult: z.unknown().optional().describe('Provider-specific result payload when structured')\n})\n\nexport const codeSandboxWriteFilesInputSchema = z.object({\n\tsession_id: sessionId,\n\tfiles: z\n\t\t.array(\n\t\t\tz.object({\n\t\t\t\tpath: z.string().min(1).max(1024).describe('Path to write'),\n\t\t\t\ttext: z.string().max(MAX_FILE_TEXT).describe('Utf8 file contents')\n\t\t\t})\n\t\t)\n\t\t.min(1)\n\t\t.max(MAX_WRITE_FILES)\n\t\t.describe('Files to write in the sandbox')\n})\n\nexport const codeSandboxWriteFilesOutputSchema = z.object({\n\tsession_id: z.string(),\n\tpaths: z.array(z.string()),\n\tok: z.literal(true)\n})\n\nexport const codeSandboxReadFilesInputSchema = z.object({\n\tsession_id: sessionId,\n\tpaths: z.array(z.string().min(1).max(1024)).min(1).max(MAX_FILE_PATHS).describe('Paths to read')\n})\n\nexport const codeSandboxReadFilesOutputSchema = z.object({\n\tsession_id: z.string(),\n\tfiles: z.array(\n\t\tz.object({\n\t\t\tpath: z.string(),\n\t\t\ttext: z.string()\n\t\t})\n\t)\n})\n\nexport const codeSandboxListFilesInputSchema = z.object({\n\tsession_id: sessionId,\n\tdirectory_path: z.string().max(1024).optional().describe('Directory to list (default sandbox root)')\n})\n\nexport const codeSandboxListFilesOutputSchema = z.object({\n\tsession_id: z.string(),\n\tpaths: z.array(z.string()).describe('Relative paths found'),\n\traw: z.unknown().optional().describe('Provider listing payload when available')\n})\n\nexport const codeSandboxRemoveFilesInputSchema = z.object({\n\tsession_id: sessionId,\n\tpaths: z.array(z.string().min(1).max(1024)).min(1).max(MAX_FILE_PATHS).describe('Paths to remove')\n})\n\nexport const codeSandboxRemoveFilesOutputSchema = z.object({\n\tsession_id: z.string(),\n\tpaths: z.array(z.string()),\n\tok: z.literal(true)\n})\n\nexport type CodeSandboxStartSessionInput = z.infer<typeof codeSandboxStartSessionInputSchema>\nexport type CodeSandboxSessionIdInput = z.infer<typeof codeSandboxSessionIdInputSchema>\nexport type CodeSandboxSessionOutput = z.infer<typeof codeSandboxSessionOutputSchema>\nexport type CodeSandboxExecuteCodeInput = z.infer<typeof codeSandboxExecuteCodeInputSchema>\nexport type CodeSandboxExecuteCommandInput = z.infer<typeof codeSandboxExecuteCommandInputSchema>\nexport type CodeSandboxExecResult = z.infer<typeof codeSandboxExecResultSchema>\nexport type CodeSandboxWriteFilesInput = z.infer<typeof codeSandboxWriteFilesInputSchema>\nexport type CodeSandboxWriteFilesOutput = z.infer<typeof codeSandboxWriteFilesOutputSchema>\nexport type CodeSandboxReadFilesInput = z.infer<typeof codeSandboxReadFilesInputSchema>\nexport type CodeSandboxReadFilesOutput = z.infer<typeof codeSandboxReadFilesOutputSchema>\nexport type CodeSandboxListFilesInput = z.infer<typeof codeSandboxListFilesInputSchema>\nexport type CodeSandboxListFilesOutput = z.infer<typeof codeSandboxListFilesOutputSchema>\nexport type CodeSandboxRemoveFilesInput = z.infer<typeof codeSandboxRemoveFilesInputSchema>\nexport type CodeSandboxRemoveFilesOutput = z.infer<typeof codeSandboxRemoveFilesOutputSchema>\n\nexport type CodeSandboxOps = {\n\tstartSession(input?: CodeSandboxStartSessionInput): Promise<CodeSandboxSessionOutput>\n\tgetSession(input: CodeSandboxSessionIdInput): Promise<CodeSandboxSessionOutput>\n\tstopSession(input: CodeSandboxSessionIdInput): Promise<CodeSandboxSessionOutput>\n\texecuteCode(input: CodeSandboxExecuteCodeInput): Promise<CodeSandboxExecResult>\n\texecuteCommand(input: CodeSandboxExecuteCommandInput): Promise<CodeSandboxExecResult>\n\twriteFiles(input: CodeSandboxWriteFilesInput): Promise<CodeSandboxWriteFilesOutput>\n\treadFiles(input: CodeSandboxReadFilesInput): Promise<CodeSandboxReadFilesOutput>\n\tlistFiles(input: CodeSandboxListFilesInput): Promise<CodeSandboxListFilesOutput>\n\tremoveFiles(input: CodeSandboxRemoveFilesInput): Promise<CodeSandboxRemoveFilesOutput>\n}\n","import { isPlainObject, isString } from 'es-toolkit'\n\nimport type { HttpServiceOptions } from '../../../transport/http-service'\nimport { BedrockAgentCoreCodeInterpreterClient } from '../../../vendors/bedrock-agentcore-code-interpreter'\nimport type {\n\tAgentCoreCodeSandboxAuth,\n\tCodeSandboxExecResult,\n\tCodeSandboxExecuteCodeInput,\n\tCodeSandboxExecuteCommandInput,\n\tCodeSandboxListFilesInput,\n\tCodeSandboxListFilesOutput,\n\tCodeSandboxOps,\n\tCodeSandboxReadFilesInput,\n\tCodeSandboxReadFilesOutput,\n\tCodeSandboxRemoveFilesInput,\n\tCodeSandboxSessionIdInput,\n\tCodeSandboxSessionOutput,\n\tCodeSandboxStartSessionInput,\n\tCodeSandboxWriteFilesInput\n} from '../contracts'\n\nexport type AgentCoreCodeSandboxProviderOptions = Pick<HttpServiceOptions, 'fetch' | 'signal'>\n\nexport class AgentCoreCodeSandboxProvider implements CodeSandboxOps {\n\treadonly #client: BedrockAgentCoreCodeInterpreterClient\n\n\tconstructor(auth: AgentCoreCodeSandboxAuth, options: AgentCoreCodeSandboxProviderOptions = {}) {\n\t\tconst { provider: _provider, ...vendorAuth } = auth\n\t\tthis.#client = new BedrockAgentCoreCodeInterpreterClient(vendorAuth, options)\n\t}\n\n\tasync startSession(input: CodeSandboxStartSessionInput = {}): Promise<CodeSandboxSessionOutput> {\n\t\tconst out = await this.#client.startSession({\n\t\t\t...(input.name && { name: input.name }),\n\t\t\t...(input.session_timeout_seconds !== undefined && {\n\t\t\t\tsession_timeout_seconds: input.session_timeout_seconds\n\t\t\t})\n\t\t})\n\t\treturn {\n\t\t\tsession_id: out.session_id,\n\t\t\t...(out.status && { status: out.status }),\n\t\t\trunning: true\n\t\t}\n\t}\n\n\tasync getSession(input: CodeSandboxSessionIdInput): Promise<CodeSandboxSessionOutput> {\n\t\tconst out = await this.#client.getSession({ session_id: input.session_id })\n\t\treturn {\n\t\t\tsession_id: out.session_id,\n\t\t\t...(out.status && { status: out.status }),\n\t\t\trunning: out.status ? out.status.toUpperCase() !== 'TERMINATED' : true\n\t\t}\n\t}\n\n\tasync stopSession(input: CodeSandboxSessionIdInput): Promise<CodeSandboxSessionOutput> {\n\t\tconst out = await this.#client.stopSession({ session_id: input.session_id })\n\t\treturn {\n\t\t\tsession_id: out.session_id,\n\t\t\t...(out.status && { status: out.status }),\n\t\t\trunning: false\n\t\t}\n\t}\n\n\tasync executeCode(input: CodeSandboxExecuteCodeInput): Promise<CodeSandboxExecResult> {\n\t\tconst out = await this.#client.executeCode({\n\t\t\tsession_id: input.session_id,\n\t\t\tcode: input.code,\n\t\t\t...(input.language && { language: input.language })\n\t\t})\n\t\treturn mapInvoke(input.session_id, out.result, out.raw)\n\t}\n\n\tasync executeCommand(input: CodeSandboxExecuteCommandInput): Promise<CodeSandboxExecResult> {\n\t\tconst out = await this.#client.executeCommand({\n\t\t\tsession_id: input.session_id,\n\t\t\tcommand: input.command\n\t\t})\n\t\treturn mapInvoke(input.session_id, out.result, out.raw)\n\t}\n\n\tasync writeFiles(input: CodeSandboxWriteFilesInput) {\n\t\tawait this.#client.writeFiles({\n\t\t\tsession_id: input.session_id,\n\t\t\tfiles: input.files\n\t\t})\n\t\treturn {\n\t\t\tsession_id: input.session_id,\n\t\t\tpaths: input.files.map((f) => f.path),\n\t\t\tok: true as const\n\t\t}\n\t}\n\n\tasync readFiles(input: CodeSandboxReadFilesInput): Promise<CodeSandboxReadFilesOutput> {\n\t\tconst out = await this.#client.readFiles({\n\t\t\tsession_id: input.session_id,\n\t\t\tpaths: input.paths\n\t\t})\n\t\tconst files = extractFiles(out.result ?? out.raw, input.paths)\n\t\treturn { session_id: input.session_id, files }\n\t}\n\n\tasync listFiles(input: CodeSandboxListFilesInput): Promise<CodeSandboxListFilesOutput> {\n\t\tconst out = await this.#client.listFiles({\n\t\t\tsession_id: input.session_id,\n\t\t\t...(input.directory_path !== undefined && { directory_path: input.directory_path })\n\t\t})\n\t\tconst paths = extractPaths(out.result ?? out.raw)\n\t\treturn { session_id: input.session_id, paths, raw: out.result ?? out.raw }\n\t}\n\n\tasync removeFiles(input: CodeSandboxRemoveFilesInput) {\n\t\tawait this.#client.removeFiles({\n\t\t\tsession_id: input.session_id,\n\t\t\tpaths: input.paths\n\t\t})\n\t\treturn { session_id: input.session_id, paths: input.paths, ok: true as const }\n\t}\n}\n\nfunction mapInvoke(session_id: string, result: unknown, raw: unknown): CodeSandboxExecResult {\n\tconst out: CodeSandboxExecResult = { session_id, result: result ?? raw, success: true }\n\tif (isPlainObject(result)) {\n\t\tif (isString(result['stdout'])) out.stdout = result['stdout']\n\t\tif (isString(result['stderr'])) out.stderr = result['stderr']\n\t\tif (typeof result['exitCode'] === 'number') out.exit_code = result['exitCode']\n\t\tif (typeof result['exit_code'] === 'number') out.exit_code = result['exit_code']\n\t\tif (typeof result['success'] === 'boolean') out.success = result['success']\n\t}\n\treturn out\n}\n\nfunction extractFiles(payload: unknown, fallbackPaths: string[]): { path: string; text: string }[] {\n\tif (isPlainObject(payload)) {\n\t\tconst content = payload['content'] ?? payload['files']\n\t\tif (Array.isArray(content)) {\n\t\t\tconst files: { path: string; text: string }[] = []\n\t\t\tfor (const row of content) {\n\t\t\t\tif (!isPlainObject(row)) continue\n\t\t\t\tconst path = row['path']\n\t\t\t\tconst text = row['text'] ?? row['content'] ?? ''\n\t\t\t\tif (isString(path) && isString(text)) files.push({ path, text })\n\t\t\t}\n\t\t\tif (files.length > 0) return files\n\t\t}\n\t}\n\t// Best-effort: single string body for first path\n\tif (isString(payload) && fallbackPaths[0]) {\n\t\treturn [{ path: fallbackPaths[0], text: payload }]\n\t}\n\treturn fallbackPaths.map((path) => ({ path, text: '' }))\n}\n\nfunction extractPaths(payload: unknown): string[] {\n\tif (!isPlainObject(payload)) return []\n\tconst list = payload['files'] ?? payload['paths'] ?? payload['entries']\n\tif (!Array.isArray(list)) return []\n\tconst paths: string[] = []\n\tfor (const row of list) {\n\t\tif (isString(row)) {\n\t\t\tpaths.push(row)\n\t\t\tcontinue\n\t\t}\n\t\tif (isPlainObject(row)) {\n\t\t\tconst path = row['path'] ?? row['name']\n\t\t\tif (isString(path)) paths.push(path)\n\t\t}\n\t}\n\treturn paths\n}\n","import { ToolError } from '../../../core/errors'\nimport type { HttpServiceOptions } from '../../../transport/http-service'\nimport { CloudflareSandboxClient } from '../../../vendors/cloudflare-sandbox'\nimport type {\n\tCodeSandboxExecResult,\n\tCodeSandboxExecuteCodeInput,\n\tCodeSandboxExecuteCommandInput,\n\tCodeSandboxListFilesInput,\n\tCodeSandboxListFilesOutput,\n\tCodeSandboxOps,\n\tCodeSandboxReadFilesInput,\n\tCodeSandboxRemoveFilesInput,\n\tCodeSandboxSessionIdInput,\n\tCodeSandboxSessionOutput,\n\tCodeSandboxStartSessionInput,\n\tCodeSandboxWriteFilesInput,\n\tCloudflareCodeSandboxAuth\n} from '../contracts'\n\nexport type CloudflareCodeSandboxProviderOptions = Pick<HttpServiceOptions, 'fetch' | 'signal'>\n\nexport class CloudflareCodeSandboxProvider implements CodeSandboxOps {\n\treadonly #client: CloudflareSandboxClient\n\n\tconstructor(auth: CloudflareCodeSandboxAuth, options: CloudflareCodeSandboxProviderOptions = {}) {\n\t\tconst { provider: _provider, ...vendorAuth } = auth\n\t\tthis.#client = new CloudflareSandboxClient(vendorAuth, options)\n\t}\n\n\tasync startSession(_input: CodeSandboxStartSessionInput = {}): Promise<CodeSandboxSessionOutput> {\n\t\t// Bridge create has no name/timeout fields; ignore optional start metadata.\n\t\tconst created = await this.#client.create()\n\t\treturn { session_id: created.sandbox_id, status: 'running', running: true }\n\t}\n\n\tasync getSession(input: CodeSandboxSessionIdInput): Promise<CodeSandboxSessionOutput> {\n\t\tconst row = await this.#client.running({ sandbox_id: input.session_id })\n\t\treturn {\n\t\t\tsession_id: input.session_id,\n\t\t\trunning: row.running,\n\t\t\tstatus: row.running ? 'running' : 'stopped'\n\t\t}\n\t}\n\n\tasync stopSession(input: CodeSandboxSessionIdInput): Promise<CodeSandboxSessionOutput> {\n\t\tawait this.#client.destroy({ sandbox_id: input.session_id })\n\t\treturn { session_id: input.session_id, status: 'stopped', running: false }\n\t}\n\n\tasync executeCode(input: CodeSandboxExecuteCodeInput): Promise<CodeSandboxExecResult> {\n\t\tconst language = normalizeLanguage(input.language)\n\t\tconst out = await this.#client.executeCode({\n\t\t\tsandbox_id: input.session_id,\n\t\t\tcode: input.code,\n\t\t\tlanguage\n\t\t})\n\t\treturn mapExec(input.session_id, out)\n\t}\n\n\tasync executeCommand(input: CodeSandboxExecuteCommandInput): Promise<CodeSandboxExecResult> {\n\t\tconst out = await this.#client.exec({\n\t\t\tsandbox_id: input.session_id,\n\t\t\targv: ['sh', '-lc', input.command]\n\t\t})\n\t\treturn mapExec(input.session_id, out)\n\t}\n\n\tasync writeFiles(input: CodeSandboxWriteFilesInput) {\n\t\tconst out = await this.#client.writeFiles({\n\t\t\tsandbox_id: input.session_id,\n\t\t\tfiles: input.files\n\t\t})\n\t\treturn { session_id: input.session_id, paths: out.paths, ok: true as const }\n\t}\n\n\tasync readFiles(input: CodeSandboxReadFilesInput) {\n\t\tconst out = await this.#client.readFiles({\n\t\t\tsandbox_id: input.session_id,\n\t\t\tpaths: input.paths\n\t\t})\n\t\t// Seam contract is utf-8 text only; vendor defaults encoding to utf8.\n\t\treturn {\n\t\t\tsession_id: input.session_id,\n\t\t\tfiles: out.files.map((file) => ({\n\t\t\t\tpath: file.path,\n\t\t\t\ttext: file.text ?? ''\n\t\t\t}))\n\t\t}\n\t}\n\n\tasync listFiles(input: CodeSandboxListFilesInput): Promise<CodeSandboxListFilesOutput> {\n\t\tconst out = await this.#client.listFiles({\n\t\t\tsandbox_id: input.session_id,\n\t\t\t...(input.directory_path !== undefined && { directory_path: input.directory_path })\n\t\t})\n\t\treturn {\n\t\t\tsession_id: input.session_id,\n\t\t\tpaths: out.paths,\n\t\t\t...(out.raw !== undefined && { raw: out.raw })\n\t\t}\n\t}\n\n\tasync removeFiles(input: CodeSandboxRemoveFilesInput) {\n\t\tconst out = await this.#client.removeFiles({\n\t\t\tsandbox_id: input.session_id,\n\t\t\tpaths: input.paths\n\t\t})\n\t\treturn { session_id: input.session_id, paths: out.paths, ok: true as const }\n\t}\n}\n\nfunction mapExec(\n\tsession_id: string,\n\tout: { stdout: string; stderr: string; exit_code?: number | undefined; success: boolean }\n): CodeSandboxExecResult {\n\tconst result: CodeSandboxExecResult = {\n\t\tsession_id,\n\t\tstdout: out.stdout,\n\t\tstderr: out.stderr,\n\t\tsuccess: out.success\n\t}\n\tif (out.exit_code !== undefined) result.exit_code = out.exit_code\n\treturn result\n}\n\nfunction normalizeLanguage(language: string | undefined): 'python' | 'javascript' | 'typescript' {\n\tconst raw = (language ?? 'python').toLowerCase()\n\tif (['js', 'javascript', 'node'].includes(raw)) return 'javascript'\n\tif (['ts', 'typescript'].includes(raw)) return 'typescript'\n\tif (['sh', 'bash', 'shell'].includes(raw)) {\n\t\tthrow new ToolError('Use executeCommand for shell', { code: 'bad_input' })\n\t}\n\treturn 'python'\n}\n","import { requireAuth } from '../../core/provider'\nimport type { ToolContext } from '../../core/types'\nimport type {\n\tCodeSandboxAuth,\n\tCodeSandboxExecuteCodeInput,\n\tCodeSandboxExecuteCommandInput,\n\tCodeSandboxListFilesInput,\n\tCodeSandboxOps,\n\tCodeSandboxReadFilesInput,\n\tCodeSandboxRemoveFilesInput,\n\tCodeSandboxSessionIdInput,\n\tCodeSandboxStartSessionInput,\n\tCodeSandboxWriteFilesInput\n} from './contracts'\nimport { codeSandboxAuthSchema } from './contracts'\nimport { AgentCoreCodeSandboxProvider } from './providers/bedrock-agentcore'\nimport { CloudflareCodeSandboxProvider } from './providers/cloudflare-sandbox'\n\nfunction providerFor(auth: CodeSandboxAuth, ctx: ToolContext): CodeSandboxOps {\n\tswitch (auth.provider) {\n\t\tcase 'cloudflare':\n\t\t\treturn new CloudflareCodeSandboxProvider(auth, {\n\t\t\t\t...(ctx.fetch && { fetch: ctx.fetch }),\n\t\t\t\t...(ctx.signal && { signal: ctx.signal })\n\t\t\t})\n\t\tcase 'bedrock-agentcore':\n\t\t\treturn new AgentCoreCodeSandboxProvider(auth, {\n\t\t\t\t...(ctx.fetch && { fetch: ctx.fetch }),\n\t\t\t\t...(ctx.signal && { signal: ctx.signal })\n\t\t\t})\n\t}\n}\n\nexport class CodeSandboxClient implements CodeSandboxOps {\n\treadonly #ops: CodeSandboxOps\n\n\tconstructor(ops: CodeSandboxOps) {\n\t\tthis.#ops = ops\n\t}\n\n\tstatic fromContext(ctx: ToolContext): CodeSandboxClient {\n\t\treturn new CodeSandboxClient(providerFor(requireAuth(ctx, codeSandboxAuthSchema), ctx))\n\t}\n\n\tstatic fromAuth(auth: CodeSandboxAuth, ctx: ToolContext = {}): CodeSandboxClient {\n\t\treturn new CodeSandboxClient(providerFor(auth, ctx))\n\t}\n\n\tstartSession(input: CodeSandboxStartSessionInput = {}) {\n\t\treturn this.#ops.startSession(input)\n\t}\n\n\tgetSession(input: CodeSandboxSessionIdInput) {\n\t\treturn this.#ops.getSession(input)\n\t}\n\n\tstopSession(input: CodeSandboxSessionIdInput) {\n\t\treturn this.#ops.stopSession(input)\n\t}\n\n\texecuteCode(input: CodeSandboxExecuteCodeInput) {\n\t\treturn this.#ops.executeCode(input)\n\t}\n\n\texecuteCommand(input: CodeSandboxExecuteCommandInput) {\n\t\treturn this.#ops.executeCommand(input)\n\t}\n\n\twriteFiles(input: CodeSandboxWriteFilesInput) {\n\t\treturn this.#ops.writeFiles(input)\n\t}\n\n\treadFiles(input: CodeSandboxReadFilesInput) {\n\t\treturn this.#ops.readFiles(input)\n\t}\n\n\tlistFiles(input: CodeSandboxListFilesInput) {\n\t\treturn this.#ops.listFiles(input)\n\t}\n\n\tremoveFiles(input: CodeSandboxRemoveFilesInput) {\n\t\treturn this.#ops.removeFiles(input)\n\t}\n}\n","import { defineModule, defineTool } from '../../core/define'\nimport { CodeSandboxClient } from './client'\nimport {\n\tcodeSandboxAuthSchema,\n\tcodeSandboxExecResultSchema,\n\tcodeSandboxExecuteCodeInputSchema,\n\tcodeSandboxExecuteCommandInputSchema,\n\tcodeSandboxListFilesInputSchema,\n\tcodeSandboxListFilesOutputSchema,\n\tcodeSandboxReadFilesInputSchema,\n\tcodeSandboxReadFilesOutputSchema,\n\tcodeSandboxRemoveFilesInputSchema,\n\tcodeSandboxRemoveFilesOutputSchema,\n\tcodeSandboxSessionIdInputSchema,\n\tcodeSandboxSessionOutputSchema,\n\tcodeSandboxStartSessionInputSchema,\n\tcodeSandboxWriteFilesInputSchema,\n\tcodeSandboxWriteFilesOutputSchema\n} from './contracts'\n\nexport const codeSandboxStartSessionTool = defineTool({\n\tid: 'code-sandbox-start-session',\n\tname: 'startCodeSandboxSession',\n\tdescription:\n\t\t'Start an isolated sandbox session and return session_id. Use only when the task requires arbitrary code, shell commands, or temporary files that no purpose-built tool covers. Do not start a sandbox to build or edit supported documents, spreadsheets, presentations, PDFs, or images.',\n\tinputSchema: codeSandboxStartSessionInputSchema,\n\toutputSchema: codeSandboxSessionOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CodeSandboxClient.fromContext(ctx).startSession(input)\n})\n\nexport const codeSandboxGetSessionTool = defineTool({\n\tid: 'code-sandbox-get-session',\n\tname: 'getCodeSandboxSession',\n\tdescription:\n\t\t'Get status for a sandbox session created by code-sandbox-start-session. Use when execution may still be running or session availability must be checked; this does not execute work.',\n\tinputSchema: codeSandboxSessionIdInputSchema,\n\toutputSchema: codeSandboxSessionOutputSchema,\n\tsideEffect: 'read',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CodeSandboxClient.fromContext(ctx).getSession(input)\n})\n\nexport const codeSandboxStopSessionTool = defineTool({\n\tid: 'code-sandbox-stop-session',\n\tname: 'stopCodeSandboxSession',\n\tdescription:\n\t\t'Stop a sandbox session created by code-sandbox-start-session and release its temporary resources. Call after sandbox work is complete when the session is no longer needed.',\n\tinputSchema: codeSandboxSessionIdInputSchema,\n\toutputSchema: codeSandboxSessionOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CodeSandboxClient.fromContext(ctx).stopSession(input)\n})\n\nexport const codeSandboxExecuteCodeTool = defineTool({\n\tid: 'code-sandbox-execute-code',\n\tname: 'executeCodeInSandbox',\n\tdescription:\n\t\t'Execute source code in an active sandbox session. Use as a fallback for computation or automation that no purpose-built tool covers. Do not use to build or edit supported documents, spreadsheets, presentations, PDFs, or images.',\n\tinputSchema: codeSandboxExecuteCodeInputSchema,\n\toutputSchema: codeSandboxExecResultSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CodeSandboxClient.fromContext(ctx).executeCode(input)\n})\n\nexport const codeSandboxExecuteCommandTool = defineTool({\n\tid: 'code-sandbox-execute-command',\n\tname: 'executeCommandInSandbox',\n\tdescription:\n\t\t'Run a shell command in an active sandbox session. Use as a fallback for command-line work that no purpose-built tool covers. Do not use command-line libraries to replace dedicated document, spreadsheet, presentation, PDF, or image tools.',\n\tinputSchema: codeSandboxExecuteCommandInputSchema,\n\toutputSchema: codeSandboxExecResultSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CodeSandboxClient.fromContext(ctx).executeCommand(input)\n})\n\nexport const codeSandboxWriteFilesTool = defineTool({\n\tid: 'code-sandbox-write-files',\n\tname: 'writeSandboxFiles',\n\tdescription:\n\t\t'Write one or more UTF-8 files into an active sandbox session for intermediate computation. Sandbox files are temporary and this tool does not return ArtifactRefs. Use a purpose-built builder for final deliverables.',\n\tinputSchema: codeSandboxWriteFilesInputSchema,\n\toutputSchema: codeSandboxWriteFilesOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CodeSandboxClient.fromContext(ctx).writeFiles(input)\n})\n\nexport const codeSandboxReadFilesTool = defineTool({\n\tid: 'code-sandbox-read-files',\n\tname: 'readSandboxFiles',\n\tdescription:\n\t\t'Read one or more UTF-8 files from an active sandbox session. Use only for files produced or imported during the same sandbox workflow; use a format-aware reader for supported user artifacts.',\n\tinputSchema: codeSandboxReadFilesInputSchema,\n\toutputSchema: codeSandboxReadFilesOutputSchema,\n\tsideEffect: 'read',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CodeSandboxClient.fromContext(ctx).readFiles(input)\n})\n\nexport const codeSandboxListFilesTool = defineTool({\n\tid: 'code-sandbox-list-files',\n\tname: 'listSandboxFiles',\n\tdescription:\n\t\t'List temporary files in an active sandbox directory when supported. Use to locate sandbox intermediates, not to discover files in the durable workspace or artifact store.',\n\tinputSchema: codeSandboxListFilesInputSchema,\n\toutputSchema: codeSandboxListFilesOutputSchema,\n\tsideEffect: 'read',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CodeSandboxClient.fromContext(ctx).listFiles(input)\n})\n\nexport const codeSandboxRemoveFilesTool = defineTool({\n\tid: 'code-sandbox-remove-files',\n\tname: 'removeSandboxFiles',\n\tdescription:\n\t\t'Remove temporary files from an active sandbox session. Use only for sandbox cleanup; this does not delete durable workspace files or ArtifactRefs.',\n\tinputSchema: codeSandboxRemoveFilesInputSchema,\n\toutputSchema: codeSandboxRemoveFilesOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CodeSandboxClient.fromContext(ctx).removeFiles(input)\n})\n\nexport const codeSandboxModule = defineModule({\n\tid: 'code-sandbox',\n\ttitle: 'Code Sandbox',\n\tdescription:\n\t\t'General-purpose fallback for arbitrary code, commands, and temporary files when no dedicated tool covers the task. Do not use it instead of purpose-built document, spreadsheet, presentation, PDF, image, or render tools.',\n\truntime: 'both',\n\tauth: { type: 'custom', schema: codeSandboxAuthSchema },\n\tcategories: ['compute', 'sandbox'],\n\tclassification: 'standard',\n\ttags: ['exec', 'workspace'],\n\ttools: [\n\t\tcodeSandboxStartSessionTool,\n\t\tcodeSandboxGetSessionTool,\n\t\tcodeSandboxStopSessionTool,\n\t\tcodeSandboxExecuteCodeTool,\n\t\tcodeSandboxExecuteCommandTool,\n\t\tcodeSandboxWriteFilesTool,\n\t\tcodeSandboxReadFilesTool,\n\t\tcodeSandboxListFilesTool,\n\t\tcodeSandboxRemoveFilesTool\n\t]\n})\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAa,sBAAsB;AACnC,MAAa,yBAAyB;;AAGtC,MAAa,kCAAkC,4BAA4B,OAAO,EACjF,UAAU,EAAE,QAAQ,YAAY,EACjC,CAAC;AAED,MAAa,iCAAiC,0CAA0C,OAAO,EAC9F,UAAU,EAAE,QAAQ,mBAAmB,EACxC,CAAC;AAED,MAAa,wBAAwB,EAAE,mBAAmB,YAAY,CACrE,iCACA,8BACD,CAAC;AAMD,MAAM,YAAY,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,SAAS,uCAAuC;AAE7F,MAAa,qCAAqC,EAAE,OAAO;CAC1D,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,2DAA2D;CAChH,yBAAyB,EACvB,IAAI,CAAC,CACL,IAAI,CAAC,CAAC,CACN,IAAI,KAAM,CAAC,CACX,SAAS,CAAC,CACV,SAAS,4DAA4D;AACxE,CAAC;AAED,MAAa,kCAAkC,EAAE,OAAO,EACvD,YAAY,UACb,CAAC;AAED,MAAa,iCAAiC,EAAE,OAAO;CACtD,YAAY,EAAE,OAAO,CAAC,CAAC,SAAS,oBAAoB;CACpD,QAAQ,EAAE,OAAO,CAA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,IAAI;CACJ,MAAM;CACN,aACC;CACD,aAAa;CACb,cAAc;CACd,YAAY;CACZ,SAAS;CACT,SAAS;CACT,SAAS,OAAO,OAAO,QAAQ,kBAAkB,YAAY,GAAG,CAAC,CAAC,WAAW,KAAK;AACnF,CAAC;AAED,MAAa,2BAA2B,WAAW;CAClD,IAAI;CACJ,MAAM;CACN,aACC;CACD,aAAa;CACb,cAAc;CACd,YAAY;CACZ,SAAS;CACT,SAAS;CACT,SAAS,OAAO,OAAO,QAAQ,kBAAkB,YAAY,GAAG,CAAC,CAAC,UAAU,KAAK;AAClF,CAAC;AAED,MAAa,2BAA2B,WAAW;CAClD,IAAI;CACJ,MAAM;CACN,aACC;CACD,aAAa;CACb,cAAc;CACd,YAAY;CACZ,SAAS;CACT,SAAS;CACT,SAAS,OAAO,OAAO,QAAQ,kBAAkB,YAAY,GAAG,CAAC,CAAC,UAAU,KAAK;AAClF,CAAC;AAED,MAAa,6BAA6B,WAAW;CACpD,IAAI;CACJ,MAAM;CACN,aACC;CACD,aAAa;CACb,cAAc;CACd,YAAY;CACZ,SAAS;CACT,SAAS;CACT,SAAS,OAAO,OAAO,QAAQ,kBAAkB,YAAY,GAAG,CAAC,CAAC,YAAY,KAAK;AACpF,CAAC;AAED,MAAa,oBAAoB,aAAa;CAC7C,IAAI;CACJ,OAAO;CACP,aACC;CACD,SAAS;CACT,MAAM;EAAE,MAAM;EAAU,QAAQ;CAAsB;CACtD,YAAY,CAAC,WAAW,SAAS;CACjC,gBAAgB;CAChB,MAAM,CAAC,QAAQ,WAAW;CAC1B,OAAO;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;AACD,CAAC"}
|
|
@@ -206,11 +206,59 @@ declare const executeCodeInputSchema: z.ZodObject<{
|
|
|
206
206
|
language: z.ZodOptional<z.ZodEnum<{
|
|
207
207
|
javascript: "javascript";
|
|
208
208
|
python: "python";
|
|
209
|
-
shell: "shell";
|
|
210
209
|
typescript: "typescript";
|
|
211
210
|
}>>;
|
|
212
211
|
timeout_ms: z.ZodOptional<z.ZodInt>;
|
|
213
|
-
|
|
212
|
+
context_id: z.ZodOptional<z.ZodString>;
|
|
213
|
+
}, z.core.$strip>;
|
|
214
|
+
declare const createCodeContextInputSchema: z.ZodObject<{
|
|
215
|
+
sandbox_id: z.ZodString;
|
|
216
|
+
language: z.ZodOptional<z.ZodEnum<{
|
|
217
|
+
javascript: "javascript";
|
|
218
|
+
python: "python";
|
|
219
|
+
typescript: "typescript";
|
|
220
|
+
}>>;
|
|
221
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
222
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
223
|
+
timeout_ms: z.ZodOptional<z.ZodInt>;
|
|
224
|
+
}, z.core.$strip>;
|
|
225
|
+
declare const createCodeContextOutputSchema: z.ZodObject<{
|
|
226
|
+
sandbox_id: z.ZodString;
|
|
227
|
+
context_id: z.ZodString;
|
|
228
|
+
language: z.ZodOptional<z.ZodEnum<{
|
|
229
|
+
javascript: "javascript";
|
|
230
|
+
python: "python";
|
|
231
|
+
typescript: "typescript";
|
|
232
|
+
}>>;
|
|
233
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
234
|
+
}, z.core.$strip>;
|
|
235
|
+
declare const listCodeContextsOutputSchema: z.ZodObject<{
|
|
236
|
+
sandbox_id: z.ZodString;
|
|
237
|
+
contexts: z.ZodArray<z.ZodObject<{
|
|
238
|
+
context_id: z.ZodString;
|
|
239
|
+
language: z.ZodOptional<z.ZodString>;
|
|
240
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
241
|
+
}, z.core.$strip>>;
|
|
242
|
+
}, z.core.$strip>;
|
|
243
|
+
declare const deleteCodeContextInputSchema: z.ZodObject<{
|
|
244
|
+
sandbox_id: z.ZodString;
|
|
245
|
+
context_id: z.ZodString;
|
|
246
|
+
}, z.core.$strip>;
|
|
247
|
+
declare const deleteCodeContextOutputSchema: z.ZodObject<{
|
|
248
|
+
sandbox_id: z.ZodString;
|
|
249
|
+
context_id: z.ZodString;
|
|
250
|
+
deleted: z.ZodLiteral<true>;
|
|
251
|
+
}, z.core.$strip>;
|
|
252
|
+
declare const runCodeInputSchema: z.ZodObject<{
|
|
253
|
+
sandbox_id: z.ZodString;
|
|
254
|
+
code: z.ZodString;
|
|
255
|
+
context_id: z.ZodOptional<z.ZodString>;
|
|
256
|
+
language: z.ZodOptional<z.ZodEnum<{
|
|
257
|
+
javascript: "javascript";
|
|
258
|
+
python: "python";
|
|
259
|
+
typescript: "typescript";
|
|
260
|
+
}>>;
|
|
261
|
+
timeout_ms: z.ZodOptional<z.ZodInt>;
|
|
214
262
|
}, z.core.$strip>;
|
|
215
263
|
/**
|
|
216
264
|
* Mount an S3-compatible bucket into the sandbox filesystem.
|
|
@@ -280,6 +328,12 @@ type CreateBridgeSessionOutput = z.infer<typeof createBridgeSessionOutputSchema>
|
|
|
280
328
|
type DeleteBridgeSessionInput = z.infer<typeof deleteBridgeSessionInputSchema>;
|
|
281
329
|
type DeleteBridgeSessionOutput = z.infer<typeof deleteBridgeSessionOutputSchema>;
|
|
282
330
|
type ExecuteCodeInput = z.infer<typeof executeCodeInputSchema>;
|
|
331
|
+
type CreateCodeContextInput = z.infer<typeof createCodeContextInputSchema>;
|
|
332
|
+
type CreateCodeContextOutput = z.infer<typeof createCodeContextOutputSchema>;
|
|
333
|
+
type ListCodeContextsOutput = z.infer<typeof listCodeContextsOutputSchema>;
|
|
334
|
+
type DeleteCodeContextInput = z.infer<typeof deleteCodeContextInputSchema>;
|
|
335
|
+
type DeleteCodeContextOutput = z.infer<typeof deleteCodeContextOutputSchema>;
|
|
336
|
+
type RunCodeInput = z.infer<typeof runCodeInputSchema>;
|
|
283
337
|
type MountBucketInput = z.infer<typeof mountBucketInputSchema>;
|
|
284
338
|
type MountBucketOutput = z.infer<typeof mountBucketOutputSchema>;
|
|
285
339
|
type UnmountBucketInput = z.infer<typeof unmountBucketInputSchema>;
|
|
@@ -305,8 +359,11 @@ declare class CloudflareSandboxClient {
|
|
|
305
359
|
onStdout?: (chunk: string) => void;
|
|
306
360
|
onStderr?: (chunk: string) => void;
|
|
307
361
|
}): Promise<ExecOutput>;
|
|
308
|
-
/** Execute source via python3/node/sh on the bridge (no native runCode route). */
|
|
309
362
|
executeCode(input: ExecuteCodeInput): Promise<ExecOutput>;
|
|
363
|
+
createCodeContext(input: CreateCodeContextInput): Promise<CreateCodeContextOutput>;
|
|
364
|
+
listCodeContexts(input: SandboxIdInput): Promise<ListCodeContextsOutput>;
|
|
365
|
+
deleteCodeContext(input: DeleteCodeContextInput): Promise<DeleteCodeContextOutput>;
|
|
366
|
+
runCode(input: RunCodeInput): Promise<ExecOutput>;
|
|
310
367
|
writeFile(input: WriteFileInput): Promise<WriteFileOutput>;
|
|
311
368
|
readFile(input: ReadFileInput): Promise<ReadFileOutput>;
|
|
312
369
|
writeFiles(input: WriteFilesInput): Promise<WriteFilesOutput>;
|
|
@@ -343,9 +400,6 @@ declare class CloudflareSandboxClient {
|
|
|
343
400
|
}
|
|
344
401
|
//#endregion
|
|
345
402
|
//#region src/vendors/cloudflare-sandbox/domain.d.ts
|
|
346
|
-
/**
|
|
347
|
-
* Cloudflare Sandbox Bridge pure helpers (no HTTP).
|
|
348
|
-
*/
|
|
349
403
|
/** Normalize a host path to the bridge URL segment under /file/… (no leading slash). */
|
|
350
404
|
declare function workspaceFileKey(path: string): string;
|
|
351
405
|
/** Absolute workspace path for shell list/rm (leading slash). */
|
|
@@ -378,8 +432,15 @@ type ParseExecSseOptions = {
|
|
|
378
432
|
* Events: stdout/stderr (base64 data), exit ({"exit_code":N}), error ({"error","code"}).
|
|
379
433
|
*/
|
|
380
434
|
declare function parseExecSse(body: string, options?: ParseExecSseOptions): ParsedExecStream;
|
|
381
|
-
|
|
382
|
-
|
|
435
|
+
type InterpreterLanguage = 'python' | 'javascript' | 'typescript';
|
|
436
|
+
type ParsedRunCode = {
|
|
437
|
+
stdout: string;
|
|
438
|
+
stderr: string;
|
|
439
|
+
success: boolean;
|
|
440
|
+
exit_code: number;
|
|
441
|
+
error?: string;
|
|
442
|
+
};
|
|
443
|
+
declare function parseRunCodePayload(data: unknown): ParsedRunCode;
|
|
383
444
|
//#endregion
|
|
384
445
|
//#region src/vendors/cloudflare-sandbox/module.d.ts
|
|
385
446
|
declare const cloudflareSandboxHealthTool: ToolDefinition<Record<string, never>, {
|
|
@@ -419,9 +480,9 @@ declare const cloudflareSandboxExecTool: ToolDefinition<{
|
|
|
419
480
|
declare const cloudflareSandboxExecuteCodeTool: ToolDefinition<{
|
|
420
481
|
sandbox_id: string;
|
|
421
482
|
code: string;
|
|
422
|
-
language?: "javascript" | "python" | "
|
|
483
|
+
language?: "javascript" | "python" | "typescript" | undefined;
|
|
423
484
|
timeout_ms?: number | undefined;
|
|
424
|
-
|
|
485
|
+
context_id?: string | undefined;
|
|
425
486
|
}, {
|
|
426
487
|
sandbox_id: string;
|
|
427
488
|
stdout: string;
|
|
@@ -561,5 +622,5 @@ declare const cloudflareSandboxModule: ModuleDefinition<{
|
|
|
561
622
|
} | undefined;
|
|
562
623
|
}>;
|
|
563
624
|
//#endregion
|
|
564
|
-
export { type CloudflareSandboxAuth, CloudflareSandboxClient, type CloudflareSandboxClientOptions, type CreateBridgeSessionOutput, type CreateSandboxOutput, DEFAULT_EXEC_TIMEOUT_MS, type DeleteBridgeSessionInput, type DeleteBridgeSessionOutput, type DestroySandboxOutput, type ExecInput, type ExecOutput, type ExecuteCodeInput, type ExportArtifactInput, type ExportArtifactOutput, type HealthOutput, type ImportArtifactInput, type ImportArtifactOutput, type ListFilesInput, type ListFilesOutput, MAX_ARGV, MAX_ARG_CHARS, MAX_EXEC_TIMEOUT_MS, MAX_FILE_BYTES, MAX_FILE_PATH, MAX_FILE_TEXT, MAX_LIST_FILES, MAX_READ_PATHS, MAX_WRITE_FILES, type MountBucketInput, type MountBucketOutput, type ParsedExecStream, type ReadFileInput, type ReadFileOutput, type ReadFilesInput, type ReadFilesOutput, type RemoveFilesInput, type RemoveFilesOutput, type RunningOutput, type SandboxIdInput, type SandboxObjectArtifactRef, type UnmountBucketInput, type UnmountBucketOutput, type WriteFileInput, type WriteFileOutput, type WriteFilesInput, type WriteFilesOutput, cloudflareSandboxAuthSchema, cloudflareSandboxCreateSessionTool, cloudflareSandboxCreateTool, cloudflareSandboxDeleteSessionTool, cloudflareSandboxDestroyTool, cloudflareSandboxExecTool, cloudflareSandboxExecuteCodeTool, cloudflareSandboxExportArtifactTool, cloudflareSandboxHealthTool, cloudflareSandboxImportArtifactTool, cloudflareSandboxListFilesTool, cloudflareSandboxModule, cloudflareSandboxReadFileTool, cloudflareSandboxReadFilesTool, cloudflareSandboxRemoveFilesTool, cloudflareSandboxRunningTool, cloudflareSandboxWriteFileTool, cloudflareSandboxWriteFilesTool, createBridgeSessionOutputSchema, createSandboxOutputSchema, deleteBridgeSessionInputSchema, deleteBridgeSessionOutputSchema, destroySandboxOutputSchema, execInputSchema, execOutputSchema,
|
|
625
|
+
export { type CloudflareSandboxAuth, CloudflareSandboxClient, type CloudflareSandboxClientOptions, type CreateBridgeSessionOutput, type CreateCodeContextInput, type CreateCodeContextOutput, type CreateSandboxOutput, DEFAULT_EXEC_TIMEOUT_MS, type DeleteBridgeSessionInput, type DeleteBridgeSessionOutput, type DeleteCodeContextInput, type DeleteCodeContextOutput, type DestroySandboxOutput, type ExecInput, type ExecOutput, type ExecuteCodeInput, type ExportArtifactInput, type ExportArtifactOutput, type HealthOutput, type ImportArtifactInput, type ImportArtifactOutput, type InterpreterLanguage, type ListCodeContextsOutput, type ListFilesInput, type ListFilesOutput, MAX_ARGV, MAX_ARG_CHARS, MAX_EXEC_TIMEOUT_MS, MAX_FILE_BYTES, MAX_FILE_PATH, MAX_FILE_TEXT, MAX_LIST_FILES, MAX_READ_PATHS, MAX_WRITE_FILES, type MountBucketInput, type MountBucketOutput, type ParsedExecStream, type ParsedRunCode, type ReadFileInput, type ReadFileOutput, type ReadFilesInput, type ReadFilesOutput, type RemoveFilesInput, type RemoveFilesOutput, type RunCodeInput, type RunningOutput, type SandboxIdInput, type SandboxObjectArtifactRef, type UnmountBucketInput, type UnmountBucketOutput, type WriteFileInput, type WriteFileOutput, type WriteFilesInput, type WriteFilesOutput, cloudflareSandboxAuthSchema, cloudflareSandboxCreateSessionTool, cloudflareSandboxCreateTool, cloudflareSandboxDeleteSessionTool, cloudflareSandboxDestroyTool, cloudflareSandboxExecTool, cloudflareSandboxExecuteCodeTool, cloudflareSandboxExportArtifactTool, cloudflareSandboxHealthTool, cloudflareSandboxImportArtifactTool, cloudflareSandboxListFilesTool, cloudflareSandboxModule, cloudflareSandboxReadFileTool, cloudflareSandboxReadFilesTool, cloudflareSandboxRemoveFilesTool, cloudflareSandboxRunningTool, cloudflareSandboxWriteFileTool, cloudflareSandboxWriteFilesTool, createBridgeSessionOutputSchema, createCodeContextInputSchema, createCodeContextOutputSchema, createSandboxOutputSchema, deleteBridgeSessionInputSchema, deleteBridgeSessionOutputSchema, deleteCodeContextInputSchema, deleteCodeContextOutputSchema, destroySandboxOutputSchema, execInputSchema, execOutputSchema, executeCodeInputSchema, exportArtifactInputSchema, exportArtifactOutputSchema, healthOutputSchema, importArtifactInputSchema, importArtifactOutputSchema, listCodeContextsOutputSchema, listFilesInputSchema, listFilesOutputSchema, mountBucketInputSchema, mountBucketOutputSchema, parseExecSse, parseRunCodePayload, readFileInputSchema, readFileOutputSchema, readFilesInputSchema, readFilesOutputSchema, removeFilesInputSchema, removeFilesOutputSchema, resolveWriteFileBytes, runCodeInputSchema, runningOutputSchema, sandboxIdInputSchema, sandboxObjectArtifactRefSchema, shellQuote, unmountBucketInputSchema, unmountBucketOutputSchema, workspaceAbsolutePath, workspaceFileKey, writeFileInputSchema, writeFileOutputSchema, writeFilesInputSchema, writeFilesOutputSchema };
|
|
565
626
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/vendors/cloudflare-sandbox/contracts.ts","../../../src/vendors/cloudflare-sandbox/client.ts","../../../src/vendors/cloudflare-sandbox/domain.ts","../../../src/vendors/cloudflare-sandbox/module.ts"],"mappings":";;;;;cAUa;cACA;cACA;cACA;;cAEA;cACA;cACA;cACA;cACA;cACA;cAEA,6BAA2B,EAAA;;;;;;;;;;;;GAStC,EAAA,KAAA;KAEU,wBAAwB,EAAE,aAAa;;cAGtC,gCAA8B,EAAA;;;;;;GAMzC,EAAA,KAAA;KAEU,2BAA2B,EAAE,aAAa;cAIzC,sBAAoB,EAAA;;GAE/B,EAAA,KAAA;cAEW,2BAAyB,EAAA;;GAEpC,EAAA,KAAA;cAEW,4BAA0B,EAAA;;;GAGrC,EAAA,KAAA;cAEW,qBAAmB,EAAA;;;GAG9B,EAAA,KAAA;cAEW,oBAAkB,EAAA;;GAE7B,EAAA,KAAA;cAEW,iBAAe,EAAA;;;;;;;GAwB1B,EAAA,KAAA;cAEW,kBAAgB,EAAA;;;;;;;;GAQ3B,EAAA,KAAA;cAiCW,sBAAoB,EAAA;;;;;;GAOE,EAAA,KAAA;cAEtB,uBAAqB,EAAA;;;;;GAKhC,EAAA,KAAA;cAEW,qBAAmB,EAAA;;;;;;;;GAQ9B,EAAA,KAAA;cAEW,sBAAoB,EAAA;;;;;;GAM/B,EAAA,KAAA;cAEW,uBAAqB,EAAA;;;;;;;;GAehC,EAAA,KAAA;cAEW,wBAAsB,EAAA;;;;GAIjC,EAAA,KAAA;cAEW,sBAAoB,EAAA;;;;;;;;GAS/B,EAAA,KAAA;cAEW,uBAAqB,EAAA;;;;;;;;GAUhC,EAAA,KAAA;cAEW,sBAAoB,EAAA;;;;GAI/B,EAAA,KAAA;cAEW,uBAAqB,EAAA;;;;GAIhC,EAAA,KAAA;cAEW,wBAAsB,EAAA;;;;GAQjC,EAAA,KAAA;cAEW,yBAAuB,EAAA;;;;GAIlC,EAAA,KAAA;cAEW,2BAAyB,EAAA;;;;;;;;;;;GAKpC,EAAA,KAAA;cAEW,4BAA0B,EAAA;;;;;GAKrC,EAAA,KAAA;cAEW,2BAAyB,EAAA;;;;;GAKpC,EAAA,KAAA;cAEW,4BAA0B,EAAA;;;;;;;;;;GAIrC,EAAA,KAAA;cAEW,iCAA+B,EAAA;;;GAG1C,EAAA,KAAA;cAEW,gCAA8B,EAAA;;;GAGzC,EAAA,KAAA;cAEW,iCAA+B,EAAA;;;;GAI1C,EAAA,KAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/vendors/cloudflare-sandbox/contracts.ts","../../../src/vendors/cloudflare-sandbox/client.ts","../../../src/vendors/cloudflare-sandbox/domain.ts","../../../src/vendors/cloudflare-sandbox/module.ts"],"mappings":";;;;;cAUa;cACA;cACA;cACA;;cAEA;cACA;cACA;cACA;cACA;cACA;cAEA,6BAA2B,EAAA;;;;;;;;;;;;GAStC,EAAA,KAAA;KAEU,wBAAwB,EAAE,aAAa;;cAGtC,gCAA8B,EAAA;;;;;;GAMzC,EAAA,KAAA;KAEU,2BAA2B,EAAE,aAAa;cAIzC,sBAAoB,EAAA;;GAE/B,EAAA,KAAA;cAEW,2BAAyB,EAAA;;GAEpC,EAAA,KAAA;cAEW,4BAA0B,EAAA;;;GAGrC,EAAA,KAAA;cAEW,qBAAmB,EAAA;;;GAG9B,EAAA,KAAA;cAEW,oBAAkB,EAAA;;GAE7B,EAAA,KAAA;cAEW,iBAAe,EAAA;;;;;;;GAwB1B,EAAA,KAAA;cAEW,kBAAgB,EAAA;;;;;;;;GAQ3B,EAAA,KAAA;cAiCW,sBAAoB,EAAA;;;;;;GAOE,EAAA,KAAA;cAEtB,uBAAqB,EAAA;;;;;GAKhC,EAAA,KAAA;cAEW,qBAAmB,EAAA;;;;;;;;GAQ9B,EAAA,KAAA;cAEW,sBAAoB,EAAA;;;;;;GAM/B,EAAA,KAAA;cAEW,uBAAqB,EAAA;;;;;;;;GAehC,EAAA,KAAA;cAEW,wBAAsB,EAAA;;;;GAIjC,EAA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;cAaA,yBAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { CloudflareSandboxClient, DEFAULT_EXEC_TIMEOUT_MS, MAX_ARGV, MAX_ARG_CHARS, MAX_EXEC_TIMEOUT_MS, MAX_FILE_BYTES, MAX_FILE_PATH, MAX_FILE_TEXT, MAX_LIST_FILES, MAX_READ_PATHS, MAX_WRITE_FILES, cloudflareSandboxAuthSchema, cloudflareSandboxCreateSessionTool, cloudflareSandboxCreateTool, cloudflareSandboxDeleteSessionTool, cloudflareSandboxDestroyTool, cloudflareSandboxExecTool, cloudflareSandboxExecuteCodeTool, cloudflareSandboxExportArtifactTool, cloudflareSandboxHealthTool, cloudflareSandboxImportArtifactTool, cloudflareSandboxListFilesTool, cloudflareSandboxModule, cloudflareSandboxReadFileTool, cloudflareSandboxReadFilesTool, cloudflareSandboxRemoveFilesTool, cloudflareSandboxRunningTool, cloudflareSandboxWriteFileTool, cloudflareSandboxWriteFilesTool, createBridgeSessionOutputSchema, createSandboxOutputSchema, deleteBridgeSessionInputSchema, deleteBridgeSessionOutputSchema, destroySandboxOutputSchema, execInputSchema, execOutputSchema,
|
|
1
|
+
import { $ as listCodeContextsOutputSchema, A as MAX_FILE_PATH, B as deleteBridgeSessionInputSchema, C as workspaceAbsolutePath, D as MAX_ARG_CHARS, E as MAX_ARGV, F as cloudflareSandboxAuthSchema, G as execInputSchema, H as deleteCodeContextInputSchema, I as createBridgeSessionOutputSchema, J as exportArtifactInputSchema, K as execOutputSchema, L as createCodeContextInputSchema, M as MAX_LIST_FILES, N as MAX_READ_PATHS, O as MAX_EXEC_TIMEOUT_MS, P as MAX_WRITE_FILES, Q as importArtifactOutputSchema, R as createCodeContextOutputSchema, S as shellQuote, T as DEFAULT_EXEC_TIMEOUT_MS, U as deleteCodeContextOutputSchema, V as deleteBridgeSessionOutputSchema, W as destroySandboxOutputSchema, X as healthOutputSchema, Y as exportArtifactOutputSchema, Z as importArtifactInputSchema, _ as cloudflareSandboxWriteFilesTool, _t as writeFileOutputSchema, a as cloudflareSandboxExecTool, at as readFileOutputSchema, b as parseRunCodePayload, c as cloudflareSandboxHealthTool, ct as removeFilesInputSchema, d as cloudflareSandboxModule, dt as runningOutputSchema, et as listFilesInputSchema, f as cloudflareSandboxReadFileTool, ft as sandboxIdInputSchema, g as cloudflareSandboxWriteFileTool, gt as writeFileInputSchema, h as cloudflareSandboxRunningTool, ht as unmountBucketOutputSchema, i as cloudflareSandboxDestroyTool, it as readFileInputSchema, j as MAX_FILE_TEXT, k as MAX_FILE_BYTES, l as cloudflareSandboxImportArtifactTool, lt as removeFilesOutputSchema, m as cloudflareSandboxRemoveFilesTool, mt as unmountBucketInputSchema, n as cloudflareSandboxCreateTool, nt as mountBucketInputSchema, o as cloudflareSandboxExecuteCodeTool, ot as readFilesInputSchema, p as cloudflareSandboxReadFilesTool, pt as sandboxObjectArtifactRefSchema, q as executeCodeInputSchema, r as cloudflareSandboxDeleteSessionTool, rt as mountBucketOutputSchema, s as cloudflareSandboxExportArtifactTool, st as readFilesOutputSchema, t as cloudflareSandboxCreateSessionTool, tt as listFilesOutputSchema, u as cloudflareSandboxListFilesTool, ut as runCodeInputSchema, v as CloudflareSandboxClient, vt as writeFilesInputSchema, w as workspaceFileKey, x as resolveWriteFileBytes, y as parseExecSse, yt as writeFilesOutputSchema, z as createSandboxOutputSchema } from "../../cloudflare-sandbox-D3rAu9bN.js";
|
|
2
|
+
export { CloudflareSandboxClient, DEFAULT_EXEC_TIMEOUT_MS, MAX_ARGV, MAX_ARG_CHARS, MAX_EXEC_TIMEOUT_MS, MAX_FILE_BYTES, MAX_FILE_PATH, MAX_FILE_TEXT, MAX_LIST_FILES, MAX_READ_PATHS, MAX_WRITE_FILES, cloudflareSandboxAuthSchema, cloudflareSandboxCreateSessionTool, cloudflareSandboxCreateTool, cloudflareSandboxDeleteSessionTool, cloudflareSandboxDestroyTool, cloudflareSandboxExecTool, cloudflareSandboxExecuteCodeTool, cloudflareSandboxExportArtifactTool, cloudflareSandboxHealthTool, cloudflareSandboxImportArtifactTool, cloudflareSandboxListFilesTool, cloudflareSandboxModule, cloudflareSandboxReadFileTool, cloudflareSandboxReadFilesTool, cloudflareSandboxRemoveFilesTool, cloudflareSandboxRunningTool, cloudflareSandboxWriteFileTool, cloudflareSandboxWriteFilesTool, createBridgeSessionOutputSchema, createCodeContextInputSchema, createCodeContextOutputSchema, createSandboxOutputSchema, deleteBridgeSessionInputSchema, deleteBridgeSessionOutputSchema, deleteCodeContextInputSchema, deleteCodeContextOutputSchema, destroySandboxOutputSchema, execInputSchema, execOutputSchema, executeCodeInputSchema, exportArtifactInputSchema, exportArtifactOutputSchema, healthOutputSchema, importArtifactInputSchema, importArtifactOutputSchema, listCodeContextsOutputSchema, listFilesInputSchema, listFilesOutputSchema, mountBucketInputSchema, mountBucketOutputSchema, parseExecSse, parseRunCodePayload, readFileInputSchema, readFileOutputSchema, readFilesInputSchema, readFilesOutputSchema, removeFilesInputSchema, removeFilesOutputSchema, resolveWriteFileBytes, runCodeInputSchema, runningOutputSchema, sandboxIdInputSchema, sandboxObjectArtifactRefSchema, shellQuote, unmountBucketInputSchema, unmountBucketOutputSchema, workspaceAbsolutePath, workspaceFileKey, writeFileInputSchema, writeFileOutputSchema, writeFilesInputSchema, writeFilesOutputSchema };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@5ss/ai-tools",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Reusable AI tools with strict schemas and model-facing contracts. Define once; project to Node, edge, Mastra, AI SDK, TanStack AI, Cloudflare Workers AI, or MCP.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "harryy",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cloudflare-sandbox-BPXbaBOp.js","names":["#http","#storage","#storageAuth","#putFileBytes","#getFileBytes","#requireStorage"],"sources":["../src/vendors/cloudflare-sandbox/contracts.ts","../src/vendors/cloudflare-sandbox/domain.ts","../src/vendors/cloudflare-sandbox/client.ts","../src/vendors/cloudflare-sandbox/module.ts"],"sourcesContent":["/**\n * Cloudflare Sandbox Bridge HTTP API contracts.\n * Host deploys the bridge Worker; this pack is a Bearer client.\n * @see https://developers.cloudflare.com/sandbox/bridge/http-api/\n */\n\nimport { z } from 'zod'\n\nimport { s3AuthSchema } from '../s3/contracts'\n\nexport const MAX_ARGV = 64\nexport const MAX_ARG_CHARS = 100_000\nexport const MAX_FILE_PATH = 1024\nexport const MAX_FILE_TEXT = 2_000_000\n/** Bridge hard cap is 32 MiB; package tool path uses the same bound. */\nexport const MAX_FILE_BYTES = 32 * 1024 * 1024\nexport const MAX_WRITE_FILES = 20\nexport const MAX_READ_PATHS = 50\nexport const MAX_LIST_FILES = 500\nexport const DEFAULT_EXEC_TIMEOUT_MS = 30_000\nexport const MAX_EXEC_TIMEOUT_MS = 600_000\n\nexport const cloudflareSandboxAuthSchema = z.object({\n\tbase_url: z\n\t\t.string()\n\t\t.min(1)\n\t\t.describe('Sandbox bridge Worker origin, for example https://sandbox-bridge.example.workers.dev'),\n\tapi_key: z.string().min(1).describe('Bridge SANDBOX_API_KEY Bearer token'),\n\tstorage: s3AuthSchema\n\t\t.optional()\n\t\t.describe('Optional S3-compatible storage for importArtifact / exportArtifact (ArtifactRef)')\n})\n\nexport type CloudflareSandboxAuth = z.infer<typeof cloudflareSandboxAuthSchema>\n\n/** Object-store ArtifactRef for sandbox import/export. */\nexport const sandboxObjectArtifactRefSchema = z.object({\n\tstore: z.literal('object').describe('Object store containing the artifact'),\n\tkey: z.string().min(1).describe('Object key'),\n\tmedia_type: z.string().min(1).optional().describe('MIME or format hint when known'),\n\tfilename: z.string().min(1).optional().describe('Original or display file name'),\n\tbyte_length: z.int().min(0).optional().describe('Size in bytes when known')\n})\n\nexport type SandboxObjectArtifactRef = z.infer<typeof sandboxObjectArtifactRefSchema>\n\nconst sandboxId = z.string().min(1).max(200).describe('Sandbox id returned by create')\n\nexport const sandboxIdInputSchema = z.object({\n\tsandbox_id: sandboxId\n})\n\nexport const createSandboxOutputSchema = z.object({\n\tsandbox_id: z.string().describe('Created sandbox id')\n})\n\nexport const destroySandboxOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tdestroyed: z.literal(true)\n})\n\nexport const runningOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\trunning: z.boolean().describe('Whether the container is live')\n})\n\nexport const healthOutputSchema = z.object({\n\tok: z.boolean()\n})\n\nexport const execInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\targv: z\n\t\t.array(z.string().min(1).max(MAX_ARG_CHARS))\n\t\t.min(1)\n\t\t.max(MAX_ARGV)\n\t\t.describe('Command argv array (not a shell string). Example: [\"python3\",\"-c\",\"print(1)\"]'),\n\ttimeout_ms: z\n\t\t.int()\n\t\t.min(1)\n\t\t.max(MAX_EXEC_TIMEOUT_MS)\n\t\t.optional()\n\t\t.describe(`Exec timeout in ms (default ${DEFAULT_EXEC_TIMEOUT_MS})`),\n\tcwd: z.string().min(1).max(MAX_FILE_PATH).optional().describe('Working directory (default /workspace)'),\n\tsession_id: z\n\t\t.string()\n\t\t.min(1)\n\t\t.max(200)\n\t\t.optional()\n\t\t.describe('Optional bridge session id for isolated working directory and runtime state'),\n\tenv: z\n\t\t.record(z.string().min(1).max(128), z.string().max(8_192))\n\t\t.optional()\n\t\t.describe('Optional environment variables for the process when the bridge supports env')\n})\n\nexport const execOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tstdout: z.string().describe('Decoded standard output'),\n\tstderr: z.string().describe('Decoded standard error'),\n\texit_code: z.number().int().optional().describe('Process exit code when the stream ends with exit'),\n\tsuccess: z.boolean().describe('True when exit_code is 0'),\n\terror: z.string().optional().describe('Bridge error message when the stream ends with error'),\n\terror_code: z.string().optional().describe('Bridge error code when present')\n})\n\nconst filePathField = z\n\t.string()\n\t.min(1)\n\t.max(MAX_FILE_PATH)\n\t.describe('Path under workspace (with or without /workspace/ prefix)')\n\nconst sessionIdField = z.string().min(1).max(200).optional().describe('Optional Session-Id header')\n\nconst writeFileBodyFields = {\n\ttext: z.string().max(MAX_FILE_TEXT).optional().describe('Utf-8 file contents (omit when body_base64 is set)'),\n\tbody_base64: z\n\t\t.string()\n\t\t.min(1)\n\t\t.optional()\n\t\t.describe('Base64 file bytes for binary content (omit when text is set; max 32 MiB decoded)')\n}\n\nfunction refineExactlyOneBody(\n\tval: { text?: string | undefined; body_base64?: string | undefined },\n\tctx: z.RefinementCtx\n): void {\n\tconst hasText = val.text !== undefined\n\tconst hasB64 = val.body_base64 !== undefined\n\tif (hasText === hasB64) {\n\t\tctx.addIssue({\n\t\t\tcode: 'custom',\n\t\t\tmessage: 'Provide exactly one of text or body_base64'\n\t\t})\n\t}\n}\n\nexport const writeFileInputSchema = z\n\t.object({\n\t\tsandbox_id: sandboxId,\n\t\tpath: filePathField,\n\t\t...writeFileBodyFields,\n\t\tsession_id: sessionIdField\n\t})\n\t.superRefine(refineExactlyOneBody)\n\nexport const writeFileOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tpath: z.string(),\n\tok: z.literal(true),\n\tbyte_length: z.number().int().nonnegative().optional().describe('Decoded byte length written when known')\n})\n\nexport const readFileInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tpath: filePathField,\n\tencoding: z\n\t\t.enum(['utf8', 'base64'])\n\t\t.optional()\n\t\t.describe('Response encoding (default utf8 for text; use base64 for binary)'),\n\tsession_id: sessionIdField\n})\n\nexport const readFileOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tpath: z.string(),\n\ttext: z.string().optional().describe('Utf-8 contents when encoding is utf8 (default)'),\n\tbody_base64: z.string().optional().describe('Base64 contents when encoding is base64'),\n\tbyte_length: z.number().int().nonnegative().optional().describe('Decoded byte length')\n})\n\nexport const writeFilesInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tfiles: z\n\t\t.array(\n\t\t\tz\n\t\t\t\t.object({\n\t\t\t\t\tpath: z.string().min(1).max(MAX_FILE_PATH).describe('Path under workspace'),\n\t\t\t\t\t...writeFileBodyFields\n\t\t\t\t})\n\t\t\t\t.superRefine(refineExactlyOneBody)\n\t\t)\n\t\t.min(1)\n\t\t.max(MAX_WRITE_FILES)\n\t\t.describe('Files to write under workspace (text or body_base64 each)'),\n\tsession_id: sessionIdField\n})\n\nexport const writeFilesOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tpaths: z.array(z.string()),\n\tok: z.literal(true)\n})\n\nexport const readFilesInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tpaths: z\n\t\t.array(z.string().min(1).max(MAX_FILE_PATH).describe('Path under workspace'))\n\t\t.min(1)\n\t\t.max(MAX_READ_PATHS)\n\t\t.describe('Paths to read under workspace'),\n\tencoding: z.enum(['utf8', 'base64']).optional().describe('Response encoding for all files (default utf8)'),\n\tsession_id: sessionIdField\n})\n\nexport const readFilesOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tfiles: z.array(\n\t\tz.object({\n\t\t\tpath: z.string(),\n\t\t\ttext: z.string().optional(),\n\t\t\tbody_base64: z.string().optional(),\n\t\t\tbyte_length: z.number().int().nonnegative().optional()\n\t\t})\n\t)\n})\n\nexport const listFilesInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tdirectory_path: z.string().max(MAX_FILE_PATH).optional().describe('Directory to list (default /workspace)'),\n\tsession_id: sessionIdField\n})\n\nexport const listFilesOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tpaths: z.array(z.string()).describe('Absolute or workspace-relative file paths found'),\n\traw: z.unknown().optional().describe('Provider listing payload when available')\n})\n\nexport const removeFilesInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tpaths: z\n\t\t.array(z.string().min(1).max(MAX_FILE_PATH))\n\t\t.min(1)\n\t\t.max(MAX_READ_PATHS)\n\t\t.describe('Paths to remove under workspace'),\n\tsession_id: sessionIdField\n})\n\nexport const removeFilesOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tpaths: z.array(z.string()),\n\tok: z.literal(true)\n})\n\nexport const importArtifactInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tpath: filePathField,\n\tsource: sandboxObjectArtifactRefSchema.describe('Object-store ArtifactRef to copy into the sandbox'),\n\tsession_id: sessionIdField\n})\n\nexport const importArtifactOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tpath: z.string(),\n\tok: z.literal(true),\n\tbyte_length: z.number().int().nonnegative()\n})\n\nexport const exportArtifactInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tpath: filePathField,\n\tdestination_key: z.string().min(1).describe('Object key to write under bound storage'),\n\tsession_id: sessionIdField\n})\n\nexport const exportArtifactOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tpath: z.string(),\n\tartifact: sandboxObjectArtifactRefSchema\n})\n\nexport const createBridgeSessionOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tsession_id: z.string().describe('Bridge session id for Session-Id header')\n})\n\nexport const deleteBridgeSessionInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tsession_id: z.string().min(1).max(200).describe('Bridge session id to delete')\n})\n\nexport const deleteBridgeSessionOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tsession_id: z.string(),\n\tdeleted: z.literal(true)\n})\n\nexport const executeCodeInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tcode: z.string().min(1).max(MAX_ARG_CHARS).describe('Source code to run'),\n\tlanguage: z\n\t\t.enum(['python', 'javascript', 'typescript', 'shell'])\n\t\t.optional()\n\t\t.describe('Runtime language (default python)'),\n\ttimeout_ms: z\n\t\t.int()\n\t\t.min(1)\n\t\t.max(MAX_EXEC_TIMEOUT_MS)\n\t\t.optional()\n\t\t.describe(`Exec timeout in ms (default ${DEFAULT_EXEC_TIMEOUT_MS})`),\n\tsession_id: z\n\t\t.string()\n\t\t.min(1)\n\t\t.max(200)\n\t\t.optional()\n\t\t.describe('Optional bridge session id for isolated working directory and runtime state')\n})\n\n/**\n * Mount an S3-compatible bucket into the sandbox filesystem.\n * @see https://developers.cloudflare.com/sandbox/bridge/http-api/#bucket-mounts\n *\n * Two bridge modes:\n * - **R2 binding:** omit `endpoint`; `bucket` is the Worker R2 binding name.\n * - **Remote S3/R2/GCS:** set `endpoint` (+ optional credentials; bridge may use Worker secrets).\n */\nexport const mountBucketInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tbucket: z\n\t\t.string()\n\t\t.min(1)\n\t\t.max(256)\n\t\t.describe(\n\t\t\t'R2 Worker binding name when endpoint is omitted; otherwise the remote bucket name (e.g. for S3/R2 endpoint mounts)'\n\t\t),\n\tmount_path: z\n\t\t.string()\n\t\t.min(1)\n\t\t.max(MAX_FILE_PATH)\n\t\t.refine((p) => p.startsWith('/'), { message: 'mount_path must be an absolute path (start with /)' })\n\t\t.describe('Absolute path inside the sandbox to mount at (e.g. /data or /mnt/workspace)'),\n\tendpoint: z\n\t\t.url()\n\t\t.optional()\n\t\t.describe(\n\t\t\t'S3-compatible endpoint URL (e.g. https://s3.amazonaws.com or https://ACCOUNT.r2.cloudflarestorage.com). Omit for Worker R2 binding mounts'\n\t\t),\n\tprovider: z\n\t\t.enum(['r2', 's3', 'gcs'])\n\t\t.optional()\n\t\t.describe('Provider hint for s3fs optimizations when using endpoint mounts'),\n\tread_only: z.boolean().optional().describe('Mount read-only (default false)'),\n\tprefix: z\n\t\t.string()\n\t\t.min(1)\n\t\t.max(MAX_FILE_PATH)\n\t\t.optional()\n\t\t.describe('Bucket prefix/subdirectory to expose at the mount (must start with / when set)'),\n\taccess_key_id: z\n\t\t.string()\n\t\t.min(1)\n\t\t.optional()\n\t\t.describe('Access key for endpoint mounts (maps to bridge credentials.accessKeyId)'),\n\tsecret_access_key: z\n\t\t.string()\n\t\t.min(1)\n\t\t.optional()\n\t\t.describe('Secret key for endpoint mounts (maps to bridge credentials.secretAccessKey)'),\n\tcredential_proxy: z\n\t\t.boolean()\n\t\t.optional()\n\t\t.describe(\n\t\t\t'When true, bridge keeps credentials out of the container (egress signing). Endpoint mounts only; requires ContainerProxy on the bridge Worker'\n\t\t),\n\tlocal_bucket: z\n\t\t.boolean()\n\t\t.optional()\n\t\t.describe('When true, use local R2 binding sync (wrangler dev). Mutually exclusive with endpoint'),\n\ts3fs_options: z\n\t\t.array(z.string().min(1).max(256))\n\t\t.max(32)\n\t\t.optional()\n\t\t.describe('Advanced s3fs mount flags (e.g. use_cache=/tmp/cache)')\n})\n\nexport const mountBucketOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tbucket: z.string(),\n\tmount_path: z.string(),\n\tok: z.literal(true)\n})\n\nexport const unmountBucketInputSchema = z.object({\n\tsandbox_id: sandboxId,\n\tmount_path: z\n\t\t.string()\n\t\t.min(1)\n\t\t.max(MAX_FILE_PATH)\n\t\t.refine((p) => p.startsWith('/'), { message: 'mount_path must be an absolute path (start with /)' })\n\t\t.describe('Absolute mount path previously passed to mount')\n})\n\nexport const unmountBucketOutputSchema = z.object({\n\tsandbox_id: z.string(),\n\tmount_path: z.string(),\n\tok: z.literal(true)\n})\n\nexport type SandboxIdInput = z.infer<typeof sandboxIdInputSchema>\nexport type CreateSandboxOutput = z.infer<typeof createSandboxOutputSchema>\nexport type DestroySandboxOutput = z.infer<typeof destroySandboxOutputSchema>\nexport type RunningOutput = z.infer<typeof runningOutputSchema>\nexport type HealthOutput = z.infer<typeof healthOutputSchema>\nexport type ExecInput = z.infer<typeof execInputSchema>\nexport type ExecOutput = z.infer<typeof execOutputSchema>\nexport type WriteFileInput = z.infer<typeof writeFileInputSchema>\nexport type WriteFileOutput = z.infer<typeof writeFileOutputSchema>\nexport type ReadFileInput = z.infer<typeof readFileInputSchema>\nexport type ReadFileOutput = z.infer<typeof readFileOutputSchema>\nexport type WriteFilesInput = z.infer<typeof writeFilesInputSchema>\nexport type WriteFilesOutput = z.infer<typeof writeFilesOutputSchema>\nexport type ReadFilesInput = z.infer<typeof readFilesInputSchema>\nexport type ReadFilesOutput = z.infer<typeof readFilesOutputSchema>\nexport type ListFilesInput = z.infer<typeof listFilesInputSchema>\nexport type ListFilesOutput = z.infer<typeof listFilesOutputSchema>\nexport type RemoveFilesInput = z.infer<typeof removeFilesInputSchema>\nexport type RemoveFilesOutput = z.infer<typeof removeFilesOutputSchema>\nexport type ImportArtifactInput = z.infer<typeof importArtifactInputSchema>\nexport type ImportArtifactOutput = z.infer<typeof importArtifactOutputSchema>\nexport type ExportArtifactInput = z.infer<typeof exportArtifactInputSchema>\nexport type ExportArtifactOutput = z.infer<typeof exportArtifactOutputSchema>\nexport type CreateBridgeSessionOutput = z.infer<typeof createBridgeSessionOutputSchema>\nexport type DeleteBridgeSessionInput = z.infer<typeof deleteBridgeSessionInputSchema>\nexport type DeleteBridgeSessionOutput = z.infer<typeof deleteBridgeSessionOutputSchema>\nexport type ExecuteCodeInput = z.infer<typeof executeCodeInputSchema>\nexport type MountBucketInput = z.infer<typeof mountBucketInputSchema>\nexport type MountBucketOutput = z.infer<typeof mountBucketOutputSchema>\nexport type UnmountBucketInput = z.infer<typeof unmountBucketInputSchema>\nexport type UnmountBucketOutput = z.infer<typeof unmountBucketOutputSchema>\n","/**\n * Cloudflare Sandbox Bridge pure helpers (no HTTP).\n */\n\nimport { isPlainObject, isString } from 'es-toolkit'\n\nimport { ToolError } from '../../core/errors'\nimport { base64ToBytes, utf8ToBytes } from '../../shared/bytes'\nimport { MAX_FILE_BYTES } from './contracts'\n\n/** Normalize a host path to the bridge URL segment under /file/… (no leading slash). */\nexport function workspaceFileKey(path: string): string {\n\tconst trimmed = path.trim()\n\tif (!trimmed) {\n\t\tthrow new ToolError('File path is empty', { code: 'bad_input' })\n\t}\n\tconst noLead = trimmed.replace(/^\\/+/, '')\n\tconst under = noLead.startsWith('workspace/') ? noLead : `workspace/${noLead}`\n\t// Reject traversal\n\tconst parts = under.split('/')\n\tif (parts.some((p) => p === '..' || p === '')) {\n\t\tthrow new ToolError('File path must stay under workspace', {\n\t\t\tcode: 'bad_input',\n\t\t\tdetails: { path: trimmed }\n\t\t})\n\t}\n\treturn under\n}\n\n/** Absolute workspace path for shell list/rm (leading slash). */\nexport function workspaceAbsolutePath(path: string): string {\n\tconst key = workspaceFileKey(path)\n\treturn `/${key}`\n}\n\n/** Shell-safe single-quoted string. */\nexport function shellQuote(value: string): string {\n\treturn `'${value.replaceAll(\"'\", `'\\\\''`)}'`\n}\n\n/**\n * Resolve write-file body to raw bytes (text UTF-8 or base64).\n * Enforces MAX_FILE_BYTES (bridge limit).\n */\nexport function resolveWriteFileBytes(input: {\n\ttext?: string | undefined\n\tbody_base64?: string | undefined\n}): Uint8Array {\n\tif (input.body_base64 !== undefined && input.text !== undefined) {\n\t\tthrow new ToolError('Provide exactly one of text or body_base64', { code: 'bad_input' })\n\t}\n\tif (input.body_base64 !== undefined) {\n\t\tconst bytes = base64ToBytes(input.body_base64)\n\t\tif (bytes.byteLength > MAX_FILE_BYTES) {\n\t\t\tthrow new ToolError('Sandbox file exceeds max byte limit', {\n\t\t\t\tcode: 'too_large',\n\t\t\t\tdetails: { max_bytes: MAX_FILE_BYTES, content_length: bytes.byteLength }\n\t\t\t})\n\t\t}\n\t\treturn bytes\n\t}\n\tif (input.text !== undefined) {\n\t\tconst bytes = utf8ToBytes(input.text)\n\t\tif (bytes.byteLength > MAX_FILE_BYTES) {\n\t\t\tthrow new ToolError('Sandbox file exceeds max byte limit', {\n\t\t\t\tcode: 'too_large',\n\t\t\t\tdetails: { max_bytes: MAX_FILE_BYTES, content_length: bytes.byteLength }\n\t\t\t})\n\t\t}\n\t\treturn bytes\n\t}\n\tthrow new ToolError('Provide exactly one of text or body_base64', { code: 'bad_input' })\n}\n\nexport type ParsedExecStream = {\n\tstdout: string\n\tstderr: string\n\texit_code?: number\n\terror?: string\n\terror_code?: string\n}\n\nexport type ParseExecSseOptions = {\n\t/** Called for each stdout chunk as the SSE body is walked (buffer may still be complete). */\n\tonStdout?: (chunk: string) => void\n\t/** Called for each stderr chunk as the SSE body is walked. */\n\tonStderr?: (chunk: string) => void\n}\n\n/**\n * Parse bridge /exec text/event-stream body.\n * Events: stdout/stderr (base64 data), exit ({\"exit_code\":N}), error ({\"error\",\"code\"}).\n */\nexport function parseExecSse(body: string, options: ParseExecSseOptions = {}): ParsedExecStream {\n\tconst stdoutChunks: string[] = []\n\tconst stderrChunks: string[] = []\n\tlet exit_code: number | undefined\n\tlet error: string | undefined\n\tlet error_code: string | undefined\n\n\tconst blocks = body.replaceAll('\\r\\n', '\\n').split('\\n\\n')\n\tfor (const block of blocks) {\n\t\tconst lines = block.split('\\n').filter((line) => line.length > 0)\n\t\tif (lines.length === 0) continue\n\t\tlet event = 'message'\n\t\tconst dataLines: string[] = []\n\t\tfor (const line of lines) {\n\t\t\tif (line.startsWith('event:')) {\n\t\t\t\tevent = line.slice(6).trim()\n\t\t\t} else if (line.startsWith('data:')) {\n\t\t\t\tdataLines.push(line.slice(5).trimStart())\n\t\t\t}\n\t\t}\n\t\tconst data = dataLines.join('\\n')\n\t\tif (event === 'stdout' && data.length > 0) {\n\t\t\tconst chunk = decodeBase64Chunk(data)\n\t\t\tstdoutChunks.push(chunk)\n\t\t\toptions.onStdout?.(chunk)\n\t\t} else if (event === 'stderr' && data.length > 0) {\n\t\t\tconst chunk = decodeBase64Chunk(data)\n\t\t\tstderrChunks.push(chunk)\n\t\t\toptions.onStderr?.(chunk)\n\t\t} else if (event === 'exit' && data.length > 0) {\n\t\t\tconst parsed = safeJson(data)\n\t\t\tif (isPlainObject(parsed)) {\n\t\t\t\tconst code = parsed['exit_code']\n\t\t\t\tif (typeof code === 'number' && Number.isFinite(code)) exit_code = code\n\t\t\t}\n\t\t} else if (event === 'error' && data.length > 0) {\n\t\t\tconst parsed = safeJson(data)\n\t\t\tif (isPlainObject(parsed)) {\n\t\t\t\tif (isString(parsed['error'])) error = parsed['error']\n\t\t\t\tif (isString(parsed['code'])) error_code = parsed['code']\n\t\t\t} else {\n\t\t\t\terror = data\n\t\t\t}\n\t\t}\n\t}\n\n\tconst out: ParsedExecStream = {\n\t\tstdout: stdoutChunks.join(''),\n\t\tstderr: stderrChunks.join('')\n\t}\n\tif (exit_code !== undefined) out.exit_code = exit_code\n\tif (error !== undefined) out.error = error\n\tif (error_code !== undefined) out.error_code = error_code\n\treturn out\n}\n\nfunction decodeBase64Chunk(data: string): string {\n\ttry {\n\t\t// Bun/Node Buffer or atob\n\t\tif (typeof Buffer !== 'undefined') {\n\t\t\treturn Buffer.from(data, 'base64').toString('utf8')\n\t\t}\n\t\tconst binary = atob(data)\n\t\tconst bytes = new Uint8Array(binary.length)\n\t\tfor (let i = 0; i < binary.length; i += 1) bytes[i] = binary.charCodeAt(i)\n\t\treturn new TextDecoder().decode(bytes)\n\t} catch {\n\t\treturn data\n\t}\n}\n\nfunction safeJson(text: string): unknown {\n\ttry {\n\t\tconst value: unknown = JSON.parse(text)\n\t\treturn value\n\t} catch {\n\t\treturn undefined\n\t}\n}\n\n/** Build argv for executeCode over the bridge (no native runCode route). */\nexport function executeCodeArgv(language: string, code: string): string[] {\n\tswitch (language) {\n\t\tcase 'javascript':\n\t\tcase 'typescript':\n\t\t\treturn ['node', '-e', code]\n\t\tcase 'shell':\n\t\t\treturn ['sh', '-lc', code]\n\t\tcase 'python':\n\t\tdefault:\n\t\t\treturn ['python3', '-c', code]\n\t}\n}\n","/**\n * Cloudflare Sandbox Bridge vendor client (HttpService + Bearer).\n * Host: `new CloudflareSandboxClient(auth)`. Agent: `fromContext(ctx)`.\n * Gold: `src/vendors/resend/client.ts` + messaging ArtifactRef storage pattern.\n * @see https://developers.cloudflare.com/sandbox/bridge/http-api/\n */\n\nimport { isPlainObject, isString, trimEnd } from 'es-toolkit'\n\nimport { ToolError } from '../../core/errors'\nimport { requireAuth } from '../../core/provider'\nimport type { ToolContext } from '../../core/types'\nimport { bytesToBase64, bytesToUtf8, toArrayBuffer } from '../../shared/bytes'\nimport { HttpService } from '../../transport/http-service'\nimport type { HttpServiceOptions } from '../../transport/http-service'\nimport { S3Client } from '../s3'\nimport type {\n\tCloudflareSandboxAuth,\n\tCreateBridgeSessionOutput,\n\tCreateSandboxOutput,\n\tDeleteBridgeSessionInput,\n\tDeleteBridgeSessionOutput,\n\tDestroySandboxOutput,\n\tExecInput,\n\tExecOutput,\n\tExecuteCodeInput,\n\tExportArtifactInput,\n\tExportArtifactOutput,\n\tHealthOutput,\n\tImportArtifactInput,\n\tImportArtifactOutput,\n\tListFilesInput,\n\tListFilesOutput,\n\tMountBucketInput,\n\tMountBucketOutput,\n\tReadFileInput,\n\tReadFileOutput,\n\tReadFilesInput,\n\tReadFilesOutput,\n\tRemoveFilesInput,\n\tRemoveFilesOutput,\n\tRunningOutput,\n\tSandboxIdInput,\n\tUnmountBucketInput,\n\tUnmountBucketOutput,\n\tWriteFileInput,\n\tWriteFileOutput,\n\tWriteFilesInput,\n\tWriteFilesOutput\n} from './contracts'\nimport {\n\tDEFAULT_EXEC_TIMEOUT_MS,\n\tMAX_FILE_BYTES,\n\tMAX_LIST_FILES,\n\tcloudflareSandboxAuthSchema,\n\tmountBucketInputSchema,\n\tunmountBucketInputSchema\n} from './contracts'\nimport {\n\texecuteCodeArgv,\n\tparseExecSse,\n\tresolveWriteFileBytes,\n\tshellQuote,\n\tworkspaceAbsolutePath,\n\tworkspaceFileKey\n} from './domain'\n\nexport type CloudflareSandboxClientOptions = Pick<HttpServiceOptions, 'fetch' | 'signal'>\n\nexport class CloudflareSandboxClient {\n\treadonly #http: HttpService\n\treadonly #storage: S3Client | undefined\n\t/** Optional S3 auth fields for endpoint mount credential fallback (Mastra workspace FS). */\n\treadonly #storageAuth:\n\t\t| {\n\t\t\t\taccess_key_id: string\n\t\t\t\tsecret_access_key: string\n\t\t\t\tendpoint?: string | undefined\n\t\t }\n\t\t| undefined\n\n\tconstructor(auth: CloudflareSandboxAuth, options: CloudflareSandboxClientOptions = {}) {\n\t\tconst parsed = cloudflareSandboxAuthSchema.safeParse(auth)\n\t\tif (!parsed.success) {\n\t\t\tthrow new ToolError('Invalid Cloudflare Sandbox auth credentials', {\n\t\t\t\tcode: 'bad_auth',\n\t\t\t\tdetails: { issues: parsed.error.issues.map((issue) => issue.message) }\n\t\t\t})\n\t\t}\n\t\tthis.#http = new HttpService({\n\t\t\tbaseURL: trimEnd(parsed.data.base_url, '/'),\n\t\t\theaders: {\n\t\t\t\tAuthorization: `Bearer ${parsed.data.api_key}`\n\t\t\t},\n\t\t\ttimeout: 120_000,\n\t\t\tlabel: 'Cloudflare Sandbox',\n\t\t\t...(options.fetch && { fetch: options.fetch }),\n\t\t\t...(options.signal && { signal: options.signal })\n\t\t})\n\t\tthis.#storage = parsed.data.storage\n\t\t\t? new S3Client(parsed.data.storage, {\n\t\t\t\t\t...(options.fetch && { fetch: options.fetch }),\n\t\t\t\t\t...(options.signal && { signal: options.signal })\n\t\t\t\t})\n\t\t\t: undefined\n\t\tthis.#storageAuth = parsed.data.storage\n\t\t\t? {\n\t\t\t\t\taccess_key_id: parsed.data.storage.access_key_id,\n\t\t\t\t\tsecret_access_key: parsed.data.storage.secret_access_key,\n\t\t\t\t\t...(parsed.data.storage.endpoint && { endpoint: parsed.data.storage.endpoint })\n\t\t\t\t}\n\t\t\t: undefined\n\t}\n\n\tstatic fromContext(ctx: ToolContext): CloudflareSandboxClient {\n\t\treturn new CloudflareSandboxClient(requireAuth(ctx, cloudflareSandboxAuthSchema), {\n\t\t\t...(ctx.fetch && { fetch: ctx.fetch }),\n\t\t\t...(ctx.signal && { signal: ctx.signal })\n\t\t})\n\t}\n\n\t/** Liveness probe on the bridge. */\n\tasync health(): Promise<HealthOutput> {\n\t\tconst { data } = await this.#http.get('/health', {\n\t\t\tlabel: 'Cloudflare Sandbox health'\n\t\t})\n\t\tif (isPlainObject(data) && data['ok'] === true) return { ok: true }\n\t\tif (isPlainObject(data) && data['ok'] === false) return { ok: false }\n\t\treturn { ok: true }\n\t}\n\n\tasync create(): Promise<CreateSandboxOutput> {\n\t\tconst { data } = await this.#http.post('/v1/sandbox', undefined, {\n\t\t\tlabel: 'Cloudflare Sandbox create'\n\t\t})\n\t\tif (!isPlainObject(data) || !isString(data['id'])) {\n\t\t\tthrow new ToolError('Unexpected create sandbox response', { code: 'upstream' })\n\t\t}\n\t\treturn { sandbox_id: data['id'] }\n\t}\n\n\tasync destroy(input: SandboxIdInput): Promise<DestroySandboxOutput> {\n\t\tawait this.#http.delete(`/v1/sandbox/${encodeURIComponent(input.sandbox_id)}`, {\n\t\t\tlabel: 'Cloudflare Sandbox destroy'\n\t\t})\n\t\treturn { sandbox_id: input.sandbox_id, destroyed: true }\n\t}\n\n\tasync running(input: SandboxIdInput): Promise<RunningOutput> {\n\t\tconst { data } = await this.#http.get(`/v1/sandbox/${encodeURIComponent(input.sandbox_id)}/running`, {\n\t\t\tlabel: 'Cloudflare Sandbox running'\n\t\t})\n\t\tif (!isPlainObject(data) || typeof data['running'] !== 'boolean') {\n\t\t\tthrow new ToolError('Unexpected running response', { code: 'upstream' })\n\t\t}\n\t\treturn { sandbox_id: input.sandbox_id, running: data['running'] }\n\t}\n\n\t/**\n\t * Run a command. Bridge returns text/event-stream (stdout/stderr base64 + exit).\n\t * Uses HttpService.bytes so ofetch does not try to JSON-parse the SSE body.\n\t * Optional onStdout/onStderr fire while walking the buffered SSE (not true wire streaming).\n\t */\n\tasync exec(\n\t\tinput: ExecInput,\n\t\tstream: { onStdout?: (chunk: string) => void; onStderr?: (chunk: string) => void } = {}\n\t): Promise<ExecOutput> {\n\t\tconst body: Record<string, unknown> = {\n\t\t\targv: input.argv,\n\t\t\ttimeout_ms: input.timeout_ms ?? DEFAULT_EXEC_TIMEOUT_MS\n\t\t}\n\t\tif (input.cwd) body['cwd'] = input.cwd\n\t\tif (input.env && Object.keys(input.env).length > 0) body['env'] = input.env\n\n\t\tconst headers: Record<string, string> = {\n\t\t\t'Content-Type': 'application/json',\n\t\t\tAccept: 'text/event-stream'\n\t\t}\n\t\tif (input.session_id) headers['Session-Id'] = input.session_id\n\n\t\tconst { bytes } = await this.#http.bytes('POST', `/v1/sandbox/${encodeURIComponent(input.sandbox_id)}/exec`, {\n\t\t\tbody,\n\t\t\theaders,\n\t\t\tlabel: 'Cloudflare Sandbox exec'\n\t\t})\n\t\tconst text = new TextDecoder().decode(bytes)\n\t\tconst parsed = parseExecSse(text, {\n\t\t\t...(stream.onStdout && { onStdout: stream.onStdout }),\n\t\t\t...(stream.onStderr && { onStderr: stream.onStderr })\n\t\t})\n\t\tif (parsed.error && parsed.exit_code === undefined) {\n\t\t\tthrow new ToolError(parsed.error, {\n\t\t\t\tcode: 'upstream',\n\t\t\t\tdetails: {\n\t\t\t\t\t...(parsed.error_code && { error_code: parsed.error_code }),\n\t\t\t\t\tsandbox_id: input.sandbox_id\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t\tconst exit_code = parsed.exit_code ?? (parsed.error ? 1 : 0)\n\t\tconst out: ExecOutput = {\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\tstdout: parsed.stdout,\n\t\t\tstderr: parsed.stderr,\n\t\t\texit_code,\n\t\t\tsuccess: exit_code === 0\n\t\t}\n\t\tif (parsed.error) out.error = parsed.error\n\t\tif (parsed.error_code) out.error_code = parsed.error_code\n\t\treturn out\n\t}\n\n\t/** Execute source via python3/node/sh on the bridge (no native runCode route). */\n\tasync executeCode(input: ExecuteCodeInput): Promise<ExecOutput> {\n\t\tconst language = input.language ?? 'python'\n\t\treturn this.exec({\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\targv: executeCodeArgv(language, input.code),\n\t\t\t...(input.timeout_ms !== undefined && { timeout_ms: input.timeout_ms }),\n\t\t\t...(input.session_id && { session_id: input.session_id })\n\t\t})\n\t}\n\n\tasync writeFile(input: WriteFileInput): Promise<WriteFileOutput> {\n\t\tconst bytes = resolveWriteFileBytes(input)\n\t\tawait this.#putFileBytes(input.sandbox_id, input.path, bytes, input.session_id)\n\t\treturn {\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\tpath: input.path,\n\t\t\tok: true,\n\t\t\tbyte_length: bytes.byteLength\n\t\t}\n\t}\n\n\tasync readFile(input: ReadFileInput): Promise<ReadFileOutput> {\n\t\tconst bytes = await this.#getFileBytes(input.sandbox_id, input.path, input.session_id)\n\t\tconst encoding = input.encoding ?? 'utf8'\n\t\tconst out: ReadFileOutput = {\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\tpath: input.path,\n\t\t\tbyte_length: bytes.byteLength\n\t\t}\n\t\tif (encoding === 'base64') {\n\t\t\tout.body_base64 = bytesToBase64(bytes)\n\t\t} else {\n\t\t\tout.text = bytesToUtf8(bytes)\n\t\t}\n\t\treturn out\n\t}\n\n\tasync writeFiles(input: WriteFilesInput): Promise<WriteFilesOutput> {\n\t\tconst paths: string[] = []\n\t\tfor (const file of input.files) {\n\t\t\tawait this.writeFile({\n\t\t\t\tsandbox_id: input.sandbox_id,\n\t\t\t\tpath: file.path,\n\t\t\t\t...(file.text !== undefined && { text: file.text }),\n\t\t\t\t...(file.body_base64 !== undefined && { body_base64: file.body_base64 }),\n\t\t\t\t...(input.session_id && { session_id: input.session_id })\n\t\t\t})\n\t\t\tpaths.push(file.path)\n\t\t}\n\t\treturn { sandbox_id: input.sandbox_id, paths, ok: true }\n\t}\n\n\tasync readFiles(input: ReadFilesInput): Promise<ReadFilesOutput> {\n\t\tconst files: ReadFilesOutput['files'] = []\n\t\tfor (const path of input.paths) {\n\t\t\tconst row = await this.readFile({\n\t\t\t\tsandbox_id: input.sandbox_id,\n\t\t\t\tpath,\n\t\t\t\t...(input.encoding && { encoding: input.encoding }),\n\t\t\t\t...(input.session_id && { session_id: input.session_id })\n\t\t\t})\n\t\t\tfiles.push({\n\t\t\t\tpath: row.path,\n\t\t\t\t...(row.text !== undefined && { text: row.text }),\n\t\t\t\t...(row.body_base64 !== undefined && { body_base64: row.body_base64 }),\n\t\t\t\t...(row.byte_length !== undefined && { byte_length: row.byte_length })\n\t\t\t})\n\t\t}\n\t\treturn { sandbox_id: input.sandbox_id, files }\n\t}\n\n\t/** List files via find in the workspace (bridge has no list route). */\n\tasync listFiles(input: ListFilesInput): Promise<ListFilesOutput> {\n\t\tconst dir = input.directory_path?.trim() || '/workspace'\n\t\tconst abs = dir.startsWith('/') ? dir : workspaceAbsolutePath(dir)\n\t\tconst out = await this.exec({\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\targv: ['sh', '-lc', `find ${shellQuote(abs)} -maxdepth 4 -type f 2>/dev/null | head -n ${MAX_LIST_FILES}`],\n\t\t\t...(input.session_id && { session_id: input.session_id })\n\t\t})\n\t\tconst paths = out.stdout\n\t\t\t.split('\\n')\n\t\t\t.map((line) => line.trim())\n\t\t\t.filter((line) => line.length > 0)\n\t\treturn {\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\tpaths,\n\t\t\traw: { stdout: out.stdout, stderr: out.stderr, exit_code: out.exit_code }\n\t\t}\n\t}\n\n\t/** Remove files via rm (bridge has no delete-file route). */\n\tasync removeFiles(input: RemoveFilesInput): Promise<RemoveFilesOutput> {\n\t\tfor (const path of input.paths) {\n\t\t\tconst abs = path.startsWith('/') ? path : workspaceAbsolutePath(path)\n\t\t\tawait this.exec({\n\t\t\t\tsandbox_id: input.sandbox_id,\n\t\t\t\targv: ['rm', '-f', '--', abs],\n\t\t\t\t...(input.session_id && { session_id: input.session_id })\n\t\t\t})\n\t\t}\n\t\treturn { sandbox_id: input.sandbox_id, paths: input.paths, ok: true }\n\t}\n\n\t/**\n\t * Copy an object-store ArtifactRef into the sandbox workspace.\n\t * Requires auth.storage.\n\t */\n\tasync importArtifact(input: ImportArtifactInput): Promise<ImportArtifactOutput> {\n\t\tconst storage = this.#requireStorage('importArtifact')\n\t\tif (input.source.store !== 'object') {\n\t\t\tthrow new ToolError('Sandbox importArtifact only supports store=object ArtifactRefs', {\n\t\t\t\tcode: 'bad_input'\n\t\t\t})\n\t\t}\n\t\tconst bytes = await storage.getBytes(input.source.key, { maxBytes: MAX_FILE_BYTES })\n\t\tawait this.#putFileBytes(input.sandbox_id, input.path, bytes, input.session_id)\n\t\treturn {\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\tpath: input.path,\n\t\t\tok: true,\n\t\t\tbyte_length: bytes.byteLength\n\t\t}\n\t}\n\n\t/**\n\t * Copy a sandbox workspace file to object storage and return an ArtifactRef.\n\t * Requires auth.storage.\n\t */\n\tasync exportArtifact(input: ExportArtifactInput): Promise<ExportArtifactOutput> {\n\t\tconst storage = this.#requireStorage('exportArtifact')\n\t\tconst bytes = await this.#getFileBytes(input.sandbox_id, input.path, input.session_id)\n\t\tawait storage.putBytes(input.destination_key, bytes)\n\t\treturn {\n\t\t\tsandbox_id: input.sandbox_id,\n\t\t\tpath: input.path,\n\t\t\tartifact: {\n\t\t\t\tstore: 'object',\n\t\t\t\tkey: input.destination_key,\n\t\t\t\tbyte_length: bytes.byteLength\n\t\t\t}\n\t\t}\n\t}\n\n\tasync createSession(input: SandboxIdInput): Promise<CreateBridgeSessionOutput> {\n\t\tconst { data } = await this.#http.post(`/v1/sandbox/${encodeURIComponent(input.sandbox_id)}/session`, undefined, {\n\t\t\tlabel: 'Cloudflare Sandbox createSession'\n\t\t})\n\t\tif (!isPlainObject(data) || !isString(data['id'])) {\n\t\t\tthrow new ToolError('Unexpected create session response', { code: 'upstream' })\n\t\t}\n\t\treturn { sandbox_id: input.sandbox_id, session_id: data['id'] }\n\t}\n\n\tasync deleteSession(input: DeleteBridgeSessionInput): Promise<DeleteBridgeSessionOutput> {\n\t\tawait this.#http.delete(\n\t\t\t`/v1/sandbox/${encodeURIComponent(input.sandbox_id)}/session/${encodeURIComponent(input.session_id)}`,\n\t\t\t{ label: 'Cloudflare Sandbox deleteSession' }\n\t\t)\n\t\treturn { sandbox_id: input.sandbox_id, session_id: input.session_id, deleted: true }\n\t}\n\n\t/**\n\t * Mount an S3-compatible bucket (or Worker R2 binding) at an absolute path in the sandbox.\n\t * Bridge: `POST /v1/sandbox/:id/mount`.\n\t * For Mastra / host workspace S3 FS: pass `endpoint` + credentials (or rely on auth.storage).\n\t * @see https://developers.cloudflare.com/sandbox/bridge/http-api/#bucket-mounts\n\t */\n\tasync mount(input: MountBucketInput): Promise<MountBucketOutput> {\n\t\tconst parsed = mountBucketInputSchema.safeParse(input)\n\t\tif (!parsed.success) {\n\t\t\tthrow new ToolError('Invalid sandbox mount input', {\n\t\t\t\tcode: 'bad_input',\n\t\t\t\tdetails: { issues: parsed.error.issues.map((issue) => issue.message) }\n\t\t\t})\n\t\t}\n\t\tconst data = parsed.data\n\t\tif (data.local_bucket && data.endpoint) {\n\t\t\tthrow new ToolError('local_bucket and endpoint are mutually exclusive on mount', { code: 'bad_input' })\n\t\t}\n\t\tif (data.prefix !== undefined && !data.prefix.startsWith('/')) {\n\t\t\tthrow new ToolError('mount prefix must start with /', { code: 'bad_input' })\n\t\t}\n\n\t\t// Endpoint mounts only: omit endpoint for Worker R2 binding mounts.\n\t\tconst endpoint = data.local_bucket ? undefined : data.endpoint\n\t\t// Credentials: explicit input, else auth.storage when doing an endpoint mount (Mastra S3 FS).\n\t\tconst accessKeyId = data.access_key_id ?? (endpoint !== undefined ? this.#storageAuth?.access_key_id : undefined)\n\t\tconst secretAccessKey =\n\t\t\tdata.secret_access_key ?? (endpoint !== undefined ? this.#storageAuth?.secret_access_key : undefined)\n\n\t\tconst options: Record<string, unknown> = {}\n\t\tif (endpoint) options['endpoint'] = endpoint\n\t\tif (data.provider) options['provider'] = data.provider\n\t\tif (data.read_only !== undefined) options['readOnly'] = data.read_only\n\t\tif (data.prefix) options['prefix'] = data.prefix\n\t\tif (data.credential_proxy !== undefined) options['credentialProxy'] = data.credential_proxy\n\t\tif (data.local_bucket) options['localBucket'] = true\n\t\tif (data.s3fs_options && data.s3fs_options.length > 0) options['s3fsOptions'] = data.s3fs_options\n\t\tif (endpoint && accessKeyId && secretAccessKey) {\n\t\t\toptions['credentials'] = {\n\t\t\t\taccessKeyId,\n\t\t\t\tsecretAccessKey\n\t\t\t}\n\t\t}\n\n\t\tconst body: Record<string, unknown> = {\n\t\t\tmountPath: data.mount_path,\n\t\t\toptions\n\t\t}\n\t\tif (endpoint) body['bucket'] = data.bucket\n\t\telse body['binding'] = data.bucket\n\n\t\tawait this.#http.post(`/v1/sandbox/${encodeURIComponent(data.sandbox_id)}/mount`, body, {\n\t\t\tlabel: 'Cloudflare Sandbox mount'\n\t\t})\n\t\treturn {\n\t\t\tsandbox_id: data.sandbox_id,\n\t\t\tbucket: data.bucket,\n\t\t\tmount_path: data.mount_path,\n\t\t\tok: true\n\t\t}\n\t}\n\n\t/**\n\t * Unmount a previously mounted bucket path.\n\t * Bridge: `POST /v1/sandbox/:id/unmount` with `{ mountPath }`.\n\t * Mounts are also cleared when the sandbox is destroyed.\n\t */\n\tasync unmount(input: UnmountBucketInput): Promise<UnmountBucketOutput> {\n\t\tconst parsed = unmountBucketInputSchema.safeParse(input)\n\t\tif (!parsed.success) {\n\t\t\tthrow new ToolError('Invalid sandbox unmount input', {\n\t\t\t\tcode: 'bad_input',\n\t\t\t\tdetails: { issues: parsed.error.issues.map((issue) => issue.message) }\n\t\t\t})\n\t\t}\n\t\tconst data = parsed.data\n\t\tawait this.#http.post(\n\t\t\t`/v1/sandbox/${encodeURIComponent(data.sandbox_id)}/unmount`,\n\t\t\t{ mountPath: data.mount_path },\n\t\t\t{ label: 'Cloudflare Sandbox unmount' }\n\t\t)\n\t\treturn {\n\t\t\tsandbox_id: data.sandbox_id,\n\t\t\tmount_path: data.mount_path,\n\t\t\tok: true\n\t\t}\n\t}\n\n\t#requireStorage(op: string): S3Client {\n\t\tif (!this.#storage) {\n\t\t\tthrow new ToolError(`${op} requires storage credentials on sandbox auth`, {\n\t\t\t\tcode: 'bad_auth'\n\t\t\t})\n\t\t}\n\t\treturn this.#storage\n\t}\n\n\tasync #putFileBytes(\n\t\tsandboxId: string,\n\t\tpath: string,\n\t\tbytes: Uint8Array,\n\t\tsessionId: string | undefined\n\t): Promise<void> {\n\t\tconst key = workspaceFileKey(path)\n\t\tconst headers: Record<string, string> = {\n\t\t\t'Content-Type': 'application/octet-stream'\n\t\t}\n\t\tif (sessionId) headers['Session-Id'] = sessionId\n\t\tconst { data } = await this.#http.put(\n\t\t\t`/v1/sandbox/${encodeURIComponent(sandboxId)}/file/${key.split('/').map(encodeURIComponent).join('/')}`,\n\t\t\ttoArrayBuffer(bytes),\n\t\t\t{ headers, label: 'Cloudflare Sandbox writeFile' }\n\t\t)\n\t\tif (isPlainObject(data) && data['ok'] === false) {\n\t\t\tthrow new ToolError('Sandbox writeFile failed', { code: 'upstream' })\n\t\t}\n\t}\n\n\tasync #getFileBytes(sandboxId: string, path: string, sessionId: string | undefined): Promise<Uint8Array> {\n\t\tconst key = workspaceFileKey(path)\n\t\tconst headers: Record<string, string> = {}\n\t\tif (sessionId) headers['Session-Id'] = sessionId\n\t\tconst { bytes } = await this.#http.bytes(\n\t\t\t'GET',\n\t\t\t`/v1/sandbox/${encodeURIComponent(sandboxId)}/file/${key.split('/').map(encodeURIComponent).join('/')}`,\n\t\t\t{ headers, label: 'Cloudflare Sandbox readFile', maxBytes: MAX_FILE_BYTES }\n\t\t)\n\t\treturn bytes\n\t}\n}\n","import { z } from 'zod'\n\nimport { defineModule, defineTool } from '../../core/define'\nimport { CloudflareSandboxClient } from './client'\nimport {\n\tcloudflareSandboxAuthSchema,\n\tcreateBridgeSessionOutputSchema,\n\tcreateSandboxOutputSchema,\n\tdeleteBridgeSessionInputSchema,\n\tdeleteBridgeSessionOutputSchema,\n\tdestroySandboxOutputSchema,\n\texecInputSchema,\n\texecOutputSchema,\n\texecuteCodeInputSchema,\n\texportArtifactInputSchema,\n\texportArtifactOutputSchema,\n\thealthOutputSchema,\n\timportArtifactInputSchema,\n\timportArtifactOutputSchema,\n\tlistFilesInputSchema,\n\tlistFilesOutputSchema,\n\treadFileInputSchema,\n\treadFileOutputSchema,\n\treadFilesInputSchema,\n\treadFilesOutputSchema,\n\tremoveFilesInputSchema,\n\tremoveFilesOutputSchema,\n\trunningOutputSchema,\n\tsandboxIdInputSchema,\n\twriteFileInputSchema,\n\twriteFileOutputSchema,\n\twriteFilesInputSchema,\n\twriteFilesOutputSchema\n} from './contracts'\n\nconst id = 'cloudflare-sandbox'\nconst emptyInputSchema = z.object({})\n\nexport const cloudflareSandboxHealthTool = defineTool({\n\tid: `${id}-health`,\n\tname: 'cloudflareSandboxHealth',\n\tdescription:\n\t\t'Check whether the Cloudflare Sandbox bridge is reachable. Use only for explicit availability diagnostics; ordinary sandbox work should begin with cloudflare-sandbox-create.',\n\tinputSchema: emptyInputSchema,\n\toutputSchema: healthOutputSchema,\n\tsideEffect: 'read',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (_input, ctx) => CloudflareSandboxClient.fromContext(ctx).health()\n})\n\nexport const cloudflareSandboxCreateTool = defineTool({\n\tid: `${id}-create`,\n\tname: 'cloudflareSandboxCreate',\n\tdescription:\n\t\t'Create an isolated Cloudflare sandbox and return sandbox_id. Use only when arbitrary code, commands, or temporary files are required and no purpose-built tool covers the task. Do not create a sandbox to build or edit supported deliverables.',\n\tinputSchema: emptyInputSchema,\n\toutputSchema: createSandboxOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (_input, ctx) => CloudflareSandboxClient.fromContext(ctx).create()\n})\n\nexport const cloudflareSandboxDestroyTool = defineTool({\n\tid: `${id}-destroy`,\n\tname: 'cloudflareSandboxDestroy',\n\tdescription:\n\t\t'Destroy a Cloudflare sandbox by sandbox_id and release its temporary files and resources. Call after the sandbox workflow is complete and any required output file has been exported.',\n\tinputSchema: sandboxIdInputSchema,\n\toutputSchema: destroySandboxOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).destroy(input)\n})\n\nexport const cloudflareSandboxRunningTool = defineTool({\n\tid: `${id}-running`,\n\tname: 'cloudflareSandboxRunning',\n\tdescription:\n\t\t'Check whether a Cloudflare sandbox is currently running. Use before continuing work on an existing sandbox_id; this does not execute code or inspect files.',\n\tinputSchema: sandboxIdInputSchema,\n\toutputSchema: runningOutputSchema,\n\tsideEffect: 'read',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).running(input)\n})\n\nexport const cloudflareSandboxExecTool = defineTool({\n\tid: `${id}-exec`,\n\tname: 'cloudflareSandboxExec',\n\tdescription:\n\t\t'One-shot argv exec in a Cloudflare sandbox (stdout/stderr/exit_code). Prefer a host workspace agent for multi-step shell; use tools for workflow one-shots. Optional env when the bridge supports it.',\n\tinputSchema: execInputSchema,\n\toutputSchema: execOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\ttags: ['exec', 'one-shot', 'compute'],\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).exec(input)\n})\n\nexport const cloudflareSandboxExecuteCodeTool = defineTool({\n\tid: `${id}-execute-code`,\n\tname: 'cloudflareSandboxExecuteCode',\n\tdescription:\n\t\t'Execute Python, JavaScript, or shell source in a Cloudflare sandbox. Use as a fallback for computation or automation with no dedicated tool. Do not generate or edit supported documents, spreadsheets, presentations, PDFs, or images here when a purpose-built tool is available.',\n\tinputSchema: executeCodeInputSchema,\n\toutputSchema: execOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).executeCode(input)\n})\n\nexport const cloudflareSandboxWriteFileTool = defineTool({\n\tid: `${id}-write-file`,\n\tname: 'cloudflareSandboxWriteFile',\n\tdescription:\n\t\t'Write one temporary file under the Cloudflare sandbox workspace from UTF-8 text or base64 bytes, up to 32 MiB decoded. Use for sandbox intermediates. This is not durable delivery; export a genuinely sandbox-produced final file with cloudflare-sandbox-export-artifact.',\n\tinputSchema: writeFileInputSchema,\n\toutputSchema: writeFileOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).writeFile(input)\n})\n\nexport const cloudflareSandboxReadFileTool = defineTool({\n\tid: `${id}-read-file`,\n\tname: 'cloudflareSandboxReadFile',\n\tdescription:\n\t\t'Read one temporary file from the Cloudflare sandbox workspace as UTF-8 or base64. Use for sandbox intermediates; use format-aware readers for supported ArtifactRefs.',\n\tinputSchema: readFileInputSchema,\n\toutputSchema: readFileOutputSchema,\n\tsideEffect: 'read',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).readFile(input)\n})\n\nexport const cloudflareSandboxWriteFilesTool = defineTool({\n\tid: `${id}-write-files`,\n\tname: 'cloudflareSandboxWriteFiles',\n\tdescription:\n\t\t'Write multiple temporary files under the Cloudflare sandbox workspace from text or base64. Use for sandbox intermediates, not final document generation. Export only a final file that the sandbox genuinely had to produce.',\n\tinputSchema: writeFilesInputSchema,\n\toutputSchema: writeFilesOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).writeFiles(input)\n})\n\nexport const cloudflareSandboxReadFilesTool = defineTool({\n\tid: `${id}-read-files`,\n\tname: 'cloudflareSandboxReadFiles',\n\tdescription:\n\t\t'Read multiple temporary files from the Cloudflare sandbox workspace as UTF-8 or base64. Use only within an active sandbox workflow; use format-aware readers for supported ArtifactRefs.',\n\tinputSchema: readFilesInputSchema,\n\toutputSchema: readFilesOutputSchema,\n\tsideEffect: 'read',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).readFiles(input)\n})\n\nexport const cloudflareSandboxListFilesTool = defineTool({\n\tid: `${id}-list-files`,\n\tname: 'cloudflareSandboxListFiles',\n\tdescription:\n\t\t'List temporary files under a Cloudflare sandbox directory, defaulting to /workspace. Use to locate sandbox intermediates, not durable workspace files or ArtifactRefs.',\n\tinputSchema: listFilesInputSchema,\n\toutputSchema: listFilesOutputSchema,\n\tsideEffect: 'read',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).listFiles(input)\n})\n\nexport const cloudflareSandboxRemoveFilesTool = defineTool({\n\tid: `${id}-remove-files`,\n\tname: 'cloudflareSandboxRemoveFiles',\n\tdescription:\n\t\t'Remove temporary files from the Cloudflare sandbox workspace by path. Use only for sandbox cleanup; this does not delete durable workspace files or ArtifactRefs.',\n\tinputSchema: removeFilesInputSchema,\n\toutputSchema: removeFilesOutputSchema,\n\tsideEffect: 'delete',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).removeFiles(input)\n})\n\nexport const cloudflareSandboxImportArtifactTool = defineTool({\n\tid: `${id}-import-artifact`,\n\tname: 'cloudflareSandboxImportArtifact',\n\tdescription:\n\t\t'Copy an existing object-store ArtifactRef into a Cloudflare sandbox workspace. Use only when arbitrary sandbox computation must consume that file. Do not import a supported document merely to read or edit it with general code.',\n\tinputSchema: importArtifactInputSchema,\n\toutputSchema: importArtifactOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).importArtifact(input)\n})\n\nexport const cloudflareSandboxExportArtifactTool = defineTool({\n\tid: `${id}-export-artifact`,\n\tname: 'cloudflareSandboxExportArtifact',\n\tdescription:\n\t\t'Persist a final file that was genuinely created inside the Cloudflare sandbox and return its ArtifactRef for delivery. Use only after sandbox work. Do not call for files returned by document, presentation, PDF, image, render, or conversion tools; those ArtifactRefs are already final.',\n\tinputSchema: exportArtifactInputSchema,\n\toutputSchema: exportArtifactOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).exportArtifact(input)\n})\n\nexport const cloudflareSandboxCreateSessionTool = defineTool({\n\tid: `${id}-create-session`,\n\tname: 'cloudflareSandboxCreateSession',\n\tdescription:\n\t\t'Create an isolated execution session inside an existing Cloudflare sandbox and return session_id. Use only when separate working directories or runtime state are needed; pass the id to later command and file calls.',\n\tinputSchema: sandboxIdInputSchema,\n\toutputSchema: createBridgeSessionOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).createSession(input)\n})\n\nexport const cloudflareSandboxDeleteSessionTool = defineTool({\n\tid: `${id}-delete-session`,\n\tname: 'cloudflareSandboxDeleteSession',\n\tdescription:\n\t\t'Delete an isolated execution session inside a Cloudflare sandbox. Use after session-specific work is complete; this does not destroy the parent sandbox.',\n\tinputSchema: deleteBridgeSessionInputSchema,\n\toutputSchema: deleteBridgeSessionOutputSchema,\n\tsideEffect: 'write',\n\truntime: 'both',\n\tnetwork: true,\n\texecute: async (input, ctx) => CloudflareSandboxClient.fromContext(ctx).deleteSession(input)\n})\n\nexport const cloudflareSandboxModule = defineModule({\n\tid,\n\ttitle: 'Cloudflare Sandbox',\n\tdescription:\n\t\t'Cloudflare sandbox bridge: one-shot exec/files/sessions for workflows. Prefer a host workspace agent for multi-step shell. Client export remains first-class for Workspace hybrids. Prefer purpose-built document tools over sandbox for office formats.',\n\truntime: 'both',\n\tauth: { type: 'custom', schema: cloudflareSandboxAuthSchema },\n\tcategories: ['compute', 'sandbox', 'cloudflare'],\n\tclassification: 'standard',\n\ttags: ['exec', 'workspace', 'bridge'],\n\ttools: [\n\t\tcloudflareSandboxHealthTool,\n\t\tcloudflareSandboxCreateTool,\n\t\tcloudflareSandboxDestroyTool,\n\t\tcloudflareSandboxRunningTool,\n\t\tcloudflareSandboxExecTool,\n\t\tcloudflareSandboxExecuteCodeTool,\n\t\tcloudflareSandboxWriteFileTool,\n\t\tcloudflareSandboxReadFileTool,\n\t\tcloudflareSandboxWriteFilesTool,\n\t\tcloudflareSandboxReadFilesTool,\n\t\tcloudflareSandboxListFilesTool,\n\t\tcloudflareSandboxRemoveFilesTool,\n\t\tcloudflareSandboxImportArtifactTool,\n\t\tcloudflareSandboxExportArtifactTool,\n\t\tcloudflareSandboxCreateSessionTool,\n\t\tcloudflareSandboxDeleteSessionTool\n\t]\n})\n"],"mappings":";;;;;;;;;;;;;;AAUA,MAAa,WAAW;AACxB,MAAa,gBAAgB;AAC7B,MAAa,gBAAgB;AAC7B,MAAa,gBAAgB;;AAE7B,MAAa,iBAAiB,KAAK,OAAO;AAC1C,MAAa,kBAAkB;AAC/B,MAAa,iBAAiB;AAC9B,MAAa,iBAAiB;AAC9B,MAAa,0BAA0B;AACvC,MAAa,sBAAsB;AAEnC,MAAa,8BAA8B,EAAE,OAAO;CACnD,UAAU,EACR,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,SAAS,sFAAsF;CACjG,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,qCAAqC;CACzE,SAAS,aACP,SAAS,CAAC,CACV,SAAS,kFAAkF;AAC9F,CAAC;;AAKD,MAAa,iCAAiC,EAAE,OAAO;CACtD,OAAO,EAAE,QAAQ,QAAQ,CAAC,CAAC,SAAS,sCAAsC;CAC1E,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,YAAY;CAC5C,YAAY,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,gCAAgC;CAClF,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,+BAA+B;CAC/E,aAAa,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,0BAA0B;AAC3E,CAAC;AAID,MAAM,YAAY,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,SAAS,+BAA+B;AAErF,MAAa,uBAAuB,EAAE,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