@parcha/agentrun-computer 0.1.0-beta.36 → 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 (121) hide show
  1. package/NOTICE +2 -0
  2. package/README.md +321 -308
  3. package/box/build-agent37.mjs +177 -0
  4. package/dist/agent37.d.ts +165 -0
  5. package/dist/agent37.js +759 -0
  6. package/dist/attach.d.ts +146 -0
  7. package/dist/attach.js +469 -0
  8. package/dist/browserbase.d.ts +2 -4
  9. package/dist/browserbase.js +2 -1
  10. package/dist/client.d.ts +33 -1
  11. package/dist/client.js +53 -0
  12. package/dist/computerd-linux-amd64 +0 -0
  13. package/dist/computerd-linux-arm64 +0 -0
  14. package/dist/conformance/agent37.d.ts +96 -0
  15. package/dist/conformance/agent37.js +154 -0
  16. package/dist/conformance/cases/apps.d.ts +5 -0
  17. package/dist/conformance/cases/apps.js +160 -73
  18. package/dist/conformance/cases/health.js +14 -0
  19. package/dist/conformance/cases/index.js +2 -0
  20. package/dist/conformance/cases/provider.js +27 -1
  21. package/dist/conformance/cases/screen.d.ts +3 -0
  22. package/dist/conformance/cases/screen.js +18 -0
  23. package/dist/conformance/cases/settings.d.ts +29 -23
  24. package/dist/conformance/cases/settings.js +76 -58
  25. package/dist/conformance/cases/touch.js +19 -17
  26. package/dist/conformance/cases/ui.d.ts +2 -0
  27. package/dist/conformance/cases/ui.js +475 -0
  28. package/dist/conformance/cli.d.ts +9 -0
  29. package/dist/conformance/cli.js +28 -3
  30. package/dist/conformance/e2b.d.ts +6 -0
  31. package/dist/conformance/e2b.js +9 -2
  32. package/dist/conformance/fixture.d.ts +1 -1
  33. package/dist/conformance/fixture.js +25 -1
  34. package/dist/conformance/modal.d.ts +17 -13
  35. package/dist/conformance/modal.js +18 -9
  36. package/dist/conformance/orgo.d.ts +3 -3
  37. package/dist/conformance/orgo.js +6 -8
  38. package/dist/conformance/phone-harness.d.ts +6 -2
  39. package/dist/conformance/phone-harness.js +21 -4
  40. package/dist/conformance/report.js +1 -1
  41. package/dist/conformance/runner.js +23 -4
  42. package/dist/conformance/sweep.d.ts +50 -0
  43. package/dist/conformance/sweep.js +187 -0
  44. package/dist/conformance/types.d.ts +11 -3
  45. package/dist/conformance/ui-fixture.d.ts +56 -0
  46. package/dist/conformance/ui-fixture.js +43 -0
  47. package/dist/create-requests.d.ts +51 -0
  48. package/dist/create-requests.js +121 -0
  49. package/dist/daytona.d.ts +2 -4
  50. package/dist/daytona.js +3 -2
  51. package/dist/descriptor.d.ts +5 -0
  52. package/dist/descriptor.js +2 -0
  53. package/dist/descriptors/agent37.d.ts +41 -0
  54. package/dist/descriptors/agent37.js +28 -0
  55. package/dist/descriptors/index.d.ts +38 -2
  56. package/dist/descriptors/index.js +4 -2
  57. package/dist/descriptors/orgo.d.ts +2 -1
  58. package/dist/descriptors/orgo.js +3 -2
  59. package/dist/descriptors/phone-harness.d.ts +1 -1
  60. package/dist/descriptors/phone-harness.js +2 -2
  61. package/dist/docker.d.ts +7 -4
  62. package/dist/docker.js +271 -29
  63. package/dist/e2b.d.ts +9 -165
  64. package/dist/e2b.js +282 -1342
  65. package/dist/fake-ui-driver.d.ts +97 -0
  66. package/dist/fake-ui-driver.js +717 -0
  67. package/dist/host.d.ts +182 -0
  68. package/dist/host.js +1 -0
  69. package/dist/hosted/process.d.ts +67 -0
  70. package/dist/hosted/process.js +228 -0
  71. package/dist/hosted/provider.d.ts +146 -0
  72. package/dist/hosted/provider.js +1364 -0
  73. package/dist/hosted/scripts.d.ts +76 -0
  74. package/dist/{child.js → hosted/scripts.js} +93 -12
  75. package/dist/index.d.ts +7 -3
  76. package/dist/index.js +7 -4
  77. package/dist/kernel.d.ts +2 -4
  78. package/dist/kernel.js +2 -1
  79. package/dist/kinds.d.ts +8 -1
  80. package/dist/kinds.js +20 -4
  81. package/dist/local-chrome.d.ts +2 -4
  82. package/dist/local-chrome.js +2 -1
  83. package/dist/modal.d.ts +23 -181
  84. package/dist/modal.js +271 -1244
  85. package/dist/orgo-channel.d.ts +3 -2
  86. package/dist/orgo-channel.js +5 -2
  87. package/dist/orgo-desktop.d.ts +9 -4
  88. package/dist/orgo-desktop.js +33 -13
  89. package/dist/orgo-workspaces.d.ts +47 -0
  90. package/dist/orgo-workspaces.js +94 -0
  91. package/dist/orgo.d.ts +10 -4
  92. package/dist/orgo.js +30 -12
  93. package/dist/phone-harness.d.ts +31 -22
  94. package/dist/phone-harness.js +510 -698
  95. package/dist/png.d.ts +4 -0
  96. package/dist/png.js +27 -0
  97. package/dist/protocol.d.ts +335 -32
  98. package/dist/protocol.js +96 -3
  99. package/dist/provider.d.ts +34 -6
  100. package/dist/provider.js +16 -0
  101. package/dist/result.d.ts +1 -1
  102. package/dist/surface/api.d.ts +248 -0
  103. package/dist/surface/api.js +1 -0
  104. package/dist/surface/core.d.ts +42 -0
  105. package/dist/surface/core.js +393 -0
  106. package/dist/surface/index.d.ts +5 -0
  107. package/dist/surface/index.js +3 -0
  108. package/dist/surface/outline.d.ts +8 -0
  109. package/dist/surface/outline.js +50 -0
  110. package/dist/surface/script.d.ts +10 -0
  111. package/dist/surface/script.js +92 -0
  112. package/dist/ui-engine.d.ts +114 -0
  113. package/dist/ui-engine.js +798 -0
  114. package/package.json +17 -1
  115. package/dist/child.d.ts +0 -42
  116. package/dist/conformance/e2b-diagnose.d.ts +0 -16
  117. package/dist/conformance/e2b-diagnose.js +0 -61
  118. package/dist/conformance/e2b-sweep.d.ts +0 -18
  119. package/dist/conformance/e2b-sweep.js +0 -132
  120. package/dist/conformance/modal-sweep.d.ts +0 -22
  121. package/dist/conformance/modal-sweep.js +0 -213
