@parcha/agentrun-computer 0.1.0-beta.53 → 0.1.0-beta.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/host.d.ts CHANGED
@@ -86,8 +86,8 @@ export interface MachineHost {
86
86
  /**
87
87
  * What agentrun-dial wrote in a dial machine, for a create whose machine never dialed: the adapter adds its last lines
88
88
  * to the timeout's words. undefined when agentrun-dial never started there. A host that started agentrun-dial itself
89
- * and can read its output has it (Daytona's: its session command's log); it replaces the machine's token with
90
- * `<token>` should agentrun-dial have written it. A read that fails throws, and the timeout's words stay as they were.
89
+ * and can read its output has it (Daytona's: its session command's log). A read that fails throws, and the timeout's
90
+ * words stay as they were.
91
91
  */
92
92
  dialLog?(id: string, ctx: HostCall): Promise<string | undefined>;
93
93
  /**
@@ -28,7 +28,11 @@ export interface HostedTimeouts {
28
28
  * listings while create waits for the new computer to show: those start at 150 ms and double up to it.
29
29
  */
30
30
  pollMs: number;
31
- /** How long create waits for the listing to show the new computer. */
31
+ /**
32
+ * How long create waits for the listing to show the new computer. A computer still not listed then is read by its id:
33
+ * one that reads running with its labels is kept, with a note, since a vendor's listing may trail its create (Daytona's
34
+ * is eventually consistent); any other is a timeout.
35
+ */
32
36
  listedMs: number;
33
37
  /**
34
38
  * The listing's stability window: create's wait ends once the listing has shown the new computer on two consecutive
@@ -11,7 +11,7 @@ import { readFileSync } from "node:fs";
11
11
  import { resolve } from "node:path";
12
12
  import { fileURLToPath } from "node:url";
13
13
  import { isDeepStrictEqual } from "node:util";
14
- import { ATTACH_EGRESS_ENV, ATTACH_PATH, attachEgressOf, DAEMON_PATH } from "../attach.js";
14
+ import { ATTACH_EGRESS_ENV, ATTACH_PATH, attachEgressOf, DAEMON_PATH, MACHINE_TOKEN_SOURCE } from "../attach.js";
15
15
  import { CreateRequests, endedWords, otherSpecWords, readBackDiffer } from "../create-requests.js";
16
16
  import { mountsOf, syncs } from "../descriptor.js";
17
17
  import { desktopOf, startDisplay } from "../desktop.js";
@@ -71,6 +71,11 @@ const START_POLL_MS = 500;
71
71
  /** How much of agentrun-dial's output a dial timeout carries (MachineHost.dialLog): its last lines, cut to these characters. */
72
72
  const DIAL_LOG_LINES = 10;
73
73
  const DIAL_LOG_CHARS = 800;
74
+ /**
75
+ * A machine token anywhere in what agentrun-dial wrote, not the tail of a longer word (`restart_…`): a dial timeout's
76
+ * words carry `<token>` in its place.
77
+ */
78
+ const MACHINE_TOKEN = new RegExp(`(?<![A-Za-z0-9_-])${MACHINE_TOKEN_SOURCE}`, "g");
74
79
  /**
75
80
  * The computerd build a hosted machine of arch runs: HostedProvider's default daemonPath, and the file serve's daemon
76
81
  * route serves, so the sha256 a dial machine checks (AGENTRUN_DAEMON_SHA256) is this file's.
@@ -184,6 +189,13 @@ export class HostedProvider {
184
189
  /** What the vendor said a machine this create made was given (Machine.resources), by machine id, from its read once it
185
190
  * ran (#prepare) until the create answers with it (#createOnce). */
186
191
  #given = new Map();
192
+ /**
193
+ * Each computer create kept while the vendor's listing still left it out (#unlisted), by name to machine id: a retry
194
+ * of its request finds it here, read by its id, where the name's listing would not show it yet. An entry goes once
195
+ * the listing shows the name, a read finds the machine gone or not this one, or release deletes it. This instance's
196
+ * alone: another instance's retry still waits on the listing.
197
+ */
198
+ #keptUnlisted = new Map();
187
199
  /** A dial host's server: what its machines reach, and what holds their tokens and sockets. */
188
200
  #dial;
189
201
  /** The host's descriptor's mounts as its machines reach this server (mountsOf): a dial host's take no Archil mount. */
@@ -535,6 +547,15 @@ export class HostedProvider {
535
547
  if (!listed.ok)
536
548
  return listed;
537
549
  const found = listed.value.filter((machine) => ours(machine.labels, name));
550
+ if (found.length === 0) {
551
+ const kept = await this.#keptOf(name, signal);
552
+ if (!kept.ok)
553
+ return kept;
554
+ if (kept.value !== undefined)
555
+ return this.#again(spec, name, kept.value, signal);
556
+ }
557
+ else
558
+ this.#keptUnlisted.delete(name);
538
559
  if (found.length > 1)
539
560
  return this.#fail("exists", `${found.length} machines carry the name ${name} (${found.map((m) => m.id).join(", ")}): create with a new request id`);
540
561
  if (found.length === 1)
@@ -573,6 +594,23 @@ export class HostedProvider {
573
594
  return this.#again(spec, name, last.value, signal);
574
595
  return ok({ ...ref, ...(prepared.value.length > 0 ? { notes: prepared.value } : {}), ...(given === undefined ? {} : { resources: given }) });
575
596
  }
597
+ /**
598
+ * The computer create kept for this name while the listing left it out (#keptUnlisted), read by its id now: undefined
599
+ * when there is none, or the read finds it gone or not this name's (the entry then goes). A read that fails fails the
600
+ * create, the entry kept: a retry never asks the vendor for a second computer while the first may still be up.
601
+ */
602
+ async #keptOf(name, signal) {
603
+ const id = this.#keptUnlisted.get(name);
604
+ if (id === undefined)
605
+ return ok(undefined);
606
+ const read = await this.#get(id, signal);
607
+ if (!read.ok)
608
+ return this.#fail(read.error.code, `${name} (machine ${id}), which create kept while the listing left it out, could not be read, so no second computer is made: ${read.error.message}`);
609
+ if (read.value !== undefined && ours(read.value.labels, name) && alive(read.value.state))
610
+ return ok(read.value);
611
+ this.#keptUnlisted.delete(name);
612
+ return ok(undefined);
613
+ }
576
614
  /**
577
615
  * The one machine a request keeps. Two creates of one request on two provider instances can both find no machine by
578
616
  * the name and both make one: #requests holds within one instance alone, and a vendor's name or label need not be
@@ -993,7 +1031,7 @@ export class HostedProvider {
993
1031
  await opened.value.close();
994
1032
  }
995
1033
  const listed = await this.#waitListed(ref, signal);
996
- return listed.ok ? ok([...closed, ...notes]) : listed;
1034
+ return listed.ok ? ok([...closed, ...notes, ...listed.value]) : listed;
997
1035
  }
998
1036
  /** What init wrote to its log (child) or the vendor's words of the machine (pid1): the end of it, or nothing. */
999
1037
  async #initWords(ref) {
@@ -1140,9 +1178,10 @@ export class HostedProvider {
1140
1178
  }
1141
1179
  }
