@parcha/agentrun-computer 0.0.0-stage → 0.1.0-beta.33

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 (173) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +8 -0
  3. package/README.md +2411 -2
  4. package/box/Dockerfile +69 -0
  5. package/box/agentrun-archil +168 -0
  6. package/box/build-daytona.py +26 -0
  7. package/box/build-e2b.mjs +32 -0
  8. package/box/build-modal.py +17 -0
  9. package/dist/actions.d.ts +18 -0
  10. package/dist/actions.js +139 -0
  11. package/dist/browser.d.ts +151 -0
  12. package/dist/browser.js +305 -0
  13. package/dist/browserbase.d.ts +139 -0
  14. package/dist/browserbase.js +408 -0
  15. package/dist/child.d.ts +40 -0
  16. package/dist/child.js +127 -0
  17. package/dist/client.d.ts +22 -0
  18. package/dist/client.js +136 -0
  19. package/dist/computerd-linux-amd64 +0 -0
  20. package/dist/computerd-linux-arm64 +0 -0
  21. package/dist/conformance/archil.d.ts +68 -0
  22. package/dist/conformance/archil.js +152 -0
  23. package/dist/conformance/browserbase.d.ts +35 -0
  24. package/dist/conformance/browserbase.js +45 -0
  25. package/dist/conformance/cases/apps.d.ts +2 -0
  26. package/dist/conformance/cases/apps.js +155 -0
  27. package/dist/conformance/cases/browser.d.ts +4 -0
  28. package/dist/conformance/cases/browser.js +105 -0
  29. package/dist/conformance/cases/drift.d.ts +2 -0
  30. package/dist/conformance/cases/drift.js +64 -0
  31. package/dist/conformance/cases/exec.d.ts +2 -0
  32. package/dist/conformance/cases/exec.js +125 -0
  33. package/dist/conformance/cases/files.d.ts +2 -0
  34. package/dist/conformance/cases/files.js +294 -0
  35. package/dist/conformance/cases/health.d.ts +2 -0
  36. package/dist/conformance/cases/health.js +71 -0
  37. package/dist/conformance/cases/index.d.ts +9 -0
  38. package/dist/conformance/cases/index.js +37 -0
  39. package/dist/conformance/cases/input.d.ts +12 -0
  40. package/dist/conformance/cases/input.js +109 -0
  41. package/dist/conformance/cases/isolation.d.ts +21 -0
  42. package/dist/conformance/cases/isolation.js +98 -0
  43. package/dist/conformance/cases/lifetime.d.ts +2 -0
  44. package/dist/conformance/cases/lifetime.js +64 -0
  45. package/dist/conformance/cases/mount.d.ts +2 -0
  46. package/dist/conformance/cases/mount.js +252 -0
  47. package/dist/conformance/cases/process.d.ts +2 -0
  48. package/dist/conformance/cases/process.js +240 -0
  49. package/dist/conformance/cases/provider.d.ts +2 -0
  50. package/dist/conformance/cases/provider.js +302 -0
  51. package/dist/conformance/cases/screen.d.ts +9 -0
  52. package/dist/conformance/cases/screen.js +230 -0
  53. package/dist/conformance/cases/settings.d.ts +57 -0
  54. package/dist/conformance/cases/settings.js +142 -0
  55. package/dist/conformance/cases/touch.d.ts +2 -0
  56. package/dist/conformance/cases/touch.js +117 -0
  57. package/dist/conformance/cases/util.d.ts +7 -0
  58. package/dist/conformance/cases/util.js +8 -0
  59. package/dist/conformance/cdp.d.ts +13 -0
  60. package/dist/conformance/cdp.js +88 -0
  61. package/dist/conformance/cli.d.ts +29 -0
  62. package/dist/conformance/cli.js +231 -0
  63. package/dist/conformance/daytona-sweep.d.ts +18 -0
  64. package/dist/conformance/daytona-sweep.js +126 -0
  65. package/dist/conformance/daytona.d.ts +83 -0
  66. package/dist/conformance/daytona.js +107 -0
  67. package/dist/conformance/docker.d.ts +38 -0
  68. package/dist/conformance/docker.js +70 -0
  69. package/dist/conformance/drift-daemon.d.ts +8 -0
  70. package/dist/conformance/drift-daemon.js +41 -0
  71. package/dist/conformance/e2b-diagnose.d.ts +16 -0
  72. package/dist/conformance/e2b-diagnose.js +61 -0
  73. package/dist/conformance/e2b-sweep.d.ts +18 -0
  74. package/dist/conformance/e2b-sweep.js +132 -0
  75. package/dist/conformance/e2b.d.ts +74 -0
  76. package/dist/conformance/e2b.js +111 -0
  77. package/dist/conformance/fixture.d.ts +65 -0
  78. package/dist/conformance/fixture.js +98 -0
  79. package/dist/conformance/index.d.ts +8 -0
  80. package/dist/conformance/index.js +8 -0
  81. package/dist/conformance/kernel.d.ts +31 -0
  82. package/dist/conformance/kernel.js +40 -0
  83. package/dist/conformance/kind.d.ts +23 -0
  84. package/dist/conformance/kind.js +58 -0
  85. package/dist/conformance/modal-sweep.d.ts +22 -0
  86. package/dist/conformance/modal-sweep.js +213 -0
  87. package/dist/conformance/modal.d.ts +69 -0
  88. package/dist/conformance/modal.js +76 -0
  89. package/dist/conformance/orgo.d.ts +41 -0
  90. package/dist/conformance/orgo.js +69 -0
  91. package/dist/conformance/phone-harness.d.ts +61 -0
  92. package/dist/conformance/phone-harness.js +241 -0
  93. package/dist/conformance/png.d.ts +16 -0
  94. package/dist/conformance/png.js +132 -0
  95. package/dist/conformance/report.d.ts +2 -0
  96. package/dist/conformance/report.js +86 -0
  97. package/dist/conformance/runner.d.ts +11 -0
  98. package/dist/conformance/runner.js +585 -0
  99. package/dist/conformance/tar.d.ts +13 -0
  100. package/dist/conformance/tar.js +105 -0
  101. package/dist/conformance/types.d.ts +257 -0
  102. package/dist/conformance/types.js +24 -0
  103. package/dist/daemon-copy.d.ts +40 -0
  104. package/dist/daemon-copy.js +259 -0
  105. package/dist/daytona.d.ts +180 -0
  106. package/dist/daytona.js +1498 -0
  107. package/dist/desktop.d.ts +24 -0
  108. package/dist/desktop.js +68 -0
  109. package/dist/docker/egress-main.d.ts +1 -0
  110. package/dist/docker/egress-main.js +68 -0
  111. package/dist/docker/egress-proxy.d.ts +53 -0
  112. package/dist/docker/egress-proxy.js +450 -0
  113. package/dist/docker/egress-table.d.ts +39 -0
  114. package/dist/docker/egress-table.js +197 -0
  115. package/dist/docker/egress.d.ts +109 -0
  116. package/dist/docker/egress.js +318 -0
  117. package/dist/docker/image.d.ts +49 -0
  118. package/dist/docker/image.js +302 -0
  119. package/dist/docker/stage.d.ts +21 -0
  120. package/dist/docker/stage.js +290 -0
  121. package/dist/docker/volume.d.ts +24 -0
  122. package/dist/docker/volume.js +67 -0
  123. package/dist/docker.d.ts +156 -0
  124. package/dist/docker.js +1277 -0
  125. package/dist/drift.d.ts +200 -0
  126. package/dist/drift.js +416 -0
  127. package/dist/e2b.d.ts +337 -0
  128. package/dist/e2b.js +1516 -0
  129. package/dist/entry.d.ts +2 -0
  130. package/dist/entry.js +24 -0
  131. package/dist/files.d.ts +50 -0
  132. package/dist/files.js +208 -0
  133. package/dist/index.d.ts +27 -0
  134. package/dist/index.js +26 -0
  135. package/dist/isolation.d.ts +29 -0
  136. package/dist/isolation.js +71 -0
  137. package/dist/janitor.d.ts +50 -0
  138. package/dist/janitor.js +135 -0
  139. package/dist/kernel.d.ts +113 -0
  140. package/dist/kernel.js +358 -0
  141. package/dist/kinds.d.ts +79 -0
  142. package/dist/kinds.js +133 -0
  143. package/dist/labels.d.ts +23 -0
  144. package/dist/labels.js +50 -0
  145. package/dist/modal.d.ts +302 -0
  146. package/dist/modal.js +1374 -0
  147. package/dist/mount-archil.d.ts +164 -0
  148. package/dist/mount-archil.js +471 -0
  149. package/dist/mount.d.ts +57 -0
  150. package/dist/mount.js +104 -0
  151. package/dist/orgo-channel.d.ts +96 -0
  152. package/dist/orgo-channel.js +391 -0
  153. package/dist/orgo.d.ts +139 -0
  154. package/dist/orgo.js +1006 -0
  155. package/dist/phone-harness.d.ts +185 -0
  156. package/dist/phone-harness.js +1420 -0
  157. package/dist/processes.d.ts +24 -0
  158. package/dist/processes.js +40 -0
  159. package/dist/protocol.d.ts +729 -0
  160. package/dist/protocol.js +54 -0
  161. package/dist/provider.d.ts +245 -0
  162. package/dist/provider.js +37 -0
  163. package/dist/providers.d.ts +68 -0
  164. package/dist/providers.js +25 -0
  165. package/dist/result.d.ts +15 -0
  166. package/dist/result.js +2 -0
  167. package/dist/screen-watch.d.ts +150 -0
  168. package/dist/screen-watch.js +490 -0
  169. package/dist/test-connection.d.ts +17 -0
  170. package/dist/test-connection.js +26 -0
  171. package/dist/wait.d.ts +23 -0
  172. package/dist/wait.js +65 -0
  173. package/package.json +62 -4
