@computesdk/promigence 0.0.0-stage → 1.0.1
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/LICENSE +21 -0
- package/README.md +153 -2
- package/dist/index.d.mts +42 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +486 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +465 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +65 -3
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { defineProvider, escapeShellArg, TIMEOUT_EXIT_CODE } from "@computesdk/provider";
|
|
3
|
+
import {
|
|
4
|
+
CommandExitError,
|
|
5
|
+
CommandTimeoutError,
|
|
6
|
+
NotFoundError,
|
|
7
|
+
PromigenceClient,
|
|
8
|
+
PromigenceError,
|
|
9
|
+
Sandbox
|
|
10
|
+
} from "@promigence/sdk";
|
|
11
|
+
import { PromigenceClient as PromigenceClient2, PromigenceError as PromigenceError2, Sandbox as Sandbox2 } from "@promigence/sdk";
|
|
12
|
+
var PROVIDER = "promigence";
|
|
13
|
+
var LIVE_STATES = ["queued", "ready", "running", "paused"];
|
|
14
|
+
var TEMPLATE_FIX = "Pass a snapshot id or alias to create() as templateId, list snapshots with snapshot.list(), and build snapshots with the Promigence CLI (promigence snapshot create).";
|
|
15
|
+
function fromEnv(name) {
|
|
16
|
+
const value = typeof process === "undefined" ? void 0 : process.env?.[name];
|
|
17
|
+
const trimmed = value?.trim();
|
|
18
|
+
return trimmed ? trimmed : void 0;
|
|
19
|
+
}
|
|
20
|
+
function show(value) {
|
|
21
|
+
return typeof value === "string" ? JSON.stringify(value) : String(value);
|
|
22
|
+
}
|
|
23
|
+
function promigenceError(message, detail = {}) {
|
|
24
|
+
const { name, ...rest } = detail;
|
|
25
|
+
const err = new Error(message);
|
|
26
|
+
if (name) err.name = name;
|
|
27
|
+
return Object.assign(err, rest);
|
|
28
|
+
}
|
|
29
|
+
function invalidArgument(message, fix) {
|
|
30
|
+
return promigenceError(`${message}. ${fix}`, { name: "InvalidArgumentError", code: "invalid_argument", fix });
|
|
31
|
+
}
|
|
32
|
+
function unsupported(message, fix) {
|
|
33
|
+
return promigenceError(`${message} ${fix}`, { name: "UnsupportedError", code: "unsupported", fix });
|
|
34
|
+
}
|
|
35
|
+
function rethrow(e, what) {
|
|
36
|
+
if (e instanceof PromigenceError) {
|
|
37
|
+
const detail = [e.message.replace(/\.+$/, ""), e.fix].filter((part) => part.length > 0).join(". ");
|
|
38
|
+
throw promigenceError(`Promigence ${what} failed (${e.code}): ${detail}`, {
|
|
39
|
+
name: e.name,
|
|
40
|
+
code: e.code,
|
|
41
|
+
fix: e.fix,
|
|
42
|
+
cause: e
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
function checkString(value, field) {
|
|
48
|
+
if (value !== void 0 && typeof value !== "string") {
|
|
49
|
+
throw invalidArgument(`Promigence: '${field}' must be a string, got ${typeof value}`, `Pass '${field}' as a string, or leave it unset.`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function checkSpendCap(value, from) {
|
|
53
|
+
if (typeof value === "number" && Number.isFinite(value) && value >= 0) return value;
|
|
54
|
+
throw invalidArgument(
|
|
55
|
+
`Promigence: ${from} must be a number of US dollars, 0 or more, got ${show(value)}`,
|
|
56
|
+
"Pass the most one sandbox may spend, or leave it unset to use your organization's default cap."
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
function snapshotLimit(value) {
|
|
60
|
+
if (value === void 0) return void 0;
|
|
61
|
+
if (typeof value === "number" && Number.isInteger(value) && value >= 0) return value;
|
|
62
|
+
throw invalidArgument(
|
|
63
|
+
`Promigence: snapshot.list() 'limit' must be a whole number, 0 or more, got ${show(value)}`,
|
|
64
|
+
"Pass the most snapshots to return, or leave it unset to list them all."
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
function checkConfig(config) {
|
|
68
|
+
checkString(config.apiKey, "apiKey");
|
|
69
|
+
checkString(config.apiUrl, "apiUrl");
|
|
70
|
+
checkString(config.snapshot, "snapshot");
|
|
71
|
+
checkString(config.tier, "tier");
|
|
72
|
+
checkString(config.optimizeFor, "optimizeFor");
|
|
73
|
+
const apiUrl = config.apiUrl?.trim() || fromEnv("PROMIGENCE_API_URL");
|
|
74
|
+
if (apiUrl !== void 0) {
|
|
75
|
+
const from = config.apiUrl?.trim() ? "'apiUrl'" : "PROMIGENCE_API_URL";
|
|
76
|
+
let protocol = "";
|
|
77
|
+
try {
|
|
78
|
+
protocol = new URL(apiUrl).protocol;
|
|
79
|
+
} catch {
|
|
80
|
+
}
|
|
81
|
+
if (protocol !== "https:" && protocol !== "http:") {
|
|
82
|
+
throw invalidArgument(
|
|
83
|
+
`Promigence: ${from} must be an http(s) URL, got ${show(apiUrl)}`,
|
|
84
|
+
"Leave it unset to use the default Promigence API."
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (config.spendCap !== void 0) checkSpendCap(config.spendCap, "'spendCap'");
|
|
89
|
+
const timeout = config.timeout;
|
|
90
|
+
if (timeout !== void 0 && !(typeof timeout === "number" && Number.isFinite(timeout) && timeout > 0)) {
|
|
91
|
+
throw invalidArgument(
|
|
92
|
+
`Promigence: 'timeout' must be a number of milliseconds above 0, got ${show(timeout)}`,
|
|
93
|
+
"Pass the sandbox lifetime in milliseconds, or leave it unset to use your account's default."
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function missingKey(client) {
|
|
98
|
+
const problem = client.credentialsProblem;
|
|
99
|
+
if (problem) {
|
|
100
|
+
return promigenceError(`Promigence did not use the API key it found: ${problem.message}. ${problem.fix}`, {
|
|
101
|
+
name: problem.name,
|
|
102
|
+
code: problem.code,
|
|
103
|
+
fix: problem.fix,
|
|
104
|
+
cause: problem
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
const fix = "Pass it: promigence({ apiKey: 'prom_api_...' })\nOr set PROMIGENCE_API_KEY in your environment.\nOr sign in once with the Promigence CLI (npm install -g promigence, then promigence login); the key it stores is used when neither is set.\nNew to Promigence? promigence signup creates an account: https://www.promigence.ai/docs/quickstart";
|
|
108
|
+
return promigenceError(`Missing Promigence API key.
|
|
109
|
+
|
|
110
|
+
${fix}`, { name: "AuthError", code: "auth", fix });
|
|
111
|
+
}
|
|
112
|
+
var clients = /* @__PURE__ */ new WeakMap();
|
|
113
|
+
function clientFor(config) {
|
|
114
|
+
const cached = clients.get(config);
|
|
115
|
+
if (cached) return cached;
|
|
116
|
+
checkConfig(config);
|
|
117
|
+
const apiKey = config.apiKey?.trim() || fromEnv("PROMIGENCE_API_KEY");
|
|
118
|
+
const apiUrl = config.apiUrl?.trim() || fromEnv("PROMIGENCE_API_URL");
|
|
119
|
+
const client = config.client ?? new PromigenceClient({
|
|
120
|
+
...apiKey === void 0 ? {} : { apiKey },
|
|
121
|
+
...apiUrl === void 0 ? {} : { apiUrl }
|
|
122
|
+
});
|
|
123
|
+
if (!client.authenticated) throw missingKey(client);
|
|
124
|
+
clients.set(config, client);
|
|
125
|
+
return client;
|
|
126
|
+
}
|
|
127
|
+
function spendCapFor(option, config) {
|
|
128
|
+
if (option !== void 0) return checkSpendCap(option, "the create() option 'spendCap'");
|
|
129
|
+
if (config.spendCap !== void 0) return config.spendCap;
|
|
130
|
+
const env = fromEnv("PROMIGENCE_SPEND_CAP");
|
|
131
|
+
return env === void 0 ? void 0 : checkSpendCap(Number(env), `PROMIGENCE_SPEND_CAP (${show(env)})`);
|
|
132
|
+
}
|
|
133
|
+
function labelsOf(metadata) {
|
|
134
|
+
if (!metadata || typeof metadata !== "object") return void 0;
|
|
135
|
+
const labels = {};
|
|
136
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
137
|
+
if (value === void 0 || value === null) continue;
|
|
138
|
+
labels[key] = typeof value === "string" ? value : JSON.stringify(value);
|
|
139
|
+
}
|
|
140
|
+
return Object.keys(labels).length > 0 ? labels : void 0;
|
|
141
|
+
}
|
|
142
|
+
function runOpts(options, config) {
|
|
143
|
+
const timeoutMs = options?.timeout ?? config.timeout;
|
|
144
|
+
return {
|
|
145
|
+
throwOnExit: false,
|
|
146
|
+
...options?.cwd === void 0 ? {} : { cwd: options.cwd },
|
|
147
|
+
...options?.env && Object.keys(options.env).length > 0 ? { envs: options.env } : {},
|
|
148
|
+
...timeoutMs === void 0 ? {} : { timeoutMs }
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function toComputeResult(r, startedAt) {
|
|
152
|
+
return { stdout: r.stdout, stderr: r.stderr, exitCode: r.exitCode, durationMs: Date.now() - startedAt };
|
|
153
|
+
}
|
|
154
|
+
function toFileEntry(e) {
|
|
155
|
+
return { name: e.name, type: e.type === "dir" ? "directory" : "file", size: e.size, modified: e.modifiedTime };
|
|
156
|
+
}
|
|
157
|
+
function createdAtOf(rec) {
|
|
158
|
+
if (typeof rec.created_at === "string") {
|
|
159
|
+
const date = new Date(rec.created_at);
|
|
160
|
+
if (!Number.isNaN(date.getTime())) return date;
|
|
161
|
+
}
|
|
162
|
+
return /* @__PURE__ */ new Date(0);
|
|
163
|
+
}
|
|
164
|
+
async function execOrThrow(inst, command, what) {
|
|
165
|
+
let r;
|
|
166
|
+
try {
|
|
167
|
+
r = await inst.sandbox.commands.run(command, { throwOnExit: false });
|
|
168
|
+
} catch (e) {
|
|
169
|
+
rethrow(e, what);
|
|
170
|
+
}
|
|
171
|
+
if (r.exitCode !== 0) {
|
|
172
|
+
throw promigenceError(`Promigence ${what} failed (exit ${r.exitCode}): ${r.stderr.trim()}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function toSnapshotInfo(s) {
|
|
176
|
+
return {
|
|
177
|
+
id: s.snapshot_id,
|
|
178
|
+
provider: PROVIDER,
|
|
179
|
+
createdAt: typeof s.created_at === "string" ? new Date(s.created_at) : /* @__PURE__ */ new Date(0),
|
|
180
|
+
metadata: {
|
|
181
|
+
...s.alias ? { alias: s.alias } : {},
|
|
182
|
+
...s.repo ? { repo: s.repo } : {},
|
|
183
|
+
...s.commit ? { commit: s.commit } : {},
|
|
184
|
+
...s.tier ? { tier: s.tier } : {},
|
|
185
|
+
...typeof s.verified === "boolean" ? { verified: s.verified } : {}
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
var promigence = defineProvider({
|
|
190
|
+
name: PROVIDER,
|
|
191
|
+
methods: {
|
|
192
|
+
instances: {
|
|
193
|
+
create: async (config, options) => {
|
|
194
|
+
const client = clientFor(config);
|
|
195
|
+
const o = options ?? {};
|
|
196
|
+
const snapshot = o.templateId ?? o.snapshotId;
|
|
197
|
+
if (o.image !== void 0 && snapshot !== void 0) {
|
|
198
|
+
throw invalidArgument(
|
|
199
|
+
"Promigence: create() takes 'image' or a snapshot ('templateId' / 'snapshotId'), not both",
|
|
200
|
+
"Pass one of them."
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
const timeoutMs = o.timeout ?? config.timeout;
|
|
204
|
+
const spendCap = spendCapFor(o.spendCap, config);
|
|
205
|
+
const tier = o.tier ?? config.tier;
|
|
206
|
+
const optimizeFor = o.optimizeFor ?? config.optimizeFor;
|
|
207
|
+
const labels = labelsOf(o.metadata);
|
|
208
|
+
const opts = {
|
|
209
|
+
client,
|
|
210
|
+
...timeoutMs === void 0 ? {} : { timeoutMs },
|
|
211
|
+
...spendCap === void 0 ? {} : { spendCap },
|
|
212
|
+
...o.envs === void 0 ? {} : { envs: o.envs },
|
|
213
|
+
...labels === void 0 ? {} : { metadata: labels },
|
|
214
|
+
...o.allowInternetAccess === void 0 ? {} : { allowInternetAccess: o.allowInternetAccess },
|
|
215
|
+
...Array.isArray(o.allowHosts) && o.allowHosts.length > 0 ? { allowHosts: o.allowHosts } : {},
|
|
216
|
+
...optimizeFor === void 0 ? {} : { optimizeFor }
|
|
217
|
+
};
|
|
218
|
+
if (o.image !== void 0) {
|
|
219
|
+
opts.image = o.image;
|
|
220
|
+
opts.allowBuild = true;
|
|
221
|
+
if (tier !== void 0) opts.tier = tier;
|
|
222
|
+
if (typeof o.registrySecret === "string") opts.registrySecret = o.registrySecret;
|
|
223
|
+
}
|
|
224
|
+
let sandbox;
|
|
225
|
+
try {
|
|
226
|
+
sandbox = o.image !== void 0 ? await Sandbox.create(opts) : await Sandbox.create(snapshot ?? config.snapshot ?? "base", opts);
|
|
227
|
+
} catch (e) {
|
|
228
|
+
rethrow(e, "sandbox create");
|
|
229
|
+
}
|
|
230
|
+
return { instance: { sandbox, client, config }, instanceId: sandbox.sandboxId };
|
|
231
|
+
},
|
|
232
|
+
getById: async (config, instanceId) => {
|
|
233
|
+
const client = clientFor(config);
|
|
234
|
+
try {
|
|
235
|
+
const sandbox = await Sandbox.connect(instanceId, { client });
|
|
236
|
+
return { instance: { sandbox, client, config }, instanceId: sandbox.sandboxId };
|
|
237
|
+
} catch (e) {
|
|
238
|
+
if (e instanceof NotFoundError) return null;
|
|
239
|
+
rethrow(e, "sandbox lookup");
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
list: async (config) => {
|
|
243
|
+
const client = clientFor(config);
|
|
244
|
+
const records = [];
|
|
245
|
+
try {
|
|
246
|
+
let cursor = null;
|
|
247
|
+
do {
|
|
248
|
+
const page = await Sandbox.listPage({ client, state: LIVE_STATES, ...cursor ? { cursor } : {} });
|
|
249
|
+
records.push(...page.items);
|
|
250
|
+
cursor = page.nextCursor;
|
|
251
|
+
} while (cursor);
|
|
252
|
+
} catch (e) {
|
|
253
|
+
rethrow(e, "sandbox list");
|
|
254
|
+
}
|
|
255
|
+
const sandboxes = await Promise.all(
|
|
256
|
+
records.filter((r) => r.state !== "ended").map(async (r) => {
|
|
257
|
+
try {
|
|
258
|
+
return await Sandbox.connect(r.sandbox_id, { client });
|
|
259
|
+
} catch (e) {
|
|
260
|
+
if (e instanceof NotFoundError) return void 0;
|
|
261
|
+
rethrow(e, "sandbox lookup");
|
|
262
|
+
}
|
|
263
|
+
})
|
|
264
|
+
);
|
|
265
|
+
return sandboxes.filter((s) => s !== void 0).map((sandbox) => ({ instance: { sandbox, client, config }, instanceId: sandbox.sandboxId }));
|
|
266
|
+
},
|
|
267
|
+
destroy: async (config, instanceId) => {
|
|
268
|
+
const client = clientFor(config);
|
|
269
|
+
try {
|
|
270
|
+
await client.sandboxes.kill(instanceId);
|
|
271
|
+
} catch (e) {
|
|
272
|
+
if (e instanceof NotFoundError) return;
|
|
273
|
+
rethrow(e, "sandbox destroy");
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
runCommand: async (inst, command, options) => {
|
|
277
|
+
const startedAt = Date.now();
|
|
278
|
+
if (options?.background) {
|
|
279
|
+
try {
|
|
280
|
+
await inst.sandbox.commands.run(command, { ...runOpts(options, inst.config), background: true });
|
|
281
|
+
return { stdout: "", stderr: "", exitCode: 0, durationMs: Date.now() - startedAt };
|
|
282
|
+
} catch (e) {
|
|
283
|
+
rethrow(e, "background command");
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
try {
|
|
287
|
+
const r = await inst.sandbox.commands.run(command, runOpts(options, inst.config));
|
|
288
|
+
return toComputeResult(r, startedAt);
|
|
289
|
+
} catch (e) {
|
|
290
|
+
if (e instanceof CommandExitError) {
|
|
291
|
+
return { stdout: e.stdout, stderr: e.stderr, exitCode: e.exitCode, durationMs: Date.now() - startedAt };
|
|
292
|
+
}
|
|
293
|
+
rethrow(e, "command");
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
/**
|
|
297
|
+
* `onStdout` / `onStderr` receive the output while the command runs. A command still running
|
|
298
|
+
* when its `timeout` is reached is stopped and reported with exit code 124; one that had
|
|
299
|
+
* already ended keeps its own exit code, however late its result arrives.
|
|
300
|
+
*/
|
|
301
|
+
streamCommand: async (inst, command, options) => {
|
|
302
|
+
const startedAt = Date.now();
|
|
303
|
+
let handle;
|
|
304
|
+
try {
|
|
305
|
+
handle = await inst.sandbox.commands.run(command, {
|
|
306
|
+
...runOpts(options, inst.config),
|
|
307
|
+
background: true,
|
|
308
|
+
...options.onStdout ? { onStdout: options.onStdout } : {},
|
|
309
|
+
...options.onStderr ? { onStderr: options.onStderr } : {}
|
|
310
|
+
});
|
|
311
|
+
} catch (e) {
|
|
312
|
+
rethrow(e, "command");
|
|
313
|
+
}
|
|
314
|
+
let timedOut = false;
|
|
315
|
+
let settled = false;
|
|
316
|
+
const atDeadline = async () => {
|
|
317
|
+
try {
|
|
318
|
+
const status = await inst.client.sandboxes.execs.get(handle.sandboxId, handle.pid);
|
|
319
|
+
if (status.state !== "running") return;
|
|
320
|
+
} catch {
|
|
321
|
+
}
|
|
322
|
+
if (settled) return;
|
|
323
|
+
timedOut = true;
|
|
324
|
+
await handle.kill().catch(() => void 0);
|
|
325
|
+
};
|
|
326
|
+
const timer = options.timeout === void 0 ? void 0 : setTimeout(() => void atDeadline(), options.timeout);
|
|
327
|
+
try {
|
|
328
|
+
return toComputeResult(await handle.wait(), startedAt);
|
|
329
|
+
} catch (e) {
|
|
330
|
+
if (e instanceof CommandExitError) {
|
|
331
|
+
const pastTimeout = timedOut || e instanceof CommandTimeoutError;
|
|
332
|
+
return {
|
|
333
|
+
stdout: e.stdout,
|
|
334
|
+
stderr: e.stderr,
|
|
335
|
+
exitCode: pastTimeout ? TIMEOUT_EXIT_CODE : e.exitCode,
|
|
336
|
+
durationMs: Date.now() - startedAt
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
rethrow(e, "command");
|
|
340
|
+
} finally {
|
|
341
|
+
settled = true;
|
|
342
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
getInfo: async (inst) => {
|
|
346
|
+
let rec;
|
|
347
|
+
try {
|
|
348
|
+
rec = await inst.sandbox.getInfo();
|
|
349
|
+
} catch (e) {
|
|
350
|
+
rethrow(e, "sandbox info");
|
|
351
|
+
}
|
|
352
|
+
return {
|
|
353
|
+
id: inst.sandbox.sandboxId,
|
|
354
|
+
provider: PROVIDER,
|
|
355
|
+
status: rec.state === "ended" ? "stopped" : "running",
|
|
356
|
+
createdAt: createdAtOf(rec),
|
|
357
|
+
// The sandbox's own lifetime, else the config's. When neither names one, your account's
|
|
358
|
+
// default applies and is not known here, so it is NaN: 0 would read as a real lifetime.
|
|
359
|
+
timeout: typeof rec.timeout_ms === "number" ? rec.timeout_ms : inst.config.timeout ?? Number.NaN,
|
|
360
|
+
metadata: {
|
|
361
|
+
state: rec.state,
|
|
362
|
+
runId: inst.sandbox.runId,
|
|
363
|
+
snapshot: inst.sandbox.snapshot,
|
|
364
|
+
...rec.outcome === void 0 ? {} : { outcome: rec.outcome }
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
},
|
|
368
|
+
getUrl: async (_inst, options) => {
|
|
369
|
+
throw unsupported(
|
|
370
|
+
`Promigence does not offer preview URLs yet, so getUrl() has no URL for port ${options.port}.`,
|
|
371
|
+
`To reach a server in the sandbox, call it from a command in the same sandbox, for example with curl on port ${options.port}.`
|
|
372
|
+
);
|
|
373
|
+
},
|
|
374
|
+
getInstance: (inst) => inst,
|
|
375
|
+
filesystem: {
|
|
376
|
+
readFile: async (inst, path) => {
|
|
377
|
+
try {
|
|
378
|
+
return await inst.sandbox.files.read(path);
|
|
379
|
+
} catch (e) {
|
|
380
|
+
rethrow(e, `read of ${path}`);
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
writeFile: async (inst, path, content) => {
|
|
384
|
+
try {
|
|
385
|
+
await inst.sandbox.files.write(path, content);
|
|
386
|
+
} catch (e) {
|
|
387
|
+
rethrow(e, `write of ${path}`);
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
mkdir: (inst, path) => execOrThrow(inst, `mkdir -p -- "${escapeShellArg(path)}"`, `mkdir of ${path}`),
|
|
391
|
+
readdir: async (inst, path) => {
|
|
392
|
+
try {
|
|
393
|
+
return (await inst.sandbox.files.list(path)).map(toFileEntry);
|
|
394
|
+
} catch (e) {
|
|
395
|
+
rethrow(e, `listing of ${path}`);
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
exists: async (inst, path) => {
|
|
399
|
+
try {
|
|
400
|
+
return await inst.sandbox.files.exists(path);
|
|
401
|
+
} catch (e) {
|
|
402
|
+
rethrow(e, `check of ${path}`);
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
// ComputeSDK's remove takes directories too.
|
|
406
|
+
remove: (inst, path) => execOrThrow(inst, `rm -rf -- "${escapeShellArg(path)}"`, `remove of ${path}`)
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
snapshot: {
|
|
410
|
+
create: async (_config, instanceId) => {
|
|
411
|
+
throw unsupported(
|
|
412
|
+
`Promigence does not create a snapshot from a running sandbox (${instanceId}).`,
|
|
413
|
+
"Build one with the Promigence CLI (promigence snapshot create --image <image>) and pass its id or alias to create() as templateId or snapshotId, or pass an image to create()."
|
|
414
|
+
);
|
|
415
|
+
},
|
|
416
|
+
list: async (config, options) => {
|
|
417
|
+
const limit = snapshotLimit(options?.limit);
|
|
418
|
+
const client = clientFor(config);
|
|
419
|
+
if (limit === 0) return [];
|
|
420
|
+
const records = [];
|
|
421
|
+
try {
|
|
422
|
+
let cursor = null;
|
|
423
|
+
do {
|
|
424
|
+
const page = await client.snapshots.listPage({
|
|
425
|
+
...limit === void 0 ? {} : { limit: limit - records.length },
|
|
426
|
+
...cursor ? { cursor } : {}
|
|
427
|
+
});
|
|
428
|
+
records.push(...page.items);
|
|
429
|
+
cursor = page.nextCursor;
|
|
430
|
+
} while (cursor && (limit === void 0 || records.length < limit));
|
|
431
|
+
} catch (e) {
|
|
432
|
+
rethrow(e, "snapshot list");
|
|
433
|
+
}
|
|
434
|
+
return (limit === void 0 ? records : records.slice(0, limit)).map(toSnapshotInfo);
|
|
435
|
+
},
|
|
436
|
+
delete: async (config, snapshotId) => {
|
|
437
|
+
const client = clientFor(config);
|
|
438
|
+
try {
|
|
439
|
+
await client.snapshots.delete(snapshotId);
|
|
440
|
+
} catch (e) {
|
|
441
|
+
if (e instanceof NotFoundError) return;
|
|
442
|
+
rethrow(e, "snapshot delete");
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
template: {
|
|
447
|
+
create: async () => {
|
|
448
|
+
throw unsupported("Promigence has no templates of its own: a template is a snapshot.", TEMPLATE_FIX);
|
|
449
|
+
},
|
|
450
|
+
list: async () => {
|
|
451
|
+
throw unsupported("Promigence has no templates of its own: a template is a snapshot.", TEMPLATE_FIX);
|
|
452
|
+
},
|
|
453
|
+
delete: async () => {
|
|
454
|
+
throw unsupported("Promigence has no templates of its own: a template is a snapshot.", TEMPLATE_FIX);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
export {
|
|
460
|
+
PromigenceClient2 as PromigenceClient,
|
|
461
|
+
PromigenceError2 as PromigenceError,
|
|
462
|
+
Sandbox2 as PromigenceSandbox,
|
|
463
|
+
promigence
|
|
464
|
+
};
|
|
465
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Promigence provider for ComputeSDK.\n *\n * Production-grade sandboxes for AI agents, with filesystem access and streaming output. Every\n * operation goes through the Promigence SDK (`@promigence/sdk`).\n */\n\nimport { defineProvider, escapeShellArg, TIMEOUT_EXIT_CODE } from '@computesdk/provider';\nimport type {\n CommandResult,\n CreateInstanceOptions,\n FileEntry,\n InstanceInfo,\n ListSnapshotsOptions,\n RunCommandOptions,\n} from '@computesdk/provider';\nimport {\n CommandExitError,\n CommandTimeoutError,\n NotFoundError,\n PromigenceClient,\n PromigenceError,\n Sandbox,\n} from '@promigence/sdk';\nimport type {\n CommandHandle,\n CommandResult as PromigenceCommandResult,\n CommandRunOpts,\n EntryInfo,\n OptimizeFor,\n SandboxCreateOpts,\n SandboxRecord,\n SnapshotRecord,\n Tier,\n} from '@promigence/sdk';\n\n/** Configuration for `promigence(config)`. Every field is optional. */\nexport interface PromigenceConfig {\n /** Promigence API key. Falls back to `PROMIGENCE_API_KEY`, then to the key `promigence login` stored. */\n apiKey?: string;\n /** Promigence API URL. Falls back to `PROMIGENCE_API_URL`, then to the default Promigence API. */\n apiUrl?: string;\n /**\n * The most one sandbox may spend, in US dollars. Falls back to `PROMIGENCE_SPEND_CAP`, then to\n * your organization's default cap.\n */\n spendCap?: number;\n /**\n * The snapshot `create()` starts from when it names none: its id (`snap_...`), its alias, or\n * `alias@commit`. Default: the built-in base snapshot.\n */\n snapshot?: string;\n /**\n * Sandbox lifetime in milliseconds when `create()` sets none; also the bound on a command that\n * sets none. Default: your account's.\n */\n timeout?: number;\n /** Size of a sandbox created from an `image`. A sandbox from a snapshot has that snapshot's size. */\n tier?: Tier;\n /** `'start'` (the default) or `'compute'` (long, memory-heavy jobs on the larger tiers). */\n optimizeFor?: OptimizeFor;\n /** A Promigence SDK client to use instead of one built from `apiKey` and `apiUrl`. */\n client?: PromigenceClient;\n}\n\n/** What `sandbox.getInstance()` returns: the Promigence SDK sandbox, its client and the provider config. */\nexport interface PromigenceInstance {\n sandbox: Sandbox;\n client: PromigenceClient;\n config: PromigenceConfig;\n}\n\n/** `create()` options ComputeSDK does not name; they arrive through its index signature. */\ninterface PromigenceCreateOptions {\n spendCap?: unknown;\n tier?: Tier;\n optimizeFor?: OptimizeFor;\n allowInternetAccess?: boolean;\n allowHosts?: string[];\n registrySecret?: string;\n}\n\nconst PROVIDER = 'promigence';\n\n/** Every state a sandbox reports before it has ended. */\nconst LIVE_STATES = ['queued', 'ready', 'running', 'paused'];\n\nconst TEMPLATE_FIX =\n 'Pass a snapshot id or alias to create() as templateId, list snapshots with snapshot.list(), ' +\n 'and build snapshots with the Promigence CLI (promigence snapshot create).';\n\nfunction fromEnv(name: string): string | undefined {\n const value = typeof process === 'undefined' ? undefined : process.env?.[name];\n const trimmed = value?.trim();\n return trimmed ? trimmed : undefined;\n}\n\nfunction show(value: unknown): string {\n return typeof value === 'string' ? JSON.stringify(value) : String(value);\n}\n\nfunction promigenceError(\n message: string,\n detail: { name?: string; code?: string; fix?: string; cause?: unknown } = {}\n): Error {\n const { name, ...rest } = detail;\n const err = new Error(message);\n if (name) err.name = name;\n return Object.assign(err, rest);\n}\n\nfunction invalidArgument(message: string, fix: string): Error {\n return promigenceError(`${message}. ${fix}`, { name: 'InvalidArgumentError', code: 'invalid_argument', fix });\n}\n\nfunction unsupported(message: string, fix: string): Error {\n return promigenceError(`${message} ${fix}`, { name: 'UnsupportedError', code: 'unsupported', fix });\n}\n\n/** A Promigence error, re-thrown with the operation named; its `code`, `fix` and the original (`cause`) are kept. */\nfunction rethrow(e: unknown, what: string): never {\n if (e instanceof PromigenceError) {\n const detail = [e.message.replace(/\\.+$/, ''), e.fix].filter((part) => part.length > 0).join('. ');\n throw promigenceError(`Promigence ${what} failed (${e.code}): ${detail}`, {\n name: e.name,\n code: e.code,\n fix: e.fix,\n cause: e,\n });\n }\n throw e;\n}\n\nfunction checkString(value: unknown, field: string): void {\n if (value !== undefined && typeof value !== 'string') {\n throw invalidArgument(`Promigence: '${field}' must be a string, got ${typeof value}`, `Pass '${field}' as a string, or leave it unset.`);\n }\n}\n\nfunction checkSpendCap(value: unknown, from: string): number {\n if (typeof value === 'number' && Number.isFinite(value) && value >= 0) return value;\n throw invalidArgument(\n `Promigence: ${from} must be a number of US dollars, 0 or more, got ${show(value)}`,\n \"Pass the most one sandbox may spend, or leave it unset to use your organization's default cap.\"\n );\n}\n\n/** `snapshot.list()`'s `limit`: unset, or a whole number, 0 or more. */\nfunction snapshotLimit(value: unknown): number | undefined {\n if (value === undefined) return undefined;\n if (typeof value === 'number' && Number.isInteger(value) && value >= 0) return value;\n throw invalidArgument(\n `Promigence: snapshot.list() 'limit' must be a whole number, 0 or more, got ${show(value)}`,\n 'Pass the most snapshots to return, or leave it unset to list them all.'\n );\n}\n\n/** Checks the provider config before anything is sent. */\nfunction checkConfig(config: PromigenceConfig): void {\n checkString(config.apiKey, 'apiKey');\n checkString(config.apiUrl, 'apiUrl');\n checkString(config.snapshot, 'snapshot');\n checkString(config.tier, 'tier');\n checkString(config.optimizeFor, 'optimizeFor');\n\n const apiUrl = config.apiUrl?.trim() || fromEnv('PROMIGENCE_API_URL');\n if (apiUrl !== undefined) {\n const from = config.apiUrl?.trim() ? \"'apiUrl'\" : 'PROMIGENCE_API_URL';\n let protocol = '';\n try {\n protocol = new URL(apiUrl).protocol;\n } catch {\n // reported below\n }\n if (protocol !== 'https:' && protocol !== 'http:') {\n throw invalidArgument(\n `Promigence: ${from} must be an http(s) URL, got ${show(apiUrl)}`,\n 'Leave it unset to use the default Promigence API.'\n );\n }\n }\n\n if (config.spendCap !== undefined) checkSpendCap(config.spendCap, \"'spendCap'\");\n\n const timeout: unknown = config.timeout;\n if (timeout !== undefined && !(typeof timeout === 'number' && Number.isFinite(timeout) && timeout > 0)) {\n throw invalidArgument(\n `Promigence: 'timeout' must be a number of milliseconds above 0, got ${show(timeout)}`,\n \"Pass the sandbox lifetime in milliseconds, or leave it unset to use your account's default.\"\n );\n }\n}\n\nfunction missingKey(client: PromigenceClient): Error {\n const problem = client.credentialsProblem;\n if (problem) {\n return promigenceError(`Promigence did not use the API key it found: ${problem.message}. ${problem.fix}`, {\n name: problem.name,\n code: problem.code,\n fix: problem.fix,\n cause: problem,\n });\n }\n const fix =\n \"Pass it: promigence({ apiKey: 'prom_api_...' })\\n\" +\n 'Or set PROMIGENCE_API_KEY in your environment.\\n' +\n 'Or sign in once with the Promigence CLI (npm install -g promigence, then promigence login); ' +\n 'the key it stores is used when neither is set.\\n' +\n 'New to Promigence? promigence signup creates an account: https://www.promigence.ai/docs/quickstart';\n return promigenceError(`Missing Promigence API key.\\n\\n${fix}`, { name: 'AuthError', code: 'auth', fix });\n}\n\nconst clients = new WeakMap<PromigenceConfig, PromigenceClient>();\n\n/** The client for one provider config, built on first use, once the config has been checked. */\nfunction clientFor(config: PromigenceConfig): PromigenceClient {\n const cached = clients.get(config);\n if (cached) return cached;\n checkConfig(config);\n const apiKey = config.apiKey?.trim() || fromEnv('PROMIGENCE_API_KEY');\n const apiUrl = config.apiUrl?.trim() || fromEnv('PROMIGENCE_API_URL');\n const client =\n config.client ??\n new PromigenceClient({\n ...(apiKey === undefined ? {} : { apiKey }),\n ...(apiUrl === undefined ? {} : { apiUrl }),\n });\n if (!client.authenticated) throw missingKey(client);\n clients.set(config, client);\n return client;\n}\n\n/** The spend cap for one `create()`: its own option, then the config, then `PROMIGENCE_SPEND_CAP`. */\nfunction spendCapFor(option: unknown, config: PromigenceConfig): number | undefined {\n if (option !== undefined) return checkSpendCap(option, \"the create() option 'spendCap'\");\n if (config.spendCap !== undefined) return config.spendCap;\n const env = fromEnv('PROMIGENCE_SPEND_CAP');\n return env === undefined ? undefined : checkSpendCap(Number(env), `PROMIGENCE_SPEND_CAP (${show(env)})`);\n}\n\n/** ComputeSDK `metadata` becomes the sandbox's labels, which are strings. */\nfunction labelsOf(metadata: unknown): Record<string, string> | undefined {\n if (!metadata || typeof metadata !== 'object') return undefined;\n const labels: Record<string, string> = {};\n for (const [key, value] of Object.entries(metadata as Record<string, unknown>)) {\n if (value === undefined || value === null) continue;\n labels[key] = typeof value === 'string' ? value : JSON.stringify(value);\n }\n return Object.keys(labels).length > 0 ? labels : undefined;\n}\n\n/** The SDK options for one command: its own timeout, else the provider config's. */\nfunction runOpts(options: RunCommandOptions | undefined, config: PromigenceConfig): Omit<CommandRunOpts, 'background'> {\n const timeoutMs = options?.timeout ?? config.timeout;\n return {\n throwOnExit: false,\n ...(options?.cwd === undefined ? {} : { cwd: options.cwd }),\n ...(options?.env && Object.keys(options.env).length > 0 ? { envs: options.env } : {}),\n ...(timeoutMs === undefined ? {} : { timeoutMs }),\n };\n}\n\nfunction toComputeResult(r: PromigenceCommandResult, startedAt: number): CommandResult {\n return { stdout: r.stdout, stderr: r.stderr, exitCode: r.exitCode, durationMs: Date.now() - startedAt };\n}\n\nfunction toFileEntry(e: EntryInfo): FileEntry {\n return { name: e.name, type: e.type === 'dir' ? 'directory' : 'file', size: e.size, modified: e.modifiedTime };\n}\n\nfunction createdAtOf(rec: SandboxRecord): Date {\n if (typeof rec.created_at === 'string') {\n const date = new Date(rec.created_at);\n if (!Number.isNaN(date.getTime())) return date;\n }\n return new Date(0);\n}\n\n/** Runs a filesystem command; a non-zero exit is an error that names the operation. */\nasync function execOrThrow(inst: PromigenceInstance, command: string, what: string): Promise<void> {\n let r: PromigenceCommandResult;\n try {\n r = await inst.sandbox.commands.run(command, { throwOnExit: false });\n } catch (e) {\n rethrow(e, what);\n }\n if (r.exitCode !== 0) {\n throw promigenceError(`Promigence ${what} failed (exit ${r.exitCode}): ${r.stderr.trim()}`);\n }\n}\n\nfunction toSnapshotInfo(s: SnapshotRecord) {\n return {\n id: s.snapshot_id,\n provider: PROVIDER,\n createdAt: typeof s.created_at === 'string' ? new Date(s.created_at) : new Date(0),\n metadata: {\n ...(s.alias ? { alias: s.alias } : {}),\n ...(s.repo ? { repo: s.repo } : {}),\n ...(s.commit ? { commit: s.commit } : {}),\n ...(s.tier ? { tier: s.tier } : {}),\n ...(typeof s.verified === 'boolean' ? { verified: s.verified } : {}),\n },\n };\n}\n\n/** The ComputeSDK provider: `promigence({ apiKey })`, or `promigence({})` to read the environment. */\nexport const promigence = defineProvider<PromigenceInstance, PromigenceConfig>({\n name: PROVIDER,\n methods: {\n instances: {\n create: async (config: PromigenceConfig, options?: CreateInstanceOptions) => {\n const client = clientFor(config);\n const o = (options ?? {}) as CreateInstanceOptions & PromigenceCreateOptions;\n const snapshot = o.templateId ?? o.snapshotId;\n if (o.image !== undefined && snapshot !== undefined) {\n throw invalidArgument(\n \"Promigence: create() takes 'image' or a snapshot ('templateId' / 'snapshotId'), not both\",\n 'Pass one of them.'\n );\n }\n const timeoutMs = o.timeout ?? config.timeout;\n const spendCap = spendCapFor(o.spendCap, config);\n const tier = o.tier ?? config.tier;\n const optimizeFor = o.optimizeFor ?? config.optimizeFor;\n const labels = labelsOf(o.metadata);\n\n const opts: SandboxCreateOpts = {\n client,\n ...(timeoutMs === undefined ? {} : { timeoutMs }),\n ...(spendCap === undefined ? {} : { spendCap }),\n ...(o.envs === undefined ? {} : { envs: o.envs }),\n ...(labels === undefined ? {} : { metadata: labels }),\n ...(o.allowInternetAccess === undefined ? {} : { allowInternetAccess: o.allowInternetAccess }),\n ...(Array.isArray(o.allowHosts) && o.allowHosts.length > 0 ? { allowHosts: o.allowHosts } : {}),\n ...(optimizeFor === undefined ? {} : { optimizeFor }),\n };\n if (o.image !== undefined) {\n // Passing an image asks for its snapshot: built on first use, reused after.\n opts.image = o.image;\n opts.allowBuild = true;\n if (tier !== undefined) opts.tier = tier;\n if (typeof o.registrySecret === 'string') opts.registrySecret = o.registrySecret;\n }\n\n let sandbox: Sandbox;\n try {\n sandbox =\n o.image !== undefined\n ? await Sandbox.create(opts)\n : await Sandbox.create(snapshot ?? config.snapshot ?? 'base', opts);\n } catch (e) {\n rethrow(e, 'sandbox create');\n }\n return { instance: { sandbox, client, config }, instanceId: sandbox.sandboxId };\n },\n\n getById: async (config: PromigenceConfig, instanceId: string) => {\n const client = clientFor(config);\n try {\n const sandbox = await Sandbox.connect(instanceId, { client });\n return { instance: { sandbox, client, config }, instanceId: sandbox.sandboxId };\n } catch (e) {\n if (e instanceof NotFoundError) return null;\n rethrow(e, 'sandbox lookup');\n }\n },\n\n list: async (config: PromigenceConfig) => {\n const client = clientFor(config);\n const records: SandboxRecord[] = [];\n try {\n let cursor: string | null = null;\n do {\n const page = await Sandbox.listPage({ client, state: LIVE_STATES, ...(cursor ? { cursor } : {}) });\n records.push(...page.items);\n cursor = page.nextCursor;\n } while (cursor);\n } catch (e) {\n rethrow(e, 'sandbox list');\n }\n const sandboxes = await Promise.all(\n records\n .filter((r) => r.state !== 'ended')\n .map(async (r) => {\n try {\n return await Sandbox.connect(r.sandbox_id, { client });\n } catch (e) {\n if (e instanceof NotFoundError) return undefined;\n rethrow(e, 'sandbox lookup');\n }\n })\n );\n return sandboxes\n .filter((s): s is Sandbox => s !== undefined)\n .map((sandbox) => ({ instance: { sandbox, client, config }, instanceId: sandbox.sandboxId }));\n },\n\n destroy: async (config: PromigenceConfig, instanceId: string) => {\n const client = clientFor(config);\n try {\n await client.sandboxes.kill(instanceId);\n } catch (e) {\n // Already gone is what destroy asks for.\n if (e instanceof NotFoundError) return;\n rethrow(e, 'sandbox destroy');\n }\n },\n\n runCommand: async (inst: PromigenceInstance, command: string, options?: RunCommandOptions): Promise<CommandResult> => {\n const startedAt = Date.now();\n if (options?.background) {\n // Started and left running; its output is not collected.\n try {\n await inst.sandbox.commands.run(command, { ...runOpts(options, inst.config), background: true });\n return { stdout: '', stderr: '', exitCode: 0, durationMs: Date.now() - startedAt };\n } catch (e) {\n rethrow(e, 'background command');\n }\n }\n try {\n const r = await inst.sandbox.commands.run(command, runOpts(options, inst.config));\n return toComputeResult(r, startedAt);\n } catch (e) {\n if (e instanceof CommandExitError) {\n return { stdout: e.stdout, stderr: e.stderr, exitCode: e.exitCode, durationMs: Date.now() - startedAt };\n }\n rethrow(e, 'command');\n }\n },\n\n /**\n * `onStdout` / `onStderr` receive the output while the command runs. A command still running\n * when its `timeout` is reached is stopped and reported with exit code 124; one that had\n * already ended keeps its own exit code, however late its result arrives.\n */\n streamCommand: async (inst: PromigenceInstance, command: string, options: RunCommandOptions): Promise<CommandResult> => {\n const startedAt = Date.now();\n let handle: CommandHandle;\n try {\n handle = await inst.sandbox.commands.run(command, {\n ...runOpts(options, inst.config),\n background: true,\n ...(options.onStdout ? { onStdout: options.onStdout } : {}),\n ...(options.onStderr ? { onStderr: options.onStderr } : {}),\n });\n } catch (e) {\n rethrow(e, 'command');\n }\n let timedOut = false;\n let settled = false;\n // At the deadline, the command's own state is asked first: one that has already ended is\n // neither killed nor reported as timed out, even when its result has not arrived yet.\n const atDeadline = async (): Promise<void> => {\n try {\n const status = await inst.client.sandboxes.execs.get(handle.sandboxId, handle.pid);\n if (status.state !== 'running') return;\n } catch {\n // Its state could not be read: it is treated as still running.\n }\n if (settled) return;\n timedOut = true;\n await handle.kill().catch(() => undefined);\n };\n const timer =\n options.timeout === undefined ? undefined : setTimeout(() => void atDeadline(), options.timeout);\n try {\n return toComputeResult(await handle.wait(), startedAt);\n } catch (e) {\n if (e instanceof CommandExitError) {\n const pastTimeout = timedOut || e instanceof CommandTimeoutError;\n return {\n stdout: e.stdout,\n stderr: e.stderr,\n exitCode: pastTimeout ? TIMEOUT_EXIT_CODE : e.exitCode,\n durationMs: Date.now() - startedAt,\n };\n }\n rethrow(e, 'command');\n } finally {\n settled = true;\n if (timer !== undefined) clearTimeout(timer);\n }\n },\n\n getInfo: async (inst: PromigenceInstance): Promise<InstanceInfo> => {\n let rec: SandboxRecord;\n try {\n rec = await inst.sandbox.getInfo();\n } catch (e) {\n rethrow(e, 'sandbox info');\n }\n return {\n id: inst.sandbox.sandboxId,\n provider: PROVIDER,\n status: rec.state === 'ended' ? 'stopped' : 'running',\n createdAt: createdAtOf(rec),\n // The sandbox's own lifetime, else the config's. When neither names one, your account's\n // default applies and is not known here, so it is NaN: 0 would read as a real lifetime.\n timeout: typeof rec.timeout_ms === 'number' ? rec.timeout_ms : (inst.config.timeout ?? Number.NaN),\n metadata: {\n state: rec.state,\n runId: inst.sandbox.runId,\n snapshot: inst.sandbox.snapshot,\n ...(rec.outcome === undefined ? {} : { outcome: rec.outcome }),\n },\n };\n },\n\n getUrl: async (_inst: PromigenceInstance, options: { port: number; protocol?: string }): Promise<string> => {\n throw unsupported(\n `Promigence does not offer preview URLs yet, so getUrl() has no URL for port ${options.port}.`,\n `To reach a server in the sandbox, call it from a command in the same sandbox, for example with curl on port ${options.port}.`\n );\n },\n\n getInstance: (inst: PromigenceInstance): PromigenceInstance => inst,\n\n filesystem: {\n readFile: async (inst: PromigenceInstance, path: string): Promise<string> => {\n try {\n return await inst.sandbox.files.read(path);\n } catch (e) {\n rethrow(e, `read of ${path}`);\n }\n },\n writeFile: async (inst: PromigenceInstance, path: string, content: string): Promise<void> => {\n try {\n await inst.sandbox.files.write(path, content);\n } catch (e) {\n rethrow(e, `write of ${path}`);\n }\n },\n mkdir: (inst: PromigenceInstance, path: string): Promise<void> =>\n execOrThrow(inst, `mkdir -p -- \"${escapeShellArg(path)}\"`, `mkdir of ${path}`),\n readdir: async (inst: PromigenceInstance, path: string): Promise<FileEntry[]> => {\n try {\n return (await inst.sandbox.files.list(path)).map(toFileEntry);\n } catch (e) {\n rethrow(e, `listing of ${path}`);\n }\n },\n exists: async (inst: PromigenceInstance, path: string): Promise<boolean> => {\n try {\n return await inst.sandbox.files.exists(path);\n } catch (e) {\n rethrow(e, `check of ${path}`);\n }\n },\n // ComputeSDK's remove takes directories too.\n remove: (inst: PromigenceInstance, path: string): Promise<void> =>\n execOrThrow(inst, `rm -rf -- \"${escapeShellArg(path)}\"`, `remove of ${path}`),\n },\n },\n\n snapshot: {\n create: async (_config: PromigenceConfig, instanceId: string) => {\n throw unsupported(\n `Promigence does not create a snapshot from a running sandbox (${instanceId}).`,\n 'Build one with the Promigence CLI (promigence snapshot create --image <image>) and pass its id or ' +\n 'alias to create() as templateId or snapshotId, or pass an image to create().'\n );\n },\n list: async (config: PromigenceConfig, options?: ListSnapshotsOptions) => {\n const limit = snapshotLimit(options?.limit);\n const client = clientFor(config);\n if (limit === 0) return [];\n // Page by page until the limit is reached; with no limit, every page.\n const records: SnapshotRecord[] = [];\n try {\n let cursor: string | null = null;\n do {\n const page = await client.snapshots.listPage({\n ...(limit === undefined ? {} : { limit: limit - records.length }),\n ...(cursor ? { cursor } : {}),\n });\n records.push(...page.items);\n cursor = page.nextCursor;\n } while (cursor && (limit === undefined || records.length < limit));\n } catch (e) {\n rethrow(e, 'snapshot list');\n }\n return (limit === undefined ? records : records.slice(0, limit)).map(toSnapshotInfo);\n },\n delete: async (config: PromigenceConfig, snapshotId: string) => {\n const client = clientFor(config);\n try {\n await client.snapshots.delete(snapshotId);\n } catch (e) {\n if (e instanceof NotFoundError) return;\n rethrow(e, 'snapshot delete');\n }\n },\n },\n\n template: {\n create: async () => {\n throw unsupported('Promigence has no templates of its own: a template is a snapshot.', TEMPLATE_FIX);\n },\n list: async () => {\n throw unsupported('Promigence has no templates of its own: a template is a snapshot.', TEMPLATE_FIX);\n },\n delete: async () => {\n throw unsupported('Promigence has no templates of its own: a template is a snapshot.', TEMPLATE_FIX);\n },\n },\n },\n});\n\nexport { PromigenceClient, PromigenceError, Sandbox as PromigenceSandbox } from '@promigence/sdk';\n"],"mappings":";AAOA,SAAS,gBAAgB,gBAAgB,yBAAyB;AASlE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA0kBP,SAAS,oBAAAA,mBAAkB,mBAAAC,kBAA4B,WAAXC,gBAAoC;AA/gBhF,IAAM,WAAW;AAGjB,IAAM,cAAc,CAAC,UAAU,SAAS,WAAW,QAAQ;AAE3D,IAAM,eACJ;AAGF,SAAS,QAAQ,MAAkC;AACjD,QAAM,QAAQ,OAAO,YAAY,cAAc,SAAY,QAAQ,MAAM,IAAI;AAC7E,QAAM,UAAU,OAAO,KAAK;AAC5B,SAAO,UAAU,UAAU;AAC7B;AAEA,SAAS,KAAK,OAAwB;AACpC,SAAO,OAAO,UAAU,WAAW,KAAK,UAAU,KAAK,IAAI,OAAO,KAAK;AACzE;AAEA,SAAS,gBACP,SACA,SAA0E,CAAC,GACpE;AACP,QAAM,EAAE,MAAM,GAAG,KAAK,IAAI;AAC1B,QAAM,MAAM,IAAI,MAAM,OAAO;AAC7B,MAAI,KAAM,KAAI,OAAO;AACrB,SAAO,OAAO,OAAO,KAAK,IAAI;AAChC;AAEA,SAAS,gBAAgB,SAAiB,KAAoB;AAC5D,SAAO,gBAAgB,GAAG,OAAO,KAAK,GAAG,IAAI,EAAE,MAAM,wBAAwB,MAAM,oBAAoB,IAAI,CAAC;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,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;AAAA,YAC7B,CAAC;AACD,oBAAQ,KAAK,GAAG,KAAK,KAAK;AAC1B,qBAAS,KAAK;AAAA,UAChB,SAAS,WAAW,UAAU,UAAa,QAAQ,SAAS;AAAA,QAC9D,SAAS,GAAG;AACV,kBAAQ,GAAG,eAAe;AAAA,QAC5B;AACA,gBAAQ,UAAU,SAAY,UAAU,QAAQ,MAAM,GAAG,KAAK,GAAG,IAAI,cAAc;AAAA,MACrF;AAAA,MACA,QAAQ,OAAO,QAA0B,eAAuB;AAC9D,cAAM,SAAS,UAAU,MAAM;AAC/B,YAAI;AACF,gBAAM,OAAO,UAAU,OAAO,UAAU;AAAA,QAC1C,SAAS,GAAG;AACV,cAAI,aAAa,cAAe;AAChC,kBAAQ,GAAG,iBAAiB;AAAA,QAC9B;AAAA,MACF;AAAA,IACF;AAAA,IAEA,UAAU;AAAA,MACR,QAAQ,YAAY;AAClB,cAAM,YAAY,qEAAqE,YAAY;AAAA,MACrG;AAAA,MACA,MAAM,YAAY;AAChB,cAAM,YAAY,qEAAqE,YAAY;AAAA,MACrG;AAAA,MACA,QAAQ,YAAY;AAClB,cAAM,YAAY,qEAAqE,YAAY;AAAA,MACrG;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":["PromigenceClient","PromigenceError","Sandbox"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,68 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@computesdk/promigence",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Promigence provider for ComputeSDK - production-grade sandboxes for AI agents, with filesystem and streaming output",
|
|
5
|
+
"author": "Promigence AI, Inc. <support@promigence.ai>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.mjs",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.mjs",
|
|
14
|
+
"require": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"keywords": [
|
|
21
|
+
"computesdk",
|
|
22
|
+
"promigence",
|
|
23
|
+
"provider",
|
|
24
|
+
"sandbox",
|
|
25
|
+
"code-execution",
|
|
26
|
+
"agents",
|
|
27
|
+
"snapshot",
|
|
28
|
+
"cloud",
|
|
29
|
+
"compute"
|
|
30
|
+
],
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@promigence/sdk": "^0.1.0-beta.9",
|
|
33
|
+
"@computesdk/provider": "2.1.14",
|
|
34
|
+
"computesdk": "4.1.12"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/node": "^20.0.0",
|
|
38
|
+
"@vitest/coverage-v8": "^1.0.0",
|
|
39
|
+
"eslint": "^8.37.0",
|
|
40
|
+
"rimraf": "^5.0.0",
|
|
41
|
+
"tsup": "^8.0.0",
|
|
42
|
+
"typescript": "^5.0.0",
|
|
43
|
+
"vitest": "^1.0.0",
|
|
44
|
+
"@computesdk/test-utils": "2.0.4"
|
|
45
|
+
},
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=20"
|
|
48
|
+
},
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "https://github.com/computesdk/computesdk.git",
|
|
52
|
+
"directory": "packages/promigence"
|
|
53
|
+
},
|
|
54
|
+
"homepage": "https://www.computesdk.com",
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "https://github.com/computesdk/computesdk/issues"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "tsup",
|
|
60
|
+
"clean": "rimraf dist",
|
|
61
|
+
"dev": "tsup --watch",
|
|
62
|
+
"test": "vitest run",
|
|
63
|
+
"test:watch": "vitest watch",
|
|
64
|
+
"test:coverage": "vitest run --coverage",
|
|
65
|
+
"typecheck": "tsc --noEmit",
|
|
66
|
+
"lint": "eslint"
|
|
67
|
+
}
|
|
6
68
|
}
|