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

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 (148) hide show
  1. package/NOTICE +2 -0
  2. package/README.md +423 -323
  3. package/box/Dockerfile +3 -1
  4. package/box/agentrun-archil +59 -7
  5. package/box/build-agent37.mjs +177 -0
  6. package/box/build-daytona.py +20 -4
  7. package/dist/agent37.d.ts +165 -0
  8. package/dist/agent37.js +759 -0
  9. package/dist/attach.d.ts +146 -0
  10. package/dist/attach.js +469 -0
  11. package/dist/browser.d.ts +61 -10
  12. package/dist/browser.js +125 -3
  13. package/dist/browserbase.d.ts +46 -23
  14. package/dist/browserbase.js +162 -17
  15. package/dist/chrome.d.ts +3 -4
  16. package/dist/chrome.js +6 -11
  17. package/dist/client.d.ts +33 -1
  18. package/dist/client.js +53 -0
  19. package/dist/computerd-linux-amd64 +0 -0
  20. package/dist/computerd-linux-arm64 +0 -0
  21. package/dist/conformance/agent37.d.ts +96 -0
  22. package/dist/conformance/agent37.js +154 -0
  23. package/dist/conformance/cases/apps.d.ts +5 -0
  24. package/dist/conformance/cases/apps.js +160 -73
  25. package/dist/conformance/cases/health.js +14 -0
  26. package/dist/conformance/cases/index.js +2 -0
  27. package/dist/conformance/cases/provider.js +27 -1
  28. package/dist/conformance/cases/screen.d.ts +3 -0
  29. package/dist/conformance/cases/screen.js +18 -0
  30. package/dist/conformance/cases/settings.d.ts +29 -23
  31. package/dist/conformance/cases/settings.js +76 -58
  32. package/dist/conformance/cases/touch.js +19 -17
  33. package/dist/conformance/cases/ui.d.ts +2 -0
  34. package/dist/conformance/cases/ui.js +475 -0
  35. package/dist/conformance/cli.d.ts +9 -0
  36. package/dist/conformance/cli.js +28 -3
  37. package/dist/conformance/daytona.d.ts +4 -0
  38. package/dist/conformance/daytona.js +5 -0
  39. package/dist/conformance/e2b.d.ts +6 -0
  40. package/dist/conformance/e2b.js +9 -2
  41. package/dist/conformance/fixture.d.ts +1 -1
  42. package/dist/conformance/fixture.js +25 -1
  43. package/dist/conformance/modal.d.ts +17 -13
  44. package/dist/conformance/modal.js +18 -9
  45. package/dist/conformance/orgo.d.ts +3 -3
  46. package/dist/conformance/orgo.js +6 -8
  47. package/dist/conformance/phone-harness.d.ts +6 -2
  48. package/dist/conformance/phone-harness.js +21 -4
  49. package/dist/conformance/report.js +1 -1
  50. package/dist/conformance/runner.js +23 -4
  51. package/dist/conformance/sweep.d.ts +50 -0
  52. package/dist/conformance/sweep.js +187 -0
  53. package/dist/conformance/types.d.ts +11 -3
  54. package/dist/conformance/ui-fixture.d.ts +56 -0
  55. package/dist/conformance/ui-fixture.js +43 -0
  56. package/dist/create-requests.d.ts +51 -0
  57. package/dist/create-requests.js +121 -0
  58. package/dist/daytona.d.ts +15 -5
  59. package/dist/daytona.js +58 -38
  60. package/dist/descriptor.d.ts +29 -2
  61. package/dist/descriptor.js +13 -0
  62. package/dist/descriptors/agent37.d.ts +41 -0
  63. package/dist/descriptors/agent37.js +28 -0
  64. package/dist/descriptors/browserbase.d.ts +1 -0
  65. package/dist/descriptors/browserbase.js +2 -0
  66. package/dist/descriptors/daytona.d.ts +23 -2
  67. package/dist/descriptors/daytona.js +34 -2
  68. package/dist/descriptors/index.d.ts +66 -3
  69. package/dist/descriptors/index.js +5 -3
  70. package/dist/descriptors/kernel.d.ts +1 -0
  71. package/dist/descriptors/kernel.js +2 -0
  72. package/dist/descriptors/modal.d.ts +4 -0
  73. package/dist/descriptors/modal.js +11 -1
  74. package/dist/descriptors/orgo.d.ts +13 -1
  75. package/dist/descriptors/orgo.js +9 -3
  76. package/dist/descriptors/phone-harness.d.ts +6 -1
  77. package/dist/descriptors/phone-harness.js +5 -2
  78. package/dist/docker/egress.d.ts +4 -3
  79. package/dist/docker/egress.js +7 -6
  80. package/dist/docker.d.ts +7 -4
  81. package/dist/docker.js +278 -34
  82. package/dist/e2b.d.ts +9 -165
  83. package/dist/e2b.js +282 -1342
  84. package/dist/fake-ui-driver.d.ts +97 -0
  85. package/dist/fake-ui-driver.js +717 -0
  86. package/dist/host.d.ts +182 -0
  87. package/dist/host.js +1 -0
  88. package/dist/hosted/process.d.ts +67 -0
  89. package/dist/hosted/process.js +228 -0
  90. package/dist/hosted/provider.d.ts +146 -0
  91. package/dist/hosted/provider.js +1364 -0
  92. package/dist/hosted/scripts.d.ts +76 -0
  93. package/dist/{child.js → hosted/scripts.js} +93 -12
  94. package/dist/index.d.ts +11 -7
  95. package/dist/index.js +10 -7
  96. package/dist/janitor.d.ts +5 -4
  97. package/dist/janitor.js +1 -1
  98. package/dist/kernel.d.ts +17 -27
  99. package/dist/kernel.js +94 -18
  100. package/dist/kinds.d.ts +17 -5
  101. package/dist/kinds.js +20 -4
  102. package/dist/labels.d.ts +10 -2
  103. package/dist/labels.js +30 -7
  104. package/dist/local-chrome.d.ts +5 -5
  105. package/dist/local-chrome.js +10 -5
  106. package/dist/modal.d.ts +23 -181
  107. package/dist/modal.js +273 -1232
  108. package/dist/mount-archil.d.ts +25 -3
  109. package/dist/mount-archil.js +39 -8
  110. package/dist/orgo-channel.d.ts +3 -2
  111. package/dist/orgo-channel.js +5 -2
  112. package/dist/orgo-desktop.d.ts +23 -9
  113. package/dist/orgo-desktop.js +328 -66
  114. package/dist/orgo-names.d.ts +129 -3
  115. package/dist/orgo-names.js +211 -8
  116. package/dist/orgo-workspaces.d.ts +47 -0
  117. package/dist/orgo-workspaces.js +94 -0
  118. package/dist/orgo.d.ts +27 -10
  119. package/dist/orgo.js +411 -81
  120. package/dist/phone-harness.d.ts +31 -21
  121. package/dist/phone-harness.js +510 -681
  122. package/dist/png.d.ts +4 -0
  123. package/dist/png.js +27 -0
  124. package/dist/protocol.d.ts +338 -30
  125. package/dist/protocol.js +96 -3
  126. package/dist/provider.d.ts +97 -7
  127. package/dist/provider.js +24 -3
  128. package/dist/result.d.ts +1 -1
  129. package/dist/surface/api.d.ts +248 -0
  130. package/dist/surface/api.js +1 -0
  131. package/dist/surface/core.d.ts +42 -0
  132. package/dist/surface/core.js +393 -0
  133. package/dist/surface/index.d.ts +5 -0
  134. package/dist/surface/index.js +3 -0
  135. package/dist/surface/outline.d.ts +8 -0
  136. package/dist/surface/outline.js +50 -0
  137. package/dist/surface/script.d.ts +10 -0
  138. package/dist/surface/script.js +92 -0
  139. package/dist/ui-engine.d.ts +114 -0
  140. package/dist/ui-engine.js +798 -0
  141. package/package.json +17 -1
  142. package/dist/child.d.ts +0 -42
  143. package/dist/conformance/e2b-diagnose.d.ts +0 -16
  144. package/dist/conformance/e2b-diagnose.js +0 -61
  145. package/dist/conformance/e2b-sweep.d.ts +0 -18
  146. package/dist/conformance/e2b-sweep.js +0 -132
  147. package/dist/conformance/modal-sweep.d.ts +0 -22
  148. package/dist/conformance/modal-sweep.js +0 -213
