@parcha/agentrun-serve 0.1.0-beta.56 → 0.1.0-beta.58

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 (312) hide show
  1. package/CHANGELOG.md +281 -0
  2. package/README.md +246 -66
  3. package/dist/acp-package.d.ts +2 -0
  4. package/dist/adapters.d.ts +15 -3
  5. package/dist/adapters.js +17 -6
  6. package/dist/agent-package.d.ts +3 -3
  7. package/dist/agent-package.js +17 -8
  8. package/dist/api-keys.d.ts +76 -0
  9. package/dist/api-keys.js +217 -0
  10. package/dist/api-only.d.ts +15 -5
  11. package/dist/api-only.js +32 -8
  12. package/dist/box-paths.d.ts +4 -3
  13. package/dist/box-paths.js +7 -4
  14. package/dist/browser-hold.d.ts +23 -0
  15. package/dist/browser-hold.js +48 -0
  16. package/dist/browser-person.d.ts +3 -0
  17. package/dist/browser-person.js +4 -1
  18. package/dist/chatgpt-plan.d.ts +18 -8
  19. package/dist/chatgpt-plan.js +91 -34
  20. package/dist/claude-login-token.d.ts +117 -0
  21. package/dist/claude-login-token.js +737 -0
  22. package/dist/claude-login.d.ts +120 -22
  23. package/dist/claude-login.js +347 -63
  24. package/dist/claude-sign-in.d.ts +17 -6
  25. package/dist/claude-sign-in.js +42 -39
  26. package/dist/cli.js +33 -10
  27. package/dist/composio-made.d.ts +4 -0
  28. package/dist/composio-made.js +4 -0
  29. package/dist/composio-preset.d.ts +43 -2
  30. package/dist/composio-preset.js +92 -4
  31. package/dist/computer-attach.d.ts +35 -17
  32. package/dist/computer-attach.js +301 -49
  33. package/dist/computer-held-routes.d.ts +5 -4
  34. package/dist/computer-held-routes.js +29 -8
  35. package/dist/computer-held.d.ts +6 -1
  36. package/dist/computer-held.js +14 -0
  37. package/dist/computer-record.js +4 -2
  38. package/dist/computer-viewer.js +4 -1
  39. package/dist/computers.d.ts +10 -10
  40. package/dist/computers.js +5 -5
  41. package/dist/console/assets/{backend-Boh7tC4i.js → backend-CSAWUqtZ.js} +19 -19
  42. package/dist/console/assets/index-Bwn1oTem.css +1 -0
  43. package/dist/console/assets/index-DPh29cyz.js +747 -0
  44. package/dist/console/index.html +2 -2
  45. package/dist/decisions.d.ts +1 -1
  46. package/dist/decisions.js +1 -1
  47. package/dist/dial-relay.d.ts +25 -4
  48. package/dist/dial-relay.js +129 -1
  49. package/dist/docker-host-addresses.d.ts +22 -11
  50. package/dist/docker-host-addresses.js +38 -26
  51. package/dist/env-switch.d.ts +8 -0
  52. package/dist/env-switch.js +31 -2
  53. package/dist/errors.d.ts +1 -0
  54. package/dist/errors.js +2 -0
  55. package/dist/fal-price.d.ts +56 -20
  56. package/dist/fal-price.js +400 -90
  57. package/dist/handed-values.d.ts +43 -1
  58. package/dist/handed-values.js +119 -2
  59. package/dist/harness-archive.d.ts +13 -10
  60. package/dist/harness-archive.js +60 -34
  61. package/dist/harness-check.d.ts +3 -1
  62. package/dist/harness-check.js +25 -46
  63. package/dist/harness-keys.d.ts +73 -27
  64. package/dist/harness-keys.js +194 -61
  65. package/dist/harness-recipe-entry.d.ts +8 -7
  66. package/dist/harness-recipe-entry.js +21 -32
  67. package/dist/harness-recipe.d.ts +38 -25
  68. package/dist/harness-recipe.js +49 -36
  69. package/dist/harness-sign-in.js +12 -23
  70. package/dist/harness-table.d.ts +10 -3
  71. package/dist/harness-table.js +26 -21
  72. package/dist/harness.d.ts +1 -0
  73. package/dist/harness.js +17 -5
  74. package/dist/hosted-search.d.ts +1 -1
  75. package/dist/hosted-search.js +1 -2
  76. package/dist/import-worker.d.ts +4 -2
  77. package/dist/import-worker.js +9 -2
  78. package/dist/in-flight.d.ts +26 -0
  79. package/dist/in-flight.js +52 -0
  80. package/dist/key-refusal.d.ts +9 -4
  81. package/dist/key-refusal.js +107 -25
  82. package/dist/learn/ledger.d.ts +170 -0
  83. package/dist/learn/ledger.js +218 -0
  84. package/dist/learn/promote.d.ts +3 -3
  85. package/dist/learn/promote.js +1 -1
  86. package/dist/learn/secrets.d.ts +13 -3
  87. package/dist/learn/secrets.js +118 -17
  88. package/dist/learning-cost.d.ts +28 -23
  89. package/dist/learning-cost.js +19 -23
  90. package/dist/link-check.js +1 -1
  91. package/dist/live-reach.d.ts +2 -0
  92. package/dist/live-reach.js +2 -0
  93. package/dist/llms.txt +1 -1
  94. package/dist/marketplace.d.ts +77 -0
  95. package/dist/marketplace.js +224 -0
  96. package/dist/mcp-api-only-origins.d.ts +35 -0
  97. package/dist/mcp-api-only-origins.js +57 -0
  98. package/dist/mcp-gateway.d.ts +7 -5
  99. package/dist/mcp-gateway.js +9 -12
  100. package/dist/mcp-secret-writes.js +5 -3
  101. package/dist/mcp-servers-store.d.ts +28 -6
  102. package/dist/mcp-servers-store.js +53 -4
  103. package/dist/media-duration.d.ts +3 -0
  104. package/dist/media-duration.js +90 -9
  105. package/dist/micro.d.ts +2 -0
  106. package/dist/micro.js +2 -0
  107. package/dist/model-form.d.ts +5 -4
  108. package/dist/model-form.js +11 -7
  109. package/dist/model.d.ts +10 -6
  110. package/dist/model.js +16 -11
  111. package/dist/monid.d.ts +14 -1
  112. package/dist/monid.js +103 -26
  113. package/dist/ollama-provider.d.ts +7 -1
  114. package/dist/ollama-provider.js +14 -2
  115. package/dist/openapi.js +210 -37
  116. package/dist/otel/genai.d.ts +65 -0
  117. package/dist/otel/genai.js +116 -0
  118. package/dist/otel/tracer.d.ts +55 -0
  119. package/dist/otel/tracer.js +308 -0
  120. package/dist/page.d.ts +2 -0
  121. package/dist/page.js +3 -1
  122. package/dist/paid-calls.d.ts +1 -32
  123. package/dist/paid-calls.js +4 -39
  124. package/dist/place-offers.d.ts +4 -0
  125. package/dist/place-offers.js +7 -4
  126. package/dist/provider.d.ts +11 -2
  127. package/dist/provider.js +59 -8
  128. package/dist/redact/match.d.ts +30 -3
  129. package/dist/redact/match.js +422 -41
  130. package/dist/refusal-words.d.ts +11 -0
  131. package/dist/refusal-words.js +11 -0
  132. package/dist/run-census.d.ts +67 -0
  133. package/dist/run-census.js +240 -0
  134. package/dist/run-computer.d.ts +6 -3
  135. package/dist/run-computer.js +4 -1
  136. package/dist/run-cut.d.ts +15 -6
  137. package/dist/run-cut.js +30 -9
  138. package/dist/run-files.d.ts +3 -0
  139. package/dist/run-files.js +3 -0
  140. package/dist/run-launch.d.ts +12 -1
  141. package/dist/run-launch.js +9 -10
  142. package/dist/run-learning-served.d.ts +4 -2
  143. package/dist/run-model-key.d.ts +8 -0
  144. package/dist/run-model-key.js +31 -1
  145. package/dist/run-reads-over-store.d.ts +24 -6
  146. package/dist/run-reads-over-store.js +67 -23
  147. package/dist/run-recordings.d.ts +5 -1
  148. package/dist/run-recordings.js +39 -14
  149. package/dist/run-timeline-served.d.ts +2 -0
  150. package/dist/run-timeline-served.js +2 -2
  151. package/dist/run-usage.d.ts +1 -0
  152. package/dist/run-view.d.ts +1 -2
  153. package/dist/run-view.js +2 -1
  154. package/dist/runnable.d.ts +10 -1
  155. package/dist/runnable.js +20 -8
  156. package/dist/runner/adapter-loop.d.ts +11 -0
  157. package/dist/runner/adapter-loop.js +58 -26
  158. package/dist/runner/adapter-run-spec.d.ts +55 -11
  159. package/dist/runner/adapter-run-spec.js +183 -52
  160. package/dist/runner/adapters/pi.js +25 -3
  161. package/dist/runner/beside.d.ts +9 -2
  162. package/dist/runner/beside.js +27 -9
  163. package/dist/runner/big-writes.js +1 -10
  164. package/dist/runner/claim-secrets.d.ts +27 -10
  165. package/dist/runner/claim-secrets.js +49 -22
  166. package/dist/runner/cli-run-spec.d.ts +6 -0
  167. package/dist/runner/cli-run-spec.js +97 -38
  168. package/dist/runner/computer-journal.d.ts +9 -1
  169. package/dist/runner/computer-journal.js +26 -0
  170. package/dist/runner/conformance/harness.js +1 -1
  171. package/dist/runner/feedback-round.js +3 -0
  172. package/dist/runner/harness-loops.d.ts +6 -5
  173. package/dist/runner/harness-loops.js +7 -7
  174. package/dist/runner/held.d.ts +24 -6
  175. package/dist/runner/journal-kinds.d.ts +5 -0
  176. package/dist/runner/journal-kinds.js +5 -0
  177. package/dist/runner/main.d.ts +11 -6
  178. package/dist/runner/main.js +19 -9
  179. package/dist/runner/mcp-claim.js +31 -3
  180. package/dist/runner/mcp-run.d.ts +9 -0
  181. package/dist/runner/mcp-run.js +11 -5
  182. package/dist/runner/model-route.d.ts +17 -0
  183. package/dist/runner/model-route.js +120 -2
  184. package/dist/runner/presence.d.ts +11 -1
  185. package/dist/runner/presence.js +7 -0
  186. package/dist/runner/reflect-hook.js +1 -1
  187. package/dist/runner/run-child-host.d.ts +22 -8
  188. package/dist/runner/run-child-host.js +128 -41
  189. package/dist/runner/run-child.js +5 -2
  190. package/dist/runner/runner.d.ts +17 -3
  191. package/dist/runner/runner.js +130 -34
  192. package/dist/runner/save-slots.js +2 -1
  193. package/dist/runner/store-port.d.ts +1 -1
  194. package/dist/runner/store-secrets.d.ts +6 -0
  195. package/dist/runner/store-secrets.js +49 -7
  196. package/dist/runner/subagent.d.ts +11 -0
  197. package/dist/runner/subagent.js +16 -38
  198. package/dist/runner/workflow-first.d.ts +35 -15
  199. package/dist/runner/workflow-first.js +38 -25
  200. package/dist/runner/workflow-spec.js +4 -3
  201. package/dist/runs-over-store.d.ts +15 -6
  202. package/dist/runs-over-store.js +33 -21
  203. package/dist/scrub-command.d.ts +73 -0
  204. package/dist/scrub-command.js +307 -0
  205. package/dist/secret-cut.d.ts +73 -0
  206. package/dist/secret-cut.js +291 -4
  207. package/dist/secret-rules.d.ts +143 -0
  208. package/dist/secret-rules.js +2564 -0
  209. package/dist/secrets.d.ts +7 -0
  210. package/dist/secrets.js +20 -0
  211. package/dist/server-keys.d.ts +20 -0
  212. package/dist/server-keys.js +25 -6
  213. package/dist/server.d.ts +65 -13
  214. package/dist/server.js +470 -157
  215. package/dist/skills/agentrun-serve/SKILL.md +4 -0
  216. package/dist/slots.d.ts +9 -0
  217. package/dist/slots.js +45 -0
  218. package/dist/store/index.d.ts +1 -1
  219. package/dist/store/index.js +1 -1
  220. package/dist/store/journal/storage.js +1 -1
  221. package/dist/store/postgres/migrations/0027_run_launch_census.sql +31 -0
  222. package/dist/store/postgres/migrations/0028_learning_ledger.sql +44 -0
  223. package/dist/store/schema.d.ts +23 -0
  224. package/dist/store/schema.js +58 -2
  225. package/dist/store/seal.d.ts +6 -1
  226. package/dist/store/seal.js +5 -3
  227. package/dist/store/sqlite/run-launch.d.ts +9 -1
  228. package/dist/store/sqlite/run-launch.js +24 -13
  229. package/dist/store/sqlite/run-patch.d.ts +12 -2
  230. package/dist/store/sqlite/run-patch.js +42 -5
  231. package/dist/store/sqlite/store.js +105 -12
  232. package/dist/store/store.d.ts +57 -2
  233. package/dist/store/store.js +20 -0
  234. package/dist/store-reads/learning.d.ts +84 -124
  235. package/dist/store-reads/learning.js +210 -274
  236. package/dist/store-view.d.ts +3 -0
  237. package/dist/store-view.js +3 -3
  238. package/dist/suggestions.js +3 -2
  239. package/dist/template-eval.d.ts +39 -9
  240. package/dist/template-eval.js +191 -60
  241. package/dist/template-import.js +6 -2
  242. package/dist/templates.d.ts +10 -2
  243. package/dist/templates.js +28 -8
  244. package/dist/timeline/labels.d.ts +6 -4
  245. package/dist/timeline/labels.js +18 -6
  246. package/dist/timeline/timeline.d.ts +5 -0
  247. package/dist/timeline/timeline.js +14 -8
  248. package/dist/timeline/util.js +1 -1
  249. package/dist/timeline/web-calls.d.ts +22 -7
  250. package/dist/timeline/web-calls.js +106 -35
  251. package/dist/tool-gate.d.ts +42 -3
  252. package/dist/tool-gate.js +66 -5
  253. package/dist/tool-keys-store.d.ts +2 -4
  254. package/dist/tool-keys-store.js +5 -21
  255. package/dist/tool-keys.d.ts +2 -2
  256. package/dist/tool-keys.js +2 -2
  257. package/dist/tool-list.js +1 -1
  258. package/dist/tool-plane.d.ts +2 -2
  259. package/dist/tool-plane.js +35 -33
  260. package/dist/tools.js +13 -7
  261. package/dist/trigger-targets.d.ts +4 -0
  262. package/dist/trigger-targets.js +9 -2
  263. package/dist/triggers.d.ts +67 -4
  264. package/dist/triggers.js +171 -22
  265. package/dist/until.d.ts +3 -0
  266. package/dist/until.js +11 -0
  267. package/dist/web-fake.d.ts +1 -3
  268. package/dist/web-fake.js +7 -18
  269. package/dist/web-fetch.d.ts +6 -72
  270. package/dist/web-fetch.js +11 -265
  271. package/dist/web-run.d.ts +31 -0
  272. package/dist/web-run.js +90 -0
  273. package/dist/web-save.d.ts +10 -13
  274. package/dist/web-save.js +13 -55
  275. package/dist/web-search.d.ts +9 -127
  276. package/dist/web-search.js +23 -259
  277. package/dist/wires.d.ts +13 -0
  278. package/dist/wires.js +11 -0
  279. package/dist/workflow-run.d.ts +5 -4
  280. package/dist/workflow-run.js +5 -4
  281. package/dist/workspace/attached-computers.d.ts +32 -9
  282. package/dist/workspace/attached-computers.js +77 -13
  283. package/dist/workspace/computer-deps.d.ts +8 -2
  284. package/dist/workspace/computer-deps.js +10 -3
  285. package/dist/workspace/computer-for-claim.d.ts +12 -1
  286. package/dist/workspace/computer-for-claim.js +83 -11
  287. package/dist/workspace/computer-kept.d.ts +3 -0
  288. package/dist/workspace/computer-kept.js +11 -2
  289. package/dist/workspace/index.d.ts +1 -1
  290. package/dist/workspace/index.js +1 -1
  291. package/dist/workspace/kind-skills.d.ts +4 -0
  292. package/dist/workspace/kind-skills.js +9 -0
  293. package/dist/workspace/paired-route.d.ts +91 -0
  294. package/dist/workspace/paired-route.js +153 -0
  295. package/dist/workspace/synced-folder.js +3 -4
  296. package/dist/wrapped.d.ts +20 -6
  297. package/dist/wrapped.js +66 -25
  298. package/package.json +17 -11
  299. package/skills/agentrun-serve/SKILL.md +4 -0
  300. package/templates/README.md +32 -10
  301. package/dist/console/assets/index-CQ3cJRzI.js +0 -746
  302. package/dist/console/assets/index-DKkaS3a0.css +0 -1
  303. package/dist/exa-keyless.d.ts +0 -34
  304. package/dist/exa-keyless.js +0 -118
  305. package/dist/firecrawl-keyless.d.ts +0 -41
  306. package/dist/firecrawl-keyless.js +0 -152
  307. package/dist/keyless-mcp.d.ts +0 -36
  308. package/dist/keyless-mcp.js +0 -127
  309. package/dist/text-urls.d.ts +0 -38
  310. package/dist/text-urls.js +0 -170
  311. package/dist/web-fetch-direct.d.ts +0 -119
  312. package/dist/web-fetch-direct.js +0 -190
