@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
@@ -0,0 +1,475 @@
1
+ // The ui group on the ui fixture (ui-fixture.ts): observe's shape on a window whose elements the suite knows; refs that
2
+ // stay good across states while their element exists and go stale when it leaves; a point refused as stale once its
3
+ // window changed; an expect met and one unmet; the route each step took; a settle on the tree while a caret blinks; a
4
+ // set the app takes back answered unverified; a window expect; an act whose window closed, with no window left or with
5
+ // another to follow; and hello.features, each declared feature
6
+ // doing what it says and each one off refused with its own sentence. The fixture is an image's, so its cases are Full: a
7
+ // computer without it skips them in words. ui.hello needs no fixture and is Core for every computer of the ui group.
8
+ import { FEATURES, MAX_IMAGE_EDGE, MAX_SETTLE_MS, SET_HOLD_MS } from "../../protocol.js";
9
+ import { featureOff } from "../../ui-engine.js";
10
+ import { NEW_WINDOW_MS, TAKES_BACK_MS, UI_FIXTURE } from "../ui-fixture.js";
11
+ import { observeWrong } from "./apps.js";
12
+ const APP = UI_FIXTURE.id;
13
+ const ROUTES = new Set(["semantic", "page", "background", "foreground"]);
14
+ const KNOWN = new Set(Object.keys(FEATURES));
15
+ const show = (value) => JSON.stringify(value) ?? String(value);
16
+ const look = (t, extra = {}) => t.call("ui.observe", { target: { app: APP }, ...extra });
17
+ /** Whether the driver's only input is the foreground route: ui.background off, ui.foreground on. */
18
+ const inputOnly = (t) => {
19
+ const features = t.hello.features ?? {};
20
+ return featureOff(features, "ui.background") !== undefined && features["ui.foreground"] === true;
21
+ };
22
+ /** The feature a route needs on. */
23
+ const ROUTE_FEATURE = { semantic: "ui.tree", page: "ui.page", background: "ui.background", foreground: "ui.foreground" };
24
+ /**
25
+ * ui.act on the fixture. An input-only driver gets foreground: true unless the case says otherwise, so the cases check
26
+ * what it offers rather than refuse it every step. Every step that ran is held to the routes it may take: its route's
27
+ * feature on, and the foreground route only when the call allowed it.
28
+ */
29
+ const act = async (t, params, window) => {
30
+ const sent = { target: { app: APP, ...(window === undefined ? {} : { window }) }, ...(inputOnly(t) && !("foreground" in params) ? { foreground: true } : {}), ...params };
31
+ const result = await t.call("ui.act", sent);
32
+ const features = t.hello.features ?? {};
33
+ for (const [index, step] of (result.steps ?? []).entries()) {
34
+ if (typeof step !== "object" || step === null || "error" in step)
35
+ continue;
36
+ const feature = ROUTE_FEATURE[step.route];
37
+ if (feature === undefined)
38
+ continue;
39
+ const off = featureOff(features, feature);
40
+ t.assert(off === undefined, `steps[${index}] took the ${step.route} route, and ${off}`);
41
+ t.assert(step.route !== "foreground" || sent.foreground === true, `steps[${index}] took the foreground route on a call without foreground: true`);
42
+ }
43
+ return result;
44
+ };
45
+ const byId = (t, seen, id) => t.present(seen.nodes.find((node) => node.id === id), `the fixture's ${id}, by its id, in ui.observe: ${show(seen.nodes.map((node) => node.id ?? node.name))}`);
46
+ const centre = ({ bounds: [x, y, w, h] }) => [Math.floor(x + w / 2), Math.floor(y + h / 2)];
47
+ /** The fixture, freshly launched; skips when this computer has not installed it. */
48
+ async function launch(t) {
49
+ const listed = await t.call("apps.list", {});
50
+ if (!listed.apps.some((app) => app.id === APP))
51
+ return t.skip(`the ui fixture (${APP}) is not installed on this computer: its conformance image installs it`);
52
+ await t.call("apps.terminate", { id: APP });
53
+ t.deepEqual(await t.call("apps.launch", { id: APP }), {}, `apps.launch ${APP}`);
54
+ await t.until(async () => (await t.call("apps.list", {})).foreground === APP, `${APP} in front after apps.launch`);
55
+ }
56
+ /** The fixture, freshly launched on its home window and seen there; skips without the fixture or the tree. */
57
+ async function start(t) {
58
+ await launch(t);
59
+ const treeOff = featureOff(t.hello.features ?? {}, "ui.tree");
60
+ if (treeOff !== undefined)
61
+ return t.skip(`the fixture's cases read its elements, and ${treeOff}`);
62
+ // A fresh window can add an element a moment after Next shows (on the Mac mini, a group in its title bar, every
63
+ // launch), which an act of no steps then counted as a change. The cases start once two looks in a row agree.
64
+ let last;
65
+ return t.until(async () => {
66
+ const seen = await look(t);
67
+ const shape = JSON.stringify(seen.nodes.map((node) => [node.ref, node.bounds]));
68
+ const still = shape === last;
69
+ last = shape;
70
+ return still && seen.nodes.some((node) => node.id === "next") ? seen : undefined;
71
+ }, `the fixture's home window, with its Next button, the same in two looks in a row in ui.observe`);
72
+ }
73
+ /** The step's result, which ran: its route one of the protocol's and verified a boolean. */
74
+ function ran(t, step, what) {
75
+ t.assert(step !== undefined, `${what}: the act answered no result for the step`);
76
+ t.assert(!("error" in step), `${what}: refused: ${show(step)}`);
77
+ const done = step;
78
+ t.assert(ROUTES.has(done.route), `${what}: route ${show(done.route)} is not one of ${[...ROUTES].join(", ")}`);
79
+ t.assert(typeof done.verified === "boolean", `${what}: verified ${show(done.verified)} is not a boolean`);
80
+ return done;
81
+ }
82
+ /** The step's refusal, of one of these kinds. */
83
+ function refusedStep(t, result, what, kinds) {
84
+ const last = result.steps.at(-1);
85
+ t.assert(last !== undefined && "error" in last, `${what}: the step ran, where it should be refused (${kinds.join(" or ")}): ${show(result.steps)}`);
86
+ const { error } = last;
87
+ t.assert(kinds.includes(error.kind), `${what}: refused as ${error.kind}, not ${kinds.join(" or ")}: ${error.message}`);
88
+ t.assert(typeof error.message === "string" && error.message.length > 0, `${what}: the refusal has no words`);
89
+ return error;
90
+ }
91
+ /** The fixture's node by its id, or a skip in words when this computer's fixture leaves it out (one window per app). */
92
+ const optional = (t, seen, id, why) => seen.nodes.find((node) => node.id === id) ?? t.skip(`the ui fixture here has no ${id} (${why}): a fixture that leaves it out skips this case`);
93
+ /** New window pressed, and the act's expect waits for the window it opens: the act answers once it is there. */
94
+ const openAnother = async (t, seen) => {
95
+ const open = optional(t, seen, "open", "New window, which opens a second window");
96
+ const opened = await act(t, { steps: [{ press: open.ref }], expect: { window: { title: "Another window" } } });
97
+ ran(t, opened.steps[0], "press New window");
98
+ t.equal(opened.expect, "met", `expect window "Another window": New window opens it ${NEW_WINDOW_MS} ms after its press, so only a polled expect sees it`);
99
+ return opened;
100
+ };
101
+ /** Whether a state is of this window: an observe of it since that state finds nothing changed. */
102
+ const stateOf = async (t, state, window, what) => {
103
+ t.assert(typeof state === "string" && state !== "", `${what}: the act answered no state: ${show(state)}`);
104
+ const since = await look(t, { target: { app: APP, window }, since: state });
105
+ t.deepEqual(since.diff, { added: [], removed: [], changed: [] }, `${what}: observe of window ${window} since the act's state (a state of another window shows every node added)`);
106
+ };
107
+ const toSecond = async (t, seen) => {
108
+ const result = await act(t, { steps: [{ press: byId(t, seen, "next").ref }], expect: { text: "Second page" } });
109
+ t.equal(result.expect, "met", "Next opens the second page, seen by the act's expect");
110
+ return result;
111
+ };
112
+ export const uiCases = [
113
+ {
114
+ id: "ui.fixture-shape",
115
+ level: "full",
116
+ group: "ui",
117
+ needs: ["ui", "apps"],
118
+ async run(t) {
119
+ const seen = await start(t);
120
+ const wrong = observeWrong(seen);
121
+ t.assert(wrong === undefined, `ui.observe: ${wrong}`);
122
+ t.equal(seen.app.id, APP, "the observed app");
123
+ const [, , width, height] = seen.window.bounds;
124
+ t.deepEqual([width, height], UI_FIXTURE.size, "the fixture's window size, in points");
125
+ for (const [id, role, name] of [
126
+ ["name", "textbox", "Name"],
127
+ ["wifi", "switch", "Wi-Fi"],
128
+ ["save", "button", "Save"],
129
+ ["next", "button", "Next"],
130
+ ]) {
131
+ const node = byId(t, seen, id);
132
+ t.equal(node.role, role, `${id}'s role`);
133
+ t.equal(node.name, name, `${id}'s name`);
134
+ }
135
+ t.equal(byId(t, seen, "wifi").desc, "Networks nearby", "Wi-Fi's secondary text, in desc (not value, which is an editable value)");
136
+ const full = await look(t, { full: true });
137
+ t.assert(full.nodes.length >= seen.nodes.length, `a full observe holds every node a compact one does: ${full.nodes.length} < ${seen.nodes.length}`);
138
+ // since: what changed from a state, by refs.
139
+ const again = await look(t, { since: seen.state });
140
+ t.assert(again.state !== seen.state, `each observe is a new state: ${again.state} twice`);
141
+ t.deepEqual(again.diff, { added: [], removed: [], changed: [] }, "observe since a state of the same window, untouched");
142
+ },
143
+ },
144
+ {
145
+ id: "ui.refs-stable",
146
+ level: "full",
147
+ group: "ui",
148
+ needs: ["ui", "apps"],
149
+ async run(t) {
150
+ const seen = await start(t);
151
+ const refs = Object.fromEntries(["name", "wifi", "save", "next"].map((id) => [id, byId(t, seen, id).ref]));
152
+ const typed = await act(t, { steps: [{ set: refs.name, value: "Ada" }] });
153
+ ran(t, typed.steps[0], "set Name to Ada");
154
+ const saved = await act(t, { steps: [{ press: refs.save }], expect: { text: "Saved" } });
155
+ ran(t, saved.steps[0], "press Save");
156
+ t.equal(saved.expect, "met", "Saved shows after Save, seen by the act's expect");
157
+ t.equal(saved.changed, true, "the act changed the window");
158
+ const after = await look(t, { since: seen.state });
159
+ for (const [id, ref] of Object.entries(refs))
160
+ t.equal(byId(t, after, id).ref, ref, `${id}'s ref, its element still there after the window changed`);
161
+ t.equal(byId(t, after, "name").value, "Ada", "Name's value after set");
162
+ const note = t.present(after.nodes.find((node) => node.name === "Saved"), "the text Saved in ui.observe");
163
+ t.assert(after.diff?.added.includes(note.ref), `observe since the first state names Saved as added: ${show(after.diff)}`);
164
+ t.assert(after.diff?.changed.includes(refs.name), `observe since the first state names Name as changed: ${show(after.diff)}`);
165
+ },
166
+ },
167
+ {
168
+ id: "ui.expect",
169
+ level: "full",
170
+ group: "ui",
171
+ needs: ["ui", "apps"],
172
+ async run(t) {
173
+ const seen = await start(t);
174
+ const next = byId(t, seen, "next").ref;
175
+ // Unmet, on the still home window: after its timeout, and the act still answers its state.
176
+ const began = Date.now();
177
+ const waited = await act(t, { steps: [], expect: { text: "No such text anywhere", timeoutMs: 300 } });
178
+ const took = Date.now() - began;
179
+ t.equal(waited.expect, "unmet", "an expect for text the window never shows");
180
+ t.assert(took >= 250, `an unmet expect waits its timeout (300 ms) before it answers: it answered in ${took} ms`);
181
+ t.assert(typeof waited.state === "string" && waited.state !== "", `an unmet act answers its state: ${show(waited.state)}`);
182
+ t.equal(waited.changed, false, "an act of no steps on a still window changes nothing");
183
+ // Met: the second page comes some time after the press, so only a polled expect sees it.
184
+ const opened = await act(t, { steps: [{ press: next }], expect: { ref: next, gone: true } });
185
+ t.equal(opened.expect, "met", "expect gone: Next leaves the window after its press");
186
+ const now = await look(t);
187
+ t.assert(now.nodes.some((node) => node.name === "Second page"), `the second page is shown after the expect was met: ${show(now.nodes.map((node) => node.name))}`);
188
+ },
189
+ },
190
+ {
191
+ id: "ui.stale-ref",
192
+ level: "full",
193
+ group: "ui",
194
+ needs: ["ui", "apps"],
195
+ async run(t) {
196
+ const seen = await start(t);
197
+ const name = byId(t, seen, "name").ref;
198
+ await toSecond(t, seen);
199
+ const gone = await act(t, { steps: [{ press: name }, { press: name }] });
200
+ refusedStep(t, gone, "press Name, which is not on the second page", ["stale"]);
201
+ t.equal(gone.steps.length, 1, "the refused step is the last result: the steps after it do not run");
202
+ const never = await t.client.call("ui.act", { target: { app: APP }, steps: [{ press: "@never-given" }] }, { signal: t.signal });
203
+ t.refused(never, "ui.act with a ref this connection was never given", ["invalid"]);
204
+ },
205
+ },
206
+ {
207
+ id: "ui.stale-point",
208
+ level: "full",
209
+ group: "ui",
210
+ needs: ["ui", "apps"],
211
+ async run(t) {
212
+ const seen = await start(t);
213
+ const save = centre(byId(t, seen, "save"));
214
+ await toSecond(t, seen);
215
+ const moved = await act(t, { state: seen.state, steps: [{ click: save }] });
216
+ refusedStep(t, moved, `a click at Save's point ${show(save)}, read from the home window's state, on the second page`, ["stale"]);
217
+ const old = await act(t, { state: "s-never-given", steps: [{ click: save }] });
218
+ refusedStep(t, old, "a click from a state never given", ["stale"]);
219
+ const second = await look(t);
220
+ const [, , width, height] = second.window.bounds;
221
+ const outside = await act(t, { state: second.state, steps: [{ click: [width + 10, height + 10] }] });
222
+ refusedStep(t, outside, "a click outside the window", ["invalid"]);
223
+ // A point from the current state lands: Back, at its centre, goes home.
224
+ const features = t.hello.features ?? {};
225
+ const foreground = features["ui.background"] !== true;
226
+ if (foreground && features["ui.foreground"] !== true)
227
+ return t.skip("a click needs ui.background or ui.foreground, and this computer declares neither");
228
+ const back = await act(t, { state: second.state, steps: [{ click: centre(byId(t, second, "back")) }], expect: { text: "UI fixture" }, ...(foreground ? { foreground: true } : {}) });
229
+ ran(t, back.steps[0], "a click at Back's point, read from the current state");
230
+ t.equal(back.expect, "met", "the click at Back's point went home");
231
+ },
232
+ },
233
+ {
234
+ id: "ui.route-reported",
235
+ level: "full",
236
+ group: "ui",
237
+ needs: ["ui", "apps"],
238
+ async run(t) {
239
+ const seen = await start(t);
240
+ const pressed = ran(t, (await act(t, { steps: [{ press: byId(t, seen, "wifi").ref }] })).steps[0], "press Wi-Fi");
241
+ // The best route first: semantic, unless the driver's input is all it has (ui.background off, foreground only).
242
+ t.assert(pressed.route === "semantic" || (inputOnly(t) && pressed.route === "foreground"), `a press on a switch with an accessibility action goes the semantic route, or foreground on a driver with no other: it went ${pressed.route}`);
243
+ const after = await look(t);
244
+ t.assert(byId(t, after, "wifi").flags?.includes("checked"), `Wi-Fi is checked after its press: ${show(byId(t, after, "wifi").flags)}`);
245
+ // The canvas takes foreground input only, and its value counts the clicks that reached it. A driver need not
246
+ // know that: without foreground: true it may refuse the click, or post it the background way, which never
247
+ // reaches the canvas. Either is right. What is never right is answering verified for a click that did not land.
248
+ const canvas = byId(t, after, "canvas").ref;
249
+ const count = (seen) => {
250
+ const value = byId(t, seen, "canvas").value;
251
+ t.assert(value !== undefined && /^\d+$/.test(value), `the canvas's value counts the clicks that reached it: ${show(value)}`);
252
+ return Number(value);
253
+ };
254
+ const off = featureOff(t.hello.features ?? {}, "ui.foreground");
255
+ const before = count(after);
256
+ const posted = await act(t, { steps: [{ click: canvas }], foreground: false });
257
+ const first = posted.steps[0];
258
+ if (first !== undefined && "error" in first) {
259
+ const refused = refusedStep(t, posted, "a click on the canvas without foreground: true", ["denied", "unsupported"]);
260
+ if (off === undefined)
261
+ t.equal(refused.kind, "denied", "with ui.foreground on, a foreground-only step in a call that does not allow it is denied");
262
+ }
263
+ else {
264
+ const step = ran(t, first, "a click on the canvas without foreground: true");
265
+ t.assert(step.route !== "foreground", "a call without foreground: true never takes the foreground route");
266
+ const landed = count(await look(t)) > before;
267
+ t.assert(!step.verified || landed, `the click answered verified, and the canvas's count did not move: a driver never verifies an effect that did not happen`);
268
+ }
269
+ if (off !== undefined)
270
+ return t.skip(`the foreground route is not tested: ${off}`);
271
+ const ready = count(await look(t));
272
+ const allowed = ran(t, (await act(t, { steps: [{ click: canvas }], foreground: true })).steps[0], "a click on the canvas with foreground: true");
273
+ t.equal(count(await look(t)), ready + 1, "the click with foreground: true reached the canvas: its count went up by one");
274
+ t.equal(allowed.verified, true, "the driver verified the click by reading the canvas's count back");
275
+ },
276
+ },
277
+ {
278
+ id: "ui.hello",
279
+ level: "core",
280
+ group: "ui",
281
+ needs: ["ui"],
282
+ async run(t) {
283
+ // Needs no fixture: every computer of the ui group says its screen and its features, each on or off in words.
284
+ const features = t.present(t.hello.features, "hello.features, which a computer of the ui group declares");
285
+ for (const [name, value] of Object.entries(features)) {
286
+ const off = typeof value === "object" && value !== null && typeof value.off === "string" && value.off.trim() !== "";
287
+ t.assert(value === true || off, `hello.features.${name} is ${show(value)}, not true or { off: "<why, in words>" }`);
288
+ if (!KNOWN.has(name))
289
+ t.observe(`hello.features names ${name}, which the protocol does not (FEATURES)`);
290
+ }
291
+ t.assert(features["ui.tree"] !== undefined, `hello.features declares ui.tree, on or off with its reason: ${show(features)}`);
292
+ const screen = t.present(t.hello.screen, "hello.screen, which a computer of the ui group declares");
293
+ t.assert([screen.width, screen.height, screen.scale].every((n) => typeof n === "number" && n > 0), `hello.screen is ${show(screen)}, not { width, height, scale } above 0`);
294
+ const device = t.hello.device;
295
+ if (device !== undefined) {
296
+ t.assert([device.maker, device.model].every((one) => typeof one === "string" && one.trim() !== ""), `hello.device is ${show(device)}, not { maker, model } in words`);
297
+ }
298
+ },
299
+ },
300
+ {
301
+ id: "ui.features-declared",
302
+ level: "full",
303
+ group: "ui",
304
+ needs: ["ui", "apps"],
305
+ async run(t) {
306
+ // Each declared feature does what it says.
307
+ const features = t.hello.features ?? {};
308
+ const seen = await start(t);
309
+ if (features["ui.image"] === true) {
310
+ const shot = t.present((await look(t, { image: { maxEdge: 256 } })).image, "ui.observe's image with ui.image on");
311
+ t.assert(shot.format === "png" || shot.format === "jpeg", `the image's format is ${show(shot.format)}`);
312
+ t.assert(Math.max(shot.width, shot.height) <= 256 && Math.min(shot.width, shot.height) > 0, `the image is ${shot.width}x${shot.height}, not within maxEdge 256`);
313
+ t.assert(Buffer.from(shot.data, "base64").length > 0, "the image has data");
314
+ const big = await t.client.call("ui.observe", { target: { app: APP }, image: { maxEdge: MAX_IMAGE_EDGE + 1 } }, { signal: t.signal });
315
+ t.refused(big, `ui.observe with image.maxEdge ${MAX_IMAGE_EDGE + 1}`, ["limit"]);
316
+ }
317
+ if (features["ui.nav"] === true) {
318
+ await toSecond(t, seen);
319
+ const back = await act(t, { steps: [{ nav: "back" }], expect: { text: "UI fixture" } });
320
+ ran(t, back.steps[0], "nav back");
321
+ t.equal(back.expect, "met", "nav back from the second page goes home");
322
+ }
323
+ if (features["apps.background"] === true) {
324
+ await t.call("apps.terminate", { id: APP });
325
+ t.deepEqual(await t.call("apps.launch", { id: APP, background: true }), {}, "apps.launch in the background, with apps.background on");
326
+ t.assert((await t.call("apps.list", {})).foreground !== APP, "an app launched in the background is not in front");
327
+ t.assert((await look(t)).nodes.some((node) => node.id === "next"), "ui.observe reaches an app in the background by its target");
328
+ }
329
+ },
330
+ },
331
+ {
332
+ id: "ui.features-off-refused",
333
+ level: "full",
334
+ group: "ui",
335
+ needs: ["ui", "apps"],
336
+ async run(t) {
337
+ const features = t.hello.features ?? {};
338
+ const offs = ["ui.tree", "ui.image", "ui.nav", "apps.background"].filter((name) => features[name] !== true);
339
+ if (offs.length === 0)
340
+ return t.skip("this computer declares ui.tree, ui.image, ui.nav and apps.background on: no refusal to check");
341
+ /** The refusal says why, in the computer's own sentence, when it declared one. */
342
+ const says = (message, name) => {
343
+ const value = features[name];
344
+ const why = typeof value === "object" ? value.off : undefined;
345
+ if (why !== undefined)
346
+ t.assert(message.includes(why), `the refusal of ${name} carries its sentence ${show(why)}: ${message}`);
347
+ };
348
+ if (offs.includes("ui.tree")) {
349
+ // No tree: the window's image with no nodes and the reason, or, with no image either, denied in words.
350
+ await launch(t);
351
+ const seen = await t.client.call("ui.observe", { target: { app: APP } }, { signal: t.signal });
352
+ if (offs.includes("ui.image")) {
353
+ const refused = t.refused(seen, "ui.observe with ui.tree and ui.image off", ["denied"]);
354
+ says(refused.message, "ui.tree");
355
+ says(refused.message, "ui.image");
356
+ }
357
+ else {
358
+ const view = t.ok(seen, "ui.observe with ui.tree off");
359
+ t.deepEqual(view.nodes, [], "ui.observe's nodes with ui.tree off");
360
+ says(t.present(view.empty, "ui.observe's empty, the reason it has no nodes"), "ui.tree");
361
+ t.present(view.image, "ui.observe's image with ui.tree off, unasked: the view a caller acts on by points");
362
+ const waited = await t.client.call("ui.act", { target: { app: APP }, steps: [], expect: { text: "UI fixture", timeoutMs: 100 } }, { signal: t.signal });
363
+ says(t.refused(waited, "an expect with ui.tree off", ["unsupported"]).message, "ui.tree");
364
+ }
365
+ if (offs.includes("apps.background")) {
366
+ const launched = await t.client.call("apps.launch", { id: APP, background: true }, { signal: t.signal });
367
+ says(t.refused(launched, "apps.launch in the background, apps.background off", ["unsupported"]).message, "apps.background");
368
+ }
369
+ return;
370
+ }
371
+ const seen = await start(t);
372
+ for (const name of offs) {
373
+ if (name === "ui.image") {
374
+ const shot = await t.client.call("ui.observe", { target: { app: APP }, image: true }, { signal: t.signal });
375
+ says(t.refused(shot, "ui.observe with an image, ui.image off", ["unsupported"]).message, name);
376
+ }
377
+ else if (name === "ui.nav") {
378
+ await toSecond(t, seen);
379
+ const back = await act(t, { steps: [{ nav: "back" }] });
380
+ says(refusedStep(t, back, "nav back, ui.nav off", ["unsupported"]).message, name);
381
+ }
382
+ else {
383
+ const launched = await t.client.call("apps.launch", { id: APP, background: true }, { signal: t.signal });
384
+ says(t.refused(launched, "apps.launch in the background, apps.background off", ["unsupported"]).message, name);
385
+ }
386
+ }
387
+ },
388
+ },
389
+ {
390
+ id: "ui.settle-tree",
391
+ level: "full",
392
+ group: "ui",
393
+ needs: ["ui", "apps"],
394
+ async run(t) {
395
+ // A focused field's caret blinks: what the window draws changes, its tree does not. A driver settles on the tree
396
+ // when the window has nodes, so an act on it answers once the tree is still, never at the settle cap.
397
+ const seen = await start(t);
398
+ ran(t, (await act(t, { steps: [{ press: byId(t, seen, "name").ref }] })).steps[0], "press Name, which takes the focus");
399
+ for (const round of [1, 2, 3]) {
400
+ const began = Date.now();
401
+ const still = await act(t, { steps: [], expect: { text: "UI fixture" } });
402
+ const took = Date.now() - began;
403
+ t.equal(still.expect, "met", `act ${round} of no steps, its expect for the heading UI fixture`);
404
+ t.assert(took < MAX_SETTLE_MS * 0.8, `act ${round} of no steps on a window whose tree is still took ${took} ms, near the ${MAX_SETTLE_MS} ms settle cap: settle on the window's nodes, and on its image only when it has none (a blinking caret never settles)`);
405
+ }
406
+ },
407
+ },
408
+ {
409
+ id: "ui.set-holds",
410
+ level: "full",
411
+ group: "ui",
412
+ needs: ["ui", "apps"],
413
+ async run(t) {
414
+ // The Code field takes back any value set into it TAKES_BACK_MS later: the set ran, and did not hold.
415
+ const seen = await start(t);
416
+ const code = optional(t, seen, "code", "Code, a field that takes back what is set into it");
417
+ const taken = ran(t, (await act(t, { steps: [{ set: code.ref, value: "1234" }] })).steps[0], "set Code to 1234");
418
+ t.equal(taken.verified, false, `set Code, which takes its value back ${TAKES_BACK_MS} ms later: a set is verified only when its value still holds ${SET_HOLD_MS} ms after the settle`);
419
+ t.equal(byId(t, await look(t), "code").value ?? "", "", "Code's value, taken back");
420
+ },
421
+ },
422
+ {
423
+ id: "ui.expect-window",
424
+ level: "full",
425
+ group: "ui",
426
+ needs: ["ui", "apps"],
427
+ async run(t) {
428
+ const seen = await start(t);
429
+ // Unmet: no window of that title comes, and the act answers unmet after its timeout, never not_found.
430
+ const none = await act(t, { steps: [], expect: { window: { title: "No such window" }, timeoutMs: 300 } });
431
+ t.equal(none.expect, "unmet", "expect a window titled No such window, which never opens");
432
+ const opened = await openAnother(t, seen);
433
+ const front = await look(t);
434
+ t.equal(front.window.title, "Another window", "the window in front after New window");
435
+ await stateOf(t, opened.state, front.window.id, "a met window expect answers that window's state");
436
+ // The wait reads the app's main window, whichever it is now: the older home window, which the act is aimed at
437
+ // and whose title matches, does not meet it while Another window is in front.
438
+ const behind = await act(t, { steps: [], expect: { window: { title: "UI fixture" }, timeoutMs: 300 } }, seen.window.id);
439
+ t.equal(behind.expect, "unmet", "expect window \"UI fixture\", aimed at the home window while Another window is in front: the app's main window is Another window");
440
+ },
441
+ },
442
+ {
443
+ id: "ui.window-closed",
444
+ level: "full",
445
+ group: "ui",
446
+ needs: ["ui", "apps"],
447
+ async run(t) {
448
+ // Close on the fixture's only window: the app runs on with none, and the act says so with no state.
449
+ const seen = await start(t);
450
+ optional(t, seen, "open", "New window: a fixture that closes its window opens one too");
451
+ const closed = await act(t, { steps: [{ press: byId(t, seen, "close").ref }] });
452
+ ran(t, closed.steps[0], "press Close on the app's only window");
453
+ t.equal(closed.window, "closed", "ui.act's window after a step closed the app's last one");
454
+ t.equal(closed.state, undefined, "ui.act's state when the app has no window left");
455
+ t.equal(closed.changed, true, "ui.act's changed when the window closed");
456
+ },
457
+ },
458
+ {
459
+ id: "ui.window-follow",
460
+ level: "full",
461
+ group: "ui",
462
+ needs: ["ui", "apps"],
463
+ async run(t) {
464
+ // Close on a second window: the act follows the app's next main window, as after a nav, and answers its state.
465
+ const seen = await start(t);
466
+ const home = seen.window.id;
467
+ await openAnother(t, seen);
468
+ const another = await look(t);
469
+ const closed = await act(t, { steps: [{ press: byId(t, another, "close").ref }] }, another.window.id);
470
+ ran(t, closed.steps[0], "press Close on the second window");
471
+ t.equal(closed.window, undefined, `ui.act's window after a step closed one window of two: ${show(closed.window)}`);
472
+ await stateOf(t, closed.state, home, "an act whose window closed follows the app's next main window");
473
+ },
474
+ },
475
+ ];
@@ -26,4 +26,13 @@ export interface CliIo {
26
26
  env?: ProviderEnv;
27
27
  } & Record<string, unknown>;