package/dist/chrome.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type Result } from "./result.js";
2
- /** The environment names a Chrome is found by: pi-browser's own, then the common one. */
2
+ /** The environment names a Chrome is found by: PI_BROWSER_CHROME, then the common CHROME_PATH. */
3
3
  export declare const CHROME_ENV: readonly ["PI_BROWSER_CHROME", "CHROME_PATH"];
4
4
  /**
5
5
  * The Chrome or Chromium on this machine: the one PI_BROWSER_CHROME or CHROME_PATH names in `env`, else the first on
@@ -22,9 +22,8 @@ export declare const CHROME_FLAGS: readonly string[];
22
22
  * each refused by the proxy after its lookup; no name or address resolved by Chrome itself but the proxy's, so a request
23
23
  * a page sends around the proxy reaches nothing; no QUIC, which goes around an HTTP proxy; and WebRTC on no UDP but the
24
24
  * proxy's, which carries none, so no ICE candidate is gathered and no STUN packet leaves. That last is
25
- * `--webrtc-ip-handling-policy`: Chrome 155 and 156 ignore the `--force-` spelling (#1718 measured a STUN server on
26
- * loopback sent its binding requests under it). From #1718's chromeFence, less the bypass it kept for the DevTools guard
27
- * Stagehand's extension dialled: nothing in this browser reaches its own DevTools socket.
25
+ * `--webrtc-ip-handling-policy`: Chrome 155 and 156 ignore the `--force-` spelling (a STUN server on loopback
26
+ * was sent binding requests under it). Nothing in this browser reaches its own DevTools socket.
28
27
  */
