computesdk 2.5.4 → 2.6.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/dist/index.d.ts CHANGED
@@ -10,11 +10,11 @@
10
10
  * - terminal, server, watcher, auth, env, etc.
11
11
  *
12
12
  * Providers can implement as much or as little as makes sense for their platform.
13
- * The gateway Sandbox class implements the full specification.
13
+ * The Sandbox client class implements the full specification.
14
14
  *
15
15
  * **Note on naming:** This interface is named "Sandbox" in this file for clarity,
16
16
  * but is exported as "SandboxInterface" from the main computesdk package to avoid
17
- * collision with the gateway Sandbox class. The rename happens at export time in
17
+ * collision with the Sandbox client class. The rename happens at export time in
18
18
  * src/index.ts. Providers using @computesdk/provider will only see "SandboxInterface".
19
19
  *
20
20
  * @example Minimal implementation
@@ -183,7 +183,7 @@ interface SandboxServerConfig {
183
183
  interface Sandbox$1 {
184
184
  /** Unique identifier for the sandbox */
185
185
  readonly sandboxId: string;
186
- /** Provider name (e2b, railway, modal, gateway, etc.) */
186
+ /** Provider name (e2b, railway, modal, etc.) */
187
187
  readonly provider: string;
188
188
  /** Execute code in the sandbox */
189
189
  runCode(code: string, runtime?: Runtime): Promise<CodeResult$1>;
@@ -207,57 +207,57 @@ interface Sandbox$1 {
207
207
  readonly filesystem: SandboxFileSystem;
208
208
  /**
209
209
  * Terminal management (interactive PTY and exec modes)
210
- * Available in: gateway, e2b (potentially)
210
+ * Available in: sandbox client, e2b (potentially)
211
211
  */
212
212
  readonly terminal?: any;
213
213
  /**
214
214
  * Code and command execution namespace
215
- * Available in: gateway
215
+ * Available in: sandbox client
216
216
  */
217
217
  readonly run?: any;
218
218
  /**
219
219
  * Managed server operations
220
- * Available in: gateway
220
+ * Available in: sandbox client
221
221
  */
222
222
  readonly server?: any;
223
223
  /**
224
224
  * File watcher with real-time change events
225
- * Available in: gateway
225
+ * Available in: sandbox client
226
226
  */
227
227
  readonly watcher?: any;
228
228
  /**
229
229
  * Session token management
230
- * Available in: gateway
230
+ * Available in: sandbox client
231
231
  */
232
232
  readonly sessionToken?: any;
233
233
  /**
234
234
  * Magic link authentication
235
- * Available in: gateway
235
+ * Available in: sandbox client
236
236
  */
237
237
  readonly magicLink?: any;
238
238
  /**
239
239
  * Signal service for port/error events
240
- * Available in: gateway
240
+ * Available in: sandbox client
241
241
  */
242
242
  readonly signal?: any;
243
243
  /**
244
244
  * File operations namespace
245
- * Available in: gateway
245
+ * Available in: sandbox client
246
246
  */
247
247
  readonly file?: any;
248
248
  /**
249
249
  * Environment variable management
250
- * Available in: gateway
250
+ * Available in: sandbox client
251
251
  */
252
252
  readonly env?: any;
253
253
  /**
254
254
  * Authentication operations
255
- * Available in: gateway
255
+ * Available in: sandbox client
256
256
  */
257
257
  readonly auth?: any;
258
258
  /**
259
259
  * Child sandbox management
260
- * Available in: gateway
260
+ * Available in: sandbox client
261
261
  */
262
262
  readonly child?: any;
263
263
  }
@@ -2257,7 +2257,7 @@ declare class Run {
2257
2257
  /**
2258
2258
  * Client Types
2259
2259
  *
2260
- * Types specific to the gateway Sandbox client implementation.
2260
+ * Types specific to the Sandbox client implementation.
2261
2261
  * Core universal types are imported from ../types/universal-sandbox
2262
2262
  */
2263
2263
 
@@ -2266,7 +2266,7 @@ declare class Run {
2266
2266
  */
2267
2267
  type SandboxStatus = 'running' | 'stopped' | 'error';
2268
2268
  /**
2269
- * Provider-agnostic sandbox info (alias for SandboxInfo for backward compatibility)
2269
+ * Provider-agnostic sandbox info
2270
2270
  */
2271
2271
  interface ProviderSandboxInfo {
2272
2272
  /** Unique identifier for the sandbox */
@@ -2461,13 +2461,13 @@ type WebSocketConstructor = new (url: string) => WebSocket;
2461
2461
  * Configuration options for creating a Sandbox
2462
2462
  */
2463
2463
  interface SandboxConfig {
2464
- /** API endpoint URL (e.g., https://sandbox-123.sandbox.computesdk.com). Optional in browser - can be auto-detected from URL query param or localStorage */
2464
+ /** API endpoint URL (e.g., https://sandbox-123.sandbox.computesdk.com). Optional in browser - can be detected from URL query param or localStorage */
2465
2465
  sandboxUrl?: string;
2466
2466
  /** Sandbox ID */
2467
2467
  sandboxId: string;
2468
- /** Provider name (e.g., 'e2b', 'gateway') */
2468
+ /** Provider name (e.g., 'e2b', 'modal') */
2469
2469
  provider: string;
2470
- /** Access token or session token for authentication. Optional in browser - can be auto-detected from URL query param or localStorage */
2470
+ /** Access token or session token for authentication. Optional in browser - can be detected from URL query param or localStorage */
2471
2471
  token?: string;
2472
2472
  /** Optional headers to include with all requests */
2473
2473
  headers?: Record<string, string>;
@@ -2481,7 +2481,7 @@ interface SandboxConfig {
2481
2481
  metadata?: Record<string, unknown>;
2482
2482
  /**
2483
2483
  * Handler called when destroy() is invoked.
2484
- * If provided, this is called to destroy the sandbox (e.g., via gateway API).
2484
+ * If provided, this is called to destroy the sandbox through an external API.
2485
2485
  * If not provided, destroy() only disconnects the WebSocket.
2486
2486
  * @internal
2487
2487
  */
@@ -3023,7 +3023,7 @@ interface BatchWriteResponse {
3023
3023
  };
3024
3024
  }
3025
3025
  /**
3026
- * Sandbox - Full-featured gateway sandbox implementation
3026
+ * Sandbox - Full-featured sandbox client implementation
3027
3027
  *
3028
3028
  * Provides complete feature set including:
3029
3029
  * - Interactive terminals (PTY and exec modes)
@@ -3775,7 +3775,7 @@ declare class Sandbox {
3775
3775
  }): Promise<string>;
3776
3776
  /**
3777
3777
  * Get provider instance
3778
- * Note: Not available when using Sandbox directly - only available through gateway provider
3778
+ * Note: Not available on direct Sandbox client instances
3779
3779
  */
3780
3780
  getProvider(): never;
3781
3781
  /**
@@ -3786,7 +3786,7 @@ declare class Sandbox {
3786
3786
  /**
3787
3787
  * Destroy the sandbox (Sandbox interface method)
3788
3788
  *
3789
- * If a destroyHandler was provided (e.g., from gateway), calls it to destroy
3789
+ * If a destroyHandler was provided, calls it to destroy
3790
3790
  * the sandbox on the backend. Otherwise, only disconnects the WebSocket.
3791
3791
  */
3792
3792
  destroy(): Promise<void>;
@@ -3823,198 +3823,12 @@ declare const buildSetupPayload: (options: BuildSetupPayloadOptions) => SetupPay
3823
3823
  declare const encodeSetupPayload: (options: BuildSetupPayloadOptions) => string;
3824
3824
 
3825
3825
  /**
3826
- * Unified Provider Configuration
3826
+ * Compute API - Direct Provider Implementation
3827
3827
  *
3828
- * Single source of truth for all provider auth requirements.
3829
- * Used by both explicit mode (computesdk) and magic mode (workbench).
3828
+ * Gateway/control-plane transport has been removed from this package.
3829
+ * `compute` now delegates to one or more configured provider instances directly.
3830
3830
  */
3831
- /**
3832
- * Provider auth requirements
3833
- *
3834
- * Structure: { provider: [[option1_vars], [option2_vars], ...] }
3835
- * - Outer array: OR conditions (any option can satisfy auth)
3836
- * - Inner arrays: AND conditions (all vars in option must be present)
3837
- *
3838
- * Example: vercel: [['OIDC_TOKEN'], ['TOKEN', 'TEAM_ID', 'PROJECT_ID']]
3839
- * -> Ready if OIDC_TOKEN is set, OR if all three traditional vars are set
3840
- */
3841
- declare const PROVIDER_AUTH: {
3842
- readonly computesdk: readonly [readonly ["COMPUTESDK_API_KEY"]];
3843
- readonly e2b: readonly [readonly ["E2B_API_KEY"]];
3844
- readonly modal: readonly [readonly ["MODAL_TOKEN_ID", "MODAL_TOKEN_SECRET"]];
3845
- readonly railway: readonly [readonly ["RAILWAY_API_KEY", "RAILWAY_PROJECT_ID", "RAILWAY_ENVIRONMENT_ID"]];
3846
- readonly render: readonly [readonly ["RENDER_API_KEY", "RENDER_OWNER_ID"]];
3847
- readonly daytona: readonly [readonly ["DAYTONA_API_KEY"]];
3848
- readonly vercel: readonly [readonly ["VERCEL_OIDC_TOKEN"], readonly ["VERCEL_TOKEN", "VERCEL_TEAM_ID", "VERCEL_PROJECT_ID"]];
3849
- readonly runloop: readonly [readonly ["RUNLOOP_API_KEY"]];
3850
- readonly cloudflare: readonly [readonly ["CLOUDFLARE_SANDBOX_URL", "CLOUDFLARE_SANDBOX_SECRET"], readonly ["CLOUDFLARE_API_TOKEN", "CLOUDFLARE_ACCOUNT_ID"]];
3851
- readonly codesandbox: readonly [readonly ["CSB_API_KEY"]];
3852
- readonly blaxel: readonly [readonly ["BL_API_KEY", "BL_WORKSPACE"]];
3853
- readonly namespace: readonly [readonly ["NSC_TOKEN"], readonly ["NSC_TOKEN_FILE"]];
3854
- readonly hopx: readonly [readonly ["HOPX_API_KEY"]];
3855
- readonly beam: readonly [readonly ["BEAM_TOKEN", "BEAM_WORKSPACE_ID"]];
3856
- readonly sprites: readonly [readonly ["SPRITES_TOKEN"]];
3857
- readonly agentuity: readonly [readonly ["AGENTUITY_SDK_KEY"]];
3858
- readonly freestyle: readonly [readonly ["FREESTYLE_API_KEY"]];
3859
- readonly upstash: readonly [readonly ["UPSTASH_BOX_API_KEY"]];
3860
- readonly 'just-bash': readonly [readonly []];
3861
- readonly 'secure-exec': readonly [readonly []];
3862
- };
3863
- /**
3864
- * All supported provider names (excluding gateway which is special)
3865
- */
3866
- declare const PROVIDER_NAMES: ProviderName[];
3867
- /**
3868
- * Provider name type derived from PROVIDER_AUTH
3869
- */
3870
- type ProviderName = keyof typeof PROVIDER_AUTH;
3871
- /**
3872
- * Header mapping for each provider
3873
- * Maps config field names to HTTP header names
3874
- */
3875
- declare const PROVIDER_HEADERS: Record<ProviderName, Record<string, string>>;
3876
- /**
3877
- * Environment variable to config field mapping for each provider
3878
- */
3879
- declare const PROVIDER_ENV_MAP: Record<ProviderName, Record<string, string>>;
3880
- /**
3881
- * Dashboard URLs for each provider (for error messages)
3882
- */
3883
- declare const PROVIDER_DASHBOARD_URLS: Record<ProviderName, string>;
3884
- /**
3885
- * Check if a provider name is valid
3886
- */
3887
- declare function isValidProvider(name: string): name is ProviderName;
3888
- /**
3889
- * Build headers from provider config
3890
- */
3891
- declare function buildProviderHeaders(provider: ProviderName, config: Record<string, string | undefined>): Record<string, string>;
3892
- /**
3893
- * Get provider config from environment variables
3894
- */
3895
- declare function getProviderConfigFromEnv(provider: ProviderName): Record<string, string>;
3896
- /**
3897
- * Check if provider has complete auth from environment
3898
- */
3899
- declare function isProviderAuthComplete(provider: ProviderName): boolean;
3900
- /**
3901
- * Get missing env vars for a provider (returns the option closest to completion)
3902
- */
3903
- declare function getMissingEnvVars(provider: ProviderName): string[];
3904
3831
 
3905
- /**
3906
- * Compute API - Gateway HTTP Implementation
3907
- *
3908
- * Provides the unified compute.* API using direct HTTP calls to the gateway.
3909
- * The `compute` export works as both a singleton and a callable function:
3910
- *
3911
- * - Singleton: `compute.sandbox.create()` (auto-detects from env vars)
3912
- * - Callable: `compute({ provider: 'e2b', ... }).sandbox.create()` (explicit config)
3913
- */
3914
-
3915
- /**
3916
- * Explicit compute configuration for callable mode
3917
- */
3918
- interface ExplicitComputeConfig {
3919
- /** Provider name to use */
3920
- provider: ProviderName;
3921
- /**
3922
- * ComputeSDK API key (required for gateway mode)
3923
- * @deprecated Use `computesdkApiKey` for clarity
3924
- */
3925
- apiKey?: string;
3926
- /** ComputeSDK API key (required for gateway mode) */
3927
- computesdkApiKey?: string;
3928
- /** Optional gateway URL override */
3929
- gatewayUrl?: string;
3930
- /** HTTP request timeout for gateway calls in milliseconds */
3931
- requestTimeoutMs?: number;
3932
- /**
3933
- * WebSocket implementation for environments without native WebSocket support.
3934
- * In Node.js < 22, pass the 'ws' package: `import WebSocket from 'ws'`
3935
- */
3936
- WebSocket?: WebSocketConstructor;
3937
- /** Provider-specific configurations */
3938
- e2b?: {
3939
- apiKey?: string;
3940
- projectId?: string;
3941
- templateId?: string;
3942
- };
3943
- modal?: {
3944
- tokenId?: string;
3945
- tokenSecret?: string;
3946
- };
3947
- railway?: {
3948
- apiToken?: string;
3949
- projectId?: string;
3950
- environmentId?: string;
3951
- };
3952
- render?: {
3953
- apiKey?: string;
3954
- serviceId?: string;
3955
- };
3956
- daytona?: {
3957
- apiKey?: string;
3958
- };
3959
- vercel?: {
3960
- oidcToken?: string;
3961
- token?: string;
3962
- teamId?: string;
3963
- projectId?: string;
3964
- };
3965
- runloop?: {
3966
- apiKey?: string;
3967
- };
3968
- cloudflare?: {
3969
- apiToken?: string;
3970
- accountId?: string;
3971
- };
3972
- codesandbox?: {
3973
- apiKey?: string;
3974
- templateId?: string;
3975
- timeout?: number;
3976
- };
3977
- blaxel?: {
3978
- apiKey?: string;
3979
- workspace?: string;
3980
- image?: string;
3981
- region?: string;
3982
- memory?: number;
3983
- };
3984
- namespace?: {
3985
- token?: string;
3986
- };
3987
- hopx?: {
3988
- apiKey?: string;
3989
- };
3990
- beam?: {
3991
- token?: string;
3992
- workspaceId?: string;
3993
- };
3994
- sprites?: {
3995
- apiKey?: string;
3996
- };
3997
- agentuity?: {
3998
- apiKey?: string;
3999
- region?: string;
4000
- baseURL?: string;
4001
- };
4002
- freestyle?: {
4003
- apiKey?: string;
4004
- };
4005
- upstash?: {
4006
- apiKey?: string;
4007
- };
4008
- 'just-bash'?: {};
4009
- 'secure-exec'?: {};
4010
- computesdk?: {};
4011
- }
4012
- /**
4013
- * Options for creating a sandbox via the gateway
4014
- *
4015
- * Note: Runtime is determined by the provider, not specified at creation time.
4016
- * Use sandbox.runCode(code, runtime) to specify which runtime to use for execution.
4017
- */
4018
3832
  interface CreateSandboxOptions {
4019
3833
  timeout?: number;
4020
3834
  templateId?: string;
@@ -4025,263 +3839,123 @@ interface CreateSandboxOptions {
4025
3839
  directory?: string;
4026
3840
  overlays?: SetupOverlayConfig[];
4027
3841
  servers?: ServerStartOptions[];
4028
- /** Docker image to use for the sandbox (for infrastructure providers like Railway) */
4029
3842
  image?: string;
4030
- /** Provider-specific snapshot to create from (e.g., Vercel snapshots) */
4031
3843
  snapshotId?: string;
3844
+ /** Optional provider name override (must match provider.name) */
3845
+ provider?: string;
4032
3846
  }
4033
- /**
4034
- * Options for finding or creating a named sandbox
4035
- */
4036
3847
  interface FindOrCreateSandboxOptions extends CreateSandboxOptions {
4037
3848
  name: string;
4038
3849
  namespace?: string;
4039
3850
  }
4040
- /**
4041
- * Options for finding a named sandbox
4042
- */
4043
3851
  interface FindSandboxOptions {
4044
3852
  name: string;
4045
3853
  namespace?: string;
3854
+ /** Optional provider name override (must match provider.name) */
3855
+ provider?: string;
4046
3856
  }
4047
- /**
4048
- * Options for extending sandbox timeout
4049
- */
4050
3857
  interface ExtendTimeoutOptions {
4051
3858
  duration?: number;
4052
3859
  }
3860
+ interface CreateSnapshotOptions {
3861
+ name?: string;
3862
+ metadata?: Record<string, any>;
3863
+ /** Optional provider name override (must match provider.name) */
3864
+ provider?: string;
3865
+ }
3866
+ interface ProviderSandboxManager {
3867
+ create(options?: CreateSandboxOptions): Promise<Sandbox$1>;
3868
+ getById(sandboxId: string): Promise<Sandbox$1 | null>;
3869
+ list?(): Promise<Sandbox$1[]>;
3870
+ destroy(sandboxId: string): Promise<void>;
3871
+ findOrCreate?(options: FindOrCreateSandboxOptions): Promise<Sandbox$1>;
3872
+ find?(options: FindSandboxOptions): Promise<Sandbox$1 | null>;
3873
+ extendTimeout?(sandboxId: string, options?: ExtendTimeoutOptions): Promise<void>;
3874
+ }
3875
+ interface ProviderSnapshotManager {
3876
+ create(sandboxId: string, options?: {
3877
+ name?: string;
3878
+ metadata?: Record<string, any>;
3879
+ }): Promise<{
3880
+ id: string;
3881
+ provider: string;
3882
+ createdAt: Date | string;
3883
+ metadata?: Record<string, any>;
3884
+ }>;
3885
+ list(): Promise<Array<{
3886
+ id: string;
3887
+ provider: string;
3888
+ createdAt: Date | string;
3889
+ metadata?: Record<string, any>;
3890
+ }>>;
3891
+ delete(snapshotId: string): Promise<void>;
3892
+ }
3893
+ interface DirectProvider {
3894
+ readonly name?: string;
3895
+ readonly sandbox: ProviderSandboxManager;
3896
+ readonly snapshot?: ProviderSnapshotManager;
3897
+ }
4053
3898
  /**
4054
- * Compute singleton implementation
3899
+ * Explicit compute configuration for callable mode.
3900
+ *
3901
+ * Use `provider` for single-provider mode or `providers` for multi-provider mode.
4055
3902
  */
3903
+ interface ExplicitComputeConfig {
3904
+ /** Single-provider mode */
3905
+ provider?: DirectProvider;
3906
+ /** Multi-provider mode (recommended for resilient routing) */
3907
+ providers?: DirectProvider[];
3908
+ /** Provider selection strategy when no explicit provider is passed */
3909
+ providerStrategy?: 'priority' | 'round-robin';
3910
+ /** Retry the next provider when create/find-or-create fails */
3911
+ fallbackOnError?: boolean;
3912
+ }
4056
3913
  declare class ComputeManager {
4057
- private config;
4058
- private autoConfigured;
4059
- /**
4060
- * Lazy auto-configure from environment if not explicitly configured
4061
- */
4062
- private ensureConfigured;
4063
- /**
4064
- * Get gateway config, throwing if not configured
4065
- */
4066
- private getGatewayConfig;
4067
- /**
4068
- * Explicitly configure the compute singleton
4069
- *
4070
- * @example
4071
- * ```typescript
4072
- * import { compute } from 'computesdk';
4073
- *
4074
- * compute.setConfig({
4075
- * provider: 'e2b',
4076
- * apiKey: 'computesdk_xxx',
4077
- * e2b: { apiKey: 'e2b_xxx' }
4078
- * });
4079
- *
4080
- * const sandbox = await compute.sandbox.create();
4081
- * ```
4082
- */
3914
+ private providers;
3915
+ private providerStrategy;
3916
+ private fallbackOnError;
3917
+ private roundRobinCursor;
3918
+ private sandboxProviders;
3919
+ private snapshotProviders;
3920
+ private getProviders;
3921
+ private getProviderByName;
3922
+ private registerSandboxProvider;
3923
+ private getCreateCandidates;
3924
+ private getByIdCandidates;
3925
+ private getSnapshotDeleteCandidates;
3926
+ private getSnapshotCreateCandidates;
3927
+ private createWithFallback;
3928
+ private findOrCreateWithFallback;
4083
3929
  setConfig(config: ExplicitComputeConfig): void;
4084
3930
  sandbox: {
4085
- /**
4086
- * Create a new sandbox
4087
- *
4088
- * @example
4089
- * ```typescript
4090
- * const sandbox = await compute.sandbox.create({
4091
- * directory: '/custom/path',
4092
- * overlays: [
4093
- * {
4094
- * source: '/templates/nextjs',
4095
- * target: 'app',
4096
- * strategy: 'smart',
4097
- * },
4098
- * ],
4099
- * servers: [
4100
- * {
4101
- * slug: 'web',
4102
- * start: 'npm run dev',
4103
- * path: '/app',
4104
- * },
4105
- * ],
4106
- * });
4107
- * ```
4108
- */
4109
- create: (options?: CreateSandboxOptions) => Promise<Sandbox>;
4110
- /**
4111
- * Get an existing sandbox by ID
4112
- */
4113
- getById: (sandboxId: string) => Promise<Sandbox | null>;
4114
- /**
4115
- * List all active sandboxes
4116
- */
4117
- list: () => Promise<Sandbox[]>;
4118
- /**
4119
- * Destroy a sandbox
4120
- */
3931
+ create: (options?: CreateSandboxOptions) => Promise<Sandbox$1>;
3932
+ getById: (sandboxId: string) => Promise<Sandbox$1 | null>;
3933
+ list: () => Promise<Sandbox$1[]>;
4121
3934
  destroy: (sandboxId: string) => Promise<void>;
4122
- /**
4123
- * Find existing or create new sandbox by (namespace, name)
4124
- */
4125
- findOrCreate: (options: FindOrCreateSandboxOptions) => Promise<Sandbox>;
4126
- /**
4127
- * Find existing sandbox by (namespace, name) without creating
4128
- */
4129
- find: (options: FindSandboxOptions) => Promise<Sandbox | null>;
4130
- /**
4131
- * Extend sandbox timeout/expiration
4132
- */
3935
+ findOrCreate: (options: FindOrCreateSandboxOptions) => Promise<Sandbox$1>;
3936
+ find: (options: FindSandboxOptions) => Promise<Sandbox$1 | null>;
4133
3937
  extendTimeout: (sandboxId: string, options?: ExtendTimeoutOptions) => Promise<void>;
4134
3938
  };
4135
3939
  snapshot: {
4136
- /**
4137
- * Create a snapshot from a running sandbox
4138
- *
4139
- * @param sandboxId ID of the sandbox to snapshot
4140
- * @param options Snapshot options (name, metadata)
4141
- */
4142
- create: (sandboxId: string, options?: {
4143
- name?: string;
4144
- metadata?: Record<string, any>;
4145
- }) => Promise<{
3940
+ create: (sandboxId: string, options?: CreateSnapshotOptions) => Promise<{
4146
3941
  id: string;
4147
3942
  provider: string;
4148
3943
  createdAt: Date;
4149
3944
  metadata?: Record<string, any>;
4150
3945
  }>;
4151
- /**
4152
- * List all snapshots
4153
- */
4154
3946
  list: () => Promise<Array<{
4155
3947
  id: string;
4156
3948
  provider: string;
4157
3949
  createdAt: Date;
4158
3950
  metadata?: Record<string, any>;
4159
3951
  }>>;
4160
- /**
4161
- * Delete a snapshot
4162
- */
4163
3952
  delete: (snapshotId: string) => Promise<void>;
4164
3953
  };
4165
3954
  }
4166
- /**
4167
- * Callable compute interface - dual nature as both singleton and factory
4168
- *
4169
- * This interface represents the compute export's two modes:
4170
- * 1. As a ComputeManager singleton (accessed via properties like compute.sandbox)
4171
- * 2. As a factory function (called with config to create new instances)
4172
- */
4173
3955
  interface CallableCompute extends ComputeManager {
4174
- /** Create a new compute instance with explicit configuration */
4175
3956
  (config: ExplicitComputeConfig): ComputeManager;
4176
- /** Explicitly configure the singleton */
4177
3957
  setConfig(config: ExplicitComputeConfig): void;
4178
3958
  }
4179
- /**
4180
- * Callable compute - works as both singleton and factory function
4181
- *
4182
- * @example
4183
- * ```typescript
4184
- * import { compute } from 'computesdk';
4185
- *
4186
- * // Singleton mode (auto-detects from env vars)
4187
- * const sandbox1 = await compute.sandbox.create();
4188
- *
4189
- * // Callable mode (explicit config)
4190
- * const sandbox2 = await compute({
4191
- * provider: 'e2b',
4192
- * apiKey: 'computesdk_xxx',
4193
- * e2b: { apiKey: 'e2b_xxx' }
4194
- * }).sandbox.create();
4195
- * ```
4196
- */
4197
3959
  declare const compute: CallableCompute;
4198
3960
 
4199
- /**
4200
- * Auto-Detection Module
4201
- *
4202
- * Automatically detects gateway mode and provider from environment variables.
4203
- * Enables zero-config usage of ComputeSDK.
4204
- */
4205
-
4206
- /**
4207
- * Check if gateway mode is enabled
4208
- * Gateway mode requires COMPUTESDK_API_KEY to be set
4209
- */
4210
- declare function isGatewayModeEnabled(): boolean;
4211
- /**
4212
- * Detect which provider to use from environment variables
4213
- *
4214
- * Detection order:
4215
- * 1. Check for explicit COMPUTESDK_PROVIDER override
4216
- * 2. Auto-detect based on PROVIDER_PRIORITY order
4217
- *
4218
- * @returns Provider name or null if none detected
4219
- */
4220
- declare function detectProvider(): string | null;
4221
- /**
4222
- * Build provider-specific headers from environment variables
4223
- * These headers are passed through to the gateway
4224
- */
4225
- declare function getProviderHeaders(provider: string): Record<string, string>;
4226
- /**
4227
- * Gateway configuration object
4228
- */
4229
- interface GatewayConfig {
4230
- apiKey: string;
4231
- gatewayUrl: string;
4232
- provider: string;
4233
- providerHeaders: Record<string, string>;
4234
- requestTimeoutMs?: number;
4235
- WebSocket?: WebSocketConstructor;
4236
- }
4237
- /**
4238
- * Main auto-configuration function
4239
- * Returns gateway configuration or null if auto-detection not possible
4240
- *
4241
- * @throws Error if COMPUTESDK_API_KEY is set but no provider detected
4242
- */
4243
- declare function autoConfigureCompute(): GatewayConfig | null;
4244
-
4245
- /**
4246
- * ComputeSDK Constants
4247
- *
4248
- * Default configuration values and provider definitions
4249
- */
4250
-
4251
- /**
4252
- * Default gateway URL for sandbox lifecycle operations
4253
- */
4254
- declare const TRIBUTARY_URL = "https://tributary.edge.computesdk.com";
4255
- /**
4256
- * Provider detection priority order
4257
- * When multiple provider credentials are detected, use the first one in this list
4258
- */
4259
- declare const PROVIDER_PRIORITY: readonly ["e2b", "railway", "render", "daytona", "modal", "runloop", "vercel", "cloudflare", "codesandbox", "blaxel", "namespace", "hopx", "beam", "sprites", "agentuity", "freestyle", "upstash", "secure-exec"];
4260
- /**
4261
- * Required environment variables for each provider
4262
- * @deprecated Use PROVIDER_AUTH from provider-config instead
4263
- */
4264
- declare const PROVIDER_ENV_VARS: {
4265
- readonly computesdk: readonly ["COMPUTESDK_API_KEY"];
4266
- readonly e2b: readonly ["E2B_API_KEY"];
4267
- readonly railway: readonly ["RAILWAY_API_KEY", "RAILWAY_PROJECT_ID", "RAILWAY_ENVIRONMENT_ID"];
4268
- readonly render: readonly ["RENDER_API_KEY", "RENDER_OWNER_ID"];
4269
- readonly daytona: readonly ["DAYTONA_API_KEY"];
4270
- readonly modal: readonly ["MODAL_TOKEN_ID", "MODAL_TOKEN_SECRET"];
4271
- readonly runloop: readonly ["RUNLOOP_API_KEY"];
4272
- readonly vercel: readonly ["VERCEL_TOKEN", "VERCEL_TEAM_ID", "VERCEL_PROJECT_ID"];
4273
- readonly cloudflare: readonly ["CLOUDFLARE_API_TOKEN", "CLOUDFLARE_ACCOUNT_ID"];
4274
- readonly codesandbox: readonly ["CSB_API_KEY"];
4275
- readonly blaxel: readonly ["BL_API_KEY", "BL_WORKSPACE"];
4276
- readonly namespace: readonly ["NSC_TOKEN"];
4277
- readonly hopx: readonly ["HOPX_API_KEY"];
4278
- readonly beam: readonly ["BEAM_TOKEN", "BEAM_WORKSPACE_ID"];
4279
- readonly sprites: readonly ["SPRITES_TOKEN"];
4280
- readonly agentuity: readonly ["AGENTUITY_SDK_KEY"];
4281
- readonly freestyle: readonly ["FREESTYLE_API_KEY"];
4282
- readonly upstash: readonly ["UPSTASH_BOX_API_KEY"];
4283
- readonly 'just-bash': readonly [];
4284
- readonly 'secure-exec': readonly [];
4285
- };
4286
-
4287
- export { type CallableCompute, type CodeResult$1 as CodeResult, CommandExitError, type CommandResult$1 as CommandResult, type CreateSandboxOptions$1 as CreateSandboxOptions, type ExplicitComputeConfig, type FileEntry, FileWatcher, Sandbox as GatewaySandbox, MessageType, PROVIDER_AUTH, PROVIDER_DASHBOARD_URLS, PROVIDER_ENV_MAP, PROVIDER_ENV_VARS, PROVIDER_HEADERS, PROVIDER_NAMES, PROVIDER_PRIORITY, type ProviderName, type ProviderSandboxInfo, type RunCommandOptions, type Runtime, Sandbox, type SandboxFileSystem, type SandboxInfo$1 as SandboxInfo, type Sandbox$1 as SandboxInterface, type SandboxStatus, type SetupOverlayConfig, type SetupPayload, SignalService, type Snapshot, TRIBUTARY_URL, TerminalInstance, type WebSocketConstructor, autoConfigureCompute, buildProviderHeaders, buildSetupPayload, compute, decodeBinaryMessage, detectProvider, encodeBinaryMessage, encodeSetupPayload, getMissingEnvVars, getProviderConfigFromEnv, getProviderHeaders, isCommandExitError, isGatewayModeEnabled, isProviderAuthComplete, isValidProvider };
3961
+ export { type CallableCompute, type CodeResult$1 as CodeResult, CommandExitError, type CommandResult$1 as CommandResult, type CreateSandboxOptions$1 as CreateSandboxOptions, type ExplicitComputeConfig, type FileEntry, FileWatcher, MessageType, type ProviderSandboxInfo, type RunCommandOptions, type Runtime, Sandbox, type SandboxFileSystem, type SandboxInfo$1 as SandboxInfo, type Sandbox$1 as SandboxInterface, type SandboxStatus, type SetupOverlayConfig, type SetupPayload, SignalService, type Snapshot, TerminalInstance, type WebSocketConstructor, buildSetupPayload, compute, decodeBinaryMessage, encodeBinaryMessage, encodeSetupPayload, isCommandExitError };