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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (312) hide show
  1. package/CHANGELOG.md +281 -0
  2. package/README.md +246 -66
  3. package/dist/acp-package.d.ts +2 -0
  4. package/dist/adapters.d.ts +15 -3
  5. package/dist/adapters.js +17 -6
  6. package/dist/agent-package.d.ts +3 -3
  7. package/dist/agent-package.js +17 -8
  8. package/dist/api-keys.d.ts +76 -0
  9. package/dist/api-keys.js +217 -0
  10. package/dist/api-only.d.ts +15 -5
  11. package/dist/api-only.js +32 -8
  12. package/dist/box-paths.d.ts +4 -3
  13. package/dist/box-paths.js +7 -4
  14. package/dist/browser-hold.d.ts +23 -0
  15. package/dist/browser-hold.js +48 -0
  16. package/dist/browser-person.d.ts +3 -0
  17. package/dist/browser-person.js +4 -1
  18. package/dist/chatgpt-plan.d.ts +18 -8
  19. package/dist/chatgpt-plan.js +91 -34
  20. package/dist/claude-login-token.d.ts +117 -0
  21. package/dist/claude-login-token.js +737 -0
  22. package/dist/claude-login.d.ts +120 -22
  23. package/dist/claude-login.js +347 -63
  24. package/dist/claude-sign-in.d.ts +17 -6
  25. package/dist/claude-sign-in.js +42 -39
  26. package/dist/cli.js +33 -10
  27. package/dist/composio-made.d.ts +4 -0
  28. package/dist/composio-made.js +4 -0
  29. package/dist/composio-preset.d.ts +43 -2
  30. package/dist/composio-preset.js +92 -4
  31. package/dist/computer-attach.d.ts +35 -17
  32. package/dist/computer-attach.js +301 -49
  33. package/dist/computer-held-routes.d.ts +5 -4
  34. package/dist/computer-held-routes.js +29 -8
  35. package/dist/computer-held.d.ts +6 -1
  36. package/dist/computer-held.js +14 -0
  37. package/dist/computer-record.js +4 -2
  38. package/dist/computer-viewer.js +4 -1
  39. package/dist/computers.d.ts +10 -10
  40. package/dist/computers.js +5 -5
  41. package/dist/console/assets/{backend-Boh7tC4i.js → backend-CSAWUqtZ.js} +19 -19
  42. package/dist/console/assets/index-Bwn1oTem.css +1 -0
  43. package/dist/console/assets/index-DPh29cyz.js +747 -0
  44. package/dist/console/index.html +2 -2
  45. package/dist/decisions.d.ts +1 -1
  46. package/dist/decisions.js +1 -1
  47. package/dist/dial-relay.d.ts +25 -4
  48. package/dist/dial-relay.js +129 -1
  49. package/dist/docker-host-addresses.d.ts +22 -11
  50. package/dist/docker-host-addresses.js +38 -26
  51. package/dist/env-switch.d.ts +8 -0
  52. package/dist/env-switch.js +31 -2
  53. package/dist/errors.d.ts +1 -0
  54. package/dist/errors.js +2 -0
  55. package/dist/fal-price.d.ts +56 -20
  56. package/dist/fal-price.js +400 -90
  57. package/dist/handed-values.d.ts +43 -1
  58. package/dist/handed-values.js +119 -2
  59. package/dist/harness-archive.d.ts +13 -10
  60. package/dist/harness-archive.js +60 -34
  61. package/dist/harness-check.d.ts +3 -1
  62. package/dist/harness-check.js +25 -46
  63. package/dist/harness-keys.d.ts +73 -27
  64. package/dist/harness-keys.js +194 -61
  65. package/dist/harness-recipe-entry.d.ts +8 -7
  66. package/dist/harness-recipe-entry.js +21 -32
  67. package/dist/harness-recipe.d.ts +38 -25
  68. package/dist/harness-recipe.js +49 -36
  69. package/dist/harness-sign-in.js +12 -23
  70. package/dist/harness-table.d.ts +10 -3
  71. package/dist/harness-table.js +26 -21
  72. package/dist/harness.d.ts +1 -0
  73. package/dist/harness.js +17 -5
  74. package/dist/hosted-search.d.ts +1 -1
  75. package/dist/hosted-search.js +1 -2
  76. package/dist/import-worker.d.ts +4 -2
  77. package/dist/import-worker.js +9 -2
  78. package/dist/in-flight.d.ts +26 -0
  79. package/dist/in-flight.js +52 -0
  80. package/dist/key-refusal.d.ts +9 -4
  81. package/dist/key-refusal.js +107 -25
  82. package/dist/learn/ledger.d.ts +170 -0
  83. package/dist/learn/ledger.js +218 -0
  84. package/dist/learn/promote.d.ts +3 -3
  85. package/dist/learn/promote.js +1 -1
  86. package/dist/learn/secrets.d.ts +13 -3
  87. package/dist/learn/secrets.js +118 -17
  88. package/dist/learning-cost.d.ts +28 -23
  89. package/dist/learning-cost.js +19 -23
  90. package/dist/link-check.js +1 -1
  91. package/dist/live-reach.d.ts +2 -0
  92. package/dist/live-reach.js +2 -0
  93. package/dist/llms.txt +1 -1
  94. package/dist/marketplace.d.ts +77 -0
  95. package/dist/marketplace.js +224 -0
  96. package/dist/mcp-api-only-origins.d.ts +35 -0
  97. package/dist/mcp-api-only-origins.js +57 -0
  98. package/dist/mcp-gateway.d.ts +7 -5
  99. package/dist/mcp-gateway.js +9 -12
  100. package/dist/mcp-secret-writes.js +5 -3
  101. package/dist/mcp-servers-store.d.ts +28 -6
  102. package/dist/mcp-servers-store.js +53 -4
  103. package/dist/media-duration.d.ts +3 -0
  104. package/dist/media-duration.js +90 -9
  105. package/dist/micro.d.ts +2 -0
  106. package/dist/micro.js +2 -0
  107. package/dist/model-form.d.ts +5 -4
  108. package/dist/model-form.js +11 -7
  109. package/dist/model.d.ts +10 -6
  110. package/dist/model.js +16 -11
  111. package/dist/monid.d.ts +14 -1
  112. package/dist/monid.js +103 -26
  113. package/dist/ollama-provider.d.ts +7 -1
  114. package/dist/ollama-provider.js +14 -2
  115. package/dist/openapi.js +210 -37
  116. package/dist/otel/genai.d.ts +65 -0
  117. package/dist/otel/genai.js +116 -0
  118. package/dist/otel/tracer.d.ts +55 -0
  119. package/dist/otel/tracer.js +308 -0
  120. package/dist/page.d.ts +2 -0
  121. package/dist/page.js +3 -1
  122. package/dist/paid-calls.d.ts +1 -32
  123. package/dist/paid-calls.js +4 -39
  124. package/dist/place-offers.d.ts +4 -0
  125. package/dist/place-offers.js +7 -4
  126. package/dist/provider.d.ts +11 -2
  127. package/dist/provider.js +59 -8
  128. package/dist/redact/match.d.ts +30 -3
  129. package/dist/redact/match.js +422 -41
  130. package/dist/refusal-words.d.ts +11 -0
  131. package/dist/refusal-words.js +11 -0
  132. package/dist/run-census.d.ts +67 -0
  133. package/dist/run-census.js +240 -0
  134. package/dist/run-computer.d.ts +6 -3
  135. package/dist/run-computer.js +4 -1
  136. package/dist/run-cut.d.ts +15 -6
  137. package/dist/run-cut.js +30 -9
  138. package/dist/run-files.d.ts +3 -0
  139. package/dist/run-files.js +3 -0
  140. package/dist/run-launch.d.ts +12 -1
  141. package/dist/run-launch.js +9 -10
  142. package/dist/run-learning-served.d.ts +4 -2
  143. package/dist/run-model-key.d.ts +8 -0
  144. package/dist/run-model-key.js +31 -1
  145. package/dist/run-reads-over-store.d.ts +24 -6
  146. package/dist/run-reads-over-store.js +67 -23
  147. package/dist/run-recordings.d.ts +5 -1
  148. package/dist/run-recordings.js +39 -14
  149. package/dist/run-timeline-served.d.ts +2 -0
  150. package/dist/run-timeline-served.js +2 -2
  151. package/dist/run-usage.d.ts +1 -0
  152. package/dist/run-view.d.ts +1 -2
  153. package/dist/run-view.js +2 -1
  154. package/dist/runnable.d.ts +10 -1
  155. package/dist/runnable.js +20 -8
  156. package/dist/runner/adapter-loop.d.ts +11 -0
  157. package/dist/runner/adapter-loop.js +58 -26
  158. package/dist/runner/adapter-run-spec.d.ts +55 -11
  159. package/dist/runner/adapter-run-spec.js +183 -52
  160. package/dist/runner/adapters/pi.js +25 -3
  161. package/dist/runner/beside.d.ts +9 -2
  162. package/dist/runner/beside.js +27 -9
  163. package/dist/runner/big-writes.js +1 -10
  164. package/dist/runner/claim-secrets.d.ts +27 -10
  165. package/dist/runner/claim-secrets.js +49 -22
  166. package/dist/runner/cli-run-spec.d.ts +6 -0
  167. package/dist/runner/cli-run-spec.js +97 -38
  168. package/dist/runner/computer-journal.d.ts +9 -1
  169. package/dist/runner/computer-journal.js +26 -0
  170. package/dist/runner/conformance/harness.js +1 -1
  171. package/dist/runner/feedback-round.js +3 -0
  172. package/dist/runner/harness-loops.d.ts +6 -5
  173. package/dist/runner/harness-loops.js +7 -7
  174. package/dist/runner/held.d.ts +24 -6
  175. package/dist/runner/journal-kinds.d.ts +5 -0
  176. package/dist/runner/journal-kinds.js +5 -0
  177. package/dist/runner/main.d.ts +11 -6
  178. package/dist/runner/main.js +19 -9
  179. package/dist/runner/mcp-claim.js +31 -3
  180. package/dist/runner/mcp-run.d.ts +9 -0
  181. package/dist/runner/mcp-run.js +11 -5
  182. package/dist/runner/model-route.d.ts +17 -0
  183. package/dist/runner/model-route.js +120 -2
  184. package/dist/runner/presence.d.ts +11 -1
  185. package/dist/runner/presence.js +7 -0
  186. package/dist/runner/reflect-hook.js +1 -1
  187. package/dist/runner/run-child-host.d.ts +22 -8
  188. package/dist/runner/run-child-host.js +128 -41
  189. package/dist/runner/run-child.js +5 -2
  190. package/dist/runner/runner.d.ts +17 -3
  191. package/dist/runner/runner.js +130 -34
  192. package/dist/runner/save-slots.js +2 -1
  193. package/dist/runner/store-port.d.ts +1 -1
  194. package/dist/runner/store-secrets.d.ts +6 -0
  195. package/dist/runner/store-secrets.js +49 -7
  196. package/dist/runner/subagent.d.ts +11 -0
  197. package/dist/runner/subagent.js +16 -38
  198. package/dist/runner/workflow-first.d.ts +35 -15
  199. package/dist/runner/workflow-first.js +38 -25
  200. package/dist/runner/workflow-spec.js +4 -3
  201. package/dist/runs-over-store.d.ts +15 -6
  202. package/dist/runs-over-store.js +33 -21
  203. package/dist/scrub-command.d.ts +73 -0
  204. package/dist/scrub-command.js +307 -0
  205. package/dist/secret-cut.d.ts +73 -0
  206. package/dist/secret-cut.js +291 -4
  207. package/dist/secret-rules.d.ts +143 -0
  208. package/dist/secret-rules.js +2564 -0
  209. package/dist/secrets.d.ts +7 -0
  210. package/dist/secrets.js +20 -0
  211. package/dist/server-keys.d.ts +20 -0
  212. package/dist/server-keys.js +25 -6
  213. package/dist/server.d.ts +65 -13
  214. package/dist/server.js +470 -157
  215. package/dist/skills/agentrun-serve/SKILL.md +4 -0
  216. package/dist/slots.d.ts +9 -0
  217. package/dist/slots.js +45 -0
  218. package/dist/store/index.d.ts +1 -1
  219. package/dist/store/index.js +1 -1
  220. package/dist/store/journal/storage.js +1 -1
  221. package/dist/store/postgres/migrations/0027_run_launch_census.sql +31 -0
  222. package/dist/store/postgres/migrations/0028_learning_ledger.sql +44 -0
  223. package/dist/store/schema.d.ts +23 -0
  224. package/dist/store/schema.js +58 -2
  225. package/dist/store/seal.d.ts +6 -1
  226. package/dist/store/seal.js +5 -3
  227. package/dist/store/sqlite/run-launch.d.ts +9 -1
  228. package/dist/store/sqlite/run-launch.js +24 -13
  229. package/dist/store/sqlite/run-patch.d.ts +12 -2
  230. package/dist/store/sqlite/run-patch.js +42 -5
  231. package/dist/store/sqlite/store.js +105 -12
  232. package/dist/store/store.d.ts +57 -2
  233. package/dist/store/store.js +20 -0
  234. package/dist/store-reads/learning.d.ts +84 -124
  235. package/dist/store-reads/learning.js +210 -274
  236. package/dist/store-view.d.ts +3 -0
  237. package/dist/store-view.js +3 -3
  238. package/dist/suggestions.js +3 -2
  239. package/dist/template-eval.d.ts +39 -9
  240. package/dist/template-eval.js +191 -60
  241. package/dist/template-import.js +6 -2
  242. package/dist/templates.d.ts +10 -2
  243. package/dist/templates.js +28 -8
  244. package/dist/timeline/labels.d.ts +6 -4
  245. package/dist/timeline/labels.js +18 -6
  246. package/dist/timeline/timeline.d.ts +5 -0
  247. package/dist/timeline/timeline.js +14 -8
  248. package/dist/timeline/util.js +1 -1
  249. package/dist/timeline/web-calls.d.ts +22 -7
  250. package/dist/timeline/web-calls.js +106 -35
  251. package/dist/tool-gate.d.ts +42 -3
  252. package/dist/tool-gate.js +66 -5
  253. package/dist/tool-keys-store.d.ts +2 -4
  254. package/dist/tool-keys-store.js +5 -21
  255. package/dist/tool-keys.d.ts +2 -2
  256. package/dist/tool-keys.js +2 -2
  257. package/dist/tool-list.js +1 -1
  258. package/dist/tool-plane.d.ts +2 -2
  259. package/dist/tool-plane.js +35 -33
  260. package/dist/tools.js +13 -7
  261. package/dist/trigger-targets.d.ts +4 -0
  262. package/dist/trigger-targets.js +9 -2
  263. package/dist/triggers.d.ts +67 -4
  264. package/dist/triggers.js +171 -22
  265. package/dist/until.d.ts +3 -0
  266. package/dist/until.js +11 -0
  267. package/dist/web-fake.d.ts +1 -3
  268. package/dist/web-fake.js +7 -18
  269. package/dist/web-fetch.d.ts +6 -72
  270. package/dist/web-fetch.js +11 -265
  271. package/dist/web-run.d.ts +31 -0
  272. package/dist/web-run.js +90 -0
  273. package/dist/web-save.d.ts +10 -13
  274. package/dist/web-save.js +13 -55
  275. package/dist/web-search.d.ts +9 -127
  276. package/dist/web-search.js +23 -259
  277. package/dist/wires.d.ts +13 -0
  278. package/dist/wires.js +11 -0
  279. package/dist/workflow-run.d.ts +5 -4
  280. package/dist/workflow-run.js +5 -4
  281. package/dist/workspace/attached-computers.d.ts +32 -9
  282. package/dist/workspace/attached-computers.js +77 -13
  283. package/dist/workspace/computer-deps.d.ts +8 -2
  284. package/dist/workspace/computer-deps.js +10 -3
  285. package/dist/workspace/computer-for-claim.d.ts +12 -1
  286. package/dist/workspace/computer-for-claim.js +83 -11
  287. package/dist/workspace/computer-kept.d.ts +3 -0
  288. package/dist/workspace/computer-kept.js +11 -2
  289. package/dist/workspace/index.d.ts +1 -1
  290. package/dist/workspace/index.js +1 -1
  291. package/dist/workspace/kind-skills.d.ts +4 -0
  292. package/dist/workspace/kind-skills.js +9 -0
  293. package/dist/workspace/paired-route.d.ts +91 -0
  294. package/dist/workspace/paired-route.js +153 -0
  295. package/dist/workspace/synced-folder.js +3 -4
  296. package/dist/wrapped.d.ts +20 -6
  297. package/dist/wrapped.js +66 -25
  298. package/package.json +17 -11
  299. package/skills/agentrun-serve/SKILL.md +4 -0
  300. package/templates/README.md +32 -10
  301. package/dist/console/assets/index-CQ3cJRzI.js +0 -746
  302. package/dist/console/assets/index-DKkaS3a0.css +0 -1
  303. package/dist/exa-keyless.d.ts +0 -34
  304. package/dist/exa-keyless.js +0 -118
  305. package/dist/firecrawl-keyless.d.ts +0 -41
  306. package/dist/firecrawl-keyless.js +0 -152
  307. package/dist/keyless-mcp.d.ts +0 -36
  308. package/dist/keyless-mcp.js +0 -127
  309. package/dist/text-urls.d.ts +0 -38
  310. package/dist/text-urls.js +0 -170
  311. package/dist/web-fetch-direct.d.ts +0 -119
  312. package/dist/web-fetch-direct.js +0 -190