29
28
  export declare function chromeFence(proxy: string): string[];
30
29
  /** Signal 0 only asks; EPERM means the process exists under another user. */
package/dist/chrome.js CHANGED
@@ -1,11 +1,7 @@
1
- // Launching a Chrome on this machine, the pieces the local browser (local-chrome.ts, local-supervisor.ts) is made of. Moved
2
- // here from pi-browser, which starts its own local Chrome (packages/pi-browser/src/providers/chrome-args.ts findChrome, and
3
- // src/providers/cdp.ts alive, leadsOwnGroup, killTree, ownDebugger and singletonDir), so pi-browser can import them back
4
- // once it depends on this package; and the fence and sandbox check of PR #1718's local Chrome for serve
5
- // (packages/serve/src/local-chrome.ts chromeFence and checkChrome), less what was there for Stagehand's extension.
1
+ // Launching a Chrome on this machine, the pieces the local browser (local-chrome.ts, local-supervisor.ts) is made of: finding
2
+ // a Chrome, its process-group and singleton-lock handling, and the fence and sandbox check of a local Chrome.
6
3
  //
7
- // The library reads no environment: where pi-browser read CHROME_PATH and PATH from process.env, findChrome takes the
8
- // environment it is given.
4
+ // The library reads no environment: findChrome takes the environment it is given.
9
5
  import { spawn } from "node:child_process";
10
6
  import { constants, existsSync, readFileSync } from "node:fs";
11
7
  import { access, mkdtemp, readFile, readlink, rm, stat } from "node:fs/promises";
@@ -23,7 +19,7 @@ const FIXED = [
23
19
  "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
24
20
  "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
25
21
  ];
26
- /** The environment names a Chrome is found by: pi-browser's own, then the common one. */
22
+ /** The environment names a Chrome is found by: PI_BROWSER_CHROME, then the common CHROME_PATH. */
27
23
  export const CHROME_ENV = ["PI_BROWSER_CHROME", "CHROME_PATH"];
28
24
  /**
29
25
  * The Chrome or Chromium on this machine: the one PI_BROWSER_CHROME or CHROME_PATH names in `env`, else the first on
@@ -71,9 +67,8 @@ export const CHROME_FLAGS = [
71
67
  * each refused by the proxy after its lookup; no name or address resolved by Chrome itself but the proxy's, so a request
72
68
  * a page sends around the proxy reaches nothing; no QUIC, which goes around an HTTP proxy; and WebRTC on no UDP but the
73
69
  * proxy's, which carries none, so no ICE candidate is gathered and no STUN packet leaves. That last is
74
- * `--webrtc-ip-handling-policy`: Chrome 155 and 156 ignore the `--force-` spelling (#1718 measured a STUN server on
75
- * loopback sent its binding requests under it). From #1718's chromeFence, less the bypass it kept for the DevTools guard
76
- * Stagehand's extension dialled: nothing in this browser reaches its own DevTools socket.
70
+ * `--webrtc-ip-handling-policy`: Chrome 155 and 156 ignore the `--force-` spelling (a STUN server on loopback
71
+ * was sent binding requests under it). Nothing in this browser reaches its own DevTools socket.
77
72
  */
78
73
  export function chromeFence(proxy) {
79
74
  const { hostname, port } = new URL(proxy);
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Readable, Writable } from "node:stream";
2
- import { type ComputerClient, type DaemonMethod, type DaemonMethods } from "./protocol.js";
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
3
  import { type Result } from "./result.js";
