chatroom-cli 1.31.1 → 1.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (841) hide show
  1. package/dist/api.d.ts +61 -0
  2. package/dist/api.d.ts.map +1 -0
  3. package/dist/api.js +10 -0
  4. package/dist/api.js.map +1 -0
  5. package/dist/commands/artifact/deps.d.ts +6 -0
  6. package/dist/commands/artifact/deps.d.ts.map +1 -0
  7. package/dist/commands/artifact/deps.js +2 -0
  8. package/dist/commands/artifact/deps.js.map +1 -0
  9. package/dist/commands/artifact/index.d.ts +43 -0
  10. package/dist/commands/artifact/index.d.ts.map +1 -0
  11. package/dist/commands/artifact/index.js +205 -0
  12. package/dist/commands/artifact/index.js.map +1 -0
  13. package/dist/commands/artifact/index.test.d.ts +8 -0
  14. package/dist/commands/artifact/index.test.d.ts.map +1 -0
  15. package/dist/commands/artifact/index.test.js +188 -0
  16. package/dist/commands/artifact/index.test.js.map +1 -0
  17. package/dist/commands/auth-login/deps.d.ts +50 -0
  18. package/dist/commands/auth-login/deps.d.ts.map +1 -0
  19. package/dist/commands/auth-login/deps.js +9 -0
  20. package/dist/commands/auth-login/deps.js.map +1 -0
  21. package/dist/commands/auth-login/index.d.ts +22 -0
  22. package/dist/commands/auth-login/index.d.ts.map +1 -0
  23. package/dist/commands/auth-login/index.js +246 -0
  24. package/dist/commands/auth-login/index.js.map +1 -0
  25. package/dist/commands/auth-login/index.test.d.ts +9 -0
  26. package/dist/commands/auth-login/index.test.d.ts.map +1 -0
  27. package/dist/commands/auth-login/index.test.js +297 -0
  28. package/dist/commands/auth-login/index.test.js.map +1 -0
  29. package/dist/commands/auth-logout/deps.d.ts +20 -0
  30. package/dist/commands/auth-logout/deps.d.ts.map +1 -0
  31. package/dist/commands/auth-logout/deps.js +7 -0
  32. package/dist/commands/auth-logout/deps.js.map +1 -0
  33. package/dist/commands/auth-logout/index.d.ts +8 -0
  34. package/dist/commands/auth-logout/index.d.ts.map +1 -0
  35. package/dist/commands/auth-logout/index.js +34 -0
  36. package/dist/commands/auth-logout/index.js.map +1 -0
  37. package/dist/commands/auth-logout/index.test.d.ts +8 -0
  38. package/dist/commands/auth-logout/index.test.d.ts.map +1 -0
  39. package/dist/commands/auth-logout/index.test.js +85 -0
  40. package/dist/commands/auth-logout/index.test.js.map +1 -0
  41. package/dist/commands/auth-status/deps.d.ts +35 -0
  42. package/dist/commands/auth-status/deps.d.ts.map +1 -0
  43. package/dist/commands/auth-status/deps.js +7 -0
  44. package/dist/commands/auth-status/deps.js.map +1 -0
  45. package/dist/commands/auth-status/index.d.ts +8 -0
  46. package/dist/commands/auth-status/index.d.ts.map +1 -0
  47. package/dist/commands/auth-status/index.js +80 -0
  48. package/dist/commands/auth-status/index.js.map +1 -0
  49. package/dist/commands/auth-status/index.test.d.ts +8 -0
  50. package/dist/commands/auth-status/index.test.d.ts.map +1 -0
  51. package/dist/commands/auth-status/index.test.js +116 -0
  52. package/dist/commands/auth-status/index.test.js.map +1 -0
  53. package/dist/commands/backlog/deps.d.ts +21 -0
  54. package/dist/commands/backlog/deps.d.ts.map +1 -0
  55. package/dist/commands/backlog/deps.js +5 -0
  56. package/dist/commands/backlog/deps.js.map +1 -0
  57. package/dist/commands/backlog/index.d.ts +129 -0
  58. package/dist/commands/backlog/index.d.ts.map +1 -0
  59. package/dist/commands/backlog/index.js +694 -0
  60. package/dist/commands/backlog/index.js.map +1 -0
  61. package/dist/commands/backlog/index.test.d.ts +7 -0
  62. package/dist/commands/backlog/index.test.d.ts.map +1 -0
  63. package/dist/commands/backlog/index.test.js +395 -0
  64. package/dist/commands/backlog/index.test.js.map +1 -0
  65. package/dist/commands/classify/deps.d.ts +18 -0
  66. package/dist/commands/classify/deps.d.ts.map +1 -0
  67. package/dist/commands/classify/deps.js +8 -0
  68. package/dist/commands/classify/deps.js.map +1 -0
  69. package/dist/commands/classify/index.d.ts +19 -0
  70. package/dist/commands/classify/index.d.ts.map +1 -0
  71. package/dist/commands/classify/index.js +162 -0
  72. package/dist/commands/classify/index.js.map +1 -0
  73. package/dist/commands/classify/index.test.d.ts +9 -0
  74. package/dist/commands/classify/index.test.d.ts.map +1 -0
  75. package/dist/commands/classify/index.test.js +263 -0
  76. package/dist/commands/classify/index.test.js.map +1 -0
  77. package/dist/commands/context/deps.d.ts +6 -0
  78. package/dist/commands/context/deps.d.ts.map +1 -0
  79. package/dist/commands/context/deps.js +2 -0
  80. package/dist/commands/context/deps.js.map +1 -0
  81. package/dist/commands/context/index.d.ts +42 -0
  82. package/dist/commands/context/index.d.ts.map +1 -0
  83. package/dist/commands/context/index.js +324 -0
  84. package/dist/commands/context/index.js.map +1 -0
  85. package/dist/commands/context/index.test.d.ts +9 -0
  86. package/dist/commands/context/index.test.d.ts.map +1 -0
  87. package/dist/commands/context/index.test.js +272 -0
  88. package/dist/commands/context/index.test.js.map +1 -0
  89. package/dist/commands/get-next-task/index.d.ts +20 -0
  90. package/dist/commands/get-next-task/index.d.ts.map +1 -0
  91. package/dist/commands/get-next-task/index.js +156 -0
  92. package/dist/commands/get-next-task/index.js.map +1 -0
  93. package/dist/commands/get-next-task/index.test.d.ts +9 -0
  94. package/dist/commands/get-next-task/index.test.d.ts.map +1 -0
  95. package/dist/commands/get-next-task/index.test.js +125 -0
  96. package/dist/commands/get-next-task/index.test.js.map +1 -0
  97. package/dist/commands/get-next-task/session.d.ts +127 -0
  98. package/dist/commands/get-next-task/session.d.ts.map +1 -0
  99. package/dist/commands/get-next-task/session.js +335 -0
  100. package/dist/commands/get-next-task/session.js.map +1 -0
  101. package/dist/commands/get-next-task/session.test.d.ts +11 -0
  102. package/dist/commands/get-next-task/session.test.d.ts.map +1 -0
  103. package/dist/commands/get-next-task/session.test.js +367 -0
  104. package/dist/commands/get-next-task/session.test.js.map +1 -0
  105. package/dist/commands/get-system-prompt/deps.d.ts +14 -0
  106. package/dist/commands/get-system-prompt/deps.d.ts.map +1 -0
  107. package/dist/commands/get-system-prompt/deps.js +7 -0
  108. package/dist/commands/get-system-prompt/deps.js.map +1 -0
  109. package/dist/commands/get-system-prompt/index.d.ts +16 -0
  110. package/dist/commands/get-system-prompt/index.d.ts.map +1 -0
  111. package/dist/commands/get-system-prompt/index.js +70 -0
  112. package/dist/commands/get-system-prompt/index.js.map +1 -0
  113. package/dist/commands/guidelines/deps.d.ts +14 -0
  114. package/dist/commands/guidelines/deps.d.ts.map +1 -0
  115. package/dist/commands/guidelines/deps.js +7 -0
  116. package/dist/commands/guidelines/deps.js.map +1 -0
  117. package/dist/commands/guidelines/index.d.ts +19 -0
  118. package/dist/commands/guidelines/index.d.ts.map +1 -0
  119. package/dist/commands/guidelines/index.js +92 -0
  120. package/dist/commands/guidelines/index.js.map +1 -0
  121. package/dist/commands/guidelines/index.test.d.ts +8 -0
  122. package/dist/commands/guidelines/index.test.d.ts.map +1 -0
  123. package/dist/commands/guidelines/index.test.js +140 -0
  124. package/dist/commands/guidelines/index.test.js.map +1 -0
  125. package/dist/commands/handoff/deps.d.ts +9 -0
  126. package/dist/commands/handoff/deps.d.ts.map +1 -0
  127. package/dist/commands/handoff/deps.js +5 -0
  128. package/dist/commands/handoff/deps.js.map +1 -0
  129. package/dist/commands/handoff/index.d.ts +23 -0
  130. package/dist/commands/handoff/index.d.ts.map +1 -0
  131. package/dist/commands/handoff/index.js +226 -0
  132. package/dist/commands/handoff/index.js.map +1 -0
  133. package/dist/commands/handoff/index.test.d.ts +9 -0
  134. package/dist/commands/handoff/index.test.d.ts.map +1 -0
  135. package/dist/commands/handoff/index.test.js +189 -0
  136. package/dist/commands/handoff/index.test.js.map +1 -0
  137. package/dist/commands/init/deps.d.ts +21 -0
  138. package/dist/commands/init/deps.d.ts.map +1 -0
  139. package/dist/commands/init/deps.js +8 -0
  140. package/dist/commands/init/deps.js.map +1 -0
  141. package/dist/commands/init/index.d.ts +22 -0
  142. package/dist/commands/init/index.d.ts.map +1 -0
  143. package/dist/commands/init/index.js +181 -0
  144. package/dist/commands/init/index.js.map +1 -0
  145. package/dist/commands/init/index.test.d.ts +8 -0
  146. package/dist/commands/init/index.test.d.ts.map +1 -0
  147. package/dist/commands/init/index.test.js +170 -0
  148. package/dist/commands/init/index.test.js.map +1 -0
  149. package/dist/commands/machine/daemon-start/command-loop.d.ts +15 -0
  150. package/dist/commands/machine/daemon-start/command-loop.d.ts.map +1 -0
  151. package/dist/commands/machine/daemon-start/command-loop.js +295 -0
  152. package/dist/commands/machine/daemon-start/command-loop.js.map +1 -0
  153. package/dist/commands/machine/daemon-start/command-loop.test.d.ts +13 -0
  154. package/dist/commands/machine/daemon-start/command-loop.test.d.ts.map +1 -0
  155. package/dist/commands/machine/daemon-start/command-loop.test.js +156 -0
  156. package/dist/commands/machine/daemon-start/command-loop.test.js.map +1 -0
  157. package/dist/commands/machine/daemon-start/command-sync-heartbeat.d.ts +12 -0
  158. package/dist/commands/machine/daemon-start/command-sync-heartbeat.d.ts.map +1 -0
  159. package/dist/commands/machine/daemon-start/command-sync-heartbeat.js +58 -0
  160. package/dist/commands/machine/daemon-start/command-sync-heartbeat.js.map +1 -0
  161. package/dist/commands/machine/daemon-start/deps.d.ts +85 -0
  162. package/dist/commands/machine/daemon-start/deps.d.ts.map +1 -0
  163. package/dist/commands/machine/daemon-start/deps.js +14 -0
  164. package/dist/commands/machine/daemon-start/deps.js.map +1 -0
  165. package/dist/commands/machine/daemon-start/event-bus.test.d.ts +2 -0
  166. package/dist/commands/machine/daemon-start/event-bus.test.d.ts.map +1 -0
  167. package/dist/commands/machine/daemon-start/event-bus.test.js +100 -0
  168. package/dist/commands/machine/daemon-start/event-bus.test.js.map +1 -0
  169. package/dist/commands/machine/daemon-start/event-listeners.test.d.ts +2 -0
  170. package/dist/commands/machine/daemon-start/event-listeners.test.d.ts.map +1 -0
  171. package/dist/commands/machine/daemon-start/event-listeners.test.js +155 -0
  172. package/dist/commands/machine/daemon-start/event-listeners.test.js.map +1 -0
  173. package/dist/commands/machine/daemon-start/file-content-fulfillment.d.ts +12 -0
  174. package/dist/commands/machine/daemon-start/file-content-fulfillment.d.ts.map +1 -0
  175. package/dist/commands/machine/daemon-start/file-content-fulfillment.js +120 -0
  176. package/dist/commands/machine/daemon-start/file-content-fulfillment.js.map +1 -0
  177. package/dist/commands/machine/daemon-start/file-content-subscription.d.ts +29 -0
  178. package/dist/commands/machine/daemon-start/file-content-subscription.d.ts.map +1 -0
  179. package/dist/commands/machine/daemon-start/file-content-subscription.js +55 -0
  180. package/dist/commands/machine/daemon-start/file-content-subscription.js.map +1 -0
  181. package/dist/commands/machine/daemon-start/file-tree-subscription.d.ts +22 -0
  182. package/dist/commands/machine/daemon-start/file-tree-subscription.d.ts.map +1 -0
  183. package/dist/commands/machine/daemon-start/file-tree-subscription.js +83 -0
  184. package/dist/commands/machine/daemon-start/file-tree-subscription.js.map +1 -0
  185. package/dist/commands/machine/daemon-start/git-heartbeat.d.ts +18 -0
  186. package/dist/commands/machine/daemon-start/git-heartbeat.d.ts.map +1 -0
  187. package/dist/commands/machine/daemon-start/git-heartbeat.js +218 -0
  188. package/dist/commands/machine/daemon-start/git-heartbeat.js.map +1 -0
  189. package/dist/commands/machine/daemon-start/git-subscription.d.ts +60 -0
  190. package/dist/commands/machine/daemon-start/git-subscription.d.ts.map +1 -0
  191. package/dist/commands/machine/daemon-start/git-subscription.js +389 -0
  192. package/dist/commands/machine/daemon-start/git-subscription.js.map +1 -0
  193. package/dist/commands/machine/daemon-start/git-subscription.test.d.ts +2 -0
  194. package/dist/commands/machine/daemon-start/git-subscription.test.d.ts.map +1 -0
  195. package/dist/commands/machine/daemon-start/git-subscription.test.js +103 -0
  196. package/dist/commands/machine/daemon-start/git-subscription.test.js.map +1 -0
  197. package/dist/commands/machine/daemon-start/handlers/command-runner.d.ts +23 -0
  198. package/dist/commands/machine/daemon-start/handlers/command-runner.d.ts.map +1 -0
  199. package/dist/commands/machine/daemon-start/handlers/command-runner.js +236 -0
  200. package/dist/commands/machine/daemon-start/handlers/command-runner.js.map +1 -0
  201. package/dist/commands/machine/daemon-start/handlers/ping.d.ts +6 -0
  202. package/dist/commands/machine/daemon-start/handlers/ping.d.ts.map +1 -0
  203. package/dist/commands/machine/daemon-start/handlers/ping.js +8 -0
  204. package/dist/commands/machine/daemon-start/handlers/ping.js.map +1 -0
  205. package/dist/commands/machine/daemon-start/handlers/ping.test.d.ts +5 -0
  206. package/dist/commands/machine/daemon-start/handlers/ping.test.d.ts.map +1 -0
  207. package/dist/commands/machine/daemon-start/handlers/ping.test.js +23 -0
  208. package/dist/commands/machine/daemon-start/handlers/ping.test.js.map +1 -0
  209. package/dist/commands/machine/daemon-start/handlers/shared.d.ts +11 -0
  210. package/dist/commands/machine/daemon-start/handlers/shared.d.ts.map +1 -0
  211. package/dist/commands/machine/daemon-start/handlers/shared.js +25 -0
  212. package/dist/commands/machine/daemon-start/handlers/shared.js.map +1 -0
  213. package/dist/commands/machine/daemon-start/handlers/state-recovery.d.ts +19 -0
  214. package/dist/commands/machine/daemon-start/handlers/state-recovery.d.ts.map +1 -0
  215. package/dist/commands/machine/daemon-start/handlers/state-recovery.js +61 -0
  216. package/dist/commands/machine/daemon-start/handlers/state-recovery.js.map +1 -0
  217. package/dist/commands/machine/daemon-start/handlers/state-recovery.test.d.ts +8 -0
  218. package/dist/commands/machine/daemon-start/handlers/state-recovery.test.d.ts.map +1 -0
  219. package/dist/commands/machine/daemon-start/handlers/state-recovery.test.js +98 -0
  220. package/dist/commands/machine/daemon-start/handlers/state-recovery.test.js.map +1 -0
  221. package/dist/commands/machine/daemon-start/handlers/status.d.ts +6 -0
  222. package/dist/commands/machine/daemon-start/handlers/status.d.ts.map +1 -0
  223. package/dist/commands/machine/daemon-start/handlers/status.js +13 -0
  224. package/dist/commands/machine/daemon-start/handlers/status.js.map +1 -0
  225. package/dist/commands/machine/daemon-start/handlers/status.test.d.ts +5 -0
  226. package/dist/commands/machine/daemon-start/handlers/status.test.d.ts.map +1 -0
  227. package/dist/commands/machine/daemon-start/handlers/status.test.js +51 -0
  228. package/dist/commands/machine/daemon-start/handlers/status.test.js.map +1 -0
  229. package/dist/commands/machine/daemon-start/handlers/stop-agent.d.ts +21 -0
  230. package/dist/commands/machine/daemon-start/handlers/stop-agent.d.ts.map +1 -0
  231. package/dist/commands/machine/daemon-start/handlers/stop-agent.js +36 -0
  232. package/dist/commands/machine/daemon-start/handlers/stop-agent.js.map +1 -0
  233. package/dist/commands/machine/daemon-start/handlers/stop-agent.test.d.ts +7 -0
  234. package/dist/commands/machine/daemon-start/handlers/stop-agent.test.d.ts.map +1 -0
  235. package/dist/commands/machine/daemon-start/handlers/stop-agent.test.js +135 -0
  236. package/dist/commands/machine/daemon-start/handlers/stop-agent.test.js.map +1 -0
  237. package/dist/commands/machine/daemon-start/index.d.ts +16 -0
  238. package/dist/commands/machine/daemon-start/index.d.ts.map +1 -0
  239. package/dist/commands/machine/daemon-start/index.js +21 -0
  240. package/dist/commands/machine/daemon-start/index.js.map +1 -0
  241. package/dist/commands/machine/daemon-start/init.d.ts +23 -0
  242. package/dist/commands/machine/daemon-start/init.d.ts.map +1 -0
  243. package/dist/commands/machine/daemon-start/init.js +338 -0
  244. package/dist/commands/machine/daemon-start/init.js.map +1 -0
  245. package/dist/commands/machine/daemon-start/init.test.d.ts +8 -0
  246. package/dist/commands/machine/daemon-start/init.test.d.ts.map +1 -0
  247. package/dist/commands/machine/daemon-start/init.test.js +385 -0
  248. package/dist/commands/machine/daemon-start/init.test.js.map +1 -0
  249. package/dist/commands/machine/daemon-start/testing/index.d.ts +5 -0
  250. package/dist/commands/machine/daemon-start/testing/index.d.ts.map +1 -0
  251. package/dist/commands/machine/daemon-start/testing/index.js +5 -0
  252. package/dist/commands/machine/daemon-start/testing/index.js.map +1 -0
  253. package/dist/commands/machine/daemon-start/testing/mock-daemon-deps.d.ts +26 -0
  254. package/dist/commands/machine/daemon-start/testing/mock-daemon-deps.d.ts.map +1 -0
  255. package/dist/commands/machine/daemon-start/testing/mock-daemon-deps.js +68 -0
  256. package/dist/commands/machine/daemon-start/testing/mock-daemon-deps.js.map +1 -0
  257. package/dist/commands/machine/daemon-start/types.d.ts +89 -0
  258. package/dist/commands/machine/daemon-start/types.d.ts.map +1 -0
  259. package/dist/commands/machine/daemon-start/types.js +5 -0
  260. package/dist/commands/machine/daemon-start/types.js.map +1 -0
  261. package/dist/commands/machine/daemon-start/utils.d.ts +8 -0
  262. package/dist/commands/machine/daemon-start/utils.d.ts.map +1 -0
  263. package/dist/commands/machine/daemon-start/utils.js +10 -0
  264. package/dist/commands/machine/daemon-start/utils.js.map +1 -0
  265. package/dist/commands/machine/daemon-status.d.ts +10 -0
  266. package/dist/commands/machine/daemon-status.d.ts.map +1 -0
  267. package/dist/commands/machine/daemon-status.js +23 -0
  268. package/dist/commands/machine/daemon-status.js.map +1 -0
  269. package/dist/commands/machine/daemon-stop.d.ts +10 -0
  270. package/dist/commands/machine/daemon-stop.d.ts.map +1 -0
  271. package/dist/commands/machine/daemon-stop.js +44 -0
  272. package/dist/commands/machine/daemon-stop.js.map +1 -0
  273. package/dist/commands/machine/index.d.ts +9 -0
  274. package/dist/commands/machine/index.d.ts.map +1 -0
  275. package/dist/commands/machine/index.js +9 -0
  276. package/dist/commands/machine/index.js.map +1 -0
  277. package/dist/commands/machine/pid.d.ts +48 -0
  278. package/dist/commands/machine/pid.d.ts.map +1 -0
  279. package/dist/commands/machine/pid.js +141 -0
  280. package/dist/commands/machine/pid.js.map +1 -0
  281. package/dist/commands/messages/deps.d.ts +6 -0
  282. package/dist/commands/messages/deps.d.ts.map +1 -0
  283. package/dist/commands/messages/deps.js +2 -0
  284. package/dist/commands/messages/deps.js.map +1 -0
  285. package/dist/commands/messages/index.d.ts +28 -0
  286. package/dist/commands/messages/index.d.ts.map +1 -0
  287. package/dist/commands/messages/index.js +166 -0
  288. package/dist/commands/messages/index.js.map +1 -0
  289. package/dist/commands/messages/index.test.d.ts +8 -0
  290. package/dist/commands/messages/index.test.d.ts.map +1 -0
  291. package/dist/commands/messages/index.test.js +159 -0
  292. package/dist/commands/messages/index.test.js.map +1 -0
  293. package/dist/commands/opencode-install/deps.d.ts +32 -0
  294. package/dist/commands/opencode-install/deps.d.ts.map +1 -0
  295. package/dist/commands/opencode-install/deps.js +8 -0
  296. package/dist/commands/opencode-install/deps.js.map +1 -0
  297. package/dist/commands/opencode-install/index.d.ts +31 -0
  298. package/dist/commands/opencode-install/index.d.ts.map +1 -0
  299. package/dist/commands/opencode-install/index.js +440 -0
  300. package/dist/commands/opencode-install/index.js.map +1 -0
  301. package/dist/commands/opencode-install/index.test.d.ts +8 -0
  302. package/dist/commands/opencode-install/index.test.d.ts.map +1 -0
  303. package/dist/commands/opencode-install/index.test.js +123 -0
  304. package/dist/commands/opencode-install/index.test.js.map +1 -0
  305. package/dist/commands/register-agent/deps.d.ts +12 -0
  306. package/dist/commands/register-agent/deps.d.ts.map +1 -0
  307. package/dist/commands/register-agent/deps.js +8 -0
  308. package/dist/commands/register-agent/deps.js.map +1 -0
  309. package/dist/commands/register-agent/index.d.ts +15 -0
  310. package/dist/commands/register-agent/index.d.ts.map +1 -0
  311. package/dist/commands/register-agent/index.js +118 -0
  312. package/dist/commands/register-agent/index.js.map +1 -0
  313. package/dist/commands/register-agent/index.test.d.ts +9 -0
  314. package/dist/commands/register-agent/index.test.d.ts.map +1 -0
  315. package/dist/commands/register-agent/index.test.js +204 -0
  316. package/dist/commands/register-agent/index.test.js.map +1 -0
  317. package/dist/commands/report-progress/deps.d.ts +9 -0
  318. package/dist/commands/report-progress/deps.d.ts.map +1 -0
  319. package/dist/commands/report-progress/deps.js +5 -0
  320. package/dist/commands/report-progress/deps.js.map +1 -0
  321. package/dist/commands/report-progress/index.d.ts +14 -0
  322. package/dist/commands/report-progress/index.d.ts.map +1 -0
  323. package/dist/commands/report-progress/index.js +110 -0
  324. package/dist/commands/report-progress/index.js.map +1 -0
  325. package/dist/commands/report-progress/index.test.d.ts +8 -0
  326. package/dist/commands/report-progress/index.test.d.ts.map +1 -0
  327. package/dist/commands/report-progress/index.test.js +114 -0
  328. package/dist/commands/report-progress/index.test.js.map +1 -0
  329. package/dist/commands/skill/deps.d.ts +9 -0
  330. package/dist/commands/skill/deps.d.ts.map +1 -0
  331. package/dist/commands/skill/deps.js +5 -0
  332. package/dist/commands/skill/deps.js.map +1 -0
  333. package/dist/commands/skill/index.d.ts +20 -0
  334. package/dist/commands/skill/index.d.ts.map +1 -0
  335. package/dist/commands/skill/index.js +86 -0
  336. package/dist/commands/skill/index.js.map +1 -0
  337. package/dist/commands/skill/index.test.d.ts +8 -0
  338. package/dist/commands/skill/index.test.d.ts.map +1 -0
  339. package/dist/commands/skill/index.test.js +166 -0
  340. package/dist/commands/skill/index.test.js.map +1 -0
  341. package/dist/commands/task/read/deps.d.ts +18 -0
  342. package/dist/commands/task/read/deps.d.ts.map +1 -0
  343. package/dist/commands/task/read/deps.js +8 -0
  344. package/dist/commands/task/read/deps.js.map +1 -0
  345. package/dist/commands/task/read/index.d.ts +17 -0
  346. package/dist/commands/task/read/index.d.ts.map +1 -0
  347. package/dist/commands/task/read/index.js +144 -0
  348. package/dist/commands/task/read/index.js.map +1 -0
  349. package/dist/commands/telegram/deps.d.ts +13 -0
  350. package/dist/commands/telegram/deps.d.ts.map +1 -0
  351. package/dist/commands/telegram/deps.js +5 -0
  352. package/dist/commands/telegram/deps.js.map +1 -0
  353. package/dist/commands/telegram/index.d.ts +18 -0
  354. package/dist/commands/telegram/index.d.ts.map +1 -0
  355. package/dist/commands/telegram/index.js +94 -0
  356. package/dist/commands/telegram/index.js.map +1 -0
  357. package/dist/commands/update/deps.d.ts +21 -0
  358. package/dist/commands/update/deps.d.ts.map +1 -0
  359. package/dist/commands/update/deps.js +8 -0
  360. package/dist/commands/update/deps.js.map +1 -0
  361. package/dist/commands/update/index.d.ts +8 -0
  362. package/dist/commands/update/index.d.ts.map +1 -0
  363. package/dist/commands/update/index.js +70 -0
  364. package/dist/commands/update/index.js.map +1 -0
  365. package/dist/commands/update/index.test.d.ts +8 -0
  366. package/dist/commands/update/index.test.d.ts.map +1 -0
  367. package/dist/commands/update/index.test.js +108 -0
  368. package/dist/commands/update/index.test.js.map +1 -0
  369. package/dist/commands/workflow/deps.d.ts +9 -0
  370. package/dist/commands/workflow/deps.d.ts.map +1 -0
  371. package/dist/commands/workflow/deps.js +5 -0
  372. package/dist/commands/workflow/deps.js.map +1 -0
  373. package/dist/commands/workflow/index.d.ts +73 -0
  374. package/dist/commands/workflow/index.d.ts.map +1 -0
  375. package/dist/commands/workflow/index.js +545 -0
  376. package/dist/commands/workflow/index.js.map +1 -0
  377. package/dist/commands/workflow/index.test.d.ts +7 -0
  378. package/dist/commands/workflow/index.test.d.ts.map +1 -0
  379. package/dist/commands/workflow/index.test.js +315 -0
  380. package/dist/commands/workflow/index.test.js.map +1 -0
  381. package/dist/config/defaults.d.ts +10 -0
  382. package/dist/config/defaults.d.ts.map +1 -0
  383. package/dist/config/defaults.js +79 -0
  384. package/dist/config/defaults.js.map +1 -0
  385. package/dist/config/loader.d.ts +52 -0
  386. package/dist/config/loader.d.ts.map +1 -0
  387. package/dist/config/loader.js +202 -0
  388. package/dist/config/loader.js.map +1 -0
  389. package/dist/config/schema.d.ts +50 -0
  390. package/dist/config/schema.d.ts.map +1 -0
  391. package/dist/config/schema.js +99 -0
  392. package/dist/config/schema.js.map +1 -0
  393. package/dist/config.d.ts +14 -0
  394. package/dist/config.d.ts.map +1 -0
  395. package/dist/config.js +14 -0
  396. package/dist/config.js.map +1 -0
  397. package/dist/events/daemon/agent/on-agent-exited.d.ts +26 -0
  398. package/dist/events/daemon/agent/on-agent-exited.d.ts.map +1 -0
  399. package/dist/events/daemon/agent/on-agent-exited.js +20 -0
  400. package/dist/events/daemon/agent/on-agent-exited.js.map +1 -0
  401. package/dist/events/daemon/agent/on-agent-started.d.ts +16 -0
  402. package/dist/events/daemon/agent/on-agent-started.d.ts.map +1 -0
  403. package/dist/events/daemon/agent/on-agent-started.js +11 -0
  404. package/dist/events/daemon/agent/on-agent-started.js.map +1 -0
  405. package/dist/events/daemon/agent/on-agent-stopped.d.ts +14 -0
  406. package/dist/events/daemon/agent/on-agent-stopped.d.ts.map +1 -0
  407. package/dist/events/daemon/agent/on-agent-stopped.js +11 -0
  408. package/dist/events/daemon/agent/on-agent-stopped.js.map +1 -0
  409. package/dist/events/daemon/agent/on-request-start-agent.d.ts +19 -0
  410. package/dist/events/daemon/agent/on-request-start-agent.d.ts.map +1 -0
  411. package/dist/events/daemon/agent/on-request-start-agent.js +55 -0
  412. package/dist/events/daemon/agent/on-request-start-agent.js.map +1 -0
  413. package/dist/events/daemon/agent/on-request-start-agent.test.d.ts +2 -0
  414. package/dist/events/daemon/agent/on-request-start-agent.test.d.ts.map +1 -0
  415. package/dist/events/daemon/agent/on-request-start-agent.test.js +96 -0
  416. package/dist/events/daemon/agent/on-request-start-agent.test.js.map +1 -0
  417. package/dist/events/daemon/agent/on-request-stop-agent.d.ts +16 -0
  418. package/dist/events/daemon/agent/on-request-stop-agent.d.ts.map +1 -0
  419. package/dist/events/daemon/agent/on-request-stop-agent.js +19 -0
  420. package/dist/events/daemon/agent/on-request-stop-agent.js.map +1 -0
  421. package/dist/events/daemon/event-bus.d.ts +87 -0
  422. package/dist/events/daemon/event-bus.d.ts.map +1 -0
  423. package/dist/events/daemon/event-bus.js +50 -0
  424. package/dist/events/daemon/event-bus.js.map +1 -0
  425. package/dist/events/daemon/register-listeners.d.ts +9 -0
  426. package/dist/events/daemon/register-listeners.d.ts.map +1 -0
  427. package/dist/events/daemon/register-listeners.js +21 -0
  428. package/dist/events/daemon/register-listeners.js.map +1 -0
  429. package/dist/events/lifecycle/on-daemon-shutdown.d.ts +9 -0
  430. package/dist/events/lifecycle/on-daemon-shutdown.d.ts.map +1 -0
  431. package/dist/events/lifecycle/on-daemon-shutdown.js +43 -0
  432. package/dist/events/lifecycle/on-daemon-shutdown.js.map +1 -0
  433. package/dist/index.d.ts +9 -0
  434. package/dist/index.d.ts.map +1 -0
  435. package/dist/index.js +315 -25
  436. package/dist/index.js.map +1 -0
  437. package/dist/infrastructure/auth/middleware.d.ts +21 -0
  438. package/dist/infrastructure/auth/middleware.d.ts.map +1 -0
  439. package/dist/infrastructure/auth/middleware.js +106 -0
  440. package/dist/infrastructure/auth/middleware.js.map +1 -0
  441. package/dist/infrastructure/auth/storage.d.ts +59 -0
  442. package/dist/infrastructure/auth/storage.d.ts.map +1 -0
  443. package/dist/infrastructure/auth/storage.js +242 -0
  444. package/dist/infrastructure/auth/storage.js.map +1 -0
  445. package/dist/infrastructure/convex/client.d.ts +28 -0
  446. package/dist/infrastructure/convex/client.d.ts.map +1 -0
  447. package/dist/infrastructure/convex/client.js +77 -0
  448. package/dist/infrastructure/convex/client.js.map +1 -0
  449. package/dist/infrastructure/deps/backend.d.ts +13 -0
  450. package/dist/infrastructure/deps/backend.d.ts.map +1 -0
  451. package/dist/infrastructure/deps/backend.js +8 -0
  452. package/dist/infrastructure/deps/backend.js.map +1 -0
  453. package/dist/infrastructure/deps/clock.d.ts +13 -0
  454. package/dist/infrastructure/deps/clock.d.ts.map +1 -0
  455. package/dist/infrastructure/deps/clock.js +8 -0
  456. package/dist/infrastructure/deps/clock.js.map +1 -0
  457. package/dist/infrastructure/deps/fs.d.ts +12 -0
  458. package/dist/infrastructure/deps/fs.d.ts.map +1 -0
  459. package/dist/infrastructure/deps/fs.js +8 -0
  460. package/dist/infrastructure/deps/fs.js.map +1 -0
  461. package/dist/infrastructure/deps/index.d.ts +12 -0
  462. package/dist/infrastructure/deps/index.d.ts.map +1 -0
  463. package/dist/infrastructure/deps/index.js +8 -0
  464. package/dist/infrastructure/deps/index.js.map +1 -0
  465. package/dist/infrastructure/deps/process.d.ts +11 -0
  466. package/dist/infrastructure/deps/process.d.ts.map +1 -0
  467. package/dist/infrastructure/deps/process.js +8 -0
  468. package/dist/infrastructure/deps/process.js.map +1 -0
  469. package/dist/infrastructure/deps/session.d.ts +16 -0
  470. package/dist/infrastructure/deps/session.d.ts.map +1 -0
  471. package/dist/infrastructure/deps/session.js +8 -0
  472. package/dist/infrastructure/deps/session.js.map +1 -0
  473. package/dist/infrastructure/git/git-reader.d.ts +206 -0
  474. package/dist/infrastructure/git/git-reader.d.ts.map +1 -0
  475. package/dist/infrastructure/git/git-reader.js +711 -0
  476. package/dist/infrastructure/git/git-reader.js.map +1 -0
  477. package/dist/infrastructure/git/git-reader.test.d.ts +8 -0
  478. package/dist/infrastructure/git/git-reader.test.d.ts.map +1 -0
  479. package/dist/infrastructure/git/git-reader.test.js +598 -0
  480. package/dist/infrastructure/git/git-reader.test.js.map +1 -0
  481. package/dist/infrastructure/git/git-writer.d.ts +48 -0
  482. package/dist/infrastructure/git/git-writer.d.ts.map +1 -0
  483. package/dist/infrastructure/git/git-writer.js +127 -0
  484. package/dist/infrastructure/git/git-writer.js.map +1 -0
  485. package/dist/infrastructure/git/index.d.ts +10 -0
  486. package/dist/infrastructure/git/index.d.ts.map +1 -0
  487. package/dist/infrastructure/git/index.js +9 -0
  488. package/dist/infrastructure/git/index.js.map +1 -0
  489. package/dist/infrastructure/git/types.d.ts +127 -0
  490. package/dist/infrastructure/git/types.d.ts.map +1 -0
  491. package/dist/infrastructure/git/types.js +20 -0
  492. package/dist/infrastructure/git/types.js.map +1 -0
  493. package/dist/infrastructure/history/storage.d.ts +21 -0
  494. package/dist/infrastructure/history/storage.d.ts.map +1 -0
  495. package/dist/infrastructure/history/storage.js +56 -0
  496. package/dist/infrastructure/history/storage.js.map +1 -0
  497. package/dist/infrastructure/lifecycle-heartbeat.d.ts +18 -0
  498. package/dist/infrastructure/lifecycle-heartbeat.d.ts.map +1 -0
  499. package/dist/infrastructure/lifecycle-heartbeat.js +21 -0
  500. package/dist/infrastructure/lifecycle-heartbeat.js.map +1 -0
  501. package/dist/infrastructure/local-actions/execute-local-action.d.ts +33 -0
  502. package/dist/infrastructure/local-actions/execute-local-action.d.ts.map +1 -0
  503. package/dist/infrastructure/local-actions/execute-local-action.js +109 -0
  504. package/dist/infrastructure/local-actions/execute-local-action.js.map +1 -0
  505. package/dist/infrastructure/local-actions/index.d.ts +9 -0
  506. package/dist/infrastructure/local-actions/index.d.ts.map +1 -0
  507. package/dist/infrastructure/local-actions/index.js +8 -0
  508. package/dist/infrastructure/local-actions/index.js.map +1 -0
  509. package/dist/infrastructure/local-api/cors.d.ts +19 -0
  510. package/dist/infrastructure/local-api/cors.d.ts.map +1 -0
  511. package/dist/infrastructure/local-api/cors.js +50 -0
  512. package/dist/infrastructure/local-api/cors.js.map +1 -0
  513. package/dist/infrastructure/local-api/identity.test.d.ts +8 -0
  514. package/dist/infrastructure/local-api/identity.test.d.ts.map +1 -0
  515. package/dist/infrastructure/local-api/identity.test.js +71 -0
  516. package/dist/infrastructure/local-api/identity.test.js.map +1 -0
  517. package/dist/infrastructure/local-api/index.d.ts +10 -0
  518. package/dist/infrastructure/local-api/index.d.ts.map +1 -0
  519. package/dist/infrastructure/local-api/index.js +8 -0
  520. package/dist/infrastructure/local-api/index.js.map +1 -0
  521. package/dist/infrastructure/local-api/open-finder.test.d.ts +13 -0
  522. package/dist/infrastructure/local-api/open-finder.test.d.ts.map +1 -0
  523. package/dist/infrastructure/local-api/open-finder.test.js +112 -0
  524. package/dist/infrastructure/local-api/open-finder.test.js.map +1 -0
  525. package/dist/infrastructure/local-api/open-github-desktop.test.d.ts +12 -0
  526. package/dist/infrastructure/local-api/open-github-desktop.test.d.ts.map +1 -0
  527. package/dist/infrastructure/local-api/open-github-desktop.test.js +129 -0
  528. package/dist/infrastructure/local-api/open-github-desktop.test.js.map +1 -0
  529. package/dist/infrastructure/local-api/open-vscode.test.d.ts +12 -0
  530. package/dist/infrastructure/local-api/open-vscode.test.d.ts.map +1 -0
  531. package/dist/infrastructure/local-api/open-vscode.test.js +130 -0
  532. package/dist/infrastructure/local-api/open-vscode.test.js.map +1 -0
  533. package/dist/infrastructure/local-api/router.d.ts +28 -0
  534. package/dist/infrastructure/local-api/router.d.ts.map +1 -0
  535. package/dist/infrastructure/local-api/router.js +60 -0
  536. package/dist/infrastructure/local-api/router.js.map +1 -0
  537. package/dist/infrastructure/local-api/router.test.d.ts +8 -0
  538. package/dist/infrastructure/local-api/router.test.d.ts.map +1 -0
  539. package/dist/infrastructure/local-api/router.test.js +142 -0
  540. package/dist/infrastructure/local-api/router.test.js.map +1 -0
  541. package/dist/infrastructure/local-api/routes/identity.d.ts +28 -0
  542. package/dist/infrastructure/local-api/routes/identity.d.ts.map +1 -0
  543. package/dist/infrastructure/local-api/routes/identity.js +42 -0
  544. package/dist/infrastructure/local-api/routes/identity.js.map +1 -0
  545. package/dist/infrastructure/local-api/routes/open-finder.d.ts +25 -0
  546. package/dist/infrastructure/local-api/routes/open-finder.d.ts.map +1 -0
  547. package/dist/infrastructure/local-api/routes/open-finder.js +58 -0
  548. package/dist/infrastructure/local-api/routes/open-finder.js.map +1 -0
  549. package/dist/infrastructure/local-api/routes/open-github-desktop.d.ts +21 -0
  550. package/dist/infrastructure/local-api/routes/open-github-desktop.d.ts.map +1 -0
  551. package/dist/infrastructure/local-api/routes/open-github-desktop.js +43 -0
  552. package/dist/infrastructure/local-api/routes/open-github-desktop.js.map +1 -0
  553. package/dist/infrastructure/local-api/routes/open-vscode.d.ts +23 -0
  554. package/dist/infrastructure/local-api/routes/open-vscode.d.ts.map +1 -0
  555. package/dist/infrastructure/local-api/routes/open-vscode.js +51 -0
  556. package/dist/infrastructure/local-api/routes/open-vscode.js.map +1 -0
  557. package/dist/infrastructure/local-api/routes/shared-utils.d.ts +51 -0
  558. package/dist/infrastructure/local-api/routes/shared-utils.d.ts.map +1 -0
  559. package/dist/infrastructure/local-api/routes/shared-utils.js +96 -0
  560. package/dist/infrastructure/local-api/routes/shared-utils.js.map +1 -0
  561. package/dist/infrastructure/local-api/server.d.ts +40 -0
  562. package/dist/infrastructure/local-api/server.d.ts.map +1 -0
  563. package/dist/infrastructure/local-api/server.js +153 -0
  564. package/dist/infrastructure/local-api/server.js.map +1 -0
  565. package/dist/infrastructure/local-api/types.d.ts +48 -0
  566. package/dist/infrastructure/local-api/types.d.ts.map +1 -0
  567. package/dist/infrastructure/local-api/types.js +8 -0
  568. package/dist/infrastructure/local-api/types.js.map +1 -0
  569. package/dist/infrastructure/machine/crash-loop-tracker.d.ts +69 -0
  570. package/dist/infrastructure/machine/crash-loop-tracker.d.ts.map +1 -0
  571. package/dist/infrastructure/machine/crash-loop-tracker.js +116 -0
  572. package/dist/infrastructure/machine/crash-loop-tracker.js.map +1 -0
  573. package/dist/infrastructure/machine/crash-loop-tracker.test.d.ts +8 -0
  574. package/dist/infrastructure/machine/crash-loop-tracker.test.d.ts.map +1 -0
  575. package/dist/infrastructure/machine/crash-loop-tracker.test.js +210 -0
  576. package/dist/infrastructure/machine/crash-loop-tracker.test.js.map +1 -0
  577. package/dist/infrastructure/machine/daemon-state.d.ts +96 -0
  578. package/dist/infrastructure/machine/daemon-state.d.ts.map +1 -0
  579. package/dist/infrastructure/machine/daemon-state.js +183 -0
  580. package/dist/infrastructure/machine/daemon-state.js.map +1 -0
  581. package/dist/infrastructure/machine/daemon-state.test.d.ts +10 -0
  582. package/dist/infrastructure/machine/daemon-state.test.d.ts.map +1 -0
  583. package/dist/infrastructure/machine/daemon-state.test.js +128 -0
  584. package/dist/infrastructure/machine/daemon-state.test.js.map +1 -0
  585. package/dist/infrastructure/machine/detection.d.ts +27 -0
  586. package/dist/infrastructure/machine/detection.d.ts.map +1 -0
  587. package/dist/infrastructure/machine/detection.js +47 -0
  588. package/dist/infrastructure/machine/detection.js.map +1 -0
  589. package/dist/infrastructure/machine/index.d.ts +10 -0
  590. package/dist/infrastructure/machine/index.d.ts.map +1 -0
  591. package/dist/infrastructure/machine/index.js +11 -0
  592. package/dist/infrastructure/machine/index.js.map +1 -0
  593. package/dist/infrastructure/machine/stop-reason.d.ts +26 -0
  594. package/dist/infrastructure/machine/stop-reason.d.ts.map +1 -0
  595. package/dist/infrastructure/machine/stop-reason.js +22 -0
  596. package/dist/infrastructure/machine/stop-reason.js.map +1 -0
  597. package/dist/infrastructure/machine/stop-reason.test.d.ts +2 -0
  598. package/dist/infrastructure/machine/stop-reason.test.d.ts.map +1 -0
  599. package/dist/infrastructure/machine/stop-reason.test.js +32 -0
  600. package/dist/infrastructure/machine/stop-reason.test.js.map +1 -0
  601. package/dist/infrastructure/machine/storage.d.ts +42 -0
  602. package/dist/infrastructure/machine/storage.d.ts.map +1 -0
  603. package/dist/infrastructure/machine/storage.js +156 -0
  604. package/dist/infrastructure/machine/storage.js.map +1 -0
  605. package/dist/infrastructure/machine/types.d.ts +58 -0
  606. package/dist/infrastructure/machine/types.d.ts.map +1 -0
  607. package/dist/infrastructure/machine/types.js +11 -0
  608. package/dist/infrastructure/machine/types.js.map +1 -0
  609. package/dist/infrastructure/retry-queue.d.ts +17 -0
  610. package/dist/infrastructure/retry-queue.d.ts.map +1 -0
  611. package/dist/infrastructure/retry-queue.js +33 -0
  612. package/dist/infrastructure/retry-queue.js.map +1 -0
  613. package/dist/infrastructure/services/agent-process-manager/agent-process-manager.d.ts +142 -0
  614. package/dist/infrastructure/services/agent-process-manager/agent-process-manager.d.ts.map +1 -0
  615. package/dist/infrastructure/services/agent-process-manager/agent-process-manager.js +567 -0
  616. package/dist/infrastructure/services/agent-process-manager/agent-process-manager.js.map +1 -0
  617. package/dist/infrastructure/services/agent-process-manager/agent-process-manager.test.d.ts +2 -0
  618. package/dist/infrastructure/services/agent-process-manager/agent-process-manager.test.d.ts.map +1 -0
  619. package/dist/infrastructure/services/agent-process-manager/agent-process-manager.test.js +692 -0
  620. package/dist/infrastructure/services/agent-process-manager/agent-process-manager.test.js.map +1 -0
  621. package/dist/infrastructure/services/harness-spawning/harness-spawning-service.d.ts +47 -0
  622. package/dist/infrastructure/services/harness-spawning/harness-spawning-service.d.ts.map +1 -0
  623. package/dist/infrastructure/services/harness-spawning/harness-spawning-service.js +68 -0
  624. package/dist/infrastructure/services/harness-spawning/harness-spawning-service.js.map +1 -0
  625. package/dist/infrastructure/services/harness-spawning/harness-spawning-service.test.d.ts +2 -0
  626. package/dist/infrastructure/services/harness-spawning/harness-spawning-service.test.d.ts.map +1 -0
  627. package/dist/infrastructure/services/harness-spawning/harness-spawning-service.test.js +149 -0
  628. package/dist/infrastructure/services/harness-spawning/harness-spawning-service.test.js.map +1 -0
  629. package/dist/infrastructure/services/harness-spawning/index.d.ts +5 -0
  630. package/dist/infrastructure/services/harness-spawning/index.d.ts.map +1 -0
  631. package/dist/infrastructure/services/harness-spawning/index.js +3 -0
  632. package/dist/infrastructure/services/harness-spawning/index.js.map +1 -0
  633. package/dist/infrastructure/services/harness-spawning/rate-limiter.d.ts +45 -0
  634. package/dist/infrastructure/services/harness-spawning/rate-limiter.d.ts.map +1 -0
  635. package/dist/infrastructure/services/harness-spawning/rate-limiter.js +84 -0
  636. package/dist/infrastructure/services/harness-spawning/rate-limiter.js.map +1 -0
  637. package/dist/infrastructure/services/harness-spawning/rate-limiter.test.d.ts +2 -0
  638. package/dist/infrastructure/services/harness-spawning/rate-limiter.test.d.ts.map +1 -0
  639. package/dist/infrastructure/services/harness-spawning/rate-limiter.test.js +179 -0
  640. package/dist/infrastructure/services/harness-spawning/rate-limiter.test.js.map +1 -0
  641. package/dist/infrastructure/services/remote-agents/base-cli-agent-service.d.ts +77 -0
  642. package/dist/infrastructure/services/remote-agents/base-cli-agent-service.d.ts.map +1 -0
  643. package/dist/infrastructure/services/remote-agents/base-cli-agent-service.js +149 -0
  644. package/dist/infrastructure/services/remote-agents/base-cli-agent-service.js.map +1 -0
  645. package/dist/infrastructure/services/remote-agents/base-cli-agent-service.test.d.ts +2 -0
  646. package/dist/infrastructure/services/remote-agents/base-cli-agent-service.test.d.ts.map +1 -0
  647. package/dist/infrastructure/services/remote-agents/base-cli-agent-service.test.js +273 -0
  648. package/dist/infrastructure/services/remote-agents/base-cli-agent-service.test.js.map +1 -0
  649. package/dist/infrastructure/services/remote-agents/claude/claude-code-agent-service.d.ts +30 -0
  650. package/dist/infrastructure/services/remote-agents/claude/claude-code-agent-service.d.ts.map +1 -0
  651. package/dist/infrastructure/services/remote-agents/claude/claude-code-agent-service.js +186 -0
  652. package/dist/infrastructure/services/remote-agents/claude/claude-code-agent-service.js.map +1 -0
  653. package/dist/infrastructure/services/remote-agents/claude/claude-stream-reader.d.ts +42 -0
  654. package/dist/infrastructure/services/remote-agents/claude/claude-stream-reader.d.ts.map +1 -0
  655. package/dist/infrastructure/services/remote-agents/claude/claude-stream-reader.js +92 -0
  656. package/dist/infrastructure/services/remote-agents/claude/claude-stream-reader.js.map +1 -0
  657. package/dist/infrastructure/services/remote-agents/claude/index.d.ts +2 -0
  658. package/dist/infrastructure/services/remote-agents/claude/index.d.ts.map +1 -0
  659. package/dist/infrastructure/services/remote-agents/claude/index.js +2 -0
  660. package/dist/infrastructure/services/remote-agents/claude/index.js.map +1 -0
  661. package/dist/infrastructure/services/remote-agents/copilot/copilot-agent-service.d.ts +44 -0
  662. package/dist/infrastructure/services/remote-agents/copilot/copilot-agent-service.d.ts.map +1 -0
  663. package/dist/infrastructure/services/remote-agents/copilot/copilot-agent-service.js +160 -0
  664. package/dist/infrastructure/services/remote-agents/copilot/copilot-agent-service.js.map +1 -0
  665. package/dist/infrastructure/services/remote-agents/copilot/copilot-stream-reader.d.ts +59 -0
  666. package/dist/infrastructure/services/remote-agents/copilot/copilot-stream-reader.d.ts.map +1 -0
  667. package/dist/infrastructure/services/remote-agents/copilot/copilot-stream-reader.js +100 -0
  668. package/dist/infrastructure/services/remote-agents/copilot/copilot-stream-reader.js.map +1 -0
  669. package/dist/infrastructure/services/remote-agents/copilot/copilot-stream-reader.test.d.ts +2 -0
  670. package/dist/infrastructure/services/remote-agents/copilot/copilot-stream-reader.test.d.ts.map +1 -0
  671. package/dist/infrastructure/services/remote-agents/copilot/copilot-stream-reader.test.js +105 -0
  672. package/dist/infrastructure/services/remote-agents/copilot/copilot-stream-reader.test.js.map +1 -0
  673. package/dist/infrastructure/services/remote-agents/copilot/index.d.ts +3 -0
  674. package/dist/infrastructure/services/remote-agents/copilot/index.d.ts.map +1 -0
  675. package/dist/infrastructure/services/remote-agents/copilot/index.js +3 -0
  676. package/dist/infrastructure/services/remote-agents/copilot/index.js.map +1 -0
  677. package/dist/infrastructure/services/remote-agents/cursor/cursor-agent-service.d.ts +29 -0
  678. package/dist/infrastructure/services/remote-agents/cursor/cursor-agent-service.d.ts.map +1 -0
  679. package/dist/infrastructure/services/remote-agents/cursor/cursor-agent-service.js +219 -0
  680. package/dist/infrastructure/services/remote-agents/cursor/cursor-agent-service.js.map +1 -0
  681. package/dist/infrastructure/services/remote-agents/cursor/cursor-agent-service.test.d.ts +2 -0
  682. package/dist/infrastructure/services/remote-agents/cursor/cursor-agent-service.test.d.ts.map +1 -0
  683. package/dist/infrastructure/services/remote-agents/cursor/cursor-agent-service.test.js +223 -0
  684. package/dist/infrastructure/services/remote-agents/cursor/cursor-agent-service.test.js.map +1 -0
  685. package/dist/infrastructure/services/remote-agents/cursor/cursor-stream-reader.d.ts +41 -0
  686. package/dist/infrastructure/services/remote-agents/cursor/cursor-stream-reader.d.ts.map +1 -0
  687. package/dist/infrastructure/services/remote-agents/cursor/cursor-stream-reader.js +95 -0
  688. package/dist/infrastructure/services/remote-agents/cursor/cursor-stream-reader.js.map +1 -0
  689. package/dist/infrastructure/services/remote-agents/cursor/cursor-stream-reader.test.d.ts +2 -0
  690. package/dist/infrastructure/services/remote-agents/cursor/cursor-stream-reader.test.d.ts.map +1 -0
  691. package/dist/infrastructure/services/remote-agents/cursor/cursor-stream-reader.test.js +334 -0
  692. package/dist/infrastructure/services/remote-agents/cursor/cursor-stream-reader.test.js.map +1 -0
  693. package/dist/infrastructure/services/remote-agents/cursor/index.d.ts +3 -0
  694. package/dist/infrastructure/services/remote-agents/cursor/index.d.ts.map +1 -0
  695. package/dist/infrastructure/services/remote-agents/cursor/index.js +2 -0
  696. package/dist/infrastructure/services/remote-agents/cursor/index.js.map +1 -0
  697. package/dist/infrastructure/services/remote-agents/index.d.ts +8 -0
  698. package/dist/infrastructure/services/remote-agents/index.d.ts.map +1 -0
  699. package/dist/infrastructure/services/remote-agents/index.js +7 -0
  700. package/dist/infrastructure/services/remote-agents/index.js.map +1 -0
  701. package/dist/infrastructure/services/remote-agents/init-registry.d.ts +3 -0
  702. package/dist/infrastructure/services/remote-agents/init-registry.d.ts.map +1 -0
  703. package/dist/infrastructure/services/remote-agents/init-registry.js +19 -0
  704. package/dist/infrastructure/services/remote-agents/init-registry.js.map +1 -0
  705. package/dist/infrastructure/services/remote-agents/opencode/index.d.ts +4 -0
  706. package/dist/infrastructure/services/remote-agents/opencode/index.d.ts.map +1 -0
  707. package/dist/infrastructure/services/remote-agents/opencode/index.js +3 -0
  708. package/dist/infrastructure/services/remote-agents/opencode/index.js.map +1 -0
  709. package/dist/infrastructure/services/remote-agents/opencode/opencode-agent-service.d.ts +32 -0
  710. package/dist/infrastructure/services/remote-agents/opencode/opencode-agent-service.d.ts.map +1 -0
  711. package/dist/infrastructure/services/remote-agents/opencode/opencode-agent-service.js +225 -0
  712. package/dist/infrastructure/services/remote-agents/opencode/opencode-agent-service.js.map +1 -0
  713. package/dist/infrastructure/services/remote-agents/opencode/opencode-agent-service.test.d.ts +2 -0
  714. package/dist/infrastructure/services/remote-agents/opencode/opencode-agent-service.test.d.ts.map +1 -0
  715. package/dist/infrastructure/services/remote-agents/opencode/opencode-agent-service.test.js +226 -0
  716. package/dist/infrastructure/services/remote-agents/opencode/opencode-agent-service.test.js.map +1 -0
  717. package/dist/infrastructure/services/remote-agents/opencode/opencode-json-reader.d.ts +46 -0
  718. package/dist/infrastructure/services/remote-agents/opencode/opencode-json-reader.d.ts.map +1 -0
  719. package/dist/infrastructure/services/remote-agents/opencode/opencode-json-reader.js +104 -0
  720. package/dist/infrastructure/services/remote-agents/opencode/opencode-json-reader.js.map +1 -0
  721. package/dist/infrastructure/services/remote-agents/opencode/opencode-json-reader.test.d.ts +2 -0
  722. package/dist/infrastructure/services/remote-agents/opencode/opencode-json-reader.test.d.ts.map +1 -0
  723. package/dist/infrastructure/services/remote-agents/opencode/opencode-json-reader.test.js +268 -0
  724. package/dist/infrastructure/services/remote-agents/opencode/opencode-json-reader.test.js.map +1 -0
  725. package/dist/infrastructure/services/remote-agents/pi/index.d.ts +3 -0
  726. package/dist/infrastructure/services/remote-agents/pi/index.d.ts.map +1 -0
  727. package/dist/infrastructure/services/remote-agents/pi/index.js +2 -0
  728. package/dist/infrastructure/services/remote-agents/pi/index.js.map +1 -0
  729. package/dist/infrastructure/services/remote-agents/pi/pi-agent-service.d.ts +35 -0
  730. package/dist/infrastructure/services/remote-agents/pi/pi-agent-service.d.ts.map +1 -0
  731. package/dist/infrastructure/services/remote-agents/pi/pi-agent-service.js +253 -0
  732. package/dist/infrastructure/services/remote-agents/pi/pi-agent-service.js.map +1 -0
  733. package/dist/infrastructure/services/remote-agents/pi/pi-agent-service.test.d.ts +2 -0
  734. package/dist/infrastructure/services/remote-agents/pi/pi-agent-service.test.d.ts.map +1 -0
  735. package/dist/infrastructure/services/remote-agents/pi/pi-agent-service.test.js +348 -0
  736. package/dist/infrastructure/services/remote-agents/pi/pi-agent-service.test.js.map +1 -0
  737. package/dist/infrastructure/services/remote-agents/pi/pi-rpc-reader.d.ts +50 -0
  738. package/dist/infrastructure/services/remote-agents/pi/pi-rpc-reader.d.ts.map +1 -0
  739. package/dist/infrastructure/services/remote-agents/pi/pi-rpc-reader.js +120 -0
  740. package/dist/infrastructure/services/remote-agents/pi/pi-rpc-reader.js.map +1 -0
  741. package/dist/infrastructure/services/remote-agents/pi/pi-rpc-reader.test.d.ts +2 -0
  742. package/dist/infrastructure/services/remote-agents/pi/pi-rpc-reader.test.d.ts.map +1 -0
  743. package/dist/infrastructure/services/remote-agents/pi/pi-rpc-reader.test.js +288 -0
  744. package/dist/infrastructure/services/remote-agents/pi/pi-rpc-reader.test.js.map +1 -0
  745. package/dist/infrastructure/services/remote-agents/registry.d.ts +8 -0
  746. package/dist/infrastructure/services/remote-agents/registry.d.ts.map +1 -0
  747. package/dist/infrastructure/services/remote-agents/registry.js +14 -0
  748. package/dist/infrastructure/services/remote-agents/registry.js.map +1 -0
  749. package/dist/infrastructure/services/remote-agents/remote-agent-service.d.ts +79 -0
  750. package/dist/infrastructure/services/remote-agents/remote-agent-service.d.ts.map +1 -0
  751. package/dist/infrastructure/services/remote-agents/remote-agent-service.js +9 -0
  752. package/dist/infrastructure/services/remote-agents/remote-agent-service.js.map +1 -0
  753. package/dist/infrastructure/services/workspace/command-discovery.d.ts +65 -0
  754. package/dist/infrastructure/services/workspace/command-discovery.d.ts.map +1 -0
  755. package/dist/infrastructure/services/workspace/command-discovery.js +193 -0
  756. package/dist/infrastructure/services/workspace/command-discovery.js.map +1 -0
  757. package/dist/infrastructure/services/workspace/command-discovery.test.d.ts +7 -0
  758. package/dist/infrastructure/services/workspace/command-discovery.test.d.ts.map +1 -0
  759. package/dist/infrastructure/services/workspace/command-discovery.test.js +182 -0
  760. package/dist/infrastructure/services/workspace/command-discovery.test.js.map +1 -0
  761. package/dist/infrastructure/services/workspace/file-tree-scanner.d.ts +47 -0
  762. package/dist/infrastructure/services/workspace/file-tree-scanner.d.ts.map +1 -0
  763. package/dist/infrastructure/services/workspace/file-tree-scanner.js +159 -0
  764. package/dist/infrastructure/services/workspace/file-tree-scanner.js.map +1 -0
  765. package/dist/infrastructure/services/workspace/file-tree-scanner.test.d.ts +2 -0
  766. package/dist/infrastructure/services/workspace/file-tree-scanner.test.d.ts.map +1 -0
  767. package/dist/infrastructure/services/workspace/file-tree-scanner.test.js +132 -0
  768. package/dist/infrastructure/services/workspace/file-tree-scanner.test.js.map +1 -0
  769. package/dist/infrastructure/services/workspace/workspace-resolver.d.ts +34 -0
  770. package/dist/infrastructure/services/workspace/workspace-resolver.d.ts.map +1 -0
  771. package/dist/infrastructure/services/workspace/workspace-resolver.js +187 -0
  772. package/dist/infrastructure/services/workspace/workspace-resolver.js.map +1 -0
  773. package/dist/infrastructure/services/workspace/workspace-resolver.test.d.ts +5 -0
  774. package/dist/infrastructure/services/workspace/workspace-resolver.test.d.ts.map +1 -0
  775. package/dist/infrastructure/services/workspace/workspace-resolver.test.js +152 -0
  776. package/dist/infrastructure/services/workspace/workspace-resolver.test.js.map +1 -0
  777. package/dist/tools/index.d.ts +7 -0
  778. package/dist/tools/index.d.ts.map +1 -0
  779. package/dist/tools/index.js +5 -0
  780. package/dist/tools/index.js.map +1 -0
  781. package/dist/tools/output.d.ts +50 -0
  782. package/dist/tools/output.d.ts.map +1 -0
  783. package/dist/tools/output.js +78 -0
  784. package/dist/tools/output.js.map +1 -0
  785. package/dist/tools/output.test.d.ts +8 -0
  786. package/dist/tools/output.test.d.ts.map +1 -0
  787. package/dist/tools/output.test.js +120 -0
  788. package/dist/tools/output.test.js.map +1 -0
  789. package/dist/tools/parse-pdf/deps.d.ts +42 -0
  790. package/dist/tools/parse-pdf/deps.d.ts.map +1 -0
  791. package/dist/tools/parse-pdf/deps.js +8 -0
  792. package/dist/tools/parse-pdf/deps.js.map +1 -0
  793. package/dist/tools/parse-pdf/index.d.ts +18 -0
  794. package/dist/tools/parse-pdf/index.d.ts.map +1 -0
  795. package/dist/tools/parse-pdf/index.js +160 -0
  796. package/dist/tools/parse-pdf/index.js.map +1 -0
  797. package/dist/tools/parse-pdf/index.test.d.ts +8 -0
  798. package/dist/tools/parse-pdf/index.test.d.ts.map +1 -0
  799. package/dist/tools/parse-pdf/index.test.js +183 -0
  800. package/dist/tools/parse-pdf/index.test.js.map +1 -0
  801. package/dist/tools/types.d.ts +12 -0
  802. package/dist/tools/types.d.ts.map +1 -0
  803. package/dist/tools/types.js +5 -0
  804. package/dist/tools/types.js.map +1 -0
  805. package/dist/utils/convex-error.d.ts +19 -0
  806. package/dist/utils/convex-error.d.ts.map +1 -0
  807. package/dist/utils/convex-error.js +38 -0
  808. package/dist/utils/convex-error.js.map +1 -0
  809. package/dist/utils/convex-error.test.d.ts +7 -0
  810. package/dist/utils/convex-error.test.d.ts.map +1 -0
  811. package/dist/utils/convex-error.test.js +71 -0
  812. package/dist/utils/convex-error.test.js.map +1 -0
  813. package/dist/utils/error-formatting.d.ts +33 -0
  814. package/dist/utils/error-formatting.d.ts.map +1 -0
  815. package/dist/utils/error-formatting.js +96 -0
  816. package/dist/utils/error-formatting.js.map +1 -0
  817. package/dist/utils/file-content.d.ts +24 -0
  818. package/dist/utils/file-content.d.ts.map +1 -0
  819. package/dist/utils/file-content.js +35 -0
  820. package/dist/utils/file-content.js.map +1 -0
  821. package/dist/utils/serialization/decode/index.d.ts +71 -0
  822. package/dist/utils/serialization/decode/index.d.ts.map +1 -0
  823. package/dist/utils/serialization/decode/index.js +167 -0
  824. package/dist/utils/serialization/decode/index.js.map +1 -0
  825. package/dist/utils/serialization/decode/index.test.d.ts +5 -0
  826. package/dist/utils/serialization/decode/index.test.d.ts.map +1 -0
  827. package/dist/utils/serialization/decode/index.test.js +226 -0
  828. package/dist/utils/serialization/decode/index.test.js.map +1 -0
  829. package/dist/utils/stdin.d.ts +6 -0
  830. package/dist/utils/stdin.d.ts.map +1 -0
  831. package/dist/utils/stdin.js +19 -0
  832. package/dist/utils/stdin.js.map +1 -0
  833. package/dist/utils/terminal-safety.d.ts +7 -0
  834. package/dist/utils/terminal-safety.d.ts.map +1 -0
  835. package/dist/utils/terminal-safety.js +17 -0
  836. package/dist/utils/terminal-safety.js.map +1 -0
  837. package/dist/version.d.ts +14 -0
  838. package/dist/version.d.ts.map +1 -0
  839. package/dist/version.js +43 -0
  840. package/dist/version.js.map +1 -0
  841. package/package.json +2 -2
