@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.
Files changed (68) hide show
  1. package/README.md +98 -12
  2. package/box/Dockerfile +2 -1
  3. package/box/build-daytona.py +12 -2
  4. package/box/install.sh +19 -5
  5. package/box/recipe.mjs +1 -1
  6. package/dist/attach.d.ts +13 -3
  7. package/dist/attach.js +182 -15
  8. package/dist/cloudflare.d.ts +4 -2
  9. package/dist/cloudflare.js +7 -3
  10. package/dist/computerd-linux-amd64 +0 -0
  11. package/dist/computerd-linux-arm64 +0 -0
  12. package/dist/computerd.json +2 -2
  13. package/dist/conformance/cases/files.js +7 -1
  14. package/dist/conformance/cases/isolation.js +4 -0
  15. package/dist/conformance/cases/mount.js +155 -2
  16. package/dist/conformance/cases/provider.js +3 -1
  17. package/dist/conformance/daytona.d.ts +15 -1
  18. package/dist/conformance/daytona.js +19 -4
  19. package/dist/conformance/types.d.ts +1 -1
  20. package/dist/daytona.d.ts +11 -2
  21. package/dist/daytona.js +47 -15
  22. package/dist/descriptor.d.ts +34 -4
  23. package/dist/descriptor.js +40 -6
  24. package/dist/descriptors/cloudflare.d.ts +14 -1
  25. package/dist/descriptors/cloudflare.js +7 -3
  26. package/dist/descriptors/daytona.d.ts +21 -3
  27. package/dist/descriptors/daytona.js +15 -8
  28. package/dist/descriptors/e2b.d.ts +1 -0
  29. package/dist/descriptors/e2b.js +2 -1
  30. package/dist/descriptors/fly.d.ts +14 -1
  31. package/dist/descriptors/fly.js +6 -3
  32. package/dist/descriptors/index.d.ts +64 -2
  33. package/dist/descriptors/modal.d.ts +16 -2
  34. package/dist/descriptors/modal.js +10 -6
  35. package/dist/descriptors/orgo.d.ts +3 -0
  36. package/dist/descriptors/orgo.js +3 -1
  37. package/dist/e2b.d.ts +9 -4
  38. package/dist/e2b.js +8 -8
  39. package/dist/env-proxy.d.ts +26 -0
  40. package/dist/env-proxy.js +97 -0
  41. package/dist/fly.d.ts +4 -3
  42. package/dist/fly.js +7 -4
  43. package/dist/hosted/provider.d.ts +2 -1
  44. package/dist/hosted/provider.js +133 -54
  45. package/dist/hosted/scripts.d.ts +3 -2
  46. package/dist/hosted/scripts.js +12 -7
  47. package/dist/hosted/values.d.ts +2 -5
  48. package/dist/hosted/values.js +2 -9
  49. package/dist/index.d.ts +4 -2
  50. package/dist/index.js +4 -2
  51. package/dist/kinds.d.ts +4 -2
  52. package/dist/kinds.js +10 -1
  53. package/dist/modal.d.ts +5 -2
  54. package/dist/modal.js +8 -2
  55. package/dist/morph.js +15 -7
  56. package/dist/mount-archil.d.ts +33 -17
  57. package/dist/mount-archil.js +83 -36
  58. package/dist/mount.d.ts +16 -7
  59. package/dist/mount.js +13 -8
  60. package/dist/orgo.js +1 -1
  61. package/dist/provider.d.ts +1 -1
  62. package/dist/sync-folder.d.ts +82 -0
  63. package/dist/sync-folder.js +494 -0
  64. package/dist/tar.d.ts +34 -0
  65. package/dist/tar.js +203 -0
  66. package/package.json +1 -1
  67. package/dist/conformance/tar.d.ts +0 -13
  68. package/dist/conformance/tar.js +0 -105
@@ -13,14 +13,15 @@ import { fileURLToPath } from "node:url";
13
13
  import { isDeepStrictEqual } from "node:util";
14
14
  import { ATTACH_PATH, DAEMON_PATH } from "../attach.js";
15
15
  import { CreateRequests, endedWords, otherSpecWords, readBackDiffer } from "../create-requests.js";
16
- import { desktopOf, startDisplay } from "../desktop.js";
16
+ import { syncs } from "../descriptor.js";
17
+ import { DESKTOP_GROUPS, desktopOf, startDisplay } from "../desktop.js";
17
18
  import { COMPUTER_LABEL, DAEMON_IN_COMPUTER, DEADLINE_LABEL, helloDrift, probeNetworkDrift, probeNotes, probeReportOf, show, WORK } from "../drift.js";
18
19
  import { BACKSTOP_MARGIN_MS } from "../host.js";
19
20
  import { readOwnNetwork, TOOL_USER } from "../isolation.js";
20
21
  import { releaseOlder } from "../janitor.js";
21
- import { RUN_LABEL } from "../labels.js";
22
- import { checkMount, readBackOf } from "../mount.js";
23
- import { ARCHIL_MOUNT_LABEL, ARCHIL_TOOL_UID, archilEgressOf, archilLabels, archilMount, archilRefusals, archilRelease, claimEpoch, mountDrift, readArchilMount, recordedArchil as recordedArchilOf, recordedMount, syncingClient, } from "../mount-archil.js";
22
+ import { EPOCH_LABEL, epochOf, RUN_LABEL } from "../labels.js";
23
+ import { checkMount } from "../mount.js";
24
+ import { ARCHIL_TOOL_UID, archilEgressOf, archilLabels, archilMount, archilRefusals, archilRelease, archilSync, claimEpoch, MOUNT_LABEL, mountDrift, readMount, recordedFolder as recordedFolderOf, recordedMount, SYNC_LABELS, syncingClient, } from "../mount-archil.js";
24
25
  import { checkGpu, checkTenure, runLifetimeMs, } from "../provider.js";
25
26
  import { failFor, ok } from "../result.js";
26
27
  import { daemonWatch } from "../screen-watch.js";
@@ -44,6 +45,8 @@ const USER = /^(\d+):(\d+)$/;
44
45
  /** A spec's user, where the host takes one: a uid, or uid:gid, in numbers (a uid alone is its own gid). */
45
46
  const SPEC_USER = /^(\d+)(?::(\d+))?$/;
46
47
  const MAX_ID = 4_294_967_294;
