@computesdk/hopx 0.2.21 → 0.2.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,7 +1,6 @@
1
1
  import * as _computesdk_provider from '@computesdk/provider';
2
2
  import { Sandbox } from '@hopx-ai/sdk';
3
3
  export { Sandbox as HopxSandbox } from '@hopx-ai/sdk';
4
- import { Runtime } from 'computesdk';
5
4
 
6
5
  /**
7
6
  * HopX-specific configuration options
@@ -9,8 +8,6 @@ import { Runtime } from 'computesdk';
9
8
  interface HopxConfig {
10
9
  /** HopX API key - if not provided, will fallback to HOPX_API_KEY environment variable */
11
10
  apiKey?: string;
12
- /** Default runtime environment */
13
- runtime?: Runtime;
14
11
  /** Execution timeout in milliseconds */
15
12
  timeout?: number;
16
13
  /** Template name for sandbox creation (e.g., 'code-interpreter') */
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import * as _computesdk_provider from '@computesdk/provider';
2
2
  import { Sandbox } from '@hopx-ai/sdk';
3
3
  export { Sandbox as HopxSandbox } from '@hopx-ai/sdk';
4
- import { Runtime } from 'computesdk';
5
4
 
6
5
  /**
7
6
  * HopX-specific configuration options
@@ -9,8 +8,6 @@ import { Runtime } from 'computesdk';
9
8
  interface HopxConfig {
10
9
  /** HopX API key - if not provided, will fallback to HOPX_API_KEY environment variable */
11
10
  apiKey?: string;
12
- /** Default runtime environment */
13
- runtime?: Runtime;
14
11
  /** Execution timeout in milliseconds */
15
12
  timeout?: number;
16
13
  /** Template name for sandbox creation (e.g., 'code-interpreter') */
