@jr2/orchestrator 0.5.1 → 0.7.0

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 (350) hide show
  1. package/console/components/app.ts +55 -15
  2. package/console/components/bottom-drawer.ts +259 -0
  3. package/console/components/drawer.ts +14 -6
  4. package/console/components/fleet.ts +36 -13
  5. package/console/components/machine-pane.ts +61 -5
  6. package/console/components/nav.ts +54 -8
  7. package/console/conversation.ts +161 -0
  8. package/console/login.ts +123 -0
  9. package/console/main.ts +600 -60
  10. package/console/store.ts +611 -64
  11. package/console/style.css +231 -0
  12. package/docs/agents-block.md +2 -2
  13. package/docs/concepts/agents-and-turns.md +142 -29
  14. package/docs/concepts/architecture.md +60 -34
  15. package/docs/concepts/callers-and-hooks.md +205 -0
  16. package/docs/concepts/charts.md +13 -8
  17. package/docs/concepts/composition.md +10 -1
  18. package/docs/concepts/converge.md +7 -2
  19. package/docs/concepts/durable-runs.md +43 -16
  20. package/docs/concepts/effects.md +133 -50
  21. package/docs/concepts/gates.md +95 -25
  22. package/docs/concepts/machines-and-workflows.md +14 -4
  23. package/docs/concepts/pools-and-sources.md +193 -17
  24. package/docs/concepts/secrets-and-trust.md +186 -62
  25. package/docs/concepts/the-menu.md +14 -0
  26. package/docs/concepts/workspaces.md +135 -56
  27. package/docs/get-started/a-model-decides.md +14 -13
  28. package/docs/get-started/an-agent-in-a-sandbox.md +46 -35
  29. package/docs/get-started/connect-a-model.md +1 -1
  30. package/docs/get-started/create-an-instance.md +17 -14
  31. package/docs/get-started/have-your-assistant-write-a-machine.md +111 -40
  32. package/docs/get-started/install.md +4 -0
  33. package/docs/guides/add-tools-to-the-sandbox.md +72 -15
  34. package/docs/guides/answer-a-gate-from-a-forge.md +304 -0
  35. package/docs/guides/answer-a-gate.md +74 -37
  36. package/docs/guides/bind-open-parts.md +29 -12
  37. package/docs/guides/call-an-mcp-tool-from-a-machine.md +572 -0
  38. package/docs/guides/cancel-a-run.md +26 -16
  39. package/docs/guides/cut-a-worktree.md +560 -0
  40. package/docs/guides/fix-a-failed-converge.md +19 -7
  41. package/docs/guides/give-a-caller-a-scope.md +203 -0
  42. package/docs/guides/give-an-agent-mcp-tools.md +422 -0
  43. package/docs/guides/iterate-on-a-machine-on-kind.md +10 -9
  44. package/docs/guides/let-an-agent-write-a-chart.md +14 -7
  45. package/docs/guides/look-inside-a-sandbox.md +115 -42
  46. package/docs/guides/move-from-kind-to-a-shared-cluster.md +16 -0
  47. package/docs/guides/open-the-console.md +63 -14
  48. package/docs/guides/push-and-sign-a-branch.md +67 -21
  49. package/docs/guides/read-a-conversation.md +225 -0
  50. package/docs/guides/run-a-chart-by-name.md +17 -16
  51. package/docs/guides/run-a-command-or-call-a-url.md +84 -41
  52. package/docs/guides/run-one-worker-per-item.md +34 -27
  53. package/docs/guides/set-an-agents-access-and-dials.md +69 -22
  54. package/docs/guides/size-a-workspace.md +19 -6
  55. package/docs/guides/start-a-run-for-each-alert.md +290 -0
  56. package/docs/guides/start-a-run-from-a-run.md +18 -16
  57. package/docs/guides/start-a-run.md +24 -18
  58. package/docs/guides/steer-an-agent.md +332 -0
  59. package/docs/guides/use-a-hosted-provider.md +7 -1
  60. package/docs/guides/watch-a-run.md +146 -117
  61. package/docs/guides/write-a-hook-kind.md +238 -0
  62. package/docs/guides/write-a-tool-as-an-mcp-server.md +351 -0
  63. package/docs/guides/write-a-workflow.md +18 -8
  64. package/docs/llms.txt +110 -23
  65. package/docs/reference/authoring-surface/agent.md +35 -12
  66. package/docs/reference/authoring-surface/answer.md +20 -4
  67. package/docs/reference/authoring-surface/arg.md +28 -6
  68. package/docs/reference/authoring-surface/basic.md +1 -1
  69. package/docs/reference/authoring-surface/bearer.md +1 -1
  70. package/docs/reference/authoring-surface/branchname.md +15 -0
  71. package/docs/reference/authoring-surface/carry.md +23 -0
  72. package/docs/reference/authoring-surface/chartschema.md +1 -1
  73. package/docs/reference/authoring-surface/chartschemafor.md +1 -1
  74. package/docs/reference/authoring-surface/command.md +37 -22
  75. package/docs/reference/authoring-surface/customize.md +4 -1
  76. package/docs/reference/authoring-surface/defineconfig.md +1 -1
  77. package/docs/reference/authoring-surface/defineevent.md +1 -1
  78. package/docs/reference/authoring-surface/dispatch.md +5 -4
  79. package/docs/reference/authoring-surface/fail.md +18 -5
  80. package/docs/reference/authoring-surface/file.md +37 -17
  81. package/docs/reference/authoring-surface/frompick.md +1 -1
  82. package/docs/reference/authoring-surface/gate.md +118 -0
  83. package/docs/reference/authoring-surface/group-agents.md +15 -0
  84. package/docs/reference/authoring-surface/group-charts.md +16 -0
  85. package/docs/reference/authoring-surface/group-composition.md +25 -0
  86. package/docs/reference/authoring-surface/group-config.md +17 -0
  87. package/docs/reference/authoring-surface/group-effects.md +48 -0
  88. package/docs/reference/authoring-surface/group-failure.md +13 -0
  89. package/docs/reference/authoring-surface/group-gates.md +16 -0
  90. package/docs/reference/authoring-surface/group-machine-and-events.md +15 -0
  91. package/docs/reference/authoring-surface/group-steering.md +12 -0
  92. package/docs/reference/authoring-surface/group-types-these-signatures-name.md +137 -0
  93. package/docs/reference/authoring-surface/group-workspaces-and-repos.md +15 -0
  94. package/docs/reference/authoring-surface/http.md +109 -9
  95. package/docs/reference/authoring-surface/isfailure.md +1 -1
  96. package/docs/reference/authoring-surface/isready.md +14 -0
  97. package/docs/reference/authoring-surface/jr2setup.md +14 -4
  98. package/docs/reference/authoring-surface/mcp.md +107 -0
  99. package/docs/reference/authoring-surface/open.md +41 -8
  100. package/docs/reference/authoring-surface/openbody.md +1 -1
  101. package/docs/reference/authoring-surface/paramsof.md +23 -5
  102. package/docs/reference/authoring-surface/pool.md +79 -11
  103. package/docs/reference/authoring-surface/push.md +31 -13
  104. package/docs/reference/authoring-surface/readyof.md +21 -0
  105. package/docs/reference/authoring-surface/reread.md +19 -0
  106. package/docs/reference/authoring-surface/secret.md +26 -5
  107. package/docs/reference/authoring-surface/sentby.md +1 -1
  108. package/docs/reference/authoring-surface/skip.md +22 -0
  109. package/docs/reference/authoring-surface/source.md +59 -4
  110. package/docs/reference/authoring-surface/steer.md +93 -0
  111. package/docs/reference/authoring-surface/text.md +1 -1
  112. package/docs/reference/authoring-surface/type-agentdefinition.md +16 -3
  113. package/docs/reference/authoring-surface/type-agentmcpserver.md +54 -0
  114. package/docs/reference/authoring-surface/type-agentslots.md +4 -1
  115. package/docs/reference/authoring-surface/type-anyframepath.md +14 -0
  116. package/docs/reference/authoring-surface/type-anyworktreepath.md +15 -0
  117. package/docs/reference/authoring-surface/type-bindactors.md +14 -0
  118. package/docs/reference/authoring-surface/type-binding.md +6 -7
  119. package/docs/reference/authoring-surface/type-caller.md +40 -0
  120. package/docs/reference/authoring-surface/type-callerrecord.md +32 -0
  121. package/docs/reference/authoring-surface/type-carry.md +19 -0
  122. package/docs/reference/authoring-surface/type-chainlink.md +3 -3
  123. package/docs/reference/authoring-surface/type-commandinput.md +4 -3
  124. package/docs/reference/authoring-surface/type-commandoptions.md +0 -22
  125. package/docs/reference/authoring-surface/type-commandoutput.md +23 -5
  126. package/docs/reference/authoring-surface/type-customize.md +20 -3
  127. package/docs/reference/authoring-surface/type-delivered.md +17 -0
  128. package/docs/reference/authoring-surface/type-deliveredevent.md +18 -0
  129. package/docs/reference/authoring-surface/type-dispatchdefinition.md +4 -3
  130. package/docs/reference/authoring-surface/type-dispatchoutput.md +9 -2
  131. package/docs/reference/authoring-surface/type-doorlessinput.md +19 -0
  132. package/docs/reference/authoring-surface/type-effectbinding.md +12 -2
  133. package/docs/reference/authoring-surface/type-filebody.md +4 -8
  134. package/docs/reference/authoring-surface/type-framepath.md +14 -0
  135. package/docs/reference/authoring-surface/type-gatebinding.md +15 -0
  136. package/docs/reference/authoring-surface/type-gatehooks.md +12 -0
  137. package/docs/reference/authoring-surface/type-gatelook.md +37 -0
  138. package/docs/reference/authoring-surface/type-gateoutcome.md +32 -0
  139. package/docs/reference/authoring-surface/type-gatereply.md +19 -0
  140. package/docs/reference/authoring-surface/type-gateslot.md +21 -0
  141. package/docs/reference/authoring-surface/type-gateslotinput.md +13 -0
  142. package/docs/reference/authoring-surface/type-gateslotparts.md +18 -0
  143. package/docs/reference/authoring-surface/type-gateslots.md +12 -0
  144. package/docs/reference/authoring-surface/type-gatetypesat.md +13 -0
  145. package/docs/reference/authoring-surface/type-hostinjectedinput.md +3 -5
  146. package/docs/reference/authoring-surface/type-httpdefinition.md +6 -3
  147. package/docs/reference/authoring-surface/type-httpfileinput.md +20 -0
  148. package/docs/reference/authoring-surface/type-httpoutput.md +8 -2
  149. package/docs/reference/authoring-surface/type-jr2config.md +37 -2
  150. package/docs/reference/authoring-surface/type-lateroutcome.md +21 -0
  151. package/docs/reference/authoring-surface/type-lends.md +5 -1
  152. package/docs/reference/authoring-surface/type-lookoutput.md +14 -0
  153. package/docs/reference/authoring-surface/type-mcpcalloutput.md +78 -0
  154. package/docs/reference/authoring-surface/type-mcpnotreturned.md +42 -0
  155. package/docs/reference/authoring-surface/type-mcpoptions.md +47 -0
  156. package/docs/reference/authoring-surface/type-mcpoutput.md +50 -0
  157. package/docs/reference/authoring-surface/type-mcpreadoutput.md +53 -0
  158. package/docs/reference/authoring-surface/type-mcpremoteserver.md +50 -0
  159. package/docs/reference/authoring-surface/type-mcpserver.md +41 -0
  160. package/docs/reference/authoring-surface/type-mcpstdioserver.md +42 -0
  161. package/docs/reference/authoring-surface/type-namedsecret.md +4 -4
  162. package/docs/reference/authoring-surface/type-namestart.md +77 -0
  163. package/docs/reference/authoring-surface/type-noslotworkspaceoptions.md +1 -6
  164. package/docs/reference/authoring-surface/type-notworktreekeys.md +12 -0
  165. package/docs/reference/authoring-surface/type-openbodydeclaration.md +1 -1
  166. package/docs/reference/authoring-surface/type-openbodyoutput.md +1 -1
  167. package/docs/reference/authoring-surface/type-opencommandinput.md +7 -2
  168. package/docs/reference/authoring-surface/type-permissivenoslotworkspaceoptions.md +1 -6
  169. package/docs/reference/authoring-surface/type-permissiveworkspaceoptions.md +5 -10
  170. package/docs/reference/authoring-surface/type-poolnextinput.md +22 -0
  171. package/docs/reference/authoring-surface/type-poolspec.md +11 -6
  172. package/docs/reference/authoring-surface/type-pushinput.md +22 -3
  173. package/docs/reference/authoring-surface/type-pushoutput.md +33 -8
  174. package/docs/reference/authoring-surface/type-pushsourcespec.md +38 -0
  175. package/docs/reference/authoring-surface/type-readsourcespec.md +47 -0
  176. package/docs/reference/authoring-surface/type-reposlot.md +6 -6
  177. package/docs/reference/authoring-surface/type-reread.md +18 -0
  178. package/docs/reference/authoring-surface/type-runsconfig.md +41 -0
  179. package/docs/reference/authoring-surface/type-sandboxoptions.md +11 -4
  180. package/docs/reference/authoring-surface/type-sender.md +26 -1
  181. package/docs/reference/authoring-surface/type-sendercallerfield.md +14 -0
  182. package/docs/reference/authoring-surface/type-size.md +1 -1
  183. package/docs/reference/authoring-surface/type-skip.md +19 -0
  184. package/docs/reference/authoring-surface/type-slothandles.md +5 -13
  185. package/docs/reference/authoring-surface/type-sourcehooks.md +23 -0
  186. package/docs/reference/authoring-surface/type-sourcein.md +25 -0
  187. package/docs/reference/authoring-surface/type-sourcereply.md +18 -0
  188. package/docs/reference/authoring-surface/type-sourcespec.md +26 -17
  189. package/docs/reference/authoring-surface/type-sourceverdict.md +49 -0
  190. package/docs/reference/authoring-surface/type-standingpoolmachine.md +12 -0
  191. package/docs/reference/authoring-surface/type-standingpoolspec.md +51 -0
  192. package/docs/reference/authoring-surface/type-steerargs.md +20 -0
  193. package/docs/reference/authoring-surface/type-thinkinglevel.md +1 -1
  194. package/docs/reference/authoring-surface/type-usercontainer.md +1 -1
  195. package/docs/reference/authoring-surface/type-workspaced.md +30 -9
  196. package/docs/reference/authoring-surface/type-workspacehandles.md +5 -6
  197. package/docs/reference/authoring-surface/type-workspaceoptions.md +1 -13
  198. package/docs/reference/authoring-surface/type-worktreefound.md +16 -0
  199. package/docs/reference/authoring-surface/type-worktreeinput.md +56 -0
  200. package/docs/reference/authoring-surface/type-worktreekey.md +14 -0
  201. package/docs/reference/authoring-surface/type-worktreeoptions.md +29 -0
  202. package/docs/reference/authoring-surface/type-worktreeoutput.md +45 -0
  203. package/docs/reference/authoring-surface/type-worktreepath.md +16 -0
  204. package/docs/reference/authoring-surface/type-worktreeready.md +37 -0
  205. package/docs/reference/authoring-surface/type-worktreerefused.md +21 -0
  206. package/docs/reference/authoring-surface/workspace.md +66 -38
  207. package/docs/reference/authoring-surface/worktree.md +71 -0
  208. package/docs/reference/authoring-surface.md +88 -147
  209. package/docs/reference/cli.md +413 -74
  210. package/docs/reference/config.md +248 -6
  211. package/docs/reference/decisions/0001-operator-owned-generic-sandbox.md +10 -9
  212. package/docs/reference/decisions/0002-duplex-streaming-actor.md +81 -14
  213. package/docs/reference/decisions/0004-worktree-provisioning-model.md +27 -21
  214. package/docs/reference/decisions/0005-sandbox-pod-composition.md +39 -25
  215. package/docs/reference/decisions/0006-agent-control-surface.md +6 -3
  216. package/docs/reference/decisions/0007-durable-machine-state.md +1 -1
  217. package/docs/reference/decisions/0009-cli-and-instance-interface.md +150 -49
  218. package/docs/reference/decisions/0010-bdd-acceptance-tests.md +5 -3
  219. package/docs/reference/decisions/0011-workflow-defined-events.md +256 -12
  220. package/docs/reference/decisions/0012-workspace-wrapper-machine.md +39 -32
  221. package/docs/reference/decisions/0013-the-agent-reaches-its-machine-through-a-container-it-cannot-read.md +54 -30
  222. package/docs/reference/decisions/0014-observation-is-open-run-state-is-not.md +53 -27
  223. package/docs/reference/decisions/0015-authoring-surface-absorbs-the-mechanism.md +26 -16
  224. package/docs/reference/decisions/0016-agent-turn-mechanics-are-internal.md +9 -7
  225. package/docs/reference/decisions/0017-pool-over-a-source-port.md +226 -10
  226. package/docs/reference/decisions/0018-instance-agents-are-definitions-jr2-assembles-the-harness.md +15 -7
  227. package/docs/reference/decisions/0019-one-converging-command-against-the-current-context.md +53 -27
  228. package/docs/reference/decisions/0021-workspace-continuity-is-a-lease-that-answers-back.md +16 -2
  229. package/docs/reference/decisions/0022-observation-is-a-level-triggered-feed.md +4 -4
  230. package/docs/reference/decisions/0023-the-harness-prints-the-conversation.md +124 -43
  231. package/docs/reference/decisions/0024-an-agents-turn-ends-with-the-state-that-asked-for-it.md +36 -38
  232. package/docs/reference/decisions/0025-cancel-ends-a-run-stop-parks-it.md +10 -5
  233. package/docs/reference/decisions/0027-the-harness-is-jr2s-own-server-flue-retires-the-wire-stays.md +16 -7
  234. package/docs/reference/decisions/0028-what-an-agent-may-do-to-the-workspace-is-part-of-its-definition.md +36 -19
  235. package/docs/reference/decisions/0029-a-menu-is-fixed-for-a-conversation-and-a-turn-is-told-its-allowed-picks.md +18 -10
  236. package/docs/reference/decisions/0030-a-snapshot-names-the-machine-it-was-written-under.md +3 -2
  237. package/docs/reference/decisions/0031-menu-only-agents-run-on-the-instance-harness.md +23 -15
  238. package/docs/reference/decisions/0032-the-console-unlocks-with-a-callers-credential.md +101 -0
  239. package/docs/reference/decisions/0033-a-machine-declares-the-input-that-starts-it.md +22 -22
  240. package/docs/reference/decisions/0034-the-console-renders-with-preact-and-the-server-erases-the-types.md +6 -6
  241. package/docs/reference/decisions/0037-an-instance-builds-its-sandbox-images-jr2-injects-the-harness.md +13 -12
  242. package/docs/reference/decisions/0049-a-machine-carries-its-parts-and-composes-by-invoke.md +23 -23
  243. package/docs/reference/decisions/0050-what-code-names-config-declares-what-the-cli-names-discovery-finds.md +6 -1
  244. package/docs/reference/decisions/0051-a-repo-is-a-slot-on-the-workspace-and-a-cache-on-the-node.md +57 -46
  245. package/docs/reference/decisions/0052-a-sandbox-lands-where-an-ordinary-pod-lands-and-the-cache-follows-it.md +5 -0
  246. package/docs/reference/decisions/0053-a-fetch-inside-the-pod-asks-the-node-cache-and-the-cache-asks-the-remote.md +20 -8
  247. package/docs/reference/decisions/0054-the-kit-ships-machines-and-a-shipped-machine-leaves-its-parts-open.md +55 -40
  248. package/docs/reference/decisions/0055-a-release-is-a-pushed-tag-and-the-publish-guard-is-the-credential.md +14 -13
  249. package/docs/reference/decisions/0057-a-turn-is-its-frame-its-dials-and-whether-it-continues.md +31 -24
  250. package/docs/reference/decisions/0058-a-harness-answers-the-orchestrator-alone.md +18 -10
  251. package/docs/reference/decisions/0059-a-harness-holds-stand-ins-and-the-custodian-holds-the-keys.md +137 -86
  252. package/docs/reference/decisions/0062-jr2-briefs-the-agent-on-its-seat-never-on-its-task.md +165 -91
  253. package/docs/reference/decisions/0063-the-orchestrator-watches-the-cluster.md +7 -7
  254. package/docs/reference/decisions/0064-a-workspace-waits-for-capacity.md +2 -2
  255. package/docs/reference/decisions/0065-a-persist-survives-a-crash-and-history-is-kept-for-a-set-time.md +109 -0
  256. package/docs/reference/decisions/0066-a-model-tier-runs-a-real-model-and-a-change-to-what-it-reads-runs-the-tier.md +53 -23
  257. package/docs/reference/decisions/0067-an-effect-is-an-actor-slot-and-runs-at-most-once-unless-marked-idempotent.md +221 -153
  258. package/docs/reference/decisions/0068-an-effector-holds-an-effects-secrets-and-signs-its-wire.md +161 -96
  259. package/docs/reference/decisions/0069-the-orchestrator-is-a-kit-image-and-an-instance-publishes-its-assembly.md +32 -9
  260. package/docs/reference/decisions/0070-a-machine-lends-its-parts-to-a-chart.md +48 -33
  261. package/docs/reference/decisions/0071-a-run-starts-a-run-through-a-dispatch-effect.md +56 -30
  262. package/docs/reference/decisions/0072-the-docs-ship-inside-the-kit-and-an-instances-agents-md-indexes-them.md +35 -25
  263. package/docs/reference/decisions/0073-a-machine-fails-a-run-with-fail-and-an-uncaught-failure-ends-it-failed.md +1 -1
  264. package/docs/reference/decisions/0075-a-machine-cuts-a-worktree-and-the-workspace-only-clones.md +296 -0
  265. package/docs/reference/decisions/0076-an-agents-control-credential-lives-only-where-no-workspace-code-runs.md +347 -0
  266. package/docs/reference/decisions/0077-jr2-requires-landlock-on-every-sandbox-node.md +79 -0
  267. package/docs/reference/decisions/0078-a-caller-comes-from-one-authenticator-seam-and-acts-within-its-scopes.md +285 -0
  268. package/docs/reference/decisions/0079-an-agent-holds-mcp-tools-a-machine-calls-them-as-an-effect-and-the-machine-is-the-approval.md +198 -0
  269. package/docs/reference/decisions.md +9 -4
  270. package/docs/reference/glossary.md +138 -45
  271. package/docs/reference/hooks.md +1077 -0
  272. package/docs/reference/http-api.md +988 -123
  273. package/docs/reference/machines.md +0 -1
  274. package/docs/why.md +7 -5
  275. package/package.json +10 -3
  276. package/src/actor.ts +194 -42
  277. package/src/agent.ts +56 -6
  278. package/src/ambient.ts +3 -5
  279. package/src/assembly-checks.ts +530 -4
  280. package/src/callers.ts +245 -0
  281. package/src/chart.ts +238 -26
  282. package/src/charts.ts +9 -2
  283. package/src/config.ts +566 -7
  284. package/src/conversations.ts +453 -0
  285. package/src/custodian.lua +17 -5
  286. package/src/custodian.ts +257 -77
  287. package/src/customize.ts +154 -7
  288. package/src/dispatch-effect.ts +142 -26
  289. package/src/durability.ts +2 -0
  290. package/src/duration.ts +20 -0
  291. package/src/effect-checks.ts +52 -4
  292. package/src/effect.ts +401 -132
  293. package/src/effector-wire.ts +278 -30
  294. package/src/fail.ts +17 -4
  295. package/src/gate-brand.ts +16 -0
  296. package/src/gate.ts +634 -48
  297. package/src/harness-client.ts +84 -35
  298. package/src/harness-env.ts +33 -0
  299. package/src/held-secrets.ts +197 -39
  300. package/src/holds.ts +5 -2
  301. package/src/hook-kinds/discord.ts +92 -0
  302. package/src/hook-kinds/door.ts +107 -0
  303. package/src/hook-kinds/github.ts +89 -0
  304. package/src/hook-kinds/gitlab.ts +72 -0
  305. package/src/hook-kinds/hook.ts +7 -0
  306. package/src/hook-kinds/index.ts +465 -0
  307. package/src/hook-kinds/slack.ts +151 -0
  308. package/src/hook-kinds/webhook.ts +113 -0
  309. package/src/hooks.ts +506 -0
  310. package/src/http-effect.ts +164 -70
  311. package/src/http.ts +933 -99
  312. package/src/index.ts +30 -5
  313. package/src/instance.ts +196 -26
  314. package/src/internal.ts +23 -3
  315. package/src/kube-client.ts +6 -3
  316. package/src/machine-doc.ts +29 -5
  317. package/src/mcp-effect.ts +424 -0
  318. package/src/model-keys.ts +24 -0
  319. package/src/mount-digest.ts +41 -7
  320. package/src/names.ts +82 -7
  321. package/src/notices.ts +576 -59
  322. package/src/open-body.ts +110 -30
  323. package/src/open-effect.ts +17 -4
  324. package/src/open.ts +40 -7
  325. package/src/parts.ts +125 -35
  326. package/src/party.ts +35 -1
  327. package/src/pick.ts +43 -9
  328. package/src/pool.ts +1172 -172
  329. package/src/registration.ts +249 -17
  330. package/src/repo-identity.ts +7 -3
  331. package/src/repos.ts +20 -2
  332. package/src/run-host.ts +1614 -190
  333. package/src/run-list.ts +191 -0
  334. package/src/sandbox-effect.ts +217 -66
  335. package/src/sandbox-kube.ts +116 -21
  336. package/src/secret-placement.ts +248 -35
  337. package/src/server.ts +53 -4
  338. package/src/setup.ts +158 -38
  339. package/src/snapshot-store.ts +565 -48
  340. package/src/steer.ts +111 -0
  341. package/src/stub-harness.ts +6 -2
  342. package/src/tokens.ts +362 -46
  343. package/src/vocabulary.ts +23 -4
  344. package/src/wire.ts +27 -10
  345. package/src/workspace.ts +314 -259
  346. package/src/worktree.ts +249 -0
  347. package/docs/reference/authoring-surface/type-noslotspec.md +0 -26
  348. package/docs/reference/authoring-surface/type-workspacespec.md +0 -37
  349. package/docs/reference/decisions/0032-the-console-unlocks-with-the-instance-token.md +0 -61
  350. package/docs/reference/decisions/0065-a-persist-survives-a-crash-and-history-is-a-week.md +0 -65
