@parcha/agentrun-serve 0.1.0-beta.36 → 0.1.0-beta.37

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 (325) hide show
  1. package/CHANGELOG.md +170 -0
  2. package/README.md +158 -52
  3. package/dist/attach-conformance-cli.d.ts +1 -0
  4. package/dist/attach-conformance-cli.js +18 -0
  5. package/dist/attach-conformance.d.ts +25 -0
  6. package/dist/attach-conformance.js +343 -0
  7. package/dist/browser-cost.d.ts +1 -1
  8. package/dist/browser-live.d.ts +20 -8
  9. package/dist/browser-live.js +50 -27
  10. package/dist/cap.d.ts +0 -17
  11. package/dist/cap.js +0 -91
  12. package/dist/catalog.d.ts +1 -12
  13. package/dist/catalog.js +3 -33
  14. package/dist/cli.js +13 -4
  15. package/dist/composio-preset.d.ts +36 -0
  16. package/dist/composio-preset.js +179 -0
  17. package/dist/computer-attach.d.ts +125 -0
  18. package/dist/computer-attach.js +330 -0
  19. package/dist/computer-calls.d.ts +48 -0
  20. package/dist/computer-calls.js +126 -0
  21. package/dist/computer-channel.d.ts +57 -0
  22. package/dist/computer-channel.js +115 -0
  23. package/dist/computer-commands.d.ts +1 -1
  24. package/dist/computer-held-routes.d.ts +35 -0
  25. package/dist/computer-held-routes.js +106 -0
  26. package/dist/computer-held.d.ts +48 -0
  27. package/dist/computer-held.js +87 -0
  28. package/dist/computer-keys.d.ts +21 -1
  29. package/dist/computer-keys.js +53 -11
  30. package/dist/computer-live.d.ts +160 -0
  31. package/dist/computer-live.js +643 -0
  32. package/dist/computer-view.d.ts +13 -0
  33. package/dist/computer-view.js +50 -3
  34. package/dist/computer-viewer.d.ts +6 -0
  35. package/dist/computer-viewer.js +297 -0
  36. package/dist/computers.d.ts +33 -7
  37. package/dist/computers.js +50 -8
  38. package/dist/console/assets/index-Cn6JX1uH.js +563 -0
  39. package/dist/console/assets/index-DRN62V5v.css +1 -0
  40. package/dist/console/index.html +2 -2
  41. package/dist/faux-computers.d.ts +9 -20
  42. package/dist/faux-computers.js +53 -25
  43. package/dist/github-connection.d.ts +10 -2
  44. package/dist/github-connection.js +65 -2
  45. package/dist/github-faux.js +1 -1
  46. package/dist/graph-view.d.ts +1 -1
  47. package/dist/harness.d.ts +1 -0
  48. package/dist/harness.js +35 -1
  49. package/dist/host-tools.d.ts +1 -1
  50. package/dist/hosted-search.d.ts +5 -4
  51. package/dist/hosted-search.js +2 -7
  52. package/dist/import-sources.d.ts +10 -0
  53. package/dist/import-sources.js +44 -2
  54. package/dist/import.d.ts +3 -3
  55. package/dist/import.js +37 -6
  56. package/dist/learn/check.d.ts +4 -1
  57. package/dist/learn/check.js +1 -1
  58. package/dist/learn/commit.d.ts +4 -2
  59. package/dist/learn/commit.js +5 -5
  60. package/dist/learn/folder.d.ts +6 -0
  61. package/dist/learn/folder.js +4 -1
  62. package/dist/learn/general.d.ts +66 -0
  63. package/dist/learn/general.js +73 -0
  64. package/dist/learn/grade.d.ts +4 -0
  65. package/dist/learn/grade.js +22 -1
  66. package/dist/learn/reflect.d.ts +10 -1
  67. package/dist/learn/reflect.js +14 -4
  68. package/dist/learn/skills.d.ts +33 -5
  69. package/dist/learn/skills.js +53 -7
  70. package/dist/learned-workflow.d.ts +24 -0
  71. package/dist/learned-workflow.js +66 -3
  72. package/dist/learning-batch.d.ts +283 -0
  73. package/dist/learning-batch.js +574 -0
  74. package/dist/learning-evals.d.ts +33 -0
  75. package/dist/learning-evals.js +98 -0
  76. package/dist/learning-routes.d.ts +25 -2
  77. package/dist/learning-routes.js +39 -6
  78. package/dist/learning-words.d.ts +6 -0
  79. package/dist/learning-words.js +6 -0
  80. package/dist/learning.d.ts +28 -15
  81. package/dist/learning.js +84 -44
  82. package/dist/live/stream.js +6 -3
  83. package/dist/live/translate.d.ts +4 -3
  84. package/dist/live/translate.js +8 -4
  85. package/dist/live-reach.d.ts +37 -0
  86. package/dist/live-reach.js +62 -0
  87. package/dist/mcp-gateway.d.ts +9 -0
  88. package/dist/mcp-gateway.js +60 -11
  89. package/dist/mcp-oauth.d.ts +57 -7
  90. package/dist/mcp-oauth.js +133 -18
  91. package/dist/mcp-private-hosts.d.ts +4 -4
  92. package/dist/mcp-private-hosts.js +20 -12
  93. package/dist/mcp-probe.d.ts +19 -2
  94. package/dist/mcp-probe.js +44 -9
  95. package/dist/mcp-secret-writes.js +4 -0
  96. package/dist/mcp-servers-store.d.ts +38 -15
  97. package/dist/mcp-servers-store.js +112 -20
  98. package/dist/mcp-store.d.ts +10 -4
  99. package/dist/mcp-store.js +17 -6
  100. package/dist/model-form.d.ts +26 -0
  101. package/dist/model-form.js +80 -0
  102. package/dist/model.js +23 -10
  103. package/dist/openapi.js +386 -21
  104. package/dist/page.d.ts +18 -0
  105. package/dist/page.js +48 -20
  106. package/dist/paid-calls.d.ts +1 -1
  107. package/dist/place-offers.d.ts +2 -3
  108. package/dist/place-offers.js +3 -7
  109. package/dist/place.js +1 -2
  110. package/dist/print.d.ts +15 -1
  111. package/dist/print.js +14 -3
  112. package/dist/propose.d.ts +3 -0
  113. package/dist/propose.js +13 -5
  114. package/dist/provider.js +3 -2
  115. package/dist/reflect-range.d.ts +8 -1
  116. package/dist/reflect-range.js +1 -1
  117. package/dist/run-launch.d.ts +14 -2
  118. package/dist/run-launch.js +9 -4
  119. package/dist/run-learning-served.d.ts +2 -2
  120. package/dist/run-reads-over-store.d.ts +1 -1
  121. package/dist/run-repo.d.ts +20 -0
  122. package/dist/run-repo.js +63 -0
  123. package/dist/run-timeline-served.d.ts +1 -1
  124. package/dist/run-view.d.ts +3 -3
  125. package/dist/run-view.js +14 -7
  126. package/dist/runner/adapter-loop.d.ts +23 -7
  127. package/dist/runner/adapter-loop.js +648 -62
  128. package/dist/runner/adapter-run-spec.d.ts +11 -3
  129. package/dist/runner/adapter-run-spec.js +77 -22
  130. package/dist/runner/adapters/pi-computer.d.ts +7 -0
  131. package/dist/runner/adapters/pi-computer.js +43 -0
  132. package/dist/runner/adapters/pi.d.ts +9 -4
  133. package/dist/runner/adapters/pi.js +76 -14
  134. package/dist/runner/beside.d.ts +7 -3
  135. package/dist/runner/beside.js +21 -11
  136. package/dist/runner/claim-secrets.d.ts +4 -0
  137. package/dist/runner/claim-secrets.js +6 -1
  138. package/dist/runner/cli-run-spec.d.ts +20 -3
  139. package/dist/runner/cli-run-spec.js +113 -43
  140. package/dist/runner/commands.d.ts +3 -1
  141. package/dist/runner/commands.js +28 -3
  142. package/dist/runner/computer-channel.d.ts +34 -0
  143. package/dist/runner/computer-channel.js +61 -0
  144. package/dist/runner/conformance/harness.js +80 -14
  145. package/dist/runner/conformance/subject.d.ts +1 -1
  146. package/dist/runner/dispatch.js +3 -0
  147. package/dist/runner/end-of-run.d.ts +22 -12
  148. package/dist/runner/end-of-run.js +38 -16
  149. package/dist/runner/github-app.d.ts +2 -1
  150. package/dist/runner/github-app.js +4 -2
  151. package/dist/runner/harness-loops.js +15 -1
  152. package/dist/runner/held-run.d.ts +65 -0
  153. package/dist/runner/held-run.js +158 -0
  154. package/dist/runner/journal-kinds.d.ts +20 -1
  155. package/dist/runner/journal-kinds.js +14 -0
  156. package/dist/runner/journal-reader.d.ts +5 -4
  157. package/dist/runner/journal-reader.js +12 -10
  158. package/dist/runner/learning-ask.d.ts +7 -1
  159. package/dist/runner/learning-ask.js +21 -6
  160. package/dist/runner/learning-dispatch.d.ts +22 -0
  161. package/dist/runner/learning-dispatch.js +77 -10
  162. package/dist/runner/learning-end.d.ts +22 -1
  163. package/dist/runner/learning-end.js +92 -12
  164. package/dist/runner/learning-factory.d.ts +1 -1
  165. package/dist/runner/learning-factory.js +11 -5
  166. package/dist/runner/learning-loop.d.ts +67 -7
  167. package/dist/runner/learning-loop.js +173 -21
  168. package/dist/runner/learning-seed.d.ts +7 -0
  169. package/dist/runner/learning-seed.js +13 -0
  170. package/dist/runner/live-ticker.js +1 -0
  171. package/dist/runner/loop-contract.d.ts +8 -1
  172. package/dist/runner/loop.d.ts +5 -1
  173. package/dist/runner/loop.js +2 -1
  174. package/dist/runner/main.d.ts +13 -1
  175. package/dist/runner/main.js +27 -5
  176. package/dist/runner/mcp-claim.d.ts +10 -7
  177. package/dist/runner/mcp-claim.js +113 -24
  178. package/dist/runner/mcp-github.js +1 -1
  179. package/dist/runner/mcp-run.d.ts +5 -5
  180. package/dist/runner/mcp-run.js +15 -3
  181. package/dist/runner/metrics.d.ts +11 -2
  182. package/dist/runner/metrics.js +12 -2
  183. package/dist/runner/pr-checkout.d.ts +1 -0
  184. package/dist/runner/pr-checkout.js +1 -1
  185. package/dist/runner/reflect-hook.d.ts +18 -0
  186. package/dist/runner/reflect-hook.js +20 -8
  187. package/dist/runner/runner.d.ts +26 -0
  188. package/dist/runner/runner.js +184 -15
  189. package/dist/runner/scratch-sweep.d.ts +13 -0
  190. package/dist/runner/scratch-sweep.js +62 -0
  191. package/dist/runner/sessions.d.ts +1 -1
  192. package/dist/runner/store-port.d.ts +4 -2
  193. package/dist/runner/store-secrets.js +4 -3
  194. package/dist/runner/subagent.js +3 -1
  195. package/dist/runner/workflow-host.d.ts +6 -1
  196. package/dist/runner/workflow-host.js +1 -1
  197. package/dist/runner/workflow-loop.d.ts +1 -1
  198. package/dist/runner/workflow-spec.d.ts +14 -2
  199. package/dist/runner/workflow-spec.js +56 -20
  200. package/dist/runs-over-store.d.ts +6 -1
  201. package/dist/runs-over-store.js +38 -9
  202. package/dist/seal-key.js +3 -3
  203. package/dist/sealed-settings-store.d.ts +5 -2
  204. package/dist/sealed-settings-store.js +10 -4
  205. package/dist/secret-writes.d.ts +5 -4
  206. package/dist/secret-writes.js +5 -4
  207. package/dist/server-secrets-store.d.ts +4 -3
  208. package/dist/server-secrets-store.js +15 -9
  209. package/dist/server-secrets.js +3 -2
  210. package/dist/server.d.ts +43 -14
  211. package/dist/server.js +472 -126
  212. package/dist/settings-wake.d.ts +21 -0
  213. package/dist/settings-wake.js +59 -0
  214. package/dist/standard-webhooks.d.ts +4 -1
  215. package/dist/standard-webhooks.js +8 -4
  216. package/dist/store/command-wake.d.ts +12 -0
  217. package/dist/store/command-wake.js +37 -0
  218. package/dist/store/dialect.d.ts +6 -0
  219. package/dist/store/dialect.js +5 -0
  220. package/dist/store/index.d.ts +1 -1
  221. package/dist/store/journal/storage.d.ts +3 -2
  222. package/dist/store/journal/storage.js +13 -5
  223. package/dist/store/postgres/dialect.js +4 -0
  224. package/dist/store/postgres/migrations/0005_learning_rounds.sql +14 -0
  225. package/dist/store/postgres/migrations/0006_run_changes_channel_attempts.sql +57 -0
  226. package/dist/store/postgres/migrations/0007_viewer_host.sql +11 -0
  227. package/dist/store/postgres/migrations/0008_paired_computers.sql +30 -0
  228. package/dist/store/postgres/migrations/0009_commands_answer.sql +10 -0
  229. package/dist/store/schema.d.ts +1 -1
  230. package/dist/store/schema.js +77 -8
  231. package/dist/store/sqlite/run-patch.d.ts +7 -5
  232. package/dist/store/sqlite/run-patch.js +28 -13
  233. package/dist/store/sqlite/store.js +272 -54
  234. package/dist/store/store.d.ts +268 -9
  235. package/dist/store/store.js +12 -1
  236. package/dist/store-reads/cap.d.ts +1 -1
  237. package/dist/store-reads/cap.js +8 -1
  238. package/dist/store-reads/decisions.d.ts +2 -2
  239. package/dist/store-reads/decisions.js +1 -1
  240. package/dist/store-reads/import-summary.d.ts +1 -1
  241. package/dist/store-reads/journal.d.ts +5 -4
  242. package/dist/store-reads/journal.js +73 -15
  243. package/dist/store-reads/learning.d.ts +20 -4
  244. package/dist/store-reads/learning.js +74 -18
  245. package/dist/store-reads/runs.d.ts +1 -1
  246. package/dist/store-reads/workflow.d.ts +1 -1
  247. package/dist/store-view.d.ts +5 -0
  248. package/dist/store-view.js +26 -11
  249. package/dist/template-eval.js +6 -4
  250. package/dist/template-github-permissions.d.ts +22 -8
  251. package/dist/template-github-permissions.js +35 -15
  252. package/dist/timeline/timeline.d.ts +27 -0
  253. package/dist/timeline/timeline.js +10 -9
  254. package/dist/timeline/util.d.ts +4 -0
  255. package/dist/timeline/util.js +14 -0
  256. package/dist/tool-budget.d.ts +19 -7
  257. package/dist/tool-budget.js +14 -8
  258. package/dist/tool-gate.d.ts +16 -9
  259. package/dist/tool-gate.js +53 -42
  260. package/dist/tool-plane.d.ts +16 -12
  261. package/dist/tool-plane.js +9 -4
  262. package/dist/tools.d.ts +13 -4
  263. package/dist/tools.js +13 -4
  264. package/dist/trigger-adapter.d.ts +4 -0
  265. package/dist/trigger-secrets-shown.d.ts +2 -2
  266. package/dist/trigger-secrets-shown.js +1 -1
  267. package/dist/trigger-signatures.d.ts +25 -6
  268. package/dist/trigger-signatures.js +41 -7
  269. package/dist/trigger-targets.d.ts +2 -0
  270. package/dist/trigger-targets.js +1 -0
  271. package/dist/trigger-webhook.js +5 -2
  272. package/dist/triggers.d.ts +7 -3
  273. package/dist/triggers.js +35 -5
  274. package/dist/turns.js +16 -1
  275. package/dist/validate.js +11 -1
  276. package/dist/web-fetch.d.ts +1 -1
  277. package/dist/web-search.d.ts +10 -5
  278. package/dist/web-search.js +7 -6
  279. package/dist/webhooks.d.ts +145 -102
  280. package/dist/webhooks.js +559 -322
  281. package/dist/workflow/decisions.d.ts +1 -1
  282. package/dist/workflow/node-runner.d.ts +2 -1
  283. package/dist/workflow/node.d.ts +2 -1
  284. package/dist/workflow/node.js +3 -1
  285. package/dist/workflow/pi-versions.d.ts +23 -0
  286. package/dist/workflow/pi-versions.js +57 -0
  287. package/dist/workflow/record-tool.d.ts +2 -1
  288. package/dist/workflow/store.d.ts +1 -1
  289. package/dist/workflow/task.js +3 -2
  290. package/dist/workflow-run.d.ts +1 -1
  291. package/dist/workspace/attached-computers.d.ts +41 -0
  292. package/dist/workspace/attached-computers.js +114 -0
  293. package/dist/workspace/computer-deps.d.ts +16 -9
  294. package/dist/workspace/computer-deps.js +19 -7
  295. package/dist/workspace/computer-for-claim.d.ts +17 -8
  296. package/dist/workspace/computer-for-claim.js +62 -21
  297. package/dist/workspace/computer-hold.d.ts +11 -27
  298. package/dist/workspace/computer-hold.js +36 -56
  299. package/dist/workspace/computer-ledger.d.ts +3 -1
  300. package/dist/workspace/computer-ledger.js +4 -0
  301. package/dist/workspace/computer-mcp.d.ts +25 -0
  302. package/dist/workspace/computer-mcp.js +41 -0
  303. package/dist/workspace/computer-ports.d.ts +4 -13
  304. package/dist/workspace/computer-ports.js +4 -107
  305. package/dist/workspace/computer-script.d.ts +37 -0
  306. package/dist/workspace/computer-script.js +138 -0
  307. package/dist/workspace/executors.d.ts +1 -1
  308. package/dist/workspace/index.d.ts +4 -2
  309. package/dist/workspace/index.js +3 -1
  310. package/dist/workspace/kind-skills/desktop/SKILL.md +119 -84
  311. package/dist/workspace/kind-skills/phone/SKILL.md +100 -85
  312. package/dist/workspace/resolve-computer.d.ts +3 -0
  313. package/dist/workspace/resolve-computer.js +8 -2
  314. package/dist/workspace/run-tools.d.ts +32 -15
  315. package/dist/workspace/run-tools.js +23 -30
  316. package/package.json +19 -16
  317. package/templates/market-monitor/agent.md +1 -1
  318. package/dist/console/assets/index-BI4Byidu.js +0 -550
  319. package/dist/console/assets/index-C19gUF2n.css +0 -1
  320. package/dist/run-db.d.ts +0 -53
  321. package/dist/run-db.js +0 -116
  322. package/dist/workflow/readers.d.ts +0 -36
  323. package/dist/workflow/readers.js +0 -145
  324. package/dist/workflow/wal.d.ts +0 -11
  325. package/dist/workflow/wal.js +0 -106
