@agimon-ai/po-runner 0.0.0-alpha.21 → 0.0.0-alpha.211

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 (332) hide show
  1. package/LICENSE +21 -149
  2. package/README.md +34 -206
  3. package/dist/apiContracts.cjs +45 -2
  4. package/dist/apiContracts.cjs.map +1 -1
  5. package/dist/apiContracts.d.mts +2 -2
  6. package/dist/apiContracts.d.mts.map +1 -1
  7. package/dist/apiContracts.mjs +45 -2
  8. package/dist/apiContracts.mjs.map +1 -1
  9. package/dist/{bashResult-BqDa7sbC.mjs → bashResult-BLCLerXE.mjs} +57 -7
  10. package/dist/bashResult-BLCLerXE.mjs.map +1 -0
  11. package/dist/{bashResult-C2iKhHpD.cjs → bashResult-CZYiyl4p.cjs} +74 -6
  12. package/dist/bashResult-CZYiyl4p.cjs.map +1 -0
  13. package/dist/{bashResult-DcrRaBLv.d.mts → bashResult-CgVS_JpL.d.mts} +8 -3
  14. package/dist/{bashResult-DcrRaBLv.d.mts.map → bashResult-CgVS_JpL.d.mts.map} +1 -1
  15. package/dist/{bashRunService-DjOH5kye.cjs → bashRunService-DmuA1mKL.cjs} +52 -31
  16. package/dist/bashRunService-DmuA1mKL.cjs.map +1 -0
  17. package/dist/{bashRunService-Ci0cGdYO.d.mts → bashRunService-Iotfc_nV.d.mts} +21 -2
  18. package/dist/bashRunService-Iotfc_nV.d.mts.map +1 -0
  19. package/dist/{bashRunService-Cl3pYccr.mjs → bashRunService-Luy2hPMS.mjs} +52 -31
  20. package/dist/bashRunService-Luy2hPMS.mjs.map +1 -0
  21. package/dist/bashRunService.cjs +1 -1
  22. package/dist/bashRunService.d.mts +4 -4
  23. package/dist/bashRunService.d.mts.map +1 -1
  24. package/dist/bashRunService.mjs +1 -1
  25. package/dist/bashSchema.cjs +1 -1
  26. package/dist/bashSchema.d.mts +1 -1
  27. package/dist/bashSchema.mjs +1 -1
  28. package/dist/bashTool-D2ECDAhc.cjs +43 -0
  29. package/dist/bashTool-D2ECDAhc.cjs.map +1 -0
  30. package/dist/{bashTool-B1EwZLo_.d.mts → bashTool-Dc1ld2E3.d.mts} +3 -9
  31. package/dist/bashTool-Dc1ld2E3.d.mts.map +1 -0
  32. package/dist/bashTool-vg8uhbkj.mjs +26 -0
  33. package/dist/bashTool-vg8uhbkj.mjs.map +1 -0
  34. package/dist/bashTool.cjs +3 -3
  35. package/dist/bashTool.cjs.map +1 -1
  36. package/dist/bashTool.d.mts +4 -4
  37. package/dist/bashTool.d.mts.map +1 -1
  38. package/dist/bashTool.mjs +3 -3
  39. package/dist/bashTool.mjs.map +1 -1
  40. package/dist/bin/cli.cjs +372 -9
  41. package/dist/bin/cli.cjs.map +1 -1
  42. package/dist/bin/cli.d.mts.map +1 -1
  43. package/dist/bin/cli.mjs +369 -8
  44. package/dist/bin/cli.mjs.map +1 -1
  45. package/dist/bin/logSink.cjs +27 -24
  46. package/dist/bin/logSink.cjs.map +1 -1
  47. package/dist/bin/logSink.mjs +24 -21
  48. package/dist/bin/logSink.mjs.map +1 -1
  49. package/dist/bin/runnerHost.cjs +141 -53
  50. package/dist/bin/runnerHost.cjs.map +1 -1
  51. package/dist/bin/runnerHost.d.mts.map +1 -1
  52. package/dist/bin/runnerHost.mjs +141 -53
  53. package/dist/bin/runnerHost.mjs.map +1 -1
  54. package/dist/cliApp-7iTUx5KZ.cjs +351 -0
  55. package/dist/cliApp-7iTUx5KZ.cjs.map +1 -0
  56. package/dist/cliApp-S4iEO-fi.mjs +338 -0
  57. package/dist/cliApp-S4iEO-fi.mjs.map +1 -0
  58. package/dist/cliApp.cjs +2 -1
  59. package/dist/cliApp.d.mts +9 -4
  60. package/dist/cliApp.d.mts.map +1 -1
  61. package/dist/cliApp.mjs +1 -1
  62. package/dist/compaction.d.mts +1 -1
  63. package/dist/extensions/mcp-ui.mjs +7 -6
  64. package/dist/extensions/mcp-ui.mjs.map +1 -1
  65. package/dist/extensions/mcp.cjs +37 -17
  66. package/dist/extensions/mcp.cjs.map +1 -1
  67. package/dist/extensions/mcp.d.mts.map +1 -1
  68. package/dist/extensions/mcp.mjs +37 -17
  69. package/dist/extensions/mcp.mjs.map +1 -1
  70. package/dist/extensions/native.mjs +1225 -374
  71. package/dist/extensions/native.mjs.map +1 -1
  72. package/dist/extensions/server.cjs +900 -221
  73. package/dist/extensions/server.cjs.map +1 -1
  74. package/dist/extensions/server.d.mts.map +1 -1
  75. package/dist/extensions/server.mjs +908 -227
  76. package/dist/extensions/server.mjs.map +1 -1
  77. package/dist/extensions/web.mjs +924 -766
  78. package/dist/extensions/web.mjs.map +1 -1
  79. package/dist/headless-CMj9hunm.cjs +237 -0
  80. package/dist/headless-CMj9hunm.cjs.map +1 -0
  81. package/dist/headless-CUJt5Ihx.mjs +226 -0
  82. package/dist/headless-CUJt5Ihx.mjs.map +1 -0
  83. package/dist/{index-DM7yJpMs.d.mts → index-7_nuKoVm.d.mts} +6 -6
  84. package/dist/index-7_nuKoVm.d.mts.map +1 -0
  85. package/dist/index-BCCF1sGD.d.mts.map +1 -1
  86. package/dist/{index-CzCF_OP9.d.mts → index-CH-z0BX3.d.mts} +11 -4
  87. package/dist/index-CH-z0BX3.d.mts.map +1 -0
  88. package/dist/{index-C-IC35d9.d.mts → index-CJNsR-Ir.d.mts} +10 -7
  89. package/dist/index-CJNsR-Ir.d.mts.map +1 -0
  90. package/dist/{index--xF7DvsE.d.mts → index-CNCb1usM.d.mts} +8 -2
  91. package/dist/index-CNCb1usM.d.mts.map +1 -0
  92. package/dist/index-EMbmq9gu.d.mts +45 -0
  93. package/dist/index-EMbmq9gu.d.mts.map +1 -0
  94. package/dist/index-QlfncPRs.d.mts +58 -0
  95. package/dist/index-QlfncPRs.d.mts.map +1 -0
  96. package/dist/index-qSi4-EJW.d.mts +49 -0
  97. package/dist/index-qSi4-EJW.d.mts.map +1 -0
  98. package/dist/index.cjs +4 -4
  99. package/dist/index.d.mts +4 -4
  100. package/dist/index.mjs +4 -4
  101. package/dist/launch.cjs +4 -0
  102. package/dist/launch.d.mts +55 -0
  103. package/dist/launch.d.mts.map +1 -0
  104. package/dist/launch.mjs +1 -0
  105. package/dist/{launcher-CCYsFBM9.mjs → launcher-3xMxw72I.mjs} +45 -31
  106. package/dist/launcher-3xMxw72I.mjs.map +1 -0
  107. package/dist/{launcher-BG5t9nvG.d.mts → launcher-CDDBTvZq.d.mts} +4 -3
  108. package/dist/launcher-CDDBTvZq.d.mts.map +1 -0
  109. package/dist/{launcher-ZgDdyXpq.cjs → launcher-D7qAhSRL.cjs} +47 -33
  110. package/dist/launcher-D7qAhSRL.cjs.map +1 -0
  111. package/dist/launcher.cjs +1 -1
  112. package/dist/launcher.d.mts +5 -5
  113. package/dist/launcher.d.mts.map +1 -1
  114. package/dist/launcher.mjs +1 -1
  115. package/dist/lifeline-26IaW5w7.d.mts +34 -0
  116. package/dist/lifeline-26IaW5w7.d.mts.map +1 -0
  117. package/dist/lifeline-B4cjtrBe.cjs +27 -0
  118. package/dist/lifeline-B4cjtrBe.cjs.map +1 -0
  119. package/dist/lifeline-C1v2ItCY.mjs +214 -0
  120. package/dist/lifeline-C1v2ItCY.mjs.map +1 -0
  121. package/dist/lifeline-D4_ZRAhO.cjs +229 -0
  122. package/dist/lifeline-D4_ZRAhO.cjs.map +1 -0
  123. package/dist/lifeline-nPh3cx5A.mjs +10 -0
  124. package/dist/lifeline-nPh3cx5A.mjs.map +1 -0
  125. package/dist/lifeline.cjs +4 -1
  126. package/dist/lifeline.d.mts +4 -21
  127. package/dist/lifeline.mjs +3 -3
  128. package/dist/logFile-B9FSwmE0.cjs +44 -0
  129. package/dist/logFile-B9FSwmE0.cjs.map +1 -0
  130. package/dist/{logFile-C7oQ_v-g.d.mts → logFile-BirfZtS1.d.mts} +4 -4
  131. package/dist/logFile-BirfZtS1.d.mts.map +1 -0
  132. package/dist/logFile-D1EOKqmL.mjs +39 -0
  133. package/dist/logFile-D1EOKqmL.mjs.map +1 -0
  134. package/dist/logFile.cjs +1 -1
  135. package/dist/logFile.d.mts +3 -3
  136. package/dist/logFile.d.mts.map +1 -1
  137. package/dist/logFile.mjs +1 -1
  138. package/dist/{logReader-mq9uVurh.mjs → logReader-BYKii_s_.mjs} +99 -52
  139. package/dist/logReader-BYKii_s_.mjs.map +1 -0
  140. package/dist/{logReader-MdW9ffvV.d.mts → logReader-Bn3WEdjg.d.mts} +4 -2
  141. package/dist/{logReader-MdW9ffvV.d.mts.map → logReader-Bn3WEdjg.d.mts.map} +1 -1
  142. package/dist/{logReader-DHCK2BEr.cjs → logReader-DpMjBqfn.cjs} +101 -54
  143. package/dist/logReader-DpMjBqfn.cjs.map +1 -0
  144. package/dist/logReader.cjs +1 -1
  145. package/dist/logReader.d.mts +2 -2
  146. package/dist/logReader.mjs +1 -1
  147. package/dist/po-runtime-identity.json +1 -0
  148. package/dist/{ptyHost-D35hNmtd.cjs → ptyHost-C-oWV455.cjs} +20 -14
  149. package/dist/ptyHost-C-oWV455.cjs.map +1 -0
  150. package/dist/{ptyHost-CwbLLr90.mjs → ptyHost-C2zu-ZfO.mjs} +19 -13
  151. package/dist/ptyHost-C2zu-ZfO.mjs.map +1 -0
  152. package/dist/{ptyHost-DWWtRrGn.d.mts → ptyHost-C_6x2xuJ.d.mts} +2 -2
  153. package/dist/{ptyHost-DWWtRrGn.d.mts.map → ptyHost-C_6x2xuJ.d.mts.map} +1 -1
  154. package/dist/ptyHost.cjs +1 -1
  155. package/dist/ptyHost.d.mts +2 -2
  156. package/dist/ptyHost.d.mts.map +1 -1
  157. package/dist/ptyHost.mjs +1 -1
  158. package/dist/{reconcile-wNYQJZF-.mjs → reconcile-DUaX_vKZ.mjs} +2 -2
  159. package/dist/reconcile-DUaX_vKZ.mjs.map +1 -0
  160. package/dist/{reconcile-5cZ11jSD.cjs → reconcile-DjF9T1hN.cjs} +2 -2
  161. package/dist/reconcile-DjF9T1hN.cjs.map +1 -0
  162. package/dist/reconcile.cjs +1 -1
  163. package/dist/reconcile.d.mts +3 -3
  164. package/dist/reconcile.mjs +1 -1
  165. package/dist/responseEnvelope.cjs +5 -2
  166. package/dist/responseEnvelope.d.mts +15 -6
  167. package/dist/responseEnvelope.d.mts.map +1 -1
  168. package/dist/responseEnvelope.mjs +3 -3
  169. package/dist/{rmuxBackend-Dh0CYVAL.cjs → rmuxBackend-9tHTx1vf.cjs} +82 -48
  170. package/dist/rmuxBackend-9tHTx1vf.cjs.map +1 -0
  171. package/dist/{rmuxBackend-rjrVTG6K.mjs → rmuxBackend-BaK-R35I.mjs} +79 -45
  172. package/dist/rmuxBackend-BaK-R35I.mjs.map +1 -0
  173. package/dist/{rmuxBackend-CaEWooWn.d.mts → rmuxBackend-xFzlANM9.d.mts} +4 -4
  174. package/dist/rmuxBackend-xFzlANM9.d.mts.map +1 -0
  175. package/dist/rmuxBackend.cjs +1 -1
  176. package/dist/rmuxBackend.d.mts +2 -2
  177. package/dist/rmuxBackend.mjs +1 -1
  178. package/dist/rolldown-runtime-8H4AJuhK.mjs +14 -0
  179. package/dist/{rolldown-runtime-VH7oDXx4.cjs → rolldown-runtime-C0BPl7ul.cjs} +15 -0
  180. package/dist/{rtkProcessor-Iw9gP5Xp.mjs → rtkProcessor-DOXcp51z.mjs} +6 -5
  181. package/dist/rtkProcessor-DOXcp51z.mjs.map +1 -0
  182. package/dist/{rtkProcessor-DSGbM-Cm.cjs → rtkProcessor-J2gLQvM4.cjs} +8 -6
  183. package/dist/rtkProcessor-J2gLQvM4.cjs.map +1 -0
  184. package/dist/rtkProcessor.cjs +1 -1
  185. package/dist/rtkProcessor.mjs +1 -1
  186. package/dist/{runnerDependencies-DSun3xO-.cjs → runnerDependencies-CABYjW7H.cjs} +97 -64
  187. package/dist/runnerDependencies-CABYjW7H.cjs.map +1 -0
  188. package/dist/{runnerDependencies-7h_cxOva.mjs → runnerDependencies-DmvIcpZi.mjs} +95 -62
  189. package/dist/runnerDependencies-DmvIcpZi.mjs.map +1 -0
  190. package/dist/runnerDependencies.cjs +1 -1
  191. package/dist/runnerDependencies.d.mts +1 -1
  192. package/dist/runnerDependencies.mjs +1 -1
  193. package/dist/runnerHost-BvNYPMeh.mjs +165 -0
  194. package/dist/runnerHost-BvNYPMeh.mjs.map +1 -0
  195. package/dist/runnerHost-C2F5oxzn.cjs +184 -0
  196. package/dist/runnerHost-C2F5oxzn.cjs.map +1 -0
  197. package/dist/runnerLaunch-BAf7hXMr.cjs +192 -0
  198. package/dist/runnerLaunch-BAf7hXMr.cjs.map +1 -0
  199. package/dist/runnerLaunch-Bimgdh4h.mjs +175 -0
  200. package/dist/runnerLaunch-Bimgdh4h.mjs.map +1 -0
  201. package/dist/runnerNamer.d.mts +1 -1
  202. package/dist/{runnerPaths-B41rMOY6.cjs → runnerPaths-CSkswyjR.cjs} +97 -179
  203. package/dist/runnerPaths-CSkswyjR.cjs.map +1 -0
  204. package/dist/{runnerPaths-Dibbvyx_.mjs → runnerPaths-D3P7_EhW.mjs} +91 -179
  205. package/dist/runnerPaths-D3P7_EhW.mjs.map +1 -0
  206. package/dist/runnerPaths.cjs +1 -1
  207. package/dist/runnerPaths.d.mts +7 -9
  208. package/dist/runnerPaths.d.mts.map +1 -1
  209. package/dist/runnerPaths.mjs +1 -1
  210. package/dist/{runnerRegistry-dQYlMSpQ.cjs → runnerRegistry-B8K1L3lq.cjs} +68 -45
  211. package/dist/runnerRegistry-B8K1L3lq.cjs.map +1 -0
  212. package/dist/{runnerRegistry-V-Ocaf4N.d.mts → runnerRegistry-BlZhS9yL.d.mts} +2 -2
  213. package/dist/{runnerRegistry-V-Ocaf4N.d.mts.map → runnerRegistry-BlZhS9yL.d.mts.map} +1 -1
  214. package/dist/{runnerRegistry-BgaR5O86.mjs → runnerRegistry-Dqca6SD3.mjs} +53 -29
  215. package/dist/runnerRegistry-Dqca6SD3.mjs.map +1 -0
  216. package/dist/runnerRegistry-NW6oAJ71.cjs +60 -0
  217. package/dist/runnerRegistry-NW6oAJ71.cjs.map +1 -0
  218. package/dist/runnerRegistry-l0C_55oO.mjs +13 -0
  219. package/dist/runnerRegistry-l0C_55oO.mjs.map +1 -0
  220. package/dist/runnerRegistry.cjs +1 -1
  221. package/dist/runnerRegistry.d.mts +2 -2
  222. package/dist/runnerRegistry.mjs +1 -1
  223. package/dist/runnerSequence-ZTYgZ_2W.cjs +32 -0
  224. package/dist/runnerSequence-ZTYgZ_2W.cjs.map +1 -0
  225. package/dist/runnerSequence-k-_Fd77y.mjs +9 -0
  226. package/dist/runnerSequence-k-_Fd77y.mjs.map +1 -0
  227. package/dist/runnerSequenceStore-CaY7S_Sd.mjs +76 -0
  228. package/dist/runnerSequenceStore-CaY7S_Sd.mjs.map +1 -0
  229. package/dist/runnerSequenceStore-Ck6M-8r_.cjs +89 -0
  230. package/dist/runnerSequenceStore-Ck6M-8r_.cjs.map +1 -0
  231. package/dist/services/lifeline/client.cjs +88 -4
  232. package/dist/services/lifeline/client.cjs.map +1 -1
  233. package/dist/services/lifeline/client.d.mts +16 -0
  234. package/dist/services/lifeline/client.d.mts.map +1 -1
  235. package/dist/services/lifeline/client.mjs +83 -2
  236. package/dist/services/lifeline/client.mjs.map +1 -1
  237. package/dist/services/runnerSupervisor/index.cjs +36 -22
  238. package/dist/services/runnerSupervisor/index.cjs.map +1 -1
  239. package/dist/services/runnerSupervisor/index.d.mts +7 -5
  240. package/dist/services/runnerSupervisor/index.d.mts.map +1 -1
  241. package/dist/services/runnerSupervisor/index.mjs +35 -21
  242. package/dist/services/runnerSupervisor/index.mjs.map +1 -1
  243. package/dist/session-CdVeSD7F.mjs +8 -0
  244. package/dist/session-CdVeSD7F.mjs.map +1 -0
  245. package/dist/session-DnUj8Q71.cjs +25 -0
  246. package/dist/session-DnUj8Q71.cjs.map +1 -0
  247. package/dist/session-ISEGK4z9.mjs +26 -0
  248. package/dist/session-ISEGK4z9.mjs.map +1 -0
  249. package/dist/session-PQd3azWf.cjs +43 -0
  250. package/dist/session-PQd3azWf.cjs.map +1 -0
  251. package/dist/session.cjs +4 -3
  252. package/dist/session.d.mts +3 -1
  253. package/dist/session.d.mts.map +1 -1
  254. package/dist/session.mjs +3 -3
  255. package/dist/{type-DwMZoINK.d.mts → type-BWY9vvSq.d.mts} +6 -4
  256. package/dist/type-BWY9vvSq.d.mts.map +1 -0
  257. package/dist/{type-Do0YxwVQ.d.mts → type-bZgYQ7hv.d.mts} +11 -11
  258. package/dist/{type-Do0YxwVQ.d.mts.map → type-bZgYQ7hv.d.mts.map} +1 -1
  259. package/dist/types.d.mts +1 -1
  260. package/llms.txt +2 -1
  261. package/locales/vi.json +169 -0
  262. package/locales/zh-CN.json +169 -0
  263. package/package.json +95 -30
  264. package/skills/po-runner/SKILL.md +32 -14
  265. package/src/prompts/codemode-how-to-runner/SKILL.md +85 -0
  266. package/src/prompts/help-how-to-runner/SKILL.md +51 -0
  267. package/dist/bashResult-BqDa7sbC.mjs.map +0 -1
  268. package/dist/bashResult-C2iKhHpD.cjs.map +0 -1
  269. package/dist/bashRunService-Ci0cGdYO.d.mts.map +0 -1
  270. package/dist/bashRunService-Cl3pYccr.mjs.map +0 -1
  271. package/dist/bashRunService-DjOH5kye.cjs.map +0 -1
  272. package/dist/bashTool-B1EwZLo_.d.mts.map +0 -1
  273. package/dist/bashTool-BvC3YOgG.mjs +0 -24
  274. package/dist/bashTool-BvC3YOgG.mjs.map +0 -1
  275. package/dist/bashTool-euL6zMDl.cjs +0 -41
  276. package/dist/bashTool-euL6zMDl.cjs.map +0 -1
  277. package/dist/cliApp-T8Fx_-1j.cjs +0 -244
  278. package/dist/cliApp-T8Fx_-1j.cjs.map +0 -1
  279. package/dist/cliApp-q97eVh4E.mjs +0 -237
  280. package/dist/cliApp-q97eVh4E.mjs.map +0 -1
  281. package/dist/headless-DOlCixyf.mjs +0 -169
  282. package/dist/headless-DOlCixyf.mjs.map +0 -1
  283. package/dist/headless-Dko_yBiy.cjs +0 -180
  284. package/dist/headless-Dko_yBiy.cjs.map +0 -1
  285. package/dist/index--xF7DvsE.d.mts.map +0 -1
  286. package/dist/index-BzeXJk6V.d.mts +0 -12
  287. package/dist/index-BzeXJk6V.d.mts.map +0 -1
  288. package/dist/index-C-IC35d9.d.mts.map +0 -1
  289. package/dist/index-CzCF_OP9.d.mts.map +0 -1
  290. package/dist/index-DM7yJpMs.d.mts.map +0 -1
  291. package/dist/launcher-BG5t9nvG.d.mts.map +0 -1
  292. package/dist/launcher-CCYsFBM9.mjs.map +0 -1
  293. package/dist/launcher-ZgDdyXpq.cjs.map +0 -1
  294. package/dist/lifeline-Bm-bHIjS.mjs +0 -88
  295. package/dist/lifeline-Bm-bHIjS.mjs.map +0 -1
  296. package/dist/lifeline-eJdZV0nN.d.mts +0 -19
  297. package/dist/lifeline-eJdZV0nN.d.mts.map +0 -1
  298. package/dist/lifeline-m7laIzIP.cjs +0 -98
  299. package/dist/lifeline-m7laIzIP.cjs.map +0 -1
  300. package/dist/lifeline.d.mts.map +0 -1
  301. package/dist/logFile-C7oQ_v-g.d.mts.map +0 -1
  302. package/dist/logFile-CnPKtxPy.cjs +0 -67
  303. package/dist/logFile-CnPKtxPy.cjs.map +0 -1
  304. package/dist/logFile-XcDHBwu1.mjs +0 -60
  305. package/dist/logFile-XcDHBwu1.mjs.map +0 -1
  306. package/dist/logReader-DHCK2BEr.cjs.map +0 -1
  307. package/dist/logReader-mq9uVurh.mjs.map +0 -1
  308. package/dist/ptyHost-CwbLLr90.mjs.map +0 -1
  309. package/dist/ptyHost-D35hNmtd.cjs.map +0 -1
  310. package/dist/reconcile-5cZ11jSD.cjs.map +0 -1
  311. package/dist/reconcile-wNYQJZF-.mjs.map +0 -1
  312. package/dist/rmuxBackend-CaEWooWn.d.mts.map +0 -1
  313. package/dist/rmuxBackend-Dh0CYVAL.cjs.map +0 -1
  314. package/dist/rmuxBackend-rjrVTG6K.mjs.map +0 -1
  315. package/dist/rtkProcessor-DSGbM-Cm.cjs.map +0 -1
  316. package/dist/rtkProcessor-Iw9gP5Xp.mjs.map +0 -1
  317. package/dist/runnerDependencies-7h_cxOva.mjs.map +0 -1
  318. package/dist/runnerDependencies-DSun3xO-.cjs.map +0 -1
  319. package/dist/runnerPaths-B41rMOY6.cjs.map +0 -1
  320. package/dist/runnerPaths-Dibbvyx_.mjs.map +0 -1
  321. package/dist/runnerRegistry-BgaR5O86.mjs.map +0 -1
  322. package/dist/runnerRegistry-dQYlMSpQ.cjs.map +0 -1
  323. package/dist/session-BKYnH4R6.mjs +0 -18
  324. package/dist/session-BKYnH4R6.mjs.map +0 -1
  325. package/dist/session-BvqzhXZY.cjs +0 -29
  326. package/dist/session-BvqzhXZY.cjs.map +0 -1
  327. package/dist/session-DE2Acesp.mjs +0 -6
  328. package/dist/session-DE2Acesp.mjs.map +0 -1
  329. package/dist/session-SfIPtdZO.cjs +0 -11
  330. package/dist/session-SfIPtdZO.cjs.map +0 -1
  331. package/dist/type-DwMZoINK.d.mts.map +0 -1
  332. package/src/prompts/po-use-runner/SKILL.md +0 -47