@@ -6,9 +6,12 @@
6
6
  // A Linux box with no display (computerd's hello says linux, with files and exec) is a sandbox: in Mode 2 it holds the
7
7
  // run's folder as a synced folder in its own /workspace, as a hosted computer that dials does.
8
8
  //
9
- // Its socket is held by the AttachHub of the server's process: a runner in that process (the CLI's start, its runner
10
- // beside the server) takes it; a runner of its own process cannot reach it and refuses it in ONE_PROCESS_WORDS.
11
- import { attachedProvider, SETTING_KIND_NAMES, SETTING_KINDS } from "@parcha/agentrun-computer";
9
+ // Its socket is held by the AttachHub of the server's process while no run holds it: a runner in that process (the CLI's
10
+ // start, its runner beside the server) takes it there, its route taken all the same (dial-relay.ts pairedRelayOn over
11
+ // the server's hub, runner/beside.ts), so a runner apart takes it for no other run meanwhile. A runner of its own
12
+ // process with a relay (dial-relay.ts) has the server move the box's socket onto its own hub for the run (PairedRelay,
13
+ // workspace/paired-route.ts); one with no relay cannot reach it and refuses it in ONE_PROCESS_WORDS.
14
+ import { attachedProvider, fail, RUN_LABEL, runLifetimeMs, SETTING_KIND_NAMES, SETTING_KINDS } from "@parcha/agentrun-computer";
12
15
  /** A paired computer's id starts with this; the rest is lowercase letters and digits, so the whole is an id an agent's
13
16
  * computer setting takes as its provider (lowercase letters, digits and dashes). */
