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

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 (93) hide show
  1. package/README.md +259 -203
  2. package/box/Dockerfile +18 -1
  3. package/box/README.md +13 -0
  4. package/box/build-agent37.mjs +8 -27
  5. package/box/build-daytona.py +2 -2
  6. package/box/build-e2b.mjs +41 -18
  7. package/box/recipe.mjs +43 -0
  8. package/dist/agent37-ssh.d.ts +89 -0
  9. package/dist/agent37-ssh.js +445 -0
  10. package/dist/agent37.d.ts +2 -63
  11. package/dist/agent37.js +104 -461
  12. package/dist/browserbase.d.ts +0 -6
  13. package/dist/browserbase.js +1 -5
  14. package/dist/client.d.ts +12 -3
  15. package/dist/client.js +39 -4
  16. package/dist/computerd-linux-amd64 +0 -0
  17. package/dist/computerd-linux-arm64 +0 -0
  18. package/dist/computerd.json +4 -0
  19. package/dist/conformance/cases/apps.d.ts +6 -0
  20. package/dist/conformance/cases/apps.js +18 -5
  21. package/dist/conformance/cases/isolation.d.ts +7 -5
  22. package/dist/conformance/cases/isolation.js +44 -14
  23. package/dist/conformance/cases/mount.js +1 -1
  24. package/dist/conformance/cli.js +66 -6
  25. package/dist/conformance/daytona.d.ts +9 -20
  26. package/dist/conformance/daytona.js +12 -21
  27. package/dist/conformance/exec-stream.d.ts +45 -0
  28. package/dist/conformance/exec-stream.js +486 -0
  29. package/dist/conformance/sweep.js +8 -8
  30. package/dist/conformance/types.d.ts +2 -2
  31. package/dist/create-requests.d.ts +1 -1
  32. package/dist/daytona.d.ts +20 -131
  33. package/dist/daytona.js +405 -1450
  34. package/dist/descriptor.d.ts +6 -1
  35. package/dist/descriptor.js +7 -0
  36. package/dist/descriptors/agent37.d.ts +1 -1
  37. package/dist/descriptors/agent37.js +1 -1
  38. package/dist/descriptors/daytona.d.ts +6 -5
  39. package/dist/descriptors/daytona.js +9 -5
  40. package/dist/descriptors/index.d.ts +4 -5
  41. package/dist/descriptors/shared.d.ts +1 -1
  42. package/dist/descriptors/shared.js +2 -2
  43. package/dist/desktop.d.ts +18 -4
  44. package/dist/desktop.js +89 -9
  45. package/dist/docker.d.ts +0 -6
  46. package/dist/docker.js +1 -5
  47. package/dist/drift.js +4 -4
  48. package/dist/e2b.d.ts +10 -128
  49. package/dist/e2b.js +130 -233
  50. package/dist/host.d.ts +106 -87
  51. package/dist/host.js +8 -1
  52. package/dist/hosted/process.d.ts +22 -8
  53. package/dist/hosted/process.js +75 -44
  54. package/dist/hosted/provider.d.ts +35 -21
  55. package/dist/hosted/provider.js +312 -261
  56. package/dist/hosted/rest.d.ts +66 -0
  57. package/dist/hosted/rest.js +121 -0
  58. package/dist/hosted/scripts.d.ts +8 -2
  59. package/dist/hosted/scripts.js +27 -2
  60. package/dist/hosted/values.d.ts +5 -0
  61. package/dist/hosted/values.js +8 -0
  62. package/dist/index.d.ts +1 -1
  63. package/dist/index.js +1 -1
  64. package/dist/kernel.d.ts +0 -6
  65. package/dist/kernel.js +1 -5
  66. package/dist/kinds.d.ts +3 -1
  67. package/dist/local-chrome.d.ts +0 -6
  68. package/dist/local-chrome.js +1 -5
  69. package/dist/modal.d.ts +7 -84
  70. package/dist/modal.js +50 -174
  71. package/dist/mount-archil.d.ts +8 -4
  72. package/dist/mount-archil.js +22 -11
  73. package/dist/mount.d.ts +10 -4
  74. package/dist/mount.js +8 -4
  75. package/dist/orgo.d.ts +0 -9
  76. package/dist/orgo.js +2 -9
  77. package/dist/phone-harness.d.ts +0 -6
  78. package/dist/phone-harness.js +0 -4
  79. package/dist/protocol.d.ts +4 -1
  80. package/dist/protocol.js +1 -0
  81. package/dist/provider.d.ts +2 -2
  82. package/dist/providers.d.ts +11 -12
  83. package/dist/screen-watch.js +34 -6
  84. package/dist/surface/api.d.ts +14 -2
  85. package/dist/surface/core.d.ts +16 -3
  86. package/dist/surface/core.js +95 -13
  87. package/dist/surface/outline.d.ts +2 -0
  88. package/dist/surface/outline.js +2 -1
  89. package/dist/surface/script.js +2 -0
  90. package/dist/ui-engine.js +19 -3
  91. package/package.json +2 -3
  92. package/dist/conformance/daytona-sweep.d.ts +0 -18
  93. package/dist/conformance/daytona-sweep.js +0 -126