@@ -9,14 +9,16 @@
9
9
  //
10
10
  // They are the owner's: the server's token or the owner's session. A run never holds the server's token (runner/main.ts
11
11
  // RUNNER_ONLY), so no run's agent reaches its own computer this way: it drives it through its tools.
12
+ import { browserHeld } from "./browser-hold.js";
12
13
  import { callComputer, callIssues, sendRow, TAKE_MS } from "./computer-channel.js";
13
14
  import { computerHoldOf, entriesOf, runOver } from "./computer-commands.js";
14
- import { COMPUTER_RELEASE, COMPUTER_START, heldIn, holdIssues } from "./computer-held.js";
15
+ import { COMPUTER_RELEASE, COMPUTER_START, heldIn, heldRefused, holdIssues } from "./computer-held.js";
15
16
  import { settingOfDefinition } from "./computer-setting.js";
16
17
  import { ApiError, invalid } from "./errors.js";
17
18
  import { runComputerField } from "./run-computer.js";
18
19
  import { readLaunchBody } from "./run-launch.js";
19
20
  import { unknownFields } from "./validate.js";
21
+ import { readKept } from "./workspace/computer-kept.js";
20
22
  export { holdIssues };
21
23
  /** The routes' names in serve's route table. */
22
24
  export const HELD_ROUTES = new Set(["startRun", "callRunComputer", "releaseRunComputer"]);
