@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
@@ -20,21 +20,22 @@ import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
20
20
  import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
21
21
  import { checkRaise, followUpOf, freeRequestLimitOf, maxRequestsOf, parkOf, planCapModel } from "@parcha/agentrun-kernel/kernel/cap";
22
22
  import { PLAN_LIMIT_WORDS } from "@parcha/agentrun-kernel";
23
- import { modelWire } from "../wires.js";
24
- import { confineOf, noNewPrivsPrefix, standsIn, thinkingFor } from "../adapters.js";
23
+ import { modelWire, routed } from "../wires.js";
24
+ import { confineOf, noNewPrivsPrefix, ownSearchRuns, standsIn, thinkingFor } from "../adapters.js";
25
25
  import { claimSettled, claudeCliIn, installDirOf, installForClaim, installingWords } from "../harness-install.js";
26
26
  import { HarnessUnavailable } from "../provider.js";
27
27
  import { effortGuidance } from "../effort-guidance.js";
28
28
  import { outputContract } from "../answer-json.js";
29
29
  import { wireName } from "../catalog.js";
30
30
  import { environmentLine, runZone } from "../environment.js";
31
- import { factsOf, harnessOf, recipeKeysOf } from "../harness-table.js";
31
+ import { factsOf, harnessOf, planRecipeOf } from "../harness-table.js";
32
32
  import { layHarnessKeys, openHarnessKeys, RECIPE_SIGN_IN_PERSON_ONLY, RECIPE_TURN_PERSON_ONLY } from "../harness-keys.js";
33
33
  import { laidLearned, learningFolderOf, secretsShown } from "../learning.js";
34
34
  import { laidOf, layLearningSeed } from "./learning-seed.js";
35
35
  import { learningWorkspace } from "../learn/folder.js";
36
36
  import { learningEndOfRun, spentBesideOf } from "./learning-end.js";
37
37
  import { ollamaTagsOf, providerModels, runModels } from "../model.js";
38
+ import { OLLAMA_PROVIDER } from "../ollama-provider.js";
38
39
  import { firstMessage, inputMessage, messageText } from "../run-manifest.js";
39
40
  import { learningStartOf, personStarted, seedFailed } from "../run-launch.js";
40
41
  import { readsFiles, systemOf } from "../skills.js";
@@ -42,15 +43,16 @@ import { DATA_ENV } from "../server-fs.js";
42
43
  import { filesToCopy, placeRunInputs } from "../uploads.js";
43
44
  import { recordingsFolder, runFolder, scratchFolder } from "../workspace/paths.js";
44
45
  import { openRunWorkspace } from "../workspace/run-workspace.js";
46
+ import { withoutKindSkill } from "../workspace/kind-skills.js";
45
47
  import { layOwnSkills } from "../workspace/revision-skills.js";
46
48
  import { runTools, withKindTools } from "../workspace/run-tools.js";
47
49
  import { archilWhereHeld, MOUNT_TTL_MS } from "../workspace/archil-claim.js";
48
50
  import { loadArchilSettings } from "../archil-settings.js";
49
51
  import { settingOfDefinition } from "../computer-setting.js";
50
52
  import { computerKeptWords, computerReadyWords, computerReplacedNote, computerStartingWords, imageWaitWords } from "../workspace/computer-deps.js";
51
- import { hadComputer } from "./computer-journal.js";
53
+ import { computerTurnedOff, hadComputer, recordComputerOff } from "./computer-journal.js";
52
54
  import { hostLifecycle } from "./adapter-loop.js";
53
- import { adapterRunGate, answersCut, buildToolHost, capModelOf as capModelOfRoute, claimLiveAt, graderRouteOf, hostToolCtxOf, learnedTierRoutes, learnedTiers, learnedWorkflowHostTool, learnsWorkflows, mcpReachOf, modelAskOf, PI_WIRES, webHostTools } from "./adapter-run-spec.js";
55
+ import { adapterRunGate, answersCut, buildToolHost, capModelOf as capModelOfRoute, claimLiveAt, graderRouteOf, heldModelOf, hostToolCtxOf, learnedTierRoutes, learnedTiers, learnedWorkflowHostTool, learnsWorkflows, mcpReachOf, modelAskOf, PI_WIRES, seedEvalFiles, webHostTools } from "./adapter-run-spec.js";
54
56
  import { openTierProxies } from "./adapters/pi.js";
55
57
  import { signInReads } from "../sign-ins-store.js";
56
58
  import { isWebHostTool } from "../tool-list.js";
@@ -58,7 +60,7 @@ import { hostToolOf } from "../host-tools.js";
58
60
  import { ASK_TOOL, askPerson } from "../tools.js";
59
61
  import { fakedPlane } from "../web-fake.js";
60
62
  import { claimModelEnv, claimModelKey, claimSecrets, claimSpendOff, holdRunKey, keyedAtClaim, hostDecisionKeys, learnedDecisionKeys, tierModelKeys, underClaimed, withoutModelKeys } from "./claim-secrets.js";
61
- import { mcpWhereHeld } from "./mcp-run.js";
63
+ import { claimMetering, mcpWhereHeld } from "./mcp-run.js";
62
64
  import { held as runnerSeam, heldSignInReads } from "./held.js";
63
65
  import { DECISION_PROVIDER_KEYS, TOOL_PLANE_ENV } from "../tool-plane.js";
64
66
  import { decisionProvidersIn } from "../decisions.js";
@@ -77,7 +79,8 @@ import { runPathOverStore } from "../store-reads/learning.js";
77
79
  import { specBuilt } from "./spec-holds.js";
78
80
  import { heldRedactor, holdClaimed, runnerSecrets, secretRedactor } from "./redact.js";
79
81
  import { planBeforeRun, PLAN_PROVIDER } from "../chatgpt-plan.js";
80
- import { CLAUDE_LOGIN_PROVIDER, loginBeforeRun, loginCli, loginForRun, withClaudeLogin } from "../claude-login.js";
82
+ import { CLAUDE_LOGIN_PROVIDER, loginBeforeRun, loginByToken, loginCli, loginForRun, withClaudeLogin } from "../claude-login.js";
83
+ import { heldTokenLogin } from "../claude-login-token.js";
81
84
  import { heldSpecOf } from "./held-run.js";
82
85
  import { loopComputerOf } from "./computer-channel.js";
83
86
  import { githubAppAccess } from "./github-app.js";
@@ -88,6 +91,7 @@ import { monidForClaim, withMonid } from "./monid-run.js";
88
91
  import { verifyPlacedProject, movedSkillFiles } from "../source-sync/claim.js";
89
92
  import { projectCheckpointForRun } from "./project-checkpoint.js";
90
93
  import { sourceAuxiliaryAdmitter } from "../source-sync/auxiliary.js";
94
+ import { routeTrace } from "../otel/genai.js";
91
95
  /** What a CLI harness refuses of an agent's computer, in words: a browser, which only pi's browser tool drives. */
92
96
  export const cliRefusesKind = (kind) => kind === "browser" ? "This agent's computer is a browser, which only the pi harness drives here: pick pi for this agent, or another kind of computer in Settings → Computers." : undefined;