1142
1180
  /**
1143
- * A dial timeout's last words: what the host's dialLog read of agentrun-dial, its last DIAL_LOG_LINES lines within
1144
- * DIAL_LOG_CHARS characters, or that it never started. Nothing for a host without dialLog, or a read that fails,
1145
- * outlasts requestMs or is cut by the create's signal, so a cancel never waits on it.
1181
+ * A dial timeout's last words: what the host's dialLog read of agentrun-dial, every machine token replaced by
1182
+ * `<token>`, its last DIAL_LOG_LINES lines within DIAL_LOG_CHARS characters, or that it never started. Nothing for a
1183
+ * host without dialLog, or a read that fails, outlasts requestMs or is cut by the create's signal, so a cancel never
1184
+ * waits on it.
1146
1185
  */
1147
1186
  async #dialWords(ref, signal) {
1148
1187
  const { dialLog } = this.host;
@@ -1153,7 +1192,7 @@ export class HostedProvider {
1153
1192
  return "";
1154
1193
  if (read.value === undefined)
1155
1194
  return "; agentrun-dial never started";
1156
- const lines = read.value.split(/\r?\n/).map((line) => line.trim()).filter((line) => line !== "");
1195
+ const lines = read.value.replaceAll(MACHINE_TOKEN, "<token>").split(/\r?\n/).map((line) => line.trim()).filter((line) => line !== "");
1157
1196
  return lines.length === 0 ? "; agentrun-dial wrote nothing" : `; agentrun-dial said: ${lines.slice(-DIAL_LOG_LINES).join(" | ").slice(-DIAL_LOG_CHARS)}`;
1158
1197
  }
