@computesdk/codesandbox 1.4.7 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -31,7 +31,7 @@ const compute = createCompute({
31
31
  });
32
32
 
33
33
  // Create sandbox
34
- const sandbox = await compute.sandbox.create({});
34
+ const sandbox = await compute.sandbox.create();
35
35
 
36
36
  // Execute JavaScript/Node.js code
37
37
  const result = await sandbox.runCode(`
package/dist/index.js CHANGED
@@ -129,12 +129,9 @@ var codesandbox = (0, import_computesdk.createProvider)({
129
129
  throw new Error(`Syntax error: ${output.trim()}`);
130
130
  }
131
131
  return {
132
- stdout: output,
133
- stderr: "",
132
+ output,
134
133
  exitCode: 0,
135
- executionTime: Date.now() - startTime,
136
- sandboxId: sandbox.id,
137
- provider: "codesandbox"
134
+ language: effectiveRuntime
138
135
  };
139
136
  } catch (error) {
140
137
  if (error instanceof Error && error.message.includes("Syntax error")) {
@@ -145,41 +142,30 @@ var codesandbox = (0, import_computesdk.createProvider)({
145
142
  );
146
143
  }
147
144
  },
148
- runCommand: async (sandbox, command, args = [], options) => {
145
+ runCommand: async (sandbox, command, args = []) => {
149
146
  const startTime = Date.now();
150
- const { command: finalCommand, args: finalArgs, isBackground } = (0, import_computesdk.createBackgroundCommand)(command, args, options);
151
147
  try {
152
148
  const client = await sandbox.connect();
153
- const quotedArgs = finalArgs.map((arg) => {
149
+ const quotedArgs = args.map((arg) => {
154
150
  if (arg.includes(" ") || arg.includes('"') || arg.includes("'") || arg.includes("$") || arg.includes("`")) {
155
151
  return `"${arg.replace(/"/g, '\\"')}"`;
156
152
  }
157
153
  return arg;
158
154
  });
159
- const fullCommand = quotedArgs.length > 0 ? `${finalCommand} ${quotedArgs.join(" ")}` : finalCommand;
155
+ const fullCommand = quotedArgs.length > 0 ? `${command} ${quotedArgs.join(" ")}` : command;
160
156
  const output = await client.commands.run(fullCommand);
161
157
  return {
162
158
  stdout: output,
163
159
  stderr: "",
164
160
  exitCode: 0,
165
- executionTime: Date.now() - startTime,
166
- sandboxId: sandbox.id,
167
- provider: "codesandbox",
168
- isBackground,
169
- // For background commands, we can't get a real PID, but we can indicate it's running
170
- ...isBackground && { pid: -1 }
161
+ durationMs: Date.now() - startTime
171
162
  };
172
163
  } catch (error) {
173
164
  return {
174
165
  stdout: "",
175
166
  stderr: error instanceof Error ? error.message : String(error),
176
167
  exitCode: 127,
177
- // Command not found exit code
178
- executionTime: Date.now() - startTime,
179
- sandboxId: sandbox.id,
180
- provider: "codesandbox",
181
- isBackground
182
- // Use the same value even for errors
168
+ durationMs: Date.now() - startTime
183
169
  };
184
170
  }
