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
@@ -13,7 +13,7 @@ import path from 'node:path';
13
13
  const LOG_FILE = process.env.AGENT_RELAY_LOG_FILE;
14
14
  const LOG_LEVEL = (process.env.AGENT_RELAY_LOG_LEVEL ?? 'INFO').toUpperCase();
15
15
  const LOG_JSON = process.env.AGENT_RELAY_LOG_JSON === '1';
16
- const DEBUG = process.env.DEBUG === '1' || LOG_LEVEL === 'DEBUG';
16
+ const _DEBUG = process.env.DEBUG === '1' || LOG_LEVEL === 'DEBUG';
17
17
  const LEVEL_PRIORITY = {
18
18
  DEBUG: 0,
19
19
  INFO: 1,
@@ -43,4 +43,28 @@ export declare function listProjects(): Array<{
43
43
  projectRoot: string;
44
44
  dataDir: string;
45
45
  }>;
46
+ /**
47
+ * Detect the actual workspace directory for cloud deployments.
48
+ *
49
+ * In cloud workspaces, repos are cloned to /workspace/{repo-name}.
50
+ * This function finds the correct working directory:
51
+ *
52
+ * Priority:
53
+ * 1. WORKSPACE_CWD env var (explicit override)
54
+ * 2. If baseDir itself is a git repo, use it
55
+ * 3. Scan baseDir for cloned repos - use the first one found (alphabetically)
56
+ * 4. Fall back to baseDir
57
+ *
58
+ * @param baseDir - The base workspace directory (e.g., /workspace)
59
+ * @returns The actual workspace path to use
60
+ */
61
+ export declare function detectWorkspacePath(baseDir: string): string;
62
+ /**
63
+ * List all git repos in a workspace directory.
64
+ * Useful for allowing users to select which repo to work in.
65
+ *
66
+ * @param baseDir - The base workspace directory
67
+ * @returns Array of repo paths
68
+ */
69
+ export declare function listWorkspaceRepos(baseDir: string): string[];
46
70
  //# sourceMappingURL=project-namespace.d.ts.map
@@ -129,4 +129,88 @@ export function listProjects() {
129
129
  }
130
130
  return projects;
131
131
  }
132
+ /**
133
+ * Detect the actual workspace directory for cloud deployments.
134
+ *
135
+ * In cloud workspaces, repos are cloned to /workspace/{repo-name}.
136
+ * This function finds the correct working directory:
137
+ *
138
+ * Priority:
139
+ * 1. WORKSPACE_CWD env var (explicit override)
140
+ * 2. If baseDir itself is a git repo, use it
141
+ * 3. Scan baseDir for cloned repos - use the first one found (alphabetically)
142
+ * 4. Fall back to baseDir
143
+ *
144
+ * @param baseDir - The base workspace directory (e.g., /workspace)
145
+ * @returns The actual workspace path to use
146
+ */
147
+ export function detectWorkspacePath(baseDir) {
148
+ // 1. Explicit override
149
+ if (process.env.WORKSPACE_CWD) {
150
+ return process.env.WORKSPACE_CWD;
151
+ }
152
+ // 2. Check if baseDir itself is a git repo
153
+ if (fs.existsSync(path.join(baseDir, '.git'))) {
154
+ return baseDir;
155
+ }
156
+ // 3. Scan for cloned repos (directories with .git)
157
+ try {
158
+ const entries = fs.readdirSync(baseDir, { withFileTypes: true });
159
+ const repos = [];
160
+ for (const entry of entries) {
161
+ if (entry.isDirectory()) {
162
+ const repoPath = path.join(baseDir, entry.name);
163
+ const gitPath = path.join(repoPath, '.git');
164
+ if (fs.existsSync(gitPath)) {
165
+ repos.push(repoPath);
166
+ }
167
+ }
168
+ }
169
+ // Sort alphabetically for consistent behavior
170
+ repos.sort();
171
+ // Use the first repo found
172
+ if (repos.length > 0) {
173
+ if (repos.length > 1) {
174
+ console.log(`[workspace] Multiple repos found, using first: ${repos[0]} (others: ${repos.slice(1).join(', ')})`);
175
+ }
176
+ else {
177
+ console.log(`[workspace] Detected repo: ${repos[0]}`);
178
+ }
179
+ return repos[0];
180
+ }
181
+ }
182
+ catch (err) {
183
+ // Failed to scan, fall back
184
+ console.warn(`[workspace] Failed to scan ${baseDir}:`, err);
185
+ }
186
+ // 4. Fall back to baseDir
187
+ return baseDir;
188
+ }
189
+ /**
190
+ * List all git repos in a workspace directory.
191
+ * Useful for allowing users to select which repo to work in.
192
+ *
193
+ * @param baseDir - The base workspace directory
194
+ * @returns Array of repo paths
195
+ */
196
+ export function listWorkspaceRepos(baseDir) {
197
+ const repos = [];
198
+ try {
199
+ const entries = fs.readdirSync(baseDir, { withFileTypes: true });
200
+ for (const entry of entries) {
201
+ if (entry.isDirectory()) {
202
+ const repoPath = path.join(baseDir, entry.name);
203
+ const gitPath = path.join(repoPath, '.git');
204
+ if (fs.existsSync(gitPath)) {
205
+ repos.push(repoPath);
206
+ }
207
+ }
208
+ }
209
+ repos.sort();
210
+ }
211
+ catch {
212
+ // Failed to scan
213
+ }
214
+ return repos;
215
+ }
132
216
  //# sourceMappingURL=project-namespace.js.map
