@computesdk/runloop 1.3.55 → 1.3.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  // src/index.ts
2
2
  import { RunloopSDK } from "@runloop/api-client";
3
- import { defineProvider, escapeShellArg } from "@computesdk/provider";
3
+ import { defineProvider } from "@computesdk/provider";
4
+ import { posix as posixPath } from "path";
4
5
  var clientCache = /* @__PURE__ */ new WeakMap();
5
6
  function resolveApiKey(config) {
6
7
  return config.apiKey || typeof process !== "undefined" && process.env?.RUNLOOP_API_KEY || "";
@@ -24,9 +25,286 @@ function getRunloopClient(config) {
24
25
  function longPollOptions(timeoutMs) {
25
26
  return timeoutMs ? { longPoll: { timeoutMs } } : void 0;
26
27
  }
27
- function optimisticTimeoutSeconds(timeoutMs) {
28
- if (!timeoutMs) return 25;
29
- return Math.max(1, Math.min(25, Math.ceil(timeoutMs / 1e3)));
28
+ function quotePosixShellToken(value) {
29
+ return `'${value.replace(/'/g, `'"'"'`)}'`;
30
+ }
31
+ function assertSafeRemovalPath(value) {
32
+ const normalized = posixPath.normalize(value);
33
+ if (value.length === 0 || normalized === "/" || normalized === "." || normalized === ".." || normalized.startsWith("../")) {
34
+ throw new Error(`Refusing to remove unsafe path: ${JSON.stringify(value)}`);
35
+ }
36
+ }
37
+ function buildCommand(command, options) {
38
+ let fullCommand = command;
39
+ if (options?.env && Object.keys(options.env).length > 0) {
40
+ const envPrefix = Object.entries(options.env).map(([key, value]) => {
41
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) {
42
+ throw new Error(`Invalid environment variable name: ${JSON.stringify(key)}`);
43
+ }
44
+ return `${key}=${quotePosixShellToken(String(value))}`;
45
+ }).join(" ");
46
+ fullCommand = `${envPrefix} ${fullCommand}`;
47
+ }
48
+ if (options?.cwd) {
49
+ fullCommand = `cd -- ${quotePosixShellToken(options.cwd)} && ${fullCommand}`;
50
+ }
51
+ if (options?.background) {
52
+ fullCommand = `nohup sh -lc ${quotePosixShellToken(fullCommand)} >/dev/null 2>&1 &`;
53
+ }
54
+ return fullCommand;
55
+ }
56
+ function isHttpNotFound(error) {
57
+ return typeof error === "object" && error !== null && "status" in error && error.status === 404;
58
+ }
59
+ var READDIR_ENTRY_SCRIPT = [
60
+ "for entry; do",
61
+ " name=${entry##*/}",
62
+ ' if [ -d "$entry" ]; then type=directory; else type=file; fi',
63
+ ' encoded=$(printf %s "$name" | base64 | tr -d "\\n")',
64
+ ' size=$(stat -c %s -- "$entry") || exit',
65
+ ' modified=$(stat -c %Y -- "$entry") || exit',
66
+ ' printf "%s\\t%s\\t%s\\t%s\\n" "$encoded" "$type" "$size" "$modified"',
67
+ "done"
68
+ ].join("\n");
69
+ function buildReaddirCommand(path) {
70
+ const findRoot = path.startsWith("-") ? `./${path}` : path;
71
+ return [
72
+ `find -- ${quotePosixShellToken(findRoot)} -mindepth 1 -maxdepth 1 -exec sh -c`,
73
+ quotePosixShellToken(READDIR_ENTRY_SCRIPT),
74
+ "sh {} +"
75
+ ].join(" ");
76
+ }
77
+ function parseReaddirOutput(stdout) {
78
+ return stdout.split("\n").filter(Boolean).map((line) => {
79
+ const [encodedName, type, rawSize, rawModified] = line.split(" ");
80
+ const size = Number(rawSize);
81
+ const modifiedSeconds = Number(rawModified);
82
+ if (!encodedName || type !== "file" && type !== "directory" || !Number.isFinite(size) || !Number.isFinite(modifiedSeconds)) {
83
+ throw new Error(`Malformed Runloop directory entry: ${JSON.stringify(line)}`);
84
+ }
85
+ return {
86
+ name: Buffer.from(encodedName, "base64").toString("utf8"),
87
+ type,
88
+ size,
89
+ modified: new Date(modifiedSeconds * 1e3)
90
+ };
91
+ });
92
+ }
93
+ function mapStatus(status) {
94
+ switch (status) {
95
+ case "scheduled":
96
+ case "queued":
97
+ case "provisioning":
98
+ case "initializing":
99
+ case "resuming":
100
+ case "running":
101
+ return "running";
102
+ case "suspending":
103
+ case "suspended":
104
+ case "shutdown":
105
+ return "stopped";
106
+ case "failure":
107
+ return "error";
108
+ }
109
+ }
110
+ async function collectPaginated(source, limit) {
111
+ if (limit !== void 0 && limit <= 0) return [];
112
+ const results = [];
113
+ for await (const item of source) {
114
+ results.push(item);
115
+ if (limit !== void 0 && results.length >= limit) break;
116
+ }
117
+ return results;
118
+ }
119
+ function normalizeSnapshot(snapshot) {
120
+ return {
121
+ id: snapshot.id,
122
+ provider: "runloop",
123
+ createdAt: new Date(snapshot.create_time_ms),
124
+ metadata: {
125
+ name: snapshot.name ?? null,
126
+ sourceDevboxId: snapshot.source_devbox_id,
127
+ sourceBlueprintId: snapshot.source_blueprint_id ?? null,
128
+ sizeBytes: snapshot.size_bytes ?? null,
129
+ commitMessage: snapshot.commit_message ?? null,
130
+ userMetadata: snapshot.metadata ?? {}
131
+ }
132
+ };
133
+ }
134
+ function emitMissingOutput(emitted, complete, callback) {
135
+ if (!callback || !complete || emitted.includes(complete)) return;
136
+ if (!emitted) {
137
+ callback(complete);
138
+ } else if (complete.startsWith(emitted)) {
139
+ callback(complete.slice(emitted.length));
140
+ } else if (!complete.includes(emitted)) {
141
+ callback(complete);
142
+ }
143
+ }
144
+ async function streamExecutionOutput(openStream, onChunk, signal, isActive) {
145
+ try {
146
+ const stream = await openStream();
147
+ for await (const chunk of stream) {
148
+ if (signal.aborted) break;
149
+ if (isActive()) onChunk(chunk.output);
150
+ }
151
+ } catch {
152
+ }
153
+ }
154
+ async function bestEffortKillExecution(sandbox, executionId) {
155
+ let killTimer;
156
+ try {
157
+ await Promise.race([
158
+ sandbox.client.api.devboxes.executions.kill(
159
+ sandbox.id,
160
+ executionId,
161
+ { kill_process_group: true }
162
+ ).catch(() => void 0),
163
+ new Promise((resolve) => {
164
+ killTimer = setTimeout(resolve, 1e3);
165
+ })
166
+ ]);
167
+ } finally {
168
+ if (killTimer) clearTimeout(killTimer);
169
+ }
170
+ }
171
+ async function executeCommand(sandbox, command, options) {
172
+ const startTime = Date.now();
173
+ const devbox = sandbox.client.devbox.fromId(sandbox.id);
174
+ const fullCommand = buildCommand(command, options);
175
+ let callbacksActive = true;
176
+ const executionParams = {
177
+ ...options?.onStdout ? { stdout: (chunk) => callbacksActive && options.onStdout?.(chunk) } : {},
178
+ ...options?.onStderr ? { stderr: (chunk) => callbacksActive && options.onStderr?.(chunk) } : {}
179
+ };
180
+ const toCommandResult = async (result) => ({
181
+ stdout: await result.stdout(),
182
+ stderr: await result.stderr(),
183
+ exitCode: result.exitCode ?? -1,
184
+ durationMs: Date.now() - startTime
185
+ });
186
+ if (options?.timeout === void 0) {
187
+ try {
188
+ const result = await devbox.cmd.exec(fullCommand, executionParams);
189
+ return await toCommandResult(result);
190
+ } finally {
191
+ callbacksActive = false;
192
+ }
193
+ }
194
+ const timeoutMs = options.timeout;
195
+ const deadline = startTime + Math.max(0, timeoutMs);
196
+ const monitorController = new AbortController();
197
+ let streamedStdout = "";
198
+ let streamedStderr = "";
199
+ let execution;
200
+ let resultPromise;
201
+ let streamPromises = [];
202
+ let executionCompleted = false;
203
+ let timer;
204
+ const timeoutPromise = new Promise((resolve) => {
205
+ timer = setTimeout(() => {
206
+ resolve("timeout");
207
+ monitorController.abort();
208
+ }, Math.max(0, deadline - Date.now()));
209
+ });
210
+ const timeoutResult = () => ({
211
+ stdout: streamedStdout,
212
+ stderr: streamedStderr,
213
+ exitCode: 124,
214
+ durationMs: Date.now() - startTime
215
+ });
216
+ try {
217
+ const executionPromise = devbox.cmd.execAsync(fullCommand);
218
+ const creationOutcome = await Promise.race([
219
+ executionPromise.then((createdExecution) => ({ execution: createdExecution })),
220
+ timeoutPromise
221
+ ]);
222
+ if (creationOutcome === "timeout") {
223
+ callbacksActive = false;
224
+ void executionPromise.then((lateExecution) => bestEffortKillExecution(sandbox, lateExecution.executionId)).catch(() => void 0);
225
+ return timeoutResult();
226
+ }
227
+ const activeExecution = creationOutcome.execution;
228
+ execution = activeExecution;
229
+ streamPromises = [
230
+ streamExecutionOutput(
231
+ () => sandbox.client.api.devboxes.executions.streamStdoutUpdates(
232
+ sandbox.id,
233
+ activeExecution.executionId,
234
+ {},
235
+ { signal: monitorController.signal }
236
+ ),
237
+ (chunk) => {
238
+ streamedStdout += chunk;
239
+ options.onStdout?.(chunk);
240
+ },
241
+ monitorController.signal,
242
+ () => callbacksActive
243
+ ),
244
+ streamExecutionOutput(
245
+ () => sandbox.client.api.devboxes.executions.streamStderrUpdates(
246
+ sandbox.id,
247
+ activeExecution.executionId,
248
+ {},
249
+ { signal: monitorController.signal }
250
+ ),
251
+ (chunk) => {
252
+ streamedStderr += chunk;
253
+ options.onStderr?.(chunk);
254
+ },
255
+ monitorController.signal,
256
+ () => callbacksActive
257
+ )
258
+ ];
259
+ resultPromise = activeExecution.result({ signal: monitorController.signal });
260
+ const outcome = await Promise.race([
261
+ resultPromise.then((result) => ({ result })),
262
+ timeoutPromise
263
+ ]);
264
+ if (outcome === "timeout") {
265
+ callbacksActive = false;
266
+ monitorController.abort();
267
+ await Promise.all([
268
+ bestEffortKillExecution(sandbox, execution.executionId),
269
+ Promise.allSettled([resultPromise, ...streamPromises])
270
+ ]);
271
+ return timeoutResult();
272
+ }
273
+ executionCompleted = true;
274
+ monitorController.abort();
275
+ await Promise.allSettled(streamPromises);
276
+ const commandResult = await toCommandResult(outcome.result);
277
+ emitMissingOutput(streamedStdout, commandResult.stdout, options.onStdout);
278
+ emitMissingOutput(streamedStderr, commandResult.stderr, options.onStderr);
279
+ return commandResult;
280
+ } catch (error) {
281
+ callbacksActive = false;
282
+ monitorController.abort();
283
+ await Promise.all([
284
+ executionCompleted || !execution ? Promise.resolve() : bestEffortKillExecution(sandbox, execution.executionId),
285
+ Promise.allSettled([
286
+ ...resultPromise ? [resultPromise] : [],
287
+ ...streamPromises
288
+ ])
289
+ ]);
290
+ throw error;
291
+ } finally {
292
+ if (timer) clearTimeout(timer);
293
+ callbacksActive = false;
294
+ monitorController.abort();
295
+ }
296
+ }
297
+ async function runCommandWithErrors(sandbox, command, options) {
298
+ try {
299
+ return await executeCommand(sandbox, command, options);
300
+ } catch (error) {
301
+ if (error instanceof Error && error.message.includes("Syntax error")) {
302
+ throw error;
303
+ }
304
+ throw new Error(
305
+ `Runloop execution failed: ${error instanceof Error ? error.message : String(error)}`
306
+ );
307
+ }
30
308
  }
31
309
  var runloop = defineProvider({
32
310
  name: "runloop",
@@ -51,7 +329,7 @@ var runloop = defineProvider({
51
329
  ...providerOptions
52
330
  } = options || {};
53
331
  const effectiveTimeout = optTimeout ?? timeout;
54
- const keepAliveSeconds = effectiveTimeout ? Math.ceil(effectiveTimeout / 1e3) : 1800;
332
+ const keepAliveSeconds = effectiveTimeout !== void 0 ? Math.ceil(effectiveTimeout / 1e3) : 1800;
55
333
  let devboxParams = {
56
334
  launch_parameters: {
57
335
  keep_alive_time_seconds: keepAliveSeconds,
@@ -97,72 +375,36 @@ var runloop = defineProvider({
97
375
  sandbox: { ...devbox, client },
98
376
  sandboxId
99
377
  };
100
- } catch {
101
- return null;
378
+ } catch (error) {
379
+ if (isHttpNotFound(error)) return null;
380
+ throw error;
102
381
  }
103
382
  },
104
383
  list: async (config) => {
105
- try {
106
- const client = getRunloopClient(config);
107
- const response = await client.api.devboxes.list();
108
- const devboxes = response.devboxes || [];
109
- return devboxes.map((devbox) => ({
110
- sandbox: { ...devbox, client },
111
- sandboxId: devbox.id
112
- }));
113
- } catch {
114
- return [];
115
- }
384
+ const client = getRunloopClient(config);
385
+ const devboxes = await collectPaginated(client.api.devboxes.list());
386
+ return devboxes.map((devbox) => ({
387
+ sandbox: { ...devbox, client },
388
+ sandboxId: devbox.id
389
+ }));
116
390
  },
117
391
  destroy: async (config, sandboxId) => {
118
392
  try {
119
393
  const client = getRunloopClient(config);
120
394
  await client.api.devboxes.shutdown(sandboxId);
121
- } catch {
122
- }
123
- },
124
- runCommand: async (sandbox, command, options) => {
125
- const startTime = Date.now();
126
- const devbox = sandbox;
127
- const client = sandbox.client;
128
- try {
129
- let fullCommand = command;
130
- if (options?.env && Object.keys(options.env).length > 0) {
131
- const envPrefix = Object.entries(options.env).map(([k, v]) => `${k}="${escapeShellArg(String(v))}"`).join(" ");
132
- fullCommand = `${envPrefix} ${fullCommand}`;
133
- }
134
- if (options?.cwd) {
135
- fullCommand = `cd "${escapeShellArg(options.cwd)}" && ${fullCommand}`;
136
- }
137
- if (options?.background) {
138
- fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;
139
- }
140
- const executionResult = await client.api.devboxes.executeAndAwaitCompletion(devbox.id, {
141
- command: fullCommand,
142
- optimistic_timeout: optimisticTimeoutSeconds(options?.timeout)
143
- }, longPollOptions(options?.timeout));
144
- return {
145
- stdout: executionResult.stdout || "",
146
- stderr: executionResult.stderr || "",
147
- exitCode: executionResult.exit_status || 0,
148
- durationMs: Date.now() - startTime
149
- };
150
395
  } catch (error) {
151
- if (error instanceof Error && error.message.includes("Syntax error")) {
152
- throw error;
153
- }
154
- throw new Error(
155
- `Runloop execution failed: ${error instanceof Error ? error.message : String(error)}`
156
- );
396
+ if (!isHttpNotFound(error)) throw error;
157
397
  }
158
398
  },
399
+ runCommand: runCommandWithErrors,
400
+ streamCommand: runCommandWithErrors,
159
401
  getInfo: async (sandbox) => {
160
- const devbox = sandbox;
161
- const keepAliveSecs = devbox.launch_parameters.keep_alive_time_seconds;
402
+ const devbox = await sandbox.client.api.devboxes.retrieve(sandbox.id);
403
+ const keepAliveSecs = devbox.launch_parameters?.keep_alive_time_seconds;
162
404
  return {
163
405
  id: devbox.id || "runloop-unknown",
164
406
  provider: "runloop",
165
- status: devbox.status,
407
+ status: mapStatus(devbox.status),
166
408
  createdAt: new Date(devbox.create_time_ms || Date.now()),
167
409
  // keep_alive_time_seconds is in seconds; SandboxInfo.timeout is in milliseconds
168
410
  timeout: keepAliveSecs ? keepAliveSecs * 1e3 : 3e5,
@@ -187,42 +429,36 @@ var runloop = defineProvider({
187
429
  }
188
430
  },
189
431
  filesystem: {
190
- readFile: async (sandbox, path, runCommand) => {
191
- const result = await runCommand(sandbox, `test -f "${path}" && base64 < "${path}" | tr -d '\\n'`);
192
- if (result.exitCode !== 0) throw new Error(`File not found or unreadable: ${result.stderr}`);
193
- return Buffer.from(result.stdout, "base64").toString("utf8");
432
+ readFile: async (sandbox, path) => {
433
+ return sandbox.client.devbox.fromId(sandbox.id).file.read({ file_path: path });
194
434
  },
195
- writeFile: async (sandbox, path, content, runCommand) => {
196
- const encoded = Buffer.from(content).toString("base64");
197
- const result = await runCommand(sandbox, `sh -c 'echo "${encoded}" | base64 -d > "${path}"'`);
198
- if (result.exitCode !== 0) throw new Error(`Failed to write file ${path}: ${result.stderr}`);
435
+ writeFile: async (sandbox, path, content) => {
436
+ const result = await sandbox.client.devbox.fromId(sandbox.id).file.write({
437
+ file_path: path,
438
+ contents: content
439
+ });
440
+ if (result.exit_status !== 0) {
441
+ throw new Error(
442
+ `Failed to write file ${path}: ${result.stderr || `exit ${result.exit_status}`}`
443
+ );
444
+ }
199
445
  },
200
446
  mkdir: async (sandbox, path, runCommand) => {
201
- const result = await runCommand(sandbox, `mkdir -p "${path}"`);
447
+ const result = await runCommand(sandbox, `mkdir -p -- ${quotePosixShellToken(path)}`);
202
448
  if (result.exitCode !== 0) throw new Error(`Failed to create directory ${path}: ${result.stderr}`);
203
449
  },
204
450
  readdir: async (sandbox, path, runCommand) => {
205
- const result = await runCommand(sandbox, `ls -la "${path}"`);
451
+ const result = await runCommand(sandbox, buildReaddirCommand(path));
206
452
  if (result.exitCode !== 0) throw new Error(`Failed to list directory ${path}: ${result.stderr}`);
207
- const lines = (result.stdout || "").split("\n").filter((line) => line.trim() && !line.startsWith("total"));
208
- return lines.map((line) => {
209
- const parts = line.trim().split(/\s+/);
210
- const name = parts[parts.length - 1];
211
- const isDirectory = line.startsWith("d");
212
- return {
213
- name,
214
- type: isDirectory ? "directory" : "file",
215
- size: parseInt(parts[4]) || 0,
216
- modified: /* @__PURE__ */ new Date()
217
- };
218
- });
453
+ return parseReaddirOutput(result.stdout || "");
219
454
  },
220
455
  exists: async (sandbox, path, runCommand) => {
221
- const result = await runCommand(sandbox, `test -e "${path}"`);
456
+ const result = await runCommand(sandbox, `test -e ${quotePosixShellToken(path)}`);
222
457
  return result.exitCode === 0;
223
458
  },
224
459
  remove: async (sandbox, path, runCommand) => {
225
- const result = await runCommand(sandbox, `rm -rf "${path}"`);
460
+ assertSafeRemovalPath(path);
461
+ const result = await runCommand(sandbox, `rm -rf -- ${quotePosixShellToken(path)}`);
226
462
  if (result.exitCode !== 0) throw new Error(`Failed to remove ${path}: ${result.stderr}`);
227
463
  }
228
464
  },
@@ -236,9 +472,8 @@ var runloop = defineProvider({
236
472
  list: async (config, options) => {
237
473
  const client = getRunloopClient(config);
238
474
  const listParams = {};
239
- if (options?.limit) listParams.limit = options.limit;
240
- const response = await client.api.blueprints.list(listParams);
241
- return response.blueprints || [];
475
+ if (options?.limit !== void 0) listParams.limit = options.limit;
476
+ return collectPaginated(client.api.blueprints.list(listParams), options?.limit);
242
477
  },
243
478
  delete: async (config, blueprintId) => {
244
479
  const client = getRunloopClient(config);
@@ -251,14 +486,19 @@ var runloop = defineProvider({
251
486
  const snapshotParams = {};
252
487
  if (options?.name) snapshotParams.name = options.name;
253
488
  if (options?.metadata) snapshotParams.metadata = options.metadata;
254
- return client.api.devboxes.snapshotDisk(sandboxId, snapshotParams);
489
+ const snapshot = await client.api.devboxes.snapshotDisk(sandboxId, snapshotParams);
490
+ return normalizeSnapshot(snapshot);
255
491
  },
256
492
  list: async (config, options) => {
257
493
  const client = getRunloopClient(config);
258
494
  const listParams = {};
259
- if (options?.limit) listParams.limit = options.limit;
260
- const response = await client.api.devboxes.listDiskSnapshots(listParams);
261
- return response.snapshots || [];
495
+ if (options?.limit !== void 0) listParams.limit = options.limit;
496
+ if (options?.sandboxId) listParams.devbox_id = options.sandboxId;
497
+ const snapshots = await collectPaginated(
498
+ client.api.devboxes.listDiskSnapshots(listParams),
499
+ options?.limit
500
+ );
501
+ return snapshots.map(normalizeSnapshot);
262
502
  },
263
503
  delete: async (config, snapshotId) => {
264
504
  const client = getRunloopClient(config);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Runloop Provider - Factory-based Implementation\n *\n * Full-featured provider with filesystem support using the factory pattern.\n * Reduces ~400 lines of boilerplate to ~100 lines of core logic.\n */\n\nimport { RunloopSDK, type Runloop } from \"@runloop/api-client\";\nimport { defineProvider, escapeShellArg } from \"@computesdk/provider\";\nimport type {\n CommandResult,\n SandboxInfo,\n CreateSnapshotOptions,\n ListSnapshotsOptions,\n RunCommandOptions,\n} from \"@computesdk/provider\";\nimport type {\n CreateSandboxOptions,\n FileEntry,\n} from \"computesdk\";\n\n// Define Runloop-specific types\ntype RunloopSnapshot = Runloop.DevboxSnapshotView;\ntype RunloopTemplate = Runloop.BlueprintView;\ntype RunloopSandbox = Runloop.DevboxView & { client: RunloopSDK };\ntype RunloopCreateWaitOptions = Parameters<RunloopSDK[\"api\"][\"devboxes\"][\"createAndAwaitRunning\"]>[1];\ntype RunloopExecuteWaitOptions = Parameters<RunloopSDK[\"api\"][\"devboxes\"][\"executeAndAwaitCompletion\"]>[2];\n\ntype CommandRunner = (\n sandbox: RunloopSandbox,\n command: string,\n options?: RunCommandOptions\n) => Promise<CommandResult>;\n\n/**\n * Runloop-specific configuration options\n */\nexport interface RunloopConfig {\n /** Runloop API key - if not provided, will fallback to RUNLOOP_API_KEY environment variable */\n apiKey?: string;\n /** Execution timeout in milliseconds */\n timeout?: number;\n}\n\nconst clientCache = new WeakMap<RunloopConfig, RunloopSDK>();\n\nfunction resolveApiKey(config: RunloopConfig): string {\n return (\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.RUNLOOP_API_KEY) ||\n \"\"\n );\n}\n\nfunction getRunloopClient(config: RunloopConfig): RunloopSDK {\n const apiKey = resolveApiKey(config);\n if (!apiKey) {\n throw new Error(\n `Missing Runloop API key. Provide 'apiKey' in config or set RUNLOOP_API_KEY environment variable. Get your API key from https://runloop.ai/`\n );\n }\n\n const cached = clientCache.get(config);\n if (cached) return cached;\n\n const client = new RunloopSDK({\n bearerToken: apiKey,\n http2: true,\n });\n clientCache.set(config, client);\n return client;\n}\n\nfunction longPollOptions<TOptions>(timeoutMs?: number): TOptions | undefined {\n return timeoutMs ? ({ longPoll: { timeoutMs } } as TOptions) : undefined;\n}\n\nfunction optimisticTimeoutSeconds(timeoutMs?: number): number {\n if (!timeoutMs) return 25;\n return Math.max(1, Math.min(25, Math.ceil(timeoutMs / 1000)));\n}\n\n/**\n * Runloop-specific blueprint creation options\n */\nexport interface CreateBlueprintTemplateOptions {\n /** Name of the blueprint template */\n name: string;\n /** Custom Dockerfile content */\n dockerfile?: string;\n /** System setup commands to run during blueprint creation */\n systemSetupCommands?: string[];\n /** Launch commands to run when starting a devbox from this blueprint */\n launchCommands?: string[];\n /** File mounts as key-value pairs (path -> content) */\n fileMounts?: Record<string, string>;\n /** Code repository mounts */\n codeMounts?: Array<{\n repoName: string;\n repoOwner: string;\n token?: string;\n installCommand?: string;\n }>;\n /** Resource size for devboxes created from this blueprint */\n resourceSize?:\n | \"X_SMALL\"\n | \"SMALL\"\n | \"MEDIUM\"\n | \"LARGE\"\n | \"X_LARGE\"\n | \"XX_LARGE\"\n | \"CUSTOM_SIZE\";\n /** CPU architecture */\n architecture?: \"x86_64\" | \"arm64\";\n /** Custom CPU cores (requires CUSTOM_SIZE) */\n customCpuCores?: number;\n /** Custom memory in GB (requires CUSTOM_SIZE) */\n customMemoryGb?: number;\n /** Custom disk size (requires CUSTOM_SIZE) */\n customDiskSize?: number;\n /** Available ports for the devbox */\n availablePorts?: number[];\n /** Action to take when devbox is idle */\n afterIdle?: { action: string; timeSeconds: number };\n /** Keep alive time in seconds */\n keepAliveTimeSeconds?: number;\n}\n\n/**\n * Create a Runloop provider instance using the factory pattern\n */\nexport const runloop = defineProvider<\n RunloopSandbox,\n RunloopConfig,\n RunloopTemplate,\n RunloopSnapshot\n>({\n name: \"runloop\",\n methods: {\n sandbox: {\n create: async (config: RunloopConfig, options?: CreateSandboxOptions) => {\n const timeout = config.timeout;\n\n try {\n const client = getRunloopClient(config);\n\n const {\n timeout: optTimeout,\n envs,\n name,\n metadata,\n templateId,\n snapshotId,\n sandboxId: optSandboxId,\n ports: _ports,\n namespace: _namespace,\n directory: _directory,\n launch_parameters: optLaunchParameters,\n ...providerOptions\n } = options || {};\n\n const effectiveTimeout = optTimeout ?? timeout;\n const keepAliveSeconds = effectiveTimeout\n ? Math.ceil(effectiveTimeout / 1000)\n : 1800;\n\n let devboxParams: Runloop.DevboxCreateParams = {\n launch_parameters: {\n keep_alive_time_seconds: keepAliveSeconds,\n ...(optLaunchParameters as Partial<Runloop.DevboxCreateParams['launch_parameters']> | undefined),\n },\n name: name || optSandboxId,\n metadata,\n environment_variables: envs,\n ...providerOptions,\n };\n\n // snapshotId is the canonical cross-provider field — map it directly to snapshot_id.\n // templateId is kept for backwards compatibility: bpt_ prefix → blueprint_id, snp_ prefix → snapshot_id.\n if (snapshotId) {\n devboxParams.snapshot_id = snapshotId;\n } else if (templateId) {\n if (templateId.startsWith(\"bpt_\")) {\n devboxParams.blueprint_id = templateId;\n } else if (templateId.startsWith(\"snp_\")) {\n devboxParams.snapshot_id = templateId;\n }\n }\n\n const dbx = await client.api.devboxes.createAndAwaitRunning(\n devboxParams,\n longPollOptions<RunloopCreateWaitOptions>(effectiveTimeout),\n );\n\n const runloopSandbox: RunloopSandbox = {\n ...dbx,\n client: client\n };\n\n return {\n sandbox: runloopSandbox,\n sandboxId: dbx.id,\n };\n } catch (error) {\n throw new Error(\n `Failed to create Runloop devbox: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n getById: async (config: RunloopConfig, sandboxId: string) => {\n try {\n const client = getRunloopClient(config);\n const devbox = await client.api.devboxes.retrieve(sandboxId);\n return {\n sandbox: { ...devbox, client } as RunloopSandbox,\n sandboxId,\n };\n } catch {\n return null;\n }\n },\n\n list: async (config: RunloopConfig) => {\n try {\n const client = getRunloopClient(config);\n const response = await client.api.devboxes.list();\n const devboxes = response.devboxes || [];\n\n return devboxes.map((devbox) => ({\n sandbox: { ...devbox, client } as RunloopSandbox,\n sandboxId: devbox.id,\n }));\n } catch {\n return [];\n }\n },\n\n destroy: async (config: RunloopConfig, sandboxId: string) => {\n try {\n const client = getRunloopClient(config);\n await client.api.devboxes.shutdown(sandboxId);\n } catch {\n // Devbox might already be destroyed or doesn't exist\n }\n },\n\n runCommand: async (\n sandbox: RunloopSandbox,\n command: string,\n options?: RunCommandOptions\n ): Promise<CommandResult> => {\n const startTime = Date.now();\n const devbox = sandbox;\n const client = sandbox.client;\n\n try {\n let fullCommand = command;\n\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([k, v]) => `${k}=\"${escapeShellArg(String(v))}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n\n if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n\n const executionResult =\n await client.api.devboxes.executeAndAwaitCompletion(devbox.id, {\n command: fullCommand,\n optimistic_timeout: optimisticTimeoutSeconds(options?.timeout),\n }, longPollOptions<RunloopExecuteWaitOptions>(options?.timeout));\n\n return {\n stdout: executionResult.stdout || \"\",\n stderr: executionResult.stderr || \"\",\n exitCode: executionResult.exit_status || 0,\n durationMs: Date.now() - startTime,\n };\n } catch (error) {\n if (error instanceof Error && error.message.includes(\"Syntax error\")) {\n throw error;\n }\n throw new Error(\n `Runloop execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n getInfo: async (sandbox): Promise<SandboxInfo> => {\n const devbox = sandbox;\n const keepAliveSecs = devbox.launch_parameters.keep_alive_time_seconds;\n\n return {\n id: devbox.id || \"runloop-unknown\",\n provider: \"runloop\",\n status: devbox.status as 'running' | 'stopped' | 'error',\n createdAt: new Date(devbox.create_time_ms || Date.now()),\n // keep_alive_time_seconds is in seconds; SandboxInfo.timeout is in milliseconds\n timeout: keepAliveSecs ? keepAliveSecs * 1000 : 300000,\n metadata: {\n runloopDevboxId: devbox.id,\n templateId: devbox.blueprint_id || devbox.snapshot_id,\n runtime: 'node',\n ...devbox.metadata,\n },\n };\n },\n\n getUrl: async (\n sandbox: RunloopSandbox,\n options: { port: number }\n ): Promise<string> => {\n const devbox = sandbox;\n const client = sandbox.client;\n\n try {\n const tunnel = await client.api.devboxes.enableTunnel(devbox.id);\n return `https://${options.port}-${tunnel.tunnel_key}.tunnel.runloop.ai`;\n } catch (error) {\n throw new Error(\n `Failed to get Runloop URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n filesystem: {\n readFile: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<string> => {\n const result = await runCommand(sandbox, `test -f \"${path}\" && base64 < \"${path}\" | tr -d '\\\\n'`);\n if (result.exitCode !== 0) throw new Error(`File not found or unreadable: ${result.stderr}`);\n return Buffer.from(result.stdout, 'base64').toString('utf8');\n },\n\n writeFile: async (sandbox: RunloopSandbox, path: string, content: string, runCommand: CommandRunner): Promise<void> => {\n const encoded = Buffer.from(content).toString('base64');\n const result = await runCommand(sandbox, `sh -c 'echo \"${encoded}\" | base64 -d > \"${path}\"'`);\n if (result.exitCode !== 0) throw new Error(`Failed to write file ${path}: ${result.stderr}`);\n },\n\n mkdir: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n const result = await runCommand(sandbox, `mkdir -p \"${path}\"`);\n if (result.exitCode !== 0) throw new Error(`Failed to create directory ${path}: ${result.stderr}`);\n },\n\n readdir: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<FileEntry[]> => {\n const result = await runCommand(sandbox, `ls -la \"${path}\"`);\n if (result.exitCode !== 0) throw new Error(`Failed to list directory ${path}: ${result.stderr}`);\n\n const lines = (result.stdout || \"\")\n .split(\"\\n\")\n .filter((line: string) => line.trim() && !line.startsWith(\"total\"));\n\n return lines.map((line: string) => {\n const parts = line.trim().split(/\\s+/);\n const name = parts[parts.length - 1];\n const isDirectory = line.startsWith(\"d\");\n return {\n name,\n type: isDirectory ? 'directory' as const : 'file' as const,\n size: parseInt(parts[4]) || 0,\n modified: new Date(),\n };\n });\n },\n\n exists: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<boolean> => {\n const result = await runCommand(sandbox, `test -e \"${path}\"`);\n return result.exitCode === 0;\n },\n\n remove: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<void> => {\n const result = await runCommand(sandbox, `rm -rf \"${path}\"`);\n if (result.exitCode !== 0) throw new Error(`Failed to remove ${path}: ${result.stderr}`);\n },\n },\n\n getInstance: (sandbox: RunloopSandbox): RunloopSandbox => sandbox,\n },\n\n template: {\n create: async (config: RunloopConfig, options: CreateBlueprintTemplateOptions | Runloop.BlueprintCreateParams) => {\n const client = getRunloopClient(config);\n return client.api.blueprints.create(options);\n },\n\n list: async (config: RunloopConfig, options?: { limit?: number }) => {\n const client = getRunloopClient(config);\n const listParams: any = {};\n if (options?.limit) listParams.limit = options.limit;\n const response = await client.api.blueprints.list(listParams);\n return response.blueprints || [];\n },\n\n delete: async (config: RunloopConfig, blueprintId: string) => {\n const client = getRunloopClient(config);\n await client.api.blueprints.delete(blueprintId);\n },\n },\n\n snapshot: {\n create: async (config: RunloopConfig, sandboxId: string, options?: CreateSnapshotOptions) => {\n const client = getRunloopClient(config);\n const snapshotParams: any = {};\n if (options?.name) snapshotParams.name = options.name;\n if (options?.metadata) snapshotParams.metadata = options.metadata;\n return client.api.devboxes.snapshotDisk(sandboxId, snapshotParams);\n },\n\n list: async (config: RunloopConfig, options?: ListSnapshotsOptions) => {\n const client = getRunloopClient(config);\n const listParams: any = {};\n if (options?.limit) listParams.limit = options.limit;\n const response = await client.api.devboxes.listDiskSnapshots(listParams);\n return response.snapshots || [];\n },\n\n delete: async (config: RunloopConfig, snapshotId: string) => {\n const client = getRunloopClient(config);\n await client.api.devboxes.deleteDiskSnapshot(snapshotId);\n },\n },\n },\n});\n"],"mappings":";AAOA,SAAS,kBAAgC;AACzC,SAAS,gBAAgB,sBAAsB;AAoC/C,IAAM,cAAc,oBAAI,QAAmC;AAE3D,SAAS,cAAc,QAA+B;AACpD,SACE,OAAO,UACN,OAAO,YAAY,eAAe,QAAQ,KAAK,mBAChD;AAEJ;AAEA,SAAS,iBAAiB,QAAmC;AAC3D,QAAM,SAAS,cAAc,MAAM;AACnC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,SAAS,YAAY,IAAI,MAAM;AACrC,MAAI,OAAQ,QAAO;AAEnB,QAAM,SAAS,IAAI,WAAW;AAAA,IAC5B,aAAa;AAAA,IACb,OAAO;AAAA,EACT,CAAC;AACD,cAAY,IAAI,QAAQ,MAAM;AAC9B,SAAO;AACT;AAEA,SAAS,gBAA0B,WAA0C;AAC3E,SAAO,YAAa,EAAE,UAAU,EAAE,UAAU,EAAE,IAAiB;AACjE;AAEA,SAAS,yBAAyB,WAA4B;AAC5D,MAAI,CAAC,UAAW,QAAO;AACvB,SAAO,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,KAAK,YAAY,GAAI,CAAC,CAAC;AAC9D;AAmDO,IAAM,UAAU,eAKrB;AAAA,EACA,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA,MACP,QAAQ,OAAO,QAAuB,YAAmC;AACvE,cAAM,UAAU,OAAO;AAEvB,YAAI;AACF,gBAAM,SAAS,iBAAiB,MAAM;AAEtC,gBAAM;AAAA,YACJ,SAAS;AAAA,YACT;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,WAAW;AAAA,YACX,OAAO;AAAA,YACP,WAAW;AAAA,YACX,WAAW;AAAA,YACX,mBAAmB;AAAA,YACnB,GAAG;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,SAAS,aAAa,WAAW,cAAc;AAAA,MACnE;AAAA,MAEA,MAAM,OAAO,QAAuB,YAAmC;AACrE,cAAM,SAAS,iBAAiB,MAAM;AACtC,cAAM,aAAkB,CAAC;AACzB,YAAI,SAAS,MAAO,YAAW,QAAQ,QAAQ;AAC/C,cAAM,WAAW,MAAM,OAAO,IAAI,SAAS,kBAAkB,UAAU;AACvE,eAAO,SAAS,aAAa,CAAC;AAAA,MAChC;AAAA,MAEA,QAAQ,OAAO,QAAuB,eAAuB;AAC3D,cAAM,SAAS,iBAAiB,MAAM;AACtC,cAAM,OAAO,IAAI,SAAS,mBAAmB,UAAU;AAAA,MACzD;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Runloop Provider - Factory-based Implementation\n *\n * Full-featured provider with filesystem support using the factory pattern.\n * Reduces ~400 lines of boilerplate to ~100 lines of core logic.\n */\n\nimport { RunloopSDK, type Runloop } from \"@runloop/api-client\";\nimport { defineProvider } from \"@computesdk/provider\";\nimport { posix as posixPath } from \"node:path\";\nimport type {\n CommandResult,\n SandboxInfo,\n CreateSnapshotOptions,\n ListSnapshotsOptions,\n RunCommandOptions,\n} from \"@computesdk/provider\";\nimport type {\n CreateSandboxOptions,\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\"]): SandboxInfo[\"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 sandbox: {\n create: async (config: RunloopConfig, options?: CreateSandboxOptions) => {\n const timeout = config.timeout;\n\n try {\n const client = getRunloopClient(config);\n\n const {\n timeout: optTimeout,\n envs,\n name,\n metadata,\n templateId,\n snapshotId,\n sandboxId: optSandboxId,\n ports: _ports,\n namespace: _namespace,\n directory: _directory,\n 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 {\n sandbox: runloopSandbox,\n sandboxId: dbx.id,\n };\n } catch (error) {\n throw new Error(\n `Failed to create Runloop devbox: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n getById: async (config: RunloopConfig, sandboxId: string) => {\n try {\n const client = getRunloopClient(config);\n const devbox = await client.api.devboxes.retrieve(sandboxId);\n return {\n sandbox: { ...devbox, client } as RunloopSandbox,\n sandboxId,\n };\n } catch (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 sandbox: { ...devbox, client } as RunloopSandbox,\n sandboxId: 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<SandboxInfo> => {\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; SandboxInfo.timeout is in milliseconds\n timeout: keepAliveSecs ? keepAliveSecs * 1000 : 300000,\n metadata: {\n runloopDevboxId: devbox.id,\n templateId: devbox.blueprint_id || devbox.snapshot_id,\n runtime: 'node',\n ...devbox.metadata,\n },\n };\n },\n\n getUrl: async (\n sandbox: RunloopSandbox,\n options: { port: number }\n ): Promise<string> => {\n const devbox = sandbox;\n const client = sandbox.client;\n\n try {\n const tunnel = await client.api.devboxes.enableTunnel(devbox.id);\n return `https://${options.port}-${tunnel.tunnel_key}.tunnel.runloop.ai`;\n } catch (error) {\n throw new Error(\n `Failed to get Runloop URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n filesystem: {\n readFile: async (sandbox: RunloopSandbox, path: string): 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,SAAS,IAAI,WAAW;AAAA,IAC5B,aAAa;AAAA,IACb,OAAO;AAAA,EACT,CAAC;AACD,cAAY,IAAI,QAAQ,MAAM;AAC9B,SAAO;AACT;AAEA,SAAS,gBAA0B,WAA0C;AAC3E,SAAO,YAAa,EAAE,UAAU,EAAE,UAAU,EAAE,IAAiB;AACjE;AAEA,SAAS,qBAAqB,OAAuB;AACnD,SAAO,IAAI,MAAM,QAAQ,MAAM,OAAO,CAAC;AACzC;AAEA,SAAS,sBAAsB,OAAqB;AAClD,QAAM,aAAa,UAAU,UAAU,KAAK;AAC5C,MAAI,MAAM,WAAW,KAAK,eAAe,OAAO,eAAe,OAC3D,eAAe,QAAQ,WAAW,WAAW,KAAK,GAAG;AACvD,UAAM,IAAI,MAAM,mCAAmC,KAAK,UAAU,KAAK,CAAC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Q;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,6 +1,6 @@
1
1
  {
2
2
  "name": "@computesdk/runloop",
3
- "version": "1.3.55",
3
+ "version": "1.3.57",
4
4
  "description": "Runloop provider for ComputeSDK - AI-optimized code execution with built-in devtools and debugging",
5
5
  "author": "Runloop",
6
6
  "license": "MIT",
@@ -18,9 +18,9 @@
18
18
  "dist"
19
19
  ],
20
20
  "dependencies": {
21
- "@runloop/api-client": "^1.24.0",
22
- "@computesdk/provider": "2.1.5",
23
- "computesdk": "4.1.4"
21
+ "@runloop/api-client": "^1.30.0",
22
+ "computesdk": "4.1.4",
23
+ "@computesdk/provider": "2.1.5"
24
24
  },
25
25
  "keywords": [
26
26
  "computesdk",