1159
1198
  /**
@@ -1214,30 +1253,53 @@ export class HostedProvider {
1214
1253
  * Create waits until the listing shows the new computer on two consecutive polls at least listedStableMs apart (and on
1215
1254
  * every poll between), so list() shows it once create returns: a listing that showed it once and then not starts over.
1216
1255
  * The polls are 150 ms apart at first, the pause doubling up to pollMs, so a vendor slow to list costs a few calls.
1256
+ * A listing that has not settled by listedMs is no failure alone (#unlisted): the computer is read by its id.
1217
1257
  */
1218
1258
  async #waitListed(ref, signal) {
1219
1259
  const { listedMs, listMs, pollMs, listedStableMs } = this.#timeouts;
1220
- const until = Date.now() + listedMs;
1260
+ const began = Date.now();
1261
+ const until = began + listedMs;
1221
1262
  let since;
1263
+ const seen = { polls: 0, shown: 0 };
1222
1264
  for (let hits = 0, delay = Math.min(LISTED_POLL_MS, pollMs);; delay = Math.min(delay * 2, pollMs)) {
1223
1265
  const listed = await listedBy(this.host, "the listing by name", byName(ref.name), listMs, signal);
1224
1266
  if (!listed.ok)
1225
1267
  return listed;
1268
+ seen.polls += 1;
1226
1269
  if (listed.value.some((machine) => machine.id === ref.id)) {
1227
1270
  hits += 1;
1271
+ seen.shown += 1;
1228
1272
  since ??= Date.now();
1229
1273
  }
1230
1274
  else
1231
1275
  [hits, since] = [0, undefined];
1232
1276
  if (hits >= LISTED_ROUNDS && since !== undefined && Date.now() - since >= listedStableMs)
1233
- return ok(undefined);
1277
+ return ok([]);
1234
1278
  if (Date.now() >= until)
1235
- return this.#fail("timeout", `the computer was not listed within ${seconds(listedMs)} of its creation`);
1279
+ return this.#unlisted(ref, { ...seen, ms: Date.now() - began }, signal);
1236
1280
  await pause(Math.min(delay, until - Date.now()), signal);
1237
1281
  if (signal?.aborted)
1238
1282
  return this.#fail("aborted", "create was aborted while it waited for the listing");
1239
1283
  }
1240
1284
  }
1285
+ /**
1286
+ * A new computer the listing did not show twice in a row within listedMs, read by its id: one that reads running and
1287
+ * carries its labels is kept, the note saying so (create already reached its daemon and checked it from inside, so only
1288
+ * the vendor's listing lags; list() leaves it out until that listing shows it). Any other answer, or a read that fails,
1289
+ * is a timeout naming the labels asked for, the machine, the polls and the time waited.
1290
+ */
1291
+ async #unlisted(ref, seen, signal) {
1292
+ const asked = Object.entries(byName(ref.name)).map(([key, value]) => `${key}=${value}`).join(", ");
1293
+ const what = `the listing by the labels ${asked} did not show ${ref.name} (machine ${ref.id}) on ${LISTED_ROUNDS} polls in a row within ${seconds(this.#timeouts.listedMs)} (${seen.polls} polls in ${seconds(seen.ms)}, ${seen.shown} of them showed it)`;
1294
+ const read = await this.#own(ref, signal);
1295
+ if (signal?.aborted)
1296
+ return this.#fail("aborted", "create was aborted while it waited for the listing");
1297
+ if (read.ok && read.value.state === "running") {
1298
+ this.#keptUnlisted.set(ref.name, ref.id);
1299
+ return ok([`${what}; a read by its id finds it running with its labels, so it is kept: the vendor's listing trails its create, and list() leaves the computer out until it shows it`]);
1300
+ }
1301
+ return this.#fail("timeout", `${what}; ${read.ok ? `a read by its id finds it ${read.value.state}` : `a read by its id: ${read.error.message}`}`);
1302
+ }
1241
1303
  /** This provider's machine for ref, as the vendor reads it, or why not. */
