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,472 @@
1
+ /**
2
+ * Handoff Store
3
+ *
4
+ * Persists cross-session handoffs as markdown files.
5
+ * Organized by agent, with timestamps in filenames.
6
+ */
7
+ import fs from 'node:fs/promises';
8
+ import path from 'node:path';
9
+ import crypto from 'node:crypto';
10
+ export class HandoffStore {
11
+ basePath;
12
+ constructor(basePath) {
13
+ this.basePath = basePath;
14
+ }
15
+ /**
16
+ * Ensure the handoffs directory exists
17
+ */
18
+ async initialize() {
19
+ await fs.mkdir(this.basePath, { recursive: true });
20
+ }
21
+ /**
22
+ * Generate a unique handoff ID
23
+ */
24
+ generateId() {
25
+ return `ho_${crypto.randomBytes(8).toString('hex')}`;
26
+ }
27
+ /**
28
+ * Get the directory path for an agent's handoffs
29
+ */
30
+ getAgentDir(agentName) {
31
+ const safeName = agentName.replace(/[^a-zA-Z0-9_-]/g, '_');
32
+ return path.join(this.basePath, safeName);
33
+ }
34
+ /**
35
+ * Generate a filename for a handoff
36
+ */
37
+ generateFilename(handoff) {
38
+ const date = handoff.createdAt.toISOString().split('T')[0];
39
+ const taskSlug = handoff.taskDescription
40
+ .toLowerCase()
41
+ .replace(/[^a-z0-9]+/g, '-')
42
+ .slice(0, 40)
43
+ .replace(/-+$/, '');
44
+ return `${date}-${taskSlug || 'handoff'}-${handoff.id.slice(-6)}.md`;
45
+ }
46
+ /**
47
+ * Convert a handoff to markdown format
48
+ */
49
+ toMarkdown(handoff) {
50
+ const lines = [];
51
+ // YAML frontmatter
52
+ lines.push('---');
53
+ lines.push(`id: ${handoff.id}`);
54
+ lines.push(`agent: ${handoff.agentName}`);
55
+ lines.push(`cli: ${handoff.cli}`);
56
+ lines.push(`created: ${handoff.createdAt.toISOString()}`);
57
+ lines.push(`trigger: ${handoff.triggerReason}`);
58
+ if (handoff.trajectoryId) {
59
+ lines.push(`trajectoryId: ${handoff.trajectoryId}`);
60
+ }
61
+ if (handoff.pderoPhase) {
62
+ lines.push(`pderoPhase: ${handoff.pderoPhase}`);
63
+ }
64
+ if (handoff.confidence !== undefined) {
65
+ lines.push(`confidence: ${handoff.confidence}`);
66
+ }
67
+ if (handoff.relatedHandoffs.length > 0) {
68
+ lines.push(`relatedHandoffs:`);
69
+ for (const id of handoff.relatedHandoffs) {
70
+ lines.push(` - ${id}`);
71
+ }
72
+ }
73
+ lines.push('---');
74
+ lines.push('');
75
+ // Title
76
+ lines.push(`# ${handoff.taskDescription || 'Handoff'}`);
77
+ lines.push('');
78
+ // Summary
79
+ if (handoff.summary) {
80
+ lines.push('## Summary');
81
+ lines.push('');
82
+ lines.push(handoff.summary);
83
+ lines.push('');
84
+ }
85
+ // Completed work
86
+ if (handoff.completedWork.length > 0) {
87
+ lines.push('## Completed');
88
+ lines.push('');
89
+ for (const item of handoff.completedWork) {
90
+ lines.push(`- ${item}`);
91
+ }
92
+ lines.push('');
93
+ }
94
+ // Next steps
95
+ if (handoff.nextSteps.length > 0) {
96
+ lines.push('## Next Steps');
97
+ lines.push('');
98
+ for (const item of handoff.nextSteps) {
99
+ lines.push(`- ${item}`);
100
+ }
101
+ lines.push('');
102
+ }
103
+ // Decisions
104
+ if (handoff.decisions.length > 0) {
105
+ lines.push('## Key Decisions');
106
+ lines.push('');
107
+ for (const decision of handoff.decisions) {
108
+ lines.push(`### ${decision.decision}`);
109
+ if (decision.reasoning) {
110
+ lines.push('');
111
+ lines.push(`**Reasoning:** ${decision.reasoning}`);
112
+ }
113
+ if (decision.alternatives && decision.alternatives.length > 0) {
114
+ lines.push('');
115
+ lines.push('**Alternatives considered:**');
116
+ for (const alt of decision.alternatives) {
117
+ lines.push(`- ${alt}`);
118
+ }
119
+ }
120
+ if (decision.confidence !== undefined) {
121
+ lines.push('');
122
+ lines.push(`**Confidence:** ${Math.round(decision.confidence * 100)}%`);
123
+ }
124
+ lines.push('');
125
+ }
126
+ }
127
+ // File references
128
+ if (handoff.fileReferences.length > 0) {
129
+ lines.push('## Files');
130
+ lines.push('');
131
+ for (const file of handoff.fileReferences) {
132
+ let line = `- \`${file.path}\``;
133
+ if (file.lines) {
134
+ line += `:${file.lines[0]}-${file.lines[1]}`;
135
+ }
136
+ if (file.description) {
137
+ line += ` - ${file.description}`;
138
+ }
139
+ lines.push(line);
140
+ }
141
+ lines.push('');
142
+ }
143
+ // Learnings
144
+ if (handoff.learnings && handoff.learnings.length > 0) {
145
+ lines.push('## Learnings');
146
+ lines.push('');
147
+ for (const learning of handoff.learnings) {
148
+ lines.push(`- ${learning}`);
149
+ }
150
+ lines.push('');
151
+ }
152
+ return lines.join('\n');
153
+ }
154
+ /**
155
+ * Parse a markdown file back to a Handoff object
156
+ */
157
+ fromMarkdown(content, _filename) {
158
+ const handoff = {
159
+ id: '',
160
+ agentName: '',
161
+ cli: 'unknown',
162
+ summary: '',
163
+ taskDescription: '',
164
+ completedWork: [],
165
+ nextSteps: [],
166
+ fileReferences: [],
167
+ decisions: [],
168
+ relatedHandoffs: [],
169
+ createdAt: new Date(),
170
+ triggerReason: 'manual',
171
+ };
172
+ // Parse YAML frontmatter
173
+ const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/);
174
+ if (frontmatterMatch) {
175
+ const frontmatter = frontmatterMatch[1];
176
+ const lines = frontmatter.split('\n');
177
+ for (const line of lines) {
178
+ const colonIndex = line.indexOf(':');
179
+ if (colonIndex === -1)
180
+ continue;
181
+ const key = line.slice(0, colonIndex).trim();
182
+ const value = line.slice(colonIndex + 1).trim();
183
+ switch (key) {
184
+ case 'id':
185
+ handoff.id = value;
186
+ break;
187
+ case 'agent':
188
+ handoff.agentName = value;
189
+ break;
190
+ case 'cli':
191
+ handoff.cli = value;
192
+ break;
193
+ case 'created':
194
+ handoff.createdAt = new Date(value);
195
+ break;
196
+ case 'trigger': {
197
+ const validTriggers = ['manual', 'trajectory_complete', 'context_limit', 'auto_restart', 'crash', 'session_end'];
198
+ if (validTriggers.includes(value)) {
199
+ handoff.triggerReason = value;
200
+ }
201
+ break;
202
+ }
203
+ case 'trajectoryId':
204
+ handoff.trajectoryId = value;
205
+ break;
206
+ case 'pderoPhase': {
207
+ const validPhases = ['plan', 'design', 'execute', 'review', 'observe'];
208
+ if (validPhases.includes(value)) {
209
+ handoff.pderoPhase = value;
210
+ }
211
+ break;
212
+ }
213
+ case 'confidence': {
214
+ const conf = parseFloat(value);
215
+ if (!isNaN(conf)) {
216
+ handoff.confidence = Math.max(0, Math.min(1, conf));
217
+ }
218
+ break;
219
+ }
220
+ }
221
+ }
222
+ // Parse relatedHandoffs array
223
+ const relatedMatch = frontmatter.match(/relatedHandoffs:\n((?:\s+-\s+\S+\n?)+)/);
224
+ if (relatedMatch) {
225
+ handoff.relatedHandoffs = relatedMatch[1]
226
+ .split('\n')
227
+ .map((l) => l.replace(/^\s+-\s+/, '').trim())
228
+ .filter(Boolean);
229
+ }
230
+ }
231
+ // Parse body
232
+ const body = content.replace(/^---\n[\s\S]*?\n---\n*/, '');
233
+ // Extract title
234
+ const titleMatch = body.match(/^#\s+(.+)$/m);
235
+ if (titleMatch) {
236
+ handoff.taskDescription = titleMatch[1];
237
+ }
238
+ // Extract sections
239
+ const sections = body.split(/^##\s+/m).slice(1);
240
+ for (const section of sections) {
241
+ const [header, ...contentLines] = section.split('\n');
242
+ const sectionContent = contentLines.join('\n').trim();
243
+ switch (header.trim().toLowerCase()) {
244
+ case 'summary':
245
+ handoff.summary = sectionContent;
246
+ break;
247
+ case 'completed':
248
+ handoff.completedWork = this.parseListItems(sectionContent);
249
+ break;
250
+ case 'next steps':
251
+ handoff.nextSteps = this.parseListItems(sectionContent);
252
+ break;
253
+ case 'files':
254
+ handoff.fileReferences = this.parseFileRefs(sectionContent);
255
+ break;
256
+ case 'learnings':
257
+ handoff.learnings = this.parseListItems(sectionContent);
258
+ break;
259
+ case 'key decisions':
260
+ handoff.decisions = this.parseDecisions(sectionContent);
261
+ break;
262
+ }
263
+ }
264
+ return handoff;
265
+ }
266
+ parseListItems(content) {
267
+ return content
268
+ .split('\n')
269
+ .filter((l) => l.startsWith('- '))
270
+ .map((l) => l.slice(2).trim());
271
+ }
272
+ parseFileRefs(content) {
273
+ return content
274
+ .split('\n')
275
+ .filter((l) => l.startsWith('- '))
276
+ .map((l) => {
277
+ const match = l.match(/^-\s+`([^`]+)`(?::(\d+)-(\d+))?(?:\s+-\s+(.+))?$/);
278
+ if (!match)
279
+ return null;
280
+ const ref = { path: match[1] };
281
+ if (match[2] && match[3]) {
282
+ const startLine = parseInt(match[2], 10);
283
+ const endLine = parseInt(match[3], 10);
284
+ // Only set lines if both are valid numbers
285
+ if (!isNaN(startLine) && !isNaN(endLine)) {
286
+ ref.lines = [startLine, endLine];
287
+ }
288
+ }
289
+ if (match[4]) {
290
+ ref.description = match[4];
291
+ }
292
+ return ref;
293
+ })
294
+ .filter((r) => r !== null);
295
+ }
296
+ parseDecisions(content) {
297
+ const decisions = [];
298
+ const decisionBlocks = content.split(/^###\s+/m).slice(1);
299
+ for (const block of decisionBlocks) {
300
+ const [decisionText, ...rest] = block.split('\n');
301
+ const blockContent = rest.join('\n');
302
+ const decision = {
303
+ decision: decisionText.trim(),
304
+ timestamp: new Date(),
305
+ };
306
+ const reasoningMatch = blockContent.match(/\*\*Reasoning:\*\*\s*(.+)/);
307
+ if (reasoningMatch) {
308
+ decision.reasoning = reasoningMatch[1];
309
+ }
310
+ const confidenceMatch = blockContent.match(/\*\*Confidence:\*\*\s*(\d+)%/);
311
+ if (confidenceMatch) {
312
+ const conf = parseInt(confidenceMatch[1], 10) / 100;
313
+ if (!isNaN(conf)) {
314
+ decision.confidence = Math.max(0, Math.min(1, conf));
315
+ }
316
+ }
317
+ decisions.push(decision);
318
+ }
319
+ return decisions;
320
+ }
321
+ /**
322
+ * Save a handoff
323
+ */
324
+ async save(handoff) {
325
+ // Ensure ID exists
326
+ if (!handoff.id) {
327
+ handoff.id = this.generateId();
328
+ }
329
+ // Ensure createdAt exists
330
+ if (!handoff.createdAt) {
331
+ handoff.createdAt = new Date();
332
+ }
333
+ const agentDir = this.getAgentDir(handoff.agentName);
334
+ await fs.mkdir(agentDir, { recursive: true });
335
+ const filename = this.generateFilename(handoff);
336
+ const filePath = path.join(agentDir, filename);
337
+ const markdown = this.toMarkdown(handoff);
338
+ await fs.writeFile(filePath, markdown, 'utf-8');
339
+ return handoff.id;
340
+ }
341
+ /**
342
+ * Load a handoff by ID
343
+ */
344
+ async loadById(handoffId) {
345
+ // Search through all agent directories
346
+ try {
347
+ const agents = await fs.readdir(this.basePath);
348
+ for (const agent of agents) {
349
+ const agentDir = path.join(this.basePath, agent);
350
+ const stat = await fs.stat(agentDir);
351
+ if (!stat.isDirectory())
352
+ continue;
353
+ const files = await fs.readdir(agentDir);
354
+ for (const file of files) {
355
+ if (!file.endsWith('.md'))
356
+ continue;
357
+ if (!file.includes(handoffId.slice(-6)))
358
+ continue;
359
+ const content = await fs.readFile(path.join(agentDir, file), 'utf-8');
360
+ const handoff = this.fromMarkdown(content, file);
361
+ if (handoff.id === handoffId) {
362
+ return handoff;
363
+ }
364
+ }
365
+ }
366
+ }
367
+ catch (error) {
368
+ if (error.code === 'ENOENT') {
369
+ return null;
370
+ }
371
+ throw error;
372
+ }
373
+ return null;
374
+ }
375
+ /**
376
+ * Get the latest handoff for an agent
377
+ */
378
+ async getLatest(agentName) {
379
+ const handoffs = await this.listForAgent(agentName, 1);
380
+ return handoffs[0] || null;
381
+ }
382
+ /**
383
+ * List handoffs for an agent (sorted by date, newest first)
384
+ */
385
+ async listForAgent(agentName, limit) {
386
+ const agentDir = this.getAgentDir(agentName);
387
+ try {
388
+ const files = await fs.readdir(agentDir);
389
+ const mdFiles = files.filter((f) => f.endsWith('.md')).sort().reverse();
390
+ const handoffs = [];
391
+ const filesToRead = limit ? mdFiles.slice(0, limit) : mdFiles;
392
+ for (const file of filesToRead) {
393
+ const content = await fs.readFile(path.join(agentDir, file), 'utf-8');
394
+ handoffs.push(this.fromMarkdown(content, file));
395
+ }
396
+ return handoffs;
397
+ }
398
+ catch (error) {
399
+ if (error.code === 'ENOENT') {
400
+ return [];
401
+ }
402
+ throw error;
403
+ }
404
+ }
405
+ /**
406
+ * List all agents with handoffs
407
+ */
408
+ async listAgents() {
409
+ try {
410
+ const entries = await fs.readdir(this.basePath, { withFileTypes: true });
411
+ return entries.filter((e) => e.isDirectory()).map((e) => e.name);
412
+ }
413
+ catch (error) {
414
+ if (error.code === 'ENOENT') {
415
+ return [];
416
+ }
417
+ throw error;
418
+ }
419
+ }
420
+ /**
421
+ * Count handoffs for an agent
422
+ */
423
+ async countForAgent(agentName) {
424
+ const agentDir = this.getAgentDir(agentName);
425
+ try {
426
+ const files = await fs.readdir(agentDir);
427
+ return files.filter((f) => f.endsWith('.md')).length;
428
+ }
429
+ catch (error) {
430
+ if (error.code === 'ENOENT') {
431
+ return 0;
432
+ }
433
+ throw error;
434
+ }
435
+ }
436
+ /**
437
+ * Delete a handoff by ID
438
+ */
439
+ async delete(handoffId) {
440
+ // Find and delete the handoff file
441
+ try {
442
+ const agents = await fs.readdir(this.basePath);
443
+ for (const agent of agents) {
444
+ const agentDir = path.join(this.basePath, agent);
445
+ const stat = await fs.stat(agentDir);
446
+ if (!stat.isDirectory())
447
+ continue;
448
+ const files = await fs.readdir(agentDir);
449
+ for (const file of files) {
450
+ if (!file.endsWith('.md'))
451
+ continue;
452
+ if (!file.includes(handoffId.slice(-6)))
453
+ continue;
454
+ const content = await fs.readFile(path.join(agentDir, file), 'utf-8');
455
+ const handoff = this.fromMarkdown(content, file);
456
+ if (handoff.id === handoffId) {
457
+ await fs.unlink(path.join(agentDir, file));
458
+ return true;
459
+ }
460
+ }
461
+ }
462
+ }
463
+ catch (error) {
464
+ if (error.code === 'ENOENT') {
465
+ return false;
466
+ }
467
+ throw error;
468
+ }
469
+ return false;
470
+ }
471
+ }
472
+ //# sourceMappingURL=handoff-store.js.map
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Continuity System
3
+ *
4
+ * CLI-agnostic session continuity for Agent Relay.
5
+ * Preserves agent state across sessions via ledgers and handoffs.
6
+ *
7
+ * Key components:
8
+ * - Ledgers: Within-session state snapshots (JSON)
9
+ * - Handoffs: Cross-session transfer documents (Markdown)
10
+ * - Parser: Detects `->continuity:` patterns in agent output
11
+ * - Formatter: Formats context for injection
12
+ * - Manager: Central service coordinating all operations
13
+ *
14
+ * Usage:
15
+ * ```typescript
16
+ * import { getContinuityManager, parseContinuityCommand } from './continuity';
17
+ *
18
+ * const manager = getContinuityManager();
19
+ *
20
+ * // On agent spawn - inject previous context
21
+ * const context = await manager.getStartupContext('Alice');
22
+ * if (context) {
23
+ * await injectMessage(context.formatted);
24
+ * }
25
+ *
26
+ * // On agent output - check for continuity commands
27
+ * const command = parseContinuityCommand(output);
28
+ * if (command) {
29
+ * const response = await manager.handleCommand('Alice', command);
30
+ * if (response) {
31
+ * await injectMessage(response);
32
+ * }
33
+ * }
34
+ *
35
+ * // On agent exit - auto-save
36
+ * await manager.autoSave('Alice', 'restart');
37
+ * ```
38
+ */
39
+ export type { Decision, FileRef, Ledger, Handoff, HandoffTrigger, ContinuityCommand, StartupContext, ContinuityPaths, SaveLedgerOptions, SearchOptions, } from './types.js';
40
+ export { parseContinuityCommand, hasContinuityCommand, parseSaveContent, parseHandoffContent, extractAllCommands, isPlaceholderValue, filterPlaceholders, type ParsedHandoffContent, } from './parser.js';
41
+ export { formatStartupContext, formatLedger, formatHandoff, formatSearchResults, formatBriefStatus, formatFileRefs, formatDecisions, type FormatOptions, } from './formatter.js';
42
+ export { LedgerStore } from './ledger-store.js';
43
+ export { HandoffStore } from './handoff-store.js';
44
+ export { ContinuityManager, getContinuityManager, resetContinuityManager, type ContinuityManagerOptions, } from './manager.js';
45
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Continuity System
3
+ *
4
+ * CLI-agnostic session continuity for Agent Relay.
5
+ * Preserves agent state across sessions via ledgers and handoffs.
6
+ *
7
+ * Key components:
8
+ * - Ledgers: Within-session state snapshots (JSON)
9
+ * - Handoffs: Cross-session transfer documents (Markdown)
10
+ * - Parser: Detects `->continuity:` patterns in agent output
11
+ * - Formatter: Formats context for injection
12
+ * - Manager: Central service coordinating all operations
13
+ *
14
+ * Usage:
15
+ * ```typescript
16
+ * import { getContinuityManager, parseContinuityCommand } from './continuity';
17
+ *
18
+ * const manager = getContinuityManager();
19
+ *
20
+ * // On agent spawn - inject previous context
21
+ * const context = await manager.getStartupContext('Alice');
22
+ * if (context) {
23
+ * await injectMessage(context.formatted);
24
+ * }
25
+ *
26
+ * // On agent output - check for continuity commands
27
+ * const command = parseContinuityCommand(output);
28
+ * if (command) {
29
+ * const response = await manager.handleCommand('Alice', command);
30
+ * if (response) {
31
+ * await injectMessage(response);
32
+ * }
33
+ * }
34
+ *
35
+ * // On agent exit - auto-save
36
+ * await manager.autoSave('Alice', 'restart');
37
+ * ```
38
+ */
39
+ // Parser
40
+ export { parseContinuityCommand, hasContinuityCommand, parseSaveContent, parseHandoffContent, extractAllCommands, isPlaceholderValue, filterPlaceholders, } from './parser.js';
41
+ // Formatter
42
+ export { formatStartupContext, formatLedger, formatHandoff, formatSearchResults, formatBriefStatus, formatFileRefs, formatDecisions, } from './formatter.js';
43
+ // Stores
44
+ export { LedgerStore } from './ledger-store.js';
45
+ export { HandoffStore } from './handoff-store.js';
46
+ // Manager
47
+ export { ContinuityManager, getContinuityManager, resetContinuityManager, } from './manager.js';
48
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Ledger Store
3
+ *
4
+ * Persists within-session state as JSON files.
5
+ * One ledger per agent, overwritten each session.
6
+ *
7
+ * Features:
8
+ * - agentId index for O(1) lookups
9
+ * - Hash-based filenames to avoid collisions
10
+ * - File locking for concurrent access safety
11
+ */
12
+ import type { Ledger } from './types.js';
13
+ export declare class LedgerStore {
14
+ private basePath;
15
+ private indexPath;
16
+ private index;
17
+ private locks;
18
+ private indexLock;
19
+ constructor(basePath: string);
20
+ /**
21
+ * Ensure the ledgers directory exists
22
+ */
23
+ initialize(): Promise<void>;
24
+ /**
25
+ * Generate a unique, collision-free filename from agent name
26
+ * Uses SHA-256 hash prefix + sanitized name for readability
27
+ */
28
+ private getFilenameForAgent;
29
+ /**
30
+ * Get the file path for an agent's ledger
31
+ */
32
+ private getLedgerPath;
33
+ /**
34
+ * Load the agentId index from disk
35
+ */
36
+ private loadIndex;
37
+ /**
38
+ * Save the agentId index to disk (atomic write)
39
+ */
40
+ private saveIndex;
41
+ /**
42
+ * Acquire the global index lock
43
+ */
44
+ private acquireIndexLock;
45
+ /**
46
+ * Update the index with a new agentId -> agentName mapping (with locking)
47
+ */
48
+ private updateIndex;
49
+ /**
50
+ * Remove an agentId from the index (with locking)
51
+ */
52
+ private removeFromIndex;
53
+ /**
54
+ * Check and release expired locks
55
+ */
56
+ private cleanupExpiredLocks;
57
+ /**
58
+ * Acquire a lock for an agent's ledger with retry logic
59
+ * @param agentName - Agent name to lock
60
+ * @param maxRetries - Maximum number of retry attempts (default: 5)
61
+ * @param baseDelayMs - Base delay for exponential backoff (default: 100ms)
62
+ * @param timeoutMs - Maximum time to wait for lock (default: 10000ms)
63
+ */
64
+ private acquireLock;
65
+ /**
66
+ * Save a ledger for an agent (with locking)
67
+ */
68
+ save(agentName: string, ledger: Ledger): Promise<void>;
69
+ /**
70
+ * Load a ledger for an agent
71
+ */
72
+ load(agentName: string): Promise<Ledger | null>;
73
+ /**
74
+ * Delete a ledger for an agent
75
+ */
76
+ delete(agentName: string): Promise<boolean>;
77
+ /**
78
+ * Check if a ledger exists for an agent
79
+ */
80
+ exists(agentName: string): Promise<boolean>;
81
+ /**
82
+ * List all agents with ledgers
83
+ */
84
+ listAgents(): Promise<string[]>;
85
+ /**
86
+ * Update specific fields in a ledger (merge, with locking)
87
+ */
88
+ update(agentName: string, updates: Partial<Omit<Ledger, 'agentName' | 'updatedAt'>>): Promise<Ledger | null>;
89
+ /**
90
+ * Add an item to a list field (completed, inProgress, etc.)
91
+ */
92
+ addToList(agentName: string, field: 'completed' | 'inProgress' | 'blocked' | 'uncertainItems', item: string): Promise<boolean>;
93
+ /**
94
+ * Add a decision to the ledger
95
+ */
96
+ addDecision(agentName: string, decision: Omit<Ledger['keyDecisions'][0], 'timestamp'>): Promise<boolean>;
97
+ /**
98
+ * Create an empty ledger for an agent
99
+ */
100
+ create(agentName: string, cli: string, sessionId: string, agentId: string): Promise<Ledger>;
101
+ /**
102
+ * Find a ledger by agent ID (O(1) via index)
103
+ */
104
+ findByAgentId(agentId: string): Promise<Ledger | null>;
105
+ /**
106
+ * Rebuild the agentId index from all ledgers
107
+ */
108
+ rebuildIndex(): Promise<void>;
109
+ }
110
+ //# sourceMappingURL=ledger-store.d.ts.map