@ai-devkit/agent-manager 0.31.0 → 0.33.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 (519) hide show
  1. package/dist/AgentManager.d.ts +3 -3
  2. package/dist/AgentManager.d.ts.map +1 -1
  3. package/dist/AgentManager.js +80 -79
  4. package/dist/AgentManager.js.map +1 -1
  5. package/dist/__tests__/AgentManager.test.js +413 -388
  6. package/dist/__tests__/AgentManager.test.js.map +1 -1
  7. package/dist/__tests__/adapters/ClaudeCodeAdapter.test.js +642 -642
  8. package/dist/__tests__/adapters/ClaudeCodeAdapter.test.js.map +1 -1
  9. package/dist/__tests__/adapters/CodexAdapter.test.js +322 -2321
  10. package/dist/__tests__/adapters/CodexAdapter.test.js.map +1 -1
  11. package/dist/__tests__/adapters/CopilotAdapter.test.js +254 -248
  12. package/dist/__tests__/adapters/CopilotAdapter.test.js.map +1 -1
  13. package/dist/__tests__/adapters/GeminiCliAdapter.test.js +564 -558
  14. package/dist/__tests__/adapters/GeminiCliAdapter.test.js.map +1 -1
  15. package/dist/__tests__/adapters/GrokCliAdapter.test.js +114 -114
  16. package/dist/__tests__/adapters/GrokCliAdapter.test.js.map +1 -1
  17. package/dist/__tests__/adapters/OpenCodeAdapter.test.js +169 -169
  18. package/dist/__tests__/adapters/OpenCodeAdapter.test.js.map +1 -1
  19. package/dist/__tests__/capacity/codex.test.js +93 -93
  20. package/dist/__tests__/capacity/codex.test.js.map +1 -1
  21. package/dist/__tests__/capacity/index.test.js +17 -17
  22. package/dist/__tests__/capacity/index.test.js.map +1 -1
  23. package/dist/__tests__/durable/CodexCliProbe.test.js +60 -60
  24. package/dist/__tests__/durable/CodexCliProbe.test.js.map +1 -1
  25. package/dist/__tests__/durable/CodexDurableAgentRepository.test.js +28 -28
  26. package/dist/__tests__/durable/CodexDurableAgentRepository.test.js.map +1 -1
  27. package/dist/__tests__/durable/CodexPrintAgent.integration.test.js +30 -30
  28. package/dist/__tests__/durable/CodexPrintAgent.integration.test.js.map +1 -1
  29. package/dist/__tests__/durable/CodexPrintAgentService.test.js +71 -71
  30. package/dist/__tests__/durable/CodexPrintAgentService.test.js.map +1 -1
  31. package/dist/__tests__/durable/CodexPrintRunner.test.js +125 -125
  32. package/dist/__tests__/durable/CodexPrintRunner.test.js.map +1 -1
  33. package/dist/__tests__/print/ClaudeCliProbe.test.js +20 -20
  34. package/dist/__tests__/print/ClaudeCliProbe.test.js.map +1 -1
  35. package/dist/__tests__/print/ClaudePrintAgent.integration.test.js +20 -20
  36. package/dist/__tests__/print/ClaudePrintAgent.integration.test.js.map +1 -1
  37. package/dist/__tests__/print/ClaudePrintAgentService.test.js +58 -58
  38. package/dist/__tests__/print/ClaudePrintAgentService.test.js.map +1 -1
  39. package/dist/__tests__/print/ClaudePrintRunner.test.js +55 -55
  40. package/dist/__tests__/print/ClaudePrintRunner.test.js.map +1 -1
  41. package/dist/__tests__/print/DurableAgent.test.js +9 -9
  42. package/dist/__tests__/print/DurableAgent.test.js.map +1 -1
  43. package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js +40 -40
  44. package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js.map +1 -1
  45. package/dist/__tests__/print/DurableAgentRepository.test.js +66 -66
  46. package/dist/__tests__/print/DurableAgentRepository.test.js.map +1 -1
  47. package/dist/__tests__/providers/claude/ClaudeAgentMapper.test.js +34 -34
  48. package/dist/__tests__/providers/claude/ClaudeAgentMapper.test.js.map +1 -1
  49. package/dist/__tests__/providers/claude/ClaudeSessionLocator.test.js +132 -132
  50. package/dist/__tests__/providers/claude/ClaudeSessionLocator.test.js.map +1 -1
  51. package/dist/__tests__/providers/codex/CodexSessionLocator.test.js +194 -0
  52. package/dist/__tests__/providers/codex/CodexSessionLocator.test.js.map +1 -0
  53. package/dist/__tests__/providers/codex/CodexSessionMapping.test.js +86 -0
  54. package/dist/__tests__/providers/codex/CodexSessionMapping.test.js.map +1 -0
  55. package/dist/__tests__/providers/codex/CodexSessionParser.test.js +254 -0
  56. package/dist/__tests__/providers/codex/CodexSessionParser.test.js.map +1 -0
  57. package/dist/__tests__/providers/pi/PiAdapter.test.js +337 -0
  58. package/dist/__tests__/providers/pi/PiAdapter.test.js.map +1 -0
  59. package/dist/__tests__/providers/pi/PiSessionParser.test.js +246 -0
  60. package/dist/__tests__/providers/pi/PiSessionParser.test.js.map +1 -0
  61. package/dist/__tests__/providers/pi/PiSessionTracker.test.js +108 -0
  62. package/dist/__tests__/providers/pi/PiSessionTracker.test.js.map +1 -0
  63. package/dist/__tests__/providers/pi/durable/PiCliProbe.test.js +33 -33
  64. package/dist/__tests__/providers/pi/durable/PiCliProbe.test.js.map +1 -1
  65. package/dist/__tests__/providers/pi/durable/PiDurableAgentRepository.test.js +16 -16
  66. package/dist/__tests__/providers/pi/durable/PiDurableAgentRepository.test.js.map +1 -1
  67. package/dist/__tests__/providers/pi/durable/PiPrintAgentService.test.js +52 -52
  68. package/dist/__tests__/providers/pi/durable/PiPrintAgentService.test.js.map +1 -1
  69. package/dist/__tests__/providers/pi/durable/PiPrintProtocol.test.js +44 -44
  70. package/dist/__tests__/providers/pi/durable/PiPrintProtocol.test.js.map +1 -1
  71. package/dist/__tests__/providers/pi/durable/PiPrintRunner.test.js +126 -126
  72. package/dist/__tests__/providers/pi/durable/PiPrintRunner.test.js.map +1 -1
  73. package/dist/__tests__/providers/pi/durable/PiStreamParser.test.js +14 -14
  74. package/dist/__tests__/providers/pi/durable/PiStreamParser.test.js.map +1 -1
  75. package/dist/__tests__/readiness/AgentReadiness.test.js +301 -0
  76. package/dist/__tests__/readiness/AgentReadiness.test.js.map +1 -0
  77. package/dist/__tests__/runtime/AgentRuntime.test.js +13 -0
  78. package/dist/__tests__/runtime/AgentRuntime.test.js.map +1 -0
  79. package/dist/__tests__/runtime/HerdrAgentRuntime.test.js +452 -0
  80. package/dist/__tests__/runtime/HerdrAgentRuntime.test.js.map +1 -0
  81. package/dist/__tests__/runtime/ManagedAgentRuntime.test.js +588 -0
  82. package/dist/__tests__/runtime/ManagedAgentRuntime.test.js.map +1 -0
  83. package/dist/__tests__/terminal/TerminalFocusManager.test.js +100 -100
  84. package/dist/__tests__/terminal/TerminalFocusManager.test.js.map +1 -1
  85. package/dist/__tests__/terminal/TmuxManager.test.js +101 -101
  86. package/dist/__tests__/terminal/TmuxManager.test.js.map +1 -1
  87. package/dist/__tests__/terminal/TtyWriter.test.js +185 -185
  88. package/dist/__tests__/terminal/TtyWriter.test.js.map +1 -1
  89. package/dist/__tests__/utils/AgentRegistry.test.js +335 -217
  90. package/dist/__tests__/utils/AgentRegistry.test.js.map +1 -1
  91. package/dist/__tests__/utils/ClaudeSessionParser.test.js +103 -101
  92. package/dist/__tests__/utils/ClaudeSessionParser.test.js.map +1 -1
  93. package/dist/__tests__/utils/agent-requests.test.js +43 -43
  94. package/dist/__tests__/utils/agent-requests.test.js.map +1 -1
  95. package/dist/__tests__/utils/agents.test.js +17 -17
  96. package/dist/__tests__/utils/agents.test.js.map +1 -1
  97. package/dist/__tests__/utils/matching.test.js +92 -92
  98. package/dist/__tests__/utils/matching.test.js.map +1 -1
  99. package/dist/__tests__/utils/process.test.js +108 -108
  100. package/dist/__tests__/utils/process.test.js.map +1 -1
  101. package/dist/__tests__/utils/session.test.js +53 -53
  102. package/dist/__tests__/utils/session.test.js.map +1 -1
  103. package/dist/adapters/AgentAdapter.d.ts +2 -2
  104. package/dist/adapters/AgentAdapter.d.ts.map +1 -1
  105. package/dist/adapters/AgentAdapter.js +1 -1
  106. package/dist/adapters/AgentAdapter.js.map +1 -1
  107. package/dist/adapters/CopilotAdapter.d.ts +2 -2
  108. package/dist/adapters/CopilotAdapter.d.ts.map +1 -1
  109. package/dist/adapters/CopilotAdapter.js +51 -51
  110. package/dist/adapters/CopilotAdapter.js.map +1 -1
  111. package/dist/adapters/GeminiCliAdapter.d.ts +2 -2
  112. package/dist/adapters/GeminiCliAdapter.d.ts.map +1 -1
  113. package/dist/adapters/GeminiCliAdapter.js +86 -86
  114. package/dist/adapters/GeminiCliAdapter.js.map +1 -1
  115. package/dist/adapters/GrokCliAdapter.d.ts +1 -1
  116. package/dist/adapters/GrokCliAdapter.d.ts.map +1 -1
  117. package/dist/adapters/GrokCliAdapter.js +80 -80
  118. package/dist/adapters/GrokCliAdapter.js.map +1 -1
  119. package/dist/adapters/OpenCodeAdapter.d.ts +1 -1
  120. package/dist/adapters/OpenCodeAdapter.d.ts.map +1 -1
  121. package/dist/adapters/OpenCodeAdapter.js +37 -36
  122. package/dist/adapters/OpenCodeAdapter.js.map +1 -1
  123. package/dist/adapters/index.d.ts +9 -9
  124. package/dist/adapters/index.d.ts.map +1 -1
  125. package/dist/adapters/index.js +8 -8
  126. package/dist/adapters/index.js.map +1 -1
  127. package/dist/capacity/codex.d.ts +3 -3
  128. package/dist/capacity/codex.d.ts.map +1 -1
  129. package/dist/capacity/codex.js +57 -57
  130. package/dist/capacity/codex.js.map +1 -1
  131. package/dist/capacity/index.d.ts +3 -3
  132. package/dist/capacity/index.d.ts.map +1 -1
  133. package/dist/capacity/index.js +8 -8
  134. package/dist/capacity/index.js.map +1 -1
  135. package/dist/capacity/types.d.ts +1 -1
  136. package/dist/capacity/types.js.map +1 -1
  137. package/dist/database/connection.d.ts +1 -1
  138. package/dist/database/connection.d.ts.map +1 -1
  139. package/dist/database/connection.js +15 -15
  140. package/dist/database/connection.js.map +1 -1
  141. package/dist/database/index.d.ts +3 -3
  142. package/dist/database/index.d.ts.map +1 -1
  143. package/dist/database/index.js +2 -2
  144. package/dist/database/index.js.map +1 -1
  145. package/dist/database/migrations/005_agent_runtime.sql +2 -0
  146. package/dist/database/schema.d.ts +1 -1
  147. package/dist/database/schema.d.ts.map +1 -1
  148. package/dist/database/schema.js +7 -7
  149. package/dist/database/schema.js.map +1 -1
  150. package/dist/durable/DurableAgent.d.ts +9 -9
  151. package/dist/durable/DurableAgent.d.ts.map +1 -1
  152. package/dist/durable/DurableAgent.js +16 -16
  153. package/dist/durable/DurableAgent.js.map +1 -1
  154. package/dist/durable/DurableAgentRepository.d.ts +4 -4
  155. package/dist/durable/DurableAgentRepository.d.ts.map +1 -1
  156. package/dist/durable/DurableAgentRepository.js +49 -48
  157. package/dist/durable/DurableAgentRepository.js.map +1 -1
  158. package/dist/durable/process.d.ts +1 -1
  159. package/dist/durable/process.d.ts.map +1 -1
  160. package/dist/durable/process.js +14 -14
  161. package/dist/durable/process.js.map +1 -1
  162. package/dist/durable/run.d.ts +2 -2
  163. package/dist/durable/run.d.ts.map +1 -1
  164. package/dist/durable/run.js +6 -6
  165. package/dist/durable/run.js.map +1 -1
  166. package/dist/durable/utils.d.ts +1 -1
  167. package/dist/durable/utils.d.ts.map +1 -1
  168. package/dist/durable/utils.js +4 -4
  169. package/dist/durable/utils.js.map +1 -1
  170. package/dist/index.d.ts +46 -41
  171. package/dist/index.d.ts.map +1 -1
  172. package/dist/index.js +27 -25
  173. package/dist/index.js.map +1 -1
  174. package/dist/providers/claude/ClaudeAgentMapper.d.ts +4 -4
  175. package/dist/providers/claude/ClaudeAgentMapper.d.ts.map +1 -1
  176. package/dist/providers/claude/ClaudeAgentMapper.js +10 -10
  177. package/dist/providers/claude/ClaudeAgentMapper.js.map +1 -1
  178. package/dist/providers/claude/ClaudeCodeAdapter.d.ts +1 -1
  179. package/dist/providers/claude/ClaudeCodeAdapter.d.ts.map +1 -1
  180. package/dist/providers/claude/ClaudeCodeAdapter.js +14 -14
  181. package/dist/providers/claude/ClaudeCodeAdapter.js.map +1 -1
  182. package/dist/providers/claude/ClaudeSessionLocator.d.ts +4 -4
  183. package/dist/providers/claude/ClaudeSessionLocator.d.ts.map +1 -1
  184. package/dist/providers/claude/ClaudeSessionLocator.js +79 -79
  185. package/dist/providers/claude/ClaudeSessionLocator.js.map +1 -1
  186. package/dist/providers/claude/ClaudeSessionParser.d.ts +2 -2
  187. package/dist/providers/claude/ClaudeSessionParser.d.ts.map +1 -1
  188. package/dist/providers/claude/ClaudeSessionParser.js +99 -99
  189. package/dist/providers/claude/ClaudeSessionParser.js.map +1 -1
  190. package/dist/providers/claude/durable/ClaudeCliProbe.d.ts.map +1 -1
  191. package/dist/providers/claude/durable/ClaudeCliProbe.js +16 -16
  192. package/dist/providers/claude/durable/ClaudeCliProbe.js.map +1 -1
  193. package/dist/providers/claude/durable/ClaudePrintAgentService.d.ts +5 -5
  194. package/dist/providers/claude/durable/ClaudePrintAgentService.d.ts.map +1 -1
  195. package/dist/providers/claude/durable/ClaudePrintAgentService.js +10 -10
  196. package/dist/providers/claude/durable/ClaudePrintAgentService.js.map +1 -1
  197. package/dist/providers/claude/durable/ClaudePrintRunner.d.ts +4 -4
  198. package/dist/providers/claude/durable/ClaudePrintRunner.d.ts.map +1 -1
  199. package/dist/providers/claude/durable/ClaudePrintRunner.js +18 -18
  200. package/dist/providers/claude/durable/ClaudePrintRunner.js.map +1 -1
  201. package/dist/providers/claude/durable/ClaudeStreamParser.d.ts +2 -2
  202. package/dist/providers/claude/durable/ClaudeStreamParser.d.ts.map +1 -1
  203. package/dist/providers/claude/durable/ClaudeStreamParser.js +17 -17
  204. package/dist/providers/claude/durable/ClaudeStreamParser.js.map +1 -1
  205. package/dist/providers/codex/CodexAdapter.d.ts +27 -0
  206. package/dist/providers/codex/CodexAdapter.d.ts.map +1 -0
  207. package/dist/providers/codex/CodexAdapter.js +162 -0
  208. package/dist/providers/codex/CodexAdapter.js.map +1 -0
  209. package/dist/providers/codex/CodexAgentMapper.d.ts +9 -0
  210. package/dist/providers/codex/CodexAgentMapper.d.ts.map +1 -0
  211. package/dist/providers/codex/CodexAgentMapper.js +35 -0
  212. package/dist/providers/codex/CodexAgentMapper.js.map +1 -0
  213. package/dist/providers/codex/CodexSessionLocator.d.ts +44 -0
  214. package/dist/providers/codex/CodexSessionLocator.d.ts.map +1 -0
  215. package/dist/providers/codex/CodexSessionLocator.js +207 -0
  216. package/dist/providers/codex/CodexSessionLocator.js.map +1 -0
  217. package/dist/providers/codex/CodexSessionMapping.d.ts +23 -0
  218. package/dist/providers/codex/CodexSessionMapping.d.ts.map +1 -0
  219. package/dist/providers/codex/CodexSessionMapping.js +68 -0
  220. package/dist/providers/codex/CodexSessionMapping.js.map +1 -0
  221. package/dist/providers/codex/CodexSessionParser.d.ts +58 -0
  222. package/dist/providers/codex/CodexSessionParser.d.ts.map +1 -0
  223. package/dist/providers/codex/CodexSessionParser.js +262 -0
  224. package/dist/providers/codex/CodexSessionParser.js.map +1 -0
  225. package/dist/providers/codex/durable/CodexCliProbe.d.ts.map +1 -1
  226. package/dist/providers/codex/durable/CodexCliProbe.js +22 -22
  227. package/dist/providers/codex/durable/CodexCliProbe.js.map +1 -1
  228. package/dist/providers/codex/durable/CodexPrintAgentService.d.ts +6 -6
  229. package/dist/providers/codex/durable/CodexPrintAgentService.d.ts.map +1 -1
  230. package/dist/providers/codex/durable/CodexPrintAgentService.js +10 -10
  231. package/dist/providers/codex/durable/CodexPrintAgentService.js.map +1 -1
  232. package/dist/providers/codex/durable/CodexPrintRunner.d.ts +4 -4
  233. package/dist/providers/codex/durable/CodexPrintRunner.d.ts.map +1 -1
  234. package/dist/providers/codex/durable/CodexPrintRunner.js +20 -20
  235. package/dist/providers/codex/durable/CodexPrintRunner.js.map +1 -1
  236. package/dist/providers/codex/durable/CodexStreamParser.d.ts +2 -2
  237. package/dist/providers/codex/durable/CodexStreamParser.d.ts.map +1 -1
  238. package/dist/providers/codex/durable/CodexStreamParser.js +21 -21
  239. package/dist/providers/codex/durable/CodexStreamParser.js.map +1 -1
  240. package/dist/providers/pi/PiAdapter.d.ts +28 -0
  241. package/dist/providers/pi/PiAdapter.d.ts.map +1 -0
  242. package/dist/providers/pi/PiAdapter.js +153 -0
  243. package/dist/providers/pi/PiAdapter.js.map +1 -0
  244. package/dist/providers/pi/PiAgentMapper.d.ts +9 -0
  245. package/dist/providers/pi/PiAgentMapper.d.ts.map +1 -0
  246. package/dist/providers/pi/PiAgentMapper.js +37 -0
  247. package/dist/providers/pi/PiAgentMapper.js.map +1 -0
  248. package/dist/providers/pi/PiSessionLocator.d.ts +23 -0
  249. package/dist/providers/pi/PiSessionLocator.d.ts.map +1 -0
  250. package/dist/providers/pi/PiSessionLocator.js +79 -0
  251. package/dist/providers/pi/PiSessionLocator.js.map +1 -0
  252. package/dist/providers/pi/PiSessionParser.d.ts +36 -0
  253. package/dist/providers/pi/PiSessionParser.d.ts.map +1 -0
  254. package/dist/providers/pi/PiSessionParser.js +191 -0
  255. package/dist/providers/pi/PiSessionParser.js.map +1 -0
  256. package/dist/providers/pi/PiSessionTracker.d.ts +23 -0
  257. package/dist/providers/pi/PiSessionTracker.d.ts.map +1 -0
  258. package/dist/providers/pi/PiSessionTracker.js +69 -0
  259. package/dist/providers/pi/PiSessionTracker.js.map +1 -0
  260. package/dist/providers/pi/durable/PiCliProbe.d.ts.map +1 -1
  261. package/dist/providers/pi/durable/PiCliProbe.js +15 -15
  262. package/dist/providers/pi/durable/PiCliProbe.js.map +1 -1
  263. package/dist/providers/pi/durable/PiPrintAgentService.d.ts +6 -6
  264. package/dist/providers/pi/durable/PiPrintAgentService.d.ts.map +1 -1
  265. package/dist/providers/pi/durable/PiPrintAgentService.js +10 -10
  266. package/dist/providers/pi/durable/PiPrintAgentService.js.map +1 -1
  267. package/dist/providers/pi/durable/PiPrintProtocol.d.ts.map +1 -1
  268. package/dist/providers/pi/durable/PiPrintProtocol.js +18 -18
  269. package/dist/providers/pi/durable/PiPrintProtocol.js.map +1 -1
  270. package/dist/providers/pi/durable/PiPrintRunner.d.ts +4 -4
  271. package/dist/providers/pi/durable/PiPrintRunner.d.ts.map +1 -1
  272. package/dist/providers/pi/durable/PiPrintRunner.js +15 -15
  273. package/dist/providers/pi/durable/PiPrintRunner.js.map +1 -1
  274. package/dist/providers/pi/durable/PiStreamParser.d.ts +1 -1
  275. package/dist/providers/pi/durable/PiStreamParser.d.ts.map +1 -1
  276. package/dist/providers/pi/durable/PiStreamParser.js +16 -16
  277. package/dist/providers/pi/durable/PiStreamParser.js.map +1 -1
  278. package/dist/readiness/AgentReadiness.d.ts +67 -0
  279. package/dist/readiness/AgentReadiness.d.ts.map +1 -0
  280. package/dist/readiness/AgentReadiness.js +614 -0
  281. package/dist/readiness/AgentReadiness.js.map +1 -0
  282. package/dist/runtime/ManagedAgentRuntime.d.ts +69 -0
  283. package/dist/runtime/ManagedAgentRuntime.d.ts.map +1 -0
  284. package/dist/runtime/ManagedAgentRuntime.js +156 -0
  285. package/dist/runtime/ManagedAgentRuntime.js.map +1 -0
  286. package/dist/runtime/RuntimeFactory.d.ts +4 -0
  287. package/dist/runtime/RuntimeFactory.d.ts.map +1 -0
  288. package/dist/runtime/RuntimeFactory.js +11 -0
  289. package/dist/runtime/RuntimeFactory.js.map +1 -0
  290. package/dist/runtime/errors.d.ts +27 -0
  291. package/dist/runtime/errors.d.ts.map +1 -0
  292. package/dist/runtime/errors.js +42 -0
  293. package/dist/runtime/errors.js.map +1 -0
  294. package/dist/runtime/herdr/HerdrAgentRuntime.d.ts +31 -0
  295. package/dist/runtime/herdr/HerdrAgentRuntime.d.ts.map +1 -0
  296. package/dist/runtime/herdr/HerdrAgentRuntime.js +184 -0
  297. package/dist/runtime/herdr/HerdrAgentRuntime.js.map +1 -0
  298. package/dist/runtime/herdr/HerdrCliClient.d.ts +13 -0
  299. package/dist/runtime/herdr/HerdrCliClient.d.ts.map +1 -0
  300. package/dist/runtime/herdr/HerdrCliClient.js +60 -0
  301. package/dist/runtime/herdr/HerdrCliClient.js.map +1 -0
  302. package/dist/runtime/herdr/HerdrErrors.d.ts +7 -0
  303. package/dist/runtime/herdr/HerdrErrors.d.ts.map +1 -0
  304. package/dist/runtime/herdr/HerdrErrors.js +10 -0
  305. package/dist/runtime/herdr/HerdrErrors.js.map +1 -0
  306. package/dist/runtime/herdr/HerdrResponseParsers.d.ts +14 -0
  307. package/dist/runtime/herdr/HerdrResponseParsers.d.ts.map +1 -0
  308. package/dist/runtime/herdr/HerdrResponseParsers.js +96 -0
  309. package/dist/runtime/herdr/HerdrResponseParsers.js.map +1 -0
  310. package/dist/runtime/herdr/HerdrRuntimeRef.d.ts +9 -0
  311. package/dist/runtime/herdr/HerdrRuntimeRef.d.ts.map +1 -0
  312. package/dist/runtime/herdr/HerdrRuntimeRef.js +33 -0
  313. package/dist/runtime/herdr/HerdrRuntimeRef.js.map +1 -0
  314. package/dist/runtime/tmux/PidPolling.d.ts +5 -0
  315. package/dist/runtime/tmux/PidPolling.d.ts.map +1 -0
  316. package/dist/runtime/tmux/PidPolling.js +24 -0
  317. package/dist/runtime/tmux/PidPolling.js.map +1 -0
  318. package/dist/runtime/tmux/TmuxAgentRuntime.d.ts +17 -0
  319. package/dist/runtime/tmux/TmuxAgentRuntime.d.ts.map +1 -0
  320. package/dist/runtime/tmux/TmuxAgentRuntime.js +80 -0
  321. package/dist/runtime/tmux/TmuxAgentRuntime.js.map +1 -0
  322. package/dist/runtime/tmux/TmuxRuntimeRef.d.ts +5 -0
  323. package/dist/runtime/tmux/TmuxRuntimeRef.d.ts.map +1 -0
  324. package/dist/runtime/tmux/TmuxRuntimeRef.js +9 -0
  325. package/dist/runtime/tmux/TmuxRuntimeRef.js.map +1 -0
  326. package/dist/runtime/types.d.ts +54 -0
  327. package/dist/runtime/types.d.ts.map +1 -0
  328. package/dist/runtime/types.js +3 -0
  329. package/dist/runtime/types.js.map +1 -0
  330. package/dist/terminal/TerminalFocusManager.d.ts.map +1 -1
  331. package/dist/terminal/TerminalFocusManager.js +50 -50
  332. package/dist/terminal/TerminalFocusManager.js.map +1 -1
  333. package/dist/terminal/TmuxManager.d.ts.map +1 -1
  334. package/dist/terminal/TmuxManager.js +47 -47
  335. package/dist/terminal/TmuxManager.js.map +1 -1
  336. package/dist/terminal/TtyWriter.d.ts +1 -1
  337. package/dist/terminal/TtyWriter.d.ts.map +1 -1
  338. package/dist/terminal/TtyWriter.js +89 -89
  339. package/dist/terminal/TtyWriter.js.map +1 -1
  340. package/dist/terminal/index.d.ts +4 -4
  341. package/dist/terminal/index.js +3 -3
  342. package/dist/terminal/index.js.map +1 -1
  343. package/dist/utils/AgentRegistry.d.ts +10 -2
  344. package/dist/utils/AgentRegistry.d.ts.map +1 -1
  345. package/dist/utils/AgentRegistry.js +57 -24
  346. package/dist/utils/AgentRegistry.js.map +1 -1
  347. package/dist/utils/agent-requests.d.ts.map +1 -1
  348. package/dist/utils/agent-requests.js +5 -5
  349. package/dist/utils/agent-requests.js.map +1 -1
  350. package/dist/utils/agents.d.ts +2 -2
  351. package/dist/utils/agents.d.ts.map +1 -1
  352. package/dist/utils/agents.js +15 -15
  353. package/dist/utils/agents.js.map +1 -1
  354. package/dist/utils/applescript.js +1 -1
  355. package/dist/utils/applescript.js.map +1 -1
  356. package/dist/utils/index.d.ts +6 -6
  357. package/dist/utils/index.d.ts.map +1 -1
  358. package/dist/utils/index.js +4 -4
  359. package/dist/utils/index.js.map +1 -1
  360. package/dist/utils/matching.d.ts +2 -2
  361. package/dist/utils/matching.d.ts.map +1 -1
  362. package/dist/utils/matching.js +4 -4
  363. package/dist/utils/matching.js.map +1 -1
  364. package/dist/utils/process.d.ts +1 -1
  365. package/dist/utils/process.d.ts.map +1 -1
  366. package/dist/utils/process.js +74 -74
  367. package/dist/utils/process.js.map +1 -1
  368. package/dist/utils/session.d.ts +1 -1
  369. package/dist/utils/session.d.ts.map +1 -1
  370. package/dist/utils/session.js +7 -7
  371. package/dist/utils/session.js.map +1 -1
  372. package/dist/utils/sortAgents.d.ts +2 -2
  373. package/dist/utils/sortAgents.d.ts.map +1 -1
  374. package/dist/utils/sortAgents.js +5 -5
  375. package/dist/utils/sortAgents.js.map +1 -1
  376. package/package.json +18 -19
  377. package/src/AgentManager.ts +283 -281
  378. package/src/__tests__/AgentManager.test.ts +917 -907
  379. package/src/__tests__/adapters/ClaudeCodeAdapter.test.ts +1657 -1368
  380. package/src/__tests__/adapters/CodexAdapter.test.ts +365 -1698
  381. package/src/__tests__/adapters/CopilotAdapter.test.ts +576 -481
  382. package/src/__tests__/adapters/GeminiCliAdapter.test.ts +1189 -1157
  383. package/src/__tests__/adapters/GrokCliAdapter.test.ts +325 -272
  384. package/src/__tests__/adapters/OpenCodeAdapter.test.ts +510 -455
  385. package/src/__tests__/capacity/codex.test.ts +178 -91
  386. package/src/__tests__/capacity/index.test.ts +27 -18
  387. package/src/__tests__/durable/CodexCliProbe.test.ts +75 -53
  388. package/src/__tests__/durable/CodexDurableAgentRepository.test.ts +51 -40
  389. package/src/__tests__/durable/CodexPrintAgent.integration.test.ts +89 -64
  390. package/src/__tests__/durable/CodexPrintAgentService.test.ts +196 -118
  391. package/src/__tests__/durable/CodexPrintRunner.test.ts +282 -162
  392. package/src/__tests__/fixtures/fake-claude.cjs +20 -13
  393. package/src/__tests__/fixtures/fake-codex.cjs +41 -30
  394. package/src/__tests__/print/ClaudeCliProbe.test.ts +27 -21
  395. package/src/__tests__/print/ClaudePrintAgent.integration.test.ts +48 -40
  396. package/src/__tests__/print/ClaudePrintAgentService.test.ts +118 -67
  397. package/src/__tests__/print/ClaudePrintRunner.test.ts +136 -83
  398. package/src/__tests__/print/DurableAgent.test.ts +19 -16
  399. package/src/__tests__/print/DurableAgentRepository.sqlite.test.ts +109 -86
  400. package/src/__tests__/print/DurableAgentRepository.test.ts +170 -137
  401. package/src/__tests__/providers/claude/ClaudeAgentMapper.test.ts +65 -65
  402. package/src/__tests__/providers/claude/ClaudeSessionLocator.test.ts +400 -377
  403. package/src/__tests__/providers/codex/CodexSessionLocator.test.ts +182 -0
  404. package/src/__tests__/providers/codex/CodexSessionMapping.test.ts +63 -0
  405. package/src/__tests__/providers/codex/CodexSessionParser.test.ts +192 -0
  406. package/src/__tests__/providers/pi/PiAdapter.test.ts +310 -0
  407. package/src/__tests__/providers/pi/PiSessionParser.test.ts +190 -0
  408. package/src/__tests__/providers/pi/PiSessionTracker.test.ts +79 -0
  409. package/src/__tests__/providers/pi/durable/PiCliProbe.test.ts +48 -32
  410. package/src/__tests__/providers/pi/durable/PiDurableAgentRepository.test.ts +24 -23
  411. package/src/__tests__/providers/pi/durable/PiPrintAgentService.test.ts +131 -59
  412. package/src/__tests__/providers/pi/durable/PiPrintProtocol.test.ts +66 -28
  413. package/src/__tests__/providers/pi/durable/PiPrintRunner.test.ts +236 -90
  414. package/src/__tests__/providers/pi/durable/PiStreamParser.test.ts +20 -18
  415. package/src/__tests__/readiness/AgentReadiness.test.ts +242 -0
  416. package/src/__tests__/runtime/AgentRuntime.test.ts +8 -0
  417. package/src/__tests__/runtime/HerdrAgentRuntime.test.ts +358 -0
  418. package/src/__tests__/runtime/ManagedAgentRuntime.test.ts +555 -0
  419. package/src/__tests__/terminal/TerminalFocusManager.test.ts +254 -253
  420. package/src/__tests__/terminal/TmuxManager.test.ts +157 -157
  421. package/src/__tests__/terminal/TtyWriter.test.ts +423 -419
  422. package/src/__tests__/utils/AgentRegistry.test.ts +506 -402
  423. package/src/__tests__/utils/ClaudeSessionParser.test.ts +276 -242
  424. package/src/__tests__/utils/agent-requests.test.ts +76 -56
  425. package/src/__tests__/utils/agents.test.ts +20 -20
  426. package/src/__tests__/utils/matching.test.ts +206 -171
  427. package/src/__tests__/utils/process.test.ts +276 -262
  428. package/src/__tests__/utils/session.test.ts +133 -139
  429. package/src/adapters/AgentAdapter.ts +134 -126
  430. package/src/adapters/CopilotAdapter.ts +405 -395
  431. package/src/adapters/GeminiCliAdapter.ts +598 -600
  432. package/src/adapters/GrokCliAdapter.ts +353 -342
  433. package/src/adapters/OpenCodeAdapter.ts +285 -259
  434. package/src/adapters/index.ts +15 -9
  435. package/src/capacity/codex.ts +137 -84
  436. package/src/capacity/index.ts +18 -13
  437. package/src/capacity/types.ts +1 -1
  438. package/src/database/connection.ts +73 -68
  439. package/src/database/index.ts +6 -6
  440. package/src/database/migrations/005_agent_runtime.sql +2 -0
  441. package/src/database/schema.ts +40 -38
  442. package/src/durable/DurableAgent.ts +85 -85
  443. package/src/durable/DurableAgentRepository.ts +409 -260
  444. package/src/durable/process.ts +22 -21
  445. package/src/durable/run.ts +61 -51
  446. package/src/durable/utils.ts +46 -41
  447. package/src/index.ts +145 -86
  448. package/src/providers/claude/ClaudeAgentMapper.ts +51 -50
  449. package/src/providers/claude/ClaudeCodeAdapter.ts +144 -136
  450. package/src/providers/claude/ClaudeSessionLocator.ts +291 -293
  451. package/src/providers/claude/ClaudeSessionParser.ts +322 -338
  452. package/src/providers/claude/durable/ClaudeCliProbe.ts +42 -37
  453. package/src/providers/claude/durable/ClaudePrintAgentService.ts +63 -50
  454. package/src/providers/claude/durable/ClaudePrintRunner.ts +79 -69
  455. package/src/providers/claude/durable/ClaudeStreamParser.ts +91 -62
  456. package/src/providers/codex/CodexAdapter.ts +205 -0
  457. package/src/providers/codex/CodexAgentMapper.ts +35 -0
  458. package/src/providers/codex/CodexSessionLocator.ts +279 -0
  459. package/src/providers/codex/CodexSessionMapping.ts +89 -0
  460. package/src/providers/codex/CodexSessionParser.ts +385 -0
  461. package/src/providers/codex/durable/CodexCliProbe.ts +50 -42
  462. package/src/providers/codex/durable/CodexPrintAgentService.ts +63 -49
  463. package/src/providers/codex/durable/CodexPrintRunner.ts +79 -69
  464. package/src/providers/codex/durable/CodexStreamParser.ts +97 -84
  465. package/src/providers/pi/PiAdapter.ts +183 -0
  466. package/src/providers/pi/PiAgentMapper.ts +36 -0
  467. package/src/providers/pi/PiSessionLocator.ts +95 -0
  468. package/src/providers/pi/PiSessionParser.ts +284 -0
  469. package/src/providers/pi/PiSessionTracker.ts +87 -0
  470. package/src/providers/pi/durable/PiCliProbe.ts +42 -34
  471. package/src/providers/pi/durable/PiPrintAgentService.ts +61 -53
  472. package/src/providers/pi/durable/PiPrintProtocol.ts +31 -29
  473. package/src/providers/pi/durable/PiPrintRunner.ts +75 -68
  474. package/src/providers/pi/durable/PiStreamParser.ts +82 -72
  475. package/src/readiness/AgentReadiness.ts +727 -0
  476. package/src/runtime/ManagedAgentRuntime.ts +266 -0
  477. package/src/runtime/RuntimeFactory.ts +13 -0
  478. package/src/runtime/errors.ts +50 -0
  479. package/src/runtime/herdr/HerdrAgentRuntime.ts +190 -0
  480. package/src/runtime/herdr/HerdrCliClient.ts +78 -0
  481. package/src/runtime/herdr/HerdrErrors.ts +9 -0
  482. package/src/runtime/herdr/HerdrResponseParsers.ts +76 -0
  483. package/src/runtime/herdr/HerdrRuntimeRef.ts +41 -0
  484. package/src/runtime/tmux/PidPolling.ts +34 -0
  485. package/src/runtime/tmux/TmuxAgentRuntime.ts +113 -0
  486. package/src/runtime/tmux/TmuxRuntimeRef.ts +9 -0
  487. package/src/runtime/types.ts +56 -0
  488. package/src/terminal/TerminalFocusManager.ts +215 -212
  489. package/src/terminal/TmuxManager.ts +99 -92
  490. package/src/terminal/TtyWriter.ts +203 -194
  491. package/src/terminal/index.ts +4 -4
  492. package/src/utils/AgentRegistry.ts +299 -238
  493. package/src/utils/agent-requests.ts +16 -16
  494. package/src/utils/agents.ts +41 -38
  495. package/src/utils/applescript.ts +4 -4
  496. package/src/utils/index.ts +12 -6
  497. package/src/utils/matching.ts +43 -43
  498. package/src/utils/process.ts +261 -258
  499. package/src/utils/session.ts +66 -66
  500. package/src/utils/sortAgents.ts +35 -33
  501. package/tsconfig.json +2 -8
  502. package/vitest.config.ts +16 -16
  503. package/.eslintrc.json +0 -31
  504. package/dist/__tests__/adapters/PiAdapter.test.js +0 -618
  505. package/dist/__tests__/adapters/PiAdapter.test.js.map +0 -1
  506. package/dist/__tests__/database/DurableAgentsDatabase.test.js +0 -128
  507. package/dist/__tests__/database/DurableAgentsDatabase.test.js.map +0 -1
  508. package/dist/adapters/CodexAdapter.d.ts +0 -109
  509. package/dist/adapters/CodexAdapter.d.ts.map +0 -1
  510. package/dist/adapters/CodexAdapter.js +0 -710
  511. package/dist/adapters/CodexAdapter.js.map +0 -1
  512. package/dist/adapters/PiAdapter.d.ts +0 -63
  513. package/dist/adapters/PiAdapter.d.ts.map +0 -1
  514. package/dist/adapters/PiAdapter.js +0 -453
  515. package/dist/adapters/PiAdapter.js.map +0 -1
  516. package/src/__tests__/adapters/PiAdapter.test.ts +0 -458
  517. package/src/__tests__/database/DurableAgentsDatabase.test.ts +0 -102
  518. package/src/adapters/CodexAdapter.ts +0 -923
  519. package/src/adapters/PiAdapter.ts +0 -598
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * Tests for ClaudeCodeAdapter
3
- */ import * as fs from 'fs';
4
- import * as path from 'path';
5
- import { ClaudeCodeAdapter } from '../../providers/claude/ClaudeCodeAdapter.js';
6
- import { AgentStatus } from '../../adapters/AgentAdapter.js';
7
- import { listAgentProcesses, enrichProcesses, captureProcessSnapshot } from '../../utils/process.js';
8
- import { batchGetSessionFileBirthtimes } from '../../utils/session.js';
9
- import { matchProcessesToSessions, generateAgentName } from '../../utils/matching.js';
10
- import * as os from 'os';
11
- vi.mock('../../utils/process.js', async (importOriginal)=>{
3
+ */ import * as fs from "fs";
4
+ import * as path from "path";
5
+ import { ClaudeCodeAdapter } from "../../providers/claude/ClaudeCodeAdapter.js";
6
+ import { AgentStatus } from "../../adapters/AgentAdapter.js";
7
+ import { listAgentProcesses, enrichProcesses, captureProcessSnapshot } from "../../utils/process.js";
8
+ import { batchGetSessionFileBirthtimes } from "../../utils/session.js";
9
+ import { matchProcessesToSessions, generateAgentName } from "../../utils/matching.js";
10
+ import * as os from "os";
11
+ vi.mock("../../utils/process.js", async (importOriginal)=>{
12
12
  const actual = await importOriginal();
13
13
  return {
14
14
  ...actual,
@@ -17,14 +17,14 @@ vi.mock('../../utils/process.js', async (importOriginal)=>{
17
17
  captureProcessSnapshot: vi.fn()
18
18
  };
19
19
  });
20
- vi.mock('../../utils/session.js', async ()=>{
21
- const actual = await vi.importActual('../../utils/session');
20
+ vi.mock("../../utils/session.js", async ()=>{
21
+ const actual = await vi.importActual("../../utils/session");
22
22
  return {
23
23
  ...actual,
24
24
  batchGetSessionFileBirthtimes: vi.fn()
25
25
  };
26
26
  });
27
- vi.mock('../../utils/matching.js', ()=>({
27
+ vi.mock("../../utils/matching.js", ()=>({
28
28
  matchProcessesToSessions: vi.fn(),
29
29
  generateAgentName: vi.fn()
30
30
  }));
@@ -34,7 +34,7 @@ const mockedCaptureProcessSnapshot = captureProcessSnapshot;
34
34
  const mockedBatchGetSessionFileBirthtimes = batchGetSessionFileBirthtimes;
35
35
  const mockedMatchProcessesToSessions = matchProcessesToSessions;
36
36
  const mockedGenerateAgentName = generateAgentName;
37
- describe('ClaudeCodeAdapter', ()=>{
37
+ describe("ClaudeCodeAdapter", ()=>{
38
38
  let adapter;
39
39
  beforeEach(()=>{
40
40
  adapter = new ClaudeCodeAdapter();
@@ -50,137 +50,137 @@ describe('ClaudeCodeAdapter', ()=>{
50
50
  mockedCaptureProcessSnapshot.mockImplementation(async (names)=>enrichProcesses(names.flatMap((name)=>listAgentProcesses(name))));
51
51
  // Default: generateAgentName returns "folder (pid)"
52
52
  mockedGenerateAgentName.mockImplementation((cwd, pid)=>{
53
- const folder = path.basename(cwd) || 'unknown';
53
+ const folder = path.basename(cwd) || "unknown";
54
54
  return `${folder} (${pid})`;
55
55
  });
56
56
  });
57
- describe('initialization', ()=>{
58
- it('should create adapter with correct type', ()=>{
59
- expect(adapter.type).toBe('claude');
57
+ describe("initialization", ()=>{
58
+ it("should create adapter with correct type", ()=>{
59
+ expect(adapter.type).toBe("claude");
60
60
  });
61
61
  });
62
- describe('canHandle', ()=>{
63
- it('should return true for claude processes', ()=>{
62
+ describe("canHandle", ()=>{
63
+ it("should return true for claude processes", ()=>{
64
64
  const processInfo = {
65
65
  pid: 12345,
66
- command: 'claude',
67
- cwd: '/test',
68
- tty: 'ttys001'
66
+ command: "claude",
67
+ cwd: "/test",
68
+ tty: "ttys001"
69
69
  };
70
70
  expect(adapter.canHandle(processInfo)).toBe(true);
71
71
  });
72
- it('should return true for claude executable with full path', ()=>{
72
+ it("should return true for claude executable with full path", ()=>{
73
73
  const processInfo = {
74
74
  pid: 12345,
75
- command: '/usr/local/bin/claude --some-flag',
76
- cwd: '/test',
77
- tty: 'ttys001'
75
+ command: "/usr/local/bin/claude --some-flag",
76
+ cwd: "/test",
77
+ tty: "ttys001"
78
78
  };
79
79
  expect(adapter.canHandle(processInfo)).toBe(true);
80
80
  });
81
- it('should return true for CLAUDE (case-insensitive)', ()=>{
81
+ it("should return true for CLAUDE (case-insensitive)", ()=>{
82
82
  const processInfo = {
83
83
  pid: 12345,
84
- command: '/usr/local/bin/CLAUDE --continue',
85
- cwd: '/test',
86
- tty: 'ttys001'
84
+ command: "/usr/local/bin/CLAUDE --continue",
85
+ cwd: "/test",
86
+ tty: "ttys001"
87
87
  };
88
88
  expect(adapter.canHandle(processInfo)).toBe(true);
89
89
  });
90
- it('should return false for non-claude processes', ()=>{
90
+ it("should return false for non-claude processes", ()=>{
91
91
  const processInfo = {
92
92
  pid: 12345,
93
- command: 'node',
94
- cwd: '/test',
95
- tty: 'ttys001'
93
+ command: "node",
94
+ cwd: "/test",
95
+ tty: "ttys001"
96
96
  };
97
97
  expect(adapter.canHandle(processInfo)).toBe(false);
98
98
  });
99
99
  it('should return false for processes with "claude" only in path arguments', ()=>{
100
100
  const processInfo = {
101
101
  pid: 12345,
102
- command: '/usr/local/bin/node /path/to/claude-worktree/node_modules/nx/start.js',
103
- cwd: '/test',
104
- tty: 'ttys001'
102
+ command: "/usr/local/bin/node /path/to/claude-worktree/node_modules/nx/start.js",
103
+ cwd: "/test",
104
+ tty: "ttys001"
105
105
  };
106
106
  expect(adapter.canHandle(processInfo)).toBe(false);
107
107
  });
108
108
  });
109
- describe('detectAgents', ()=>{
110
- it('should return empty array if no claude processes running', async ()=>{
109
+ describe("detectAgents", ()=>{
110
+ it("should return empty array if no claude processes running", async ()=>{
111
111
  mockedListAgentProcesses.mockReturnValue([]);
112
112
  const agents = await adapter.detectAgents();
113
113
  expect(agents).toEqual([]);
114
- expect(mockedListAgentProcesses).toHaveBeenCalledWith('claude');
114
+ expect(mockedListAgentProcesses).toHaveBeenCalledWith("claude");
115
115
  });
116
- it('should return process-only agents when no sessions discovered', async ()=>{
116
+ it("should return process-only agents when no sessions discovered", async ()=>{
117
117
  const processes = [
118
118
  {
119
119
  pid: 777,
120
- command: 'claude',
121
- cwd: '/project/app',
122
- tty: 'ttys001'
120
+ command: "claude",
121
+ cwd: "/project/app",
122
+ tty: "ttys001"
123
123
  }
124
124
  ];
125
125
  mockedListAgentProcesses.mockReturnValue(processes);
126
126
  mockedEnrichProcesses.mockReturnValue(processes);
127
127
  // No projects dir → discoverSessions returns []
128
- adapter.projectsDir = '/nonexistent/path';
128
+ adapter.projectsDir = "/nonexistent/path";
129
129
  const agents = await adapter.detectAgents();
130
130
  expect(agents).toHaveLength(1);
131
131
  expect(agents[0]).toMatchObject({
132
- type: 'claude',
132
+ type: "claude",
133
133
  status: AgentStatus.IDLE,
134
134
  pid: 777,
135
- projectPath: '/project/app',
136
- sessionId: 'pid-777',
137
- summary: 'Unknown'
135
+ projectPath: "/project/app",
136
+ sessionId: "pid-777",
137
+ summary: "Unknown"
138
138
  });
139
139
  });
140
- it('should detect agents with matched sessions', async ()=>{
140
+ it("should detect agents with matched sessions", async ()=>{
141
141
  const processes = [
142
142
  {
143
143
  pid: 12345,
144
- command: 'claude',
145
- cwd: '/Users/test/my-project',
146
- tty: 'ttys001',
147
- startTime: new Date('2026-03-18T23:18:01.000Z')
144
+ command: "claude",
145
+ cwd: "/Users/test/my-project",
146
+ tty: "ttys001",
147
+ startTime: new Date("2026-03-18T23:18:01.000Z")
148
148
  }
149
149
  ];
150
150
  mockedListAgentProcesses.mockReturnValue(processes);
151
151
  mockedEnrichProcesses.mockReturnValue(processes);
152
152
  // Set up projects dir with encoded directory name
153
- const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'claude-test-'));
154
- const projectsDir = path.join(tmpDir, 'projects');
153
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "claude-test-"));
154
+ const projectsDir = path.join(tmpDir, "projects");
155
155
  // Claude encodes /Users/test/my-project → -Users-test-my-project
156
- const projDir = path.join(projectsDir, '-Users-test-my-project');
156
+ const projDir = path.join(projectsDir, "-Users-test-my-project");
157
157
  fs.mkdirSync(projDir, {
158
158
  recursive: true
159
159
  });
160
160
  // Create session file
161
- const sessionFile = path.join(projDir, 'session-1.jsonl');
161
+ const sessionFile = path.join(projDir, "session-1.jsonl");
162
162
  fs.writeFileSync(sessionFile, [
163
163
  JSON.stringify({
164
- type: 'user',
165
- timestamp: '2026-03-18T23:18:44Z',
166
- cwd: '/Users/test/my-project',
164
+ type: "user",
165
+ timestamp: "2026-03-18T23:18:44Z",
166
+ cwd: "/Users/test/my-project",
167
167
  message: {
168
- content: 'Investigate failing tests'
168
+ content: "Investigate failing tests"
169
169
  }
170
170
  }),
171
171
  JSON.stringify({
172
- type: 'assistant',
173
- timestamp: '2026-03-18T23:19:00Z'
172
+ type: "assistant",
173
+ timestamp: "2026-03-18T23:19:00Z"
174
174
  })
175
- ].join('\n'));
175
+ ].join("\n"));
176
176
  adapter.projectsDir = projectsDir;
177
177
  const sessionFiles = [
178
178
  {
179
- sessionId: 'session-1',
179
+ sessionId: "session-1",
180
180
  filePath: sessionFile,
181
181
  projectDir: projDir,
182
- birthtimeMs: new Date('2026-03-18T23:18:44Z').getTime(),
183
- resolvedCwd: ''
182
+ birthtimeMs: new Date("2026-03-18T23:18:44Z").getTime(),
183
+ resolvedCwd: ""
184
184
  }
185
185
  ];
186
186
  mockedBatchGetSessionFileBirthtimes.mockReturnValue(sessionFiles);
@@ -189,7 +189,7 @@ describe('ClaudeCodeAdapter', ()=>{
189
189
  process: processes[0],
190
190
  session: {
191
191
  ...sessionFiles[0],
192
- resolvedCwd: '/Users/test/my-project'
192
+ resolvedCwd: "/Users/test/my-project"
193
193
  },
194
194
  deltaMs: 43000
195
195
  }
@@ -198,62 +198,62 @@ describe('ClaudeCodeAdapter', ()=>{
198
198
  const agents = await adapter.detectAgents();
199
199
  expect(agents).toHaveLength(1);
200
200
  expect(agents[0]).toMatchObject({
201
- type: 'claude',
201
+ type: "claude",
202
202
  status: AgentStatus.WAITING,
203
203
  pid: 12345,
204
- projectPath: '/Users/test/my-project',
205
- sessionId: 'session-1'
204
+ projectPath: "/Users/test/my-project",
205
+ sessionId: "session-1"
206
206
  });
207
- expect(agents[0].summary).toContain('Investigate failing tests');
207
+ expect(agents[0].summary).toContain("Investigate failing tests");
208
208
  fs.rmSync(tmpDir, {
209
209
  recursive: true,
210
210
  force: true
211
211
  });
212
212
  });
213
- it('should fall back to process-only for unmatched processes', async ()=>{
213
+ it("should fall back to process-only for unmatched processes", async ()=>{
214
214
  const processes = [
215
215
  {
216
216
  pid: 100,
217
- command: 'claude',
218
- cwd: '/project-a',
219
- tty: 'ttys001',
217
+ command: "claude",
218
+ cwd: "/project-a",
219
+ tty: "ttys001",
220
220
  startTime: new Date()
221
221
  },
222
222
  {
223
223
  pid: 200,
224
- command: 'claude',
225
- cwd: '/project-b',
226
- tty: 'ttys002',
224
+ command: "claude",
225
+ cwd: "/project-b",
226
+ tty: "ttys002",
227
227
  startTime: new Date()
228
228
  }
229
229
  ];
230
230
  mockedListAgentProcesses.mockReturnValue(processes);
231
231
  mockedEnrichProcesses.mockReturnValue(processes);
232
232
  // Set up projects dir with encoded directory names
233
- const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'claude-test-'));
234
- const projectsDir = path.join(tmpDir, 'projects');
233
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "claude-test-"));
234
+ const projectsDir = path.join(tmpDir, "projects");
235
235
  // /project-a → -project-a, /project-b → -project-b
236
- const projDirA = path.join(projectsDir, '-project-a');
237
- const projDirB = path.join(projectsDir, '-project-b');
236
+ const projDirA = path.join(projectsDir, "-project-a");
237
+ const projDirB = path.join(projectsDir, "-project-b");
238
238
  fs.mkdirSync(projDirA, {
239
239
  recursive: true
240
240
  });
241
241
  fs.mkdirSync(projDirB, {
242
242
  recursive: true
243
243
  });
244
- const sessionFile = path.join(projDirA, 'only-session.jsonl');
244
+ const sessionFile = path.join(projDirA, "only-session.jsonl");
245
245
  fs.writeFileSync(sessionFile, JSON.stringify({
246
- type: 'assistant',
247
- timestamp: '2026-03-18T23:19:00Z'
246
+ type: "assistant",
247
+ timestamp: "2026-03-18T23:19:00Z"
248
248
  }));
249
249
  adapter.projectsDir = projectsDir;
250
250
  const sessionFiles = [
251
251
  {
252
- sessionId: 'only-session',
252
+ sessionId: "only-session",
253
253
  filePath: sessionFile,
254
254
  projectDir: projDirA,
255
255
  birthtimeMs: Date.now(),
256
- resolvedCwd: ''
256
+ resolvedCwd: ""
257
257
  }
258
258
  ];
259
259
  mockedBatchGetSessionFileBirthtimes.mockReturnValue(sessionFiles);
@@ -263,7 +263,7 @@ describe('ClaudeCodeAdapter', ()=>{
263
263
  process: processes[0],
264
264
  session: {
265
265
  ...sessionFiles[0],
266
- resolvedCwd: '/project-a'
266
+ resolvedCwd: "/project-a"
267
267
  },
268
268
  deltaMs: 5000
269
269
  }
@@ -273,154 +273,154 @@ describe('ClaudeCodeAdapter', ()=>{
273
273
  expect(agents).toHaveLength(2);
274
274
  const matched = agents.find((a)=>a.pid === 100);
275
275
  const unmatched = agents.find((a)=>a.pid === 200);
276
- expect(matched?.sessionId).toBe('only-session');
277
- expect(unmatched?.sessionId).toBe('pid-200');
276
+ expect(matched?.sessionId).toBe("only-session");
277
+ expect(unmatched?.sessionId).toBe("pid-200");
278
278
  expect(unmatched?.status).toBe(AgentStatus.IDLE);
279
279
  fs.rmSync(tmpDir, {
280
280
  recursive: true,
281
281
  force: true
282
282
  });
283
283
  });
284
- it('should handle process with empty cwd in process-only fallback', async ()=>{
284
+ it("should handle process with empty cwd in process-only fallback", async ()=>{
285
285
  const processes = [
286
286
  {
287
287
  pid: 300,
288
- command: 'claude',
289
- cwd: '',
290
- tty: 'ttys003'
288
+ command: "claude",
289
+ cwd: "",
290
+ tty: "ttys003"
291
291
  }
292
292
  ];
293
293
  mockedListAgentProcesses.mockReturnValue(processes);
294
294
  mockedEnrichProcesses.mockReturnValue(processes);
295
- adapter.projectsDir = '/nonexistent';
295
+ adapter.projectsDir = "/nonexistent";
296
296
  const agents = await adapter.detectAgents();
297
297
  expect(agents).toHaveLength(1);
298
298
  expect(agents[0]).toMatchObject({
299
299
  pid: 300,
300
- sessionId: 'pid-300',
301
- summary: 'Unknown',
302
- projectPath: ''
300
+ sessionId: "pid-300",
301
+ summary: "Unknown",
302
+ projectPath: ""
303
303
  });
304
304
  });
305
- it('should match via --resume <uuid> in command line and skip PID-file/legacy', async ()=>{
306
- const sessionId = '0555f803-7eca-4fc6-a1e0-34dbf86b33b2';
305
+ it("should match via --resume <uuid> in command line and skip PID-file/legacy", async ()=>{
306
+ const sessionId = "0555f803-7eca-4fc6-a1e0-34dbf86b33b2";
307
307
  const processes = [
308
308
  {
309
309
  pid: 41920,
310
310
  command: `claude --resume ${sessionId}`,
311
- cwd: '/project/resumed',
312
- tty: 'ttys001',
311
+ cwd: "/project/resumed",
312
+ tty: "ttys001",
313
313
  startTime: new Date()
314
314
  }
315
315
  ];
316
316
  mockedListAgentProcesses.mockReturnValue(processes);
317
317
  mockedEnrichProcesses.mockReturnValue(processes);
318
- const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'claude-resume-'));
319
- const projectsDir = path.join(tmpDir, 'projects');
320
- const projDir = path.join(projectsDir, '-project-resumed');
318
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "claude-resume-"));
319
+ const projectsDir = path.join(tmpDir, "projects");
320
+ const projDir = path.join(projectsDir, "-project-resumed");
321
321
  fs.mkdirSync(projDir, {
322
322
  recursive: true
323
323
  });
324
324
  const jsonlPath = path.join(projDir, `${sessionId}.jsonl`);
325
325
  fs.writeFileSync(jsonlPath, [
326
326
  JSON.stringify({
327
- type: 'user',
327
+ type: "user",
328
328
  timestamp: new Date().toISOString(),
329
- cwd: '/project/resumed',
329
+ cwd: "/project/resumed",
330
330
  message: {
331
- content: 'resumed conversation'
331
+ content: "resumed conversation"
332
332
  }
333
333
  }),
334
334
  JSON.stringify({
335
- type: 'assistant',
335
+ type: "assistant",
336
336
  timestamp: new Date().toISOString()
337
337
  })
338
- ].join('\n'));
338
+ ].join("\n"));
339
339
  adapter.projectsDir = projectsDir;
340
- adapter.sessionsDir = path.join(tmpDir, 'sessions'); // empty — no PID file
340
+ adapter.sessionsDir = path.join(tmpDir, "sessions"); // empty — no PID file
341
341
  const agents = await adapter.detectAgents();
342
342
  // Legacy matching helpers must NOT have been consulted — resume match was authoritative
343
343
  expect(mockedBatchGetSessionFileBirthtimes).not.toHaveBeenCalled();
344
344
  expect(mockedMatchProcessesToSessions).not.toHaveBeenCalled();
345
345
  expect(agents).toHaveLength(1);
346
346
  expect(agents[0]).toMatchObject({
347
- type: 'claude',
347
+ type: "claude",
348
348
  pid: 41920,
349
349
  sessionId,
350
- projectPath: '/project/resumed'
350
+ projectPath: "/project/resumed"
351
351
  });
352
- expect(agents[0].summary).toContain('resumed conversation');
352
+ expect(agents[0].summary).toContain("resumed conversation");
353
353
  fs.rmSync(tmpDir, {
354
354
  recursive: true,
355
355
  force: true
356
356
  });
357
357
  });
358
- it('should fall through when --resume points to a JSONL that does not exist', async ()=>{
358
+ it("should fall through when --resume points to a JSONL that does not exist", async ()=>{
359
359
  const processes = [
360
360
  {
361
361
  pid: 41921,
362
- command: 'claude --resume aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee',
363
- cwd: '/project/missing',
364
- tty: 'ttys001',
362
+ command: "claude --resume aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
363
+ cwd: "/project/missing",
364
+ tty: "ttys001",
365
365
  startTime: new Date()
366
366
  }
367
367
  ];
368
368
  mockedListAgentProcesses.mockReturnValue(processes);
369
369
  mockedEnrichProcesses.mockReturnValue(processes);
370
370
  // No projects dir, no PID file → both matchers fail → process-only
371
- adapter.projectsDir = '/nonexistent';
372
- adapter.sessionsDir = '/nonexistent';
371
+ adapter.projectsDir = "/nonexistent";
372
+ adapter.sessionsDir = "/nonexistent";
373
373
  const agents = await adapter.detectAgents();
374
374
  expect(agents).toHaveLength(1);
375
- expect(agents[0].sessionId).toBe('pid-41921');
375
+ expect(agents[0].sessionId).toBe("pid-41921");
376
376
  expect(agents[0].status).toBe(AgentStatus.IDLE);
377
377
  });
378
- it('should use PID file for direct match and skip legacy matching for that process', async ()=>{
378
+ it("should use PID file for direct match and skip legacy matching for that process", async ()=>{
379
379
  const startTime = new Date();
380
380
  const processes = [
381
381
  {
382
382
  pid: 55001,
383
- command: 'claude',
384
- cwd: '/project/direct',
385
- tty: 'ttys001',
383
+ command: "claude",
384
+ cwd: "/project/direct",
385
+ tty: "ttys001",
386
386
  startTime
387
387
  }
388
388
  ];
389
389
  mockedListAgentProcesses.mockReturnValue(processes);
390
390
  mockedEnrichProcesses.mockReturnValue(processes);
391
- const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'claude-pid-test-'));
392
- const sessionsDir = path.join(tmpDir, 'sessions');
393
- const projectsDir = path.join(tmpDir, 'projects');
394
- const projDir = path.join(projectsDir, '-project-direct');
391
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "claude-pid-test-"));
392
+ const sessionsDir = path.join(tmpDir, "sessions");
393
+ const projectsDir = path.join(tmpDir, "projects");
394
+ const projDir = path.join(projectsDir, "-project-direct");
395
395
  fs.mkdirSync(sessionsDir, {
396
396
  recursive: true
397
397
  });
398
398
  fs.mkdirSync(projDir, {
399
399
  recursive: true
400
400
  });
401
- const sessionId = 'pid-file-session';
401
+ const sessionId = "pid-file-session";
402
402
  const jsonlPath = path.join(projDir, `${sessionId}.jsonl`);
403
403
  fs.writeFileSync(jsonlPath, [
404
404
  JSON.stringify({
405
- type: 'user',
405
+ type: "user",
406
406
  timestamp: new Date().toISOString(),
407
- cwd: '/project/direct',
407
+ cwd: "/project/direct",
408
408
  message: {
409
- content: 'hello from pid file'
409
+ content: "hello from pid file"
410
410
  }
411
411
  }),
412
412
  JSON.stringify({
413
- type: 'assistant',
413
+ type: "assistant",
414
414
  timestamp: new Date().toISOString()
415
415
  })
416
- ].join('\n'));
417
- fs.writeFileSync(path.join(sessionsDir, '55001.json'), JSON.stringify({
416
+ ].join("\n"));
417
+ fs.writeFileSync(path.join(sessionsDir, "55001.json"), JSON.stringify({
418
418
  pid: 55001,
419
419
  sessionId,
420
- cwd: '/project/direct',
420
+ cwd: "/project/direct",
421
421
  startedAt: startTime.getTime(),
422
- kind: 'interactive',
423
- entrypoint: 'cli'
422
+ kind: "interactive",
423
+ entrypoint: "cli"
424
424
  }));
425
425
  adapter.sessionsDir = sessionsDir;
426
426
  adapter.projectsDir = projectsDir;
@@ -430,76 +430,76 @@ describe('ClaudeCodeAdapter', ()=>{
430
430
  expect(mockedMatchProcessesToSessions).not.toHaveBeenCalled();
431
431
  expect(agents).toHaveLength(1);
432
432
  expect(agents[0]).toMatchObject({
433
- type: 'claude',
433
+ type: "claude",
434
434
  pid: 55001,
435
435
  sessionId,
436
- projectPath: '/project/direct',
436
+ projectPath: "/project/direct",
437
437
  status: AgentStatus.WAITING
438
438
  });
439
- expect(agents[0].summary).toContain('hello from pid file');
439
+ expect(agents[0].summary).toContain("hello from pid file");
440
440
  fs.rmSync(tmpDir, {
441
441
  recursive: true,
442
442
  force: true
443
443
  });
444
444
  });
445
- it('should prefer PID-file live status over JSONL-derived status and surface waitingFor in summary', async ()=>{
445
+ it("should prefer PID-file live status over JSONL-derived status and surface waitingFor in summary", async ()=>{
446
446
  const startTime = new Date();
447
447
  const processes = [
448
448
  {
449
449
  pid: 55050,
450
- command: 'claude',
451
- cwd: '/project/wait',
452
- tty: 'ttys001',
450
+ command: "claude",
451
+ cwd: "/project/wait",
452
+ tty: "ttys001",
453
453
  startTime
454
454
  }
455
455
  ];
456
456
  mockedListAgentProcesses.mockReturnValue(processes);
457
457
  mockedEnrichProcesses.mockReturnValue(processes);
458
- const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'claude-pid-wait-'));
459
- const sessionsDir = path.join(tmpDir, 'sessions');
460
- const projectsDir = path.join(tmpDir, 'projects');
461
- const projDir = path.join(projectsDir, '-project-wait');
458
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "claude-pid-wait-"));
459
+ const sessionsDir = path.join(tmpDir, "sessions");
460
+ const projectsDir = path.join(tmpDir, "projects");
461
+ const projDir = path.join(projectsDir, "-project-wait");
462
462
  fs.mkdirSync(sessionsDir, {
463
463
  recursive: true
464
464
  });
465
465
  fs.mkdirSync(projDir, {
466
466
  recursive: true
467
467
  });
468
- const sessionId = 'wait-session';
468
+ const sessionId = "wait-session";
469
469
  const jsonlPath = path.join(projDir, `${sessionId}.jsonl`);
470
470
  // PID file's live status must win over JSONL-derived status.
471
471
  fs.writeFileSync(jsonlPath, [
472
472
  JSON.stringify({
473
- type: 'user',
473
+ type: "user",
474
474
  timestamp: new Date().toISOString(),
475
- cwd: '/project/wait',
475
+ cwd: "/project/wait",
476
476
  message: {
477
- content: '/reddit-commenter'
477
+ content: "/reddit-commenter"
478
478
  }
479
479
  }),
480
480
  JSON.stringify({
481
- type: 'permission-mode',
481
+ type: "permission-mode",
482
482
  timestamp: new Date().toISOString(),
483
- permissionMode: 'default'
483
+ permissionMode: "default"
484
484
  })
485
- ].join('\n'));
486
- fs.writeFileSync(path.join(sessionsDir, '55050.json'), JSON.stringify({
485
+ ].join("\n"));
486
+ fs.writeFileSync(path.join(sessionsDir, "55050.json"), JSON.stringify({
487
487
  pid: 55050,
488
488
  sessionId,
489
- cwd: '/project/wait',
489
+ cwd: "/project/wait",
490
490
  startedAt: startTime.getTime(),
491
- kind: 'interactive',
492
- entrypoint: 'cli',
493
- status: 'waiting',
494
- waitingFor: 'approve Read'
491
+ kind: "interactive",
492
+ entrypoint: "cli",
493
+ status: "waiting",
494
+ waitingFor: "approve Read"
495
495
  }));
496
496
  adapter.sessionsDir = sessionsDir;
497
497
  adapter.projectsDir = projectsDir;
498
498
  const agents = await adapter.detectAgents();
499
499
  expect(agents).toHaveLength(1);
500
500
  expect(agents[0].status).toBe(AgentStatus.WAITING);
501
- expect(agents[0].summary).toContain('/reddit-commenter');
502
- expect(agents[0].summary).toContain('waiting for approve Read');
501
+ expect(agents[0].summary).toContain("/reddit-commenter");
502
+ expect(agents[0].summary).toContain("waiting for approve Read");
503
503
  fs.rmSync(tmpDir, {
504
504
  recursive: true,
505
505
  force: true
@@ -510,49 +510,49 @@ describe('ClaudeCodeAdapter', ()=>{
510
510
  const processes = [
511
511
  {
512
512
  pid: 55051,
513
- command: 'claude',
514
- cwd: '/project/idle',
515
- tty: 'ttys001',
513
+ command: "claude",
514
+ cwd: "/project/idle",
515
+ tty: "ttys001",
516
516
  startTime
517
517
  }
518
518
  ];
519
519
  mockedListAgentProcesses.mockReturnValue(processes);
520
520
  mockedEnrichProcesses.mockReturnValue(processes);
521
- const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'claude-pid-idle-'));
522
- const sessionsDir = path.join(tmpDir, 'sessions');
523
- const projectsDir = path.join(tmpDir, 'projects');
524
- const projDir = path.join(projectsDir, '-project-idle');
521
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "claude-pid-idle-"));
522
+ const sessionsDir = path.join(tmpDir, "sessions");
523
+ const projectsDir = path.join(tmpDir, "projects");
524
+ const projDir = path.join(projectsDir, "-project-idle");
525
525
  fs.mkdirSync(sessionsDir, {
526
526
  recursive: true
527
527
  });
528
528
  fs.mkdirSync(projDir, {
529
529
  recursive: true
530
530
  });
531
- const sessionId = 'idle-session';
531
+ const sessionId = "idle-session";
532
532
  const jsonlPath = path.join(projDir, `${sessionId}.jsonl`);
533
533
  fs.writeFileSync(jsonlPath, [
534
534
  JSON.stringify({
535
- type: 'user',
535
+ type: "user",
536
536
  timestamp: new Date().toISOString(),
537
- cwd: '/project/idle',
537
+ cwd: "/project/idle",
538
538
  message: {
539
- content: 'hello'
539
+ content: "hello"
540
540
  }
541
541
  }),
542
542
  JSON.stringify({
543
- type: 'permission-mode',
543
+ type: "permission-mode",
544
544
  timestamp: new Date().toISOString(),
545
- permissionMode: 'default'
545
+ permissionMode: "default"
546
546
  })
547
- ].join('\n'));
548
- fs.writeFileSync(path.join(sessionsDir, '55051.json'), JSON.stringify({
547
+ ].join("\n"));
548
+ fs.writeFileSync(path.join(sessionsDir, "55051.json"), JSON.stringify({
549
549
  pid: 55051,
550
550
  sessionId,
551
- cwd: '/project/idle',
551
+ cwd: "/project/idle",
552
552
  startedAt: startTime.getTime(),
553
- kind: 'interactive',
554
- entrypoint: 'cli',
555
- status: 'idle'
553
+ kind: "interactive",
554
+ entrypoint: "cli",
555
+ status: "idle"
556
556
  }));
557
557
  adapter.sessionsDir = sessionsDir;
558
558
  adapter.projectsDir = projectsDir;
@@ -560,61 +560,61 @@ describe('ClaudeCodeAdapter', ()=>{
560
560
  expect(agents).toHaveLength(1);
561
561
  expect(agents[0].status).toBe(AgentStatus.IDLE);
562
562
  // No waitingFor in PID file → summary is just the last user message
563
- expect(agents[0].summary).toBe('hello');
563
+ expect(agents[0].summary).toBe("hello");
564
564
  fs.rmSync(tmpDir, {
565
565
  recursive: true,
566
566
  force: true
567
567
  });
568
568
  });
569
- it('should fall back to JSONL-derived status when PID-file status is missing or unrecognized', async ()=>{
569
+ it("should fall back to JSONL-derived status when PID-file status is missing or unrecognized", async ()=>{
570
570
  const startTime = new Date();
571
571
  const processes = [
572
572
  {
573
573
  pid: 55052,
574
- command: 'claude',
575
- cwd: '/project/legacy',
576
- tty: 'ttys001',
574
+ command: "claude",
575
+ cwd: "/project/legacy",
576
+ tty: "ttys001",
577
577
  startTime
578
578
  }
579
579
  ];
580
580
  mockedListAgentProcesses.mockReturnValue(processes);
581
581
  mockedEnrichProcesses.mockReturnValue(processes);
582
- const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'claude-pid-nostat-'));
583
- const sessionsDir = path.join(tmpDir, 'sessions');
584
- const projectsDir = path.join(tmpDir, 'projects');
585
- const projDir = path.join(projectsDir, '-project-legacy');
582
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "claude-pid-nostat-"));
583
+ const sessionsDir = path.join(tmpDir, "sessions");
584
+ const projectsDir = path.join(tmpDir, "projects");
585
+ const projDir = path.join(projectsDir, "-project-legacy");
586
586
  fs.mkdirSync(sessionsDir, {
587
587
  recursive: true
588
588
  });
589
589
  fs.mkdirSync(projDir, {
590
590
  recursive: true
591
591
  });
592
- const sessionId = 'legacy-session';
592
+ const sessionId = "legacy-session";
593
593
  const jsonlPath = path.join(projDir, `${sessionId}.jsonl`);
594
594
  // Last entry is assistant → JSONL parser yields WAITING.
595
595
  fs.writeFileSync(jsonlPath, [
596
596
  JSON.stringify({
597
- type: 'user',
597
+ type: "user",
598
598
  timestamp: new Date().toISOString(),
599
- cwd: '/project/legacy',
599
+ cwd: "/project/legacy",
600
600
  message: {
601
- content: 'do the thing'
601
+ content: "do the thing"
602
602
  }
603
603
  }),
604
604
  JSON.stringify({
605
- type: 'assistant',
605
+ type: "assistant",
606
606
  timestamp: new Date().toISOString()
607
607
  })
608
- ].join('\n'));
608
+ ].join("\n"));
609
609
  // PID file with unrecognized status string — adapter must ignore it and use parser
610
- fs.writeFileSync(path.join(sessionsDir, '55052.json'), JSON.stringify({
610
+ fs.writeFileSync(path.join(sessionsDir, "55052.json"), JSON.stringify({
611
611
  pid: 55052,
612
612
  sessionId,
613
- cwd: '/project/legacy',
613
+ cwd: "/project/legacy",
614
614
  startedAt: startTime.getTime(),
615
- kind: 'interactive',
616
- entrypoint: 'cli',
617
- status: 'fantastical-future-state'
615
+ kind: "interactive",
616
+ entrypoint: "cli",
617
+ status: "fantastical-future-state"
618
618
  }));
619
619
  adapter.sessionsDir = sessionsDir;
620
620
  adapter.projectsDir = projectsDir;
@@ -626,24 +626,24 @@ describe('ClaudeCodeAdapter', ()=>{
626
626
  force: true
627
627
  });
628
628
  });
629
- it('should pick up live status from PID file even when matched via --resume', async ()=>{
630
- const sessionId = 'aaaaaaaa-1111-2222-3333-444444444444';
629
+ it("should pick up live status from PID file even when matched via --resume", async ()=>{
630
+ const sessionId = "aaaaaaaa-1111-2222-3333-444444444444";
631
631
  const startTime = new Date();
632
632
  const processes = [
633
633
  {
634
634
  pid: 55053,
635
635
  command: `claude --resume ${sessionId}`,
636
- cwd: '/project/resume-wait',
637
- tty: 'ttys001',
636
+ cwd: "/project/resume-wait",
637
+ tty: "ttys001",
638
638
  startTime
639
639
  }
640
640
  ];
641
641
  mockedListAgentProcesses.mockReturnValue(processes);
642
642
  mockedEnrichProcesses.mockReturnValue(processes);
643
- const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'claude-resume-wait-'));
644
- const sessionsDir = path.join(tmpDir, 'sessions');
645
- const projectsDir = path.join(tmpDir, 'projects');
646
- const projDir = path.join(projectsDir, '-project-resume-wait');
643
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "claude-resume-wait-"));
644
+ const sessionsDir = path.join(tmpDir, "sessions");
645
+ const projectsDir = path.join(tmpDir, "projects");
646
+ const projDir = path.join(projectsDir, "-project-resume-wait");
647
647
  fs.mkdirSync(sessionsDir, {
648
648
  recursive: true
649
649
  });
@@ -653,86 +653,86 @@ describe('ClaudeCodeAdapter', ()=>{
653
653
  const jsonlPath = path.join(projDir, `${sessionId}.jsonl`);
654
654
  fs.writeFileSync(jsonlPath, [
655
655
  JSON.stringify({
656
- type: 'user',
656
+ type: "user",
657
657
  timestamp: new Date().toISOString(),
658
- cwd: '/project/resume-wait',
658
+ cwd: "/project/resume-wait",
659
659
  message: {
660
- content: 'resumed work'
660
+ content: "resumed work"
661
661
  }
662
662
  }),
663
663
  JSON.stringify({
664
- type: 'permission-mode',
664
+ type: "permission-mode",
665
665
  timestamp: new Date().toISOString(),
666
- permissionMode: 'default'
666
+ permissionMode: "default"
667
667
  })
668
- ].join('\n'));
669
- fs.writeFileSync(path.join(sessionsDir, '55053.json'), JSON.stringify({
668
+ ].join("\n"));
669
+ fs.writeFileSync(path.join(sessionsDir, "55053.json"), JSON.stringify({
670
670
  pid: 55053,
671
671
  sessionId,
672
- cwd: '/project/resume-wait',
672
+ cwd: "/project/resume-wait",
673
673
  startedAt: startTime.getTime(),
674
- kind: 'interactive',
675
- entrypoint: 'cli',
676
- status: 'waiting',
677
- waitingFor: 'approve Bash'
674
+ kind: "interactive",
675
+ entrypoint: "cli",
676
+ status: "waiting",
677
+ waitingFor: "approve Bash"
678
678
  }));
679
679
  adapter.sessionsDir = sessionsDir;
680
680
  adapter.projectsDir = projectsDir;
681
681
  const agents = await adapter.detectAgents();
682
682
  expect(agents).toHaveLength(1);
683
683
  expect(agents[0].status).toBe(AgentStatus.WAITING);
684
- expect(agents[0].summary).toContain('resumed work');
685
- expect(agents[0].summary).toContain('waiting for approve Bash');
684
+ expect(agents[0].summary).toContain("resumed work");
685
+ expect(agents[0].summary).toContain("waiting for approve Bash");
686
686
  fs.rmSync(tmpDir, {
687
687
  recursive: true,
688
688
  force: true
689
689
  });
690
690
  });
691
- it('should fall back to process-only when direct-matched JSONL becomes unreadable', async ()=>{
691
+ it("should fall back to process-only when direct-matched JSONL becomes unreadable", async ()=>{
692
692
  const startTime = new Date();
693
693
  const processes = [
694
694
  {
695
695
  pid: 66001,
696
- command: 'claude',
697
- cwd: '/project/gone',
698
- tty: 'ttys001',
696
+ command: "claude",
697
+ cwd: "/project/gone",
698
+ tty: "ttys001",
699
699
  startTime
700
700
  }
701
701
  ];
702
702
  mockedListAgentProcesses.mockReturnValue(processes);
703
703
  mockedEnrichProcesses.mockReturnValue(processes);
704
- const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'claude-gone-'));
705
- const sessionsDir = path.join(tmpDir, 'sessions');
706
- const projectsDir = path.join(tmpDir, 'projects');
707
- const projDir = path.join(projectsDir, '-project-gone');
704
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "claude-gone-"));
705
+ const sessionsDir = path.join(tmpDir, "sessions");
706
+ const projectsDir = path.join(tmpDir, "projects");
707
+ const projDir = path.join(projectsDir, "-project-gone");
708
708
  fs.mkdirSync(sessionsDir, {
709
709
  recursive: true
710
710
  });
711
711
  fs.mkdirSync(projDir, {
712
712
  recursive: true
713
713
  });
714
- const sessionId = 'gone-session';
714
+ const sessionId = "gone-session";
715
715
  const jsonlPath = path.join(projDir, `${sessionId}.jsonl`);
716
716
  fs.writeFileSync(jsonlPath, JSON.stringify({
717
- type: 'assistant',
717
+ type: "assistant",
718
718
  timestamp: new Date().toISOString()
719
719
  }));
720
- fs.writeFileSync(path.join(sessionsDir, '66001.json'), JSON.stringify({
720
+ fs.writeFileSync(path.join(sessionsDir, "66001.json"), JSON.stringify({
721
721
  pid: 66001,
722
722
  sessionId,
723
- cwd: '/project/gone',
723
+ cwd: "/project/gone",
724
724
  startedAt: startTime.getTime(),
725
- kind: 'interactive',
726
- entrypoint: 'cli'
725
+ kind: "interactive",
726
+ entrypoint: "cli"
727
727
  }));
728
728
  adapter.sessionsDir = sessionsDir;
729
729
  adapter.projectsDir = projectsDir;
730
730
  // Simulate JSONL disappearing between existence check and read
731
- vi.spyOn(adapter.parser, 'readSession').mockReturnValueOnce(null);
731
+ vi.spyOn(adapter.parser, "readSession").mockReturnValueOnce(null);
732
732
  const agents = await adapter.detectAgents();
733
733
  // matchedPids.delete called → process falls back to IDLE
734
734
  expect(agents).toHaveLength(1);
735
- expect(agents[0].sessionId).toBe('pid-66001');
735
+ expect(agents[0].sessionId).toBe("pid-66001");
736
736
  expect(agents[0].status).toBe(AgentStatus.IDLE);
737
737
  fs.rmSync(tmpDir, {
738
738
  recursive: true,
@@ -740,40 +740,40 @@ describe('ClaudeCodeAdapter', ()=>{
740
740
  });
741
741
  vi.restoreAllMocks();
742
742
  });
743
- it('should fall back to process-only when legacy-matched JSONL becomes unreadable', async ()=>{
743
+ it("should fall back to process-only when legacy-matched JSONL becomes unreadable", async ()=>{
744
744
  const startTime = new Date();
745
745
  const processes = [
746
746
  {
747
747
  pid: 66002,
748
- command: 'claude',
749
- cwd: '/project/legacy-gone',
750
- tty: 'ttys001',
748
+ command: "claude",
749
+ cwd: "/project/legacy-gone",
750
+ tty: "ttys001",
751
751
  startTime
752
752
  }
753
753
  ];
754
754
  mockedListAgentProcesses.mockReturnValue(processes);
755
755
  mockedEnrichProcesses.mockReturnValue(processes);
756
- const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'claude-lgone-'));
757
- const projectsDir = path.join(tmpDir, 'projects');
758
- const projDir = path.join(projectsDir, '-project-legacy-gone');
756
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "claude-lgone-"));
757
+ const projectsDir = path.join(tmpDir, "projects");
758
+ const projDir = path.join(projectsDir, "-project-legacy-gone");
759
759
  fs.mkdirSync(projDir, {
760
760
  recursive: true
761
761
  });
762
- const sessionId = 'legacy-gone-session';
762
+ const sessionId = "legacy-gone-session";
763
763
  const jsonlPath = path.join(projDir, `${sessionId}.jsonl`);
764
764
  fs.writeFileSync(jsonlPath, JSON.stringify({
765
- type: 'assistant',
765
+ type: "assistant",
766
766
  timestamp: new Date().toISOString()
767
767
  }));
768
768
  // No PID file → process goes to legacy fallback
769
- adapter.sessionsDir = path.join(tmpDir, 'no-sessions');
769
+ adapter.sessionsDir = path.join(tmpDir, "no-sessions");
770
770
  adapter.projectsDir = projectsDir;
771
771
  const legacySessionFile = {
772
772
  sessionId,
773
773
  filePath: jsonlPath,
774
774
  projectDir: projDir,
775
775
  birthtimeMs: startTime.getTime(),
776
- resolvedCwd: '/project/legacy-gone'
776
+ resolvedCwd: "/project/legacy-gone"
777
777
  };
778
778
  mockedBatchGetSessionFileBirthtimes.mockReturnValue([
779
779
  legacySessionFile
@@ -786,10 +786,10 @@ describe('ClaudeCodeAdapter', ()=>{
786
786
  }
787
787
  ]);
788
788
  // Simulate JSONL disappearing between match and read
789
- vi.spyOn(adapter.parser, 'readSession').mockReturnValueOnce(null);
789
+ vi.spyOn(adapter.parser, "readSession").mockReturnValueOnce(null);
790
790
  const agents = await adapter.detectAgents();
791
791
  expect(agents).toHaveLength(1);
792
- expect(agents[0].sessionId).toBe('pid-66002');
792
+ expect(agents[0].sessionId).toBe("pid-66002");
793
793
  expect(agents[0].status).toBe(AgentStatus.IDLE);
794
794
  fs.rmSync(tmpDir, {
795
795
  recursive: true,
@@ -797,31 +797,31 @@ describe('ClaudeCodeAdapter', ()=>{
797
797
  });
798
798
  vi.restoreAllMocks();
799
799
  });
800
- it('should mix direct PID-file matches and legacy matches across processes', async ()=>{
800
+ it("should mix direct PID-file matches and legacy matches across processes", async ()=>{
801
801
  const startTime = new Date();
802
802
  const processes = [
803
803
  {
804
804
  pid: 55002,
805
- command: 'claude',
806
- cwd: '/project/alpha',
807
- tty: 'ttys001',
805
+ command: "claude",
806
+ cwd: "/project/alpha",
807
+ tty: "ttys001",
808
808
  startTime
809
809
  },
810
810
  {
811
811
  pid: 55003,
812
- command: 'claude',
813
- cwd: '/project/beta',
814
- tty: 'ttys002',
812
+ command: "claude",
813
+ cwd: "/project/beta",
814
+ tty: "ttys002",
815
815
  startTime
816
816
  }
817
817
  ];
818
818
  mockedListAgentProcesses.mockReturnValue(processes);
819
819
  mockedEnrichProcesses.mockReturnValue(processes);
820
- const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'claude-mix-test-'));
821
- const sessionsDir = path.join(tmpDir, 'sessions');
822
- const projectsDir = path.join(tmpDir, 'projects');
823
- const projAlpha = path.join(projectsDir, '-project-alpha');
824
- const projBeta = path.join(projectsDir, '-project-beta');
820
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "claude-mix-test-"));
821
+ const sessionsDir = path.join(tmpDir, "sessions");
822
+ const projectsDir = path.join(tmpDir, "projects");
823
+ const projAlpha = path.join(projectsDir, "-project-alpha");
824
+ const projBeta = path.join(projectsDir, "-project-beta");
825
825
  fs.mkdirSync(sessionsDir, {
826
826
  recursive: true
827
827
  });
@@ -832,47 +832,47 @@ describe('ClaudeCodeAdapter', ()=>{
832
832
  recursive: true
833
833
  });
834
834
  // PID file only for process 55002
835
- const directSessionId = 'direct-session';
835
+ const directSessionId = "direct-session";
836
836
  const directJsonl = path.join(projAlpha, `${directSessionId}.jsonl`);
837
837
  fs.writeFileSync(directJsonl, [
838
838
  JSON.stringify({
839
- type: 'user',
839
+ type: "user",
840
840
  timestamp: new Date().toISOString(),
841
- cwd: '/project/alpha',
841
+ cwd: "/project/alpha",
842
842
  message: {
843
- content: 'direct question'
843
+ content: "direct question"
844
844
  }
845
845
  }),
846
846
  JSON.stringify({
847
- type: 'assistant',
847
+ type: "assistant",
848
848
  timestamp: new Date().toISOString()
849
849
  })
850
- ].join('\n'));
851
- fs.writeFileSync(path.join(sessionsDir, '55002.json'), JSON.stringify({
850
+ ].join("\n"));
851
+ fs.writeFileSync(path.join(sessionsDir, "55002.json"), JSON.stringify({
852
852
  pid: 55002,
853
853
  sessionId: directSessionId,
854
- cwd: '/project/alpha',
854
+ cwd: "/project/alpha",
855
855
  startedAt: startTime.getTime(),
856
- kind: 'interactive',
857
- entrypoint: 'cli'
856
+ kind: "interactive",
857
+ entrypoint: "cli"
858
858
  }));
859
859
  // Legacy session file for process 55003
860
- const legacySessionId = 'legacy-session';
860
+ const legacySessionId = "legacy-session";
861
861
  const legacyJsonl = path.join(projBeta, `${legacySessionId}.jsonl`);
862
862
  fs.writeFileSync(legacyJsonl, [
863
863
  JSON.stringify({
864
- type: 'user',
864
+ type: "user",
865
865
  timestamp: new Date().toISOString(),
866
- cwd: '/project/beta',
866
+ cwd: "/project/beta",
867
867
  message: {
868
- content: 'legacy question'
868
+ content: "legacy question"
869
869
  }
870
870
  }),
871
871
  JSON.stringify({
872
- type: 'assistant',
872
+ type: "assistant",
873
873
  timestamp: new Date().toISOString()
874
874
  })
875
- ].join('\n'));
875
+ ].join("\n"));
876
876
  adapter.sessionsDir = sessionsDir;
877
877
  adapter.projectsDir = projectsDir;
878
878
  // Mock legacy matching for process 55003
@@ -881,7 +881,7 @@ describe('ClaudeCodeAdapter', ()=>{
881
881
  filePath: legacyJsonl,
882
882
  projectDir: projBeta,
883
883
  birthtimeMs: startTime.getTime(),
884
- resolvedCwd: '/project/beta'
884
+ resolvedCwd: "/project/beta"
885
885
  };
886
886
  mockedBatchGetSessionFileBirthtimes.mockReturnValue([
887
887
  legacySessionFile
@@ -910,13 +910,13 @@ describe('ClaudeCodeAdapter', ()=>{
910
910
  });
911
911
  });
912
912
  });
913
- describe('helper methods', ()=>{
914
- describe('determineStatus', ()=>{
913
+ describe("helper methods", ()=>{
914
+ describe("determineStatus", ()=>{
915
915
  it('should return "unknown" for sessions with no last entry type', ()=>{
916
916
  const determineStatus = adapter.parser.determineStatus.bind(adapter.parser);
917
917
  const session = {
918
- sessionId: 'test',
919
- projectPath: '/test',
918
+ sessionId: "test",
919
+ projectPath: "/test",
920
920
  sessionStart: new Date(),
921
921
  lastActive: new Date(),
922
922
  isInterrupted: false
@@ -926,11 +926,11 @@ describe('ClaudeCodeAdapter', ()=>{
926
926
  it('should return "waiting" for assistant entries', ()=>{
927
927
  const determineStatus = adapter.parser.determineStatus.bind(adapter.parser);
928
928
  const session = {
929
- sessionId: 'test',
930
- projectPath: '/test',
929
+ sessionId: "test",
930
+ projectPath: "/test",
931
931
  sessionStart: new Date(),
932
932
  lastActive: new Date(),
933
- lastEntryType: 'assistant',
933
+ lastEntryType: "assistant",
934
934
  isInterrupted: false
935
935
  };
936
936
  expect(determineStatus(session)).toBe(AgentStatus.WAITING);
@@ -938,11 +938,11 @@ describe('ClaudeCodeAdapter', ()=>{
938
938
  it('should return "waiting" for user interruption', ()=>{
939
939
  const determineStatus = adapter.parser.determineStatus.bind(adapter.parser);
940
940
  const session = {
941
- sessionId: 'test',
942
- projectPath: '/test',
941
+ sessionId: "test",
942
+ projectPath: "/test",
943
943
  sessionStart: new Date(),
944
944
  lastActive: new Date(),
945
- lastEntryType: 'user',
945
+ lastEntryType: "user",
946
946
  isInterrupted: true
947
947
  };
948
948
  expect(determineStatus(session)).toBe(AgentStatus.WAITING);
@@ -950,24 +950,24 @@ describe('ClaudeCodeAdapter', ()=>{
950
950
  it('should return "running" for user/progress entries', ()=>{
951
951
  const determineStatus = adapter.parser.determineStatus.bind(adapter.parser);
952
952
  const session = {
953
- sessionId: 'test',
954
- projectPath: '/test',
953
+ sessionId: "test",
954
+ projectPath: "/test",
955
955
  sessionStart: new Date(),
956
956
  lastActive: new Date(),
957
- lastEntryType: 'user',
957
+ lastEntryType: "user",
958
958
  isInterrupted: false
959
959
  };
960
960
  expect(determineStatus(session)).toBe(AgentStatus.RUNNING);
961
961
  });
962
- it('should not override status based on age (process is running)', ()=>{
962
+ it("should not override status based on age (process is running)", ()=>{
963
963
  const determineStatus = adapter.parser.determineStatus.bind(adapter.parser);
964
964
  const oldDate = new Date(Date.now() - 10 * 60 * 1000);
965
965
  const session = {
966
- sessionId: 'test',
967
- projectPath: '/test',
966
+ sessionId: "test",
967
+ projectPath: "/test",
968
968
  sessionStart: oldDate,
969
969
  lastActive: oldDate,
970
- lastEntryType: 'assistant',
970
+ lastEntryType: "assistant",
971
971
  isInterrupted: false
972
972
  };
973
973
  expect(determineStatus(session)).toBe(AgentStatus.WAITING);
@@ -975,11 +975,11 @@ describe('ClaudeCodeAdapter', ()=>{
975
975
  it('should return "idle" for system entries', ()=>{
976
976
  const determineStatus = adapter.parser.determineStatus.bind(adapter.parser);
977
977
  const session = {
978
- sessionId: 'test',
979
- projectPath: '/test',
978
+ sessionId: "test",
979
+ projectPath: "/test",
980
980
  sessionStart: new Date(),
981
981
  lastActive: new Date(),
982
- lastEntryType: 'system',
982
+ lastEntryType: "system",
983
983
  isInterrupted: false
984
984
  };
985
985
  expect(determineStatus(session)).toBe(AgentStatus.IDLE);
@@ -987,11 +987,11 @@ describe('ClaudeCodeAdapter', ()=>{
987
987
  it('should return "running" for thinking entries', ()=>{
988
988
  const determineStatus = adapter.parser.determineStatus.bind(adapter.parser);
989
989
  const session = {
990
- sessionId: 'test',
991
- projectPath: '/test',
990
+ sessionId: "test",
991
+ projectPath: "/test",
992
992
  sessionStart: new Date(),
993
993
  lastActive: new Date(),
994
- lastEntryType: 'thinking',
994
+ lastEntryType: "thinking",
995
995
  isInterrupted: false
996
996
  };
997
997
  expect(determineStatus(session)).toBe(AgentStatus.RUNNING);
@@ -999,11 +999,11 @@ describe('ClaudeCodeAdapter', ()=>{
999
999
  it('should return "running" for progress entries', ()=>{
1000
1000
  const determineStatus = adapter.parser.determineStatus.bind(adapter.parser);
1001
1001
  const session = {
1002
- sessionId: 'test',
1003
- projectPath: '/test',
1002
+ sessionId: "test",
1003
+ projectPath: "/test",
1004
1004
  sessionStart: new Date(),
1005
1005
  lastActive: new Date(),
1006
- lastEntryType: 'progress',
1006
+ lastEntryType: "progress",
1007
1007
  isInterrupted: false
1008
1008
  };
1009
1009
  expect(determineStatus(session)).toBe(AgentStatus.RUNNING);
@@ -1011,80 +1011,80 @@ describe('ClaudeCodeAdapter', ()=>{
1011
1011
  it('should return "unknown" for unrecognized entry types', ()=>{
1012
1012
  const determineStatus = adapter.parser.determineStatus.bind(adapter.parser);
1013
1013
  const session = {
1014
- sessionId: 'test',
1015
- projectPath: '/test',
1014
+ sessionId: "test",
1015
+ projectPath: "/test",
1016
1016
  sessionStart: new Date(),
1017
1017
  lastActive: new Date(),
1018
- lastEntryType: 'some_other_type',
1018
+ lastEntryType: "some_other_type",
1019
1019
  isInterrupted: false
1020
1020
  };
1021
1021
  expect(determineStatus(session)).toBe(AgentStatus.UNKNOWN);
1022
1022
  });
1023
1023
  });
1024
- describe('extractUserMessageText', ()=>{
1025
- it('should extract plain string content', ()=>{
1026
- const extract = adapter.parser['extractUserMessageText'].bind(adapter.parser);
1027
- expect(extract('hello world')).toBe('hello world');
1024
+ describe("extractUserMessageText", ()=>{
1025
+ it("should extract plain string content", ()=>{
1026
+ const extract = adapter.parser["extractUserMessageText"].bind(adapter.parser);
1027
+ expect(extract("hello world")).toBe("hello world");
1028
1028
  });
1029
- it('should extract text from array content blocks', ()=>{
1030
- const extract = adapter.parser['extractUserMessageText'].bind(adapter.parser);
1029
+ it("should extract text from array content blocks", ()=>{
1030
+ const extract = adapter.parser["extractUserMessageText"].bind(adapter.parser);
1031
1031
  const content = [
1032
1032
  {
1033
- type: 'tool_result',
1034
- content: 'some result'
1033
+ type: "tool_result",
1034
+ content: "some result"
1035
1035
  },
1036
1036
  {
1037
- type: 'text',
1038
- text: 'user question'
1037
+ type: "text",
1038
+ text: "user question"
1039
1039
  }
1040
1040
  ];
1041
- expect(extract(content)).toBe('user question');
1041
+ expect(extract(content)).toBe("user question");
1042
1042
  });
1043
- it('should return undefined for empty/null content', ()=>{
1044
- const extract = adapter.parser['extractUserMessageText'].bind(adapter.parser);
1043
+ it("should return undefined for empty/null content", ()=>{
1044
+ const extract = adapter.parser["extractUserMessageText"].bind(adapter.parser);
1045
1045
  expect(extract(undefined)).toBeUndefined();
1046
- expect(extract('')).toBeUndefined();
1046
+ expect(extract("")).toBeUndefined();
1047
1047
  expect(extract([])).toBeUndefined();
1048
1048
  });
1049
- it('should parse command-message tags', ()=>{
1050
- const extract = adapter.parser['extractUserMessageText'].bind(adapter.parser);
1051
- const msg = '<command-message><command-name>commit</command-name><command-args>fix bug</command-args></command-message>';
1052
- expect(extract(msg)).toBe('commit fix bug');
1049
+ it("should parse command-message tags", ()=>{
1050
+ const extract = adapter.parser["extractUserMessageText"].bind(adapter.parser);
1051
+ const msg = "<command-message><command-name>commit</command-name><command-args>fix bug</command-args></command-message>";
1052
+ expect(extract(msg)).toBe("commit fix bug");
1053
1053
  });
1054
- it('should parse command-message without args', ()=>{
1055
- const extract = adapter.parser['extractUserMessageText'].bind(adapter.parser);
1056
- const msg = '<command-message><command-name>help</command-name></command-message>';
1057
- expect(extract(msg)).toBe('help');
1054
+ it("should parse command-message without args", ()=>{
1055
+ const extract = adapter.parser["extractUserMessageText"].bind(adapter.parser);
1056
+ const msg = "<command-message><command-name>help</command-name></command-message>";
1057
+ expect(extract(msg)).toBe("help");
1058
1058
  });
1059
- it('should extract ARGUMENTS from skill expansion', ()=>{
1060
- const extract = adapter.parser['extractUserMessageText'].bind(adapter.parser);
1061
- const msg = 'Base directory for this skill: /some/path\n\nSome instructions\n\nARGUMENTS: implement the feature';
1062
- expect(extract(msg)).toBe('implement the feature');
1059
+ it("should extract ARGUMENTS from skill expansion", ()=>{
1060
+ const extract = adapter.parser["extractUserMessageText"].bind(adapter.parser);
1061
+ const msg = "Base directory for this skill: /some/path\n\nSome instructions\n\nARGUMENTS: implement the feature";
1062
+ expect(extract(msg)).toBe("implement the feature");
1063
1063
  });
1064
- it('should return undefined for skill expansion without ARGUMENTS', ()=>{
1065
- const extract = adapter.parser['extractUserMessageText'].bind(adapter.parser);
1066
- const msg = 'Base directory for this skill: /some/path\n\nSome instructions only';
1064
+ it("should return undefined for skill expansion without ARGUMENTS", ()=>{
1065
+ const extract = adapter.parser["extractUserMessageText"].bind(adapter.parser);
1066
+ const msg = "Base directory for this skill: /some/path\n\nSome instructions only";
1067
1067
  expect(extract(msg)).toBeUndefined();
1068
1068
  });
1069
- it('should filter noise messages', ()=>{
1070
- const extract = adapter.parser['extractUserMessageText'].bind(adapter.parser);
1071
- expect(extract('[Request interrupted by user]')).toBeUndefined();
1072
- expect(extract('Tool loaded.')).toBeUndefined();
1073
- expect(extract('This session is being continued from a previous conversation')).toBeUndefined();
1069
+ it("should filter noise messages", ()=>{
1070
+ const extract = adapter.parser["extractUserMessageText"].bind(adapter.parser);
1071
+ expect(extract("[Request interrupted by user]")).toBeUndefined();
1072
+ expect(extract("Tool loaded.")).toBeUndefined();
1073
+ expect(extract("This session is being continued from a previous conversation")).toBeUndefined();
1074
1074
  });
1075
1075
  });
1076
- describe('parseCommandMessage', ()=>{
1077
- it('should return undefined for malformed command-message', ()=>{
1078
- const parse = adapter.parser['parseCommandMessage'].bind(adapter.parser);
1079
- expect(parse('<command-message>no tags</command-message>')).toBeUndefined();
1076
+ describe("parseCommandMessage", ()=>{
1077
+ it("should return undefined for malformed command-message", ()=>{
1078
+ const parse = adapter.parser["parseCommandMessage"].bind(adapter.parser);
1079
+ expect(parse("<command-message>no tags</command-message>")).toBeUndefined();
1080
1080
  });
1081
1081
  });
1082
1082
  });
1083
- describe('file I/O methods', ()=>{
1083
+ describe("file I/O methods", ()=>{
1084
1084
  let tmpDir;
1085
1085
  beforeEach(()=>{
1086
- tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'claude-test-'));
1087
- adapter.projectsDir = path.join(tmpDir, 'projects');
1086
+ tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "claude-test-"));
1087
+ adapter.projectsDir = path.join(tmpDir, "projects");
1088
1088
  });
1089
1089
  afterEach(()=>{
1090
1090
  fs.rmSync(tmpDir, {
@@ -1092,197 +1092,197 @@ describe('ClaudeCodeAdapter', ()=>{
1092
1092
  force: true
1093
1093
  });
1094
1094
  });
1095
- describe('readSession', ()=>{
1096
- it('should parse session file with timestamps, cwd, and entry type', ()=>{
1095
+ describe("readSession", ()=>{
1096
+ it("should parse session file with timestamps, cwd, and entry type", ()=>{
1097
1097
  const readSession = adapter.parser.readSession.bind(adapter.parser);
1098
- const filePath = path.join(tmpDir, 'test-session.jsonl');
1098
+ const filePath = path.join(tmpDir, "test-session.jsonl");
1099
1099
  const lines = [
1100
1100
  JSON.stringify({
1101
- type: 'user',
1102
- timestamp: '2026-03-10T10:00:00Z',
1103
- cwd: '/my/project'
1101
+ type: "user",
1102
+ timestamp: "2026-03-10T10:00:00Z",
1103
+ cwd: "/my/project"
1104
1104
  }),
1105
1105
  JSON.stringify({
1106
- type: 'assistant',
1107
- timestamp: '2026-03-10T10:01:00Z'
1106
+ type: "assistant",
1107
+ timestamp: "2026-03-10T10:01:00Z"
1108
1108
  })
1109
1109
  ];
1110
- fs.writeFileSync(filePath, lines.join('\n'));
1111
- const session = readSession(filePath, '/my/project');
1110
+ fs.writeFileSync(filePath, lines.join("\n"));
1111
+ const session = readSession(filePath, "/my/project");
1112
1112
  expect(session).toMatchObject({
1113
- sessionId: 'test-session',
1114
- projectPath: '/my/project',
1115
- lastCwd: '/my/project',
1116
- lastEntryType: 'assistant',
1113
+ sessionId: "test-session",
1114
+ projectPath: "/my/project",
1115
+ lastCwd: "/my/project",
1116
+ lastEntryType: "assistant",
1117
1117
  isInterrupted: false
1118
1118
  });
1119
- expect(session.sessionStart.toISOString()).toBe('2026-03-10T10:00:00.000Z');
1120
- expect(session.lastActive.toISOString()).toBe('2026-03-10T10:01:00.000Z');
1119
+ expect(session.sessionStart.toISOString()).toBe("2026-03-10T10:00:00.000Z");
1120
+ expect(session.lastActive.toISOString()).toBe("2026-03-10T10:01:00.000Z");
1121
1121
  });
1122
- it('should detect user interruption', ()=>{
1122
+ it("should detect user interruption", ()=>{
1123
1123
  const readSession = adapter.parser.readSession.bind(adapter.parser);
1124
- const filePath = path.join(tmpDir, 'interrupted.jsonl');
1124
+ const filePath = path.join(tmpDir, "interrupted.jsonl");
1125
1125
  const lines = [
1126
1126
  JSON.stringify({
1127
- type: 'user',
1128
- timestamp: '2026-03-10T10:00:00Z',
1127
+ type: "user",
1128
+ timestamp: "2026-03-10T10:00:00Z",
1129
1129
  message: {
1130
1130
  content: [
1131
1131
  {
1132
- type: 'text',
1133
- text: '[Request interrupted by user for tool use]'
1132
+ type: "text",
1133
+ text: "[Request interrupted by user for tool use]"
1134
1134
  }
1135
1135
  ]
1136
1136
  }
1137
1137
  })
1138
1138
  ];
1139
- fs.writeFileSync(filePath, lines.join('\n'));
1140
- const session = readSession(filePath, '/test');
1139
+ fs.writeFileSync(filePath, lines.join("\n"));
1140
+ const session = readSession(filePath, "/test");
1141
1141
  expect(session.isInterrupted).toBe(true);
1142
- expect(session.lastEntryType).toBe('user');
1142
+ expect(session.lastEntryType).toBe("user");
1143
1143
  });
1144
- it('should return session with defaults for empty file', ()=>{
1144
+ it("should return session with defaults for empty file", ()=>{
1145
1145
  const readSession = adapter.parser.readSession.bind(adapter.parser);
1146
- const filePath = path.join(tmpDir, 'empty.jsonl');
1147
- fs.writeFileSync(filePath, '');
1148
- const session = readSession(filePath, '/test');
1146
+ const filePath = path.join(tmpDir, "empty.jsonl");
1147
+ fs.writeFileSync(filePath, "");
1148
+ const session = readSession(filePath, "/test");
1149
1149
  expect(session).not.toBeNull();
1150
1150
  expect(session.lastEntryType).toBeUndefined();
1151
1151
  });
1152
- it('should return null for non-existent file', ()=>{
1152
+ it("should return null for non-existent file", ()=>{
1153
1153
  const readSession = adapter.parser.readSession.bind(adapter.parser);
1154
- expect(readSession(path.join(tmpDir, 'nonexistent.jsonl'), '/test')).toBeNull();
1154
+ expect(readSession(path.join(tmpDir, "nonexistent.jsonl"), "/test")).toBeNull();
1155
1155
  });
1156
- it('should skip metadata entry types for lastEntryType', ()=>{
1156
+ it("should skip metadata entry types for lastEntryType", ()=>{
1157
1157
  const readSession = adapter.parser.readSession.bind(adapter.parser);
1158
- const filePath = path.join(tmpDir, 'metadata-test.jsonl');
1158
+ const filePath = path.join(tmpDir, "metadata-test.jsonl");
1159
1159
  const lines = [
1160
1160
  JSON.stringify({
1161
- type: 'user',
1162
- timestamp: '2026-03-10T10:00:00Z',
1161
+ type: "user",
1162
+ timestamp: "2026-03-10T10:00:00Z",
1163
1163
  message: {
1164
- content: 'hello'
1164
+ content: "hello"
1165
1165
  }
1166
1166
  }),
1167
1167
  JSON.stringify({
1168
- type: 'assistant',
1169
- timestamp: '2026-03-10T10:01:00Z'
1168
+ type: "assistant",
1169
+ timestamp: "2026-03-10T10:01:00Z"
1170
1170
  }),
1171
1171
  JSON.stringify({
1172
- type: 'last-prompt',
1173
- timestamp: '2026-03-10T10:02:00Z'
1172
+ type: "last-prompt",
1173
+ timestamp: "2026-03-10T10:02:00Z"
1174
1174
  }),
1175
1175
  JSON.stringify({
1176
- type: 'file-history-snapshot',
1177
- timestamp: '2026-03-10T10:03:00Z'
1176
+ type: "file-history-snapshot",
1177
+ timestamp: "2026-03-10T10:03:00Z"
1178
1178
  })
1179
1179
  ];
1180
- fs.writeFileSync(filePath, lines.join('\n'));
1181
- const session = readSession(filePath, '/test');
1182
- expect(session.lastEntryType).toBe('assistant');
1180
+ fs.writeFileSync(filePath, lines.join("\n"));
1181
+ const session = readSession(filePath, "/test");
1182
+ expect(session.lastEntryType).toBe("assistant");
1183
1183
  });
1184
- it('should parse snapshot.timestamp from file-history-snapshot first entry', ()=>{
1184
+ it("should parse snapshot.timestamp from file-history-snapshot first entry", ()=>{
1185
1185
  const readSession = adapter.parser.readSession.bind(adapter.parser);
1186
- const filePath = path.join(tmpDir, 'snapshot-ts.jsonl');
1186
+ const filePath = path.join(tmpDir, "snapshot-ts.jsonl");
1187
1187
  const lines = [
1188
1188
  JSON.stringify({
1189
- type: 'file-history-snapshot',
1189
+ type: "file-history-snapshot",
1190
1190
  snapshot: {
1191
- timestamp: '2026-03-10T09:55:00Z',
1191
+ timestamp: "2026-03-10T09:55:00Z",
1192
1192
  files: []
1193
1193
  }
1194
1194
  }),
1195
1195
  JSON.stringify({
1196
- type: 'user',
1197
- timestamp: '2026-03-10T10:00:00Z',
1196
+ type: "user",
1197
+ timestamp: "2026-03-10T10:00:00Z",
1198
1198
  message: {
1199
- content: 'test'
1199
+ content: "test"
1200
1200
  }
1201
1201
  }),
1202
1202
  JSON.stringify({
1203
- type: 'assistant',
1204
- timestamp: '2026-03-10T10:01:00Z'
1203
+ type: "assistant",
1204
+ timestamp: "2026-03-10T10:01:00Z"
1205
1205
  })
1206
1206
  ];
1207
- fs.writeFileSync(filePath, lines.join('\n'));
1208
- const session = readSession(filePath, '/test');
1209
- expect(session.sessionStart.toISOString()).toBe('2026-03-10T09:55:00.000Z');
1210
- expect(session.lastActive.toISOString()).toBe('2026-03-10T10:01:00.000Z');
1207
+ fs.writeFileSync(filePath, lines.join("\n"));
1208
+ const session = readSession(filePath, "/test");
1209
+ expect(session.sessionStart.toISOString()).toBe("2026-03-10T09:55:00.000Z");
1210
+ expect(session.lastActive.toISOString()).toBe("2026-03-10T10:01:00.000Z");
1211
1211
  });
1212
- it('should extract lastUserMessage from session entries', ()=>{
1212
+ it("should extract lastUserMessage from session entries", ()=>{
1213
1213
  const readSession = adapter.parser.readSession.bind(adapter.parser);
1214
- const filePath = path.join(tmpDir, 'user-msg.jsonl');
1214
+ const filePath = path.join(tmpDir, "user-msg.jsonl");
1215
1215
  const lines = [
1216
1216
  JSON.stringify({
1217
- type: 'user',
1218
- timestamp: '2026-03-10T10:00:00Z',
1217
+ type: "user",
1218
+ timestamp: "2026-03-10T10:00:00Z",
1219
1219
  message: {
1220
- content: 'first question'
1220
+ content: "first question"
1221
1221
  }
1222
1222
  }),
1223
1223
  JSON.stringify({
1224
- type: 'assistant',
1225
- timestamp: '2026-03-10T10:01:00Z'
1224
+ type: "assistant",
1225
+ timestamp: "2026-03-10T10:01:00Z"
1226
1226
  }),
1227
1227
  JSON.stringify({
1228
- type: 'user',
1229
- timestamp: '2026-03-10T10:02:00Z',
1228
+ type: "user",
1229
+ timestamp: "2026-03-10T10:02:00Z",
1230
1230
  message: {
1231
1231
  content: [
1232
1232
  {
1233
- type: 'text',
1234
- text: 'second question'
1233
+ type: "text",
1234
+ text: "second question"
1235
1235
  }
1236
1236
  ]
1237
1237
  }
1238
1238
  }),
1239
1239
  JSON.stringify({
1240
- type: 'assistant',
1241
- timestamp: '2026-03-10T10:03:00Z'
1240
+ type: "assistant",
1241
+ timestamp: "2026-03-10T10:03:00Z"
1242
1242
  })
1243
1243
  ];
1244
- fs.writeFileSync(filePath, lines.join('\n'));
1245
- const session = readSession(filePath, '/test');
1246
- expect(session.lastUserMessage).toBe('second question');
1244
+ fs.writeFileSync(filePath, lines.join("\n"));
1245
+ const session = readSession(filePath, "/test");
1246
+ expect(session.lastUserMessage).toBe("second question");
1247
1247
  });
1248
- it('should use lastCwd as projectPath when projectPath is empty', ()=>{
1248
+ it("should use lastCwd as projectPath when projectPath is empty", ()=>{
1249
1249
  const readSession = adapter.parser.readSession.bind(adapter.parser);
1250
- const filePath = path.join(tmpDir, 'no-project.jsonl');
1250
+ const filePath = path.join(tmpDir, "no-project.jsonl");
1251
1251
  const lines = [
1252
1252
  JSON.stringify({
1253
- type: 'user',
1254
- timestamp: '2026-03-10T10:00:00Z',
1255
- cwd: '/derived/path',
1253
+ type: "user",
1254
+ timestamp: "2026-03-10T10:00:00Z",
1255
+ cwd: "/derived/path",
1256
1256
  message: {
1257
- content: 'test'
1257
+ content: "test"
1258
1258
  }
1259
1259
  })
1260
1260
  ];
1261
- fs.writeFileSync(filePath, lines.join('\n'));
1262
- const session = readSession(filePath, '');
1263
- expect(session.projectPath).toBe('/derived/path');
1261
+ fs.writeFileSync(filePath, lines.join("\n"));
1262
+ const session = readSession(filePath, "");
1263
+ expect(session.projectPath).toBe("/derived/path");
1264
1264
  });
1265
- it('should handle malformed JSON lines gracefully', ()=>{
1265
+ it("should handle malformed JSON lines gracefully", ()=>{
1266
1266
  const readSession = adapter.parser.readSession.bind(adapter.parser);
1267
- const filePath = path.join(tmpDir, 'malformed.jsonl');
1267
+ const filePath = path.join(tmpDir, "malformed.jsonl");
1268
1268
  const lines = [
1269
- 'not json',
1269
+ "not json",
1270
1270
  JSON.stringify({
1271
- type: 'assistant',
1272
- timestamp: '2026-03-10T10:00:00Z'
1271
+ type: "assistant",
1272
+ timestamp: "2026-03-10T10:00:00Z"
1273
1273
  })
1274
1274
  ];
1275
- fs.writeFileSync(filePath, lines.join('\n'));
1276
- const session = readSession(filePath, '/test');
1275
+ fs.writeFileSync(filePath, lines.join("\n"));
1276
+ const session = readSession(filePath, "/test");
1277
1277
  expect(session).not.toBeNull();
1278
- expect(session.lastEntryType).toBe('assistant');
1278
+ expect(session.lastEntryType).toBe("assistant");
1279
1279
  });
1280
1280
  });
1281
1281
  });
1282
- describe('getConversation', ()=>{
1282
+ describe("getConversation", ()=>{
1283
1283
  let tmpDir;
1284
1284
  beforeEach(()=>{
1285
- tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'claude-conv-'));
1285
+ tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "claude-conv-"));
1286
1286
  });
1287
1287
  afterEach(()=>{
1288
1288
  fs.rmSync(tmpDir, {
@@ -1291,27 +1291,27 @@ describe('ClaudeCodeAdapter', ()=>{
1291
1291
  });
1292
1292
  });
1293
1293
  function writeJsonl(lines) {
1294
- const filePath = path.join(tmpDir, 'session.jsonl');
1295
- fs.writeFileSync(filePath, lines.map((l)=>JSON.stringify(l)).join('\n'));
1294
+ const filePath = path.join(tmpDir, "session.jsonl");
1295
+ fs.writeFileSync(filePath, lines.map((l)=>JSON.stringify(l)).join("\n"));
1296
1296
  return filePath;
1297
1297
  }
1298
- it('should parse user and assistant text messages', ()=>{
1298
+ it("should parse user and assistant text messages", ()=>{
1299
1299
  const filePath = writeJsonl([
1300
1300
  {
1301
- type: 'user',
1302
- timestamp: '2026-03-27T10:00:00Z',
1301
+ type: "user",
1302
+ timestamp: "2026-03-27T10:00:00Z",
1303
1303
  message: {
1304
- content: 'Hello'
1304
+ content: "Hello"
1305
1305
  }
1306
1306
  },
1307
1307
  {
1308
- type: 'assistant',
1309
- timestamp: '2026-03-27T10:00:05Z',
1308
+ type: "assistant",
1309
+ timestamp: "2026-03-27T10:00:05Z",
1310
1310
  message: {
1311
1311
  content: [
1312
1312
  {
1313
- type: 'text',
1314
- text: 'Hi there!'
1313
+ type: "text",
1314
+ text: "Hi there!"
1315
1315
  }
1316
1316
  ]
1317
1317
  }
@@ -1320,65 +1320,65 @@ describe('ClaudeCodeAdapter', ()=>{
1320
1320
  const messages = adapter.getConversation(filePath);
1321
1321
  expect(messages).toHaveLength(2);
1322
1322
  expect(messages[0]).toEqual({
1323
- role: 'user',
1324
- content: 'Hello',
1325
- timestamp: '2026-03-27T10:00:00Z'
1323
+ role: "user",
1324
+ content: "Hello",
1325
+ timestamp: "2026-03-27T10:00:00Z"
1326
1326
  });
1327
1327
  expect(messages[1]).toEqual({
1328
- role: 'assistant',
1329
- content: 'Hi there!',
1330
- timestamp: '2026-03-27T10:00:05Z'
1328
+ role: "assistant",
1329
+ content: "Hi there!",
1330
+ timestamp: "2026-03-27T10:00:05Z"
1331
1331
  });
1332
1332
  });
1333
- it('should skip metadata entry types', ()=>{
1333
+ it("should skip metadata entry types", ()=>{
1334
1334
  const filePath = writeJsonl([
1335
1335
  {
1336
- type: 'file-history-snapshot',
1337
- timestamp: '2026-03-27T10:00:00Z',
1336
+ type: "file-history-snapshot",
1337
+ timestamp: "2026-03-27T10:00:00Z",
1338
1338
  snapshot: {}
1339
1339
  },
1340
1340
  {
1341
- type: 'last-prompt',
1342
- timestamp: '2026-03-27T10:00:00Z'
1341
+ type: "last-prompt",
1342
+ timestamp: "2026-03-27T10:00:00Z"
1343
1343
  },
1344
1344
  {
1345
- type: 'user',
1346
- timestamp: '2026-03-27T10:00:01Z',
1345
+ type: "user",
1346
+ timestamp: "2026-03-27T10:00:01Z",
1347
1347
  message: {
1348
- content: 'Fix bug'
1348
+ content: "Fix bug"
1349
1349
  }
1350
1350
  }
1351
1351
  ]);
1352
1352
  const messages = adapter.getConversation(filePath);
1353
1353
  expect(messages).toHaveLength(1);
1354
- expect(messages[0].content).toBe('Fix bug');
1354
+ expect(messages[0].content).toBe("Fix bug");
1355
1355
  });
1356
- it('should skip progress and thinking entries', ()=>{
1356
+ it("should skip progress and thinking entries", ()=>{
1357
1357
  const filePath = writeJsonl([
1358
1358
  {
1359
- type: 'user',
1360
- timestamp: '2026-03-27T10:00:00Z',
1359
+ type: "user",
1360
+ timestamp: "2026-03-27T10:00:00Z",
1361
1361
  message: {
1362
- content: 'Hello'
1362
+ content: "Hello"
1363
1363
  }
1364
1364
  },
1365
1365
  {
1366
- type: 'progress',
1367
- timestamp: '2026-03-27T10:00:01Z',
1366
+ type: "progress",
1367
+ timestamp: "2026-03-27T10:00:01Z",
1368
1368
  data: {}
1369
1369
  },
1370
1370
  {
1371
- type: 'thinking',
1372
- timestamp: '2026-03-27T10:00:02Z'
1371
+ type: "thinking",
1372
+ timestamp: "2026-03-27T10:00:02Z"
1373
1373
  },
1374
1374
  {
1375
- type: 'assistant',
1376
- timestamp: '2026-03-27T10:00:03Z',
1375
+ type: "assistant",
1376
+ timestamp: "2026-03-27T10:00:03Z",
1377
1377
  message: {
1378
1378
  content: [
1379
1379
  {
1380
- type: 'text',
1381
- text: 'Done'
1380
+ type: "text",
1381
+ text: "Done"
1382
1382
  }
1383
1383
  ]
1384
1384
  }
@@ -1386,57 +1386,57 @@ describe('ClaudeCodeAdapter', ()=>{
1386
1386
  ]);
1387
1387
  const messages = adapter.getConversation(filePath);
1388
1388
  expect(messages).toHaveLength(2);
1389
- expect(messages[0].role).toBe('user');
1390
- expect(messages[1].role).toBe('assistant');
1389
+ expect(messages[0].role).toBe("user");
1390
+ expect(messages[1].role).toBe("assistant");
1391
1391
  });
1392
- it('should include system messages', ()=>{
1392
+ it("should include system messages", ()=>{
1393
1393
  const filePath = writeJsonl([
1394
1394
  {
1395
- type: 'system',
1396
- timestamp: '2026-03-27T10:00:00Z',
1395
+ type: "system",
1396
+ timestamp: "2026-03-27T10:00:00Z",
1397
1397
  message: {
1398
- content: 'System initialized'
1398
+ content: "System initialized"
1399
1399
  }
1400
1400
  }
1401
1401
  ]);
1402
1402
  const messages = adapter.getConversation(filePath);
1403
1403
  expect(messages).toHaveLength(1);
1404
1404
  expect(messages[0]).toEqual({
1405
- role: 'system',
1406
- content: 'System initialized',
1407
- timestamp: '2026-03-27T10:00:00Z'
1405
+ role: "system",
1406
+ content: "System initialized",
1407
+ timestamp: "2026-03-27T10:00:00Z"
1408
1408
  });
1409
1409
  });
1410
- it('should skip tool_use and tool_result blocks in default mode', ()=>{
1410
+ it("should skip tool_use and tool_result blocks in default mode", ()=>{
1411
1411
  const filePath = writeJsonl([
1412
1412
  {
1413
- type: 'assistant',
1414
- timestamp: '2026-03-27T10:00:00Z',
1413
+ type: "assistant",
1414
+ timestamp: "2026-03-27T10:00:00Z",
1415
1415
  message: {
1416
1416
  content: [
1417
1417
  {
1418
- type: 'text',
1419
- text: 'Let me read the file.'
1418
+ type: "text",
1419
+ text: "Let me read the file."
1420
1420
  },
1421
1421
  {
1422
- type: 'tool_use',
1423
- name: 'Read',
1422
+ type: "tool_use",
1423
+ name: "Read",
1424
1424
  input: {
1425
- file_path: '/src/app.ts'
1425
+ file_path: "/src/app.ts"
1426
1426
  }
1427
1427
  }
1428
1428
  ]
1429
1429
  }
1430
1430
  },
1431
1431
  {
1432
- type: 'user',
1433
- timestamp: '2026-03-27T10:00:01Z',
1432
+ type: "user",
1433
+ timestamp: "2026-03-27T10:00:01Z",
1434
1434
  message: {
1435
1435
  content: [
1436
1436
  {
1437
- type: 'tool_result',
1438
- tool_use_id: 'toolu_1',
1439
- content: 'file contents here'
1437
+ type: "tool_result",
1438
+ tool_use_id: "toolu_1",
1439
+ content: "file contents here"
1440
1440
  }
1441
1441
  ]
1442
1442
  }
@@ -1444,38 +1444,38 @@ describe('ClaudeCodeAdapter', ()=>{
1444
1444
  ]);
1445
1445
  const messages = adapter.getConversation(filePath);
1446
1446
  expect(messages).toHaveLength(1);
1447
- expect(messages[0].content).toBe('Let me read the file.');
1447
+ expect(messages[0].content).toBe("Let me read the file.");
1448
1448
  });
1449
- it('should include tool_use and tool_result blocks in verbose mode', ()=>{
1449
+ it("should include tool_use and tool_result blocks in verbose mode", ()=>{
1450
1450
  const filePath = writeJsonl([
1451
1451
  {
1452
- type: 'assistant',
1453
- timestamp: '2026-03-27T10:00:00Z',
1452
+ type: "assistant",
1453
+ timestamp: "2026-03-27T10:00:00Z",
1454
1454
  message: {
1455
1455
  content: [
1456
1456
  {
1457
- type: 'text',
1458
- text: 'Let me read the file.'
1457
+ type: "text",
1458
+ text: "Let me read the file."
1459
1459
  },
1460
1460
  {
1461
- type: 'tool_use',
1462
- name: 'Read',
1461
+ type: "tool_use",
1462
+ name: "Read",
1463
1463
  input: {
1464
- file_path: '/src/app.ts'
1464
+ file_path: "/src/app.ts"
1465
1465
  }
1466
1466
  }
1467
1467
  ]
1468
1468
  }
1469
1469
  },
1470
1470
  {
1471
- type: 'user',
1472
- timestamp: '2026-03-27T10:00:01Z',
1471
+ type: "user",
1472
+ timestamp: "2026-03-27T10:00:01Z",
1473
1473
  message: {
1474
1474
  content: [
1475
1475
  {
1476
- type: 'tool_result',
1477
- tool_use_id: 'toolu_1',
1478
- content: 'file contents here'
1476
+ type: "tool_result",
1477
+ tool_use_id: "toolu_1",
1478
+ content: "file contents here"
1479
1479
  }
1480
1480
  ]
1481
1481
  }
@@ -1485,21 +1485,21 @@ describe('ClaudeCodeAdapter', ()=>{
1485
1485
  verbose: true
1486
1486
  });
1487
1487
  expect(messages).toHaveLength(2);
1488
- expect(messages[0].content).toContain('[Tool: Read]');
1489
- expect(messages[0].content).toContain('/src/app.ts');
1490
- expect(messages[1].content).toContain('[Tool Result]');
1488
+ expect(messages[0].content).toContain("[Tool: Read]");
1489
+ expect(messages[0].content).toContain("/src/app.ts");
1490
+ expect(messages[1].content).toContain("[Tool Result]");
1491
1491
  });
1492
- it('should handle tool_result errors in verbose mode', ()=>{
1492
+ it("should handle tool_result errors in verbose mode", ()=>{
1493
1493
  const filePath = writeJsonl([
1494
1494
  {
1495
- type: 'user',
1496
- timestamp: '2026-03-27T10:00:00Z',
1495
+ type: "user",
1496
+ timestamp: "2026-03-27T10:00:00Z",
1497
1497
  message: {
1498
1498
  content: [
1499
1499
  {
1500
- type: 'tool_result',
1501
- tool_use_id: 'toolu_1',
1502
- content: 'Something went wrong',
1500
+ type: "tool_result",
1501
+ tool_use_id: "toolu_1",
1502
+ content: "Something went wrong",
1503
1503
  is_error: true
1504
1504
  }
1505
1505
  ]
@@ -1510,85 +1510,85 @@ describe('ClaudeCodeAdapter', ()=>{
1510
1510
  verbose: true
1511
1511
  });
1512
1512
  expect(messages).toHaveLength(1);
1513
- expect(messages[0].content).toContain('[Tool Error]');
1513
+ expect(messages[0].content).toContain("[Tool Error]");
1514
1514
  });
1515
- it('should handle malformed JSON lines gracefully', ()=>{
1516
- const filePath = path.join(tmpDir, 'malformed.jsonl');
1515
+ it("should handle malformed JSON lines gracefully", ()=>{
1516
+ const filePath = path.join(tmpDir, "malformed.jsonl");
1517
1517
  fs.writeFileSync(filePath, [
1518
1518
  JSON.stringify({
1519
- type: 'user',
1520
- timestamp: '2026-03-27T10:00:00Z',
1519
+ type: "user",
1520
+ timestamp: "2026-03-27T10:00:00Z",
1521
1521
  message: {
1522
- content: 'Hello'
1522
+ content: "Hello"
1523
1523
  }
1524
1524
  }),
1525
- 'this is not valid json',
1525
+ "this is not valid json",
1526
1526
  JSON.stringify({
1527
- type: 'assistant',
1528
- timestamp: '2026-03-27T10:00:01Z',
1527
+ type: "assistant",
1528
+ timestamp: "2026-03-27T10:00:01Z",
1529
1529
  message: {
1530
1530
  content: [
1531
1531
  {
1532
- type: 'text',
1533
- text: 'World'
1532
+ type: "text",
1533
+ text: "World"
1534
1534
  }
1535
1535
  ]
1536
1536
  }
1537
1537
  })
1538
- ].join('\n'));
1538
+ ].join("\n"));
1539
1539
  const messages = adapter.getConversation(filePath);
1540
1540
  expect(messages).toHaveLength(2);
1541
1541
  });
1542
- it('should return empty array for missing file', ()=>{
1543
- const messages = adapter.getConversation('/nonexistent/path.jsonl');
1542
+ it("should return empty array for missing file", ()=>{
1543
+ const messages = adapter.getConversation("/nonexistent/path.jsonl");
1544
1544
  expect(messages).toEqual([]);
1545
1545
  });
1546
- it('should return empty array for empty file', ()=>{
1547
- const filePath = path.join(tmpDir, 'empty.jsonl');
1548
- fs.writeFileSync(filePath, '');
1546
+ it("should return empty array for empty file", ()=>{
1547
+ const filePath = path.join(tmpDir, "empty.jsonl");
1548
+ fs.writeFileSync(filePath, "");
1549
1549
  const messages = adapter.getConversation(filePath);
1550
1550
  expect(messages).toEqual([]);
1551
1551
  });
1552
- it('should filter noise messages from user entries', ()=>{
1552
+ it("should filter noise messages from user entries", ()=>{
1553
1553
  const filePath = writeJsonl([
1554
1554
  {
1555
- type: 'user',
1556
- timestamp: '2026-03-27T10:00:00Z',
1555
+ type: "user",
1556
+ timestamp: "2026-03-27T10:00:00Z",
1557
1557
  message: {
1558
1558
  content: [
1559
1559
  {
1560
- type: 'text',
1561
- text: '[Request interrupted by user]'
1560
+ type: "text",
1561
+ text: "[Request interrupted by user]"
1562
1562
  }
1563
1563
  ]
1564
1564
  }
1565
1565
  },
1566
1566
  {
1567
- type: 'user',
1568
- timestamp: '2026-03-27T10:00:01Z',
1567
+ type: "user",
1568
+ timestamp: "2026-03-27T10:00:01Z",
1569
1569
  message: {
1570
- content: 'Tool loaded.'
1570
+ content: "Tool loaded."
1571
1571
  }
1572
1572
  },
1573
1573
  {
1574
- type: 'user',
1575
- timestamp: '2026-03-27T10:00:02Z',
1574
+ type: "user",
1575
+ timestamp: "2026-03-27T10:00:02Z",
1576
1576
  message: {
1577
- content: 'Real question'
1577
+ content: "Real question"
1578
1578
  }
1579
1579
  }
1580
1580
  ]);
1581
1581
  const messages = adapter.getConversation(filePath);
1582
1582
  expect(messages).toHaveLength(1);
1583
- expect(messages[0].content).toBe('Real question');
1583
+ expect(messages[0].content).toBe("Real question");
1584
1584
  });
1585
1585
  });
1586
- describe('listSessions', ()=>{
1586
+ describe("listSessions", ()=>{
1587
1587
  let tmpDir;
1588
1588
  let projectsDir;
1589
1589
  beforeEach(()=>{
1590
- tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'claude-list-'));
1591
- projectsDir = path.join(tmpDir, 'projects');
1590
+ tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "claude-list-"));
1591
+ projectsDir = path.join(tmpDir, "projects");
1592
1592
  fs.mkdirSync(projectsDir, {
1593
1593
  recursive: true
1594
1594
  });
@@ -1605,10 +1605,10 @@ describe('ClaudeCodeAdapter', ()=>{
1605
1605
  recursive: true
1606
1606
  });
1607
1607
  const filePath = path.join(projectDir, `${sessionId}.jsonl`);
1608
- fs.writeFileSync(filePath, lines.map((l)=>JSON.stringify(l)).join('\n'));
1608
+ fs.writeFileSync(filePath, lines.map((l)=>JSON.stringify(l)).join("\n"));
1609
1609
  return filePath;
1610
1610
  }
1611
- it('returns empty when projects dir does not exist', async ()=>{
1611
+ it("returns empty when projects dir does not exist", async ()=>{
1612
1612
  fs.rmSync(projectsDir, {
1613
1613
  recursive: true,
1614
1614
  force: true
@@ -1616,21 +1616,21 @@ describe('ClaudeCodeAdapter', ()=>{
1616
1616
  const result = await adapter.listSessions();
1617
1617
  expect(result).toEqual([]);
1618
1618
  });
1619
- it('returns sessions from a single cwd-scoped project dir', async ()=>{
1620
- const cwd = '/Users/test/proj';
1621
- const projDir = path.join(projectsDir, '-Users-test-proj');
1622
- const filePath = writeSession(projDir, 'sess-1', [
1619
+ it("returns sessions from a single cwd-scoped project dir", async ()=>{
1620
+ const cwd = "/Users/test/proj";
1621
+ const projDir = path.join(projectsDir, "-Users-test-proj");
1622
+ const filePath = writeSession(projDir, "sess-1", [
1623
1623
  {
1624
- type: 'user',
1625
- timestamp: '2025-01-01T00:00:00Z',
1624
+ type: "user",
1625
+ timestamp: "2025-01-01T00:00:00Z",
1626
1626
  cwd,
1627
1627
  message: {
1628
- content: 'first prompt'
1628
+ content: "first prompt"
1629
1629
  }
1630
1630
  },
1631
1631
  {
1632
- type: 'assistant',
1633
- timestamp: '2025-01-01T00:01:00Z'
1632
+ type: "assistant",
1633
+ timestamp: "2025-01-01T00:01:00Z"
1634
1634
  }
1635
1635
  ]);
1636
1636
  const result = await adapter.listSessions({
@@ -1638,43 +1638,43 @@ describe('ClaudeCodeAdapter', ()=>{
1638
1638
  });
1639
1639
  expect(result).toHaveLength(1);
1640
1640
  expect(result[0]).toMatchObject({
1641
- type: 'claude',
1642
- sessionId: 'sess-1',
1641
+ type: "claude",
1642
+ sessionId: "sess-1",
1643
1643
  cwd,
1644
- firstUserMessage: 'first prompt',
1644
+ firstUserMessage: "first prompt",
1645
1645
  sessionFilePath: filePath
1646
1646
  });
1647
1647
  expect(result[0].lastActive).toBeInstanceOf(Date);
1648
1648
  expect(result[0].startedAt).toBeInstanceOf(Date);
1649
1649
  });
1650
- it('lists sessions from all project dirs when no cwd filter', async ()=>{
1651
- const cwdA = '/Users/test/proj-a';
1652
- const cwdB = '/Users/test/proj-b';
1653
- writeSession(path.join(projectsDir, '-Users-test-proj-a'), 'a', [
1650
+ it("lists sessions from all project dirs when no cwd filter", async ()=>{
1651
+ const cwdA = "/Users/test/proj-a";
1652
+ const cwdB = "/Users/test/proj-b";
1653
+ writeSession(path.join(projectsDir, "-Users-test-proj-a"), "a", [
1654
1654
  {
1655
- type: 'user',
1656
- timestamp: '2025-01-01T00:00:00Z',
1655
+ type: "user",
1656
+ timestamp: "2025-01-01T00:00:00Z",
1657
1657
  cwd: cwdA,
1658
1658
  message: {
1659
- content: 'msg-a'
1659
+ content: "msg-a"
1660
1660
  }
1661
1661
  }
1662
1662
  ]);
1663
- writeSession(path.join(projectsDir, '-Users-test-proj-b'), 'b', [
1663
+ writeSession(path.join(projectsDir, "-Users-test-proj-b"), "b", [
1664
1664
  {
1665
- type: 'user',
1666
- timestamp: '2025-01-02T00:00:00Z',
1665
+ type: "user",
1666
+ timestamp: "2025-01-02T00:00:00Z",
1667
1667
  cwd: cwdB,
1668
1668
  message: {
1669
- content: 'msg-b'
1669
+ content: "msg-b"
1670
1670
  }
1671
1671
  }
1672
1672
  ]);
1673
1673
  const result = await adapter.listSessions();
1674
1674
  expect(result).toHaveLength(2);
1675
1675
  expect(result.map((r)=>r.sessionId).sort()).toEqual([
1676
- 'a',
1677
- 'b'
1676
+ "a",
1677
+ "b"
1678
1678
  ]);
1679
1679
  const cwds = result.map((r)=>r.cwd).sort();
1680
1680
  expect(cwds).toEqual([
@@ -1682,16 +1682,16 @@ describe('ClaudeCodeAdapter', ()=>{
1682
1682
  cwdB
1683
1683
  ]);
1684
1684
  });
1685
- it('drops sessions whose recorded cwd does not match opts.cwd (strict equality)', async ()=>{
1686
- const cwdReal = '/Users/test/foo';
1687
- const cwdRequested = '/Users/test/foo/sub';
1688
- writeSession(path.join(projectsDir, '-Users-test-foo'), 's', [
1685
+ it("drops sessions whose recorded cwd does not match opts.cwd (strict equality)", async ()=>{
1686
+ const cwdReal = "/Users/test/foo";
1687
+ const cwdRequested = "/Users/test/foo/sub";
1688
+ writeSession(path.join(projectsDir, "-Users-test-foo"), "s", [
1689
1689
  {
1690
- type: 'user',
1691
- timestamp: '2025-01-01T00:00:00Z',
1690
+ type: "user",
1691
+ timestamp: "2025-01-01T00:00:00Z",
1692
1692
  cwd: cwdReal,
1693
1693
  message: {
1694
- content: 'hi'
1694
+ content: "hi"
1695
1695
  }
1696
1696
  }
1697
1697
  ]);
@@ -1701,18 +1701,18 @@ describe('ClaudeCodeAdapter', ()=>{
1701
1701
  });
1702
1702
  expect(result).toEqual([]);
1703
1703
  });
1704
- it('drops sessions whose recorded cwd disagrees with the encoded dir', async ()=>{
1704
+ it("drops sessions whose recorded cwd disagrees with the encoded dir", async ()=>{
1705
1705
  // Edge case: encoded dir lookup matches, but session content
1706
1706
  // records a different cwd. Strict-equality filter must reject.
1707
- const requested = '/Users/test/proj';
1708
- const projDir = path.join(projectsDir, '-Users-test-proj');
1709
- writeSession(projDir, 's', [
1707
+ const requested = "/Users/test/proj";
1708
+ const projDir = path.join(projectsDir, "-Users-test-proj");
1709
+ writeSession(projDir, "s", [
1710
1710
  {
1711
- type: 'user',
1712
- timestamp: '2025-01-01T00:00:00Z',
1713
- cwd: '/different/path',
1711
+ type: "user",
1712
+ timestamp: "2025-01-01T00:00:00Z",
1713
+ cwd: "/different/path",
1714
1714
  message: {
1715
- content: 'mismatch'
1715
+ content: "mismatch"
1716
1716
  }
1717
1717
  }
1718
1718
  ]);
@@ -1721,20 +1721,20 @@ describe('ClaudeCodeAdapter', ()=>{
1721
1721
  });
1722
1722
  expect(result).toEqual([]);
1723
1723
  });
1724
- it('finds sessions whose recorded cwd lives in a different encoded dir (worktree case)', async ()=>{
1724
+ it("finds sessions whose recorded cwd lives in a different encoded dir (worktree case)", async ()=>{
1725
1725
  // Real-world case: Claude Code is launched in /repo, then chdirs into
1726
1726
  // /repo/.worktrees/feature. The session file is stored under the
1727
1727
  // ENCODED launch dir, but its content records the worktree path.
1728
1728
  // listSessions({ cwd: worktree }) must still find it.
1729
- const launchDir = path.join(projectsDir, '-repo');
1730
- const worktreeCwd = '/repo/.worktrees/feature';
1731
- writeSession(launchDir, 'wt', [
1729
+ const launchDir = path.join(projectsDir, "-repo");
1730
+ const worktreeCwd = "/repo/.worktrees/feature";
1731
+ writeSession(launchDir, "wt", [
1732
1732
  {
1733
- type: 'user',
1734
- timestamp: '2025-01-01T00:00:00Z',
1733
+ type: "user",
1734
+ timestamp: "2025-01-01T00:00:00Z",
1735
1735
  cwd: worktreeCwd,
1736
1736
  message: {
1737
- content: 'in worktree'
1737
+ content: "in worktree"
1738
1738
  }
1739
1739
  }
1740
1740
  ]);
@@ -1743,25 +1743,25 @@ describe('ClaudeCodeAdapter', ()=>{
1743
1743
  });
1744
1744
  expect(result).toHaveLength(1);
1745
1745
  expect(result[0]).toMatchObject({
1746
- sessionId: 'wt',
1746
+ sessionId: "wt",
1747
1747
  cwd: worktreeCwd,
1748
- firstUserMessage: 'in worktree'
1748
+ firstUserMessage: "in worktree"
1749
1749
  });
1750
1750
  });
1751
- it('skips malformed session files', async ()=>{
1752
- const cwd = '/Users/test/p';
1753
- const projDir = path.join(projectsDir, '-Users-test-p');
1751
+ it("skips malformed session files", async ()=>{
1752
+ const cwd = "/Users/test/p";
1753
+ const projDir = path.join(projectsDir, "-Users-test-p");
1754
1754
  fs.mkdirSync(projDir, {
1755
1755
  recursive: true
1756
1756
  });
1757
- fs.writeFileSync(path.join(projDir, 'bad.jsonl'), 'not valid json');
1758
- writeSession(projDir, 'good', [
1757
+ fs.writeFileSync(path.join(projDir, "bad.jsonl"), "not valid json");
1758
+ writeSession(projDir, "good", [
1759
1759
  {
1760
- type: 'user',
1761
- timestamp: '2025-01-01T00:00:00Z',
1760
+ type: "user",
1761
+ timestamp: "2025-01-01T00:00:00Z",
1762
1762
  cwd,
1763
1763
  message: {
1764
- content: 'ok'
1764
+ content: "ok"
1765
1765
  }
1766
1766
  }
1767
1767
  ]);
@@ -1769,33 +1769,33 @@ describe('ClaudeCodeAdapter', ()=>{
1769
1769
  cwd
1770
1770
  });
1771
1771
  expect(result).toHaveLength(1);
1772
- expect(result[0].sessionId).toBe('good');
1772
+ expect(result[0].sessionId).toBe("good");
1773
1773
  });
1774
- it('captures first user message after filtering noise', async ()=>{
1775
- const cwd = '/Users/test/q';
1776
- writeSession(path.join(projectsDir, '-Users-test-q'), 's', [
1774
+ it("captures first user message after filtering noise", async ()=>{
1775
+ const cwd = "/Users/test/q";
1776
+ writeSession(path.join(projectsDir, "-Users-test-q"), "s", [
1777
1777
  {
1778
- type: 'user',
1779
- timestamp: '2025-01-01T00:00:00Z',
1778
+ type: "user",
1779
+ timestamp: "2025-01-01T00:00:00Z",
1780
1780
  cwd,
1781
1781
  message: {
1782
- content: 'Tool loaded.'
1782
+ content: "Tool loaded."
1783
1783
  }
1784
1784
  },
1785
1785
  {
1786
- type: 'user',
1787
- timestamp: '2025-01-01T00:00:01Z',
1786
+ type: "user",
1787
+ timestamp: "2025-01-01T00:00:01Z",
1788
1788
  cwd,
1789
1789
  message: {
1790
- content: 'real first prompt'
1790
+ content: "real first prompt"
1791
1791
  }
1792
1792
  },
1793
1793
  {
1794
- type: 'user',
1795
- timestamp: '2025-01-01T00:00:02Z',
1794
+ type: "user",
1795
+ timestamp: "2025-01-01T00:00:02Z",
1796
1796
  cwd,
1797
1797
  message: {
1798
- content: 'second prompt'
1798
+ content: "second prompt"
1799
1799
  }
1800
1800
  }
1801
1801
  ]);
@@ -1803,21 +1803,21 @@ describe('ClaudeCodeAdapter', ()=>{
1803
1803
  cwd
1804
1804
  });
1805
1805
  expect(result).toHaveLength(1);
1806
- expect(result[0].firstUserMessage).toBe('real first prompt');
1806
+ expect(result[0].firstUserMessage).toBe("real first prompt");
1807
1807
  });
1808
- it('returns empty firstUserMessage when no user message exists', async ()=>{
1809
- const cwd = '/Users/test/empty';
1810
- writeSession(path.join(projectsDir, '-Users-test-empty'), 's', [
1808
+ it("returns empty firstUserMessage when no user message exists", async ()=>{
1809
+ const cwd = "/Users/test/empty";
1810
+ writeSession(path.join(projectsDir, "-Users-test-empty"), "s", [
1811
1811
  {
1812
- type: 'assistant',
1813
- timestamp: '2025-01-01T00:00:00Z'
1812
+ type: "assistant",
1813
+ timestamp: "2025-01-01T00:00:00Z"
1814
1814
  }
1815
1815
  ]);
1816
1816
  const result = await adapter.listSessions({
1817
1817
  cwd
1818
1818
  });
1819
1819
  expect(result).toHaveLength(1);
1820
- expect(result[0].firstUserMessage).toBe('');
1820
+ expect(result[0].firstUserMessage).toBe("");
1821
1821
  });
1822
1822
  });
1823
1823
  });