93
97
  /** The run's model and the catalog that prices it, as main chooses a CLI run's (app.ts wireModels and runModels): on the
@@ -107,6 +111,22 @@ async function modelsOf(entry, env, ref) {
107
111
  throw new Error(`${entry.id} has no model here.`);
108
112
  return { model: chosen.model, models: chosen.models, unpriced: chosen.unpriced };
109
113
  }
114
+ /** A held run's model, its model refused at its create (hold.refused): named as its revision names it (heldModelOf),
115
+ * chosen by nothing, in no catalog, unpriced. */
116
+ function heldChoice(ref) {
117
+ const model = heldModelOf(ref);
118
+ return { model, models: { getModel: () => undefined }, unpriced: new Set([model.modelId]) };
119
+ }
120
+ /** A harness's facts for a run on `model`: on a model the route translates onto its wire (an Ollama model), its own tool
121
+ * search is not its (AdapterFacts.ownToolSearch dropped): what it sends (deferred tools, a tool search's references) is
122
+ * the provider's to read, and the translation's model has none. The host's own tools_search and tools_call are offered
123
+ * in its place, as to a harness with none of its own. */
124
+ export const factsOn = (facts, model) => {
125
+ if (!facts?.ownToolSearch || !routed(facts.wire, model))
126
+ return facts;
127
+ const { ownToolSearch: _own, ...rest } = facts;
128
+ return rest;
129
+ };
110
130
  /** The model a CLI run is capped at: the catalog entry that bills it (its entry's priceModel), its cost WITH TIERS (the
111
131
  * money rule: a request past a tier is held and booked at it, as main's calculateCost does), on the harness's wire. A
112
132
  * model the catalog does not price is held at no price: its requests are unknown, never $0. A ChatGPT plan's model
@@ -132,7 +152,10 @@ export function capModelOf(id, wire, listed, unpriced, plan = false) {
132
152
  function chosenCapModel(entry, env, chosen, wire) {
133
153
  const priced = entry.priceModel(env, chosen.model);
134
154
  const listed = chosen.models.getModel(priced.provider, priced.modelId);
135
- return capModelOf(priced.modelId, wire, listed, chosen.unpriced.has(priced.modelId) || listed === undefined, priced.provider === PLAN_PROVIDER || priced.provider === CLAUDE_LOGIN_PROVIDER || !modelWire(wire));
155
+ const capped = capModelOf(priced.modelId, wire, listed, chosen.unpriced.has(priced.modelId) || listed === undefined, priced.provider === PLAN_PROVIDER || priced.provider === CLAUDE_LOGIN_PROVIDER || !modelWire(wire));
156
+ // A model of this machine's own Ollama (the route's translation, provider.ts routedProvider): its requests never count
157
+ // toward the run's free-model limit, as pi's on the same route do (model-route.ts ModelRoute.local).
158
+ return priced.provider === OLLAMA_PROVIDER ? { ...capped, local: true } : capped;
136
159
  }
137
160
  /** The model a run of the CLI harness `entry` on `ref` (a revision's model; none, this host's default for it) is capped
138
161
  * at here, as its run's spec prices it (modelsOf, chosenCapModel), before any run: a save's cap warning (cap-short.ts)
@@ -154,7 +177,7 @@ export async function cliCapModel(entry, env, ref) {
154
177
  export function cliRunEnv(env, data, claimed = {}, plane, runKey, claim) {
155
178
  // A run with its own model key: that key alone, in the variables its route sends (claimModelEnv, never enumerable), and
156
179
  // the claim's request metadata beside it (request-metadata.ts, never enumerable either).
157
- const out = claimModelEnv(env ?? {}, claimed, runKey, claim);
180
+ const out = claimModelEnv(env ?? {}, [claimed], runKey, claim);
158
181
  Object.defineProperty(out, DATA_ENV, { value: data, enumerable: true, writable: true, configurable: true });
159
182
  delete out[TOOL_PLANE_ENV];
160
183
  if (plane && Object.keys(plane).length)
@@ -337,7 +360,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
337
360
  // A credential the claim opens mid-run (a GitHub App token, a saved or per_run server's) joins the run's redactors.
338
361
  const hold = (values) => { for (const redact of [...(run.redact ? [heldRedactor(run.redact)] : []), cut])
339
362
  redact.hold(values); };
340
- const mcp = await mcpWhereHeld({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, work: () => runFolder(deps.data, runRow.agentId, claim.runId), launchInput: launch.input, hold, githubAppAccess: (store, key, input) => githubAppAccess(store, key, input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub: launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github", hold, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) }), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, capped: launch.maxCostUsd !== undefined, media: { env: deps.env, web, slots: deps.saveSlots } });
363
+ const mcp = await mcpWhereHeld({ claim, store: deps.store, sealKey: deps.sealKey, grants: granted, harness: run.harness, work: () => runFolder(deps.data, runRow.agentId, claim.runId), launchInput: launch.input, hold, githubAppAccess: (store, key, input) => githubAppAccess(store, key, input, { ...(deps.githubApi ? { api: deps.githubApi } : {}), fromGitHub: launch.inputOrigin?.kind === "trigger" && launch.inputOrigin.source === "github", hold, ...(launch.repo !== undefined ? { repo: launch.repo } : {}) }), ...(deps.githubMcpOrigin ? { githubMcpOrigin: deps.githubMcpOrigin } : {}), ...(deps.composioMcpOrigin ? { composioMcpOrigin: deps.composioMcpOrigin } : {}), ...reach, ...claimMetering(deps, web, launch) });
341
364
  // The claim's MCP goes to the loop, which lets it go; a build that throws lets it go itself.
342
365
  holds.hold({ passed: mcp });
343
366
  // The run's mode is the server's: Mode 2 where its Archil settings are saved (archil-settings.ts), the run's folder then
@@ -369,6 +392,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
369
392
  // A run's own process copies nothing: its runner placed them before the process started (run-child-host.ts).
370
393
  if (!(deps.sealKey === undefined && runnerSeam()))
371
394
  await placeRunInputs(deps.data, claim.runId, ws.workspace, filesToCopy(launch), messageText(launch.input));
395
+ await seedEvalFiles(ws.workspace, fakes?.files);
372
396
  // The run's skills and its learning seed laid before its computer exists, as the pi spec lays them (adapter-run-spec.ts):
373
397
  // on Archil the computer's mount takes the disk's write delegation, and a lay over the disk's file API after it is
374
398
  // refused (409) while the mount holds it.
@@ -388,6 +412,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
388
412
  // The run's computer, from the one shared claim-time function (the pi spec takes the same): none for a runner place.
389
413
  // It throws computer_unavailable (nothing made) when the computer cannot be had: the run fails in its words.
390
414
  const claimSignal = run.stopped ?? run.signal;
415
+ // An earlier claim's deny turned the run's computer off for the run (computerTurnedOff): this claim starts none, and
416
+ // ends the one a park kept (turnedOff).
417
+ const offAlready = await computerTurnedOff(deps.journal(claim), context);
391
418
  const computer = await deps.computerForClaim(
392
419
  // The runner holding the claim, as the pi spec hands it: a computer kept that only it can reach again is pinned to it.
393
420
  { runId: claim.runId, epoch: claim.epoch, claim, agentId: runRow.agentId, revisionId: runRow.revisionId, place: launch.place, ...(run.incarnation ? { holder: { runner: claim.runner, incarnation: run.incarnation } } : {}) }, deps.store,
@@ -400,7 +427,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
400
427
  // Whether an earlier claim made the run a computer of its own is the run's journal's to say (hadComputer), as the pi
401
428
  // spec asks it. The computer a park kept, attached again, brings its mount credential with it (inheritMount). Its
402
429
  // screen's recording (computer.record) goes in the run's recordings folder, as the pi spec's does.
403
- { ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, refuseKind: cliRefusesKind, recordings: { folder: recordingsFolder(deps.data, runRow.agentId, claim.runId), say: (words) => run.phase?.(words) }, hadComputer: () => hadComputer(deps.journal(claim), context), stopRun: stopRunWith((refusal) => run.ledger.pause(refusal)), ...(run.ledger ? { compute: { ledger: { paid: run.ledger.paid, pause: (refusal) => run.ledger.pause(refusal), judges: () => run.ledger.judges?.() ?? true }, env: deps.env } } : {}), ...(claimSignal ? { signal: claimSignal } : {}), ...(archil ? { revokeMount: () => archil.revoke(), inheritMount: () => archil.inherit() } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)), onStarting: (said) => run.phase?.(computerStartingWords(said)), onConnected: (said) => run.phase?.(computerReadyWords(said)), onComputerNote: (words) => run.phase?.(words) } : {}) });
430
+ { ...deps.computerDeps, mode, workspace: ws.workspace, sealKey: deps.sealKey, refuseKind: cliRefusesKind, ...(offAlready ? { turnedOff: offAlready } : {}), recordings: { folder: recordingsFolder(deps.data, runRow.agentId, claim.runId), say: (words) => run.phase?.(words) }, hadComputer: () => hadComputer(deps.journal(claim), context), stopRun: stopRunWith((refusal) => run.ledger.pause(refusal)), ...(run.ledger ? { compute: { ledger: { paid: run.ledger.paid, pause: (refusal) => run.ledger.pause(refusal), judges: () => run.ledger.judges?.() ?? true }, env: deps.env } } : {}), ...(claimSignal ? { signal: claimSignal } : {}), ...(archil ? { revokeMount: () => archil.revoke(), inheritMount: () => archil.inherit() } : {}), ...(run.phase ? { onImageWait: (making, image) => run.phase?.(imageWaitWords(making, image)), onStarting: (said) => run.phase?.(computerStartingWords(said)), onConnected: (said) => run.phase?.(computerReadyWords(said)), onComputerNote: (words) => run.phase?.(words) } : {}) });
404
431
  holds.hold({ computer });
405
432
  const loopComputer = loopComputerOf(computer.computer, computer.held, computer.made);
406
433
  const heldComputer = heldSpecOf(launch, loopComputer);
@@ -437,7 +464,9 @@ async function cliSpec(launch, run, deps, claim, holds) {
437
464
  // A start whose seed failed tells the run nothing: it is never asked what to keep (learning-end.ts drops it).
438
465
  const laid = start && !seedFailed(start) ? laidLearned(body.instructions ?? "", start.section) : (body.instructions ?? "");
439
466
  const check = movedProject ? undefined : await entry.skillCheck?.();
440
- const { system: instructions, native } = await systemOf(laid, currentSkills, ws.workspace, check, { onDemand: movedProject || readsFiles(granted) });
467
+ // A computer the claim did not start (every tool of it set to deny: ClaimComputer.off) has its kind's skill named to no one.
468
+ const skills = computer.off ? withoutKindSkill(currentSkills, body.skills ?? {}, settingOfDefinition(body)?.computer.kind) : currentSkills;
469
+ const { system: instructions, native } = await systemOf(laid, skills, ws.workspace, check, { onDemand: movedProject || readsFiles(granted) });
441
470
  const guidance = effortGuidance(launch.effort);
442
471
  // The run's model (the launch's, pinned at start, else the revision's) and its adapter, as main builds them, on the
443
472
  // environment main's server gives its runs: the server's data directory named (DATA_ENV), so the CLI's install is
@@ -461,8 +490,14 @@ async function cliSpec(launch, run, deps, claim, holds) {
461
490
  }
462
491
  // Claude Code's login on this machine, where the owner turned it on for claude-agent here (claude-login.ts): the run
463
492
  // carries only where it is, and its CLI says it is signed in before the run starts. A run that brought its own key
464
- // runs on that key, and a run in a sandbox place on the model keys.
465
- const login = keyed ? undefined : await loginForRun(deps.store.settings, deps.data, deps.env ?? {}, name, launch.place);
493
+ // runs on that key, and a run in a sandbox place on the model keys. A run's own process (a user of its own, which
494
+ // cannot open the login's folder) goes on its runner's reader of the login's access token alone (held.ts claudeLogin),
495
+ // each token it hands held by the redactors and this process's own; its CLI then never gets a refresh token. Whether
496
+ // such a claim goes on the login at all is its runner's answer alone (none: it does not): the setting names the
497
+ // machine by the id in the server's data folder (claude-login.ts machineId), which the run's user can neither read nor
498
+ // make there.
499
+ const handed = keyed || deps.sealKey ? undefined : await runnerSeam()?.claudeLogin();
500
+ const login = keyed ? undefined : handed ? heldTokenLogin(handed, hold) : deps.sealKey ? await loginForRun(deps.store.settings, deps.data, deps.env ?? {}, name, launch.place) : undefined;
466
501
  const env = withClaudeLogin(cliRunEnv(deps.env, deps.data, claimed, launch.plane, runKey, claim), login);
467
502
  // A plan-billed recipe's keys saved for its harness alone (harness-keys.ts), opened at each claim for this run's harness
468
503
  // and no other (a run's own process asks its runner, which opens its claim's own: held.ts harnessKeys), held by the
@@ -476,12 +511,13 @@ async function cliSpec(launch, run, deps, claim, holds) {
476
511
  // is chosen, so it never falls to its owner's sign-in (a row counted at its claim may be gone, or not open, by now).
477
512
  // A person's claim that laid none keeps its session on the sign-in (or on nothing) for good: a trigger's message the
478
513
  // claim takes later is refused in it (personOnly), keys saved since or not, as no new claim opens them.
479
- const recipeKeys = name === undefined ? undefined : recipeKeysOf(deps.env ?? {}, name);
514
+ const recipe = name === undefined ? undefined : planRecipeOf(deps.env ?? {}, name);
515
+ const recipeKeys = recipe?.keys;
480
516
  let personOnly;
481
- if (name !== undefined && recipeKeys?.length) {
517
+ if (recipe !== undefined && recipeKeys?.length) {
482
518
  for (const key of recipeKeys)
483
519
  delete env[key];
484
- const opened = deps.sealKey ? await openHarnessKeys(deps.store, deps.sealKey, name, recipeKeys) : ((await runnerSeam()?.harnessKeys()) ?? {});
520
+ const opened = deps.sealKey ? await openHarnessKeys(deps.store, deps.sealKey, recipe) : ((await runnerSeam()?.harnessKeys(recipe.digest)) ?? {});
485
521
  hold(Object.values(opened));
486
522
  if (recipeKeys.every((key) => typeof opened[key] === "string" && opened[key] !== ""))
487
523
  layHarnessKeys(env, opened);
@@ -490,11 +526,25 @@ async function cliSpec(launch, run, deps, claim, holds) {
490
526
  else
491
527
  personOnly = RECIPE_TURN_PERSON_ONLY;
492
528
  }
493
- const chosen = await modelsOf(entry, env, modelAskOf(launch.model, body.model));
494
- await planBeforeRun(env, chosen.model);
495
- if (login && entry.priceModel(env, chosen.model).provider === CLAUDE_LOGIN_PROVIDER) {
496
- const claude = await import("@parcha/agentrun-harness-claude");
497
- await loginBeforeRun(login, loginCli(claudeCliIn(installDirOf(deps.data, name), claude.claudeAgentPlatform()), env), (cli, at) => claude.claudeLoginStatus(cli, at, env.PATH ? { path: env.PATH } : {}));
529
+ // A held run its model kept from running at its create (hold.refused) chooses no model here, and no plan or login is
530
+ // asked before it: its model's route chooses no model and reads no key, its adapter's provider being the stand-in that
531
+ // refuses every request in the create's words (adapters.ts providerOf), never a key or the Claude login. Its claim lays
532
+ // only the keys any claim of the run lays (its tools', a key handed with it: claimSecrets lays it no model key) and
533
+ // takes no learning step (below), so it holds the computer on a host with no key for its model, and a key saved since
534
+ // runs a new run, never this one.
535
+ const heldRefusal = launch.hold?.refused?.message;
536
+ const chosen = heldRefusal !== undefined ? heldChoice(body.model) : await modelsOf(entry, env, modelAskOf(launch.model, body.model));
537
+ if (heldRefusal === undefined) {
538
+ await planBeforeRun(env, chosen.model);
539
+ if (login && entry.priceModel(env, chosen.model).provider === CLAUDE_LOGIN_PROVIDER) {
540
+ // On a token: one read before the run, refused in its words (signed out, near its end) as the CLI's own check is.
541
+ if (loginByToken(login))
542
+ await login.token();
543
+ else {
544
+ const claude = await import("@parcha/agentrun-harness-claude");
545
+ await loginBeforeRun(login, loginCli(claudeCliIn(installDirOf(deps.data, name), claude.claudeAgentPlatform()), env), (cli, at) => claude.claudeLoginStatus(cli, at, env.PATH ? { path: env.PATH } : {}), { data: deps.data });
546
+ }
547
+ }
498
548
  }
499
549
  // The CLI's own process (the Claude CLI, Codex, OpenCode) starts under the no_new_privs pi's commands start under
500
550
  // (adapters.ts' noNewPrivsPrefix): on Linux, setpriv --no-new-privs, so a setuid program or file capability it
@@ -506,7 +556,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
506
556
  // A run's own process reads no trigger's row: its runner answers the zone (held.ts runZone).
507
557
  const seam = deps.sealKey ? undefined : runnerSeam();
508
558
  const zone = seam ? await seam.runZone() : await runZone(deps.store, launch.inputOrigin);
509
- const built = await entry.adapter(env, { zone, model: chosen.model, models: chosen.models, unpriced: chosen.unpriced, ...(confine ? { confine } : {}), ...(native.length ? { skills: native } : {}), ...(now ? { now: () => now } : {}) });
559
+ const built = await entry.adapter(env, { zone, model: chosen.model, models: chosen.models, unpriced: chosen.unpriced, ...(heldRefusal !== undefined ? { heldRefusal } : {}), ...(confine ? { confine } : {}), ...(native.length ? { skills: native } : {}), ...(now ? { now: () => now } : {}) });
510
560
  // The harness's own session options, its private directory and its working directory (SessionIO's dir and cwd, which
511
561
  // every CLI adapter reads), set on its open here, so the loop lends the session nothing of its own. A turn that ends on
512
562
  // the CLI's own error names the harness first, as main words it (harness-app.ts: `<harness>: <error>`), so the run's
@@ -590,7 +640,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
590
640
  // A pinned MCP tool is held to the arguments its listing in the run's pin declares (mcp.argumentsOf). The harness's
591
641
  // native tools are named by its facts on the owner's table (factsOf: a module's harness's too).
592
642
  const ownerFacts = factsOf(deps.env, name);
593
- const gate = await adapterRunGate(deps.store, claim, revision, ws.workspace, tools.shell, { ...(mcp ? { effectOf: (name) => mcp.effectOf(name), argumentsOf: (name) => mcp.argumentsOf(name) } : {}), facts: ownerFacts });
643
+ const gate = await adapterRunGate(deps.store, claim, revision, ws.workspace, tools.shell, { ...(mcp ? { effectOf: (name) => mcp.effectOf(name), argumentsOf: (name) => mcp.argumentsOf(name) } : {}), facts: ownerFacts, turnedOff: offAlready !== undefined, onComputerOff: (kind) => recordComputerOff(run.harness, kind) });
594
644
  // The run's tools: the kernel registry's hands on its Workspace (and computer); the web host tools it is granted
595
645
  // (web_fetch, web_search, monid), bound by the binding the pi spec uses (webHostTools) on the ToolHost the pi spec builds
596
646
  // (buildToolHost); and the learned_workflow tool when the run has it (learnsWorkflows: its revision is agentic and the
@@ -609,7 +659,10 @@ async function cliSpec(launch, run, deps, claim, holds) {
609
659
  // its MCP tools in the loop's one catalog seam; their answers pass the redactors as the web tools' do.
610
660
  const monid = monidForClaim(revisionRow.monidPin ?? undefined, { ...claimed }, () => ws.workspace, claim.runId, () => launch.maxCostUsd !== undefined, fakes?.monid);
611
661
  const catalog = withMonid(mcp, monid && { ...monid, tools: monid.tools.map((tool) => answersCut(tool, held)) });
612
- const webNames = granted.filter(isWebHostTool);
662
+ // A run whose web_search is the harness's own search (ownSearchRuns: native on its plane, Claude's WebSearch, Codex's
663
+ // live search) is not handed the host's web_search beside it.
664
+ const webGranted = ownSearchRuns(ownerFacts, launch.plane) ? granted.filter((name) => name !== "web_search") : granted;
665
+ const webNames = webGranted.filter(isWebHostTool);
613
666
  let learnedTool;
614
667
  let webTools = [];
615
668
  let life;
@@ -629,19 +682,20 @@ async function cliSpec(launch, run, deps, claim, holds) {
629
682
  // five); while the folder's revision replays or is held, the champion (the digest promoted last) serves in its place
630
683
  // (laidFor). Or the one the money rule stopped, over the agent's past runs (costLineOf): the agent takes the run.
631
684
  // The audits that finished since are written first (runner/audit.ts settleAudits): a hold they make decides this claim.
632
- // Model spend beside the run that its caller's key does not pay for (claimSpendOff): a shadow audit and a replay check
633
- // are skipped, in words, where the run brought its own key or the server holds none.
634
- const spendOff = await claimSpendOff({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, runKey);
635
685
  const admitAuxiliary = runnerSeam() ? undefined : sourceAuxiliaryAdmitter(deps.store, { data: deps.data, sealKey: deps.sealKey, env: deps.env, control: { ...deps.mountControl, ...(deps.makeArchilDisk ? { makeDisk: deps.makeArchilDisk } : {}) } });
636
- const audits = { store: deps.store, agentId: runRow.agentId, revisionId: runRow.revisionId, context, log, folder: learningFolder, shown, sealKey: deps.sealKey, spendOff, admitAuxiliary };
686
+ // None for a held run, so its claim reads no saved key for spend beside it (claimSpendOff).
687
+ const audits = heldRefusal === undefined ? { store: deps.store, agentId: runRow.agentId, revisionId: runRow.revisionId, context, log, folder: learningFolder, shown, sealKey: deps.sealKey, spendOff: await claimSpendOff({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, runKey), admitAuxiliary } : undefined;
637
688
  // A replay run's or a shadow's grader (runner/compare-end.ts), on a proxy of its own beside the CLI session's, as pi's
638
689
  // is (adapter-run-spec.ts graderRouteOf), reached through the session's port while it is up. None: compared whole.
639
- const graderRoute = launch.replay || launch.audit ? await graderRouteOf(body, keyed, runKey, claimed, cut, log, deps, [held, cut], claim) : undefined;
690
+ // None for a held run its model kept from running, whose model runs nowhere.
691
+ const graderRoute = (launch.replay || launch.audit) && heldRefusal === undefined ? await graderRouteOf(body, keyed, runKey, claimed, cut, log, deps, [held, cut], claim) : undefined;
640
692
  if (graderRoute)
641
693
  tierRoutes.set(GRADER, graderRoute);
642
694
  // Each step writes the store or reads another run (runner/learned-first.ts): in a run's own process its runner takes
643
- // them (held.ts learnedFirst), over the workflows it reads at the claim's seed itself.
644
- const learned = await learnedFirstWhereHeld(deps, { agentId: runRow.agentId, runId: claim.runId, revisionId: runRow.revisionId, kind: revision.kind, outputSchema: revision.body.outputSchema, launch, context, log, folder: learningFolder, shown, spendOff, admitAuxiliary }, seedLaid?.workflows ?? []);
695
+ // them (held.ts learnedFirst), over the workflows it reads at the claim's seed itself. A held run its model kept from
696
+ // running takes none of them, as on pi: it settles no audit and starts no replay run, starts on no workflow, and its
697
+ // tool runs none (so no learned tier is routed, below).
698
+ const learned = audits ? await learnedFirstWhereHeld(deps, { agentId: runRow.agentId, runId: claim.runId, revisionId: runRow.revisionId, kind: revision.kind, outputSchema: revision.body.outputSchema, launch, context, log, folder: learningFolder, shown, spendOff: audits.spendOff, admitAuxiliary }, seedLaid?.workflows ?? []) : { choice: {}, workflows: [] };
645
699
  const firstChoice = learned.choice;
646
700
  // A replay run's call nodes: reads live through a cache seeded from the graded run's recorded calls, writes only ever
647
701
  // answered from that recording (runner/promotion.ts replayCallsOver, learn/replay-calls.ts).
@@ -651,7 +705,8 @@ async function cliSpec(launch, run, deps, claim, holds) {
651
705
  const workflows = learned.workflows;
652
706
  const learns = learnsWorkflows(revision.kind, workflows);
653
707
  if (webNames.length || learns) {
654
- // The claim's keys (above, already held by the redactors), a copy of its own for the tools' plane below.
708
+ // The claim's keys (above, already held by the redactors), a copy of its own for the tools' plane below: its tool and
709
+ // decision keys alone, since its model keys are not enumerable (claimSecrets), so no spread or spawn of it carries one.
655
710
  const toolEnv = { ...claimed };
656
711
  // The decision keys its learned workflows' typed questions need, as the pi spec reads them (claim-secrets.ts
657
712
  // learnedDecisionKeys): onto this copy alone, never the CLI's own environment or its model's (cliRunEnv, above), and
@@ -662,7 +717,8 @@ async function cliSpec(launch, run, deps, claim, holds) {
662
717
  holdClaimed(redact, learnedKeys);
663
718
  underClaimed(toolEnv, learnedKeys);
664
719
  }
665
- handedKeys = runnerSecrets(toolEnv);
720
+ // The model keys the claim opened among them, read by name from `claimed`: the run never learns those either.
721
+ handedKeys = runnerSecrets(toolEnv, runnerSecrets(claimed));
666
722
  // The run's resolved tool plane (its web tools' providers), as the pi spec hands it its web tools.
667
723
  delete toolEnv[TOOL_PLANE_ENV];
668
724
  if (launch.plane && Object.keys(launch.plane).length)
@@ -672,7 +728,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
672
728
  const liveAt = await claimLiveAt(deps, claim.runId);
673
729
  const host = buildToolHost({ root, workspace: ws.workspace, claim, env: toolEnv, run, store: deps.store, sealKey: deps.sealKey, life, redact: held, launch, toolSettings: body.toolSettings, ...(fakes ? { fakes } : {}), ...reach, ...(liveAt ? { liveAt } : {}), ...(deps.saveSlots ? { saveSlots: deps.saveSlots } : {}) });
674
730
  gate.askedOn(host);
675
- webTools = await webHostTools(host, granted, ctx);
731
+ webTools = await webHostTools(host, webGranted, ctx);
676
732
  }
677
733
  if (learns) {
678
734
  // A tier the learned workflows name that the host has a model of, routed as pi's are (learnedTierRoutes: the run's
@@ -683,7 +739,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
683
739
  const tierKeys = keyed ? {} : await tierModelKeys({ store: deps.store, sealKey: deps.sealKey, env: deps.env }, learnedTiers(workflows));
684
740
  for (const redact of new Set([held, cut]))
685
741
  holdClaimed(redact, tierKeys);
686
- const modelEnv = claimModelEnv(deps.env, { ...claimed, ...tierKeys }, runKey, claim);
742
+ const modelEnv = claimModelEnv(deps.env, [tierKeys, claimed], runKey, claim);
687
743
  const tiers = new Map();
688
744
  for (const [tier, routed] of await learnedTierRoutes(workflows, modelEnv, (tier) => deps.routeOf(undefined, modelEnv, tier, PI_WIRES, undefined, cut))) {
689
745
  if ("why" in routed)
@@ -722,7 +778,8 @@ async function cliSpec(launch, run, deps, claim, holds) {
722
778
  // from. With a grader it compares its answer with the other one (runner/compare-end.ts), on its own cap.
723
779
  // A run the promoted workflow answered (path `workflow`) starts its shadow audit after the step, drawn at 1 in k (runner/audit.ts
724
780
  // withAudit): at its end, so the shadow's cap is what the run's own left.
725
- const endOfRun = launch.replay || launch.audit ? withGrader(compareEndOfRun(launch, { store: deps.store, folder: learningFolder, log, ...(run.redact ? { redact: run.redact } : {}) }), graderRoute ? { model: graderRoute.model, models: () => run.ledger.models(GRADER, GRADER) } : undefined) : withAudit(learningEndOfRun(launch, {
781
+ // A held run (no audits) takes none, as on pi.
782
+ const endOfRun = audits === undefined ? undefined : launch.replay || launch.audit ? withGrader(compareEndOfRun(launch, { store: deps.store, folder: learningFolder, log, ...(run.redact ? { redact: run.redact } : {}) }), graderRoute ? { model: graderRoute.model, models: () => run.ledger.models(GRADER, GRADER) } : undefined) : withAudit(learningEndOfRun(launch, {
726
783
  store: deps.store,
727
784
  data: deps.data,
728
785
  ...(deps.env ? { env: deps.env } : {}),
@@ -741,7 +798,7 @@ async function cliSpec(launch, run, deps, claim, holds) {
741
798
  }), { ...audits, launch, ...(run.redact ? { redact: run.redact } : {}) });
742
799
  return {
743
800
  adapter,
744
- facts: ownerFacts,
801
+ facts: factsOn(ownerFacts, chosen.model),
745
802
  session,
746
803
  input,
747
804
  // A trigger's first input is its origin's, the launch's own owner flag kept (run-launch.ts keepInputOrigin).
@@ -752,6 +809,8 @@ async function cliSpec(launch, run, deps, claim, holds) {
752
809
  // The answer's schema: a miss is asked again once (adapter-loop.ts, the output contract's retry), as on pi.
753
810
  ...(body.outputSchema !== undefined ? { outputSchema: body.outputSchema } : {}),
754
811
  ...(cap ? { cap } : {}),
812
+ // Its model, as its GenAI trace names it (otel/genai.ts); its requests' host is its CLI's own to choose.
813
+ trace: routeTrace({ named: `${chosen.model.provider}/${chosen.model.modelId}`, model: chosen.model.modelId }),
755
814
  // The run's MCP for a harness with its own client (mcp-run.ts), with its monid endpoints beside it (monid-run.ts):
756
815
  // the catalog tools the session mounts; absent when none.
757
816
  ...(catalog ? { mcp: catalog } : {}),
@@ -1,4 +1,5 @@
1
- import type { Context } from "@earendil-works/chord/context";
1
+ import { type Context } from "@earendil-works/chord/context";
2
+ import { type Harness } from "@earendil-works/pi-durable";
2
3
  import type { JournalReads } from "../store/store.js";
3
4
  import type { HeldComputer, HoldEnd, HoldState } from "../workspace/computer-hold.js";
4
5
  import type { Command, CommandOutcome } from "./loop-contract.js";
@@ -6,6 +7,13 @@ import type { Command, CommandOutcome } from "./loop-contract.js";
6
7
  * claim's pass writes): what a later claim asks (computerForClaim's hadComputer) before it makes a fresh one, so it
7
8
  * says it replaces one even when nothing of the earlier claim's is left to let go (a server's stop, a park). */