@@ -1,4 +1,4 @@
1
- import type { Context } from "@earendil-works/chord";
1
+ import type { Context } from "@earendil-works/chord/context";
2
2
  import { type DocumentReader, type Harness } from "@earendil-works/pi-durable";
3
3
  /** The session document that holds a run's decision rows. */
4
4
  export declare const DECISION_RECEIPTS_DOC = "agentrun.decisions";
@@ -1,4 +1,5 @@
1
- import type { Context, JsonValue } from "@earendil-works/chord";
1
+ import type { Context } from "@earendil-works/chord/context";
2
+ import type { JsonValue } from "@earendil-works/chord/json";
2
3
  import { type AgentChange, type ConversationId, type Extension, type Tx } from "@earendil-works/pi-durable";
3
4
  import type { WorkflowDeps } from "@parcha/agentrun-dsl";
4
5
  import { type RecoveryNodeParams } from "@parcha/agentrun-dsl/recovery";
@@ -1,4 +1,5 @@
1
- import type { Context, JsonValue } from "@earendil-works/chord";
1
+ import type { Context } from "@earendil-works/chord/context";
2
+ import type { JsonValue } from "@earendil-works/chord/json";
2
3
  import { type AgentChange, type ConversationId, type DocumentReader, type InputSubmissionDraft, type Submission, type TaskId, type Tx } from "@earendil-works/pi-durable";
