@cloudflare/sandbox 0.5.2 → 0.5.3

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @cloudflare/sandbox@0.5.2 build
2
+ > @cloudflare/sandbox@0.5.3 build
3
3
  > rm -rf dist && tsdown --config tsdown.config.ts
4
4
 
5
5
  ℹ tsdown v0.16.6 powered by rolldown v1.0.0-beta.51
@@ -7,17 +7,17 @@
7
7
  ℹ entry: src/index.ts, src/openai/index.ts
8
8
  ℹ tsconfig: tsconfig.json
9
9
  ℹ Build start
10
- ℹ dist/index.js 100.84 kB │ gzip: 22.92 kB
10
+ ℹ dist/index.js 102.82 kB │ gzip: 23.33 kB
11
11
  ℹ dist/openai/index.js  10.42 kB │ gzip: 2.63 kB
12
- ℹ dist/index.js.map 214.92 kB │ gzip: 47.84 kB
13
- ℹ dist/sandbox-B3vJ541e.d.ts.map  60.94 kB │ gzip: 16.79 kB
12
+ ℹ dist/index.js.map 219.05 kB │ gzip: 48.46 kB
13
+ ℹ dist/sandbox-HQazw9bn.d.ts.map  61.69 kB │ gzip: 16.89 kB
14
14
  ℹ dist/dist-gVyG2H2h.js.map  30.14 kB │ gzip: 8.31 kB
15
15
  ℹ dist/openai/index.js.map  21.00 kB │ gzip: 5.13 kB
16
16
  ℹ dist/dist-gVyG2H2h.js  17.03 kB │ gzip: 5.39 kB
17
- ℹ dist/index.d.ts.map  8.84 kB │ gzip: 2.71 kB
17
+ ℹ dist/index.d.ts.map  9.22 kB │ gzip: 2.82 kB
18
18
  ℹ dist/openai/index.d.ts.map  0.72 kB │ gzip: 0.37 kB
19
- ℹ dist/index.d.ts  10.66 kB │ gzip: 3.21 kB
19
+ ℹ dist/index.d.ts  11.11 kB │ gzip: 3.32 kB
20
20
  ℹ dist/openai/index.d.ts  2.10 kB │ gzip: 0.81 kB
21
- ℹ dist/sandbox-B3vJ541e.d.ts  50.82 kB │ gzip: 11.69 kB
22
- ℹ 12 files, total: 528.43 kB
23
- ✔ Build complete in 3705ms
21
+ ℹ dist/sandbox-HQazw9bn.d.ts  51.36 kB │ gzip: 11.79 kB
22
+ ℹ 12 files, total: 536.66 kB
23
+ ✔ Build complete in 3733ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @cloudflare/sandbox
2
2
 
