@computesdk/runloop 1.3.79 → 1.3.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @computesdk/runloop
|
|
2
|
+
|
|
3
|
+
Runloop sandbox adapter for ComputeSDK. Run commands and work with files in Runloop Devboxes.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install computesdk @computesdk/runloop
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Configure the `runloop` adapter with `RUNLOOP_API_KEY`.
|
|
12
|
+
|
|
13
|
+
See the [direct provider setup guide](https://github.com/computesdk/computesdk/blob/main/OPEN_SOURCE.md#direct-provider-mode) to use the adapter with `compute.setConfig()`.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
[Sandbox providers](https://www.computesdk.com/providers/sandboxes) · [Sandbox Router](https://www.computesdk.com/sandbox-router)
|
package/dist/index.js
CHANGED
|
@@ -330,8 +330,41 @@ async function runCommandWithErrors(sandbox, command, options) {
|
|
|
330
330
|
);
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
|
+
var STANDARD_DISK_GIB = { xs: 4, sm: 4, md: 8, lg: 16, xl: 16, "2xl": 16 };
|
|
334
|
+
var MIN_MEMORY_MIB_PER_VCPU = 2048;
|
|
335
|
+
var NATIVE_SIZE_FIELDS = [
|
|
336
|
+
"resource_size_request",
|
|
337
|
+
"custom_cpu_cores",
|
|
338
|
+
"custom_gb_memory",
|
|
339
|
+
"custom_disk_size"
|
|
340
|
+
];
|
|
333
341
|
var runloop = (0, import_provider.defineProvider)({
|
|
334
342
|
name: "runloop",
|
|
343
|
+
sizes: (_config, { sizeClass, vcpus, memoryMiB }, options) => {
|
|
344
|
+
const conflict = NATIVE_SIZE_FIELDS.find((field) => options?.[field] !== void 0);
|
|
345
|
+
if (conflict) {
|
|
346
|
+
throw new import_provider.InstanceSizeError("conflict", `cannot combine sizeClass with Runloop ${conflict}`);
|
|
347
|
+
}
|
|
348
|
+
if (sizeClass === "3xl") {
|
|
349
|
+
return {
|
|
350
|
+
status: "unsupported",
|
|
351
|
+
reason: "Runloop custom sizes are capped at 16 vCPUs and 64 GiB RAM."
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
const diskGiB = STANDARD_DISK_GIB[sizeClass];
|
|
355
|
+
const sizedMemoryMiB = Math.max(memoryMiB, vcpus * MIN_MEMORY_MIB_PER_VCPU);
|
|
356
|
+
const launch_parameters = {
|
|
357
|
+
resource_size_request: "CUSTOM_SIZE",
|
|
358
|
+
custom_cpu_cores: vcpus,
|
|
359
|
+
custom_gb_memory: sizedMemoryMiB / 1024,
|
|
360
|
+
custom_disk_size: diskGiB
|
|
361
|
+
};
|
|
362
|
+
return {
|
|
363
|
+
status: "supported",
|
|
364
|
+
resolved: { vcpus, memoryMiB: sizedMemoryMiB, diskMiB: diskGiB * 1024 },
|
|
365
|
+
nativeOptions: { launch_parameters }
|
|
366
|
+
};
|
|
367
|
+
},
|
|
335
368
|
methods: {
|
|
336
369
|
instances: {
|
|
337
370
|
create: async (config, options) => {
|
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 } from \"@computesdk/provider\";\nimport { posix as posixPath } from \"node:path\";\nimport type {\n CommandResult,\n InstanceInfo,\n CreateSnapshotOptions,\n ListSnapshotsOptions,\n RunCommandOptions,\n} from \"@computesdk/provider\";\nimport type {\n CreateInstanceOptions,\n FileEntry,\n Snapshot,\n} from \"computesdk\";\n\n// Define Runloop-specific types\ntype RunloopTemplate = Runloop.BlueprintView;\ntype RunloopSandbox = Runloop.DevboxView & { client: RunloopSDK };\ntype RunloopCreateWaitOptions = Parameters<RunloopSDK[\"api\"][\"devboxes\"][\"createAndAwaitRunning\"]>[1];\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 quotePosixShellToken(value: string): string {\n return `'${value.replace(/'/g, `'\"'\"'`)}'`;\n}\n\nfunction assertSafeRemovalPath(value: string): void {\n const normalized = posixPath.normalize(value);\n if (value.length === 0 || normalized === \"/\" || normalized === \".\" ||\n normalized === \"..\" || normalized.startsWith(\"../\")) {\n throw new Error(`Refusing to remove unsafe path: ${JSON.stringify(value)}`);\n }\n}\n\nfunction buildCommand(command: string, options?: RunCommandOptions): string {\n let fullCommand = command;\n\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([key, value]) => {\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) {\n throw new Error(`Invalid environment variable name: ${JSON.stringify(key)}`);\n }\n return `${key}=${quotePosixShellToken(String(value))}`;\n })\n .join(\" \");\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n\n if (options?.cwd) {\n fullCommand = `cd -- ${quotePosixShellToken(options.cwd)} && ${fullCommand}`;\n }\n\n if (options?.background) {\n fullCommand = `nohup sh -lc ${quotePosixShellToken(fullCommand)} >/dev/null 2>&1 &`;\n }\n\n return fullCommand;\n}\n\nfunction isHttpNotFound(error: unknown): boolean {\n return typeof error === \"object\" && error !== null &&\n \"status\" in error && error.status === 404;\n}\n\nconst READDIR_ENTRY_SCRIPT = [\n \"for entry; do\",\n ' name=${entry##*/}',\n ' if [ -d \"$entry\" ]; then type=directory; else type=file; fi',\n ' encoded=$(printf %s \"$name\" | base64 | tr -d \"\\\\n\")',\n ' size=$(stat -c %s -- \"$entry\") || exit',\n ' modified=$(stat -c %Y -- \"$entry\") || exit',\n ' printf \"%s\\\\t%s\\\\t%s\\\\t%s\\\\n\" \"$encoded\" \"$type\" \"$size\" \"$modified\"',\n \"done\",\n].join(\"\\n\");\n\nfunction buildReaddirCommand(path: string): string {\n const findRoot = path.startsWith(\"-\") ? `./${path}` : path;\n return [\n `find -- ${quotePosixShellToken(findRoot)} -mindepth 1 -maxdepth 1 -exec sh -c`,\n quotePosixShellToken(READDIR_ENTRY_SCRIPT),\n \"sh {} +\",\n ].join(\" \");\n}\n\nfunction parseReaddirOutput(stdout: string): FileEntry[] {\n return stdout\n .split(\"\\n\")\n .filter(Boolean)\n .map((line) => {\n const [encodedName, type, rawSize, rawModified] = line.split(\"\\t\");\n const size = Number(rawSize);\n const modifiedSeconds = Number(rawModified);\n if (!encodedName || (type !== \"file\" && type !== \"directory\") ||\n !Number.isFinite(size) || !Number.isFinite(modifiedSeconds)) {\n throw new Error(`Malformed Runloop directory entry: ${JSON.stringify(line)}`);\n }\n return {\n name: Buffer.from(encodedName, \"base64\").toString(\"utf8\"),\n type,\n size,\n modified: new Date(modifiedSeconds * 1000),\n };\n });\n}\n\nfunction mapStatus(status: Runloop.DevboxView[\"status\"]): InstanceInfo[\"status\"] {\n switch (status) {\n case \"scheduled\":\n case \"queued\":\n case \"provisioning\":\n case \"initializing\":\n case \"resuming\":\n case \"running\":\n return \"running\";\n case \"suspending\":\n case \"suspended\":\n case \"shutdown\":\n return \"stopped\";\n case \"failure\":\n return \"error\";\n }\n}\n\nasync function collectPaginated<T>(\n source: AsyncIterable<T>,\n limit?: number,\n): Promise<T[]> {\n if (limit !== undefined && limit <= 0) return [];\n\n const results: T[] = [];\n for await (const item of source) {\n results.push(item);\n if (limit !== undefined && results.length >= limit) break;\n }\n return results;\n}\n\nfunction normalizeSnapshot(snapshot: Runloop.DevboxSnapshotView): Snapshot {\n return {\n id: snapshot.id,\n provider: \"runloop\",\n createdAt: new Date(snapshot.create_time_ms),\n metadata: {\n name: snapshot.name ?? null,\n sourceDevboxId: snapshot.source_devbox_id,\n sourceBlueprintId: snapshot.source_blueprint_id ?? null,\n sizeBytes: snapshot.size_bytes ?? null,\n commitMessage: snapshot.commit_message ?? null,\n userMetadata: snapshot.metadata ?? {},\n },\n };\n}\n\nfunction emitMissingOutput(\n emitted: string,\n complete: string,\n callback: ((chunk: string) => void) | undefined,\n): void {\n if (!callback || !complete || emitted.includes(complete)) return;\n if (!emitted) {\n callback(complete);\n } else if (complete.startsWith(emitted)) {\n callback(complete.slice(emitted.length));\n } else if (!complete.includes(emitted)) {\n callback(complete);\n }\n}\n\nasync function streamExecutionOutput(\n openStream: () => Promise<AsyncIterable<{ output: string }>>,\n onChunk: (chunk: string) => void,\n signal: AbortSignal,\n isActive: () => boolean,\n): Promise<void> {\n try {\n const stream = await openStream();\n for await (const chunk of stream) {\n if (signal.aborted) break;\n if (isActive()) onChunk(chunk.output);\n }\n } catch {\n // Streaming is best effort, matching the native SDK callback behavior.\n }\n}\n\nasync function bestEffortKillExecution(\n sandbox: RunloopSandbox,\n executionId: string,\n): Promise<void> {\n let killTimer: ReturnType<typeof setTimeout> | undefined;\n try {\n await Promise.race([\n sandbox.client.api.devboxes.executions.kill(\n sandbox.id,\n executionId,\n { kill_process_group: true },\n ).catch(() => undefined),\n new Promise<void>((resolve) => {\n killTimer = setTimeout(resolve, 1_000);\n }),\n ]);\n } finally {\n if (killTimer) clearTimeout(killTimer);\n }\n}\n\nasync function executeCommand(\n sandbox: RunloopSandbox,\n command: string,\n options?: RunCommandOptions,\n): Promise<CommandResult> {\n const startTime = Date.now();\n const devbox = sandbox.client.devbox.fromId(sandbox.id);\n const fullCommand = buildCommand(command, options);\n let callbacksActive = true;\n const executionParams = {\n ...(options?.onStdout\n ? { stdout: (chunk: string) => callbacksActive && options.onStdout?.(chunk) }\n : {}),\n ...(options?.onStderr\n ? { stderr: (chunk: string) => callbacksActive && options.onStderr?.(chunk) }\n : {}),\n };\n\n const toCommandResult = async (result: Awaited<ReturnType<typeof devbox.cmd.exec>>): Promise<CommandResult> => ({\n stdout: await result.stdout(),\n stderr: await result.stderr(),\n exitCode: result.exitCode ?? -1,\n durationMs: Date.now() - startTime,\n });\n\n if (options?.timeout === undefined) {\n try {\n const result = await devbox.cmd.exec(fullCommand, executionParams);\n return await toCommandResult(result);\n } finally {\n callbacksActive = false;\n }\n }\n\n const timeoutMs = options.timeout;\n const deadline = startTime + Math.max(0, timeoutMs);\n const monitorController = new AbortController();\n let streamedStdout = \"\";\n let streamedStderr = \"\";\n let execution: Awaited<ReturnType<typeof devbox.cmd.execAsync>> | undefined;\n let resultPromise: ReturnType<Awaited<ReturnType<typeof devbox.cmd.execAsync>>[\"result\"]> | undefined;\n let streamPromises: Promise<void>[] = [];\n let executionCompleted = false;\n let timer: ReturnType<typeof setTimeout> | undefined;\n const timeoutPromise = new Promise<\"timeout\">((resolve) => {\n timer = setTimeout(() => {\n resolve(\"timeout\");\n monitorController.abort();\n }, Math.max(0, deadline - Date.now()));\n });\n const timeoutResult = (): CommandResult => ({\n stdout: streamedStdout,\n stderr: streamedStderr,\n exitCode: 124,\n durationMs: Date.now() - startTime,\n });\n\n try {\n // Keep creation alive after the caller's deadline. Aborting this non-idempotent\n // request can hide an execution that the server already accepted, leaving no ID\n // available for cleanup. The caller still returns at the deadline; if creation\n // resolves later, the timeout branch below kills the remote process group.\n const executionPromise = devbox.cmd.execAsync(fullCommand);\n const creationOutcome = await Promise.race([\n executionPromise.then((createdExecution) => ({ execution: createdExecution })),\n timeoutPromise,\n ]);\n\n if (creationOutcome === \"timeout\") {\n callbacksActive = false;\n void executionPromise\n .then((lateExecution) => bestEffortKillExecution(sandbox, lateExecution.executionId))\n .catch(() => undefined);\n return timeoutResult();\n }\n\n const activeExecution = creationOutcome.execution;\n execution = activeExecution;\n streamPromises = [\n streamExecutionOutput(\n () => sandbox.client.api.devboxes.executions.streamStdoutUpdates(\n sandbox.id,\n activeExecution.executionId,\n {},\n { signal: monitorController.signal },\n ),\n (chunk) => {\n streamedStdout += chunk;\n options.onStdout?.(chunk);\n },\n monitorController.signal,\n () => callbacksActive,\n ),\n streamExecutionOutput(\n () => sandbox.client.api.devboxes.executions.streamStderrUpdates(\n sandbox.id,\n activeExecution.executionId,\n {},\n { signal: monitorController.signal },\n ),\n (chunk) => {\n streamedStderr += chunk;\n options.onStderr?.(chunk);\n },\n monitorController.signal,\n () => callbacksActive,\n ),\n ];\n resultPromise = activeExecution.result({ signal: monitorController.signal });\n const outcome = await Promise.race([\n resultPromise.then((result) => ({ result })),\n timeoutPromise,\n ]);\n\n if (outcome === \"timeout\") {\n callbacksActive = false;\n monitorController.abort();\n await Promise.all([\n bestEffortKillExecution(sandbox, execution.executionId),\n Promise.allSettled([resultPromise, ...streamPromises]),\n ]);\n return timeoutResult();\n }\n\n executionCompleted = true;\n monitorController.abort();\n await Promise.allSettled(streamPromises);\n const commandResult = await toCommandResult(outcome.result);\n emitMissingOutput(streamedStdout, commandResult.stdout, options.onStdout);\n emitMissingOutput(streamedStderr, commandResult.stderr, options.onStderr);\n return commandResult;\n } catch (error) {\n callbacksActive = false;\n monitorController.abort();\n await Promise.all([\n executionCompleted || !execution\n ? Promise.resolve()\n : bestEffortKillExecution(sandbox, execution.executionId),\n Promise.allSettled([\n ...(resultPromise ? [resultPromise] : []),\n ...streamPromises,\n ]),\n ]);\n throw error;\n } finally {\n if (timer) clearTimeout(timer);\n callbacksActive = false;\n monitorController.abort();\n }\n}\n\nasync function runCommandWithErrors(\n sandbox: RunloopSandbox,\n command: string,\n options?: RunCommandOptions,\n): Promise<CommandResult> {\n try {\n return await executeCommand(sandbox, command, options);\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/**\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 Snapshot\n>({\n name: \"runloop\",\n methods: {\n instances: {\n create: async (config: RunloopConfig, options?: CreateInstanceOptions) => {\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 launch_parameters: optLaunchParameters,\n ...providerOptions\n } = options || {};\n\n const effectiveTimeout = optTimeout ?? timeout;\n const keepAliveSeconds = effectiveTimeout !== undefined\n ? Math.ceil(effectiveTimeout / 1000)\n : 1800;\n\n let devboxParams: Runloop.DevboxCreateParams = {\n launch_parameters: {\n keep_alive_time_seconds: keepAliveSeconds,\n ...optLaunchParameters,\n } as Runloop.DevboxCreateParams[\"launch_parameters\"],\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 { instance: runloopSandbox, instanceId: 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 { instance: { ...devbox, client } as RunloopSandbox,\n instanceId: sandboxId,\n };\n } catch (error) {\n if (isHttpNotFound(error)) return null;\n throw error;\n }\n },\n\n list: async (config: RunloopConfig) => {\n const client = getRunloopClient(config);\n const devboxes = await collectPaginated(client.api.devboxes.list());\n\n return devboxes.map((devbox) => ({\n instance: { ...devbox, client } as RunloopSandbox, instanceId: devbox.id,\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 (error) {\n if (!isHttpNotFound(error)) throw error;\n }\n },\n\n runCommand: runCommandWithErrors,\n\n streamCommand: runCommandWithErrors,\n\n getInfo: async (sandbox: RunloopSandbox): Promise<InstanceInfo> => {\n const devbox = await sandbox.client.api.devboxes.retrieve(sandbox.id);\n const keepAliveSecs = devbox.launch_parameters?.keep_alive_time_seconds;\n\n return {\n id: devbox.id || \"runloop-unknown\",\n provider: \"runloop\",\n status: mapStatus(devbox.status),\n createdAt: new Date(devbox.create_time_ms || Date.now()),\n // keep_alive_time_seconds is in seconds; InstanceInfo.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): Promise<string> => {\n return sandbox.client.devbox.fromId(sandbox.id).file.read({ file_path: path });\n },\n\n writeFile: async (sandbox: RunloopSandbox, path: string, content: string): Promise<void> => {\n const result = await sandbox.client.devbox.fromId(sandbox.id).file.write({\n file_path: path,\n contents: content,\n });\n if (result.exit_status !== 0) {\n throw new Error(\n `Failed to write file ${path}: ${result.stderr || `exit ${result.exit_status}`}`,\n );\n }\n },\n\n mkdir: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n const result = await runCommand(sandbox, `mkdir -p -- ${quotePosixShellToken(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, buildReaddirCommand(path));\n if (result.exitCode !== 0) throw new Error(`Failed to list directory ${path}: ${result.stderr}`);\n\n return parseReaddirOutput(result.stdout || \"\");\n },\n\n exists: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<boolean> => {\n const result = await runCommand(sandbox, `test -e ${quotePosixShellToken(path)}`);\n return result.exitCode === 0;\n },\n\n remove: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n assertSafeRemovalPath(path);\n const result = await runCommand(sandbox, `rm -rf -- ${quotePosixShellToken(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: Runloop.BlueprintListParams = {};\n if (options?.limit !== undefined) listParams.limit = options.limit;\n return collectPaginated(client.api.blueprints.list(listParams), options?.limit);\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: Runloop.DevboxSnapshotDiskParams = {};\n if (options?.name) snapshotParams.name = options.name;\n if (options?.metadata) snapshotParams.metadata = options.metadata;\n const snapshot = await client.api.devboxes.snapshotDisk(sandboxId, snapshotParams);\n return normalizeSnapshot(snapshot);\n },\n\n list: async (config: RunloopConfig, options?: ListSnapshotsOptions) => {\n const client = getRunloopClient(config);\n const listParams: Runloop.DevboxListDiskSnapshotsParams = {};\n if (options?.limit !== undefined) listParams.limit = options.limit;\n if (options?.sandboxId) listParams.devbox_id = options.sandboxId;\n const snapshots = await collectPaginated(\n client.api.devboxes.listDiskSnapshots(listParams),\n options?.limit,\n );\n return snapshots.map(normalizeSnapshot);\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+B;AAC/B,uBAAmC;AAmCnC,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,IA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OAAO,IAAI,WAAW,KAAK,UAAU,GAAG,SAAS,KAAK;AAAA,MAChF;AAAA,MAEA,QAAQ,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,iBAAmD,CAAC;AAC1D,YAAI,SAAS,KAAM,gBAAe,OAAO,QAAQ;AACjD,YAAI,SAAS,SAAU,gBAAe,WAAW,QAAQ;AACzD,cAAM,WAAW,MAAM,OAAO,IAAI,SAAS,aAAa,WAAW,cAAc;AACjF,eAAO,kBAAkB,QAAQ;AAAA,MACnC;AAAA,MAEA,MAAM,OAAO,QAAuB,YAAmC;AACrE,cAAM,SAAS,iBAAiB,MAAM;AACtC,cAAM,aAAoD,CAAC;AAC3D,YAAI,SAAS,UAAU,OAAW,YAAW,QAAQ,QAAQ;AAC7D,YAAI,SAAS,UAAW,YAAW,YAAY,QAAQ;AACvD,cAAM,YAAY,MAAM;AAAA,UACtB,OAAO,IAAI,SAAS,kBAAkB,UAAU;AAAA,UAChD,SAAS;AAAA,QACX;AACA,eAAO,UAAU,IAAI,iBAAiB;AAAA,MACxC;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":["posixPath"]}
|
|
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, InstanceSizeError } from \"@computesdk/provider\";\nimport { posix as posixPath } from \"node:path\";\nimport type {\n CommandResult,\n InstanceInfo,\n CreateSnapshotOptions,\n ListSnapshotsOptions,\n RunCommandOptions,\n} from \"@computesdk/provider\";\nimport type {\n CreateInstanceOptions,\n FileEntry,\n Snapshot,\n} from \"computesdk\";\n\n// Define Runloop-specific types\ntype RunloopTemplate = Runloop.BlueprintView;\ntype RunloopSandbox = Runloop.DevboxView & { client: RunloopSDK };\ntype RunloopCreateWaitOptions = Parameters<RunloopSDK[\"api\"][\"devboxes\"][\"createAndAwaitRunning\"]>[1];\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 quotePosixShellToken(value: string): string {\n return `'${value.replace(/'/g, `'\"'\"'`)}'`;\n}\n\nfunction assertSafeRemovalPath(value: string): void {\n const normalized = posixPath.normalize(value);\n if (value.length === 0 || normalized === \"/\" || normalized === \".\" ||\n normalized === \"..\" || normalized.startsWith(\"../\")) {\n throw new Error(`Refusing to remove unsafe path: ${JSON.stringify(value)}`);\n }\n}\n\nfunction buildCommand(command: string, options?: RunCommandOptions): string {\n let fullCommand = command;\n\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([key, value]) => {\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) {\n throw new Error(`Invalid environment variable name: ${JSON.stringify(key)}`);\n }\n return `${key}=${quotePosixShellToken(String(value))}`;\n })\n .join(\" \");\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n\n if (options?.cwd) {\n fullCommand = `cd -- ${quotePosixShellToken(options.cwd)} && ${fullCommand}`;\n }\n\n if (options?.background) {\n fullCommand = `nohup sh -lc ${quotePosixShellToken(fullCommand)} >/dev/null 2>&1 &`;\n }\n\n return fullCommand;\n}\n\nfunction isHttpNotFound(error: unknown): boolean {\n return typeof error === \"object\" && error !== null &&\n \"status\" in error && error.status === 404;\n}\n\nconst READDIR_ENTRY_SCRIPT = [\n \"for entry; do\",\n ' name=${entry##*/}',\n ' if [ -d \"$entry\" ]; then type=directory; else type=file; fi',\n ' encoded=$(printf %s \"$name\" | base64 | tr -d \"\\\\n\")',\n ' size=$(stat -c %s -- \"$entry\") || exit',\n ' modified=$(stat -c %Y -- \"$entry\") || exit',\n ' printf \"%s\\\\t%s\\\\t%s\\\\t%s\\\\n\" \"$encoded\" \"$type\" \"$size\" \"$modified\"',\n \"done\",\n].join(\"\\n\");\n\nfunction buildReaddirCommand(path: string): string {\n const findRoot = path.startsWith(\"-\") ? `./${path}` : path;\n return [\n `find -- ${quotePosixShellToken(findRoot)} -mindepth 1 -maxdepth 1 -exec sh -c`,\n quotePosixShellToken(READDIR_ENTRY_SCRIPT),\n \"sh {} +\",\n ].join(\" \");\n}\n\nfunction parseReaddirOutput(stdout: string): FileEntry[] {\n return stdout\n .split(\"\\n\")\n .filter(Boolean)\n .map((line) => {\n const [encodedName, type, rawSize, rawModified] = line.split(\"\\t\");\n const size = Number(rawSize);\n const modifiedSeconds = Number(rawModified);\n if (!encodedName || (type !== \"file\" && type !== \"directory\") ||\n !Number.isFinite(size) || !Number.isFinite(modifiedSeconds)) {\n throw new Error(`Malformed Runloop directory entry: ${JSON.stringify(line)}`);\n }\n return {\n name: Buffer.from(encodedName, \"base64\").toString(\"utf8\"),\n type,\n size,\n modified: new Date(modifiedSeconds * 1000),\n };\n });\n}\n\nfunction mapStatus(status: Runloop.DevboxView[\"status\"]): InstanceInfo[\"status\"] {\n switch (status) {\n case \"scheduled\":\n case \"queued\":\n case \"provisioning\":\n case \"initializing\":\n case \"resuming\":\n case \"running\":\n return \"running\";\n case \"suspending\":\n case \"suspended\":\n case \"shutdown\":\n return \"stopped\";\n case \"failure\":\n return \"error\";\n }\n}\n\nasync function collectPaginated<T>(\n source: AsyncIterable<T>,\n limit?: number,\n): Promise<T[]> {\n if (limit !== undefined && limit <= 0) return [];\n\n const results: T[] = [];\n for await (const item of source) {\n results.push(item);\n if (limit !== undefined && results.length >= limit) break;\n }\n return results;\n}\n\nfunction normalizeSnapshot(snapshot: Runloop.DevboxSnapshotView): Snapshot {\n return {\n id: snapshot.id,\n provider: \"runloop\",\n createdAt: new Date(snapshot.create_time_ms),\n metadata: {\n name: snapshot.name ?? null,\n sourceDevboxId: snapshot.source_devbox_id,\n sourceBlueprintId: snapshot.source_blueprint_id ?? null,\n sizeBytes: snapshot.size_bytes ?? null,\n commitMessage: snapshot.commit_message ?? null,\n userMetadata: snapshot.metadata ?? {},\n },\n };\n}\n\nfunction emitMissingOutput(\n emitted: string,\n complete: string,\n callback: ((chunk: string) => void) | undefined,\n): void {\n if (!callback || !complete || emitted.includes(complete)) return;\n if (!emitted) {\n callback(complete);\n } else if (complete.startsWith(emitted)) {\n callback(complete.slice(emitted.length));\n } else if (!complete.includes(emitted)) {\n callback(complete);\n }\n}\n\nasync function streamExecutionOutput(\n openStream: () => Promise<AsyncIterable<{ output: string }>>,\n onChunk: (chunk: string) => void,\n signal: AbortSignal,\n isActive: () => boolean,\n): Promise<void> {\n try {\n const stream = await openStream();\n for await (const chunk of stream) {\n if (signal.aborted) break;\n if (isActive()) onChunk(chunk.output);\n }\n } catch {\n // Streaming is best effort, matching the native SDK callback behavior.\n }\n}\n\nasync function bestEffortKillExecution(\n sandbox: RunloopSandbox,\n executionId: string,\n): Promise<void> {\n let killTimer: ReturnType<typeof setTimeout> | undefined;\n try {\n await Promise.race([\n sandbox.client.api.devboxes.executions.kill(\n sandbox.id,\n executionId,\n { kill_process_group: true },\n ).catch(() => undefined),\n new Promise<void>((resolve) => {\n killTimer = setTimeout(resolve, 1_000);\n }),\n ]);\n } finally {\n if (killTimer) clearTimeout(killTimer);\n }\n}\n\nasync function executeCommand(\n sandbox: RunloopSandbox,\n command: string,\n options?: RunCommandOptions,\n): Promise<CommandResult> {\n const startTime = Date.now();\n const devbox = sandbox.client.devbox.fromId(sandbox.id);\n const fullCommand = buildCommand(command, options);\n let callbacksActive = true;\n const executionParams = {\n ...(options?.onStdout\n ? { stdout: (chunk: string) => callbacksActive && options.onStdout?.(chunk) }\n : {}),\n ...(options?.onStderr\n ? { stderr: (chunk: string) => callbacksActive && options.onStderr?.(chunk) }\n : {}),\n };\n\n const toCommandResult = async (result: Awaited<ReturnType<typeof devbox.cmd.exec>>): Promise<CommandResult> => ({\n stdout: await result.stdout(),\n stderr: await result.stderr(),\n exitCode: result.exitCode ?? -1,\n durationMs: Date.now() - startTime,\n });\n\n if (options?.timeout === undefined) {\n try {\n const result = await devbox.cmd.exec(fullCommand, executionParams);\n return await toCommandResult(result);\n } finally {\n callbacksActive = false;\n }\n }\n\n const timeoutMs = options.timeout;\n const deadline = startTime + Math.max(0, timeoutMs);\n const monitorController = new AbortController();\n let streamedStdout = \"\";\n let streamedStderr = \"\";\n let execution: Awaited<ReturnType<typeof devbox.cmd.execAsync>> | undefined;\n let resultPromise: ReturnType<Awaited<ReturnType<typeof devbox.cmd.execAsync>>[\"result\"]> | undefined;\n let streamPromises: Promise<void>[] = [];\n let executionCompleted = false;\n let timer: ReturnType<typeof setTimeout> | undefined;\n const timeoutPromise = new Promise<\"timeout\">((resolve) => {\n timer = setTimeout(() => {\n resolve(\"timeout\");\n monitorController.abort();\n }, Math.max(0, deadline - Date.now()));\n });\n const timeoutResult = (): CommandResult => ({\n stdout: streamedStdout,\n stderr: streamedStderr,\n exitCode: 124,\n durationMs: Date.now() - startTime,\n });\n\n try {\n // Keep creation alive after the caller's deadline. Aborting this non-idempotent\n // request can hide an execution that the server already accepted, leaving no ID\n // available for cleanup. The caller still returns at the deadline; if creation\n // resolves later, the timeout branch below kills the remote process group.\n const executionPromise = devbox.cmd.execAsync(fullCommand);\n const creationOutcome = await Promise.race([\n executionPromise.then((createdExecution) => ({ execution: createdExecution })),\n timeoutPromise,\n ]);\n\n if (creationOutcome === \"timeout\") {\n callbacksActive = false;\n void executionPromise\n .then((lateExecution) => bestEffortKillExecution(sandbox, lateExecution.executionId))\n .catch(() => undefined);\n return timeoutResult();\n }\n\n const activeExecution = creationOutcome.execution;\n execution = activeExecution;\n streamPromises = [\n streamExecutionOutput(\n () => sandbox.client.api.devboxes.executions.streamStdoutUpdates(\n sandbox.id,\n activeExecution.executionId,\n {},\n { signal: monitorController.signal },\n ),\n (chunk) => {\n streamedStdout += chunk;\n options.onStdout?.(chunk);\n },\n monitorController.signal,\n () => callbacksActive,\n ),\n streamExecutionOutput(\n () => sandbox.client.api.devboxes.executions.streamStderrUpdates(\n sandbox.id,\n activeExecution.executionId,\n {},\n { signal: monitorController.signal },\n ),\n (chunk) => {\n streamedStderr += chunk;\n options.onStderr?.(chunk);\n },\n monitorController.signal,\n () => callbacksActive,\n ),\n ];\n resultPromise = activeExecution.result({ signal: monitorController.signal });\n const outcome = await Promise.race([\n resultPromise.then((result) => ({ result })),\n timeoutPromise,\n ]);\n\n if (outcome === \"timeout\") {\n callbacksActive = false;\n monitorController.abort();\n await Promise.all([\n bestEffortKillExecution(sandbox, execution.executionId),\n Promise.allSettled([resultPromise, ...streamPromises]),\n ]);\n return timeoutResult();\n }\n\n executionCompleted = true;\n monitorController.abort();\n await Promise.allSettled(streamPromises);\n const commandResult = await toCommandResult(outcome.result);\n emitMissingOutput(streamedStdout, commandResult.stdout, options.onStdout);\n emitMissingOutput(streamedStderr, commandResult.stderr, options.onStderr);\n return commandResult;\n } catch (error) {\n callbacksActive = false;\n monitorController.abort();\n await Promise.all([\n executionCompleted || !execution\n ? Promise.resolve()\n : bestEffortKillExecution(sandbox, execution.executionId),\n Promise.allSettled([\n ...(resultPromise ? [resultPromise] : []),\n ...streamPromises,\n ]),\n ]);\n throw error;\n } finally {\n if (timer) clearTimeout(timer);\n callbacksActive = false;\n monitorController.abort();\n }\n}\n\nasync function runCommandWithErrors(\n sandbox: RunloopSandbox,\n command: string,\n options?: RunCommandOptions,\n): Promise<CommandResult> {\n try {\n return await executeCommand(sandbox, command, options);\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/**\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// Match the platform size presets and use Runloop's default custom disk for 2xl.\nconst STANDARD_DISK_GIB = { xs: 4, sm: 4, md: 8, lg: 16, xl: 16, \"2xl\": 16 } as const;\n/** Runloop custom sizes need at least 2 GiB of RAM per vCPU. */\nconst MIN_MEMORY_MIB_PER_VCPU = 2048;\n\nconst NATIVE_SIZE_FIELDS = [\n \"resource_size_request\",\n \"custom_cpu_cores\",\n \"custom_gb_memory\",\n \"custom_disk_size\",\n] as const;\n\n/**\n * Create a Runloop provider instance using the factory pattern\n */\nexport const runloop = defineProvider<\n RunloopSandbox,\n RunloopConfig,\n RunloopTemplate,\n Snapshot\n>({\n name: \"runloop\",\n sizes: (_config, { sizeClass, vcpus, memoryMiB }, options) => {\n // Core rejects launch_parameters; the create path also forwards top-level options.\n const conflict = NATIVE_SIZE_FIELDS.find((field) => options?.[field] !== undefined);\n if (conflict) {\n throw new InstanceSizeError(\"conflict\", `cannot combine sizeClass with Runloop ${conflict}`);\n }\n if (sizeClass === \"3xl\") {\n return {\n status: \"unsupported\",\n reason: \"Runloop custom sizes are capped at 16 vCPUs and 64 GiB RAM.\",\n };\n }\n\n const diskGiB = STANDARD_DISK_GIB[sizeClass];\n // vCPU picks the class; xs takes 1 vCPU / 2 GiB, the smallest custom size with a whole vCPU.\n const sizedMemoryMiB = Math.max(memoryMiB, vcpus * MIN_MEMORY_MIB_PER_VCPU);\n const launch_parameters = {\n resource_size_request: \"CUSTOM_SIZE\",\n custom_cpu_cores: vcpus,\n custom_gb_memory: sizedMemoryMiB / 1024,\n custom_disk_size: diskGiB,\n } satisfies NonNullable<Runloop.DevboxCreateParams[\"launch_parameters\"]>;\n\n return {\n status: \"supported\",\n resolved: { vcpus, memoryMiB: sizedMemoryMiB, diskMiB: diskGiB * 1024 },\n nativeOptions: { launch_parameters },\n };\n },\n methods: {\n instances: {\n create: async (config: RunloopConfig, options?: CreateInstanceOptions) => {\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 launch_parameters: optLaunchParameters,\n ...providerOptions\n } = options || {};\n\n const effectiveTimeout = optTimeout ?? timeout;\n const keepAliveSeconds = effectiveTimeout !== undefined\n ? Math.ceil(effectiveTimeout / 1000)\n : 1800;\n\n let devboxParams: Runloop.DevboxCreateParams = {\n launch_parameters: {\n keep_alive_time_seconds: keepAliveSeconds,\n ...optLaunchParameters,\n } as Runloop.DevboxCreateParams[\"launch_parameters\"],\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 { instance: runloopSandbox, instanceId: 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 { instance: { ...devbox, client } as RunloopSandbox,\n instanceId: sandboxId,\n };\n } catch (error) {\n if (isHttpNotFound(error)) return null;\n throw error;\n }\n },\n\n list: async (config: RunloopConfig) => {\n const client = getRunloopClient(config);\n const devboxes = await collectPaginated(client.api.devboxes.list());\n\n return devboxes.map((devbox) => ({\n instance: { ...devbox, client } as RunloopSandbox, instanceId: devbox.id,\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 (error) {\n if (!isHttpNotFound(error)) throw error;\n }\n },\n\n runCommand: runCommandWithErrors,\n\n streamCommand: runCommandWithErrors,\n\n getInfo: async (sandbox: RunloopSandbox): Promise<InstanceInfo> => {\n const devbox = await sandbox.client.api.devboxes.retrieve(sandbox.id);\n const keepAliveSecs = devbox.launch_parameters?.keep_alive_time_seconds;\n\n return {\n id: devbox.id || \"runloop-unknown\",\n provider: \"runloop\",\n status: mapStatus(devbox.status),\n createdAt: new Date(devbox.create_time_ms || Date.now()),\n // keep_alive_time_seconds is in seconds; InstanceInfo.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): Promise<string> => {\n return sandbox.client.devbox.fromId(sandbox.id).file.read({ file_path: path });\n },\n\n writeFile: async (sandbox: RunloopSandbox, path: string, content: string): Promise<void> => {\n const result = await sandbox.client.devbox.fromId(sandbox.id).file.write({\n file_path: path,\n contents: content,\n });\n if (result.exit_status !== 0) {\n throw new Error(\n `Failed to write file ${path}: ${result.stderr || `exit ${result.exit_status}`}`,\n );\n }\n },\n\n mkdir: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n const result = await runCommand(sandbox, `mkdir -p -- ${quotePosixShellToken(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, buildReaddirCommand(path));\n if (result.exitCode !== 0) throw new Error(`Failed to list directory ${path}: ${result.stderr}`);\n\n return parseReaddirOutput(result.stdout || \"\");\n },\n\n exists: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<boolean> => {\n const result = await runCommand(sandbox, `test -e ${quotePosixShellToken(path)}`);\n return result.exitCode === 0;\n },\n\n remove: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n assertSafeRemovalPath(path);\n const result = await runCommand(sandbox, `rm -rf -- ${quotePosixShellToken(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: Runloop.BlueprintListParams = {};\n if (options?.limit !== undefined) listParams.limit = options.limit;\n return collectPaginated(client.api.blueprints.list(listParams), options?.limit);\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: Runloop.DevboxSnapshotDiskParams = {};\n if (options?.name) snapshotParams.name = options.name;\n if (options?.metadata) snapshotParams.metadata = options.metadata;\n const snapshot = await client.api.devboxes.snapshotDisk(sandboxId, snapshotParams);\n return normalizeSnapshot(snapshot);\n },\n\n list: async (config: RunloopConfig, options?: ListSnapshotsOptions) => {\n const client = getRunloopClient(config);\n const listParams: Runloop.DevboxListDiskSnapshotsParams = {};\n if (options?.limit !== undefined) listParams.limit = options.limit;\n if (options?.sandboxId) listParams.devbox_id = options.sandboxId;\n const snapshots = await collectPaginated(\n client.api.devboxes.listDiskSnapshots(listParams),\n options?.limit,\n );\n return snapshots.map(normalizeSnapshot);\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,sBAAkD;AAClD,uBAAmC;AAmCnC,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,IACb,OAAO;AAAA,EACT,CAAC;AACD,cAAY,IAAI,QAAQ,MAAM;AAC9B,SAAO;AACT;AAEA,SAAS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;AACjF,eAAO,kBAAkB,QAAQ;AAAA,MACnC;AAAA,MAEA,MAAM,OAAO,QAAuB,YAAmC;AACrE,cAAM,SAAS,iBAAiB,MAAM;AACtC,cAAM,aAAoD,CAAC;AAC3D,YAAI,SAAS,UAAU,OAAW,YAAW,QAAQ,QAAQ;AAC7D,YAAI,SAAS,UAAW,YAAW,YAAY,QAAQ;AACvD,cAAM,YAAY,MAAM;AAAA,UACtB,OAAO,IAAI,SAAS,kBAAkB,UAAU;AAAA,UAChD,SAAS;AAAA,QACX;AACA,eAAO,UAAU,IAAI,iBAAiB;AAAA,MACxC;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":["posixPath"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { RunloopSDK } from "@runloop/api-client";
|
|
3
|
-
import { defineProvider } from "@computesdk/provider";
|
|
3
|
+
import { defineProvider, InstanceSizeError } from "@computesdk/provider";
|
|
4
4
|
import { posix as posixPath } from "path";
|
|
5
5
|
var clientCache = /* @__PURE__ */ new WeakMap();
|
|
6
6
|
function resolveApiKey(config) {
|
|
@@ -306,8 +306,41 @@ async function runCommandWithErrors(sandbox, command, options) {
|
|
|
306
306
|
);
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
|
+
var STANDARD_DISK_GIB = { xs: 4, sm: 4, md: 8, lg: 16, xl: 16, "2xl": 16 };
|
|
310
|
+
var MIN_MEMORY_MIB_PER_VCPU = 2048;
|
|
311
|
+
var NATIVE_SIZE_FIELDS = [
|
|
312
|
+
"resource_size_request",
|
|
313
|
+
"custom_cpu_cores",
|
|
314
|
+
"custom_gb_memory",
|
|
315
|
+
"custom_disk_size"
|
|
316
|
+
];
|
|
309
317
|
var runloop = defineProvider({
|
|
310
318
|
name: "runloop",
|
|
319
|
+
sizes: (_config, { sizeClass, vcpus, memoryMiB }, options) => {
|
|
320
|
+
const conflict = NATIVE_SIZE_FIELDS.find((field) => options?.[field] !== void 0);
|
|
321
|
+
if (conflict) {
|
|
322
|
+
throw new InstanceSizeError("conflict", `cannot combine sizeClass with Runloop ${conflict}`);
|
|
323
|
+
}
|
|
324
|
+
if (sizeClass === "3xl") {
|
|
325
|
+
return {
|
|
326
|
+
status: "unsupported",
|
|
327
|
+
reason: "Runloop custom sizes are capped at 16 vCPUs and 64 GiB RAM."
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
const diskGiB = STANDARD_DISK_GIB[sizeClass];
|
|
331
|
+
const sizedMemoryMiB = Math.max(memoryMiB, vcpus * MIN_MEMORY_MIB_PER_VCPU);
|
|
332
|
+
const launch_parameters = {
|
|
333
|
+
resource_size_request: "CUSTOM_SIZE",
|
|
334
|
+
custom_cpu_cores: vcpus,
|
|
335
|
+
custom_gb_memory: sizedMemoryMiB / 1024,
|
|
336
|
+
custom_disk_size: diskGiB
|
|
337
|
+
};
|
|
338
|
+
return {
|
|
339
|
+
status: "supported",
|
|
340
|
+
resolved: { vcpus, memoryMiB: sizedMemoryMiB, diskMiB: diskGiB * 1024 },
|
|
341
|
+
nativeOptions: { launch_parameters }
|
|
342
|
+
};
|
|
343
|
+
},
|
|
311
344
|
methods: {
|
|
312
345
|
instances: {
|
|
313
346
|
create: async (config, options) => {
|
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 } from \"@computesdk/provider\";\nimport { posix as posixPath } from \"node:path\";\nimport type {\n CommandResult,\n InstanceInfo,\n CreateSnapshotOptions,\n ListSnapshotsOptions,\n RunCommandOptions,\n} from \"@computesdk/provider\";\nimport type {\n CreateInstanceOptions,\n FileEntry,\n Snapshot,\n} from \"computesdk\";\n\n// Define Runloop-specific types\ntype RunloopTemplate = Runloop.BlueprintView;\ntype RunloopSandbox = Runloop.DevboxView & { client: RunloopSDK };\ntype RunloopCreateWaitOptions = Parameters<RunloopSDK[\"api\"][\"devboxes\"][\"createAndAwaitRunning\"]>[1];\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 quotePosixShellToken(value: string): string {\n return `'${value.replace(/'/g, `'\"'\"'`)}'`;\n}\n\nfunction assertSafeRemovalPath(value: string): void {\n const normalized = posixPath.normalize(value);\n if (value.length === 0 || normalized === \"/\" || normalized === \".\" ||\n normalized === \"..\" || normalized.startsWith(\"../\")) {\n throw new Error(`Refusing to remove unsafe path: ${JSON.stringify(value)}`);\n }\n}\n\nfunction buildCommand(command: string, options?: RunCommandOptions): string {\n let fullCommand = command;\n\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([key, value]) => {\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) {\n throw new Error(`Invalid environment variable name: ${JSON.stringify(key)}`);\n }\n return `${key}=${quotePosixShellToken(String(value))}`;\n })\n .join(\" \");\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n\n if (options?.cwd) {\n fullCommand = `cd -- ${quotePosixShellToken(options.cwd)} && ${fullCommand}`;\n }\n\n if (options?.background) {\n fullCommand = `nohup sh -lc ${quotePosixShellToken(fullCommand)} >/dev/null 2>&1 &`;\n }\n\n return fullCommand;\n}\n\nfunction isHttpNotFound(error: unknown): boolean {\n return typeof error === \"object\" && error !== null &&\n \"status\" in error && error.status === 404;\n}\n\nconst READDIR_ENTRY_SCRIPT = [\n \"for entry; do\",\n ' name=${entry##*/}',\n ' if [ -d \"$entry\" ]; then type=directory; else type=file; fi',\n ' encoded=$(printf %s \"$name\" | base64 | tr -d \"\\\\n\")',\n ' size=$(stat -c %s -- \"$entry\") || exit',\n ' modified=$(stat -c %Y -- \"$entry\") || exit',\n ' printf \"%s\\\\t%s\\\\t%s\\\\t%s\\\\n\" \"$encoded\" \"$type\" \"$size\" \"$modified\"',\n \"done\",\n].join(\"\\n\");\n\nfunction buildReaddirCommand(path: string): string {\n const findRoot = path.startsWith(\"-\") ? `./${path}` : path;\n return [\n `find -- ${quotePosixShellToken(findRoot)} -mindepth 1 -maxdepth 1 -exec sh -c`,\n quotePosixShellToken(READDIR_ENTRY_SCRIPT),\n \"sh {} +\",\n ].join(\" \");\n}\n\nfunction parseReaddirOutput(stdout: string): FileEntry[] {\n return stdout\n .split(\"\\n\")\n .filter(Boolean)\n .map((line) => {\n const [encodedName, type, rawSize, rawModified] = line.split(\"\\t\");\n const size = Number(rawSize);\n const modifiedSeconds = Number(rawModified);\n if (!encodedName || (type !== \"file\" && type !== \"directory\") ||\n !Number.isFinite(size) || !Number.isFinite(modifiedSeconds)) {\n throw new Error(`Malformed Runloop directory entry: ${JSON.stringify(line)}`);\n }\n return {\n name: Buffer.from(encodedName, \"base64\").toString(\"utf8\"),\n type,\n size,\n modified: new Date(modifiedSeconds * 1000),\n };\n });\n}\n\nfunction mapStatus(status: Runloop.DevboxView[\"status\"]): InstanceInfo[\"status\"] {\n switch (status) {\n case \"scheduled\":\n case \"queued\":\n case \"provisioning\":\n case \"initializing\":\n case \"resuming\":\n case \"running\":\n return \"running\";\n case \"suspending\":\n case \"suspended\":\n case \"shutdown\":\n return \"stopped\";\n case \"failure\":\n return \"error\";\n }\n}\n\nasync function collectPaginated<T>(\n source: AsyncIterable<T>,\n limit?: number,\n): Promise<T[]> {\n if (limit !== undefined && limit <= 0) return [];\n\n const results: T[] = [];\n for await (const item of source) {\n results.push(item);\n if (limit !== undefined && results.length >= limit) break;\n }\n return results;\n}\n\nfunction normalizeSnapshot(snapshot: Runloop.DevboxSnapshotView): Snapshot {\n return {\n id: snapshot.id,\n provider: \"runloop\",\n createdAt: new Date(snapshot.create_time_ms),\n metadata: {\n name: snapshot.name ?? null,\n sourceDevboxId: snapshot.source_devbox_id,\n sourceBlueprintId: snapshot.source_blueprint_id ?? null,\n sizeBytes: snapshot.size_bytes ?? null,\n commitMessage: snapshot.commit_message ?? null,\n userMetadata: snapshot.metadata ?? {},\n },\n };\n}\n\nfunction emitMissingOutput(\n emitted: string,\n complete: string,\n callback: ((chunk: string) => void) | undefined,\n): void {\n if (!callback || !complete || emitted.includes(complete)) return;\n if (!emitted) {\n callback(complete);\n } else if (complete.startsWith(emitted)) {\n callback(complete.slice(emitted.length));\n } else if (!complete.includes(emitted)) {\n callback(complete);\n }\n}\n\nasync function streamExecutionOutput(\n openStream: () => Promise<AsyncIterable<{ output: string }>>,\n onChunk: (chunk: string) => void,\n signal: AbortSignal,\n isActive: () => boolean,\n): Promise<void> {\n try {\n const stream = await openStream();\n for await (const chunk of stream) {\n if (signal.aborted) break;\n if (isActive()) onChunk(chunk.output);\n }\n } catch {\n // Streaming is best effort, matching the native SDK callback behavior.\n }\n}\n\nasync function bestEffortKillExecution(\n sandbox: RunloopSandbox,\n executionId: string,\n): Promise<void> {\n let killTimer: ReturnType<typeof setTimeout> | undefined;\n try {\n await Promise.race([\n sandbox.client.api.devboxes.executions.kill(\n sandbox.id,\n executionId,\n { kill_process_group: true },\n ).catch(() => undefined),\n new Promise<void>((resolve) => {\n killTimer = setTimeout(resolve, 1_000);\n }),\n ]);\n } finally {\n if (killTimer) clearTimeout(killTimer);\n }\n}\n\nasync function executeCommand(\n sandbox: RunloopSandbox,\n command: string,\n options?: RunCommandOptions,\n): Promise<CommandResult> {\n const startTime = Date.now();\n const devbox = sandbox.client.devbox.fromId(sandbox.id);\n const fullCommand = buildCommand(command, options);\n let callbacksActive = true;\n const executionParams = {\n ...(options?.onStdout\n ? { stdout: (chunk: string) => callbacksActive && options.onStdout?.(chunk) }\n : {}),\n ...(options?.onStderr\n ? { stderr: (chunk: string) => callbacksActive && options.onStderr?.(chunk) }\n : {}),\n };\n\n const toCommandResult = async (result: Awaited<ReturnType<typeof devbox.cmd.exec>>): Promise<CommandResult> => ({\n stdout: await result.stdout(),\n stderr: await result.stderr(),\n exitCode: result.exitCode ?? -1,\n durationMs: Date.now() - startTime,\n });\n\n if (options?.timeout === undefined) {\n try {\n const result = await devbox.cmd.exec(fullCommand, executionParams);\n return await toCommandResult(result);\n } finally {\n callbacksActive = false;\n }\n }\n\n const timeoutMs = options.timeout;\n const deadline = startTime + Math.max(0, timeoutMs);\n const monitorController = new AbortController();\n let streamedStdout = \"\";\n let streamedStderr = \"\";\n let execution: Awaited<ReturnType<typeof devbox.cmd.execAsync>> | undefined;\n let resultPromise: ReturnType<Awaited<ReturnType<typeof devbox.cmd.execAsync>>[\"result\"]> | undefined;\n let streamPromises: Promise<void>[] = [];\n let executionCompleted = false;\n let timer: ReturnType<typeof setTimeout> | undefined;\n const timeoutPromise = new Promise<\"timeout\">((resolve) => {\n timer = setTimeout(() => {\n resolve(\"timeout\");\n monitorController.abort();\n }, Math.max(0, deadline - Date.now()));\n });\n const timeoutResult = (): CommandResult => ({\n stdout: streamedStdout,\n stderr: streamedStderr,\n exitCode: 124,\n durationMs: Date.now() - startTime,\n });\n\n try {\n // Keep creation alive after the caller's deadline. Aborting this non-idempotent\n // request can hide an execution that the server already accepted, leaving no ID\n // available for cleanup. The caller still returns at the deadline; if creation\n // resolves later, the timeout branch below kills the remote process group.\n const executionPromise = devbox.cmd.execAsync(fullCommand);\n const creationOutcome = await Promise.race([\n executionPromise.then((createdExecution) => ({ execution: createdExecution })),\n timeoutPromise,\n ]);\n\n if (creationOutcome === \"timeout\") {\n callbacksActive = false;\n void executionPromise\n .then((lateExecution) => bestEffortKillExecution(sandbox, lateExecution.executionId))\n .catch(() => undefined);\n return timeoutResult();\n }\n\n const activeExecution = creationOutcome.execution;\n execution = activeExecution;\n streamPromises = [\n streamExecutionOutput(\n () => sandbox.client.api.devboxes.executions.streamStdoutUpdates(\n sandbox.id,\n activeExecution.executionId,\n {},\n { signal: monitorController.signal },\n ),\n (chunk) => {\n streamedStdout += chunk;\n options.onStdout?.(chunk);\n },\n monitorController.signal,\n () => callbacksActive,\n ),\n streamExecutionOutput(\n () => sandbox.client.api.devboxes.executions.streamStderrUpdates(\n sandbox.id,\n activeExecution.executionId,\n {},\n { signal: monitorController.signal },\n ),\n (chunk) => {\n streamedStderr += chunk;\n options.onStderr?.(chunk);\n },\n monitorController.signal,\n () => callbacksActive,\n ),\n ];\n resultPromise = activeExecution.result({ signal: monitorController.signal });\n const outcome = await Promise.race([\n resultPromise.then((result) => ({ result })),\n timeoutPromise,\n ]);\n\n if (outcome === \"timeout\") {\n callbacksActive = false;\n monitorController.abort();\n await Promise.all([\n bestEffortKillExecution(sandbox, execution.executionId),\n Promise.allSettled([resultPromise, ...streamPromises]),\n ]);\n return timeoutResult();\n }\n\n executionCompleted = true;\n monitorController.abort();\n await Promise.allSettled(streamPromises);\n const commandResult = await toCommandResult(outcome.result);\n emitMissingOutput(streamedStdout, commandResult.stdout, options.onStdout);\n emitMissingOutput(streamedStderr, commandResult.stderr, options.onStderr);\n return commandResult;\n } catch (error) {\n callbacksActive = false;\n monitorController.abort();\n await Promise.all([\n executionCompleted || !execution\n ? Promise.resolve()\n : bestEffortKillExecution(sandbox, execution.executionId),\n Promise.allSettled([\n ...(resultPromise ? [resultPromise] : []),\n ...streamPromises,\n ]),\n ]);\n throw error;\n } finally {\n if (timer) clearTimeout(timer);\n callbacksActive = false;\n monitorController.abort();\n }\n}\n\nasync function runCommandWithErrors(\n sandbox: RunloopSandbox,\n command: string,\n options?: RunCommandOptions,\n): Promise<CommandResult> {\n try {\n return await executeCommand(sandbox, command, options);\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/**\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 Snapshot\n>({\n name: \"runloop\",\n methods: {\n instances: {\n create: async (config: RunloopConfig, options?: CreateInstanceOptions) => {\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 launch_parameters: optLaunchParameters,\n ...providerOptions\n } = options || {};\n\n const effectiveTimeout = optTimeout ?? timeout;\n const keepAliveSeconds = effectiveTimeout !== undefined\n ? Math.ceil(effectiveTimeout / 1000)\n : 1800;\n\n let devboxParams: Runloop.DevboxCreateParams = {\n launch_parameters: {\n keep_alive_time_seconds: keepAliveSeconds,\n ...optLaunchParameters,\n } as Runloop.DevboxCreateParams[\"launch_parameters\"],\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 { instance: runloopSandbox, instanceId: 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 { instance: { ...devbox, client } as RunloopSandbox,\n instanceId: sandboxId,\n };\n } catch (error) {\n if (isHttpNotFound(error)) return null;\n throw error;\n }\n },\n\n list: async (config: RunloopConfig) => {\n const client = getRunloopClient(config);\n const devboxes = await collectPaginated(client.api.devboxes.list());\n\n return devboxes.map((devbox) => ({\n instance: { ...devbox, client } as RunloopSandbox, instanceId: devbox.id,\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 (error) {\n if (!isHttpNotFound(error)) throw error;\n }\n },\n\n runCommand: runCommandWithErrors,\n\n streamCommand: runCommandWithErrors,\n\n getInfo: async (sandbox: RunloopSandbox): Promise<InstanceInfo> => {\n const devbox = await sandbox.client.api.devboxes.retrieve(sandbox.id);\n const keepAliveSecs = devbox.launch_parameters?.keep_alive_time_seconds;\n\n return {\n id: devbox.id || \"runloop-unknown\",\n provider: \"runloop\",\n status: mapStatus(devbox.status),\n createdAt: new Date(devbox.create_time_ms || Date.now()),\n // keep_alive_time_seconds is in seconds; InstanceInfo.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): Promise<string> => {\n return sandbox.client.devbox.fromId(sandbox.id).file.read({ file_path: path });\n },\n\n writeFile: async (sandbox: RunloopSandbox, path: string, content: string): Promise<void> => {\n const result = await sandbox.client.devbox.fromId(sandbox.id).file.write({\n file_path: path,\n contents: content,\n });\n if (result.exit_status !== 0) {\n throw new Error(\n `Failed to write file ${path}: ${result.stderr || `exit ${result.exit_status}`}`,\n );\n }\n },\n\n mkdir: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n const result = await runCommand(sandbox, `mkdir -p -- ${quotePosixShellToken(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, buildReaddirCommand(path));\n if (result.exitCode !== 0) throw new Error(`Failed to list directory ${path}: ${result.stderr}`);\n\n return parseReaddirOutput(result.stdout || \"\");\n },\n\n exists: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<boolean> => {\n const result = await runCommand(sandbox, `test -e ${quotePosixShellToken(path)}`);\n return result.exitCode === 0;\n },\n\n remove: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n assertSafeRemovalPath(path);\n const result = await runCommand(sandbox, `rm -rf -- ${quotePosixShellToken(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: Runloop.BlueprintListParams = {};\n if (options?.limit !== undefined) listParams.limit = options.limit;\n return collectPaginated(client.api.blueprints.list(listParams), options?.limit);\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: Runloop.DevboxSnapshotDiskParams = {};\n if (options?.name) snapshotParams.name = options.name;\n if (options?.metadata) snapshotParams.metadata = options.metadata;\n const snapshot = await client.api.devboxes.snapshotDisk(sandboxId, snapshotParams);\n return normalizeSnapshot(snapshot);\n },\n\n list: async (config: RunloopConfig, options?: ListSnapshotsOptions) => {\n const client = getRunloopClient(config);\n const listParams: Runloop.DevboxListDiskSnapshotsParams = {};\n if (options?.limit !== undefined) listParams.limit = options.limit;\n if (options?.sandboxId) listParams.devbox_id = options.sandboxId;\n const snapshots = await collectPaginated(\n client.api.devboxes.listDiskSnapshots(listParams),\n options?.limit,\n );\n return snapshots.map(normalizeSnapshot);\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,sBAAsB;AAC/B,SAAS,SAAS,iBAAiB;AAmCnC,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,SAA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AAO,iBAAiB,OAAO,IAAI,WAAW,KAAK,UAAU,GAAG,SAAS,KAAK;AAAA,MAChF;AAAA,MAEA,QAAQ,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,iBAAmD,CAAC;AAC1D,YAAI,SAAS,KAAM,gBAAe,OAAO,QAAQ;AACjD,YAAI,SAAS,SAAU,gBAAe,WAAW,QAAQ;AACzD,cAAM,WAAW,MAAM,OAAO,IAAI,SAAS,aAAa,WAAW,cAAc;AACjF,eAAO,kBAAkB,QAAQ;AAAA,MACnC;AAAA,MAEA,MAAM,OAAO,QAAuB,YAAmC;AACrE,cAAM,SAAS,iBAAiB,MAAM;AACtC,cAAM,aAAoD,CAAC;AAC3D,YAAI,SAAS,UAAU,OAAW,YAAW,QAAQ,QAAQ;AAC7D,YAAI,SAAS,UAAW,YAAW,YAAY,QAAQ;AACvD,cAAM,YAAY,MAAM;AAAA,UACtB,OAAO,IAAI,SAAS,kBAAkB,UAAU;AAAA,UAChD,SAAS;AAAA,QACX;AACA,eAAO,UAAU,IAAI,iBAAiB;AAAA,MACxC;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, InstanceSizeError } from \"@computesdk/provider\";\nimport { posix as posixPath } from \"node:path\";\nimport type {\n CommandResult,\n InstanceInfo,\n CreateSnapshotOptions,\n ListSnapshotsOptions,\n RunCommandOptions,\n} from \"@computesdk/provider\";\nimport type {\n CreateInstanceOptions,\n FileEntry,\n Snapshot,\n} from \"computesdk\";\n\n// Define Runloop-specific types\ntype RunloopTemplate = Runloop.BlueprintView;\ntype RunloopSandbox = Runloop.DevboxView & { client: RunloopSDK };\ntype RunloopCreateWaitOptions = Parameters<RunloopSDK[\"api\"][\"devboxes\"][\"createAndAwaitRunning\"]>[1];\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 quotePosixShellToken(value: string): string {\n return `'${value.replace(/'/g, `'\"'\"'`)}'`;\n}\n\nfunction assertSafeRemovalPath(value: string): void {\n const normalized = posixPath.normalize(value);\n if (value.length === 0 || normalized === \"/\" || normalized === \".\" ||\n normalized === \"..\" || normalized.startsWith(\"../\")) {\n throw new Error(`Refusing to remove unsafe path: ${JSON.stringify(value)}`);\n }\n}\n\nfunction buildCommand(command: string, options?: RunCommandOptions): string {\n let fullCommand = command;\n\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([key, value]) => {\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) {\n throw new Error(`Invalid environment variable name: ${JSON.stringify(key)}`);\n }\n return `${key}=${quotePosixShellToken(String(value))}`;\n })\n .join(\" \");\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n\n if (options?.cwd) {\n fullCommand = `cd -- ${quotePosixShellToken(options.cwd)} && ${fullCommand}`;\n }\n\n if (options?.background) {\n fullCommand = `nohup sh -lc ${quotePosixShellToken(fullCommand)} >/dev/null 2>&1 &`;\n }\n\n return fullCommand;\n}\n\nfunction isHttpNotFound(error: unknown): boolean {\n return typeof error === \"object\" && error !== null &&\n \"status\" in error && error.status === 404;\n}\n\nconst READDIR_ENTRY_SCRIPT = [\n \"for entry; do\",\n ' name=${entry##*/}',\n ' if [ -d \"$entry\" ]; then type=directory; else type=file; fi',\n ' encoded=$(printf %s \"$name\" | base64 | tr -d \"\\\\n\")',\n ' size=$(stat -c %s -- \"$entry\") || exit',\n ' modified=$(stat -c %Y -- \"$entry\") || exit',\n ' printf \"%s\\\\t%s\\\\t%s\\\\t%s\\\\n\" \"$encoded\" \"$type\" \"$size\" \"$modified\"',\n \"done\",\n].join(\"\\n\");\n\nfunction buildReaddirCommand(path: string): string {\n const findRoot = path.startsWith(\"-\") ? `./${path}` : path;\n return [\n `find -- ${quotePosixShellToken(findRoot)} -mindepth 1 -maxdepth 1 -exec sh -c`,\n quotePosixShellToken(READDIR_ENTRY_SCRIPT),\n \"sh {} +\",\n ].join(\" \");\n}\n\nfunction parseReaddirOutput(stdout: string): FileEntry[] {\n return stdout\n .split(\"\\n\")\n .filter(Boolean)\n .map((line) => {\n const [encodedName, type, rawSize, rawModified] = line.split(\"\\t\");\n const size = Number(rawSize);\n const modifiedSeconds = Number(rawModified);\n if (!encodedName || (type !== \"file\" && type !== \"directory\") ||\n !Number.isFinite(size) || !Number.isFinite(modifiedSeconds)) {\n throw new Error(`Malformed Runloop directory entry: ${JSON.stringify(line)}`);\n }\n return {\n name: Buffer.from(encodedName, \"base64\").toString(\"utf8\"),\n type,\n size,\n modified: new Date(modifiedSeconds * 1000),\n };\n });\n}\n\nfunction mapStatus(status: Runloop.DevboxView[\"status\"]): InstanceInfo[\"status\"] {\n switch (status) {\n case \"scheduled\":\n case \"queued\":\n case \"provisioning\":\n case \"initializing\":\n case \"resuming\":\n case \"running\":\n return \"running\";\n case \"suspending\":\n case \"suspended\":\n case \"shutdown\":\n return \"stopped\";\n case \"failure\":\n return \"error\";\n }\n}\n\nasync function collectPaginated<T>(\n source: AsyncIterable<T>,\n limit?: number,\n): Promise<T[]> {\n if (limit !== undefined && limit <= 0) return [];\n\n const results: T[] = [];\n for await (const item of source) {\n results.push(item);\n if (limit !== undefined && results.length >= limit) break;\n }\n return results;\n}\n\nfunction normalizeSnapshot(snapshot: Runloop.DevboxSnapshotView): Snapshot {\n return {\n id: snapshot.id,\n provider: \"runloop\",\n createdAt: new Date(snapshot.create_time_ms),\n metadata: {\n name: snapshot.name ?? null,\n sourceDevboxId: snapshot.source_devbox_id,\n sourceBlueprintId: snapshot.source_blueprint_id ?? null,\n sizeBytes: snapshot.size_bytes ?? null,\n commitMessage: snapshot.commit_message ?? null,\n userMetadata: snapshot.metadata ?? {},\n },\n };\n}\n\nfunction emitMissingOutput(\n emitted: string,\n complete: string,\n callback: ((chunk: string) => void) | undefined,\n): void {\n if (!callback || !complete || emitted.includes(complete)) return;\n if (!emitted) {\n callback(complete);\n } else if (complete.startsWith(emitted)) {\n callback(complete.slice(emitted.length));\n } else if (!complete.includes(emitted)) {\n callback(complete);\n }\n}\n\nasync function streamExecutionOutput(\n openStream: () => Promise<AsyncIterable<{ output: string }>>,\n onChunk: (chunk: string) => void,\n signal: AbortSignal,\n isActive: () => boolean,\n): Promise<void> {\n try {\n const stream = await openStream();\n for await (const chunk of stream) {\n if (signal.aborted) break;\n if (isActive()) onChunk(chunk.output);\n }\n } catch {\n // Streaming is best effort, matching the native SDK callback behavior.\n }\n}\n\nasync function bestEffortKillExecution(\n sandbox: RunloopSandbox,\n executionId: string,\n): Promise<void> {\n let killTimer: ReturnType<typeof setTimeout> | undefined;\n try {\n await Promise.race([\n sandbox.client.api.devboxes.executions.kill(\n sandbox.id,\n executionId,\n { kill_process_group: true },\n ).catch(() => undefined),\n new Promise<void>((resolve) => {\n killTimer = setTimeout(resolve, 1_000);\n }),\n ]);\n } finally {\n if (killTimer) clearTimeout(killTimer);\n }\n}\n\nasync function executeCommand(\n sandbox: RunloopSandbox,\n command: string,\n options?: RunCommandOptions,\n): Promise<CommandResult> {\n const startTime = Date.now();\n const devbox = sandbox.client.devbox.fromId(sandbox.id);\n const fullCommand = buildCommand(command, options);\n let callbacksActive = true;\n const executionParams = {\n ...(options?.onStdout\n ? { stdout: (chunk: string) => callbacksActive && options.onStdout?.(chunk) }\n : {}),\n ...(options?.onStderr\n ? { stderr: (chunk: string) => callbacksActive && options.onStderr?.(chunk) }\n : {}),\n };\n\n const toCommandResult = async (result: Awaited<ReturnType<typeof devbox.cmd.exec>>): Promise<CommandResult> => ({\n stdout: await result.stdout(),\n stderr: await result.stderr(),\n exitCode: result.exitCode ?? -1,\n durationMs: Date.now() - startTime,\n });\n\n if (options?.timeout === undefined) {\n try {\n const result = await devbox.cmd.exec(fullCommand, executionParams);\n return await toCommandResult(result);\n } finally {\n callbacksActive = false;\n }\n }\n\n const timeoutMs = options.timeout;\n const deadline = startTime + Math.max(0, timeoutMs);\n const monitorController = new AbortController();\n let streamedStdout = \"\";\n let streamedStderr = \"\";\n let execution: Awaited<ReturnType<typeof devbox.cmd.execAsync>> | undefined;\n let resultPromise: ReturnType<Awaited<ReturnType<typeof devbox.cmd.execAsync>>[\"result\"]> | undefined;\n let streamPromises: Promise<void>[] = [];\n let executionCompleted = false;\n let timer: ReturnType<typeof setTimeout> | undefined;\n const timeoutPromise = new Promise<\"timeout\">((resolve) => {\n timer = setTimeout(() => {\n resolve(\"timeout\");\n monitorController.abort();\n }, Math.max(0, deadline - Date.now()));\n });\n const timeoutResult = (): CommandResult => ({\n stdout: streamedStdout,\n stderr: streamedStderr,\n exitCode: 124,\n durationMs: Date.now() - startTime,\n });\n\n try {\n // Keep creation alive after the caller's deadline. Aborting this non-idempotent\n // request can hide an execution that the server already accepted, leaving no ID\n // available for cleanup. The caller still returns at the deadline; if creation\n // resolves later, the timeout branch below kills the remote process group.\n const executionPromise = devbox.cmd.execAsync(fullCommand);\n const creationOutcome = await Promise.race([\n executionPromise.then((createdExecution) => ({ execution: createdExecution })),\n timeoutPromise,\n ]);\n\n if (creationOutcome === \"timeout\") {\n callbacksActive = false;\n void executionPromise\n .then((lateExecution) => bestEffortKillExecution(sandbox, lateExecution.executionId))\n .catch(() => undefined);\n return timeoutResult();\n }\n\n const activeExecution = creationOutcome.execution;\n execution = activeExecution;\n streamPromises = [\n streamExecutionOutput(\n () => sandbox.client.api.devboxes.executions.streamStdoutUpdates(\n sandbox.id,\n activeExecution.executionId,\n {},\n { signal: monitorController.signal },\n ),\n (chunk) => {\n streamedStdout += chunk;\n options.onStdout?.(chunk);\n },\n monitorController.signal,\n () => callbacksActive,\n ),\n streamExecutionOutput(\n () => sandbox.client.api.devboxes.executions.streamStderrUpdates(\n sandbox.id,\n activeExecution.executionId,\n {},\n { signal: monitorController.signal },\n ),\n (chunk) => {\n streamedStderr += chunk;\n options.onStderr?.(chunk);\n },\n monitorController.signal,\n () => callbacksActive,\n ),\n ];\n resultPromise = activeExecution.result({ signal: monitorController.signal });\n const outcome = await Promise.race([\n resultPromise.then((result) => ({ result })),\n timeoutPromise,\n ]);\n\n if (outcome === \"timeout\") {\n callbacksActive = false;\n monitorController.abort();\n await Promise.all([\n bestEffortKillExecution(sandbox, execution.executionId),\n Promise.allSettled([resultPromise, ...streamPromises]),\n ]);\n return timeoutResult();\n }\n\n executionCompleted = true;\n monitorController.abort();\n await Promise.allSettled(streamPromises);\n const commandResult = await toCommandResult(outcome.result);\n emitMissingOutput(streamedStdout, commandResult.stdout, options.onStdout);\n emitMissingOutput(streamedStderr, commandResult.stderr, options.onStderr);\n return commandResult;\n } catch (error) {\n callbacksActive = false;\n monitorController.abort();\n await Promise.all([\n executionCompleted || !execution\n ? Promise.resolve()\n : bestEffortKillExecution(sandbox, execution.executionId),\n Promise.allSettled([\n ...(resultPromise ? [resultPromise] : []),\n ...streamPromises,\n ]),\n ]);\n throw error;\n } finally {\n if (timer) clearTimeout(timer);\n callbacksActive = false;\n monitorController.abort();\n }\n}\n\nasync function runCommandWithErrors(\n sandbox: RunloopSandbox,\n command: string,\n options?: RunCommandOptions,\n): Promise<CommandResult> {\n try {\n return await executeCommand(sandbox, command, options);\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/**\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// Match the platform size presets and use Runloop's default custom disk for 2xl.\nconst STANDARD_DISK_GIB = { xs: 4, sm: 4, md: 8, lg: 16, xl: 16, \"2xl\": 16 } as const;\n/** Runloop custom sizes need at least 2 GiB of RAM per vCPU. */\nconst MIN_MEMORY_MIB_PER_VCPU = 2048;\n\nconst NATIVE_SIZE_FIELDS = [\n \"resource_size_request\",\n \"custom_cpu_cores\",\n \"custom_gb_memory\",\n \"custom_disk_size\",\n] as const;\n\n/**\n * Create a Runloop provider instance using the factory pattern\n */\nexport const runloop = defineProvider<\n RunloopSandbox,\n RunloopConfig,\n RunloopTemplate,\n Snapshot\n>({\n name: \"runloop\",\n sizes: (_config, { sizeClass, vcpus, memoryMiB }, options) => {\n // Core rejects launch_parameters; the create path also forwards top-level options.\n const conflict = NATIVE_SIZE_FIELDS.find((field) => options?.[field] !== undefined);\n if (conflict) {\n throw new InstanceSizeError(\"conflict\", `cannot combine sizeClass with Runloop ${conflict}`);\n }\n if (sizeClass === \"3xl\") {\n return {\n status: \"unsupported\",\n reason: \"Runloop custom sizes are capped at 16 vCPUs and 64 GiB RAM.\",\n };\n }\n\n const diskGiB = STANDARD_DISK_GIB[sizeClass];\n // vCPU picks the class; xs takes 1 vCPU / 2 GiB, the smallest custom size with a whole vCPU.\n const sizedMemoryMiB = Math.max(memoryMiB, vcpus * MIN_MEMORY_MIB_PER_VCPU);\n const launch_parameters = {\n resource_size_request: \"CUSTOM_SIZE\",\n custom_cpu_cores: vcpus,\n custom_gb_memory: sizedMemoryMiB / 1024,\n custom_disk_size: diskGiB,\n } satisfies NonNullable<Runloop.DevboxCreateParams[\"launch_parameters\"]>;\n\n return {\n status: \"supported\",\n resolved: { vcpus, memoryMiB: sizedMemoryMiB, diskMiB: diskGiB * 1024 },\n nativeOptions: { launch_parameters },\n };\n },\n methods: {\n instances: {\n create: async (config: RunloopConfig, options?: CreateInstanceOptions) => {\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 launch_parameters: optLaunchParameters,\n ...providerOptions\n } = options || {};\n\n const effectiveTimeout = optTimeout ?? timeout;\n const keepAliveSeconds = effectiveTimeout !== undefined\n ? Math.ceil(effectiveTimeout / 1000)\n : 1800;\n\n let devboxParams: Runloop.DevboxCreateParams = {\n launch_parameters: {\n keep_alive_time_seconds: keepAliveSeconds,\n ...optLaunchParameters,\n } as Runloop.DevboxCreateParams[\"launch_parameters\"],\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 { instance: runloopSandbox, instanceId: 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 { instance: { ...devbox, client } as RunloopSandbox,\n instanceId: sandboxId,\n };\n } catch (error) {\n if (isHttpNotFound(error)) return null;\n throw error;\n }\n },\n\n list: async (config: RunloopConfig) => {\n const client = getRunloopClient(config);\n const devboxes = await collectPaginated(client.api.devboxes.list());\n\n return devboxes.map((devbox) => ({\n instance: { ...devbox, client } as RunloopSandbox, instanceId: devbox.id,\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 (error) {\n if (!isHttpNotFound(error)) throw error;\n }\n },\n\n runCommand: runCommandWithErrors,\n\n streamCommand: runCommandWithErrors,\n\n getInfo: async (sandbox: RunloopSandbox): Promise<InstanceInfo> => {\n const devbox = await sandbox.client.api.devboxes.retrieve(sandbox.id);\n const keepAliveSecs = devbox.launch_parameters?.keep_alive_time_seconds;\n\n return {\n id: devbox.id || \"runloop-unknown\",\n provider: \"runloop\",\n status: mapStatus(devbox.status),\n createdAt: new Date(devbox.create_time_ms || Date.now()),\n // keep_alive_time_seconds is in seconds; InstanceInfo.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): Promise<string> => {\n return sandbox.client.devbox.fromId(sandbox.id).file.read({ file_path: path });\n },\n\n writeFile: async (sandbox: RunloopSandbox, path: string, content: string): Promise<void> => {\n const result = await sandbox.client.devbox.fromId(sandbox.id).file.write({\n file_path: path,\n contents: content,\n });\n if (result.exit_status !== 0) {\n throw new Error(\n `Failed to write file ${path}: ${result.stderr || `exit ${result.exit_status}`}`,\n );\n }\n },\n\n mkdir: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n const result = await runCommand(sandbox, `mkdir -p -- ${quotePosixShellToken(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, buildReaddirCommand(path));\n if (result.exitCode !== 0) throw new Error(`Failed to list directory ${path}: ${result.stderr}`);\n\n return parseReaddirOutput(result.stdout || \"\");\n },\n\n exists: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<boolean> => {\n const result = await runCommand(sandbox, `test -e ${quotePosixShellToken(path)}`);\n return result.exitCode === 0;\n },\n\n remove: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n assertSafeRemovalPath(path);\n const result = await runCommand(sandbox, `rm -rf -- ${quotePosixShellToken(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: Runloop.BlueprintListParams = {};\n if (options?.limit !== undefined) listParams.limit = options.limit;\n return collectPaginated(client.api.blueprints.list(listParams), options?.limit);\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: Runloop.DevboxSnapshotDiskParams = {};\n if (options?.name) snapshotParams.name = options.name;\n if (options?.metadata) snapshotParams.metadata = options.metadata;\n const snapshot = await client.api.devboxes.snapshotDisk(sandboxId, snapshotParams);\n return normalizeSnapshot(snapshot);\n },\n\n list: async (config: RunloopConfig, options?: ListSnapshotsOptions) => {\n const client = getRunloopClient(config);\n const listParams: Runloop.DevboxListDiskSnapshotsParams = {};\n if (options?.limit !== undefined) listParams.limit = options.limit;\n if (options?.sandboxId) listParams.devbox_id = options.sandboxId;\n const snapshots = await collectPaginated(\n client.api.devboxes.listDiskSnapshots(listParams),\n options?.limit,\n );\n return snapshots.map(normalizeSnapshot);\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,yBAAyB;AAClD,SAAS,SAAS,iBAAiB;AAmCnC,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,WAA0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AQ;AAAA,MACnC;AAAA,MAEA,MAAM,OAAO,QAAuB,YAAmC;AACrE,cAAM,SAAS,iBAAiB,MAAM;AACtC,cAAM,aAAoD,CAAC;AAC3D,YAAI,SAAS,UAAU,OAAW,YAAW,QAAQ,QAAQ;AAC7D,YAAI,SAAS,UAAW,YAAW,YAAY,QAAQ;AACvD,cAAM,YAAY,MAAM;AAAA,UACtB,OAAO,IAAI,SAAS,kBAAkB,UAAU;AAAA,UAChD,SAAS;AAAA,QACX;AACA,eAAO,UAAU,IAAI,iBAAiB;AAAA,MACxC;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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@computesdk/runloop",
|
|
3
|
-
"version": "1.3.
|
|
4
|
-
"description": "Runloop
|
|
3
|
+
"version": "1.3.81",
|
|
4
|
+
"description": "Runloop sandbox adapter for ComputeSDK. Run commands and work with files in Runloop Devboxes.",
|
|
5
5
|
"author": "Runloop",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@runloop/api-client": "^1.30.0",
|
|
22
|
-
"@computesdk/provider": "2.1.
|
|
23
|
-
"computesdk": "4.1.
|
|
22
|
+
"@computesdk/provider": "2.1.29",
|
|
23
|
+
"computesdk": "4.1.23"
|
|
24
24
|
},
|
|
25
25
|
"keywords": [
|
|
26
26
|
"computesdk",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"url": "https://github.com/computesdk/computesdk.git",
|
|
40
40
|
"directory": "packages/runloop"
|
|
41
41
|
},
|
|
42
|
-
"homepage": "https://
|
|
42
|
+
"homepage": "https://github.com/computesdk/computesdk/tree/main/packages/runloop#readme",
|
|
43
43
|
"bugs": {
|
|
44
44
|
"url": "https://github.com/computesdk/computesdk/issues"
|
|
45
45
|
},
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"tsup": "^8.0.0",
|
|
52
52
|
"typescript": "^5.0.0",
|
|
53
53
|
"vitest": "^1.0.0",
|
|
54
|
-
"@computesdk/test-utils": "2.0.
|
|
54
|
+
"@computesdk/test-utils": "2.0.7"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"build": "tsup",
|