@parcha/agentrun-serve 0.1.0-beta.55 → 0.1.0-beta.57

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 (296) hide show
  1. package/CHANGELOG.md +261 -0
  2. package/README.md +228 -45
  3. package/dist/acp-package.d.ts +2 -0
  4. package/dist/adapters.d.ts +18 -5
  5. package/dist/adapters.js +23 -9
  6. package/dist/agent-package.d.ts +3 -3
  7. package/dist/agent-package.js +17 -8
  8. package/dist/answer-json.d.ts +6 -2
  9. package/dist/answer-json.js +22 -4
  10. package/dist/api-keys.d.ts +76 -0
  11. package/dist/api-keys.js +217 -0
  12. package/dist/api-only.d.ts +17 -5
  13. package/dist/api-only.js +36 -8
  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/calendar/tools.js +3 -2
  19. package/dist/chatgpt-plan.d.ts +28 -3
  20. package/dist/chatgpt-plan.js +182 -21
  21. package/dist/claude-login.d.ts +101 -14
  22. package/dist/claude-login.js +232 -49
  23. package/dist/claude-sign-in.d.ts +46 -0
  24. package/dist/claude-sign-in.js +93 -0
  25. package/dist/cli.js +63 -6
  26. package/dist/composio-made.d.ts +4 -0
  27. package/dist/composio-made.js +4 -0
  28. package/dist/composio-preset.d.ts +43 -2
  29. package/dist/composio-preset.js +92 -4
  30. package/dist/computer-held-routes.d.ts +5 -4
  31. package/dist/computer-held-routes.js +29 -8
  32. package/dist/computer-held.d.ts +6 -1
  33. package/dist/computer-held.js +14 -0
  34. package/dist/computer-record.js +4 -2
  35. package/dist/computer-viewer.js +4 -1
  36. package/dist/console/assets/{backend-D5EmB4N3.js → backend-DVhHzJX2.js} +19 -19
  37. package/dist/console/assets/index-Bwn1oTem.css +1 -0
  38. package/dist/console/assets/index-okP-y8PK.js +747 -0
  39. package/dist/console/index.html +2 -2
  40. package/dist/decisions.d.ts +1 -1
  41. package/dist/decisions.js +1 -1
  42. package/dist/docker-host-addresses.d.ts +22 -11
  43. package/dist/docker-host-addresses.js +38 -26
  44. package/dist/env-switch.d.ts +10 -0
  45. package/dist/env-switch.js +33 -2
  46. package/dist/errors.d.ts +1 -0
  47. package/dist/errors.js +2 -0
  48. package/dist/fal-price.d.ts +58 -20
  49. package/dist/fal-price.js +341 -82
  50. package/dist/handed-values.d.ts +43 -1
  51. package/dist/handed-values.js +119 -2
  52. package/dist/harness-archive.d.ts +13 -10
  53. package/dist/harness-archive.js +60 -34
  54. package/dist/harness-check.d.ts +3 -1
  55. package/dist/harness-check.js +25 -46
  56. package/dist/harness-keys.d.ts +73 -27
  57. package/dist/harness-keys.js +194 -61
  58. package/dist/harness-recipe-entry.d.ts +8 -7
  59. package/dist/harness-recipe-entry.js +21 -32
  60. package/dist/harness-recipe.d.ts +38 -25
  61. package/dist/harness-recipe.js +49 -36
  62. package/dist/harness-sign-in.js +12 -23
  63. package/dist/harness-table.d.ts +10 -3
  64. package/dist/harness-table.js +26 -21
  65. package/dist/harness.d.ts +1 -0
  66. package/dist/harness.js +17 -5
  67. package/dist/host-check.d.ts +4 -0
  68. package/dist/host-check.js +4 -0
  69. package/dist/hosted-search.d.ts +1 -1
  70. package/dist/hosted-search.js +1 -2
  71. package/dist/import-worker.d.ts +4 -2
  72. package/dist/import-worker.js +9 -2
  73. package/dist/in-flight.d.ts +26 -0
  74. package/dist/in-flight.js +52 -0
  75. package/dist/key-refusal.d.ts +26 -5
  76. package/dist/key-refusal.js +313 -37
  77. package/dist/learn/secrets.d.ts +31 -11
  78. package/dist/learn/secrets.js +152 -191
  79. package/dist/learning-cost.d.ts +6 -3
  80. package/dist/learning-cost.js +4 -2
  81. package/dist/link-check.js +1 -1
  82. package/dist/llms.txt +2 -2
  83. package/dist/marketplace.d.ts +77 -0
  84. package/dist/marketplace.js +224 -0
  85. package/dist/mcp-api-only-origins.d.ts +30 -0
  86. package/dist/mcp-api-only-origins.js +57 -0
  87. package/dist/mcp-gateway.d.ts +7 -5
  88. package/dist/mcp-gateway.js +9 -12
  89. package/dist/mcp-secret-writes.js +5 -3
  90. package/dist/mcp-servers-store.d.ts +28 -6
  91. package/dist/mcp-servers-store.js +53 -4
  92. package/dist/media-duration.d.ts +3 -0
  93. package/dist/media-duration.js +90 -9
  94. package/dist/model-form.d.ts +5 -4
  95. package/dist/model-form.js +11 -7
  96. package/dist/model.d.ts +5 -2
  97. package/dist/model.js +9 -5
  98. package/dist/ollama-provider.d.ts +7 -1
  99. package/dist/ollama-provider.js +14 -2
  100. package/dist/openapi.d.ts +3 -3
  101. package/dist/openapi.js +245 -42
  102. package/dist/otel/genai.d.ts +65 -0
  103. package/dist/otel/genai.js +116 -0
  104. package/dist/otel/tracer.d.ts +55 -0
  105. package/dist/otel/tracer.js +308 -0
  106. package/dist/page.d.ts +2 -0
  107. package/dist/page.js +3 -1
  108. package/dist/paid-calls.d.ts +1 -32
  109. package/dist/paid-calls.js +4 -39
  110. package/dist/place-offers.d.ts +14 -6
  111. package/dist/place-offers.js +26 -13
  112. package/dist/provider.d.ts +9 -0
  113. package/dist/provider.js +50 -3
  114. package/dist/redact/match.d.ts +101 -0
  115. package/dist/redact/match.js +1152 -0
  116. package/dist/refusal-words.d.ts +11 -0
  117. package/dist/refusal-words.js +11 -0
  118. package/dist/run-census.d.ts +67 -0
  119. package/dist/run-census.js +240 -0
  120. package/dist/run-computer.d.ts +6 -3
  121. package/dist/run-computer.js +4 -1
  122. package/dist/run-cut.d.ts +15 -6
  123. package/dist/run-cut.js +30 -9
  124. package/dist/run-files.d.ts +3 -0
  125. package/dist/run-files.js +3 -0
  126. package/dist/run-launch.d.ts +12 -1
  127. package/dist/run-launch.js +9 -10
  128. package/dist/run-learning-served.d.ts +2 -0
  129. package/dist/run-model-key.d.ts +8 -0
  130. package/dist/run-model-key.js +31 -1
  131. package/dist/run-reads-over-store.d.ts +24 -6
  132. package/dist/run-reads-over-store.js +67 -23
  133. package/dist/run-recordings.d.ts +5 -1
  134. package/dist/run-recordings.js +39 -14
  135. package/dist/run-timeline-served.d.ts +3 -1
  136. package/dist/run-timeline-served.js +4 -4
  137. package/dist/run-usage.d.ts +1 -0
  138. package/dist/runnable.d.ts +10 -1
  139. package/dist/runnable.js +20 -8
  140. package/dist/runner/adapter-loop.d.ts +14 -0
  141. package/dist/runner/adapter-loop.js +56 -11
  142. package/dist/runner/adapter-run-spec.d.ts +45 -8
  143. package/dist/runner/adapter-run-spec.js +154 -29
  144. package/dist/runner/adapters/pi.js +25 -3
  145. package/dist/runner/beside.js +11 -6
  146. package/dist/runner/big-writes.js +1 -10
  147. package/dist/runner/claim-secrets.d.ts +18 -3
  148. package/dist/runner/claim-secrets.js +35 -6
  149. package/dist/runner/cli-run-spec.d.ts +6 -0
  150. package/dist/runner/cli-run-spec.js +85 -36
  151. package/dist/runner/computer-journal.d.ts +9 -1
  152. package/dist/runner/computer-journal.js +26 -0
  153. package/dist/runner/conformance/harness.js +1 -1
  154. package/dist/runner/feedback-round.js +3 -0
  155. package/dist/runner/harness-loops.d.ts +6 -5
  156. package/dist/runner/harness-loops.js +7 -7
  157. package/dist/runner/held.d.ts +11 -5
  158. package/dist/runner/journal-kinds.d.ts +5 -0
  159. package/dist/runner/journal-kinds.js +5 -0
  160. package/dist/runner/loop-contract.d.ts +4 -0
  161. package/dist/runner/main.js +15 -6
  162. package/dist/runner/mcp-claim.js +30 -3
  163. package/dist/runner/mcp-run.d.ts +12 -0
  164. package/dist/runner/mcp-run.js +12 -5
  165. package/dist/runner/model-route.d.ts +17 -0
  166. package/dist/runner/model-route.js +120 -2
  167. package/dist/runner/presence.d.ts +4 -3
  168. package/dist/runner/presence.js +4 -2
  169. package/dist/runner/run-child-host.d.ts +5 -0
  170. package/dist/runner/run-child-host.js +71 -30
  171. package/dist/runner/run-child.js +5 -2
  172. package/dist/runner/runner.d.ts +18 -3
  173. package/dist/runner/runner.js +162 -36
  174. package/dist/runner/store-port.d.ts +1 -1
  175. package/dist/runner/store-secrets.d.ts +6 -0
  176. package/dist/runner/store-secrets.js +49 -7
  177. package/dist/runner/subagent.js +4 -40
  178. package/dist/runner/workflow-first.d.ts +11 -4
  179. package/dist/runner/workflow-first.js +14 -8
  180. package/dist/runner/workflow-spec.js +3 -2
  181. package/dist/runs-over-store.d.ts +15 -6
  182. package/dist/runs-over-store.js +33 -21
  183. package/dist/scrub-command.d.ts +73 -0
  184. package/dist/scrub-command.js +307 -0
  185. package/dist/secret-cut.d.ts +73 -0
  186. package/dist/secret-cut.js +291 -4
  187. package/dist/secret-rules.d.ts +143 -0
  188. package/dist/secret-rules.js +2564 -0
  189. package/dist/secrets.d.ts +7 -0
  190. package/dist/secrets.js +20 -0
  191. package/dist/server-keys.d.ts +20 -0
  192. package/dist/server-keys.js +25 -6
  193. package/dist/server.d.ts +57 -13
  194. package/dist/server.js +371 -113
  195. package/dist/skills/agentrun-serve/SKILL.md +4 -0
  196. package/dist/store/dialect.d.ts +3 -0
  197. package/dist/store/dialect.js +1 -0
  198. package/dist/store/index.d.ts +1 -1
  199. package/dist/store/index.js +1 -1
  200. package/dist/store/journal/storage.js +1 -1
  201. package/dist/store/postgres/dialect.js +3 -0
  202. package/dist/store/postgres/migrations/0027_run_launch_census.sql +31 -0
  203. package/dist/store/schema.d.ts +6 -0
  204. package/dist/store/schema.js +11 -1
  205. package/dist/store/seal.d.ts +6 -1
  206. package/dist/store/seal.js +5 -3
  207. package/dist/store/sqlite/run-launch.d.ts +9 -1
  208. package/dist/store/sqlite/run-launch.js +24 -13
  209. package/dist/store/sqlite/run-patch.d.ts +1 -1
  210. package/dist/store/sqlite/run-patch.js +13 -4
  211. package/dist/store/sqlite/store.js +76 -16
  212. package/dist/store/store.d.ts +53 -3
  213. package/dist/store/store.js +27 -0
  214. package/dist/store-reads/learning.d.ts +6 -3
  215. package/dist/store-reads/learning.js +22 -7
  216. package/dist/store-view.d.ts +3 -0
  217. package/dist/store-view.js +4 -4
  218. package/dist/suggestions.js +3 -2
  219. package/dist/template-eval.d.ts +22 -11
  220. package/dist/template-eval.js +124 -41
  221. package/dist/template-import.d.ts +10 -0
  222. package/dist/template-import.js +16 -7
  223. package/dist/templates.d.ts +10 -2
  224. package/dist/templates.js +28 -8
  225. package/dist/timeline/index.d.ts +1 -1
  226. package/dist/timeline/index.js +1 -1
  227. package/dist/timeline/labels.d.ts +6 -4
  228. package/dist/timeline/labels.js +18 -6
  229. package/dist/timeline/timeline.d.ts +17 -7
  230. package/dist/timeline/timeline.js +28 -14
  231. package/dist/timeline/util.js +1 -1
  232. package/dist/timeline/web-calls.d.ts +26 -9
  233. package/dist/timeline/web-calls.js +124 -37
  234. package/dist/tool-gate.d.ts +42 -3
  235. package/dist/tool-gate.js +69 -6
  236. package/dist/tool-keys-store.d.ts +2 -4
  237. package/dist/tool-keys-store.js +5 -21
  238. package/dist/tool-keys.d.ts +2 -2
  239. package/dist/tool-keys.js +2 -2
  240. package/dist/tool-list.js +1 -1
  241. package/dist/tool-plane.d.ts +2 -2
  242. package/dist/tool-plane.js +35 -33
  243. package/dist/tools.js +13 -7
  244. package/dist/trigger-targets.d.ts +4 -0
  245. package/dist/trigger-targets.js +9 -2
  246. package/dist/triggers.d.ts +67 -4
  247. package/dist/triggers.js +171 -22
  248. package/dist/until.d.ts +3 -0
  249. package/dist/until.js +11 -0
  250. package/dist/validate.js +1 -1
  251. package/dist/web-fake.d.ts +1 -3
  252. package/dist/web-fake.js +7 -18
  253. package/dist/web-fetch.d.ts +6 -72
  254. package/dist/web-fetch.js +11 -265
  255. package/dist/web-run.d.ts +31 -0
  256. package/dist/web-run.js +90 -0
  257. package/dist/web-save.d.ts +6 -4
  258. package/dist/web-save.js +9 -12
  259. package/dist/web-search.d.ts +9 -127
  260. package/dist/web-search.js +23 -259
  261. package/dist/wires.d.ts +13 -0
  262. package/dist/wires.js +11 -0
  263. package/dist/workflow-run.d.ts +5 -4
  264. package/dist/workflow-run.js +5 -4
  265. package/dist/workspace/computer-deps.d.ts +3 -1
  266. package/dist/workspace/computer-deps.js +12 -4
  267. package/dist/workspace/computer-for-claim.d.ts +19 -2
  268. package/dist/workspace/computer-for-claim.js +101 -13
  269. package/dist/workspace/computer-janitor.d.ts +15 -7
  270. package/dist/workspace/computer-janitor.js +33 -8
  271. package/dist/workspace/computer-kept.d.ts +55 -4
  272. package/dist/workspace/computer-kept.js +129 -8
  273. package/dist/workspace/index.d.ts +1 -1
  274. package/dist/workspace/index.js +1 -1
  275. package/dist/workspace/kind-skills.d.ts +4 -0
  276. package/dist/workspace/kind-skills.js +9 -0
  277. package/dist/workspace/run-end-computers.d.ts +5 -1
  278. package/dist/workspace/run-end-computers.js +27 -1
  279. package/dist/workspace/synced-folder.js +3 -4
  280. package/dist/wrapped.d.ts +65 -0
  281. package/dist/wrapped.js +77 -0
  282. package/package.json +17 -11
  283. package/skills/agentrun-serve/SKILL.md +4 -0
  284. package/templates/README.md +38 -15
  285. package/dist/console/assets/index-DUYLaqiR.js +0 -746
  286. package/dist/console/assets/index-DYhU4adm.css +0 -1
  287. package/dist/exa-keyless.d.ts +0 -34
  288. package/dist/exa-keyless.js +0 -118
  289. package/dist/firecrawl-keyless.d.ts +0 -41
  290. package/dist/firecrawl-keyless.js +0 -152
  291. package/dist/keyless-mcp.d.ts +0 -36
  292. package/dist/keyless-mcp.js +0 -127
  293. package/dist/text-urls.d.ts +0 -38
  294. package/dist/text-urls.js +0 -170
  295. package/dist/web-fetch-direct.d.ts +0 -119
  296. package/dist/web-fetch-direct.js +0 -190
