@openagt/dashboard 0.0.0-stage → 0.9.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 (610) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +125 -2
  3. package/dist/agent-id.d.ts +13 -0
  4. package/dist/agent-id.d.ts.map +1 -0
  5. package/dist/agent-id.js +20 -0
  6. package/dist/agent-id.js.map +1 -0
  7. package/dist/agent-locks.d.ts +3 -0
  8. package/dist/agent-locks.d.ts.map +1 -0
  9. package/dist/agent-locks.js +40 -0
  10. package/dist/agent-locks.js.map +1 -0
  11. package/dist/agent-view.d.ts +39 -0
  12. package/dist/agent-view.d.ts.map +1 -0
  13. package/dist/agent-view.js +45 -0
  14. package/dist/agent-view.js.map +1 -0
  15. package/dist/bin.d.ts +3 -0
  16. package/dist/bin.d.ts.map +1 -0
  17. package/dist/bin.js +11 -0
  18. package/dist/bin.js.map +1 -0
  19. package/dist/branch-name.d.ts +8 -0
  20. package/dist/branch-name.d.ts.map +1 -0
  21. package/dist/branch-name.js +20 -0
  22. package/dist/branch-name.js.map +1 -0
  23. package/dist/bridge-browser.d.ts +217 -0
  24. package/dist/bridge-browser.d.ts.map +1 -0
  25. package/dist/bridge-browser.js +520 -0
  26. package/dist/bridge-browser.js.map +1 -0
  27. package/dist/browser-stream.d.ts +20 -0
  28. package/dist/browser-stream.d.ts.map +1 -0
  29. package/dist/browser-stream.js +51 -0
  30. package/dist/browser-stream.js.map +1 -0
  31. package/dist/browser.d.ts +16 -0
  32. package/dist/browser.d.ts.map +1 -0
  33. package/dist/browser.js +38 -0
  34. package/dist/browser.js.map +1 -0
  35. package/dist/built-in.d.ts +38 -0
  36. package/dist/built-in.d.ts.map +1 -0
  37. package/dist/built-in.js +119 -0
  38. package/dist/built-in.js.map +1 -0
  39. package/dist/chrome-extension/background.js +532 -0
  40. package/dist/chrome-extension/content.js +1475 -0
  41. package/dist/chrome-extension/driver-plan.js +41 -0
  42. package/dist/chrome-extension/fingerprint.js +43 -0
  43. package/dist/chrome-extension/manifest.json +31 -0
  44. package/dist/chrome-extension/options.html +48 -0
  45. package/dist/chrome-extension/options.js +122 -0
  46. package/dist/cli.d.ts +43 -0
  47. package/dist/cli.d.ts.map +1 -0
  48. package/dist/cli.js +186 -0
  49. package/dist/cli.js.map +1 -0
  50. package/dist/client.d.ts +16 -0
  51. package/dist/client.d.ts.map +1 -0
  52. package/dist/client.js +30 -0
  53. package/dist/client.js.map +1 -0
  54. package/dist/cloud-run-state.d.ts +27 -0
  55. package/dist/cloud-run-state.d.ts.map +1 -0
  56. package/dist/cloud-run-state.js +36 -0
  57. package/dist/cloud-run-state.js.map +1 -0
  58. package/dist/cloud-scratch-refs.d.ts +85 -0
  59. package/dist/cloud-scratch-refs.d.ts.map +1 -0
  60. package/dist/cloud-scratch-refs.js +275 -0
  61. package/dist/cloud-scratch-refs.js.map +1 -0
  62. package/dist/cloud-work.d.ts +66 -0
  63. package/dist/cloud-work.d.ts.map +1 -0
  64. package/dist/cloud-work.js +204 -0
  65. package/dist/cloud-work.js.map +1 -0
  66. package/dist/daemon-runtime.d.ts +42 -0
  67. package/dist/daemon-runtime.d.ts.map +1 -0
  68. package/dist/daemon-runtime.js +183 -0
  69. package/dist/daemon-runtime.js.map +1 -0
  70. package/dist/daemon-services.d.ts +37 -0
  71. package/dist/daemon-services.d.ts.map +1 -0
  72. package/dist/daemon-services.js +126 -0
  73. package/dist/daemon-services.js.map +1 -0
  74. package/dist/daemon-tick.d.ts +68 -0
  75. package/dist/daemon-tick.d.ts.map +1 -0
  76. package/dist/daemon-tick.js +97 -0
  77. package/dist/daemon-tick.js.map +1 -0
  78. package/dist/daemon.d.ts +65 -0
  79. package/dist/daemon.d.ts.map +1 -0
  80. package/dist/daemon.js +202 -0
  81. package/dist/daemon.js.map +1 -0
  82. package/dist/dashboard/activity.d.ts +41 -0
  83. package/dist/dashboard/activity.d.ts.map +1 -0
  84. package/dist/dashboard/activity.js +56 -0
  85. package/dist/dashboard/activity.js.map +1 -0
  86. package/dist/dashboard/agent-handoff.d.ts +244 -0
  87. package/dist/dashboard/agent-handoff.d.ts.map +1 -0
  88. package/dist/dashboard/agent-handoff.js +310 -0
  89. package/dist/dashboard/agent-handoff.js.map +1 -0
  90. package/dist/dashboard/bridge-endpoints.d.ts +158 -0
  91. package/dist/dashboard/bridge-endpoints.d.ts.map +1 -0
  92. package/dist/dashboard/bridge-endpoints.js +382 -0
  93. package/dist/dashboard/bridge-endpoints.js.map +1 -0
  94. package/dist/dashboard/bridge-question.d.ts +33 -0
  95. package/dist/dashboard/bridge-question.d.ts.map +1 -0
  96. package/dist/dashboard/bridge-question.js +20 -0
  97. package/dist/dashboard/bridge-question.js.map +1 -0
  98. package/dist/dashboard/bridge-sessions.d.ts +25 -0
  99. package/dist/dashboard/bridge-sessions.d.ts.map +1 -0
  100. package/dist/dashboard/bridge-sessions.js +46 -0
  101. package/dist/dashboard/bridge-sessions.js.map +1 -0
  102. package/dist/dashboard/bridge-starts.d.ts +61 -0
  103. package/dist/dashboard/bridge-starts.d.ts.map +1 -0
  104. package/dist/dashboard/bridge-starts.js +94 -0
  105. package/dist/dashboard/bridge-starts.js.map +1 -0
  106. package/dist/dashboard/bridge-store.d.ts +179 -0
  107. package/dist/dashboard/bridge-store.d.ts.map +1 -0
  108. package/dist/dashboard/bridge-store.js +262 -0
  109. package/dist/dashboard/bridge-store.js.map +1 -0
  110. package/dist/dashboard/bundle.d.ts +12 -0
  111. package/dist/dashboard/bundle.d.ts.map +1 -0
  112. package/dist/dashboard/bundle.js +22 -0
  113. package/dist/dashboard/bundle.js.map +1 -0
  114. package/dist/dashboard/cache.d.ts +47 -0
  115. package/dist/dashboard/cache.d.ts.map +1 -0
  116. package/dist/dashboard/cache.js +87 -0
  117. package/dist/dashboard/cache.js.map +1 -0
  118. package/dist/dashboard/content-type.d.ts +3 -0
  119. package/dist/dashboard/content-type.d.ts.map +1 -0
  120. package/dist/dashboard/content-type.js +31 -0
  121. package/dist/dashboard/content-type.js.map +1 -0
  122. package/dist/dashboard/dashboard.d.ts +38 -0
  123. package/dist/dashboard/dashboard.d.ts.map +1 -0
  124. package/dist/dashboard/dashboard.js +42 -0
  125. package/dist/dashboard/dashboard.js.map +1 -0
  126. package/dist/dashboard/docs.d.ts +39 -0
  127. package/dist/dashboard/docs.d.ts.map +1 -0
  128. package/dist/dashboard/docs.js +59 -0
  129. package/dist/dashboard/docs.js.map +1 -0
  130. package/dist/dashboard/git-status.d.ts +44 -0
  131. package/dist/dashboard/git-status.d.ts.map +1 -0
  132. package/dist/dashboard/git-status.js +37 -0
  133. package/dist/dashboard/git-status.js.map +1 -0
  134. package/dist/dashboard/http.d.ts +29 -0
  135. package/dist/dashboard/http.d.ts.map +1 -0
  136. package/dist/dashboard/http.js +74 -0
  137. package/dist/dashboard/http.js.map +1 -0
  138. package/dist/dashboard/index.d.ts +24 -0
  139. package/dist/dashboard/index.d.ts.map +1 -0
  140. package/dist/dashboard/index.js +23 -0
  141. package/dist/dashboard/index.js.map +1 -0
  142. package/dist/dashboard/interventions.d.ts +67 -0
  143. package/dist/dashboard/interventions.d.ts.map +1 -0
  144. package/dist/dashboard/interventions.js +169 -0
  145. package/dist/dashboard/interventions.js.map +1 -0
  146. package/dist/dashboard/keyed-watcher.d.ts +29 -0
  147. package/dist/dashboard/keyed-watcher.d.ts.map +1 -0
  148. package/dist/dashboard/keyed-watcher.js +42 -0
  149. package/dist/dashboard/keyed-watcher.js.map +1 -0
  150. package/dist/dashboard/keys.d.ts +31 -0
  151. package/dist/dashboard/keys.d.ts.map +1 -0
  152. package/dist/dashboard/keys.js +37 -0
  153. package/dist/dashboard/keys.js.map +1 -0
  154. package/dist/dashboard/models.d.ts +25 -0
  155. package/dist/dashboard/models.d.ts.map +1 -0
  156. package/dist/dashboard/models.js +30 -0
  157. package/dist/dashboard/models.js.map +1 -0
  158. package/dist/dashboard/module-host.d.ts +44 -0
  159. package/dist/dashboard/module-host.d.ts.map +1 -0
  160. package/dist/dashboard/module-host.js +91 -0
  161. package/dist/dashboard/module-host.js.map +1 -0
  162. package/dist/dashboard/module-serve.d.ts +15 -0
  163. package/dist/dashboard/module-serve.d.ts.map +1 -0
  164. package/dist/dashboard/module-serve.js +45 -0
  165. package/dist/dashboard/module-serve.js.map +1 -0
  166. package/dist/dashboard/open-in-app.d.ts +43 -0
  167. package/dist/dashboard/open-in-app.d.ts.map +1 -0
  168. package/dist/dashboard/open-in-app.js +98 -0
  169. package/dist/dashboard/open-in-app.js.map +1 -0
  170. package/dist/dashboard/open-questions.d.ts +45 -0
  171. package/dist/dashboard/open-questions.d.ts.map +1 -0
  172. package/dist/dashboard/open-questions.js +62 -0
  173. package/dist/dashboard/open-questions.js.map +1 -0
  174. package/dist/dashboard/overview.d.ts +78 -0
  175. package/dist/dashboard/overview.d.ts.map +1 -0
  176. package/dist/dashboard/overview.js +87 -0
  177. package/dist/dashboard/overview.js.map +1 -0
  178. package/dist/dashboard/projects.d.ts +101 -0
  179. package/dist/dashboard/projects.d.ts.map +1 -0
  180. package/dist/dashboard/projects.js +63 -0
  181. package/dist/dashboard/projects.js.map +1 -0
  182. package/dist/dashboard/pull-requests.d.ts +127 -0
  183. package/dist/dashboard/pull-requests.d.ts.map +1 -0
  184. package/dist/dashboard/pull-requests.js +137 -0
  185. package/dist/dashboard/pull-requests.js.map +1 -0
  186. package/dist/dashboard/queue.d.ts +17 -0
  187. package/dist/dashboard/queue.d.ts.map +1 -0
  188. package/dist/dashboard/queue.js +19 -0
  189. package/dist/dashboard/queue.js.map +1 -0
  190. package/dist/dashboard/quota.d.ts +53 -0
  191. package/dist/dashboard/quota.d.ts.map +1 -0
  192. package/dist/dashboard/quota.js +42 -0
  193. package/dist/dashboard/quota.js.map +1 -0
  194. package/dist/dashboard/relay-endpoints.d.ts +32 -0
  195. package/dist/dashboard/relay-endpoints.d.ts.map +1 -0
  196. package/dist/dashboard/relay-endpoints.js +115 -0
  197. package/dist/dashboard/relay-endpoints.js.map +1 -0
  198. package/dist/dashboard/remote-run.d.ts +95 -0
  199. package/dist/dashboard/remote-run.d.ts.map +1 -0
  200. package/dist/dashboard/remote-run.js +235 -0
  201. package/dist/dashboard/remote-run.js.map +1 -0
  202. package/dist/dashboard/rpc-serve.d.ts +106 -0
  203. package/dist/dashboard/rpc-serve.d.ts.map +1 -0
  204. package/dist/dashboard/rpc-serve.js +180 -0
  205. package/dist/dashboard/rpc-serve.js.map +1 -0
  206. package/dist/dashboard/run-inbox.d.ts +31 -0
  207. package/dist/dashboard/run-inbox.d.ts.map +1 -0
  208. package/dist/dashboard/run-inbox.js +51 -0
  209. package/dist/dashboard/run-inbox.js.map +1 -0
  210. package/dist/dashboard/server.d.ts +105 -0
  211. package/dist/dashboard/server.d.ts.map +1 -0
  212. package/dist/dashboard/server.js +231 -0
  213. package/dist/dashboard/server.js.map +1 -0
  214. package/dist/dashboard/static.d.ts +9 -0
  215. package/dist/dashboard/static.d.ts.map +1 -0
  216. package/dist/dashboard/static.js +54 -0
  217. package/dist/dashboard/static.js.map +1 -0
  218. package/dist/dashboard/types.d.ts +135 -0
  219. package/dist/dashboard/types.d.ts.map +1 -0
  220. package/dist/dashboard/types.js +2 -0
  221. package/dist/dashboard/types.js.map +1 -0
  222. package/dist/dashboard/web-start-endpoints.d.ts +32 -0
  223. package/dist/dashboard/web-start-endpoints.d.ts.map +1 -0
  224. package/dist/dashboard/web-start-endpoints.js +75 -0
  225. package/dist/dashboard/web-start-endpoints.js.map +1 -0
  226. package/dist/dashboard-bundle/assets/client-CbBRB9m4.js +9 -0
  227. package/dist/dashboard-bundle/assets/jsx-runtime-By8HlURe.js +1 -0
  228. package/dist/dashboard-bundle/assets/main-B98UOA3_.js +140 -0
  229. package/dist/dashboard-bundle/assets/main-ByRjbCiA.css +2 -0
  230. package/dist/dashboard-bundle/assets/module-v213KWfH.js +21 -0
  231. package/dist/dashboard-bundle/assets/react-CZI7_Jkm.js +1 -0
  232. package/dist/dashboard-bundle/assets/react-dom-cJyBB_A4.js +1 -0
  233. package/dist/dashboard-bundle/assets/rolldown-runtime-QTnfLwEv.js +1 -0
  234. package/dist/dashboard-bundle/host/module.js +1 -0
  235. package/dist/dashboard-bundle/host/react-dom-client.js +1 -0
  236. package/dist/dashboard-bundle/host/react-dom.js +1 -0
  237. package/dist/dashboard-bundle/host/react-jsx-runtime.js +1 -0
  238. package/dist/dashboard-bundle/host/react.js +1 -0
  239. package/dist/dashboard-bundle/index.html +42 -0
  240. package/dist/dashboard-bundle/logo-animated.svg +34 -0
  241. package/dist/dashboard-bundle/logo.svg +16 -0
  242. package/dist/dashboard-rpc/context.d.ts +56 -0
  243. package/dist/dashboard-rpc/context.d.ts.map +1 -0
  244. package/dist/dashboard-rpc/context.js +106 -0
  245. package/dist/dashboard-rpc/context.js.map +1 -0
  246. package/dist/dashboard-rpc/control.d.ts +124 -0
  247. package/dist/dashboard-rpc/control.d.ts.map +1 -0
  248. package/dist/dashboard-rpc/control.js +284 -0
  249. package/dist/dashboard-rpc/control.js.map +1 -0
  250. package/dist/dashboard-rpc/devices.d.ts +9 -0
  251. package/dist/dashboard-rpc/devices.d.ts.map +1 -0
  252. package/dist/dashboard-rpc/devices.js +12 -0
  253. package/dist/dashboard-rpc/devices.js.map +1 -0
  254. package/dist/dashboard-rpc/events-tail.d.ts +68 -0
  255. package/dist/dashboard-rpc/events-tail.d.ts.map +1 -0
  256. package/dist/dashboard-rpc/events-tail.js +257 -0
  257. package/dist/dashboard-rpc/events-tail.js.map +1 -0
  258. package/dist/dashboard-rpc/events.d.ts +39 -0
  259. package/dist/dashboard-rpc/events.d.ts.map +1 -0
  260. package/dist/dashboard-rpc/events.js +47 -0
  261. package/dist/dashboard-rpc/events.js.map +1 -0
  262. package/dist/dashboard-rpc/index.d.ts +29 -0
  263. package/dist/dashboard-rpc/index.d.ts.map +1 -0
  264. package/dist/dashboard-rpc/index.js +40 -0
  265. package/dist/dashboard-rpc/index.js.map +1 -0
  266. package/dist/dashboard-rpc/models.d.ts +4 -0
  267. package/dist/dashboard-rpc/models.d.ts.map +1 -0
  268. package/dist/dashboard-rpc/models.js +8 -0
  269. package/dist/dashboard-rpc/models.js.map +1 -0
  270. package/dist/dashboard-rpc/modules.d.ts +45 -0
  271. package/dist/dashboard-rpc/modules.d.ts.map +1 -0
  272. package/dist/dashboard-rpc/modules.js +79 -0
  273. package/dist/dashboard-rpc/modules.js.map +1 -0
  274. package/dist/dashboard-rpc/preferences.d.ts +41 -0
  275. package/dist/dashboard-rpc/preferences.d.ts.map +1 -0
  276. package/dist/dashboard-rpc/preferences.js +65 -0
  277. package/dist/dashboard-rpc/preferences.js.map +1 -0
  278. package/dist/dashboard-rpc/projects.d.ts +85 -0
  279. package/dist/dashboard-rpc/projects.d.ts.map +1 -0
  280. package/dist/dashboard-rpc/projects.js +129 -0
  281. package/dist/dashboard-rpc/projects.js.map +1 -0
  282. package/dist/dashboard-rpc/quota.d.ts +4 -0
  283. package/dist/dashboard-rpc/quota.d.ts.map +1 -0
  284. package/dist/dashboard-rpc/quota.js +15 -0
  285. package/dist/dashboard-rpc/quota.js.map +1 -0
  286. package/dist/dashboard-rpc/reads.d.ts +185 -0
  287. package/dist/dashboard-rpc/reads.d.ts.map +1 -0
  288. package/dist/dashboard-rpc/reads.js +370 -0
  289. package/dist/dashboard-rpc/reads.js.map +1 -0
  290. package/dist/dashboard-rpc/relay-agent.d.ts +9 -0
  291. package/dist/dashboard-rpc/relay-agent.d.ts.map +1 -0
  292. package/dist/dashboard-rpc/relay-agent.js +21 -0
  293. package/dist/dashboard-rpc/relay-agent.js.map +1 -0
  294. package/dist/dashboard-rpc/relay-dispatch.d.ts +9 -0
  295. package/dist/dashboard-rpc/relay-dispatch.d.ts.map +1 -0
  296. package/dist/dashboard-rpc/relay-dispatch.js +24 -0
  297. package/dist/dashboard-rpc/relay-dispatch.js.map +1 -0
  298. package/dist/dashboard-rpc/stream-forward.d.ts +17 -0
  299. package/dist/dashboard-rpc/stream-forward.d.ts.map +1 -0
  300. package/dist/dashboard-rpc/stream-forward.js +38 -0
  301. package/dist/dashboard-rpc/stream-forward.js.map +1 -0
  302. package/dist/dashboard-rpc/test-context.d.ts +23 -0
  303. package/dist/dashboard-rpc/test-context.d.ts.map +1 -0
  304. package/dist/dashboard-rpc/test-context.js +43 -0
  305. package/dist/dashboard-rpc/test-context.js.map +1 -0
  306. package/dist/driver-names.d.ts +22 -0
  307. package/dist/driver-names.d.ts.map +1 -0
  308. package/dist/driver-names.js +29 -0
  309. package/dist/driver-names.js.map +1 -0
  310. package/dist/error-message.d.ts +8 -0
  311. package/dist/error-message.d.ts.map +1 -0
  312. package/dist/error-message.js +10 -0
  313. package/dist/error-message.js.map +1 -0
  314. package/dist/event-stream.d.ts +33 -0
  315. package/dist/event-stream.d.ts.map +1 -0
  316. package/dist/event-stream.js +104 -0
  317. package/dist/event-stream.js.map +1 -0
  318. package/dist/events.d.ts +236 -0
  319. package/dist/events.d.ts.map +1 -0
  320. package/dist/events.js +5 -0
  321. package/dist/events.js.map +1 -0
  322. package/dist/format-bytes.d.ts +3 -0
  323. package/dist/format-bytes.d.ts.map +1 -0
  324. package/dist/format-bytes.js +18 -0
  325. package/dist/format-bytes.js.map +1 -0
  326. package/dist/has-remote.d.ts +8 -0
  327. package/dist/has-remote.d.ts.map +1 -0
  328. package/dist/has-remote.js +10 -0
  329. package/dist/has-remote.js.map +1 -0
  330. package/dist/index.d.ts +42 -0
  331. package/dist/index.d.ts.map +1 -0
  332. package/dist/index.js +16 -0
  333. package/dist/index.js.map +1 -0
  334. package/dist/install.d.ts +31 -0
  335. package/dist/install.d.ts.map +1 -0
  336. package/dist/install.js +54 -0
  337. package/dist/install.js.map +1 -0
  338. package/dist/jsonl-tail.d.ts +59 -0
  339. package/dist/jsonl-tail.d.ts.map +1 -0
  340. package/dist/jsonl-tail.js +152 -0
  341. package/dist/jsonl-tail.js.map +1 -0
  342. package/dist/loopback-host.d.ts +20 -0
  343. package/dist/loopback-host.d.ts.map +1 -0
  344. package/dist/loopback-host.js +31 -0
  345. package/dist/loopback-host.js.map +1 -0
  346. package/dist/module-server.d.ts +56 -0
  347. package/dist/module-types/dashboard/components/DiffStat.d.ts +6 -0
  348. package/dist/module-types/dashboard/components/DriverModelMenu.d.ts +23 -0
  349. package/dist/module-types/dashboard/components/LinkActions.d.ts +26 -0
  350. package/dist/module-types/dashboard/components/Markdown.d.ts +4 -0
  351. package/dist/module-types/dashboard/components/SettingsRows.d.ts +37 -0
  352. package/dist/module-types/dashboard/components/StartAgentButton.d.ts +39 -0
  353. package/dist/module-types/dashboard/components/ui/badge.d.ts +2 -0
  354. package/dist/module-types/dashboard/components/ui/button.d.ts +10 -0
  355. package/dist/module-types/dashboard/components/ui/card.d.ts +5 -0
  356. package/dist/module-types/dashboard/components/ui/checkbox.d.ts +7 -0
  357. package/dist/module-types/dashboard/components/ui/dropdown-menu.d.ts +16 -0
  358. package/dist/module-types/dashboard/components/ui/input.d.ts +2 -0
  359. package/dist/module-types/dashboard/components/ui/option-label.d.ts +4 -0
  360. package/dist/module-types/dashboard/components/ui/popover.d.ts +8 -0
  361. package/dist/module-types/dashboard/components/ui/scroll-area.d.ts +10 -0
  362. package/dist/module-types/dashboard/components/ui/separator.d.ts +3 -0
  363. package/dist/module-types/dashboard/components/ui/skeleton.d.ts +2 -0
  364. package/dist/module-types/dashboard/components/ui/slider.d.ts +9 -0
  365. package/dist/module-types/dashboard/components/ui/tooltip.d.ts +11 -0
  366. package/dist/module-types/dashboard/lib/agent-settings.d.ts +2 -0
  367. package/dist/module-types/dashboard/lib/draft-handoff.d.ts +15 -0
  368. package/dist/module-types/dashboard/lib/format-date.d.ts +51 -0
  369. package/dist/module-types/dashboard/lib/host-services.d.ts +12 -0
  370. package/dist/module-types/dashboard/lib/models.d.ts +24 -0
  371. package/dist/module-types/dashboard/lib/route.d.ts +38 -0
  372. package/dist/module-types/dashboard/lib/rpc.d.ts +31 -0
  373. package/dist/module-types/dashboard/lib/use-action.d.ts +25 -0
  374. package/dist/module-types/dashboard/lib/use-async.d.ts +45 -0
  375. package/dist/module-types/dashboard/lib/use-modules.d.ts +79 -0
  376. package/dist/module-types/dashboard/lib/utils.d.ts +3 -0
  377. package/dist/module-types/dashboard/module/index.d.ts +335 -0
  378. package/dist/module-types/dashboard/rpc/models.d.ts +2 -0
  379. package/dist/module-types/dashboard/rpc/modules.d.ts +5 -0
  380. package/dist/module-types/src/agent-id.d.ts +12 -0
  381. package/dist/module-types/src/agent-locks.d.ts +2 -0
  382. package/dist/module-types/src/agent-view.d.ts +38 -0
  383. package/dist/module-types/src/bridge-browser.d.ts +216 -0
  384. package/dist/module-types/src/browser-stream.d.ts +19 -0
  385. package/dist/module-types/src/browser.d.ts +15 -0
  386. package/dist/module-types/src/built-in.d.ts +37 -0
  387. package/dist/module-types/src/client.d.ts +15 -0
  388. package/dist/module-types/src/cloud-run-state.d.ts +26 -0
  389. package/dist/module-types/src/dashboard/activity.d.ts +40 -0
  390. package/dist/module-types/src/dashboard/agent-handoff.d.ts +243 -0
  391. package/dist/module-types/src/dashboard/bridge-endpoints.d.ts +157 -0
  392. package/dist/module-types/src/dashboard/bridge-question.d.ts +32 -0
  393. package/dist/module-types/src/dashboard/bridge-store.d.ts +178 -0
  394. package/dist/module-types/src/dashboard/cache.d.ts +46 -0
  395. package/dist/module-types/src/dashboard/content-type.d.ts +2 -0
  396. package/dist/module-types/src/dashboard/dashboard.d.ts +37 -0
  397. package/dist/module-types/src/dashboard/docs.d.ts +38 -0
  398. package/dist/module-types/src/dashboard/git-status.d.ts +43 -0
  399. package/dist/module-types/src/dashboard/http.d.ts +28 -0
  400. package/dist/module-types/src/dashboard/interventions.d.ts +66 -0
  401. package/dist/module-types/src/dashboard/keyed-watcher.d.ts +28 -0
  402. package/dist/module-types/src/dashboard/keys.d.ts +30 -0
  403. package/dist/module-types/src/dashboard/models.d.ts +24 -0
  404. package/dist/module-types/src/dashboard/module-host.d.ts +43 -0
  405. package/dist/module-types/src/dashboard/module-serve.d.ts +14 -0
  406. package/dist/module-types/src/dashboard/open-in-app.d.ts +42 -0
  407. package/dist/module-types/src/dashboard/open-questions.d.ts +44 -0
  408. package/dist/module-types/src/dashboard/overview.d.ts +77 -0
  409. package/dist/module-types/src/dashboard/projects.d.ts +100 -0
  410. package/dist/module-types/src/dashboard/pull-requests.d.ts +126 -0
  411. package/dist/module-types/src/dashboard/queue.d.ts +16 -0
  412. package/dist/module-types/src/dashboard/quota.d.ts +52 -0
  413. package/dist/module-types/src/dashboard/remote-run.d.ts +94 -0
  414. package/dist/module-types/src/dashboard/rpc-serve.d.ts +105 -0
  415. package/dist/module-types/src/dashboard/run-inbox.d.ts +30 -0
  416. package/dist/module-types/src/dashboard/types.d.ts +134 -0
  417. package/dist/module-types/src/dashboard-rpc/context.d.ts +55 -0
  418. package/dist/module-types/src/dashboard-rpc/control.d.ts +123 -0
  419. package/dist/module-types/src/dashboard-rpc/devices.d.ts +8 -0
  420. package/dist/module-types/src/dashboard-rpc/events-tail.d.ts +67 -0
  421. package/dist/module-types/src/dashboard-rpc/events.d.ts +38 -0
  422. package/dist/module-types/src/dashboard-rpc/index.d.ts +28 -0
  423. package/dist/module-types/src/dashboard-rpc/models.d.ts +3 -0
  424. package/dist/module-types/src/dashboard-rpc/modules.d.ts +44 -0
  425. package/dist/module-types/src/dashboard-rpc/preferences.d.ts +40 -0
  426. package/dist/module-types/src/dashboard-rpc/projects.d.ts +84 -0
  427. package/dist/module-types/src/dashboard-rpc/quota.d.ts +3 -0
  428. package/dist/module-types/src/dashboard-rpc/reads.d.ts +184 -0
  429. package/dist/module-types/src/dashboard-rpc/relay-agent.d.ts +8 -0
  430. package/dist/module-types/src/dashboard-rpc/stream-forward.d.ts +16 -0
  431. package/dist/module-types/src/driver-names.d.ts +21 -0
  432. package/dist/module-types/src/error-message.d.ts +7 -0
  433. package/dist/module-types/src/event-stream.d.ts +32 -0
  434. package/dist/module-types/src/events.d.ts +235 -0
  435. package/dist/module-types/src/format-bytes.d.ts +2 -0
  436. package/dist/module-types/src/has-remote.d.ts +7 -0
  437. package/dist/module-types/src/index.d.ts +41 -0
  438. package/dist/module-types/src/jsonl-tail.d.ts +58 -0
  439. package/dist/module-types/src/loopback-host.d.ts +19 -0
  440. package/dist/module-types/src/node-fs.d.ts +32 -0
  441. package/dist/module-types/src/open-choices.d.ts +14 -0
  442. package/dist/module-types/src/openagent-dir.d.ts +10 -0
  443. package/dist/module-types/src/openagent-gitignore.d.ts +11 -0
  444. package/dist/module-types/src/pick-directory.d.ts +29 -0
  445. package/dist/module-types/src/preference-defaults.d.ts +42 -0
  446. package/dist/module-types/src/project-commands.d.ts +23 -0
  447. package/dist/module-types/src/project-errors.d.ts +59 -0
  448. package/dist/module-types/src/project-hooks.d.ts +129 -0
  449. package/dist/module-types/src/project-modules.d.ts +49 -0
  450. package/dist/module-types/src/project-presets.d.ts +29 -0
  451. package/dist/module-types/src/project.d.ts +28 -0
  452. package/dist/module-types/src/publish-levels.d.ts +32 -0
  453. package/dist/module-types/src/quota-boundary.d.ts +64 -0
  454. package/dist/module-types/src/quota-poller.d.ts +82 -0
  455. package/dist/module-types/src/registry.d.ts +226 -0
  456. package/dist/module-types/src/store/agent-checkout.d.ts +53 -0
  457. package/dist/module-types/src/store/agent-store.d.ts +266 -0
  458. package/dist/module-types/src/store/branches.d.ts +163 -0
  459. package/dist/module-types/src/store/git-host.d.ts +113 -0
  460. package/dist/module-types/src/store/index.d.ts +9 -0
  461. package/dist/module-types/src/store/provided.d.ts +16 -0
  462. package/dist/module-types/src/store/queue.d.ts +45 -0
  463. package/dist/module-types/src/store/repository.d.ts +32 -0
  464. package/dist/module-types/src/store/run-record.d.ts +21 -0
  465. package/dist/module-types/src/store/runs.d.ts +107 -0
  466. package/dist/module-types/src/store/tickets.d.ts +72 -0
  467. package/dist/module-types/src/terminal.d.ts +3 -0
  468. package/dist/module-types/src/worktrees.d.ts +89 -0
  469. package/dist/module.css +50 -0
  470. package/dist/node-fs.d.ts +33 -0
  471. package/dist/node-fs.d.ts.map +1 -0
  472. package/dist/node-fs.js +57 -0
  473. package/dist/node-fs.js.map +1 -0
  474. package/dist/open-choices.d.ts +15 -0
  475. package/dist/open-choices.d.ts.map +1 -0
  476. package/dist/open-choices.js +31 -0
  477. package/dist/open-choices.js.map +1 -0
  478. package/dist/openagent-dir.d.ts +11 -0
  479. package/dist/openagent-dir.d.ts.map +1 -0
  480. package/dist/openagent-dir.js +11 -0
  481. package/dist/openagent-dir.js.map +1 -0
  482. package/dist/openagent-gitignore.d.ts +12 -0
  483. package/dist/openagent-gitignore.d.ts.map +1 -0
  484. package/dist/openagent-gitignore.js +19 -0
  485. package/dist/openagent-gitignore.js.map +1 -0
  486. package/dist/pick-directory.d.ts +30 -0
  487. package/dist/pick-directory.d.ts.map +1 -0
  488. package/dist/pick-directory.js +102 -0
  489. package/dist/pick-directory.js.map +1 -0
  490. package/dist/preference-defaults.d.ts +43 -0
  491. package/dist/preference-defaults.d.ts.map +1 -0
  492. package/dist/preference-defaults.js +34 -0
  493. package/dist/preference-defaults.js.map +1 -0
  494. package/dist/project-commands.d.ts +24 -0
  495. package/dist/project-commands.d.ts.map +1 -0
  496. package/dist/project-commands.js +57 -0
  497. package/dist/project-commands.js.map +1 -0
  498. package/dist/project-errors.d.ts +60 -0
  499. package/dist/project-errors.d.ts.map +1 -0
  500. package/dist/project-errors.js +51 -0
  501. package/dist/project-errors.js.map +1 -0
  502. package/dist/project-hooks.d.ts +130 -0
  503. package/dist/project-hooks.d.ts.map +1 -0
  504. package/dist/project-hooks.js +232 -0
  505. package/dist/project-hooks.js.map +1 -0
  506. package/dist/project-modules.d.ts +50 -0
  507. package/dist/project-modules.d.ts.map +1 -0
  508. package/dist/project-modules.js +110 -0
  509. package/dist/project-modules.js.map +1 -0
  510. package/dist/project-pass.d.ts +32 -0
  511. package/dist/project-pass.d.ts.map +1 -0
  512. package/dist/project-pass.js +45 -0
  513. package/dist/project-pass.js.map +1 -0
  514. package/dist/project-presets.d.ts +30 -0
  515. package/dist/project-presets.d.ts.map +1 -0
  516. package/dist/project-presets.js +74 -0
  517. package/dist/project-presets.js.map +1 -0
  518. package/dist/project.d.ts +29 -0
  519. package/dist/project.d.ts.map +1 -0
  520. package/dist/project.js +41 -0
  521. package/dist/project.js.map +1 -0
  522. package/dist/publish-levels.d.ts +33 -0
  523. package/dist/publish-levels.d.ts.map +1 -0
  524. package/dist/publish-levels.js +53 -0
  525. package/dist/publish-levels.js.map +1 -0
  526. package/dist/quota-boundary.d.ts +65 -0
  527. package/dist/quota-boundary.d.ts.map +1 -0
  528. package/dist/quota-boundary.js +135 -0
  529. package/dist/quota-boundary.js.map +1 -0
  530. package/dist/quota-poller.d.ts +83 -0
  531. package/dist/quota-poller.d.ts.map +1 -0
  532. package/dist/quota-poller.js +118 -0
  533. package/dist/quota-poller.js.map +1 -0
  534. package/dist/registry.d.ts +227 -0
  535. package/dist/registry.d.ts.map +1 -0
  536. package/dist/registry.js +364 -0
  537. package/dist/registry.js.map +1 -0
  538. package/dist/remove-files.d.ts +24 -0
  539. package/dist/remove-files.d.ts.map +1 -0
  540. package/dist/remove-files.js +98 -0
  541. package/dist/remove-files.js.map +1 -0
  542. package/dist/request-path.d.ts +10 -0
  543. package/dist/request-path.d.ts.map +1 -0
  544. package/dist/request-path.js +16 -0
  545. package/dist/request-path.js.map +1 -0
  546. package/dist/store/agent-checkout.d.ts +54 -0
  547. package/dist/store/agent-checkout.d.ts.map +1 -0
  548. package/dist/store/agent-checkout.js +61 -0
  549. package/dist/store/agent-checkout.js.map +1 -0
  550. package/dist/store/agent-store.d.ts +267 -0
  551. package/dist/store/agent-store.d.ts.map +1 -0
  552. package/dist/store/agent-store.js +190 -0
  553. package/dist/store/agent-store.js.map +1 -0
  554. package/dist/store/branches.d.ts +164 -0
  555. package/dist/store/branches.d.ts.map +1 -0
  556. package/dist/store/branches.js +187 -0
  557. package/dist/store/branches.js.map +1 -0
  558. package/dist/store/git-host.d.ts +114 -0
  559. package/dist/store/git-host.d.ts.map +1 -0
  560. package/dist/store/git-host.js +103 -0
  561. package/dist/store/git-host.js.map +1 -0
  562. package/dist/store/index.d.ts +10 -0
  563. package/dist/store/index.d.ts.map +1 -0
  564. package/dist/store/index.js +10 -0
  565. package/dist/store/index.js.map +1 -0
  566. package/dist/store/provided.d.ts +17 -0
  567. package/dist/store/provided.d.ts.map +1 -0
  568. package/dist/store/provided.js +37 -0
  569. package/dist/store/provided.js.map +1 -0
  570. package/dist/store/queue.d.ts +46 -0
  571. package/dist/store/queue.d.ts.map +1 -0
  572. package/dist/store/queue.js +61 -0
  573. package/dist/store/queue.js.map +1 -0
  574. package/dist/store/repository.d.ts +33 -0
  575. package/dist/store/repository.d.ts.map +1 -0
  576. package/dist/store/repository.js +25 -0
  577. package/dist/store/repository.js.map +1 -0
  578. package/dist/store/run-record.d.ts +22 -0
  579. package/dist/store/run-record.d.ts.map +1 -0
  580. package/dist/store/run-record.js +108 -0
  581. package/dist/store/run-record.js.map +1 -0
  582. package/dist/store/runs.d.ts +108 -0
  583. package/dist/store/runs.d.ts.map +1 -0
  584. package/dist/store/runs.js +146 -0
  585. package/dist/store/runs.js.map +1 -0
  586. package/dist/store/test-branches.d.ts +18 -0
  587. package/dist/store/test-branches.d.ts.map +1 -0
  588. package/dist/store/test-branches.js +59 -0
  589. package/dist/store/test-branches.js.map +1 -0
  590. package/dist/store/test-runs.d.ts +15 -0
  591. package/dist/store/test-runs.d.ts.map +1 -0
  592. package/dist/store/test-runs.js +37 -0
  593. package/dist/store/test-runs.js.map +1 -0
  594. package/dist/store/tickets.d.ts +73 -0
  595. package/dist/store/tickets.d.ts.map +1 -0
  596. package/dist/store/tickets.js +67 -0
  597. package/dist/store/tickets.js.map +1 -0
  598. package/dist/terminal.d.ts +4 -0
  599. package/dist/terminal.d.ts.map +1 -0
  600. package/dist/terminal.js +97 -0
  601. package/dist/terminal.js.map +1 -0
  602. package/dist/update-check.d.ts +44 -0
  603. package/dist/update-check.d.ts.map +1 -0
  604. package/dist/update-check.js +71 -0
  605. package/dist/update-check.js.map +1 -0
  606. package/dist/worktrees.d.ts +90 -0
  607. package/dist/worktrees.d.ts.map +1 -0
  608. package/dist/worktrees.js +123 -0
  609. package/dist/worktrees.js.map +1 -0
  610. package/package.json +103 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activity.d.ts","sourceRoot":"","sources":["../../src/dashboard/activity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACnF,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAKnE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAcvC;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,0FAA0F;IAC1F,IAAI,EAAE,SAAS,GAAG,UAAU,CAAA;IAC5B,2FAA2F;IAC3F,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,uGAAuG;IACvG,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,0EAA0E;AAC1E,MAAM,WAAW,YAAY;IAC3B,gGAAgG;IAChG,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,EAAE,CAAC,CAAA;CACnD;AAgBD;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,cAAc,EAAE,EAC1B,IAAI,GAAE,YAAiB,GACtB,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAYnC"}
