@parcha/agentrun-serve 0.1.0-beta.46 → 0.1.0-beta.47

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 (247) hide show
  1. package/CHANGELOG.md +164 -1
  2. package/NOTICE +4 -0
  3. package/README.md +267 -40
  4. package/dist/acp-package.d.ts +35 -6
  5. package/dist/acp-package.js +3 -3
  6. package/dist/adapter-facts.d.ts +5 -2
  7. package/dist/adapter-facts.js +6 -3
  8. package/dist/adapters.d.ts +7 -0
  9. package/dist/adapters.js +39 -0
  10. package/dist/agents-store.d.ts +5 -3
  11. package/dist/agents-store.js +13 -8
  12. package/dist/api-only.d.ts +7 -10
  13. package/dist/api-only.js +7 -10
  14. package/dist/archil-routes.js +2 -1
  15. package/dist/cap.js +12 -2
  16. package/dist/chatgpt-plan.js +2 -1
  17. package/dist/cli.js +109 -41
  18. package/dist/composio-made.d.ts +19 -2
  19. package/dist/composio-made.js +17 -5
  20. package/dist/composio-preset.d.ts +42 -7
  21. package/dist/composio-preset.js +106 -70
  22. package/dist/composio-triggers.d.ts +9 -4
  23. package/dist/composio-triggers.js +20 -13
  24. package/dist/computer-attach.d.ts +11 -10
  25. package/dist/computer-attach.js +13 -14
  26. package/dist/computer-commands.d.ts +3 -0
  27. package/dist/computer-commands.js +3 -2
  28. package/dist/computer-lost.d.ts +4 -0
  29. package/dist/computer-lost.js +8 -3
  30. package/dist/computer-setting.d.ts +2 -0
  31. package/dist/computer-setting.js +2 -0
  32. package/dist/computers.d.ts +9 -75
  33. package/dist/computers.js +20 -66
  34. package/dist/console/assets/index-BBFzAxLB.js +715 -0
  35. package/dist/console/assets/index-BRi-Rgq6.css +1 -0
  36. package/dist/console/index.html +2 -2
  37. package/dist/cost-heal.d.ts +13 -0
  38. package/dist/cost-heal.js +27 -0
  39. package/dist/dial-relay.d.ts +6 -2
  40. package/dist/dial-relay.js +9 -12
  41. package/dist/email/routes.js +2 -1
  42. package/dist/errors.d.ts +2 -0
  43. package/dist/errors.js +5 -0
  44. package/dist/exa-keyless.d.ts +1 -1
  45. package/dist/exa-keyless.js +1 -1
  46. package/dist/faux-computers.d.ts +2 -3
  47. package/dist/faux-computers.js +9 -31
  48. package/dist/github-connection.js +2 -1
  49. package/dist/harness-archive.d.ts +19 -2
  50. package/dist/harness-archive.js +49 -15
  51. package/dist/harness-check.d.ts +73 -0
  52. package/dist/harness-check.js +489 -0
  53. package/dist/harness-cursor.d.ts +45 -0
  54. package/dist/harness-cursor.js +121 -0
  55. package/dist/harness-recipe.d.ts +127 -0
  56. package/dist/harness-recipe.js +357 -0
  57. package/dist/harness-table.d.ts +12 -0
  58. package/dist/harness-table.js +62 -2
  59. package/dist/harness.d.ts +2 -0
  60. package/dist/harness.js +3 -2
  61. package/dist/host-check.d.ts +6 -0
  62. package/dist/host-check.js +14 -0
  63. package/dist/host.d.ts +10 -3
  64. package/dist/host.js +17 -3
  65. package/dist/import-sources.d.ts +2 -0
  66. package/dist/import-sources.js +2 -0
  67. package/dist/import-summary.d.ts +15 -5
  68. package/dist/import-summary.js +24 -8
  69. package/dist/import.d.ts +24 -4
  70. package/dist/import.js +108 -26
  71. package/dist/key-refusal.d.ts +1 -0
  72. package/dist/key-refusal.js +8 -3
  73. package/dist/key-words.d.ts +1 -1
  74. package/dist/key-words.js +4 -4
  75. package/dist/learn/check.d.ts +3 -0
  76. package/dist/learn/check.js +31 -20
  77. package/dist/learn/compile.js +12 -5
  78. package/dist/learn/promote.d.ts +69 -2
  79. package/dist/learn/promote.js +95 -3
  80. package/dist/learned-nodes.d.ts +4 -3
  81. package/dist/learned-workflow.js +4 -1
  82. package/dist/learning-cost.d.ts +6 -16
  83. package/dist/learning-cost.js +6 -12
  84. package/dist/learning-words.d.ts +2 -0
  85. package/dist/learning-words.js +1 -1
  86. package/dist/listen-first.d.ts +10 -0
  87. package/dist/listen-first.js +25 -1
  88. package/dist/llms.txt +1 -1
  89. package/dist/mcp-gateway.d.ts +2 -1
  90. package/dist/mcp-gateway.js +31 -15
  91. package/dist/mcp-probe.d.ts +18 -6
  92. package/dist/mcp-probe.js +41 -8
  93. package/dist/mcp-secret-writes.d.ts +8 -0
  94. package/dist/mcp-secret-writes.js +104 -4
  95. package/dist/mcp-servers-store.d.ts +11 -5
  96. package/dist/mcp-servers-store.js +46 -20
  97. package/dist/model-form.d.ts +2 -1
  98. package/dist/model-form.js +22 -8
  99. package/dist/model-gateway.d.ts +113 -0
  100. package/dist/model-gateway.js +433 -0
  101. package/dist/model.d.ts +2 -1
  102. package/dist/model.js +9 -7
  103. package/dist/monid.js +1 -1
  104. package/dist/native/binding.d.ts +4 -0
  105. package/dist/native/binding.js +9 -0
  106. package/dist/native/cli.d.ts +3 -2
  107. package/dist/native/cli.js +6 -5
  108. package/dist/openapi.d.ts +2 -0
  109. package/dist/openapi.js +322 -39
  110. package/dist/owner.d.ts +4 -2
  111. package/dist/owner.js +10 -4
  112. package/dist/page.d.ts +8 -0
  113. package/dist/page.js +9 -1
  114. package/dist/port-models.js +17 -10
  115. package/dist/provider.d.ts +3 -3
  116. package/dist/provider.js +12 -3
  117. package/dist/public-address.d.ts +28 -0
  118. package/dist/public-address.js +62 -0
  119. package/dist/run-launch.d.ts +1 -1
  120. package/dist/run-launch.js +1 -1
  121. package/dist/run-secrets.d.ts +3 -2
  122. package/dist/run-secrets.js +6 -4
  123. package/dist/runner/adapter-loop.d.ts +10 -7
  124. package/dist/runner/adapter-loop.js +57 -22
  125. package/dist/runner/adapter-run-spec.d.ts +12 -0
  126. package/dist/runner/adapter-run-spec.js +40 -6
  127. package/dist/runner/adapters/index.js +16 -0
  128. package/dist/runner/adapters/pi.d.ts +5 -2
  129. package/dist/runner/adapters/pi.js +7 -4
  130. package/dist/runner/audit.d.ts +7 -0
  131. package/dist/runner/audit.js +15 -6
  132. package/dist/runner/claim-secrets.js +5 -1
  133. package/dist/runner/cli-run-spec.js +15 -7
  134. package/dist/runner/compare-end.d.ts +43 -0
  135. package/dist/runner/compare-end.js +95 -0
  136. package/dist/runner/computer-journal.d.ts +3 -0
  137. package/dist/runner/computer-journal.js +22 -2
  138. package/dist/runner/harness-loops.d.ts +6 -1
  139. package/dist/runner/harness-loops.js +94 -54
  140. package/dist/runner/held.d.ts +5 -4
  141. package/dist/runner/journal-kinds.d.ts +4 -1
  142. package/dist/runner/journal-kinds.js +3 -0
  143. package/dist/runner/loop-contract.d.ts +10 -0
  144. package/dist/runner/main.d.ts +5 -5
  145. package/dist/runner/main.js +62 -11
  146. package/dist/runner/mcp-claim.js +40 -12
  147. package/dist/runner/metrics.d.ts +26 -0
  148. package/dist/runner/metrics.js +44 -1
  149. package/dist/runner/presence.d.ts +41 -0
  150. package/dist/runner/presence.js +89 -0
  151. package/dist/runner/promotion.d.ts +9 -4
  152. package/dist/runner/promotion.js +33 -14
  153. package/dist/runner/run-child-host.js +40 -10
  154. package/dist/runner/runner.d.ts +5 -0
  155. package/dist/runner/runner.js +8 -0
  156. package/dist/runner/store-port.d.ts +3 -0
  157. package/dist/runner/store-secrets.js +19 -7
  158. package/dist/runner/workflow-first.d.ts +5 -2
  159. package/dist/runner/workflow-first.js +6 -3
  160. package/dist/runs-over-store.d.ts +6 -2
  161. package/dist/runs-over-store.js +14 -4
  162. package/dist/sdk/runs.d.ts +1 -1
  163. package/dist/sdk/runs.js +6 -1
  164. package/dist/sdk/schema.js +1 -1
  165. package/dist/secret-writes.d.ts +16 -3
  166. package/dist/secret-writes.js +28 -3
  167. package/dist/server-secrets-store.js +5 -0
  168. package/dist/server.d.ts +31 -2
  169. package/dist/server.js +322 -51
  170. package/dist/sign-ins-secrets.js +4 -1
  171. package/dist/skills/agentrun-serve/SKILL.md +11 -0
  172. package/dist/slack-url.d.ts +5 -0
  173. package/dist/slack-url.js +11 -0
  174. package/dist/slack.d.ts +107 -0
  175. package/dist/slack.js +292 -0
  176. package/dist/start-switches.d.ts +28 -0
  177. package/dist/start-switches.js +37 -0
  178. package/dist/stats.d.ts +1 -1
  179. package/dist/stats.js +2 -1
  180. package/dist/stop-signals.d.ts +11 -0
  181. package/dist/stop-signals.js +22 -0
  182. package/dist/store/agent-body.d.ts +1 -1
  183. package/dist/store/agent-body.js +2 -2
  184. package/dist/store/index.d.ts +3 -3
  185. package/dist/store/index.js +1 -1
  186. package/dist/store/postgres/migrations/0020_runners.sql +18 -0
  187. package/dist/store/postgres/store.d.ts +1 -1
  188. package/dist/store/postgres/store.js +4 -2
  189. package/dist/store/schema.d.ts +13 -5
  190. package/dist/store/schema.js +20 -11
  191. package/dist/store/seal.d.ts +16 -4
  192. package/dist/store/sqlite/store.d.ts +1 -1
  193. package/dist/store/sqlite/store.js +106 -27
  194. package/dist/store/store.d.ts +75 -23
  195. package/dist/store/store.js +11 -0
  196. package/dist/store-reads/analytics.js +3 -2
  197. package/dist/store-reads/cap.d.ts +7 -0
  198. package/dist/store-reads/cap.js +11 -1
  199. package/dist/store-reads/journal.js +27 -1
  200. package/dist/store-reads/learning.d.ts +23 -2
  201. package/dist/store-reads/learning.js +29 -8
  202. package/dist/store-reads/runs.d.ts +9 -0
  203. package/dist/store-reads/runs.js +19 -6
  204. package/dist/store-reads/stats.d.ts +4 -1
  205. package/dist/store-reads/stats.js +15 -6
  206. package/dist/store-view.d.ts +123 -14
  207. package/dist/store-view.js +154 -21
  208. package/dist/telemetry.d.ts +7 -7
  209. package/dist/telemetry.js +38 -15
  210. package/dist/timeline/timeline.js +18 -0
  211. package/dist/tool-keys-store.js +2 -2
  212. package/dist/tool-keys.js +2 -1
  213. package/dist/tool-plane.js +2 -2
  214. package/dist/trigger-adapter.d.ts +3 -4
  215. package/dist/trigger-adapter.js +2 -2
  216. package/dist/trigger-composio.js +3 -3
  217. package/dist/trigger-email.js +0 -2
  218. package/dist/trigger-feed.js +0 -2
  219. package/dist/trigger-schedule.js +3 -0
  220. package/dist/trigger-secrets-shown.d.ts +6 -3
  221. package/dist/trigger-secrets-shown.js +22 -13
  222. package/dist/trigger-targets.d.ts +1 -1
  223. package/dist/trigger-targets.js +19 -8
  224. package/dist/triggers.d.ts +2 -2
  225. package/dist/webhooks.d.ts +82 -8
  226. package/dist/webhooks.js +128 -45
  227. package/dist/wires.d.ts +6 -1
  228. package/dist/wires.js +5 -0
  229. package/dist/workspace/attach.d.ts +3 -2
  230. package/dist/workspace/attach.js +2 -1
  231. package/dist/workspace/attached-computers.d.ts +6 -8
  232. package/dist/workspace/attached-computers.js +27 -24
  233. package/dist/workspace/computer-deps.d.ts +2 -3
  234. package/dist/workspace/computer-deps.js +3 -6
  235. package/dist/workspace/computer-for-claim.js +72 -96
  236. package/dist/workspace/computer-kept.d.ts +0 -7
  237. package/dist/workspace/computer-kept.js +0 -17
  238. package/dist/workspace/resolve-computer.d.ts +18 -14
  239. package/dist/workspace/resolve-computer.js +47 -60
  240. package/dist/workspace/synced-folder.d.ts +20 -15
  241. package/dist/workspace/synced-folder.js +33 -43
  242. package/launcher/agentrun-serve +4 -1
  243. package/package.json +10 -10
  244. package/skills/agentrun-serve/SKILL.md +11 -0
  245. package/templates/README.md +1 -1
  246. package/dist/console/assets/index-C2MYaUBa.css +0 -1
  247. package/dist/console/assets/index-CZZeCReB.js +0 -701
