@cloudflare/sandbox 0.13.0-next.769.1 → 0.13.0-next.788.1

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.
Files changed (33) hide show
  1. package/Dockerfile +52 -11
  2. package/dist/bridge/index.js +24 -8
  3. package/dist/bridge/index.js.map +1 -1
  4. package/dist/{dist-Duor5GbS.js → dist-n_eniPAR.js} +8 -46
  5. package/dist/dist-n_eniPAR.js.map +1 -0
  6. package/dist/extensions/index.d.ts +2 -2
  7. package/dist/extensions/index.js +2 -2
  8. package/dist/{extensions-CFB2xHqY.js → extensions-Be5HnDGt.js} +2 -2
  9. package/dist/{extensions-CFB2xHqY.js.map → extensions-Be5HnDGt.js.map} +1 -1
  10. package/dist/{filesystem-BWAZCZER.d.ts → filesystem-Y5aF3nmJ.d.ts} +7 -3
  11. package/dist/filesystem-Y5aF3nmJ.d.ts.map +1 -0
  12. package/dist/git/index.d.ts +2 -2
  13. package/dist/git/index.js +2 -2
  14. package/dist/{index-Bs4bqXDR.d.ts → index-DfXx3uZL.d.ts} +2 -2
  15. package/dist/{index-Bs4bqXDR.d.ts.map → index-DfXx3uZL.d.ts.map} +1 -1
  16. package/dist/index.d.ts +3 -3
  17. package/dist/index.js +3 -3
  18. package/dist/interpreter/index.d.ts +2 -2
  19. package/dist/interpreter/index.js +2 -2
  20. package/dist/openai/index.d.ts +2 -2
  21. package/dist/openai/index.d.ts.map +1 -1
  22. package/dist/openai/index.js +10 -34
  23. package/dist/openai/index.js.map +1 -1
  24. package/dist/opencode/index.d.ts +2 -2
  25. package/dist/opencode/index.js +2 -2
  26. package/dist/{sandbox-BbAabq93.d.ts → sandbox-CBkS3tGv.d.ts} +2 -2
  27. package/dist/{sandbox-BbAabq93.d.ts.map → sandbox-CBkS3tGv.d.ts.map} +1 -1
  28. package/dist/{sandbox-cmlgGVYX.js → sandbox-pJ4JSnDx.js} +101 -43
  29. package/dist/sandbox-pJ4JSnDx.js.map +1 -0
  30. package/package.json +1 -1
  31. package/dist/dist-Duor5GbS.js.map +0 -1
  32. package/dist/filesystem-BWAZCZER.d.ts.map +0 -1
  33. package/dist/sandbox-cmlgGVYX.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { i as ErrorCode } from "../errors-CXR0xBpw.js";
2
2
  import "../errors-QYlSkVGz.js";
3
- import { r as createLogger } from "../dist-Duor5GbS.js";
4
- import { n as createExtensionProcessSandbox, t as SandboxExtension } from "../extensions-CFB2xHqY.js";
3
+ import { r as createLogger } from "../dist-n_eniPAR.js";
4
+ import { n as createExtensionProcessSandbox, t as SandboxExtension } from "../extensions-Be5HnDGt.js";
5
5
 
6
6
  //#region ../../extensions/opencode/src/client.ts
7
7
  let createSDKClient;
@@ -1,5 +1,5 @@
1
1
  import { o as ProcessStatus, s as SandboxCommand } from "./process-types-GStiZ8f8.js";
