@ai-devkit/agent-manager 0.43.0 → 0.44.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 (444) hide show
  1. package/package.json +8 -3
  2. package/.swcrc +0 -27
  3. package/dist/__tests__/AgentManager.test.js +0 -1727
  4. package/dist/__tests__/AgentManager.test.js.map +0 -1
  5. package/dist/__tests__/adapters/IncrementalSessionRefresh.test.js +0 -486
  6. package/dist/__tests__/adapters/IncrementalSessionRefresh.test.js.map +0 -1
  7. package/dist/__tests__/adapters/adapterProcessImports.test.js +0 -52
  8. package/dist/__tests__/adapters/adapterProcessImports.test.js.map +0 -1
  9. package/dist/__tests__/adapters/adapterSnapshotCandidates.test.js +0 -247
  10. package/dist/__tests__/adapters/adapterSnapshotCandidates.test.js.map +0 -1
  11. package/dist/__tests__/capacity/anthropic.test.js +0 -115
  12. package/dist/__tests__/capacity/anthropic.test.js.map +0 -1
  13. package/dist/__tests__/capacity/boundaries.test.js +0 -45
  14. package/dist/__tests__/capacity/boundaries.test.js.map +0 -1
  15. package/dist/__tests__/capacity/claude.test.js +0 -485
  16. package/dist/__tests__/capacity/claude.test.js.map +0 -1
  17. package/dist/__tests__/capacity/codex.test.js +0 -339
  18. package/dist/__tests__/capacity/codex.test.js.map +0 -1
  19. package/dist/__tests__/capacity/devin.test.js +0 -239
  20. package/dist/__tests__/capacity/devin.test.js.map +0 -1
  21. package/dist/__tests__/capacity/index.test.js +0 -53
  22. package/dist/__tests__/capacity/index.test.js.map +0 -1
  23. package/dist/__tests__/capacity/openai.test.js +0 -687
  24. package/dist/__tests__/capacity/openai.test.js.map +0 -1
  25. package/dist/__tests__/capacity/wham.test.js +0 -159
  26. package/dist/__tests__/capacity/wham.test.js.map +0 -1
  27. package/dist/__tests__/capacity/zai.test.js +0 -212
  28. package/dist/__tests__/capacity/zai.test.js.map +0 -1
  29. package/dist/__tests__/fixtures.test.js +0 -218
  30. package/dist/__tests__/fixtures.test.js.map +0 -1
  31. package/dist/__tests__/harnesses/BoundedSummarySkip.test.js +0 -568
  32. package/dist/__tests__/harnesses/BoundedSummarySkip.test.js.map +0 -1
  33. package/dist/__tests__/harnesses/SessionSummaryEquivalence.test.js +0 -1089
  34. package/dist/__tests__/harnesses/SessionSummaryEquivalence.test.js.map +0 -1
  35. package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.js +0 -143
  36. package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.js.map +0 -1
  37. package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.js +0 -462
  38. package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.js.map +0 -1
  39. package/dist/__tests__/harnesses/builtinAdapters.test.js +0 -33
  40. package/dist/__tests__/harnesses/builtinAdapters.test.js.map +0 -1
  41. package/dist/__tests__/harnesses/claude/ClaudeAgentMapper.test.js +0 -79
  42. package/dist/__tests__/harnesses/claude/ClaudeAgentMapper.test.js.map +0 -1
  43. package/dist/__tests__/harnesses/claude/ClaudeCodeAdapter.test.js +0 -1881
  44. package/dist/__tests__/harnesses/claude/ClaudeCodeAdapter.test.js.map +0 -1
  45. package/dist/__tests__/harnesses/claude/ClaudeSessionLocator.test.js +0 -425
  46. package/dist/__tests__/harnesses/claude/ClaudeSessionLocator.test.js.map +0 -1
  47. package/dist/__tests__/harnesses/claude/ClaudeSessionParser.test.js +0 -314
  48. package/dist/__tests__/harnesses/claude/ClaudeSessionParser.test.js.map +0 -1
  49. package/dist/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.js +0 -49
  50. package/dist/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.js.map +0 -1
  51. package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.js +0 -76
  52. package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.js.map +0 -1
  53. package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.js +0 -173
  54. package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.js.map +0 -1
  55. package/dist/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.js +0 -181
  56. package/dist/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.js.map +0 -1
  57. package/dist/__tests__/harnesses/codex/CodexAdapter.test.js +0 -685
  58. package/dist/__tests__/harnesses/codex/CodexAdapter.test.js.map +0 -1
  59. package/dist/__tests__/harnesses/codex/CodexSessionLocator.test.js +0 -463
  60. package/dist/__tests__/harnesses/codex/CodexSessionLocator.test.js.map +0 -1
  61. package/dist/__tests__/harnesses/codex/CodexSessionMapping.test.js +0 -86
  62. package/dist/__tests__/harnesses/codex/CodexSessionMapping.test.js.map +0 -1
  63. package/dist/__tests__/harnesses/codex/CodexSessionParser.test.js +0 -254
  64. package/dist/__tests__/harnesses/codex/CodexSessionParser.test.js.map +0 -1
  65. package/dist/__tests__/harnesses/codex/durable/CodexCliProbe.test.js +0 -121
  66. package/dist/__tests__/harnesses/codex/durable/CodexCliProbe.test.js.map +0 -1
  67. package/dist/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.js +0 -84
  68. package/dist/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.js.map +0 -1
  69. package/dist/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.js +0 -128
  70. package/dist/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.js.map +0 -1
  71. package/dist/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.js +0 -246
  72. package/dist/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.js.map +0 -1
  73. package/dist/__tests__/harnesses/codex/durable/CodexPrintRunner.test.js +0 -384
  74. package/dist/__tests__/harnesses/codex/durable/CodexPrintRunner.test.js.map +0 -1
  75. package/dist/__tests__/harnesses/copilot/CopilotAdapter.test.js +0 -659
  76. package/dist/__tests__/harnesses/copilot/CopilotAdapter.test.js.map +0 -1
  77. package/dist/__tests__/harnesses/copilot/CopilotRefreshIO.test.js +0 -290
  78. package/dist/__tests__/harnesses/copilot/CopilotRefreshIO.test.js.map +0 -1
  79. package/dist/__tests__/harnesses/devin/DevinAdapter.test.js +0 -597
  80. package/dist/__tests__/harnesses/devin/DevinAdapter.test.js.map +0 -1
  81. package/dist/__tests__/harnesses/devin/DevinAgentMapper.test.js +0 -99
  82. package/dist/__tests__/harnesses/devin/DevinAgentMapper.test.js.map +0 -1
  83. package/dist/__tests__/harnesses/devin/DevinSessionLocator.test.js +0 -192
  84. package/dist/__tests__/harnesses/devin/DevinSessionLocator.test.js.map +0 -1
  85. package/dist/__tests__/harnesses/devin/DevinSessionParser.test.js +0 -407
  86. package/dist/__tests__/harnesses/devin/DevinSessionParser.test.js.map +0 -1
  87. package/dist/__tests__/harnesses/devin/fixtures.js +0 -95
  88. package/dist/__tests__/harnesses/devin/fixtures.js.map +0 -1
  89. package/dist/__tests__/harnesses/gemini/GeminiCliAdapter.test.js +0 -1454
  90. package/dist/__tests__/harnesses/gemini/GeminiCliAdapter.test.js.map +0 -1
  91. package/dist/__tests__/harnesses/gemini/GeminiSessionJsonl.test.js +0 -491
  92. package/dist/__tests__/harnesses/gemini/GeminiSessionJsonl.test.js.map +0 -1
  93. package/dist/__tests__/harnesses/gemini/GeminiSessionLocator.test.js +0 -399
  94. package/dist/__tests__/harnesses/gemini/GeminiSessionLocator.test.js.map +0 -1
  95. package/dist/__tests__/harnesses/grok/GrokAgentMapper.test.js +0 -56
  96. package/dist/__tests__/harnesses/grok/GrokAgentMapper.test.js.map +0 -1
  97. package/dist/__tests__/harnesses/grok/GrokCliAdapter.test.js +0 -421
  98. package/dist/__tests__/harnesses/grok/GrokCliAdapter.test.js.map +0 -1
  99. package/dist/__tests__/harnesses/grok/GrokIncrementalRefresh.test.js +0 -167
  100. package/dist/__tests__/harnesses/grok/GrokIncrementalRefresh.test.js.map +0 -1
  101. package/dist/__tests__/harnesses/grok/GrokSessionLocator.test.js +0 -133
  102. package/dist/__tests__/harnesses/grok/GrokSessionLocator.test.js.map +0 -1
  103. package/dist/__tests__/harnesses/grok/GrokSessionParser.test.js +0 -301
  104. package/dist/__tests__/harnesses/grok/GrokSessionParser.test.js.map +0 -1
  105. package/dist/__tests__/harnesses/kiro/KiroAdapter.test.js +0 -662
  106. package/dist/__tests__/harnesses/kiro/KiroAdapter.test.js.map +0 -1
  107. package/dist/__tests__/harnesses/muse/MuseAdapter.test.js +0 -247
  108. package/dist/__tests__/harnesses/muse/MuseAdapter.test.js.map +0 -1
  109. package/dist/__tests__/harnesses/muse/MuseAgentMapper.test.js +0 -81
  110. package/dist/__tests__/harnesses/muse/MuseAgentMapper.test.js.map +0 -1
  111. package/dist/__tests__/harnesses/muse/MuseSessionLocator.test.js +0 -185
  112. package/dist/__tests__/harnesses/muse/MuseSessionLocator.test.js.map +0 -1
  113. package/dist/__tests__/harnesses/muse/MuseSessionParser.test.js +0 -328
  114. package/dist/__tests__/harnesses/muse/MuseSessionParser.test.js.map +0 -1
  115. package/dist/__tests__/harnesses/opencode/OpenCodeAdapter.test.js +0 -213
  116. package/dist/__tests__/harnesses/opencode/OpenCodeAdapter.test.js.map +0 -1
  117. package/dist/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.js +0 -108
  118. package/dist/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.js.map +0 -1
  119. package/dist/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.js +0 -94
  120. package/dist/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.js.map +0 -1
  121. package/dist/__tests__/harnesses/opencode/OpenCodeSessionParser.test.js +0 -147
  122. package/dist/__tests__/harnesses/opencode/OpenCodeSessionParser.test.js.map +0 -1
  123. package/dist/__tests__/harnesses/pi/PiAdapter.test.js +0 -367
  124. package/dist/__tests__/harnesses/pi/PiAdapter.test.js.map +0 -1
  125. package/dist/__tests__/harnesses/pi/PiDiscoveryIO.test.js +0 -382
  126. package/dist/__tests__/harnesses/pi/PiDiscoveryIO.test.js.map +0 -1
  127. package/dist/__tests__/harnesses/pi/PiSessionParser.test.js +0 -416
  128. package/dist/__tests__/harnesses/pi/PiSessionParser.test.js.map +0 -1
  129. package/dist/__tests__/harnesses/pi/PiSessionTracker.test.js +0 -108
  130. package/dist/__tests__/harnesses/pi/PiSessionTracker.test.js.map +0 -1
  131. package/dist/__tests__/harnesses/pi/durable/PiCliProbe.test.js +0 -70
  132. package/dist/__tests__/harnesses/pi/durable/PiCliProbe.test.js.map +0 -1
  133. package/dist/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.js +0 -43
  134. package/dist/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.js.map +0 -1
  135. package/dist/__tests__/harnesses/pi/durable/PiPrintAgentService.test.js +0 -192
  136. package/dist/__tests__/harnesses/pi/durable/PiPrintAgentService.test.js.map +0 -1
  137. package/dist/__tests__/harnesses/pi/durable/PiPrintProtocol.test.js +0 -119
  138. package/dist/__tests__/harnesses/pi/durable/PiPrintProtocol.test.js.map +0 -1
  139. package/dist/__tests__/harnesses/pi/durable/PiPrintRunner.test.js +0 -382
  140. package/dist/__tests__/harnesses/pi/durable/PiPrintRunner.test.js.map +0 -1
  141. package/dist/__tests__/harnesses/pi/durable/PiStreamParser.test.js +0 -34
  142. package/dist/__tests__/harnesses/pi/durable/PiStreamParser.test.js.map +0 -1
  143. package/dist/__tests__/harnesses/readiness/AgentReadiness.test.js +0 -446
  144. package/dist/__tests__/harnesses/readiness/AgentReadiness.test.js.map +0 -1
  145. package/dist/__tests__/harnesses/runtimeProfiles.test.js +0 -101
  146. package/dist/__tests__/harnesses/runtimeProfiles.test.js.map +0 -1
  147. package/dist/__tests__/print/DurableAgent.test.js +0 -15
  148. package/dist/__tests__/print/DurableAgent.test.js.map +0 -1
  149. package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js +0 -186
  150. package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js.map +0 -1
  151. package/dist/__tests__/print/DurableAgentRepository.test.js +0 -249
  152. package/dist/__tests__/print/DurableAgentRepository.test.js.map +0 -1
  153. package/dist/__tests__/readiness-fixtures.test.js +0 -54
  154. package/dist/__tests__/readiness-fixtures.test.js.map +0 -1
  155. package/dist/__tests__/runtime/AgentRuntime.test.js +0 -13
  156. package/dist/__tests__/runtime/AgentRuntime.test.js.map +0 -1
  157. package/dist/__tests__/runtime/HerdrAgentDiscovery.test.js +0 -164
  158. package/dist/__tests__/runtime/HerdrAgentDiscovery.test.js.map +0 -1
  159. package/dist/__tests__/runtime/HerdrAgentRuntime.test.js +0 -488
  160. package/dist/__tests__/runtime/HerdrAgentRuntime.test.js.map +0 -1
  161. package/dist/__tests__/runtime/ManagedAgentRuntime.test.js +0 -637
  162. package/dist/__tests__/runtime/ManagedAgentRuntime.test.js.map +0 -1
  163. package/dist/__tests__/terminal/GhosttyBackend.test.js +0 -334
  164. package/dist/__tests__/terminal/GhosttyBackend.test.js.map +0 -1
  165. package/dist/__tests__/terminal/TerminalFocusManager.test.js +0 -253
  166. package/dist/__tests__/terminal/TerminalFocusManager.test.js.map +0 -1
  167. package/dist/__tests__/terminal/TmuxManager.test.js +0 -168
  168. package/dist/__tests__/terminal/TmuxManager.test.js.map +0 -1
  169. package/dist/__tests__/terminal/TtyWriter.test.js +0 -386
  170. package/dist/__tests__/terminal/TtyWriter.test.js.map +0 -1
  171. package/dist/__tests__/utils/AgentRegistry.test.js +0 -636
  172. package/dist/__tests__/utils/AgentRegistry.test.js.map +0 -1
  173. package/dist/__tests__/utils/IncrementalJsonlSummary.test.js +0 -650
  174. package/dist/__tests__/utils/IncrementalJsonlSummary.test.js.map +0 -1
  175. package/dist/__tests__/utils/agent-requests.test.js +0 -90
  176. package/dist/__tests__/utils/agent-requests.test.js.map +0 -1
  177. package/dist/__tests__/utils/conversationTail.bench.test.js +0 -258
  178. package/dist/__tests__/utils/conversationTail.bench.test.js.map +0 -1
  179. package/dist/__tests__/utils/conversationTailParity.test.js +0 -588
  180. package/dist/__tests__/utils/conversationTailParity.test.js.map +0 -1
  181. package/dist/__tests__/utils/jsonlTail.test.js +0 -360
  182. package/dist/__tests__/utils/jsonlTail.test.js.map +0 -1
  183. package/dist/__tests__/utils/matching.test.js +0 -324
  184. package/dist/__tests__/utils/matching.test.js.map +0 -1
  185. package/dist/__tests__/utils/matchingConstants.test.js +0 -35
  186. package/dist/__tests__/utils/matchingConstants.test.js.map +0 -1
  187. package/dist/__tests__/utils/process.test.js +0 -818
  188. package/dist/__tests__/utils/process.test.js.map +0 -1
  189. package/dist/__tests__/utils/session.test.js +0 -175
  190. package/dist/__tests__/utils/session.test.js.map +0 -1
  191. package/project.json +0 -29
  192. package/scripts/benchmark-cold-start.mjs +0 -350
  193. package/src/AgentManager.ts +0 -559
  194. package/src/__tests__/AgentManager.test.ts +0 -1578
  195. package/src/__tests__/adapters/IncrementalSessionRefresh.test.ts +0 -437
  196. package/src/__tests__/adapters/adapterProcessImports.test.ts +0 -58
  197. package/src/__tests__/adapters/adapterSnapshotCandidates.test.ts +0 -243
  198. package/src/__tests__/capacity/anthropic.test.ts +0 -105
  199. package/src/__tests__/capacity/boundaries.test.ts +0 -36
  200. package/src/__tests__/capacity/claude.test.ts +0 -462
  201. package/src/__tests__/capacity/codex.test.ts +0 -311
  202. package/src/__tests__/capacity/devin.test.ts +0 -210
  203. package/src/__tests__/capacity/fixtures/claude-credentials.json +0 -7
  204. package/src/__tests__/capacity/fixtures/claude-usage-malformed.json +0 -1
  205. package/src/__tests__/capacity/fixtures/claude-usage-partial.json +0 -15
  206. package/src/__tests__/capacity/fixtures/claude-usage.json +0 -63
  207. package/src/__tests__/capacity/fixtures/devin-config.json +0 -6
  208. package/src/__tests__/capacity/fixtures/devin-credentials.toml +0 -4
  209. package/src/__tests__/capacity/fixtures/devin-quota-nonplan.json +0 -5
  210. package/src/__tests__/capacity/fixtures/devin-quota.json +0 -10
  211. package/src/__tests__/capacity/fixtures/openai-auth.json +0 -6
  212. package/src/__tests__/capacity/fixtures/openai-codex-auth.json +0 -9
  213. package/src/__tests__/capacity/fixtures/openai-usage-completions.json +0 -67
  214. package/src/__tests__/capacity/fixtures/openai-usage-responses.json +0 -20
  215. package/src/__tests__/capacity/fixtures/wham-usage.json +0 -45
  216. package/src/__tests__/capacity/fixtures/zai-auth.json +0 -6
  217. package/src/__tests__/capacity/fixtures/zai-quota-invalid.json +0 -7
  218. package/src/__tests__/capacity/fixtures/zai-quota.json +0 -38
  219. package/src/__tests__/capacity/index.test.ts +0 -54
  220. package/src/__tests__/capacity/openai.test.ts +0 -571
  221. package/src/__tests__/capacity/wham.test.ts +0 -122
  222. package/src/__tests__/capacity/zai.test.ts +0 -151
  223. package/src/__tests__/fixtures.test.ts +0 -245
  224. package/src/__tests__/harnesses/BoundedSummarySkip.test.ts +0 -496
  225. package/src/__tests__/harnesses/SessionSummaryEquivalence.test.ts +0 -726
  226. package/src/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.ts +0 -133
  227. package/src/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.ts +0 -396
  228. package/src/__tests__/harnesses/builtinAdapters.test.ts +0 -33
  229. package/src/__tests__/harnesses/claude/ClaudeAgentMapper.test.ts +0 -84
  230. package/src/__tests__/harnesses/claude/ClaudeCodeAdapter.test.ts +0 -1793
  231. package/src/__tests__/harnesses/claude/ClaudeSessionLocator.test.ts +0 -423
  232. package/src/__tests__/harnesses/claude/ClaudeSessionParser.test.ts +0 -300
  233. package/src/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.ts +0 -34
  234. package/src/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.ts +0 -61
  235. package/src/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.ts +0 -129
  236. package/src/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.ts +0 -152
  237. package/src/__tests__/harnesses/codex/CodexAdapter.test.ts +0 -652
  238. package/src/__tests__/harnesses/codex/CodexSessionLocator.test.ts +0 -419
  239. package/src/__tests__/harnesses/codex/CodexSessionMapping.test.ts +0 -63
  240. package/src/__tests__/harnesses/codex/CodexSessionParser.test.ts +0 -192
  241. package/src/__tests__/harnesses/codex/durable/CodexCliProbe.test.ts +0 -80
  242. package/src/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.ts +0 -65
  243. package/src/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.ts +0 -104
  244. package/src/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.ts +0 -201
  245. package/src/__tests__/harnesses/codex/durable/CodexPrintRunner.test.ts +0 -299
  246. package/src/__tests__/harnesses/copilot/CopilotAdapter.test.ts +0 -614
  247. package/src/__tests__/harnesses/copilot/CopilotRefreshIO.test.ts +0 -270
  248. package/src/__tests__/harnesses/devin/DevinAdapter.test.ts +0 -290
  249. package/src/__tests__/harnesses/devin/DevinAgentMapper.test.ts +0 -101
  250. package/src/__tests__/harnesses/devin/DevinSessionLocator.test.ts +0 -139
  251. package/src/__tests__/harnesses/devin/DevinSessionParser.test.ts +0 -212
  252. package/src/__tests__/harnesses/devin/fixtures.ts +0 -144
  253. package/src/__tests__/harnesses/gemini/GeminiCliAdapter.test.ts +0 -1336
  254. package/src/__tests__/harnesses/gemini/GeminiSessionJsonl.test.ts +0 -402
  255. package/src/__tests__/harnesses/gemini/GeminiSessionLocator.test.ts +0 -396
  256. package/src/__tests__/harnesses/grok/GrokAgentMapper.test.ts +0 -57
  257. package/src/__tests__/harnesses/grok/GrokCliAdapter.test.ts +0 -376
  258. package/src/__tests__/harnesses/grok/GrokIncrementalRefresh.test.ts +0 -170
  259. package/src/__tests__/harnesses/grok/GrokSessionLocator.test.ts +0 -106
  260. package/src/__tests__/harnesses/grok/GrokSessionParser.test.ts +0 -230
  261. package/src/__tests__/harnesses/kiro/KiroAdapter.test.ts +0 -552
  262. package/src/__tests__/harnesses/muse/MuseAdapter.test.ts +0 -197
  263. package/src/__tests__/harnesses/muse/MuseAgentMapper.test.ts +0 -83
  264. package/src/__tests__/harnesses/muse/MuseSessionLocator.test.ts +0 -177
  265. package/src/__tests__/harnesses/muse/MuseSessionParser.test.ts +0 -279
  266. package/src/__tests__/harnesses/opencode/OpenCodeAdapter.test.ts +0 -215
  267. package/src/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.ts +0 -101
  268. package/src/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.ts +0 -84
  269. package/src/__tests__/harnesses/opencode/OpenCodeSessionParser.test.ts +0 -149
  270. package/src/__tests__/harnesses/pi/PiAdapter.test.ts +0 -325
  271. package/src/__tests__/harnesses/pi/PiDiscoveryIO.test.ts +0 -337
  272. package/src/__tests__/harnesses/pi/PiSessionParser.test.ts +0 -280
  273. package/src/__tests__/harnesses/pi/PiSessionTracker.test.ts +0 -79
  274. package/src/__tests__/harnesses/pi/durable/PiCliProbe.test.ts +0 -50
  275. package/src/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.ts +0 -33
  276. package/src/__tests__/harnesses/pi/durable/PiPrintAgentService.test.ts +0 -138
  277. package/src/__tests__/harnesses/pi/durable/PiPrintProtocol.test.ts +0 -71
  278. package/src/__tests__/harnesses/pi/durable/PiPrintRunner.test.ts +0 -252
  279. package/src/__tests__/harnesses/pi/durable/PiStreamParser.test.ts +0 -26
  280. package/src/__tests__/harnesses/readiness/AgentReadiness.test.ts +0 -362
  281. package/src/__tests__/harnesses/runtimeProfiles.test.ts +0 -123
  282. package/src/__tests__/print/DurableAgent.test.ts +0 -15
  283. package/src/__tests__/print/DurableAgentRepository.sqlite.test.ts +0 -128
  284. package/src/__tests__/print/DurableAgentRepository.test.ts +0 -184
  285. package/src/__tests__/readiness-fixtures.test.ts +0 -79
  286. package/src/__tests__/runtime/AgentRuntime.test.ts +0 -8
  287. package/src/__tests__/runtime/HerdrAgentDiscovery.test.ts +0 -131
  288. package/src/__tests__/runtime/HerdrAgentRuntime.test.ts +0 -377
  289. package/src/__tests__/runtime/ManagedAgentRuntime.test.ts +0 -590
  290. package/src/__tests__/terminal/GhosttyBackend.test.ts +0 -271
  291. package/src/__tests__/terminal/TerminalFocusManager.test.ts +0 -280
  292. package/src/__tests__/terminal/TmuxManager.test.ts +0 -185
  293. package/src/__tests__/terminal/TtyWriter.test.ts +0 -454
  294. package/src/__tests__/utils/AgentRegistry.test.ts +0 -532
  295. package/src/__tests__/utils/IncrementalJsonlSummary.test.ts +0 -414
  296. package/src/__tests__/utils/agent-requests.test.ts +0 -94
  297. package/src/__tests__/utils/conversationTail.bench.test.ts +0 -193
  298. package/src/__tests__/utils/conversationTailParity.test.ts +0 -365
  299. package/src/__tests__/utils/jsonlTail.test.ts +0 -317
  300. package/src/__tests__/utils/matching.test.ts +0 -234
  301. package/src/__tests__/utils/matchingConstants.test.ts +0 -40
  302. package/src/__tests__/utils/process.test.ts +0 -596
  303. package/src/__tests__/utils/session.test.ts +0 -158
  304. package/src/adapters/AgentAdapter.ts +0 -255
  305. package/src/capacity/index.ts +0 -127
  306. package/src/capacity/providers/anthropic.ts +0 -198
  307. package/src/capacity/providers/devin.ts +0 -121
  308. package/src/capacity/providers/openai-platform.ts +0 -150
  309. package/src/capacity/providers/openai-subscription.ts +0 -184
  310. package/src/capacity/providers/zai.ts +0 -155
  311. package/src/capacity/sources/claude.ts +0 -30
  312. package/src/capacity/sources/codex.ts +0 -251
  313. package/src/capacity/sources/devin.ts +0 -49
  314. package/src/capacity/sources/pi.ts +0 -131
  315. package/src/capacity/types.ts +0 -29
  316. package/src/database/connection.ts +0 -96
  317. package/src/database/index.ts +0 -7
  318. package/src/database/migrations/001_initial.sql +0 -12
  319. package/src/database/migrations/002_pins.sql +0 -1
  320. package/src/database/migrations/003_durable_agents.sql +0 -43
  321. package/src/database/migrations/004_codex_durable_sessions.sql +0 -1
  322. package/src/database/migrations/005_agent_runtime.sql +0 -2
  323. package/src/database/schema.ts +0 -64
  324. package/src/durable/DurableAgent.ts +0 -139
  325. package/src/durable/DurableAgentRepository.ts +0 -485
  326. package/src/durable/process.ts +0 -29
  327. package/src/durable/run.ts +0 -84
  328. package/src/durable/utils.ts +0 -66
  329. package/src/fixtures/bundle.ts +0 -130
  330. package/src/fixtures/capture.ts +0 -364
  331. package/src/harnesses/antigravity/AntigravityAgentMapper.ts +0 -34
  332. package/src/harnesses/antigravity/AntigravityCliAdapter.ts +0 -126
  333. package/src/harnesses/antigravity/AntigravitySessionLocator.ts +0 -75
  334. package/src/harnesses/antigravity/AntigravitySessionParser.ts +0 -252
  335. package/src/harnesses/claude/ClaudeAgentMapper.ts +0 -55
  336. package/src/harnesses/claude/ClaudeCodeAdapter.ts +0 -175
  337. package/src/harnesses/claude/ClaudeSessionLocator.ts +0 -358
  338. package/src/harnesses/claude/ClaudeSessionParser.ts +0 -524
  339. package/src/harnesses/claude/credentials.ts +0 -122
  340. package/src/harnesses/claude/durable/ClaudeCliProbe.ts +0 -57
  341. package/src/harnesses/claude/durable/ClaudePrintAgentService.ts +0 -79
  342. package/src/harnesses/claude/durable/ClaudePrintRunner.ts +0 -102
  343. package/src/harnesses/claude/durable/ClaudeStreamParser.ts +0 -108
  344. package/src/harnesses/claude/readiness.ts +0 -69
  345. package/src/harnesses/codex/CodexAdapter.ts +0 -337
  346. package/src/harnesses/codex/CodexAgentMapper.ts +0 -26
  347. package/src/harnesses/codex/CodexSessionLocator.ts +0 -509
  348. package/src/harnesses/codex/CodexSessionMapping.ts +0 -89
  349. package/src/harnesses/codex/CodexSessionParser.ts +0 -462
  350. package/src/harnesses/codex/credentials.ts +0 -81
  351. package/src/harnesses/codex/durable/CodexCliProbe.ts +0 -68
  352. package/src/harnesses/codex/durable/CodexPrintAgentService.ts +0 -79
  353. package/src/harnesses/codex/durable/CodexPrintRunner.ts +0 -104
  354. package/src/harnesses/codex/durable/CodexStreamParser.ts +0 -117
  355. package/src/harnesses/codex/readiness.ts +0 -72
  356. package/src/harnesses/copilot/CopilotAdapter.ts +0 -161
  357. package/src/harnesses/copilot/CopilotAgentMapper.ts +0 -27
  358. package/src/harnesses/copilot/CopilotSessionLocator.ts +0 -161
  359. package/src/harnesses/copilot/CopilotSessionParser.ts +0 -380
  360. package/src/harnesses/copilot/readiness.ts +0 -33
  361. package/src/harnesses/devin/DevinAdapter.ts +0 -212
  362. package/src/harnesses/devin/DevinAgentMapper.ts +0 -39
  363. package/src/harnesses/devin/DevinSessionLocator.ts +0 -230
  364. package/src/harnesses/devin/DevinSessionParser.ts +0 -227
  365. package/src/harnesses/devin/credentials.ts +0 -88
  366. package/src/harnesses/devin/readiness.ts +0 -36
  367. package/src/harnesses/gemini/GeminiAgentMapper.ts +0 -27
  368. package/src/harnesses/gemini/GeminiCliAdapter.ts +0 -272
  369. package/src/harnesses/gemini/GeminiSessionLocator.ts +0 -394
  370. package/src/harnesses/gemini/GeminiSessionParser.ts +0 -395
  371. package/src/harnesses/gemini/fileSignature.ts +0 -10
  372. package/src/harnesses/grok/GrokAgentMapper.ts +0 -32
  373. package/src/harnesses/grok/GrokCliAdapter.ts +0 -126
  374. package/src/harnesses/grok/GrokSessionLocator.ts +0 -179
  375. package/src/harnesses/grok/GrokSessionParser.ts +0 -251
  376. package/src/harnesses/index.ts +0 -32
  377. package/src/harnesses/kiro/KiroAdapter.ts +0 -143
  378. package/src/harnesses/kiro/KiroAgentMapper.ts +0 -34
  379. package/src/harnesses/kiro/KiroSessionLocator.ts +0 -143
  380. package/src/harnesses/kiro/KiroSessionParser.ts +0 -376
  381. package/src/harnesses/muse/MuseAdapter.ts +0 -157
  382. package/src/harnesses/muse/MuseAgentMapper.ts +0 -33
  383. package/src/harnesses/muse/MuseSessionLocator.ts +0 -286
  384. package/src/harnesses/muse/MuseSessionParser.ts +0 -435
  385. package/src/harnesses/muse/readiness.ts +0 -38
  386. package/src/harnesses/opencode/OpenCodeAdapter.ts +0 -110
  387. package/src/harnesses/opencode/OpenCodeAgentMapper.ts +0 -49
  388. package/src/harnesses/opencode/OpenCodeSessionLocator.ts +0 -151
  389. package/src/harnesses/opencode/OpenCodeSessionParser.ts +0 -146
  390. package/src/harnesses/opencode/readiness.ts +0 -48
  391. package/src/harnesses/pi/PiAdapter.ts +0 -197
  392. package/src/harnesses/pi/PiAgentMapper.ts +0 -27
  393. package/src/harnesses/pi/PiSessionLocator.ts +0 -288
  394. package/src/harnesses/pi/PiSessionParser.ts +0 -488
  395. package/src/harnesses/pi/PiSessionTracker.ts +0 -87
  396. package/src/harnesses/pi/credentials.ts +0 -129
  397. package/src/harnesses/pi/durable/PiCliProbe.ts +0 -56
  398. package/src/harnesses/pi/durable/PiPrintAgentService.ts +0 -77
  399. package/src/harnesses/pi/durable/PiPrintProtocol.ts +0 -41
  400. package/src/harnesses/pi/durable/PiPrintRunner.ts +0 -95
  401. package/src/harnesses/pi/durable/PiStreamParser.ts +0 -94
  402. package/src/harnesses/pi/readiness.ts +0 -104
  403. package/src/harnesses/readiness/AgentReadiness.ts +0 -91
  404. package/src/harnesses/readiness/checks.ts +0 -336
  405. package/src/harnesses/readiness/types.ts +0 -90
  406. package/src/harnesses/runtimeProfiles.ts +0 -105
  407. package/src/harnesses/shared.ts +0 -124
  408. package/src/index.ts +0 -71
  409. package/src/runtime/ManagedAgentRuntime.ts +0 -253
  410. package/src/runtime/RuntimeFactory.ts +0 -13
  411. package/src/runtime/errors.ts +0 -50
  412. package/src/runtime/herdr/HerdrAgentDiscovery.ts +0 -166
  413. package/src/runtime/herdr/HerdrAgentRuntime.ts +0 -216
  414. package/src/runtime/herdr/HerdrCliClient.ts +0 -78
  415. package/src/runtime/herdr/HerdrErrors.ts +0 -9
  416. package/src/runtime/herdr/HerdrResponseParsers.ts +0 -86
  417. package/src/runtime/herdr/HerdrRuntimeRef.ts +0 -41
  418. package/src/runtime/tmux/PidPolling.ts +0 -34
  419. package/src/runtime/tmux/TmuxAgentRuntime.ts +0 -113
  420. package/src/runtime/tmux/TmuxManager.ts +0 -102
  421. package/src/runtime/tmux/TmuxRuntimeRef.ts +0 -9
  422. package/src/runtime/types.ts +0 -56
  423. package/src/terminal/TerminalFocusManager.ts +0 -52
  424. package/src/terminal/TtyWriter.ts +0 -26
  425. package/src/terminal/backends/ghostty.ts +0 -180
  426. package/src/terminal/backends/index.ts +0 -23
  427. package/src/terminal/backends/iterm2.ts +0 -126
  428. package/src/terminal/backends/shared.ts +0 -47
  429. package/src/terminal/backends/terminal-app.ts +0 -122
  430. package/src/terminal/backends/tmux.ts +0 -62
  431. package/src/terminal/backends/wezterm.ts +0 -65
  432. package/src/terminal/types.ts +0 -23
  433. package/src/utils/AgentRegistry.ts +0 -351
  434. package/src/utils/IncrementalJsonlSummary.ts +0 -306
  435. package/src/utils/agent-requests.ts +0 -28
  436. package/src/utils/applescript.ts +0 -10
  437. package/src/utils/jsonlTail.ts +0 -349
  438. package/src/utils/matching.ts +0 -96
  439. package/src/utils/matchingConstants.ts +0 -15
  440. package/src/utils/process.ts +0 -604
  441. package/src/utils/session.ts +0 -144
  442. package/src/utils/sortAgents.ts +0 -54
  443. package/tsconfig.json +0 -11
  444. package/vitest.config.ts +0 -20
