computesdk 1.8.5 → 1.8.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.js CHANGED
@@ -57,7 +57,8 @@ async function authorizeApiKey(apiKey) {
57
57
  })
58
58
  });
59
59
  if (!response.ok) {
60
- throw new Error(`License authorization failed: ${response.statusText}`);
60
+ const errorText = await response.text().catch(() => response.statusText);
61
+ throw new Error(`License authorization failed (${response.status}): ${errorText}`);
61
62
  }
62
63
  const data = await response.json();
63
64
  if (!data.access_token) {
@@ -75,44 +76,110 @@ async function authorizeApiKey(apiKey) {
75
76
  preview_url: data.preview_url
76
77
  };
77
78
  } catch (error) {
78
- throw new Error(`Failed to authorize API key: ${error}`);
79
+ if (error instanceof Error && error.message.includes("License authorization failed")) {
80
+ throw error;
81
+ }
82
+ throw new Error(`Failed to authorize API key (network error): ${error instanceof Error ? error.message : String(error)}`);
83
+ }
84
+ }
85
+ async function isCommandAvailable(sandbox, command) {
86
+ const result = await sandbox.runCommand("sh", ["-c", `command -v ${command}`]);
87
+ return result.exitCode === 0;
88
+ }
89
+ async function detectPackageManager(sandbox) {
90
+ if (await isCommandAvailable(sandbox, "apk")) {
91
+ return "apk";
92
+ }
93
+ if (await isCommandAvailable(sandbox, "apt-get")) {
94
+ return "apt";
95
+ }
96
+ return null;
97
+ }
98
+ async function ensureDependencies(sandbox) {
99
+ const hasCurl = await isCommandAvailable(sandbox, "curl");
100
+ const hasBash = await isCommandAvailable(sandbox, "bash");
101
+ if (hasCurl && hasBash) {
102
+ return;
103
+ }
104
+ const packageManager = await detectPackageManager(sandbox);
105
+ if (!packageManager) {
106
+ throw new Error(
107
+ `Missing required tools (curl: ${hasCurl}, bash: ${hasBash}), but no supported package manager found.
108
+ Supported package managers: apk (Alpine), apt-get (Debian/Ubuntu).
109
+ Please use a sandbox image that includes curl and bash, or install them manually first.`
110
+ );
111
+ }
112
+ let installResult;
113
+ if (packageManager === "apk") {
114
+ installResult = await sandbox.runCommand("sh", ["-c", "apk add --no-cache curl bash 2>&1"]);
115
+ } else {
116
+ installResult = await sandbox.runCommand("sh", ["-c", "apt-get update -qq && apt-get install -qq -y curl bash 2>&1"]);
117
+ }
118
+ if (installResult.exitCode !== 0) {
119
+ throw new Error(
120
+ `Failed to install curl and bash using ${packageManager}.
121
+ Install output: ${installResult.stderr || installResult.stdout}
122
+ Please install curl and bash manually or use a different sandbox image.`
123
+ );
124
+ }
125
+ }
126
+ async function isComputeInstalled(sandbox) {
127
+ const result = await sandbox.runCommand("sh", ["-c", 'test -f /usr/local/bin/compute && echo "exists" || echo "missing"']);
128
+ return result.stdout?.trim() === "exists";
129
+ }
130
+ async function downloadInstallScript(sandbox) {
131
+ const downloadResult = await sandbox.runCommand("sh", ["-c", "curl -fsSL https://computesdk.com/install.sh -o /tmp/compute-install.sh 2>&1"]);
132
+ if (downloadResult.exitCode !== 0) {
133
+ const errorOutput = downloadResult.stderr || downloadResult.stdout || "unknown error";
134
+ throw new Error(
135
+ `Failed to download install script from https://computesdk.com/install.sh: ${errorOutput}`
136
+ );
137
+ }
138
+ }
139
+ async function runInstallScript(sandbox, accessToken) {
140
+ const installCommand = accessToken ? `bash /tmp/compute-install.sh --non-interactive --access-token "${accessToken}" --location /usr/local/bin` : `bash /tmp/compute-install.sh --non-interactive --location /usr/local/bin`;
141
+ const installResult = await sandbox.runCommand("bash", ["-c", installCommand]);
142
+ if (installResult.exitCode !== 0) {
143
+ const errorOutput = installResult.stderr || installResult.stdout || "unknown error";
144
+ throw new Error(`Failed to install compute CLI: ${errorOutput}`);
79
145
  }
80
146
  }
