|
7 | 7 | import { compareVersions } from 'compare-versions' |
8 | 8 | import { SandboxNotFoundError, TemplateError } from '../errors' |
9 | 9 | import { timeoutToSeconds } from '../utils' |
| 10 | +import type { Volume } from '../volume' |
10 | 11 | import type { McpServer as BaseMcpServer } from './mcp' |
11 | 12 |
|
12 | 13 | /** |
@@ -156,6 +157,16 @@ export interface SandboxOpts extends ConnectionOpts { |
156 | 157 | */ |
157 | 158 | network?: SandboxNetworkOpts |
158 | 159 |
|
| 160 | + /** |
| 161 | + * Volume mounts for the sandbox. |
| 162 | + * |
| 163 | + * The keys are mount paths inside the sandbox and the values are either |
| 164 | + * a `Volume` instance or a string representing the volume name. |
| 165 | + * |
| 166 | + * @default undefined |
| 167 | + */ |
| 168 | + volumeMounts?: Record<string, Volume | string> |
| 169 | + |
159 | 170 | /** |
160 | 171 | * Sandbox URL. Used for local development |
161 | 172 | */ |
@@ -337,6 +348,11 @@ export interface SandboxInfo { |
337 | 348 | * Sandbox lifecycle configuration. |
338 | 349 | */ |
339 | 350 | lifecycle?: SandboxInfoLifecycle |
| 351 | + |
| 352 | + /** |
| 353 | + * Volume mounts for the sandbox. |
| 354 | + */ |
| 355 | + volumeMounts?: Array<{ name: string; path: string }> |
340 | 356 | } |
341 | 357 |
|
342 | 358 | /** |
@@ -602,6 +618,7 @@ export class SandboxApi { |
602 | 618 | } |
603 | 619 | : undefined, |
604 | 620 | sandboxDomain: res.data.domain || undefined, |
| 621 | + volumeMounts: res.data.volumeMounts ?? [], |
605 | 622 | } |
606 | 623 | } |
607 | 624 |
|
@@ -775,6 +792,15 @@ export class SandboxApi { |
775 | 792 | : {}), |
776 | 793 | } |
777 | 794 |
|
| 795 | + if (opts?.volumeMounts) { |
| 796 | + body.volumeMounts = Object.entries(opts.volumeMounts).map( |
| 797 | + ([mountPath, vol]) => ({ |
| 798 | + name: typeof vol === 'string' ? vol : vol.name, |
| 799 | + path: mountPath, |
| 800 | + }) |
| 801 | + ) |
| 802 | + } |
| 803 | + |
778 | 804 | const res = await client.api.POST('/sandboxes', { |
779 | 805 | body, |
780 | 806 | signal: config.getSignal(opts?.requestTimeoutMs), |
@@ -959,6 +985,7 @@ export class SandboxPaginator extends BasePaginator<SandboxInfo> { |
959 | 985 | cpuCount: sandbox.cpuCount, |
960 | 986 | memoryMB: sandbox.memoryMB, |
961 | 987 | envdVersion: sandbox.envdVersion, |
| 988 | + volumeMounts: sandbox.volumeMounts ?? [], |
962 | 989 | }) |
963 | 990 | ) |
964 | 991 | } |
|
0 commit comments