8
9
  export declare function hadComputer(journal: JournalReads, context: Context): Promise<boolean>;
10
+ /** The kind of the run's computer when an earlier claim's deny turned it off for the rest of the run (KINDS.computerOff,
11
+ * recordComputerOff): a claim that finds it starts no computer, and its gate refuses each call of that computer's tools
12
+ * short (RunGate.turnOff). Undefined while the run's computer is on. */
13
+ export declare function computerTurnedOff(journal: JournalReads, context: Context): Promise<string | undefined>;
14
+ /** Writes on the run's root, through the claim's Harness, that the run's `kind` computer is off for the rest of the run:
15
+ * what computerTurnedOff reads back at a later claim. */
16
+ export declare function recordComputerOff(harness: Pick<Harness, "commit">, kind: string): Promise<void>;
9
17
  /** One root entry, as the run's journal takes it. */
10
18
  export type RootEntry = {
11
19
  readonly kind: string;
@@ -1,3 +1,16 @@
1
+ // The run's desktop or phone hold, on the runner: every change of the hold (workspace/computer-hold.ts) is committed to the
2
+ // run's journal with its Timeline row, which is what the server reads (computer-commands.ts, computer-routes.ts); and the
3
+ // person's take-over and hand-back rows are applied to the hold. The adapter loop calls this once the run's Harness is
4
+ // open, for a spec that carries a computer (AdapterRunSpec.computer).
5
+ //
6
+ // Commits go one at a time, in the order the hold changed, each at the change's own time. A row the hold took or ended a
7
+ // take for is taken by the commit that writes that change (its `by`); one the hold refuses is refused in words.
8
+ //
9
+ // onComputerHold is the change signal for whoever else in the runner's process shows the hold (tl-browser's run-side
10
+ // viewer and its bar): it fires after each computer.hold change entry is committed, with that change's Timeline words.
11
+ // A run in a process of its own commits there and its viewer is its runner's: the change crosses to the runner first.
12
+ import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
13
+ import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
1
14
  import { HOST_PHASE } from "../timeline/index.js";
2
15
  import { COMPUTER_HAND_BACK, COMPUTER_HANDOVER_KIND, COMPUTER_HOLD_KIND, COMPUTER_TAKE_OVER, ENDS, holdIn, holdWords, STATES, takeEndedWords, } from "../computer-commands.js";
3
16
  import { held } from "./held.js";
@@ -9,6 +22,19 @@ import { journalEntries } from "./journal-reader.js";
9
22
  export async function hadComputer(journal, context) {
10
23
  return (await journalEntries(journal, context)).some((entry) => entry.kind === KINDS.computerMade);
11
24
  }
25
+ /** The kind of the run's computer when an earlier claim's deny turned it off for the rest of the run (KINDS.computerOff,
26
+ * recordComputerOff): a claim that finds it starts no computer, and its gate refuses each call of that computer's tools
27
+ * short (RunGate.turnOff). Undefined while the run's computer is on. */
28
+ export async function computerTurnedOff(journal, context) {
29
+ const off = (await journalEntries(journal, context)).find((entry) => entry.kind === KINDS.computerOff);
30
+ const kind = off?.data?.computer;
31
+ return typeof kind === "string" ? kind : undefined;
32
+ }
33
+ /** Writes on the run's root, through the claim's Harness, that the run's `kind` computer is off for the rest of the run:
34
+ * what computerTurnedOff reads back at a later claim. */
35
+ export async function recordComputerOff(harness, kind) {
36
+ await harness.commit(async (tx) => void (await tx.appendEntry(ROOT_CONVERSATION_ID, { kind: KINDS.computerOff, data: { computer: kind } })), BACKGROUND_CONTEXT);
37
+ }
12
38
  const listeners = new Map();
13
39
  /** Calls `listener` after each change of run `runId`'s hold is committed to its journal, in order, in this process.
14
40
  * Returns the unsubscribe. */
@@ -385,7 +385,7 @@ async function world(subject, t, timing = STEADY) {
385
385
  return reducer.rows();
386
386
  };
387
387
  /** The run's Timeline rows as GET /runs/{id}/timeline serves them (run-timeline-served.ts), its approval rows among them. */
388
- const servedRows = () => servedTimelineRows({ serverSecrets: () => [], keyEnv: () => ({}) }, server, RUN, BACKGROUND_CONTEXT);
388
+ const servedRows = () => servedTimelineRows({ serverSecrets: () => [], sealKey: undefined, keyEnv: () => ({}) }, server, RUN, BACKGROUND_CONTEXT);
389
389
  const commandRow = async (id) => (await server.commands(RUN, id - 1)).find((row) => row.id === id);
390
390
  /** The call the run asked a person about: its ask entry's callId, which an approve or deny names as its approval. */
391
391
  const askedCall = async () => {
@@ -113,6 +113,9 @@ export async function openFeedbackRound(store, grade, label, canTurn = () => tru
113
113
  // Source sessions and application-owned SDK tasks cannot consume a managed feedback steer.
114
114
  if (launch?.native || launch?.sdk || launch?.cli_learning)
115
115
  return null;
116
+ // A held run its model kept from running at its create never runs a turn (computer-held.ts): no round opens it again.
117
+ if (launch?.hold?.refused)
118
+ return null;
116
119
  const learning = launch?.learning;
117
120
  if (!learning || learning.use)
118
121
  return null;
@@ -1,5 +1,5 @@
1
1
  import { RECIPE_SIGN_IN_PERSON_ONLY } from "../harness-keys.js";
2
- import type { SealedKeys } from "../store/index.js";
2
+ import type { SealedKeys, Settings } from "../store/index.js";
3
3
  import { type RunLaunch } from "../run-launch.js";
4
4
  import { type AdapterSpecDeps } from "./adapter-run-spec.js";
5
5
  import { ClaimRefused, type LoopFactory } from "./loop-contract.js";
@@ -10,14 +10,15 @@ export declare class NeverFits extends ClaimRefused {
10
10
  }
11
11
  export { RECIPE_SIGN_IN_PERSON_ONLY };
12
12
  /** Refuses at its claim a run no person started (a schedule's, a trigger's, a learned workflow's audit shadow or replay:
13
- * personStarted) on a plan-billed recipe's harness (harness-table.ts recipeKeysOf) unless every key it runs on is saved for that harness (harness-keys.ts), on
14
- * every path a claim takes (run-child-host.ts staysInRunner, and here): the early word, before a process is made. Rows
15
- * are counted, never opened; the claim's spec opens them and refuses it again if not every one opened, since a row
16
- * counted here can be gone or not open by then (cli-run-spec.ts). */
13
+ * personStarted) on a plan-billed recipe's harness (harness-table.ts planRecipeOf) unless every key it runs on is saved
14
+ * for that recipe (harness-keys.ts), on every path a claim takes (run-child-host.ts staysInRunner, and here): the early
15
+ * word, before a process is made. Rows and their bindings are counted, never opened; the claim's spec opens them and
16
+ * refuses it again if not every one opened, since a row counted here can be gone or not open by then (cli-run-spec.ts). */
17
17
  export declare function refuseRecipeTriggerRun(deps: {
18
18
  readonly env?: NodeJS.ProcessEnv;
19
19
  readonly store: {
20
20
  readonly sealedKeys: Pick<SealedKeys, "all">;
21
+ readonly settings: Pick<Settings, "get">;
21
22
  };
22
23
  }, harness: string, launch: Pick<RunLaunch, "trigger" | "audit" | "replay">): Promise<void>;
23
24
  /** The dispatch's `resolve`, built from the runner's deps: it reads the run's revision (for a workflow revision) and
@@ -13,7 +13,7 @@ import { createNativeLoop } from "./native-loop.js";
13
13
  // module adds with no adapter facts of its own, on its runner's adapter;
14
14
  // - a CLI harness (claude-agent, codex, opencode) runs on the adapter loop with its own adapter;
15
15
  // - anything else fails the run in words (the dispatch's UnknownHarness).
16
- import { harnessOf, recipeKeysOf } from "../harness-table.js";
16
+ import { harnessOf, planRecipeOf } from "../harness-table.js";
17
17
  import { harnessKeysSaved, RECIPE_SIGN_IN_PERSON_ONLY } from "../harness-keys.js";
18
18
  import { hostMemory, neverFits } from "../host.js";
19
19
  import { personStarted } from "../run-launch.js";
@@ -36,15 +36,15 @@ export class NeverFits extends ClaimRefused {
36
36
  }
37
37
  export { RECIPE_SIGN_IN_PERSON_ONLY };
38
38
  /** Refuses at its claim a run no person started (a schedule's, a trigger's, a learned workflow's audit shadow or replay:
39
- * personStarted) on a plan-billed recipe's harness (harness-table.ts recipeKeysOf) unless every key it runs on is saved for that harness (harness-keys.ts), on
40
- * every path a claim takes (run-child-host.ts staysInRunner, and here): the early word, before a process is made. Rows
41
- * are counted, never opened; the claim's spec opens them and refuses it again if not every one opened, since a row
42
- * counted here can be gone or not open by then (cli-run-spec.ts). */
39
+ * personStarted) on a plan-billed recipe's harness (harness-table.ts planRecipeOf) unless every key it runs on is saved
40
+ * for that recipe (harness-keys.ts), on every path a claim takes (run-child-host.ts staysInRunner, and here): the early
41
+ * word, before a process is made. Rows and their bindings are counted, never opened; the claim's spec opens them and
42
+ * refuses it again if not every one opened, since a row counted here can be gone or not open by then (cli-run-spec.ts). */
43
43
  export async function refuseRecipeTriggerRun(deps, harness, launch) {
44
44
  if (personStarted(launch))
45
45
  return;
46
- const keys = recipeKeysOf(deps.env ?? {}, harness);
47
- if (keys !== undefined && !(await harnessKeysSaved(deps.store, harness, keys)))
46
+ const recipe = planRecipeOf(deps.env ?? {}, harness);
47
+ if (recipe !== undefined && !(await harnessKeysSaved(deps.store, recipe)))
48
48
  throw new ClaimRefused(RECIPE_SIGN_IN_PERSON_ONLY);
49
49
  }
50
50
  /** The dispatch's `resolve`, built from the runner's deps: it reads the run's revision (for a workflow revision) and
@@ -43,10 +43,12 @@ export interface HeldMcpAsk {
43
43
  /** The run's journal commit, for a call's record on the run's root (mcp-gateway.ts commit): an entry appended. */
44
44
  readonly appendRoot: (entry: unknown) => Promise<void>;
45
45
  }