3
+ ## 0.5.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#204](https://github.com/cloudflare/sandbox-sdk/pull/204) [`55981f8`](https://github.com/cloudflare/sandbox-sdk/commit/55981f8802b4e0d3b65b947ef8ba7ae2bae183d7) Thanks [@whoiskatrin](https://github.com/whoiskatrin)! - add environment variables and working directory support to command exec
8
+
3
9
  ## 0.5.2
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,7 +1,25 @@
1
- import { $ as ProcessCleanupResult, A as HttpClientOptions, B as ExecutionSession, C as WriteFileRequest, D as BaseApiResponse, E as ExecuteResponse, F as BucketCredentials, G as ISandbox, H as FileMetadata, I as BucketProvider, J as MountBucketOptions, K as ListFilesOptions, L as ExecEvent, M as ResponseHandler, N as SessionRequest, O as ContainerStub, P as BaseExecOptions, Q as Process, R as ExecOptions, S as ReadFileRequest, T as ExecuteRequest, U as FileStreamEvent, V as FileChunk, W as GitCheckoutResult, X as PortExposeResult, Y as PortCloseResult, Z as PortListResult, _ as GitCheckoutRequest, _t as RunCodeOptions, a as CreateSessionRequest, at as ProcessStartResult, b as FileOperationRequest, c as DeleteSessionResponse, ct as SessionOptions, d as ProcessClient, dt as isProcess, et as ProcessInfoResult, f as ExposePortRequest, ft as isProcessStatus, g as InterpreterClient, gt as ExecutionResult, h as ExecutionCallbacks, ht as Execution, i as CommandsResponse, it as ProcessOptions, j as RequestConfig, k as ErrorResponse, l as PingResponse, lt as StreamOptions, m as UnexposePortRequest, mt as CreateContextOptions, n as getSandbox, nt as ProcessListResult, o as CreateSessionResponse, ot as ProcessStatus, p as PortClient, pt as CodeContext, q as LogEvent, r as SandboxClient, rt as ProcessLogsResult, s as DeleteSessionRequest, st as SandboxOptions, t as Sandbox, tt as ProcessKillResult, u as UtilityClient, ut as isExecResult, v as GitClient, w as CommandClient, x as MkdirRequest, y as FileClient, z as ExecResult } from "./sandbox-B3vJ541e.js";
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, a as CreateSessionRequest, at as ProcessStatus, b as FileOperationRequest, c as DeleteSessionResponse, ct as StreamOptions, d as ProcessClient, dt as isProcessStatus, et as ProcessKillResult, f as ExposePortRequest, ft as CodeContext, g as InterpreterClient, gt as RunCodeOptions, h as ExecutionCallbacks, ht as ExecutionResult, i as CommandsResponse, it as ProcessStartResult, j as ResponseHandler, k as HttpClientOptions, l as PingResponse, lt as isExecResult, m as UnexposePortRequest, mt as Execution, n as getSandbox, nt as ProcessLogsResult, o as CreateSessionResponse, ot as SandboxOptions, p as PortClient, pt as CreateContextOptions, 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 isProcess, v as GitClient, w as CommandClient, x as MkdirRequest, y as FileClient, z as ExecutionSession } from "./sandbox-HQazw9bn.js";
2
2
 
3
3
  //#region ../shared/dist/request-types.d.ts
4
4
 