2
- import { A as CreateTerminalOptions, D as MountBucketOptions, M as Terminal, R as ExecOptions, S as BackupOptions, T as DirectoryBackup, _ as RenameFileResult, b as WriteFileResult, d as ListFilesOptions, f as ListFilesResult, g as ReadFileStreamResult, h as ReadFileResult, i as DeleteFileResult, k as RestoreBackupResult, m as MoveFileResult, o as FileEncoding, p as MkdirResult, q as SandboxProcess, r as CheckChangesResult, s as FileExistsResult, t as CheckChangesOptions, v as WatchOptions } from "./filesystem-BWAZCZER.js";
2
+ import { A as CreateTerminalOptions, D as MountBucketOptions, M as Terminal, R as ExecOptions, S as BackupOptions, T as DirectoryBackup, _ as RenameFileResult, b as WriteFileResult, d as ListFilesOptions, f as ListFilesResult, g as ReadFileStreamResult, h as ReadFileResult, i as DeleteFileResult, k as RestoreBackupResult, m as MoveFileResult, o as FileEncoding, p as MkdirResult, q as SandboxProcess, r as CheckChangesResult, s as FileExistsResult, t as CheckChangesOptions, v as WatchOptions } from "./filesystem-Y5aF3nmJ.js";
3
3
 
4
4
  //#region ../shared/dist/types/sandbox.d.ts
5
5
 
@@ -39,4 +39,4 @@ interface ISandbox {
39
39
  }
40
40
  //#endregion
41
41
  export { ISandbox as t };
