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

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 (99) hide show
  1. package/README.md +144 -26
  2. package/dist/browser.d.ts +12 -13
  3. package/dist/browser.js +16 -14
  4. package/dist/browserbase.d.ts +3 -5
  5. package/dist/browserbase.js +16 -13
  6. package/dist/chrome.js +1 -1
  7. package/dist/computerd-linux-amd64 +0 -0
  8. package/dist/computerd-linux-arm64 +0 -0
  9. package/dist/conformance/browserbase.js +1 -1
  10. package/dist/conformance/cases/provider.js +78 -3
  11. package/dist/conformance/daytona.js +2 -1
  12. package/dist/conformance/e2b.js +2 -1
  13. package/dist/conformance/fixture.js +24 -2
  14. package/dist/conformance/kernel.js +1 -1
  15. package/dist/conformance/kind.js +2 -1
  16. package/dist/conformance/{local.d.ts → local-chrome.d.ts} +7 -7
  17. package/dist/conformance/{local.js → local-chrome.js} +11 -11
  18. package/dist/conformance/orgo.d.ts +11 -5
  19. package/dist/conformance/orgo.js +37 -8
  20. package/dist/conformance/phone-harness.js +2 -1
  21. package/dist/conformance/report.js +3 -2
  22. package/dist/conformance/runner.js +25 -7
  23. package/dist/conformance/types.d.ts +21 -8
  24. package/dist/conformance/types.js +10 -0
  25. package/dist/conformance/windows-fixture.d.ts +1 -0
  26. package/dist/conformance/windows-fixture.js +37 -0
  27. package/dist/daytona.d.ts +3 -34
  28. package/dist/daytona.js +34 -61
  29. package/dist/descriptor.d.ts +94 -0
  30. package/dist/descriptor.js +81 -0
  31. package/dist/descriptors/browserbase.d.ts +24 -0
  32. package/dist/descriptors/browserbase.js +18 -0
  33. package/dist/descriptors/daytona.d.ts +62 -0
  34. package/dist/descriptors/daytona.js +49 -0
  35. package/dist/descriptors/docker.d.ts +12 -0
  36. package/dist/descriptors/docker.js +17 -0
  37. package/dist/descriptors/e2b.d.ts +22 -0
  38. package/dist/descriptors/e2b.js +19 -0
  39. package/dist/descriptors/index.d.ts +229 -0
  40. package/dist/descriptors/index.js +19 -0
  41. package/dist/descriptors/kernel.d.ts +20 -0
  42. package/dist/descriptors/kernel.js +15 -0
  43. package/dist/descriptors/local-chrome.d.ts +17 -0
  44. package/dist/descriptors/local-chrome.js +21 -0
  45. package/dist/descriptors/modal.d.ts +50 -0
  46. package/dist/descriptors/modal.js +38 -0
  47. package/dist/descriptors/orgo.d.ts +88 -0
  48. package/dist/descriptors/orgo.js +44 -0
  49. package/dist/descriptors/phone-harness.d.ts +28 -0
  50. package/dist/descriptors/phone-harness.js +20 -0
  51. package/dist/descriptors/shared.d.ts +7 -0
  52. package/dist/descriptors/shared.js +6 -0
  53. package/dist/desktop.d.ts +4 -4
  54. package/dist/desktop.js +4 -4
  55. package/dist/docker/egress.d.ts +1 -1
  56. package/dist/docker/image.js +17 -15
  57. package/dist/docker/inspect.d.ts +147 -0
  58. package/dist/docker/inspect.js +335 -0
  59. package/dist/docker.d.ts +6 -6
  60. package/dist/docker.js +46 -42
  61. package/dist/drift.d.ts +3 -145
  62. package/dist/drift.js +5 -334
  63. package/dist/e2b.d.ts +2 -8
  64. package/dist/e2b.js +16 -22
  65. package/dist/index.d.ts +8 -11
  66. package/dist/index.js +13 -11
  67. package/dist/isolation.js +2 -2
  68. package/dist/janitor.d.ts +18 -1
  69. package/dist/janitor.js +67 -19
  70. package/dist/kernel.d.ts +3 -5
  71. package/dist/kernel.js +19 -16
  72. package/dist/kinds.d.ts +54 -34
  73. package/dist/kinds.js +19 -117
  74. package/dist/labels.d.ts +12 -0
  75. package/dist/labels.js +39 -1
  76. package/dist/{local.d.ts → local-chrome.d.ts} +5 -8
  77. package/dist/{local.js → local-chrome.js} +19 -16
  78. package/dist/local-supervisor.d.ts +3 -3
  79. package/dist/local-supervisor.js +3 -3
  80. package/dist/modal.d.ts +3 -22
  81. package/dist/modal.js +15 -31
  82. package/dist/mount-archil.js +4 -4
  83. package/dist/orgo-channel.js +16 -13
  84. package/dist/orgo-desktop.d.ts +153 -0
  85. package/dist/orgo-desktop.js +1614 -0
  86. package/dist/orgo-names.d.ts +52 -0
  87. package/dist/orgo-names.js +84 -0
  88. package/dist/orgo.d.ts +18 -15
  89. package/dist/orgo.js +46 -107
  90. package/dist/phone-harness.d.ts +4 -10
  91. package/dist/phone-harness.js +45 -46
  92. package/dist/provider.d.ts +91 -10
  93. package/dist/provider.js +42 -0
  94. package/dist/providers.d.ts +23 -24
  95. package/dist/providers.js +14 -17
  96. package/dist/result.d.ts +11 -1
  97. package/dist/result.js +11 -0
  98. package/dist/test-connection.js +2 -2
  99. package/package.json +42 -2
@@ -4,8 +4,9 @@
4
4
  // the janitor ends only the expired, stopped or running, and a takeover releases the run's lower epochs by label (Full).
5
5
  import { randomBytes } from "node:crypto";
6
6
  import { releaseOlder, sweep } from "../../janitor.js";
7
- import { EPOCH_LABEL, RUN_LABEL, runLabels } from "../../labels.js";
8
- import { CASE_LABEL } from "./util.js";
7
+ import { EPOCH_LABEL, OWNER_LABEL, RUN_LABEL, runLabels } from "../../labels.js";
8
+ import { runLifetimeMs } from "../../provider.js";
9
+ import { b64, CASE_LABEL, decode } from "./util.js";
9
10
  /** Labels for one case's computers: the run's, and the case's own. */