81
147
  async function installComputeInSandbox(sandbox, config) {
82
- try {
83
- console.log("Installing and starting compute CLI in sandbox...");
84
- let authResponse = null;
85
- let accessToken = config?.accessToken;
86
- if (config?.apiKey && !accessToken) {
87
- console.log("Authorizing API key and getting access token...");
88
- authResponse = await authorizeApiKey(config.apiKey);
89
- accessToken = authResponse.access_token;
90
- }
91
- let installCommand = "curl -fsSL https://computesdk.com/install.sh | sh";
92
- if (accessToken) {
93
- installCommand = `curl -fsSL https://computesdk.com/install.sh | sh -s -- --access-token ${accessToken}`;
94
- }
95
- const result = await sandbox.runCommand("sh", ["-c", installCommand]);
96
- if (result.exitCode !== 0) {
97
- throw new Error(`Failed to install and start compute CLI: ${result.stderr}`);
98
- }
99
- console.log("Compute CLI installed successfully");
148
+ let authResponse = null;
149
+ let accessToken = config?.accessToken;
150
+ if (config?.apiKey && !accessToken) {
151
+ authResponse = await authorizeApiKey(config.apiKey);
152
+ accessToken = authResponse.access_token;
153
+ }
154
+ if (await isComputeInstalled(sandbox)) {
100
155
  return authResponse;
101
- } catch (error) {
102
- throw new Error(`Failed to install compute CLI in sandbox: ${error}`);
103
156
  }
157
+ await ensureDependencies(sandbox);
158
+ await downloadInstallScript(sandbox);
159
+ await runInstallScript(sandbox, accessToken);
160
+ if (!await isComputeInstalled(sandbox)) {
161
+ throw new Error("Compute binary not found at /usr/local/bin/compute after installation");
162
+ }
163
+ return authResponse;
104
164
  }
105
- async function waitForComputeReady(client, maxRetries = 10, delayMs = 1e3) {
165
+ async function waitForComputeReady(client, maxRetries = 30, delayMs = 2e3) {
166
+ let lastError = null;
106
167
  for (let i = 0; i < maxRetries; i++) {
107
168
  try {
108
169
  await client.health();
109
- console.log("Compute CLI is ready");
110
170
  return;
111
171
  } catch (error) {
172
+ lastError = error instanceof Error ? error : new Error(String(error));
112
173
  if (i === maxRetries - 1) {
113
- throw new Error(`Compute CLI failed to start after ${maxRetries} attempts: ${error}`);
174
+ throw new Error(
175
+ `Compute CLI failed to start after ${maxRetries} attempts (${maxRetries * delayMs / 1e3}s).
176
+ Last error: ${lastError.message}
177
+ This could indicate:
178
+ 1. The compute daemon failed to start in the sandbox
179
+ 2. The sandbox_url is incorrect or unreachable
180
+ 3. The sandbox is taking longer than expected to initialize`
181
+ );
114
182
  }
115
- console.log(`Waiting for compute CLI to start... (attempt ${i + 1}/${maxRetries})`);
116
183
  await new Promise((resolve) => setTimeout(resolve, delayMs));
117
184
  }
118
185
  }
@@ -145,9 +212,13 @@ var ComputeManager = class {
145
212
  const provider = params && "provider" in params && params.provider ? params.provider : this.getDefaultProvider();
146
213
  const options = params?.options;
147
214
  const sandbox = await provider.sandbox.create(options);
148
- const authResponse = await installComputeInSandbox(sandbox, this.computeAuth);
149
- const finalSandbox = authResponse ? await this.wrapWithComputeClient(sandbox, authResponse) : sandbox;
150
- return finalSandbox;
215
+ if (this.computeAuth.apiKey || this.computeAuth.accessToken) {
216
+ const authResponse = await installComputeInSandbox(sandbox, this.computeAuth);
217
+ if (authResponse) {
218
+ return await this.wrapWithComputeClient(sandbox, authResponse);
219
+ }
220
+ }
221
+ return sandbox;
151
222
  },
152
223
  /**
153
224
  * Get an existing sandbox by ID from a provider (or default provider if configured)
@@ -242,7 +313,8 @@ var ComputeManager = class {
242
313
  sandboxUrl: authResponse.sandbox_url,
243
314
  sandboxId: originalSandbox.sandboxId,
244
315
  provider: originalSandbox.provider,
245
- token: authResponse.access_token
316
+ token: authResponse.access_token,
317
+ WebSocket: globalThis.WebSocket
246
318
  });
247
319
  await waitForComputeReady(client);
248
320
  const wrappedSandbox = Object.assign(client, {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/types/sandbox.ts","../src/compute.ts","../src/request-handler.ts","../src/factory.ts"],"sourcesContent":["/**\n * ComputeSDK Core\n * \n * Clean Provider/Sandbox separation architecture with extensible compute.* API\n */\n\n// Export all types\nexport * from './types';\n\n// Export compute singleton - the main API\nexport { compute, createCompute } from './compute';\n\n// Export request handler for web framework integration\nexport { handleComputeRequest } from './request-handler';\n\n// Export compute request/response types\nexport type {\n ComputeRequest,\n ComputeResponse,\n HandleComputeRequestParams\n} from './request-handler';\n\n\n\n// Export provider factory for creating custom providers\nexport { createProvider, createBackgroundCommand } from './factory';\nexport type { ProviderConfig, SandboxMethods, TemplateMethods, SnapshotMethods } from './factory';\n\n// Export error handling utilities (explicitly for clarity)\nexport { CommandExitError, isCommandExitError } from './types/sandbox';\n\n// Test suite is available separately via @computesdk/test-utils package\n","/**\n * Sandbox Types\n * \n * Types related to sandbox execution, filesystem, terminal operations\n */\n\n// Forward declaration to avoid circular dependency\ninterface Provider {\n readonly name: string;\n readonly sandbox: any; // Will be properly typed when imported together\n}\n\n/**\n * Type mapping for provider names to their sandbox types\n * Manually defined for known providers since declaration merging isn't working reliably\n */\nexport interface ProviderSandboxTypeMap {\n e2b: any; // We can't import the E2B type directly, but we'll handle it differently\n vercel: any;\n daytona: any;\n}\n\n/**\n * Utility type to extract the native instance type from a provider\n * Uses provider name and manual type inference\n */\nexport type ExtractSandboxInstanceType<TProvider extends Provider> = \n TProvider extends { readonly name: 'e2b' }\n ? any // For now, let's just try to make the runtime casting work\n : TProvider extends { readonly name: 'vercel' }\n ? any\n : TProvider extends { readonly name: 'daytona' }\n ? any\n : any;\n\n/**\n * Supported runtime environments\n */\nexport type Runtime = 'node' | 'python';\n\n/**\n * Sandbox status types\n */\nexport type SandboxStatus = 'running' | 'stopped' | 'error';\n\n/**\n * Options for running commands\n */\nexport interface RunCommandOptions {\n /** Run command in background (non-blocking) */\n background?: boolean;\n}\n\n/**\n * Result of code execution\n */\nexport interface ExecutionResult {\n /** Standard output from the execution */\n stdout: string;\n /** Standard error from the execution */\n stderr: string;\n /** Exit code from the execution */\n exitCode: number;\n /** Time taken for execution in milliseconds */\n executionTime: number;\n /** ID of the sandbox where the code was executed */\n sandboxId: string;\n /** Provider that executed the code */\n provider: string;\n /** Process ID for background jobs (if applicable) */\n pid?: number;\n /** Whether this command is running in background */\n isBackground?: boolean;\n}\n\n/**\n * Information about a sandbox\n */\nexport interface SandboxInfo {\n /** Unique identifier for the sandbox */\n id: string;\n /** Provider hosting the sandbox */\n provider: string;\n /** Runtime environment in the sandbox */\n runtime: Runtime;\n /** Current status of the sandbox */\n status: SandboxStatus;\n /** When the sandbox was created */\n createdAt: Date;\n /** Execution timeout in milliseconds */\n timeout: number;\n /** Additional provider-specific metadata */\n metadata?: Record<string, any>;\n}\n\n/**\n * Options for creating a sandbox\n */\nexport interface CreateSandboxOptions {\n /** Runtime environment (defaults to 'node' if not specified) */\n runtime?: Runtime;\n /** Execution timeout in milliseconds */\n timeout?: number;\n /** Custom sandbox ID (if supported by provider) */\n sandboxId?: string;\n /** Template ID for sandbox creation (provider-specific) */\n templateId?: string;\n /** Additional metadata for the sandbox */\n metadata?: Record<string, any>;\n /** Domain for sandbox connection (provider-specific) */\n domain?: string;\n /** Environment variables for the sandbox */\n envs?: Record<string, string>;\n}\n\n/**\n * File system entry information\n */\nexport interface FileEntry {\n /** File/directory name */\n name: string;\n /** Full path to the entry */\n path: string;\n /** Whether this is a directory */\n isDirectory: boolean;\n /** File size in bytes (0 for directories) */\n size: number;\n /** Last modified timestamp */\n lastModified: Date;\n}\n\n/**\n * File system interface for sandbox operations\n */\nexport interface SandboxFileSystem {\n /** Read file contents */\n readFile(path: string): Promise<string>;\n /** Write file contents */\n writeFile(path: string, content: string): Promise<void>;\n /** Create directory */\n mkdir(path: string): Promise<void>;\n /** List directory contents */\n readdir(path: string): Promise<FileEntry[]>;\n /** Check if file/directory exists */\n exists(path: string): Promise<boolean>;\n /** Remove file or directory */\n remove(path: string): Promise<void>;\n}\n\n/**\n * Error thrown when a command exits with a non-zero status\n */\nexport class CommandExitError extends Error {\n name = 'CommandExitError';\n constructor(public result: {\n exitCode: number;\n stdout: string;\n stderr: string;\n error: boolean;\n }) {\n super(`Command exited with code ${result.exitCode}`);\n }\n}\n\n/**\n * Type guard to check if an error is a CommandExitError\n */\nexport function isCommandExitError(error: unknown): error is CommandExitError {\n return (\n typeof error === 'object' &&\n error !== null &&\n 'name' in error &&\n error.name === 'CommandExitError' &&\n 'result' in error\n );\n}\n\n\n\n\n\n/**\n * Base sandbox interface - what developers interact with\n */\nexport interface Sandbox<TSandbox = any> {\n /** Unique identifier for the sandbox */\n readonly sandboxId: string;\n /** Provider that created this sandbox */\n readonly provider: string;\n\n /** Execute code in the sandbox */\n runCode(code: string, runtime?: Runtime): Promise<ExecutionResult>;\n /** Execute shell commands */\n runCommand(command: string, args?: string[], options?: RunCommandOptions): Promise<ExecutionResult>;\n /** Get information about the sandbox */\n getInfo(): Promise<SandboxInfo>;\n /** Get URL for accessing the sandbox on a specific port */\n getUrl(options: { port: number; protocol?: string }): Promise<string>;\n /** Get the provider instance that created this sandbox */\n getProvider(): import('./provider').Provider<TSandbox>;\n /** Get the native provider sandbox instance with proper typing */\n getInstance(): TSandbox;\n /** Kill the sandbox */\n kill(): Promise<void>;\n /** Destroy the sandbox and clean up resources */\n destroy(): Promise<void>;\n\n /** File system operations */\n readonly filesystem: SandboxFileSystem;\n}\n\n/**\n * Extract the sandbox type from a provider\n */\ntype ExtractProviderSandboxType<TProvider extends Provider> = TProvider extends { readonly __sandboxType: infer TSandbox } ? TSandbox : any;\n\n/**\n * Typed sandbox interface that preserves the provider's native instance type\n */\nexport interface TypedSandbox<TProvider extends Provider> extends Omit<Sandbox<ExtractProviderSandboxType<TProvider>>, 'getProvider'> {\n /** Get the provider instance that created this sandbox with proper typing */\n getProvider(): TProvider;\n /** Get the native provider sandbox instance with proper typing */\n getInstance(): ExtractProviderSandboxType<TProvider>;\n}\n\n/**\n * Enhanced sandbox type that includes ComputeClient features\n *\n * When a sandbox is created with an API key/JWT, it gets wrapped with ComputeClient\n * which adds powerful features like WebSocket terminals, file watchers, and signals.\n *\n * @example\n * ```typescript\n * const sandbox = await compute.sandbox.create();\n *\n * // ComputeClient features (only available when API key is configured)\n * const terminal = await sandbox.createTerminal();\n * const watcher = await sandbox.createWatcher('/home/project');\n * const signals = await sandbox.startSignals();\n *\n * // Original sandbox features still work\n * await sandbox.runCommand('ls');\n * const instance = sandbox.getInstance();\n * ```\n */\nexport type ComputeEnhancedSandbox<TSandbox = any> = Sandbox<TSandbox> & {\n /** The original provider sandbox instance */\n __originalSandbox: Sandbox<TSandbox>;\n\n // ComputeClient enhanced features\n /** Create a persistent terminal session with WebSocket integration */\n createTerminal(shell?: string, encoding?: 'raw' | 'base64'): Promise<import('@computesdk/client').Terminal>;\n /** Create a file watcher with real-time change notifications */\n createWatcher(path: string, options?: {\n includeContent?: boolean;\n ignored?: string[];\n encoding?: 'raw' | 'base64';\n }): Promise<import('@computesdk/client').FileWatcher>;\n /** Start the signal service for port and error monitoring */\n startSignals(): Promise<import('@computesdk/client').SignalService>;\n /** Execute a one-off command without creating a persistent terminal */\n execute(options: { command: string; shell?: string }): Promise<any>;\n /** List all active terminals */\n listTerminals(): Promise<any[]>;\n /** Get terminal by ID */\n getTerminal(id: string): Promise<any>;\n /** List all active file watchers */\n listWatchers(): Promise<any>;\n /** Get file watcher by ID */\n getWatcher(id: string): Promise<any>;\n /** Get signal service status */\n getSignalStatus(): Promise<any>;\n /** Create a session token (requires access token) */\n createSessionToken(options?: { description?: string; expiresIn?: number }): Promise<any>;\n /** List all session tokens (requires access token) */\n listSessionTokens(): Promise<any>;\n /** Get session token details (requires access token) */\n getSessionToken(tokenId: string): Promise<any>;\n /** Revoke a session token (requires access token) */\n revokeSessionToken(tokenId: string): Promise<void>;\n /** Create a magic link for browser authentication (requires access token) */\n createMagicLink(options?: { redirectUrl?: string }): Promise<any>;\n /** Check authentication status */\n getAuthStatus(): Promise<any>;\n /** Get authentication information */\n getAuthInfo(): Promise<any>;\n /** Set authentication token manually */\n setToken(token: string): void;\n /** Get current authentication token */\n getToken(): string | null;\n /** Get current sandbox URL */\n getSandboxUrl(): string;\n /** Disconnect WebSocket connection */\n disconnect(): Promise<void>;\n}\n\n/**\n * Typed enhanced sandbox that preserves both provider typing and ComputeClient features\n */\nexport type TypedEnhancedSandbox<TProvider extends Provider> =\n ComputeEnhancedSandbox<ExtractProviderSandboxType<TProvider>> &\n Omit<TypedSandbox<TProvider>, keyof Sandbox>;","/**\n * Compute Singleton - Main API Orchestrator\n *\n * Provides the unified compute.* API and delegates to specialized managers\n */\n\nimport { ComputeClient } from '@computesdk/client';\nimport type { ComputeAPI, CreateSandboxParams, CreateSandboxParamsWithOptionalProvider, ComputeConfig, Sandbox, Provider, TypedSandbox, TypedComputeAPI, ComputeEnhancedSandbox, TypedEnhancedSandbox } from './types';\n\n/**\n * Authorization response from license server\n */\ninterface AuthorizationResponse {\n access_token: string;\n sandbox_url: string;\n preview_url: string;\n}\n\n/**\n * Authorize license key and get JWT token + URLs from license server\n */\nasync function authorizeApiKey(apiKey: string): Promise<AuthorizationResponse> {\n try {\n const response = await fetch('https://preview.computesdk.com/__api/license/authorize', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n key: apiKey,\n increment_usage: 1\n })\n });\n\n if (!response.ok) {\n throw new Error(`License authorization failed: ${response.statusText}`);\n }\n\n const data = await response.json();\n\n if (!data.access_token) {\n throw new Error('No access token received from license server');\n }\n\n if (!data.sandbox_url) {\n throw new Error('No sandbox_url received from license server');\n }\n\n if (!data.preview_url) {\n throw new Error('No preview_url received from license server');\n }\n\n return {\n access_token: data.access_token,\n sandbox_url: data.sandbox_url,\n preview_url: data.preview_url\n };\n } catch (error) {\n throw new Error(`Failed to authorize API key: ${error}`);\n }\n}\n\n/**\n * Install and start compute CLI inside a sandbox\n */\nasync function installComputeInSandbox(\n sandbox: Sandbox,\n config?: { apiKey?: string; accessToken?: string }\n): Promise<AuthorizationResponse | null> {\n try {\n console.log('Installing and starting compute CLI in sandbox...');\n\n // Get access token and URLs from API key if provided\n let authResponse: AuthorizationResponse | null = null;\n let accessToken = config?.accessToken;\n\n if (config?.apiKey && !accessToken) {\n console.log('Authorizing API key and getting access token...');\n authResponse = await authorizeApiKey(config.apiKey);\n accessToken = authResponse.access_token;\n }\n\n // Build install command with authentication\n let installCommand = 'curl -fsSL https://computesdk.com/install.sh | sh';\n\n if (accessToken) {\n installCommand = `curl -fsSL https://computesdk.com/install.sh | sh -s -- --access-token ${accessToken}`;\n }\n\n // Run the install script (it will handle installation and starting compute)\n const result = await sandbox.runCommand('sh', ['-c', installCommand]);\n\n if (result.exitCode !== 0) {\n throw new Error(`Failed to install and start compute CLI: ${result.stderr}`);\n }\n\n console.log('Compute CLI installed successfully');\n\n return authResponse;\n } catch (error) {\n throw new Error(`Failed to install compute CLI in sandbox: ${error}`);\n }\n}\n\n/**\n * Wait for compute CLI to be ready by polling the health endpoint\n */\nasync function waitForComputeReady(client: ComputeClient, maxRetries = 10, delayMs = 1000): Promise<void> {\n for (let i = 0; i < maxRetries; i++) {\n try {\n await client.health();\n console.log('Compute CLI is ready');\n return;\n } catch (error) {\n if (i === maxRetries - 1) {\n throw new Error(`Compute CLI failed to start after ${maxRetries} attempts: ${error}`);\n }\n console.log(`Waiting for compute CLI to start... (attempt ${i + 1}/${maxRetries})`);\n await new Promise(resolve => setTimeout(resolve, delayMs));\n }\n }\n}\n\n/**\n * Compute singleton implementation - orchestrates all compute operations\n */\nclass ComputeManager implements ComputeAPI {\n private config: ComputeConfig | null = null;\n private computeAuth: { apiKey?: string; accessToken?: string } = {};\n\n /**\n * Set default configuration with generic type preservation\n */\n setConfig<TProvider extends Provider>(config: ComputeConfig<TProvider>): void {\n // Validate that at least one provider is specified\n if (!config.defaultProvider && !config.provider) {\n throw new Error('Either defaultProvider or provider must be specified in setConfig');\n }\n\n // Handle backwards compatibility: if both are provided, defaultProvider takes precedence\n if (config.defaultProvider && config.provider) {\n console.warn('Both defaultProvider and provider specified in setConfig. Using defaultProvider. The provider key is deprecated, please use defaultProvider instead.');\n }\n\n // Normalize config to always have both fields for internal use (backward compatibility)\n const actualProvider = config.defaultProvider || config.provider!;\n const accessToken = config.accessToken || config.jwt; // Support both accessToken and deprecated jwt\n this.config = {\n provider: actualProvider,\n defaultProvider: actualProvider,\n apiKey: config.apiKey,\n accessToken: accessToken\n };\n\n // Store compute auth credentials\n this.computeAuth = {\n apiKey: config.apiKey,\n accessToken: accessToken\n };\n }\n\n /**\n * Get current configuration\n */\n getConfig(): ComputeConfig | null {\n return this.config;\n }\n\n /**\n * Clear current configuration\n */\n clearConfig(): void {\n this.config = null;\n }\n\n /**\n * Get the default provider, throwing if not configured\n */\n private getDefaultProvider(): Provider {\n const provider = this.config?.defaultProvider || this.config?.provider;\n if (!provider) {\n throw new Error(\n 'No default provider configured. Either call compute.setConfig({ defaultProvider }) or pass provider explicitly.'\n );\n }\n return provider;\n }\n\n /**\n * Wrap a provider sandbox with ComputeClient while preserving the original sandbox\n * This adds powerful features like WebSocket terminals, file watchers, and signals\n */\n private async wrapWithComputeClient(originalSandbox: Sandbox, authResponse: AuthorizationResponse): Promise<ComputeEnhancedSandbox> {\n const client = new ComputeClient({\n sandboxUrl: authResponse.sandbox_url,\n sandboxId: originalSandbox.sandboxId,\n provider: originalSandbox.provider,\n token: authResponse.access_token\n });\n\n // Wait for compute CLI to be ready before returning\n await waitForComputeReady(client);\n\n // Store the original sandbox for getInstance() and getProvider() calls\n // We create a proxy-like object that delegates most calls to ComputeClient\n // but preserves access to the original provider sandbox\n const wrappedSandbox = Object.assign(client, {\n __originalSandbox: originalSandbox,\n\n // Override getInstance to return the original provider's instance\n getInstance: () => originalSandbox.getInstance(),\n\n // Override getProvider to return the original provider\n getProvider: () => originalSandbox.getProvider()\n });\n\n return wrappedSandbox as ComputeEnhancedSandbox;\n }\n\n sandbox = {\n /**\n * Create a sandbox from a provider (or default provider if configured)\n * \n * @example\n * ```typescript\n * import { e2b } from '@computesdk/e2b'\n * import { compute } from 'computesdk'\n * \n * // With explicit provider\n * const sandbox = await compute.sandbox.create({\n * provider: e2b({ apiKey: 'your-key' })\n * })\n * \n * // With default provider (both forms work)\n * compute.setConfig({ defaultProvider: e2b({ apiKey: 'your-key' }) })\n * const sandbox1 = await compute.sandbox.create({})\n * const sandbox2 = await compute.sandbox.create()\n * ```\n */\n create: async (params?: CreateSandboxParams | CreateSandboxParamsWithOptionalProvider): Promise<Sandbox | ComputeEnhancedSandbox> => {\n const provider = params && 'provider' in params && params.provider ? params.provider : this.getDefaultProvider();\n const options = params?.options;\n const sandbox = await provider.sandbox.create(options);\n\n // Install compute CLI in the sandbox with auth credentials if available\n const authResponse = await installComputeInSandbox(sandbox, this.computeAuth);\n\n // Wrap with ComputeClient if we have authorization info\n // This adds features like createTerminal(), createWatcher(), startSignals()\n const finalSandbox = authResponse\n ? await this.wrapWithComputeClient(sandbox, authResponse)\n : sandbox;\n\n return finalSandbox;\n },\n\n /**\n * Get an existing sandbox by ID from a provider (or default provider if configured)\n */\n getById: async (providerOrSandboxId: Provider | string, sandboxId?: string): Promise<Sandbox | null> => {\n if (typeof providerOrSandboxId === 'string') {\n // Called with just sandboxId, use default provider\n const provider = this.getDefaultProvider();\n return await provider.sandbox.getById(providerOrSandboxId);\n } else {\n // Called with provider and sandboxId\n if (!sandboxId) {\n throw new Error('sandboxId is required when provider is specified');\n }\n return await providerOrSandboxId.sandbox.getById(sandboxId);\n }\n },\n\n /**\n * List all active sandboxes from a provider (or default provider if configured)\n */\n list: async (provider?: Provider): Promise<Sandbox[]> => {\n const actualProvider = provider || this.getDefaultProvider();\n return await actualProvider.sandbox.list();\n },\n\n /**\n * Destroy a sandbox via a provider (or default provider if configured)\n */\n destroy: async (providerOrSandboxId: Provider | string, sandboxId?: string): Promise<void> => {\n if (typeof providerOrSandboxId === 'string') {\n // Called with just sandboxId, use default provider\n const provider = this.getDefaultProvider();\n return await provider.sandbox.destroy(providerOrSandboxId);\n } else {\n // Called with provider and sandboxId\n if (!sandboxId) {\n throw new Error('sandboxId is required when provider is specified');\n }\n return await providerOrSandboxId.sandbox.destroy(sandboxId);\n }\n }\n };\n\n // Future: compute.blob.*, compute.database.*, compute.git.* will be added here\n // blob = new BlobManager();\n // database = new DatabaseManager(); \n // git = new GitManager();\n\n\n}\n\n/**\n * Singleton instance - the main API (untyped)\n */\nexport const compute: ComputeAPI = new ComputeManager();\n\n\n\n/**\n * Create a compute instance with proper typing\n *\n * @example\n * ```typescript\n * import { e2b } from '@computesdk/e2b'\n * import { createCompute } from 'computesdk'\n *\n * // With API key (automatically gets access token from license server)\n * const compute = createCompute({\n * defaultProvider: e2b({ apiKey: 'your-key' }),\n * apiKey: 'computesdk_live_...' // Returns enhanced sandboxes\n * });\n *\n * // Or with direct access token\n * const compute2 = createCompute({\n * defaultProvider: e2b({ apiKey: 'your-key' }),\n * accessToken: 'your-access-token' // Returns enhanced sandboxes\n * });\n *\n * const sandbox = await compute.sandbox.create();\n * const instance = sandbox.getInstance(); // ✅ Properly typed E2B Sandbox!\n * await sandbox.createTerminal(); // ✅ Enhanced sandbox features!\n * ```\n */\nexport function createCompute<TProvider extends Provider>(\n config: ComputeConfig<TProvider> & { apiKey: string }\n): TypedComputeAPI<TProvider, true>;\nexport function createCompute<TProvider extends Provider>(\n config: ComputeConfig<TProvider> & { accessToken: string }\n): TypedComputeAPI<TProvider, true>;\nexport function createCompute<TProvider extends Provider>(\n config: ComputeConfig<TProvider> & { jwt: string }\n): TypedComputeAPI<TProvider, true>;\nexport function createCompute<TProvider extends Provider>(\n config: ComputeConfig<TProvider>\n): TypedComputeAPI<TProvider, false>;\nexport function createCompute<TProvider extends Provider>(\n config: ComputeConfig<TProvider>\n): TypedComputeAPI<TProvider, boolean> {\n const manager = new ComputeManager();\n\n // Set config directly without calling the public setConfig method\n const actualProvider = config.defaultProvider || config.provider!;\n const accessToken = config.accessToken || config.jwt; // Support both accessToken and deprecated jwt\n manager['config'] = {\n provider: actualProvider,\n defaultProvider: actualProvider,\n apiKey: config.apiKey,\n accessToken: accessToken\n };\n manager['computeAuth'] = {\n apiKey: config.apiKey,\n accessToken: accessToken\n };\n\n const isEnhanced = !!(config.apiKey || config.accessToken || config.jwt);\n\n return {\n setConfig: <T extends Provider>(cfg: ComputeConfig<T>) => createCompute(cfg),\n getConfig: () => manager.getConfig(),\n clearConfig: () => manager.clearConfig(),\n\n sandbox: {\n create: async (params?: Omit<CreateSandboxParamsWithOptionalProvider, 'provider'>) => {\n const sandbox = await manager.sandbox.create(params);\n // If API key/JWT is configured, the sandbox will be enhanced with ComputeClient features\n // Cast to the appropriate type based on whether it's enhanced or not\n if (isEnhanced) {\n return sandbox as TypedEnhancedSandbox<TProvider>;\n }\n return sandbox as TypedSandbox<TProvider>;\n },\n\n getById: async (sandboxId: string) => {\n const sandbox = await manager.sandbox.getById(sandboxId);\n if (!sandbox) return null;\n // Type depends on whether auth is configured\n if (isEnhanced) {\n return sandbox as TypedEnhancedSandbox<TProvider>;\n }\n return sandbox as TypedSandbox<TProvider>;\n },\n\n list: async () => {\n const sandboxes = await manager.sandbox.list();\n // Type depends on whether auth is configured\n if (isEnhanced) {\n return sandboxes as TypedEnhancedSandbox<TProvider>[];\n }\n return sandboxes as TypedSandbox<TProvider>[];\n },\n\n destroy: async (sandboxId: string) => {\n return await manager.sandbox.destroy(sandboxId);\n }\n }\n } as TypedComputeAPI<TProvider, typeof isEnhanced>;\n}\n\n\n\n","/**\n * Simplified Request Handler for Web Framework Integration\n * \n * Handles JSON requests for sandbox and code execution operations.\n * Terminal support removed - will be re-added with WebSocket VM connections.\n */\n\nimport type { Provider, Runtime } from './types';\nimport { compute } from './compute';\n\n/**\n * Request structure supporting sandbox and code execution capabilities\n */\nexport interface ComputeRequest {\n /** Action in dot notation (e.g., 'compute.sandbox.create') */\n action: string;\n \n /** Parameters for the action */\n sandboxId?: string;\n code?: string;\n command?: string;\n args?: string[];\n runtime?: Runtime;\n path?: string;\n content?: string;\n \n /** Command options (for runCommand action) */\n commandOptions?: {\n background?: boolean;\n };\n \n /** Sandbox creation options */\n options?: {\n runtime?: Runtime;\n timeout?: number;\n sandboxId?: string;\n };\n}\n\n/**\n * Response structure for compute operations\n */\nexport interface ComputeResponse {\n success: boolean;\n error?: string;\n sandboxId: string;\n provider: string;\n [key: string]: any; // Allow any additional response data\n}\n\n/**\n * Execute compute action using targeted handling\n */\nasync function executeAction(body: ComputeRequest, provider: Provider): Promise<ComputeResponse> {\n try {\n const { action, sandboxId } = body;\n \n // Sandbox management operations\n if (action === 'compute.sandbox.create') {\n const sandbox = await compute.sandbox.create({\n provider,\n options: body.options || { runtime: 'python' }\n });\n return {\n success: true,\n sandboxId: sandbox.sandboxId,\n provider: provider.name\n };\n }\n \n if (action === 'compute.sandbox.list') {\n const sandboxes = await compute.sandbox.list(provider);\n return {\n success: true,\n sandboxId: '',\n provider: provider.name,\n sandboxes: sandboxes.map(sb => ({\n sandboxId: sb.sandboxId,\n provider: sb.provider\n }))\n };\n }\n \n if (action === 'compute.sandbox.destroy') {\n if (!sandboxId) {\n throw new Error('sandboxId is required for destroy action');\n }\n await compute.sandbox.destroy(provider, sandboxId);\n return {\n success: true,\n sandboxId,\n provider: provider.name\n };\n }\n \n // For sandbox instance methods, get the sandbox first\n if (!sandboxId) {\n throw new Error('sandboxId is required for this action');\n }\n \n const sandbox = await compute.sandbox.getById(provider, sandboxId);\n if (!sandbox) {\n throw new Error(`Sandbox ${sandboxId} not found`);\n }\n \n // Sandbox info\n if (action === 'compute.sandbox.getInfo') {\n const result = await sandbox.getInfo();\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n info: {\n id: result.id,\n provider: result.provider,\n runtime: result.runtime,\n status: result.status,\n createdAt: result.createdAt.toISOString(),\n timeout: result.timeout,\n metadata: result.metadata\n }\n };\n }\n \n // Code execution\n if (action === 'compute.sandbox.runCode') {\n if (!body.code) throw new Error('code is required');\n const result = await sandbox.runCode(body.code, body.runtime);\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n result: {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n executionTime: result.executionTime\n }\n };\n }\n \n if (action === 'compute.sandbox.runCommand') {\n if (!body.command) throw new Error('command is required');\n const result = await sandbox.runCommand(body.command, body.args, body.commandOptions);\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n result: {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n executionTime: result.executionTime,\n ...(result.isBackground && { isBackground: result.isBackground }),\n ...(result.pid && { pid: result.pid })\n }\n };\n }\n \n // Filesystem operations\n if (action === 'compute.sandbox.filesystem.readFile') {\n if (!body.path) throw new Error('path is required');\n const result = await sandbox.filesystem.readFile(body.path);\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n fileContent: result\n };\n }\n \n if (action === 'compute.sandbox.filesystem.writeFile') {\n if (!body.path) throw new Error('path is required');\n if (body.content === undefined) throw new Error('content is required');\n await sandbox.filesystem.writeFile(body.path, body.content);\n return { success: true, sandboxId, provider: provider.name };\n }\n \n if (action === 'compute.sandbox.filesystem.mkdir') {\n if (!body.path) throw new Error('path is required');\n await sandbox.filesystem.mkdir(body.path);\n return { success: true, sandboxId, provider: provider.name };\n }\n \n if (action === 'compute.sandbox.filesystem.readdir') {\n if (!body.path) throw new Error('path is required');\n const result = await sandbox.filesystem.readdir(body.path);\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n files: result.map((entry: any) => ({\n name: entry.name,\n path: entry.path,\n isDirectory: entry.isDirectory,\n size: entry.size,\n lastModified: entry.lastModified.toISOString()\n }))\n };\n }\n \n if (action === 'compute.sandbox.filesystem.exists') {\n if (!body.path) throw new Error('path is required');\n const result = await sandbox.filesystem.exists(body.path);\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n exists: result\n };\n }\n \n if (action === 'compute.sandbox.filesystem.remove') {\n if (!body.path) throw new Error('path is required');\n await sandbox.filesystem.remove(body.path);\n return { success: true, sandboxId, provider: provider.name };\n }\n \n throw new Error(`Unknown action: ${action}`);\n \n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n sandboxId: body.sandboxId || '',\n provider: provider.name\n };\n }\n}\n\n/**\n * Main request handler - handles HTTP requests and pre-parsed bodies\n */\nexport async function handleComputeRequest(\n params: HandleComputeRequestParams\n): Promise<ComputeResponse>;\nexport async function handleComputeRequest(\n requestOrBody: Request | ComputeRequest,\n provider: Provider\n): Promise<Response>;\nexport async function handleComputeRequest(\n paramsOrRequestOrBody: HandleComputeRequestParams | Request | ComputeRequest,\n provider?: Provider\n): Promise<ComputeResponse | Response> {\n // Handle object-style API\n if (typeof paramsOrRequestOrBody === 'object' && 'request' in paramsOrRequestOrBody && 'provider' in paramsOrRequestOrBody) {\n const params = paramsOrRequestOrBody as HandleComputeRequestParams;\n return await executeAction(params.request, params.provider);\n }\n \n // Handle original API\n if (!provider) {\n throw new Error('Provider is required when not using object-style API');\n }\n \n const requestOrBody = paramsOrRequestOrBody as Request | ComputeRequest;\n try {\n let body: ComputeRequest;\n \n if (requestOrBody instanceof Request) {\n // Handle HTTP method validation\n if (requestOrBody.method !== 'POST') {\n return Response.json({\n success: false,\n error: 'Only POST requests are supported',\n sandboxId: '',\n provider: provider.name\n }, { status: 405 });\n }\n \n // Parse JSON body with better error handling\n try {\n body = await requestOrBody.json();\n } catch (parseError) {\n return Response.json({\n success: false,\n error: 'Invalid JSON in request body',\n sandboxId: '',\n provider: provider.name\n }, { status: 400 });\n }\n } else {\n body = requestOrBody;\n }\n \n // Execute the action\n const result = await executeAction(body, provider);\n \n return Response.json(result, {\n status: result.success ? 200 : 500\n });\n \n } catch (error) {\n return Response.json({\n success: false,\n error: error instanceof Error ? error.message : 'Request handling failed',\n sandboxId: '',\n provider: provider.name\n }, { status: 500 });\n }\n}\n\n/**\n * Legacy export for backward compatibility\n */\nexport interface HandleComputeRequestParams {\n request: ComputeRequest;\n provider: Provider;\n}\n\nexport { handleComputeRequest as handleHttpComputeRequest };","/**\n * Provider Factory - Creates providers from method definitions\n * \n * Eliminates boilerplate by auto-generating Provider/Sandbox classes\n * from simple method definitions with automatic feature detection.\n */\n\nimport type {\n Provider,\n ProviderSandboxManager,\n ProviderTemplateManager,\n ProviderSnapshotManager,\n Sandbox,\n SandboxFileSystem,\n SandboxInfo,\n ExecutionResult,\n Runtime,\n CreateSandboxOptions,\n FileEntry,\n RunCommandOptions,\n CreateSnapshotOptions,\n ListSnapshotsOptions,\n CreateTemplateOptions,\n ListTemplatesOptions,\n} from './types/index.js';\n\n/**\n * Helper function to handle background command execution\n * Providers can use this to implement background job support\n */\nexport function createBackgroundCommand(command: string, args: string[] = [], options?: RunCommandOptions): { command: string; args: string[]; isBackground: boolean } {\n if (!options?.background) {\n return { command, args, isBackground: false };\n }\n\n // For background execution, we modify the command to run in background\n // Default approach: append & to make it run in background\n const fullCommand = args.length > 0 ? `${command} ${args.join(' ')}` : command;\n \n return {\n command: 'sh',\n args: ['-c', `${fullCommand} &`],\n isBackground: true\n };\n}\n\n/**\n * Flat sandbox method implementations - all operations in one place\n */\nexport interface SandboxMethods<TSandbox = any, TConfig = any> {\n // Collection operations (map to compute.sandbox.*)\n create: (config: TConfig, options?: CreateSandboxOptions) => Promise<{ sandbox: TSandbox; sandboxId: string }>;\n getById: (config: TConfig, sandboxId: string) => Promise<{ sandbox: TSandbox; sandboxId: string } | null>;\n list: (config: TConfig) => Promise<Array<{ sandbox: TSandbox; sandboxId: string }>>;\n destroy: (config: TConfig, sandboxId: string) => Promise<void>;\n \n // Instance operations (map to individual Sandbox methods)\n runCode: (sandbox: TSandbox, code: string, runtime?: Runtime, config?: TConfig) => Promise<ExecutionResult>;\n runCommand: (sandbox: TSandbox, command: string, args?: string[], options?: RunCommandOptions) => Promise<ExecutionResult>;\n getInfo: (sandbox: TSandbox) => Promise<SandboxInfo>;\n getUrl: (sandbox: TSandbox, options: { port: number; protocol?: string }) => Promise<string>;\n \n // Optional provider-specific typed getInstance method\n getInstance?: (sandbox: TSandbox) => TSandbox;\n \n // Optional filesystem methods\n filesystem?: {\n readFile: (sandbox: TSandbox, path: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<string>;\n writeFile: (sandbox: TSandbox, path: string, content: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<void>;\n mkdir: (sandbox: TSandbox, path: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<void>;\n readdir: (sandbox: TSandbox, path: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<FileEntry[]>;\n exists: (sandbox: TSandbox, path: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<boolean>;\n remove: (sandbox: TSandbox, path: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<void>;\n };\n}\n\n/**\n * Template method implementations\n */\nexport interface TemplateMethods<TTemplate = any, TConfig = any> {\n create: (config: TConfig, options: CreateTemplateOptions | any) => Promise<TTemplate>;\n list: (config: TConfig, options?: ListTemplatesOptions) => Promise<TTemplate[]>;\n delete: (config: TConfig, templateId: string) => Promise<void>;\n}\n\n/**\n * Snapshot method implementations \n */\nexport interface SnapshotMethods<TSnapshot = any, TConfig = any> {\n create: (config: TConfig, sandboxId: string, options?: CreateSnapshotOptions) => Promise<TSnapshot>;\n list: (config: TConfig, options?: ListSnapshotsOptions) => Promise<TSnapshot[]>;\n delete: (config: TConfig, snapshotId: string) => Promise<void>;\n}\n\n/**\n * Provider configuration for createProvider()\n */\nexport interface ProviderConfig<TSandbox = any, TConfig = any, TTemplate = any, TSnapshot = any> {\n name: string;\n methods: {\n sandbox: SandboxMethods<TSandbox, TConfig>;\n template?: TemplateMethods<TTemplate, TConfig>;\n snapshot?: SnapshotMethods<TSnapshot, TConfig>;\n };\n}\n\n/**\n * Default filesystem implementations based on shell commands\n * These work for any provider that supports shell command execution\n */\nconst defaultFilesystemMethods = {\n readFile: async (sandbox: any, path: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<string> => {\n const result = await runCommand(sandbox, 'cat', [path]);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to read file ${path}: ${result.stderr}`);\n }\n // Trim trailing newline that cat command adds\n return result.stdout.replace(/\\n$/, '');\n },\n\n writeFile: async (sandbox: any, path: string, content: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<void> => {\n const result = await runCommand(sandbox, 'sh', ['-c', `echo ${JSON.stringify(content)} > ${JSON.stringify(path)}`]);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to write file ${path}: ${result.stderr}`);\n }\n },\n\n mkdir: async (sandbox: any, path: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<void> => {\n const result = await runCommand(sandbox, 'mkdir', ['-p', path]);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to create directory ${path}: ${result.stderr}`);\n }\n },\n\n readdir: async (sandbox: any, path: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<FileEntry[]> => {\n // Try different ls variations for maximum compatibility\n let result = await runCommand(sandbox, 'ls', ['-la', path]);\n let hasDetailedOutput = true;\n \n // Fall back to basic ls if detailed flags not supported\n if (result.exitCode !== 0) {\n result = await runCommand(sandbox, 'ls', ['-l', path]);\n }\n if (result.exitCode !== 0) {\n result = await runCommand(sandbox, 'ls', [path]);\n hasDetailedOutput = false;\n }\n \n if (result.exitCode !== 0) {\n throw new Error(`Failed to list directory ${path}: ${result.stderr}`);\n }\n\n const lines = (result.stdout || '').split('\\n').filter((line: string) => line.trim() && !line.startsWith('total'));\n\n return lines.map((line: string) => {\n if (hasDetailedOutput && line.includes(' ')) {\n // Parse detailed ls output (ls -la or ls -l)\n const parts = line.trim().split(/\\s+/);\n const name = parts[parts.length - 1];\n const isDirectory = line.startsWith('d');\n \n return {\n name,\n path: `${path}/${name}`,\n isDirectory,\n size: parseInt(parts[4]) || 0,\n lastModified: new Date()\n };\n } else {\n // Parse simple ls output (just filenames)\n const name = line.trim();\n return {\n name,\n path: `${path}/${name}`,\n isDirectory: false, // Can't determine from simple ls\n size: 0,\n lastModified: new Date()\n };\n }\n });\n },\n\n exists: async (sandbox: any, path: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<boolean> => {\n const result = await runCommand(sandbox, 'test', ['-e', path]);\n return result.exitCode === 0; // Exit code 0 means file exists\n },\n\n remove: async (sandbox: any, path: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<void> => {\n const result = await runCommand(sandbox, 'rm', ['-rf', path]);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to remove ${path}: ${result.stderr}`);\n }\n }\n};\n\n/**\n * Auto-generated filesystem implementation that throws \"not supported\" errors\n */\nclass UnsupportedFileSystem implements SandboxFileSystem {\n private readonly providerName: string;\n\n constructor(providerName: string) {\n this.providerName = providerName;\n }\n\n async readFile(_path: string): Promise<string> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n\n async writeFile(_path: string, _content: string): Promise<void> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n\n async mkdir(_path: string): Promise<void> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n\n async readdir(_path: string): Promise<FileEntry[]> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n\n async exists(_path: string): Promise<boolean> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n\n async remove(_path: string): Promise<void> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n}\n\n\n\n/**\n * Auto-generated filesystem implementation that wraps provider methods\n */\nclass SupportedFileSystem<TSandbox> implements SandboxFileSystem {\n constructor(\n private sandbox: TSandbox,\n private methods: NonNullable<SandboxMethods<TSandbox>['filesystem']>,\n private allMethods: SandboxMethods<TSandbox>\n ) {}\n\n async readFile(path: string): Promise<string> {\n return this.methods.readFile(this.sandbox, path, this.allMethods.runCommand);\n }\n\n async writeFile(path: string, content: string): Promise<void> {\n return this.methods.writeFile(this.sandbox, path, content, this.allMethods.runCommand);\n }\n\n async mkdir(path: string): Promise<void> {\n return this.methods.mkdir(this.sandbox, path, this.allMethods.runCommand);\n }\n\n async readdir(path: string): Promise<FileEntry[]> {\n return this.methods.readdir(this.sandbox, path, this.allMethods.runCommand);\n }\n\n async exists(path: string): Promise<boolean> {\n return this.methods.exists(this.sandbox, path, this.allMethods.runCommand);\n }\n\n async remove(path: string): Promise<void> {\n return this.methods.remove(this.sandbox, path, this.allMethods.runCommand);\n }\n}\n\n\n\n\n\n/**\n * Generated sandbox class - implements the Sandbox interface\n */\nclass GeneratedSandbox<TSandbox = any> implements Sandbox<TSandbox> {\n readonly sandboxId: string;\n readonly provider: string;\n readonly filesystem: SandboxFileSystem;\n\n constructor(\n private sandbox: TSandbox,\n sandboxId: string,\n providerName: string,\n private methods: SandboxMethods<TSandbox>,\n private config: any,\n private destroyMethod: (config: any, sandboxId: string) => Promise<void>,\n private providerInstance: Provider\n ) {\n this.sandboxId = sandboxId;\n this.provider = providerName;\n\n // Auto-detect filesystem support\n if (methods.filesystem) {\n this.filesystem = new SupportedFileSystem(sandbox, methods.filesystem, methods);\n } else {\n this.filesystem = new UnsupportedFileSystem(providerName);\n }\n }\n\n getInstance(): TSandbox {\n // Use provider-specific typed getInstance if available\n if (this.methods.getInstance) {\n return this.methods.getInstance(this.sandbox);\n }\n // Fallback to returning the sandbox directly\n return this.sandbox;\n }\n\n async runCode(code: string, runtime?: Runtime): Promise<ExecutionResult> {\n return await this.methods.runCode(this.sandbox, code, runtime, this.config);\n }\n\n async runCommand(command: string, args?: string[], options?: RunCommandOptions): Promise<ExecutionResult> {\n return await this.methods.runCommand(this.sandbox, command, args, options);\n }\n\n async getInfo(): Promise<SandboxInfo> {\n return await this.methods.getInfo(this.sandbox);\n }\n\n async getUrl(options: { port: number; protocol?: string }): Promise<string> {\n return await this.methods.getUrl(this.sandbox, options);\n }\n\n getProvider(): Provider<TSandbox> {\n return this.providerInstance;\n }\n\n async kill(): Promise<void> {\n // For backward compatibility, kill() delegates to destroy()\n await this.destroy();\n }\n\n async destroy(): Promise<void> {\n // Destroy via the provider's destroy method using our sandboxId\n await this.destroyMethod(this.config, this.sandboxId);\n }\n}\n\n/**\n * Auto-generated Sandbox Manager implementation\n */\nclass GeneratedSandboxManager<TSandbox, TConfig> implements ProviderSandboxManager<TSandbox> {\n private activeSandboxes: Map<string, GeneratedSandbox<TSandbox>> = new Map();\n\n constructor(\n private config: TConfig,\n private providerName: string,\n private methods: SandboxMethods<TSandbox, TConfig>,\n private providerInstance: Provider\n ) {}\n\n async create(options?: CreateSandboxOptions): Promise<Sandbox<TSandbox>> {\n // Default to 'node' runtime if not specified for consistency across providers\n const optionsWithDefaults = { runtime: 'node' as Runtime, ...options };\n const result = await this.methods.create(this.config, optionsWithDefaults);\n const sandbox = new GeneratedSandbox<TSandbox>(\n result.sandbox,\n result.sandboxId,\n this.providerName,\n this.methods,\n this.config,\n this.methods.destroy,\n this.providerInstance\n );\n \n this.activeSandboxes.set(result.sandboxId, sandbox);\n return sandbox;\n }\n\n async getById(sandboxId: string): Promise<Sandbox<TSandbox> | null> {\n // Check active sandboxes first\n const existing = this.activeSandboxes.get(sandboxId);\n if (existing) {\n return existing;\n }\n\n // Try to reconnect\n const result = await this.methods.getById(this.config, sandboxId);\n if (!result) {\n return null;\n }\n\n const sandbox = new GeneratedSandbox<TSandbox>(\n result.sandbox,\n result.sandboxId,\n this.providerName,\n this.methods,\n this.config,\n this.methods.destroy,\n this.providerInstance\n );\n \n this.activeSandboxes.set(result.sandboxId, sandbox);\n return sandbox;\n }\n\n async list(): Promise<Sandbox<TSandbox>[]> {\n const results = await this.methods.list(this.config);\n const sandboxes: Sandbox[] = [];\n\n for (const result of results) {\n let sandbox = this.activeSandboxes.get(result.sandboxId);\n if (!sandbox) {\n sandbox = new GeneratedSandbox<TSandbox>(\n result.sandbox,\n result.sandboxId,\n this.providerName,\n this.methods,\n this.config,\n this.methods.destroy,\n this.providerInstance\n );\n this.activeSandboxes.set(result.sandboxId, sandbox);\n }\n sandboxes.push(sandbox);\n }\n\n return sandboxes;\n }\n\n async destroy(sandboxId: string): Promise<void> {\n await this.methods.destroy(this.config, sandboxId);\n this.activeSandboxes.delete(sandboxId);\n }\n}\n\n/**\n * Auto-generated Template Manager implementation\n */\nclass GeneratedTemplateManager<TTemplate, TConfig> implements ProviderTemplateManager<TTemplate> {\n constructor(\n private config: TConfig,\n private methods: TemplateMethods<TTemplate, TConfig>\n ) {}\n\n async create(options: CreateTemplateOptions | any): Promise<TTemplate> {\n return await this.methods.create(this.config, options);\n }\n\n async list(options?: ListTemplatesOptions): Promise<TTemplate[]> {\n return await this.methods.list(this.config, options);\n }\n\n async delete(templateId: string): Promise<void> {\n return await this.methods.delete(this.config, templateId);\n }\n}\n\n/**\n * Auto-generated Snapshot Manager implementation\n */\nclass GeneratedSnapshotManager<TSnapshot, TConfig> implements ProviderSnapshotManager<TSnapshot> {\n constructor(\n private config: TConfig,\n private methods: SnapshotMethods<TSnapshot, TConfig>\n ) {}\n\n async create(sandboxId: string, options?: CreateSnapshotOptions): Promise<TSnapshot> {\n return await this.methods.create(this.config, sandboxId, options);\n }\n\n async list(options?: ListSnapshotsOptions): Promise<TSnapshot[]> {\n return await this.methods.list(this.config, options);\n }\n\n async delete(snapshotId: string): Promise<void> {\n return await this.methods.delete(this.config, snapshotId);\n }\n}\n\n/**\n * Auto-generated Provider implementation\n */\nclass GeneratedProvider<TSandbox, TConfig, TTemplate, TSnapshot> implements Provider<TSandbox, TTemplate, TSnapshot> {\n readonly name: string;\n readonly sandbox: ProviderSandboxManager<TSandbox>;\n readonly template?: ProviderTemplateManager<TTemplate>;\n readonly snapshot?: ProviderSnapshotManager<TSnapshot>;\n readonly __sandboxType!: TSandbox; // Phantom type for TypeScript inference\n\n constructor(config: TConfig, providerConfig: ProviderConfig<TSandbox, TConfig, TTemplate, TSnapshot>) {\n this.name = providerConfig.name;\n this.sandbox = new GeneratedSandboxManager(\n config,\n providerConfig.name,\n providerConfig.methods.sandbox,\n this\n );\n\n // Initialize optional managers if methods are provided\n if (providerConfig.methods.template) {\n this.template = new GeneratedTemplateManager(config, providerConfig.methods.template);\n }\n \n if (providerConfig.methods.snapshot) {\n this.snapshot = new GeneratedSnapshotManager(config, providerConfig.methods.snapshot);\n }\n }\n\n getSupportedRuntimes(): Runtime[] {\n // For now, all providers support both node and python\n // In the future, this could be configurable per provider\n return ['node', 'python'];\n }\n}\n\n/**\n * Create a provider from method definitions\n * \n * Auto-generates all boilerplate classes and provides feature detection\n * based on which methods are implemented.\n */\nexport function createProvider<TSandbox, TConfig = any, TTemplate = any, TSnapshot = any>(\n providerConfig: ProviderConfig<TSandbox, TConfig, TTemplate, TSnapshot>\n): (config: TConfig) => Provider<TSandbox, TTemplate, TSnapshot> {\n // Auto-inject default filesystem methods if none provided\n if (!providerConfig.methods.sandbox.filesystem) {\n providerConfig.methods.sandbox.filesystem = defaultFilesystemMethods;\n }\n\n return (config: TConfig) => {\n return new GeneratedProvider(config, providerConfig);\n };\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACwJO,IAAM,mBAAN,cAA+B,MAAM;AAAA,EAE1C,YAAmB,QAKhB;AACD,UAAM,4BAA4B,OAAO,QAAQ,EAAE;AANlC;AADnB,gBAAO;AAAA,EAQP;AACF;AAKO,SAAS,mBAAmB,OAA2C;AAC5E,SACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,MAAM,SAAS,sBACf,YAAY;AAEhB;;;ACzKA,oBAA8B;AAe9B,eAAe,gBAAgB,QAAgD;AAC7E,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,0DAA0D;AAAA,MACrF,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM,KAAK,UAAU;AAAA,QACnB,KAAK;AAAA,QACL,iBAAiB;AAAA,MACnB,CAAC;AAAA,IACH,CAAC;AAED,QAAI,CAA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AAA,IACtF;AAEA,QAAI,eAAe,QAAQ,UAAU;AACnC,WAAK,WAAW,IAAI,yBAAyB,QAAQ,eAAe,QAAQ,QAAQ;AAAA,IACtF;AAAA,EACF;AAAA,EAEA,uBAAkC;AAGhC,WAAO,CAAC,QAAQ,QAAQ;AAAA,EAC1B;AACF;AAQO,SAAS,eACd,gBAC+D;AAE/D,MAAI,CAAC,eAAe,QAAQ,QAAQ,YAAY;AAC9C,mBAAe,QAAQ,QAAQ,aAAa;AAAA,EAC9C;AAEA,SAAO,CAAC,WAAoB;AAC1B,WAAO,IAAI,kBAAkB,QAAQ,cAAc;AAAA,EACrD;AACF;","names":["sandbox"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/types/sandbox.ts","../src/compute.ts","../src/request-handler.ts","../src/factory.ts"],"sourcesContent":["/**\n * ComputeSDK Core\n * \n * Clean Provider/Sandbox separation architecture with extensible compute.* API\n */\n\n// Export all types\nexport * from './types';\n\n// Export compute singleton - the main API\nexport { compute, createCompute } from './compute';\n\n// Export request handler for web framework integration\nexport { handleComputeRequest } from './request-handler';\n\n// Export compute request/response types\nexport type {\n ComputeRequest,\n ComputeResponse,\n HandleComputeRequestParams\n} from './request-handler';\n\n\n\n// Export provider factory for creating custom providers\nexport { createProvider, createBackgroundCommand } from './factory';\nexport type { ProviderConfig, SandboxMethods, TemplateMethods, SnapshotMethods } from './factory';\n\n// Export error handling utilities (explicitly for clarity)\nexport { CommandExitError, isCommandExitError } from './types/sandbox';\n\n// Test suite is available separately via @computesdk/test-utils package\n","/**\n * Sandbox Types\n * \n * Types related to sandbox execution, filesystem, terminal operations\n */\n\n// Forward declaration to avoid circular dependency\ninterface Provider {\n readonly name: string;\n readonly sandbox: any; // Will be properly typed when imported together\n}\n\n/**\n * Type mapping for provider names to their sandbox types\n * Manually defined for known providers since declaration merging isn't working reliably\n */\nexport interface ProviderSandboxTypeMap {\n e2b: any; // We can't import the E2B type directly, but we'll handle it differently\n vercel: any;\n daytona: any;\n}\n\n/**\n * Utility type to extract the native instance type from a provider\n * Uses provider name and manual type inference\n */\nexport type ExtractSandboxInstanceType<TProvider extends Provider> = \n TProvider extends { readonly name: 'e2b' }\n ? any // For now, let's just try to make the runtime casting work\n : TProvider extends { readonly name: 'vercel' }\n ? any\n : TProvider extends { readonly name: 'daytona' }\n ? any\n : any;\n\n/**\n * Supported runtime environments\n */\nexport type Runtime = 'node' | 'python';\n\n/**\n * Sandbox status types\n */\nexport type SandboxStatus = 'running' | 'stopped' | 'error';\n\n/**\n * Options for running commands\n */\nexport interface RunCommandOptions {\n /** Run command in background (non-blocking) */\n background?: boolean;\n}\n\n/**\n * Result of code execution\n */\nexport interface ExecutionResult {\n /** Standard output from the execution */\n stdout: string;\n /** Standard error from the execution */\n stderr: string;\n /** Exit code from the execution */\n exitCode: number;\n /** Time taken for execution in milliseconds */\n executionTime: number;\n /** ID of the sandbox where the code was executed */\n sandboxId: string;\n /** Provider that executed the code */\n provider: string;\n /** Process ID for background jobs (if applicable) */\n pid?: number;\n /** Whether this command is running in background */\n isBackground?: boolean;\n}\n\n/**\n * Information about a sandbox\n */\nexport interface SandboxInfo {\n /** Unique identifier for the sandbox */\n id: string;\n /** Provider hosting the sandbox */\n provider: string;\n /** Runtime environment in the sandbox */\n runtime: Runtime;\n /** Current status of the sandbox */\n status: SandboxStatus;\n /** When the sandbox was created */\n createdAt: Date;\n /** Execution timeout in milliseconds */\n timeout: number;\n /** Additional provider-specific metadata */\n metadata?: Record<string, any>;\n}\n\n/**\n * Options for creating a sandbox\n */\nexport interface CreateSandboxOptions {\n /** Runtime environment (defaults to 'node' if not specified) */\n runtime?: Runtime;\n /** Execution timeout in milliseconds */\n timeout?: number;\n /** Custom sandbox ID (if supported by provider) */\n sandboxId?: string;\n /** Template ID for sandbox creation (provider-specific) */\n templateId?: string;\n /** Additional metadata for the sandbox */\n metadata?: Record<string, any>;\n /** Domain for sandbox connection (provider-specific) */\n domain?: string;\n /** Environment variables for the sandbox */\n envs?: Record<string, string>;\n}\n\n/**\n * File system entry information\n */\nexport interface FileEntry {\n /** File/directory name */\n name: string;\n /** Full path to the entry */\n path: string;\n /** Whether this is a directory */\n isDirectory: boolean;\n /** File size in bytes (0 for directories) */\n size: number;\n /** Last modified timestamp */\n lastModified: Date;\n}\n\n/**\n * File system interface for sandbox operations\n */\nexport interface SandboxFileSystem {\n /** Read file contents */\n readFile(path: string): Promise<string>;\n /** Write file contents */\n writeFile(path: string, content: string): Promise<void>;\n /** Create directory */\n mkdir(path: string): Promise<void>;\n /** List directory contents */\n readdir(path: string): Promise<FileEntry[]>;\n /** Check if file/directory exists */\n exists(path: string): Promise<boolean>;\n /** Remove file or directory */\n remove(path: string): Promise<void>;\n}\n\n/**\n * Error thrown when a command exits with a non-zero status\n */\nexport class CommandExitError extends Error {\n name = 'CommandExitError';\n constructor(public result: {\n exitCode: number;\n stdout: string;\n stderr: string;\n error: boolean;\n }) {\n super(`Command exited with code ${result.exitCode}`);\n }\n}\n\n/**\n * Type guard to check if an error is a CommandExitError\n */\nexport function isCommandExitError(error: unknown): error is CommandExitError {\n return (\n typeof error === 'object' &&\n error !== null &&\n 'name' in error &&\n error.name === 'CommandExitError' &&\n 'result' in error\n );\n}\n\n\n\n\n\n/**\n * Base sandbox interface - what developers interact with\n */\nexport interface Sandbox<TSandbox = any> {\n /** Unique identifier for the sandbox */\n readonly sandboxId: string;\n /** Provider that created this sandbox */\n readonly provider: string;\n\n /** Execute code in the sandbox */\n runCode(code: string, runtime?: Runtime): Promise<ExecutionResult>;\n /** Execute shell commands */\n runCommand(command: string, args?: string[], options?: RunCommandOptions): Promise<ExecutionResult>;\n /** Get information about the sandbox */\n getInfo(): Promise<SandboxInfo>;\n /** Get URL for accessing the sandbox on a specific port */\n getUrl(options: { port: number; protocol?: string }): Promise<string>;\n /** Get the provider instance that created this sandbox */\n getProvider(): import('./provider').Provider<TSandbox>;\n /** Get the native provider sandbox instance with proper typing */\n getInstance(): TSandbox;\n /** Kill the sandbox */\n kill(): Promise<void>;\n /** Destroy the sandbox and clean up resources */\n destroy(): Promise<void>;\n\n /** File system operations */\n readonly filesystem: SandboxFileSystem;\n}\n\n/**\n * Extract the sandbox type from a provider\n */\ntype ExtractProviderSandboxType<TProvider extends Provider> = TProvider extends { readonly __sandboxType: infer TSandbox } ? TSandbox : any;\n\n/**\n * Typed sandbox interface that preserves the provider's native instance type\n */\nexport interface TypedSandbox<TProvider extends Provider> extends Omit<Sandbox<ExtractProviderSandboxType<TProvider>>, 'getProvider'> {\n /** Get the provider instance that created this sandbox with proper typing */\n getProvider(): TProvider;\n /** Get the native provider sandbox instance with proper typing */\n getInstance(): ExtractProviderSandboxType<TProvider>;\n}\n\n/**\n * Enhanced sandbox type that includes ComputeClient features\n *\n * When a sandbox is created with an API key/JWT, it gets wrapped with ComputeClient\n * which adds powerful features like WebSocket terminals, file watchers, and signals.\n *\n * @example\n * ```typescript\n * const sandbox = await compute.sandbox.create();\n *\n * // ComputeClient features (only available when API key is configured)\n * const terminal = await sandbox.createTerminal();\n * const watcher = await sandbox.createWatcher('/home/project');\n * const signals = await sandbox.startSignals();\n *\n * // Original sandbox features still work\n * await sandbox.runCommand('ls');\n * const instance = sandbox.getInstance();\n * ```\n */\nexport type ComputeEnhancedSandbox<TSandbox = any> = Sandbox<TSandbox> & {\n /** The original provider sandbox instance */\n __originalSandbox: Sandbox<TSandbox>;\n\n // ComputeClient enhanced features\n /** Create a persistent terminal session with WebSocket integration */\n createTerminal(shell?: string, encoding?: 'raw' | 'base64'): Promise<import('@computesdk/client').Terminal>;\n /** Create a file watcher with real-time change notifications */\n createWatcher(path: string, options?: {\n includeContent?: boolean;\n ignored?: string[];\n encoding?: 'raw' | 'base64';\n }): Promise<import('@computesdk/client').FileWatcher>;\n /** Start the signal service for port and error monitoring */\n startSignals(): Promise<import('@computesdk/client').SignalService>;\n /** Execute a one-off command without creating a persistent terminal */\n execute(options: { command: string; shell?: string }): Promise<any>;\n /** List all active terminals */\n listTerminals(): Promise<any[]>;\n /** Get terminal by ID */\n getTerminal(id: string): Promise<any>;\n /** List all active file watchers */\n listWatchers(): Promise<any>;\n /** Get file watcher by ID */\n getWatcher(id: string): Promise<any>;\n /** Get signal service status */\n getSignalStatus(): Promise<any>;\n /** Create a session token (requires access token) */\n createSessionToken(options?: { description?: string; expiresIn?: number }): Promise<any>;\n /** List all session tokens (requires access token) */\n listSessionTokens(): Promise<any>;\n /** Get session token details (requires access token) */\n getSessionToken(tokenId: string): Promise<any>;\n /** Revoke a session token (requires access token) */\n revokeSessionToken(tokenId: string): Promise<void>;\n /** Create a magic link for browser authentication (requires access token) */\n createMagicLink(options?: { redirectUrl?: string }): Promise<any>;\n /** Check authentication status */\n getAuthStatus(): Promise<any>;\n /** Get authentication information */\n getAuthInfo(): Promise<any>;\n /** Set authentication token manually */\n setToken(token: string): void;\n /** Get current authentication token */\n getToken(): string | null;\n /** Get current sandbox URL */\n getSandboxUrl(): string;\n /** Disconnect WebSocket connection */\n disconnect(): Promise<void>;\n}\n\n/**\n * Typed enhanced sandbox that preserves both provider typing and ComputeClient features\n */\nexport type TypedEnhancedSandbox<TProvider extends Provider> =\n ComputeEnhancedSandbox<ExtractProviderSandboxType<TProvider>> &\n Omit<TypedSandbox<TProvider>, keyof Sandbox>;","/**\n * Compute Singleton - Main API Orchestrator\n *\n * Provides the unified compute.* API and delegates to specialized managers\n */\n\nimport { ComputeClient } from '@computesdk/client';\nimport type { ComputeAPI, CreateSandboxParams, CreateSandboxParamsWithOptionalProvider, ComputeConfig, Sandbox, Provider, TypedSandbox, TypedComputeAPI, ComputeEnhancedSandbox, TypedEnhancedSandbox } from './types';\n\n/**\n * Authorization response from license server\n */\ninterface AuthorizationResponse {\n access_token: string;\n sandbox_url: string;\n preview_url: string;\n}\n\n/**\n * Authorize license key and get JWT token + URLs from license server\n */\nasync function authorizeApiKey(apiKey: string): Promise<AuthorizationResponse> {\n try {\n const response = await fetch('https://preview.computesdk.com/__api/license/authorize', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n key: apiKey,\n increment_usage: 1\n })\n });\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => response.statusText);\n throw new Error(`License authorization failed (${response.status}): ${errorText}`);\n }\n\n const data = await response.json();\n\n if (!data.access_token) {\n throw new Error('No access token received from license server');\n }\n\n if (!data.sandbox_url) {\n throw new Error('No sandbox_url received from license server');\n }\n\n if (!data.preview_url) {\n throw new Error('No preview_url received from license server');\n }\n\n return {\n access_token: data.access_token,\n sandbox_url: data.sandbox_url,\n preview_url: data.preview_url\n };\n } catch (error) {\n if (error instanceof Error && error.message.includes('License authorization failed')) {\n throw error; // Re-throw our formatted error\n }\n // Network or other errors\n throw new Error(`Failed to authorize API key (network error): ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/**\n * Check if a command is available in the sandbox\n */\nasync function isCommandAvailable(sandbox: Sandbox, command: string): Promise<boolean> {\n const result = await sandbox.runCommand('sh', ['-c', `command -v ${command}`]);\n return result.exitCode === 0;\n}\n\n/**\n * Detect package manager available in the sandbox\n */\nasync function detectPackageManager(sandbox: Sandbox): Promise<'apk' | 'apt' | null> {\n // Try Alpine's apk first (most common in minimal containers)\n if (await isCommandAvailable(sandbox, 'apk')) {\n return 'apk';\n }\n\n // Fall back to Debian/Ubuntu apt\n if (await isCommandAvailable(sandbox, 'apt-get')) {\n return 'apt';\n }\n\n return null;\n}\n\n/**\n * Install required dependencies (curl and bash) if missing\n */\nasync function ensureDependencies(sandbox: Sandbox): Promise<void> {\n const hasCurl = await isCommandAvailable(sandbox, 'curl');\n const hasBash = await isCommandAvailable(sandbox, 'bash');\n\n // If both are available, nothing to do\n if (hasCurl && hasBash) {\n return;\n }\n\n const packageManager = await detectPackageManager(sandbox);\n\n if (!packageManager) {\n throw new Error(\n `Missing required tools (curl: ${hasCurl}, bash: ${hasBash}), but no supported package manager found.\\n` +\n `Supported package managers: apk (Alpine), apt-get (Debian/Ubuntu).\\n` +\n `Please use a sandbox image that includes curl and bash, or install them manually first.`\n );\n }\n\n let installResult;\n\n if (packageManager === 'apk') {\n // Alpine Linux\n installResult = await sandbox.runCommand('sh', ['-c', 'apk add --no-cache curl bash 2>&1']);\n } else {\n // Debian/Ubuntu\n installResult = await sandbox.runCommand('sh', ['-c', 'apt-get update -qq && apt-get install -qq -y curl bash 2>&1']);\n }\n\n if (installResult.exitCode !== 0) {\n throw new Error(\n `Failed to install curl and bash using ${packageManager}.\\n` +\n `Install output: ${installResult.stderr || installResult.stdout}\\n` +\n `Please install curl and bash manually or use a different sandbox image.`\n );\n }\n}\n\n/**\n * Check if compute CLI is already installed in the sandbox\n */\nasync function isComputeInstalled(sandbox: Sandbox): Promise<boolean> {\n const result = await sandbox.runCommand('sh', ['-c', 'test -f /usr/local/bin/compute && echo \"exists\" || echo \"missing\"']);\n return result.stdout?.trim() === 'exists';\n}\n\n/**\n * Download the compute install script\n */\nasync function downloadInstallScript(sandbox: Sandbox): Promise<void> {\n const downloadResult = await sandbox.runCommand('sh', ['-c', 'curl -fsSL https://computesdk.com/install.sh -o /tmp/compute-install.sh 2>&1']);\n\n if (downloadResult.exitCode !== 0) {\n const errorOutput = downloadResult.stderr || downloadResult.stdout || 'unknown error';\n throw new Error(\n `Failed to download install script from https://computesdk.com/install.sh: ${errorOutput}`\n );\n }\n}\n\n/**\n * Run the compute install script\n */\nasync function runInstallScript(sandbox: Sandbox, accessToken?: string): Promise<void> {\n const installCommand = accessToken\n ? `bash /tmp/compute-install.sh --non-interactive --access-token \"${accessToken}\" --location /usr/local/bin`\n : `bash /tmp/compute-install.sh --non-interactive --location /usr/local/bin`;\n\n const installResult = await sandbox.runCommand('bash', ['-c', installCommand]);\n\n if (installResult.exitCode !== 0) {\n const errorOutput = installResult.stderr || installResult.stdout || 'unknown error';\n throw new Error(`Failed to install compute CLI: ${errorOutput}`);\n }\n}\n\n/**\n * Install and start compute CLI inside a sandbox\n *\n * This is the main installation orchestrator that:\n * 1. Checks if compute is already installed\n * 2. Ensures curl and bash are available (installs if needed)\n * 3. Downloads the install script\n * 4. Runs the install script with proper credentials\n * 5. Verifies the installation succeeded\n */\nasync function installComputeInSandbox(\n sandbox: Sandbox,\n config?: { apiKey?: string; accessToken?: string }\n): Promise<AuthorizationResponse | null> {\n // Get access token and URLs from API key if provided\n let authResponse: AuthorizationResponse | null = null;\n let accessToken = config?.accessToken;\n\n if (config?.apiKey && !accessToken) {\n authResponse = await authorizeApiKey(config.apiKey);\n accessToken = authResponse.access_token;\n }\n\n // Check if compute is already installed\n if (await isComputeInstalled(sandbox)) {\n return authResponse;\n }\n\n // Ensure required dependencies are available\n await ensureDependencies(sandbox);\n\n // Download install script\n await downloadInstallScript(sandbox);\n\n // Run install script with credentials\n await runInstallScript(sandbox, accessToken);\n\n // Verify installation succeeded\n if (!await isComputeInstalled(sandbox)) {\n throw new Error('Compute binary not found at /usr/local/bin/compute after installation');\n }\n\n return authResponse;\n}\n\n/**\n * Wait for compute CLI to be ready by polling the health endpoint\n */\nasync function waitForComputeReady(client: ComputeClient, maxRetries = 30, delayMs = 2000): Promise<void> {\n let lastError: Error | null = null;\n\n for (let i = 0; i < maxRetries; i++) {\n try {\n await client.health();\n return;\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error));\n\n // Only log on last attempt to avoid noise\n if (i === maxRetries - 1) {\n throw new Error(\n `Compute CLI failed to start after ${maxRetries} attempts (${maxRetries * delayMs / 1000}s).\\n` +\n `Last error: ${lastError.message}\\n` +\n `This could indicate:\\n` +\n ` 1. The compute daemon failed to start in the sandbox\\n` +\n ` 2. The sandbox_url is incorrect or unreachable\\n` +\n ` 3. The sandbox is taking longer than expected to initialize`\n );\n }\n\n await new Promise(resolve => setTimeout(resolve, delayMs));\n }\n }\n}\n\n/**\n * Compute singleton implementation - orchestrates all compute operations\n */\nclass ComputeManager implements ComputeAPI {\n private config: ComputeConfig | null = null;\n private computeAuth: { apiKey?: string; accessToken?: string } = {};\n\n /**\n * Set default configuration with generic type preservation\n */\n setConfig<TProvider extends Provider>(config: ComputeConfig<TProvider>): void {\n // Validate that at least one provider is specified\n if (!config.defaultProvider && !config.provider) {\n throw new Error('Either defaultProvider or provider must be specified in setConfig');\n }\n\n // Handle backwards compatibility: if both are provided, defaultProvider takes precedence\n if (config.defaultProvider && config.provider) {\n console.warn('Both defaultProvider and provider specified in setConfig. Using defaultProvider. The provider key is deprecated, please use defaultProvider instead.');\n }\n\n // Normalize config to always have both fields for internal use (backward compatibility)\n const actualProvider = config.defaultProvider || config.provider!;\n const accessToken = config.accessToken || config.jwt; // Support both accessToken and deprecated jwt\n this.config = {\n provider: actualProvider,\n defaultProvider: actualProvider,\n apiKey: config.apiKey,\n accessToken: accessToken\n };\n\n // Store compute auth credentials\n this.computeAuth = {\n apiKey: config.apiKey,\n accessToken: accessToken\n };\n }\n\n /**\n * Get current configuration\n */\n getConfig(): ComputeConfig | null {\n return this.config;\n }\n\n /**\n * Clear current configuration\n */\n clearConfig(): void {\n this.config = null;\n }\n\n /**\n * Get the default provider, throwing if not configured\n */\n private getDefaultProvider(): Provider {\n const provider = this.config?.defaultProvider || this.config?.provider;\n if (!provider) {\n throw new Error(\n 'No default provider configured. Either call compute.setConfig({ defaultProvider }) or pass provider explicitly.'\n );\n }\n return provider;\n }\n\n /**\n * Wrap a provider sandbox with ComputeClient while preserving the original sandbox\n * This adds powerful features like WebSocket terminals, file watchers, and signals\n */\n private async wrapWithComputeClient(originalSandbox: Sandbox, authResponse: AuthorizationResponse): Promise<ComputeEnhancedSandbox> {\n const client = new ComputeClient({\n sandboxUrl: authResponse.sandbox_url,\n sandboxId: originalSandbox.sandboxId,\n provider: originalSandbox.provider,\n token: authResponse.access_token,\n WebSocket: globalThis.WebSocket\n });\n\n // Wait for compute CLI to be ready before returning\n await waitForComputeReady(client);\n\n // Store the original sandbox for getInstance() and getProvider() calls\n // We create a proxy-like object that delegates most calls to ComputeClient\n // but preserves access to the original provider sandbox\n const wrappedSandbox = Object.assign(client, {\n __originalSandbox: originalSandbox,\n\n // Override getInstance to return the original provider's instance\n getInstance: () => originalSandbox.getInstance(),\n\n // Override getProvider to return the original provider\n getProvider: () => originalSandbox.getProvider()\n });\n\n return wrappedSandbox as ComputeEnhancedSandbox;\n }\n\n sandbox = {\n /**\n * Create a sandbox from a provider (or default provider if configured)\n * \n * @example\n * ```typescript\n * import { e2b } from '@computesdk/e2b'\n * import { compute } from 'computesdk'\n * \n * // With explicit provider\n * const sandbox = await compute.sandbox.create({\n * provider: e2b({ apiKey: 'your-key' })\n * })\n * \n * // With default provider (both forms work)\n * compute.setConfig({ defaultProvider: e2b({ apiKey: 'your-key' }) })\n * const sandbox1 = await compute.sandbox.create({})\n * const sandbox2 = await compute.sandbox.create()\n * ```\n */\n create: async (params?: CreateSandboxParams | CreateSandboxParamsWithOptionalProvider): Promise<Sandbox | ComputeEnhancedSandbox> => {\n const provider = params && 'provider' in params && params.provider ? params.provider : this.getDefaultProvider();\n const options = params?.options;\n const sandbox = await provider.sandbox.create(options);\n\n // Install compute CLI and wrap with ComputeClient if auth is configured\n if (this.computeAuth.apiKey || this.computeAuth.accessToken) {\n // Install compute CLI in the sandbox with auth credentials\n const authResponse = await installComputeInSandbox(sandbox, this.computeAuth);\n\n // Wrap with ComputeClient if we have authorization info\n // This adds features like createTerminal(), createWatcher(), startSignals()\n if (authResponse) {\n return await this.wrapWithComputeClient(sandbox, authResponse);\n }\n }\n\n return sandbox;\n },\n\n /**\n * Get an existing sandbox by ID from a provider (or default provider if configured)\n */\n getById: async (providerOrSandboxId: Provider | string, sandboxId?: string): Promise<Sandbox | null> => {\n if (typeof providerOrSandboxId === 'string') {\n // Called with just sandboxId, use default provider\n const provider = this.getDefaultProvider();\n return await provider.sandbox.getById(providerOrSandboxId);\n } else {\n // Called with provider and sandboxId\n if (!sandboxId) {\n throw new Error('sandboxId is required when provider is specified');\n }\n return await providerOrSandboxId.sandbox.getById(sandboxId);\n }\n },\n\n /**\n * List all active sandboxes from a provider (or default provider if configured)\n */\n list: async (provider?: Provider): Promise<Sandbox[]> => {\n const actualProvider = provider || this.getDefaultProvider();\n return await actualProvider.sandbox.list();\n },\n\n /**\n * Destroy a sandbox via a provider (or default provider if configured)\n */\n destroy: async (providerOrSandboxId: Provider | string, sandboxId?: string): Promise<void> => {\n if (typeof providerOrSandboxId === 'string') {\n // Called with just sandboxId, use default provider\n const provider = this.getDefaultProvider();\n return await provider.sandbox.destroy(providerOrSandboxId);\n } else {\n // Called with provider and sandboxId\n if (!sandboxId) {\n throw new Error('sandboxId is required when provider is specified');\n }\n return await providerOrSandboxId.sandbox.destroy(sandboxId);\n }\n }\n };\n\n // Future: compute.blob.*, compute.database.*, compute.git.* will be added here\n // blob = new BlobManager();\n // database = new DatabaseManager(); \n // git = new GitManager();\n\n\n}\n\n/**\n * Singleton instance - the main API (untyped)\n */\nexport const compute: ComputeAPI = new ComputeManager();\n\n\n\n/**\n * Create a compute instance with proper typing\n *\n * @example\n * ```typescript\n * import { e2b } from '@computesdk/e2b'\n * import { createCompute } from 'computesdk'\n *\n * // With API key (automatically gets access token from license server)\n * const compute = createCompute({\n * defaultProvider: e2b({ apiKey: 'your-key' }),\n * apiKey: 'computesdk_live_...' // Returns enhanced sandboxes\n * });\n *\n * // Or with direct access token\n * const compute2 = createCompute({\n * defaultProvider: e2b({ apiKey: 'your-key' }),\n * accessToken: 'your-access-token' // Returns enhanced sandboxes\n * });\n *\n * const sandbox = await compute.sandbox.create();\n * const instance = sandbox.getInstance(); // ✅ Properly typed E2B Sandbox!\n * await sandbox.createTerminal(); // ✅ Enhanced sandbox features!\n * ```\n */\nexport function createCompute<TProvider extends Provider>(\n config: ComputeConfig<TProvider> & { apiKey: string }\n): TypedComputeAPI<TProvider, true>;\nexport function createCompute<TProvider extends Provider>(\n config: ComputeConfig<TProvider> & { accessToken: string }\n): TypedComputeAPI<TProvider, true>;\nexport function createCompute<TProvider extends Provider>(\n config: ComputeConfig<TProvider> & { jwt: string }\n): TypedComputeAPI<TProvider, true>;\nexport function createCompute<TProvider extends Provider>(\n config: ComputeConfig<TProvider>\n): TypedComputeAPI<TProvider, false>;\nexport function createCompute<TProvider extends Provider>(\n config: ComputeConfig<TProvider>\n): TypedComputeAPI<TProvider, boolean> {\n const manager = new ComputeManager();\n\n // Set config directly without calling the public setConfig method\n const actualProvider = config.defaultProvider || config.provider!;\n const accessToken = config.accessToken || config.jwt; // Support both accessToken and deprecated jwt\n manager['config'] = {\n provider: actualProvider,\n defaultProvider: actualProvider,\n apiKey: config.apiKey,\n accessToken: accessToken\n };\n manager['computeAuth'] = {\n apiKey: config.apiKey,\n accessToken: accessToken\n };\n\n const isEnhanced = !!(config.apiKey || config.accessToken || config.jwt);\n\n return {\n setConfig: <T extends Provider>(cfg: ComputeConfig<T>) => createCompute(cfg),\n getConfig: () => manager.getConfig(),\n clearConfig: () => manager.clearConfig(),\n\n sandbox: {\n create: async (params?: Omit<CreateSandboxParamsWithOptionalProvider, 'provider'>) => {\n const sandbox = await manager.sandbox.create(params);\n // If API key/JWT is configured, the sandbox will be enhanced with ComputeClient features\n // Cast to the appropriate type based on whether it's enhanced or not\n if (isEnhanced) {\n return sandbox as TypedEnhancedSandbox<TProvider>;\n }\n return sandbox as TypedSandbox<TProvider>;\n },\n\n getById: async (sandboxId: string) => {\n const sandbox = await manager.sandbox.getById(sandboxId);\n if (!sandbox) return null;\n // Type depends on whether auth is configured\n if (isEnhanced) {\n return sandbox as TypedEnhancedSandbox<TProvider>;\n }\n return sandbox as TypedSandbox<TProvider>;\n },\n\n list: async () => {\n const sandboxes = await manager.sandbox.list();\n // Type depends on whether auth is configured\n if (isEnhanced) {\n return sandboxes as TypedEnhancedSandbox<TProvider>[];\n }\n return sandboxes as TypedSandbox<TProvider>[];\n },\n\n destroy: async (sandboxId: string) => {\n return await manager.sandbox.destroy(sandboxId);\n }\n }\n } as TypedComputeAPI<TProvider, typeof isEnhanced>;\n}\n\n\n\n","/**\n * Simplified Request Handler for Web Framework Integration\n * \n * Handles JSON requests for sandbox and code execution operations.\n * Terminal support removed - will be re-added with WebSocket VM connections.\n */\n\nimport type { Provider, Runtime } from './types';\nimport { compute } from './compute';\n\n/**\n * Request structure supporting sandbox and code execution capabilities\n */\nexport interface ComputeRequest {\n /** Action in dot notation (e.g., 'compute.sandbox.create') */\n action: string;\n \n /** Parameters for the action */\n sandboxId?: string;\n code?: string;\n command?: string;\n args?: string[];\n runtime?: Runtime;\n path?: string;\n content?: string;\n \n /** Command options (for runCommand action) */\n commandOptions?: {\n background?: boolean;\n };\n \n /** Sandbox creation options */\n options?: {\n runtime?: Runtime;\n timeout?: number;\n sandboxId?: string;\n };\n}\n\n/**\n * Response structure for compute operations\n */\nexport interface ComputeResponse {\n success: boolean;\n error?: string;\n sandboxId: string;\n provider: string;\n [key: string]: any; // Allow any additional response data\n}\n\n/**\n * Execute compute action using targeted handling\n */\nasync function executeAction(body: ComputeRequest, provider: Provider): Promise<ComputeResponse> {\n try {\n const { action, sandboxId } = body;\n \n // Sandbox management operations\n if (action === 'compute.sandbox.create') {\n const sandbox = await compute.sandbox.create({\n provider,\n options: body.options || { runtime: 'python' }\n });\n return {\n success: true,\n sandboxId: sandbox.sandboxId,\n provider: provider.name\n };\n }\n \n if (action === 'compute.sandbox.list') {\n const sandboxes = await compute.sandbox.list(provider);\n return {\n success: true,\n sandboxId: '',\n provider: provider.name,\n sandboxes: sandboxes.map(sb => ({\n sandboxId: sb.sandboxId,\n provider: sb.provider\n }))\n };\n }\n \n if (action === 'compute.sandbox.destroy') {\n if (!sandboxId) {\n throw new Error('sandboxId is required for destroy action');\n }\n await compute.sandbox.destroy(provider, sandboxId);\n return {\n success: true,\n sandboxId,\n provider: provider.name\n };\n }\n \n // For sandbox instance methods, get the sandbox first\n if (!sandboxId) {\n throw new Error('sandboxId is required for this action');\n }\n \n const sandbox = await compute.sandbox.getById(provider, sandboxId);\n if (!sandbox) {\n throw new Error(`Sandbox ${sandboxId} not found`);\n }\n \n // Sandbox info\n if (action === 'compute.sandbox.getInfo') {\n const result = await sandbox.getInfo();\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n info: {\n id: result.id,\n provider: result.provider,\n runtime: result.runtime,\n status: result.status,\n createdAt: result.createdAt.toISOString(),\n timeout: result.timeout,\n metadata: result.metadata\n }\n };\n }\n \n // Code execution\n if (action === 'compute.sandbox.runCode') {\n if (!body.code) throw new Error('code is required');\n const result = await sandbox.runCode(body.code, body.runtime);\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n result: {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n executionTime: result.executionTime\n }\n };\n }\n \n if (action === 'compute.sandbox.runCommand') {\n if (!body.command) throw new Error('command is required');\n const result = await sandbox.runCommand(body.command, body.args, body.commandOptions);\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n result: {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n executionTime: result.executionTime,\n ...(result.isBackground && { isBackground: result.isBackground }),\n ...(result.pid && { pid: result.pid })\n }\n };\n }\n \n // Filesystem operations\n if (action === 'compute.sandbox.filesystem.readFile') {\n if (!body.path) throw new Error('path is required');\n const result = await sandbox.filesystem.readFile(body.path);\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n fileContent: result\n };\n }\n \n if (action === 'compute.sandbox.filesystem.writeFile') {\n if (!body.path) throw new Error('path is required');\n if (body.content === undefined) throw new Error('content is required');\n await sandbox.filesystem.writeFile(body.path, body.content);\n return { success: true, sandboxId, provider: provider.name };\n }\n \n if (action === 'compute.sandbox.filesystem.mkdir') {\n if (!body.path) throw new Error('path is required');\n await sandbox.filesystem.mkdir(body.path);\n return { success: true, sandboxId, provider: provider.name };\n }\n \n if (action === 'compute.sandbox.filesystem.readdir') {\n if (!body.path) throw new Error('path is required');\n const result = await sandbox.filesystem.readdir(body.path);\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n files: result.map((entry: any) => ({\n name: entry.name,\n path: entry.path,\n isDirectory: entry.isDirectory,\n size: entry.size,\n lastModified: entry.lastModified.toISOString()\n }))\n };\n }\n \n if (action === 'compute.sandbox.filesystem.exists') {\n if (!body.path) throw new Error('path is required');\n const result = await sandbox.filesystem.exists(body.path);\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n exists: result\n };\n }\n \n if (action === 'compute.sandbox.filesystem.remove') {\n if (!body.path) throw new Error('path is required');\n await sandbox.filesystem.remove(body.path);\n return { success: true, sandboxId, provider: provider.name };\n }\n \n throw new Error(`Unknown action: ${action}`);\n \n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n sandboxId: body.sandboxId || '',\n provider: provider.name\n };\n }\n}\n\n/**\n * Main request handler - handles HTTP requests and pre-parsed bodies\n */\nexport async function handleComputeRequest(\n params: HandleComputeRequestParams\n): Promise<ComputeResponse>;\nexport async function handleComputeRequest(\n requestOrBody: Request | ComputeRequest,\n provider: Provider\n): Promise<Response>;\nexport async function handleComputeRequest(\n paramsOrRequestOrBody: HandleComputeRequestParams | Request | ComputeRequest,\n provider?: Provider\n): Promise<ComputeResponse | Response> {\n // Handle object-style API\n if (typeof paramsOrRequestOrBody === 'object' && 'request' in paramsOrRequestOrBody && 'provider' in paramsOrRequestOrBody) {\n const params = paramsOrRequestOrBody as HandleComputeRequestParams;\n return await executeAction(params.request, params.provider);\n }\n \n // Handle original API\n if (!provider) {\n throw new Error('Provider is required when not using object-style API');\n }\n \n const requestOrBody = paramsOrRequestOrBody as Request | ComputeRequest;\n try {\n let body: ComputeRequest;\n \n if (requestOrBody instanceof Request) {\n // Handle HTTP method validation\n if (requestOrBody.method !== 'POST') {\n return Response.json({\n success: false,\n error: 'Only POST requests are supported',\n sandboxId: '',\n provider: provider.name\n }, { status: 405 });\n }\n \n // Parse JSON body with better error handling\n try {\n body = await requestOrBody.json();\n } catch (parseError) {\n return Response.json({\n success: false,\n error: 'Invalid JSON in request body',\n sandboxId: '',\n provider: provider.name\n }, { status: 400 });\n }\n } else {\n body = requestOrBody;\n }\n \n // Execute the action\n const result = await executeAction(body, provider);\n \n return Response.json(result, {\n status: result.success ? 200 : 500\n });\n \n } catch (error) {\n return Response.json({\n success: false,\n error: error instanceof Error ? error.message : 'Request handling failed',\n sandboxId: '',\n provider: provider.name\n }, { status: 500 });\n }\n}\n\n/**\n * Legacy export for backward compatibility\n */\nexport interface HandleComputeRequestParams {\n request: ComputeRequest;\n provider: Provider;\n}\n\nexport { handleComputeRequest as handleHttpComputeRequest };","/**\n * Provider Factory - Creates providers from method definitions\n * \n * Eliminates boilerplate by auto-generating Provider/Sandbox classes\n * from simple method definitions with automatic feature detection.\n */\n\nimport type {\n Provider,\n ProviderSandboxManager,\n ProviderTemplateManager,\n ProviderSnapshotManager,\n Sandbox,\n SandboxFileSystem,\n SandboxInfo,\n ExecutionResult,\n Runtime,\n CreateSandboxOptions,\n FileEntry,\n RunCommandOptions,\n CreateSnapshotOptions,\n ListSnapshotsOptions,\n CreateTemplateOptions,\n ListTemplatesOptions,\n} from './types/index.js';\n\n/**\n * Helper function to handle background command execution\n * Providers can use this to implement background job support\n */\nexport function createBackgroundCommand(command: string, args: string[] = [], options?: RunCommandOptions): { command: string; args: string[]; isBackground: boolean } {\n if (!options?.background) {\n return { command, args, isBackground: false };\n }\n\n // For background execution, we modify the command to run in background\n // Default approach: append & to make it run in background\n const fullCommand = args.length > 0 ? `${command} ${args.join(' ')}` : command;\n \n return {\n command: 'sh',\n args: ['-c', `${fullCommand} &`],\n isBackground: true\n };\n}\n\n/**\n * Flat sandbox method implementations - all operations in one place\n */\nexport interface SandboxMethods<TSandbox = any, TConfig = any> {\n // Collection operations (map to compute.sandbox.*)\n create: (config: TConfig, options?: CreateSandboxOptions) => Promise<{ sandbox: TSandbox; sandboxId: string }>;\n getById: (config: TConfig, sandboxId: string) => Promise<{ sandbox: TSandbox; sandboxId: string } | null>;\n list: (config: TConfig) => Promise<Array<{ sandbox: TSandbox; sandboxId: string }>>;\n destroy: (config: TConfig, sandboxId: string) => Promise<void>;\n \n // Instance operations (map to individual Sandbox methods)\n runCode: (sandbox: TSandbox, code: string, runtime?: Runtime, config?: TConfig) => Promise<ExecutionResult>;\n runCommand: (sandbox: TSandbox, command: string, args?: string[], options?: RunCommandOptions) => Promise<ExecutionResult>;\n getInfo: (sandbox: TSandbox) => Promise<SandboxInfo>;\n getUrl: (sandbox: TSandbox, options: { port: number; protocol?: string }) => Promise<string>;\n \n // Optional provider-specific typed getInstance method\n getInstance?: (sandbox: TSandbox) => TSandbox;\n \n // Optional filesystem methods\n filesystem?: {\n readFile: (sandbox: TSandbox, path: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<string>;\n writeFile: (sandbox: TSandbox, path: string, content: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<void>;\n mkdir: (sandbox: TSandbox, path: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<void>;\n readdir: (sandbox: TSandbox, path: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<FileEntry[]>;\n exists: (sandbox: TSandbox, path: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<boolean>;\n remove: (sandbox: TSandbox, path: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<void>;\n };\n}\n\n/**\n * Template method implementations\n */\nexport interface TemplateMethods<TTemplate = any, TConfig = any> {\n create: (config: TConfig, options: CreateTemplateOptions | any) => Promise<TTemplate>;\n list: (config: TConfig, options?: ListTemplatesOptions) => Promise<TTemplate[]>;\n delete: (config: TConfig, templateId: string) => Promise<void>;\n}\n\n/**\n * Snapshot method implementations \n */\nexport interface SnapshotMethods<TSnapshot = any, TConfig = any> {\n create: (config: TConfig, sandboxId: string, options?: CreateSnapshotOptions) => Promise<TSnapshot>;\n list: (config: TConfig, options?: ListSnapshotsOptions) => Promise<TSnapshot[]>;\n delete: (config: TConfig, snapshotId: string) => Promise<void>;\n}\n\n/**\n * Provider configuration for createProvider()\n */\nexport interface ProviderConfig<TSandbox = any, TConfig = any, TTemplate = any, TSnapshot = any> {\n name: string;\n methods: {\n sandbox: SandboxMethods<TSandbox, TConfig>;\n template?: TemplateMethods<TTemplate, TConfig>;\n snapshot?: SnapshotMethods<TSnapshot, TConfig>;\n };\n}\n\n/**\n * Default filesystem implementations based on shell commands\n * These work for any provider that supports shell command execution\n */\nconst defaultFilesystemMethods = {\n readFile: async (sandbox: any, path: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<string> => {\n const result = await runCommand(sandbox, 'cat', [path]);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to read file ${path}: ${result.stderr}`);\n }\n // Trim trailing newline that cat command adds\n return result.stdout.replace(/\\n$/, '');\n },\n\n writeFile: async (sandbox: any, path: string, content: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<void> => {\n const result = await runCommand(sandbox, 'sh', ['-c', `echo ${JSON.stringify(content)} > ${JSON.stringify(path)}`]);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to write file ${path}: ${result.stderr}`);\n }\n },\n\n mkdir: async (sandbox: any, path: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<void> => {\n const result = await runCommand(sandbox, 'mkdir', ['-p', path]);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to create directory ${path}: ${result.stderr}`);\n }\n },\n\n readdir: async (sandbox: any, path: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<FileEntry[]> => {\n // Try different ls variations for maximum compatibility\n let result = await runCommand(sandbox, 'ls', ['-la', path]);\n let hasDetailedOutput = true;\n \n // Fall back to basic ls if detailed flags not supported\n if (result.exitCode !== 0) {\n result = await runCommand(sandbox, 'ls', ['-l', path]);\n }\n if (result.exitCode !== 0) {\n result = await runCommand(sandbox, 'ls', [path]);\n hasDetailedOutput = false;\n }\n \n if (result.exitCode !== 0) {\n throw new Error(`Failed to list directory ${path}: ${result.stderr}`);\n }\n\n const lines = (result.stdout || '').split('\\n').filter((line: string) => line.trim() && !line.startsWith('total'));\n\n return lines.map((line: string) => {\n if (hasDetailedOutput && line.includes(' ')) {\n // Parse detailed ls output (ls -la or ls -l)\n const parts = line.trim().split(/\\s+/);\n const name = parts[parts.length - 1];\n const isDirectory = line.startsWith('d');\n \n return {\n name,\n path: `${path}/${name}`,\n isDirectory,\n size: parseInt(parts[4]) || 0,\n lastModified: new Date()\n };\n } else {\n // Parse simple ls output (just filenames)\n const name = line.trim();\n return {\n name,\n path: `${path}/${name}`,\n isDirectory: false, // Can't determine from simple ls\n size: 0,\n lastModified: new Date()\n };\n }\n });\n },\n\n exists: async (sandbox: any, path: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<boolean> => {\n const result = await runCommand(sandbox, 'test', ['-e', path]);\n return result.exitCode === 0; // Exit code 0 means file exists\n },\n\n remove: async (sandbox: any, path: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<void> => {\n const result = await runCommand(sandbox, 'rm', ['-rf', path]);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to remove ${path}: ${result.stderr}`);\n }\n }\n};\n\n/**\n * Auto-generated filesystem implementation that throws \"not supported\" errors\n */\nclass UnsupportedFileSystem implements SandboxFileSystem {\n private readonly providerName: string;\n\n constructor(providerName: string) {\n this.providerName = providerName;\n }\n\n async readFile(_path: string): Promise<string> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n\n async writeFile(_path: string, _content: string): Promise<void> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n\n async mkdir(_path: string): Promise<void> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n\n async readdir(_path: string): Promise<FileEntry[]> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n\n async exists(_path: string): Promise<boolean> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n\n async remove(_path: string): Promise<void> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n}\n\n\n\n/**\n * Auto-generated filesystem implementation that wraps provider methods\n */\nclass SupportedFileSystem<TSandbox> implements SandboxFileSystem {\n constructor(\n private sandbox: TSandbox,\n private methods: NonNullable<SandboxMethods<TSandbox>['filesystem']>,\n private allMethods: SandboxMethods<TSandbox>\n ) {}\n\n async readFile(path: string): Promise<string> {\n return this.methods.readFile(this.sandbox, path, this.allMethods.runCommand);\n }\n\n async writeFile(path: string, content: string): Promise<void> {\n return this.methods.writeFile(this.sandbox, path, content, this.allMethods.runCommand);\n }\n\n async mkdir(path: string): Promise<void> {\n return this.methods.mkdir(this.sandbox, path, this.allMethods.runCommand);\n }\n\n async readdir(path: string): Promise<FileEntry[]> {\n return this.methods.readdir(this.sandbox, path, this.allMethods.runCommand);\n }\n\n async exists(path: string): Promise<boolean> {\n return this.methods.exists(this.sandbox, path, this.allMethods.runCommand);\n }\n\n async remove(path: string): Promise<void> {\n return this.methods.remove(this.sandbox, path, this.allMethods.runCommand);\n }\n}\n\n\n\n\n\n/**\n * Generated sandbox class - implements the Sandbox interface\n */\nclass GeneratedSandbox<TSandbox = any> implements Sandbox<TSandbox> {\n readonly sandboxId: string;\n readonly provider: string;\n readonly filesystem: SandboxFileSystem;\n\n constructor(\n private sandbox: TSandbox,\n sandboxId: string,\n providerName: string,\n private methods: SandboxMethods<TSandbox>,\n private config: any,\n private destroyMethod: (config: any, sandboxId: string) => Promise<void>,\n private providerInstance: Provider\n ) {\n this.sandboxId = sandboxId;\n this.provider = providerName;\n\n // Auto-detect filesystem support\n if (methods.filesystem) {\n this.filesystem = new SupportedFileSystem(sandbox, methods.filesystem, methods);\n } else {\n this.filesystem = new UnsupportedFileSystem(providerName);\n }\n }\n\n getInstance(): TSandbox {\n // Use provider-specific typed getInstance if available\n if (this.methods.getInstance) {\n return this.methods.getInstance(this.sandbox);\n }\n // Fallback to returning the sandbox directly\n return this.sandbox;\n }\n\n async runCode(code: string, runtime?: Runtime): Promise<ExecutionResult> {\n return await this.methods.runCode(this.sandbox, code, runtime, this.config);\n }\n\n async runCommand(command: string, args?: string[], options?: RunCommandOptions): Promise<ExecutionResult> {\n return await this.methods.runCommand(this.sandbox, command, args, options);\n }\n\n async getInfo(): Promise<SandboxInfo> {\n return await this.methods.getInfo(this.sandbox);\n }\n\n async getUrl(options: { port: number; protocol?: string }): Promise<string> {\n return await this.methods.getUrl(this.sandbox, options);\n }\n\n getProvider(): Provider<TSandbox> {\n return this.providerInstance;\n }\n\n async kill(): Promise<void> {\n // For backward compatibility, kill() delegates to destroy()\n await this.destroy();\n }\n\n async destroy(): Promise<void> {\n // Destroy via the provider's destroy method using our sandboxId\n await this.destroyMethod(this.config, this.sandboxId);\n }\n}\n\n/**\n * Auto-generated Sandbox Manager implementation\n */\nclass GeneratedSandboxManager<TSandbox, TConfig> implements ProviderSandboxManager<TSandbox> {\n private activeSandboxes: Map<string, GeneratedSandbox<TSandbox>> = new Map();\n\n constructor(\n private config: TConfig,\n private providerName: string,\n private methods: SandboxMethods<TSandbox, TConfig>,\n private providerInstance: Provider\n ) {}\n\n async create(options?: CreateSandboxOptions): Promise<Sandbox<TSandbox>> {\n // Default to 'node' runtime if not specified for consistency across providers\n const optionsWithDefaults = { runtime: 'node' as Runtime, ...options };\n const result = await this.methods.create(this.config, optionsWithDefaults);\n const sandbox = new GeneratedSandbox<TSandbox>(\n result.sandbox,\n result.sandboxId,\n this.providerName,\n this.methods,\n this.config,\n this.methods.destroy,\n this.providerInstance\n );\n \n this.activeSandboxes.set(result.sandboxId, sandbox);\n return sandbox;\n }\n\n async getById(sandboxId: string): Promise<Sandbox<TSandbox> | null> {\n // Check active sandboxes first\n const existing = this.activeSandboxes.get(sandboxId);\n if (existing) {\n return existing;\n }\n\n // Try to reconnect\n const result = await this.methods.getById(this.config, sandboxId);\n if (!result) {\n return null;\n }\n\n const sandbox = new GeneratedSandbox<TSandbox>(\n result.sandbox,\n result.sandboxId,\n this.providerName,\n this.methods,\n this.config,\n this.methods.destroy,\n this.providerInstance\n );\n \n this.activeSandboxes.set(result.sandboxId, sandbox);\n return sandbox;\n }\n\n async list(): Promise<Sandbox<TSandbox>[]> {\n const results = await this.methods.list(this.config);\n const sandboxes: Sandbox[] = [];\n\n for (const result of results) {\n let sandbox = this.activeSandboxes.get(result.sandboxId);\n if (!sandbox) {\n sandbox = new GeneratedSandbox<TSandbox>(\n result.sandbox,\n result.sandboxId,\n this.providerName,\n this.methods,\n this.config,\n this.methods.destroy,\n this.providerInstance\n );\n this.activeSandboxes.set(result.sandboxId, sandbox);\n }\n sandboxes.push(sandbox);\n }\n\n return sandboxes;\n }\n\n async destroy(sandboxId: string): Promise<void> {\n await this.methods.destroy(this.config, sandboxId);\n this.activeSandboxes.delete(sandboxId);\n }\n}\n\n/**\n * Auto-generated Template Manager implementation\n */\nclass GeneratedTemplateManager<TTemplate, TConfig> implements ProviderTemplateManager<TTemplate> {\n constructor(\n private config: TConfig,\n private methods: TemplateMethods<TTemplate, TConfig>\n ) {}\n\n async create(options: CreateTemplateOptions | any): Promise<TTemplate> {\n return await this.methods.create(this.config, options);\n }\n\n async list(options?: ListTemplatesOptions): Promise<TTemplate[]> {\n return await this.methods.list(this.config, options);\n }\n\n async delete(templateId: string): Promise<void> {\n return await this.methods.delete(this.config, templateId);\n }\n}\n\n/**\n * Auto-generated Snapshot Manager implementation\n */\nclass GeneratedSnapshotManager<TSnapshot, TConfig> implements ProviderSnapshotManager<TSnapshot> {\n constructor(\n private config: TConfig,\n private methods: SnapshotMethods<TSnapshot, TConfig>\n ) {}\n\n async create(sandboxId: string, options?: CreateSnapshotOptions): Promise<TSnapshot> {\n return await this.methods.create(this.config, sandboxId, options);\n }\n\n async list(options?: ListSnapshotsOptions): Promise<TSnapshot[]> {\n return await this.methods.list(this.config, options);\n }\n\n async delete(snapshotId: string): Promise<void> {\n return await this.methods.delete(this.config, snapshotId);\n }\n}\n\n/**\n * Auto-generated Provider implementation\n */\nclass GeneratedProvider<TSandbox, TConfig, TTemplate, TSnapshot> implements Provider<TSandbox, TTemplate, TSnapshot> {\n readonly name: string;\n readonly sandbox: ProviderSandboxManager<TSandbox>;\n readonly template?: ProviderTemplateManager<TTemplate>;\n readonly snapshot?: ProviderSnapshotManager<TSnapshot>;\n readonly __sandboxType!: TSandbox; // Phantom type for TypeScript inference\n\n constructor(config: TConfig, providerConfig: ProviderConfig<TSandbox, TConfig, TTemplate, TSnapshot>) {\n this.name = providerConfig.name;\n this.sandbox = new GeneratedSandboxManager(\n config,\n providerConfig.name,\n providerConfig.methods.sandbox,\n this\n );\n\n // Initialize optional managers if methods are provided\n if (providerConfig.methods.template) {\n this.template = new GeneratedTemplateManager(config, providerConfig.methods.template);\n }\n \n if (providerConfig.methods.snapshot) {\n this.snapshot = new GeneratedSnapshotManager(config, providerConfig.methods.snapshot);\n }\n }\n\n getSupportedRuntimes(): Runtime[] {\n // For now, all providers support both node and python\n // In the future, this could be configurable per provider\n return ['node', 'python'];\n }\n}\n\n/**\n * Create a provider from method definitions\n * \n * Auto-generates all boilerplate classes and provides feature detection\n * based on which methods are implemented.\n */\nexport function createProvider<TSandbox, TConfig = any, TTemplate = any, TSnapshot = any>(\n providerConfig: ProviderConfig<TSandbox, TConfig, TTemplate, TSnapshot>\n): (config: TConfig) => Provider<TSandbox, TTemplate, TSnapshot> {\n // Auto-inject default filesystem methods if none provided\n if (!providerConfig.methods.sandbox.filesystem) {\n providerConfig.methods.sandbox.filesystem = defaultFilesystemMethods;\n }\n\n return (config: TConfig) => {\n return new GeneratedPro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nC,WAAK,WAAW,IAAI,yBAAyB,QAAQ,eAAe,QAAQ,QAAQ;AAAA,IACtF;AAEA,QAAI,eAAe,QAAQ,UAAU;AACnC,WAAK,WAAW,IAAI,yBAAyB,QAAQ,eAAe,QAAQ,QAAQ;AAAA,IACtF;AAAA,EACF;AAAA,EAEA,uBAAkC;AAGhC,WAAO,CAAC,QAAQ,QAAQ;AAAA,EAC1B;AACF;AAQO,SAAS,eACd,gBAC+D;AAE/D,MAAI,CAAC,eAAe,QAAQ,QAAQ,YAAY;AAC9C,mBAAe,QAAQ,QAAQ,aAAa;AAAA,EAC9C;AAEA,SAAO,CAAC,WAAoB;AAC1B,WAAO,IAAI,kBAAkB,QAAQ,cAAc;AAAA,EACrD;AACF;","names":["sandbox"]}
package/dist/index.mjs CHANGED
@@ -25,7 +25,8 @@ async function authorizeApiKey(apiKey) {
25
25
  })
26
26
  });
