computesdk 1.9.4 → 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 +227 -9
- package/dist/index.d.ts +227 -9
- package/dist/index.js +277 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +265 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
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
|
*/
|
|
@@ -259,17 +328,154 @@ interface TypedComputeAPI<TProvider extends Provider> extends Omit<ComputeAPI, '
|
|
|
259
328
|
destroy(sandboxId: string): Promise<void>;
|
|
260
329
|
};
|
|
261
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* E2B provider configuration for explicit compute mode
|
|
333
|
+
*/
|
|
334
|
+
interface E2BProviderConfig {
|
|
335
|
+
/** E2B API key */
|
|
336
|
+
apiKey?: string;
|
|
337
|
+
/** E2B project ID */
|
|
338
|
+
projectId?: string;
|
|
339
|
+
/** E2B environment/template ID */
|
|
340
|
+
templateId?: string;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Modal provider configuration for explicit compute mode
|
|
344
|
+
*/
|
|
345
|
+
interface ModalProviderConfig {
|
|
346
|
+
/** Modal token ID */
|
|
347
|
+
tokenId?: string;
|
|
348
|
+
/** Modal token secret */
|
|
349
|
+
tokenSecret?: string;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Railway provider configuration for explicit compute mode
|
|
353
|
+
*/
|
|
354
|
+
interface RailwayProviderConfig {
|
|
355
|
+
/** Railway API token */
|
|
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;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Blaxel provider configuration for explicit compute mode
|
|
407
|
+
*/
|
|
408
|
+
interface BlaxelProviderConfig {
|
|
409
|
+
/** Blaxel API key */
|
|
410
|
+
apiKey?: string;
|
|
411
|
+
/** Blaxel workspace */
|
|
412
|
+
workspace?: string;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Explicit compute configuration for callable compute()
|
|
417
|
+
*
|
|
418
|
+
* Used when calling compute as a function: compute({ provider: 'e2b', ... })
|
|
419
|
+
* Always uses gateway mode.
|
|
420
|
+
*/
|
|
421
|
+
interface ExplicitComputeConfig {
|
|
422
|
+
/** Provider name to use */
|
|
423
|
+
provider: ProviderName;
|
|
424
|
+
/** ComputeSDK API key (required for gateway mode) */
|
|
425
|
+
apiKey: string;
|
|
426
|
+
/** E2B provider configuration */
|
|
427
|
+
e2b?: E2BProviderConfig;
|
|
428
|
+
/** Modal provider configuration */
|
|
429
|
+
modal?: ModalProviderConfig;
|
|
430
|
+
/** Railway provider configuration */
|
|
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;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Callable compute type - works as both singleton and factory function
|
|
447
|
+
*/
|
|
448
|
+
type CallableCompute = ComputeAPI & ((config: ExplicitComputeConfig) => ComputeAPI);
|
|
262
449
|
|
|
263
450
|
/**
|
|
264
451
|
* Compute Singleton - Main API Orchestrator
|
|
265
452
|
*
|
|
266
|
-
* Provides the unified compute.* API and delegates to specialized managers
|
|
453
|
+
* Provides the unified compute.* API and delegates to specialized managers.
|
|
454
|
+
* The `compute` export works as both a singleton and a callable function:
|
|
455
|
+
*
|
|
456
|
+
* - Singleton: `compute.sandbox.create()` (auto-detects from env vars)
|
|
457
|
+
* - Callable: `compute({ provider: 'e2b', ... }).sandbox.create()` (explicit config, uses gateway)
|
|
267
458
|
*/
|
|
268
459
|
|
|
269
460
|
/**
|
|
270
|
-
*
|
|
461
|
+
* Callable compute - works as both singleton and factory function
|
|
462
|
+
*
|
|
463
|
+
* @example
|
|
464
|
+
* ```typescript
|
|
465
|
+
* import { compute } from 'computesdk';
|
|
466
|
+
*
|
|
467
|
+
* // Singleton mode (auto-detects from env vars)
|
|
468
|
+
* const sandbox1 = await compute.sandbox.create();
|
|
469
|
+
*
|
|
470
|
+
* // Callable mode (explicit config, uses gateway)
|
|
471
|
+
* const sandbox2 = await compute({
|
|
472
|
+
* provider: 'e2b',
|
|
473
|
+
* apiKey: 'computesdk_xxx',
|
|
474
|
+
* e2b: { apiKey: 'e2b_xxx' }
|
|
475
|
+
* }).sandbox.create();
|
|
476
|
+
* ```
|
|
271
477
|
*/
|
|
272
|
-
declare const compute:
|
|
478
|
+
declare const compute: CallableCompute;
|
|
273
479
|
/**
|
|
274
480
|
* Create a compute instance with proper typing
|
|
275
481
|
*
|
|
@@ -294,6 +500,21 @@ declare const compute: ComputeAPI;
|
|
|
294
500
|
declare function createCompute(): ComputeAPI;
|
|
295
501
|
declare function createCompute<TProvider extends Provider>(config: ComputeConfig<TProvider>): TypedComputeAPI<TProvider>;
|
|
296
502
|
|
|
503
|
+
/**
|
|
504
|
+
* Explicit Config
|
|
505
|
+
*
|
|
506
|
+
* Converts explicit compute configuration to a gateway provider.
|
|
507
|
+
* Used when compute() is called as a function with configuration.
|
|
508
|
+
*/
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Create a gateway provider from explicit configuration
|
|
512
|
+
*
|
|
513
|
+
* @param config - Explicit compute configuration
|
|
514
|
+
* @returns A configured gateway provider
|
|
515
|
+
*/
|
|
516
|
+
declare function createProviderFromConfig(config: ExplicitComputeConfig): Provider;
|
|
517
|
+
|
|
297
518
|
/**
|
|
298
519
|
* Provider Factory - Creates providers from method definitions
|
|
299
520
|
*
|
|
@@ -471,6 +692,7 @@ declare function autoConfigureCompute(): Provider | null;
|
|
|
471
692
|
*
|
|
472
693
|
* Default configuration values and provider definitions
|
|
473
694
|
*/
|
|
695
|
+
|
|
474
696
|
/**
|
|
475
697
|
* Default gateway URL for sandbox lifecycle operations
|
|
476
698
|
*/
|
|
@@ -482,7 +704,7 @@ declare const GATEWAY_URL = "https://gateway.computesdk.com";
|
|
|
482
704
|
declare const PROVIDER_PRIORITY: readonly ["e2b", "railway", "daytona", "modal", "runloop", "vercel", "cloudflare", "codesandbox", "blaxel"];
|
|
483
705
|
/**
|
|
484
706
|
* Required environment variables for each provider
|
|
485
|
-
*
|
|
707
|
+
* @deprecated Use PROVIDER_AUTH from provider-config instead
|
|
486
708
|
*/
|
|
487
709
|
declare const PROVIDER_ENV_VARS: {
|
|
488
710
|
readonly e2b: readonly ["E2B_API_KEY"];
|
|
@@ -495,10 +717,6 @@ declare const PROVIDER_ENV_VARS: {
|
|
|
495
717
|
readonly codesandbox: readonly ["CSB_API_KEY"];
|
|
496
718
|
readonly blaxel: readonly ["BL_API_KEY", "BL_WORKSPACE"];
|
|
497
719
|
};
|
|
498
|
-
/**
|
|
499
|
-
* Type for provider names
|
|
500
|
-
*/
|
|
501
|
-
type ProviderName = keyof typeof PROVIDER_ENV_VARS;
|
|
502
720
|
|
|
503
721
|
/**
|
|
504
722
|
* Utility functions for ComputeSDK
|
|
@@ -583,4 +801,4 @@ interface HandleComputeRequestParams {
|
|
|
583
801
|
provider: Provider;
|
|
584
802
|
}
|
|
585
803
|
|
|
586
|
-
export { type BaseProviderConfig, type ComputeAPI, type ComputeConfig, type ComputeRequest, type ComputeResponse, type CreateSandboxParams, type CreateSandboxParamsWithOptionalProvider, type CreateSnapshotOptions, type CreateTemplateOptions, type ExtractProviderSandboxType, GATEWAY_URL, type GatewayConfig, type HandleComputeRequestParams, type ListSnapshotsOptions, type ListTemplatesOptions, PROVIDER_ENV_VARS, PROVIDER_PRIORITY, type Provider, type ProviderConfig, type ProviderMode, type ProviderName, type ProviderSandbox, type ProviderSandboxManager, type ProviderSnapshotManager, type ProviderTemplateManager, type SandboxInfo, type SandboxMethods, type SnapshotMethods, type TemplateMethods, type TypedComputeAPI, type TypedProviderSandbox, autoConfigureCompute, calculateBackoff, compute, createCompute, createProvider, 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
|
*/
|
|
@@ -259,17 +328,154 @@ interface TypedComputeAPI<TProvider extends Provider> extends Omit<ComputeAPI, '
|
|
|
259
328
|
destroy(sandboxId: string): Promise<void>;
|
|
260
329
|
};
|
|
261
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* E2B provider configuration for explicit compute mode
|
|
333
|
+
*/
|
|
334
|
+
interface E2BProviderConfig {
|
|
335
|
+
/** E2B API key */
|
|
336
|
+
apiKey?: string;
|
|
337
|
+
/** E2B project ID */
|
|
338
|
+
projectId?: string;
|
|
339
|
+
/** E2B environment/template ID */
|
|
340
|
+
templateId?: string;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Modal provider configuration for explicit compute mode
|
|
344
|
+
*/
|
|
345
|
+
interface ModalProviderConfig {
|
|
346
|
+
/** Modal token ID */
|
|
347
|
+
tokenId?: string;
|
|
348
|
+
/** Modal token secret */
|
|
349
|
+
tokenSecret?: string;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Railway provider configuration for explicit compute mode
|
|
353
|
+
*/
|
|
354
|
+
interface RailwayProviderConfig {
|
|
355
|
+
/** Railway API token */
|
|
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;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Blaxel provider configuration for explicit compute mode
|
|
407
|
+
*/
|
|
408
|
+
interface BlaxelProviderConfig {
|
|
409
|
+
/** Blaxel API key */
|
|
410
|
+
apiKey?: string;
|
|
411
|
+
/** Blaxel workspace */
|
|
412
|
+
workspace?: string;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Explicit compute configuration for callable compute()
|
|
417
|
+
*
|
|
418
|
+
* Used when calling compute as a function: compute({ provider: 'e2b', ... })
|
|
419
|
+
* Always uses gateway mode.
|
|
420
|
+
*/
|
|
421
|
+
interface ExplicitComputeConfig {
|
|
422
|
+
/** Provider name to use */
|
|
423
|
+
provider: ProviderName;
|
|
424
|
+
/** ComputeSDK API key (required for gateway mode) */
|
|
425
|
+
apiKey: string;
|
|
426
|
+
/** E2B provider configuration */
|
|
427
|
+
e2b?: E2BProviderConfig;
|
|
428
|
+
/** Modal provider configuration */
|
|
429
|
+
modal?: ModalProviderConfig;
|
|
430
|
+
/** Railway provider configuration */
|
|
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;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Callable compute type - works as both singleton and factory function
|
|
447
|
+
*/
|
|
448
|
+
type CallableCompute = ComputeAPI & ((config: ExplicitComputeConfig) => ComputeAPI);
|
|
262
449
|
|
|
263
450
|
/**
|
|
264
451
|
* Compute Singleton - Main API Orchestrator
|
|
265
452
|
*
|
|
266
|
-
* Provides the unified compute.* API and delegates to specialized managers
|
|
453
|
+
* Provides the unified compute.* API and delegates to specialized managers.
|
|
454
|
+
* The `compute` export works as both a singleton and a callable function:
|
|
455
|
+
*
|
|
456
|
+
* - Singleton: `compute.sandbox.create()` (auto-detects from env vars)
|
|
457
|
+
* - Callable: `compute({ provider: 'e2b', ... }).sandbox.create()` (explicit config, uses gateway)
|
|
267
458
|
*/
|
|
268
459
|
|
|
269
460
|
/**
|
|
270
|
-
*
|
|
461
|
+
* Callable compute - works as both singleton and factory function
|
|
462
|
+
*
|
|
463
|
+
* @example
|
|
464
|
+
* ```typescript
|
|
465
|
+
* import { compute } from 'computesdk';
|
|
466
|
+
*
|
|
467
|
+
* // Singleton mode (auto-detects from env vars)
|
|
468
|
+
* const sandbox1 = await compute.sandbox.create();
|
|
469
|
+
*
|
|
470
|
+
* // Callable mode (explicit config, uses gateway)
|
|
471
|
+
* const sandbox2 = await compute({
|
|
472
|
+
* provider: 'e2b',
|
|
473
|
+
* apiKey: 'computesdk_xxx',
|
|
474
|
+
* e2b: { apiKey: 'e2b_xxx' }
|
|
475
|
+
* }).sandbox.create();
|
|
476
|
+
* ```
|
|
271
477
|
*/
|
|
272
|
-
declare const compute:
|
|
478
|
+
declare const compute: CallableCompute;
|
|
273
479
|
/**
|
|
274
480
|
* Create a compute instance with proper typing
|
|
275
481
|
*
|
|
@@ -294,6 +500,21 @@ declare const compute: ComputeAPI;
|
|
|
294
500
|
declare function createCompute(): ComputeAPI;
|
|
295
501
|
declare function createCompute<TProvider extends Provider>(config: ComputeConfig<TProvider>): TypedComputeAPI<TProvider>;
|
|
296
502
|
|
|
503
|
+
/**
|
|
504
|
+
* Explicit Config
|
|
505
|
+
*
|
|
506
|
+
* Converts explicit compute configuration to a gateway provider.
|
|
507
|
+
* Used when compute() is called as a function with configuration.
|
|
508
|
+
*/
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Create a gateway provider from explicit configuration
|
|
512
|
+
*
|
|
513
|
+
* @param config - Explicit compute configuration
|
|
514
|
+
* @returns A configured gateway provider
|
|
515
|
+
*/
|
|
516
|
+
declare function createProviderFromConfig(config: ExplicitComputeConfig): Provider;
|
|
517
|
+
|
|
297
518
|
/**
|
|
298
519
|
* Provider Factory - Creates providers from method definitions
|
|
299
520
|
*
|
|
@@ -471,6 +692,7 @@ declare function autoConfigureCompute(): Provider | null;
|
|
|
471
692
|
*
|
|
472
693
|
* Default configuration values and provider definitions
|
|
473
694
|
*/
|
|
695
|
+
|
|
474
696
|
/**
|
|
475
697
|
* Default gateway URL for sandbox lifecycle operations
|
|
476
698
|
*/
|
|
@@ -482,7 +704,7 @@ declare const GATEWAY_URL = "https://gateway.computesdk.com";
|
|
|
482
704
|
declare const PROVIDER_PRIORITY: readonly ["e2b", "railway", "daytona", "modal", "runloop", "vercel", "cloudflare", "codesandbox", "blaxel"];
|
|
483
705
|
/**
|
|
484
706
|
* Required environment variables for each provider
|
|
485
|
-
*
|
|
707
|
+
* @deprecated Use PROVIDER_AUTH from provider-config instead
|
|
486
708
|
*/
|
|
487
709
|
declare const PROVIDER_ENV_VARS: {
|
|
488
710
|
readonly e2b: readonly ["E2B_API_KEY"];
|
|
@@ -495,10 +717,6 @@ declare const PROVIDER_ENV_VARS: {
|
|
|
495
717
|
readonly codesandbox: readonly ["CSB_API_KEY"];
|
|
496
718
|
readonly blaxel: readonly ["BL_API_KEY", "BL_WORKSPACE"];
|
|
497
719
|
};
|
|
498
|
-
/**
|
|
499
|
-
* Type for provider names
|
|
500
|
-
*/
|
|
501
|
-
type ProviderName = keyof typeof PROVIDER_ENV_VARS;
|
|
502
720
|
|
|
503
721
|
/**
|
|
504
722
|
* Utility functions for ComputeSDK
|
|
@@ -583,4 +801,4 @@ interface HandleComputeRequestParams {
|
|
|
583
801
|
provider: Provider;
|
|
584
802
|
}
|
|
585
803
|
|
|
586
|
-
export { type BaseProviderConfig, type ComputeAPI, type ComputeConfig, type ComputeRequest, type ComputeResponse, type CreateSandboxParams, type CreateSandboxParamsWithOptionalProvider, type CreateSnapshotOptions, type CreateTemplateOptions, type ExtractProviderSandboxType, GATEWAY_URL, type GatewayConfig, type HandleComputeRequestParams, type ListSnapshotsOptions, type ListTemplatesOptions, PROVIDER_ENV_VARS, PROVIDER_PRIORITY, type Provider, type ProviderConfig, type ProviderMode, type ProviderName, type ProviderSandbox, type ProviderSandboxManager, type ProviderSnapshotManager, type ProviderTemplateManager, type SandboxInfo, type SandboxMethods, type SnapshotMethods, type TemplateMethods, type TypedComputeAPI, type TypedProviderSandbox, autoConfigureCompute, calculateBackoff, compute, createCompute, createProvider, 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 };
|