computesdk 1.9.5 → 1.9.6

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.mts CHANGED
@@ -94,6 +94,75 @@ interface TypedProviderSandbox<TProvider extends Provider<any, any, any>> extend
94
94
  getInstance(): ExtractProviderSandboxType<TProvider>;
95
95
  }
96
96
 
97
+ /**
98
+ * Unified Provider Configuration
99
+ *
100
+ * Single source of truth for all provider auth requirements.
101
+ * Used by both explicit mode (computesdk) and magic mode (workbench).
102
+ */
103
+ /**
104
+ * Provider auth requirements
105
+ *
106
+ * Structure: { provider: [[option1_vars], [option2_vars], ...] }
107
+ * - Outer array: OR conditions (any option can satisfy auth)
108
+ * - Inner arrays: AND conditions (all vars in option must be present)
109
+ *
110
+ * Example: vercel: [['OIDC_TOKEN'], ['TOKEN', 'TEAM_ID', 'PROJECT_ID']]
111
+ * -> Ready if OIDC_TOKEN is set, OR if all three traditional vars are set
112
+ */
113
+ declare const PROVIDER_AUTH: {
114
+ readonly e2b: readonly [readonly ["E2B_API_KEY"]];
115
+ readonly modal: readonly [readonly ["MODAL_TOKEN_ID", "MODAL_TOKEN_SECRET"]];
116
+ readonly railway: readonly [readonly ["RAILWAY_API_KEY", "RAILWAY_PROJECT_ID", "RAILWAY_ENVIRONMENT_ID"]];
117
+ readonly daytona: readonly [readonly ["DAYTONA_API_KEY"]];
118
+ readonly vercel: readonly [readonly ["VERCEL_OIDC_TOKEN"], readonly ["VERCEL_TOKEN", "VERCEL_TEAM_ID", "VERCEL_PROJECT_ID"]];
119
+ readonly runloop: readonly [readonly ["RUNLOOP_API_KEY"]];
120
+ readonly cloudflare: readonly [readonly ["CLOUDFLARE_API_TOKEN", "CLOUDFLARE_ACCOUNT_ID"]];
121
+ readonly codesandbox: readonly [readonly ["CSB_API_KEY"]];
122
+ readonly blaxel: readonly [readonly ["BL_API_KEY", "BL_WORKSPACE"]];
123
+ };
124
+ /**
125
+ * All supported provider names (excluding gateway which is special)
126
+ */
127
+ declare const PROVIDER_NAMES: ProviderName[];
128
+ /**
129
+ * Provider name type derived from PROVIDER_AUTH
130
+ */
131
+ type ProviderName = keyof typeof PROVIDER_AUTH;
132
+ /**
133
+ * Header mapping for each provider
134
+ * Maps config field names to HTTP header names
135
+ */
136
+ declare const PROVIDER_HEADERS: Record<ProviderName, Record<string, string>>;
137
+ /**
138
+ * Environment variable to config field mapping for each provider
139
+ */
140
+ declare const PROVIDER_ENV_MAP: Record<ProviderName, Record<string, string>>;
141
+ /**
142
+ * Dashboard URLs for each provider (for error messages)
143
+ */
144
+ declare const PROVIDER_DASHBOARD_URLS: Record<ProviderName, string>;
145
+ /**
146
+ * Check if a provider name is valid
147
+ */
148
+ declare function isValidProvider(name: string): name is ProviderName;
149
+ /**
150
+ * Build headers from provider config
151
+ */
152
+ declare function buildProviderHeaders(provider: ProviderName, config: Record<string, string | undefined>): Record<string, string>;
153
+ /**
154
+ * Get provider config from environment variables
155
+ */
156
+ declare function getProviderConfigFromEnv(provider: ProviderName): Record<string, string>;
157
+ /**
158
+ * Check if provider has complete auth from environment
159
+ */
160
+ declare function isProviderAuthComplete(provider: ProviderName): boolean;
161
+ /**
162
+ * Get missing env vars for a provider (returns the option closest to completion)
163
+ */
164
+ declare function getMissingEnvVars(provider: ProviderName): string[];
165
+
97
166
  /**
98
167
  * Common options for creating snapshots
99
168
  */