@@ -2,27 +2,40 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_rolldown_runtime = require("../rolldown-runtime-VH7oDXx4.cjs");
5
+ const require_rolldown_runtime = require("../rolldown-runtime-C0BPl7ul.cjs");
6
6
  const require_runnerConfig = require("../runnerConfig-BoLMinlx.cjs");
7
- const require_logReader = require("../logReader-DHCK2BEr.cjs");
8
- const require_headless = require("../headless-Dko_yBiy.cjs");
9
- const require_reconcile = require("../reconcile-5cZ11jSD.cjs");
7
+ const require_runnerSequence = require("../runnerSequence-ZTYgZ_2W.cjs");
8
+ const require_bashTool = require("../bashTool-D2ECDAhc.cjs");
9
+ const require_bashResult = require("../bashResult-CZYiyl4p.cjs");
10
+ const require_logReader = require("../logReader-DpMjBqfn.cjs");
11
+ const require_headless = require("../headless-CMj9hunm.cjs");
12
+ const require_reconcile = require("../reconcile-DjF9T1hN.cjs");
13
+ const require_runnerSequenceStore = require("../runnerSequenceStore-Ck6M-8r_.cjs");
10
14
  const require_clock = require("../clock-jqnLWziT.cjs");
11
15
  const require_compaction = require("../compaction-Cduebib_.cjs");