@@ -1,126 +0,0 @@
1
- // The sweep around a live Daytona run, with the conformance module's settings (COMPUTER_DAYTONA_*, never DAYTONA_*):
2
- //
3
- // node packages/computer/dist/conformance/daytona-sweep.js --before <file>
4
- // node packages/computer/dist/conformance/daytona-sweep.js --after <file>
5
- //
6
- // --before records the id of every sandbox carrying agentrun.computer=1 into <file>. --after lists them again, deletes
7
- // (release delete) every one whose id is not in <file> and that carries a conformance run's label (agentrun.conformance,
8
- // RUN_LABEL), then reads each of those back with GET /sandbox/{id} until Daytona answers 404, up to 60 s each, and
9
- // prints one JSON line, {"swept":n,"notFound":m,"stillThere":[ids],"leftAlone":k}: swept is every conformance sandbox
10
- // it found that was not there before, notFound + stillThere.length = swept, and leftAlone counts the new labelled
11
- // sandboxes with no conformance label, which another user of the account made during the run (a server's computers):
12
- // never touched. A sandbox in <file> is never touched either: no call names it. Exit 0 when every swept sandbox reads
13
- // back 404, 1 when one is still there, 2 on a usage error, a before file it cannot read, a missing key or a listing
14
- // Daytona refused (nothing is deleted then).
15
- import { readFileSync, writeFileSync } from "node:fs";
16
- import { COMPUTER_LABEL } from "../drift.js";
17
- import { isCommand } from "../entry.js";
18
- import { waitUntil } from "../wait.js";
19
- import { createProvider } from "./daytona.js";
20
- import { RUN_LABEL } from "./runner.js";
21
- const USAGE = `usage: node packages/computer/dist/conformance/daytona-sweep.js --before <file> | --after <file>
22
- --before <file> record the id of every sandbox carrying ${COMPUTER_LABEL}=1 into <file>
23
- --after <file> delete every sandbox carrying ${COMPUTER_LABEL}=1 and ${RUN_LABEL} whose id is not in <file>, read
24
- each back until Daytona answers 404 (up to 60 s each), and print
25
- {"swept":n,"notFound":m,"stillThere":[ids],"leftAlone":k}; a new one with no ${RUN_LABEL} is left alone
26
- settings: COMPUTER_DAYTONA_API_KEY (required) and COMPUTER_DAYTONA_API_URL, as the conformance module reads them
27
- exit: 0 every swept sandbox is gone, 1 one is still there, 2 usage error, unreadable before file, no key, or a refused listing`;
28
- class Usage extends Error {
29
- }
30
- const write = (stream, text) => new Promise((resolve) => void stream.write(text, () => resolve()));
31
- function parse(argv) {
32
- let found;
33
- for (let i = 0; i < argv.length; i++) {
34
- const [flag = "", inline] = (argv[i] ?? "").split(/=(.*)/s, 2);
35
- if (flag !== "--before" && flag !== "--after")
36
- throw new Usage(`unknown option ${flag}`);
37
- const file = inline ?? argv[++i];
38
- if (file === undefined || file === "" || file.startsWith("--"))
39
- throw new Usage(`${flag} needs a file`);
40
- if (found !== undefined)
41
- throw new Usage("give --before <file> or --after <file>, one of them");
42
- found = { mode: flag === "--before" ? "before" : "after", file };
43
- }
44
- if (found === undefined)
45
- throw new Usage("give --before <file> or --after <file>, one of them");
46
- return found;
47
- }
48
- /** The ids a before file holds, or why it is not one. */
49
- function beforeIds(file) {
50
- let text;
51
- try {
52
- text = readFileSync(file, "utf8");
53
- }
54
- catch (error) {
55
- throw new Usage(`cannot read the before file ${file}: ${error.message}`);
56
- }
57
- let record;
58
- try {
59
- record = JSON.parse(text);
60
- }
61
- catch {
62
- record = undefined;
63
- }
64
- const ids = record?.ids;
65
- if (!Array.isArray(ids) || !ids.every((id) => typeof id === "string" && id !== ""))
66
- throw new Usage(`${file} is not a before file: it holds no "ids" array of sandbox ids`);
67
- return new Set(ids);
68
- }
69
- export async function main(argv, io = {}) {
70
- const { env = process.env, stdout = process.stdout, stderr = process.stderr, waitMs = 60_000, pollMs = 2_000 } = io;
71
- let args;
72
- let before;
73
- let provider;
74
- try {
75
- args = parse(argv);
76
- if (args.mode === "after")
77
- before = beforeIds(args.file);
78
- // A release waits for the sandbox to go, for as long as the sweep's own wait.
79
- provider = createProvider({ env, timeouts: { goneMs: waitMs, pollMs }, ...(io.fetch ? { fetch: io.fetch } : {}), ...(io.webSocket ? { webSocket: io.webSocket } : {}) });
80
- }
81
- catch (error) {
82
- await write(stderr, `${error.message}\n${error instanceof Usage ? `${USAGE}\n` : ""}`);
83
- return 2;
84
- }
85
- const listed = await provider.listLabelled();
86
- if (!listed.ok) {
87
- await write(stderr, `listing the sandboxes carrying ${COMPUTER_LABEL}=1 failed, so nothing was ${args.mode === "after" ? "deleted" : "recorded"}: ${listed.error.message}\n`);
88
- return 2;
89
- }
90
- if (before === undefined) {
91
- const ids = [...new Set(listed.value.map((sb) => sb.id))].sort();
92
- writeFileSync(args.file, `${JSON.stringify({ label: `${COMPUTER_LABEL}=1`, at: new Date().toISOString(), ids }, null, 2)}\n`);
93
- await write(stdout, `${JSON.stringify({ recorded: ids.length, file: args.file })}\n`);
94
- return 0;
95
- }
96
- const known = before;
97
- const added = [...new Map(listed.value.filter((sb) => !known.has(sb.id)).map((sb) => [sb.id, sb])).values()];
98
- // Only a conformance run's computers: one another user of the account made during the run is not this sweep's.
99
- const fresh = added.filter((sb) => Object.hasOwn(sb.labels, RUN_LABEL));
100
- const leftAlone = added.length - fresh.length;
101
- for (const sb of fresh) {
102
- const released = await provider.release({ id: sb.id, name: sb.name ?? "" }, "delete");
103
- if (!released.ok)
104
- await write(stderr, `${sb.id} (${sb.name ?? "no name"}) was not deleted: ${released.error.message}\n`);
105
- }
106
- // Each one read back on its own, at once, through waitUntil: a 404 is gone; anything else, or no answer, is read
107
- // again every pollMs until its wait ends.
108
- const gone = await Promise.all(fresh.map(async (sb) => {
109
- const waited = await waitUntil(() => provider.probe(sb.id), (read) => read.ok && read.value.status === 404, {
110
- boundMs: waitMs,
111
- minMs: pollMs,
112
- maxMs: pollMs,
113
- what: `${sb.id} to be gone`,
114
- describe: (read) => `GET /sandbox/${sb.id} answered ${read.ok ? `${read.value.status}${read.value.state ? ` (${read.value.state})` : ""}` : read.error.message}`,
115
- });
116
- if (!waited.ok)
117
- await write(stderr, `${sb.id} is still there: ${waited.error.message}\n`);
118
- return waited.ok;
119
- }));
120
- const stillThere = fresh.filter((_, i) => !gone[i]).map((sb) => sb.id);
121
- await write(stdout, `${JSON.stringify({ swept: fresh.length, notFound: fresh.length - stillThere.length, stillThere, leftAlone })}\n`);
122
- return stillThere.length === 0 ? 0 : 1;
123
- }
124
- if (isCommand(import.meta)) {
125
- process.exitCode = await main(process.argv.slice(2));
126
- }