@@ -7,7 +7,7 @@ import type { MountCheck } from "./attach.js";
7
7
  import { type AttachedComputers } from "./attached-computers.js";
8
8
  import { type HeldComputer } from "./computer-hold.js";
9
9
  import { type ComputeLedger, type ComputeMeterOptions } from "../compute-cost.js";
10
- import { type Kept, type ParkCause, type ParkedEnd } from "./computer-kept.js";
10
+ import { type Kept, type KeptHolder, type ParkCause, type ParkedEnd } from "./computer-kept.js";
11
11
  import { type ProviderLedger } from "./computer-ledger.js";
12
12
  import { type ClaimBrowser, type ClaimSide, type ComputerSetting, type ComputerSettingKind, type KindRegistry, type ProviderEntry } from "./resolve-computer.js";
13
13
  import type { RunComputer, RunHold } from "./run-tools.js";
@@ -29,6 +29,10 @@ export interface ClaimLaunch {
29
29
  readonly boxAllow?: readonly string[] | "none";
30
30
  /** The operator set that (run-launch.ts boxAllowSet), not the default. */
31
31
  readonly boxAllowSet?: true;
32
+ /** The runner this claim runs in: its name and its process's presence incarnation (runner/presence.ts). A park that
33
+ * keeps a computer only this runner can reach again (computer-kept.ts pinnedOf) names both on its row, so the claim
34
+ * rule gives the run back to this runner while it is there. Absent: nothing kept is pinned. */
35
+ readonly holder?: KeptHolder;
32
36
  }
