@computesdk/runloop 1.3.44 → 1.3.46
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.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +52 -228
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -228
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as _computesdk_provider from '@computesdk/provider';
|
|
2
|
-
import { Runloop } from '@runloop/api-client';
|
|
2
|
+
import { Runloop, RunloopSDK } from '@runloop/api-client';
|
|
3
3
|
|
|
4
|
+
type RunloopSandbox = Runloop.DevboxView & {
|
|
5
|
+
client: RunloopSDK;
|
|
6
|
+
};
|
|
4
7
|
/**
|
|
5
8
|
* Runloop-specific configuration options
|
|
6
9
|
*/
|
|
@@ -54,6 +57,6 @@ interface CreateBlueprintTemplateOptions {
|
|
|
54
57
|
/**
|
|
55
58
|
* Create a Runloop provider instance using the factory pattern
|
|
56
59
|
*/
|
|
57
|
-
declare const runloop: (config: RunloopConfig) => _computesdk_provider.Provider<
|
|
60
|
+
declare const runloop: (config: RunloopConfig) => _computesdk_provider.Provider<RunloopSandbox, Runloop.Blueprints.BlueprintView, Runloop.Devboxes.DevboxSnapshotView>;
|
|
58
61
|
|
|
59
62
|
export { type CreateBlueprintTemplateOptions, type RunloopConfig, runloop };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as _computesdk_provider from '@computesdk/provider';
|
|
2
|
-
import { Runloop } from '@runloop/api-client';
|
|
2
|
+
import { Runloop, RunloopSDK } from '@runloop/api-client';
|
|
3
3
|
|
|
4
|
+
type RunloopSandbox = Runloop.DevboxView & {
|
|
5
|
+
client: RunloopSDK;
|
|
6
|
+
};
|
|
4
7
|
/**
|
|
5
8
|
* Runloop-specific configuration options
|
|
6
9
|
*/
|
|
@@ -54,6 +57,6 @@ interface CreateBlueprintTemplateOptions {
|
|
|
54
57
|
/**
|
|
55
58
|
* Create a Runloop provider instance using the factory pattern
|
|
56
59
|
*/
|
|
57
|
-
declare const runloop: (config: RunloopConfig) => _computesdk_provider.Provider<
|
|
60
|
+
declare const runloop: (config: RunloopConfig) => _computesdk_provider.Provider<RunloopSandbox, Runloop.Blueprints.BlueprintView, Runloop.Devboxes.DevboxSnapshotView>;
|
|
58
61
|
|
|
59
62
|
export { type CreateBlueprintTemplateOptions, type RunloopConfig, runloop };
|
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,7 +42,6 @@ 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,
|
|
@@ -53,8 +51,6 @@ var runloop = (0, import_provider.defineProvider)({
|
|
|
53
51
|
sandboxId: optSandboxId,
|
|
54
52
|
namespace: _namespace,
|
|
55
53
|
directory: _directory,
|
|
56
|
-
overlays: _overlays,
|
|
57
|
-
servers: _servers,
|
|
58
54
|
...providerOptions
|
|
59
55
|
} = options || {};
|
|
60
56
|
const effectiveTimeout = optTimeout ?? timeout;
|
|
@@ -67,7 +63,6 @@ var runloop = (0, import_provider.defineProvider)({
|
|
|
67
63
|
metadata,
|
|
68
64
|
environment_variables: envs,
|
|
69
65
|
...providerOptions
|
|
70
|
-
// Spread provider-specific options (e.g., blueprint params, resource_size)
|
|
71
66
|
};
|
|
72
67
|
if (templateId) {
|
|
73
68
|
if (templateId.startsWith("bpt_")) {
|
|
@@ -81,9 +76,7 @@ var runloop = (0, import_provider.defineProvider)({
|
|
|
81
76
|
);
|
|
82
77
|
const runloopSandbox = {
|
|
83
78
|
...dbx,
|
|
84
|
-
// Spread all DevboxView properties
|
|
85
79
|
client
|
|
86
|
-
// Add client for method access
|
|
87
80
|
};
|
|
88
81
|
return {
|
|
89
82
|
sandbox: runloopSandbox,
|
|
@@ -98,93 +91,36 @@ var runloop = (0, import_provider.defineProvider)({
|
|
|
98
91
|
getById: async (config, sandboxId) => {
|
|
99
92
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
100
93
|
try {
|
|
101
|
-
const client = new import_api_client.RunloopSDK({
|
|
102
|
-
bearerToken: apiKey
|
|
103
|
-
});
|
|
94
|
+
const client = new import_api_client.RunloopSDK({ bearerToken: apiKey });
|
|
104
95
|
const devbox = await client.api.devboxes.retrieve(sandboxId);
|
|
105
96
|
return {
|
|
106
|
-
sandbox: devbox,
|
|
97
|
+
sandbox: { ...devbox, client },
|
|
107
98
|
sandboxId
|
|
108
99
|
};
|
|
109
|
-
} catch
|
|
100
|
+
} catch {
|
|
110
101
|
return null;
|
|
111
102
|
}
|
|
112
103
|
},
|
|
113
104
|
list: async (config) => {
|
|
114
105
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
115
106
|
try {
|
|
116
|
-
const client = new import_api_client.RunloopSDK({
|
|
117
|
-
bearerToken: apiKey
|
|
118
|
-
});
|
|
107
|
+
const client = new import_api_client.RunloopSDK({ bearerToken: apiKey });
|
|
119
108
|
const response = await client.api.devboxes.list();
|
|
120
109
|
const devboxes = response.devboxes || [];
|
|
121
110
|
return devboxes.map((devbox) => ({
|
|
122
|
-
sandbox: devbox,
|
|
111
|
+
sandbox: { ...devbox, client },
|
|
123
112
|
sandboxId: devbox.id
|
|
124
113
|
}));
|
|
125
|
-
} catch
|
|
114
|
+
} catch {
|
|
126
115
|
return [];
|
|
127
116
|
}
|
|
128
117
|
},
|
|
129
118
|
destroy: async (config, sandboxId) => {
|
|
130
119
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
131
120
|
try {
|
|
132
|
-
const client = new import_api_client.RunloopSDK({
|
|
133
|
-
bearerToken: apiKey
|
|
134
|
-
});
|
|
121
|
+
const client = new import_api_client.RunloopSDK({ bearerToken: apiKey });
|
|
135
122
|
await client.api.devboxes.shutdown(sandboxId);
|
|
136
|
-
} catch
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
// Instance operations (map to individual Sandbox methods)
|
|
140
|
-
runCode: async (sandbox, code, runtime) => {
|
|
141
|
-
const startTime = Date.now();
|
|
142
|
-
const devbox = sandbox;
|
|
143
|
-
const client = sandbox.client;
|
|
144
|
-
const effectiveRuntime = runtime || // Strong Python indicators
|
|
145
|
-
(code.includes("print(") || code.includes("import ") || code.includes("def ") || code.includes("sys.") || code.includes("json.") || code.includes("__") || code.includes('f"') || code.includes("f'") || code.includes("raise ") ? "python" : "node");
|
|
146
|
-
try {
|
|
147
|
-
const encoded = Buffer.from(code).toString("base64");
|
|
148
|
-
let command;
|
|
149
|
-
if (effectiveRuntime === "python") {
|
|
150
|
-
command = `echo "${encoded}" | base64 -d | python3`;
|
|
151
|
-
} else {
|
|
152
|
-
command = `echo "${encoded}" | base64 -d | node`;
|
|
153
|
-
}
|
|
154
|
-
const executionResult = await client.api.devboxes.executeAndAwaitCompletion(devbox.id, {
|
|
155
|
-
command
|
|
156
|
-
});
|
|
157
|
-
if (executionResult.exit_status !== 0 && executionResult.stderr) {
|
|
158
|
-
if (executionResult.stderr.includes("SyntaxError") || executionResult.stderr.includes("invalid syntax") || executionResult.stderr.includes("Unexpected token") || executionResult.stderr.includes("Unexpected identifier")) {
|
|
159
|
-
throw new Error(`Syntax error: ${executionResult.stderr.trim()}`);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return {
|
|
163
|
-
output: (executionResult.stdout || "") + (executionResult.stderr || ""),
|
|
164
|
-
exitCode: executionResult.exit_status || 0,
|
|
165
|
-
language: effectiveRuntime
|
|
166
|
-
};
|
|
167
|
-
} catch (error) {
|
|
168
|
-
if (error instanceof Error && error.message === "exit status 1") {
|
|
169
|
-
const actualStderr = error?.result?.stderr || "";
|
|
170
|
-
const isSyntaxError = actualStderr.includes("SyntaxError");
|
|
171
|
-
if (isSyntaxError) {
|
|
172
|
-
const syntaxErrorLine = actualStderr.split("\n").find((line) => line.includes("SyntaxError")) || "SyntaxError: Invalid syntax in code";
|
|
173
|
-
throw new Error(`Syntax error: ${syntaxErrorLine}`);
|
|
174
|
-
} else {
|
|
175
|
-
return {
|
|
176
|
-
output: actualStderr || "Error: Runtime error occurred during execution",
|
|
177
|
-
exitCode: 1,
|
|
178
|
-
language: effectiveRuntime
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
if (error instanceof Error && error.message.includes("Syntax error")) {
|
|
183
|
-
throw error;
|
|
184
|
-
}
|
|
185
|
-
throw new Error(
|
|
186
|
-
`Runloop execution failed: ${error instanceof Error ? error.message : String(error)}`
|
|
187
|
-
);
|
|
123
|
+
} catch {
|
|
188
124
|
}
|
|
189
125
|
},
|
|
190
126
|
runCommand: async (sandbox, command, options) => {
|
|
@@ -194,7 +130,7 @@ var runloop = (0, import_provider.defineProvider)({
|
|
|
194
130
|
try {
|
|
195
131
|
let fullCommand = command;
|
|
196
132
|
if (options?.env && Object.keys(options.env).length > 0) {
|
|
197
|
-
const envPrefix = Object.entries(options.env).map(([k, v]) => `${k}="${(0, import_provider.escapeShellArg)(v)}"`).join(" ");
|
|
133
|
+
const envPrefix = Object.entries(options.env).map(([k, v]) => `${k}="${(0, import_provider.escapeShellArg)(String(v))}"`).join(" ");
|
|
198
134
|
fullCommand = `${envPrefix} ${fullCommand}`;
|
|
199
135
|
}
|
|
200
136
|
if (options?.cwd) {
|
|
@@ -223,17 +159,18 @@ var runloop = (0, import_provider.defineProvider)({
|
|
|
223
159
|
},
|
|
224
160
|
getInfo: async (sandbox) => {
|
|
225
161
|
const devbox = sandbox;
|
|
162
|
+
const keepAliveSecs = devbox.launch_parameters.keep_alive_time_seconds;
|
|
226
163
|
return {
|
|
227
164
|
id: devbox.id || "runloop-unknown",
|
|
228
165
|
provider: "runloop",
|
|
229
|
-
runtime: "node",
|
|
230
|
-
// Runloop supports multiple runtimes, defaulting to node
|
|
231
166
|
status: devbox.status,
|
|
232
167
|
createdAt: new Date(devbox.create_time_ms || Date.now()),
|
|
233
|
-
|
|
168
|
+
// keep_alive_time_seconds is in seconds; SandboxInfo.timeout is in milliseconds
|
|
169
|
+
timeout: keepAliveSecs ? keepAliveSecs * 1e3 : 3e5,
|
|
234
170
|
metadata: {
|
|
235
171
|
runloopDevboxId: devbox.id,
|
|
236
172
|
templateId: devbox.blueprint_id || devbox.snapshot_id,
|
|
173
|
+
runtime: "node",
|
|
237
174
|
...devbox.metadata
|
|
238
175
|
}
|
|
239
176
|
};
|
|
@@ -242,59 +179,32 @@ var runloop = (0, import_provider.defineProvider)({
|
|
|
242
179
|
const devbox = sandbox;
|
|
243
180
|
const client = sandbox.client;
|
|
244
181
|
try {
|
|
245
|
-
const tunnel = await client.api.devboxes.
|
|
246
|
-
|
|
247
|
-
});
|
|
248
|
-
return tunnel.url;
|
|
182
|
+
const tunnel = await client.api.devboxes.enableTunnel(devbox.id);
|
|
183
|
+
return `https://${options.port}-${tunnel.tunnel_key}.tunnel.runloop.ai`;
|
|
249
184
|
} catch (error) {
|
|
250
185
|
throw new Error(
|
|
251
186
|
`Failed to get Runloop URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`
|
|
252
187
|
);
|
|
253
188
|
}
|
|
254
189
|
},
|
|
255
|
-
// Optional filesystem methods - using Runloop's file operations
|
|
256
190
|
filesystem: {
|
|
257
191
|
readFile: async (sandbox, path, runCommand) => {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
throw new Error(`File not found or unreadable: ${result.stderr}`);
|
|
262
|
-
}
|
|
263
|
-
return result.stdout;
|
|
264
|
-
} catch (error) {
|
|
265
|
-
throw new Error(
|
|
266
|
-
`Failed to read file ${path}: ${error instanceof Error ? error.message : String(error)}`
|
|
267
|
-
);
|
|
268
|
-
}
|
|
192
|
+
const result = await runCommand(sandbox, `cat "${path}"`);
|
|
193
|
+
if (result.exitCode !== 0) throw new Error(`File not found or unreadable: ${result.stderr}`);
|
|
194
|
+
return result.stdout;
|
|
269
195
|
},
|
|
270
196
|
writeFile: async (sandbox, path, content, runCommand) => {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
if (result.exitCode !== 0) {
|
|
275
|
-
throw new Error(`Command failed: ${result.stderr}`);
|
|
276
|
-
}
|
|
277
|
-
} catch (error) {
|
|
278
|
-
throw new Error(
|
|
279
|
-
`Failed to write file ${path}: ${error instanceof Error ? error.message : String(error)}`
|
|
280
|
-
);
|
|
281
|
-
}
|
|
197
|
+
const encoded = Buffer.from(content).toString("base64");
|
|
198
|
+
const result = await runCommand(sandbox, `sh -c 'echo "${encoded}" | base64 -d > "${path}"'`);
|
|
199
|
+
if (result.exitCode !== 0) throw new Error(`Failed to write file ${path}: ${result.stderr}`);
|
|
282
200
|
},
|
|
283
201
|
mkdir: async (sandbox, path, runCommand) => {
|
|
284
202
|
const result = await runCommand(sandbox, `mkdir -p "${path}"`);
|
|
285
|
-
if (result.exitCode !== 0) {
|
|
286
|
-
throw new Error(
|
|
287
|
-
`Failed to create directory ${path}: ${result.stderr}`
|
|
288
|
-
);
|
|
289
|
-
}
|
|
203
|
+
if (result.exitCode !== 0) throw new Error(`Failed to create directory ${path}: ${result.stderr}`);
|
|
290
204
|
},
|
|
291
205
|
readdir: async (sandbox, path, runCommand) => {
|
|
292
206
|
const result = await runCommand(sandbox, `ls -la "${path}"`);
|
|
293
|
-
if (result.exitCode !== 0) {
|
|
294
|
-
throw new Error(
|
|
295
|
-
`Failed to list directory ${path}: ${result.stderr}`
|
|
296
|
-
);
|
|
297
|
-
}
|
|
207
|
+
if (result.exitCode !== 0) throw new Error(`Failed to list directory ${path}: ${result.stderr}`);
|
|
298
208
|
const lines = (result.stdout || "").split("\n").filter((line) => line.trim() && !line.startsWith("total"));
|
|
299
209
|
return lines.map((line) => {
|
|
300
210
|
const parts = line.trim().split(/\s+/);
|
|
@@ -314,144 +224,58 @@ var runloop = (0, import_provider.defineProvider)({
|
|
|
314
224
|
},
|
|
315
225
|
remove: async (sandbox, path, runCommand) => {
|
|
316
226
|
const result = await runCommand(sandbox, `rm -rf "${path}"`);
|
|
317
|
-
if (result.exitCode !== 0) {
|
|
318
|
-
throw new Error(`Failed to remove ${path}: ${result.stderr}`);
|
|
319
|
-
}
|
|
227
|
+
if (result.exitCode !== 0) throw new Error(`Failed to remove ${path}: ${result.stderr}`);
|
|
320
228
|
}
|
|
321
229
|
},
|
|
322
|
-
|
|
323
|
-
getInstance: (sandbox) => {
|
|
324
|
-
return sandbox;
|
|
325
|
-
}
|
|
230
|
+
getInstance: (sandbox) => sandbox
|
|
326
231
|
},
|
|
327
|
-
// Template management methods using the new factory pattern
|
|
328
232
|
template: {
|
|
329
233
|
create: async (config, options) => {
|
|
330
234
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
331
|
-
if (!apiKey)
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
);
|
|
335
|
-
}
|
|
336
|
-
try {
|
|
337
|
-
const client = new import_api_client.RunloopSDK({
|
|
338
|
-
bearerToken: apiKey
|
|
339
|
-
});
|
|
340
|
-
const blueprint = await client.api.blueprints.create(options);
|
|
341
|
-
return blueprint;
|
|
342
|
-
} catch (error) {
|
|
343
|
-
throw new Error(
|
|
344
|
-
`Failed to create blueprint template: ${error instanceof Error ? error.message : String(error)}`
|
|
345
|
-
);
|
|
346
|
-
}
|
|
235
|
+
if (!apiKey) throw new Error("Missing Runloop API key for blueprint template creation");
|
|
236
|
+
const client = new import_api_client.RunloopSDK({ bearerToken: apiKey });
|
|
237
|
+
return client.api.blueprints.create(options);
|
|
347
238
|
},
|
|
348
239
|
list: async (config, options) => {
|
|
349
240
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
350
|
-
if (!apiKey)
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
const client = new import_api_client.RunloopSDK({
|
|
357
|
-
bearerToken: apiKey
|
|
358
|
-
});
|
|
359
|
-
const listParams = {};
|
|
360
|
-
if (options?.limit) {
|
|
361
|
-
listParams.limit = options.limit;
|
|
362
|
-
}
|
|
363
|
-
const response = await client.api.blueprints.list(listParams);
|
|
364
|
-
return response.blueprints || [];
|
|
365
|
-
} catch (error) {
|
|
366
|
-
throw new Error(
|
|
367
|
-
`Failed to list blueprint templates: ${error instanceof Error ? error.message : String(error)}`
|
|
368
|
-
);
|
|
369
|
-
}
|
|
241
|
+
if (!apiKey) throw new Error("Missing Runloop API key for listing blueprint templates");
|
|
242
|
+
const client = new import_api_client.RunloopSDK({ bearerToken: apiKey });
|
|
243
|
+
const listParams = {};
|
|
244
|
+
if (options?.limit) listParams.limit = options.limit;
|
|
245
|
+
const response = await client.api.blueprints.list(listParams);
|
|
246
|
+
return response.blueprints || [];
|
|
370
247
|
},
|
|
371
248
|
delete: async (config, blueprintId) => {
|
|
372
249
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
373
|
-
if (!apiKey)
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
);
|
|
377
|
-
}
|
|
378
|
-
try {
|
|
379
|
-
const client = new import_api_client.RunloopSDK({
|
|
380
|
-
bearerToken: apiKey
|
|
381
|
-
});
|
|
382
|
-
await client.api.blueprints.delete(blueprintId);
|
|
383
|
-
} catch (error) {
|
|
384
|
-
throw new Error(
|
|
385
|
-
`Failed to delete blueprint template ${blueprintId}: ${error instanceof Error ? error.message : String(error)}`
|
|
386
|
-
);
|
|
387
|
-
}
|
|
250
|
+
if (!apiKey) throw new Error("Missing Runloop API key for blueprint template deletion");
|
|
251
|
+
const client = new import_api_client.RunloopSDK({ bearerToken: apiKey });
|
|
252
|
+
await client.api.blueprints.delete(blueprintId);
|
|
388
253
|
}
|
|
389
254
|
},
|
|
390
|
-
// Snapshot management methods using the new factory pattern
|
|
391
255
|
snapshot: {
|
|
392
256
|
create: async (config, sandboxId, options) => {
|
|
393
257
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
394
|
-
if (!apiKey)
|
|
395
|
-
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
});
|
|
401
|
-
const snapshotParams = {};
|
|
402
|
-
if (options?.name) {
|
|
403
|
-
snapshotParams.name = options.name;
|
|
404
|
-
}
|
|
405
|
-
if (options?.metadata) {
|
|
406
|
-
snapshotParams.metadata = options.metadata;
|
|
407
|
-
}
|
|
408
|
-
const snapshot = await client.api.devboxes.snapshotDisk(
|
|
409
|
-
sandboxId,
|
|
410
|
-
snapshotParams
|
|
411
|
-
);
|
|
412
|
-
return snapshot;
|
|
413
|
-
} catch (error) {
|
|
414
|
-
throw new Error(
|
|
415
|
-
`Failed to create snapshot for sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)}`
|
|
416
|
-
);
|
|
417
|
-
}
|
|
258
|
+
if (!apiKey) throw new Error("Missing Runloop API key for snapshot creation");
|
|
259
|
+
const client = new import_api_client.RunloopSDK({ bearerToken: apiKey });
|
|
260
|
+
const snapshotParams = {};
|
|
261
|
+
if (options?.name) snapshotParams.name = options.name;
|
|
262
|
+
if (options?.metadata) snapshotParams.metadata = options.metadata;
|
|
263
|
+
return client.api.devboxes.snapshotDisk(sandboxId, snapshotParams);
|
|
418
264
|
},
|
|
419
265
|
list: async (config, options) => {
|
|
420
266
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
421
|
-
if (!apiKey)
|
|
422
|
-
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
});
|
|
428
|
-
const listParams = {};
|
|
429
|
-
if (options?.limit) {
|
|
430
|
-
listParams.limit = options.limit;
|
|
431
|
-
}
|
|
432
|
-
const response = await client.api.devboxes.listDiskSnapshots(listParams);
|
|
433
|
-
return response.snapshots || [];
|
|
434
|
-
} catch (error) {
|
|
435
|
-
throw new Error(
|
|
436
|
-
`Failed to list snapshots: ${error instanceof Error ? error.message : String(error)}`
|
|
437
|
-
);
|
|
438
|
-
}
|
|
267
|
+
if (!apiKey) throw new Error("Missing Runloop API key for listing snapshots");
|
|
268
|
+
const client = new import_api_client.RunloopSDK({ bearerToken: apiKey });
|
|
269
|
+
const listParams = {};
|
|
270
|
+
if (options?.limit) listParams.limit = options.limit;
|
|
271
|
+
const response = await client.api.devboxes.listDiskSnapshots(listParams);
|
|
272
|
+
return response.snapshots || [];
|
|
439
273
|
},
|
|
440
274
|
delete: async (config, snapshotId) => {
|
|
441
275
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
442
|
-
if (!apiKey)
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
try {
|
|
446
|
-
const client = new import_api_client.RunloopSDK({
|
|
447
|
-
bearerToken: apiKey
|
|
448
|
-
});
|
|
449
|
-
await client.api.devboxes.deleteDiskSnapshot(snapshotId);
|
|
450
|
-
} catch (error) {
|
|
451
|
-
throw new Error(
|
|
452
|
-
`Failed to delete snapshot ${snapshotId}: ${error instanceof Error ? error.message : String(error)}`
|
|
453
|
-
);
|
|
454
|
-
}
|
|
276
|
+
if (!apiKey) throw new Error("Missing Runloop API key for snapshot deletion");
|
|
277
|
+
const client = new import_api_client.RunloopSDK({ bearerToken: apiKey });
|
|
278
|
+
await client.api.devboxes.deleteDiskSnapshot(snapshotId);
|
|
455
279
|
}
|
|
456
280
|
}
|
|
457
281
|
}
|
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 CodeResult,\n CommandResult,\n SandboxInfo,\n CreateSnapshotOptions,\n ListSnapshotsOptions,\n RunCommandOptions,\n} from \"@computesdk/provider\";\nimport type {\n CreateSandboxOptions,\n FileEntry,\n Runtime,\n SandboxStatus,\n Sandbox,\n} from \"computesdk\";\n\n// Define Runloop-specific types\ntype RunloopSnapshot = Runloop.DevboxSnapshotView;\ntype RunloopTemplate = Runloop.BlueprintView;\n\n/**\n * Runloop-specific configuration options\n */\nexport interface RunloopConfig {\n /** Runloop API key - if not provided, will fallback to RUNLOOP_API_KEY environment variable */\n apiKey?: string;\n /** Execution timeout in milliseconds */\n timeout?: number;\n}\n\n/**\n * Runloop-specific blueprint creation options\n */\nexport interface CreateBlueprintTemplateOptions {\n /** Name of the blueprint template */\n name: string;\n /** Custom Dockerfile content */\n dockerfile?: string;\n /** System setup commands to run during blueprint creation */\n systemSetupCommands?: string[];\n /** Launch commands to run when starting a devbox from this blueprint */\n launchCommands?: string[];\n /** File mounts as key-value pairs (path -> content) */\n fileMounts?: Record<string, string>;\n /** Code repository mounts */\n codeMounts?: Array<{\n repoName: string;\n repoOwner: string;\n token?: string;\n installCommand?: string;\n }>;\n /** Resource size for devboxes created from this blueprint */\n resourceSize?:\n | \"X_SMALL\"\n | \"SMALL\"\n | \"MEDIUM\"\n | \"LARGE\"\n | \"X_LARGE\"\n | \"XX_LARGE\"\n | \"CUSTOM_SIZE\";\n /** CPU architecture */\n architecture?: \"x86_64\" | \"arm64\";\n /** Custom CPU cores (requires CUSTOM_SIZE) */\n customCpuCores?: number;\n /** Custom memory in GB (requires CUSTOM_SIZE) */\n customMemoryGb?: number;\n /** Custom disk size (requires CUSTOM_SIZE) */\n customDiskSize?: number;\n /** Available ports for the devbox */\n availablePorts?: number[];\n /** Action to take when devbox is idle */\n afterIdle?: { action: string; timeSeconds: number };\n /** Keep alive time in seconds */\n keepAliveTimeSeconds?: number;\n}\n\n/**\n * Create a Runloop provider instance using the factory pattern\n */\nexport const runloop = defineProvider<\n Runloop.DevboxView, // TSandbox\n RunloopConfig, // TConfig\n RunloopTemplate, // TTemplate \n RunloopSnapshot // TSnapshot\n>({\n name: \"runloop\",\n methods: {\n sandbox: {\n // Collection operations (map to compute.sandbox.*)\n create: async (config: RunloopConfig, options?: CreateSandboxOptions) => {\n // Validate API key\n const apiKey =\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.RUNLOOP_API_KEY) ||\n \"\";\n\n if (!apiKey) {\n throw new Error(\n `Missing Runloop API key. Provide 'apiKey' in config or set RUNLOOP_API_KEY environment variable. Get your API key from https://runloop.ai/`\n );\n }\n\n const timeout = config.timeout;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n // 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 overlays: _overlays,\n servers: _servers,\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 = {\n ...dbx, // Spread all DevboxView properties\n client: client // Add client for method access\n };\n\n return {\n sandbox: runloopSandbox,\n sandboxId: dbx.id,\n };\n } catch (error) {\n throw new Error(\n `Failed to create Runloop devbox: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n getById: async (config: RunloopConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const devbox = await client.api.devboxes.retrieve(sandboxId);\n\n return {\n sandbox: devbox,\n sandboxId,\n };\n } catch (error) {\n // Devbox doesn't exist or can't be accessed\n return null;\n }\n },\n\n list: async (config: RunloopConfig) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const response = await client.api.devboxes.list();\n const devboxes = response.devboxes || [];\n\n return devboxes.map((devbox) => ({\n sandbox: devbox,\n sandboxId: devbox.id,\n }));\n } catch (error) {\n // Return empty array if listing fails\n return [];\n }\n },\n\n destroy: async (config: RunloopConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n await client.api.devboxes.shutdown(sandboxId);\n } catch (error) {\n // Devbox might already be destroyed or doesn't exist\n // This is acceptable for destroy operations\n }\n },\n\n // Instance operations (map to individual Sandbox methods)\n runCode: async (sandbox: any, code: string, runtime?: Runtime): Promise<CodeResult> => {\n const startTime = Date.now();\n const devbox = sandbox;\n const client = sandbox.client;\n\n // Auto-detect runtime if not specified\n const effectiveRuntime: Runtime = runtime || (\n // Strong Python indicators\n code.includes('print(') ||\n code.includes('import ') ||\n code.includes('def ') ||\n code.includes('sys.') ||\n code.includes('json.') ||\n code.includes('__') ||\n code.includes('f\"') ||\n code.includes(\"f'\") ||\n code.includes('raise ')\n ? 'python'\n // Default to Node.js for all other cases (including ambiguous)\n : 'node'\n ) as Runtime;\n\n try {\n\n // Use base64 encoding for both runtimes for reliability and consistency\n const encoded = Buffer.from(code).toString('base64');\n\n let command;\n if (effectiveRuntime === 'python') {\n command = `echo \"${encoded}\" | base64 -d | python3`;\n } else {\n command = `echo \"${encoded}\" | base64 -d | node`;\n }\n\n // Execute code using Runloop's executeAsync\n const executionResult =\n await client.api.devboxes.executeAndAwaitCompletion(devbox.id, {\n command: command,\n });\n\n // Check for syntax errors and throw them (similar to Vercel behavior)\n if (executionResult.exit_status !== 0 && executionResult.stderr) {\n // Check for common syntax error patterns\n if (executionResult.stderr.includes('SyntaxError') ||\n executionResult.stderr.includes('invalid syntax') ||\n executionResult.stderr.includes('Unexpected token') ||\n executionResult.stderr.includes('Unexpected identifier')) {\n throw new Error(`Syntax error: ${executionResult.stderr.trim()}`);\n }\n }\n\n return {\n output: (executionResult.stdout || \"\") + (executionResult.stderr || \"\"),\n exitCode: executionResult.exit_status || 0,\n language: effectiveRuntime,\n };\n } catch (error) {\n // Handle Runloop execution errors\n if (error instanceof Error && error.message === 'exit status 1') {\n const actualStderr = (error as any)?.result?.stderr || '';\n const isSyntaxError = actualStderr.includes('SyntaxError');\n\n if (isSyntaxError) {\n // For syntax errors, throw\n const syntaxErrorLine = actualStderr.split('\\n').find((line: string) => line.includes('SyntaxError')) || 'SyntaxError: Invalid syntax in code';\n throw new Error(`Syntax error: ${syntaxErrorLine}`);\n } else {\n // For runtime errors, return a result instead of throwing\n return {\n output: actualStderr || 'Error: Runtime error occurred during execution',\n exitCode: 1,\n language: effectiveRuntime,\n };\n }\n }\n\n // Re-throw syntax errors\n if (error instanceof Error && error.message.includes('Syntax error')) {\n throw error;\n }\n throw new Error(\n `Runloop execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n runCommand: async (\n sandbox: any,\n command: string,\n options?: RunCommandOptions\n ): Promise<CommandResult> => {\n const startTime = Date.now();\n const devbox = sandbox;\n const client = sandbox.client;\n\n try {\n // Build the full command with options\n let fullCommand = command;\n\n // Handle environment variables\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([k, v]) => `${k}=\"${escapeShellArg(v)}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n\n // Handle working directory\n if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n\n // Handle background execution\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n\n const executionResult =\n await client.api.devboxes.executeAndAwaitCompletion(devbox.id, {\n command: fullCommand,\n });\n\n return {\n stdout: executionResult.stdout || \"\",\n stderr: executionResult.stderr || \"\",\n exitCode: executionResult.exit_status || 0,\n durationMs: Date.now() - startTime,\n };\n } catch (error) {\n // Re-throw syntax errors\n if (\n error instanceof Error &&\n error.message.includes(\"Syntax error\")\n ) {\n throw error;\n }\n throw new Error(\n `Runloop execution failed: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n getInfo: async (sandbox): Promise<SandboxInfo> => {\n const devbox = sandbox;\n\n return {\n id: devbox.id || \"runloop-unknown\",\n provider: \"runloop\",\n runtime: \"node\" as Runtime, // Runloop supports multiple runtimes, defaulting to node\n status: devbox.status as SandboxStatus,\n createdAt: new Date(devbox.create_time_ms || Date.now()),\n timeout: devbox.launch_parameters.keep_alive_time_seconds || 300000,\n metadata: {\n runloopDevboxId: devbox.id,\n templateId: devbox.blueprint_id || devbox.snapshot_id,\n ...devbox.metadata,\n },\n };\n },\n\n getUrl: async (\n sandbox: any,\n options: { port: number }\n ): Promise<string> => {\n const devbox = sandbox;\n const client = sandbox.client;\n\n try {\n const tunnel = await client.api.devboxes.createTunnel(devbox.id, {\n port: options.port,\n });\n\n return tunnel.url;\n } catch (error) {\n throw new Error(\n `Failed to get Runloop URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n // Optional filesystem methods - using Runloop's file operations\n filesystem: {\n readFile: async (sandbox: any, path: string, runCommand: any): Promise<string> => {\n try {\n const result = await runCommand(sandbox, `cat \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`File not found or unreadable: ${result.stderr}`);\n }\n return result.stdout;\n } catch (error) {\n throw new Error(\n `Failed to read file ${path}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n writeFile: async (\n sandbox: any,\n path: string,\n content: string,\n runCommand: any\n ): Promise<void> => {\n try {\n // Use command-based approach for file writing since API writeFileContents may have issues\n const encoded = Buffer.from(content).toString('base64');\n const result = await runCommand(sandbox, `sh -c 'echo \"${encoded}\" | base64 -d > \"${path}\"'`);\n\n if (result.exitCode !== 0) {\n throw new Error(`Command failed: ${result.stderr}`);\n }\n } catch (error) {\n throw new Error(\n `Failed to write file ${path}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n mkdir: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<void> => {\n const result = await runCommand(sandbox, `mkdir -p \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(\n `Failed to create directory ${path}: ${result.stderr}`\n );\n }\n },\n\n readdir: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<FileEntry[]> => {\n const result = await runCommand(sandbox, `ls -la \"${path}\"`);\n\n if (result.exitCode !== 0) {\n throw new Error(\n `Failed to list directory ${path}: ${result.stderr}`\n );\n }\n\n const lines = (result.stdout || \"\")\n .split(\"\\n\")\n .filter((line: string) => line.trim() && !line.startsWith(\"total\"));\n\n return lines.map((line: string) => {\n const parts = line.trim().split(/\\s+/);\n const name = parts[parts.length - 1];\n const isDirectory = line.startsWith(\"d\");\n\n return {\n name,\n type: isDirectory ? 'directory' as const : 'file' as const,\n size: parseInt(parts[4]) || 0,\n modified: new Date(),\n };\n });\n },\n\n exists: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<boolean> => {\n const result = await runCommand(sandbox, `test -e \"${path}\"`);\n return result.exitCode === 0;\n },\n\n remove: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<void> => {\n const result = await runCommand(sandbox, `rm -rf \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to remove ${path}: ${result.stderr}`);\n }\n },\n },\n\n // Provider-specific typed getInstance method\n getInstance: (sandbox): Runloop.DevboxView => {\n return sandbox;\n },\n },\n\n // Template management methods using the new factory pattern\n template: {\n create: async (\n config: RunloopConfig,\n options: CreateBlueprintTemplateOptions | Runloop.BlueprintCreateParams\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for blueprint template creation\"\n );\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const blueprint = await client.api.blueprints.create(options);\n return blueprint;\n } catch (error) {\n throw new Error(\n `Failed to create blueprint template: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n list: async (config: RunloopConfig, options?: { limit?: number }) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for listing blueprint templates\"\n );\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const listParams: any = {};\n if (options?.limit) {\n listParams.limit = options.limit;\n }\n\n const response = await client.api.blueprints.list(listParams);\n return response.blueprints || [];\n } catch (error) {\n throw new Error(\n `Failed to list blueprint templates: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n delete: async (config: RunloopConfig, blueprintId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for blueprint template deletion\"\n );\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n await client.api.blueprints.delete(blueprintId);\n } catch (error) {\n throw new Error(\n `Failed to delete blueprint template ${blueprintId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n },\n\n // Snapshot management methods using the new factory pattern\n snapshot: {\n create: async (\n config: RunloopConfig,\n sandboxId: string,\n options?: CreateSnapshotOptions\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for snapshot creation\");\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const snapshotParams: any = {};\n if (options?.name) {\n snapshotParams.name = options.name;\n }\n if (options?.metadata) {\n snapshotParams.metadata = options.metadata;\n }\n\n const snapshot = await client.api.devboxes.snapshotDisk(\n sandboxId,\n snapshotParams\n );\n return snapshot;\n } catch (error) {\n throw new Error(\n `Failed to create snapshot for sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n list: async (\n config: RunloopConfig,\n options?: ListSnapshotsOptions\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for listing snapshots\");\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const listParams: any = {};\n if (options?.limit) {\n listParams.limit = options.limit;\n }\n\n const response = await client.api.devboxes.listDiskSnapshots(listParams);\n return response.snapshots || [];\n } catch (error) {\n throw new Error(\n `Failed to list snapshots: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n delete: async (config: RunloopConfig, snapshotId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for snapshot deletion\");\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n await client.api.devboxes.deleteDiskSnapshot(snapshotId);\n } catch (error) {\n throw new Error(\n `Failed to delete snapshot ${snapshotId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n },\n },\n});"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,wBAAyC;AACzC,sBAA+C;AAgFxC,IAAM,cAAU,gCAKrB;AAAA,EACA,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA;AAAA,MAEP,QAAQ,OAAO,QAAuB,YAAmC;AAEvE,cAAM,SACJ,OAAO,UACN,OAAO,YAAY,eAAe,QAAQ,KAAK,mBAChD;AAEF,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAEA,cAAM,UAAU,OAAO;AAEvB,YAAI;AACF,gBAAM,SAAS,IAAI,6BAAW;AAAA,YAC5B,aAAa;AAAA,UACf,CAAC;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,UAAU;AAAA,YACV,SAAS;AAAA,YACT,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;AAAA,YACA,uBAAuB;AAAA,YACvB,GAAG;AAAA;AAAA,UACL;AAGA,cAAI,YAAY;AAEd,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,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AI,6BAAW;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: _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 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,YAAY;AAAA,YACZ,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;AAEA,cAAI,YAAY;AACd,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,SAAS;AAAA,YACpC;AAAA,UAC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A,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,7 +18,6 @@ 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,
|
|
@@ -29,8 +27,6 @@ var runloop = defineProvider({
|
|
|
29
27
|
sandboxId: optSandboxId,
|
|
30
28
|
namespace: _namespace,
|
|
31
29
|
directory: _directory,
|
|
32
|
-
overlays: _overlays,
|
|
33
|
-
servers: _servers,
|
|
34
30
|
...providerOptions
|
|
35
31
|
} = options || {};
|
|
36
32
|
const effectiveTimeout = optTimeout ?? timeout;
|
|
@@ -43,7 +39,6 @@ var runloop = defineProvider({
|
|
|
43
39
|
metadata,
|
|
44
40
|
environment_variables: envs,
|
|
45
41
|
...providerOptions
|
|
46
|
-
// Spread provider-specific options (e.g., blueprint params, resource_size)
|
|
47
42
|
};
|
|
48
43
|
if (templateId) {
|
|
49
44
|
if (templateId.startsWith("bpt_")) {
|
|
@@ -57,9 +52,7 @@ var runloop = defineProvider({
|
|
|
57
52
|
);
|
|
58
53
|
const runloopSandbox = {
|
|
59
54
|
...dbx,
|
|
60
|
-
// Spread all DevboxView properties
|
|
61
55
|
client
|
|
62
|
-
// Add client for method access
|
|
63
56
|
};
|
|
64
57
|
return {
|
|
65
58
|
sandbox: runloopSandbox,
|
|
@@ -74,93 +67,36 @@ var runloop = defineProvider({
|
|
|
74
67
|
getById: async (config, sandboxId) => {
|
|
75
68
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
76
69
|
try {
|
|
77
|
-
const client = new RunloopSDK({
|
|
78
|
-
bearerToken: apiKey
|
|
79
|
-
});
|
|
70
|
+
const client = new RunloopSDK({ bearerToken: apiKey });
|
|
80
71
|
const devbox = await client.api.devboxes.retrieve(sandboxId);
|
|
81
72
|
return {
|
|
82
|
-
sandbox: devbox,
|
|
73
|
+
sandbox: { ...devbox, client },
|
|
83
74
|
sandboxId
|
|
84
75
|
};
|
|
85
|
-
} catch
|
|
76
|
+
} catch {
|
|
86
77
|
return null;
|
|
87
78
|
}
|
|
88
79
|
},
|
|
89
80
|
list: async (config) => {
|
|
90
81
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
91
82
|
try {
|
|
92
|
-
const client = new RunloopSDK({
|
|
93
|
-
bearerToken: apiKey
|
|
94
|
-
});
|
|
83
|
+
const client = new RunloopSDK({ bearerToken: apiKey });
|
|
95
84
|
const response = await client.api.devboxes.list();
|
|
96
85
|
const devboxes = response.devboxes || [];
|
|
97
86
|
return devboxes.map((devbox) => ({
|
|
98
|
-
sandbox: devbox,
|
|
87
|
+
sandbox: { ...devbox, client },
|
|
99
88
|
sandboxId: devbox.id
|
|
100
89
|
}));
|
|
101
|
-
} catch
|
|
90
|
+
} catch {
|
|
102
91
|
return [];
|
|
103
92
|
}
|
|
104
93
|
},
|
|
105
94
|
destroy: async (config, sandboxId) => {
|
|
106
95
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
107
96
|
try {
|
|
108
|
-
const client = new RunloopSDK({
|
|
109
|
-
bearerToken: apiKey
|
|
110
|
-
});
|
|
97
|
+
const client = new RunloopSDK({ bearerToken: apiKey });
|
|
111
98
|
await client.api.devboxes.shutdown(sandboxId);
|
|
112
|
-
} catch
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
// Instance operations (map to individual Sandbox methods)
|
|
116
|
-
runCode: async (sandbox, code, runtime) => {
|
|
117
|
-
const startTime = Date.now();
|
|
118
|
-
const devbox = sandbox;
|
|
119
|
-
const client = sandbox.client;
|
|
120
|
-
const effectiveRuntime = runtime || // Strong Python indicators
|
|
121
|
-
(code.includes("print(") || code.includes("import ") || code.includes("def ") || code.includes("sys.") || code.includes("json.") || code.includes("__") || code.includes('f"') || code.includes("f'") || code.includes("raise ") ? "python" : "node");
|
|
122
|
-
try {
|
|
123
|
-
const encoded = Buffer.from(code).toString("base64");
|
|
124
|
-
let command;
|
|
125
|
-
if (effectiveRuntime === "python") {
|
|
126
|
-
command = `echo "${encoded}" | base64 -d | python3`;
|
|
127
|
-
} else {
|
|
128
|
-
command = `echo "${encoded}" | base64 -d | node`;
|
|
129
|
-
}
|
|
130
|
-
const executionResult = await client.api.devboxes.executeAndAwaitCompletion(devbox.id, {
|
|
131
|
-
command
|
|
132
|
-
});
|
|
133
|
-
if (executionResult.exit_status !== 0 && executionResult.stderr) {
|
|
134
|
-
if (executionResult.stderr.includes("SyntaxError") || executionResult.stderr.includes("invalid syntax") || executionResult.stderr.includes("Unexpected token") || executionResult.stderr.includes("Unexpected identifier")) {
|
|
135
|
-
throw new Error(`Syntax error: ${executionResult.stderr.trim()}`);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return {
|
|
139
|
-
output: (executionResult.stdout || "") + (executionResult.stderr || ""),
|
|
140
|
-
exitCode: executionResult.exit_status || 0,
|
|
141
|
-
language: effectiveRuntime
|
|
142
|
-
};
|
|
143
|
-
} catch (error) {
|
|
144
|
-
if (error instanceof Error && error.message === "exit status 1") {
|
|
145
|
-
const actualStderr = error?.result?.stderr || "";
|
|
146
|
-
const isSyntaxError = actualStderr.includes("SyntaxError");
|
|
147
|
-
if (isSyntaxError) {
|
|
148
|
-
const syntaxErrorLine = actualStderr.split("\n").find((line) => line.includes("SyntaxError")) || "SyntaxError: Invalid syntax in code";
|
|
149
|
-
throw new Error(`Syntax error: ${syntaxErrorLine}`);
|
|
150
|
-
} else {
|
|
151
|
-
return {
|
|
152
|
-
output: actualStderr || "Error: Runtime error occurred during execution",
|
|
153
|
-
exitCode: 1,
|
|
154
|
-
language: effectiveRuntime
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
if (error instanceof Error && error.message.includes("Syntax error")) {
|
|
159
|
-
throw error;
|
|
160
|
-
}
|
|
161
|
-
throw new Error(
|
|
162
|
-
`Runloop execution failed: ${error instanceof Error ? error.message : String(error)}`
|
|
163
|
-
);
|
|
99
|
+
} catch {
|
|
164
100
|
}
|
|
165
101
|
},
|
|
166
102
|
runCommand: async (sandbox, command, options) => {
|
|
@@ -170,7 +106,7 @@ var runloop = defineProvider({
|
|
|
170
106
|
try {
|
|
171
107
|
let fullCommand = command;
|
|
172
108
|
if (options?.env && Object.keys(options.env).length > 0) {
|
|
173
|
-
const envPrefix = Object.entries(options.env).map(([k, v]) => `${k}="${escapeShellArg(v)}"`).join(" ");
|
|
109
|
+
const envPrefix = Object.entries(options.env).map(([k, v]) => `${k}="${escapeShellArg(String(v))}"`).join(" ");
|
|
174
110
|
fullCommand = `${envPrefix} ${fullCommand}`;
|
|
175
111
|
}
|
|
176
112
|
if (options?.cwd) {
|
|
@@ -199,17 +135,18 @@ var runloop = defineProvider({
|
|
|
199
135
|
},
|
|
200
136
|
getInfo: async (sandbox) => {
|
|
201
137
|
const devbox = sandbox;
|
|
138
|
+
const keepAliveSecs = devbox.launch_parameters.keep_alive_time_seconds;
|
|
202
139
|
return {
|
|
203
140
|
id: devbox.id || "runloop-unknown",
|
|
204
141
|
provider: "runloop",
|
|
205
|
-
runtime: "node",
|
|
206
|
-
// Runloop supports multiple runtimes, defaulting to node
|
|
207
142
|
status: devbox.status,
|
|
208
143
|
createdAt: new Date(devbox.create_time_ms || Date.now()),
|
|
209
|
-
|
|
144
|
+
// keep_alive_time_seconds is in seconds; SandboxInfo.timeout is in milliseconds
|
|
145
|
+
timeout: keepAliveSecs ? keepAliveSecs * 1e3 : 3e5,
|
|
210
146
|
metadata: {
|
|
211
147
|
runloopDevboxId: devbox.id,
|
|
212
148
|
templateId: devbox.blueprint_id || devbox.snapshot_id,
|
|
149
|
+
runtime: "node",
|
|
213
150
|
...devbox.metadata
|
|
214
151
|
}
|
|
215
152
|
};
|
|
@@ -218,59 +155,32 @@ var runloop = defineProvider({
|
|
|
218
155
|
const devbox = sandbox;
|
|
219
156
|
const client = sandbox.client;
|
|
220
157
|
try {
|
|
221
|
-
const tunnel = await client.api.devboxes.
|
|
222
|
-
|
|
223
|
-
});
|
|
224
|
-
return tunnel.url;
|
|
158
|
+
const tunnel = await client.api.devboxes.enableTunnel(devbox.id);
|
|
159
|
+
return `https://${options.port}-${tunnel.tunnel_key}.tunnel.runloop.ai`;
|
|
225
160
|
} catch (error) {
|
|
226
161
|
throw new Error(
|
|
227
162
|
`Failed to get Runloop URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)}`
|
|
228
163
|
);
|
|
229
164
|
}
|
|
230
165
|
},
|
|
231
|
-
// Optional filesystem methods - using Runloop's file operations
|
|
232
166
|
filesystem: {
|
|
233
167
|
readFile: async (sandbox, path, runCommand) => {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
throw new Error(`File not found or unreadable: ${result.stderr}`);
|
|
238
|
-
}
|
|
239
|
-
return result.stdout;
|
|
240
|
-
} catch (error) {
|
|
241
|
-
throw new Error(
|
|
242
|
-
`Failed to read file ${path}: ${error instanceof Error ? error.message : String(error)}`
|
|
243
|
-
);
|
|
244
|
-
}
|
|
168
|
+
const result = await runCommand(sandbox, `cat "${path}"`);
|
|
169
|
+
if (result.exitCode !== 0) throw new Error(`File not found or unreadable: ${result.stderr}`);
|
|
170
|
+
return result.stdout;
|
|
245
171
|
},
|
|
246
172
|
writeFile: async (sandbox, path, content, runCommand) => {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
if (result.exitCode !== 0) {
|
|
251
|
-
throw new Error(`Command failed: ${result.stderr}`);
|
|
252
|
-
}
|
|
253
|
-
} catch (error) {
|
|
254
|
-
throw new Error(
|
|
255
|
-
`Failed to write file ${path}: ${error instanceof Error ? error.message : String(error)}`
|
|
256
|
-
);
|
|
257
|
-
}
|
|
173
|
+
const encoded = Buffer.from(content).toString("base64");
|
|
174
|
+
const result = await runCommand(sandbox, `sh -c 'echo "${encoded}" | base64 -d > "${path}"'`);
|
|
175
|
+
if (result.exitCode !== 0) throw new Error(`Failed to write file ${path}: ${result.stderr}`);
|
|
258
176
|
},
|
|
259
177
|
mkdir: async (sandbox, path, runCommand) => {
|
|
260
178
|
const result = await runCommand(sandbox, `mkdir -p "${path}"`);
|
|
261
|
-
if (result.exitCode !== 0) {
|
|
262
|
-
throw new Error(
|
|
263
|
-
`Failed to create directory ${path}: ${result.stderr}`
|
|
264
|
-
);
|
|
265
|
-
}
|
|
179
|
+
if (result.exitCode !== 0) throw new Error(`Failed to create directory ${path}: ${result.stderr}`);
|
|
266
180
|
},
|
|
267
181
|
readdir: async (sandbox, path, runCommand) => {
|
|
268
182
|
const result = await runCommand(sandbox, `ls -la "${path}"`);
|
|
269
|
-
if (result.exitCode !== 0) {
|
|
270
|
-
throw new Error(
|
|
271
|
-
`Failed to list directory ${path}: ${result.stderr}`
|
|
272
|
-
);
|
|
273
|
-
}
|
|
183
|
+
if (result.exitCode !== 0) throw new Error(`Failed to list directory ${path}: ${result.stderr}`);
|
|
274
184
|
const lines = (result.stdout || "").split("\n").filter((line) => line.trim() && !line.startsWith("total"));
|
|
275
185
|
return lines.map((line) => {
|
|
276
186
|
const parts = line.trim().split(/\s+/);
|
|
@@ -290,144 +200,58 @@ var runloop = defineProvider({
|
|
|
290
200
|
},
|
|
291
201
|
remove: async (sandbox, path, runCommand) => {
|
|
292
202
|
const result = await runCommand(sandbox, `rm -rf "${path}"`);
|
|
293
|
-
if (result.exitCode !== 0) {
|
|
294
|
-
throw new Error(`Failed to remove ${path}: ${result.stderr}`);
|
|
295
|
-
}
|
|
203
|
+
if (result.exitCode !== 0) throw new Error(`Failed to remove ${path}: ${result.stderr}`);
|
|
296
204
|
}
|
|
297
205
|
},
|
|
298
|
-
|
|
299
|
-
getInstance: (sandbox) => {
|
|
300
|
-
return sandbox;
|
|
301
|
-
}
|
|
206
|
+
getInstance: (sandbox) => sandbox
|
|
302
207
|
},
|
|
303
|
-
// Template management methods using the new factory pattern
|
|
304
208
|
template: {
|
|
305
209
|
create: async (config, options) => {
|
|
306
210
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
307
|
-
if (!apiKey)
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
);
|
|
311
|
-
}
|
|
312
|
-
try {
|
|
313
|
-
const client = new RunloopSDK({
|
|
314
|
-
bearerToken: apiKey
|
|
315
|
-
});
|
|
316
|
-
const blueprint = await client.api.blueprints.create(options);
|
|
317
|
-
return blueprint;
|
|
318
|
-
} catch (error) {
|
|
319
|
-
throw new Error(
|
|
320
|
-
`Failed to create blueprint template: ${error instanceof Error ? error.message : String(error)}`
|
|
321
|
-
);
|
|
322
|
-
}
|
|
211
|
+
if (!apiKey) throw new Error("Missing Runloop API key for blueprint template creation");
|
|
212
|
+
const client = new RunloopSDK({ bearerToken: apiKey });
|
|
213
|
+
return client.api.blueprints.create(options);
|
|
323
214
|
},
|
|
324
215
|
list: async (config, options) => {
|
|
325
216
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
326
|
-
if (!apiKey)
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
const client = new RunloopSDK({
|
|
333
|
-
bearerToken: apiKey
|
|
334
|
-
});
|
|
335
|
-
const listParams = {};
|
|
336
|
-
if (options?.limit) {
|
|
337
|
-
listParams.limit = options.limit;
|
|
338
|
-
}
|
|
339
|
-
const response = await client.api.blueprints.list(listParams);
|
|
340
|
-
return response.blueprints || [];
|
|
341
|
-
} catch (error) {
|
|
342
|
-
throw new Error(
|
|
343
|
-
`Failed to list blueprint templates: ${error instanceof Error ? error.message : String(error)}`
|
|
344
|
-
);
|
|
345
|
-
}
|
|
217
|
+
if (!apiKey) throw new Error("Missing Runloop API key for listing blueprint templates");
|
|
218
|
+
const client = new RunloopSDK({ bearerToken: apiKey });
|
|
219
|
+
const listParams = {};
|
|
220
|
+
if (options?.limit) listParams.limit = options.limit;
|
|
221
|
+
const response = await client.api.blueprints.list(listParams);
|
|
222
|
+
return response.blueprints || [];
|
|
346
223
|
},
|
|
347
224
|
delete: async (config, blueprintId) => {
|
|
348
225
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
349
|
-
if (!apiKey)
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
);
|
|
353
|
-
}
|
|
354
|
-
try {
|
|
355
|
-
const client = new RunloopSDK({
|
|
356
|
-
bearerToken: apiKey
|
|
357
|
-
});
|
|
358
|
-
await client.api.blueprints.delete(blueprintId);
|
|
359
|
-
} catch (error) {
|
|
360
|
-
throw new Error(
|
|
361
|
-
`Failed to delete blueprint template ${blueprintId}: ${error instanceof Error ? error.message : String(error)}`
|
|
362
|
-
);
|
|
363
|
-
}
|
|
226
|
+
if (!apiKey) throw new Error("Missing Runloop API key for blueprint template deletion");
|
|
227
|
+
const client = new RunloopSDK({ bearerToken: apiKey });
|
|
228
|
+
await client.api.blueprints.delete(blueprintId);
|
|
364
229
|
}
|
|
365
230
|
},
|
|
366
|
-
// Snapshot management methods using the new factory pattern
|
|
367
231
|
snapshot: {
|
|
368
232
|
create: async (config, sandboxId, options) => {
|
|
369
233
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
370
|
-
if (!apiKey)
|
|
371
|
-
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
});
|
|
377
|
-
const snapshotParams = {};
|
|
378
|
-
if (options?.name) {
|
|
379
|
-
snapshotParams.name = options.name;
|
|
380
|
-
}
|
|
381
|
-
if (options?.metadata) {
|
|
382
|
-
snapshotParams.metadata = options.metadata;
|
|
383
|
-
}
|
|
384
|
-
const snapshot = await client.api.devboxes.snapshotDisk(
|
|
385
|
-
sandboxId,
|
|
386
|
-
snapshotParams
|
|
387
|
-
);
|
|
388
|
-
return snapshot;
|
|
389
|
-
} catch (error) {
|
|
390
|
-
throw new Error(
|
|
391
|
-
`Failed to create snapshot for sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)}`
|
|
392
|
-
);
|
|
393
|
-
}
|
|
234
|
+
if (!apiKey) throw new Error("Missing Runloop API key for snapshot creation");
|
|
235
|
+
const client = new RunloopSDK({ bearerToken: apiKey });
|
|
236
|
+
const snapshotParams = {};
|
|
237
|
+
if (options?.name) snapshotParams.name = options.name;
|
|
238
|
+
if (options?.metadata) snapshotParams.metadata = options.metadata;
|
|
239
|
+
return client.api.devboxes.snapshotDisk(sandboxId, snapshotParams);
|
|
394
240
|
},
|
|
395
241
|
list: async (config, options) => {
|
|
396
242
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
397
|
-
if (!apiKey)
|
|
398
|
-
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
});
|
|
404
|
-
const listParams = {};
|
|
405
|
-
if (options?.limit) {
|
|
406
|
-
listParams.limit = options.limit;
|
|
407
|
-
}
|
|
408
|
-
const response = await client.api.devboxes.listDiskSnapshots(listParams);
|
|
409
|
-
return response.snapshots || [];
|
|
410
|
-
} catch (error) {
|
|
411
|
-
throw new Error(
|
|
412
|
-
`Failed to list snapshots: ${error instanceof Error ? error.message : String(error)}`
|
|
413
|
-
);
|
|
414
|
-
}
|
|
243
|
+
if (!apiKey) throw new Error("Missing Runloop API key for listing snapshots");
|
|
244
|
+
const client = new RunloopSDK({ bearerToken: apiKey });
|
|
245
|
+
const listParams = {};
|
|
246
|
+
if (options?.limit) listParams.limit = options.limit;
|
|
247
|
+
const response = await client.api.devboxes.listDiskSnapshots(listParams);
|
|
248
|
+
return response.snapshots || [];
|
|
415
249
|
},
|
|
416
250
|
delete: async (config, snapshotId) => {
|
|
417
251
|
const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY;
|
|
418
|
-
if (!apiKey)
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
try {
|
|
422
|
-
const client = new RunloopSDK({
|
|
423
|
-
bearerToken: apiKey
|
|
424
|
-
});
|
|
425
|
-
await client.api.devboxes.deleteDiskSnapshot(snapshotId);
|
|
426
|
-
} catch (error) {
|
|
427
|
-
throw new Error(
|
|
428
|
-
`Failed to delete snapshot ${snapshotId}: ${error instanceof Error ? error.message : String(error)}`
|
|
429
|
-
);
|
|
430
|
-
}
|
|
252
|
+
if (!apiKey) throw new Error("Missing Runloop API key for snapshot deletion");
|
|
253
|
+
const client = new RunloopSDK({ bearerToken: apiKey });
|
|
254
|
+
await client.api.devboxes.deleteDiskSnapshot(snapshotId);
|
|
431
255
|
}
|
|
432
256
|
}
|
|
433
257
|
}
|
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 CodeResult,\n CommandResult,\n SandboxInfo,\n CreateSnapshotOptions,\n ListSnapshotsOptions,\n RunCommandOptions,\n} from \"@computesdk/provider\";\nimport type {\n CreateSandboxOptions,\n FileEntry,\n Runtime,\n SandboxStatus,\n Sandbox,\n} from \"computesdk\";\n\n// Define Runloop-specific types\ntype RunloopSnapshot = Runloop.DevboxSnapshotView;\ntype RunloopTemplate = Runloop.BlueprintView;\n\n/**\n * Runloop-specific configuration options\n */\nexport interface RunloopConfig {\n /** Runloop API key - if not provided, will fallback to RUNLOOP_API_KEY environment variable */\n apiKey?: string;\n /** Execution timeout in milliseconds */\n timeout?: number;\n}\n\n/**\n * Runloop-specific blueprint creation options\n */\nexport interface CreateBlueprintTemplateOptions {\n /** Name of the blueprint template */\n name: string;\n /** Custom Dockerfile content */\n dockerfile?: string;\n /** System setup commands to run during blueprint creation */\n systemSetupCommands?: string[];\n /** Launch commands to run when starting a devbox from this blueprint */\n launchCommands?: string[];\n /** File mounts as key-value pairs (path -> content) */\n fileMounts?: Record<string, string>;\n /** Code repository mounts */\n codeMounts?: Array<{\n repoName: string;\n repoOwner: string;\n token?: string;\n installCommand?: string;\n }>;\n /** Resource size for devboxes created from this blueprint */\n resourceSize?:\n | \"X_SMALL\"\n | \"SMALL\"\n | \"MEDIUM\"\n | \"LARGE\"\n | \"X_LARGE\"\n | \"XX_LARGE\"\n | \"CUSTOM_SIZE\";\n /** CPU architecture */\n architecture?: \"x86_64\" | \"arm64\";\n /** Custom CPU cores (requires CUSTOM_SIZE) */\n customCpuCores?: number;\n /** Custom memory in GB (requires CUSTOM_SIZE) */\n customMemoryGb?: number;\n /** Custom disk size (requires CUSTOM_SIZE) */\n customDiskSize?: number;\n /** Available ports for the devbox */\n availablePorts?: number[];\n /** Action to take when devbox is idle */\n afterIdle?: { action: string; timeSeconds: number };\n /** Keep alive time in seconds */\n keepAliveTimeSeconds?: number;\n}\n\n/**\n * Create a Runloop provider instance using the factory pattern\n */\nexport const runloop = defineProvider<\n Runloop.DevboxView, // TSandbox\n RunloopConfig, // TConfig\n RunloopTemplate, // TTemplate \n RunloopSnapshot // TSnapshot\n>({\n name: \"runloop\",\n methods: {\n sandbox: {\n // Collection operations (map to compute.sandbox.*)\n create: async (config: RunloopConfig, options?: CreateSandboxOptions) => {\n // Validate API key\n const apiKey =\n config.apiKey ||\n (typeof process !== \"undefined\" && process.env?.RUNLOOP_API_KEY) ||\n \"\";\n\n if (!apiKey) {\n throw new Error(\n `Missing Runloop API key. Provide 'apiKey' in config or set RUNLOOP_API_KEY environment variable. Get your API key from https://runloop.ai/`\n );\n }\n\n const timeout = config.timeout;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n // 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 overlays: _overlays,\n servers: _servers,\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 = {\n ...dbx, // Spread all DevboxView properties\n client: client // Add client for method access\n };\n\n return {\n sandbox: runloopSandbox,\n sandboxId: dbx.id,\n };\n } catch (error) {\n throw new Error(\n `Failed to create Runloop devbox: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n getById: async (config: RunloopConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const devbox = await client.api.devboxes.retrieve(sandboxId);\n\n return {\n sandbox: devbox,\n sandboxId,\n };\n } catch (error) {\n // Devbox doesn't exist or can't be accessed\n return null;\n }\n },\n\n list: async (config: RunloopConfig) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const response = await client.api.devboxes.list();\n const devboxes = response.devboxes || [];\n\n return devboxes.map((devbox) => ({\n sandbox: devbox,\n sandboxId: devbox.id,\n }));\n } catch (error) {\n // Return empty array if listing fails\n return [];\n }\n },\n\n destroy: async (config: RunloopConfig, sandboxId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n await client.api.devboxes.shutdown(sandboxId);\n } catch (error) {\n // Devbox might already be destroyed or doesn't exist\n // This is acceptable for destroy operations\n }\n },\n\n // Instance operations (map to individual Sandbox methods)\n runCode: async (sandbox: any, code: string, runtime?: Runtime): Promise<CodeResult> => {\n const startTime = Date.now();\n const devbox = sandbox;\n const client = sandbox.client;\n\n // Auto-detect runtime if not specified\n const effectiveRuntime: Runtime = runtime || (\n // Strong Python indicators\n code.includes('print(') ||\n code.includes('import ') ||\n code.includes('def ') ||\n code.includes('sys.') ||\n code.includes('json.') ||\n code.includes('__') ||\n code.includes('f\"') ||\n code.includes(\"f'\") ||\n code.includes('raise ')\n ? 'python'\n // Default to Node.js for all other cases (including ambiguous)\n : 'node'\n ) as Runtime;\n\n try {\n\n // Use base64 encoding for both runtimes for reliability and consistency\n const encoded = Buffer.from(code).toString('base64');\n\n let command;\n if (effectiveRuntime === 'python') {\n command = `echo \"${encoded}\" | base64 -d | python3`;\n } else {\n command = `echo \"${encoded}\" | base64 -d | node`;\n }\n\n // Execute code using Runloop's executeAsync\n const executionResult =\n await client.api.devboxes.executeAndAwaitCompletion(devbox.id, {\n command: command,\n });\n\n // Check for syntax errors and throw them (similar to Vercel behavior)\n if (executionResult.exit_status !== 0 && executionResult.stderr) {\n // Check for common syntax error patterns\n if (executionResult.stderr.includes('SyntaxError') ||\n executionResult.stderr.includes('invalid syntax') ||\n executionResult.stderr.includes('Unexpected token') ||\n executionResult.stderr.includes('Unexpected identifier')) {\n throw new Error(`Syntax error: ${executionResult.stderr.trim()}`);\n }\n }\n\n return {\n output: (executionResult.stdout || \"\") + (executionResult.stderr || \"\"),\n exitCode: executionResult.exit_status || 0,\n language: effectiveRuntime,\n };\n } catch (error) {\n // Handle Runloop execution errors\n if (error instanceof Error && error.message === 'exit status 1') {\n const actualStderr = (error as any)?.result?.stderr || '';\n const isSyntaxError = actualStderr.includes('SyntaxError');\n\n if (isSyntaxError) {\n // For syntax errors, throw\n const syntaxErrorLine = actualStderr.split('\\n').find((line: string) => line.includes('SyntaxError')) || 'SyntaxError: Invalid syntax in code';\n throw new Error(`Syntax error: ${syntaxErrorLine}`);\n } else {\n // For runtime errors, return a result instead of throwing\n return {\n output: actualStderr || 'Error: Runtime error occurred during execution',\n exitCode: 1,\n language: effectiveRuntime,\n };\n }\n }\n\n // Re-throw syntax errors\n if (error instanceof Error && error.message.includes('Syntax error')) {\n throw error;\n }\n throw new Error(\n `Runloop execution failed: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n },\n\n runCommand: async (\n sandbox: any,\n command: string,\n options?: RunCommandOptions\n ): Promise<CommandResult> => {\n const startTime = Date.now();\n const devbox = sandbox;\n const client = sandbox.client;\n\n try {\n // Build the full command with options\n let fullCommand = command;\n\n // Handle environment variables\n if (options?.env && Object.keys(options.env).length > 0) {\n const envPrefix = Object.entries(options.env)\n .map(([k, v]) => `${k}=\"${escapeShellArg(v)}\"`)\n .join(' ');\n fullCommand = `${envPrefix} ${fullCommand}`;\n }\n\n // Handle working directory\n if (options?.cwd) {\n fullCommand = `cd \"${escapeShellArg(options.cwd)}\" && ${fullCommand}`;\n }\n\n // Handle background execution\n if (options?.background) {\n fullCommand = `nohup ${fullCommand} > /dev/null 2>&1 &`;\n }\n\n const executionResult =\n await client.api.devboxes.executeAndAwaitCompletion(devbox.id, {\n command: fullCommand,\n });\n\n return {\n stdout: executionResult.stdout || \"\",\n stderr: executionResult.stderr || \"\",\n exitCode: executionResult.exit_status || 0,\n durationMs: Date.now() - startTime,\n };\n } catch (error) {\n // Re-throw syntax errors\n if (\n error instanceof Error &&\n error.message.includes(\"Syntax error\")\n ) {\n throw error;\n }\n throw new Error(\n `Runloop execution failed: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n getInfo: async (sandbox): Promise<SandboxInfo> => {\n const devbox = sandbox;\n\n return {\n id: devbox.id || \"runloop-unknown\",\n provider: \"runloop\",\n runtime: \"node\" as Runtime, // Runloop supports multiple runtimes, defaulting to node\n status: devbox.status as SandboxStatus,\n createdAt: new Date(devbox.create_time_ms || Date.now()),\n timeout: devbox.launch_parameters.keep_alive_time_seconds || 300000,\n metadata: {\n runloopDevboxId: devbox.id,\n templateId: devbox.blueprint_id || devbox.snapshot_id,\n ...devbox.metadata,\n },\n };\n },\n\n getUrl: async (\n sandbox: any,\n options: { port: number }\n ): Promise<string> => {\n const devbox = sandbox;\n const client = sandbox.client;\n\n try {\n const tunnel = await client.api.devboxes.createTunnel(devbox.id, {\n port: options.port,\n });\n\n return tunnel.url;\n } catch (error) {\n throw new Error(\n `Failed to get Runloop URL for port ${options.port}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n // Optional filesystem methods - using Runloop's file operations\n filesystem: {\n readFile: async (sandbox: any, path: string, runCommand: any): Promise<string> => {\n try {\n const result = await runCommand(sandbox, `cat \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`File not found or unreadable: ${result.stderr}`);\n }\n return result.stdout;\n } catch (error) {\n throw new Error(\n `Failed to read file ${path}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n writeFile: async (\n sandbox: any,\n path: string,\n content: string,\n runCommand: any\n ): Promise<void> => {\n try {\n // Use command-based approach for file writing since API writeFileContents may have issues\n const encoded = Buffer.from(content).toString('base64');\n const result = await runCommand(sandbox, `sh -c 'echo \"${encoded}\" | base64 -d > \"${path}\"'`);\n\n if (result.exitCode !== 0) {\n throw new Error(`Command failed: ${result.stderr}`);\n }\n } catch (error) {\n throw new Error(\n `Failed to write file ${path}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n mkdir: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<void> => {\n const result = await runCommand(sandbox, `mkdir -p \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(\n `Failed to create directory ${path}: ${result.stderr}`\n );\n }\n },\n\n readdir: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<FileEntry[]> => {\n const result = await runCommand(sandbox, `ls -la \"${path}\"`);\n\n if (result.exitCode !== 0) {\n throw new Error(\n `Failed to list directory ${path}: ${result.stderr}`\n );\n }\n\n const lines = (result.stdout || \"\")\n .split(\"\\n\")\n .filter((line: string) => line.trim() && !line.startsWith(\"total\"));\n\n return lines.map((line: string) => {\n const parts = line.trim().split(/\\s+/);\n const name = parts[parts.length - 1];\n const isDirectory = line.startsWith(\"d\");\n\n return {\n name,\n type: isDirectory ? 'directory' as const : 'file' as const,\n size: parseInt(parts[4]) || 0,\n modified: new Date(),\n };\n });\n },\n\n exists: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<boolean> => {\n const result = await runCommand(sandbox, `test -e \"${path}\"`);\n return result.exitCode === 0;\n },\n\n remove: async (\n sandbox: any,\n path: string,\n runCommand: any\n ): Promise<void> => {\n const result = await runCommand(sandbox, `rm -rf \"${path}\"`);\n if (result.exitCode !== 0) {\n throw new Error(`Failed to remove ${path}: ${result.stderr}`);\n }\n },\n },\n\n // Provider-specific typed getInstance method\n getInstance: (sandbox): Runloop.DevboxView => {\n return sandbox;\n },\n },\n\n // Template management methods using the new factory pattern\n template: {\n create: async (\n config: RunloopConfig,\n options: CreateBlueprintTemplateOptions | Runloop.BlueprintCreateParams\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for blueprint template creation\"\n );\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const blueprint = await client.api.blueprints.create(options);\n return blueprint;\n } catch (error) {\n throw new Error(\n `Failed to create blueprint template: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n list: async (config: RunloopConfig, options?: { limit?: number }) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for listing blueprint templates\"\n );\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const listParams: any = {};\n if (options?.limit) {\n listParams.limit = options.limit;\n }\n\n const response = await client.api.blueprints.list(listParams);\n return response.blueprints || [];\n } catch (error) {\n throw new Error(\n `Failed to list blueprint templates: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n delete: async (config: RunloopConfig, blueprintId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\n \"Missing Runloop API key for blueprint template deletion\"\n );\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n await client.api.blueprints.delete(blueprintId);\n } catch (error) {\n throw new Error(\n `Failed to delete blueprint template ${blueprintId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n },\n\n // Snapshot management methods using the new factory pattern\n snapshot: {\n create: async (\n config: RunloopConfig,\n sandboxId: string,\n options?: CreateSnapshotOptions\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for snapshot creation\");\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const snapshotParams: any = {};\n if (options?.name) {\n snapshotParams.name = options.name;\n }\n if (options?.metadata) {\n snapshotParams.metadata = options.metadata;\n }\n\n const snapshot = await client.api.devboxes.snapshotDisk(\n sandboxId,\n snapshotParams\n );\n return snapshot;\n } catch (error) {\n throw new Error(\n `Failed to create snapshot for sandbox ${sandboxId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n list: async (\n config: RunloopConfig,\n options?: ListSnapshotsOptions\n ) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for listing snapshots\");\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n const listParams: any = {};\n if (options?.limit) {\n listParams.limit = options.limit;\n }\n\n const response = await client.api.devboxes.listDiskSnapshots(listParams);\n return response.snapshots || [];\n } catch (error) {\n throw new Error(\n `Failed to list snapshots: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n\n delete: async (config: RunloopConfig, snapshotId: string) => {\n const apiKey = config.apiKey || process.env.RUNLOOP_API_KEY!;\n\n if (!apiKey) {\n throw new Error(\"Missing Runloop API key for snapshot deletion\");\n }\n\n try {\n const client = new RunloopSDK({\n bearerToken: apiKey,\n });\n\n await client.api.devboxes.deleteDiskSnapshot(snapshotId);\n } catch (error) {\n throw new Error(\n `Failed to delete snapshot ${snapshotId}: ${error instanceof Error ? error.message : String(error)\n }`\n );\n }\n },\n },\n },\n});"],"mappings":";AAOA,SAAS,kBAAgC;AACzC,SAAS,gBAAgB,sBAAsB;AAgFxC,IAAM,UAAU,eAKrB;AAAA,EACA,MAAM;AAAA,EACN,SAAS;AAAA,IACP,SAAS;AAAA;AAAA,MAEP,QAAQ,OAAO,QAAuB,YAAmC;AAEvE,cAAM,SACJ,OAAO,UACN,OAAO,YAAY,eAAe,QAAQ,KAAK,mBAChD;AAEF,YAAI,CAAC,QAAQ;AACX,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AAEA,cAAM,UAAU,OAAO;AAEvB,YAAI;AACF,gBAAM,SAAS,IAAI,WAAW;AAAA,YAC5B,aAAa;AAAA,UACf,CAAC;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,UAAU;AAAA,YACV,SAAS;AAAA,YACT,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;AAAA,YACA,uBAAuB;AAAA,YACvB,GAAG;AAAA;AAAA,UACL;AAGA,cAAI,YAAY;AAEd,gBAAI,WAAW,WAAW,MAAM,GAAG;AACjC,2BAAa,eAAe;AAAA,YAC9B,WAAW,WAAW,WAAW,MAAM,GAAG;AACxC,2BAAa,cAAc;AAAA,YAC7B;AAAA,UACF;AAEA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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: _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 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,YAAY;AAAA,YACZ,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;AAEA,cAAI,YAAY;AACd,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,SAAS;AAAA,YACpC;AAAA,UACF;AAEA,gBAAM,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,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.46",
|
|
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": "
|
|
23
|
-
"computesdk": "
|
|
22
|
+
"@computesdk/provider": "2.0.0",
|
|
23
|
+
"computesdk": "4.0.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",
|