agent-relay 2.3.14 → 2.3.16

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 (1420) hide show
  1. package/README.md +42 -176
  2. package/bin/agent-relay-broker-darwin-arm64 +0 -0
  3. package/bin/agent-relay-broker-darwin-x64 +0 -0
  4. package/bin/agent-relay-broker-linux-arm64 +0 -0
  5. package/bin/agent-relay-broker-linux-x64 +0 -0
  6. package/dist/index.cjs +50319 -63390
  7. package/dist/src/cli/bootstrap.d.ts +6 -0
  8. package/dist/src/cli/bootstrap.d.ts.map +1 -0
  9. package/dist/src/cli/bootstrap.js +109 -0
  10. package/dist/src/cli/bootstrap.js.map +1 -0
  11. package/dist/src/cli/commands/agent-management.d.ts +51 -0
  12. package/dist/src/cli/commands/agent-management.d.ts.map +1 -0
  13. package/dist/src/cli/commands/agent-management.js +290 -0
  14. package/dist/src/cli/commands/agent-management.js.map +1 -0
  15. package/dist/src/cli/commands/auth.d.ts +9 -0
  16. package/dist/src/cli/commands/auth.d.ts.map +1 -0
  17. package/dist/src/cli/commands/auth.js +33 -0
  18. package/dist/src/cli/commands/auth.js.map +1 -0
  19. package/dist/src/cli/commands/cloud.d.ts +18 -0
  20. package/dist/src/cli/commands/cloud.d.ts.map +1 -0
  21. package/dist/src/cli/commands/cloud.js +392 -0
  22. package/dist/src/cli/commands/cloud.js.map +1 -0
  23. package/dist/src/cli/commands/core.d.ts +107 -0
  24. package/dist/src/cli/commands/core.d.ts.map +1 -0
  25. package/dist/src/cli/commands/core.js +299 -0
  26. package/dist/src/cli/commands/core.js.map +1 -0
  27. package/dist/src/cli/commands/doctor.d.ts +1 -1
  28. package/dist/src/cli/commands/doctor.d.ts.map +1 -1
  29. package/dist/src/cli/commands/doctor.js +1 -485
  30. package/dist/src/cli/commands/doctor.js.map +1 -1
  31. package/dist/src/cli/commands/messaging.d.ts +61 -0
  32. package/dist/src/cli/commands/messaging.d.ts.map +1 -0
  33. package/dist/src/cli/commands/messaging.js +213 -0
  34. package/dist/src/cli/commands/messaging.js.map +1 -0
  35. package/dist/src/cli/commands/monitoring.d.ts +57 -0
  36. package/dist/src/cli/commands/monitoring.d.ts.map +1 -0
  37. package/dist/src/cli/commands/monitoring.js +350 -0
  38. package/dist/src/cli/commands/monitoring.js.map +1 -0
  39. package/dist/src/cli/commands/setup.d.ts +29 -0
  40. package/dist/src/cli/commands/setup.d.ts.map +1 -0
  41. package/dist/src/cli/commands/setup.js +324 -0
  42. package/dist/src/cli/commands/setup.js.map +1 -0
  43. package/dist/src/cli/commands/swarm.d.ts +3 -0
  44. package/dist/src/cli/commands/swarm.d.ts.map +1 -0
  45. package/dist/src/cli/commands/swarm.js +108 -0
  46. package/dist/src/cli/commands/swarm.js.map +1 -0
  47. package/dist/src/cli/index.d.ts +1 -28
  48. package/dist/src/cli/index.d.ts.map +1 -1
  49. package/dist/src/cli/index.js +4 -4936
  50. package/dist/src/cli/index.js.map +1 -1
  51. package/dist/src/cli/lib/agent-management-listing.d.ts +39 -0
  52. package/dist/src/cli/lib/agent-management-listing.d.ts.map +1 -0
  53. package/dist/src/cli/lib/agent-management-listing.js +253 -0
  54. package/dist/src/cli/lib/agent-management-listing.js.map +1 -0
  55. package/dist/src/cli/lib/auth-ssh.d.ts +48 -0
  56. package/dist/src/cli/lib/auth-ssh.d.ts.map +1 -0
  57. package/dist/src/cli/lib/auth-ssh.js +572 -0
  58. package/dist/src/cli/lib/auth-ssh.js.map +1 -0
  59. package/dist/src/cli/lib/bridge.d.ts +8 -0
  60. package/dist/src/cli/lib/bridge.d.ts.map +1 -0
  61. package/dist/src/cli/lib/bridge.js +100 -0
  62. package/dist/src/cli/lib/bridge.js.map +1 -0
  63. package/dist/src/cli/lib/broker-lifecycle.d.ts +20 -0
  64. package/dist/src/cli/lib/broker-lifecycle.d.ts.map +1 -0
  65. package/dist/src/cli/lib/broker-lifecycle.js +843 -0
  66. package/dist/src/cli/lib/broker-lifecycle.js.map +1 -0
  67. package/dist/src/cli/lib/client-factory.d.ts +24 -0
  68. package/dist/src/cli/lib/client-factory.d.ts.map +1 -0
  69. package/dist/src/cli/lib/client-factory.js +20 -0
  70. package/dist/src/cli/lib/client-factory.js.map +1 -0
  71. package/dist/src/cli/lib/cloud-client.d.ts +39 -0
  72. package/dist/src/cli/lib/cloud-client.d.ts.map +1 -0
  73. package/dist/src/cli/lib/cloud-client.js +120 -0
  74. package/dist/src/cli/lib/cloud-client.js.map +1 -0
  75. package/dist/src/cli/lib/core-maintenance.d.ts +13 -0
  76. package/dist/src/cli/lib/core-maintenance.d.ts.map +1 -0
  77. package/dist/src/cli/lib/core-maintenance.js +250 -0
  78. package/dist/src/cli/lib/core-maintenance.js.map +1 -0
  79. package/dist/src/cli/lib/doctor.d.ts +2 -0
  80. package/dist/src/cli/lib/doctor.d.ts.map +1 -0
  81. package/dist/src/cli/lib/doctor.js +484 -0
  82. package/dist/src/cli/lib/doctor.js.map +1 -0
  83. package/dist/src/cli/lib/formatting.d.ts +8 -0
  84. package/dist/src/cli/lib/formatting.d.ts.map +1 -0
  85. package/dist/src/cli/lib/formatting.js +48 -0
  86. package/dist/src/cli/lib/formatting.js.map +1 -0
  87. package/dist/src/cli/lib/index.d.ts +5 -0
  88. package/dist/src/cli/lib/index.d.ts.map +1 -0
  89. package/dist/src/cli/lib/index.js +5 -0
  90. package/dist/src/cli/lib/index.js.map +1 -0
  91. package/dist/src/cli/lib/jsonc.d.ts +8 -0
  92. package/dist/src/cli/lib/jsonc.d.ts.map +1 -0
  93. package/dist/src/cli/lib/jsonc.js +88 -0
  94. package/dist/src/cli/lib/jsonc.js.map +1 -0
  95. package/dist/src/cli/lib/monitoring-health.d.ts +32 -0
  96. package/dist/src/cli/lib/monitoring-health.d.ts.map +1 -0
  97. package/dist/src/cli/lib/monitoring-health.js +2 -0
  98. package/dist/src/cli/lib/monitoring-health.js.map +1 -0
  99. package/dist/src/cli/lib/paths.d.ts +2 -0
  100. package/dist/src/cli/lib/paths.d.ts.map +1 -0
  101. package/dist/src/cli/lib/paths.js +5 -0
  102. package/dist/src/cli/lib/paths.js.map +1 -0
  103. package/dist/src/index.d.ts +1 -5
  104. package/dist/src/index.d.ts.map +1 -1
  105. package/dist/src/index.js +1 -5
  106. package/dist/src/index.js.map +1 -1
  107. package/install.sh +0 -30
  108. package/package.json +84 -98
  109. package/packages/acp-bridge/README.md +8 -8
  110. package/packages/acp-bridge/dist/acp-agent.d.ts +8 -7
  111. package/packages/acp-bridge/dist/acp-agent.d.ts.map +1 -1
  112. package/packages/acp-bridge/dist/acp-agent.js +118 -143
  113. package/packages/acp-bridge/dist/acp-agent.js.map +1 -1
  114. package/packages/acp-bridge/dist/cli.d.ts +1 -1
  115. package/packages/acp-bridge/dist/cli.js +3 -3
  116. package/packages/acp-bridge/dist/index.d.ts +2 -2
  117. package/packages/acp-bridge/dist/index.d.ts.map +1 -1
  118. package/packages/acp-bridge/dist/index.js +1 -1
  119. package/packages/acp-bridge/dist/index.js.map +1 -1
  120. package/packages/acp-bridge/dist/types.d.ts +3 -3
  121. package/packages/acp-bridge/package.json +3 -3
  122. package/packages/acp-bridge/src/acp-agent.ts +123 -160
  123. package/packages/acp-bridge/src/cli.ts +3 -3
  124. package/packages/acp-bridge/src/index.ts +2 -2
  125. package/packages/acp-bridge/src/types.ts +3 -3
  126. package/packages/config/dist/bridge-config.d.ts +5 -5
  127. package/packages/config/dist/bridge-config.d.ts.map +1 -1
  128. package/packages/config/dist/bridge-config.js +16 -9
  129. package/packages/config/dist/bridge-config.js.map +1 -1
  130. package/packages/config/dist/cli-auth-config.d.ts +1 -1
  131. package/packages/config/dist/cli-auth-config.js +1 -1
  132. package/packages/config/dist/cli-registry.generated.d.ts +340 -0
  133. package/packages/config/dist/cli-registry.generated.d.ts.map +1 -0
  134. package/packages/config/dist/cli-registry.generated.js +297 -0
  135. package/packages/config/dist/cli-registry.generated.js.map +1 -0
  136. package/packages/config/dist/index.d.ts +1 -0
  137. package/packages/config/dist/index.d.ts.map +1 -1
  138. package/packages/config/dist/index.js +1 -0
  139. package/packages/config/dist/index.js.map +1 -1
  140. package/packages/config/dist/project-namespace.d.ts +9 -9
  141. package/packages/config/dist/project-namespace.js +3 -3
  142. package/packages/config/dist/relay-config.d.ts +1 -1
  143. package/packages/config/dist/relay-config.js +1 -1
  144. package/packages/config/dist/schemas.js +1 -1
  145. package/packages/config/dist/shadow-config.d.ts +2 -1
  146. package/packages/config/dist/shadow-config.d.ts.map +1 -1
  147. package/packages/config/dist/shadow-config.js.map +1 -1
  148. package/packages/config/package.json +2 -3
  149. package/packages/config/src/bridge-config.test.ts +20 -6
  150. package/packages/config/src/bridge-config.ts +20 -10
  151. package/packages/config/src/cli-auth-config.ts +1 -1
  152. package/packages/config/src/cli-registry.generated.ts +328 -0
  153. package/packages/config/src/index.ts +1 -0
  154. package/packages/config/src/project-namespace.ts +9 -9
  155. package/packages/config/src/relay-config.ts +1 -1
  156. package/packages/config/src/schemas.ts +1 -1
  157. package/packages/config/src/shadow-config.ts +8 -1
  158. package/packages/contracts/fixtures/error-fixtures.json +42 -0
  159. package/packages/contracts/fixtures/event-fixtures.json +161 -0
  160. package/packages/contracts/fixtures/health-fixtures.json +35 -0
  161. package/packages/contracts/fixtures/identity-fixtures.json +58 -0
  162. package/packages/contracts/fixtures/replay-fixtures.json +33 -0
  163. package/packages/hooks/dist/inbox-check/types.d.ts +2 -2
  164. package/packages/hooks/dist/types.d.ts +9 -3
  165. package/packages/hooks/dist/types.d.ts.map +1 -1
  166. package/packages/hooks/dist/types.js +1 -1
  167. package/packages/hooks/dist/types.js.map +1 -1
  168. package/packages/hooks/package.json +5 -5
  169. package/packages/hooks/src/inbox-check/types.ts +2 -2
  170. package/packages/hooks/src/types.ts +11 -3
  171. package/packages/memory/package.json +2 -2
  172. package/packages/policy/package.json +2 -2
  173. package/packages/sdk/.mcp.json +14 -0
  174. package/packages/sdk/.trajectories/active/traj_1771875803391_84ca57b2.json +50 -0
  175. package/packages/sdk/.trajectories/active/traj_1771891934534_06504121.json +50 -0
  176. package/packages/sdk/.trajectories/active/traj_1771891957929_211afc4e.json +50 -0
  177. package/packages/sdk/.trajectories/active/traj_1771891982509_38c84638.json +50 -0
  178. package/packages/sdk/.trajectories/completed/traj_1771875803188_cd6d181c.json +80 -0
  179. package/packages/sdk/.trajectories/completed/traj_1771875803204_f2aeb8c8.json +80 -0
  180. package/packages/sdk/.trajectories/completed/traj_1771875803210_d65f3f1a.json +80 -0
  181. package/packages/sdk/.trajectories/completed/traj_1771875803218_e454a25d.json +80 -0
  182. package/packages/sdk/.trajectories/completed/traj_1771875803223_d7a64815.json +80 -0
  183. package/packages/sdk/.trajectories/completed/traj_1771875803227_7e56da5b.json +80 -0
  184. package/packages/sdk/.trajectories/completed/traj_1771875803235_4fbf93b4.json +80 -0
  185. package/packages/sdk/.trajectories/completed/traj_1771875803243_47931c71.json +80 -0
  186. package/packages/sdk/.trajectories/completed/traj_1771875803258_3816f3fe.json +80 -0
  187. package/packages/sdk/.trajectories/completed/traj_1771875803268_8061140e.json +80 -0
  188. package/packages/sdk/.trajectories/completed/traj_1771875803326_ae6f9c78.json +80 -0
  189. package/packages/sdk/.trajectories/completed/traj_1771875808396_cbde0a6c.json +91 -0
  190. package/packages/sdk/.trajectories/completed/traj_1771875812026_aa2442bb.json +91 -0
  191. package/packages/sdk/.trajectories/completed/traj_1771875815431_c2c656c5.json +91 -0
  192. package/packages/sdk/.trajectories/completed/traj_1771875818645_3a4dbf02.json +91 -0
  193. package/packages/sdk/.trajectories/completed/traj_1771891934403_24923c03.json +80 -0
  194. package/packages/sdk/.trajectories/completed/traj_1771891934421_dca16e24.json +80 -0
  195. package/packages/sdk/.trajectories/completed/traj_1771891934430_057706f7.json +80 -0
  196. package/packages/sdk/.trajectories/completed/traj_1771891934442_faf97382.json +80 -0
  197. package/packages/sdk/.trajectories/completed/traj_1771891934454_5542ecd5.json +80 -0
  198. package/packages/sdk/.trajectories/completed/traj_1771891934464_12202a08.json +80 -0
  199. package/packages/sdk/.trajectories/completed/traj_1771891934487_94378275.json +80 -0
  200. package/packages/sdk/.trajectories/completed/traj_1771891934503_ca728c13.json +80 -0
  201. package/packages/sdk/.trajectories/completed/traj_1771891934519_100af69a.json +80 -0
  202. package/packages/sdk/.trajectories/completed/traj_1771891934536_62ad39d9.json +80 -0
  203. package/packages/sdk/.trajectories/completed/traj_1771891934553_d6798a52.json +80 -0
  204. package/packages/sdk/.trajectories/completed/traj_1771891939537_541c8096.json +91 -0
  205. package/packages/sdk/.trajectories/completed/traj_1771891942985_36ab9a4d.json +91 -0
  206. package/packages/sdk/.trajectories/completed/traj_1771891946453_e8a6e05f.json +91 -0
  207. package/packages/sdk/.trajectories/completed/traj_1771891949838_5de0de84.json +91 -0
  208. package/packages/sdk/.trajectories/completed/traj_1771891957807_0ecfb4f4.json +80 -0
  209. package/packages/sdk/.trajectories/completed/traj_1771891957827_c4539239.json +80 -0
  210. package/packages/sdk/.trajectories/completed/traj_1771891957836_91168b48.json +80 -0
  211. package/packages/sdk/.trajectories/completed/traj_1771891957848_8c5cad0b.json +80 -0
  212. package/packages/sdk/.trajectories/completed/traj_1771891957857_0986b293.json +80 -0
  213. package/packages/sdk/.trajectories/completed/traj_1771891957872_8a3113af.json +80 -0
  214. package/packages/sdk/.trajectories/completed/traj_1771891957884_0bb85208.json +80 -0
  215. package/packages/sdk/.trajectories/completed/traj_1771891957892_86c75e2e.json +80 -0
  216. package/packages/sdk/.trajectories/completed/traj_1771891957907_98ca0e6f.json +80 -0
  217. package/packages/sdk/.trajectories/completed/traj_1771891957918_d9091231.json +80 -0
  218. package/packages/sdk/.trajectories/completed/traj_1771891957931_dcaf77ed.json +80 -0
  219. package/packages/sdk/.trajectories/completed/traj_1771891962931_eb1fdee2.json +91 -0
  220. package/packages/sdk/.trajectories/completed/traj_1771891966262_9061a93f.json +91 -0
  221. package/packages/sdk/.trajectories/completed/traj_1771891969915_1adaba19.json +91 -0
  222. package/packages/sdk/.trajectories/completed/traj_1771891973588_f08b79e9.json +91 -0
  223. package/packages/sdk/.trajectories/completed/traj_1771891982421_f1985bce.json +80 -0
  224. package/packages/sdk/.trajectories/completed/traj_1771891982432_e7a84163.json +80 -0
  225. package/packages/sdk/.trajectories/completed/traj_1771891982447_369b842a.json +80 -0
  226. package/packages/sdk/.trajectories/completed/traj_1771891982469_5fc45199.json +80 -0
  227. package/packages/sdk/.trajectories/completed/traj_1771891982495_454c7cb3.json +80 -0
  228. package/packages/sdk/.trajectories/completed/traj_1771891982514_08098e03.json +80 -0
  229. package/packages/sdk/.trajectories/completed/traj_1771891982526_b351d778.json +80 -0
  230. package/packages/sdk/.trajectories/completed/traj_1771891982533_fa542d83.json +80 -0
  231. package/packages/sdk/.trajectories/completed/traj_1771891982540_18ab24dc.json +80 -0
  232. package/packages/sdk/.trajectories/completed/traj_1771891982544_5b4fa163.json +80 -0
  233. package/packages/sdk/.trajectories/completed/traj_1771891982548_c13f089a.json +80 -0
  234. package/packages/sdk/.trajectories/completed/traj_1771891987510_23f6da1f.json +91 -0
  235. package/packages/sdk/.trajectories/completed/traj_1771891991466_912c2e04.json +91 -0
  236. package/packages/sdk/.trajectories/completed/traj_1771891994891_60604be2.json +91 -0
  237. package/packages/sdk/.trajectories/completed/traj_1771891998370_cfaf9b8b.json +91 -0
  238. package/packages/sdk/README.md +68 -838
  239. package/packages/sdk/dist/__tests__/contract-fixtures.test.d.ts +2 -0
  240. package/packages/sdk/dist/__tests__/contract-fixtures.test.d.ts.map +1 -0
  241. package/packages/sdk/dist/__tests__/contract-fixtures.test.js +85 -0
  242. package/packages/sdk/dist/__tests__/contract-fixtures.test.js.map +1 -0
  243. package/packages/sdk/dist/__tests__/facade.test.js +305 -0
  244. package/packages/sdk/dist/__tests__/facade.test.js.map +1 -0
  245. package/packages/sdk/dist/__tests__/integration.test.js +169 -0
  246. package/packages/sdk/dist/__tests__/integration.test.js.map +1 -0
  247. package/packages/sdk/dist/__tests__/pty.test.d.ts +2 -0
  248. package/packages/sdk/dist/__tests__/pty.test.d.ts.map +1 -0
  249. package/packages/sdk/dist/__tests__/pty.test.js +20 -0
  250. package/packages/sdk/dist/__tests__/pty.test.js.map +1 -0
  251. package/packages/sdk/dist/__tests__/quickstart.test.js +176 -0
  252. package/packages/sdk/dist/__tests__/quickstart.test.js.map +1 -0
  253. package/packages/sdk/dist/__tests__/spawn-from-env.test.d.ts +2 -0
  254. package/packages/sdk/dist/__tests__/spawn-from-env.test.d.ts.map +1 -0
  255. package/packages/sdk/dist/__tests__/spawn-from-env.test.js +206 -0
  256. package/packages/sdk/dist/__tests__/spawn-from-env.test.js.map +1 -0
  257. package/packages/sdk/dist/__tests__/unit.test.js +347 -0
  258. package/packages/sdk/dist/__tests__/unit.test.js.map +1 -0
  259. package/packages/sdk/dist/client.d.ts +140 -526
  260. package/packages/sdk/dist/client.d.ts.map +1 -1
  261. package/packages/sdk/dist/client.js +430 -1509
  262. package/packages/sdk/dist/client.js.map +1 -1
  263. package/packages/sdk/dist/examples/workflow-superiority.d.ts +32 -0
  264. package/packages/sdk/dist/examples/workflow-superiority.d.ts.map +1 -0
  265. package/packages/sdk/dist/examples/workflow-superiority.js +1421 -0
  266. package/packages/sdk/dist/examples/workflow-superiority.js.map +1 -0
  267. package/packages/sdk/dist/index.d.ts +13 -20
  268. package/packages/sdk/dist/index.d.ts.map +1 -1
  269. package/packages/sdk/dist/index.js +12 -26
  270. package/packages/sdk/dist/index.js.map +1 -1
  271. package/packages/sdk/dist/logs.d.ts +70 -25
  272. package/packages/sdk/dist/logs.d.ts.map +1 -1
  273. package/packages/sdk/dist/logs.js +238 -42
  274. package/packages/sdk/dist/logs.js.map +1 -1
  275. package/packages/sdk/dist/models.d.ts +9 -0
  276. package/packages/sdk/dist/models.d.ts.map +1 -0
  277. package/packages/sdk/dist/models.js +17 -0
  278. package/packages/sdk/dist/models.js.map +1 -0
  279. package/packages/sdk/dist/protocol.d.ts +366 -0
  280. package/packages/sdk/dist/protocol.d.ts.map +1 -0
  281. package/packages/sdk/dist/pty.d.ts.map +1 -0
  282. package/packages/sdk/dist/pty.js +26 -0
  283. package/packages/sdk/dist/pty.js.map +1 -0
  284. package/packages/sdk/dist/relay-adapter.d.ts +139 -0
  285. package/packages/sdk/dist/relay-adapter.d.ts.map +1 -0
  286. package/packages/sdk/dist/relay-adapter.js +210 -0
  287. package/packages/sdk/dist/relay-adapter.js.map +1 -0
  288. package/packages/sdk/dist/relay.d.ts +304 -0
  289. package/packages/sdk/dist/relay.d.ts.map +1 -0
  290. package/packages/sdk/dist/relay.js +910 -0
  291. package/packages/sdk/dist/relay.js.map +1 -0
  292. package/packages/sdk/dist/shadow.d.ts +101 -0
  293. package/packages/sdk/dist/shadow.d.ts.map +1 -0
  294. package/packages/sdk/dist/shadow.js.map +1 -0
  295. package/packages/sdk/dist/spawn-from-env.d.ts +77 -0
  296. package/packages/sdk/dist/spawn-from-env.d.ts.map +1 -0
  297. package/packages/sdk/dist/spawn-from-env.js +172 -0
  298. package/packages/sdk/dist/spawn-from-env.js.map +1 -0
  299. package/packages/sdk/dist/workflows/builder.d.ts +114 -0
  300. package/packages/sdk/dist/workflows/builder.d.ts.map +1 -0
  301. package/packages/sdk/dist/workflows/builder.js +201 -0
  302. package/packages/sdk/dist/workflows/builder.js.map +1 -0
  303. package/packages/sdk/dist/workflows/cli.d.ts +11 -0
  304. package/packages/sdk/dist/workflows/cli.d.ts.map +1 -0
  305. package/packages/sdk/dist/workflows/cli.js +144 -0
  306. package/packages/sdk/dist/workflows/cli.js.map +1 -0
  307. package/packages/sdk/dist/workflows/coordinator.d.ts +73 -0
  308. package/packages/sdk/dist/workflows/coordinator.d.ts.map +1 -0
  309. package/packages/sdk/dist/workflows/coordinator.js +647 -0
  310. package/packages/sdk/dist/workflows/coordinator.js.map +1 -0
  311. package/packages/sdk/dist/workflows/custom-steps.d.ts +73 -0
  312. package/packages/sdk/dist/workflows/custom-steps.d.ts.map +1 -0
  313. package/packages/sdk/dist/workflows/custom-steps.js +321 -0
  314. package/packages/sdk/dist/workflows/custom-steps.js.map +1 -0
  315. package/packages/sdk/dist/workflows/dry-run-format.d.ts +6 -0
  316. package/packages/sdk/dist/workflows/dry-run-format.d.ts.map +1 -0
  317. package/packages/sdk/dist/workflows/dry-run-format.js +68 -0
  318. package/packages/sdk/dist/workflows/dry-run-format.js.map +1 -0
  319. package/packages/sdk/dist/workflows/file-db.d.ts +33 -0
  320. package/packages/sdk/dist/workflows/file-db.d.ts.map +1 -0
  321. package/packages/sdk/dist/workflows/file-db.js +108 -0
  322. package/packages/sdk/dist/workflows/file-db.js.map +1 -0
  323. package/packages/sdk/dist/workflows/index.d.ts +15 -0
  324. package/packages/sdk/dist/workflows/index.d.ts.map +1 -0
  325. package/packages/sdk/dist/workflows/index.js +15 -0
  326. package/packages/sdk/dist/workflows/index.js.map +1 -0
  327. package/packages/sdk/dist/workflows/run.d.ts +38 -0
  328. package/packages/sdk/dist/workflows/run.d.ts.map +1 -0
  329. package/packages/sdk/dist/workflows/run.js +25 -0
  330. package/packages/sdk/dist/workflows/run.js.map +1 -0
  331. package/packages/sdk/dist/workflows/runner.d.ts +320 -0
  332. package/packages/sdk/dist/workflows/runner.d.ts.map +1 -0
  333. package/packages/sdk/dist/workflows/runner.js +2821 -0
  334. package/packages/sdk/dist/workflows/runner.js.map +1 -0
  335. package/packages/sdk/dist/workflows/templates.d.ts +47 -0
  336. package/packages/sdk/dist/workflows/templates.d.ts.map +1 -0
  337. package/packages/sdk/dist/workflows/templates.js +405 -0
  338. package/packages/sdk/dist/workflows/templates.js.map +1 -0
  339. package/packages/sdk/dist/workflows/trajectory.d.ts +87 -0
  340. package/packages/sdk/dist/workflows/trajectory.d.ts.map +1 -0
  341. package/packages/sdk/dist/workflows/trajectory.js +441 -0
  342. package/packages/sdk/dist/workflows/trajectory.js.map +1 -0
  343. package/packages/sdk/dist/workflows/types.d.ts +306 -0
  344. package/packages/sdk/dist/workflows/types.d.ts.map +1 -0
  345. package/packages/sdk/dist/workflows/types.js +23 -0
  346. package/packages/sdk/dist/workflows/types.js.map +1 -0
  347. package/packages/sdk/dist/workflows/validator.d.ts +11 -0
  348. package/packages/sdk/dist/workflows/validator.d.ts.map +1 -0
  349. package/packages/sdk/dist/workflows/validator.js +128 -0
  350. package/packages/sdk/dist/workflows/validator.js.map +1 -0
  351. package/packages/sdk/package.json +59 -53
  352. package/packages/sdk/scripts/bundle-agent-relay.mjs +53 -0
  353. package/packages/sdk/src/__tests__/contract-fixtures.test.ts +122 -0
  354. package/packages/sdk/src/__tests__/error-scenarios.test.ts +682 -0
  355. package/packages/sdk/src/__tests__/facade.test.ts +364 -0
  356. package/packages/sdk/src/__tests__/idle-nudge.test.ts +438 -0
  357. package/packages/sdk/src/__tests__/integration.test.ts +204 -0
  358. package/packages/sdk/src/__tests__/orchestration-upgrades.test.ts +797 -0
  359. package/packages/sdk/src/__tests__/pty.test.ts +24 -0
  360. package/packages/sdk/src/__tests__/quickstart.test.ts +198 -0
  361. package/packages/sdk/src/__tests__/spawn-from-env.test.ts +282 -0
  362. package/packages/sdk/src/__tests__/swarm-coordinator.test.ts +909 -0
  363. package/packages/sdk/src/__tests__/unit.test.ts +435 -0
  364. package/packages/sdk/src/__tests__/workflow-runner.test.ts +489 -0
  365. package/packages/sdk/src/__tests__/yaml-validation.test.ts +890 -0
  366. package/packages/sdk/src/client.ts +527 -1911
  367. package/packages/sdk/src/examples/workflow-superiority.ts +1485 -0
  368. package/packages/sdk/src/examples/workflows/README.md +156 -0
  369. package/packages/sdk/src/examples/workflows/ralph-overnight.yaml +421 -0
  370. package/packages/sdk/src/examples/workflows/ralph-swarm.yaml +411 -0
  371. package/packages/sdk/src/examples/workflows/ralph-tdd.yaml +259 -0
  372. package/packages/sdk/src/index.ts +13 -116
  373. package/packages/sdk/src/logs.ts +282 -54
  374. package/packages/sdk/src/models.ts +36 -0
  375. package/packages/sdk/src/protocol.ts +385 -0
  376. package/packages/sdk/src/pty.ts +35 -0
  377. package/packages/sdk/src/relay-adapter.ts +316 -0
  378. package/packages/sdk/src/relay.ts +1147 -0
  379. package/packages/sdk/src/shadow.ts +228 -0
  380. package/packages/sdk/src/spawn-from-env.ts +245 -0
  381. package/packages/sdk/src/workflows/README.md +656 -0
  382. package/packages/sdk/src/workflows/builder.ts +278 -0
  383. package/packages/sdk/src/workflows/builtin-templates/bug-fix.yaml +135 -0
  384. package/packages/sdk/src/workflows/builtin-templates/code-review.yaml +133 -0
  385. package/packages/sdk/src/workflows/builtin-templates/competitive.yaml +103 -0
  386. package/packages/sdk/src/workflows/builtin-templates/documentation.yaml +120 -0
  387. package/packages/sdk/src/workflows/builtin-templates/feature-dev.yaml +142 -0
  388. package/packages/sdk/src/workflows/builtin-templates/refactor.yaml +141 -0
  389. package/packages/sdk/src/workflows/builtin-templates/review-loop.yaml +223 -0
  390. package/packages/sdk/src/workflows/builtin-templates/security-audit.yaml +129 -0
  391. package/packages/sdk/src/workflows/cli.ts +162 -0
  392. package/packages/sdk/src/workflows/coordinator.ts +842 -0
  393. package/packages/sdk/src/workflows/custom-steps.ts +450 -0
  394. package/packages/sdk/src/workflows/dry-run-format.ts +75 -0
  395. package/packages/sdk/src/workflows/file-db.ts +117 -0
  396. package/packages/sdk/src/workflows/index.ts +24 -0
  397. package/packages/sdk/src/workflows/run.ts +72 -0
  398. package/packages/sdk/src/workflows/runner.ts +3409 -0
  399. package/packages/sdk/src/workflows/schema.json +651 -0
  400. package/packages/sdk/src/workflows/templates.ts +552 -0
  401. package/packages/sdk/src/workflows/trajectory.ts +631 -0
  402. package/packages/sdk/src/workflows/types.ts +389 -0
  403. package/packages/sdk/src/workflows/validator.ts +151 -0
  404. package/packages/sdk/tsconfig.build.json +25 -0
  405. package/packages/sdk/tsconfig.json +17 -18
  406. package/packages/sdk/vitest.config.ts +1 -1
  407. package/packages/sdk-py/README.md +106 -21
  408. package/packages/sdk-py/agent_relay/__init__.py +21 -0
  409. package/packages/sdk-py/agent_relay/models.py +206 -0
  410. package/packages/sdk-py/pyproject.toml +2 -2
  411. package/packages/sdk-py/src/agent_relay/__init__.py +76 -0
  412. package/packages/sdk-py/src/agent_relay/builder.py +430 -109
  413. package/packages/sdk-py/src/agent_relay/templates.py +197 -0
  414. package/packages/sdk-py/src/agent_relay/types.py +489 -15
  415. package/packages/sdk-py/tests/test_builder.py +115 -1
  416. package/packages/sdk-py/tests/test_workflow_templates.py +450 -0
  417. package/packages/shared/cli-registry.yaml +193 -0
  418. package/packages/shared/codegen-py.mjs +215 -0
  419. package/packages/shared/codegen-ts.mjs +227 -0
  420. package/packages/telemetry/dist/events.d.ts +8 -8
  421. package/packages/telemetry/dist/index.d.ts +1 -1
  422. package/packages/telemetry/package.json +2 -2
  423. package/packages/telemetry/src/events.ts +9 -9
  424. package/packages/telemetry/src/index.ts +2 -2
  425. package/packages/trajectory/package.json +2 -2
  426. package/packages/user-directory/dist/user-directory.js +1 -1
  427. package/packages/user-directory/dist/user-directory.js.map +1 -1
  428. package/packages/user-directory/package.json +2 -2
  429. package/packages/user-directory/src/user-directory.ts +1 -1
  430. package/packages/utils/dist/cjs/client-helpers.js +4 -4
  431. package/packages/utils/dist/cjs/discovery.js +9 -6
  432. package/packages/utils/dist/cjs/errors.js +5 -5
  433. package/packages/utils/dist/cjs/legacy-protocol.js +70 -0
  434. package/packages/utils/dist/cjs/logger.js +3 -3
  435. package/packages/utils/dist/cjs/precompiled-patterns.js +33 -2
  436. package/packages/utils/dist/cjs/relay-pty-path.js +0 -6
  437. package/packages/utils/dist/client-helpers.d.ts +1 -1
  438. package/packages/utils/dist/client-helpers.d.ts.map +1 -1
  439. package/packages/utils/dist/client-helpers.js +1 -1
  440. package/packages/utils/dist/client-helpers.js.map +1 -1
  441. package/packages/utils/dist/discovery.d.ts +7 -7
  442. package/packages/utils/dist/discovery.d.ts.map +1 -1
  443. package/packages/utils/dist/discovery.js +20 -17
  444. package/packages/utils/dist/discovery.js.map +1 -1
  445. package/packages/utils/dist/errors.d.ts +1 -1
  446. package/packages/utils/dist/errors.js +3 -3
  447. package/packages/utils/dist/legacy-protocol.d.ts +46 -0
  448. package/packages/utils/dist/legacy-protocol.d.ts.map +1 -0
  449. package/packages/utils/dist/legacy-protocol.js +47 -0
  450. package/packages/utils/dist/legacy-protocol.js.map +1 -0
  451. package/packages/utils/dist/logger.d.ts +2 -2
  452. package/packages/utils/dist/logger.js +2 -2
  453. package/packages/utils/dist/precompiled-patterns.d.ts.map +1 -1
  454. package/packages/utils/dist/precompiled-patterns.js +28 -2
  455. package/packages/utils/dist/precompiled-patterns.js.map +1 -1
  456. package/packages/utils/dist/relay-pty-path.d.ts.map +1 -1
  457. package/packages/utils/dist/relay-pty-path.js +1 -10
  458. package/packages/utils/dist/relay-pty-path.js.map +1 -1
  459. package/packages/utils/package.json +2 -3
  460. package/packages/utils/src/client-helpers.ts +1 -1
  461. package/packages/utils/src/consolidation.test.ts +3 -3
  462. package/packages/utils/src/discovery.test.ts +3 -3
  463. package/packages/utils/src/discovery.ts +21 -18
  464. package/packages/utils/src/errors.test.ts +6 -11
  465. package/packages/utils/src/errors.ts +3 -3
  466. package/packages/utils/src/legacy-protocol.ts +151 -0
  467. package/packages/utils/src/logger.ts +2 -2
  468. package/packages/utils/src/precompiled-patterns.test.ts +8 -0
  469. package/packages/utils/src/precompiled-patterns.ts +40 -2
  470. package/packages/utils/src/relay-pty-path.test.ts +23 -34
  471. package/packages/utils/src/relay-pty-path.ts +1 -11
  472. package/relay-snippets/agent-relay-protocol.md +6 -43
  473. package/relay-snippets/agent-relay-snippet.md +59 -203
  474. package/scripts/postinstall.js +44 -171
  475. package/bin/relay-pty-darwin-arm64 +0 -0
  476. package/bin/relay-pty-darwin-x64 +0 -0
  477. package/bin/relay-pty-linux-arm64 +0 -0
  478. package/bin/relay-pty-linux-x64 +0 -0
  479. package/dist/src/bridge/index.d.ts +0 -8
  480. package/dist/src/bridge/index.d.ts.map +0 -1
  481. package/dist/src/bridge/index.js +0 -8
  482. package/dist/src/bridge/index.js.map +0 -1
  483. package/dist/src/continuity/index.d.ts +0 -5
  484. package/dist/src/continuity/index.d.ts.map +0 -1
  485. package/dist/src/continuity/index.js +0 -5
  486. package/dist/src/continuity/index.js.map +0 -1
  487. package/dist/src/daemon/index.d.ts +0 -8
  488. package/dist/src/daemon/index.d.ts.map +0 -1
  489. package/dist/src/daemon/index.js +0 -9
  490. package/dist/src/daemon/index.js.map +0 -1
  491. package/dist/src/protocol/index.d.ts +0 -8
  492. package/dist/src/protocol/index.d.ts.map +0 -1
  493. package/dist/src/protocol/index.js +0 -8
  494. package/dist/src/protocol/index.js.map +0 -1
  495. package/dist/src/resiliency/index.d.ts +0 -5
  496. package/dist/src/resiliency/index.d.ts.map +0 -1
  497. package/dist/src/resiliency/index.js +0 -5
  498. package/dist/src/resiliency/index.js.map +0 -1
  499. package/dist/src/state/index.d.ts +0 -5
  500. package/dist/src/state/index.d.ts.map +0 -1
  501. package/dist/src/state/index.js +0 -5
  502. package/dist/src/state/index.js.map +0 -1
  503. package/dist/src/storage/index.d.ts +0 -8
  504. package/dist/src/storage/index.d.ts.map +0 -1
  505. package/dist/src/storage/index.js +0 -8
  506. package/dist/src/storage/index.js.map +0 -1
  507. package/dist/src/wrapper/index.d.ts +0 -8
  508. package/dist/src/wrapper/index.d.ts.map +0 -1
  509. package/dist/src/wrapper/index.js +0 -11
  510. package/dist/src/wrapper/index.js.map +0 -1
  511. package/packages/bridge/dist/cli-resolution.d.ts +0 -32
  512. package/packages/bridge/dist/cli-resolution.d.ts.map +0 -1
  513. package/packages/bridge/dist/cli-resolution.js +0 -88
  514. package/packages/bridge/dist/cli-resolution.js.map +0 -1
  515. package/packages/bridge/dist/index.d.ts +0 -9
  516. package/packages/bridge/dist/index.d.ts.map +0 -1
  517. package/packages/bridge/dist/index.js +0 -11
  518. package/packages/bridge/dist/index.js.map +0 -1
  519. package/packages/bridge/dist/multi-project-client.d.ts +0 -99
  520. package/packages/bridge/dist/multi-project-client.d.ts.map +0 -1
  521. package/packages/bridge/dist/multi-project-client.js +0 -389
  522. package/packages/bridge/dist/multi-project-client.js.map +0 -1
  523. package/packages/bridge/dist/shadow-cli.d.ts +0 -17
  524. package/packages/bridge/dist/shadow-cli.d.ts.map +0 -1
  525. package/packages/bridge/dist/shadow-cli.js +0 -75
  526. package/packages/bridge/dist/shadow-cli.js.map +0 -1
  527. package/packages/bridge/dist/spawner.d.ts +0 -263
  528. package/packages/bridge/dist/spawner.d.ts.map +0 -1
  529. package/packages/bridge/dist/spawner.js +0 -1758
  530. package/packages/bridge/dist/spawner.js.map +0 -1
  531. package/packages/bridge/dist/types.d.ts +0 -141
  532. package/packages/bridge/dist/types.d.ts.map +0 -1
  533. package/packages/bridge/dist/types.js +0 -6
  534. package/packages/bridge/dist/types.js.map +0 -1
  535. package/packages/bridge/dist/utils.d.ts +0 -39
  536. package/packages/bridge/dist/utils.d.ts.map +0 -1
  537. package/packages/bridge/dist/utils.js +0 -98
  538. package/packages/bridge/dist/utils.js.map +0 -1
  539. package/packages/bridge/package.json +0 -45
  540. package/packages/bridge/src/cli-resolution.test.ts +0 -225
  541. package/packages/bridge/src/cli-resolution.ts +0 -100
  542. package/packages/bridge/src/index.ts +0 -34
  543. package/packages/bridge/src/multi-project-client.test.ts +0 -340
  544. package/packages/bridge/src/multi-project-client.ts +0 -469
  545. package/packages/bridge/src/shadow-cli.ts +0 -95
  546. package/packages/bridge/src/spawner-mcp.test.ts +0 -505
  547. package/packages/bridge/src/spawner.ts +0 -2067
  548. package/packages/bridge/src/types.ts +0 -153
  549. package/packages/bridge/src/utils.test.ts +0 -235
  550. package/packages/bridge/src/utils.ts +0 -113
  551. package/packages/bridge/tsconfig.json +0 -29
  552. package/packages/bridge/vitest.config.ts +0 -9
  553. package/packages/broker-sdk/README.md +0 -97
  554. package/packages/broker-sdk/dist/__tests__/facade.test.js +0 -257
  555. package/packages/broker-sdk/dist/__tests__/facade.test.js.map +0 -1
  556. package/packages/broker-sdk/dist/__tests__/integration.test.js +0 -139
  557. package/packages/broker-sdk/dist/__tests__/integration.test.js.map +0 -1
  558. package/packages/broker-sdk/dist/__tests__/quickstart.test.js +0 -176
  559. package/packages/broker-sdk/dist/__tests__/quickstart.test.js.map +0 -1
  560. package/packages/broker-sdk/dist/__tests__/unit.test.js +0 -192
  561. package/packages/broker-sdk/dist/__tests__/unit.test.js.map +0 -1
  562. package/packages/broker-sdk/dist/client.d.ts +0 -95
  563. package/packages/broker-sdk/dist/client.d.ts.map +0 -1
  564. package/packages/broker-sdk/dist/client.js +0 -372
  565. package/packages/broker-sdk/dist/client.js.map +0 -1
  566. package/packages/broker-sdk/dist/index.d.ts +0 -10
  567. package/packages/broker-sdk/dist/index.d.ts.map +0 -1
  568. package/packages/broker-sdk/dist/index.js +0 -10
  569. package/packages/broker-sdk/dist/index.js.map +0 -1
  570. package/packages/broker-sdk/dist/logs.d.ts +0 -47
  571. package/packages/broker-sdk/dist/logs.d.ts.map +0 -1
  572. package/packages/broker-sdk/dist/logs.js +0 -137
  573. package/packages/broker-sdk/dist/logs.js.map +0 -1
  574. package/packages/broker-sdk/dist/protocol.d.ts +0 -258
  575. package/packages/broker-sdk/dist/protocol.d.ts.map +0 -1
  576. package/packages/broker-sdk/dist/pty.d.ts.map +0 -1
  577. package/packages/broker-sdk/dist/pty.js +0 -14
  578. package/packages/broker-sdk/dist/pty.js.map +0 -1
  579. package/packages/broker-sdk/dist/relay.d.ts +0 -178
  580. package/packages/broker-sdk/dist/relay.d.ts.map +0 -1
  581. package/packages/broker-sdk/dist/relay.js +0 -494
  582. package/packages/broker-sdk/dist/relay.js.map +0 -1
  583. package/packages/broker-sdk/dist/relaycast.d.ts +0 -73
  584. package/packages/broker-sdk/dist/relaycast.d.ts.map +0 -1
  585. package/packages/broker-sdk/dist/relaycast.js +0 -184
  586. package/packages/broker-sdk/dist/relaycast.js.map +0 -1
  587. package/packages/broker-sdk/dist/shadow.d.ts +0 -100
  588. package/packages/broker-sdk/dist/shadow.d.ts.map +0 -1
  589. package/packages/broker-sdk/dist/shadow.js.map +0 -1
  590. package/packages/broker-sdk/dist/workflows/builder.d.ts +0 -101
  591. package/packages/broker-sdk/dist/workflows/builder.d.ts.map +0 -1
  592. package/packages/broker-sdk/dist/workflows/builder.js +0 -179
  593. package/packages/broker-sdk/dist/workflows/builder.js.map +0 -1
  594. package/packages/broker-sdk/dist/workflows/cli.d.ts +0 -10
  595. package/packages/broker-sdk/dist/workflows/cli.d.ts.map +0 -1
  596. package/packages/broker-sdk/dist/workflows/cli.js +0 -82
  597. package/packages/broker-sdk/dist/workflows/cli.js.map +0 -1
  598. package/packages/broker-sdk/dist/workflows/coordinator.d.ts +0 -69
  599. package/packages/broker-sdk/dist/workflows/coordinator.d.ts.map +0 -1
  600. package/packages/broker-sdk/dist/workflows/coordinator.js +0 -585
  601. package/packages/broker-sdk/dist/workflows/coordinator.js.map +0 -1
  602. package/packages/broker-sdk/dist/workflows/index.d.ts +0 -11
  603. package/packages/broker-sdk/dist/workflows/index.d.ts.map +0 -1
  604. package/packages/broker-sdk/dist/workflows/index.js +0 -11
  605. package/packages/broker-sdk/dist/workflows/index.js.map +0 -1
  606. package/packages/broker-sdk/dist/workflows/run.d.ts +0 -33
  607. package/packages/broker-sdk/dist/workflows/run.d.ts.map +0 -1
  608. package/packages/broker-sdk/dist/workflows/run.js +0 -28
  609. package/packages/broker-sdk/dist/workflows/run.js.map +0 -1
  610. package/packages/broker-sdk/dist/workflows/runner.d.ts +0 -140
  611. package/packages/broker-sdk/dist/workflows/runner.d.ts.map +0 -1
  612. package/packages/broker-sdk/dist/workflows/runner.js +0 -962
  613. package/packages/broker-sdk/dist/workflows/runner.js.map +0 -1
  614. package/packages/broker-sdk/dist/workflows/templates.d.ts +0 -47
  615. package/packages/broker-sdk/dist/workflows/templates.d.ts.map +0 -1
  616. package/packages/broker-sdk/dist/workflows/templates.js +0 -395
  617. package/packages/broker-sdk/dist/workflows/templates.js.map +0 -1
  618. package/packages/broker-sdk/dist/workflows/trajectory.d.ts +0 -80
  619. package/packages/broker-sdk/dist/workflows/trajectory.d.ts.map +0 -1
  620. package/packages/broker-sdk/dist/workflows/trajectory.js +0 -362
  621. package/packages/broker-sdk/dist/workflows/trajectory.js.map +0 -1
  622. package/packages/broker-sdk/dist/workflows/types.d.ts +0 -140
  623. package/packages/broker-sdk/dist/workflows/types.d.ts.map +0 -1
  624. package/packages/broker-sdk/dist/workflows/types.js +0 -8
  625. package/packages/broker-sdk/dist/workflows/types.js.map +0 -1
  626. package/packages/broker-sdk/package.json +0 -81
  627. package/packages/broker-sdk/scripts/bundle-agent-relay.mjs +0 -53
  628. package/packages/broker-sdk/src/__tests__/error-scenarios.test.ts +0 -682
  629. package/packages/broker-sdk/src/__tests__/facade.test.ts +0 -296
  630. package/packages/broker-sdk/src/__tests__/integration.test.ts +0 -170
  631. package/packages/broker-sdk/src/__tests__/quickstart.test.ts +0 -198
  632. package/packages/broker-sdk/src/__tests__/swarm-coordinator.test.ts +0 -772
  633. package/packages/broker-sdk/src/__tests__/unit.test.ts +0 -243
  634. package/packages/broker-sdk/src/__tests__/workflow-runner.test.ts +0 -333
  635. package/packages/broker-sdk/src/client.ts +0 -510
  636. package/packages/broker-sdk/src/index.ts +0 -9
  637. package/packages/broker-sdk/src/logs.ts +0 -163
  638. package/packages/broker-sdk/src/protocol.ts +0 -276
  639. package/packages/broker-sdk/src/pty.ts +0 -16
  640. package/packages/broker-sdk/src/relay.ts +0 -625
  641. package/packages/broker-sdk/src/relaycast.ts +0 -221
  642. package/packages/broker-sdk/src/shadow.ts +0 -230
  643. package/packages/broker-sdk/src/workflows/README.md +0 -544
  644. package/packages/broker-sdk/src/workflows/builder.ts +0 -241
  645. package/packages/broker-sdk/src/workflows/builtin-templates/bug-fix.yaml +0 -75
  646. package/packages/broker-sdk/src/workflows/builtin-templates/code-review.yaml +0 -82
  647. package/packages/broker-sdk/src/workflows/builtin-templates/documentation.yaml +0 -70
  648. package/packages/broker-sdk/src/workflows/builtin-templates/feature-dev.yaml +0 -76
  649. package/packages/broker-sdk/src/workflows/builtin-templates/refactor.yaml +0 -82
  650. package/packages/broker-sdk/src/workflows/builtin-templates/security-audit.yaml +0 -84
  651. package/packages/broker-sdk/src/workflows/cli.ts +0 -93
  652. package/packages/broker-sdk/src/workflows/coordinator.ts +0 -758
  653. package/packages/broker-sdk/src/workflows/index.ts +0 -10
  654. package/packages/broker-sdk/src/workflows/run.ts +0 -55
  655. package/packages/broker-sdk/src/workflows/runner.ts +0 -1271
  656. package/packages/broker-sdk/src/workflows/schema.json +0 -333
  657. package/packages/broker-sdk/src/workflows/templates.ts +0 -544
  658. package/packages/broker-sdk/src/workflows/trajectory.ts +0 -507
  659. package/packages/broker-sdk/src/workflows/types.ts +0 -208
  660. package/packages/broker-sdk/tsconfig.json +0 -22
  661. package/packages/broker-sdk/vitest.config.ts +0 -9
  662. package/packages/continuity/dist/formatter.d.ts +0 -57
  663. package/packages/continuity/dist/formatter.d.ts.map +0 -1
  664. package/packages/continuity/dist/formatter.js +0 -448
  665. package/packages/continuity/dist/formatter.js.map +0 -1
  666. package/packages/continuity/dist/handoff-store.d.ts +0 -67
  667. package/packages/continuity/dist/handoff-store.d.ts.map +0 -1
  668. package/packages/continuity/dist/handoff-store.js +0 -472
  669. package/packages/continuity/dist/handoff-store.js.map +0 -1
  670. package/packages/continuity/dist/index.d.ts +0 -10
  671. package/packages/continuity/dist/index.d.ts.map +0 -1
  672. package/packages/continuity/dist/index.js +0 -11
  673. package/packages/continuity/dist/index.js.map +0 -1
  674. package/packages/continuity/dist/ledger-store.d.ts +0 -110
  675. package/packages/continuity/dist/ledger-store.d.ts.map +0 -1
  676. package/packages/continuity/dist/ledger-store.js +0 -500
  677. package/packages/continuity/dist/ledger-store.js.map +0 -1
  678. package/packages/continuity/dist/manager.d.ts +0 -183
  679. package/packages/continuity/dist/manager.d.ts.map +0 -1
  680. package/packages/continuity/dist/manager.js +0 -616
  681. package/packages/continuity/dist/manager.js.map +0 -1
  682. package/packages/continuity/dist/parser.d.ts +0 -76
  683. package/packages/continuity/dist/parser.d.ts.map +0 -1
  684. package/packages/continuity/dist/parser.js +0 -579
  685. package/packages/continuity/dist/parser.js.map +0 -1
  686. package/packages/continuity/dist/types.d.ts +0 -180
  687. package/packages/continuity/dist/types.d.ts.map +0 -1
  688. package/packages/continuity/dist/types.js +0 -2
  689. package/packages/continuity/dist/types.js.map +0 -1
  690. package/packages/continuity/package.json +0 -40
  691. package/packages/continuity/src/formatter.ts +0 -536
  692. package/packages/continuity/src/handoff-store.ts +0 -523
  693. package/packages/continuity/src/index.ts +0 -12
  694. package/packages/continuity/src/ledger-store.ts +0 -594
  695. package/packages/continuity/src/manager.test.ts +0 -291
  696. package/packages/continuity/src/manager.ts +0 -774
  697. package/packages/continuity/src/parser.test.ts +0 -292
  698. package/packages/continuity/src/parser.ts +0 -680
  699. package/packages/continuity/src/types.ts +0 -211
  700. package/packages/continuity/tsconfig.json +0 -21
  701. package/packages/continuity/vitest.config.ts +0 -9
  702. package/packages/daemon/dist/agent-manager.d.ts +0 -134
  703. package/packages/daemon/dist/agent-manager.d.ts.map +0 -1
  704. package/packages/daemon/dist/agent-manager.js +0 -578
  705. package/packages/daemon/dist/agent-manager.js.map +0 -1
  706. package/packages/daemon/dist/agent-registry.d.ts +0 -99
  707. package/packages/daemon/dist/agent-registry.d.ts.map +0 -1
  708. package/packages/daemon/dist/agent-registry.js +0 -213
  709. package/packages/daemon/dist/agent-registry.js.map +0 -1
  710. package/packages/daemon/dist/agent-signing.d.ts +0 -158
  711. package/packages/daemon/dist/agent-signing.d.ts.map +0 -1
  712. package/packages/daemon/dist/agent-signing.js +0 -523
  713. package/packages/daemon/dist/agent-signing.js.map +0 -1
  714. package/packages/daemon/dist/api.d.ts +0 -106
  715. package/packages/daemon/dist/api.d.ts.map +0 -1
  716. package/packages/daemon/dist/api.js +0 -895
  717. package/packages/daemon/dist/api.js.map +0 -1
  718. package/packages/daemon/dist/auth.d.ts +0 -94
  719. package/packages/daemon/dist/auth.d.ts.map +0 -1
  720. package/packages/daemon/dist/auth.js +0 -197
  721. package/packages/daemon/dist/auth.js.map +0 -1
  722. package/packages/daemon/dist/channel-membership-store.d.ts +0 -55
  723. package/packages/daemon/dist/channel-membership-store.d.ts.map +0 -1
  724. package/packages/daemon/dist/channel-membership-store.js +0 -176
  725. package/packages/daemon/dist/channel-membership-store.js.map +0 -1
  726. package/packages/daemon/dist/cli-auth.d.ts +0 -97
  727. package/packages/daemon/dist/cli-auth.d.ts.map +0 -1
  728. package/packages/daemon/dist/cli-auth.js +0 -808
  729. package/packages/daemon/dist/cli-auth.js.map +0 -1
  730. package/packages/daemon/dist/cloud-sync.d.ts +0 -263
  731. package/packages/daemon/dist/cloud-sync.d.ts.map +0 -1
  732. package/packages/daemon/dist/cloud-sync.js +0 -820
  733. package/packages/daemon/dist/cloud-sync.js.map +0 -1
  734. package/packages/daemon/dist/connection.d.ts +0 -137
  735. package/packages/daemon/dist/connection.d.ts.map +0 -1
  736. package/packages/daemon/dist/connection.js +0 -465
  737. package/packages/daemon/dist/connection.js.map +0 -1
  738. package/packages/daemon/dist/consensus-integration.d.ts +0 -168
  739. package/packages/daemon/dist/consensus-integration.d.ts.map +0 -1
  740. package/packages/daemon/dist/consensus-integration.js +0 -371
  741. package/packages/daemon/dist/consensus-integration.js.map +0 -1
  742. package/packages/daemon/dist/consensus.d.ts +0 -269
  743. package/packages/daemon/dist/consensus.d.ts.map +0 -1
  744. package/packages/daemon/dist/consensus.js +0 -632
  745. package/packages/daemon/dist/consensus.js.map +0 -1
  746. package/packages/daemon/dist/delivery-tracker.d.ts +0 -34
  747. package/packages/daemon/dist/delivery-tracker.d.ts.map +0 -1
  748. package/packages/daemon/dist/delivery-tracker.js +0 -104
  749. package/packages/daemon/dist/delivery-tracker.js.map +0 -1
  750. package/packages/daemon/dist/enhanced-features.d.ts +0 -118
  751. package/packages/daemon/dist/enhanced-features.d.ts.map +0 -1
  752. package/packages/daemon/dist/enhanced-features.js +0 -177
  753. package/packages/daemon/dist/enhanced-features.js.map +0 -1
  754. package/packages/daemon/dist/index.d.ts +0 -29
  755. package/packages/daemon/dist/index.d.ts.map +0 -1
  756. package/packages/daemon/dist/index.js +0 -34
  757. package/packages/daemon/dist/index.js.map +0 -1
  758. package/packages/daemon/dist/orchestrator.d.ts +0 -217
  759. package/packages/daemon/dist/orchestrator.d.ts.map +0 -1
  760. package/packages/daemon/dist/orchestrator.js +0 -1172
  761. package/packages/daemon/dist/orchestrator.js.map +0 -1
  762. package/packages/daemon/dist/rate-limiter.d.ts +0 -68
  763. package/packages/daemon/dist/rate-limiter.d.ts.map +0 -1
  764. package/packages/daemon/dist/rate-limiter.js +0 -130
  765. package/packages/daemon/dist/rate-limiter.js.map +0 -1
  766. package/packages/daemon/dist/registry.d.ts +0 -9
  767. package/packages/daemon/dist/registry.d.ts.map +0 -1
  768. package/packages/daemon/dist/registry.js +0 -9
  769. package/packages/daemon/dist/registry.js.map +0 -1
  770. package/packages/daemon/dist/repo-manager.d.ts +0 -116
  771. package/packages/daemon/dist/repo-manager.d.ts.map +0 -1
  772. package/packages/daemon/dist/repo-manager.js +0 -384
  773. package/packages/daemon/dist/repo-manager.js.map +0 -1
  774. package/packages/daemon/dist/router.d.ts +0 -389
  775. package/packages/daemon/dist/router.d.ts.map +0 -1
  776. package/packages/daemon/dist/router.js +0 -1607
  777. package/packages/daemon/dist/router.js.map +0 -1
  778. package/packages/daemon/dist/server.d.ts +0 -201
  779. package/packages/daemon/dist/server.d.ts.map +0 -1
  780. package/packages/daemon/dist/server.js +0 -1791
  781. package/packages/daemon/dist/server.js.map +0 -1
  782. package/packages/daemon/dist/spawn-manager.d.ts +0 -119
  783. package/packages/daemon/dist/spawn-manager.d.ts.map +0 -1
  784. package/packages/daemon/dist/spawn-manager.js +0 -319
  785. package/packages/daemon/dist/spawn-manager.js.map +0 -1
  786. package/packages/daemon/dist/sync-queue.d.ts +0 -116
  787. package/packages/daemon/dist/sync-queue.d.ts.map +0 -1
  788. package/packages/daemon/dist/sync-queue.js +0 -361
  789. package/packages/daemon/dist/sync-queue.js.map +0 -1
  790. package/packages/daemon/dist/types.d.ts +0 -133
  791. package/packages/daemon/dist/types.d.ts.map +0 -1
  792. package/packages/daemon/dist/types.js +0 -6
  793. package/packages/daemon/dist/types.js.map +0 -1
  794. package/packages/daemon/dist/workspace-manager.d.ts +0 -80
  795. package/packages/daemon/dist/workspace-manager.d.ts.map +0 -1
  796. package/packages/daemon/dist/workspace-manager.js +0 -314
  797. package/packages/daemon/dist/workspace-manager.js.map +0 -1
  798. package/packages/daemon/package.json +0 -56
  799. package/packages/daemon/src/agent-manager.ts +0 -679
  800. package/packages/daemon/src/agent-registry.ts +0 -284
  801. package/packages/daemon/src/agent-signing.ts +0 -707
  802. package/packages/daemon/src/api.ts +0 -1034
  803. package/packages/daemon/src/auth.ts +0 -276
  804. package/packages/daemon/src/channel-membership-store.ts +0 -217
  805. package/packages/daemon/src/cli-auth.ts +0 -945
  806. package/packages/daemon/src/cloud-sync.ts +0 -1100
  807. package/packages/daemon/src/connection.ts +0 -561
  808. package/packages/daemon/src/consensus-integration.ts +0 -510
  809. package/packages/daemon/src/consensus.ts +0 -848
  810. package/packages/daemon/src/delivery-tracker.ts +0 -145
  811. package/packages/daemon/src/enhanced-features.ts +0 -390
  812. package/packages/daemon/src/index.ts +0 -48
  813. package/packages/daemon/src/orchestrator.test.ts +0 -231
  814. package/packages/daemon/src/orchestrator.ts +0 -1376
  815. package/packages/daemon/src/rate-limiter.ts +0 -172
  816. package/packages/daemon/src/registry.ts +0 -8
  817. package/packages/daemon/src/repo-manager.ts +0 -468
  818. package/packages/daemon/src/router.test.ts +0 -181
  819. package/packages/daemon/src/router.ts +0 -1925
  820. package/packages/daemon/src/server.ts +0 -2051
  821. package/packages/daemon/src/spawn-manager-set-model.test.ts +0 -144
  822. package/packages/daemon/src/spawn-manager.ts +0 -415
  823. package/packages/daemon/src/sync-queue.ts +0 -477
  824. package/packages/daemon/src/types.ts +0 -158
  825. package/packages/daemon/src/workspace-manager.ts +0 -371
  826. package/packages/daemon/tsconfig.json +0 -21
  827. package/packages/daemon/vitest.config.ts +0 -9
  828. package/packages/mcp/CHANGELOG.md +0 -28
  829. package/packages/mcp/LICENSE +0 -190
  830. package/packages/mcp/README.md +0 -266
  831. package/packages/mcp/dist/bin.d.ts +0 -12
  832. package/packages/mcp/dist/bin.d.ts.map +0 -1
  833. package/packages/mcp/dist/bin.js +0 -179
  834. package/packages/mcp/dist/bin.js.map +0 -1
  835. package/packages/mcp/dist/client-adapter.d.ts +0 -164
  836. package/packages/mcp/dist/client-adapter.d.ts.map +0 -1
  837. package/packages/mcp/dist/client-adapter.js +0 -231
  838. package/packages/mcp/dist/client-adapter.js.map +0 -1
  839. package/packages/mcp/dist/cloud.d.ts +0 -13
  840. package/packages/mcp/dist/cloud.d.ts.map +0 -1
  841. package/packages/mcp/dist/cloud.js +0 -25
  842. package/packages/mcp/dist/cloud.js.map +0 -1
  843. package/packages/mcp/dist/errors.d.ts +0 -9
  844. package/packages/mcp/dist/errors.d.ts.map +0 -1
  845. package/packages/mcp/dist/errors.js +0 -9
  846. package/packages/mcp/dist/errors.js.map +0 -1
  847. package/packages/mcp/dist/file-transport.d.ts +0 -103
  848. package/packages/mcp/dist/file-transport.d.ts.map +0 -1
  849. package/packages/mcp/dist/file-transport.js +0 -204
  850. package/packages/mcp/dist/file-transport.js.map +0 -1
  851. package/packages/mcp/dist/hybrid-client.d.ts +0 -5
  852. package/packages/mcp/dist/hybrid-client.d.ts.map +0 -1
  853. package/packages/mcp/dist/hybrid-client.js +0 -23
  854. package/packages/mcp/dist/hybrid-client.js.map +0 -1
  855. package/packages/mcp/dist/index.d.ts +0 -11
  856. package/packages/mcp/dist/index.d.ts.map +0 -1
  857. package/packages/mcp/dist/index.js +0 -25
  858. package/packages/mcp/dist/index.js.map +0 -1
  859. package/packages/mcp/dist/install-cli.d.ts +0 -35
  860. package/packages/mcp/dist/install-cli.d.ts.map +0 -1
  861. package/packages/mcp/dist/install-cli.js +0 -157
  862. package/packages/mcp/dist/install-cli.js.map +0 -1
  863. package/packages/mcp/dist/install.d.ts +0 -123
  864. package/packages/mcp/dist/install.d.ts.map +0 -1
  865. package/packages/mcp/dist/install.js +0 -661
  866. package/packages/mcp/dist/install.js.map +0 -1
  867. package/packages/mcp/dist/prompts/index.d.ts +0 -2
  868. package/packages/mcp/dist/prompts/index.d.ts.map +0 -1
  869. package/packages/mcp/dist/prompts/index.js +0 -2
  870. package/packages/mcp/dist/prompts/index.js.map +0 -1
  871. package/packages/mcp/dist/prompts/protocol.d.ts +0 -11
  872. package/packages/mcp/dist/prompts/protocol.d.ts.map +0 -1
  873. package/packages/mcp/dist/prompts/protocol.js +0 -160
  874. package/packages/mcp/dist/prompts/protocol.js.map +0 -1
  875. package/packages/mcp/dist/resources/agents.d.ts +0 -11
  876. package/packages/mcp/dist/resources/agents.d.ts.map +0 -1
  877. package/packages/mcp/dist/resources/agents.js +0 -17
  878. package/packages/mcp/dist/resources/agents.js.map +0 -1
  879. package/packages/mcp/dist/resources/inbox.d.ts +0 -11
  880. package/packages/mcp/dist/resources/inbox.d.ts.map +0 -1
  881. package/packages/mcp/dist/resources/inbox.js +0 -17
  882. package/packages/mcp/dist/resources/inbox.js.map +0 -1
  883. package/packages/mcp/dist/resources/index.d.ts +0 -4
  884. package/packages/mcp/dist/resources/index.d.ts.map +0 -1
  885. package/packages/mcp/dist/resources/index.js +0 -4
  886. package/packages/mcp/dist/resources/index.js.map +0 -1
  887. package/packages/mcp/dist/resources/project.d.ts +0 -11
  888. package/packages/mcp/dist/resources/project.d.ts.map +0 -1
  889. package/packages/mcp/dist/resources/project.js +0 -21
  890. package/packages/mcp/dist/resources/project.js.map +0 -1
  891. package/packages/mcp/dist/server.d.ts +0 -23
  892. package/packages/mcp/dist/server.d.ts.map +0 -1
  893. package/packages/mcp/dist/server.js +0 -317
  894. package/packages/mcp/dist/server.js.map +0 -1
  895. package/packages/mcp/dist/simple.d.ts +0 -170
  896. package/packages/mcp/dist/simple.d.ts.map +0 -1
  897. package/packages/mcp/dist/simple.js +0 -120
  898. package/packages/mcp/dist/simple.js.map +0 -1
  899. package/packages/mcp/dist/tools/index.d.ts +0 -20
  900. package/packages/mcp/dist/tools/index.d.ts.map +0 -1
  901. package/packages/mcp/dist/tools/index.js +0 -20
  902. package/packages/mcp/dist/tools/index.js.map +0 -1
  903. package/packages/mcp/dist/tools/relay-broadcast.d.ts +0 -20
  904. package/packages/mcp/dist/tools/relay-broadcast.d.ts.map +0 -1
  905. package/packages/mcp/dist/tools/relay-broadcast.js +0 -25
  906. package/packages/mcp/dist/tools/relay-broadcast.js.map +0 -1
  907. package/packages/mcp/dist/tools/relay-channel.d.ts +0 -75
  908. package/packages/mcp/dist/tools/relay-channel.d.ts.map +0 -1
  909. package/packages/mcp/dist/tools/relay-channel.js +0 -124
  910. package/packages/mcp/dist/tools/relay-channel.js.map +0 -1
  911. package/packages/mcp/dist/tools/relay-connected.d.ts +0 -17
  912. package/packages/mcp/dist/tools/relay-connected.d.ts.map +0 -1
  913. package/packages/mcp/dist/tools/relay-connected.js +0 -54
  914. package/packages/mcp/dist/tools/relay-connected.js.map +0 -1
  915. package/packages/mcp/dist/tools/relay-consensus.d.ts +0 -45
  916. package/packages/mcp/dist/tools/relay-consensus.d.ts.map +0 -1
  917. package/packages/mcp/dist/tools/relay-consensus.js +0 -80
  918. package/packages/mcp/dist/tools/relay-consensus.js.map +0 -1
  919. package/packages/mcp/dist/tools/relay-continuity.d.ts +0 -35
  920. package/packages/mcp/dist/tools/relay-continuity.d.ts.map +0 -1
  921. package/packages/mcp/dist/tools/relay-continuity.js +0 -101
  922. package/packages/mcp/dist/tools/relay-continuity.js.map +0 -1
  923. package/packages/mcp/dist/tools/relay-health.d.ts +0 -20
  924. package/packages/mcp/dist/tools/relay-health.d.ts.map +0 -1
  925. package/packages/mcp/dist/tools/relay-health.js +0 -130
  926. package/packages/mcp/dist/tools/relay-health.js.map +0 -1
  927. package/packages/mcp/dist/tools/relay-inbox.d.ts +0 -26
  928. package/packages/mcp/dist/tools/relay-inbox.d.ts.map +0 -1
  929. package/packages/mcp/dist/tools/relay-inbox.js +0 -58
  930. package/packages/mcp/dist/tools/relay-inbox.js.map +0 -1
  931. package/packages/mcp/dist/tools/relay-logs.d.ts +0 -20
  932. package/packages/mcp/dist/tools/relay-logs.d.ts.map +0 -1
  933. package/packages/mcp/dist/tools/relay-logs.js +0 -90
  934. package/packages/mcp/dist/tools/relay-logs.js.map +0 -1
  935. package/packages/mcp/dist/tools/relay-messages.d.ts +0 -32
  936. package/packages/mcp/dist/tools/relay-messages.d.ts.map +0 -1
  937. package/packages/mcp/dist/tools/relay-messages.js +0 -61
  938. package/packages/mcp/dist/tools/relay-messages.js.map +0 -1
  939. package/packages/mcp/dist/tools/relay-metrics.d.ts +0 -17
  940. package/packages/mcp/dist/tools/relay-metrics.d.ts.map +0 -1
  941. package/packages/mcp/dist/tools/relay-metrics.js +0 -124
  942. package/packages/mcp/dist/tools/relay-metrics.js.map +0 -1
  943. package/packages/mcp/dist/tools/relay-release.d.ts +0 -20
  944. package/packages/mcp/dist/tools/relay-release.d.ts.map +0 -1
  945. package/packages/mcp/dist/tools/relay-release.js +0 -44
  946. package/packages/mcp/dist/tools/relay-release.js.map +0 -1
  947. package/packages/mcp/dist/tools/relay-remove-agent.d.ts +0 -20
  948. package/packages/mcp/dist/tools/relay-remove-agent.d.ts.map +0 -1
  949. package/packages/mcp/dist/tools/relay-remove-agent.js +0 -50
  950. package/packages/mcp/dist/tools/relay-remove-agent.js.map +0 -1
  951. package/packages/mcp/dist/tools/relay-send.d.ts +0 -29
  952. package/packages/mcp/dist/tools/relay-send.d.ts.map +0 -1
  953. package/packages/mcp/dist/tools/relay-send.js +0 -73
  954. package/packages/mcp/dist/tools/relay-send.js.map +0 -1
  955. package/packages/mcp/dist/tools/relay-set-model.d.ts +0 -23
  956. package/packages/mcp/dist/tools/relay-set-model.d.ts.map +0 -1
  957. package/packages/mcp/dist/tools/relay-set-model.js +0 -52
  958. package/packages/mcp/dist/tools/relay-set-model.js.map +0 -1
  959. package/packages/mcp/dist/tools/relay-shadow.d.ts +0 -30
  960. package/packages/mcp/dist/tools/relay-shadow.d.ts.map +0 -1
  961. package/packages/mcp/dist/tools/relay-shadow.js +0 -55
  962. package/packages/mcp/dist/tools/relay-shadow.js.map +0 -1
  963. package/packages/mcp/dist/tools/relay-spawn.d.ts +0 -36
  964. package/packages/mcp/dist/tools/relay-spawn.d.ts.map +0 -1
  965. package/packages/mcp/dist/tools/relay-spawn.js +0 -73
  966. package/packages/mcp/dist/tools/relay-spawn.js.map +0 -1
  967. package/packages/mcp/dist/tools/relay-status.d.ts +0 -11
  968. package/packages/mcp/dist/tools/relay-status.d.ts.map +0 -1
  969. package/packages/mcp/dist/tools/relay-status.js +0 -43
  970. package/packages/mcp/dist/tools/relay-status.js.map +0 -1
  971. package/packages/mcp/dist/tools/relay-subscribe.d.ts +0 -27
  972. package/packages/mcp/dist/tools/relay-subscribe.d.ts.map +0 -1
  973. package/packages/mcp/dist/tools/relay-subscribe.js +0 -49
  974. package/packages/mcp/dist/tools/relay-subscribe.js.map +0 -1
  975. package/packages/mcp/dist/tools/relay-who.d.ts +0 -20
  976. package/packages/mcp/dist/tools/relay-who.d.ts.map +0 -1
  977. package/packages/mcp/dist/tools/relay-who.js +0 -62
  978. package/packages/mcp/dist/tools/relay-who.js.map +0 -1
  979. package/packages/mcp/package.json +0 -82
  980. package/packages/mcp/src/bin.ts +0 -200
  981. package/packages/mcp/src/client-adapter.ts +0 -358
  982. package/packages/mcp/src/cloud.ts +0 -41
  983. package/packages/mcp/src/errors.ts +0 -17
  984. package/packages/mcp/src/file-transport.ts +0 -275
  985. package/packages/mcp/src/hybrid-client.ts +0 -25
  986. package/packages/mcp/src/index.ts +0 -143
  987. package/packages/mcp/src/install-cli.ts +0 -210
  988. package/packages/mcp/src/install.ts +0 -820
  989. package/packages/mcp/src/prompts/index.ts +0 -1
  990. package/packages/mcp/src/prompts/protocol.ts +0 -164
  991. package/packages/mcp/src/resources/agents.ts +0 -21
  992. package/packages/mcp/src/resources/inbox.ts +0 -21
  993. package/packages/mcp/src/resources/index.ts +0 -3
  994. package/packages/mcp/src/resources/project.ts +0 -29
  995. package/packages/mcp/src/server.ts +0 -475
  996. package/packages/mcp/src/simple.ts +0 -214
  997. package/packages/mcp/src/tools/index.ts +0 -155
  998. package/packages/mcp/src/tools/relay-broadcast.ts +0 -32
  999. package/packages/mcp/src/tools/relay-channel.ts +0 -151
  1000. package/packages/mcp/src/tools/relay-connected.ts +0 -67
  1001. package/packages/mcp/src/tools/relay-consensus.ts +0 -92
  1002. package/packages/mcp/src/tools/relay-continuity.ts +0 -127
  1003. package/packages/mcp/src/tools/relay-health.ts +0 -148
  1004. package/packages/mcp/src/tools/relay-inbox.ts +0 -70
  1005. package/packages/mcp/src/tools/relay-logs.ts +0 -106
  1006. package/packages/mcp/src/tools/relay-messages.ts +0 -66
  1007. package/packages/mcp/src/tools/relay-metrics.ts +0 -142
  1008. package/packages/mcp/src/tools/relay-release.ts +0 -54
  1009. package/packages/mcp/src/tools/relay-remove-agent.ts +0 -58
  1010. package/packages/mcp/src/tools/relay-send.ts +0 -84
  1011. package/packages/mcp/src/tools/relay-set-model.ts +0 -62
  1012. package/packages/mcp/src/tools/relay-shadow.ts +0 -67
  1013. package/packages/mcp/src/tools/relay-spawn.ts +0 -87
  1014. package/packages/mcp/src/tools/relay-status.ts +0 -57
  1015. package/packages/mcp/src/tools/relay-subscribe.ts +0 -61
  1016. package/packages/mcp/src/tools/relay-who.ts +0 -75
  1017. package/packages/mcp/tests/client.test.ts +0 -451
  1018. package/packages/mcp/tests/discover.test.ts +0 -256
  1019. package/packages/mcp/tests/install.test.ts +0 -123
  1020. package/packages/mcp/tests/prompts.test.ts +0 -12
  1021. package/packages/mcp/tests/resources.test.ts +0 -53
  1022. package/packages/mcp/tests/tools.test.ts +0 -1516
  1023. package/packages/mcp/tsconfig.json +0 -22
  1024. package/packages/mcp/vitest.config.ts +0 -9
  1025. package/packages/protocol/dist/channels.d.ts +0 -137
  1026. package/packages/protocol/dist/channels.d.ts.map +0 -1
  1027. package/packages/protocol/dist/channels.js +0 -154
  1028. package/packages/protocol/dist/channels.js.map +0 -1
  1029. package/packages/protocol/dist/framing.d.ts +0 -80
  1030. package/packages/protocol/dist/framing.d.ts.map +0 -1
  1031. package/packages/protocol/dist/framing.js +0 -206
  1032. package/packages/protocol/dist/framing.js.map +0 -1
  1033. package/packages/protocol/dist/id-generator.d.ts +0 -35
  1034. package/packages/protocol/dist/id-generator.d.ts.map +0 -1
  1035. package/packages/protocol/dist/id-generator.js +0 -60
  1036. package/packages/protocol/dist/id-generator.js.map +0 -1
  1037. package/packages/protocol/dist/index.d.ts +0 -5
  1038. package/packages/protocol/dist/index.d.ts.map +0 -1
  1039. package/packages/protocol/dist/index.js +0 -5
  1040. package/packages/protocol/dist/index.js.map +0 -1
  1041. package/packages/protocol/dist/relay-pty-schemas.d.ts +0 -340
  1042. package/packages/protocol/dist/relay-pty-schemas.d.ts.map +0 -1
  1043. package/packages/protocol/dist/relay-pty-schemas.js +0 -60
  1044. package/packages/protocol/dist/relay-pty-schemas.js.map +0 -1
  1045. package/packages/protocol/dist/types.d.ts +0 -793
  1046. package/packages/protocol/dist/types.d.ts.map +0 -1
  1047. package/packages/protocol/dist/types.js +0 -8
  1048. package/packages/protocol/dist/types.js.map +0 -1
  1049. package/packages/protocol/package.json +0 -61
  1050. package/packages/protocol/src/channels.test.ts +0 -330
  1051. package/packages/protocol/src/channels.ts +0 -270
  1052. package/packages/protocol/src/framing.test.ts +0 -164
  1053. package/packages/protocol/src/framing.ts +0 -242
  1054. package/packages/protocol/src/id-generator.ts +0 -69
  1055. package/packages/protocol/src/index.ts +0 -4
  1056. package/packages/protocol/src/relay-pty-schemas.ts +0 -400
  1057. package/packages/protocol/src/types.test.ts +0 -271
  1058. package/packages/protocol/src/types.ts +0 -988
  1059. package/packages/protocol/tsconfig.json +0 -21
  1060. package/packages/protocol/vitest.config.ts +0 -9
  1061. package/packages/resiliency/dist/cgroup-manager.d.ts +0 -152
  1062. package/packages/resiliency/dist/cgroup-manager.d.ts.map +0 -1
  1063. package/packages/resiliency/dist/cgroup-manager.js +0 -394
  1064. package/packages/resiliency/dist/cgroup-manager.js.map +0 -1
  1065. package/packages/resiliency/dist/context-persistence.d.ts +0 -140
  1066. package/packages/resiliency/dist/context-persistence.d.ts.map +0 -1
  1067. package/packages/resiliency/dist/context-persistence.js +0 -397
  1068. package/packages/resiliency/dist/context-persistence.js.map +0 -1
  1069. package/packages/resiliency/dist/crash-insights.d.ts +0 -156
  1070. package/packages/resiliency/dist/crash-insights.d.ts.map +0 -1
  1071. package/packages/resiliency/dist/crash-insights.js +0 -492
  1072. package/packages/resiliency/dist/crash-insights.js.map +0 -1
  1073. package/packages/resiliency/dist/gossip-health.d.ts +0 -137
  1074. package/packages/resiliency/dist/gossip-health.d.ts.map +0 -1
  1075. package/packages/resiliency/dist/gossip-health.js +0 -241
  1076. package/packages/resiliency/dist/gossip-health.js.map +0 -1
  1077. package/packages/resiliency/dist/health-monitor.d.ts +0 -97
  1078. package/packages/resiliency/dist/health-monitor.d.ts.map +0 -1
  1079. package/packages/resiliency/dist/health-monitor.js +0 -291
  1080. package/packages/resiliency/dist/health-monitor.js.map +0 -1
  1081. package/packages/resiliency/dist/index.d.ts +0 -69
  1082. package/packages/resiliency/dist/index.d.ts.map +0 -1
  1083. package/packages/resiliency/dist/index.js +0 -69
  1084. package/packages/resiliency/dist/index.js.map +0 -1
  1085. package/packages/resiliency/dist/leader-watchdog.d.ts +0 -109
  1086. package/packages/resiliency/dist/leader-watchdog.d.ts.map +0 -1
  1087. package/packages/resiliency/dist/leader-watchdog.js +0 -189
  1088. package/packages/resiliency/dist/leader-watchdog.js.map +0 -1
  1089. package/packages/resiliency/dist/logger.d.ts +0 -114
  1090. package/packages/resiliency/dist/logger.d.ts.map +0 -1
  1091. package/packages/resiliency/dist/logger.js +0 -250
  1092. package/packages/resiliency/dist/logger.js.map +0 -1
  1093. package/packages/resiliency/dist/memory-monitor.d.ts +0 -172
  1094. package/packages/resiliency/dist/memory-monitor.d.ts.map +0 -1
  1095. package/packages/resiliency/dist/memory-monitor.js +0 -599
  1096. package/packages/resiliency/dist/memory-monitor.js.map +0 -1
  1097. package/packages/resiliency/dist/metrics.d.ts +0 -115
  1098. package/packages/resiliency/dist/metrics.d.ts.map +0 -1
  1099. package/packages/resiliency/dist/metrics.js +0 -239
  1100. package/packages/resiliency/dist/metrics.js.map +0 -1
  1101. package/packages/resiliency/dist/provider-context.d.ts +0 -100
  1102. package/packages/resiliency/dist/provider-context.d.ts.map +0 -1
  1103. package/packages/resiliency/dist/provider-context.js +0 -362
  1104. package/packages/resiliency/dist/provider-context.js.map +0 -1
  1105. package/packages/resiliency/dist/stateless-lead.d.ts +0 -149
  1106. package/packages/resiliency/dist/stateless-lead.d.ts.map +0 -1
  1107. package/packages/resiliency/dist/stateless-lead.js +0 -308
  1108. package/packages/resiliency/dist/stateless-lead.js.map +0 -1
  1109. package/packages/resiliency/dist/supervisor.d.ts +0 -147
  1110. package/packages/resiliency/dist/supervisor.d.ts.map +0 -1
  1111. package/packages/resiliency/dist/supervisor.js +0 -459
  1112. package/packages/resiliency/dist/supervisor.js.map +0 -1
  1113. package/packages/resiliency/package.json +0 -38
  1114. package/packages/resiliency/src/cgroup-manager.ts +0 -468
  1115. package/packages/resiliency/src/context-persistence.ts +0 -538
  1116. package/packages/resiliency/src/crash-insights.test.ts +0 -620
  1117. package/packages/resiliency/src/crash-insights.ts +0 -660
  1118. package/packages/resiliency/src/gossip-health.ts +0 -333
  1119. package/packages/resiliency/src/health-monitor.ts +0 -371
  1120. package/packages/resiliency/src/index.ts +0 -157
  1121. package/packages/resiliency/src/leader-watchdog.ts +0 -260
  1122. package/packages/resiliency/src/logger.ts +0 -320
  1123. package/packages/resiliency/src/memory-monitor.test.ts +0 -637
  1124. package/packages/resiliency/src/memory-monitor.ts +0 -740
  1125. package/packages/resiliency/src/metrics.ts +0 -311
  1126. package/packages/resiliency/src/provider-context.ts +0 -452
  1127. package/packages/resiliency/src/stateless-lead.ts +0 -408
  1128. package/packages/resiliency/src/supervisor.ts +0 -578
  1129. package/packages/resiliency/tsconfig.json +0 -21
  1130. package/packages/resiliency/vitest.config.ts +0 -9
  1131. package/packages/sdk/dist/discovery.d.ts +0 -10
  1132. package/packages/sdk/dist/discovery.d.ts.map +0 -1
  1133. package/packages/sdk/dist/discovery.js +0 -22
  1134. package/packages/sdk/dist/discovery.js.map +0 -1
  1135. package/packages/sdk/dist/errors.d.ts +0 -9
  1136. package/packages/sdk/dist/errors.d.ts.map +0 -1
  1137. package/packages/sdk/dist/errors.js +0 -9
  1138. package/packages/sdk/dist/errors.js.map +0 -1
  1139. package/packages/sdk/dist/protocol/index.d.ts +0 -8
  1140. package/packages/sdk/dist/protocol/index.d.ts.map +0 -1
  1141. package/packages/sdk/dist/protocol/index.js +0 -8
  1142. package/packages/sdk/dist/protocol/index.js.map +0 -1
  1143. package/packages/sdk/examples/SWARM_CAPABILITIES.md +0 -498
  1144. package/packages/sdk/examples/SWARM_PATTERNS.md +0 -541
  1145. package/packages/sdk/src/client.test.ts +0 -1041
  1146. package/packages/sdk/src/discovery.ts +0 -38
  1147. package/packages/sdk/src/errors.ts +0 -17
  1148. package/packages/sdk/src/logs.test.ts +0 -98
  1149. package/packages/sdk/src/protocol/framing.test.ts +0 -164
  1150. package/packages/sdk/src/protocol/index.ts +0 -8
  1151. package/packages/spawner/.trajectories/index.json +0 -5
  1152. package/packages/spawner/API.md +0 -256
  1153. package/packages/spawner/dist/index.d.ts +0 -8
  1154. package/packages/spawner/dist/index.d.ts.map +0 -1
  1155. package/packages/spawner/dist/index.js +0 -8
  1156. package/packages/spawner/dist/index.js.map +0 -1
  1157. package/packages/spawner/dist/types.d.ts +0 -552
  1158. package/packages/spawner/dist/types.d.ts.map +0 -1
  1159. package/packages/spawner/dist/types.js +0 -193
  1160. package/packages/spawner/dist/types.js.map +0 -1
  1161. package/packages/spawner/package.json +0 -47
  1162. package/packages/spawner/src/index.ts +0 -8
  1163. package/packages/spawner/src/types.test.ts +0 -385
  1164. package/packages/spawner/src/types.ts +0 -228
  1165. package/packages/spawner/tsconfig.json +0 -19
  1166. package/packages/spawner/vitest.config.ts +0 -9
  1167. package/packages/state/dist/agent-state.d.ts +0 -40
  1168. package/packages/state/dist/agent-state.d.ts.map +0 -1
  1169. package/packages/state/dist/agent-state.js +0 -120
  1170. package/packages/state/dist/agent-state.js.map +0 -1
  1171. package/packages/state/dist/index.d.ts +0 -8
  1172. package/packages/state/dist/index.d.ts.map +0 -1
  1173. package/packages/state/dist/index.js +0 -8
  1174. package/packages/state/dist/index.js.map +0 -1
  1175. package/packages/state/package.json +0 -37
  1176. package/packages/state/src/agent-state.test.ts +0 -335
  1177. package/packages/state/src/agent-state.ts +0 -153
  1178. package/packages/state/src/index.ts +0 -12
  1179. package/packages/state/tsconfig.json +0 -21
  1180. package/packages/state/vitest.config.ts +0 -9
  1181. package/packages/storage/dist/adapter.d.ts +0 -189
  1182. package/packages/storage/dist/adapter.d.ts.map +0 -1
  1183. package/packages/storage/dist/adapter.js +0 -267
  1184. package/packages/storage/dist/adapter.js.map +0 -1
  1185. package/packages/storage/dist/batched-sqlite-adapter.d.ts +0 -75
  1186. package/packages/storage/dist/batched-sqlite-adapter.d.ts.map +0 -1
  1187. package/packages/storage/dist/batched-sqlite-adapter.js +0 -189
  1188. package/packages/storage/dist/batched-sqlite-adapter.js.map +0 -1
  1189. package/packages/storage/dist/dead-letter-queue.d.ts +0 -196
  1190. package/packages/storage/dist/dead-letter-queue.d.ts.map +0 -1
  1191. package/packages/storage/dist/dead-letter-queue.js +0 -427
  1192. package/packages/storage/dist/dead-letter-queue.js.map +0 -1
  1193. package/packages/storage/dist/dlq-adapter.d.ts +0 -195
  1194. package/packages/storage/dist/dlq-adapter.d.ts.map +0 -1
  1195. package/packages/storage/dist/dlq-adapter.js +0 -664
  1196. package/packages/storage/dist/dlq-adapter.js.map +0 -1
  1197. package/packages/storage/dist/index.d.ts +0 -6
  1198. package/packages/storage/dist/index.d.ts.map +0 -1
  1199. package/packages/storage/dist/index.js +0 -7
  1200. package/packages/storage/dist/index.js.map +0 -1
  1201. package/packages/storage/dist/jsonl-adapter.d.ts +0 -91
  1202. package/packages/storage/dist/jsonl-adapter.d.ts.map +0 -1
  1203. package/packages/storage/dist/jsonl-adapter.js +0 -580
  1204. package/packages/storage/dist/jsonl-adapter.js.map +0 -1
  1205. package/packages/storage/dist/sqlite-adapter.d.ts +0 -131
  1206. package/packages/storage/dist/sqlite-adapter.d.ts.map +0 -1
  1207. package/packages/storage/dist/sqlite-adapter.js +0 -865
  1208. package/packages/storage/dist/sqlite-adapter.js.map +0 -1
  1209. package/packages/storage/package.json +0 -74
  1210. package/packages/storage/src/adapter.ts +0 -446
  1211. package/packages/storage/src/batched-sqlite-adapter.test.ts +0 -256
  1212. package/packages/storage/src/batched-sqlite-adapter.ts +0 -239
  1213. package/packages/storage/src/dead-letter-queue.ts +0 -643
  1214. package/packages/storage/src/dlq-adapter.test.ts +0 -509
  1215. package/packages/storage/src/dlq-adapter.ts +0 -954
  1216. package/packages/storage/src/index.ts +0 -6
  1217. package/packages/storage/src/jsonl-adapter.test.ts +0 -239
  1218. package/packages/storage/src/jsonl-adapter.ts +0 -704
  1219. package/packages/storage/src/memory-adapter.test.ts +0 -36
  1220. package/packages/storage/src/sqlite-adapter.test.ts +0 -580
  1221. package/packages/storage/src/sqlite-adapter.ts +0 -1099
  1222. package/packages/storage/tsconfig.json +0 -21
  1223. package/packages/storage/vitest.config.ts +0 -9
  1224. package/packages/wrapper/dist/__fixtures__/claude-outputs.d.ts +0 -49
  1225. package/packages/wrapper/dist/__fixtures__/claude-outputs.d.ts.map +0 -1
  1226. package/packages/wrapper/dist/__fixtures__/claude-outputs.js +0 -443
  1227. package/packages/wrapper/dist/__fixtures__/claude-outputs.js.map +0 -1
  1228. package/packages/wrapper/dist/__fixtures__/codex-outputs.d.ts +0 -9
  1229. package/packages/wrapper/dist/__fixtures__/codex-outputs.d.ts.map +0 -1
  1230. package/packages/wrapper/dist/__fixtures__/codex-outputs.js +0 -94
  1231. package/packages/wrapper/dist/__fixtures__/codex-outputs.js.map +0 -1
  1232. package/packages/wrapper/dist/__fixtures__/gemini-outputs.d.ts +0 -19
  1233. package/packages/wrapper/dist/__fixtures__/gemini-outputs.d.ts.map +0 -1
  1234. package/packages/wrapper/dist/__fixtures__/gemini-outputs.js +0 -144
  1235. package/packages/wrapper/dist/__fixtures__/gemini-outputs.js.map +0 -1
  1236. package/packages/wrapper/dist/__fixtures__/index.d.ts +0 -68
  1237. package/packages/wrapper/dist/__fixtures__/index.d.ts.map +0 -1
  1238. package/packages/wrapper/dist/__fixtures__/index.js +0 -44
  1239. package/packages/wrapper/dist/__fixtures__/index.js.map +0 -1
  1240. package/packages/wrapper/dist/auth-detection.d.ts +0 -49
  1241. package/packages/wrapper/dist/auth-detection.d.ts.map +0 -1
  1242. package/packages/wrapper/dist/auth-detection.js +0 -199
  1243. package/packages/wrapper/dist/auth-detection.js.map +0 -1
  1244. package/packages/wrapper/dist/base-wrapper.d.ts +0 -254
  1245. package/packages/wrapper/dist/base-wrapper.d.ts.map +0 -1
  1246. package/packages/wrapper/dist/base-wrapper.js +0 -664
  1247. package/packages/wrapper/dist/base-wrapper.js.map +0 -1
  1248. package/packages/wrapper/dist/client.d.ts +0 -291
  1249. package/packages/wrapper/dist/client.d.ts.map +0 -1
  1250. package/packages/wrapper/dist/client.js +0 -926
  1251. package/packages/wrapper/dist/client.js.map +0 -1
  1252. package/packages/wrapper/dist/id-generator.d.ts +0 -35
  1253. package/packages/wrapper/dist/id-generator.d.ts.map +0 -1
  1254. package/packages/wrapper/dist/id-generator.js +0 -60
  1255. package/packages/wrapper/dist/id-generator.js.map +0 -1
  1256. package/packages/wrapper/dist/idle-detector.d.ts +0 -114
  1257. package/packages/wrapper/dist/idle-detector.d.ts.map +0 -1
  1258. package/packages/wrapper/dist/idle-detector.js +0 -317
  1259. package/packages/wrapper/dist/idle-detector.js.map +0 -1
  1260. package/packages/wrapper/dist/inbox.d.ts +0 -37
  1261. package/packages/wrapper/dist/inbox.d.ts.map +0 -1
  1262. package/packages/wrapper/dist/inbox.js +0 -73
  1263. package/packages/wrapper/dist/inbox.js.map +0 -1
  1264. package/packages/wrapper/dist/index.d.ts +0 -40
  1265. package/packages/wrapper/dist/index.d.ts.map +0 -1
  1266. package/packages/wrapper/dist/index.js +0 -53
  1267. package/packages/wrapper/dist/index.js.map +0 -1
  1268. package/packages/wrapper/dist/opencode-api.d.ts +0 -106
  1269. package/packages/wrapper/dist/opencode-api.d.ts.map +0 -1
  1270. package/packages/wrapper/dist/opencode-api.js +0 -219
  1271. package/packages/wrapper/dist/opencode-api.js.map +0 -1
  1272. package/packages/wrapper/dist/opencode-wrapper.d.ts +0 -161
  1273. package/packages/wrapper/dist/opencode-wrapper.d.ts.map +0 -1
  1274. package/packages/wrapper/dist/opencode-wrapper.js +0 -438
  1275. package/packages/wrapper/dist/opencode-wrapper.js.map +0 -1
  1276. package/packages/wrapper/dist/parser.d.ts +0 -236
  1277. package/packages/wrapper/dist/parser.d.ts.map +0 -1
  1278. package/packages/wrapper/dist/parser.js +0 -1238
  1279. package/packages/wrapper/dist/parser.js.map +0 -1
  1280. package/packages/wrapper/dist/prompt-composer.d.ts +0 -67
  1281. package/packages/wrapper/dist/prompt-composer.d.ts.map +0 -1
  1282. package/packages/wrapper/dist/prompt-composer.js +0 -168
  1283. package/packages/wrapper/dist/prompt-composer.js.map +0 -1
  1284. package/packages/wrapper/dist/relay-pty-orchestrator.d.ts +0 -486
  1285. package/packages/wrapper/dist/relay-pty-orchestrator.d.ts.map +0 -1
  1286. package/packages/wrapper/dist/relay-pty-orchestrator.js +0 -2550
  1287. package/packages/wrapper/dist/relay-pty-orchestrator.js.map +0 -1
  1288. package/packages/wrapper/dist/shared.d.ts +0 -262
  1289. package/packages/wrapper/dist/shared.d.ts.map +0 -1
  1290. package/packages/wrapper/dist/shared.js +0 -507
  1291. package/packages/wrapper/dist/shared.js.map +0 -1
  1292. package/packages/wrapper/dist/stuck-detector.d.ts +0 -161
  1293. package/packages/wrapper/dist/stuck-detector.d.ts.map +0 -1
  1294. package/packages/wrapper/dist/stuck-detector.js +0 -402
  1295. package/packages/wrapper/dist/stuck-detector.js.map +0 -1
  1296. package/packages/wrapper/dist/tmux-resolver.d.ts +0 -55
  1297. package/packages/wrapper/dist/tmux-resolver.d.ts.map +0 -1
  1298. package/packages/wrapper/dist/tmux-resolver.js +0 -175
  1299. package/packages/wrapper/dist/tmux-resolver.js.map +0 -1
  1300. package/packages/wrapper/dist/tmux-wrapper.d.ts +0 -352
  1301. package/packages/wrapper/dist/tmux-wrapper.d.ts.map +0 -1
  1302. package/packages/wrapper/dist/tmux-wrapper.js +0 -1816
  1303. package/packages/wrapper/dist/tmux-wrapper.js.map +0 -1
  1304. package/packages/wrapper/dist/trajectory-integration.d.ts +0 -292
  1305. package/packages/wrapper/dist/trajectory-integration.d.ts.map +0 -1
  1306. package/packages/wrapper/dist/trajectory-integration.js +0 -979
  1307. package/packages/wrapper/dist/trajectory-integration.js.map +0 -1
  1308. package/packages/wrapper/dist/wrapper-events.d.ts +0 -489
  1309. package/packages/wrapper/dist/wrapper-events.d.ts.map +0 -1
  1310. package/packages/wrapper/dist/wrapper-events.js +0 -252
  1311. package/packages/wrapper/dist/wrapper-events.js.map +0 -1
  1312. package/packages/wrapper/dist/wrapper-types.d.ts +0 -41
  1313. package/packages/wrapper/dist/wrapper-types.d.ts.map +0 -1
  1314. package/packages/wrapper/dist/wrapper-types.js +0 -7
  1315. package/packages/wrapper/dist/wrapper-types.js.map +0 -1
  1316. package/packages/wrapper/package.json +0 -60
  1317. package/packages/wrapper/src/__fixtures__/claude-outputs.ts +0 -471
  1318. package/packages/wrapper/src/__fixtures__/codex-outputs.ts +0 -99
  1319. package/packages/wrapper/src/__fixtures__/gemini-outputs.ts +0 -151
  1320. package/packages/wrapper/src/__fixtures__/index.ts +0 -47
  1321. package/packages/wrapper/src/auth-detection.ts +0 -244
  1322. package/packages/wrapper/src/base-wrapper.test.ts +0 -589
  1323. package/packages/wrapper/src/base-wrapper.ts +0 -841
  1324. package/packages/wrapper/src/client.test.ts +0 -351
  1325. package/packages/wrapper/src/client.ts +0 -1166
  1326. package/packages/wrapper/src/id-generator.test.ts +0 -71
  1327. package/packages/wrapper/src/id-generator.ts +0 -69
  1328. package/packages/wrapper/src/idle-detector.test.ts +0 -418
  1329. package/packages/wrapper/src/idle-detector.ts +0 -384
  1330. package/packages/wrapper/src/inbox.test.ts +0 -233
  1331. package/packages/wrapper/src/inbox.ts +0 -89
  1332. package/packages/wrapper/src/index.ts +0 -199
  1333. package/packages/wrapper/src/opencode-api.test.ts +0 -292
  1334. package/packages/wrapper/src/opencode-api.ts +0 -285
  1335. package/packages/wrapper/src/opencode-wrapper.ts +0 -541
  1336. package/packages/wrapper/src/parser.regression.test.ts +0 -251
  1337. package/packages/wrapper/src/parser.test.ts +0 -1359
  1338. package/packages/wrapper/src/parser.ts +0 -1477
  1339. package/packages/wrapper/src/prompt-composer.test.ts +0 -219
  1340. package/packages/wrapper/src/prompt-composer.ts +0 -231
  1341. package/packages/wrapper/src/relay-pty-orchestrator.test.ts +0 -1386
  1342. package/packages/wrapper/src/relay-pty-orchestrator.ts +0 -3041
  1343. package/packages/wrapper/src/shared.test.ts +0 -467
  1344. package/packages/wrapper/src/shared.ts +0 -652
  1345. package/packages/wrapper/src/stuck-detector.test.ts +0 -303
  1346. package/packages/wrapper/src/stuck-detector.ts +0 -511
  1347. package/packages/wrapper/src/tmux-resolver.test.ts +0 -104
  1348. package/packages/wrapper/src/tmux-resolver.ts +0 -207
  1349. package/packages/wrapper/src/tmux-wrapper.test.ts +0 -316
  1350. package/packages/wrapper/src/tmux-wrapper.ts +0 -2095
  1351. package/packages/wrapper/src/trajectory-detection.test.ts +0 -151
  1352. package/packages/wrapper/src/trajectory-integration.ts +0 -1261
  1353. package/packages/wrapper/src/wrapper-events.ts +0 -395
  1354. package/packages/wrapper/src/wrapper-types.ts +0 -45
  1355. package/packages/wrapper/tsconfig.json +0 -19
  1356. package/packages/wrapper/vitest.config.ts +0 -9
  1357. /package/packages/{broker-sdk → sdk}/dist/__tests__/facade.test.d.ts +0 -0
  1358. /package/packages/{broker-sdk → sdk}/dist/__tests__/facade.test.d.ts.map +0 -0
  1359. /package/packages/{broker-sdk → sdk}/dist/__tests__/integration.test.d.ts +0 -0
  1360. /package/packages/{broker-sdk → sdk}/dist/__tests__/integration.test.d.ts.map +0 -0
  1361. /package/packages/{broker-sdk → sdk}/dist/__tests__/quickstart.test.d.ts +0 -0
  1362. /package/packages/{broker-sdk → sdk}/dist/__tests__/quickstart.test.d.ts.map +0 -0
  1363. /package/packages/{broker-sdk → sdk}/dist/__tests__/unit.test.d.ts +0 -0
  1364. /package/packages/{broker-sdk → sdk}/dist/__tests__/unit.test.d.ts.map +0 -0
  1365. /package/packages/{broker-sdk → sdk}/dist/browser.d.ts +0 -0
  1366. /package/packages/{broker-sdk → sdk}/dist/browser.d.ts.map +0 -0
  1367. /package/packages/{broker-sdk → sdk}/dist/browser.js +0 -0
  1368. /package/packages/{broker-sdk → sdk}/dist/browser.js.map +0 -0
  1369. /package/packages/{broker-sdk → sdk}/dist/consensus-helpers.d.ts +0 -0
  1370. /package/packages/{broker-sdk → sdk}/dist/consensus-helpers.d.ts.map +0 -0
  1371. /package/packages/{broker-sdk → sdk}/dist/consensus-helpers.js +0 -0
  1372. /package/packages/{broker-sdk → sdk}/dist/consensus-helpers.js.map +0 -0
  1373. /package/packages/{broker-sdk → sdk}/dist/consensus.d.ts +0 -0
  1374. /package/packages/{broker-sdk → sdk}/dist/consensus.d.ts.map +0 -0
  1375. /package/packages/{broker-sdk → sdk}/dist/consensus.js +0 -0
  1376. /package/packages/{broker-sdk → sdk}/dist/consensus.js.map +0 -0
  1377. /package/packages/{broker-sdk → sdk}/dist/examples/demo.d.ts +0 -0
  1378. /package/packages/{broker-sdk → sdk}/dist/examples/demo.d.ts.map +0 -0
  1379. /package/packages/{broker-sdk → sdk}/dist/examples/demo.js +0 -0
  1380. /package/packages/{broker-sdk → sdk}/dist/examples/demo.js.map +0 -0
  1381. /package/packages/{broker-sdk → sdk}/dist/examples/example.d.ts +0 -0
  1382. /package/packages/{broker-sdk → sdk}/dist/examples/example.d.ts.map +0 -0
  1383. /package/packages/{broker-sdk → sdk}/dist/examples/example.js +0 -0
  1384. /package/packages/{broker-sdk → sdk}/dist/examples/example.js.map +0 -0
  1385. /package/packages/{broker-sdk → sdk}/dist/examples/quickstart.d.ts +0 -0
  1386. /package/packages/{broker-sdk → sdk}/dist/examples/quickstart.d.ts.map +0 -0
  1387. /package/packages/{broker-sdk → sdk}/dist/examples/quickstart.js +0 -0
  1388. /package/packages/{broker-sdk → sdk}/dist/examples/quickstart.js.map +0 -0
  1389. /package/packages/{broker-sdk → sdk}/dist/examples/ralph-loop.d.ts +0 -0
  1390. /package/packages/{broker-sdk → sdk}/dist/examples/ralph-loop.d.ts.map +0 -0
  1391. /package/packages/{broker-sdk → sdk}/dist/examples/ralph-loop.js +0 -0
  1392. /package/packages/{broker-sdk → sdk}/dist/examples/ralph-loop.js.map +0 -0
  1393. /package/packages/{broker-sdk → sdk}/dist/protocol.js +0 -0
  1394. /package/packages/{broker-sdk → sdk}/dist/protocol.js.map +0 -0
  1395. /package/packages/{broker-sdk → sdk}/dist/pty.d.ts +0 -0
  1396. /package/packages/{broker-sdk → sdk}/dist/shadow.js +0 -0
  1397. /package/packages/{broker-sdk → sdk}/dist/workflows/barrier.d.ts +0 -0
  1398. /package/packages/{broker-sdk → sdk}/dist/workflows/barrier.d.ts.map +0 -0
  1399. /package/packages/{broker-sdk → sdk}/dist/workflows/barrier.js +0 -0
  1400. /package/packages/{broker-sdk → sdk}/dist/workflows/barrier.js.map +0 -0
  1401. /package/packages/{broker-sdk → sdk}/dist/workflows/memory-db.d.ts +0 -0
  1402. /package/packages/{broker-sdk → sdk}/dist/workflows/memory-db.d.ts.map +0 -0
  1403. /package/packages/{broker-sdk → sdk}/dist/workflows/memory-db.js +0 -0
  1404. /package/packages/{broker-sdk → sdk}/dist/workflows/memory-db.js.map +0 -0
  1405. /package/packages/{broker-sdk → sdk}/dist/workflows/state.d.ts +0 -0
  1406. /package/packages/{broker-sdk → sdk}/dist/workflows/state.d.ts.map +0 -0
  1407. /package/packages/{broker-sdk → sdk}/dist/workflows/state.js +0 -0
  1408. /package/packages/{broker-sdk → sdk}/dist/workflows/state.js.map +0 -0
  1409. /package/packages/{broker-sdk → sdk}/src/__tests__/workflow-trajectory.test.ts +0 -0
  1410. /package/packages/{broker-sdk → sdk}/src/browser.ts +0 -0
  1411. /package/packages/{broker-sdk → sdk}/src/consensus-helpers.ts +0 -0
  1412. /package/packages/{broker-sdk → sdk}/src/consensus.ts +0 -0
  1413. /package/packages/{broker-sdk → sdk}/src/examples/demo.ts +0 -0
  1414. /package/packages/{broker-sdk → sdk}/src/examples/example.ts +0 -0
  1415. /package/packages/{broker-sdk → sdk}/src/examples/quickstart.ts +0 -0
  1416. /package/packages/{broker-sdk → sdk}/src/examples/ralph-loop.ts +0 -0
  1417. /package/packages/{broker-sdk → sdk}/src/examples/sample-prd.json +0 -0
  1418. /package/packages/{broker-sdk → sdk}/src/workflows/barrier.ts +0 -0
  1419. /package/packages/{broker-sdk → sdk}/src/workflows/memory-db.ts +0 -0
  1420. /package/packages/{broker-sdk → sdk}/src/workflows/state.ts +0 -0
