@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
package/dist/page.d.ts CHANGED
@@ -4,6 +4,22 @@ import type { Owner } from "./owner.js";
4
4
  * once opens the address over https only, for a year. None over http or with no public address (a browser would pin
5
5
  * the loopback address to https and lose the console). */
6
6
  export declare function hstsHeaders(publicUrl: string | undefined): Record<string, string>;
7
+ /**
8
+ * The console's sessions on a server with no accounts. Each start makes a launch code at random and prints its link
9
+ * (`/?launch=<code>`, Serve's `consoleUrl`); a browser that opens it gets a session: an id made at random, kept here, in
10
+ * memory, as its cookie. Neither the code nor an id is derived from the API token, so the token, whoever holds it, never
11
+ * computes or fetches a session: its own link (`/?token=`) signs no browser in. A restart forgets them, and the new
12
+ * start prints its own link.
13
+ */
14
+ export declare class ConsoleSessions {
15
+ readonly code: string;
16
+ /** The sessions, by the hash of their id (a lookup that reads no id), oldest first. */
17
+ private readonly ids;
18
+ /** A new session's id when `code` is this start's, else undefined. */
19
+ open(code: string): string | undefined;
20
+ /** Whether `value` is a session this server made. */
21
+ holds(value: string): boolean;
22
+ }
7
23
  export declare const overHttps: (req: IncomingMessage) => boolean;
8
24
  export declare const ownOrigin: (req: IncomingMessage) => string;
9
25
  export declare const isJson: (req: IncomingMessage) => boolean;
@@ -19,10 +35,12 @@ export declare const signedIn: (req: IncomingMessage, owner: Owner) => boolean;
19
35
  export declare const sendHostRefused: (req: IncomingMessage, res: ServerResponse) => void;
20
36
  /** `takesBytes`: whether a request of `method` to `path` (under /v2) goes to a route whose body is bytes (server.ts). */
21
37
  /** `publicUrl`: the address people open (AGENTRUN_PUBLIC_URL); an https one adds HSTS to every page answer (hstsHeaders). */
38
+ /** `sessions`: the console's sessions on a server with no accounts (ConsoleSessions); with `owner`, none. */
22
39
  type PageServer = {
23
40
  token: string;
24
41
  authFailed?: (route: string, reason: string) => void;
25
42
  owner?: Owner;
43
+ sessions?: ConsoleSessions;
26
44
  console?: string | undefined;
27
45
  takesBytes?: (method: string | undefined, path: string) => boolean;
28
46
  publicUrl?: string;
package/dist/page.js CHANGED
@@ -1,9 +1,10 @@
1
1
  // The console at "/" (apps/console, which this package's build copies into dist/console): its index.html and Vite's
2
2
  // hashed assets under /assets/, public, under one strict CSP. The console signs a person in itself. With accounts it
3
- // takes the owner's session cookie (owner.ts); without, the server's token as a cookie that the printed link (`/?token=`)
4
- // sets once. Either stands in for the Bearer header on /v2, and for a write only from this origin with a JSON body, or
3
+ // takes the owner's session cookie (owner.ts); without, a console session the link this start prints (`/?launch=<code>`)
4
+ // sets (ConsoleSessions): made at random, kept by the server, never computable from the API token, and the token's own
5
+ // link signs no browser in. Either stands in for the Bearer header on /v2, and for a write only from this origin with a JSON body, or
5
6
  // with any body on a route that takes bytes (a PUT or POST marked `raw` in server.ts).
6
- import { createHash, createHmac, timingSafeEqual } from "node:crypto";
7
+ import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
7
8
  import { readFile, realpath, stat } from "node:fs/promises";
8
9
  import { extname, join, sep } from "node:path";
9
10
  import { fileURLToPath } from "node:url";
@@ -36,8 +37,34 @@ const CONSOLE_SEGMENT = /^[A-Za-z0-9_-][A-Za-z0-9._-]*$/;
36
37
  const MOVED = new Set(["/console", "/console/", "/setup", "/sign-in"]);
37
38
  const digest = (text) => createHash("sha256").update(text).digest();
38
39
  const same = (given, expected) => timingSafeEqual(digest(given), digest(expected));
39
- /** The cookie's value: a MAC of the token, so the cookie is never the API key itself. */
40
- const sessionOf = (token) => createHmac("sha256", token).update("agentrun-serve page").digest("base64url");
40
+ /** The most console sessions a server keeps at once; past it, the oldest is forgotten (its browser opens the link again). */
41
+ const CONSOLE_SESSIONS = 64;
42
+ /**
43
+ * The console's sessions on a server with no accounts. Each start makes a launch code at random and prints its link
44
+ * (`/?launch=<code>`, Serve's `consoleUrl`); a browser that opens it gets a session: an id made at random, kept here, in
45
+ * memory, as its cookie. Neither the code nor an id is derived from the API token, so the token, whoever holds it, never
46
+ * computes or fetches a session: its own link (`/?token=`) signs no browser in. A restart forgets them, and the new
47
+ * start prints its own link.
48
+ */
49
+ export class ConsoleSessions {
50
+ code = randomBytes(24).toString("base64url");
51
+ /** The sessions, by the hash of their id (a lookup that reads no id), oldest first. */
52
+ ids = new Set();
53
+ /** A new session's id when `code` is this start's, else undefined. */
54
+ open(code) {
55
+ if (!same(code, this.code))
56
+ return undefined;
57
+ const id = randomBytes(32).toString("base64url");
58
+ this.ids.add(digest(id).toString("hex"));
59
+ if (this.ids.size > CONSOLE_SESSIONS)
60
+ this.ids.delete(this.ids.values().next().value);
61
+ return id;
62
+ }
63
+ /** Whether `value` is a session this server made. */
64
+ holds(value) {
65
+ return this.ids.has(digest(value).toString("hex"));
66
+ }
67
+ }
41
68
  /** One name per port: cookies are kept per host, not per port, and another server on this machine has another token. */
42
69
  const cookieName = (req) => `agentrun-${req.socket.localPort}`;
43
70
  const cookiesOf = (req, name) => String(req.headers.cookie ?? "").split(";").map((part) => part.trim()).filter((part) => part.startsWith(`${name}=`)).map((part) => part.slice(name.length + 1));
@@ -85,30 +112,31 @@ async function answer(req, res, raw, server) {
85
112
  return redirect(res, `/${(req.url ?? "").slice(raw.length)}`);
86
113
  if (raw !== "/")
87
114
  return file(req, res, raw, dir, raw.slice(1));
88
- // Without accounts, the printed link's token becomes this browser's cookie once. With an owner the console is the
89
- // owner's session alone: the token is for scripts and the CLI, and its link signs no browser in.
115
+ // Without accounts, the printed link's launch code gives this browser a console session (ConsoleSessions). The token
116
+ // is for scripts and the CLI: a token in the address signs nothing in, here or with an owner, and leaves it (the same
117
+ // address without it, no cookie). With an owner the console is the owner's session alone.
90
118
  const url = new URL(req.url ?? "/", "http://serve");
91
- const without = () => (url.searchParams.delete("token"), `/${url.searchParams.size ? `?${url.searchParams}` : ""}`);
92
- // With an owner a token in the address signs nothing in, and leaves it: the same address without it, no cookie.
93
- if (server.owner && url.searchParams.has("token"))
119
+ const without = () => (url.searchParams.delete("token"), url.searchParams.delete("launch"), `/${url.searchParams.size ? `?${url.searchParams}` : ""}`);
120
+ const given = url.searchParams.get("launch");
121
+ if (url.searchParams.has("token") || (server.owner && given !== null))
94
122
  return redirect(res, without());
95
- const given = server.owner ? null : url.searchParams.get("token");
96
- // A token holds no whitespace, so a space in the link is a "+" that was not encoded.
97
- if (given !== null && (same(given, server.token) || same(given.replaceAll(" ", "+"), server.token))) {
98
- return redirect(res, without(), { "set-cookie": `${cookieName(req)}=${sessionOf(server.token)}; HttpOnly; SameSite=Strict; Path=/${overHttps(req) ? "; Secure" : ""}` });
99
- }
123
+ // A code holds no "+", but a space in the link is one that was not encoded all the same.
124
+ const id = given === null ? undefined : server.sessions?.open(given) ?? server.sessions?.open(given.replaceAll(" ", "+"));
125
+ if (id !== undefined)
126
+ return redirect(res, without(), { "set-cookie": `${cookieName(req)}=${id}; HttpOnly; SameSite=Strict; Path=/${overHttps(req) ? "; Secure" : ""}` });
100
127
  if (given !== null)
101
- server.authFailed?.(raw, "wrong_link_token");
128
+ server.authFailed?.(raw, "wrong_launch_code");
102
129
  return file(req, res, raw, dir, "index.html", given === null ? 200 : 401);
103
130
  }
104
131
  /** The requests the owner's password session sends from the page (a write only from this server's own origin, with a
105
- * JSON body), never under the cookie accounts-off mints from the token. */
132
+ * JSON body), never under an accounts-off console session. */
106
133
  const ownerSessions = new WeakSet();