@@ -285,11 +354,64 @@ interface ModalProviderConfig {
285
354
  interface RailwayProviderConfig {
286
355
  /** Railway API token */
287
356
  apiToken?: string;
357
+ /** Railway project ID */
358
+ projectId?: string;
359
+ /** Railway environment ID */
360
+ environmentId?: string;
361
+ }
362
+ /**
363
+ * Daytona provider configuration for explicit compute mode
364
+ */
365
+ interface DaytonaProviderConfig {
366
+ /** Daytona API key */
367
+ apiKey?: string;
368
+ }
369
+ /**
370
+ * Vercel provider configuration for explicit compute mode
371
+ */
372
+ interface VercelProviderConfig {
373
+ /** Vercel OIDC token (preferred, simpler auth) */
374
+ oidcToken?: string;
375
+ /** Vercel API token (traditional auth) */
376
+ token?: string;
377
+ /** Vercel team ID (required with token) */
378
+ teamId?: string;
379
+ /** Vercel project ID (required with token) */
380
+ projectId?: string;
381
+ }
382
+ /**
383
+ * Runloop provider configuration for explicit compute mode
384
+ */
385
+ interface RunloopProviderConfig {
386
+ /** Runloop API key */
387
+ apiKey?: string;
388
+ }
389
+ /**
390
+ * Cloudflare provider configuration for explicit compute mode
391
+ */
392
+ interface CloudflareProviderConfig {
393
+ /** Cloudflare API token */
394
+ apiToken?: string;
395
+ /** Cloudflare account ID */
396
+ accountId?: string;
397
+ }
398
+ /**
399
+ * CodeSandbox provider configuration for explicit compute mode
400
+ */
401
+ interface CodesandboxProviderConfig {
402
+ /** CodeSandbox API key */
403
+ apiKey?: string;
288
404
  }
289
405
  /**
290
- * Supported provider names for explicit compute mode
406
+ * Blaxel provider configuration for explicit compute mode
291
407
  */
292
- type ExplicitProviderName = 'e2b' | 'modal' | 'railway';
408
+ interface BlaxelProviderConfig {
409
+ /** Blaxel API key */
410
+ apiKey?: string;
411
+ /** Blaxel workspace */
412
+ workspace?: string;
413
+ }
414
+
293
415
  /**
294
416
  * Explicit compute configuration for callable compute()
295
417
  *
@@ -298,7 +420,7 @@ type ExplicitProviderName = 'e2b' | 'modal' | 'railway';
298
420
  */
299
421
  interface ExplicitComputeConfig {
300
422
  /** Provider name to use */
301
- provider: ExplicitProviderName;
423
+ provider: ProviderName;
302
424
  /** ComputeSDK API key (required for gateway mode) */
303
425
  apiKey: string;
304
426
  /** E2B provider configuration */
@@ -307,6 +429,18 @@ interface ExplicitComputeConfig {
307
429
  modal?: ModalProviderConfig;
308
430
  /** Railway provider configuration */
309
431
  railway?: RailwayProviderConfig;
432
+ /** Daytona provider configuration */
433
+ daytona?: DaytonaProviderConfig;
434
+ /** Vercel provider configuration */
435
+ vercel?: VercelProviderConfig;
436
+ /** Runloop provider configuration */
437
+ runloop?: RunloopProviderConfig;
438
+ /** Cloudflare provider configuration */
439
+ cloudflare?: CloudflareProviderConfig;
440
+ /** CodeSandbox provider configuration */
441
+ codesandbox?: CodesandboxProviderConfig;
442
+ /** Blaxel provider configuration */
443
+ blaxel?: BlaxelProviderConfig;
310
444
  }
311
445
  /**
312
446
  * Callable compute type - works as both singleton and factory function
@@ -558,6 +692,7 @@ declare function autoConfigureCompute(): Provider | null;
558
692
  *
559
693
  * Default configuration values and provider definitions
560
694
  */
695
+
561
696
  /**
562
697
  * Default gateway URL for sandbox lifecycle operations
563
698
  */
@@ -569,7 +704,7 @@ declare const GATEWAY_URL = "https://gateway.computesdk.com";
569
704
  declare const PROVIDER_PRIORITY: readonly ["e2b", "railway", "daytona", "modal", "runloop", "vercel", "cloudflare", "codesandbox", "blaxel"];
570
705
  /**
571
706
  * Required environment variables for each provider
572
- * Used to detect which provider to use from environment
707
+ * @deprecated Use PROVIDER_AUTH from provider-config instead
573
708
  */
574
709
  declare const PROVIDER_ENV_VARS: {
575
710
  readonly e2b: readonly ["E2B_API_KEY"];
@@ -582,10 +717,6 @@ declare const PROVIDER_ENV_VARS: {
582
717
  readonly codesandbox: readonly ["CSB_API_KEY"];
583
718
  readonly blaxel: readonly ["BL_API_KEY", "BL_WORKSPACE"];
584
719
  };
585
- /**
586
- * Type for provider names
587
- */
588
- type ProviderName = keyof typeof PROVIDER_ENV_VARS;
589
720
 
590
721
  /**
591
722
  * Utility functions for ComputeSDK
@@ -670,4 +801,4 @@ interface HandleComputeRequestParams {
670
801
  provider: Provider;
671
802
  }
672
803
 
673
- export { type BaseProviderConfig, type CallableCompute, type ComputeAPI, type ComputeConfig, type ComputeRequest, type ComputeResponse, type CreateSandboxParams, type CreateSandboxParamsWithOptionalProvider, type CreateSnapshotOptions, type CreateTemplateOptions, type E2BProviderConfig, type ExplicitComputeConfig, type ExplicitProviderName, type ExtractProviderSandboxType, GATEWAY_URL, type GatewayConfig, type HandleComputeRequestParams, type ListSnapshotsOptions, type ListTemplatesOptions, type ModalProviderConfig, PROVIDER_ENV_VARS, PROVIDER_PRIORITY, type Provider, type ProviderConfig, type ProviderMode, type ProviderName, type ProviderSandbox, type ProviderSandboxManager, type ProviderSnapshotManager, type ProviderTemplateManager, type RailwayProviderConfig, type SandboxInfo, type SandboxMethods, type SnapshotMethods, type TemplateMethods, type TypedComputeAPI, type TypedProviderSandbox, autoConfigureCompute, calculateBackoff, compute, createCompute, createProvider, createProviderFromConfig, detectProvider, gateway, getProviderHeaders, handleComputeRequest, isGatewayModeEnabled };
804
+ export { type BaseProviderConfig, type BlaxelProviderConfig, type CallableCompute, type CloudflareProviderConfig, type CodesandboxProviderConfig, type ComputeAPI, type ComputeConfig, type ComputeRequest, type ComputeResponse, type CreateSandboxParams, type CreateSandboxParamsWithOptionalProvider, type CreateSnapshotOptions, type CreateTemplateOptions, type DaytonaProviderConfig, type E2BProviderConfig, type ExplicitComputeConfig, type ProviderName as ExplicitProviderName, type ExtractProviderSandboxType, GATEWAY_URL, type GatewayConfig, type HandleComputeRequestParams, type ListSnapshotsOptions, type ListTemplatesOptions, type ModalProviderConfig, PROVIDER_AUTH, PROVIDER_DASHBOARD_URLS, PROVIDER_ENV_MAP, PROVIDER_ENV_VARS, PROVIDER_HEADERS, PROVIDER_NAMES, PROVIDER_PRIORITY, type Provider, type ProviderConfig, type ProviderMode, type ProviderName, type ProviderSandbox, type ProviderSandboxManager, type ProviderSnapshotManager, type ProviderTemplateManager, type RailwayProviderConfig, type RunloopProviderConfig, type SandboxInfo, type SandboxMethods, type SnapshotMethods, type TemplateMethods, type TypedComputeAPI, type TypedProviderSandbox, type VercelProviderConfig, autoConfigureCompute, buildProviderHeaders, calculateBackoff, compute, createCompute, createProvider, createProviderFromConfig, detectProvider, gateway, getMissingEnvVars, getProviderConfigFromEnv, getProviderHeaders, handleComputeRequest, isGatewayModeEnabled, isProviderAuthComplete, isValidProvider };
package/dist/index.d.ts CHANGED
@@ -94,6 +94,75 @@ interface TypedProviderSandbox<TProvider extends Provider<any, any, any>> extend
94
94
  getInstance(): ExtractProviderSandboxType<TProvider>;
95
95
  }
96
96
 
97
+ /**
98
+ * Unified Provider Configuration
99
+ *
100
+ * Single source of truth for all provider auth requirements.
101
+ * Used by both explicit mode (computesdk) and magic mode (workbench).
102
+ */
103
+ /**
104
+ * Provider auth requirements
105
+ *
106
+ * Structure: { provider: [[option1_vars], [option2_vars], ...] }
107
+ * - Outer array: OR conditions (any option can satisfy auth)
108
+ * - Inner arrays: AND conditions (all vars in option must be present)
109
+ *
110
+ * Example: vercel: [['OIDC_TOKEN'], ['TOKEN', 'TEAM_ID', 'PROJECT_ID']]
111
+ * -> Ready if OIDC_TOKEN is set, OR if all three traditional vars are set
112
+ */
113
+ declare const PROVIDER_AUTH: {
114
+ readonly e2b: readonly [readonly ["E2B_API_KEY"]];
115
+ readonly modal: readonly [readonly ["MODAL_TOKEN_ID", "MODAL_TOKEN_SECRET"]];
116
+ readonly railway: readonly [readonly ["RAILWAY_API_KEY", "RAILWAY_PROJECT_ID", "RAILWAY_ENVIRONMENT_ID"]];
117
+ readonly daytona: readonly [readonly ["DAYTONA_API_KEY"]];
118
+ readonly vercel: readonly [readonly ["VERCEL_OIDC_TOKEN"], readonly ["VERCEL_TOKEN", "VERCEL_TEAM_ID", "VERCEL_PROJECT_ID"]];
119
+ readonly runloop: readonly [readonly ["RUNLOOP_API_KEY"]];
120
+ readonly cloudflare: readonly [readonly ["CLOUDFLARE_API_TOKEN", "CLOUDFLARE_ACCOUNT_ID"]];
121
+ readonly codesandbox: readonly [readonly ["CSB_API_KEY"]];
122
+ readonly blaxel: readonly [readonly ["BL_API_KEY", "BL_WORKSPACE"]];
123
+ };
124
+ /**
125
+ * All supported provider names (excluding gateway which is special)
126
+ */
127
+ declare const PROVIDER_NAMES: ProviderName[];
128
+ /**
129
+ * Provider name type derived from PROVIDER_AUTH
130
+ */
131
+ type ProviderName = keyof typeof PROVIDER_AUTH;
132
+ /**
133
+ * Header mapping for each provider
134
+ * Maps config field names to HTTP header names
135
+ */
136
+ declare const PROVIDER_HEADERS: Record<ProviderName, Record<string, string>>;
137
+ /**
138
+ * Environment variable to config field mapping for each provider
139
+ */
140
+ declare const PROVIDER_ENV_MAP: Record<ProviderName, Record<string, string>>;
141
+ /**
142
+ * Dashboard URLs for each provider (for error messages)
143
+ */
144
+ declare const PROVIDER_DASHBOARD_URLS: Record<ProviderName, string>;
145
+ /**
146
+ * Check if a provider name is valid
147
+ */
148
+ declare function isValidProvider(name: string): name is ProviderName;
149
+ /**
150
+ * Build headers from provider config
151
+ */
152
+ declare function buildProviderHeaders(provider: ProviderName, config: Record<string, string | undefined>): Record<string, string>;
153
+ /**
154
+ * Get provider config from environment variables
155
+ */
156
+ declare function getProviderConfigFromEnv(provider: ProviderName): Record<string, string>;
157
+ /**
158
+ * Check if provider has complete auth from environment
159
+ */
160
+ declare function isProviderAuthComplete(provider: ProviderName): boolean;
161
+ /**
162
+ * Get missing env vars for a provider (returns the option closest to completion)
163
+ */
164
+ declare function getMissingEnvVars(provider: ProviderName): string[];
165
+
97
166
  /**
98
167
  * Common options for creating snapshots
99
168
  */
@@ -285,11 +354,64 @@ interface ModalProviderConfig {
285
354
  interface RailwayProviderConfig {
286
355
  /** Railway API token */
287
356
  apiToken?: string;
357
+ /** Railway project ID */
358
+ projectId?: string;
359
+ /** Railway environment ID */
360
+ environmentId?: string;
361
+ }
362
+ /**
363
+ * Daytona provider configuration for explicit compute mode
364
+ */
365
+ interface DaytonaProviderConfig {
366
+ /** Daytona API key */
367
+ apiKey?: string;
368
+ }
369
+ /**
370
+ * Vercel provider configuration for explicit compute mode
371
+ */
372
+ interface VercelProviderConfig {
373
+ /** Vercel OIDC token (preferred, simpler auth) */
374
+ oidcToken?: string;
375
+ /** Vercel API token (traditional auth) */
376
+ token?: string;
377
+ /** Vercel team ID (required with token) */
378
+ teamId?: string;
379
+ /** Vercel project ID (required with token) */
380
+ projectId?: string;
381
+ }
382
+ /**
383
+ * Runloop provider configuration for explicit compute mode
384
+ */
385
+ interface RunloopProviderConfig {
386
+ /** Runloop API key */
387
+ apiKey?: string;
388
+ }
389
+ /**
390
+ * Cloudflare provider configuration for explicit compute mode
391
+ */
392
+ interface CloudflareProviderConfig {
393
+ /** Cloudflare API token */
394
+ apiToken?: string;
395
+ /** Cloudflare account ID */
396
+ accountId?: string;
397
+ }
398
+ /**
399
+ * CodeSandbox provider configuration for explicit compute mode
400
+ */
401
+ interface CodesandboxProviderConfig {
402
+ /** CodeSandbox API key */
403
+ apiKey?: string;
288
404
  }
289
405
  /**
290
- * Supported provider names for explicit compute mode
406
+ * Blaxel provider configuration for explicit compute mode
291
407
  */
292
- type ExplicitProviderName = 'e2b' | 'modal' | 'railway';
408
+ interface BlaxelProviderConfig {
409
+ /** Blaxel API key */
410
+ apiKey?: string;
411
+ /** Blaxel workspace */
412
+ workspace?: string;
413
+ }
414
+
293
415
  /**
294
416
  * Explicit compute configuration for callable compute()
295
417
  *
@@ -298,7 +420,7 @@ type ExplicitProviderName = 'e2b' | 'modal' | 'railway';
298
420
  */
299
421
  interface ExplicitComputeConfig {
300
422
  /** Provider name to use */
301
- provider: ExplicitProviderName;
423
+ provider: ProviderName;
302
424
  /** ComputeSDK API key (required for gateway mode) */
303
425
  apiKey: string;
304
426
  /** E2B provider configuration */
@@ -307,6 +429,18 @@ interface ExplicitComputeConfig {
307
429
  modal?: ModalProviderConfig;
308
430
  /** Railway provider configuration */
309
431
  railway?: RailwayProviderConfig;
432
+ /** Daytona provider configuration */
433
+ daytona?: DaytonaProviderConfig;
434
+ /** Vercel provider configuration */
435
+ vercel?: VercelProviderConfig;
436
+ /** Runloop provider configuration */
437
+ runloop?: RunloopProviderConfig;
438
+ /** Cloudflare provider configuration */
439
+ cloudflare?: CloudflareProviderConfig;
440
+ /** CodeSandbox provider configuration */
441
+ codesandbox?: CodesandboxProviderConfig;
442
+ /** Blaxel provider configuration */
443
+ blaxel?: BlaxelProviderConfig;
310
444
  }
311
445
  /**
312
446
  * Callable compute type - works as both singleton and factory function
@@ -558,6 +692,7 @@ declare function autoConfigureCompute(): Provider | null;
558
692
  *
559
693
  * Default configuration values and provider definitions
560
694
  */
695
+
561
696
  /**
562
697
  * Default gateway URL for sandbox lifecycle operations
563
698
  */
@@ -569,7 +704,7 @@ declare const GATEWAY_URL = "https://gateway.computesdk.com";
569
704
  declare const PROVIDER_PRIORITY: readonly ["e2b", "railway", "daytona", "modal", "runloop", "vercel", "cloudflare", "codesandbox", "blaxel"];
570
705
  /**
571
706
  * Required environment variables for each provider
572
- * Used to detect which provider to use from environment
707
+ * @deprecated Use PROVIDER_AUTH from provider-config instead
573
708
  */
574
709
  declare const PROVIDER_ENV_VARS: {
575
710
  readonly e2b: readonly ["E2B_API_KEY"];
@@ -582,10 +717,6 @@ declare const PROVIDER_ENV_VARS: {
582
717
  readonly codesandbox: readonly ["CSB_API_KEY"];
583
718
  readonly blaxel: readonly ["BL_API_KEY", "BL_WORKSPACE"];
584
719
  };
585
- /**
586
- * Type for provider names
587
- */
588
- type ProviderName = keyof typeof PROVIDER_ENV_VARS;
589
720
 
590
721
  /**
591
722
  * Utility functions for ComputeSDK
@@ -670,4 +801,4 @@ interface HandleComputeRequestParams {
670
801
  provider: Provider;
671
802
  }
672
803
 
673
- export { type BaseProviderConfig, type CallableCompute, type ComputeAPI, type ComputeConfig, type ComputeRequest, type ComputeResponse, type CreateSandboxParams, type CreateSandboxParamsWithOptionalProvider, type CreateSnapshotOptions, type CreateTemplateOptions, type E2BProviderConfig, type ExplicitComputeConfig, type ExplicitProviderName, type ExtractProviderSandboxType, GATEWAY_URL, type GatewayConfig, type HandleComputeRequestParams, type ListSnapshotsOptions, type ListTemplatesOptions, type ModalProviderConfig, PROVIDER_ENV_VARS, PROVIDER_PRIORITY, type Provider, type ProviderConfig, type ProviderMode, type ProviderName, type ProviderSandbox, type ProviderSandboxManager, type ProviderSnapshotManager, type ProviderTemplateManager, type RailwayProviderConfig, type SandboxInfo, type SandboxMethods, type SnapshotMethods, type TemplateMethods, type TypedComputeAPI, type TypedProviderSandbox, autoConfigureCompute, calculateBackoff, compute, createCompute, createProvider, createProviderFromConfig, detectProvider, gateway, getProviderHeaders, handleComputeRequest, isGatewayModeEnabled };
804
+ export { type BaseProviderConfig, type BlaxelProviderConfig, type CallableCompute, type CloudflareProviderConfig, type CodesandboxProviderConfig, type ComputeAPI, type ComputeConfig, type ComputeRequest, type ComputeResponse, type CreateSandboxParams, type CreateSandboxParamsWithOptionalProvider, type CreateSnapshotOptions, type CreateTemplateOptions, type DaytonaProviderConfig, type E2BProviderConfig, type ExplicitComputeConfig, type ProviderName as ExplicitProviderName, type ExtractProviderSandboxType, GATEWAY_URL, type GatewayConfig, type HandleComputeRequestParams, type ListSnapshotsOptions, type ListTemplatesOptions, type ModalProviderConfig, PROVIDER_AUTH, PROVIDER_DASHBOARD_URLS, PROVIDER_ENV_MAP, PROVIDER_ENV_VARS, PROVIDER_HEADERS, PROVIDER_NAMES, PROVIDER_PRIORITY, type Provider, type ProviderConfig, type ProviderMode, type ProviderName, type ProviderSandbox, type ProviderSandboxManager, type ProviderSnapshotManager, type ProviderTemplateManager, type RailwayProviderConfig, type RunloopProviderConfig, type SandboxInfo, type SandboxMethods, type SnapshotMethods, type TemplateMethods, type TypedComputeAPI, type TypedProviderSandbox, type VercelProviderConfig, autoConfigureCompute, buildProviderHeaders, calculateBackoff, compute, createCompute, createProvider, createProviderFromConfig, detectProvider, gateway, getMissingEnvVars, getProviderConfigFromEnv, getProviderHeaders, handleComputeRequest, isGatewayModeEnabled, isProviderAuthComplete, isValidProvider };