@@ -1,1816 +0,0 @@
1
- /**
2
- * TmuxWrapper - Attach-based tmux wrapper
3
- *
4
- * Architecture:
5
- * 1. Start agent in detached tmux session
6
- * 2. Attach user to tmux (they see real terminal)
7
- * 3. Background: poll capture-pane silently (no stdout writes)
8
- * 4. Background: parse ->relay commands, send to daemon
9
- * 5. Background: inject messages via send-keys
10
- *
11
- * The key insight: user sees the REAL tmux session, not a proxy.
12
- * We just do background parsing and injection.
13
- */
14
- import { exec, execSync, spawn } from 'node:child_process';
15
- import crypto from 'node:crypto';
16
- import { promisify } from 'node:util';
17
- import { BaseWrapper } from './base-wrapper.js';
18
- import { OutputParser, parseSummaryWithDetails, parseSessionEndFromOutput } from './parser.js';
19
- import { hasContinuityCommand, parseContinuityCommand, } from '@agent-relay/continuity';
20
- import { InboxManager } from './inbox.js';
21
- import { SqliteStorageAdapter } from '@agent-relay/storage/sqlite-adapter';
22
- import { getProjectPaths } from '@agent-relay/config/project-namespace';
23
- import { getTmuxPath } from '@agent-relay/wrapper';
24
- import { findAgentConfig } from '@agent-relay/config/agent-config';
25
- import { getTrajectoryIntegration, detectPhaseFromContent, detectToolCalls, detectErrors, getCompactTrailInstructions, getTrailEnvVars, } from '@agent-relay/wrapper';
26
- import { escapeForShell } from '@agent-relay/config/bridge-utils';
27
- import { detectProviderAuthRevocation } from './auth-detection.js';
28
- import { stripAnsi, sleep, getDefaultRelayPrefix, buildInjectionString, injectWithRetry as sharedInjectWithRetry, INJECTION_CONSTANTS, CLI_QUIRKS, AdaptiveThrottle, sortByPriority, getPriorityFromImportance, } from './shared.js';
29
- import { getTmuxPanePid } from './idle-detector.js';
30
- import { DEFAULT_TMUX_WRAPPER_CONFIG } from '@agent-relay/config/relay-config';
31
- const execAsync = promisify(exec);
32
- // Constants for cursor stability detection in waitForClearInput
33
- /** Number of consecutive polls with stable cursor before assuming input is clear */
34
- const STABLE_CURSOR_THRESHOLD = 3;
35
- /** Maximum cursor X position that indicates a prompt (typical prompts are 1-4 chars) */
36
- const MAX_PROMPT_CURSOR_POSITION = 4;
37
- /** Maximum characters to show in debug log truncation */
38
- const DEBUG_LOG_TRUNCATE_LENGTH = 40;
39
- /** Maximum characters to show in relay command log truncation */
40
- const RELAY_LOG_TRUNCATE_LENGTH = 50;
41
- /**
42
- * Get the default relay prefix for a given CLI type.
43
- * All agents now use '->relay:' as the unified prefix.
44
- * @deprecated Use getDefaultRelayPrefix() from shared.js instead
45
- */
46
- export function getDefaultPrefix(_cliType) {
47
- return getDefaultRelayPrefix();
48
- }
49
- export class TmuxWrapper extends BaseWrapper {
50
- config;
51
- sessionName;
52
- parser;
53
- inbox;
54
- storage;
55
- storageReady; // Resolves true if storage initialized, false if failed
56
- pollTimer;
57
- attachProcess;
58
- lastCapturedOutput = '';
59
- lastOutputTime = 0;
60
- lastActivityTime = Date.now();
61
- activityState = 'disconnected';
62
- recentlySentMessages = new Map();
63
- // Track processed output to avoid re-parsing
64
- processedOutputLength = 0;
65
- lastLoggedLength = 0; // Track length for incremental log streaming
66
- lastDebugLog = 0;
67
- lastSummaryHash = ''; // Dedup summary saves
68
- pendingRelayCommands = [];
69
- queuedMessageHashes = new Set(); // For offline queue dedup
70
- MAX_PENDING_RELAY_COMMANDS = 50;
71
- receivedMessageIdSet = new Set();
72
- receivedMessageIdOrder = [];
73
- MAX_RECEIVED_MESSAGES = 2000;
74
- tmuxPath; // Resolved path to tmux binary (system or bundled)
75
- trajectory; // Trajectory tracking via trail
76
- lastDetectedPhase; // Track last auto-detected PDERO phase
77
- seenToolCalls = new Set(); // Dedup tool call trajectory events
78
- seenErrors = new Set(); // Dedup error trajectory events
79
- authRevoked = false; // Track if auth has been revoked
80
- lastAuthCheck = 0; // Timestamp of last auth check (throttle)
81
- AUTH_CHECK_INTERVAL = 5000; // Check auth status every 5 seconds max
82
- // Adaptive throttle for message queue - adjusts delay based on success/failure
83
- throttle = new AdaptiveThrottle();
84
- constructor(config) {
85
- // Merge defaults with config
86
- const mergedConfig = {
87
- cols: process.stdout.columns || 120,
88
- rows: process.stdout.rows || 40,
89
- ...DEFAULT_TMUX_WRAPPER_CONFIG,
90
- ...config,
91
- };
92
- // Call parent constructor (initializes client, cliType, relayPrefix, continuity)
93
- super(mergedConfig);
94
- this.config = mergedConfig;
95
- // Session name (one agent per name - starting a duplicate kills the existing one)
96
- this.sessionName = `relay-${config.name}`;
97
- // Resolve tmux path early so we fail fast if tmux isn't available
98
- this.tmuxPath = getTmuxPath();
99
- // Auto-detect agent role from .claude/agents/ or .openagents/ if task not provided
100
- let detectedTask = this.config.task;
101
- if (!detectedTask) {
102
- const agentConfig = findAgentConfig(config.name, this.config.cwd);
103
- if (agentConfig?.description) {
104
- detectedTask = agentConfig.description;
105
- this.logStderr(`Auto-detected role: ${detectedTask.substring(0, 60)}...`, true);
106
- }
107
- }
108
- this.parser = new OutputParser({ prefix: this.relayPrefix });
109
- // Initialize inbox if using file-based messaging
110
- if (config.useInbox) {
111
- this.inbox = new InboxManager({
112
- agentName: config.name,
113
- inboxDir: config.inboxDir,
114
- });
115
- }
116
- // Initialize storage for session/summary persistence
117
- const projectPaths = getProjectPaths();
118
- this.storage = new SqliteStorageAdapter({ dbPath: projectPaths.dbPath });
119
- // Initialize asynchronously (don't block constructor) - methods await storageReady
120
- this.storageReady = this.storage.init().then(() => true).catch(err => {
121
- this.logStderr(`Failed to initialize storage: ${err.message}`, true);
122
- this.storage = undefined;
123
- return false;
124
- });
125
- // Initialize trajectory tracking via trail CLI
126
- this.trajectory = getTrajectoryIntegration(projectPaths.projectId, config.name);
127
- this.client.onStateChange = (state) => {
128
- // Only log to stderr, never stdout (user is in tmux)
129
- if (state === 'READY') {
130
- this.logStderr('Connected to relay daemon');
131
- this.flushQueuedRelayCommands();
132
- }
133
- else if (state === 'BACKOFF') {
134
- this.logStderr('Relay unavailable, will retry (backoff)');
135
- }
136
- else if (state === 'DISCONNECTED') {
137
- this.logStderr('Relay disconnected (offline mode)');
138
- }
139
- else if (state === 'CONNECTING') {
140
- this.logStderr('Connecting to relay daemon...');
141
- }
142
- };
143
- }
144
- // =========================================================================
145
- // Abstract method implementations
146
- // =========================================================================
147
- /**
148
- * Inject content into the tmux session via paste
149
- */
150
- async performInjection(content) {
151
- await this.pasteLiteral(content);
152
- }
153
- /**
154
- * Get cleaned output for parsing (strip ANSI codes)
155
- */
156
- getCleanOutput() {
157
- return stripAnsi(this.lastCapturedOutput);
158
- }
159
- /**
160
- * Log to stderr (safe - doesn't interfere with tmux display)
161
- */
162
- logStderr(msg, force = false) {
163
- if (!force && !this.config.debug)
164
- return;
165
- const now = Date.now();
166
- if (!force && this.config.debugLogIntervalMs && this.config.debugLogIntervalMs > 0) {
167
- if (now - this.lastDebugLog < this.config.debugLogIntervalMs) {
168
- return;
169
- }
170
- this.lastDebugLog = now;
171
- }
172
- // Prefix with newline to avoid corrupting tmux status line
173
- process.stderr.write(`\r[relay:${this.config.name}] ${msg}\n`);
174
- }
175
- /**
176
- * Detect PDERO phase from output content and auto-transition if needed.
177
- * Also detects tool calls and errors, recording them to the trajectory.
178
- */
179
- detectAndTransitionPhase(content) {
180
- if (!this.trajectory)
181
- return;
182
- // Detect phase transitions
183
- const detectedPhase = detectPhaseFromContent(content);
184
- if (detectedPhase && detectedPhase !== this.lastDetectedPhase) {
185
- const currentPhase = this.trajectory.getPhase();
186
- if (detectedPhase !== currentPhase) {
187
- this.trajectory.transition(detectedPhase, 'Auto-detected from output');
188
- this.lastDetectedPhase = detectedPhase;
189
- this.logStderr(`Phase transition: ${currentPhase || 'none'} → ${detectedPhase}`);
190
- }
191
- }
192
- // Detect and record tool calls
193
- // Note: We deduplicate by tool+status to record each unique tool type once per session
194
- // (e.g., "Read" started, "Read" completed). This provides a summary of tools used
195
- // without flooding the trajectory with every individual invocation.
196
- const tools = detectToolCalls(content);
197
- for (const tool of tools) {
198
- const key = `${tool.tool}:${tool.status || 'started'}`;
199
- if (!this.seenToolCalls.has(key)) {
200
- this.seenToolCalls.add(key);
201
- const statusLabel = tool.status === 'completed' ? ' (completed)' : '';
202
- this.trajectory.event(`Tool: ${tool.tool}${statusLabel}`, 'tool_call');
203
- }
204
- }
205
- // Detect and record errors
206
- const errors = detectErrors(content);
207
- for (const error of errors) {
208
- if (!this.seenErrors.has(error.message)) {
209
- this.seenErrors.add(error.message);
210
- const prefix = error.type === 'warning' ? 'Warning' : 'Error';
211
- this.trajectory.event(`${prefix}: ${error.message}`, 'error');
212
- }
213
- }
214
- }
215
- /**
216
- * Build the full command with proper quoting
217
- * Args containing spaces need to be quoted
218
- */
219
- buildCommand() {
220
- if (!this.config.args || this.config.args.length === 0) {
221
- return this.config.command;
222
- }
223
- // Quote any argument that contains spaces, quotes, or shell special chars
224
- // Must handle: spaces, quotes, $, <, >, |, &, ;, (, ), `, etc.
225
- const quotedArgs = this.config.args.map(arg => {
226
- if (/[\s"'$<>|&;()`,!\\]/.test(arg)) {
227
- // Use double quotes and escape internal quotes and special chars
228
- const escaped = arg
229
- .replace(/\\/g, '\\\\')
230
- .replace(/"/g, '\\"')
231
- .replace(/\$/g, '\\$')
232
- .replace(/`/g, '\\`')
233
- .replace(/!/g, '\\!');
234
- return `"${escaped}"`;
235
- }
236
- return arg;
237
- });
238
- return `${this.config.command} ${quotedArgs.join(' ')}`;
239
- }
240
- /**
241
- * Check if tmux session exists
242
- */
243
- async sessionExists() {
244
- try {
245
- await execAsync(`"${this.tmuxPath}" has-session -t ${this.sessionName} 2>/dev/null`);
246
- return true;
247
- }
248
- catch {
249
- return false;
250
- }
251
- }
252
- /**
253
- * Start the wrapped agent process
254
- */
255
- async start() {
256
- if (this.running)
257
- return;
258
- // Initialize inbox if enabled
259
- if (this.inbox) {
260
- this.inbox.init();
261
- }
262
- // Connect to relay daemon (in background, don't block)
263
- this.client.connect()
264
- .then(() => {
265
- this.logStderr(`Relay connected (state: ${this.client.state})`, true);
266
- })
267
- .catch((err) => {
268
- // Connection failures will retry via client backoff; surface once to stderr.
269
- this.logStderr(`Relay connect failed: ${err.message}. Will retry if enabled.`, true);
270
- this.logStderr(`Relay client state: ${this.client.state}`, true);
271
- });
272
- // Kill any existing session with this name
273
- try {
274
- execSync(`"${this.tmuxPath}" kill-session -t ${this.sessionName} 2>/dev/null`);
275
- }
276
- catch {
277
- // Session doesn't exist, that's fine
278
- }
279
- // Build the command - properly quote args that contain spaces
280
- const fullCommand = this.buildCommand();
281
- this.logStderr(`Command: ${fullCommand}`);
282
- this.logStderr(`Prefix: ${this.relayPrefix} (use ${this.relayPrefix}AgentName to send)`);
283
- // Create tmux session
284
- try {
285
- execSync(`"${this.tmuxPath}" new-session -d -s ${this.sessionName} -x ${this.config.cols} -y ${this.config.rows}`, {
286
- cwd: this.config.cwd ?? process.cwd(),
287
- stdio: 'pipe',
288
- });
289
- // Configure tmux for seamless scrolling
290
- // Mouse mode passes scroll events to the application when in alternate screen
291
- const tmuxSettings = [
292
- 'set -g set-clipboard on', // Enable clipboard
293
- 'set -g history-limit 50000', // Large scrollback for when needed
294
- 'setw -g alternate-screen on', // Ensure alternate screen works
295
- // Pass through mouse scroll to application in alternate screen mode
296
- 'set -ga terminal-overrides ",xterm*:Tc"',
297
- 'set -g status-left-length 100', // Provide ample space for agent name in status bar
298
- 'set -g mode-keys vi', // Predictable key table (avoid copy-mode surprises)
299
- ];
300
- // Add mouse mode if enabled (allows scroll passthrough to CLI apps)
301
- if (this.config.mouseMode) {
302
- tmuxSettings.unshift('set -g mouse on');
303
- this.logStderr('Mouse mode enabled (scroll should work in app)');
304
- }
305
- for (const setting of tmuxSettings) {
306
- try {
307
- execSync(`"${this.tmuxPath}" ${setting}`, { stdio: 'pipe' });
308
- }
309
- catch {
310
- // Some settings may not be available in older tmux versions
311
- }
312
- }
313
- // Mouse scroll should work for both TUIs (alternate screen) and plain shells.
314
- // If the pane is in alternate screen, pass scroll to the app; otherwise enter copy-mode and scroll tmux history.
315
- const tmuxMouseBindings = [
316
- 'unbind -T root WheelUpPane',
317
- 'unbind -T root WheelDownPane',
318
- 'unbind -T root MouseDrag1Pane',
319
- 'bind -T root WheelUpPane if-shell -F "#{alternate_on}" "send-keys -M" "copy-mode -e; send-keys -X scroll-up"',
320
- 'bind -T root WheelDownPane if-shell -F "#{alternate_on}" "send-keys -M" "send-keys -X scroll-down"',
321
- 'bind -T root MouseDrag1Pane if-shell -F "#{alternate_on}" "send-keys -M" "copy-mode -e"',
322
- ];
323
- for (const setting of tmuxMouseBindings) {
324
- try {
325
- execSync(`"${this.tmuxPath}" ${setting}`, { stdio: 'pipe' });
326
- }
327
- catch {
328
- // Ignore on older tmux versions lacking these key tables
329
- }
330
- }
331
- // Set environment variables including trail/trajectory vars
332
- const projectPaths = getProjectPaths();
333
- const trailEnvVars = getTrailEnvVars(projectPaths.projectId, this.config.name, projectPaths.dataDir);
334
- for (const [key, value] of Object.entries({
335
- ...this.config.env,
336
- ...trailEnvVars,
337
- AGENT_RELAY_NAME: this.config.name,
338
- TERM: 'xterm-256color',
339
- })) {
340
- // Use proper shell escaping to prevent command injection via env var values
341
- const escaped = escapeForShell(value);
342
- execSync(`"${this.tmuxPath}" setenv -t ${this.sessionName} ${key} "${escaped}"`);
343
- }
344
- // Wait for shell to be ready (look for prompt)
345
- await this.waitForShellReady();
346
- // Send the command to run
347
- this.logStderr('Sending command to tmux...');
348
- await this.sendKeysLiteral(fullCommand);
349
- await sleep(300); // Give shell time to process the command literal
350
- this.logStderr('Sending Enter...');
351
- await this.sendKeys('Enter');
352
- await sleep(500); // Ensure Enter is processed and command starts before we continue
353
- this.logStderr('Command sent');
354
- }
355
- catch (err) {
356
- throw new Error(`Failed to create tmux session: ${err.message}`);
357
- }
358
- // Wait for session to be ready
359
- await this.waitForSession();
360
- this.running = true;
361
- this.lastActivityTime = Date.now();
362
- this.activityState = 'active';
363
- // Initialize trajectory tracking (auto-start if task provided)
364
- this.initializeTrajectory();
365
- // Initialize continuity and get/create agentId
366
- this.initializeAgentId();
367
- // Start background polling (silent - no stdout writes)
368
- this.startSilentPolling();
369
- // Initialize idle detector with the tmux pane PID for process state inspection
370
- this.initializeIdleDetectorPid();
371
- this.startStuckDetection();
372
- // Wait for agent to be ready, then inject instructions
373
- // This replaces the fixed 3-second delay with actual readiness detection
374
- this.waitForAgentReady().then(() => {
375
- this.injectInstructions();
376
- }).catch(err => {
377
- this.logStderr(`Failed to wait for agent ready: ${err.message}`, true);
378
- // Fall back to injecting after a delay
379
- setTimeout(() => this.injectInstructions(), 3000);
380
- });
381
- // Attach user to tmux session
382
- // This takes over stdin/stdout - user sees the real terminal
383
- this.attachToSession();
384
- }
385
- /**
386
- * Initialize trajectory tracking
387
- * Auto-starts a trajectory if task is provided in config
388
- */
389
- async initializeTrajectory() {
390
- if (!this.trajectory)
391
- return;
392
- // Auto-start trajectory if task is provided
393
- if (this.config.task) {
394
- const success = await this.trajectory.initialize(this.config.task);
395
- if (success) {
396
- this.logStderr(`Trajectory started for task: ${this.config.task}`);
397
- }
398
- }
399
- else {
400
- // Just initialize without starting a trajectory
401
- await this.trajectory.initialize();
402
- }
403
- }
404
- /**
405
- * Initialize agent ID for continuity/resume functionality (uses logStderr for tmux)
406
- */
407
- async initializeAgentId() {
408
- if (!this.continuity)
409
- return;
410
- try {
411
- let ledger;
412
- // If resuming from a previous agent ID, try to find that ledger
413
- if (this.config.resumeAgentId) {
414
- ledger = await this.continuity.findLedgerByAgentId(this.config.resumeAgentId);
415
- if (ledger) {
416
- this.logStderr(`Resuming agent ID: ${ledger.agentId} (from previous session)`);
417
- }
418
- else {
419
- this.logStderr(`Resume agent ID ${this.config.resumeAgentId} not found, creating new`, true);
420
- }
421
- }
422
- // If not resuming or resume ID not found, get or create ledger
423
- if (!ledger) {
424
- ledger = await this.continuity.getOrCreateLedger(this.config.name, this.cliType);
425
- this.logStderr(`Agent ID: ${ledger.agentId} (use this to resume if agent dies)`);
426
- }
427
- this.agentId = ledger.agentId;
428
- }
429
- catch (err) {
430
- this.logStderr(`Failed to initialize agent ID: ${err.message}`, true);
431
- }
432
- }
433
- /**
434
- * Initialize the idle detector with the tmux pane PID.
435
- * This enables process state inspection on Linux for more reliable idle detection.
436
- */
437
- async initializeIdleDetectorPid() {
438
- try {
439
- const pid = await getTmuxPanePid(this.tmuxPath, this.sessionName);
440
- if (pid) {
441
- this.setIdleDetectorPid(pid);
442
- this.logStderr(`Idle detector initialized with PID ${pid}`);
443
- }
444
- else {
445
- this.logStderr('Could not get pane PID for idle detection (will use output analysis)');
446
- }
447
- }
448
- catch (err) {
449
- this.logStderr(`Failed to initialize idle detector PID: ${err.message}`);
450
- }
451
- }
452
- /**
453
- * Wait for the agent to be ready for input.
454
- * Uses idle detection instead of a fixed delay.
455
- */
456
- async waitForAgentReady() {
457
- // Minimum wait to ensure the CLI process has started
458
- await sleep(500);
459
- // Wait for agent to become idle (CLI fully initialized)
460
- const result = await this.waitForIdleState(10000, 200);
461
- if (result.isIdle) {
462
- this.logStderr(`Agent ready (confidence: ${(result.confidence * 100).toFixed(0)}%)`);
463
- }
464
- else {
465
- this.logStderr('Agent readiness timeout, proceeding anyway');
466
- }
467
- }
468
- /**
469
- * Inject usage instructions for the agent including persistence protocol
470
- */
471
- async injectInstructions() {
472
- if (!this.running)
473
- return;
474
- if (this.config.skipInstructions)
475
- return;
476
- // Use escaped prefix (\->relay:) in examples to prevent parser from treating them as real commands
477
- const escapedPrefix = '\\' + this.relayPrefix;
478
- // Build instructions including relay and trail
479
- const relayInstructions = [
480
- `[Agent Relay] You are "${this.config.name}" - connected for real-time messaging.`,
481
- `SEND: ${escapedPrefix}AgentName message`,
482
- `MULTI-LINE: ${escapedPrefix}AgentName <<<(newline)content(newline)>>> - ALWAYS end with >>> on its own line!`,
483
- `IMPORTANT: Do NOT include self-identification or preamble in messages. Start with your actual response content.`,
484
- `PERSIST: Output [[SUMMARY]]{"currentTask":"...","context":"..."}[[/SUMMARY]] after major work.`,
485
- `END: Output [[SESSION_END]]{"summary":"..."}[[/SESSION_END]] when session complete.`,
486
- ].join(' | ');
487
- // Add trail instructions if available
488
- const trailInstructions = getCompactTrailInstructions();
489
- try {
490
- await this.sendKeysLiteral(relayInstructions);
491
- await sleep(50);
492
- await this.sendKeys('Enter');
493
- // Inject trail instructions
494
- if (this.trajectory?.isTrailInstalledSync()) {
495
- await sleep(100);
496
- await this.sendKeysLiteral(trailInstructions);
497
- await sleep(50);
498
- await this.sendKeys('Enter');
499
- }
500
- // Inject continuity context from previous session
501
- await this.injectContinuityContext();
502
- }
503
- catch {
504
- // Silent fail - instructions are nice-to-have
505
- }
506
- }
507
- /**
508
- * Inject continuity context from previous session
509
- */
510
- async injectContinuityContext() {
511
- if (!this.continuity || !this.running)
512
- return;
513
- try {
514
- const context = await this.continuity.getStartupContext(this.config.name);
515
- if (context && context.formatted) {
516
- // Inject a brief notification about loaded context
517
- const notification = `[Continuity] Previous session context loaded. ${context.ledger ? `Task: ${context.ledger.currentTask?.slice(0, 50) || 'unknown'}` : ''}${context.handoff ? ` | Last handoff: ${context.handoff.createdAt.toISOString().split('T')[0]}` : ''}`;
518
- await sleep(200);
519
- await this.sendKeysLiteral(notification);
520
- await sleep(50);
521
- await this.sendKeys('Enter');
522
- // Queue the full context for injection when agent is ready
523
- this.messageQueue.push({
524
- from: 'system',
525
- body: context.formatted,
526
- messageId: `continuity-startup-${Date.now()}`,
527
- });
528
- this.checkForInjectionOpportunity();
529
- if (this.config.debug) {
530
- this.logStderr(`[CONTINUITY] Loaded context for ${this.config.name}`);
531
- }
532
- }
533
- }
534
- catch (err) {
535
- this.logStderr(`[CONTINUITY] Failed to load context: ${err.message}`, true);
536
- }
537
- }
538
- /**
539
- * Wait for tmux session to be ready
540
- */
541
- async waitForSession(maxWaitMs = 5000) {
542
- const startTime = Date.now();
543
- while (Date.now() - startTime < maxWaitMs) {
544
- if (await this.sessionExists()) {
545
- await new Promise(r => setTimeout(r, 200));
546
- return;
547
- }
548
- await new Promise(r => setTimeout(r, 100));
549
- }
550
- throw new Error('Timeout waiting for tmux session');
551
- }
552
- /**
553
- * Wait for shell prompt to appear (shell is ready for input)
554
- */
555
- async waitForShellReady(maxWaitMs = 10000) {
556
- const startTime = Date.now();
557
- // Common prompt endings: $, %, >, ➜, #
558
- const promptPatterns = /[$%>#➜]\s*$/;
559
- this.logStderr('Waiting for shell to initialize...');
560
- while (Date.now() - startTime < maxWaitMs) {
561
- try {
562
- const { stdout } = await execAsync(
563
- // -J joins wrapped lines so long prompts/messages stay intact
564
- `"${this.tmuxPath}" capture-pane -t ${this.sessionName} -p -J 2>/dev/null`);
565
- // Check if the last non-empty line looks like a prompt
566
- const lines = stdout.split('\n').filter(l => l.trim());
567
- const lastLine = lines[lines.length - 1] || '';
568
- if (promptPatterns.test(lastLine)) {
569
- this.logStderr('Shell ready');
570
- // Extra delay to ensure shell is fully ready
571
- await sleep(200);
572
- return;
573
- }
574
- }
575
- catch {
576
- // Session might not be ready yet
577
- }
578
- await sleep(200);
579
- }
580
- // Fallback: proceed anyway after timeout
581
- this.logStderr('Shell ready timeout, proceeding anyway');
582
- }
583
- /**
584
- * Attach user to tmux session
585
- * This spawns tmux attach and lets it take over stdin/stdout
586
- */
587
- attachToSession() {
588
- this.attachProcess = spawn(this.tmuxPath, ['attach-session', '-t', this.sessionName], {
589
- stdio: 'inherit', // User's terminal connects directly to tmux
590
- });
591
- this.attachProcess.on('exit', (code) => {
592
- this.logStderr(`Session ended (code: ${code})`, true);
593
- this.stop();
594
- process.exit(code ?? 0);
595
- });
596
- this.attachProcess.on('error', (err) => {
597
- this.logStderr(`Attach error: ${err.message}`, true);
598
- this.stop();
599
- process.exit(1);
600
- });
601
- // Handle signals
602
- const cleanup = () => {
603
- this.stop();
604
- };
605
- process.on('SIGINT', cleanup);
606
- process.on('SIGTERM', cleanup);
607
- }
608
- /**
609
- * Start silent polling for ->relay commands
610
- * Does NOT write to stdout - just parses and sends to daemon
611
- */
612
- startSilentPolling() {
613
- this.pollTimer = setInterval(() => {
614
- this.pollForRelayCommands().catch(() => {
615
- // Ignore poll errors
616
- });
617
- }, this.config.pollInterval);
618
- }
619
- /**
620
- * Poll for ->relay commands in output (silent)
621
- */
622
- async pollForRelayCommands() {
623
- if (!this.running)
624
- return;
625
- try {
626
- // Capture scrollback
627
- const { stdout } = await execAsync(
628
- // -J joins wrapped lines to avoid truncating ->relay commands mid-line
629
- `"${this.tmuxPath}" capture-pane -t ${this.sessionName} -p -J -S - 2>/dev/null`);
630
- // Always parse the FULL capture for ->relay commands
631
- // This handles terminal UIs that rewrite content in place
632
- const cleanContent = stripAnsi(stdout);
633
- // Join continuation lines that TUIs split across multiple lines
634
- const joinedContent = this.joinContinuationLines(cleanContent);
635
- const { commands, output: filteredOutput } = this.parser.parse(joinedContent);
636
- // Debug: log relay commands being parsed
637
- if (commands.length > 0 && this.config.debug) {
638
- for (const cmd of commands) {
639
- const bodyPreview = cmd.body.substring(0, 80).replace(/\n/g, '\\n');
640
- this.logStderr(`[RELAY_PARSED] to=${cmd.to}, body="${bodyPreview}...", lines=${cmd.body.split('\n').length}`);
641
- }
642
- }
643
- // Track last output time for injection timing
644
- if (stdout.length !== this.processedOutputLength) {
645
- this.lastOutputTime = Date.now();
646
- this.markActivity();
647
- // Feed new output to idle detector for more robust idle detection
648
- const newOutput = stdout.substring(this.processedOutputLength);
649
- this.feedIdleDetectorOutput(newOutput);
650
- this.processedOutputLength = stdout.length;
651
- // Stream new output to daemon for dashboard log viewing
652
- // Use filtered output to exclude thinking blocks and relay commands
653
- if (this.config.streamLogs && this.client.state === 'READY') {
654
- // Send incremental filtered output since last log
655
- const newContent = filteredOutput.substring(this.lastLoggedLength);
656
- if (newContent.length > 0) {
657
- this.client.sendLog(newContent);
658
- this.lastLoggedLength = filteredOutput.length;
659
- }
660
- }
661
- }
662
- // Send any commands found (deduplication handles repeats)
663
- for (const cmd of commands) {
664
- this.sendRelayCommand(cmd);
665
- }
666
- // Check for [[SUMMARY]] blocks and save to storage
667
- this.parseSummaryAndSave(cleanContent);
668
- // Detect PDERO phase transitions from output content
669
- this.detectAndTransitionPhase(cleanContent);
670
- // Parse and handle continuity commands (->continuity:save, ->continuity:load, etc.)
671
- await this.parseContinuityCommands(joinedContent);
672
- // Check for [[SESSION_END]] blocks to explicitly close session
673
- this.parseSessionEndAndClose(cleanContent);
674
- // Check for ->relay:spawn and ->relay:release commands (any agent can spawn)
675
- // Use joinedContent to handle multi-line output from TUIs like Claude Code
676
- this.parseSpawnReleaseCommands(joinedContent);
677
- // Check for auth revocation (limited sessions scenario)
678
- this.checkAuthRevocation(cleanContent);
679
- this.updateActivityState();
680
- // Also check for injection opportunity
681
- this.checkForInjectionOpportunity();
682
- }
683
- catch (err) {
684
- if (err.message?.includes('no such session')) {
685
- this.stop();
686
- }
687
- }
688
- }
689
- /**
690
- * Record recent activity and transition back to active if needed.
691
- */
692
- markActivity() {
693
- this.lastActivityTime = Date.now();
694
- if (this.activityState === 'idle') {
695
- this.activityState = 'active';
696
- this.logStderr('Session active');
697
- }
698
- }
699
- /**
700
- * Update activity state based on idle threshold and trigger injections when idle.
701
- */
702
- updateActivityState() {
703
- if (this.activityState === 'disconnected')
704
- return;
705
- const now = Date.now();
706
- const idleThreshold = this.config.activityIdleThresholdMs ?? 30000;
707
- const timeSinceActivity = now - this.lastActivityTime;
708
- if (timeSinceActivity > idleThreshold && this.activityState === 'active') {
709
- this.activityState = 'idle';
710
- this.logStderr('Session went idle');
711
- this.checkForInjectionOpportunity();
712
- }
713
- else if (timeSinceActivity <= idleThreshold && this.activityState === 'idle') {
714
- this.activityState = 'active';
715
- this.logStderr('Session active');
716
- }
717
- }
718
- /**
719
- * Check if the CLI output indicates auth has been revoked.
720
- * This can happen when the user authenticates elsewhere (limited sessions).
721
- */
722
- checkAuthRevocation(output) {
723
- // Don't check if already revoked or if we checked recently
724
- if (this.authRevoked)
725
- return;
726
- const now = Date.now();
727
- if (now - this.lastAuthCheck < this.AUTH_CHECK_INTERVAL)
728
- return;
729
- this.lastAuthCheck = now;
730
- // Get the CLI type/provider from config
731
- const provider = this.config.program || this.cliType || 'claude';
732
- // Check for auth revocation patterns in recent output
733
- const result = detectProviderAuthRevocation(output, provider);
734
- if (result.detected && result.confidence !== 'low') {
735
- this.authRevoked = true;
736
- this.logStderr(`[AUTH] Auth revocation detected (${result.confidence} confidence): ${result.message}`);
737
- // Send auth status message to daemon
738
- if (this.client.state === 'READY') {
739
- const authPayload = JSON.stringify({
740
- type: 'auth_revoked',
741
- agent: this.config.name,
742
- provider,
743
- message: result.message,
744
- confidence: result.confidence,
745
- timestamp: new Date().toISOString(),
746
- });
747
- this.client.sendMessage('#system', authPayload, 'message');
748
- }
749
- // Emit event for listeners
750
- this.emit('auth_revoked', {
751
- agent: this.config.name,
752
- provider,
753
- message: result.message,
754
- confidence: result.confidence,
755
- });
756
- }
757
- }
758
- /**
759
- * Reset auth revocation state (called after successful re-authentication)
760
- */
761
- resetAuthState() {
762
- this.authRevoked = false;
763
- this.lastAuthCheck = 0;
764
- this.logStderr('[AUTH] Auth state reset');
765
- }
766
- /**
767
- * Check if auth has been revoked
768
- */
769
- isAuthRevoked() {
770
- return this.authRevoked;
771
- }
772
- /**
773
- * Send relay command to daemon (overrides BaseWrapper for offline queue support)
774
- */
775
- sendRelayCommand(cmd) {
776
- const msgHash = `${cmd.to}:${cmd.body}`;
777
- // Permanent dedup - never send the same message twice
778
- if (this.sentMessageHashes.has(msgHash)) {
779
- this.logStderr(`[DEDUP] Skipped duplicate message to ${cmd.to} (hash already sent)`);
780
- return;
781
- }
782
- // If client not ready, queue for later and return
783
- if (this.client.state !== 'READY') {
784
- if (this.queuedMessageHashes.has(msgHash)) {
785
- return; // Already queued
786
- }
787
- if (this.pendingRelayCommands.length >= this.MAX_PENDING_RELAY_COMMANDS) {
788
- this.logStderr('Relay offline queue full, dropping oldest');
789
- const dropped = this.pendingRelayCommands.shift();
790
- if (dropped) {
791
- this.queuedMessageHashes.delete(`${dropped.to}:${dropped.body}`);
792
- }
793
- }
794
- this.pendingRelayCommands.push(cmd);
795
- this.queuedMessageHashes.add(msgHash);
796
- this.logStderr(`Relay offline; queued message to ${cmd.to}`);
797
- return;
798
- }
799
- // Convert ParsedMessageMetadata to SendMeta if present
800
- let sendMeta;
801
- if (cmd.meta) {
802
- sendMeta = {
803
- importance: cmd.meta.importance,
804
- replyTo: cmd.meta.replyTo,
805
- requires_ack: cmd.meta.ackRequired,
806
- };
807
- }
808
- // Check if target is a channel (starts with #)
809
- if (cmd.to.startsWith('#')) {
810
- // Use CHANNEL_MESSAGE protocol for channel targets
811
- this.logStderr(`→ [channel] ${cmd.to}: ${cmd.body.substring(0, Math.min(RELAY_LOG_TRUNCATE_LENGTH, cmd.body.length))}...`);
812
- const success = this.client.sendChannelMessage(cmd.to, cmd.body, {
813
- thread: cmd.thread,
814
- data: cmd.data,
815
- });
816
- if (success) {
817
- this.sentMessageHashes.add(msgHash);
818
- this.queuedMessageHashes.delete(msgHash);
819
- this.trajectory?.message('sent', this.config.name, cmd.to, cmd.body);
820
- }
821
- return;
822
- }
823
- // Use SEND protocol for direct messages and broadcasts
824
- if (cmd.sync?.blocking) {
825
- this.client.sendAndWait(cmd.to, cmd.body, {
826
- timeoutMs: cmd.sync.timeoutMs,
827
- kind: cmd.kind,
828
- data: cmd.data,
829
- thread: cmd.thread,
830
- }).then(() => {
831
- this.sentMessageHashes.add(msgHash);
832
- this.queuedMessageHashes.delete(msgHash);
833
- }).catch((err) => {
834
- this.logStderr(`sendAndWait failed for ${cmd.to}: ${err.message}`, true);
835
- });
836
- return;
837
- }
838
- const success = this.client.sendMessage(cmd.to, cmd.body, cmd.kind, cmd.data, cmd.thread, sendMeta);
839
- if (success) {
840
- this.sentMessageHashes.add(msgHash);
841
- this.queuedMessageHashes.delete(msgHash);
842
- const truncatedBody = cmd.body.substring(0, Math.min(RELAY_LOG_TRUNCATE_LENGTH, cmd.body.length));
843
- this.logStderr(`→ ${cmd.to}: ${truncatedBody}...`);
844
- // Record in trajectory via trail
845
- this.trajectory?.message('sent', this.config.name, cmd.to, cmd.body);
846
- }
847
- else if (this.client.state !== 'READY') {
848
- // Only log failure once per state change
849
- this.logStderr(`Send failed (client ${this.client.state})`);
850
- }
851
- }
852
- /**
853
- * Flush any queued relay commands when the client reconnects.
854
- */
855
- flushQueuedRelayCommands() {
856
- if (this.pendingRelayCommands.length === 0)
857
- return;
858
- const queued = [...this.pendingRelayCommands];
859
- this.pendingRelayCommands = [];
860
- this.queuedMessageHashes.clear();
861
- for (const cmd of queued) {
862
- this.sendRelayCommand(cmd);
863
- }
864
- }
865
- /**
866
- * Parse [[SUMMARY]] blocks from output and save to storage.
867
- * Agents can output summaries to maintain running context:
868
- *
869
- * [[SUMMARY]]
870
- * {"currentTask": "Implementing auth", "context": "Completed login flow"}
871
- * [[/SUMMARY]]
872
- */
873
- parseSummaryAndSave(content) {
874
- const result = parseSummaryWithDetails(content);
875
- // No SUMMARY block found
876
- if (!result.found)
877
- return;
878
- // Dedup based on raw content - prevents repeated error logging for same invalid JSON
879
- if (result.rawContent === this.lastSummaryRawContent)
880
- return;
881
- this.lastSummaryRawContent = result.rawContent || '';
882
- // Invalid JSON - log error once (deduped above)
883
- if (!result.valid) {
884
- this.logStderr('[parser] Invalid JSON in SUMMARY block');
885
- return;
886
- }
887
- const summary = result.summary;
888
- // Dedup valid summaries - don't save same summary twice
889
- const summaryHash = JSON.stringify(summary);
890
- if (summaryHash === this.lastSummaryHash)
891
- return;
892
- this.lastSummaryHash = summaryHash;
893
- // Save to continuity ledger for session recovery
894
- // This ensures the ledger has actual data instead of placeholders
895
- if (this.continuity) {
896
- this.saveSummaryToLedger(summary).catch(err => {
897
- this.logStderr(`Failed to save summary to ledger: ${err.message}`, true);
898
- });
899
- }
900
- // Wait for storage to be ready before saving to project storage
901
- this.storageReady.then(ready => {
902
- if (!ready || !this.storage) {
903
- this.logStderr('Cannot save summary: storage not initialized');
904
- return;
905
- }
906
- const projectPaths = getProjectPaths();
907
- this.storage.saveAgentSummary({
908
- agentName: this.config.name,
909
- projectId: projectPaths.projectId,
910
- currentTask: summary.currentTask,
911
- completedTasks: summary.completedTasks,
912
- decisions: summary.decisions,
913
- context: summary.context,
914
- files: summary.files,
915
- }).then(() => {
916
- this.logStderr(`Saved agent summary: ${summary.currentTask || 'updated context'}`);
917
- }).catch(err => {
918
- this.logStderr(`Failed to save summary: ${err.message}`, true);
919
- });
920
- });
921
- }
922
- /**
923
- * Save a parsed summary to the continuity ledger (uses logStderr for tmux).
924
- * Maps summary fields to ledger fields for session recovery.
925
- */
926
- async saveSummaryToLedger(summary) {
927
- if (!this.continuity)
928
- return;
929
- const updates = {};
930
- // Map summary fields to ledger fields
931
- if (summary.currentTask) {
932
- updates.currentTask = summary.currentTask;
933
- }
934
- if (summary.completedTasks && summary.completedTasks.length > 0) {
935
- updates.completed = summary.completedTasks;
936
- }
937
- if (summary.context) {
938
- // Store context in inProgress as "next steps" hint
939
- updates.inProgress = [summary.context];
940
- }
941
- if (summary.files && summary.files.length > 0) {
942
- updates.fileContext = summary.files.map((f) => ({ path: f }));
943
- }
944
- // Only save if we have meaningful updates
945
- if (Object.keys(updates).length > 0) {
946
- await this.continuity.saveLedger(this.config.name, updates);
947
- this.logStderr('Saved summary to continuity ledger');
948
- }
949
- }
950
- /**
951
- * Parse ->continuity: commands from output and handle them.
952
- * Supported commands:
953
- * ->continuity:save <<<...>>> - Save session state to ledger
954
- * ->continuity:load - Request context injection
955
- * ->continuity:search "query" - Search past handoffs
956
- * ->continuity:uncertain "..." - Mark item as uncertain
957
- * ->continuity:handoff <<<...>>> - Create explicit handoff
958
- */
959
- async parseContinuityCommands(content) {
960
- if (!this.continuity)
961
- return;
962
- if (!hasContinuityCommand(content))
963
- return;
964
- const command = parseContinuityCommand(content);
965
- if (!command)
966
- return;
967
- // Create a hash for deduplication
968
- // For commands with content (save, handoff, uncertain), use content hash
969
- // For commands without content (load, search), allow each unique call
970
- const hasContent = command.content || command.query || command.item;
971
- const cmdHash = hasContent
972
- ? `${command.type}:${command.content || command.query || command.item}`
973
- : `${command.type}:${Date.now()}`; // Allow load/search to run each time
974
- if (hasContent && this.processedContinuityCommands.has(cmdHash))
975
- return;
976
- this.processedContinuityCommands.add(cmdHash);
977
- // Limit dedup set size
978
- if (this.processedContinuityCommands.size > 100) {
979
- const oldest = this.processedContinuityCommands.values().next().value;
980
- if (oldest)
981
- this.processedContinuityCommands.delete(oldest);
982
- }
983
- try {
984
- if (this.config.debug) {
985
- this.logStderr(`[CONTINUITY] Processing ${command.type} command`);
986
- }
987
- const response = await this.continuity.handleCommand(this.config.name, command);
988
- // If there's a response (e.g., from load or search), inject it
989
- if (response) {
990
- this.messageQueue.push({
991
- from: 'system',
992
- body: response,
993
- messageId: `continuity-${Date.now()}`,
994
- });
995
- this.checkForInjectionOpportunity();
996
- }
997
- }
998
- catch (err) {
999
- this.logStderr(`[CONTINUITY] Error: ${err.message}`, true);
1000
- }
1001
- }
1002
- /**
1003
- * Parse [[SESSION_END]] blocks from output and close session explicitly.
1004
- * Agents output this to mark their work session as complete:
1005
- *
1006
- * [[SESSION_END]]
1007
- * {"summary": "Completed auth module", "completedTasks": ["login", "logout"]}
1008
- * [[/SESSION_END]]
1009
- *
1010
- * Also stores the data for use in autoSave to populate handoff (fixes empty handoff issue).
1011
- */
1012
- parseSessionEndAndClose(content) {
1013
- if (this.sessionEndProcessed)
1014
- return; // Only process once per session
1015
- const sessionEnd = parseSessionEndFromOutput(content);
1016
- if (!sessionEnd)
1017
- return;
1018
- // Store SESSION_END data for use in autoSave (fixes empty handoff issue)
1019
- this.sessionEndData = sessionEnd;
1020
- // Get session ID from client connection - if not available yet, don't set flag
1021
- // so we can retry when sessionId becomes available
1022
- const sessionId = this.client.currentSessionId;
1023
- if (!sessionId) {
1024
- this.logStderr('Cannot close session: no session ID yet, will retry');
1025
- return;
1026
- }
1027
- this.sessionEndProcessed = true;
1028
- // Wait for storage to be ready before attempting to close session
1029
- this.storageReady.then(ready => {
1030
- if (!ready || !this.storage) {
1031
- this.logStderr('Cannot close session: storage not initialized');
1032
- return;
1033
- }
1034
- this.storage.endSession(sessionId, {
1035
- summary: sessionEnd.summary,
1036
- closedBy: 'agent',
1037
- }).then(() => {
1038
- this.logStderr(`Session closed by agent: ${sessionEnd.summary || 'complete'}`);
1039
- }).catch(err => {
1040
- this.logStderr(`Failed to close session: ${err.message}`, true);
1041
- });
1042
- });
1043
- }
1044
- /**
1045
- * Execute spawn via API (if dashboardPort set) or callback.
1046
- * After spawning, waits for the agent to come online and sends the task via relay.
1047
- */
1048
- async executeSpawn(name, cli, task) {
1049
- let spawned = false;
1050
- if (this.config.dashboardPort) {
1051
- // Use dashboard API for spawning (works from any context, no terminal required)
1052
- try {
1053
- const response = await fetch(`http://localhost:${this.config.dashboardPort}/api/spawn`, {
1054
- method: 'POST',
1055
- headers: { 'Content-Type': 'application/json' },
1056
- body: JSON.stringify({ name, cli }), // No task - we send it after agent is online
1057
- });
1058
- const result = await response.json();
1059
- if (result.success) {
1060
- this.logStderr(`Spawned ${name} via API`);
1061
- spawned = true;
1062
- }
1063
- else {
1064
- this.logStderr(`Spawn failed: ${result.error}`, true);
1065
- }
1066
- }
1067
- catch (err) {
1068
- this.logStderr(`Spawn API call failed: ${err.message}`, true);
1069
- }
1070
- }
1071
- else if (this.config.onSpawn) {
1072
- // Fall back to callback
1073
- try {
1074
- await this.config.onSpawn(name, cli, task);
1075
- spawned = true;
1076
- }
1077
- catch (err) {
1078
- this.logStderr(`Spawn failed: ${err.message}`, true);
1079
- }
1080
- }
1081
- // If spawn succeeded and we have a task, wait for agent to come online and send it
1082
- if (spawned && task && task.trim() && this.config.dashboardPort) {
1083
- await this.waitAndSendTask(name, task);
1084
- }
1085
- }
1086
- /**
1087
- * Wait for a spawned agent to come online, then send the task via relay.
1088
- * Uses the wrapper's own relay client so the message comes "from" this agent,
1089
- * not from the dashboard's relay client.
1090
- */
1091
- async waitAndSendTask(agentName, task) {
1092
- const maxWaitMs = 30000;
1093
- const pollIntervalMs = 500;
1094
- const startTime = Date.now();
1095
- this.logStderr(`Waiting for ${agentName} to come online...`);
1096
- // Poll for agent to be online using dedicated status endpoint
1097
- while (Date.now() - startTime < maxWaitMs) {
1098
- try {
1099
- const response = await fetch(`http://localhost:${this.config.dashboardPort}/api/agents/${encodeURIComponent(agentName)}/online`);
1100
- const data = await response.json();
1101
- if (data.online) {
1102
- this.logStderr(`${agentName} is online, sending task...`);
1103
- // Send task directly via our relay client (not dashboard API)
1104
- // This ensures the message comes "from" this agent, not from Dashboard
1105
- if (this.client.state === 'READY') {
1106
- const sent = this.client.sendMessage(agentName, task, 'message');
1107
- if (sent) {
1108
- this.logStderr(`Task sent to ${agentName}`);
1109
- }
1110
- else {
1111
- this.logStderr(`Failed to send task to ${agentName}: sendMessage returned false`, true);
1112
- }
1113
- }
1114
- else {
1115
- this.logStderr(`Failed to send task to ${agentName}: relay client not ready (state: ${this.client.state})`, true);
1116
- }
1117
- return;
1118
- }
1119
- }
1120
- catch (_err) {
1121
- // Ignore poll errors, keep trying
1122
- }
1123
- await sleep(pollIntervalMs);
1124
- }
1125
- this.logStderr(`Timeout waiting for ${agentName} to come online`, true);
1126
- }
1127
- /**
1128
- * Execute release via API (if dashboardPort set) or callback
1129
- */
1130
- async executeRelease(name) {
1131
- if (this.config.dashboardPort) {
1132
- // Use dashboard API for release (works from any context, no terminal required)
1133
- try {
1134
- const response = await fetch(`http://localhost:${this.config.dashboardPort}/api/spawned/${encodeURIComponent(name)}`, {
1135
- method: 'DELETE',
1136
- });
1137
- const result = await response.json();
1138
- if (result.success) {
1139
- this.logStderr(`Released ${name} via API`);
1140
- }
1141
- else {
1142
- this.logStderr(`Release failed: ${result.error}`, true);
1143
- }
1144
- }
1145
- catch (err) {
1146
- this.logStderr(`Release API call failed: ${err.message}`, true);
1147
- }
1148
- }
1149
- else if (this.config.onRelease) {
1150
- // Fall back to callback
1151
- try {
1152
- await this.config.onRelease(name);
1153
- }
1154
- catch (err) {
1155
- this.logStderr(`Release failed: ${err.message}`, true);
1156
- }
1157
- }
1158
- }
1159
- /**
1160
- * Parse ->relay:spawn and ->relay:release commands from output.
1161
- * Supports two formats:
1162
- * Single-line: ->relay:spawn WorkerName cli "task description"
1163
- * Multi-line (fenced): ->relay:spawn WorkerName cli <<<
1164
- * task description here
1165
- * can span multiple lines>>>
1166
- * ->relay:release WorkerName
1167
- */
1168
- parseSpawnReleaseCommands(content) {
1169
- // Only process if we have API or callbacks configured
1170
- const canSpawn = this.config.dashboardPort || this.config.onSpawn;
1171
- const canRelease = this.config.dashboardPort || this.config.onRelease;
1172
- // Debug: Log spawn capability status
1173
- if (content.includes('->relay:spawn')) {
1174
- this.logStderr(`[spawn-debug] canSpawn=${!!canSpawn} dashboardPort=${this.config.dashboardPort} hasOnSpawn=${!!this.config.onSpawn}`);
1175
- }
1176
- if (!canSpawn && !canRelease)
1177
- return;
1178
- const lines = content.split('\n');
1179
- // Pattern to strip common line prefixes (bullets, prompts, etc.)
1180
- // Must include ● (U+25CF BLACK CIRCLE) used by Claude's TUI
1181
- const linePrefixPattern = /^(?:[>$%#→➜›»●•◦‣⁃\-*⏺◆◇○□■│┃┆┇┊┋╎╏✦]\s*)+/;
1182
- for (const line of lines) {
1183
- let trimmed = line.trim();
1184
- // Strip common line prefixes (bullets, prompts) before checking for commands
1185
- trimmed = trimmed.replace(linePrefixPattern, '');
1186
- // Fix for over-stripping: the linePrefixPattern includes - and > characters,
1187
- // which can accidentally strip the -> from ->relay:spawn, leaving just relay:spawn.
1188
- // If we detect this happened, restore the -> prefix.
1189
- if (/^(relay|thinking|continuity):/.test(trimmed)) {
1190
- trimmed = '->' + trimmed;
1191
- }
1192
- // If we're in fenced spawn mode, accumulate lines until we see >>>
1193
- if (this.pendingFencedSpawn) {
1194
- // Check for fence close (>>> at end of line or on its own line)
1195
- const closeIdx = trimmed.indexOf('>>>');
1196
- if (closeIdx !== -1) {
1197
- // Add content before >>> to task
1198
- const contentBeforeClose = trimmed.substring(0, closeIdx);
1199
- if (contentBeforeClose) {
1200
- this.pendingFencedSpawn.taskLines.push(contentBeforeClose);
1201
- }
1202
- // Execute the spawn with accumulated task
1203
- const { name, cli, taskLines } = this.pendingFencedSpawn;
1204
- const taskStr = taskLines.join('\n').trim();
1205
- const spawnKey = `${name}:${cli}`;
1206
- if (!this.processedSpawnCommands.has(spawnKey)) {
1207
- this.processedSpawnCommands.add(spawnKey);
1208
- if (taskStr) {
1209
- this.logStderr(`Spawn command (fenced): ${name} (${cli}) - "${taskStr.substring(0, 50)}..."`);
1210
- }
1211
- else {
1212
- this.logStderr(`Spawn command (fenced): ${name} (${cli}) - no task`);
1213
- }
1214
- this.executeSpawn(name, cli, taskStr);
1215
- }
1216
- this.pendingFencedSpawn = null;
1217
- }
1218
- else {
1219
- // Accumulate line as part of task
1220
- this.pendingFencedSpawn.taskLines.push(line);
1221
- }
1222
- continue;
1223
- }
1224
- // Check for fenced spawn start: ->relay:spawn Name [cli] <<< (CLI optional, defaults to 'claude')
1225
- // Prefixes are stripped above, so we just look for the command at start of line
1226
- const fencedSpawnMatch = trimmed.match(/^->relay:spawn\s+(\S+)(?:\s+(\S+))?\s+<<<(.*)$/);
1227
- if (fencedSpawnMatch && canSpawn) {
1228
- const [, name, cliOrUndefined, inlineContent] = fencedSpawnMatch;
1229
- const cli = cliOrUndefined || 'claude';
1230
- // Validate name
1231
- if (name.length < 2) {
1232
- this.logStderr(`Fenced spawn has invalid name, skipping: name=${name}`);
1233
- continue;
1234
- }
1235
- // Check if fence closes on same line (e.g., ->relay:spawn Worker cli <<<task>>>)
1236
- const inlineCloseIdx = inlineContent.indexOf('>>>');
1237
- if (inlineCloseIdx !== -1) {
1238
- // Single line fenced: extract task between <<< and >>>
1239
- const taskStr = inlineContent.substring(0, inlineCloseIdx).trim();
1240
- const spawnKey = `${name}:${cli}`;
1241
- if (!this.processedSpawnCommands.has(spawnKey)) {
1242
- this.processedSpawnCommands.add(spawnKey);
1243
- if (taskStr) {
1244
- this.logStderr(`Spawn command: ${name} (${cli}) - "${taskStr.substring(0, 50)}..."`);
1245
- }
1246
- else {
1247
- this.logStderr(`Spawn command: ${name} (${cli}) - no task`);
1248
- }
1249
- this.executeSpawn(name, cli, taskStr);
1250
- }
1251
- }
1252
- else {
1253
- // Start multi-line fenced mode
1254
- this.pendingFencedSpawn = {
1255
- name,
1256
- cli,
1257
- taskLines: inlineContent.trim() ? [inlineContent.trim()] : [],
1258
- };
1259
- this.logStderr(`Starting fenced spawn capture: ${name} (${cli})`);
1260
- }
1261
- continue;
1262
- }
1263
- // Match single-line spawn: ->relay:spawn WorkerName [cli] ["task"]
1264
- // CLI is optional - defaults to 'claude'. Task is also optional.
1265
- // Prefixes are stripped above, so we just look for the command at start of line
1266
- const spawnMatch = trimmed.match(/^->relay:spawn\s+(\S+)(?:\s+(\S+))?(?:\s+["'](.+?)["'])?\s*$/);
1267
- if (spawnMatch && canSpawn) {
1268
- const [, name, cliOrUndefined, task] = spawnMatch;
1269
- const cli = cliOrUndefined || 'claude';
1270
- // Validate the parsed values
1271
- if (cli === '<<<' || cli === '>>>' || name === '<<<' || name === '>>>') {
1272
- this.logStderr(`Invalid spawn command (fence markers), skipping: name=${name}, cli=${cli}`);
1273
- continue;
1274
- }
1275
- if (name.length < 2) {
1276
- this.logStderr(`Spawn command has suspiciously short name, skipping: name=${name}`);
1277
- continue;
1278
- }
1279
- const taskStr = task || '';
1280
- const spawnKey = `${name}:${cli}`;
1281
- if (!this.processedSpawnCommands.has(spawnKey)) {
1282
- this.processedSpawnCommands.add(spawnKey);
1283
- if (taskStr) {
1284
- this.logStderr(`Spawn command: ${name} (${cli}) - "${taskStr.substring(0, 50)}..."`);
1285
- }
1286
- else {
1287
- this.logStderr(`Spawn command: ${name} (${cli}) - no task`);
1288
- }
1289
- this.executeSpawn(name, cli, taskStr);
1290
- }
1291
- continue;
1292
- }
1293
- // Match ->relay:release WorkerName
1294
- // Prefixes are stripped above, so we just look for the command at start of line
1295
- const releaseMatch = trimmed.match(/^->relay:release\s+(\S+)\s*$/);
1296
- if (releaseMatch && canRelease) {
1297
- const [, name] = releaseMatch;
1298
- if (!this.processedReleaseCommands.has(name)) {
1299
- this.processedReleaseCommands.add(name);
1300
- this.logStderr(`Release command: ${name}`);
1301
- this.executeRelease(name);
1302
- }
1303
- }
1304
- }
1305
- }
1306
- /**
1307
- * Handle incoming message from relay
1308
- * @param originalTo - The original 'to' field from sender. '*' indicates this was a broadcast message.
1309
- * Agents should reply to originalTo to maintain channel routing (e.g., respond to #general, not DM).
1310
- */
1311
- handleIncomingMessage(from, payload, messageId, meta, originalTo) {
1312
- if (this.hasSeenIncoming(messageId)) {
1313
- this.logStderr(`← ${from}: duplicate delivery (${messageId.substring(0, 8)})`);
1314
- return;
1315
- }
1316
- const truncatedBody = payload.body.substring(0, Math.min(DEBUG_LOG_TRUNCATE_LENGTH, payload.body.length));
1317
- const channelInfo = originalTo === '*' ? ' [broadcast]' : '';
1318
- this.logStderr(`← ${from}${channelInfo}: ${truncatedBody}...`);
1319
- // Record in trajectory via trail
1320
- this.trajectory?.message('received', from, this.config.name, payload.body);
1321
- // Queue for injection - include originalTo so we can inform the agent how to route responses
1322
- this.messageQueue.push({
1323
- from,
1324
- body: payload.body,
1325
- messageId,
1326
- thread: payload.thread,
1327
- importance: meta?.importance,
1328
- data: payload.data,
1329
- sync: meta?.sync,
1330
- originalTo,
1331
- });
1332
- // Write to inbox if enabled
1333
- if (this.inbox) {
1334
- this.inbox.addMessage(from, payload.body);
1335
- }
1336
- // Try to inject
1337
- this.checkForInjectionOpportunity();
1338
- }
1339
- /**
1340
- * Handle incoming channel message from relay.
1341
- * Channel messages include a channel indicator so the agent knows to reply to the channel.
1342
- */
1343
- handleIncomingChannelMessage(from, channel, body, envelope) {
1344
- const messageId = envelope.id;
1345
- if (this.hasSeenIncoming(messageId)) {
1346
- this.logStderr(`← ${from} [${channel}]: duplicate delivery (${messageId.substring(0, 8)})`);
1347
- return;
1348
- }
1349
- const truncatedBody = body.substring(0, Math.min(DEBUG_LOG_TRUNCATE_LENGTH, body.length));
1350
- this.logStderr(`← ${from} [${channel}]: ${truncatedBody}...`);
1351
- // Record in trajectory via trail
1352
- this.trajectory?.message('received', from, this.config.name, body);
1353
- // Queue for injection - include channel as originalTo so we can inform the agent how to route responses
1354
- this.messageQueue.push({
1355
- from,
1356
- body,
1357
- messageId,
1358
- thread: envelope.payload.thread,
1359
- data: {
1360
- _isChannelMessage: true,
1361
- _channel: channel,
1362
- _mentions: envelope.payload.mentions,
1363
- },
1364
- originalTo: channel, // Set channel as the reply target
1365
- });
1366
- // Write to inbox if enabled
1367
- if (this.inbox) {
1368
- this.inbox.addMessage(from, body);
1369
- }
1370
- // Try to inject
1371
- this.checkForInjectionOpportunity();
1372
- }
1373
- /**
1374
- * Check if we should inject a message.
1375
- * Uses UniversalIdleDetector (from BaseWrapper) for robust cross-CLI idle detection.
1376
- * Processes messages by priority (urgent first).
1377
- */
1378
- checkForInjectionOpportunity() {
1379
- if (this.messageQueue.length === 0)
1380
- return;
1381
- if (this.isInjecting)
1382
- return;
1383
- if (!this.running)
1384
- return;
1385
- // Sort queue by priority before processing (urgent messages first)
1386
- if (this.messageQueue.length > 1) {
1387
- this.messageQueue = sortByPriority(this.messageQueue);
1388
- }
1389
- // Check the priority of the next message
1390
- const nextMsg = this.messageQueue[0];
1391
- const priority = getPriorityFromImportance(nextMsg?.importance);
1392
- // Use universal idle detector for more reliable detection (inherited from BaseWrapper)
1393
- const idleResult = this.checkIdleForInjection();
1394
- // Urgent messages (priority 0) can proceed with lower idle confidence
1395
- const idleThreshold = priority === 0 ? 0.5 : 0.7;
1396
- if (!idleResult.isIdle && idleResult.confidence < idleThreshold) {
1397
- // Not idle yet, retry later (urgent messages retry faster)
1398
- const baseRetryMs = this.config.injectRetryMs ?? 300;
1399
- const retryMs = priority <= 1 ? Math.floor(baseRetryMs / 2) : baseRetryMs;
1400
- setTimeout(() => this.checkForInjectionOpportunity(), retryMs);
1401
- return;
1402
- }
1403
- this.injectNextMessage();
1404
- }
1405
- /**
1406
- * Inject message via tmux send-keys.
1407
- * Uses shared injection logic with tmux-specific callbacks.
1408
- */
1409
- async injectNextMessage() {
1410
- const msg = this.messageQueue.shift();
1411
- if (!msg)
1412
- return;
1413
- this.isInjecting = true;
1414
- try {
1415
- const shortId = msg.messageId.substring(0, 8);
1416
- // Wait for input to be clear before injecting
1417
- // If input is not clear (human typing), re-queue and try later - never clear forcefully!
1418
- const waitTimeoutMs = this.config.inputWaitTimeoutMs ?? 5000;
1419
- const waitPollMs = this.config.inputWaitPollMs ?? 200;
1420
- const inputClear = await this.waitForClearInput(waitTimeoutMs, waitPollMs);
1421
- if (!inputClear) {
1422
- // Input still has text after timeout - DON'T clear forcefully, re-queue instead
1423
- this.logStderr('Input not clear, re-queuing injection');
1424
- this.messageQueue.unshift(msg);
1425
- this.isInjecting = false;
1426
- setTimeout(() => this.checkForInjectionOpportunity(), this.config.injectRetryMs ?? 1000);
1427
- return;
1428
- }
1429
- // Ensure pane output is stable to avoid interleaving with active generation
1430
- // Pass message priority for adaptive timeout (urgent messages wait less)
1431
- const msgPriority = getPriorityFromImportance(msg.importance);
1432
- const stablePane = await this.waitForStablePane(this.config.outputStabilityTimeoutMs ?? 800, this.config.outputStabilityPollMs ?? 150, 2, msgPriority);
1433
- if (!stablePane) {
1434
- this.logStderr('Output still active, re-queuing injection');
1435
- this.messageQueue.unshift(msg);
1436
- this.isInjecting = false;
1437
- setTimeout(() => this.checkForInjectionOpportunity(), this.config.injectRetryMs ?? 300);
1438
- return;
1439
- }
1440
- // For Gemini: check if we're at a shell prompt ($) vs chat prompt (>)
1441
- // If at shell prompt, skip injection to avoid shell command execution
1442
- if (this.cliType === 'gemini') {
1443
- const lastLine = await this.getLastLine();
1444
- const cleanLine = stripAnsi(lastLine).trim();
1445
- if (CLI_QUIRKS.isShellPrompt(cleanLine)) {
1446
- this.logStderr('Gemini at shell prompt, skipping injection to avoid shell execution');
1447
- // Re-queue the message for later
1448
- this.messageQueue.unshift(msg);
1449
- this.isInjecting = false;
1450
- setTimeout(() => this.checkForInjectionOpportunity(), 2000);
1451
- return;
1452
- }
1453
- }
1454
- // Build injection string using shared utility
1455
- let injection = buildInjectionString(msg);
1456
- // Gemini-specific: wrap body in backticks to prevent shell keyword interpretation
1457
- if (this.cliType === 'gemini') {
1458
- const colonIdx = injection.indexOf(': ');
1459
- if (colonIdx > 0) {
1460
- const prefix = injection.substring(0, colonIdx + 2);
1461
- const body = injection.substring(colonIdx + 2);
1462
- injection = prefix + CLI_QUIRKS.wrapForGemini(body);
1463
- }
1464
- }
1465
- // Create callbacks for shared injection logic
1466
- const callbacks = {
1467
- getOutput: async () => {
1468
- try {
1469
- const { stdout } = await execAsync(`"${this.tmuxPath}" capture-pane -t ${this.sessionName} -p -S - 2>/dev/null`);
1470
- return stdout;
1471
- }
1472
- catch {
1473
- return '';
1474
- }
1475
- },
1476
- performInjection: async (inj) => {
1477
- // Use send-keys -l (literal) instead of paste-buffer
1478
- // paste-buffer causes issues where Claude shows "[Pasted text]" but content doesn't appear
1479
- await this.sendKeysLiteral(inj);
1480
- await sleep(INJECTION_CONSTANTS.ENTER_DELAY_MS);
1481
- await this.sendKeys('Enter');
1482
- },
1483
- log: (message) => this.logStderr(message),
1484
- logError: (message) => this.logStderr(message, true),
1485
- getMetrics: () => this.injectionMetrics,
1486
- };
1487
- // Inject with retry and verification using shared logic
1488
- const result = await sharedInjectWithRetry(injection, shortId, msg.from, callbacks);
1489
- if (result.success) {
1490
- this.logStderr(`Injection complete (attempt ${result.attempts})`);
1491
- // Record success for adaptive throttling
1492
- this.throttle.recordSuccess();
1493
- this.sendSyncAck(msg.messageId, msg.sync, 'OK');
1494
- }
1495
- else {
1496
- // All retries failed - log and optionally fall back to inbox
1497
- this.logStderr(`Message delivery failed after ${result.attempts} attempts: from=${msg.from} id=${shortId}`, true);
1498
- // Record failure for adaptive throttling
1499
- this.throttle.recordFailure();
1500
- // Write to inbox as fallback if enabled
1501
- if (this.inbox) {
1502
- this.inbox.addMessage(msg.from, msg.body);
1503
- this.logStderr('Wrote message to inbox as fallback');
1504
- }
1505
- this.sendSyncAck(msg.messageId, msg.sync, 'ERROR', { error: 'injection_failed' });
1506
- }
1507
- }
1508
- catch (err) {
1509
- this.logStderr(`Injection failed: ${err.message}`, true);
1510
- // Record failure for adaptive throttling
1511
- this.throttle.recordFailure();
1512
- this.sendSyncAck(msg.messageId, msg.sync, 'ERROR', { error: err.message });
1513
- }
1514
- finally {
1515
- this.isInjecting = false;
1516
- // Process next message after adaptive delay (faster when healthy, slower under stress)
1517
- if (this.messageQueue.length > 0) {
1518
- const delay = this.throttle.getDelay();
1519
- setTimeout(() => this.checkForInjectionOpportunity(), delay);
1520
- }
1521
- }
1522
- }
1523
- hasSeenIncoming(messageId) {
1524
- if (this.receivedMessageIdSet.has(messageId)) {
1525
- return true;
1526
- }
1527
- this.receivedMessageIdSet.add(messageId);
1528
- this.receivedMessageIdOrder.push(messageId);
1529
- if (this.receivedMessageIdOrder.length > this.MAX_RECEIVED_MESSAGES) {
1530
- const oldest = this.receivedMessageIdOrder.shift();
1531
- if (oldest) {
1532
- this.receivedMessageIdSet.delete(oldest);
1533
- }
1534
- }
1535
- return false;
1536
- }
1537
- /**
1538
- * Send special keys to tmux
1539
- */
1540
- async sendKeys(keys) {
1541
- const cmd = `"${this.tmuxPath}" send-keys -t ${this.sessionName} ${keys}`;
1542
- try {
1543
- await execAsync(cmd);
1544
- this.logStderr(`[sendKeys] Sent: ${keys}`);
1545
- }
1546
- catch (err) {
1547
- this.logStderr(`[sendKeys] Failed to send ${keys}: ${err.message}`, true);
1548
- throw err;
1549
- }
1550
- }
1551
- /**
1552
- * Send literal text to tmux
1553
- */
1554
- async sendKeysLiteral(text) {
1555
- // Escape for shell and use -l for literal
1556
- // Must escape: \ " $ ` ! and remove any newlines
1557
- const escaped = text
1558
- .replace(/[\r\n]+/g, ' ') // Remove any newlines first
1559
- .replace(/\\/g, '\\\\')
1560
- .replace(/"/g, '\\"')
1561
- .replace(/\$/g, '\\$')
1562
- .replace(/`/g, '\\`')
1563
- .replace(/!/g, '\\!');
1564
- try {
1565
- await execAsync(`"${this.tmuxPath}" send-keys -t ${this.sessionName} -l "${escaped}"`);
1566
- this.logStderr(`[sendKeysLiteral] Sent ${text.length} chars`);
1567
- }
1568
- catch (err) {
1569
- this.logStderr(`[sendKeysLiteral] Failed: ${err.message}`, true);
1570
- throw err;
1571
- }
1572
- }
1573
- /**
1574
- * Paste text using tmux buffer with optional bracketed paste to avoid interleaving with ongoing output.
1575
- * Some CLIs (like droid) don't handle bracketed paste sequences properly, so we skip -p for them.
1576
- */
1577
- async pasteLiteral(text) {
1578
- // Sanitize newlines to keep injection single-line inside paste buffer
1579
- const sanitized = text.replace(/[\r\n]+/g, ' ');
1580
- const escaped = sanitized
1581
- .replace(/\\/g, '\\\\')
1582
- .replace(/"/g, '\\"')
1583
- .replace(/\$/g, '\\$')
1584
- .replace(/`/g, '\\`')
1585
- .replace(/!/g, '\\!');
1586
- // Set tmux buffer then paste
1587
- const setBufferCmd = `"${this.tmuxPath}" set-buffer -- "${escaped}"`;
1588
- await execAsync(setBufferCmd);
1589
- await execAsync(`"${this.tmuxPath}" paste-buffer -t ${this.sessionName}`);
1590
- }
1591
- /**
1592
- * Reset session-specific state for wrapper reuse.
1593
- * Call this when starting a new session with the same wrapper instance.
1594
- */
1595
- resetSessionState() {
1596
- super.resetSessionState();
1597
- // TmuxWrapper-specific state
1598
- this.lastSummaryHash = '';
1599
- }
1600
- /**
1601
- * Get the prompt pattern for the current CLI type.
1602
- */
1603
- getPromptPattern() {
1604
- return CLI_QUIRKS.getPromptPattern(this.cliType);
1605
- }
1606
- /**
1607
- * Capture the last non-empty line from the tmux pane.
1608
- */
1609
- async getLastLine() {
1610
- try {
1611
- const { stdout } = await execAsync(`"${this.tmuxPath}" capture-pane -t ${this.sessionName} -p -J 2>/dev/null`);
1612
- const lines = stdout.split('\n').filter(l => l.length > 0);
1613
- return lines[lines.length - 1] || '';
1614
- }
1615
- catch {
1616
- return '';
1617
- }
1618
- }
1619
- /**
1620
- * Detect if the provided line contains visible user input (beyond the prompt).
1621
- */
1622
- hasVisibleInput(line) {
1623
- const cleanLine = stripAnsi(line).trimEnd();
1624
- if (cleanLine === '')
1625
- return false;
1626
- return !this.getPromptPattern().test(cleanLine);
1627
- }
1628
- /**
1629
- * Check if the input line is clear (no user-typed text after the prompt).
1630
- * Returns true if the last visible line appears to be just a prompt.
1631
- */
1632
- async isInputClear(lastLine) {
1633
- try {
1634
- const lineToCheck = lastLine ?? await this.getLastLine();
1635
- const cleanLine = stripAnsi(lineToCheck).trimEnd();
1636
- const isClear = this.getPromptPattern().test(cleanLine);
1637
- if (this.config.debug) {
1638
- const truncatedLine = cleanLine.substring(0, Math.min(DEBUG_LOG_TRUNCATE_LENGTH, cleanLine.length));
1639
- this.logStderr(`isInputClear: lastLine="${truncatedLine}", clear=${isClear}`);
1640
- }
1641
- return isClear;
1642
- }
1643
- catch {
1644
- // If we can't capture, assume not clear (safer)
1645
- return false;
1646
- }
1647
- }
1648
- /**
1649
- * Get cursor X position to detect input length.
1650
- * Returns the cursor column (0-indexed).
1651
- */
1652
- async getCursorX() {
1653
- try {
1654
- const { stdout } = await execAsync(`"${this.tmuxPath}" display-message -t ${this.sessionName} -p "#{cursor_x}" 2>/dev/null`);
1655
- return parseInt(stdout.trim(), 10) || 0;
1656
- }
1657
- catch {
1658
- return 0;
1659
- }
1660
- }
1661
- /**
1662
- * Wait for the input line to be clear before injecting.
1663
- * Polls until the input appears empty or timeout is reached.
1664
- *
1665
- * @param maxWaitMs Maximum time to wait (default 5000ms)
1666
- * @param pollIntervalMs How often to check (default 200ms)
1667
- * @returns true if input became clear, false if timed out
1668
- */
1669
- async waitForClearInput(maxWaitMs = 5000, pollIntervalMs = 200) {
1670
- const startTime = Date.now();
1671
- let lastCursorX = -1;
1672
- let stableCursorCount = 0;
1673
- while (Date.now() - startTime < maxWaitMs) {
1674
- const lastLine = await this.getLastLine();
1675
- // Check if input line is just a prompt
1676
- if (await this.isInputClear(lastLine)) {
1677
- return true;
1678
- }
1679
- const hasInput = this.hasVisibleInput(lastLine);
1680
- // Also check cursor stability - if cursor is moving, agent is typing
1681
- const cursorX = await this.getCursorX();
1682
- if (!hasInput && cursorX === lastCursorX) {
1683
- stableCursorCount++;
1684
- // If cursor has been stable for enough polls and at typical prompt position,
1685
- // the agent might be done but we just can't match the prompt pattern
1686
- if (stableCursorCount >= STABLE_CURSOR_THRESHOLD && cursorX <= MAX_PROMPT_CURSOR_POSITION) {
1687
- this.logStderr(`waitForClearInput: cursor stable at x=${cursorX}, assuming clear`);
1688
- return true;
1689
- }
1690
- }
1691
- else {
1692
- stableCursorCount = 0;
1693
- lastCursorX = cursorX;
1694
- }
1695
- await sleep(pollIntervalMs);
1696
- }
1697
- this.logStderr(`waitForClearInput: timed out after ${maxWaitMs}ms`);
1698
- return false;
1699
- }
1700
- /**
1701
- * Capture a signature of the current pane content for stability checks.
1702
- * Uses hash+length to cheaply detect changes without storing full content.
1703
- */
1704
- async capturePaneSignature() {
1705
- try {
1706
- const { stdout } = await execAsync(`"${this.tmuxPath}" capture-pane -t ${this.sessionName} -p -J -S - 2>/dev/null`);
1707
- const hash = crypto.createHash('sha1').update(stdout).digest('hex');
1708
- return `${stdout.length}:${hash}`;
1709
- }
1710
- catch {
1711
- return null;
1712
- }
1713
- }
1714
- /**
1715
- * Wait for pane output to stabilize before injecting to avoid interleaving with ongoing output.
1716
- * Uses adaptive timeout based on idle detector confidence for faster injection when safe.
1717
- *
1718
- * @param maxWaitMs - Maximum time to wait (default from config)
1719
- * @param pollIntervalMs - Polling interval (default from config)
1720
- * @param requiredStablePolls - Consecutive stable polls needed (default 2)
1721
- * @param priority - Message priority (lower = more urgent, can use shorter timeout)
1722
- */
1723
- async waitForStablePane(maxWaitMs = 800, pollIntervalMs = 150, requiredStablePolls = 2, priority) {
1724
- const start = Date.now();
1725
- // Adaptive timeout based on idle confidence and priority
1726
- // If idle detector shows high confidence (process state), we can be more aggressive
1727
- const idleResult = this.checkIdleForInjection();
1728
- const highConfidence = idleResult.confidence >= 0.9;
1729
- // Priority-based timeout adjustment (urgent messages get shorter timeout)
1730
- let effectiveMaxWait = maxWaitMs;
1731
- if (priority !== undefined && priority <= 1) {
1732
- // Urgent/high priority: reduce timeout by 50%
1733
- effectiveMaxWait = Math.min(maxWaitMs, highConfidence ? 200 : 400);
1734
- }
1735
- else if (highConfidence) {
1736
- // High confidence from process state: reduce timeout by 60%
1737
- effectiveMaxWait = Math.floor(maxWaitMs * 0.4);
1738
- }
1739
- let lastSig = await this.capturePaneSignature();
1740
- if (!lastSig)
1741
- return false;
1742
- let stableCount = 0;
1743
- // Fast initial check - if already stable, exit quickly
1744
- await sleep(Math.min(pollIntervalMs, 50));
1745
- const initialSig = await this.capturePaneSignature();
1746
- if (initialSig && initialSig === lastSig) {
1747
- stableCount = 1;
1748
- // If high confidence and initial check stable, we're good
1749
- if (highConfidence && stableCount >= 1) {
1750
- this.logStderr(`waitForStablePane: fast exit (high confidence, ${Date.now() - start}ms)`);
1751
- return true;
1752
- }
1753
- }
1754
- else if (initialSig) {
1755
- lastSig = initialSig;
1756
- }
1757
- while (Date.now() - start < effectiveMaxWait) {
1758
- await sleep(pollIntervalMs);
1759
- const sig = await this.capturePaneSignature();
1760
- if (!sig)
1761
- continue;
1762
- if (sig === lastSig) {
1763
- stableCount++;
1764
- if (stableCount >= requiredStablePolls) {
1765
- this.logStderr(`waitForStablePane: stable after ${Date.now() - start}ms`);
1766
- return true;
1767
- }
1768
- }
1769
- else {
1770
- stableCount = 0;
1771
- lastSig = sig;
1772
- }
1773
- }
1774
- // Even on timeout, if we had at least 1 stable poll and high confidence, proceed
1775
- if (stableCount >= 1 && highConfidence) {
1776
- this.logStderr(`waitForStablePane: proceeding with partial stability (high confidence)`);
1777
- return true;
1778
- }
1779
- this.logStderr(`waitForStablePane: timed out after ${Date.now() - start}ms`);
1780
- return false;
1781
- }
1782
- /**
1783
- * Stop and cleanup
1784
- */
1785
- stop() {
1786
- if (!this.running)
1787
- return;
1788
- this.running = false;
1789
- this.activityState = 'disconnected';
1790
- this.stopStuckDetection();
1791
- // Auto-save continuity state before shutdown (fire and forget)
1792
- // Pass sessionEndData to populate handoff (fixes empty handoff issue)
1793
- if (this.continuity) {
1794
- this.continuity.autoSave(this.config.name, 'session_end', this.sessionEndData).catch((err) => {
1795
- this.logStderr(`[CONTINUITY] Auto-save failed: ${err.message}`, true);
1796
- });
1797
- }
1798
- // Reset session state for potential reuse
1799
- this.resetSessionState();
1800
- // Stop polling
1801
- if (this.pollTimer) {
1802
- clearInterval(this.pollTimer);
1803
- this.pollTimer = undefined;
1804
- }
1805
- // Kill tmux session
1806
- try {
1807
- execSync(`"${this.tmuxPath}" kill-session -t ${this.sessionName} 2>/dev/null`);
1808
- }
1809
- catch {
1810
- // Ignore
1811
- }
1812
- // Disconnect relay
1813
- this.client.destroy();
1814
- }
1815
- }
1816
- //# sourceMappingURL=tmux-wrapper.js.map