@@ -3,7 +3,7 @@ import type { Duplex } from "node:stream";
3
3
  import { type AttachHub, type AttachSocket, type HelloResult, type MachineTokens } from "@parcha/agentrun-computer";
4
4
  import { WebSocket } from "ws";
5
5
  import { type LiveReach } from "./live-reach.js";
6
- import type { MintedTokens, PairedComputerRow, PairedComputers, RunnerRelays } from "./store/index.js";
6
+ import type { MintedTokens, PairedComputerRow, PairedComputers, RunnerRow, Runners } from "./store/index.js";
7
7
  /** The characters of a pairing code: no 0, O, 1 or I, so a person reads it off a screen without a doubt. */
8
8
  export declare const PAIRING_ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
9
9
  /** A computer's token starts with this, so a secret scanner knows one. */
@@ -22,10 +22,6 @@ export declare function newPairingCode(pick?: (below: number) => number): string
22
22
  export declare function pairingCodeOf(typed: unknown): string | undefined;
23
23
  /** A new paired computer's id: PAIRED_ID_PREFIX and 16 lowercase letters and digits. */
24
24
  export declare const newPairedId: (pick?: (below: number) => number) => string;
25
- /** A new computer token: ATTACH_TOKEN_PREFIX and 32 random bytes. */
26
- export declare const newAttachToken: () => string;
27
- /** A new hosted machine's token: ATTACH_TOKEN_PREFIX and 32 random bytes in hex, which goes in the machine's env. */
28
- export declare const newMintedToken: () => string;
29
25
  /** `reason` cut to what a close frame holds (123 bytes of UTF-8), never inside a character. */
