@parcha/agentrun-computer 0.1.0-beta.37 → 0.1.0-beta.38

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 (93) hide show
  1. package/README.md +259 -203
  2. package/box/Dockerfile +18 -1
  3. package/box/README.md +13 -0
  4. package/box/build-agent37.mjs +8 -27
  5. package/box/build-daytona.py +2 -2
  6. package/box/build-e2b.mjs +41 -18
  7. package/box/recipe.mjs +43 -0
  8. package/dist/agent37-ssh.d.ts +89 -0
  9. package/dist/agent37-ssh.js +445 -0
  10. package/dist/agent37.d.ts +2 -63
  11. package/dist/agent37.js +104 -461
  12. package/dist/browserbase.d.ts +0 -6
  13. package/dist/browserbase.js +1 -5
  14. package/dist/client.d.ts +12 -3
  15. package/dist/client.js +39 -4
  16. package/dist/computerd-linux-amd64 +0 -0
  17. package/dist/computerd-linux-arm64 +0 -0
  18. package/dist/computerd.json +4 -0
  19. package/dist/conformance/cases/apps.d.ts +6 -0
  20. package/dist/conformance/cases/apps.js +18 -5
  21. package/dist/conformance/cases/isolation.d.ts +7 -5
  22. package/dist/conformance/cases/isolation.js +44 -14
  23. package/dist/conformance/cases/mount.js +1 -1
  24. package/dist/conformance/cli.js +66 -6
  25. package/dist/conformance/daytona.d.ts +9 -20
  26. package/dist/conformance/daytona.js +12 -21
  27. package/dist/conformance/exec-stream.d.ts +45 -0
  28. package/dist/conformance/exec-stream.js +486 -0
  29. package/dist/conformance/sweep.js +8 -8
  30. package/dist/conformance/types.d.ts +2 -2
  31. package/dist/create-requests.d.ts +1 -1
  32. package/dist/daytona.d.ts +20 -131
  33. package/dist/daytona.js +405 -1450
  34. package/dist/descriptor.d.ts +6 -1
  35. package/dist/descriptor.js +7 -0
  36. package/dist/descriptors/agent37.d.ts +1 -1
  37. package/dist/descriptors/agent37.js +1 -1
  38. package/dist/descriptors/daytona.d.ts +6 -5
  39. package/dist/descriptors/daytona.js +9 -5
  40. package/dist/descriptors/index.d.ts +4 -5
  41. package/dist/descriptors/shared.d.ts +1 -1
  42. package/dist/descriptors/shared.js +2 -2
  43. package/dist/desktop.d.ts +18 -4
  44. package/dist/desktop.js +89 -9
  45. package/dist/docker.d.ts +0 -6
  46. package/dist/docker.js +1 -5
  47. package/dist/drift.js +4 -4
  48. package/dist/e2b.d.ts +10 -128
  49. package/dist/e2b.js +130 -233
  50. package/dist/host.d.ts +106 -87
  51. package/dist/host.js +8 -1
  52. package/dist/hosted/process.d.ts +22 -8
  53. package/dist/hosted/process.js +75 -44
  54. package/dist/hosted/provider.d.ts +35 -21
  55. package/dist/hosted/provider.js +312 -261
  56. package/dist/hosted/rest.d.ts +66 -0
  57. package/dist/hosted/rest.js +121 -0
  58. package/dist/hosted/scripts.d.ts +8 -2
  59. package/dist/hosted/scripts.js +27 -2
  60. package/dist/hosted/values.d.ts +5 -0
  61. package/dist/hosted/values.js +8 -0
  62. package/dist/index.d.ts +1 -1
  63. package/dist/index.js +1 -1
  64. package/dist/kernel.d.ts +0 -6
  65. package/dist/kernel.js +1 -5
  66. package/dist/kinds.d.ts +3 -1
  67. package/dist/local-chrome.d.ts +0 -6
  68. package/dist/local-chrome.js +1 -5
  69. package/dist/modal.d.ts +7 -84
  70. package/dist/modal.js +50 -174
  71. package/dist/mount-archil.d.ts +8 -4
  72. package/dist/mount-archil.js +22 -11
  73. package/dist/mount.d.ts +10 -4
  74. package/dist/mount.js +8 -4
  75. package/dist/orgo.d.ts +0 -9
  76. package/dist/orgo.js +2 -9
  77. package/dist/phone-harness.d.ts +0 -6
  78. package/dist/phone-harness.js +0 -4
  79. package/dist/protocol.d.ts +4 -1
  80. package/dist/protocol.js +1 -0
  81. package/dist/provider.d.ts +2 -2
  82. package/dist/providers.d.ts +11 -12
  83. package/dist/screen-watch.js +34 -6
  84. package/dist/surface/api.d.ts +14 -2
  85. package/dist/surface/core.d.ts +16 -3
  86. package/dist/surface/core.js +95 -13
  87. package/dist/surface/outline.d.ts +2 -0
  88. package/dist/surface/outline.js +2 -1
  89. package/dist/surface/script.js +2 -0
  90. package/dist/ui-engine.js +19 -3
  91. package/package.json +2 -3
  92. package/dist/conformance/daytona-sweep.d.ts +0 -18
  93. package/dist/conformance/daytona-sweep.js +0 -126
@@ -1,6 +1,4 @@
1
1
  import { type BrowserComputerProvider, type BrowserDownloads, type BrowserProfiles, type BrowserStream, type ReleaseConfirm } from "./browser.js";
2
- import type { KindCapabilities } from "./kinds.js";
3
- import type { MountKind } from "./mount.js";
4
2
  import { type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type CreateContext, type CreatedComputer, type NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseHow } from "./provider.js";
5
3
  import { type Result } from "./result.js";
6
4
  export declare const BROWSERBASE_API_URL = "https://api.browserbase.com";
@@ -16,10 +14,6 @@ export declare const metadataKey: (labelKey: string) => string;
16
14
  export declare const labelKey: (metadataKey: string) => string;
17
15
  /** Why labels cannot ride a Browserbase session's userMetadata, in words naming the label; undefined when they can. */
