@computesdk/runloop 1.3.36 → 1.3.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -39,7 +39,7 @@ var runloop = (0, import_provider.defineProvider)({
39
39
  }
40
40
  const timeout = config.timeout;
41
41
  try {
42
- const client = new import_api_client.Runloop({
42
+ const client = new import_api_client.RunloopSDK({
43
43
  bearerToken: apiKey
44
44
  });
45
45
  let devboxParams = {
@@ -59,7 +59,9 @@ var runloop = (0, import_provider.defineProvider)({
59
59
  } else {
60
60
  }
61
61
  }
62
- const dbx = await client.devboxes.createAndAwaitRunning(devboxParams);
62
+ const dbx = await client.api.devboxes.createAndAwaitRunning(
63
+ devboxParams
64
+ );
63
65
  const runloopSandbox = {
64
66
  ...dbx,
65
67
  // Spread all DevboxView properties
@@ -79,10 +81,10 @@ var runloop = (0, import_provider.defineProvider)({
79
81
  getById: async (config, sandboxId) => {
80
82
  const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
81
83
  try {
82
- const client = new import_api_client.Runloop({
84
+ const client = new import_api_client.RunloopSDK({
83
85
  bearerToken: apiKey
84
86
  });
85
- const devbox = await client.devboxes.retrieve(sandboxId);
87
+ const devbox = await client.api.devboxes.retrieve(sandboxId);
86
88
  return {
87
89
  sandbox: devbox,
88
90
  sandboxId
@@ -94,10 +96,10 @@ var runloop = (0, import_provider.defineProvider)({
94
96
  list: async (config) => {
95
97
  const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
96
98
  try {
97
- const client = new import_api_client.Runloop({
99
+ const client = new import_api_client.RunloopSDK({
98
100
  bearerToken: apiKey
99
101
  });
100
- const response = await client.devboxes.list();
102
+ const response = await client.api.devboxes.list();
101
103
  const devboxes = response.devboxes || [];
102
104
  return devboxes.map((devbox) => ({
103
105
  sandbox: devbox,
@@ -110,10 +112,10 @@ var runloop = (0, import_provider.defineProvider)({
110
112
  destroy: async (config, sandboxId) => {
111
113
  const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
112
114
  try {
113
- const client = new import_api_client.Runloop({
115
+ const client = new import_api_client.RunloopSDK({
114
116
  bearerToken: apiKey
115
117
  });
116
- await client.devboxes.shutdown(sandboxId);
118
+ await client.api.devboxes.shutdown(sandboxId);
117
119
  } catch (error) {
118
120
  }
119
121
  },
@@ -132,13 +134,9 @@ var runloop = (0, import_provider.defineProvider)({
132
134
  } else {
133
135
  command = `echo "${encoded}" | base64 -d | node`;
134
136
  }
135
- const execution = await client.devboxes.executeAsync(devbox.id, {
137
+ const executionResult = await client.api.devboxes.executeAndAwaitCompletion(devbox.id, {
136
138
  command
137
139
  });
138
- const executionResult = await client.devboxes.executions.awaitCompleted(
139
- devbox.id,
140
- execution.execution_id
141
- );
142
140
  if (executionResult.exit_status !== 0 && executionResult.stderr) {
143
141
  if (executionResult.stderr.includes("SyntaxError") || executionResult.stderr.includes("invalid syntax") || executionResult.stderr.includes("Unexpected token") || executionResult.stderr.includes("Unexpected identifier")) {
144
142
  throw new Error(`Syntax error: ${executionResult.stderr.trim()}`);
@@ -188,13 +186,9 @@ var runloop = (0, import_provider.defineProvider)({
188
186
  if (options?.background) {
189
187
  fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;
190
188
  }
191
- const execution = await client.devboxes.executeAsync(devbox.id, {
189
+ const executionResult = await client.api.devboxes.executeAndAwaitCompletion(devbox.id, {
192
190
  command: fullCommand
193
191
  });
194
- const executionResult = await client.devboxes.executions.awaitCompleted(
195
- devbox.id,
196
- execution.execution_id
197
- );
198
192
  return {
199
193
  stdout: executionResult.stdout || "",
200
194
  stderr: executionResult.stderr || "",
@@ -231,7 +225,7 @@ var runloop = (0, import_provider.defineProvider)({
231
225
  const devbox = sandbox;
232
226
  const client = sandbox.client;
233
227
  try {
234
- const tunnel = await client.devboxes.createTunnel(devbox.id, {
228
+ const tunnel = await client.api.devboxes.createTunnel(devbox.id, {
235
229
  port: options.port
236
230
  });
237
231
  return tunnel.url;
@@ -323,10 +317,10 @@ var runloop = (0, import_provider.defineProvider)({
323
317
  );
324
318
  }
325
319
  try {
326
- const client = new import_api_client.Runloop({
320
+ const client = new import_api_client.RunloopSDK({
327
321
  bearerToken: apiKey
328
322
  });
329
- const blueprint = await client.blueprints.create(options);
323
+ const blueprint = await client.api.blueprints.create(options);
330
324
  return blueprint;
331
325
  } catch (error) {
332
326
  throw new Error(
@@ -342,14 +336,14 @@ var runloop = (0, import_provider.defineProvider)({
342
336
  );
343
337
  }
344
338
  try {
345
- const client = new import_api_client.Runloop({
339
+ const client = new import_api_client.RunloopSDK({
346
340
  bearerToken: apiKey
347
341
  });
348
342
  const listParams = {};
349
343
  if (options?.limit) {
350
344
  listParams.limit = options.limit;
351
345
  }
352
- const response = await client.blueprints.list(listParams);
346
+ const response = await client.api.blueprints.list(listParams);
353
347
  return response.blueprints || [];
354
348
  } catch (error) {
355
349
  throw new Error(
@@ -365,10 +359,10 @@ var runloop = (0, import_provider.defineProvider)({
365
359
  );
366
360
  }
367
361
  try {
368
- const client = new import_api_client.Runloop({
362
+ const client = new import_api_client.RunloopSDK({
369
363
  bearerToken: apiKey
370
364
  });
371
- await client.blueprints.delete(blueprintId);
365
+ await client.api.blueprints.delete(blueprintId);
372
366
  } catch (error) {
373
367
  throw new Error(
374
368
  `Failed to delete blueprint template ${blueprintId}: ${error instanceof Error ? error.message : String(error)}`
@@ -384,7 +378,7 @@ var runloop = (0, import_provider.defineProvider)({
384
378
  throw new Error("Missing Runloop API key for snapshot creation");
385
379
  }
386
380
  try {
387
- const client = new import_api_client.Runloop({
381
+ const client = new import_api_client.RunloopSDK({
388
382
  bearerToken: apiKey
389
383
  });
390
384
  const snapshotParams = {};
@@ -394,7 +388,7 @@ var runloop = (0, import_provider.defineProvider)({
394
388
  if (options?.metadata) {
395
389
  snapshotParams.metadata = options.metadata;
396
390
  }
397
- const snapshot = await client.devboxes.snapshotDisk(
391
+ const snapshot = await client.api.devboxes.snapshotDisk(
398
392
  sandboxId,
399
393
  snapshotParams
400
394
  );
@@ -411,14 +405,14 @@ var runloop = (0, import_provider.defineProvider)({
411
405
  throw new Error("Missing Runloop API key for listing snapshots");
412
406
  }
413
407
  try {
414
- const client = new import_api_client.Runloop({
408
+ const client = new import_api_client.RunloopSDK({
415
409
  bearerToken: apiKey
416
410
  });
417
411
  const listParams = {};
418
412
  if (options?.limit) {
419
413
  listParams.limit = options.limit;
420
414
  }
421
- const response = await client.devboxes.listDiskSnapshots(listParams);
415
+ const response = await client.api.devboxes.listDiskSnapshots(listParams);
422
416
  return response.snapshots || [];
423
417
  } catch (error) {
424
418
  throw new Error(
@@ -432,10 +426,10 @@ var runloop = (0, import_provider.defineProvider)({
432
426
  throw new Error("Missing Runloop API key for snapshot deletion");
433
427
  }
434
428
  try {
435
- const client = new import_api_client.Runloop({
429
+ const client = new import_api_client.RunloopSDK({
436
430
  bearerToken: apiKey
437
431
  });
438
- await client.devboxes.deleteDiskSnapshot(snapshotId);
432
+ await client.api.devboxes.deleteDiskSnapshot(snapshotId);
439
433
  } catch (error) {
440
434
  throw new Error(
441
435
  `Failed to delete snapshot ${snapshotId}: ${error instanceof Error ? error.message : String(error)}`
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Runloop Provider - Factory-based Implementation\n *\n * Full-featured provider with filesystem support using the factory pattern.\n * Reduces ~400 lines of boilerplate to ~100 lines of core logic.\n */\n\nimport { Runloop } from \"@runloop/api-client\";\nimport { defineProvider, escapeShellArg } from \"@computesdk/provider\";\nimport type {\n CodeResult,\n CommandResult,\n SandboxInfo,\n CreateSnapshotOptions,\n ListSnapshotsOptions,\n RunCommandOptions,\n} from \"@computesdk/provider\";\nimport type {\n CreateSandboxOptions,\n FileEntry,\n Runtime,\n SandboxStatus,\n Sandbox,\n} from \"computesdk\";\n\n// Define Runloop-specific types\ntype RunloopSnapshot = Runloop.DevboxSnapshotView;\ntype RunloopTemplate = Runloop.BlueprintView;\n\n/**\n * Runloop-specific configuration options\n */\nexport interface RunloopConfig {\n /** Runloop API key - if not provided, will fallback to RUNLOOP_API_KEY environment variable */\n apiKey?: string;\n /** Execution timeout in milliseconds */\n timeout?: number;\n}\n\n/**\n * Runloop-specific blueprint creation options\n */\nexport interface CreateBlueprintTemplateOptions {\n /** Name of the blueprint template */\n name: string;\n /** Custom Dockerfile content */\n dockerfile?: string;\n /** System setup commands to run during blueprint creation */\n systemSetupCommands?: string[];\n /** Launch commands to run when starting a devbox from this blueprint */\n launchCommands?: string[];\n /** File mounts as key-value pairs (path -> content) */\n fileMounts?: Record<string, string>;\n /** Code repository mounts */\n codeMounts?: Array<{\n repoName: string;\n repoOwner: string;\n token?: string;\n installCommand?: string;\n }>;\n /** Resource size for devboxes created from this blueprint */\n resourceSize?:\n | \"X_SMALL\"\n | \"SMALL\"\n | \"MEDIUM\"\n | \"LARGE\"\n | \"X_LARGE\"\n | \"XX_LARGE\"\n | \"CUSTOM_SIZE\";\n /** CPU architecture */\n architecture?: \"x86_64\" | \"arm64\";\n /** Custom CPU cores (requires CUSTOM_SIZE) */\n customCpuCores?: number;\n /** Custom memory in GB (requires CUSTOM_SIZE) */\n customMemoryGb?: number;\n /** Custom disk size (requires CUSTOM_SIZE) */\n customDiskSize?: number;\n /** Available ports for the devbox */\n availablePorts?: number[];\n /** Action to take when devbox is idle */\n afterIdle?: { action: string; timeSeconds: number };\n /** Keep alive time in seconds */\n keepAliveTimeSeconds?: number;\n}\n\n/**\n * Create a Runloop provider instance using the factory pattern\n */\nexport const runloop = defineProvider<\n Runloop.DevboxView, // TSandbox\n RunloopConfig, // TConfig\n RunloopTemplate, // TTemplate \n RunloopSnapshot // TSnapshot\n>({\n name: \"runloop\",\n methods: {\n sandbox: {\n // Collection operations (map to compute.sandbox.*)\n create: async (config: RunloopConfig, options?: CreateSandboxOptions) => {\n // Validate API key\n const apiKey =\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.RUNLOOP_API_KEY) ||\n \"\";\n\n if (!apiKey) {\n throw new Error(\n `Missing Runloop API key. Provide 'apiKey' in config or set RUNLOOP_API_KEY environment variable. Get your API key from https://runloop.ai/`\n );\n }\n\n const timeout = config.timeout;\n\n try {\n const client = new Runloop({\n bearerToken: apiKey,\n });\n\n let devboxParams: Runloop.DevboxCreateParams = {\n launch_parameters: {\n keep_alive_time_seconds: timeout || options?.timeout || 1800,\n },\n name: options?.sandboxId,\n metadata: options?.metadata,\n environment_variables: options?.envs,\n };\n\n // Use blueprint if specified\n if (options?.templateId) {\n const templateId = options?.templateId;\n // Check template prefix to determine parameter type\n if (templateId?.startsWith(\"bpt_\")) {\n devboxParams.blueprint_id = templateId;\n } else if (templateId?.startsWith(\"snp_\")) {\n devboxParams.snapshot_id = templateId;\n } else {\n // empty\n }\n }\n\n const dbx = await client.devboxes.createAndAwaitRunning(devboxParams);\n\n // Create a RunloopSandbox object that contains both devbox and client\n const runloopSandbox = {\n ...dbx, // Spread all DevboxView properties\n client: client // Add client for method access\n };\n\n return {\n sandbox: runloopSandbox,\n sandboxId: dbx.id,\n };\n } catch (error) {\n throw new Error(\n `Failed to create Runloop devbox: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n getById: async (config: RunloopConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new Runloop({\n bearerToken: apiKey,\n });\n\n const devbox = await client.devboxes.retrieve(sandboxId);\n\n return {\n sandbox: devbox,\n sandboxId,\n };\n } catch (error) {\n // Devbox doesn't exist or can't be accessed\n return null;\n }\n },\n\n list: async (config: RunloopConfig) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new Runloop({\n bearerToken: apiKey,\n });\n\n const response = await client.devboxes.list();\n const devboxes = response.devboxes || [];\n\n return devboxes.map((devbox) => ({\n sandbox: devbox,\n sandboxId: devbox.id,\n }));\n } catch (error) {\n // Return empty array if listing fails\n return [];\n }\n },\n\n destroy: async (config: RunloopConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new Runloop({\n bearerToken: apiKey,\n });\n\n await client.devboxes.shutdown(sandboxId);\n } catch (error) {\n // Devbox might already be destroyed or doesn't exist\n // This is acceptable for destroy operations\n }\n },\n\n // Instance operations (map to individual Sandbox methods)\n runCode: async (sandbox: any, code: string, runtime?: Runtime): Promise<CodeResult> => {\n const startTime = Date.now();\n const devbox = sandbox;\n const client = sandbox.client;\n\n // Auto-detect runtime if not specified\n const effectiveRuntime: Runtime = 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 ) as Runtime;\n\n try {\n\n // Use base64 encoding for both runtimes for reliability and consistency\n const encoded = Buffer.from(code).toString('base64');\n\n let command;\n if (effectiveRuntime === 'python') {\n command = `echo \"${encoded}\" | base64 -d | python3`;\n } else {\n command = `echo \"${encoded}\" | base64 -d | node`;\n }\n\n // Execute code using Runloop's executeAsync\n const execution = await client.devboxes.executeAsync(devbox.id, {\n command: command,\n });\n\n const executionResult = await client.devboxes.executions.awaitCompleted(\n devbox.id,\n execution.execution_id\n );\n\n // Check for syntax errors and throw them (similar to Vercel behavior)\n if (executionResult.exit_status !== 0 && executionResult.stderr) {\n // Check for common syntax error patterns\n if (executionResult.stderr.includes('SyntaxError') ||\n executionResult.stderr.includes('invalid syntax') ||\n executionResult.stderr.includes('Unexpected token') ||\n executionResult.stderr.includes('Unexpected identifier')) {\n throw new Error(`Syntax error: ${executionResult.stderr.trim()}`);\n }\n }\n\n return {\n output: (executionResult.stdout || \"\") + (executionResult.stderr || \"\"),\n exitCode: executionResult.exit_status || 0,\n language: effectiveRuntime,\n };\n } catch (error) {\n // Handle Runloop execution errors\n if (error instanceof Error && error.message === 'exit status 1') {\n const actualStderr = (error as any)?.result?.stderr || '';\n const isSyntaxError = actualStderr.includes('SyntaxError');\n\n if (isSyntaxError) {\n // For syntax errors, throw\n const syntaxErrorLine = actualStderr.split('\\n').find((line: string) => line.includes('SyntaxError')) || 'SyntaxError: Invalid syntax in code';\n throw new Error(`Syntax error: ${syntaxErrorLine}`);\n } else {\n // For runtime errors, return a result instead of throwing\n return {\n output: actualStderr || 'Error: Runtime error occurred during execution',\n exitCode: 1,\n language: effectiveRuntime,\n };\n }\n }\n\n // Re-throw syntax errors\n if (error instanceof Error && error.message.includes('Syntax error')) {\n throw error;\n }\n throw new Error(\n `Runloop execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n runCommand: async (\n sandbox: any,\n command: string,\n options?: RunCommandOptions\n ): Promise<CommandResult> => {\n const startTime = Date.now();\n const devbox = sandbox;\n const client = sandbox.client;\n\n try {\n // Build the full 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}=\"${escapeShellArg(v)}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n\n // Handle working directory\n if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n\n // Handle background execution\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n\n const execution = await client.devboxes.executeAsync(devbox.id, {\n command: fullCommand,\n });\n\n const executionResult =\n await client.devboxes.executions.awaitCompleted(\n devbox.id,\n execution.execution_id\n );\n\n return {\n stdout: executionResult.stdout || \"\",\n stderr: executionResult.stderr || \"\",\n exitCode: executionResult.exit_status || 0,\n durationMs: Date.now() - startTime,\n };\n } catch (error) {\n // Re-throw syntax errors\n if (\n error instanceof Error &&\n error.message.includes(\"Syntax error\")\n ) {\n throw error;\n }\n throw new Error(\n `Runloop execution failed: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n getInfo: async (sandbox): Promise<SandboxInfo> => {\n const devbox = sandbox;\n\n return {\n id: devbox.id || \"runloop-unknown\",\n provider: \"runloop\",\n runtime: \"node\" as Runtime, // Runloop supports multiple runtimes, defaulting to node\n status: devbox.status as SandboxStatus,\n createdAt: new Date(devbox.create_time_ms || Date.now()),\n timeout: devbox.launch_parameters.keep_alive_time_seconds || 300000,\n metadata: {\n runloopDevboxId: devbox.id,\n templateId: devbox.blueprint_id || devbox.snapshot_id,\n ...devbox.metadata,\n },\n };\n },\n\n getUrl: async (\n sandbox: any,\n options: { port: number }\n ): Promise<string> => {\n const devbox = sandbox;\n const client = sandbox.client;\n\n try {\n const tunnel = await client.devboxes.createTunnel(devbox.id, {\n port: options.port,\n });\n\n return tunnel.url;\n } catch (error) {\n throw new Error(\n `Failed to get Runloop URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n // Optional filesystem methods - using Runloop's file operations\n filesystem: {\n readFile: async (sandbox: any, path: string, runCommand: any): Promise<string> => {\n try {\n const result = await runCommand(sandbox, `cat \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`File not found or unreadable: ${result.stderr}`);\n }\n return result.stdout;\n } catch (error) {\n throw new Error(\n `Failed to read file ${path}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n writeFile: async (\n sandbox: any,\n path: string,\n content: string,\n runCommand: any\n ): Promise<void> => {\n try {\n // Use command-based approach for file writing since API writeFileContents may have issues\n const encoded = Buffer.from(content).toString('base64');\n const result = await runCommand(sandbox, `sh -c 'echo \"${encoded}\" | base64 -d > \"${path}\"'`);\n\n if (result.exitCode !== 0) {\n throw new Error(`Command failed: ${result.stderr}`);\n }\n } catch (error) {\n throw new Error(\n `Failed to write file ${path}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n mkdir: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<void> => {\n const result = await runCommand(sandbox, `mkdir -p \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(\n `Failed to create directory ${path}: ${result.stderr}`\n );\n }\n },\n\n readdir: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<FileEntry[]> => {\n const result = await runCommand(sandbox, `ls -la \"${path}\"`);\n\n if (result.exitCode !== 0) {\n throw new Error(\n `Failed to list directory ${path}: ${result.stderr}`\n );\n }\n\n const lines = (result.stdout || \"\")\n .split(\"\\n\")\n .filter((line: string) => line.trim() && !line.startsWith(\"total\"));\n\n return lines.map((line: string) => {\n const parts = line.trim().split(/\\s+/);\n const name = parts[parts.length - 1];\n const isDirectory = line.startsWith(\"d\");\n\n return {\n name,\n type: isDirectory ? 'directory' as const : 'file' as const,\n size: parseInt(parts[4]) || 0,\n modified: new Date(),\n };\n });\n },\n\n exists: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<boolean> => {\n const result = await runCommand(sandbox, `test -e \"${path}\"`);\n return result.exitCode === 0;\n },\n\n remove: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<void> => {\n const result = await runCommand(sandbox, `rm -rf \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to remove ${path}: ${result.stderr}`);\n }\n },\n },\n\n // Provider-specific typed getInstance method\n getInstance: (sandbox): Runloop.DevboxView => {\n return sandbox;\n },\n },\n\n // Template management methods using the new factory pattern\n template: {\n create: async (\n config: RunloopConfig,\n options: CreateBlueprintTemplateOptions | Runloop.BlueprintCreateParams\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for blueprint template creation\"\n );\n }\n\n try {\n const client = new Runloop({\n bearerToken: apiKey,\n });\n\n const blueprint = await client.blueprints.create(options);\n return blueprint;\n } catch (error) {\n throw new Error(\n `Failed to create blueprint template: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n list: async (config: RunloopConfig, options?: { limit?: number }) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for listing blueprint templates\"\n );\n }\n\n try {\n const client = new Runloop({\n bearerToken: apiKey,\n });\n\n const listParams: any = {};\n if (options?.limit) {\n listParams.limit = options.limit;\n }\n\n const response = await client.blueprints.list(listParams);\n return response.blueprints || [];\n } catch (error) {\n throw new Error(\n `Failed to list blueprint templates: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n delete: async (config: RunloopConfig, blueprintId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for blueprint template deletion\"\n );\n }\n\n try {\n const client = new Runloop({\n bearerToken: apiKey,\n });\n\n await client.blueprints.delete(blueprintId);\n } catch (error) {\n throw new Error(\n `Failed to delete blueprint template ${blueprintId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n },\n\n // Snapshot management methods using the new factory pattern\n snapshot: {\n create: async (\n config: RunloopConfig,\n sandboxId: string,\n options?: CreateSnapshotOptions\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for snapshot creation\");\n }\n\n try {\n const client = new Runloop({\n bearerToken: apiKey,\n });\n\n const snapshotParams: any = {};\n if (options?.name) {\n snapshotParams.name = options.name;\n }\n if (options?.metadata) {\n snapshotParams.metadata = options.metadata;\n }\n\n const snapshot = await client.devboxes.snapshotDisk(\n sandboxId,\n snapshotParams\n );\n return snapshot;\n } catch (error) {\n throw new Error(\n `Failed to create snapshot for sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n list: async (\n config: RunloopConfig,\n options?: ListSnapshotsOptions\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for listing snapshots\");\n }\n\n try {\n const client = new Runloop({\n bearerToken: apiKey,\n });\n\n const listParams: any = {};\n if (options?.limit) {\n listParams.limit = options.limit;\n }\n\n const response = await client.devboxes.listDiskSnapshots(listParams);\n return response.snapshots || [];\n } catch (error) {\n throw new Error(\n `Failed to list snapshots: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n delete: async (config: RunloopConfig, snapshotId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for snapshot deletion\");\n }\n\n try {\n const client = new Runloop({\n bearerToken: apiKey,\n });\n\n await client.devboxes.deleteDiskSnapshot(snapshotId);\n } catch (error) {\n throw new Error(\n `Failed to delete snapshot ${snapshotId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n },\n },\n});"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,wBAAwB;AACxB,sBAA+C;AAgFxC,IAAM,cAAU,gCAKrB;AAAA,EACA,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA;AAAA,MAEP,QAAQ,OAAO,QAAuB,YAAmC;AAEvE,cAAM,SACJ,OAAO,UACN,OAAO,YAAY,eAAe,QAAQ,KAAK,mBAChD;AAEF,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAEA,cAAM,UAAU,OAAO;AAEvB,YAAI;AACF,gBAAM,SAAS,IAAI,0BAAQ;AAAA,YACzB,aAAa;AAAA,UACf,CAAC;AAED,cAAI,eAA2C;AAAA,YAC7C,mBAAmB;AAAA,cACjB,yBAAyB,WAAW,SAAS,WAAW;AAAA,YAC1D;AAAA,YACA,MAAM,SAAS;AAAA,YACf,UAAU,SAAS;AAAA,YACnB,uBAAuB,SAAS;AAAA,UAClC;AAGA,cAAI,SAAS,YAAY;AACvB,kBAAM,aAAa,SAAS;AAE5B,gBAAI,YAAY,WA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BAA6B,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAClF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,MAEA,QAAQ,OAAO,QAAuB,eAAuB;AAC3D,cAAM,SAAS,OAAO,UAAU,QAAQ,IAAI;AAE5C,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI,MAAM,+CAA+C;AAAA,QACjE;AAEA,YAAI;AACF,gBAAM,SAAS,IAAI,0BAAQ;AAAA,YACzB,aAAa;AAAA,UACf,CAAC;AAED,gBAAM,OAAO,SAAS,mBAAmB,UAAU;AAAA,QACrD,SAAS,OAAO;AACd,gBAAM,IAAI;AAAA,YACR,6BAA6B,UAAU,KAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CACjG;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Runloop Provider - Factory-based Implementation\n *\n * Full-featured provider with filesystem support using the factory pattern.\n * Reduces ~400 lines of boilerplate to ~100 lines of core logic.\n */\n\nimport { RunloopSDK, type Runloop } from \"@runloop/api-client\";\nimport { defineProvider, escapeShellArg } from \"@computesdk/provider\";\nimport type {\n CodeResult,\n CommandResult,\n SandboxInfo,\n CreateSnapshotOptions,\n ListSnapshotsOptions,\n RunCommandOptions,\n} from \"@computesdk/provider\";\nimport type {\n CreateSandboxOptions,\n FileEntry,\n Runtime,\n SandboxStatus,\n Sandbox,\n} from \"computesdk\";\n\n// Define Runloop-specific types\ntype RunloopSnapshot = Runloop.DevboxSnapshotView;\ntype RunloopTemplate = Runloop.BlueprintView;\n\n/**\n * Runloop-specific configuration options\n */\nexport interface RunloopConfig {\n /** Runloop API key - if not provided, will fallback to RUNLOOP_API_KEY environment variable */\n apiKey?: string;\n /** Execution timeout in milliseconds */\n timeout?: number;\n}\n\n/**\n * Runloop-specific blueprint creation options\n */\nexport interface CreateBlueprintTemplateOptions {\n /** Name of the blueprint template */\n name: string;\n /** Custom Dockerfile content */\n dockerfile?: string;\n /** System setup commands to run during blueprint creation */\n systemSetupCommands?: string[];\n /** Launch commands to run when starting a devbox from this blueprint */\n launchCommands?: string[];\n /** File mounts as key-value pairs (path -> content) */\n fileMounts?: Record<string, string>;\n /** Code repository mounts */\n codeMounts?: Array<{\n repoName: string;\n repoOwner: string;\n token?: string;\n installCommand?: string;\n }>;\n /** Resource size for devboxes created from this blueprint */\n resourceSize?:\n | \"X_SMALL\"\n | \"SMALL\"\n | \"MEDIUM\"\n | \"LARGE\"\n | \"X_LARGE\"\n | \"XX_LARGE\"\n | \"CUSTOM_SIZE\";\n /** CPU architecture */\n architecture?: \"x86_64\" | \"arm64\";\n /** Custom CPU cores (requires CUSTOM_SIZE) */\n customCpuCores?: number;\n /** Custom memory in GB (requires CUSTOM_SIZE) */\n customMemoryGb?: number;\n /** Custom disk size (requires CUSTOM_SIZE) */\n customDiskSize?: number;\n /** Available ports for the devbox */\n availablePorts?: number[];\n /** Action to take when devbox is idle */\n afterIdle?: { action: string; timeSeconds: number };\n /** Keep alive time in seconds */\n keepAliveTimeSeconds?: number;\n}\n\n/**\n * Create a Runloop provider instance using the factory pattern\n */\nexport const runloop = defineProvider<\n Runloop.DevboxView, // TSandbox\n RunloopConfig, // TConfig\n RunloopTemplate, // TTemplate \n RunloopSnapshot // TSnapshot\n>({\n name: \"runloop\",\n methods: {\n sandbox: {\n // Collection operations (map to compute.sandbox.*)\n create: async (config: RunloopConfig, options?: CreateSandboxOptions) => {\n // Validate API key\n const apiKey =\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.RUNLOOP_API_KEY) ||\n \"\";\n\n if (!apiKey) {\n throw new Error(\n `Missing Runloop API key. Provide 'apiKey' in config or set RUNLOOP_API_KEY environment variable. Get your API key from https://runloop.ai/`\n );\n }\n\n const timeout = config.timeout;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n let devboxParams: Runloop.DevboxCreateParams = {\n launch_parameters: {\n keep_alive_time_seconds: timeout || options?.timeout || 1800,\n },\n name: options?.sandboxId,\n metadata: options?.metadata,\n environment_variables: options?.envs,\n };\n\n // Use blueprint if specified\n if (options?.templateId) {\n const templateId = options?.templateId;\n // Check template prefix to determine parameter type\n if (templateId?.startsWith(\"bpt_\")) {\n devboxParams.blueprint_id = templateId;\n } else if (templateId?.startsWith(\"snp_\")) {\n devboxParams.snapshot_id = templateId;\n } else {\n // empty\n }\n }\n\n const dbx = await client.api.devboxes.createAndAwaitRunning(\n devboxParams,\n );\n\n // Create a RunloopSandbox object that contains both devbox and client\n const runloopSandbox = {\n ...dbx, // Spread all DevboxView properties\n client: client // Add client for method access\n };\n\n return {\n sandbox: runloopSandbox,\n sandboxId: dbx.id,\n };\n } catch (error) {\n throw new Error(\n `Failed to create Runloop devbox: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n getById: async (config: RunloopConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const devbox = await client.api.devboxes.retrieve(sandboxId);\n\n return {\n sandbox: devbox,\n sandboxId,\n };\n } catch (error) {\n // Devbox doesn't exist or can't be accessed\n return null;\n }\n },\n\n list: async (config: RunloopConfig) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const response = await client.api.devboxes.list();\n const devboxes = response.devboxes || [];\n\n return devboxes.map((devbox) => ({\n sandbox: devbox,\n sandboxId: devbox.id,\n }));\n } catch (error) {\n // Return empty array if listing fails\n return [];\n }\n },\n\n destroy: async (config: RunloopConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n await client.api.devboxes.shutdown(sandboxId);\n } catch (error) {\n // Devbox might already be destroyed or doesn't exist\n // This is acceptable for destroy operations\n }\n },\n\n // Instance operations (map to individual Sandbox methods)\n runCode: async (sandbox: any, code: string, runtime?: Runtime): Promise<CodeResult> => {\n const startTime = Date.now();\n const devbox = sandbox;\n const client = sandbox.client;\n\n // Auto-detect runtime if not specified\n const effectiveRuntime: Runtime = 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 ) as Runtime;\n\n try {\n\n // Use base64 encoding for both runtimes for reliability and consistency\n const encoded = Buffer.from(code).toString('base64');\n\n let command;\n if (effectiveRuntime === 'python') {\n command = `echo \"${encoded}\" | base64 -d | python3`;\n } else {\n command = `echo \"${encoded}\" | base64 -d | node`;\n }\n\n // Execute code using Runloop's executeAsync\n const executionResult =\n await client.api.devboxes.executeAndAwaitCompletion(devbox.id, {\n command: command,\n });\n\n // Check for syntax errors and throw them (similar to Vercel behavior)\n if (executionResult.exit_status !== 0 && executionResult.stderr) {\n // Check for common syntax error patterns\n if (executionResult.stderr.includes('SyntaxError') ||\n executionResult.stderr.includes('invalid syntax') ||\n executionResult.stderr.includes('Unexpected token') ||\n executionResult.stderr.includes('Unexpected identifier')) {\n throw new Error(`Syntax error: ${executionResult.stderr.trim()}`);\n }\n }\n\n return {\n output: (executionResult.stdout || \"\") + (executionResult.stderr || \"\"),\n exitCode: executionResult.exit_status || 0,\n language: effectiveRuntime,\n };\n } catch (error) {\n // Handle Runloop execution errors\n if (error instanceof Error && error.message === 'exit status 1') {\n const actualStderr = (error as any)?.result?.stderr || '';\n const isSyntaxError = actualStderr.includes('SyntaxError');\n\n if (isSyntaxError) {\n // For syntax errors, throw\n const syntaxErrorLine = actualStderr.split('\\n').find((line: string) => line.includes('SyntaxError')) || 'SyntaxError: Invalid syntax in code';\n throw new Error(`Syntax error: ${syntaxErrorLine}`);\n } else {\n // For runtime errors, return a result instead of throwing\n return {\n output: actualStderr || 'Error: Runtime error occurred during execution',\n exitCode: 1,\n language: effectiveRuntime,\n };\n }\n }\n\n // Re-throw syntax errors\n if (error instanceof Error && error.message.includes('Syntax error')) {\n throw error;\n }\n throw new Error(\n `Runloop execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n runCommand: async (\n sandbox: any,\n command: string,\n options?: RunCommandOptions\n ): Promise<CommandResult> => {\n const startTime = Date.now();\n const devbox = sandbox;\n const client = sandbox.client;\n\n try {\n // Build the full 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}=\"${escapeShellArg(v)}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n\n // Handle working directory\n if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n\n // Handle background execution\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n\n const executionResult =\n await client.api.devboxes.executeAndAwaitCompletion(devbox.id, {\n command: fullCommand,\n });\n\n return {\n stdout: executionResult.stdout || \"\",\n stderr: executionResult.stderr || \"\",\n exitCode: executionResult.exit_status || 0,\n durationMs: Date.now() - startTime,\n };\n } catch (error) {\n // Re-throw syntax errors\n if (\n error instanceof Error &&\n error.message.includes(\"Syntax error\")\n ) {\n throw error;\n }\n throw new Error(\n `Runloop execution failed: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n getInfo: async (sandbox): Promise<SandboxInfo> => {\n const devbox = sandbox;\n\n return {\n id: devbox.id || \"runloop-unknown\",\n provider: \"runloop\",\n runtime: \"node\" as Runtime, // Runloop supports multiple runtimes, defaulting to node\n status: devbox.status as SandboxStatus,\n createdAt: new Date(devbox.create_time_ms || Date.now()),\n timeout: devbox.launch_parameters.keep_alive_time_seconds || 300000,\n metadata: {\n runloopDevboxId: devbox.id,\n templateId: devbox.blueprint_id || devbox.snapshot_id,\n ...devbox.metadata,\n },\n };\n },\n\n getUrl: async (\n sandbox: any,\n options: { port: number }\n ): Promise<string> => {\n const devbox = sandbox;\n const client = sandbox.client;\n\n try {\n const tunnel = await client.api.devboxes.createTunnel(devbox.id, {\n port: options.port,\n });\n\n return tunnel.url;\n } catch (error) {\n throw new Error(\n `Failed to get Runloop URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n // Optional filesystem methods - using Runloop's file operations\n filesystem: {\n readFile: async (sandbox: any, path: string, runCommand: any): Promise<string> => {\n try {\n const result = await runCommand(sandbox, `cat \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`File not found or unreadable: ${result.stderr}`);\n }\n return result.stdout;\n } catch (error) {\n throw new Error(\n `Failed to read file ${path}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n writeFile: async (\n sandbox: any,\n path: string,\n content: string,\n runCommand: any\n ): Promise<void> => {\n try {\n // Use command-based approach for file writing since API writeFileContents may have issues\n const encoded = Buffer.from(content).toString('base64');\n const result = await runCommand(sandbox, `sh -c 'echo \"${encoded}\" | base64 -d > \"${path}\"'`);\n\n if (result.exitCode !== 0) {\n throw new Error(`Command failed: ${result.stderr}`);\n }\n } catch (error) {\n throw new Error(\n `Failed to write file ${path}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n mkdir: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<void> => {\n const result = await runCommand(sandbox, `mkdir -p \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(\n `Failed to create directory ${path}: ${result.stderr}`\n );\n }\n },\n\n readdir: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<FileEntry[]> => {\n const result = await runCommand(sandbox, `ls -la \"${path}\"`);\n\n if (result.exitCode !== 0) {\n throw new Error(\n `Failed to list directory ${path}: ${result.stderr}`\n );\n }\n\n const lines = (result.stdout || \"\")\n .split(\"\\n\")\n .filter((line: string) => line.trim() && !line.startsWith(\"total\"));\n\n return lines.map((line: string) => {\n const parts = line.trim().split(/\\s+/);\n const name = parts[parts.length - 1];\n const isDirectory = line.startsWith(\"d\");\n\n return {\n name,\n type: isDirectory ? 'directory' as const : 'file' as const,\n size: parseInt(parts[4]) || 0,\n modified: new Date(),\n };\n });\n },\n\n exists: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<boolean> => {\n const result = await runCommand(sandbox, `test -e \"${path}\"`);\n return result.exitCode === 0;\n },\n\n remove: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<void> => {\n const result = await runCommand(sandbox, `rm -rf \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to remove ${path}: ${result.stderr}`);\n }\n },\n },\n\n // Provider-specific typed getInstance method\n getInstance: (sandbox): Runloop.DevboxView => {\n return sandbox;\n },\n },\n\n // Template management methods using the new factory pattern\n template: {\n create: async (\n config: RunloopConfig,\n options: CreateBlueprintTemplateOptions | Runloop.BlueprintCreateParams\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for blueprint template creation\"\n );\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const blueprint = await client.api.blueprints.create(options);\n return blueprint;\n } catch (error) {\n throw new Error(\n `Failed to create blueprint template: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n list: async (config: RunloopConfig, options?: { limit?: number }) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for listing blueprint templates\"\n );\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const listParams: any = {};\n if (options?.limit) {\n listParams.limit = options.limit;\n }\n\n const response = await client.api.blueprints.list(listParams);\n return response.blueprints || [];\n } catch (error) {\n throw new Error(\n `Failed to list blueprint templates: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n delete: async (config: RunloopConfig, blueprintId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for blueprint template deletion\"\n );\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n await client.api.blueprints.delete(blueprintId);\n } catch (error) {\n throw new Error(\n `Failed to delete blueprint template ${blueprintId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n },\n\n // Snapshot management methods using the new factory pattern\n snapshot: {\n create: async (\n config: RunloopConfig,\n sandboxId: string,\n options?: CreateSnapshotOptions\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for snapshot creation\");\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const snapshotParams: any = {};\n if (options?.name) {\n snapshotParams.name = options.name;\n }\n if (options?.metadata) {\n snapshotParams.metadata = options.metadata;\n }\n\n const snapshot = await client.api.devboxes.snapshotDisk(\n sandboxId,\n snapshotParams\n );\n return snapshot;\n } catch (error) {\n throw new Error(\n `Failed to create snapshot for sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n list: async (\n config: RunloopConfig,\n options?: ListSnapshotsOptions\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for listing snapshots\");\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const listParams: any = {};\n if (options?.limit) {\n listParams.limit = options.limit;\n }\n\n const response = await client.api.devboxes.listDiskSnapshots(listParams);\n return response.snapshots || [];\n } catch (error) {\n throw new Error(\n `Failed to list snapshots: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n delete: async (config: RunloopConfig, snapshotId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for snapshot deletion\");\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n await client.api.devboxes.deleteDiskSnapshot(snapshotId);\n } catch (error) {\n throw new Error(\n `Failed to delete snapshot ${snapshotId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n },\n },\n});"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,wBAAyC;AACzC,sBAA+C;AAgFxC,IAAM,cAAU,gCAKrB;AAAA,EACA,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA;AAAA,MAEP,QAAQ,OAAO,QAAuB,YAAmC;AAEvE,cAAM,SACJ,OAAO,UACN,OAAO,YAAY,eAAe,QAAQ,KAAK,mBAChD;AAEF,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAEA,cAAM,UAAU,OAAO;AAEvB,YAAI;AACF,gBAAM,SAAS,IAAI,6BAAW;AAAA,YAC5B,aAAa;AAAA,UACf,CAAC;AAED,cAAI,eAA2C;AAAA,YAC7C,mBAAmB;AAAA,cACjB,yBAAyB,WAAW,SAAS,WAAW;AAAA,YAC1D;AAAA,YACA,MAAM,SAAS;AAAA,YACf,UAAU,SAAS;AAAA,YACnB,uBAAuB,SAAS;AAAA,UAClC;AAGA,cAAI,SAAS,YAAY;AACvB,kBAAM,aAAa,SAAS;AAE5B,gBAAI,YAAY,WAAW,MAAM,GAAG;AAClC,2BAAa,eAAe;AAAA,YAC9B,WAAW,YAAY,WAAW,MAAM,GAAG;AACzC,2BAAa,cAAc;AAAA,YAC7B,OAAO;AAAA,YAEP;AAAA,UACF;AAEA,gBAAM,MAAM,MAAM,OAAO,IAAI,SAAS;AAAA,YACpC;AAAA,UACF;AAGA,gBAAM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CAAC;AAED,gBAAM,OAAO,IAAI,SAAS,mBAAmB,UAAU;AAAA,QACzD,SAAS,OAAO;AACd,gBAAM,IAAI;AAAA,YACR,6BAA6B,UAAU,KAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CACjG;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/index.ts
2
- import { Runloop } from "@runloop/api-client";
2
+ import { RunloopSDK } from "@runloop/api-client";
3
3
  import { defineProvider, escapeShellArg } from "@computesdk/provider";
4
4
  var runloop = defineProvider({
5
5
  name: "runloop",
@@ -15,7 +15,7 @@ var runloop = defineProvider({
15
15
  }
16
16
  const timeout = config.timeout;
17
17
  try {
18
- const client = new Runloop({
18
+ const client = new RunloopSDK({
19
19
  bearerToken: apiKey
20
20
  });
21
21
  let devboxParams = {
@@ -35,7 +35,9 @@ var runloop = defineProvider({
35
35
  } else {
36
36
  }
37
37
  }
38
- const dbx = await client.devboxes.createAndAwaitRunning(devboxParams);
38
+ const dbx = await client.api.devboxes.createAndAwaitRunning(
39
+ devboxParams
40
+ );
39
41
  const runloopSandbox = {
40
42
  ...dbx,
41
43
  // Spread all DevboxView properties
@@ -55,10 +57,10 @@ var runloop = defineProvider({
55
57
  getById: async (config, sandboxId) => {
56
58
  const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
57
59
  try {
58
- const client = new Runloop({
60
+ const client = new RunloopSDK({
59
61
  bearerToken: apiKey
60
62
  });
61
- const devbox = await client.devboxes.retrieve(sandboxId);
63
+ const devbox = await client.api.devboxes.retrieve(sandboxId);
62
64
  return {
63
65
  sandbox: devbox,
64
66
  sandboxId
@@ -70,10 +72,10 @@ var runloop = defineProvider({
70
72
  list: async (config) => {
71
73
  const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
72
74
  try {
73
- const client = new Runloop({
75
+ const client = new RunloopSDK({
74
76
  bearerToken: apiKey
75
77
  });
76
- const response = await client.devboxes.list();
78
+ const response = await client.api.devboxes.list();
77
79
  const devboxes = response.devboxes || [];
78
80
  return devboxes.map((devbox) => ({
79
81
  sandbox: devbox,
@@ -86,10 +88,10 @@ var runloop = defineProvider({
86
88
  destroy: async (config, sandboxId) => {
87
89
  const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
88
90
  try {
89
- const client = new Runloop({
91
+ const client = new RunloopSDK({
90
92
  bearerToken: apiKey
91
93
  });
92
- await client.devboxes.shutdown(sandboxId);
94
+ await client.api.devboxes.shutdown(sandboxId);
93
95
  } catch (error) {
94
96
  }
95
97
  },
@@ -108,13 +110,9 @@ var runloop = defineProvider({
108
110
  } else {
109
111
  command = `echo "${encoded}" | base64 -d | node`;
110
112
  }
111
- const execution = await client.devboxes.executeAsync(devbox.id, {
113
+ const executionResult = await client.api.devboxes.executeAndAwaitCompletion(devbox.id, {
112
114
  command
113
115
  });
114
- const executionResult = await client.devboxes.executions.awaitCompleted(
115
- devbox.id,
116
- execution.execution_id
117
- );
118
116
  if (executionResult.exit_status !== 0 && executionResult.stderr) {
119
117
  if (executionResult.stderr.includes("SyntaxError") || executionResult.stderr.includes("invalid syntax") || executionResult.stderr.includes("Unexpected token") || executionResult.stderr.includes("Unexpected identifier")) {
120
118
  throw new Error(`Syntax error: ${executionResult.stderr.trim()}`);
@@ -164,13 +162,9 @@ var runloop = defineProvider({
164
162
  if (options?.background) {
165
163
  fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;
166
164
  }
167
- const execution = await client.devboxes.executeAsync(devbox.id, {
165
+ const executionResult = await client.api.devboxes.executeAndAwaitCompletion(devbox.id, {
168
166
  command: fullCommand
169
167
  });
170
- const executionResult = await client.devboxes.executions.awaitCompleted(
171
- devbox.id,
172
- execution.execution_id
173
- );
174
168
  return {
175
169
  stdout: executionResult.stdout || "",
176
170
  stderr: executionResult.stderr || "",
@@ -207,7 +201,7 @@ var runloop = defineProvider({
207
201
  const devbox = sandbox;
208
202
  const client = sandbox.client;
209
203
  try {
210
- const tunnel = await client.devboxes.createTunnel(devbox.id, {
204
+ const tunnel = await client.api.devboxes.createTunnel(devbox.id, {
211
205
  port: options.port
212
206
  });
213
207
  return tunnel.url;
@@ -299,10 +293,10 @@ var runloop = defineProvider({
299
293
  );
300
294
  }
301
295
  try {
302
- const client = new Runloop({
296
+ const client = new RunloopSDK({
303
297
  bearerToken: apiKey
304
298
  });
305
- const blueprint = await client.blueprints.create(options);
299
+ const blueprint = await client.api.blueprints.create(options);
306
300
  return blueprint;
307
301
  } catch (error) {
308
302
  throw new Error(
@@ -318,14 +312,14 @@ var runloop = defineProvider({
318
312
  );
319
313
  }
320
314
  try {
321
- const client = new Runloop({
315
+ const client = new RunloopSDK({
322
316
  bearerToken: apiKey
323
317
  });
324
318
  const listParams = {};
325
319
  if (options?.limit) {
326
320
  listParams.limit = options.limit;
327
321
  }
328
- const response = await client.blueprints.list(listParams);
322
+ const response = await client.api.blueprints.list(listParams);
329
323
  return response.blueprints || [];
330
324
  } catch (error) {
331
325
  throw new Error(
@@ -341,10 +335,10 @@ var runloop = defineProvider({
341
335
  );
342
336
  }
343
337
  try {
344
- const client = new Runloop({
338
+ const client = new RunloopSDK({
345
339
  bearerToken: apiKey
346
340
  });
347
- await client.blueprints.delete(blueprintId);
341
+ await client.api.blueprints.delete(blueprintId);
348
342
  } catch (error) {
349
343
  throw new Error(
350
344
  `Failed to delete blueprint template ${blueprintId}: ${error instanceof Error ? error.message : String(error)}`
@@ -360,7 +354,7 @@ var runloop = defineProvider({
360
354
  throw new Error("Missing Runloop API key for snapshot creation");
361
355
  }
362
356
  try {
363
- const client = new Runloop({
357
+ const client = new RunloopSDK({
364
358
  bearerToken: apiKey
365
359
  });
366
360
  const snapshotParams = {};
@@ -370,7 +364,7 @@ var runloop = defineProvider({
370
364
  if (options?.metadata) {
371
365
  snapshotParams.metadata = options.metadata;
372
366
  }
373
- const snapshot = await client.devboxes.snapshotDisk(
367
+ const snapshot = await client.api.devboxes.snapshotDisk(
374
368
  sandboxId,
375
369
  snapshotParams
376
370
  );
@@ -387,14 +381,14 @@ var runloop = defineProvider({
387
381
  throw new Error("Missing Runloop API key for listing snapshots");
388
382
  }
389
383
  try {
390
- const client = new Runloop({
384
+ const client = new RunloopSDK({
391
385
  bearerToken: apiKey
392
386
  });
393
387
  const listParams = {};
394
388
  if (options?.limit) {
395
389
  listParams.limit = options.limit;
396
390
  }
397
- const response = await client.devboxes.listDiskSnapshots(listParams);
391
+ const response = await client.api.devboxes.listDiskSnapshots(listParams);
398
392
  return response.snapshots || [];
399
393
  } catch (error) {
400
394
  throw new Error(
@@ -408,10 +402,10 @@ var runloop = defineProvider({
408
402
  throw new Error("Missing Runloop API key for snapshot deletion");
409
403
  }
410
404
  try {
411
- const client = new Runloop({
405
+ const client = new RunloopSDK({
412
406
  bearerToken: apiKey
413
407
  });
414
- await client.devboxes.deleteDiskSnapshot(snapshotId);
408
+ await client.api.devboxes.deleteDiskSnapshot(snapshotId);
415
409
  } catch (error) {
416
410
  throw new Error(
417
411
  `Failed to delete snapshot ${snapshotId}: ${error instanceof Error ? error.message : String(error)}`
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Runloop Provider - Factory-based Implementation\n *\n * Full-featured provider with filesystem support using the factory pattern.\n * Reduces ~400 lines of boilerplate to ~100 lines of core logic.\n */\n\nimport { Runloop } from \"@runloop/api-client\";\nimport { defineProvider, escapeShellArg } from \"@computesdk/provider\";\nimport type {\n CodeResult,\n CommandResult,\n SandboxInfo,\n CreateSnapshotOptions,\n ListSnapshotsOptions,\n RunCommandOptions,\n} from \"@computesdk/provider\";\nimport type {\n CreateSandboxOptions,\n FileEntry,\n Runtime,\n SandboxStatus,\n Sandbox,\n} from \"computesdk\";\n\n// Define Runloop-specific types\ntype RunloopSnapshot = Runloop.DevboxSnapshotView;\ntype RunloopTemplate = Runloop.BlueprintView;\n\n/**\n * Runloop-specific configuration options\n */\nexport interface RunloopConfig {\n /** Runloop API key - if not provided, will fallback to RUNLOOP_API_KEY environment variable */\n apiKey?: string;\n /** Execution timeout in milliseconds */\n timeout?: number;\n}\n\n/**\n * Runloop-specific blueprint creation options\n */\nexport interface CreateBlueprintTemplateOptions {\n /** Name of the blueprint template */\n name: string;\n /** Custom Dockerfile content */\n dockerfile?: string;\n /** System setup commands to run during blueprint creation */\n systemSetupCommands?: string[];\n /** Launch commands to run when starting a devbox from this blueprint */\n launchCommands?: string[];\n /** File mounts as key-value pairs (path -> content) */\n fileMounts?: Record<string, string>;\n /** Code repository mounts */\n codeMounts?: Array<{\n repoName: string;\n repoOwner: string;\n token?: string;\n installCommand?: string;\n }>;\n /** Resource size for devboxes created from this blueprint */\n resourceSize?:\n | \"X_SMALL\"\n | \"SMALL\"\n | \"MEDIUM\"\n | \"LARGE\"\n | \"X_LARGE\"\n | \"XX_LARGE\"\n | \"CUSTOM_SIZE\";\n /** CPU architecture */\n architecture?: \"x86_64\" | \"arm64\";\n /** Custom CPU cores (requires CUSTOM_SIZE) */\n customCpuCores?: number;\n /** Custom memory in GB (requires CUSTOM_SIZE) */\n customMemoryGb?: number;\n /** Custom disk size (requires CUSTOM_SIZE) */\n customDiskSize?: number;\n /** Available ports for the devbox */\n availablePorts?: number[];\n /** Action to take when devbox is idle */\n afterIdle?: { action: string; timeSeconds: number };\n /** Keep alive time in seconds */\n keepAliveTimeSeconds?: number;\n}\n\n/**\n * Create a Runloop provider instance using the factory pattern\n */\nexport const runloop = defineProvider<\n Runloop.DevboxView, // TSandbox\n RunloopConfig, // TConfig\n RunloopTemplate, // TTemplate \n RunloopSnapshot // TSnapshot\n>({\n name: \"runloop\",\n methods: {\n sandbox: {\n // Collection operations (map to compute.sandbox.*)\n create: async (config: RunloopConfig, options?: CreateSandboxOptions) => {\n // Validate API key\n const apiKey =\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.RUNLOOP_API_KEY) ||\n \"\";\n\n if (!apiKey) {\n throw new Error(\n `Missing Runloop API key. Provide 'apiKey' in config or set RUNLOOP_API_KEY environment variable. Get your API key from https://runloop.ai/`\n );\n }\n\n const timeout = config.timeout;\n\n try {\n const client = new Runloop({\n bearerToken: apiKey,\n });\n\n let devboxParams: Runloop.DevboxCreateParams = {\n launch_parameters: {\n keep_alive_time_seconds: timeout || options?.timeout || 1800,\n },\n name: options?.sandboxId,\n metadata: options?.metadata,\n environment_variables: options?.envs,\n };\n\n // Use blueprint if specified\n if (options?.templateId) {\n const templateId = options?.templateId;\n // Check template prefix to determine parameter type\n if (templateId?.startsWith(\"bpt_\")) {\n devboxParams.blueprint_id = templateId;\n } else if (templateId?.startsWith(\"snp_\")) {\n devboxParams.snapshot_id = templateId;\n } else {\n // empty\n }\n }\n\n const dbx = await client.devboxes.createAndAwaitRunning(devboxParams);\n\n // Create a RunloopSandbox object that contains both devbox and client\n const runloopSandbox = {\n ...dbx, // Spread all DevboxView properties\n client: client // Add client for method access\n };\n\n return {\n sandbox: runloopSandbox,\n sandboxId: dbx.id,\n };\n } catch (error) {\n throw new Error(\n `Failed to create Runloop devbox: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n getById: async (config: RunloopConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new Runloop({\n bearerToken: apiKey,\n });\n\n const devbox = await client.devboxes.retrieve(sandboxId);\n\n return {\n sandbox: devbox,\n sandboxId,\n };\n } catch (error) {\n // Devbox doesn't exist or can't be accessed\n return null;\n }\n },\n\n list: async (config: RunloopConfig) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new Runloop({\n bearerToken: apiKey,\n });\n\n const response = await client.devboxes.list();\n const devboxes = response.devboxes || [];\n\n return devboxes.map((devbox) => ({\n sandbox: devbox,\n sandboxId: devbox.id,\n }));\n } catch (error) {\n // Return empty array if listing fails\n return [];\n }\n },\n\n destroy: async (config: RunloopConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new Runloop({\n bearerToken: apiKey,\n });\n\n await client.devboxes.shutdown(sandboxId);\n } catch (error) {\n // Devbox might already be destroyed or doesn't exist\n // This is acceptable for destroy operations\n }\n },\n\n // Instance operations (map to individual Sandbox methods)\n runCode: async (sandbox: any, code: string, runtime?: Runtime): Promise<CodeResult> => {\n const startTime = Date.now();\n const devbox = sandbox;\n const client = sandbox.client;\n\n // Auto-detect runtime if not specified\n const effectiveRuntime: Runtime = 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 ) as Runtime;\n\n try {\n\n // Use base64 encoding for both runtimes for reliability and consistency\n const encoded = Buffer.from(code).toString('base64');\n\n let command;\n if (effectiveRuntime === 'python') {\n command = `echo \"${encoded}\" | base64 -d | python3`;\n } else {\n command = `echo \"${encoded}\" | base64 -d | node`;\n }\n\n // Execute code using Runloop's executeAsync\n const execution = await client.devboxes.executeAsync(devbox.id, {\n command: command,\n });\n\n const executionResult = await client.devboxes.executions.awaitCompleted(\n devbox.id,\n execution.execution_id\n );\n\n // Check for syntax errors and throw them (similar to Vercel behavior)\n if (executionResult.exit_status !== 0 && executionResult.stderr) {\n // Check for common syntax error patterns\n if (executionResult.stderr.includes('SyntaxError') ||\n executionResult.stderr.includes('invalid syntax') ||\n executionResult.stderr.includes('Unexpected token') ||\n executionResult.stderr.includes('Unexpected identifier')) {\n throw new Error(`Syntax error: ${executionResult.stderr.trim()}`);\n }\n }\n\n return {\n output: (executionResult.stdout || \"\") + (executionResult.stderr || \"\"),\n exitCode: executionResult.exit_status || 0,\n language: effectiveRuntime,\n };\n } catch (error) {\n // Handle Runloop execution errors\n if (error instanceof Error && error.message === 'exit status 1') {\n const actualStderr = (error as any)?.result?.stderr || '';\n const isSyntaxError = actualStderr.includes('SyntaxError');\n\n if (isSyntaxError) {\n // For syntax errors, throw\n const syntaxErrorLine = actualStderr.split('\\n').find((line: string) => line.includes('SyntaxError')) || 'SyntaxError: Invalid syntax in code';\n throw new Error(`Syntax error: ${syntaxErrorLine}`);\n } else {\n // For runtime errors, return a result instead of throwing\n return {\n output: actualStderr || 'Error: Runtime error occurred during execution',\n exitCode: 1,\n language: effectiveRuntime,\n };\n }\n }\n\n // Re-throw syntax errors\n if (error instanceof Error && error.message.includes('Syntax error')) {\n throw error;\n }\n throw new Error(\n `Runloop execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n runCommand: async (\n sandbox: any,\n command: string,\n options?: RunCommandOptions\n ): Promise<CommandResult> => {\n const startTime = Date.now();\n const devbox = sandbox;\n const client = sandbox.client;\n\n try {\n // Build the full 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}=\"${escapeShellArg(v)}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n\n // Handle working directory\n if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n\n // Handle background execution\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n\n const execution = await client.devboxes.executeAsync(devbox.id, {\n command: fullCommand,\n });\n\n const executionResult =\n await client.devboxes.executions.awaitCompleted(\n devbox.id,\n execution.execution_id\n );\n\n return {\n stdout: executionResult.stdout || \"\",\n stderr: executionResult.stderr || \"\",\n exitCode: executionResult.exit_status || 0,\n durationMs: Date.now() - startTime,\n };\n } catch (error) {\n // Re-throw syntax errors\n if (\n error instanceof Error &&\n error.message.includes(\"Syntax error\")\n ) {\n throw error;\n }\n throw new Error(\n `Runloop execution failed: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n getInfo: async (sandbox): Promise<SandboxInfo> => {\n const devbox = sandbox;\n\n return {\n id: devbox.id || \"runloop-unknown\",\n provider: \"runloop\",\n runtime: \"node\" as Runtime, // Runloop supports multiple runtimes, defaulting to node\n status: devbox.status as SandboxStatus,\n createdAt: new Date(devbox.create_time_ms || Date.now()),\n timeout: devbox.launch_parameters.keep_alive_time_seconds || 300000,\n metadata: {\n runloopDevboxId: devbox.id,\n templateId: devbox.blueprint_id || devbox.snapshot_id,\n ...devbox.metadata,\n },\n };\n },\n\n getUrl: async (\n sandbox: any,\n options: { port: number }\n ): Promise<string> => {\n const devbox = sandbox;\n const client = sandbox.client;\n\n try {\n const tunnel = await client.devboxes.createTunnel(devbox.id, {\n port: options.port,\n });\n\n return tunnel.url;\n } catch (error) {\n throw new Error(\n `Failed to get Runloop URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n // Optional filesystem methods - using Runloop's file operations\n filesystem: {\n readFile: async (sandbox: any, path: string, runCommand: any): Promise<string> => {\n try {\n const result = await runCommand(sandbox, `cat \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`File not found or unreadable: ${result.stderr}`);\n }\n return result.stdout;\n } catch (error) {\n throw new Error(\n `Failed to read file ${path}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n writeFile: async (\n sandbox: any,\n path: string,\n content: string,\n runCommand: any\n ): Promise<void> => {\n try {\n // Use command-based approach for file writing since API writeFileContents may have issues\n const encoded = Buffer.from(content).toString('base64');\n const result = await runCommand(sandbox, `sh -c 'echo \"${encoded}\" | base64 -d > \"${path}\"'`);\n\n if (result.exitCode !== 0) {\n throw new Error(`Command failed: ${result.stderr}`);\n }\n } catch (error) {\n throw new Error(\n `Failed to write file ${path}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n mkdir: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<void> => {\n const result = await runCommand(sandbox, `mkdir -p \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(\n `Failed to create directory ${path}: ${result.stderr}`\n );\n }\n },\n\n readdir: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<FileEntry[]> => {\n const result = await runCommand(sandbox, `ls -la \"${path}\"`);\n\n if (result.exitCode !== 0) {\n throw new Error(\n `Failed to list directory ${path}: ${result.stderr}`\n );\n }\n\n const lines = (result.stdout || \"\")\n .split(\"\\n\")\n .filter((line: string) => line.trim() && !line.startsWith(\"total\"));\n\n return lines.map((line: string) => {\n const parts = line.trim().split(/\\s+/);\n const name = parts[parts.length - 1];\n const isDirectory = line.startsWith(\"d\");\n\n return {\n name,\n type: isDirectory ? 'directory' as const : 'file' as const,\n size: parseInt(parts[4]) || 0,\n modified: new Date(),\n };\n });\n },\n\n exists: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<boolean> => {\n const result = await runCommand(sandbox, `test -e \"${path}\"`);\n return result.exitCode === 0;\n },\n\n remove: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<void> => {\n const result = await runCommand(sandbox, `rm -rf \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to remove ${path}: ${result.stderr}`);\n }\n },\n },\n\n // Provider-specific typed getInstance method\n getInstance: (sandbox): Runloop.DevboxView => {\n return sandbox;\n },\n },\n\n // Template management methods using the new factory pattern\n template: {\n create: async (\n config: RunloopConfig,\n options: CreateBlueprintTemplateOptions | Runloop.BlueprintCreateParams\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for blueprint template creation\"\n );\n }\n\n try {\n const client = new Runloop({\n bearerToken: apiKey,\n });\n\n const blueprint = await client.blueprints.create(options);\n return blueprint;\n } catch (error) {\n throw new Error(\n `Failed to create blueprint template: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n list: async (config: RunloopConfig, options?: { limit?: number }) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for listing blueprint templates\"\n );\n }\n\n try {\n const client = new Runloop({\n bearerToken: apiKey,\n });\n\n const listParams: any = {};\n if (options?.limit) {\n listParams.limit = options.limit;\n }\n\n const response = await client.blueprints.list(listParams);\n return response.blueprints || [];\n } catch (error) {\n throw new Error(\n `Failed to list blueprint templates: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n delete: async (config: RunloopConfig, blueprintId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for blueprint template deletion\"\n );\n }\n\n try {\n const client = new Runloop({\n bearerToken: apiKey,\n });\n\n await client.blueprints.delete(blueprintId);\n } catch (error) {\n throw new Error(\n `Failed to delete blueprint template ${blueprintId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n },\n\n // Snapshot management methods using the new factory pattern\n snapshot: {\n create: async (\n config: RunloopConfig,\n sandboxId: string,\n options?: CreateSnapshotOptions\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for snapshot creation\");\n }\n\n try {\n const client = new Runloop({\n bearerToken: apiKey,\n });\n\n const snapshotParams: any = {};\n if (options?.name) {\n snapshotParams.name = options.name;\n }\n if (options?.metadata) {\n snapshotParams.metadata = options.metadata;\n }\n\n const snapshot = await client.devboxes.snapshotDisk(\n sandboxId,\n snapshotParams\n );\n return snapshot;\n } catch (error) {\n throw new Error(\n `Failed to create snapshot for sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n list: async (\n config: RunloopConfig,\n options?: ListSnapshotsOptions\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for listing snapshots\");\n }\n\n try {\n const client = new Runloop({\n bearerToken: apiKey,\n });\n\n const listParams: any = {};\n if (options?.limit) {\n listParams.limit = options.limit;\n }\n\n const response = await client.devboxes.listDiskSnapshots(listParams);\n return response.snapshots || [];\n } catch (error) {\n throw new Error(\n `Failed to list snapshots: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n delete: async (config: RunloopConfig, snapshotId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for snapshot deletion\");\n }\n\n try {\n const client = new Runloop({\n bearerToken: apiKey,\n });\n\n await client.devboxes.deleteDiskSnapshot(snapshotId);\n } catch (error) {\n throw new Error(\n `Failed to delete snapshot ${snapshotId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n },\n },\n});"],"mappings":";AAOA,SAAS,eAAe;AACxB,SAAS,gBAAgB,sBAAsB;AAgFxC,IAAM,UAAU,eAKrB;AAAA,EACA,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA;AAAA,MAEP,QAAQ,OAAO,QAAuB,YAAmC;AAEvE,cAAM,SACJ,OAAO,UACN,OAAO,YAAY,eAAe,QAAQ,KAAK,mBAChD;AAEF,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAEA,cAAM,UAAU,OAAO;AAEvB,YAAI;AACF,gBAAM,SAAS,IAAI,QAAQ;AAAA,YACzB,aAAa;AAAA,UACf,CAAC;AAED,cAAI,eAA2C;AAAA,YAC7C,mBAAmB;AAAA,cACjB,yBAAyB,WAAW,SAAS,WAAW;AAAA,YAC1D;AAAA,YACA,MAAM,SAAS;AAAA,YACf,UAAU,SAAS;AAAA,YACnB,uBAAuB,SAAS;AAAA,UAClC;AAGA,cAAI,SAAS,YAAY;AACvB,kBAAM,aAAa,SAAS;AAE5B,gBAAI,YAAY,WAAW,MAAM,GAAG;AAClC,2BAAa,eAAe;AAAA,YAC9B,WAAW,YAAY,W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;AAAA,MACF;AAAA,MAEA,QAAQ,OAAO,QAAuB,eAAuB;AAC3D,cAAM,SAAS,OAAO,UAAU,QAAQ,IAAI;AAE5C,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI,MAAM,+CAA+C;AAAA,QACjE;AAEA,YAAI;AACF,gBAAM,SAAS,IAAI,QAAQ;AAAA,YACzB,aAAa;AAAA,UACf,CAAC;AAED,gBAAM,OAAO,SAAS,mBAAmB,UAAU;AAAA,QACrD,SAAS,OAAO;AACd,gBAAM,IAAI;AAAA,YACR,6BAA6B,UAAU,KAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CACjG;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Runloop Provider - Factory-based Implementation\n *\n * Full-featured provider with filesystem support using the factory pattern.\n * Reduces ~400 lines of boilerplate to ~100 lines of core logic.\n */\n\nimport { RunloopSDK, type Runloop } from \"@runloop/api-client\";\nimport { defineProvider, escapeShellArg } from \"@computesdk/provider\";\nimport type {\n CodeResult,\n CommandResult,\n SandboxInfo,\n CreateSnapshotOptions,\n ListSnapshotsOptions,\n RunCommandOptions,\n} from \"@computesdk/provider\";\nimport type {\n CreateSandboxOptions,\n FileEntry,\n Runtime,\n SandboxStatus,\n Sandbox,\n} from \"computesdk\";\n\n// Define Runloop-specific types\ntype RunloopSnapshot = Runloop.DevboxSnapshotView;\ntype RunloopTemplate = Runloop.BlueprintView;\n\n/**\n * Runloop-specific configuration options\n */\nexport interface RunloopConfig {\n /** Runloop API key - if not provided, will fallback to RUNLOOP_API_KEY environment variable */\n apiKey?: string;\n /** Execution timeout in milliseconds */\n timeout?: number;\n}\n\n/**\n * Runloop-specific blueprint creation options\n */\nexport interface CreateBlueprintTemplateOptions {\n /** Name of the blueprint template */\n name: string;\n /** Custom Dockerfile content */\n dockerfile?: string;\n /** System setup commands to run during blueprint creation */\n systemSetupCommands?: string[];\n /** Launch commands to run when starting a devbox from this blueprint */\n launchCommands?: string[];\n /** File mounts as key-value pairs (path -> content) */\n fileMounts?: Record<string, string>;\n /** Code repository mounts */\n codeMounts?: Array<{\n repoName: string;\n repoOwner: string;\n token?: string;\n installCommand?: string;\n }>;\n /** Resource size for devboxes created from this blueprint */\n resourceSize?:\n | \"X_SMALL\"\n | \"SMALL\"\n | \"MEDIUM\"\n | \"LARGE\"\n | \"X_LARGE\"\n | \"XX_LARGE\"\n | \"CUSTOM_SIZE\";\n /** CPU architecture */\n architecture?: \"x86_64\" | \"arm64\";\n /** Custom CPU cores (requires CUSTOM_SIZE) */\n customCpuCores?: number;\n /** Custom memory in GB (requires CUSTOM_SIZE) */\n customMemoryGb?: number;\n /** Custom disk size (requires CUSTOM_SIZE) */\n customDiskSize?: number;\n /** Available ports for the devbox */\n availablePorts?: number[];\n /** Action to take when devbox is idle */\n afterIdle?: { action: string; timeSeconds: number };\n /** Keep alive time in seconds */\n keepAliveTimeSeconds?: number;\n}\n\n/**\n * Create a Runloop provider instance using the factory pattern\n */\nexport const runloop = defineProvider<\n Runloop.DevboxView, // TSandbox\n RunloopConfig, // TConfig\n RunloopTemplate, // TTemplate \n RunloopSnapshot // TSnapshot\n>({\n name: \"runloop\",\n methods: {\n sandbox: {\n // Collection operations (map to compute.sandbox.*)\n create: async (config: RunloopConfig, options?: CreateSandboxOptions) => {\n // Validate API key\n const apiKey =\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.RUNLOOP_API_KEY) ||\n \"\";\n\n if (!apiKey) {\n throw new Error(\n `Missing Runloop API key. Provide 'apiKey' in config or set RUNLOOP_API_KEY environment variable. Get your API key from https://runloop.ai/`\n );\n }\n\n const timeout = config.timeout;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n let devboxParams: Runloop.DevboxCreateParams = {\n launch_parameters: {\n keep_alive_time_seconds: timeout || options?.timeout || 1800,\n },\n name: options?.sandboxId,\n metadata: options?.metadata,\n environment_variables: options?.envs,\n };\n\n // Use blueprint if specified\n if (options?.templateId) {\n const templateId = options?.templateId;\n // Check template prefix to determine parameter type\n if (templateId?.startsWith(\"bpt_\")) {\n devboxParams.blueprint_id = templateId;\n } else if (templateId?.startsWith(\"snp_\")) {\n devboxParams.snapshot_id = templateId;\n } else {\n // empty\n }\n }\n\n const dbx = await client.api.devboxes.createAndAwaitRunning(\n devboxParams,\n );\n\n // Create a RunloopSandbox object that contains both devbox and client\n const runloopSandbox = {\n ...dbx, // Spread all DevboxView properties\n client: client // Add client for method access\n };\n\n return {\n sandbox: runloopSandbox,\n sandboxId: dbx.id,\n };\n } catch (error) {\n throw new Error(\n `Failed to create Runloop devbox: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n getById: async (config: RunloopConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const devbox = await client.api.devboxes.retrieve(sandboxId);\n\n return {\n sandbox: devbox,\n sandboxId,\n };\n } catch (error) {\n // Devbox doesn't exist or can't be accessed\n return null;\n }\n },\n\n list: async (config: RunloopConfig) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const response = await client.api.devboxes.list();\n const devboxes = response.devboxes || [];\n\n return devboxes.map((devbox) => ({\n sandbox: devbox,\n sandboxId: devbox.id,\n }));\n } catch (error) {\n // Return empty array if listing fails\n return [];\n }\n },\n\n destroy: async (config: RunloopConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n await client.api.devboxes.shutdown(sandboxId);\n } catch (error) {\n // Devbox might already be destroyed or doesn't exist\n // This is acceptable for destroy operations\n }\n },\n\n // Instance operations (map to individual Sandbox methods)\n runCode: async (sandbox: any, code: string, runtime?: Runtime): Promise<CodeResult> => {\n const startTime = Date.now();\n const devbox = sandbox;\n const client = sandbox.client;\n\n // Auto-detect runtime if not specified\n const effectiveRuntime: Runtime = 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 ) as Runtime;\n\n try {\n\n // Use base64 encoding for both runtimes for reliability and consistency\n const encoded = Buffer.from(code).toString('base64');\n\n let command;\n if (effectiveRuntime === 'python') {\n command = `echo \"${encoded}\" | base64 -d | python3`;\n } else {\n command = `echo \"${encoded}\" | base64 -d | node`;\n }\n\n // Execute code using Runloop's executeAsync\n const executionResult =\n await client.api.devboxes.executeAndAwaitCompletion(devbox.id, {\n command: command,\n });\n\n // Check for syntax errors and throw them (similar to Vercel behavior)\n if (executionResult.exit_status !== 0 && executionResult.stderr) {\n // Check for common syntax error patterns\n if (executionResult.stderr.includes('SyntaxError') ||\n executionResult.stderr.includes('invalid syntax') ||\n executionResult.stderr.includes('Unexpected token') ||\n executionResult.stderr.includes('Unexpected identifier')) {\n throw new Error(`Syntax error: ${executionResult.stderr.trim()}`);\n }\n }\n\n return {\n output: (executionResult.stdout || \"\") + (executionResult.stderr || \"\"),\n exitCode: executionResult.exit_status || 0,\n language: effectiveRuntime,\n };\n } catch (error) {\n // Handle Runloop execution errors\n if (error instanceof Error && error.message === 'exit status 1') {\n const actualStderr = (error as any)?.result?.stderr || '';\n const isSyntaxError = actualStderr.includes('SyntaxError');\n\n if (isSyntaxError) {\n // For syntax errors, throw\n const syntaxErrorLine = actualStderr.split('\\n').find((line: string) => line.includes('SyntaxError')) || 'SyntaxError: Invalid syntax in code';\n throw new Error(`Syntax error: ${syntaxErrorLine}`);\n } else {\n // For runtime errors, return a result instead of throwing\n return {\n output: actualStderr || 'Error: Runtime error occurred during execution',\n exitCode: 1,\n language: effectiveRuntime,\n };\n }\n }\n\n // Re-throw syntax errors\n if (error instanceof Error && error.message.includes('Syntax error')) {\n throw error;\n }\n throw new Error(\n `Runloop execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n runCommand: async (\n sandbox: any,\n command: string,\n options?: RunCommandOptions\n ): Promise<CommandResult> => {\n const startTime = Date.now();\n const devbox = sandbox;\n const client = sandbox.client;\n\n try {\n // Build the full 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}=\"${escapeShellArg(v)}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n\n // Handle working directory\n if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n\n // Handle background execution\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n\n const executionResult =\n await client.api.devboxes.executeAndAwaitCompletion(devbox.id, {\n command: fullCommand,\n });\n\n return {\n stdout: executionResult.stdout || \"\",\n stderr: executionResult.stderr || \"\",\n exitCode: executionResult.exit_status || 0,\n durationMs: Date.now() - startTime,\n };\n } catch (error) {\n // Re-throw syntax errors\n if (\n error instanceof Error &&\n error.message.includes(\"Syntax error\")\n ) {\n throw error;\n }\n throw new Error(\n `Runloop execution failed: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n getInfo: async (sandbox): Promise<SandboxInfo> => {\n const devbox = sandbox;\n\n return {\n id: devbox.id || \"runloop-unknown\",\n provider: \"runloop\",\n runtime: \"node\" as Runtime, // Runloop supports multiple runtimes, defaulting to node\n status: devbox.status as SandboxStatus,\n createdAt: new Date(devbox.create_time_ms || Date.now()),\n timeout: devbox.launch_parameters.keep_alive_time_seconds || 300000,\n metadata: {\n runloopDevboxId: devbox.id,\n templateId: devbox.blueprint_id || devbox.snapshot_id,\n ...devbox.metadata,\n },\n };\n },\n\n getUrl: async (\n sandbox: any,\n options: { port: number }\n ): Promise<string> => {\n const devbox = sandbox;\n const client = sandbox.client;\n\n try {\n const tunnel = await client.api.devboxes.createTunnel(devbox.id, {\n port: options.port,\n });\n\n return tunnel.url;\n } catch (error) {\n throw new Error(\n `Failed to get Runloop URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n // Optional filesystem methods - using Runloop's file operations\n filesystem: {\n readFile: async (sandbox: any, path: string, runCommand: any): Promise<string> => {\n try {\n const result = await runCommand(sandbox, `cat \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`File not found or unreadable: ${result.stderr}`);\n }\n return result.stdout;\n } catch (error) {\n throw new Error(\n `Failed to read file ${path}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n writeFile: async (\n sandbox: any,\n path: string,\n content: string,\n runCommand: any\n ): Promise<void> => {\n try {\n // Use command-based approach for file writing since API writeFileContents may have issues\n const encoded = Buffer.from(content).toString('base64');\n const result = await runCommand(sandbox, `sh -c 'echo \"${encoded}\" | base64 -d > \"${path}\"'`);\n\n if (result.exitCode !== 0) {\n throw new Error(`Command failed: ${result.stderr}`);\n }\n } catch (error) {\n throw new Error(\n `Failed to write file ${path}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n mkdir: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<void> => {\n const result = await runCommand(sandbox, `mkdir -p \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(\n `Failed to create directory ${path}: ${result.stderr}`\n );\n }\n },\n\n readdir: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<FileEntry[]> => {\n const result = await runCommand(sandbox, `ls -la \"${path}\"`);\n\n if (result.exitCode !== 0) {\n throw new Error(\n `Failed to list directory ${path}: ${result.stderr}`\n );\n }\n\n const lines = (result.stdout || \"\")\n .split(\"\\n\")\n .filter((line: string) => line.trim() && !line.startsWith(\"total\"));\n\n return lines.map((line: string) => {\n const parts = line.trim().split(/\\s+/);\n const name = parts[parts.length - 1];\n const isDirectory = line.startsWith(\"d\");\n\n return {\n name,\n type: isDirectory ? 'directory' as const : 'file' as const,\n size: parseInt(parts[4]) || 0,\n modified: new Date(),\n };\n });\n },\n\n exists: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<boolean> => {\n const result = await runCommand(sandbox, `test -e \"${path}\"`);\n return result.exitCode === 0;\n },\n\n remove: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<void> => {\n const result = await runCommand(sandbox, `rm -rf \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to remove ${path}: ${result.stderr}`);\n }\n },\n },\n\n // Provider-specific typed getInstance method\n getInstance: (sandbox): Runloop.DevboxView => {\n return sandbox;\n },\n },\n\n // Template management methods using the new factory pattern\n template: {\n create: async (\n config: RunloopConfig,\n options: CreateBlueprintTemplateOptions | Runloop.BlueprintCreateParams\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for blueprint template creation\"\n );\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const blueprint = await client.api.blueprints.create(options);\n return blueprint;\n } catch (error) {\n throw new Error(\n `Failed to create blueprint template: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n list: async (config: RunloopConfig, options?: { limit?: number }) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for listing blueprint templates\"\n );\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const listParams: any = {};\n if (options?.limit) {\n listParams.limit = options.limit;\n }\n\n const response = await client.api.blueprints.list(listParams);\n return response.blueprints || [];\n } catch (error) {\n throw new Error(\n `Failed to list blueprint templates: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n delete: async (config: RunloopConfig, blueprintId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for blueprint template deletion\"\n );\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n await client.api.blueprints.delete(blueprintId);\n } catch (error) {\n throw new Error(\n `Failed to delete blueprint template ${blueprintId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n },\n\n // Snapshot management methods using the new factory pattern\n snapshot: {\n create: async (\n config: RunloopConfig,\n sandboxId: string,\n options?: CreateSnapshotOptions\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for snapshot creation\");\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const snapshotParams: any = {};\n if (options?.name) {\n snapshotParams.name = options.name;\n }\n if (options?.metadata) {\n snapshotParams.metadata = options.metadata;\n }\n\n const snapshot = await client.api.devboxes.snapshotDisk(\n sandboxId,\n snapshotParams\n );\n return snapshot;\n } catch (error) {\n throw new Error(\n `Failed to create snapshot for sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n list: async (\n config: RunloopConfig,\n options?: ListSnapshotsOptions\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for listing snapshots\");\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const listParams: any = {};\n if (options?.limit) {\n listParams.limit = options.limit;\n }\n\n const response = await client.api.devboxes.listDiskSnapshots(listParams);\n return response.snapshots || [];\n } catch (error) {\n throw new Error(\n `Failed to list snapshots: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n delete: async (config: RunloopConfig, snapshotId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for snapshot deletion\");\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n await client.api.devboxes.deleteDiskSnapshot(snapshotId);\n } catch (error) {\n throw new Error(\n `Failed to delete snapshot ${snapshotId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n },\n },\n});"],"mappings":";AAOA,SAAS,kBAAgC;AACzC,SAAS,gBAAgB,sBAAsB;AAgFxC,IAAM,UAAU,eAKrB;AAAA,EACA,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA;AAAA,MAEP,QAAQ,OAAO,QAAuB,YAAmC;AAEvE,cAAM,SACJ,OAAO,UACN,OAAO,YAAY,eAAe,QAAQ,KAAK,mBAChD;AAEF,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAEA,cAAM,UAAU,OAAO;AAEvB,YAAI;AACF,gBAAM,SAAS,IAAI,WAAW;AAAA,YAC5B,aAAa;AAAA,UACf,CAAC;AAED,cAAI,eAA2C;AAAA,YAC7C,mBAAmB;AAAA,cACjB,yBAAyB,WAAW,SAAS,WAAW;AAAA,YAC1D;AAAA,YACA,MAAM,SAAS;AAAA,YACf,UAAU,SAAS;AAAA,YACnB,uBAAuB,SAAS;AAAA,UAClC;AAGA,cAAI,SAAS,YAAY;AACvB,kBAAM,aAAa,SAAS;AAE5B,gBAAI,YAAY,WAAW,MAAM,GAAG;AAClC,2BAAa,eAAe;AAAA,YAC9B,WAAW,YAAY,WAAW,MAAM,GAAG;AACzC,2BAAa,cAAc;AAAA,YAC7B,OAAO;AAAA,YAEP;AAAA,UACF;AAEA,gBAAM,MAAM,MAAM,OAAO,IAAI,SAAS;AAAA,YACpC;AAAA,UACF;AAGA,gBAAM,iBAAiB;AAAA,YACrB,GAAG;AAAA;AAAA,YACH;AAAA;AAAA,UACF;AAEA,iBAAO;AAAA,YACL,SAAS;AAAA,YACT,WAAW,I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,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CACjG;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@computesdk/runloop",
3
- "version": "1.3.36",
3
+ "version": "1.3.38",
4
4
  "description": "Runloop provider for ComputeSDK - AI-optimized code execution with built-in devtools and debugging",
5
5
  "author": "Runloop",
6
6
  "license": "MIT",
@@ -18,9 +18,9 @@
18
18
  "dist"
19
19
  ],
20
20
  "dependencies": {
21
- "@runloop/api-client": "^1.8.1",
22
- "computesdk": "2.3.0",
23
- "@computesdk/provider": "1.0.28"
21
+ "@runloop/api-client": "^1.11.0",
22
+ "@computesdk/provider": "1.0.30",
23
+ "computesdk": "2.5.0"
24
24
  },
25
25
  "keywords": [
26
26
  "computesdk",