@parcha/agentrun-serve 0.1.0-beta.45 → 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 (256) hide show
  1. package/CHANGELOG.md +180 -0
  2. package/NOTICE +4 -0
  3. package/README.md +283 -47
  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 +119 -44
  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 +34 -4
  70. package/dist/import.js +134 -32
  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 +11 -4
  78. package/dist/learn/promote.d.ts +77 -4
  79. package/dist/learn/promote.js +123 -2
  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-setting.d.ts +17 -6
  85. package/dist/learning-setting.js +41 -5
  86. package/dist/learning-words.d.ts +2 -0
  87. package/dist/learning-words.js +1 -1
  88. package/dist/listen-first.d.ts +10 -0
  89. package/dist/listen-first.js +25 -1
  90. package/dist/llms.txt +1 -1
  91. package/dist/mcp-gateway.d.ts +2 -1
  92. package/dist/mcp-gateway.js +31 -15
  93. package/dist/mcp-probe.d.ts +18 -6
  94. package/dist/mcp-probe.js +41 -8
  95. package/dist/mcp-secret-writes.d.ts +8 -0
  96. package/dist/mcp-secret-writes.js +104 -4
  97. package/dist/mcp-servers-store.d.ts +11 -5
  98. package/dist/mcp-servers-store.js +46 -20
  99. package/dist/model-form.d.ts +2 -1
  100. package/dist/model-form.js +22 -8
  101. package/dist/model-gateway.d.ts +113 -0
  102. package/dist/model-gateway.js +433 -0
  103. package/dist/model.d.ts +2 -1
  104. package/dist/model.js +9 -7
  105. package/dist/monid.js +1 -1
  106. package/dist/native/binding.d.ts +4 -0
  107. package/dist/native/binding.js +9 -0
  108. package/dist/native/cli.d.ts +3 -2
  109. package/dist/native/cli.js +6 -5
  110. package/dist/openapi.d.ts +2 -0
  111. package/dist/openapi.js +326 -41
  112. package/dist/owner.d.ts +4 -2
  113. package/dist/owner.js +10 -4
  114. package/dist/page.d.ts +8 -0
  115. package/dist/page.js +9 -1
  116. package/dist/port-models.js +17 -10
  117. package/dist/provider.d.ts +3 -3
  118. package/dist/provider.js +12 -3
  119. package/dist/public-address.d.ts +28 -0
  120. package/dist/public-address.js +62 -0
  121. package/dist/run-launch.d.ts +1 -1
  122. package/dist/run-launch.js +1 -1
  123. package/dist/run-secrets.d.ts +3 -2
  124. package/dist/run-secrets.js +6 -4
  125. package/dist/runner/adapter-loop.d.ts +10 -7
  126. package/dist/runner/adapter-loop.js +57 -22
  127. package/dist/runner/adapter-run-spec.d.ts +12 -0
  128. package/dist/runner/adapter-run-spec.js +40 -6
  129. package/dist/runner/adapters/index.js +16 -0
  130. package/dist/runner/adapters/pi.d.ts +5 -2
  131. package/dist/runner/adapters/pi.js +7 -4
  132. package/dist/runner/audit.d.ts +7 -0
  133. package/dist/runner/audit.js +24 -6
  134. package/dist/runner/claim-secrets.js +5 -1
  135. package/dist/runner/cli-run-spec.js +15 -7
  136. package/dist/runner/compare-end.d.ts +43 -0
  137. package/dist/runner/compare-end.js +95 -0
  138. package/dist/runner/computer-journal.d.ts +3 -0
  139. package/dist/runner/computer-journal.js +22 -2
  140. package/dist/runner/conformance/harness.js +19 -8
  141. package/dist/runner/conformance/subject.d.ts +6 -0
  142. package/dist/runner/harness-loops.d.ts +6 -1
  143. package/dist/runner/harness-loops.js +94 -54
  144. package/dist/runner/held.d.ts +5 -4
  145. package/dist/runner/journal-kinds.d.ts +4 -1
  146. package/dist/runner/journal-kinds.js +3 -0
  147. package/dist/runner/loop-contract.d.ts +10 -0
  148. package/dist/runner/main.d.ts +5 -5
  149. package/dist/runner/main.js +81 -11
  150. package/dist/runner/mcp-claim.js +40 -12
  151. package/dist/runner/metrics.d.ts +26 -0
  152. package/dist/runner/metrics.js +44 -1
  153. package/dist/runner/presence.d.ts +41 -0
  154. package/dist/runner/presence.js +89 -0
  155. package/dist/runner/promotion.d.ts +10 -3
  156. package/dist/runner/promotion.js +42 -21
  157. package/dist/runner/run-child-host.js +52 -14
  158. package/dist/runner/runner.d.ts +5 -0
  159. package/dist/runner/runner.js +8 -0
  160. package/dist/runner/store-port.d.ts +3 -0
  161. package/dist/runner/store-secrets.js +19 -7
  162. package/dist/runner/workflow-first.d.ts +5 -2
  163. package/dist/runner/workflow-first.js +6 -3
  164. package/dist/runs-over-store.d.ts +6 -2
  165. package/dist/runs-over-store.js +14 -4
  166. package/dist/sdk/runs.d.ts +1 -1
  167. package/dist/sdk/runs.js +6 -1
  168. package/dist/sdk/schema.js +1 -1
  169. package/dist/secret-writes.d.ts +16 -3
  170. package/dist/secret-writes.js +28 -3
  171. package/dist/server-secrets-store.js +5 -0
  172. package/dist/server.d.ts +31 -2
  173. package/dist/server.js +326 -53
  174. package/dist/sign-ins-secrets.js +4 -1
  175. package/dist/skills/agentrun-serve/SKILL.md +11 -0
  176. package/dist/slack-url.d.ts +5 -0
  177. package/dist/slack-url.js +11 -0
  178. package/dist/slack.d.ts +107 -0
  179. package/dist/slack.js +292 -0
  180. package/dist/start-switches.d.ts +28 -0
  181. package/dist/start-switches.js +37 -0
  182. package/dist/stats.d.ts +1 -1
  183. package/dist/stats.js +2 -1
  184. package/dist/stop-signals.d.ts +11 -0
  185. package/dist/stop-signals.js +22 -0
  186. package/dist/store/agent-body.d.ts +1 -1
  187. package/dist/store/agent-body.js +2 -2
  188. package/dist/store/index.d.ts +3 -3
  189. package/dist/store/index.js +1 -1
  190. package/dist/store/postgres/migrations/0020_runners.sql +18 -0
  191. package/dist/store/postgres/store.d.ts +1 -1
  192. package/dist/store/postgres/store.js +4 -2
  193. package/dist/store/schema.d.ts +13 -5
  194. package/dist/store/schema.js +20 -11
  195. package/dist/store/seal.d.ts +16 -4
  196. package/dist/store/sqlite/store.d.ts +1 -1
  197. package/dist/store/sqlite/store.js +106 -27
  198. package/dist/store/store.d.ts +75 -23
  199. package/dist/store/store.js +11 -0
  200. package/dist/store-reads/analytics.js +3 -2
  201. package/dist/store-reads/cap.d.ts +7 -0
  202. package/dist/store-reads/cap.js +11 -1
  203. package/dist/store-reads/journal.js +27 -1
  204. package/dist/store-reads/learning.d.ts +23 -2
  205. package/dist/store-reads/learning.js +29 -8
  206. package/dist/store-reads/runs.d.ts +9 -0
  207. package/dist/store-reads/runs.js +19 -6
  208. package/dist/store-reads/stats.d.ts +4 -1
  209. package/dist/store-reads/stats.js +15 -6
  210. package/dist/store-view.d.ts +123 -14
  211. package/dist/store-view.js +154 -21
  212. package/dist/telemetry.d.ts +7 -7
  213. package/dist/telemetry.js +38 -15
  214. package/dist/templates.d.ts +6 -3
  215. package/dist/templates.js +38 -3
  216. package/dist/timeline/timeline.js +18 -0
  217. package/dist/tool-keys-store.js +2 -2
  218. package/dist/tool-keys.js +2 -1
  219. package/dist/tool-plane.js +2 -2
  220. package/dist/trigger-adapter.d.ts +3 -4
  221. package/dist/trigger-adapter.js +2 -2
  222. package/dist/trigger-composio.js +3 -3
  223. package/dist/trigger-email.js +0 -2
  224. package/dist/trigger-feed.js +0 -2
  225. package/dist/trigger-schedule.js +3 -0
  226. package/dist/trigger-secrets-shown.d.ts +6 -3
  227. package/dist/trigger-secrets-shown.js +22 -13
  228. package/dist/trigger-targets.d.ts +1 -1
  229. package/dist/trigger-targets.js +19 -8
  230. package/dist/triggers.d.ts +7 -3
  231. package/dist/triggers.js +2 -1
  232. package/dist/webhooks.d.ts +85 -9
  233. package/dist/webhooks.js +129 -46
  234. package/dist/wires.d.ts +6 -1
  235. package/dist/wires.js +5 -0
  236. package/dist/workspace/attach.d.ts +3 -2
  237. package/dist/workspace/attach.js +2 -1
  238. package/dist/workspace/attached-computers.d.ts +6 -8
  239. package/dist/workspace/attached-computers.js +27 -24
  240. package/dist/workspace/computer-deps.d.ts +2 -3
  241. package/dist/workspace/computer-deps.js +3 -6
  242. package/dist/workspace/computer-for-claim.js +72 -96
  243. package/dist/workspace/computer-kept.d.ts +0 -7
  244. package/dist/workspace/computer-kept.js +0 -17
  245. package/dist/workspace/resolve-computer.d.ts +18 -14
  246. package/dist/workspace/resolve-computer.js +47 -60
  247. package/dist/workspace/synced-folder.d.ts +20 -15
  248. package/dist/workspace/synced-folder.js +33 -43
  249. package/launcher/agentrun-serve +4 -1
  250. package/package.json +10 -10
  251. package/skills/agentrun-serve/SKILL.md +11 -0
  252. package/templates/README.md +1 -1
  253. package/templates/inbound-lead/agent.md +2 -1
  254. package/templates/kyb/agent.md +2 -1
  255. package/dist/console/assets/index-3O2Yl6hZ.js +0 -701
  256. package/dist/console/assets/index-DaFsZuzQ.css +0 -1
@@ -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`. */