46
- /** What the run's process gives the runner's computerForClaim (workspace/computer-for-claim.ts): its callbacks only. The
47
- * run, its epoch, its folder, its mode and its revision are the runner's own reads of the claim. */
46
+ /** What the run's process gives the runner's computerForClaim (workspace/computer-for-claim.ts): its callbacks, and the
47
+ * kind its journal says an earlier claim's deny turned off (ComputerForClaimDeps.turnedOff), read there as hadComputer
48
+ * is. The run, its epoch, its folder, its mode and its revision are the runner's own reads of the claim. */
48
49
  export interface HeldComputerAsk {
49
50
  readonly hadComputer: () => Promise<boolean>;
51
+ readonly turnedOff?: string;
50
52
  readonly signal?: AbortSignal;
51
53
  readonly say?: (words: string) => void;
52
54
  readonly onImageWait?: (making: boolean, image: string) => void;
@@ -60,6 +62,17 @@ export interface Held {
60
62
  projectCheckpoint(signal?: AbortSignal): Promise<ProjectCheckpoint>;
61
63
  /** The ChatGPT sign-in's reader (chatgpt-plan.ts planReaderOf), for a run whose models reach the plan; else none. */
62
64
  plan(): Promise<PlanReader | undefined>;
65
+ /** Claude Code's login on this machine, for a claim of a run that goes on it (claude-login.ts loginForRun, the
66
+ * claim's own harness and place, and no model key of its own): its access token alone, read by the runner at each ask
67
+ * and renewed by it when near its end (claude-login-token.ts LoginTokens), which throws in words where there is none
68
+ * to hand; `refused(sent)` tells the runner Anthropic refused `sent` (the CLI's 401), so the next ask renews it. Else
69
+ * none, and the claim does not go on the login: the one answer to that, since the process can read neither the
70
+ * setting's machine id nor the login's folder. A claim on a login other than AgentRun's own folder is refused
71
+ * (LOGIN_NOT_HANDED). */
72
+ claudeLogin(): Promise<{
73
+ token(): Promise<string>;
74
+ refused(sent: string): Promise<void>;
75
+ } | undefined>;
63
76
  /** Whether a browser sign-in handed to the run reads back here (sign-ins-store.ts handedSignInReadsBack). */
64
77
  signInReadsBack(): Promise<boolean>;
65
78
  /** The run's browser sign-in for vendor `resolution` (sign-ins-store.ts runSignIn). */
@@ -72,8 +85,11 @@ export interface Held {
72
85
  * out and its launch's payload names the pull request. Its mint makes a token of that repository alone, contents
73
86
  * read, whatever the process names; its MCP mints on the runner (mcp). */
74
87
  githubAppAccess(): Promise<GithubAppAccessAt | undefined>;
75
- /** Every saved model key, for a run whose routes have no revision to scope them by (a subagent's tiers, a grade). */
76
- savedModelKeys(): Promise<Record<string, string>>;
88
+ /** The saved model keys of the models of the claim's subagent tiers (claim-secrets.ts subagentTierKeys asks): an agentic
89
+ * run granted the subagent tool gets its routed tiers' keys; a replay's or an audit's grader, its fast tier's key alone
90
+ * (none when its revision names agree_on or routes no fast tier). None to any other run, to one that holds a model key
91
+ * of its own, or to a held run its model kept from running. */
92
+ subagentTierKeys(): Promise<Record<string, string>>;
77
93
  /** The model keys the host's models of `tiers` need (claim-secrets.ts tierModelKeys), the plan's reader with them: of
78
94
  * the tiers the claim's learned workflows name, as the runner chose them (learnedFirst), alone. */
79
95
  tierModelKeys(tiers: readonly Tier[]): Promise<{
@@ -90,8 +106,10 @@ export interface Held {
90
106
  * claim's own launch, else the server's. A zone's name, never the trigger's row. */
91
107
  runZone(): Promise<string>;
92
108
  /** The keys saved for the claim's own harness alone (harness-keys.ts openHarnessKeys), by name, opened by the runner:
93
- * none unless that harness is a plan-billed recipe. The process lays them on its adapter's environment alone. */
94
- harnessKeys(): Promise<Record<string, string>>;
109
+ * none unless that harness is a plan-billed recipe, and none unless they are bound to `digest`, the sha256 of the
110
+ * recipe file the process loaded itself (a file swapped since the runner read its table never takes the first's).
111
+ * The process lays them on its adapter's environment alone. */
112
+ harnessKeys(digest: string): Promise<Record<string, string>>;
95
113
  /** The host's keys of the decision providers `providers` (claim-secrets.ts hostDecisionKeys): of the providers the
96
114
  * claim's learned workflows' questions name, as the runner chose them (learnedFirst), alone. */
97
115
  decisionKeys(providers: readonly string[]): Promise<Record<string, string>>;
@@ -89,6 +89,11 @@ export declare const KINDS: {
89
89
  * entry is how that claim knows the run had one when nothing of the earlier claim's is left to let go (a server's
90
90
  * stop, a park): computer-journal.ts hadComputer. Neither a call nor a message, and never on the Timeline. */
91
91
  readonly computerMade: "agentrun.computer.made";
92
+ /** The run's computer is off for the rest of the run (`computer`: its kind): written on the root by the claim's gate at
93
+ * the first deny of a call of that computer's own tools (tool-gate.ts RunGate.computerOff), whose refusal said so. A
94
+ * later claim of the run starts no computer and refuses each call of its tools short: computer-journal.ts
95
+ * computerTurnedOff. Neither a call nor a message, and never on the Timeline. */
96
+ readonly computerOff: "agentrun.computer.off";
92
97
  /** A grade's feedback round (runner/feedback-round.ts): the run opened again on a grade's words, asked no turn of the
93
98
  * job's; its next end's end-of-run turn reads them (`text`, the `round`, whether the grade said right, the workflow a
94
99
  * revision is asked of). Written on the root by the commit that takes the round's steer row. Neither a call nor a
@@ -89,6 +89,11 @@ export const KINDS = {
89
89
  * entry is how that claim knows the run had one when nothing of the earlier claim's is left to let go (a server's
90
90
  * stop, a park): computer-journal.ts hadComputer. Neither a call nor a message, and never on the Timeline. */
91
91
  computerMade: "agentrun.computer.made",
92
+ /** The run's computer is off for the rest of the run (`computer`: its kind): written on the root by the claim's gate at
93
+ * the first deny of a call of that computer's own tools (tool-gate.ts RunGate.computerOff), whose refusal said so. A
94
+ * later claim of the run starts no computer and refuses each call of its tools short: computer-journal.ts
95
+ * computerTurnedOff. Neither a call nor a message, and never on the Timeline. */
96
+ computerOff: "agentrun.computer.off",
92
97
  /** A grade's feedback round (runner/feedback-round.ts): the run opened again on a grade's words, asked no turn of the
93
98
  * job's; its next end's end-of-run turn reads them (`text`, the `round`, whether the grade said right, the workflow a
94
99
  * revision is asked of). Written on the root by the commit that takes the round's steer row. Neither a call nor a