12
- const require_rmuxBackend = require("../rmuxBackend-Dh0CYVAL.cjs");
13
- const require_launcher = require("../launcher-ZgDdyXpq.cjs");
14
- const require_runnerDependencies = require("../runnerDependencies-DSun3xO-.cjs");
15
- const require_runnerPaths = require("../runnerPaths-B41rMOY6.cjs");
16
- const require_runnerRegistry = require("../runnerRegistry-dQYlMSpQ.cjs");
17
- let node_fs = require("node:fs");
18
- node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
16
+ const require_rmuxBackend = require("../rmuxBackend-9tHTx1vf.cjs");
17
+ const require_launcher = require("../launcher-D7qAhSRL.cjs");
18
+ const require_lifeline = require("../lifeline-D4_ZRAhO.cjs");
19
+ const require_runnerDependencies = require("../runnerDependencies-CABYjW7H.cjs");
20
+ const require_runnerPaths = require("../runnerPaths-CSkswyjR.cjs");
21
+ require("../runnerRegistry-NW6oAJ71.cjs");
22
+ const require_runnerRegistry$1 = require("../runnerRegistry-B8K1L3lq.cjs");
23
+ const require_runnerLaunch = require("../runnerLaunch-BAf7hXMr.cjs");
24
+ const require_runnerHost = require("../runnerHost-C2F5oxzn.cjs");
25
+ let node_fs_promises = require("node:fs/promises");
26
+ node_fs_promises = require_rolldown_runtime.__toESM(node_fs_promises, 1);
19
27
  let node_path = require("node:path");
20
28
  node_path = require_rolldown_runtime.__toESM(node_path, 1);
21
- let _agimon_ai_po_core_childProcess = require("@agimon-ai/po-core/childProcess");
29
+ let _agimon_ai_po_core_locale = require("@agimon-ai/po-core/locale");
30
+ let _agimon_ai_po_core_platform = require("@agimon-ai/po-core/platform");
22
31
  let _agimon_ai_po_core_serverPlugin = require("@agimon-ai/po-core/serverPlugin");
23
32
  let _agimon_ai_po_core_extensionFile = require("@agimon-ai/po-core/extensionFile");
33
+ let _agimon_ai_po_core_codemode = require("@agimon-ai/po-core/codemode");
34
+ let _agimon_ai_po_core_telemetry = require("@agimon-ai/po-core/telemetry");
35
+ let _agimon_ai_po_core_workflow = require("@agimon-ai/po-core/workflow");
24
36
  let _agimon_ai_po_core_backgroundWork = require("@agimon-ai/po-core/backgroundWork");
25
- let _agimon_ai_po_telemetry = require("@agimon-ai/po-telemetry");
37
+ let typebox_value = require("typebox/value");
38
+ let _agimon_ai_po_core_childProcess = require("@agimon-ai/po-core/childProcess");
26
39
  let _earendil_works_pi_coding_agent = require("@earendil-works/pi-coding-agent");
27
40
  let hono = require("hono");
28
41
  let hono_streaming = require("hono/streaming");
@@ -38,107 +51,630 @@ const MAX_RESULT_BYTES_CEILING = 262144;
38
51
  const MAX_RESULT_LINES_CEILING = 5e3;
39
52
  const MAX_RESULT_TOKENS_CEILING = 1e5;
40
53
  //#endregion