28
28
  }
29
+ /**
30
+ * A fresh planted value for each secret name, and the text to hunt for in answers. A `*_SSH_KEY` name takes a throwaway
31
+ * ed25519 private key (a provider refuses a non-PEM key at build) and its base64 body line is the secret: the armor is
32
+ * public text that the provider's own errors quote. Every other name takes a random string that is its own secret.
33
+ */
34
+ export declare function plantSecrets(names: readonly string[]): {
35
+ values: string[];
36
+ secrets: string[];
37
+ };
29
38
  export declare function main(argv: string[], io?: CliIo): Promise<number>;
@@ -3,7 +3,7 @@
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
- import { randomBytes } from "node:crypto";
6
+ import { generateKeyPairSync, randomBytes } from "node:crypto";
7
7
  import { resolve } from "node:path";
8
8
  import { pathToFileURL } from "node:url";
9
9
  import { isCommand } from "../entry.js";
@@ -154,6 +154,31 @@ async function moduleFor(name, cwd) {
154
154
  }
155
155
  /** A name of a module's ENV that holds a secret: an API key, a token, a token's secret. */
156
156
  const SECRET_NAME = /(^|_)(KEY|TOKEN|SECRET)(_|$)/;
157
+ /**
158
+ * A fresh planted value for each secret name, and the text to hunt for in answers. A `*_SSH_KEY` name takes a throwaway
159
+ * ed25519 private key (a provider refuses a non-PEM key at build) and its base64 body line is the secret: the armor is
160
+ * public text that the provider's own errors quote. Every other name takes a random string that is its own secret.
161
+ */
162
+ export function plantSecrets(names) {
163
+ const values = [];
164
+ const secrets = [];
165
+ for (const name of names) {
166
+ if (name.endsWith("_SSH_KEY")) {
167
+ const { privateKey } = generateKeyPairSync("ed25519", {
168
+ privateKeyEncoding: { type: "pkcs8", format: "pem" },
169
+ publicKeyEncoding: { type: "spki", format: "pem" },
170
+ });
171
+ values.push(privateKey);
172
+ secrets.push(privateKey.split("\n").filter((line) => line !== "" && !line.startsWith("-----")).join(""));
173
+ }
174
+ else {
175
+ const value = `agentrun-planted-${randomBytes(12).toString("hex")}`;
176
+ values.push(value);
177
+ secrets.push(value);
178
+ }
179
+ }
180
+ return { values, secrets };
181
+ }
157
182
  /**
158
183
  * The provider a conformance module makes, its drifted twin and its run folders (mountFor) when it offers them, and what
159
184
  * it says of its run: conformanceImage(), the image when --image names none, and conformanceNotes, strings for the report.
@@ -177,9 +202,9 @@ async function load(label, module, options, declared) {
177
202
  const secretNames = Object.values(module.ENV ?? {}).filter((name) => typeof name === "string" && SECRET_NAME.test(name));
178
203
  if (secretNames.length > 0) {
179
204
  target.planted = async () => {
180
- const secrets = secretNames.map(() => `agentrun-planted-${randomBytes(12).toString("hex")}`);
205
+ const { values, secrets } = plantSecrets(secretNames);
181
206
  const given = options.env ?? process.env;
182
- const env = { ...given, ...Object.fromEntries(secretNames.map((name, i) => [name, secrets[i]])) };
207
+ const env = { ...given, ...Object.fromEntries(secretNames.map((name, i) => [name, values[i]])) };
183
208
  return { provider: (await createProvider({ ...options, env })), secrets };
184
209
  };
185
210
  }
@@ -31,6 +31,8 @@ export declare const DAYTONA_ENV: {
31
31
  readonly user: "COMPUTER_DAYTONA_USER";
32
32
  /** The snapshot every computer of the run starts from; default "default", Daytona's default snapshot. */
