@computesdk/runloop 1.3.50 → 1.3.52
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 +2 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -39,7 +39,8 @@ function getRunloopClient(config) {
|
|
|
39
39
|
const cached = clientCache.get(config);
|
|
40
40
|
if (cached) return cached;
|
|
41
41
|
const client = new import_api_client.RunloopSDK({
|
|
42
|
-
bearerToken: apiKey
|
|
42
|
+
bearerToken: apiKey,
|
|
43
|
+
http2: true
|
|
43
44
|
});
|
|
44
45
|
clientCache.set(config, client);
|
|
45
46
|
return client;
|
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 { RunloopSDK, type Runloop } from \"@runloop/api-client\";\nimport { defineProvider, escapeShellArg } from \"@computesdk/provider\";\nimport type {\n CommandResult,\n SandboxInfo,\n CreateSnapshotOptions,\n ListSnapshotsOptions,\n RunCommandOptions,\n} from \"@computesdk/provider\";\nimport type {\n CreateSandboxOptions,\n FileEntry,\n} from \"computesdk\";\n\n// Define Runloop-specific types\ntype RunloopSnapshot = Runloop.DevboxSnapshotView;\ntype RunloopTemplate = Runloop.BlueprintView;\ntype RunloopSandbox = Runloop.DevboxView & { client: RunloopSDK };\ntype RunloopCreateWaitOptions = Parameters<RunloopSDK[\"api\"][\"devboxes\"][\"createAndAwaitRunning\"]>[1];\ntype RunloopExecuteWaitOptions = Parameters<RunloopSDK[\"api\"][\"devboxes\"][\"executeAndAwaitCompletion\"]>[2];\n\ntype CommandRunner = (\n sandbox: RunloopSandbox,\n command: string,\n options?: RunCommandOptions\n) => Promise<CommandResult>;\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\nconst clientCache = new WeakMap<RunloopConfig, RunloopSDK>();\n\nfunction resolveApiKey(config: RunloopConfig): string {\n return (\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.RUNLOOP_API_KEY) ||\n \"\"\n );\n}\n\nfunction getRunloopClient(config: RunloopConfig): RunloopSDK {\n const apiKey = resolveApiKey(config);\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 cached = clientCache.get(config);\n if (cached) return cached;\n\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n clientCache.set(config, client);\n return client;\n}\n\nfunction longPollOptions<TOptions>(timeoutMs?: number): TOptions | undefined {\n return timeoutMs ? ({ longPoll: { timeoutMs } } as TOptions) : undefined;\n}\n\nfunction optimisticTimeoutSeconds(timeoutMs?: number): number {\n if (!timeoutMs) return 25;\n return Math.max(1, Math.min(25, Math.ceil(timeoutMs / 1000)));\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 RunloopSandbox,\n RunloopConfig,\n RunloopTemplate,\n RunloopSnapshot\n>({\n name: \"runloop\",\n methods: {\n sandbox: {\n create: async (config: RunloopConfig, options?: CreateSandboxOptions) => {\n const timeout = config.timeout;\n\n try {\n const client = getRunloopClient(config);\n\n const {\n timeout: optTimeout,\n envs,\n name,\n metadata,\n templateId,\n snapshotId,\n sandboxId: optSandboxId,\n ports: _ports,\n namespace: _namespace,\n directory: _directory,\n ...providerOptions\n } = options || {};\n\n const effectiveTimeout = optTimeout ?? timeout;\n const keepAliveSeconds = effectiveTimeout\n ? Math.ceil(effectiveTimeout / 1000)\n : 1800;\n\n let devboxParams: Runloop.DevboxCreateParams = {\n launch_parameters: {\n keep_alive_time_seconds: keepAliveSeconds,\n },\n name: name || optSandboxId,\n metadata,\n environment_variables: envs,\n ...providerOptions,\n };\n\n // snapshotId is the canonical cross-provider field — map it directly to snapshot_id.\n // templateId is kept for backwards compatibility: bpt_ prefix → blueprint_id, snp_ prefix → snapshot_id.\n if (snapshotId) {\n devboxParams.snapshot_id = snapshotId;\n } else if (templateId) {\n if (templateId.startsWith(\"bpt_\")) {\n devboxParams.blueprint_id = templateId;\n } else if (templateId.startsWith(\"snp_\")) {\n devboxParams.snapshot_id = templateId;\n }\n }\n\n const dbx = await client.api.devboxes.createAndAwaitRunning(\n devboxParams,\n longPollOptions<RunloopCreateWaitOptions>(effectiveTimeout),\n );\n\n const runloopSandbox: RunloopSandbox = {\n ...dbx,\n client: client\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 getById: async (config: RunloopConfig, sandboxId: string) => {\n try {\n const client = getRunloopClient(config);\n const devbox = await client.api.devboxes.retrieve(sandboxId);\n return {\n sandbox: { ...devbox, client } as RunloopSandbox,\n sandboxId,\n };\n } catch {\n return null;\n }\n },\n\n list: async (config: RunloopConfig) => {\n try {\n const client = getRunloopClient(config);\n const response = await client.api.devboxes.list();\n const devboxes = response.devboxes || [];\n\n return devboxes.map((devbox) => ({\n sandbox: { ...devbox, client } as RunloopSandbox,\n sandboxId: devbox.id,\n }));\n } catch {\n return [];\n }\n },\n\n destroy: async (config: RunloopConfig, sandboxId: string) => {\n try {\n const client = getRunloopClient(config);\n await client.api.devboxes.shutdown(sandboxId);\n } catch {\n // Devbox might already be destroyed or doesn't exist\n }\n },\n\n runCommand: async (\n sandbox: RunloopSandbox,\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 let fullCommand = command;\n\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([k, v]) => `${k}=\"${escapeShellArg(String(v))}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n\n if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n\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 optimistic_timeout: optimisticTimeoutSeconds(options?.timeout),\n }, longPollOptions<RunloopExecuteWaitOptions>(options?.timeout));\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 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 getInfo: async (sandbox): Promise<SandboxInfo> => {\n const devbox = sandbox;\n const keepAliveSecs = devbox.launch_parameters.keep_alive_time_seconds;\n\n return {\n id: devbox.id || \"runloop-unknown\",\n provider: \"runloop\",\n status: devbox.status as 'running' | 'stopped' | 'error',\n createdAt: new Date(devbox.create_time_ms || Date.now()),\n // keep_alive_time_seconds is in seconds; SandboxInfo.timeout is in milliseconds\n timeout: keepAliveSecs ? keepAliveSecs * 1000 : 300000,\n metadata: {\n runloopDevboxId: devbox.id,\n templateId: devbox.blueprint_id || devbox.snapshot_id,\n runtime: 'node',\n ...devbox.metadata,\n },\n };\n },\n\n getUrl: async (\n sandbox: RunloopSandbox,\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.enableTunnel(devbox.id);\n return `https://${options.port}-${tunnel.tunnel_key}.tunnel.runloop.ai`;\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 filesystem: {\n readFile: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<string> => {\n const result = await runCommand(sandbox, `test -f \"${path}\" && base64 < \"${path}\" | tr -d '\\\\n'`);\n if (result.exitCode !== 0) throw new Error(`File not found or unreadable: ${result.stderr}`);\n return Buffer.from(result.stdout, 'base64').toString('utf8');\n },\n\n writeFile: async (sandbox: RunloopSandbox, path: string, content: string, runCommand: CommandRunner): Promise<void> => {\n const encoded = Buffer.from(content).toString('base64');\n const result = await runCommand(sandbox, `sh -c 'echo \"${encoded}\" | base64 -d > \"${path}\"'`);\n if (result.exitCode !== 0) throw new Error(`Failed to write file ${path}: ${result.stderr}`);\n },\n\n mkdir: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n const result = await runCommand(sandbox, `mkdir -p \"${path}\"`);\n if (result.exitCode !== 0) throw new Error(`Failed to create directory ${path}: ${result.stderr}`);\n },\n\n readdir: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<FileEntry[]> => {\n const result = await runCommand(sandbox, `ls -la \"${path}\"`);\n if (result.exitCode !== 0) throw new Error(`Failed to list directory ${path}: ${result.stderr}`);\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 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 (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<boolean> => {\n const result = await runCommand(sandbox, `test -e \"${path}\"`);\n return result.exitCode === 0;\n },\n\n remove: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n const result = await runCommand(sandbox, `rm -rf \"${path}\"`);\n if (result.exitCode !== 0) throw new Error(`Failed to remove ${path}: ${result.stderr}`);\n },\n },\n\n getInstance: (sandbox: RunloopSandbox): RunloopSandbox => sandbox,\n },\n\n template: {\n create: async (config: RunloopConfig, options: CreateBlueprintTemplateOptions | Runloop.BlueprintCreateParams) => {\n const client = getRunloopClient(config);\n return client.api.blueprints.create(options);\n },\n\n list: async (config: RunloopConfig, options?: { limit?: number }) => {\n const client = getRunloopClient(config);\n const listParams: any = {};\n if (options?.limit) listParams.limit = options.limit;\n const response = await client.api.blueprints.list(listParams);\n return response.blueprints || [];\n },\n\n delete: async (config: RunloopConfig, blueprintId: string) => {\n const client = getRunloopClient(config);\n await client.api.blueprints.delete(blueprintId);\n },\n },\n\n snapshot: {\n create: async (config: RunloopConfig, sandboxId: string, options?: CreateSnapshotOptions) => {\n const client = getRunloopClient(config);\n const snapshotParams: any = {};\n if (options?.name) snapshotParams.name = options.name;\n if (options?.metadata) snapshotParams.metadata = options.metadata;\n return client.api.devboxes.snapshotDisk(sandboxId, snapshotParams);\n },\n\n list: async (config: RunloopConfig, options?: ListSnapshotsOptions) => {\n const client = getRunloopClient(config);\n const listParams: any = {};\n if (options?.limit) listParams.limit = options.limit;\n const response = await client.api.devboxes.listDiskSnapshots(listParams);\n return response.snapshots || [];\n },\n\n delete: async (config: RunloopConfig, snapshotId: string) => {\n const client = getRunloopClient(config);\n await client.api.devboxes.deleteDiskSnapshot(snapshotId);\n },\n },\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,wBAAyC;AACzC,sBAA+C;AAoC/C,IAAM,cAAc,oBAAI,QAAmC;AAE3D,SAAS,cAAc,QAA+B;AACpD,SACE,OAAO,UACN,OAAO,YAAY,eAAe,QAAQ,KAAK,mBAChD;AAEJ;AAEA,SAAS,iBAAiB,QAAmC;AAC3D,QAAM,SAAS,cAAc,MAAM;AACnC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,SAAS,YAAY,IAAI,MAAM;AACrC,MAAI,OAAQ,QAAO;AAEnB,QAAM,SAAS,IAAI,6BAAW;AAAA,IAC5B,aAAa;AAAA,EACf,CAAC;AACD,cAAY,IAAI,QAAQ,MAAM;AAC9B,SAAO;AACT;AAEA,SAAS,gBAA0B,WAA0C;AAC3E,SAAO,YAAa,EAAE,UAAU,EAAE,UAAU,EAAE,IAAiB;AACjE;AAEA,SAAS,yBAAyB,WAA4B;AAC5D,MAAI,CAAC,UAAW,QAAO;AACvB,SAAO,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,KAAK,YAAY,GAAI,C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AQ,OAAO,QAAuB,gBAAwB;AAC5D,cAAM,SAAS,iBAAiB,MAAM;AACtC,cAAM,OAAO,IAAI,WAAW,OAAO,WAAW;AAAA,MAChD;AAAA,IACF;AAAA,IAEA,UAAU;AAAA,MACR,QAAQ,OAAO,QAAuB,WAAmB,YAAoC;AAC3F,cAAM,SAAS,iBAAiB,MAAM;AACtC,cAAM,iBAAsB,CAAC;AAC7B,YAAI,SAAS,KAAM,gBAAe,OAAO,QAAQ;AACjD,YAAI,SAAS,SAAU,gBAAe,WAAW,QAAQ;AACzD,eAAO,OAAO,IAAI,SAAS,aAAa,WAAW,cAAc;AAAA,MACnE;AAAA,MAEA,MAAM,OAAO,QAAuB,YAAmC;AACrE,cAAM,SAAS,iBAAiB,MAAM;AACtC,cAAM,aAAkB,CAAC;AACzB,YAAI,SAAS,MAAO,YAAW,QAAQ,QAAQ;AAC/C,cAAM,WAAW,MAAM,OAAO,IAAI,SAAS,kBAAkB,UAAU;AACvE,eAAO,SAAS,aAAa,CAAC;AAAA,MAChC;AAAA,MAEA,QAAQ,OAAO,QAAuB,eAAuB;AAC3D,cAAM,SAAS,iBAAiB,MAAM;AACtC,cAAM,OAAO,IAAI,SAAS,mBAAmB,UAAU;AAAA,MACzD;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 CommandResult,\n SandboxInfo,\n CreateSnapshotOptions,\n ListSnapshotsOptions,\n RunCommandOptions,\n} from \"@computesdk/provider\";\nimport type {\n CreateSandboxOptions,\n FileEntry,\n} from \"computesdk\";\n\n// Define Runloop-specific types\ntype RunloopSnapshot = Runloop.DevboxSnapshotView;\ntype RunloopTemplate = Runloop.BlueprintView;\ntype RunloopSandbox = Runloop.DevboxView & { client: RunloopSDK };\ntype RunloopCreateWaitOptions = Parameters<RunloopSDK[\"api\"][\"devboxes\"][\"createAndAwaitRunning\"]>[1];\ntype RunloopExecuteWaitOptions = Parameters<RunloopSDK[\"api\"][\"devboxes\"][\"executeAndAwaitCompletion\"]>[2];\n\ntype CommandRunner = (\n sandbox: RunloopSandbox,\n command: string,\n options?: RunCommandOptions\n) => Promise<CommandResult>;\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\nconst clientCache = new WeakMap<RunloopConfig, RunloopSDK>();\n\nfunction resolveApiKey(config: RunloopConfig): string {\n return (\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.RUNLOOP_API_KEY) ||\n \"\"\n );\n}\n\nfunction getRunloopClient(config: RunloopConfig): RunloopSDK {\n const apiKey = resolveApiKey(config);\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 cached = clientCache.get(config);\n if (cached) return cached;\n\n const client = new RunloopSDK({\n bearerToken: apiKey,\n http2: true,\n });\n clientCache.set(config, client);\n return client;\n}\n\nfunction longPollOptions<TOptions>(timeoutMs?: number): TOptions | undefined {\n return timeoutMs ? ({ longPoll: { timeoutMs } } as TOptions) : undefined;\n}\n\nfunction optimisticTimeoutSeconds(timeoutMs?: number): number {\n if (!timeoutMs) return 25;\n return Math.max(1, Math.min(25, Math.ceil(timeoutMs / 1000)));\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 RunloopSandbox,\n RunloopConfig,\n RunloopTemplate,\n RunloopSnapshot\n>({\n name: \"runloop\",\n methods: {\n sandbox: {\n create: async (config: RunloopConfig, options?: CreateSandboxOptions) => {\n const timeout = config.timeout;\n\n try {\n const client = getRunloopClient(config);\n\n const {\n timeout: optTimeout,\n envs,\n name,\n metadata,\n templateId,\n snapshotId,\n sandboxId: optSandboxId,\n ports: _ports,\n namespace: _namespace,\n directory: _directory,\n ...providerOptions\n } = options || {};\n\n const effectiveTimeout = optTimeout ?? timeout;\n const keepAliveSeconds = effectiveTimeout\n ? Math.ceil(effectiveTimeout / 1000)\n : 1800;\n\n let devboxParams: Runloop.DevboxCreateParams = {\n launch_parameters: {\n keep_alive_time_seconds: keepAliveSeconds,\n },\n name: name || optSandboxId,\n metadata,\n environment_variables: envs,\n ...providerOptions,\n };\n\n // snapshotId is the canonical cross-provider field — map it directly to snapshot_id.\n // templateId is kept for backwards compatibility: bpt_ prefix → blueprint_id, snp_ prefix → snapshot_id.\n if (snapshotId) {\n devboxParams.snapshot_id = snapshotId;\n } else if (templateId) {\n if (templateId.startsWith(\"bpt_\")) {\n devboxParams.blueprint_id = templateId;\n } else if (templateId.startsWith(\"snp_\")) {\n devboxParams.snapshot_id = templateId;\n }\n }\n\n const dbx = await client.api.devboxes.createAndAwaitRunning(\n devboxParams,\n longPollOptions<RunloopCreateWaitOptions>(effectiveTimeout),\n );\n\n const runloopSandbox: RunloopSandbox = {\n ...dbx,\n client: client\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 getById: async (config: RunloopConfig, sandboxId: string) => {\n try {\n const client = getRunloopClient(config);\n const devbox = await client.api.devboxes.retrieve(sandboxId);\n return {\n sandbox: { ...devbox, client } as RunloopSandbox,\n sandboxId,\n };\n } catch {\n return null;\n }\n },\n\n list: async (config: RunloopConfig) => {\n try {\n const client = getRunloopClient(config);\n const response = await client.api.devboxes.list();\n const devboxes = response.devboxes || [];\n\n return devboxes.map((devbox) => ({\n sandbox: { ...devbox, client } as RunloopSandbox,\n sandboxId: devbox.id,\n }));\n } catch {\n return [];\n }\n },\n\n destroy: async (config: RunloopConfig, sandboxId: string) => {\n try {\n const client = getRunloopClient(config);\n await client.api.devboxes.shutdown(sandboxId);\n } catch {\n // Devbox might already be destroyed or doesn't exist\n }\n },\n\n runCommand: async (\n sandbox: RunloopSandbox,\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 let fullCommand = command;\n\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([k, v]) => `${k}=\"${escapeShellArg(String(v))}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n\n if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n\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 optimistic_timeout: optimisticTimeoutSeconds(options?.timeout),\n }, longPollOptions<RunloopExecuteWaitOptions>(options?.timeout));\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 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 getInfo: async (sandbox): Promise<SandboxInfo> => {\n const devbox = sandbox;\n const keepAliveSecs = devbox.launch_parameters.keep_alive_time_seconds;\n\n return {\n id: devbox.id || \"runloop-unknown\",\n provider: \"runloop\",\n status: devbox.status as 'running' | 'stopped' | 'error',\n createdAt: new Date(devbox.create_time_ms || Date.now()),\n // keep_alive_time_seconds is in seconds; SandboxInfo.timeout is in milliseconds\n timeout: keepAliveSecs ? keepAliveSecs * 1000 : 300000,\n metadata: {\n runloopDevboxId: devbox.id,\n templateId: devbox.blueprint_id || devbox.snapshot_id,\n runtime: 'node',\n ...devbox.metadata,\n },\n };\n },\n\n getUrl: async (\n sandbox: RunloopSandbox,\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.enableTunnel(devbox.id);\n return `https://${options.port}-${tunnel.tunnel_key}.tunnel.runloop.ai`;\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 filesystem: {\n readFile: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<string> => {\n const result = await runCommand(sandbox, `test -f \"${path}\" && base64 < \"${path}\" | tr -d '\\\\n'`);\n if (result.exitCode !== 0) throw new Error(`File not found or unreadable: ${result.stderr}`);\n return Buffer.from(result.stdout, 'base64').toString('utf8');\n },\n\n writeFile: async (sandbox: RunloopSandbox, path: string, content: string, runCommand: CommandRunner): Promise<void> => {\n const encoded = Buffer.from(content).toString('base64');\n const result = await runCommand(sandbox, `sh -c 'echo \"${encoded}\" | base64 -d > \"${path}\"'`);\n if (result.exitCode !== 0) throw new Error(`Failed to write file ${path}: ${result.stderr}`);\n },\n\n mkdir: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n const result = await runCommand(sandbox, `mkdir -p \"${path}\"`);\n if (result.exitCode !== 0) throw new Error(`Failed to create directory ${path}: ${result.stderr}`);\n },\n\n readdir: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<FileEntry[]> => {\n const result = await runCommand(sandbox, `ls -la \"${path}\"`);\n if (result.exitCode !== 0) throw new Error(`Failed to list directory ${path}: ${result.stderr}`);\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 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 (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<boolean> => {\n const result = await runCommand(sandbox, `test -e \"${path}\"`);\n return result.exitCode === 0;\n },\n\n remove: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n const result = await runCommand(sandbox, `rm -rf \"${path}\"`);\n if (result.exitCode !== 0) throw new Error(`Failed to remove ${path}: ${result.stderr}`);\n },\n },\n\n getInstance: (sandbox: RunloopSandbox): RunloopSandbox => sandbox,\n },\n\n template: {\n create: async (config: RunloopConfig, options: CreateBlueprintTemplateOptions | Runloop.BlueprintCreateParams) => {\n const client = getRunloopClient(config);\n return client.api.blueprints.create(options);\n },\n\n list: async (config: RunloopConfig, options?: { limit?: number }) => {\n const client = getRunloopClient(config);\n const listParams: any = {};\n if (options?.limit) listParams.limit = options.limit;\n const response = await client.api.blueprints.list(listParams);\n return response.blueprints || [];\n },\n\n delete: async (config: RunloopConfig, blueprintId: string) => {\n const client = getRunloopClient(config);\n await client.api.blueprints.delete(blueprintId);\n },\n },\n\n snapshot: {\n create: async (config: RunloopConfig, sandboxId: string, options?: CreateSnapshotOptions) => {\n const client = getRunloopClient(config);\n const snapshotParams: any = {};\n if (options?.name) snapshotParams.name = options.name;\n if (options?.metadata) snapshotParams.metadata = options.metadata;\n return client.api.devboxes.snapshotDisk(sandboxId, snapshotParams);\n },\n\n list: async (config: RunloopConfig, options?: ListSnapshotsOptions) => {\n const client = getRunloopClient(config);\n const listParams: any = {};\n if (options?.limit) listParams.limit = options.limit;\n const response = await client.api.devboxes.listDiskSnapshots(listParams);\n return response.snapshots || [];\n },\n\n delete: async (config: RunloopConfig, snapshotId: string) => {\n const client = getRunloopClient(config);\n await client.api.devboxes.deleteDiskSnapshot(snapshotId);\n },\n },\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,wBAAyC;AACzC,sBAA+C;AAoC/C,IAAM,cAAc,oBAAI,QAAmC;AAE3D,SAAS,cAAc,QAA+B;AACpD,SACE,OAAO,UACN,OAAO,YAAY,eAAe,QAAQ,KAAK,mBAChD;AAEJ;AAEA,SAAS,iBAAiB,QAAmC;AAC3D,QAAM,SAAS,cAAc,MAAM;AACnC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,SAAS,YAAY,IAAI,MAAM;AACrC,MAAI,OAAQ,QAAO;AAEnB,QAAM,SAAS,IAAI,6BAAW;AAAA,IAC5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) return cached;
|
|
17
17
|
const client = new RunloopSDK({
|
|
18
|
-
bearerToken: apiKey
|
|
18
|
+
bearerToken: apiKey,
|
|
19
|
+
http2: true
|
|
19
20
|
});
|
|
20
21
|
clientCache.set(config, client);
|
|
21
22
|
return client;
|
package/dist/index.mjs.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 { RunloopSDK, type Runloop } from \"@runloop/api-client\";\nimport { defineProvider, escapeShellArg } from \"@computesdk/provider\";\nimport type {\n CommandResult,\n SandboxInfo,\n CreateSnapshotOptions,\n ListSnapshotsOptions,\n RunCommandOptions,\n} from \"@computesdk/provider\";\nimport type {\n CreateSandboxOptions,\n FileEntry,\n} from \"computesdk\";\n\n// Define Runloop-specific types\ntype RunloopSnapshot = Runloop.DevboxSnapshotView;\ntype RunloopTemplate = Runloop.BlueprintView;\ntype RunloopSandbox = Runloop.DevboxView & { client: RunloopSDK };\ntype RunloopCreateWaitOptions = Parameters<RunloopSDK[\"api\"][\"devboxes\"][\"createAndAwaitRunning\"]>[1];\ntype RunloopExecuteWaitOptions = Parameters<RunloopSDK[\"api\"][\"devboxes\"][\"executeAndAwaitCompletion\"]>[2];\n\ntype CommandRunner = (\n sandbox: RunloopSandbox,\n command: string,\n options?: RunCommandOptions\n) => Promise<CommandResult>;\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\nconst clientCache = new WeakMap<RunloopConfig, RunloopSDK>();\n\nfunction resolveApiKey(config: RunloopConfig): string {\n return (\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.RUNLOOP_API_KEY) ||\n \"\"\n );\n}\n\nfunction getRunloopClient(config: RunloopConfig): RunloopSDK {\n const apiKey = resolveApiKey(config);\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 cached = clientCache.get(config);\n if (cached) return cached;\n\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n clientCache.set(config, client);\n return client;\n}\n\nfunction longPollOptions<TOptions>(timeoutMs?: number): TOptions | undefined {\n return timeoutMs ? ({ longPoll: { timeoutMs } } as TOptions) : undefined;\n}\n\nfunction optimisticTimeoutSeconds(timeoutMs?: number): number {\n if (!timeoutMs) return 25;\n return Math.max(1, Math.min(25, Math.ceil(timeoutMs / 1000)));\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 RunloopSandbox,\n RunloopConfig,\n RunloopTemplate,\n RunloopSnapshot\n>({\n name: \"runloop\",\n methods: {\n sandbox: {\n create: async (config: RunloopConfig, options?: CreateSandboxOptions) => {\n const timeout = config.timeout;\n\n try {\n const client = getRunloopClient(config);\n\n const {\n timeout: optTimeout,\n envs,\n name,\n metadata,\n templateId,\n snapshotId,\n sandboxId: optSandboxId,\n ports: _ports,\n namespace: _namespace,\n directory: _directory,\n ...providerOptions\n } = options || {};\n\n const effectiveTimeout = optTimeout ?? timeout;\n const keepAliveSeconds = effectiveTimeout\n ? Math.ceil(effectiveTimeout / 1000)\n : 1800;\n\n let devboxParams: Runloop.DevboxCreateParams = {\n launch_parameters: {\n keep_alive_time_seconds: keepAliveSeconds,\n },\n name: name || optSandboxId,\n metadata,\n environment_variables: envs,\n ...providerOptions,\n };\n\n // snapshotId is the canonical cross-provider field — map it directly to snapshot_id.\n // templateId is kept for backwards compatibility: bpt_ prefix → blueprint_id, snp_ prefix → snapshot_id.\n if (snapshotId) {\n devboxParams.snapshot_id = snapshotId;\n } else if (templateId) {\n if (templateId.startsWith(\"bpt_\")) {\n devboxParams.blueprint_id = templateId;\n } else if (templateId.startsWith(\"snp_\")) {\n devboxParams.snapshot_id = templateId;\n }\n }\n\n const dbx = await client.api.devboxes.createAndAwaitRunning(\n devboxParams,\n longPollOptions<RunloopCreateWaitOptions>(effectiveTimeout),\n );\n\n const runloopSandbox: RunloopSandbox = {\n ...dbx,\n client: client\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 getById: async (config: RunloopConfig, sandboxId: string) => {\n try {\n const client = getRunloopClient(config);\n const devbox = await client.api.devboxes.retrieve(sandboxId);\n return {\n sandbox: { ...devbox, client } as RunloopSandbox,\n sandboxId,\n };\n } catch {\n return null;\n }\n },\n\n list: async (config: RunloopConfig) => {\n try {\n const client = getRunloopClient(config);\n const response = await client.api.devboxes.list();\n const devboxes = response.devboxes || [];\n\n return devboxes.map((devbox) => ({\n sandbox: { ...devbox, client } as RunloopSandbox,\n sandboxId: devbox.id,\n }));\n } catch {\n return [];\n }\n },\n\n destroy: async (config: RunloopConfig, sandboxId: string) => {\n try {\n const client = getRunloopClient(config);\n await client.api.devboxes.shutdown(sandboxId);\n } catch {\n // Devbox might already be destroyed or doesn't exist\n }\n },\n\n runCommand: async (\n sandbox: RunloopSandbox,\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 let fullCommand = command;\n\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([k, v]) => `${k}=\"${escapeShellArg(String(v))}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n\n if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n\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 optimistic_timeout: optimisticTimeoutSeconds(options?.timeout),\n }, longPollOptions<RunloopExecuteWaitOptions>(options?.timeout));\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 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 getInfo: async (sandbox): Promise<SandboxInfo> => {\n const devbox = sandbox;\n const keepAliveSecs = devbox.launch_parameters.keep_alive_time_seconds;\n\n return {\n id: devbox.id || \"runloop-unknown\",\n provider: \"runloop\",\n status: devbox.status as 'running' | 'stopped' | 'error',\n createdAt: new Date(devbox.create_time_ms || Date.now()),\n // keep_alive_time_seconds is in seconds; SandboxInfo.timeout is in milliseconds\n timeout: keepAliveSecs ? keepAliveSecs * 1000 : 300000,\n metadata: {\n runloopDevboxId: devbox.id,\n templateId: devbox.blueprint_id || devbox.snapshot_id,\n runtime: 'node',\n ...devbox.metadata,\n },\n };\n },\n\n getUrl: async (\n sandbox: RunloopSandbox,\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.enableTunnel(devbox.id);\n return `https://${options.port}-${tunnel.tunnel_key}.tunnel.runloop.ai`;\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 filesystem: {\n readFile: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<string> => {\n const result = await runCommand(sandbox, `test -f \"${path}\" && base64 < \"${path}\" | tr -d '\\\\n'`);\n if (result.exitCode !== 0) throw new Error(`File not found or unreadable: ${result.stderr}`);\n return Buffer.from(result.stdout, 'base64').toString('utf8');\n },\n\n writeFile: async (sandbox: RunloopSandbox, path: string, content: string, runCommand: CommandRunner): Promise<void> => {\n const encoded = Buffer.from(content).toString('base64');\n const result = await runCommand(sandbox, `sh -c 'echo \"${encoded}\" | base64 -d > \"${path}\"'`);\n if (result.exitCode !== 0) throw new Error(`Failed to write file ${path}: ${result.stderr}`);\n },\n\n mkdir: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n const result = await runCommand(sandbox, `mkdir -p \"${path}\"`);\n if (result.exitCode !== 0) throw new Error(`Failed to create directory ${path}: ${result.stderr}`);\n },\n\n readdir: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<FileEntry[]> => {\n const result = await runCommand(sandbox, `ls -la \"${path}\"`);\n if (result.exitCode !== 0) throw new Error(`Failed to list directory ${path}: ${result.stderr}`);\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 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 (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<boolean> => {\n const result = await runCommand(sandbox, `test -e \"${path}\"`);\n return result.exitCode === 0;\n },\n\n remove: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n const result = await runCommand(sandbox, `rm -rf \"${path}\"`);\n if (result.exitCode !== 0) throw new Error(`Failed to remove ${path}: ${result.stderr}`);\n },\n },\n\n getInstance: (sandbox: RunloopSandbox): RunloopSandbox => sandbox,\n },\n\n template: {\n create: async (config: RunloopConfig, options: CreateBlueprintTemplateOptions | Runloop.BlueprintCreateParams) => {\n const client = getRunloopClient(config);\n return client.api.blueprints.create(options);\n },\n\n list: async (config: RunloopConfig, options?: { limit?: number }) => {\n const client = getRunloopClient(config);\n const listParams: any = {};\n if (options?.limit) listParams.limit = options.limit;\n const response = await client.api.blueprints.list(listParams);\n return response.blueprints || [];\n },\n\n delete: async (config: RunloopConfig, blueprintId: string) => {\n const client = getRunloopClient(config);\n await client.api.blueprints.delete(blueprintId);\n },\n },\n\n snapshot: {\n create: async (config: RunloopConfig, sandboxId: string, options?: CreateSnapshotOptions) => {\n const client = getRunloopClient(config);\n const snapshotParams: any = {};\n if (options?.name) snapshotParams.name = options.name;\n if (options?.metadata) snapshotParams.metadata = options.metadata;\n return client.api.devboxes.snapshotDisk(sandboxId, snapshotParams);\n },\n\n list: async (config: RunloopConfig, options?: ListSnapshotsOptions) => {\n const client = getRunloopClient(config);\n const listParams: any = {};\n if (options?.limit) listParams.limit = options.limit;\n const response = await client.api.devboxes.listDiskSnapshots(listParams);\n return response.snapshots || [];\n },\n\n delete: async (config: RunloopConfig, snapshotId: string) => {\n const client = getRunloopClient(config);\n await client.api.devboxes.deleteDiskSnapshot(snapshotId);\n },\n },\n },\n});\n"],"mappings":";AAOA,SAAS,kBAAgC;AACzC,SAAS,gBAAgB,sBAAsB;AAoC/C,IAAM,cAAc,oBAAI,QAAmC;AAE3D,SAAS,cAAc,QAA+B;AACpD,SACE,OAAO,UACN,OAAO,YAAY,eAAe,QAAQ,KAAK,mBAChD;AAEJ;AAEA,SAAS,iBAAiB,QAAmC;AAC3D,QAAM,SAAS,cAAc,MAAM;AACnC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,SAAS,YAAY,IAAI,MAAM;AACrC,MAAI,OAAQ,QAAO;AAEnB,QAAM,SAAS,IAAI,WAAW;AAAA,IAC5B,aAAa;AAAA,EACf,CAAC;AACD,cAAY,IAAI,QAAQ,MAAM;AAC9B,SAAO;AACT;AAEA,SAAS,gBAA0B,WAA0C;AAC3E,SAAO,YAAa,EAAE,UAAU,EAAE,UAAU,EAAE,IAAiB;AACjE;AAEA,SAAS,yBAAyB,WAA4B;AAC5D,MAAI,CAAC,UAAW,QAAO;AACvB,SAAO,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,KAAK,YAAY,GAAI,CAAC,CAAC;AAC9D;AAmDO,IAAM,UAAU,eAKrB;AAAA,EACA,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA,MACP,QAAQ,OAAO,QAAuB,YAAmC;AACvE,cAAM,UAAU,OAAO;AAEvB,YAAI;AACF,gBAAM,SAAS,iBAAiB,MAAM;AAEtC,gBAAM;AAAA,YACJ,SAAS;AAAA,YACT;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,WAAW;AAAA,YACX,OAAO;AAAA,YACP,WAAW;AAAA,YACX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AO,IAAI,SAAS,aAAa,WAAW,cAAc;AAAA,MACnE;AAAA,MAEA,MAAM,OAAO,QAAuB,YAAmC;AACrE,cAAM,SAAS,iBAAiB,MAAM;AACtC,cAAM,aAAkB,CAAC;AACzB,YAAI,SAAS,MAAO,YAAW,QAAQ,QAAQ;AAC/C,cAAM,WAAW,MAAM,OAAO,IAAI,SAAS,kBAAkB,UAAU;AACvE,eAAO,SAAS,aAAa,CAAC;AAAA,MAChC;AAAA,MAEA,QAAQ,OAAO,QAAuB,eAAuB;AAC3D,cAAM,SAAS,iBAAiB,MAAM;AACtC,cAAM,OAAO,IAAI,SAAS,mBAAmB,UAAU;AAAA,MACzD;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 CommandResult,\n SandboxInfo,\n CreateSnapshotOptions,\n ListSnapshotsOptions,\n RunCommandOptions,\n} from \"@computesdk/provider\";\nimport type {\n CreateSandboxOptions,\n FileEntry,\n} from \"computesdk\";\n\n// Define Runloop-specific types\ntype RunloopSnapshot = Runloop.DevboxSnapshotView;\ntype RunloopTemplate = Runloop.BlueprintView;\ntype RunloopSandbox = Runloop.DevboxView & { client: RunloopSDK };\ntype RunloopCreateWaitOptions = Parameters<RunloopSDK[\"api\"][\"devboxes\"][\"createAndAwaitRunning\"]>[1];\ntype RunloopExecuteWaitOptions = Parameters<RunloopSDK[\"api\"][\"devboxes\"][\"executeAndAwaitCompletion\"]>[2];\n\ntype CommandRunner = (\n sandbox: RunloopSandbox,\n command: string,\n options?: RunCommandOptions\n) => Promise<CommandResult>;\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\nconst clientCache = new WeakMap<RunloopConfig, RunloopSDK>();\n\nfunction resolveApiKey(config: RunloopConfig): string {\n return (\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.RUNLOOP_API_KEY) ||\n \"\"\n );\n}\n\nfunction getRunloopClient(config: RunloopConfig): RunloopSDK {\n const apiKey = resolveApiKey(config);\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 cached = clientCache.get(config);\n if (cached) return cached;\n\n const client = new RunloopSDK({\n bearerToken: apiKey,\n http2: true,\n });\n clientCache.set(config, client);\n return client;\n}\n\nfunction longPollOptions<TOptions>(timeoutMs?: number): TOptions | undefined {\n return timeoutMs ? ({ longPoll: { timeoutMs } } as TOptions) : undefined;\n}\n\nfunction optimisticTimeoutSeconds(timeoutMs?: number): number {\n if (!timeoutMs) return 25;\n return Math.max(1, Math.min(25, Math.ceil(timeoutMs / 1000)));\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 RunloopSandbox,\n RunloopConfig,\n RunloopTemplate,\n RunloopSnapshot\n>({\n name: \"runloop\",\n methods: {\n sandbox: {\n create: async (config: RunloopConfig, options?: CreateSandboxOptions) => {\n const timeout = config.timeout;\n\n try {\n const client = getRunloopClient(config);\n\n const {\n timeout: optTimeout,\n envs,\n name,\n metadata,\n templateId,\n snapshotId,\n sandboxId: optSandboxId,\n ports: _ports,\n namespace: _namespace,\n directory: _directory,\n ...providerOptions\n } = options || {};\n\n const effectiveTimeout = optTimeout ?? timeout;\n const keepAliveSeconds = effectiveTimeout\n ? Math.ceil(effectiveTimeout / 1000)\n : 1800;\n\n let devboxParams: Runloop.DevboxCreateParams = {\n launch_parameters: {\n keep_alive_time_seconds: keepAliveSeconds,\n },\n name: name || optSandboxId,\n metadata,\n environment_variables: envs,\n ...providerOptions,\n };\n\n // snapshotId is the canonical cross-provider field — map it directly to snapshot_id.\n // templateId is kept for backwards compatibility: bpt_ prefix → blueprint_id, snp_ prefix → snapshot_id.\n if (snapshotId) {\n devboxParams.snapshot_id = snapshotId;\n } else if (templateId) {\n if (templateId.startsWith(\"bpt_\")) {\n devboxParams.blueprint_id = templateId;\n } else if (templateId.startsWith(\"snp_\")) {\n devboxParams.snapshot_id = templateId;\n }\n }\n\n const dbx = await client.api.devboxes.createAndAwaitRunning(\n devboxParams,\n longPollOptions<RunloopCreateWaitOptions>(effectiveTimeout),\n );\n\n const runloopSandbox: RunloopSandbox = {\n ...dbx,\n client: client\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 getById: async (config: RunloopConfig, sandboxId: string) => {\n try {\n const client = getRunloopClient(config);\n const devbox = await client.api.devboxes.retrieve(sandboxId);\n return {\n sandbox: { ...devbox, client } as RunloopSandbox,\n sandboxId,\n };\n } catch {\n return null;\n }\n },\n\n list: async (config: RunloopConfig) => {\n try {\n const client = getRunloopClient(config);\n const response = await client.api.devboxes.list();\n const devboxes = response.devboxes || [];\n\n return devboxes.map((devbox) => ({\n sandbox: { ...devbox, client } as RunloopSandbox,\n sandboxId: devbox.id,\n }));\n } catch {\n return [];\n }\n },\n\n destroy: async (config: RunloopConfig, sandboxId: string) => {\n try {\n const client = getRunloopClient(config);\n await client.api.devboxes.shutdown(sandboxId);\n } catch {\n // Devbox might already be destroyed or doesn't exist\n }\n },\n\n runCommand: async (\n sandbox: RunloopSandbox,\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 let fullCommand = command;\n\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([k, v]) => `${k}=\"${escapeShellArg(String(v))}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n\n if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n\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 optimistic_timeout: optimisticTimeoutSeconds(options?.timeout),\n }, longPollOptions<RunloopExecuteWaitOptions>(options?.timeout));\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 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 getInfo: async (sandbox): Promise<SandboxInfo> => {\n const devbox = sandbox;\n const keepAliveSecs = devbox.launch_parameters.keep_alive_time_seconds;\n\n return {\n id: devbox.id || \"runloop-unknown\",\n provider: \"runloop\",\n status: devbox.status as 'running' | 'stopped' | 'error',\n createdAt: new Date(devbox.create_time_ms || Date.now()),\n // keep_alive_time_seconds is in seconds; SandboxInfo.timeout is in milliseconds\n timeout: keepAliveSecs ? keepAliveSecs * 1000 : 300000,\n metadata: {\n runloopDevboxId: devbox.id,\n templateId: devbox.blueprint_id || devbox.snapshot_id,\n runtime: 'node',\n ...devbox.metadata,\n },\n };\n },\n\n getUrl: async (\n sandbox: RunloopSandbox,\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.enableTunnel(devbox.id);\n return `https://${options.port}-${tunnel.tunnel_key}.tunnel.runloop.ai`;\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 filesystem: {\n readFile: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<string> => {\n const result = await runCommand(sandbox, `test -f \"${path}\" && base64 < \"${path}\" | tr -d '\\\\n'`);\n if (result.exitCode !== 0) throw new Error(`File not found or unreadable: ${result.stderr}`);\n return Buffer.from(result.stdout, 'base64').toString('utf8');\n },\n\n writeFile: async (sandbox: RunloopSandbox, path: string, content: string, runCommand: CommandRunner): Promise<void> => {\n const encoded = Buffer.from(content).toString('base64');\n const result = await runCommand(sandbox, `sh -c 'echo \"${encoded}\" | base64 -d > \"${path}\"'`);\n if (result.exitCode !== 0) throw new Error(`Failed to write file ${path}: ${result.stderr}`);\n },\n\n mkdir: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n const result = await runCommand(sandbox, `mkdir -p \"${path}\"`);\n if (result.exitCode !== 0) throw new Error(`Failed to create directory ${path}: ${result.stderr}`);\n },\n\n readdir: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<FileEntry[]> => {\n const result = await runCommand(sandbox, `ls -la \"${path}\"`);\n if (result.exitCode !== 0) throw new Error(`Failed to list directory ${path}: ${result.stderr}`);\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 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 (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<boolean> => {\n const result = await runCommand(sandbox, `test -e \"${path}\"`);\n return result.exitCode === 0;\n },\n\n remove: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n const result = await runCommand(sandbox, `rm -rf \"${path}\"`);\n if (result.exitCode !== 0) throw new Error(`Failed to remove ${path}: ${result.stderr}`);\n },\n },\n\n getInstance: (sandbox: RunloopSandbox): RunloopSandbox => sandbox,\n },\n\n template: {\n create: async (config: RunloopConfig, options: CreateBlueprintTemplateOptions | Runloop.BlueprintCreateParams) => {\n const client = getRunloopClient(config);\n return client.api.blueprints.create(options);\n },\n\n list: async (config: RunloopConfig, options?: { limit?: number }) => {\n const client = getRunloopClient(config);\n const listParams: any = {};\n if (options?.limit) listParams.limit = options.limit;\n const response = await client.api.blueprints.list(listParams);\n return response.blueprints || [];\n },\n\n delete: async (config: RunloopConfig, blueprintId: string) => {\n const client = getRunloopClient(config);\n await client.api.blueprints.delete(blueprintId);\n },\n },\n\n snapshot: {\n create: async (config: RunloopConfig, sandboxId: string, options?: CreateSnapshotOptions) => {\n const client = getRunloopClient(config);\n const snapshotParams: any = {};\n if (options?.name) snapshotParams.name = options.name;\n if (options?.metadata) snapshotParams.metadata = options.metadata;\n return client.api.devboxes.snapshotDisk(sandboxId, snapshotParams);\n },\n\n list: async (config: RunloopConfig, options?: ListSnapshotsOptions) => {\n const client = getRunloopClient(config);\n const listParams: any = {};\n if (options?.limit) listParams.limit = options.limit;\n const response = await client.api.devboxes.listDiskSnapshots(listParams);\n return response.snapshots || [];\n },\n\n delete: async (config: RunloopConfig, snapshotId: string) => {\n const client = getRunloopClient(config);\n await client.api.devboxes.deleteDiskSnapshot(snapshotId);\n },\n },\n },\n});\n"],"mappings":";AAOA,SAAS,kBAAgC;AACzC,SAAS,gBAAgB,sBAAsB;AAoC/C,IAAM,cAAc,oBAAI,QAAmC;AAE3D,SAAS,cAAc,QAA+B;AACpD,SACE,OAAO,UACN,OAAO,YAAY,eAAe,QAAQ,KAAK,mBAChD;AAEJ;AAEA,SAAS,iBAAiB,QAAmC;AAC3D,QAAM,SAAS,cAAc,MAAM;AACnC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,SAAS,YAAY,IAAI,MAAM;AACrC,MAAI,OAAQ,QAAO;AAEnB,QAAM,SAAS,IAAI,WAAW;AAAA,IAC5B,aAAa;AAAA,IACb,OAAO;AAAA,EACT,CAAC;AACD,cAAY,IAAI,QAAQ,MAAM;AAC9B,SAAO;AACT;AAEA,SAAS,gBAA0B,WAA0C;AAC3E,SAAO,YAAa,EAAE,UAAU,EAAE,UAAU,EAAE,IAAiB;AACjE;AAEA,SAAS,yBAAyB,WAA4B;AAC5D,MAAI,CAAC,UAAW,QAAO;AACvB,SAAO,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,KAAK,YAAY,GAAI,CAAC,CAAC;AAC9D;AAmDO,IAAM,UAAU,eAKrB;AAAA,EACA,MAAM;AAAA,EACN,SA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IAAI,WAAW,OAAO,WAAW;AAAA,MAChD;AAAA,IACF;AAAA,IAEA,UAAU;AAAA,MACR,QAAQ,OAAO,QAAuB,WAAmB,YAAoC;AAC3F,cAAM,SAAS,iBAAiB,MAAM;AACtC,cAAM,iBAAsB,CAAC;AAC7B,YAAI,SAAS,KAAM,gBAAe,OAAO,QAAQ;AACjD,YAAI,SAAS,SAAU,gBAAe,WAAW,QAAQ;AACzD,eAAO,OAAO,IAAI,SAAS,aAAa,WAAW,cAAc;AAAA,MACnE;AAAA,MAEA,MAAM,OAAO,QAAuB,YAAmC;AACrE,cAAM,SAAS,iBAAiB,MAAM;AACtC,cAAM,aAAkB,CAAC;AACzB,YAAI,SAAS,MAAO,YAAW,QAAQ,QAAQ;AAC/C,cAAM,WAAW,MAAM,OAAO,IAAI,SAAS,kBAAkB,UAAU;AACvE,eAAO,SAAS,aAAa,CAAC;AAAA,MAChC;AAAA,MAEA,QAAQ,OAAO,QAAuB,eAAuB;AAC3D,cAAM,SAAS,iBAAiB,MAAM;AACtC,cAAM,OAAO,IAAI,SAAS,mBAAmB,UAAU;AAAA,MACzD;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.
|
|
3
|
+
"version": "1.3.52",
|
|
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.
|
|
22
|
-
"@computesdk/provider": "2.1.
|
|
23
|
-
"computesdk": "4.1.
|
|
21
|
+
"@runloop/api-client": "^1.23.0",
|
|
22
|
+
"@computesdk/provider": "2.1.3",
|
|
23
|
+
"computesdk": "4.1.3"
|
|
24
24
|
},
|
|
25
25
|
"keywords": [
|
|
26
26
|
"computesdk",
|