33
37
  /** What of the run a computer's spec is made from, besides its kind and provider: what it may reach, and whether the
34
38
  * operator set that; and what the provider declares it makes (its capabilities()): its networks and its longest
@@ -169,6 +173,10 @@ export interface ComputerForClaimDeps {
169
173
  * claim's Archil mount credential (Mode 2): the credential is this claim's to remove now (archil-claim.ts inherit),
170
174
  * since this claim mints none. Absent: nothing was minted (Mode 1). */
171
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;
172
180
  /** The clock a kept computer's time is read by (computer-kept.ts), and its computers' intervals are written on
173
181
  * (computer-intervals.ts). Default Date.now. */
174
182
  readonly now?: () => number;
@@ -192,6 +200,10 @@ export interface ComputerForClaimDeps {
192
200
  * owner's view let go, then the computer. */
193
201
  export interface ClaimComputer {
194
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;
195
207
  readonly hold?: RunHold;
196
208
  readonly held?: HeldComputer;
197
209
  /** The computer is a new one that replaced an earlier claim's (Replaced): what was on that one is gone. Absent: the
@@ -224,11 +236,16 @@ export type MadeKind = "desktop" | "sandbox" | "phone";
224
236
  export type KeptKind = Kept["kind"];
225
237
  /** A computer the claim made fresh in place of an earlier claim's: its kind, and `folderKept`, the run's folder is on
226
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
227
- * (KEEP_MS) passed before this claim. */
239
+ * (KEEP_MS) passed before this claim. `lost`: the earlier one was kept at a park pinned to another runner (or another
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). */
228
243
  export type Replaced = {
229
244
  readonly kind: MadeKind;
230
245
  readonly folderKept: boolean;
231
246
  readonly lapsed?: true;
247
+ readonly lost?: true;
248
+ readonly refused?: string;
232
249
  };
233
250
  /** The agent's computer setting: the launch's, else its revision's (computer, else place), else the launch's place. The
234
251
  * run's end reads it the same way (run-end-computers.ts). */
@@ -15,7 +15,11 @@
15
15
  // to be replaced. The claim that makes one says its kind (`made`), which the adapter loop records in the run's
16
16
  // journal. When a later claim's replaces an earlier claim's (`replaced`: one this claim let go of, or one the run's
17
17
  // journal says an earlier claim made, hadComputer), the ready line says so (and that the kept one's time had passed,
18
- // `lapsed`), and the run's tools and model are told (run-tools.ts, the adapter loop's computer note).
18
+ // `lapsed`), and the run's tools and model are told (run-tools.ts, the adapter loop's computer note). A kept one only
19
+ // the runner that kept it can reach again (a Docker container, a machine that dials that runner: computer-kept.ts
20
+ // pinnedOf) names that runner and its incarnation on its row (`ClaimLaunch.holder`), and the store's claim rule lets no
21
+ // other runner claim the run while that runner is live and the keep lasts; one taken after it is gone and not reached
22
+ // here is said to be lost with it (`lost`).
19
23
  //
20
24
  // A sandbox the claim made can be lost mid-run (its vendor deleted it, or no longer has it): the call that finds it lost
21
25
  // fails, saying so and that it was not run again (code gone, computer-lost.ts lostInCallWords), and is never sent to the
@@ -51,9 +55,12 @@ import { pairedProvider, withPaired } from "./attached-computers.js";
51
55
  import { computerHold, heldHands } from "./computer-hold.js";
52
56
  import { endingDeletes, figuresOf, intervalWrites } from "./computer-intervals.js";
53
57
  import { computeMeter } from "../compute-cost.js";
54
- import { deleteKept, endKept, KEEP_MS, readKept, takeKept, writeKept } from "./computer-kept.js";
58
+ import { bounded, deleteKept, endKept, KEEP_MS, KEPT_DELETE_MS, keptBy, pinnedOf, readKept, takeKept, writeKept } from "./computer-kept.js";
55
59
  import { storeLedger } from "./computer-ledger.js";
56
- import { providerKeys, registryHere, resolveComputer } from "./resolve-computer.js";
60
+ import { providerKeys, registryHere, resolveComputer, runShellOf } from "./resolve-computer.js";
61
+ import { computerDenied } from "../tool-gate.js";
62
+ import { loadToolSettings } from "../tool-plane.js";
63
+ import { computerDeniedWords, computerStillOffWords } from "../refusal-words.js";
57
64
  import { claimHolds, fencedStore, holdSynced, storedFolder } from "./synced-folder.js";
58
65
  /** A computer that cannot be had, with the code the run fails with and the server's words. */
59
66
  const unavailable = (words) => Object.assign(new Error(words), { code: "computer_unavailable" });
@@ -90,6 +97,20 @@ export async function settingOf(launch, store) {
90
97
  return computerOfPlace(body.place);
91
98
  return launch.place ? computerOfPlace(launch.place) : undefined;
92
99
  }
100
+ /** The kind of the claim's computer `setting` when every tool it serves the run is set to deny (tool-gate.ts
101
+ * computerDenied): the revision's grants and tool settings over the server's, as the run's gate reads them. `shell`: where
102
+ * the run's shell would be with it. A store with no settings, or settings that do not read, deny nothing. */
103
+ async function deniedKind(launch, setting, store, shell) {
104
+ if (setting.kind === "none" || !store.settings || !launch.revisionId)
105
+ return undefined;
106
+ const revision = await store.agents.revision(launch.revisionId);
107
+ if (!revision || revision.kind !== "agentic")
108
+ return undefined;
109
+ const server = await loadToolSettings({ settings: store.settings }).catch(() => undefined);
110
+ if (!server || server.unreadable)
111
+ return undefined;
112
+ return computerDenied({ kind: revision.kind, body: { ...revision.body, computer: setting } }, shell, server);
113
+ }
93
114
  /** A phone's platform: what the phone says it is, else its provider's phone configuration's machine kind; android when
94
115
  * neither says ios. */
95
116
  function phonePlatform(machine, entry) {
@@ -438,13 +459,14 @@ function lostAware(first, renewal) {
438
459
  },
439
460
  };
440
461
  }
441
- /** The computer an earlier claim of the run kept at its park (`kept`), attached again through `provider` and connected,
442
- * or undefined when its provider no longer has it or it does not connect (one that does not is deleted). */
462
+ /** The computer an earlier claim of the run kept at its park (`kept`), attached again through `provider` and connected;
463
+ * `refused`, the provider's words, when it refuses to attach it; or undefined when its provider no longer has it or it
464
+ * does not connect (one that does not is deleted). */
443
465
  async function keptLaunch(provider, kept, signal, ended) {
444
466
  const ref = { id: kept.id, name: kept.name };
445
467
  const found = await provider.attach({ id: ref.id }, signal ? { signal } : {});
446
468
  if (!found.ok)
447
- return undefined;
469
+ return found.error.code === "refused" ? { refused: found.error.message } : undefined;
448
470
  const connected = await provider.connect(ref);
449
471
  if (!connected.ok) {
450
472
  const released = await provider.release(ref, "delete").catch(() => undefined);
@@ -650,9 +672,18 @@ store, deps) {
650
672
  let kept = store.settings && launch.epoch > 1 ? await readKept(store.settings, launch.runId).catch(() => undefined) : undefined;
651
673
  /** The kept computer's time passed before this claim: the new one says so (Replaced.lapsed). */
652
674
  let lapsed = false;
675
+ /** The kept computer was pinned to another runner, gone by this claim, and this claim could not reach it: the new one
676
+ * says so (Replaced.lost). */
677
+ let lost = false;
678
+ /** The kept computer's provider refused to attach it again, in these words: the new one says why (Replaced.refused). */
679
+ let refused;
653
680
  /** What a park of this claim keeps (ClaimComputer.park): a desktop, a phone or a sandbox it made through its provider, or took
654
- * back, with its provider, its connection's close and the claim epoch its labels carry. */
681
+ * back, with its provider, its connection's close and the claim epoch its labels carry; `pinned`: only this runner can
682
+ * reach it again (computer-kept.ts pinnedOf), so the park names this claim's holder on its row. */
655
683
  let keepable;
684
+ /** Whether a computer of `entry` made with `configuration` is reachable again only by this runner: its options as
685
+ * vendorProvider makes it (the settings' options under the configuration's). */
686
+ const pinnedHere = (entry, configuration) => pinnedOf(entry, { ...settingOptions(entry.id, deps.settings ?? {}, table), ...configuration.options });
656
687
  /** A vendor's provider (or a local one's), made with the keys and the configuration the setting selected: that
657
688
  * configuration is built by its own create() options (Orgo's Windows: { os: "windows" }), beside the keys'. */
658
689
  const vendorProvider = async (entry, keys, configuration) => {
@@ -770,6 +801,10 @@ store, deps) {
770
801
  return undefined;
771
802
  if (persistent || paired.some((row) => row.id === entry.id) || (deps.launch && (deps.launches?.(entry.id) ?? true)) || record.provider !== entry.id || record.kind !== kind || record.folder !== folder)
772
803
  return undefined;
804
+ // Kept pinned to another runner (or another process of this runner's name): the claim rule let this claim have the
805
+ // run only once that runner was gone. Taken off its row, it is tried here all the same (a runner on the same host,
806
+ // sharing its Docker engine, finds it); one this claim cannot reach is lost with that runner, said so.
807
+ const elsewhere = record.runner !== undefined && !keptBy(record, launch.holder);
773
808
  try {
774
809
  // Its time over, or its end took it first (ending or ended): a new one, said so.
775
810
  if (record.ending || record.ended || now() >= record.until || !(await takeKept(store.settings, launch.runId, record))) {
@@ -778,8 +813,11 @@ store, deps) {
778
813
  }
779
814
  const provider = await vendorProvider(entry, keys, configuration);
780
815
  const taken = await keptLaunch(provider, record, signal, () => writes.ended(entry.id, record.id));
781
- if (!taken)
816
+ if (!taken || "refused" in taken) {
817
+ lost = elsewhere;
818
+ refused = taken?.refused;
782
819
  return undefined;
820
+ }
783
821
  // Metered again from here, with what its interval says it was made with: the time it was kept is no claim's.
784
822
  const row = meter ? (await store.computerIntervals?.forRun(launch.runId).catch(() => undefined))?.find((one) => one.provider === entry.id && one.providerId === record.id) : undefined;
785
823
  if (row)
@@ -788,7 +826,7 @@ store, deps) {
788
826
  // A sandbox taken back is started again when it is lost as one this claim made (lostAware): the new one is this
789
827
  // claim's, made from this claim's spec, its folder mounted.
790
828
  const again = record.kind === "sandbox" ? lostAware(taken, renewalOf(provider, entry, () => specOf(entry, provider, kind, configuration, deps.signal, gpu), folder)) : taken;
791
- keepable = { provider, entry: entry.id, kind: record.kind, computer: again, epoch: record.epoch };
829
+ keepable = { provider, entry: entry.id, kind: record.kind, computer: again, pinned: pinnedHere(entry, configuration), epoch: record.epoch };
792
830
  ownKind = record.kind;
793
831
  const screen = record.kind === "sandbox" ? undefined : record.kind;
794
832
  made = { id: again.id, machine: again.machine, ...(again.watch && screen ? { watch: again.watch, gone: goneOf(provider, again.id, runLabels(launch.runId, record.epoch), screen) } : {}) };
@@ -798,6 +836,8 @@ store, deps) {
798
836
  return { ...again, epoch: record.epoch };
799
837
  }
800
838
  catch {
839
+ // Taken off its row (or not), and not reached here: lost with its runner where it was pinned to another.
840
+ lost = elsewhere && !lapsed;
801
841
  return undefined;
802
842
  }
803
843
  },
@@ -861,9 +901,9 @@ store, deps) {
861
901
  if (!pairedRow)
862
902
  ownKind = kind;
863
903
  if (!pairedRow && (kind === "desktop" || kind === "phone" || kind === "sandbox"))
864
- keepable = { provider, entry: entry.id, kind, computer: held, epoch: launch.epoch };
865
- if (!pairedRow && (releasedOlder || journalSays))
866
- replaced = { kind: kind, folderKept: deps.mode === 2 && mount !== undefined, ...(lapsed ? { lapsed: true } : {}) };
904
+ keepable = { provider, entry: entry.id, kind, computer: held, pinned: pinnedHere(entry, configuration), epoch: launch.epoch };
905
+ if (!pairedRow && (releasedOlder || journalSays || lost || refused !== undefined))
906
+ replaced = { kind: kind, folderKept: deps.mode === 2 && mount !== undefined, ...(lost ? { lost: true } : lapsed ? { lapsed: true } : {}), ...(refused !== undefined ? { refused } : {}) };
867
907
  }
868
908
  made = { id: launched.id, machine: launched.machine, ...(launched.watch ? { watch: launched.watch, ...(kind === "desktop" || kind === "phone" ? { gone: goneOf(provider, launched.id, listedUnder, kind) } : {}) } : {}) };
869
909
  madeBy = entry;
@@ -872,6 +912,46 @@ store, deps) {
872
912
  return launched;
873
913
  },
874
914
  };