107
134
  /** Whether `req` came from the owner's page under their password session (answerPage). A token, whoever holds it, never
108
135
  * did. */
109
136
  export const byOwnerSession = (req) => ownerSessions.has(req);
110
- /** The requests the console sends under the cookie accounts-off mints from the token (no password), held to this server's
111
- * own origin and a JSON body as every page write is: a fact secret-writes.ts reads (mayWriteSecrets), never an owner. */
137
+ /** The requests the console sends under an accounts-off console session (ConsoleSessions: the launch link's, made at
138
+ * random, never from the token), held to this server's own origin and a JSON body as every page write is: a fact
139
+ * secret-writes.ts reads (mayWriteSecrets), never an owner. */
112
140
  const consoleSessions = new WeakSet();
113
141
  /** Whether `req` came from the accounts-off console's page session (answerPage). */
114
142
  export const byConsoleSession = (req) => consoleSessions.has(req);
@@ -119,7 +147,7 @@ export const byConsoleSession = (req) => consoleSessions.has(req);
119
147
  * content type.
120
148
  */
121
149
  export function answerPage(req, res, raw, server) {
122
- const held = server.owner ? signedIn(req, server.owner) : cookiesOf(req, cookieName(req)).some((value) => same(value, sessionOf(server.token)));
150
+ const held = server.owner ? signedIn(req, server.owner) : cookiesOf(req, cookieName(req)).some((value) => server.sessions?.holds(value) === true);
123
151
  if (raw.startsWith("/v2/")) {
124
152
  const safe = req.method === "GET" || req.method === "HEAD";
125
153
  const bytes = (req.method === "PUT" || req.method === "POST") && server.takesBytes?.(req.method, raw.slice(3)) === true;
@@ -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 { Refusal } from "@parcha/agentrun-kernel";
3
3
  import { type ToolExecutionApi, type ToolRegistration } from "@earendil-works/pi-durable";
4
4
  /** Parallel's published prices (https://docs.parallel.ai/getting-started/pricing, read 2026-11-03): a `fast` search
@@ -3,7 +3,7 @@
3
3
  * list is narrowed to none (workspace/computer-deps.ts networkOf). */
4
4
  export declare const remoteNoList: (id: "daytona" | "modal") => string;
5
5
  /** Every box a place may name, in the order capabilities lists them. */
6
- export declare const BOX_IDS: readonly ["bwrap", "docker", "modal", "daytona"];
6
+ export declare const BOX_IDS: readonly ["docker", "modal", "daytona"];
7
7
  export type BoxId = (typeof BOX_IDS)[number];
8
8
  /** A box as capabilities show it: whether this server has it, and why when not (or how it was checked); `state`, which
9
9
  * capabilities derive from it (place.ts stated). `network`: what an available box reaches (BOX_NETWORKS), with
@@ -81,8 +81,7 @@ export type PlaceOffersOptions = {
81
81
  /** Under --faux only: Docker answers, whatever AGENTRUN_BOXES lists, and nothing asks it. */
82
82
  fauxDocker?: boolean;
83
83
  };
84
- /** Every box, in BOX_IDS order, as this server has it at its start (`env`: its environment, its secrets readable): bwrap
85
- * is in no release; a box AGENTRUN_BOXES does not list is not enabled; docker by its probe (or `fauxDocker`); daytona
84
+ /** Every box, in BOX_IDS order, as this server has it at its start (`env`: its environment, its secrets readable): a box AGENTRUN_BOXES does not list is not enabled; docker by its probe (or `fauxDocker`); daytona
86
85
  * and modal by their keys. Rejects only for a name in AGENTRUN_BOXES that is no box. No reason holds a key or an answer's body. */
87
86
  export declare function placeOffers(env: NodeJS.ProcessEnv, options?: PlaceOffersOptions): Promise<BoxOffer[]>;
88
87
  /** What each available box reaches, from the server's host list (`allow`, box-settings.ts boxAllowOf): Docker's
@@ -8,7 +8,7 @@
8
8
  // lists it, an empty value or `none` sets up no box, and a name in it that is no box refuses the start. Every reason says
9
9
  // what to do next. Docker is probed (`docker version`); Daytona and Modal are offered when the keys their computer
10
10
  // provider requires are set (the server's environment, else saved in Settings → Computers), and are not asked anything
11
- // at the start: a key the vendor refuses fails the run's computer start, in the vendor's words. bwrap is in no release.
11
+ // at the start: a key the vendor refuses fails the run's computer start, in the vendor's words.
12
12
  import { execFile } from "node:child_process";
13
13
  import { readFile } from "node:fs/promises";
14
14
  import { userInfo } from "node:os";
@@ -19,7 +19,7 @@ import { withoutSecrets } from "./secrets.js";
19
19
  * list is narrowed to none (workspace/computer-deps.ts networkOf). */
20
20
  export const remoteNoList = (id) => `a ${id === "daytona" ? "Daytona" : "Modal"} computer is never made with a host list, so a ${id} box has no network`;
21
21
  /** Every box a place may name, in the order capabilities lists them. */
22
- export const BOX_IDS = ["bwrap", "docker", "modal", "daytona"];
22
+ export const BOX_IDS = ["docker", "modal", "daytona"];
23
23
  /** What an available box reaches: the hosts of `places.allow` (`allowlist`), or nothing (`none`). */
24
24
  export const BOX_NETWORKS = ["allowlist", "none"];
25
25
  /** A box's state in capabilities: ready (available) or unavailable. */
@@ -161,15 +161,12 @@ async function remoteOffer(id, keyOf) {
161
161
  return { id, available: false, reason: `needs ${missing.join(" and ")}` };
162
162
  return { id, available: true, reason: "configured; not probed at start" };
163
163
  }
164
- /** Every box, in BOX_IDS order, as this server has it at its start (`env`: its environment, its secrets readable): bwrap
165
- * is in no release; a box AGENTRUN_BOXES does not list is not enabled; docker by its probe (or `fauxDocker`); daytona
164
+ /** Every box, in BOX_IDS order, as this server has it at its start (`env`: its environment, its secrets readable): a box AGENTRUN_BOXES does not list is not enabled; docker by its probe (or `fauxDocker`); daytona
166
165
  * and modal by their keys. Rejects only for a name in AGENTRUN_BOXES that is no box. No reason holds a key or an answer's body. */
167
166
  export async function placeOffers(env, options = {}) {
168
167
  const enabled = enabledBoxes(env);
169
168
  const keyOf = options.keyOf ?? (async (name) => env[name] || undefined);
170
169
  return Promise.all(BOX_IDS.map(async (id) => {
171
- if (id === "bwrap")
172
- return { id, available: false, reason: NOT_YET };
173
170
  // The tests' faux docker stands in whatever AGENTRUN_BOXES lists, as the old faux box did.
174
171
  if (id === "docker" && options.fauxDocker)
175
172
  return { id, available: true, reason: "a faux docker (tests)" };
@@ -180,7 +177,6 @@ export async function placeOffers(env, options = {}) {
180
177
  return remoteOffer(id, keyOf);
181
178
  }));
182
179
  }
183
- const NOT_YET = "the bwrap box is not in this release yet: use the docker box";
184
180
  /** What each available box reaches, from the server's host list (`allow`, box-settings.ts boxAllowOf): Docker's
185
181
  * computers through their egress proxy (an allowlist), with the Docker host's own addresses it refuses when the server
186
182
  * runs in a container (`hostAddresses`), or unavailable where `dockerRefused` says Docker can't run a computer here
package/dist/place.js CHANGED
@@ -4,8 +4,7 @@
4
4
  // before this field keeps its id. Which boxes this server has is said in capabilities, and a revision whose box it does
5
5
  // not have saves with a warning and is refused at run time. A run runs in its revision's place, else this host's
6
6
  // default, and keeps the place it resolved to: a run request names none. A sandbox place on a box is a sandbox computer
7
- // of that provider (computer-setting.ts computerOfPlace), which the run's claim starts: Docker, Daytona or Modal; bwrap
8
- // says it does not run yet. A harness's own tools in the box, when they come, are an option of sandbox, never a third
7
+ // of that provider (computer-setting.ts computerOfPlace), which the run's claim starts: Docker, Daytona or Modal. A harness's own tools in the box, when they come, are an option of sandbox, never a third
9
8
  // mode.
10
9
  //
11
10
  // The box is a new agent's default machine: an agentic definition that names no place is saved, at its create, with the
package/dist/print.d.ts CHANGED
@@ -2,7 +2,9 @@
2
2
  export type TokenSource = "made" | "file" | "env";
3
3
  /** The banner's lines. The token is printed only when this start made it; else where it is. `publicUrl` is the address
4
4
  * people open (AGENTRUN_PUBLIC_URL), which the base URL and the link use. With `accounts` the page is the owner's
5
- * password, so its link holds no token. `apiOnly`: no console to open, so the line says what is served instead. `boxes`: which boxes are ready, in words (Serve's boxesLine), last. */
5
+ * password, so its link holds nothing; with none, the link holds this start's launch code (`launchCode`), never the
6
+ * token. `apiOnly`: no console to open, so the line says what is served instead. `boxes`: which boxes are ready, in
7
+ * words (Serve's boxesLine), last. */
6
8
  export declare function banner(o: {
7
9
  url: string;
8
10
  baseUrl: string;
@@ -13,9 +15,21 @@ export declare function banner(o: {
13
15
  publicUrl?: string;
14
16
  accounts?: boolean;
15
17
  apiOnly?: boolean;
18
+ launchCode?: string;
16
19
  boxes?: string;
17
20
  }): string[];
18
21
  /** One log line. */
19
22
  export declare const logLine: (event: string, fields?: Record<string, string | number>) => string;
23
+ /** The log line of a runner's start or end event (runner.ts RunnerEvent): `run_started` (run, agent, kind) once a run's
24
+ * first claim, `run_ended` (run, agent, status, cost_usd) once it is final. Any other event has none. Ids and numbers
25
+ * only: no token or secret reaches a line. */
26
+ export declare function runLine(event: {
27
+ type: string;
28
+ runId?: string;
29
+ agent?: string;
30
+ kind?: string;
31
+ status?: string;
32
+ costUsd?: number | null;
33
+ }): string | undefined;
20
34
  /** A duration as --drain-timeout takes it ("8s", "500ms", "1m"), in milliseconds; undefined when it is not one. */
21
35
  export declare function durationMs(text: string): number | undefined;
package/dist/print.js CHANGED
@@ -3,7 +3,9 @@
3
3
  import { join } from "node:path";
4
4
  /** The banner's lines. The token is printed only when this start made it; else where it is. `publicUrl` is the address
5
5
  * people open (AGENTRUN_PUBLIC_URL), which the base URL and the link use. With `accounts` the page is the owner's
6
- * password, so its link holds no token. `apiOnly`: no console to open, so the line says what is served instead. `boxes`: which boxes are ready, in words (Serve's boxesLine), last. */
6
+ * password, so its link holds nothing; with none, the link holds this start's launch code (`launchCode`), never the
7
+ * token. `apiOnly`: no console to open, so the line says what is served instead. `boxes`: which boxes are ready, in
8
+ * words (Serve's boxesLine), last. */
7
9
  export function banner(o) {
8
10
  const where = o.source === "env" ? "$AGENTRUN_TOKEN" : `<in ${join(o.data, ".token")}>`;
9
11
  const key = o.source === "made" ? o.token : where;
@@ -11,10 +13,9 @@ export function banner(o) {
11
13
  `agentrun-serve on ${o.baseUrl} (agent store in ${o.data}${o.listen ? `, listening on ${o.listen}` : ""})`,
12
14
  `AGENTRUN_BASE_URL=${o.publicUrl ? `${o.publicUrl}/v2` : o.baseUrl}`,
13
15
  `AGENTRUN_API_KEY=${key}`,
14
- // Encoded: a "+" in a token reads as a space in a query string.
15
16
  o.apiOnly
16
17
  ? "API only (AGENTRUN_API_ONLY=1): the run routes are served; the console, sign-in, setup, settings, MCP, triggers and hooks are refused."
17
- : o.accounts ? `Open ${o.publicUrl ?? o.url}/` : `Open ${o.publicUrl ?? o.url}/?token=${o.source === "made" ? encodeURIComponent(o.token) : where}`,
18
+ : o.accounts || o.launchCode === undefined ? `Open ${o.publicUrl ?? o.url}/` : `Open ${o.publicUrl ?? o.url}/?launch=${o.launchCode}`,
18
19
  ...(o.boxes ? [o.boxes] : []),
19
20
  ];
20
21
  }
@@ -24,6 +25,16 @@ const value = (v) => {
24
25
  };
25
26
  /** One log line. */
26
27
  export const logLine = (event, fields = {}) => [`at=${new Date().toISOString()}`, `event=${event}`, ...Object.entries(fields).map(([k, v]) => `${k}=${value(v)}`)].join(" ");
28
+ /** The log line of a runner's start or end event (runner.ts RunnerEvent): `run_started` (run, agent, kind) once a run's
29
+ * first claim, `run_ended` (run, agent, status, cost_usd) once it is final. Any other event has none. Ids and numbers
30
+ * only: no token or secret reaches a line. */
31
+ export function runLine(event) {
32
+ if (event.type === "started")
33
+ return logLine("run_started", { run: event.runId, agent: event.agent, kind: event.kind });
34
+ if (event.type === "ended")
35
+ return logLine("run_ended", { run: event.runId, agent: event.agent, status: event.status === "ended" ? "completed" : event.status, cost_usd: event.costUsd ?? "unknown" });
36
+ return undefined;
37
+ }
27
38
  /** A duration as --drain-timeout takes it ("8s", "500ms", "1m"), in milliseconds; undefined when it is not one. */
28
39
  export function durationMs(text) {
29
40
  const m = /^(\d+(?:\.\d+)?)(ms|s|m)$/.exec(text.trim());
package/dist/propose.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { DraftAsk } from "./learn/skills.js";
2
2
  import { type Problem } from "./learn/index.js";
3
+ import type { DraftDecisions } from "./learn/skills.js";
3
4
  import { type Turn } from "./learning.js";
4
5
  import type { Workspace } from "./workspace/index.js";
5
6
  export type Proposed = {
@@ -33,6 +34,7 @@ export declare const proposeRun: (input: {
33
34
  folder: Workspace;
34
35
  runDir: string;
35
36
  seed: string;
37
+ notesSeed?: string;
36
38
  turn: Turn;
37
39
  refuse: readonly string[];
38
40
  outcome?: string;
@@ -40,5 +42,6 @@ export declare const proposeRun: (input: {
40
42
  gated?: Readonly<Record<string, string>>;
41
43
  deniedBy?: Readonly<Record<string, "agent" | "server" | "default">>;
42
44
  ask?: DraftAsk;
45
+ decisions?: DraftDecisions;
43
46
  workflows?: false;
44
47
  }) => Promise<Proposed>;
package/dist/propose.js CHANGED
@@ -101,11 +101,19 @@ export const proposeRun = async (input) => {
101
101
  if (!parsed.ok)
102
102
  return parsed.reason === "empty" ? { state: "dropped", reason: "empty" } : { state: "dropped", reason: "unparsed", detail: parsed.detail };
103
103
  const { base: seedBase, kept } = baseOf(snapshot);
104
- const rules = new Map(activeOf(snapshot).flatMap((file) => {
105
- const note = texts.has(file) ? parseNoteFile(file, texts.get(file)) : undefined;
104
+ // A later round's notes are checked against the main the earlier rounds merged into (`notesSeed`: a note round 1 added
105
+ // is a supersedes target and a duplicate rule), while a skill's or a draft's files keep `seed` as their conflict base:
106
+ // the run was laid from it, so a file changed on main since is a conflict, never written over.
107
+ const noted = input.notesSeed && input.notesSeed !== input.seed
108
+ ? await seedAt(input.folder, input.notesSeed, (seedSnapshot) => (parsed.ok ? [...parsed.notes.map(({ file }) => file), ...activeOf(seedSnapshot)] : []))
109
+ : { snapshot, texts };
110
+ const rules = new Map(activeOf(noted.snapshot).flatMap((file) => {
111
+ const note = noted.texts.has(file) ? parseNoteFile(file, noted.texts.get(file)) : undefined;
106
112
  return note && !Array.isArray(note) ? [[ruleOf(note.body), file]] : [];
107
113
  }));
108
- const base = { ...seedBase, rules };
114
+ const learnedPath = (path) => path.startsWith(`${SKILLS_DIR}/`) || path.startsWith(`${WORKFLOWS_DIR}/`);
115
+ const notedBase = baseOf(noted.snapshot).base;
116
+ const base = { files: [...[...notedBase.files].filter((path) => !learnedPath(path)), ...[...seedBase.files].filter(learnedPath)], active: notedBase.active, rules };
109
117
  const held = new Set(base.files);
110
118
  const files = given.filter((group) => group.some(({ file, text }) => texts.get(file) !== text)).flat();
111
119
  const changeOf = ({ file, text }) => ({ path: file, status: held.has(file) ? "modified" : "added", mode: "100644", bytes: Buffer.from(text) });
@@ -116,7 +124,7 @@ export const proposeRun = async (input) => {
116
124
  const changes = parsed.order.flatMap(({ kind, name }) => {
117
125
  if (kind === NOTE_BLOCK) {
118
126
  const text = noteTexts.get(name);
119
- return texts.get(name) !== text ? [changeOf({ file: name, text })] : [];
127
+ return noted.texts.get(name) !== text ? [changeOf({ file: name, text })] : [];
120
128
  }
121
129
  return (fileGroups.get(keyOf(kind, name)) ?? []).filter(({ file }) => changed.has(file)).map(changeOf);
122
130
  });
@@ -131,7 +139,7 @@ export const proposeRun = async (input) => {
131
139
  return { state: "dropped", reason: "checker", problems: leaky };
132
140
  // A skill or a draft whose seed text has a status is a person's call (retired, or waiting for their OK): never changed.
133
141
  const dryRuns = {};
134
- const check = (some) => checkProposal({ base, changes: some, refuseValues: input.refuse, ...(input.workflows === false ? { workflows: false } : {}), ...(kept.length ? { kept } : {}), ...(input.outcome === undefined ? {} : { outcome: input.outcome }), ...(input.tools ? { tools: input.tools } : {}), ...(input.gated ? { gated: input.gated } : {}), ...(input.deniedBy ? { deniedBy: input.deniedBy } : {}), ...(input.ask ? { ask: input.ask } : {}), ...(dsl ? { dsl, dryRuns } : {}) });
142
+ const check = (some) => checkProposal({ base, changes: some, refuseValues: input.refuse, ...(input.workflows === false ? { workflows: false } : {}), ...(kept.length ? { kept } : {}), ...(input.outcome === undefined ? {} : { outcome: input.outcome }), ...(input.tools ? { tools: input.tools } : {}), ...(input.gated ? { gated: input.gated } : {}), ...(input.deniedBy ? { deniedBy: input.deniedBy } : {}), ...(input.ask ? { ask: input.ask } : {}), ...(input.decisions ? { decisions: input.decisions } : {}), ...(dsl ? { dsl, dryRuns } : {}) });
135
143
  // The static checks first, every one (validateWorkflow with executeCode: false, draftProblems' refusal of code nodes,
136
144
  // caps, secrets): a draft they refuse is never dry-run, nor is any when they refuse the answer whole. Then each draft
137
145
  // left is dry-run on its example, else on a synthesized input (learn/skills.ts draftDryRun): every model and tool
package/dist/provider.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { chooseModel, FAUX_ENV, hostModel } from "./model.js";
2
2
  import { WIRES } from "./wires.js";
3
+ import { modelFormWhy } from "./model-form.js";
3
4
  // Each wire's own settings live in a leaf module (wires.ts), which the harness table reads as it loads.
4
5
  export { WIRES };
5
6
  /** Why this server cannot run a harness here, in words a person can act on; `fix`, when installing is the fix; `keys`,
@@ -151,14 +152,14 @@ export async function modelOn(wire, env, ref, harness) {
151
152
  const modelId = named.slice(vendor.length + 1);
152
153
  const { builtinModels } = await import("@earendil-works/pi-ai/providers/all");
153
154
  if (!builtinModels().getModel(vendor, modelId))
154
- return { why: `pi-ai knows no model ${modelId} of ${vendor}. Name one of its models, or route every model through a gateway with AGENT_MODEL_BASE_URL.`, host: ref === undefined, needs: "model" };
155
+ return { why: modelFormWhy(env, harness, named, ref === undefined), host: ref === undefined, needs: "model" };
155
156
  return { model: { provider: vendor, modelId } };
156
157
  }
157
158
  if (!named)
158
159
  return { why: `No model yet for ${harness}: add an OpenRouter or ${label} key in Settings → Model keys, or set OPENROUTER_API_KEY or ${WIRES[wire].key} where AgentRun starts.`, host: true };
159
160
  const slash = named.indexOf("/");
160
161
  if (slash < 1)
161
- return { why: `${harness} runs a model named ${vendor}/<model-id>; the run's model is ${named}.`, host: ref === undefined };
162
+ return { why: modelFormWhy(env, harness, named, ref === undefined), host: ref === undefined };
162
163
  const [provider, modelId] = [named.slice(0, slash), named.slice(slash + 1)];
163
164
  // OpenRouter's name for a model is OpenRouter's provider, then the vendor's model; another vendor's is providerFor's
164
165
  // to refuse.
@@ -1,7 +1,8 @@
1
1
  import type { TimelineEvent } from "./timeline/index.js";
2
2
  import type { Status } from "./run-view.js";
3
3
  /** A run's end-of-run turn: the job's outcome, the newest store entry before the turn and, once the run ended, the newest
4
- * after it (its rows are those between), its deadline, and how it ended. */
4
+ * after it (its rows are those between), its deadline, and how it ended. `earlier`: the turns of the run's earlier ends,
5
+ * each closed (a follow-up opened the run again after it looked back), whose rows are the turn's too. */
5
6
  export type Reflect = {
6
7
  outcome: Status;
7
8
  after: number;
@@ -9,6 +10,12 @@ export type Reflect = {
9
10
  deadline: string;
10
11
  ended?: true;
11
12
  timedOut?: true;
13
+ earlier?: readonly ReflectSpan[];
14
+ };
15
+ /** One earlier end-of-run turn of a run: the store entry before it, and the run's end entry that closed it. */
16
+ export type ReflectSpan = {
17
+ readonly after: number;
18
+ readonly until: number;
12
19
  };
13
20
  /** The run asked its end-of-run turn and has not ended since. */
14
21
  export declare const reflecting: (run: {
@@ -12,7 +12,7 @@ export function reflects(reflect, id) {
12
12
  return false;
13
13
  const entry = typeof id === "number" ? id : entryOf(id);
14
14
  if (Number.isInteger(entry))
15
- return entry > reflect.after && (reflect.until === undefined || entry <= reflect.until);
15
+ return (entry > reflect.after && (reflect.until === undefined || entry <= reflect.until)) || (reflect.earlier ?? []).some(({ after, until }) => entry > after && entry <= until);
16
16
  return reflect.until === undefined && typeof id === "string" && id.includes(":live:");
17
17
  }
18
18
  /** `rows` with the end-of-run turn's labelled: never the run's answer (meaningful skips the label), its answer shown as
@@ -13,6 +13,9 @@ export interface RunLaunch {
13
13
  /** The start request's body, as the person or trigger gave it, or an object a built-in run names. */
14
14
  readonly input: unknown;
15
15
  readonly title: string;
16
+ /** The GitHub repository (owner/name) a person's run reaches, from the start body's `repo` or its agent's one bound
17
+ * repository (run-repo.ts); a github trigger's run has none here, its event names it. */
18
+ readonly repo?: string;
16
19
  readonly place: Place;
17
20
  /** The loop's adapter, when not the revision's: a built-in learning run names "learning". */
18
21
  readonly harness?: string;
@@ -43,14 +46,16 @@ export interface RunLaunch {
43
46
  * shows them); `seed`, the learning commit's sha (or null when the seed could not be read); and `section`, the exact
44
47
  * # Learned text to lay into the prompt for those notes (what the old layLearned laid), within the learning budget; and
45
48
  * `seedNotes`, the count of all notes in the seed before the budget picked `given` (present with a read seed; absent when
46
- * the seed could not be read); `skills`, the names of the learned skills the seed offers the run (each active one that
49
+ * the seed could not be read); `notesLeftOut`, the files of the active notes the section names in no way, over the
50
+ * learning budget, which its claim says in the run's log, absent when none; `skills`, the names of the learned skills the seed offers the run (each active one that
47
51
  * fits a run's skill budget at all; its claim lays them), absent when none; `workflows`, the names of the learned
48
52
  * workflows the seed offers its learned_workflow tool (chooseWorkflows), absent when none; `notesOnly`, a run of a
49
53
  * revision that says `learning: "notes"`: given its notes and skills but never a learned workflow, and asked for no
50
54
  * workflow draft at its end; `gradeModel`, the model the
51
55
  * server names to grade what the run proposes (learning.ts gradeModelOf: --grade-model, else AGENTRUN_SERVE_GRADE_MODEL,
52
56
  * else AGENT_MODEL_STRONG), absent when it names none and the agent's own grades it; and `seedFailed`, why it starts with
53
- * nothing learned when it does (SeedFailed). Absent when the run does not learn. */
57
+ * nothing learned when it does (SeedFailed); `use`, a run started with `learning: "use"` (learning.ts RUN_LEARNING_USE):
58
+ * it starts from all of the above and keeps nothing, never asked its end-of-run turn. Absent when the run does not learn. */
54
59
  readonly learning?: {
55
60
  readonly given: readonly {
56
61
  readonly file: string;
@@ -59,11 +64,13 @@ export interface RunLaunch {
59
64
  readonly seed: string | null;
60
65
  readonly section: string;
61
66
  readonly seedNotes?: number;
67
+ readonly notesLeftOut?: readonly string[];
62
68
  readonly skills?: readonly string[];
63
69
  readonly workflows?: readonly string[];
64
70
  readonly notesOnly?: true;
65
71
  readonly gradeModel?: string;
66
72
  readonly seedFailed?: SeedFailed;
73
+ readonly use?: true;
67
74
  };
68
75
  /** The trigger and firing that started the run, or none for a person's run. */
69
76
  readonly trigger?: RunTrigger;
@@ -76,6 +83,11 @@ export interface RunLaunch {
76
83
  * run uses its agent's disk, made at its claim when the agent has none (workspace/run-disk.ts). Kept here so every
77
84
  * claim, revoke and reclaim of the run, after a restart too, acts on that one disk. */
78
85
  readonly archilDisk?: LaunchDisk;
86
+ /** A run started with `hold: true` (computer-held.ts): its computer waits for its owner's start, and stays the owner's
87
+ * after the agent's end until released, each wait for at most `minutes` with no call. */
88
+ readonly hold?: {
89
+ readonly minutes: number;
90
+ };
79
91
  }
80
92
  /** The disk a launch record names, and whose it is. */
81
93
  export interface LaunchDisk {
@@ -46,6 +46,7 @@ export function launchBody(launch) {
46
46
  return {
47
47
  input: launch.input,
48
48
  title: launch.title,
49
+ ...(launch.repo !== undefined ? { repo: launch.repo } : {}),
49
50
  place: launch.place,
50
51
  ...(launch.harness !== undefined ? { harness: launch.harness } : {}),
51
52
  ...(launch.model ? { model: launch.model } : {}),
@@ -58,15 +59,17 @@ export function launchBody(launch) {
58
59
  ...(launch.boxAllow !== undefined ? { box_allow: launch.boxAllow } : {}),
59
60
  ...(launch.boxAllowSet ? { box_allow_set: true } : {}),
60
61
  ...(launch.files?.length ? { files: launch.files } : {}),
61
- ...(launch.learning ? { learning: { given: launch.learning.given.map((note) => ({ file: note.file, name: note.name })), seed: launch.learning.seed, section: launch.learning.section, ...(launch.learning.seedNotes !== undefined ? { seedNotes: launch.learning.seedNotes } : {}), ...(launch.learning.skills?.length ? { skills: [...launch.learning.skills] } : {}), ...(launch.learning.notesOnly ? { notesOnly: true } : {}), ...(launch.learning.workflows?.length ? { workflows: [...launch.learning.workflows] } : {}), ...(launch.learning.gradeModel ? { gradeModel: launch.learning.gradeModel } : {}), ...(launch.learning.seedFailed ? { seedFailed: launch.learning.seedFailed } : {}) } } : {}),
62
+ ...(launch.learning ? { learning: { given: launch.learning.given.map((note) => ({ file: note.file, name: note.name })), seed: launch.learning.seed, section: launch.learning.section, ...(launch.learning.seedNotes !== undefined ? { seedNotes: launch.learning.seedNotes } : {}), ...(launch.learning.notesLeftOut?.length ? { notesLeftOut: [...launch.learning.notesLeftOut] } : {}), ...(launch.learning.skills?.length ? { skills: [...launch.learning.skills] } : {}), ...(launch.learning.notesOnly ? { notesOnly: true } : {}), ...(launch.learning.workflows?.length ? { workflows: [...launch.learning.workflows] } : {}), ...(launch.learning.gradeModel ? { gradeModel: launch.learning.gradeModel } : {}), ...(launch.learning.seedFailed ? { seedFailed: launch.learning.seedFailed } : {}), ...(launch.learning.use ? { use: true } : {}) } } : {}),
62
63
  ...(launch.trigger ? { trigger: launch.trigger } : {}),
63
64
  ...(launch.inputOrigin ? { input_origin: launch.inputOrigin } : {}),
64
65
  ...(launch.followUp ? { follow_up: true } : {}),
65
66
  ...(launch.archilDisk ? { archil_disk: { disk_id: launch.archilDisk.diskId, kind: launch.archilDisk.kind } } : {}),
67
+ ...(launch.hold ? { hold: { minutes: launch.hold.minutes } } : {}),
66
68
  };
67
69
  }
68
70
  /** The learning start a launch body names, as read back: its given notes (each {file, name}), its seed sha, its # Learned
69
- * section text, the learned skills and workflows it was offered, its grade model and why its seed failed, or undefined
71
+ * section text, the learned skills and workflows it was offered, its grade model, why its seed failed and whether it only
72
+ * uses them (`use`), or undefined
70
73
  * when the body names none (a run that does not learn). */
71
74
  function readLearning(value) {
72
75
  if (!isObject(value))
@@ -75,8 +78,8 @@ function readLearning(value) {
75
78
  const seed = typeof value.seed === "string" ? value.seed : null;
76
79
  const section = typeof value.section === "string" ? value.section : "";
77
80
  const names = (list) => (Array.isArray(list) ? list.filter((name) => typeof name === "string") : []);
78
- const [skills, workflows] = [names(value.skills), names(value.workflows)];
79
- return { given, seed, section, ...(typeof value.seedNotes === "number" ? { seedNotes: value.seedNotes } : {}), ...(skills.length ? { skills } : {}), ...(workflows.length ? { workflows } : {}), ...(value.notesOnly === true ? { notesOnly: true } : {}), ...(typeof value.gradeModel === "string" && value.gradeModel !== "" ? { gradeModel: value.gradeModel } : {}), ...(typeof value.seedFailed === "string" && SEED_FAILURES.includes(value.seedFailed) ? { seedFailed: value.seedFailed } : {}) };
81
+ const [skills, workflows, notesLeftOut] = [names(value.skills), names(value.workflows), names(value.notesLeftOut)];
82
+ return { given, seed, section, ...(typeof value.seedNotes === "number" ? { seedNotes: value.seedNotes } : {}), ...(notesLeftOut.length ? { notesLeftOut } : {}), ...(skills.length ? { skills } : {}), ...(workflows.length ? { workflows } : {}), ...(value.notesOnly === true ? { notesOnly: true } : {}), ...(typeof value.gradeModel === "string" && value.gradeModel !== "" ? { gradeModel: value.gradeModel } : {}), ...(typeof value.seedFailed === "string" && SEED_FAILURES.includes(value.seedFailed) ? { seedFailed: value.seedFailed } : {}), ...(value.use === true ? { use: true } : {}) };
80
83
  }
81
84
  /** A launch body read back into a `RunLaunch`, with the input-origin fail-safe applied through the body's own trigger, or
82
85
  * undefined when the body is not one (not an object, or it names no place: a damaged or hand-edited body). */
@@ -94,6 +97,7 @@ export function readLaunchBody(stored) {
94
97
  return {
95
98
  input: stored.input,
96
99
  title: typeof stored.title === "string" ? stored.title : "",
100
+ ...(typeof stored.repo === "string" ? { repo: stored.repo } : {}),
97
101
  place,
98
102
  ...(typeof stored.harness === "string" ? { harness: stored.harness } : {}),
99
103
  ...(model ? { model } : {}),
@@ -111,6 +115,7 @@ export function readLaunchBody(stored) {
111
115
  ...(inputOrigin ? { inputOrigin } : {}),
112
116
  ...(stored.follow_up === true ? { followUp: true } : {}),
113
117
  ...(archilDisk ? { archilDisk } : {}),
118
+ ...(isObject(stored.hold) && typeof stored.hold.minutes === "number" ? { hold: { minutes: stored.hold.minutes } } : {}),
114
119
  };
115
120
  }
116
121
  /** The run's learning start (its given notes, its seed sha and its # Learned section), read from one place by learning's
@@ -53,8 +53,8 @@ export declare function servedRunLearning(deps: {
53
53
  skills?: import("./learning.js").LearnedFile[];
54
54
  workflows?: import("./learning.js").LearnedFile[];
55
55
  run: string;
56
- state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
57
- reason: "cancelled" | "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
56
+ state: "dropped" | "proposed" | "merged" | "seeded" | "reflecting";
57
+ reason: "cancelled" | "use" | "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
58
58
  detail: string | null;
59
59
  at: string;
60
60
  } | null>;
@@ -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 { TimelineEvent } from "./timeline/index.js";
3
3
  import type { IncomingMessage, ServerResponse } from "node:http";
4
4
  import { type Page } from "./rows.js";
@@ -0,0 +1,20 @@
1
+ /** `owner/name`, as github.ts githubTargetOf reads a repository. */
2
+ export declare const REPO_NAME: RegExp;
3
+ /** What an agent's GitHub triggers bind it to: the repositories they name, and whether one takes events from any. */
4
+ export type RepoBinding = {
5
+ readonly repos: readonly string[];
6
+ readonly open: boolean;
7
+ };
8
+ /** `agentId`'s binding, from the triggers (their source and target as stored): none (no repos, not open) for an agent no
9
+ * GitHub trigger starts. */
10
+ export declare function bindingOf(triggers: readonly {
11
+ readonly source: unknown;
12
+ readonly target: unknown;
13
+ }[], agentId: string): RepoBinding;
14
+ /** The repository a manual start runs against: `named` (the body's `repo`) when it is one the agent is bound to, else the
15
+ * agent's one repository when `named` is absent and the first message names none (`words`: it names its own). Undefined
16
+ * when the run is to have none. `refused`: why a named one is not allowed, in words for the 422. */
17
+ export declare function repoOf(binding: RepoBinding, named: string | undefined, words: boolean): {
18
+ repo?: string;
19
+ refused?: string;
20
+ };