5
+ /**
6
+ * Request types for API calls to the container
7
+ * These types enforce the contract between the Durable Object client and container handlers
8
+ *
9
+ * IMPORTANT: These types must match the Zod schemas in:
10
+ * @repo/sandbox-container/src/validation/schemas.ts
11
+ */
12
+ /**
13
+ * Request to execute a command
14
+ */
15
+ interface ExecuteRequest {
16
+ command: string;
17
+ sessionId?: string;
18
+ background?: boolean;
19
+ timeoutMs?: number;
20
+ env?: Record<string, string>;
21
+ cwd?: string;
22
+ }
5
23
  /**
6
24
  * Request to start a background process
7
25
  * Uses flat structure consistent with other endpoints
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["ExecuteRequest","StartProcessRequest","Record","ReadFileRequest","WriteFileRequest","DeleteFileRequest","RenameFileRequest","MoveFileRequest","MkdirRequest","FileExistsRequest","ExposePortRequest","GitCheckoutRequest","SessionCreateRequest","SessionDeleteRequest","ErrorCode"],"sources":["../../shared/dist/request-types.d.ts","../src/file-stream.ts","../src/interpreter.ts","../src/request-handler.ts","../src/sse-parser.ts","../../shared/dist/errors/codes.d.ts","../src/storage-mount/errors.ts"],"sourcesContent":["/**\n * Request types for API calls to the container\n * These types enforce the contract between the Durable Object client and container handlers\n *\n * IMPORTANT: These types must match the Zod schemas in:\n * @repo/sandbox-container/src/validation/schemas.ts\n */\n/**\n * Request to execute a command\n */\nexport interface ExecuteRequest {\n command: string;\n sessionId?: string;\n background?: boolean;\n timeoutMs?: number;\n}\n/**\n * Request to start a background process\n * Uses flat structure consistent with other endpoints\n */\nexport interface StartProcessRequest {\n command: string;\n sessionId?: string;\n processId?: string;\n timeoutMs?: number;\n env?: Record<string, string>;\n cwd?: string;\n encoding?: string;\n autoCleanup?: boolean;\n}\n/**\n * Request to read a file\n */\nexport interface ReadFileRequest {\n path: string;\n encoding?: string;\n sessionId?: string;\n}\n/**\n * Request to write a file\n */\nexport interface WriteFileRequest {\n path: string;\n content: string;\n encoding?: string;\n sessionId?: string;\n}\n/**\n * Request to delete a file\n */\nexport interface DeleteFileRequest {\n path: string;\n sessionId?: string;\n}\n/**\n * Request to rename a file\n */\nexport interface RenameFileRequest {\n oldPath: string;\n newPath: string;\n sessionId?: string;\n}\n/**\n * Request to move a file\n */\nexport interface MoveFileRequest {\n sourcePath: string;\n destinationPath: string;\n sessionId?: string;\n}\n/**\n * Request to create a directory\n */\nexport interface MkdirRequest {\n path: string;\n recursive?: boolean;\n sessionId?: string;\n}\n/**\n * Request to check if a file or directory exists\n */\nexport interface FileExistsRequest {\n path: string;\n sessionId?: string;\n}\n/**\n * Request to expose a port\n */\nexport interface ExposePortRequest {\n port: number;\n name?: string;\n}\n/**\n * Request to clone a Git repository\n */\nexport interface GitCheckoutRequest {\n repoUrl: string;\n branch?: string;\n targetDir?: string;\n sessionId?: string;\n}\n/**\n * Request to create a session\n */\nexport interface SessionCreateRequest {\n id?: string;\n name?: string;\n env?: Record<string, string>;\n cwd?: string;\n}\n/**\n * Request to delete a session\n */\nexport interface SessionDeleteRequest {\n sessionId: string;\n}\n//# sourceMappingURL=request-types.d.ts.map","/**\n * Centralized error code registry\n * Each code maps to a specific error type with consistent semantics\n */\nexport declare const ErrorCode: {\n readonly FILE_NOT_FOUND: \"FILE_NOT_FOUND\";\n readonly PERMISSION_DENIED: \"PERMISSION_DENIED\";\n readonly FILE_EXISTS: \"FILE_EXISTS\";\n readonly IS_DIRECTORY: \"IS_DIRECTORY\";\n readonly NOT_DIRECTORY: \"NOT_DIRECTORY\";\n readonly NO_SPACE: \"NO_SPACE\";\n readonly TOO_MANY_FILES: \"TOO_MANY_FILES\";\n readonly RESOURCE_BUSY: \"RESOURCE_BUSY\";\n readonly READ_ONLY: \"READ_ONLY\";\n readonly NAME_TOO_LONG: \"NAME_TOO_LONG\";\n readonly TOO_MANY_LINKS: \"TOO_MANY_LINKS\";\n readonly FILESYSTEM_ERROR: \"FILESYSTEM_ERROR\";\n readonly COMMAND_NOT_FOUND: \"COMMAND_NOT_FOUND\";\n readonly COMMAND_PERMISSION_DENIED: \"COMMAND_PERMISSION_DENIED\";\n readonly INVALID_COMMAND: \"INVALID_COMMAND\";\n readonly COMMAND_EXECUTION_ERROR: \"COMMAND_EXECUTION_ERROR\";\n readonly STREAM_START_ERROR: \"STREAM_START_ERROR\";\n readonly PROCESS_NOT_FOUND: \"PROCESS_NOT_FOUND\";\n readonly PROCESS_PERMISSION_DENIED: \"PROCESS_PERMISSION_DENIED\";\n readonly PROCESS_ERROR: \"PROCESS_ERROR\";\n readonly PORT_ALREADY_EXPOSED: \"PORT_ALREADY_EXPOSED\";\n readonly PORT_IN_USE: \"PORT_IN_USE\";\n readonly PORT_NOT_EXPOSED: \"PORT_NOT_EXPOSED\";\n readonly INVALID_PORT_NUMBER: \"INVALID_PORT_NUMBER\";\n readonly INVALID_PORT: \"INVALID_PORT\";\n readonly SERVICE_NOT_RESPONDING: \"SERVICE_NOT_RESPONDING\";\n readonly PORT_OPERATION_ERROR: \"PORT_OPERATION_ERROR\";\n readonly CUSTOM_DOMAIN_REQUIRED: \"CUSTOM_DOMAIN_REQUIRED\";\n readonly GIT_REPOSITORY_NOT_FOUND: \"GIT_REPOSITORY_NOT_FOUND\";\n readonly GIT_BRANCH_NOT_FOUND: \"GIT_BRANCH_NOT_FOUND\";\n readonly GIT_AUTH_FAILED: \"GIT_AUTH_FAILED\";\n readonly GIT_NETWORK_ERROR: \"GIT_NETWORK_ERROR\";\n readonly INVALID_GIT_URL: \"INVALID_GIT_URL\";\n readonly GIT_CLONE_FAILED: \"GIT_CLONE_FAILED\";\n readonly GIT_CHECKOUT_FAILED: \"GIT_CHECKOUT_FAILED\";\n readonly GIT_OPERATION_FAILED: \"GIT_OPERATION_FAILED\";\n readonly BUCKET_MOUNT_ERROR: \"BUCKET_MOUNT_ERROR\";\n readonly S3FS_MOUNT_ERROR: \"S3FS_MOUNT_ERROR\";\n readonly MISSING_CREDENTIALS: \"MISSING_CREDENTIALS\";\n readonly INVALID_MOUNT_CONFIG: \"INVALID_MOUNT_CONFIG\";\n readonly INTERPRETER_NOT_READY: \"INTERPRETER_NOT_READY\";\n readonly CONTEXT_NOT_FOUND: \"CONTEXT_NOT_FOUND\";\n readonly CODE_EXECUTION_ERROR: \"CODE_EXECUTION_ERROR\";\n readonly VALIDATION_FAILED: \"VALIDATION_FAILED\";\n readonly INVALID_JSON_RESPONSE: \"INVALID_JSON_RESPONSE\";\n readonly UNKNOWN_ERROR: \"UNKNOWN_ERROR\";\n readonly INTERNAL_ERROR: \"INTERNAL_ERROR\";\n};\nexport type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];\n//# sourceMappingURL=codes.d.ts.map"],"mappings":";;;;;;;;AC8H8E,UD1G7DC,mBAAAA,CC0G6D;;;;EChHjE,SAAA,CAAA,EAAA,MAAe;EAIL,GAAA,CAAA,EFObC,MEPa,CAAA,MAAA,EAAA,MAAA,CAAA;EAUV,GAAA,CAAA,EAAA,MAAA;EACA,QAAA,CAAA,EAAA,MAAA;EAAR,WAAA,CAAA,EAAA,OAAA;;;;;;AFTL;;;;AC2CA;;;;;;;AA+DA;;;;;;;iBA/DuB,UAAA,SACb,eAAe,cACtB,eAAe,WAAW;;;ACnD7B;;;;;;;;;;;;AAyH4B,iBDTN,WAAA,CCSM,MAAA,EDTc,cCSd,CDT6B,UCS7B,CAAA,CAAA,EDT2C,OCS3C,CAAA;EAckB,OAAA,EAAA,MAAA,GDtB1B,UCsB0B;EAAO,QAAA,EDrBzC,YCqByC;;;;cAvIxC,eAAA;EFMID,QAAAA,iBAAmB;;uBEFb;;AD6CvB;;EACU,iBAAA,CAAA,OAAA,CAAA,ECpCG,oBDoCH,CAAA,ECnCL,ODmCK,CCnCG,WDmCH,CAAA;EACQ;;;EAAD,OAAA,CAAA,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,ECtBJ,cDsBI,CAAA,ECrBZ,ODqBY,CCrBJ,SDqBI,CAAA;EA6DK;;;EACF,aAAA,CAAA,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,ECtCP,cDsCO,CAAA,ECrCf,ODqCe,CCrCP,cDqCO,CAAA;EACR;;;sBCOgB,QAAQ;;;AAzHpC;EAIuB,iBAAA,CAAA,SAAA,EAAA,MAAA,CAAA,EAmIuB,OAnIvB,C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,WAAA,CAAA,OAAA,EAAA,MAAA"}
1
+ {"version":3,"file":"index.d.ts","names":["ExecuteRequest","Record","StartProcessRequest","ReadFileRequest","WriteFileRequest","DeleteFileRequest","RenameFileRequest","MoveFileRequest","MkdirRequest","FileExistsRequest","ExposePortRequest","GitCheckoutRequest","SessionCreateRequest","SessionDeleteRequest","ErrorCode"],"sources":["../../shared/dist/request-types.d.ts","../src/file-stream.ts","../src/interpreter.ts","../src/request-handler.ts","../src/sse-parser.ts","../../shared/dist/errors/codes.d.ts","../src/storage-mount/errors.ts"],"sourcesContent":["/**\n * Request types for API calls to the container\n * These types enforce the contract between the Durable Object client and container handlers\n *\n * IMPORTANT: These types must match the Zod schemas in:\n * @repo/sandbox-container/src/validation/schemas.ts\n */\n/**\n * Request to execute a command\n */\nexport interface ExecuteRequest {\n command: string;\n sessionId?: string;\n background?: boolean;\n timeoutMs?: number;\n env?: Record<string, string>;\n cwd?: string;\n}\n/**\n * Request to start a background process\n * Uses flat structure consistent with other endpoints\n */\nexport interface StartProcessRequest {\n command: string;\n sessionId?: string;\n processId?: string;\n timeoutMs?: number;\n env?: Record<string, string>;\n cwd?: string;\n encoding?: string;\n autoCleanup?: boolean;\n}\n/**\n * Request to read a file\n */\nexport interface ReadFileRequest {\n path: string;\n encoding?: string;\n sessionId?: string;\n}\n/**\n * Request to write a file\n */\nexport interface WriteFileRequest {\n path: string;\n content: string;\n encoding?: string;\n sessionId?: string;\n}\n/**\n * Request to delete a file\n */\nexport interface DeleteFileRequest {\n path: string;\n sessionId?: string;\n}\n/**\n * Request to rename a file\n */\nexport interface RenameFileRequest {\n oldPath: string;\n newPath: string;\n sessionId?: string;\n}\n/**\n * Request to move a file\n */\nexport interface MoveFileRequest {\n sourcePath: string;\n destinationPath: string;\n sessionId?: string;\n}\n/**\n * Request to create a directory\n */\nexport interface MkdirRequest {\n path: string;\n recursive?: boolean;\n sessionId?: string;\n}\n/**\n * Request to check if a file or directory exists\n */\nexport interface FileExistsRequest {\n path: string;\n sessionId?: string;\n}\n/**\n * Request to expose a port\n */\nexport interface ExposePortRequest {\n port: number;\n name?: string;\n}\n/**\n * Request to clone a Git repository\n */\nexport interface GitCheckoutRequest {\n repoUrl: string;\n branch?: string;\n targetDir?: string;\n sessionId?: string;\n}\n/**\n * Request to create a session\n */\nexport interface SessionCreateRequest {\n id?: string;\n name?: string;\n env?: Record<string, string>;\n cwd?: string;\n}\n/**\n * Request to delete a session\n */\nexport interface SessionDeleteRequest {\n sessionId: string;\n}\n//# sourceMappingURL=request-types.d.ts.map","/**\n * Centralized error code registry\n * Each code maps to a specific error type with consistent semantics\n */\nexport declare const ErrorCode: {\n readonly FILE_NOT_FOUND: \"FILE_NOT_FOUND\";\n readonly PERMISSION_DENIED: \"PERMISSION_DENIED\";\n readonly FILE_EXISTS: \"FILE_EXISTS\";\n readonly IS_DIRECTORY: \"IS_DIRECTORY\";\n readonly NOT_DIRECTORY: \"NOT_DIRECTORY\";\n readonly NO_SPACE: \"NO_SPACE\";\n readonly TOO_MANY_FILES: \"TOO_MANY_FILES\";\n readonly RESOURCE_BUSY: \"RESOURCE_BUSY\";\n readonly READ_ONLY: \"READ_ONLY\";\n readonly NAME_TOO_LONG: \"NAME_TOO_LONG\";\n readonly TOO_MANY_LINKS: \"TOO_MANY_LINKS\";\n readonly FILESYSTEM_ERROR: \"FILESYSTEM_ERROR\";\n readonly COMMAND_NOT_FOUND: \"COMMAND_NOT_FOUND\";\n readonly COMMAND_PERMISSION_DENIED: \"COMMAND_PERMISSION_DENIED\";\n readonly INVALID_COMMAND: \"INVALID_COMMAND\";\n readonly COMMAND_EXECUTION_ERROR: \"COMMAND_EXECUTION_ERROR\";\n readonly STREAM_START_ERROR: \"STREAM_START_ERROR\";\n readonly PROCESS_NOT_FOUND: \"PROCESS_NOT_FOUND\";\n readonly PROCESS_PERMISSION_DENIED: \"PROCESS_PERMISSION_DENIED\";\n readonly PROCESS_ERROR: \"PROCESS_ERROR\";\n readonly PORT_ALREADY_EXPOSED: \"PORT_ALREADY_EXPOSED\";\n readonly PORT_IN_USE: \"PORT_IN_USE\";\n readonly PORT_NOT_EXPOSED: \"PORT_NOT_EXPOSED\";\n readonly INVALID_PORT_NUMBER: \"INVALID_PORT_NUMBER\";\n readonly INVALID_PORT: \"INVALID_PORT\";\n readonly SERVICE_NOT_RESPONDING: \"SERVICE_NOT_RESPONDING\";\n readonly PORT_OPERATION_ERROR: \"PORT_OPERATION_ERROR\";\n readonly CUSTOM_DOMAIN_REQUIRED: \"CUSTOM_DOMAIN_REQUIRED\";\n readonly GIT_REPOSITORY_NOT_FOUND: \"GIT_REPOSITORY_NOT_FOUND\";\n readonly GIT_BRANCH_NOT_FOUND: \"GIT_BRANCH_NOT_FOUND\";\n readonly GIT_AUTH_FAILED: \"GIT_AUTH_FAILED\";\n readonly GIT_NETWORK_ERROR: \"GIT_NETWORK_ERROR\";\n readonly INVALID_GIT_URL: \"INVALID_GIT_URL\";\n readonly GIT_CLONE_FAILED: \"GIT_CLONE_FAILED\";\n readonly GIT_CHECKOUT_FAILED: \"GIT_CHECKOUT_FAILED\";\n readonly GIT_OPERATION_FAILED: \"GIT_OPERATION_FAILED\";\n readonly BUCKET_MOUNT_ERROR: \"BUCKET_MOUNT_ERROR\";\n readonly S3FS_MOUNT_ERROR: \"S3FS_MOUNT_ERROR\";\n readonly MISSING_CREDENTIALS: \"MISSING_CREDENTIALS\";\n readonly INVALID_MOUNT_CONFIG: \"INVALID_MOUNT_CONFIG\";\n readonly INTERPRETER_NOT_READY: \"INTERPRETER_NOT_READY\";\n readonly CONTEXT_NOT_FOUND: \"CONTEXT_NOT_FOUND\";\n readonly CODE_EXECUTION_ERROR: \"CODE_EXECUTION_ERROR\";\n readonly VALIDATION_FAILED: \"VALIDATION_FAILED\";\n readonly INVALID_JSON_RESPONSE: \"INVALID_JSON_RESPONSE\";\n readonly UNKNOWN_ERROR: \"UNKNOWN_ERROR\";\n readonly INTERNAL_ERROR: \"INTERNAL_ERROR\";\n};\nexport type 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,EAAA,IAAA,CAAA,EKlDQ,SLkDR;;;AA6D7B;;AAA0C,cKrG7B,cAAA,SAAuB,gBAAA,CLqGM;EACtB,WAAA,CAAA,OAAA,EAAA,MAAA;;;;;cK5FP,uBAAA,SAAgC,gBAAA;;AJrB7C;;;;AAeK,cIgBQ,uBAAA,SAAgC,gBAAA,CJhBxC;EAcQ,WAAA,CAAA,OAAA,EAAA,MAAA"}
package/dist/index.js CHANGED
@@ -834,13 +834,17 @@ var CommandClient = class extends BaseHttpClient {
834
834
  * @param command - The command to execute
835
835
  * @param sessionId - The session ID for this command execution
836
836
  * @param timeoutMs - Optional timeout in milliseconds (unlimited by default)
837
+ * @param env - Optional environment variables for this command
838
+ * @param cwd - Optional working directory for this command
837
839
  */
838
- async execute(command, sessionId, timeoutMs) {
840
+ async execute(command, sessionId, options) {
839
841
  try {
840
842
  const data = {
841
843
  command,
842
844
  sessionId,
843
- ...timeoutMs !== void 0 && { timeoutMs }
845
+ ...options?.timeoutMs !== void 0 && { timeoutMs: options.timeoutMs },
846
+ ...options?.env !== void 0 && { env: options.env },
847
+ ...options?.cwd !== void 0 && { cwd: options.cwd }
844
848
  };
845
849
  const response = await this.post("/api/execute", data);
846
850
  this.logSuccess("Command executed", `${command}, Success: ${response.success}`);
@@ -856,12 +860,16 @@ var CommandClient = class extends BaseHttpClient {
856
860
  * Execute a command and return a stream of events
857
861
  * @param command - The command to execute
858
862
  * @param sessionId - The session ID for this command execution
863
+ * @param options - Optional per-command execution settings
859
864
  */
860
- async executeStream(command, sessionId) {
865
+ async executeStream(command, sessionId, options) {
861
866
  try {
862
867
  const data = {
863
868
  command,
864
- sessionId
869
+ sessionId,
870
+ ...options?.timeoutMs !== void 0 && { timeoutMs: options.timeoutMs },
871
+ ...options?.env !== void 0 && { env: options.env },
872
+ ...options?.cwd !== void 0 && { cwd: options.cwd }
865
873
  };
866
874
  const response = await this.doFetch("/api/execute/stream", {
867
875
  method: "POST",
@@ -1377,7 +1385,12 @@ var ProcessClient = class extends BaseHttpClient {
1377
1385
  const data = {
1378
1386
  command,
1379
1387
  sessionId,
1380
- processId: options?.processId
1388
+ ...options?.processId !== void 0 && { processId: options.processId },
1389
+ ...options?.timeoutMs !== void 0 && { timeoutMs: options.timeoutMs },
1390
+ ...options?.env !== void 0 && { env: options.env },
1391
+ ...options?.cwd !== void 0 && { cwd: options.cwd },
1392
+ ...options?.encoding !== void 0 && { encoding: options.encoding },
1393
+ ...options?.autoCleanup !== void 0 && { autoCleanup: options.autoCleanup }
1381
1394
  };
1382
1395
  const response = await this.post("/api/process/start", data);
1383
1396
  this.logSuccess("Process started", `${command} (ID: ${response.processId})`);
@@ -2042,7 +2055,7 @@ function resolveS3fsOptions(provider, userOptions) {
2042
2055
  * This file is auto-updated by .github/changeset-version.ts during releases
2043
2056
  * DO NOT EDIT MANUALLY - Changes will be overwritten on the next version bump
2044
2057
  */
2045
- const SDK_VERSION = "0.5.2";
2058
+ const SDK_VERSION = "0.5.3";
2046
2059
 
2047
2060
  //#endregion
2048
2061
  //#region src/sandbox.ts
@@ -2527,7 +2540,12 @@ var Sandbox = class extends Container {
2527
2540
  let result;
2528
2541
  if (options?.stream && options?.onOutput) result = await this.executeWithStreaming(command, sessionId, options, startTime, timestamp);
2529
2542
  else {
2530
- const response = await this.client.commands.execute(command, sessionId);
2543
+ const commandOptions = options && (options.timeout !== void 0 || options.env !== void 0 || options.cwd !== void 0) ? {
2544
+ timeoutMs: options.timeout,
2545
+ env: options.env,
2546
+ cwd: options.cwd
2547
+ } : void 0;
2548
+ const response = await this.client.commands.execute(command, sessionId, commandOptions);
2531
2549
  const duration = Date.now() - startTime;
2532
2550
  result = this.mapExecuteResponseToExecResult(response, duration, sessionId);
2533
2551
  }
@@ -2542,7 +2560,11 @@ var Sandbox = class extends Container {
2542
2560
  let stdout = "";
2543
2561
  let stderr = "";
2544
2562
  try {
2545
- const stream = await this.client.commands.executeStream(command, sessionId);
2563
+ const stream = await this.client.commands.executeStream(command, sessionId, {
2564
+ timeoutMs: options.timeout,
2565
+ env: options.env,
2566
+ cwd: options.cwd
2567
+ });
2546
2568
  for await (const event of parseSSEStream(stream)) {
2547
2569
  if (options.signal?.aborted) throw new Error("Operation was aborted");
2548
2570
  switch (event.type) {
@@ -2621,7 +2643,15 @@ var Sandbox = class extends Container {
2621
2643
  async startProcess(command, options, sessionId) {
2622
2644
  try {
2623
2645
  const session = sessionId ?? await this.ensureDefaultSession();
2624
- const response = await this.client.processes.startProcess(command, session, { processId: options?.processId });
2646
+ const requestOptions = {
2647
+ ...options?.processId !== void 0 && { processId: options.processId },
2648
+ ...options?.timeout !== void 0 && { timeoutMs: options.timeout },
2649
+ ...options?.env !== void 0 && { env: options.env },
2650
+ ...options?.cwd !== void 0 && { cwd: options.cwd },
2651
+ ...options?.encoding !== void 0 && { encoding: options.encoding },
2652
+ ...options?.autoCleanup !== void 0 && { autoCleanup: options.autoCleanup }
2653
+ };
2654
+ const response = await this.client.processes.startProcess(command, session, requestOptions);
2625
2655
  const processObj = this.createProcessFromDTO({
2626
2656
  id: response.processId,
2627
2657
  pid: response.pid,
@@ -2685,14 +2715,22 @@ var Sandbox = class extends Container {
2685
2715
  async execStream(command, options) {
2686
2716
  if (options?.signal?.aborted) throw new Error("Operation was aborted");
2687
2717
  const session = await this.ensureDefaultSession();
2688
- return this.client.commands.executeStream(command, session);
2718
+ return this.client.commands.executeStream(command, session, {
2719
+ timeoutMs: options?.timeout,
2720
+ env: options?.env,
2721
+ cwd: options?.cwd
2722
+ });
2689
2723
  }
2690
2724
  /**
2691
2725
  * Internal session-aware execStream implementation
2692
2726
  */
2693
2727
  async execStreamWithSession(command, sessionId, options) {
2694
2728
  if (options?.signal?.aborted) throw new Error("Operation was aborted");
2695
- return this.client.commands.executeStream(command, sessionId);
2729
+ return this.client.commands.executeStream(command, sessionId, {
2730
+ timeoutMs: options?.timeout,
2731
+ env: options?.env,
2732
+ cwd: options?.cwd
2733
+ });
2696
2734
  }
2697
2735
  /**
2698
2736
  * Stream logs from a background process as a ReadableStream.
@@ -2852,10 +2890,15 @@ var Sandbox = class extends Container {
2852
2890
  */
2853
2891
  async createSession(options) {
2854
2892
  const sessionId = options?.id || `session-${Date.now()}`;
2893
+ const mergedEnv = {
2894
+ ...this.envVars,
2895
+ ...options?.env ?? {}
2896
+ };
2897
+ const envPayload = Object.keys(mergedEnv).length > 0 ? mergedEnv : void 0;
2855
2898
  await this.client.utils.createSession({
2856
2899
  id: sessionId,
2857
- env: options?.env,
2858
- cwd: options?.cwd
2900
+ ...envPayload && { env: envPayload },
2901
+ ...options?.cwd && { cwd: options.cwd }
2859
2902
  });
2860
2903
  return this.getSessionWrapper(sessionId);
2861
2904
  }