agent-relay 1.1.0 → 1.2.3

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 (567) hide show
  1. package/.gitattributes +3 -0
  2. package/.nvmrc +1 -0
  3. package/.trajectories/completed/2026-01/traj_1dviorhnkcb5.json +65 -0
  4. package/.trajectories/completed/2026-01/traj_1dviorhnkcb5.md +37 -0
  5. package/.trajectories/completed/2026-01/traj_1k5if5snst2e.json +65 -0
  6. package/.trajectories/completed/2026-01/traj_1k5if5snst2e.md +37 -0
  7. package/.trajectories/completed/2026-01/traj_1rp3rges5811.json +49 -0
  8. package/.trajectories/completed/2026-01/traj_1rp3rges5811.md +31 -0
  9. package/.trajectories/completed/2026-01/traj_22bhyulruouw.json +113 -0
  10. package/.trajectories/completed/2026-01/traj_22bhyulruouw.md +57 -0
  11. package/.trajectories/completed/2026-01/traj_2dao7ddgnta0.json +53 -0
  12. package/.trajectories/completed/2026-01/traj_2dao7ddgnta0.md +32 -0
  13. package/.trajectories/completed/2026-01/traj_3t0440mjeunc.json +26 -0
  14. package/.trajectories/completed/2026-01/traj_3t0440mjeunc.md +6 -0
  15. package/.trajectories/completed/2026-01/traj_45x9494d9xnr.json +47 -0
  16. package/.trajectories/completed/2026-01/traj_45x9494d9xnr.md +32 -0
  17. package/.trajectories/completed/2026-01/traj_4aa0bb77s4nh.json +53 -0
  18. package/.trajectories/completed/2026-01/traj_4aa0bb77s4nh.md +32 -0
  19. package/.trajectories/completed/2026-01/traj_5lhmzq8rxpqv.json +59 -0
  20. package/.trajectories/completed/2026-01/traj_5lhmzq8rxpqv.md +33 -0
  21. package/.trajectories/completed/2026-01/traj_5vr4e9erb1fs.json +53 -0
  22. package/.trajectories/completed/2026-01/traj_5vr4e9erb1fs.md +32 -0
  23. package/.trajectories/completed/2026-01/traj_6fgiwdoklvym.json +48 -0
  24. package/.trajectories/completed/2026-01/traj_6fgiwdoklvym.md +24 -0
  25. package/.trajectories/completed/2026-01/traj_7ludwvz45veh.json +209 -0
  26. package/.trajectories/completed/2026-01/traj_7ludwvz45veh.md +97 -0
  27. package/.trajectories/completed/2026-01/traj_9921cuhel0pj.json +48 -0
  28. package/.trajectories/completed/2026-01/traj_9921cuhel0pj.md +24 -0
  29. package/.trajectories/completed/2026-01/traj_ajs7zqfux4wc.json +49 -0
  30. package/.trajectories/completed/2026-01/traj_ajs7zqfux4wc.md +23 -0
  31. package/.trajectories/completed/2026-01/traj_cvtqhlwcq9s0.json +53 -0
  32. package/.trajectories/completed/2026-01/traj_cvtqhlwcq9s0.md +32 -0
  33. package/.trajectories/completed/2026-01/traj_cxofprm2m2en.json +49 -0
  34. package/.trajectories/completed/2026-01/traj_cxofprm2m2en.md +31 -0
  35. package/.trajectories/completed/2026-01/traj_d2hhz3k0vrhn.json +26 -0
  36. package/.trajectories/completed/2026-01/traj_d2hhz3k0vrhn.md +6 -0
  37. package/.trajectories/completed/2026-01/traj_dfuvww9pege5.json +59 -0
  38. package/.trajectories/completed/2026-01/traj_dfuvww9pege5.md +37 -0
  39. package/.trajectories/completed/2026-01/traj_g0fisy9h51mf.json +77 -0
  40. package/.trajectories/completed/2026-01/traj_g0fisy9h51mf.md +42 -0
  41. package/.trajectories/completed/2026-01/traj_gjdre5voouod.json +53 -0
  42. package/.trajectories/completed/2026-01/traj_gjdre5voouod.md +32 -0
  43. package/.trajectories/completed/2026-01/traj_gtlyqtta3x8l.json +25 -0
  44. package/.trajectories/completed/2026-01/traj_gtlyqtta3x8l.md +15 -0
  45. package/.trajectories/completed/2026-01/traj_h4xijiuip3w4.json +101 -0
  46. package/.trajectories/completed/2026-01/traj_h4xijiuip3w4.md +44 -0
  47. package/.trajectories/completed/2026-01/traj_hhxte7w4gjjx.json +22 -0
  48. package/.trajectories/completed/2026-01/traj_hhxte7w4gjjx.md +5 -0
  49. package/.trajectories/completed/2026-01/traj_hpungyhoj6v5.json +53 -0
  50. package/.trajectories/completed/2026-01/traj_hpungyhoj6v5.md +32 -0
  51. package/.trajectories/completed/2026-01/traj_m2xkjv0w2sq7.json +25 -0
  52. package/.trajectories/completed/2026-01/traj_m2xkjv0w2sq7.md +15 -0
  53. package/.trajectories/completed/2026-01/traj_noq5zbvnrdvz.json +53 -0
  54. package/.trajectories/completed/2026-01/traj_noq5zbvnrdvz.md +32 -0
  55. package/.trajectories/completed/2026-01/traj_ntbs6ppopf46.json +53 -0
  56. package/.trajectories/completed/2026-01/traj_ntbs6ppopf46.md +32 -0
  57. package/.trajectories/completed/2026-01/traj_ozd98si6a7ns.json +48 -0
  58. package/.trajectories/completed/2026-01/traj_ozd98si6a7ns.md +24 -0
  59. package/.trajectories/completed/2026-01/traj_prdza7a5cxp5.json +53 -0
  60. package/.trajectories/completed/2026-01/traj_prdza7a5cxp5.md +32 -0
  61. package/.trajectories/completed/2026-01/traj_qb3twvvywfwi.json +77 -0
  62. package/.trajectories/completed/2026-01/traj_qb3twvvywfwi.md +42 -0
  63. package/.trajectories/completed/2026-01/traj_qft54mi7nfor.json +53 -0
  64. package/.trajectories/completed/2026-01/traj_qft54mi7nfor.md +32 -0
  65. package/.trajectories/completed/2026-01/traj_qx9uhf8whhxo.json +83 -0
  66. package/.trajectories/completed/2026-01/traj_qx9uhf8whhxo.md +47 -0
  67. package/.trajectories/completed/2026-01/traj_rd9toccj18a0.json +59 -0
  68. package/.trajectories/completed/2026-01/traj_rd9toccj18a0.md +37 -0
  69. package/.trajectories/completed/2026-01/traj_rt4fiw3ecp50.json +48 -0
  70. package/.trajectories/completed/2026-01/traj_rt4fiw3ecp50.md +16 -0
  71. package/.trajectories/completed/2026-01/traj_st8j35b0hrlc.json +59 -0
  72. package/.trajectories/completed/2026-01/traj_st8j35b0hrlc.md +37 -0
  73. package/.trajectories/completed/2026-01/traj_t1yy8m7hbuxp.json +53 -0
  74. package/.trajectories/completed/2026-01/traj_t1yy8m7hbuxp.md +32 -0
  75. package/.trajectories/completed/2026-01/traj_tmux_orchestrator_analysis.json +84 -0
  76. package/.trajectories/completed/2026-01/traj_tmux_orchestrator_analysis.md +109 -0
  77. package/.trajectories/completed/2026-01/traj_u9n9eqasw16k.json +53 -0
  78. package/.trajectories/completed/2026-01/traj_u9n9eqasw16k.md +32 -0
  79. package/.trajectories/completed/2026-01/traj_v87hypnongqx.json +71 -0
  80. package/.trajectories/completed/2026-01/traj_v87hypnongqx.md +42 -0
  81. package/.trajectories/completed/2026-01/traj_wkp2fgzdyinb.json +53 -0
  82. package/.trajectories/completed/2026-01/traj_wkp2fgzdyinb.md +32 -0
  83. package/.trajectories/completed/2026-01/traj_x14t8w8rn7xg.json +20 -0
  84. package/.trajectories/completed/2026-01/traj_x14t8w8rn7xg.md +6 -0
  85. package/.trajectories/completed/2026-01/traj_xnwbznkvv8ua.json +175 -0
  86. package/.trajectories/completed/2026-01/traj_xnwbznkvv8ua.md +82 -0
  87. package/.trajectories/completed/2026-01/traj_ysjc8zaeqtd3.json +47 -0
  88. package/.trajectories/completed/2026-01/traj_ysjc8zaeqtd3.md +32 -0
  89. package/.trajectories/completed/2026-01/traj_yvdadtvdgnz3.json +59 -0
  90. package/.trajectories/completed/2026-01/traj_yvdadtvdgnz3.md +37 -0
  91. package/.trajectories/completed/2026-01/traj_z0vcw1wrzide.json +53 -0
  92. package/.trajectories/completed/2026-01/traj_z0vcw1wrzide.md +32 -0
  93. package/.trajectories/index.json +314 -0
  94. package/ARCHITECTURE.md +1245 -0
  95. package/README.md +1 -1
  96. package/TESTING.md +278 -0
  97. package/deploy/init-db.sql +5 -0
  98. package/deploy/scripts/setup-fly-workspaces.sh +69 -0
  99. package/deploy/scripts/setup-railway.sh +75 -0
  100. package/deploy/workspace/entrypoint-browser.sh +118 -0
  101. package/deploy/workspace/entrypoint.sh +348 -0
  102. package/deploy/workspace/git-credential-relay +111 -0
  103. package/dist/bridge/spawner.d.ts +53 -0
  104. package/dist/bridge/spawner.js +203 -19
  105. package/dist/bridge/types.d.ts +12 -0
  106. package/dist/cli/index.js +618 -5
  107. package/dist/cloud/api/auth.d.ts +3 -2
  108. package/dist/cloud/api/auth.js +10 -98
  109. package/dist/cloud/api/billing.js +30 -9
  110. package/dist/cloud/api/cli-pty-runner.d.ts +54 -0
  111. package/dist/cloud/api/cli-pty-runner.js +119 -0
  112. package/dist/cloud/api/codex-auth-helper.d.ts +15 -0
  113. package/dist/cloud/api/codex-auth-helper.js +100 -0
  114. package/dist/cloud/api/generic-webhooks.d.ts +8 -0
  115. package/dist/cloud/api/generic-webhooks.js +129 -0
  116. package/dist/cloud/api/git.d.ts +8 -0
  117. package/dist/cloud/api/git.js +152 -0
  118. package/dist/cloud/api/github-app.d.ts +11 -0
  119. package/dist/cloud/api/github-app.js +189 -0
  120. package/dist/cloud/api/middleware/planLimits.d.ts +7 -0
  121. package/dist/cloud/api/middleware/planLimits.js +39 -1
  122. package/dist/cloud/api/monitoring.d.ts +11 -0
  123. package/dist/cloud/api/monitoring.js +578 -0
  124. package/dist/cloud/api/nango-auth.d.ts +9 -0
  125. package/dist/cloud/api/nango-auth.js +377 -0
  126. package/dist/cloud/api/onboarding.d.ts +8 -1
  127. package/dist/cloud/api/onboarding.js +313 -119
  128. package/dist/cloud/api/policy.d.ts +8 -0
  129. package/dist/cloud/api/policy.js +229 -0
  130. package/dist/cloud/api/providers.js +114 -42
  131. package/dist/cloud/api/repos.d.ts +1 -0
  132. package/dist/cloud/api/repos.js +186 -0
  133. package/dist/cloud/api/test-helpers.d.ts +10 -0
  134. package/dist/cloud/api/test-helpers.js +575 -0
  135. package/dist/cloud/api/webhooks.d.ts +8 -0
  136. package/dist/cloud/api/webhooks.js +645 -0
  137. package/dist/cloud/api/workspaces.js +320 -12
  138. package/dist/cloud/billing/plans.js +32 -19
  139. package/dist/cloud/billing/types.d.ts +9 -3
  140. package/dist/cloud/config.d.ts +9 -2
  141. package/dist/cloud/config.js +13 -4
  142. package/dist/cloud/db/drizzle.d.ts +84 -1
  143. package/dist/cloud/db/drizzle.js +470 -0
  144. package/dist/cloud/db/index.d.ts +9 -4
  145. package/dist/cloud/db/index.js +11 -3
  146. package/dist/cloud/db/schema.d.ts +3283 -556
  147. package/dist/cloud/db/schema.js +314 -1
  148. package/dist/cloud/index.d.ts +1 -0
  149. package/dist/cloud/index.js +2 -0
  150. package/dist/cloud/provisioner/index.d.ts +56 -0
  151. package/dist/cloud/provisioner/index.js +676 -34
  152. package/dist/cloud/server.d.ts +1 -0
  153. package/dist/cloud/server.js +362 -13
  154. package/dist/cloud/services/auto-scaler.d.ts +152 -0
  155. package/dist/cloud/services/auto-scaler.js +439 -0
  156. package/dist/cloud/services/capacity-manager.d.ts +148 -0
  157. package/dist/cloud/services/capacity-manager.js +449 -0
  158. package/dist/cloud/services/ci-agent-spawner.d.ts +49 -0
  159. package/dist/cloud/services/ci-agent-spawner.js +373 -0
  160. package/dist/cloud/services/index.d.ts +12 -0
  161. package/dist/cloud/services/index.js +15 -0
  162. package/dist/cloud/services/mention-handler.d.ts +65 -0
  163. package/dist/cloud/services/mention-handler.js +405 -0
  164. package/dist/cloud/services/nango.d.ts +186 -0
  165. package/dist/cloud/services/nango.js +344 -0
  166. package/dist/cloud/services/persistence.d.ts +131 -0
  167. package/dist/cloud/services/persistence.js +200 -0
  168. package/dist/cloud/services/planLimits.d.ts +37 -0
  169. package/dist/cloud/services/planLimits.js +86 -5
  170. package/dist/cloud/services/scaling-orchestrator.d.ts +159 -0
  171. package/dist/cloud/services/scaling-orchestrator.js +502 -0
  172. package/dist/cloud/services/scaling-policy.d.ts +121 -0
  173. package/dist/cloud/services/scaling-policy.js +415 -0
  174. package/dist/cloud/vault/index.js +1 -1
  175. package/dist/cloud/webhooks/index.d.ts +24 -0
  176. package/dist/cloud/webhooks/index.js +29 -0
  177. package/dist/cloud/webhooks/parsers/github.d.ts +8 -0
  178. package/dist/cloud/webhooks/parsers/github.js +234 -0
  179. package/dist/cloud/webhooks/parsers/index.d.ts +23 -0
  180. package/dist/cloud/webhooks/parsers/index.js +30 -0
  181. package/dist/cloud/webhooks/parsers/linear.d.ts +9 -0
  182. package/dist/cloud/webhooks/parsers/linear.js +258 -0
  183. package/dist/cloud/webhooks/parsers/slack.d.ts +9 -0
  184. package/dist/cloud/webhooks/parsers/slack.js +214 -0
  185. package/dist/cloud/webhooks/responders/github.d.ts +8 -0
  186. package/dist/cloud/webhooks/responders/github.js +73 -0
  187. package/dist/cloud/webhooks/responders/index.d.ts +23 -0
  188. package/dist/cloud/webhooks/responders/index.js +30 -0
  189. package/dist/cloud/webhooks/responders/linear.d.ts +9 -0
  190. package/dist/cloud/webhooks/responders/linear.js +149 -0
  191. package/dist/cloud/webhooks/responders/slack.d.ts +20 -0
  192. package/dist/cloud/webhooks/responders/slack.js +178 -0
  193. package/dist/cloud/webhooks/router.d.ts +25 -0
  194. package/dist/cloud/webhooks/router.js +504 -0
  195. package/dist/cloud/webhooks/rules-engine.d.ts +24 -0
  196. package/dist/cloud/webhooks/rules-engine.js +287 -0
  197. package/dist/cloud/webhooks/types.d.ts +186 -0
  198. package/dist/cloud/webhooks/types.js +8 -0
  199. package/dist/continuity/formatter.d.ts +51 -0
  200. package/dist/continuity/formatter.js +313 -0
  201. package/dist/continuity/handoff-store.d.ts +67 -0
  202. package/dist/continuity/handoff-store.js +472 -0
  203. package/dist/continuity/index.d.ts +45 -0
  204. package/dist/continuity/index.js +48 -0
  205. package/dist/continuity/ledger-store.d.ts +110 -0
  206. package/dist/continuity/ledger-store.js +500 -0
  207. package/dist/continuity/manager.d.ts +178 -0
  208. package/dist/continuity/manager.js +562 -0
  209. package/dist/continuity/parser.d.ts +76 -0
  210. package/dist/continuity/parser.js +579 -0
  211. package/dist/continuity/types.d.ts +180 -0
  212. package/dist/continuity/types.js +9 -0
  213. package/dist/daemon/agent-manager.d.ts +27 -0
  214. package/dist/daemon/agent-manager.js +107 -6
  215. package/dist/daemon/agent-registry.d.ts +32 -0
  216. package/dist/daemon/agent-registry.js +42 -2
  217. package/dist/daemon/api.d.ts +12 -0
  218. package/dist/daemon/api.js +131 -2
  219. package/dist/daemon/cli-auth.d.ts +67 -0
  220. package/dist/daemon/cli-auth.js +537 -0
  221. package/dist/daemon/cloud-sync.js +9 -7
  222. package/dist/daemon/orchestrator.js +30 -0
  223. package/dist/daemon/router.d.ts +5 -0
  224. package/dist/daemon/router.js +78 -26
  225. package/dist/daemon/server.d.ts +5 -0
  226. package/dist/daemon/server.js +9 -1
  227. package/dist/daemon/services/browser-testing.d.ts +88 -0
  228. package/dist/daemon/services/browser-testing.js +244 -0
  229. package/dist/daemon/services/container-spawner.d.ts +135 -0
  230. package/dist/daemon/services/container-spawner.js +313 -0
  231. package/dist/daemon/types.d.ts +5 -1
  232. package/dist/dashboard/out/404.html +1 -1
  233. package/dist/dashboard/out/_next/static/chunks/116-2502180def231162.js +1 -0
  234. package/dist/dashboard/out/_next/static/chunks/282-980c2eb8fff20123.js +1 -0
  235. package/dist/dashboard/out/_next/static/chunks/699-3b1cd6618a45d259.js +1 -0
  236. package/dist/dashboard/out/_next/static/chunks/724-2dae7627550ab88f.js +9 -0
  237. package/dist/dashboard/out/_next/static/chunks/766-1f2dd8cb7f766b0b.js +1 -0
  238. package/dist/dashboard/out/_next/static/chunks/app/app/onboarding/page-3fdfa60e53f2810d.js +1 -0
  239. package/dist/dashboard/out/_next/static/chunks/app/app/page-e6381e5a6e1fbcfd.js +1 -0
  240. package/dist/dashboard/out/_next/static/chunks/app/connect-repos/page-3538dfe0ffe984b8.js +1 -0
  241. package/dist/dashboard/out/_next/static/chunks/app/history/{page-b6edd4dde8d08194.js → page-abb9ab2d329f56e9.js} +1 -1
  242. package/dist/dashboard/out/_next/static/chunks/app/layout-c0d118c0f92d969c.js +1 -0
  243. package/dist/dashboard/out/_next/static/chunks/app/login/page-c22d080201cbd9fb.js +1 -0
  244. package/dist/dashboard/out/_next/static/chunks/app/metrics/page-67a3e98d9a43a6ed.js +1 -0
  245. package/dist/dashboard/out/_next/static/chunks/app/page-77e9c65420a06cfb.js +1 -0
  246. package/dist/dashboard/out/_next/static/chunks/app/pricing/page-b08ed1c34d14434a.js +1 -0
  247. package/dist/dashboard/out/_next/static/chunks/app/providers/page-e88bc117ef7671c3.js +1 -0
  248. package/dist/dashboard/out/_next/static/chunks/app/signup/page-68d34f50baa8ab6b.js +1 -0
  249. package/dist/dashboard/out/_next/static/chunks/e868780c-48e5f147c90a3a41.js +18 -0
  250. package/dist/dashboard/out/_next/static/chunks/{main-app-5d692157a8eb1fd9.js → main-app-6e8e8d3ef4e0192a.js} +1 -1
  251. package/dist/dashboard/out/_next/static/chunks/{main-c2f423b9c9f4591b.js → main-ed4e1fb6f29c34cf.js} +1 -1
  252. package/dist/dashboard/out/_next/static/chunks/webpack-1cdd8ed57114d5e1.js +1 -0
  253. package/dist/dashboard/out/_next/static/css/29852f26181969a0.css +1 -0
  254. package/dist/dashboard/out/_next/static/css/7c3ae9e8617d42a5.css +1 -0
  255. package/dist/dashboard/out/app/onboarding.html +1 -0
  256. package/dist/dashboard/out/app/onboarding.txt +7 -0
  257. package/dist/dashboard/out/app.html +1 -14
  258. package/dist/dashboard/out/app.txt +2 -2
  259. package/dist/dashboard/out/connect-repos.html +1 -0
  260. package/dist/dashboard/out/connect-repos.txt +7 -0
  261. package/dist/dashboard/out/history.html +1 -1
  262. package/dist/dashboard/out/history.txt +2 -2
  263. package/dist/dashboard/out/index.html +1 -1
  264. package/dist/dashboard/out/index.txt +2 -2
  265. package/dist/dashboard/out/login.html +6 -0
  266. package/dist/dashboard/out/login.txt +7 -0
  267. package/dist/dashboard/out/metrics.html +1 -1
  268. package/dist/dashboard/out/metrics.txt +2 -2
  269. package/dist/dashboard/out/pricing.html +3 -3
  270. package/dist/dashboard/out/pricing.txt +2 -2
  271. package/dist/dashboard/out/providers.html +1 -0
  272. package/dist/dashboard/out/providers.txt +7 -0
  273. package/dist/dashboard/out/signup.html +6 -0
  274. package/dist/dashboard/out/signup.txt +7 -0
  275. package/dist/dashboard-server/server.js +1308 -8
  276. package/dist/hooks/emitter.d.ts +40 -0
  277. package/dist/hooks/emitter.js +63 -0
  278. package/dist/hooks/index.d.ts +3 -0
  279. package/dist/hooks/index.js +3 -0
  280. package/dist/hooks/registry.d.ts +173 -0
  281. package/dist/hooks/registry.js +476 -0
  282. package/dist/hooks/trajectory-hooks.d.ts +52 -0
  283. package/dist/hooks/trajectory-hooks.js +183 -0
  284. package/dist/hooks/types.d.ts +141 -0
  285. package/dist/index.d.ts +2 -0
  286. package/dist/index.js +3 -0
  287. package/dist/memory/adapters/index.d.ts +8 -0
  288. package/dist/memory/adapters/index.js +8 -0
  289. package/dist/memory/adapters/inmemory.d.ts +59 -0
  290. package/dist/memory/adapters/inmemory.js +195 -0
  291. package/dist/memory/adapters/supermemory.d.ts +71 -0
  292. package/dist/memory/adapters/supermemory.js +338 -0
  293. package/dist/memory/factory.d.ts +48 -0
  294. package/dist/memory/factory.js +143 -0
  295. package/dist/memory/index.d.ts +32 -0
  296. package/dist/memory/index.js +32 -0
  297. package/dist/memory/memory-hooks.d.ts +60 -0
  298. package/dist/memory/memory-hooks.js +313 -0
  299. package/dist/memory/service.d.ts +49 -0
  300. package/dist/memory/service.js +146 -0
  301. package/dist/memory/types.d.ts +195 -0
  302. package/dist/memory/types.js +8 -0
  303. package/dist/policy/agent-policy.d.ts +225 -0
  304. package/dist/policy/agent-policy.js +665 -0
  305. package/dist/policy/cloud-policy-fetcher.d.ts +12 -0
  306. package/dist/policy/cloud-policy-fetcher.js +64 -0
  307. package/dist/resiliency/crash-insights.d.ts +156 -0
  308. package/dist/resiliency/crash-insights.js +492 -0
  309. package/dist/resiliency/gossip-health.d.ts +137 -0
  310. package/dist/resiliency/gossip-health.js +241 -0
  311. package/dist/resiliency/index.d.ts +5 -0
  312. package/dist/resiliency/index.js +5 -0
  313. package/dist/resiliency/leader-watchdog.d.ts +109 -0
  314. package/dist/resiliency/leader-watchdog.js +189 -0
  315. package/dist/resiliency/memory-monitor.d.ts +172 -0
  316. package/dist/resiliency/memory-monitor.js +593 -0
  317. package/dist/resiliency/stateless-lead.d.ts +149 -0
  318. package/dist/resiliency/stateless-lead.js +308 -0
  319. package/dist/resiliency/supervisor.d.ts +38 -0
  320. package/dist/resiliency/supervisor.js +122 -0
  321. package/dist/shared/cli-auth-config.d.ts +91 -0
  322. package/dist/shared/cli-auth-config.js +264 -0
  323. package/dist/storage/adapter.d.ts +1 -1
  324. package/dist/trajectory/config.d.ts +84 -0
  325. package/dist/trajectory/config.js +163 -0
  326. package/dist/trajectory/index.d.ts +8 -0
  327. package/dist/trajectory/index.js +8 -0
  328. package/dist/trajectory/integration.d.ts +292 -0
  329. package/dist/trajectory/integration.js +834 -0
  330. package/dist/utils/logger.js +1 -1
  331. package/dist/utils/project-namespace.d.ts +24 -0
  332. package/dist/utils/project-namespace.js +84 -0
  333. package/dist/wrapper/parser.d.ts +10 -0
  334. package/dist/wrapper/parser.js +100 -33
  335. package/dist/wrapper/pty-wrapper.d.ts +197 -16
  336. package/dist/wrapper/pty-wrapper.js +943 -106
  337. package/dist/wrapper/shared.d.ts +165 -0
  338. package/dist/wrapper/shared.js +270 -0
  339. package/dist/wrapper/tmux-wrapper.d.ts +73 -11
  340. package/dist/wrapper/tmux-wrapper.js +541 -120
  341. package/package.json +16 -16
  342. package/scripts/postinstall.js +60 -0
  343. package/test-push.txt +1 -0
  344. package/bin/tmux +0 -0
  345. package/dist/bridge/config.d.ts.map +0 -1
  346. package/dist/bridge/config.js.map +0 -1
  347. package/dist/bridge/index.d.ts.map +0 -1
  348. package/dist/bridge/index.js.map +0 -1
  349. package/dist/bridge/multi-project-client.d.ts.map +0 -1
  350. package/dist/bridge/multi-project-client.js.map +0 -1
  351. package/dist/bridge/shadow-cli.d.ts.map +0 -1
  352. package/dist/bridge/shadow-cli.js.map +0 -1
  353. package/dist/bridge/shadow-config.d.ts.map +0 -1
  354. package/dist/bridge/shadow-config.js.map +0 -1
  355. package/dist/bridge/spawner.d.ts.map +0 -1
  356. package/dist/bridge/spawner.js.map +0 -1
  357. package/dist/bridge/teams-config.d.ts.map +0 -1
  358. package/dist/bridge/teams-config.js.map +0 -1
  359. package/dist/bridge/types.d.ts.map +0 -1
  360. package/dist/bridge/types.js.map +0 -1
  361. package/dist/bridge/utils.d.ts.map +0 -1
  362. package/dist/bridge/utils.js.map +0 -1
  363. package/dist/cli/index.d.ts.map +0 -1
  364. package/dist/cli/index.js.map +0 -1
  365. package/dist/cloud/api/auth.d.ts.map +0 -1
  366. package/dist/cloud/api/auth.js.map +0 -1
  367. package/dist/cloud/api/billing.d.ts.map +0 -1
  368. package/dist/cloud/api/billing.js.map +0 -1
  369. package/dist/cloud/api/coordinators.d.ts.map +0 -1
  370. package/dist/cloud/api/coordinators.js.map +0 -1
  371. package/dist/cloud/api/daemons.d.ts.map +0 -1
  372. package/dist/cloud/api/daemons.js.map +0 -1
  373. package/dist/cloud/api/middleware/planLimits.d.ts.map +0 -1
  374. package/dist/cloud/api/middleware/planLimits.js.map +0 -1
  375. package/dist/cloud/api/onboarding.d.ts.map +0 -1
  376. package/dist/cloud/api/onboarding.js.map +0 -1
  377. package/dist/cloud/api/providers.d.ts.map +0 -1
  378. package/dist/cloud/api/providers.js.map +0 -1
  379. package/dist/cloud/api/repos.d.ts.map +0 -1
  380. package/dist/cloud/api/repos.js.map +0 -1
  381. package/dist/cloud/api/teams.d.ts.map +0 -1
  382. package/dist/cloud/api/teams.js.map +0 -1
  383. package/dist/cloud/api/usage.d.ts.map +0 -1
  384. package/dist/cloud/api/usage.js.map +0 -1
  385. package/dist/cloud/api/workspaces.d.ts.map +0 -1
  386. package/dist/cloud/api/workspaces.js.map +0 -1
  387. package/dist/cloud/billing/index.d.ts.map +0 -1
  388. package/dist/cloud/billing/index.js.map +0 -1
  389. package/dist/cloud/billing/plans.d.ts.map +0 -1
  390. package/dist/cloud/billing/plans.js.map +0 -1
  391. package/dist/cloud/billing/service.d.ts.map +0 -1
  392. package/dist/cloud/billing/service.js.map +0 -1
  393. package/dist/cloud/billing/types.d.ts.map +0 -1
  394. package/dist/cloud/billing/types.js.map +0 -1
  395. package/dist/cloud/config.d.ts.map +0 -1
  396. package/dist/cloud/config.js.map +0 -1
  397. package/dist/cloud/db/drizzle.d.ts.map +0 -1
  398. package/dist/cloud/db/drizzle.js.map +0 -1
  399. package/dist/cloud/db/index.d.ts.map +0 -1
  400. package/dist/cloud/db/index.js.map +0 -1
  401. package/dist/cloud/db/schema.d.ts.map +0 -1
  402. package/dist/cloud/db/schema.js.map +0 -1
  403. package/dist/cloud/index.d.ts.map +0 -1
  404. package/dist/cloud/index.js.map +0 -1
  405. package/dist/cloud/provisioner/index.d.ts.map +0 -1
  406. package/dist/cloud/provisioner/index.js.map +0 -1
  407. package/dist/cloud/server.d.ts.map +0 -1
  408. package/dist/cloud/server.js.map +0 -1
  409. package/dist/cloud/services/coordinator.d.ts.map +0 -1
  410. package/dist/cloud/services/coordinator.js.map +0 -1
  411. package/dist/cloud/services/planLimits.d.ts.map +0 -1
  412. package/dist/cloud/services/planLimits.js.map +0 -1
  413. package/dist/cloud/vault/index.d.ts.map +0 -1
  414. package/dist/cloud/vault/index.js.map +0 -1
  415. package/dist/daemon/agent-manager.d.ts.map +0 -1
  416. package/dist/daemon/agent-manager.js.map +0 -1
  417. package/dist/daemon/agent-registry.d.ts.map +0 -1
  418. package/dist/daemon/agent-registry.js.map +0 -1
  419. package/dist/daemon/api.d.ts.map +0 -1
  420. package/dist/daemon/api.js.map +0 -1
  421. package/dist/daemon/auth.d.ts.map +0 -1
  422. package/dist/daemon/auth.js.map +0 -1
  423. package/dist/daemon/cloud-sync.d.ts.map +0 -1
  424. package/dist/daemon/cloud-sync.js.map +0 -1
  425. package/dist/daemon/connection.d.ts.map +0 -1
  426. package/dist/daemon/connection.js.map +0 -1
  427. package/dist/daemon/index.d.ts.map +0 -1
  428. package/dist/daemon/index.js.map +0 -1
  429. package/dist/daemon/orchestrator.d.ts.map +0 -1
  430. package/dist/daemon/orchestrator.js.map +0 -1
  431. package/dist/daemon/registry.d.ts.map +0 -1
  432. package/dist/daemon/registry.js.map +0 -1
  433. package/dist/daemon/router.d.ts.map +0 -1
  434. package/dist/daemon/router.js.map +0 -1
  435. package/dist/daemon/server.d.ts.map +0 -1
  436. package/dist/daemon/server.js.map +0 -1
  437. package/dist/daemon/types.d.ts.map +0 -1
  438. package/dist/daemon/types.js.map +0 -1
  439. package/dist/daemon/workspace-manager.d.ts.map +0 -1
  440. package/dist/daemon/workspace-manager.js.map +0 -1
  441. package/dist/dashboard/out/_next/static/chunks/693-7b3301d8f6bc5014.js +0 -1
  442. package/dist/dashboard/out/_next/static/chunks/713-f78477eb185f1f4d.js +0 -1
  443. package/dist/dashboard/out/_next/static/chunks/766-e53e1cfe39b0b5b5.js +0 -1
  444. package/dist/dashboard/out/_next/static/chunks/900-037c64bfd797fb2a.js +0 -1
  445. package/dist/dashboard/out/_next/static/chunks/app/app/page-e3d9e1f4466b9bae.js +0 -1
  446. package/dist/dashboard/out/_next/static/chunks/app/layout-2433bb48965f4333.js +0 -1
  447. package/dist/dashboard/out/_next/static/chunks/app/metrics/page-e68825a81db67ba1.js +0 -1
  448. package/dist/dashboard/out/_next/static/chunks/app/page-cc108bf68c8a657f.js +0 -1
  449. package/dist/dashboard/out/_next/static/chunks/app/pricing/page-d80e03a5297f95b6.js +0 -1
  450. package/dist/dashboard/out/_next/static/chunks/webpack-a5acc2831d094776.js +0 -1
  451. package/dist/dashboard/out/_next/static/css/79b80143647a07d7.css +0 -1
  452. package/dist/dashboard/out/_next/static/css/8cf277370ad48cfe.css +0 -1
  453. package/dist/dashboard-server/metrics.d.ts.map +0 -1
  454. package/dist/dashboard-server/metrics.js.map +0 -1
  455. package/dist/dashboard-server/needs-attention.d.ts.map +0 -1
  456. package/dist/dashboard-server/needs-attention.js.map +0 -1
  457. package/dist/dashboard-server/server.d.ts.map +0 -1
  458. package/dist/dashboard-server/server.js.map +0 -1
  459. package/dist/dashboard-server/start.d.ts.map +0 -1
  460. package/dist/dashboard-server/start.js.map +0 -1
  461. package/dist/hooks/inbox-check/hook.d.ts.map +0 -1
  462. package/dist/hooks/inbox-check/hook.js.map +0 -1
  463. package/dist/hooks/inbox-check/index.d.ts.map +0 -1
  464. package/dist/hooks/inbox-check/index.js.map +0 -1
  465. package/dist/hooks/inbox-check/types.d.ts.map +0 -1
  466. package/dist/hooks/inbox-check/types.js.map +0 -1
  467. package/dist/hooks/inbox-check/utils.d.ts.map +0 -1
  468. package/dist/hooks/inbox-check/utils.js.map +0 -1
  469. package/dist/hooks/index.d.ts.map +0 -1
  470. package/dist/hooks/index.js.map +0 -1
  471. package/dist/hooks/types.d.ts.map +0 -1
  472. package/dist/hooks/types.js.map +0 -1
  473. package/dist/index.d.ts.map +0 -1
  474. package/dist/index.js.map +0 -1
  475. package/dist/protocol/framing.d.ts.map +0 -1
  476. package/dist/protocol/framing.js.map +0 -1
  477. package/dist/protocol/index.d.ts.map +0 -1
  478. package/dist/protocol/index.js.map +0 -1
  479. package/dist/protocol/types.d.ts.map +0 -1
  480. package/dist/protocol/types.js.map +0 -1
  481. package/dist/resiliency/context-persistence.d.ts.map +0 -1
  482. package/dist/resiliency/context-persistence.js.map +0 -1
  483. package/dist/resiliency/health-monitor.d.ts.map +0 -1
  484. package/dist/resiliency/health-monitor.js.map +0 -1
  485. package/dist/resiliency/index.d.ts.map +0 -1
  486. package/dist/resiliency/index.js.map +0 -1
  487. package/dist/resiliency/logger.d.ts.map +0 -1
  488. package/dist/resiliency/logger.js.map +0 -1
  489. package/dist/resiliency/metrics.d.ts.map +0 -1
  490. package/dist/resiliency/metrics.js.map +0 -1
  491. package/dist/resiliency/provider-context.d.ts.map +0 -1
  492. package/dist/resiliency/provider-context.js.map +0 -1
  493. package/dist/resiliency/supervisor.d.ts.map +0 -1
  494. package/dist/resiliency/supervisor.js.map +0 -1
  495. package/dist/state/agent-state.d.ts.map +0 -1
  496. package/dist/state/agent-state.js.map +0 -1
  497. package/dist/storage/adapter.d.ts.map +0 -1
  498. package/dist/storage/adapter.js.map +0 -1
  499. package/dist/storage/sqlite-adapter.d.ts.map +0 -1
  500. package/dist/storage/sqlite-adapter.js.map +0 -1
  501. package/dist/utils/agent-config.d.ts.map +0 -1
  502. package/dist/utils/agent-config.js.map +0 -1
  503. package/dist/utils/command-resolver.d.ts.map +0 -1
  504. package/dist/utils/command-resolver.js.map +0 -1
  505. package/dist/utils/index.d.ts.map +0 -1
  506. package/dist/utils/index.js.map +0 -1
  507. package/dist/utils/logger.d.ts.map +0 -1
  508. package/dist/utils/logger.js.map +0 -1
  509. package/dist/utils/name-generator.d.ts.map +0 -1
  510. package/dist/utils/name-generator.js.map +0 -1
  511. package/dist/utils/project-namespace.d.ts.map +0 -1
  512. package/dist/utils/project-namespace.js.map +0 -1
  513. package/dist/utils/tmux-resolver.d.ts.map +0 -1
  514. package/dist/utils/tmux-resolver.js.map +0 -1
  515. package/dist/utils/update-checker.d.ts.map +0 -1
  516. package/dist/utils/update-checker.js.map +0 -1
  517. package/dist/wrapper/client.d.ts.map +0 -1
  518. package/dist/wrapper/client.js.map +0 -1
  519. package/dist/wrapper/inbox.d.ts.map +0 -1
  520. package/dist/wrapper/inbox.js.map +0 -1
  521. package/dist/wrapper/index.d.ts.map +0 -1
  522. package/dist/wrapper/index.js.map +0 -1
  523. package/dist/wrapper/parser.d.ts.map +0 -1
  524. package/dist/wrapper/parser.js.map +0 -1
  525. package/dist/wrapper/pty-wrapper.d.ts.map +0 -1
  526. package/dist/wrapper/pty-wrapper.js.map +0 -1
  527. package/dist/wrapper/tmux-wrapper.d.ts.map +0 -1
  528. package/dist/wrapper/tmux-wrapper.js.map +0 -1
  529. package/docs/AGENTS.md +0 -513
  530. package/docs/ARCHITECTURE_DECISIONS.md +0 -175
  531. package/docs/CHANGELOG.md +0 -11
  532. package/docs/CLI-SIMPLIFICATION-COMPLETE.md +0 -48
  533. package/docs/CLOUD-ARCHITECTURE.md +0 -652
  534. package/docs/CLOUD-ONBOARDING-DESIGN.md +0 -1983
  535. package/docs/COMPETITIVE_ANALYSIS.md +0 -897
  536. package/docs/CONTRIBUTING.md +0 -151
  537. package/docs/DESIGN_BRIDGE_STAFFING.md +0 -878
  538. package/docs/DESIGN_V2.md +0 -1079
  539. package/docs/INTEGRATION-GUIDE.md +0 -926
  540. package/docs/MONETIZATION.md +0 -1679
  541. package/docs/PROPOSAL-trajectories.md +0 -1582
  542. package/docs/PROTOCOL.md +0 -325
  543. package/docs/SCALING_ANALYSIS.md +0 -280
  544. package/docs/TESTING_PRESENCE_FEATURES.md +0 -327
  545. package/docs/TMUX_IMPLEMENTATION_NOTES.md +0 -364
  546. package/docs/TMUX_IMPROVEMENTS.md +0 -968
  547. package/docs/agent-relay-snippet.md +0 -168
  548. package/docs/competitive-analysis-mcp-agent-mail.md +0 -389
  549. package/docs/dashboard-v2-plan.md +0 -179
  550. package/docs/guides/CLOUD.md +0 -236
  551. package/docs/guides/LOCAL.md +0 -535
  552. package/docs/guides/SELF-HOSTED.md +0 -494
  553. package/docs/proposals/shadow-as-subagent.md +0 -765
  554. package/docs/proposals/slack-bot-integration.md +0 -1457
  555. package/docs/removable-code-analysis.md +0 -24
  556. package/scripts/dev/PUBLIC_RELEASE_PLAN.md +0 -88
  557. package/scripts/dev/dev-team-setup.sh +0 -431
  558. package/scripts/e2e-test.sh +0 -119
  559. package/scripts/games/game-protocol.md +0 -79
  560. package/scripts/games/hearts-setup.sh +0 -264
  561. package/scripts/tictactoe-setup.sh +0 -181
  562. /package/dist/dashboard/out/_next/static/chunks/{117-b2cd8d6485aacf2b.js → 117-f7b8ab0809342e77.js} +0 -0
  563. /package/dist/dashboard/out/_next/static/chunks/{648-8f3f26864ce515e5.js → 648-5cc6e1921389a58a.js} +0 -0
  564. /package/dist/dashboard/out/_next/static/chunks/app/_not-found/{page-0b990dbb71d72a98.js → page-53b8a69f76db17d0.js} +0 -0
  565. /package/dist/dashboard/out/_next/static/chunks/{fd9d1056-bf46c09eb57e019c.js → fd9d1056-609918ca7b6280bb.js} +0 -0
  566. /package/dist/dashboard/out/_next/static/{6HHWb2ZmnJ4OSm0zUP7h4 → wPgKJtcOmTFLpUncDg16A}/_buildManifest.js +0 -0
  567. /package/dist/dashboard/out/_next/static/{6HHWb2ZmnJ4OSm0zUP7h4 → wPgKJtcOmTFLpUncDg16A}/_ssgManifest.js +0 -0
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Shared types and utilities for TmuxWrapper and PtyWrapper
3
+ *
4
+ * This module contains common code to prevent drift between the two
5
+ * wrapper implementations and reduce duplication.
6
+ */
7
+ /**
8
+ * Message queued for injection into an agent's terminal
9
+ */
10
+ export interface QueuedMessage {
11
+ from: string;
12
+ body: string;
13
+ messageId: string;
14
+ thread?: string;
15
+ importance?: number;
16
+ data?: Record<string, unknown>;
17
+ /** Original 'to' field - '*' indicates broadcast */
18
+ originalTo?: string;
19
+ }
20
+ /**
21
+ * Result of an injection attempt with retry
22
+ */
23
+ export interface InjectionResult {
24
+ success: boolean;
25
+ attempts: number;
26
+ fallbackUsed?: boolean;
27
+ }
28
+ /**
29
+ * Metrics tracking injection reliability
30
+ */
31
+ export interface InjectionMetrics {
32
+ total: number;
33
+ successFirstTry: number;
34
+ successWithRetry: number;
35
+ failed: number;
36
+ }
37
+ /**
38
+ * CLI types for special handling
39
+ */
40
+ export type CliType = 'claude' | 'codex' | 'gemini' | 'droid' | 'opencode' | 'spawned' | 'other';
41
+ /**
42
+ * Injection timing constants
43
+ */
44
+ export declare const INJECTION_CONSTANTS: {
45
+ /** Maximum retry attempts for injection */
46
+ readonly MAX_RETRIES: 3;
47
+ /** Timeout for output stability check (ms) */
48
+ readonly STABILITY_TIMEOUT_MS: 3000;
49
+ /** Polling interval for stability check (ms) */
50
+ readonly STABILITY_POLL_MS: 200;
51
+ /** Required consecutive stable polls before injection */
52
+ readonly REQUIRED_STABLE_POLLS: 2;
53
+ /** Timeout for injection verification (ms) */
54
+ readonly VERIFICATION_TIMEOUT_MS: 2000;
55
+ /** Delay between message and Enter key (ms) */
56
+ readonly ENTER_DELAY_MS: 50;
57
+ /** Backoff multiplier for retries (ms per attempt) */
58
+ readonly RETRY_BACKOFF_MS: 300;
59
+ /** Delay between processing queued messages (ms) */
60
+ readonly QUEUE_PROCESS_DELAY_MS: 500;
61
+ };
62
+ /**
63
+ * Strip ANSI escape codes from a string.
64
+ * Converts cursor movements to spaces to preserve visual layout.
65
+ */
66
+ export declare function stripAnsi(str: string): string;
67
+ /**
68
+ * Sleep for a given number of milliseconds
69
+ */
70
+ export declare function sleep(ms: number): Promise<void>;
71
+ /**
72
+ * Build the injection string for a relay message.
73
+ * Format: Relay message from {from} [{shortId}]{hints}: {body}
74
+ */
75
+ export declare function buildInjectionString(msg: QueuedMessage): string;
76
+ /**
77
+ * Calculate injection success rate from metrics
78
+ */
79
+ export declare function calculateSuccessRate(metrics: InjectionMetrics): number;
80
+ /**
81
+ * Create a fresh injection metrics object
82
+ */
83
+ export declare function createInjectionMetrics(): InjectionMetrics;
84
+ /**
85
+ * Detect CLI type from command string
86
+ */
87
+ export declare function detectCliType(command: string): CliType;
88
+ /**
89
+ * Get the default relay prefix (unified for all agent types)
90
+ */
91
+ export declare function getDefaultRelayPrefix(): string;
92
+ /**
93
+ * CLI-specific quirks and handling
94
+ */
95
+ export declare const CLI_QUIRKS: {
96
+ /**
97
+ * CLIs that support bracketed paste mode.
98
+ * Others may interpret the escape sequences literally.
99
+ */
100
+ readonly supportsBracketedPaste: (cli: CliType) => boolean;
101
+ /**
102
+ * Gemini interprets certain keywords (While, For, If, etc.) as shell commands.
103
+ * Wrap message in backticks to prevent shell keyword interpretation.
104
+ */
105
+ readonly wrapForGemini: (body: string) => string;
106
+ /**
107
+ * Get prompt pattern regex for a CLI type.
108
+ * Used to detect when input line is clear.
109
+ */
110
+ readonly getPromptPattern: (cli: CliType) => RegExp;
111
+ /**
112
+ * Check if a line looks like a shell prompt (for Gemini safety check).
113
+ * Gemini can drop into shell mode - we skip injection to avoid executing commands.
114
+ */
115
+ readonly isShellPrompt: (line: string) => boolean;
116
+ };
117
+ /**
118
+ * Callbacks for wrapper-specific injection operations.
119
+ * These allow the shared injection logic to work with both
120
+ * TmuxWrapper (tmux paste) and PtyWrapper (PTY write).
121
+ */
122
+ export interface InjectionCallbacks {
123
+ /** Get current output content for verification */
124
+ getOutput: () => Promise<string>;
125
+ /** Perform the actual injection (write to terminal) */
126
+ performInjection: (injection: string) => Promise<void>;
127
+ /** Log a message (debug/info level) */
128
+ log: (message: string) => void;
129
+ /** Log an error message */
130
+ logError: (message: string) => void;
131
+ /** Get the injection metrics object to update */
132
+ getMetrics: () => InjectionMetrics;
133
+ /**
134
+ * Skip verification and trust that write succeeded.
135
+ * Set to true for PTY-based injection where CLIs don't echo input.
136
+ * When true, injection succeeds on first attempt without verification.
137
+ */
138
+ skipVerification?: boolean;
139
+ }
140
+ /**
141
+ * Verify that an injected message appeared in the output.
142
+ * Uses a callback to get output content, allowing different backends
143
+ * (tmux capture-pane, PTY buffer) to be used.
144
+ *
145
+ * @param shortId - First 8 chars of message ID
146
+ * @param from - Sender name
147
+ * @param getOutput - Callback to retrieve current output
148
+ * @returns true if message pattern found in output
149
+ */
150
+ export declare function verifyInjection(shortId: string, from: string, getOutput: () => Promise<string>): Promise<boolean>;
151
+ /**
152
+ * Inject a message with retry logic and verification.
153
+ * Includes dedup check to prevent double-injection race condition.
154
+ *
155
+ * This consolidates the retry/verification logic that was duplicated
156
+ * in TmuxWrapper and PtyWrapper.
157
+ *
158
+ * @param injection - The formatted injection string
159
+ * @param shortId - First 8 chars of message ID for verification
160
+ * @param from - Sender name for verification pattern
161
+ * @param callbacks - Wrapper-specific callbacks for injection operations
162
+ * @returns Result indicating success/failure and attempt count
163
+ */
164
+ export declare function injectWithRetry(injection: string, shortId: string, from: string, callbacks: InjectionCallbacks): Promise<InjectionResult>;
165
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1,270 @@
1
+ /**
2
+ * Shared types and utilities for TmuxWrapper and PtyWrapper
3
+ *
4
+ * This module contains common code to prevent drift between the two
5
+ * wrapper implementations and reduce duplication.
6
+ */
7
+ /**
8
+ * Injection timing constants
9
+ */
10
+ export const INJECTION_CONSTANTS = {
11
+ /** Maximum retry attempts for injection */
12
+ MAX_RETRIES: 3,
13
+ /** Timeout for output stability check (ms) */
14
+ STABILITY_TIMEOUT_MS: 3000,
15
+ /** Polling interval for stability check (ms) */
16
+ STABILITY_POLL_MS: 200,
17
+ /** Required consecutive stable polls before injection */
18
+ REQUIRED_STABLE_POLLS: 2,
19
+ /** Timeout for injection verification (ms) */
20
+ VERIFICATION_TIMEOUT_MS: 2000,
21
+ /** Delay between message and Enter key (ms) */
22
+ ENTER_DELAY_MS: 50,
23
+ /** Backoff multiplier for retries (ms per attempt) */
24
+ RETRY_BACKOFF_MS: 300,
25
+ /** Delay between processing queued messages (ms) */
26
+ QUEUE_PROCESS_DELAY_MS: 500,
27
+ };
28
+ /**
29
+ * Strip ANSI escape codes from a string.
30
+ * Converts cursor movements to spaces to preserve visual layout.
31
+ */
32
+ export function stripAnsi(str) {
33
+ // Convert cursor forward movements to spaces (CSI n C)
34
+ // eslint-disable-next-line no-control-regex
35
+ let result = str.replace(/\x1B\[(\d+)C/g, (_m, n) => ' '.repeat(parseInt(n, 10) || 1));
36
+ // Convert single cursor right (CSI C) to space
37
+ // eslint-disable-next-line no-control-regex
38
+ result = result.replace(/\x1B\[C/g, ' ');
39
+ // Remove carriage returns (causes text overwriting issues)
40
+ result = result.replace(/\r(?!\n)/g, '');
41
+ // Strip ANSI escape sequences (with \x1B prefix)
42
+ // eslint-disable-next-line no-control-regex
43
+ result = result.replace(/\x1B(?:\[[0-9;?]*[A-Za-z]|\].*?(?:\x07|\x1B\\)|[@-Z\\-_])/g, '');
44
+ // Strip orphaned CSI sequences that lost their escape byte
45
+ // Requires at least one digit or question mark to avoid stripping legitimate text like [Agent
46
+ result = result.replace(/^\s*(\[(?:\?|\d)\d*[A-Za-z])+\s*/g, '');
47
+ return result;
48
+ }
49
+ /**
50
+ * Sleep for a given number of milliseconds
51
+ */
52
+ export function sleep(ms) {
53
+ return new Promise((resolve) => setTimeout(resolve, ms));
54
+ }
55
+ /**
56
+ * Build the injection string for a relay message.
57
+ * Format: Relay message from {from} [{shortId}]{hints}: {body}
58
+ */
59
+ export function buildInjectionString(msg) {
60
+ const shortId = msg.messageId.substring(0, 8);
61
+ // Strip ANSI and normalize whitespace
62
+ const sanitizedBody = stripAnsi(msg.body).replace(/[\r\n]+/g, ' ').trim();
63
+ // Thread hint
64
+ const threadHint = msg.thread ? ` [thread:${msg.thread}]` : '';
65
+ // Importance indicator: [!!] for high (>75), [!] for medium (>50)
66
+ const importanceHint = msg.importance !== undefined && msg.importance > 75
67
+ ? ' [!!]'
68
+ : msg.importance !== undefined && msg.importance > 50
69
+ ? ' [!]'
70
+ : '';
71
+ // Channel indicator for broadcasts
72
+ const channelHint = msg.originalTo === '*' ? ' [#general]' : '';
73
+ // Extract attachment file paths if present
74
+ let attachmentHint = '';
75
+ if (msg.data?.attachments && Array.isArray(msg.data.attachments)) {
76
+ const filePaths = msg.data.attachments
77
+ .map((att) => att.filePath)
78
+ .filter((p) => typeof p === 'string');
79
+ if (filePaths.length > 0) {
80
+ attachmentHint = ` [Attachments: ${filePaths.join(', ')}]`;
81
+ }
82
+ }
83
+ return `Relay message from ${msg.from} [${shortId}]${threadHint}${importanceHint}${channelHint}${attachmentHint}: ${sanitizedBody}`;
84
+ }
85
+ /**
86
+ * Calculate injection success rate from metrics
87
+ */
88
+ export function calculateSuccessRate(metrics) {
89
+ if (metrics.total === 0)
90
+ return 100;
91
+ const successful = metrics.successFirstTry + metrics.successWithRetry;
92
+ return Math.round((successful / metrics.total) * 10000) / 100;
93
+ }
94
+ /**
95
+ * Create a fresh injection metrics object
96
+ */
97
+ export function createInjectionMetrics() {
98
+ return {
99
+ total: 0,
100
+ successFirstTry: 0,
101
+ successWithRetry: 0,
102
+ failed: 0,
103
+ };
104
+ }
105
+ /**
106
+ * Detect CLI type from command string
107
+ */
108
+ export function detectCliType(command) {
109
+ const cmdLower = command.toLowerCase();
110
+ if (cmdLower.includes('gemini'))
111
+ return 'gemini';
112
+ if (cmdLower.includes('codex'))
113
+ return 'codex';
114
+ if (cmdLower.includes('claude'))
115
+ return 'claude';
116
+ if (cmdLower.includes('droid'))
117
+ return 'droid';
118
+ if (cmdLower.includes('opencode'))
119
+ return 'opencode';
120
+ return 'other';
121
+ }
122
+ /**
123
+ * Get the default relay prefix (unified for all agent types)
124
+ */
125
+ export function getDefaultRelayPrefix() {
126
+ return '->relay:';
127
+ }
128
+ /**
129
+ * CLI-specific quirks and handling
130
+ */
131
+ export const CLI_QUIRKS = {
132
+ /**
133
+ * CLIs that support bracketed paste mode.
134
+ * Others may interpret the escape sequences literally.
135
+ */
136
+ supportsBracketedPaste: (cli) => {
137
+ return cli === 'claude' || cli === 'codex' || cli === 'gemini' || cli === 'opencode';
138
+ },
139
+ /**
140
+ * Gemini interprets certain keywords (While, For, If, etc.) as shell commands.
141
+ * Wrap message in backticks to prevent shell keyword interpretation.
142
+ */
143
+ wrapForGemini: (body) => {
144
+ return `\`${body.replace(/`/g, "'")}\``;
145
+ },
146
+ /**
147
+ * Get prompt pattern regex for a CLI type.
148
+ * Used to detect when input line is clear.
149
+ */
150
+ getPromptPattern: (cli) => {
151
+ const patterns = {
152
+ claude: /^[>›»]\s*$/,
153
+ gemini: /^[>›»]\s*$/,
154
+ codex: /^[>›»]\s*$/,
155
+ droid: /^[>›»]\s*$/,
156
+ opencode: /^[>›»]\s*$/,
157
+ spawned: /^[>›»]\s*$/,
158
+ other: /^[>$%#➜›»]\s*$/,
159
+ };
160
+ return patterns[cli] || patterns.other;
161
+ },
162
+ /**
163
+ * Check if a line looks like a shell prompt (for Gemini safety check).
164
+ * Gemini can drop into shell mode - we skip injection to avoid executing commands.
165
+ */
166
+ isShellPrompt: (line) => {
167
+ const clean = stripAnsi(line).trim();
168
+ return /^\$\s*$/.test(clean) || /^\s*\$\s*$/.test(clean);
169
+ },
170
+ };
171
+ /**
172
+ * Verify that an injected message appeared in the output.
173
+ * Uses a callback to get output content, allowing different backends
174
+ * (tmux capture-pane, PTY buffer) to be used.
175
+ *
176
+ * @param shortId - First 8 chars of message ID
177
+ * @param from - Sender name
178
+ * @param getOutput - Callback to retrieve current output
179
+ * @returns true if message pattern found in output
180
+ */
181
+ export async function verifyInjection(shortId, from, getOutput) {
182
+ const expectedPattern = `Relay message from ${from} [${shortId}]`;
183
+ const startTime = Date.now();
184
+ while (Date.now() - startTime < INJECTION_CONSTANTS.VERIFICATION_TIMEOUT_MS) {
185
+ try {
186
+ const output = await getOutput();
187
+ if (output.includes(expectedPattern)) {
188
+ return true;
189
+ }
190
+ }
191
+ catch {
192
+ // Output retrieval failed, verification fails
193
+ return false;
194
+ }
195
+ await sleep(100);
196
+ }
197
+ return false;
198
+ }
199
+ /**
200
+ * Inject a message with retry logic and verification.
201
+ * Includes dedup check to prevent double-injection race condition.
202
+ *
203
+ * This consolidates the retry/verification logic that was duplicated
204
+ * in TmuxWrapper and PtyWrapper.
205
+ *
206
+ * @param injection - The formatted injection string
207
+ * @param shortId - First 8 chars of message ID for verification
208
+ * @param from - Sender name for verification pattern
209
+ * @param callbacks - Wrapper-specific callbacks for injection operations
210
+ * @returns Result indicating success/failure and attempt count
211
+ */
212
+ export async function injectWithRetry(injection, shortId, from, callbacks) {
213
+ const metrics = callbacks.getMetrics();
214
+ metrics.total++;
215
+ // Skip verification mode: trust that write() succeeds without checking output
216
+ // Used for PTY-based injection where CLIs don't echo input back
217
+ if (callbacks.skipVerification) {
218
+ try {
219
+ await callbacks.performInjection(injection);
220
+ metrics.successFirstTry++;
221
+ return { success: true, attempts: 1 };
222
+ }
223
+ catch (err) {
224
+ callbacks.logError(`Injection error: ${err?.message || err}`);
225
+ metrics.failed++;
226
+ return { success: false, attempts: 1 };
227
+ }
228
+ }
229
+ for (let attempt = 0; attempt < INJECTION_CONSTANTS.MAX_RETRIES; attempt++) {
230
+ try {
231
+ // On retry attempts, first check if message already exists (race condition fix)
232
+ // Previous injection may have succeeded but verification timed out
233
+ if (attempt > 0) {
234
+ const alreadyExists = await verifyInjection(shortId, from, callbacks.getOutput);
235
+ if (alreadyExists) {
236
+ metrics.successWithRetry++;
237
+ callbacks.log(`Message already present (late verification), skipping re-injection`);
238
+ return { success: true, attempts: attempt + 1 };
239
+ }
240
+ }
241
+ // Perform the injection
242
+ await callbacks.performInjection(injection);
243
+ // Verify it appeared in output
244
+ const verified = await verifyInjection(shortId, from, callbacks.getOutput);
245
+ if (verified) {
246
+ if (attempt === 0) {
247
+ metrics.successFirstTry++;
248
+ }
249
+ else {
250
+ metrics.successWithRetry++;
251
+ callbacks.log(`Injection succeeded on attempt ${attempt + 1}`);
252
+ }
253
+ return { success: true, attempts: attempt + 1 };
254
+ }
255
+ // Not verified - log and retry
256
+ callbacks.log(`Injection not verified, attempt ${attempt + 1}/${INJECTION_CONSTANTS.MAX_RETRIES}`);
257
+ // Backoff before retry
258
+ if (attempt < INJECTION_CONSTANTS.MAX_RETRIES - 1) {
259
+ await sleep(INJECTION_CONSTANTS.RETRY_BACKOFF_MS * (attempt + 1));
260
+ }
261
+ }
262
+ catch (err) {
263
+ callbacks.logError(`Injection error on attempt ${attempt + 1}: ${err?.message || err}`);
264
+ }
265
+ }
266
+ // All retries failed
267
+ metrics.failed++;
268
+ return { success: false, attempts: INJECTION_CONSTANTS.MAX_RETRIES };
269
+ }
270
+ //# sourceMappingURL=shared.js.map
@@ -11,6 +11,7 @@
11
11
  * The key insight: user sees the REAL tmux session, not a proxy.
12
12
  * We just do background parsing and injection.
13
13
  */
14
+ import { type CliType } from './shared.js';
14
15
  export interface TmuxWrapperConfig {
15
16
  name: string;
16
17
  command: string;
@@ -47,7 +48,7 @@ export interface TmuxWrapperConfig {
47
48
  /** Polling interval when waiting for clear input (ms) */
48
49
  inputWaitPollMs?: number;
49
50
  /** CLI type for special handling (auto-detected from command if not set) */
50
- cliType?: 'claude' | 'codex' | 'gemini' | 'droid' | 'other';
51
+ cliType?: 'claude' | 'codex' | 'gemini' | 'droid' | 'opencode' | 'other';
51
52
  /** Enable tmux mouse mode for scroll passthrough (default: true) */
52
53
  mouseMode?: boolean;
53
54
  /** Relay prefix pattern (default: '->relay:') */
@@ -62,12 +63,17 @@ export interface TmuxWrapperConfig {
62
63
  outputStabilityPollMs?: number;
63
64
  /** Stream output to daemon for dashboard log viewing (default: true) */
64
65
  streamLogs?: boolean;
66
+ /** Resume from a previous agent ID (for crash recovery) */
67
+ resumeAgentId?: string;
68
+ /** Dashboard port for API-based spawn/release (preferred over callbacks) */
69
+ dashboardPort?: number;
65
70
  }
66
71
  /**
67
72
  * Get the default relay prefix for a given CLI type.
68
73
  * All agents now use '->relay:' as the unified prefix.
74
+ * @deprecated Use getDefaultRelayPrefix() from shared.js instead
69
75
  */
70
- export declare function getDefaultPrefix(_cliType: 'claude' | 'codex' | 'gemini' | 'droid' | 'other'): string;
76
+ export declare function getDefaultPrefix(_cliType: CliType): string;
71
77
  export declare class TmuxWrapper {
72
78
  private config;
73
79
  private sessionName;
@@ -95,20 +101,35 @@ export declare class TmuxWrapper {
95
101
  private lastSummaryHash;
96
102
  private lastSummaryRawContent;
97
103
  private sessionEndProcessed;
104
+ private sessionEndData?;
98
105
  private pendingRelayCommands;
99
106
  private queuedMessageHashes;
100
107
  private readonly MAX_PENDING_RELAY_COMMANDS;
101
108
  private processedSpawnCommands;
102
109
  private processedReleaseCommands;
110
+ private pendingFencedSpawn;
103
111
  private receivedMessageIdSet;
104
112
  private receivedMessageIdOrder;
105
113
  private readonly MAX_RECEIVED_MESSAGES;
106
114
  private tmuxPath;
115
+ private trajectory?;
116
+ private lastDetectedPhase?;
117
+ private seenToolCalls;
118
+ private seenErrors;
119
+ private continuity?;
120
+ private processedContinuityCommands;
121
+ private agentId?;
122
+ private injectionMetrics;
107
123
  constructor(config: TmuxWrapperConfig);
108
124
  /**
109
125
  * Log to stderr (safe - doesn't interfere with tmux display)
110
126
  */
111
127
  private logStderr;
128
+ /**
129
+ * Detect PDERO phase from output content and auto-transition if needed.
130
+ * Also detects tool calls and errors, recording them to the trajectory.
131
+ */
132
+ private detectAndTransitionPhase;
112
133
  /**
113
134
  * Build the full command with proper quoting
114
135
  * Args containing spaces need to be quoted
@@ -123,9 +144,26 @@ export declare class TmuxWrapper {
123
144
  */
124
145
  start(): Promise<void>;
125
146
  /**
126
- * Inject usage instructions for the agent
147
+ * Initialize trajectory tracking
148
+ * Auto-starts a trajectory if task is provided in config
149
+ */
150
+ private initializeTrajectory;
151
+ /**
152
+ * Initialize agent ID for continuity/resume functionality
153
+ */
154
+ private initializeAgentId;
155
+ /**
156
+ * Get the current agent ID
157
+ */
158
+ getAgentId(): string | undefined;
159
+ /**
160
+ * Inject usage instructions for the agent including persistence protocol
127
161
  */
128
162
  private injectInstructions;
163
+ /**
164
+ * Inject continuity context from previous session
165
+ */
166
+ private injectContinuityContext;
129
167
  /**
130
168
  * Wait for tmux session to be ready
131
169
  */
@@ -148,10 +186,6 @@ export declare class TmuxWrapper {
148
186
  * Poll for ->relay commands in output (silent)
149
187
  */
150
188
  private pollForRelayCommands;
151
- /**
152
- * Strip ANSI escape codes
153
- */
154
- private stripAnsi;
155
189
  /**
156
190
  * Join continuation lines after ->relay commands.
157
191
  * Claude Code and other TUIs insert real newlines in output, causing
@@ -184,6 +218,21 @@ export declare class TmuxWrapper {
184
218
  * [[/SUMMARY]]
185
219
  */
186
220
  private parseSummaryAndSave;
221
+ /**
222
+ * Save a parsed summary to the continuity ledger.
223
+ * Maps summary fields to ledger fields for session recovery.
224
+ */
225
+ private saveSummaryToLedger;
226
+ /**
227
+ * Parse ->continuity: commands from output and handle them.
228
+ * Supported commands:
229
+ * ->continuity:save <<<...>>> - Save session state to ledger
230
+ * ->continuity:load - Request context injection
231
+ * ->continuity:search "query" - Search past handoffs
232
+ * ->continuity:uncertain "..." - Mark item as uncertain
233
+ * ->continuity:handoff <<<...>>> - Create explicit handoff
234
+ */
235
+ private parseContinuityCommands;
187
236
  /**
188
237
  * Parse [[SESSION_END]] blocks from output and close session explicitly.
189
238
  * Agents output this to mark their work session as complete:
@@ -191,12 +240,25 @@ export declare class TmuxWrapper {
191
240
  * [[SESSION_END]]
192
241
  * {"summary": "Completed auth module", "completedTasks": ["login", "logout"]}
193
242
  * [[/SESSION_END]]
243
+ *
244
+ * Also stores the data for use in autoSave to populate handoff (fixes empty handoff issue).
194
245
  */
195
246
  private parseSessionEndAndClose;
247
+ /**
248
+ * Execute spawn via API (if dashboardPort set) or callback
249
+ */
250
+ private executeSpawn;
251
+ /**
252
+ * Execute release via API (if dashboardPort set) or callback
253
+ */
254
+ private executeRelease;
196
255
  /**
197
256
  * Parse ->relay:spawn and ->relay:release commands from output.
198
- * Format:
199
- * ->relay:spawn WorkerName cli "task description"
257
+ * Supports two formats:
258
+ * Single-line: ->relay:spawn WorkerName cli "task description"
259
+ * Multi-line (fenced): ->relay:spawn WorkerName cli <<<
260
+ * task description here
261
+ * can span multiple lines>>>
200
262
  * ->relay:release WorkerName
201
263
  */
202
264
  private parseSpawnReleaseCommands;
@@ -211,7 +273,8 @@ export declare class TmuxWrapper {
211
273
  */
212
274
  private checkForInjectionOpportunity;
213
275
  /**
214
- * Inject message via tmux send-keys
276
+ * Inject message via tmux send-keys.
277
+ * Uses shared injection logic with tmux-specific callbacks.
215
278
  */
216
279
  private injectNextMessage;
217
280
  private hasSeenIncoming;
@@ -228,7 +291,6 @@ export declare class TmuxWrapper {
228
291
  * Some CLIs (like droid) don't handle bracketed paste sequences properly, so we skip -p for them.
229
292
  */
230
293
  private pasteLiteral;
231
- private sleep;
232
294
  /**
233
295
  * Reset session-specific state for wrapper reuse.
234
296
  * Call this when starting a new session with the same wrapper instance.