@@ -37,9 +39,17 @@ export async function heldField(store, runId, options = {}) {
37
39
  const state = read.state !== "released" && (await runOver(store, runId)) ? "released" : read.state;
38
40
  return { state, minutes: read.minutes, ...(state === "released" ? {} : { until: new Date(read.until).toISOString() }), ...(read.why ? { why: read.why } : {}) };
39
41
  }
42
+ /** Whether parked run `runId`'s computer of `kind` was let go: a park's claim releases it but for a desktop, a phone or a
43
+ * sandbox kept for the resume, until its keep's time (workspace/computer-kept.ts). A browser's is said on its own read. */
44
+ async function releasedAtPark(store, runId, kind, now) {
45
+ if (kind === "browser")
46
+ return false;
47
+ const kept = await readKept(store.settings, runId).catch(() => undefined);
48
+ return !kept || kept.kind !== kind || kept.ended === true || kept.ending === true || now >= kept.until;
49
+ }
40
50
  /** The run read's `computer` field (`{ computer }`, or nothing for a run with none): its revision's computer setting, else
41
- * the one its place says; taken_over while the owner holds its desktop or phone (computerHoldOf, read from the run's
42
- * journal only while that computer is up); with `held` for a run that holds its computer for its owner. The journal is
51
+ * the one its place says; released once a stop let it go, or while the run is parked with it let go (releasedAtPark); taken_over while the owner holds its desktop or phone (computerHoldOf, read from the run's
52
+ * journal only while that computer is up) or its browser (browserHeld, one settings read while it is up); with `held` for a run that holds its computer for its owner. The journal is
43
53
  * read at most once, and not at all for a run that neither can be taken over nor holds. `view` is the run read so far. */