33
33
  readonly snapshot: "COMPUTER_DAYTONA_SNAPSHOT";
34
+ /** gpuSnapshot: the GPU snapshot of box/Dockerfile GPU computers are made from (box/build-daytona.py --gpu); default daytona-gpu. */
35
+ readonly gpuSnapshot: "COMPUTER_DAYTONA_GPU_SNAPSHOT";
34
36
  };
35
37
  /** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
36
38
  export declare const ENV: {
@@ -50,6 +52,8 @@ export declare const ENV: {
50
52
  readonly user: "COMPUTER_DAYTONA_USER";
51
53
  /** The snapshot every computer of the run starts from; default "default", Daytona's default snapshot. */
52
54
  readonly snapshot: "COMPUTER_DAYTONA_SNAPSHOT";
55
+ /** gpuSnapshot: the GPU snapshot of box/Dockerfile GPU computers are made from (box/build-daytona.py --gpu); default daytona-gpu. */
56
+ readonly gpuSnapshot: "COMPUTER_DAYTONA_GPU_SNAPSHOT";
53
57
  };
54
58
  /**
55
59
  * The provider's options this module reads from env, each only when its name is set; throws in words without the key,
@@ -39,6 +39,8 @@ export const DAYTONA_ENV = {
39
39
  user: "COMPUTER_DAYTONA_USER",
40
40
  /** The snapshot every computer of the run starts from; default "default", Daytona's default snapshot. */