@@ -9,8 +9,9 @@ See where a run is and what its [Agents](../reference/glossary.md#agent) do, in
9
9
  [Console](../reference/glossary.md#console) and the pod log of an Agent.
10
10
 
11
11
  The CLI shows the status of a run: where its [Machine](../reference/glossary.md#machine) is, its context, and its open
12
- [Gates](../reference/glossary.md#gate). The Console shows where the Machine is and, with the Instance token, the open
13
- Gates. The pod log shows the conversation of each Agent: its prompts, its text, and its calls.
12
+ [Gates](../reference/glossary.md#gate). The Console shows where the Machine is and, with the credential of a
13
+ [Caller](../reference/glossary.md#caller) that has the `answer` scope, the open Gates. `jr2 logs` and the pod log show
14
+ the [Conversation](../reference/glossary.md#conversation) of each Agent: its prompts, its text, and its calls.
14
15
 
15
16
  The examples on this page use a run of the [Workflow](../reference/glossary.md#workflow) `release`. Its Gate `review`
16
17
  waits for `approve` or `reject`. [Answer a Gate](answer-a-gate.md) gives the file `workflows/release.ts`. In the
@@ -34,7 +35,7 @@ jr2 run release --input '{"version":"2.0.0"}' --detach
34
35
 
35
36
  ```text
36
37
  → context <context> / namespace <namespace>
37
- {"runId":"a2d8b5b5-645c-44d2-8175-a949493e2320"}
38
+ {"runId":"41ca7842-786f-44ca-9083-47109500da5f"}
38
39
  ```
39
40
 
40
41
  Your run ids, instance ids and `assembly` hash are different from the values on this page.
@@ -49,49 +50,78 @@ jr2 runs
49
50
 
50
51
  ```text
51
52
  → context <context> / namespace <namespace>
52
- workflows:
53
- ping (machine)
54
- release (machine)
55
- [{"runId":"a2d8b5b5-645c-44d2-8175-a949493e2320","workflow":"release","instanceId":"6242963e-76d0-4acd-ac86-09359a29912f","status":"active","value":"review","context":{"version":"2.0.0"},"children":[],"waiting":[],"held":[],"assembly":"28c844453c20"}]
53
+ [{"runId":"41ca7842-786f-44ca-9083-47109500da5f","workflow":"release","status":"active","startedBy":{"kind":"caller","via":"token","name":"instance","onBehalfOf":"kubernetes-admin"},"startedAt":"2026-11-06T19:17:04.653Z","assembly":"19d0bf0cbe10","openGates":1}]
56
54
  ```
57
55
 
58
- `jr2 runs` prints a JSON array of the runs that did not end. On stderr, it first lists the Workflows that a run can
59
- start, each with where it comes from: `machine`, `chart file` or `chart`. A Chart wrapper lists its named Charts under
60
- it. `jr2 runs --workflows` prints that list as the JSON result. To read a run that ended, use `jr2 status <run id>`. A
61
- run with a [Workspace](../reference/glossary.md#workspace) that waits for capacity also has `placing`: the path of each
62
- such Workspace in the run. `jr2 status` tells why it waits. A run that a `dispatch`
63
- [Effect](../reference/glossary.md#effect) started has `dispatchedBy` after its id: the run that started it, the slot of
64
- the Effect, the id of the Effect (`effect`), and its `depth` in the chain.
65
- [Start a run from a run](start-a-run-from-a-run.md) shows it.
56
+ `jr2 runs` prints a JSON array of the runs that did not end, the newest start first. Each item is a summary of the run:
57
+ its id, its Workflow, its status, who started it and when, its [Assembly](../reference/glossary.md#assembly), and the
58
+ number of its open Gates (`openGates`). `--status ended` lists the runs that ended, and `--status all` lists both.
59
+ `--workflow` and `--since` (such as `7d`) filter the list. [`jr2 workflows`](../reference/cli.md#workflows) lists the
60
+ Workflows that a run can start. To read the state and the context of a run, use `jr2 status <run id>`. A run with a
61
+ [Workspace](../reference/glossary.md#workspace) that waits for capacity also has `placing`: the path of each such
62
+ Workspace in the run. `jr2 status` tells why it waits. A run that a `dispatch` [Effect](../reference/glossary.md#effect)
63
+ started has `dispatchedBy`: the run that started it, the slot of the Effect, the id of the Effect (`effect`), and its
64
+ `depth` in the chain. [Start a run from a run](start-a-run-from-a-run.md) shows it.
65
+
66
+ ## List the runs that ended
67
+
68
+ Give `--status ended` to list the runs that ended. Give `--workflow` and `--since` to make the list shorter. `--since`
69
+ takes a duration, such as `2h` or `7d`, or an ISO-8601 time:
70
+
71
+ ```sh
72
+ jr2 runs --status ended --workflow release --since 7d
73
+ ```
74
+
75
+ ```text
76
+ → context <context> / namespace <namespace>
77
+ [{"runId":"cad78069-0d8d-4c04-9cf4-3f771693274f","workflow":"release","status":"done","startedBy":{"kind":"caller","via":"token","name":"instance","onBehalfOf":"kubernetes-admin"},"startedAt":"2026-11-06T19:16:37.594Z","endedAt":"2026-11-06T19:16:39.762Z","assembly":"19d0bf0cbe10","openGates":0},{"runId":"a4099c00-88a6-4add-8068-dcf39e8c4224","workflow":"release","status":"done","startedBy":{"kind":"caller","via":"token","name":"instance","onBehalfOf":"kubernetes-admin"},"startedAt":"2026-11-06T19:16:30.787Z","endedAt":"2026-11-06T19:16:34.593Z","assembly":"19d0bf0cbe10","openGates":0},{"runId":"08b42407-1c4f-4776-9879-7c505bfa6695","workflow":"release","status":"done","startedBy":{"kind":"caller","via":"token","name":"instance","onBehalfOf":"kubernetes-admin"},"startedAt":"2026-11-06T19:16:18.276Z","endedAt":"2026-11-06T19:16:22.355Z","assembly":"19d0bf0cbe10","openGates":0},{"runId":"342fef91-53a1-4640-87bf-6fb4395beebf","workflow":"release","status":"done","startedBy":{"kind":"caller","via":"token","name":"instance","onBehalfOf":"kubernetes-admin"},"startedAt":"2026-11-06T19:16:00.147Z","endedAt":"2026-11-06T19:16:05.091Z","assembly":"19d0bf0cbe10","openGates":0},{"runId":"0c948d65-fd6f-453a-87fa-71ec00c7fe68","workflow":"release","status":"failed","reason":"The changelog is not ready.","startedBy":{"kind":"caller","via":"token","name":"instance","onBehalfOf":"kubernetes-admin"},"startedAt":"2026-11-06T19:15:39.018Z","endedAt":"2026-11-06T19:15:52.902Z","assembly":"19d0bf0cbe10","openGates":0}]
78
+ ```
79
+
80
+ An ended run has `endedAt`. `reason` tells why a run is `failed`, `error`, `lost` or `drifted`. `--status` also takes a
81
+ comma list of statuses, such as `--status failed,error`. jr2 keeps an ended run for
82
+ [`runs.retain`](../reference/config.md#runs), 30 days by default. `jr2 runs` reads every page of the list.
83
+ [`GET /runs`](../reference/http-api.md#get-runs) gives the list one page at a time, with a `cursor`.
66
84
 
67
85
  ## Read the status of a run
68
86
 
69
87
  Run [`jr2 status`](../reference/cli.md#status) with the run id. It reads a run that ended too:
70
88
 
71
89
  ```sh
72
- jr2 status a2d8
90
+ jr2 status 41ca
73
91
  ```
74
92
 
75
93
  ```text
76
94
  → context <context> / namespace <namespace>
77
- {"runId":"a2d8b5b5-645c-44d2-8175-a949493e2320","workflow":"release","instanceId":"6242963e-76d0-4acd-ac86-09359a29912f","status":"active","value":"review","context":{"version":"2.0.0"},"children":[],"waiting":[],"held":[],"assembly":"28c844453c20","gates":[{"gate":"review","path":["review"],"accepts":[{"name":"approve","description":"Release this version.","input":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{},"additionalProperties":false}},{"name":"reject","description":"Do not release this version. Say why.","input":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"reason":{"type":"string"}},"required":["reason"],"additionalProperties":false}}],"acceptsNow":["approve","reject"],"meta":{"version":"2.0.0"}}]}
95
+ {"runId":"41ca7842-786f-44ca-9083-47109500da5f","workflow":"release","instanceId":"a17469b8-b648-44dc-acb9-dcce6fcb81ad","startedAt":"2026-11-06T19:17:04.653Z","startedBy":{"kind":"caller","via":"token","name":"instance","onBehalfOf":"kubernetes-admin"},"status":"active","value":"review","context":{"version":"2.0.0"},"children":[],"waiting":[],"held":[],"assembly":"19d0bf0cbe10","gates":[{"gate":"review","path":["review"],"accepts":[{"name":"approve","description":"Release this version.","input":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{},"additionalProperties":false}},{"name":"reject","description":"Do not release this version. Say why.","input":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"reason":{"type":"string","minLength":1}},"required":["reason"],"additionalProperties":false}}],"acceptsNow":["approve","reject"],"meta":{"version":"2.0.0"}}]}
96
+ started by: token/instance on behalf of kubernetes-admin
78
97
  ```
79
98
 
80
99
  The status is a [`RunStatus`](../reference/http-api.md#type-runstatus), with the open Gates of the run:
81
100
 
82
- | Field | What it holds |
83
- | ---------- | --------------------------------------------------------------------------------------------------------------------------------- |
84
- | `status` | `active` while the run continues. `done`, `failed`, `error` or `cancelled` when it ended. `drifted` when jr2 did not continue it. |
85
- | `value` | The state of the root Machine. |
86
- | `context` | The context of the root Machine. |
87
- | `children` | The Machines that the run invokes now, such as its Workspaces, each with its state. |
88
- | `waiting` | Each Workspace that waits for capacity: what it waits for, since when, and the words of the scheduler or the quota. |
89
- | `held` | Each [outstanding](../reference/glossary.md#outstanding) pick of an Agent: the Agent, the pick, and since when. |
90
- | `fault` | The error, when the status is `error`. |
91
- | `output` | The output of the Machine, when the run ended. For `failed`, the Failure: `{ reason, detail? }`. |
92
- | `reason` | Why jr2 set the status, when the Machine did not set it, such as `drifted`. |
93
- | `assembly` | The hash of the [Assembly](../reference/glossary.md#assembly) that the run started under, and holds. |
94
- | `gates` | Each open Gate. [Answer a Gate](answer-a-gate.md) explains its fields. |
101
+ | Field | What it holds |
102
+ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
103
+ | `status` | `active` while the run continues. `done`, `failed`, `error` or `cancelled` when it ended. `drifted` when jr2 did not continue it. |
104
+ | `value` | The state of the root Machine. |
105
+ | `context` | The context of the root Machine. |
106
+ | `children` | The Machines that the run invokes now, such as its Workspaces, each with its state. |
107
+ | `waiting` | Each Workspace that waits for capacity: what it waits for, since when, and the words of the scheduler or the quota. |
108
+ | `held` | Each [outstanding](../reference/glossary.md#outstanding) pick of an Agent: the Agent, the pick, and since when. |
109
+ | `fault` | The error, when the status is `error`. |
110
+ | `output` | The output of the Machine, when the run ended. For `failed`, the Failure: `{ reason, detail? }`. |
111
+ | `reason` | Why jr2 set the status, when the Machine did not set it, such as `drifted`. |
112
+ | `assembly` | The hash of the Assembly that the run started under, and holds. |
113
+ | `gates` | Each open Gate. [Answer a Gate](answer-a-gate.md) explains its fields. |
114
+ | `worktrees` | Each [Worktree](../reference/glossary.md#worktree) that the run cut: its `slot`, its `path`, and its `branch`, which is `null` when the Worktree is detached. |
115
+
116
+ `jr2 status` also prints on stderr who started the run, from `startedBy`: `started by: <via>/<name>`, then the name that
117
+ jr2 shows and `on behalf of <party>` when the [Caller](../reference/glossary.md#caller) gave them. For a run that a
118
+ `dispatch` started, `jr2 status` reads each run of the chain, up to the first run that a Caller started. Then the line
119
+ also names the runs between, as `through run <run id> (<slot>)`. A run that jr2 started says `started by: jr2 (<why>)`.
120
+ A cancelled run also prints `cancelled by: <via>/<name>`.
121
+
122
+ For a run that cut a Worktree, `jr2 status` also prints one line on stderr for each cut:
123
+ `worktree: <path> (<slot>), branch <branch>`, or `worktree: <path> (<slot>), detached`. jr2 reads each line from the
124
+ record of the cut, so these lines do not change when an Agent changes the branch in the Worktree.
95
125
 
96
126
  [Durable runs](../concepts/durable-runs.md) tells how long jr2 keeps a run that ended.
97
127
 
@@ -100,40 +130,54 @@ and the [Repos](../reference/glossary.md#repo) of the Instance.
100
130
 
101
131
  ## Follow a run
102
132
 
103
- Run [`jr2 logs`](../reference/cli.md#logs) with `-f`. It prints the status now, then each change, until the run ends:
133
+ Run [`jr2 watch`](../reference/cli.md#watch). It prints the state now, then each change, until the run ends. It prints
134
+ the lines that `jr2 run` prints while it is attached:
104
135
 
105
136
  ```sh
106
- jr2 logs -f a2d8
137
+ jr2 watch 41ca
107
138
  ```
108
139
 
109
- While `jr2 logs -f` runs, send `approve` to the Gate in a second terminal:
140
+ While `jr2 watch` runs, send `approve` to the Gate in a second terminal:
110
141
 
111
142
  ```sh
112
- jr2 send a2d8 --gate review --event approve
143
+ jr2 send 41ca --gate review --event approve
144
+ ```
145
+
146
+ The run ends. `jr2 watch` prints the state when it attached, then the last status, and stops:
147
+
148
+ ```text
149
+ → context <context> / namespace <namespace>
150
+ run 41ca7842-786f-44ca-9083-47109500da5f (release) — attached
151
+ → active "review"
152
+ → done "released"
113
153
  ```
114
154
 
115
- The run ends. `jr2 logs -f` prints the status when it attached, then the last status, and stops:
155
+ When the run ended before you attach, `jr2 watch` prints only its last status. With `--json`, it prints each status as
156
+ one JSON line:
157
+
158
+ ```sh
159
+ jr2 watch 41ca --json
160
+ ```
116
161
 
117
162
  ```text
118
163
  → context <context> / namespace <namespace>
119
- {"runId":"a2d8b5b5-645c-44d2-8175-a949493e2320","workflow":"release","instanceId":"6242963e-76d0-4acd-ac86-09359a29912f","status":"active","value":"review","context":{"version":"2.0.0"},"children":[],"waiting":[],"held":[],"assembly":"28c844453c20"}
120
- {"runId":"a2d8b5b5-645c-44d2-8175-a949493e2320","workflow":"release","instanceId":"6242963e-76d0-4acd-ac86-09359a29912f","status":"done","value":"released","context":{"version":"2.0.0"},"children":[],"waiting":[],"held":[],"assembly":"28c844453c20"}
164
+ {"runId":"41ca7842-786f-44ca-9083-47109500da5f","workflow":"release","instanceId":"a17469b8-b648-44dc-acb9-dcce6fcb81ad","startedAt":"2026-11-06T19:17:04.653Z","status":"done","value":"released","context":{"version":"2.0.0"},"children":[],"waiting":[],"held":[],"assembly":"19d0bf0cbe10","startedBy":{"kind":"caller","via":"token","name":"instance","onBehalfOf":"kubernetes-admin"},"answers":[{"gate":"review","type":"approve","at":"2026-11-06T19:17:14.022Z","answeredBy":{"via":"token","name":"instance","onBehalfOf":"kubernetes-admin"}}]}
121
165
  ```
122
166
 
123
- When the run ended before you attach, `jr2 logs -f` prints only its last status. Without `-f`, `jr2 logs` prints the
124
- status now, and stops. `jr2 logs` exits with `0` when it reads the run, also when the run ended with the status `error`.
125
- Read `status` in the last line.
167
+ After the last status of a run that failed, `jr2 watch` prints `failed: <reason>`, as `jr2 run` does. `jr2 watch` exits
168
+ with `0` when it reads the run, also when the run ended with the status `error`. Read `status` in the last status.
126
169
 
127
- `jr2 logs` prints each status as one JSON line on stdout. It prints the other activity of the run on stderr, one line
128
- for each item of activity:
170
+ Without `--json`, `jr2 watch` prints each line on stdout. With `--json`, it prints each status as one JSON line on
171
+ stdout, and the other activity of the run on stderr, one line for each item of activity:
129
172
 
130
- | Line | What happened |
131
- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
132
- | `emit <emit>` | The Machine sent an [Emit](../reference/glossary.md#emit). `<emit>` is its JSON. |
133
- | `retry <child> attempt <n> (<reason>)` | jr2 tries a [Turn](../reference/glossary.md#turn) of an Agent again. `<child>` names its Machine. `<reason>` says why. |
134
- | `placing <child>: waits for a node — <message>` | The [Sandbox](../reference/glossary.md#sandbox) of a Workspace waits for a node. With a quota, the line says `waits for quota`. |
135
- | `placed <child> after <n>s` | The Sandbox got its node after `<n>` seconds. |
136
- | ``child-error: `<child>` failed below <agent>'s pick `<pick>` — <error>`` | A child that an Agent's pick started failed. The Agent does not get this error. |
173
+ | Line | What happened |
174
+ | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
175
+ | `emit <emit>` | The Machine sent an [Emit](../reference/glossary.md#emit). `<emit>` is its JSON. |
176
+ | `retry <child> attempt <n> (<reason>)` | jr2 tries a [Turn](../reference/glossary.md#turn) of an Agent again. `<child>` names its Machine. `<reason>` says why. With `runaway reroll`, the Harness ended a [Runaway](../reference/glossary.md#runaway), and jr2 runs the Turn one more time in a new conversation. A second Runaway is an Agent fault. |
177
+ | `placing <child>: waits for a node — <message>` | The [Sandbox](../reference/glossary.md#sandbox) of a Workspace waits for a node. With a quota, the line says `waits for quota`. |
178
+ | `placed <child> after <n>s` | The Sandbox got its node after `<n>` seconds. |
179
+ | ``child-error: `<child>` failed below <agent>'s pick `<pick>` — <error>`` | A child that an Agent's pick started failed. The Agent does not get this error. |
180
+ | `looked: gate <gate> read its fact, and the run took "<event>"` | The look of a Gate slot read the fact that the Gate waits for, and the run took the event of its `until`. No Caller answered. |
137
181
 
138
182
  A line about the root Workspace of the run has no `<child>`. `jr2 run` prints the same lines, with two spaces before
139
183
  each line. It prints each change of status as `→ <status> <state>`.
@@ -148,8 +192,9 @@ each line. It prints each change of status as `→ <status> <state>`.
148
192
  - The `Activity` tab in the drawer lists the Emits of the runs of the Workflow that you selected. Each Emit shows the
149
193
  first 8 characters of the run id, and only the type of the Emit.
150
194
 
151
- To see more, type the Instance token in the `instance token` box in the nav. Push Enter. When the badge beside the box
152
- shows `live`:
195
+ To see more, type a Caller token, such as the Instance token, in the `Caller token` box in the nav. Push Enter. When the
196
+ badge beside the box shows `live`, the nav shows who the Console acts as, such as `as token/instance`. With the `answer`
197
+ and `read` scopes for the Workflow ([Open the Console](open-the-console.md) gives what each scope shows):
153
198
 
154
199
  - In the Fleet rail, `⚑` and a number show the open Gates of each run.
155
200
  - The `Attention` tab shows the open Gates, and you can answer them. See [Answer a Gate](answer-a-gate.md).
@@ -158,17 +203,20 @@ shows `live`:
158
203
  - For a run that you selected that ended `failed`, the Console shows the reason of its
159
204
  [Failure](../reference/glossary.md#failure): `failed: <reason>`, as `jr2 status` shows it. With no token, the rail
160
205
  shows only the status `failed`, in orange.
206
+ - For the run that you selected, the Console shows who started it, such as `started by token/ci`.
207
+ - The Fleet rail lists the ended runs of the Workflow under its live runs. The bottom drawer shows the conversation of
208
+ each Agent slot of the run that you selected ([Open the Console](open-the-console.md#read-a-conversation)).
161
209
 
162
210
  ## Watch from a program
163
211
 
164
212
  The [Orchestrator](../reference/glossary.md#orchestrator) sends the activity of a run as Server-Sent Events. A program
165
213
  can read them:
166
214
 
167
- | Route | Token | What it sends |
168
- | ---------------------------------------------------------------------------------------------------------- | -------------- | ---------------------------------------------------------------------------------------- |
169
- | [`GET /runs/:runId/events`](../reference/http-api.md#get-runs-runid-events) | Instance token | The full status of one run, its Emits, and its other activity, until it ends. |
170
- | [`GET /workflows/:name/runs/:runId/events`](../reference/http-api.md#get-workflows-name-runs-runid-events) | none | The state of one live run, and the type of each Emit, with no context. |
171
- | [`GET /workflows/:name/events`](../reference/http-api.md#get-workflows-name-events) | none | A `runs` event with all the live runs, then the same events for each run. It stays open. |
215
+ | Route | Token | What it sends |
216
+ | ---------------------------------------------------------------------------------------------------------- | ------------ | ---------------------------------------------------------------------------------------- |
217
+ | [`GET /runs/:runId/events`](../reference/http-api.md#get-runs-runid-events) | `read` scope | The full status of one run, its Emits, and its other activity, until it ends. |
218
+ | [`GET /workflows/:name/runs/:runId/events`](../reference/http-api.md#get-workflows-name-runs-runid-events) | none | The state of one live run, and the type of each Emit, with no context. |
219
+ | [`GET /workflows/:name/events`](../reference/http-api.md#get-workflows-name-events) | none | A `runs` event with all the live runs, then the same events for each run. It stays open. |
172
220
 
173
221
  The run of the steps above ended, and a feed of one run sends only a live run. Start a new run:
174
222
 
@@ -178,7 +226,7 @@ jr2 run release --input '{"version":"2.0.0"}' --detach
178
226
 
179
227
  ```text
180
228
  → context <context> / namespace <namespace>
181
- {"runId":"2a009f09-13d4-44ba-9e17-fd665acc7aa8"}
229
+ {"runId":"0e4a6a62-587e-4550-aee8-58642dde0637"}
182
230
  ```
183
231
 
184
232
  To read its feed, forward a port to the Orchestrator, as [Start a run](start-a-run.md#start-a-run-with-the-http-api)
@@ -198,10 +246,10 @@ The feed sends the status when you attached, then the last status, and closes:
198
246
 
199
247
  ```text
200
248
  event: status
201
- data: {"runId":"2a009f09-13d4-44ba-9e17-fd665acc7aa8","workflow":"release","status":"active","value":"review","children":[]}
249
+ data: {"runId":"0e4a6a62-587e-4550-aee8-58642dde0637","workflow":"release","status":"active","value":"review","children":[]}
202
250
 
203
251
  event: status
204
- data: {"runId":"2a009f09-13d4-44ba-9e17-fd665acc7aa8","workflow":"release","status":"done","value":"released","children":[]}
252
+ data: {"runId":"0e4a6a62-587e-4550-aee8-58642dde0637","workflow":"release","status":"done","value":"released","children":[]}
205
253
  ```
206
254
 
207
255
  The first event is the status when you attach. The feed of one run closes when the run ends. While the run waits, the
@@ -209,8 +257,23 @@ feed also sends a comment line, `:`, at intervals, to keep the connection open.
209
257
 
210
258
  ## Read an Agent's conversation
211
259
 
212
- The [Harness](../reference/glossary.md#harness) that runs an Agent's Turn prints the conversation to the log of its
213
- container, `harness`. Read it with `kubectl logs`. Add `-f` to follow it.
260
+ Run [`jr2 logs`](../reference/cli.md#logs) with the run id. It prints the conversation of each Agent of the run, in the
261
+ order of the time of each entry. Give an Agent slot or the name of an Agent to print only that Agent. Add `-f` to follow
262
+ the conversations while the run continues:
263
+
264
+ ```sh
265
+ jr2 logs <run id> coder -f
266
+ ```
267
+
268
+ The Orchestrator keeps each conversation for as long as it keeps the run, so `jr2 logs` also reads a run that ended.
269
+ [Read a conversation](read-a-conversation.md) tells what each line shows, how long jr2 keeps a conversation, and how the
270
+ Console shows it.
271
+
272
+ ## Read the pod log
273
+
274
+ The [Harness](../reference/glossary.md#harness) that runs an Agent's Turn also prints the conversation to the log of its
275
+ container, `harness`. The lines have the form that `jr2 logs` prints. Read them with `kubectl logs`. Add `-f` to follow
276
+ them. A cluster that sends its pod logs to a log store keeps them there for as long as that store keeps them.
214
277
 
215
278
  For a [Menu](../reference/glossary.md#menu)-only Agent, an Agent with `workspace: "none"`, read the log of the
216
279
  [Instance Harness](../reference/glossary.md#instance-harness):
@@ -220,81 +283,44 @@ kubectl -n <namespace> logs -f statefulset/jr2-instance-harness -c harness
220
283
  ```
221
284
 
222
285
  The Instance Harness runs the Turns of all the Menu-only Agents of the Instance. Thus its log can hold the lines of more
223
- than one run. Each line of a conversation holds its Instance ID, which starts with the run id. To read the lines of one
224
- run, keep the lines that hold `[<run id>/`:
286
+ than one run. Each line of a conversation holds its [Instance ID](../reference/glossary.md#instance-id), which starts
287
+ with the run id. To read the lines of one run, keep the lines that hold `[<run id>/`:
225
288
 
226
289
  ```sh
227
290
  kubectl -n <namespace> logs statefulset/jr2-instance-harness -c harness | grep -F '[<run id>/'
228
291
  ```
229
292
 
230
- For an Agent that works in a Workspace, read the log of its Sandbox. Find the Sandbox with the full run id, as
231
- [Look inside a Sandbox](look-inside-a-sandbox.md) shows. The pod has the name of the Sandbox:
293
+ For an Agent that works in a Workspace, read the log of its Sandbox. Find the Sandbox with
294
+ [`jr2 workspace ls`](../reference/cli.md#workspace-ls), as [Look inside a Sandbox](look-inside-a-sandbox.md) shows. The
295
+ pod has the name of the Sandbox, in the `SANDBOX` column:
232
296
 
233
297
  ```sh
234
- kubectl -n <namespace> get sandboxes -l jr2.dev/run=<run id>
298
+ jr2 workspace ls <run id>
235
299
  kubectl -n <namespace> logs -f <sandbox> -c harness
236
300
  ```
237
301
 
238
- For example, this is the log of a run of the `task` Workflow of
239
- [An Agent in a Sandbox](../get-started/an-agent-in-a-sandbox.md), with the prompt
240
- ``In docs/intro/repo, run `node bin/greet.js`. Then finish, with what it printed.``:
302
+ The log of a Sandbox also tells the story of its run, in lines that start with `[run]`. `jr2 logs` does not print these
303
+ lines:
241
304
 
242
305
  ```text
243
306
  jr2 harness serving on :8080
307
+ [run] [status] running · body: cutting
244
308
  [run] [status] running · body: working
245
- [run] [status] running · body: working
246
- [coder] [19b49b58-2ea4-4d79-b100-49aad6e12013/body/coder] [prompt] In docs/intro/repo, run `node bin/greet.js`. Then finish, with what it printed.
247
- [coder] [19b49b58-2ea4-4d79-b100-49aad6e12013/body/coder]
248
- [coder] [19b49b58-2ea4-4d79-b100-49aad6e12013/body/coder] Work in /work/target/jr2-task-19b49b58-2ea4-4d79-b100-49aad6e12013, on branch jr2/task-19b49b58-2ea4-4d79-b100-49aad6e12013 — your tools are rooted there, so a relative path lands inside it. Commit what you do there, then call finish.
249
- …
250
- [coder] [19b49b58-2ea4-4d79-b100-49aad6e12013/body/coder] [thinking] The user wants me to run `node bin/greet.js` inside `docs/intro/repo` directory. Let me navigate there and run it.
309
+ [coder] [9501dd2f-95ba-479b-b384-307c736a8aad/body/coder] [prompt] In docs/intro/repo, run `node bin/greet.js`. Then finish, with what it printed.
251
310
  …
252
- [coder] [19b49b58-2ea4-4d79-b100-49aad6e12013/body/coder] [bash] cd docs/intro/repo && node bin/greet.js
253
- [coder] [19b49b58-2ea4-4d79-b100-49aad6e12013/body/coder] [thinking] The script printed "hello, world". I should now finish with this summary.
254
- …
255
- [coder] [19b49b58-2ea4-4d79-b100-49aad6e12013/body/coder] [finish] {"summary":"Ran `node bin/greet.js` in docs/intro/repo, which printed: hello, world"}
256
- [coder] [19b49b58-2ea4-4d79-b100-49aad6e12013/body/coder] [finish answer] Delivered "finish" to the workflow (delivery afe6340b-fe10-4819-b545-8ebd1b9a3964). The workflow consumed it and moved on: your turn is over.
311
+ [coder] [9501dd2f-95ba-479b-b384-307c736a8aad/body/coder] [finish answer] Delivered "finish" to the workflow (delivery 1b61fa16-50b7-4202-b7ed-b46a6ead5930). The workflow consumed it and moved on: your turn is over.
257
312
  [run] [status] running · body: review
258
313
  ```
259
314
 
260
- The thinking, the calls and the text are the words of the model, so your log is different. Your ids are different too.
261
-
262
- Each line of a conversation starts with the name of the Agent in brackets, then the
263
- [Instance ID](../reference/glossary.md#instance-id) of the conversation in brackets. The Instance ID starts with the run
264
- id. The first line of each message then has a label in brackets. The next lines of the same message have no label:
265
-
266
- | Line | What it shows |
267
- | ------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
268
- | `[<agent>] [<iid>] [prompt] <text>` | A message that the model reads: the prompt of the Turn, or a message that jr2 adds to the Turn. |
269
- | `[<agent>] [<iid>] [thinking] <text>` | The thinking of the model. |
270
- | `[<agent>] [<iid>] [text] <text>` | The text of the model. |
271
- | `[<agent>] [<iid>] [<call>] <input>` | A call of a [Working tool](../reference/glossary.md#working-tools), or a pick from the Menu. `<input>` is a path for read, write and edit, the command for `bash`, or else JSON. |
272
- | `[<agent>] [<iid>] [<pick> answer] <text>` | The answer that the model got for a pick from its Menu. |
273
- | `[<agent>] [<iid>] [<pick> error] <text>` | An answer to a pick that the model reads as an error, such as a refusal. |
274
- | `[<agent>] [<iid>] [compacted] <text>` | The Harness made the context of the conversation smaller: `context <before> → ~<after> tokens (window <window>)`. |
275
- | `[<agent>] [<iid>] [thinking level] <text>` | The model has no thinking level of the name that the Turn asked for, and the line names the level that the model ran at. The Harness prints it one time for each Turn. |
276
-
277
- The log of a Sandbox also tells the story of its run, in lines that start with `[run]`. `[run] [status] <state>` gives
278
- the state of the run, then the state of each Machine that it invokes, separated by `·`, such as
279
- `running · body: working`. When the run ends, the line gives its status. `[run] [emit] <type> <payload>` gives an Emit.
280
- A Turn that runs in a different Harness shows only as `[<agent>] [admitted] <prompt>` and
315
+ `[run] [status] <state>` gives the state of the run, then the state of each Machine that it invokes, separated by `·`,
316
+ such as `running · body: working`. When the run ends, the line gives its status. `[run] [emit] <type> <payload>` gives
317
+ an Emit. A Turn that runs in a different Harness shows only as `[<agent>] [admitted] <prompt>` and
281
318
  `[<agent>] [pick] <pick> <input>`. `<input>` is the JSON of the input of the pick, and it is absent for a pick with no
282
319
  input. The lines of the story of the run have no Instance ID.
283
320
 
284
- The Harness does not print the result of a Working tool. For example, it does not print the text of a file that the
285
- Agent read, or the output of a command that the Agent ran.
286
-
287
- The Harness cuts an input that is longer than 2000 characters at its end, and marks the cut with `…`. It cuts a long
288
- answer to a pick in its middle, and marks the cut with `… [<n> characters cut] …`. The model reads the full text. The
289
- Harness cuts only the log.
290
-
291
321
  The log of a Sandbox goes away with its pod. The Workspace deletes its Sandbox when its body gets to its final state,
292
322
  and when a [Failure](../reference/glossary.md#failure) goes up through it. `jr2 send <run id> --event CANCEL` without
293
- `--keep` also deletes it. To keep the log, save it before then:
294
-
295
- ```sh
296
- kubectl -n <namespace> logs <sandbox> -c harness > <file>
297
- ```
323
+ `--keep` also deletes it. `jr2 logs` still reads the conversations after that.
298
324
 
299
325
  > **Caution**
300
326
  >
@@ -309,18 +335,21 @@ kubectl -n <namespace> logs <sandbox> -c harness > <file>
309
335
  - A prefix that no run id starts with is an error. The command exits with `1`: `no run "<prefix>"`
310
336
  - A prefix that more than one run id starts with is an error. The command lists the run ids, and exits with `1`:
311
337
  `error: run id "<prefix>" is ambiguous`
312
- - `GET /runs/:runId/events` refuses a call without the Instance token, with the status code `401`: `unauthorized`.
338
+ - `GET /runs/:runId/events` refuses a call without a Caller's credential, with the status code `401`: `unauthorized`. It
339
+ refuses a Caller without the `read` scope for the Workflow of the run with the status code `403`.
313
340
  - `GET /workflows/:name/runs/:runId/events` sends only a live run of that Workflow. For a different run, it refuses with
314
341
  the status code `404`: `no live run "<run id>" of "<workflow>"`
315
342
 
316
343
  ## Read next
317
344
 
318
345
  - [Durable runs](../concepts/durable-runs.md)
319
- - [ADR-0009](../reference/decisions/0009-cli-and-instance-interface.md): `jr2 runs`, `jr2 status`, `jr2 logs`, and run
320
- id prefixes.
346
+ - [ADR-0009](../reference/decisions/0009-cli-and-instance-interface.md): `jr2 runs`, `jr2 status`, `jr2 watch`,
347
+ `jr2 logs`, and run id prefixes.
321
348
  - [ADR-0014](../reference/decisions/0014-observation-is-open-run-state-is-not.md): what the Console and the feeds show
322
349
  without the token.
323
350
  - [ADR-0022](../reference/decisions/0022-observation-is-a-level-triggered-feed.md): the feeds.
324
- - [ADR-0023](../reference/decisions/0023-the-harness-prints-the-conversation.md): the conversation in the pod log.
351
+ - [ADR-0023](../reference/decisions/0023-the-harness-prints-the-conversation.md): the conversation in the pod log, and
352
+ the copy that the Orchestrator keeps.
325
353
  - [Architecture](../concepts/architecture.md): the Harness and the Instance Harness.
354
+ - [Read a conversation](read-a-conversation.md)
326
355
  - [Look inside a Sandbox](look-inside-a-sandbox.md)