27
27
  if (!response.ok) {
28
- throw new Error(`License authorization failed: ${response.statusText}`);
28
+ const errorText = await response.text().catch(() => response.statusText);
29
+ throw new Error(`License authorization failed (${response.status}): ${errorText}`);
29
30
  }
30
31
  const data = await response.json();
31
32
  if (!data.access_token) {
@@ -43,44 +44,110 @@ async function authorizeApiKey(apiKey) {
43
44
  preview_url: data.preview_url
44
45
  };
45
46
  } catch (error) {
46
- throw new Error(`Failed to authorize API key: ${error}`);
47
+ if (error instanceof Error && error.message.includes("License authorization failed")) {
48
+ throw error;
49
+ }
50
+ throw new Error(`Failed to authorize API key (network error): ${error instanceof Error ? error.message : String(error)}`);
51
+ }
52
+ }
53
+ async function isCommandAvailable(sandbox, command) {
54
+ const result = await sandbox.runCommand("sh", ["-c", `command -v ${command}`]);
55
+ return result.exitCode === 0;
56
+ }
57
+ async function detectPackageManager(sandbox) {
58
+ if (await isCommandAvailable(sandbox, "apk")) {
59
+ return "apk";
60
+ }
61
+ if (await isCommandAvailable(sandbox, "apt-get")) {
62
+ return "apt";
63
+ }
64
+ return null;
65
+ }
66
+ async function ensureDependencies(sandbox) {
67
+ const hasCurl = await isCommandAvailable(sandbox, "curl");
68
+ const hasBash = await isCommandAvailable(sandbox, "bash");
69
+ if (hasCurl && hasBash) {
70
+ return;
71
+ }
72
+ const packageManager = await detectPackageManager(sandbox);
73
+ if (!packageManager) {
74
+ throw new Error(
75
+ `Missing required tools (curl: ${hasCurl}, bash: ${hasBash}), but no supported package manager found.
76
+ Supported package managers: apk (Alpine), apt-get (Debian/Ubuntu).
77
+ Please use a sandbox image that includes curl and bash, or install them manually first.`
78
+ );
79
+ }
80
+ let installResult;
81
+ if (packageManager === "apk") {
82
+ installResult = await sandbox.runCommand("sh", ["-c", "apk add --no-cache curl bash 2>&1"]);
83
+ } else {
84
+ installResult = await sandbox.runCommand("sh", ["-c", "apt-get update -qq && apt-get install -qq -y curl bash 2>&1"]);
85
+ }
86
+ if (installResult.exitCode !== 0) {
87
+ throw new Error(
88
+ `Failed to install curl and bash using ${packageManager}.
89
+ Install output: ${installResult.stderr || installResult.stdout}
90
+ Please install curl and bash manually or use a different sandbox image.`
91
+ );
92
+ }
93
+ }
94
+ async function isComputeInstalled(sandbox) {
95
+ const result = await sandbox.runCommand("sh", ["-c", 'test -f /usr/local/bin/compute && echo "exists" || echo "missing"']);
96
+ return result.stdout?.trim() === "exists";
97
+ }
98
+ async function downloadInstallScript(sandbox) {
99
+ const downloadResult = await sandbox.runCommand("sh", ["-c", "curl -fsSL https://computesdk.com/install.sh -o /tmp/compute-install.sh 2>&1"]);
100
+ if (downloadResult.exitCode !== 0) {
101
+ const errorOutput = downloadResult.stderr || downloadResult.stdout || "unknown error";
102
+ throw new Error(
103
+ `Failed to download install script from https://computesdk.com/install.sh: ${errorOutput}`
104
+ );
105
+ }
106
+ }
107
+ async function runInstallScript(sandbox, accessToken) {
108
+ const installCommand = accessToken ? `bash /tmp/compute-install.sh --non-interactive --access-token "${accessToken}" --location /usr/local/bin` : `bash /tmp/compute-install.sh --non-interactive --location /usr/local/bin`;
109
+ const installResult = await sandbox.runCommand("bash", ["-c", installCommand]);
110
+ if (installResult.exitCode !== 0) {
111
+ const errorOutput = installResult.stderr || installResult.stdout || "unknown error";
112
+ throw new Error(`Failed to install compute CLI: ${errorOutput}`);
47
113
  }
48
114
  }