30
26
  export declare function closeReason(reason: string): string;
31
27
  /** A limit of `perMinute` tries a minute by key: the pair route's by source address (`keyOf` peerKey: an IPv6 one by its
@@ -139,16 +135,21 @@ export interface AttachRoutesOptions {
139
135
  /** The server's relay of a dial whose token another runner minted: where each runner's attach listener answers, and
140
136
  * the hosts it may dial with the proxy's proof (live-reach.ts). Without it such a dial is refused 503. */
141
137
  readonly relay?: {
142
- readonly relays: Pick<RunnerRelays, "get">;
138
+ readonly runners: Pick<Runners, "live">;
143
139
  readonly reach: LiveReach;
144
140
  };
145
141
  }
146
142
  /** A request's Bearer token, or undefined. */
147
143
  export declare const bearerOf: (authorization: string | undefined) => string | undefined;
148
- /** How often a runner's attach listener says it is there (its runner_relays row's seen_at), and how long after its last
149
- * word the server takes it as gone. */
150
- export declare const RELAY_RENEW_MS = 10000;
151
- export declare const RELAY_STALE_MS: number;
144
+ /** A runner's row that says where its relay answers. */
145
+ export type RelayRow = RunnerRow & {
146
+ readonly host: string;
147
+ readonly port: number;
148
+ };
149
+ /** The runners whose relay takes dials now: their rows seen within PRESENCE_STALE_MS on the store's clock (Runners.live,
150
+ * the database's on Postgres), never one process's, that say where their relay answers. The server relays a dial only
151
+ * to one of these, and says a dial provider is served while one answers at a host it dials (server.ts relayed). */
152
+ export declare function liveRelays(runners: Pick<Runners, "live">): Promise<RelayRow[]>;
152
153
  /** How long the server waits for a runner's attach listener to take a relayed dial. */
153
154
  export declare const RELAY_CONNECT_MS = 10000;
154
155
  /** Two WebSockets joined frame by frame, each an attach socket with `timing` (attachSocketOf: its idle close, its binary
@@ -24,12 +24,13 @@
24
24
  // over MAX_LINE_BYTES, a binary frame, ATTACH_IDLE_MS of silence), joined frame by frame: a close of either closes the
25
25
  // other with its code.
26
26
  import { createHash, randomBytes, randomInt } from "node:crypto";
27
- import { ATTACH_CLOSE, ATTACH_HEARTBEAT_MS, ATTACH_IDLE_MS, ATTACH_PATH, ATTACH_SUBPROTOCOL, hostedDaemonPath, MAX_LINE_BYTES, mintedComputer, PAIRING_CODE_PATTERN, PAIRING_CODE_TTL_MS, PROTOCOL_VERSION, RUN_LABEL } from "@parcha/agentrun-computer";
27
+ import { ATTACH_CLOSE, ATTACH_HEARTBEAT_MS, ATTACH_IDLE_MS, ATTACH_PATH, ATTACH_SUBPROTOCOL, hostedDaemonPath, MAX_LINE_BYTES, mintedComputer, newMachineToken, PAIRING_CODE_PATTERN, PAIRING_CODE_TTL_MS, PROTOCOL_VERSION, RUN_LABEL } from "@parcha/agentrun-computer";
28
28
  import { WebSocket, WebSocketServer } from "ws";
29
29
  import { ApiError, invalid } from "./errors.js";
30
30
  import { dialHost, LIVE_PROOF_HEADER, relayProof } from "./live-reach.js";
31
31
  import { peerKey } from "./owner.js";
32
32
  import { registerNotSecretWrite } from "./secret-writes.js";
33
+ import { PRESENCE_STALE_MS } from "./runner/presence.js";
33
34
  import { pairedOf, PAIRED_ID_PREFIX, RUNNER_APART_WORDS, servesNoKind } from "./workspace/attached-computers.js";
34
35
  // Routes under /computers, where a provider's keys are a secret write (computers.ts): these three write none of the
35
36
  // owner's secrets, so the API token may call them as the console's session does.
@@ -70,10 +71,6 @@ export function pairingCodeOf(typed) {
70
71
  }
71
72
  /** A new paired computer's id: PAIRED_ID_PREFIX and 16 lowercase letters and digits. */