3
4
  import type { Disagreement } from "./record.js";
4
5
  /** The node index: an attempt's conversation by its session id, the digest of what it was bound to, when it started,
@@ -1,4 +1,5 @@
1
1
  import { configure, defineDocFamily, } from "@earendil-works/pi-durable";
2
+ import { durableWait } from "./pi-versions.js";
2
3
  import { deliveredRecord } from "./record-tool.js";
3
4
  /** The node index: an attempt's conversation by its session id, the digest of what it was bound to, when it started,
4
5
  * and whether its owner closed it without a record. */
@@ -86,7 +87,8 @@ export async function runNodeAttempt(scope, attempt, context) {
86
87
  if (!handle)
87
88
  throw new Error(`node attempt ${attempt.session} names conversation ${String(conversationId)}, which does not exist`);
88
89
  const submission = await handle.submit({ type: "input", content: attempt.user, requestId: `node:${attempt.session}` }, context);
89
- const ended = await submission.wait(context);
90
+ // Never on the task's signal (durableWait): an abort while it registers rejects this wait, never one unhandled.
91
+ const ended = await durableWait((at) => submission.wait(at), context);
90
92
  const settled = ended.status === "unanswered"
91
93
  ? { status: "unanswered", reason: ended.reason, ...(ended.detail !== undefined ? { detail: ended.detail } : {}) } : { status: "done" };
92
94
  const delivered = await deliveredRecord(scope, conversationId, context);
@@ -1,3 +1,4 @@
1
+ import { type Context } from "@earendil-works/chord/context";
1
2
  import type { ToolExecutionResult } from "@earendil-works/pi-durable";
2
3
  export type TextBlock = {
3
4
  type: "text";
@@ -7,3 +8,25 @@ export type TextBlock = {
7
8
  export declare function toolResult(blocks: readonly TextBlock[], fields?: Omit<ToolExecutionResult, "content" | "output">): ToolExecutionResult;
8
9
  /** The storage error behind a Session that failed at one (`SessionFailed`, matched by name), else the error. */
9
10
  export declare function storageError(error: unknown): unknown;
11
+ /**
12
+ * `wait(context)` settled, or `context`'s signal aborted, whichever is first: rejected with the abort's reason on the
13
+ * abort, as pi-durable's own wait rejects. The wait itself runs on `context` with its signal swapped for one that never
14
+ * aborts.
15
+ *
16
+ * pi-durable (1.5.0, and 1.5.2 unchanged) makes a submission's or a task's waiter while the Session's line reads its
17
+ * record (harness/util.js Waiters.add, from harness/submissions.js wait and harness/scheduler.js waitForTask), and hands
18
+ * it back only when the line delivers that read, after every commit before it is published. Until then the waiter is
19
+ * held by pi-durable alone, and it rejects there in two ways:
20
+ * - registered after its context's signal aborted, it is a promise rejected at once;
21
+ * - when the Session closes (a storage error fails it), every waiter rejects (Waiters.rejectAll), and a waiter whose
22
+ * context has no signal has no handler; the failed Session's line then never hands it back.
23
+ * Either way Node reports a rejection nothing handles: the runner process exits on it (runner/main.ts lastResort), its
24
+ * claims left to lapse, and a runner beside the server takes the server down with it. A runner's close or a lost claim
25
+ * while a resumed loop opens its session is the first; a commit failing under a runner that lost its claim the second.
26
+ *
27
+ * So the wait gets a signal of its own that never aborts: Waiters.add never sees an abort, and it handles every waiter it
28
+ * makes (its listener detach). The caller's signal is watched here: an abort answers with its reason, a wait asked once
29
+ * it has aborted is never started, and the wait's later outcome is handled and dropped (its waiter settles when its
30
+ * submission or task does, or when its Session closes).
31
+ */
32
+ export declare function durableWait<T>(wait: (context: Context) => Promise<T>, context: Context): Promise<T>;
@@ -1,3 +1,10 @@
1
+ // What the workflow code and the runner hold pi-durable to about a tool result, a failed Session and a wait, in one place
2
+ // (pi-durable 1.5).
3
+ //
4
+ // A tool result's blocks are its `output` (pi 1.1 read `content`). A storage error fails the Session, and its later
5
+ // calls reject with `SessionFailed` whose cause is that error. A wait (a submission's, Harness.waitForTask) is handed a
6
+ // signal that never aborts (durableWait).
7
+ import { withAbortSignal, withoutAbortSignal } from "@earendil-works/chord/context";
1
8
  /** A tool result pi-durable reads as `blocks`: the blocks under `output`, each its own copy. */
2
9
  export function toolResult(blocks, fields = {}) {
3
10
  return { ...fields, output: blocks.map((block) => ({ ...block })) };
@@ -6,3 +13,53 @@ export function toolResult(blocks, fields = {}) {
6
13
  export function storageError(error) {
7
14
  return error instanceof Error && error.name === "SessionFailed" && error.cause !== undefined ? error.cause : error;
8
15
  }
16
+ /**
17
+ * `wait(context)` settled, or `context`'s signal aborted, whichever is first: rejected with the abort's reason on the
18
+ * abort, as pi-durable's own wait rejects. The wait itself runs on `context` with its signal swapped for one that never
19
+ * aborts.
20
+ *
21
+ * pi-durable (1.5.0, and 1.5.2 unchanged) makes a submission's or a task's waiter while the Session's line reads its
22
+ * record (harness/util.js Waiters.add, from harness/submissions.js wait and harness/scheduler.js waitForTask), and hands
23
+ * it back only when the line delivers that read, after every commit before it is published. Until then the waiter is
24
+ * held by pi-durable alone, and it rejects there in two ways:
25
+ * - registered after its context's signal aborted, it is a promise rejected at once;
26
+ * - when the Session closes (a storage error fails it), every waiter rejects (Waiters.rejectAll), and a waiter whose
27
+ * context has no signal has no handler; the failed Session's line then never hands it back.
28
+ * Either way Node reports a rejection nothing handles: the runner process exits on it (runner/main.ts lastResort), its
29
+ * claims left to lapse, and a runner beside the server takes the server down with it. A runner's close or a lost claim
30
+ * while a resumed loop opens its session is the first; a commit failing under a runner that lost its claim the second.
31
+ *
32
+ * So the wait gets a signal of its own that never aborts: Waiters.add never sees an abort, and it handles every waiter it
33
+ * makes (its listener detach). The caller's signal is watched here: an abort answers with its reason, a wait asked once
34
+ * it has aborted is never started, and the wait's later outcome is handled and dropped (its waiter settles when its
35
+ * submission or task does, or when its Session closes).
36
+ */
37
+ export function durableWait(wait, context) {
38
+ const signal = context.abortSignal;
39
+ const unabortable = withAbortSignal(new AbortController().signal, withoutAbortSignal(context));
40
+ if (signal === undefined)
41
+ return wait(unabortable);
42
+ if (signal.aborted)
43
+ return Promise.reject(signal.reason);
44
+ return new Promise((resolve, reject) => {
45
+ const onAbort = () => reject(signal.reason);
46
+ signal.addEventListener("abort", onAbort, { once: true });
47
+ const settled = () => signal.removeEventListener("abort", onAbort);
48
+ let waiting;
49
+ try {
50
+ waiting = wait(unabortable);
51
+ }
52
+ catch (error) {
53
+ settled();
54
+ reject(error);
55
+ return;
56
+ }
57
+ waiting.then((value) => {
58
+ settled();
59
+ resolve(value);
60
+ }, (error) => {
61
+ settled();
62
+ reject(error);
63
+ });
64
+ });
65
+ }
@@ -1,4 +1,5 @@
1
- import type { Context, JsonValue } from "@earendil-works/chord";
1
+ import type { Context } from "@earendil-works/chord/context";
2
+ import type { JsonValue } from "@earendil-works/chord/json";
2
3
  import { type ConversationId, type DocumentReader, type HookApi, type HookRegistration, type ToolExecutionApi, type ToolRegistration } from "@earendil-works/pi-durable";
3
4
  import { type Delivery, type Disagreement, type RecordContract, type RecordStore } from "./record.js";
4
5
  /** The record a conversation delivered, or null while it has not, and the delivery attempts it has spent. */
@@ -1,5 +1,5 @@
1
1
  import type { Harness } from "@earendil-works/pi-durable";
2
- import type { Context } from "@earendil-works/chord";
2
+ import type { Context } from "@earendil-works/chord/context";
3
3
  import { type RecoveryStore } from "@parcha/agentrun-dsl/recovery";
4
4
  /** An effect's key in `agentrun.effects`: its journal key, then its id. The two are joined by NUL, so neither may hold
5
5
  * one: two pairs could otherwise name the same document. */
@@ -15,7 +15,7 @@
15
15
  import { defineDocFamily, defineExtension, defineTask } from "@earendil-works/pi-durable";
16
16
  import { runWorkflow } from "@parcha/agentrun-dsl";
17
17
  import { bindingDigests, bindingMismatch, canonicalHash, isRecoveryError, openRecovery, recoveryBound, RecoveryError, withRecovery } from "@parcha/agentrun-dsl/recovery";
18
- import { storageError } from "./pi-versions.js";
18
+ import { durableWait, storageError } from "./pi-versions.js";
19
19
  import { documentStore } from "./store.js";
20
20
  const RunDoc = defineDocFamily({ kind: "agentrun.task", version: 1, scope: "session", family: true, initial: () => ({ task: null, stop: null }), checkpointWhen: () => false });
21
21
  /** Records a stop on a run's entry. A recorded cancel stands, so the first cancel names the run's source; a recorded
@@ -293,7 +293,8 @@ export function createWorkflowExtension(host) {
293
293
  const failure = uncommittedOf(key, taskId);
294
294
  failure.waits += 1;
295
295
  try {
296
- const settled = await Promise.race([harness.waitForTask(taskId, context), failure.promise]);
296
+ // Never on the caller's signal (durableWait): an abort while it registers rejects this wait, never one unhandled.
297
+ const settled = await Promise.race([durableWait((at) => harness.waitForTask(taskId, at), context), failure.promise]);
297
298
  return (await outcomeOf(harness, settled, key, context));
298
299
  }
299
300
  catch (error) {
@@ -1,4 +1,4 @@
1
- import type { Context } from "@earendil-works/chord";
1
+ import type { Context } from "@earendil-works/chord/context";
2
2
  import type { Storage } from "@earendil-works/pi-durable";
3
3
  import type { Workflow } from "@parcha/agentrun-dsl";
4
4
  import type { GraphDiff, NodeState, WorkflowGraph } from "@parcha/agentrun-dsl/graph";
@@ -0,0 +1,41 @@
1
+ import { type AttachHub, type ComputerProvider, type HelloResult, type PairedComputer } from "@parcha/agentrun-computer";
2
+ import type { PairedComputerRow } from "../store/index.js";
3
+ import type { ComputerSettingKind, KindRegistry, ProviderEntry } from "./resolve-computer.js";
4
+ /** A paired computer's id starts with this; the rest is lowercase letters and digits, so the whole is an id an agent's
5
+ * computer setting takes as its provider (lowercase letters, digits and dashes). */
6
+ export declare const PAIRED_ID_PREFIX = "cmp-";
7
+ /** The image a paired computer's spec names: none is made, so this only says what it is. */
8
+ export declare const ATTACHED_IMAGE = "attached";
9
+ /** The words a run gets when its agent's computer is a paired computer and its runner is not in the server's process. */
10
+ export declare const ONE_PROCESS_WORDS = "a paired computer's socket is held by the serve process it dialed, and this runner runs in a process of its own: start AgentRun as one process (agentrun serve, with its runner beside it, not --no-runner) to use a paired computer";
11
+ /** What the claim reads of the paired computers: the store's rows (removed ones left out), and the server's hub where
12
+ * the runner shares its process (absent: a runner of its own process). */
13
+ export interface AttachedComputers {
14
+ rows(): Promise<readonly PairedComputerRow[]>;
15
+ readonly hub?: AttachHub;
16
+ }
17
+ /** The store's row as the hub and attachedProvider take it. */
18
+ export declare const pairedOf: (row: PairedComputerRow) => PairedComputer;
19
+ /** What a driver's hello lacks to serve `kind`, by the kind registry's rule (the computer package's SETTING_KINDS, which
20
+ * servingRefusals reads): "it says desktop but declares no input.pointer, input.keys", "it says android, which no
21
+ * desktop computer is"; undefined when the hello serves the kind. The one source of a paired computer's words for a
22
+ * kind it cannot serve: at pairing (servesNoKind) and at a run's start (withPaired's unservedWhy). */
23
+ export declare function helloLacks(hello: Partial<HelloResult>, kind: ComputerSettingKind): string | undefined;
24
+ /** Why `name`'s driver may not pair: its hello serves no kind an agent's computer can be, so no agent could pick it; in
25
+ * words that say what it lacks and to update the driver. Undefined when it serves one. */
26
+ export declare function servesNoKind(name: string, hello: Partial<HelloResult>): string | undefined;
27
+ /** A paired computer as a provider of `registry`: named by its name and its os, as an agent's computer picker lists it;
28
+ * the setting kinds its paired hello serves, no keys, no mount, the machine's own network ("open": a run never narrows
29
+ * a person's own machine), never metered. */
30
+ export declare function pairedEntry(row: PairedComputerRow, registry: Pick<KindRegistry, "SETTING_KINDS" | "servingRefusals">): ProviderEntry;
31
+ /** `registry` with each paired computer of `rows` as one more provider (pairedEntry), and the words for one that cannot
32
+ * serve a kind an agent asks of it: it is a computer of the person's own, and either the attach path carries no such
33
+ * kind (ATTACH_CANNOT: a sandbox, which would run the agent's shell there, or a browser), so the agent takes it as the
34
+ * kind it serves, or its driver lacks what the kind needs (helloLacks), so the driver is what to update. */
35
+ export declare function withPaired<R extends KindRegistry>(registry: R, rows: readonly PairedComputerRow[]): R;
36
+ /** The provider of the paired computer `row`: attachedProvider over the hub, or a refusal in ONE_PROCESS_WORDS where this
37
+ * process holds no hub. */
38
+ export declare function pairedProvider(row: PairedComputerRow, hub: AttachHub | undefined): ComputerProvider;
39
+ /** Why the paired computer `row` cannot be had now, in words that say what to do, or undefined: it must be attached (its
40
+ * driver dialed this server). Asked at a run's start, as a vendor's readiness is; another run's hold is the claim's. */
41
+ export declare function pairedRefusal(row: PairedComputerRow, hub: Pick<AttachHub, "online"> | undefined): string | undefined;
@@ -0,0 +1,114 @@
1
+ // A paired computer (a person's own, attached over the attach binding: computer-attach.ts) as the claim and Settings see
2
+ // it: one provider of the kind registry, whose id is the computer's own (cmp-...), whose label is its name, and whose one
3
+ // configuration is the kind and groups it paired as. An agent's computer setting names it as its provider, {kind:
4
+ // "desktop", provider: "cmp-..."}, so a run resolves, checks and claims it on the one path every computer takes
5
+ // (resolve-computer.ts, computer-for-claim.ts), and the computer package's attachedProvider stands in for a vendor's.
6
+ //
7
+ // Its socket is held by the AttachHub of the server's process: a runner in that process (the CLI's start, its runner
8
+ // beside the server) takes it; a runner of its own process cannot reach it and refuses it in ONE_PROCESS_WORDS.
9
+ import { attachedProvider, SETTING_KIND_NAMES, SETTING_KINDS } from "@parcha/agentrun-computer";
10
+ /** A paired computer's id starts with this; the rest is lowercase letters and digits, so the whole is an id an agent's
11
+ * computer setting takes as its provider (lowercase letters, digits and dashes). */
12
+ export const PAIRED_ID_PREFIX = "cmp-";
13
+ /** The image a paired computer's spec names: none is made, so this only says what it is. */
14
+ export const ATTACHED_IMAGE = "attached";
15
+ /** The words a run gets when its agent's computer is a paired computer and its runner is not in the server's process. */
16
+ export const ONE_PROCESS_WORDS = "a paired computer's socket is held by the serve process it dialed, and this runner runs in a process of its own: start AgentRun as one process (agentrun serve, with its runner beside it, not --no-runner) to use a paired computer";
17
+ /** The store's row as the hub and attachedProvider take it. */
18
+ export const pairedOf = (row) => ({
19
+ id: row.id,
20
+ name: row.name,
21
+ hello: row.hello,
22
+ labels: { ...row.labels },
23
+ });
24
+ /** The setting kinds the attach path cannot serve, with why and what to pair instead: a browser session needs a CDP
25
+ * connection, which the attach socket does not carry, and a sandbox needs the run's folder mounted, which a paired
26
+ * computer has no mount for (resolve-computer.ts refuses a sandbox without one). Kind-based, never by OS: a driver whose hello serves one of
27
+ * these and no other kind is refused at pairing, and a paired row of one serves nothing. */
28
+ const ATTACH_CANNOT = {
29
+ browser: "a paired computer can't serve browser sessions yet, so pair a desktop or phone driver",
30
+ sandbox: "a paired computer can't mount a run's folder yet, so no agent could run a sandbox on it: pair a desktop or phone driver",
31
+ };
32
+ /** What a driver's hello lacks to serve `kind`, by the kind registry's rule (the computer package's SETTING_KINDS, which
33
+ * servingRefusals reads): "it says desktop but declares no input.pointer, input.keys", "it says android, which no
34
+ * desktop computer is"; undefined when the hello serves the kind. The one source of a paired computer's words for a
35
+ * kind it cannot serve: at pairing (servesNoKind) and at a run's start (withPaired's unservedWhy). */
36
+ export function helloLacks(hello, kind) {
37
+ const spec = SETTING_KINDS[kind];
38
+ const said = String(hello.kind ?? "nothing");
39
+ if (!spec.machineKinds.some((one) => one === hello.kind))
40
+ return `it says ${said}, which no ${kind} computer is`;
41
+ const groups = Array.isArray(hello.groups) ? hello.groups : [];
42
+ const missing = spec.required.filter((group) => !groups.includes(group));
43
+ return missing.length === 0 ? undefined : `it says ${said} but declares no ${missing.join(", ")}`;
44
+ }
45
+ /** Why `name`'s driver may not pair: its hello serves no kind an agent's computer can be, so no agent could pick it; in
46
+ * words that say what it lacks and to update the driver. Undefined when it serves one. */
47
+ export function servesNoKind(name, hello) {
48
+ const kinds = SETTING_KIND_NAMES.filter((kind) => kind !== "none" && !(kind in ATTACH_CANNOT));
49
+ if (kinds.some((kind) => helloLacks(hello, kind) === undefined))
50
+ return undefined;
51
+ // A hello that is whole for a kind the attach path cannot carry says so, in that kind's words.
52
+ const carried = Object.entries(ATTACH_CANNOT).find(([kind]) => helloLacks(hello, kind) === undefined);
53
+ if (carried !== undefined)
54
+ return `${name}'s driver is a ${carried[0]}: ${carried[1]}`;
55
+ // The kind its machine kind is (a desktop's, a phone's) says what is missing; a machine kind no kind takes says that.
56
+ const near = kinds.find((kind) => SETTING_KINDS[kind].machineKinds.some((one) => one === hello.kind));
57
+ const lack = near === undefined ? `it says ${String(hello.kind ?? "nothing")}, which no kind of computer is` : helloLacks(hello, near);
58
+ return `${name}'s driver serves no kind: ${lack}: update the driver on ${name}`;
59
+ }
60
+ /** A paired computer as a provider of `registry`: named by its name and its os, as an agent's computer picker lists it;
61
+ * the setting kinds its paired hello serves, no keys, no mount, the machine's own network ("open": a run never narrows
62
+ * a person's own machine), never metered. */
63
+ export function pairedEntry(row, registry) {
64
+ const hello = row.hello;
65
+ const configuration = { kind: String(hello.kind ?? ""), groups: Array.isArray(hello.groups) ? [...hello.groups] : [] };
66
+ const kinds = Object.keys(registry.SETTING_KINDS).filter((kind) => kind !== "none" && !(kind in ATTACH_CANNOT) && registry.servingRefusals(configuration, kind).length === 0);
67
+ return {
68
+ id: row.id,
69
+ label: typeof hello.os === "string" ? `${row.name} (${hello.os})` : row.name,
70
+ kinds,
71
+ keys: [],
72
+ mounts: [],
73
+ network: ["open"],
74
+ metered: false,
75
+ capabilities: [configuration],
76
+ defaultImage: Object.fromEntries(kinds.map((kind) => [kind, ATTACHED_IMAGE])),
77
+ };
78
+ }
79
+ /** `registry` with each paired computer of `rows` as one more provider (pairedEntry), and the words for one that cannot
80
+ * serve a kind an agent asks of it: it is a computer of the person's own, and either the attach path carries no such
81
+ * kind (ATTACH_CANNOT: a sandbox, which would run the agent's shell there, or a browser), so the agent takes it as the
82
+ * kind it serves, or its driver lacks what the kind needs (helloLacks), so the driver is what to update. */
83
+ export function withPaired(registry, rows) {
84
+ if (rows.length === 0)
85
+ return registry;
86
+ const byId = new Map(rows.map((row) => [row.id, row]));
87
+ const unservedWhy = (entry, kind) => {
88
+ const row = byId.get(entry.id);
89
+ if (row !== undefined && kind in ATTACH_CANNOT && entry.kinds.length > 0) {
90
+ return `${row.name} is a computer of your own, and a paired computer can't be a ${kind} computer yet: give this agent ${row.name} as a ${entry.kinds.join(" or ")} computer`;
91
+ }
92
+ const lack = row === undefined ? undefined : helloLacks(row.hello, kind);
93
+ if (row === undefined || lack === undefined)
94
+ return registry.unservedWhy?.(entry, kind);
95
+ return `${row.name} is a computer of your own, and its driver gives no ${kind} computer: ${lack}. Update the driver on ${row.name}`;
96
+ };
97
+ return { ...registry, PROVIDERS: [...registry.PROVIDERS, ...rows.map((row) => pairedEntry(row, registry))], unservedWhy };
98
+ }
99
+ /** The provider of the paired computer `row`: attachedProvider over the hub, or a refusal in ONE_PROCESS_WORDS where this
100
+ * process holds no hub. */
101
+ export function pairedProvider(row, hub) {
102
+ if (hub === undefined)
103
+ throw Object.assign(new Error(ONE_PROCESS_WORDS), { code: "computer_unavailable" });
104
+ return attachedProvider(pairedOf(row), hub);
105
+ }
106
+ /** Why the paired computer `row` cannot be had now, in words that say what to do, or undefined: it must be attached (its
107
+ * driver dialed this server). Asked at a run's start, as a vendor's readiness is; another run's hold is the claim's. */
108
+ export function pairedRefusal(row, hub) {
109
+ if (hub === undefined)
110
+ return ONE_PROCESS_WORDS;
111
+ if (!hub.online(row.id))
112
+ return `This agent's computer is ${row.name}, which is not attached now: open its driver on that computer, which dials this server, then start the run again.`;
113
+ return undefined;
114
+ }
@@ -1,7 +1,7 @@
1
- import { type ComputerSpec, type DockerVolume } from "@parcha/agentrun-computer";
1
+ import { type AttachHub, type ComputerSpec, type DockerVolume } from "@parcha/agentrun-computer";
2
2
  import type { DockerPaths } from "../box-paths.js";
3
3
  import { type HostRead } from "../docker-host-addresses.js";
4
- import type { ProviderFactories } from "../computer-keys.js";
4
+ import { type ProviderFactories } from "../computer-keys.js";
5
5
  import type { FauxComputers } from "../faux-computers.js";
6
6
  import { type KeyEnv } from "../key-meta.js";
7
7
  import type { Store } from "../store/index.js";
@@ -48,8 +48,14 @@ export interface ComputerDepsOptions {
48
48
  /** The server's environment: a provider key named here wins over its saved one; AGENTRUN_DOCKER_IMAGE names Docker's
49
49
  * image. Passed in, never read here. */
50
50
  readonly env: KeyEnv;
51
- /** The store: its sealed keys (a provider's saved keys) and its computer ledger (the phone provider's). */
52
- readonly store: Pick<Store, "sealedKeys" | "computerLedger">;
51
+ /** The store: its sealed keys (a provider's saved keys), its computer ledger (the phone provider's) and its paired
52
+ * computers (a test's stand-in may have none). */
53
+ readonly store: Pick<Store, "sealedKeys" | "computerLedger"> & {
54
+ readonly pairedComputers?: Pick<Store["pairedComputers"], "list">;
55
+ };
56
+ /** The server's AttachHub, where this runner shares the server's process (runner/beside.ts): a paired computer's
57
+ * socket is there. Absent: a runner of its own process, which refuses a paired computer in words. */
58
+ readonly hub?: AttachHub;
53
59
  /** The server's seal key: absent, no saved key is opened (a key from the environment still is). */
54
60
  readonly sealKey: Buffer | undefined;
55
61
  /** The kind registry: the computer package's unless given (a test's fixture). */
@@ -66,15 +72,15 @@ export interface ComputerDepsOptions {
66
72
  /** Whether a provider that binds a folder of this machine answers here now (Docker), for the Mode 1 default. */
67
73
  readonly answers?: ComputerForClaimDeps["answers"];
68
74
  /** This machine's Docker daemon, asked when a Docker launch fails (docker-daemon.ts dockerDaemonCheck over `env`
69
- * unless given; none under --faux, whose launch is its own). */
75
+ * unless given). */
70
76
  readonly daemon?: ComputerForClaimDeps["daemon"];
71
77
  /** Why this machine cannot run a provider's computers, by its id (computers.ts hostCommandRefusals over this process's
72
78
  * PATH): the claim refuses such a computer before it rents anything. Absent: not asked. */
73
79
  readonly hostWhy?: Readonly<Record<string, string>>;
74
80
  /** The live view's registration for a desktop or a phone (proxy-only): absent, no view is opened. */
75
81
  readonly openComputerView?: OpenComputerView;
76
- /** --faux's computers (faux-computers.ts), in place of the computer package's: their kind registry, key table, launch
77
- * and factories. */
82
+ /** --faux's computers (faux-computers.ts), beside the computer package's: their providers in the kind registry, their
83
+ * keys and factories with the package's, and their launch for their own providers. */
78
84
  readonly faux?: FauxComputers;
79
85
  }
80
86
  /** The spec a computer of `kind` on `entry` is made with, besides its labels and its mount: its image (a provider that
@@ -100,8 +106,9 @@ export declare const computerReadyWords: ({ provider, kind, hello }: ComputerSai
100
106
  export declare const claimComputer: (launch: ClaimLaunch, store: Parameters<typeof computerForClaim>[1] & {
101
107
  readonly runs?: Pick<Store["runs"], "launch">;
102
108
  }, deps: ComputerForClaimDeps) => Promise<ClaimComputer>;
103
- /** The kind registry a claim composed with `options` resolves a setting against: --faux's when it is given faux, else a
104
- * test's own, else the computer package's. The one choice: computerDepsFrom makes it, and the server's start check
109
+ /** The kind registry a claim composed with `options` resolves a setting against: a test's own, else the computer
110
+ * package's; given faux, with --faux's providers beside them (so a --faux run takes the faux desktop, and a run on a
111
+ * provider a test loads still gets it). The one choice: computerDepsFrom makes it, and the server's start check
105
112
  * (server.ts computerReady) asks it with what the runner composes with, so a run's start and its claim answer alike. */
106
113
  export declare function claimKinds(options: Pick<ComputerDepsOptions, "faux" | "kinds">): KindRegistry;
107
114
  /** computerForClaim and its process-wide deps, composed once; and Settings → Computers' factories from the same makers. */
@@ -22,6 +22,7 @@ import { DockerProvider } from "@parcha/agentrun-computer/docker";
22
22
  import { DOCKER_IMAGE_ENV } from "../box-image.js";
23
23
  import { dockerDaemonCheck } from "../docker-daemon.js";
24
24
  import { unionOf } from "../docker-host-addresses.js";
25
+ import { KEY_TABLE } from "../computer-keys.js";
25
26
  import { envValue, keyReader } from "../key-meta.js";
26
27
  import { boxAllowOf, boxAllowSetIn } from "../box-settings.js";
27
28
  import { readLaunchBody } from "../run-launch.js";
@@ -193,12 +194,17 @@ export const claimComputer = async (launch, store, deps) => {
193
194
  const boxAllow = body?.boxAllow;
194
195
  return computerForClaim(boxAllow === undefined ? launch : { ...launch, boxAllow, ...(body?.boxAllowSet ? { boxAllowSet: true } : {}) }, store, deps);
195
196
  };
196
- /** The kind registry a claim composed with `options` resolves a setting against: --faux's when it is given faux, else a
197
- * test's own, else the computer package's. The one choice: computerDepsFrom makes it, and the server's start check
197
+ /** The kind registry a claim composed with `options` resolves a setting against: a test's own, else the computer
198
+ * package's; given faux, with --faux's providers beside them (so a --faux run takes the faux desktop, and a run on a
199
+ * provider a test loads still gets it). The one choice: computerDepsFrom makes it, and the server's start check
198
200
  * (server.ts computerReady) asks it with what the runner composes with, so a run's start and its claim answer alike. */
199
201
  export function claimKinds(options) {
202
+ const base = options.kinds ?? { SETTING_KINDS, PROVIDERS, servingRefusals };
203
+ if (!options.faux)
204
+ return base;
200
205
  // The faux registry is Settings' shape (computers.ts); the claim reads the same data as resolve-computer.ts's.
201
- return options.faux?.kinds ?? options.kinds ?? { SETTING_KINDS, PROVIDERS, servingRefusals };
206
+ const faux = options.faux.kinds;
207
+ return { ...base, PROVIDERS: [...base.PROVIDERS, ...faux.PROVIDERS] };
202
208
  }
203
209
  /** This machine's Docker daemon as the claim asks it once a Docker launch fails: one check per process (its answer
204
210
  * kept a while, docker-daemon.ts), in `env`. */
@@ -260,13 +266,19 @@ export function computerDepsFrom(options) {
260
266
  spec: computerSpecOf(env),
261
267
  check: { readBackOf },
262
268
  keyOf: keyReader(store, sealKey, env),
263
- // Under --faux, its launch makes the computer, with its key table: no provider of the package is built.
264
- ...(faux ? { keyTable: faux.keyTable, launch: (entry, spec) => faux.launch(entry, spec) } : {}),
269
+ // Under --faux, its launch makes a faux provider's computer, its keys beside the package's: any other provider's is
270
+ // made as without it.
271
+ ...(faux ? {
272
+ keyTable: { keys: { ...KEY_TABLE.keys, ...faux.keyTable.keys }, labels: { ...KEY_TABLE.labels, ...faux.keyTable.labels } },
273
+ launch: (entry, spec) => faux.launch(entry, spec),
274
+ launches: (provider) => faux.owns(provider),
275
+ } : {}),
265
276
  ...(options.answers ? { answers: options.answers } : {}),
266
277
  ...(options.hostWhy ? { hostWhy: (provider) => (Object.hasOwn(options.hostWhy, provider) ? options.hostWhy[provider] : undefined) } : {}),
267
- ...(options.daemon ? { daemon: options.daemon } : faux ? {} : { daemon: dockerDaemonOf(env) }),
278
+ ...(options.daemon ? { daemon: options.daemon } : { daemon: dockerDaemonOf(env) }),
268
279
  ...(options.openComputerView ? { openComputerView: options.openComputerView } : {}),
280
+ ...(store.pairedComputers ? { attached: { rows: () => store.pairedComputers.list(), ...(options.hub ? { hub: options.hub } : {}) } } : {}),
269
281
  };
270
- const factories = faux?.factories ?? computerProviderFactories(providers, (id) => storeLedger(store.computerLedger, id));
282
+ const factories = { ...computerProviderFactories(providers, (id) => storeLedger(store.computerLedger, id)), ...faux?.factories };
271
283
  return { computerForClaim: claimComputer, computerDeps, factories };
272
284
  }
@@ -1,8 +1,9 @@
1
- import type { ComputerProvider, ComputerSpec, HelloResult } from "@parcha/agentrun-computer";
1
+ import type { ComputerProvider, ComputerSpec, HelloResult, Result, ScreenWatch, ScreenWatchHandlers, WatchOptions } from "@parcha/agentrun-computer";
2
2
  import { type PlaceView } from "../computer-setting.js";
3
3
  import { type KeyTable, type ProviderSettings } from "../computer-keys.js";
4
4
  import type { Store } from "../store/index.js";
5
5
  import type { MountCheck } from "./attach.js";
6
+ import { type AttachedComputers } from "./attached-computers.js";
6
7
  import { type HeldComputer } from "./computer-hold.js";
7
8
  import { type ProviderLedger } from "./computer-ledger.js";
8
9
  import { type ClaimBrowser, type ClaimSide, type ComputerSetting, type ComputerSettingKind, type KindRegistry, type ProviderEntry } from "./resolve-computer.js";
@@ -46,9 +47,11 @@ export type ProviderExtras = {
46
47
  };
47
48
  /** Why a live view ends: the computer was released, or the run ended. */
48
49
  export type ViewEnd = "released" | "ended";
49
- /** The live view of a desktop or a phone, proxy-only, as its registration (computer-live.ts
50
- * openComputerView, taken as a dep until it is on the base) opens it at the claim: fenced on the claim, tagged with the
51
- * computer's ref id, fed by the provider's watch, and held by the run's take-over hold. */
50
+ /** A computer's live frames and input: its provider's watch on the computer's ref (ComputerProvider.watch). */
51
+ export type WatchOf = (handlers: ScreenWatchHandlers, options: WatchOptions) => Promise<Result<ScreenWatch>>;
52
+ /** The live view of a desktop or a phone, proxy-only, as its registration (computer-live.ts openClaimView, which the
53
+ * runner composes in) opens it at the claim: fenced on the claim, tagged with the computer's ref id, fed by the
54
+ * provider's watch, and held by the run's take-over hold. */
52
55
  export type OpenComputerView = (args: {
53
56
  readonly store: unknown;
54
57
  readonly sealKey: Buffer | undefined;
@@ -57,7 +60,9 @@ export type OpenComputerView = (args: {
57
60
  /** How the viewer's input is made into actions: a desktop's, or the phone's platform (its machine kind). */
58
61
  readonly input: "desktop" | "android" | "ios";
59
62
  readonly tag: string;
60
- readonly watch: (signal: AbortSignal) => unknown;
63
+ /** The launched computer's watch, bound to its ref: the opener gives the handlers and the signal. */
64
+ readonly watch: WatchOf;
65
+ /** The run's hold (computer-hold.ts ComputerHold). */
61
66
  readonly hold: unknown;
62
67
  }) => Promise<{
63
68
  readonly ok: true;
@@ -66,7 +71,7 @@ export type OpenComputerView = (args: {
66
71
  };
67
72
  } | {
68
73
  readonly ok: false;
69
- readonly refused: "fenced" | "bad_tag" | "kind";
74
+ readonly refused: "fenced" | "bad_tag" | "kind" | "failed";
70
75
  readonly message: string;
71
76
  }>;
72
77
  export interface ComputerForClaimDeps {
@@ -90,8 +95,10 @@ export interface ComputerForClaimDeps {
90
95
  readonly answers?: (provider: string) => Promise<boolean>;
91
96
  /** Its daemon's answer (docker-daemon.ts), asked when a launch on such a provider fails (ClaimSide.daemon). */
92
97
  readonly daemon?: ClaimSide["daemon"];
93
- /** A launch of the server's own in place of the providers' (--faux's desktop). */
98
+ /** A launch of the server's own in place of the providers' (--faux's desktop), for the providers `launches` takes (by
99
+ * id; absent, every one): any other is made by its provider, as with no launch. */
94
100
  readonly launch?: ClaimSide["launch"];
101
+ readonly launches?: (provider: string) => boolean;
95
102
  /** The run's folder (mounted only where the provider mounts it) and the mount check attach runs. */
96
103
  readonly workspace: Workspace;
97
104
  readonly check: MountCheck;
@@ -112,6 +119,9 @@ export interface ComputerForClaimDeps {
112
119
  * phone's adb not on PATH), in words that say how to fix it, or undefined: refused with code computer_unavailable
113
120
  * before anything is rented. Absent: not asked. */
114
121
  readonly hostWhy?: (provider: string) => string | undefined;
122
+ /** The paired computers (attached-computers.ts): each one more provider of `kinds` for this claim, claimed through the
123
+ * hub of this process. Absent: none is. */
124
+ readonly attached?: AttachedComputers;
115
125
  /** Why this run's harness takes no computer of `kind`, in words (a CLI harness's of a browser), or undefined: a kind
116
126
  * it refuses is refused with code computer_unavailable before anything is made. Absent: every kind. */
117
127
  readonly refuseKind?: (kind: Exclude<ComputerSettingKind, "none">) => string | undefined;
@@ -131,7 +141,6 @@ export interface ClaimComputer {
131
141
  readonly held?: HeldComputer;
132
142
  release(why?: ViewEnd): Promise<void>;
133
143
  }
134
- /** The provider's watch of a computer's screen (ComputerProvider.watch), where it has one. */
135
144
  /** Told once, before the claim waits on its computer's image being built or pulled; never when the host has it. */
136
145
  export type ImageWait = (making: "build" | "pull", tag: string) => void;
137
146
  /** What a computer the claim made says it is, once it is connected: the provider's name in words, the agent's setting