computesdk 1.10.2 → 1.11.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/README.md CHANGED
@@ -40,8 +40,11 @@ For more control, use `setConfig()` to explicitly configure the provider:
40
40
  import { compute } from 'computesdk';
41
41
 
42
42
  compute.setConfig({
43
- provider: 'e2b',
44
- e2b: { apiKey: 'your_api_key' }
43
+ provider: 'your-provider',
44
+ apiKey: process.env.COMPUTESDK_API_KEY,
45
+ 'your-provider': {
46
+ apiKey: process.env.YOUR_PROVIDER_API_KEY
47
+ }
45
48
  });
46
49
 
47
50
  const sandbox = await compute.sandbox.create();
@@ -84,8 +87,11 @@ Configure the gateway with explicit provider settings.
84
87
 
85
88
  ```typescript
86
89
  compute.setConfig({
87
- provider: 'e2b',
88
- e2b: { apiKey: 'your_api_key' }
90
+ provider: 'your-provider',
91
+ apiKey: process.env.COMPUTESDK_API_KEY,
92
+ 'your-provider': {
93
+ apiKey: process.env.YOUR_PROVIDER_API_KEY
94
+ }
89
95
  });
90
96
  ```
91
97
 
@@ -95,6 +101,7 @@ compute.setConfig({
95
101
  // E2B
96
102
  compute.setConfig({
97
103
  provider: 'e2b',
104
+ apiKey: process.env.COMPUTESDK_API_KEY,
98
105
  e2b: {
99
106
  apiKey: 'e2b_xxx',
100
107
  templateId: 'optional_template'
@@ -104,6 +111,7 @@ compute.setConfig({
104
111
  // Modal
105
112
  compute.setConfig({
106
113
  provider: 'modal',
114
+ apiKey: process.env.COMPUTESDK_API_KEY,
107
115
  modal: {
108
116
  tokenId: 'ak-xxx',
109
117
  tokenSecret: 'as-xxx'
@@ -113,6 +121,7 @@ compute.setConfig({
113
121
  // Railway
114
122
  compute.setConfig({
115
123
  provider: 'railway',
124
+ apiKey: process.env.COMPUTESDK_API_KEY,
116
125
  railway: {
117
126
  apiToken: 'your_token',
118
127
  projectId: 'project_id',
@@ -123,12 +132,14 @@ compute.setConfig({
123
132
  // Daytona
124
133
  compute.setConfig({
125
134
  provider: 'daytona',
135
+ apiKey: process.env.COMPUTESDK_API_KEY,
126
136
  daytona: { apiKey: 'your_api_key' }
127
137
  });
128
138
 
129
139
  // Vercel
130
140
  compute.setConfig({
131
141
  provider: 'vercel',
142
+ apiKey: process.env.COMPUTESDK_API_KEY,
132
143
  vercel: {
133
144
  token: 'your_token',
134
145
  teamId: 'team_xxx',
package/dist/index.d.mts CHANGED
@@ -132,8 +132,13 @@ interface Sandbox$1 {
132
132
  readonly provider: string;
133
133
  /** Execute code in the sandbox */
134
134
  runCode(code: string, runtime?: Runtime): Promise<CodeResult$1>;
135
- /** Execute shell commands */
136
- runCommand(commandOrArray: string | [string, ...string[]], argsOrOptions?: string[] | RunCommandOptions, maybeOptions?: RunCommandOptions): Promise<CommandResult$1>;
135
+ /**
136
+ * Execute shell command
137
+ *
138
+ * Send raw command string to the sandbox - no preprocessing.
139
+ * The provider/server handles shell invocation and execution details.
140
+ */
141
+ runCommand(command: string, options?: RunCommandOptions): Promise<CommandResult$1>;
137
142
  /** Get information about the sandbox */
138
143
  getInfo(): Promise<SandboxInfo$1>;
139
144
  /** Get URL for accessing the sandbox on a specific port */
@@ -245,6 +250,42 @@ interface TerminalErrorMessage {
245
250
  error: string;
246
251
  };
247
252
  }
253
+ /**
254
+ * Command stdout streaming message (exec mode with stream: true)
255
+ */
256
+ interface CommandStdoutMessage {
257
+ type: 'command:stdout';
258
+ channel: string;
259
+ data: {
260
+ terminal_id: string;
261
+ cmd_id: string;
262
+ output: string;
263
+ };
264
+ }
265
+ /**
266
+ * Command stderr streaming message (exec mode with stream: true)
267
+ */
268
+ interface CommandStderrMessage {
269
+ type: 'command:stderr';
270
+ channel: string;
271
+ data: {
272
+ terminal_id: string;
273
+ cmd_id: string;
274
+ output: string;
275
+ };
276
+ }
277
+ /**
278
+ * Command exit message (exec mode with stream: true)
279
+ */
280
+ interface CommandExitMessage {
281
+ type: 'command:exit';
282
+ channel: string;
283
+ data: {
284
+ terminal_id: string;
285
+ cmd_id: string;
286
+ exit_code: number;
287
+ };
288
+ }
248
289
  /**
249
290
  * File watcher created notification
250
291
  */
@@ -422,6 +463,12 @@ declare class WebSocketManager {
422
463
  * Resize terminal window
423
464
  */
424
465
  resizeTerminal(terminalId: string, cols: number, rows: number): void;
466
+ /**
467
+ * Start a pending streaming command
468
+ * Used in two-phase streaming flow: HTTP request creates pending command,
469
+ * then this signal triggers execution after client has subscribed.
470
+ */
471
+ startCommand(cmdId: string): void;
425
472
  /**
426
473
  * Register event handler
427
474
  */
@@ -433,6 +480,9 @@ declare class WebSocketManager {
433
480
  on(event: 'terminal:output', handler: MessageHandler<TerminalOutputMessage>): void;
434
481
  on(event: 'terminal:destroyed', handler: MessageHandler<TerminalDestroyedMessage>): void;
435
482
  on(event: 'terminal:error', handler: MessageHandler<TerminalErrorMessage>): void;
483
+ on(event: 'command:stdout', handler: MessageHandler<CommandStdoutMessage>): void;
484
+ on(event: 'command:stderr', handler: MessageHandler<CommandStderrMessage>): void;
485
+ on(event: 'command:exit', handler: MessageHandler<CommandExitMessage>): void;
436
486
  on(event: 'watcher:created', handler: MessageHandler<WatcherCreatedMessage>): void;
437
487
  on(event: 'file:changed', handler: MessageHandler<FileChangedMessage>): void;
438
488
  on(event: 'watcher:destroyed', handler: MessageHandler<WatcherDestroyedMessage>): void;
@@ -1695,6 +1745,10 @@ interface CommandRunOptions {
1695
1745
  shell?: string;
1696
1746
  /** Run in background (optional) */
1697
1747
  background?: boolean;
1748
+ /** Working directory for the command (optional) */
1749
+ cwd?: string;
1750
+ /** Environment variables (optional) */
1751
+ env?: Record<string, string>;
1698
1752
  }
1699
1753
  /**
1700
1754
  * Run - Resource namespace for executing code and commands
@@ -1740,6 +1794,8 @@ declare class Run {
1740
1794
  * @param options - Execution options
1741
1795
  * @param options.shell - Shell to use (optional)
1742
1796
  * @param options.background - Run in background (optional)
1797
+ * @param options.cwd - Working directory for the command (optional)
1798
+ * @param options.env - Environment variables (optional)
1743
1799
  * @returns Command execution result with stdout, stderr, exit code, and duration
1744
1800
  */
1745
1801
  command(command: string, options?: CommandRunOptions): Promise<CommandResult>;
@@ -1946,6 +2002,13 @@ interface SandboxConfig {
1946
2002
  protocol?: 'json' | 'binary';
1947
2003
  /** Optional metadata associated with the sandbox */
1948
2004
  metadata?: Record<string, unknown>;
2005
+ /**
2006
+ * Handler called when destroy() is invoked.
2007
+ * If provided, this is called to destroy the sandbox (e.g., via gateway API).
2008
+ * If not provided, destroy() only disconnects the WebSocket.
2009
+ * @internal
2010
+ */
2011
+ destroyHandler?: () => Promise<void>;
1949
2012
  }
1950
2013
  /**
1951
2014
  * Health check response
@@ -2065,7 +2128,7 @@ interface FileResponse {
2065
2128
  };
2066
2129
  }
2067
2130
  /**
2068
- * Command execution response
2131
+ * Command execution response (used by both /run/command and /terminals/{id}/execute)
2069
2132
  */
2070
2133
  interface CommandExecutionResponse {
2071
2134
  message: string;
@@ -2073,12 +2136,12 @@ interface CommandExecutionResponse {
2073
2136
  terminal_id?: string;
2074
2137
  cmd_id?: string;
2075
2138
  command: string;
2076
- output?: string;
2077
2139
  stdout: string;
2078
2140
  stderr: string;
2079
2141
  exit_code?: number;
2080
2142
  duration_ms?: number;
2081
2143
  status?: 'running' | 'completed' | 'failed';
2144
+ channel?: string;
2082
2145
  pty?: boolean;
2083
2146
  };
2084
2147
  }
@@ -2131,22 +2194,6 @@ interface CodeExecutionResponse {
2131
2194
  language: string;
2132
2195
  };
2133
2196
  }
2134
- /**
2135
- * Run command response (POST /run/command)
2136
- */
2137
- interface RunCommandResponse {
2138
- message: string;
2139
- data: {
2140
- terminal_id?: string;
2141
- cmd_id?: string;
2142
- command: string;
2143
- stdout: string;
2144
- stderr: string;
2145
- exit_code?: number;
2146
- duration_ms?: number;
2147
- status?: 'running' | 'completed' | 'failed';
2148
- };
2149
- }
2150
2197
  /**
2151
2198
  * File watcher information
2152
2199
  */
@@ -2598,12 +2645,14 @@ declare class Sandbox {
2598
2645
  */
2599
2646
  runCodeRequest(code: string, language?: string): Promise<CodeExecutionResponse>;
2600
2647
  /**
2601
- * Execute a shell command (POST /run/command)
2648
+ * Execute a command and get the result
2649
+ * Lower-level method that returns the raw API response
2602
2650
  *
2603
- * @param options - Command options
2604
- * @param options.command - The command to execute
2651
+ * @param options.command - Command to execute
2605
2652
  * @param options.shell - Shell to use (optional)
2606
2653
  * @param options.background - Run in background (optional)
2654
+ * @param options.cwd - Working directory for the command (optional)
2655
+ * @param options.env - Environment variables (optional)
2607
2656
  * @returns Command execution result
2608
2657
  *
2609
2658
  * @example
@@ -2616,7 +2665,10 @@ declare class Sandbox {
2616
2665
  command: string;
2617
2666
  shell?: string;
2618
2667
  background?: boolean;
2619
- }): Promise<RunCommandResponse>;
2668
+ stream?: boolean;
2669
+ cwd?: string;
2670
+ env?: Record<string, string>;
2671
+ }): Promise<CommandExecutionResponse>;
2620
2672
  /**
2621
2673
  * List files at the specified path
2622
2674
  */
@@ -2629,6 +2681,11 @@ declare class Sandbox {
2629
2681
  * Get file metadata (without content)
2630
2682
  */
2631
2683
  getFile(path: string): Promise<FileResponse>;
2684
+ /**
2685
+ * Encode a file path for use in URLs
2686
+ * Strips leading slash and encodes each segment separately to preserve path structure
2687
+ */
2688
+ private encodeFilePath;
2632
2689
  /**
2633
2690
  * Read file content
2634
2691
  */
@@ -2891,21 +2948,47 @@ declare class Sandbox {
2891
2948
  language: string;
2892
2949
  }>;
2893
2950
  /**
2894
- * Execute shell command in the sandbox (convenience method)
2951
+ * Execute shell command in the sandbox
2895
2952
  *
2896
- * Delegates to sandbox.run.command() - prefer using that directly for new code.
2953
+ * Sends clean command string to server - no preprocessing or shell wrapping.
2954
+ * The server handles shell invocation, working directory, and backgrounding.
2897
2955
  *
2898
- * @param command - The command to execute (string or array form)
2899
- * @param argsOrOptions - Arguments array or options object
2900
- * @param maybeOptions - Options when using (command, args, options) form
2956
+ * @param command - The command to execute (raw string, e.g., "npm install")
2957
+ * @param options - Execution options
2958
+ * @param options.background - Run in background (server uses goroutines)
2959
+ * @param options.cwd - Working directory (server uses cmd.Dir)
2960
+ * @param options.env - Environment variables (server uses cmd.Env)
2961
+ * @param options.onStdout - Callback for streaming stdout data
2962
+ * @param options.onStderr - Callback for streaming stderr data
2901
2963
  * @returns Command execution result
2964
+ *
2965
+ * @example
2966
+ * ```typescript
2967
+ * // Simple command
2968
+ * await sandbox.runCommand('ls -la')
2969
+ *
2970
+ * // With working directory
2971
+ * await sandbox.runCommand('npm install', { cwd: '/app' })
2972
+ *
2973
+ * // Background with env vars
2974
+ * await sandbox.runCommand('node server.js', {
2975
+ * background: true,
2976
+ * env: { PORT: '3000' }
2977
+ * })
2978
+ *
2979
+ * // With streaming output
2980
+ * await sandbox.runCommand('npm install', {
2981
+ * onStdout: (data) => console.log(data),
2982
+ * onStderr: (data) => console.error(data),
2983
+ * })
2984
+ * ```
2902
2985
  */
2903
- runCommand(commandOrArray: string | [string, ...string[]], argsOrOptions?: string[] | {
2904
- background?: boolean;
2905
- cwd?: string;
2906
- }, maybeOptions?: {
2986
+ runCommand(command: string, options?: {
2907
2987
  background?: boolean;
2908
2988
  cwd?: string;
2989
+ env?: Record<string, string>;
2990
+ onStdout?: (data: string) => void;
2991
+ onStderr?: (data: string) => void;
2909
2992
  }): Promise<{
2910
2993
  stdout: string;
2911
2994
  stderr: string;
@@ -2948,6 +3031,9 @@ declare class Sandbox {
2948
3031
  getInstance(): this;
2949
3032
  /**
2950
3033
  * Destroy the sandbox (Sandbox interface method)
3034
+ *
3035
+ * If a destroyHandler was provided (e.g., from gateway), calls it to destroy
3036
+ * the sandbox on the backend. Otherwise, only disconnects the WebSocket.
2951
3037
  */
2952
3038
  destroy(): Promise<void>;
2953
3039
  /**
@@ -3045,8 +3131,13 @@ declare function getMissingEnvVars(provider: ProviderName): string[];
3045
3131
  interface ExplicitComputeConfig {
3046
3132
  /** Provider name to use */
3047
3133
  provider: ProviderName;
3134
+ /**
3135
+ * ComputeSDK API key (required for gateway mode)
3136
+ * @deprecated Use `computesdkApiKey` for clarity
3137
+ */
3138
+ apiKey?: string;
3048
3139
  /** ComputeSDK API key (required for gateway mode) */
3049
- apiKey: string;
3140
+ computesdkApiKey?: string;
3050
3141
  /** Optional gateway URL override */
3051
3142
  gatewayUrl?: string;
3052
3143
  /** Provider-specific configurations */
package/dist/index.d.ts CHANGED
@@ -132,8 +132,13 @@ interface Sandbox$1 {
132
132
  readonly provider: string;
133
133
  /** Execute code in the sandbox */
134
134
  runCode(code: string, runtime?: Runtime): Promise<CodeResult$1>;
135
- /** Execute shell commands */
136
- runCommand(commandOrArray: string | [string, ...string[]], argsOrOptions?: string[] | RunCommandOptions, maybeOptions?: RunCommandOptions): Promise<CommandResult$1>;
135
+ /**
136
+ * Execute shell command
137
+ *
138
+ * Send raw command string to the sandbox - no preprocessing.
139
+ * The provider/server handles shell invocation and execution details.
140
+ */
141
+ runCommand(command: string, options?: RunCommandOptions): Promise<CommandResult$1>;
137
142
  /** Get information about the sandbox */
138
143
  getInfo(): Promise<SandboxInfo$1>;
139
144
  /** Get URL for accessing the sandbox on a specific port */
@@ -245,6 +250,42 @@ interface TerminalErrorMessage {
245
250
  error: string;
246
251
  };
247
252
  }
253
+ /**
254
+ * Command stdout streaming message (exec mode with stream: true)
255
+ */
256
+ interface CommandStdoutMessage {
257
+ type: 'command:stdout';
258
+ channel: string;
259
+ data: {
260
+ terminal_id: string;
261
+ cmd_id: string;
262
+ output: string;
263
+ };
264
+ }
265
+ /**
266
+ * Command stderr streaming message (exec mode with stream: true)
267
+ */
268
+ interface CommandStderrMessage {
269
+ type: 'command:stderr';
270
+ channel: string;
271
+ data: {
272
+ terminal_id: string;
273
+ cmd_id: string;
274
+ output: string;
275
+ };
276
+ }
277
+ /**
278
+ * Command exit message (exec mode with stream: true)
279
+ */
280
+ interface CommandExitMessage {
281
+ type: 'command:exit';
282
+ channel: string;
283
+ data: {
284
+ terminal_id: string;
285
+ cmd_id: string;
286
+ exit_code: number;
287
+ };
288
+ }
248
289
  /**
249
290
  * File watcher created notification
250
291
  */
@@ -422,6 +463,12 @@ declare class WebSocketManager {
422
463
  * Resize terminal window
423
464
  */
424
465
  resizeTerminal(terminalId: string, cols: number, rows: number): void;
466
+ /**
467
+ * Start a pending streaming command
468
+ * Used in two-phase streaming flow: HTTP request creates pending command,
469
+ * then this signal triggers execution after client has subscribed.
470
+ */
471
+ startCommand(cmdId: string): void;
425
472
  /**
426
473
  * Register event handler
427
474
  */
@@ -433,6 +480,9 @@ declare class WebSocketManager {
433
480
  on(event: 'terminal:output', handler: MessageHandler<TerminalOutputMessage>): void;
434
481
  on(event: 'terminal:destroyed', handler: MessageHandler<TerminalDestroyedMessage>): void;
435
482
  on(event: 'terminal:error', handler: MessageHandler<TerminalErrorMessage>): void;
483
+ on(event: 'command:stdout', handler: MessageHandler<CommandStdoutMessage>): void;
484
+ on(event: 'command:stderr', handler: MessageHandler<CommandStderrMessage>): void;
485
+ on(event: 'command:exit', handler: MessageHandler<CommandExitMessage>): void;
436
486
  on(event: 'watcher:created', handler: MessageHandler<WatcherCreatedMessage>): void;
437
487
  on(event: 'file:changed', handler: MessageHandler<FileChangedMessage>): void;
438
488
  on(event: 'watcher:destroyed', handler: MessageHandler<WatcherDestroyedMessage>): void;
@@ -1695,6 +1745,10 @@ interface CommandRunOptions {
1695
1745
  shell?: string;
1696
1746
  /** Run in background (optional) */
1697
1747
  background?: boolean;
1748
+ /** Working directory for the command (optional) */
1749
+ cwd?: string;
1750
+ /** Environment variables (optional) */
1751
+ env?: Record<string, string>;
1698
1752
  }
1699
1753
  /**
1700
1754
  * Run - Resource namespace for executing code and commands
@@ -1740,6 +1794,8 @@ declare class Run {
1740
1794
  * @param options - Execution options
1741
1795
  * @param options.shell - Shell to use (optional)
1742
1796
  * @param options.background - Run in background (optional)
1797
+ * @param options.cwd - Working directory for the command (optional)
1798
+ * @param options.env - Environment variables (optional)
1743
1799
  * @returns Command execution result with stdout, stderr, exit code, and duration
1744
1800
  */
1745
1801
  command(command: string, options?: CommandRunOptions): Promise<CommandResult>;
@@ -1946,6 +2002,13 @@ interface SandboxConfig {
1946
2002
  protocol?: 'json' | 'binary';
1947
2003
  /** Optional metadata associated with the sandbox */
1948
2004
  metadata?: Record<string, unknown>;
2005
+ /**
2006
+ * Handler called when destroy() is invoked.
2007
+ * If provided, this is called to destroy the sandbox (e.g., via gateway API).
2008
+ * If not provided, destroy() only disconnects the WebSocket.
2009
+ * @internal
2010
+ */
2011
+ destroyHandler?: () => Promise<void>;
1949
2012
  }
1950
2013
  /**
1951
2014
  * Health check response
@@ -2065,7 +2128,7 @@ interface FileResponse {
2065
2128
  };
2066
2129
  }
2067
2130
  /**
2068
- * Command execution response
2131
+ * Command execution response (used by both /run/command and /terminals/{id}/execute)
2069
2132
  */
2070
2133
  interface CommandExecutionResponse {
2071
2134
  message: string;
@@ -2073,12 +2136,12 @@ interface CommandExecutionResponse {
2073
2136
  terminal_id?: string;
2074
2137
  cmd_id?: string;
2075
2138
  command: string;
2076
- output?: string;
2077
2139
  stdout: string;
2078
2140
  stderr: string;
2079
2141
  exit_code?: number;
2080
2142
  duration_ms?: number;
2081
2143
  status?: 'running' | 'completed' | 'failed';
2144
+ channel?: string;
2082
2145
  pty?: boolean;
2083
2146
  };
2084
2147
  }
@@ -2131,22 +2194,6 @@ interface CodeExecutionResponse {
2131
2194
  language: string;
2132
2195
  };
2133
2196
  }
2134
- /**
2135
- * Run command response (POST /run/command)
2136
- */
2137
- interface RunCommandResponse {
2138
- message: string;
2139
- data: {
2140
- terminal_id?: string;
2141
- cmd_id?: string;
2142
- command: string;
2143
- stdout: string;
2144
- stderr: string;
2145
- exit_code?: number;
2146
- duration_ms?: number;
2147
- status?: 'running' | 'completed' | 'failed';
2148
- };
2149
- }
2150
2197
  /**
2151
2198
  * File watcher information
2152
2199
  */
@@ -2598,12 +2645,14 @@ declare class Sandbox {
2598
2645
  */
2599
2646
  runCodeRequest(code: string, language?: string): Promise<CodeExecutionResponse>;
2600
2647
  /**
2601
- * Execute a shell command (POST /run/command)
2648
+ * Execute a command and get the result
2649
+ * Lower-level method that returns the raw API response
2602
2650
  *
2603
- * @param options - Command options
2604
- * @param options.command - The command to execute
2651
+ * @param options.command - Command to execute
2605
2652
  * @param options.shell - Shell to use (optional)
2606
2653
  * @param options.background - Run in background (optional)
2654
+ * @param options.cwd - Working directory for the command (optional)
2655
+ * @param options.env - Environment variables (optional)
2607
2656
  * @returns Command execution result
2608
2657
  *
2609
2658
  * @example
@@ -2616,7 +2665,10 @@ declare class Sandbox {
2616
2665
  command: string;
2617
2666
  shell?: string;
2618
2667
  background?: boolean;
2619
- }): Promise<RunCommandResponse>;
2668
+ stream?: boolean;
2669
+ cwd?: string;
2670
+ env?: Record<string, string>;
2671
+ }): Promise<CommandExecutionResponse>;
2620
2672
  /**
2621
2673
  * List files at the specified path
2622
2674
  */
@@ -2629,6 +2681,11 @@ declare class Sandbox {
2629
2681
  * Get file metadata (without content)
2630
2682
  */
2631
2683
  getFile(path: string): Promise<FileResponse>;
2684
+ /**
2685
+ * Encode a file path for use in URLs
2686
+ * Strips leading slash and encodes each segment separately to preserve path structure
2687
+ */
2688
+ private encodeFilePath;
2632
2689
  /**
2633
2690
  * Read file content
2634
2691
  */
@@ -2891,21 +2948,47 @@ declare class Sandbox {
2891
2948
  language: string;
2892
2949
  }>;
2893
2950
  /**
2894
- * Execute shell command in the sandbox (convenience method)
2951
+ * Execute shell command in the sandbox
2895
2952
  *
2896
- * Delegates to sandbox.run.command() - prefer using that directly for new code.
2953
+ * Sends clean command string to server - no preprocessing or shell wrapping.
2954
+ * The server handles shell invocation, working directory, and backgrounding.
2897
2955
  *
2898
- * @param command - The command to execute (string or array form)
2899
- * @param argsOrOptions - Arguments array or options object
2900
- * @param maybeOptions - Options when using (command, args, options) form
2956
+ * @param command - The command to execute (raw string, e.g., "npm install")
2957
+ * @param options - Execution options
2958
+ * @param options.background - Run in background (server uses goroutines)
2959
+ * @param options.cwd - Working directory (server uses cmd.Dir)
2960
+ * @param options.env - Environment variables (server uses cmd.Env)
2961
+ * @param options.onStdout - Callback for streaming stdout data
2962
+ * @param options.onStderr - Callback for streaming stderr data
2901
2963
  * @returns Command execution result
2964
+ *
2965
+ * @example
2966
+ * ```typescript
2967
+ * // Simple command
2968
+ * await sandbox.runCommand('ls -la')
2969
+ *
2970
+ * // With working directory
2971
+ * await sandbox.runCommand('npm install', { cwd: '/app' })
2972
+ *
2973
+ * // Background with env vars
2974
+ * await sandbox.runCommand('node server.js', {
2975
+ * background: true,
2976
+ * env: { PORT: '3000' }
2977
+ * })
2978
+ *
2979
+ * // With streaming output
2980
+ * await sandbox.runCommand('npm install', {
2981
+ * onStdout: (data) => console.log(data),
2982
+ * onStderr: (data) => console.error(data),
2983
+ * })
2984
+ * ```
2902
2985
  */
2903
- runCommand(commandOrArray: string | [string, ...string[]], argsOrOptions?: string[] | {
2904
- background?: boolean;
2905
- cwd?: string;
2906
- }, maybeOptions?: {
2986
+ runCommand(command: string, options?: {
2907
2987
  background?: boolean;
2908
2988
  cwd?: string;
2989
+ env?: Record<string, string>;
2990
+ onStdout?: (data: string) => void;
2991
+ onStderr?: (data: string) => void;
2909
2992
  }): Promise<{
2910
2993
  stdout: string;
2911
2994
  stderr: string;
@@ -2948,6 +3031,9 @@ declare class Sandbox {
2948
3031
  getInstance(): this;
2949
3032
  /**
2950
3033
  * Destroy the sandbox (Sandbox interface method)
3034
+ *
3035
+ * If a destroyHandler was provided (e.g., from gateway), calls it to destroy
3036
+ * the sandbox on the backend. Otherwise, only disconnects the WebSocket.
2951
3037
  */
2952
3038
  destroy(): Promise<void>;
2953
3039
  /**
@@ -3045,8 +3131,13 @@ declare function getMissingEnvVars(provider: ProviderName): string[];
3045
3131
  interface ExplicitComputeConfig {
3046
3132
  /** Provider name to use */
3047
3133
  provider: ProviderName;
3134
+ /**
3135
+ * ComputeSDK API key (required for gateway mode)
3136
+ * @deprecated Use `computesdkApiKey` for clarity
3137
+ */
3138
+ apiKey?: string;
3048
3139
  /** ComputeSDK API key (required for gateway mode) */
3049
- apiKey: string;
3140
+ computesdkApiKey?: string;
3050
3141
  /** Optional gateway URL override */
3051
3142
  gatewayUrl?: string;
3052
3143
  /** Provider-specific configurations */