@cloudflare/sandbox 0.6.10 → 0.6.11
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/dist/index.d.ts +1 -1
- package/dist/index.js +40 -9
- package/dist/index.js.map +1 -1
- package/dist/openai/index.d.ts +1 -1
- package/dist/opencode/index.d.ts +1 -1
- package/dist/{sandbox-DAb6o08K.d.ts → sandbox-HCG7Oeg0.d.ts} +10 -1
- package/dist/{sandbox-DAb6o08K.d.ts.map → sandbox-HCG7Oeg0.d.ts.map} +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as ProcessInfoResult, A as RequestConfig, B as FileChunk, C as WriteFileRequest, D as ContainerStub, E as BaseApiResponse, F as BucketProvider, G as ListFilesOptions, H as FileStreamEvent, I as ExecEvent, J as PortCloseResult, K as LogEvent, L as ExecOptions, M as SessionRequest, N as BaseExecOptions, O as ErrorResponse, P as BucketCredentials, Q as ProcessCleanupResult, R as ExecResult, S as ReadFileRequest, T as ExecuteResponse, U as GitCheckoutResult, V as FileMetadata, W as ISandbox, X as PortListResult, Y as PortExposeResult, Z as Process, _ as GitCheckoutRequest, _t as ExecutionResult, a as CreateSessionRequest, at as ProcessStatus, b as FileOperationRequest, c as DeleteSessionResponse, ct as StreamOptions, d as ProcessClient, dt as isExecResult, et as ProcessKillResult, f as ExposePortRequest, ft as isProcess, g as InterpreterClient, gt as Execution, h as ExecutionCallbacks, ht as CreateContextOptions, i as CommandsResponse, it as ProcessStartResult, j as ResponseHandler, k as HttpClientOptions, l as PingResponse, lt as WaitForLogResult, m as UnexposePortRequest, mt as CodeContext, n as getSandbox, nt as ProcessLogsResult, o as CreateSessionResponse, ot as SandboxOptions, p as PortClient, pt as isProcessStatus, q as MountBucketOptions, r as SandboxClient, rt as ProcessOptions, s as DeleteSessionRequest, st as SessionOptions, t as Sandbox, tt as ProcessListResult, u as UtilityClient, ut as WaitForPortOptions, v as GitClient, vt as RunCodeOptions, w as CommandClient, x as MkdirRequest, y as FileClient, z as ExecutionSession } from "./sandbox-
|
|
1
|
+
import { $ as ProcessInfoResult, A as RequestConfig, B as FileChunk, C as WriteFileRequest, D as ContainerStub, E as BaseApiResponse, F as BucketProvider, G as ListFilesOptions, H as FileStreamEvent, I as ExecEvent, J as PortCloseResult, K as LogEvent, L as ExecOptions, M as SessionRequest, N as BaseExecOptions, O as ErrorResponse, P as BucketCredentials, Q as ProcessCleanupResult, R as ExecResult, S as ReadFileRequest, T as ExecuteResponse, U as GitCheckoutResult, V as FileMetadata, W as ISandbox, X as PortListResult, Y as PortExposeResult, Z as Process, _ as GitCheckoutRequest, _t as ExecutionResult, a as CreateSessionRequest, at as ProcessStatus, b as FileOperationRequest, c as DeleteSessionResponse, ct as StreamOptions, d as ProcessClient, dt as isExecResult, et as ProcessKillResult, f as ExposePortRequest, ft as isProcess, g as InterpreterClient, gt as Execution, h as ExecutionCallbacks, ht as CreateContextOptions, i as CommandsResponse, it as ProcessStartResult, j as ResponseHandler, k as HttpClientOptions, l as PingResponse, lt as WaitForLogResult, m as UnexposePortRequest, mt as CodeContext, n as getSandbox, nt as ProcessLogsResult, o as CreateSessionResponse, ot as SandboxOptions, p as PortClient, pt as isProcessStatus, q as MountBucketOptions, r as SandboxClient, rt as ProcessOptions, s as DeleteSessionRequest, st as SessionOptions, t as Sandbox, tt as ProcessListResult, u as UtilityClient, ut as WaitForPortOptions, v as GitClient, vt as RunCodeOptions, w as CommandClient, x as MkdirRequest, y as FileClient, z as ExecutionSession } from "./sandbox-HCG7Oeg0.js";
|
|
2
2
|
import { a as OperationType, i as ErrorResponse$1, n as ProcessExitedBeforeReadyContext, o as ErrorCode, r as ProcessReadyTimeoutContext } from "./contexts-CdrlvHWK.js";
|
|
3
3
|
|
|
4
4
|
//#region ../shared/dist/request-types.d.ts
|
package/dist/index.js
CHANGED
|
@@ -2509,6 +2509,30 @@ function resolveS3fsOptions(provider, userOptions) {
|
|
|
2509
2509
|
return Array.from(flagMap.values());
|
|
2510
2510
|
}
|
|
2511
2511
|
|
|
2512
|
+
//#endregion
|
|
2513
|
+
//#region src/storage-mount/validation.ts
|
|
2514
|
+
function validatePrefix(prefix) {
|
|
2515
|
+
if (!prefix.startsWith("/")) throw new InvalidMountConfigError(`Prefix must start with '/': "${prefix}"`);
|
|
2516
|
+
}
|
|
2517
|
+
function validateBucketName(bucket, mountPath) {
|
|
2518
|
+
if (bucket.includes(":")) {
|
|
2519
|
+
const [bucketName, prefixPart] = bucket.split(":");
|
|
2520
|
+
throw new InvalidMountConfigError(`Bucket name cannot contain ':'. To mount a prefix, use the 'prefix' option:\n mountBucket('${bucketName}', '${mountPath}', { ...options, prefix: '${prefixPart}' })`);
|
|
2521
|
+
}
|
|
2522
|
+
if (!/^[a-z0-9]([a-z0-9.-]{0,61}[a-z0-9])?$/.test(bucket)) throw new InvalidMountConfigError(`Invalid bucket name: "${bucket}". Bucket names must be 3-63 characters, lowercase alphanumeric, dots, or hyphens, and cannot start/end with dots or hyphens.`);
|
|
2523
|
+
}
|
|
2524
|
+
/**
|
|
2525
|
+
* Builds the s3fs source string from bucket name and optional prefix.
|
|
2526
|
+
* Format: "bucket" or "bucket:/prefix/" for subdirectory mounts.
|
|
2527
|
+
*
|
|
2528
|
+
* @param bucket - The bucket name
|
|
2529
|
+
* @param prefix - Optional prefix/subdirectory path
|
|
2530
|
+
* @returns The s3fs source string
|
|
2531
|
+
*/
|
|
2532
|
+
function buildS3fsSource(bucket, prefix) {
|
|
2533
|
+
return prefix ? `${bucket}:${prefix}` : bucket;
|
|
2534
|
+
}
|
|
2535
|
+
|
|
2512
2536
|
//#endregion
|
|
2513
2537
|
//#region src/version.ts
|
|
2514
2538
|
/**
|
|
@@ -2516,7 +2540,7 @@ function resolveS3fsOptions(provider, userOptions) {
|
|
|
2516
2540
|
* This file is auto-updated by .github/changeset-version.ts during releases
|
|
2517
2541
|
* DO NOT EDIT MANUALLY - Changes will be overwritten on the next version bump
|
|
2518
2542
|
*/
|
|
2519
|
-
const SDK_VERSION = "0.6.
|
|
2543
|
+
const SDK_VERSION = "0.6.11";
|
|
2520
2544
|
|
|
2521
2545
|
//#endregion
|
|
2522
2546
|
//#region src/sandbox.ts
|
|
@@ -2631,8 +2655,6 @@ var Sandbox = class extends Container {
|
|
|
2631
2655
|
async setKeepAlive(keepAlive) {
|
|
2632
2656
|
this.keepAliveEnabled = keepAlive;
|
|
2633
2657
|
await this.ctx.storage.put("keepAliveEnabled", keepAlive);
|
|
2634
|
-
if (keepAlive) this.logger.info("KeepAlive mode enabled - container will stay alive until explicitly destroyed");
|
|
2635
|
-
else this.logger.info("KeepAlive mode disabled - container will timeout normally");
|
|
2636
2658
|
}
|
|
2637
2659
|
async setEnvVars(envVars) {
|
|
2638
2660
|
this.envVars = {
|
|
@@ -2693,13 +2715,21 @@ var Sandbox = class extends Container {
|
|
|
2693
2715
|
}
|
|
2694
2716
|
async mountBucket(bucket, mountPath, options) {
|
|
2695
2717
|
this.logger.info(`Mounting bucket ${bucket} to ${mountPath}`);
|
|
2696
|
-
|
|
2718
|
+
const prefix = options.prefix || void 0;
|
|
2719
|
+
this.validateMountOptions(bucket, mountPath, {
|
|
2720
|
+
...options,
|
|
2721
|
+
prefix
|
|
2722
|
+
});
|
|
2723
|
+
const s3fsSource = buildS3fsSource(bucket, prefix);
|
|
2697
2724
|
const provider = options.provider || detectProviderFromUrl(options.endpoint);
|
|
2698
|
-
this.logger.debug(`Detected provider: ${provider || "unknown"}`, {
|
|
2725
|
+
this.logger.debug(`Detected provider: ${provider || "unknown"}`, {
|
|
2726
|
+
explicitProvider: options.provider,
|
|
2727
|
+
prefix
|
|
2728
|
+
});
|
|
2699
2729
|
const credentials = detectCredentials(options, this.envVars);
|
|
2700
2730
|
const passwordFilePath = this.generatePasswordFilePath();
|
|
2701
2731
|
this.activeMounts.set(mountPath, {
|
|
2702
|
-
bucket,
|
|
2732
|
+
bucket: s3fsSource,
|
|
2703
2733
|
mountPath,
|
|
2704
2734
|
endpoint: options.endpoint,
|
|
2705
2735
|
provider,
|
|
@@ -2709,9 +2739,9 @@ var Sandbox = class extends Container {
|
|
|
2709
2739
|
try {
|
|
2710
2740
|
await this.createPasswordFile(passwordFilePath, bucket, credentials);
|
|
2711
2741
|
await this.exec(`mkdir -p ${shellEscape(mountPath)}`);
|
|
2712
|
-
await this.executeS3FSMount(
|
|
2742
|
+
await this.executeS3FSMount(s3fsSource, mountPath, options, provider, passwordFilePath);
|
|
2713
2743
|
this.activeMounts.set(mountPath, {
|
|
2714
|
-
bucket,
|
|
2744
|
+
bucket: s3fsSource,
|
|
2715
2745
|
mountPath,
|
|
2716
2746
|
endpoint: options.endpoint,
|
|
2717
2747
|
provider,
|
|
@@ -2754,9 +2784,10 @@ var Sandbox = class extends Container {
|
|
|
2754
2784
|
} catch (error) {
|
|
2755
2785
|
throw new InvalidMountConfigError(`Invalid endpoint URL: "${options.endpoint}". Must be a valid HTTP(S) URL.`);
|
|
2756
2786
|
}
|
|
2757
|
-
|
|
2787
|
+
validateBucketName(bucket, mountPath);
|
|
2758
2788
|
if (!mountPath.startsWith("/")) throw new InvalidMountConfigError(`Mount path must be absolute (start with /): "${mountPath}"`);
|
|
2759
2789
|
if (this.activeMounts.has(mountPath)) throw new InvalidMountConfigError(`Mount path "${mountPath}" is already in use by bucket "${this.activeMounts.get(mountPath)?.bucket}". Unmount the existing bucket first or use a different mount path.`);
|
|
2790
|
+
if (options.prefix !== void 0) validatePrefix(options.prefix);
|
|
2760
2791
|
}
|
|
2761
2792
|
/**
|
|
2762
2793
|
* Generate unique password file path for s3fs credentials
|