@promigence/sdk 0.1.0-beta.12 → 0.1.0-beta.14
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/caller.js +10 -0
- package/dist/cjs/caller.js +10 -0
- package/dist/cjs/client.d.ts +16 -6
- package/dist/cjs/client.js +1180 -1129
- package/dist/cjs/core.d.ts +1 -1
- package/dist/cjs/core.js +1 -1
- package/dist/cjs/dispatcher.d.ts +2 -0
- package/dist/cjs/dispatcher.js +5 -0
- package/dist/cjs/http2.d.ts +11 -0
- package/dist/cjs/http2.js +335 -71
- package/dist/cjs/keyed.d.ts +6 -0
- package/dist/cjs/keyed.js +59 -0
- package/dist/cjs/proxy.js +11 -0
- package/dist/cjs/sandbox.d.ts +3 -1
- package/dist/cjs/sandbox.js +33 -20
- package/dist/cjs/trace.d.ts +2 -0
- package/dist/cjs/trace.js +17 -0
- package/dist/cjs/transport-worker.js +83 -14
- package/dist/client.d.ts +16 -6
- package/dist/client.js +1179 -1127
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/dispatcher.d.ts +2 -0
- package/dist/dispatcher.js +5 -0
- package/dist/http2.d.ts +11 -0
- package/dist/http2.js +335 -72
- package/dist/keyed.d.ts +6 -0
- package/dist/keyed.js +55 -0
- package/dist/proxy.js +11 -0
- package/dist/sandbox.d.ts +3 -1
- package/dist/sandbox.js +33 -20
- package/dist/trace.d.ts +2 -0
- package/dist/trace.js +16 -0
- package/dist/transport-worker.js +83 -14
- package/package.json +1 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Is `method path` a create that takes an `Idempotency-Key`? `path` is relative to `/v1` and may
|
|
3
|
+
* carry a query string. The list is the API reference's (generated from the operations that
|
|
4
|
+
* document the header), so a create the API keys is never sent unkeyed by this client.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isKeyedCreate(method: string, path: string): boolean;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.__keyedInternals = void 0;
|
|
4
|
+
exports.isKeyedCreate = isKeyedCreate;
|
|
5
|
+
const keyed_gen_js_1 = require("./keyed.gen.js");
|
|
6
|
+
const KEYED_PATTERNS = keyed_gen_js_1.KEYED_CREATES.map(([m, p]) => [m, p.split("/").filter(Boolean)]);
|
|
7
|
+
const KEYED_METHODS = new Set(keyed_gen_js_1.KEYED_CREATES.map(([m]) => m));
|
|
8
|
+
let keyedLastMethod = "";
|
|
9
|
+
let keyedLastPath = "";
|
|
10
|
+
let keyedLastAnswer = false;
|
|
11
|
+
let keyedReads = 0;
|
|
12
|
+
function isKeyedCreate(method, path) {
|
|
13
|
+
if (!KEYED_METHODS.has(method))
|
|
14
|
+
return false;
|
|
15
|
+
if (path === keyedLastPath && method === keyedLastMethod)
|
|
16
|
+
return keyedLastAnswer;
|
|
17
|
+
const answer = keyedCreateOf(method, path);
|
|
18
|
+
keyedLastMethod = method;
|
|
19
|
+
keyedLastPath = path;
|
|
20
|
+
keyedLastAnswer = answer;
|
|
21
|
+
return answer;
|
|
22
|
+
}
|
|
23
|
+
function keyedCreateOf(method, path) {
|
|
24
|
+
keyedReads++;
|
|
25
|
+
let end = path.indexOf("?");
|
|
26
|
+
if (end < 0)
|
|
27
|
+
end = path.length;
|
|
28
|
+
for (let p = 0; p < KEYED_PATTERNS.length; p++) {
|
|
29
|
+
const entry = KEYED_PATTERNS[p];
|
|
30
|
+
if (entry[0] === method && segmentsMatch(path, end, entry[1]))
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
function segmentsMatch(path, end, pat) {
|
|
36
|
+
let i = 0;
|
|
37
|
+
let k = 0;
|
|
38
|
+
for (;;) {
|
|
39
|
+
while (i < end && path.charCodeAt(i) === 0x2f)
|
|
40
|
+
i++;
|
|
41
|
+
if (i >= end)
|
|
42
|
+
return k === pat.length;
|
|
43
|
+
if (k >= pat.length)
|
|
44
|
+
return false;
|
|
45
|
+
let j = i;
|
|
46
|
+
while (j < end && path.charCodeAt(j) !== 0x2f)
|
|
47
|
+
j++;
|
|
48
|
+
const s = pat[k];
|
|
49
|
+
if (s.charCodeAt(0) !== 0x7b && (j - i !== s.length || !path.startsWith(s, i)))
|
|
50
|
+
return false;
|
|
51
|
+
k++;
|
|
52
|
+
i = j;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.__keyedInternals = {
|
|
56
|
+
reads() {
|
|
57
|
+
return keyedReads;
|
|
58
|
+
},
|
|
59
|
+
};
|
package/dist/cjs/proxy.js
CHANGED
|
@@ -65,12 +65,23 @@ function noProxy(host, port, env = process.env) {
|
|
|
65
65
|
}
|
|
66
66
|
return false;
|
|
67
67
|
}
|
|
68
|
+
let proxyLastInputs;
|
|
69
|
+
let proxyLast;
|
|
68
70
|
function proxyFor(url, env = process.env) {
|
|
69
71
|
const https = envOf(env, "HTTPS_PROXY");
|
|
70
72
|
const http = envOf(env, "HTTP_PROXY");
|
|
71
73
|
const all = envOf(env, "ALL_PROXY");
|
|
72
74
|
if (https === undefined && http === undefined && all === undefined)
|
|
73
75
|
return undefined;
|
|
76
|
+
const inputs = `${url}\n${https ?? "\0"}\n${http ?? "\0"}\n${all ?? "\0"}\n${envOf(env, "NO_PROXY") ?? "\0"}`;
|
|
77
|
+
if (inputs === proxyLastInputs)
|
|
78
|
+
return proxyLast;
|
|
79
|
+
const found = proxyForOf(url, env, https, http, all);
|
|
80
|
+
proxyLastInputs = inputs;
|
|
81
|
+
proxyLast = found;
|
|
82
|
+
return found;
|
|
83
|
+
}
|
|
84
|
+
function proxyForOf(url, env, https, http, all) {
|
|
74
85
|
let u;
|
|
75
86
|
try {
|
|
76
87
|
u = new URL(url);
|
package/dist/cjs/sandbox.d.ts
CHANGED
|
@@ -396,7 +396,9 @@ export declare class Sandbox {
|
|
|
396
396
|
}>;
|
|
397
397
|
/**
|
|
398
398
|
* `forkHandles`, plus what `create` needs to end a run it was interrupted starting: the key the
|
|
399
|
-
* create is sent under, a signal for it and its waits, and the start options as sent
|
|
399
|
+
* create is sent under, a signal for it and its waits, and the start options as sent (`onStart`
|
|
400
|
+
* is handed the very options sent, the signal included); `client` and `count` stand in for the
|
|
401
|
+
* options' own.
|
|
400
402
|
*/
|
|
401
403
|
private static forkHandlesWith;
|
|
402
404
|
/** Attach to a running sandbox (`GET /sandboxes/:id`). */
|
package/dist/cjs/sandbox.js
CHANGED
|
@@ -178,16 +178,19 @@ function onSigint() {
|
|
|
178
178
|
return;
|
|
179
179
|
void Promise.allSettled(cleanups.map((f) => f())).finally(() => { process.kill(process.pid, "SIGINT"); });
|
|
180
180
|
}
|
|
181
|
+
function createAborted() {
|
|
182
|
+
return new core_js_1.TimeoutError("Sandbox.create was aborted by the caller's signal; anything it had started was ended", "Nothing to fix: the caller aborted it.");
|
|
183
|
+
}
|
|
181
184
|
function holdSigint(cleanup) {
|
|
182
185
|
if (typeof process === "undefined" || typeof process.listenerCount !== "function")
|
|
183
|
-
return
|
|
184
|
-
if (process.listenerCount("SIGINT") - (sigintHeld ? 1 : 0) > 0)
|
|
185
|
-
return () => { };
|
|
186
|
-
creatingNow.add(cleanup);
|
|
186
|
+
return undefined;
|
|
187
187
|
if (!sigintHeld) {
|
|
188
|
+
if (process.listenerCount("SIGINT") > 0)
|
|
189
|
+
return undefined;
|
|
188
190
|
process.once("SIGINT", onSigint);
|
|
189
191
|
sigintHeld = true;
|
|
190
192
|
}
|
|
193
|
+
creatingNow.add(cleanup);
|
|
191
194
|
return () => {
|
|
192
195
|
creatingNow.delete(cleanup);
|
|
193
196
|
if (creatingNow.size === 0 && sigintHeld) {
|
|
@@ -465,7 +468,7 @@ class Sandbox {
|
|
|
465
468
|
...(opts.apiKey === undefined ? {} : { apiKey: opts.apiKey }),
|
|
466
469
|
...(opts.apiUrl === undefined ? {} : { apiUrl: opts.apiUrl }),
|
|
467
470
|
});
|
|
468
|
-
const aborted =
|
|
471
|
+
const aborted = createAborted;
|
|
469
472
|
if (opts.signal?.aborted)
|
|
470
473
|
throw aborted();
|
|
471
474
|
if (opts.image !== undefined) {
|
|
@@ -486,24 +489,31 @@ class Sandbox {
|
|
|
486
489
|
else if (snapshotIdOrAlias === undefined || snapshotIdOrAlias === "base") {
|
|
487
490
|
snapshotIdOrAlias = exports.DEFAULT_SNAPSHOT;
|
|
488
491
|
}
|
|
489
|
-
const stop = new AbortController();
|
|
490
492
|
const key = (0, client_js_1.newIdempotencyKey)();
|
|
491
493
|
let sent;
|
|
492
494
|
let runId;
|
|
493
495
|
let ending;
|
|
494
496
|
const end = () => (ending ??= endInterruptedCreate(client, runId, sent));
|
|
495
|
-
|
|
496
|
-
const
|
|
497
|
-
opts.signal
|
|
497
|
+
let stop;
|
|
498
|
+
const release = holdSigint(() => { stop?.abort(); return end(); });
|
|
499
|
+
const callerSignal = opts.signal;
|
|
500
|
+
const onAbort = callerSignal === undefined ? undefined : () => { stop?.abort(); };
|
|
501
|
+
if (release !== undefined || callerSignal !== undefined)
|
|
502
|
+
stop = new AbortController();
|
|
503
|
+
if (onAbort !== undefined)
|
|
504
|
+
callerSignal.addEventListener("abort", onAbort, { once: true });
|
|
498
505
|
try {
|
|
499
506
|
let handles;
|
|
500
507
|
try {
|
|
501
|
-
|
|
502
|
-
idempotencyKey: key,
|
|
503
|
-
}
|
|
508
|
+
const extra = {
|
|
509
|
+
idempotencyKey: key, onStart: (s) => { sent = s; }, client, count: 1,
|
|
510
|
+
};
|
|
511
|
+
if (stop !== undefined)
|
|
512
|
+
extra.signal = stop.signal;
|
|
513
|
+
({ runId, handles } = await Sandbox.forkHandlesWith(snapshotIdOrAlias, opts, extra));
|
|
504
514
|
}
|
|
505
515
|
catch (e) {
|
|
506
|
-
if (stop
|
|
516
|
+
if (stop?.signal.aborted) {
|
|
507
517
|
await end();
|
|
508
518
|
throw aborted();
|
|
509
519
|
}
|
|
@@ -516,7 +526,7 @@ class Sandbox {
|
|
|
516
526
|
return await first;
|
|
517
527
|
}
|
|
518
528
|
catch (e) {
|
|
519
|
-
if (stop
|
|
529
|
+
if (stop?.signal.aborted) {
|
|
520
530
|
await end();
|
|
521
531
|
throw aborted();
|
|
522
532
|
}
|
|
@@ -528,8 +538,9 @@ class Sandbox {
|
|
|
528
538
|
}
|
|
529
539
|
}
|
|
530
540
|
finally {
|
|
531
|
-
release();
|
|
532
|
-
|
|
541
|
+
release?.();
|
|
542
|
+
if (onAbort !== undefined)
|
|
543
|
+
callerSignal.removeEventListener("abort", onAbort);
|
|
533
544
|
}
|
|
534
545
|
}
|
|
535
546
|
static async fork(snapshotIdOrAlias, opts = {}) {
|
|
@@ -540,11 +551,11 @@ class Sandbox {
|
|
|
540
551
|
return Sandbox.forkHandlesWith(snapshotIdOrAlias, opts, {});
|
|
541
552
|
}
|
|
542
553
|
static async forkHandlesWith(snapshotIdOrAlias, opts, extra) {
|
|
543
|
-
const client = opts.client ?? new client_js_1.PromigenceClient({
|
|
554
|
+
const client = extra.client ?? opts.client ?? new client_js_1.PromigenceClient({
|
|
544
555
|
...(opts.apiKey === undefined ? {} : { apiKey: opts.apiKey }),
|
|
545
556
|
...(opts.apiUrl === undefined ? {} : { apiUrl: opts.apiUrl }),
|
|
546
557
|
});
|
|
547
|
-
const count = opts.count ?? 1;
|
|
558
|
+
const count = extra.count ?? opts.count ?? 1;
|
|
548
559
|
const spendCap = spendCapFromEnv(opts.spendCap);
|
|
549
560
|
const start = { snapshot: snapshotIdOrAlias, count };
|
|
550
561
|
if (spendCap !== undefined)
|
|
@@ -565,8 +576,10 @@ class Sandbox {
|
|
|
565
576
|
start.optimizeFor = opts.optimizeFor;
|
|
566
577
|
if (extra.idempotencyKey !== undefined)
|
|
567
578
|
start.idempotencyKey = extra.idempotencyKey;
|
|
568
|
-
extra.
|
|
569
|
-
|
|
579
|
+
if (extra.signal !== undefined)
|
|
580
|
+
start.signal = extra.signal;
|
|
581
|
+
extra.onStart?.(start);
|
|
582
|
+
const run = await client.runs.start(start);
|
|
570
583
|
const envs = opts.envs;
|
|
571
584
|
const mk = (ref) => {
|
|
572
585
|
const init = { sandboxId: ref.sandbox_id, runId: run.run_id, snapshot: snapshotIdOrAlias, client };
|
package/dist/cjs/trace.d.ts
CHANGED
|
@@ -31,3 +31,5 @@ export declare function mark(s: TraceStamp | undefined, phase: string): void;
|
|
|
31
31
|
export declare function traceEvent(name: string): void;
|
|
32
32
|
/** A process event that happened at `t` (`performance.now()` terms), recorded now: one another thread reported. */
|
|
33
33
|
export declare function traceEventAt(name: string, t: number): void;
|
|
34
|
+
/** `fn` runs once at exit, before the trace is written (tracing on only). */
|
|
35
|
+
export declare function onTraceFlush(fn: () => void): void;
|
package/dist/cjs/trace.js
CHANGED
|
@@ -6,6 +6,7 @@ exports.traceBegin = traceBegin;
|
|
|
6
6
|
exports.mark = mark;
|
|
7
7
|
exports.traceEvent = traceEvent;
|
|
8
8
|
exports.traceEventAt = traceEventAt;
|
|
9
|
+
exports.onTraceFlush = onTraceFlush;
|
|
9
10
|
const node_fs_1 = require("node:fs");
|
|
10
11
|
const core_js_1 = require("./core.js");
|
|
11
12
|
exports.TRACE_ON = (() => {
|
|
@@ -68,7 +69,23 @@ function modulePath() {
|
|
|
68
69
|
const m = /\((.*):\d+:\d+\)\s*$/.exec(frame) ?? /at (.*):\d+:\d+\s*$/.exec(frame);
|
|
69
70
|
return m?.[1] ?? "";
|
|
70
71
|
}
|
|
72
|
+
const beforeFlush = [];
|
|
73
|
+
function onTraceFlush(fn) {
|
|
74
|
+
if (!exports.TRACE_ON)
|
|
75
|
+
return;
|
|
76
|
+
beforeFlush.push(fn);
|
|
77
|
+
if (!hooked) {
|
|
78
|
+
hooked = true;
|
|
79
|
+
process.once("exit", flush);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
71
82
|
function flush() {
|
|
83
|
+
for (const fn of beforeFlush.splice(0)) {
|
|
84
|
+
try {
|
|
85
|
+
fn();
|
|
86
|
+
}
|
|
87
|
+
catch { }
|
|
88
|
+
}
|
|
72
89
|
const head = {
|
|
73
90
|
trace: "promigence-sdk",
|
|
74
91
|
version: core_js_1.VERSION,
|
|
@@ -36,6 +36,11 @@ function start(init) {
|
|
|
36
36
|
}
|
|
37
37
|
catch { }
|
|
38
38
|
};
|
|
39
|
+
const ev = (n) => {
|
|
40
|
+
if (init.trace === true)
|
|
41
|
+
post({ t: "ev", n, hr: hrNow() });
|
|
42
|
+
};
|
|
43
|
+
ev("boot");
|
|
39
44
|
const live = () => sessions.filter((e) => !e.retired && !e.session.closed && !e.session.destroyed);
|
|
40
45
|
const end = (reason) => {
|
|
41
46
|
if (closed)
|
|
@@ -96,14 +101,14 @@ function start(init) {
|
|
|
96
101
|
catch {
|
|
97
102
|
context = undefined;
|
|
98
103
|
}
|
|
99
|
-
const connect = (address) => new Promise((resolve) => {
|
|
104
|
+
const connect = (address, k) => new Promise((resolve) => {
|
|
100
105
|
let done = false;
|
|
101
106
|
const finish = (e) => { if (!done) {
|
|
102
107
|
done = true;
|
|
103
108
|
clearTimeout(timer);
|
|
104
109
|
resolve(e);
|
|
105
110
|
} };
|
|
106
|
-
const timer = setTimeout(() => { try {
|
|
111
|
+
const timer = setTimeout(() => { ev(`timeout${k}`); try {
|
|
107
112
|
socket.destroy();
|
|
108
113
|
}
|
|
109
114
|
catch { } finish(null); }, init.connectTimeoutMs);
|
|
@@ -115,8 +120,11 @@ function start(init) {
|
|
|
115
120
|
checkServerIdentity: ca_guard_js_1.guardCertChain,
|
|
116
121
|
...(context === undefined ? {} : { secureContext: context }),
|
|
117
122
|
});
|
|
118
|
-
|
|
123
|
+
if (init.trace === true)
|
|
124
|
+
socket.once("connect", () => { ev(`tcp${k}`); });
|
|
125
|
+
socket.once("error", (e) => { ev(`fail${k} ${e?.code ?? "error"}`); finish(null); });
|
|
119
126
|
socket.once("secureConnect", () => {
|
|
127
|
+
ev(`tls${k}`);
|
|
120
128
|
if (socket.alpnProtocol !== "h2") {
|
|
121
129
|
socket.destroy();
|
|
122
130
|
finish(null);
|
|
@@ -169,14 +177,66 @@ function start(init) {
|
|
|
169
177
|
resolve(v4);
|
|
170
178
|
return;
|
|
171
179
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
+
const at = init.lookupAtMs.length > 0 ? init.lookupAtMs : [0];
|
|
181
|
+
const resolvers = [];
|
|
182
|
+
const timers = [];
|
|
183
|
+
let done = false;
|
|
184
|
+
let asked = 0;
|
|
185
|
+
let failed = 0;
|
|
186
|
+
const finish = (addrs) => {
|
|
187
|
+
if (done)
|
|
188
|
+
return;
|
|
189
|
+
done = true;
|
|
190
|
+
for (const t of timers)
|
|
191
|
+
clearTimeout(t);
|
|
192
|
+
for (const r of resolvers) {
|
|
193
|
+
try {
|
|
194
|
+
r.cancel();
|
|
195
|
+
}
|
|
196
|
+
catch { }
|
|
197
|
+
}
|
|
198
|
+
resolve(addrs);
|
|
199
|
+
};
|
|
200
|
+
const gaveUp = () => {
|
|
201
|
+
if (++failed < asked)
|
|
202
|
+
return;
|
|
203
|
+
if (asked < at.length)
|
|
204
|
+
ask();
|
|
205
|
+
else
|
|
206
|
+
finish([]);
|
|
207
|
+
};
|
|
208
|
+
const ask = () => {
|
|
209
|
+
if (done || asked >= at.length)
|
|
210
|
+
return;
|
|
211
|
+
const k = asked++;
|
|
212
|
+
try {
|
|
213
|
+
const r = new dns.Resolver({ timeout: init.lookupTimeoutMs, tries: init.lookupTries });
|
|
214
|
+
const list = Array.isArray(init.servers) && init.servers.length > 0 ? init.servers : r.getServers();
|
|
215
|
+
if (list.length > 0)
|
|
216
|
+
r.setServers(list.map((_, i) => list[(i + k) % list.length]));
|
|
217
|
+
resolvers.push(r);
|
|
218
|
+
ev(`lookup${k + 1}`);
|
|
219
|
+
r.resolve4(name, (err, addrs) => {
|
|
220
|
+
if (done)
|
|
221
|
+
return;
|
|
222
|
+
if (!err && Array.isArray(addrs) && addrs.length > 0) {
|
|
223
|
+
ev(`addrs${k + 1} ${addrs.length}`);
|
|
224
|
+
finish(addrs);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
ev(`nolookup${k + 1} ${err?.code ?? "empty"}`);
|
|
228
|
+
gaveUp();
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
gaveUp();
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
for (const ms of at) {
|
|
236
|
+
if (ms <= 0)
|
|
237
|
+
ask();
|
|
238
|
+
else
|
|
239
|
+
timers.push(setTimeout(ask, ms));
|
|
180
240
|
}
|
|
181
241
|
});
|
|
182
242
|
const limitOf = (e) => {
|
|
@@ -198,7 +258,7 @@ function start(init) {
|
|
|
198
258
|
}
|
|
199
259
|
const n = Math.max(1, init.sessions);
|
|
200
260
|
pendingConnects = n;
|
|
201
|
-
const tries = Array.from({ length: n }, (_, i) => connect(addrs[i % addrs.length]).then((e) => {
|
|
261
|
+
const tries = Array.from({ length: n }, (_, i) => connect(addrs[i % addrs.length], i).then((e) => {
|
|
202
262
|
pendingConnects--;
|
|
203
263
|
if (closed) {
|
|
204
264
|
if (e)
|
|
@@ -336,7 +396,7 @@ function start(init) {
|
|
|
336
396
|
return;
|
|
337
397
|
}
|
|
338
398
|
entry.active++;
|
|
339
|
-
|
|
399
|
+
Atomics.store(init.acks, req.mark, req.id);
|
|
340
400
|
const sent = init.trace !== true ? 0 : granted > 0 ? granted : hrNow();
|
|
341
401
|
let head = 0;
|
|
342
402
|
let status = 0;
|
|
@@ -445,11 +505,20 @@ function start(init) {
|
|
|
445
505
|
else
|
|
446
506
|
armIdle(init.idleMs);
|
|
447
507
|
};
|
|
508
|
+
let wedged = false;
|
|
448
509
|
port.on("message", (m) => {
|
|
449
|
-
if (closed)
|
|
510
|
+
if (closed || wedged)
|
|
511
|
+
return;
|
|
512
|
+
if (m?.t === "wedge-for-test") {
|
|
513
|
+
wedged = true;
|
|
450
514
|
return;
|
|
515
|
+
}
|
|
451
516
|
if (m?.t === "req")
|
|
452
517
|
void run(m);
|
|
518
|
+
else if (m?.t === "reqs") {
|
|
519
|
+
for (const r of m.list)
|
|
520
|
+
void run(r);
|
|
521
|
+
}
|
|
453
522
|
else if (m?.t === "drain")
|
|
454
523
|
drain("asked");
|
|
455
524
|
else if (m?.t === "cancel" && typeof m.id === "number") {
|
package/dist/client.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { type Bundle } from "./bundle.js";
|
|
|
5
5
|
import { type PtyExit, type PtySession } from "./pty.js";
|
|
6
6
|
import { type SshTunnel } from "./ssh.js";
|
|
7
7
|
import type * as M from "./models.gen.js";
|
|
8
|
+
import { isKeyedCreate } from "./keyed.js";
|
|
8
9
|
import { type ConnectRequest, type ConnectTicket, type GithubConnect, type GithubDisconnected, type GithubRepos, type GithubStatus, type GithubUntracked } from "./github.js";
|
|
9
10
|
import { type GitlabConnect, type GitlabDisconnected, type GitlabRepos, type GitlabStatus, type GitlabUntracked } from "./gitlab.js";
|
|
10
11
|
export type FetchLike = typeof globalThis.fetch;
|
|
@@ -1882,12 +1883,7 @@ export declare function errorFor(code: string, message: string, fix: string, ext
|
|
|
1882
1883
|
category?: string;
|
|
1883
1884
|
retryable?: boolean;
|
|
1884
1885
|
}): PromigenceError;
|
|
1885
|
-
|
|
1886
|
-
* Is `method path` a create that takes an `Idempotency-Key`? `path` is relative to `/v1` and may
|
|
1887
|
-
* carry a query string. The list is the API reference's (generated from the operations that
|
|
1888
|
-
* document the header), so a create the API keys is never sent unkeyed by this client.
|
|
1889
|
-
*/
|
|
1890
|
-
export declare function isKeyedCreate(method: string, path: string): boolean;
|
|
1886
|
+
export { isKeyedCreate };
|
|
1891
1887
|
/** A sandbox id as a request names it: a non-empty string, or refused before anything is sent. */
|
|
1892
1888
|
export declare function checkSandboxId(sandboxId: unknown, call: string): asserts sandboxId is string;
|
|
1893
1889
|
/** A spend cap in USD: a finite number, 0 or more. A negative one used to be sent and echoed back as "$-1.00". */
|
|
@@ -2006,6 +2002,7 @@ export declare class PromigenceClient {
|
|
|
2006
2002
|
private readExtras;
|
|
2007
2003
|
private guardDispatcher;
|
|
2008
2004
|
private dispatcherFor;
|
|
2005
|
+
private againKeyed;
|
|
2009
2006
|
request<T>(opts: RequestOpts): Promise<T>;
|
|
2010
2007
|
/**
|
|
2011
2008
|
* A request whose body — in either direction — is **bytes, not JSON** (`files get|put`).
|
|
@@ -2066,6 +2063,7 @@ export declare class PromigenceClient {
|
|
|
2066
2063
|
signal?: AbortSignal;
|
|
2067
2064
|
}) => Promise<M.TemplateDetail>;
|
|
2068
2065
|
};
|
|
2066
|
+
private group_templates;
|
|
2069
2067
|
me(opts?: {
|
|
2070
2068
|
signal?: AbortSignal;
|
|
2071
2069
|
}): Promise<MeResponse>;
|
|
@@ -2114,6 +2112,7 @@ export declare class PromigenceClient {
|
|
|
2114
2112
|
/** `POST /referrals/apply` — apply a referral code (an owner's key, before the first paid invoice). */
|
|
2115
2113
|
applyReferral: (code: string) => Promise<ReferralApplied>;
|
|
2116
2114
|
};
|
|
2115
|
+
private group_billing;
|
|
2117
2116
|
/**
|
|
2118
2117
|
* This key's API keys. With an API key the list is the key's own project's; `all` includes
|
|
2119
2118
|
* revoked ones.
|
|
@@ -2137,6 +2136,7 @@ export declare class PromigenceClient {
|
|
|
2137
2136
|
*/
|
|
2138
2137
|
revoke: (keyId: string) => Promise<KeyRecord>;
|
|
2139
2138
|
};
|
|
2139
|
+
private group_keys;
|
|
2140
2140
|
/** The organization this key belongs to, its projects, members and pending invites. */
|
|
2141
2141
|
readonly orgs: {
|
|
2142
2142
|
/** `GET /orgs` — with an API key, the key's own organization. */
|
|
@@ -2175,10 +2175,12 @@ export declare class PromigenceClient {
|
|
|
2175
2175
|
rename: (org: string, project: string, name: string) => Promise<ProjectRecord>;
|
|
2176
2176
|
};
|
|
2177
2177
|
};
|
|
2178
|
+
private group_orgs;
|
|
2178
2179
|
readonly credits: {
|
|
2179
2180
|
/** `GET /credits/offer` — claimable (how much, until when), claimed, being checked, or none. */
|
|
2180
2181
|
offer: () => Promise<CreditOffer>;
|
|
2181
2182
|
};
|
|
2183
|
+
private group_credits;
|
|
2182
2184
|
/**
|
|
2183
2185
|
* The GitHub connection: install the platform's GitHub App once, then build snapshots from the
|
|
2184
2186
|
* repositories it can read (`snapshots.create({ repo: "github:owner/name", ref })`).
|
|
@@ -2206,6 +2208,7 @@ export declare class PromigenceClient {
|
|
|
2206
2208
|
/** `DELETE /integrations/github/tracks/:id` — the snapshot stays; pushes stop rebuilding it. */
|
|
2207
2209
|
untrack: (trackId: string) => Promise<GithubUntracked>;
|
|
2208
2210
|
};
|
|
2211
|
+
private group_github;
|
|
2209
2212
|
/**
|
|
2210
2213
|
* The GitLab connection: authorize the platform's GitLab application once (read-only), have an
|
|
2211
2214
|
* owner confirm it, then build snapshots from the projects it can read
|
|
@@ -2235,6 +2238,7 @@ export declare class PromigenceClient {
|
|
|
2235
2238
|
/** `DELETE /integrations/gitlab/tracks/:id` — the snapshot stays; new commits stop rebuilding it. */
|
|
2236
2239
|
untrack: (trackId: string) => Promise<GitlabUntracked>;
|
|
2237
2240
|
};
|
|
2241
|
+
private group_gitlab;
|
|
2238
2242
|
readonly runs: {
|
|
2239
2243
|
/** `POST /runs` — returns immediately; sandboxes start `queued`. */
|
|
2240
2244
|
start: (opts: RunStartOpts) => Promise<RunStartResponse>;
|
|
@@ -2328,6 +2332,7 @@ export declare class PromigenceClient {
|
|
|
2328
2332
|
*/
|
|
2329
2333
|
waitDone: (runId: string, opts?: WaitOpts) => Promise<WaitRunResult>;
|
|
2330
2334
|
};
|
|
2335
|
+
private group_runs;
|
|
2331
2336
|
/**
|
|
2332
2337
|
* The loop behind `waitReady` / `waitDone`.
|
|
2333
2338
|
*
|
|
@@ -2805,6 +2810,7 @@ export declare class PromigenceClient {
|
|
|
2805
2810
|
};
|
|
2806
2811
|
}) => Promise<ExecOutput>;
|
|
2807
2812
|
};
|
|
2813
|
+
private group_sandboxes;
|
|
2808
2814
|
/** Bound helpers for one sandbox (kept from the 0.0.0 shape). */
|
|
2809
2815
|
sandbox(id: string): {
|
|
2810
2816
|
id: string;
|
|
@@ -2874,6 +2880,7 @@ export declare class PromigenceClient {
|
|
|
2874
2880
|
deleted: boolean;
|
|
2875
2881
|
}>;
|
|
2876
2882
|
};
|
|
2883
|
+
private group_secrets;
|
|
2877
2884
|
/**
|
|
2878
2885
|
* Container images, as far as we need to know about them: what digest does this tag name?
|
|
2879
2886
|
*/
|
|
@@ -2901,6 +2908,7 @@ export declare class PromigenceClient {
|
|
|
2901
2908
|
registrySecret?: string;
|
|
2902
2909
|
}) => Promise<ResolvedImage>;
|
|
2903
2910
|
};
|
|
2911
|
+
private group_images;
|
|
2904
2912
|
readonly captures: {
|
|
2905
2913
|
/**
|
|
2906
2914
|
* `DELETE /captures/:snapshot_id` — destroy a preserved failure now, before it expires.
|
|
@@ -2916,6 +2924,7 @@ export declare class PromigenceClient {
|
|
|
2916
2924
|
deleted_at: string;
|
|
2917
2925
|
}>;
|
|
2918
2926
|
};
|
|
2927
|
+
private group_captures;
|
|
2919
2928
|
readonly snapshots: {
|
|
2920
2929
|
/**
|
|
2921
2930
|
* `POST /snapshots` — 202 with a `build_id`, or 200 with the existing snapshot when an
|
|
@@ -3011,5 +3020,6 @@ export declare class PromigenceClient {
|
|
|
3011
3020
|
record?: SnapshotRecord;
|
|
3012
3021
|
}>;
|
|
3013
3022
|
};
|
|
3023
|
+
private group_snapshots;
|
|
3014
3024
|
}
|
|
3015
3025
|
export declare function toCommandResult(r: ExecResponse): CommandResult;
|