44
54
  export async function runComputerRead(store, runId, view, options = {}) {
45
55
  const run = await store.runs.get(runId);
@@ -47,14 +57,19 @@ export async function runComputerRead(store, runId, view, options = {}) {
47
57
  if (!setting)
48
58
  return {};
49
59
  const error = view.error;
50
- const read = { id: runId, status: String(view.status), ...(error && typeof error.code === "string" ? { error: { code: error.code, message: String(error.message ?? "") } } : {}) };
60
+ // A stop lets the run's computer go (the run's row is final until a follow-up queues it again); a park keeps a desktop,
61
+ // a phone or a sandbox only for its keep's time.
62
+ const released = run?.state === "stopped" || (run?.state === "parked" && (await releasedAtPark(store, runId, setting.kind, options.now?.() ?? Date.now())));
63
+ const read = { id: runId, status: String(view.status), ...(error && typeof error.code === "string" ? { error: { code: error.code, message: String(error.message ?? "") } } : {}), ...(released ? { released } : {}) };
51
64
  // The run's journal, read at most once for the whole field (the hold and `held` both read it), and only when one needs
52
65
  // it: a long run's every poll would pay for a read that grows with it.
53
66
  let journal;
54
67
  const once = { ...options, entries: () => (journal ??= entriesOf(store, runId, options)) };
55
- // Who drives: only a desktop or a phone is taken over (a sandbox or a browser never is here), and only while it is up.
68
+ // Who drives, only while the computer is up: a desktop's or a phone's hold from the run's journal; a browser's from the
69
+ // one row its live view's take keeps (browser-hold.ts); a sandbox is never taken over.
56
70
  const takeable = setting.kind === "desktop" || setting.kind === "phone";
57
- const hold = takeable && runComputerField(setting, read)?.state === "ready" ? await computerHoldOf(store, runId, once) : "agent";
71
+ const up = runComputerField(setting, read)?.state === "ready";
72
+ const hold = !up ? "agent" : takeable ? await computerHoldOf(store, runId, once) : setting.kind === "browser" && (await browserHeld(store.settings, runId)) ? "person" : "agent";
58
73
  const field = runComputerField(setting, read, (_, state) => (hold === "person" ? "taken_over" : state));
59
74
  if (!field)
60
75
  return {};
@@ -73,7 +88,8 @@ function fieldsOf(body) {
73
88
  * - callRunComputer: the channel's answer (callComputer), the computer's own: `{ ok: true, value }` or `{ ok: false,
74
89
  * error }`. 422 for a method the protocol does not have.
75
90
  * - startRun, releaseRunComputer: 404 for a run that holds no computer, and for a release of one already let go; 409
76
- * computer_not_live when the hold is not where the route needs it (not up yet, already started, released).
91
+ * computer_not_live when the hold is not where the route needs it (not up yet, already started, released). A start of a
92
+ * run whose model kept it from running at its create: 409 agent_not_runnable, in its create's words (hold.refused).
77
93
  * Either: 503 when the runner took no row in time.
78
94
  */
79
95
  export async function heldRoute(name, runId, body, store, options = {}) {
@@ -87,8 +103,13 @@ export async function heldRoute(name, runId, body, store, options = {}) {
87
103
  const issues = unknownFields(fields, []);
88
104
  if (issues.length)
89
105
  throw invalid(issues);
90
- if (!(await holdOfRun(store, runId)))
106
+ const hold = await holdOfRun(store, runId);
107
+ if (!hold)
91
108
  throw new ApiError("not_found", `run ${runId} holds no computer: a run started with hold: true holds one`);
109
+ // Its model kept it from running at its create: its agent never starts, in the words its create would have said, and
110
+ // nothing is sent, so its computer still takes calls and its release (computer-held.ts).
111
+ if (name === "startRun" && hold.refused)
112
+ throw heldRefused(hold.refused);
92
113
  const read = heldIn(await entriesOf(store, runId, options));
93
114
  const over = await runOver(store, runId);
94
115
  if (name === "releaseRunComputer" && (over || read?.state === "released"))
@@ -1,6 +1,7 @@
1
1
  import type { JournalEntry } from "./computer-commands.js";
2
2
  import type { ComputerKind } from "./computer-setting.js";
3
- import type { InputIssue } from "./errors.js";
3
+ import { ApiError, type InputIssue } from "./errors.js";
4
+ import type { HeldRefusal } from "./run-launch.js";
4
5
  /** The journal entry kind the runner commits for each change of the hold. */
5
6
  export declare const HELD_KIND = "computer.held";
6
7
  /** The command row kinds the server writes. */
@@ -21,6 +22,10 @@ export declare function holdIssues(body: Record<string, unknown>): InputIssue[];
21
22
  export declare function holdOf(body: Record<string, unknown>, kind: ComputerKind): {
22
23
  minutes: number;
23
24
  } | InputIssue | undefined;
25
+ /** The refusal of a held run whose model kept it from running when it was created (run-launch.ts hold.refused), for its
26
+ * start and every message: 409 agent_not_runnable, in the words, fields and details its create would have answered.
27
+ * Read from its launch, never checked again: a key saved since runs a new run, never this one. */
28
+ export declare const heldRefused: (refused: HeldRefusal) => ApiError;
24
29
  /** Where a held computer is. */
25
30
  export type HeldState = "waiting" | "started" | "ended" | "released";
26
31
  export declare const HELD_STATES: readonly HeldState[];
@@ -9,6 +9,15 @@
9
9
  // the run keeps its computer until the release or the lapse, then ends stopped. A cancel ends the run and lets the
10
10
  // computer go at once.
11
11
  //
12
+ // A held run's create does not refuse it for its model (no key for it here, its harness refusing it or lacking only a
13
+ // model key here, no price under a cap): a benchmark that only calls the computer and lets it go never needs one. Those words ride its launch (hold.refused),
14
+ // and its start and every message are refused in them (heldRefused), so its agent never runs; its computer still takes
15
+ // calls until the release or the lapse. On pi and on every CLI harness, its model's route chooses no model and reads no
16
+ // key: its provider is a stand-in that refuses every model request in those words, sending none (provider.ts
17
+ // heldRefusedProvider), so a host with no key for it holds the computer all the same. Its claim lays only the keys any
18
+ // claim of the run lays (its tools', a key handed with it), in a run's own process too (run-child-host.ts: no model key,
19
+ // no saved gateway key), routes no subagent tier and takes no learning step. Every other blocker still refuses the create.
20
+ //
12
21
  // Like the take-over (computer-commands.ts), it runs over the one store: the server writes command rows, the run's
13
22
  // runner applies them to the computer it holds (runner/held-run.ts), and commits what came of each to the run's journal.
14
23
  // The server reads the journal, never anything in its own memory.
@@ -20,6 +29,7 @@
20
29
  // computer.call (the channel's, computer-channel.ts): each owner call starts the hold's `minutes` again from its `at`.
21
30
  // The rows: computer_start `{}`, computer_release `{}`.
22
31
  import { CALL_KIND } from "./computer-channel.js";
32
+ import { ApiError } from "./errors.js";
23
33
  /** The journal entry kind the runner commits for each change of the hold. */
24
34
  export const HELD_KIND = "computer.held";
25
35
  /** The command row kinds the server writes. */
@@ -58,6 +68,10 @@ export function holdOf(body, kind) {
58
68
  }
59
69
  return { minutes: typeof body.hold_minutes === "number" ? body.hold_minutes : HOLD_MINUTES };
60
70
  }
71
+ /** The refusal of a held run whose model kept it from running when it was created (run-launch.ts hold.refused), for its
72
+ * start and every message: 409 agent_not_runnable, in the words, fields and details its create would have answered.
73
+ * Read from its launch, never checked again: a key saved since runs a new run, never this one. */
74
+ export const heldRefused = (refused) => new ApiError("agent_not_runnable", refused.message, { fields: [...refused.fields], details: { ...refused.details } });
61
75
  export const HELD_STATES = ["waiting", "started", "ended", "released"];
62
76
  const dataOf = (entry) => (entry.data && typeof entry.data === "object" ? entry.data : {});
63
77
  /** The run's hold, from its journal: undefined until its computer first came up held. */
@@ -71,7 +71,8 @@ const fitted = (width, height, edge) => {
71
71
  return [even(width), even(height)];
72
72
  };
73
73
  /** ffmpeg's arguments for one file: `format` frames piped in, each stamped as it is read (in ms), fitted into
74
- * width x height, H.264 at the frames' own times, a key frame every 2 s at most apart, fragmented MP4. The file is on disk
74
+ * width x height, H.264 at the frames' own times, a key frame every 2 s at most apart, fragmented MP4 whose header says
75
+ * when it started (its mvhd's creation time, which run-recordings.ts orders a run's computers by). The file is on disk
75
76
  * as it goes, a fragment at each key frame (run-recordings.ts reads it mid-run): the input is not probed (a quiet screen's
76
77
  * few frames would never fill ffmpeg's 5 MB probe), it is decoded on one thread (the PNG decoder's frame threads hold one
77
78
  * frame per core back), and each fragment is flushed as it is written. */
@@ -80,7 +81,8 @@ const argsOf = (format, width, height, path) => [
80
81
  "-probesize", "32", "-analyzeduration", "0", "-fpsprobesize", "0", "-threads", "1", "-use_wallclock_as_timestamps", "1", "-framerate", "1000", "-f", "image2pipe", "-c:v", format === "png" ? "png" : "mjpeg", "-i", "pipe:0",
81
82
  "-an", "-vf", `scale=${width}:${height}:force_original_aspect_ratio=decrease,pad=${width}:${height}:(ow-iw)/2:(oh-ih)/2,format=yuv420p`,
82
83
  "-fps_mode", "vfr", "-c:v", "libx264", "-preset", "veryfast", "-tune", "zerolatency", "-crf", "28",
83
- "-force_key_frames", "expr:gte(t,n_forced*2)", "-movflags", "+frag_keyframe+empty_moov+default_base_moof", "-flush_packets", "1", "-f", "mp4", "-n", path,
84
+ "-force_key_frames", "expr:gte(t,n_forced*2)", "-movflags", "+frag_keyframe+empty_moov+default_base_moof", "-flush_packets", "1",
85
+ "-metadata", `creation_time=${new Date().toISOString()}`, "-f", "mp4", "-n", path,
84
86
  ];
85
87
  /** A length in words: "2 h", "90 min", "45 s". */
86
88
  const lengthWords = (ms) => (ms >= 3_600_000 && ms % 3_600_000 === 0 ? `${ms / 3_600_000} h` : ms >= 60_000 && ms % 60_000 === 0 ? `${ms / 60_000} min` : `${Math.round(ms / 1000)} s`);
@@ -179,7 +179,8 @@ const js = `"use strict";
179
179
  ready = true; kind = m.kind; input = m.input; holding = m.held === true;
180
180
  $("phone").hidden = kind !== "phone";
181
181
  document.body.dataset.kind = kind;
182
- showHands(); setDrive(m.drive); say(""); focusScreen();
182
+ // Focus comes in only for a person who holds the computer: the page that frames the viewer keeps its own otherwise.
183
+ showHands(); setDrive(m.drive); say(""); if (holding) focusScreen();
183
184
  }
184
185
  else if (m.type === "hold") {
185
186
  holding = m.held === true;
@@ -273,6 +274,8 @@ const js = `"use strict";
273
274
  var justComposed = null;
274
275
  function onKeyDown(e) {
275
276
  justComposed = null;
277
+ // Tab is the computer's only while the person holds it; else it moves the focus on, out of the viewer.
278
+ if (e.key === "Tab" && !holding) return;
276
279
  if (e.isComposing || e.keyCode === 229 || e.key === "Dead") return;
277
280
  if ((e.ctrlKey || e.metaKey) && (e.key === "v" || e.key === "V")) return;
278
281
  e.preventDefault();
@@ -41,20 +41,20 @@ export interface ComputerRoutesOptions {
41
41
  /** Whether a provider that binds a folder of this machine (Docker) answers here now, or why not (the server's daemon
42
42
  * check, docker-daemon.ts, which keeps its answer a while). Absent: taken as answering. */
43
43
  readonly answers?: (provider: string) => Promise<DockerDaemon>;
44
- /** The person's own computers paired with this server (computer-attach.ts): the store's rows and each one's view.
45
- * Each is one more provider of its kind (attached-computers.ts pairedEntry), ready while it is attached. Absent:
46
- * none. */
44
+ /** The person's own computers paired with this server (computer-attach.ts): the store's rows and each one's view, with
45
+ * its runs_refused as this module reads it. Each is one more provider of its kind (attached-computers.ts pairedEntry),
46
+ * ready while it is attached. Absent: none. */
47
47
  readonly paired?: {
48
48
  rows(): Promise<readonly PairedComputerRow[]>;
49
- viewOf(row: PairedComputerRow, serves: readonly ComputerSettingKind[]): PairedView;
49
+ viewOf(row: PairedComputerRow, serves: readonly ComputerSettingKind[], runsRefused: string | null): Promise<PairedView>;
50
50
  };
51
- /** No runner in this server's process (ServeOptions.runnerApart): no run here can use a computer whose socket the
52
- * server's attach hub takes, a paired computer's or a dial provider's machine's. Each such provider's row says so
53
- * (runs_refused), and a dial provider's test fails in those words. */
51
+ /** No runner in this server's process (ServeOptions.runnerApart): while no runner relays (`relayed`), no run here can
52
+ * use a computer whose socket the server's attach hub takes, a paired computer's or a dial provider's machine's. Each
53
+ * such provider's row says so (runs_refused), and a dial provider's test fails in those words. */
54
54
  readonly runnerApart?: boolean;
55
- /** Whether a runner in a process of its own relays its dials now (dial-relay.ts): its machines dial this server, which
56
- * relays each socket to it, so a dial provider's runs can use it and its row says nothing. Read once per view and per
57
- * test. Absent: none does. A paired computer's socket is never relayed. */
55
+ /** Whether a runner in a process of its own relays now (dial-relay.ts): a dial provider's machines and a paired
56
+ * computer dial this server, which relays each socket to the runner that holds its run, so their runs can use them and
57
+ * their rows say nothing. Read once per view and per test. Absent: none does. */
58
58
  readonly relayed?: () => Promise<boolean>;
59
59
  }
60
60
  /** A provider as Settings shows it: `metered` straight from the kind registry (its computers are billed by the vendor);
package/dist/computers.js CHANGED
@@ -133,9 +133,9 @@ export function createComputerRoutes(options) {
133
133
  const modeNow = async () => (typeof options.mode === "function" ? options.mode() : options.mode);
134
134
  /** Why no run here can use `provider`'s computers, on a server whose runner runs in a process of its own: its machines
135
135
  * dial this server (connectOf, with the connect its settings give), or it is a paired computer (`paired`), so the
136
- * server's attach hub takes its socket, which the runner never reaches. A dial provider's machine reaches a runner
137
- * that relays its dials (`relayed`, read by relaysNow), so it is null there. Null where its runs can use it. */
138
- const runsRefused = (provider, relays, paired = false) => options.runnerApart !== true ? null : paired ? RUNNER_APART_WORDS : !relays && connectOf(provider, settingOptions(provider.id, settings, keyTable)) === "dial" ? dialApartWords(provider.label) : null;
136
+ * server's attach hub takes its socket, which the runner never reaches. Either reaches a runner that relays
137
+ * (`relayed`, read by relaysNow), so it is null there. Null where its runs can use it. */
138
+ const runsRefused = (provider, relays, paired = false) => options.runnerApart !== true || relays ? null : paired ? RUNNER_APART_WORDS : connectOf(provider, settingOptions(provider.id, settings, keyTable)) === "dial" ? dialApartWords(provider.label) : null;
139
139
  const relaysNow = async () => options.runnerApart === true && options.relayed !== undefined && (await options.relayed());
140
140
  /** Why a computer of `kind` on `provider` can't be had for its daemon (a provider that binds a folder of this machine,
141
141
  * `said` its answer, in folder `mode`): none answering is the one wording (docker-daemon.ts noDockerWords); else its
@@ -148,10 +148,10 @@ export function createComputerRoutes(options) {
148
148
  // The paired computers, each one more provider of its kind; one not attached now is not ready, saying so.
149
149
  const rows = options.paired ? await options.paired.rows() : [];
150
150
  const listed = withPaired(options.kinds, rows);
151
- const paired = rows.map((row) => options.paired.viewOf(row, listed.PROVIDERS.find((provider) => provider.id === row.id)?.kinds ?? []));
151
+ const relays = await relaysNow();
152
+ const paired = await Promise.all(rows.map((row) => options.paired.viewOf(row, listed.PROVIDERS.find((provider) => provider.id === row.id)?.kinds ?? [], runsRefused({ id: row.id, label: row.name }, relays, true))));
152
153
  const offline = new Map(rows.flatMap((row, at) => (paired[at].online ? [] : [[row.id, `${row.name} is not attached now: open its driver on that computer, which dials this server`]])));
153
154
  const pairedIds = new Set(rows.map((row) => row.id));
154
- const relays = await relaysNow();
155
155
  // Every provider's keys in one read: each a SecretMeta named for its provider, set by the environment or the store row
156
156
  // of its key's name.
157
157
  const slots = listed.PROVIDERS.flatMap((provider) => provider.keys.map((key) => ({ secret: secretName("computer", provider.id, key.name), env: key.name, row: key.name })));