@parcha/agentrun-computer 0.1.0-beta.43 → 0.1.0-beta.45
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 +98 -12
- package/box/Dockerfile +2 -1
- package/box/build-daytona.py +12 -2
- package/box/install.sh +19 -5
- package/box/recipe.mjs +1 -1
- package/dist/attach.d.ts +13 -3
- package/dist/attach.js +182 -15
- package/dist/cloudflare.d.ts +4 -2
- package/dist/cloudflare.js +7 -3
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/computerd.json +2 -2
- package/dist/conformance/cases/files.js +7 -1
- package/dist/conformance/cases/isolation.js +4 -0
- package/dist/conformance/cases/mount.js +155 -2
- package/dist/conformance/cases/provider.js +3 -1
- package/dist/conformance/daytona.d.ts +15 -1
- package/dist/conformance/daytona.js +19 -4
- package/dist/conformance/types.d.ts +1 -1
- package/dist/daytona.d.ts +11 -2
- package/dist/daytona.js +47 -15
- package/dist/descriptor.d.ts +34 -4
- package/dist/descriptor.js +40 -6
- package/dist/descriptors/cloudflare.d.ts +14 -1
- package/dist/descriptors/cloudflare.js +7 -3
- package/dist/descriptors/daytona.d.ts +21 -3
- package/dist/descriptors/daytona.js +15 -8
- package/dist/descriptors/e2b.d.ts +1 -0
- package/dist/descriptors/e2b.js +2 -1
- package/dist/descriptors/fly.d.ts +14 -1
- package/dist/descriptors/fly.js +6 -3
- package/dist/descriptors/index.d.ts +64 -2
- package/dist/descriptors/modal.d.ts +16 -2
- package/dist/descriptors/modal.js +10 -6
- package/dist/descriptors/orgo.d.ts +3 -0
- package/dist/descriptors/orgo.js +3 -1
- package/dist/e2b.d.ts +9 -4
- package/dist/e2b.js +8 -8
- package/dist/env-proxy.d.ts +26 -0
- package/dist/env-proxy.js +97 -0
- package/dist/fly.d.ts +4 -3
- package/dist/fly.js +7 -4
- package/dist/hosted/provider.d.ts +2 -1
- package/dist/hosted/provider.js +133 -54
- package/dist/hosted/scripts.d.ts +3 -2
- package/dist/hosted/scripts.js +12 -7
- package/dist/hosted/values.d.ts +2 -5
- package/dist/hosted/values.js +2 -9
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/kinds.d.ts +4 -2
- package/dist/kinds.js +10 -1
- package/dist/modal.d.ts +5 -2
- package/dist/modal.js +8 -2
- package/dist/morph.js +15 -7
- package/dist/mount-archil.d.ts +33 -17
- package/dist/mount-archil.js +83 -36
- package/dist/mount.d.ts +16 -7
- package/dist/mount.js +13 -8
- package/dist/orgo.js +1 -1
- package/dist/provider.d.ts +1 -1
- package/dist/sync-folder.d.ts +82 -0
- package/dist/sync-folder.js +494 -0
- package/dist/tar.d.ts +34 -0
- package/dist/tar.js +203 -0
- package/package.json +1 -1
- package/dist/conformance/tar.d.ts +0 -13
- package/dist/conformance/tar.js +0 -105
package/dist/attach.js
CHANGED
|
@@ -7,6 +7,8 @@ import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
|
7
7
|
import { PassThrough, Writable } from "node:stream";
|
|
8
8
|
import { DaemonClient } from "./client.js";
|
|
9
9
|
import { kindServed } from "./kinds.js";
|
|
10
|
+
import { EPOCH_LABEL, epochOf } from "./labels.js";
|
|
11
|
+
import { checkMount, WORKSPACE } from "./mount.js";
|
|
10
12
|
import { PROTOCOL_VERSION } from "./protocol.js";
|
|
11
13
|
import { checkLifetime, kindRefusals, runLifetimeMs } from "./provider.js";
|
|
12
14
|
import { fail, ok } from "./result.js";
|
|
@@ -36,7 +38,7 @@ export const ATTACH_CLOSE = {
|
|
|
36
38
|
binary: 1003,
|
|
37
39
|
/** A frame over maxLineBytes. */
|
|
38
40
|
tooBig: 1009,
|
|
39
|
-
/** The computer's hello is not what it paired as (another kind or
|
|
41
|
+
/** The computer's hello is not what it paired as (another kind, os or arch): pair again. */
|
|
40
42
|
mismatch: 4400,
|
|
41
43
|
/** The token is unknown or was revoked: pair again. */
|
|
42
44
|
unauthorized: 4401,
|
|
@@ -110,6 +112,10 @@ export class MemoryMachineTokens {
|
|
|
110
112
|
async revoke(machine) {
|
|
111
113
|
this.#drop(machine);
|
|
112
114
|
}
|
|
115
|
+
// One process: its own attach route takes every dial, and no relay to a runner apart is refused.
|
|
116
|
+
async refused(_machine) {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
113
119
|
#drop(machine) {
|
|
114
120
|
this.#held.delete(this.#hashOf.get(machine) ?? "");
|
|
115
121
|
this.#hashOf.delete(machine);
|
|
@@ -160,12 +166,19 @@ export function helloMismatch(paired, hello) {
|
|
|
160
166
|
if (missing.length > 0) {
|
|
161
167
|
return { code: ATTACH_CLOSE.protocol, message: `${paired.name}'s driver ${hello.version} answered a protocol ${PROTOCOL_VERSION} hello without ${missing.join(", ")}: ${update}` };
|
|
162
168
|
}
|
|
163
|
-
if (paired.minted
|
|
164
|
-
|
|
165
|
-
|
|
169
|
+
if (paired.minted) {
|
|
170
|
+
// A minted desktop says linux until its display answers: its create starts the X server over this socket (desktop.ts).
|
|
171
|
+
const kind = hello.kind === paired.hello.kind || (paired.hello.kind === "desktop" && hello.kind === "linux");
|
|
172
|
+
if (!kind || hello.os !== paired.hello.os || hello.arch !== paired.hello.arch) {
|
|
173
|
+
const was = paired.hello;
|
|
174
|
+
return { code: ATTACH_CLOSE.mismatch, message: `${paired.name} was made a ${was.os} ${was.kind} on ${was.arch} and says ${hello.os} ${hello.kind} on ${hello.arch}: its token is that machine's alone` };
|
|
175
|
+
}
|
|
166
176
|
}
|
|
167
|
-
if (hello.kind !== paired.hello.kind || hello.os !== paired.hello.os) {
|
|
168
|
-
|
|
177
|
+
else if (hello.kind !== paired.hello.kind || hello.os !== paired.hello.os || (hello.arch !== paired.hello.arch && paired.hello.os !== "macos")) {
|
|
178
|
+
// Its arch too, so a token copied to a machine of another arch is refused; but a Mac's: its driver may move from
|
|
179
|
+
// amd64 (under Rosetta) to arm64 on the same machine.
|
|
180
|
+
const was = paired.hello;
|
|
181
|
+
return { code: ATTACH_CLOSE.mismatch, message: `${paired.name} paired as a ${was.os} ${was.kind} on ${was.arch} and now says ${hello.os} ${hello.kind} on ${hello.arch}: pair it again` };
|
|
169
182
|
}
|
|
170
183
|
// A computer that lacks a group its kind needs can't be given to an agent: refused at connect, in the hello's own
|
|
171
184
|
// words for what it is, never at a run's first call.
|
|
@@ -373,22 +386,109 @@ export class AttachHub {
|
|
|
373
386
|
}
|
|
374
387
|
}
|
|
375
388
|
const ATTACHED_NOTE = "an attached computer is a person's own machine: release ends the run's hold on it, and deletes nothing";
|
|
389
|
+
/** How a person makes a Linux box's /workspace, in the words a refusal names it by (attach.md, A Linux box). */
|
|
390
|
+
const WORKSPACE_FIX = `make ${WORKSPACE} a directory of computerd's user's own, mode 0700, as root: the tmpfiles.d line in spec/computer/attach.md, A Linux box (d ${WORKSPACE} 0700 <user> <user> -), then systemd-tmpfiles --create`;
|
|
391
|
+
/**
|
|
392
|
+
* Why the paired Linux box `name`'s /workspace can't hold a run's synced folder, in words naming the fix, or undefined
|
|
393
|
+
* when it can: a directory, never a link (a push follows /workspace itself, then writes only under it, opening each name
|
|
394
|
+
* with O_NOFOLLOW), of the user computerd runs as (the effective uid its /proc/self/status says), with no access for its
|
|
395
|
+
* group or others. Read through `client` (computerd's), which runs nothing on the box.
|
|
396
|
+
*/
|
|
397
|
+
async function pairedWorkspaceWhy(client, name, signal) {
|
|
398
|
+
const options = signal ? { signal } : {};
|
|
399
|
+
const status = await client.call("files.read", { path: "/proc/self/status" }, options);
|
|
400
|
+
if (!status.ok)
|
|
401
|
+
return fail(status.error.code, `reading the user computerd runs as on ${name}: ${status.error.message}`);
|
|
402
|
+
const uid = /^Uid:\s+\d+\s+(\d+)/m.exec(Buffer.from(status.value.data, "base64").toString("utf8"))?.[1];
|
|
403
|
+
if (uid === undefined)
|
|
404
|
+
return fail("invalid", `${name}'s /proc/self/status names no user computerd runs as`);
|
|
405
|
+
const folder = await client.call("files.stat", { path: WORKSPACE, follow: false }, options);
|
|
406
|
+
if (!folder.ok)
|
|
407
|
+
return folder.error.code === "not_found" ? ok(`${name} has no ${WORKSPACE}, where a run's synced folder goes: ${WORKSPACE_FIX}`) : fail(folder.error.code, `reading ${WORKSPACE} on ${name}: ${folder.error.message}`);
|
|
408
|
+
const { type, uid: owner, mode } = folder.value;
|
|
409
|
+
if (type === "symlink")
|
|
410
|
+
return ok(`${WORKSPACE} on ${name} is a link, and a run's synced folder is never written through one: remove it, then ${WORKSPACE_FIX}`);
|
|
411
|
+
if (type !== "dir")
|
|
412
|
+
return ok(`${WORKSPACE} on ${name} is a ${type}, where a run's synced folder needs a directory: remove it, then ${WORKSPACE_FIX}`);
|
|
413
|
+
if (String(owner) !== uid)
|
|
414
|
+
return ok(`${WORKSPACE} on ${name} is uid ${owner}'s, not uid ${uid}'s, the user computerd runs as: ${WORKSPACE_FIX}`);
|
|
415
|
+
if ((mode & 0o077) !== 0)
|
|
416
|
+
return ok(`${WORKSPACE} on ${name} is open to its group or others (mode ${(mode & 0o7777).toString(8).padStart(4, "0")}): ${WORKSPACE_FIX}`);
|
|
417
|
+
return ok(undefined);
|
|
418
|
+
}
|
|
419
|
+
/** Every program computerd still runs on `name` ended, waited for up to 5 s each: the box outlives its runs, and one
|
|
420
|
+
* run holds it at a time, so a program running at a claim is an earlier run's (a background program left when its hold
|
|
421
|
+
* ended at its deadline, or its runner was lost), which could read or write the next run's folder. KILL goes to its
|
|
422
|
+
* process group; init kills what left that group once its guard is gone. */
|
|
423
|
+
async function endPrograms(client, name, signal) {
|
|
424
|
+
const options = signal ? { signal } : {};
|
|
425
|
+
const words = (message) => `ending an earlier run's programs on ${name}: ${message}`;
|
|
426
|
+
for (let from = 0;;) {
|
|
427
|
+
const listed = await client.call("process.list", { from }, options);
|
|
428
|
+
if (!listed.ok)
|
|
429
|
+
return fail(listed.error.code, words(listed.error.message));
|
|
430
|
+
for (const program of listed.value.processes.filter((one) => one.running)) {
|
|
431
|
+
const killed = await client.call("process.signal", { id: program.id, signal: "KILL" }, options);
|
|
432
|
+
if (!killed.ok && killed.error.code !== "not_found")
|
|
433
|
+
return fail(killed.error.code, words(killed.error.message));
|
|
434
|
+
const waited = await client.call("process.wait", { id: program.id, timeoutMs: 5_000 }, options);
|
|
435
|
+
if (waited.ok && waited.value.running)
|
|
436
|
+
return fail("refused", words(`${program.argv.join(" ")} (pid ${program.pid}) is still running 5 s after KILL`));
|
|
437
|
+
}
|
|
438
|
+
if (!listed.value.truncated)
|
|
439
|
+
return ok(undefined);
|
|
440
|
+
from = listed.value.next;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
/** Everything in `name`'s /workspace removed, the folder itself kept (only root makes one): each entry of its first
|
|
444
|
+
* level, a directory with what it holds, a link removed and never followed (files.remove). An entry a remove can't
|
|
445
|
+
* find (a name that is not UTF-8 reaches the wire changed) is left: a whole listing with one left, or a truncated one
|
|
446
|
+
* that a pass removes nothing of, refuses the box in words naming what was left. */
|
|
447
|
+
async function emptyWorkspace(client, name, signal) {
|
|
448
|
+
const options = signal ? { signal } : {};
|
|
449
|
+
const words = (message) => `emptying ${WORKSPACE} on ${name} of an earlier run's folder: ${message}`;
|
|
450
|
+
for (;;) {
|
|
451
|
+
const listed = await client.call("files.list", { path: WORKSPACE }, options);
|
|
452
|
+
if (!listed.ok)
|
|
453
|
+
return fail(listed.error.code, words(listed.error.message));
|
|
454
|
+
const left = [];
|
|
455
|
+
for (const entry of listed.value.entries) {
|
|
456
|
+
const removed = await client.call("files.remove", { path: entry.path, recursive: true }, options);
|
|
457
|
+
if (removed.ok)
|
|
458
|
+
continue;
|
|
459
|
+
if (removed.error.code !== "not_found")
|
|
460
|
+
return fail(removed.error.code, words(removed.error.message));
|
|
461
|
+
left.push(`${entry.path}: ${removed.error.message}`);
|
|
462
|
+
}
|
|
463
|
+
// A truncated listing is listed again while a pass removes something; what is left past that stays.
|
|
464
|
+
const stuck = listed.value.truncated ? left.length === listed.value.entries.length : left.length > 0;
|
|
465
|
+
if (stuck)
|
|
466
|
+
return fail("refused", words(`${left.length} entries could not be removed (first: ${left[0] ?? "none listed"})`));
|
|
467
|
+
if (!listed.value.truncated)
|
|
468
|
+
return ok(undefined);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
376
471
|
/**
|
|
377
472
|
* One paired computer as a provider, id "attached": its capabilities are what it paired as. create claims it for a
|
|
378
473
|
* run (refused while it is offline or another run holds it) and release ends the claim; a person's machine is never
|
|
379
|
-
* made, stopped or deleted by a run.
|
|
474
|
+
* made, stopped or deleted by a run. A desktop or a phone has no init of ours, so its daemon mode is none; a Linux box
|
|
475
|
+
* (kind linux, a sandbox) runs computerd init, a child of its service manager, and takes the run's folder as a synced
|
|
476
|
+
* folder in its /workspace (pairedWorkspaceWhy), read back under the run's claim epoch.
|
|
380
477
|
*/
|
|
381
478
|
export function attachedProvider(paired, hub) {
|
|
382
479
|
/** What the computer says now: its live hello while attached (an update may add groups), else what it paired as. */
|
|
383
480
|
const now = () => hub.hello(paired.id) ?? paired.hello;
|
|
481
|
+
const box = paired.hello.kind === "linux";
|
|
384
482
|
const capabilities = () => ({
|
|
385
483
|
kind: paired.hello.kind,
|
|
386
484
|
lifetime: "vendor",
|
|
387
485
|
network: ["open"],
|
|
388
486
|
isolation: "machine",
|
|
389
487
|
os: paired.hello.os,
|
|
390
|
-
daemon: "none",
|
|
488
|
+
daemon: box ? "child" : "none",
|
|
391
489
|
groups: [...now().groups],
|
|
490
|
+
// computerd attach dials out, so no agent of ours listens on the box's TCP ports.
|
|
491
|
+
...(box ? { mount: ["sync"], vendorAgentPorts: [] } : {}),
|
|
392
492
|
maxLifetimeMs: 24 * 60 * 60_000,
|
|
393
493
|
release: ["delete"],
|
|
394
494
|
});
|
|
@@ -412,12 +512,50 @@ export function attachedProvider(paired, hub) {
|
|
|
412
512
|
const mine = (asked) => named(asked) !== undefined;
|
|
413
513
|
/** The hold each create request made: a request id makes one hold, ever. */
|
|
414
514
|
const holdsBy = new Map();
|
|
515
|
+
/** A create still readying the box's synced folder, by its request id: its hold, and the answer a retry meanwhile
|
|
516
|
+
* shares once it asks for the same labels. */
|
|
517
|
+
const startingBy = new Map();
|
|
415
518
|
const ended = () => fail("gone", `this run's hold on ${paired.name} has ended (released, or at its deadline): another run may hold it now`);
|
|
416
519
|
const unknown = (id) => fail("not_found", `no attached computer ${id}: this provider is ${paired.name}'s (${paired.id})`);
|
|
417
520
|
const offline = () => fail("gone", `${paired.name} is not attached now: open its driver, which dials this server`);
|
|
418
521
|
const holds = (labels, wanted) => Object.entries(wanted).every(([key, value]) => labels[key] === value);
|
|
419
522
|
/** Why a network other than open is refused: a run never narrows a person's own machine's network. */
|
|
420
523
|
const networkRefusal = (asked) => `${paired.name} is a person's own machine on its own network, which a run cannot block or limit: network ${JSON.stringify(asked)} is refused; ask for network "open"`;
|
|
524
|
+
/** The hold whose create took the run's folder as a synced folder (one run holds the machine at a time). */
|
|
525
|
+
let syncedHold;
|
|
526
|
+
/** The synced folder as the hold's labels record it: under the run's claim epoch. */
|
|
527
|
+
const recorded = () => {
|
|
528
|
+
const epoch = epochOf(hub.claimed(paired.id));
|
|
529
|
+
return epoch.ok ? { kind: "sync", epoch: epoch.value } : { other: `a synced folder with no epoch to read it back under (${epoch.error.message})` };
|
|
530
|
+
};
|
|
531
|
+
/** The synced folder read back from inside the box: its /workspace as pairedWorkspaceWhy holds it, else in words.
|
|
532
|
+
* `fresh`: what an earlier run left is ended and removed first, its programs (endPrograms) and then each entry of the
|
|
533
|
+
* folder (a link removed and never followed), so the run's push goes into an empty folder no other run's program
|
|
534
|
+
* reaches, as into a hosted computer's new one. */
|
|
535
|
+
const folder = async (signal, fresh = false) => {
|
|
536
|
+
const connection = hub.connection(paired.id);
|
|
537
|
+
if (connection === undefined)
|
|
538
|
+
return offline();
|
|
539
|
+
try {
|
|
540
|
+
const why = await pairedWorkspaceWhy(connection.client, paired.name, signal);
|
|
541
|
+
if (!why.ok)
|
|
542
|
+
return why;
|
|
543
|
+
if (why.value !== undefined)
|
|
544
|
+
return ok({ other: why.value });
|
|
545
|
+
if (fresh) {
|
|
546
|
+
const stopped = await endPrograms(connection.client, paired.name, signal);
|
|
547
|
+
if (!stopped.ok)
|
|
548
|
+
return stopped;
|
|
549
|
+
const emptied = await emptyWorkspace(connection.client, paired.name, signal);
|
|
550
|
+
if (!emptied.ok)
|
|
551
|
+
return emptied;
|
|
552
|
+
}
|
|
553
|
+
return ok(recorded());
|
|
554
|
+
}
|
|
555
|
+
finally {
|
|
556
|
+
await connection.close();
|
|
557
|
+
}
|
|
558
|
+
};
|
|
421
559
|
return {
|
|
422
560
|
id: "attached",
|
|
423
561
|
// The driver's version is the computer's, whatever it is: the provider never refuses a newer or older build of one
|
|
@@ -430,6 +568,9 @@ export function attachedProvider(paired, hub) {
|
|
|
430
568
|
...kindRefusals(capabilities()),
|
|
431
569
|
...(spec.owner === undefined ? checkLifetime(spec.lifetimeMs, capabilities()) : []),
|
|
432
570
|
...(spec.network === "open" ? [] : [{ field: "network", message: networkRefusal(spec.network) }]),
|
|
571
|
+
// A Linux box takes the run's folder as a synced folder alone; a desktop or a phone takes none.
|
|
572
|
+
...checkMount(spec.mount, capabilities().mount),
|
|
573
|
+
...(spec.mount?.kind === "sync" && !epochOf(spec.labels).ok ? [{ field: "labels", message: `a synced folder is made under the run's claim epoch: the label ${EPOCH_LABEL} is required` }] : []),
|
|
433
574
|
],
|
|
434
575
|
async create(spec, context) {
|
|
435
576
|
const refusals = this.check(spec);
|
|
@@ -439,7 +580,9 @@ export function attachedProvider(paired, hub) {
|
|
|
439
580
|
return fail("invalid", "create needs a request id (CreateContext.requestId): pass the same one to retry the same request");
|
|
440
581
|
// One hold per request id (provider.md, Idempotent create): a retry while it holds answers it, and after it ended
|
|
441
582
|
// is refused, so a retry never takes the machine from the run that holds it next.
|
|
442
|
-
|
|
583
|
+
// A retry while its synced folder is still being readied is checked as one after, then shares that answer.
|
|
584
|
+
const starting = startingBy.get(context.requestId);
|
|
585
|
+
const before = starting?.hold ?? holdsBy.get(context.requestId);
|
|
443
586
|
if (before !== undefined) {
|
|
444
587
|
if (hub.hold(paired.id) !== before)
|
|
445
588
|
return fail("exists", `${paired.name}'s hold ${before} was made for this request and has ended: create with a new request id`);
|
|
@@ -449,7 +592,7 @@ export function attachedProvider(paired, hub) {
|
|
|
449
592
|
const same = Object.keys(asked).length === Object.keys(claimed).length && holds(claimed, asked);
|
|
450
593
|
if (!same)
|
|
451
594
|
return fail("exists", `${paired.name}'s hold ${before} was made for this request with other labels: create with a new request id`);
|
|
452
|
-
return ok({ ...holdRef(before), notes: [ATTACHED_NOTE] });
|
|
595
|
+
return starting?.answer ?? ok({ ...holdRef(before), notes: [ATTACHED_NOTE] });
|
|
453
596
|
}
|
|
454
597
|
if (!hub.online(paired.id))
|
|
455
598
|
return offline();
|
|
@@ -458,10 +601,28 @@ export function attachedProvider(paired, hub) {
|
|
|
458
601
|
const hold = hub.claim(paired.id, spec.labels ?? {}, deadline);
|
|
459
602
|
if (hold === undefined)
|
|
460
603
|
return fail("refused", `${paired.name} is held by another run: one run at a time`);
|
|
461
|
-
|
|
462
|
-
|
|
604
|
+
if (spec.mount?.kind !== "sync") {
|
|
605
|
+
holdsBy.set(context.requestId, hold);
|
|
606
|
+
return ok({ ...holdRef(hold), notes: [ATTACHED_NOTE] });
|
|
607
|
+
}
|
|
608
|
+
// The run's synced folder goes in the box's /workspace, which must be computerd's user's own directory before
|
|
609
|
+
// anything is pushed there, and is cleared of an earlier run's programs and files: one that is not lets the hold
|
|
610
|
+
// go, in words. A retry of this request meanwhile shares this answer.
|
|
611
|
+
const requestId = context.requestId;
|
|
612
|
+
const answer = (async () => {
|
|
613
|
+
const read = await folder(context.signal, true);
|
|
614
|
+
if (!read.ok || "other" in read.value) {
|
|
615
|
+
hub.unclaim(paired.id, hold);
|
|
616
|
+
return read.ok ? fail("refused", read.value.other) : read;
|
|
617
|
+
}
|
|
618
|
+
syncedHold = hold;
|
|
619
|
+
holdsBy.set(requestId, hold);
|
|
620
|
+
return ok({ ...holdRef(hold), notes: [ATTACHED_NOTE] });
|
|
621
|
+
})().finally(() => startingBy.delete(requestId));
|
|
622
|
+
startingBy.set(requestId, { hold, answer });
|
|
623
|
+
return answer;
|
|
463
624
|
},
|
|
464
|
-
async attach(asked) {
|
|
625
|
+
async attach(asked, context) {
|
|
465
626
|
if ("id" in asked) {
|
|
466
627
|
const which = named(asked);
|
|
467
628
|
if (which === undefined)
|
|
@@ -473,13 +634,19 @@ export function attachedProvider(paired, hub) {
|
|
|
473
634
|
return unknown(JSON.stringify(asked.labels));
|
|
474
635
|
const deadline = hub.deadline(paired.id);
|
|
475
636
|
const found = "id" in asked ? { id: asked.id, name: paired.name } : heldRef();
|
|
476
|
-
|
|
637
|
+
// A hold that took the run's folder reads it back from inside the box, as a hosted computer's is.
|
|
638
|
+
const mounted = syncedHold !== undefined && hub.hold(paired.id) === syncedHold ? await folder(context?.signal) : undefined;
|
|
639
|
+
if (mounted !== undefined && !mounted.ok)
|
|
640
|
+
return mounted;
|
|
641
|
+
return ok({ ...found, spec: { image: "attached", user: "the person's own", network: { other: "the machine's own network" }, kind: paired.hello.kind, ...(deadline === undefined ? {} : { deadline }), ...(mounted === undefined ? {} : { mount: mounted.value }) } });
|
|
477
642
|
},
|
|
478
643
|
async list(labels) {
|
|
479
644
|
const have = { ...paired.labels, ...hub.claimed(paired.id) };
|
|
480
645
|
if (!holds(have, labels))
|
|
481
646
|
return ok([]);
|
|
482
|
-
|
|
647
|
+
// list runs nothing on the box: a hold's synced folder is the one its labels record.
|
|
648
|
+
const mount = syncedHold !== undefined && hub.hold(paired.id) === syncedHold ? { mount: recorded() } : {};
|
|
649
|
+
return ok([{ ref: heldRef(), labels: have, deadline: hub.deadline(paired.id), state: hub.online(paired.id) ? "running" : "stopped", network: { other: "the machine's own network" }, ...mount }]);
|
|
483
650
|
},
|
|
484
651
|
async network(asked, policy) {
|
|
485
652
|
if (!mine(asked))
|
package/dist/cloudflare.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { HostedProvider, type HostedOptions, type HostedTimeouts } from "./hosted/provider.js";
|
|
2
2
|
import type { CallContext } from "./provider.js";
|
|
3
3
|
import { type Result } from "./result.js";
|
|
4
|
-
|
|
4
|
+
/** The Cloudflare provider's options: the relay's address and token, then the shared adapter's (HostedOptions), kind among them. */
|
|
5
|
+
export interface CloudflareProviderOptions extends Omit<HostedOptions, "desktop" | "maxLifetimeMs"> {
|
|
5
6
|
/** The relay Worker's https address, as `wrangler deploy` printed it. */
|
|
6
7
|
relayUrl: string;
|
|
7
8
|
/** The relay's RELAY_TOKEN (`wrangler secret put RELAY_TOKEN`). The caller passes it; this provider reads no environment. */
|
|
@@ -18,7 +19,8 @@ export declare function create(options: CloudflareProviderOptions): CloudflarePr
|
|
|
18
19
|
export declare const conformance: () => Promise<typeof import("./conformance/cloudflare.js")>;
|
|
19
20
|
/**
|
|
20
21
|
* Computers that are Cloudflare Containers, through the operator's relay, each dialing the server that made it: a server
|
|
21
|
-
* with no public https address (AGENTRUN_PUBLIC_URL) refuses a create in words before the relay is called. Kind linux
|
|
22
|
+
* with no public https address (AGENTRUN_PUBLIC_URL) refuses a create in words before the relay is called. Kind linux
|
|
23
|
+
* (default) or desktop, whose X server and window manager start through computerd over the socket the container dialed.
|
|
22
24
|
*/
|
|
23
25
|
export declare class CloudflareProvider extends HostedProvider {
|
|
24
26
|
#private;
|
package/dist/cloudflare.js
CHANGED
|
@@ -62,7 +62,10 @@ class CloudflareHost {
|
|
|
62
62
|
arch: "amd64",
|
|
63
63
|
// No page names an agent of Cloudflare's inside the container (unverified).
|
|
64
64
|
vendorAgentPorts: [],
|
|
65
|
-
|
|
65
|
+
// The relay's image is FROM the box image (relays/cloudflare/Dockerfile), which has xfwm4 (box/install.sh's desktop step).
|
|
66
|
+
windowManager: true,
|
|
67
|
+
// Its descriptor's (connectOf): the container dials the server.
|
|
68
|
+
connect: CLOUDFLARE.connect,
|
|
66
69
|
};
|
|
67
70
|
relayUrl;
|
|
68
71
|
#client;
|
|
@@ -152,7 +155,8 @@ export function create(options) {
|
|
|
152
155
|
export const conformance = () => import("./conformance/cloudflare.js");
|
|
153
156
|
/**
|
|
154
157
|
* Computers that are Cloudflare Containers, through the operator's relay, each dialing the server that made it: a server
|
|
155
|
-
* with no public https address (AGENTRUN_PUBLIC_URL) refuses a create in words before the relay is called. Kind linux
|
|
158
|
+
* with no public https address (AGENTRUN_PUBLIC_URL) refuses a create in words before the relay is called. Kind linux
|
|
159
|
+
* (default) or desktop, whose X server and window manager start through computerd over the socket the container dialed.
|
|
156
160
|
*/
|
|
157
161
|
export class CloudflareProvider extends HostedProvider {
|
|
158
162
|
#relay;
|
|
@@ -165,7 +169,7 @@ export class CloudflareProvider extends HostedProvider {
|
|
|
165
169
|
if (typeof fetcher !== "function")
|
|
166
170
|
throw new Error("options.fetch must be a function, as the global fetch is");
|
|
167
171
|
const host = new CloudflareHost({ relayUrl, relayToken, fetch: fetcher });
|
|
168
|
-
super(host, { ...rest,
|
|
172
|
+
super(host, { ...rest, timeouts: { ...CLOUDFLARE_TIMEOUTS, ...timeouts } });
|
|
169
173
|
this.#relay = host;
|
|
170
174
|
}
|
|
171
175
|
/** The provider contract's prepareImage (its descriptor declares it): the box image the relay was deployed FROM. */
|
|
Binary file
|
|
Binary file
|
package/dist/computerd.json
CHANGED
|
@@ -3,11 +3,17 @@
|
|
|
3
3
|
import { createHash, randomBytes } from "node:crypto";
|
|
4
4
|
import { pullTar, pullTarStream, pushTar, readFile, writeFile } from "../../files.js";
|
|
5
5
|
import { MAX_LIST_ENTRIES } from "../../protocol.js";
|
|
6
|
-
import {
|
|
6
|
+
import { tarOf, untar } from "../../tar.js";
|
|
7
7
|
import { b64, decode, delay } from "./util.js";
|
|
8
8
|
// Most cases work in t.dir(), which finds HOME through exec.run: they need exec as well as files.
|
|
9
9
|
const files = (name, run, needs = ["files", "exec"]) => ({ id: `files.${name}`, level: "core", group: "files", needs, run });
|
|
10
10
|
const sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
11
|
+
/** An entry as one comparable line: its name without "./" or a trailing "/", type, mode, and content hash or target. */
|
|
12
|
+
const describeEntry = (entry) => {
|
|
13
|
+
const name = entry.name.replace(/^\.\//, "").replace(/\/$/, "");
|
|
14
|
+
const what = entry.type === "file" ? sha256(entry.body ?? new Uint8Array()) : entry.type === "symlink" ? `-> ${entry.link}` : "";
|
|
15
|
+
return `${name} ${entry.type} ${entry.mode.toString(8)} ${what}`.trimEnd();
|
|
16
|
+
};
|
|
11
17
|
const sorted = (entries) => entries
|
|
12
18
|
.filter((entry) => !["", ".", "./"].includes(entry.name))
|
|
13
19
|
.map(describeEntry)
|
|
@@ -65,6 +65,10 @@ export async function assertIsolated(t, client) {
|
|
|
65
65
|
}
|
|
66
66
|
const found = search.sockets.map((one) => ({ path: String(one.path), type: String(one.type) }));
|
|
67
67
|
t.observe(`unix sockets a tool can connect to: ${found.map(({ path, type }) => `${path} (${type})`).join(", ") || "none"}`);
|
|
68
|
+
// Folders of a filesystem no socket can be a file of (proc, sysfs a runtime mounted inside a searched root) are not
|
|
69
|
+
// gone into; they take nothing from the proof, and are said so a run shows them.
|
|
70
|
+
if (Array.isArray(search.skipped) && search.skipped.length > 0)
|
|
71
|
+
t.observe(`not searched, no socket can be a file there: ${search.skipped.map(String).join(", ")}`);
|
|
68
72
|
const incomplete = search.incomplete.map(String);
|
|
69
73
|
t.assert(incomplete.length === 0, `the probe could not search every place a socket may be, so the socket fence is unproven: ${incomplete.join("; ")}`);
|
|
70
74
|
// A desktop's tools draw on its display: the X server of the display its hello names, on its path and on the same
|
|
@@ -10,10 +10,21 @@
|
|
|
10
10
|
// disk once the computer lets the folder go; a new claim takes the folder from a lower epoch, whose computer is gone;
|
|
11
11
|
// the token is nowhere a tool can read it; and, on one computer, a tool reaches no network while its writes reach the
|
|
12
12
|
// disk as each call returns.
|
|
13
|
+
//
|
|
14
|
+
// A synced folder has no disk of the provider's: the runner holds the copy (a SyncSink), pushes it in at the claim and
|
|
15
|
+
// lands each call's delta on it before the call answers (FolderSync under syncingClient). Its cases hold that copy in
|
|
16
|
+
// memory, as a runner would hold it, and check what the provider's computer gives the runner: a push restores modes and
|
|
17
|
+
// links, a change is on the copy before the call that made it answers, a delete reaches it, and a folder past a cap
|
|
18
|
+
// fails the call in words.
|
|
13
19
|
import { randomBytes } from "node:crypto";
|
|
20
|
+
import { pushTar } from "../../files.js";
|
|
14
21
|
import { EPOCH_LABEL, RUN_LABEL, runLabels as claimLabels } from "../../labels.js";
|
|
15
22
|
import { MOUNT_KINDS, readBackOf, WORKSPACE } from "../../mount.js";
|
|
16
|
-
import {
|
|
23
|
+
import { syncingClient } from "../../mount-archil.js";
|
|
24
|
+
import { MAX_LIST_DEPTH, MAX_OUTPUT_BYTES } from "../../protocol.js";
|
|
25
|
+
import { ok } from "../../result.js";
|
|
26
|
+
import { FolderSync, SYNC_MAX_ENTRIES } from "../../sync-folder.js";
|
|
27
|
+
import { tarStream } from "../../tar.js";
|
|
17
28
|
import { assertIsolated, assertRootRunsClosed } from "./isolation.js";
|
|
18
29
|
import { b64, CASE_LABEL, decode } from "./util.js";
|
|
19
30
|
/** The claim epoch the run-folder cases make their computers under. */
|
|
@@ -64,7 +75,8 @@ export async function mounted(t, folder, epoch, name, extra = {}) {
|
|
|
64
75
|
return { ref, labels };
|
|
65
76
|
}
|
|
66
77
|
const text = (bytes) => (bytes === undefined ? undefined : Buffer.from(bytes).toString("utf8"));
|
|
67
|
-
/** "mounts the run's folder" for one kind: on a computer of its own, made with a fresh run folder from the run.
|
|
78
|
+
/** "mounts the run's folder" for one kind: on a computer of its own, made with a fresh run folder from the run. A synced
|
|
79
|
+
* folder's cases are the sync-* ones, below. */
|
|
68
80
|
const runFolder = (kind) => mount(`run-folder-${kind}`, async (t) => {
|
|
69
81
|
const folder = await t.runFolder(kind);
|
|
70
82
|
const asked = folder.mount;
|
|
@@ -219,8 +231,145 @@ const archilLoopToolEdit = mount("archil-loop-tool-edit", async (t) => {
|
|
|
219
231
|
t.ok(await t.provider.release(ref, "delete"), `release of ${ref.name}`);
|
|
220
232
|
t.equal(text(await folder.read(name)), want, `${name}: the loop's text with the tool's line, read through the file API once the computer is released`);
|
|
221
233
|
}, { needs: ["mount:archil", "exec", "files"], timeoutMs: 600_000 });
|
|
234
|
+
/** The runner's copy of a synced folder, in memory: its files, its empty directories, its modes and links, and each
|
|
235
|
+
* write in order ("put a", "remove a", ...). */
|
|
236
|
+
class CopySink {
|
|
237
|
+
files = new Map();
|
|
238
|
+
dirs = new Set();
|
|
239
|
+
kept = { modes: {}, links: {} };
|
|
240
|
+
writes = [];
|
|
241
|
+
async put(path, body) {
|
|
242
|
+
this.writes.push(`put ${path}`);
|
|
243
|
+
this.files.set(path, body);
|
|
244
|
+
return ok(undefined);
|
|
245
|
+
}
|
|
246
|
+
async mkdir(path) {
|
|
247
|
+
this.writes.push(`mkdir ${path}`);
|
|
248
|
+
this.dirs.add(path);
|
|
249
|
+
return ok(undefined);
|
|
250
|
+
}
|
|
251
|
+
async remove(path, type) {
|
|
252
|
+
this.writes.push(`remove ${path}`);
|
|
253
|
+
if (type === "file")
|
|
254
|
+
this.files.delete(path);
|
|
255
|
+
else
|
|
256
|
+
this.dirs.delete(path);
|
|
257
|
+
return ok(undefined);
|
|
258
|
+
}
|
|
259
|
+
async meta(meta) {
|
|
260
|
+
this.writes.push("meta");
|
|
261
|
+
this.kept = meta;
|
|
262
|
+
return ok(undefined);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* A computer made with a synced folder, its copy `entries` held by the runner and pushed into /workspace as one tar
|
|
267
|
+
* (none: an empty folder), the computer's listing read as the manifest, and its client under syncingClient, as a runner
|
|
268
|
+
* hands it to the tools: each call that may change the folder answers once its delta is on the copy.
|
|
269
|
+
*/
|
|
270
|
+
async function synced(t, name, entries = []) {
|
|
271
|
+
const copy = new CopySink();
|
|
272
|
+
for (const entry of entries) {
|
|
273
|
+
if (entry.type === "file")
|
|
274
|
+
copy.files.set(entry.name, entry.body ?? new Uint8Array());
|
|
275
|
+
else if (entry.type === "dir" && !entries.some((other) => other.name.startsWith(`${entry.name}/`)))
|
|
276
|
+
copy.dirs.add(entry.name);
|
|
277
|
+
}
|
|
278
|
+
const kept = {
|
|
279
|
+
mount: { kind: "sync" },
|
|
280
|
+
read: async (path) => copy.files.get(path),
|
|
281
|
+
write: async (path, data) => void copy.files.set(path, data),
|
|
282
|
+
close: async () => { },
|
|
283
|
+
};
|
|
284
|
+
const { ref } = await mounted(t, kept, EPOCH, name);
|
|
285
|
+
const connected = await t.connect(ref);
|
|
286
|
+
if (entries.length > 0)
|
|
287
|
+
t.ok(await pushTar(connected.client, WORKSPACE, tarStream(entries)), `tar.push of the run's folder into ${WORKSPACE}`);
|
|
288
|
+
const folder = new FolderSync(connected.client, copy);
|
|
289
|
+
t.ok(await folder.baseline(), `files.list of ${WORKSPACE} pushed in, as the manifest`);
|
|
290
|
+
const client = syncingClient(connected.client, async () => {
|
|
291
|
+
const done = await folder.sync();
|
|
292
|
+
return done.ok ? ok(undefined) : done;
|
|
293
|
+
});
|
|
294
|
+
return { copy, client, own: connected.client, folder };
|
|
295
|
+
}
|
|
296
|
+
/** /workspace as files.list gives it, by path relative to it. */
|
|
297
|
+
async function listed(t, client) {
|
|
298
|
+
const page = await t.call("files.list", { path: WORKSPACE, depth: MAX_LIST_DEPTH }, client);
|
|
299
|
+
return new Map(page.entries.map((entry) => [entry.path.slice(WORKSPACE.length + 1), entry]));
|
|
300
|
+
}
|
|
301
|
+
const SYNC_NEEDS = ["mount:sync", "exec", "files"];
|
|
302
|
+
/** "on the copy before the answer": a program's write, a files.write and a new tree land before their call answers. */
|
|
303
|
+
const syncDurable = mount("sync-durable", async (t) => {
|
|
304
|
+
const { copy, client } = await synced(t, "mount-sync-durable");
|
|
305
|
+
const nonce = randomBytes(6).toString("hex");
|
|
306
|
+
const ran = await t.exec(["sh", "-c", `printf '%s\\n' ${nonce} > exec-${nonce}.txt`], { cwd: WORKSPACE }, client);
|
|
307
|
+
t.equal(ran.exitCode, 0, `a program's write at ${WORKSPACE}: its exit code (${ran.err.trim()})`);
|
|
308
|
+
t.equal(text(copy.files.get(`exec-${nonce}.txt`)), `${nonce}\n`, `exec-${nonce}.txt, written by a program, on the runner's copy when exec.run answered`);
|
|
309
|
+
const body = `written by files.write ${nonce}\n`;
|
|
310
|
+
await t.call("files.write", { path: `${WORKSPACE}/write-${nonce}.txt`, data: b64(body) }, client);
|
|
311
|
+
t.equal(text(copy.files.get(`write-${nonce}.txt`)), body, `write-${nonce}.txt, written by files.write, on the runner's copy when it answered`);
|
|
312
|
+
// A new tree (npm install's node_modules), pulled as one tar, and an empty directory, with no bytes.
|
|
313
|
+
const tree = await t.exec(["sh", "-c", `mkdir -p tree/a/b tree/empty && printf ${nonce} > tree/a/b/leaf`], { cwd: WORKSPACE }, client);
|
|
314
|
+
t.equal(tree.exitCode, 0, `a program's new tree at ${WORKSPACE}: its exit code (${tree.err.trim()})`);
|
|
315
|
+
t.equal(text(copy.files.get("tree/a/b/leaf")), nonce, "tree/a/b/leaf, in a tree a program made, on the runner's copy when exec.run answered");
|
|
316
|
+
t.assert(copy.dirs.has("tree/empty"), `tree/empty, an empty directory a program made, is not on the runner's copy: ${copy.writes.join(", ")}`);
|
|
317
|
+
}, { needs: SYNC_NEEDS });
|
|
318
|
+
/** "a push restores modes and links": the runner's copy pushed in reads back with its modes and its link, a program runs
|
|
319
|
+
* from it, and a sync after it writes nothing, since the copy holds it all. */
|
|
320
|
+
const syncPush = mount("sync-push", async (t) => {
|
|
321
|
+
const nonce = randomBytes(6).toString("hex");
|
|
322
|
+
const entries = [
|
|
323
|
+
{ name: "run.sh", type: "file", mode: 0o755, body: Buffer.from(`#!/bin/sh\necho ran ${nonce}\n`) },
|
|
324
|
+
{ name: "empty", type: "dir", mode: 0o755 },
|
|
325
|
+
{ name: "private", type: "dir", mode: 0o700 },
|
|
326
|
+
{ name: "private/key.txt", type: "file", mode: 0o600, body: Buffer.from(nonce) },
|
|
327
|
+
{ name: "link", type: "symlink", mode: 0o777, link: "run.sh" },
|
|
328
|
+
];
|
|
329
|
+
const { copy, client, own } = await synced(t, "mount-sync-push", entries);
|
|
330
|
+
const seen = await listed(t, own);
|
|
331
|
+
for (const { name, type, mode, link } of entries) {
|
|
332
|
+
const entry = t.present(seen.get(name), `${name}, pushed in, listed at ${WORKSPACE}`);
|
|
333
|
+
t.equal(entry.type, type, `${name}: its type`);
|
|
334
|
+
if (link !== undefined)
|
|
335
|
+
t.equal(entry.target, link, `${name}: the link's target, as pushed`);
|
|
336
|
+
else
|
|
337
|
+
t.equal((entry.mode & 0o7777).toString(8), mode.toString(8), `${name}: its mode, as pushed`);
|
|
338
|
+
}
|
|
339
|
+
const ran = await t.exec(["./run.sh"], { cwd: WORKSPACE }, client);
|
|
340
|
+
t.equal(ran.out, `ran ${nonce}\n`, `./run.sh, pushed in with mode 755, run at ${WORKSPACE} (${ran.err.trim()})`);
|
|
341
|
+
t.deepEqual(copy.writes, [], "what the sync after the push wrote to the runner's copy, which already holds the folder");
|
|
342
|
+
}, { needs: SYNC_NEEDS });
|
|
343
|
+
/** "a delete reaches the copy": a file removed, a tree removed and a file moved, on the copy when the call answers; the
|
|
344
|
+
* moved file's new path put before its old one is removed. */
|
|
345
|
+
const syncDelete = mount("sync-delete", async (t) => {
|
|
346
|
+
const nonce = randomBytes(6).toString("hex");
|
|
347
|
+
const file = (name) => ({ name, type: "file", mode: 0o644, body: Buffer.from(`${name} ${nonce}`) });
|
|
348
|
+
const { copy, client } = await synced(t, "mount-sync-delete", [file("gone.txt"), file("keep.txt"), file("move-me.txt"), { name: "dir", type: "dir", mode: 0o755 }, file("dir/a.txt"), { name: "dir/sub", type: "dir", mode: 0o755 }, file("dir/sub/b.txt")]);
|
|
349
|
+
const ran = await t.exec(["sh", "-c", "rm gone.txt && rm -rf dir && mv move-me.txt moved.txt"], { cwd: WORKSPACE }, client);
|
|
350
|
+
t.equal(ran.exitCode, 0, `rm, rm -rf and mv at ${WORKSPACE}: the exit code (${ran.err.trim()})`);
|
|
351
|
+
t.deepEqual([...copy.files.keys()].sort(), ["keep.txt", "moved.txt"], "the files on the runner's copy when exec.run answered");
|
|
352
|
+
t.equal(text(copy.files.get("moved.txt")), `move-me.txt ${nonce}`, "moved.txt: the moved file's bytes");
|
|
353
|
+
t.deepEqual([...copy.dirs], [], "the empty directories on the runner's copy");
|
|
354
|
+
t.assert(copy.writes.indexOf("put moved.txt") < copy.writes.indexOf("remove move-me.txt"), `the moved file is put at its new path before its old one is removed: ${copy.writes.join(", ")}`);
|
|
355
|
+
t.assert(copy.writes.indexOf("remove dir/sub/b.txt") < copy.writes.indexOf("remove dir/sub") && copy.writes.indexOf("remove dir/sub") < copy.writes.indexOf("remove dir"), `a tree is removed deepest first: ${copy.writes.join(", ")}`);
|
|
356
|
+
}, { needs: SYNC_NEEDS });
|
|
357
|
+
/** "a cap refuses": a folder grown past SYNC_MAX_ENTRIES fails the call that grew it, kind limit, in words naming the cap,
|
|
358
|
+
* and nothing past the cap reaches the copy. */
|
|
359
|
+
const syncCap = mount("sync-cap", async (t) => {
|
|
360
|
+
const { copy, client } = await synced(t, "mount-sync-cap");
|
|
361
|
+
const grown = await client.call("exec.run", { argv: ["sh", "-c", `mkdir many && cd many && seq 1 ${SYNC_MAX_ENTRIES} | xargs touch`], cwd: WORKSPACE, timeoutMs: 120_000 });
|
|
362
|
+
t.assert(!grown.ok, `exec.run that made ${SYNC_MAX_ENTRIES + 1} entries answered as if the folder were synced`);
|
|
363
|
+
if (grown.ok)
|
|
364
|
+
return;
|
|
365
|
+
t.equal(grown.error.code, "limit", `the failure's code (${grown.error.message})`);
|
|
366
|
+
t.equal(grown.error.message, `exec.run ran, but the run's folder could not be made durable: the run's folder holds more than ${SYNC_MAX_ENTRIES} entries, the most a synced folder holds`, "the failure's words");
|
|
367
|
+
t.deepEqual(copy.writes, [], "what reached the runner's copy");
|
|
368
|
+
}, { needs: SYNC_NEEDS, timeoutMs: 600_000 });
|
|
222
369
|
/** A mount of each kind the provider does not declare, with a token this case alone knows. */
|
|
223
370
|
function undeclaredMount(kind, token) {
|
|
371
|
+
if (kind === "sync")
|
|
372
|
+
return { kind };
|
|
224
373
|
return kind === "bind" ? { kind, path: "/" } : { kind, disk: "conformance-disk", region: "conformance-region", folder: "agents/conformance/runs/r/work", token };
|
|
225
374
|
}
|
|
226
375
|
export const mountCases = [
|
|
@@ -231,6 +380,10 @@ export const mountCases = [
|
|
|
231
380
|
archilToken,
|
|
232
381
|
archilIsolatedDurable,
|
|
233
382
|
archilLoopToolEdit,
|
|
383
|
+
syncDurable,
|
|
384
|
+
syncPush,
|
|
385
|
+
syncDelete,
|
|
386
|
+
syncCap,
|
|
234
387
|
mount("undeclared-kind", async (t) => {
|
|
235
388
|
const declared = t.provider.capabilities().mount ?? [];
|
|
236
389
|
const undeclared = MOUNT_KINDS.filter((kind) => !declared.includes(kind));
|
|
@@ -393,7 +393,9 @@ export const providerCases = [
|
|
|
393
393
|
// Past the machine's backstop: create's time, the most it may live and the margin, and a minute.
|
|
394
394
|
const past = new Date(Date.now() + t.provider.capabilities().maxLifetimeMs + BACKSTOP_MARGIN_MS + 60_000);
|
|
395
395
|
t.equal(await kit.check(token, past), undefined, "the machine's token past its backstop");
|
|
396
|
-
|
|
396
|
+
// A desktop's token takes a linux hello, its own before its display answers (attach.ts helloMismatch): it is held to
|
|
397
|
+
// another kind instead.
|
|
398
|
+
const others = [{ kind: hello.kind === "linux" ? "desktop" : hello.kind === "desktop" ? "android" : "linux" }, { os: hello.os === "linux" ? "windows" : "linux" }, { arch: hello.arch === "amd64" ? "arm64" : "amd64" }];
|
|
397
399
|
for (const other of others) {
|
|
398
400
|
t.equal(await kit.dialAs(token, { ...hello, ...other }), ATTACH_CLOSE.mismatch, `the machine's token with a hello of ${JSON.stringify(other)}: the close code`);
|
|
399
401
|
}
|