@@ -1,185 +0,0 @@
1
- import { execFile } from "child_process";
2
- import type { MockedFunction } from "vitest";
3
- import { TmuxManager } from "../../runtime/tmux/TmuxManager.js";
4
-
5
- vi.mock("child_process", () => ({
6
- execFile: vi.fn(),
7
- }));
8
-
9
- type ExecFileCb = (err: Error | null, result?: { stdout: string; stderr: string }) => void;
10
- const mockedExecFile = execFile as unknown as MockedFunction<
11
- (cmd: string, args: string[], cb: ExecFileCb) => void
12
- >;
13
-
14
- /** Drive the promisified execFile mock with a per-call handler. */
15
- function setExecFileHandler(handler: (cmd: string, args: string[]) => string | Error) {
16
- mockedExecFile.mockImplementation((_cmd, _args, cb) => {
17
- const result = handler(_cmd, _args);
18
- if (result instanceof Error) cb(result);
19
- else cb(null, { stdout: result, stderr: "" });
20
- });
21
- }
22
-
23
- describe("TmuxManager", () => {
24
- let tmux: TmuxManager;
25
-
26
- beforeEach(() => {
27
- tmux = new TmuxManager();
28
- mockedExecFile.mockReset();
29
- });
30
-
31
- describe("isAvailable", () => {
32
- it("returns true when `tmux -V` succeeds", async () => {
33
- setExecFileHandler(() => "tmux 3.4");
34
- expect(await tmux.isAvailable()).toBe(true);
35
- });
36
-
37
- it("returns false when tmux is missing", async () => {
38
- setExecFileHandler(() => new Error("ENOENT"));
39
- expect(await tmux.isAvailable()).toBe(false);
40
- });
41
- });
42
-
43
- describe("sessionExists", () => {
44
- it("returns true when has-session succeeds", async () => {
45
- setExecFileHandler(() => "");
46
- expect(await tmux.sessionExists("foo")).toBe(true);
47
- });
48
-
49
- it("returns false when has-session fails", async () => {
50
- setExecFileHandler(() => new Error("no session"));
51
- expect(await tmux.sessionExists("foo")).toBe(false);
52
- });
53
- });
54
-
55
- describe("createSession", () => {
56
- it("issues `tmux new-session -d -s <name> -c <cwd>`", async () => {
57
- setExecFileHandler(() => "");
58
- await tmux.createSession("foo", "/work");
59
- expect(mockedExecFile).toHaveBeenCalledWith(
60
- "tmux",
61
- ["new-session", "-d", "-s", "foo", "-c", "/work"],
62
- expect.any(Function),
63
- );
64
- });
65
- });
66
-
67
- describe("sendKeys", () => {
68
- it("appends Enter so the command runs", async () => {
69
- setExecFileHandler(() => "");
70
- await tmux.sendKeys("foo", "claude");
71
- expect(mockedExecFile).toHaveBeenCalledWith(
72
- "tmux",
73
- ["send-keys", "-t", "foo", "claude", "Enter"],
74
- expect.any(Function),
75
- );
76
- });
77
- });
78
-
79
- describe("killSession", () => {
80
- it("swallows errors when session is already gone", async () => {
81
- setExecFileHandler(() => new Error("can't find session"));
82
- await expect(tmux.killSession("foo")).resolves.toBeUndefined();
83
- });
84
- });
85
-
86
- describe("findAgentPid", () => {
87
- const matchesClaude = (cmd: string) => cmd.split(/\s+/)[0]?.endsWith("claude") ?? false;
88
-
89
- it("returns null when the session has no pane", async () => {
90
- setExecFileHandler((cmd, args) => {
91
- if (args[0] === "list-panes") return new Error("no session");
92
- return "";
93
- });
94
- expect(await tmux.findAgentPid("foo", matchesClaude)).toBeNull();
95
- });
96
-
97
- it("returns null when no descendant matches", async () => {
98
- // pane PID 100; child 200 is "node /unrelated" — no match
99
- setExecFileHandler((cmd, args) => {
100
- if (cmd === "tmux" && args[0] === "list-panes") return "100\n";
101
- if (cmd === "pgrep" && args[1] === "100") return "200\n";
102
- if (cmd === "pgrep") return new Error("no children");
103
- if (cmd === "ps" && args[1] === "200") return "node /unrelated";
104
- return "";
105
- });
106
- expect(await tmux.findAgentPid("foo", matchesClaude)).toBeNull();
107
- });
108
-
109
- it("returns the matching pane PID when the agent replaces the shell", async () => {
110
- setExecFileHandler((cmd, args) => {
111
- if (cmd === "tmux" && args[0] === "list-panes") return "100\n";
112
- if (cmd === "pgrep") return new Error("no children");
113
- if (cmd === "ps" && args[1] === "100") return "/usr/local/bin/claude";
114
- return "";
115
- });
116
- expect(await tmux.findAgentPid("foo", matchesClaude)).toBe(100);
117
- });
118
-
119
- it("returns the matching descendant when found", async () => {
120
- // pane 100 → child 200 (claude) — no grandchildren
121
- setExecFileHandler((cmd, args) => {
122
- if (cmd === "tmux") return "100\n";
123
- if (cmd === "pgrep" && args[1] === "100") return "200\n";
124
- if (cmd === "pgrep") return new Error("no children");
125
- if (cmd === "ps" && args[1] === "200") return "claude";
126
- return "";
127
- });
128
- expect(await tmux.findAgentPid("foo", matchesClaude)).toBe(200);
129
- });
130
-
131
- it("prefers the deepest match (wrapper case)", async () => {
132
- // pane 100 → 200 (claude wrapper, matches) → 300 (claude, matches, deeper)
133
- setExecFileHandler((cmd, args) => {
134
- if (cmd === "tmux") return "100\n";
135
- if (cmd === "pgrep" && args[1] === "100") return "200\n";
136
- if (cmd === "pgrep" && args[1] === "200") return "300\n";
137
- if (cmd === "pgrep") return new Error("no children");
138
- if (cmd === "ps" && args[1] === "200") return "/usr/local/bin/claude";
139
- if (cmd === "ps" && args[1] === "300") return "/usr/local/lib/claude";
140
- return "";
141
- });
142
- expect(await tmux.findAgentPid("foo", matchesClaude)).toBe(300);
143
- });
144
-
145
- it("skips non-matching subprocesses (MCP child case)", async () => {
146
- // pane 100 → 200 (claude, matches) → 300 (mcp-server, no match)
147
- setExecFileHandler((cmd, args) => {
148
- if (cmd === "tmux") return "100\n";
149
- if (cmd === "pgrep" && args[1] === "100") return "200\n";
150
- if (cmd === "pgrep" && args[1] === "200") return "300\n";
151
- if (cmd === "pgrep") return new Error("no children");
152
- if (cmd === "ps" && args[1] === "200") return "claude";
153
- if (cmd === "ps" && args[1] === "300") return "node mcp-server.js";
154
- return "";
155
- });
156
- expect(await tmux.findAgentPid("foo", matchesClaude)).toBe(200);
157
- });
158
-
159
- it("handles the gemini Node-script shape via a token-scan matcher", async () => {
160
- const matchesGemini = (cmd: string) =>
161
- cmd.split(/\s+/).some((t) => t.endsWith("/gemini") || t === "gemini");
162
- setExecFileHandler((cmd, args) => {
163
- if (cmd === "tmux") return "100\n";
164
- if (cmd === "pgrep" && args[1] === "100") return "200\n";
165
- if (cmd === "pgrep") return new Error("no children");
166
- if (cmd === "ps" && args[1] === "200") return "node /opt/homebrew/bin/gemini --foo";
167
- return "";
168
- });
169
- expect(await tmux.findAgentPid("foo", matchesGemini)).toBe(200);
170
- });
171
-
172
- it("handles multiple children at the same level", async () => {
173
- // pane 100 → [200 (nope), 201 (claude)]
174
- setExecFileHandler((cmd, args) => {
175
- if (cmd === "tmux") return "100\n";
176
- if (cmd === "pgrep" && args[1] === "100") return "200\n201\n";
177
- if (cmd === "pgrep") return new Error("no children");
178
- if (cmd === "ps" && args[1] === "200") return "bash";
179
- if (cmd === "ps" && args[1] === "201") return "claude";
180
- return "";
181
- });
182
- expect(await tmux.findAgentPid("foo", matchesClaude)).toBe(201);
183
- });
184
- });
185
- });
@@ -1,454 +0,0 @@
1
- import type { Mock } from "vitest";
2
-
3
- import { TtyWriter } from "../../terminal/TtyWriter.js";
4
- import { TerminalType } from "../../terminal/TerminalFocusManager.js";
5
- import type { TerminalLocation } from "../../terminal/TerminalFocusManager.js";
6
- import { execFile } from "child_process";
7
-
8
- vi.mock("child_process", async () => {
9
- const actual = await vi.importActual<typeof import("child_process")>("child_process");
10
- return {
11
- ...actual,
12
- execFile: vi.fn(),
13
- };
14
- });
15
-
16
- const mockedExecFile = execFile as unknown as Mock;
17
-
18
- function mockExecFileSuccess(stdout = "") {
19
- mockedExecFile.mockImplementation((...args: unknown[]) => {
20
- const cb = args[args.length - 1] as (
21
- err: Error | null,
22
- result: { stdout: string },
23
- stderr: string,
24
- ) => void;
25
- cb(null, { stdout }, "");
26
- return { stdin: { end: vi.fn() } };
27
- });
28
- }
29
-
30
- function mockExecFileError(message: string) {
31
- mockedExecFile.mockImplementation((...args: unknown[]) => {
32
- const cb = args[args.length - 1] as (err: Error | null, result: null, stderr: string) => void;
33
- cb(new Error(message), null, "");
34
- });
35
- }
36
-
37
- describe("TtyWriter", () => {
38
- beforeEach(() => {
39
- vi.clearAllMocks();
40
- });
41
-
42
- describe("tmux", () => {
43
- const location: TerminalLocation = {
44
- type: TerminalType.TMUX,
45
- identifier: "main:0.1",
46
- tty: "/dev/ttys030",
47
- };
48
-
49
- it("pastes message in bracketed paste mode and sends Enter separately", async () => {
50
- mockExecFileSuccess();
51
- const message = "line 1\nline 2\n";
52
-
53
- await TtyWriter.send(location, message);
54
-
55
- const loadArgs = mockedExecFile.mock.calls[0]?.[1] as string[];
56
- const bufferName = loadArgs[2];
57
- expect(bufferName).toMatch(/^ai-devkit-send-/);
58
- expect(mockedExecFile).toHaveBeenNthCalledWith(
59
- 1,
60
- "tmux",
61
- ["load-buffer", "-b", bufferName, "-"],
62
- expect.any(Function),
63
- );
64
- expect(mockedExecFile.mock.results[0]?.value.stdin.end).toHaveBeenCalledWith(message);
65
- expect(mockedExecFile).toHaveBeenNthCalledWith(
66
- 2,
67
- "tmux",
68
- ["paste-buffer", "-t", "main:0.1", "-b", bufferName, "-p", "-d"],
69
- expect.any(Function),
70
- );
71
- expect(mockedExecFile).toHaveBeenNthCalledWith(
72
- 3,
73
- "tmux",
74
- ["send-keys", "-t", "main:0.1", "Enter"],
75
- expect.any(Function),
76
- );
77
- expect(mockedExecFile).toHaveBeenCalledTimes(3);
78
- });
79
-
80
- it("throws on tmux failure", async () => {
81
- mockExecFileError("tmux not running");
82
-
83
- await expect(TtyWriter.send(location, "hello")).rejects.toThrow("tmux not running");
84
- });
85
- });
86
-
87
- describe("iTerm2", () => {
88
- const location: TerminalLocation = {
89
- type: TerminalType.ITERM2,
90
- identifier: "/dev/ttys030",
91
- tty: "/dev/ttys030",
92
- };
93
-
94
- it("sends message via osascript with execFile (no shell)", async () => {
95
- mockExecFileSuccess("ok");
96
-
97
- await TtyWriter.send(location, "hello");
98
-
99
- // First call: send text without newline
100
- expect(mockedExecFile).toHaveBeenCalledWith(
101
- "osascript",
102
- ["-e", expect.stringContaining('write text "hello" newline no')],
103
- expect.any(Function),
104
- );
105
- // Second call: send Enter via separate write text with newline
106
- expect(mockedExecFile).toHaveBeenCalledWith(
107
- "osascript",
108
- ["-e", expect.stringContaining('write text "" newline yes')],
109
- expect.any(Function),
110
- );
111
- expect(mockedExecFile).toHaveBeenCalledTimes(2);
112
- });
113
-
114
- it("escapes special characters in message", async () => {
115
- mockExecFileSuccess("ok");
116
-
117
- await TtyWriter.send(location, 'say "hi" \\ there');
118
-
119
- expect(mockedExecFile).toHaveBeenCalledWith(
120
- "osascript",
121
- ["-e", expect.stringContaining('write text "say \\"hi\\" \\\\ there" newline no')],
122
- expect.any(Function),
123
- );
124
- });
125
-
126
- it("escapes newlines in message", async () => {
127
- mockExecFileSuccess("ok");
128
-
129
- await TtyWriter.send(location, "line1\nline2");
130
-
131
- expect(mockedExecFile).toHaveBeenCalledWith(
132
- "osascript",
133
- ["-e", expect.stringContaining('write text "line1\\nline2" newline no')],
134
- expect.any(Function),
135
- );
136
- });
137
-
138
- it("throws when session not found", async () => {
139
- mockExecFileSuccess("not_found");
140
-
141
- await expect(TtyWriter.send(location, "test")).rejects.toThrow("iTerm2 session not found");
142
- });
143
-
144
- it("throws when session disappears before Enter", async () => {
145
- // First call succeeds (text sent), second returns not_found
146
- let callCount = 0;
147
- mockedExecFile.mockImplementation((...args: unknown[]) => {
148
- const cb = args[args.length - 1] as (
149
- err: Error | null,
150
- result: { stdout: string },
151
- stderr: string,
152
- ) => void;
153
- callCount++;
154
- cb(null, { stdout: callCount === 1 ? "ok" : "not_found" }, "");
155
- });
156
-
157
- await expect(TtyWriter.send(location, "test")).rejects.toThrow(
158
- "iTerm2 session disappeared before Enter",
159
- );
160
- });
161
- });
162
-
163
- describe("Terminal.app", () => {
164
- const location: TerminalLocation = {
165
- type: TerminalType.TERMINAL_APP,
166
- identifier: "/dev/ttys030",
167
- tty: "/dev/ttys030",
168
- };
169
-
170
- it("sends message via do script (not System Events)", async () => {
171
- mockExecFileSuccess("ok");
172
-
173
- await TtyWriter.send(location, "hello");
174
-
175
- // First call: send text via do script
176
- const firstCallArgs = (mockedExecFile.mock.calls[0] as unknown[])[1] as string[];
177
- const textScript = firstCallArgs[1];
178
- expect(textScript).toContain('do script "hello" in targetTab');
179
- expect(textScript).not.toContain("keystroke");
180
- expect(textScript).not.toContain("key code 36");
181
-
182
- // Second call: send Enter via separate do script
183
- const secondCallArgs = (mockedExecFile.mock.calls[1] as unknown[])[1] as string[];
184
- const enterScript = secondCallArgs[1];
185
- expect(enterScript).toContain('do script "" in targetTab');
186
-
187
- expect(mockedExecFile).toHaveBeenCalledTimes(2);
188
- });
189
-
190
- it("throws when tab not found", async () => {
191
- mockExecFileSuccess("not_found");
192
-
193
- await expect(TtyWriter.send(location, "test")).rejects.toThrow("Terminal.app tab not found");
194
- });
195
-
196
- it("throws when tab disappears before Enter", async () => {
197
- let callCount = 0;
198
- mockedExecFile.mockImplementation((...args: unknown[]) => {
199
- const cb = args[args.length - 1] as (
200
- err: Error | null,
201
- result: { stdout: string },
202
- stderr: string,
203
- ) => void;
204
- callCount++;
205
- cb(null, { stdout: callCount === 1 ? "ok" : "not_found" }, "");
206
- });
207
-
208
- await expect(TtyWriter.send(location, "test")).rejects.toThrow(
209
- "Terminal.app tab disappeared before Enter",
210
- );
211
- });
212
- });
213
-
214
- describe("WezTerm", () => {
215
- const location: TerminalLocation = {
216
- type: TerminalType.WEZTERM,
217
- identifier: "7",
218
- tty: "/dev/ttys030",
219
- };
220
-
221
- it("sends the message via stdin and Enter as a separate send-text call", async () => {
222
- mockExecFileSuccess();
223
-
224
- await TtyWriter.send(location, "continue");
225
-
226
- // Step 1: message body via stdin, not argv, so prompt contents are
227
- // not exposed through process listings.
228
- expect(mockedExecFile).toHaveBeenCalledWith(
229
- "wezterm",
230
- ["cli", "send-text", "--pane-id", "7"],
231
- expect.any(Function),
232
- );
233
- expect(mockedExecFile.mock.results[0]?.value.stdin.end).toHaveBeenCalledWith("continue");
234
- // Step 2: Enter as a single carriage return (0x0d) with --no-paste,
235
- // so the CR is delivered literally (not wrapped in paste brackets).
236
- // execFile passes the actual CR byte (JS '\x0d'); the equivalent
237
- // shell command is:
238
- // wezterm cli send-text --pane-id <id> --no-paste $'\x0d'
239
- expect(mockedExecFile).toHaveBeenCalledWith(
240
- "wezterm",
241
- ["cli", "send-text", "--pane-id", "7", "--no-paste", "\x0d"],
242
- expect.any(Function),
243
- );
244
- expect(mockedExecFile).toHaveBeenCalledTimes(2);
245
- });
246
-
247
- it("passes the Enter byte as the carriage return (0x0d), not newline", async () => {
248
- mockExecFileSuccess();
249
-
250
- await TtyWriter.send(location, "continue");
251
-
252
- // The Enter call is the second invocation; its last argv element is
253
- // a single byte equal to char code 13 (0x0d).
254
- const enterCall = mockedExecFile.mock.calls[1];
255
- const enterArgs = enterCall[1] as string[];
256
- const enterByte = enterArgs[enterArgs.length - 1];
257
- expect(enterByte).toHaveLength(1);
258
- expect(enterByte.charCodeAt(0)).toBe(0x0d);
259
- expect(enterArgs).toContain("--no-paste");
260
- });
261
-
262
- it("keeps the whole message out of argv and writes it verbatim to stdin", async () => {
263
- mockExecFileSuccess();
264
- const hostile = "echo pwned; $(rm -rf /) `whoami` | cat\nline2";
265
-
266
- await TtyWriter.send(location, hostile);
267
-
268
- // The message is written verbatim to stdin, not built into a shell
269
- // string or exposed as a process argument.
270
- const textCall = mockedExecFile.mock.calls[0];
271
- const textArgs = textCall[1] as string[];
272
- expect(textArgs).toEqual(["cli", "send-text", "--pane-id", "7"]);
273
- expect(textCall[2]).toBeTypeOf("function");
274
- expect(mockedExecFile.mock.results[0]?.value.stdin.end).toHaveBeenCalledWith(hostile);
275
- });
276
-
277
- it("uses the pane id from location.identifier", async () => {
278
- mockExecFileSuccess();
279
- const pane42 = { ...location, identifier: "42" };
280
-
281
- await TtyWriter.send(pane42, "hi");
282
-
283
- expect(mockedExecFile).toHaveBeenCalledWith(
284
- "wezterm",
285
- ["cli", "send-text", "--pane-id", "42"],
286
- expect.any(Function),
287
- );
288
- expect(mockedExecFile.mock.results[0]?.value.stdin.end).toHaveBeenCalledWith("hi");
289
- });
290
-
291
- it("throws when the text send fails", async () => {
292
- mockExecFileError("wezterm send-text failed");
293
-
294
- await expect(TtyWriter.send(location, "hello")).rejects.toThrow("wezterm send-text failed");
295
- });
296
- });
297
-
298
- describe("unsupported terminal", () => {
299
- it("throws for unknown terminal type", async () => {
300
- const location: TerminalLocation = {
301
- type: TerminalType.UNKNOWN,
302
- identifier: "",
303
- tty: "/dev/ttys030",
304
- };
305
-
306
- await expect(TtyWriter.send(location, "test")).rejects.toThrow(
307
- "Cannot send input: unsupported terminal type",
308
- );
309
- });
310
- });
311
-
312
- describe("sendKey — tmux", () => {
313
- const location: TerminalLocation = {
314
- type: TerminalType.TMUX,
315
- identifier: "main:0.1",
316
- tty: "/dev/ttys030",
317
- };
318
-
319
- it("sends key via tmux send-keys directly (no paste buffer, no auto-Enter)", async () => {
320
- mockExecFileSuccess();
321
-
322
- await TtyWriter.sendKey(location, "1");
323
-
324
- expect(mockedExecFile).toHaveBeenCalledTimes(1);
325
- expect(mockedExecFile).toHaveBeenCalledWith(
326
- "tmux",
327
- ["send-keys", "-t", "main:0.1", "1"],
328
- expect.any(Function),
329
- );
330
- });
331
-
332
- it("passes through named keys like Enter", async () => {
333
- mockExecFileSuccess();
334
- await TtyWriter.sendKey(location, "Enter");
335
- expect(mockedExecFile).toHaveBeenCalledWith(
336
- "tmux",
337
- ["send-keys", "-t", "main:0.1", "Enter"],
338
- expect.any(Function),
339
- );
340
- });
341
-
342
- it('translates Esc byte (\\x1b) to the named "Escape" key', async () => {
343
- mockExecFileSuccess();
344
- await TtyWriter.sendKey(location, "\x1b");
345
- expect(mockedExecFile).toHaveBeenCalledWith(
346
- "tmux",
347
- ["send-keys", "-t", "main:0.1", "Escape"],
348
- expect.any(Function),
349
- );
350
- });
351
- });
352
-
353
- describe("sendKey — WezTerm", () => {
354
- const location: TerminalLocation = {
355
- type: TerminalType.WEZTERM,
356
- identifier: "7",
357
- tty: "/dev/ttys030",
358
- };
359
-
360
- it("uses wezterm cli send-text --no-paste to deliver a raw key", async () => {
361
- mockExecFileSuccess();
362
-
363
- await TtyWriter.sendKey(location, "1");
364
-
365
- expect(mockedExecFile).toHaveBeenCalledTimes(1);
366
- expect(mockedExecFile).toHaveBeenCalledWith(
367
- "wezterm",
368
- ["cli", "send-text", "--pane-id", "7", "--no-paste", "1"],
369
- expect.any(Function),
370
- );
371
- });
372
- });
373
-
374
- describe("sendKey — iTerm2", () => {
375
- const location: TerminalLocation = {
376
- type: TerminalType.ITERM2,
377
- identifier: "/dev/ttys030",
378
- tty: "/dev/ttys030",
379
- };
380
-
381
- it("uses System Events keystroke after activating the iTerm2 session", async () => {
382
- mockExecFileSuccess("ok");
383
-
384
- await TtyWriter.sendKey(location, "2");
385
-
386
- const args = (mockedExecFile.mock.calls[0] as unknown[])[1] as string[];
387
- const script = args[1];
388
- expect(script).toContain('tell application "iTerm"');
389
- expect(script).toContain('tell application "System Events" to keystroke "2"');
390
- expect(mockedExecFile).toHaveBeenCalledTimes(1);
391
- });
392
-
393
- it("translates Esc byte (\\x1b) to AppleScript `key code 53`", async () => {
394
- mockExecFileSuccess("ok");
395
- await TtyWriter.sendKey(location, "\x1b");
396
- const args = (mockedExecFile.mock.calls[0] as unknown[])[1] as string[];
397
- const script = args[1];
398
- expect(script).toContain('tell application "System Events" to key code 53');
399
- expect(script).not.toContain("keystroke");
400
- });
401
-
402
- it("throws when session not found", async () => {
403
- mockExecFileSuccess("not_found");
404
- await expect(TtyWriter.sendKey(location, "1")).rejects.toThrow("iTerm2 session not found");
405
- });
406
- });
407
-
408
- describe("sendKey — Terminal.app", () => {
409
- const location: TerminalLocation = {
410
- type: TerminalType.TERMINAL_APP,
411
- identifier: "/dev/ttys030",
412
- tty: "/dev/ttys030",
413
- };
414
-
415
- it("uses System Events keystroke after selecting the Terminal.app tab", async () => {
416
- mockExecFileSuccess("ok");
417
-
418
- await TtyWriter.sendKey(location, "3");
419
-
420
- const args = (mockedExecFile.mock.calls[0] as unknown[])[1] as string[];
421
- const script = args[1];
422
- expect(script).toContain('tell application "Terminal"');
423
- expect(script).toContain('tell application "System Events" to keystroke "3"');
424
- expect(mockedExecFile).toHaveBeenCalledTimes(1);
425
- });
426
-
427
- it("translates Esc byte (\\x1b) to AppleScript `key code 53`", async () => {
428
- mockExecFileSuccess("ok");
429
- await TtyWriter.sendKey(location, "\x1b");
430
- const args = (mockedExecFile.mock.calls[0] as unknown[])[1] as string[];
431
- const script = args[1];
432
- expect(script).toContain('tell application "System Events" to key code 53');
433
- expect(script).not.toContain("keystroke");
434
- });
435
-
436
- it("throws when tab not found", async () => {
437
- mockExecFileSuccess("not_found");
438
- await expect(TtyWriter.sendKey(location, "1")).rejects.toThrow("Terminal.app tab not found");
439
- });
440
- });
441
-
442
- describe("sendKey — unsupported terminal", () => {
443
- it("throws for unknown terminal type", async () => {
444
- const location: TerminalLocation = {
445
- type: TerminalType.UNKNOWN,
446
- identifier: "",
447
- tty: "/dev/ttys030",
448
- };
449
- await expect(TtyWriter.sendKey(location, "1")).rejects.toThrow(
450
- "Cannot send key: unsupported terminal type",
451
- );
452
- });
453
- });
454
- });