14
17
  export const PAIRED_ID_PREFIX = "cmp-";
@@ -16,11 +19,16 @@ export const PAIRED_ID_PREFIX = "cmp-";
16
19
  export const ATTACHED_IMAGE = "attached";
17
20
  /** How to start a server so its runs can use a paired computer, in one line: the same words wherever it is said. */
18
21
  export const ONE_PROCESS_FIX = "start the image with the server options alone, without server-and-runner (outside the image: agentrun-serve without --no-runner)";
19
- /** The words a run gets when its agent's computer is a paired computer and its runner is not in the server's process. */
20
- export const ONE_PROCESS_WORDS = `a paired computer's socket is held by the server process it dialed, and this runner runs in a process of its own: ${ONE_PROCESS_FIX}`;
22
+ /** The fix for a runner in a process of its own that relays no computer's socket: it relays once it has the server's
23
+ * public address (dial-relay.ts). */
24
+ const RELAY_FIX = "give the runner AGENTRUN_PUBLIC_URL (this server's public address)";
25
+ /** The words a run gets when its agent's computer is a paired computer and its runner, in a process of its own, keeps
26
+ * no relay. */
27
+ export const ONE_PROCESS_WORDS = `a paired computer's socket is held by the server process it dialed, and this runner runs in a process of its own and relays no computer's socket: ${RELAY_FIX}, or ${ONE_PROCESS_FIX}`;
21
28
  /** What a pairing code, the pair answer and each paired computer say on a server whose runner runs in a process of its
22
- * own (--no-runner; the image's server-and-runner): the computer pairs, and no run here can use it. */
23
- export const RUNNER_APART_WORDS = `no run on this server can use a paired computer: its runner runs in a process of its own, and the computer's socket is held by the server's: ${ONE_PROCESS_FIX}`;
29
+ * own (--no-runner; the image's server-and-runner) while no runner relays: the computer pairs, and no run here can use
30
+ * it. */
31
+ export const RUNNER_APART_WORDS = `no run on this server can use a paired computer: its runner runs in a process of its own and relays no computer's socket: ${RELAY_FIX}, or ${ONE_PROCESS_FIX}`;
24
32
  /** What a provider whose machines dial this server (the computer package's connectOf "dial": Fly Machines, Cloudflare,
25
33
  * and E2B, Daytona or Modal set to dial) says on such a server: its row in GET /v2/computers and its test. Its
26
34
  * machines' sockets are taken by the server's attach hub, and a runner of its own process has none, so its create
@@ -115,12 +123,68 @@ export function withPaired(registry, rows) {
115
123
  return registry;
116
124
  return { ...registry, PROVIDERS: [...registry.PROVIDERS, ...rows.map((row) => pairedEntry(row, registry))] };
117
125
  }
118
- /** The provider of the paired computer `row`: attachedProvider over the hub, or a refusal in ONE_PROCESS_WORDS where this
119
- * process holds no hub. */
120
- export function pairedProvider(row, hub) {
121
- if (hub === undefined)
122
- throw Object.assign(new Error(ONE_PROCESS_WORDS), { code: "computer_unavailable" });
123
- return attachedProvider(pairedOf(row), hub);
126
+ /** The provider of the paired computer `row`: over a relay's hub where the runner has one (`relay`: a runner apart's
127
+ * own, or the server's for the runner beside it), the box brought there before each create and let go after each
128
+ * release (relayedProvider); else attachedProvider over the server's hub (`hub`) with no route; else a refusal in
129
+ * ONE_PROCESS_WORDS. `claim`: the run's claim (ClaimLaunch.claim), which the bring's route takes under. */
130
+ export function pairedProvider(row, hub, relay, claim) {
131
+ if (relay !== undefined)
132
+ return relayedProvider(row, relay, claim);
133
+ if (hub !== undefined)
134
+ return attachedProvider(pairedOf(row), hub);
135
+ throw Object.assign(new Error(ONE_PROCESS_WORDS), { code: "computer_unavailable" });
136
+ }
137
+ /** attachedProvider over a relay's hub: create brings the box to this runner for the run (its labels' run, its
138
+ * lifetime's end) and is refused in the bring's words, never hanging; a create that fails after the bring lets the box
139
+ * go; release ends the hold, then lets the box go (a run's loop releases in its finally, so a cancelled run or a throw
140
+ * in its pass lets the box go as it unwinds). Every other call is attachedProvider's own. */
141
+ function relayedProvider(row, relay, claim) {
142
+ const inner = attachedProvider(pairedOf(row), relay.hub);
143
+ /** The run of each hold this provider made, by its ref's id (`<computer id>.<hold>`). */
144
+ const runs = new Map();
145
+ return {
146
+ id: inner.id,
147
+ get version() {
148
+ return inner.version;
149
+ },
150
+ capabilities: () => inner.capabilities(),
151
+ check: (spec) => inner.check(spec),
152
+ async create(spec, context) {
153
+ const run = spec.labels?.[RUN_LABEL];
154
+ if (run === undefined)
155
+ return inner.create(spec, context);
156
+ try {
157
+ // The claim's cancel (the create's signal) ends the bring's wait at once, the route it took dropped.
158
+ await relay.bring(row, { run, until: Date.now() + runLifetimeMs(spec), ...(claim ? { claim } : {}), ...(context.signal ? { signal: context.signal } : {}) });
159
+ }
160
+ catch (error) {
161
+ // A superseded claim (Fenced), and any failure that is not the bring's in words, is the claim's to answer.
162
+ if (error.code !== "computer_unavailable")
163
+ throw error;
164
+ return fail(context.signal?.aborted ? "aborted" : "refused", error.message);
165
+ }
166
+ const made = await inner.create(spec, context);
167
+ if (!made.ok) {
168
+ await relay.letGo(row.id, undefined, run).catch(() => undefined);
169
+ return made;
170
+ }
171
+ runs.set(made.value.id, run);
172
+ return made;
173
+ },
174
+ attach: (asked, context) => inner.attach(asked, context),
175
+ list: (labels, context) => inner.list(labels, context),
176
+ network: (asked, policy, context) => inner.network(asked, policy, context),
177
+ connect: (asked) => inner.connect(asked),
178
+ async release(asked, how, context) {
179
+ const done = await inner.release(asked, how, context);
180
+ if (done.ok && asked.id !== row.id) {
181
+ const run = runs.get(asked.id);
182
+ runs.delete(asked.id);
183
+ await relay.letGo(row.id, undefined, run);
184
+ }
185
+ return done;
186
+ },
187
+ };
124
188
  }
125
189
  /** Why the paired computer `row` cannot be had now, in words that say what to do, or undefined: it must be attached (its
126
190
  * driver dialed this server). Asked at a run's start, as a vendor's readiness is; another run's hold is the claim's. */
@@ -6,6 +6,7 @@ import type { FauxComputers } from "../faux-computers.js";
6
6
  import { type KeyEnv } from "../key-meta.js";
7
7
  import { BOX_CPUS_ENV, BOX_MEMORY_ENV, BOX_PIDS_ENV } from "../start-switches.js";
8
8
  import type { Store } from "../store/index.js";
9
+ import type { PairedRelay } from "./attached-computers.js";
9
10
  import { type ClaimComputer, type ClaimLaunch, computerForClaim, type ComputerForClaimDeps, type ComputerSaid, type KeptKind, type OpenComputerView, type Replaced } from "./computer-for-claim.js";
10
11
  import { type ProviderLoad } from "./computer-providers.js";
11
12
  import { type KindRegistry } from "./resolve-computer.js";
@@ -53,8 +54,12 @@ export interface ComputerDepsOptions {
53
54
  readonly pairedComputers?: Pick<Store["pairedComputers"], "list">;
54
55
  };
55
56
  /** The server's AttachHub, where this runner shares the server's process (runner/beside.ts): a paired computer's
56
- * socket is there. Absent: a runner of its own process, which refuses a paired computer in words. */
57
+ * socket is there. Absent: a runner of its own process, which reaches a paired computer through its relay
58
+ * (`pairedRelay`), or refuses one in words where it keeps none. */
57
59
  readonly hub?: AttachHub;
60
+ /** The relay of a runner in a process of its own (dial-relay.ts RunnerRelay.paired): the server moves a paired
61
+ * computer's socket onto its hub for the run. Absent: none. */
62
+ readonly pairedRelay?: PairedRelay;
58
63
  /** The server's dial (Serve.dial), where this runner shares the server's process: every remote provider's create
59
64
  * takes it, and one whose host dials the server (facts.connect "dial") mints its machine's token there. Absent: a
60
65
  * runner of its own process, where such a provider's create refuses in words. */
@@ -111,7 +116,8 @@ export declare const computerStartingWords: ({ provider, kind }: Pick<ComputerSa
111
116
  * server's stop, a park: the words fit each), and, where the run's folder is on Archil and mounted in it
112
117
  * (`folderKept`), that the folder is kept. The one kept through the run's park (`kept`) says it is the same; a new one
113
118
  * after a kept one's time passed (`replaced.lapsed`) says why first, as does one after a kept one pinned to a runner
114
- * that was gone by the resume (`replaced.lost`, computerLostWords). */
119
+ * that was gone by the resume (`replaced.lost`, computerLostWords), and one after the kept one's provider refused to
120
+ * attach it again (`replaced.refused`, in the provider's words). */
115
121
  export declare const computerReadyWords: ({ provider, kind, hello, replaced, kept }: ComputerSaid) => string;
116
122
  /** The run's timeline phase as its run parks with its computer kept (ClaimComputer.keeps), such as "The desktop is kept
117
123
  * for 10 minutes while you decide." */
@@ -206,14 +206,21 @@ export const computerStartingWords = ({ provider, kind }) => `Starting a ${kind}
206
206
  * server's stop, a park: the words fit each), and, where the run's folder is on Archil and mounted in it
207
207
  * (`folderKept`), that the folder is kept. The one kept through the run's park (`kept`) says it is the same; a new one
208
208
  * after a kept one's time passed (`replaced.lapsed`) says why first, as does one after a kept one pinned to a runner
209
- * that was gone by the resume (`replaced.lost`, computerLostWords). */
209
+ * that was gone by the resume (`replaced.lost`, computerLostWords), and one after the kept one's provider refused to
210
+ * attach it again (`replaced.refused`, in the provider's words). */
210
211
  export const computerReadyWords = ({ provider, kind, hello, replaced, kept }) => {
211
212
  const ready = `The ${kind} is ready: ${[OS_NAMES[hello.os] ?? hello.os, hello.osVersion].filter(Boolean).join(" ")} (${hello.arch}), from ${provider}.`;
212
213
  if (kept)
213
214
  return `${ready} It's the same ${kind}, as the wait left it.`;
214
215
  if (!replaced)
215
216
  return ready;
216
- const why = replaced.lost ? ` ${computerLostWords(kind)}` : replaced.lapsed ? ` ${computerLapsedWords(kind)}` : "";
217
+ const why = replaced.refused
218
+ ? ` The ${kind} kept before could not be taken back: ${replaced.refused.replace(/[.!?]+$/, "")}.`
219
+ : replaced.lost
220
+ ? ` ${computerLostWords(kind)}`
221
+ : replaced.lapsed
222
+ ? ` ${computerLapsedWords(kind)}`
223
+ : "";
217
224
  return `${ready}${why} It's a new ${kind}: the one before is gone, with what was on it.${replaced.folderKept ? " The run folder is kept." : ""}`;
218
225
  };
219
226
  /** The run's timeline phase as its run parks with its computer kept (ClaimComputer.keeps), such as "The desktop is kept
@@ -319,7 +326,7 @@ export function computerDepsFrom(options) {
319
326
  ...(options.hostWhy ? { hostWhy: (provider) => (Object.hasOwn(options.hostWhy, provider) ? options.hostWhy[provider] : undefined) } : {}),
320
327
  ...(options.daemon ? { daemon: options.daemon } : { daemon: dockerDaemonOf(env) }),
321
328
  ...(options.openComputerView ? { openComputerView: options.openComputerView } : {}),
322
- ...(store.pairedComputers ? { attached: { rows: () => store.pairedComputers.list(), ...(options.hub ? { hub: options.hub } : {}) } } : {}),
329
+ ...(store.pairedComputers ? { attached: { rows: () => store.pairedComputers.list(), ...(options.hub ? { hub: options.hub } : {}), ...(options.pairedRelay ? { relay: options.pairedRelay } : {}) } } : {}),
323
330
  };
324
331
  const factories = { ...computerProviderFactories(providers, (id) => storeLedger(store.computerLedger, id)), ...faux?.factories };
325
332
  return { computerForClaim: claimComputer, computerDeps, factories };
@@ -173,6 +173,10 @@ export interface ComputerForClaimDeps {
173
173
  * claim's Archil mount credential (Mode 2): the credential is this claim's to remove now (archil-claim.ts inherit),
174
174
  * since this claim mints none. Absent: nothing was minted (Mode 1). */
175
175
  readonly inheritMount?: () => void;
176
+ /** The kind of the run's computer an earlier claim's deny turned off for the run (runner/computer-journal.ts
177
+ * computerTurnedOff): this claim starts none, says so, and ends at once the one a park kept, its mount with it.
178
+ * Absent: the computer is on. */
179
+ readonly turnedOff?: string;
176
180
  /** The clock a kept computer's time is read by (computer-kept.ts), and its computers' intervals are written on
177
181
  * (computer-intervals.ts). Default Date.now. */
178
182
  readonly now?: () => number;
@@ -196,6 +200,10 @@ export interface ComputerForClaimDeps {
196
200
  * owner's view let go, then the computer. */
197
201
  export interface ClaimComputer {
198
202
  readonly computer?: RunComputer;
203
+ /** The agent's computer was not started: every tool it serves the run is set to deny (tool-gate.ts computerDenied), or
204
+ * an earlier claim's deny turned it off for the run (ComputerForClaimDeps.turnedOff). The run goes on without it, and
205
+ * its kind's skill is not named to the model. */
206
+ readonly off?: true;
199
207
  readonly hold?: RunHold;
200
208
  readonly held?: HeldComputer;
201
209
  /** The computer is a new one that replaced an earlier claim's (Replaced): what was on that one is gone. Absent: the
@@ -229,12 +237,15 @@ export type KeptKind = Kept["kind"];
229
237
  /** A computer the claim made fresh in place of an earlier claim's: its kind, and `folderKept`, the run's folder is on
230
238
  * Archil (Mode 2) and mounted in it, so the folder is kept. `lapsed`: the earlier one was kept at a park, and its time
231
239
  * (KEEP_MS) passed before this claim. `lost`: the earlier one was kept at a park pinned to another runner (or another
232
- * process of this runner's name), that runner was gone by this claim, and this claim could not reach it. */
240
+ * process of this runner's name), that runner was gone by this claim, and this claim could not reach it. `refused`: the
241
+ * earlier one was kept at a park, and its provider refused to attach it again, in these words (a Docker computer made
242
+ * before its egress bridge). */
233
243
  export type Replaced = {
234
244
  readonly kind: MadeKind;
235
245
  readonly folderKept: boolean;
236
246
  readonly lapsed?: true;
237
247
  readonly lost?: true;
248
+ readonly refused?: string;
238
249
  };
239
250
  /** The agent's computer setting: the launch's, else its revision's (computer, else place), else the launch's place. The
240
251
  * run's end reads it the same way (run-end-computers.ts). */
@@ -35,8 +35,9 @@
35
35
  // and a test's stand-ins are passed in.
36
36
  //
37
37
  // A paired computer (a person's own, attached-computers.ts) is one more provider of the registry for the claim, by its
38
- // id: claimed through the hub of the server's process (the computer package's attachedProvider), released by ending the
39
- // run's hold, never made or deleted.
38
+ // id: claimed through the hub of the server's process (the computer package's attachedProvider), or through a runner's
39
+ // relay hub once the server moved the box's socket there (dial-relay.ts), released by ending the run's hold, never made
40
+ // or deleted.
40
41
  //
41
42
  // A persistent setting (the agent's own computer, agent-computer.ts) is made once under the agent's owner (this server's
42
43
  // id and the agent's), found again by its owner at each later claim and attached under the new claim, and detached, not
@@ -55,9 +56,12 @@ import { pairedProvider, withPaired } from "./attached-computers.js";
55
56
  import { computerHold, heldHands } from "./computer-hold.js";
56
57
  import { endingDeletes, figuresOf, intervalWrites } from "./computer-intervals.js";
57
58
  import { computeMeter } from "../compute-cost.js";
58
- import { deleteKept, endKept, KEEP_MS, keptBy, pinnedOf, readKept, takeKept, writeKept } from "./computer-kept.js";
59
+ import { bounded, deleteKept, endKept, KEEP_MS, KEPT_DELETE_MS, keptBy, pinnedOf, readKept, takeKept, writeKept } from "./computer-kept.js";
59
60
  import { storeLedger } from "./computer-ledger.js";
60
- import { providerKeys, registryHere, resolveComputer } from "./resolve-computer.js";
61
+ import { providerKeys, registryHere, resolveComputer, runShellOf } from "./resolve-computer.js";
62
+ import { computerDenied } from "../tool-gate.js";
63
+ import { loadToolSettings } from "../tool-plane.js";
64
+ import { computerDeniedWords, computerStillOffWords } from "../refusal-words.js";
61
65
  import { claimHolds, fencedStore, holdSynced, storedFolder } from "./synced-folder.js";
62
66
  /** A computer that cannot be had, with the code the run fails with and the server's words. */
63
67
  const unavailable = (words) => Object.assign(new Error(words), { code: "computer_unavailable" });
@@ -94,6 +98,20 @@ export async function settingOf(launch, store) {
94
98
  return computerOfPlace(body.place);
95
99
  return launch.place ? computerOfPlace(launch.place) : undefined;
96
100
  }
101
+ /** The kind of the claim's computer `setting` when every tool it serves the run is set to deny (tool-gate.ts
102
+ * computerDenied): the revision's grants and tool settings over the server's, as the run's gate reads them. `shell`: where
103
+ * the run's shell would be with it. A store with no settings, or settings that do not read, deny nothing. */
104
+ async function deniedKind(launch, setting, store, shell) {
105
+ if (setting.kind === "none" || !store.settings || !launch.revisionId)
106
+ return undefined;
107
+ const revision = await store.agents.revision(launch.revisionId);
108
+ if (!revision || revision.kind !== "agentic")
109
+ return undefined;
110
+ const server = await loadToolSettings({ settings: store.settings }).catch(() => undefined);
111
+ if (!server || server.unreadable)
112
+ return undefined;
113
+ return computerDenied({ kind: revision.kind, body: { ...revision.body, computer: setting } }, shell, server);
114
+ }
97
115
  /** A phone's platform: what the phone says it is, else its provider's phone configuration's machine kind; android when
98
116
  * neither says ios. */
99
117
  function phonePlatform(machine, entry) {
@@ -442,13 +460,14 @@ function lostAware(first, renewal) {
442
460
  },
443
461
  };
444
462
  }
445
- /** The computer an earlier claim of the run kept at its park (`kept`), attached again through `provider` and connected,
446
- * or undefined when its provider no longer has it or it does not connect (one that does not is deleted). */
463
+ /** The computer an earlier claim of the run kept at its park (`kept`), attached again through `provider` and connected;
464
+ * `refused`, the provider's words, when it refuses to attach it; or undefined when its provider no longer has it or it
465
+ * does not connect (one that does not is deleted). */
447
466
  async function keptLaunch(provider, kept, signal, ended) {
448
467
  const ref = { id: kept.id, name: kept.name };
449
468
  const found = await provider.attach({ id: ref.id }, signal ? { signal } : {});
450
469
  if (!found.ok)
451
- return undefined;
470
+ return found.error.code === "refused" ? { refused: found.error.message } : undefined;
452
471
  const connected = await provider.connect(ref);
453
472
  if (!connected.ok) {
454
473
  const released = await provider.release(ref, "delete").catch(() => undefined);
@@ -657,6 +676,8 @@ store, deps) {
657
676
  /** The kept computer was pinned to another runner, gone by this claim, and this claim could not reach it: the new one
658
677
  * says so (Replaced.lost). */
659
678
  let lost = false;
679
+ /** The kept computer's provider refused to attach it again, in these words: the new one says why (Replaced.refused). */
680
+ let refused;
660
681
  /** What a park of this claim keeps (ClaimComputer.park): a desktop, a phone or a sandbox it made through its provider, or took
661
682
  * back, with its provider, its connection's close and the claim epoch its labels carry; `pinned`: only this runner can
662
683
  * reach it again (computer-kept.ts pinnedOf), so the park names this claim's holder on its row. */
@@ -793,8 +814,9 @@ store, deps) {
793
814
  }
794
815
  const provider = await vendorProvider(entry, keys, configuration);
795
816
  const taken = await keptLaunch(provider, record, signal, () => writes.ended(entry.id, record.id));
796
- if (!taken) {
817
+ if (!taken || "refused" in taken) {
797
818
  lost = elsewhere;
819
+ refused = taken?.refused;
798
820
  return undefined;
799
821
  }
800
822
  // Metered again from here, with what its interval says it was made with: the time it was kept is no claim's.
@@ -835,7 +857,9 @@ store, deps) {
835
857
  madeBy = entry;
836
858
  return own;
837
859
  }
838
- const provider = pairedRow ? pairedProvider(pairedRow, deps.attached?.hub) : await vendorProvider(entry, keys, configuration);
860
+ // Under a runner of its own process, through its relay: the box is routed under the run's claim (launch.claim, a
861
+ // store Claim from each claim's launch), so a claim another runner superseded is Fenced at the route.
862
+ const provider = pairedRow ? pairedProvider(pairedRow, deps.attached?.hub, deps.attached?.relay, launch.claim) : await vendorProvider(entry, keys, configuration);
839
863
  const spec = { ...(await specOf(entry, provider, kind, configuration, signal, gpu)), ...(mount ? { mount } : {}) };
840
864
  // A browser makes nothing here: the run's browser tool opens each session through it, so a session lives (and is
841
865
  // booked) only while the tool holds it.
@@ -881,8 +905,8 @@ store, deps) {
881
905
  ownKind = kind;
882
906
  if (!pairedRow && (kind === "desktop" || kind === "phone" || kind === "sandbox"))
883
907
  keepable = { provider, entry: entry.id, kind, computer: held, pinned: pinnedHere(entry, configuration), epoch: launch.epoch };
884
- if (!pairedRow && (releasedOlder || journalSays || lost))
885
- replaced = { kind: kind, folderKept: deps.mode === 2 && mount !== undefined, ...(lost ? { lost: true } : lapsed ? { lapsed: true } : {}) };
908
+ if (!pairedRow && (releasedOlder || journalSays || lost || refused !== undefined))
909
+ replaced = { kind: kind, folderKept: deps.mode === 2 && mount !== undefined, ...(lost ? { lost: true } : lapsed ? { lapsed: true } : {}), ...(refused !== undefined ? { refused } : {}) };
886
910
  }
887
911
  made = { id: launched.id, machine: launched.machine, ...(launched.watch ? { watch: launched.watch, ...(kind === "desktop" || kind === "phone" ? { gone: goneOf(provider, launched.id, listedUnder, kind) } : {}) } : {}) };
888
912
  madeBy = entry;
@@ -891,6 +915,46 @@ store, deps) {
891
915
  return launched;
892
916
  },
893
917
  };
918
+ /** The computer an earlier claim kept at the run's park, ended now by a claim that starts none (the run's computer is
919
+ * off): deleted, its interval ended, and its mount credential, the parking claim's, taken on and removed
920
+ * (archil-claim.ts revoke removes only one its claim minted or took on), so the run's folder is its own again before
921
+ * its tools touch it. The credential is taken on only once this claim's end holds the row (endKept's compare-and-set):
922
+ * a later claim that took the computer back first holds its mount, which this claim's revoke (at its loss, its end)
923
+ * then never removes. Once taken on, a revoke this claim does not finish here is the run's end's. The delete and the
924
+ * revoke together are bounded (KEPT_DELETE_MS) and end at the run's stop: one that fails or does not answer leaves the
925
+ * row ending, for the janitor's next pass. Never throws. */
926
+ const endKeptNow = async () => {
927
+ const record = kept;
928
+ kept = undefined;
929
+ const settings = store.settings;
930
+ const entry = record && kinds.PROVIDERS.find((one) => one.id === record.provider);
931
+ if (!record || record.ended || !settings || !entry)
932
+ return;
933
+ try {
934
+ await endKept(settings, launch.runId, record, () => {
935
+ deps.inheritMount?.();
936
+ return bounded(KEPT_DELETE_MS, (async () => {
937
+ try {
938
+ const provider = await vendorProvider(entry, await side.keysOf(entry.id), {});
939
+ if (await deleteKept(provider, record))
940
+ await writes.ended(entry.id, record.id);
941
+ }
942
+ finally {
943
+ await deps.revokeMount?.().catch(() => undefined);
944
+ }
945
+ })(), deps.signal);
946
+ });
947
+ }
948
+ catch {
949
+ // Left ending for the janitor.
950
+ }
951
+ };
952
+ // The run's computer turned off by an earlier claim's deny: none is started, and the one a park kept goes now.
953
+ if (deps.turnedOff) {
954
+ deps.onComputerNote?.(computerStillOffWords(deps.turnedOff));
955
+ await endKeptNow();
956
+ return { computer: undefined, off: true, release: noop };
957
+ }
894
958
  const setting = await settingOf(launch, store);
895
959
  // Programs it needs (computer.needs) are checked in a sandbox's box alone: a setting that needs them and is any other
896
960
  // kind is refused before anything is rented, never run without them.
@@ -899,6 +963,14 @@ store, deps) {
899
963
  const label = setting?.provider ? kinds.PROVIDERS.find((one) => one.id === setting.provider)?.label ?? setting.provider : undefined;
900
964
  throw unavailable(needsNoSandboxWords(needs, setting?.kind === "none" || !setting ? "none" : `a ${setting.kind}${label ? ` on ${label}` : ""}`));
901
965
  }
966
+ // A computer every tool of which is set to deny (tool-gate.ts computerDenied) serves the run nothing: none is started,
967
+ // nothing is rented or checked, and the run goes on without it, its timeline saying why.
968
+ const denied = setting && (await deniedKind(launch, setting, store, runShellOf(setting, deps.mode, kinds)));
969
+ if (denied) {
970
+ deps.onComputerNote?.(computerDeniedWords(denied));
971
+ await endKeptNow();
972
+ return { computer: undefined, off: true, release: noop };
973
+ }
902
974
  const resolved = await resolveComputer(setting, deps.mode, kinds, side);
903
975
  if ("refused" in resolved)
904
976
  throw unavailable(resolved.refused);
@@ -136,3 +136,6 @@ export declare function sweepKept(deps: {
136
136
  * provider's delete answered ok, the one answer that proves its end now (its interval's, computer-intervals.ts); false
137
137
  * for one already gone, whose end is not known. */
138
138
  export declare function deleteKept(provider: Pick<ComputerProvider, "release">, kept: Pick<Kept, "id" | "name">): Promise<boolean>;
139
+ /** `work`, or its timeout in words after `ms`, or `signal`'s abort, whichever is first: a delete that hangs is left to
140
+ * finish on its own. */
141
+ export declare function bounded(ms: number, work: Promise<void>, signal?: AbortSignal): Promise<void>;
@@ -254,17 +254,26 @@ export async function deleteKept(provider, kept) {
254
254
  throw new Error(released.error.message);
255
255
  return released.ok;
256
256
  }
257
- /** `work`, or its timeout in words after `ms`: a delete that hangs is left to finish on its own. */
258
- async function bounded(ms, work) {
257
+ /** `work`, or its timeout in words after `ms`, or `signal`'s abort, whichever is first: a delete that hangs is left to
258
+ * finish on its own. */
259
+ export async function bounded(ms, work, signal) {
259
260
  let timer;
261
+ let stopped;
260
262
  const late = new Promise((_, reject) => {
261
263
  timer = setTimeout(() => reject(new Error(`its delete did not answer within ${ms / 1000} s; the next pass tries again`)), ms);
264
+ stopped = () => reject(new Error("its delete was left at the run's stop; the next pass tries again"));
265
+ if (signal?.aborted)
266
+ stopped();
267
+ else
268
+ signal?.addEventListener("abort", stopped, { once: true });
262
269
  });
263
270
  try {
264
271
  await Promise.race([work, late]);
265
272
  }
266
273
  finally {
267
274
  clearTimeout(timer);
275
+ if (stopped)
276
+ signal?.removeEventListener("abort", stopped);
268
277
  }
269
278
  }
270
279
  const words = (error) => (error instanceof Error ? error.message : String(error));
@@ -24,4 +24,4 @@ export { type ClaimComputer, type ClaimLaunch, computerForClaim, type ComputerFo
24
24
  export { JANITOR_EVERY_MS, type JanitorDeps, type ProviderSweep, startJanitor, sweepServerComputers } from "./computer-janitor.js";
25
25
  export { agentComputerOf, agentComputerView, ownerGoneOf, reconcileAgentComputer, serverIdOf } from "./agent-computer.js";
26
26
  export { layOwnSkills, RUN_SKILLS_DIR } from "./revision-skills.js";
27
- export { KIND_SKILLS, type KindSkill, kindSkillOf, type SkillKind } from "./kind-skills.js";
27
+ export { KIND_SKILLS, type KindSkill, kindSkillOf, type SkillKind, withoutKindSkill } from "./kind-skills.js";
@@ -26,4 +26,4 @@ export { computerForClaim } from "./computer-for-claim.js";
26
26
  export { JANITOR_EVERY_MS, startJanitor, sweepServerComputers } from "./computer-janitor.js";
27
27
  export { agentComputerOf, agentComputerView, ownerGoneOf, reconcileAgentComputer, serverIdOf } from "./agent-computer.js";
28
28
  export { layOwnSkills, RUN_SKILLS_DIR } from "./revision-skills.js";
29
- export { KIND_SKILLS, kindSkillOf } from "./kind-skills.js";
29
+ export { KIND_SKILLS, kindSkillOf, withoutKindSkill } from "./kind-skills.js";
@@ -9,3 +9,7 @@ export type SkillKind = "desktop" | "phone";
9
9
  export declare const KIND_SKILLS: Readonly<Record<SkillKind, KindSkill>>;
10
10
  /** The skill a run's computer kind brings, if it brings one. */
11
11
  export declare const kindSkillOf: (kind: string | undefined) => KindSkill | undefined;
12
+ /** A run's skill files without the one its computer kind brings: for a computer the claim did not start (every tool of
13
+ * it set to deny: ClaimComputer.off), whose skill is named to no one. An authored skill of that name is the agent's own,
14
+ * and stays. */
15
+ export declare function withoutKindSkill(files: readonly string[], authored: Readonly<Record<string, unknown>>, kind: string | undefined): readonly string[];
@@ -14,3 +14,12 @@ const read = (kind) => {
14
14
  export const KIND_SKILLS = Object.freeze({ desktop: read("desktop"), phone: read("phone") });
15
15
  /** The skill a run's computer kind brings, if it brings one. */
16
16
  export const kindSkillOf = (kind) => (kind === "desktop" || kind === "phone" ? KIND_SKILLS[kind] : undefined);
17
+ /** A run's skill files without the one its computer kind brings: for a computer the claim did not start (every tool of
18
+ * it set to deny: ClaimComputer.off), whose skill is named to no one. An authored skill of that name is the agent's own,
19
+ * and stays. */
20
+ export function withoutKindSkill(files, authored, kind) {
21
+ const skill = kindSkillOf(kind);
22
+ if (!skill || Object.keys(authored).some((path) => path.split("/")[0] === skill.name))
23
+ return files;
24
+ return files.filter((file) => file !== `${skill.name}/SKILL.md`);
25
+ }
@@ -0,0 +1,91 @@
1
+ import { type Claim, type Runners, type Runs, type Settings } from "../store/index.js";
2
+ /** The settings key prefix of the paired computers' routes, one row per computer. */
3
+ export declare const ROUTE_PREFIX = "paired_route:";
4
+ /** The settings key of computer `id`'s route. */
5
+ export declare const routeKeyOf: (id: string) => string;
6
+ /** How often the server compares each route with where the box's socket is (server.ts, computer-attach.ts tick). */
7
+ export declare const PAIRED_ROUTE_MS = 1000;
8
+ /** How long a run's claim waits for its box to reach its runner: one tick of the server's, the driver's longest wait
9
+ * between dials (it backs off after quick reconnects), the relay's connect and the hub's hello. */
10
+ export declare const PAIRED_BRING_MS: number;
11
+ /** How often the claim reads the route while it waits. */
12
+ export declare const PAIRED_BRING_POLL_MS = 500;
13
+ /** A paired computer's route: the runner whose hub holds the box for `run` (and that runner's incarnation), the hold's
14
+ * end (ms), and the server's note of why a route was refused or dropped. All null: no route, the server's hub. */
15
+ export type Route = {
16
+ readonly runner: string | null;
17
+ readonly incarnation: string | null;
18
+ readonly run: string | null;
19
+ readonly until: number | null;
20
+ readonly refused: string | null;
21
+ };
22
+ /** No route and no note. */
23
+ export declare const EMPTY_ROUTE: Route;
24
+ /** What a run's claim asks: its runner and incarnation, the run, and its hold's end (ms). */
25
+ export type RouteWant = {
26
+ readonly runner: string;
27
+ readonly incarnation: string;
28
+ readonly run: string;
29
+ readonly until: number;
30
+ };
31
+ /** The settings the routes live in. */
32
+ export type RouteSettings = Pick<Settings, "get" | "putIfAbsent" | "replaceIf" | "removeIf" | "remove" | "all">;
33
+ /** What a take reads: the routes, the runners (is the route's runner live), and the runs (is the route's run final). */
34
+ export type RouteDeps = {
35
+ readonly settings: Pick<RouteSettings, "get" | "putIfAbsent" | "replaceIf" | "removeIf">;
36
+ readonly runners: Pick<Runners, "live">;
37
+ readonly runs?: Pick<Runs, "get">;
38
+ };
39
+ /** A row's value as a Route; anything else reads as EMPTY_ROUTE. */
40
+ export declare function routeOf(value: unknown): Route;
41
+ /** Computer `id`'s route as its row reads now: EMPTY_ROUTE when there is none. */
42
+ export declare function readRoute(settings: Pick<RouteSettings, "get">, id: string): Promise<Route>;
43
+ /** Computer `id`'s route and its row's value as read (undefined: no row), for a compare-and-set on it. */
44
+ export declare function seeRoute(settings: Pick<RouteSettings, "get">, id: string): Promise<{
45
+ readonly seen: unknown;
46
+ readonly route: Route;
47
+ }>;
48
+ /** Every route row, as the server's tick reads them: one read of the prefix, a range on the settings' primary key. */
49
+ export declare function allRoutes(settings: Pick<RouteSettings, "all">): Promise<{
50
+ readonly id: string;
51
+ readonly seen: unknown;
52
+ readonly route: Route;
53
+ }[]>;
54
+ /** Writes `next` over computer `id`'s row while it still holds `seen` (as read): one compare-and-set. An empty `next` (no
55
+ * route, no note) removes the row. False when the row changed since. */
56
+ export declare function replaceRoute(settings: Pick<RouteSettings, "putIfAbsent" | "replaceIf" | "removeIf">, id: string, seen: unknown, next: Route, claim?: Claim): Promise<boolean>;
57
+ /** `name` held by another run, on a live runner. */
58
+ export declare const heldWords: (name: string, run: string, runner: string) => string;
59
+ /** How a stale route's words end (the server's 503 and the box's note): where the box goes, and when. */
60
+ export declare const ROUTE_COMES_BACK = "it comes back to this server at its next dial, within 60 s, and the run's next claim takes it again";
61
+ /** What a route says once its runner restarted. The words for a runner gone are the relay's own (computer-attach.ts
62
+ * relayDial), ending in ROUTE_COMES_BACK. */
63
+ export declare const routeRestartedWords: (runner: string) => string;
64
+ /** A box routed to a run's runner, attached nowhere: the claim's wait ends in these words. */
65
+ export declare const notAttachedWords: (name: string) => string;
66
+ /** A box that did not reach its run's runner within PAIRED_BRING_MS. */
67
+ export declare const lateWords: (name: string, runner: string) => string;
68
+ /** What a take came to: the route taken (as written), or why not, with the route as it is. */
69
+ export type Took = {
70
+ readonly taken: true;
71
+ readonly route: Route;
72
+ } | {
73
+ readonly taken: false;
74
+ readonly why: string;
75
+ readonly route: Route;
76
+ };
77
+ /** Routes computer `id` to `want`'s runner for its run, where holdsAgainst lets it: the run's claim, before it waits for
78
+ * the box (dial-relay.ts bring). With `claim`, the write checks the claim's epoch and lease in its transaction, so a
79
+ * claim another runner superseded throws Fenced and writes nothing. `name` is the computer's, for the words. */
80
+ export declare function takeRoute(deps: RouteDeps, id: string, want: RouteWant, { claim, name }?: {
81
+ readonly claim?: Claim;
82
+ readonly name?: string;
83
+ }): Promise<Took>;
84
+ /** Drops computer `id`'s route where it is `mine` (its runner and incarnation, and its run where given): the runner
85
+ * that holds it, once its hold ended. `note` is kept on the row (why the run let it go); none: the row goes. False when
86
+ * the route is not mine (another's, or none). */
87
+ export declare function dropRoute(settings: Pick<RouteSettings, "get" | "putIfAbsent" | "replaceIf" | "removeIf">, id: string, mine: {
88
+ readonly runner: string;
89
+ readonly incarnation: string;
90
+ readonly run?: string;
91
+ }, note?: string): Promise<boolean>;