4
4
  export interface DaemonStream {
5
5
  readable: Readable;
@@ -20,3 +20,35 @@ export declare class DaemonClient implements ComputerClient {
20
20
  /** Ends the connection: pending and later calls fail with `gone`. */
21
21
  close(): void;
22
22
  }
23
+ /** What findNodes matches: every field given must hold. text is in the node's name or value. */
24
+ export interface UiQuery {
25
+ role?: UiRole;
26
+ text?: string;
27
+ id?: string;
28
+ }
29
+ /** The nodes of an observation that match the query, in the observation's order. */
30
+ export declare function findNodes(seen: Pick<UiObserveResult, "nodes">, { role, text, id }: UiQuery): UiNode[];
31
+ /** The refused step of an act, with its index, or undefined when every step ran. A refused step is always the last. */
32
+ export declare function refusedStep(result: Pick<UiActResult, "steps">): {
33
+ index: number;
34
+ kind: DaemonErrorKind;
35
+ message: string;
36
+ } | undefined;
37
+ export interface UiActOptions extends CallOptions {
38
+ expect?: UiExpect;
39
+ foreground?: boolean;
40
+ /** The state the steps' points were read from; default the last state this session saw. */
41
+ state?: string;
42
+ }
43
+ /**
44
+ * The ui group on one target, over any connection: observe and act with their types, and the last state each answered,
45
+ * so an act at a point carries the state the point was read from without the caller threading it.
46
+ */
47
+ export declare class UiSession {
48
+ #private;
49
+ constructor(client: ComputerClient, target?: UiTarget);
50
+ /** The last state an observe or an act answered. */
51
+ get state(): string | undefined;
52
+ observe(params?: Omit<UiObserveParams, "target">, options?: CallOptions): Promise<Result<UiObserveResult>>;
53
+ act(steps: UiStep[], { expect, foreground, state, signal }?: UiActOptions): Promise<Result<UiActResult>>;
54
+ }
package/dist/client.js CHANGED
@@ -11,6 +11,8 @@ const KINDS = new Set([
11
11
  "exists",
12
12
  "not_dir",
13
13
  "is_dir",
14
+ "stale",
15
+ "refused",
14
16
  ]);
15
17
  /** A daemon's error reply as a ComputerError: its kind when it names one, else what its JSON-RPC code means. */
16
18
  function fromReply(error) {
@@ -134,3 +136,54 @@ export class DaemonClient {
134
136
  settle({ ok: false, error: gone });
135
137
  }
136
138
  }
139
+ /** The nodes of an observation that match the query, in the observation's order. */
140
+ export function findNodes(seen, { role, text, id }) {
141
+ return seen.nodes.filter((node) => (role === undefined || node.role === role) && (id === undefined || node.id === id) && (text === undefined || (node.name?.includes(text) ?? false) || (node.value?.includes(text) ?? false)));
142
+ }
143
+ /** The refused step of an act, with its index, or undefined when every step ran. A refused step is always the last. */
144
+ export function refusedStep(result) {
145
+ const index = result.steps.length - 1;
146
+ const last = result.steps[index];
147
+ return last !== undefined && "error" in last ? { index, ...last.error } : undefined;
148
+ }
149
+ /**
150
+ * The ui group on one target, over any connection: observe and act with their types, and the last state each answered,
151
+ * so an act at a point carries the state the point was read from without the caller threading it.
152
+ */
153
+ export class UiSession {
154
+ #client;
155
+ #target;
156
+ #state;
157
+ constructor(client, target) {
158
+ this.#client = client;
159
+ this.#target = target;
160
+ }
161
+ /** The last state an observe or an act answered. */
162
+ get state() {
163
+ return this.#state;
164
+ }
165
+ async observe(params = {}, options = {}) {
166
+ const seen = await this.#client.call("ui.observe", { ...this.#withTarget(), ...params }, options);
167
+ if (seen.ok)
168
+ this.#state = seen.value.state;
169
+ return seen;
170
+ }
171
+ async act(steps, { expect, foreground, state, signal } = {}) {
172
+ const atPoint = steps.some((step) => ("click" in step && Array.isArray(step.click)) || ("scroll" in step && Array.isArray(step.scroll)) || "drag" in step);
173
+ const from = state ?? (atPoint ? this.#state : undefined);
174
+ const params = {
175
+ ...this.#withTarget(),
176
+ steps,
177
+ ...(from === undefined ? {} : { state: from }),
178
+ ...(expect === undefined ? {} : { expect }),
179
+ ...(foreground === undefined ? {} : { foreground }),
180
+ };
181
+ const done = await this.#client.call("ui.act", params, signal === undefined ? {} : { signal });
182
+ if (done.ok)
183
+ this.#state = done.value.state;
184
+ return done;
185
+ }
186
+ #withTarget() {
187
+ return this.#target === undefined ? {} : { target: this.#target };
188
+ }
189
+ }
Binary file
Binary file
@@ -0,0 +1,96 @@
1
+ import { type Agent37Options, type Agent37Provider } from "../agent37.js";
2
+ import type { MachineHost } from "../host.js";
3
+ import type { MountKind } from "../mount.js";
4
+ import { type ArchilRunFolderOptions } from "./archil.js";
5
+ import type { RunFolder } from "./types.js";
6
+ /** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
7
+ export { ARCHIL_ENV } from "./archil.js";
8
+ /** The environment this module reads, by name, each for the option its comment names, the live switch and the run's template. */
9
+ export declare const AGENT37_ENV: {
10
+ readonly live: "AGENTRUN_COMPUTER_LIVE_AGENT37";
11
+ /** The template every computer of the run starts from; default agent37-base, or agentrun-box for kind desktop. */
12
+ readonly template: "COMPUTER_AGENT37_TEMPLATE";
13
+ /** kind: linux (default) or desktop. */
14
+ readonly kind: "COMPUTER_AGENT37_KIND";
15
+ /** apiKey, required: the workspace's API key. */
16
+ readonly key: "COMPUTER_AGENT37_API_KEY";
17
+ /** sshKey, required: the private SSH key registered on the workspace, its contents. */
18
+ readonly sshKey: "COMPUTER_AGENT37_SSH_KEY";
19
+ /** type: vm (default) or default. */
20
+ readonly type: "COMPUTER_AGENT37_TYPE";
21
+ /** region: us (default), eu or ap-south. */
22
+ readonly region: "COMPUTER_AGENT37_REGION";
23
+ /** apiUrl: Agent37's REST API; default https://api.agent37.com. */
24
+ readonly apiUrl: "COMPUTER_AGENT37_API_URL";
25
+ /** daemonPath: the daemon binary; default this package's dist/computerd-linux-amd64. */
26
+ readonly daemon: "COMPUTER_AGENT37_DAEMON";
27
+ /** maxLifetimeMs: the cap, in ms, at most 86400000; a run takes it when it is under 30 minutes, else 30 minutes. */
28
+ readonly maxLifetimeMs: "COMPUTER_AGENT37_MAX_LIFETIME_MS";
29
+ /** daemonUser: uid:gid the daemon runs as; default 2510:2510. */
30
+ readonly user: "COMPUTER_AGENT37_USER";
31
+ };
32
+ /** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
33
+ export declare const ENV: {
34
+ readonly live: "AGENTRUN_COMPUTER_LIVE_AGENT37";
35
+ /** The template every computer of the run starts from; default agent37-base, or agentrun-box for kind desktop. */
36
+ readonly template: "COMPUTER_AGENT37_TEMPLATE";
37
+ /** kind: linux (default) or desktop. */
38
+ readonly kind: "COMPUTER_AGENT37_KIND";
39
+ /** apiKey, required: the workspace's API key. */
40
+ readonly key: "COMPUTER_AGENT37_API_KEY";
41
+ /** sshKey, required: the private SSH key registered on the workspace, its contents. */
42
+ readonly sshKey: "COMPUTER_AGENT37_SSH_KEY";
43
+ /** type: vm (default) or default. */
44
+ readonly type: "COMPUTER_AGENT37_TYPE";
45
+ /** region: us (default), eu or ap-south. */
46
+ readonly region: "COMPUTER_AGENT37_REGION";
47
+ /** apiUrl: Agent37's REST API; default https://api.agent37.com. */
48
+ readonly apiUrl: "COMPUTER_AGENT37_API_URL";
49
+ /** daemonPath: the daemon binary; default this package's dist/computerd-linux-amd64. */
50
+ readonly daemon: "COMPUTER_AGENT37_DAEMON";
51
+ /** maxLifetimeMs: the cap, in ms, at most 86400000; a run takes it when it is under 30 minutes, else 30 minutes. */
52
+ readonly maxLifetimeMs: "COMPUTER_AGENT37_MAX_LIFETIME_MS";
53
+ /** daemonUser: uid:gid the daemon runs as; default 2510:2510. */
54
+ readonly user: "COMPUTER_AGENT37_USER";
55
+ };
56
+ /** What this module reads from the environment: the keys, and each other option whose name is set. */
57
+ export type Agent37Settings = Omit<Agent37Options, "ssh2" | "fetch" | "WebSocket" | "timeouts" | "probeTargets" | "proxyDomain">;
58
+ /**
59
+ * The provider's options this module reads from env, each only when its name is set; throws in words without a key,
60
+ * or on a value it cannot read, never echoing a key. create() checks the rest.
61
+ */
62
+ export declare function settingsFromEnv(env?: Record<string, string | undefined>): Agent37Settings;
63
+ /** The longest lifetime a computer of a run may ask for: init ends it at its deadline, the sweep deletes it. */
64
+ export declare const CONFORMANCE_MAX_LIFETIME_MS: number;
65
+ /** For the run's report: what this configuration means for the suite. */
66
+ export declare const conformanceNotes: string[];
67
+ export interface Agent37ModuleOptions extends Pick<Agent37Options, "ssh2" | "fetch" | "WebSocket" | "daemonPath" | "timeouts" | "onNote"> {
68
+ /** Where the settings are read; default process.env. */
69
+ env?: Record<string, string | undefined>;
70
+ /** Builds this package's daemon for linux/amd64 stamped with version, and gives its path; default go build. */
71
+ buildDaemon?: (version: string) => Promise<string>;
72
+ /** For mountFor("archil"): the disk's object API, or the SDK's Archil client, in place of the host's disk package. */
73
+ archil?: Pick<ArchilRunFolderOptions, "objects" | "Archil" | "baseUrl">;
74
+ }
75
+ /** The template every computer of the run starts from: COMPUTER_AGENT37_TEMPLATE, or agentrun-box for kind desktop, else agent37-base. */
76
+ export declare function conformanceImage({ env }?: Pick<Agent37ModuleOptions, "env">): string;
77
+ /** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
78
+ export declare function createProvider(options?: Agent37ModuleOptions): Promise<Agent37Provider>;
79
+ /** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
80
+ export declare function createDriftedProvider(options?: Agent37ModuleOptions): Promise<Agent37Provider>;
81
+ /**
82
+ * A run folder for an Archil mount, and none for any other kind (an Agent37 computer takes no bind): a fresh folder on
83
+ * the disk the COMPUTER_ARCHIL_* names name (archilSettings), none when they name none. Reaching it is a call to
84
+ * Archil, so it needs the live switch.
85
+ */
86
+ export declare function mountFor(kind: MountKind, { env, archil }?: Agent37ModuleOptions): Promise<RunFolder | undefined>;
87
+ /**
88
+ * The Agent37 host the live sweep (sweep.ts) lists and deletes through, from the same settings; it needs no live
89
+ * switch, since the sweep makes nothing, and it calls nothing until the sweep does.
90
+ */
91
+ export declare function createHost(options?: Pick<Agent37ModuleOptions, "env" | "ssh2" | "fetch" | "WebSocket">): Promise<MachineHost>;
92
+ /**
93
+ * Where the host lists, in words: one key is one workspace, and one listing covers all of it, every region and type
94
+ * (docs: instances/list). The key is named by its sha256 prefix alone, so a before file of another key is refused.
95
+ */
96
+ export declare function sweepScope({ env }?: Pick<Agent37ModuleOptions, "env">): string;
@@ -0,0 +1,154 @@
1
+ // Agent37 for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider agent37`.
2
+ // It makes real instances, which bill per minute until deleted, so it runs only with AGENTRUN_COMPUTER_LIVE_AGENT37=1
3
+ // and a key the lead has OKed, under COMPUTER_AGENT37_API_KEY, beside COMPUTER_AGENT37_SSH_KEY, the private half (its
4
+ // contents) of an SSH key registered on the same workspace. The provider reads no environment: this module reads its
5
+ // own COMPUTER_AGENT37_* names (never AGENT37_API_KEY, which may hold another team's key) and passes each to create()
6
+ // as its option. The live switch is checked first, before any other setting is read. The live sweep (sweep.ts,
7
+ // --provider agent37) reads the same names through createHost, which needs no live switch: it makes nothing.
8
+ //
9
+ // The daemon is uploaded into each instance over SSH (dist/computerd-linux-amd64, `npm run build:daemon`), so a run
10
+ // publishes nothing. The drifted provider uploads a daemon built with Go as version <version>-drift. Agent37 never
11
+ // ends an instance on its own: every computer of a run lives at most 30 minutes, by init's deadline and the janitor's
12
+ // label, and the run's sweep deletes what is left.
13
+ //
14
+ // COMPUTER_AGENT37_KIND=desktop runs the desktop's cases (screen, input) on agentrun-box, the box template
15
+ // box/build-agent37.mjs publishes in the key's workspace: build it there first, or name another with an X server in
16
+ // COMPUTER_AGENT37_TEMPLATE.
17
+ //
18
+ // For the mount cases, mountFor("archil") makes a fresh run folder on the Archil disk COMPUTER_ARCHIL_DISK names, as
19
+ // the E2B module does (./archil.ts); with no disk named it makes none, and the cases are skipped. An Archil computer
20
+ // needs a provider whose daemon user is the tool user: COMPUTER_AGENT37_USER=2510:2510, the default.
21
+ import { create, workspaceOf } from "../agent37.js";
22
+ import { AGENT37_BASE_TEMPLATE, AGENT37_BOX_TEMPLATE } from "../descriptors/agent37.js";
23
+ import { archilRunFolder, archilSettings } from "./archil.js";
24
+ import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
25
+ /** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
26
+ export { ARCHIL_ENV } from "./archil.js";
27
+ /** The environment this module reads, by name, each for the option its comment names, the live switch and the run's template. */
28
+ export const AGENT37_ENV = {
29
+ live: "AGENTRUN_COMPUTER_LIVE_AGENT37",
30
+ /** The template every computer of the run starts from; default agent37-base, or agentrun-box for kind desktop. */
31
+ template: "COMPUTER_AGENT37_TEMPLATE",
32
+ /** kind: linux (default) or desktop. */
33
+ kind: "COMPUTER_AGENT37_KIND",
34
+ /** apiKey, required: the workspace's API key. */
35
+ key: "COMPUTER_AGENT37_API_KEY",
36
+ /** sshKey, required: the private SSH key registered on the workspace, its contents. */
37
+ sshKey: "COMPUTER_AGENT37_SSH_KEY",
38
+ /** type: vm (default) or default. */
39
+ type: "COMPUTER_AGENT37_TYPE",
40
+ /** region: us (default), eu or ap-south. */
41
+ region: "COMPUTER_AGENT37_REGION",
42
+ /** apiUrl: Agent37's REST API; default https://api.agent37.com. */
43
+ apiUrl: "COMPUTER_AGENT37_API_URL",
44
+ /** daemonPath: the daemon binary; default this package's dist/computerd-linux-amd64. */
45
+ daemon: "COMPUTER_AGENT37_DAEMON",
46
+ /** maxLifetimeMs: the cap, in ms, at most 86400000; a run takes it when it is under 30 minutes, else 30 minutes. */
47
+ maxLifetimeMs: "COMPUTER_AGENT37_MAX_LIFETIME_MS",
48
+ /** daemonUser: uid:gid the daemon runs as; default 2510:2510. */
49
+ user: "COMPUTER_AGENT37_USER",
50
+ };
51
+ /** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
52
+ export const ENV = AGENT37_ENV;
53
+ /**
54
+ * The provider's options this module reads from env, each only when its name is set; throws in words without a key,
55
+ * or on a value it cannot read, never echoing a key. create() checks the rest.
56
+ */
57
+ export function settingsFromEnv(env = process.env) {
58
+ const apiKey = env[AGENT37_ENV.key];
59
+ if (apiKey === undefined || apiKey === "")
60
+ throw new Error(`set ${AGENT37_ENV.key} to an Agent37 API key: the conformance module reads it there and nowhere else, never from AGENT37_API_KEY`);
61
+ const sshKey = env[AGENT37_ENV.sshKey];
62
+ if (sshKey === undefined || sshKey === "")
63
+ throw new Error(`set ${AGENT37_ENV.sshKey} to the private SSH key registered on the Agent37 workspace (its contents, never a path)`);
64
+ const lifetime = env[AGENT37_ENV.maxLifetimeMs] || undefined;
65
+ if (lifetime !== undefined && !/^\d+$/.test(lifetime))
66
+ throw new Error(`${AGENT37_ENV.maxLifetimeMs} is a whole number of milliseconds, such as 86400000`);
67
+ const type = env[AGENT37_ENV.type] || undefined;
68
+ const region = env[AGENT37_ENV.region] || undefined;
69
+ const apiUrl = env[AGENT37_ENV.apiUrl] || undefined;
70
+ const daemonPath = env[AGENT37_ENV.daemon] || undefined;
71
+ const daemonUser = env[AGENT37_ENV.user] || undefined;
72
+ const kind = env[AGENT37_ENV.kind] || undefined;
73
+ return {
74
+ apiKey,
75
+ sshKey,
76
+ // create() refuses any other type or region in words.
77
+ ...(type === undefined ? {} : { type: type }),
78
+ ...(region === undefined ? {} : { region: region }),
79
+ ...(kind === undefined ? {} : { kind: kind }),
80
+ ...(apiUrl === undefined ? {} : { apiUrl }),
81
+ ...(daemonPath === undefined ? {} : { daemonPath }),
82
+ ...(lifetime === undefined ? {} : { maxLifetimeMs: Number(lifetime) }),
83
+ ...(daemonUser === undefined ? {} : { daemonUser }),
84
+ };
85
+ }
86
+ /** The longest lifetime a computer of a run may ask for: init ends it at its deadline, the sweep deletes it. */
87
+ export const CONFORMANCE_MAX_LIFETIME_MS = 30 * 60_000;
88
+ /** For the run's report: what this configuration means for the suite. */
89
+ export const conformanceNotes = [
90
+ "agent37: every computer is an instance (type vm by default), made with network deny-all, auto-sleep off and no public port, read back from Agent37 and probed from inside; the daemon is a child, started over SSH through the platform's sshd (port 22022; it and the platform's web terminal on 7681 are declared as the vendor's agent), and every command goes over that SSH as root. Agent37 never ends an instance on its own: lifetime janitor, capped at 30 minutes for the run. No stream() (a screen is streamed through agentrun), so screen.stream is skipped. Kind desktop (COMPUTER_AGENT37_KIND=desktop) starts from agentrun-box, our box image as a template of the key's workspace (box/build-agent37.mjs), with Xvfb on :0 started through the daemon as the tool user.",
91
+ ];
92
+ function live(env) {
93
+ if (env[AGENT37_ENV.live] !== "1") {
94
+ throw new Error(`the Agent37 conformance module makes real instances, which bill until deleted: set ${AGENT37_ENV.live}=1, with a key the lead has OKed, to run it`);
95
+ }
96
+ }
97
+ /** The template every computer of the run starts from: COMPUTER_AGENT37_TEMPLATE, or agentrun-box for kind desktop, else agent37-base. */
98
+ export function conformanceImage({ env = process.env } = {}) {
99
+ return env[AGENT37_ENV.template] || (env[AGENT37_ENV.kind] === "desktop" ? AGENT37_BOX_TEMPLATE : AGENT37_BASE_TEMPLATE);
100
+ }
101
+ /** The test doubles a caller hands in, each only when given. */
102
+ const doubles = ({ ssh2, fetch, WebSocket, timeouts, onNote }) => ({
103
+ ...(ssh2 ? { ssh2 } : {}),
104
+ ...(fetch ? { fetch } : {}),
105
+ ...(WebSocket ? { WebSocket } : {}),
106
+ ...(timeouts ? { timeouts } : {}),
107
+ ...(onNote ? { onNote } : {}),
108
+ });
109
+ /** A run's cap: COMPUTER_AGENT37_MAX_LIFETIME_MS when it is shorter, else CONFORMANCE_MAX_LIFETIME_MS. */
110
+ const runCap = (settings) => Math.min(settings.maxLifetimeMs ?? CONFORMANCE_MAX_LIFETIME_MS, CONFORMANCE_MAX_LIFETIME_MS);
111
+ /** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
112
+ export async function createProvider(options = {}) {
113
+ const { env = process.env, daemonPath } = options;
114
+ live(env);
115
+ const settings = settingsFromEnv(env);
116
+ return create({ ...settings, ...doubles(options), ...(daemonPath === undefined ? {} : { daemonPath }), maxLifetimeMs: runCap(settings) });
117
+ }
118
+ /** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
119
+ export async function createDriftedProvider(options = {}) {
120
+ const { env = process.env, buildDaemon = (version) => buildDriftDaemon("amd64", version) } = options;
121
+ live(env);
122
+ const settings = settingsFromEnv(env);
123
+ const daemonPath = await buildDaemon(DRIFT_VERSION);
124
+ return create({ ...settings, ...doubles(options), daemonPath, maxLifetimeMs: runCap(settings) });
125
+ }
126
+ /**
127
+ * A run folder for an Archil mount, and none for any other kind (an Agent37 computer takes no bind): a fresh folder on
128
+ * the disk the COMPUTER_ARCHIL_* names name (archilSettings), none when they name none. Reaching it is a call to
129
+ * Archil, so it needs the live switch.
130
+ */
131
+ export async function mountFor(kind, { env = process.env, archil = {} } = {}) {
132
+ if (kind !== "archil")
133
+ return undefined;
134
+ const settings = archilSettings(env);
135
+ if (settings === undefined)
136
+ return undefined;
137
+ live(env);
138
+ return archilRunFolder({ ...settings, ...archil });
139
+ }
140
+ /**
141
+ * The Agent37 host the live sweep (sweep.ts) lists and deletes through, from the same settings; it needs no live
142
+ * switch, since the sweep makes nothing, and it calls nothing until the sweep does.
143
+ */
144
+ export async function createHost(options = {}) {
145
+ return (await create({ ...settingsFromEnv(options.env ?? process.env), ...doubles(options) })).host;
146
+ }
147
+ /**
148
+ * Where the host lists, in words: one key is one workspace, and one listing covers all of it, every region and type
149
+ * (docs: instances/list). The key is named by its sha256 prefix alone, so a before file of another key is refused.
150
+ */
151
+ export function sweepScope({ env = process.env } = {}) {
152
+ const { apiKey, apiUrl } = settingsFromEnv(env);
153
+ return workspaceOf(apiKey, apiUrl);
154
+ }
@@ -1,2 +1,7 @@
1
1
  import type { Case } from "../types.js";
2
+ /**
3
+ * The first way ui.observe's result breaks the protocol, in words, or undefined: its state, app, window and truncated,
4
+ * and each node against UiNode, its bounds inside the window and its parent a node before it.
5
+ */
6
+ export declare function observeWrong(result: unknown): string | undefined;
2
7
  export declare const appsCases: Case[];