48
+ /** The calls of a desktop's display (DESKTOP_GROUPS): screen, input, apps and ui. */
49
+ const DISPLAY_METHOD = /^(screen|input|apps|ui)\./;
47
50
  const DEFAULTS = {
48
51
  requestMs: 30_000,
49
52
  createMs: 120_000,
@@ -114,12 +117,12 @@ export function isoOf(written) {
114
117
  export const deadlineOf = (machine) => isoOf(machine.labels[DEADLINE_LABEL]);
115
118
  /** Only a machine this adapter made counts: its label, a name of its making, and the name asked for when one is. */
116
119
  export const ours = (labels, name) => labels?.[COMPUTER_LABEL] === "1" && NAME.test(labels[NAME_LABEL] ?? "") && (name === undefined || labels[NAME_LABEL] === name);
117
- /** The Archil mount a computer's agentrun.mount label records, or undefined when it has none. */
118
- function recordedArchil(labels) {
119
- if (labels?.[ARCHIL_MOUNT_LABEL] === undefined)
120
+ /** The mount (an Archil mount, a synced folder) a computer's agentrun.mount label records, or undefined when it has none. */
121
+ function recordedFolder(labels) {
122
+ if (labels?.[MOUNT_LABEL] === undefined)
120
123
  return undefined;
121
124
  const mount = recordedMount(labels);
122
- return recordedArchilOf(labels, mount === undefined ? { other: `the label ${ARCHIL_MOUNT_LABEL} records a mount this provider never makes` } : { mount });
125
+ return recordedFolderOf(labels, mount === undefined ? { other: `the label ${MOUNT_LABEL} records a mount this provider never makes` } : { mount });
123
126
  }
124
127
  function filterProblem(labels) {
125
128
  if (typeof labels !== "object" || labels === null || Array.isArray(labels))
@@ -148,8 +151,8 @@ function gpuOf(written) {
148
151
  const count = Number(written.slice(at + 1));
149
152
  return isWhole(count) ? { gpu: { type: written.slice(0, at), count } } : {};
150
153
  }
151
- /** The caller's labels of a machine: every one but the adapter's own namespace and the Archil mount's. */
152
- const callerLabels = (labels) => Object.fromEntries(Object.entries(labels).filter(([key]) => key !== COMPUTER_LABEL && !key.startsWith(`${COMPUTER_LABEL}.`) && key !== ARCHIL_MOUNT_LABEL));
154
+ /** The caller's labels of a machine: every one but the adapter's own namespace and the mount's. */
155
+ const callerLabels = (labels) => Object.fromEntries(Object.entries(labels).filter(([key]) => key !== COMPUTER_LABEL && !key.startsWith(`${COMPUTER_LABEL}.`) && key !== MOUNT_LABEL));
153
156
  /** The shared adapter's provider: a ComputerProvider whose vendor is host. */
154
157
  export class HostedProvider {
155
158
  id;
@@ -196,13 +199,9 @@ export class HostedProvider {
196
199
  if (!isWhole(maxLifetimeMs) || maxLifetimeMs <= 0 || maxLifetimeMs > host.facts.maxLifetimeMs) {
197
200
  throw new Error(`maxLifetimeMs must be a whole number of ms above 0 and at most ${host.facts.maxLifetimeMs} ms, the longest ${label} keeps a computer`);
198
201
  }
199
- if (host.facts.connect === "dial") {
200
- // Every connection goes over the socket the machine dials: nothing reaches into it from here.
201
- if (host.exec || host.upload)
202
- throw new Error(`${label}'s machines dial this server (facts.connect "dial"), so its host has no exec and no upload: leave them out`);
203
- if (kind === "desktop")
204
- throw new Error(`${label}'s machines dial this server (facts.connect "dial"), and agentrun-dial starts init with no display: make it kind linux`);
205
- }
202
+ // Every connection of a dial host's machine goes over the socket it dials: nothing reaches into it from here.
203
+ if (host.facts.connect === "dial" && (host.exec || host.upload))
204
+ throw new Error(`${label}'s machines dial this server (facts.connect "dial"), so its host has no exec and no upload: leave them out`);
206
205
  const user = USER.exec(daemonUser);
207
206
  if (user === null || Number(user[1]) > MAX_ID || Number(user[2]) > MAX_ID)
208
207
  throw new Error(`the daemon user ${daemonUser} must be uid:gid in numbers, such as 1000:1000`);
@@ -251,7 +250,9 @@ export class HostedProvider {
251
250
  groups: [...this.#configuration.groups],
252
251
  maxLifetimeMs: this.#maxLifetimeMs,
253
252
  release: ["delete"],
254
- mount: descriptor.mounts.filter((kind) => !(this.#dialing && kind === "archil")),
253
+ // A synced folder is derived for this configuration alone (descriptor.ts syncs), whatever the descriptor's list
254
+ // says: a dial machine takes one too, its /workspace made by the box image's agentrun-dial.
255
+ mount: [...descriptor.mounts.filter((kind) => kind !== "sync" && !(this.#dialing && kind === "archil")), ...(syncs(descriptor, this.#configuration) ? ["sync"] : [])],
255
256
  vendorAgentPorts: [...facts.vendorAgentPorts],
256
257
  ...(gpu === undefined ? {} : { gpu: structuredClone(gpu) }),
257
258
  ...(facts.user === undefined ? {} : { user: [...facts.user] }),
@@ -269,6 +270,12 @@ export class HostedProvider {
269
270
  // A machine that dials takes no Archil mount yet: its helper's steps run as root through exec, which it has none of.
270
271
  const unmounted = this.#dialing ? { ...this.host.descriptor.unmounted, archil: `${label}'s machines dial this server, and a machine that dials takes no Archil mount yet` } : this.host.descriptor.unmounted;
271
272
  refusals.push(...checkMount(mount, capabilities.mount ?? [], unmounted), ...(archil ? archilRefusals(given) : []));
273
+ // A synced folder reads back under the run's claim epoch, as an Archil mount does: nothing in the computer holds one.
274
+ if (mount?.kind === "sync" && (capabilities.mount ?? []).includes("sync")) {
275
+ const epoch = epochOf(typeof labels === "object" && labels !== null ? labels : undefined);
276
+ if (!epoch.ok)
277
+ refuse("labels", `a synced folder is made under the run's claim epoch: the label ${EPOCH_LABEL} is required (${epoch.error.message})`);
278
+ }
272
279
  const daemonUser = `${this.#uid}:${this.#gid}`;
273
280
  const asked = this.#takesUser ? given.user : undefined;
274
281
  if (asked !== undefined) {
@@ -332,7 +339,11 @@ export class HostedProvider {
332
339
  */
333
340
  #dialed() {
334
341
  if (this.#dial === undefined) {
335
- return { problem: `${this.#label} machines dial in to this server, and this process has no attach hub: start them from serve's own process` };
342
+ // No dial: a runner in a process of its own (serve's runner subcommand, the image's server-and-runner). The fix is
343
+ // the one a paired computer's refusal names (serve's workspace/attached-computers.ts ONE_PROCESS_FIX).
344
+ return {
345
+ problem: `${this.#label} machines dial in to this server, and this runner runs in a process of its own, with no attach hub to take their socket: start the image with the server options alone, without server-and-runner (outside the image: agentrun-serve without --no-runner)`,
346
+ };
336
347
  }
337
348
  const url = this.#dial.url;
338
349
  const at = URL.canParse(url ?? "") ? new URL(url) : undefined;
@@ -374,6 +385,26 @@ export class HostedProvider {
374
385
  dial.hub.revoke(name, `${name} was deleted`);
375
386
  }
376
387
  }
388
+ /**
389
+ * The server's words for a refusal of the machine's dial (MachineTokens refused), or undefined: while none is kept, and
390
+ * when the token store errs, or does not answer within ms or before signal aborts (the wait goes on to createMs as before).
391
+ */
392
+ async #dialRefused(name, ms, signal) {
393
+ const dial = this.#dial;
394
+ if (dial === undefined)
395
+ return undefined;
396
+ const done = new AbortController();
397
+ try {
398
+ const bound = pause(ms, signal ? AbortSignal.any([signal, done.signal]) : done.signal).then(() => undefined);
399
+ return await Promise.race([dial.tokens.refused(name), bound]);
400
+ }
401
+ catch {
402
+ return undefined;
403
+ }
404
+ finally {
405
+ done.abort();
406
+ }
407
+ }
377
408
  /** Whether the host takes a spec's user (facts.user): then a computer's daemon runs as the one a spec names. */
378
409
  get #takesUser() {
379
410
  return this.host.facts.user !== undefined;
@@ -613,7 +644,7 @@ export class HostedProvider {
613
644
  }
614
645
  }
615
646
  /**
616
- * The labels create gives a computer: the caller's, the adapter's own, and an Archil mount's (never its token). The
647
+ * The labels create gives a computer: the caller's, the adapter's own, and its mount's (never an Archil token). The
617
648
  * most its deadline may reach only where the host can extend it, the label's one reader: a host with no extend (Modal,
618
649
  * Daytona) spends none of its label bytes on it (Modal's 512 hold the box image's tag beside an Archil mount's label).
619
650
  */
@@ -627,7 +658,7 @@ export class HostedProvider {
627
658
  [IMAGE_LABEL]: spec.image,
628
659
  ...(this.host.extend ? { [MAX_LABEL]: maxDeadline } : {}),
629
660
  ...(network === "" ? {} : { [NETWORK_LABEL]: network }),
630
- ...(spec.mount?.kind === "archil" ? archilLabels(spec.mount) : {}),
661
+ ...(spec.mount?.kind === "archil" ? archilLabels(spec.mount) : spec.mount?.kind === "sync" ? SYNC_LABELS : {}),
631
662
  ...(typeof spec.gpu?.type === "string" && typeof spec.gpu.count === "number" ? { [GPU_LABEL]: `${spec.gpu.type}:${spec.gpu.count}` } : {}),
632
663
  };
633
664
  }
@@ -668,9 +699,12 @@ export class HostedProvider {
668
699
  ...(archil && this.host.facts.daemon === "pid1" ? { gate: ARCHIL_GATE } : {}),
669
700
  rootOnly: this.host.facts.rootOnly ?? [],
670
701
  network: formOf(spec.network),
702
+ // A synced folder's /workspace, the computer's user's, made by install before init.
703
+ workspace: spec.mount?.kind === "sync",
671
704
  });
672
705
  const backstopAt = new Date(now + this.#maxLifetimeMs + BACKSTOP_MARGIN_MS).toISOString();
673
- const boot = this.#dialing ? await this.#boot(name, backstopAt, { deadline, user, maxDeadline, network: formOf(spec.network) }, sha256) : undefined;
706
+ const run = spec.labels?.[RUN_LABEL];
707
+ const boot = this.#dialing ? await this.#boot(name, backstopAt, { deadline, user, maxDeadline, network: formOf(spec.network) }, sha256, typeof run === "string" ? run : undefined) : undefined;
674
708
  if (boot !== undefined && !boot.ok)
675
709
  return boot;
676
710
  const request = {
@@ -713,15 +747,16 @@ export class HostedProvider {
713
747
  }
714
748
  /**
715
749
  * A dial machine's environment (MachineRequest.boot.env, spec/computer/attach.md): its own token, minted here to stop
716
- * at backstopAt, where it dials and fetches the daemon, the daemon's sha256, and init's flags as start gives them.
750
+ * at backstopAt and naming the run its labels name (`run`), where it dials and fetches the daemon, the daemon's
751
+ * sha256, and init's flags as start gives them.
717
752
  */
718
- async #boot(name, backstopAt, init, sha256) {
753
+ async #boot(name, backstopAt, init, sha256, run) {
719
754
  const dialed = this.#dialed();
720
755
  if ("problem" in dialed)
721
756
  return this.#fail("refused", dialed.problem);
722
757
  let token;
723
758
  try {
724
- token = await dialed.dial.tokens.mint(name, { kind: this.#kind, os: "linux", arch: this.host.facts.arch, expiresAt: new Date(backstopAt) });
759
+ token = await dialed.dial.tokens.mint(name, { kind: this.#kind, os: "linux", arch: this.host.facts.arch, expiresAt: new Date(backstopAt), ...(run !== undefined ? { run } : {}) });
725
760
  }
726
761
  catch (error) {
727
762
  return this.#fail("refused", `minting ${name}'s machine token failed, so ${this.#label} was not called: ${words(error)}`);
@@ -732,6 +767,8 @@ export class HostedProvider {
732
767
  AGENTRUN_DAEMON_URL: dialed.daemon,
733
768
  AGENTRUN_DAEMON_SHA256: sha256,
734
769
  AGENTRUN_INIT_ARGS: initFlags(init).join(" "),
770
+ // A desktop's init gets its display as the exec path's start gives it: DISPLAY, which agentrun-dial passes on.
771
+ ...(this.#desktop === undefined ? {} : { DISPLAY: this.#desktop.display }),
735
772
  });
736
773
  }
737
774
  /** Deletes a machine create gives up on, then waits, under the caller's signal, until get answers none for it. */
@@ -926,8 +963,8 @@ export class HostedProvider {
926
963
  }
927
964
  let notes;
928
965
  try {
929
- const archil = spec.mount?.kind === "archil" ? { mount: { kind: "archil", disk: spec.mount.disk, region: spec.mount.region, folder: spec.mount.folder }, epoch: claimEpoch(spec.labels) } : undefined;
930
- const expected = archil === undefined ? undefined : { ...archil, expected: readBackOf({ ...archil.mount, token: "" }, archil.epoch) };
966
+ const mount = spec.mount?.kind === "archil" ? { kind: "archil", disk: spec.mount.disk, region: spec.mount.region, folder: spec.mount.folder } : spec.mount?.kind === "sync" ? spec.mount : undefined;
967
+ const expected = mount === undefined ? undefined : recordedFolderOf(spec.labels, { mount });
931
968
  const inside = await this.#checkInside(opened.value, ref.name, networkOfForm(formOf(spec.network)), true, want, signal, expected);
932
969
  if (!inside.ok)
933
970
  return inside;
@@ -954,12 +991,12 @@ export class HostedProvider {
954
991
  /**
955
992
  * Inside the computer: for a desktop just made, the X server started through the daemon and hello declaring the
956
993
  * display; then the daemon's own report (hello, credentials, home, binary) and, for network none, the probe, which
957
- * refuses on an answer and records a silent accept in the notes it returns; and, for an Archil computer, the mount
958
- * read back from inside, held to the one expected. want.user is the uid:gid the daemon runs as (undefined: read back,
994
+ * refuses on an answer and records a silent accept in the notes it returns; and, for an Archil computer or a synced
995
+ * folder, the mount read back from inside, held to the one expected. want.user is the uid:gid the daemon runs as (undefined: read back,
959
996
  * never root), want.runtime the kernel the probe must report. Its value says what was read back of the mount (mount)
960
997
  * and, through the probe, the user the computer's programs run as (user).
961
998
  */
962
- async #checkInside(connection, name, network, starting, want, signal, archil) {
999
+ async #checkInside(connection, name, network, starting, want, signal, folder) {
963
1000
  let current = connection;
964
1001
  if (starting && this.#desktop) {
965
1002
  const shown = await startDisplay(connection.client, this.#desktop, { version: VERSION, vendor: this.id, signal, windowManager: this.host.facts.windowManager === true });
@@ -989,12 +1026,12 @@ export class HostedProvider {
989
1026
  notes.push(`fence: userns-netns: init made its programs' network namespace inside a user namespace of its own, as root on ${want.isolation ?? "this machine"} may not make one itself`);
990
1027
  }
991
1028
  const said = user === undefined ? {} : { user };
992
- if (archil === undefined)
1029
+ if (folder === undefined)
993
1030
  return drift.length === 0 ? { ...ok(notes), ...said } : this.#fail("refused", `it did not match its spec: ${drift.join("; ")}`);
994
- const mount = await readArchilMount(current.client, archil, { name, timeoutMs: this.#timeouts.helloMs, ...(signal ? { signal } : {}) });
1031
+ const mount = await readMount(current.client, folder, { name, timeoutMs: this.#timeouts.helloMs, ...(signal ? { signal } : {}) });
995
1032
  if (!mount.ok)
996
1033
  return mount;
997
- drift.push(...mountDrift(archil.expected, mount.value));
1034
+ drift.push(...mountDrift(folder.expected, mount.value));
998
1035
  const read = mount.value === undefined ? {} : { mount: mount.value };
999
1036
  return drift.length === 0 ? { ...ok(notes), ...read, ...said } : this.#fail("refused", `it did not match its spec: ${drift.join("; ")}`);
1000
1037
  }
@@ -1025,7 +1062,14 @@ export class HostedProvider {
1025
1062
  const connection = this.#dial?.hub.connection(ref.name);
1026
1063
  if (connection === undefined)
1027
1064
  return this.#fail("gone", `${ref.name} is not attached to this server now: its computerd dials back on its own, so try again shortly`);
1028
- return ok(deletedSaid(this.host, ref, this.#label, requestMs, connection));
1065
+ // The hub holds the hello of the machine's dial; a desktop's display answered after it, so each open asks again,
1066
+ // as a bridge's open does.
1067
+ const hello = await connection.client.call("hello", { client: `@parcha/agentrun-computer ${VERSION}` }, { signal: bounded(helloMs, signal) });
1068
+ if (!hello.ok) {
1069
+ await connection.close();
1070
+ return hello.error.code === "aborted" && !signal?.aborted ? this.#fail("timeout", `the daemon in ${ref.name} did not answer hello within ${seconds(helloMs)}`) : hello;
1071
+ }
1072
+ return ok(deletedSaid(this.host, ref, this.#label, requestMs, { ...connection, hello: hello.value }));
1029
1073
  }
1030
1074
  const opened = await openBridge(this.host, ref.id, { argv: hostedCommands().stdio, name: ref.name, version: VERSION, requestMs, helloMs, ...(signal ? { signal } : {}) });
1031
1075
  return opened.ok ? ok(deletedSaid(this.host, ref, this.#label, requestMs, opened.value)) : opened;
@@ -1043,21 +1087,34 @@ export class HostedProvider {
1043
1087
  /**
1044
1088
  * A dial machine's first connection: its socket waited for in the hub, from its start, within createMs. One that never
1045
1089
  * dials (a server it cannot reach, a daemon whose sha256 it refused, a hello the hub refused) fails timeout, naming the
1046
- * address it was given; create then deletes it.
1090
+ * address it was given. One the server refused in words (a relay to this runner it could not make, MachineTokens
1091
+ * refused) fails refused in those words as the read answers. The read, one at a time, bounded by requestMs, the time
1092
+ * left and the signal, holds no poll of the hub back, and the hub is read once more before a timeout: a socket there
1093
+ * wins. Create then deletes one that failed.
1047
1094
  */
1048
1095
  async #whenDialed(ref, signal) {
1049
- const { createMs } = this.#timeouts;
1096
+ const { createMs, requestMs } = this.#timeouts;
1050
1097
  const until = Date.now() + createMs;
1098
+ let reading;
1051
1099
  for (;;) {
1052
1100
  const opened = await this.#open(ref, signal);
1053
1101
  if (opened.ok)
1054
1102
  return opened;
1055
- if (Date.now() + this.#startPollMs() >= until) {
1103
+ const left = until - Date.now();
1104
+ if (left <= 0) {
1056
1105
  const dialed = this.#dialed();
1057
1106
  const to = "problem" in dialed ? "this server" : dialed.attach;
1058
1107
  return this.#fail("timeout", `${ref.name} did not dial ${to} within ${seconds(createMs)}: the machine must reach that address, and run agentrun-dial (the box image's entrypoint while AGENTRUN_ATTACH_URL is set)`);
1059
1108
  }
1060
- await pause(this.#startPollMs(), signal);
1109
+ const polled = pause(Math.min(this.#startPollMs(), left), signal).then(() => false);
1110
+ reading ??= this.#dialRefused(ref.name, Math.min(requestMs, left), signal);
1111
+ const read = await Promise.race([reading, polled]);
1112
+ if (read !== false) {
1113
+ reading = undefined;
1114
+ if (read !== undefined)
1115
+ return this.#fail("refused", `the server refused ${read}`);
1116
+ await polled;
1117
+ }
1061
1118
  if (signal?.aborted)
1062
1119
  return this.#fail("aborted", `create was aborted while it waited for ${ref.name} to dial`);
1063
1120
  }
@@ -1165,9 +1222,13 @@ export class HostedProvider {
1165
1222
  }
1166
1223
  /** The live view: screen.watch on a connection of the watch's own (daemonWatch); a linux computer has no screen. */
1167
1224
  watch(ref, handlers, options) {
1168
- return daemonWatch(this, ref, handlers, options);
1225
+ return daemonWatch({ connect: (one) => this.#connect(one, "screen.watch") }, ref, handlers, options);
1226
+ }
1227
+ connect(ref) {
1228
+ return this.#connect(ref);
1169
1229
  }
1170
- async connect(ref) {
1230
+ /** connect; `watching`, a watch's: a dial desktop whose display isn't up yet refuses it in words, as its client does. */
1231
+ async #connect(ref, watching) {
1171
1232
  const problem = this.#refProblem(ref);
1172
1233
  if (problem)
1173
1234
  return this.#fail("invalid", problem);
@@ -1183,10 +1244,24 @@ export class HostedProvider {
1183
1244
  if (!opened.ok)
1184
1245
  return opened;
1185
1246
  const { kind, groups } = this.capabilities();
1186
- const drifted = helloDrift(opened.value.hello, { version: VERSION, kind, groups, arch: this.host.facts.arch, fence: true });
1187
- // An Archil computer's client syncs the run's folder after every call that may change it, before it answers.
1247
+ // A dial desktop says linux until its display answers (attach.ts helloMismatch), and until a hello says desktop it is
1248
+ // a linux computer: its screen, input, apps and ui calls are refused here in words, never sent.
1249
+ const dark = this.#dialing && kind === "desktop" && opened.value.hello?.kind === "linux";
1250
+ const expected = dark ? { kind: "linux", groups: groups.filter((group) => !DESKTOP_GROUPS.includes(group)) } : { kind, groups };
1251
+ const drifted = helloDrift(opened.value.hello, { version: VERSION, ...expected, arch: this.host.facts.arch, fence: true });
1252
+ const notUp = (method) => this.#fail("unsupported", `${ref.name}'s display isn't up yet: ${method} was not sent, and it is a linux computer until its daemon's hello says desktop`);
1253
+ if (drifted.length === 0 && dark && watching) {
1254
+ await opened.value.close();
1255
+ return notUp(watching);
1256
+ }
1257
+ if (drifted.length === 0 && dark) {
1258
+ const client = opened.value.client;
1259
+ return ok({ ...opened.value, client: { call: (method, params, options) => (DISPLAY_METHOD.test(method) ? Promise.resolve(notUp(method)) : client.call(method, params, options)), close: () => client.close() } });
1260
+ }
1261
+ // An Archil computer's client syncs the run's folder after every call that may change it, before it answers. A synced
1262
+ // folder's sync is its runner's (the sink is serve's), which wraps the client itself.
1188
1263
  if (drifted.length === 0)
1189
- return recordedArchil(found.value.labels) === undefined ? opened : ok({ ...opened.value, client: syncingClient(opened.value.client) });
1264
+ return recordedFolder(found.value.labels)?.mount?.kind !== "archil" ? opened : ok({ ...opened.value, client: syncingClient(opened.value.client, archilSync(opened.value.client)) });
1190
1265
  await opened.value.close();
1191
1266
  return this.#fail("refused", `the daemon in ${ref.name} does not match this provider: ${drifted.join("; ")}`);
1192
1267
  }
@@ -1235,7 +1310,7 @@ export class HostedProvider {
1235
1310
  const deadline = deadlineOf(machine);
1236
1311
  if (deadline === undefined)
1237
1312
  found.push(`deadline: the label ${DEADLINE_LABEL} reads ${show(machine.labels[DEADLINE_LABEL])}, not the ISO time create writes`);
1238
- const archil = recordedArchil(machine.labels);
1313
+ const folder = recordedFolder(machine.labels);
1239
1314
  // Its tools' network as create recorded it, read from inside (#checkInside: the probe, and the proxy's policy):
1240
1315
  // no vendor's read of it is taken.
1241
1316
  const network = networkOfForm(machine.labels[NETWORK_LABEL]);
@@ -1253,8 +1328,8 @@ export class HostedProvider {
1253
1328
  try {
1254
1329
  // A host that takes a spec's user made this computer's daemon run as the one its spec named: read back, never root
1255
1330
  // (an Archil computer's is the tool user); every other runs as the provider's daemon user.
1256
- const want = this.#takesUser ? (archil === undefined ? {} : { user: ARCHIL_USER }) : { user: `${this.#uid}:${this.#gid}` };
1257
- const inside = await this.#checkInside(opened.value, name, network, false, want, signal, archil);
1331
+ const want = this.#takesUser ? (folder?.mount?.kind !== "archil" ? {} : { user: ARCHIL_USER }) : { user: `${this.#uid}:${this.#gid}` };
1332
+ const inside = await this.#checkInside(opened.value, name, network, false, want, signal, folder);
1258
1333
  if (!inside.ok && inside.error.code !== "refused")
1259
1334
  return inside;
1260
1335
  if (!inside.ok)
@@ -1270,7 +1345,7 @@ export class HostedProvider {
1270
1345
  }
1271
1346
  kind = opened.value.hello.kind;
1272
1347
  }
1273
- else if (archil !== undefined)
1348
+ else if (folder !== undefined)
1274
1349
  found.push(`mount: ${name} is ${machine.state}, so its mount cannot be read back from inside`);
1275
1350
  if (found.length > 0)
1276
1351
  return this.#fail("refused", `the computer ${name} does not match this provider, so attach refuses it and it is left as it is: ${found.join("; ")}`);
@@ -1315,15 +1390,15 @@ export class HostedProvider {
1315
1390
  for (const machine of listed.value) {
1316
1391
  if (!ours(machine.labels) || (machine.state !== "running" && machine.state !== "stopped"))
1317
1392
  continue;
1318
- // list runs nothing in a computer: an Archil computer's mount is the one its label records, under its epoch label.
1319
- const archil = recordedArchil(machine.labels);
1393
+ // list runs nothing in a computer: a computer's mount is the one its label records, under its epoch label.
1394
+ const folder = recordedFolder(machine.labels);
1320
1395
  infos.push({
1321
1396
  ref: { id: machine.id, name: machine.labels[NAME_LABEL] },
1322
1397
  labels: { ...machine.labels },
1323
1398
  deadline: deadlineOf(machine),
1324
1399
  state: machine.state,
1325
1400
  network: networkOfForm(machine.labels[NETWORK_LABEL]),
1326
- ...(archil === undefined ? {} : { mount: archil.expected }),
1401
+ ...(folder === undefined ? {} : { mount: folder.expected }),
1327
1402
  });
1328
1403
  }
1329
1404
  return ok(infos);
@@ -1492,9 +1567,13 @@ export class HostedProvider {
1492
1567
  const killed = await this.#kill(ref.id);
1493
1568
  return { letGo, gone: killed.ok ? await this.#settle(ref, signal) : killed };
1494
1569
  }
1495
- /** #letGo where machine, as read, is a running Archil computer: a stopped one holds no folder. */
1570
+ /**
1571
+ * #letGo where machine, as read, is a running Archil computer: a stopped one holds no folder, and a synced folder's
1572
+ * final delta is its runner's, before it releases.
1573
+ */
1496
1574
  #letGoOf(ref, machine, signal) {
1497
- return machine !== undefined && recordedArchil(machine.labels) !== undefined && machine.state === "running" ? this.#letGo(ref, signal) : Promise.resolve(ok(undefined));
1575
+ const folder = machine === undefined ? undefined : recordedFolder(machine.labels);
1576
+ return folder !== undefined && folder.mount?.kind !== "sync" && machine?.state === "running" ? this.#letGo(ref, signal) : Promise.resolve(ok(undefined));
1498
1577
  }
1499
1578
  /** A running Archil computer's folder let go: the final sync through a connection when it answers, then checkin as root. */
1500
1579
  async #letGo(ref, signal) {
@@ -1704,8 +1783,8 @@ function labelProblem(key, value) {
1704
1783
  return "a label name must be non-empty";
1705
1784
  if (key === COMPUTER_LABEL || key.startsWith(`${COMPUTER_LABEL}.`))
1706
1785
  return `the label ${key} is in the provider's own namespace (${COMPUTER_LABEL})`;
1707
- if (key === ARCHIL_MOUNT_LABEL)
1708
- return `the label ${key} is the provider's own: it records an Archil computer's mount`;
1786
+ if (key === MOUNT_LABEL)
1787
+ return `the label ${key} is the provider's own: it records a computer's mount`;
1709
1788
  return undefined;
1710
1789
  }
1711
1790
  /** "a" or "an" before a vendor's name, by its first letter. */
@@ -45,9 +45,9 @@ export interface HostedCommands {
45
45
  * wait for the daemon (and gate, for an Archil computer); with atomic, install moves the daemon into place last, and only
46
46
  * once it reads sha256, when given, then writes nonce, when given, to the marker the entrypoint waits for. sockets are
47
47
  * the patterns a child's sockets command closes (default SESSION_BUSES); rootOnly the paths its root-only command takes
48
- * others' write off (default none).
48
+ * others' write off (default none). With workspace, install makes WORKSPACE the user's, 0700: a synced folder's.
49
49
  */
50
- export declare function hostedCommands({ staging, deadline, user, display, maxDeadline, atomic, waitS, gate, sha256, nonce, sockets, rootOnly, network, }?: ChildCommandOptions & {
50
+ export declare function hostedCommands({ staging, deadline, user, display, maxDeadline, atomic, waitS, gate, sha256, nonce, sockets, rootOnly, network, workspace, }?: ChildCommandOptions & {
51
51
  atomic?: boolean;
52
52
  waitS?: number;
53
53
  gate?: string;
@@ -55,6 +55,7 @@ export declare function hostedCommands({ staging, deadline, user, display, maxDe
55
55
  nonce?: string;
56
56
  sockets?: readonly string[];
57
57
  rootOnly?: readonly string[];
58
+ workspace?: boolean;
58
59
  }): HostedCommands;
59
60
  export interface ChildCommandOptions {
60
61
  /** Where the vendor's upload left the daemon. */
@@ -7,6 +7,7 @@
7
7
  import { PassThrough } from "node:stream";
8
8
  import { DAEMON_IN_COMPUTER, helloDrift, SOCKET_DIR, WORK } from "../drift.js";
9
9
  import { readOwnNetwork, TOOL_USER } from "../isolation.js";
10
+ import { WORKSPACE } from "../mount.js";
10
11
  import { fail, ok } from "../result.js";
11
12
  const PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
12
13
  const CAPS = ["CapInh", "CapPrm", "CapEff", "CapBnd", "CapAmb"];
@@ -22,22 +23,25 @@ const HELD = 'held() { x=$1; while :; do set -- $(ls -ldn "$x" 2>/dev/null); cas
22
23
  * them to the daemon's user), and prints who installed it and the installed binary's sha256. As root, or through passwordless sudo; else
23
24
  * it says why. The daemon's directory is made root's (0755) even when the image already had it, a stale entry at
24
25
  * the daemon's path is removed first, and the whole path is held to `held` before and after; a path another user can
25
- * change is refused with nothing installed. Every tool is in BusyBox and in coreutils alike: no privilege tool of the
26
- * image's is relied on. */
26
+ * change is refused with nothing installed. A synced folder's /workspace is made the daemon's user's, 0700, before the
27
+ * daemon is moved into place, so before init starts. Every tool is in BusyBox and in coreutils alike: no privilege tool
28
+ * of the image's is relied on. */
27
29
  const INSTALL_SCRIPT = [
28
30
  "# agentrun-computer: install",
29
31
  // a: when set, the binary goes in beside its path and is moved into place last, so a pid1 entrypoint waiting for the
30
32
  // path never starts one half written; e: when set too, the sha256 it must read before it is moved, so the entrypoint
31
33
  // never starts one that is not the daemon uploaded; n: when set too, this create's nonce, written to the marker beside
32
34
  // the daemon once it is in place, so the entrypoint starts the daemon this create installed and never one the image
33
- // had there. (Not x: held() assigns x.)
34
- "s=$1; d=$2; h=$3; r=$4; a=${5-}; e=${6-}; n=${7-}; b=${d%/*}; t=$d; [ -z \"$a\" ] || t=$d.part",
35
+ // had there; k: when set, a synced folder's directory, made u's (the daemon's user, uid:gid). (Not x: held() assigns
36
+ // x, and its `set --` the arguments, so every one is read here.)
37
+ "s=$1; d=$2; h=$3; r=$4; a=${5-}; e=${6-}; n=${7-}; k=${8-}; u=${9-}; b=${d%/*}; t=$d; [ -z \"$a\" ] || t=$d.part",
35
38
  'if [ "$(id -u)" = 0 ]; then p=; elif command -v sudo >/dev/null 2>&1 && sudo -n true 2>/dev/null; then p="sudo -n"; else echo "the sandbox user $(id -un) is not root and has no passwordless sudo, so the daemon cannot be installed"; exit 3; fi',
36
39
  HELD,
37
40
  '[ -d "${b%/*}" ] || $p mkdir -p -m 0755 "${b%/*}" || { echo "installing the daemon at $d failed"; exit 5; }',
38
41
  'held "${b%/*}" || exit 6',
39
42
  '[ ! -L "$b" ] || { echo "the daemon at $d is not root\'s alone: $b is a symbolic link"; exit 6; }',
40
43
  '$p mkdir -p "$b" "$h" "$r" && $p chown 0:0 "$b" && $p chmod 0755 "$b" && $p rm -f "$d" "$t" "$d.installed" && $p install -m 0755 -o 0 -g 0 "$s" "$t" || { echo "installing the daemon at $d failed"; exit 5; }',
44
+ '[ -z "$k" ] || { [ ! -L "$k" ] && $p mkdir -p "$k" && $p chown "$u" "$k" && $p chmod 0700 "$k"; } || { echo "the synced folder $k was not made the computer user\'s"; exit 8; }',
41
45
  'if [ -n "$a" ] && [ -n "$e" ]; then w=$($p sha256sum "$t" | cut -c1-64); [ "$w" = "$e" ] || { echo "sha256 $w"; echo "the daemon written to $t reads sha256 $w, not $e, so it is not moved into place"; $p rm -f "$t"; exit 7; }; fi',
42
46
  '[ "$t" = "$d" ] || $p mv -f "$t" "$d" || { echo "installing the daemon at $d failed"; exit 5; }',
43
47
  'held "$d" || exit 6',
@@ -187,13 +191,14 @@ export const ARCHIL_GATE = `${DAEMON_IN_COMPUTER.slice(0, DAEMON_IN_COMPUTER.las
187
191
  * wait for the daemon (and gate, for an Archil computer); with atomic, install moves the daemon into place last, and only
188
192
  * once it reads sha256, when given, then writes nonce, when given, to the marker the entrypoint waits for. sockets are
189
193
  * the patterns a child's sockets command closes (default SESSION_BUSES); rootOnly the paths its root-only command takes
190
- * others' write off (default none).
194
+ * others' write off (default none). With workspace, install makes WORKSPACE the user's, 0700: a synced folder's.
191
195
  */
192
- export function hostedCommands({ staging = "", deadline = "", user = TOOL_USER, display = "", maxDeadline = "", atomic = false, waitS = 600, gate, sha256 = "", nonce = "", sockets = SESSION_BUSES, rootOnly = [], network = "", } = {}) {
196
+ export function hostedCommands({ staging = "", deadline = "", user = TOOL_USER, display = "", maxDeadline = "", atomic = false, waitS = 600, gate, sha256 = "", nonce = "", sockets = SESSION_BUSES, rootOnly = [], network = "", workspace = false, } = {}) {
193
197
  const init = initScriptArgs({ deadline, user, display, maxDeadline, network });
194
198
  const initArgs = ["init", ...initFlags({ deadline, user, maxDeadline, network })];
199
+ const atomicArgs = atomic ? ["1", sha256, nonce] : workspace ? ["", "", ""] : [];
195
200
  return {
196
- install: argvOf(INSTALL_SCRIPT, [staging, DAEMON_IN_COMPUTER, WORK, SOCKET_DIR, ...(atomic ? ["1", sha256, nonce] : [])]),
201
+ install: argvOf(INSTALL_SCRIPT, [staging, DAEMON_IN_COMPUTER, WORK, SOCKET_DIR, ...atomicArgs, ...(workspace ? [WORKSPACE, user] : [])]),
197
202
  start: argvOf(START_SCRIPT, [INIT_LOG, ...argvOf(INIT_SCRIPT, init)]),
198
203
  stdio: argvOf(STDIO_SCRIPT, [DAEMON_IN_COMPUTER, SOCKET_DIR]),
199
204
  log: argvOf(LOG_SCRIPT, [INIT_LOG]),
@@ -3,11 +3,8 @@ import type { ComputerSpec, Refusal } from "../provider.js";
3
3
  /** A host name, as a vendor's domain option is one: DNS labels and a top-level name of letters. */
4
4
  export declare const DOMAIN: RegExp;
5
5
  export declare const isWhole: (value: unknown) => value is number;
6
- /**
7
- * How a provider that can do both reaches its machines (its descriptor's connect setting): exec (the default), a bridge
8
- * through the vendor's exec for each connection; dial, the machine's computerd dials the server (HostFacts.connect).
9
- */
10
- export declare function connectOf(value: unknown, label: string): "exec" | "dial";
6
+ /** Why a provider of both makes no desktop on exec (label: "Modal"): its desktop is the box image's, started over the dial. */
7
+ export declare const execDesktopRefusal: (label: string, image: string) => string;
11
8
  /** A vendor whose computer has its image's size: a spec's cpus or memoryMb, refused in words (computer: "an E2B computer"). */
12
9
  export declare function sizeRefusals(spec: Partial<ComputerSpec>, computer: string, image: string): Refusal[];
13
10
  /** A time the vendor reports: a Date, an ISO string, or a whole number of ms (or seconds); undefined when it is none of them. */
@@ -4,15 +4,8 @@ import { deflateRawSync, inflateRawSync } from "node:zlib";
4
4
  /** A host name, as a vendor's domain option is one: DNS labels and a top-level name of letters. */
5
5
  export const DOMAIN = /^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/;
6
6
  export const isWhole = (value) => typeof value === "number" && Number.isSafeInteger(value);
7
- /**
8
- * How a provider that can do both reaches its machines (its descriptor's connect setting): exec (the default), a bridge
9
- * through the vendor's exec for each connection; dial, the machine's computerd dials the server (HostFacts.connect).
10
- */
11
- export function connectOf(value, label) {
12
- if (value === undefined || value === "exec" || value === "dial")
13
- return value ?? "exec";
14
- throw new Error(`connect is how ${label} reaches its machines, "exec" (the default) or "dial", not ${JSON.stringify(value)}`);
15
- }
7
+ /** Why a provider of both makes no desktop on exec (label: "Modal"): its desktop is the box image's, started over the dial. */
8
+ export const execDesktopRefusal = (label, image) => `a ${label} desktop is made on connect "dial" alone, from ${image}, its X server started over the socket its machine dials: connect "exec" makes kind linux`;
16
9
  /** A vendor whose computer has its image's size: a spec's cpus or memoryMb, refused in words (computer: "an E2B computer"). */
17
10
  export function sizeRefusals(spec, computer, image) {
18
11
  return ["cpus", "memoryMb"].filter((field) => spec[field] !== undefined).map((field) => ({ field, message: `${computer} has the size of its ${image}: name a ${image} of the size you need, not ${field}` }));
package/dist/index.d.ts CHANGED
@@ -7,6 +7,8 @@ export * from "./mount.js";
7
7
  export { type CallOptions, DaemonClient, type DaemonStream, findNodes, refusedStep, type UiActOptions, type UiQuery, UiSession } from "./client.js";
8
8
  export { type ActionFailure, type CheckActionsOptions, checkActions, isKey } from "./actions.js";
9
9
  export { pullTar, pullTarStream, pushTar, readFile, writeFile, type PulledTar } from "./files.js";
10
+ export { type FolderMeta, FolderSync, folderPathProblem, SYNC_MAX_BYTES, SYNC_MAX_ENTRIES, type SyncCounts, type SyncSink } from "./sync-folder.js";
11
+ export { type TarEntry, TarReader, tarEntry, tarOf, tarStream, untar, untarStream } from "./tar.js";
10
12
  export { listProcesses, readAll, type ReadAllResult } from "./processes.js";
11
13
  export { type ActionMapper, createActionMapper, daemonWatch, redactWords, type ScreenFrame, type ScreenFrames, type ScreenWatch, ScreenWatchError, type ScreenWatchHandlers, toAction, type ViewerEvent, type WatchEndCode, watchEndCode, type WatchOptions, watchScreen, } from "./screen-watch.js";
12
14
  export type { HostCall, HostFacts, Machine, MachineHost, MachineProcess, MachineRequest } from "./host.js";
@@ -14,7 +16,7 @@ export { HostedProvider, type HostedDial, type HostedOptions, type HostedTimeout
14
16
  export { type DockerVolume, VOLUME_SUBPATH_ENGINE } from "./docker/volume.js";
15
17
  export { DEFAULT_DOCKER_IMAGE, DOCKER_BASE, DOCKER_RECIPE, DOCKER_RECIPE_HAS, ensureImage, type EnsureImageOptions, IMAGE_REPOSITORY, IMAGE_TIMEOUT_MS, type ImageSource, imageSourceProblem, type Making, RECIPE_LABEL, recipeHash, recipeTag, } from "./docker/image.js";
16
18
  export { EGRESS_IMAGE, EGRESS_LABEL, EGRESS_MOUNT, EGRESS_SOCKET } from "./docker/egress.js";
17
- export { ARCHIL_HELPER, ARCHIL_MOUNT_LABEL, ARCHIL_SYNC_SOCKET, ARCHIL_TOOL_UID, ARCHIL_TOOL_USER, ARCHIL_VERSION, type ArchilMount, type ArchilEgress, type ArchilMountOptions, type ArchilRoot, type ProviderNote, archilEgressOf, archilLabels, archilMount, archilReadBack, archilRefusals, archilRelease, claimEpoch, helperSha256, mountDrift, mountWords, type RecordedArchil, readArchilMount, recordedArchil, recordedMount, syncingClient, } from "./mount-archil.js";
19
+ export { ARCHIL_HELPER, ARCHIL_SYNC_SOCKET, ARCHIL_TOOL_UID, ARCHIL_TOOL_USER, ARCHIL_VERSION, type ArchilMount, type ArchilEgress, type ArchilMountOptions, type ArchilRoot, type ProviderNote, archilEgressOf, archilLabels, archilMount, archilReadBack, archilRefusals, archilRelease, archilSync, claimEpoch, helperSha256, MOUNT_LABEL, mountDrift, mountWords, type RecordedFolder, type RecordedSource, readMount, recordedFolder, recordedMount, SYNC_LABELS, syncingClient, } from "./mount-archil.js";
18
20
  export { type BrowserComputerProvider, type BrowserDownloads, type BrowserFile, type BrowserProfiles, browserSpecRefusals, type BrowserStream, isBrowserProvider, BrowserVendorError, CREATE_LABEL, causeOf, memoryUrls, RECOVER_MS, type ReleaseConfirm, type RestReply, type UrlStore, } from "./browser.js";
19
21
  export { CHROME_ENV, CHROME_FLAGS, checkChrome, chromeFence, findChrome, killTree, NO_CHROME } from "./chrome.js";
20
22
  export { DAEMON_IN_COMPUTER, helloDrift, type HelloExpected } from "./drift.js";
@@ -23,7 +25,7 @@ export { type ReleasedOlder, releaseOlder, sweep, type SweepOptions, type Swept
23
25
  export { EPOCH_LABEL, epochOf, epochProblem, IDLE_TTL_LABEL, OWNER_LABEL, OWNER_SERVER_LABEL, ownerFilter, ownerLabels, ownerOf, RUN_HASH_LABEL, RUN_LABEL, runHash, runLabels, runProblem } from "./labels.js";
24
26
  export { waitUntil, type WaitOptions } from "./wait.js";
25
27
  export { type BuiltinProviderId, type ConformanceModule, descriptorOf, isProviderId, type ProviderEnv, providerFor, type ProviderId, providerIds, type ProviderModule, providerModule, type ProviderOptions, providers, } from "./providers.js";
26
- export { type DescriptorKey, type DescriptorSetting, defineProvider, descriptorProblems, type HostCommand, mountsOf, type ParkedConfiguration, type ProviderDescriptor } from "./descriptor.js";
28
+ export { connectOf, type DescriptorKey, type DescriptorSetting, defineProvider, descriptorProblems, type HostCommand, mountsOf, type ParkedConfiguration, type ProviderDescriptor } from "./descriptor.js";
27
29
  export { AGENT37, AGENT37_BASE_TEMPLATE, BOXD, BOXD_DEFAULT_IMAGE, BROWSER_IMAGE, BROWSERBASE, DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, type DaytonaGpuSnapshot, DESCRIPTORS, daytonaGpu, daytonaGpuSnapshot, DOCKER, E2B, KERNEL, LOCAL, MODAL, MORPH, ORGO, ORGO_BASE_IMAGE, PHONE_GROUPS, PHONE_HARNESS, PHONE_IMAGE, } from "./descriptors/index.js";
28
30
  export type { PhoneLedger, PhoneLedgerEntry } from "./phone-harness.js";
29
31
  export { type ComputerSettingKind, configurationOf, entryOf, imagesOf, type KindCapabilities, kindOf, kindServed, type ProviderEntry, PROVIDERS, SETTING_KIND_NAMES, SETTING_KINDS, type SettingKindSpec, serves, servingRefusals, type TestConnection, type TestConnectionOptions, } from "./kinds.js";
package/dist/index.js CHANGED
@@ -7,6 +7,8 @@ export * from "./mount.js";
7
7
  export { DaemonClient, findNodes, refusedStep, UiSession } from "./client.js";
8
8
  export { checkActions, isKey } from "./actions.js";
9
9
  export { pullTar, pullTarStream, pushTar, readFile, writeFile } from "./files.js";
10
+ export { FolderSync, folderPathProblem, SYNC_MAX_BYTES, SYNC_MAX_ENTRIES } from "./sync-folder.js";
11
+ export { TarReader, tarEntry, tarOf, tarStream, untar, untarStream } from "./tar.js";
10
12
  export { listProcesses, readAll } from "./processes.js";
11
13
  export { createActionMapper, daemonWatch, redactWords, ScreenWatchError, toAction, watchEndCode, watchScreen, } from "./screen-watch.js";
12
14
  export { HostedProvider, hostedDaemonPath } from "./hosted/provider.js";
@@ -16,7 +18,7 @@ export { HostedProvider, hostedDaemonPath } from "./hosted/provider.js";
16
18
  export { VOLUME_SUBPATH_ENGINE } from "./docker/volume.js";
17
19
  export { DEFAULT_DOCKER_IMAGE, DOCKER_BASE, DOCKER_RECIPE, DOCKER_RECIPE_HAS, ensureImage, IMAGE_REPOSITORY, IMAGE_TIMEOUT_MS, imageSourceProblem, RECIPE_LABEL, recipeHash, recipeTag, } from "./docker/image.js";
18
20
  export { EGRESS_IMAGE, EGRESS_LABEL, EGRESS_MOUNT, EGRESS_SOCKET } from "./docker/egress.js";
19
- export { ARCHIL_HELPER, ARCHIL_MOUNT_LABEL, ARCHIL_SYNC_SOCKET, ARCHIL_TOOL_UID, ARCHIL_TOOL_USER, ARCHIL_VERSION, archilEgressOf, archilLabels, archilMount, archilReadBack, archilRefusals, archilRelease, claimEpoch, helperSha256, mountDrift, mountWords, readArchilMount, recordedArchil, recordedMount, syncingClient, } from "./mount-archil.js";
21
+ export { ARCHIL_HELPER, ARCHIL_SYNC_SOCKET, ARCHIL_TOOL_UID, ARCHIL_TOOL_USER, ARCHIL_VERSION, archilEgressOf, archilLabels, archilMount, archilReadBack, archilRefusals, archilRelease, archilSync, claimEpoch, helperSha256, MOUNT_LABEL, mountDrift, mountWords, readMount, recordedFolder, recordedMount, SYNC_LABELS, syncingClient, } from "./mount-archil.js";
20
22
  export { browserSpecRefusals, isBrowserProvider, BrowserVendorError, CREATE_LABEL, causeOf, memoryUrls, RECOVER_MS, } from "./browser.js";
21
23
  // Local Chrome's provider class is on its provider id's subpath (@parcha/agentrun-computer/local-chrome), as every
22
24
  // provider's is; the Chrome helpers it runs on are not a provider and stay here.
@@ -27,7 +29,7 @@ export { releaseOlder, sweep } from "./janitor.js";
27
29
  export { EPOCH_LABEL, epochOf, epochProblem, IDLE_TTL_LABEL, OWNER_LABEL, OWNER_SERVER_LABEL, ownerFilter, ownerLabels, ownerOf, RUN_HASH_LABEL, RUN_LABEL, runHash, runLabels, runProblem } from "./labels.js";
28
30
  export { waitUntil } from "./wait.js";
29
31
  export { descriptorOf, isProviderId, providerFor, providerIds, providerModule, providers, } from "./providers.js";
30
- export { defineProvider, descriptorProblems, mountsOf } from "./descriptor.js";
32
+ export { connectOf, defineProvider, descriptorProblems, mountsOf } from "./descriptor.js";
31
33
  export { AGENT37, AGENT37_BASE_TEMPLATE, BOXD, BOXD_DEFAULT_IMAGE, BROWSER_IMAGE, BROWSERBASE, DAYTONA, DAYTONA_DEFAULT_SNAPSHOT, DAYTONA_GPU_SNAPSHOT, DESCRIPTORS, daytonaGpu, daytonaGpuSnapshot, DOCKER, E2B, KERNEL, LOCAL, MODAL, MORPH, ORGO, ORGO_BASE_IMAGE, PHONE_GROUPS, PHONE_HARNESS, PHONE_IMAGE, } from "./descriptors/index.js";
32
34
  export { configurationOf, entryOf, imagesOf, kindOf, kindServed, PROVIDERS, SETTING_KIND_NAMES, SETTING_KINDS, serves, servingRefusals, } from "./kinds.js";
33
35
  export * from "./conformance/index.js";
package/dist/kinds.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { DescriptorKey, DescriptorSetting, HostCommand, ParkedConfiguration, ProviderDescriptor } from "./descriptor.js";
1
+ import { type DescriptorKey, type DescriptorSetting, type HostCommand, type ParkedConfiguration, type ProviderDescriptor } from "./descriptor.js";
2
2
  import type { MountKind, Unmounted } from "./mount.js";
3
3
  import type { ComputerKind, Group, HelloResult } from "./protocol.js";
4
4
  import type { ComputerCapabilities, NetworkForm } from "./provider.js";
@@ -64,7 +64,9 @@ export interface ProviderEntry {
64
64
  readonly keys: readonly DescriptorKey[];
65
65
  /** Settings that are no key but go to its options. */
66
66
  readonly settings?: readonly DescriptorSetting[];
67
- /** The mount kinds its computers take; [] cannot mount the run's folder. */
67
+ /** Whether its machines dial the server: always ("dial"), or as its connect option says ("either"); descriptor.ts connectOf. */
68
+ readonly connect?: "dial" | "either";
69
+ /** The mount kinds its computers take, sync derived (derivedMounts); [] cannot mount the run's folder. */
68
70
  readonly mounts: readonly MountKind[];
69
71
  /** Why its computers take none of these mount kinds, each in one sentence (descriptor.ts). */
70
72
  readonly unmounted?: Unmounted;