915
+ /** The computer an earlier claim kept at the run's park, ended now by a claim that starts none (the run's computer is
916
+ * off): deleted, its interval ended, and its mount credential, the parking claim's, taken on and removed
917
+ * (archil-claim.ts revoke removes only one its claim minted or took on), so the run's folder is its own again before
918
+ * its tools touch it. The credential is taken on only once this claim's end holds the row (endKept's compare-and-set):
919
+ * a later claim that took the computer back first holds its mount, which this claim's revoke (at its loss, its end)
920
+ * then never removes. Once taken on, a revoke this claim does not finish here is the run's end's. The delete and the
921
+ * revoke together are bounded (KEPT_DELETE_MS) and end at the run's stop: one that fails or does not answer leaves the
922
+ * row ending, for the janitor's next pass. Never throws. */
923
+ const endKeptNow = async () => {
924
+ const record = kept;
925
+ kept = undefined;
926
+ const settings = store.settings;
927
+ const entry = record && kinds.PROVIDERS.find((one) => one.id === record.provider);
928
+ if (!record || record.ended || !settings || !entry)
929
+ return;
930
+ try {
931
+ await endKept(settings, launch.runId, record, () => {
932
+ deps.inheritMount?.();
933
+ return bounded(KEPT_DELETE_MS, (async () => {
934
+ try {
935
+ const provider = await vendorProvider(entry, await side.keysOf(entry.id), {});
936
+ if (await deleteKept(provider, record))
937
+ await writes.ended(entry.id, record.id);
938
+ }
939
+ finally {
940
+ await deps.revokeMount?.().catch(() => undefined);
941
+ }
942
+ })(), deps.signal);
943
+ });
944
+ }
945
+ catch {
946
+ // Left ending for the janitor.
947
+ }
948
+ };
949
+ // The run's computer turned off by an earlier claim's deny: none is started, and the one a park kept goes now.
950
+ if (deps.turnedOff) {
951
+ deps.onComputerNote?.(computerStillOffWords(deps.turnedOff));
952
+ await endKeptNow();
953
+ return { computer: undefined, off: true, release: noop };
954
+ }
875
955
  const setting = await settingOf(launch, store);