1242
1304
  async #own(ref, signal) {
1243
1305
  const found = await this.#get(ref.id, signal);
@@ -1559,6 +1621,8 @@ export class HostedProvider {
1559
1621
  return this.#fail("unsupported", `${a(this.#label)} computer is deleted, never stopped and kept: release it with delete`);
1560
1622
  if (how !== "delete")
1561
1623
  return this.#fail("invalid", `release is "delete", not ${String(how)}`);
1624
+ if (this.#keptUnlisted.get(ref.name) === ref.id)
1625
+ this.#keptUnlisted.delete(ref.name);
1562
1626
  const found = await this.#get(ref.id);
1563
1627
  if (!found.ok)
1564
1628
  return found;
@@ -60,10 +60,13 @@ export declare function hostedCommands({ staging, deadline, user, display, maxDe
60
60
  workspace?: boolean;
61
61
  }): HostedCommands;
62
62
  /**
63
- * The shell line a provider that starts agentrun-dial itself runs, as root. On dial the adapter runs nothing in the
64
- * machine, so the line runs the steps the exec path runs before init first: rootOnly made root's alone when it names
65
- * paths (HostFacts.rootOnly), then the session buses in /tmp closed (SESSION_BUSES). Joined by &&, so a step that fails
66
- * starts nothing, and the machine never dials. attach, when given, is AGENTRUN_ATTACH_URL's quoted assignment on the line.
63
+ * The shell line a provider that starts agentrun-dial itself runs, as root, under umask 077 whatever the vendor's, as on
64
+ * the exec path (START_SCRIPT): init's start log is root's alone, and init and every program the computer runs inherit
65
+ * 077 (init gives /work to the computer's user, 0700). On
66
+ * dial the adapter runs nothing in the machine, so the line runs the steps the exec path runs before init first:
67
+ * rootOnly made root's alone when it names paths (HostFacts.rootOnly), then the session buses in /tmp closed
68
+ * (SESSION_BUSES). Joined by &&, so a step that fails starts nothing, and the machine never dials. attach, when given, is
69
+ * AGENTRUN_ATTACH_URL's quoted assignment on the line.
67
70
  */
68
71
  export declare function dialLaunch({ rootOnly, attach }?: {
69
72
  rootOnly?: readonly string[] | undefined;
@@ -97,9 +97,10 @@ export const AGENTRUN_DIAL = "/usr/local/bin/agentrun-dial";
97
97
  export const INIT_LOG = `${SOCKET_DIR}-init.log`;
98
98
  /**
99
99
  * Starts init detached from the call that starts it: in a session of its own (setsid), its output to the log, its stdin
100
- * none, so the vendor's call ends at once and nothing of it holds init. As root, or through passwordless sudo.
100
+ * none, so the vendor's call ends at once and nothing of it holds init. As root, or through passwordless sudo, under
101
+ * umask 077, so the log is root's alone whatever the vendor's umask.
101
102
  */
102
- const START_SCRIPT = ["# agentrun-computer: start", "l=$1; shift", ROOT, `exec $p sh -c 'exec >"$0" 2>&1 </dev/null; setsid "$@" &' "$l" "$@"`].join("\n");
103
+ const START_SCRIPT = ["# agentrun-computer: start", "l=$1; shift", ROOT, `exec $p sh -c 'umask 077; exec >"$0" 2>&1 </dev/null; setsid "$@" &' "$l" "$@"`].join("\n");
103
104
  /**
104
105
  * The session buses a vendor's own processes leave in /tmp (Daytona's D-Bus, /tmp/dbus-Y8OW6E3FDx), which no network
105
106
  * namespace cuts: every child host's create closes them to the computer's user before init starts. The window
@@ -211,13 +212,17 @@ export function hostedCommands({ staging = "", deadline = "", user = TOOL_USER,
211
212
  };
212
213
  }
213
214
  /**
214
- * The shell line a provider that starts agentrun-dial itself runs, as root. On dial the adapter runs nothing in the
215
- * machine, so the line runs the steps the exec path runs before init first: rootOnly made root's alone when it names
216
- * paths (HostFacts.rootOnly), then the session buses in /tmp closed (SESSION_BUSES). Joined by &&, so a step that fails
217
- * starts nothing, and the machine never dials. attach, when given, is AGENTRUN_ATTACH_URL's quoted assignment on the line.
215
+ * The shell line a provider that starts agentrun-dial itself runs, as root, under umask 077 whatever the vendor's, as on
216
+ * the exec path (START_SCRIPT): init's start log is root's alone, and init and every program the computer runs inherit
217
+ * 077 (init gives /work to the computer's user, 0700). On
218
+ * dial the adapter runs nothing in the machine, so the line runs the steps the exec path runs before init first:
219
+ * rootOnly made root's alone when it names paths (HostFacts.rootOnly), then the session buses in /tmp closed
220
+ * (SESSION_BUSES). Joined by &&, so a step that fails starts nothing, and the machine never dials. attach, when given, is
221
+ * AGENTRUN_ATTACH_URL's quoted assignment on the line.
218
222
  */
219
223
  export function dialLaunch({ rootOnly = [], attach } = {}) {
220
224
  return [
225
+ "umask 077",
221
226
  ...(rootOnly.length > 0 ? [shellLine(hostedCommands({ rootOnly }).rootOnly)] : []),
222
227
  shellLine(hostedCommands().sockets),
223
228
  `${attach === undefined ? "" : `AGENTRUN_ATTACH_URL=${quote(attach)} `}exec ${AGENTRUN_DIAL}`,
package/dist/index.d.ts CHANGED
@@ -7,8 +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, PUSHED_MTIME, SYNC_MAX_BYTES, SYNC_MAX_ENTRIES, type SyncCounts, type SyncSink } from "./sync-folder.js";
11
- export { MAX_TAR_MTIME, type TarEntry, TarReader, tarEntry, tarOf, tarStream, untar, untarStream } from "./tar.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";
12
12
  export { listProcesses, readAll, type ReadAllResult } from "./processes.js";
13
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";
14
14
  export type { HostCall, HostFacts, Machine, MachineHost, MachineProcess, MachineRequest } from "./host.js";
@@ -26,7 +26,7 @@ export { EPOCH_LABEL, epochOf, epochProblem, IDLE_TTL_LABEL, OWNER_LABEL, OWNER_
26
26
  export { waitUntil, type WaitOptions } from "./wait.js";
27
27
  export { type BuiltinProviderId, type ConformanceModule, descriptorOf, isProviderId, type ProviderEnv, providerFor, type ProviderId, providerIds, type ProviderModule, providerModule, type ProviderOptions, providers, } from "./providers.js";
28
28
  export { connectOf, type DescriptorKey, type DescriptorSetting, defineProvider, descriptorProblems, type HostCommand, mountsOf, type ParkedConfiguration, type ProviderDescriptor } from "./descriptor.js";
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, SMOLCLOUD, } from "./descriptors/index.js";
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, GROUNDBOX, GROUNDBOX_OWN_IMAGE, KERNEL, LOCAL, MODAL, MORPH, ORGO, ORGO_BASE_IMAGE, PHONE_GROUPS, PHONE_HARNESS, PHONE_IMAGE, SMOLCLOUD, } from "./descriptors/index.js";
30
30
  export type { PhoneLedger, PhoneLedgerEntry } from "./phone-harness.js";
31
31
  export { configurationOf, entryOf, imagesOf, type KindCapabilities, kindOf, kindServed, type ProviderEntry, PROVIDERS, serves, servingRefusals, type TestConnection, type TestConnectionOptions, } from "./kinds.js";
32
32
  export { type ComputerSettingKind, SETTING_KIND_NAMES, SETTING_KINDS, type SettingKindSpec } from "./setting-kinds.js";
package/dist/index.js CHANGED
@@ -7,14 +7,14 @@ 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, PUSHED_MTIME, SYNC_MAX_BYTES, SYNC_MAX_ENTRIES } from "./sync-folder.js";
11
- export { MAX_TAR_MTIME, TarReader, tarEntry, tarOf, tarStream, untar, untarStream } from "./tar.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";
12
12
  export { listProcesses, readAll } from "./processes.js";
13
13
  export { createActionMapper, daemonWatch, redactWords, ScreenWatchError, toAction, watchEndCode, watchScreen, } from "./screen-watch.js";
14
14
  export { HostedProvider, hostedDaemonPath } from "./hosted/provider.js";
15
15
  // The provider classes and their option types are not here: each provider loads by its id through the registry
16
16
  // (providerFor), or from its own subpath (@parcha/agentrun-computer/docker, /daytona, /modal, /e2b, /agent37, /morph, /orgo,
17
- // /phone-harness, /browserbase, /kernel, /local, /smolcloud: each the provider file's name).
17
+ // /phone-harness, /browserbase, /kernel, /local, /smolcloud, /groundbox: each the provider file's name).
18
18
  export { VOLUME_SUBPATH_ENGINE } from "./docker/volume.js";
19
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";
20
20
  export { EGRESS_IMAGE, EGRESS_LABEL, EGRESS_MOUNT, EGRESS_SOCKET } from "./docker/egress.js";
@@ -30,7 +30,7 @@ export { EPOCH_LABEL, epochOf, epochProblem, IDLE_TTL_LABEL, OWNER_LABEL, OWNER_
30
30
  export { waitUntil } from "./wait.js";
31
31
  export { descriptorOf, isProviderId, providerFor, providerIds, providerModule, providers, } from "./providers.js";
32
32
  export { connectOf, defineProvider, descriptorProblems, mountsOf } from "./descriptor.js";
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, SMOLCLOUD, } from "./descriptors/index.js";
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, GROUNDBOX, GROUNDBOX_OWN_IMAGE, KERNEL, LOCAL, MODAL, MORPH, ORGO, ORGO_BASE_IMAGE, PHONE_GROUPS, PHONE_HARNESS, PHONE_IMAGE, SMOLCLOUD, } from "./descriptors/index.js";
34
34
  export { configurationOf, entryOf, imagesOf, kindOf, kindServed, PROVIDERS, serves, servingRefusals, } from "./kinds.js";
35
35
  export { SETTING_KIND_NAMES, SETTING_KINDS } from "./setting-kinds.js";
36
36
  export * from "./conformance/index.js";
@@ -1,16 +1,10 @@
1
1
  import { type ComputerClient } from "./protocol.js";
2
2
  import { type Result } from "./result.js";
3
+ import { type TarEntry } from "./tar.js";
3
4
  /** The most entries (files, directories and links) a synced folder holds: over it, a sync fails, kind limit. */
4
5
  export declare const SYNC_MAX_ENTRIES = 20000;
5
6
  /** The most bytes a synced folder's files hold together: over it, a sync fails, kind limit. */
6
7
  export declare const SYNC_MAX_BYTES: number;
7
- /**
8
- * The mtime (whole seconds) a push into a synced folder gives each file, in its tar header, which computerd's extraction
9
- * keeps: 2000-01-01T00:00:00Z. Older than any reading of the computer's clock, so a write after the push, even in its
10
- * own clock tick, never leaves a file at it, and the newest mtime in a listing that holds such a write is still one of
11
- * the computer's clock, as the racy rule needs. Not 1970: a zip of the folder can't hold a time before 1980.
12
- */
13
- export declare const PUSHED_MTIME = 946684800;
14
8
  /**
15
9
  * The folder's modes and links: what an object store keeps no record of. A mode is listed where it is not the default
16
10
  * (0644 for a file, 0755 for a directory); a link by its target, as written, never followed.
@@ -55,9 +49,19 @@ export declare class FolderSync {
55
49
  now?: () => number;
56
50
  });
57
51
  /**
58
- * The manifest of a folder just pushed from the sink, each file at PUSHED_MTIME, read, never guessed: what it lists is
59
- * what the sink holds, so nothing is pulled, and a later write moves a file's mtime off the one it lists. Over a cap,
60
- * it fails, kind limit.
52
+ * `entries` (the sink's copy of the folder) pushed into the computer's folder as one streaming tar, each file at
53
+ * PUSHED_MTIME, then the baseline taken: the rule a push into a synced folder keeps, in one place. `entries` is read
54
+ * only as pushTar reads it, so an abort or a failing source ends it as it ends any push (a source that throws is a
55
+ * failed push, and the source is let go). A failure says which step it was: "could not be pushed into the computer:
56
+ * ..." or "pushed into the computer could not be listed: ...", its code kept.
57
+ */
58
+ push(entries: AsyncIterable<TarEntry> | Iterable<TarEntry>, options?: {
59
+ signal?: AbortSignal;
60
+ }): Promise<Result<void>>;
61
+ /**
62
+ * The manifest of a folder just pushed from the sink, each file at PUSHED_MTIME (push() does both), read, never
63
+ * guessed: what it lists is what the sink holds, so nothing is pulled, and a later write moves a file's mtime off the
64
+ * one it lists. Over a cap, it fails, kind limit.
61
65
  */
62
66
  baseline(options?: {
63
67
  signal?: AbortSignal;
@@ -11,11 +11,11 @@
11
11
  // re-read, a touch) are not put again. While a directory the computer's user can't read hides what the sink holds under
12
12
  // it (files.list lists one without what it holds), a sync writes nothing and fails in words.
13
13
  import { createHash } from "node:crypto";
14
- import { pullTarStream } from "./files.js";
14
+ import { pullTarStream, pushTar } from "./files.js";
15
15
  import { WORKSPACE } from "./mount.js";
16
16
  import { MAX_CHUNK_BYTES, MAX_LIST_DEPTH, MAX_LIST_ENTRIES } from "./protocol.js";
17
- import { fail, ok } from "./result.js";
18
- import { untarStream } from "./tar.js";
17
+ import { fail, failAs, ok } from "./result.js";
18
+ import { tarStream, untarStream } from "./tar.js";
19
19
  /** The most entries (files, directories and links) a synced folder holds: over it, a sync fails, kind limit. */
20
20
  export const SYNC_MAX_ENTRIES = 20_000;
21
21
  /** The most bytes a synced folder's files hold together: over it, a sync fails, kind limit. */
@@ -30,7 +30,7 @@ const RACY_MS = 1000;
30
30
  * own clock tick, never leaves a file at it, and the newest mtime in a listing that holds such a write is still one of
31
31
  * the computer's clock, as the racy rule needs. Not 1970: a zip of the folder can't hold a time before 1980.
32
32
  */
33
- export const PUSHED_MTIME = 946_684_800;
33
+ const PUSHED_MTIME = 946_684_800;
34
34
  const TOO_MANY = `the run's folder holds more than ${SYNC_MAX_ENTRIES} entries, the most a synced folder holds`;
35
35
  const FILE_MODE = 0o644;
36
36
  const DIR_MODE = 0o755;
@@ -132,9 +132,27 @@ export class FolderSync {
132
132
  this.#now = now;
133
133
  }
134
134
  /**
135
- * The manifest of a folder just pushed from the sink, each file at PUSHED_MTIME, read, never guessed: what it lists is
136
- * what the sink holds, so nothing is pulled, and a later write moves a file's mtime off the one it lists. Over a cap,
137
- * it fails, kind limit.
135
+ * `entries` (the sink's copy of the folder) pushed into the computer's folder as one streaming tar, each file at
136
+ * PUSHED_MTIME, then the baseline taken: the rule a push into a synced folder keeps, in one place. `entries` is read
137
+ * only as pushTar reads it, so an abort or a failing source ends it as it ends any push (a source that throws is a
138
+ * failed push, and the source is let go). A failure says which step it was: "could not be pushed into the computer:
139
+ * ..." or "pushed into the computer could not be listed: ...", its code kept.
140
+ */
141
+ async push(entries, options = {}) {
142
+ const stamped = (async function* () {
143
+ for await (const entry of entries)
144
+ yield entry.type === "file" ? { ...entry, mtime: PUSHED_MTIME } : entry;
145
+ })();
146
+ const pushed = await pushTar(this.#client, this.#root, tarStream(stamped), options);
147
+ if (!pushed.ok)
148
+ return failAs(pushed.error, `could not be pushed into the computer: ${pushed.error.message}`);
149
+ const listed = await this.baseline(options);
150
+ return listed.ok ? listed : failAs(listed.error, `pushed into the computer could not be listed: ${listed.error.message}`);
151
+ }
152
+ /**
153
+ * The manifest of a folder just pushed from the sink, each file at PUSHED_MTIME (push() does both), read, never
154
+ * guessed: what it lists is what the sink holds, so nothing is pulled, and a later write moves a file's mtime off the
155
+ * one it lists. Over a cap, it fails, kind limit.
138
156
  */
139
157
  async baseline(options = {}) {
140
158
  const listed = await this.#list(options.signal);
package/dist/tar.d.ts CHANGED
@@ -10,8 +10,6 @@ export interface TarEntry {
10
10
  */
11
11
  mtime?: number;
12
12
  }
13
- /** The latest mtime a ustar header holds: 11 octal digits of seconds. */
14
- export declare const MAX_TAR_MTIME: number;
15
13
  /** One entry's blocks: a pax header first where its name or link does not fit ustar's 100 bytes, then its own, its body and the padding. */
16
14
  export declare function tarEntry(entry: TarEntry): Buffer[];
17
15
  /** A whole archive of these entries. */
package/dist/tar.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // ways: ustar out, with a pax header for a name or a link target past ustar's 100 bytes; ustar, pax and GNU long names
3
3
  // in, one entry at a time, each with its whole body, so what is held is one entry, never the archive.
4
4
  /** The latest mtime a ustar header holds: 11 octal digits of seconds. */
5
- export const MAX_TAR_MTIME = 8 ** 11 - 1;
5
+ const MAX_TAR_MTIME = 8 ** 11 - 1;
6
6
  const BLOCK = 512;
7
7
  const END = Buffer.alloc(2 * BLOCK);
8
8
  const TYPE_FLAG = { file: "0", dir: "5", symlink: "2", other: "0" };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun-computer",
3
- "version": "0.1.0-beta.53",
3
+ "version": "0.1.0-beta.54",
4
4
  "description": "The open platform's computer protocol: a daemon in every computer, and one provisioner per vendor, starting with Docker.",
5
5
  "keywords": [
6
6
  "agentrun",
@@ -9,7 +9,8 @@
9
9
  "docker",
10
10
  "daytona",
11
11
  "boxd",
12
- "smolcloud"
12
+ "smolcloud",
13
+ "groundbox"
13
14
  ],
14
15
  "type": "module",
15
16
  "license": "Apache-2.0",
@@ -72,6 +73,10 @@
72
73
  "types": "./dist/boxd.d.ts",
73
74
  "default": "./dist/boxd.js"
74
75
  },
76
+ "./groundbox": {
77
+ "types": "./dist/groundbox.d.ts",
78
+ "default": "./dist/groundbox.js"
79
+ },
75
80
  "./orgo": {
76
81
  "types": "./dist/orgo.d.ts",
77
82
  "default": "./dist/orgo.js"
@@ -126,6 +131,7 @@
126
131
  "test:modal": "node --test --test-timeout=1800000 test/modal/*.test.mjs",
127
132
  "test:e2b": "node --test --test-timeout=1800000 test/e2b/*.test.mjs",
128
133
  "test:boxd": "node --test --test-timeout=1800000 test/boxd/*.test.mjs",
134
+ "test:groundbox": "node --test --test-timeout=1800000 test/groundbox/*.test.mjs",
129
135
  "conformance": "node dist/conformance/cli.js"
130
136
  },
131
137
  "repository": {