@@ -0,0 +1,56 @@
1
+ import { readAllAgents } from '../store/index.js';
2
+ // The identity + diff live in the leaf `keys.ts` so the dashboard can share them (they are pure);
3
+ // re-exported here so this stays the import site for anything that already reads them from the
4
+ // module that defines `Activity`.
5
+ export { activityKey } from './keys.js';
6
+ // The "New activity" feed (#627): the cross-project stream of run lifecycle transitions that
7
+ // do NOT need the human — an agent started, an agent finished. It is the default-off notification
8
+ // category, the counterpart to the interventions queue (which is the always-on "needs you"
9
+ // half). Same shape and same "only genuinely new" diff as interventions.ts, so the browser
10
+ // hook folds it into a baseline on first look and then notifies once per transition — you hear
11
+ // an agent kick off and an agent land, nothing when the page opens.
12
+ /** How many recent agents per project to consider. Bounds the finished-set — older agents rolled off
13
+ * long ago and were already baselined, so they never fire. A running agent is always newest (live
14
+ * meta is prepended), so it is always in range. */
15
+ const RECENT_RUNS = 20;
16
+ /** Map one agent to its current activity item: `started` while running, else `finished`. */
17
+ function activityFor(project, agent) {
18
+ const kind = agent.status === 'running' ? 'started' : 'finished';
19
+ return {
20
+ projectId: project.id,
21
+ projectName: project.name,
22
+ agentId: agent.id,
23
+ kind,
24
+ ...(agent.intent ? { title: agent.intent } : {}),
25
+ ...(kind === 'finished' ? { status: agent.status } : {}),
26
+ ...(agent.updatedAt ? { updatedAt: agent.updatedAt } : {}),
27
+ };
28
+ }
29
+ /**
30
+ * Build the cross-project activity feed: for each registered project's most recent agents, one
31
+ * item per agent reflecting where it is now (`started` while it runs, `finished` once it lands),
32
+ * newest first. Forgiving — a project whose agents cannot be read simply contributes nothing, and
33
+ * comes back named as one that was *not* read whole (#1623), since "nothing happened there" and
34
+ * "I could not look" are the same empty list to everyone but the notification watcher.
35
+ *
36
+ * The `started` and `finished` items for one agent carry distinct keys ({@link activityKey}), so a
37
+ * run that is still going notifies once (started) and again when it lands (finished). An agent that
38
+ * both starts and finishes between two polls is only ever seen terminal, so it notifies once
39
+ * (finished) — one quick agent, one line.
40
+ */
41
+ export async function buildActivity(projects, deps = {}) {
42
+ const readAgents = deps.readAgents ?? readAllAgents;
43
+ const items = [];
44
+ const whole = [];
45
+ for (const project of projects) {
46
+ const read = await readAgents(project.path).catch(() => undefined);
47
+ if (!read)
48
+ continue;
49
+ whole.push(project.id);
50
+ for (const agent of read.slice(0, RECENT_RUNS))
51
+ items.push(activityFor(project, agent));
52
+ }
53
+ items.sort((a, b) => (b.updatedAt ?? '').localeCompare(a.updatedAt ?? ''));
54
+ return { items, whole };
55
+ }
56
+ //# sourceMappingURL=activity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activity.js","sourceRoot":"","sources":["../../src/dashboard/activity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAoC,MAAM,mBAAmB,CAAA;AAGnF,kGAAkG;AAClG,+FAA+F;AAC/F,kCAAkC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvC,6FAA6F;AAC7F,kGAAkG;AAClG,2FAA2F;AAC3F,2FAA2F;AAC3F,+FAA+F;AAC/F,oEAAoE;AAEpE;;mDAEmD;AACnD,MAAM,WAAW,GAAG,EAAE,CAAA;AA4BtB,4FAA4F;AAC5F,SAAS,WAAW,CAAC,OAAuB,EAAE,KAAgB;IAC5D,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAA;IAChE,OAAO;QACL,SAAS,EAAE,OAAO,CAAC,EAAE;QACrB,WAAW,EAAE,OAAO,CAAC,IAAI;QACzB,OAAO,EAAE,KAAK,CAAC,EAAE;QACjB,IAAI;QACJ,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChD,GAAG,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACxD,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC3D,CAAA;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,QAA0B,EAC1B,IAAI,GAAiB,EAAE;IAEvB,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,aAAa,CAAA;IACnD,MAAM,KAAK,GAAe,EAAE,CAAA;IAC5B,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;QAClE,IAAI,CAAC,IAAI;YAAE,SAAQ;QACnB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QACtB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;IACzF,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,CAAA;IAC1E,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;AACzB,CAAC"}
@@ -0,0 +1,244 @@
1
+ import { type LinkedPr, type BranchPrLookup } from './pull-requests.js';
2
+ import type { Cached } from './cache.js';
3
+ import type { AgentMeta } from '../store/index.js';
4
+ import { type BranchesFor } from '../store/branches.js';
5
+ import { type GitHostFor } from '../store/git-host.js';
6
+ import { type RunsFor } from '../store/runs.js';
7
+ /** One commit a session put on its branch. */
8
+ export interface HandoffCommit {
9
+ sha: string;
10
+ /** Short sha, for display. */
11
+ short: string;
12
+ subject: string;
13
+ }
14
+ /** One file the session changed, against the branch point. */
15
+ export interface HandoffFile {
16
+ path: string;
17
+ insertions: number;
18
+ deletions: number;
19
+ /** True for a binary file, where line counts are meaningless. */
20
+ binary: boolean;
21
+ }
22
+ /** What a finished session produced and what can still be done with it. */
23
+ export interface AgentHandoff {
24
+ /** The branch the work is on. */
25
+ branch: string;
26
+ /** The name the agent gave its work, as the branches provider answers it; absent while the run has not named it. */
27
+ name?: string;
28
+ /** The branch still exists in the repo (a deleted or never-created one does not). */
29
+ exists: boolean;
30
+ /** The branch is gone because the run changed nothing ({@link leftNothing}), not because work went. */
31
+ unchanged?: boolean;
32
+ /**
33
+ * The run's work was landed: merged into its main agent's branch by that agent, or into the
34
+ * project's default branch by the person, on this machine. The run's own branch went with that,
35
+ * and what is read here is what it held, by the last commit its record kept.
36
+ */
37
+ landed?: boolean;
38
+ /** What the branch is measured against: the repo's default branch, or the commit the run's own work begins at (a run started from another branch, or one already merged), when one was found. */
39
+ base?: string;
40
+ commits: HandoffCommit[];
41
+ files: HandoffFile[];
42
+ insertions: number;
43
+ deletions: number;
44
+ /**
45
+ * The session produced nothing to hand off: the branch exists but carries no commit the base
46
+ * does not already have — or nothing beyond OpenAgent's own bookkeeping (#1291), which is
47
+ * committed for provenance, never as publishable work. Said out loud, rather than shown as an
48
+ * empty branch.
49
+ */
50
+ empty: boolean;
51
+ /** The repo has a remote to push to at all. */
52
+ hasRemote: boolean;
53
+ /** The branch is on the remote and the remote is at the same commit. */
54
+ pushed: boolean;
55
+ /** The branch is already merged into the base. */
56
+ merged: boolean;
57
+ /** The project has a git host package (#1820): a pull request is a next step at all. Without one, the last step is the push. */
58
+ gitHost: boolean;
59
+ /** The PR opened for this branch, when there is one. */
60
+ pr?: LinkedPr;
61
+ /** The PR is not known yet, rather than absent (#1028): the lookup is still running. */
62
+ prPending?: boolean;
63
+ /**
64
+ * The files the session changed and never committed, read from its own checkout (#1173).
65
+ *
66
+ * The agent is told to commit its work, but one that ended without doing so holds its whole
67
+ * output in an uncommitted tree, and nothing commits it on the agent's behalf (#1638). That work
68
+ * is not on the branch yet, so it is
69
+ * not in {@link commits} and it does not make {@link empty} false. Paths rather than a count,
70
+ * because a no-diff branch must *name* what is waiting instead of offering an Open PR that
71
+ * the git host can only refuse. Absent when no checkout is on the branch any more — "no checkout"
72
+ * and "a checkout, tree clean" are different answers.
73
+ */
74
+ pendingFiles?: string[];
75
+ }
76
+ /** Injectable seams so the reader is unit-testable off disk and off the provider. */
77
+ export interface AgentHandoffDeps {
78
+ pr?: BranchPrLookup;
79
+ /** The project's checkouts and branches (default the project's provider, {@link projectBranches}). */
80
+ branches?: BranchesFor;
81
+ /** The project's git host (default the project's provider, {@link projectGitHost}). */
82
+ gitHost?: GitHostFor;
83
+ /**
84
+ * When the agent started (ISO), so the PR lookup can tell the agent's own PR from an earlier agent's
85
+ * on the same branch name (#1251). Without it, only an open PR is trusted.
86
+ */
87
+ since?: string;
88
+ /**
89
+ * Which of the run's own PRs answers, when it has more than one (#1512). Identity questions want
90
+ * the first; a handoff decision comparing the branch tip against a PR's head wants the last one
91
+ * that saw the branch, or work a later PR already landed reads as unlanded. See {@link pickAgentPr}.
92
+ */
93
+ order?: 'first' | 'latest';
94
+ /** The commit the run's own work begins at ({@link AgentMeta.baseCommit}): what the branch is measured from. */
95
+ from?: string;
96
+ }
97
+ /**
98
+ * The branch an agent's work is on: what was recorded while the checkout existed (#799/#1277).
99
+ * The agent renames its branch itself (#1725), so anything but the record is a guess, and a run
100
+ * whose record carries no branch has none to hand off.
101
+ */
102
+ export declare function agentBranchFor(agent: {
103
+ id: string;
104
+ branch?: string;
105
+ }): string | undefined;
106
+ /**
107
+ * Whether a run whose branch is gone changed nothing (#1850): it ended `done`, `failed` or
108
+ * `stopped` on this machine, has no pull request, and was not landed by a main agent (a landed
109
+ * run's branch went because its work moved on, not for holding nothing). Such a run's own tool recorded the branch's
110
+ * last name as it ended, a Stop included, and then reclaimed the checkout, and the branches rule
111
+ * deletes a branch with the checkout only when it holds nothing. A run whose process died is marked
112
+ * `stopped` by the sweep only when it left no checkout, so it had nowhere to keep a change. A run
113
+ * another machine ran leaves no such proof here, and one `waiting` keeps its checkout.
114
+ */
115
+ export declare function leftNothing(agent: {
116
+ status?: string;
117
+ host?: string;
118
+ pr?: unknown;
119
+ landed?: string;
120
+ }, host?: string): boolean;
121
+ /** The cached single-PR read {@link resolveAgentPr} asks for the recorded PR's current state. */
122
+ export type CachedBranchPrLookup = (cwd: string, branch?: string) => Promise<Cached<LinkedPr | undefined>>;
123
+ /** What {@link resolveAgentPr} needs to know about an agent: structurally satisfied by {@link AgentMeta}. */
124
+ export interface PrAgent {
125
+ id: string;
126
+ branch?: string;
127
+ /** The pull request the agent recorded when one was opened for it (E6). */
128
+ pr?: {
129
+ number: number;
130
+ url: string;
131
+ };
132
+ }
133
+ /**
134
+ * The pull request that belongs to an agent: the one it recorded (E6), read live for its state.
135
+ *
136
+ * The number is a fact about the agent, so the agent writes it down — at the moment its handoff opens
137
+ * the PR, or when the dashboard's button does after the process is gone. Every surface then reads
138
+ * the same integer instead of re-deriving it.
139
+ *
140
+ * What that replaced: a three-way branch-name ladder (the recorded branch, then a branch built from
141
+ * the session name, then the run-id branch, because a hands-off web agent's checkout is gone and its
142
+ * session name may be a reused pin) plus a timestamp heuristic on top of it, so that a predecessor's PR on
143
+ * a shared branch name was not mistaken for this agent's. Three sources and a guess, standing in for
144
+ * one integer nobody had written down — the same lesson the `branch` event (#1277) already learned.
145
+ *
146
+ * The *state* is still read live, because it changes without this agent doing anything: a PR merges,
147
+ * a human closes it. That read rides the PR-lookup cache (#1028), and `pending` while it is warming means the
148
+ * caller can ask again rather than render "no PR".
149
+ */
150
+ export declare function resolveAgentPr(cwd: string, agent: PrAgent, prs?: CachedBranchPrLookup): Promise<Cached<LinkedPr | undefined>>;
151
+ /**
152
+ * Merge a finished session's open PR (#1391): the Merge action, pressed by a human saying "it's
153
+ * good, land it". The landing itself is the git host provider's (`merge <number>`): armed to merge on
154
+ * green, merged at once where it is already green, or watched by the provider where the
155
+ * repository allows no auto-merge; a draft is marked ready on the way. Refuses when the agent has
156
+ * no PR or it is no longer open — "already merged" is an answer, not an action.
157
+ */
158
+ export declare function mergeAgentPr(cwd: string, agent: PrAgent, deps?: {
159
+ gitHost?: GitHostFor;
160
+ prs?: CachedBranchPrLookup;
161
+ }): Promise<HandoffResult>;
162
+ /**
163
+ * Read what a finished session left behind, for `branch`: the branch's git facts from the
164
+ * project's branches provider, and the run's own pull request from OpenAgent's lookup.
165
+ *
166
+ * Returns undefined only when the project has no branches provider, or the provider did not
167
+ * answer for the branch. A branch that no longer exists still returns a handoff (with
168
+ * `exists: false`), because "that branch is gone" is itself the answer the dashboard needs to
169
+ * show — and its PR is a remote question, still answerable (#1255).
170
+ */
171
+ export declare function readAgentHandoff(cwd: string, branch: string, deps?: AgentHandoffDeps): Promise<AgentHandoff | undefined>;
172
+ /**
173
+ * What a finished run left behind, off its record: {@link readAgentHandoff} for the branch the
174
+ * record names, measured from the commit the run's own work begins at when the record names one
175
+ * (a run started from another branch holds, beyond the default branch, that branch's work too).
176
+ *
177
+ * A run its main agent landed has no branch left: what it held is read by the last commit its
178
+ * record kept, and the answer says landed. A branch gone because the run changed nothing is said
179
+ * as that, not as lost work. Undefined for a run with neither a branch nor a landed commit.
180
+ */
181
+ export declare function readRunHandoff(cwd: string, agent: Pick<AgentMeta, 'id' | 'startedAt' | 'branch' | 'baseCommit' | 'landed' | 'status' | 'host' | 'pr'>, deps?: AgentHandoffDeps): Promise<AgentHandoff | undefined>;
182
+ /**
183
+ * What a handoff action did. The PR's `number` rides along with its `url` (E6), because the number
184
+ * is the fact worth *recording* — every surface that wants an agent's PR then reads it off the agent
185
+ * rather than re-deriving it later.
186
+ */
187
+ export type HandoffResult = {
188
+ ok: true;
189
+ url?: string;
190
+ number?: number;
191
+ } | {
192
+ ok: false;
193
+ error: string;
194
+ };
195
+ /**
196
+ * Push a finished session's branch (#1820): the last step where the project has no git host, or the
197
+ * step a person wants on its own. The branches provider pushes it under its clean rule; a branch
198
+ * only the remote has is already there. Refuses a session that recorded no branch.
199
+ */
200
+ export declare function pushAgentBranch(cwd: string, agent: Pick<AgentMeta, 'id' | 'branch'>, deps?: {
201
+ branches?: BranchesFor;
202
+ }): Promise<HandoffResult>;
203
+ /**
204
+ * Merge a finished session's branch into the project's default branch, on this machine: how the
205
+ * work reaches the project's own folder where there is no remote to push to. The branches provider
206
+ * merges and deletes the branch; the session's record then keeps the branch's last commit and the
207
+ * commit its work began at, so what it changed is still read once the branch is gone.
208
+ */
209
+ export declare function mergeAgentBranch(cwd: string, agent: Pick<AgentMeta, 'id' | 'branch'>, deps?: {
210
+ branches?: BranchesFor;
211
+ runs?: RunsFor;
212
+ }): Promise<HandoffResult>;
213
+ /**
214
+ * Open a draft PR for a branch that exists only on the remote (#1601): a cloud session's own
215
+ * `claude/*` branch was pushed from a VM this machine never sees, so there is nothing to push
216
+ * here — the provider publishes the branch as the remote has it. Draft because a PR
217
+ * OpenAgent opens by itself must not put a review request in anyone's inbox, and the
218
+ * interventions queue keeps listing a session's draft.
219
+ */
220
+ export declare function openRemoteBranchPullRequest(cwd: string, agent: HandoffAgent, branch: string, deps?: {
221
+ branches?: BranchesFor;
222
+ gitHost?: GitHostFor;
223
+ }): Promise<HandoffResult>;
224
+ /**
225
+ * Open a PR for a finished session, deciding from what the agent recorded which cases should not
226
+ * open one. Reads the branch's handoff first: a branch that no longer exists, or a session that
227
+ * changed nothing, is a clear error rather than an empty PR, and a branch that already has a PR
228
+ * returns that one. Title is its branch, else the id; body is the intent, plus which session did it. This is the handoff decision the
229
+ * dashboard's open-PR button offers; the RPC layer only resolves which run it is about, and the
230
+ * two providers do the pushing and the opening.
231
+ */
232
+ export declare function openAgentPullRequest(cwd: string, agent: AgentMeta, options?: {
233
+ draft?: boolean;
234
+ branches?: BranchesFor;
235
+ gitHost?: GitHostFor;
236
+ pr?: BranchPrLookup;
237
+ }): Promise<HandoffResult>;
238
+ /**
239
+ * The little a handoff needs to know about the agent it is for: which branch, and what to say on
240
+ * the PR. Narrower than {@link AgentMeta} so a caller cannot quietly start depending on the rest
241
+ * of the agent's state.
242
+ */
243
+ export type HandoffAgent = Pick<AgentMeta, 'id' | 'branch' | 'intent'> & Partial<Pick<AgentMeta, 'startedAt'>>;
244
+ //# sourceMappingURL=agent-handoff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-handoff.d.ts","sourceRoot":"","sources":["../../src/dashboard/agent-handoff.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,310 @@
1
+ import { hostname } from 'node:os';
2
+ import { cachedPrView, cachedPrsForBranch, forgetBranchPrs, forgetPr, pickAgentPr } from './pull-requests.js';
3
+ import { projectBranches } from '../store/branches.js';
4
+ import { projectGitHost } from '../store/git-host.js';
5
+ import { projectRuns } from '../store/runs.js';
6
+ /**
7
+ * The branch an agent's work is on: what was recorded while the checkout existed (#799/#1277).
8
+ * The agent renames its branch itself (#1725), so anything but the record is a guess, and a run
9
+ * whose record carries no branch has none to hand off.
10
+ */
11
+ export function agentBranchFor(agent) {
12
+ return agent.branch;
13
+ }
14
+ /**
15
+ * Whether a run whose branch is gone changed nothing (#1850): it ended `done`, `failed` or
16
+ * `stopped` on this machine, has no pull request, and was not landed by a main agent (a landed
17
+ * run's branch went because its work moved on, not for holding nothing). Such a run's own tool recorded the branch's
18
+ * last name as it ended, a Stop included, and then reclaimed the checkout, and the branches rule
19
+ * deletes a branch with the checkout only when it holds nothing. A run whose process died is marked
20
+ * `stopped` by the sweep only when it left no checkout, so it had nowhere to keep a change. A run
21
+ * another machine ran leaves no such proof here, and one `waiting` keeps its checkout.
22
+ */
23
+ export function leftNothing(agent, host = hostname()) {
24
+ return !agent.pr && agent.landed === undefined && (agent.status === 'done' || agent.status === 'failed' || agent.status === 'stopped') && agent.host === host;
25
+ }
26
+ /**
27
+ * The branch's PR as it applies to *this* run: the injected seam when the caller gave one, else
28
+ * the cached history filtered through {@link pickAgentPr} with the agent's start time (#1251).
29
+ */
30
+ async function lookupAgentPr(cwd, branch, deps) {
31
+ if (deps.pr)
32
+ return { value: await deps.pr(cwd, branch).catch(() => undefined), pending: false };
33
+ const prs = await cachedPrsForBranch(cwd, branch).catch(() => ({ value: undefined, pending: false }));
34
+ return { value: prs.value ? pickAgentPr(prs.value, deps.since, deps.order) : undefined, pending: prs.pending };
35
+ }
36
+ /**
37
+ * The pull request that belongs to an agent: the one it recorded (E6), read live for its state.
38
+ *
39
+ * The number is a fact about the agent, so the agent writes it down — at the moment its handoff opens
40
+ * the PR, or when the dashboard's button does after the process is gone. Every surface then reads
41
+ * the same integer instead of re-deriving it.
42
+ *
43
+ * What that replaced: a three-way branch-name ladder (the recorded branch, then a branch built from
44
+ * the session name, then the run-id branch, because a hands-off web agent's checkout is gone and its
45
+ * session name may be a reused pin) plus a timestamp heuristic on top of it, so that a predecessor's PR on
46
+ * a shared branch name was not mistaken for this agent's. Three sources and a guess, standing in for
47
+ * one integer nobody had written down — the same lesson the `branch` event (#1277) already learned.
48
+ *
49
+ * The *state* is still read live, because it changes without this agent doing anything: a PR merges,
50
+ * a human closes it. That read rides the PR-lookup cache (#1028), and `pending` while it is warming means the
51
+ * caller can ask again rather than render "no PR".
52
+ */
53
+ export async function resolveAgentPr(cwd, agent, prs = cachedPrView) {
54
+ if (!agent.pr)
55
+ return { value: undefined, pending: false };
56
+ const branch = agentBranchFor(agent);
57
+ const read = await prs(cwd, branch).catch(() => ({ value: undefined, pending: false }));
58
+ // The live read is about the recorded PR's *state*; a different number on the branch is some
59
+ // other PR and never this agent's answer.
60
+ if (read.value && read.value.number === agent.pr.number)
61
+ return { value: read.value, pending: false };
62
+ // Nothing live to say, so the recorded fact stands on its own: an agent whose PR is on a branch this
63
+ // machine cannot see still has a PR, and its number and URL are what the surfaces need.
64
+ return { value: { ...agent.pr, state: read.pending ? 'OPEN' : 'UNKNOWN', title: '' }, pending: read.pending };
65
+ }
66
+ /**
67
+ * Merge a finished session's open PR (#1391): the Merge action, pressed by a human saying "it's
68
+ * good, land it". The landing itself is the git host provider's (`merge <number>`): armed to merge on
69
+ * green, merged at once where it is already green, or watched by the provider where the
70
+ * repository allows no auto-merge; a draft is marked ready on the way. Refuses when the agent has
71
+ * no PR or it is no longer open — "already merged" is an answer, not an action.
72
+ */
73
+ export async function mergeAgentPr(cwd, agent, deps = {}) {
74
+ const pr = (await resolveAgentPr(cwd, agent, deps.prs)).value;
75
+ if (!pr)
76
+ return { ok: false, error: 'this session has no pull request to merge' };
77
+ if (pr.state !== 'OPEN')
78
+ return { ok: false, error: `this session's PR is already ${pr.state.toLowerCase()}` };
79
+ const gitHost = await (deps.gitHost ?? projectGitHost)(cwd).catch(() => undefined);
80
+ if (!gitHost)
81
+ return { ok: false, error: 'this project has no git host package to merge with' };
82
+ const merged = await gitHost.merge(pr.number);
83
+ if (!merged.ok)
84
+ return { ok: false, error: merged.error };
85
+ // The PR's cached state just changed, so the branch's cached read must go or the bar keeps
86
+ // offering a merge for a PR that landed (#1028).
87
+ const branch = agentBranchFor(agent);
88
+ forgetPr(cwd, branch);
89
+ if (branch !== undefined)
90
+ forgetBranchPrs(cwd, branch);
91
+ return { ok: true, url: pr.url, number: pr.number };
92
+ }
93
+ /**
94
+ * Read what a finished session left behind, for `branch`: the branch's git facts from the
95
+ * project's branches provider, and the run's own pull request from OpenAgent's lookup.
96
+ *
97
+ * Returns undefined only when the project has no branches provider, or the provider did not
98
+ * answer for the branch. A branch that no longer exists still returns a handoff (with
99
+ * `exists: false`), because "that branch is gone" is itself the answer the dashboard needs to
100
+ * show — and its PR is a remote question, still answerable (#1255).
101
+ */
102
+ export async function readAgentHandoff(cwd, branch, deps = {}) {
103
+ const branches = await (deps.branches ?? projectBranches)(cwd).catch(() => undefined);
104
+ if (!branches)
105
+ return undefined;
106
+ const [state] = await branches.show([branch], deps.from);
107
+ if (!state)
108
+ return undefined;
109
+ const gitHost = await (deps.gitHost ?? projectGitHost)(cwd).catch(() => undefined);
110
+ // Read through the cache and allowed to arrive late (#1028): the branch's facts are local
111
+ // git, and none of them should wait on the git host.
112
+ const pr = await lookupAgentPr(cwd, branch, deps);
113
+ const commits = state.commits.map(commit => ({ sha: commit.sha, short: commit.sha.slice(0, 7), subject: commit.subject }));
114
+ const files = state.files.map(file => ({ path: file.path, insertions: file.insertions, deletions: file.deletions, binary: file.binary }));
115
+ return {
116
+ branch,
117
+ ...(state.name ? { name: state.name } : {}),
118
+ exists: state.exists,
119
+ ...(state.base ? { base: state.base } : {}),
120
+ commits,
121
+ files,
122
+ insertions: files.reduce((sum, f) => sum + f.insertions, 0),
123
+ deletions: files.reduce((sum, f) => sum + f.deletions, 0),
124
+ // A session that changed nothing is a real outcome, not an error: it gets said, not shown as
125
+ // an empty branch with buttons that would push nothing. The files decide as well as the
126
+ // commits: commits that net to no change leave nothing to hand off.
127
+ empty: commits.length === 0 || files.length === 0,
128
+ hasRemote: state.hasRemote,
129
+ pushed: state.pushed,
130
+ merged: state.merged,
131
+ gitHost: gitHost !== undefined,
132
+ ...(pr.value ? { pr: pr.value } : {}),
133
+ ...(pr.pending ? { prPending: true } : {}),
134
+ ...(state.pendingFiles ? { pendingFiles: state.pendingFiles } : {}),
135
+ };
136
+ }
137
+ /**
138
+ * What a finished run left behind, off its record: {@link readAgentHandoff} for the branch the
139
+ * record names, measured from the commit the run's own work begins at when the record names one
140
+ * (a run started from another branch holds, beyond the default branch, that branch's work too).
141
+ *
142
+ * A run its main agent landed has no branch left: what it held is read by the last commit its
143
+ * record kept, and the answer says landed. A branch gone because the run changed nothing is said
144
+ * as that, not as lost work. Undefined for a run with neither a branch nor a landed commit.
145
+ */
146
+ export async function readRunHandoff(cwd, agent, deps = {}) {
147
+ const at = agentBranchFor(agent) ?? agent.landed;
148
+ if (at === undefined)
149
+ return undefined;
150
+ // A commit has no pull request to look up: only a branch is asked of the git host.
151
+ const noPr = agentBranchFor(agent) === undefined ? { pr: async () => undefined } : {};
152
+ const handoff = await readAgentHandoff(cwd, at, { since: agent.startedAt, ...(agent.baseCommit !== undefined ? { from: agent.baseCommit } : {}), ...deps, ...noPr });
153
+ if (!handoff)
154
+ return undefined;
155
+ if (agent.landed !== undefined)
156
+ return { ...handoff, landed: true };
157
+ return !handoff.exists && leftNothing(agent) ? { ...handoff, unchanged: true } : handoff;
158
+ }
159
+ /**
160
+ * Open a PR for a branch: the two providers composed (#1820). The branches provider pushes the
161
+ * branch (`push --branch`), then the git host provider opens its request (`open --branch`); the
162
+ * request's base is the git host's. A branch that already has an open request is answered as it is.
163
+ * The branch has a PR now, so the cached "no PR" must go or the bar would keep offering to open
164
+ * one for the next minute (#1028) — both caches: the single-PR view and the history.
165
+ */
166
+ async function publishBranch(cwd, branch, draft, branches, gitHost) {
167
+ const source = await branches(cwd).catch(() => undefined);
168
+ if (!source)
169
+ return { ok: false, error: 'this project has no branches provider to push with' };
170
+ const gitHostSource = await gitHost(cwd).catch(() => undefined);
171
+ if (!gitHostSource)
172
+ return { ok: false, error: 'this project has no git host package to open a pull request with' };
173
+ const pushed = await source.push(branch);
174
+ if (!pushed.ok)
175
+ return { ok: false, error: pushed.error };
176
+ const opened = await gitHostSource.open(branch, { title: draft.title, body: draft.body, ...(draft.draft ? { draft: true } : {}) });
177
+ if (!opened.ok)
178
+ return { ok: false, error: opened.error };
179
+ forgetPr(cwd, branch);
180
+ forgetBranchPrs(cwd, branch);
181
+ return { ok: true, url: opened.request.url, number: opened.request.number };
182
+ }
183
+ /**
184
+ * Push a finished session's branch (#1820): the last step where the project has no git host, or the
185
+ * step a person wants on its own. The branches provider pushes it under its clean rule; a branch
186
+ * only the remote has is already there. Refuses a session that recorded no branch.
187
+ */
188
+ export async function pushAgentBranch(cwd, agent, deps = {}) {
189
+ const branch = agentBranchFor(agent);
190
+ if (branch === undefined)
191
+ return { ok: false, error: 'this session recorded no branch to push' };
192
+ const source = await (deps.branches ?? projectBranches)(cwd).catch(() => undefined);
193
+ if (!source)
194
+ return { ok: false, error: 'this project has no branches provider to push with' };
195
+ const pushed = await source.push(branch);
196
+ return pushed.ok ? { ok: true } : { ok: false, error: pushed.error };
197
+ }
198
+ /**
199
+ * Merge a finished session's branch into the project's default branch, on this machine: how the
200
+ * work reaches the project's own folder where there is no remote to push to. The branches provider
201
+ * merges and deletes the branch; the session's record then keeps the branch's last commit and the
202
+ * commit its work began at, so what it changed is still read once the branch is gone.
203
+ */
204
+ export async function mergeAgentBranch(cwd, agent, deps = {}) {
205
+ const branch = agentBranchFor(agent);
206
+ if (branch === undefined)
207
+ return { ok: false, error: 'this session recorded no branch to merge' };
208
+ const source = await (deps.branches ?? projectBranches)(cwd).catch(() => undefined);
209
+ if (!source)
210
+ return { ok: false, error: 'this project has no branches provider to merge with' };
211
+ const merged = await source.merge(branch);
212
+ if (!merged.ok)
213
+ return { ok: false, error: merged.error };
214
+ if (!merged.deleted)
215
+ return { ok: true };
216
+ const runs = await (deps.runs ?? projectRuns)(cwd).catch(() => undefined);
217
+ const recorded = await runs?.patch(agent.id, { landed: { commit: merged.commit, from: merged.from } });
218
+ // The merge is in whatever the record says; a record that could not be written is said, since the page reads the record.
219
+ if (recorded && !recorded.ok)
220
+ return { ok: false, error: `merged into ${merged.into}, but the record was not updated: ${recorded.error}` };
221
+ return { ok: true };
222
+ }
223
+ /**
224
+ * Open a draft PR for a branch that exists only on the remote (#1601): a cloud session's own
225
+ * `claude/*` branch was pushed from a VM this machine never sees, so there is nothing to push
226
+ * here — the provider publishes the branch as the remote has it. Draft because a PR
227
+ * OpenAgent opens by itself must not put a review request in anyone's inbox, and the
228
+ * interventions queue keeps listing a session's draft.
229
+ */
230
+ export async function openRemoteBranchPullRequest(cwd, agent, branch, deps = {}) {
231
+ return publishBranch(cwd, branch, { title: agentPrTitle(agent), body: agentPrBody(agent), draft: true }, deps.branches ?? projectBranches, deps.gitHost ?? projectGitHost);
232
+ }
233
+ /**
234
+ * Whether the session kept committing after its PR merged or closed (#1512): the PR carries a
235
+ * head, the branch has a tip, and they disagree. False for an open PR (pushed commits still land
236
+ * on it), for a headless read (an older cache or injected lookup — never risk a duplicate PR on
237
+ * a guess), and for a gone branch (no tip to compare; the PR stays the best answer, #1255).
238
+ */
239
+ function movedPastPr(state) {
240
+ if (!state.pr || state.pr.state === 'OPEN')
241
+ return false;
242
+ const tip = state.commits[0]?.sha;
243
+ return Boolean(state.pr.headRefOid && tip && state.pr.headRefOid !== tip);
244
+ }
245
+ /**
246
+ * Open a PR for a finished session, deciding from what the agent recorded which cases should not
247
+ * open one. Reads the branch's handoff first: a branch that no longer exists, or a session that
248
+ * changed nothing, is a clear error rather than an empty PR, and a branch that already has a PR
249
+ * returns that one. Title is its branch, else the id; body is the intent, plus which session did it. This is the handoff decision the
250
+ * dashboard's open-PR button offers; the RPC layer only resolves which run it is about, and the
251
+ * two providers do the pushing and the opening.
252
+ */
253
+ export async function openAgentPullRequest(cwd, agent, options = {}) {
254
+ // A subagent's work goes to its main agent's branch, and that one opens the pull request.
255
+ if (agent.parent !== undefined)
256
+ return { ok: false, error: 'this run is a subagent: its main agent lands its work and opens the pull request' };
257
+ const branch = agentBranchFor(agent);
258
+ if (branch === undefined)
259
+ return { ok: false, error: 'this session recorded no branch to open a PR from' };
260
+ const branches = options.branches ?? projectBranches;
261
+ const gitHost = options.gitHost ?? projectGitHost;
262
+ // `latest` order (#1512), because the `movedPastPr` decision below compares the branch tip
263
+ // against a PR's head: against the *first* PR, work a second one already landed reads as
264
+ // unlanded and this opens a third for it.
265
+ const handoff = await readAgentHandoff(cwd, branch, { since: agent.startedAt, order: 'latest', branches, gitHost, ...(options.pr ? { pr: options.pr } : {}), ...(agent.baseCommit !== undefined ? { from: agent.baseCommit } : {}) }).catch(() => undefined);
266
+ // The agent's PR first, even when its branch is gone locally: a hands-off web agent's branch only
267
+ // ever existed on the remote, and its PR is the answer the button exists to give (#1255).
268
+ // Unless the session demonstrably kept committing after that PR merged or closed (#1512) —
269
+ // then the old PR is not the answer, the new work needs its own.
270
+ if (handoff?.pr && !movedPastPr(handoff))
271
+ return { ok: true, url: handoff.pr.url, number: handoff.pr.number };
272
+ if (handoff && !handoff.exists)
273
+ return { ok: false, error: `branch ${branch} no longer exists` };
274
+ // Refuse rather than open an empty PR: a session that changed nothing has nothing to hand off.
275
+ if (handoff?.empty)
276
+ return { ok: false, error: 'this session produced no commits to open a PR for' };
277
+ // Its commits are still counted once the default branch has them, from where its work began: nothing is left to open one for.
278
+ if (handoff?.merged)
279
+ return { ok: false, error: 'this session’s work is already merged' };
280
+ return publishBranch(cwd, branch, { title: agentPrTitle(agent, handoff?.name), body: agentPrBody(agent), ...(options.draft ? { draft: true } : {}) }, branches, gitHost);
281
+ }
282
+ /**
283
+ * The PR title for a session (#1102).
284
+ *
285
+ * Two rungs, each a name for the work the session did: the branch the agent named its work with
286
+ * (#1725), else the session id — which says little, but says it honestly. An agent that publishes
287
+ * its own work titles its own PR; this is only the title of one a person opens for it.
288
+ *
289
+ * The prompt the session was given is not among them. It used to be, cut to 72 characters, and a
290
+ * squash merge made that permanent: `main` ended up carrying instructions truncated mid-sentence
291
+ * as commit subjects, which describe neither what changed nor even a whole thought (#1618).
292
+ */
293
+ function agentPrTitle(agent, name) {
294
+ // The name the branches provider answers for the branch comes before the branch itself:
295
+ // OpenAgent draws the name it is given and never cuts the package's prefix off a branch.
296
+ return name ?? agent.branch ?? `Session ${agent.id}`;
297
+ }
298
+ /**
299
+ * The PR body: what was asked for, which is all OpenAgent knows on its own, and which session
300
+ * did it.
301
+ */
302
+ function agentPrBody(agent) {
303
+ const lines = [];
304
+ const opening = agent.intent?.trim();
305
+ if (opening)
306
+ lines.push(opening, '');
307
+ lines.push(`Opened from OpenAgent session \`${agent.id}\`.`);
308
+ return lines.join('\n');
309
+ }
310
+ //# sourceMappingURL=agent-handoff.js.map