18
16
  export declare function browserbaseLabelsProblem(labels: unknown): string | undefined;
19
- /** A browser takes no mount. */
20
- export declare const MOUNT: readonly MountKind[];
21
- /** The one configuration it offers, its descriptor's: a browser with a CDP target and a live view. */
22
- export declare const CAPABILITIES: readonly KindCapabilities[];
23
17
  /** A session as Browserbase answers it; only what the provider reads. */
24
18
  export interface BrowserbaseSession {
25
19
  id: string;
@@ -64,10 +64,6 @@ export function browserbaseLabelsProblem(labels) {
64
64
  }
65
65
  return undefined;
66
66
  }
67
- /** A browser takes no mount. */
68
- export const MOUNT = BROWSERBASE.mounts;
69
- /** The one configuration it offers, its descriptor's: a browser with a CDP target and a live view. */
70
- export const CAPABILITIES = BROWSERBASE.capabilities;
71
67
  /** A plain id as Browserbase answers one (a context's, a download's): a token, never a path. */
72
68
  const plainId = (id) => typeof id === "string" && /^[A-Za-z0-9_.:-]{1,128}$/.test(id);
73
69
  /** Browserbase's v1 REST API over fetch: the default api. */
@@ -207,7 +203,7 @@ export class BrowserbaseProvider {
207
203
  isolation: "vm",
208
204
  os: "linux",
209
205
  daemon: "none",
210
- groups: [...CAPABILITIES[0].groups],
206
+ groups: [...BROWSERBASE.capabilities[0].groups],
211
207
  maxLifetimeMs: BROWSERBASE_MAX_LIFETIME_MS,
212
208
  release: ["delete"],
213
209
  browser: structuredClone(this.#browser),
package/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Readable, Writable } from "node:stream";
2
2
  import { type ComputerClient, type DaemonErrorKind, type DaemonMethod, type DaemonMethods, type UiActResult, type UiExpect, type UiNode, type UiObserveParams, type UiObserveResult, type UiRole, type UiStep, type UiTarget } from "./protocol.js";
3
- import { type Result } from "./result.js";
3
+ import { type ComputerError, type Result } from "./result.js";
4
4
  export interface DaemonStream {
5
5
  readable: Readable;
6
6
  writable: Writable;
@@ -8,10 +8,19 @@ export interface DaemonStream {
8
8
  export interface CallOptions {
9
9
  signal?: AbortSignal;
10
10
  }
11
+ /**
12
+ * How long past a call's own timeoutMs (exec.run's, process.wait's) the daemon has to answer it. The daemon answers by
13
+ * that bound itself, so a call still unanswered after this has a transport that hangs: it ends here as timeout, never
14
+ * at whatever ends the transport much later.
15
+ */
16
+ export declare const ANSWER_SLACK_MS = 5000;
17
+ /** Whether `error` is a timeout this client gave a call whose bound passed with no answer over the transport. */
18
+ export declare function unanswered(error: ComputerError): boolean;
11
19
  /**
12
20
  * Calls a daemon's methods. Each call gets its own id; replies may come in any order. An aborted call sends
13
- * $/cancelRequest and returns `aborted` at once; the daemon still ends what the call started. When the stream ends,
14
- * every pending and later call fails with `gone`. A line that is not a reply to a pending call is dropped.
21
+ * $/cancelRequest and returns `aborted` at once; the daemon still ends what the call started. A call whose params carry
22
+ * a timeoutMs and that has no answer ANSWER_SLACK_MS past it sends the same cancel and returns `timeout`. When the
23
+ * stream ends, every pending and later call fails with `gone`. A line that is not a reply to a pending call is dropped.
15
24
  */
16
25
  export declare class DaemonClient implements ComputerClient {
17
26
  #private;
package/dist/client.js CHANGED
@@ -1,5 +1,22 @@
1
1
  import { CANCEL_METHOD, JSONRPC_CODES, MAX_LINE_BYTES, } from "./protocol.js";
2
2
  import { fail, ok } from "./result.js";
3
+ /**
4
+ * How long past a call's own timeoutMs (exec.run's, process.wait's) the daemon has to answer it. The daemon answers by
5
+ * that bound itself, so a call still unanswered after this has a transport that hangs: it ends here as timeout, never
6
+ * at whatever ends the transport much later.
7
+ */
8
+ export const ANSWER_SLACK_MS = 5_000;
9
+ /** The timeout errors a client gave itself, a call's bound passed with no answer: never one the daemon answered. */
10
+ const UNANSWERED = new WeakSet();
11
+ /** Whether `error` is a timeout this client gave a call whose bound passed with no answer over the transport. */
12
+ export function unanswered(error) {
13
+ return UNANSWERED.has(error);
14
+ }
15
+ /** The bound of a call whose params carry their own timeoutMs, or undefined for a call with none. */
16
+ function boundOf(params) {
17
+ const own = params?.timeoutMs;
18
+ return typeof own === "number" && Number.isFinite(own) && own >= 0 ? { ms: own + ANSWER_SLACK_MS, own } : undefined;
19
+ }
3
20
  const KINDS = new Set([
4
21
  "not_found",
5
22
  "invalid",
@@ -28,8 +45,9 @@ function fromReply(error) {
28
45
  }
29
46
  /**
30
47
  * Calls a daemon's methods. Each call gets its own id; replies may come in any order. An aborted call sends
31
- * $/cancelRequest and returns `aborted` at once; the daemon still ends what the call started. When the stream ends,
32
- * every pending and later call fails with `gone`. A line that is not a reply to a pending call is dropped.
48
+ * $/cancelRequest and returns `aborted` at once; the daemon still ends what the call started. A call whose params carry
49
+ * a timeoutMs and that has no answer ANSWER_SLACK_MS past it sends the same cancel and returns `timeout`. When the
50
+ * stream ends, every pending and later call fails with `gone`. A line that is not a reply to a pending call is dropped.
33
51
  */
34
52
  export class DaemonClient {
35
53
  #writable;
@@ -58,18 +76,35 @@ export class DaemonClient {
58
76
  const line = `${JSON.stringify({ jsonrpc: "2.0", id, method, params })}\n`;
59
77
  if (Buffer.byteLength(line) - 1 > MAX_LINE_BYTES)
60
78
  return fail("limit", `the ${method} request is over the 1 MiB line limit`);
79
+ const bound = boundOf(params);
61
80
  return new Promise((resolve) => {
62
- const onAbort = () => {
81
+ let timer;
82
+ const giveUp = (result) => {
63
83
  if (!this.#pending.delete(id))
64
84
  return;
85
+ clearTimeout(timer);
86
+ signal?.removeEventListener("abort", onAbort);
65
87
  this.#write({ jsonrpc: "2.0", method: CANCEL_METHOD, params: { id } });
66
- resolve(fail("aborted", `${method} was aborted`));
88
+ resolve(result);
67
89
  };
90
+ const onAbort = () => giveUp(fail("aborted", `${method} was aborted`));
68
91
  this.#pending.set(id, (result) => {
92
+ clearTimeout(timer);
69
93
  signal?.removeEventListener("abort", onAbort);
70
94
  resolve(result);
71
95
  });
72
96
  signal?.addEventListener("abort", onAbort, { once: true });
97
+ if (bound !== undefined) {
98
+ const s = (ms) => `${ms / 1000} s`;
99
+ timer = setTimeout(() => {
100
+ const timedOut = fail("timeout", `${method} had no answer within ${s(bound.ms)} (its own timeout of ${s(bound.own)}, and ${s(ANSWER_SLACK_MS)} for the answer to come)`);
101
+ if (!timedOut.ok)
102
+ UNANSWERED.add(timedOut.error);
103
+ giveUp(timedOut);
104
+ }, bound.ms);
105
+ // The stream holds the process while a call waits on it; the bound alone never does.
106
+ timer.unref?.();
107
+ }
73
108
  this.#writable.write(line);
74
109
  });
75
110
  }
Binary file
Binary file
@@ -0,0 +1,4 @@
1
+ {
2
+ "version": "0.1.0-beta.38",
3
+ "source": "sha256:95e013be031ee2a63d9f52a82e540cf0ed71f42cf82b40f93b8843673875c30a"
4
+ }
@@ -4,4 +4,10 @@ import type { Case } from "../types.js";
4
4
  * and each node against UiNode, its bounds inside the window and its parent a node before it.
5
5
  */
6
6
  export declare function observeWrong(result: unknown): string | undefined;
7
+ /**
8
+ * The stock apps a Linux desktop may have, by their desktop file ids, any vendor's: the text editor and the terminal of
9
+ * Xfce, which E2B Desktop's template and the box image (box/build-agent37.mjs) both carry, and xterm, which a bare
10
+ * desktop has (the Docker suite's, test/fixtures/desktop).
11
+ */
12
+ export declare const DESKTOP_APPS: readonly string[];
7
13
  export declare const appsCases: Case[];
@@ -1,6 +1,7 @@
1
1
  // Apps: the fixture installs, is listed, comes to the front when launched and leaves it when terminated; ui.observe has
2
2
  // the protocol's shape, inside its window, with the fixture's button found by its id. A phone's stock Settings app is
3
- // listed, launched and terminated with no install, which needs the apps group alone: its launch is seen in ui.observe
3
+ // listed, launched and terminated with no install, which needs the apps group alone, and so is a Linux desktop's stock
4
+ // editor or terminal (DESKTOP_APPS), on any vendor: its launch is seen in ui.observe
4
5
  // (Settings' list) when the phone has the ui group, else in a screenshot that is not the one before. On a phone that
5
6
  // takes no fixture file the observation's shape is checked on Settings, with its rows found (settings.ts).
6
7
  import { MAX_UI_NODES, UI_FLAGS, UI_ROLES } from "../../protocol.js";
@@ -104,6 +105,18 @@ export function observeWrong(result) {
104
105
  return undefined;
105
106
  }
106
107
  const foreground = async (t) => (await t.call("apps.list", {})).foreground;
108
+ /**
109
+ * The stock apps a Linux desktop may have, by their desktop file ids, any vendor's: the text editor and the terminal of
110
+ * Xfce, which E2B Desktop's template and the box image (box/build-agent37.mjs) both carry, and xterm, which a bare
111
+ * desktop has (the Docker suite's, test/fixtures/desktop).
112
+ */
113
+ export const DESKTOP_APPS = ["org.xfce.mousepad", "mousepad", "xfce4-terminal", "org.xfce.terminal", "xterm"];
114
+ /** A stock app the computer lists: the first of DESKTOP_APPS on a desktop, a phone's Settings, or the case skips in words. */
115
+ function stockApp(t, listed) {
116
+ if (t.provider.capabilities().kind !== "desktop")
117
+ return settingsApp(t);
118
+ return DESKTOP_APPS.find((id) => listed.some((one) => one.id === id)) ?? t.skip(`this desktop lists none of the stock apps the case knows (${DESKTOP_APPS.join(", ")})`);
119
+ }
107
120
  export const appsCases = [
108
121
  {
109
122
  id: "apps.install-launch",
@@ -130,12 +143,12 @@ export const appsCases = [
130
143
  group: "apps",
131
144
  needs: ["apps"],
132
145
  async run(t) {
133
- // An app the computer has: the ui fixture where it is installed, else the phone's own Settings app. Listed;
134
- // launched, in front and shown; terminated, and no longer in front.
146
+ // An app the computer has: the ui fixture where it is installed, else a stock app (a Linux desktop's editor or
147
+ // terminal, the phone's own Settings app). Listed; launched, in front and shown; terminated, and no longer in front.
135
148
  const listed = await t.call("apps.list", {});
136
149
  t.assert(Array.isArray(listed.apps) && listed.apps.every((one) => typeof one?.id === "string"), `apps.list gives apps with ids: ${JSON.stringify(listed.apps).slice(0, 300)}`);
137
150
  const uiFixture = listed.apps.some((one) => one.id === UI_FIXTURE.id);
138
- const app = uiFixture ? UI_FIXTURE.id : settingsApp(t);
151
+ const app = uiFixture ? UI_FIXTURE.id : stockApp(t, listed.apps);
139
152
  t.assert(listed.apps.some((one) => one.id === app), `apps.list holds ${app}`);
140
153
  t.deepEqual(await t.call("apps.terminate", { id: app }), {}, `apps.terminate ${app}`);
141
154
  await t.until(async () => (await foreground(t)) !== app, `${app} not in front after apps.terminate`);
@@ -172,7 +185,7 @@ export const appsCases = [
172
185
  if (treeOff(t) !== undefined && featureOff(t.hello.features ?? {}, "ui.image") !== undefined)
173
186
  return t.skip("ui.observe has nothing to show on this computer: ui.tree and ui.image are both off");
174
187
  const listed = await t.call("apps.list", {});
175
- const app = listed.apps.some((one) => one.id === UI_FIXTURE.id) ? UI_FIXTURE.id : settingsApp(t);
188
+ const app = listed.apps.some((one) => one.id === UI_FIXTURE.id) ? UI_FIXTURE.id : stockApp(t, listed.apps);
176
189
  t.assert(listed.apps.some((one) => one.id === app), `apps.list holds ${app}`);
177
190
  t.deepEqual(await t.call("apps.terminate", { id: app }), {}, `apps.terminate ${app}`);
178
191
  await t.until(async () => (await foreground(t)) !== app, `${app} not in front after apps.terminate`);
@@ -1,8 +1,9 @@
1
1
  import type { ComputerClient } from "../../protocol.js";
2
2
  import type { Case, CaseContext } from "../types.js";
3
3
  /**
4
- * The path unix sockets a program of the computer's user may connect to: the computer's own, computerd's and the Archil
5
- * sync socket (which only syncs). A network namespace does not cut a path socket, so any other is a door out.
4
+ * The unix sockets a program of the computer's user may connect to: the computer's own, computerd's and the Archil sync
5
+ * socket (which only syncs). A network namespace does not cut a path socket, and every program in the namespace reaches
6
+ * an abstract name (@...), so any other socket is a door out.
6
7
  */
7
8
  export declare const OWN_SOCKETS: readonly string[];
8
9
  /**
@@ -13,9 +14,10 @@ export declare const OUTSIDE_TARGETS: string[];
13
14
  /**
14
15
  * The isolation check, on the computer `client` reaches (the case's own by default): computerd's probe, run as the
15
16
  * computer's user, sees its own loopback alone, and is refused at the vendor's agent's declared ports on 127.0.0.1 and
16
- * ::1 and at OUTSIDE_TARGETS; and the path unix sockets it connects to (the probe's own listing, --sockets) are the
17
- * computer's own (OWN_SOCKETS, and a desktop's display) alone, each recorded with its type. A probe that reports no
18
- * socket list, or a search it could not finish, fails the check in words. The Archil case mount.archil-isolated-durable runs the same check on an Archil computer.
17
+ * ::1 and at OUTSIDE_TARGETS; and the unix sockets it connects to, paths and abstract names (the probe's own listing,
18
+ * --sockets), are the computer's own (OWN_SOCKETS, and a desktop's display) alone, each recorded with its type; and every TCP and UDP
19
+ * listener in its own network is computerd's (assertOnlyComputerdListens: today, none listens). A probe that reports no
20
+ * socket list or no listener list, or a search it could not finish, fails the check in words. The Archil case mount.archil-isolated-durable runs the same check on an Archil computer.
19
21
  */
20
22
  export declare function assertIsolated(t: CaseContext, client?: ComputerClient): Promise<void>;
21
23
  export declare const isolationCases: Case[];
@@ -1,11 +1,12 @@
1
1
  // A program the computer's user runs reaches none of the vendor's own agent, whose ports each provider declares
2
- // (capabilities().vendorAgentPorts), and no outside address, and sees its own loopback alone: computerd init
3
- // --own-network at work.
2
+ // (capabilities().vendorAgentPorts), and no outside address, sees its own loopback alone, and finds nothing listening in
3
+ // its own network but computerd: computerd init --own-network at work.
4
4
  import { DAEMON_IN_COMPUTER, SOCKET_DIR } from "../../drift.js";
5
5
  import { ARCHIL_SYNC_SOCKET } from "../../mount-archil.js";
6
6
  /**
7
- * The path unix sockets a program of the computer's user may connect to: the computer's own, computerd's and the Archil
8
- * sync socket (which only syncs). A network namespace does not cut a path socket, so any other is a door out.
7
+ * The unix sockets a program of the computer's user may connect to: the computer's own, computerd's and the Archil sync
8
+ * socket (which only syncs). A network namespace does not cut a path socket, and every program in the namespace reaches
9
+ * an abstract name (@...), so any other socket is a door out.
9
10
  */
10
11
  export const OWN_SOCKETS = [`${SOCKET_DIR}/computerd.sock`, ARCHIL_SYNC_SOCKET];
11
12
  /**
@@ -16,9 +17,10 @@ export const OUTSIDE_TARGETS = ["1.1.1.1:443", "example.com:443"];
16
17
  /**
17
18
  * The isolation check, on the computer `client` reaches (the case's own by default): computerd's probe, run as the
18
19
  * computer's user, sees its own loopback alone, and is refused at the vendor's agent's declared ports on 127.0.0.1 and
19
- * ::1 and at OUTSIDE_TARGETS; and the path unix sockets it connects to (the probe's own listing, --sockets) are the
20
- * computer's own (OWN_SOCKETS, and a desktop's display) alone, each recorded with its type. A probe that reports no
21
- * socket list, or a search it could not finish, fails the check in words. The Archil case mount.archil-isolated-durable runs the same check on an Archil computer.
20
+ * ::1 and at OUTSIDE_TARGETS; and the unix sockets it connects to, paths and abstract names (the probe's own listing,
21
+ * --sockets), are the computer's own (OWN_SOCKETS, and a desktop's display) alone, each recorded with its type; and every TCP and UDP
22
+ * listener in its own network is computerd's (assertOnlyComputerdListens: today, none listens). A probe that reports no
23
+ * socket list or no listener list, or a search it could not finish, fails the check in words. The Archil case mount.archil-isolated-durable runs the same check on an Archil computer.
22
24
  */
23
25
  export async function assertIsolated(t, client) {
24
26
  const ports = t.provider.capabilities().vendorAgentPorts ?? [];
@@ -52,27 +54,55 @@ export async function assertIsolated(t, client) {
52
54
  const what = agent.includes(target) ? "the vendor's agent" : "the outside";
53
55
  t.equal(result?.outcome, "refused", `a program of the computer's user, to ${what} at ${target} (${String(result?.detail ?? "no result")})`);
54
56
  }
55
- // The path unix sockets, which no network namespace cuts: computerd's own listing, so no image can lack it. Each with
56
- // the type that connected (stream, dgram, seqpacket); a search it could not finish proves nothing, and fails.
57
+ // The unix sockets: paths, which no network namespace cuts, and the abstract names of the user's own namespace.
58
+ // computerd's own listing, so no image can lack it. Each with the type that connected (stream, dgram, seqpacket); a
59
+ // search it could not finish proves nothing, and fails.
57
60
  const search = probe.sockets;
58
61
  if (search === null || typeof search !== "object" || !Array.isArray(search.sockets) || !Array.isArray(search.incomplete)) {
59
- return t.assert(false, "the probe reported no list of the path unix sockets a program can connect to (a computerd too old for probe --sockets), so the socket fence could not run");
62
+ return t.assert(false, "the probe reported no list of the unix sockets a program can connect to (a computerd too old for probe --sockets), so the socket fence could not run");
60
63
  }
61
64
  const found = search.sockets.map((one) => ({ path: String(one.path), type: String(one.type) }));
62
- t.observe(`path unix sockets a tool can connect to: ${found.map(({ path, type }) => `${path} (${type})`).join(", ") || "none"}`);
65
+ t.observe(`unix sockets a tool can connect to: ${found.map(({ path, type }) => `${path} (${type})`).join(", ") || "none"}`);
63
66
  const incomplete = search.incomplete.map(String);
64
67
  t.assert(incomplete.length === 0, `the probe could not search every place a socket may be, so the socket fence is unproven: ${incomplete.join("; ")}`);
65
- // A desktop's tools draw on its display: the one X socket of the display its hello names is the computer's own too.
68
+ // A desktop's tools draw on its display: the X server of the display its hello names, on its path and on the same
69
+ // name as an abstract one, is the computer's own too.
66
70
  const own = [...OWN_SOCKETS];
67
71
  if (t.provider.capabilities().kind === "desktop") {
68
72
  const display = await displaySocket(client ?? t.client);
69
73
  if (display !== undefined)
70
- own.push(display);
74
+ own.push(display, `@${display}`);
71
75
  else
72
76
  t.observe("the desktop's display socket: not known (its hello names no display of the form :N)");
73
77
  }
74
78
  const other = found.filter(({ path }) => !own.includes(path)).map(({ path, type }) => `${path} (${type})`);
75
- t.assert(other.length === 0, `a program of the computer's user connects to path unix sockets that are not the computer's own (${own.join(", ")}): ${other.join(", ")}`);
79
+ t.assert(other.length === 0, `a program of the computer's user connects to unix sockets that are not the computer's own (${own.join(", ")}): ${other.join(", ")}`);
80
+ assertOnlyComputerdListens(t, probe.listeners);
81
+ }
82
+ /**
83
+ * The TCP and UDP listeners in the network of the computer's user (the probe's listing, --sockets, from /proc/net/tcp,
84
+ * tcp6, udp and udp6 of its own namespace) are computerd's alone: each held by a process that runs computerd's own
85
+ * program, as the probe ties a socket's inode to the descriptors of the processes /proc shows it. Computerd listens on
86
+ * nothing there today: init's one TCP listener, the egress relay (--egress), is a Docker computer's, which takes no
87
+ * --own-network, and the Archil relay and sync server run as root beside the fence, in the vendor's network. So the rule
88
+ * now is that nothing listens. Init's own descriptors are not the probe's to read (it drops to the programs' uid
89
+ * non-dumpable), so a listener init opened there would fail here, named, until the probe ties it. A listing the probe did
90
+ * not report, or a table it could not read, fails in words.
91
+ */
92
+ function assertOnlyComputerdListens(t, reported) {
93
+ const search = reported;
94
+ if (search === null || typeof search !== "object" || !Array.isArray(search.listeners) || !Array.isArray(search.incomplete)) {
95
+ return t.assert(false, "the probe reported no list of the TCP and UDP listeners in the user's own network (a computerd too old for its listeners), so the listener fence could not run");
96
+ }
97
+ const listeners = search.listeners.map((one) => {
98
+ const { protocol, address, port, owner, computerd } = one;
99
+ return { protocol: String(protocol), address: String(address), port: String(port), owner: typeof owner === "string" && owner !== "" ? owner : "its owner not shown", computerd: computerd === true };
100
+ });
101
+ t.observe(`TCP and UDP listeners in the user's own network: ${listeners.map((one) => `${one.protocol} ${one.address} port ${one.port} (${one.owner}${one.computerd ? ", computerd" : ""})`).join(", ") || "none"}`);
102
+ const incomplete = search.incomplete.map(String);
103
+ t.assert(incomplete.length === 0, `the probe could not read every table of listeners, so the listener fence is unproven: ${incomplete.join("; ")}`);
104
+ const stray = listeners.filter((one) => !one.computerd).map((one) => `${one.protocol} port ${one.port} listens in the user's own network (on ${one.address}, ${one.owner}), and it isn't computerd's`);
105
+ t.assert(stray.length === 0, stray.join("; "));
76
106
  }
77
107
  /**
78
108
  * The X socket of the display a desktop's hello names (:N or :N.S, /tmp/.X11-unix/XN). Asked of the daemon itself: its
@@ -178,7 +178,7 @@ const archilIsolatedDurable = mount("archil-isolated-durable", async (t) => {
178
178
  const { ref } = await mounted(t, folder, EPOCH, "mount-archil-isolated-durable");
179
179
  const connected = await t.connect(ref);
180
180
  // isolation.vendor-agent's own check, on this Archil computer: lo alone, refused at the vendor's agent and outside,
181
- // and no path unix socket a tool connects to but the computer's own (computerd's, the sync socket).
181
+ // and no unix socket a tool connects to but the computer's own (computerd's, the sync socket).
182
182
  await assertIsolated(t, connected.client);
183
183
  const nonce = randomBytes(6).toString("hex");
184
184
  const ran = await t.exec(["sh", "-c", `printf '%s\\n' ${nonce} > exec-${nonce}.txt`], { cwd: WORKSPACE }, connected.client);
@@ -3,13 +3,16 @@
3
3
  // Exits 0 when Core passes, 1 when it fails, 2 on a usage error, and 3 when --only left Core cases out and every case
4
4
  // that ran passed: a partial run is never a Core pass, so no script reads its exit code as one. With --kind it exits on
5
5
  // the kind's verdict alone: 0 when the provider passes the kind, 1 when it does not.
6
+ // `--exec-stream --machine <id> [--quick]` runs the exec pre-check (./exec-stream.ts) alone, on a machine the vendor made
7
+ // by hand, through the module's createHost(): 0 when exec passes every check, 1 when one fails.
6
8
  import { generateKeyPairSync, randomBytes } from "node:crypto";
7
9
  import { resolve } from "node:path";
8
10
  import { pathToFileURL } from "node:url";
9
11
  import { isCommand } from "../entry.js";
10
- import { isProviderId, providerIds, providerModule } from "../providers.js";
12
+ import { descriptorOf, isProviderId, providerIds, providerModule } from "../providers.js";
11
13
  import { SETTING_KIND_NAMES } from "../kinds.js";
12
14
  import { browserCases, casesFor, conformanceCases } from "./cases/index.js";
15
+ import { checkExecStream, DEFAULT_LONG_MS, formatExecStream, QUICK_LONG_MS } from "./exec-stream.js";
13
16
  import { kindRunProblem } from "./kind.js";
14
17
  import { formatReport } from "./report.js";
15
18
  import { runConformance } from "./runner.js";
@@ -30,8 +33,12 @@ const USAGE = `usage: npm run conformance -w @parcha/agentrun-computer -- --prov
30
33
  --gpu the GPU the gpu case's one computer asks for, a type the provider declares and a count (default 1), such
31
34
  as T4 or H100:2; it bills by the second, so without it the gpu case skips
32
35
  --json print the report as JSON
36
+ --exec-stream --machine <id> [--quick]
37
+ the exec pre-check, alone: the module's createHost() and host.exec, nothing else, on a machine you made
38
+ by hand. Bytes 0-255 both ways, 8 MiB by sha256, output and stdin while the process runs, stderr apart,
39
+ the exit code, kill, and a silent process of ${DEFAULT_LONG_MS / 1000} s (--quick: ${QUICK_LONG_MS / 1000} s) that is not cut off
33
40
  exit: 0 Core passes, 1 it fails, 2 usage error, 3 partial (--only) and every case that ran passed; with --kind,
34
- 0 the provider passes the kind, 1 it does not`;
41
+ 0 the provider passes the kind, 1 it does not; with --exec-stream, 0 every check passes, 1 one fails`;
35
42
  const PROVIDER_METHODS = ["capabilities", "check", "create", "attach", "list", "network", "connect", "release"];
36
43
  class Usage extends Error {
37
44
  }
@@ -44,6 +51,9 @@ function gpuOf(text) {
44
51
  }
45
52
  function parse(argv, cases) {
46
53
  const args = { json: false, help: false };
54
+ let execStream = false;
55
+ let quick = false;
56
+ let machine;
47
57
  for (let i = 0; i < argv.length; i++) {
48
58
  const [flag = "", inline] = (argv[i] ?? "").split(/=(.*)/s, 2);
49
59
  const value = () => {
@@ -71,6 +81,12 @@ function parse(argv, cases) {
71
81
  args.fixture = value();
72
82
  else if (flag === "--gpu")
73
83
  args.gpu = gpuOf(value());
84
+ else if (flag === "--exec-stream")
85
+ execStream = true;
86
+ else if (flag === "--machine")
87
+ machine = value();
88
+ else if (flag === "--quick")
89
+ quick = true;
74
90
  else if (flag === "--json")
75
91
  args.json = true;
76
92
  else if (flag === "--help" || flag === "-h")
@@ -82,6 +98,16 @@ function parse(argv, cases) {
82
98
  return { provider: "", json: false, help: true };
83
99
  if (args.provider === undefined)
84
100
  throw new Usage("--provider is required");
101
+ if (execStream) {
102
+ if (machine === undefined)
103
+ throw new Usage("--exec-stream needs --machine <id>, a machine you made by hand");
104
+ const others = ["image", "only", "kind", "fixture", "gpu"].filter((name) => args[name] !== undefined);
105
+ if (others.length > 0)
106
+ throw new Usage(`--exec-stream runs alone: drop ${others.map((name) => `--${name}`).join(", ")}`);
107
+ return { provider: args.provider, execStream: { machine, quick }, json: args.json, help: false };
108
+ }
109
+ if (machine !== undefined || quick)
110
+ throw new Usage(`${machine !== undefined ? "--machine" : "--quick"} goes with --exec-stream`);
85
111
  if (args.kind !== undefined && args.only !== undefined)
86
112
  throw new Usage("--kind and --only go apart: a kind runs its own cases");
87
113
  const groups = [...new Set(cases.map((c) => c.group))];
@@ -112,10 +138,9 @@ const BARE = /^[A-Za-z][A-Za-z0-9-]*$/;
112
138
  */
113
139
  async function conformanceModule(name, cwd) {
114
140
  const found = await moduleFor(name, cwd);
115
- // What the provider file declares of itself (its CAPABILITIES; its descriptor once that lands), kept across the switch
116
- // to its conformance module, for health.declared.
117
- const declared = found.file.CAPABILITIES;
118
- return { label: found.label, module: found.module, ...(Array.isArray(declared) ? { declared: declared } : {}) };
141
+ // What a registry provider declares of itself, its descriptor's configurations, for health.declared.
142
+ const declared = isProviderId(name) ? descriptorOf(name)?.capabilities : undefined;
143
+ return { label: found.label, module: found.module, ...(declared === undefined ? {} : { declared }) };
119
144
  }
120
145
  async function moduleFor(name, cwd) {
121
146
  let label = name;
@@ -224,6 +249,39 @@ async function load(label, module, options, declared) {
224
249
  }
225
250
  return target;
226
251
  }
252
+ /**
253
+ * The exec pre-check: the host the module's createHost() builds (a conformance module's, else the provider file's own),
254
+ * given the CLI's provider options, and its exec alone on the named machine. Nothing else of the host is called.
255
+ */
256
+ async function execStreamMain(name, { machine, quick }, json, cwd, io) {
257
+ const { stdout = process.stdout, stderr = process.stderr, signal, progress = false } = io;
258
+ let host;
259
+ try {
260
+ const found = await moduleFor(name, cwd);
261
+ const createHost = found.module.createHost ?? found.file.createHost;
262
+ if (typeof createHost !== "function") {
263
+ throw new Usage(`${found.label} does not export createHost(options): the exec pre-check builds your MachineHost with it, from your conformance module or your provider file`);
264
+ }
265
+ host = (await createHost(io.providerOptions ?? {}));
266
+ if (typeof host?.exec !== "function")
267
+ throw new Error(`${found.label}: createHost() did not return a MachineHost with exec`);
268
+ }
269
+ catch (error) {
270
+ await write(stderr, `${error.message}\n`);
271
+ if (error instanceof Usage) {
272
+ await write(stderr, `${USAGE}\n`);
273
+ return 2;
274
+ }
275
+ return 1;
276
+ }
277
+ const report = await checkExecStream(host, machine, {
278
+ longMs: quick ? QUICK_LONG_MS : DEFAULT_LONG_MS,
279
+ ...(signal ? { signal } : {}),
280
+ ...(progress ? { onCheck: (check) => stderr.write(`${check.status === "pass" ? "✓" : "✗"} ${check.id}\n`) } : {}),
281
+ });
282
+ await write(stdout, json ? `${JSON.stringify(report, null, 2)}\n` : formatExecStream(report));
283
+ return report.pass ? 0 : 1;
284
+ }
227
285
  export async function main(argv, io = {}) {
228
286
  const { stdout = process.stdout, stderr = process.stderr, signal, progress = false } = io;
229
287
  let args;
@@ -240,6 +298,8 @@ export async function main(argv, io = {}) {
240
298
  return 0;
241
299
  }
242
300
  const cwd = io.cwd ?? process.env.INIT_CWD ?? process.cwd();
301
+ if (args.execStream)
302
+ return execStreamMain(args.provider, args.execStream, args.json, cwd, io);
243
303
  // What the provider says that is no failure (onNote, as each remote provider takes it) goes in the report.
244
304
  const providerNotes = [];
245
305
  const options = { ...(io.providerOptions ?? {}), onNote: (note) => providerNotes.push({ computer: note.computer, note: note.note }) };
@@ -1,18 +1,5 @@
1
- import { type DaytonaCreateOptions, type DaytonaProvider, type DaytonaProviderOptions } from "../daytona.js";
2
- import type { MountKind } from "../mount.js";
3
- import { type ArchilRunFolderOptions } from "./archil.js";
4
- import type { RunFolder } from "./types.js";
5
- /** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
6
- export { ARCHIL_ENV } from "./archil.js";
7
- /**
8
- * A fresh run folder for the mount cases: an Archil one on the disk the COMPUTER_ARCHIL_* settings name (the shared
9
- * archilRunFolder; the run's snapshot is then one of box/Dockerfile, and COMPUTER_DAYTONA_USER is 2510:2510); none when
10
- * they name none, and none for a bind, which a remote computer cannot take.
11
- */
12
- export declare function mountFor(kind: MountKind, { env, archil }?: {
13
- env?: Record<string, string | undefined>;
14
- archil?: Pick<ArchilRunFolderOptions, "objects" | "Archil" | "baseUrl">;
15
- }): Promise<RunFolder | undefined>;
1
+ import { type DaytonaProvider, type DaytonaProviderOptions } from "../daytona.js";
2
+ import type { MachineHost } from "../host.js";
16
3
  /** The environment this module reads, by name, each for the option its comment names. */
17
4
  export declare const DAYTONA_ENV: {
18
5
  /** apiKey, required: the Daytona API key. */
@@ -59,15 +46,12 @@ export declare const ENV: {
59
46
  * The provider's options this module reads from env, each only when its name is set; throws in words without the key,
60
47
  * never echoing one. create() checks the rest.
61
48
  */
62
- export declare function settingsFromEnv(env?: Record<string, string | undefined>): DaytonaCreateOptions;
49
+ export declare function settingsFromEnv(env?: Record<string, string | undefined>): DaytonaProviderOptions;
63
50
  /** Minutes without outside activity before Daytona stops a run's sandbox: at most 30, so none outlives a run for long. */
64
51
  export declare const CONFORMANCE_AUTO_STOP_MINUTES = 30;
65
52
  /** Minutes a run's sandbox may stay stopped: 0, Daytona deletes it as soon as it stops. */
66
53
  export declare const CONFORMANCE_AUTO_DELETE_MINUTES = 0;
67
- /**
68
- * For the run's report: what this configuration means for the suite. The provider declares it (stopDeletes), and the
69
- * note says it in words.
70
- */
54
+ /** For the run's report: what this configuration means for the suite, in words. */
71
55
  export declare const conformanceNotes: string[];
72
56
  export interface DaytonaModuleOptions {
73
57
  /** Where the settings are read; default process.env. */
@@ -83,5 +67,10 @@ export interface DaytonaModuleOptions {
83
67
  export declare function conformanceImage({ env }?: Pick<DaytonaModuleOptions, "env">): string;
84
68
  /** The provider the CLI runs; throws in words when a setting is missing or wrong. */
85
69
  export declare function createProvider(options?: DaytonaModuleOptions): DaytonaProvider;
70
+ /**
71
+ * The Daytona host the live sweep (sweep.ts) lists and deletes through, from the same settings (the key and the API
72
+ * URL); it calls nothing until the sweep does.
73
+ */
74
+ export declare function createHost({ env, fetch }?: Pick<DaytonaModuleOptions, "env" | "fetch">): Promise<MachineHost>;
86
75
  /** The same provider with a daemon that reports another version, built with Go for the drift case. */
87
76
  export declare function createDriftedProvider(options?: DaytonaModuleOptions): Promise<DaytonaProvider>;
@@ -2,25 +2,11 @@
2
2
  // module reads the run's settings from its own COMPUTER_DAYTONA_* names (never a bare DAYTONA_ variable, which may hold
3
3
  // another organization's key on a host that runs other Daytona work) and passes each to create() as its option, the key
4
4
  // read only when createProvider() runs. Every sandbox of a run has a bounded life besides its TTL: Daytona stops one
5
- // after 30 minutes with no outside activity and deletes it as soon as it stops, so a stop deletes, and the provider
6
- // declares it (stopDeletes; see conformanceNotes).
5
+ // after 30 minutes with no outside activity and deletes it as soon as it stops (see conformanceNotes). The live sweep
6
+ // (sweep.ts, --provider daytona) reads the same names through createHost: it makes nothing.
7
7
  import { create } from "../daytona.js";
8
8
  import { DAYTONA_DEFAULT_SNAPSHOT } from "../descriptors/daytona.js";
9
- import { archilRunFolder, archilSettings } from "./archil.js";
10
9
  import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
11
- /** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
12
- export { ARCHIL_ENV } from "./archil.js";
13
- /**
14
- * A fresh run folder for the mount cases: an Archil one on the disk the COMPUTER_ARCHIL_* settings name (the shared
15
- * archilRunFolder; the run's snapshot is then one of box/Dockerfile, and COMPUTER_DAYTONA_USER is 2510:2510); none when
16
- * they name none, and none for a bind, which a remote computer cannot take.
17
- */
18
- export async function mountFor(kind, { env = process.env, archil = {} } = {}) {
19
- if (kind !== "archil")
20
- return undefined;
21
- const settings = archilSettings(env);
22
- return settings === undefined ? undefined : archilRunFolder({ ...settings, ...archil });
23
- }
24
10
  /** The environment this module reads, by name, each for the option its comment names. */
25
11
  export const DAYTONA_ENV = {
26
12
  /** apiKey, required: the Daytona API key. */
@@ -65,6 +51,7 @@ export function settingsFromEnv(env = process.env) {
65
51
  ...(url ? { apiUrl: url.value } : {}),
66
52
  ...(target ? { target: target.value } : {}),
67
53
  ...(daemon ? { daemonPath: daemon.value } : {}),
54
+ // create() refuses any other arch in words.
68
55
  ...(arch ? { arch: arch.value } : {}),
69
56
  // create() refuses any other class in words.
70
57
  ...(sandboxClass ? { sandboxClass: sandboxClass.value } : {}),
@@ -77,12 +64,9 @@ export function settingsFromEnv(env = process.env) {
77
64
  export const CONFORMANCE_AUTO_STOP_MINUTES = 30;
78
65
  /** Minutes a run's sandbox may stay stopped: 0, Daytona deletes it as soon as it stops. */
79
66
  export const CONFORMANCE_AUTO_DELETE_MINUTES = 0;
80
- /**
81
- * For the run's report: what this configuration means for the suite. The provider declares it (stopDeletes), and the
82
- * note says it in words.
83
- */
67
+ /** For the run's report: what this configuration means for the suite, in words. */
84
68
  export const conformanceNotes = [
85
- `daytona: every sandbox runs with autoStopMinutes ${CONFORMANCE_AUTO_STOP_MINUTES} and autoDeleteMinutes ${CONFORMANCE_AUTO_DELETE_MINUTES}, besides its TTL: Daytona deletes a sandbox as soon as it stops, so this configuration keeps no stopped computer, and the provider declares stopDeletes. Core provider.stop holds it to that: a stopped computer is gone, neither listed nor attachable. Full provider.janitor, which needs a stopped computer kept, is skipped (the lifetime being vendor).`,
69
+ `daytona: every sandbox runs with autoStopMinutes ${CONFORMANCE_AUTO_STOP_MINUTES} and autoDeleteMinutes ${CONFORMANCE_AUTO_DELETE_MINUTES}, besides its TTL: Daytona deletes a sandbox as soon as it stops, so this configuration keeps no stopped computer. A computer here is deleted, never stopped: release stop is refused. Full provider.janitor, which needs a stopped computer kept, is skipped (the lifetime being vendor).`,
86
70
  ];
87
71
  /** The provider's options: what this module reads from the environment (settingsFromEnv), with the run's bounds. */
88
72
  function optionsOf({ env = process.env, fetch, webSocket, timeouts, onNote }) {
@@ -104,6 +88,13 @@ export function conformanceImage({ env = process.env } = {}) {
104
88
  export function createProvider(options = {}) {
105
89
  return create(optionsOf(options));
106
90
  }
91
+ /**
92
+ * The Daytona host the live sweep (sweep.ts) lists and deletes through, from the same settings (the key and the API
93
+ * URL); it calls nothing until the sweep does.
94
+ */
95
+ export async function createHost({ env = process.env, fetch } = {}) {
96
+ return create({ ...settingsFromEnv(env), ...(fetch ? { fetch } : {}) }).host;
97
+ }
107
98
  /** The same provider with a daemon that reports another version, built with Go for the drift case. */
108
99
  export async function createDriftedProvider(options = {}) {
109
100
  const settings = optionsOf(options);