agent-relay 1.6.0 → 2.0.0

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