72
73
  export const newPairedId = (pick = randomInt) => `${PAIRED_ID_PREFIX}${Array.from({ length: 16 }, () => "abcdefghijkmnpqrstuvwxyz23456789"[pick(32)]).join("")}`;
73
- /** A new computer token: ATTACH_TOKEN_PREFIX and 32 random bytes. */
74
- export const newAttachToken = () => `${ATTACH_TOKEN_PREFIX}${randomBytes(32).toString("base64url")}`;
75
- /** A new hosted machine's token: ATTACH_TOKEN_PREFIX and 32 random bytes in hex, which goes in the machine's env. */
76
- export const newMintedToken = () => `${ATTACH_TOKEN_PREFIX}${randomBytes(32).toString("hex")}`;
77
74
  /** The computerd builds a minted machine fetches (GET /v2/computers/daemon?arch=), each at hostedDaemonPath: the file a
78
75
  * hosted provider uploads by default, so the route serves the bytes whose SHA-256 the provider puts in the machine's env. */
79
76
  const DAEMON_ARCHES = ["amd64", "arm64"];
@@ -274,10 +271,12 @@ export function attachSocketOf(ws, timing = { heartbeatMs: ATTACH_HEARTBEAT_MS,
274
271
  }
275
272
  /** A request's Bearer token, or undefined. */
276
273
  export const bearerOf = (authorization) => /^Bearer (\S+)$/.exec(String(authorization ?? ""))?.[1];
277
- /** How often a runner's attach listener says it is there (its runner_relays row's seen_at), and how long after its last
278
- * word the server takes it as gone. */
279
- export const RELAY_RENEW_MS = 10_000;
280
- export const RELAY_STALE_MS = 3 * RELAY_RENEW_MS;
274
+ /** The runners whose relay takes dials now: their rows seen within PRESENCE_STALE_MS on the store's clock (Runners.live,
275
+ * the database's on Postgres), never one process's, that say where their relay answers. The server relays a dial only
276
+ * to one of these, and says a dial provider is served while one answers at a host it dials (server.ts relayed). */
277
+ export async function liveRelays(runners) {
278
+ return (await runners.live(PRESENCE_STALE_MS)).filter((row) => row.host !== null && row.port !== null);
279
+ }
281
280
  /** How long the server waits for a runner's attach listener to take a relayed dial. */
282
281
  export const RELAY_CONNECT_MS = 10_000;
283
282
  /** A close code one side of a relay may send the other: its own, or 1001 for one a peer may not send (1005, 1006). */
@@ -337,7 +336,7 @@ export function createAttachRoutes(options) {
337
336
  if (unserved)
338
337
  throw invalid([{ field: "hello.groups", reason: "invalid", message: unserved }]);
339
338
  const id = newPairedId();
340
- const token = newAttachToken();
339
+ const token = newMachineToken();
341
340
  const made = await paired.pair(sha256Hex(code), { id, name, hello: hello, labels: {}, tokenSha256: sha256Hex(token) });
342
341
  if (!made)
343
342
  throw new ApiError("not_found", "no such pairing code: make a new one on the console's Computers page");
@@ -360,7 +359,7 @@ export function createAttachRoutes(options) {
360
359
  const until = expiresAt.getTime();
361
360
  if (!Number.isFinite(until))
362
361
  throw new TypeError(`a machine token's expiresAt is a time, not ${JSON.stringify(expiresAt)}`);
363
- const token = newMintedToken();
362
+ const token = newMachineToken();
364
363
  await minted.mint({ machine, tokenSha256: sha256Hex(token), kind, os, arch, expiresAt: until, ...(options.owner ?? {}), ...(run !== undefined ? { run } : {}) });
365
364
  log("machine_token_minted", { ...(run !== undefined ? { run } : {}), machine, kind, os, arch, expires_at: new Date(until).toISOString() });
366
365
  return token;
@@ -417,9 +416,9 @@ export function createAttachRoutes(options) {
417
416
  };
418
417
  if (options.relay === undefined)
419
418
  return refuse(`runner ${runner} made it, and this server relays no dial to a runner`);
420
- const at = await options.relay.relays.get(runner);
421
- if (at === undefined || at.seenAt < now() - RELAY_STALE_MS)
422
- return refuse(`runner ${runner}, which made it, is not running now (no attach listener of its has said it is there for ${RELAY_STALE_MS / 1000} s): its run makes a new machine at its next claim`);
419
+ const at = (await liveRelays(options.relay.runners)).find((row) => row.runner === runner);
420
+ if (at === undefined)
421
+ return refuse(`runner ${runner}, which made it, is not running now (no attach listener of its has said it is there for ${PRESENCE_STALE_MS / 1000} s): its run makes a new machine at its next claim`);
423
422
  if (at.incarnation !== row.incarnation)
424
423
  return refuse(`runner ${runner}, which made it, restarted since, and the machine was its earlier process's: its run makes a new machine at its next claim`);
425
424
  const host = dialHost(at.host, options.relay.reach);
@@ -25,6 +25,9 @@ export interface JournalEntry {
25
25
  readonly kind: string;
26
26
  readonly data: unknown;
27
27
  }
28
+ /** Who may drive, and how a take may end, as a journal entry (or a run's own process) may say them. */
29
+ export declare const STATES: readonly string[];
30
+ export declare const ENDS: readonly string[];
28
31
  /** The hold as the run's journal has it. */
29
32
  export type HoldRead = {
30
33
  /** Whether the run's computer is up (its last up entry). */
@@ -37,8 +37,9 @@ export const takeEndedWords = (computer, why) => why === "given" || why === "ans
37
37
  /** An ask already answered: 409, in the browser's route's words. */
38
38
  const answeredWords = (outcome) => outcome === "expired" ? "The agent's hand-over expired before this answer: the agent was told it expired." : `The agent's hand-over was already answered ${outcome}.`;
39
39
  const dataOf = (entry) => (entry.data && typeof entry.data === "object" ? entry.data : {});
40
- const STATES = ["agent", "pending", "person"];
41
- const ENDS = ["given", "answered", "idle", "away", "released"];
40
+ /** Who may drive, and how a take may end, as a journal entry (or a run's own process) may say them. */
41
+ export const STATES = ["agent", "pending", "person"];
42
+ export const ENDS = ["given", "answered", "idle", "away", "released"];
42
43
  const OUTCOMES = ["done", "cancelled", "expired"];
43
44
  /** The run's hold, from its journal's computer.hold entries. */
44
45
  export function holdIn(entries) {
@@ -2,6 +2,10 @@
2
2
  export declare const LOST_RECREATES = 2;
3
3
  /** The code a run past its new sandboxes fails with: the one a computer that cannot be had at the claim is refused with. */
4
4
  export declare const COMPUTER_UNAVAILABLE_CODE = "computer_unavailable";
5
+ /** The answer of the call in flight when its sandbox, `name`, was found lost, `why` the provider's words. Its code is
6
+ * gone, never not_found, so no caller reads it as a file or a program that is not there (a shell's fallback from bash
7
+ * to sh would send the command again, to the new sandbox). */
8
+ export declare const lostInCallWords: (name: string, why: string) => string;
5
9
  /** The Timeline's row once a new sandbox replaced a lost one: its name. */
6
10
  export declare const lostRecreatedWords: (name: string) => string;
7
11
  /** The run's end once its sandbox was lost again after `recreates` new ones (the claim's bound): the provider's words,
@@ -1,7 +1,8 @@
1
1
  // A run's sandbox that its provider lost mid-run (deleted by the vendor's own API or console, or gone with no why): the
2
- // claim starts a new one in its place at the next tool call (workspace/computer-for-claim.ts lostAware), up to
3
- // LOST_RECREATES times a claim. These are the words of both: the Timeline's row for a new one, and the run's end once the
4
- // claim has started as many as it may. That end's words begin with its code, so a reader of the run's summary serves it
2
+ // call in flight when the loss is confirmed fails and is never run again, and the claim starts a new one in its place at
3
+ // the next tool call (workspace/computer-for-claim.ts lostAware), up to LOST_RECREATES times a claim. These are the words
4
+ // of all three: the call the loss cut, the Timeline's row for a new one, and the run's end once the claim has started as
5
+ // many as it may. That end's words begin with its code, so a reader of the run's summary serves it
5
6
  // as the error computer_unavailable, its message the words after the code (store-view.ts errorOfRow), as a cap's end is
6
7
  // served as spend_cap_reached.
7
8
  /** How many new sandboxes a claim starts in place of ones its provider lost, by default. */
@@ -10,6 +11,10 @@ export const LOST_RECREATES = 2;
10
11
  export const COMPUTER_UNAVAILABLE_CODE = "computer_unavailable";
11
12
  /** How lostEnd's words begin, and only theirs. */
12
13
  const LOST_END = `${COMPUTER_UNAVAILABLE_CODE}: `;
14
+ /** The answer of the call in flight when its sandbox, `name`, was found lost, `why` the provider's words. Its code is
15
+ * gone, never not_found, so no caller reads it as a file or a program that is not there (a shell's fallback from bash
16
+ * to sh would send the command again, to the new sandbox). */
17
+ export const lostInCallWords = (name, why) => `the computer ${name} was lost while this call ran, and it was not run again: ${why.replace(/[.!?]+$/, "")}. A new computer starts at the next call.`;
13
18
  /** The Timeline's row once a new sandbox replaced a lost one: its name. */
14
19
  export const lostRecreatedWords = (name) => `Its computer was lost; started a new one (${name}).`;
15
20
  /** The run's end once its sandbox was lost again after `recreates` new ones (the claim's bound): the provider's words,
@@ -43,6 +43,8 @@ export declare const gpuOf: (computer: {
43
43
  readonly kind: string;
44
44
  readonly gpu?: GpuSetting;
45
45
  }) => GpuSetting | undefined;
46
+ /** The fields a computer of `kind` may set beside its kind and provider, in OPTIONAL's order: none for kind none. */
47
+ export declare const kindSettings: (kind: ComputerKind) => string[];
46
48
  /** A place as the v2 API names it. */
47
49
  export type PlaceView = {
48
50
  mode: "runner";
@@ -74,6 +74,8 @@ const OPTIONAL = {
74
74
  },
75
75
  },
76
76
  };
77
+ /** The fields a computer of `kind` may set beside its kind and provider, in OPTIONAL's order: none for kind none. */
78
+ export const kindSettings = (kind) => kind === "none" ? [] : Object.entries(OPTIONAL).filter(([, { kinds }]) => kinds === undefined || kinds.includes(kind)).map(([key]) => key);
77
79
  /** The place the setting reads as: sandbox on its provider, else the runner (no computer holds the run's folder). */
78
80
  export const placeOfComputer = (computer) => (computer.kind === "sandbox" ? { mode: "sandbox", box: computer.provider } : { mode: "runner" });
79
81
  /** The setting a place says: runner is no computer, a sandbox place a sandbox on its box. */
@@ -1,72 +1,11 @@
1
- import { type ComputerProvider, type GpuCapability } from "@parcha/agentrun-computer";
2
- import { type KeyChoice, type KeyTable, type OptionsAnswer, type ProviderFactories, type ProviderSettings } from "./computer-keys.js";
3
- import { type ComputerKind, type ComputerSetting } from "./computer-setting.js";
1
+ import { type ComputerProvider, type GpuCapability, type HostCommand, type ProviderEntry } from "@parcha/agentrun-computer";
2
+ import { type KeyChoice, type KeyTable, type ProviderFactories, type ProviderSettings } from "./computer-keys.js";
3
+ import { type ComputerKind } from "./computer-setting.js";
4
4
  import { type DockerDaemon } from "./docker-daemon.js";
5
5
  import { type KeyEnv, type KeyMeta } from "./key-meta.js";
6
6
  import type { PairedComputerRow, Store } from "./store/index.js";
7
7
  import type { PairedView } from "./computer-attach.js";
8
- import { type ComputerSettingKind, type ShellPlace } from "./workspace/resolve-computer.js";
9
- /** A setting kind as the kind registry's SETTING_KINDS gives it. */
10
- export interface SettingKindSpec {
11
- readonly machineKinds: readonly string[];
12
- readonly required: readonly string[];
13
- readonly optional: readonly string[];
14
- }
15
- /** A provider configuration's machine kind and groups, the GPUs it gives where it declares them, whether it keeps an
16
- * agent's own computer between runs (persistence), and the image a setting selects it by, where it names one, as the
17
- * kind registry gives them. */
18
- export type KindCapabilities = {
19
- readonly kind: string;
20
- readonly groups: readonly string[];
21
- readonly gpu?: GpuCapability;
22
- readonly persistence?: unknown;
23
- readonly image?: string;
24
- readonly options?: Readonly<Record<string, unknown>>;
25
- };
26
- /** A provider as the kind registry's PROVIDERS gives it. */
27
- export interface ProviderEntry {
28
- readonly id: string;
29
- readonly label: string;
30
- /** Whether its machines dial this server, as its descriptor declares it (the computer package's connectOf reads it
31
- * with its settings' connect). Absent: they never do. */
32
- readonly connect?: "dial" | "either";
33
- readonly kinds: readonly ComputerKind[];
34
- readonly keys: readonly {
35
- readonly name: string;
36
- readonly required: boolean;
37
- readonly picked?: boolean;
38
- }[];
39
- /** The mounts its computers take; none means it cannot mount the run's folder. */
40
- readonly mounts: readonly string[];
41
- /** Why its computers take none of these mounts, each in one sentence (Daytona's archil), as its descriptor says. */
42
- readonly unmounted?: Readonly<Partial<Record<string, string>>>;
43
- /** Mounts its computers take only where the operator sets the key named, by mount (Daytona's archil, with
44
- * DAYTONA_ARCHIL_EGRESS), as its descriptor says: resolve-computer.ts entryHere reads it with the keys set here. */
45
- readonly mountsWith?: Readonly<Partial<Record<string, string>>>;
46
- /** The server's environment variable that names the image every computer of it starts from (Daytona's
47
- * AGENTRUN_DAYTONA_SNAPSHOT), as its descriptor says: set, the operator names its image here (entryHere). */
48
- readonly imageEnv?: string;
49
- /** Set by entryHere alone: its imageEnv has a value here. */
50
- readonly imageNamed?: true;
51
- /** The network forms its computers make ("none", "open", "allow"), as its descriptor declares them. Absent (a
52
- * test's fixture): nothing is said of its network. */
53
- readonly network?: readonly string[];
54
- readonly metered: boolean;
55
- readonly capabilities: readonly KindCapabilities[];
56
- /** The image a computer of each kind starts from when its setting names none. */
57
- readonly defaultImage?: Partial<Record<ComputerKind, string>>;
58
- /** Its provider makes its image ready before the first create (its descriptor's prepareImage). */
59
- readonly prepareImage?: boolean;
60
- /** A program its computers need on this machine's PATH, what installs it, and the machines it is built for
61
- * (`${platform}-${arch}`; absent, every one), as its descriptor declares it: the phone's adb. Absent: none. */
62
- readonly hostCommand?: HostCommand;
63
- }
64
- /** A provider's host command, as the kind registry's entry names it. */
65
- export type HostCommand = {
66
- readonly command: string;
67
- readonly from: string;
68
- readonly builds?: readonly string[];
69
- };
8
+ import { type ComputerSettingKind, type KindRegistry, type ShellPlace } from "./workspace/resolve-computer.js";
70
9
  /** Why a provider whose host command is not on this machine's PATH cannot run here, in words that say how to fix it,
71
10
  * as the server says Docker's (docker-daemon.ts). On a machine the command has no build for (adb on arm64 Linux: AgentRun's
72
11
  * arm64 image has none either), they say which machine it needs, not how to install it. */
@@ -75,12 +14,6 @@ export declare function hostCommandWhy(label: string, { command, from, builds }:
75
14
  * words: what Settings → Computers, a run's start and the claim say for it. A command is there when a folder of `path`
76
15
  * holds an executable file of its name. */
77
16
  export declare function hostCommandRefusals(providers: readonly Pick<ProviderEntry, "id" | "label" | "hostCommand">[], path: string | undefined, platform?: string, arch?: string): Readonly<Record<string, string>>;
78
- /** The kind registry, by its own names: the computer package's module (SETTING_KINDS, PROVIDERS, servingRefusals). */
79
- export interface KindRegistry {
80
- readonly SETTING_KINDS: Readonly<Record<ComputerKind, SettingKindSpec>>;
81
- readonly PROVIDERS: readonly ProviderEntry[];
82
- servingRefusals(capabilities: KindCapabilities, kind: ComputerKind): string[];
83
- }
84
17
  /** Where the run's folder lives: on this machine (Mode 1), or on the owner's disk (Mode 2). */
85
18
  export type FolderMode = "local" | "disk";
86
19
  export interface ComputerRoutesOptions {
@@ -176,13 +109,15 @@ export declare const NETWORK_REFUSED_WORDS = "needs a network, which this server
176
109
  * makes "none" alone, "open" alone, or "open" and "allow" but no "none" (a browser behind its own proxy); none where
177
110
  * the allow-list applies as it is (Docker), or nothing is declared. */
178
111
  export declare function networkWords(network: readonly string[] | undefined, kind?: ComputerKind): string | undefined;
179
- /** A kind; kind none, the one "no computer" choice, carries its ShellChoice itself (it has no providers). */
112
+ /** A kind; kind none, the one "no computer" choice, carries its ShellChoice itself (it has no providers). `settings`: the
113
+ * fields its computer may set beside kind and provider (computer-setting.ts kindSettings). */
180
114
  export type KindView = {
181
115
  kind: ComputerKind;
182
116
  offered: boolean;
183
117
  why?: string;
184
118
  groups: string[];
185
119
  tools: string[];
120
+ settings: string[];
186
121
  providers: ProviderView[];
187
122
  } & Partial<ShellChoice>;
188
123
  export type TestView = {
@@ -226,7 +161,8 @@ export declare const COMPUTER_UNAVAILABLE = "computer_unavailable";
226
161
  * mode takes it. `provider` is as this server has it (resolve-computer.ts entryHere). */
227
162
  export declare function modeRefusal(kind: ComputerKind, provider: ProviderEntry, mode: FolderMode): string | undefined;
228
163
  /** The routes' work over the server's store: GET /v2/computers (view), PUT /v2/computers/{provider}/keys (saveKeys), POST
229
- * /v2/computers/{provider}/test (test), and the claim's refusal (claimRefusal). */
164
+ * /v2/computers/{provider}/test (test), GET /v2/computers/{provider}/choices (choices), and the provider of an agent's
165
+ * own computer (providerFor). */
230
166
  export declare function createComputerRoutes(options: ComputerRoutesOptions): {
231
167
  view: () => Promise<{
232
168
  kinds: KindView[];
@@ -237,8 +173,6 @@ export declare function createComputerRoutes(options: ComputerRoutesOptions): {
237
173
  choices: (providerId: string, signal?: AbortSignal) => Promise<{
238
174
  choices: KeyChoicesView[];
239
175
  } | undefined>;
240
- claimRefusal: (computer: ComputerSetting) => Promise<string | undefined>;
241
- claimOptions: (computer: ComputerSetting) => Promise<OptionsAnswer | undefined>;
242
176
  providerFor: (providerId: string, image: string | undefined) => Promise<Pick<ComputerProvider, "release">>;
243
177
  };
244
178
  export type ComputerRoutes = ReturnType<typeof createComputerRoutes>;
package/dist/computers.js CHANGED
@@ -1,16 +1,16 @@
1
1
  // Settings → Computers, the serve side: which computers this server offers, each provider's keys (saved or not, never a
2
- // value), saving a provider's keys sealed in the store, testing a provider's account, and the refusal a run meets at its
3
- // claim when its agent's computer cannot be had here, with the options its provider is made with. createComputerRoutes
4
- // takes the server's Store and the computer package's kind registry by its own names (SETTING_KINDS, PROVIDERS,
5
- // servingRefusals); the tools each kind brings are the server's to say (server.ts kindTools: a sandbox's shell tools from
6
- // the kernel's hostToolDefs, a browser's from pi-browser, a desktop's or a phone's the kernel's COMPUTER_TOOLS). Keys go by
7
- // their names only: a provider declares them, Settings takes only those, and the store keeps each sealed under the
8
- // server's seal key (server-keys.ts); a provider is handed its keys only at the claim, or for its test, both through
9
- // computer-keys.ts (providerOptions, testConnection), which maps a key's name onto the option it fills.
2
+ // value), saving a provider's keys sealed in the store, and testing a provider's account. createComputerRoutes takes the
3
+ // server's Store and the computer package's kind registry by its own names (SETTING_KINDS, PROVIDERS, servingRefusals);
4
+ // the tools each kind brings are the server's to say (server.ts kindTools: a sandbox's shell tools from the kernel's
5
+ // hostToolDefs, a browser's from pi-browser, a desktop's or a phone's the kernel's COMPUTER_TOOLS). Keys go by their
6
+ // names only: a provider declares them, Settings takes only those, and the store keeps each sealed under the server's
7
+ // seal key (server-keys.ts); a provider is handed its keys only for its test, or for the agent's own computer
8
+ // (providerFor), through computer-keys.ts (providerOptions, testConnection), which maps a key's name onto the option it
9
+ // fills. A run's claim is refused by the workspace's resolver (workspace/resolve-computer.ts resolveComputer).
10
10
  import { connectOf, imagesOf } from "@parcha/agentrun-computer";
11
11
  import { BOX_ALLOW_ENV, boxAllowOf } from "./box-settings.js";
12
12
  import { KEY_TABLE, keyChoices, providerOptions, settingOptions, testConnection } from "./computer-keys.js";
13
- import { COMPUTER_KINDS, gpuOf } from "./computer-setting.js";
13
+ import { COMPUTER_KINDS, kindSettings } from "./computer-setting.js";
14
14
  import { inArchilMode } from "./archil-settings.js";
15
15
  import { daemonUp, noDockerWords } from "./docker-daemon.js";
16
16
  import { ApiError, invalid } from "./errors.js";
@@ -18,14 +18,16 @@ import { commandOnPath } from "./host-command.js";
18
18
  import { gpuRefused } from "./gpu-words.js";
19
19
  import { redacted } from "./key-refusal.js";
20
20
  import { keyMetaOf, envValue } from "./key-meta.js";
21
- import { registerNotSecretWrite, registerSecretWrite, secretName } from "./secret-writes.js";
22
- import { getSealedKey, putSealedKey, removeSealedKey, sealedKeyNames } from "./server-keys.js";
21
+ import { registerNotSecretWrite, registerSecretPage, registerSecretWrite, secretName } from "./secret-writes.js";
22
+ import { getSealedKey, putSealedKey, removeSealedKey } from "./server-keys.js";
23
23
  import { dialApartWords, RUNNER_APART_WORDS, withPaired } from "./workspace/attached-computers.js";
24
24
  import { aLabel, entryHere, folderKindOf, needsNetwork, shellChoiceOf } from "./workspace/resolve-computer.js";
25
+ import { restartWith } from "./start-switches.js";
25
26
  // Every request to a computer's keys is a secret write (secret-writes.ts), whatever its body (a value, a null, an empty
26
27
  // body or none), as saveToolKey's is: the server's one dispatch check keeps it to the owner's session before any provider
27
28
  // is looked up, so a token learns nothing of which providers exist. The view and the connection test write none.
28
29
  registerSecretWrite("saveComputerKeys", () => true);
30
+ registerSecretPage("saveComputerKeys", "/#/settings/computers");
29
31
  registerNotSecretWrite("testComputer", "A connection test reads the saved keys and writes none.");
30
32
  const ARCH_NAMES = { x64: "x86-64", arm64: "arm64" };
31
33
  const PLATFORM_NAMES = { linux: "Linux", darwin: "macOS", win32: "Windows" };
@@ -56,7 +58,7 @@ export const OPERATOR_LIST_WORDS = "open unless this server sets AGENTRUN_BOX_AL
56
58
  * and at its claim (resolve-computer.ts noNetworkRefusal), so Settings says so and never offers it. */
57
59
  export const NETWORK_REFUSED_WORDS = `needs a network, which this server refuses: its ${BOX_ALLOW_ENV} is none`;
58
60
  /** Why a provider whose computers can't run with no network is not ready where this server has none. */
59
- const noNetworkWhy = (provider) => `${provider.label} needs a network, and this server's ${BOX_ALLOW_ENV} is none (no network): pick a computer that runs with no network, or set ${BOX_ALLOW_ENV} to a host list`;
61
+ const noNetworkWhy = (provider) => `${provider.label} needs a network, and this server's ${BOX_ALLOW_ENV} is none (no network): pick a computer that runs with no network, or ${restartWith(`${BOX_ALLOW_ENV} set to a host list`)}`;
60
62
  /** What this server's allow-list means for a provider's computers, by the network forms it declares: words for one that
61
63
  * makes "none" alone, "open" alone, or "open" and "allow" but no "none" (a browser behind its own proxy); none where
62
64
  * the allow-list applies as it is (Docker), or nothing is declared. */
@@ -115,27 +117,15 @@ function gpuView(gpu, provider, mode) {
115
117
  delete shown.unmounted;
116
118
  return { ...shown, ...(refused ? { why: refused.words } : {}) };
117
119
  }
118
- /** Why `computer`'s GPUs cannot be had on `provider` in `mode`, in gpuRefused's words; undefined when they can, or it
119
- * asks for none (only a sandbox does). */
120
- function gpuRefusal(kinds, computer, provider, mode) {
121
- const asked = gpuOf(computer);
122
- if (!asked)
123
- return undefined;
124
- const gpu = sandboxGpu(kinds, provider);
125
- const refused = gpuRefused(asked, gpu, folderMount(provider, gpu, mode), provider.label);
126
- if (!refused)
127
- return undefined;
128
- return refused.folder ? `${refused.words} (Settings → Computers)` : `${provider.label} can't give this agent's computer its GPUs: ${refused.words} (Settings → Computers)`;
129
- }
130
120
  /** The required keys `provider` has no saved value for, by name. */
131
121
  const missingKeys = (provider, saved) => provider.keys.filter((key) => key.required && !saved.has(key.name)).map((key) => key.name);
132
- /** Why a provider with keys missing is not ready, naming the setting to fill: a person reads it (the view, the test), so
133
- * it ends at the setting. A caller's refusal (the claim's) adds the route that saves them (`route`). */
134
- const keysWhy = (provider, missing, route = false) => `${provider.label} needs ${missing.join(" and ")} saved: save ${missing.length > 1 ? "them" : "it"} in Settings → Computers${route ? ` (PUT /v2/computers/${provider.id}/keys)` : ""}`;
122
+ /** Why a provider with keys missing is not ready, naming the setting to fill: a person reads it (the view, the test). */
123
+ const keysWhy = (provider, missing) => `${provider.label} needs ${missing.join(" and ")} saved: save ${missing.length > 1 ? "them" : "it"} in Settings → Computers`;
135
124
  /** Whether `provider` binds a folder of this machine, so its computers need this machine's Docker daemon. */
136
125
  const local = (provider) => provider.mounts.includes("bind");
137
126
  /** The routes' work over the server's store: GET /v2/computers (view), PUT /v2/computers/{provider}/keys (saveKeys), POST
138
- * /v2/computers/{provider}/test (test), and the claim's refusal (claimRefusal). */
127
+ * /v2/computers/{provider}/test (test), GET /v2/computers/{provider}/choices (choices), and the provider of an agent's
128
+ * own computer (providerFor). */
139
129
  export function createComputerRoutes(options) {
140
130
  const { store, sealKey, kinds, factories, settings = {}, keyTable = KEY_TABLE, tools, env = {}, answers = daemonUp, hostWhy = {} } = options;
141
131
  const providerOf = (id) => kinds.PROVIDERS.find((one) => one.id === id);
@@ -202,7 +192,7 @@ export function createComputerRoutes(options) {
202
192
  const why = offered ? undefined
203
193
  : serving.length && serving.every(refusedOpen) ? `every provider of a ${kind} computer needs a network, and this server's ${BOX_ALLOW_ENV} is none (no network)`
204
194
  : serving.length ? `no provider of a ${kind} computer can reach this server's run folders` : `no provider serves a ${kind} computer`;
205
- return { kind, offered, ...(why ? { why } : {}), groups: [...spec.required, ...spec.optional], tools: [...tools(kind)], providers, ...(kind === "none" ? choice({ kind: "none" }) : {}) };
195
+ return { kind, offered, ...(why ? { why } : {}), groups: [...spec.required, ...spec.optional], tools: [...tools(kind)], settings: kindSettings(kind), providers, ...(kind === "none" ? choice({ kind: "none" }) : {}) };
206
196
  }),
207
197
  paired,
208
198
  };
@@ -288,42 +278,6 @@ export function createComputerRoutes(options) {
288
278
  }
289
279
  return { choices: views };
290
280
  }
291
- /** Why a run of an agent whose computer is `computer` cannot have it here, in words naming the setting to fill;
292
- * undefined when it can. Checked at the claim: the provider must serve the kind (servingRefusals' words), fit this
293
- * server's folder mode, give a sandbox the GPUs it asks for (checkGpu's words), have its daemon answer where it binds
294
- * a folder of this machine (Docker), find what it runs on this machine (hostWhy's words), and have every required key
295
- * saved; a key refusal names the route that saves them. */
296
- async function claimRefusal(computer) {
297
- if (computer.kind === "none")
298
- return undefined;
299
- const listed = providerOf(computer.provider);
300
- if (!listed)
301
- return `this agent's computer names the provider ${computer.provider}, which this server does not have: set its computer in Settings → Computers`;
302
- // The keys set here, saved or the environment's: what the provider is made with, and what turns its mounts on.
303
- const set = new Set([...(await sealedKeyNames(store)), ...listed.keys.filter((key) => envValue(env, key.name) !== undefined).map((key) => key.name)]);
304
- const provider = entryHere(listed, (name) => set.has(name) || envValue(env, name) !== undefined, settingOptions(listed.id, settings, keyTable));
305
- if (!provider.kinds.includes(computer.kind)) {
306
- const words = [...new Set(provider.capabilities.flatMap((capabilities) => kinds.servingRefusals(capabilities, computer.kind)))];
307
- return `${provider.label} does not serve a ${computer.kind} computer${words.length ? ` (${words.join("; ")})` : ""}: set this agent's computer to one it serves (Settings → Computers)`;
308
- }
309
- const mode = await modeNow();
310
- const refused = modeRefusal(computer.kind, provider, mode) ?? gpuRefusal(kinds, computer, provider, mode) ?? (local(provider) ? daemonWhy(computer.kind, await answers(provider.id), mode) : undefined) ?? hostOf(provider);
311
- if (refused)
312
- return refused;
313
- const missing = missingKeys(provider, set);
314
- return missing.length ? keysWhy(provider, missing, true) : undefined;
315
- }
316
- /** What the claim makes a run's computer with: the options its provider's create() takes, from its saved keys and the
317
- * server's settings (computer-keys.ts providerOptions); refused with computer_unavailable and claimRefusal's words when
318
- * the computer cannot be had here. Undefined for a run with no computer. */
319
- async function claimOptions(computer) {
320
- if (computer.kind === "none")
321
- return undefined;
322
- const why = await claimRefusal(computer);
323
- if (why)
324
- return { ok: false, error: { code: COMPUTER_UNAVAILABLE, message: why } };
325
- return providerOptions(computer.provider, await keysOf(providerOf(computer.provider)), settings, keyTable);
326
- }
327
281
  /** The provider an agent's own computer lives on (workspace/agent-computer.ts reconcileAgentComputer deletes it
328
282
  * through it): made from its saved keys and the server's settings, with the create() options of the configuration
329
283
  * `image` selects, and the store's ledger (the factories'). Throws, in words, when it cannot be made here. */
@@ -343,7 +297,7 @@ export function createComputerRoutes(options) {
343
297
  throw new Error(`this server's ${entry.label} provider cannot release a computer`);
344
298
  return made;
345
299
  }
346
- return { view, saveKeys, test, choices, claimRefusal, claimOptions, providerFor };
300
+ return { view, saveKeys, test, choices, providerFor };
347
301
  }
348
302
  /** This server's folder mode, read from the store at each call: "disk" (Mode 2) while the Archil settings row is saved
349
303
  * (PUT /v2/workspace/archil), else "local" (Mode 1). createComputerRoutes' `mode`. */