@parcha/agentrun-computer 0.1.0-beta.39 → 0.1.0-beta.41
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/README.md +56 -21
- package/box/Dockerfile +11 -58
- package/box/README.md +15 -2
- package/box/build-daytona.py +4 -2
- package/box/build-e2b.mjs +1 -1
- package/box/install.sh +148 -0
- package/box/recipe.mjs +12 -10
- package/dist/agent37.js +2 -1
- package/dist/attach.d.ts +46 -1
- package/dist/attach.js +48 -4
- package/dist/box-image.d.ts +2 -0
- package/dist/box-image.js +10 -0
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/computerd.json +2 -2
- package/dist/conformance/cases/isolation.js +17 -1
- package/dist/conformance/cases/lifetime.js +30 -0
- package/dist/conformance/cases/provider.js +63 -1
- package/dist/conformance/cli.js +27 -5
- package/dist/conformance/daytona.d.ts +25 -0
- package/dist/conformance/daytona.js +26 -1
- package/dist/conformance/exec-stream.d.ts +37 -7
- package/dist/conformance/exec-stream.js +349 -89
- package/dist/conformance/report.js +3 -0
- package/dist/conformance/runner.js +134 -12
- package/dist/conformance/sweep.d.ts +7 -2
- package/dist/conformance/sweep.js +17 -7
- package/dist/conformance/types.d.ts +42 -0
- package/dist/daytona.d.ts +8 -1
- package/dist/daytona.js +126 -101
- package/dist/descriptor.d.ts +22 -1
- package/dist/descriptor.js +18 -0
- package/dist/descriptors/daytona.d.ts +12 -3
- package/dist/descriptors/daytona.js +15 -7
- package/dist/descriptors/index.d.ts +8 -1
- package/dist/e2b.js +1 -1
- package/dist/host.d.ts +91 -26
- package/dist/host.js +5 -0
- package/dist/hosted/framed-exec.d.ts +38 -0
- package/dist/hosted/framed-exec.js +119 -0
- package/dist/hosted/process.d.ts +13 -5
- package/dist/hosted/process.js +39 -14
- package/dist/hosted/provider.d.ts +48 -6
- package/dist/hosted/provider.js +435 -64
- package/dist/hosted/rest.d.ts +29 -0
- package/dist/hosted/rest.js +91 -6
- package/dist/hosted/scripts.d.ts +58 -0
- package/dist/hosted/scripts.js +138 -1
- package/dist/hosted/ssh-exec.d.ts +7 -6
- package/dist/hosted/ssh-exec.js +35 -52
- package/dist/hosted/values.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/kinds.d.ts +2 -0
- package/dist/modal.js +21 -8
- package/dist/providers.d.ts +4 -2
- package/package.json +1 -1
|
@@ -85,9 +85,12 @@ function whenAborted(signal) {
|
|
|
85
85
|
*/
|
|
86
86
|
export async function runConformance(provider, options) {
|
|
87
87
|
// Given no cases, the run takes its computer's suite: a browser's own cases, as the CLI does, else the suite's.
|
|
88
|
-
const { image, only, kind, signal, cases = casesFor(provider.capabilities().kind), drifted, planted, mountFor, onResult, notes, caseTimeoutMs = 180_000, patience = 30_000, cleanupTimeoutMs = 60_000, fixture, gpu } = options;
|
|
88
|
+
const { image, only, kind, signal, cases = casesFor(provider.capabilities().kind), drifted, planted, dial, mountFor, onResult, notes, caseTimeoutMs = 180_000, patience = 30_000, cleanupTimeoutMs = 60_000, fixture, gpu, long = false, concurrency } = options;
|
|
89
89
|
if (kind !== undefined && only !== undefined)
|
|
90
90
|
throw new TypeError("a run takes kind and only apart: a kind runs its own cases");
|
|
91
|
+
if (concurrency !== undefined && !(Number.isSafeInteger(concurrency) && concurrency >= 1))
|
|
92
|
+
throw new TypeError(`concurrency is a whole number of computers, 1 or more; got ${concurrency}`);
|
|
93
|
+
const cap = concurrency ?? Infinity;
|
|
91
94
|
// What the provider declares of itself: as given, else the kind registry's entry for its id (health.declared), its
|
|
92
95
|
// parked configurations with its offered ones: a parked one built for the suite is held to its own declaration.
|
|
93
96
|
const entry = PROVIDERS.find((one) => one.id === provider.id);
|
|
@@ -97,7 +100,6 @@ export async function runConformance(provider, options) {
|
|
|
97
100
|
throw new TypeError(kindProblem);
|
|
98
101
|
const fetcher = options.fetch ?? ((url, init) => fetch(url, init));
|
|
99
102
|
const dialer = options.cdp ?? dialCdp;
|
|
100
|
-
const clock = options.clock ?? { now: () => Date.now(), sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)) };
|
|
101
103
|
const run = randomBytes(6).toString("hex");
|
|
102
104
|
const runLabels = { [RUN_LABEL]: run };
|
|
103
105
|
const capabilities = provider.capabilities();
|
|
@@ -119,6 +121,7 @@ export async function runConformance(provider, options) {
|
|
|
119
121
|
core: "fail",
|
|
120
122
|
undeclared: [],
|
|
121
123
|
cleanup: { deleted: [], left: [], errors: [], late: [] },
|
|
124
|
+
computers: { peak: 0, ...(concurrency === undefined ? {} : { cap: concurrency }) },
|
|
122
125
|
...(notes !== undefined && notes.length > 0 ? { notes: [...notes] } : {}),
|
|
123
126
|
};
|
|
124
127
|
const deleted = new Set();
|
|
@@ -143,17 +146,111 @@ export async function runConformance(provider, options) {
|
|
|
143
146
|
...extra,
|
|
144
147
|
labels: { ...extra.labels, ...runLabels },
|
|
145
148
|
});
|
|
149
|
+
/**
|
|
150
|
+
* The computers alive now, by the request that makes each (its retries share it), with its role: held from the
|
|
151
|
+
* request's first create until its computer is deleted, or until its creates settle with none made. One whose delete
|
|
152
|
+
* failed is `lost`: it may still be there, so it is never freed. A create past the cap waits for one to go.
|
|
153
|
+
*/
|
|
154
|
+
const alive = new Map();
|
|
155
|
+
/** Each computer the run made, by name: the request that made it. */
|
|
156
|
+
const madeBy = new Map();
|
|
157
|
+
/** The providers built with planted secrets: their creates are not capped (attempt). */
|
|
158
|
+
const plantedBy = new WeakSet();
|
|
159
|
+
/** The creates of each request still unanswered. */
|
|
160
|
+
const flying = new Map();
|
|
161
|
+
const waiting = [];
|
|
162
|
+
const free = (request) => {
|
|
163
|
+
if (alive.delete(request))
|
|
164
|
+
for (const wake of waiting.splice(0))
|
|
165
|
+
wake();
|
|
166
|
+
};
|
|
167
|
+
/** Deletes the computer, its errors in the report; true once it is deleted. */
|
|
146
168
|
const release = async (ref, by = provider) => {
|
|
169
|
+
let gone = false;
|
|
147
170
|
try {
|
|
148
171
|
const released = await within(by.release(ref, "delete"), cleanupTimeoutMs, `release ${ref.name}`);
|
|
149
172
|
if (released.ok)
|
|
150
173
|
deleted.add(ref.name);
|
|
151
174
|
else
|
|
152
175
|
report.cleanup.errors.push(`release ${ref.name}: ${released.error.code}: ${released.error.message}`);
|
|
176
|
+
gone = released.ok;
|
|
153
177
|
}
|
|
154
178
|
catch (error) {
|
|
155
179
|
report.cleanup.errors.push(words(error).startsWith(`release ${ref.name}`) ? words(error) : `release ${ref.name} threw: ${words(error)}`);
|
|
156
180
|
}
|
|
181
|
+
const request = madeBy.get(ref.name);
|
|
182
|
+
if (request !== undefined) {
|
|
183
|
+
madeBy.delete(ref.name);
|
|
184
|
+
if (gone)
|
|
185
|
+
free(request);
|
|
186
|
+
else if (alive.has(request))
|
|
187
|
+
alive.get(request).lost = true;
|
|
188
|
+
}
|
|
189
|
+
return gone;
|
|
190
|
+
};
|
|
191
|
+
/** Whether the case running now uses the run's computer: while it does, the run's computer is not deleted for room. */
|
|
192
|
+
let usingShared = false;
|
|
193
|
+
/**
|
|
194
|
+
* Room for `request`'s computer, of `role`, under the cap; a retry of a request that holds room already has it. While
|
|
195
|
+
* there is none, the run's computer makes way when the case running doesn't use it (and nothing more is made when it
|
|
196
|
+
* can't be deleted); a case whose own computers, the run's computer it uses and those that could not be deleted fill
|
|
197
|
+
* the cap fails in words; else the create waits for a computer to be deleted, or for `signal`.
|
|
198
|
+
*/
|
|
199
|
+
const hold = async (request, role, signal) => {
|
|
200
|
+
while (!alive.has(request) && alive.size >= cap) {
|
|
201
|
+
if (sharedRef !== undefined && !usingShared) {
|
|
202
|
+
const ref = sharedRef;
|
|
203
|
+
[shared, sharedRef] = [undefined, undefined];
|
|
204
|
+
if (!(await release(ref)))
|
|
205
|
+
throw new Error(`the run's computer ${ref.name} could not be deleted to make room, so --concurrency ${cap} lets no other be made`);
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
const held = [...alive.values()];
|
|
209
|
+
if (held.every((one) => one.lost || one.role === role || (one.role === "shared" && usingShared))) {
|
|
210
|
+
const lost = held.filter((one) => one.lost).length;
|
|
211
|
+
throw new Error(lost > 0
|
|
212
|
+
? `--concurrency ${cap} is full: ${lost} of the run's computers could not be deleted, so no other is made`
|
|
213
|
+
: `this case needs more than ${cap} ${cap === 1 ? "computer" : "computers"} alive at once, and --concurrency ${cap} caps them`);
|
|
214
|
+
}
|
|
215
|
+
signal?.throwIfAborted();
|
|
216
|
+
await new Promise((resolve) => {
|
|
217
|
+
const wake = () => {
|
|
218
|
+
signal?.removeEventListener("abort", wake);
|
|
219
|
+
resolve();
|
|
220
|
+
};
|
|
221
|
+
waiting.push(wake);
|
|
222
|
+
signal?.addEventListener("abort", wake, { once: true });
|
|
223
|
+
});
|
|
224
|
+
signal?.throwIfAborted();
|
|
225
|
+
}
|
|
226
|
+
if (alive.has(request))
|
|
227
|
+
return;
|
|
228
|
+
alive.set(request, { role });
|
|
229
|
+
report.computers.peak = Math.max(report.computers.peak, alive.size);
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* A create of `request`, under the cap (hold): the room it holds is the computer's it made until that computer's
|
|
233
|
+
* delete, or is freed once every create of the request has answered with none made.
|
|
234
|
+
*/
|
|
235
|
+
const capped = async (request, role, signal, create) => {
|
|
236
|
+
flying.set(request, (flying.get(request) ?? 0) + 1);
|
|
237
|
+
try {
|
|
238
|
+
await hold(request, role, signal);
|
|
239
|
+
const created = await create();
|
|
240
|
+
if (created.ok && !madeBy.has(created.value.name))
|
|
241
|
+
madeBy.set(created.value.name, request);
|
|
242
|
+
return created;
|
|
243
|
+
}
|
|
244
|
+
finally {
|
|
245
|
+
const left = flying.get(request) - 1;
|
|
246
|
+
if (left > 0)
|
|
247
|
+
flying.set(request, left);
|
|
248
|
+
else {
|
|
249
|
+
flying.delete(request);
|
|
250
|
+
if (![...madeBy.values()].includes(request))
|
|
251
|
+
free(request);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
157
254
|
};
|
|
158
255
|
/** Each computer the run made, by name: its role, "shared" or the id of the case that made it. */
|
|
159
256
|
const roles = new Map();
|
|
@@ -185,14 +282,21 @@ export async function runConformance(provider, options) {
|
|
|
185
282
|
return;
|
|
186
283
|
report.daemons.push({ computer, role: roles.get(computer) ?? role, version: hello.version, os: hello.os, arch: hello.arch, ...(hello.fence === undefined ? {} : { fence: hello.fence }) });
|
|
187
284
|
};
|
|
188
|
-
/**
|
|
285
|
+
/**
|
|
286
|
+
* The run's shared computer, made the first time a case needs it or the daemon's hello, and again after it made way
|
|
287
|
+
* for a case's own under the cap (hold); `hello` is its first one's.
|
|
288
|
+
*/
|
|
189
289
|
let shared;
|
|
190
290
|
let sharedRef;
|
|
291
|
+
let hello;
|
|
292
|
+
let made = 0;
|
|
191
293
|
const getShared = () => (shared ??= (async () => {
|
|
192
294
|
// The run's signal ends the wait at once (Ctrl-C during setup) and reaches the create; a computer that arrives
|
|
193
295
|
// after it is deleted as it lands (lateCreate).
|
|
194
296
|
const stop = new AbortController();
|
|
195
|
-
const
|
|
297
|
+
const both = signal ? AbortSignal.any([signal, stop.signal]) : stop.signal;
|
|
298
|
+
const requestId = `${run}/shared${++made > 1 ? `/${made}` : ""}`;
|
|
299
|
+
const creating = capped(requestId, "shared", both, () => provider.create(spec(), { signal: both, requestId }));
|
|
196
300
|
let created;
|
|
197
301
|
try {
|
|
198
302
|
created = await within(creating, caseTimeoutMs, "create", signal);
|
|
@@ -219,6 +323,7 @@ export async function runConformance(provider, options) {
|
|
|
219
323
|
return { error: `connect: ${connected.error.code}: ${connected.error.message}` };
|
|
220
324
|
await bounded(connected.value.close(), CLOSE_MS);
|
|
221
325
|
sawHello(created.value.name, connected.value.hello, "shared");
|
|
326
|
+
hello ??= connected.value.hello;
|
|
222
327
|
return { ref: created.value, hello: connected.value.hello };
|
|
223
328
|
})().catch((error) => ({ error: `the provider threw: ${words(error)}` })));
|
|
224
329
|
/** Why a case cannot run here, or undefined when everything it needs is declared. */
|
|
@@ -232,7 +337,8 @@ export async function runConformance(provider, options) {
|
|
|
232
337
|
else if (GROUP_NAMES.has(need)) {
|
|
233
338
|
if (!groups.includes(need))
|
|
234
339
|
return `the provider does not declare ${need}`;
|
|
235
|
-
|
|
340
|
+
// The run's first computer's hello: one that made way under the cap is not made again to be read.
|
|
341
|
+
const got = hello === undefined ? await getShared() : { hello };
|
|
236
342
|
if ("hello" in got && !(Array.isArray(got.hello.groups) && got.hello.groups.includes(need))) {
|
|
237
343
|
return `the ${capabilities.daemon === "none" ? "computer's" : "daemon's"} hello does not declare ${need}`;
|
|
238
344
|
}
|
|
@@ -282,6 +388,7 @@ export async function runConformance(provider, options) {
|
|
|
282
388
|
});
|
|
283
389
|
if (signal?.aborted)
|
|
284
390
|
return result("fail", "not run: the run was aborted");
|
|
391
|
+
usingShared = (c.computer ?? "shared") === "shared";
|
|
285
392
|
const why = await missing(c.needs);
|
|
286
393
|
if (why !== undefined) {
|
|
287
394
|
const lacking = [];
|
|
@@ -348,9 +455,13 @@ export async function runConformance(provider, options) {
|
|
|
348
455
|
};
|
|
349
456
|
/** Each create of the case is its own request: the run, the case and the create's count. */
|
|
350
457
|
let creates = 0;
|
|
351
|
-
/**
|
|
458
|
+
/**
|
|
459
|
+
* create through by, kept: what it gives is deleted when the case ends, or as it comes after that. A create with
|
|
460
|
+
* planted secrets is outside the cap: it can't use the account, so it holds no room (one it makes anyway fails its case).
|
|
461
|
+
*/
|
|
352
462
|
const attempt = (whole, by = provider, requestId = `${run}/${c.id}/${++creates}`) => {
|
|
353
|
-
const
|
|
463
|
+
const make = () => by.create(whole, { signal: caseSignal, requestId });
|
|
464
|
+
const creating = (plantedBy.has(by) ? make() : capped(requestId, c.id, caseSignal, make)).then((created) => {
|
|
354
465
|
noteCreated(created, c.id);
|
|
355
466
|
// A retry of one request answers the computer the first attempt made: it is tracked once.
|
|
356
467
|
if (created.ok && !refs.some((one) => one.ref.id === created.value.id))
|
|
@@ -443,7 +554,8 @@ export async function runConformance(provider, options) {
|
|
|
443
554
|
sockets.push(socket);
|
|
444
555
|
return socket;
|
|
445
556
|
},
|
|
446
|
-
clock,
|
|
557
|
+
// The wall clock's wait ends with the case (its timeout, or the run's abort), so no timer outlives the run.
|
|
558
|
+
clock: options.clock ?? { now: () => Date.now(), sleep: (ms) => sleep(ms, undefined, { signal: caseSignal }).catch(() => undefined) },
|
|
447
559
|
async drifted() {
|
|
448
560
|
if (drifted === undefined)
|
|
449
561
|
return t.skip("no drifted provider was given: a provider module exports createDriftedProvider() for the drift cases");
|
|
@@ -453,7 +565,13 @@ export async function runConformance(provider, options) {
|
|
|
453
565
|
async planted() {
|
|
454
566
|
if (planted === undefined)
|
|
455
567
|
return t.skip("no provider with planted secrets was given: the provider takes no secret, or its module lists none in ENV");
|
|
456
|
-
|
|
568
|
+
const got = await planted();
|
|
569
|
+
plantedBy.add(got.provider);
|
|
570
|
+
return got;
|
|
571
|
+
},
|
|
572
|
+
async dial() {
|
|
573
|
+
t.assert(dial !== undefined, "the provider's machines dial the server, and the run was given no server for them: a conformance module exports dialKit() (ConformanceOptions.dial)");
|
|
574
|
+
return await dial();
|
|
457
575
|
},
|
|
458
576
|
async runFolder(kind) {
|
|
459
577
|
const none = `the run was given no run folder for mount kind ${kind}`;
|
|
@@ -474,6 +592,10 @@ export async function runConformance(provider, options) {
|
|
|
474
592
|
return t.skip("the run named no GPU: give --gpu <type>[:<count>] (or options.gpu), one the provider declares in capabilities().gpu");
|
|
475
593
|
return { type: gpu.type, count: gpu.count };
|
|
476
594
|
},
|
|
595
|
+
long(what) {
|
|
596
|
+
if (!long)
|
|
597
|
+
t.skip(`a long case (${what}): run with --long (or options.long), as the live sweep does`);
|
|
598
|
+
},
|
|
477
599
|
async exec(argv, extra = {}, client = t.client) {
|
|
478
600
|
const ran = unwrap(await client.call("exec.run", { argv, timeoutMs: patience, ...extra }, { signal: caseSignal }), `exec.run ${show(argv)}`);
|
|
479
601
|
const decode = (base64) => Buffer.from(base64, "base64").toString("utf8");
|
|
@@ -595,7 +717,7 @@ export async function runConformance(provider, options) {
|
|
|
595
717
|
for (const what of pending.values()) {
|
|
596
718
|
report.cleanup.errors.push(`${what} did not settle within ${cleanupTimeoutMs / 1000} s of the run's end: what it makes may be left`);
|
|
597
719
|
}
|
|
598
|
-
await cleanup(provider, capabilities.lifetime, runLabels, report, deleted, cleanupTimeoutMs);
|
|
720
|
+
await cleanup(provider, capabilities.lifetime, runLabels, report, deleted, cleanupTimeoutMs, image);
|
|
599
721
|
}
|
|
600
722
|
// A Core case skipped for an optional group the computer does not declare, or written for another system, is not part
|
|
601
723
|
// of Core's verdict.
|
|
@@ -611,7 +733,7 @@ export async function runConformance(provider, options) {
|
|
|
611
733
|
return report;
|
|
612
734
|
}
|
|
613
735
|
/** Sweeps a janitor provider by the run's label, past every deadline, and lists the label to show nothing is left. */
|
|
614
|
-
async function cleanup(provider, lifetime, labels, report, deleted, ms) {
|
|
736
|
+
async function cleanup(provider, lifetime, labels, report, deleted, ms, image) {
|
|
615
737
|
try {
|
|
616
738
|
if (lifetime === "janitor") {
|
|
617
739
|
const stop = new AbortController();
|
|
@@ -636,7 +758,7 @@ async function cleanup(provider, lifetime, labels, report, deleted, ms) {
|
|
|
636
758
|
if (host !== undefined && typeof host.list === "function") {
|
|
637
759
|
const { sweepMachines } = await import("./sweep.js");
|
|
638
760
|
const said = [];
|
|
639
|
-
const swept = await within(sweepMachines(host, { labels, waitMs: ms, onWords: (words) => said.push(words) }), ms * 2, "the sweep of the run's machines");
|
|
761
|
+
const swept = await within(sweepMachines(host, { labels, waitMs: ms, image, onWords: (words) => said.push(words) }), ms * 2, "the sweep of the run's machines");
|
|
640
762
|
report.cleanup.errors.push(...said.map((words) => `sweep: ${words}`));
|
|
641
763
|
if (!swept.ok)
|
|
642
764
|
report.cleanup.errors.push(`sweep: ${swept.error.code}: ${swept.error.message}`);
|
|
@@ -20,15 +20,20 @@ export interface SweepMachinesOptions {
|
|
|
20
20
|
requestMs?: number;
|
|
21
21
|
/** One whole listing's bound; default 60 s. */
|
|
22
22
|
listMs?: number;
|
|
23
|
-
/** Told, in words, of a machine not deleted or still there. */
|
|
23
|
+
/** Told, in words, of a machine not read, not deleted or still there. */
|
|
24
24
|
onWords?: (words: string) => void;
|
|
25
|
+
/**
|
|
26
|
+
* The image the run's computers started from. With facts.labels "machine", labels are read only in a machine of this
|
|
27
|
+
* image or a box image (HostedOptions.image): one of another image is never read, so never swept.
|
|
28
|
+
*/
|
|
29
|
+
image?: string;
|
|
25
30
|
}
|
|
26
31
|
/**
|
|
27
32
|
* The sweep over host: every machine listed with agentrun.computer=1 and `labels`, not in `before`, that carries a
|
|
28
33
|
* conformance run's label is deleted and read back gone; one without it is left alone and counted. A listing the
|
|
29
34
|
* vendor refused is the error, with nothing deleted.
|
|
30
35
|
*/
|
|
31
|
-
export declare function sweepMachines(host: MachineHost, { labels, before, waitMs, pollMs, requestMs, listMs, onWords }?: SweepMachinesOptions): Promise<Result<SweepCounts>>;
|
|
36
|
+
export declare function sweepMachines(host: MachineHost, { labels, before, waitMs, pollMs, requestMs, listMs, onWords, image }?: SweepMachinesOptions): Promise<Result<SweepCounts>>;
|
|
32
37
|
/** A stream as main writes to it: done is called once the text is handed on. */
|
|
33
38
|
export interface Writer {
|
|
34
39
|
write(text: string, done?: (error?: Error | null) => void): unknown;
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
// labelled machines with no conformance label, which another user of the account made during the run: never touched. A
|
|
13
13
|
// machine in <file> is never touched either: no call names it, and a before file of another provider is refused, as is
|
|
14
14
|
// one listed elsewhere for a provider whose module names where it lists (sweepScope: an app and a server), since
|
|
15
|
-
// every machine there would read as new.
|
|
15
|
+
// every machine there would read as new. A host that keeps its labels in the machine has them read only in a machine
|
|
16
|
+
// of a box image or of --after's --image <image>, the image the run started from.
|
|
16
17
|
// Exit 0 when every swept machine is gone, 1 when one is still there, 2 on a usage error, a before file it cannot read,
|
|
17
18
|
// missing settings, or a listing the vendor refused (nothing is deleted then). It makes nothing, so it needs no live switch.
|
|
18
19
|
//
|
|
@@ -31,8 +32,8 @@ import { RUN_LABEL } from "./runner.js";
|
|
|
31
32
|
* conformance run's label is deleted and read back gone; one without it is left alone and counted. A listing the
|
|
32
33
|
* vendor refused is the error, with nothing deleted.
|
|
33
34
|
*/
|
|
34
|
-
export async function sweepMachines(host, { labels = {}, before = new Set(), waitMs = 60_000, pollMs = 2_000, requestMs = 30_000, listMs = 60_000, onWords = () => { } } = {}) {
|
|
35
|
-
const listed = await foundBy(host, "the listing", { ...labels, [COMPUTER_LABEL]: "1" }, { listMs, requestMs });
|
|
35
|
+
export async function sweepMachines(host, { labels = {}, before = new Set(), waitMs = 60_000, pollMs = 2_000, requestMs = 30_000, listMs = 60_000, onWords = () => { }, image } = {}) {
|
|
36
|
+
const listed = await foundBy(host, "the listing", { ...labels, [COMPUTER_LABEL]: "1" }, { listMs, requestMs, image, onNote: ({ computer, note }) => onWords(`${computer} was not read: ${note}`) });
|
|
36
37
|
if (!listed.ok)
|
|
37
38
|
return listed;
|
|
38
39
|
const added = listed.value.filter((machine) => !before.has(machine.id));
|
|
@@ -61,6 +62,8 @@ const USAGE = `usage: node packages/computer/dist/conformance/sweep.js --provide
|
|
|
61
62
|
--after <file> delete every machine listed with ${COMPUTER_LABEL}=1 and ${RUN_LABEL} whose id is not in <file>, read
|
|
62
63
|
each back until the vendor no longer has it (up to 60 s each), and print
|
|
63
64
|
{"swept":n,"gone":m,"stillThere":[ids],"leftAlone":k}; a new one with no ${RUN_LABEL} is left alone
|
|
65
|
+
--image <image> with --after, for a host that keeps its labels in the machine: the image the run's computers started
|
|
66
|
+
from, read beside the box images (a machine of any other image is never read, so never swept)
|
|
64
67
|
settings: the provider's conformance module's (COMPUTER_<VENDOR>_*), never the vendor's own names
|
|
65
68
|
exit: 0 every swept machine is gone, 1 one is still there, 2 usage error, unreadable before file, no settings, or a refused listing`;
|
|
66
69
|
class Usage extends Error {
|
|
@@ -68,20 +71,27 @@ class Usage extends Error {
|
|
|
68
71
|
const write = (stream, text) => new Promise((resolve) => void stream.write(text, () => resolve()));
|
|
69
72
|
function parse(argv) {
|
|
70
73
|
let provider;
|
|
74
|
+
let image;
|
|
71
75
|
let found;
|
|
72
76
|
for (let i = 0; i < argv.length; i++) {
|
|
73
77
|
const [flag = "", inline] = (argv[i] ?? "").split(/=(.*)/s, 2);
|
|
74
|
-
if (flag !== "--before" && flag !== "--after" && flag !== "--provider")
|
|
78
|
+
if (flag !== "--before" && flag !== "--after" && flag !== "--provider" && flag !== "--image")
|
|
75
79
|
throw new Usage(`unknown option ${flag}`);
|
|
76
80
|
const value = inline ?? argv[++i];
|
|
77
81
|
if (value === undefined || value === "" || value.startsWith("--"))
|
|
78
|
-
throw new Usage(`${flag} needs a ${flag === "--provider" ? "provider id" : "file"}`);
|
|
82
|
+
throw new Usage(`${flag} needs a ${flag === "--provider" ? "provider id" : flag === "--image" ? "image" : "file"}`);
|
|
79
83
|
if (flag === "--provider") {
|
|
80
84
|
if (provider !== undefined)
|
|
81
85
|
throw new Usage("give --provider once");
|
|
82
86
|
provider = value;
|
|
83
87
|
continue;
|
|
84
88
|
}
|
|
89
|
+
if (flag === "--image") {
|
|
90
|
+
if (image !== undefined)
|
|
91
|
+
throw new Usage("give --image once");
|
|
92
|
+
image = value;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
85
95
|
if (found !== undefined)
|
|
86
96
|
throw new Usage("give --before <file> or --after <file>, one of them");
|
|
87
97
|
found = { mode: flag === "--before" ? "before" : "after", file: value };
|
|
@@ -90,7 +100,7 @@ function parse(argv) {
|
|
|
90
100
|
throw new Usage("give --provider <id>");
|
|
91
101
|
if (found === undefined)
|
|
92
102
|
throw new Usage("give --before <file> or --after <file>, one of them");
|
|
93
|
-
return { provider, ...found };
|
|
103
|
+
return { provider, ...found, ...(image === undefined ? {} : { image }) };
|
|
94
104
|
}
|
|
95
105
|
/** The ids a before file of this provider (and of this scope, when the provider names one) holds, or why it is not one. */
|
|
96
106
|
function beforeIds(file, provider, scope) {
|
|
@@ -172,7 +182,7 @@ export async function main(argv, io = {}) {
|
|
|
172
182
|
return 0;
|
|
173
183
|
}
|
|
174
184
|
const said = [];
|
|
175
|
-
const swept = await sweepMachines(host, { before, waitMs, pollMs, onWords: (words) => said.push(words) });
|
|
185
|
+
const swept = await sweepMachines(host, { before, waitMs, pollMs, image: args.image, onWords: (words) => said.push(words) });
|
|
176
186
|
for (const words of said)
|
|
177
187
|
await write(stderr, `${words}\n`);
|
|
178
188
|
if (!swept.ok) {
|
|
@@ -93,10 +93,14 @@ export interface CaseContext {
|
|
|
93
93
|
readonly declared: readonly KindCapabilities[] | undefined;
|
|
94
94
|
/** The provider built with planted secrets (ConformanceOptions.planted); skips the case when none was given. */
|
|
95
95
|
planted(): Promise<PlantedProvider>;
|
|
96
|
+
/** The server a dial host's machines reach (ConformanceOptions.dial); fails the case when none was given. */
|
|
97
|
+
dial(): Promise<DialKit>;
|
|
96
98
|
/** A fresh run's folder for this mount kind, closed when the case ends; skips the case when the run can make none. */
|
|
97
99
|
runFolder(kind: MountKind): Promise<RunFolder>;
|
|
98
100
|
/** The GPU the run pays for (options.gpu, the CLI's --gpu); skips the case when the run names none. */
|
|
99
101
|
gpu(): GpuSpec;
|
|
102
|
+
/** Skips the case, saying what makes it long, unless the run takes long cases (options.long, the CLI's --long). */
|
|
103
|
+
long(what: string): void;
|
|
100
104
|
/**
|
|
101
105
|
* Starts the run's fixture in the case's computer and waits until it is up: an app that logs each input event it
|
|
102
106
|
* gets, so a case checks what an action did with no model. It is stopped when the case ends. Skips the case when the
|
|
@@ -218,6 +222,14 @@ export interface ConformanceReport {
|
|
|
218
222
|
leftAlone: number;
|
|
219
223
|
};
|
|
220
224
|
};
|
|
225
|
+
/**
|
|
226
|
+
* The most computers the run had alive at once, each counted from its create's call until it was released or its
|
|
227
|
+
* create made none, and the cap the run was given (concurrency), when it was.
|
|
228
|
+
*/
|
|
229
|
+
computers: {
|
|
230
|
+
peak: number;
|
|
231
|
+
cap?: number;
|
|
232
|
+
};
|
|
221
233
|
/** What the provider module says of its configuration, for whoever reads the report; absent when it says nothing. */
|
|
222
234
|
notes?: string[];
|
|
223
235
|
/**
|
|
@@ -256,6 +268,23 @@ export interface ComputerDaemon {
|
|
|
256
268
|
arch: string;
|
|
257
269
|
fence?: NetworkFence;
|
|
258
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* The server a dial host's machines reach (MachineHost facts.connect "dial"), as the run stands it up: its machine
|
|
273
|
+
* tokens and its attach route, for provider.dial-token.
|
|
274
|
+
*/
|
|
275
|
+
export interface DialKit {
|
|
276
|
+
/** The machine (computer name) a token is good for at a time, as the server's attach route reads it; undefined: refused. */
|
|
277
|
+
check(token: string, at: Date): Promise<string | undefined> | string | undefined;
|
|
278
|
+
/** The token a computer's machine was given at its create (its AGENTRUN_ATTACH_TOKEN). */
|
|
279
|
+
token(ref: ComputerRef): string | undefined;
|
|
280
|
+
/** Dials the server's attach route with a token and answers its hello with this one: the code the socket closed with. */
|
|
281
|
+
dialAs(token: string, hello: HelloResult): Promise<number | undefined>;
|
|
282
|
+
/** The same provider with no public address, and how many creates its host has been asked for since. */
|
|
283
|
+
unreachable(): {
|
|
284
|
+
provider: ComputerProvider;
|
|
285
|
+
creates(): number;
|
|
286
|
+
};
|
|
287
|
+
}
|
|
259
288
|
/** A provider built with planted secrets, and the values planted: none of them may show in anything it answers. */
|
|
260
289
|
export interface PlantedProvider {
|
|
261
290
|
provider: ComputerProvider;
|
|
@@ -286,6 +315,8 @@ export interface ConformanceOptions {
|
|
|
286
315
|
* values, for health.no-key-in-errors. Without it (a provider that takes no secret), that case skips.
|
|
287
316
|
*/
|
|
288
317
|
planted?: () => Promise<PlantedProvider> | PlantedProvider;
|
|
318
|
+
/** The server a dial host's machines reach, for provider.dial-token: a dial host's run fails that case without it. */
|
|
319
|
+
dial?: () => Promise<DialKit> | DialKit;
|
|
289
320
|
/**
|
|
290
321
|
* A fresh run's folder for a mount kind, for the mount cases: the provider's conformance module makes it (a folder on
|
|
291
322
|
* the Docker host for a bind), or gives undefined for a kind it cannot make. Without it, those cases skip in words.
|
|
@@ -301,6 +332,12 @@ export interface ConformanceOptions {
|
|
|
301
332
|
patience?: number;
|
|
302
333
|
/** The longest each cleanup call (release, the sweep, list) may take; default 60 s. */
|
|
303
334
|
cleanupTimeoutMs?: number;
|
|
335
|
+
/**
|
|
336
|
+
* The most computers alive at once, for a vendor plan or rate limit that keeps fewer: a create waits for one to be
|
|
337
|
+
* released, the run's computer is deleted while a case that doesn't use it needs room (and made again for the next
|
|
338
|
+
* case that does), and a case that needs more at once than this fails in words. Default no cap.
|
|
339
|
+
*/
|
|
340
|
+
concurrency?: number;
|
|
304
341
|
/**
|
|
305
342
|
* The fixture on this machine, for the cases that check what input did: computerd-fixture for a desktop, the
|
|
306
343
|
* fixture APK for an Android phone. Without it those cases skip, and Core cannot pass where kind requires them.
|
|
@@ -311,6 +348,11 @@ export interface ConformanceOptions {
|
|
|
311
348
|
* the one it pays for; without it the case skips in words.
|
|
312
349
|
*/
|
|
313
350
|
gpu?: GpuSpec;
|
|
351
|
+
/**
|
|
352
|
+
* Run the long cases, which wait minutes on a vendor's timer (lifetime.idle leaves a computer quiet 6 min): the CLI's
|
|
353
|
+
* --long, which the live sweep gives. Without it they skip in words.
|
|
354
|
+
*/
|
|
355
|
+
long?: boolean;
|
|
314
356
|
/** fetch for screen.stream; default the global one. */
|
|
315
357
|
fetch?: CaseContext["fetch"];
|
|
316
358
|
/** How the browser cases open a CDP socket; default a WebSocket (dialCdp). Tests give a fake browser's. */
|
package/dist/daytona.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type DaytonaTimeouts = HostedTimeouts & {
|
|
|
18
18
|
retryMs: number;
|
|
19
19
|
};
|
|
20
20
|
/** The Daytona provider's options: the key and Daytona's own settings, then the shared adapter's (HostedOptions). */
|
|
21
|
-
export interface DaytonaProviderOptions extends Omit<HostedOptions, "kind" | "desktop" | "maxLifetimeMs" | "timeouts"
|
|
21
|
+
export interface DaytonaProviderOptions extends Omit<HostedOptions, "kind" | "desktop" | "maxLifetimeMs" | "timeouts"> {
|
|
22
22
|
/** The Daytona API key. The caller passes it; this provider never reads the environment and never puts it in a computer. */
|
|
23
23
|
apiKey: string;
|
|
24
24
|
/** Default https://app.daytona.io/api. */
|
|
@@ -29,6 +29,13 @@ export interface DaytonaProviderOptions extends Omit<HostedOptions, "kind" | "de
|
|
|
29
29
|
sandboxClass?: "container" | "linux-vm";
|
|
30
30
|
/** The Daytona target (region); default the organization's. */
|
|
31
31
|
target?: string;
|
|
32
|
+
/**
|
|
33
|
+
* The operator's Archil egress relay, `<IPv4 gateway>:<mount lane>:<data lane>` (HostedOptions.archilEgress, checked
|
|
34
|
+
* as the adapter checks it): for a self-hosted Daytona target whose sandboxes reach Archil only through it. With it,
|
|
35
|
+
* this provider takes an Archil mount (DAYTONA.mountsWith); without it, check() refuses one in DAYTONA_NO_ARCHIL's
|
|
36
|
+
* words, since Archil's client hangs on Daytona's hosted cloud. Set it only for such a target.
|
|
37
|
+
*/
|
|
38
|
+
archilEgress?: string;
|
|
32
39
|
/**
|
|
33
40
|
* The snapshot GPU computers are made from: one of ours, box/Dockerfile built with a GPU (box/build-daytona.py --gpu
|
|
34
41
|
* H100 prints its name, agentrun-archil-gpu-h100-<hash>), whose user is root; its GPU is the one its name says.
|