@computesdk/runloop 1.3.45 → 1.3.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +53 -180
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -180
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -29,7 +29,6 @@ var runloop = (0, import_provider.defineProvider)({
|
|
|
29
29
|
name: "runloop",
|
|
30
30
|
methods: {
|
|
31
31
|
sandbox: {
|
|
32
|
-
// Collection operations (map to compute.sandbox.*)
|
|
33
32
|
create: async (config, options) => {
|
|
34
33
|
const apiKey = config.apiKey || typeof process !== "undefined" && process.env?.RUNLOOP_API_KEY || "";
|
|
35
34
|
if (!apiKey) {
|
|
@@ -43,13 +42,12 @@ var runloop = (0, import_provider.defineProvider)({
|
|
|
43
42
|
bearerToken: apiKey
|
|
44
43
|
});
|
|
45
44
|
const {
|
|
46
|
-
runtime: _runtime,
|
|
47
45
|
timeout: optTimeout,
|
|
48
46
|
envs,
|
|
49
47
|
name,
|
|
50
48
|
metadata,
|
|
51
49
|
templateId,
|
|
52
|
-
snapshotId
|
|
50
|
+
snapshotId,
|
|
53
51
|
sandboxId: optSandboxId,
|
|
54
52
|
namespace: _namespace,
|
|
55
53
|
directory: _directory,
|
|
@@ -65,9 +63,10 @@ var runloop = (0, import_provider.defineProvider)({
|
|
|
65
63
|
metadata,
|
|
66
64
|
environment_variables: envs,
|
|
67
65
|
...providerOptions
|
|
68
|
-
// Spread provider-specific options (e.g., blueprint params, resource_size)
|
|
69
66
|
};
|
|
70
|
-
if (
|
|
67
|
+
if (snapshotId) {
|
|
68
|
+
devboxParams.snapshot_id = snapshotId;
|
|
69
|
+
} else if (templateId) {
|
|
71
70
|
if (templateId.startsWith("bpt_")) {
|
|
72
71
|
devboxParams.blueprint_id = templateId;
|
|
73
72
|
} else if (templateId.startsWith("snp_")) {
|
|
@@ -79,9 +78,7 @@ var runloop = (0, import_provider.defineProvider)({
|
|
|
79
78
|
);
|
|
80
79
|
const runloopSandbox = {
|
|
81
80
|
...dbx,
|
|
82
|
-
// Spread all DevboxView properties
|
|
83
81
|
client
|
|
84
|
-
// Add client for method access
|
|
85
82
|
};
|
|
86
83
|
return {
|
|
87
84
|
sandbox: runloopSandbox,
|
|
@@ -96,52 +93,38 @@ var runloop = (0, import_provider.defineProvider)({
|
|
|
96
93
|
getById: async (config, sandboxId) => {
|
|
97
94
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
98
95
|
try {
|
|
99
|
-
const client = new import_api_client.RunloopSDK({
|
|
100
|
-
bearerToken: apiKey
|
|
101
|
-
});
|
|
96
|
+
const client = new import_api_client.RunloopSDK({ bearerToken: apiKey });
|
|
102
97
|
const devbox = await client.api.devboxes.retrieve(sandboxId);
|
|
103
|
-
const runloopSandbox = {
|
|
104
|
-
...devbox,
|
|
105
|
-
client
|
|
106
|
-
};
|
|
107
98
|
return {
|
|
108
|
-
sandbox:
|
|
99
|
+
sandbox: { ...devbox, client },
|
|
109
100
|
sandboxId
|
|
110
101
|
};
|
|
111
|
-
} catch
|
|
102
|
+
} catch {
|
|
112
103
|
return null;
|
|
113
104
|
}
|
|
114
105
|
},
|
|
115
106
|
list: async (config) => {
|
|
116
107
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
117
108
|
try {
|
|
118
|
-
const client = new import_api_client.RunloopSDK({
|
|
119
|
-
bearerToken: apiKey
|
|
120
|
-
});
|
|
109
|
+
const client = new import_api_client.RunloopSDK({ bearerToken: apiKey });
|
|
121
110
|
const response = await client.api.devboxes.list();
|
|
122
111
|
const devboxes = response.devboxes || [];
|
|
123
112
|
return devboxes.map((devbox) => ({
|
|
124
|
-
sandbox: {
|
|
125
|
-
...devbox,
|
|
126
|
-
client
|
|
127
|
-
},
|
|
113
|
+
sandbox: { ...devbox, client },
|
|
128
114
|
sandboxId: devbox.id
|
|
129
115
|
}));
|
|
130
|
-
} catch
|
|
116
|
+
} catch {
|
|
131
117
|
return [];
|
|
132
118
|
}
|
|
133
119
|
},
|
|
134
120
|
destroy: async (config, sandboxId) => {
|
|
135
121
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
136
122
|
try {
|
|
137
|
-
const client = new import_api_client.RunloopSDK({
|
|
138
|
-
bearerToken: apiKey
|
|
139
|
-
});
|
|
123
|
+
const client = new import_api_client.RunloopSDK({ bearerToken: apiKey });
|
|
140
124
|
await client.api.devboxes.shutdown(sandboxId);
|
|
141
|
-
} catch
|
|
125
|
+
} catch {
|
|
142
126
|
}
|
|
143
127
|
},
|
|
144
|
-
// Instance operations (map to individual Sandbox methods)
|
|
145
128
|
runCommand: async (sandbox, command, options) => {
|
|
146
129
|
const startTime = Date.now();
|
|
147
130
|
const devbox = sandbox;
|
|
@@ -178,17 +161,18 @@ var runloop = (0, import_provider.defineProvider)({
|
|
|
178
161
|
},
|
|
179
162
|
getInfo: async (sandbox) => {
|
|
180
163
|
const devbox = sandbox;
|
|
164
|
+
const keepAliveSecs = devbox.launch_parameters.keep_alive_time_seconds;
|
|
181
165
|
return {
|
|
182
166
|
id: devbox.id || "runloop-unknown",
|
|
183
167
|
provider: "runloop",
|
|
184
|
-
runtime: "node",
|
|
185
|
-
// Runloop supports multiple runtimes, defaulting to node
|
|
186
168
|
status: devbox.status,
|
|
187
169
|
createdAt: new Date(devbox.create_time_ms || Date.now()),
|
|
188
|
-
|
|
170
|
+
// keep_alive_time_seconds is in seconds; SandboxInfo.timeout is in milliseconds
|
|
171
|
+
timeout: keepAliveSecs ? keepAliveSecs * 1e3 : 3e5,
|
|
189
172
|
metadata: {
|
|
190
173
|
runloopDevboxId: devbox.id,
|
|
191
174
|
templateId: devbox.blueprint_id || devbox.snapshot_id,
|
|
175
|
+
runtime: "node",
|
|
192
176
|
...devbox.metadata
|
|
193
177
|
}
|
|
194
178
|
};
|
|
@@ -205,49 +189,24 @@ var runloop = (0, import_provider.defineProvider)({
|
|
|
205
189
|
);
|
|
206
190
|
}
|
|
207
191
|
},
|
|
208
|
-
// Optional filesystem methods - using Runloop's file operations
|
|
209
192
|
filesystem: {
|
|
210
193
|
readFile: async (sandbox, path, runCommand) => {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
throw new Error(`File not found or unreadable: ${result.stderr}`);
|
|
215
|
-
}
|
|
216
|
-
return result.stdout;
|
|
217
|
-
} catch (error) {
|
|
218
|
-
throw new Error(
|
|
219
|
-
`Failed to read file ${path}: ${error instanceof Error ? error.message : String(error)}`
|
|
220
|
-
);
|
|
221
|
-
}
|
|
194
|
+
const result = await runCommand(sandbox, `cat "${path}"`);
|
|
195
|
+
if (result.exitCode !== 0) throw new Error(`File not found or unreadable: ${result.stderr}`);
|
|
196
|
+
return result.stdout;
|
|
222
197
|
},
|
|
223
198
|
writeFile: async (sandbox, path, content, runCommand) => {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
if (result.exitCode !== 0) {
|
|
228
|
-
throw new Error(`Command failed: ${result.stderr}`);
|
|
229
|
-
}
|
|
230
|
-
} catch (error) {
|
|
231
|
-
throw new Error(
|
|
232
|
-
`Failed to write file ${path}: ${error instanceof Error ? error.message : String(error)}`
|
|
233
|
-
);
|
|
234
|
-
}
|
|
199
|
+
const encoded = Buffer.from(content).toString("base64");
|
|
200
|
+
const result = await runCommand(sandbox, `sh -c 'echo "${encoded}" | base64 -d > "${path}"'`);
|
|
201
|
+
if (result.exitCode !== 0) throw new Error(`Failed to write file ${path}: ${result.stderr}`);
|
|
235
202
|
},
|
|
236
203
|
mkdir: async (sandbox, path, runCommand) => {
|
|
237
204
|
const result = await runCommand(sandbox, `mkdir -p "${path}"`);
|
|
238
|
-
if (result.exitCode !== 0) {
|
|
239
|
-
throw new Error(
|
|
240
|
-
`Failed to create directory ${path}: ${result.stderr}`
|
|
241
|
-
);
|
|
242
|
-
}
|
|
205
|
+
if (result.exitCode !== 0) throw new Error(`Failed to create directory ${path}: ${result.stderr}`);
|
|
243
206
|
},
|
|
244
207
|
readdir: async (sandbox, path, runCommand) => {
|
|
245
208
|
const result = await runCommand(sandbox, `ls -la "${path}"`);
|
|
246
|
-
if (result.exitCode !== 0) {
|
|
247
|
-
throw new Error(
|
|
248
|
-
`Failed to list directory ${path}: ${result.stderr}`
|
|
249
|
-
);
|
|
250
|
-
}
|
|
209
|
+
if (result.exitCode !== 0) throw new Error(`Failed to list directory ${path}: ${result.stderr}`);
|
|
251
210
|
const lines = (result.stdout || "").split("\n").filter((line) => line.trim() && !line.startsWith("total"));
|
|
252
211
|
return lines.map((line) => {
|
|
253
212
|
const parts = line.trim().split(/\s+/);
|
|
@@ -267,144 +226,58 @@ var runloop = (0, import_provider.defineProvider)({
|
|
|
267
226
|
},
|
|
268
227
|
remove: async (sandbox, path, runCommand) => {
|
|
269
228
|
const result = await runCommand(sandbox, `rm -rf "${path}"`);
|
|
270
|
-
if (result.exitCode !== 0) {
|
|
271
|
-
throw new Error(`Failed to remove ${path}: ${result.stderr}`);
|
|
272
|
-
}
|
|
229
|
+
if (result.exitCode !== 0) throw new Error(`Failed to remove ${path}: ${result.stderr}`);
|
|
273
230
|
}
|
|
274
231
|
},
|
|
275
|
-
|
|
276
|
-
getInstance: (sandbox) => {
|
|
277
|
-
return sandbox;
|
|
278
|
-
}
|
|
232
|
+
getInstance: (sandbox) => sandbox
|
|
279
233
|
},
|
|
280
|
-
// Template management methods using the new factory pattern
|
|
281
234
|
template: {
|
|
282
235
|
create: async (config, options) => {
|
|
283
236
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
284
|
-
if (!apiKey)
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
);
|
|
288
|
-
}
|
|
289
|
-
try {
|
|
290
|
-
const client = new import_api_client.RunloopSDK({
|
|
291
|
-
bearerToken: apiKey
|
|
292
|
-
});
|
|
293
|
-
const blueprint = await client.api.blueprints.create(options);
|
|
294
|
-
return blueprint;
|
|
295
|
-
} catch (error) {
|
|
296
|
-
throw new Error(
|
|
297
|
-
`Failed to create blueprint template: ${error instanceof Error ? error.message : String(error)}`
|
|
298
|
-
);
|
|
299
|
-
}
|
|
237
|
+
if (!apiKey) throw new Error("Missing Runloop API key for blueprint template creation");
|
|
238
|
+
const client = new import_api_client.RunloopSDK({ bearerToken: apiKey });
|
|
239
|
+
return client.api.blueprints.create(options);
|
|
300
240
|
},
|
|
301
241
|
list: async (config, options) => {
|
|
302
242
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
303
|
-
if (!apiKey)
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
const client = new import_api_client.RunloopSDK({
|
|
310
|
-
bearerToken: apiKey
|
|
311
|
-
});
|
|
312
|
-
const listParams = {};
|
|
313
|
-
if (options?.limit) {
|
|
314
|
-
listParams.limit = options.limit;
|
|
315
|
-
}
|
|
316
|
-
const response = await client.api.blueprints.list(listParams);
|
|
317
|
-
return response.blueprints || [];
|
|
318
|
-
} catch (error) {
|
|
319
|
-
throw new Error(
|
|
320
|
-
`Failed to list blueprint templates: ${error instanceof Error ? error.message : String(error)}`
|
|
321
|
-
);
|
|
322
|
-
}
|
|
243
|
+
if (!apiKey) throw new Error("Missing Runloop API key for listing blueprint templates");
|
|
244
|
+
const client = new import_api_client.RunloopSDK({ bearerToken: apiKey });
|
|
245
|
+
const listParams = {};
|
|
246
|
+
if (options?.limit) listParams.limit = options.limit;
|
|
247
|
+
const response = await client.api.blueprints.list(listParams);
|
|
248
|
+
return response.blueprints || [];
|
|
323
249
|
},
|
|
324
250
|
delete: async (config, blueprintId) => {
|
|
325
251
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
326
|
-
if (!apiKey)
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
);
|
|
330
|
-
}
|
|
331
|
-
try {
|
|
332
|
-
const client = new import_api_client.RunloopSDK({
|
|
333
|
-
bearerToken: apiKey
|
|
334
|
-
});
|
|
335
|
-
await client.api.blueprints.delete(blueprintId);
|
|
336
|
-
} catch (error) {
|
|
337
|
-
throw new Error(
|
|
338
|
-
`Failed to delete blueprint template ${blueprintId}: ${error instanceof Error ? error.message : String(error)}`
|
|
339
|
-
);
|
|
340
|
-
}
|
|
252
|
+
if (!apiKey) throw new Error("Missing Runloop API key for blueprint template deletion");
|
|
253
|
+
const client = new import_api_client.RunloopSDK({ bearerToken: apiKey });
|
|
254
|
+
await client.api.blueprints.delete(blueprintId);
|
|
341
255
|
}
|
|
342
256
|
},
|
|
343
|
-
// Snapshot management methods using the new factory pattern
|
|
344
257
|
snapshot: {
|
|
345
258
|
create: async (config, sandboxId, options) => {
|
|
346
259
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
347
|
-
if (!apiKey)
|
|
348
|
-
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
});
|
|
354
|
-
const snapshotParams = {};
|
|
355
|
-
if (options?.name) {
|
|
356
|
-
snapshotParams.name = options.name;
|
|
357
|
-
}
|
|
358
|
-
if (options?.metadata) {
|
|
359
|
-
snapshotParams.metadata = options.metadata;
|
|
360
|
-
}
|
|
361
|
-
const snapshot = await client.api.devboxes.snapshotDisk(
|
|
362
|
-
sandboxId,
|
|
363
|
-
snapshotParams
|
|
364
|
-
);
|
|
365
|
-
return snapshot;
|
|
366
|
-
} catch (error) {
|
|
367
|
-
throw new Error(
|
|
368
|
-
`Failed to create snapshot for sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)}`
|
|
369
|
-
);
|
|
370
|
-
}
|
|
260
|
+
if (!apiKey) throw new Error("Missing Runloop API key for snapshot creation");
|
|
261
|
+
const client = new import_api_client.RunloopSDK({ bearerToken: apiKey });
|
|
262
|
+
const snapshotParams = {};
|
|
263
|
+
if (options?.name) snapshotParams.name = options.name;
|
|
264
|
+
if (options?.metadata) snapshotParams.metadata = options.metadata;
|
|
265
|
+
return client.api.devboxes.snapshotDisk(sandboxId, snapshotParams);
|
|
371
266
|
},
|
|
372
267
|
list: async (config, options) => {
|
|
373
268
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
374
|
-
if (!apiKey)
|
|
375
|
-
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
});
|
|
381
|
-
const listParams = {};
|
|
382
|
-
if (options?.limit) {
|
|
383
|
-
listParams.limit = options.limit;
|
|
384
|
-
}
|
|
385
|
-
const response = await client.api.devboxes.listDiskSnapshots(listParams);
|
|
386
|
-
return response.snapshots || [];
|
|
387
|
-
} catch (error) {
|
|
388
|
-
throw new Error(
|
|
389
|
-
`Failed to list snapshots: ${error instanceof Error ? error.message : String(error)}`
|
|
390
|
-
);
|
|
391
|
-
}
|
|
269
|
+
if (!apiKey) throw new Error("Missing Runloop API key for listing snapshots");
|
|
270
|
+
const client = new import_api_client.RunloopSDK({ bearerToken: apiKey });
|
|
271
|
+
const listParams = {};
|
|
272
|
+
if (options?.limit) listParams.limit = options.limit;
|
|
273
|
+
const response = await client.api.devboxes.listDiskSnapshots(listParams);
|
|
274
|
+
return response.snapshots || [];
|
|
392
275
|
},
|
|
393
276
|
delete: async (config, snapshotId) => {
|
|
394
277
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
395
|
-
if (!apiKey)
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
try {
|
|
399
|
-
const client = new import_api_client.RunloopSDK({
|
|
400
|
-
bearerToken: apiKey
|
|
401
|
-
});
|
|
402
|
-
await client.api.devboxes.deleteDiskSnapshot(snapshotId);
|
|
403
|
-
} catch (error) {
|
|
404
|
-
throw new Error(
|
|
405
|
-
`Failed to delete snapshot ${snapshotId}: ${error instanceof Error ? error.message : String(error)}`
|
|
406
|
-
);
|
|
407
|
-
}
|
|
278
|
+
if (!apiKey) throw new Error("Missing Runloop API key for snapshot deletion");
|
|
279
|
+
const client = new import_api_client.RunloopSDK({ bearerToken: apiKey });
|
|
280
|
+
await client.api.devboxes.deleteDiskSnapshot(snapshotId);
|
|
408
281
|
}
|
|
409
282
|
}
|
|
410
283
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Runloop Provider - Factory-based Implementation\n *\n * Full-featured provider with filesystem support using the factory pattern.\n * Reduces ~400 lines of boilerplate to ~100 lines of core logic.\n */\n\nimport { RunloopSDK, type Runloop } from \"@runloop/api-client\";\nimport { defineProvider, escapeShellArg } from \"@computesdk/provider\";\nimport type {\n CommandResult,\n SandboxInfo,\n CreateSnapshotOptions,\n ListSnapshotsOptions,\n RunCommandOptions,\n} from \"@computesdk/provider\";\nimport type {\n CreateSandboxOptions,\n FileEntry,\n Runtime,\n} from \"computesdk\";\n\n// Define Runloop-specific types\ntype RunloopSnapshot = Runloop.DevboxSnapshotView;\ntype RunloopTemplate = Runloop.BlueprintView;\ntype RunloopSandbox = Runloop.DevboxView & { client: RunloopSDK };\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\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, // TSandbox\n RunloopConfig, // TConfig\n RunloopTemplate, // TTemplate \n RunloopSnapshot // TSnapshot\n>({\n name: \"runloop\",\n methods: {\n sandbox: {\n // Collection operations (map to compute.sandbox.*)\n create: async (config: RunloopConfig, options?: CreateSandboxOptions) => {\n // Validate API key\n const apiKey =\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.RUNLOOP_API_KEY) ||\n \"\";\n\n if (!apiKey) {\n throw new Error(\n `Missing Runloop API key. Provide 'apiKey' in config or set RUNLOOP_API_KEY environment variable. Get your API key from https://runloop.ai/`\n );\n }\n\n const timeout = config.timeout;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n // Destructure known ComputeSDK fields, collect the rest for passthrough\n const {\n runtime: _runtime,\n timeout: optTimeout,\n envs,\n name,\n metadata,\n templateId,\n snapshotId: _snapshotId,\n sandboxId: optSandboxId,\n namespace: _namespace,\n directory: _directory,\n ...providerOptions\n } = options || {};\n\n // Convert ms to seconds for Runloop's keep_alive_time_seconds\n // options.timeout takes precedence over config.timeout\n const effectiveTimeout = optTimeout ?? timeout;\n const keepAliveSeconds = effectiveTimeout\n ? Math.ceil(effectiveTimeout / 1000)\n : 1800;\n\n let devboxParams: Runloop.DevboxCreateParams = {\n launch_parameters: {\n keep_alive_time_seconds: keepAliveSeconds,\n },\n name: name || optSandboxId,\n metadata,\n environment_variables: envs,\n ...providerOptions, // Spread provider-specific options (e.g., blueprint params, resource_size)\n };\n\n // Use blueprint if specified\n if (templateId) {\n // Check template prefix to determine parameter type\n if (templateId.startsWith(\"bpt_\")) {\n devboxParams.blueprint_id = templateId;\n } else if (templateId.startsWith(\"snp_\")) {\n devboxParams.snapshot_id = templateId;\n }\n }\n\n const dbx = await client.api.devboxes.createAndAwaitRunning(\n devboxParams,\n );\n\n // Create a RunloopSandbox object that contains both devbox and client\n const runloopSandbox: RunloopSandbox = {\n ...dbx, // Spread all DevboxView properties\n client: client // Add client for method access\n };\n\n return {\n sandbox: runloopSandbox,\n sandboxId: dbx.id,\n };\n } catch (error) {\n throw new Error(\n `Failed to create Runloop devbox: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n getById: async (config: RunloopConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const devbox = await client.api.devboxes.retrieve(sandboxId);\n const runloopSandbox: RunloopSandbox = {\n ...devbox,\n client,\n };\n\n return {\n sandbox: runloopSandbox,\n sandboxId,\n };\n } catch (error) {\n // Devbox doesn't exist or can't be accessed\n return null;\n }\n },\n\n list: async (config: RunloopConfig) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const response = await client.api.devboxes.list();\n const devboxes = response.devboxes || [];\n\n return devboxes.map((devbox) => ({\n sandbox: {\n ...devbox,\n client,\n } as RunloopSandbox,\n sandboxId: devbox.id,\n }));\n } catch (error) {\n // Return empty array if listing fails\n return [];\n }\n },\n\n destroy: async (config: RunloopConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n await client.api.devboxes.shutdown(sandboxId);\n } catch (error) {\n // Devbox might already be destroyed or doesn't exist\n // This is acceptable for destroy operations\n }\n },\n\n // Instance operations (map to individual Sandbox methods)\n\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 // Build the full command with options\n let fullCommand = command;\n\n // Handle environment variables\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([k, v]) => `${k}=\"${escapeShellArg(String(v))}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n\n // Handle working directory\n if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n\n // Handle background execution\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n\n const executionResult =\n await client.api.devboxes.executeAndAwaitCompletion(devbox.id, {\n command: fullCommand,\n });\n\n return {\n stdout: executionResult.stdout || \"\",\n stderr: executionResult.stderr || \"\",\n exitCode: executionResult.exit_status || 0,\n durationMs: Date.now() - startTime,\n };\n } catch (error) {\n // Re-throw syntax errors\n if (\n error instanceof Error &&\n error.message.includes(\"Syntax error\")\n ) {\n throw error;\n }\n throw new Error(\n `Runloop execution failed: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n getInfo: async (sandbox): Promise<SandboxInfo> => {\n const devbox = sandbox;\n\n return {\n id: devbox.id || \"runloop-unknown\",\n provider: \"runloop\",\n runtime: \"node\" as Runtime, // Runloop supports multiple runtimes, defaulting to node\n status: devbox.status as 'running' | 'stopped' | 'error',\n createdAt: new Date(devbox.create_time_ms || Date.now()),\n timeout: devbox.launch_parameters.keep_alive_time_seconds || 300000,\n metadata: {\n runloopDevboxId: devbox.id,\n templateId: devbox.blueprint_id || devbox.snapshot_id,\n ...devbox.metadata,\n },\n };\n },\n\n getUrl: async (\n sandbox: 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\n // Optional filesystem methods - using Runloop's file operations\n filesystem: {\n readFile: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<string> => {\n try {\n const result = await runCommand(sandbox, `cat \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`File not found or unreadable: ${result.stderr}`);\n }\n return result.stdout;\n } catch (error) {\n throw new Error(\n `Failed to read file ${path}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n writeFile: async (\n sandbox: RunloopSandbox,\n path: string,\n content: string,\n runCommand: CommandRunner\n ): Promise<void> => {\n try {\n // Use command-based approach for file writing since API writeFileContents may have issues\n const encoded = Buffer.from(content).toString('base64');\n const result = await runCommand(sandbox, `sh -c 'echo \"${encoded}\" | base64 -d > \"${path}\"'`);\n\n if (result.exitCode !== 0) {\n throw new Error(`Command failed: ${result.stderr}`);\n }\n } catch (error) {\n throw new Error(\n `Failed to write file ${path}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n mkdir: async (\n sandbox: RunloopSandbox,\n path: string,\n runCommand: CommandRunner\n ): Promise<void> => {\n const result = await runCommand(sandbox, `mkdir -p \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(\n `Failed to create directory ${path}: ${result.stderr}`\n );\n }\n },\n\n readdir: async (\n sandbox: RunloopSandbox,\n path: string,\n runCommand: CommandRunner\n ): Promise<FileEntry[]> => {\n const result = await runCommand(sandbox, `ls -la \"${path}\"`);\n\n if (result.exitCode !== 0) {\n throw new Error(\n `Failed to list directory ${path}: ${result.stderr}`\n );\n }\n\n const lines = (result.stdout || \"\")\n .split(\"\\n\")\n .filter((line: string) => line.trim() && !line.startsWith(\"total\"));\n\n return lines.map((line: string) => {\n const parts = line.trim().split(/\\s+/);\n const name = parts[parts.length - 1];\n const isDirectory = line.startsWith(\"d\");\n\n return {\n name,\n type: isDirectory ? 'directory' as const : 'file' as const,\n size: parseInt(parts[4]) || 0,\n modified: new Date(),\n };\n });\n },\n\n exists: async (\n sandbox: RunloopSandbox,\n path: string,\n runCommand: CommandRunner\n ): Promise<boolean> => {\n const result = await runCommand(sandbox, `test -e \"${path}\"`);\n return result.exitCode === 0;\n },\n\n remove: async (\n sandbox: RunloopSandbox,\n path: string,\n runCommand: CommandRunner\n ): Promise<void> => {\n const result = await runCommand(sandbox, `rm -rf \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to remove ${path}: ${result.stderr}`);\n }\n },\n },\n\n // Provider-specific typed getInstance method\n getInstance: (sandbox: RunloopSandbox): RunloopSandbox => {\n return sandbox;\n },\n },\n\n // Template management methods using the new factory pattern\n template: {\n create: async (\n config: RunloopConfig,\n options: CreateBlueprintTemplateOptions | Runloop.BlueprintCreateParams\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for blueprint template creation\"\n );\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const blueprint = await client.api.blueprints.create(options);\n return blueprint;\n } catch (error) {\n throw new Error(\n `Failed to create blueprint template: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n list: async (config: RunloopConfig, options?: { limit?: number }) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for listing blueprint templates\"\n );\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const listParams: any = {};\n if (options?.limit) {\n listParams.limit = options.limit;\n }\n\n const response = await client.api.blueprints.list(listParams);\n return response.blueprints || [];\n } catch (error) {\n throw new Error(\n `Failed to list blueprint templates: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n delete: async (config: RunloopConfig, blueprintId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for blueprint template deletion\"\n );\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n await client.api.blueprints.delete(blueprintId);\n } catch (error) {\n throw new Error(\n `Failed to delete blueprint template ${blueprintId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n },\n\n // Snapshot management methods using the new factory pattern\n snapshot: {\n create: async (\n config: RunloopConfig,\n sandboxId: string,\n options?: CreateSnapshotOptions\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for snapshot creation\");\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const snapshotParams: any = {};\n if (options?.name) {\n snapshotParams.name = options.name;\n }\n if (options?.metadata) {\n snapshotParams.metadata = options.metadata;\n }\n\n const snapshot = await client.api.devboxes.snapshotDisk(\n sandboxId,\n snapshotParams\n );\n return snapshot;\n } catch (error) {\n throw new Error(\n `Failed to create snapshot for sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n list: async (\n config: RunloopConfig,\n options?: ListSnapshotsOptions\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for listing snapshots\");\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const listParams: any = {};\n if (options?.limit) {\n listParams.limit = options.limit;\n }\n\n const response = await client.api.devboxes.listDiskSnapshots(listParams);\n return response.snapshots || [];\n } catch (error) {\n throw new Error(\n `Failed to list snapshots: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n delete: async (config: RunloopConfig, snapshotId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for snapshot deletion\");\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n await client.api.devboxes.deleteDiskSnapshot(snapshotId);\n } catch (error) {\n throw new Error(\n `Failed to delete snapshot ${snapshotId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n },\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,wBAAyC;AACzC,sBAA+C;AAoFxC,IAAM,cAAU,gCAKrB;AAAA,EACA,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA;AAAA,MAEP,QAAQ,OAAO,QAAuB,YAAmC;AAEvE,cAAM,SACJ,OAAO,UACN,OAAO,YAAY,eAAe,QAAQ,KAAK,mBAChD;AAEF,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAEA,cAAM,UAAU,OAAO;AAEvB,YAAI;AACF,gBAAM,SAAS,IAAI,6BAAW;AAAA,YAC5B,aAAa;AAAA,UACf,CAAC;AAGD,gBAAM;AAAA,YACJ,SAAS;AAAA,YACT,SAAS;AAAA,YACT;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,YAAY;AAAA,YACZ,WAAW;AAAA,YACX,WAAW;AAAA,YACX,WAAW;AAAA,YACX,GAAG;AAAA,UACL,IAAI,WAAW,CAAC;AAIhB,gBAAM,mBAAmB,cAAc;AACvC,gBAAM,mBAAmB,mBACrB,KAAK,KAAK,mBAAmB,GAAI,IACjC;AAEJ,cAAI,eAA2C;AAAA,YAC7C,mBAAmB;AAAA,cACjB,yBAAyB;AAAA,YAC3B;AAAA,YACA,MAAM,QAAQ;AAAA,YACd;AAA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,6BAA6B,UAAU,KAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CACjG;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Runloop Provider - Factory-based Implementation\n *\n * Full-featured provider with filesystem support using the factory pattern.\n * Reduces ~400 lines of boilerplate to ~100 lines of core logic.\n */\n\nimport { RunloopSDK, type Runloop } from \"@runloop/api-client\";\nimport { defineProvider, escapeShellArg } from \"@computesdk/provider\";\nimport type {\n 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 };\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\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 apiKey =\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.RUNLOOP_API_KEY) ||\n \"\";\n\n if (!apiKey) {\n throw new Error(\n `Missing Runloop API key. Provide 'apiKey' in config or set RUNLOOP_API_KEY environment variable. Get your API key from https://runloop.ai/`\n );\n }\n\n const timeout = config.timeout;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const {\n timeout: optTimeout,\n envs,\n name,\n metadata,\n templateId,\n snapshotId,\n sandboxId: optSandboxId,\n namespace: _namespace,\n directory: _directory,\n ...providerOptions\n } = options || {};\n\n const effectiveTimeout = optTimeout ?? timeout;\n const keepAliveSeconds = effectiveTimeout\n ? Math.ceil(effectiveTimeout / 1000)\n : 1800;\n\n let devboxParams: Runloop.DevboxCreateParams = {\n launch_parameters: {\n keep_alive_time_seconds: keepAliveSeconds,\n },\n name: name || optSandboxId,\n metadata,\n environment_variables: envs,\n ...providerOptions,\n };\n\n // snapshotId is the canonical cross-provider field — map it directly to snapshot_id.\n // templateId is kept for backwards compatibility: bpt_ prefix → blueprint_id, snp_ prefix → snapshot_id.\n if (snapshotId) {\n devboxParams.snapshot_id = snapshotId;\n } else if (templateId) {\n if (templateId.startsWith(\"bpt_\")) {\n devboxParams.blueprint_id = templateId;\n } else if (templateId.startsWith(\"snp_\")) {\n devboxParams.snapshot_id = templateId;\n }\n }\n\n const dbx = await client.api.devboxes.createAndAwaitRunning(\n devboxParams,\n );\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 const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({ bearerToken: apiKey });\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 const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({ bearerToken: apiKey });\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 const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({ bearerToken: apiKey });\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 });\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, `cat \"${path}\"`);\n if (result.exitCode !== 0) throw new Error(`File not found or unreadable: ${result.stderr}`);\n return result.stdout;\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 apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n if (!apiKey) throw new Error(\"Missing Runloop API key for blueprint template creation\");\n const client = new RunloopSDK({ bearerToken: apiKey });\n return client.api.blueprints.create(options);\n },\n\n list: async (config: RunloopConfig, options?: { limit?: number }) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n if (!apiKey) throw new Error(\"Missing Runloop API key for listing blueprint templates\");\n const client = new RunloopSDK({ bearerToken: apiKey });\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 apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n if (!apiKey) throw new Error(\"Missing Runloop API key for blueprint template deletion\");\n const client = new RunloopSDK({ bearerToken: apiKey });\n await client.api.blueprints.delete(blueprintId);\n },\n },\n\n snapshot: {\n create: async (config: RunloopConfig, sandboxId: string, options?: CreateSnapshotOptions) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n if (!apiKey) throw new Error(\"Missing Runloop API key for snapshot creation\");\n const client = new RunloopSDK({ bearerToken: apiKey });\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 apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n if (!apiKey) throw new Error(\"Missing Runloop API key for listing snapshots\");\n const client = new RunloopSDK({ bearerToken: apiKey });\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 apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n if (!apiKey) throw new Error(\"Missing Runloop API key for snapshot deletion\");\n const client = new RunloopSDK({ bearerToken: apiKey });\n await client.api.devboxes.deleteDiskSnapshot(snapshotId);\n },\n },\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,wBAAyC;AACzC,sBAA+C;AAmFxC,IAAM,cAAU,gCAKrB;AAAA,EACA,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA,MACP,QAAQ,OAAO,QAAuB,YAAmC;AACvE,cAAM,SACJ,OAAO,UACN,OAAO,YAAY,eAAe,QAAQ,KAAK,mBAChD;AAEF,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAEA,cAAM,UAAU,OAAO;AAEvB,YAAI;AACF,gBAAM,SAAS,IAAI,6BAAW;AAAA,YAC5B,aAAa;AAAA,UACf,CAAC;AAED,gBAAM;AAAA,YACJ,SAAS;AAAA,YACT;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,WAAW;AAAA,YACX,WAAW;AAAA,YACX,WAAW;AAAA,YACX,GAAG;AAAA,UACL,IAAI,WAAW,CAAC;AAEhB,gBAAM,mBAAmB,cAAc;AACvC,gBAAM,mBAAmB,mBACrB,KAAK,KAAK,mBAAmB,GAAI,IACjC;AAEJ,cAAI,eAA2C;AAAA,YAC7C,mBAAmB;AAAA,cACjB,yBAAyB;AAAA,YAC3B;AAAA,YACA,MAAM,QAAQ;AAAA,YACd;AAAA,YACA,uBAAuB;AAAA,YACvB,GAAG;AAAA,UACL;AAIA,cAAI,YAAY;AACd,yBAAa,cAAc;AAAA,UAC7B,WAAW,YAAY;AACrB,gBAAI,WAAW,WAAW,MAAM,GAAG;AACjC,2BAAa,eAAe;AAAA,YAC9B,WAAW,WAAW,WAAW,MAAM,GAAG;AACxC,2BAAa,cAAc;AAAA,YAC7B;AAAA,UACF;AAEA,gBAAM,MAAM,MAAM,OAAO,IAAI,SA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W,cAAc;AAAA,MACnE;AAAA,MAEA,MAAM,OAAO,QAAuB,YAAmC;AACrE,cAAM,SAAS,OAAO,UAAU,QAAQ,IAAI;AAC5C,YAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,+CAA+C;AAC5E,cAAM,SAAS,IAAI,6BAAW,EAAE,aAAa,OAAO,CAAC;AACrD,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,OAAO,UAAU,QAAQ,IAAI;AAC5C,YAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,+CAA+C;AAC5E,cAAM,SAAS,IAAI,6BAAW,EAAE,aAAa,OAAO,CAAC;AACrD,cAAM,OAAO,IAAI,SAAS,mBAAmB,UAAU;AAAA,MACzD;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,6 @@ var runloop = defineProvider({
|
|
|
5
5
|
name: "runloop",
|
|
6
6
|
methods: {
|
|
7
7
|
sandbox: {
|
|
8
|
-
// Collection operations (map to compute.sandbox.*)
|
|
9
8
|
create: async (config, options) => {
|
|
10
9
|
const apiKey = config.apiKey || typeof process !== "undefined" && process.env?.RUNLOOP_API_KEY || "";
|
|
11
10
|
if (!apiKey) {
|
|
@@ -19,13 +18,12 @@ var runloop = defineProvider({
|
|
|
19
18
|
bearerToken: apiKey
|
|
20
19
|
});
|
|
21
20
|
const {
|
|
22
|
-
runtime: _runtime,
|
|
23
21
|
timeout: optTimeout,
|
|
24
22
|
envs,
|
|
25
23
|
name,
|
|
26
24
|
metadata,
|
|
27
25
|
templateId,
|
|
28
|
-
snapshotId
|
|
26
|
+
snapshotId,
|
|
29
27
|
sandboxId: optSandboxId,
|
|
30
28
|
namespace: _namespace,
|
|
31
29
|
directory: _directory,
|
|
@@ -41,9 +39,10 @@ var runloop = defineProvider({
|
|
|
41
39
|
metadata,
|
|
42
40
|
environment_variables: envs,
|
|
43
41
|
...providerOptions
|
|
44
|
-
// Spread provider-specific options (e.g., blueprint params, resource_size)
|
|
45
42
|
};
|
|
46
|
-
if (
|
|
43
|
+
if (snapshotId) {
|
|
44
|
+
devboxParams.snapshot_id = snapshotId;
|
|
45
|
+
} else if (templateId) {
|
|
47
46
|
if (templateId.startsWith("bpt_")) {
|
|
48
47
|
devboxParams.blueprint_id = templateId;
|
|
49
48
|
} else if (templateId.startsWith("snp_")) {
|
|
@@ -55,9 +54,7 @@ var runloop = defineProvider({
|
|
|
55
54
|
);
|
|
56
55
|
const runloopSandbox = {
|
|
57
56
|
...dbx,
|
|
58
|
-
// Spread all DevboxView properties
|
|
59
57
|
client
|
|
60
|
-
// Add client for method access
|
|
61
58
|
};
|
|
62
59
|
return {
|
|
63
60
|
sandbox: runloopSandbox,
|
|
@@ -72,52 +69,38 @@ var runloop = defineProvider({
|
|
|
72
69
|
getById: async (config, sandboxId) => {
|
|
73
70
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
74
71
|
try {
|
|
75
|
-
const client = new RunloopSDK({
|
|
76
|
-
bearerToken: apiKey
|
|
77
|
-
});
|
|
72
|
+
const client = new RunloopSDK({ bearerToken: apiKey });
|
|
78
73
|
const devbox = await client.api.devboxes.retrieve(sandboxId);
|
|
79
|
-
const runloopSandbox = {
|
|
80
|
-
...devbox,
|
|
81
|
-
client
|
|
82
|
-
};
|
|
83
74
|
return {
|
|
84
|
-
sandbox:
|
|
75
|
+
sandbox: { ...devbox, client },
|
|
85
76
|
sandboxId
|
|
86
77
|
};
|
|
87
|
-
} catch
|
|
78
|
+
} catch {
|
|
88
79
|
return null;
|
|
89
80
|
}
|
|
90
81
|
},
|
|
91
82
|
list: async (config) => {
|
|
92
83
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
93
84
|
try {
|
|
94
|
-
const client = new RunloopSDK({
|
|
95
|
-
bearerToken: apiKey
|
|
96
|
-
});
|
|
85
|
+
const client = new RunloopSDK({ bearerToken: apiKey });
|
|
97
86
|
const response = await client.api.devboxes.list();
|
|
98
87
|
const devboxes = response.devboxes || [];
|
|
99
88
|
return devboxes.map((devbox) => ({
|
|
100
|
-
sandbox: {
|
|
101
|
-
...devbox,
|
|
102
|
-
client
|
|
103
|
-
},
|
|
89
|
+
sandbox: { ...devbox, client },
|
|
104
90
|
sandboxId: devbox.id
|
|
105
91
|
}));
|
|
106
|
-
} catch
|
|
92
|
+
} catch {
|
|
107
93
|
return [];
|
|
108
94
|
}
|
|
109
95
|
},
|
|
110
96
|
destroy: async (config, sandboxId) => {
|
|
111
97
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
112
98
|
try {
|
|
113
|
-
const client = new RunloopSDK({
|
|
114
|
-
bearerToken: apiKey
|
|
115
|
-
});
|
|
99
|
+
const client = new RunloopSDK({ bearerToken: apiKey });
|
|
116
100
|
await client.api.devboxes.shutdown(sandboxId);
|
|
117
|
-
} catch
|
|
101
|
+
} catch {
|
|
118
102
|
}
|
|
119
103
|
},
|
|
120
|
-
// Instance operations (map to individual Sandbox methods)
|
|
121
104
|
runCommand: async (sandbox, command, options) => {
|
|
122
105
|
const startTime = Date.now();
|
|
123
106
|
const devbox = sandbox;
|
|
@@ -154,17 +137,18 @@ var runloop = defineProvider({
|
|
|
154
137
|
},
|
|
155
138
|
getInfo: async (sandbox) => {
|
|
156
139
|
const devbox = sandbox;
|
|
140
|
+
const keepAliveSecs = devbox.launch_parameters.keep_alive_time_seconds;
|
|
157
141
|
return {
|
|
158
142
|
id: devbox.id || "runloop-unknown",
|
|
159
143
|
provider: "runloop",
|
|
160
|
-
runtime: "node",
|
|
161
|
-
// Runloop supports multiple runtimes, defaulting to node
|
|
162
144
|
status: devbox.status,
|
|
163
145
|
createdAt: new Date(devbox.create_time_ms || Date.now()),
|
|
164
|
-
|
|
146
|
+
// keep_alive_time_seconds is in seconds; SandboxInfo.timeout is in milliseconds
|
|
147
|
+
timeout: keepAliveSecs ? keepAliveSecs * 1e3 : 3e5,
|
|
165
148
|
metadata: {
|
|
166
149
|
runloopDevboxId: devbox.id,
|
|
167
150
|
templateId: devbox.blueprint_id || devbox.snapshot_id,
|
|
151
|
+
runtime: "node",
|
|
168
152
|
...devbox.metadata
|
|
169
153
|
}
|
|
170
154
|
};
|
|
@@ -181,49 +165,24 @@ var runloop = defineProvider({
|
|
|
181
165
|
);
|
|
182
166
|
}
|
|
183
167
|
},
|
|
184
|
-
// Optional filesystem methods - using Runloop's file operations
|
|
185
168
|
filesystem: {
|
|
186
169
|
readFile: async (sandbox, path, runCommand) => {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
throw new Error(`File not found or unreadable: ${result.stderr}`);
|
|
191
|
-
}
|
|
192
|
-
return result.stdout;
|
|
193
|
-
} catch (error) {
|
|
194
|
-
throw new Error(
|
|
195
|
-
`Failed to read file ${path}: ${error instanceof Error ? error.message : String(error)}`
|
|
196
|
-
);
|
|
197
|
-
}
|
|
170
|
+
const result = await runCommand(sandbox, `cat "${path}"`);
|
|
171
|
+
if (result.exitCode !== 0) throw new Error(`File not found or unreadable: ${result.stderr}`);
|
|
172
|
+
return result.stdout;
|
|
198
173
|
},
|
|
199
174
|
writeFile: async (sandbox, path, content, runCommand) => {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
if (result.exitCode !== 0) {
|
|
204
|
-
throw new Error(`Command failed: ${result.stderr}`);
|
|
205
|
-
}
|
|
206
|
-
} catch (error) {
|
|
207
|
-
throw new Error(
|
|
208
|
-
`Failed to write file ${path}: ${error instanceof Error ? error.message : String(error)}`
|
|
209
|
-
);
|
|
210
|
-
}
|
|
175
|
+
const encoded = Buffer.from(content).toString("base64");
|
|
176
|
+
const result = await runCommand(sandbox, `sh -c 'echo "${encoded}" | base64 -d > "${path}"'`);
|
|
177
|
+
if (result.exitCode !== 0) throw new Error(`Failed to write file ${path}: ${result.stderr}`);
|
|
211
178
|
},
|
|
212
179
|
mkdir: async (sandbox, path, runCommand) => {
|
|
213
180
|
const result = await runCommand(sandbox, `mkdir -p "${path}"`);
|
|
214
|
-
if (result.exitCode !== 0) {
|
|
215
|
-
throw new Error(
|
|
216
|
-
`Failed to create directory ${path}: ${result.stderr}`
|
|
217
|
-
);
|
|
218
|
-
}
|
|
181
|
+
if (result.exitCode !== 0) throw new Error(`Failed to create directory ${path}: ${result.stderr}`);
|
|
219
182
|
},
|
|
220
183
|
readdir: async (sandbox, path, runCommand) => {
|
|
221
184
|
const result = await runCommand(sandbox, `ls -la "${path}"`);
|
|
222
|
-
if (result.exitCode !== 0) {
|
|
223
|
-
throw new Error(
|
|
224
|
-
`Failed to list directory ${path}: ${result.stderr}`
|
|
225
|
-
);
|
|
226
|
-
}
|
|
185
|
+
if (result.exitCode !== 0) throw new Error(`Failed to list directory ${path}: ${result.stderr}`);
|
|
227
186
|
const lines = (result.stdout || "").split("\n").filter((line) => line.trim() && !line.startsWith("total"));
|
|
228
187
|
return lines.map((line) => {
|
|
229
188
|
const parts = line.trim().split(/\s+/);
|
|
@@ -243,144 +202,58 @@ var runloop = defineProvider({
|
|
|
243
202
|
},
|
|
244
203
|
remove: async (sandbox, path, runCommand) => {
|
|
245
204
|
const result = await runCommand(sandbox, `rm -rf "${path}"`);
|
|
246
|
-
if (result.exitCode !== 0) {
|
|
247
|
-
throw new Error(`Failed to remove ${path}: ${result.stderr}`);
|
|
248
|
-
}
|
|
205
|
+
if (result.exitCode !== 0) throw new Error(`Failed to remove ${path}: ${result.stderr}`);
|
|
249
206
|
}
|
|
250
207
|
},
|
|
251
|
-
|
|
252
|
-
getInstance: (sandbox) => {
|
|
253
|
-
return sandbox;
|
|
254
|
-
}
|
|
208
|
+
getInstance: (sandbox) => sandbox
|
|
255
209
|
},
|
|
256
|
-
// Template management methods using the new factory pattern
|
|
257
210
|
template: {
|
|
258
211
|
create: async (config, options) => {
|
|
259
212
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
260
|
-
if (!apiKey)
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
);
|
|
264
|
-
}
|
|
265
|
-
try {
|
|
266
|
-
const client = new RunloopSDK({
|
|
267
|
-
bearerToken: apiKey
|
|
268
|
-
});
|
|
269
|
-
const blueprint = await client.api.blueprints.create(options);
|
|
270
|
-
return blueprint;
|
|
271
|
-
} catch (error) {
|
|
272
|
-
throw new Error(
|
|
273
|
-
`Failed to create blueprint template: ${error instanceof Error ? error.message : String(error)}`
|
|
274
|
-
);
|
|
275
|
-
}
|
|
213
|
+
if (!apiKey) throw new Error("Missing Runloop API key for blueprint template creation");
|
|
214
|
+
const client = new RunloopSDK({ bearerToken: apiKey });
|
|
215
|
+
return client.api.blueprints.create(options);
|
|
276
216
|
},
|
|
277
217
|
list: async (config, options) => {
|
|
278
218
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
279
|
-
if (!apiKey)
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
const client = new RunloopSDK({
|
|
286
|
-
bearerToken: apiKey
|
|
287
|
-
});
|
|
288
|
-
const listParams = {};
|
|
289
|
-
if (options?.limit) {
|
|
290
|
-
listParams.limit = options.limit;
|
|
291
|
-
}
|
|
292
|
-
const response = await client.api.blueprints.list(listParams);
|
|
293
|
-
return response.blueprints || [];
|
|
294
|
-
} catch (error) {
|
|
295
|
-
throw new Error(
|
|
296
|
-
`Failed to list blueprint templates: ${error instanceof Error ? error.message : String(error)}`
|
|
297
|
-
);
|
|
298
|
-
}
|
|
219
|
+
if (!apiKey) throw new Error("Missing Runloop API key for listing blueprint templates");
|
|
220
|
+
const client = new RunloopSDK({ bearerToken: apiKey });
|
|
221
|
+
const listParams = {};
|
|
222
|
+
if (options?.limit) listParams.limit = options.limit;
|
|
223
|
+
const response = await client.api.blueprints.list(listParams);
|
|
224
|
+
return response.blueprints || [];
|
|
299
225
|
},
|
|
300
226
|
delete: async (config, blueprintId) => {
|
|
301
227
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
302
|
-
if (!apiKey)
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
);
|
|
306
|
-
}
|
|
307
|
-
try {
|
|
308
|
-
const client = new RunloopSDK({
|
|
309
|
-
bearerToken: apiKey
|
|
310
|
-
});
|
|
311
|
-
await client.api.blueprints.delete(blueprintId);
|
|
312
|
-
} catch (error) {
|
|
313
|
-
throw new Error(
|
|
314
|
-
`Failed to delete blueprint template ${blueprintId}: ${error instanceof Error ? error.message : String(error)}`
|
|
315
|
-
);
|
|
316
|
-
}
|
|
228
|
+
if (!apiKey) throw new Error("Missing Runloop API key for blueprint template deletion");
|
|
229
|
+
const client = new RunloopSDK({ bearerToken: apiKey });
|
|
230
|
+
await client.api.blueprints.delete(blueprintId);
|
|
317
231
|
}
|
|
318
232
|
},
|
|
319
|
-
// Snapshot management methods using the new factory pattern
|
|
320
233
|
snapshot: {
|
|
321
234
|
create: async (config, sandboxId, options) => {
|
|
322
235
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
323
|
-
if (!apiKey)
|
|
324
|
-
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
});
|
|
330
|
-
const snapshotParams = {};
|
|
331
|
-
if (options?.name) {
|
|
332
|
-
snapshotParams.name = options.name;
|
|
333
|
-
}
|
|
334
|
-
if (options?.metadata) {
|
|
335
|
-
snapshotParams.metadata = options.metadata;
|
|
336
|
-
}
|
|
337
|
-
const snapshot = await client.api.devboxes.snapshotDisk(
|
|
338
|
-
sandboxId,
|
|
339
|
-
snapshotParams
|
|
340
|
-
);
|
|
341
|
-
return snapshot;
|
|
342
|
-
} catch (error) {
|
|
343
|
-
throw new Error(
|
|
344
|
-
`Failed to create snapshot for sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)}`
|
|
345
|
-
);
|
|
346
|
-
}
|
|
236
|
+
if (!apiKey) throw new Error("Missing Runloop API key for snapshot creation");
|
|
237
|
+
const client = new RunloopSDK({ bearerToken: apiKey });
|
|
238
|
+
const snapshotParams = {};
|
|
239
|
+
if (options?.name) snapshotParams.name = options.name;
|
|
240
|
+
if (options?.metadata) snapshotParams.metadata = options.metadata;
|
|
241
|
+
return client.api.devboxes.snapshotDisk(sandboxId, snapshotParams);
|
|
347
242
|
},
|
|
348
243
|
list: async (config, options) => {
|
|
349
244
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
350
|
-
if (!apiKey)
|
|
351
|
-
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
});
|
|
357
|
-
const listParams = {};
|
|
358
|
-
if (options?.limit) {
|
|
359
|
-
listParams.limit = options.limit;
|
|
360
|
-
}
|
|
361
|
-
const response = await client.api.devboxes.listDiskSnapshots(listParams);
|
|
362
|
-
return response.snapshots || [];
|
|
363
|
-
} catch (error) {
|
|
364
|
-
throw new Error(
|
|
365
|
-
`Failed to list snapshots: ${error instanceof Error ? error.message : String(error)}`
|
|
366
|
-
);
|
|
367
|
-
}
|
|
245
|
+
if (!apiKey) throw new Error("Missing Runloop API key for listing snapshots");
|
|
246
|
+
const client = new RunloopSDK({ bearerToken: apiKey });
|
|
247
|
+
const listParams = {};
|
|
248
|
+
if (options?.limit) listParams.limit = options.limit;
|
|
249
|
+
const response = await client.api.devboxes.listDiskSnapshots(listParams);
|
|
250
|
+
return response.snapshots || [];
|
|
368
251
|
},
|
|
369
252
|
delete: async (config, snapshotId) => {
|
|
370
253
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
371
|
-
if (!apiKey)
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
try {
|
|
375
|
-
const client = new RunloopSDK({
|
|
376
|
-
bearerToken: apiKey
|
|
377
|
-
});
|
|
378
|
-
await client.api.devboxes.deleteDiskSnapshot(snapshotId);
|
|
379
|
-
} catch (error) {
|
|
380
|
-
throw new Error(
|
|
381
|
-
`Failed to delete snapshot ${snapshotId}: ${error instanceof Error ? error.message : String(error)}`
|
|
382
|
-
);
|
|
383
|
-
}
|
|
254
|
+
if (!apiKey) throw new Error("Missing Runloop API key for snapshot deletion");
|
|
255
|
+
const client = new RunloopSDK({ bearerToken: apiKey });
|
|
256
|
+
await client.api.devboxes.deleteDiskSnapshot(snapshotId);
|
|
384
257
|
}
|
|
385
258
|
}
|
|
386
259
|
}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Runloop Provider - Factory-based Implementation\n *\n * Full-featured provider with filesystem support using the factory pattern.\n * Reduces ~400 lines of boilerplate to ~100 lines of core logic.\n */\n\nimport { RunloopSDK, type Runloop } from \"@runloop/api-client\";\nimport { defineProvider, escapeShellArg } from \"@computesdk/provider\";\nimport type {\n CommandResult,\n SandboxInfo,\n CreateSnapshotOptions,\n ListSnapshotsOptions,\n RunCommandOptions,\n} from \"@computesdk/provider\";\nimport type {\n CreateSandboxOptions,\n FileEntry,\n Runtime,\n} from \"computesdk\";\n\n// Define Runloop-specific types\ntype RunloopSnapshot = Runloop.DevboxSnapshotView;\ntype RunloopTemplate = Runloop.BlueprintView;\ntype RunloopSandbox = Runloop.DevboxView & { client: RunloopSDK };\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\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, // TSandbox\n RunloopConfig, // TConfig\n RunloopTemplate, // TTemplate \n RunloopSnapshot // TSnapshot\n>({\n name: \"runloop\",\n methods: {\n sandbox: {\n // Collection operations (map to compute.sandbox.*)\n create: async (config: RunloopConfig, options?: CreateSandboxOptions) => {\n // Validate API key\n const apiKey =\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.RUNLOOP_API_KEY) ||\n \"\";\n\n if (!apiKey) {\n throw new Error(\n `Missing Runloop API key. Provide 'apiKey' in config or set RUNLOOP_API_KEY environment variable. Get your API key from https://runloop.ai/`\n );\n }\n\n const timeout = config.timeout;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n // Destructure known ComputeSDK fields, collect the rest for passthrough\n const {\n runtime: _runtime,\n timeout: optTimeout,\n envs,\n name,\n metadata,\n templateId,\n snapshotId: _snapshotId,\n sandboxId: optSandboxId,\n namespace: _namespace,\n directory: _directory,\n ...providerOptions\n } = options || {};\n\n // Convert ms to seconds for Runloop's keep_alive_time_seconds\n // options.timeout takes precedence over config.timeout\n const effectiveTimeout = optTimeout ?? timeout;\n const keepAliveSeconds = effectiveTimeout\n ? Math.ceil(effectiveTimeout / 1000)\n : 1800;\n\n let devboxParams: Runloop.DevboxCreateParams = {\n launch_parameters: {\n keep_alive_time_seconds: keepAliveSeconds,\n },\n name: name || optSandboxId,\n metadata,\n environment_variables: envs,\n ...providerOptions, // Spread provider-specific options (e.g., blueprint params, resource_size)\n };\n\n // Use blueprint if specified\n if (templateId) {\n // Check template prefix to determine parameter type\n if (templateId.startsWith(\"bpt_\")) {\n devboxParams.blueprint_id = templateId;\n } else if (templateId.startsWith(\"snp_\")) {\n devboxParams.snapshot_id = templateId;\n }\n }\n\n const dbx = await client.api.devboxes.createAndAwaitRunning(\n devboxParams,\n );\n\n // Create a RunloopSandbox object that contains both devbox and client\n const runloopSandbox: RunloopSandbox = {\n ...dbx, // Spread all DevboxView properties\n client: client // Add client for method access\n };\n\n return {\n sandbox: runloopSandbox,\n sandboxId: dbx.id,\n };\n } catch (error) {\n throw new Error(\n `Failed to create Runloop devbox: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n getById: async (config: RunloopConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const devbox = await client.api.devboxes.retrieve(sandboxId);\n const runloopSandbox: RunloopSandbox = {\n ...devbox,\n client,\n };\n\n return {\n sandbox: runloopSandbox,\n sandboxId,\n };\n } catch (error) {\n // Devbox doesn't exist or can't be accessed\n return null;\n }\n },\n\n list: async (config: RunloopConfig) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const response = await client.api.devboxes.list();\n const devboxes = response.devboxes || [];\n\n return devboxes.map((devbox) => ({\n sandbox: {\n ...devbox,\n client,\n } as RunloopSandbox,\n sandboxId: devbox.id,\n }));\n } catch (error) {\n // Return empty array if listing fails\n return [];\n }\n },\n\n destroy: async (config: RunloopConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n await client.api.devboxes.shutdown(sandboxId);\n } catch (error) {\n // Devbox might already be destroyed or doesn't exist\n // This is acceptable for destroy operations\n }\n },\n\n // Instance operations (map to individual Sandbox methods)\n\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 // Build the full command with options\n let fullCommand = command;\n\n // Handle environment variables\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([k, v]) => `${k}=\"${escapeShellArg(String(v))}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n\n // Handle working directory\n if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n\n // Handle background execution\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n\n const executionResult =\n await client.api.devboxes.executeAndAwaitCompletion(devbox.id, {\n command: fullCommand,\n });\n\n return {\n stdout: executionResult.stdout || \"\",\n stderr: executionResult.stderr || \"\",\n exitCode: executionResult.exit_status || 0,\n durationMs: Date.now() - startTime,\n };\n } catch (error) {\n // Re-throw syntax errors\n if (\n error instanceof Error &&\n error.message.includes(\"Syntax error\")\n ) {\n throw error;\n }\n throw new Error(\n `Runloop execution failed: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n getInfo: async (sandbox): Promise<SandboxInfo> => {\n const devbox = sandbox;\n\n return {\n id: devbox.id || \"runloop-unknown\",\n provider: \"runloop\",\n runtime: \"node\" as Runtime, // Runloop supports multiple runtimes, defaulting to node\n status: devbox.status as 'running' | 'stopped' | 'error',\n createdAt: new Date(devbox.create_time_ms || Date.now()),\n timeout: devbox.launch_parameters.keep_alive_time_seconds || 300000,\n metadata: {\n runloopDevboxId: devbox.id,\n templateId: devbox.blueprint_id || devbox.snapshot_id,\n ...devbox.metadata,\n },\n };\n },\n\n getUrl: async (\n sandbox: 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\n // Optional filesystem methods - using Runloop's file operations\n filesystem: {\n readFile: async (sandbox: RunloopSandbox, path: string, runCommand: CommandRunner): Promise<string> => {\n try {\n const result = await runCommand(sandbox, `cat \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`File not found or unreadable: ${result.stderr}`);\n }\n return result.stdout;\n } catch (error) {\n throw new Error(\n `Failed to read file ${path}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n writeFile: async (\n sandbox: RunloopSandbox,\n path: string,\n content: string,\n runCommand: CommandRunner\n ): Promise<void> => {\n try {\n // Use command-based approach for file writing since API writeFileContents may have issues\n const encoded = Buffer.from(content).toString('base64');\n const result = await runCommand(sandbox, `sh -c 'echo \"${encoded}\" | base64 -d > \"${path}\"'`);\n\n if (result.exitCode !== 0) {\n throw new Error(`Command failed: ${result.stderr}`);\n }\n } catch (error) {\n throw new Error(\n `Failed to write file ${path}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n mkdir: async (\n sandbox: RunloopSandbox,\n path: string,\n runCommand: CommandRunner\n ): Promise<void> => {\n const result = await runCommand(sandbox, `mkdir -p \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(\n `Failed to create directory ${path}: ${result.stderr}`\n );\n }\n },\n\n readdir: async (\n sandbox: RunloopSandbox,\n path: string,\n runCommand: CommandRunner\n ): Promise<FileEntry[]> => {\n const result = await runCommand(sandbox, `ls -la \"${path}\"`);\n\n if (result.exitCode !== 0) {\n throw new Error(\n `Failed to list directory ${path}: ${result.stderr}`\n );\n }\n\n const lines = (result.stdout || \"\")\n .split(\"\\n\")\n .filter((line: string) => line.trim() && !line.startsWith(\"total\"));\n\n return lines.map((line: string) => {\n const parts = line.trim().split(/\\s+/);\n const name = parts[parts.length - 1];\n const isDirectory = line.startsWith(\"d\");\n\n return {\n name,\n type: isDirectory ? 'directory' as const : 'file' as const,\n size: parseInt(parts[4]) || 0,\n modified: new Date(),\n };\n });\n },\n\n exists: async (\n sandbox: RunloopSandbox,\n path: string,\n runCommand: CommandRunner\n ): Promise<boolean> => {\n const result = await runCommand(sandbox, `test -e \"${path}\"`);\n return result.exitCode === 0;\n },\n\n remove: async (\n sandbox: RunloopSandbox,\n path: string,\n runCommand: CommandRunner\n ): Promise<void> => {\n const result = await runCommand(sandbox, `rm -rf \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to remove ${path}: ${result.stderr}`);\n }\n },\n },\n\n // Provider-specific typed getInstance method\n getInstance: (sandbox: RunloopSandbox): RunloopSandbox => {\n return sandbox;\n },\n },\n\n // Template management methods using the new factory pattern\n template: {\n create: async (\n config: RunloopConfig,\n options: CreateBlueprintTemplateOptions | Runloop.BlueprintCreateParams\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for blueprint template creation\"\n );\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const blueprint = await client.api.blueprints.create(options);\n return blueprint;\n } catch (error) {\n throw new Error(\n `Failed to create blueprint template: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n list: async (config: RunloopConfig, options?: { limit?: number }) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for listing blueprint templates\"\n );\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const listParams: any = {};\n if (options?.limit) {\n listParams.limit = options.limit;\n }\n\n const response = await client.api.blueprints.list(listParams);\n return response.blueprints || [];\n } catch (error) {\n throw new Error(\n `Failed to list blueprint templates: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n delete: async (config: RunloopConfig, blueprintId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for blueprint template deletion\"\n );\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n await client.api.blueprints.delete(blueprintId);\n } catch (error) {\n throw new Error(\n `Failed to delete blueprint template ${blueprintId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n },\n\n // Snapshot management methods using the new factory pattern\n snapshot: {\n create: async (\n config: RunloopConfig,\n sandboxId: string,\n options?: CreateSnapshotOptions\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for snapshot creation\");\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const snapshotParams: any = {};\n if (options?.name) {\n snapshotParams.name = options.name;\n }\n if (options?.metadata) {\n snapshotParams.metadata = options.metadata;\n }\n\n const snapshot = await client.api.devboxes.snapshotDisk(\n sandboxId,\n snapshotParams\n );\n return snapshot;\n } catch (error) {\n throw new Error(\n `Failed to create snapshot for sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n list: async (\n config: RunloopConfig,\n options?: ListSnapshotsOptions\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for listing snapshots\");\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const listParams: any = {};\n if (options?.limit) {\n listParams.limit = options.limit;\n }\n\n const response = await client.api.devboxes.listDiskSnapshots(listParams);\n return response.snapshots || [];\n } catch (error) {\n throw new Error(\n `Failed to list snapshots: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n delete: async (config: RunloopConfig, snapshotId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for snapshot deletion\");\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n await client.api.devboxes.deleteDiskSnapshot(snapshotId);\n } catch (error) {\n throw new Error(\n `Failed to delete snapshot ${snapshotId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n },\n },\n});\n"],"mappings":";AAOA,SAAS,kBAAgC;AACzC,SAAS,gBAAgB,sBAAsB;AAoFxC,IAAM,UAAU,eAKrB;AAAA,EACA,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA;AAAA,MAEP,QAAQ,OAAO,QAAuB,YAAmC;AAEvE,cAAM,SACJ,OAAO,UACN,OAAO,YAAY,eAAe,QAAQ,KAAK,mBAChD;AAEF,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAEA,cAAM,UAAU,OAAO;AAEvB,YAAI;AACF,gBAAM,SAAS,IAAI,WAAW;AAAA,YAC5B,aAAa;AAAA,UACf,CAAC;AAGD,gBAAM;AAAA,YACJ,SAAS;AAAA,YACT,SAAS;AAAA,YACT;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,YAAY;AAAA,YACZ,WAAW;AAAA,YACX,WAAW;AAAA,YACX,WAAW;AAAA,YACX,GAAG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;AACX,gBAAM,IAAI,MAAM,+CAA+C;AAAA,QACjE;AAEA,YAAI;AACF,gBAAM,SAAS,IAAI,WAAW;AAAA,YAC5B,aAAa;AAAA,UACf,CAAC;AAED,gBAAM,OAAO,IAAI,SAAS,mBAAmB,UAAU;AAAA,QACzD,SAAS,OAAO;AACd,gBAAM,IAAI;AAAA,YACR,6BAA6B,UAAU,KAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CACjG;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
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 };\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\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 apiKey =\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.RUNLOOP_API_KEY) ||\n \"\";\n\n if (!apiKey) {\n throw new Error(\n `Missing Runloop API key. Provide 'apiKey' in config or set RUNLOOP_API_KEY environment variable. Get your API key from https://runloop.ai/`\n );\n }\n\n const timeout = config.timeout;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const {\n timeout: optTimeout,\n envs,\n name,\n metadata,\n templateId,\n snapshotId,\n sandboxId: optSandboxId,\n namespace: _namespace,\n directory: _directory,\n ...providerOptions\n } = options || {};\n\n const effectiveTimeout = optTimeout ?? timeout;\n const keepAliveSeconds = effectiveTimeout\n ? Math.ceil(effectiveTimeout / 1000)\n : 1800;\n\n let devboxParams: Runloop.DevboxCreateParams = {\n launch_parameters: {\n keep_alive_time_seconds: keepAliveSeconds,\n },\n name: name || optSandboxId,\n metadata,\n environment_variables: envs,\n ...providerOptions,\n };\n\n // snapshotId is the canonical cross-provider field — map it directly to snapshot_id.\n // templateId is kept for backwards compatibility: bpt_ prefix → blueprint_id, snp_ prefix → snapshot_id.\n if (snapshotId) {\n devboxParams.snapshot_id = snapshotId;\n } else if (templateId) {\n if (templateId.startsWith(\"bpt_\")) {\n devboxParams.blueprint_id = templateId;\n } else if (templateId.startsWith(\"snp_\")) {\n devboxParams.snapshot_id = templateId;\n }\n }\n\n const dbx = await client.api.devboxes.createAndAwaitRunning(\n devboxParams,\n );\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 const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({ bearerToken: apiKey });\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 const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({ bearerToken: apiKey });\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 const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({ bearerToken: apiKey });\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 });\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, `cat \"${path}\"`);\n if (result.exitCode !== 0) throw new Error(`File not found or unreadable: ${result.stderr}`);\n return result.stdout;\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 apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n if (!apiKey) throw new Error(\"Missing Runloop API key for blueprint template creation\");\n const client = new RunloopSDK({ bearerToken: apiKey });\n return client.api.blueprints.create(options);\n },\n\n list: async (config: RunloopConfig, options?: { limit?: number }) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n if (!apiKey) throw new Error(\"Missing Runloop API key for listing blueprint templates\");\n const client = new RunloopSDK({ bearerToken: apiKey });\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 apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n if (!apiKey) throw new Error(\"Missing Runloop API key for blueprint template deletion\");\n const client = new RunloopSDK({ bearerToken: apiKey });\n await client.api.blueprints.delete(blueprintId);\n },\n },\n\n snapshot: {\n create: async (config: RunloopConfig, sandboxId: string, options?: CreateSnapshotOptions) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n if (!apiKey) throw new Error(\"Missing Runloop API key for snapshot creation\");\n const client = new RunloopSDK({ bearerToken: apiKey });\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 apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n if (!apiKey) throw new Error(\"Missing Runloop API key for listing snapshots\");\n const client = new RunloopSDK({ bearerToken: apiKey });\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 apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n if (!apiKey) throw new Error(\"Missing Runloop API key for snapshot deletion\");\n const client = new RunloopSDK({ bearerToken: apiKey });\n await client.api.devboxes.deleteDiskSnapshot(snapshotId);\n },\n },\n },\n});\n"],"mappings":";AAOA,SAAS,kBAAgC;AACzC,SAAS,gBAAgB,sBAAsB;AAmFxC,IAAM,UAAU,eAKrB;AAAA,EACA,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA,MACP,QAAQ,OAAO,QAAuB,YAAmC;AACvE,cAAM,SACJ,OAAO,UACN,OAAO,YAAY,eAAe,QAAQ,KAAK,mBAChD;AAEF,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAEA,cAAM,UAAU,OAAO;AAEvB,YAAI;AACF,gBAAM,SAAS,IAAI,WAAW;AAAA,YAC5B,aAAa;AAAA,UACf,CAAC;AAED,gBAAM;AAAA,YACJ,SAAS;AAAA,YACT;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,WAAW;AAAA,YACX,WAAW;AAAA,YACX,WAAW;AAAA,YACX,GAAG;AAAA,UACL,IAAI,WAAW,CAAC;AAEhB,gBAAM,mBAAmB,cAAc;AACvC,gBAAM,mBAAmB,mBACrB,KAAK,KAAK,mBAAmB,GAAI,IACjC;AAEJ,cAAI,eAA2C;AAAA,YAC7C,mBAAmB;AAAA,cACjB,yBAAyB;AAAA,YAC3B;AAAA,YACA,MAAM,QAAQ;AAAA,YACd;AAAA,YACA,uBAAuB;AAAA,YACvB,GAAG;AAAA,UACL;AAIA,cAAI,YAAY;AACd,yBAAa,cAAc;AAAA,UAC7B,WAAW,YA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,aAAa,OAAO,CAAC;AACrD,cAAM,iBAAsB,CAAC;AAC7B,YAAI,SAAS,KAAM,gBAAe,OAAO,QAAQ;AACjD,YAAI,SAAS,SAAU,gBAAe,WAAW,QAAQ;AACzD,eAAO,OAAO,IAAI,SAAS,aAAa,WAAW,cAAc;AAAA,MACnE;AAAA,MAEA,MAAM,OAAO,QAAuB,YAAmC;AACrE,cAAM,SAAS,OAAO,UAAU,QAAQ,IAAI;AAC5C,YAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,+CAA+C;AAC5E,cAAM,SAAS,IAAI,WAAW,EAAE,aAAa,OAAO,CAAC;AACrD,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,OAAO,UAAU,QAAQ,IAAI;AAC5C,YAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,+CAA+C;AAC5E,cAAM,SAAS,IAAI,WAAW,EAAE,aAAa,OAAO,CAAC;AACrD,cAAM,OAAO,IAAI,SAAS,mBAAmB,UAAU;AAAA,MACzD;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@computesdk/runloop",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.47",
|
|
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",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@runloop/api-client": "^1.11.0",
|
|
22
|
-
"@computesdk/provider": "1.
|
|
23
|
-
"computesdk": "
|
|
22
|
+
"@computesdk/provider": "2.1.0",
|
|
23
|
+
"computesdk": "4.1.0"
|
|
24
24
|
},
|
|
25
25
|
"keywords": [
|
|
26
26
|
"computesdk",
|
|
@@ -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": "
|
|
54
|
+
"@computesdk/test-utils": "2.0.0"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"build": "tsup",
|