41
41
  snapshot: "COMPUTER_DAYTONA_SNAPSHOT",
42
+ /** gpuSnapshot: the GPU snapshot of box/Dockerfile GPU computers are made from (box/build-daytona.py --gpu); default daytona-gpu. */
43
+ gpuSnapshot: "COMPUTER_DAYTONA_GPU_SNAPSHOT",
42
44
  };
43
45
  /** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
44
46
  export const ENV = DAYTONA_ENV;
@@ -57,6 +59,7 @@ export function settingsFromEnv(env = process.env) {
57
59
  const arch = named(DAYTONA_ENV.arch);
58
60
  const sandboxClass = named(DAYTONA_ENV.sandboxClass);
59
61
  const user = named(DAYTONA_ENV.user);
62
+ const gpuSnapshot = named(DAYTONA_ENV.gpuSnapshot);
60
63
  return {
61
64
  apiKey,
62
65
  ...(url ? { apiUrl: url.value } : {}),
@@ -66,6 +69,8 @@ export function settingsFromEnv(env = process.env) {
66
69
  // create() refuses any other class in words.
67
70
  ...(sandboxClass ? { sandboxClass: sandboxClass.value } : {}),
68
71
  ...(user ? { daemonUser: user.value } : {}),
72
+ // create() refuses a name that is not one of ours in words.
73
+ ...(gpuSnapshot ? { gpuSnapshot: gpuSnapshot.value } : {}),
69
74
  };
70
75
  }
71
76
  /** Minutes without outside activity before Daytona stops a run's sandbox: at most 30, so none outlives a run for long. */