@@ -36,6 +36,11 @@ export interface ParserOptions {
36
36
  /** Thinking prefix pattern (default: '->thinking:') */
37
37
  thinkingPrefix?: string;
38
38
  }
39
+ /**
40
+ * Check if a target name is a placeholder commonly used in documentation/examples.
41
+ * These should not be treated as real message targets.
42
+ */
43
+ export declare function isPlaceholderTarget(target: string): boolean;
39
44
  export declare class OutputParser {
40
45
  private options;
41
46
  private inCodeFence;
@@ -106,6 +111,11 @@ export declare class OutputParser {
106
111
  * Returns the command (if valid) and any remaining content after [[/RELAY]].
107
112
  */
108
113
  private finishBlock;
114
+ /**
115
+ * Check if the current fenced inline command should be filtered out.
116
+ * Returns true if the command looks like instructional/example text.
117
+ */
118
+ private shouldFilterFencedInline;
109
119
  /**
110
120
  * Parse while inside a fenced inline block (->relay:Target <<< ... >>>).
111
121
  * Accumulates lines until >>> is seen on its own line.
@@ -57,8 +57,8 @@ function isSpawnOrReleaseCommand(line) {
57
57
  return SPAWN_COMMAND_PATTERN.test(line) || RELEASE_COMMAND_PATTERN.test(line);
58
58
  }
59
59
  // Claude extended thinking block markers - skip content inside these
60
- const THINKING_START = /<antml:thinking>/;
61
- const THINKING_END = /<\/thinking>/;
60
+ const THINKING_START = new RegExp(String.raw `<` + `thinking>`);
61
+ const THINKING_END = new RegExp(String.raw `</` + `thinking>`);
62
62
  /**
63
63
  * Patterns that indicate instructional/example text that should NOT be parsed as actual commands.
64
64
  * These are common in system prompts, documentation, and injected instructions.
@@ -75,6 +75,21 @@ const INSTRUCTIONAL_MARKERS = [
75
75
  /MULTI-LINE:/i, // Multi-line format instruction
76
76
  /RECEIVE:/i, // Receive instruction marker
77
77
  ];
78
+ /**
79
+ * Placeholder target names commonly used in documentation and examples.
80
+ * Messages to these targets should be filtered out as instructional text.
81
+ */
82
+ const PLACEHOLDER_TARGETS = new Set([
83
+ 'agentname',
84
+ 'target',
85
+ 'recipient',
86
+ 'yourtarget',
87
+ 'targetagent',
88
+ 'someagent',
89
+ 'otheragent',
90
+ 'worker', // Too generic, often used in examples
91
+ // NOTE: Don't add 'agent', 'name', 'lead', 'developer', etc. - these can be valid agent names!
92
+ ]);
78
93
  /**
79
94
  * Check if a parsed relay command body looks like instructional/example text.
80
95
  * These patterns commonly appear in system prompts and documentation.
@@ -82,6 +97,13 @@ const INSTRUCTIONAL_MARKERS = [
82
97
  function isInstructionalText(body) {
83
98
  return INSTRUCTIONAL_MARKERS.some(pattern => pattern.test(body));
84
99
  }
100
+ /**
101
+ * Check if a target name is a placeholder commonly used in documentation/examples.
102
+ * These should not be treated as real message targets.
103
+ */
104
+ export function isPlaceholderTarget(target) {
105
+ return PLACEHOLDER_TARGETS.has(target.toLowerCase());
106
+ }
85
107
  /**
86
108
  * Escape special regex characters in a string
87
109
  */
@@ -127,7 +149,8 @@ function buildEscapePattern(prefix, thinkingPrefix) {
127
149
  const ANSI_PATTERN = /\x1b\[[0-9;?]*[a-zA-Z]|\x1b\].*?(?:\x07|\x1b\\)|\r/g;
128
150
  // Pattern for orphaned CSI sequences that lost their escape byte
129
151
  // These look like [?25h, [?2026l, [0m, etc. at the start of content
130
- const ORPHANED_CSI_PATTERN = /^\s*(\[\??\d*[A-Za-z])+\s*/g;
152
+ // Requires at least one digit or question mark to avoid stripping legitimate text like [Agent
153
+ const ORPHANED_CSI_PATTERN = /^\s*(\[(?:\?|\d)\d*[A-Za-z])+\s*/g;
131
154
  /**
132
155
  * Parse a target string that may contain cross-project syntax.
133
156
  * Supports: "agent" (local) or "project:agent" (cross-project)
@@ -467,9 +490,21 @@ export class OutputParser {
467
490
  strippedCount++;
468
491
  continue;
469
492
  }
493
+ // Skip spawn/release commands BEFORE checking fenced format
494
+ // This prevents ->relay:spawn Worker cli <<< from being parsed as a message to "spawn"
495
+ const strippedForSpawnCheck = stripAnsi(line);
496
+ if (isSpawnOrReleaseCommand(strippedForSpawnCheck)) {
497
+ outputLines.push(line);
498
+ continue;
499
+ }
470
500
  // Check for fenced inline start: ->relay:Target <<<
471
501
  const fencedStart = isFencedInlineStart(line);
472
502
  if (fencedStart && this.options.enableInline) {
503
+ // Skip placeholder target names early (common in documentation/examples)
504
+ if (isPlaceholderTarget(fencedStart.target)) {
505
+ outputLines.push(line);
506
+ continue;
507
+ }
473
508
  // Enter fenced inline mode
474
509
  this.inFencedInline = true;
475
510
  this.fencedInlineTarget = fencedStart.target;
@@ -640,6 +675,10 @@ export class OutputParser {
640
675
  return { command: null, output: line };
641
676
  }
642
677
  const { to, project } = parseTarget(target);
678
+ // Skip placeholder target names (common in documentation/examples)
679
+ if (isPlaceholderTarget(to)) {
680
+ return { command: null, output: line };
681
+ }
643
682
  return {
644
683
  command: {
645
684
  to,
@@ -661,6 +700,10 @@ export class OutputParser {
661
700
  return { command: null, output: line };
662
701
  }
663
702
  const { to, project } = parseTarget(target);
703
+ // Skip placeholder target names (common in documentation/examples)
704
+ if (isPlaceholderTarget(to)) {
705
+ return { command: null, output: line };
706
+ }
664
707
  return {
665
708
  command: {
666
709
  to,
@@ -745,6 +788,21 @@ export class OutputParser {
745
788
  }
746
789
  }
747
790
  }
791
+ /**
792
+ * Check if the current fenced inline command should be filtered out.
793
+ * Returns true if the command looks like instructional/example text.
794
+ */
795
+ shouldFilterFencedInline(target, body) {
796
+ // Check for placeholder target names
797
+ if (isPlaceholderTarget(target)) {
798
+ return true;
799
+ }
800
+ // Check for instructional body content
801
+ if (isInstructionalText(body)) {
802
+ return true;
803
+ }
804
+ return false;
805
+ }
748
806
  /**
749
807
  * Parse while inside a fenced inline block (->relay:Target <<< ... >>>).
750
808
  * Accumulates lines until >>> is seen on its own line.
@@ -769,16 +827,19 @@ export class OutputParser {
769
827
  // Only if we have actual content to send
770
828
  if (consecutiveBlankLines >= 2 && this.fencedInlineBuffer.trim().length > 0) {
771
829
  const body = unescapeFenceMarkers(stripAnsi(this.fencedInlineBuffer.trim()));
772
- const command = {
773
- to: this.fencedInlineTarget,
774
- kind: this.fencedInlineKind,
775
- body,
776
- thread: this.fencedInlineThread,
777
- threadProject: this.fencedInlineThreadProject,
778
- project: this.fencedInlineProject,
779
- raw: this.fencedInlineRaw.join('\n'),
780
- };
781
- commands.push(command);
830
+ // Skip instructional/example text (common in system prompts and documentation)
831
+ if (!this.shouldFilterFencedInline(this.fencedInlineTarget, body)) {
832
+ const command = {
833
+ to: this.fencedInlineTarget,
834
+ kind: this.fencedInlineKind,
835
+ body,
836
+ thread: this.fencedInlineThread,
837
+ threadProject: this.fencedInlineThreadProject,
838
+ project: this.fencedInlineProject,
839
+ raw: this.fencedInlineRaw.join('\n'),
840
+ };
841
+ commands.push(command);
842
+ }
782
843
  // Reset fenced inline state
783
844
  this.inFencedInline = false;
784
845
  this.fencedInlineBuffer = '';
@@ -802,16 +863,19 @@ export class OutputParser {
802
863
  // Auto-close and send the incomplete fenced block (if it has content)
803
864
  if (this.fencedInlineBuffer.trim().length > 0) {
804
865
  const body = unescapeFenceMarkers(stripAnsi(this.fencedInlineBuffer.trim()));
805
- const command = {
806
- to: this.fencedInlineTarget,
807
- kind: this.fencedInlineKind,
808
- body,
809
- thread: this.fencedInlineThread,
810
- threadProject: this.fencedInlineThreadProject,
811
- project: this.fencedInlineProject,
812
- raw: this.fencedInlineRaw.join('\n'),
813
- };
814
- commands.push(command);
866
+ // Skip instructional/example text (common in system prompts and documentation)
867
+ if (!this.shouldFilterFencedInline(this.fencedInlineTarget, body)) {
868
+ const command = {
869
+ to: this.fencedInlineTarget,
870
+ kind: this.fencedInlineKind,
871
+ body,
872
+ thread: this.fencedInlineThread,
873
+ threadProject: this.fencedInlineThreadProject,
874
+ project: this.fencedInlineProject,
875
+ raw: this.fencedInlineRaw.join('\n'),
876
+ };
877
+ commands.push(command);
878
+ }
815
879
  }
816
880
  // Reset fenced inline state
817
881
  this.inFencedInline = false;
@@ -848,16 +912,19 @@ export class OutputParser {
848
912
  // Complete the fenced inline command - unescape any \<<< and \>>> in content
849
913
  const body = unescapeFenceMarkers(stripAnsi(this.fencedInlineBuffer.trim()));
850
914
  this.fencedInlineRaw.push(line);
851
- const command = {
852
- to: this.fencedInlineTarget,
853
- kind: this.fencedInlineKind,
854
- body,
855
- thread: this.fencedInlineThread,
856
- threadProject: this.fencedInlineThreadProject,
857
- project: this.fencedInlineProject,
858
- raw: this.fencedInlineRaw.join('\n'),
859
- };
860
- commands.push(command);
915
+ // Skip instructional/example text (common in system prompts and documentation)
916
+ if (!this.shouldFilterFencedInline(this.fencedInlineTarget, body)) {
917
+ const command = {
918
+ to: this.fencedInlineTarget,
919
+ kind: this.fencedInlineKind,
920
+ body,
921
+ thread: this.fencedInlineThread,
922
+ threadProject: this.fencedInlineThreadProject,
923
+ project: this.fencedInlineProject,
924
+ raw: this.fencedInlineRaw.join('\n'),
925
+ };
926
+ commands.push(command);
927
+ }
861
928
  // Reset fenced inline state
862
929
  this.inFencedInline = false;
863
930
  this.fencedInlineBuffer = '';
@@ -6,7 +6,10 @@
6
6
  * Used for spawned workers that don't need direct user interaction.
7
7
  */
8
8
  import { EventEmitter } from 'node:events';
9
+ import type { ParsedSummary, SessionEndMarker } from './parser.js';
9
10
  import type { SpeakOnTrigger } from '../protocol/types.js';
11
+ import { type LifecycleHooks } from '../hooks/index.js';
12
+ import { type InjectionMetrics, type CliType } from './shared.js';
10
13
  export interface PtyWrapperConfig {
11
14
  name: string;
12
15
  command: string;
@@ -16,10 +19,14 @@ export interface PtyWrapperConfig {
16
19
  env?: Record<string, string>;
17
20
  /** Relay prefix pattern (default: '->relay:') */
18
21
  relayPrefix?: string;
22
+ /** CLI type for special handling (auto-detected from command if not set) */
23
+ cliType?: CliType;
19
24
  /** Directory to write log files (optional) */
20
25
  logsDir?: string;
21
26
  /** Dashboard port for spawn/release API calls (enables nested spawning from spawned agents) */
22
27
  dashboardPort?: number;
28
+ /** Allow this agent to spawn other agents (default: true for Lead, false for spawned workers) */
29
+ allowSpawn?: boolean;
23
30
  /** Callback for spawn commands (fallback if dashboardPort not set) */
24
31
  onSpawn?: (name: string, cli: string, task: string) => Promise<void>;
25
32
  /** Callback for release commands (fallback if dashboardPort not set) */
@@ -32,11 +39,47 @@ export interface PtyWrapperConfig {
32
39
  shadowSpeakOn?: SpeakOnTrigger[];
33
40
  /** Stream output to daemon for dashboard log viewing (default: true) */
34
41
  streamLogs?: boolean;
42
+ /** Task/role description for trajectory tracking */
43
+ task?: string;
44
+ /** Custom lifecycle hooks */
45
+ hooks?: LifecycleHooks;
46
+ /** Enable trajectory tracking hooks (default: true if task provided) */
47
+ trajectoryTracking?: boolean;
48
+ /** Resume from a previous agent ID (for crash recovery) */
49
+ resumeAgentId?: string;
50
+ /**
51
+ * Summary reminder configuration. Set to false to disable.
52
+ * Default: { intervalMinutes: 15, minOutputs: 50 }
53
+ */
54
+ summaryReminder?: {
55
+ /** Minutes of activity before reminding (default: 15) */
56
+ intervalMinutes?: number;
57
+ /** Minimum significant outputs before reminding (default: 50) */
58
+ minOutputs?: number;
59
+ } | false;
60
+ }
61
+ export interface InjectionFailedEvent {
62
+ messageId: string;
63
+ from: string;
64
+ attempts: number;
65
+ }
66
+ export interface SummaryEvent {
67
+ agentName: string;
68
+ summary: ParsedSummary;
69
+ }
70
+ export interface SessionEndEvent {
71
+ agentName: string;
72
+ marker: SessionEndMarker;
35
73
  }
36
74
  export interface PtyWrapperEvents {
37
75
  output: (data: string) => void;
38
76
  exit: (code: number) => void;
39
77
  error: (error: Error) => void;
78
+ 'injection-failed': (event: InjectionFailedEvent) => void;
79
+ /** Emitted when agent outputs a [[SUMMARY]] block. Cloud services can persist this. */
80
+ 'summary': (event: SummaryEvent) => void;
81
+ /** Emitted when agent outputs a [[SESSION_END]] block. Cloud services can handle session closure. */
82
+ 'session-end': (event: SessionEndEvent) => void;
40
83
  }
41
84
  export declare class PtyWrapper extends EventEmitter {
42
85
  private config;
@@ -46,27 +89,99 @@ export declare class PtyWrapper extends EventEmitter {
46
89
  private outputBuffer;
47
90
  private rawBuffer;
48
91
  private relayPrefix;
92
+ private cliType;
49
93
  private sentMessageHashes;
94
+ private receivedMessageIds;
50
95
  private processedSpawnCommands;
51
96
  private processedReleaseCommands;
97
+ private pendingFencedSpawn;
52
98
  private messageQueue;
53
99
  private isInjecting;
54
100
  private readyForMessages;
101
+ private lastOutputTime;
102
+ private injectionMetrics;
55
103
  private logFilePath?;
56
104
  private logStream?;
57
- private hasAcceptedPrompt;
105
+ private acceptedPrompts;
106
+ private hookRegistry;
107
+ private sessionStartTime;
108
+ private continuity?;
109
+ private agentId?;
110
+ private processedContinuityCommands;
111
+ private lastSummaryRawContent;
112
+ private sessionEndProcessed;
113
+ private inThinkingBlock;
114
+ private lastSummaryTime;
115
+ private outputsSinceSummary;
116
+ private detectedTask?;
117
+ private sessionEndData?;
118
+ private instructionsInjected;
119
+ private continuityInjected;
120
+ private recentLogChunks;
121
+ private static readonly LOG_DEDUP_WINDOW_MS;
122
+ private static readonly LOG_DEDUP_MAX_SIZE;
123
+ private lastParsedLength;
124
+ private lastContinuityParsedLength;
58
125
  constructor(config: PtyWrapperConfig);
59
126
  /**
60
127
  * Start the agent process
61
128
  */
62
129
  start(): Promise<void>;
130
+ /**
131
+ * Initialize agent ID for continuity/resume functionality
132
+ */
133
+ private initializeAgentId;
134
+ /**
135
+ * Get the current agent ID
136
+ */
137
+ getAgentId(): string | undefined;
138
+ /**
139
+ * Inject continuity context from previous session.
140
+ * Called after agent ID initialization to restore state from ledger.
141
+ */
142
+ private injectContinuityContext;
143
+ /**
144
+ * Parse ->continuity: commands from output and handle them.
145
+ *
146
+ * Supported commands:
147
+ * ->continuity:save <<<...>>> - Save session state to ledger
148
+ * ->continuity:load - Request context injection
149
+ * ->continuity:search "query" - Search past handoffs
150
+ * ->continuity:uncertain "..." - Mark item as uncertain
151
+ * ->continuity:handoff <<<...>>> - Create explicit handoff
152
+ */
153
+ private parseContinuityCommands;
63
154
  /**
64
155
  * Handle output from the process
65
156
  */
66
157
  private handleOutput;
67
158
  /**
68
- * Auto-accept Claude's first-run prompts for --dangerously-skip-permissions
69
- * Detects the acceptance prompt and sends "2" to select "Yes, I accept"
159
+ * Filter Claude's extended thinking blocks from output.
160
+ * Thinking blocks are wrapped in <thinking>...</thinking> tags and should
161
+ * not be streamed to the dashboard or stored in output buffers.
162
+ *
163
+ * This method tracks state across calls to handle multi-line thinking blocks.
164
+ */
165
+ private filterThinkingBlocks;
166
+ /**
167
+ * Check if a log chunk is a duplicate (recently streamed).
168
+ * Prevents terminal redraws from causing duplicate log entries in the dashboard.
169
+ *
170
+ * Uses content normalization and time-based deduplication:
171
+ * - Strips whitespace and normalizes content for comparison
172
+ * - Considers chunks with same normalized content within LOG_DEDUP_WINDOW_MS as duplicates
173
+ * - Cleans up old entries to prevent memory growth
174
+ */
175
+ private isDuplicateLogChunk;
176
+ /**
177
+ * Auto-accept Claude's first-run prompts
178
+ * Handles multiple prompts in sequence:
179
+ * 1. --dangerously-skip-permissions acceptance ("Yes, I accept")
180
+ * 2. Trust directory prompt ("Yes, I trust this folder")
181
+ * 3. "Ready to code here?" permission prompt ("Yes, continue")
182
+ *
183
+ * Uses a Set to track which prompts have been accepted, allowing
184
+ * multiple different prompts to be handled in sequence.
70
185
  */
71
186
  private handleAutoAcceptPrompts;
72
187
  /**
@@ -84,6 +199,9 @@ export declare class PtyWrapper extends EventEmitter {
84
199
  * Parse relay commands from output.
85
200
  * Handles both single-line and multi-line (fenced) formats.
86
201
  * Deduplication via sentMessageHashes.
202
+ *
203
+ * Optimization: Only parses new content since last parse to avoid O(n²) behavior.
204
+ * Uses lookback buffer for incomplete fenced messages that span output chunks.
87
205
  */
88
206
  private parseRelayCommands;
89
207
  /**
@@ -95,19 +213,30 @@ export declare class PtyWrapper extends EventEmitter {
95
213
  * Format: ->relay:Target [thread:xxx] message body
96
214
  */
97
215
  private parseSingleLineMessages;
98
- /**
99
- * Strip ANSI escape codes from string.
100
- * Converts cursor movements to spaces to preserve visual layout.
101
- */
102
- private stripAnsi;
103
216
  /**
104
217
  * Send relay command to daemon
105
218
  */
106
219
  private sendRelayCommand;
220
+ /** Valid CLI types for spawn commands */
221
+ private static readonly VALID_CLI_TYPES;
222
+ /** Validate agent name format (PascalCase, alphanumeric, 2-30 chars) */
223
+ private isValidAgentName;
224
+ /** Validate CLI type */
225
+ private isValidCliType;
107
226
  /**
108
227
  * Parse spawn/release commands from output
109
228
  * Uses string-based parsing for robustness with PTY output.
229
+ * Supports two formats:
230
+ * Single-line: ->relay:spawn WorkerName cli "task description"
231
+ * Multi-line (fenced): ->relay:spawn WorkerName cli <<<
232
+ * task description here
233
+ * can span multiple lines>>>
110
234
  * Delegates to dashboard API if dashboardPort is set (for nested spawns).
235
+ *
236
+ * STRICT VALIDATION:
237
+ * - Command must be at start of line (after whitespace)
238
+ * - Agent name must be PascalCase (e.g., Backend, Frontend, Worker1)
239
+ * - CLI must be a known type (claude, codex, gemini, etc.)
111
240
  */
112
241
  private parseSpawnReleaseCommands;
113
242
  /**
@@ -124,11 +253,30 @@ export declare class PtyWrapper extends EventEmitter {
124
253
  */
125
254
  private handleIncomingMessage;
126
255
  /**
127
- * Process queued messages
256
+ * Wait for output to stabilize before injection.
257
+ * Returns true if output has been stable for the required duration.
258
+ */
259
+ private waitForOutputStable;
260
+ /**
261
+ * Check if the agent process is still alive and responsive.
262
+ */
263
+ private isAgentAlive;
264
+ /**
265
+ * Process queued messages with reliability improvements:
266
+ * 1. Wait for output stability before injection
267
+ * 2. Verify injection appeared in output
268
+ * 3. Retry with backoff on failure
269
+ * 4. Fall back to logging on complete failure
270
+ *
271
+ * Uses shared injection logic with PTY-specific callbacks.
128
272
  */
129
273
  private processMessageQueue;
130
274
  /**
131
- * Inject usage instructions
275
+ * Queue minimal agent identity notification as the first message.
276
+ *
277
+ * Full protocol instructions are in ~/.claude/CLAUDE.md (set up by entrypoint.sh).
278
+ * We only inject a brief identity message here to let the agent know its name
279
+ * and that it's connected to the relay.
132
280
  */
133
281
  private injectInstructions;
134
282
  /**
@@ -146,15 +294,11 @@ export declare class PtyWrapper extends EventEmitter {
146
294
  /**
147
295
  * Stop the agent process
148
296
  */
149
- stop(): void;
297
+ stop(): Promise<void>;
150
298
  /**
151
299
  * Kill the process immediately
152
300
  */
153
- kill(): void;
154
- /**
155
- * Sleep helper
156
- */
157
- private sleep;
301
+ kill(): Promise<void>;
158
302
  /**
159
303
  * Close the log file stream
160
304
  */
@@ -163,5 +307,42 @@ export declare class PtyWrapper extends EventEmitter {
163
307
  get name(): string;
164
308
  get pid(): number | undefined;
165
309
  get logPath(): string | undefined;
310
+ /**
311
+ * Track significant outputs and inject summary reminder if needed.
312
+ * Works with any CLI (Claude, Gemini, Codex, etc.)
313
+ */
314
+ private trackOutputAndRemind;
315
+ /**
316
+ * Check for [[SUMMARY]] blocks and emit 'summary' event.
317
+ * Allows cloud services to persist summaries without hardcoding storage.
318
+ * Also updates the local continuity ledger for session recovery.
319
+ */
320
+ private checkForSummaryAndEmit;
321
+ /**
322
+ * Save a parsed summary to the continuity ledger.
323
+ * Maps summary fields to ledger fields for session recovery.
324
+ */
325
+ private saveSummaryToLedger;
326
+ /**
327
+ * Check for [[SESSION_END]] blocks and emit 'session-end' event.
328
+ * Allows cloud services to handle session closure without hardcoding storage.
329
+ * Also stores the data for use in autoSave to populate handoff.
330
+ */
331
+ private checkForSessionEndAndEmit;
332
+ /**
333
+ * Reset session-specific state for wrapper reuse.
334
+ * Call this when starting a new session with the same wrapper instance.
335
+ */
336
+ resetSessionState(): void;
337
+ /**
338
+ * Get injection reliability metrics
339
+ */
340
+ getInjectionMetrics(): InjectionMetrics & {
341
+ successRate: number;
342
+ };
343
+ /**
344
+ * Get count of pending messages in queue
345
+ */
346
+ get pendingMessageCount(): number;
166
347
  }
167
348
  //# sourceMappingURL=pty-wrapper.d.ts.map