185
171
  },
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Codesandbox Provider - Factory-based Implementation\n * \n * Full-featured provider with filesystem support using the factory pattern.\n */\n\nimport { CodeSandbox } from '@codesandbox/sdk';\nimport type { Sandbox as CodesandboxSandbox } from '@codesandbox/sdk';\nimport { createProvider, createBackgroundCommand } from 'computesdk';\nimport type { Runtime, ExecutionResult, SandboxInfo, CreateSandboxOptions, FileEntry, RunCommandOptions } from 'computesdk';\n\n/**\n * Codesandbox-specific configuration options\n */\nexport interface CodesandboxConfig {\n /** CodeSandbox API key - if not provided, will fallback to CSB_API_KEY environment variable */\n apiKey?: string;\n /** Template to use for new sandboxes */\n templateId?: string;\n /** Default runtime environment */\n runtime?: Runtime;\n /** Execution timeout in milliseconds */\n timeout?: number;\n}\n\n/**\n * Create a Codesandbox provider instance using the factory pattern\n */\nexport const codesandbox = createProvider<CodesandboxSandbox, CodesandboxConfig>({\n name: 'codesandbox',\n methods: {\n sandbox: {\n // Collection operations (compute.sandbox.*)\n create: async (config: CodesandboxConfig, options?: CreateSandboxOptions) => {\n // Validate API key\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.CSB_API_KEY) || '';\n\n if (!apiKey) {\n throw new Error(\n `Missing CodeSandbox API key. Provide 'apiKey' in config or set CSB_API_KEY environment variable. Get your API key from https://codesandbox.io/t/api`\n );\n }\n\n const sdk = new CodeSandbox(apiKey);\n\n try {\n let sandbox: CodesandboxSandbox;\n let sandboxId: string;\n\n if (options?.sandboxId) {\n // Resume existing CodeSandbox using sdk.sandboxes.resume()\n sandbox = await sdk.sandboxes.resume(options.sandboxId);\n sandboxId = options.sandboxId;\n } else {\n // Create new CodeSandbox using sdk.sandboxes.create()\n const createOptions: any = {};\n \n if (config.templateId) {\n createOptions.id = config.templateId;\n }\n\n sandbox = await sdk.sandboxes.create(createOptions);\n sandboxId = sandbox.id;\n }\n\n return {\n sandbox,\n sandboxId\n };\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('unauthorized') || error.message.includes('API key')) {\n throw new Error(\n `CodeSandbox authentication failed. Please check your CSB_API_KEY environment variable. Get your API key from https://codesandbox.io/t/api`\n );\n }\n if (error.message.includes('quota') || error.message.includes('limit')) {\n throw new Error(\n `CodeSandbox quota exceeded. Please check your usage at https://codesandbox.io/dashboard`\n );\n }\n }\n throw new Error(\n `Failed to create CodeSandbox sandbox: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n getById: async (config: CodesandboxConfig, sandboxId: string) => {\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.CSB_API_KEY) || '';\n\n if (!apiKey) {\n throw new Error(\n `Missing CodeSandbox API key. Provide 'apiKey' in config or set CSB_API_KEY environment variable.`\n );\n }\n\n const sdk = new CodeSandbox(apiKey);\n\n try {\n // Resume existing sandbox using sdk.sandboxes.resume()\n const sandbox = await sdk.sandboxes.resume(sandboxId);\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 list: async (_config: CodesandboxConfig) => {\n throw new Error(\n `CodeSandbox provider does not support listing sandboxes. CodeSandbox SDK does not provide a native list API. Consider using the CodeSandbox dashboard or implement your own tracking system.`\n );\n },\n\n destroy: async (config: CodesandboxConfig, sandboxId: string) => {\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.CSB_API_KEY) || '';\n\n if (!apiKey) {\n throw new Error(\n `Missing CodeSandbox API key. Provide 'apiKey' in config or set CSB_API_KEY environment variable.`\n );\n }\n\n const sdk = new CodeSandbox(apiKey);\n\n try {\n // Shutdown the sandbox using sdk.sandboxes.shutdown() to clean it up\n await sdk.sandboxes.shutdown(sandboxId);\n } catch (error) {\n // Sandbox might already be shutdown or doesn't exist\n // This is acceptable for destroy operations\n }\n },\n\n // Instance operations (sandbox.*)\n runCode: async (sandbox: CodesandboxSandbox, code: string, runtime?: Runtime): Promise<ExecutionResult> => {\n const startTime = Date.now();\n\n try {\n // Connect to the sandbox client using sandbox.connect()\n const client = await sandbox.connect();\n\n // Auto-detect runtime if not specified\n const effectiveRuntime = runtime || (\n // Strong Python indicators\n code.includes('print(') || \n code.includes('import ') ||\n code.includes('def ') ||\n code.includes('sys.') ||\n code.includes('json.') ||\n code.includes('__') ||\n code.includes('f\"') ||\n code.includes(\"f'\") ||\n code.includes('raise ')\n ? 'python'\n // Default to Node.js for all other cases (including ambiguous)\n : 'node'\n );\n\n // Use base64 encoding for reliability and consistency\n const encoded = Buffer.from(code).toString('base64');\n let command: string;\n\n if (effectiveRuntime === 'python') {\n // Execute Python code using client.commands.run()\n command = `echo \"${encoded}\" | base64 -d | python3`;\n } else {\n // Execute Node.js code using client.commands.run()\n command = `echo \"${encoded}\" | base64 -d | node`;\n }\n\n // Execute the command using CodeSandbox client.commands.run()\n // This returns the full output as a string\n const output = await client.commands.run(command);\n\n // Check for syntax errors in the output and throw them (similar to other providers)\n if (output.includes('SyntaxError') || \n output.includes('invalid syntax') ||\n output.includes('Unexpected token') ||\n output.includes('Unexpected identifier')) {\n throw new Error(`Syntax error: ${output.trim()}`);\n }\n\n return {\n stdout: output,\n stderr: '',\n exitCode: 0,\n executionTime: Date.now() - startTime,\n sandboxId: sandbox.id,\n provider: 'codesandbox'\n };\n } catch (error) {\n // Re-throw syntax errors\n if (error instanceof Error && error.message.includes('Syntax error')) {\n throw error;\n }\n throw new Error(\n `CodeSandbox execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n runCommand: async (sandbox: CodesandboxSandbox, command: string, args: string[] = [], options?: RunCommandOptions): Promise<ExecutionResult> => {\n const startTime = Date.now();\n\n // Handle background command execution outside try block so it's accessible everywhere\n const { command: finalCommand, args: finalArgs, isBackground } = createBackgroundCommand(command, args, options);\n\n try {\n // Connect to the sandbox client using sandbox.connect()\n const client = await sandbox.connect();\n\n // Construct full command with arguments, properly quoting each arg\n const quotedArgs = finalArgs.map(arg => {\n // Quote arguments that contain spaces or special characters\n if (arg.includes(' ') || arg.includes('\"') || arg.includes(\"'\") || arg.includes('$') || arg.includes('`')) {\n // Escape any double quotes in the argument and wrap in double quotes\n return `\"${arg.replace(/\"/g, '\\\\\"')}\"`;\n }\n return arg;\n });\n const fullCommand = quotedArgs.length > 0 ? `${finalCommand} ${quotedArgs.join(' ')}` : finalCommand;\n\n // Execute command using CodeSandbox client.commands.run()\n // This returns the full output as a string\n const output = await client.commands.run(fullCommand);\n\n return {\n stdout: output,\n stderr: '',\n exitCode: 0,\n executionTime: Date.now() - startTime,\n sandboxId: sandbox.id,\n provider: 'codesandbox',\n isBackground,\n // For background commands, we can't get a real PID, but we can indicate it's running\n ...(isBackground && { pid: -1 })\n };\n } catch (error) {\n // For command failures, return error info instead of throwing\n return {\n stdout: '',\n stderr: error instanceof Error ? error.message : String(error),\n exitCode: 127, // Command not found exit code\n executionTime: Date.now() - startTime,\n sandboxId: sandbox.id,\n provider: 'codesandbox',\n isBackground // Use the same value even for errors\n };\n }\n },\n\n getInfo: async (sandbox: CodesandboxSandbox): Promise<SandboxInfo> => {\n return {\n id: sandbox.id,\n provider: 'codesandbox',\n runtime: 'node', // CodeSandbox default\n status: 'running',\n createdAt: new Date(),\n timeout: 300000,\n metadata: {\n cluster: sandbox.cluster,\n bootupType: sandbox.bootupType,\n isUpToDate: sandbox.isUpToDate\n }\n };\n },\n\n getUrl: async (sandbox: CodesandboxSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n const protocol = options.protocol || 'https';\n // CodeSandbox provides URLs in the format: https://{sandbox-id}.{cluster}.csb.app:{port}\n // Use the actual CodeSandbox URL format\n return `${protocol}://${sandbox.id}.${sandbox.cluster}.csb.app:${options.port}`;\n },\n\n // Filesystem operations using CodeSandbox client.fs API\n filesystem: {\n readFile: async (sandbox: CodesandboxSandbox, path: string): Promise<string> => {\n // Connect to the sandbox client and use client.fs.readTextFile()\n const client = await sandbox.connect();\n return await client.fs.readTextFile(path);\n },\n\n writeFile: async (sandbox: CodesandboxSandbox, path: string, content: string): Promise<void> => {\n // Connect to the sandbox client and use client.fs.writeTextFile()\n const client = await sandbox.connect();\n await client.fs.writeTextFile(path, content);\n },\n\n mkdir: async (sandbox: CodesandboxSandbox, path: string): Promise<void> => {\n // CodeSandbox doesn't have a direct mkdir API, use commands to create directory\n const client = await sandbox.connect();\n await client.commands.run(`mkdir -p \"${path}\"`);\n },\n\n readdir: async (sandbox: CodesandboxSandbox, path: string): Promise<FileEntry[]> => {\n // Connect to the sandbox client and use client.fs.readdir()\n const client = await sandbox.connect();\n const entries = await client.fs.readdir(path);\n\n return entries.map((entry: any) => ({\n name: entry.name,\n path: `${path}/${entry.name}`.replace(/\\/+/g, '/'),\n isDirectory: entry.isDirectory || false,\n size: entry.size || 0,\n lastModified: entry.lastModified ? new Date(entry.lastModified) : new Date()\n }));\n },\n\n exists: async (sandbox: CodesandboxSandbox, path: string): Promise<boolean> => {\n // CodeSandbox doesn't have a direct exists API, use ls command to check\n const client = await sandbox.connect();\n try {\n await client.commands.run(`ls \"${path}\"`);\n return true;\n } catch {\n return false;\n }\n },\n\n remove: async (sandbox: CodesandboxSandbox, path: string): Promise<void> => {\n // Connect to the sandbox client and use client.fs.remove()\n const client = await sandbox.connect();\n await client.fs.remove(path);\n }\n },\n\n // Provider-specific typed getInstance method\n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C;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Codesandbox Provider - Factory-based Implementation\n * \n * Full-featured provider with filesystem support using the factory pattern.\n */\n\nimport { CodeSandbox } from '@codesandbox/sdk';\nimport type { Sandbox as CodesandboxSandbox } from '@codesandbox/sdk';\nimport { createProvider } from 'computesdk';\nimport type { Runtime, CodeResult, CommandResult, SandboxInfo, CreateSandboxOptions, FileEntry } from 'computesdk';\n\n/**\n * Codesandbox-specific configuration options\n */\nexport interface CodesandboxConfig {\n /** CodeSandbox API key - if not provided, will fallback to CSB_API_KEY environment variable */\n apiKey?: string;\n /** Template to use for new sandboxes */\n templateId?: string;\n /** Default runtime environment */\n runtime?: Runtime;\n /** Execution timeout in milliseconds */\n timeout?: number;\n}\n\n/**\n * Create a Codesandbox provider instance using the factory pattern\n */\nexport const codesandbox = createProvider<CodesandboxSandbox, CodesandboxConfig>({\n name: 'codesandbox',\n methods: {\n sandbox: {\n // Collection operations (compute.sandbox.*)\n create: async (config: CodesandboxConfig, options?: CreateSandboxOptions) => {\n // Validate API key\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.CSB_API_KEY) || '';\n\n if (!apiKey) {\n throw new Error(\n `Missing CodeSandbox API key. Provide 'apiKey' in config or set CSB_API_KEY environment variable. Get your API key from https://codesandbox.io/t/api`\n );\n }\n\n const sdk = new CodeSandbox(apiKey);\n\n try {\n let sandbox: CodesandboxSandbox;\n let sandboxId: string;\n\n if (options?.sandboxId) {\n // Resume existing CodeSandbox using sdk.sandboxes.resume()\n sandbox = await sdk.sandboxes.resume(options.sandboxId);\n sandboxId = options.sandboxId;\n } else {\n // Create new CodeSandbox using sdk.sandboxes.create()\n const createOptions: any = {};\n \n if (config.templateId) {\n createOptions.id = config.templateId;\n }\n\n sandbox = await sdk.sandboxes.create(createOptions);\n sandboxId = sandbox.id;\n }\n\n return {\n sandbox,\n sandboxId\n };\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('unauthorized') || error.message.includes('API key')) {\n throw new Error(\n `CodeSandbox authentication failed. Please check your CSB_API_KEY environment variable. Get your API key from https://codesandbox.io/t/api`\n );\n }\n if (error.message.includes('quota') || error.message.includes('limit')) {\n throw new Error(\n `CodeSandbox quota exceeded. Please check your usage at https://codesandbox.io/dashboard`\n );\n }\n }\n throw new Error(\n `Failed to create CodeSandbox sandbox: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n getById: async (config: CodesandboxConfig, sandboxId: string) => {\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.CSB_API_KEY) || '';\n\n if (!apiKey) {\n throw new Error(\n `Missing CodeSandbox API key. Provide 'apiKey' in config or set CSB_API_KEY environment variable.`\n );\n }\n\n const sdk = new CodeSandbox(apiKey);\n\n try {\n // Resume existing sandbox using sdk.sandboxes.resume()\n const sandbox = await sdk.sandboxes.resume(sandboxId);\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 list: async (_config: CodesandboxConfig) => {\n throw new Error(\n `CodeSandbox provider does not support listing sandboxes. CodeSandbox SDK does not provide a native list API. Consider using the CodeSandbox dashboard or implement your own tracking system.`\n );\n },\n\n destroy: async (config: CodesandboxConfig, sandboxId: string) => {\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.CSB_API_KEY) || '';\n\n if (!apiKey) {\n throw new Error(\n `Missing CodeSandbox API key. Provide 'apiKey' in config or set CSB_API_KEY environment variable.`\n );\n }\n\n const sdk = new CodeSandbox(apiKey);\n\n try {\n // Shutdown the sandbox using sdk.sandboxes.shutdown() to clean it up\n await sdk.sandboxes.shutdown(sandboxId);\n } catch (error) {\n // Sandbox might already be shutdown or doesn't exist\n // This is acceptable for destroy operations\n }\n },\n\n // Instance operations (sandbox.*)\n runCode: async (sandbox: CodesandboxSandbox, code: string, runtime?: Runtime): Promise<CodeResult> => {\n const startTime = Date.now();\n\n try {\n // Connect to the sandbox client using sandbox.connect()\n const client = await sandbox.connect();\n\n // Auto-detect runtime if not specified\n const effectiveRuntime = runtime || (\n // Strong Python indicators\n code.includes('print(') || \n code.includes('import ') ||\n code.includes('def ') ||\n code.includes('sys.') ||\n code.includes('json.') ||\n code.includes('__') ||\n code.includes('f\"') ||\n code.includes(\"f'\") ||\n code.includes('raise ')\n ? 'python'\n // Default to Node.js for all other cases (including ambiguous)\n : 'node'\n );\n\n // Use base64 encoding for reliability and consistency\n const encoded = Buffer.from(code).toString('base64');\n let command: string;\n\n if (effectiveRuntime === 'python') {\n // Execute Python code using client.commands.run()\n command = `echo \"${encoded}\" | base64 -d | python3`;\n } else {\n // Execute Node.js code using client.commands.run()\n command = `echo \"${encoded}\" | base64 -d | node`;\n }\n\n // Execute the command using CodeSandbox client.commands.run()\n // This returns the full output as a string\n const output = await client.commands.run(command);\n\n // Check for syntax errors in the output and throw them (similar to other providers)\n if (output.includes('SyntaxError') ||\n output.includes('invalid syntax') ||\n output.includes('Unexpected token') ||\n output.includes('Unexpected identifier')) {\n throw new Error(`Syntax error: ${output.trim()}`);\n }\n\n return {\n output: output,\n exitCode: 0,\n language: effectiveRuntime\n };\n } catch (error) {\n // Re-throw syntax errors\n if (error instanceof Error && error.message.includes('Syntax error')) {\n throw error;\n }\n throw new Error(\n `CodeSandbox execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n runCommand: async (sandbox: CodesandboxSandbox, command: string, args: string[] = []): Promise<CommandResult> => {\n const startTime = Date.now();\n\n try {\n // Connect to the sandbox client using sandbox.connect()\n const client = await sandbox.connect();\n\n // Construct full command with arguments, properly quoting each arg\n const quotedArgs = args.map((arg: string) => {\n if (arg.includes(' ') || arg.includes('\"') || arg.includes(\"'\") || arg.includes('$') || arg.includes('`')) {\n return `\"${arg.replace(/\"/g, '\\\\\"')}\"`;\n }\n return arg;\n });\n const fullCommand = quotedArgs.length > 0 ? `${command} ${quotedArgs.join(' ')}` : command;\n\n // Execute command using CodeSandbox client.commands.run()\n const output = await client.commands.run(fullCommand);\n\n return {\n stdout: output,\n stderr: '',\n exitCode: 0,\n durationMs: Date.now() - startTime\n };\n } catch (error) {\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 getInfo: async (sandbox: CodesandboxSandbox): Promise<SandboxInfo> => {\n return {\n id: sandbox.id,\n provider: 'codesandbox',\n runtime: 'node', // CodeSandbox default\n status: 'running',\n createdAt: new Date(),\n timeout: 300000,\n metadata: {\n cluster: sandbox.cluster,\n bootupType: sandbox.bootupType,\n isUpToDate: sandbox.isUpToDate\n }\n };\n },\n\n getUrl: async (sandbox: CodesandboxSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n const protocol = options.protocol || 'https';\n // CodeSandbox provides URLs in the format: https://{sandbox-id}.{cluster}.csb.app:{port}\n // Use the actual CodeSandbox URL format\n return `${protocol}://${sandbox.id}.${sandbox.cluster}.csb.app:${options.port}`;\n },\n\n // Filesystem operations using CodeSandbox client.fs API\n filesystem: {\n readFile: async (sandbox: CodesandboxSandbox, path: string): Promise<string> => {\n // Connect to the sandbox client and use client.fs.readTextFile()\n const client = await sandbox.connect();\n return await client.fs.readTextFile(path);\n },\n\n writeFile: async (sandbox: CodesandboxSandbox, path: string, content: string): Promise<void> => {\n // Connect to the sandbox client and use client.fs.writeTextFile()\n const client = await sandbox.connect();\n await client.fs.writeTextFile(path, content);\n },\n\n mkdir: async (sandbox: CodesandboxSandbox, path: string): Promise<void> => {\n // CodeSandbox doesn't have a direct mkdir API, use commands to create directory\n const client = await sandbox.connect();\n await client.commands.run(`mkdir -p \"${path}\"`);\n },\n\n readdir: async (sandbox: CodesandboxSandbox, path: string): Promise<FileEntry[]> => {\n // Connect to the sandbox client and use client.fs.readdir()\n const client = await sandbox.connect();\n const entries = await client.fs.readdir(path);\n\n return entries.map((entry: any) => ({\n name: entry.name,\n path: `${path}/${entry.name}`.replace(/\\/+/g, '/'),\n isDirectory: entry.isDirectory || false,\n size: entry.size || 0,\n lastModified: entry.lastModified ? new Date(entry.lastModified) : new Date()\n }));\n },\n\n exists: async (sandbox: CodesandboxSandbox, path: string): Promise<boolean> => {\n // CodeSandbox doesn't have a direct exists API, use ls command to check\n const client = await sandbox.connect();\n try {\n await client.commands.run(`ls \"${path}\"`);\n return true;\n } catch {\n return false;\n }\n },\n\n remove: async (sandbox: CodesandboxSandbox, path: string): Promise<void> => {\n // Connect to the sandbox client and use client.fs.remove()\n const client = await sandbox.connect();\n await client.fs.remove(path);\n }\n },\n\n // Provider-specific typed getInstance method\n getInstance: (sandbox: CodesandboxSandbox): CodesandboxSandbox => {\n return sandbox;\n },\n\n }\n }\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,iBAA4B;AAE5B,wBAA+B;AAoBxB,IAAM,kBAAc,kCAAsD;AAAA,EAC/E,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA;AAAA,MAEP,QAAQ,OAAO,QAA2B,YAAmC;AAE3E,cAAM,SAAS,OAAO,UAAW,OAAO,YAAY,eAAe,QAAQ,KAAK,eAAgB;AAEhG,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAEA,cAAM,MAAM,IAAI,uBAAY,MAAM;AAElC,YAAI;AACF,cAAI;AACJ,cAAI;AAEJ,cAAI,SAAS,WAAW;AAEtB,sBAAU,MAAM,IAAI,UAAU,OAAO,QAAQ,SAAS;AACtD,wBAAY,QAAQ;AAAA,UACtB,OAAO;AAEL,kBAAM,gBAAqB,CAAC;AAE5B,gBAAI,OAAO,YAAY;AACrB,4BAAc,KAAK,OAAO;AAAA,YAC5B;AAEA,sBAAU,MAAM,IAAI,UAAU,OAAO,aAAa;AAClD,wBAAY,QAAQ;AAAA,UACtB;AAEA,iBAAO;AAAA,YACL;AAAA,YACA;AAAA,UACF;AAAA,QACF,SAAS,OAAO;AACd,c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EF;AAAA,EACF;AACF,CAAC;","names":[]}
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/index.ts
2
2
  import { CodeSandbox } from "@codesandbox/sdk";
3
- import { createProvider, createBackgroundCommand } from "computesdk";
3
+ import { createProvider } from "computesdk";
4
4
  var codesandbox = createProvider({
5
5
  name: "codesandbox",
6
6
  methods: {
@@ -105,12 +105,9 @@ var codesandbox = createProvider({
105
105
  throw new Error(`Syntax error: ${output.trim()}`);
106
106
  }
107
107
  return {
108
- stdout: output,
109
- stderr: "",
108
+ output,
110
109
  exitCode: 0,
111
- executionTime: Date.now() - startTime,
112
- sandboxId: sandbox.id,
113
- provider: "codesandbox"
110
+ language: effectiveRuntime
114
111
  };
115
112
  } catch (error) {
116
113
  if (error instanceof Error && error.message.includes("Syntax error")) {
@@ -121,41 +118,30 @@ var codesandbox = createProvider({
121
118
  );
122
119
  }
123
120
  },
124
- runCommand: async (sandbox, command, args = [], options) => {
121
+ runCommand: async (sandbox, command, args = []) => {
125
122
  const startTime = Date.now();
126
- const { command: finalCommand, args: finalArgs, isBackground } = createBackgroundCommand(command, args, options);
127
123
  try {
128
124
  const client = await sandbox.connect();
129
- const quotedArgs = finalArgs.map((arg) => {
125
+ const quotedArgs = args.map((arg) => {
130
126
  if (arg.includes(" ") || arg.includes('"') || arg.includes("'") || arg.includes("$") || arg.includes("`")) {
131
127
  return `"${arg.replace(/"/g, '\\"')}"`;
132
128
  }
133
129
  return arg;
134
130
  });
135
- const fullCommand = quotedArgs.length > 0 ? `${finalCommand} ${quotedArgs.join(" ")}` : finalCommand;
131
+ const fullCommand = quotedArgs.length > 0 ? `${command} ${quotedArgs.join(" ")}` : command;
136
132
  const output = await client.commands.run(fullCommand);
137
133
  return {
138
134
  stdout: output,
139
135
  stderr: "",
140
136
  exitCode: 0,
141
- executionTime: Date.now() - startTime,
142
- sandboxId: sandbox.id,
143
- provider: "codesandbox",
144
- isBackground,
145
- // For background commands, we can't get a real PID, but we can indicate it's running
146
- ...isBackground && { pid: -1 }
137
+ durationMs: Date.now() - startTime
147
138
  };
148
139
  } catch (error) {
149
140
  return {
150
141
  stdout: "",
151
142
  stderr: error instanceof Error ? error.message : String(error),
152
143
  exitCode: 127,
153
- // Command not found exit code
154
- executionTime: Date.now() - startTime,
155
- sandboxId: sandbox.id,
156
- provider: "codesandbox",
157
- isBackground
158
- // Use the same value even for errors
144
+ durationMs: Date.now() - startTime
159
145
  };
160
146
  }
161
147
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Codesandbox Provider - Factory-based Implementation\n * \n * Full-featured provider with filesystem support using the factory pattern.\n */\n\nimport { CodeSandbox } from '@codesandbox/sdk';\nimport type { Sandbox as CodesandboxSandbox } from '@codesandbox/sdk';\nimport { createProvider, createBackgroundCommand } from 'computesdk';\nimport type { Runtime, ExecutionResult, SandboxInfo, CreateSandboxOptions, FileEntry, RunCommandOptions } from 'computesdk';\n\n/**\n * Codesandbox-specific configuration options\n */\nexport interface CodesandboxConfig {\n /** CodeSandbox API key - if not provided, will fallback to CSB_API_KEY environment variable */\n apiKey?: string;\n /** Template to use for new sandboxes */\n templateId?: string;\n /** Default runtime environment */\n runtime?: Runtime;\n /** Execution timeout in milliseconds */\n timeout?: number;\n}\n\n/**\n * Create a Codesandbox provider instance using the factory pattern\n */\nexport const codesandbox = createProvider<CodesandboxSandbox, CodesandboxConfig>({\n name: 'codesandbox',\n methods: {\n sandbox: {\n // Collection operations (compute.sandbox.*)\n create: async (config: CodesandboxConfig, options?: CreateSandboxOptions) => {\n // Validate API key\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.CSB_API_KEY) || '';\n\n if (!apiKey) {\n throw new Error(\n `Missing CodeSandbox API key. Provide 'apiKey' in config or set CSB_API_KEY environment variable. Get your API key from https://codesandbox.io/t/api`\n );\n }\n\n const sdk = new CodeSandbox(apiKey);\n\n try {\n let sandbox: CodesandboxSandbox;\n let sandboxId: string;\n\n if (options?.sandboxId) {\n // Resume existing CodeSandbox using sdk.sandboxes.resume()\n sandbox = await sdk.sandboxes.resume(options.sandboxId);\n sandboxId = options.sandboxId;\n } else {\n // Create new CodeSandbox using sdk.sandboxes.create()\n const createOptions: any = {};\n \n if (config.templateId) {\n createOptions.id = config.templateId;\n }\n\n sandbox = await sdk.sandboxes.create(createOptions);\n sandboxId = sandbox.id;\n }\n\n return {\n sandbox,\n sandboxId\n };\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('unauthorized') || error.message.includes('API key')) {\n throw new Error(\n `CodeSandbox authentication failed. Please check your CSB_API_KEY environment variable. Get your API key from https://codesandbox.io/t/api`\n );\n }\n if (error.message.includes('quota') || error.message.includes('limit')) {\n throw new Error(\n `CodeSandbox quota exceeded. Please check your usage at https://codesandbox.io/dashboard`\n );\n }\n }\n throw new Error(\n `Failed to create CodeSandbox sandbox: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n getById: async (config: CodesandboxConfig, sandboxId: string) => {\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.CSB_API_KEY) || '';\n\n if (!apiKey) {\n throw new Error(\n `Missing CodeSandbox API key. Provide 'apiKey' in config or set CSB_API_KEY environment variable.`\n );\n }\n\n const sdk = new CodeSandbox(apiKey);\n\n try {\n // Resume existing sandbox using sdk.sandboxes.resume()\n const sandbox = await sdk.sandboxes.resume(sandboxId);\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 list: async (_config: CodesandboxConfig) => {\n throw new Error(\n `CodeSandbox provider does not support listing sandboxes. CodeSandbox SDK does not provide a native list API. Consider using the CodeSandbox dashboard or implement your own tracking system.`\n );\n },\n\n destroy: async (config: CodesandboxConfig, sandboxId: string) => {\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.CSB_API_KEY) || '';\n\n if (!apiKey) {\n throw new Error(\n `Missing CodeSandbox API key. Provide 'apiKey' in config or set CSB_API_KEY environment variable.`\n );\n }\n\n const sdk = new CodeSandbox(apiKey);\n\n try {\n // Shutdown the sandbox using sdk.sandboxes.shutdown() to clean it up\n await sdk.sandboxes.shutdown(sandboxId);\n } catch (error) {\n // Sandbox might already be shutdown or doesn't exist\n // This is acceptable for destroy operations\n }\n },\n\n // Instance operations (sandbox.*)\n runCode: async (sandbox: CodesandboxSandbox, code: string, runtime?: Runtime): Promise<ExecutionResult> => {\n const startTime = Date.now();\n\n try {\n // Connect to the sandbox client using sandbox.connect()\n const client = await sandbox.connect();\n\n // Auto-detect runtime if not specified\n const effectiveRuntime = runtime || (\n // Strong Python indicators\n code.includes('print(') || \n code.includes('import ') ||\n code.includes('def ') ||\n code.includes('sys.') ||\n code.includes('json.') ||\n code.includes('__') ||\n code.includes('f\"') ||\n code.includes(\"f'\") ||\n code.includes('raise ')\n ? 'python'\n // Default to Node.js for all other cases (including ambiguous)\n : 'node'\n );\n\n // Use base64 encoding for reliability and consistency\n const encoded = Buffer.from(code).toString('base64');\n let command: string;\n\n if (effectiveRuntime === 'python') {\n // Execute Python code using client.commands.run()\n command = `echo \"${encoded}\" | base64 -d | python3`;\n } else {\n // Execute Node.js code using client.commands.run()\n command = `echo \"${encoded}\" | base64 -d | node`;\n }\n\n // Execute the command using CodeSandbox client.commands.run()\n // This returns the full output as a string\n const output = await client.commands.run(command);\n\n // Check for syntax errors in the output and throw them (similar to other providers)\n if (output.includes('SyntaxError') || \n output.includes('invalid syntax') ||\n output.includes('Unexpected token') ||\n output.includes('Unexpected identifier')) {\n throw new Error(`Syntax error: ${output.trim()}`);\n }\n\n return {\n stdout: output,\n stderr: '',\n exitCode: 0,\n executionTime: Date.now() - startTime,\n sandboxId: sandbox.id,\n provider: 'codesandbox'\n };\n } catch (error) {\n // Re-throw syntax errors\n if (error instanceof Error && error.message.includes('Syntax error')) {\n throw error;\n }\n throw new Error(\n `CodeSandbox execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n runCommand: async (sandbox: CodesandboxSandbox, command: string, args: string[] = [], options?: RunCommandOptions): Promise<ExecutionResult> => {\n const startTime = Date.now();\n\n // Handle background command execution outside try block so it's accessible everywhere\n const { command: finalCommand, args: finalArgs, isBackground } = createBackgroundCommand(command, args, options);\n\n try {\n // Connect to the sandbox client using sandbox.connect()\n const client = await sandbox.connect();\n\n // Construct full command with arguments, properly quoting each arg\n const quotedArgs = finalArgs.map(arg => {\n // Quote arguments that contain spaces or special characters\n if (arg.includes(' ') || arg.includes('\"') || arg.includes(\"'\") || arg.includes('$') || arg.includes('`')) {\n // Escape any double quotes in the argument and wrap in double quotes\n return `\"${arg.replace(/\"/g, '\\\\\"')}\"`;\n }\n return arg;\n });\n const fullCommand = quotedArgs.length > 0 ? `${finalCommand} ${quotedArgs.join(' ')}` : finalCommand;\n\n // Execute command using CodeSandbox client.commands.run()\n // This returns the full output as a string\n const output = await client.commands.run(fullCommand);\n\n return {\n stdout: output,\n stderr: '',\n exitCode: 0,\n executionTime: Date.now() - startTime,\n sandboxId: sandbox.id,\n provider: 'codesandbox',\n isBackground,\n // For background commands, we can't get a real PID, but we can indicate it's running\n ...(isBackground && { pid: -1 })\n };\n } catch (error) {\n // For command failures, return error info instead of throwing\n return {\n stdout: '',\n stderr: error instanceof Error ? error.message : String(error),\n exitCode: 127, // Command not found exit code\n executionTime: Date.now() - startTime,\n sandboxId: sandbox.id,\n provider: 'codesandbox',\n isBackground // Use the same value even for errors\n };\n }\n },\n\n getInfo: async (sandbox: CodesandboxSandbox): Promise<SandboxInfo> => {\n return {\n id: sandbox.id,\n provider: 'codesandbox',\n runtime: 'node', // CodeSandbox default\n status: 'running',\n createdAt: new Date(),\n timeout: 300000,\n metadata: {\n cluster: sandbox.cluster,\n bootupType: sandbox.bootupType,\n isUpToDate: sandbox.isUpToDate\n }\n };\n },\n\n getUrl: async (sandbox: CodesandboxSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n const protocol = options.protocol || 'https';\n // CodeSandbox provides URLs in the format: https://{sandbox-id}.{cluster}.csb.app:{port}\n // Use the actual CodeSandbox URL format\n return `${protocol}://${sandbox.id}.${sandbox.cluster}.csb.app:${options.port}`;\n },\n\n // Filesystem operations using CodeSandbox client.fs API\n filesystem: {\n readFile: async (sandbox: CodesandboxSandbox, path: string): Promise<string> => {\n // Connect to the sandbox client and use client.fs.readTextFile()\n const client = await sandbox.connect();\n return await client.fs.readTextFile(path);\n },\n\n writeFile: async (sandbox: CodesandboxSandbox, path: string, content: string): Promise<void> => {\n // Connect to the sandbox client and use client.fs.writeTextFile()\n const client = await sandbox.connect();\n await client.fs.writeTextFile(path, content);\n },\n\n mkdir: async (sandbox: CodesandboxSandbox, path: string): Promise<void> => {\n // CodeSandbox doesn't have a direct mkdir API, use commands to create directory\n const client = await sandbox.connect();\n await client.commands.run(`mkdir -p \"${path}\"`);\n },\n\n readdir: async (sandbox: CodesandboxSandbox, path: string): Promise<FileEntry[]> => {\n // Connect to the sandbox client and use client.fs.readdir()\n const client = await sandbox.connect();\n const entries = await client.fs.readdir(path);\n\n return entries.map((entry: any) => ({\n name: entry.name,\n path: `${path}/${entry.name}`.replace(/\\/+/g, '/'),\n isDirectory: entry.isDirectory || false,\n size: entry.size || 0,\n lastModified: entry.lastModified ? new Date(entry.lastModified) : new Date()\n }));\n },\n\n exists: async (sandbox: CodesandboxSandbox, path: string): Promise<boolean> => {\n // CodeSandbox doesn't have a direct exists API, use ls command to check\n const client = await sandbox.connect();\n try {\n await client.commands.run(`ls \"${path}\"`);\n return true;\n } catch {\n return false;\n }\n },\n\n remove: async (sandbox: CodesandboxSandbox, path: string): Promise<void> => {\n // Connect to the sandbox client and use client.fs.remove()\n const client = await sandbox.connect();\n await client.fs.remove(path);\n }\n },\n\n // Provider-specific typed getInstance method\n getInstance: (sandbox: CodesandboxSandbox): CodesandboxSandbox => {\n return sandbox;\n },\n\n }\n }\n});\n"],"mappings":";AAMA,SAAS,mBAAmB;AAE5B,SAAS,gBAAgB,+BAA+B;AAoBjD,IAAM,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AG,cAAc,MAAM,OAAO;AAAA,QAC7C;AAAA,QAEA,OAAO,OAAO,SAA6B,SAAgC;AAEzE,gBAAM,SAAS,MAAM,QAAQ,QAAQ;AACrC,gBAAM,OAAO,SAAS,IAAI,aAAa,IAAI,GAAG;AAAA,QAChD;AAAA,QAEA,SAAS,OAAO,SAA6B,SAAuC;AAElF,gBAAM,SAAS,MAAM,QAAQ,QAAQ;AACrC,gBAAM,UAAU,MAAM,OAAO,GAAG,QAAQ,IAAI;AAE5C,iBAAO,QAAQ,IAAI,CAAC,WAAgB;AAAA,YAClC,MAAM,MAAM;AAAA,YACZ,MAAM,GAAG,IAAI,IAAI,MAAM,IAAI,GAAG,QAAQ,QAAQ,GAAG;AAAA,YACjD,aAAa,MAAM,eAAe;AAAA,YAClC,MAAM,MAAM,QAAQ;AAAA,YACpB,cAAc,MAAM,eAAe,IAAI,KAAK,MAAM,YAAY,IAAI,oBAAI,KAAK;AAAA,UAC7E,EAAE;AAAA,QACJ;AAAA,QAEA,QAAQ,OAAO,SAA6B,SAAmC;AAE7E,gBAAM,SAAS,MAAM,QAAQ,QAAQ;AACrC,cAAI;AACF,kBAAM,OAAO,SAAS,IAAI,OAAO,IAAI,GAAG;AACxC,mBAAO;AAAA,UACT,QAAQ;AACN,mBAAO;AAAA,UACT;AAAA,QACF;AAAA,QAEA,QAAQ,OAAO,SAA6B,SAAgC;AAE1E,gBAAM,SAAS,MAAM,QAAQ,QAAQ;AACrC,gBAAM,OAAO,GAAG,OAAO,IAAI;AAAA,QAC7B;AAAA,MACF;AAAA;AAAA,MAGA,aAAa,CAAC,YAAoD;AAChE,eAAO;AAAA,MACT;AAAA,IAEF;AAAA,EACF;AACF,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Codesandbox Provider - Factory-based Implementation\n * \n * Full-featured provider with filesystem support using the factory pattern.\n */\n\nimport { CodeSandbox } from '@codesandbox/sdk';\nimport type { Sandbox as CodesandboxSandbox } from '@codesandbox/sdk';\nimport { createProvider } from 'computesdk';\nimport type { Runtime, CodeResult, CommandResult, SandboxInfo, CreateSandboxOptions, FileEntry } from 'computesdk';\n\n/**\n * Codesandbox-specific configuration options\n */\nexport interface CodesandboxConfig {\n /** CodeSandbox API key - if not provided, will fallback to CSB_API_KEY environment variable */\n apiKey?: string;\n /** Template to use for new sandboxes */\n templateId?: string;\n /** Default runtime environment */\n runtime?: Runtime;\n /** Execution timeout in milliseconds */\n timeout?: number;\n}\n\n/**\n * Create a Codesandbox provider instance using the factory pattern\n */\nexport const codesandbox = createProvider<CodesandboxSandbox, CodesandboxConfig>({\n name: 'codesandbox',\n methods: {\n sandbox: {\n // Collection operations (compute.sandbox.*)\n create: async (config: CodesandboxConfig, options?: CreateSandboxOptions) => {\n // Validate API key\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.CSB_API_KEY) || '';\n\n if (!apiKey) {\n throw new Error(\n `Missing CodeSandbox API key. Provide 'apiKey' in config or set CSB_API_KEY environment variable. Get your API key from https://codesandbox.io/t/api`\n );\n }\n\n const sdk = new CodeSandbox(apiKey);\n\n try {\n let sandbox: CodesandboxSandbox;\n let sandboxId: string;\n\n if (options?.sandboxId) {\n // Resume existing CodeSandbox using sdk.sandboxes.resume()\n sandbox = await sdk.sandboxes.resume(options.sandboxId);\n sandboxId = options.sandboxId;\n } else {\n // Create new CodeSandbox using sdk.sandboxes.create()\n const createOptions: any = {};\n \n if (config.templateId) {\n createOptions.id = config.templateId;\n }\n\n sandbox = await sdk.sandboxes.create(createOptions);\n sandboxId = sandbox.id;\n }\n\n return {\n sandbox,\n sandboxId\n };\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('unauthorized') || error.message.includes('API key')) {\n throw new Error(\n `CodeSandbox authentication failed. Please check your CSB_API_KEY environment variable. Get your API key from https://codesandbox.io/t/api`\n );\n }\n if (error.message.includes('quota') || error.message.includes('limit')) {\n throw new Error(\n `CodeSandbox quota exceeded. Please check your usage at https://codesandbox.io/dashboard`\n );\n }\n }\n throw new Error(\n `Failed to create CodeSandbox sandbox: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n getById: async (config: CodesandboxConfig, sandboxId: string) => {\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.CSB_API_KEY) || '';\n\n if (!apiKey) {\n throw new Error(\n `Missing CodeSandbox API key. Provide 'apiKey' in config or set CSB_API_KEY environment variable.`\n );\n }\n\n const sdk = new CodeSandbox(apiKey);\n\n try {\n // Resume existing sandbox using sdk.sandboxes.resume()\n const sandbox = await sdk.sandboxes.resume(sandboxId);\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 list: async (_config: CodesandboxConfig) => {\n throw new Error(\n `CodeSandbox provider does not support listing sandboxes. CodeSandbox SDK does not provide a native list API. Consider using the CodeSandbox dashboard or implement your own tracking system.`\n );\n },\n\n destroy: async (config: CodesandboxConfig, sandboxId: string) => {\n const apiKey = config.apiKey || (typeof process !== 'undefined' && process.env?.CSB_API_KEY) || '';\n\n if (!apiKey) {\n throw new Error(\n `Missing CodeSandbox API key. Provide 'apiKey' in config or set CSB_API_KEY environment variable.`\n );\n }\n\n const sdk = new CodeSandbox(apiKey);\n\n try {\n // Shutdown the sandbox using sdk.sandboxes.shutdown() to clean it up\n await sdk.sandboxes.shutdown(sandboxId);\n } catch (error) {\n // Sandbox might already be shutdown or doesn't exist\n // This is acceptable for destroy operations\n }\n },\n\n // Instance operations (sandbox.*)\n runCode: async (sandbox: CodesandboxSandbox, code: string, runtime?: Runtime): Promise<CodeResult> => {\n const startTime = Date.now();\n\n try {\n // Connect to the sandbox client using sandbox.connect()\n const client = await sandbox.connect();\n\n // Auto-detect runtime if not specified\n const effectiveRuntime = runtime || (\n // Strong Python indicators\n code.includes('print(') || \n code.includes('import ') ||\n code.includes('def ') ||\n code.includes('sys.') ||\n code.includes('json.') ||\n code.includes('__') ||\n code.includes('f\"') ||\n code.includes(\"f'\") ||\n code.includes('raise ')\n ? 'python'\n // Default to Node.js for all other cases (including ambiguous)\n : 'node'\n );\n\n // Use base64 encoding for reliability and consistency\n const encoded = Buffer.from(code).toString('base64');\n let command: string;\n\n if (effectiveRuntime === 'python') {\n // Execute Python code using client.commands.run()\n command = `echo \"${encoded}\" | base64 -d | python3`;\n } else {\n // Execute Node.js code using client.commands.run()\n command = `echo \"${encoded}\" | base64 -d | node`;\n }\n\n // Execute the command using CodeSandbox client.commands.run()\n // This returns the full output as a string\n const output = await client.commands.run(command);\n\n // Check for syntax errors in the output and throw them (similar to other providers)\n if (output.includes('SyntaxError') ||\n output.includes('invalid syntax') ||\n output.includes('Unexpected token') ||\n output.includes('Unexpected identifier')) {\n throw new Error(`Syntax error: ${output.trim()}`);\n }\n\n return {\n output: output,\n exitCode: 0,\n language: effectiveRuntime\n };\n } catch (error) {\n // Re-throw syntax errors\n if (error instanceof Error && error.message.includes('Syntax error')) {\n throw error;\n }\n throw new Error(\n `CodeSandbox execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n runCommand: async (sandbox: CodesandboxSandbox, command: string, args: string[] = []): Promise<CommandResult> => {\n const startTime = Date.now();\n\n try {\n // Connect to the sandbox client using sandbox.connect()\n const client = await sandbox.connect();\n\n // Construct full command with arguments, properly quoting each arg\n const quotedArgs = args.map((arg: string) => {\n if (arg.includes(' ') || arg.includes('\"') || arg.includes(\"'\") || arg.includes('$') || arg.includes('`')) {\n return `\"${arg.replace(/\"/g, '\\\\\"')}\"`;\n }\n return arg;\n });\n const fullCommand = quotedArgs.length > 0 ? `${command} ${quotedArgs.join(' ')}` : command;\n\n // Execute command using CodeSandbox client.commands.run()\n const output = await client.commands.run(fullCommand);\n\n return {\n stdout: output,\n stderr: '',\n exitCode: 0,\n durationMs: Date.now() - startTime\n };\n } catch (error) {\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 getInfo: async (sandbox: CodesandboxSandbox): Promise<SandboxInfo> => {\n return {\n id: sandbox.id,\n provider: 'codesandbox',\n runtime: 'node', // CodeSandbox default\n status: 'running',\n createdAt: new Date(),\n timeout: 300000,\n metadata: {\n cluster: sandbox.cluster,\n bootupType: sandbox.bootupType,\n isUpToDate: sandbox.isUpToDate\n }\n };\n },\n\n getUrl: async (sandbox: CodesandboxSandbox, options: { port: number; protocol?: string }): Promise<string> => {\n const protocol = options.protocol || 'https';\n // CodeSandbox provides URLs in the format: https://{sandbox-id}.{cluster}.csb.app:{port}\n // Use the actual CodeSandbox URL format\n return `${protocol}://${sandbox.id}.${sandbox.cluster}.csb.app:${options.port}`;\n },\n\n // Filesystem operations using CodeSandbox client.fs API\n filesystem: {\n readFile: async (sandbox: CodesandboxSandbox, path: string): Promise<string> => {\n // Connect to the sandbox client and use client.fs.readTextFile()\n const client = await sandbox.connect();\n return await client.fs.readTextFile(path);\n },\n\n writeFile: async (sandbox: CodesandboxSandbox, path: string, content: string): Promise<void> => {\n // Connect to the sandbox client and use client.fs.writeTextFile()\n const client = await sandbox.connect();\n await client.fs.writeTextFile(path, content);\n },\n\n mkdir: async (sandbox: CodesandboxSandbox, path: string): Promise<void> => {\n // CodeSandbox doesn't have a direct mkdir API, use commands to create directory\n const client = await sandbox.connect();\n await client.commands.run(`mkdir -p \"${path}\"`);\n },\n\n readdir: async (sandbox: CodesandboxSandbox, path: string): Promise<FileEntry[]> => {\n // Connect to the sandbox client and use client.fs.readdir()\n const client = await sandbox.connect();\n const entries = await client.fs.readdir(path);\n\n return entries.map((entry: any) => ({\n name: entry.name,\n path: `${path}/${entry.name}`.replace(/\\/+/g, '/'),\n isDirectory: entry.isDirectory || false,\n size: entry.size || 0,\n lastModified: entry.lastModified ? new Date(entry.lastModified) : new Date()\n }));\n },\n\n exists: async (sandbox: CodesandboxSandbox, path: string): Promise<boolean> => {\n // CodeSandbox doesn't have a direct exists API, use ls command to check\n const client = await sandbox.connect();\n try {\n await client.commands.run(`ls \"${path}\"`);\n return true;\n } catch {\n return false;\n }\n },\n\n remove: async (sandbox: CodesandboxSandbox, path: string): Promise<void> => {\n // Connect to the sandbox client and use client.fs.remove()\n const client = await sandbox.connect();\n await client.fs.remove(path);\n }\n },\n\n // Provider-specific typed getInstance method\n getInstance: (sandbox: CodesandboxSandbox): CodesandboxSandbox => {\n return sandbox;\n },\n\n }\n }\n});\n"],"mappings":";AAMA,SAAS,mBAAmB;AAE5B,SAAS,sBAAsB;AAoBxB,IAAM,cAAc,eAAsD;AAAA,EAC/E,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA;AAAA,MAEP,QAAQ,OAAO,QAA2B,YAAmC;AAE3E,cAAM,SAAS,OAAO,UAAW,OAAO,YAAY,eAAe,QAAQ,KAAK,eAAgB;AAEhG,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAEA,cAAM,MAAM,IAAI,YAAY,MAAM;AAElC,YAAI;AACF,cAAI;AACJ,cAAI;AAEJ,cAAI,SAAS,WAAW;AAEtB,sBAAU,MAAM,IAAI,UAAU,OAAO,QAAQ,SAAS;AACtD,wBAAY,QAAQ;AAAA,UACtB,OAAO;AAEL,kBAAM,gBAAqB,CAAC;AAE5B,gBAAI,OAAO,YAAY;AACrB,4BAAc,KAAK,OAAO;AAAA,YAC5B;AAEA,sBAAU,MAAM,IAAI,UAAU,OAAO,aAAa;AAClD,wBAAY,QAAQ;AAAA,UACtB;AAEA,iBAAO;AAAA,YACL;AAAA,YACA;AAAA,UACF;AAAA,QACF,SAAS,OAAO;AACd,cAAI,iBAAiB,OAAO;AAC1B,gBAAI,MAAM,QAAQ,SAAS,cAAc,KAAK,MAAM,QAAQ,SAAS,SAAS,GAAG;AAC/E,oBAAM,IAAI;AAAA,gBACR;AAAA,cACF;AAAA,YACF;AACA,gBAAI,MAAM,QAAQ,SAAS,OAAO,KAAK,MAAM,QAAQ,SAAS,OAAO,GAAG;AAC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AA,QAC7C;AAAA,QAEA,OAAO,OAAO,SAA6B,SAAgC;AAEzE,gBAAM,SAAS,MAAM,QAAQ,QAAQ;AACrC,gBAAM,OAAO,SAAS,IAAI,aAAa,IAAI,GAAG;AAAA,QAChD;AAAA,QAEA,SAAS,OAAO,SAA6B,SAAuC;AAElF,gBAAM,SAAS,MAAM,QAAQ,QAAQ;AACrC,gBAAM,UAAU,MAAM,OAAO,GAAG,QAAQ,IAAI;AAE5C,iBAAO,QAAQ,IAAI,CAAC,WAAgB;AAAA,YAClC,MAAM,MAAM;AAAA,YACZ,MAAM,GAAG,IAAI,IAAI,MAAM,IAAI,GAAG,QAAQ,QAAQ,GAAG;AAAA,YACjD,aAAa,MAAM,eAAe;AAAA,YAClC,MAAM,MAAM,QAAQ;AAAA,YACpB,cAAc,MAAM,eAAe,IAAI,KAAK,MAAM,YAAY,IAAI,oBAAI,KAAK;AAAA,UAC7E,EAAE;AAAA,QACJ;AAAA,QAEA,QAAQ,OAAO,SAA6B,SAAmC;AAE7E,gBAAM,SAAS,MAAM,QAAQ,QAAQ;AACrC,cAAI;AACF,kBAAM,OAAO,SAAS,IAAI,OAAO,IAAI,GAAG;AACxC,mBAAO;AAAA,UACT,QAAQ;AACN,mBAAO;AAAA,UACT;AAAA,QACF;AAAA,QAEA,QAAQ,OAAO,SAA6B,SAAgC;AAE1E,gBAAM,SAAS,MAAM,QAAQ,QAAQ;AACrC,gBAAM,OAAO,GAAG,OAAO,IAAI;AAAA,QAC7B;AAAA,MACF;AAAA;AAAA,MAGA,aAAa,CAAC,YAAoD;AAChE,eAAO;AAAA,MACT;AAAA,IAEF;AAAA,EACF;AACF,CAAC;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@computesdk/codesandbox",
3
- "version": "1.4.7",
3
+ "version": "1.5.0",
4
4
  "description": "CodeSandbox provider for ComputeSDK",
5
5
  "author": "Garrison",
6
6
  "license": "MIT",
@@ -19,7 +19,7 @@
19
19
  ],
20
20
  "dependencies": {
21
21
  "@codesandbox/sdk": "^2.0.7",
22
- "computesdk": "1.8.7"
22
+ "computesdk": "1.9.0"
23
23
  },
24
24
  "keywords": [
25
25
  "codesandbox",