10
11
  const own = (t, name) => ({ ...t.runLabels, [CASE_LABEL]: name });
11
12
  const names = async (t, labels) => t
@@ -186,7 +187,8 @@ export const providerCases = [
186
187
  t.equal(info.state, "running", "its state");
187
188
  t.deepEqual(info.network, spec.network, "its network, read back");
188
189
  const deadline = info.deadline instanceof Date ? info.deadline.getTime() : Number.NaN;
189
- t.assert(deadline >= before + spec.lifetimeMs - 1000 && deadline <= after + spec.lifetimeMs + 1000, `its deadline, ${String(info.deadline)}, is lifetimeMs after create`);
190
+ const lifetimeMs = runLifetimeMs(spec);
191
+ t.assert(deadline >= before + lifetimeMs - 1000 && deadline <= after + lifetimeMs + 1000, `its deadline, ${String(info.deadline)}, is lifetimeMs after create`);
190
192
  t.deepEqual(await names(t, { ...labels, role: "other" }), [], "list by a label no computer has");
191
193
  }),
192
194
  // Stop is declared or refused: a provider that declares it lists the computer stopped; one that does not refuses it
@@ -219,6 +221,79 @@ export const providerCases = [
219
221
  t.ok(await t.provider.release(ref, "delete"), "release delete of a stopped computer");
220
222
  t.deepEqual(await names(t, labels), [], "listed after delete");
221
223
  }),