41
- //#region src/services/runnerHost/index.ts
42
- const describe = (error) => error instanceof Error ? error.message : String(error);
43
- /** Runs `pass` again `ms` after the previous pass finished, so two passes never overlap. */
44
- function repeat(clock, ms, pass) {
45
- let stopped = false;
46
- let cancel;
47
- let running;
48
- const arm = () => {
49
- cancel = clock.after(ms, () => {
50
- cancel = void 0;
51
- running = pass().finally(() => {
52
- running = void 0;
53
- if (!stopped) arm();
54
- });
54
+ //#region src/constants/runnerLogApi.ts
55
+ const LOG_DIR_NAME = "logs";
56
+ const STATE_EXTENSION = ".json";
57
+ const RUNNING_STATE = "running";
58
+ const STATE_POLL_MS = 1e3;
59
+ const HEARTBEAT_MS = 15e3;
60
+ const MAX_LINES = 5e3;
61
+ const SAFE_SEGMENT = /^[\w.@-]+$/;
62
+ const RAW_LOG_SUFFIX = ".raw";
63
+ const MAX_INPUT_CHARS = 4096;
64
+ /** Ceiling for one finite log/screen read, before base64 encoding. */
65
+ const MAX_OUTPUT_BYTES = 65536;
66
+ const NOT_ATTACHABLE = "No attachable runner by that name in this session.";
67
+ //#endregion
68
+ //#region src/services/runnerOperations/index.ts
69
+ function runnerId(value) {
70
+ if (typeof value !== "string" || value.length > 256 || value === "." || value === ".." || !SAFE_SEGMENT.test(value)) throw new Error("id must be a non-empty runner ID, not a path.");
71
+ return value;
72
+ }
73
+ /** Session-owned controls shared by native code mode and the CLI. */
74
+ function createRunnerOperations(options) {
75
+ const { sessionId, registry } = options;
76
+ if (!sessionId) throw new Error("Runner controls require a session.");
77
+ const owned = (record) => {
78
+ runnerId(record.id);
79
+ if (record.sessionId !== sessionId) throw new Error("Runner belongs to another session.");
80
+ return record;
81
+ };
82
+ const status = async (id) => {
83
+ runnerId(id);
84
+ const record = await registry.get(id, sessionId);
85
+ if (!record || record.id !== id) throw new Error(`No runner with id ${id} in this session.`);
86
+ return owned(record);
87
+ };
88
+ const list = async (all = false) => (await (all ? registry.listAll(sessionId) : registry.listBySession(sessionId))).map(owned);
89
+ const stop = async (id, reason, assertAvailable = () => void 0) => {
90
+ const record = await status(id);
91
+ assertAvailable();
92
+ if (record.state !== "running") return {
93
+ id,
94
+ stopped: false,
95
+ reason: "Runner is already completed."
96
+ };
97
+ const stopped = await require_reconcile.stopRunnerProcess(record, options.launcher, options.rmuxBackend, {
98
+ registry,
99
+ intent: {
100
+ reason: "stopped",
101
+ terminationReason: "user_stop",
102
+ ...reason ? { stopReason: reason } : {}
103
+ }
55
104
  });
105
+ if (stopped) await registry.complete(id, {
106
+ reason: "stopped",
107
+ code: null,
108
+ signal: "SIGTERM",
109
+ ...reason ? { stopReason: reason } : {}
110
+ }, sessionId);
111
+ return {
112
+ id,
113
+ stopped
114
+ };
115
+ };
116
+ return {
117
+ list,
118
+ status,
119
+ async logs(id, query = {}, assertAvailable = () => void 0) {
120
+ const record = await status(id);
121
+ assertAvailable();
122
+ const expected = options.paths.logPathFor(id, sessionId);
123
+ if (record.logPath !== expected) throw new Error("Runner log is outside its admitted session path.");
124
+ const exists = await options.fs.exists(expected, _agimon_ai_po_core_platform.BACKGROUND_CONTEXT);
125
+ if (!exists.ok) throw exists.error;
126
+ if (exists.value) {
127
+ const [root, file] = await Promise.all([options.fs.canonicalPath(options.paths.logDirectory(sessionId), _agimon_ai_po_core_platform.BACKGROUND_CONTEXT), options.fs.canonicalPath(expected, _agimon_ai_po_core_platform.BACKGROUND_CONTEXT)]);
128
+ if (!root.ok) throw root.error;
129
+ if (!file.ok) throw file.error;
130
+ if (!file.value.startsWith(`${root.value.replace(/\/$/u, "")}/`)) throw new Error("Runner log resolves outside its session.");
131
+ }
132
+ const lines = query.lines ?? 200;
133
+ if (!Number.isInteger(lines) || lines < 1 || lines > 5e3) throw new Error(`lines must be an integer between 1 and ${MAX_LINES}.`);
134
+ if (query.contextLines !== void 0 && (!Number.isInteger(query.contextLines) || query.contextLines < 0 || query.contextLines > 5e3)) throw new Error(`contextLines must be an integer between 0 and ${MAX_LINES}.`);
135
+ assertAvailable();
136
+ const slice = await options.logReader.read(expected, {
137
+ ...query,
138
+ lines
139
+ });
140
+ const bounded = require_bashResult.boundExcerpt(slice.text, lines, MAX_OUTPUT_BYTES);
141
+ const { lineNumbers, ...metadata } = slice;
142
+ return {
143
+ ...metadata,
144
+ text: bounded.text,
145
+ lineCount: bounded.lines,
146
+ truncated: slice.truncated || bounded.truncated || slice.lineCount < slice.totalLines,
147
+ ...lineNumbers && !bounded.truncated ? { lineNumbers } : {}
148
+ };
149
+ },
150
+ stop,
151
+ async stopAll(reason, assertAvailable = () => void 0) {
152
+ const results = [];
153
+ for (const record of await list()) {
154
+ assertAvailable();
155
+ try {
156
+ results.push(await stop(record.id, reason, assertAvailable));
157
+ } catch (error) {
158
+ results.push({
159
+ id: record.id,
160
+ stopped: false,
161
+ reason: String(error)
162
+ });
163
+ }
164
+ }
165
+ return results;
166
+ },
167
+ async input(id, text = "", enter = false, assertAvailable = () => void 0) {
168
+ const record = await status(id);
169
+ assertAvailable();
170
+ if (record.state !== "running" || !record.interactive || !["rmux", "tmux"].includes(record.backend) || !record.backendTarget) throw new Error("Input requires a running interactive RMUX or tmux runner.");
171
+ runnerId(record.backendTarget);
172
+ const payload = enter && !text.endsWith("\n") ? `${text}\n` : text;
173
+ if (!payload || payload.length > 4096) throw new Error(`Input must contain between 1 and ${MAX_INPUT_CHARS} characters.`);
174
+ if (!await options.rmuxBackend.input(record.backendTarget, payload)) throw new Error("The runner is no longer accepting input.");
175
+ return {
176
+ id,
177
+ delivered: true
178
+ };
179
+ }
56
180
  };
57
- arm();
58
- return { async stop() {
59
- stopped = true;
60
- cancel?.();
61
- await running;
62
- } };
63
181
  }
64
- /**
65
- * The housekeeping every session running one po-runner build in one hub shares.
66
- *
67
- * A session used to open its own registry connection and arm its own status poll and history
68
- * sweep, and each sweep walked the whole runner store. Here one loop refreshes the attached sessions
69
- * one at a time, one sweep per store spares every attached session at once, and runners a crashed
70
- * server left behind are reclaimed once rather than at every session start.
71
- */
72
- function createRunnerHost(options) {
73
- const sessions = /* @__PURE__ */ new Set();
74
- let closed = false;
75
- let reclaiming;
76
- let sweeping;
77
- const refreshAll = async () => {
78
- for (const session of sessions) {
79
- if (closed) return;
182
+ //#endregion
183
+ //#region src/services/runnerNamespace/index.ts
184
+ const DECLARATIONS = `declare namespace Runner {
185
+ interface Record {
186
+ id: string; name: string; command: string; cwd: string; sessionId: string;
187
+ state: 'running' | 'completed'; backend: 'rmux' | 'tmux' | 'native';
188
+ pid: number; logPath: string; interactive: boolean; startedAt: string; promoted: boolean;
189
+ exit?: { reason: string; code: number | null; signal: string | null; finishedAt: string; stopReason?: string };
190
+ }
191
+ interface Stage {
192
+ index: number; command: string; state: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled' | 'denied';
193
+ id?: string; logPath?: string; exitCode?: number | null;
194
+ }
195
+ interface Result { content: { type: string; text?: string }[]; details?: unknown; isError?: boolean; }
196
+ interface Sequence {
197
+ id: string; sessionId: string; name: string; state: 'running' | 'completed';
198
+ outcome?: string; promoted: boolean; createdAt: string; stages?: Stage[]; result?: Result;
199
+ }
200
+ interface Logs {
201
+ text: string; lineCount: number; totalLines: number; fileSize: number; completeBytes: number;
202
+ path: string; exists: boolean; truncated: boolean; lineNumbers?: number[];
203
+ }
204
+ interface Stop { id: string; stopped?: boolean; requested?: boolean; reason?: string; }
205
+ }
206
+ declare const runner: {
207
+ /** Active runners and sequences in this session; all includes retained history. */
208
+ list(input?: { all?: boolean }): Promise<(Runner.Record | Runner.Sequence)[]>;
209
+ /** Running sequences expose stages. Completed sequences expose only the guarded result, including its allowed manifest. */
210
+ status(input: { id: string }): Promise<Runner.Record | Runner.Sequence>;
211
+ /** Finite process log snapshot, or a sequence manifest with its guarded final result. */
212
+ logs(input: { id: string; lines?: number; grep?: string; ignoreCase?: boolean; contextLines?: number }): Promise<Runner.Logs | Runner.Sequence>;
213
+ /** Stop a process or request cancellation of an entire sequence. Requested is not confirmed stopped. */
214
+ stop(input: { id: string; reason?: string }): Promise<Runner.Stop>;
215
+ /** Stop this session's active work. Outcomes are per ID, not unconditional success. */
216
+ stopAll(input?: { reason?: string }): Promise<Runner.Stop[]>;
217
+ /** Send input to a running interactive process, never to a sequence. */
218
+ input(input: { id: string; text?: string; enter?: boolean }): Promise<{ id: string; delivered: boolean }>;
219
+ };`;
220
+ function parameters(input, fields, optional = false) {
221
+ if (input === void 0 && optional) return {};
222
+ if (typeof input === "string" && fields.includes("id")) return { id: input };
223
+ if (input === null || typeof input !== "object" || Array.isArray(input)) throw new Error(`Expected an object with the documented runner fields: ${fields.join(", ")}.`);
224
+ for (const key of Object.keys(input)) if (!fields.includes(key)) throw new Error(`Unknown runner field: ${key}. Allowed: ${fields.join(", ")}.`);
225
+ return input;
226
+ }
227
+ function optionalString(record, field) {
228
+ const value = record[field];
229
+ if (value !== void 0 && (typeof value !== "string" || value.length > 4096)) throw new Error(`${field} must be a string of at most ${MAX_INPUT_CHARS} characters.`);
230
+ return value;
231
+ }
232
+ function optionalBoolean(record, field) {
233
+ const value = record[field];
234
+ if (value !== void 0 && typeof value !== "boolean") throw new Error(`${field} must be a boolean.`);
235
+ return value;
236
+ }
237
+ function sequenceView(record) {
238
+ const { id, sessionId, name, state, outcome, promoted, createdAt, stages, result } = record;
239
+ return {
240
+ id,
241
+ sessionId,
242
+ name,
243
+ state,
244
+ outcome,
245
+ promoted,
246
+ createdAt,
247
+ ...state === "running" ? { stages } : {},
248
+ result
249
+ };
250
+ }
251
+ function createRunnerNamespace(options) {
252
+ return {
253
+ name: "runner",
254
+ summary: "Inspect supervised Bash processes and sequential command groups, read saved logs, provide interactive input, and stop unused work.",
255
+ declarations: DECLARATIONS,
256
+ bind(run) {
257
+ if (run.sessionId !== options.sessionId) throw new Error("Runner namespace belongs to another session.");
258
+ const disposal = new AbortController();
259
+ const signal = AbortSignal.any([run.signal, disposal.signal]);
260
+ run.onDispose(() => disposal.abort(/* @__PURE__ */ new Error("Runner namespace run is disposed.")));
261
+ const check = () => {
262
+ signal.throwIfAborted();
263
+ options.assertAvailable();
264
+ };
265
+ const detached = async (work) => {
266
+ check();
267
+ const value = await work();
268
+ check();
269
+ return JSON.parse(JSON.stringify(value));
270
+ };
271
+ const sequence = async (id) => {
272
+ if (!require_runnerSequenceStore.isSequenceId(id)) return void 0;
273
+ const record = await options.sequences?.get(id);
274
+ check();
275
+ if (record && (record.id !== id || record.sessionId !== options.sessionId)) throw new Error("Sequence belongs to another session.");
276
+ return record;
277
+ };
278
+ const stop = async (id, reason) => {
279
+ if (await sequence(id)) return options.sequences.stop(id, reason);
280
+ check();
281
+ return options.operations.stop(id, reason, check);
282
+ };
283
+ const members = Object.create(null);
284
+ members.list = (input) => detached(async () => {
285
+ const all = optionalBoolean(parameters(input, ["all"], true), "all");
286
+ const processes = await options.operations.list(all);
287
+ check();
288
+ const sequences = await options.sequences?.list(all) ?? [];
289
+ for (const item of sequences) if (item.sessionId !== options.sessionId) throw new Error("Sequence belongs to another session.");
290
+ return [...processes, ...sequences.map(sequenceView)];
291
+ });
292
+ members.status = (input) => detached(async () => {
293
+ const id = runnerId(parameters(input, ["id"]).id);
294
+ const found = await sequence(id);
295
+ return found ? sequenceView(found) : options.operations.status(id);
296
+ });
297
+ members.logs = (input) => detached(async () => {
298
+ const record = parameters(input, [
299
+ "id",
300
+ "lines",
301
+ "grep",
302
+ "ignoreCase",
303
+ "contextLines"
304
+ ]);
305
+ const id = runnerId(record.id);
306
+ const grep = optionalString(record, "grep");
307
+ const ignoreCase = optionalBoolean(record, "ignoreCase");
308
+ for (const [field, minimum] of [["lines", 1], ["contextLines", 0]]) {
309
+ const value = record[field];
310
+ if (value !== void 0 && (!Number.isInteger(value) || Number(value) < minimum || Number(value) > 5e3)) throw new Error(`${field} must be an integer between ${minimum} and ${MAX_LINES}.`);
311
+ }
312
+ const found = await sequence(id);
313
+ if (found) return sequenceView(found);
314
+ return options.operations.logs(id, {
315
+ lines: record.lines,
316
+ contextLines: record.contextLines,
317
+ grep,
318
+ ignoreCase
319
+ }, check);
320
+ });
321
+ members.stop = (input) => detached(async () => {
322
+ const record = parameters(input, ["id", "reason"]);
323
+ return stop(runnerId(record.id), optionalString(record, "reason"));
324
+ });
325
+ members.stopAll = (input) => detached(async () => {
326
+ const reason = optionalString(parameters(input, ["reason"], true), "reason");
327
+ const outcomes = [];
328
+ const sequences = await options.sequences?.list() ?? [];
329
+ for (const item of sequences) {
330
+ check();
331
+ if (item.sessionId !== options.sessionId) throw new Error("Sequence belongs to another session.");
332
+ try {
333
+ outcomes.push(await options.sequences.stop(item.id, reason));
334
+ } catch (error) {
335
+ outcomes.push({
336
+ id: item.id,
337
+ stopped: false,
338
+ reason: String(error)
339
+ });
340
+ }
341
+ }
342
+ check();
343
+ return [...outcomes, ...await options.operations.stopAll(reason, check)];
344
+ });
345
+ members.input = (input) => detached(async () => {
346
+ const record = parameters(input, [
347
+ "id",
348
+ "text",
349
+ "enter"
350
+ ]);
351
+ const id = runnerId(record.id);
352
+ const text = optionalString(record, "text");
353
+ const enter = optionalBoolean(record, "enter");
354
+ if (await sequence(id)) throw new Error("Input is only available for an interactive process, not a sequence.");
355
+ return options.operations.input(id, text, enter, check);
356
+ });
357
+ return members;
358
+ }
359
+ };
360
+ }
361
+ //#endregion
362
+ //#region src/services/runnerSequence/index.ts
363
+ function validateSequenceCommands(command) {
364
+ if (!Array.isArray(command) || command.length === 0 || command.length > 32 || command.some((item) => typeof item !== "string" || !item.trim() || item.length > 65536)) throw require_bashResult.bashFailureError(`command must contain 1 to 32 nonempty Bash strings, each at most ${require_runnerSequence.MAX_SEQUENCE_COMMAND_LENGTH} characters.`, "invalid_arguments");
365
+ }
366
+ function validateTimeout(timeout) {
367
+ if (timeout !== void 0 && (typeof timeout !== "number" || !Number.isFinite(timeout) || timeout <= 0)) throw require_bashResult.bashFailureError("A sequence timeout must be a finite positive number of seconds.", "invalid_arguments");
368
+ }
369
+ const textResult = (text, details, isError = false) => ({
370
+ content: [{
371
+ type: "text",
372
+ text
373
+ }],
374
+ ...details ? { details } : {},
375
+ ...isError ? { isError: true } : {}
376
+ });
377
+ /** The session owns continuation, not the tool-call signal that expires on promotion. */
378
+ function createRunnerSequenceService(options) {
379
+ const { dependencies, store } = options;
380
+ const owner = crypto.randomUUID();
381
+ const active = /* @__PURE__ */ new Map();
382
+ const notifications = /* @__PURE__ */ new Map();
383
+ let disposed = false;
384
+ let refreshing;
385
+ const assertAvailable = () => {
386
+ if (disposed) throw new Error("Runner sequence service is disposed.");
387
+ options.signal?.throwIfAborted();
388
+ };
389
+ const save = async (record) => {
390
+ await store.save(record);
391
+ options.onChange();
392
+ };
393
+ let recovery;
394
+ const recover = () => {
395
+ recovery ??= (async () => {
396
+ for (const record of await store.list(true)) {
397
+ if (disposed) return;
398
+ if (record.state === "running") {
399
+ record.state = "completed";
400
+ record.outcome = "interrupted";
401
+ record.notificationPending = false;
402
+ record.result = textResult("Sequence interrupted because its owning runtime ended. Pending commands were not replayed.", {
403
+ id: record.id,
404
+ sequenceId: record.id,
405
+ sequence: true
406
+ }, true);
407
+ await save(record);
408
+ } else if (record.notificationPending) active.set(record.id, { record });
409
+ }
410
+ })().catch((error) => {
411
+ recovery = void 0;
412
+ throw error;
413
+ });
414
+ return recovery;
415
+ };
416
+ const notify = (record) => {
417
+ const pending = notifications.get(record.id);
418
+ if (pending) return pending;
419
+ if (!record.notificationPending || !record.result || disposed) return Promise.resolve();
420
+ const work = (async () => {
80
421
  try {
81
- await session.refresh();
422
+ await options.onComplete?.(record);
423
+ await store.save({
424
+ ...record,
425
+ notificationPending: false
426
+ });
427
+ record.notificationPending = false;
428
+ options.onChange();
82
429
  } catch (error) {
83
- options.onWarning(`Could not refresh po-runner session ${session.sessionId}: ${describe(error)}`);
430
+ options.onWarning(`Could not report sequence ${record.id}: ${String(error)}`);
84
431
  }
85
- }
432
+ })().finally(() => notifications.delete(record.id));
433
+ notifications.set(record.id, work);
434
+ return work;
86
435
  };
87
- const sweepAll = () => {
88
- sweeping ??= (async () => {
89
- try {
90
- const byStore = /* @__PURE__ */ new Map();
91
- for (const session of sessions) {
92
- const store = session.paths.storeDirectory();
93
- byStore.set(store, [...byStore.get(store) ?? [], session]);
436
+ const details = (record, tail = "") => ({
437
+ id: record.id,
438
+ sequenceId: record.id,
439
+ sequence: true,
440
+ runner: record.name,
441
+ stages: structuredClone(record.stages),
442
+ tail
443
+ });
444
+ const execute = async (record, controller, params, context, toolCallId, onInteractiveStarted, onUpdate) => {
445
+ let last = textResult("No command was executed.");
446
+ let finalArgs = {
447
+ ...params,
448
+ command: record.stages[0].command,
449
+ background: false,
450
+ interactive: false
451
+ };
452
+ const continuation = context.toolContinuation;
453
+ try {
454
+ for (const stage of record.stages) {
455
+ assertAvailable();
456
+ if (await store.stopRequested(record.id)) controller.abort(/* @__PURE__ */ new Error("Sequence stop requested."));
457
+ controller.signal.throwIfAborted();
458
+ const interactive = params.interactive === true && stage.index === record.stages.length - 1;
459
+ finalArgs = {
460
+ ...params,
461
+ command: stage.command,
462
+ background: false,
463
+ interactive
464
+ };
465
+ const args = await continuation.admit({
466
+ toolCallId: `${toolCallId}:${record.id}:${stage.index}`,
467
+ toolName: "bash",
468
+ args: finalArgs,
469
+ signal: controller.signal
470
+ });
471
+ if (typeof args.command !== "string" || !typebox_value.Value.Check(require_bashTool.BashParamsSchema, {
472
+ ...args,
473
+ command: [args.command]
474
+ }) || args.interactive === true && !interactive || args.background === true) throw require_bashResult.bashFailureError("A sequence hook must return one foreground Bash command; only the last may be interactive.", "invalid_arguments");
475
+ validateSequenceCommands([args.command]);
476
+ validateTimeout(args.timeout);
477
+ stage.command = args.command;
478
+ finalArgs = args;
479
+ controller.signal.throwIfAborted();
480
+ if (await store.stopRequested(record.id)) throw require_bashResult.bashFailureError("Sequence stop requested.", "cancelled");
481
+ stage.state = "running";
482
+ await save(record);
483
+ if (!record.promoted) onUpdate?.(textResult(`Running command ${stage.index + 1}/${record.stages.length}: ${stage.command}`, details(record)));
484
+ const result = await dependencies.bashRunService.run({
485
+ command: stage.command,
486
+ cwd: context.cwd,
487
+ sessionId: options.sessionId,
488
+ waitForExit: true,
489
+ interactive: args.interactive === true,
490
+ ...typeof args.name === "string" ? { name: args.name } : {},
491
+ signal: controller.signal,
492
+ ...typeof args.timeout === "number" ? { timeoutMs: args.timeout * 1e3 } : {},
493
+ onStarted: async (run) => {
494
+ stage.id = run.id;
495
+ stage.logPath = run.logPath;
496
+ await save(record);
497
+ if (args.interactive === true) onInteractiveStarted();
498
+ }
499
+ });
500
+ if (result.kind !== "failed") {
501
+ stage.id = result.id;
502
+ stage.logPath = result.logPath;
503
+ }
504
+ try {
505
+ last = await require_bashResult.formatRunResult(result, require_bashResult.parseResultPragma(stage.command), options.summarizeLog, dependencies.settings, dependencies.environment, false);
506
+ } catch (error) {
507
+ last = textResult(error instanceof Error ? error.message : String(error), { failure: require_bashResult.bashFailure(require_bashResult.bashFailureReason(error, "result_format_failed")) }, true);
94
508
  }
95
- for (const group of byStore.values()) {
96
- const [first] = group;
97
- if (closed || first === void 0) return;
98
- const live = new Set(group.map((session) => session.sessionId));
99
- const now = options.clock.now();
100
- const result = first.paths.sweepHistoryAsync ? await first.paths.sweepHistoryAsync(first.historyTtlMs, now, live) : first.paths.sweepHistory(first.historyTtlMs, now, live);
101
- for (const error of result.errors) options.onWarning(error);
509
+ const succeeded = result.kind === "completed" && result.exitCode === 0 && result.signal === null && !result.timedOut && !result.aborted;
510
+ stage.state = succeeded ? "completed" : controller.signal.aborted ? "cancelled" : "failed";
511
+ if (result.kind === "completed") stage.exitCode = result.exitCode;
512
+ if (!succeeded) {
513
+ record.outcome = controller.signal.aborted ? "cancelled" : result.kind === "completed" && result.timedOut ? "timed_out" : "failed";
514
+ last.isError = true;
515
+ if (result.kind === "promoted") last = textResult(`Could not stop command ${stage.index + 1}; runner ${result.id} remains supervised.`, { failure: require_bashResult.bashFailure("stop_failed") }, true);
516
+ break;
102
517
  }
103
- } catch (error) {
104
- options.onWarning(`Could not sweep po-runner history: ${describe(error)}`);
518
+ await save(record);
105
519
  }
106
- })().finally(() => {
107
- sweeping = void 0;
108
- });
109
- return sweeping;
520
+ record.outcome ??= "completed";
521
+ } catch (error) {
522
+ const reason = controller.signal.aborted ? "cancelled" : require_bashResult.bashFailureReason(error, "internal_error");
523
+ const state = reason === "cancelled" ? "cancelled" : reason === "approval_denied" ? "denied" : "failed";
524
+ record.outcome = state;
525
+ const stage = record.stages.find((item) => item.state === "running" || item.state === "pending");
526
+ if (stage) stage.state = state;
527
+ last = textResult(error instanceof Error ? error.message : String(error), { failure: require_bashResult.bashFailure(reason) }, true);
528
+ }
529
+ for (const stage of record.stages) if (stage.state === "pending") stage.state = "cancelled";
530
+ const lastDetails = typeof last.details === "object" && last.details !== null ? last.details : {};
531
+ const tail = typeof lastDetails.tail === "string" ? lastDetails.tail : last.content.map((part) => "text" in part ? part.text : "").join("\n");
532
+ const manifest = record.stages.filter((stage) => stage.logPath).map((stage) => `${stage.index + 1}. ${stage.logPath}`).join("\n");
533
+ const aggregate = {
534
+ ...last,
535
+ content: [{
536
+ type: "text",
537
+ text: [manifest ? `Command logs:\n${manifest}` : "No command logs were created.", last.content.map((part) => "text" in part ? part.text : "").join("\n")].join("\n\n")
538
+ }],
539
+ details: {
540
+ ...lastDetails,
541
+ ...details(record, tail),
542
+ ...record.outcome === "timed_out" ? { timedOut: true } : {}
543
+ },
544
+ ...record.outcome !== "completed" ? { isError: true } : {}
545
+ };
546
+ try {
547
+ record.result = await continuation.finalize({
548
+ toolCallId: `${toolCallId}:${record.id}:result`,
549
+ toolName: "bash",
550
+ args: finalArgs,
551
+ result: aggregate,
552
+ ...options.signal ? { signal: options.signal } : {}
553
+ });
554
+ } catch (error) {
555
+ record.outcome = "finalization_failed";
556
+ record.result = textResult("Sequence finished, but its result could not pass the session result policy.", {
557
+ id: record.id,
558
+ sequenceId: record.id,
559
+ sequence: true,
560
+ failure: require_bashResult.bashFailure("result_policy_failed")
561
+ }, true);
562
+ options.onWarning(`Could not finalize sequence ${record.id}: ${String(error)}`);
563
+ }
564
+ record.state = "completed";
565
+ record.notificationPending = record.promoted && record.notify;
566
+ await save(record);
567
+ await notify(record);
110
568
  };
111
- const polling = repeat(options.clock, options.statusPollMs, refreshAll);
112
- const sweeper = repeat(options.clock, options.historySweepMs, sweepAll);
113
569
  return {
114
- processRegistry: {
115
- registerProcess: (...args) => options.processRegistry.registerProcess(...args),
116
- releaseProcess: (...args) => options.processRegistry.releaseProcess(...args),
117
- listProcesses: (...args) => options.processRegistry.listProcesses(...args),
118
- close: () => void 0
119
- },
120
- attach(session) {
121
- if (closed) throw new Error("The po-runner host is disposed.");
122
- sessions.add(session);
123
- if (reclaiming === void 0) {
124
- reclaiming = session.reclaimOrphans().catch((error) => options.onWarning(`Could not reclaim orphaned runners: ${describe(error)}`));
125
- sweepAll();
126
- }
127
- return () => {
128
- sessions.delete(session);
570
+ store,
571
+ async run(params, context, toolCallId, signal, onUpdate, wakeOnExit = true) {
572
+ assertAvailable();
573
+ if (context.sessionId !== options.sessionId) throw new Error("Sequence belongs to another session.");
574
+ validateSequenceCommands(params.command);
575
+ validateTimeout(params.timeout);
576
+ if (!context.toolContinuation) throw new Error("This host does not support guarded Bash command sequences.");
577
+ signal?.throwIfAborted();
578
+ await recover();
579
+ assertAvailable();
580
+ signal?.throwIfAborted();
581
+ const controller = new AbortController();
582
+ const abort = () => controller.abort(signal?.reason);
583
+ signal?.addEventListener("abort", abort, { once: true });
584
+ const ownerAbort = () => controller.abort(options.signal?.reason);
585
+ options.signal?.addEventListener("abort", ownerAbort, { once: true });
586
+ const record = {
587
+ id: `${require_runnerSequence.SEQUENCE_PREFIX}${crypto.randomUUID()}`,
588
+ owner,
589
+ sessionId: options.sessionId,
590
+ name: params.name ?? "command-sequence",
591
+ state: "running",
592
+ promoted: params.background === true,
593
+ notify: wakeOnExit && params.background !== true,
594
+ notificationPending: false,
595
+ createdAt: new Date(dependencies.clock.now()).toISOString(),
596
+ stages: params.command.map((command, index) => ({
597
+ index,
598
+ command,
599
+ state: "pending"
600
+ }))
129
601
  };
602
+ let cancelTimer;
603
+ let promoteInteractive;
604
+ const promotion = new Promise((resolve) => {
605
+ promoteInteractive = () => resolve("promoted");
606
+ if (params.background) resolve("promoted");
607
+ else cancelTimer = dependencies.clock.after(require_runnerConfig.getBackgroundThresholdMs(dependencies.environment), () => resolve("promoted"));
608
+ });
609
+ const entry = {
610
+ record,
611
+ controller,
612
+ work: Promise.resolve()
613
+ };
614
+ active.set(record.id, entry);
615
+ entry.work = save(record).then(() => execute(record, controller, params, context, toolCallId, promoteInteractive, onUpdate)).finally(() => {
616
+ options.signal?.removeEventListener("abort", ownerAbort);
617
+ if (!record.notificationPending) active.delete(record.id);
618
+ });
619
+ entry.work.catch((error) => options.onWarning(`Sequence ${record.id} failed: ${String(error)}`));
620
+ try {
621
+ if (await Promise.race([entry.work.then(() => "completed"), promotion]) === "completed" || record.state === "completed") {
622
+ await entry.work;
623
+ return record.result;
624
+ }
625
+ record.promoted = true;
626
+ await save(record);
627
+ return textResult([`Sequence ${record.name} (${record.id}) continues in the background. Inspect its status before retrying.`, ...params.interactive ? ["Only the last command is interactive. Inspect its stage runner ID and logs, then send input with runner.input or po-runner input using that stage ID, not the sequence ID."] : []].join("\n"), {
628
+ ...details(record),
629
+ promoted: true
630
+ });
631
+ } finally {
632
+ cancelTimer?.();
633
+ signal?.removeEventListener("abort", abort);
634
+ }
635
+ },
636
+ async stop(id, reason) {
637
+ const requested = await store.requestStop(id, reason);
638
+ active.get(id)?.controller?.abort(new Error(reason ?? "Sequence stop requested."));
639
+ return requested;
640
+ },
641
+ list: (includeCompleted) => store.list(includeCompleted),
642
+ get: (id) => store.get(id),
643
+ activeWork() {
644
+ return [...active.values()].filter(({ record }) => record.state === "running" || record.notificationPending).map(({ record }) => ({
645
+ id: record.id,
646
+ sessionId: record.sessionId,
647
+ label: record.name,
648
+ ...record.state === "running" ? { status: record.notify ? "running" : _agimon_ai_po_core_backgroundWork.BACKGROUND_SERVICE_STATUS } : {}
649
+ }));
650
+ },
651
+ refresh() {
652
+ if (disposed) return Promise.resolve();
653
+ refreshing ??= (async () => {
654
+ await recover();
655
+ for (const { record, controller } of active.values()) {
656
+ if (disposed) return;
657
+ if (record.state === "running" && controller && await store.stopRequested(record.id)) controller.abort(/* @__PURE__ */ new Error("Sequence stop requested."));
658
+ await notify(record);
659
+ if (record.state === "completed" && !record.notificationPending) active.delete(record.id);
660
+ }
661
+ })().finally(() => {
662
+ refreshing = void 0;
663
+ });
664
+ return refreshing;
665
+ },
666
+ async recoveryText() {
667
+ return (await store.list()).map((record) => `Active sequence ${record.name} (${record.id}), inspect runner.status({ id: ${JSON.stringify(record.id)} }).`).join("\n");
130
668
  },
131
669
  async dispose() {
132
- if (closed) return;
133
- closed = true;
134
- sessions.clear();
135
- await Promise.all([
136
- polling.stop(),
137
- sweeper.stop(),
138
- reclaiming,
139
- sweeping
670
+ if (disposed) return;
671
+ disposed = true;
672
+ for (const { controller } of active.values()) controller?.abort(/* @__PURE__ */ new Error("Runner session ended."));
673
+ await Promise.allSettled([
674
+ recovery,
675
+ refreshing,
676
+ ...[...active.values()].map(({ work }) => work)
140
677
  ]);
141
- options.processRegistry.close();
142
678
  }
143
679
  };
144
680
  }
@@ -152,7 +688,7 @@ const RUNNER_RUNS_TYPE = "runner_runs";
152
688
  function parseRunnerRecord(raw) {
153
689
  try {
154
690
  const parsed = JSON.parse(raw);
155
- return require_runnerRegistry.isRunnerRecord(parsed) ? parsed : void 0;
691
+ return require_runnerRegistry$1.isRunnerRecord(parsed) ? parsed : void 0;
156
692
  } catch {
157
693
  return;
158
694
  }
@@ -197,15 +733,7 @@ function presentRunnerRuns(records, now) {
197
733
  //#endregion
198
734
  //#region src/services/runnerServerRuntime/index.ts
199
735
  const COMPLETION_RETRY_MS = 1e3;
200
- function createRunnerServerRuntime(container, host, directEvents, wakeAgent, execution) {
201
- const telemetry = execution ? (0, _agimon_ai_po_telemetry.createPoTelemetry)({
202
- serviceName: "po-runner",
203
- packageName: "@agimon-ai/po-runner",
204
- cwd: execution.cwd,
205
- env: execution.environment,
206
- enableLogs: true,
207
- enableTraces: true
208
- }) : void 0;
736
+ function createRunnerServerRuntime(container, host, directEvents, wakeAgent, execution, telemetry) {
209
737
  let sessionId;
210
738
  let recoveredCompactionId;
211
739
  let supervision;
@@ -220,6 +748,9 @@ function createRunnerServerRuntime(container, host, directEvents, wakeAgent, exe
220
748
  let retryTimer;
221
749
  /** Stops the shared loop refreshing this session and sweeping around it. */
222
750
  let detach;
751
+ let startFailure;
752
+ let startFailures = 0;
753
+ let sequences;
223
754
  /** Every runner of every session the registry knows, reclaimed when its owning process is gone. */
224
755
  const reclaimOrphans = async () => {
225
756
  const reclaimed = await require_reconcile.reconcileActiveRunners({
@@ -283,6 +814,7 @@ function createRunnerServerRuntime(container, host, directEvents, wakeAgent, exe
283
814
  const ownedSessionId = sessionId;
284
815
  if (ownedSessionId === void 0) return;
285
816
  await (0, _agimon_ai_po_core_extensionFile.runCleanups)([
817
+ () => sequences?.dispose(),
286
818
  async () => {
287
819
  const records = await container.runnerRegistry.listBySession(ownedSessionId);
288
820
  const errors = (await Promise.allSettled(records.map(async (record) => {
@@ -310,6 +842,13 @@ function createRunnerServerRuntime(container, host, directEvents, wakeAgent, exe
310
842
  },
311
843
  () => container.ptyHost.disposeAll(),
312
844
  () => container.lifeline.dispose(),
845
+ () => require_runnerHost.cleanupRunnerSession({
846
+ sessionId: ownedSessionId,
847
+ paths: container.paths,
848
+ processRegistry: container.processRegistry,
849
+ ownerPid: process.pid,
850
+ generation: container.lifeline.generation?.()
851
+ }),
313
852
  () => container.runnerRegistry.close()
314
853
  ], "Runner runtime cleanup failed.");
315
854
  })();
@@ -326,6 +865,7 @@ function createRunnerServerRuntime(container, host, directEvents, wakeAgent, exe
326
865
  const refreshNow = async (ownedSessionId) => {
327
866
  if (closing) return;
328
867
  try {
868
+ await sequences?.refresh();
329
869
  const reconciled = await require_reconcile.reconcileActiveRunners({
330
870
  registry: container.runnerRegistry,
331
871
  launcher: container.launcher,
@@ -344,6 +884,7 @@ function createRunnerServerRuntime(container, host, directEvents, wakeAgent, exe
344
884
  process.emitWarning(`Could not refresh po-runner: ${String(error)}`);
345
885
  }
346
886
  };
887
+ let sentRuns;
347
888
  const publishRuns = async (ownedSessionId) => {
348
889
  try {
349
890
  const records = await container.runnerRegistry.listAll(ownedSessionId);
@@ -352,20 +893,30 @@ function createRunnerServerRuntime(container, host, directEvents, wakeAgent, exe
352
893
  const root = (0, _agimon_ai_po_core_childProcess.resolveRootSessionId)(ownedSessionId, container.environment);
353
894
  const count = (await container.runnerRegistry.list()).filter((record) => (record.rootSessionId ?? record.sessionId) === root).length;
354
895
  if (closing) return;
355
- execution.client.setStatus(RUNNER_STATUS_KEY, require_runnerRegistry.formatRunnerStatus(count));
896
+ execution.client.setStatus(RUNNER_STATUS_KEY, require_runnerRegistry$1.formatRunnerStatus(count));
356
897
  }
357
898
  if (closing) return;
358
899
  const nextBackgroundWork = records.filter((record) => record.state === "running" || watched.has(record.id)).map((record) => ({
359
900
  id: record.id,
360
901
  sessionId: record.sessionId,
361
902
  label: record.name,
362
- ...record.state === "running" ? { status: record.state } : {}
903
+ ...record.state === "running" ? { status: watched.has(record.id) ? record.state : _agimon_ai_po_core_backgroundWork.BACKGROUND_SERVICE_STATUS } : {}
363
904
  }));
905
+ nextBackgroundWork.push(...sequences?.activeWork() ?? []);
364
906
  if (JSON.stringify(nextBackgroundWork) !== JSON.stringify(backgroundWorkItems)) {
365
907
  backgroundWorkItems = nextBackgroundWork;
366
908
  backgroundWorkProvider?.update();
367
909
  }
368
- directEvents.publish(RUNNER_RUNS_TYPE, ownedSessionId, { runs: presentRunnerRuns(records, Date.now()) });
910
+ const runs = {
911
+ runs: presentRunnerRuns(records, Date.now()),
912
+ ...execution ? { sessionDirectory: execution.cwd } : {},
913
+ ...startFailure ? { startFailure } : {}
914
+ };
915
+ const serialized = JSON.stringify(runs);
916
+ if (serialized !== sentRuns) {
917
+ sentRuns = serialized;
918
+ directEvents.publish(RUNNER_RUNS_TYPE, ownedSessionId, runs);
919
+ }
369
920
  } catch (error) {
370
921
  process.emitWarning(`Could not publish runner state: ${String(error)}`);
371
922
  }
@@ -400,12 +951,7 @@ function createRunnerServerRuntime(container, host, directEvents, wakeAgent, exe
400
951
  const record = await container.runnerRegistry.get(id, ownedSessionId);
401
952
  if (closing) return;
402
953
  if (record?.state === "running") continue;
403
- if (record) await wakeAgent?.(require_runnerRegistry.formatRunnerFinished(record), `runner-finished:${JSON.stringify([ownedSessionId, id])}`, require_runnerRegistry.formatRunnerFinishedNotice(record));
404
- if (record) await telemetry?.recordEvent("po_runner.process_finished", {
405
- outcome: "completed",
406
- "runner.exit_code": record.exit?.code ?? 0,
407
- "runner.backend": record.backend
408
- });
954
+ if (record) await wakeAgent?.(require_runnerRegistry$1.formatRunnerFinished(record), `runner-finished:${JSON.stringify([ownedSessionId, id])}`, require_runnerRegistry$1.formatRunnerFinishedNotice(record));
409
955
  watched.delete(id);
410
956
  requestPublish(ownedSessionId);
411
957
  } catch (error) {
@@ -450,20 +996,38 @@ function createRunnerServerRuntime(container, host, directEvents, wakeAgent, exe
450
996
  },
451
997
  ensureSession,
452
998
  watchRunner,
999
+ setSequences(service) {
1000
+ sequences = service;
1001
+ },
1002
+ sequenceChanged() {
1003
+ if (sessionId !== void 0) requestPublish(sessionId);
1004
+ },
1005
+ reportStart(startedSessionId, failure) {
1006
+ startFailures += 1;
1007
+ startFailure = failure === void 0 ? void 0 : {
1008
+ id: `${String(Date.now())}-${String(startFailures)}`,
1009
+ message: failure
1010
+ };
1011
+ requestPublish(startedSessionId);
1012
+ },
453
1013
  async recoverCompaction(event) {
454
1014
  if (event.status !== "completed" || closing || !execution || typeof event.entryId !== "string" || event.entryId === recoveredCompactionId) return;
455
- const compacted = (await execution.session.entries()).findLast((entry) => entry.type === "compaction");
1015
+ const compacted = (await execution.session.entries({
1016
+ type: "compaction",
1017
+ limit: 1
1018
+ })).findLast((entry) => entry.type === "compaction");
456
1019
  if (closing || compacted?.id !== event.entryId) return;
457
1020
  await ensureSession(execution.sessionId);
458
1021
  let records;
459
1022
  try {
460
1023
  records = await container.runnerRegistry.listBySession(execution.sessionId);
461
- } catch {
1024
+ } catch (error) {
1025
+ process.emitWarning(`Could not read runner compaction recovery: ${String(error)}`);
462
1026
  return;
463
1027
  }
464
1028
  if (closing) return;
465
1029
  const active = records.filter((record) => record.state === "running");
466
- const text = require_compaction.activeRunnerRecovery(active);
1030
+ const text = [require_compaction.activeRunnerRecovery(active), await sequences?.recoveryText()].filter(Boolean).join("\n");
467
1031
  if (!text) return;
468
1032
  await execution.session.appendMessage?.({
469
1033
  type: "po-runner-compaction",
@@ -555,11 +1119,18 @@ const CEILINGS = {
555
1119
  errorMaxVariantsJoined: 100
556
1120
  };
557
1121
  var RunnerSettingsLoader = class {
558
- load(cwd, trusted) {
1122
+ files;
1123
+ constructor(files) {
1124
+ this.files = files;
1125
+ }
1126
+ async load(cwd, trusted) {
559
1127
  if (!trusted) return EMPTY;
560
1128
  let raw;
561
1129
  try {
562
- raw = node_fs.default.readFileSync(node_path.default.join(cwd, _earendil_works_pi_coding_agent.CONFIG_DIR_NAME, RUNNER_SETTINGS_FILE), "utf8");
1130
+ const target = node_path.default.join(cwd, _earendil_works_pi_coding_agent.CONFIG_DIR_NAME, RUNNER_SETTINGS_FILE);
1131
+ const text = this.files ? await (0, _agimon_ai_po_core_platform.readTextIfExists)(this.files, target, _agimon_ai_po_core_platform.BACKGROUND_CONTEXT) : await node_fs_promises.default.readFile(target, "utf8");
1132
+ if (text === void 0) return EMPTY;
1133
+ raw = text;
563
1134
  } catch (error) {
564
1135
  if (error.code === "ENOENT") return EMPTY;
565
1136
  return {
@@ -634,31 +1205,44 @@ function validate(parsed) {
634
1205
  //#endregion
635
1206
  //#region src/extensions/workspaces/sessions/(backend)/_lib/serverRoot.ts
636
1207
  const RUNNER_SERVER_SCOPE_SERVICE = "po/runner-server-scope";
637
- const createRunnerServerRoot = async ({ host, agent, signal, resources }) => {
1208
+ const createRunnerServerRoot = async ({ context, host, agent, signal, resources }) => {
638
1209
  if (!host.context.directEvents) throw new Error("Runner server plugin requires the session direct event bus.");
639
1210
  if (!host.context.cwd || !host.context.environment) throw new Error("Runner server plugin requires session cwd and environment.");
640
- const loaded = new RunnerSettingsLoader().load(host.context.cwd, true);
1211
+ const fs = (0, _agimon_ai_po_core_platform.readPoFs)(context);
1212
+ const loaded = await new RunnerSettingsLoader(fs).load(host.context.cwd, true);
641
1213
  const settings = Object.freeze({
642
1214
  ...loaded.settings,
643
1215
  ...loaded.settings.errorPatterns ? { errorPatterns: Object.freeze([...loaded.settings.errorPatterns]) } : {}
644
1216
  });
645
1217
  for (const issue of loaded.issues) process.emitWarning(`${RUNNER_SETTINGS_FILE}: ${issue}`);
646
1218
  const environment = host.context.environment;
647
- const runnerHost = await resources.acquire(["runner-host", environment["PROCESS_REGISTRY_PATH"] ?? null], () => createRunnerHost({
648
- processRegistry: require_runnerRegistry.createDefaultProcessRegistry(environment),
1219
+ if (!environment[_agimon_ai_po_core_platform.PO_SESSION_TEMP_DIR]) throw new Error("Runner requires the host-admitted session temporary directory.");
1220
+ const runnerHost = await resources.acquire(["runner-host", environment["PROCESS_REGISTRY_PATH"] ?? null], () => require_runnerHost.createRunnerHost({
1221
+ processRegistry: require_runnerRegistry$1.createDefaultProcessRegistry(environment),
649
1222
  clock: new require_clock.SystemClock(),
650
1223
  statusPollMs: 500,
651
1224
  historySweepMs: HISTORY_SWEEP_INTERVAL_MS,
652
1225
  onWarning: (message) => process.emitWarning(message)
653
1226
  }), (shared) => shared.dispose());
1227
+ const lifelineObserver = await resources.acquire(["runner-lifeline-observer", environment["PROCESS_REGISTRY_PATH"] ?? null], () => new require_lifeline.LifelineObserver(environment), (shared) => shared.close());
1228
+ const execution = agent?.context;
1229
+ const telemetry = execution ? (0, _agimon_ai_po_core_telemetry.createPoTelemetry)({
1230
+ serviceName: "po-runner",
1231
+ packageName: "@agimon-ai/po-runner",
1232
+ cwd: execution.cwd,
1233
+ env: execution.environment,
1234
+ enableLogs: true,
1235
+ enableTraces: true
1236
+ }) : void 0;
654
1237
  const dependencies = require_runnerDependencies.createRunnerDependencies({
655
1238
  settings,
656
1239
  cwd: host.context.cwd,
657
1240
  environment,
658
1241
  processRegistry: runnerHost.processRegistry,
1242
+ lifelineObserver,
1243
+ ...telemetry === void 0 ? {} : { telemetry },
659
1244
  ...host.context.executionBudget === void 0 ? {} : { executionBudget: host.context.executionBudget }
660
1245
  });
661
- const execution = agent?.context;
662
1246
  const wakeAgent = execution && (async (content, requestId, notice) => {
663
1247
  try {
664
1248
  if (!execution.session.admitMessage) throw new Error("The session cannot admit a runner notification.");
@@ -676,32 +1260,98 @@ const createRunnerServerRoot = async ({ host, agent, signal, resources }) => {
676
1260
  throw error;
677
1261
  }
678
1262
  });
679
- const runtime = createRunnerServerRuntime(dependencies, runnerHost, host.context.directEvents, wakeAgent, execution);
680
- const bash = (wakeOnExit) => require_headless.createHeadlessBashTool({ run: async (request) => {
681
- await runtime.ensureSession(request.sessionId);
682
- const result = await dependencies.bashRunService.run({
683
- ...request,
684
- ...signal ? { signal: request.signal ? AbortSignal.any([signal, request.signal]) : signal } : {}
685
- });
686
- if (wakeOnExit && result.kind === "promoted") runtime.watchRunner(result.id);
687
- return result;
688
- } }, (path, lines, bytes, tokens) => require_logReader.summarizeLog(path, lines, bytes, tokens, settings), settings, dependencies.environment);
1263
+ const runtime = createRunnerServerRuntime(dependencies, runnerHost, host.context.directEvents, wakeAgent, execution, telemetry);
1264
+ const sequences = fs && execution ? createRunnerSequenceService({
1265
+ dependencies,
1266
+ store: require_runnerSequenceStore.createRunnerSequenceStore(fs, dependencies.paths, execution.sessionId),
1267
+ sessionId: execution.sessionId,
1268
+ signal,
1269
+ summarizeLog: (path, lines, bytes, tokens) => require_logReader.summarizeLog(path, lines, bytes, tokens, settings),
1270
+ onChange: () => runtime.sequenceChanged(),
1271
+ onWarning: (message) => process.emitWarning(message),
1272
+ onComplete: async (record) => {
1273
+ if (!record.result) return;
1274
+ await wakeAgent?.(record.result.content.flatMap((part) => part.type === "text" ? [part.text] : []).join("\n"), `runner-sequence-finished:${JSON.stringify([record.sessionId, record.id])}`, `Command sequence ${record.name} finished: ${record.outcome ?? record.state}`);
1275
+ }
1276
+ }) : void 0;
1277
+ if (sequences) runtime.setSequences(sequences);
1278
+ const bash = (wakeOnExit) => require_headless.createHeadlessBashTool(sequences ? async (params, context, toolCallId, callSignal, onUpdate) => {
1279
+ await runtime.ensureSession(context.sessionId);
1280
+ return sequences.run(params, context, toolCallId, callSignal, onUpdate, wakeOnExit);
1281
+ } : void 0, dependencies.environment);
689
1282
  const value = {
1283
+ sequences,
690
1284
  tool: bash(true),
691
1285
  remoteTool: bash(false),
692
- command: require_headless.createHeadlessRunnersCommand(dependencies),
1286
+ command: require_headless.createHeadlessRunnersCommand(dependencies, {
1287
+ translate: (key, fallback, vars) => (0, _agimon_ai_po_core_locale.readPoLang)(context)?.t((0, _agimon_ai_po_core_locale.readPoPersonLocale)(context)?.read(), key, fallback, vars) ?? (0, _agimon_ai_po_core_locale.formatMessage)(fallback, vars),
1288
+ fs,
1289
+ sequences,
1290
+ onStart: (startedSessionId, failure) => runtime.reportStart(startedSessionId, failure)
1291
+ }),
693
1292
  recoverCompaction: runtime.recoverCompaction
694
1293
  };
1294
+ let controlsDisposed = false;
1295
+ let launch;
1296
+ let unregisterOwner;
1297
+ if (fs && execution) {
1298
+ const operations = createRunnerOperations({
1299
+ ...dependencies,
1300
+ registry: dependencies.runnerRegistry,
1301
+ fs,
1302
+ sessionId: execution.sessionId
1303
+ });
1304
+ const assertAvailable = () => {
1305
+ signal?.throwIfAborted();
1306
+ if (controlsDisposed) throw new Error("Runner session is disposed.");
1307
+ };
1308
+ launch = require_runnerLaunch.createRunnerLaunch({
1309
+ sessionId: execution.sessionId,
1310
+ ownerSessionId: (0, _agimon_ai_po_core_workflow.readPoWorkflowContextService)(context)?.run.ownerSessionId ?? execution.sessionId,
1311
+ getOwner: (ownerSessionId) => runnerHost.getOwner(ownerSessionId),
1312
+ runService: dependencies.bashRunService,
1313
+ registry: dependencies.runnerRegistry,
1314
+ operations,
1315
+ ensureSession: (sessionId) => runtime.ensureSession(sessionId),
1316
+ watchRunner: (id) => runtime.watchRunner(id),
1317
+ assertAvailable
1318
+ });
1319
+ unregisterOwner = runnerHost.registerOwner(execution.sessionId, launch);
1320
+ const namespace = createRunnerNamespace({
1321
+ sessionId: execution.sessionId,
1322
+ operations,
1323
+ sequences,
1324
+ assertAvailable
1325
+ });
1326
+ context.inject([_agimon_ai_po_core_codemode.PO_CODEMODE_SERVICE], (scoped) => {
1327
+ const registration = (0, _agimon_ai_po_core_codemode.readPoCodemode)(scoped)?.register("@agimon-ai/po-runner", namespace);
1328
+ return () => registration?.dispose();
1329
+ });
1330
+ }
695
1331
  return {
696
1332
  value,
697
1333
  services: [runtime.backgroundWorkPlugin, (context) => {
698
- context.plugin((providerContext) => providerContext.provide(RUNNER_SERVER_SCOPE_SERVICE, value));
1334
+ context.plugin((providerContext) => {
1335
+ providerContext.provide(RUNNER_SERVER_SCOPE_SERVICE, value);
1336
+ if (launch) providerContext.provide(require_runnerLaunch.PO_RUNNER_LAUNCH_SERVICE, launch);
1337
+ });
699
1338
  }],
700
1339
  activities: [runtime.activity],
701
1340
  onStart: execution ? () => {
702
1341
  runtime.ensureSession(execution.sessionId).catch((error) => process.emitWarning(`Could not initialize headless runner supervision: ${String(error)}`));
703
1342
  } : void 0,
704
- onStop: runtime.dispose
1343
+ onStop: async () => {
1344
+ controlsDisposed = true;
1345
+ unregisterOwner?.();
1346
+ const failures = [];
1347
+ for (const release of [() => launch?.dispose(), () => runtime.dispose()]) try {
1348
+ await release();
1349
+ } catch (error) {
1350
+ failures.push(error);
1351
+ }
1352
+ if (failures.length === 1) throw failures[0];
1353
+ if (failures.length > 1) throw new AggregateError(failures, "Runner session cleanup failed.");
1354
+ }
705
1355
  };
706
1356
  };
707
1357
  //#endregion
@@ -758,19 +1408,6 @@ var runnerRuns_server_default = (0, _agimon_ai_po_core_extensionFile.defineChann
758
1408
  return createRunnersChannel();
759
1409
  });
760
1410
  //#endregion
761
- //#region src/constants/runnerLogApi.ts
762
- const LOG_DIR_NAME = "logs";
763
- const STATE_EXTENSION = ".json";
764
- const RUNNING_STATE = "running";
765
- const STATE_POLL_MS = 1e3;
766
- const HEARTBEAT_MS = 15e3;
767
- const MAX_LINES = 5e3;
768
- const SAFE_SEGMENT = /^[\w.@-]+$/;
769
- const RAW_LOG_SUFFIX = ".raw";
770
- /** Ceiling for one finite log/screen read, before base64 encoding. */
771
- const MAX_OUTPUT_BYTES = 65536;
772
- const NOT_ATTACHABLE = "No attachable runner by that name in this session.";
773
- //#endregion
774
1411
  //#region src/constants/webRunnerLog.ts
775
1412
  const RUNNER_API_BASE_PATH = "runner";
776
1413
  const RUN_ID_PARAM = "runId";
@@ -798,7 +1435,7 @@ var LogTail = class {
798
1435
  let offset = options.from;
799
1436
  let pending = "";
800
1437
  let closed = false;
801
- const drain = (size) => {
1438
+ const drain = async (size) => {
802
1439
  if (size < offset) {
803
1440
  offset = 0;
804
1441
  pending = "";
@@ -806,27 +1443,32 @@ var LogTail = class {
806
1443
  if (size === offset) return;
807
1444
  const length = size - offset;
808
1445
  const buffer = Buffer.alloc(length);
809
- const descriptor = node_fs.default.openSync(logPath, "r");
1446
+ const descriptor = await node_fs_promises.default.open(logPath, "r");
810
1447
  let bytesRead;
811
1448
  try {
812
- bytesRead = node_fs.default.readSync(descriptor, buffer, 0, length, offset);
1449
+ ({bytesRead} = await descriptor.read(buffer, 0, length, offset));
813
1450
  } finally {
814
- node_fs.default.closeSync(descriptor);
1451
+ await descriptor.close();
815
1452
  }
816
- offset = size;
1453
+ if (closed) return;
1454
+ offset += bytesRead;
817
1455
  if (bytesRead <= 0) return;
818
1456
  pending += buffer.subarray(0, bytesRead).toString("utf8");
819
1457
  const lines = pending.split("\n");
820
1458
  pending = lines.pop() ?? "";
821
1459
  if (lines.length > 0) options.onLines(lines, offset - Buffer.byteLength(pending, "utf8"));
822
1460
  };
823
- const tick = () => {
824
- if (closed) return;
1461
+ let reading = false;
1462
+ const tick = async () => {
1463
+ if (closed || reading) return;
1464
+ reading = true;
825
1465
  try {
826
- drain(node_fs.default.statSync(logPath).size);
1466
+ await drain((await node_fs_promises.default.stat(logPath)).size);
827
1467
  } catch (error) {
828
1468
  if (error.code === "ENOENT") return;
829
- options.onError(error instanceof Error ? error : new Error(String(error)));
1469
+ if (!closed) options.onError(error instanceof Error ? error : new Error(String(error)));
1470
+ } finally {
1471
+ reading = false;
830
1472
  }
831
1473
  };
832
1474
  const timer = setInterval(tick, 250);
@@ -941,13 +1583,13 @@ function isSafeSegment(value) {
941
1583
  return value !== "" && value !== "." && value !== ".." && SAFE_SEGMENT.test(value);
942
1584
  }
943
1585
  /** A log must stay inside its session even when a path component is a symlink. Missing files are normal. */
944
- function isSessionLog(file, logsDir) {
1586
+ async function isSessionLog(file, logsDir) {
945
1587
  const resolved = node_path.default.resolve(file);
946
1588
  if (resolved !== logsDir && !resolved.startsWith(`${logsDir}${node_path.default.sep}`)) return false;
947
1589
  try {
948
- if (node_fs.default.lstatSync(file).isSymbolicLink()) return false;
949
- const realFile = node_fs.default.realpathSync(file);
950
- const realLogs = node_fs.default.realpathSync(logsDir);
1590
+ if ((await node_fs_promises.default.lstat(file)).isSymbolicLink()) return false;
1591
+ const realFile = await node_fs_promises.default.realpath(file);
1592
+ const realLogs = await node_fs_promises.default.realpath(logsDir);
951
1593
  return realFile.startsWith(`${realLogs}${node_path.default.sep}`);
952
1594
  } catch (error) {
953
1595
  return isRecord(error) && error.code === "ENOENT";
@@ -962,17 +1604,17 @@ function isSessionLog(file, logsDir) {
962
1604
  * session's own logs directory. Without that check a doctored record would
963
1605
  * turn this route into an arbitrary file read.
964
1606
  */
965
- function resolveLogFile(stateDir, logsDir, sessionId, runId) {
1607
+ async function resolveLogFile(stateDir, logsDir, sessionId, runId) {
966
1608
  const statePath = node_path.default.join(stateDir, `${runId}${STATE_EXTENSION}`);
967
1609
  let raw;
968
1610
  try {
969
- raw = node_fs.default.readFileSync(statePath, "utf8");
1611
+ raw = await node_fs_promises.default.readFile(statePath, "utf8");
970
1612
  } catch {
971
1613
  return;
972
1614
  }
973
1615
  const record = parseRunnerRecord(raw);
974
1616
  if (record === void 0 || record.id !== runId || record.sessionId !== sessionId) return void 0;
975
- if (!isSessionLog(record.logPath, logsDir)) return void 0;
1617
+ if (!await isSessionLog(record.logPath, logsDir)) return void 0;
976
1618
  return record;
977
1619
  }
978
1620
  function isRecord(value) {
@@ -984,10 +1626,10 @@ function numberParam(value, fallback, max) {
984
1626
  return Math.min(parsed, max);
985
1627
  }
986
1628
  /** Missing output is normal before the sink opens it; other IO failures must not look like an empty read. */
987
- function readOutput(file, from, running, priorGeneration, screen = false) {
1629
+ async function readOutput(file, from, running, priorGeneration, screen = false) {
988
1630
  let descriptor;
989
1631
  try {
990
- descriptor = node_fs.default.openSync(file, node_fs.default.constants.O_RDONLY | node_fs.default.constants.O_NOFOLLOW);
1632
+ descriptor = await node_fs_promises.default.open(file, node_fs_promises.default.constants.O_RDONLY | node_fs_promises.default.constants.O_NOFOLLOW);
991
1633
  } catch (error) {
992
1634
  if (!isRecord(error) || error.code !== "ENOENT") throw error;
993
1635
  return {
@@ -1000,14 +1642,14 @@ function readOutput(file, from, running, priorGeneration, screen = false) {
1000
1642
  };
1001
1643
  }
1002
1644
  try {
1003
- const stat = node_fs.default.fstatSync(descriptor, { bigint: true });
1645
+ const stat = await descriptor.stat({ bigint: true });
1004
1646
  const size = Number(stat.size);
1005
1647
  const generation = screen ? `${stat.dev}:${stat.ino}:${stat.birthtimeNs}` : void 0;
1006
1648
  const reset = from > size || priorGeneration !== void 0 && generation !== priorGeneration;
1007
1649
  const start = reset ? 0 : from;
1008
1650
  const length = Math.min(size - start, MAX_OUTPUT_BYTES);
1009
1651
  const buffer = Buffer.alloc(length);
1010
- const read = length === 0 ? 0 : node_fs.default.readSync(descriptor, buffer, 0, length, start);
1652
+ const read = length === 0 ? 0 : (await descriptor.read(buffer, 0, length, start)).bytesRead;
1011
1653
  const offset = start + read;
1012
1654
  const hasMore = offset < size;
1013
1655
  return {
@@ -1020,7 +1662,7 @@ function readOutput(file, from, running, priorGeneration, screen = false) {
1020
1662
  ended: !running && !hasMore
1021
1663
  };
1022
1664
  } finally {
1023
- node_fs.default.closeSync(descriptor);
1665
+ await descriptor.close();
1024
1666
  }
1025
1667
  }
1026
1668
  function logQueryOf(url) {
@@ -1063,7 +1705,7 @@ function createRunnerLogApi(options) {
1063
1705
  return paneBackend;
1064
1706
  };
1065
1707
  /** The record behind a request, or undefined when this session has no such run. */
1066
- const runnerOf = (runId) => isSafeSegment(runId) ? resolveLogFile(stateDir, logsDir, sessionId, runId) : void 0;
1708
+ const runnerOf = async (runId) => isSafeSegment(runId) ? resolveLogFile(stateDir, logsDir, sessionId, runId) : void 0;
1067
1709
  /**
1068
1710
  * The owned pane whose recorded output a request may read.
1069
1711
  *
@@ -1073,8 +1715,8 @@ function createRunnerLogApi(options) {
1073
1715
  * interactive. A non-interactive run has no terminal to type into, and a
1074
1716
  * subprocess-backed run has no pane at all.
1075
1717
  */
1076
- const paneOf = (runId) => {
1077
- const record = runnerOf(runId);
1718
+ const paneOf = async (runId) => {
1719
+ const record = await runnerOf(runId);
1078
1720
  if (record === void 0 || record.interactive !== true) return void 0;
1079
1721
  const target = record.backendTarget;
1080
1722
  if (target === void 0 || !MULTIPLEXER_BACKENDS.has(record.backend) || !isSafeSegment(target)) return void 0;
@@ -1083,35 +1725,35 @@ function createRunnerLogApi(options) {
1083
1725
  target
1084
1726
  };
1085
1727
  };
1086
- const attachableOf = (runId) => {
1087
- const owned = paneOf(runId);
1728
+ const attachableOf = async (runId) => {
1729
+ const owned = await paneOf(runId);
1088
1730
  return owned?.record.state === "running" ? owned : void 0;
1089
1731
  };
1090
- for (const [route, screen] of [[routes.logRead, false], [routes.screenRead, true]]) app.get(route.path, (context) => {
1732
+ for (const [route, screen] of [[routes.logRead, false], [routes.screenRead, true]]) app.get(route.path, async (context) => {
1091
1733
  const runId = context.req.param(RUN_ID_PARAM);
1092
- const record = screen ? paneOf(runId)?.record : runnerOf(runId);
1734
+ const record = screen ? (await paneOf(runId))?.record : await runnerOf(runId);
1093
1735
  if (record === void 0) return context.json({ error: screen ? NOT_ATTACHABLE : `No runner '${runId}' in this session.` }, 404);
1094
1736
  const value = context.req.query(RUNNER_LOG_PARAMS.from);
1095
1737
  const from = value === void 0 ? 0 : Number(value);
1096
1738
  if (value !== void 0 && !/^\d+$/.test(value) || !Number.isSafeInteger(from) || from < 0) return context.json({ error: "Expected a non-negative safe integer byte offset." }, 400);
1097
1739
  const file = screen ? `${record.logPath}${RAW_LOG_SUFFIX}` : record.logPath;
1098
- if (!isSessionLog(file, logsDir)) return context.json({ error: "No readable output in this session." }, 404);
1099
- return context.json(readOutput(file, from, record.state === RUNNING_STATE, screen ? context.req.query(RUNNER_LOG_PARAMS.generation) : void 0, screen));
1740
+ if (!await isSessionLog(file, logsDir)) return context.json({ error: "No readable output in this session." }, 404);
1741
+ return context.json(await readOutput(file, from, record.state === RUNNING_STATE, screen ? context.req.query(RUNNER_LOG_PARAMS.generation) : void 0, screen));
1100
1742
  });
1101
- app.get(routes.log.path, (context) => {
1743
+ app.get(routes.log.path, async (context) => {
1102
1744
  const runId = context.req.param(RUN_ID_PARAM);
1103
- const record = runnerOf(runId);
1745
+ const record = await runnerOf(runId);
1104
1746
  if (record === void 0) return context.json({ error: `No runner '${runId}' in this session.` }, 404);
1105
1747
  const body = {
1106
- ...logReader.read(record.logPath, logQueryOf(new URL(context.req.url))),
1748
+ ...await logReader.read(record.logPath, logQueryOf(new URL(context.req.url))),
1107
1749
  runId,
1108
1750
  running: record.state === RUNNING_STATE
1109
1751
  };
1110
1752
  return context.json(body);
1111
1753
  });
1112
- app.get(routes.logStream.path, (context) => {
1754
+ app.get(routes.logStream.path, async (context) => {
1113
1755
  const runId = context.req.param(RUN_ID_PARAM);
1114
- const record = runnerOf(runId);
1756
+ const record = await runnerOf(runId);
1115
1757
  if (record === void 0) return context.json({ error: `No runner '${runId}' in this session.` }, 404);
1116
1758
  const from = numberParam(new URL(context.req.url).searchParams.get(RUNNER_LOG_PARAMS.from) ?? void 0, 0, Number.MAX_SAFE_INTEGER);
1117
1759
  return (0, hono_streaming.streamSSE)(context, async (stream) => {
@@ -1135,8 +1777,8 @@ function createRunnerLogApi(options) {
1135
1777
  }),
1136
1778
  onError: () => finish()
1137
1779
  });
1138
- const poll = setInterval(() => {
1139
- const current = runnerOf(runId);
1780
+ const poll = setInterval(async () => {
1781
+ const current = await runnerOf(runId);
1140
1782
  if (current !== void 0 && current.state === "running") return;
1141
1783
  queue({
1142
1784
  lines: [],
@@ -1158,9 +1800,9 @@ function createRunnerLogApi(options) {
1158
1800
  await pump;
1159
1801
  });
1160
1802
  });
1161
- app.get(routes.screenStream.path, (context) => {
1803
+ app.get(routes.screenStream.path, async (context) => {
1162
1804
  const runId = context.req.param(RUN_ID_PARAM);
1163
- const attachable = attachableOf(runId);
1805
+ const attachable = await attachableOf(runId);
1164
1806
  if (attachable === void 0) return context.json({ error: NOT_ATTACHABLE }, 404);
1165
1807
  const rawPath = `${attachable.record.logPath}${RAW_LOG_SUFFIX}`;
1166
1808
  const from = numberParam(new URL(context.req.url).searchParams.get(RUNNER_LOG_PARAMS.from) ?? void 0, 0, Number.MAX_SAFE_INTEGER);
@@ -1177,10 +1819,10 @@ function createRunnerLogApi(options) {
1177
1819
  finish = resolve;
1178
1820
  });
1179
1821
  let offset = from;
1180
- const drain = () => {
1822
+ const drain = async () => {
1181
1823
  let size;
1182
1824
  try {
1183
- size = node_fs.default.statSync(rawPath).size;
1825
+ size = (await node_fs_promises.default.stat(rawPath)).size;
1184
1826
  } catch {
1185
1827
  return;
1186
1828
  }
@@ -1188,12 +1830,12 @@ function createRunnerLogApi(options) {
1188
1830
  if (size === offset) return;
1189
1831
  const length = size - offset;
1190
1832
  const buffer = Buffer.alloc(length);
1191
- const descriptor = node_fs.default.openSync(rawPath, "r");
1833
+ const descriptor = await node_fs_promises.default.open(rawPath, "r");
1192
1834
  let read;
1193
1835
  try {
1194
- read = node_fs.default.readSync(descriptor, buffer, 0, length, offset);
1836
+ ({bytesRead: read} = await descriptor.read(buffer, 0, length, offset));
1195
1837
  } finally {
1196
- node_fs.default.closeSync(descriptor);
1838
+ await descriptor.close();
1197
1839
  }
1198
1840
  if (read <= 0) return;
1199
1841
  offset += read;
@@ -1202,20 +1844,32 @@ function createRunnerLogApi(options) {
1202
1844
  offset
1203
1845
  });
1204
1846
  };
1205
- const poll = setInterval(() => {
1206
- const current = runnerOf(runId);
1207
- drain();
1208
- if (current === void 0 || current.state !== "running") {
1209
- queue({
1210
- chunk: "",
1211
- offset,
1212
- ended: true
1213
- });
1847
+ let polling = false;
1848
+ let stopped = false;
1849
+ const poll = setInterval(async () => {
1850
+ if (polling || stopped) return;
1851
+ polling = true;
1852
+ try {
1853
+ const current = await runnerOf(runId);
1854
+ await drain();
1855
+ if (stopped) return;
1856
+ if (current === void 0 || current.state !== "running") {
1857
+ queue({
1858
+ chunk: "",
1859
+ offset,
1860
+ ended: true
1861
+ });
1862
+ finish();
1863
+ }
1864
+ } catch {
1214
1865
  finish();
1866
+ } finally {
1867
+ polling = false;
1215
1868
  }
1216
1869
  }, 100);
1217
1870
  stream.onAbort(() => finish());
1218
1871
  await done;
1872
+ stopped = true;
1219
1873
  clearInterval(poll);
1220
1874
  await pump;
1221
1875
  });
@@ -1229,7 +1883,7 @@ function createRunnerLogApi(options) {
1229
1883
  */
1230
1884
  app.post(routes.input.path, async (context) => {
1231
1885
  const runId = context.req.param(RUN_ID_PARAM);
1232
- const attachable = attachableOf(runId);
1886
+ const attachable = await attachableOf(runId);
1233
1887
  if (attachable === void 0) return context.json({ error: NOT_ATTACHABLE }, 404);
1234
1888
  let body;
1235
1889
  try {
@@ -1260,6 +1914,10 @@ const api = {
1260
1914
  };
1261
1915
  }
1262
1916
  };
1917
+ /** The edge build reads its run records from the session root (`index.edge.ts`). Node has its own registry. */
1918
+ function createRunnerApi(_root) {
1919
+ return api;
1920
+ }
1263
1921
  //#endregion
1264
1922
  //#region src/extensions/workspaces/sessions/(backend)/api/runner/route.server.ts
1265
1923
  /**
@@ -1270,25 +1928,38 @@ const api = {
1270
1928
  * rather than in a constant and in four URL builders that were each free to
1271
1929
  * drift.
1272
1930
  */
1273
- var route_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoute)(api);
1931
+ var route_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoute)(({ root }) => createRunnerApi(root));
1274
1932
  //#endregion
1275
1933
  //#region src/extensions/workspaces/sessions/(backend)/command/runners.server.ts
1276
1934
  var runners_server_default = (0, _agimon_ai_po_core_extensionFile.defineServerCommand)((context) => context.root.command);
1277
1935
  //#endregion
1278
1936
  //#region src/extensions/workspaces/sessions/(backend)/hook/session-compact.server.ts
1279
1937
  var session_compact_server_default = (0, _agimon_ai_po_core_extensionFile.defineHook)(({ root }) => ({
1938
+ name: "restore-runner-compaction-context",
1939
+ description: "For a new completed compaction in a live runner session, append recovery context for running processes and sequences when available.",
1280
1940
  event: "session_compact",
1281
1941
  handle: root.recoverCompaction
1282
1942
  }));
1283
1943
  //#endregion
1284
- //#region src/extensions/workspaces/sessions/(backend)/resource/po-use-runner.server.ts
1285
- var po_use_runner_server_default = (0, _agimon_ai_po_core_extensionFile.defineResource)({
1286
- name: "po-use-runner",
1944
+ //#region src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-runner.server.ts
1945
+ const skillFile = "src/prompts/codemode-how-to-runner/SKILL.md";
1946
+ var codemode_how_to_runner_server_default = (0, _agimon_ai_po_core_extensionFile.defineResource)({
1947
+ name: "codemode-how-to-runner",
1948
+ description: "Inspect supervised shell commands and sequential command groups, read saved logs, provide interactive input, and stop unused work through the runner namespace in code mode.",
1949
+ kind: "skill",
1950
+ pinned: true,
1951
+ path: (0, _agimon_ai_po_core_serverPlugin.packageResourcePath)(require("url").pathToFileURL(__filename).href, skillFile),
1952
+ read: () => (0, _agimon_ai_po_core_serverPlugin.readPackageResource)(require("url").pathToFileURL(__filename).href, skillFile)
1953
+ });
1954
+ //#endregion
1955
+ //#region src/extensions/workspaces/sessions/(backend)/resource/help-how-to-runner.server.ts
1956
+ var help_how_to_runner_server_default = (0, _agimon_ai_po_core_extensionFile.defineResource)({
1957
+ name: "help-how-to-runner",
1287
1958
  description: "Use Po Pi Runner to supervise shell commands, inspect durable logs, provide interactive input, and stop background runs.",
1288
1959
  when: _agimon_ai_po_core_help.PO_HELP_WHEN,
1289
1960
  kind: "skill",
1290
- path: (0, _agimon_ai_po_core_serverPlugin.packageResourcePath)(require("url").pathToFileURL(__filename).href, "src/prompts/po-use-runner/SKILL.md"),
1291
- read: () => (0, _agimon_ai_po_core_serverPlugin.readPackageResource)(require("url").pathToFileURL(__filename).href, "src/prompts/po-use-runner/SKILL.md")
1961
+ path: (0, _agimon_ai_po_core_serverPlugin.packageResourcePath)(require("url").pathToFileURL(__filename).href, "src/prompts/help-how-to-runner/SKILL.md"),
1962
+ read: () => (0, _agimon_ai_po_core_serverPlugin.readPackageResource)(require("url").pathToFileURL(__filename).href, "src/prompts/help-how-to-runner/SKILL.md")
1292
1963
  });
1293
1964
  //#endregion
1294
1965
  //#region src/extensions/workspaces/sessions/(backend)/tool/bash.server.ts
@@ -1298,19 +1969,27 @@ var bash_server_default = (0, _agimon_ai_po_core_extensionFile.defineServerTool)
1298
1969
  const at = (value, context) => typeof value === "function" ? value(context) : value;
1299
1970
  /* v8 ignore next -- generated normalization branch */
1300
1971
  const defined = (values) => values.filter((value) => value !== void 0);
1301
- const via = (identity, value) => value === void 0 ? void 0 : {
1302
- ...identity,
1303
- ...value
1972
+ const via = (identity, value) => {
1973
+ if (value === void 0) return void 0;
1974
+ const declaration = value;
1975
+ return {
1976
+ ...identity,
1977
+ ...declaration,
1978
+ ...declaration.relations === void 0 ? {} : { relations: declaration.relations.map((relation) => ({
1979
+ evidence: "declared",
1980
+ ...relation
1981
+ })) }
1982
+ };
1304
1983
  };
1305
1984
  const serverPlugin = (0, _agimon_ai_po_core_serverPlugin.defineServerPlugin)({
1306
1985
  name: "@agimon-ai/po-runner",
1307
1986
  providerOverrides: (0, _agimon_ai_po_core_serverPlugin.composeServerProviderOverrides)(root_server_default),
1308
1987
  injects: (0, _agimon_ai_po_core_extensionFile.composeRootInjects)({ session: [root_server_default] }),
1309
- global: () => ({ get channels() {
1310
- return [() => via({ frameType: "runner_runs" }, runnerRuns_server_default())];
1988
+ host: (context) => ({ get channels() {
1989
+ return [() => via({ frameType: "runner_runs" }, at(runnerRuns_server_default, context))];
1311
1990
  } }),
1312
1991
  workspace: (context) => ({ get channels() {
1313
- return defined([context.hosted("global") ? void 0 : () => via({ frameType: "runner_runs" }, runnerRuns_server_default())]);
1992
+ return defined([context.hosted("host") ? void 0 : () => via({ frameType: "runner_runs" }, at(runnerRuns_server_default, context))]);
1314
1993
  } }),
1315
1994
  session: async (context) => {
1316
1995
  const scopeSession = await context.scopeRoot("session", root_server_default, context);
@@ -1324,7 +2003,7 @@ const serverPlugin = (0, _agimon_ai_po_core_serverPlugin.defineServerPlugin)({
1324
2003
  return [at(route_server_default, contextSession)];
1325
2004
  },
1326
2005
  get channels() {
1327
- return defined([context.hosted("global") ? void 0 : () => via({ frameType: "runner_runs" }, runnerRuns_server_default())]);
2006
+ return defined([context.hosted("host") ? void 0 : () => via({ frameType: "runner_runs" }, at(runnerRuns_server_default, context))]);
1328
2007
  },
1329
2008
  get commands() {
1330
2009
  return [via({ name: "runners" }, at(runners_server_default, contextSession))];
@@ -1333,7 +2012,7 @@ const serverPlugin = (0, _agimon_ai_po_core_serverPlugin.defineServerPlugin)({
1333
2012
  return [via({ event: "session_compact" }, at(session_compact_server_default, contextSession))];
1334
2013
  },
1335
2014
  get resources() {
1336
- return [at(po_use_runner_server_default, contextSession)];
2015
+ return [at(codemode_how_to_runner_server_default, contextSession), at(help_how_to_runner_server_default, contextSession)];
1337
2016
  },
1338
2017
  get tools() {
1339
2018
  return [via({ name: "bash" }, at(bash_server_default, contextSession))];