42
- //# sourceMappingURL=sandbox-BbAabq93.d.ts.map
42
+ //# sourceMappingURL=sandbox-CBkS3tGv.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sandbox-BbAabq93.d.ts","names":["ProcessStatus","SandboxCommand","CreateTerminalOptions","Terminal","BackupOptions","DirectoryBackup","MountBucketOptions","RestoreBackupResult","ExecOptions","SandboxProcess","CheckChangesOptions","CheckChangesResult","DeleteFileResult","FileEncoding","FileExistsResult","ListFilesOptions","ListFilesResult","MkdirResult","MoveFileResult","ReadFileResult","ReadFileStreamResult","RenameFileResult","WatchOptions","WriteFileResult","ISandbox","Promise","Uint8Array","ReadableStream","Exclude","Record","Request","Response"],"sources":["../../shared/dist/types/sandbox.d.ts"],"sourcesContent":["import type { ProcessStatus, SandboxCommand } from '../process-types.js';\nimport type { CreateTerminalOptions, Terminal } from '../pty-types.js';\nimport type { BackupOptions, DirectoryBackup, MountBucketOptions, RestoreBackupResult } from './backup-mounts.js';\nimport type { ExecOptions, SandboxProcess } from './core.js';\nimport type { CheckChangesOptions, CheckChangesResult, DeleteFileResult, FileEncoding, FileExistsResult, ListFilesOptions, ListFilesResult, MkdirResult, MoveFileResult, ReadFileResult, ReadFileStreamResult, RenameFileResult, WatchOptions, WriteFileResult } from './filesystem.js';\nexport interface ISandbox {\n exec(command: SandboxCommand, options?: ExecOptions): Promise<SandboxProcess>;\n getProcess(id: string): Promise<SandboxProcess | null>;\n listProcesses(): Promise<ProcessStatus[]>;\n writeFile(path: string, content: string | ReadableStream<Uint8Array>, options?: {\n encoding?: string;\n }): Promise<WriteFileResult>;\n readFile(path: string, options: {\n encoding: 'none';\n }): Promise<ReadFileStreamResult>;\n readFile(path: string, options?: {\n encoding?: Exclude<FileEncoding, 'none'>;\n }): Promise<ReadFileResult>;\n readFileStream(path: string): Promise<ReadableStream<Uint8Array>>;\n watch(path: string, options?: WatchOptions): Promise<ReadableStream<Uint8Array>>;\n checkChanges(path: string, options?: CheckChangesOptions): Promise<CheckChangesResult>;\n mkdir(path: string, options?: {\n recursive?: boolean;\n }): Promise<MkdirResult>;\n deleteFile(path: string): Promise<DeleteFileResult>;\n renameFile(oldPath: string, newPath: string, options?: Record<string, never>): Promise<RenameFileResult>;\n moveFile(sourcePath: string, destinationPath: string, options?: Record<string, never>): Promise<MoveFileResult>;\n listFiles(path: string, options?: ListFilesOptions): Promise<ListFilesResult>;\n exists(path: string): Promise<FileExistsResult>;\n setEnvVars(envVars: Record<string, string | undefined>): Promise<void>;\n mountBucket(bucket: string, mountPath: string, options: MountBucketOptions): Promise<void>;\n unmountBucket(mountPath: string): Promise<void>;\n createBackup(options: BackupOptions): Promise<DirectoryBackup>;\n restoreBackup(backup: DirectoryBackup): Promise<RestoreBackupResult>;\n wsConnect(request: Request, port: number): Promise<Response>;\n createTerminal(options: CreateTerminalOptions): Promise<Terminal>;\n getTerminal(id: string): Promise<Terminal | null>;\n listTerminals(): Promise<Terminal[]>;\n}\n//# sourceMappingURL=sandbox.d.ts.map"],"mappings":";;;;;AAMkBC,UADDuB,QAAAA,CACCvB;EAA0BO,IAAAA,CAAAA,OAAAA,EAA1BP,cAA0BO,EAAAA,OAAAA,CAAAA,EAAAA,WAAAA,CAAAA,EAAciB,OAAdjB,CAAsBC,cAAtBD,CAAAA;EAAsBC,UAAAA,CAAAA,EAAAA,EAAAA,MAAAA,CAAAA,EACtCgB,OADsChB,CAC9BA,cAD8BA,GAAAA,IAAAA,CAAAA;EAARgB,aAAAA,EAAAA,EAErCA,OAFqCA,CAE7BzB,aAF6ByB,EAAAA,CAAAA;EACtBhB,SAAAA,CAAAA,IAAAA,EAAAA,MAAAA,EAAAA,OAAAA,EAAAA,MAAAA,GAEUkB,cAFVlB,CAEyBiB,UAFzBjB,CAAAA,EAAAA,OACPT,CADOS,EAAAA;IAARgB,QAAAA,CAAAA,EAAAA,MAAAA;EACCzB,CAAAA,CAAAA,EAGrByB,OAHqBzB,CAGbuB,eAHavB,CA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AAA,EAYDA,OAZCA,CAYOtB,QAZPsB,GAAAA,IAAAA,CAAAA;EAC6BI,aAAAA,EAAAA,EAYtCJ,OAZsCI,CAY9B1B,QAZ8B0B,EAAAA,CAAAA"}
1
+ {"version":3,"file":"sandbox-CBkS3tGv.d.ts","names":["ProcessStatus","SandboxCommand","CreateTerminalOptions","Terminal","BackupOptions","DirectoryBackup","MountBucketOptions","RestoreBackupResult","ExecOptions","SandboxProcess","CheckChangesOptions","CheckChangesResult","DeleteFileResult","FileEncoding","FileExistsResult","ListFilesOptions","ListFilesResult","MkdirResult","MoveFileResult","ReadFileResult","ReadFileStreamResult","RenameFileResult","WatchOptions","WriteFileResult","ISandbox","Promise","Uint8Array","ReadableStream","Exclude","Record","Request","Response"],"sources":["../../shared/dist/types/sandbox.d.ts"],"sourcesContent":["import type { ProcessStatus, SandboxCommand } from '../process-types.js';\nimport type { CreateTerminalOptions, Terminal } from '../pty-types.js';\nimport type { BackupOptions, DirectoryBackup, MountBucketOptions, RestoreBackupResult } from './backup-mounts.js';\nimport type { ExecOptions, SandboxProcess } from './core.js';\nimport type { CheckChangesOptions, CheckChangesResult, DeleteFileResult, FileEncoding, FileExistsResult, ListFilesOptions, ListFilesResult, MkdirResult, MoveFileResult, ReadFileResult, ReadFileStreamResult, RenameFileResult, WatchOptions, WriteFileResult } from './filesystem.js';\nexport interface ISandbox {\n exec(command: SandboxCommand, options?: ExecOptions): Promise<SandboxProcess>;\n getProcess(id: string): Promise<SandboxProcess | null>;\n listProcesses(): Promise<ProcessStatus[]>;\n writeFile(path: string, content: string | ReadableStream<Uint8Array>, options?: {\n encoding?: string;\n }): Promise<WriteFileResult>;\n readFile(path: string, options: {\n encoding: 'none';\n }): Promise<ReadFileStreamResult>;\n readFile(path: string, options?: {\n encoding?: Exclude<FileEncoding, 'none'>;\n }): Promise<ReadFileResult>;\n readFileStream(path: string): Promise<ReadableStream<Uint8Array>>;\n watch(path: string, options?: WatchOptions): Promise<ReadableStream<Uint8Array>>;\n checkChanges(path: string, options?: CheckChangesOptions): Promise<CheckChangesResult>;\n mkdir(path: string, options?: {\n recursive?: boolean;\n }): Promise<MkdirResult>;\n deleteFile(path: string): Promise<DeleteFileResult>;\n renameFile(oldPath: string, newPath: string, options?: Record<string, never>): Promise<RenameFileResult>;\n moveFile(sourcePath: string, destinationPath: string, options?: Record<string, never>): Promise<MoveFileResult>;\n listFiles(path: string, options?: ListFilesOptions): Promise<ListFilesResult>;\n exists(path: string): Promise<FileExistsResult>;\n setEnvVars(envVars: Record<string, string | undefined>): Promise<void>;\n mountBucket(bucket: string, mountPath: string, options: MountBucketOptions): Promise<void>;\n unmountBucket(mountPath: string): Promise<void>;\n createBackup(options: BackupOptions): Promise<DirectoryBackup>;\n restoreBackup(backup: DirectoryBackup): Promise<RestoreBackupResult>;\n wsConnect(request: Request, port: number): Promise<Response>;\n createTerminal(options: CreateTerminalOptions): Promise<Terminal>;\n getTerminal(id: string): Promise<Terminal | null>;\n listTerminals(): Promise<Terminal[]>;\n}\n//# sourceMappingURL=sandbox.d.ts.map"],"mappings":";;;;;AAMkBC,UADDuB,QAAAA,CACCvB;EAA0BO,IAAAA,CAAAA,OAAAA,EAA1BP,cAA0BO,EAAAA,OAAAA,CAAAA,EAAAA,WAAAA,CAAAA,EAAciB,OAAdjB,CAAsBC,cAAtBD,CAAAA;EAAsBC,UAAAA,CAAAA,EAAAA,EAAAA,MAAAA,CAAAA,EACtCgB,OADsChB,CAC9BA,cAD8BA,GAAAA,IAAAA,CAAAA;EAARgB,aAAAA,EAAAA,EAErCA,OAFqCA,CAE7BzB,aAF6ByB,EAAAA,CAAAA;EACtBhB,SAAAA,CAAAA,IAAAA,EAAAA,MAAAA,EAAAA,OAAAA,EAAAA,MAAAA,GAEUkB,cAFVlB,CAEyBiB,UAFzBjB,CAAAA,EAAAA,OACPT,CADOS,EAAAA;IAARgB,QAAAA,CAAAA,EAAAA,MAAAA;EACCzB,CAAAA,CAAAA,EAGrByB,OAHqBzB,CAGbuB,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MAAAA,CAAAA,EAYDA,OAZCA,CAYOtB,QAZPsB,GAAAA,IAAAA,CAAAA;EAC6BI,aAAAA,EAAAA,EAYtCJ,OAZsCI,CAY9B1B,QAZ8B0B,EAAAA,CAAAA"}
@@ -1,7 +1,7 @@
1
1
  import { i as ErrorCode, n as getSuggestion, r as getHttpStatus } from "./errors-CXR0xBpw.js";