224
+ // An agent's computer needs persistence. A provider that declares none refuses spec.owner in check() and create, in
225
+ // words; one that declares it takes an owner with no lifetime, and refuses an owner with one: an agent's computer has
226
+ // no run deadline.
227
+ provider("owner", async (t) => {
228
+ const labels = own(t, "owner");
229
+ const owner = { agent: `conformance-${randomBytes(6).toString("hex")}` };
230
+ const { lifetimeMs: _, ...base } = t.spec({ labels });
231
+ const owned = { ...base, owner };
232
+ if (t.provider.capabilities().persistence === undefined) {
233
+ const refusals = t.provider.check(owned);
234
+ t.assert(refusals.some((r) => r.field === "owner" && r.message !== ""), `check of a spec with an owner, on a provider with no persistence, refuses owner in words: ${JSON.stringify(refusals)}`);
235
+ await refusedCreate(t, owned, "create of a spec with an owner, on a provider with no persistence");
236
+ return;
237
+ }
238
+ t.deepEqual(t.provider.check(owned), [], "check of an agent's spec with no lifetime");
239
+ const timed = t.provider.check(t.spec({ labels, owner }));
240
+ t.assert(timed.some((r) => r.field === "lifetimeMs" && r.message !== ""), `check of an agent's spec with a lifetime refuses lifetimeMs in words: ${JSON.stringify(timed)}`);
241
+ }),
242
+ // Detach is an agent's computer's alone: a run's computer refuses it in words and runs on, listed running, never
243
+ // stopped or deleted behind the caller's back.
244
+ provider("detach", async (t) => {
245
+ const labels = own(t, "detach");
246
+ const ref = await t.create({ labels });
247
+ const words = "release detach of a run's computer";
248
+ const error = t.refused(await t.provider.release(ref, "detach"), words);
249
+ t.assert(error.message !== "", `${words}: the refusal is in words`);
250
+ t.deepEqual(t.ok(await t.provider.list(labels), "list").map((info) => [info.ref.name, info.state]), [[ref.name, "running"]], `${words}: the computer is still listed, running`);
251
+ }),
252
+ // An agent's computer across two claims (Full, where persistence is declared): made with an owner and no lifetime, a
253
+ // file written in it, detached (listed stopped, with when), attached by id under a new claim, the file read back (with
254
+ // resume, the process it ran still running), a claim below that epoch refused as fenced, then deleted.
255
+ provider("persistence", async (t) => {
256
+ const nonce = randomBytes(6).toString("hex");
257
+ const run = `conformance-${nonce}`;
258
+ const labels = own(t, "persistence");
259
+ const owner = { agent: `conformance-${nonce}` };
260
+ const { lifetimeMs: _, ...base } = t.spec({ labels: { ...labels, ...runLabels(run, 1) } });
261
+ const made = await t.attempt({ ...base, owner });
262
+ const ref = refOf(t.ok(made, "create of an agent's computer"));
263
+ const listed = async (what) => t.present(t.ok(await t.provider.list(labels), `list ${what}`).find((info) => info.ref.name === ref.name), `the agent's computer, listed ${what}`);
264
+ const first = await listed("after create");
265
+ t.deepEqual([first.labels[OWNER_LABEL], first.state], [`agent:${owner.agent}`, "running"], "after create: its owner label and state");
266
+ const before = await t.connect(ref);
267
+ const home = /^HOME=(.*)$/m.exec((await t.exec(["env"], {}, before.client)).out)?.[1]?.replace(/\/+$/, "");
268
+ const path = `${t.present(home, "HOME in the agent's computer")}/agentrun-conformance-persist-${nonce}`;
269
+ t.ok(await before.client.call("files.write", { path, data: b64(nonce) }), "files.write before the detach");
270
+ const { resume } = t.present(t.provider.capabilities().persistence, "capabilities().persistence");
271
+ const resumes = resume && t.provider.capabilities().groups.includes("processes");
272
+ const started = resumes ? t.ok(await before.client.call("process.start", { argv: ["sleep", "600"] }), "process.start before the detach") : undefined;
273
+ await before.close();
274
+ t.ok(await t.provider.release(ref, "detach"), "release detach");
275
+ const detached = await listed("after detach");
276
+ t.equal(detached.state, "stopped", "after detach: its state");
277
+ t.assert(detached.detachedAt instanceof Date && !Number.isNaN(detached.detachedAt.getTime()), `after detach: detachedAt is when, not ${String(detached.detachedAt)}`);
278
+ t.equal(detached.labels[OWNER_LABEL], `agent:${owner.agent}`, "after detach: still the agent's");
279
+ const attached = t.ok(await t.provider.attach({ id: ref.id }, { claim: { run, epoch: 2 }, signal: t.signal }), "attach by id under the claim at epoch 2");
280
+ t.deepEqual(refOf(attached), ref, "attach under a new claim: the same computer");
281
+ const back = await listed("after attach");
282
+ t.deepEqual([back.state, back.labels[RUN_LABEL], back.labels[EPOCH_LABEL], back.detachedAt], ["running", run, "2", undefined], "after attach: its state, the claim's labels, and no detachedAt");
283
+ const after = await t.connect(ref);
284
+ const read = t.ok(await after.client.call("files.read", { path }), "files.read after the attach");
285
+ t.equal(decode(read.data), nonce, "the file written before the detach, read after the attach");
286
+ if (started !== undefined) {
287
+ const waited = t.ok(await after.client.call("process.wait", { id: started.id, timeoutMs: 0 }), "process.wait after the attach");
288
+ t.equal(waited.running, true, "with resume: the process started before the detach, still running");
289
+ }
290
+ await after.close();
291
+ const fenced = t.refused(await t.provider.attach({ id: ref.id }, { claim: { run, epoch: 1 }, signal: t.signal }), "attach under the claim at epoch 1, below 2", ["refused"]);
292
+ t.assert(fenced.message !== "", "a fenced claim: the refusal is in words");
293
+ t.equal((await listed("after the fenced claim")).labels[EPOCH_LABEL], "2", "after the fenced claim: its epoch");
294
+ t.ok(await t.provider.release(ref, "delete"), "release delete of the agent's computer");
295
+ t.deepEqual(await names(t, labels), [], "listed after delete");
296
+ }, { level: "full", needs: ["persistence", "files"] }),
222
297
  provider("network-change", async (t) => {
223
298
  const spec = t.spec({ labels: own(t, "network") });
224
299
  const ref = await t.create(spec);
@@ -4,7 +4,8 @@
4
4
  // read only when createProvider() runs. Every sandbox of a run has a bounded life besides its TTL: Daytona stops one
5
5
  // after 30 minutes with no outside activity and deletes it as soon as it stops, so a stop deletes, and the provider
6
6
  // declares it (stopDeletes; see conformanceNotes).
7
- import { create, DAYTONA_DEFAULT_SNAPSHOT } from "../daytona.js";
7
+ import { create } from "../daytona.js";
8
+ import { DAYTONA_DEFAULT_SNAPSHOT } from "../descriptors/daytona.js";
8
9
  import { archilRunFolder, archilSettings } from "./archil.js";
9
10
  import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
10
11
  /** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
@@ -15,7 +15,8 @@
15
15
  // disk's object API (the shared archilRunFolder, ./archil.ts: the host's disk SDK with COMPUTER_ARCHIL_API_KEY and
16
16
  // COMPUTER_ARCHIL_S3_URL, or an object API given as archil.objects); with no disk named it makes none, and the cases
17
17
  // are skipped. An Archil computer needs a provider whose daemon user is the tool user: COMPUTER_E2B_USER=2510:2510.
18
- import { create, E2B_BASE_TEMPLATE, E2B_DESKTOP_TEMPLATE } from "../e2b.js";
18
+ import { E2B_BASE_TEMPLATE, E2B_DESKTOP_TEMPLATE } from "../descriptors/e2b.js";
19
+ import { create } from "../e2b.js";
19
20
  import { archilRunFolder, archilSettings } from "./archil.js";
20
21
  import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
21
22
  /** The Archil disk's settings for the mount cases, by name (COMPUTER_ARCHIL_*: all five, or none). */
@@ -2,9 +2,11 @@
2
2
  // every input event it gets as one JSON line in a file the case reads over files. On a desktop it is computerd-fixture,
3
3
  // a test-only static binary: a 200x200 override-redirect window at (0, 0) in four known colors, which grabs focus. On
4
4
  // Android it is a small APK that logs touches and its own launch to its files directory and shows a button with a fixed
5
- // id. This file is their contract: the binary and the APK come with the PRs that first run them.
5
+ // id. This file is their contract: the binary and the APK come with the PRs that first run them. On a Windows desktop it
6
+ // is a PowerShell script this package carries (windows-fixture.ts), the same window, started detached with Start-Process.
6
7
  import { readFileSync } from "node:fs";
7
8
  import { readFile, writeFile } from "../files.js";
9
+ import { WINDOWS_FIXTURE } from "./windows-fixture.js";
8
10
  /** The desktop fixture's window, in screenshot pixels. */
9
11
  export const FIXTURE_WINDOW = [0, 0, 200, 200];
10
12
  /** The window's quadrants in RGB: top left, top right, bottom left, bottom right. */
@@ -59,7 +61,27 @@ async function ready(t, events, what) {
59
61
  * the fixture's stop as soon as it is launched, before it logs ready, so a fixture that never does is stopped too.
60
62
  */
61
63
  export async function startFixture(t, path, launched) {
62
- const { kind } = t.provider.capabilities();
64
+ const { kind, os } = t.provider.capabilities();
65
+ if (kind === "desktop" && os === "windows") {
66
+ // No processes on a Windows desktop Orgo's API answers: the script is started detached with Start-Process (its
67
+ // file and its log as one argument list) and stopped by the pid its ready line logs.
68
+ needs(t, ["exec", "files"], "the Windows desktop fixture");
69
+ const dir = await t.dir();
70
+ const script = `${dir}\\agentrun-fixture.ps1`;
71
+ const log = `${dir}\\events.jsonl`;
72
+ t.ok(await writeFile(t.client, script, Buffer.from(WINDOWS_FIXTURE, "utf8"), { signal: t.signal }), `files.write of the fixture to ${script}`);
73
+ const started = await t.exec(["Start-Process", "powershell.exe", `-NoProfile -ExecutionPolicy Bypass -STA -WindowStyle Hidden -File "${script}" "${log}"`]);
74
+ t.equal(started.exitCode, 0, `Start-Process of the fixture (stderr ${JSON.stringify(started.err.trim())})`);
75
+ const events = () => logOf(t, log);
76
+ const stop = async () => {
77
+ const ready = (await events().catch(() => [])).find((e) => e.event === "ready");
78
+ if (Number.isSafeInteger(ready?.pid))
79
+ await t.client.call("exec.run", { argv: ["taskkill.exe", "/PID", String(ready?.pid), "/F"], timeoutMs: 30_000 });
80
+ };
81
+ launched(stop);
82
+ await ready(t, events, "the Windows desktop fixture");
83
+ return { bounds: FIXTURE_WINDOW, events, stop };
84
+ }
63
85
  if (kind === "desktop") {
64
86
  needs(t, ["exec", "files", "processes"], "the desktop fixture");
65
87
  const dir = await t.dir();
@@ -3,7 +3,7 @@
3
3
  // COMPUTER_KERNEL_API_KEY. The provider reads no environment: this module reads its own COMPUTER_KERNEL_* names (never
4
4
  // KERNEL_API_KEY, which may hold another organization's key) and passes each to create() as its option. The live switch
5
5
  // is checked first, before any other setting is read. The run makes one browser, shared by every case, and deletes it.
6
- import { BROWSER_IMAGE } from "../browser.js";
6
+ import { BROWSER_IMAGE } from "../descriptors/shared.js";
7
7
  import { create } from "../kernel.js";
8
8
  /** The environment this module reads, by name, each for the option its comment names, and the live switch. */
9
9
  export const KERNEL_ENV = {
@@ -45,7 +45,8 @@ export function kindVerdict(kind, capabilities, report, cases = suiteOf(kind)) {
45
45
  for (const group of SETTING_KINDS[kind].required) {
46
46
  const ofGroup = report.results.filter((result) => byId.get(result.id)?.needs.includes(group));
47
47
  for (const result of ofGroup) {
48
- if (result.status === "skip" && result.undeclared === undefined && byId.get(result.id)?.level === "core")
48
+ // A case written for another system is not this computer's: its skip is no reason the kind fails.
49
+ if (result.status === "skip" && result.undeclared === undefined && result.os === undefined && byId.get(result.id)?.level === "core")
49
50
  reasons.push(`${result.id} was skipped: ${result.reason ?? "no reason given"}`);
50
51
  }
51
52
  if (!ofGroup.some((result) => result.status === "pass"))
@@ -1,19 +1,19 @@
1
- import { type LocalBrowserOptions, type LocalBrowserProvider } from "../local.js";
1
+ import { type LocalBrowserOptions, type LocalBrowserProvider } from "../local-chrome.js";
2
2
  /** The environment this module reads, by name, each for the option its comment names, and the live switch. */
3
3
  export declare const LOCAL_ENV: {
4
- readonly live: "AGENTRUN_COMPUTER_LIVE_LOCAL";
4
+ readonly live: "AGENTRUN_COMPUTER_LIVE_LOCAL_CHROME";
5
5
  /** executablePath: the Chrome or Chromium to run; default the first on PATH, then the usual install places. */
6
- readonly chrome: "COMPUTER_LOCAL_CHROME";
6
+ readonly chrome: "COMPUTER_LOCAL_CHROME_PATH";
7
7
  /** headed: "1" shows the window. */
8
- readonly headed: "COMPUTER_LOCAL_HEADED";
8
+ readonly headed: "COMPUTER_LOCAL_CHROME_HEADED";
9
9
  };
10
10
  /** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
11
11
  export declare const ENV: {
12
- readonly live: "AGENTRUN_COMPUTER_LIVE_LOCAL";
12
+ readonly live: "AGENTRUN_COMPUTER_LIVE_LOCAL_CHROME";
13
13
  /** executablePath: the Chrome or Chromium to run; default the first on PATH, then the usual install places. */
14
- readonly chrome: "COMPUTER_LOCAL_CHROME";
14
+ readonly chrome: "COMPUTER_LOCAL_CHROME_PATH";
15
15
  /** headed: "1" shows the window. */
16
- readonly headed: "COMPUTER_LOCAL_HEADED";
16
+ readonly headed: "COMPUTER_LOCAL_CHROME_HEADED";
17
17
  };
18
18
  export type LocalSettings = Pick<LocalBrowserOptions, "executablePath" | "headed" | "env">;
19
19
  /** The provider's options this module reads from env, each only when its name is set; PATH goes in as the provider's env, to find a Chrome on it. */
@@ -1,16 +1,16 @@
1
- // The local browser for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider local`. It
2
- // starts a real Chrome on this machine (nothing billed, no key), so it runs only with AGENTRUN_COMPUTER_LIVE_LOCAL=1. The
3
- // provider reads no environment: this module reads its own COMPUTER_LOCAL_* names, and PATH to find a Chrome, and passes
4
- // each to create() as its option.
5
- import { BROWSER_IMAGE } from "../browser.js";
6
- import { create } from "../local.js";
1
+ // Local Chrome for the conformance CLI: `npm run conformance -w @parcha/agentrun-computer -- --provider local-chrome`.
2
+ // It starts a real Chrome on this machine (nothing billed, no key), so it runs only with
3
+ // AGENTRUN_COMPUTER_LIVE_LOCAL_CHROME=1. The provider reads no environment: this module reads its own
4
+ // COMPUTER_LOCAL_CHROME_* names, and PATH to find a Chrome, and passes each to create() as its option.
5
+ import { BROWSER_IMAGE } from "../descriptors/shared.js";
6
+ import { create } from "../local-chrome.js";
7
7
  /** The environment this module reads, by name, each for the option its comment names, and the live switch. */
8
8
  export const LOCAL_ENV = {
9
- live: "AGENTRUN_COMPUTER_LIVE_LOCAL",
9
+ live: "AGENTRUN_COMPUTER_LIVE_LOCAL_CHROME",
10
10
  /** executablePath: the Chrome or Chromium to run; default the first on PATH, then the usual install places. */
11
- chrome: "COMPUTER_LOCAL_CHROME",
11
+ chrome: "COMPUTER_LOCAL_CHROME_PATH",
12
12
  /** headed: "1" shows the window. */
13
- headed: "COMPUTER_LOCAL_HEADED",
13
+ headed: "COMPUTER_LOCAL_CHROME_HEADED",
14
14
  };
15
15
  /** The names this module reads, under the conformance modules' common name (ConformanceModule.ENV). */
16
16
  export const ENV = LOCAL_ENV;
@@ -22,7 +22,7 @@ export function settingsFromEnv(env = process.env) {
22
22
  }
23
23
  /** For the run's report: what this configuration means for the suite. */
24
24
  export const conformanceNotes = [
25
- "local: this machine's Chrome, one browser for the whole run, deleted by its last case and again at the run's end. Its supervisor ends it at its deadline, which list reads.",
25
+ "local-chrome: this machine's Chrome, one browser for the whole run, deleted by its last case and again at the run's end. Its supervisor ends it at its deadline, which list reads.",
26
26
  ];
27
27
  /** The image every computer of the run asks for: this machine's Chrome. */
28
28
  export function conformanceImage() {
@@ -31,6 +31,6 @@ export function conformanceImage() {
31
31
  /** The provider the CLI runs; throws in words without the live switch. */
32
32
  export async function createProvider({ env = process.env } = {}) {
33
33
  if (env[LOCAL_ENV.live] !== "1")
34
- throw new Error(`the local conformance module starts a real Chrome on this machine: set ${LOCAL_ENV.live}=1 to run it`);
34
+ throw new Error(`the Local Chrome conformance module starts a real Chrome on this machine: set ${LOCAL_ENV.live}=1 to run it`);
35
35
  return create(settingsFromEnv(env));
36
36
  }
@@ -1,8 +1,9 @@
1
1
  import { type OrgoChannel, type OrgoProvider, type OrgoWebSocketFactory } from "../orgo.js";
2
+ import type { OrgoDesktopProvider } from "../orgo-desktop.js";
2
3
  /** The environment this module reads, by name: the live switch, the run's template, and the provider's settings. */
3
4
  export declare const ENV: {
4
5
  readonly live: "AGENTRUN_COMPUTER_LIVE_ORGO";
5
- /** The template every computer of the run starts from; default Orgo's base desktop ("linux"). */
6
+ /** The template every computer of the run starts from; default Orgo's base desktop ("linux"). Linux only. */
6
7
  readonly template: "COMPUTER_ORGO_TEMPLATE";
7
8
  /** Required: an Orgo API key (never ORGO_API_KEY, which a host may hold for another account). */
8
9
  readonly key: "COMPUTER_ORGO_API_KEY";
@@ -10,6 +11,8 @@ export declare const ENV: {
10
11
  readonly workspace: "COMPUTER_ORGO_WORKSPACE";
11
12
  /** Orgo's API; default https://www.orgo.ai/api. */
12
13
  readonly apiUrl: "COMPUTER_ORGO_API_URL";
14
+ /** The desktop: linux (default), windows or macos. */
15
+ readonly os: "COMPUTER_ORGO_OS";
13
16
  };
14
17
  /** The longest lifetime a computer of a run may ask for: Orgo's shortest end, 1 h. */
15
18
  export declare const CONFORMANCE_MAX_LIFETIME_MS: number;
@@ -33,9 +36,12 @@ export declare function settingsFromEnv(env?: Record<string, string | undefined>
33
36
  workspaceId: string;
34
37
  apiUrl?: string;
35
38
  };
36
- /** The image every computer of the run starts from: COMPUTER_ORGO_TEMPLATE, or Orgo's base desktop. */
39
+ /** The image every computer of the run starts from: "windows" or "macos" for those desktops; else COMPUTER_ORGO_TEMPLATE, or Orgo's base desktop. */
37
40
  export declare function conformanceImage({ env }?: Pick<OrgoModuleOptions, "env">): string;
38
41
  /** The provider the CLI runs; throws in words without the live switch, or when a setting is missing or wrong. */
39
- export declare function createProvider(options?: OrgoModuleOptions): Promise<OrgoProvider>;
40
- /** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
41
- export declare function createDriftedProvider({ buildDaemon, ...options }?: OrgoModuleOptions): Promise<OrgoProvider>;
42
+ export declare function createProvider(options?: OrgoModuleOptions): Promise<OrgoProvider | OrgoDesktopProvider>;
43
+ /**
44
+ * The same provider uploading a daemon that reports version <version>-drift, for the drift.version case; on Windows and
45
+ * macOS, where no daemon runs, the provider whose computer's hello reports that version.
46
+ */
47
+ export declare function createDriftedProvider({ buildDaemon, ...options }?: OrgoModuleOptions): Promise<OrgoProvider | OrgoDesktopProvider>;
@@ -3,15 +3,19 @@
3
3
  // COMPUTER_ORGO_API_KEY (never ORGO_API_KEY), in the workspace COMPUTER_ORGO_WORKSPACE names. The live switch is checked
4
4
  // first, before any other setting is read.
5
5
  //
6
- // The daemon is uploaded into each computer (dist/computerd-linux-amd64, `npm run build:daemon`); the drifted provider
7
- // uploads one built with Go as version <version>-drift. Every computer of a run lives at most 1 h, Orgo's shortest end
8
- // (ends_in_hours 1): Orgo deletes it then whatever happens to the run.
9
- import { create, ORGO_BASE_IMAGE } from "../orgo.js";
6
+ // COMPUTER_ORGO_OS picks the desktop: linux (the default), windows or macos. On Linux the daemon is uploaded into each
7
+ // computer (dist/computerd-linux-amd64, `npm run build:daemon`); the drifted provider uploads one built with Go as
8
+ // version <version>-drift. On Windows and macOS no daemon runs: the provider answers over Orgo's API (daemon none), the
9
+ // run's image is "windows" or "macos", and `--kind desktop` runs the desktop's cases, with the Windows fixture this
10
+ // package carries. Every computer of a run lives at most 1 h (on Linux and Windows Orgo's shortest end, ends_in_hours
11
+ // 1, deletes it then whatever happens to the run; macOS has no Orgo end, so the janitor alone ends it).
12
+ import { ORGO_BASE_IMAGE, ORGO_MACOS_IMAGE, ORGO_WINDOWS_IMAGE } from "../descriptors/orgo.js";
13
+ import { create } from "../orgo.js";
10
14
  import { buildDriftDaemon, DRIFT_VERSION } from "./drift-daemon.js";
11
15
  /** The environment this module reads, by name: the live switch, the run's template, and the provider's settings. */
12
16
  export const ENV = {
13
17
  live: "AGENTRUN_COMPUTER_LIVE_ORGO",
14
- /** The template every computer of the run starts from; default Orgo's base desktop ("linux"). */
18
+ /** The template every computer of the run starts from; default Orgo's base desktop ("linux"). Linux only. */
15
19
  template: "COMPUTER_ORGO_TEMPLATE",
16
20
  /** Required: an Orgo API key (never ORGO_API_KEY, which a host may hold for another account). */
17
21
  key: "COMPUTER_ORGO_API_KEY",
@@ -19,6 +23,8 @@ export const ENV = {
19
23
  workspace: "COMPUTER_ORGO_WORKSPACE",
20
24
  /** Orgo's API; default https://www.orgo.ai/api. */
21
25
  apiUrl: "COMPUTER_ORGO_API_URL",
26
+ /** The desktop: linux (default), windows or macos. */
27
+ os: "COMPUTER_ORGO_OS",
22
28
  };
23
29
  const ORGO_ENV = ENV;
24
30
  /** The longest lifetime a computer of a run may ask for: Orgo's shortest end, 1 h. */
@@ -26,12 +32,20 @@ export const CONFORMANCE_MAX_LIFETIME_MS = 60 * 60_000;
26
32
  /** For the run's report: what this configuration means for the suite. */
27
33
  export const conformanceNotes = [
28
34
  "orgo: a Linux desktop on Orgo with computerd inside, on Orgo's own X display :99, its tools as 2510:2510; janitor-ended at the exact deadline its name carries, and within 1 h whatever happens (Orgo deletes it at ends_in_hours 1, the backstop); network none is init's own namespace (--own-network), probed from inside at the outside and at every port root listens on, since Orgo has no egress control; the desktop's path sockets are root's alone but the display's; no mount.",
35
+ "orgo windows and macos (COMPUTER_ORGO_OS): daemon none, the provider answering over Orgo's REST API: the screen from its screenshot, the pointer and keys from its click, drag, scroll, type and key calls, exec from its bash call (PowerShell on Windows), files through PowerShell on Windows; network open, since Orgo has no egress control and no daemon runs inside to hold one; the cases written for Linux (sh, /proc) are skipped in words.",
29
36
  ];
30
37
  function live(env) {
31
38
  if (env[ORGO_ENV.live] !== "1") {
32
39
  throw new Error(`the Orgo conformance module makes real computers: set ${ORGO_ENV.live}=1, with a key the lead has OKed, to run it`);
33
40
  }
34
41
  }
42
+ /** The desktop COMPUTER_ORGO_OS names, linux when it names none; a throw in words for any other. */
43
+ function osOf(env) {
44
+ const os = env[ORGO_ENV.os] || "linux";
45
+ if (os !== "linux" && os !== "windows" && os !== "macos")
46
+ throw new Error(`${ORGO_ENV.os} is linux, windows or macos, not ${JSON.stringify(os)}`);
47
+ return os;
48
+ }
35
49
  /** The provider's settings from COMPUTER_ORGO_* alone: the key, the workspace, and Orgo's API when named. No word holds the key. */
36
50
  export function settingsFromEnv(env = process.env) {
37
51
  const apiKey = env[ORGO_ENV.key];
@@ -43,11 +57,19 @@ export function settingsFromEnv(env = process.env) {
43
57
  const apiUrl = env[ORGO_ENV.apiUrl] || undefined;
44
58
  return { apiKey, workspaceId, ...(apiUrl ? { apiUrl } : {}) };
45
59
  }
46
- /** The image every computer of the run starts from: COMPUTER_ORGO_TEMPLATE, or Orgo's base desktop. */
60
+ /** The image every computer of the run starts from: "windows" or "macos" for those desktops; else COMPUTER_ORGO_TEMPLATE, or Orgo's base desktop. */
47
61
  export function conformanceImage({ env = process.env } = {}) {
62
+ const os = osOf(env);
63
+ if (os === "windows")
64
+ return ORGO_WINDOWS_IMAGE;
65
+ if (os === "macos")
66
+ return ORGO_MACOS_IMAGE;
48
67
  return env[ORGO_ENV.template] || ORGO_BASE_IMAGE;
49
68
  }
50
69
  function build({ env = process.env, fetch, webSocket, channel }, daemonPath) {
70
+ const os = osOf(env);
71
+ if (os !== "linux")
72
+ return create({ os, ...settingsFromEnv(env), maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS, ...(fetch ? { fetch } : {}) });
51
73
  return create({
52
74
  ...settingsFromEnv(env),
53
75
  maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS,
@@ -62,8 +84,15 @@ export async function createProvider(options = {}) {
62
84
  live(options.env ?? process.env);
63
85
  return build(options, options.daemonPath);
64
86
  }
65
- /** The same provider uploading a daemon that reports version <version>-drift, for the drift.version case. */
87
+ /**
88
+ * The same provider uploading a daemon that reports version <version>-drift, for the drift.version case; on Windows and
89
+ * macOS, where no daemon runs, the provider whose computer's hello reports that version.
90
+ */
66
91
  export async function createDriftedProvider({ buildDaemon = (version) => buildDriftDaemon("amd64", version), ...options } = {}) {
67
- live(options.env ?? process.env);
92
+ const env = options.env ?? process.env;
93
+ live(env);
94
+ const os = osOf(env);
95
+ if (os !== "linux")
96
+ return create({ os, ...settingsFromEnv(env), maxLifetimeMs: CONFORMANCE_MAX_LIFETIME_MS, daemonVersion: DRIFT_VERSION, ...(options.fetch ? { fetch: options.fetch } : {}) });
68
97
  return build(options, await buildDaemon(DRIFT_VERSION));
69
98
  }
@@ -8,7 +8,8 @@ import { randomBytes } from "node:crypto";
8
8
  import { linkSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
9
9
  import { tmpdir } from "node:os";
10
10
  import { dirname, join } from "node:path";
11
- import { adbCli, create, PHONE_IMAGE } from "../phone-harness.js";
11
+ import { PHONE_IMAGE } from "../descriptors/phone-harness.js";
12
+ import { adbCli, create } from "../phone-harness.js";
12
13
  /** The environment this module reads, by name. */
13
14
  export const PHONE_ENV = {
14
15
  /** The phone harness API key: this module's own name, never the bare PHONE_HARNESS_API_KEY. */
@@ -21,8 +21,9 @@ export function formatReport(report) {
21
21
  const reached = first ? said(first) : report.daemonMode === "none" ? "no computer reached" : "no daemon reached";
22
22
  const lines = [`computer conformance · ${report.provider} · ${report.kind}, daemon ${report.daemonMode} · ${reached}`];
23
23
  // A Core case skipped for an optional group the computer does not declare is not Core for this kind of computer (a
24
- // linux computer is never held to screen): it is listed as optional, out of Core's lines and count.
25
- const optional = (r) => r.status === "skip" && r.undeclared !== undefined;
24
+ // linux computer is never held to screen), nor one written for another system: it is listed as optional, out of
25
+ // Core's lines and count, its reason kept.
26
+ const optional = (r) => r.status === "skip" && (r.undeclared !== undefined || r.os !== undefined);
26
27
  const levelOf = (r) => (r.level === "core" && optional(r) ? "optional" : r.level);
27
28
  for (const level of ["core", "full", "optional"]) {
28
29
  for (const group of GROUPS) {
@@ -10,7 +10,7 @@ import { casesFor } from "./cases/index.js";
10
10
  import { dialCdp } from "./cdp.js";
11
11
  import { startFixture } from "./fixture.js";
12
12
  import { kindCases, kindRunProblem, kindVerdict } from "./kind.js";
13
- import { coreGroups, } from "./types.js";
13
+ import { caseOs, coreGroups, } from "./types.js";
14
14
  /** The label every computer of a run carries, with the run's id. */
15
15
  export const RUN_LABEL = "agentrun.conformance";
16
16
  /** The lifetime a run's computers ask for, at most the provider's own cap: a metered phone's cap is its hard stop. */
@@ -88,8 +88,10 @@ export async function runConformance(provider, options) {
88
88
  const { image, only, kind, signal, cases = casesFor(provider.capabilities().kind), drifted, planted, mountFor, onResult, notes, caseTimeoutMs = 180_000, patience = 30_000, cleanupTimeoutMs = 60_000, fixture, gpu } = options;
89
89
  if (kind !== undefined && only !== undefined)
90
90
  throw new TypeError("a run takes kind and only apart: a kind runs its own cases");
91
- // What the provider declares of itself: as given, else the kind registry's entry for its id (health.declared).
92
- const declared = options.declared ?? PROVIDERS.find((entry) => entry.id === provider.id)?.capabilities;
91
+ // What the provider declares of itself: as given, else the kind registry's entry for its id (health.declared), its
92
+ // parked configurations with its offered ones: a parked one built for the suite is held to its own declaration.
93
+ const entry = PROVIDERS.find((one) => one.id === provider.id);
94
+ const declared = options.declared ?? (entry ? [...entry.capabilities, ...(entry.parked ?? [])] : undefined);
93
95
  const kindProblem = kind === undefined ? undefined : kindRunProblem(kind);
94
96
  if (kindProblem !== undefined)
95
97
  throw new TypeError(kindProblem);
@@ -252,6 +254,9 @@ export async function runConformance(provider, options) {
252
254
  else if (need === "release:stop" && !(Array.isArray(capabilities.release) && capabilities.release.includes("stop"))) {
253
255
  return `the provider does not declare ${need}`;
254
256
  }
257
+ else if (need === "persistence" && capabilities.persistence === undefined) {
258
+ return `the provider does not declare ${need}: it keeps no computer for an agent`;
259
+ }
255
260
  else if (need === "vendor-agent" && !Array.isArray(capabilities.vendorAgentPorts)) {
256
261
  return `the provider does not declare ${need} (capabilities().vendorAgentPorts): no vendor's agent runs beside its computers' programs`;
257
262
  }
@@ -295,6 +300,10 @@ export async function runConformance(provider, options) {
295
300
  report.undeclared.push(need);
296
301
  return { ...result("skip", why), undeclared: lacking };
297
302
  }
303
+ // A case written for other systems (a POSIX program, /proc) is not this computer's to pass or fail: skipped in words.
304
+ const systems = caseOs(c);
305
+ if (systems !== undefined && !systems.includes(capabilities.os))
306
+ return { ...result("skip", `the case is written for ${systems.join(" or ")}, and this computer runs ${capabilities.os}`), os: systems };
298
307
  // The shared computer is made, bounded on its own, before the case's time starts.
299
308
  const sharedComputer = (c.computer ?? "shared") === "shared" ? await getShared() : undefined;
300
309
  const timeoutMs = c.timeoutMs ?? caseTimeoutMs;
@@ -394,6 +403,13 @@ export async function runConformance(provider, options) {
394
403
  track,
395
404
  connect: (ref) => connect(ref ?? needComputer().ref),
396
405
  async home() {
406
+ if (capabilities.os === "windows") {
407
+ // Windows has no HOME: the profile folder is USERPROFILE, read through PowerShell's own environment.
408
+ const profile = (await t.exec(["powershell.exe", "-NoProfile", "-Command", "[Console]::Out.Write($env:USERPROFILE)"])).out.trim();
409
+ if (!/^[A-Za-z]:[\\/]/.test(profile))
410
+ throw new Error(`USERPROFILE in the computer is ${show(profile)}, not an absolute path`);
411
+ return profile.replace(/[\\/]+$/, "");
412
+ }
397
413
  const env = await t.exec(["env"]);
398
414
  const home = /^HOME=(.*)$/m.exec(env.out)?.[1];
399
415
  if (home === undefined || !home.startsWith("/"))
@@ -406,10 +422,11 @@ export async function runConformance(provider, options) {
406
422
  return path;
407
423
  },
408
424
  fixture() {
409
- if (fixture === undefined) {
425
+ // A Windows desktop's fixture is a PowerShell script this package carries (windows-fixture.ts): no file to name.
426
+ if (fixture === undefined && !(capabilities.kind === "desktop" && capabilities.os === "windows")) {
410
427
  return t.skip("no fixture was given: --fixture names computerd-fixture for a desktop, or the fixture APK for an Android phone");
411
428
  }
412
- started ??= startFixture(t, fixture, (stop) => {
429
+ started ??= startFixture(t, fixture ?? "", (stop) => {
413
430
  stopFixture = stop;
414
431
  });
415
432
  return started;
@@ -577,8 +594,9 @@ export async function runConformance(provider, options) {
577
594
  }
578
595
  await cleanup(provider, capabilities.lifetime, runLabels, report, deleted, cleanupTimeoutMs);
579
596
  }
580
- // A Core case skipped for an optional group the computer does not declare is not part of Core's verdict.
581
- const core = report.results.filter((r) => r.level === "core" && !(r.status === "skip" && r.undeclared !== undefined));
597
+ // A Core case skipped for an optional group the computer does not declare, or written for another system, is not part
598
+ // of Core's verdict.
599
+ const core = report.results.filter((r) => r.level === "core" && !(r.status === "skip" && (r.undeclared !== undefined || r.os !== undefined)));
582
600
  const clean = report.cleanup.left.length === 0 && report.cleanup.errors.length === 0;
583
601
  const corePassed = core.every((r) => r.status === "pass") && clean;
584
602
  if ((report.coreNotRun ?? []).length === 0)
@@ -1,5 +1,5 @@
1
1
  import type { MountKind, MountSpec } from "../mount.js";
2
- import type { ComputerClient, ComputerKind, DaemonMethod, DaemonMethods, ExecRunParams, Group, HelloResult, NetworkFence } from "../protocol.js";
2
+ import type { ComputerClient, ComputerKind, ComputerOs, DaemonMethod, DaemonMethods, ExecRunParams, Group, HelloResult, NetworkFence } from "../protocol.js";
3
3
  import type { ComputerConnection, ComputerProvider, ComputerRef, ComputerSpec, DaemonMode, GpuSpec } from "../provider.js";
4
4
  import type { ComputerError, ComputerErrorCode, Result } from "../result.js";
5
5
  import type { ComputerSettingKind, KindCapabilities } from "../kinds.js";
@@ -13,13 +13,13 @@ export type CaseGroup = "health" | "exec" | "files" | "process" | "provider" | "
13
13
  /**
14
14
  * What a case needs: a group (declared by both the provider's capabilities().groups and the computer's hello), a
15
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, the ports of a vendor's agent in the computer (vendor-agent: declared
18
- * by capabilities().vendorAgentPorts, an empty list included), a secret the provider takes (secrets: declared by the
19
- * run's planted provider, which its conformance module's ENV makes possible), or GPUs (gpu: declared by
20
- * capabilities().gpu).
16
+ * stops a computer and keeps it, an agent's persistent computer (capabilities().persistence), a mount kind
17
+ * capabilities().mount declares, a provider method that is optional (extend, stream), declared by being there, the
18
+ * ports of a vendor's agent in the computer (vendor-agent: declared by capabilities().vendorAgentPorts, an empty list
19
+ * included), a secret the provider takes (secrets: declared by the run's planted provider, which its conformance
20
+ * module's ENV makes possible), or GPUs (gpu: declared by capabilities().gpu).
21
21
  */
22
- 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" | "secrets" | "gpu";
22
+ export type Capability = Group | "network:none" | "network:open" | "network:allow" | "lifetime:janitor" | "user:root" | "user:uid" | "release:stop" | "persistence" | "mount:bind" | "mount:archil" | "extend" | "stream" | "vendor-agent" | "secrets" | "gpu";
23
23
  /**
24
24
  * A fresh run's folder for one mount kind, made by the provider's conformance module: the mount that reaches it, and its
25
25
  * outside, where a computer does not run (the folder on the host for a bind, the disk's file API for Archil).
@@ -142,8 +142,16 @@ export interface Case {
142
142
  computer?: "shared" | "fresh" | "none";
143
143
  /** The longest this case may run, when it needs longer than the run's default. */
144
144
  timeoutMs?: number;
145
+ /**
146
+ * The systems the case's body is written for. Absent: any, but a case that needs exec or processes runs POSIX
147
+ * programs (sh, id, /proc) and is Linux's alone, and one that needs files names POSIX paths (/tmp) and is no Windows
148
+ * computer's (caseOs). A computer of another os skips it in words.
149
+ */
150
+ os?: readonly ComputerOs[];
145
151
  run(t: CaseContext): Promise<void>;
146
152
  }
153
+ /** The systems a case runs on: its own os; else Linux alone for one that runs programs, any but Windows for one that names paths. */
154
+ export declare function caseOs(c: Pick<Case, "os" | "needs">): readonly ComputerOs[] | undefined;
147
155
  export interface CaseResult {
148
156
  id: string;
149
157
  level: Level;
@@ -152,9 +160,14 @@ export interface CaseResult {
152
160
  reason?: string;
153
161
  /**
154
162
  * On a skip: the needs that were not declared and are optional for this kind of computer. A Core case skipped for
155
- * these does not fail Core; any other skip of a Core case does.
163
+ * these does not fail Core; any other skip of a Core case does, but one for `os`.
156
164
  */
157
165
  undeclared?: Capability[];
166
+ /**
167
+ * On a skip: the systems the case is written for (Case.os, caseOs), none of them this computer's. A Core case skipped
168
+ * for this is not this computer's to pass or fail, so it does not fail Core; its reason stays in the report.
169
+ */
170
+ os?: readonly string[];
158
171
  /** What the case saw and recorded without asserting it (CaseContext.observe); absent when nothing. */
159
172
  observed?: string[];
160
173
  }
@@ -22,3 +22,13 @@ export function coreGroups(kind, daemon) {
22
22
  return computerd;
23
23
  }
24
24
  }
25
+ /** The systems a case runs on: its own os; else Linux alone for one that runs programs, any but Windows for one that names paths. */
26
+ export function caseOs(c) {
27
+ if (c.os !== undefined)
28
+ return c.os;
29
+ if (c.needs.some((need) => need === "exec" || need === "processes"))
30
+ return ["linux"];
31
+ if (c.needs.includes("files"))
32
+ return ["linux", "macos", "android", "ios"];
33
+ return undefined;
34
+ }
@@ -0,0 +1 @@
1
+ export declare const WINDOWS_FIXTURE: string;