@ai-devkit/agent-manager 0.37.0 → 0.39.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 (357) hide show
  1. package/dist/AgentManager.d.ts +0 -4
  2. package/dist/AgentManager.d.ts.map +1 -1
  3. package/dist/AgentManager.js +2 -2
  4. package/dist/AgentManager.js.map +1 -1
  5. package/dist/__tests__/capacity/anthropic.test.js +115 -0
  6. package/dist/__tests__/capacity/anthropic.test.js.map +1 -0
  7. package/dist/__tests__/capacity/boundaries.test.js +45 -0
  8. package/dist/__tests__/capacity/boundaries.test.js.map +1 -0
  9. package/dist/__tests__/capacity/claude.test.js +3 -3
  10. package/dist/__tests__/capacity/claude.test.js.map +1 -1
  11. package/dist/__tests__/capacity/codex.test.js +3 -1
  12. package/dist/__tests__/capacity/codex.test.js.map +1 -1
  13. package/dist/__tests__/capacity/openai.test.js +21 -12
  14. package/dist/__tests__/capacity/openai.test.js.map +1 -1
  15. package/dist/__tests__/capacity/wham.test.js +1 -1
  16. package/dist/__tests__/capacity/wham.test.js.map +1 -1
  17. package/dist/__tests__/capacity/zai.test.js +7 -8
  18. package/dist/__tests__/capacity/zai.test.js.map +1 -1
  19. package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.js +2 -1
  20. package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.js.map +1 -1
  21. package/dist/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.js.map +1 -1
  22. package/dist/__tests__/harnesses/codex/durable/CodexCliProbe.test.js +7 -15
  23. package/dist/__tests__/harnesses/codex/durable/CodexCliProbe.test.js.map +1 -1
  24. package/dist/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.js +3 -1
  25. package/dist/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.js.map +1 -1
  26. package/dist/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.js +11 -26
  27. package/dist/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.js.map +1 -1
  28. package/dist/__tests__/harnesses/codex/durable/CodexPrintRunner.test.js +3 -7
  29. package/dist/__tests__/harnesses/codex/durable/CodexPrintRunner.test.js.map +1 -1
  30. package/dist/__tests__/harnesses/devin/DevinAdapter.test.js +597 -0
  31. package/dist/__tests__/harnesses/devin/DevinAdapter.test.js.map +1 -0
  32. package/dist/__tests__/harnesses/devin/DevinAgentMapper.test.js +91 -0
  33. package/dist/__tests__/harnesses/devin/DevinAgentMapper.test.js.map +1 -0
  34. package/dist/__tests__/harnesses/devin/DevinSessionLocator.test.js +192 -0
  35. package/dist/__tests__/harnesses/devin/DevinSessionLocator.test.js.map +1 -0
  36. package/dist/__tests__/harnesses/devin/DevinSessionParser.test.js +407 -0
  37. package/dist/__tests__/harnesses/devin/DevinSessionParser.test.js.map +1 -0
  38. package/dist/__tests__/harnesses/devin/fixtures.js +95 -0
  39. package/dist/__tests__/harnesses/devin/fixtures.js.map +1 -0
  40. package/dist/__tests__/harnesses/pi/durable/PiCliProbe.test.js +5 -11
  41. package/dist/__tests__/harnesses/pi/durable/PiCliProbe.test.js.map +1 -1
  42. package/dist/__tests__/harnesses/pi/durable/PiPrintAgentService.test.js +9 -19
  43. package/dist/__tests__/harnesses/pi/durable/PiPrintAgentService.test.js.map +1 -1
  44. package/dist/__tests__/harnesses/pi/durable/PiPrintRunner.test.js +3 -7
  45. package/dist/__tests__/harnesses/pi/durable/PiPrintRunner.test.js.map +1 -1
  46. package/dist/__tests__/{readiness → harnesses/readiness}/AgentReadiness.test.js +95 -11
  47. package/dist/__tests__/harnesses/readiness/AgentReadiness.test.js.map +1 -0
  48. package/dist/__tests__/harnesses/runtimeProfiles.test.js +89 -0
  49. package/dist/__tests__/harnesses/runtimeProfiles.test.js.map +1 -0
  50. package/dist/__tests__/print/DurableAgent.test.js +4 -6
  51. package/dist/__tests__/print/DurableAgent.test.js.map +1 -1
  52. package/dist/__tests__/print/DurableAgentRepository.test.js +1 -12
  53. package/dist/__tests__/print/DurableAgentRepository.test.js.map +1 -1
  54. package/dist/__tests__/runtime/ManagedAgentRuntime.test.js.map +1 -1
  55. package/dist/__tests__/terminal/GhosttyBackend.test.js +334 -0
  56. package/dist/__tests__/terminal/GhosttyBackend.test.js.map +1 -0
  57. package/dist/__tests__/terminal/TmuxManager.test.js +1 -1
  58. package/dist/__tests__/terminal/TmuxManager.test.js.map +1 -1
  59. package/dist/adapters/AgentAdapter.d.ts +1 -1
  60. package/dist/adapters/AgentAdapter.d.ts.map +1 -1
  61. package/dist/adapters/AgentAdapter.js +2 -1
  62. package/dist/adapters/AgentAdapter.js.map +1 -1
  63. package/dist/capacity/index.d.ts +9 -19
  64. package/dist/capacity/index.d.ts.map +1 -1
  65. package/dist/capacity/index.js +11 -4
  66. package/dist/capacity/index.js.map +1 -1
  67. package/dist/capacity/providers/anthropic.d.ts +9 -0
  68. package/dist/capacity/providers/anthropic.d.ts.map +1 -0
  69. package/dist/capacity/{claude.js → providers/anthropic.js} +10 -128
  70. package/dist/capacity/providers/anthropic.js.map +1 -0
  71. package/dist/capacity/providers/openai-platform.d.ts +14 -0
  72. package/dist/capacity/providers/openai-platform.d.ts.map +1 -0
  73. package/dist/capacity/providers/openai-platform.js +120 -0
  74. package/dist/capacity/providers/openai-platform.js.map +1 -0
  75. package/dist/capacity/providers/openai-subscription.d.ts +20 -0
  76. package/dist/capacity/providers/openai-subscription.d.ts.map +1 -0
  77. package/dist/capacity/providers/openai-subscription.js +129 -0
  78. package/dist/capacity/providers/openai-subscription.js.map +1 -0
  79. package/dist/capacity/providers/zai.d.ts +8 -0
  80. package/dist/capacity/providers/zai.d.ts.map +1 -0
  81. package/dist/capacity/{zai.js → providers/zai.js} +17 -62
  82. package/dist/capacity/providers/zai.js.map +1 -0
  83. package/dist/capacity/sources/claude.d.ts +9 -0
  84. package/dist/capacity/sources/claude.d.ts.map +1 -0
  85. package/dist/capacity/sources/claude.js +17 -0
  86. package/dist/capacity/sources/claude.js.map +1 -0
  87. package/dist/capacity/{codex.d.ts → sources/codex.d.ts} +5 -9
  88. package/dist/capacity/sources/codex.d.ts.map +1 -0
  89. package/dist/capacity/{codex.js → sources/codex.js} +31 -84
  90. package/dist/capacity/sources/codex.js.map +1 -0
  91. package/dist/capacity/sources/pi.d.ts +30 -0
  92. package/dist/capacity/sources/pi.d.ts.map +1 -0
  93. package/dist/capacity/sources/pi.js +81 -0
  94. package/dist/capacity/sources/pi.js.map +1 -0
  95. package/dist/capacity/types.d.ts +2 -0
  96. package/dist/capacity/types.d.ts.map +1 -1
  97. package/dist/capacity/types.js +1 -1
  98. package/dist/capacity/types.js.map +1 -1
  99. package/dist/harnesses/claude/credentials.d.ts +10 -0
  100. package/dist/harnesses/claude/credentials.d.ts.map +1 -0
  101. package/dist/harnesses/claude/credentials.js +112 -0
  102. package/dist/harnesses/claude/credentials.js.map +1 -0
  103. package/dist/harnesses/claude/readiness.d.ts +3 -0
  104. package/dist/harnesses/claude/readiness.d.ts.map +1 -0
  105. package/dist/harnesses/claude/readiness.js +63 -0
  106. package/dist/harnesses/claude/readiness.js.map +1 -0
  107. package/dist/harnesses/codex/credentials.d.ts +15 -0
  108. package/dist/harnesses/codex/credentials.d.ts.map +1 -0
  109. package/dist/harnesses/codex/credentials.js +58 -0
  110. package/dist/harnesses/codex/credentials.js.map +1 -0
  111. package/dist/harnesses/codex/readiness.d.ts +3 -0
  112. package/dist/harnesses/codex/readiness.d.ts.map +1 -0
  113. package/dist/harnesses/codex/readiness.js +60 -0
  114. package/dist/harnesses/codex/readiness.js.map +1 -0
  115. package/dist/harnesses/copilot/readiness.d.ts +3 -0
  116. package/dist/harnesses/copilot/readiness.d.ts.map +1 -0
  117. package/dist/harnesses/copilot/readiness.js +39 -0
  118. package/dist/harnesses/copilot/readiness.js.map +1 -0
  119. package/dist/harnesses/devin/DevinAdapter.d.ts +39 -0
  120. package/dist/harnesses/devin/DevinAdapter.d.ts.map +1 -0
  121. package/dist/harnesses/devin/DevinAdapter.js +177 -0
  122. package/dist/harnesses/devin/DevinAdapter.js.map +1 -0
  123. package/dist/harnesses/devin/DevinAgentMapper.d.ts +11 -0
  124. package/dist/harnesses/devin/DevinAgentMapper.d.ts.map +1 -0
  125. package/dist/harnesses/devin/DevinAgentMapper.js +35 -0
  126. package/dist/harnesses/devin/DevinAgentMapper.js.map +1 -0
  127. package/dist/harnesses/devin/DevinSessionLocator.d.ts +46 -0
  128. package/dist/harnesses/devin/DevinSessionLocator.d.ts.map +1 -0
  129. package/dist/harnesses/devin/DevinSessionLocator.js +176 -0
  130. package/dist/harnesses/devin/DevinSessionLocator.js.map +1 -0
  131. package/dist/harnesses/devin/DevinSessionParser.d.ts +29 -0
  132. package/dist/harnesses/devin/DevinSessionParser.d.ts.map +1 -0
  133. package/dist/harnesses/devin/DevinSessionParser.js +166 -0
  134. package/dist/harnesses/devin/DevinSessionParser.js.map +1 -0
  135. package/dist/harnesses/devin/readiness.d.ts +3 -0
  136. package/dist/harnesses/devin/readiness.d.ts.map +1 -0
  137. package/dist/harnesses/devin/readiness.js +39 -0
  138. package/dist/harnesses/devin/readiness.js.map +1 -0
  139. package/dist/harnesses/index.d.ts.map +1 -1
  140. package/dist/harnesses/index.js +3 -1
  141. package/dist/harnesses/index.js.map +1 -1
  142. package/dist/harnesses/opencode/readiness.d.ts +3 -0
  143. package/dist/harnesses/opencode/readiness.d.ts.map +1 -0
  144. package/dist/harnesses/opencode/readiness.js +50 -0
  145. package/dist/harnesses/opencode/readiness.js.map +1 -0
  146. package/dist/harnesses/pi/credentials.d.ts +22 -0
  147. package/dist/harnesses/pi/credentials.d.ts.map +1 -0
  148. package/dist/harnesses/pi/credentials.js +98 -0
  149. package/dist/harnesses/pi/credentials.js.map +1 -0
  150. package/dist/harnesses/pi/readiness.d.ts +3 -0
  151. package/dist/harnesses/pi/readiness.d.ts.map +1 -0
  152. package/dist/harnesses/pi/readiness.js +96 -0
  153. package/dist/harnesses/pi/readiness.js.map +1 -0
  154. package/dist/harnesses/readiness/AgentReadiness.d.ts +6 -0
  155. package/dist/harnesses/readiness/AgentReadiness.d.ts.map +1 -0
  156. package/dist/harnesses/readiness/AgentReadiness.js +70 -0
  157. package/dist/harnesses/readiness/AgentReadiness.js.map +1 -0
  158. package/dist/harnesses/readiness/checks.d.ts +31 -0
  159. package/dist/harnesses/readiness/checks.d.ts.map +1 -0
  160. package/dist/harnesses/readiness/checks.js +270 -0
  161. package/dist/harnesses/readiness/checks.js.map +1 -0
  162. package/dist/{readiness/AgentReadiness.d.ts → harnesses/readiness/types.d.ts} +19 -10
  163. package/dist/harnesses/readiness/types.d.ts.map +1 -0
  164. package/dist/harnesses/readiness/types.js +4 -0
  165. package/dist/harnesses/readiness/types.js.map +1 -0
  166. package/dist/harnesses/runtimeProfiles.d.ts +11 -0
  167. package/dist/harnesses/runtimeProfiles.d.ts.map +1 -0
  168. package/dist/harnesses/runtimeProfiles.js +100 -0
  169. package/dist/harnesses/runtimeProfiles.js.map +1 -0
  170. package/dist/index.d.ts +16 -42
  171. package/dist/index.d.ts.map +1 -1
  172. package/dist/index.js +9 -23
  173. package/dist/index.js.map +1 -1
  174. package/dist/runtime/ManagedAgentRuntime.d.ts +3 -3
  175. package/dist/runtime/ManagedAgentRuntime.d.ts.map +1 -1
  176. package/dist/runtime/ManagedAgentRuntime.js +6 -20
  177. package/dist/runtime/ManagedAgentRuntime.js.map +1 -1
  178. package/dist/runtime/herdr/HerdrAgentDiscovery.d.ts.map +1 -1
  179. package/dist/runtime/herdr/HerdrAgentDiscovery.js +2 -43
  180. package/dist/runtime/herdr/HerdrAgentDiscovery.js.map +1 -1
  181. package/dist/runtime/tmux/PidPolling.d.ts +1 -1
  182. package/dist/runtime/tmux/PidPolling.d.ts.map +1 -1
  183. package/dist/runtime/tmux/PidPolling.js.map +1 -1
  184. package/dist/runtime/tmux/TmuxAgentRuntime.d.ts +1 -1
  185. package/dist/runtime/tmux/TmuxAgentRuntime.d.ts.map +1 -1
  186. package/dist/runtime/tmux/TmuxAgentRuntime.js +1 -1
  187. package/dist/runtime/tmux/TmuxAgentRuntime.js.map +1 -1
  188. package/dist/runtime/tmux/TmuxManager.d.ts +12 -0
  189. package/dist/runtime/tmux/TmuxManager.d.ts.map +1 -0
  190. package/dist/{terminal → runtime/tmux}/TmuxManager.js +9 -28
  191. package/dist/runtime/tmux/TmuxManager.js.map +1 -0
  192. package/dist/runtime/types.d.ts +1 -1
  193. package/dist/runtime/types.d.ts.map +1 -1
  194. package/dist/runtime/types.js.map +1 -1
  195. package/dist/terminal/TerminalFocusManager.d.ts +4 -32
  196. package/dist/terminal/TerminalFocusManager.d.ts.map +1 -1
  197. package/dist/terminal/TerminalFocusManager.js +17 -267
  198. package/dist/terminal/TerminalFocusManager.js.map +1 -1
  199. package/dist/terminal/TtyWriter.d.ts +1 -44
  200. package/dist/terminal/TtyWriter.d.ts.map +1 -1
  201. package/dist/terminal/TtyWriter.js +12 -347
  202. package/dist/terminal/TtyWriter.js.map +1 -1
  203. package/dist/terminal/backends/ghostty.d.ts +3 -0
  204. package/dist/terminal/backends/ghostty.d.ts.map +1 -0
  205. package/dist/terminal/backends/ghostty.js +161 -0
  206. package/dist/terminal/backends/ghostty.js.map +1 -0
  207. package/dist/terminal/backends/index.d.ts +5 -0
  208. package/dist/terminal/backends/index.d.ts.map +1 -0
  209. package/dist/terminal/backends/index.js +21 -0
  210. package/dist/terminal/backends/index.js.map +1 -0
  211. package/dist/terminal/backends/iterm2.d.ts +3 -0
  212. package/dist/terminal/backends/iterm2.d.ts.map +1 -0
  213. package/dist/terminal/backends/iterm2.js +135 -0
  214. package/dist/terminal/backends/iterm2.js.map +1 -0
  215. package/dist/terminal/backends/shared.d.ts +9 -0
  216. package/dist/terminal/backends/shared.d.ts.map +1 -0
  217. package/dist/terminal/backends/shared.js +38 -0
  218. package/dist/terminal/backends/shared.js.map +1 -0
  219. package/dist/terminal/backends/terminal-app.d.ts +3 -0
  220. package/dist/terminal/backends/terminal-app.d.ts.map +1 -0
  221. package/dist/terminal/backends/terminal-app.js +129 -0
  222. package/dist/terminal/backends/terminal-app.js.map +1 -0
  223. package/dist/terminal/backends/tmux.d.ts +3 -0
  224. package/dist/terminal/backends/tmux.d.ts.map +1 -0
  225. package/dist/terminal/backends/tmux.js +76 -0
  226. package/dist/terminal/backends/tmux.js.map +1 -0
  227. package/dist/terminal/backends/wezterm.d.ts +3 -0
  228. package/dist/terminal/backends/wezterm.d.ts.map +1 -0
  229. package/dist/terminal/backends/wezterm.js +71 -0
  230. package/dist/terminal/backends/wezterm.js.map +1 -0
  231. package/dist/terminal/types.d.ts +22 -0
  232. package/dist/terminal/types.d.ts.map +1 -0
  233. package/dist/terminal/types.js +11 -0
  234. package/dist/terminal/types.js.map +1 -0
  235. package/dist/utils/process.d.ts +2 -0
  236. package/dist/utils/process.d.ts.map +1 -1
  237. package/dist/utils/process.js +3 -0
  238. package/dist/utils/process.js.map +1 -1
  239. package/package.json +1 -1
  240. package/src/AgentManager.ts +1 -1
  241. package/src/__tests__/capacity/anthropic.test.ts +105 -0
  242. package/src/__tests__/capacity/boundaries.test.ts +36 -0
  243. package/src/__tests__/capacity/claude.test.ts +3 -8
  244. package/src/__tests__/capacity/codex.test.ts +12 -35
  245. package/src/__tests__/capacity/fixtures/openai-codex-auth.json +1 -1
  246. package/src/__tests__/capacity/openai.test.ts +15 -15
  247. package/src/__tests__/capacity/wham.test.ts +1 -1
  248. package/src/__tests__/capacity/zai.test.ts +27 -62
  249. package/src/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.ts +2 -2
  250. package/src/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.ts +1 -1
  251. package/src/__tests__/harnesses/codex/durable/CodexCliProbe.test.ts +14 -19
  252. package/src/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.ts +3 -3
  253. package/src/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.ts +24 -30
  254. package/src/__tests__/harnesses/codex/durable/CodexPrintRunner.test.ts +4 -8
  255. package/src/__tests__/harnesses/devin/DevinAdapter.test.ts +292 -0
  256. package/src/__tests__/harnesses/devin/DevinAgentMapper.test.ts +88 -0
  257. package/src/__tests__/harnesses/devin/DevinSessionLocator.test.ts +139 -0
  258. package/src/__tests__/harnesses/devin/DevinSessionParser.test.ts +218 -0
  259. package/src/__tests__/harnesses/devin/fixtures.ts +144 -0
  260. package/src/__tests__/harnesses/pi/durable/PiCliProbe.test.ts +7 -11
  261. package/src/__tests__/harnesses/pi/durable/PiPrintAgentService.test.ts +19 -22
  262. package/src/__tests__/harnesses/pi/durable/PiPrintRunner.test.ts +7 -8
  263. package/src/__tests__/{readiness → harnesses/readiness}/AgentReadiness.test.ts +77 -9
  264. package/src/__tests__/harnesses/runtimeProfiles.test.ts +110 -0
  265. package/src/__tests__/print/DurableAgent.test.ts +4 -13
  266. package/src/__tests__/print/DurableAgentRepository.test.ts +1 -13
  267. package/src/__tests__/runtime/ManagedAgentRuntime.test.ts +1 -1
  268. package/src/__tests__/terminal/GhosttyBackend.test.ts +271 -0
  269. package/src/__tests__/terminal/TmuxManager.test.ts +1 -1
  270. package/src/adapters/AgentAdapter.ts +1 -0
  271. package/src/capacity/index.ts +29 -23
  272. package/src/capacity/{claude.ts → providers/anthropic.ts} +16 -131
  273. package/src/capacity/providers/openai-platform.ts +150 -0
  274. package/src/capacity/{wham.ts → providers/openai-subscription.ts} +86 -8
  275. package/src/capacity/{zai.ts → providers/zai.ts} +29 -111
  276. package/src/capacity/sources/claude.ts +30 -0
  277. package/src/capacity/{codex.ts → sources/codex.ts} +54 -124
  278. package/src/capacity/sources/pi.ts +131 -0
  279. package/src/capacity/types.ts +3 -0
  280. package/src/harnesses/claude/credentials.ts +122 -0
  281. package/src/harnesses/claude/readiness.ts +69 -0
  282. package/src/harnesses/codex/credentials.ts +81 -0
  283. package/src/harnesses/codex/readiness.ts +72 -0
  284. package/src/harnesses/copilot/readiness.ts +33 -0
  285. package/src/harnesses/devin/DevinAdapter.ts +224 -0
  286. package/src/harnesses/devin/DevinAgentMapper.ts +43 -0
  287. package/src/harnesses/devin/DevinSessionLocator.ts +230 -0
  288. package/src/harnesses/devin/DevinSessionParser.ts +236 -0
  289. package/src/harnesses/devin/readiness.ts +36 -0
  290. package/src/harnesses/index.ts +2 -0
  291. package/src/harnesses/opencode/readiness.ts +48 -0
  292. package/src/harnesses/pi/credentials.ts +129 -0
  293. package/src/harnesses/pi/readiness.ts +104 -0
  294. package/src/harnesses/readiness/AgentReadiness.ts +89 -0
  295. package/src/harnesses/readiness/checks.ts +336 -0
  296. package/src/harnesses/readiness/types.ts +90 -0
  297. package/src/{utils/agents.ts → harnesses/runtimeProfiles.ts} +35 -38
  298. package/src/index.ts +15 -128
  299. package/src/runtime/ManagedAgentRuntime.ts +7 -22
  300. package/src/runtime/herdr/HerdrAgentDiscovery.ts +3 -19
  301. package/src/runtime/tmux/PidPolling.ts +1 -1
  302. package/src/runtime/tmux/TmuxAgentRuntime.ts +1 -1
  303. package/src/{terminal → runtime/tmux}/TmuxManager.ts +9 -30
  304. package/src/runtime/types.ts +1 -1
  305. package/src/terminal/TerminalFocusManager.ts +19 -292
  306. package/src/terminal/TtyWriter.ts +15 -335
  307. package/src/terminal/backends/ghostty.ts +180 -0
  308. package/src/terminal/backends/index.ts +23 -0
  309. package/src/terminal/backends/iterm2.ts +126 -0
  310. package/src/terminal/backends/shared.ts +47 -0
  311. package/src/terminal/backends/terminal-app.ts +122 -0
  312. package/src/terminal/backends/tmux.ts +62 -0
  313. package/src/terminal/backends/wezterm.ts +65 -0
  314. package/src/terminal/types.ts +23 -0
  315. package/src/utils/process.ts +5 -0
  316. package/dist/__tests__/readiness/AgentReadiness.test.js.map +0 -1
  317. package/dist/__tests__/utils/agents.test.js +0 -93
  318. package/dist/__tests__/utils/agents.test.js.map +0 -1
  319. package/dist/capacity/claude.d.ts +0 -17
  320. package/dist/capacity/claude.d.ts.map +0 -1
  321. package/dist/capacity/claude.js.map +0 -1
  322. package/dist/capacity/codex.d.ts.map +0 -1
  323. package/dist/capacity/codex.js.map +0 -1
  324. package/dist/capacity/openai.d.ts +0 -47
  325. package/dist/capacity/openai.d.ts.map +0 -1
  326. package/dist/capacity/openai.js +0 -307
  327. package/dist/capacity/openai.js.map +0 -1
  328. package/dist/capacity/wham.d.ts +0 -16
  329. package/dist/capacity/wham.d.ts.map +0 -1
  330. package/dist/capacity/wham.js +0 -66
  331. package/dist/capacity/wham.js.map +0 -1
  332. package/dist/capacity/zai.d.ts +0 -14
  333. package/dist/capacity/zai.d.ts.map +0 -1
  334. package/dist/capacity/zai.js.map +0 -1
  335. package/dist/readiness/AgentReadiness.d.ts.map +0 -1
  336. package/dist/readiness/AgentReadiness.js +0 -614
  337. package/dist/readiness/AgentReadiness.js.map +0 -1
  338. package/dist/terminal/TmuxManager.d.ts +0 -28
  339. package/dist/terminal/TmuxManager.d.ts.map +0 -1
  340. package/dist/terminal/TmuxManager.js.map +0 -1
  341. package/dist/terminal/index.d.ts +0 -5
  342. package/dist/terminal/index.d.ts.map +0 -1
  343. package/dist/terminal/index.js +0 -5
  344. package/dist/terminal/index.js.map +0 -1
  345. package/dist/utils/agents.d.ts +0 -16
  346. package/dist/utils/agents.d.ts.map +0 -1
  347. package/dist/utils/agents.js +0 -117
  348. package/dist/utils/agents.js.map +0 -1
  349. package/dist/utils/index.d.ts +0 -8
  350. package/dist/utils/index.d.ts.map +0 -1
  351. package/dist/utils/index.js +0 -6
  352. package/dist/utils/index.js.map +0 -1
  353. package/src/__tests__/utils/agents.test.ts +0 -105
  354. package/src/capacity/openai.ts +0 -355
  355. package/src/readiness/AgentReadiness.ts +0 -730
  356. package/src/terminal/index.ts +0 -4
  357. package/src/utils/index.ts +0 -14