2
2
  import { $ as TerminalControlError, G as BackupRestoreError, H as BackupCreateError, Q as StaleTerminalHandleError, U as BackupExpiredError, W as BackupNotFoundError, X as OperationInterruptedError, Z as RPCTransportError, _ as StaleProcessHandleError, n as RuntimeIdentityInactiveError, p as ProcessNotFoundError, q as InvalidBackupConfigError, r as RuntimeControlProtocolError, t as createErrorFromResponse, tt as SandboxError, v as CustomDomainRequiredError } from "./errors-QYlSkVGz.js";
3
- import { a as TraceContext, d as partitionEnvVars, i as createNoOpLogger, o as logCanonicalEvent, r as createLogger, t as parseSSEFrames, u as getEnvString } from "./dist-Duor5GbS.js";
4
- import { a as PullSubscriptionTarget, i as createSandboxProcess, o as openRemoteSubscription, r as sandboxRuntimeCall, s as translateRPCError, t as SandboxExtension } from "./extensions-CFB2xHqY.js";
3
+ import { a as TraceContext, d as partitionEnvVars, i as createNoOpLogger, o as logCanonicalEvent, r as createLogger, t as parseSSEFrames, u as getEnvString } from "./dist-n_eniPAR.js";
4
+ import { a as PullSubscriptionTarget, i as createSandboxProcess, o as openRemoteSubscription, r as sandboxRuntimeCall, s as translateRPCError, t as SandboxExtension } from "./extensions-Be5HnDGt.js";
5
5
  import { Container, ContainerProxy, getContainer, switchPort } from "@cloudflare/containers";