@@ -1,4 +1,5 @@
1
1
  import { type E2BOptions, type E2BProvider } from "../e2b.js";
2
+ import type { MachineHost } from "../host.js";
2
3
  import type { MountKind } from "../mount.js";
3
4
  import { type ArchilRunFolderOptions } from "./archil.js";
4
5
  import type { RunFolder } from "./types.js";
@@ -70,5 +71,10 @@ export declare function createProvider({ env, Sandbox, daemonPath, timeouts, onN
70
71
  * Reaching it is a call to Archil, so it needs the live switch.
71
72
  */
72
73
  export declare function mountFor(kind: MountKind, { env, archil }?: E2BModuleOptions): Promise<RunFolder | undefined>;
74
+ /**
75
+ * The E2B host the live sweep (sweep.ts) lists and deletes through, from the same settings; it needs no live switch,
76
+ * since the sweep makes nothing, and it calls nothing until the sweep does.
77
+ */
78
+ export declare function createHost({ env, Sandbox }?: Pick<E2BModuleOptions, "env" | "Sandbox">): Promise<MachineHost>;
73
79
  /** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
74
80
  export declare function createDriftedProvider({ env, Sandbox, timeouts, buildDaemon }?: E2BModuleOptions): Promise<E2BProvider>;
@@ -3,8 +3,8 @@
3
3
  // COMPUTER_E2B_API_KEY. The provider reads no environment: this module reads its own COMPUTER_E2B_* names (never
4
4
  // E2B_API_KEY, which may hold another team's key) and passes each to create() as its option; the provider gives the SDK
5
5
  // the key, domain and API URL explicitly, and refuses an ambient E2B_SANDBOX_URL (see create in ../e2b.ts). The live
6
- // switch is checked first, before any other setting is read. The sweep and the network diagnostic (e2b-sweep.ts,
7
- // e2b-diagnose.ts) read the same names through settingsFromEnv.
6
+ // switch is checked first, before any other setting is read. The live sweep (sweep.ts, --provider e2b) reads the same
7
+ // names through createHost, which needs no live switch: it makes nothing.
8
8
  //
9
9
  // The daemon is uploaded into each sandbox (dist/computerd-linux-amd64, `npm run build:daemon`), so a run publishes
10
10
  // nothing. The drifted provider uploads a daemon built with Go as version <version>-drift. Every computer of a run lives
@@ -103,6 +103,13 @@ export async function mountFor(kind, { env = process.env, archil = {} } = {}) {
103
103
  live(env);
104
104
  return archilRunFolder({ ...settings, ...archil });
105
105
  }
106
+ /**
107
+ * The E2B host the live sweep (sweep.ts) lists and deletes through, from the same settings; it needs no live switch,
108
+ * since the sweep makes nothing, and it calls nothing until the sweep does.
109
+ */
110
+ export async function createHost({ env = process.env, Sandbox } = {}) {
111
+ return (await create({ ...settingsFromEnv(env), ...(Sandbox ? { Sandbox } : {}) })).host;
112
+ }
106
113
  /** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
107
114
  export async function createDriftedProvider({ env = process.env, Sandbox, timeouts, buildDaemon = (version) => buildDriftDaemon("amd64", version) } = {}) {
108
115
  live(env);
@@ -6,7 +6,7 @@ export declare const FIXTURE_WINDOW: Rect;
6
6
  export declare const FIXTURE_COLORS: ReadonlyArray<readonly [number, number, number]>;
7
7
  /** The fixture APK's application id. */
8
8
  export declare const FIXTURE_APP_ID = "ai.agentrun.fixture";
9
- /** The APK's button, found in apps.ui_tree by its id. */
9
+ /** The APK's button, found in ui.observe by its id, its name the button's text. */
10
10
  export declare const FIXTURE_BUTTON: {
11
11
  readonly id: "ai.agentrun.fixture:id/button";
12
12
  readonly text: "agentrun fixture";