876
956
  // Programs it needs (computer.needs) are checked in a sandbox's box alone: a setting that needs them and is any other
877
957
  // kind is refused before anything is rented, never run without them.
@@ -880,6 +960,14 @@ store, deps) {
880
960
  const label = setting?.provider ? kinds.PROVIDERS.find((one) => one.id === setting.provider)?.label ?? setting.provider : undefined;
881
961
  throw unavailable(needsNoSandboxWords(needs, setting?.kind === "none" || !setting ? "none" : `a ${setting.kind}${label ? ` on ${label}` : ""}`));
882
962
  }
963
+ // A computer every tool of which is set to deny (tool-gate.ts computerDenied) serves the run nothing: none is started,
964
+ // nothing is rented or checked, and the run goes on without it, its timeline saying why.
965
+ const denied = setting && (await deniedKind(launch, setting, store, runShellOf(setting, deps.mode, kinds)));
966
+ if (denied) {
967
+ deps.onComputerNote?.(computerDeniedWords(denied));
968
+ await endKeptNow();
969
+ return { computer: undefined, off: true, release: noop };
970
+ }
883
971
  const resolved = await resolveComputer(setting, deps.mode, kinds, side);
884
972
  if ("refused" in resolved)
885
973
  throw unavailable(resolved.refused);