6
6
  import { RpcTarget } from "cloudflare:workers";
7
7
  import { AwsClient } from "aws4fetch";
@@ -2003,6 +2003,8 @@ const DEFAULT_POLL_INTERVAL_MS = 1e3;
2003
2003
  const DEFAULT_ECHO_SUPPRESS_TTL_MS = 2e3;
2004
2004
  const MAX_BACKOFF_MS = 3e4;
2005
2005
  const SYNC_CONCURRENCY = 5;
2006
+ const STREAM_TO_CONTAINER_THRESHOLD_BYTES = 4 * 1024 * 1024;
2007
+ const UPLOAD_DEBOUNCE_MS = 1500;
2006
2008
  /**
2007
2009
  * Manages bidirectional sync between an R2 binding and a container directory.
2008
2010
  *
@@ -2020,7 +2022,9 @@ var LocalMountSyncManager = class {
2020
2022
  pollIntervalMs;
2021
2023
  echoSuppressTtlMs;
2022
2024
  snapshot = /* @__PURE__ */ new Map();
2023
- echoSuppressSet = /* @__PURE__ */ new Set();
2025
+ echoSuppressTimers = /* @__PURE__ */ new Map();
2026
+ uploadTimers = /* @__PURE__ */ new Map();
2027
+ containerToR2Queue = Promise.resolve();
2024
2028
  pollTimer = null;
2025
2029
  watchReconnectTimer = null;
2026
2030
  watchAbortController = null;
@@ -2071,9 +2075,10 @@ var LocalMountSyncManager = class {
2071
2075
  this.interrupt();
2072
2076
  const pollCycle = this.activePollCycle;
2073
2077
  const watchLoop = this.activeWatchLoop;
2074
- await Promise.allSettled([pollCycle, watchLoop].filter(isPromise));
2078
+ await Promise.allSettled([...[pollCycle, watchLoop].filter(isPromise), this.containerToR2Queue]);
2079
+ for (const timer of this.echoSuppressTimers.values()) clearTimeout(timer);
2080
+ this.echoSuppressTimers.clear();
2075
2081
  this.snapshot.clear();
2076
- this.echoSuppressSet.clear();
2077
2082
  this.logger.info("Local mount sync stopped", { mountPath: this.mountPath });
2078
2083
  }
