computesdk 1.0.2 → 2.0.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.mjs CHANGED
@@ -130,25 +130,19 @@ var DEFAULT_TIMEOUT = 3e5;
130
130
  var ENV_KEYS = {
131
131
  E2B: "E2B_API_KEY",
132
132
  VERCEL: "VERCEL_TOKEN",
133
- CLOUDFLARE: "CLOUDFLARE_API_TOKEN",
134
- FLY: "FLY_API_TOKEN"
133
+ DAYTONA: "DAYTONA_API_KEY"
135
134
  };
136
- function isCloudflareWorkers() {
137
- return typeof DurableObject !== "undefined" && typeof WebSocketPair !== "undefined" && typeof caches !== "undefined";
138
- }
139
135
  function detectAvailableProviders() {
140
136
  const available = [];
141
- if (process.env[ENV_KEYS.E2B]) {
137
+ const env = typeof process !== "undefined" ? process.env : {};
138
+ if (env[ENV_KEYS.E2B]) {
142
139
  available.push("e2b");
143
140
  }
144
- if (process.env[ENV_KEYS.VERCEL]) {
141
+ if (env[ENV_KEYS.VERCEL]) {
145
142
  available.push("vercel");
146
143
  }
147
- if (isCloudflareWorkers() || process.env[ENV_KEYS.CLOUDFLARE]) {
148
- available.push("cloudflare");
149
- }
150
- if (process.env[ENV_KEYS.FLY]) {
151
- available.push("fly");
144
+ if (env[ENV_KEYS.DAYTONA]) {
145
+ available.push("daytona");
152
146
  }
153
147
  return available;
154
148
  }
@@ -177,12 +171,8 @@ function getDefaultRuntime(provider, runtime) {
177
171
  return "python";
178
172
  case "vercel":
179
173
  return "node";
180
- case "cloudflare":
181
- case "fly":
182
- throw new ConfigurationError(
183
- `Container-based provider '${provider}' requires explicit runtime or container configuration`,
184
- provider
185
- );
174
+ case "daytona":
175
+ return "python";
186
176
  default:
187
177
  return "node";
188
178
  }
@@ -196,14 +186,8 @@ function validateProviderApiKey(provider) {
196
186
  case "vercel":
197
187
  envKey = ENV_KEYS.VERCEL;
198
188
  break;
199
- case "cloudflare":
200
- if (isCloudflareWorkers()) {
201
- return;
202
- }
203
- envKey = ENV_KEYS.CLOUDFLARE;
204
- break;
205
- case "fly":
206
- envKey = ENV_KEYS.FLY;
189
+ case "daytona":
190
+ envKey = ENV_KEYS.DAYTONA;
207
191
  break;
208
192
  case "auto":
209
193
  return;
@@ -211,7 +195,8 @@ function validateProviderApiKey(provider) {
211
195
  default:
212
196
  throw new ConfigurationError(`Unknown provider: ${provider}`, "config");
213
197
  }
214
- if (!process.env[envKey]) {
198
+ const env = typeof process !== "undefined" ? process.env : {};
199
+ if (!env[envKey]) {
215
200
  const available = detectAvailableProviders();
216
201
  const suggestions = available.length > 0 ? `Available providers: ${available.join(", ")}` : `No provider API keys found. Set ${Object.values(ENV_KEYS).join(" or ")} environment variables.`;
217
202
  throw new ConfigurationError(
@@ -252,18 +237,33 @@ function normalizeSandboxConfig(config) {
252
237
  async function executeSandbox(params) {
253
238
  return await params.sandbox.execute(params.code, params.runtime);
254
239
  }
255
- async function retry(fn, maxRetries = 3, baseDelay = 1e3) {
240
+ async function runCode(params) {
241
+ return await params.sandbox.runCode(params.code, params.runtime);
242
+ }
243
+ async function runCommand(params) {
244
+ return await params.sandbox.runCommand(params.command, params.args);
245
+ }
246
+ async function retry(fn, options = {}) {
247
+ const {
248
+ maxAttempts = 3,
249
+ delay = 1e3,
250
+ backoff = 2,
251
+ onRetry
252
+ } = options;
256
253
  let lastError;
257
- for (let i = 0; i < maxRetries; i++) {
254
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
258
255
  try {
259
256
  return await fn();
260
257
  } catch (error) {
261
258
  lastError = error instanceof Error ? error : new Error(String(error));
262
- if (i === maxRetries - 1) {
259
+ if (attempt === maxAttempts - 1) {
263
260
  throw lastError;
264
261
  }
265
- const delay = baseDelay * Math.pow(2, i);
266
- await new Promise((resolve) => setTimeout(resolve, delay));
262
+ if (onRetry) {
263
+ onRetry(lastError, attempt + 1);
264
+ }
265
+ const currentDelay = delay * Math.pow(backoff, attempt);
266
+ await new Promise((resolve) => setTimeout(resolve, currentDelay));
267
267
  }
268
268
  }
269
269
  throw lastError;
@@ -400,6 +400,195 @@ var BaseProvider = class {
400
400
  );
401
401
  }
402
402
  }
403
+ /**
404
+ * Execute code in a runtime environment
405
+ *
406
+ * @param code Code to execute
407
+ * @param runtime Optional runtime to use
408
+ * @returns Execution result
409
+ */
410
+ async runCode(code, runtime) {
411
+ const startTime = Date.now();
412
+ try {
413
+ const timeoutPromise = new Promise((_, reject) => {
414
+ setTimeout(() => {
415
+ reject(new TimeoutError(
416
+ `Code execution timed out after ${this.timeout}ms`,
417
+ this.provider,
418
+ this.timeout,
419
+ this.sandboxId
420
+ ));
421
+ }, this.timeout);
422
+ });
423
+ const result = await Promise.race([
424
+ this.doRunCode ? this.doRunCode(code, runtime) : this.doExecute(code, runtime),
425
+ timeoutPromise
426
+ ]);
427
+ const executionTime = Date.now() - startTime;
428
+ return {
429
+ ...result,
430
+ executionTime,
431
+ sandboxId: this.sandboxId,
432
+ provider: this.provider
433
+ };
434
+ } catch (error) {
435
+ if (error instanceof Error && error.name.includes("Error") && "code" in error) {
436
+ throw error;
437
+ }
438
+ throw new ProviderError(
439
+ `Code execution failed: ${error instanceof Error ? error.message : String(error)}`,
440
+ this.provider,
441
+ error instanceof Error ? error : void 0,
442
+ this.sandboxId
443
+ );
444
+ }
445
+ }
446
+ /**
447
+ * Execute shell commands
448
+ *
449
+ * @param command Command to execute
450
+ * @param args Command arguments
451
+ * @returns Execution result
452
+ */
453
+ async runCommand(command, args = []) {
454
+ const startTime = Date.now();
455
+ try {
456
+ const timeoutPromise = new Promise((_, reject) => {
457
+ setTimeout(() => {
458
+ reject(new TimeoutError(
459
+ `Command execution timed out after ${this.timeout}ms`,
460
+ this.provider,
461
+ this.timeout,
462
+ this.sandboxId
463
+ ));
464
+ }, this.timeout);
465
+ });
466
+ const result = await Promise.race([
467
+ this.doRunCommand ? this.doRunCommand(command, args) : this.doExecute(`${command} ${args.join(" ")}`, "node"),
468
+ timeoutPromise
469
+ ]);
470
+ const executionTime = Date.now() - startTime;
471
+ return {
472
+ ...result,
473
+ executionTime,
474
+ sandboxId: this.sandboxId,
475
+ provider: this.provider
476
+ };
477
+ } catch (error) {
478
+ if (error instanceof Error && error.name.includes("Error") && "code" in error) {
479
+ throw error;
480
+ }
481
+ throw new ProviderError(
482
+ `Command execution failed: ${error instanceof Error ? error.message : String(error)}`,
483
+ this.provider,
484
+ error instanceof Error ? error : void 0,
485
+ this.sandboxId
486
+ );
487
+ }
488
+ }
489
+ };
490
+ var BaseFileSystem = class {
491
+ constructor(provider, sandboxId) {
492
+ this.provider = provider;
493
+ this.sandboxId = sandboxId;
494
+ }
495
+ async readFile(path) {
496
+ try {
497
+ return await this.doReadFile(path);
498
+ } catch (error) {
499
+ throw new ProviderError(
500
+ `Failed to read file: ${error instanceof Error ? error.message : String(error)}`,
501
+ this.provider,
502
+ error instanceof Error ? error : void 0,
503
+ this.sandboxId
504
+ );
505
+ }
506
+ }
507
+ async writeFile(path, content) {
508
+ try {
509
+ await this.doWriteFile(path, content);
510
+ } catch (error) {
511
+ throw new ProviderError(
512
+ `Failed to write file: ${error instanceof Error ? error.message : String(error)}`,
513
+ this.provider,
514
+ error instanceof Error ? error : void 0,
515
+ this.sandboxId
516
+ );
517
+ }
518
+ }
519
+ async mkdir(path) {
520
+ try {
521
+ await this.doMkdir(path);
522
+ } catch (error) {
523
+ throw new ProviderError(
524
+ `Failed to create directory: ${error instanceof Error ? error.message : String(error)}`,
525
+ this.provider,
526
+ error instanceof Error ? error : void 0,
527
+ this.sandboxId
528
+ );
529
+ }
530
+ }
531
+ async readdir(path) {
532
+ try {
533
+ return await this.doReaddir(path);
534
+ } catch (error) {
535
+ throw new ProviderError(
536
+ `Failed to read directory: ${error instanceof Error ? error.message : String(error)}`,
537
+ this.provider,
538
+ error instanceof Error ? error : void 0,
539
+ this.sandboxId
540
+ );
541
+ }
542
+ }
543
+ async exists(path) {
544
+ try {
545
+ return await this.doExists(path);
546
+ } catch (error) {
547
+ return false;
548
+ }
549
+ }
550
+ async remove(path) {
551
+ try {
552
+ await this.doRemove(path);
553
+ } catch (error) {
554
+ throw new ProviderError(
555
+ `Failed to remove: ${error instanceof Error ? error.message : String(error)}`,
556
+ this.provider,
557
+ error instanceof Error ? error : void 0,
558
+ this.sandboxId
559
+ );
560
+ }
561
+ }
562
+ };
563
+ var BaseTerminal = class {
564
+ constructor(provider, sandboxId) {
565
+ this.provider = provider;
566
+ this.sandboxId = sandboxId;
567
+ }
568
+ async create(options) {
569
+ try {
570
+ return await this.doCreate(options);
571
+ } catch (error) {
572
+ throw new ProviderError(
573
+ `Failed to create terminal: ${error instanceof Error ? error.message : String(error)}`,
574
+ this.provider,
575
+ error instanceof Error ? error : void 0,
576
+ this.sandboxId
577
+ );
578
+ }
579
+ }
580
+ async list() {
581
+ try {
582
+ return await this.doList();
583
+ } catch (error) {
584
+ throw new ProviderError(
585
+ `Failed to list terminals: ${error instanceof Error ? error.message : String(error)}`,
586
+ this.provider,
587
+ error instanceof Error ? error : void 0,
588
+ this.sandboxId
589
+ );
590
+ }
591
+ }
403
592
  };
404
593
 
405
594
  // src/sdk.ts
@@ -423,22 +612,7 @@ var ComputeSDK = class {
423
612
  "sdk"
424
613
  );
425
614
  }
426
- if (providerName === "cloudflare") {
427
- throw new ConfigurationError(
428
- 'Cloudflare provider requires env parameter with Sandbox namespace. Use createSandbox({ provider: "cloudflare", env: yourEnv }) from within a Worker.',
429
- "sdk"
430
- );
431
- } else if (providerName === "fly") {
432
- if (!normalizedConfig.container) {
433
- throw new ConfigurationError(
434
- `${providerName} provider requires container configuration`,
435
- "sdk"
436
- );
437
- }
438
- return factory({ ...normalizedConfig, container: normalizedConfig.container });
439
- } else {
440
- return factory(normalizedConfig);
441
- }
615
+ return factory(normalizedConfig);
442
616
  } catch (error) {
443
617
  if (error instanceof ConfigurationError) {
444
618
  throw error;
@@ -469,7 +643,9 @@ var ComputeSDK = class {
469
643
  var index_default = ComputeSDK;
470
644
  export {
471
645
  AuthenticationError,
646
+ BaseFileSystem,
472
647
  BaseProvider,
648
+ BaseTerminal,
473
649
  ComputeError,
474
650
  ComputeSDK,
475
651
  ConfigurationError,
@@ -485,10 +661,11 @@ export {
485
661
  detectAvailableProviders,
486
662
  executeSandbox,
487
663
  getDefaultRuntime,
488
- isCloudflareWorkers,
489
664
  normalizeContainerConfig,
490
665
  normalizeSandboxConfig,
491
666
  retry,
667
+ runCode,
668
+ runCommand,
492
669
  validateProviderApiKey
493
670
  };
494
671
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors.ts","../src/config.ts","../src/utils.ts","../src/registry.ts","../src/providers/base.ts","../src/sdk.ts","../src/index.ts"],"sourcesContent":["/**\n * ComputeSDK Error Handling\n * \n * This file contains standardized error classes for the ComputeSDK.\n */\n\n/**\n * Base error class for all ComputeSDK errors\n */\nexport abstract class ComputeError extends Error {\n /** Error code identifier */\n abstract readonly code: string;\n\n /** Whether the operation can be retried */\n abstract readonly isRetryable: boolean;\n\n /** Provider where the error occurred */\n readonly provider: string;\n\n /** Sandbox ID where the error occurred */\n readonly sandboxId?: string;\n\n /**\n * Create a new ComputeError\n * \n * @param message Error message\n * @param provider Provider identifier\n * @param sandboxId Optional sandbox identifier\n */\n constructor(message: string, provider: string, sandboxId?: string) {\n super(message);\n this.name = this.constructor.name;\n this.provider = provider;\n this.sandboxId = sandboxId;\n\n // Ensure proper prototype chain for instanceof checks\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Error thrown when code execution fails\n */\nexport class ExecutionError extends ComputeError {\n /** Error code */\n readonly code = 'EXECUTION_ERROR';\n\n /** Execution errors are generally not retryable */\n readonly isRetryable = false;\n\n /** Exit code from the failed execution */\n readonly exitCode: number;\n\n /**\n * Create a new ExecutionError\n * \n * @param message Error message\n * @param provider Provider identifier\n * @param exitCode Exit code from the execution\n * @param sandboxId Optional sandbox identifier\n */\n constructor(message: string, provider: string, exitCode: number, sandboxId?: string) {\n super(message, provider, sandboxId);\n this.exitCode = exitCode;\n }\n}\n\n/**\n * Error thrown when code execution times out\n */\nexport class TimeoutError extends ComputeError {\n /** Error code */\n readonly code = 'TIMEOUT_ERROR';\n\n /** Timeout errors may be retryable with a longer timeout */\n readonly isRetryable = true;\n\n /** Timeout duration in milliseconds */\n readonly timeoutMs: number;\n\n /**\n * Create a new TimeoutError\n * \n * @param message Error message\n * @param provider Provider identifier\n * @param timeoutMs Timeout duration in milliseconds\n * @param sandboxId Optional sandbox identifier\n */\n constructor(message: string, provider: string, timeoutMs: number, sandboxId?: string) {\n super(message, provider, sandboxId);\n this.timeoutMs = timeoutMs;\n }\n}\n\n/**\n * Error thrown when provider-specific operations fail\n */\nexport class ProviderError extends ComputeError {\n /** Error code */\n readonly code = 'PROVIDER_ERROR';\n\n /** Provider errors may be retryable */\n readonly isRetryable = true;\n\n /** Original error from the provider */\n readonly originalError?: Error;\n\n /**\n * Create a new ProviderError\n * \n * @param message Error message\n * @param provider Provider identifier\n * @param originalError Optional original error from the provider\n * @param sandboxId Optional sandbox identifier\n */\n constructor(message: string, provider: string, originalError?: Error, sandboxId?: string) {\n super(message, provider, sandboxId);\n this.originalError = originalError;\n }\n}\n\n/**\n * Error thrown when configuration is invalid\n */\nexport class ConfigurationError extends ComputeError {\n /** Error code */\n readonly code = 'CONFIGURATION_ERROR';\n\n /** Configuration errors are not retryable without changes */\n readonly isRetryable = false;\n\n /**\n * Create a new ConfigurationError\n * \n * @param message Error message\n * @param provider Provider identifier\n * @param sandboxId Optional sandbox identifier\n */\n constructor(message: string, provider: string, sandboxId?: string) {\n super(message, provider, sandboxId);\n }\n}\n\n/**\n * Error thrown when authentication fails\n */\nexport class AuthenticationError extends ComputeError {\n /** Error code */\n readonly code = 'AUTHENTICATION_ERROR';\n\n /** Authentication errors are not retryable without new credentials */\n readonly isRetryable = false;\n\n /**\n * Create a new AuthenticationError\n * \n * @param message Error message\n * @param provider Provider identifier\n * @param sandboxId Optional sandbox identifier\n */\n constructor(message: string, provider: string, sandboxId?: string) {\n super(message, provider, sandboxId);\n }\n}\n\n/**\n * Error thrown when the provider is not available\n */\nexport class ProviderUnavailableError extends ComputeError {\n /** Error code */\n readonly code = 'PROVIDER_UNAVAILABLE';\n\n /** Provider unavailability may be temporary */\n readonly isRetryable = true;\n\n /**\n * Create a new ProviderUnavailableError\n * \n * @param message Error message\n * @param provider Provider identifier\n * @param sandboxId Optional sandbox identifier\n */\n constructor(message: string, provider: string, sandboxId?: string) {\n super(message, provider, sandboxId);\n }\n}\n","/**\n * ComputeSDK Configuration Management\n * \n * This file manages configuration and provider selection logic.\n */\n\nimport { SandboxConfig, ProviderType, Runtime, ContainerConfig } from './types';\nimport { ConfigurationError } from './errors';\n\n// Global type declarations for platform detection\ndeclare global {\n var DurableObject: any;\n var WebSocketPair: any;\n}\n\n// Default configuration values\nexport const DEFAULT_TIMEOUT = 300000; // 5 minutes in milliseconds\n\n/**\n * Environment variable names for provider API keys\n */\nexport const ENV_KEYS = {\n E2B: 'E2B_API_KEY',\n VERCEL: 'VERCEL_TOKEN',\n CLOUDFLARE: 'CLOUDFLARE_API_TOKEN',\n FLY: 'FLY_API_TOKEN',\n};\n\n/**\n * Detect if running in Cloudflare Workers environment\n * \n * @returns True if running in Cloudflare Workers\n */\nexport function isCloudflareWorkers(): boolean {\n return typeof DurableObject !== 'undefined' && \n typeof WebSocketPair !== 'undefined' &&\n typeof caches !== 'undefined';\n}\n\n/**\n * Detect available providers based on environment variables\n * \n * @returns Array of available provider types\n */\nexport function detectAvailableProviders(): ProviderType[] {\n const available: ProviderType[] = [];\n\n if (process.env[ENV_KEYS.E2B]) {\n available.push('e2b');\n }\n\n if (process.env[ENV_KEYS.VERCEL]) {\n available.push('vercel');\n }\n\n // Cloudflare can be detected by environment OR API key\n if (isCloudflareWorkers() || process.env[ENV_KEYS.CLOUDFLARE]) {\n available.push('cloudflare');\n }\n\n if (process.env[ENV_KEYS.FLY]) {\n available.push('fly');\n }\n\n return available;\n}\n\n/**\n * Auto-select the best provider based on available API keys\n * \n * @returns Selected provider type or undefined if none available\n */\nexport function autoSelectProvider(): ProviderType | undefined {\n const available = detectAvailableProviders();\n return available.length > 0 ? available[0] : undefined;\n}\n\n/**\n * Validate and normalize container configuration\n * \n * @param container Container configuration or image string\n * @returns Normalized container configuration\n */\nexport function normalizeContainerConfig(container: string | ContainerConfig | undefined): ContainerConfig | undefined {\n if (!container) {\n return undefined;\n }\n\n if (typeof container === 'string') {\n return { image: container };\n }\n\n if (!container.image) {\n throw new ConfigurationError('Container configuration must include an image', 'config');\n }\n\n return container;\n}\n\n/**\n * Get the appropriate runtime based on provider and configuration\n * \n * @param provider Provider type\n * @param runtime Optional runtime preference\n * @returns Selected runtime\n */\nexport function getDefaultRuntime(provider: ProviderType, runtime?: Runtime): Runtime {\n if (runtime) {\n return runtime;\n }\n\n // Provider-specific defaults\n switch (provider) {\n case 'e2b':\n return 'python';\n case 'vercel':\n return 'node';\n case 'cloudflare':\n case 'fly':\n throw new ConfigurationError(\n `Container-based provider '${provider}' requires explicit runtime or container configuration`,\n provider\n );\n default:\n return 'node';\n }\n}\n\n/**\n * Validate API key for selected provider\n * \n * @param provider Provider type\n * @throws AuthenticationError if API key is missing\n */\nexport function validateProviderApiKey(provider: ProviderType): void {\n let envKey: string;\n\n switch (provider) {\n case 'e2b':\n envKey = ENV_KEYS.E2B;\n break;\n case 'vercel':\n envKey = ENV_KEYS.VERCEL;\n break;\n case 'cloudflare':\n // Cloudflare can work without API key if in Workers environment\n if (isCloudflareWorkers()) {\n return;\n }\n envKey = ENV_KEYS.CLOUDFLARE;\n break;\n case 'fly':\n envKey = ENV_KEYS.FLY;\n break;\n case 'auto':\n return; // Will be handled by auto-selection\n default:\n throw new ConfigurationError(`Unknown provider: ${provider}`, 'config');\n }\n\n if (!process.env[envKey]) {\n const available = detectAvailableProviders();\n const suggestions = available.length > 0\n ? `Available providers: ${available.join(', ')}`\n : `No provider API keys found. Set ${Object.values(ENV_KEYS).join(' or ')} environment variables.`;\n\n throw new ConfigurationError(\n `Missing API key for provider '${provider}'. ${suggestions}`,\n provider\n );\n }\n}\n\n/**\n * Normalize and validate sandbox configuration\n * \n * @param config User-provided configuration\n * @returns Normalized configuration with defaults applied\n */\nexport function normalizeSandboxConfig(config?: Partial<SandboxConfig>): SandboxConfig {\n const normalized: SandboxConfig = {\n provider: config?.provider || 'auto',\n timeout: config?.timeout || DEFAULT_TIMEOUT,\n };\n\n // Handle provider selection\n if (normalized.provider === 'auto') {\n const autoProvider = autoSelectProvider();\n if (!autoProvider) {\n throw new ConfigurationError(\n `No provider API keys found. Set one of the following environment variables: ${Object.values(ENV_KEYS).join(', ')}`,\n 'config'\n );\n }\n normalized.provider = autoProvider;\n } else {\n validateProviderApiKey(normalized.provider!);\n }\n\n // Handle runtime selection\n if (config?.runtime) {\n normalized.runtime = config.runtime;\n } else if (!config?.container) {\n normalized.runtime = getDefaultRuntime(normalized.provider!);\n }\n\n // Handle container configuration\n if (config?.container) {\n normalized.container = normalizeContainerConfig(config.container);\n }\n\n return normalized;\n}\n","/**\n * Utility functions for ComputeSDK\n */\n\nimport type { ExecuteSandboxParams, ExecutionResult, ComputeSandbox } from './types';\n\n/**\n * Execute code in a sandbox\n */\nexport async function executeSandbox(params: ExecuteSandboxParams): Promise<ExecutionResult> {\n return await params.sandbox.execute(params.code, params.runtime);\n}\n\n/**\n * Retry function with exponential backoff\n */\nexport async function retry<T>(\n fn: () => Promise<T>,\n maxRetries: number = 3,\n baseDelay: number = 1000\n): Promise<T> {\n let lastError: Error;\n \n for (let i = 0; i < maxRetries; i++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error));\n \n if (i === maxRetries - 1) {\n throw lastError;\n }\n \n // Exponential backoff\n const delay = baseDelay * Math.pow(2, i);\n await new Promise(resolve => setTimeout(resolve, delay));\n }\n }\n \n throw lastError!;\n}","/**\n * ComputeSDK Provider Registry\n * \n * This file implements the provider registry for managing multiple providers.\n */\n\nimport { ComputeSandbox, ProviderMap, ProviderRegistry, Runtime } from './types';\nimport { ConfigurationError } from './errors';\n\n/**\n * Create a provider registry for managing multiple providers\n * \n * @param providers Map of provider factories\n * @returns Provider registry instance\n */\nexport function createComputeRegistry(providers: ProviderMap): ProviderRegistry {\n // Validate provider map\n if (!providers || Object.keys(providers).length === 0) {\n throw new ConfigurationError('Provider registry requires at least one provider', 'registry');\n }\n\n /**\n * Get a sandbox by ID string\n * \n * Format: \"<provider>:<runtime>\" or \"<provider>:<container-image>\"\n * Examples: \"e2b:python\", \"vercel:node\", \"fly:python:3.9\"\n * \n * @param id Sandbox identifier string\n * @returns Configured sandbox instance\n */\n function sandbox(id: string): ComputeSandbox {\n const parts = id.split(':');\n\n if (parts.length < 1) {\n throw new ConfigurationError(`Invalid sandbox ID format: ${id}`, 'registry');\n }\n\n const providerName = parts[0];\n const providerFactory = providers[providerName];\n\n if (!providerFactory) {\n const availableProviders = Object.keys(providers).join(', ');\n throw new ConfigurationError(\n `Provider '${providerName}' not found in registry. Available providers: ${availableProviders}`,\n 'registry'\n );\n }\n\n // Handle different ID formats\n if (parts.length === 1) {\n // Just provider name, use default configuration\n return providerFactory();\n } else if (parts.length === 2) {\n // Provider with runtime or container image\n const runtimeOrImage = parts[1];\n\n // Check if it's a runtime\n if (isRuntime(runtimeOrImage)) {\n return providerFactory({ runtime: runtimeOrImage });\n }\n\n // Otherwise, treat as container image\n return providerFactory({ container: { image: runtimeOrImage } });\n } else {\n // Handle more complex formats (container with tag)\n const containerImage = parts.slice(1).join(':');\n return providerFactory({ container: { image: containerImage } });\n }\n }\n\n return { sandbox };\n}\n\n/**\n * Check if a string is a valid runtime\n * \n * @param value String to check\n * @returns Whether the string is a valid runtime\n */\nfunction isRuntime(value: string): value is Runtime {\n return ['node', 'python'].includes(value);\n}\n","/**\n * ComputeSDK Base Provider\n * \n * This file contains the base provider implementation that all\n * specific provider implementations extend.\n */\n\nimport { v4 as uuidv4 } from 'uuid';\nimport {\n ComputeSpecification,\n ComputeSandbox,\n Runtime,\n ExecutionResult,\n SandboxInfo\n} from '../types';\nimport { ProviderError, TimeoutError } from '../errors';\n\n/**\n * Base implementation of the ComputeSandbox interface\n * \n * Provides common functionality and wraps provider-specific implementations.\n */\nexport abstract class BaseProvider implements ComputeSandbox, ComputeSpecification {\n /** Specification version */\n public readonly specificationVersion = 'v1';\n\n /** Provider identifier */\n public readonly provider: string;\n\n /** Sandbox identifier */\n public readonly sandboxId: string;\n\n /** Execution timeout in milliseconds */\n protected readonly timeout: number;\n\n /**\n * Create a new base provider\n * \n * @param provider Provider identifier\n * @param timeout Execution timeout in milliseconds\n */\n constructor(provider: string, timeout: number) {\n this.provider = provider;\n this.sandboxId = uuidv4();\n this.timeout = timeout;\n }\n\n /**\n * Execute code in the sandbox\n * \n * @param code Code to execute\n * @param runtime Optional runtime to use\n * @returns Execution result\n */\n public async execute(code: string, runtime?: Runtime): Promise<ExecutionResult> {\n const startTime = Date.now();\n\n try {\n // Create a timeout promise that rejects after the timeout\n const timeoutPromise = new Promise<never>((_, reject) => {\n setTimeout(() => {\n reject(new TimeoutError(\n `Execution timed out after ${this.timeout}ms`,\n this.provider,\n this.timeout,\n this.sandboxId\n ));\n }, this.timeout);\n });\n\n // Execute the code with a timeout\n const result = await Promise.race([\n this.doExecute(code, runtime),\n timeoutPromise\n ]);\n\n // Calculate execution time\n const executionTime = Date.now() - startTime;\n\n return {\n ...result,\n executionTime,\n sandboxId: this.sandboxId,\n provider: this.provider\n };\n } catch (error) {\n // If the error is already a ComputeError, rethrow it\n if (error instanceof Error && error.name.includes('Error') && 'code' in error) {\n throw error;\n }\n\n // Otherwise, wrap it in a ProviderError\n throw new ProviderError(\n `Execution failed: ${error instanceof Error ? error.message : String(error)}`,\n this.provider,\n error instanceof Error ? error : undefined,\n this.sandboxId\n );\n }\n }\n\n /**\n * Kill the sandbox\n * \n * @returns Promise that resolves when the sandbox is killed\n */\n public async kill(): Promise<void> {\n try {\n await this.doKill();\n } catch (error) {\n throw new ProviderError(\n `Failed to kill sandbox: ${error instanceof Error ? error.message : String(error)}`,\n this.provider,\n error instanceof Error ? error : undefined,\n this.sandboxId\n );\n }\n }\n\n /**\n * Get information about the sandbox\n * \n * @returns Sandbox information\n */\n public async getInfo(): Promise<SandboxInfo> {\n try {\n return await this.doGetInfo();\n } catch (error) {\n throw new ProviderError(\n `Failed to get sandbox info: ${error instanceof Error ? error.message : String(error)}`,\n this.provider,\n error instanceof Error ? error : undefined,\n this.sandboxId\n );\n }\n }\n\n /**\n * Provider-specific implementation of code execution\n * \n * @param code Code to execute\n * @param runtime Optional runtime to use\n * @returns Execution result\n */\n public abstract doExecute(code: string, runtime?: Runtime): Promise<ExecutionResult>;\n\n /**\n * Provider-specific implementation of sandbox termination\n * \n * @returns Promise that resolves when the sandbox is killed\n */\n public abstract doKill(): Promise<void>;\n\n /**\n * Provider-specific implementation of retrieving sandbox information\n * \n * @returns Sandbox information\n */\n public abstract doGetInfo(): Promise<SandboxInfo>;\n}\n","import type { \n SandboxConfig, \n ComputeSandbox, \n ProviderType,\n Runtime,\n ContainerConfig\n} from './types';\nimport { \n ConfigurationError, \n AuthenticationError \n} from './errors';\nimport { \n normalizeSandboxConfig, \n detectAvailableProviders \n} from './config';\n\nexport class ComputeSDK {\n /**\n * Create a new sandbox with the specified configuration\n * \n * @param config Optional sandbox configuration\n * @returns Configured sandbox instance\n */\n static createSandbox(config?: Partial<SandboxConfig>): ComputeSandbox {\n const normalizedConfig = normalizeSandboxConfig(config);\n \n // Try to dynamically load the provider\n const providerName = normalizedConfig.provider;\n \n try {\n // Attempt to load provider package\n const providerPackage = `@computesdk/${providerName}`;\n const provider = require(providerPackage);\n \n // Get the factory function\n const factory = provider[providerName!];\n if (!factory) {\n throw new ConfigurationError(\n `Provider package ${providerPackage} does not export a '${providerName}' function`,\n 'sdk'\n );\n }\n \n // Create the sandbox based on provider type\n if (providerName === 'cloudflare') {\n // Cloudflare requires env parameter with Durable Object namespace\n // This would need to be passed in from the Worker context\n throw new ConfigurationError(\n 'Cloudflare provider requires env parameter with Sandbox namespace. ' +\n 'Use createSandbox({ provider: \"cloudflare\", env: yourEnv }) from within a Worker.',\n 'sdk'\n );\n } else if (providerName === 'fly') {\n if (!normalizedConfig.container) {\n throw new ConfigurationError(\n `${providerName} provider requires container configuration`,\n 'sdk'\n );\n }\n return factory({ ...normalizedConfig, container: normalizedConfig.container });\n } else {\n return factory(normalizedConfig);\n }\n } catch (error) {\n if (error instanceof ConfigurationError) {\n throw error;\n }\n \n // Check if it's a missing package error\n if ((error as any).code === 'MODULE_NOT_FOUND') {\n throw new ConfigurationError(\n `Provider '${providerName}' not installed. Run: npm install @computesdk/${providerName}`,\n 'sdk'\n );\n }\n \n throw new ConfigurationError(\n `Failed to load provider '${providerName}': ${(error as Error).message}`,\n 'sdk'\n );\n }\n }\n \n /**\n * Detect available providers based on environment variables\n * \n * @returns Array of available provider types\n */\n static detectProviders(): ProviderType[] {\n return detectAvailableProviders();\n }\n}","/**\n * ComputeSDK Core\n * \n * A unified abstraction layer for executing code in secure,\n * isolated sandboxed environments across multiple cloud providers.\n */\n\n// Export all types\nexport * from './types';\n\n// Export all errors\nexport * from './errors';\n\n// Export configuration utilities\nexport * from './config';\n\n// Export utilities\nexport { executeSandbox, retry } from './utils';\n\n// Export registry\nexport { createComputeRegistry } from './registry';\n\n// Export base provider for extension\nexport { BaseProvider } from './providers/base';\n\n// Export main SDK class\nexport { ComputeSDK } from './sdk';\n\n// Default export\nimport { ComputeSDK } from './sdk';\nexport default ComputeSDK;\n"],"mappings":";;;;;;;;AASO,IAAe,eAAf,cAAoC,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoB/C,YAAY,SAAiB,UAAkB,WAAoB;AACjE,UAAM,OAAO;AACb,SAAK,OAAO,KAAK,YAAY;AAC7B,SAAK,WAAW;AAChB,SAAK,YAAY;AAGjB,WAAO,eAAe,MAAM,WAAW,SAAS;AAAA,EAClD;AACF;AAKO,I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E,UAAM,mBAAmB,uBAAuB,MAAM;AAGtD,UAAM,eAAe,iBAAiB;AAEtC,QAAI;AAEF,YAAM,kBAAkB,eAAe,YAAY;AACnD,YAAM,WAAW,UAAQ,eAAe;AAGxC,YAAM,UAAU,SAAS,YAAa;AACtC,UAAI,CAAC,SAAS;AACZ,cAAM,IAAI;AAAA,UACR,oBAAoB,eAAe,uBAAuB,YAAY;AAAA,UACtE;AAAA,QACF;AAAA,MACF;AAGA,UAAI,iBAAiB,cAAc;AAGjC,cAAM,IAAI;AAAA,UACR;AAAA,UAEA;AAAA,QACF;AAAA,MACF,WAAW,iBAAiB,OAAO;AACjC,YAAI,CAAC,iBAAiB,WAAW;AAC/B,gBAAM,IAAI;AAAA,YACR,GAAG,YAAY;AAAA,YACf;AAAA,UACF;AAAA,QACF;AACA,eAAO,QAAQ,EAAE,GAAG,kBAAkB,WAAW,iBAAiB,UAAU,CAAC;AAAA,MAC/E,OAAO;AACL,eAAO,QAAQ,gBAAgB;AAAA,MACjC;AAAA,IACF,SAAS,OAAO;AACd,UAAI,iBAAiB,oBAAoB;AACvC,cAAM;AAAA,MACR;AAGA,UAAK,MAAc,SAAS,oBAAoB;AAC9C,cAAM,IAAI;AAAA,UACR,aAAa,YAAY,iDAAiD,YAAY;AAAA,UACtF;AAAA,QACF;AAAA,MACF;AAEA,YAAM,IAAI;AAAA,QACR,4BAA4B,YAAY,MAAO,MAAgB,OAAO;AAAA,QACtE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,kBAAkC;AACvC,WAAO,yBAAyB;AAAA,EAClC;AACF;;;AC7DA,IAAO,gBAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/config.ts","../src/utils.ts","../src/registry.ts","../src/providers/base.ts","../src/sdk.ts","../src/index.ts"],"sourcesContent":["/**\n * ComputeSDK Error Handling\n * \n * This file contains standardized error classes for the ComputeSDK.\n */\n\n/**\n * Base error class for all ComputeSDK errors\n */\nexport abstract class ComputeError extends Error {\n /** Error code identifier */\n abstract readonly code: string;\n\n /** Whether the operation can be retried */\n abstract readonly isRetryable: boolean;\n\n /** Provider where the error occurred */\n readonly provider: string;\n\n /** Sandbox ID where the error occurred */\n readonly sandboxId?: string;\n\n /**\n * Create a new ComputeError\n * \n * @param message Error message\n * @param provider Provider identifier\n * @param sandboxId Optional sandbox identifier\n */\n constructor(message: string, provider: string, sandboxId?: string) {\n super(message);\n this.name = this.constructor.name;\n this.provider = provider;\n this.sandboxId = sandboxId;\n\n // Ensure proper prototype chain for instanceof checks\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Error thrown when code execution fails\n */\nexport class ExecutionError extends ComputeError {\n /** Error code */\n readonly code = 'EXECUTION_ERROR';\n\n /** Execution errors are generally not retryable */\n readonly isRetryable = false;\n\n /** Exit code from the failed execution */\n readonly exitCode: number;\n\n /**\n * Create a new ExecutionError\n * \n * @param message Error message\n * @param provider Provider identifier\n * @param exitCode Exit code from the execution\n * @param sandboxId Optional sandbox identifier\n */\n constructor(message: string, provider: string, exitCode: number, sandboxId?: string) {\n super(message, provider, sandboxId);\n this.exitCode = exitCode;\n }\n}\n\n/**\n * Error thrown when code execution times out\n */\nexport class TimeoutError extends ComputeError {\n /** Error code */\n readonly code = 'TIMEOUT_ERROR';\n\n /** Timeout errors may be retryable with a longer timeout */\n readonly isRetryable = true;\n\n /** Timeout duration in milliseconds */\n readonly timeoutMs: number;\n\n /**\n * Create a new TimeoutError\n * \n * @param message Error message\n * @param provider Provider identifier\n * @param timeoutMs Timeout duration in milliseconds\n * @param sandboxId Optional sandbox identifier\n */\n constructor(message: string, provider: string, timeoutMs: number, sandboxId?: string) {\n super(message, provider, sandboxId);\n this.timeoutMs = timeoutMs;\n }\n}\n\n/**\n * Error thrown when provider-specific operations fail\n */\nexport class ProviderError extends ComputeError {\n /** Error code */\n readonly code = 'PROVIDER_ERROR';\n\n /** Provider errors may be retryable */\n readonly isRetryable = true;\n\n /** Original error from the provider */\n readonly originalError?: Error;\n\n /**\n * Create a new ProviderError\n * \n * @param message Error message\n * @param provider Provider identifier\n * @param originalError Optional original error from the provider\n * @param sandboxId Optional sandbox identifier\n */\n constructor(message: string, provider: string, originalError?: Error, sandboxId?: string) {\n super(message, provider, sandboxId);\n this.originalError = originalError;\n }\n}\n\n/**\n * Error thrown when configuration is invalid\n */\nexport class ConfigurationError extends ComputeError {\n /** Error code */\n readonly code = 'CONFIGURATION_ERROR';\n\n /** Configuration errors are not retryable without changes */\n readonly isRetryable = false;\n\n /**\n * Create a new ConfigurationError\n * \n * @param message Error message\n * @param provider Provider identifier\n * @param sandboxId Optional sandbox identifier\n */\n constructor(message: string, provider: string, sandboxId?: string) {\n super(message, provider, sandboxId);\n }\n}\n\n/**\n * Error thrown when authentication fails\n */\nexport class AuthenticationError extends ComputeError {\n /** Error code */\n readonly code = 'AUTHENTICATION_ERROR';\n\n /** Authentication errors are not retryable without new credentials */\n readonly isRetryable = false;\n\n /**\n * Create a new AuthenticationError\n * \n * @param message Error message\n * @param provider Provider identifier\n * @param sandboxId Optional sandbox identifier\n */\n constructor(message: string, provider: string, sandboxId?: string) {\n super(message, provider, sandboxId);\n }\n}\n\n/**\n * Error thrown when the provider is not available\n */\nexport class ProviderUnavailableError extends ComputeError {\n /** Error code */\n readonly code = 'PROVIDER_UNAVAILABLE';\n\n /** Provider unavailability may be temporary */\n readonly isRetryable = true;\n\n /**\n * Create a new ProviderUnavailableError\n * \n * @param message Error message\n * @param provider Provider identifier\n * @param sandboxId Optional sandbox identifier\n */\n constructor(message: string, provider: string, sandboxId?: string) {\n super(message, provider, sandboxId);\n }\n}\n","/**\n * ComputeSDK Configuration Management\n * \n * This file manages configuration and provider selection logic.\n */\n\nimport { SandboxConfig, ProviderType, Runtime, ContainerConfig } from './types';\nimport { ConfigurationError } from './errors';\n\n// Global type declarations for platform detection\ndeclare global {\n var DurableObject: any;\n var WebSocketPair: any;\n}\n\n// Default configuration values\nexport const DEFAULT_TIMEOUT = 300000; // 5 minutes in milliseconds\n\n/**\n * Environment variable names for provider API keys\n */\nexport const ENV_KEYS = {\n E2B: 'E2B_API_KEY',\n VERCEL: 'VERCEL_TOKEN',\n DAYTONA: 'DAYTONA_API_KEY',\n};\n\n/**\n * Detect available providers based on environment variables\n * \n * @returns Array of available provider types\n */\nexport function detectAvailableProviders(): ProviderType[] {\n const available: ProviderType[] = [];\n\n // Safe process.env access for environments without Node.js\n const env = typeof process !== 'undefined' ? process.env : {};\n\n if (env[ENV_KEYS.E2B]) {\n available.push('e2b');\n }\n\n if (env[ENV_KEYS.VERCEL]) {\n available.push('vercel');\n }\n\n if (env[ENV_KEYS.DAYTONA]) {\n available.push('daytona');\n }\n\n return available;\n}\n\n/**\n * Auto-select the best provider based on available API keys\n * \n * @returns Selected provider type or undefined if none available\n */\nexport function autoSelectProvider(): ProviderType | undefined {\n const available = detectAvailableProviders();\n return available.length > 0 ? available[0] : undefined;\n}\n\n/**\n * Validate and normalize container configuration\n * \n * @param container Container configuration or image string\n * @returns Normalized container configuration\n */\nexport function normalizeContainerConfig(container: string | ContainerConfig | undefined): ContainerConfig | undefined {\n if (!container) {\n return undefined;\n }\n\n if (typeof container === 'string') {\n return { image: container };\n }\n\n if (!container.image) {\n throw new ConfigurationError('Container configuration must include an image', 'config');\n }\n\n return container;\n}\n\n/**\n * Get the appropriate runtime based on provider and configuration\n * \n * @param provider Provider type\n * @param runtime Optional runtime preference\n * @returns Selected runtime\n */\nexport function getDefaultRuntime(provider: ProviderType, runtime?: Runtime): Runtime {\n if (runtime) {\n return runtime;\n }\n\n // Provider-specific defaults\n switch (provider) {\n case 'e2b':\n return 'python';\n case 'vercel':\n return 'node';\n case 'daytona':\n return 'python';\n default:\n return 'node';\n }\n}\n\n/**\n * Validate API key for selected provider\n * \n * @param provider Provider type\n * @throws AuthenticationError if API key is missing\n */\nexport function validateProviderApiKey(provider: ProviderType): void {\n let envKey: string;\n\n switch (provider) {\n case 'e2b':\n envKey = ENV_KEYS.E2B;\n break;\n case 'vercel':\n envKey = ENV_KEYS.VERCEL;\n break;\n case 'daytona':\n envKey = ENV_KEYS.DAYTONA;\n break;\n case 'auto':\n return; // Will be handled by auto-selection\n default:\n throw new ConfigurationError(`Unknown provider: ${provider}`, 'config');\n }\n\n // Safe process.env access for environments without Node.js\n const env = typeof process !== 'undefined' ? process.env : {};\n \n if (!env[envKey]) {\n const available = detectAvailableProviders();\n const suggestions = available.length > 0\n ? `Available providers: ${available.join(', ')}`\n : `No provider API keys found. Set ${Object.values(ENV_KEYS).join(' or ')} environment variables.`;\n\n throw new ConfigurationError(\n `Missing API key for provider '${provider}'. ${suggestions}`,\n provider\n );\n }\n}\n\n/**\n * Normalize and validate sandbox configuration\n * \n * @param config User-provided configuration\n * @returns Normalized configuration with defaults applied\n */\nexport function normalizeSandboxConfig(config?: Partial<SandboxConfig>): SandboxConfig {\n const normalized: SandboxConfig = {\n provider: config?.provider || 'auto',\n timeout: config?.timeout || DEFAULT_TIMEOUT,\n };\n\n // Handle provider selection\n if (normalized.provider === 'auto') {\n const autoProvider = autoSelectProvider();\n if (!autoProvider) {\n throw new ConfigurationError(\n `No provider API keys found. Set one of the following environment variables: ${Object.values(ENV_KEYS).join(', ')}`,\n 'config'\n );\n }\n normalized.provider = autoProvider;\n } else {\n validateProviderApiKey(normalized.provider!);\n }\n\n // Handle runtime selection\n if (config?.runtime) {\n normalized.runtime = config.runtime;\n } else if (!config?.container) {\n normalized.runtime = getDefaultRuntime(normalized.provider!);\n }\n\n // Handle container configuration\n if (config?.container) {\n normalized.container = normalizeContainerConfig(config.container);\n }\n\n return normalized;\n}\n","/**\n * Utility functions for ComputeSDK\n */\n\nimport type { ExecuteSandboxParams, ExecutionResult, ComputeSandbox, Runtime } from './types';\n\n/**\n * Execute code in a sandbox\n */\nexport async function executeSandbox(params: ExecuteSandboxParams): Promise<ExecutionResult> {\n return await params.sandbox.execute(params.code, params.runtime);\n}\n\n/**\n * Parameters for the runCode function\n */\nexport interface RunCodeParams {\n /** Sandbox to execute in */\n sandbox: ComputeSandbox;\n /** Code to execute */\n code: string;\n /** Runtime to use */\n runtime?: Runtime;\n}\n\n/**\n * Execute code in a runtime environment\n */\nexport async function runCode(params: RunCodeParams): Promise<ExecutionResult> {\n return await params.sandbox.runCode(params.code, params.runtime);\n}\n\n/**\n * Parameters for the runCommand function\n */\nexport interface RunCommandParams {\n /** Sandbox to execute in */\n sandbox: ComputeSandbox;\n /** Command to execute */\n command: string;\n /** Command arguments */\n args?: string[];\n}\n\n/**\n * Execute shell commands\n */\nexport async function runCommand(params: RunCommandParams): Promise<ExecutionResult> {\n return await params.sandbox.runCommand(params.command, params.args);\n}\n\n/**\n * Options for retry function\n */\nexport interface RetryOptions {\n /** Maximum number of attempts (default: 3) */\n maxAttempts?: number;\n /** Base delay in milliseconds (default: 1000) */\n delay?: number;\n /** Backoff multiplier (default: 2) */\n backoff?: number;\n /** Callback called on each retry attempt */\n onRetry?: (error: Error, attempt: number) => void;\n}\n\n/**\n * Retry function with exponential backoff\n */\nexport async function retry<T>(\n fn: () => Promise<T>,\n options: RetryOptions = {}\n): Promise<T> {\n const {\n maxAttempts = 3,\n delay = 1000,\n backoff = 2,\n onRetry\n } = options;\n \n let lastError: Error;\n \n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error));\n \n if (attempt === maxAttempts - 1) {\n throw lastError;\n }\n \n // Call onRetry callback if provided\n if (onRetry) {\n onRetry(lastError, attempt + 1);\n }\n \n // Calculate delay with exponential backoff\n const currentDelay = delay * Math.pow(backoff, attempt);\n await new Promise(resolve => setTimeout(resolve, currentDelay));\n }\n }\n \n throw lastError!;\n}","/**\n * ComputeSDK Provider Registry\n * \n * This file implements the provider registry for managing multiple providers.\n */\n\nimport { ComputeSandbox, ProviderMap, ProviderRegistry, Runtime } from './types';\nimport { ConfigurationError } from './errors';\n\n/**\n * Create a provider registry for managing multiple providers\n * \n * @param providers Map of provider factories\n * @returns Provider registry instance\n */\nexport function createComputeRegistry(providers: ProviderMap): ProviderRegistry {\n // Validate provider map\n if (!providers || Object.keys(providers).length === 0) {\n throw new ConfigurationError('Provider registry requires at least one provider', 'registry');\n }\n\n /**\n * Get a sandbox by ID string\n * \n * Format: \"<provider>:<runtime>\" or \"<provider>:<container-image>\"\n * Examples: \"e2b:python\", \"vercel:node\", \"fly:python:3.9\"\n * \n * @param id Sandbox identifier string\n * @returns Configured sandbox instance\n */\n function sandbox(id: string): ComputeSandbox {\n const parts = id.split(':');\n\n if (parts.length < 1) {\n throw new ConfigurationError(`Invalid sandbox ID format: ${id}`, 'registry');\n }\n\n const providerName = parts[0];\n const providerFactory = providers[providerName];\n\n if (!providerFactory) {\n const availableProviders = Object.keys(providers).join(', ');\n throw new ConfigurationError(\n `Provider '${providerName}' not found in registry. Available providers: ${availableProviders}`,\n 'registry'\n );\n }\n\n // Handle different ID formats\n if (parts.length === 1) {\n // Just provider name, use default configuration\n return providerFactory();\n } else if (parts.length === 2) {\n // Provider with runtime or container image\n const runtimeOrImage = parts[1];\n\n // Check if it's a runtime\n if (isRuntime(runtimeOrImage)) {\n return providerFactory({ runtime: runtimeOrImage });\n }\n\n // Otherwise, treat as container image\n return providerFactory({ container: { image: runtimeOrImage } });\n } else {\n // Handle more complex formats (container with tag)\n const containerImage = parts.slice(1).join(':');\n return providerFactory({ container: { image: containerImage } });\n }\n }\n\n return { sandbox };\n}\n\n/**\n * Check if a string is a valid runtime\n * \n * @param value String to check\n * @returns Whether the string is a valid runtime\n */\nfunction isRuntime(value: string): value is Runtime {\n return ['node', 'python'].includes(value);\n}\n","/**\n * ComputeSDK Base Provider\n * \n * This file contains the base provider implementation that all\n * specific provider implementations extend.\n */\n\nimport { v4 as uuidv4 } from 'uuid';\nimport {\n BaseComputeSpecification,\n BaseComputeSandbox,\n Runtime,\n ExecutionResult,\n SandboxInfo,\n SandboxFileSystem,\n SandboxTerminal\n} from '../types';\nimport { ProviderError, TimeoutError } from '../errors';\n\n/**\n * Base implementation of the ComputeSandbox interface\n * \n * Provides common functionality and wraps provider-specific implementations.\n */\nexport abstract class BaseProvider implements BaseComputeSandbox, BaseComputeSpecification {\n /** Specification version */\n public readonly specificationVersion = 'v1';\n\n /** Provider identifier */\n public readonly provider: string;\n\n /** Sandbox identifier */\n public readonly sandboxId: string;\n\n /** Execution timeout in milliseconds */\n protected readonly timeout: number;\n\n /**\n * Create a new base provider\n * \n * @param provider Provider identifier\n * @param timeout Execution timeout in milliseconds\n */\n constructor(provider: string, timeout: number) {\n this.provider = provider;\n this.sandboxId = uuidv4();\n this.timeout = timeout;\n }\n\n /**\n * Execute code in the sandbox\n * \n * @param code Code to execute\n * @param runtime Optional runtime to use\n * @returns Execution result\n */\n public async execute(code: string, runtime?: Runtime): Promise<ExecutionResult> {\n const startTime = Date.now();\n\n try {\n // Create a timeout promise that rejects after the timeout\n const timeoutPromise = new Promise<never>((_, reject) => {\n setTimeout(() => {\n reject(new TimeoutError(\n `Execution timed out after ${this.timeout}ms`,\n this.provider,\n this.timeout,\n this.sandboxId\n ));\n }, this.timeout);\n });\n\n // Execute the code with a timeout\n const result = await Promise.race([\n this.doExecute(code, runtime),\n timeoutPromise\n ]);\n\n // Calculate execution time\n const executionTime = Date.now() - startTime;\n\n return {\n ...result,\n executionTime,\n sandboxId: this.sandboxId,\n provider: this.provider\n };\n } catch (error) {\n // If the error is already a ComputeError, rethrow it\n if (error instanceof Error && error.name.includes('Error') && 'code' in error) {\n throw error;\n }\n\n // Otherwise, wrap it in a ProviderError\n throw new ProviderError(\n `Execution failed: ${error instanceof Error ? error.message : String(error)}`,\n this.provider,\n error instanceof Error ? error : undefined,\n this.sandboxId\n );\n }\n }\n\n /**\n * Kill the sandbox\n * \n * @returns Promise that resolves when the sandbox is killed\n */\n public async kill(): Promise<void> {\n try {\n await this.doKill();\n } catch (error) {\n throw new ProviderError(\n `Failed to kill sandbox: ${error instanceof Error ? error.message : String(error)}`,\n this.provider,\n error instanceof Error ? error : undefined,\n this.sandboxId\n );\n }\n }\n\n /**\n * Get information about the sandbox\n * \n * @returns Sandbox information\n */\n public async getInfo(): Promise<SandboxInfo> {\n try {\n return await this.doGetInfo();\n } catch (error) {\n throw new ProviderError(\n `Failed to get sandbox info: ${error instanceof Error ? error.message : String(error)}`,\n this.provider,\n error instanceof Error ? error : undefined,\n this.sandboxId\n );\n }\n }\n\n /**\n * Execute code in a runtime environment\n * \n * @param code Code to execute\n * @param runtime Optional runtime to use\n * @returns Execution result\n */\n public async runCode(code: string, runtime?: Runtime): Promise<ExecutionResult> {\n const startTime = Date.now();\n\n try {\n // Create a timeout promise that rejects after the timeout\n const timeoutPromise = new Promise<never>((_, reject) => {\n setTimeout(() => {\n reject(new TimeoutError(\n `Code execution timed out after ${this.timeout}ms`,\n this.provider,\n this.timeout,\n this.sandboxId\n ));\n }, this.timeout);\n });\n\n // Execute the code with a timeout\n const result = await Promise.race([\n this.doRunCode ? this.doRunCode(code, runtime) : this.doExecute(code, runtime),\n timeoutPromise\n ]);\n\n // Calculate execution time\n const executionTime = Date.now() - startTime;\n\n return {\n ...result,\n executionTime,\n sandboxId: this.sandboxId,\n provider: this.provider\n };\n } catch (error) {\n // If the error is already a ComputeError, rethrow it\n if (error instanceof Error && error.name.includes('Error') && 'code' in error) {\n throw error;\n }\n\n // Otherwise, wrap it in a ProviderError\n throw new ProviderError(\n `Code execution failed: ${error instanceof Error ? error.message : String(error)}`,\n this.provider,\n error instanceof Error ? error : undefined,\n this.sandboxId\n );\n }\n }\n\n /**\n * Execute shell commands\n * \n * @param command Command to execute\n * @param args Command arguments\n * @returns Execution result\n */\n public async runCommand(command: string, args: string[] = []): Promise<ExecutionResult> {\n const startTime = Date.now();\n\n try {\n // Create a timeout promise that rejects after the timeout\n const timeoutPromise = new Promise<never>((_, reject) => {\n setTimeout(() => {\n reject(new TimeoutError(\n `Command execution timed out after ${this.timeout}ms`,\n this.provider,\n this.timeout,\n this.sandboxId\n ));\n }, this.timeout);\n });\n\n // Execute the command with a timeout\n const result = await Promise.race([\n this.doRunCommand ? this.doRunCommand(command, args) : this.doExecute(`${command} ${args.join(' ')}`, 'node'),\n timeoutPromise\n ]);\n\n // Calculate execution time\n const executionTime = Date.now() - startTime;\n\n return {\n ...result,\n executionTime,\n sandboxId: this.sandboxId,\n provider: this.provider\n };\n } catch (error) {\n // If the error is already a ComputeError, rethrow it\n if (error instanceof Error && error.name.includes('Error') && 'code' in error) {\n throw error;\n }\n\n // Otherwise, wrap it in a ProviderError\n throw new ProviderError(\n `Command execution failed: ${error instanceof Error ? error.message : String(error)}`,\n this.provider,\n error instanceof Error ? error : undefined,\n this.sandboxId\n );\n }\n }\n\n /**\n * Provider-specific implementation of code execution\n * \n * @param code Code to execute\n * @param runtime Optional runtime to use\n * @returns Execution result\n */\n public abstract doExecute(code: string, runtime?: Runtime): Promise<ExecutionResult>;\n\n /**\n * Provider-specific implementation of sandbox termination\n * \n * @returns Promise that resolves when the sandbox is killed\n */\n public abstract doKill(): Promise<void>;\n\n /**\n * Provider-specific implementation of retrieving sandbox information\n * \n * @returns Sandbox information\n */\n public abstract doGetInfo(): Promise<SandboxInfo>;\n\n /**\n * Provider-specific implementation of code execution (optional)\n * \n * @param code Code to execute\n * @param runtime Optional runtime to use\n * @returns Execution result\n */\n public doRunCode?(code: string, runtime?: Runtime): Promise<ExecutionResult>;\n\n /**\n * Provider-specific implementation of command execution (optional)\n * \n * @param command Command to execute\n * @param args Command arguments\n * @returns Execution result\n */\n public doRunCommand?(command: string, args: string[]): Promise<ExecutionResult>;\n}\n\n/**\n * Helper class for implementing FileSystem with error handling\n */\nexport abstract class BaseFileSystem implements SandboxFileSystem {\n constructor(\n protected provider: string,\n protected sandboxId: string\n ) {}\n\n async readFile(path: string): Promise<string> {\n try {\n return await this.doReadFile(path);\n } catch (error) {\n throw new ProviderError(\n `Failed to read file: ${error instanceof Error ? error.message : String(error)}`,\n this.provider,\n error instanceof Error ? error : undefined,\n this.sandboxId\n );\n }\n }\n\n async writeFile(path: string, content: string): Promise<void> {\n try {\n await this.doWriteFile(path, content);\n } catch (error) {\n throw new ProviderError(\n `Failed to write file: ${error instanceof Error ? error.message : String(error)}`,\n this.provider,\n error instanceof Error ? error : undefined,\n this.sandboxId\n );\n }\n }\n\n async mkdir(path: string): Promise<void> {\n try {\n await this.doMkdir(path);\n } catch (error) {\n throw new ProviderError(\n `Failed to create directory: ${error instanceof Error ? error.message : String(error)}`,\n this.provider,\n error instanceof Error ? error : undefined,\n this.sandboxId\n );\n }\n }\n\n async readdir(path: string): Promise<import('../types').FileEntry[]> {\n try {\n return await this.doReaddir(path);\n } catch (error) {\n throw new ProviderError(\n `Failed to read directory: ${error instanceof Error ? error.message : String(error)}`,\n this.provider,\n error instanceof Error ? error : undefined,\n this.sandboxId\n );\n }\n }\n\n async exists(path: string): Promise<boolean> {\n try {\n return await this.doExists(path);\n } catch (error) {\n return false;\n }\n }\n\n async remove(path: string): Promise<void> {\n try {\n await this.doRemove(path);\n } catch (error) {\n throw new ProviderError(\n `Failed to remove: ${error instanceof Error ? error.message : String(error)}`,\n this.provider,\n error instanceof Error ? error : undefined,\n this.sandboxId\n );\n }\n }\n\n protected abstract doReadFile(path: string): Promise<string>;\n protected abstract doWriteFile(path: string, content: string): Promise<void>;\n protected abstract doMkdir(path: string): Promise<void>;\n protected abstract doReaddir(path: string): Promise<import('../types').FileEntry[]>;\n protected abstract doExists(path: string): Promise<boolean>;\n protected abstract doRemove(path: string): Promise<void>;\n}\n\n/**\n * Helper class for implementing Terminal with error handling\n */\nexport abstract class BaseTerminal implements SandboxTerminal {\n constructor(\n protected provider: string,\n protected sandboxId: string\n ) {}\n\n async create(options?: import('../types').TerminalCreateOptions): Promise<import('../types').InteractiveTerminalSession> {\n try {\n return await this.doCreate(options);\n } catch (error) {\n throw new ProviderError(\n `Failed to create terminal: ${error instanceof Error ? error.message : String(error)}`,\n this.provider,\n error instanceof Error ? error : undefined,\n this.sandboxId\n );\n }\n }\n\n async list(): Promise<import('../types').InteractiveTerminalSession[]> {\n try {\n return await this.doList();\n } catch (error) {\n throw new ProviderError(\n `Failed to list terminals: ${error instanceof Error ? error.message : String(error)}`,\n this.provider,\n error instanceof Error ? error : undefined,\n this.sandboxId\n );\n }\n }\n\n protected abstract doCreate(options?: import('../types').TerminalCreateOptions): Promise<import('../types').InteractiveTerminalSession>;\n protected abstract doList(): Promise<import('../types').InteractiveTerminalSession[]>;\n}\n","import type { \n SandboxConfig, \n ComputeSandbox, \n ProviderType,\n Runtime,\n ContainerConfig\n} from './types';\nimport { \n ConfigurationError, \n AuthenticationError \n} from './errors';\nimport { \n normalizeSandboxConfig, \n detectAvailableProviders \n} from './config';\n\nexport class ComputeSDK {\n /**\n * Create a new sandbox with the specified configuration\n * \n * @param config Optional sandbox configuration\n * @returns Configured sandbox instance\n */\n static createSandbox(config?: Partial<SandboxConfig>): ComputeSandbox {\n const normalizedConfig = normalizeSandboxConfig(config);\n \n // Try to dynamically load the provider\n const providerName = normalizedConfig.provider;\n \n try {\n // Attempt to load provider package\n const providerPackage = `@computesdk/${providerName}`;\n const provider = require(providerPackage);\n \n // Get the factory function\n const factory = provider[providerName!];\n if (!factory) {\n throw new ConfigurationError(\n `Provider package ${providerPackage} does not export a '${providerName}' function`,\n 'sdk'\n );\n }\n \n // Create the sandbox using the factory\n return factory(normalizedConfig);\n } catch (error) {\n if (error instanceof ConfigurationError) {\n throw error;\n }\n \n // Check if it's a missing package error\n if ((error as any).code === 'MODULE_NOT_FOUND') {\n throw new ConfigurationError(\n `Provider '${providerName}' not installed. Run: npm install @computesdk/${providerName}`,\n 'sdk'\n );\n }\n \n throw new ConfigurationError(\n `Failed to load provider '${providerName}': ${(error as Error).message}`,\n 'sdk'\n );\n }\n }\n \n /**\n * Detect available providers based on environment variables\n * \n * @returns Array of available provider types\n */\n static detectProviders(): ProviderType[] {\n return detectAvailableProviders();\n }\n}","/**\n * ComputeSDK Core\n * \n * A unified abstraction layer for executing code in secure,\n * isolated sandboxed environments across multiple cloud providers.\n */\n\n// Export all types\nexport * from './types';\n\n// Export all errors\nexport * from './errors';\n\n// Export configuration utilities\nexport * from './config';\n\n// Export utilities\nexport { executeSandbox, runCode, runCommand, retry } from './utils';\n\n// Export registry\nexport { createComputeRegistry } from './registry';\n\n// Export base provider for extension\nexport { BaseProvider, BaseFileSystem, BaseTerminal } from './providers/base';\n\n// Export main SDK class\nexport { ComputeSDK } from './sdk';\n\n// Default export\nimport { ComputeSDK } from './sdk';\nexport default ComputeSDK;\n"],"mappings":";;;;;;;;AASO,IAAe,eAAf,cAAoC,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoB/C,YAAY,SAAiB,UAAkB,WAAoB;AACjE,UAAM,OAAO;AACb,SAAK,OAAO,KAAK,YAAY;AAC7B,SAAK,WAAW;AAChB,SAAK,YAAY;AAGjB,WAAO,eAAe,MAAM,WAAW,SAAS;AAAA,EAClD;AACF;AAKO,IAAM,iBAAN,cAA6B,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkB/C,YAAY,SAAiB,UAAkB,UAAkB,WAAoB;AACnF,UAAM,SAAS,UAAU,SAAS;AAjBpC;AAAA,SAAS,OAAO;AAGhB;AAAA,SAAS,cAAc;AAerB,SAAK,WAAW;AAAA,EAClB;AACF;AAKO,IAAM,eAAN,cAA2B,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkB7C,YAAY,SAAiB,UAAkB,WAAmB,WAAoB;AACpF,UAAM,SAAS,UAAU,SAAS;AAjBpC;AAAA,SAAS,OAAO;AAGhB;AAAA,SAAS,cAAc;AAerB,SAAK,YAAY;AAAA,EACnB;AACF;AAKO,IAAM,gBAAN,cAA4B,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkB9C,YAAY,SAAiB,UAAkB,eAAuB,WAAoB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mBAAmB,uBAAuB,MAAM;AAGtD,UAAM,eAAe,iBAAiB;AAEtC,QAAI;AAEF,YAAM,kBAAkB,eAAe,YAAY;AACnD,YAAM,WAAW,UAAQ,eAAe;AAGxC,YAAM,UAAU,SAAS,YAAa;AACtC,UAAI,CAAC,SAAS;AACZ,cAAM,IAAI;AAAA,UACR,oBAAoB,eAAe,uBAAuB,YAAY;AAAA,UACtE;AAAA,QACF;AAAA,MACF;AAGA,aAAO,QAAQ,gBAAgB;AAAA,IACjC,SAAS,OAAO;AACd,UAAI,iBAAiB,oBAAoB;AACvC,cAAM;AAAA,MACR;AAGA,UAAK,MAAc,SAAS,oBAAoB;AAC9C,cAAM,IAAI;AAAA,UACR,aAAa,YAAY,iDAAiD,YAAY;AAAA,UACtF;AAAA,QACF;AAAA,MACF;AAEA,YAAM,IAAI;AAAA,QACR,4BAA4B,YAAY,MAAO,MAAgB,OAAO;AAAA,QACtE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,kBAAkC;AACvC,WAAO,yBAAyB;AAAA,EAClC;AACF;;;AC3CA,IAAO,gBAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "computesdk",
3
- "version": "1.0.2",
3
+ "version": "2.0.0",
4
4
  "description": "Unified abstraction layer for executing code in secure, isolated sandboxed environments across multiple cloud providers",
5
5
  "author": "Garrison",
6
6
  "license": "MIT",
@@ -18,16 +18,6 @@
18
18
  "dist",
19
19
  "README.md"
20
20
  ],
21
- "scripts": {
22
- "build": "tsup",
23
- "clean": "rimraf dist",
24
- "dev": "tsup --watch",
25
- "test": "vitest",
26
- "test:watch": "vitest watch",
27
- "test:coverage": "vitest run --coverage",
28
- "typecheck": "tsc --noEmit",
29
- "lint": "eslint ."
30
- },
31
21
  "keywords": [
32
22
  "sandbox",
33
23
  "code-execution",
@@ -51,26 +41,6 @@
51
41
  "zod": "^3.22.0",
52
42
  "uuid": "^9.0.0"
53
43
  },
54
- "peerDependencies": {
55
- "@computesdk/e2b": "workspace:*",
56
- "@computesdk/vercel": "workspace:*",
57
- "@computesdk/cloudflare": "workspace:*",
58
- "@computesdk/fly": "workspace:*"
59
- },
60
- "peerDependenciesMeta": {
61
- "@computesdk/e2b": {
62
- "optional": true
63
- },
64
- "@computesdk/vercel": {
65
- "optional": true
66
- },
67
- "@computesdk/cloudflare": {
68
- "optional": true
69
- },
70
- "@computesdk/fly": {
71
- "optional": true
72
- }
73
- },
74
44
  "devDependencies": {
75
45
  "@types/node": "^20.0.0",
76
46
  "@types/uuid": "^9.0.0",
@@ -80,5 +50,15 @@
80
50
  "tsup": "^8.0.0",
81
51
  "typescript": "^5.0.0",
82
52
  "vitest": "^1.0.0"
53
+ },
54
+ "scripts": {
55
+ "build": "tsup",
56
+ "clean": "rimraf dist",
57
+ "dev": "tsup --watch",
58
+ "test": "vitest run",
59
+ "test:watch": "vitest watch",
60
+ "test:coverage": "vitest run --coverage",
61
+ "typecheck": "tsc --noEmit",
62
+ "lint": "eslint"
83
63
  }
84
64
  }