@@ -87,9 +87,10 @@ export type OrgoWebSocketFactory = (url: string) => OrgoSocket;
87
87
  * line (the prompt, the typed line's echo) is dropped. The marker is printed from two words, so the echo of the line
88
88
  * that prints it never holds it.
89
89
  */
90
- export declare function orgoTerminalChannel({ rest, workspaceId, webSocket, echoMs, }: {
90
+ export declare function orgoTerminalChannel({ rest, workspace, webSocket, echoMs, }: {
91
91
  rest: OrgoRest;
92
- workspaceId: string;
92
+ /** The workspace the computers live in, which an upload names: the provider's, read when first needed. */
93
+ workspace: (signal?: AbortSignal) => Promise<Result<string>>;
93
94
  webSocket?: OrgoWebSocketFactory;
94
95
  /** How long a typed line waits for the shell's echo before it is typed again. */
95
96
  echoMs?: number;
@@ -126,7 +126,7 @@ function frameText(data) {
126
126
  * line (the prompt, the typed line's echo) is dropped. The marker is printed from two words, so the echo of the line
127
127
  * that prints it never holds it.
128
128
  */
129
- export function orgoTerminalChannel({ rest, workspaceId, webSocket = defaultWebSocket, echoMs = 3_000, }) {
129
+ export function orgoTerminalChannel({ rest, workspace, webSocket = defaultWebSocket, echoMs = 3_000, }) {
130
130
  const bash = async (computer, command, timeoutMs, signal) => {
131
131
  const timeout = Math.min(BASH_MAX_S, Math.max(1, Math.ceil(timeoutMs / 1000)));
132
132
  const ran = await rest.request("POST", `/computers/${encodeURIComponent(computer)}/bash`, { body: { command, timeout }, timeoutMs: timeout * 1000 + BASH_PROXY_MS, ...(signal ? { signal } : {}) });
@@ -298,9 +298,12 @@ export function orgoTerminalChannel({ rest, workspaceId, webSocket = defaultWebS
298
298
  const at = path.lastIndexOf("/");
299
299
  if (at < 0 || path.slice(at + 1) === "")
300
300
  return fail("invalid", `an upload goes to an absolute file path, not ${JSON.stringify(path)}`);
301
+ const workspaceId = await workspace(signal);
302
+ if (!workspaceId.ok)
303
+ return workspaceId;
301
304
  const form = new FormData();
302
305
  form.set("file", new Blob([new Uint8Array(bytes)]), path.slice(at + 1));
303
- form.set("workspaceId", workspaceId);
306
+ form.set("workspaceId", workspaceId.value);
304
307
  form.set("desktopId", computer);
305
308
  form.set("destPath", path.slice(0, at) || "/");
306
309
  const put = await rest.request("POST", "/files/upload", { form, timeoutMs, ...(signal ? { signal } : {}) });
@@ -1,7 +1,7 @@
1
1
  import { type OrgoRest } from "./orgo-channel.js";
2
2
  import { type OrgoLedger } from "./orgo-names.js";
3
3
  import { type ComputerClient, type DaemonMethod, type DaemonMethods, type Group, type HelloResult } from "./protocol.js";
4
- import { type AttachContext, type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type CreatedComputer, type NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseContext, type ReleaseHow } from "./provider.js";
4
+ import { type AttachContext, type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type CreateContext, type CreatedComputer, type KeyChoice, type NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseContext, type ReleaseHow } from "./provider.js";
5
5
  import { type Result } from "./result.js";
6
6
  import { type ScreenWatch, type ScreenWatchHandlers, type WatchOptions } from "./screen-watch.js";
7
7
  export type OrgoDesktopOs = "windows" | "macos";
@@ -25,8 +25,11 @@ export interface OrgoDesktopOptions {
25
25
  os: OrgoDesktopOs;
26
26
  /** The Orgo API key. Serve passes ORGO_API_KEY's value; the provider never reads the environment or logs it. */
27
27
  apiKey: string;
28
- /** The workspace this deployment's computers live in; the provider lists, attaches and releases only there. */
29
- workspaceId: string;
28
+ /**
29
+ * The workspace this deployment's computers live in; the provider lists, attaches and releases only there. Absent:
30
+ * the key's account's one workspace, read from Orgo when first needed (orgo-workspaces.ts soleWorkspace).
31
+ */
32
+ workspaceId?: string;
30
33
  /** Orgo's API, https; default https://www.orgo.ai/api. */
31
34
  apiUrl?: string;
32
35
  /** For tests: every REST call goes through it. Default the global fetch. */
@@ -93,7 +96,7 @@ export declare class OrgoDesktopProvider implements ComputerProvider {
93
96
  */
94
97
  capabilities(): ComputerCapabilities;
95
98
  check(spec: ComputerSpec): Refusal[];
96
- create(spec: ComputerSpec, { signal }?: CallContext): Promise<Result<CreatedComputer>>;
99
+ create(spec: ComputerSpec, context: CreateContext): Promise<Result<CreatedComputer>>;
97
100
  /** The live view: screen.watch on a connection of the watch's own (daemonWatch), the client's polled screenshots. */
98
101
  watch(ref: ComputerRef, handlers: ScreenWatchHandlers, options?: WatchOptions): Promise<Result<ScreenWatch>>;
99
102
  /**
@@ -118,6 +121,8 @@ export declare class OrgoDesktopProvider implements ComputerProvider {
118
121
  testConnection(context?: CallContext): Promise<Result<{
119
122
  detail: string;
120
123
  }>>;
124
+ /** Settings' pick of ORGO_WORKSPACE_ID (workspaceId): every workspace the key's account sees, by name. Makes nothing. */
125
+ keyChoices(option: string, { signal }?: CallContext): Promise<Result<KeyChoice[]>>;
121
126
  /** open: what Orgo gives, the one network here; never read from inside, and a change is refused. */
122
127
  network(ref: ComputerRef, policy?: NetworkSpec, { signal }?: CallContext): Promise<Result<NetworkPolicy>>;
123
128
  /**
@@ -36,8 +36,9 @@ import { MACOS_GROUPS, ORGO_MACOS_IMAGE, ORGO_WINDOWS_IMAGE, WINDOWS_GROUPS } fr
36
36
  import { EPOCH_LABEL, OWNER_LABEL, OWNER_SERVER_LABEL, ownerLabels, RUN_HASH_LABEL, RUN_LABEL, runHash } from "./labels.js";
37
37
  import { checkMount } from "./mount.js";
38
38
  import { ORGO_API_URL, orgoRest } from "./orgo-channel.js";
39
+ import { workspaceChoices, workspaceHolder } from "./orgo-workspaces.js";
39
40
  import { COMPUTER_ID, claimProblem, andSettled, inTurn, filterProblem, labelProblem, labelsOf, NAME_MAX, NO_DEADLINE, nameParts, orgoMemoryLedger, orgoName, ownedListing, ownerHashOfLabels, ownerReadBack, refProblem, sameComputer, settleEntry, show, renewEntry, takeEntry, withDeadline, } from "./orgo-names.js";
40
- import { encodePng } from "./phone-harness.js";
41
+ import { encodePng } from "./png.js";
41
42
  import { MAX_CHUNK_BYTES, MAX_LIST_ENTRIES, MAX_OUTPUT_BYTES, PROTOCOL_VERSION, } from "./protocol.js";
42
43
  import { checkGpu, checkTenure, runLifetimeMs, } from "./provider.js";
43
44
  import { failFor, ok, vendorFail } from "./result.js";
@@ -333,7 +334,7 @@ export class OrgoDesktopProvider {
333
334
  id = "orgo";
334
335
  version = VERSION;
335
336
  #rest;
336
- #workspaceId;
337
+ #workspace;
337
338
  #profile;
338
339
  #maxLifetimeMs;
339
340
  #timeouts;
@@ -353,8 +354,8 @@ export class OrgoDesktopProvider {
353
354
  throw new Error(`os is "windows" or "macos" for an Orgo desktop Orgo's API answers, not ${JSON.stringify(os)}`);
354
355
  if (typeof apiKey !== "string" || apiKey === "")
355
356
  throw new Error("options.apiKey, an Orgo API key, is required");
356
- if (typeof workspaceId !== "string" || !WORKSPACE_ID.test(workspaceId))
357
- throw new Error("options.workspaceId, the Orgo workspace this deployment's computers live in, is required");
357
+ if (workspaceId !== undefined && (typeof workspaceId !== "string" || !WORKSPACE_ID.test(workspaceId)))
358
+ throw new Error("options.workspaceId, the Orgo workspace this deployment's computers live in, is an Orgo workspace id when given");
358
359
  let url;
359
360
  try {
360
361
  url = new URL(apiUrl);
@@ -372,7 +373,7 @@ export class OrgoDesktopProvider {
372
373
  throw new Error(`timeouts.${key} must be a whole number of ms above 0`);
373
374
  }
374
375
  this.#rest = orgoRest({ apiKey, apiUrl: url.href, ...(fetch ? { fetch } : {}) });
375
- this.#workspaceId = workspaceId;
376
+ this.#workspace = workspaceHolder(workspaceId, this.#rest, merged.requestMs);
376
377
  this.#profile = PROFILES[os];
377
378
  this.#maxLifetimeMs = maxLifetimeMs;
378
379
  this.#timeouts = merged;
@@ -384,7 +385,10 @@ export class OrgoDesktopProvider {
384
385
  let pointer = this.#pointers.get(ref.id);
385
386
  if (pointer === undefined)
386
387
  this.#pointers.set(ref.id, (pointer = {}));
387
- const client = new OrgoDesktopClient(this.#rest, ref.id, this.#profile, this.#workspaceId, this.#timeouts.requestMs, pointer);
388
+ const workspace = await this.#workspace.read(signal);
389
+ if (!workspace.ok)
390
+ return workspace;
391
+ const client = new OrgoDesktopClient(this.#rest, ref.id, this.#profile, workspace.value, this.#timeouts.requestMs, pointer);
388
392
  const hello = await client.open(this.#daemonVersion, signal);
389
393
  if (!hello.ok) {
390
394
  client.close();
@@ -455,12 +459,16 @@ export class OrgoDesktopProvider {
455
459
  }
456
460
  return refusals;
457
461
  }
458
- async create(spec, { signal } = {}) {
462
+ async create(spec, context) {
463
+ const signal = context?.signal;
459
464
  const refusals = this.check(spec);
460
465
  if (refusals.length > 0)
461
466
  return fail("refused", refusals.map(({ field, message }) => `${field}: ${message}`).join("; "));
462
467
  if (signal?.aborted)
463
468
  return fail("aborted", "create was aborted before Orgo was called");
469
+ const workspace = await this.#workspace.read(signal);
470
+ if (!workspace.ok)
471
+ return workspace;
464
472
  const profile = this.#profile;
465
473
  // An agent's own computer outlives the run: no deadline, no Orgo end, the owner in its name and its labels.
466
474
  const owner = spec.owner;
@@ -474,7 +482,7 @@ export class OrgoDesktopProvider {
474
482
  const ram = spec.memoryMb === undefined ? profile.ram[0] : spec.memoryMb / 1024;
475
483
  const cpu = profile.cpus ? (spec.cpus ?? CPU_FOR_RAM[ram]) : undefined;
476
484
  const body = {
477
- workspace_id: this.#workspaceId,
485
+ workspace_id: workspace.value,
478
486
  name,
479
487
  os: profile.os,
480
488
  ram,
@@ -572,8 +580,11 @@ export class OrgoDesktopProvider {
572
580
  return written;
573
581
  return written.value.exitCode === 0 ? ok(undefined) : fail("refused", `writing ${this.#profile.labels} in ${ref.name} failed (exit ${written.value.exitCode})`);
574
582
  }
575
- /** Orgo's record of a computer; not_found once Orgo no longer has it. */
583
+ /** Orgo's record of a computer; not_found once Orgo no longer has it. The workspace is read first, so #ours knows it. */
576
584
  async #get(id, signal) {
585
+ const workspace = await this.#workspace.read(signal);
586
+ if (!workspace.ok)
587
+ return workspace;
577
588
  const read = await this.#rest.request("GET", `/computers/${encodeURIComponent(id)}`, { timeoutMs: this.#timeouts.requestMs, ...(signal ? { signal } : {}) });
578
589
  if (!read.ok)
579
590
  return read;
@@ -587,7 +598,8 @@ export class OrgoDesktopProvider {
587
598
  */
588
599
  #ours(record, name) {
589
600
  return (nameParts(record.name) !== undefined &&
590
- (record.workspace_id ?? record.project_id) === this.#workspaceId &&
601
+ this.#workspace.id !== undefined &&
602
+ (record.workspace_id ?? record.project_id) === this.#workspace.id &&
591
603
  (name === undefined || sameComputer(record.name, name)) &&
592
604
  record.status !== "deleted" &&
593
605
  (record.os === undefined || record.os === this.#profile.os));
@@ -702,13 +714,17 @@ export class OrgoDesktopProvider {
702
714
  }
703
715
  /** The workspace's computers, as Orgo lists them. */
704
716
  async #desktops(signal) {
705
- const read = await this.#rest.request("GET", `/workspaces/${encodeURIComponent(this.#workspaceId)}`, { timeoutMs: this.#timeouts.listMs, ...(signal ? { signal } : {}) });
717
+ const workspace = await this.#workspace.read(signal);
718
+ if (!workspace.ok)
719
+ return workspace;
720
+ const id = workspace.value;
721
+ const read = await this.#rest.request("GET", `/workspaces/${encodeURIComponent(id)}`, { timeoutMs: this.#timeouts.listMs, ...(signal ? { signal } : {}) });
706
722
  if (!read.ok)
707
723
  return read;
708
724
  const desktops = read.value?.desktops;
709
725
  if (!Array.isArray(desktops))
710
- return fail("vendor", `Orgo's workspace ${this.#workspaceId} lists no computers array`);
711
- return ok(desktops.filter((one) => typeof one?.id === "string" && typeof one.name === "string").map((one) => ({ ...one, workspace_id: this.#workspaceId })));
726
+ return fail("vendor", `Orgo's workspace ${id} lists no computers array`);
727
+ return ok(desktops.filter((one) => typeof one?.id === "string" && typeof one.name === "string").map((one) => ({ ...one, workspace_id: id })));
712
728
  }
713
729
  /** The live view: screen.watch on a connection of the watch's own (daemonWatch), the client's polled screenshots. */
714
730
  watch(ref, handlers, options) {
@@ -991,6 +1007,10 @@ export class OrgoDesktopProvider {
991
1007
  async testConnection(context = {}) {
992
1008
  return listTested("Orgo", await this.list({}, context));
993
1009
  }
1010
+ /** Settings' pick of ORGO_WORKSPACE_ID (workspaceId): every workspace the key's account sees, by name. Makes nothing. */
1011
+ keyChoices(option, { signal } = {}) {
1012
+ return workspaceChoices(this.#rest, option, { timeoutMs: this.#timeouts.requestMs, ...(signal ? { signal } : {}) });
1013
+ }
994
1014
  /** open: what Orgo gives, the one network here; never read from inside, and a change is refused. */
995
1015
  async network(ref, policy, { signal } = {}) {
996
1016
  const problem = refProblem(ref);
@@ -0,0 +1,47 @@
1
+ import type { OrgoRest } from "./orgo-channel.js";
2
+ import type { KeyChoice } from "./provider.js";
3
+ import { type Result } from "./result.js";
4
+ /** One workspace a key's account sees: its id, its name, and its status where Orgo says one other than active. */
5
+ export interface OrgoWorkspace {
6
+ readonly id: string;
7
+ readonly name: string;
8
+ readonly status?: string;
9
+ }
10
+ /** What a person reads for a key whose account has no workspace. */
11
+ export declare const NO_WORKSPACE = "this Orgo key's account has no workspace: make one at orgo.ai";
12
+ /** A workspace in words: its name, and its status when it is not active. */
13
+ export declare const workspaceWords: (workspace: OrgoWorkspace) => string;
14
+ /** Every workspace the key's account sees, deleted ones left out, in Orgo's order. An HTTP failure keeps its code. */
15
+ export declare function orgoWorkspaces(rest: OrgoRest, { timeoutMs, signal }: {
16
+ timeoutMs: number;
17
+ signal?: AbortSignal;
18
+ }): Promise<Result<OrgoWorkspace[]>>;
19
+ /**
20
+ * The workspace a provider whose settings name none uses: the key's account's one workspace. Several are refused in
21
+ * words naming them and pointing at Settings, where a person picks one; none is refused saying to make one.
22
+ */
23
+ export declare function soleWorkspace(rest: OrgoRest, context: {
24
+ timeoutMs: number;
25
+ signal?: AbortSignal;
26
+ }): Promise<Result<string>>;
27
+ /**
28
+ * keyChoices for an Orgo provider: workspaceId's choices, every workspace the key's account sees, each its id and its
29
+ * name; none is refused saying to make one. Orgo's descriptor picks no other option.
30
+ */
31
+ export declare function workspaceChoices(rest: OrgoRest, option: string, context: {
32
+ timeoutMs: number;
33
+ signal?: AbortSignal;
34
+ }): Promise<Result<KeyChoice[]>>;
35
+ /** A provider's workspace: `read()` the one its computers live in, and `id`, that id once a read found it. */
36
+ export interface WorkspaceHolder {
37
+ read(signal?: AbortSignal): Promise<Result<string>>;
38
+ readonly id: string | undefined;
39
+ }
40
+ /**
41
+ * The workspace a provider's computers live in: `given` when its settings name one; else the key's account's sole one
42
+ * (soleWorkspace), read on the first call that needs it and kept. A read that fails is not kept: the next call reads again.
43
+ * Calls that come while a read is under way share it. The shared read is bounded by timeoutMs alone, never by one
44
+ * caller's signal, so one caller giving up never fails the others: a caller whose signal fires stops waiting, answered
45
+ * "aborted", and the read goes on for the rest.
46
+ */
47
+ export declare function workspaceHolder(given: string | undefined, rest: OrgoRest, timeoutMs: number): WorkspaceHolder;
@@ -0,0 +1,94 @@
1
+ import { failAs, failFor, ok } from "./result.js";
2
+ const fail = failFor("orgo");
3
+ /** What a person reads for a key whose account has no workspace. */
4
+ export const NO_WORKSPACE = "this Orgo key's account has no workspace: make one at orgo.ai";
5
+ /** A workspace in words: its name, and its status when it is not active. */
6
+ export const workspaceWords = (workspace) => (workspace.status === undefined ? workspace.name : `${workspace.name} (${workspace.status})`);
7
+ /** Every workspace the key's account sees, deleted ones left out, in Orgo's order. An HTTP failure keeps its code. */
8
+ export async function orgoWorkspaces(rest, { timeoutMs, signal }) {
9
+ const read = await rest.request("GET", "/workspaces", { timeoutMs, ...(signal ? { signal } : {}) });
10
+ if (!read.ok)
11
+ return failAs(read.error, `Orgo's workspaces could not be read: ${read.error.message}`);
12
+ const listed = read.value?.workspaces;
13
+ if (!Array.isArray(listed))
14
+ return fail("vendor", "Orgo's GET /workspaces answered no workspaces list");
15
+ const workspaces = [];
16
+ for (const one of listed) {
17
+ if (typeof one?.id !== "string" || one.id === "" || (one.deleted_at !== null && one.deleted_at !== undefined))
18
+ continue;
19
+ const name = typeof one.name === "string" && one.name.trim() !== "" ? one.name.trim() : one.id;
20
+ const status = typeof one.status === "string" && one.status !== "active" ? one.status : undefined;
21
+ workspaces.push({ id: one.id, name, ...(status === undefined ? {} : { status }) });
22
+ }
23
+ return ok(workspaces);
24
+ }
25
+ /**
26
+ * The workspace a provider whose settings name none uses: the key's account's one workspace. Several are refused in
27
+ * words naming them and pointing at Settings, where a person picks one; none is refused saying to make one.
28
+ */
29
+ export async function soleWorkspace(rest, context) {
30
+ const listed = await orgoWorkspaces(rest, context);
31
+ if (!listed.ok)
32
+ return listed;
33
+ const [only, ...more] = listed.value;
34
+ if (only === undefined)
35
+ return fail("not_found", NO_WORKSPACE);
36
+ if (more.length === 0)
37
+ return ok(only.id);
38
+ return fail("invalid", `this Orgo key's account has ${listed.value.length} workspaces (${listed.value.map(workspaceWords).join(", ")}): pick the one its computers live in, in Settings → Computers (ORGO_WORKSPACE_ID)`);
39
+ }
40
+ /**
41
+ * keyChoices for an Orgo provider: workspaceId's choices, every workspace the key's account sees, each its id and its
42
+ * name; none is refused saying to make one. Orgo's descriptor picks no other option.
43
+ */
44
+ export async function workspaceChoices(rest, option, context) {
45
+ if (option !== "workspaceId")
46
+ return fail("unsupported", `an Orgo provider offers choices for workspaceId alone, not ${JSON.stringify(option)}`);
47
+ const listed = await orgoWorkspaces(rest, context);
48
+ if (!listed.ok)
49
+ return listed;
50
+ if (listed.value.length === 0)
51
+ return fail("not_found", NO_WORKSPACE);
52
+ return ok(listed.value.map((workspace) => ({ value: workspace.id, label: workspaceWords(workspace) })));
53
+ }
54
+ /**
55
+ * The workspace a provider's computers live in: `given` when its settings name one; else the key's account's sole one
56
+ * (soleWorkspace), read on the first call that needs it and kept. A read that fails is not kept: the next call reads again.
57
+ * Calls that come while a read is under way share it. The shared read is bounded by timeoutMs alone, never by one
58
+ * caller's signal, so one caller giving up never fails the others: a caller whose signal fires stops waiting, answered
59
+ * "aborted", and the read goes on for the rest.
60
+ */
61
+ export function workspaceHolder(given, rest, timeoutMs) {
62
+ let id = given;
63
+ let reading;
64
+ const shared = () => (reading ??= soleWorkspace(rest, { timeoutMs }).then((found) => {
65
+ reading = undefined;
66
+ if (found.ok)
67
+ id = found.value;
68
+ return found;
69
+ }));
70
+ return {
71
+ get id() {
72
+ return id;
73
+ },
74
+ async read(signal) {
75
+ if (id !== undefined)
76
+ return ok(id);
77
+ if (signal?.aborted)
78
+ return fail("aborted", "the Orgo workspace read was aborted before it was sent");
79
+ if (!signal)
80
+ return shared();
81
+ let stop = () => { };
82
+ const stopped = new Promise((resolve) => {
83
+ stop = () => resolve(fail("aborted", "the Orgo workspace read was aborted; it goes on for other callers"));
84
+ signal.addEventListener("abort", stop, { once: true });
85
+ });
86
+ try {
87
+ return await Promise.race([shared(), stopped]);
88
+ }
89
+ finally {
90
+ signal.removeEventListener("abort", stop);
91
+ }
92
+ },
93
+ };
94
+ }
package/dist/orgo.d.ts CHANGED
@@ -3,7 +3,7 @@ import { type MountKind } from "./mount.js";
3
3
  import { type OrgoChannel, type OrgoStart, type OrgoWebSocketFactory } from "./orgo-channel.js";
4
4
  import { OrgoDesktopProvider, type OrgoDesktopOptions } from "./orgo-desktop.js";
5
5
  import { type OrgoLedger } from "./orgo-names.js";
6
- import { type AttachContext, type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type CreatedComputer, type NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseContext, type ReleaseHow } from "./provider.js";
6
+ import { type AttachContext, type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type CreateContext, type CreatedComputer, type KeyChoice, type NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseContext, type ReleaseHow } from "./provider.js";
7
7
  import { type Result } from "./result.js";
8
8
  import { type ScreenWatch, type ScreenWatchHandlers, type WatchOptions } from "./screen-watch.js";
9
9
  /** The mount kinds an Orgo computer takes: none yet (an Archil mount needs an Orgo template that bakes the helper). */
@@ -39,8 +39,12 @@ export interface OrgoTimeouts {
39
39
  export interface OrgoProviderOptions {
40
40
  /** The Orgo API key. Serve passes ORGO_API_KEY's value; the provider never reads the environment or logs it. */
41
41
  apiKey: string;
42
- /** The workspace this deployment's computers live in; the provider lists, attaches and releases only there. */
43
- workspaceId: string;
42
+ /**
43
+ * The workspace this deployment's computers live in; the provider lists, attaches and releases only there. Absent:
44
+ * the key's account's one workspace, read from Orgo when first needed; with several or none, every call that needs
45
+ * it is refused in words (orgo-workspaces.ts soleWorkspace).
46
+ */
47
+ workspaceId?: string;
44
48
  /** Orgo's API, https; default https://www.orgo.ai/api. */
45
49
  apiUrl?: string;
46
50
  /** For tests: every REST call goes through it. Default the global fetch. */
@@ -99,7 +103,7 @@ export declare class OrgoProvider implements ComputerProvider {
99
103
  */
100
104
  capabilities(): ComputerCapabilities;
101
105
  check(spec: ComputerSpec): Refusal[];
102
- create(spec: ComputerSpec, { signal }?: CallContext): Promise<Result<CreatedComputer>>;
106
+ create(spec: ComputerSpec, context: CreateContext): Promise<Result<CreatedComputer>>;
103
107
  /** The live view: screen.watch on a connection of the watch's own (daemonWatch), never Orgo's VNC (proxy only). */
104
108
  watch(ref: ComputerRef, handlers: ScreenWatchHandlers, options?: WatchOptions): Promise<Result<ScreenWatch>>;
105
109
  connect(ref: ComputerRef): Promise<Result<ComputerConnection>>;
@@ -119,6 +123,8 @@ export declare class OrgoProvider implements ComputerProvider {
119
123
  testConnection(context?: CallContext): Promise<Result<{
120
124
  detail: string;
121
125
  }>>;
126
+ /** Settings' pick of ORGO_WORKSPACE_ID (workspaceId): every workspace the key's account sees, by name. Makes nothing. */
127
+ keyChoices(option: string, { signal }?: CallContext): Promise<Result<KeyChoice[]>>;
122
128
  network(ref: ComputerRef, policy?: NetworkSpec, { signal }?: CallContext): Promise<Result<NetworkPolicy>>;
123
129
  /**
124
130
  * delete: idempotent, a computer Orgo no longer has is done; it waits until Orgo no longer has it. detach, for an
package/dist/orgo.js CHANGED
@@ -14,7 +14,7 @@
14
14
  import { createHash, randomBytes, randomUUID } from "node:crypto";
15
15
  import { readFileSync } from "node:fs";
16
16
  import { fileURLToPath } from "node:url";
17
- import { childCommands, daemonDrift } from "./child.js";
17
+ import { childCommands, daemonDrift } from "./hosted/scripts.js";
18
18
  import { DaemonClient } from "./client.js";
19
19
  import { ORGO, ORGO_BASE_IMAGE } from "./descriptors/orgo.js";
20
20
  import { DESKTOP_GROUPS } from "./desktop.js";
@@ -23,6 +23,7 @@ import { EPOCH_LABEL, OWNER_LABEL, OWNER_SERVER_LABEL, ownerLabels, RUN_HASH_LAB
23
23
  import { checkMount } from "./mount.js";
24
24
  import { ORGO_API_URL, orgoRest, orgoTerminalChannel, START_LOG } from "./orgo-channel.js";
25
25
  import { OrgoDesktopProvider } from "./orgo-desktop.js";
26
+ import { workspaceChoices, workspaceHolder } from "./orgo-workspaces.js";
26
27
  import { COMPUTER_ID, filterProblem, labelProblem, labelsOf, NAME_MAX, NO_DEADLINE, nameParts, orgoMemoryLedger, orgoName, claimProblem, andSettled, inTurn, ownedListing, ownerHashOfLabels, ownerReadBack, refProblem, sameComputer, settleEntry, show, renewEntry, takeEntry, withDeadline, } from "./orgo-names.js";
27
28
  import { checkGpu, checkTenure, runLifetimeMs, } from "./provider.js";
28
29
  import { failFor, ok, vendorFail } from "./result.js";
@@ -181,7 +182,7 @@ export class OrgoProvider {
181
182
  version = VERSION;
182
183
  #rest;
183
184
  #channel;
184
- #workspaceId;
185
+ #workspace;
185
186
  #daemonPath;
186
187
  #maxLifetimeMs;
187
188
  #uid;
@@ -198,8 +199,8 @@ export class OrgoProvider {
198
199
  constructor({ apiKey, workspaceId, apiUrl = ORGO_API_URL, fetch, webSocket, channel, daemonPath = DEFAULT_DAEMON_PATH, maxLifetimeMs = MAX_LIFETIME_MS, user = "2510:2510", start = "bash", display = ":99", timeouts = {}, probeTargets = DEFAULT_PROBE_TARGETS, ledger = orgoMemoryLedger() }) {
199
200
  if (typeof apiKey !== "string" || apiKey === "")
200
201
  throw new Error("options.apiKey, an Orgo API key, is required");
201
- if (typeof workspaceId !== "string" || !WORKSPACE_ID.test(workspaceId))
202
- throw new Error("options.workspaceId, the Orgo workspace this deployment's computers live in, is required");
202
+ if (workspaceId !== undefined && (typeof workspaceId !== "string" || !WORKSPACE_ID.test(workspaceId)))
203
+ throw new Error("options.workspaceId, the Orgo workspace this deployment's computers live in, is an Orgo workspace id when given");
203
204
  let url;
204
205
  try {
205
206
  url = new URL(apiUrl);
@@ -229,8 +230,8 @@ export class OrgoProvider {
229
230
  throw new Error("probeTargets must name at least one address for the probe, each host:port or host:port/udp");
230
231
  }
231
232
  this.#rest = orgoRest({ apiKey, apiUrl: url.href, ...(fetch ? { fetch } : {}) });
232
- this.#channel = channel ?? orgoTerminalChannel({ rest: this.#rest, workspaceId, ...(webSocket ? { webSocket } : {}) });
233
- this.#workspaceId = workspaceId;
233
+ this.#workspace = workspaceHolder(workspaceId, this.#rest, merged.requestMs);
234
+ this.#channel = channel ?? orgoTerminalChannel({ rest: this.#rest, workspace: (signal) => this.#workspace.read(signal), ...(webSocket ? { webSocket } : {}) });
234
235
  this.#daemonPath = daemonPath;
235
236
  this.#maxLifetimeMs = maxLifetimeMs;
236
237
  [this.#uid, this.#gid] = [String(Number(ids[1])), String(Number(ids[2]))];
@@ -303,7 +304,8 @@ export class OrgoProvider {
303
304
  }
304
305
  return refusals;
305
306
  }
306
- async create(spec, { signal } = {}) {
307
+ async create(spec, context) {
308
+ const signal = context?.signal;
307
309
  const refusals = this.check(spec);
308
310
  if (refusals.length > 0)
309
311
  return fail("refused", refusals.map(({ field, message }) => `${field}: ${message}`).join("; "));
@@ -316,6 +318,9 @@ export class OrgoProvider {
316
318
  }
317
319
  if (signal?.aborted)
318
320
  return fail("aborted", "create was aborted before Orgo was called");
321
+ const workspace = await this.#workspace.read(signal);
322
+ if (!workspace.ok)
323
+ return workspace;
319
324
  // An agent's own computer outlives the run: no janitor's deadline and no Orgo end, the owner in its name and labels.
320
325
  // Init still takes one, maxLifetimeMs out, since it ends its programs at its deadline, with no most in practice:
321
326
  // each attach moves it maxLifetimeMs out again (#ownedInit).
@@ -332,7 +337,7 @@ export class OrgoProvider {
332
337
  const ram = spec.memoryMb === undefined ? 4 : spec.memoryMb / 1024;
333
338
  const cpu = spec.cpus ?? CPU_FOR_RAM[ram];
334
339
  const body = {
335
- workspace_id: this.#workspaceId,
340
+ workspace_id: workspace.value,
336
341
  name,
337
342
  os: "linux",
338
343
  ram,
@@ -582,7 +587,11 @@ export class OrgoProvider {
582
587
  }
583
588
  }
584
589
  /** Orgo's record of a computer; not_found once Orgo no longer has it. */
590
+ /** Orgo's record of a computer. The workspace is read first, so #ours knows it for every record read. */
585
591
  async #get(id, signal) {
592
+ const workspace = await this.#workspace.read(signal);
593
+ if (!workspace.ok)
594
+ return workspace;
586
595
  const read = await this.#rest.request("GET", `/computers/${encodeURIComponent(id)}`, { timeoutMs: this.#timeouts.requestMs, ...(signal ? { signal } : {}) });
587
596
  if (!read.ok)
588
597
  return read;
@@ -595,7 +604,8 @@ export class OrgoProvider {
595
604
  // A ref's name matches by its stable part: extend renames the computer with its new deadline.
596
605
  // A Windows or macOS computer in the workspace is the desktop provider's (orgo-desktop.ts), where Orgo says its os.
597
606
  return (nameParts(record.name) !== undefined &&
598
- (record.workspace_id ?? record.project_id) === this.#workspaceId &&
607
+ this.#workspace.id !== undefined &&
608
+ (record.workspace_id ?? record.project_id) === this.#workspace.id &&
599
609
  (name === undefined || sameComputer(record.name, name)) &&
600
610
  record.status !== "deleted" &&
601
611
  (record.os === undefined || record.os === "linux"));
@@ -710,13 +720,17 @@ export class OrgoProvider {
710
720
  }
711
721
  /** The workspace's computers, as Orgo lists them. */
712
722
  async #desktops(signal) {
713
- const read = await this.#rest.request("GET", `/workspaces/${encodeURIComponent(this.#workspaceId)}`, { timeoutMs: this.#timeouts.listMs, ...(signal ? { signal } : {}) });
723
+ const workspace = await this.#workspace.read(signal);
724
+ if (!workspace.ok)
725
+ return workspace;
726
+ const id = workspace.value;
727
+ const read = await this.#rest.request("GET", `/workspaces/${encodeURIComponent(id)}`, { timeoutMs: this.#timeouts.listMs, ...(signal ? { signal } : {}) });
714
728
  if (!read.ok)
715
729
  return read;
716
730
  const desktops = read.value?.desktops;
717
731
  if (!Array.isArray(desktops))
718
- return vendorFail("orgo", `Orgo's workspace ${this.#workspaceId} lists no computers array`);
719
- return ok(desktops.filter((one) => typeof one?.id === "string" && typeof one.name === "string").map((one) => ({ ...one, workspace_id: this.#workspaceId })));
732
+ return vendorFail("orgo", `Orgo's workspace ${id} lists no computers array`);
733
+ return ok(desktops.filter((one) => typeof one?.id === "string" && typeof one.name === "string").map((one) => ({ ...one, workspace_id: id })));
720
734
  }
721
735
  /** The live view: screen.watch on a connection of the watch's own (daemonWatch), never Orgo's VNC (proxy only). */
722
736
  watch(ref, handlers, options) {
@@ -1073,6 +1087,10 @@ export class OrgoProvider {
1073
1087
  async testConnection(context = {}) {
1074
1088
  return listTested("Orgo", await this.list({}, context));
1075
1089
  }
1090
+ /** Settings' pick of ORGO_WORKSPACE_ID (workspaceId): every workspace the key's account sees, by name. Makes nothing. */
1091
+ keyChoices(option, { signal } = {}) {
1092
+ return workspaceChoices(this.#rest, option, { timeoutMs: this.#timeouts.requestMs, ...(signal ? { signal } : {}) });
1093
+ }
1076
1094
  async network(ref, policy, { signal } = {}) {
1077
1095
  const problem = refProblem(ref);
1078
1096
  if (problem)
@@ -1,7 +1,7 @@
1
+ import type { Duplex } from "node:stream";
1
2
  import type { KindCapabilities } from "./kinds.js";
2
3
  import type { MountKind } from "./mount.js";
3
- import { type Rect, type UiNode } from "./protocol.js";
4
- import { type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type CreatedComputer, type NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseHow } from "./provider.js";
4
+ import { type AttachedComputer, type CallContext, type ComputerCapabilities, type ComputerConnection, type ComputerInfo, type ComputerProvider, type ComputerRef, type ComputerSpec, type CreateContext, type CreatedComputer, type NetworkPolicy, type NetworkSpec, type Refusal, type ReleaseHow } from "./provider.js";
5
5
  import { type Result } from "./result.js";
6
6
  import { type ScreenWatch, type ScreenWatchHandlers, type WatchOptions } from "./screen-watch.js";
7
7
  /** The phone harness's API. */
@@ -16,8 +16,10 @@ export declare const DEFAULT_MAX_LIFETIME_MS: number;
16
16
  export declare const DEFAULT_READY_MS = 240000;
17
17
  /** One phone this provider made, as its ledger keeps it. */
18
18
  export interface PhoneLedgerEntry {
19
- /** The session's id, the computer's id and name. */
19
+ /** The session's id, the computer's id. */
20
20
  id: string;
21
+ /** The computer's name, its request's (computerNameFor): a create of the same request finds the phone by it. */
22
+ name: string;
21
23
  labels: Record<string, string>;
22
24
  /** The image create was asked for, read back as asked. */
23
25
  image: string;
@@ -39,6 +41,8 @@ export interface PhoneLedgerEntry {
39
41
  /** Where the provider keeps its phones' labels: the vendor keeps none. Each call may be sync or async. */
40
42
  export interface PhoneLedger {
41
43
  put(entry: PhoneLedgerEntry): void | Promise<void>;
44
+ /** entry put only while the ledger holds none under its id, in one step (two writers never both put it): whether it was. */
45
+ claim(entry: PhoneLedgerEntry): boolean | Promise<boolean>;
42
46
  get(id: string): PhoneLedgerEntry | undefined | Promise<PhoneLedgerEntry | undefined>;
43
47
  list(): PhoneLedgerEntry[] | Promise<PhoneLedgerEntry[]>;
44
48
  remove(id: string): void | Promise<void>;
@@ -76,6 +80,16 @@ export interface AdbTransport {
76
80
  timeoutMs: number;
77
81
  transport?: string;
78
82
  }): Promise<Result<string>>;
83
+ /**
84
+ * A service of the phone on transport (exec:<command>) as a stream both ways: the adb server's socket, bound to the
85
+ * phone and then to the service, which carries the command's stdin and stdout raw once both answered OKAY. How phoned
86
+ * is started and spoken to. The stream comes paused, so nothing is lost before the caller listens: it resumes it. The
87
+ * words never hold the service.
88
+ */
89
+ open(service: string, options: {
90
+ timeoutMs: number;
91
+ transport: string;
92
+ }): Promise<Result<Duplex>>;
79
93
  }
80
94
  /** The adb server's port when none is given: adb's own default. */
81
95
  export declare const ADB_SERVER_PORT = 5037;
@@ -125,8 +139,15 @@ export interface PhoneProviderOptions {
125
139
  sleep?: (ms: number) => Promise<void>;
126
140
  /** A signal that fires after ms, which bounds a request; default AbortSignal.timeout. Tests give one they fire. */
127
141
  timeout?: (ms: number) => AbortSignal;
128
- /** The version the phone's hello reports; default the provider's. Only the conformance drift case sets another. */
142
+ /** The version phoned's hello must report; default the provider's own. Only the conformance drift case sets another. */
129
143
  daemonVersion?: string;
144
+ /** phoned, the phone's driver, as its jar (npm run build:phoned); default this package's dist/phoned.jar. */
145
+ phoned?: string;
146
+ /**
147
+ * APK files installed on each phone before phoned starts there (`pm install -r`), as the conformance run installs the
148
+ * ui fixture (npm run build:ui-fixture). Default none. A connect that cannot install one fails in words.
149
+ */
150
+ apks?: string[];
130
151
  }
131
152
  /** The phone-harness provider from its options alone; throws in words when one is missing or wrong. */
132
153
  export declare function create(options: PhoneProviderOptions): Promise<PhoneHarnessProvider>;
@@ -139,9 +160,12 @@ export declare class PhoneHarnessProvider implements ComputerProvider {
139
160
  constructor(options: PhoneProviderOptions);
140
161
  capabilities(): ComputerCapabilities;
141
162
  check(spec: ComputerSpec): Refusal[];
142
- create(spec: ComputerSpec, context?: {
143
- signal?: AbortSignal;
144
- }): Promise<Result<CreatedComputer>>;
163
+ /**
164
+ * Makes a phone, once per request (provider.md, Idempotent create): context.requestId names it (computerNameFor) and
165
+ * gives the POST's Idempotency-Key. A request whose phone the ledger holds answers that phone once it is ready; one
166
+ * released is refused exists; a create of a request in flight here waits for the first (CreateRequests).
167
+ */
168
+ create(spec: ComputerSpec, context: CreateContext): Promise<Result<CreatedComputer>>;
145
169
  attach(ref: {
146
170
  id: string;
147
171
  } | {
@@ -165,18 +189,3 @@ export declare class PhoneHarnessProvider implements ComputerProvider {
165
189
  detail: string;
166
190
  }>>;
167
191
  }
168
- /** The frame `adb exec-out screencap` gives: a header (width, height, format, and a color space on newer Androids), then the pixels. */
169
- export declare function decodeScreencap(raw: Buffer): Result<{
170
- width: number;
171
- height: number;
172
- rgba: Buffer;
173
- }>;
174
- /** An 8-bit RGBA PNG, non-interlaced, of rect of a width-wide RGBA frame. The rows are deflated off the event loop: a
175
- * 1080x2400 screen took about 170 ms, every request of the server this harness runs in waiting on it. */
176
- export declare function encodePng(rgba: Buffer, width: number, [x, y, w, h]: Rect): Promise<Buffer>;
177
- /** uiautomator's dump as the protocol's tree: one root (the window's, or one over several), at most MAX_UI_NODES nodes. */
178
- export declare function parseUiTree(xml: string, [width, height]: [number, number]): Result<{
179
- root: UiNode;
180
- nodes: number;
181
- truncated: boolean;
182
- }>;