49
115
  async function installComputeInSandbox(sandbox, config) {
50
- try {
51
- console.log("Installing and starting compute CLI in sandbox...");
52
- let authResponse = null;
53
- let accessToken = config?.accessToken;
54
- if (config?.apiKey && !accessToken) {
55
- console.log("Authorizing API key and getting access token...");
56
- authResponse = await authorizeApiKey(config.apiKey);
57
- accessToken = authResponse.access_token;
58
- }
59
- let installCommand = "curl -fsSL https://computesdk.com/install.sh | sh";
60
- if (accessToken) {
61
- installCommand = `curl -fsSL https://computesdk.com/install.sh | sh -s -- --access-token ${accessToken}`;
62
- }
63
- const result = await sandbox.runCommand("sh", ["-c", installCommand]);
64
- if (result.exitCode !== 0) {
65
- throw new Error(`Failed to install and start compute CLI: ${result.stderr}`);
66
- }
67
- console.log("Compute CLI installed successfully");
116
+ let authResponse = null;
117
+ let accessToken = config?.accessToken;
118
+ if (config?.apiKey && !accessToken) {
119
+ authResponse = await authorizeApiKey(config.apiKey);
120
+ accessToken = authResponse.access_token;
121
+ }
122
+ if (await isComputeInstalled(sandbox)) {
68
123
  return authResponse;
69
- } catch (error) {
70
- throw new Error(`Failed to install compute CLI in sandbox: ${error}`);
71
124
  }
125
+ await ensureDependencies(sandbox);
126
+ await downloadInstallScript(sandbox);
127
+ await runInstallScript(sandbox, accessToken);
128
+ if (!await isComputeInstalled(sandbox)) {
129
+ throw new Error("Compute binary not found at /usr/local/bin/compute after installation");
130
+ }
131
+ return authResponse;
72
132
  }
73
- async function waitForComputeReady(client, maxRetries = 10, delayMs = 1e3) {
133
+ async function waitForComputeReady(client, maxRetries = 30, delayMs = 2e3) {
134
+ let lastError = null;
74
135
  for (let i = 0; i < maxRetries; i++) {
75
136
  try {
76
137
  await client.health();
77
- console.log("Compute CLI is ready");
78
138
  return;
79
139
  } catch (error) {
140
+ lastError = error instanceof Error ? error : new Error(String(error));
80
141
  if (i === maxRetries - 1) {
81
- throw new Error(`Compute CLI failed to start after ${maxRetries} attempts: ${error}`);
142
+ throw new Error(
143
+ `Compute CLI failed to start after ${maxRetries} attempts (${maxRetries * delayMs / 1e3}s).
144
+ Last error: ${lastError.message}
145
+ This could indicate:
146
+ 1. The compute daemon failed to start in the sandbox
147
+ 2. The sandbox_url is incorrect or unreachable
148
+ 3. The sandbox is taking longer than expected to initialize`
149
+ );
82
150
  }
83
- console.log(`Waiting for compute CLI to start... (attempt ${i + 1}/${maxRetries})`);
84
151
  await new Promise((resolve) => setTimeout(resolve, delayMs));
85
152
  }
86
153
  }
@@ -113,9 +180,13 @@ var ComputeManager = class {
113
180
  const provider = params && "provider" in params && params.provider ? params.provider : this.getDefaultProvider();
114
181
  const options = params?.options;
115
182
  const sandbox = await provider.sandbox.create(options);
116
- const authResponse = await installComputeInSandbox(sandbox, this.computeAuth);
117
- const finalSandbox = authResponse ? await this.wrapWithComputeClient(sandbox, authResponse) : sandbox;
118
- return finalSandbox;
183
+ if (this.computeAuth.apiKey || this.computeAuth.accessToken) {
184
+ const authResponse = await installComputeInSandbox(sandbox, this.computeAuth);
185
+ if (authResponse) {
186
+ return await this.wrapWithComputeClient(sandbox, authResponse);
187
+ }
188
+ }
189
+ return sandbox;
119
190
  },
120
191
  /**
121
192
  * Get an existing sandbox by ID from a provider (or default provider if configured)
@@ -210,7 +281,8 @@ var ComputeManager = class {
210
281
  sandboxUrl: authResponse.sandbox_url,
211
282
  sandboxId: originalSandbox.sandboxId,
212
283
  provider: originalSandbox.provider,
213
- token: authResponse.access_token
284
+ token: authResponse.access_token,
285
+ WebSocket: globalThis.WebSocket
214
286
  });
215
287
  await waitForComputeReady(client);
216
288
  const wrappedSandbox = Object.assign(client, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types/sandbox.ts","../src/compute.ts","../src/request-handler.ts","../src/factory.ts"],"sourcesContent":["/**\n * Sandbox Types\n * \n * Types related to sandbox execution, filesystem, terminal operations\n */\n\n// Forward declaration to avoid circular dependency\ninterface Provider {\n readonly name: string;\n readonly sandbox: any; // Will be properly typed when imported together\n}\n\n/**\n * Type mapping for provider names to their sandbox types\n * Manually defined for known providers since declaration merging isn't working reliably\n */\nexport interface ProviderSandboxTypeMap {\n e2b: any; // We can't import the E2B type directly, but we'll handle it differently\n vercel: any;\n daytona: any;\n}\n\n/**\n * Utility type to extract the native instance type from a provider\n * Uses provider name and manual type inference\n */\nexport type ExtractSandboxInstanceType<TProvider extends Provider> = \n TProvider extends { readonly name: 'e2b' }\n ? any // For now, let's just try to make the runtime casting work\n : TProvider extends { readonly name: 'vercel' }\n ? any\n : TProvider extends { readonly name: 'daytona' }\n ? any\n : any;\n\n/**\n * Supported runtime environments\n */\nexport type Runtime = 'node' | 'python';\n\n/**\n * Sandbox status types\n */\nexport type SandboxStatus = 'running' | 'stopped' | 'error';\n\n/**\n * Options for running commands\n */\nexport interface RunCommandOptions {\n /** Run command in background (non-blocking) */\n background?: boolean;\n}\n\n/**\n * Result of code execution\n */\nexport interface ExecutionResult {\n /** Standard output from the execution */\n stdout: string;\n /** Standard error from the execution */\n stderr: string;\n /** Exit code from the execution */\n exitCode: number;\n /** Time taken for execution in milliseconds */\n executionTime: number;\n /** ID of the sandbox where the code was executed */\n sandboxId: string;\n /** Provider that executed the code */\n provider: string;\n /** Process ID for background jobs (if applicable) */\n pid?: number;\n /** Whether this command is running in background */\n isBackground?: boolean;\n}\n\n/**\n * Information about a sandbox\n */\nexport interface SandboxInfo {\n /** Unique identifier for the sandbox */\n id: string;\n /** Provider hosting the sandbox */\n provider: string;\n /** Runtime environment in the sandbox */\n runtime: Runtime;\n /** Current status of the sandbox */\n status: SandboxStatus;\n /** When the sandbox was created */\n createdAt: Date;\n /** Execution timeout in milliseconds */\n timeout: number;\n /** Additional provider-specific metadata */\n metadata?: Record<string, any>;\n}\n\n/**\n * Options for creating a sandbox\n */\nexport interface CreateSandboxOptions {\n /** Runtime environment (defaults to 'node' if not specified) */\n runtime?: Runtime;\n /** Execution timeout in milliseconds */\n timeout?: number;\n /** Custom sandbox ID (if supported by provider) */\n sandboxId?: string;\n /** Template ID for sandbox creation (provider-specific) */\n templateId?: string;\n /** Additional metadata for the sandbox */\n metadata?: Record<string, any>;\n /** Domain for sandbox connection (provider-specific) */\n domain?: string;\n /** Environment variables for the sandbox */\n envs?: Record<string, string>;\n}\n\n/**\n * File system entry information\n */\nexport interface FileEntry {\n /** File/directory name */\n name: string;\n /** Full path to the entry */\n path: string;\n /** Whether this is a directory */\n isDirectory: boolean;\n /** File size in bytes (0 for directories) */\n size: number;\n /** Last modified timestamp */\n lastModified: Date;\n}\n\n/**\n * File system interface for sandbox operations\n */\nexport interface SandboxFileSystem {\n /** Read file contents */\n readFile(path: string): Promise<string>;\n /** Write file contents */\n writeFile(path: string, content: string): Promise<void>;\n /** Create directory */\n mkdir(path: string): Promise<void>;\n /** List directory contents */\n readdir(path: string): Promise<FileEntry[]>;\n /** Check if file/directory exists */\n exists(path: string): Promise<boolean>;\n /** Remove file or directory */\n remove(path: string): Promise<void>;\n}\n\n/**\n * Error thrown when a command exits with a non-zero status\n */\nexport class CommandExitError extends Error {\n name = 'CommandExitError';\n constructor(public result: {\n exitCode: number;\n stdout: string;\n stderr: string;\n error: boolean;\n }) {\n super(`Command exited with code ${result.exitCode}`);\n }\n}\n\n/**\n * Type guard to check if an error is a CommandExitError\n */\nexport function isCommandExitError(error: unknown): error is CommandExitError {\n return (\n typeof error === 'object' &&\n error !== null &&\n 'name' in error &&\n error.name === 'CommandExitError' &&\n 'result' in error\n );\n}\n\n\n\n\n\n/**\n * Base sandbox interface - what developers interact with\n */\nexport interface Sandbox<TSandbox = any> {\n /** Unique identifier for the sandbox */\n readonly sandboxId: string;\n /** Provider that created this sandbox */\n readonly provider: string;\n\n /** Execute code in the sandbox */\n runCode(code: string, runtime?: Runtime): Promise<ExecutionResult>;\n /** Execute shell commands */\n runCommand(command: string, args?: string[], options?: RunCommandOptions): Promise<ExecutionResult>;\n /** Get information about the sandbox */\n getInfo(): Promise<SandboxInfo>;\n /** Get URL for accessing the sandbox on a specific port */\n getUrl(options: { port: number; protocol?: string }): Promise<string>;\n /** Get the provider instance that created this sandbox */\n getProvider(): import('./provider').Provider<TSandbox>;\n /** Get the native provider sandbox instance with proper typing */\n getInstance(): TSandbox;\n /** Kill the sandbox */\n kill(): Promise<void>;\n /** Destroy the sandbox and clean up resources */\n destroy(): Promise<void>;\n\n /** File system operations */\n readonly filesystem: SandboxFileSystem;\n}\n\n/**\n * Extract the sandbox type from a provider\n */\ntype ExtractProviderSandboxType<TProvider extends Provider> = TProvider extends { readonly __sandboxType: infer TSandbox } ? TSandbox : any;\n\n/**\n * Typed sandbox interface that preserves the provider's native instance type\n */\nexport interface TypedSandbox<TProvider extends Provider> extends Omit<Sandbox<ExtractProviderSandboxType<TProvider>>, 'getProvider'> {\n /** Get the provider instance that created this sandbox with proper typing */\n getProvider(): TProvider;\n /** Get the native provider sandbox instance with proper typing */\n getInstance(): ExtractProviderSandboxType<TProvider>;\n}\n\n/**\n * Enhanced sandbox type that includes ComputeClient features\n *\n * When a sandbox is created with an API key/JWT, it gets wrapped with ComputeClient\n * which adds powerful features like WebSocket terminals, file watchers, and signals.\n *\n * @example\n * ```typescript\n * const sandbox = await compute.sandbox.create();\n *\n * // ComputeClient features (only available when API key is configured)\n * const terminal = await sandbox.createTerminal();\n * const watcher = await sandbox.createWatcher('/home/project');\n * const signals = await sandbox.startSignals();\n *\n * // Original sandbox features still work\n * await sandbox.runCommand('ls');\n * const instance = sandbox.getInstance();\n * ```\n */\nexport type ComputeEnhancedSandbox<TSandbox = any> = Sandbox<TSandbox> & {\n /** The original provider sandbox instance */\n __originalSandbox: Sandbox<TSandbox>;\n\n // ComputeClient enhanced features\n /** Create a persistent terminal session with WebSocket integration */\n createTerminal(shell?: string, encoding?: 'raw' | 'base64'): Promise<import('@computesdk/client').Terminal>;\n /** Create a file watcher with real-time change notifications */\n createWatcher(path: string, options?: {\n includeContent?: boolean;\n ignored?: string[];\n encoding?: 'raw' | 'base64';\n }): Promise<import('@computesdk/client').FileWatcher>;\n /** Start the signal service for port and error monitoring */\n startSignals(): Promise<import('@computesdk/client').SignalService>;\n /** Execute a one-off command without creating a persistent terminal */\n execute(options: { command: string; shell?: string }): Promise<any>;\n /** List all active terminals */\n listTerminals(): Promise<any[]>;\n /** Get terminal by ID */\n getTerminal(id: string): Promise<any>;\n /** List all active file watchers */\n listWatchers(): Promise<any>;\n /** Get file watcher by ID */\n getWatcher(id: string): Promise<any>;\n /** Get signal service status */\n getSignalStatus(): Promise<any>;\n /** Create a session token (requires access token) */\n createSessionToken(options?: { description?: string; expiresIn?: number }): Promise<any>;\n /** List all session tokens (requires access token) */\n listSessionTokens(): Promise<any>;\n /** Get session token details (requires access token) */\n getSessionToken(tokenId: string): Promise<any>;\n /** Revoke a session token (requires access token) */\n revokeSessionToken(tokenId: string): Promise<void>;\n /** Create a magic link for browser authentication (requires access token) */\n createMagicLink(options?: { redirectUrl?: string }): Promise<any>;\n /** Check authentication status */\n getAuthStatus(): Promise<any>;\n /** Get authentication information */\n getAuthInfo(): Promise<any>;\n /** Set authentication token manually */\n setToken(token: string): void;\n /** Get current authentication token */\n getToken(): string | null;\n /** Get current sandbox URL */\n getSandboxUrl(): string;\n /** Disconnect WebSocket connection */\n disconnect(): Promise<void>;\n}\n\n/**\n * Typed enhanced sandbox that preserves both provider typing and ComputeClient features\n */\nexport type TypedEnhancedSandbox<TProvider extends Provider> =\n ComputeEnhancedSandbox<ExtractProviderSandboxType<TProvider>> &\n Omit<TypedSandbox<TProvider>, keyof Sandbox>;","/**\n * Compute Singleton - Main API Orchestrator\n *\n * Provides the unified compute.* API and delegates to specialized managers\n */\n\nimport { ComputeClient } from '@computesdk/client';\nimport type { ComputeAPI, CreateSandboxParams, CreateSandboxParamsWithOptionalProvider, ComputeConfig, Sandbox, Provider, TypedSandbox, TypedComputeAPI, ComputeEnhancedSandbox, TypedEnhancedSandbox } from './types';\n\n/**\n * Authorization response from license server\n */\ninterface AuthorizationResponse {\n access_token: string;\n sandbox_url: string;\n preview_url: string;\n}\n\n/**\n * Authorize license key and get JWT token + URLs from license server\n */\nasync function authorizeApiKey(apiKey: string): Promise<AuthorizationResponse> {\n try {\n const response = await fetch('https://preview.computesdk.com/__api/license/authorize', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n key: apiKey,\n increment_usage: 1\n })\n });\n\n if (!response.ok) {\n throw new Error(`License authorization failed: ${response.statusText}`);\n }\n\n const data = await response.json();\n\n if (!data.access_token) {\n throw new Error('No access token received from license server');\n }\n\n if (!data.sandbox_url) {\n throw new Error('No sandbox_url received from license server');\n }\n\n if (!data.preview_url) {\n throw new Error('No preview_url received from license server');\n }\n\n return {\n access_token: data.access_token,\n sandbox_url: data.sandbox_url,\n preview_url: data.preview_url\n };\n } catch (error) {\n throw new Error(`Failed to authorize API key: ${error}`);\n }\n}\n\n/**\n * Install and start compute CLI inside a sandbox\n */\nasync function installComputeInSandbox(\n sandbox: Sandbox,\n config?: { apiKey?: string; accessToken?: string }\n): Promise<AuthorizationResponse | null> {\n try {\n console.log('Installing and starting compute CLI in sandbox...');\n\n // Get access token and URLs from API key if provided\n let authResponse: AuthorizationResponse | null = null;\n let accessToken = config?.accessToken;\n\n if (config?.apiKey && !accessToken) {\n console.log('Authorizing API key and getting access token...');\n authResponse = await authorizeApiKey(config.apiKey);\n accessToken = authResponse.access_token;\n }\n\n // Build install command with authentication\n let installCommand = 'curl -fsSL https://computesdk.com/install.sh | sh';\n\n if (accessToken) {\n installCommand = `curl -fsSL https://computesdk.com/install.sh | sh -s -- --access-token ${accessToken}`;\n }\n\n // Run the install script (it will handle installation and starting compute)\n const result = await sandbox.runCommand('sh', ['-c', installCommand]);\n\n if (result.exitCode !== 0) {\n throw new Error(`Failed to install and start compute CLI: ${result.stderr}`);\n }\n\n console.log('Compute CLI installed successfully');\n\n return authResponse;\n } catch (error) {\n throw new Error(`Failed to install compute CLI in sandbox: ${error}`);\n }\n}\n\n/**\n * Wait for compute CLI to be ready by polling the health endpoint\n */\nasync function waitForComputeReady(client: ComputeClient, maxRetries = 10, delayMs = 1000): Promise<void> {\n for (let i = 0; i < maxRetries; i++) {\n try {\n await client.health();\n console.log('Compute CLI is ready');\n return;\n } catch (error) {\n if (i === maxRetries - 1) {\n throw new Error(`Compute CLI failed to start after ${maxRetries} attempts: ${error}`);\n }\n console.log(`Waiting for compute CLI to start... (attempt ${i + 1}/${maxRetries})`);\n await new Promise(resolve => setTimeout(resolve, delayMs));\n }\n }\n}\n\n/**\n * Compute singleton implementation - orchestrates all compute operations\n */\nclass ComputeManager implements ComputeAPI {\n private config: ComputeConfig | null = null;\n private computeAuth: { apiKey?: string; accessToken?: string } = {};\n\n /**\n * Set default configuration with generic type preservation\n */\n setConfig<TProvider extends Provider>(config: ComputeConfig<TProvider>): void {\n // Validate that at least one provider is specified\n if (!config.defaultProvider && !config.provider) {\n throw new Error('Either defaultProvider or provider must be specified in setConfig');\n }\n\n // Handle backwards compatibility: if both are provided, defaultProvider takes precedence\n if (config.defaultProvider && config.provider) {\n console.warn('Both defaultProvider and provider specified in setConfig. Using defaultProvider. The provider key is deprecated, please use defaultProvider instead.');\n }\n\n // Normalize config to always have both fields for internal use (backward compatibility)\n const actualProvider = config.defaultProvider || config.provider!;\n const accessToken = config.accessToken || config.jwt; // Support both accessToken and deprecated jwt\n this.config = {\n provider: actualProvider,\n defaultProvider: actualProvider,\n apiKey: config.apiKey,\n accessToken: accessToken\n };\n\n // Store compute auth credentials\n this.computeAuth = {\n apiKey: config.apiKey,\n accessToken: accessToken\n };\n }\n\n /**\n * Get current configuration\n */\n getConfig(): ComputeConfig | null {\n return this.config;\n }\n\n /**\n * Clear current configuration\n */\n clearConfig(): void {\n this.config = null;\n }\n\n /**\n * Get the default provider, throwing if not configured\n */\n private getDefaultProvider(): Provider {\n const provider = this.config?.defaultProvider || this.config?.provider;\n if (!provider) {\n throw new Error(\n 'No default provider configured. Either call compute.setConfig({ defaultProvider }) or pass provider explicitly.'\n );\n }\n return provider;\n }\n\n /**\n * Wrap a provider sandbox with ComputeClient while preserving the original sandbox\n * This adds powerful features like WebSocket terminals, file watchers, and signals\n */\n private async wrapWithComputeClient(originalSandbox: Sandbox, authResponse: AuthorizationResponse): Promise<ComputeEnhancedSandbox> {\n const client = new ComputeClient({\n sandboxUrl: authResponse.sandbox_url,\n sandboxId: originalSandbox.sandboxId,\n provider: originalSandbox.provider,\n token: authResponse.access_token\n });\n\n // Wait for compute CLI to be ready before returning\n await waitForComputeReady(client);\n\n // Store the original sandbox for getInstance() and getProvider() calls\n // We create a proxy-like object that delegates most calls to ComputeClient\n // but preserves access to the original provider sandbox\n const wrappedSandbox = Object.assign(client, {\n __originalSandbox: originalSandbox,\n\n // Override getInstance to return the original provider's instance\n getInstance: () => originalSandbox.getInstance(),\n\n // Override getProvider to return the original provider\n getProvider: () => originalSandbox.getProvider()\n });\n\n return wrappedSandbox as ComputeEnhancedSandbox;\n }\n\n sandbox = {\n /**\n * Create a sandbox from a provider (or default provider if configured)\n * \n * @example\n * ```typescript\n * import { e2b } from '@computesdk/e2b'\n * import { compute } from 'computesdk'\n * \n * // With explicit provider\n * const sandbox = await compute.sandbox.create({\n * provider: e2b({ apiKey: 'your-key' })\n * })\n * \n * // With default provider (both forms work)\n * compute.setConfig({ defaultProvider: e2b({ apiKey: 'your-key' }) })\n * const sandbox1 = await compute.sandbox.create({})\n * const sandbox2 = await compute.sandbox.create()\n * ```\n */\n create: async (params?: CreateSandboxParams | CreateSandboxParamsWithOptionalProvider): Promise<Sandbox | ComputeEnhancedSandbox> => {\n const provider = params && 'provider' in params && params.provider ? params.provider : this.getDefaultProvider();\n const options = params?.options;\n const sandbox = await provider.sandbox.create(options);\n\n // Install compute CLI in the sandbox with auth credentials if available\n const authResponse = await installComputeInSandbox(sandbox, this.computeAuth);\n\n // Wrap with ComputeClient if we have authorization info\n // This adds features like createTerminal(), createWatcher(), startSignals()\n const finalSandbox = authResponse\n ? await this.wrapWithComputeClient(sandbox, authResponse)\n : sandbox;\n\n return finalSandbox;\n },\n\n /**\n * Get an existing sandbox by ID from a provider (or default provider if configured)\n */\n getById: async (providerOrSandboxId: Provider | string, sandboxId?: string): Promise<Sandbox | null> => {\n if (typeof providerOrSandboxId === 'string') {\n // Called with just sandboxId, use default provider\n const provider = this.getDefaultProvider();\n return await provider.sandbox.getById(providerOrSandboxId);\n } else {\n // Called with provider and sandboxId\n if (!sandboxId) {\n throw new Error('sandboxId is required when provider is specified');\n }\n return await providerOrSandboxId.sandbox.getById(sandboxId);\n }\n },\n\n /**\n * List all active sandboxes from a provider (or default provider if configured)\n */\n list: async (provider?: Provider): Promise<Sandbox[]> => {\n const actualProvider = provider || this.getDefaultProvider();\n return await actualProvider.sandbox.list();\n },\n\n /**\n * Destroy a sandbox via a provider (or default provider if configured)\n */\n destroy: async (providerOrSandboxId: Provider | string, sandboxId?: string): Promise<void> => {\n if (typeof providerOrSandboxId === 'string') {\n // Called with just sandboxId, use default provider\n const provider = this.getDefaultProvider();\n return await provider.sandbox.destroy(providerOrSandboxId);\n } else {\n // Called with provider and sandboxId\n if (!sandboxId) {\n throw new Error('sandboxId is required when provider is specified');\n }\n return await providerOrSandboxId.sandbox.destroy(sandboxId);\n }\n }\n };\n\n // Future: compute.blob.*, compute.database.*, compute.git.* will be added here\n // blob = new BlobManager();\n // database = new DatabaseManager(); \n // git = new GitManager();\n\n\n}\n\n/**\n * Singleton instance - the main API (untyped)\n */\nexport const compute: ComputeAPI = new ComputeManager();\n\n\n\n/**\n * Create a compute instance with proper typing\n *\n * @example\n * ```typescript\n * import { e2b } from '@computesdk/e2b'\n * import { createCompute } from 'computesdk'\n *\n * // With API key (automatically gets access token from license server)\n * const compute = createCompute({\n * defaultProvider: e2b({ apiKey: 'your-key' }),\n * apiKey: 'computesdk_live_...' // Returns enhanced sandboxes\n * });\n *\n * // Or with direct access token\n * const compute2 = createCompute({\n * defaultProvider: e2b({ apiKey: 'your-key' }),\n * accessToken: 'your-access-token' // Returns enhanced sandboxes\n * });\n *\n * const sandbox = await compute.sandbox.create();\n * const instance = sandbox.getInstance(); // ✅ Properly typed E2B Sandbox!\n * await sandbox.createTerminal(); // ✅ Enhanced sandbox features!\n * ```\n */\nexport function createCompute<TProvider extends Provider>(\n config: ComputeConfig<TProvider> & { apiKey: string }\n): TypedComputeAPI<TProvider, true>;\nexport function createCompute<TProvider extends Provider>(\n config: ComputeConfig<TProvider> & { accessToken: string }\n): TypedComputeAPI<TProvider, true>;\nexport function createCompute<TProvider extends Provider>(\n config: ComputeConfig<TProvider> & { jwt: string }\n): TypedComputeAPI<TProvider, true>;\nexport function createCompute<TProvider extends Provider>(\n config: ComputeConfig<TProvider>\n): TypedComputeAPI<TProvider, false>;\nexport function createCompute<TProvider extends Provider>(\n config: ComputeConfig<TProvider>\n): TypedComputeAPI<TProvider, boolean> {\n const manager = new ComputeManager();\n\n // Set config directly without calling the public setConfig method\n const actualProvider = config.defaultProvider || config.provider!;\n const accessToken = config.accessToken || config.jwt; // Support both accessToken and deprecated jwt\n manager['config'] = {\n provider: actualProvider,\n defaultProvider: actualProvider,\n apiKey: config.apiKey,\n accessToken: accessToken\n };\n manager['computeAuth'] = {\n apiKey: config.apiKey,\n accessToken: accessToken\n };\n\n const isEnhanced = !!(config.apiKey || config.accessToken || config.jwt);\n\n return {\n setConfig: <T extends Provider>(cfg: ComputeConfig<T>) => createCompute(cfg),\n getConfig: () => manager.getConfig(),\n clearConfig: () => manager.clearConfig(),\n\n sandbox: {\n create: async (params?: Omit<CreateSandboxParamsWithOptionalProvider, 'provider'>) => {\n const sandbox = await manager.sandbox.create(params);\n // If API key/JWT is configured, the sandbox will be enhanced with ComputeClient features\n // Cast to the appropriate type based on whether it's enhanced or not\n if (isEnhanced) {\n return sandbox as TypedEnhancedSandbox<TProvider>;\n }\n return sandbox as TypedSandbox<TProvider>;\n },\n\n getById: async (sandboxId: string) => {\n const sandbox = await manager.sandbox.getById(sandboxId);\n if (!sandbox) return null;\n // Type depends on whether auth is configured\n if (isEnhanced) {\n return sandbox as TypedEnhancedSandbox<TProvider>;\n }\n return sandbox as TypedSandbox<TProvider>;\n },\n\n list: async () => {\n const sandboxes = await manager.sandbox.list();\n // Type depends on whether auth is configured\n if (isEnhanced) {\n return sandboxes as TypedEnhancedSandbox<TProvider>[];\n }\n return sandboxes as TypedSandbox<TProvider>[];\n },\n\n destroy: async (sandboxId: string) => {\n return await manager.sandbox.destroy(sandboxId);\n }\n }\n } as TypedComputeAPI<TProvider, typeof isEnhanced>;\n}\n\n\n\n","/**\n * Simplified Request Handler for Web Framework Integration\n * \n * Handles JSON requests for sandbox and code execution operations.\n * Terminal support removed - will be re-added with WebSocket VM connections.\n */\n\nimport type { Provider, Runtime } from './types';\nimport { compute } from './compute';\n\n/**\n * Request structure supporting sandbox and code execution capabilities\n */\nexport interface ComputeRequest {\n /** Action in dot notation (e.g., 'compute.sandbox.create') */\n action: string;\n \n /** Parameters for the action */\n sandboxId?: string;\n code?: string;\n command?: string;\n args?: string[];\n runtime?: Runtime;\n path?: string;\n content?: string;\n \n /** Command options (for runCommand action) */\n commandOptions?: {\n background?: boolean;\n };\n \n /** Sandbox creation options */\n options?: {\n runtime?: Runtime;\n timeout?: number;\n sandboxId?: string;\n };\n}\n\n/**\n * Response structure for compute operations\n */\nexport interface ComputeResponse {\n success: boolean;\n error?: string;\n sandboxId: string;\n provider: string;\n [key: string]: any; // Allow any additional response data\n}\n\n/**\n * Execute compute action using targeted handling\n */\nasync function executeAction(body: ComputeRequest, provider: Provider): Promise<ComputeResponse> {\n try {\n const { action, sandboxId } = body;\n \n // Sandbox management operations\n if (action === 'compute.sandbox.create') {\n const sandbox = await compute.sandbox.create({\n provider,\n options: body.options || { runtime: 'python' }\n });\n return {\n success: true,\n sandboxId: sandbox.sandboxId,\n provider: provider.name\n };\n }\n \n if (action === 'compute.sandbox.list') {\n const sandboxes = await compute.sandbox.list(provider);\n return {\n success: true,\n sandboxId: '',\n provider: provider.name,\n sandboxes: sandboxes.map(sb => ({\n sandboxId: sb.sandboxId,\n provider: sb.provider\n }))\n };\n }\n \n if (action === 'compute.sandbox.destroy') {\n if (!sandboxId) {\n throw new Error('sandboxId is required for destroy action');\n }\n await compute.sandbox.destroy(provider, sandboxId);\n return {\n success: true,\n sandboxId,\n provider: provider.name\n };\n }\n \n // For sandbox instance methods, get the sandbox first\n if (!sandboxId) {\n throw new Error('sandboxId is required for this action');\n }\n \n const sandbox = await compute.sandbox.getById(provider, sandboxId);\n if (!sandbox) {\n throw new Error(`Sandbox ${sandboxId} not found`);\n }\n \n // Sandbox info\n if (action === 'compute.sandbox.getInfo') {\n const result = await sandbox.getInfo();\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n info: {\n id: result.id,\n provider: result.provider,\n runtime: result.runtime,\n status: result.status,\n createdAt: result.createdAt.toISOString(),\n timeout: result.timeout,\n metadata: result.metadata\n }\n };\n }\n \n // Code execution\n if (action === 'compute.sandbox.runCode') {\n if (!body.code) throw new Error('code is required');\n const result = await sandbox.runCode(body.code, body.runtime);\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n result: {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n executionTime: result.executionTime\n }\n };\n }\n \n if (action === 'compute.sandbox.runCommand') {\n if (!body.command) throw new Error('command is required');\n const result = await sandbox.runCommand(body.command, body.args, body.commandOptions);\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n result: {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n executionTime: result.executionTime,\n ...(result.isBackground && { isBackground: result.isBackground }),\n ...(result.pid && { pid: result.pid })\n }\n };\n }\n \n // Filesystem operations\n if (action === 'compute.sandbox.filesystem.readFile') {\n if (!body.path) throw new Error('path is required');\n const result = await sandbox.filesystem.readFile(body.path);\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n fileContent: result\n };\n }\n \n if (action === 'compute.sandbox.filesystem.writeFile') {\n if (!body.path) throw new Error('path is required');\n if (body.content === undefined) throw new Error('content is required');\n await sandbox.filesystem.writeFile(body.path, body.content);\n return { success: true, sandboxId, provider: provider.name };\n }\n \n if (action === 'compute.sandbox.filesystem.mkdir') {\n if (!body.path) throw new Error('path is required');\n await sandbox.filesystem.mkdir(body.path);\n return { success: true, sandboxId, provider: provider.name };\n }\n \n if (action === 'compute.sandbox.filesystem.readdir') {\n if (!body.path) throw new Error('path is required');\n const result = await sandbox.filesystem.readdir(body.path);\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n files: result.map((entry: any) => ({\n name: entry.name,\n path: entry.path,\n isDirectory: entry.isDirectory,\n size: entry.size,\n lastModified: entry.lastModified.toISOString()\n }))\n };\n }\n \n if (action === 'compute.sandbox.filesystem.exists') {\n if (!body.path) throw new Error('path is required');\n const result = await sandbox.filesystem.exists(body.path);\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n exists: result\n };\n }\n \n if (action === 'compute.sandbox.filesystem.remove') {\n if (!body.path) throw new Error('path is required');\n await sandbox.filesystem.remove(body.path);\n return { success: true, sandboxId, provider: provider.name };\n }\n \n throw new Error(`Unknown action: ${action}`);\n \n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n sandboxId: body.sandboxId || '',\n provider: provider.name\n };\n }\n}\n\n/**\n * Main request handler - handles HTTP requests and pre-parsed bodies\n */\nexport async function handleComputeRequest(\n params: HandleComputeRequestParams\n): Promise<ComputeResponse>;\nexport async function handleComputeRequest(\n requestOrBody: Request | ComputeRequest,\n provider: Provider\n): Promise<Response>;\nexport async function handleComputeRequest(\n paramsOrRequestOrBody: HandleComputeRequestParams | Request | ComputeRequest,\n provider?: Provider\n): Promise<ComputeResponse | Response> {\n // Handle object-style API\n if (typeof paramsOrRequestOrBody === 'object' && 'request' in paramsOrRequestOrBody && 'provider' in paramsOrRequestOrBody) {\n const params = paramsOrRequestOrBody as HandleComputeRequestParams;\n return await executeAction(params.request, params.provider);\n }\n \n // Handle original API\n if (!provider) {\n throw new Error('Provider is required when not using object-style API');\n }\n \n const requestOrBody = paramsOrRequestOrBody as Request | ComputeRequest;\n try {\n let body: ComputeRequest;\n \n if (requestOrBody instanceof Request) {\n // Handle HTTP method validation\n if (requestOrBody.method !== 'POST') {\n return Response.json({\n success: false,\n error: 'Only POST requests are supported',\n sandboxId: '',\n provider: provider.name\n }, { status: 405 });\n }\n \n // Parse JSON body with better error handling\n try {\n body = await requestOrBody.json();\n } catch (parseError) {\n return Response.json({\n success: false,\n error: 'Invalid JSON in request body',\n sandboxId: '',\n provider: provider.name\n }, { status: 400 });\n }\n } else {\n body = requestOrBody;\n }\n \n // Execute the action\n const result = await executeAction(body, provider);\n \n return Response.json(result, {\n status: result.success ? 200 : 500\n });\n \n } catch (error) {\n return Response.json({\n success: false,\n error: error instanceof Error ? error.message : 'Request handling failed',\n sandboxId: '',\n provider: provider.name\n }, { status: 500 });\n }\n}\n\n/**\n * Legacy export for backward compatibility\n */\nexport interface HandleComputeRequestParams {\n request: ComputeRequest;\n provider: Provider;\n}\n\nexport { handleComputeRequest as handleHttpComputeRequest };","/**\n * Provider Factory - Creates providers from method definitions\n * \n * Eliminates boilerplate by auto-generating Provider/Sandbox classes\n * from simple method definitions with automatic feature detection.\n */\n\nimport type {\n Provider,\n ProviderSandboxManager,\n ProviderTemplateManager,\n ProviderSnapshotManager,\n Sandbox,\n SandboxFileSystem,\n SandboxInfo,\n ExecutionResult,\n Runtime,\n CreateSandboxOptions,\n FileEntry,\n RunCommandOptions,\n CreateSnapshotOptions,\n ListSnapshotsOptions,\n CreateTemplateOptions,\n ListTemplatesOptions,\n} from './types/index.js';\n\n/**\n * Helper function to handle background command execution\n * Providers can use this to implement background job support\n */\nexport function createBackgroundCommand(command: string, args: string[] = [], options?: RunCommandOptions): { command: string; args: string[]; isBackground: boolean } {\n if (!options?.background) {\n return { command, args, isBackground: false };\n }\n\n // For background execution, we modify the command to run in background\n // Default approach: append & to make it run in background\n const fullCommand = args.length > 0 ? `${command} ${args.join(' ')}` : command;\n \n return {\n command: 'sh',\n args: ['-c', `${fullCommand} &`],\n isBackground: true\n };\n}\n\n/**\n * Flat sandbox method implementations - all operations in one place\n */\nexport interface SandboxMethods<TSandbox = any, TConfig = any> {\n // Collection operations (map to compute.sandbox.*)\n create: (config: TConfig, options?: CreateSandboxOptions) => Promise<{ sandbox: TSandbox; sandboxId: string }>;\n getById: (config: TConfig, sandboxId: string) => Promise<{ sandbox: TSandbox; sandboxId: string } | null>;\n list: (config: TConfig) => Promise<Array<{ sandbox: TSandbox; sandboxId: string }>>;\n destroy: (config: TConfig, sandboxId: string) => Promise<void>;\n \n // Instance operations (map to individual Sandbox methods)\n runCode: (sandbox: TSandbox, code: string, runtime?: Runtime, config?: TConfig) => Promise<ExecutionResult>;\n runCommand: (sandbox: TSandbox, command: string, args?: string[], options?: RunCommandOptions) => Promise<ExecutionResult>;\n getInfo: (sandbox: TSandbox) => Promise<SandboxInfo>;\n getUrl: (sandbox: TSandbox, options: { port: number; protocol?: string }) => Promise<string>;\n \n // Optional provider-specific typed getInstance method\n getInstance?: (sandbox: TSandbox) => TSandbox;\n \n // Optional filesystem methods\n filesystem?: {\n readFile: (sandbox: TSandbox, path: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<string>;\n writeFile: (sandbox: TSandbox, path: string, content: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<void>;\n mkdir: (sandbox: TSandbox, path: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<void>;\n readdir: (sandbox: TSandbox, path: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<FileEntry[]>;\n exists: (sandbox: TSandbox, path: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<boolean>;\n remove: (sandbox: TSandbox, path: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<void>;\n };\n}\n\n/**\n * Template method implementations\n */\nexport interface TemplateMethods<TTemplate = any, TConfig = any> {\n create: (config: TConfig, options: CreateTemplateOptions | any) => Promise<TTemplate>;\n list: (config: TConfig, options?: ListTemplatesOptions) => Promise<TTemplate[]>;\n delete: (config: TConfig, templateId: string) => Promise<void>;\n}\n\n/**\n * Snapshot method implementations \n */\nexport interface SnapshotMethods<TSnapshot = any, TConfig = any> {\n create: (config: TConfig, sandboxId: string, options?: CreateSnapshotOptions) => Promise<TSnapshot>;\n list: (config: TConfig, options?: ListSnapshotsOptions) => Promise<TSnapshot[]>;\n delete: (config: TConfig, snapshotId: string) => Promise<void>;\n}\n\n/**\n * Provider configuration for createProvider()\n */\nexport interface ProviderConfig<TSandbox = any, TConfig = any, TTemplate = any, TSnapshot = any> {\n name: string;\n methods: {\n sandbox: SandboxMethods<TSandbox, TConfig>;\n template?: TemplateMethods<TTemplate, TConfig>;\n snapshot?: SnapshotMethods<TSnapshot, TConfig>;\n };\n}\n\n/**\n * Default filesystem implementations based on shell commands\n * These work for any provider that supports shell command execution\n */\nconst defaultFilesystemMethods = {\n readFile: async (sandbox: any, path: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<string> => {\n const result = await runCommand(sandbox, 'cat', [path]);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to read file ${path}: ${result.stderr}`);\n }\n // Trim trailing newline that cat command adds\n return result.stdout.replace(/\\n$/, '');\n },\n\n writeFile: async (sandbox: any, path: string, content: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<void> => {\n const result = await runCommand(sandbox, 'sh', ['-c', `echo ${JSON.stringify(content)} > ${JSON.stringify(path)}`]);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to write file ${path}: ${result.stderr}`);\n }\n },\n\n mkdir: async (sandbox: any, path: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<void> => {\n const result = await runCommand(sandbox, 'mkdir', ['-p', path]);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to create directory ${path}: ${result.stderr}`);\n }\n },\n\n readdir: async (sandbox: any, path: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<FileEntry[]> => {\n // Try different ls variations for maximum compatibility\n let result = await runCommand(sandbox, 'ls', ['-la', path]);\n let hasDetailedOutput = true;\n \n // Fall back to basic ls if detailed flags not supported\n if (result.exitCode !== 0) {\n result = await runCommand(sandbox, 'ls', ['-l', path]);\n }\n if (result.exitCode !== 0) {\n result = await runCommand(sandbox, 'ls', [path]);\n hasDetailedOutput = false;\n }\n \n if (result.exitCode !== 0) {\n throw new Error(`Failed to list directory ${path}: ${result.stderr}`);\n }\n\n const lines = (result.stdout || '').split('\\n').filter((line: string) => line.trim() && !line.startsWith('total'));\n\n return lines.map((line: string) => {\n if (hasDetailedOutput && line.includes(' ')) {\n // Parse detailed ls output (ls -la or ls -l)\n const parts = line.trim().split(/\\s+/);\n const name = parts[parts.length - 1];\n const isDirectory = line.startsWith('d');\n \n return {\n name,\n path: `${path}/${name}`,\n isDirectory,\n size: parseInt(parts[4]) || 0,\n lastModified: new Date()\n };\n } else {\n // Parse simple ls output (just filenames)\n const name = line.trim();\n return {\n name,\n path: `${path}/${name}`,\n isDirectory: false, // Can't determine from simple ls\n size: 0,\n lastModified: new Date()\n };\n }\n });\n },\n\n exists: async (sandbox: any, path: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<boolean> => {\n const result = await runCommand(sandbox, 'test', ['-e', path]);\n return result.exitCode === 0; // Exit code 0 means file exists\n },\n\n remove: async (sandbox: any, path: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<void> => {\n const result = await runCommand(sandbox, 'rm', ['-rf', path]);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to remove ${path}: ${result.stderr}`);\n }\n }\n};\n\n/**\n * Auto-generated filesystem implementation that throws \"not supported\" errors\n */\nclass UnsupportedFileSystem implements SandboxFileSystem {\n private readonly providerName: string;\n\n constructor(providerName: string) {\n this.providerName = providerName;\n }\n\n async readFile(_path: string): Promise<string> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n\n async writeFile(_path: string, _content: string): Promise<void> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n\n async mkdir(_path: string): Promise<void> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n\n async readdir(_path: string): Promise<FileEntry[]> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n\n async exists(_path: string): Promise<boolean> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n\n async remove(_path: string): Promise<void> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n}\n\n\n\n/**\n * Auto-generated filesystem implementation that wraps provider methods\n */\nclass SupportedFileSystem<TSandbox> implements SandboxFileSystem {\n constructor(\n private sandbox: TSandbox,\n private methods: NonNullable<SandboxMethods<TSandbox>['filesystem']>,\n private allMethods: SandboxMethods<TSandbox>\n ) {}\n\n async readFile(path: string): Promise<string> {\n return this.methods.readFile(this.sandbox, path, this.allMethods.runCommand);\n }\n\n async writeFile(path: string, content: string): Promise<void> {\n return this.methods.writeFile(this.sandbox, path, content, this.allMethods.runCommand);\n }\n\n async mkdir(path: string): Promise<void> {\n return this.methods.mkdir(this.sandbox, path, this.allMethods.runCommand);\n }\n\n async readdir(path: string): Promise<FileEntry[]> {\n return this.methods.readdir(this.sandbox, path, this.allMethods.runCommand);\n }\n\n async exists(path: string): Promise<boolean> {\n return this.methods.exists(this.sandbox, path, this.allMethods.runCommand);\n }\n\n async remove(path: string): Promise<void> {\n return this.methods.remove(this.sandbox, path, this.allMethods.runCommand);\n }\n}\n\n\n\n\n\n/**\n * Generated sandbox class - implements the Sandbox interface\n */\nclass GeneratedSandbox<TSandbox = any> implements Sandbox<TSandbox> {\n readonly sandboxId: string;\n readonly provider: string;\n readonly filesystem: SandboxFileSystem;\n\n constructor(\n private sandbox: TSandbox,\n sandboxId: string,\n providerName: string,\n private methods: SandboxMethods<TSandbox>,\n private config: any,\n private destroyMethod: (config: any, sandboxId: string) => Promise<void>,\n private providerInstance: Provider\n ) {\n this.sandboxId = sandboxId;\n this.provider = providerName;\n\n // Auto-detect filesystem support\n if (methods.filesystem) {\n this.filesystem = new SupportedFileSystem(sandbox, methods.filesystem, methods);\n } else {\n this.filesystem = new UnsupportedFileSystem(providerName);\n }\n }\n\n getInstance(): TSandbox {\n // Use provider-specific typed getInstance if available\n if (this.methods.getInstance) {\n return this.methods.getInstance(this.sandbox);\n }\n // Fallback to returning the sandbox directly\n return this.sandbox;\n }\n\n async runCode(code: string, runtime?: Runtime): Promise<ExecutionResult> {\n return await this.methods.runCode(this.sandbox, code, runtime, this.config);\n }\n\n async runCommand(command: string, args?: string[], options?: RunCommandOptions): Promise<ExecutionResult> {\n return await this.methods.runCommand(this.sandbox, command, args, options);\n }\n\n async getInfo(): Promise<SandboxInfo> {\n return await this.methods.getInfo(this.sandbox);\n }\n\n async getUrl(options: { port: number; protocol?: string }): Promise<string> {\n return await this.methods.getUrl(this.sandbox, options);\n }\n\n getProvider(): Provider<TSandbox> {\n return this.providerInstance;\n }\n\n async kill(): Promise<void> {\n // For backward compatibility, kill() delegates to destroy()\n await this.destroy();\n }\n\n async destroy(): Promise<void> {\n // Destroy via the provider's destroy method using our sandboxId\n await this.destroyMethod(this.config, this.sandboxId);\n }\n}\n\n/**\n * Auto-generated Sandbox Manager implementation\n */\nclass GeneratedSandboxManager<TSandbox, TConfig> implements ProviderSandboxManager<TSandbox> {\n private activeSandboxes: Map<string, GeneratedSandbox<TSandbox>> = new Map();\n\n constructor(\n private config: TConfig,\n private providerName: string,\n private methods: SandboxMethods<TSandbox, TConfig>,\n private providerInstance: Provider\n ) {}\n\n async create(options?: CreateSandboxOptions): Promise<Sandbox<TSandbox>> {\n // Default to 'node' runtime if not specified for consistency across providers\n const optionsWithDefaults = { runtime: 'node' as Runtime, ...options };\n const result = await this.methods.create(this.config, optionsWithDefaults);\n const sandbox = new GeneratedSandbox<TSandbox>(\n result.sandbox,\n result.sandboxId,\n this.providerName,\n this.methods,\n this.config,\n this.methods.destroy,\n this.providerInstance\n );\n \n this.activeSandboxes.set(result.sandboxId, sandbox);\n return sandbox;\n }\n\n async getById(sandboxId: string): Promise<Sandbox<TSandbox> | null> {\n // Check active sandboxes first\n const existing = this.activeSandboxes.get(sandboxId);\n if (existing) {\n return existing;\n }\n\n // Try to reconnect\n const result = await this.methods.getById(this.config, sandboxId);\n if (!result) {\n return null;\n }\n\n const sandbox = new GeneratedSandbox<TSandbox>(\n result.sandbox,\n result.sandboxId,\n this.providerName,\n this.methods,\n this.config,\n this.methods.destroy,\n this.providerInstance\n );\n \n this.activeSandboxes.set(result.sandboxId, sandbox);\n return sandbox;\n }\n\n async list(): Promise<Sandbox<TSandbox>[]> {\n const results = await this.methods.list(this.config);\n const sandboxes: Sandbox[] = [];\n\n for (const result of results) {\n let sandbox = this.activeSandboxes.get(result.sandboxId);\n if (!sandbox) {\n sandbox = new GeneratedSandbox<TSandbox>(\n result.sandbox,\n result.sandboxId,\n this.providerName,\n this.methods,\n this.config,\n this.methods.destroy,\n this.providerInstance\n );\n this.activeSandboxes.set(result.sandboxId, sandbox);\n }\n sandboxes.push(sandbox);\n }\n\n return sandboxes;\n }\n\n async destroy(sandboxId: string): Promise<void> {\n await this.methods.destroy(this.config, sandboxId);\n this.activeSandboxes.delete(sandboxId);\n }\n}\n\n/**\n * Auto-generated Template Manager implementation\n */\nclass GeneratedTemplateManager<TTemplate, TConfig> implements ProviderTemplateManager<TTemplate> {\n constructor(\n private config: TConfig,\n private methods: TemplateMethods<TTemplate, TConfig>\n ) {}\n\n async create(options: CreateTemplateOptions | any): Promise<TTemplate> {\n return await this.methods.create(this.config, options);\n }\n\n async list(options?: ListTemplatesOptions): Promise<TTemplate[]> {\n return await this.methods.list(this.config, options);\n }\n\n async delete(templateId: string): Promise<void> {\n return await this.methods.delete(this.config, templateId);\n }\n}\n\n/**\n * Auto-generated Snapshot Manager implementation\n */\nclass GeneratedSnapshotManager<TSnapshot, TConfig> implements ProviderSnapshotManager<TSnapshot> {\n constructor(\n private config: TConfig,\n private methods: SnapshotMethods<TSnapshot, TConfig>\n ) {}\n\n async create(sandboxId: string, options?: CreateSnapshotOptions): Promise<TSnapshot> {\n return await this.methods.create(this.config, sandboxId, options);\n }\n\n async list(options?: ListSnapshotsOptions): Promise<TSnapshot[]> {\n return await this.methods.list(this.config, options);\n }\n\n async delete(snapshotId: string): Promise<void> {\n return await this.methods.delete(this.config, snapshotId);\n }\n}\n\n/**\n * Auto-generated Provider implementation\n */\nclass GeneratedProvider<TSandbox, TConfig, TTemplate, TSnapshot> implements Provider<TSandbox, TTemplate, TSnapshot> {\n readonly name: string;\n readonly sandbox: ProviderSandboxManager<TSandbox>;\n readonly template?: ProviderTemplateManager<TTemplate>;\n readonly snapshot?: ProviderSnapshotManager<TSnapshot>;\n readonly __sandboxType!: TSandbox; // Phantom type for TypeScript inference\n\n constructor(config: TConfig, providerConfig: ProviderConfig<TSandbox, TConfig, TTemplate, TSnapshot>) {\n this.name = providerConfig.name;\n this.sandbox = new GeneratedSandboxManager(\n config,\n providerConfig.name,\n providerConfig.methods.sandbox,\n this\n );\n\n // Initialize optional managers if methods are provided\n if (providerConfig.methods.template) {\n this.template = new GeneratedTemplateManager(config, providerConfig.methods.template);\n }\n \n if (providerConfig.methods.snapshot) {\n this.snapshot = new GeneratedSnapshotManager(config, providerConfig.methods.snapshot);\n }\n }\n\n getSupportedRuntimes(): Runtime[] {\n // For now, all providers support both node and python\n // In the future, this could be configurable per provider\n return ['node', 'python'];\n }\n}\n\n/**\n * Create a provider from method definitions\n * \n * Auto-generates all boilerplate classes and provides feature detection\n * based on which methods are implemented.\n */\nexport function createProvider<TSandbox, TConfig = any, TTemplate = any, TSnapshot = any>(\n providerConfig: ProviderConfig<TSandbox, TConfig, TTemplate, TSnapshot>\n): (config: TConfig) => Provider<TSandbox, TTemplate, TSnapshot> {\n // Auto-inject default filesystem methods if none provided\n if (!providerConfig.methods.sandbox.filesystem) {\n providerConfig.methods.sandbox.filesystem = defaultFilesystemMethods;\n }\n\n return (config: TConfig) => {\n return new GeneratedProvider(config, providerConfig);\n };\n}"],"mappings":";AAwJO,IAAM,mBAAN,cAA+B,MAAM;AAAA,EAE1C,YAAmB,QAKhB;AACD,UAAM,4BAA4B,OAAO,QAAQ,EAAE;AANlC;AADnB,gBAAO;AAAA,EAQP;AACF;AAKO,SAAS,mBAAmB,OAA2C;AAC5E,SACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,MAAM,SAAS,sBACf,YAAY;AAEhB;;;ACzKA,SAAS,qBAAqB;AAe9B,eAAe,gBAAgB,QAAgD;AAC7E,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,0DAA0D;AAAA,MACrF,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM,KAAK,UAAU;AAAA,QACnB,KAAK;AAAA,QACL,iBAAiB;AAAA,MACnB,CAAC;AAAA,IACH,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,IAAI,MAAM,iCAAiC,SAAS,UAAU,EAAE;AAAA,IACxE;AAEA,UAAM,OAAO,MAAM,SAAS,KAAK;AAEjC,QAAI,CAAC,KAAK,cAAc;AACtB,YAAM,IAAI,MAAM,8CAA8C;AAAA,IAChE;AA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AACF;AAQO,SAAS,eACd,gBAC+D;AAE/D,MAAI,CAAC,eAAe,QAAQ,QAAQ,YAAY;AAC9C,mBAAe,QAAQ,QAAQ,aAAa;AAAA,EAC9C;AAEA,SAAO,CAAC,WAAoB;AAC1B,WAAO,IAAI,kBAAkB,QAAQ,cAAc;AAAA,EACrD;AACF;","names":["sandbox"]}
1
+ {"version":3,"sources":["../src/types/sandbox.ts","../src/compute.ts","../src/request-handler.ts","../src/factory.ts"],"sourcesContent":["/**\n * Sandbox Types\n * \n * Types related to sandbox execution, filesystem, terminal operations\n */\n\n// Forward declaration to avoid circular dependency\ninterface Provider {\n readonly name: string;\n readonly sandbox: any; // Will be properly typed when imported together\n}\n\n/**\n * Type mapping for provider names to their sandbox types\n * Manually defined for known providers since declaration merging isn't working reliably\n */\nexport interface ProviderSandboxTypeMap {\n e2b: any; // We can't import the E2B type directly, but we'll handle it differently\n vercel: any;\n daytona: any;\n}\n\n/**\n * Utility type to extract the native instance type from a provider\n * Uses provider name and manual type inference\n */\nexport type ExtractSandboxInstanceType<TProvider extends Provider> = \n TProvider extends { readonly name: 'e2b' }\n ? any // For now, let's just try to make the runtime casting work\n : TProvider extends { readonly name: 'vercel' }\n ? any\n : TProvider extends { readonly name: 'daytona' }\n ? any\n : any;\n\n/**\n * Supported runtime environments\n */\nexport type Runtime = 'node' | 'python';\n\n/**\n * Sandbox status types\n */\nexport type SandboxStatus = 'running' | 'stopped' | 'error';\n\n/**\n * Options for running commands\n */\nexport interface RunCommandOptions {\n /** Run command in background (non-blocking) */\n background?: boolean;\n}\n\n/**\n * Result of code execution\n */\nexport interface ExecutionResult {\n /** Standard output from the execution */\n stdout: string;\n /** Standard error from the execution */\n stderr: string;\n /** Exit code from the execution */\n exitCode: number;\n /** Time taken for execution in milliseconds */\n executionTime: number;\n /** ID of the sandbox where the code was executed */\n sandboxId: string;\n /** Provider that executed the code */\n provider: string;\n /** Process ID for background jobs (if applicable) */\n pid?: number;\n /** Whether this command is running in background */\n isBackground?: boolean;\n}\n\n/**\n * Information about a sandbox\n */\nexport interface SandboxInfo {\n /** Unique identifier for the sandbox */\n id: string;\n /** Provider hosting the sandbox */\n provider: string;\n /** Runtime environment in the sandbox */\n runtime: Runtime;\n /** Current status of the sandbox */\n status: SandboxStatus;\n /** When the sandbox was created */\n createdAt: Date;\n /** Execution timeout in milliseconds */\n timeout: number;\n /** Additional provider-specific metadata */\n metadata?: Record<string, any>;\n}\n\n/**\n * Options for creating a sandbox\n */\nexport interface CreateSandboxOptions {\n /** Runtime environment (defaults to 'node' if not specified) */\n runtime?: Runtime;\n /** Execution timeout in milliseconds */\n timeout?: number;\n /** Custom sandbox ID (if supported by provider) */\n sandboxId?: string;\n /** Template ID for sandbox creation (provider-specific) */\n templateId?: string;\n /** Additional metadata for the sandbox */\n metadata?: Record<string, any>;\n /** Domain for sandbox connection (provider-specific) */\n domain?: string;\n /** Environment variables for the sandbox */\n envs?: Record<string, string>;\n}\n\n/**\n * File system entry information\n */\nexport interface FileEntry {\n /** File/directory name */\n name: string;\n /** Full path to the entry */\n path: string;\n /** Whether this is a directory */\n isDirectory: boolean;\n /** File size in bytes (0 for directories) */\n size: number;\n /** Last modified timestamp */\n lastModified: Date;\n}\n\n/**\n * File system interface for sandbox operations\n */\nexport interface SandboxFileSystem {\n /** Read file contents */\n readFile(path: string): Promise<string>;\n /** Write file contents */\n writeFile(path: string, content: string): Promise<void>;\n /** Create directory */\n mkdir(path: string): Promise<void>;\n /** List directory contents */\n readdir(path: string): Promise<FileEntry[]>;\n /** Check if file/directory exists */\n exists(path: string): Promise<boolean>;\n /** Remove file or directory */\n remove(path: string): Promise<void>;\n}\n\n/**\n * Error thrown when a command exits with a non-zero status\n */\nexport class CommandExitError extends Error {\n name = 'CommandExitError';\n constructor(public result: {\n exitCode: number;\n stdout: string;\n stderr: string;\n error: boolean;\n }) {\n super(`Command exited with code ${result.exitCode}`);\n }\n}\n\n/**\n * Type guard to check if an error is a CommandExitError\n */\nexport function isCommandExitError(error: unknown): error is CommandExitError {\n return (\n typeof error === 'object' &&\n error !== null &&\n 'name' in error &&\n error.name === 'CommandExitError' &&\n 'result' in error\n );\n}\n\n\n\n\n\n/**\n * Base sandbox interface - what developers interact with\n */\nexport interface Sandbox<TSandbox = any> {\n /** Unique identifier for the sandbox */\n readonly sandboxId: string;\n /** Provider that created this sandbox */\n readonly provider: string;\n\n /** Execute code in the sandbox */\n runCode(code: string, runtime?: Runtime): Promise<ExecutionResult>;\n /** Execute shell commands */\n runCommand(command: string, args?: string[], options?: RunCommandOptions): Promise<ExecutionResult>;\n /** Get information about the sandbox */\n getInfo(): Promise<SandboxInfo>;\n /** Get URL for accessing the sandbox on a specific port */\n getUrl(options: { port: number; protocol?: string }): Promise<string>;\n /** Get the provider instance that created this sandbox */\n getProvider(): import('./provider').Provider<TSandbox>;\n /** Get the native provider sandbox instance with proper typing */\n getInstance(): TSandbox;\n /** Kill the sandbox */\n kill(): Promise<void>;\n /** Destroy the sandbox and clean up resources */\n destroy(): Promise<void>;\n\n /** File system operations */\n readonly filesystem: SandboxFileSystem;\n}\n\n/**\n * Extract the sandbox type from a provider\n */\ntype ExtractProviderSandboxType<TProvider extends Provider> = TProvider extends { readonly __sandboxType: infer TSandbox } ? TSandbox : any;\n\n/**\n * Typed sandbox interface that preserves the provider's native instance type\n */\nexport interface TypedSandbox<TProvider extends Provider> extends Omit<Sandbox<ExtractProviderSandboxType<TProvider>>, 'getProvider'> {\n /** Get the provider instance that created this sandbox with proper typing */\n getProvider(): TProvider;\n /** Get the native provider sandbox instance with proper typing */\n getInstance(): ExtractProviderSandboxType<TProvider>;\n}\n\n/**\n * Enhanced sandbox type that includes ComputeClient features\n *\n * When a sandbox is created with an API key/JWT, it gets wrapped with ComputeClient\n * which adds powerful features like WebSocket terminals, file watchers, and signals.\n *\n * @example\n * ```typescript\n * const sandbox = await compute.sandbox.create();\n *\n * // ComputeClient features (only available when API key is configured)\n * const terminal = await sandbox.createTerminal();\n * const watcher = await sandbox.createWatcher('/home/project');\n * const signals = await sandbox.startSignals();\n *\n * // Original sandbox features still work\n * await sandbox.runCommand('ls');\n * const instance = sandbox.getInstance();\n * ```\n */\nexport type ComputeEnhancedSandbox<TSandbox = any> = Sandbox<TSandbox> & {\n /** The original provider sandbox instance */\n __originalSandbox: Sandbox<TSandbox>;\n\n // ComputeClient enhanced features\n /** Create a persistent terminal session with WebSocket integration */\n createTerminal(shell?: string, encoding?: 'raw' | 'base64'): Promise<import('@computesdk/client').Terminal>;\n /** Create a file watcher with real-time change notifications */\n createWatcher(path: string, options?: {\n includeContent?: boolean;\n ignored?: string[];\n encoding?: 'raw' | 'base64';\n }): Promise<import('@computesdk/client').FileWatcher>;\n /** Start the signal service for port and error monitoring */\n startSignals(): Promise<import('@computesdk/client').SignalService>;\n /** Execute a one-off command without creating a persistent terminal */\n execute(options: { command: string; shell?: string }): Promise<any>;\n /** List all active terminals */\n listTerminals(): Promise<any[]>;\n /** Get terminal by ID */\n getTerminal(id: string): Promise<any>;\n /** List all active file watchers */\n listWatchers(): Promise<any>;\n /** Get file watcher by ID */\n getWatcher(id: string): Promise<any>;\n /** Get signal service status */\n getSignalStatus(): Promise<any>;\n /** Create a session token (requires access token) */\n createSessionToken(options?: { description?: string; expiresIn?: number }): Promise<any>;\n /** List all session tokens (requires access token) */\n listSessionTokens(): Promise<any>;\n /** Get session token details (requires access token) */\n getSessionToken(tokenId: string): Promise<any>;\n /** Revoke a session token (requires access token) */\n revokeSessionToken(tokenId: string): Promise<void>;\n /** Create a magic link for browser authentication (requires access token) */\n createMagicLink(options?: { redirectUrl?: string }): Promise<any>;\n /** Check authentication status */\n getAuthStatus(): Promise<any>;\n /** Get authentication information */\n getAuthInfo(): Promise<any>;\n /** Set authentication token manually */\n setToken(token: string): void;\n /** Get current authentication token */\n getToken(): string | null;\n /** Get current sandbox URL */\n getSandboxUrl(): string;\n /** Disconnect WebSocket connection */\n disconnect(): Promise<void>;\n}\n\n/**\n * Typed enhanced sandbox that preserves both provider typing and ComputeClient features\n */\nexport type TypedEnhancedSandbox<TProvider extends Provider> =\n ComputeEnhancedSandbox<ExtractProviderSandboxType<TProvider>> &\n Omit<TypedSandbox<TProvider>, keyof Sandbox>;","/**\n * Compute Singleton - Main API Orchestrator\n *\n * Provides the unified compute.* API and delegates to specialized managers\n */\n\nimport { ComputeClient } from '@computesdk/client';\nimport type { ComputeAPI, CreateSandboxParams, CreateSandboxParamsWithOptionalProvider, ComputeConfig, Sandbox, Provider, TypedSandbox, TypedComputeAPI, ComputeEnhancedSandbox, TypedEnhancedSandbox } from './types';\n\n/**\n * Authorization response from license server\n */\ninterface AuthorizationResponse {\n access_token: string;\n sandbox_url: string;\n preview_url: string;\n}\n\n/**\n * Authorize license key and get JWT token + URLs from license server\n */\nasync function authorizeApiKey(apiKey: string): Promise<AuthorizationResponse> {\n try {\n const response = await fetch('https://preview.computesdk.com/__api/license/authorize', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n key: apiKey,\n increment_usage: 1\n })\n });\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => response.statusText);\n throw new Error(`License authorization failed (${response.status}): ${errorText}`);\n }\n\n const data = await response.json();\n\n if (!data.access_token) {\n throw new Error('No access token received from license server');\n }\n\n if (!data.sandbox_url) {\n throw new Error('No sandbox_url received from license server');\n }\n\n if (!data.preview_url) {\n throw new Error('No preview_url received from license server');\n }\n\n return {\n access_token: data.access_token,\n sandbox_url: data.sandbox_url,\n preview_url: data.preview_url\n };\n } catch (error) {\n if (error instanceof Error && error.message.includes('License authorization failed')) {\n throw error; // Re-throw our formatted error\n }\n // Network or other errors\n throw new Error(`Failed to authorize API key (network error): ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/**\n * Check if a command is available in the sandbox\n */\nasync function isCommandAvailable(sandbox: Sandbox, command: string): Promise<boolean> {\n const result = await sandbox.runCommand('sh', ['-c', `command -v ${command}`]);\n return result.exitCode === 0;\n}\n\n/**\n * Detect package manager available in the sandbox\n */\nasync function detectPackageManager(sandbox: Sandbox): Promise<'apk' | 'apt' | null> {\n // Try Alpine's apk first (most common in minimal containers)\n if (await isCommandAvailable(sandbox, 'apk')) {\n return 'apk';\n }\n\n // Fall back to Debian/Ubuntu apt\n if (await isCommandAvailable(sandbox, 'apt-get')) {\n return 'apt';\n }\n\n return null;\n}\n\n/**\n * Install required dependencies (curl and bash) if missing\n */\nasync function ensureDependencies(sandbox: Sandbox): Promise<void> {\n const hasCurl = await isCommandAvailable(sandbox, 'curl');\n const hasBash = await isCommandAvailable(sandbox, 'bash');\n\n // If both are available, nothing to do\n if (hasCurl && hasBash) {\n return;\n }\n\n const packageManager = await detectPackageManager(sandbox);\n\n if (!packageManager) {\n throw new Error(\n `Missing required tools (curl: ${hasCurl}, bash: ${hasBash}), but no supported package manager found.\\n` +\n `Supported package managers: apk (Alpine), apt-get (Debian/Ubuntu).\\n` +\n `Please use a sandbox image that includes curl and bash, or install them manually first.`\n );\n }\n\n let installResult;\n\n if (packageManager === 'apk') {\n // Alpine Linux\n installResult = await sandbox.runCommand('sh', ['-c', 'apk add --no-cache curl bash 2>&1']);\n } else {\n // Debian/Ubuntu\n installResult = await sandbox.runCommand('sh', ['-c', 'apt-get update -qq && apt-get install -qq -y curl bash 2>&1']);\n }\n\n if (installResult.exitCode !== 0) {\n throw new Error(\n `Failed to install curl and bash using ${packageManager}.\\n` +\n `Install output: ${installResult.stderr || installResult.stdout}\\n` +\n `Please install curl and bash manually or use a different sandbox image.`\n );\n }\n}\n\n/**\n * Check if compute CLI is already installed in the sandbox\n */\nasync function isComputeInstalled(sandbox: Sandbox): Promise<boolean> {\n const result = await sandbox.runCommand('sh', ['-c', 'test -f /usr/local/bin/compute && echo \"exists\" || echo \"missing\"']);\n return result.stdout?.trim() === 'exists';\n}\n\n/**\n * Download the compute install script\n */\nasync function downloadInstallScript(sandbox: Sandbox): Promise<void> {\n const downloadResult = await sandbox.runCommand('sh', ['-c', 'curl -fsSL https://computesdk.com/install.sh -o /tmp/compute-install.sh 2>&1']);\n\n if (downloadResult.exitCode !== 0) {\n const errorOutput = downloadResult.stderr || downloadResult.stdout || 'unknown error';\n throw new Error(\n `Failed to download install script from https://computesdk.com/install.sh: ${errorOutput}`\n );\n }\n}\n\n/**\n * Run the compute install script\n */\nasync function runInstallScript(sandbox: Sandbox, accessToken?: string): Promise<void> {\n const installCommand = accessToken\n ? `bash /tmp/compute-install.sh --non-interactive --access-token \"${accessToken}\" --location /usr/local/bin`\n : `bash /tmp/compute-install.sh --non-interactive --location /usr/local/bin`;\n\n const installResult = await sandbox.runCommand('bash', ['-c', installCommand]);\n\n if (installResult.exitCode !== 0) {\n const errorOutput = installResult.stderr || installResult.stdout || 'unknown error';\n throw new Error(`Failed to install compute CLI: ${errorOutput}`);\n }\n}\n\n/**\n * Install and start compute CLI inside a sandbox\n *\n * This is the main installation orchestrator that:\n * 1. Checks if compute is already installed\n * 2. Ensures curl and bash are available (installs if needed)\n * 3. Downloads the install script\n * 4. Runs the install script with proper credentials\n * 5. Verifies the installation succeeded\n */\nasync function installComputeInSandbox(\n sandbox: Sandbox,\n config?: { apiKey?: string; accessToken?: string }\n): Promise<AuthorizationResponse | null> {\n // Get access token and URLs from API key if provided\n let authResponse: AuthorizationResponse | null = null;\n let accessToken = config?.accessToken;\n\n if (config?.apiKey && !accessToken) {\n authResponse = await authorizeApiKey(config.apiKey);\n accessToken = authResponse.access_token;\n }\n\n // Check if compute is already installed\n if (await isComputeInstalled(sandbox)) {\n return authResponse;\n }\n\n // Ensure required dependencies are available\n await ensureDependencies(sandbox);\n\n // Download install script\n await downloadInstallScript(sandbox);\n\n // Run install script with credentials\n await runInstallScript(sandbox, accessToken);\n\n // Verify installation succeeded\n if (!await isComputeInstalled(sandbox)) {\n throw new Error('Compute binary not found at /usr/local/bin/compute after installation');\n }\n\n return authResponse;\n}\n\n/**\n * Wait for compute CLI to be ready by polling the health endpoint\n */\nasync function waitForComputeReady(client: ComputeClient, maxRetries = 30, delayMs = 2000): Promise<void> {\n let lastError: Error | null = null;\n\n for (let i = 0; i < maxRetries; i++) {\n try {\n await client.health();\n return;\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error));\n\n // Only log on last attempt to avoid noise\n if (i === maxRetries - 1) {\n throw new Error(\n `Compute CLI failed to start after ${maxRetries} attempts (${maxRetries * delayMs / 1000}s).\\n` +\n `Last error: ${lastError.message}\\n` +\n `This could indicate:\\n` +\n ` 1. The compute daemon failed to start in the sandbox\\n` +\n ` 2. The sandbox_url is incorrect or unreachable\\n` +\n ` 3. The sandbox is taking longer than expected to initialize`\n );\n }\n\n await new Promise(resolve => setTimeout(resolve, delayMs));\n }\n }\n}\n\n/**\n * Compute singleton implementation - orchestrates all compute operations\n */\nclass ComputeManager implements ComputeAPI {\n private config: ComputeConfig | null = null;\n private computeAuth: { apiKey?: string; accessToken?: string } = {};\n\n /**\n * Set default configuration with generic type preservation\n */\n setConfig<TProvider extends Provider>(config: ComputeConfig<TProvider>): void {\n // Validate that at least one provider is specified\n if (!config.defaultProvider && !config.provider) {\n throw new Error('Either defaultProvider or provider must be specified in setConfig');\n }\n\n // Handle backwards compatibility: if both are provided, defaultProvider takes precedence\n if (config.defaultProvider && config.provider) {\n console.warn('Both defaultProvider and provider specified in setConfig. Using defaultProvider. The provider key is deprecated, please use defaultProvider instead.');\n }\n\n // Normalize config to always have both fields for internal use (backward compatibility)\n const actualProvider = config.defaultProvider || config.provider!;\n const accessToken = config.accessToken || config.jwt; // Support both accessToken and deprecated jwt\n this.config = {\n provider: actualProvider,\n defaultProvider: actualProvider,\n apiKey: config.apiKey,\n accessToken: accessToken\n };\n\n // Store compute auth credentials\n this.computeAuth = {\n apiKey: config.apiKey,\n accessToken: accessToken\n };\n }\n\n /**\n * Get current configuration\n */\n getConfig(): ComputeConfig | null {\n return this.config;\n }\n\n /**\n * Clear current configuration\n */\n clearConfig(): void {\n this.config = null;\n }\n\n /**\n * Get the default provider, throwing if not configured\n */\n private getDefaultProvider(): Provider {\n const provider = this.config?.defaultProvider || this.config?.provider;\n if (!provider) {\n throw new Error(\n 'No default provider configured. Either call compute.setConfig({ defaultProvider }) or pass provider explicitly.'\n );\n }\n return provider;\n }\n\n /**\n * Wrap a provider sandbox with ComputeClient while preserving the original sandbox\n * This adds powerful features like WebSocket terminals, file watchers, and signals\n */\n private async wrapWithComputeClient(originalSandbox: Sandbox, authResponse: AuthorizationResponse): Promise<ComputeEnhancedSandbox> {\n const client = new ComputeClient({\n sandboxUrl: authResponse.sandbox_url,\n sandboxId: originalSandbox.sandboxId,\n provider: originalSandbox.provider,\n token: authResponse.access_token,\n WebSocket: globalThis.WebSocket\n });\n\n // Wait for compute CLI to be ready before returning\n await waitForComputeReady(client);\n\n // Store the original sandbox for getInstance() and getProvider() calls\n // We create a proxy-like object that delegates most calls to ComputeClient\n // but preserves access to the original provider sandbox\n const wrappedSandbox = Object.assign(client, {\n __originalSandbox: originalSandbox,\n\n // Override getInstance to return the original provider's instance\n getInstance: () => originalSandbox.getInstance(),\n\n // Override getProvider to return the original provider\n getProvider: () => originalSandbox.getProvider()\n });\n\n return wrappedSandbox as ComputeEnhancedSandbox;\n }\n\n sandbox = {\n /**\n * Create a sandbox from a provider (or default provider if configured)\n * \n * @example\n * ```typescript\n * import { e2b } from '@computesdk/e2b'\n * import { compute } from 'computesdk'\n * \n * // With explicit provider\n * const sandbox = await compute.sandbox.create({\n * provider: e2b({ apiKey: 'your-key' })\n * })\n * \n * // With default provider (both forms work)\n * compute.setConfig({ defaultProvider: e2b({ apiKey: 'your-key' }) })\n * const sandbox1 = await compute.sandbox.create({})\n * const sandbox2 = await compute.sandbox.create()\n * ```\n */\n create: async (params?: CreateSandboxParams | CreateSandboxParamsWithOptionalProvider): Promise<Sandbox | ComputeEnhancedSandbox> => {\n const provider = params && 'provider' in params && params.provider ? params.provider : this.getDefaultProvider();\n const options = params?.options;\n const sandbox = await provider.sandbox.create(options);\n\n // Install compute CLI and wrap with ComputeClient if auth is configured\n if (this.computeAuth.apiKey || this.computeAuth.accessToken) {\n // Install compute CLI in the sandbox with auth credentials\n const authResponse = await installComputeInSandbox(sandbox, this.computeAuth);\n\n // Wrap with ComputeClient if we have authorization info\n // This adds features like createTerminal(), createWatcher(), startSignals()\n if (authResponse) {\n return await this.wrapWithComputeClient(sandbox, authResponse);\n }\n }\n\n return sandbox;\n },\n\n /**\n * Get an existing sandbox by ID from a provider (or default provider if configured)\n */\n getById: async (providerOrSandboxId: Provider | string, sandboxId?: string): Promise<Sandbox | null> => {\n if (typeof providerOrSandboxId === 'string') {\n // Called with just sandboxId, use default provider\n const provider = this.getDefaultProvider();\n return await provider.sandbox.getById(providerOrSandboxId);\n } else {\n // Called with provider and sandboxId\n if (!sandboxId) {\n throw new Error('sandboxId is required when provider is specified');\n }\n return await providerOrSandboxId.sandbox.getById(sandboxId);\n }\n },\n\n /**\n * List all active sandboxes from a provider (or default provider if configured)\n */\n list: async (provider?: Provider): Promise<Sandbox[]> => {\n const actualProvider = provider || this.getDefaultProvider();\n return await actualProvider.sandbox.list();\n },\n\n /**\n * Destroy a sandbox via a provider (or default provider if configured)\n */\n destroy: async (providerOrSandboxId: Provider | string, sandboxId?: string): Promise<void> => {\n if (typeof providerOrSandboxId === 'string') {\n // Called with just sandboxId, use default provider\n const provider = this.getDefaultProvider();\n return await provider.sandbox.destroy(providerOrSandboxId);\n } else {\n // Called with provider and sandboxId\n if (!sandboxId) {\n throw new Error('sandboxId is required when provider is specified');\n }\n return await providerOrSandboxId.sandbox.destroy(sandboxId);\n }\n }\n };\n\n // Future: compute.blob.*, compute.database.*, compute.git.* will be added here\n // blob = new BlobManager();\n // database = new DatabaseManager(); \n // git = new GitManager();\n\n\n}\n\n/**\n * Singleton instance - the main API (untyped)\n */\nexport const compute: ComputeAPI = new ComputeManager();\n\n\n\n/**\n * Create a compute instance with proper typing\n *\n * @example\n * ```typescript\n * import { e2b } from '@computesdk/e2b'\n * import { createCompute } from 'computesdk'\n *\n * // With API key (automatically gets access token from license server)\n * const compute = createCompute({\n * defaultProvider: e2b({ apiKey: 'your-key' }),\n * apiKey: 'computesdk_live_...' // Returns enhanced sandboxes\n * });\n *\n * // Or with direct access token\n * const compute2 = createCompute({\n * defaultProvider: e2b({ apiKey: 'your-key' }),\n * accessToken: 'your-access-token' // Returns enhanced sandboxes\n * });\n *\n * const sandbox = await compute.sandbox.create();\n * const instance = sandbox.getInstance(); // ✅ Properly typed E2B Sandbox!\n * await sandbox.createTerminal(); // ✅ Enhanced sandbox features!\n * ```\n */\nexport function createCompute<TProvider extends Provider>(\n config: ComputeConfig<TProvider> & { apiKey: string }\n): TypedComputeAPI<TProvider, true>;\nexport function createCompute<TProvider extends Provider>(\n config: ComputeConfig<TProvider> & { accessToken: string }\n): TypedComputeAPI<TProvider, true>;\nexport function createCompute<TProvider extends Provider>(\n config: ComputeConfig<TProvider> & { jwt: string }\n): TypedComputeAPI<TProvider, true>;\nexport function createCompute<TProvider extends Provider>(\n config: ComputeConfig<TProvider>\n): TypedComputeAPI<TProvider, false>;\nexport function createCompute<TProvider extends Provider>(\n config: ComputeConfig<TProvider>\n): TypedComputeAPI<TProvider, boolean> {\n const manager = new ComputeManager();\n\n // Set config directly without calling the public setConfig method\n const actualProvider = config.defaultProvider || config.provider!;\n const accessToken = config.accessToken || config.jwt; // Support both accessToken and deprecated jwt\n manager['config'] = {\n provider: actualProvider,\n defaultProvider: actualProvider,\n apiKey: config.apiKey,\n accessToken: accessToken\n };\n manager['computeAuth'] = {\n apiKey: config.apiKey,\n accessToken: accessToken\n };\n\n const isEnhanced = !!(config.apiKey || config.accessToken || config.jwt);\n\n return {\n setConfig: <T extends Provider>(cfg: ComputeConfig<T>) => createCompute(cfg),\n getConfig: () => manager.getConfig(),\n clearConfig: () => manager.clearConfig(),\n\n sandbox: {\n create: async (params?: Omit<CreateSandboxParamsWithOptionalProvider, 'provider'>) => {\n const sandbox = await manager.sandbox.create(params);\n // If API key/JWT is configured, the sandbox will be enhanced with ComputeClient features\n // Cast to the appropriate type based on whether it's enhanced or not\n if (isEnhanced) {\n return sandbox as TypedEnhancedSandbox<TProvider>;\n }\n return sandbox as TypedSandbox<TProvider>;\n },\n\n getById: async (sandboxId: string) => {\n const sandbox = await manager.sandbox.getById(sandboxId);\n if (!sandbox) return null;\n // Type depends on whether auth is configured\n if (isEnhanced) {\n return sandbox as TypedEnhancedSandbox<TProvider>;\n }\n return sandbox as TypedSandbox<TProvider>;\n },\n\n list: async () => {\n const sandboxes = await manager.sandbox.list();\n // Type depends on whether auth is configured\n if (isEnhanced) {\n return sandboxes as TypedEnhancedSandbox<TProvider>[];\n }\n return sandboxes as TypedSandbox<TProvider>[];\n },\n\n destroy: async (sandboxId: string) => {\n return await manager.sandbox.destroy(sandboxId);\n }\n }\n } as TypedComputeAPI<TProvider, typeof isEnhanced>;\n}\n\n\n\n","/**\n * Simplified Request Handler for Web Framework Integration\n * \n * Handles JSON requests for sandbox and code execution operations.\n * Terminal support removed - will be re-added with WebSocket VM connections.\n */\n\nimport type { Provider, Runtime } from './types';\nimport { compute } from './compute';\n\n/**\n * Request structure supporting sandbox and code execution capabilities\n */\nexport interface ComputeRequest {\n /** Action in dot notation (e.g., 'compute.sandbox.create') */\n action: string;\n \n /** Parameters for the action */\n sandboxId?: string;\n code?: string;\n command?: string;\n args?: string[];\n runtime?: Runtime;\n path?: string;\n content?: string;\n \n /** Command options (for runCommand action) */\n commandOptions?: {\n background?: boolean;\n };\n \n /** Sandbox creation options */\n options?: {\n runtime?: Runtime;\n timeout?: number;\n sandboxId?: string;\n };\n}\n\n/**\n * Response structure for compute operations\n */\nexport interface ComputeResponse {\n success: boolean;\n error?: string;\n sandboxId: string;\n provider: string;\n [key: string]: any; // Allow any additional response data\n}\n\n/**\n * Execute compute action using targeted handling\n */\nasync function executeAction(body: ComputeRequest, provider: Provider): Promise<ComputeResponse> {\n try {\n const { action, sandboxId } = body;\n \n // Sandbox management operations\n if (action === 'compute.sandbox.create') {\n const sandbox = await compute.sandbox.create({\n provider,\n options: body.options || { runtime: 'python' }\n });\n return {\n success: true,\n sandboxId: sandbox.sandboxId,\n provider: provider.name\n };\n }\n \n if (action === 'compute.sandbox.list') {\n const sandboxes = await compute.sandbox.list(provider);\n return {\n success: true,\n sandboxId: '',\n provider: provider.name,\n sandboxes: sandboxes.map(sb => ({\n sandboxId: sb.sandboxId,\n provider: sb.provider\n }))\n };\n }\n \n if (action === 'compute.sandbox.destroy') {\n if (!sandboxId) {\n throw new Error('sandboxId is required for destroy action');\n }\n await compute.sandbox.destroy(provider, sandboxId);\n return {\n success: true,\n sandboxId,\n provider: provider.name\n };\n }\n \n // For sandbox instance methods, get the sandbox first\n if (!sandboxId) {\n throw new Error('sandboxId is required for this action');\n }\n \n const sandbox = await compute.sandbox.getById(provider, sandboxId);\n if (!sandbox) {\n throw new Error(`Sandbox ${sandboxId} not found`);\n }\n \n // Sandbox info\n if (action === 'compute.sandbox.getInfo') {\n const result = await sandbox.getInfo();\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n info: {\n id: result.id,\n provider: result.provider,\n runtime: result.runtime,\n status: result.status,\n createdAt: result.createdAt.toISOString(),\n timeout: result.timeout,\n metadata: result.metadata\n }\n };\n }\n \n // Code execution\n if (action === 'compute.sandbox.runCode') {\n if (!body.code) throw new Error('code is required');\n const result = await sandbox.runCode(body.code, body.runtime);\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n result: {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n executionTime: result.executionTime\n }\n };\n }\n \n if (action === 'compute.sandbox.runCommand') {\n if (!body.command) throw new Error('command is required');\n const result = await sandbox.runCommand(body.command, body.args, body.commandOptions);\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n result: {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n executionTime: result.executionTime,\n ...(result.isBackground && { isBackground: result.isBackground }),\n ...(result.pid && { pid: result.pid })\n }\n };\n }\n \n // Filesystem operations\n if (action === 'compute.sandbox.filesystem.readFile') {\n if (!body.path) throw new Error('path is required');\n const result = await sandbox.filesystem.readFile(body.path);\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n fileContent: result\n };\n }\n \n if (action === 'compute.sandbox.filesystem.writeFile') {\n if (!body.path) throw new Error('path is required');\n if (body.content === undefined) throw new Error('content is required');\n await sandbox.filesystem.writeFile(body.path, body.content);\n return { success: true, sandboxId, provider: provider.name };\n }\n \n if (action === 'compute.sandbox.filesystem.mkdir') {\n if (!body.path) throw new Error('path is required');\n await sandbox.filesystem.mkdir(body.path);\n return { success: true, sandboxId, provider: provider.name };\n }\n \n if (action === 'compute.sandbox.filesystem.readdir') {\n if (!body.path) throw new Error('path is required');\n const result = await sandbox.filesystem.readdir(body.path);\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n files: result.map((entry: any) => ({\n name: entry.name,\n path: entry.path,\n isDirectory: entry.isDirectory,\n size: entry.size,\n lastModified: entry.lastModified.toISOString()\n }))\n };\n }\n \n if (action === 'compute.sandbox.filesystem.exists') {\n if (!body.path) throw new Error('path is required');\n const result = await sandbox.filesystem.exists(body.path);\n return {\n success: true,\n sandboxId,\n provider: provider.name,\n exists: result\n };\n }\n \n if (action === 'compute.sandbox.filesystem.remove') {\n if (!body.path) throw new Error('path is required');\n await sandbox.filesystem.remove(body.path);\n return { success: true, sandboxId, provider: provider.name };\n }\n \n throw new Error(`Unknown action: ${action}`);\n \n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n sandboxId: body.sandboxId || '',\n provider: provider.name\n };\n }\n}\n\n/**\n * Main request handler - handles HTTP requests and pre-parsed bodies\n */\nexport async function handleComputeRequest(\n params: HandleComputeRequestParams\n): Promise<ComputeResponse>;\nexport async function handleComputeRequest(\n requestOrBody: Request | ComputeRequest,\n provider: Provider\n): Promise<Response>;\nexport async function handleComputeRequest(\n paramsOrRequestOrBody: HandleComputeRequestParams | Request | ComputeRequest,\n provider?: Provider\n): Promise<ComputeResponse | Response> {\n // Handle object-style API\n if (typeof paramsOrRequestOrBody === 'object' && 'request' in paramsOrRequestOrBody && 'provider' in paramsOrRequestOrBody) {\n const params = paramsOrRequestOrBody as HandleComputeRequestParams;\n return await executeAction(params.request, params.provider);\n }\n \n // Handle original API\n if (!provider) {\n throw new Error('Provider is required when not using object-style API');\n }\n \n const requestOrBody = paramsOrRequestOrBody as Request | ComputeRequest;\n try {\n let body: ComputeRequest;\n \n if (requestOrBody instanceof Request) {\n // Handle HTTP method validation\n if (requestOrBody.method !== 'POST') {\n return Response.json({\n success: false,\n error: 'Only POST requests are supported',\n sandboxId: '',\n provider: provider.name\n }, { status: 405 });\n }\n \n // Parse JSON body with better error handling\n try {\n body = await requestOrBody.json();\n } catch (parseError) {\n return Response.json({\n success: false,\n error: 'Invalid JSON in request body',\n sandboxId: '',\n provider: provider.name\n }, { status: 400 });\n }\n } else {\n body = requestOrBody;\n }\n \n // Execute the action\n const result = await executeAction(body, provider);\n \n return Response.json(result, {\n status: result.success ? 200 : 500\n });\n \n } catch (error) {\n return Response.json({\n success: false,\n error: error instanceof Error ? error.message : 'Request handling failed',\n sandboxId: '',\n provider: provider.name\n }, { status: 500 });\n }\n}\n\n/**\n * Legacy export for backward compatibility\n */\nexport interface HandleComputeRequestParams {\n request: ComputeRequest;\n provider: Provider;\n}\n\nexport { handleComputeRequest as handleHttpComputeRequest };","/**\n * Provider Factory - Creates providers from method definitions\n * \n * Eliminates boilerplate by auto-generating Provider/Sandbox classes\n * from simple method definitions with automatic feature detection.\n */\n\nimport type {\n Provider,\n ProviderSandboxManager,\n ProviderTemplateManager,\n ProviderSnapshotManager,\n Sandbox,\n SandboxFileSystem,\n SandboxInfo,\n ExecutionResult,\n Runtime,\n CreateSandboxOptions,\n FileEntry,\n RunCommandOptions,\n CreateSnapshotOptions,\n ListSnapshotsOptions,\n CreateTemplateOptions,\n ListTemplatesOptions,\n} from './types/index.js';\n\n/**\n * Helper function to handle background command execution\n * Providers can use this to implement background job support\n */\nexport function createBackgroundCommand(command: string, args: string[] = [], options?: RunCommandOptions): { command: string; args: string[]; isBackground: boolean } {\n if (!options?.background) {\n return { command, args, isBackground: false };\n }\n\n // For background execution, we modify the command to run in background\n // Default approach: append & to make it run in background\n const fullCommand = args.length > 0 ? `${command} ${args.join(' ')}` : command;\n \n return {\n command: 'sh',\n args: ['-c', `${fullCommand} &`],\n isBackground: true\n };\n}\n\n/**\n * Flat sandbox method implementations - all operations in one place\n */\nexport interface SandboxMethods<TSandbox = any, TConfig = any> {\n // Collection operations (map to compute.sandbox.*)\n create: (config: TConfig, options?: CreateSandboxOptions) => Promise<{ sandbox: TSandbox; sandboxId: string }>;\n getById: (config: TConfig, sandboxId: string) => Promise<{ sandbox: TSandbox; sandboxId: string } | null>;\n list: (config: TConfig) => Promise<Array<{ sandbox: TSandbox; sandboxId: string }>>;\n destroy: (config: TConfig, sandboxId: string) => Promise<void>;\n \n // Instance operations (map to individual Sandbox methods)\n runCode: (sandbox: TSandbox, code: string, runtime?: Runtime, config?: TConfig) => Promise<ExecutionResult>;\n runCommand: (sandbox: TSandbox, command: string, args?: string[], options?: RunCommandOptions) => Promise<ExecutionResult>;\n getInfo: (sandbox: TSandbox) => Promise<SandboxInfo>;\n getUrl: (sandbox: TSandbox, options: { port: number; protocol?: string }) => Promise<string>;\n \n // Optional provider-specific typed getInstance method\n getInstance?: (sandbox: TSandbox) => TSandbox;\n \n // Optional filesystem methods\n filesystem?: {\n readFile: (sandbox: TSandbox, path: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<string>;\n writeFile: (sandbox: TSandbox, path: string, content: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<void>;\n mkdir: (sandbox: TSandbox, path: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<void>;\n readdir: (sandbox: TSandbox, path: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<FileEntry[]>;\n exists: (sandbox: TSandbox, path: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<boolean>;\n remove: (sandbox: TSandbox, path: string, runCommand: (sandbox: TSandbox, command: string, args?: string[]) => Promise<ExecutionResult>) => Promise<void>;\n };\n}\n\n/**\n * Template method implementations\n */\nexport interface TemplateMethods<TTemplate = any, TConfig = any> {\n create: (config: TConfig, options: CreateTemplateOptions | any) => Promise<TTemplate>;\n list: (config: TConfig, options?: ListTemplatesOptions) => Promise<TTemplate[]>;\n delete: (config: TConfig, templateId: string) => Promise<void>;\n}\n\n/**\n * Snapshot method implementations \n */\nexport interface SnapshotMethods<TSnapshot = any, TConfig = any> {\n create: (config: TConfig, sandboxId: string, options?: CreateSnapshotOptions) => Promise<TSnapshot>;\n list: (config: TConfig, options?: ListSnapshotsOptions) => Promise<TSnapshot[]>;\n delete: (config: TConfig, snapshotId: string) => Promise<void>;\n}\n\n/**\n * Provider configuration for createProvider()\n */\nexport interface ProviderConfig<TSandbox = any, TConfig = any, TTemplate = any, TSnapshot = any> {\n name: string;\n methods: {\n sandbox: SandboxMethods<TSandbox, TConfig>;\n template?: TemplateMethods<TTemplate, TConfig>;\n snapshot?: SnapshotMethods<TSnapshot, TConfig>;\n };\n}\n\n/**\n * Default filesystem implementations based on shell commands\n * These work for any provider that supports shell command execution\n */\nconst defaultFilesystemMethods = {\n readFile: async (sandbox: any, path: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<string> => {\n const result = await runCommand(sandbox, 'cat', [path]);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to read file ${path}: ${result.stderr}`);\n }\n // Trim trailing newline that cat command adds\n return result.stdout.replace(/\\n$/, '');\n },\n\n writeFile: async (sandbox: any, path: string, content: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<void> => {\n const result = await runCommand(sandbox, 'sh', ['-c', `echo ${JSON.stringify(content)} > ${JSON.stringify(path)}`]);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to write file ${path}: ${result.stderr}`);\n }\n },\n\n mkdir: async (sandbox: any, path: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<void> => {\n const result = await runCommand(sandbox, 'mkdir', ['-p', path]);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to create directory ${path}: ${result.stderr}`);\n }\n },\n\n readdir: async (sandbox: any, path: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<FileEntry[]> => {\n // Try different ls variations for maximum compatibility\n let result = await runCommand(sandbox, 'ls', ['-la', path]);\n let hasDetailedOutput = true;\n \n // Fall back to basic ls if detailed flags not supported\n if (result.exitCode !== 0) {\n result = await runCommand(sandbox, 'ls', ['-l', path]);\n }\n if (result.exitCode !== 0) {\n result = await runCommand(sandbox, 'ls', [path]);\n hasDetailedOutput = false;\n }\n \n if (result.exitCode !== 0) {\n throw new Error(`Failed to list directory ${path}: ${result.stderr}`);\n }\n\n const lines = (result.stdout || '').split('\\n').filter((line: string) => line.trim() && !line.startsWith('total'));\n\n return lines.map((line: string) => {\n if (hasDetailedOutput && line.includes(' ')) {\n // Parse detailed ls output (ls -la or ls -l)\n const parts = line.trim().split(/\\s+/);\n const name = parts[parts.length - 1];\n const isDirectory = line.startsWith('d');\n \n return {\n name,\n path: `${path}/${name}`,\n isDirectory,\n size: parseInt(parts[4]) || 0,\n lastModified: new Date()\n };\n } else {\n // Parse simple ls output (just filenames)\n const name = line.trim();\n return {\n name,\n path: `${path}/${name}`,\n isDirectory: false, // Can't determine from simple ls\n size: 0,\n lastModified: new Date()\n };\n }\n });\n },\n\n exists: async (sandbox: any, path: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<boolean> => {\n const result = await runCommand(sandbox, 'test', ['-e', path]);\n return result.exitCode === 0; // Exit code 0 means file exists\n },\n\n remove: async (sandbox: any, path: string, runCommand: (sandbox: any, command: string, args?: string[]) => Promise<ExecutionResult>): Promise<void> => {\n const result = await runCommand(sandbox, 'rm', ['-rf', path]);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to remove ${path}: ${result.stderr}`);\n }\n }\n};\n\n/**\n * Auto-generated filesystem implementation that throws \"not supported\" errors\n */\nclass UnsupportedFileSystem implements SandboxFileSystem {\n private readonly providerName: string;\n\n constructor(providerName: string) {\n this.providerName = providerName;\n }\n\n async readFile(_path: string): Promise<string> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n\n async writeFile(_path: string, _content: string): Promise<void> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n\n async mkdir(_path: string): Promise<void> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n\n async readdir(_path: string): Promise<FileEntry[]> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n\n async exists(_path: string): Promise<boolean> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n\n async remove(_path: string): Promise<void> {\n throw new Error(`Filesystem operations are not supported by ${this.providerName}'s sandbox environment. ${this.providerName} sandboxes are designed for code execution only.`);\n }\n}\n\n\n\n/**\n * Auto-generated filesystem implementation that wraps provider methods\n */\nclass SupportedFileSystem<TSandbox> implements SandboxFileSystem {\n constructor(\n private sandbox: TSandbox,\n private methods: NonNullable<SandboxMethods<TSandbox>['filesystem']>,\n private allMethods: SandboxMethods<TSandbox>\n ) {}\n\n async readFile(path: string): Promise<string> {\n return this.methods.readFile(this.sandbox, path, this.allMethods.runCommand);\n }\n\n async writeFile(path: string, content: string): Promise<void> {\n return this.methods.writeFile(this.sandbox, path, content, this.allMethods.runCommand);\n }\n\n async mkdir(path: string): Promise<void> {\n return this.methods.mkdir(this.sandbox, path, this.allMethods.runCommand);\n }\n\n async readdir(path: string): Promise<FileEntry[]> {\n return this.methods.readdir(this.sandbox, path, this.allMethods.runCommand);\n }\n\n async exists(path: string): Promise<boolean> {\n return this.methods.exists(this.sandbox, path, this.allMethods.runCommand);\n }\n\n async remove(path: string): Promise<void> {\n return this.methods.remove(this.sandbox, path, this.allMethods.runCommand);\n }\n}\n\n\n\n\n\n/**\n * Generated sandbox class - implements the Sandbox interface\n */\nclass GeneratedSandbox<TSandbox = any> implements Sandbox<TSandbox> {\n readonly sandboxId: string;\n readonly provider: string;\n readonly filesystem: SandboxFileSystem;\n\n constructor(\n private sandbox: TSandbox,\n sandboxId: string,\n providerName: string,\n private methods: SandboxMethods<TSandbox>,\n private config: any,\n private destroyMethod: (config: any, sandboxId: string) => Promise<void>,\n private providerInstance: Provider\n ) {\n this.sandboxId = sandboxId;\n this.provider = providerName;\n\n // Auto-detect filesystem support\n if (methods.filesystem) {\n this.filesystem = new SupportedFileSystem(sandbox, methods.filesystem, methods);\n } else {\n this.filesystem = new UnsupportedFileSystem(providerName);\n }\n }\n\n getInstance(): TSandbox {\n // Use provider-specific typed getInstance if available\n if (this.methods.getInstance) {\n return this.methods.getInstance(this.sandbox);\n }\n // Fallback to returning the sandbox directly\n return this.sandbox;\n }\n\n async runCode(code: string, runtime?: Runtime): Promise<ExecutionResult> {\n return await this.methods.runCode(this.sandbox, code, runtime, this.config);\n }\n\n async runCommand(command: string, args?: string[], options?: RunCommandOptions): Promise<ExecutionResult> {\n return await this.methods.runCommand(this.sandbox, command, args, options);\n }\n\n async getInfo(): Promise<SandboxInfo> {\n return await this.methods.getInfo(this.sandbox);\n }\n\n async getUrl(options: { port: number; protocol?: string }): Promise<string> {\n return await this.methods.getUrl(this.sandbox, options);\n }\n\n getProvider(): Provider<TSandbox> {\n return this.providerInstance;\n }\n\n async kill(): Promise<void> {\n // For backward compatibility, kill() delegates to destroy()\n await this.destroy();\n }\n\n async destroy(): Promise<void> {\n // Destroy via the provider's destroy method using our sandboxId\n await this.destroyMethod(this.config, this.sandboxId);\n }\n}\n\n/**\n * Auto-generated Sandbox Manager implementation\n */\nclass GeneratedSandboxManager<TSandbox, TConfig> implements ProviderSandboxManager<TSandbox> {\n private activeSandboxes: Map<string, GeneratedSandbox<TSandbox>> = new Map();\n\n constructor(\n private config: TConfig,\n private providerName: string,\n private methods: SandboxMethods<TSandbox, TConfig>,\n private providerInstance: Provider\n ) {}\n\n async create(options?: CreateSandboxOptions): Promise<Sandbox<TSandbox>> {\n // Default to 'node' runtime if not specified for consistency across providers\n const optionsWithDefaults = { runtime: 'node' as Runtime, ...options };\n const result = await this.methods.create(this.config, optionsWithDefaults);\n const sandbox = new GeneratedSandbox<TSandbox>(\n result.sandbox,\n result.sandboxId,\n this.providerName,\n this.methods,\n this.config,\n this.methods.destroy,\n this.providerInstance\n );\n \n this.activeSandboxes.set(result.sandboxId, sandbox);\n return sandbox;\n }\n\n async getById(sandboxId: string): Promise<Sandbox<TSandbox> | null> {\n // Check active sandboxes first\n const existing = this.activeSandboxes.get(sandboxId);\n if (existing) {\n return existing;\n }\n\n // Try to reconnect\n const result = await this.methods.getById(this.config, sandboxId);\n if (!result) {\n return null;\n }\n\n const sandbox = new GeneratedSandbox<TSandbox>(\n result.sandbox,\n result.sandboxId,\n this.providerName,\n this.methods,\n this.config,\n this.methods.destroy,\n this.providerInstance\n );\n \n this.activeSandboxes.set(result.sandboxId, sandbox);\n return sandbox;\n }\n\n async list(): Promise<Sandbox<TSandbox>[]> {\n const results = await this.methods.list(this.config);\n const sandboxes: Sandbox[] = [];\n\n for (const result of results) {\n let sandbox = this.activeSandboxes.get(result.sandboxId);\n if (!sandbox) {\n sandbox = new GeneratedSandbox<TSandbox>(\n result.sandbox,\n result.sandboxId,\n this.providerName,\n this.methods,\n this.config,\n this.methods.destroy,\n this.providerInstance\n );\n this.activeSandboxes.set(result.sandboxId, sandbox);\n }\n sandboxes.push(sandbox);\n }\n\n return sandboxes;\n }\n\n async destroy(sandboxId: string): Promise<void> {\n await this.methods.destroy(this.config, sandboxId);\n this.activeSandboxes.delete(sandboxId);\n }\n}\n\n/**\n * Auto-generated Template Manager implementation\n */\nclass GeneratedTemplateManager<TTemplate, TConfig> implements ProviderTemplateManager<TTemplate> {\n constructor(\n private config: TConfig,\n private methods: TemplateMethods<TTemplate, TConfig>\n ) {}\n\n async create(options: CreateTemplateOptions | any): Promise<TTemplate> {\n return await this.methods.create(this.config, options);\n }\n\n async list(options?: ListTemplatesOptions): Promise<TTemplate[]> {\n return await this.methods.list(this.config, options);\n }\n\n async delete(templateId: string): Promise<void> {\n return await this.methods.delete(this.config, templateId);\n }\n}\n\n/**\n * Auto-generated Snapshot Manager implementation\n */\nclass GeneratedSnapshotManager<TSnapshot, TConfig> implements ProviderSnapshotManager<TSnapshot> {\n constructor(\n private config: TConfig,\n private methods: SnapshotMethods<TSnapshot, TConfig>\n ) {}\n\n async create(sandboxId: string, options?: CreateSnapshotOptions): Promise<TSnapshot> {\n return await this.methods.create(this.config, sandboxId, options);\n }\n\n async list(options?: ListSnapshotsOptions): Promise<TSnapshot[]> {\n return await this.methods.list(this.config, options);\n }\n\n async delete(snapshotId: string): Promise<void> {\n return await this.methods.delete(this.config, snapshotId);\n }\n}\n\n/**\n * Auto-generated Provider implementation\n */\nclass GeneratedProvider<TSandbox, TConfig, TTemplate, TSnapshot> implements Provider<TSandbox, TTemplate, TSnapshot> {\n readonly name: string;\n readonly sandbox: ProviderSandboxManager<TSandbox>;\n readonly template?: ProviderTemplateManager<TTemplate>;\n readonly snapshot?: ProviderSnapshotManager<TSnapshot>;\n readonly __sandboxType!: TSandbox; // Phantom type for TypeScript inference\n\n constructor(config: TConfig, providerConfig: ProviderConfig<TSandbox, TConfig, TTemplate, TSnapshot>) {\n this.name = providerConfig.name;\n this.sandbox = new GeneratedSandboxManager(\n config,\n providerConfig.name,\n providerConfig.methods.sandbox,\n this\n );\n\n // Initialize optional managers if methods are provided\n if (providerConfig.methods.template) {\n this.template = new GeneratedTemplateManager(config, providerConfig.methods.template);\n }\n \n if (providerConfig.methods.snapshot) {\n this.snapshot = new GeneratedSnapshotManager(config, providerConfig.methods.snapshot);\n }\n }\n\n getSupportedRuntimes(): Runtime[] {\n // For now, all providers support both node and python\n // In the future, this could be configurable per provider\n return ['node', 'python'];\n }\n}\n\n/**\n * Create a provider from method definitions\n * \n * Auto-generates all boilerplate classes and provides feature detection\n * based on which methods are implemented.\n */\nexport function createProvider<TSandbox, TConfig = any, TTemplate = any, TSnapshot = any>(\n providerConfig: ProviderConfig<TSandbox, TConfig, TTemplate, TSnapshot>\n): (config: TConfig) => Provider<TSandbox, TTemplate, TSnapshot> {\n // Auto-inject default filesystem methods if none provided\n if (!providerConfig.methods.sandbox.filesystem) {\n providerConfig.methods.sandbox.filesystem = defaultFilesystemMethods;\n }\n\n return (config: TConfig) => {\n return new GeneratedProvider(config, providerConfig);\n };\n}"],"mappings":";AAwJO,IAAM,mBAAN,cAA+B,MAAM;AAAA,EAE1C,YAAmB,QAKhB;AACD,UAAM,4BAA4B,OAAO,QAAQ,EAAE;AANlC;AADnB,gBAAO;AAAA,EAQP;AACF;AAKO,SAAS,mBAAmB,OAA2C;AAC5E,SACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,MAAM,SAAS,sBACf,YAAY;AAEhB;;;ACzKA,SAAS,qBAAqB;AAe9B,eAAe,gBAAgB,QAAgD;AAC7E,MAAI;AACF,UAAM,WAAW,MAAM,MAAM,0DAA0D;AAAA,MACrF,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM,KAAK,UAAU;AAAA,QACnB,KAAK;AAAA,QACL,iBAAiB;AAAA,MACnB,CAAC;AAAA,IACH,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,YAAY,MAAM,SAAS,KAAK,EAAE,MAAM,MAAM,SAAS,UAAU;AACvE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MAAM,KAAK,QAAQ,OAAO,KAAK,QAAQ,WAAW,OAAO;AAAA,EAClE;AAAA,EAEA,MAAM,KAAK,SAAsD;AAC/D,WAAO,MAAM,KAAK,QAAQ,KAAK,KAAK,QAAQ,OAAO;AAAA,EACrD;AAAA,EAEA,MAAM,OAAO,YAAmC;AAC9C,WAAO,MAAM,KAAK,QAAQ,OAAO,KAAK,QAAQ,UAAU;AAAA,EAC1D;AACF;AAKA,IAAM,oBAAN,MAAqH;AAAA;AAAA,EAOnH,YAAY,QAAiB,gBAAyE;AACpG,SAAK,OAAO,eAAe;AAC3B,SAAK,UAAU,IAAI;AAAA,MACjB;AAAA,MACA,eAAe;AAAA,MACf,eAAe,QAAQ;AAAA,MACvB;AAAA,IACF;AAGA,QAAI,eAAe,QAAQ,UAAU;AACnC,WAAK,WAAW,IAAI,yBAAyB,QAAQ,eAAe,QAAQ,QAAQ;AAAA,IACtF;AAEA,QAAI,eAAe,QAAQ,UAAU;AACnC,WAAK,WAAW,IAAI,yBAAyB,QAAQ,eAAe,QAAQ,QAAQ;AAAA,IACtF;AAAA,EACF;AAAA,EAEA,uBAAkC;AAGhC,WAAO,CAAC,QAAQ,QAAQ;AAAA,EAC1B;AACF;AAQO,SAAS,eACd,gBAC+D;AAE/D,MAAI,CAAC,eAAe,QAAQ,QAAQ,YAAY;AAC9C,mBAAe,QAAQ,QAAQ,aAAa;AAAA,EAC9C;AAEA,SAAO,CAAC,WAAoB;AAC1B,WAAO,IAAI,kBAAkB,QAAQ,cAAc;AAAA,EACrD;AACF;","names":["sandbox"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "computesdk",
3
- "version": "1.8.5",
3
+ "version": "1.8.6",
4
4
  "description": "A free and open-source toolkit for running other people's code in your applications.",
5
5
  "author": "Garrison",
6
6
  "license": "MIT",
@@ -37,13 +37,10 @@
37
37
  "url": "https://github.com/computesdk/computesdk/issues"
38
38
  },
39
39
  "dependencies": {
40
- "zod": "^3.22.0",
41
- "uuid": "^9.0.0",
42
- "@computesdk/client": "0.3.4"
40
+ "@computesdk/client": "0.3.5"
43
41
  },
44
42
  "devDependencies": {
45
43
  "@types/node": "^20.0.0",
46
- "@types/uuid": "^9.0.0",
47
44
  "@vitest/coverage-v8": "^1.0.0",
48
45
  "eslint": "^8.37.0",
49
46
  "rimraf": "^5.0.0",