@@ -1026,7 +1114,7 @@ store, deps) {
1026
1114
  }
1027
1115
  let row;
1028
1116
  try {
1029
- row = await writeKept(settings, launch.runId, { provider: keeps.entry, kind: keeps.kind, id: ref.id, name: ref.name, epoch: keeps.epoch, until: now() + KEEP_MS, ...(resolved.folder ? { folder: resolved.folder } : {}) });
1117
+ row = await writeKept(settings, launch.runId, { provider: keeps.entry, kind: keeps.kind, id: ref.id, name: ref.name, epoch: keeps.epoch, until: now() + KEEP_MS, ...(resolved.folder ? { folder: resolved.folder } : {}), ...(keeps.pinned && launch.holder ? { runner: launch.holder.runner, incarnation: launch.holder.incarnation } : {}) });
1030
1118
  }
1031
1119
  catch {
1032
1120
  // No row, nothing to find it by: it goes as at the run's end.
@@ -2,7 +2,7 @@ import { type Result, type Swept } from "@parcha/agentrun-computer";
2
2
  import { type KeyTable, type ProviderSettings } from "../computer-keys.js";
3
3
  import { type Store } from "../store/index.js";
4
4
  import type { ComputerDeps } from "./computer-deps.js";
5
- import { type KeptSweep } from "./computer-kept.js";
5
+ import { type KeptHolder, type KeptSweep } from "./computer-kept.js";
6
6
  /** How often the janitor sweeps after its first sweep at the runner's start. */
7
7
  export declare const JANITOR_EVERY_MS: number;
8
8
  /** The longest close() waits for a sweep it cut: a vendor call that ignores the cut is left to finish on its own. */
@@ -13,7 +13,11 @@ export declare const JANITOR_PROVIDER_MS: number;
13
13
  export interface JanitorDeps {
14
14
  /** The store: whose runs a computer's run label names, and the phone provider's ledger; with `settings` and `agents`,
15
15
  * this server's id and its agents, whose own computers it then sweeps by their owner. */
16
- readonly store: Pick<Store, "runs" | "computerLedger"> & Partial<Pick<Store, "settings" | "agents" | "computerIntervals">>;
16
+ readonly store: Pick<Store, "runs" | "computerLedger"> & Partial<Pick<Store, "settings" | "agents" | "computerIntervals" | "runners">>;
17
+ /** The runner this janitor sweeps for (its name and presence incarnation): a computer kept at a park pinned to another
18
+ * runner still there is that runner's to end, never this one's: its row (computer-kept.ts sweepKept) and its machine
19
+ * in a provider's list (sparedKept). Absent: every pinned row whose runner is there is left. */
20
+ readonly self?: KeptHolder;
17
21
  /** The run's computers as the runner composed them (computer-deps.ts computerDepsFrom): the registry, the provider
18
22
  * makers and the key reader. */
19
23
  readonly computers: Pick<ComputerDeps, "kinds" | "providers" | "keyOf"> & {
@@ -38,15 +42,19 @@ export type ProviderSweep = {
38
42
  readonly swept: Result<Swept>;
39
43
  };
40
44
  /** One sweep of every provider this server can list: each provider whose keys it has and whose computers the janitor
41
- * ends, its computers past their deadline that are this server's and unheld ended. A provider that fails is answered
42
- * in its words; nothing throws. */
43
- export declare function sweepServerComputers(deps: Pick<JanitorDeps, "store" | "computers" | "now" | "providerMs"> & {
45
+ * ends, its computers past their deadline that are this server's and unheld ended. A computer kept at a park pinned to
46
+ * another runner still there is left out of every list (computer-kept.ts sparedKept, by the kept pass's own rule): a
47
+ * provider both runners list (a dial vendor's account, a shared Docker engine) would otherwise end, once its run is
48
+ * over, a machine the kept pass left to its runner. Where the kept rows can't be read, each provider is answered as not
49
+ * swept this pass. A provider that fails is answered in its words; nothing throws. */
50
+ export declare function sweepServerComputers(deps: Pick<JanitorDeps, "store" | "computers" | "now" | "providerMs" | "self"> & {
44
51
  readonly log?: (line: string) => void;
45
52
  }, signal?: AbortSignal): Promise<ProviderSweep[]>;
46
53
  /** The pass over the desktops and phones kept at a run's park (computer-kept.ts sweepKept): one past its time, or whose
47
54
  * run ended, is ended through its provider, made with this server's keys, whatever its lifetime (a vendor's own end is
48
- * hours away). Undefined without the store's settings, where none is kept. Never throws. */
49
- export declare function sweepKeptComputers(deps: Pick<JanitorDeps, "store" | "computers" | "now"> & {
55
+ * hours away); one pinned to another runner still there (the store's runners) is left to that runner. Undefined without
56
+ * the store's settings, where none is kept. Never throws. */
57
+ export declare function sweepKeptComputers(deps: Pick<JanitorDeps, "store" | "computers" | "now" | "self"> & {
50
58
  readonly log?: (line: string) => void;
51
59
  }): Promise<KeptSweep | undefined>;
52
60
  /** The janitor: one sweep now, then one every `everyMs`, never two at once, and a kept pass at the earliest time a kept
@@ -17,7 +17,10 @@
17
17
  // not asked, since it reads labels alone and can't tell this server's parts from another's.
18
18
  //
19
19
  // A desktop or a phone kept at a run's park (computer-kept.ts) goes by its own row, on any provider: each sweep ends one
20
- // past its time or whose run ended, and the janitor wakes again at the earliest time still ahead.
20
+ // past its time or whose run ended, and the janitor wakes again at the earliest time still ahead. One pinned to another
21
+ // runner still there is that runner's (computer-kept.ts heldElsewhere): the kept pass leaves its row, and the provider
22
+ // sweep leaves its machine out of every list by the same rule (sparedKept), so a run that ended on this runner never has
23
+ // this janitor end a machine another runner keeps.
21
24
  //
22
25
  // A provider whose sweep fails is logged, once per distinct failure, and the others are swept. It runs only where its
23
26
  // start asks for it (the CLI's runner and the runner subcommand), never under --faux, and never two sweeps at once. Its
@@ -32,7 +35,7 @@ import { KEY_TABLE, providerOptions } from "../computer-keys.js";
32
35
  import { FAUX_ENV } from "../model.js";
33
36
  import { FINAL_STATES } from "../store/index.js";
34
37
  import { deleteUnderHold, ownerGoneOf, serverIdOf, wantsOn } from "./agent-computer.js";
35
- import { sweepKept } from "./computer-kept.js";
38
+ import { sparedKept, sweepKept } from "./computer-kept.js";
36
39
  import { storeLedger } from "./computer-ledger.js";
37
40
  import { providerKeys } from "./resolve-computer.js";
38
41
  import { intervalWrites } from "./computer-intervals.js";
@@ -79,7 +82,7 @@ async function sweepable(store, info, byHash, serverId) {
79
82
  * now: a server that stopped before its run's end let go of an earlier claim's computer (run-end-computers.ts) leaves
80
83
  * it for this sweep, never for its day-long deadline. Each call goes to the provider itself, so its own state is used
81
84
  * as it is. */
82
- function thisServers(provider, store, byHash, serverId, at, ended) {
85
+ function thisServers(provider, store, byHash, serverId, at, ended, spared) {
83
86
  // The agents' own computers the list kept, by id: their delete goes under the agent's hold (deleteUnderHold), which
84
87
  // also clears the agent's record of it, so its view no longer shows it deleting.
85
88
  const ownedBy = new Map();
@@ -113,6 +116,9 @@ function thisServers(provider, store, byHash, serverId, at, ended) {
113
116
  return listed;
114
117
  const kept = [];
115
118
  for (const info of listed.value) {
119
+ // A machine kept at a park for another runner still there (sparedKept): that runner's to end, never this sweep's.
120
+ if (spared(info.ref.id))
121
+ continue;
116
122
  const mine = await sweepable(store, info, byHash, serverId);
117
123
  if (!mine)
118
124
  continue;
@@ -144,8 +150,11 @@ async function bounded(ms, signal, work) {
144
150
  }
145
151
  }
146
152
  /** One sweep of every provider this server can list: each provider whose keys it has and whose computers the janitor
147
- * ends, its computers past their deadline that are this server's and unheld ended. A provider that fails is answered
148
- * in its words; nothing throws. */
153
+ * ends, its computers past their deadline that are this server's and unheld ended. A computer kept at a park pinned to
154
+ * another runner still there is left out of every list (computer-kept.ts sparedKept, by the kept pass's own rule): a
155
+ * provider both runners list (a dial vendor's account, a shared Docker engine) would otherwise end, once its run is
156
+ * over, a machine the kept pass left to its runner. Where the kept rows can't be read, each provider is answered as not
157
+ * swept this pass. A provider that fails is answered in its words; nothing throws. */
149
158
  export async function sweepServerComputers(deps, signal) {
150
159
  const { store, computers } = deps;
151
160
  const writes = intervalWrites(store, deps.log, deps.now);
@@ -154,6 +163,16 @@ export async function sweepServerComputers(deps, signal) {
154
163
  const byHash = runsByHash(store);
155
164
  // This server's id and its agents: its agents' own computers are swept by their owner (ownerGoneOf).
156
165
  const { settings, agents } = store;
166
+ // The kept machines this sweep leaves, read once for every provider; with no settings, nothing is kept.
167
+ let spared = () => false;
168
+ if (settings) {
169
+ try {
170
+ spared = await sparedKept({ settings, ...(store.runners ? { runners: store.runners } : {}), ...(deps.self ? { self: deps.self } : {}) });
171
+ }
172
+ catch (error) {
173
+ spared = { unread: `the computers kept at a park could not be read, so none of its computers is swept this pass: ${error instanceof Error ? error.message : String(error)}` };
174
+ }
175
+ }
157
176
  const serverId = settings && agents ? await serverIdOf({ settings }) : undefined;
158
177
  const out = [];
159
178
  for (const entry of computers.kinds.PROVIDERS) {
@@ -172,8 +191,13 @@ export async function sweepServerComputers(deps, signal) {
172
191
  // A vendor that ends its own computers needs no janitor.
173
192
  if (provider.capabilities().lifetime !== "janitor")
174
193
  continue;
194
+ if (typeof spared !== "function") {
195
+ out.push({ provider: entry.id, swept: { ok: false, error: { code: "unreachable", message: spared.unread } } });
196
+ continue;
197
+ }
198
+ const leaves = spared;
175
199
  const ownerGone = serverId !== undefined && settings && agents ? ownerGoneOf({ agents, settings, runs: store.runs }, serverId, entry.id) : undefined;
176
- out.push({ provider: entry.id, swept: await bounded(deps.providerMs ?? JANITOR_PROVIDER_MS, signal, (cut) => sweep(thisServers(provider, store, byHash, serverId, at, (id) => writes.ended(entry.id, id)), { now: new Date(at), signal: cut, ...(ownerGone ? { ownerGone } : {}) })) });
200
+ out.push({ provider: entry.id, swept: await bounded(deps.providerMs ?? JANITOR_PROVIDER_MS, signal, (cut) => sweep(thisServers(provider, store, byHash, serverId, at, (id) => writes.ended(entry.id, id), (id) => leaves(entry.id, id)), { now: new Date(at), signal: cut, ...(ownerGone ? { ownerGone } : {}) })) });
177
201
  }
178
202
  catch (error) {
179
203
  out.push({ provider: entry.id, swept: { ok: false, error: { code: "refused", message: error instanceof Error ? error.message : String(error) } } });
@@ -183,7 +207,8 @@ export async function sweepServerComputers(deps, signal) {
183
207
  }
184
208
  /** The pass over the desktops and phones kept at a run's park (computer-kept.ts sweepKept): one past its time, or whose
185
209
  * run ended, is ended through its provider, made with this server's keys, whatever its lifetime (a vendor's own end is
186
- * hours away). Undefined without the store's settings, where none is kept. Never throws. */
210
+ * hours away); one pinned to another runner still there (the store's runners) is left to that runner. Undefined without
211
+ * the store's settings, where none is kept. Never throws. */
187
212
  export async function sweepKeptComputers(deps) {
188
213
  const { store, computers } = deps;
189
214
  const writes = intervalWrites(store, deps.log, deps.now);
@@ -197,7 +222,7 @@ export async function sweepKeptComputers(deps) {
197
222
  const options = providerOptions(id, await keysOf(id), computers.settings ?? {}, computers.keyTable ?? KEY_TABLE);
198
223
  return options.ok ? make(options.options, { ledger: storeLedger(store.computerLedger, id) }) : undefined;
199
224
  };
200
- return sweepKept({ settings: store.settings, runs: store.runs, now: (deps.now ?? Date.now)(), providerOf, deleted: (provider, id) => writes.ended(provider, id) });
225
+ return sweepKept({ settings: store.settings, runs: store.runs, now: (deps.now ?? Date.now)(), providerOf, deleted: (provider, id) => writes.ended(provider, id), ...(store.runners ? { runners: store.runners } : {}), ...(deps.self ? { self: deps.self } : {}) });
201
226
  }
202
227
  /** The janitor: one sweep now, then one every `everyMs`, never two at once, and a kept pass at the earliest time a kept
203
228
  * computer is due (sweepKeptComputers; each delete bounded, KEPT_DELETE_MS), so a park's keep ends on time though the
@@ -1,5 +1,5 @@
1
- import type { ComputerProvider, MountKind } from "@parcha/agentrun-computer";
2
- import { type Settings, type Store } from "../store/index.js";
1
+ import { type ComputerProvider, type MountKind, type ProviderEntry } from "@parcha/agentrun-computer";
2
+ import { type Runners, type Settings, type Store } from "../store/index.js";
3
3
  /** How long a park keeps the run's computer for its resume: 10 minutes. */
4
4
  export declare const KEEP_MS: number;
5
5
  /** KEEP_MS in words. */
@@ -17,9 +17,13 @@ export type ParkedEnd = {
17
17
  export declare const parkedWords: (kind: string, cause: ParkCause) => string;
18
18
  /** Why the run's computer at its resume is a new one: the one kept at its park was ended at its time. */
19
19
  export declare const computerLapsedWords: (kind: string) => string;
20
+ /** Why the run's computer at its resume is a new one: the one kept at its park was pinned to the runner that kept it
21
+ * (pinnedOf), that runner was gone by the resume, and the claiming runner could not reach it. Never names the runner:
22
+ * a runner's name carries its host's. */
23
+ export declare const computerLostWords: (kind: string) => string;
20
24
  /** The live view's words once the kept computer's time passed, the run still parked. */
21
25
  export declare const lapsedWords: (kind: string) => string;
22
- /** The settings key prefix of the kept computers, one row per run. */
26
+ /** The settings key prefix of the kept computers, one row per run (the store's, which its claim rule reads). */
23
27
  export declare const KEPT_PREFIX = "computer_kept:";
24
28
  /** The settings key of `runId`'s kept computer. */
25
29
  export declare const keptKeyOf: (runId: string) => string;
@@ -36,9 +40,45 @@ export type Kept = {
36
40
  /** The kind of the run's folder it holds (a bind, an Archil mount or a synced folder); none: it holds none. A claim
37
41
  * takes it back only to hold the folder the same way (computer-for-claim.ts reattach). */
38
42
  readonly folder?: MountKind;
43
+ /** The runner that kept it and that runner's process (its presence incarnation), where only that runner can reach it
44
+ * again (pinnedOf): both or neither. Absent: any runner takes it back. */
45
+ readonly runner?: string;
46
+ readonly incarnation?: string;
39
47
  readonly ending?: true;
40
48
  readonly ended?: true;
41
49
  };
50
+ /** The runner a claim runs in: its name (the claim's runner) and its process's presence incarnation. */
51
+ export type KeptHolder = {
52
+ readonly runner: string;
53
+ readonly incarnation: string;
54
+ };
55
+ /** Whether a computer of `entry`, made with `options` (its settings' options under the configuration's, as the claim makes
56
+ * its provider), can be reached again only by the runner that kept it: a local provider's (a container on that
57
+ * runner's Docker engine), or one whose machines dial this server (the computer package's connectOf "dial": its socket
58
+ * is in that runner's attach hub, its token names that runner). A connect the computer package refuses reads as exec,
59
+ * as resolve-computer.ts reads it. */
60
+ export declare function pinnedOf(entry: Pick<ProviderEntry, "label" | "connect" | "local">, options?: Readonly<Record<string, unknown>>): boolean;
61
+ /** Whether `kept` names `holder` as the runner that keeps it (the same name and the same process). */
62
+ export declare const keptBy: (kept: Pick<Kept, "runner" | "incarnation">, holder: KeptHolder | undefined) => boolean;
63
+ /** Who holds what, for one janitor pass: the runners there now (Runners.live) and the runner the pass runs in (`self`). */
64
+ export type KeptHolders = {
65
+ /** Absent: none is read, and no row counts as held elsewhere. */
66
+ readonly runners?: Pick<Runners, "live">;
67
+ readonly self?: KeptHolder;
68
+ };
69
+ /** The one rule both janitor sweeps leave a kept machine by (sweepKept, and the provider sweep through sparedKept): its
70
+ * row is pinned to a runner other than `self` that is still there under the row's incarnation (seen within
71
+ * PRESENCE_STALE_MS). Only that runner's engine or hub has the machine, so a delete from here either finds nothing (and
72
+ * marks the row ended, leaking it) or, where both runners list it (a dial vendor's account, a shared Docker engine),
73
+ * ends a machine its runner still keeps. The runners are read once per maker's call. A read that fails counts every
74
+ * pinned row as held elsewhere: ending another runner's machine blind would leak it or take it. */
75
+ export declare function heldElsewhere(holders: KeptHolders): (kept: Pick<Kept, "runner" | "incarnation">) => Promise<boolean>;
76
+ /** The kept machines a provider sweep leaves this pass, by provider id and computer id: each row not yet ended whose
77
+ * machine is held elsewhere (heldElsewhere, the kept pass's own rule). Throws when the rows can't be read: the sweep
78
+ * then can't tell which machines are kept, and must not guess. */
79
+ export declare function sparedKept(deps: KeptHolders & {
80
+ readonly settings: Pick<KeptSettings, "all">;
81
+ }): Promise<(provider: string, id: string) => boolean>;
42
82
  /** How long one delete of a kept computer may take at the janitor's pass: past it the pass goes on, the row is left
43
83
  * ending, and the next pass deletes it again (a Docker command has no timeout of its own). */
44
84
  export declare const KEPT_DELETE_MS = 60000;
@@ -71,7 +111,10 @@ export type KeptSweep = {
71
111
  * deleted (unless its time already ended it) and the row removed; one past its time, or left ending, is ended (endKept),
72
112
  * each delete bounded by `deleteMs` (KEPT_DELETE_MS). The rest are left, the earliest of their times answered as `next`.
73
113
  * `providerOf`: the provider a row names, made with this server's keys, or undefined when this server can't make it (its
74
- * keys gone): that row is left and said. Never throws.
114
+ * keys gone): that row is left and said. A row pinned to a runner other than this one (`self`) that is still there under
115
+ * the row's incarnation (`runners`, seen within PRESENCE_STALE_MS) is left whatever its time or its run: only that
116
+ * runner's engine or hub has its machine, so a delete from here would find nothing, mark it ended and leak the machine.
117
+ * That runner's own timer, or its janitor, ends it; once it is gone the row is ended here as any other. Never throws.
75
118
  */
76
119
  export declare function sweepKept(deps: {
77
120
  readonly settings: KeptSettings;
@@ -82,9 +125,17 @@ export declare function sweepKept(deps: {
82
125
  /** Told of each kept computer whose delete answered ok, by its provider and id (its interval's end,
83
126
  * computer-intervals.ts). Never throws. */
84
127
  readonly deleted?: (provider: string, id: string) => Promise<void>;
128
+ /** The runners there now (Runners.live): a row pinned to one of them, not `self`, is left. Absent: none is read, and
129
+ * every row is swept as before. */
130
+ readonly runners?: Pick<Runners, "live">;
131
+ /** The runner this sweep runs in (its name and presence incarnation): the rows pinned to it are its own to end. */
132
+ readonly self?: KeptHolder;
85
133
  }): Promise<KeptSweep>;
86
134
  /** Deletes the kept computer through its provider; one already gone (its run's end let it go, run-end-computers.ts, or
87
135
  * its vendor ended it) is as good as deleted. Throws the provider's words on any other failure. True when the
88
136
  * provider's delete answered ok, the one answer that proves its end now (its interval's, computer-intervals.ts); false
89
137
  * for one already gone, whose end is not known. */
90
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>;