@@ -1,355 +1,20 @@
1
- import { execFile } from "child_process";
2
- import { promisify } from "util";
3
- import { TerminalType } from "./TerminalFocusManager.js";
4
- import { escapeAppleScript } from "../utils/applescript.js";
5
- const execFileAsync = promisify(execFile);
6
- /**
7
- * Carriage return byte (0x0d). Sent as a fixed discrete argv element with
8
- * `--no-paste` to deliver Enter literally (shell equivalent: $'\x0d').
9
- */ const CARRIAGE_RETURN = "\x0d";
10
- /**
11
- * Escape byte (0x1b). Recognized by `sendKey` and translated to the
12
- * backend-native representation (`Escape` for tmux, `key code 53` for
13
- * AppleScript, the literal byte for WezTerm).
14
- */ const ESCAPE_BYTE = "\x1b";
1
+ import { TERMINAL_BACKENDS, terminalBackendFor } from "./backends/index.js";
2
+ const SUPPORTED = `Supported: ${TERMINAL_BACKENDS.map((backend)=>backend.label).join(", ")}.`;
15
3
  export class TtyWriter {
16
- /**
17
- * Send a message as keyboard input to a terminal session.
18
- *
19
- * Dispatches to the correct mechanism based on terminal type:
20
- * - tmux: `tmux send-keys`
21
- * - iTerm2: Two separate AppleScript `write text` calls (text then newline)
22
- * - Terminal.app: Two separate AppleScript `do script` calls (text then newline)
23
- *
24
- * All AppleScript is executed via `execFile('osascript', ['-e', script])`
25
- * to avoid shell interpolation and command injection.
26
- *
27
- * @param location Terminal location from TerminalFocusManager.findTerminal()
28
- * @param message Text to send
29
- * @throws Error if terminal type is unsupported or send fails
30
- */ static async send(location, message) {
31
- switch(location.type){
32
- case TerminalType.TMUX:
33
- return TtyWriter.sendViaTmux(location.identifier, message);
34
- case TerminalType.WEZTERM:
35
- return TtyWriter.sendViaWezterm(location.identifier, message);
36
- case TerminalType.ITERM2:
37
- return TtyWriter.sendViaITerm2(location.tty, message);
38
- case TerminalType.TERMINAL_APP:
39
- return TtyWriter.sendViaTerminalApp(location.tty, message);
40
- default:
41
- throw new Error(`Cannot send input: unsupported terminal type "${location.type}". ` + "Supported: tmux, WezTerm, iTerm2, Terminal.app.");
4
+ static async send(location, message) {
5
+ const backend = terminalBackendFor(location.type);
6
+ if (!backend) {
7
+ throw new Error(`Cannot send input: unsupported terminal type "${location.type}". ${SUPPORTED}`);
42
8
  }
9
+ await backend.send(location, message);
43
10
  }
44
- /**
45
- * Send a single raw key (e.g. "1", "Enter", "Up") to the terminal as a
46
- * keystroke — bypassing bracketed paste and without auto-appending Enter.
47
- *
48
- * Use this when the target TUI distinguishes between typed text and raw
49
- * keypresses (e.g. an `AskUserQuestion` picker that selects on digit-key
50
- * press, not on a pasted digit followed by Enter).
51
- *
52
- * - tmux: `tmux send-keys -t <id> <key>` — direct keystroke, no paste buffer.
53
- * - WezTerm: `wezterm cli send-text --pane-id <id> --no-paste <key>`.
54
- * - iTerm2 / Terminal.app: AppleScript via System Events. Requires
55
- * Accessibility permissions.
56
- */ static async sendKey(location, key) {
57
- switch(location.type){
58
- case TerminalType.TMUX:
59
- return TtyWriter.sendKeyViaTmux(location.identifier, key);
60
- case TerminalType.WEZTERM:
61
- return TtyWriter.sendKeyViaWezterm(location.identifier, key);
62
- case TerminalType.ITERM2:
63
- return TtyWriter.sendKeyViaITerm2(location.tty, key);
64
- case TerminalType.TERMINAL_APP:
65
- return TtyWriter.sendKeyViaTerminalApp(location.tty, key);
66
- default:
67
- throw new Error(`Cannot send key: unsupported terminal type "${location.type}". ` + "Supported: tmux, WezTerm, iTerm2, Terminal.app.");
11
+ static async sendKey(location, key) {
12
+ const backend = terminalBackendFor(location.type);
13
+ if (!backend) {
14
+ throw new Error(`Cannot send key: unsupported terminal type "${location.type}". ${SUPPORTED}`);
68
15
  }
16
+ await backend.sendKey(location, key);
69
17
  }
70
- static async sendKeyViaTmux(identifier, key) {
71
- // tmux send-keys interprets named keys (Enter, Up, Escape, ...) and
72
- // passes literals through. No bracketed paste, no auto-Enter.
73
- const arg = key === ESCAPE_BYTE ? "Escape" : key;
74
- await execFileAsync("tmux", [
75
- "send-keys",
76
- "-t",
77
- identifier,
78
- arg
79
- ]);
80
- }
81
- static async sendKeyViaWezterm(paneId, key) {
82
- // --no-paste delivers the key bytes literally outside bracketed-paste
83
- // markers; the TUI sees a raw keystroke. For Esc (`\x1b`), wezterm
84
- // accepts the byte directly.
85
- await execFileAsync("wezterm", [
86
- "cli",
87
- "send-text",
88
- "--pane-id",
89
- paneId,
90
- "--no-paste",
91
- key
92
- ]);
93
- }
94
- static async sendKeyViaITerm2(tty, key) {
95
- // Focus the target session, then press the key via System Events so the
96
- // inner TUI sees a raw keystroke (not a bracketed-paste text run).
97
- const action = appleScriptKeyAction(key);
98
- const script = `
99
- tell application "iTerm"
100
- set targetSession to missing value
101
- repeat with w in windows
102
- repeat with t in tabs of w
103
- repeat with s in sessions of t
104
- if tty of s is "${tty}" then
105
- set targetSession to s
106
- set frontmost of w to true
107
- tell t to select
108
- tell s to select
109
- exit repeat
110
- end if
111
- end repeat
112
- if targetSession is not missing value then exit repeat
113
- end repeat
114
- if targetSession is not missing value then exit repeat
115
- end repeat
116
- if targetSession is missing value then return "not_found"
117
- activate
118
- end tell
119
- tell application "System Events" to ${action}
120
- return "ok"`;
121
- const { stdout } = await execFileAsync("osascript", [
122
- "-e",
123
- script
124
- ]);
125
- if (stdout.trim() !== "ok") {
126
- throw new Error(`iTerm2 session not found for TTY ${tty}`);
127
- }
128
- }
129
- static async sendKeyViaTerminalApp(tty, key) {
130
- const action = appleScriptKeyAction(key);
131
- const script = `
132
- tell application "Terminal"
133
- set targetTab to missing value
134
- set targetWindow to missing value
135
- repeat with w in windows
136
- repeat with i from 1 to count of tabs of w
137
- set t to tab i of w
138
- if tty of t is "${tty}" then
139
- set targetTab to t
140
- set targetWindow to w
141
- exit repeat
142
- end if
143
- end repeat
144
- if targetTab is not missing value then exit repeat
145
- end repeat
146
- if targetTab is missing value then return "not_found"
147
- set selected of targetTab to true
148
- set frontmost of targetWindow to true
149
- activate
150
- end tell
151
- tell application "System Events" to ${action}
152
- return "ok"`;
153
- const { stdout } = await execFileAsync("osascript", [
154
- "-e",
155
- script
156
- ]);
157
- if (stdout.trim() !== "ok") {
158
- throw new Error(`Terminal.app tab not found for TTY ${tty}`);
159
- }
160
- }
161
- static async sendViaWezterm(paneId, message) {
162
- // Two explicit CLI calls, mirroring the text-then-Enter convention used
163
- // by tmux / iTerm2 / Terminal.app so a bracketed-paste-aware TUI still
164
- // sees Enter as a submit.
165
- //
166
- // Step 1 (text): write the message to stdin so prompt contents are not
167
- // exposed through process arguments. execFile still spawns wezterm
168
- // directly (no shell), so shell metacharacters remain inert.
169
- // Step 2 (Enter): pass a fixed carriage return (0x0d) as a discrete
170
- // argv element (the JS char '\x0d') with --no-paste, so the CR is
171
- // delivered literally rather than wrapped in paste brackets. The
172
- // equivalent shell command is:
173
- // wezterm cli send-text --pane-id <id> --no-paste $'\x0d'
174
- // (ANSI-C quoting, note the leading $).
175
- await TtyWriter.execFileWithInput("wezterm", [
176
- "cli",
177
- "send-text",
178
- "--pane-id",
179
- paneId
180
- ], message);
181
- await new Promise((resolve)=>setTimeout(resolve, 150));
182
- await execFileAsync("wezterm", [
183
- "cli",
184
- "send-text",
185
- "--pane-id",
186
- paneId,
187
- "--no-paste",
188
- CARRIAGE_RETURN
189
- ]);
190
- }
191
- static async sendViaTmux(identifier, message) {
192
- // Paste the message body using tmux bracketed paste, then send Enter as
193
- // a separate key so the inner TUI treats it as submission rather than
194
- // pasted content.
195
- const bufferName = `ai-devkit-send-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}`;
196
- await TtyWriter.execFileWithInput("tmux", [
197
- "load-buffer",
198
- "-b",
199
- bufferName,
200
- "-"
201
- ], message);
202
- await execFileAsync("tmux", [
203
- "paste-buffer",
204
- "-t",
205
- identifier,
206
- "-b",
207
- bufferName,
208
- "-p",
209
- "-d"
210
- ]);
211
- await new Promise((resolve)=>setTimeout(resolve, 150));
212
- await execFileAsync("tmux", [
213
- "send-keys",
214
- "-t",
215
- identifier,
216
- "Enter"
217
- ]);
218
- }
219
- static async execFileWithInput(command, args, input) {
220
- await new Promise((resolve, reject)=>{
221
- const child = execFile(command, args, (error)=>{
222
- if (error) {
223
- reject(error);
224
- return;
225
- }
226
- resolve();
227
- });
228
- if (!child.stdin) {
229
- reject(new Error(`Cannot write stdin to ${command}`));
230
- return;
231
- }
232
- child.stdin.end(input);
233
- });
234
- }
235
- /**
236
- * Build an AppleScript that finds an iTerm2 session by TTY and runs a
237
- * command against it. The `sessionCommand` is inserted inside a
238
- * `tell targetSession` block.
239
- */ static iterm2SessionScript(tty, sessionCommand) {
240
- return `
241
- tell application "iTerm"
242
- set targetSession to missing value
243
- repeat with w in windows
244
- repeat with t in tabs of w
245
- repeat with s in sessions of t
246
- if tty of s is "${tty}" then
247
- set targetSession to s
248
- exit repeat
249
- end if
250
- end repeat
251
- if targetSession is not missing value then exit repeat
252
- end repeat
253
- if targetSession is not missing value then exit repeat
254
- end repeat
255
- if targetSession is missing value then return "not_found"
256
- tell targetSession to ${sessionCommand}
257
- end tell
258
- return "ok"`;
259
- }
260
- static async sendViaITerm2(tty, message) {
261
- const escaped = escapeAppleScript(message);
262
- // Send text and Enter as two separate write text calls so the newline
263
- // is delivered outside the bracketed paste sequence of the message body.
264
- // iTerm2 appends the newline after the paste-end marker (\e[201~), so
265
- // the inner TUI (Claude Code, Codex) sees it as a real submit action.
266
- const textScript = TtyWriter.iterm2SessionScript(tty, `write text "${escaped}" newline no`);
267
- const { stdout: textResult } = await execFileAsync("osascript", [
268
- "-e",
269
- textScript
270
- ]);
271
- if (textResult.trim() !== "ok") {
272
- throw new Error(`iTerm2 session not found for TTY ${tty}`);
273
- }
274
- // Wait for the paste to complete before sending Enter separately
275
- await new Promise((resolve)=>setTimeout(resolve, 150));
276
- const enterScript = TtyWriter.iterm2SessionScript(tty, 'write text "" newline yes');
277
- const { stdout: enterResult } = await execFileAsync("osascript", [
278
- "-e",
279
- enterScript
280
- ]);
281
- if (enterResult.trim() !== "ok") {
282
- throw new Error(`iTerm2 session disappeared before Enter could be sent for TTY ${tty}`);
283
- }
284
- }
285
- static async sendViaTerminalApp(tty, message) {
286
- const escaped = escapeAppleScript(message);
287
- // Use Terminal.app's `do script` to send text to the correct tab by TTY.
288
- // We avoid System Events `keystroke` + `key code 36` because it requires
289
- // accessibility permissions and unreliably delivers the Return key.
290
- //
291
- // `do script` with `in` targets a specific tab without opening a new one.
292
- // We send text and Enter as two separate calls so the newline arrives
293
- // outside of bracketed paste mode — same pattern as iTerm2 and tmux.
294
- const textScript = `
295
- tell application "Terminal"
296
- set targetTab to missing value
297
- repeat with w in windows
298
- repeat with i from 1 to count of tabs of w
299
- set t to tab i of w
300
- if tty of t is "${tty}" then
301
- set targetTab to t
302
- exit repeat
303
- end if
304
- end repeat
305
- if targetTab is not missing value then exit repeat
306
- end repeat
307
- if targetTab is missing value then return "not_found"
308
- do script "${escaped}" in targetTab
309
- end tell
310
- return "ok"`;
311
- const { stdout: textResult } = await execFileAsync("osascript", [
312
- "-e",
313
- textScript
314
- ]);
315
- if (textResult.trim() !== "ok") {
316
- throw new Error(`Terminal.app tab not found for TTY ${tty}`);
317
- }
318
- // Wait for the text to be delivered before sending Enter
319
- await new Promise((resolve)=>setTimeout(resolve, 150));
320
- const enterScript = `
321
- tell application "Terminal"
322
- set targetTab to missing value
323
- repeat with w in windows
324
- repeat with i from 1 to count of tabs of w
325
- set t to tab i of w
326
- if tty of t is "${tty}" then
327
- set targetTab to t
328
- exit repeat
329
- end if
330
- end repeat
331
- if targetTab is not missing value then exit repeat
332
- end repeat
333
- if targetTab is missing value then return "not_found"
334
- do script "" in targetTab
335
- end tell
336
- return "ok"`;
337
- const { stdout: enterResult } = await execFileAsync("osascript", [
338
- "-e",
339
- enterScript
340
- ]);
341
- if (enterResult.trim() !== "ok") {
342
- throw new Error(`Terminal.app tab disappeared before Enter could be sent for TTY ${tty}`);
343
- }
344
- }
345
- }
346
- /**
347
- * AppleScript `keystroke` only delivers typeable characters; non-typeable
348
- * keys (Esc, arrows, F-keys, …) must be sent via `key code <N>`. Add more
349
- * mappings here as new special keys are needed.
350
- */ function appleScriptKeyAction(key) {
351
- if (key === ESCAPE_BYTE) return "key code 53";
352
- return `keystroke "${escapeAppleScript(key)}"`;
353
18
  }
354
19
 
355
20
  //# sourceMappingURL=TtyWriter.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/terminal/TtyWriter.ts"],"sourcesContent":["import { execFile } from \"child_process\";\nimport { promisify } from \"util\";\nimport type { TerminalLocation } from \"./TerminalFocusManager.js\";\nimport { TerminalType } from \"./TerminalFocusManager.js\";\nimport { escapeAppleScript } from \"../utils/applescript.js\";\n\nconst execFileAsync = promisify(execFile);\n\n/**\n * Carriage return byte (0x0d). Sent as a fixed discrete argv element with\n * `--no-paste` to deliver Enter literally (shell equivalent: $'\\x0d').\n */\nconst CARRIAGE_RETURN = \"\\x0d\";\n\n/**\n * Escape byte (0x1b). Recognized by `sendKey` and translated to the\n * backend-native representation (`Escape` for tmux, `key code 53` for\n * AppleScript, the literal byte for WezTerm).\n */\nconst ESCAPE_BYTE = \"\\x1b\";\n\nexport class TtyWriter {\n /**\n * Send a message as keyboard input to a terminal session.\n *\n * Dispatches to the correct mechanism based on terminal type:\n * - tmux: `tmux send-keys`\n * - iTerm2: Two separate AppleScript `write text` calls (text then newline)\n * - Terminal.app: Two separate AppleScript `do script` calls (text then newline)\n *\n * All AppleScript is executed via `execFile('osascript', ['-e', script])`\n * to avoid shell interpolation and command injection.\n *\n * @param location Terminal location from TerminalFocusManager.findTerminal()\n * @param message Text to send\n * @throws Error if terminal type is unsupported or send fails\n */\n static async send(location: TerminalLocation, message: string): Promise<void> {\n switch (location.type) {\n case TerminalType.TMUX:\n return TtyWriter.sendViaTmux(location.identifier, message);\n case TerminalType.WEZTERM:\n return TtyWriter.sendViaWezterm(location.identifier, message);\n case TerminalType.ITERM2:\n return TtyWriter.sendViaITerm2(location.tty, message);\n case TerminalType.TERMINAL_APP:\n return TtyWriter.sendViaTerminalApp(location.tty, message);\n default:\n throw new Error(\n `Cannot send input: unsupported terminal type \"${location.type}\". ` +\n \"Supported: tmux, WezTerm, iTerm2, Terminal.app.\",\n );\n }\n }\n\n /**\n * Send a single raw key (e.g. \"1\", \"Enter\", \"Up\") to the terminal as a\n * keystroke — bypassing bracketed paste and without auto-appending Enter.\n *\n * Use this when the target TUI distinguishes between typed text and raw\n * keypresses (e.g. an `AskUserQuestion` picker that selects on digit-key\n * press, not on a pasted digit followed by Enter).\n *\n * - tmux: `tmux send-keys -t <id> <key>` — direct keystroke, no paste buffer.\n * - WezTerm: `wezterm cli send-text --pane-id <id> --no-paste <key>`.\n * - iTerm2 / Terminal.app: AppleScript via System Events. Requires\n * Accessibility permissions.\n */\n static async sendKey(location: TerminalLocation, key: string): Promise<void> {\n switch (location.type) {\n case TerminalType.TMUX:\n return TtyWriter.sendKeyViaTmux(location.identifier, key);\n case TerminalType.WEZTERM:\n return TtyWriter.sendKeyViaWezterm(location.identifier, key);\n case TerminalType.ITERM2:\n return TtyWriter.sendKeyViaITerm2(location.tty, key);\n case TerminalType.TERMINAL_APP:\n return TtyWriter.sendKeyViaTerminalApp(location.tty, key);\n default:\n throw new Error(\n `Cannot send key: unsupported terminal type \"${location.type}\". ` +\n \"Supported: tmux, WezTerm, iTerm2, Terminal.app.\",\n );\n }\n }\n\n private static async sendKeyViaTmux(identifier: string, key: string): Promise<void> {\n // tmux send-keys interprets named keys (Enter, Up, Escape, ...) and\n // passes literals through. No bracketed paste, no auto-Enter.\n const arg = key === ESCAPE_BYTE ? \"Escape\" : key;\n await execFileAsync(\"tmux\", [\"send-keys\", \"-t\", identifier, arg]);\n }\n\n private static async sendKeyViaWezterm(paneId: string, key: string): Promise<void> {\n // --no-paste delivers the key bytes literally outside bracketed-paste\n // markers; the TUI sees a raw keystroke. For Esc (`\\x1b`), wezterm\n // accepts the byte directly.\n await execFileAsync(\"wezterm\", [\"cli\", \"send-text\", \"--pane-id\", paneId, \"--no-paste\", key]);\n }\n\n private static async sendKeyViaITerm2(tty: string, key: string): Promise<void> {\n // Focus the target session, then press the key via System Events so the\n // inner TUI sees a raw keystroke (not a bracketed-paste text run).\n const action = appleScriptKeyAction(key);\n const script = `\ntell application \"iTerm\"\n set targetSession to missing value\n repeat with w in windows\n repeat with t in tabs of w\n repeat with s in sessions of t\n if tty of s is \"${tty}\" then\n set targetSession to s\n set frontmost of w to true\n tell t to select\n tell s to select\n exit repeat\n end if\n end repeat\n if targetSession is not missing value then exit repeat\n end repeat\n if targetSession is not missing value then exit repeat\n end repeat\n if targetSession is missing value then return \"not_found\"\n activate\nend tell\ntell application \"System Events\" to ${action}\nreturn \"ok\"`;\n\n const { stdout } = await execFileAsync(\"osascript\", [\"-e\", script]);\n if (stdout.trim() !== \"ok\") {\n throw new Error(`iTerm2 session not found for TTY ${tty}`);\n }\n }\n\n private static async sendKeyViaTerminalApp(tty: string, key: string): Promise<void> {\n const action = appleScriptKeyAction(key);\n const script = `\ntell application \"Terminal\"\n set targetTab to missing value\n set targetWindow to missing value\n repeat with w in windows\n repeat with i from 1 to count of tabs of w\n set t to tab i of w\n if tty of t is \"${tty}\" then\n set targetTab to t\n set targetWindow to w\n exit repeat\n end if\n end repeat\n if targetTab is not missing value then exit repeat\n end repeat\n if targetTab is missing value then return \"not_found\"\n set selected of targetTab to true\n set frontmost of targetWindow to true\n activate\nend tell\ntell application \"System Events\" to ${action}\nreturn \"ok\"`;\n\n const { stdout } = await execFileAsync(\"osascript\", [\"-e\", script]);\n if (stdout.trim() !== \"ok\") {\n throw new Error(`Terminal.app tab not found for TTY ${tty}`);\n }\n }\n\n private static async sendViaWezterm(paneId: string, message: string): Promise<void> {\n // Two explicit CLI calls, mirroring the text-then-Enter convention used\n // by tmux / iTerm2 / Terminal.app so a bracketed-paste-aware TUI still\n // sees Enter as a submit.\n //\n // Step 1 (text): write the message to stdin so prompt contents are not\n // exposed through process arguments. execFile still spawns wezterm\n // directly (no shell), so shell metacharacters remain inert.\n // Step 2 (Enter): pass a fixed carriage return (0x0d) as a discrete\n // argv element (the JS char '\\x0d') with --no-paste, so the CR is\n // delivered literally rather than wrapped in paste brackets. The\n // equivalent shell command is:\n // wezterm cli send-text --pane-id <id> --no-paste $'\\x0d'\n // (ANSI-C quoting, note the leading $).\n await TtyWriter.execFileWithInput(\n \"wezterm\",\n [\"cli\", \"send-text\", \"--pane-id\", paneId],\n message,\n );\n await new Promise((resolve) => setTimeout(resolve, 150));\n await execFileAsync(\"wezterm\", [\n \"cli\",\n \"send-text\",\n \"--pane-id\",\n paneId,\n \"--no-paste\",\n CARRIAGE_RETURN,\n ]);\n }\n\n private static async sendViaTmux(identifier: string, message: string): Promise<void> {\n // Paste the message body using tmux bracketed paste, then send Enter as\n // a separate key so the inner TUI treats it as submission rather than\n // pasted content.\n const bufferName = `ai-devkit-send-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}`;\n await TtyWriter.execFileWithInput(\"tmux\", [\"load-buffer\", \"-b\", bufferName, \"-\"], message);\n await execFileAsync(\"tmux\", [\"paste-buffer\", \"-t\", identifier, \"-b\", bufferName, \"-p\", \"-d\"]);\n await new Promise((resolve) => setTimeout(resolve, 150));\n await execFileAsync(\"tmux\", [\"send-keys\", \"-t\", identifier, \"Enter\"]);\n }\n\n private static async execFileWithInput(\n command: string,\n args: string[],\n input: string,\n ): Promise<void> {\n await new Promise<void>((resolve, reject) => {\n const child = execFile(command, args, (error) => {\n if (error) {\n reject(error);\n return;\n }\n resolve();\n });\n if (!child.stdin) {\n reject(new Error(`Cannot write stdin to ${command}`));\n return;\n }\n child.stdin.end(input);\n });\n }\n\n /**\n * Build an AppleScript that finds an iTerm2 session by TTY and runs a\n * command against it. The `sessionCommand` is inserted inside a\n * `tell targetSession` block.\n */\n private static iterm2SessionScript(tty: string, sessionCommand: string): string {\n return `\ntell application \"iTerm\"\n set targetSession to missing value\n repeat with w in windows\n repeat with t in tabs of w\n repeat with s in sessions of t\n if tty of s is \"${tty}\" then\n set targetSession to s\n exit repeat\n end if\n end repeat\n if targetSession is not missing value then exit repeat\n end repeat\n if targetSession is not missing value then exit repeat\n end repeat\n if targetSession is missing value then return \"not_found\"\n tell targetSession to ${sessionCommand}\nend tell\nreturn \"ok\"`;\n }\n\n private static async sendViaITerm2(tty: string, message: string): Promise<void> {\n const escaped = escapeAppleScript(message);\n // Send text and Enter as two separate write text calls so the newline\n // is delivered outside the bracketed paste sequence of the message body.\n // iTerm2 appends the newline after the paste-end marker (\\e[201~), so\n // the inner TUI (Claude Code, Codex) sees it as a real submit action.\n const textScript = TtyWriter.iterm2SessionScript(tty, `write text \"${escaped}\" newline no`);\n\n const { stdout: textResult } = await execFileAsync(\"osascript\", [\"-e\", textScript]);\n if (textResult.trim() !== \"ok\") {\n throw new Error(`iTerm2 session not found for TTY ${tty}`);\n }\n\n // Wait for the paste to complete before sending Enter separately\n await new Promise((resolve) => setTimeout(resolve, 150));\n\n const enterScript = TtyWriter.iterm2SessionScript(tty, 'write text \"\" newline yes');\n const { stdout: enterResult } = await execFileAsync(\"osascript\", [\"-e\", enterScript]);\n if (enterResult.trim() !== \"ok\") {\n throw new Error(`iTerm2 session disappeared before Enter could be sent for TTY ${tty}`);\n }\n }\n\n private static async sendViaTerminalApp(tty: string, message: string): Promise<void> {\n const escaped = escapeAppleScript(message);\n // Use Terminal.app's `do script` to send text to the correct tab by TTY.\n // We avoid System Events `keystroke` + `key code 36` because it requires\n // accessibility permissions and unreliably delivers the Return key.\n //\n // `do script` with `in` targets a specific tab without opening a new one.\n // We send text and Enter as two separate calls so the newline arrives\n // outside of bracketed paste mode — same pattern as iTerm2 and tmux.\n const textScript = `\ntell application \"Terminal\"\n set targetTab to missing value\n repeat with w in windows\n repeat with i from 1 to count of tabs of w\n set t to tab i of w\n if tty of t is \"${tty}\" then\n set targetTab to t\n exit repeat\n end if\n end repeat\n if targetTab is not missing value then exit repeat\n end repeat\n if targetTab is missing value then return \"not_found\"\n do script \"${escaped}\" in targetTab\nend tell\nreturn \"ok\"`;\n\n const { stdout: textResult } = await execFileAsync(\"osascript\", [\"-e\", textScript]);\n if (textResult.trim() !== \"ok\") {\n throw new Error(`Terminal.app tab not found for TTY ${tty}`);\n }\n\n // Wait for the text to be delivered before sending Enter\n await new Promise((resolve) => setTimeout(resolve, 150));\n\n const enterScript = `\ntell application \"Terminal\"\n set targetTab to missing value\n repeat with w in windows\n repeat with i from 1 to count of tabs of w\n set t to tab i of w\n if tty of t is \"${tty}\" then\n set targetTab to t\n exit repeat\n end if\n end repeat\n if targetTab is not missing value then exit repeat\n end repeat\n if targetTab is missing value then return \"not_found\"\n do script \"\" in targetTab\nend tell\nreturn \"ok\"`;\n\n const { stdout: enterResult } = await execFileAsync(\"osascript\", [\"-e\", enterScript]);\n if (enterResult.trim() !== \"ok\") {\n throw new Error(`Terminal.app tab disappeared before Enter could be sent for TTY ${tty}`);\n }\n }\n}\n\n/**\n * AppleScript `keystroke` only delivers typeable characters; non-typeable\n * keys (Esc, arrows, F-keys, …) must be sent via `key code <N>`. Add more\n * mappings here as new special keys are needed.\n */\nfunction appleScriptKeyAction(key: string): string {\n if (key === ESCAPE_BYTE) return \"key code 53\";\n return `keystroke \"${escapeAppleScript(key)}\"`;\n}\n"],"names":["execFile","promisify","TerminalType","escapeAppleScript","execFileAsync","CARRIAGE_RETURN","ESCAPE_BYTE","TtyWriter","send","location","message","type","TMUX","sendViaTmux","identifier","WEZTERM","sendViaWezterm","ITERM2","sendViaITerm2","tty","TERMINAL_APP","sendViaTerminalApp","Error","sendKey","key","sendKeyViaTmux","sendKeyViaWezterm","sendKeyViaITerm2","sendKeyViaTerminalApp","arg","paneId","action","appleScriptKeyAction","script","stdout","trim","execFileWithInput","Promise","resolve","setTimeout","bufferName","process","pid","Date","now","Math","random","toString","slice","command","args","input","reject","child","error","stdin","end","iterm2SessionScript","sessionCommand","escaped","textScript","textResult","enterScript","enterResult"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,SAAS,QAAQ,OAAO;AAEjC,SAASC,YAAY,QAAQ,4BAA4B;AACzD,SAASC,iBAAiB,QAAQ,0BAA0B;AAE5D,MAAMC,gBAAgBH,UAAUD;AAEhC;;;CAGC,GACD,MAAMK,kBAAkB;AAExB;;;;CAIC,GACD,MAAMC,cAAc;AAEpB,OAAO,MAAMC;IACX;;;;;;;;;;;;;;GAcC,GACD,aAAaC,KAAKC,QAA0B,EAAEC,OAAe,EAAiB;QAC5E,OAAQD,SAASE,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WAUjB,CAAC;QAER,MAAM,EAAEe,QAAQ6B,WAAW,EAAE,GAAG,MAAM3D,cAAc,aAAa;YAAC;YAAM0D;SAAY;QACpF,IAAIC,YAAY5B,IAAI,OAAO,MAAM;YAC/B,MAAM,IAAIb,MAAM,CAAC,gEAAgE,EAAEH,KAAK;QAC1F;IACF;AACF;AAEA;;;;CAIC,GACD,SAASa,qBAAqBR,GAAW;IACvC,IAAIA,QAAQlB,aAAa,OAAO;IAChC,OAAO,CAAC,WAAW,EAAEH,kBAAkBqB,KAAK,CAAC,CAAC;AAChD"}
1
+ {"version":3,"sources":["../../src/terminal/TtyWriter.ts"],"sourcesContent":["import { TERMINAL_BACKENDS, terminalBackendFor } from \"./backends/index.js\";\nimport type { TerminalLocation } from \"./types.js\";\n\nconst SUPPORTED = `Supported: ${TERMINAL_BACKENDS.map((backend) => backend.label).join(\", \")}.`;\n\nexport class TtyWriter {\n static async send(location: TerminalLocation, message: string): Promise<void> {\n const backend = terminalBackendFor(location.type);\n if (!backend) {\n throw new Error(\n `Cannot send input: unsupported terminal type \"${location.type}\". ${SUPPORTED}`,\n );\n }\n await backend.send(location, message);\n }\n\n static async sendKey(location: TerminalLocation, key: string): Promise<void> {\n const backend = terminalBackendFor(location.type);\n if (!backend) {\n throw new Error(\n `Cannot send key: unsupported terminal type \"${location.type}\". ${SUPPORTED}`,\n );\n }\n await backend.sendKey(location, key);\n }\n}\n"],"names":["TERMINAL_BACKENDS","terminalBackendFor","SUPPORTED","map","backend","label","join","TtyWriter","send","location","message","type","Error","sendKey","key"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,kBAAkB,QAAQ,sBAAsB;AAG5E,MAAMC,YAAY,CAAC,WAAW,EAAEF,kBAAkBG,GAAG,CAAC,CAACC,UAAYA,QAAQC,KAAK,EAAEC,IAAI,CAAC,MAAM,CAAC,CAAC;AAE/F,OAAO,MAAMC;IACX,aAAaC,KAAKC,QAA0B,EAAEC,OAAe,EAAiB;QAC5E,MAAMN,UAAUH,mBAAmBQ,SAASE,IAAI;QAChD,IAAI,CAACP,SAAS;YACZ,MAAM,IAAIQ,MACR,CAAC,8CAA8C,EAAEH,SAASE,IAAI,CAAC,GAAG,EAAET,WAAW;QAEnF;QACA,MAAME,QAAQI,IAAI,CAACC,UAAUC;IAC/B;IAEA,aAAaG,QAAQJ,QAA0B,EAAEK,GAAW,EAAiB;QAC3E,MAAMV,UAAUH,mBAAmBQ,SAASE,IAAI;QAChD,IAAI,CAACP,SAAS;YACZ,MAAM,IAAIQ,MACR,CAAC,4CAA4C,EAAEH,SAASE,IAAI,CAAC,GAAG,EAAET,WAAW;QAEjF;QACA,MAAME,QAAQS,OAAO,CAACJ,UAAUK;IAClC;AACF"}
@@ -0,0 +1,3 @@
1
+ import { type TerminalBackend } from "../types.js";
2
+ export declare const ghosttyBackend: TerminalBackend;
3
+ //# sourceMappingURL=ghostty.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ghostty.d.ts","sourceRoot":"","sources":["../../../src/terminal/backends/ghostty.ts"],"names":[],"mappings":"AAKA,OAAO,EAAgB,KAAK,eAAe,EAAyB,MAAM,aAAa,CAAC;AA2IxF,eAAO,MAAM,cAAc,EAAE,eAmC5B,CAAC"}
@@ -0,0 +1,161 @@
1
+ import { execFile } from "child_process";
2
+ import { writeFile } from "fs/promises";
3
+ import { promisify } from "util";
4
+ import { escapeAppleScript } from "../../utils/applescript.js";
5
+ import { getProcessCwdsAsync } from "../../utils/process.js";
6
+ import { TerminalType } from "../types.js";
7
+ import { CARRIAGE_RETURN, isProcessName, sleep } from "./shared.js";
8
+ const execFileAsync = promisify(execFile);
9
+ /** Separates fields in AppleScript output; never part of an id, title or path. */ const FIELD_SEPARATOR = "\x1f";
10
+ const MARKER_POLL_ATTEMPTS = 10;
11
+ const MARKER_POLL_INTERVAL_MS = 50;
12
+ async function listProcesses() {
13
+ const { stdout } = await execFileAsync("ps", [
14
+ "-Axo",
15
+ "pid=,ppid=,tty=,comm="
16
+ ]);
17
+ const rows = [];
18
+ for (const line of stdout.split("\n")){
19
+ const match = line.trim().match(/^(\d+)\s+(\d+)\s+(\S+)\s+(.+)$/);
20
+ if (match) {
21
+ rows.push({
22
+ pid: Number(match[1]),
23
+ ppid: Number(match[2]),
24
+ tty: match[3],
25
+ comm: match[4]
26
+ });
27
+ }
28
+ }
29
+ return rows;
30
+ }
31
+ async function listTerminals() {
32
+ const script = `
33
+ tell application "Ghostty"
34
+ set out to ""
35
+ repeat with t in terminals
36
+ set out to out & (id of t) & (character id 31) & (name of t) & (character id 31) & (working directory of t) & linefeed
37
+ end repeat
38
+ return out
39
+ end tell`;
40
+ const { stdout } = await execFileAsync("osascript", [
41
+ "-e",
42
+ script
43
+ ]);
44
+ return stdout.split("\n").map((line)=>line.split(FIELD_SEPARATOR)).filter((fields)=>fields.length === 3 && fields[0]).map(([id, name, workingDirectory])=>({
45
+ id,
46
+ name,
47
+ workingDirectory
48
+ }));
49
+ }
50
+ /** Run an AppleScript `command` with `t` bound to the located terminal; false if it is gone. */ async function onTerminal(location, command) {
51
+ const script = `
52
+ tell application "Ghostty"
53
+ set matches to (every terminal whose id is "${escapeAppleScript(location.identifier)}")
54
+ if (count of matches) is 0 then return "not_found"
55
+ set t to item 1 of matches
56
+ ${command}
57
+ end tell
58
+ return "ok"`;
59
+ const { stdout } = await execFileAsync("osascript", [
60
+ "-e",
61
+ script
62
+ ]);
63
+ return stdout.trim() === "ok";
64
+ }
65
+ /** Set the window title of whatever terminal owns `tty` (OSC 2). */ async function writeTitle(tty, title) {
66
+ // eslint-disable-next-line no-control-regex
67
+ const safe = title.replace(/[\x00-\x1f\x7f]/g, "");
68
+ await writeFile(tty, `\x1b]2;${safe}\x07`, {
69
+ flag: "a"
70
+ });
71
+ }
72
+ /**
73
+ * Ghostty's AppleScript terminals expose an id, title and working directory,
74
+ * but not their TTY. Find the one owning `tty` without guessing:
75
+ * 1. only TTYs whose session was started by a ghostty process qualify;
76
+ * 2. if exactly one terminal's working directory matches a process on this
77
+ * TTY, and no other Ghostty TTY has a process there, that is it;
78
+ * 3. otherwise briefly set a unique title on the TTY, find the terminal now
79
+ * showing it, and restore its previous title.
80
+ */ async function findTerminalId(tty) {
81
+ const processes = await listProcesses();
82
+ const ghosttyPids = new Set(processes.filter((p)=>isProcessName(p.comm, "ghostty")).map((p)=>p.pid));
83
+ if (ghosttyPids.size === 0) return null;
84
+ const ttyName = tty.replace(/^\/dev\//, "");
85
+ const ghosttyTtys = new Set(processes.filter((p)=>ghosttyPids.has(p.ppid) && p.tty !== "??").map((p)=>p.tty));
86
+ if (!ghosttyTtys.has(ttyName)) return null;
87
+ const terminals = await listTerminals();
88
+ const sessionProcesses = processes.filter((p)=>ghosttyTtys.has(p.tty));
89
+ const cwdByPid = await getProcessCwdsAsync(sessionProcesses.map((p)=>p.pid));
90
+ const ownDirs = new Set();
91
+ const otherDirs = new Set();
92
+ for (const p of sessionProcesses){
93
+ const cwd = cwdByPid.get(p.pid);
94
+ if (cwd) (p.tty === ttyName ? ownDirs : otherDirs).add(cwd);
95
+ }
96
+ // Trust the directory only when exactly one terminal is in a folder no other Ghostty TTY uses.
97
+ const byDirectory = terminals.filter((t)=>ownDirs.has(t.workingDirectory));
98
+ if (byDirectory.length === 1 && !otherDirs.has(byDirectory[0].workingDirectory)) {
99
+ return byDirectory[0].id;
100
+ }
101
+ const marker = `ai-devkit-${process.pid}-${Date.now()}`;
102
+ await writeTitle(tty, marker);
103
+ for(let attempt = 0; attempt < MARKER_POLL_ATTEMPTS; attempt++){
104
+ const marked = (await listTerminals()).find((t)=>t.name === marker);
105
+ if (marked) {
106
+ const previous = terminals.find((t)=>t.id === marked.id)?.name ?? "";
107
+ await writeTitle(tty, previous);
108
+ return marked.id;
109
+ }
110
+ await sleep(MARKER_POLL_INTERVAL_MS);
111
+ }
112
+ return null;
113
+ }
114
+ /**
115
+ * A Ghostty `text:` action that writes `bytes` to the terminal as typed.
116
+ * Unlike `send key`, it does not go through the keyboard layout or input
117
+ * method, which can turn a digit key into another character.
118
+ */ function textAction(bytes) {
119
+ const escaped = Array.from(bytes, (char)=>{
120
+ if (char === "\\") return "\\\\";
121
+ const code = char.charCodeAt(0);
122
+ return code >= 0x20 && code < 0x7f ? char : `\\x${code.toString(16).padStart(2, "0")}`;
123
+ }).join("");
124
+ return `perform action "${escapeAppleScript(`text:${escaped}`)}" on t`;
125
+ }
126
+ export const ghosttyBackend = {
127
+ type: TerminalType.GHOSTTY,
128
+ label: "Ghostty",
129
+ async find (tty) {
130
+ try {
131
+ const id = await findTerminalId(tty);
132
+ return id ? {
133
+ type: TerminalType.GHOSTTY,
134
+ identifier: id,
135
+ tty
136
+ } : null;
137
+ } catch {
138
+ // Ghostty not installed, not scriptable, or the TTY is not writable
139
+ return null;
140
+ }
141
+ },
142
+ async focus (location) {
143
+ return onTerminal(location, "focus t\n activate");
144
+ },
145
+ async send (location, message) {
146
+ if (!await onTerminal(location, `input text "${escapeAppleScript(message)}" to t`)) {
147
+ throw new Error(`Ghostty terminal not found for TTY ${location.tty}`);
148
+ }
149
+ await sleep(150);
150
+ if (!await onTerminal(location, textAction(CARRIAGE_RETURN))) {
151
+ throw new Error(`Ghostty terminal disappeared before Enter could be sent for TTY ${location.tty}`);
152
+ }
153
+ },
154
+ async sendKey (location, key) {
155
+ if (!await onTerminal(location, textAction(key))) {
156
+ throw new Error(`Ghostty terminal not found for TTY ${location.tty}`);
157
+ }
158
+ }
159
+ };
160
+
161
+ //# sourceMappingURL=ghostty.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/terminal/backends/ghostty.ts"],"sourcesContent":["import { execFile } from \"child_process\";\nimport { writeFile } from \"fs/promises\";\nimport { promisify } from \"util\";\nimport { escapeAppleScript } from \"../../utils/applescript.js\";\nimport { getProcessCwdsAsync } from \"../../utils/process.js\";\nimport { TerminalType, type TerminalBackend, type TerminalLocation } from \"../types.js\";\nimport { CARRIAGE_RETURN, isProcessName, sleep } from \"./shared.js\";\n\nconst execFileAsync = promisify(execFile);\n\n/** Separates fields in AppleScript output; never part of an id, title or path. */\nconst FIELD_SEPARATOR = \"\\x1f\";\nconst MARKER_POLL_ATTEMPTS = 10;\nconst MARKER_POLL_INTERVAL_MS = 50;\n\ninterface GhosttyTerminal {\n id: string;\n name: string;\n workingDirectory: string;\n}\n\ninterface ProcessRow {\n pid: number;\n ppid: number;\n tty: string;\n comm: string;\n}\n\nasync function listProcesses(): Promise<ProcessRow[]> {\n const { stdout } = await execFileAsync(\"ps\", [\"-Axo\", \"pid=,ppid=,tty=,comm=\"]);\n const rows: ProcessRow[] = [];\n for (const line of stdout.split(\"\\n\")) {\n const match = line.trim().match(/^(\\d+)\\s+(\\d+)\\s+(\\S+)\\s+(.+)$/);\n if (match) {\n rows.push({ pid: Number(match[1]), ppid: Number(match[2]), tty: match[3], comm: match[4] });\n }\n }\n return rows;\n}\n\nasync function listTerminals(): Promise<GhosttyTerminal[]> {\n const script = `\ntell application \"Ghostty\"\n set out to \"\"\n repeat with t in terminals\n set out to out & (id of t) & (character id 31) & (name of t) & (character id 31) & (working directory of t) & linefeed\n end repeat\n return out\nend tell`;\n const { stdout } = await execFileAsync(\"osascript\", [\"-e\", script]);\n return stdout\n .split(\"\\n\")\n .map((line) => line.split(FIELD_SEPARATOR))\n .filter((fields) => fields.length === 3 && fields[0])\n .map(([id, name, workingDirectory]) => ({ id, name, workingDirectory }));\n}\n\n/** Run an AppleScript `command` with `t` bound to the located terminal; false if it is gone. */\nasync function onTerminal(location: TerminalLocation, command: string): Promise<boolean> {\n const script = `\ntell application \"Ghostty\"\n set matches to (every terminal whose id is \"${escapeAppleScript(location.identifier)}\")\n if (count of matches) is 0 then return \"not_found\"\n set t to item 1 of matches\n ${command}\nend tell\nreturn \"ok\"`;\n const { stdout } = await execFileAsync(\"osascript\", [\"-e\", script]);\n return stdout.trim() === \"ok\";\n}\n\n/** Set the window title of whatever terminal owns `tty` (OSC 2). */\nasync function writeTitle(tty: string, title: string): Promise<void> {\n // eslint-disable-next-line no-control-regex\n const safe = title.replace(/[\\x00-\\x1f\\x7f]/g, \"\");\n await writeFile(tty, `\\x1b]2;${safe}\\x07`, { flag: \"a\" });\n}\n\n/**\n * Ghostty's AppleScript terminals expose an id, title and working directory,\n * but not their TTY. Find the one owning `tty` without guessing:\n * 1. only TTYs whose session was started by a ghostty process qualify;\n * 2. if exactly one terminal's working directory matches a process on this\n * TTY, and no other Ghostty TTY has a process there, that is it;\n * 3. otherwise briefly set a unique title on the TTY, find the terminal now\n * showing it, and restore its previous title.\n */\nasync function findTerminalId(tty: string): Promise<string | null> {\n const processes = await listProcesses();\n const ghosttyPids = new Set(\n processes.filter((p) => isProcessName(p.comm, \"ghostty\")).map((p) => p.pid),\n );\n if (ghosttyPids.size === 0) return null;\n\n const ttyName = tty.replace(/^\\/dev\\//, \"\");\n const ghosttyTtys = new Set(\n processes.filter((p) => ghosttyPids.has(p.ppid) && p.tty !== \"??\").map((p) => p.tty),\n );\n if (!ghosttyTtys.has(ttyName)) return null;\n\n const terminals = await listTerminals();\n const sessionProcesses = processes.filter((p) => ghosttyTtys.has(p.tty));\n const cwdByPid = await getProcessCwdsAsync(sessionProcesses.map((p) => p.pid));\n const ownDirs = new Set<string>();\n const otherDirs = new Set<string>();\n for (const p of sessionProcesses) {\n const cwd = cwdByPid.get(p.pid);\n if (cwd) (p.tty === ttyName ? ownDirs : otherDirs).add(cwd);\n }\n\n // Trust the directory only when exactly one terminal is in a folder no other Ghostty TTY uses.\n const byDirectory = terminals.filter((t) => ownDirs.has(t.workingDirectory));\n if (byDirectory.length === 1 && !otherDirs.has(byDirectory[0].workingDirectory)) {\n return byDirectory[0].id;\n }\n\n const marker = `ai-devkit-${process.pid}-${Date.now()}`;\n await writeTitle(tty, marker);\n for (let attempt = 0; attempt < MARKER_POLL_ATTEMPTS; attempt++) {\n const marked = (await listTerminals()).find((t) => t.name === marker);\n if (marked) {\n const previous = terminals.find((t) => t.id === marked.id)?.name ?? \"\";\n await writeTitle(tty, previous);\n return marked.id;\n }\n await sleep(MARKER_POLL_INTERVAL_MS);\n }\n return null;\n}\n\n/**\n * A Ghostty `text:` action that writes `bytes` to the terminal as typed.\n * Unlike `send key`, it does not go through the keyboard layout or input\n * method, which can turn a digit key into another character.\n */\nfunction textAction(bytes: string): string {\n const escaped = Array.from(bytes, (char) => {\n if (char === \"\\\\\") return \"\\\\\\\\\";\n const code = char.charCodeAt(0);\n return code >= 0x20 && code < 0x7f ? char : `\\\\x${code.toString(16).padStart(2, \"0\")}`;\n }).join(\"\");\n return `perform action \"${escapeAppleScript(`text:${escaped}`)}\" on t`;\n}\n\nexport const ghosttyBackend: TerminalBackend = {\n type: TerminalType.GHOSTTY,\n label: \"Ghostty\",\n\n async find(tty) {\n try {\n const id = await findTerminalId(tty);\n return id ? { type: TerminalType.GHOSTTY, identifier: id, tty } : null;\n } catch {\n // Ghostty not installed, not scriptable, or the TTY is not writable\n return null;\n }\n },\n\n async focus(location) {\n return onTerminal(location, \"focus t\\n activate\");\n },\n\n async send(location, message) {\n if (!(await onTerminal(location, `input text \"${escapeAppleScript(message)}\" to t`))) {\n throw new Error(`Ghostty terminal not found for TTY ${location.tty}`);\n }\n await sleep(150);\n if (!(await onTerminal(location, textAction(CARRIAGE_RETURN)))) {\n throw new Error(\n `Ghostty terminal disappeared before Enter could be sent for TTY ${location.tty}`,\n );\n }\n },\n\n async sendKey(location, key) {\n if (!(await onTerminal(location, textAction(key)))) {\n throw new Error(`Ghostty terminal not found for TTY ${location.tty}`);\n }\n },\n};\n"],"names":["execFile","writeFile","promisify","escapeAppleScript","getProcessCwdsAsync","TerminalType","CARRIAGE_RETURN","isProcessName","sleep","execFileAsync","FIELD_SEPARATOR","MARKER_POLL_ATTEMPTS","MARKER_POLL_INTERVAL_MS","listProcesses","stdout","rows","line","split","match","trim","push","pid","Number","ppid","tty","comm","listTerminals","script","map","filter","fields","length","id","name","workingDirectory","onTerminal","location","command","identifier","writeTitle","title","safe","replace","flag","findTerminalId","processes","ghosttyPids","Set","p","size","ttyName","ghosttyTtys","has","terminals","sessionProcesses","cwdByPid","ownDirs","otherDirs","cwd","get","add","byDirectory","t","marker","process","Date","now","attempt","marked","find","previous","textAction","bytes","escaped","Array","from","char","code","charCodeAt","toString","padStart","join","ghosttyBackend","type","GHOSTTY","label","focus","send","message","Error","sendKey","key"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,SAAS,QAAQ,cAAc;AACxC,SAASC,SAAS,QAAQ,OAAO;AACjC,SAASC,iBAAiB,QAAQ,6BAA6B;AAC/D,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,YAAY,QAAqD,cAAc;AACxF,SAASC,eAAe,EAAEC,aAAa,EAAEC,KAAK,QAAQ,cAAc;AAEpE,MAAMC,gBAAgBP,UAAUF;AAEhC,gFAAgF,GAChF,MAAMU,kBAAkB;AACxB,MAAMC,uBAAuB;AAC7B,MAAMC,0BAA0B;AAehC,eAAeC;IACb,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAML,cAAc,MAAM;QAAC;QAAQ;KAAwB;IAC9E,MAAMM,OAAqB,EAAE;IAC7B,KAAK,MAAMC,QAAQF,OAAOG,KAAK,CAAC,MAAO;QACrC,MAAMC,QAAQF,KAAKG,IAAI,GAAGD,KAAK,CAAC;QAChC,IAAIA,OAAO;YACTH,KAAKK,IAAI,CAAC;gBAAEC,KAAKC,OAAOJ,KAAK,CAAC,EAAE;gBAAGK,MAAMD,OAAOJ,KAAK,CAAC,EAAE;gBAAGM,KAAKN,KAAK,CAAC,EAAE;gBAAEO,MAAMP,KAAK,CAAC,EAAE;YAAC;QAC3F;IACF;IACA,OAAOH;AACT;AAEA,eAAeW;IACb,MAAMC,SAAS,CAAC;;;;;;;QAOV,CAAC;IACP,MAAM,EAAEb,MAAM,EAAE,GAAG,MAAML,cAAc,aAAa;QAAC;QAAMkB;KAAO;IAClE,OAAOb,OACJG,KAAK,CAAC,MACNW,GAAG,CAAC,CAACZ,OAASA,KAAKC,K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WC,UAAUmC,WAAWoB,OAAQ;YAClD,MAAM,IAAIF,MAAM,CAAC,mCAAmC,EAAErD,SAASZ,GAAG,EAAE;QACtE;IACF;AACF,EAAE"}
@@ -0,0 +1,5 @@
1
+ import type { TerminalBackend } from "../types.js";
2
+ import { TerminalType } from "../types.js";
3
+ export declare const TERMINAL_BACKENDS: readonly TerminalBackend[];
4
+ export declare function terminalBackendFor(type: TerminalType): TerminalBackend | undefined;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/terminal/backends/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAO3C,eAAO,MAAM,iBAAiB,EAAE,SAAS,eAAe,EAMvD,CAAC;AAMF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,GAAG,eAAe,GAAG,SAAS,CAElF"}
@@ -0,0 +1,21 @@
1
+ import { ghosttyBackend } from "./ghostty.js";
2
+ import { iterm2Backend } from "./iterm2.js";
3
+ import { terminalAppBackend } from "./terminal-app.js";
4
+ import { tmuxBackend } from "./tmux.js";
5
+ import { weztermBackend } from "./wezterm.js";
6
+ export const TERMINAL_BACKENDS = [
7
+ tmuxBackend,
8
+ weztermBackend,
9
+ ghosttyBackend,
10
+ iterm2Backend,
11
+ terminalAppBackend
12
+ ];
13
+ const BACKENDS_BY_TYPE = new Map(TERMINAL_BACKENDS.map((backend)=>[
14
+ backend.type,
15
+ backend
16
+ ]));
17
+ export function terminalBackendFor(type) {
18
+ return BACKENDS_BY_TYPE.get(type);
19
+ }
20
+
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/terminal/backends/index.ts"],"sourcesContent":["import type { TerminalBackend } from \"../types.js\";\nimport { TerminalType } from \"../types.js\";\nimport { ghosttyBackend } from \"./ghostty.js\";\nimport { iterm2Backend } from \"./iterm2.js\";\nimport { terminalAppBackend } from \"./terminal-app.js\";\nimport { tmuxBackend } from \"./tmux.js\";\nimport { weztermBackend } from \"./wezterm.js\";\n\nexport const TERMINAL_BACKENDS: readonly TerminalBackend[] = [\n tmuxBackend,\n weztermBackend,\n ghosttyBackend,\n iterm2Backend,\n terminalAppBackend,\n];\n\nconst BACKENDS_BY_TYPE = new Map<TerminalType, TerminalBackend>(\n TERMINAL_BACKENDS.map((backend) => [backend.type, backend]),\n);\n\nexport function terminalBackendFor(type: TerminalType): TerminalBackend | undefined {\n return BACKENDS_BY_TYPE.get(type);\n}\n"],"names":["ghosttyBackend","iterm2Backend","terminalAppBackend","tmuxBackend","weztermBackend","TERMINAL_BACKENDS","BACKENDS_BY_TYPE","Map","map","backend","type","terminalBackendFor","get"],"mappings":"AAEA,SAASA,cAAc,QAAQ,eAAe;AAC9C,SAASC,aAAa,QAAQ,cAAc;AAC5C,SAASC,kBAAkB,QAAQ,oBAAoB;AACvD,SAASC,WAAW,QAAQ,YAAY;AACxC,SAASC,cAAc,QAAQ,eAAe;AAE9C,OAAO,MAAMC,oBAAgD;IAC3DF;IACAC;IACAJ;IACAC;IACAC;CACD,CAAC;AAEF,MAAMI,mBAAmB,IAAIC,IAC3BF,kBAAkBG,GAAG,CAAC,CAACC,UAAY;QAACA,QAAQC,IAAI;QAAED;KAAQ;AAG5D,OAAO,SAASE,mBAAmBD,IAAkB;IACnD,OAAOJ,iBAAiBM,GAAG,CAACF;AAC9B"}