package/dist/index.js CHANGED
@@ -48,7 +48,6 @@ var hopx = (0, import_provider.defineProvider)({
48
48
  let sandbox;
49
49
  let sandboxId;
50
50
  const {
51
- runtime: _runtime,
52
51
  timeout: _timeout,
53
52
  envs,
54
53
  name,
@@ -162,12 +161,6 @@ var hopx = (0, import_provider.defineProvider)({
162
161
  } catch (error) {
163
162
  }
164
163
  },
165
- /**
166
- * Execute code in the sandbox
167
- *
168
- * Uses sandbox.runCode() with auto-detected runtime.
169
- * Maps ComputeSDK runtime ('node'/'python') to HopX language ('javascript'/'python').
170
- */
171
164
  /**
172
165
  * Execute a shell command in the sandbox
173
166
  *
@@ -225,8 +218,6 @@ var hopx = (0, import_provider.defineProvider)({
225
218
  return {
226
219
  id: sandbox.sandboxId,
227
220
  provider: "hopx",
228
- runtime: "python",
229
- // HopX default runtime
230
221
  status: info.status || "running",
231
222
  createdAt: info.createdAt ? new Date(info.createdAt) : /* @__PURE__ */ new Date(),
232
223
  timeout: info.timeoutSeconds ? info.timeoutSeconds * 1e3 : 3e5,
@@ -241,7 +232,6 @@ var hopx = (0, import_provider.defineProvider)({
241
232
  return {
242
233
  id: sandbox.sandboxId,
243
234
  provider: "hopx",
244
- runtime: "python",
245
235
  status: "running",
246
236
  createdAt: /* @__PURE__ */ new Date(),
247
237
  timeout: 3e5,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * HopX Provider - Factory-based Implementation\n * \n * Full-featured provider with native filesystem support using the factory pattern.\n * HopX provides isolated cloud sandboxes (lightweight VMs) with full Linux environments.\n * \n * Features:\n * - Native filesystem API via sandbox.files.*\n * - Code execution in Python, JavaScript, Bash\n * - Shell command execution\n * - Preview URLs for accessing sandbox services\n */\n\nimport { Sandbox as HopxSandbox } from '@hopx-ai/sdk';\nimport { defineProvider } from '@computesdk/provider';\nimport type {\n CodeResult,\n CommandResult,\n SandboxInfo,\n Runtime,\n CreateSandboxOptions,\n FileEntry,\n RunCommandOptions\n} from 'computesdk';\n\n/**\n * HopX-specific configuration options\n */\nexport interface HopxConfig {\n /** HopX API key - if not provided, will fallback to HOPX_API_KEY environment variable */\n apiKey?: string;\n /** Default runtime environment */\n runtime?: Runtime;\n /** Execution timeout in milliseconds */\n timeout?: number;\n /** Template name for sandbox creation (e.g., 'code-interpreter') */\n template?: string;\n /** Base API URL for custom/staging environments */\n baseURL?: string;\n}\n\n/**\n * Create a HopX provider instance using the factory pattern\n * \n * HopX provides isolated cloud sandboxes with:\n * - Full root access to the VM\n * - Pre-installed language runtimes (Python, Node.js, etc.)\n * - Persistent filesystem during session\n * - Automatic cleanup after timeout\n */\nexport const hopx = defineProvider<HopxSandbox, HopxConfig>({\n name: 'hopx',\n methods: {\n sandbox: {\n /**\n * Create a new HopX sandbox\n * \n * Uses Sandbox.create() from @hopx-ai/sdk to provision a new sandbox.\n * Default template is 'code-interpreter' if not specified.\n */\n create: async (config: HopxConfig, options?: CreateSandboxOptions) => {\n // Validate API key - fail fast with helpful error message\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.HOPX_API_KEY) || '';\n\n if (!apiKey) {\n throw new Error(\n `Missing HopX API key. Provide 'apiKey' in config or set HOPX_API_KEY environment variable. Get your API key from https://hopx.ai/dashboard`\n );\n }\n\n // Convert timeout from milliseconds to seconds (HopX uses seconds)\n // options.timeout takes precedence over config.timeout\n const timeout = options?.timeout ?? config.timeout;\n const timeoutSeconds = timeout ? Math.ceil(timeout / 1000) : undefined;\n\n try {\n let sandbox: HopxSandbox;\n let sandboxId: string;\n\n // Destructure known ComputeSDK fields, collect the rest for passthrough\n const {\n runtime: _runtime,\n timeout: _timeout,\n envs,\n name,\n metadata: _metadata,\n templateId,\n snapshotId,\n sandboxId: _sandboxId,\n namespace: _namespace,\n directory: _directory,\n ...providerOptions\n } = options || {};\n\n // Create new HopX sandbox using Sandbox.create()\n const createOptions: any = {\n apiKey,\n baseURL: config.baseURL,\n timeoutSeconds,\n ...providerOptions, // Spread provider-specific options\n };\n\n // Handle template specification (templateId/snapshotId takes precedence)\n if (templateId || snapshotId) {\n createOptions.templateId = templateId || snapshotId;\n } else {\n createOptions.template = config.template || 'code-interpreter';\n }\n\n // Remap envs to envVars\n if (envs) {\n createOptions.envVars = envs;\n }\n\n // Pass sandbox name\n if (name) {\n createOptions.name = name;\n }\n\n sandbox = await HopxSandbox.create(createOptions);\n sandboxId = sandbox.sandboxId;\n\n return {\n sandbox,\n sandboxId\n };\n } catch (error) {\n // Provide helpful error messages for common issues\n if (error instanceof Error) {\n if (error.message.includes('unauthorized') || error.message.includes('API key') || error.message.includes('401')) {\n throw new Error(\n `HopX authentication failed. Please check your HOPX_API_KEY environment variable. Get your API key from https://hopx.ai/dashboard`\n );\n }\n if (error.message.includes('quota') || error.message.includes('limit')) {\n throw new Error(\n `HopX quota exceeded. Please check your usage at https://hopx.ai/dashboard`\n );\n }\n }\n throw new Error(\n `Failed to create HopX sandbox: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n /**\n * Connect to an existing HopX sandbox by ID\n * \n * Uses Sandbox.connect() to reconnect to a running sandbox.\n * Returns null if sandbox doesn't exist or can't be accessed.\n */\n getById: async (config: HopxConfig, sandboxId: string) => {\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.HOPX_API_KEY) || '';\n\n if (!apiKey) {\n return null;\n }\n\n try {\n // Connect to existing sandbox using Sandbox.connect()\n const sandbox = await HopxSandbox.connect(sandboxId, apiKey, config.baseURL);\n\n return {\n sandbox,\n sandboxId\n };\n } catch (error) {\n // Sandbox doesn't exist or can't be accessed\n return null;\n }\n },\n\n /**\n * List all active HopX sandboxes\n * \n * Uses Sandbox.list() to get all sandboxes for the account.\n */\n list: async (config: HopxConfig) => {\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.HOPX_API_KEY) || '';\n\n if (!apiKey) {\n return [];\n }\n\n try {\n // List sandboxes using Sandbox.list()\n const sandboxes = await HopxSandbox.list({\n apiKey,\n baseURL: config.baseURL,\n });\n\n return sandboxes.map((sandbox: HopxSandbox) => ({\n sandbox,\n sandboxId: sandbox.sandboxId\n }));\n } catch (error) {\n // Return empty array if listing fails\n return [];\n }\n },\n\n /**\n * Destroy a HopX sandbox\n * \n * Uses sandbox.kill() to terminate and clean up the sandbox.\n */\n destroy: async (config: HopxConfig, sandboxId: string) => {\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.HOPX_API_KEY) || '';\n\n if (!apiKey) {\n return;\n }\n\n try {\n // Connect to sandbox and kill it\n const sandbox = await HopxSandbox.connect(sandboxId, apiKey, config.baseURL);\n await sandbox.kill();\n } catch (error) {\n // Sandbox might already be destroyed or doesn't exist\n // This is acceptable for destroy operations\n }\n },\n\n /**\n * Execute code in the sandbox\n * \n * Uses sandbox.runCode() with auto-detected runtime.\n * Maps ComputeSDK runtime ('node'/'python') to HopX language ('javascript'/'python').\n */\n\n /**\n * Execute a shell command in the sandbox\n * \n * Uses sandbox.commands.run() to execute shell commands.\n * Arguments are properly quoted to handle special characters.\n */\n runCommand: async (sandbox: HopxSandbox, command: string, options?: RunCommandOptions): Promise<CommandResult> => {\n const startTime = Date.now();\n try {\n // Build command with options\n let fullCommand = command;\n \n // Handle environment variables\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([k, v]) => `${k}=\"${v.replace(/\"/g, '\\\\\"')}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n \n // Handle working directory\n if (options?.cwd) {\n fullCommand = `cd \"${options.cwd.replace(/\"/g, '\\\\\"')}\" && ${fullCommand}`;\n }\n \n // Handle background execution\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n \n // Execute command using sandbox.commands.run()\n const result = await sandbox.commands.run(fullCommand);\n \n return {\n stdout: result.stdout || '',\n stderr: result.stderr || '',\n exitCode: result.exit_code || 0, // Note: HopX uses snake_case\n durationMs: Date.now() - startTime\n };\n } catch (error) {\n // Extract result from error if available (some errors include partial results)\n const result = (error as any)?.result;\n if (result) {\n return {\n stdout: result.stdout || '',\n stderr: result.stderr || '',\n exitCode: result.exit_code || 1,\n durationMs: Date.now() - startTime\n };\n }\n \n // Fallback for other errors (command not found, etc.)\n return {\n stdout: '',\n stderr: error instanceof Error ? error.message : String(error),\n exitCode: 127,\n durationMs: Date.now() - startTime\n };\n }\n },\n\n /**\n * Get sandbox information\n * \n * Uses sandbox.getInfo() to retrieve sandbox metadata.\n */\n getInfo: async (sandbox: HopxSandbox): Promise<SandboxInfo> => {\n try {\n const info = await sandbox.getInfo();\n\n return {\n id: sandbox.sandboxId,\n provider: 'hopx',\n runtime: 'python', // HopX default runtime\n status: (info.status as 'running' | 'stopped' | 'error') || 'running',\n createdAt: info.createdAt ? new Date(info.createdAt) : new Date(),\n timeout: info.timeoutSeconds ? info.timeoutSeconds * 1000 : 300000,\n metadata: {\n templateName: info.templateName,\n templateId: info.templateId,\n region: info.region,\n publicHost: info.publicHost,\n }\n };\n } catch (error) {\n // Return basic info if getInfo fails\n return {\n id: sandbox.sandboxId,\n provider: 'hopx',\n runtime: 'python',\n status: 'running',\n createdAt: new Date(),\n timeout: 300000,\n metadata: {}\n };\n }\n },\n\n /**\n * Get preview URL for a specific port\n * \n * Uses sandbox.getPreviewUrl() to get the public URL for accessing\n * services running on a specific port in the sandbox.\n */\n getUrl: async (sandbox: HopxSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n try {\n // Use HopX's built-in getPreviewUrl method\n const url = await sandbox.getPreviewUrl(options.port);\n return url;\n } catch (error) {\n throw new Error(\n `Failed to get HopX URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n /**\n * Native filesystem operations using HopX's files API\n * \n * HopX has full native filesystem support via sandbox.files.*\n * This is Option A from the documentation (native API, not shell-based).\n */\n filesystem: {\n /**\n * Read file contents from sandbox\n */\n readFile: async (sandbox: HopxSandbox, path: string): Promise<string> => {\n return await sandbox.files.read(path);\n },\n\n /**\n * Write content to a file in the sandbox\n */\n writeFile: async (sandbox: HopxSandbox, path: string, content: string): Promise<void> => {\n await sandbox.files.write(path, content);\n },\n\n /**\n * Create a directory in the sandbox\n */\n mkdir: async (sandbox: HopxSandbox, path: string): Promise<void> => {\n await sandbox.files.mkdir(path);\n },\n\n /**\n * List directory contents\n * \n * Maps HopX's EnhancedFileInfo to ComputeSDK's FileEntry format.\n */\n readdir: async (sandbox: HopxSandbox, path: string): Promise<FileEntry[]> => {\n const entries = await sandbox.files.list(path);\n\n return entries.map((entry: any) => ({\n name: entry.name,\n type: (entry.isDir || entry.isDirectory) ? 'directory' as const : 'file' as const,\n path: entry.path || `${path}/${entry.name}`.replace(/\\/+/g, '/'),\n isDirectory: Boolean(entry.isDir || entry.isDirectory || entry.type === 'directory'),\n size: entry.size || 0,\n lastModified: entry.modTime ? new Date(entry.modTime) : new Date()\n }));\n },\n\n /**\n * Check if a file or directory exists\n */\n exists: async (sandbox: HopxSandbox, path: string): Promise<boolean> => {\n return await sandbox.files.exists(path);\n },\n\n /**\n * Remove a file or directory\n */\n remove: async (sandbox: HopxSandbox, path: string): Promise<void> => {\n await sandbox.files.remove(path);\n }\n },\n\n /**\n * Get the native HopX Sandbox instance for advanced usage\n * \n * This allows users to access HopX-specific features not exposed\n * through the ComputeSDK interface.\n */\n getInstance: (sandbox: HopxSandbox): HopxSandbox => {\n return sandbox;\n },\n }\n }\n});\n\n// Export HopX sandbox type for explicit typing\nexport type { Sandbox as HopxSandbox } from '@hopx-ai/sdk';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,iBAAuC;AACvC,sBAA+B;AAoCxB,IAAM,WAAO,gCAAwC;AAAA,EAC1D,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOP,QAAQ,OAAO,QAAoB,YAAmC;AAEpE,cAAM,SAAS,OAAO,UAAW,OAAO,YAAY,eAAe,QAAQ,KAAK,gBAAiB;AAEjG,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAIA,cAAM,UAAU,SAAS,WAAW,OAAO;AAC3C,cAAM,iBAAiB,UAAU,KAAK,KAAK,UAAU,GAAI,IAAI;AAE7D,YAAI;AAC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,MAAM,IAAI;AAAA,QAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAOA,SAAS,OAAO,SAAsB,SAAuC;AAC3E,gBAAM,UAAU,MAAM,QAAQ,MAAM,KAAK,IAAI;AAE7C,iBAAO,QAAQ,IAAI,CAAC,WAAgB;AAAA,YAClC,MAAM,MAAM;AAAA,YACZ,MAAO,MAAM,SAAS,MAAM,cAAe,cAAuB;AAAA,YAClE,MAAM,MAAM,QAAQ,GAAG,IAAI,IAAI,MAAM,IAAI,GAAG,QAAQ,QAAQ,GAAG;AAAA,YAC/D,aAAa,QAAQ,MAAM,SAAS,MAAM,eAAe,MAAM,SAAS,WAAW;AAAA,YACnF,MAAM,MAAM,QAAQ;AAAA,YACpB,cAAc,MAAM,UAAU,IAAI,KAAK,MAAM,OAAO,IAAI,oBAAI,KAAK;AAAA,UACnE,EAAE;AAAA,QACJ;AAAA;AAAA;AAAA;AAAA,QAKA,QAAQ,OAAO,SAAsB,SAAmC;AACtE,iBAAO,MAAM,QAAQ,MAAM,OAAO,IAAI;AAAA,QACxC;AAAA;AAAA;AAAA;AAAA,QAKA,QAAQ,OAAO,SAAsB,SAAgC;AACnE,gBAAM,QAAQ,MAAM,OAAO,IAAI;AAAA,QACjC;AAAA,MACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQA,aAAa,CAAC,YAAsC;AAClD,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":["HopxSandbox"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * HopX Provider - Factory-based Implementation\n * \n * Full-featured provider with native filesystem support using the factory pattern.\n * HopX provides isolated cloud sandboxes (lightweight VMs) with full Linux environments.\n * \n * Features:\n * - Native filesystem API via sandbox.files.*\n * - Code execution in Python, JavaScript, Bash\n * - Shell command execution\n * - Preview URLs for accessing sandbox services\n */\n\nimport { Sandbox as HopxSandbox } from '@hopx-ai/sdk';\nimport { defineProvider } from '@computesdk/provider';\nimport type {\n CommandResult,\n SandboxInfo,\n CreateSandboxOptions,\n FileEntry,\n RunCommandOptions\n} from 'computesdk';\n\n/**\n * HopX-specific configuration options\n */\nexport interface HopxConfig {\n /** HopX API key - if not provided, will fallback to HOPX_API_KEY environment variable */\n apiKey?: string;\n /** Execution timeout in milliseconds */\n timeout?: number;\n /** Template name for sandbox creation (e.g., 'code-interpreter') */\n template?: string;\n /** Base API URL for custom/staging environments */\n baseURL?: string;\n}\n\n/**\n * Create a HopX provider instance using the factory pattern\n * \n * HopX provides isolated cloud sandboxes with:\n * - Full root access to the VM\n * - Pre-installed language runtimes (Python, Node.js, etc.)\n * - Persistent filesystem during session\n * - Automatic cleanup after timeout\n */\nexport const hopx = defineProvider<HopxSandbox, HopxConfig>({\n name: 'hopx',\n methods: {\n sandbox: {\n /**\n * Create a new HopX sandbox\n * \n * Uses Sandbox.create() from @hopx-ai/sdk to provision a new sandbox.\n * Default template is 'code-interpreter' if not specified.\n */\n create: async (config: HopxConfig, options?: CreateSandboxOptions) => {\n // Validate API key - fail fast with helpful error message\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.HOPX_API_KEY) || '';\n\n if (!apiKey) {\n throw new Error(\n `Missing HopX API key. Provide 'apiKey' in config or set HOPX_API_KEY environment variable. Get your API key from https://hopx.ai/dashboard`\n );\n }\n\n // Convert timeout from milliseconds to seconds (HopX uses seconds)\n // options.timeout takes precedence over config.timeout\n const timeout = options?.timeout ?? config.timeout;\n const timeoutSeconds = timeout ? Math.ceil(timeout / 1000) : undefined;\n\n try {\n let sandbox: HopxSandbox;\n let sandboxId: string;\n\n // Destructure known ComputeSDK fields, collect the rest for passthrough\n const {\n timeout: _timeout,\n envs,\n name,\n metadata: _metadata,\n templateId,\n snapshotId,\n sandboxId: _sandboxId,\n namespace: _namespace,\n directory: _directory,\n ...providerOptions\n } = options || {};\n\n // Create new HopX sandbox using Sandbox.create()\n const createOptions: any = {\n apiKey,\n baseURL: config.baseURL,\n timeoutSeconds,\n ...providerOptions, // Spread provider-specific options\n };\n\n // Handle template specification (templateId/snapshotId takes precedence)\n if (templateId || snapshotId) {\n createOptions.templateId = templateId || snapshotId;\n } else {\n createOptions.template = config.template || 'code-interpreter';\n }\n\n // Remap envs to envVars\n if (envs) {\n createOptions.envVars = envs;\n }\n\n // Pass sandbox name\n if (name) {\n createOptions.name = name;\n }\n\n sandbox = await HopxSandbox.create(createOptions);\n sandboxId = sandbox.sandboxId;\n\n return {\n sandbox,\n sandboxId\n };\n } catch (error) {\n // Provide helpful error messages for common issues\n if (error instanceof Error) {\n if (error.message.includes('unauthorized') || error.message.includes('API key') || error.message.includes('401')) {\n throw new Error(\n `HopX authentication failed. Please check your HOPX_API_KEY environment variable. Get your API key from https://hopx.ai/dashboard`\n );\n }\n if (error.message.includes('quota') || error.message.includes('limit')) {\n throw new Error(\n `HopX quota exceeded. Please check your usage at https://hopx.ai/dashboard`\n );\n }\n }\n throw new Error(\n `Failed to create HopX sandbox: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n /**\n * Connect to an existing HopX sandbox by ID\n * \n * Uses Sandbox.connect() to reconnect to a running sandbox.\n * Returns null if sandbox doesn't exist or can't be accessed.\n */\n getById: async (config: HopxConfig, sandboxId: string) => {\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.HOPX_API_KEY) || '';\n\n if (!apiKey) {\n return null;\n }\n\n try {\n // Connect to existing sandbox using Sandbox.connect()\n const sandbox = await HopxSandbox.connect(sandboxId, apiKey, config.baseURL);\n\n return {\n sandbox,\n sandboxId\n };\n } catch (error) {\n // Sandbox doesn't exist or can't be accessed\n return null;\n }\n },\n\n /**\n * List all active HopX sandboxes\n * \n * Uses Sandbox.list() to get all sandboxes for the account.\n */\n list: async (config: HopxConfig) => {\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.HOPX_API_KEY) || '';\n\n if (!apiKey) {\n return [];\n }\n\n try {\n // List sandboxes using Sandbox.list()\n const sandboxes = await HopxSandbox.list({\n apiKey,\n baseURL: config.baseURL,\n });\n\n return sandboxes.map((sandbox: HopxSandbox) => ({\n sandbox,\n sandboxId: sandbox.sandboxId\n }));\n } catch (error) {\n // Return empty array if listing fails\n return [];\n }\n },\n\n /**\n * Destroy a HopX sandbox\n * \n * Uses sandbox.kill() to terminate and clean up the sandbox.\n */\n destroy: async (config: HopxConfig, sandboxId: string) => {\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.HOPX_API_KEY) || '';\n\n if (!apiKey) {\n return;\n }\n\n try {\n // Connect to sandbox and kill it\n const sandbox = await HopxSandbox.connect(sandboxId, apiKey, config.baseURL);\n await sandbox.kill();\n } catch (error) {\n // Sandbox might already be destroyed or doesn't exist\n // This is acceptable for destroy operations\n }\n },\n\n /**\n * Execute a shell command in the sandbox\n * \n * Uses sandbox.commands.run() to execute shell commands.\n * Arguments are properly quoted to handle special characters.\n */\n runCommand: async (sandbox: HopxSandbox, command: string, options?: RunCommandOptions): Promise<CommandResult> => {\n const startTime = Date.now();\n try {\n // Build command with options\n let fullCommand = command;\n \n // Handle environment variables\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([k, v]) => `${k}=\"${v.replace(/\"/g, '\\\\\"')}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n \n // Handle working directory\n if (options?.cwd) {\n fullCommand = `cd \"${options.cwd.replace(/\"/g, '\\\\\"')}\" && ${fullCommand}`;\n }\n \n // Handle background execution\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n \n // Execute command using sandbox.commands.run()\n const result = await sandbox.commands.run(fullCommand);\n \n return {\n stdout: result.stdout || '',\n stderr: result.stderr || '',\n exitCode: result.exit_code || 0, // Note: HopX uses snake_case\n durationMs: Date.now() - startTime\n };\n } catch (error) {\n // Extract result from error if available (some errors include partial results)\n const result = (error as any)?.result;\n if (result) {\n return {\n stdout: result.stdout || '',\n stderr: result.stderr || '',\n exitCode: result.exit_code || 1,\n durationMs: Date.now() - startTime\n };\n }\n \n // Fallback for other errors (command not found, etc.)\n return {\n stdout: '',\n stderr: error instanceof Error ? error.message : String(error),\n exitCode: 127,\n durationMs: Date.now() - startTime\n };\n }\n },\n\n /**\n * Get sandbox information\n * \n * Uses sandbox.getInfo() to retrieve sandbox metadata.\n */\n getInfo: async (sandbox: HopxSandbox): Promise<SandboxInfo> => {\n try {\n const info = await sandbox.getInfo();\n\n return {\n id: sandbox.sandboxId,\n provider: 'hopx',\n status: (info.status as 'running' | 'stopped' | 'error') || 'running',\n createdAt: info.createdAt ? new Date(info.createdAt) : new Date(),\n timeout: info.timeoutSeconds ? info.timeoutSeconds * 1000 : 300000,\n metadata: {\n templateName: info.templateName,\n templateId: info.templateId,\n region: info.region,\n publicHost: info.publicHost,\n }\n };\n } catch (error) {\n // Return basic info if getInfo fails\n return {\n id: sandbox.sandboxId,\n provider: 'hopx',\n status: 'running',\n createdAt: new Date(),\n timeout: 300000,\n metadata: {}\n };\n }\n },\n\n /**\n * Get preview URL for a specific port\n * \n * Uses sandbox.getPreviewUrl() to get the public URL for accessing\n * services running on a specific port in the sandbox.\n */\n getUrl: async (sandbox: HopxSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n try {\n // Use HopX's built-in getPreviewUrl method\n const url = await sandbox.getPreviewUrl(options.port);\n return url;\n } catch (error) {\n throw new Error(\n `Failed to get HopX URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n /**\n * Native filesystem operations using HopX's files API\n * \n * HopX has full native filesystem support via sandbox.files.*\n * This is Option A from the documentation (native API, not shell-based).\n */\n filesystem: {\n /**\n * Read file contents from sandbox\n */\n readFile: async (sandbox: HopxSandbox, path: string): Promise<string> => {\n return await sandbox.files.read(path);\n },\n\n /**\n * Write content to a file in the sandbox\n */\n writeFile: async (sandbox: HopxSandbox, path: string, content: string): Promise<void> => {\n await sandbox.files.write(path, content);\n },\n\n /**\n * Create a directory in the sandbox\n */\n mkdir: async (sandbox: HopxSandbox, path: string): Promise<void> => {\n await sandbox.files.mkdir(path);\n },\n\n /**\n * List directory contents\n * \n * Maps HopX's EnhancedFileInfo to ComputeSDK's FileEntry format.\n */\n readdir: async (sandbox: HopxSandbox, path: string): Promise<FileEntry[]> => {\n const entries = await sandbox.files.list(path);\n\n return entries.map((entry: any) => ({\n name: entry.name,\n type: (entry.isDir || entry.isDirectory) ? 'directory' as const : 'file' as const,\n path: entry.path || `${path}/${entry.name}`.replace(/\\/+/g, '/'),\n isDirectory: Boolean(entry.isDir || entry.isDirectory || entry.type === 'directory'),\n size: entry.size || 0,\n lastModified: entry.modTime ? new Date(entry.modTime) : new Date()\n }));\n },\n\n /**\n * Check if a file or directory exists\n */\n exists: async (sandbox: HopxSandbox, path: string): Promise<boolean> => {\n return await sandbox.files.exists(path);\n },\n\n /**\n * Remove a file or directory\n */\n remove: async (sandbox: HopxSandbox, path: string): Promise<void> => {\n await sandbox.files.remove(path);\n }\n },\n\n /**\n * Get the native HopX Sandbox instance for advanced usage\n * \n * This allows users to access HopX-specific features not exposed\n * through the ComputeSDK interface.\n */\n getInstance: (sandbox: HopxSandbox): HopxSandbox => {\n return sandbox;\n },\n }\n }\n});\n\n// Export HopX sandbox type for explicit typing\nexport type { Sandbox as HopxSandbox } from '@hopx-ai/sdk';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,iBAAuC;AACvC,sBAA+B;AAgCxB,IAAM,WAAO,gCAAwC;AAAA,EAC1D,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOP,QAAQ,OAAO,QAAoB,YAAmC;AAEpE,cAAM,SAAS,OAAO,UAAW,OAAO,YAAY,eAAe,QAAQ,KAAK,gBAAiB;AAEjG,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;A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AM,QAAQ,MAAM,MAAM,IAAI;AAAA,QAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAOA,SAAS,OAAO,SAAsB,SAAuC;AAC3E,gBAAM,UAAU,MAAM,QAAQ,MAAM,KAAK,IAAI;AAE7C,iBAAO,QAAQ,IAAI,CAAC,WAAgB;AAAA,YAClC,MAAM,MAAM;AAAA,YACZ,MAAO,MAAM,SAAS,MAAM,cAAe,cAAuB;AAAA,YAClE,MAAM,MAAM,QAAQ,GAAG,IAAI,IAAI,MAAM,IAAI,GAAG,QAAQ,QAAQ,GAAG;AAAA,YAC/D,aAAa,QAAQ,MAAM,SAAS,MAAM,eAAe,MAAM,SAAS,WAAW;AAAA,YACnF,MAAM,MAAM,QAAQ;AAAA,YACpB,cAAc,MAAM,UAAU,IAAI,KAAK,MAAM,OAAO,IAAI,oBAAI,KAAK;AAAA,UACnE,EAAE;AAAA,QACJ;AAAA;AAAA;AAAA;AAAA,QAKA,QAAQ,OAAO,SAAsB,SAAmC;AACtE,iBAAO,MAAM,QAAQ,MAAM,OAAO,IAAI;AAAA,QACxC;AAAA;AAAA;AAAA;AAAA,QAKA,QAAQ,OAAO,SAAsB,SAAgC;AACnE,gBAAM,QAAQ,MAAM,OAAO,IAAI;AAAA,QACjC;AAAA,MACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQA,aAAa,CAAC,YAAsC;AAClD,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":["HopxSandbox"]}
package/dist/index.mjs CHANGED
@@ -24,7 +24,6 @@ var hopx = defineProvider({
24
24
  let sandbox;
25
25
  let sandboxId;
26
26
  const {
27
- runtime: _runtime,
28
27
  timeout: _timeout,
29
28
  envs,
30
29
  name,
@@ -138,12 +137,6 @@ var hopx = defineProvider({
138
137
  } catch (error) {
139
138
  }
140
139
  },
141
- /**
142
- * Execute code in the sandbox
143
- *
144
- * Uses sandbox.runCode() with auto-detected runtime.
145
- * Maps ComputeSDK runtime ('node'/'python') to HopX language ('javascript'/'python').
146
- */
147
140
  /**
148
141
  * Execute a shell command in the sandbox
149
142
  *
@@ -201,8 +194,6 @@ var hopx = defineProvider({
201
194
  return {
202
195
  id: sandbox.sandboxId,
203
196
  provider: "hopx",
204
- runtime: "python",
205
- // HopX default runtime
206
197
  status: info.status || "running",
207
198
  createdAt: info.createdAt ? new Date(info.createdAt) : /* @__PURE__ */ new Date(),
208
199
  timeout: info.timeoutSeconds ? info.timeoutSeconds * 1e3 : 3e5,
@@ -217,7 +208,6 @@ var hopx = defineProvider({
217
208
  return {
218
209
  id: sandbox.sandboxId,
219
210
  provider: "hopx",
220
- runtime: "python",
221
211
  status: "running",
222
212
  createdAt: /* @__PURE__ */ new Date(),
223
213
  timeout: 3e5,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * HopX Provider - Factory-based Implementation\n * \n * Full-featured provider with native filesystem support using the factory pattern.\n * HopX provides isolated cloud sandboxes (lightweight VMs) with full Linux environments.\n * \n * Features:\n * - Native filesystem API via sandbox.files.*\n * - Code execution in Python, JavaScript, Bash\n * - Shell command execution\n * - Preview URLs for accessing sandbox services\n */\n\nimport { Sandbox as HopxSandbox } from '@hopx-ai/sdk';\nimport { defineProvider } from '@computesdk/provider';\nimport type {\n CodeResult,\n CommandResult,\n SandboxInfo,\n Runtime,\n CreateSandboxOptions,\n FileEntry,\n RunCommandOptions\n} from 'computesdk';\n\n/**\n * HopX-specific configuration options\n */\nexport interface HopxConfig {\n /** HopX API key - if not provided, will fallback to HOPX_API_KEY environment variable */\n apiKey?: string;\n /** Default runtime environment */\n runtime?: Runtime;\n /** Execution timeout in milliseconds */\n timeout?: number;\n /** Template name for sandbox creation (e.g., 'code-interpreter') */\n template?: string;\n /** Base API URL for custom/staging environments */\n baseURL?: string;\n}\n\n/**\n * Create a HopX provider instance using the factory pattern\n * \n * HopX provides isolated cloud sandboxes with:\n * - Full root access to the VM\n * - Pre-installed language runtimes (Python, Node.js, etc.)\n * - Persistent filesystem during session\n * - Automatic cleanup after timeout\n */\nexport const hopx = defineProvider<HopxSandbox, HopxConfig>({\n name: 'hopx',\n methods: {\n sandbox: {\n /**\n * Create a new HopX sandbox\n * \n * Uses Sandbox.create() from @hopx-ai/sdk to provision a new sandbox.\n * Default template is 'code-interpreter' if not specified.\n */\n create: async (config: HopxConfig, options?: CreateSandboxOptions) => {\n // Validate API key - fail fast with helpful error message\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.HOPX_API_KEY) || '';\n\n if (!apiKey) {\n throw new Error(\n `Missing HopX API key. Provide 'apiKey' in config or set HOPX_API_KEY environment variable. Get your API key from https://hopx.ai/dashboard`\n );\n }\n\n // Convert timeout from milliseconds to seconds (HopX uses seconds)\n // options.timeout takes precedence over config.timeout\n const timeout = options?.timeout ?? config.timeout;\n const timeoutSeconds = timeout ? Math.ceil(timeout / 1000) : undefined;\n\n try {\n let sandbox: HopxSandbox;\n let sandboxId: string;\n\n // Destructure known ComputeSDK fields, collect the rest for passthrough\n const {\n runtime: _runtime,\n timeout: _timeout,\n envs,\n name,\n metadata: _metadata,\n templateId,\n snapshotId,\n sandboxId: _sandboxId,\n namespace: _namespace,\n directory: _directory,\n ...providerOptions\n } = options || {};\n\n // Create new HopX sandbox using Sandbox.create()\n const createOptions: any = {\n apiKey,\n baseURL: config.baseURL,\n timeoutSeconds,\n ...providerOptions, // Spread provider-specific options\n };\n\n // Handle template specification (templateId/snapshotId takes precedence)\n if (templateId || snapshotId) {\n createOptions.templateId = templateId || snapshotId;\n } else {\n createOptions.template = config.template || 'code-interpreter';\n }\n\n // Remap envs to envVars\n if (envs) {\n createOptions.envVars = envs;\n }\n\n // Pass sandbox name\n if (name) {\n createOptions.name = name;\n }\n\n sandbox = await HopxSandbox.create(createOptions);\n sandboxId = sandbox.sandboxId;\n\n return {\n sandbox,\n sandboxId\n };\n } catch (error) {\n // Provide helpful error messages for common issues\n if (error instanceof Error) {\n if (error.message.includes('unauthorized') || error.message.includes('API key') || error.message.includes('401')) {\n throw new Error(\n `HopX authentication failed. Please check your HOPX_API_KEY environment variable. Get your API key from https://hopx.ai/dashboard`\n );\n }\n if (error.message.includes('quota') || error.message.includes('limit')) {\n throw new Error(\n `HopX quota exceeded. Please check your usage at https://hopx.ai/dashboard`\n );\n }\n }\n throw new Error(\n `Failed to create HopX sandbox: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n /**\n * Connect to an existing HopX sandbox by ID\n * \n * Uses Sandbox.connect() to reconnect to a running sandbox.\n * Returns null if sandbox doesn't exist or can't be accessed.\n */\n getById: async (config: HopxConfig, sandboxId: string) => {\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.HOPX_API_KEY) || '';\n\n if (!apiKey) {\n return null;\n }\n\n try {\n // Connect to existing sandbox using Sandbox.connect()\n const sandbox = await HopxSandbox.connect(sandboxId, apiKey, config.baseURL);\n\n return {\n sandbox,\n sandboxId\n };\n } catch (error) {\n // Sandbox doesn't exist or can't be accessed\n return null;\n }\n },\n\n /**\n * List all active HopX sandboxes\n * \n * Uses Sandbox.list() to get all sandboxes for the account.\n */\n list: async (config: HopxConfig) => {\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.HOPX_API_KEY) || '';\n\n if (!apiKey) {\n return [];\n }\n\n try {\n // List sandboxes using Sandbox.list()\n const sandboxes = await HopxSandbox.list({\n apiKey,\n baseURL: config.baseURL,\n });\n\n return sandboxes.map((sandbox: HopxSandbox) => ({\n sandbox,\n sandboxId: sandbox.sandboxId\n }));\n } catch (error) {\n // Return empty array if listing fails\n return [];\n }\n },\n\n /**\n * Destroy a HopX sandbox\n * \n * Uses sandbox.kill() to terminate and clean up the sandbox.\n */\n destroy: async (config: HopxConfig, sandboxId: string) => {\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.HOPX_API_KEY) || '';\n\n if (!apiKey) {\n return;\n }\n\n try {\n // Connect to sandbox and kill it\n const sandbox = await HopxSandbox.connect(sandboxId, apiKey, config.baseURL);\n await sandbox.kill();\n } catch (error) {\n // Sandbox might already be destroyed or doesn't exist\n // This is acceptable for destroy operations\n }\n },\n\n /**\n * Execute code in the sandbox\n * \n * Uses sandbox.runCode() with auto-detected runtime.\n * Maps ComputeSDK runtime ('node'/'python') to HopX language ('javascript'/'python').\n */\n\n /**\n * Execute a shell command in the sandbox\n * \n * Uses sandbox.commands.run() to execute shell commands.\n * Arguments are properly quoted to handle special characters.\n */\n runCommand: async (sandbox: HopxSandbox, command: string, options?: RunCommandOptions): Promise<CommandResult> => {\n const startTime = Date.now();\n try {\n // Build command with options\n let fullCommand = command;\n \n // Handle environment variables\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([k, v]) => `${k}=\"${v.replace(/\"/g, '\\\\\"')}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n \n // Handle working directory\n if (options?.cwd) {\n fullCommand = `cd \"${options.cwd.replace(/\"/g, '\\\\\"')}\" && ${fullCommand}`;\n }\n \n // Handle background execution\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n \n // Execute command using sandbox.commands.run()\n const result = await sandbox.commands.run(fullCommand);\n \n return {\n stdout: result.stdout || '',\n stderr: result.stderr || '',\n exitCode: result.exit_code || 0, // Note: HopX uses snake_case\n durationMs: Date.now() - startTime\n };\n } catch (error) {\n // Extract result from error if available (some errors include partial results)\n const result = (error as any)?.result;\n if (result) {\n return {\n stdout: result.stdout || '',\n stderr: result.stderr || '',\n exitCode: result.exit_code || 1,\n durationMs: Date.now() - startTime\n };\n }\n \n // Fallback for other errors (command not found, etc.)\n return {\n stdout: '',\n stderr: error instanceof Error ? error.message : String(error),\n exitCode: 127,\n durationMs: Date.now() - startTime\n };\n }\n },\n\n /**\n * Get sandbox information\n * \n * Uses sandbox.getInfo() to retrieve sandbox metadata.\n */\n getInfo: async (sandbox: HopxSandbox): Promise<SandboxInfo> => {\n try {\n const info = await sandbox.getInfo();\n\n return {\n id: sandbox.sandboxId,\n provider: 'hopx',\n runtime: 'python', // HopX default runtime\n status: (info.status as 'running' | 'stopped' | 'error') || 'running',\n createdAt: info.createdAt ? new Date(info.createdAt) : new Date(),\n timeout: info.timeoutSeconds ? info.timeoutSeconds * 1000 : 300000,\n metadata: {\n templateName: info.templateName,\n templateId: info.templateId,\n region: info.region,\n publicHost: info.publicHost,\n }\n };\n } catch (error) {\n // Return basic info if getInfo fails\n return {\n id: sandbox.sandboxId,\n provider: 'hopx',\n runtime: 'python',\n status: 'running',\n createdAt: new Date(),\n timeout: 300000,\n metadata: {}\n };\n }\n },\n\n /**\n * Get preview URL for a specific port\n * \n * Uses sandbox.getPreviewUrl() to get the public URL for accessing\n * services running on a specific port in the sandbox.\n */\n getUrl: async (sandbox: HopxSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n try {\n // Use HopX's built-in getPreviewUrl method\n const url = await sandbox.getPreviewUrl(options.port);\n return url;\n } catch (error) {\n throw new Error(\n `Failed to get HopX URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n /**\n * Native filesystem operations using HopX's files API\n * \n * HopX has full native filesystem support via sandbox.files.*\n * This is Option A from the documentation (native API, not shell-based).\n */\n filesystem: {\n /**\n * Read file contents from sandbox\n */\n readFile: async (sandbox: HopxSandbox, path: string): Promise<string> => {\n return await sandbox.files.read(path);\n },\n\n /**\n * Write content to a file in the sandbox\n */\n writeFile: async (sandbox: HopxSandbox, path: string, content: string): Promise<void> => {\n await sandbox.files.write(path, content);\n },\n\n /**\n * Create a directory in the sandbox\n */\n mkdir: async (sandbox: HopxSandbox, path: string): Promise<void> => {\n await sandbox.files.mkdir(path);\n },\n\n /**\n * List directory contents\n * \n * Maps HopX's EnhancedFileInfo to ComputeSDK's FileEntry format.\n */\n readdir: async (sandbox: HopxSandbox, path: string): Promise<FileEntry[]> => {\n const entries = await sandbox.files.list(path);\n\n return entries.map((entry: any) => ({\n name: entry.name,\n type: (entry.isDir || entry.isDirectory) ? 'directory' as const : 'file' as const,\n path: entry.path || `${path}/${entry.name}`.replace(/\\/+/g, '/'),\n isDirectory: Boolean(entry.isDir || entry.isDirectory || entry.type === 'directory'),\n size: entry.size || 0,\n lastModified: entry.modTime ? new Date(entry.modTime) : new Date()\n }));\n },\n\n /**\n * Check if a file or directory exists\n */\n exists: async (sandbox: HopxSandbox, path: string): Promise<boolean> => {\n return await sandbox.files.exists(path);\n },\n\n /**\n * Remove a file or directory\n */\n remove: async (sandbox: HopxSandbox, path: string): Promise<void> => {\n await sandbox.files.remove(path);\n }\n },\n\n /**\n * Get the native HopX Sandbox instance for advanced usage\n * \n * This allows users to access HopX-specific features not exposed\n * through the ComputeSDK interface.\n */\n getInstance: (sandbox: HopxSandbox): HopxSandbox => {\n return sandbox;\n },\n }\n }\n});\n\n// Export HopX sandbox type for explicit typing\nexport type { Sandbox as HopxSandbox } from '@hopx-ai/sdk';\n"],"mappings":";AAaA,SAAS,WAAW,mBAAmB;AACvC,SAAS,sBAAsB;AAoCxB,IAAM,OAAO,eAAwC;AAAA,EAC1D,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOP,QAAQ,OAAO,QAAoB,YAAmC;AAEpE,cAAM,SAAS,OAAO,UAAW,OAAO,YAAY,eAAe,QAAQ,KAAK,gBAAiB;AAEjG,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAIA,cAAM,UAAU,SAAS,WAAW,OAAO;AAC3C,cAAM,iBAAiB,UAAU,KAAK,KAAK,UAAU,GAAI,IAAI;AAE7D,YAAI;AACF,cAAI;AACJ,cAAI;AAGJ,gBAAM;AAAA,YACJ,SAAS;AAAA,YACT,SAAS;AAAA,YACT;AAAA,YACA;AAAA,YACA,UAAU;AAAA,YACV;AAAA,YACA;AAAA,YACA,WAAW;AAAA,YACX,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AAAA,YAClC,MAAM,MAAM;AAAA,YACZ,MAAO,MAAM,SAAS,MAAM,cAAe,cAAuB;AAAA,YAClE,MAAM,MAAM,QAAQ,GAAG,IAAI,IAAI,MAAM,IAAI,GAAG,QAAQ,QAAQ,GAAG;AAAA,YAC/D,aAAa,QAAQ,MAAM,SAAS,MAAM,eAAe,MAAM,SAAS,WAAW;AAAA,YACnF,MAAM,MAAM,QAAQ;AAAA,YACpB,cAAc,MAAM,UAAU,IAAI,KAAK,MAAM,OAAO,IAAI,oBAAI,KAAK;AAAA,UACnE,EAAE;AAAA,QACJ;AAAA;AAAA;AAAA;AAAA,QAKA,QAAQ,OAAO,SAAsB,SAAmC;AACtE,iBAAO,MAAM,QAAQ,MAAM,OAAO,IAAI;AAAA,QACxC;AAAA;AAAA;AAAA;AAAA,QAKA,QAAQ,OAAO,SAAsB,SAAgC;AACnE,gBAAM,QAAQ,MAAM,OAAO,IAAI;AAAA,QACjC;AAAA,MACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQA,aAAa,CAAC,YAAsC;AAClD,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * HopX Provider - Factory-based Implementation\n * \n * Full-featured provider with native filesystem support using the factory pattern.\n * HopX provides isolated cloud sandboxes (lightweight VMs) with full Linux environments.\n * \n * Features:\n * - Native filesystem API via sandbox.files.*\n * - Code execution in Python, JavaScript, Bash\n * - Shell command execution\n * - Preview URLs for accessing sandbox services\n */\n\nimport { Sandbox as HopxSandbox } from '@hopx-ai/sdk';\nimport { defineProvider } from '@computesdk/provider';\nimport type {\n CommandResult,\n SandboxInfo,\n CreateSandboxOptions,\n FileEntry,\n RunCommandOptions\n} from 'computesdk';\n\n/**\n * HopX-specific configuration options\n */\nexport interface HopxConfig {\n /** HopX API key - if not provided, will fallback to HOPX_API_KEY environment variable */\n apiKey?: string;\n /** Execution timeout in milliseconds */\n timeout?: number;\n /** Template name for sandbox creation (e.g., 'code-interpreter') */\n template?: string;\n /** Base API URL for custom/staging environments */\n baseURL?: string;\n}\n\n/**\n * Create a HopX provider instance using the factory pattern\n * \n * HopX provides isolated cloud sandboxes with:\n * - Full root access to the VM\n * - Pre-installed language runtimes (Python, Node.js, etc.)\n * - Persistent filesystem during session\n * - Automatic cleanup after timeout\n */\nexport const hopx = defineProvider<HopxSandbox, HopxConfig>({\n name: 'hopx',\n methods: {\n sandbox: {\n /**\n * Create a new HopX sandbox\n * \n * Uses Sandbox.create() from @hopx-ai/sdk to provision a new sandbox.\n * Default template is 'code-interpreter' if not specified.\n */\n create: async (config: HopxConfig, options?: CreateSandboxOptions) => {\n // Validate API key - fail fast with helpful error message\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.HOPX_API_KEY) || '';\n\n if (!apiKey) {\n throw new Error(\n `Missing HopX API key. Provide 'apiKey' in config or set HOPX_API_KEY environment variable. Get your API key from https://hopx.ai/dashboard`\n );\n }\n\n // Convert timeout from milliseconds to seconds (HopX uses seconds)\n // options.timeout takes precedence over config.timeout\n const timeout = options?.timeout ?? config.timeout;\n const timeoutSeconds = timeout ? Math.ceil(timeout / 1000) : undefined;\n\n try {\n let sandbox: HopxSandbox;\n let sandboxId: string;\n\n // Destructure known ComputeSDK fields, collect the rest for passthrough\n const {\n timeout: _timeout,\n envs,\n name,\n metadata: _metadata,\n templateId,\n snapshotId,\n sandboxId: _sandboxId,\n namespace: _namespace,\n directory: _directory,\n ...providerOptions\n } = options || {};\n\n // Create new HopX sandbox using Sandbox.create()\n const createOptions: any = {\n apiKey,\n baseURL: config.baseURL,\n timeoutSeconds,\n ...providerOptions, // Spread provider-specific options\n };\n\n // Handle template specification (templateId/snapshotId takes precedence)\n if (templateId || snapshotId) {\n createOptions.templateId = templateId || snapshotId;\n } else {\n createOptions.template = config.template || 'code-interpreter';\n }\n\n // Remap envs to envVars\n if (envs) {\n createOptions.envVars = envs;\n }\n\n // Pass sandbox name\n if (name) {\n createOptions.name = name;\n }\n\n sandbox = await HopxSandbox.create(createOptions);\n sandboxId = sandbox.sandboxId;\n\n return {\n sandbox,\n sandboxId\n };\n } catch (error) {\n // Provide helpful error messages for common issues\n if (error instanceof Error) {\n if (error.message.includes('unauthorized') || error.message.includes('API key') || error.message.includes('401')) {\n throw new Error(\n `HopX authentication failed. Please check your HOPX_API_KEY environment variable. Get your API key from https://hopx.ai/dashboard`\n );\n }\n if (error.message.includes('quota') || error.message.includes('limit')) {\n throw new Error(\n `HopX quota exceeded. Please check your usage at https://hopx.ai/dashboard`\n );\n }\n }\n throw new Error(\n `Failed to create HopX sandbox: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n /**\n * Connect to an existing HopX sandbox by ID\n * \n * Uses Sandbox.connect() to reconnect to a running sandbox.\n * Returns null if sandbox doesn't exist or can't be accessed.\n */\n getById: async (config: HopxConfig, sandboxId: string) => {\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.HOPX_API_KEY) || '';\n\n if (!apiKey) {\n return null;\n }\n\n try {\n // Connect to existing sandbox using Sandbox.connect()\n const sandbox = await HopxSandbox.connect(sandboxId, apiKey, config.baseURL);\n\n return {\n sandbox,\n sandboxId\n };\n } catch (error) {\n // Sandbox doesn't exist or can't be accessed\n return null;\n }\n },\n\n /**\n * List all active HopX sandboxes\n * \n * Uses Sandbox.list() to get all sandboxes for the account.\n */\n list: async (config: HopxConfig) => {\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.HOPX_API_KEY) || '';\n\n if (!apiKey) {\n return [];\n }\n\n try {\n // List sandboxes using Sandbox.list()\n const sandboxes = await HopxSandbox.list({\n apiKey,\n baseURL: config.baseURL,\n });\n\n return sandboxes.map((sandbox: HopxSandbox) => ({\n sandbox,\n sandboxId: sandbox.sandboxId\n }));\n } catch (error) {\n // Return empty array if listing fails\n return [];\n }\n },\n\n /**\n * Destroy a HopX sandbox\n * \n * Uses sandbox.kill() to terminate and clean up the sandbox.\n */\n destroy: async (config: HopxConfig, sandboxId: string) => {\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.HOPX_API_KEY) || '';\n\n if (!apiKey) {\n return;\n }\n\n try {\n // Connect to sandbox and kill it\n const sandbox = await HopxSandbox.connect(sandboxId, apiKey, config.baseURL);\n await sandbox.kill();\n } catch (error) {\n // Sandbox might already be destroyed or doesn't exist\n // This is acceptable for destroy operations\n }\n },\n\n /**\n * Execute a shell command in the sandbox\n * \n * Uses sandbox.commands.run() to execute shell commands.\n * Arguments are properly quoted to handle special characters.\n */\n runCommand: async (sandbox: HopxSandbox, command: string, options?: RunCommandOptions): Promise<CommandResult> => {\n const startTime = Date.now();\n try {\n // Build command with options\n let fullCommand = command;\n \n // Handle environment variables\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([k, v]) => `${k}=\"${v.replace(/\"/g, '\\\\\"')}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n \n // Handle working directory\n if (options?.cwd) {\n fullCommand = `cd \"${options.cwd.replace(/\"/g, '\\\\\"')}\" && ${fullCommand}`;\n }\n \n // Handle background execution\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n \n // Execute command using sandbox.commands.run()\n const result = await sandbox.commands.run(fullCommand);\n \n return {\n stdout: result.stdout || '',\n stderr: result.stderr || '',\n exitCode: result.exit_code || 0, // Note: HopX uses snake_case\n durationMs: Date.now() - startTime\n };\n } catch (error) {\n // Extract result from error if available (some errors include partial results)\n const result = (error as any)?.result;\n if (result) {\n return {\n stdout: result.stdout || '',\n stderr: result.stderr || '',\n exitCode: result.exit_code || 1,\n durationMs: Date.now() - startTime\n };\n }\n \n // Fallback for other errors (command not found, etc.)\n return {\n stdout: '',\n stderr: error instanceof Error ? error.message : String(error),\n exitCode: 127,\n durationMs: Date.now() - startTime\n };\n }\n },\n\n /**\n * Get sandbox information\n * \n * Uses sandbox.getInfo() to retrieve sandbox metadata.\n */\n getInfo: async (sandbox: HopxSandbox): Promise<SandboxInfo> => {\n try {\n const info = await sandbox.getInfo();\n\n return {\n id: sandbox.sandboxId,\n provider: 'hopx',\n status: (info.status as 'running' | 'stopped' | 'error') || 'running',\n createdAt: info.createdAt ? new Date(info.createdAt) : new Date(),\n timeout: info.timeoutSeconds ? info.timeoutSeconds * 1000 : 300000,\n metadata: {\n templateName: info.templateName,\n templateId: info.templateId,\n region: info.region,\n publicHost: info.publicHost,\n }\n };\n } catch (error) {\n // Return basic info if getInfo fails\n return {\n id: sandbox.sandboxId,\n provider: 'hopx',\n status: 'running',\n createdAt: new Date(),\n timeout: 300000,\n metadata: {}\n };\n }\n },\n\n /**\n * Get preview URL for a specific port\n * \n * Uses sandbox.getPreviewUrl() to get the public URL for accessing\n * services running on a specific port in the sandbox.\n */\n getUrl: async (sandbox: HopxSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n try {\n // Use HopX's built-in getPreviewUrl method\n const url = await sandbox.getPreviewUrl(options.port);\n return url;\n } catch (error) {\n throw new Error(\n `Failed to get HopX URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n /**\n * Native filesystem operations using HopX's files API\n * \n * HopX has full native filesystem support via sandbox.files.*\n * This is Option A from the documentation (native API, not shell-based).\n */\n filesystem: {\n /**\n * Read file contents from sandbox\n */\n readFile: async (sandbox: HopxSandbox, path: string): Promise<string> => {\n return await sandbox.files.read(path);\n },\n\n /**\n * Write content to a file in the sandbox\n */\n writeFile: async (sandbox: HopxSandbox, path: string, content: string): Promise<void> => {\n await sandbox.files.write(path, content);\n },\n\n /**\n * Create a directory in the sandbox\n */\n mkdir: async (sandbox: HopxSandbox, path: string): Promise<void> => {\n await sandbox.files.mkdir(path);\n },\n\n /**\n * List directory contents\n * \n * Maps HopX's EnhancedFileInfo to ComputeSDK's FileEntry format.\n */\n readdir: async (sandbox: HopxSandbox, path: string): Promise<FileEntry[]> => {\n const entries = await sandbox.files.list(path);\n\n return entries.map((entry: any) => ({\n name: entry.name,\n type: (entry.isDir || entry.isDirectory) ? 'directory' as const : 'file' as const,\n path: entry.path || `${path}/${entry.name}`.replace(/\\/+/g, '/'),\n isDirectory: Boolean(entry.isDir || entry.isDirectory || entry.type === 'directory'),\n size: entry.size || 0,\n lastModified: entry.modTime ? new Date(entry.modTime) : new Date()\n }));\n },\n\n /**\n * Check if a file or directory exists\n */\n exists: async (sandbox: HopxSandbox, path: string): Promise<boolean> => {\n return await sandbox.files.exists(path);\n },\n\n /**\n * Remove a file or directory\n */\n remove: async (sandbox: HopxSandbox, path: string): Promise<void> => {\n await sandbox.files.remove(path);\n }\n },\n\n /**\n * Get the native HopX Sandbox instance for advanced usage\n * \n * This allows users to access HopX-specific features not exposed\n * through the ComputeSDK interface.\n */\n getInstance: (sandbox: HopxSandbox): HopxSandbox => {\n return sandbox;\n },\n }\n }\n});\n\n// Export HopX sandbox type for explicit typing\nexport type { Sandbox as HopxSandbox } from '@hopx-ai/sdk';\n"],"mappings":";AAaA,SAAS,WAAW,mBAAmB;AACvC,SAAS,sBAAsB;AAgCxB,IAAM,OAAO,eAAwC;AAAA,EAC1D,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOP,QAAQ,OAAO,QAAoB,YAAmC;AAEpE,cAAM,SAAS,OAAO,UAAW,OAAO,YAAY,eAAe,QAAQ,KAAK,gBAAiB;AAEjG,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAIA,cAAM,UAAU,SAAS,WAAW,OAAO;AAC3C,cAAM,iBAAiB,UAAU,KAAK,KAAK,UAAU,GAAI,IAAI;AAE7D,YAAI;AACF,cAAI;AACJ,cAAI;AAGJ,gBAAM;AAAA,YACJ,SAAS;AAAA,YACT;AAAA,YACA;AAAA,YACA,UAAU;AAAA,YACV;AAAA,YACA;AAAA,YACA,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,cAAe,cAAuB;AAAA,YAClE,MAAM,MAAM,QAAQ,GAAG,IAAI,IAAI,MAAM,IAAI,GAAG,QAAQ,QAAQ,GAAG;AAAA,YAC/D,aAAa,QAAQ,MAAM,SAAS,MAAM,eAAe,MAAM,SAAS,WAAW;AAAA,YACnF,MAAM,MAAM,QAAQ;AAAA,YACpB,cAAc,MAAM,UAAU,IAAI,KAAK,MAAM,OAAO,IAAI,oBAAI,KAAK;AAAA,UACnE,EAAE;AAAA,QACJ;AAAA;AAAA;AAAA;AAAA,QAKA,QAAQ,OAAO,SAAsB,SAAmC;AACtE,iBAAO,MAAM,QAAQ,MAAM,OAAO,IAAI;AAAA,QACxC;AAAA;AAAA;AAAA;AAAA,QAKA,QAAQ,OAAO,SAAsB,SAAgC;AACnE,gBAAM,QAAQ,MAAM,OAAO,IAAI;AAAA,QACjC;AAAA,MACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAQA,aAAa,CAAC,YAAsC;AAClD,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@computesdk/hopx",
3
- "version": "0.2.21",
3
+ "version": "0.2.22",
4
4
  "description": "HopX provider for ComputeSDK - cloud sandboxes with full Linux environments, filesystem access, and microVM isolation",
5
5
  "author": "ComputeSDK",
6
6
  "license": "MIT",
@@ -19,8 +19,8 @@
19
19
  ],
20
20
  "dependencies": {
21
21
  "@hopx-ai/sdk": "^0.5.1",
22
- "computesdk": "3.0.0",
23
- "@computesdk/provider": "1.4.0"
22
+ "@computesdk/provider": "2.0.0",
23
+ "computesdk": "4.0.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/node": "^20.0.0",
@@ -30,7 +30,7 @@
30
30
  "tsup": "^8.0.0",
31
31
  "typescript": "^5.0.0",
32
32
  "vitest": "^1.0.0",
33
- "@computesdk/test-utils": "1.6.1"
33
+ "@computesdk/test-utils": "2.0.0"
34
34
  },
35
35
  "keywords": [
36
36
  "computesdk",