@@ -0,0 +1,225 @@
1
+ /**
2
+ * OpenCodeAgentService — concrete RemoteAgentService for the OpenCode runtime.
3
+ *
4
+ * Encapsulates all interactions with OpenCode: installation detection,
5
+ * version queries, model discovery, agent spawning, and process lifecycle.
6
+ *
7
+ * Spawns agents using:
8
+ * opencode run --format json --print-logs [--model <model>]
9
+ *
10
+ * The prompt is sent over stdin. OpenCode streams JSON events on stdout,
11
+ * parsed by OpenCodeJsonReader. Text events are buffered per-line and
12
+ * emitted with [oc:role text] prefixes so PM2 / daemon logs capture them.
13
+ * step_finish with reason "stop" triggers onAgentEnd.
14
+ *
15
+ * Extends BaseCLIAgentService which handles all shared boilerplate:
16
+ * process registry, stop/isAlive/getTrackedProcesses/untrack, and
17
+ * the underlying isInstalled/getVersion helpers.
18
+ */
19
+ import { createInterface } from 'node:readline';
20
+ import { BaseCLIAgentService } from '../base-cli-agent-service.js';
21
+ import { OpenCodeJsonReader } from './opencode-json-reader.js';
22
+ // ─── Constants ────────────────────────────────────────────────────────────────
23
+ const OPENCODE_COMMAND = 'opencode';
24
+ // ─── Implementation ──────────────────────────────────────────────────────────
25
+ export class OpenCodeAgentService extends BaseCLIAgentService {
26
+ id = 'opencode';
27
+ displayName = 'OpenCode';
28
+ command = OPENCODE_COMMAND;
29
+ constructor(deps) {
30
+ super(deps);
31
+ }
32
+ isInstalled() {
33
+ return this.checkInstalled(OPENCODE_COMMAND);
34
+ }
35
+ getVersion() {
36
+ return this.checkVersion(OPENCODE_COMMAND);
37
+ }
38
+ async listModels() {
39
+ try {
40
+ const output = this.deps
41
+ .execSync(`${OPENCODE_COMMAND} models`, {
42
+ stdio: ['pipe', 'pipe', 'pipe'],
43
+ timeout: 10000,
44
+ })
45
+ .toString()
46
+ .trim();
47
+ if (!output)
48
+ return [];
49
+ return output
50
+ .split('\n')
51
+ .map((line) => line.trim())
52
+ .filter((line) => line.length > 0);
53
+ }
54
+ catch {
55
+ return [];
56
+ }
57
+ }
58
+ async spawn(options) {
59
+ const args = ['run', '--format', 'json', '--print-logs'];
60
+ if (options.model) {
61
+ args.push('--model', options.model);
62
+ }
63
+ // Combine systemPrompt and prompt — opencode doesn't have a --system-prompt flag,
64
+ // so we prepend the role prompt to the initial message as a single combined prompt.
65
+ const fullPrompt = options.systemPrompt
66
+ ? `${options.systemPrompt}\n\n${options.prompt}`
67
+ : options.prompt;
68
+ const childProcess = this.deps.spawn(OPENCODE_COMMAND, args, {
69
+ cwd: options.workingDir,
70
+ stdio: ['pipe', 'pipe', 'pipe'],
71
+ shell: false,
72
+ detached: true,
73
+ env: {
74
+ ...process.env,
75
+ // Prevent git rebase/merge from opening an interactive editor
76
+ GIT_EDITOR: 'true',
77
+ GIT_SEQUENCE_EDITOR: 'true',
78
+ },
79
+ });
80
+ // Write combined prompt to stdin
81
+ childProcess.stdin?.write(fullPrompt);
82
+ childProcess.stdin?.end();
83
+ // Wait briefly for immediate crash detection
84
+ await new Promise((resolve) => setTimeout(resolve, 500));
85
+ if (childProcess.killed || childProcess.exitCode !== null) {
86
+ throw new Error(`Agent process exited immediately (exit code: ${childProcess.exitCode})`);
87
+ }
88
+ if (!childProcess.pid) {
89
+ throw new Error('Agent process started but has no PID');
90
+ }
91
+ const pid = childProcess.pid;
92
+ const context = options.context;
93
+ // Register in process registry
94
+ const entry = this.registerProcess(pid, context);
95
+ // Build a log prefix from spawn context for easier debugging.
96
+ // Format: [oc:role] or [oc:role@short-id] when chatroomId is available.
97
+ const roleTag = context.role ?? 'unknown';
98
+ const chatroomSuffix = context.chatroomId ? `@${context.chatroomId.slice(-6)}` : '';
99
+ const logPrefix = `[oc:${roleTag}${chatroomSuffix}`;
100
+ // Output tracking callbacks (for external consumers) + internal timestamp update
101
+ const outputCallbacks = [];
102
+ if (childProcess.stdout) {
103
+ // Parse the JSON event stream — fire output callbacks on every event
104
+ // so the daemon knows the agent is still producing output.
105
+ const reader = new OpenCodeJsonReader(childProcess.stdout);
106
+ // Buffer accumulated text so we can emit complete lines with
107
+ // an [oc:role text] prefix — PM2 captures output per-line, so
108
+ // raw streaming tokens without newlines don't appear as distinct log entries.
109
+ let textBuffer = '';
110
+ const flushText = () => {
111
+ if (!textBuffer)
112
+ return;
113
+ for (const line of textBuffer.split('\n')) {
114
+ if (line)
115
+ process.stdout.write(`${logPrefix} text] ${line}\n`);
116
+ }
117
+ textBuffer = '';
118
+ };
119
+ reader.onText((text) => {
120
+ textBuffer += text;
121
+ // Always flush — OpenCode delivers full text per event (not streaming deltas)
122
+ flushText();
123
+ entry.lastOutputAt = Date.now();
124
+ for (const cb of outputCallbacks)
125
+ cb();
126
+ });
127
+ reader.onToolUse((part) => {
128
+ flushText();
129
+ const toolName = typeof part['tool'] === 'string' ? part['tool'] : 'unknown';
130
+ const state = part['state'];
131
+ const input = state?.['input'];
132
+ const output = state?.['output'];
133
+ // Log tool name and input summary
134
+ if (input && typeof input === 'object') {
135
+ const inputStr = JSON.stringify(input);
136
+ const truncated = inputStr.length > 200 ? inputStr.slice(0, 200) + '...' : inputStr;
137
+ process.stdout.write(`${logPrefix} tool: ${toolName} input: ${truncated}]\n`);
138
+ }
139
+ else {
140
+ process.stdout.write(`${logPrefix} tool: ${toolName}]\n`);
141
+ }
142
+ // Log tool output if available (truncated for readability)
143
+ if (output && typeof output === 'string') {
144
+ const truncated = output.length > 500 ? output.slice(0, 500) + '...' : output;
145
+ for (const line of truncated.split('\n')) {
146
+ if (line)
147
+ process.stdout.write(`${logPrefix} tool_output] ${line}\n`);
148
+ }
149
+ }
150
+ entry.lastOutputAt = Date.now();
151
+ for (const cb of outputCallbacks)
152
+ cb();
153
+ });
154
+ reader.onAnyEvent(() => {
155
+ // All events count as activity for output timestamp purposes.
156
+ entry.lastOutputAt = Date.now();
157
+ for (const cb of outputCallbacks)
158
+ cb();
159
+ });
160
+ reader.onStepStart(() => {
161
+ process.stdout.write(`${logPrefix} step_start]\n`);
162
+ });
163
+ reader.onStepFinish((reason) => {
164
+ process.stdout.write(`${logPrefix} step_finish: ${reason}]\n`);
165
+ });
166
+ reader.onAgentEnd(() => {
167
+ // Flush any buffered text before the turn boundary marker
168
+ flushText();
169
+ process.stdout.write(`${logPrefix} agent_end]\n`);
170
+ });
171
+ if (childProcess.stderr) {
172
+ // Parse stderr line-by-line so we can prefix each line with the agent tag
173
+ // for consistent daemon log formatting (--print-logs sends debug output here).
174
+ const stderrRl = createInterface({ input: childProcess.stderr, crlfDelay: Infinity });
175
+ stderrRl.on('line', (line) => {
176
+ if (line.trim()) {
177
+ process.stdout.write(`${logPrefix} log] ${line}\n`);
178
+ }
179
+ entry.lastOutputAt = Date.now();
180
+ for (const cb of outputCallbacks)
181
+ cb();
182
+ });
183
+ }
184
+ return {
185
+ pid,
186
+ onExit: (cb) => {
187
+ childProcess.on('exit', (code, signal) => {
188
+ this.deleteProcess(pid);
189
+ cb({ code, signal, context });
190
+ });
191
+ },
192
+ onOutput: (cb) => {
193
+ outputCallbacks.push(cb);
194
+ },
195
+ onAgentEnd: (cb) => {
196
+ reader.onAgentEnd(cb);
197
+ },
198
+ };
199
+ }
200
+ if (childProcess.stderr) {
201
+ const stderrRl = createInterface({ input: childProcess.stderr, crlfDelay: Infinity });
202
+ stderrRl.on('line', (line) => {
203
+ if (line.trim()) {
204
+ process.stdout.write(`${logPrefix} log] ${line}\n`);
205
+ }
206
+ entry.lastOutputAt = Date.now();
207
+ for (const cb of outputCallbacks)
208
+ cb();
209
+ });
210
+ }
211
+ return {
212
+ pid,
213
+ onExit: (cb) => {
214
+ childProcess.on('exit', (code, signal) => {
215
+ this.deleteProcess(pid);
216
+ cb({ code, signal, context });
217
+ });
218
+ },
219
+ onOutput: (cb) => {
220
+ outputCallbacks.push(cb);
221
+ },
222
+ };
223
+ }
224
+ }
225
+ //# sourceMappingURL=opencode-agent-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode-agent-service.js","sourceRoot":"","sources":["../../../../../src/infrastructure/services/remote-agents/opencode/opencode-agent-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,mBAAmB,EAA4B,MAAM,8BAA8B,CAAC;AAE7F,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAI/D,iFAAiF;AAEjF,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAEpC,gFAAgF;AAEhF,MAAM,OAAO,oBAAqB,SAAQ,mBAAmB;IAClD,EAAE,GAAG,UAAU,CAAC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GAAG,EAAE,CAAC;gBAChC,KAAK,MAAM,EAAE,IAAI,eAAe;oBAAE,EAAE,EAAE,CAAC;YACzC,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO;YACL,GAAG;YACH,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE;gBACb,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;oBACvC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;oBACxB,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;gBAChC,CAAC,CAAC,CAAC;YACL,CAAC;YACD,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE;gBACf,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC3B,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=opencode-agent-service.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode-agent-service.test.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/services/remote-agents/opencode/opencode-agent-service.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,226 @@
1
+ import { EventEmitter, Readable } from 'node:stream';
2
+ import { describe, expect, it, vi } from 'vitest';
3
+ import { OpenCodeAgentService } from './opencode-agent-service.js';
4
+ function createMockDeps(overrides) {
5
+ return {
6
+ execSync: vi.fn(),
7
+ spawn: vi.fn(),
8
+ kill: vi.fn(),
9
+ ...overrides,
10
+ };
11
+ }
12
+ describe('OpenCodeAgentService', () => {
13
+ describe('isInstalled', () => {
14
+ it('returns true when opencode command exists', () => {
15
+ const deps = createMockDeps({
16
+ execSync: vi.fn(),
17
+ });
18
+ const service = new OpenCodeAgentService(deps);
19
+ expect(service.isInstalled()).toBe(true);
20
+ });
21
+ it('returns false when opencode command is missing', () => {
22
+ const deps = createMockDeps({
23
+ execSync: vi.fn(() => {
24
+ throw new Error('not found');
25
+ }),
26
+ });
27
+ const service = new OpenCodeAgentService(deps);
28
+ expect(service.isInstalled()).toBe(false);
29
+ });
30
+ });
31
+ describe('getVersion', () => {
32
+ it('parses semantic version from opencode --version output', () => {
33
+ const deps = createMockDeps({
34
+ execSync: vi.fn().mockReturnValue(Buffer.from('v0.2.15')),
35
+ });
36
+ const service = new OpenCodeAgentService(deps);
37
+ expect(service.getVersion()).toEqual({ version: '0.2.15', major: 0 });
38
+ });
39
+ it('parses version without v prefix', () => {
40
+ const deps = createMockDeps({
41
+ execSync: vi.fn().mockReturnValue(Buffer.from('1.0.3')),
42
+ });
43
+ const service = new OpenCodeAgentService(deps);
44
+ expect(service.getVersion()).toEqual({ version: '1.0.3', major: 1 });
45
+ });
46
+ it('returns null when version cannot be parsed', () => {
47
+ const deps = createMockDeps({
48
+ execSync: vi.fn().mockReturnValue(Buffer.from('unknown')),
49
+ });
50
+ const service = new OpenCodeAgentService(deps);
51
+ expect(service.getVersion()).toBeNull();
52
+ });
53
+ it('returns null when command fails', () => {
54
+ const deps = createMockDeps({
55
+ execSync: vi.fn(() => {
56
+ throw new Error('command not found');
57
+ }),
58
+ });
59
+ const service = new OpenCodeAgentService(deps);
60
+ expect(service.getVersion()).toBeNull();
61
+ });
62
+ });
63
+ describe('listModels', () => {
64
+ it('returns parsed model list', async () => {
65
+ const deps = createMockDeps({
66
+ execSync: vi
67
+ .fn()
68
+ .mockReturnValue(Buffer.from('anthropic/claude-3.5-sonnet\nopenai/gpt-4o\n')),
69
+ });
70
+ const service = new OpenCodeAgentService(deps);
71
+ const models = await service.listModels();
72
+ expect(models).toEqual(['anthropic/claude-3.5-sonnet', 'openai/gpt-4o']);
73
+ });
74
+ it('returns empty array when output is empty', async () => {
75
+ const deps = createMockDeps({
76
+ execSync: vi.fn().mockReturnValue(Buffer.from('')),
77
+ });
78
+ const service = new OpenCodeAgentService(deps);
79
+ expect(await service.listModels()).toEqual([]);
80
+ });
81
+ it('returns empty array when command fails', async () => {
82
+ const deps = createMockDeps({
83
+ execSync: vi.fn(() => {
84
+ throw new Error('failed');
85
+ }),
86
+ });
87
+ const service = new OpenCodeAgentService(deps);
88
+ expect(await service.listModels()).toEqual([]);
89
+ });
90
+ it('filters blank lines from output', async () => {
91
+ const deps = createMockDeps({
92
+ execSync: vi.fn().mockReturnValue(Buffer.from('model/a\n\n \nmodel/b\n')),
93
+ });
94
+ const service = new OpenCodeAgentService(deps);
95
+ expect(await service.listModels()).toEqual(['model/a', 'model/b']);
96
+ });
97
+ });
98
+ describe('isAlive', () => {
99
+ it('returns true when process is alive', () => {
100
+ const deps = createMockDeps({ kill: vi.fn() });
101
+ const service = new OpenCodeAgentService(deps);
102
+ expect(service.isAlive(1234)).toBe(true);
103
+ expect(deps.kill).toHaveBeenCalledWith(1234, 0);
104
+ });
105
+ it('returns false when process is dead', () => {
106
+ const deps = createMockDeps({
107
+ kill: vi.fn(() => {
108
+ throw new Error('ESRCH');
109
+ }),
110
+ });
111
+ const service = new OpenCodeAgentService(deps);
112
+ expect(service.isAlive(1234)).toBe(false);
113
+ });
114
+ });
115
+ describe('stop', () => {
116
+ it('sends SIGTERM to process group then returns when process exits', async () => {
117
+ const kill = vi
118
+ .fn()
119
+ .mockImplementationOnce(() => { }) // SIGTERM to -pid
120
+ .mockImplementationOnce(() => {
121
+ // kill(pid, 0) check
122
+ throw new Error('ESRCH');
123
+ });
124
+ const deps = createMockDeps({ kill });
125
+ const service = new OpenCodeAgentService(deps);
126
+ await service.stop(1234);
127
+ expect(kill).toHaveBeenCalledWith(-1234, 'SIGTERM');
128
+ });
129
+ it('returns immediately if process is already dead', async () => {
130
+ const kill = vi.fn().mockImplementationOnce(() => {
131
+ throw new Error('ESRCH');
132
+ });
133
+ const deps = createMockDeps({ kill });
134
+ const service = new OpenCodeAgentService(deps);
135
+ await service.stop(1234);
136
+ expect(kill).toHaveBeenCalledWith(-1234, 'SIGTERM');
137
+ expect(kill).toHaveBeenCalledTimes(1);
138
+ });
139
+ });
140
+ describe('spawn', () => {
141
+ it('spawns process with correct arguments', async () => {
142
+ const mockStdin = { write: vi.fn(), end: vi.fn() };
143
+ const mockStdout = new Readable({ read() { } });
144
+ const mockStderr = new Readable({ read() { } });
145
+ const mockChild = Object.assign(new EventEmitter(), {
146
+ stdin: mockStdin,
147
+ stdout: mockStdout,
148
+ stderr: mockStderr,
149
+ pid: 42,
150
+ killed: false,
151
+ exitCode: null,
152
+ });
153
+ // Pipe needs the target to be a writable stream, mock it
154
+ mockStdout.pipe = vi.fn().mockReturnValue(mockStdout);
155
+ mockStderr.pipe = vi.fn().mockReturnValue(mockStderr);
156
+ const spawnFn = vi.fn().mockReturnValue(mockChild);
157
+ const deps = createMockDeps({ spawn: spawnFn });
158
+ const service = new OpenCodeAgentService(deps);
159
+ const result = await service.spawn({
160
+ workingDir: '/tmp/test',
161
+ prompt: 'Hello agent',
162
+ systemPrompt: 'You are a test agent',
163
+ model: 'anthropic/claude-3.5-sonnet',
164
+ context: { machineId: 'test-machine', chatroomId: 'test-chatroom', role: 'test-role' },
165
+ });
166
+ expect(spawnFn).toHaveBeenCalledWith('opencode', ['run', '--format', 'json', '--print-logs', '--model', 'anthropic/claude-3.5-sonnet'], expect.objectContaining({
167
+ cwd: '/tmp/test',
168
+ stdio: ['pipe', 'pipe', 'pipe'],
169
+ shell: false,
170
+ detached: true,
171
+ }));
172
+ expect(mockStdin.write).toHaveBeenCalledWith('You are a test agent\n\nHello agent');
173
+ expect(mockStdin.end).toHaveBeenCalled();
174
+ expect(result.pid).toBe(42);
175
+ expect(typeof result.onExit).toBe('function');
176
+ expect(typeof result.onOutput).toBe('function');
177
+ expect(typeof result.onAgentEnd).toBe('function');
178
+ });
179
+ it('spawns without --model flag when model is not specified', async () => {
180
+ const mockStdin = { write: vi.fn(), end: vi.fn() };
181
+ const mockStdout = new Readable({ read() { } });
182
+ const mockStderr = new Readable({ read() { } });
183
+ const mockChild = Object.assign(new EventEmitter(), {
184
+ stdin: mockStdin,
185
+ stdout: mockStdout,
186
+ stderr: mockStderr,
187
+ pid: 99,
188
+ killed: false,
189
+ exitCode: null,
190
+ });
191
+ mockStdout.pipe = vi.fn().mockReturnValue(mockStdout);
192
+ mockStderr.pipe = vi.fn().mockReturnValue(mockStderr);
193
+ const spawnFn = vi.fn().mockReturnValue(mockChild);
194
+ const deps = createMockDeps({ spawn: spawnFn });
195
+ const service = new OpenCodeAgentService(deps);
196
+ await service.spawn({
197
+ workingDir: '/tmp',
198
+ prompt: 'test',
199
+ systemPrompt: 'test system prompt',
200
+ context: { machineId: 'test-machine', chatroomId: 'test-chatroom', role: 'test-role' },
201
+ });
202
+ expect(spawnFn).toHaveBeenCalledWith('opencode', ['run', '--format', 'json', '--print-logs'], expect.any(Object));
203
+ });
204
+ it('throws when process exits immediately', async () => {
205
+ const mockStdin = { write: vi.fn(), end: vi.fn() };
206
+ const mockChild = Object.assign(new EventEmitter(), {
207
+ stdin: mockStdin,
208
+ stdout: null,
209
+ stderr: null,
210
+ pid: 1,
211
+ killed: false,
212
+ exitCode: 1,
213
+ });
214
+ const spawnFn = vi.fn().mockReturnValue(mockChild);
215
+ const deps = createMockDeps({ spawn: spawnFn });
216
+ const service = new OpenCodeAgentService(deps);
217
+ await expect(service.spawn({
218
+ workingDir: '/tmp',
219
+ prompt: 'test',
220
+ systemPrompt: 'test system prompt',
221
+ context: { machineId: 'test-machine', chatroomId: 'test-chatroom', role: 'test-role' },
222
+ })).rejects.toThrow('exited immediately');
223
+ });
224
+ });
225
+ });
226
+ //# sourceMappingURL=opencode-agent-service.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode-agent-service.test.js","sourceRoot":"","sources":["../../../../../src/infrastructure/services/remote-agents/opencode/opencode-agent-service.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,Q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H,CAAC,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * OpenCodeJsonReader — parses the newline-delimited JSON event stream emitted by
3
+ * `opencode run --format json` on stdout and surfaces typed callbacks for each event type.
4
+ *
5
+ * OpenCode JSON protocol (stdout, one JSON object per line):
6
+ *
7
+ * step_start – { type: "step_start", part: { type: "step-start" } }
8
+ * text – { type: "text", part: { type: "text", text: "Hello." } }
9
+ * tool_use – { type: "tool_use", part: { type: "tool" } }
10
+ * step_finish – { type: "step_finish", part: { type: "step-finish", reason: "stop" | "tool-calls" } }
11
+ *
12
+ * Key: step_finish with part.reason === "stop" means the agent turn is complete (= onAgentEnd).
13
+ *
14
+ * Note: Non-JSON lines (ANSI banner, log lines) may appear on stdout and are ignored gracefully.
15
+ */
16
+ import type { Readable } from 'node:stream';
17
+ type TextCallback = (text: string) => void;
18
+ type ToolUseCallback = (part: Record<string, unknown>) => void;
19
+ type StepStartCallback = () => void;
20
+ type StepFinishCallback = (reason: string) => void;
21
+ type AgentEndCallback = () => void;
22
+ type AnyEventCallback = () => void;
23
+ export declare class OpenCodeJsonReader {
24
+ private readonly textCallbacks;
25
+ private readonly toolUseCallbacks;
26
+ private readonly stepStartCallbacks;
27
+ private readonly stepFinishCallbacks;
28
+ private readonly agentEndCallbacks;
29
+ private readonly anyEventCallbacks;
30
+ constructor(stream: Readable);
31
+ /** Fires when a text event is received with the full text content. */
32
+ onText(cb: TextCallback): void;
33
+ /** Fires when a tool_use event is received. */
34
+ onToolUse(cb: ToolUseCallback): void;
35
+ /** Fires when a step_start event is received. */
36
+ onStepStart(cb: StepStartCallback): void;
37
+ /** Fires when a step_finish event is received, with the reason. */
38
+ onStepFinish(cb: StepFinishCallback): void;
39
+ /** Fires when the agent completes a turn (step_finish with reason "stop"). */
40
+ onAgentEnd(cb: AgentEndCallback): void;
41
+ /** Fires for every successfully parsed event, regardless of type. */
42
+ onAnyEvent(cb: AnyEventCallback): void;
43
+ private _handleLine;
44
+ }
45
+ export {};
46
+ //# sourceMappingURL=opencode-json-reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode-json-reader.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/services/remote-agents/opencode/opencode-json-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C,KAAK,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;AAC3C,KAAK,eAAe,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;AAC/D,KAAK,iBAAiB,GAAG,MAAM,IAAI,CAAC;AACpC,KAAK,kBAAkB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;AACnD,KAAK,gBAAgB,GAAG,MAAM,IAAI,CAAC;AACnC,KAAK,gBAAgB,GAAG,MAAM,IAAI,CAAC;AAInC,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAsB;IACpD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAyB;IAC1D,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA2B;IAC9D,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAA4B;IAChE,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA0B;IAC5D,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA0B;gBAEhD,MAAM,EAAE,QAAQ;IAK5B,sEAAsE;IACtE,MAAM,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI;IAI9B,+CAA+C;IAC/C,SAAS,CAAC,EAAE,EAAE,eAAe,GAAG,IAAI;IAIpC,iDAAiD;IACjD,WAAW,CAAC,EAAE,EAAE,iBAAiB,GAAG,IAAI;IAIxC,mEAAmE;IACnE,YAAY,CAAC,EAAE,EAAE,kBAAkB,GAAG,IAAI;IAI1C,8EAA8E;IAC9E,UAAU,CAAC,EAAE,EAAE,gBAAgB,GAAG,IAAI;IAItC,qEAAqE;IACrE,UAAU,CAAC,EAAE,EAAE,gBAAgB,GAAG,IAAI;IAMtC,OAAO,CAAC,WAAW;CAmDpB"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * OpenCodeJsonReader — parses the newline-delimited JSON event stream emitted by
3
+ * `opencode run --format json` on stdout and surfaces typed callbacks for each event type.
4
+ *
5
+ * OpenCode JSON protocol (stdout, one JSON object per line):
6
+ *
7
+ * step_start – { type: "step_start", part: { type: "step-start" } }
8
+ * text – { type: "text", part: { type: "text", text: "Hello." } }
9
+ * tool_use – { type: "tool_use", part: { type: "tool" } }
10
+ * step_finish – { type: "step_finish", part: { type: "step-finish", reason: "stop" | "tool-calls" } }
11
+ *
12
+ * Key: step_finish with part.reason === "stop" means the agent turn is complete (= onAgentEnd).
13
+ *
14
+ * Note: Non-JSON lines (ANSI banner, log lines) may appear on stdout and are ignored gracefully.
15
+ */
16
+ import { createInterface } from 'node:readline';
17
+ // ─── Implementation ───────────────────────────────────────────────────────────
18
+ export class OpenCodeJsonReader {
19
+ textCallbacks = [];
20
+ toolUseCallbacks = [];
21
+ stepStartCallbacks = [];
22
+ stepFinishCallbacks = [];
23
+ agentEndCallbacks = [];
24
+ anyEventCallbacks = [];
25
+ constructor(stream) {
26
+ const rl = createInterface({ input: stream, crlfDelay: Infinity });
27
+ rl.on('line', (line) => this._handleLine(line));
28
+ }
29
+ /** Fires when a text event is received with the full text content. */
30
+ onText(cb) {
31
+ this.textCallbacks.push(cb);
32
+ }
33
+ /** Fires when a tool_use event is received. */
34
+ onToolUse(cb) {
35
+ this.toolUseCallbacks.push(cb);
36
+ }
37
+ /** Fires when a step_start event is received. */
38
+ onStepStart(cb) {
39
+ this.stepStartCallbacks.push(cb);
40
+ }
41
+ /** Fires when a step_finish event is received, with the reason. */
42
+ onStepFinish(cb) {
43
+ this.stepFinishCallbacks.push(cb);
44
+ }
45
+ /** Fires when the agent completes a turn (step_finish with reason "stop"). */
46
+ onAgentEnd(cb) {
47
+ this.agentEndCallbacks.push(cb);
48
+ }
49
+ /** Fires for every successfully parsed event, regardless of type. */
50
+ onAnyEvent(cb) {
51
+ this.anyEventCallbacks.push(cb);
52
+ }
53
+ // ─── Private ───────────────────────────────────────────────────────────────
54
+ _handleLine(line) {
55
+ const trimmed = line.trim();
56
+ if (!trimmed)
57
+ return;
58
+ let event;
59
+ try {
60
+ event = JSON.parse(trimmed);
61
+ }
62
+ catch {
63
+ // Non-JSON line (e.g. ANSI banner, log line) — ignore silently
64
+ return;
65
+ }
66
+ // Fire any-event callbacks first
67
+ for (const cb of this.anyEventCallbacks)
68
+ cb();
69
+ const type = event['type'];
70
+ if (type === 'text') {
71
+ const part = event['part'];
72
+ if (part && typeof part['text'] === 'string') {
73
+ for (const cb of this.textCallbacks)
74
+ cb(part['text']);
75
+ }
76
+ return;
77
+ }
78
+ if (type === 'tool_use') {
79
+ const part = event['part'] ?? {};
80
+ for (const cb of this.toolUseCallbacks)
81
+ cb(part);
82
+ return;
83
+ }
84
+ if (type === 'step_start') {
85
+ for (const cb of this.stepStartCallbacks)
86
+ cb();
87
+ return;
88
+ }
89
+ if (type === 'step_finish') {
90
+ const part = event['part'];
91
+ const reason = typeof part?.['reason'] === 'string' ? part['reason'] : '';
92
+ for (const cb of this.stepFinishCallbacks)
93
+ cb(reason);
94
+ if (reason === 'stop') {
95
+ for (const cb of this.agentEndCallbacks)
96
+ cb();
97
+ }
98
+ return;
99
+ }
100
+ // All other event types (step_start, etc.) are silently accepted —
101
+ // anyEventCallbacks already fired above.
102
+ }
103
+ }
104
+ //# sourceMappingURL=opencode-json-reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencode-json-reader.js","sourceRoot":"","sources":["../../../../../src/infrastructure/services/remote-agents/openc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