2079
2084
  interrupt() {
@@ -2090,6 +2095,8 @@ var LocalMountSyncManager = class {
2090
2095
  this.watchAbortController.abort();
2091
2096
  this.watchAbortController = null;
2092
2097
  }
2098
+ for (const timer of this.uploadTimers.values()) clearTimeout(timer);
2099
+ this.uploadTimers.clear();
2093
2100
  if (!this.runtimeHoldReleased) {
2094
2101
  this.runtimeHoldReleased = true;
2095
2102
  this.runtimeHold.release();
@@ -2163,6 +2170,7 @@ var LocalMountSyncManager = class {
2163
2170
  if (!this.isCurrentGeneration(generation)) return;
2164
2171
  this.suppressEcho(containerPath);
2165
2172
  await this.transferR2ObjectToContainer(key, containerPath, generation);
2173
+ this.suppressEcho(containerPath);
2166
2174
  this.logger.debug("R2 -> Container: synced object", {
2167
2175
  key,
2168
2176
  action
@@ -2206,6 +2214,15 @@ var LocalMountSyncManager = class {
2206
2214
  async transferR2ObjectToContainer(key, containerPath, generation) {
2207
2215
  const obj = await this.bucket.get(key);
2208
2216
  if (!obj) return;
2217
+ if (obj.size > STREAM_TO_CONTAINER_THRESHOLD_BYTES) {
2218
+ try {
2219
+ await this.runRuntimeCallIfCurrent(generation, "mount.local.writeFileStream", (control) => control.files.writeFileStream(containerPath, obj.body));
2220
+ } catch (error) {
2221
+ await obj.body.cancel().catch(() => {});
2222
+ throw error;
2223
+ }
2224
+ return;
2225
+ }
2209
2226
  const arrayBuffer = await obj.arrayBuffer();
2210
2227
  const base64 = uint8ArrayToBase64(new Uint8Array(arrayBuffer));
2211
2228
  await this.runRuntimeCallIfCurrent(generation, "mount.local.writeFile", (control) => control.files.writeFile(containerPath, base64, { encoding: "base64" }));
@@ -2265,48 +2282,89 @@ var LocalMountSyncManager = class {
2265
2282
  if (event.type !== "event") continue;
2266
2283
  if (event.isDirectory) continue;
2267
2284
  const containerPath = event.path;
2268
- if (this.echoSuppressSet.has(containerPath)) continue;
2285
+ if (this.echoSuppressTimers.has(containerPath)) continue;
2269
2286
  const r2Key = this.containerPathToR2Key(containerPath);
2270
2287
  if (!r2Key) continue;
2271
- try {
2272
- switch (event.eventType) {
2273
- case "create":
2274
- case "modify":
2275
- case "move_to":
2276
- await this.uploadFileToR2(containerPath, r2Key, generation);
2277
- this.logger.debug("Container -> R2: synced file", {
2278
- path: containerPath,
2279
- key: r2Key,
2280
- action: event.eventType
2281
- });
2282
- break;
2283
- case "delete":
2284
- case "move_from":
2285
- if (!this.isCurrentGeneration(generation)) break;
2288
+ switch (event.eventType) {
2289
+ case "create":
2290
+ case "modify":
2291
+ case "move_to":
2292
+ this.scheduleUpload(containerPath, r2Key, generation);
2293
+ break;
2294
+ case "delete":
2295
+ case "move_from":
2296
+ this.cancelScheduledUpload(containerPath);
2297
+ this.enqueueContainerToR2(containerPath, generation, async () => {
2286
2298
  await this.bucket.delete(r2Key);
2287
- if (!this.isCurrentGeneration(generation)) break;
2299
+ if (!this.isCurrentGeneration(generation)) return;
2288
2300
  this.snapshot.delete(r2Key);
2289
2301
  this.logger.debug("Container -> R2: deleted object", {
2290
2302
  path: containerPath,
2291
2303
  key: r2Key
2292
2304
  });
2293
- break;
2294
- }
2295
- } catch (error) {
2296
- this.logger.error(`Container -> R2 sync failed for ${containerPath}`, error instanceof Error ? error : new Error(String(error)));
2305
+ });
2306
+ break;
2297
2307
  }
2298
2308
  }
2299
2309
  });
2300
2310
  }
2301
2311
  /**
2302
- * Read a container file and upload it to R2, then update the local
2303
- * snapshot so the next poll cycle doesn't echo the write back.
2312
+ * Upload a changed file once its burst of watch events settles. Each new
2313
+ * event for the path restarts the wait.
2314
+ */
2315
+ scheduleUpload(containerPath, r2Key, generation) {
2316
+ this.cancelScheduledUpload(containerPath);
2317
+ const timer = setTimeout(() => {
2318
+ this.uploadTimers.delete(containerPath);
2319
+ this.enqueueContainerToR2(containerPath, generation, async () => {
2320
+ await this.uploadFileToR2(containerPath, r2Key, generation);
2321
+ this.logger.debug("Container -> R2: synced file", {
2322
+ path: containerPath,
2323
+ key: r2Key
2324
+ });
2325
+ });
2326
+ }, UPLOAD_DEBOUNCE_MS);
2327
+ this.uploadTimers.set(containerPath, timer);
2328
+ }
2329
+ cancelScheduledUpload(containerPath) {
2330
+ const timer = this.uploadTimers.get(containerPath);
2331
+ if (timer !== void 0) {
2332
+ clearTimeout(timer);
2333
+ this.uploadTimers.delete(containerPath);
2334
+ }
2335
+ }
2336
+ enqueueContainerToR2(containerPath, generation, operation) {
2337
+ this.containerToR2Queue = this.containerToR2Queue.then(async () => {
2338
+ if (!this.isCurrentGeneration(generation)) return;
2339
+ try {
2340
+ await operation();
2341
+ } catch (error) {
2342
+ if (!this.isCurrentGeneration(generation)) return;
2343
+ this.logger.error(`Container -> R2 sync failed for ${containerPath}`, error instanceof Error ? error : new Error(String(error)));
2344
+ }
2345
+ });
2346
+ }
2347
+ /**
2348
+ * Stream a container file into R2, then update the local snapshot so the
2349
+ * next poll cycle doesn't echo the write back.
2304
2350
  */
2305
2351
  async uploadFileToR2(containerPath, r2Key, generation) {
2306
- const result = await this.runRuntimeCallIfCurrent(generation, "mount.local.readFile", (control) => control.files.readFile(containerPath, { encoding: "base64" }));
2307
- if (!this.isCurrentOrUnscoped(generation)) return;
2308
- const bytes = base64ToUint8Array(result.content);
2309
- await this.bucket.put(r2Key, bytes);
2352
+ await this.runRuntimeCallIfCurrent(generation, "mount.local.readFile", async (control) => {
2353
+ const file = await control.files.readFile(containerPath, { encoding: "none" });
2354
+ if (!this.isCurrentOrUnscoped(generation)) {
2355
+ await file.content.cancel();
2356
+ return;
2357
+ }
2358
+ const sized = new FixedLengthStream(file.size);
2359
+ const pipeAbort = new AbortController();
2360
+ file.content.pipeTo(sized.writable, { signal: pipeAbort.signal }).catch(() => {});
2361
+ try {
2362
+ await this.bucket.put(r2Key, sized.readable);
2363
+ } catch (error) {
2364
+ pipeAbort.abort(error);
2365
+ throw error;
2366
+ }
2367
+ });
2310
2368
  if (!this.isCurrentOrUnscoped(generation)) return;
2311
2369
  const head = await this.bucket.head(r2Key);
2312
2370
  if (head) this.snapshot.set(r2Key, {
@@ -2328,10 +2386,10 @@ var LocalMountSyncManager = class {
2328
2386
  return this.running && this.generation === generation;
2329
2387
  }
2330
2388
  suppressEcho(containerPath) {
2331
- this.echoSuppressSet.add(containerPath);
2332
- setTimeout(() => {
2333
- this.echoSuppressSet.delete(containerPath);
2334
- }, this.echoSuppressTtlMs);
2389
+ clearTimeout(this.echoSuppressTimers.get(containerPath));
2390
+ this.echoSuppressTimers.set(containerPath, setTimeout(() => {
2391
+ this.echoSuppressTimers.delete(containerPath);
2392
+ }, this.echoSuppressTtlMs));
2335
2393
  }
2336
2394
  r2KeyToContainerPath(key) {
2337
2395
  let relativePath = key;
@@ -2353,9 +2411,6 @@ function isPromise(value) {
2353
2411
  function uint8ArrayToBase64(bytes) {
2354
2412
  return Buffer.from(bytes).toString("base64");
2355
2413
  }
2356
- function base64ToUint8Array(base64) {
2357
- return new Uint8Array(Buffer.from(base64, "base64"));
2358
- }
2359
2414
 
2360
2415
  //#endregion
2361
2416
  //#region src/storage-mount/operations/local-sync-mount.ts
@@ -9670,7 +9725,10 @@ var Sandbox = class extends Container {
9670
9725
  async exec(command, options = {}) {
9671
9726
  const argv = validateExecArgv(command);
9672
9727
  const startTime = Date.now();
9673
- const commandText = argv.join(" ");
9728
+ const commandSummary = {
9729
+ argv0: argv[0],
9730
+ argCount: argv.length - 1
9731
+ };
9674
9732
  const launchOptions = (options.env === void 0 || isPlainObject(options.env)) && (Object.keys(this.envVars).length > 0 || options.env !== void 0) ? {
9675
9733
  ...options,
9676
9734
  env: mergeExecEnvironment(this.envVars, options.env ?? {})
@@ -9683,7 +9741,7 @@ var Sandbox = class extends Container {
9683
9741
  logCanonicalEvent(this.logger, {
9684
9742
  event: "sandbox.exec",
9685
9743
  outcome: "success",
9686
- command: commandText,
9744
+ ...commandSummary,
9687
9745
  processId: descriptor.id,
9688
9746
  pid: descriptor.pid,
9689
9747
  durationMs: Date.now() - startTime,
@@ -9695,7 +9753,7 @@ var Sandbox = class extends Container {
9695
9753
  logCanonicalEvent(this.logger, {
9696
9754
  event: "sandbox.exec",
9697
9755
  outcome: "error",
9698
- command: commandText,
9756
+ ...commandSummary,
9699
9757
  durationMs: Date.now() - startTime,
9700
9758
  origin: "user",
9701
9759
  error: execError,
@@ -10053,4 +10111,4 @@ var Sandbox = class extends Container {
10053
10111
 
10054
10112
  //#endregion
10055
10113
  export { proxyTerminal as _, responseToAsyncIterable as a, collectFile as b, BucketUnmountError as c, S3FSMountError as d, parsePreviewRoute as f, validateTunnelName as g, validatePort as h, parseSSEStream as i, InvalidMountConfigError as l, SandboxSecurityError as m, getSandbox as n, ContainerProxy$1 as o, withPreviewProxyMetadata as p, asyncIterableToSSEStream as r, BucketMountError as s, Sandbox as t, MissingCredentialsError as u, isDurableObjectCodeUpdateReset as v, streamFile as x, isPlatformTransientError as y };
10056
- //# sourceMappingURL=sandbox-cmlgGVYX.js.map
10114
+ //# sourceMappingURL=sandbox-pJ4JSnDx.js.map