@@ -0,0 +1,105 @@
1
+ // Just enough tar for the suite to build archives and read them back without the host's tar: ustar out; ustar, pax
2
+ // and GNU long names in.
3
+ import { createHash } from "node:crypto";
4
+ const TYPE_FLAG = { file: "0", dir: "5", symlink: "2", other: "0" };
5
+ function header(name, type, mode, size, link) {
6
+ const block = Buffer.alloc(512);
7
+ const field = (at, length, value) => block.write(value, at, length, "utf8");
8
+ const octal = (value, width) => `${value.toString(8).padStart(width - 1, "0")}\0`;
9
+ field(0, 100, name);
10
+ field(100, 8, octal(mode, 8));
11
+ field(108, 8, octal(0, 8));
12
+ field(116, 8, octal(0, 8));
13
+ field(124, 12, octal(size, 12));
14
+ field(136, 12, octal(Math.floor(Date.now() / 1000), 12));
15
+ field(148, 8, " ");
16
+ field(156, 1, type);
17
+ field(157, 100, link);
18
+ field(257, 6, "ustar\0");
19
+ field(263, 2, "00");
20
+ let sum = 0;
21
+ for (const byte of block)
22
+ sum += byte;
23
+ field(148, 8, `${sum.toString(8).padStart(6, "0")}\0 `);
24
+ return block;
25
+ }
26
+ const pad = (length) => Buffer.alloc((512 - (length % 512)) % 512);
27
+ /** A ustar archive of these entries, names as given (each under 100 bytes). */
28
+ export function tarOf(entries) {
29
+ const parts = [];
30
+ for (const entry of entries) {
31
+ const body = entry.type === "file" ? Buffer.from(entry.body ?? new Uint8Array()) : Buffer.alloc(0);
32
+ parts.push(header(entry.name, TYPE_FLAG[entry.type], entry.mode, body.length, entry.link ?? ""), body, pad(body.length));
33
+ }
34
+ parts.push(Buffer.alloc(1024));
35
+ return Buffer.concat(parts);
36
+ }
37
+ const text = (block, at, length) => {
38
+ const raw = block.subarray(at, at + length);
39
+ const end = raw.indexOf(0);
40
+ return raw.subarray(0, end < 0 ? raw.length : end).toString("utf8");
41
+ };
42
+ const number = (block, at, length) => Number.parseInt(text(block, at, length).trim() || "0", 8);
43
+ /** Reads pax records: "<len> key=value\n" each. */
44
+ function pax(body) {
45
+ const records = {};
46
+ let at = 0;
47
+ while (at < body.length) {
48
+ const space = body.indexOf(0x20, at);
49
+ if (space < 0)
50
+ break;
51
+ const length = Number.parseInt(body.subarray(at, space).toString("utf8"), 10);
52
+ if (!(length > 0))
53
+ break;
54
+ const record = body.subarray(space + 1, at + length - 1).toString("utf8");
55
+ const equals = record.indexOf("=");
56
+ if (equals > 0)
57
+ records[record.slice(0, equals)] = record.slice(equals + 1);
58
+ at += length;
59
+ }
60
+ return records;
61
+ }
62
+ /** Every entry of an archive, in order. Throws in words on an archive it cannot read. */
63
+ export function untar(bytes) {
64
+ const archive = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
65
+ const entries = [];
66
+ let next = {};
67
+ let at = 0;
68
+ while (at + 512 <= archive.length) {
69
+ const block = archive.subarray(at, at + 512);
70
+ if (block.every((byte) => byte === 0))
71
+ break;
72
+ const size = number(block, 124, 12);
73
+ const flag = text(block, 156, 1) || "0";
74
+ const body = archive.subarray(at + 512, at + 512 + size);
75
+ if (body.length < size)
76
+ throw new Error(`the archive ends inside ${text(block, 0, 100)}`);
77
+ at += 512 + size + ((512 - (size % 512)) % 512);
78
+ if (flag === "x") {
79
+ const records = pax(body);
80
+ next = { path: records.path ?? next.path, linkpath: records.linkpath ?? next.linkpath };
81
+ continue;
82
+ }
83
+ if (flag === "g")
84
+ continue;
85
+ if (flag === "L" || flag === "K") {
86
+ const value = body.toString("utf8").replace(/\0+$/, "");
87
+ next = flag === "L" ? { ...next, path: value } : { ...next, linkpath: value };
88
+ continue;
89
+ }
90
+ const prefix = text(block, 345, 155);
91
+ const name = next.path ?? (prefix ? `${prefix}/${text(block, 0, 100)}` : text(block, 0, 100));
92
+ const link = next.linkpath ?? text(block, 157, 100);
93
+ next = {};
94
+ const type = flag === "0" || flag === "7" ? "file" : flag === "5" ? "dir" : flag === "2" ? "symlink" : "other";
95
+ const mode = number(block, 100, 8) & 0o7777;
96
+ entries.push({ name, type, mode, ...(type === "file" ? { body } : {}), ...(type === "symlink" ? { link } : {}) });
97
+ }
98
+ return entries;
99
+ }
100
+ /** An entry as one comparable line: its name without "./" or a trailing "/", type, mode, and content hash or target. */
101
+ export function describeEntry(entry) {
102
+ const name = entry.name.replace(/^\.\//, "").replace(/\/$/, "");
103
+ const what = entry.type === "file" ? createHash("sha256").update(entry.body ?? new Uint8Array()).digest("hex") : entry.type === "symlink" ? `-> ${entry.link}` : "";
104
+ return `${name} ${entry.type} ${entry.mode.toString(8)} ${what}`.trimEnd();
105
+ }
@@ -0,0 +1,257 @@
1
+ import type { MountKind, MountSpec } from "../mount.js";
2
+ import type { ComputerClient, ComputerKind, DaemonMethod, DaemonMethods, ExecRunParams, Group, HelloResult } from "../protocol.js";
3
+ import type { ComputerConnection, ComputerProvider, ComputerRef, ComputerSpec, DaemonMode } from "../provider.js";
4
+ import type { ComputerError, ComputerErrorCode, Result } from "../result.js";
5
+ import type { ComputerSettingKind } from "../kinds.js";
6
+ import type { CdpDialer, CdpSocket } from "./cdp.js";
7
+ import type { StartedFixture } from "./fixture.js";
8
+ import type { KindVerdict } from "./kind.js";
9
+ /** Core: what a computer of its kind must do. Full: an optional capability, tested only where it is declared. */
10
+ export type Level = "core" | "full";
11
+ /** The suite's own grouping of its cases, the first part of each case id; not the protocol's Group. */
12
+ export type CaseGroup = "health" | "exec" | "files" | "process" | "provider" | "drift" | "isolation" | "mount" | "screen" | "input" | "touch" | "apps" | "lifetime" | "browser";
13
+ /**
14
+ * What a case needs: a group (declared by both the provider's capabilities().groups and the computer's hello), a
15
+ * network the provider declares, the janitor as the keeper of deadlines, a spec.user the provider takes, a release that
16
+ * stops a computer and keeps it, a mount kind capabilities().mount declares, a provider method that is optional
17
+ * (extend, stream), declared by being there, or the ports of a vendor's agent in the computer (vendor-agent: declared
18
+ * by capabilities().vendorAgentPorts, an empty list included).
19
+ */
20
+ export type Capability = Group | "network:none" | "network:open" | "network:allow" | "lifetime:janitor" | "user:root" | "user:uid" | "release:stop" | "mount:bind" | "mount:archil" | "extend" | "stream" | "vendor-agent";
21
+ /**
22
+ * A fresh run's folder for one mount kind, made by the provider's conformance module: the mount that reaches it, and its
23
+ * outside, where a computer does not run (the folder on the host for a bind, the disk's file API for Archil).
24
+ */
25
+ export interface RunFolder {
26
+ mount: MountSpec;
27
+ /** The run whose folder it is, for a mount made for a run (Archil: agents/<agent>/runs/<run>/work): a computer that
28
+ * mounts it is labelled agentrun.run with it. */
29
+ run?: string;
30
+ /** A file of the folder, by its path relative to the folder, read from outside; undefined when there is none. */
31
+ read(path: string): Promise<Uint8Array | undefined>;
32
+ /** Writes a file of the folder from outside, by its path relative to the folder. */
33
+ write(path: string, data: Uint8Array): Promise<void>;
34
+ /** Removes the folder and what is in it; the runner calls it when the case ends. */
35
+ close(): Promise<void>;
36
+ }
37
+ /**
38
+ * What a computer of this kind and daemon mode must declare: a case that needs one of these fails Core when it is
39
+ * missing, where a case that needs an undeclared optional group is skipped. exec, files and processes are Core whenever
40
+ * computerd runs (pid1 or child); with daemon none they are tested only when declared. Network none is Core wherever
41
+ * computerd runs; a phone is tested on an open network. A child daemon runs beside the vendor's own agent, so it must
42
+ * declare that agent's ports (vendor-agent), and isolation.vendor-agent checks its programs reach none of them. A
43
+ * browser must declare its CDP target.
44
+ */
45
+ export declare function coreGroups(kind: ComputerKind, daemon: DaemonMode): Capability[];
46
+ /** exec.run's result with its streams decoded. */
47
+ export interface Ran {
48
+ exitCode: number | null;
49
+ signal?: string;
50
+ out: string;
51
+ err: string;
52
+ timedOut: boolean;
53
+ truncated: boolean;
54
+ }
55
+ /** What a case is given. Every computer and connection made through it is ended when the case ends. */
56
+ export interface CaseContext {
57
+ readonly provider: ComputerProvider;
58
+ readonly image: string;
59
+ /** Aborts when the run is aborted or the case runs past its time. */
60
+ readonly signal: AbortSignal;
61
+ /** The case's computer: the run's shared one, or one made for this case alone. */
62
+ readonly ref: ComputerRef;
63
+ /** A connection of the case's own to that computer, after hello: computerd, or the provider itself (daemon none). */
64
+ readonly client: ComputerClient;
65
+ readonly hello: HelloResult;
66
+ /** The label every computer of this run carries. */
67
+ readonly runLabels: Record<string, string>;
68
+ /** How long a case waits on a program before it fails: a bound, never a claim about speed. */
69
+ readonly patience: number;
70
+ /** A spec with this run's label, the image, a lifetime and network none, with extra over it. */
71
+ spec(extra?: Partial<ComputerSpec>): ComputerSpec;
72
+ /** Makes a computer for this case; fails the case when create refuses. */
73
+ create(extra?: Partial<ComputerSpec>): Promise<ComputerRef>;
74
+ /**
75
+ * Calls create with this whole spec, through by (default the provider), and gives its result as it is. The runner
76
+ * waits for it: a computer it makes is deleted when the case ends, or as it comes after that, named in cleanup.late.
77
+ */
78
+ attempt(spec: ComputerSpec, by?: ComputerProvider): Promise<Result<ComputerRef>>;
79
+ /** A computer the case made through another provider (the drifted one): deleted through it when the case ends. */
80
+ track(ref: ComputerRef, by?: ComputerProvider): void;
81
+ /** A further connection, to the case's computer or another; fails the case when connect refuses. */
82
+ connect(ref?: ComputerRef): Promise<ComputerConnection>;
83
+ /** The computer's HOME, which its user can write: the suite works under it. */
84
+ home(): Promise<string>;
85
+ /** A new directory for this case under HOME. */
86
+ dir(): Promise<string>;
87
+ /** The same provider with a daemon that reports another version; skips the case when none was given. */
88
+ drifted(): Promise<ComputerProvider>;
89
+ /** A fresh run's folder for this mount kind, closed when the case ends; skips the case when the run can make none. */
90
+ runFolder(kind: MountKind): Promise<RunFolder>;
91
+ /**
92
+ * Starts the run's fixture in the case's computer and waits until it is up: an app that logs each input event it
93
+ * gets, so a case checks what an action did with no model. It is stopped when the case ends. Skips the case when the
94
+ * run was given no fixture, or none can start on this kind of computer.
95
+ */
96
+ fixture(): Promise<StartedFixture>;
97
+ /** fetch, as the run was given it; the global one by default. */
98
+ fetch(url: string, init?: {
99
+ signal?: AbortSignal;
100
+ method?: string;
101
+ }): Promise<{
102
+ status: number;
103
+ }>;
104
+ /** A CDP socket to a browser's CDP URL, through the run's dialer, closed when the case ends. */
105
+ cdp(url: string): Promise<CdpSocket>;
106
+ /** The run's clock: the wall clock by default. A case that waits on a vendor's timer reads time and waits through it. */
107
+ clock: Clock;
108
+ exec(argv: string[], extra?: Partial<ExecRunParams>, client?: ComputerClient): Promise<Ran>;
109
+ call<M extends DaemonMethod>(method: M, params: DaemonMethods[M]["params"], client?: ComputerClient): Promise<DaemonMethods[M]["result"]>;
110
+ ok<T>(result: Result<T>, what: string): T;
111
+ /** Asserts the result is an error, with one of these codes when given. */
112
+ refused(result: Result<unknown>, what: string, codes?: ComputerErrorCode[]): ComputerError;
113
+ equal(actual: unknown, expected: unknown, what: string): void;
114
+ deepEqual(actual: unknown, expected: unknown, what: string): void;
115
+ match(text: string, pattern: RegExp, what: string): void;
116
+ /** Fails the case with what when condition is false. */
117
+ assert(condition: unknown, what: string): void;
118
+ /** The value, or the case fails with what when it is undefined or null. */
119
+ present<T>(value: T | undefined | null, what: string): T;
120
+ /** Calls fn until it returns a value other than undefined or false, for up to ms (default patience). */
121
+ until<T>(fn: () => Promise<T | undefined | false>, what: string, ms?: number): Promise<T>;
122
+ /** Ends the case as a skip, with the reason. */
123
+ skip(reason: string): never;
124
+ /** Records what the case saw without asserting it (its result's observed), for a fact not yet known either way. */
125
+ observe(words: string): void;
126
+ }
127
+ export interface Case {
128
+ /** `<group>.<name>`. */
129
+ id: string;
130
+ level: Level;
131
+ group: CaseGroup;
132
+ needs: Capability[];
133
+ /** "shared" (default): the run's computer; "fresh": one of its own; "none": no computer. */
134
+ computer?: "shared" | "fresh" | "none";
135
+ /** The longest this case may run, when it needs longer than the run's default. */
136
+ timeoutMs?: number;
137
+ run(t: CaseContext): Promise<void>;
138
+ }
139
+ export interface CaseResult {
140
+ id: string;
141
+ level: Level;
142
+ group: CaseGroup;
143
+ status: "pass" | "fail" | "skip";
144
+ reason?: string;
145
+ /**
146
+ * On a skip: the needs that were not declared and are optional for this kind of computer. A Core case skipped for
147
+ * these does not fail Core; any other skip of a Core case does.
148
+ */
149
+ undeclared?: Capability[];
150
+ /** What the case saw and recorded without asserting it (CaseContext.observe); absent when nothing. */
151
+ observed?: string[];
152
+ }
153
+ export interface ConformanceReport {
154
+ /** The provider's id. */
155
+ provider: string;
156
+ providerVersion: string;
157
+ /** What the provider declares the computer is, and who answers its methods. */
158
+ kind: ComputerKind;
159
+ daemonMode: DaemonMode;
160
+ image: string;
161
+ /** What the run's computer said in hello; null when no computer could be made. */
162
+ daemon: {
163
+ version: string;
164
+ os: string;
165
+ arch: string;
166
+ } | null;
167
+ /** The groups or case ids the run was limited to, when it was. */
168
+ only?: string[];
169
+ /** When only or kind was given: the Core cases it left out, which did not run. */
170
+ coreNotRun?: string[];
171
+ /** When the run was by kind: whether the provider passes it, and why not. */
172
+ kindVerdict?: KindVerdict;
173
+ results: CaseResult[];
174
+ /**
175
+ * pass when every Core case ran and passed, but those skipped for an optional group the computer does not declare,
176
+ * and the run left no computer behind. partial when only left Core cases out and every case that ran passed (a Core
177
+ * case skipped for any other reason is not a pass), with nothing left behind: no Core verdict. fail otherwise.
178
+ */
179
+ core: "pass" | "partial" | "fail";
180
+ /** What cases needed that the provider or the computer does not declare and its kind does not require. */
181
+ undeclared: Capability[];
182
+ /**
183
+ * The computers of this run deleted, those still there after it, what went wrong, and the computers a provider gave
184
+ * after their case had ended (each deleted as it came).
185
+ */
186
+ cleanup: {
187
+ deleted: string[];
188
+ left: string[];
189
+ errors: string[];
190
+ late: string[];
191
+ };
192
+ /** What the provider module says of its configuration, for whoever reads the report; absent when it says nothing. */
193
+ notes?: string[];
194
+ /**
195
+ * What create's read-back recorded of each computer the run made that does not refuse it (a probe target that
196
+ * accepted and sent nothing back), one entry per note, naming the computer, in the order they came; absent when none.
197
+ */
198
+ computerNotes?: ComputerNote[];
199
+ /**
200
+ * What the provider said through its onNote option during the run (a release that did not let an Archil folder go
201
+ * cleanly), naming the computer, in the order it came: no failure of any case. The CLI gives the option and fills
202
+ * this; absent when nothing was said.
203
+ */
204
+ providerNotes?: ComputerNote[];
205
+ }
206
+ /** One note a create returned: the computer's name and the note's words. */
207
+ export interface ComputerNote {
208
+ computer: string;
209
+ note: string;
210
+ }
211
+ export interface ConformanceOptions {
212
+ /** The image every computer of the run starts from. */
213
+ image: string;
214
+ /** Run only these groups or case ids. */
215
+ only?: string[];
216
+ /**
217
+ * Run a setting kind's cases (kindCases) and give its verdict (report.kindVerdict); not with only. Kind none, no
218
+ * computer, is refused, in words.
219
+ */
220
+ kind?: ComputerSettingKind;
221
+ signal?: AbortSignal;
222
+ /** The cases to run; default casesFor the provider's machine kind: a browser's own cases, else every case of the suite. */
223
+ cases?: Case[];
224
+ /** The same provider with a daemon that reports another version, for the drift cases. */
225
+ drifted?: () => Promise<ComputerProvider> | ComputerProvider;
226
+ /**
227
+ * A fresh run's folder for a mount kind, for the mount cases: the provider's conformance module makes it (a folder on
228
+ * the Docker host for a bind), or gives undefined for a kind it cannot make. Without it, those cases skip in words.
229
+ */
230
+ mountFor?: (kind: MountKind) => Promise<RunFolder | undefined> | RunFolder | undefined;
231
+ /** Called as each case ends. */
232
+ onResult?: (result: CaseResult) => void;
233
+ /** Notes the provider module gives for the report, printed before the verdict. */
234
+ notes?: string[];
235
+ /** The longest one case may run; default 180 s. */
236
+ caseTimeoutMs?: number;
237
+ /** How long a case waits on a program; default 30 s. */
238
+ patience?: number;
239
+ /** The longest each cleanup call (release, the sweep, list) may take; default 60 s. */
240
+ cleanupTimeoutMs?: number;
241
+ /**
242
+ * The fixture on this machine, for the cases that check what input did: computerd-fixture for a desktop, the
243
+ * fixture APK for an Android phone. Without it those cases skip, and Core cannot pass where kind requires them.
244
+ */
245
+ fixture?: string;
246
+ /** fetch for screen.stream; default the global one. */
247
+ fetch?: CaseContext["fetch"];
248
+ /** How the browser cases open a CDP socket; default a WebSocket (dialCdp). Tests give a fake browser's. */
249
+ cdp?: CdpDialer;
250
+ /** The clock lifetime.extend reads and waits on; default the wall clock. Tests give one their fakes share. */
251
+ clock?: Clock;
252
+ }
253
+ /** Time as a case reads it: now() in ms since the epoch, and a wait of ms on the same clock. */
254
+ export interface Clock {
255
+ now(): number;
256
+ sleep(ms: number): Promise<void>;
257
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * What a computer of this kind and daemon mode must declare: a case that needs one of these fails Core when it is
3
+ * missing, where a case that needs an undeclared optional group is skipped. exec, files and processes are Core whenever
4
+ * computerd runs (pid1 or child); with daemon none they are tested only when declared. Network none is Core wherever
5
+ * computerd runs; a phone is tested on an open network. A child daemon runs beside the vendor's own agent, so it must
6
+ * declare that agent's ports (vendor-agent), and isolation.vendor-agent checks its programs reach none of them. A
7
+ * browser must declare its CDP target.
8
+ */
9
+ export function coreGroups(kind, daemon) {
10
+ const computerd = daemon === "none" ? [] : ["exec", "files", "processes", "network:none", ...(daemon === "child" ? ["vendor-agent"] : [])];
11
+ switch (kind) {
12
+ case "linux":
13
+ return computerd;
14
+ case "desktop":
15
+ return [...computerd, "screen", "input.pointer", "input.keys"];
16
+ case "android":
17
+ case "ios":
18
+ return ["screen", "input.touch"];
19
+ case "browser":
20
+ return ["cdp"];
21
+ default:
22
+ return computerd;
23
+ }
24
+ }
@@ -0,0 +1,40 @@
1
+ import { closeSync, fchmodSync, fsyncSync, renameSync, type Stats, unlinkSync } from "node:fs";
2
+ import { type Result } from "./result.js";
3
+ /**
4
+ * The default directory for the copies: ~/.cache/agentrun-computer. The library reads no environment, XDG_CACHE_HOME
5
+ * included: a caller that keeps its cache elsewhere passes the provider's daemonCache.
6
+ */
7
+ export declare function defaultDaemonCache(): string;
8
+ /** The file operations daemonCopy uses: node:fs's own, or, in a test, a wrapper of them that fails one call. */
9
+ export interface CopyFs {
10
+ closeSync: typeof closeSync;
11
+ fchmodSync: typeof fchmodSync;
12
+ fstatSync: (fd: number) => Stats;
13
+ fsyncSync: typeof fsyncSync;
14
+ lstatSync: (path: string) => Stats;
15
+ mkdirSync: (path: string, options: {
16
+ recursive?: boolean;
17
+ mode: number;
18
+ }) => unknown;
19
+ openSync: (path: string, flags: number, mode?: number) => number;
20
+ readFileSync: (fd: number) => Buffer;
21
+ realpathSync: (path: string) => string;
22
+ renameSync: typeof renameSync;
23
+ unlinkSync: typeof unlinkSync;
24
+ writeFileSync: (fd: number, data: Buffer) => void;
25
+ }
26
+ /**
27
+ * The path of a 0755 copy of the daemon at `source` in `directory`, named computerd-<sha256>, made if it is not there
28
+ * yet and hashed again before it is returned; or a refusal in words. A copy is written to a temporary file in the
29
+ * directory and renamed into place, so processes copying the same daemon at once each leave a whole file, and only the
30
+ * same bytes ever take that name. A directory that is gone partway (a cache cleaner) is made again and checked again,
31
+ * once. Never throws: every failure is a Result in words naming its path. `fs` is node:fs's own but in tests.
32
+ */
33
+ export declare function daemonCopy(source: string, directory: string, fs?: CopyFs): Result<string>;
34
+ /**
35
+ * `directory`, made if missing and checked as daemonCopy checks its own (privateDirectory: this user's, 0700, no link,
36
+ * nothing above it another user may write), as a path with no link in it; made again once when a cleaner removes it
37
+ * partway. For what else the provider keeps beside the daemon's copy: the trees the volume option stages
38
+ * (src/docker/stage.ts), the daemon's directory and the egress proxy's code.
39
+ */
40
+ export declare function privateCacheDirectory(directory: string): Result<string>;