@computesdk/hopx 0.2.34 → 0.2.36
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 +5 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ var import_provider = require("@computesdk/provider");
|
|
|
28
28
|
var hopx = (0, import_provider.defineProvider)({
|
|
29
29
|
name: "hopx",
|
|
30
30
|
methods: {
|
|
31
|
-
|
|
31
|
+
instances: {
|
|
32
32
|
/**
|
|
33
33
|
* Create a new HopX sandbox
|
|
34
34
|
*
|
|
@@ -79,10 +79,7 @@ var hopx = (0, import_provider.defineProvider)({
|
|
|
79
79
|
}
|
|
80
80
|
sandbox = await import_sdk.Sandbox.create(createOptions);
|
|
81
81
|
sandboxId = sandbox.sandboxId;
|
|
82
|
-
return {
|
|
83
|
-
sandbox,
|
|
84
|
-
sandboxId
|
|
85
|
-
};
|
|
82
|
+
return { instance: sandbox, instanceId: sandboxId };
|
|
86
83
|
} catch (error) {
|
|
87
84
|
if (error instanceof Error) {
|
|
88
85
|
if (error.message.includes("unauthorized") || error.message.includes("API key") || error.message.includes("401")) {
|
|
@@ -114,10 +111,7 @@ var hopx = (0, import_provider.defineProvider)({
|
|
|
114
111
|
}
|
|
115
112
|
try {
|
|
116
113
|
const sandbox = await import_sdk.Sandbox.connect(sandboxId, apiKey, config.baseURL);
|
|
117
|
-
return {
|
|
118
|
-
sandbox,
|
|
119
|
-
sandboxId
|
|
120
|
-
};
|
|
114
|
+
return { instance: sandbox, instanceId: sandboxId };
|
|
121
115
|
} catch (error) {
|
|
122
116
|
return null;
|
|
123
117
|
}
|
|
@@ -138,8 +132,8 @@ var hopx = (0, import_provider.defineProvider)({
|
|
|
138
132
|
baseURL: config.baseURL
|
|
139
133
|
});
|
|
140
134
|
return sandboxes.map((sandbox) => ({
|
|
141
|
-
sandbox,
|
|
142
|
-
|
|
135
|
+
instance: sandbox,
|
|
136
|
+
instanceId: sandbox.sandboxId
|
|
143
137
|
}));
|
|
144
138
|
} catch (error) {
|
|
145
139
|
return [];
|
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 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 timeout: options?.timeout ? Math.ceil(options.timeout / 1000) : undefined,\n });\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;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,WAAW;AAAA,YACX,WAAW;AAAA,YACX,WAAW;AAAA,YACX,GAAG;AAAA,UACL,IAAI,WAAW,CAAC;AAGd,gBAAM,gBAAqB;AAAA,YACzB;AAAA,YACA,SAAS,OAAO;AAAA,YAChB;AAAA,YACA,GAAG;AAAA;AAAA,UACL;AAGA,cAAI,cAAc,YAAY;AAC5B,0BAAc,aAAa,cAAc;AAAA,UAC3C,OAAO;AACL,0BAAc,WAAW,OAAO,YAAY;AAAA,UAC9C;AAGA,cAAI,MAAM;AACR,0BAAc,UAAU;AAAA,UAC1B;AAGA,cAAI,MAAM;AACR,0BAAc,OAAO;AAAA,UACvB;AAEF,oBAAU,MAAM,WAAAA,QAAY,OAAO,aAAa;AAChD,sBAAY,QAAQ;A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AsB,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 InstanceInfo,\n CreateInstanceOptions,\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 instances: {\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?: CreateInstanceOptions) => {\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 { instance: sandbox, instanceId: sandboxId };\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 { instance: sandbox, instanceId: sandboxId };\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) => ({ instance: sandbox, instanceId: 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 timeout: options?.timeout ? Math.ceil(options.timeout / 1000) : undefined,\n });\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<InstanceInfo> => {\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,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOT,QAAQ,OAAO,QAAoB,YAAoC;AAErE,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,WAAW;AAAA,YACX,WAAW;AAAA,YACX,WAAW;AAAA,YACX,GAAG;AAAA,UACL,IAAI,WAAW,CAAC;AAGd,gBAAM,gBAAqB;AAAA,YACzB;AAAA,YACA,SAAS,OAAO;AAAA,YAChB;AAAA,YACA,GAAG;AAAA;AAAA,UACL;AAGA,cAAI,cAAc,YAAY;AAC5B,0BAAc,aAAa,cAAc;AAAA,UAC3C,OAAO;AACL,0BAAc,WAAW,OAAO,YAAY;AAAA,UAC9C;AAGA,cA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M,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
|
@@ -4,7 +4,7 @@ import { defineProvider } from "@computesdk/provider";
|
|
|
4
4
|
var hopx = defineProvider({
|
|
5
5
|
name: "hopx",
|
|
6
6
|
methods: {
|
|
7
|
-
|
|
7
|
+
instances: {
|
|
8
8
|
/**
|
|
9
9
|
* Create a new HopX sandbox
|
|
10
10
|
*
|
|
@@ -55,10 +55,7 @@ var hopx = defineProvider({
|
|
|
55
55
|
}
|
|
56
56
|
sandbox = await HopxSandbox.create(createOptions);
|
|
57
57
|
sandboxId = sandbox.sandboxId;
|
|
58
|
-
return {
|
|
59
|
-
sandbox,
|
|
60
|
-
sandboxId
|
|
61
|
-
};
|
|
58
|
+
return { instance: sandbox, instanceId: sandboxId };
|
|
62
59
|
} catch (error) {
|
|
63
60
|
if (error instanceof Error) {
|
|
64
61
|
if (error.message.includes("unauthorized") || error.message.includes("API key") || error.message.includes("401")) {
|
|
@@ -90,10 +87,7 @@ var hopx = defineProvider({
|
|
|
90
87
|
}
|
|
91
88
|
try {
|
|
92
89
|
const sandbox = await HopxSandbox.connect(sandboxId, apiKey, config.baseURL);
|
|
93
|
-
return {
|
|
94
|
-
sandbox,
|
|
95
|
-
sandboxId
|
|
96
|
-
};
|
|
90
|
+
return { instance: sandbox, instanceId: sandboxId };
|
|
97
91
|
} catch (error) {
|
|
98
92
|
return null;
|
|
99
93
|
}
|
|
@@ -114,8 +108,8 @@ var hopx = defineProvider({
|
|
|
114
108
|
baseURL: config.baseURL
|
|
115
109
|
});
|
|
116
110
|
return sandboxes.map((sandbox) => ({
|
|
117
|
-
sandbox,
|
|
118
|
-
|
|
111
|
+
instance: sandbox,
|
|
112
|
+
instanceId: sandbox.sandboxId
|
|
119
113
|
}));
|
|
120
114
|
} catch (error) {
|
|
121
115
|
return [];
|
package/dist/index.mjs.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 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 timeout: options?.timeout ? Math.ceil(options.timeout / 1000) : undefined,\n });\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,WAAW;AAAA,YACX,WAAW;AAAA,YACX,WAAW;AAAA,YACX,GAAG;AAAA,UACL,IAAI,WAAW,CAAC;AAGd,gBAAM,gBAAqB;AAAA,YACzB;AAAA,YACA,SAAS,OAAO;AAAA,YAChB;AAAA,YACA,GAAG;AAAA;AAAA,UACL;AAGA,cAAI,cAAc,YAAY;AAC5B,0BAAc,aAAa,cAAc;AAAA,UAC3C,OAAO;AACL,0B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F,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 InstanceInfo,\n CreateInstanceOptions,\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 instances: {\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?: CreateInstanceOptions) => {\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 { instance: sandbox, instanceId: sandboxId };\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 { instance: sandbox, instanceId: sandboxId };\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) => ({ instance: sandbox, instanceId: 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 timeout: options?.timeout ? Math.ceil(options.timeout / 1000) : undefined,\n });\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<InstanceInfo> => {\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,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOT,QAAQ,OAAO,QAAoB,YAAoC;AAErE,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,WAAW;AAAA,YACX,WAAW;AAAA,YACX,WAAW;AAAA,YACX,GAAG;AAAA,UACL,IAAI,WAAW,CAAC;AAGd,gBAAM,gBAAqB;AAAA,YACzB;AAAA,YACA,SAAS,OAAO;AAAA,YAChB;AAAA,YACA,GAAG;AAAA;AAAA,U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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.
|
|
3
|
+
"version": "0.2.36",
|
|
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
|
-
"
|
|
23
|
-
"computesdk": "
|
|
22
|
+
"computesdk": "4.1.11",
|
|
23
|
+
"@computesdk/provider": "2.1.13"
|
|
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": "2.0.
|
|
33
|
+
"@computesdk/test-utils": "2.0.4"
|
|
34
34
|
},
|
|
35
35
|
"keywords": [
|
|
36
36
|
"computesdk",
|