@ai-devkit/agent-manager 0.42.3 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (451) hide show
  1. package/dist/AgentManager.d.ts +14 -5
  2. package/dist/AgentManager.d.ts.map +1 -1
  3. package/dist/AgentManager.js +32 -13
  4. package/dist/AgentManager.js.map +1 -1
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js.map +1 -1
  8. package/package.json +9 -4
  9. package/.swcrc +0 -27
  10. package/dist/__tests__/AgentManager.test.js +0 -1596
  11. package/dist/__tests__/AgentManager.test.js.map +0 -1
  12. package/dist/__tests__/adapters/IncrementalSessionRefresh.test.js +0 -486
  13. package/dist/__tests__/adapters/IncrementalSessionRefresh.test.js.map +0 -1
  14. package/dist/__tests__/adapters/adapterProcessImports.test.js +0 -52
  15. package/dist/__tests__/adapters/adapterProcessImports.test.js.map +0 -1
  16. package/dist/__tests__/adapters/adapterSnapshotCandidates.test.js +0 -247
  17. package/dist/__tests__/adapters/adapterSnapshotCandidates.test.js.map +0 -1
  18. package/dist/__tests__/capacity/anthropic.test.js +0 -115
  19. package/dist/__tests__/capacity/anthropic.test.js.map +0 -1
  20. package/dist/__tests__/capacity/boundaries.test.js +0 -45
  21. package/dist/__tests__/capacity/boundaries.test.js.map +0 -1
  22. package/dist/__tests__/capacity/claude.test.js +0 -485
  23. package/dist/__tests__/capacity/claude.test.js.map +0 -1
  24. package/dist/__tests__/capacity/codex.test.js +0 -339
  25. package/dist/__tests__/capacity/codex.test.js.map +0 -1
  26. package/dist/__tests__/capacity/devin.test.js +0 -239
  27. package/dist/__tests__/capacity/devin.test.js.map +0 -1
  28. package/dist/__tests__/capacity/index.test.js +0 -53
  29. package/dist/__tests__/capacity/index.test.js.map +0 -1
  30. package/dist/__tests__/capacity/openai.test.js +0 -687
  31. package/dist/__tests__/capacity/openai.test.js.map +0 -1
  32. package/dist/__tests__/capacity/wham.test.js +0 -159
  33. package/dist/__tests__/capacity/wham.test.js.map +0 -1
  34. package/dist/__tests__/capacity/zai.test.js +0 -212
  35. package/dist/__tests__/capacity/zai.test.js.map +0 -1
  36. package/dist/__tests__/fixtures.test.js +0 -218
  37. package/dist/__tests__/fixtures.test.js.map +0 -1
  38. package/dist/__tests__/harnesses/BoundedSummarySkip.test.js +0 -568
  39. package/dist/__tests__/harnesses/BoundedSummarySkip.test.js.map +0 -1
  40. package/dist/__tests__/harnesses/SessionSummaryEquivalence.test.js +0 -1089
  41. package/dist/__tests__/harnesses/SessionSummaryEquivalence.test.js.map +0 -1
  42. package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.js +0 -143
  43. package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.js.map +0 -1
  44. package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.js +0 -462
  45. package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.js.map +0 -1
  46. package/dist/__tests__/harnesses/builtinAdapters.test.js +0 -33
  47. package/dist/__tests__/harnesses/builtinAdapters.test.js.map +0 -1
  48. package/dist/__tests__/harnesses/claude/ClaudeAgentMapper.test.js +0 -79
  49. package/dist/__tests__/harnesses/claude/ClaudeAgentMapper.test.js.map +0 -1
  50. package/dist/__tests__/harnesses/claude/ClaudeCodeAdapter.test.js +0 -1881
  51. package/dist/__tests__/harnesses/claude/ClaudeCodeAdapter.test.js.map +0 -1
  52. package/dist/__tests__/harnesses/claude/ClaudeSessionLocator.test.js +0 -425
  53. package/dist/__tests__/harnesses/claude/ClaudeSessionLocator.test.js.map +0 -1
  54. package/dist/__tests__/harnesses/claude/ClaudeSessionParser.test.js +0 -314
  55. package/dist/__tests__/harnesses/claude/ClaudeSessionParser.test.js.map +0 -1
  56. package/dist/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.js +0 -49
  57. package/dist/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.js.map +0 -1
  58. package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.js +0 -76
  59. package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.js.map +0 -1
  60. package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.js +0 -173
  61. package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.js.map +0 -1
  62. package/dist/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.js +0 -181
  63. package/dist/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.js.map +0 -1
  64. package/dist/__tests__/harnesses/codex/CodexAdapter.test.js +0 -685
  65. package/dist/__tests__/harnesses/codex/CodexAdapter.test.js.map +0 -1
  66. package/dist/__tests__/harnesses/codex/CodexSessionLocator.test.js +0 -463
  67. package/dist/__tests__/harnesses/codex/CodexSessionLocator.test.js.map +0 -1
  68. package/dist/__tests__/harnesses/codex/CodexSessionMapping.test.js +0 -86
  69. package/dist/__tests__/harnesses/codex/CodexSessionMapping.test.js.map +0 -1
  70. package/dist/__tests__/harnesses/codex/CodexSessionParser.test.js +0 -254
  71. package/dist/__tests__/harnesses/codex/CodexSessionParser.test.js.map +0 -1
  72. package/dist/__tests__/harnesses/codex/durable/CodexCliProbe.test.js +0 -121
  73. package/dist/__tests__/harnesses/codex/durable/CodexCliProbe.test.js.map +0 -1
  74. package/dist/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.js +0 -84
  75. package/dist/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.js.map +0 -1
  76. package/dist/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.js +0 -128
  77. package/dist/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.js.map +0 -1
  78. package/dist/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.js +0 -246
  79. package/dist/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.js.map +0 -1
  80. package/dist/__tests__/harnesses/codex/durable/CodexPrintRunner.test.js +0 -384
  81. package/dist/__tests__/harnesses/codex/durable/CodexPrintRunner.test.js.map +0 -1
  82. package/dist/__tests__/harnesses/copilot/CopilotAdapter.test.js +0 -659
  83. package/dist/__tests__/harnesses/copilot/CopilotAdapter.test.js.map +0 -1
  84. package/dist/__tests__/harnesses/copilot/CopilotRefreshIO.test.js +0 -290
  85. package/dist/__tests__/harnesses/copilot/CopilotRefreshIO.test.js.map +0 -1
  86. package/dist/__tests__/harnesses/devin/DevinAdapter.test.js +0 -597
  87. package/dist/__tests__/harnesses/devin/DevinAdapter.test.js.map +0 -1
  88. package/dist/__tests__/harnesses/devin/DevinAgentMapper.test.js +0 -99
  89. package/dist/__tests__/harnesses/devin/DevinAgentMapper.test.js.map +0 -1
  90. package/dist/__tests__/harnesses/devin/DevinSessionLocator.test.js +0 -192
  91. package/dist/__tests__/harnesses/devin/DevinSessionLocator.test.js.map +0 -1
  92. package/dist/__tests__/harnesses/devin/DevinSessionParser.test.js +0 -407
  93. package/dist/__tests__/harnesses/devin/DevinSessionParser.test.js.map +0 -1
  94. package/dist/__tests__/harnesses/devin/fixtures.js +0 -95
  95. package/dist/__tests__/harnesses/devin/fixtures.js.map +0 -1
  96. package/dist/__tests__/harnesses/gemini/GeminiCliAdapter.test.js +0 -1454
  97. package/dist/__tests__/harnesses/gemini/GeminiCliAdapter.test.js.map +0 -1
  98. package/dist/__tests__/harnesses/gemini/GeminiSessionJsonl.test.js +0 -491
  99. package/dist/__tests__/harnesses/gemini/GeminiSessionJsonl.test.js.map +0 -1
  100. package/dist/__tests__/harnesses/gemini/GeminiSessionLocator.test.js +0 -399
  101. package/dist/__tests__/harnesses/gemini/GeminiSessionLocator.test.js.map +0 -1
  102. package/dist/__tests__/harnesses/grok/GrokAgentMapper.test.js +0 -56
  103. package/dist/__tests__/harnesses/grok/GrokAgentMapper.test.js.map +0 -1
  104. package/dist/__tests__/harnesses/grok/GrokCliAdapter.test.js +0 -421
  105. package/dist/__tests__/harnesses/grok/GrokCliAdapter.test.js.map +0 -1
  106. package/dist/__tests__/harnesses/grok/GrokIncrementalRefresh.test.js +0 -167
  107. package/dist/__tests__/harnesses/grok/GrokIncrementalRefresh.test.js.map +0 -1
  108. package/dist/__tests__/harnesses/grok/GrokSessionLocator.test.js +0 -133
  109. package/dist/__tests__/harnesses/grok/GrokSessionLocator.test.js.map +0 -1
  110. package/dist/__tests__/harnesses/grok/GrokSessionParser.test.js +0 -301
  111. package/dist/__tests__/harnesses/grok/GrokSessionParser.test.js.map +0 -1
  112. package/dist/__tests__/harnesses/kiro/KiroAdapter.test.js +0 -662
  113. package/dist/__tests__/harnesses/kiro/KiroAdapter.test.js.map +0 -1
  114. package/dist/__tests__/harnesses/muse/MuseAdapter.test.js +0 -247
  115. package/dist/__tests__/harnesses/muse/MuseAdapter.test.js.map +0 -1
  116. package/dist/__tests__/harnesses/muse/MuseAgentMapper.test.js +0 -81
  117. package/dist/__tests__/harnesses/muse/MuseAgentMapper.test.js.map +0 -1
  118. package/dist/__tests__/harnesses/muse/MuseSessionLocator.test.js +0 -185
  119. package/dist/__tests__/harnesses/muse/MuseSessionLocator.test.js.map +0 -1
  120. package/dist/__tests__/harnesses/muse/MuseSessionParser.test.js +0 -328
  121. package/dist/__tests__/harnesses/muse/MuseSessionParser.test.js.map +0 -1
  122. package/dist/__tests__/harnesses/opencode/OpenCodeAdapter.test.js +0 -213
  123. package/dist/__tests__/harnesses/opencode/OpenCodeAdapter.test.js.map +0 -1
  124. package/dist/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.js +0 -108
  125. package/dist/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.js.map +0 -1
  126. package/dist/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.js +0 -94
  127. package/dist/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.js.map +0 -1
  128. package/dist/__tests__/harnesses/opencode/OpenCodeSessionParser.test.js +0 -147
  129. package/dist/__tests__/harnesses/opencode/OpenCodeSessionParser.test.js.map +0 -1
  130. package/dist/__tests__/harnesses/pi/PiAdapter.test.js +0 -367
  131. package/dist/__tests__/harnesses/pi/PiAdapter.test.js.map +0 -1
  132. package/dist/__tests__/harnesses/pi/PiDiscoveryIO.test.js +0 -382
  133. package/dist/__tests__/harnesses/pi/PiDiscoveryIO.test.js.map +0 -1
  134. package/dist/__tests__/harnesses/pi/PiSessionParser.test.js +0 -416
  135. package/dist/__tests__/harnesses/pi/PiSessionParser.test.js.map +0 -1
  136. package/dist/__tests__/harnesses/pi/PiSessionTracker.test.js +0 -108
  137. package/dist/__tests__/harnesses/pi/PiSessionTracker.test.js.map +0 -1
  138. package/dist/__tests__/harnesses/pi/durable/PiCliProbe.test.js +0 -70
  139. package/dist/__tests__/harnesses/pi/durable/PiCliProbe.test.js.map +0 -1
  140. package/dist/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.js +0 -43
  141. package/dist/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.js.map +0 -1
  142. package/dist/__tests__/harnesses/pi/durable/PiPrintAgentService.test.js +0 -192
  143. package/dist/__tests__/harnesses/pi/durable/PiPrintAgentService.test.js.map +0 -1
  144. package/dist/__tests__/harnesses/pi/durable/PiPrintProtocol.test.js +0 -119
  145. package/dist/__tests__/harnesses/pi/durable/PiPrintProtocol.test.js.map +0 -1
  146. package/dist/__tests__/harnesses/pi/durable/PiPrintRunner.test.js +0 -382
  147. package/dist/__tests__/harnesses/pi/durable/PiPrintRunner.test.js.map +0 -1
  148. package/dist/__tests__/harnesses/pi/durable/PiStreamParser.test.js +0 -34
  149. package/dist/__tests__/harnesses/pi/durable/PiStreamParser.test.js.map +0 -1
  150. package/dist/__tests__/harnesses/readiness/AgentReadiness.test.js +0 -446
  151. package/dist/__tests__/harnesses/readiness/AgentReadiness.test.js.map +0 -1
  152. package/dist/__tests__/harnesses/runtimeProfiles.test.js +0 -101
  153. package/dist/__tests__/harnesses/runtimeProfiles.test.js.map +0 -1
  154. package/dist/__tests__/print/DurableAgent.test.js +0 -15
  155. package/dist/__tests__/print/DurableAgent.test.js.map +0 -1
  156. package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js +0 -186
  157. package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js.map +0 -1
  158. package/dist/__tests__/print/DurableAgentRepository.test.js +0 -249
  159. package/dist/__tests__/print/DurableAgentRepository.test.js.map +0 -1
  160. package/dist/__tests__/readiness-fixtures.test.js +0 -54
  161. package/dist/__tests__/readiness-fixtures.test.js.map +0 -1
  162. package/dist/__tests__/runtime/AgentRuntime.test.js +0 -13
  163. package/dist/__tests__/runtime/AgentRuntime.test.js.map +0 -1
  164. package/dist/__tests__/runtime/HerdrAgentDiscovery.test.js +0 -164
  165. package/dist/__tests__/runtime/HerdrAgentDiscovery.test.js.map +0 -1
  166. package/dist/__tests__/runtime/HerdrAgentRuntime.test.js +0 -488
  167. package/dist/__tests__/runtime/HerdrAgentRuntime.test.js.map +0 -1
  168. package/dist/__tests__/runtime/ManagedAgentRuntime.test.js +0 -637
  169. package/dist/__tests__/runtime/ManagedAgentRuntime.test.js.map +0 -1
  170. package/dist/__tests__/terminal/GhosttyBackend.test.js +0 -334
  171. package/dist/__tests__/terminal/GhosttyBackend.test.js.map +0 -1
  172. package/dist/__tests__/terminal/TerminalFocusManager.test.js +0 -253
  173. package/dist/__tests__/terminal/TerminalFocusManager.test.js.map +0 -1
  174. package/dist/__tests__/terminal/TmuxManager.test.js +0 -168
  175. package/dist/__tests__/terminal/TmuxManager.test.js.map +0 -1
  176. package/dist/__tests__/terminal/TtyWriter.test.js +0 -386
  177. package/dist/__tests__/terminal/TtyWriter.test.js.map +0 -1
  178. package/dist/__tests__/utils/AgentRegistry.test.js +0 -636
  179. package/dist/__tests__/utils/AgentRegistry.test.js.map +0 -1
  180. package/dist/__tests__/utils/IncrementalJsonlSummary.test.js +0 -650
  181. package/dist/__tests__/utils/IncrementalJsonlSummary.test.js.map +0 -1
  182. package/dist/__tests__/utils/agent-requests.test.js +0 -90
  183. package/dist/__tests__/utils/agent-requests.test.js.map +0 -1
  184. package/dist/__tests__/utils/conversationTail.bench.test.js +0 -258
  185. package/dist/__tests__/utils/conversationTail.bench.test.js.map +0 -1
  186. package/dist/__tests__/utils/conversationTailParity.test.js +0 -588
  187. package/dist/__tests__/utils/conversationTailParity.test.js.map +0 -1
  188. package/dist/__tests__/utils/jsonlTail.test.js +0 -360
  189. package/dist/__tests__/utils/jsonlTail.test.js.map +0 -1
  190. package/dist/__tests__/utils/matching.test.js +0 -324
  191. package/dist/__tests__/utils/matching.test.js.map +0 -1
  192. package/dist/__tests__/utils/matchingConstants.test.js +0 -35
  193. package/dist/__tests__/utils/matchingConstants.test.js.map +0 -1
  194. package/dist/__tests__/utils/process.test.js +0 -818
  195. package/dist/__tests__/utils/process.test.js.map +0 -1
  196. package/dist/__tests__/utils/session.test.js +0 -175
  197. package/dist/__tests__/utils/session.test.js.map +0 -1
  198. package/project.json +0 -29
  199. package/scripts/benchmark-cold-start.mjs +0 -350
  200. package/src/AgentManager.ts +0 -530
  201. package/src/__tests__/AgentManager.test.ts +0 -1483
  202. package/src/__tests__/adapters/IncrementalSessionRefresh.test.ts +0 -437
  203. package/src/__tests__/adapters/adapterProcessImports.test.ts +0 -58
  204. package/src/__tests__/adapters/adapterSnapshotCandidates.test.ts +0 -243
  205. package/src/__tests__/capacity/anthropic.test.ts +0 -105
  206. package/src/__tests__/capacity/boundaries.test.ts +0 -36
  207. package/src/__tests__/capacity/claude.test.ts +0 -462
  208. package/src/__tests__/capacity/codex.test.ts +0 -311
  209. package/src/__tests__/capacity/devin.test.ts +0 -210
  210. package/src/__tests__/capacity/fixtures/claude-credentials.json +0 -7
  211. package/src/__tests__/capacity/fixtures/claude-usage-malformed.json +0 -1
  212. package/src/__tests__/capacity/fixtures/claude-usage-partial.json +0 -15
  213. package/src/__tests__/capacity/fixtures/claude-usage.json +0 -63
  214. package/src/__tests__/capacity/fixtures/devin-config.json +0 -6
  215. package/src/__tests__/capacity/fixtures/devin-credentials.toml +0 -4
  216. package/src/__tests__/capacity/fixtures/devin-quota-nonplan.json +0 -5
  217. package/src/__tests__/capacity/fixtures/devin-quota.json +0 -10
  218. package/src/__tests__/capacity/fixtures/openai-auth.json +0 -6
  219. package/src/__tests__/capacity/fixtures/openai-codex-auth.json +0 -9
  220. package/src/__tests__/capacity/fixtures/openai-usage-completions.json +0 -67
  221. package/src/__tests__/capacity/fixtures/openai-usage-responses.json +0 -20
  222. package/src/__tests__/capacity/fixtures/wham-usage.json +0 -45
  223. package/src/__tests__/capacity/fixtures/zai-auth.json +0 -6
  224. package/src/__tests__/capacity/fixtures/zai-quota-invalid.json +0 -7
  225. package/src/__tests__/capacity/fixtures/zai-quota.json +0 -38
  226. package/src/__tests__/capacity/index.test.ts +0 -54
  227. package/src/__tests__/capacity/openai.test.ts +0 -571
  228. package/src/__tests__/capacity/wham.test.ts +0 -122
  229. package/src/__tests__/capacity/zai.test.ts +0 -151
  230. package/src/__tests__/fixtures.test.ts +0 -245
  231. package/src/__tests__/harnesses/BoundedSummarySkip.test.ts +0 -496
  232. package/src/__tests__/harnesses/SessionSummaryEquivalence.test.ts +0 -726
  233. package/src/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.ts +0 -133
  234. package/src/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.ts +0 -396
  235. package/src/__tests__/harnesses/builtinAdapters.test.ts +0 -33
  236. package/src/__tests__/harnesses/claude/ClaudeAgentMapper.test.ts +0 -84
  237. package/src/__tests__/harnesses/claude/ClaudeCodeAdapter.test.ts +0 -1793
  238. package/src/__tests__/harnesses/claude/ClaudeSessionLocator.test.ts +0 -423
  239. package/src/__tests__/harnesses/claude/ClaudeSessionParser.test.ts +0 -300
  240. package/src/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.ts +0 -34
  241. package/src/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.ts +0 -61
  242. package/src/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.ts +0 -129
  243. package/src/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.ts +0 -152
  244. package/src/__tests__/harnesses/codex/CodexAdapter.test.ts +0 -652
  245. package/src/__tests__/harnesses/codex/CodexSessionLocator.test.ts +0 -419
  246. package/src/__tests__/harnesses/codex/CodexSessionMapping.test.ts +0 -63
  247. package/src/__tests__/harnesses/codex/CodexSessionParser.test.ts +0 -192
  248. package/src/__tests__/harnesses/codex/durable/CodexCliProbe.test.ts +0 -80
  249. package/src/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.ts +0 -65
  250. package/src/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.ts +0 -104
  251. package/src/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.ts +0 -201
  252. package/src/__tests__/harnesses/codex/durable/CodexPrintRunner.test.ts +0 -299
  253. package/src/__tests__/harnesses/copilot/CopilotAdapter.test.ts +0 -614
  254. package/src/__tests__/harnesses/copilot/CopilotRefreshIO.test.ts +0 -270
  255. package/src/__tests__/harnesses/devin/DevinAdapter.test.ts +0 -290
  256. package/src/__tests__/harnesses/devin/DevinAgentMapper.test.ts +0 -101
  257. package/src/__tests__/harnesses/devin/DevinSessionLocator.test.ts +0 -139
  258. package/src/__tests__/harnesses/devin/DevinSessionParser.test.ts +0 -212
  259. package/src/__tests__/harnesses/devin/fixtures.ts +0 -144
  260. package/src/__tests__/harnesses/gemini/GeminiCliAdapter.test.ts +0 -1336
  261. package/src/__tests__/harnesses/gemini/GeminiSessionJsonl.test.ts +0 -402
  262. package/src/__tests__/harnesses/gemini/GeminiSessionLocator.test.ts +0 -396
  263. package/src/__tests__/harnesses/grok/GrokAgentMapper.test.ts +0 -57
  264. package/src/__tests__/harnesses/grok/GrokCliAdapter.test.ts +0 -376
  265. package/src/__tests__/harnesses/grok/GrokIncrementalRefresh.test.ts +0 -170
  266. package/src/__tests__/harnesses/grok/GrokSessionLocator.test.ts +0 -106
  267. package/src/__tests__/harnesses/grok/GrokSessionParser.test.ts +0 -230
  268. package/src/__tests__/harnesses/kiro/KiroAdapter.test.ts +0 -552
  269. package/src/__tests__/harnesses/muse/MuseAdapter.test.ts +0 -197
  270. package/src/__tests__/harnesses/muse/MuseAgentMapper.test.ts +0 -83
  271. package/src/__tests__/harnesses/muse/MuseSessionLocator.test.ts +0 -177
  272. package/src/__tests__/harnesses/muse/MuseSessionParser.test.ts +0 -279
  273. package/src/__tests__/harnesses/opencode/OpenCodeAdapter.test.ts +0 -215
  274. package/src/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.ts +0 -101
  275. package/src/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.ts +0 -84
  276. package/src/__tests__/harnesses/opencode/OpenCodeSessionParser.test.ts +0 -149
  277. package/src/__tests__/harnesses/pi/PiAdapter.test.ts +0 -325
  278. package/src/__tests__/harnesses/pi/PiDiscoveryIO.test.ts +0 -337
  279. package/src/__tests__/harnesses/pi/PiSessionParser.test.ts +0 -280
  280. package/src/__tests__/harnesses/pi/PiSessionTracker.test.ts +0 -79
  281. package/src/__tests__/harnesses/pi/durable/PiCliProbe.test.ts +0 -50
  282. package/src/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.ts +0 -33
  283. package/src/__tests__/harnesses/pi/durable/PiPrintAgentService.test.ts +0 -138
  284. package/src/__tests__/harnesses/pi/durable/PiPrintProtocol.test.ts +0 -71
  285. package/src/__tests__/harnesses/pi/durable/PiPrintRunner.test.ts +0 -252
  286. package/src/__tests__/harnesses/pi/durable/PiStreamParser.test.ts +0 -26
  287. package/src/__tests__/harnesses/readiness/AgentReadiness.test.ts +0 -362
  288. package/src/__tests__/harnesses/runtimeProfiles.test.ts +0 -123
  289. package/src/__tests__/print/DurableAgent.test.ts +0 -15
  290. package/src/__tests__/print/DurableAgentRepository.sqlite.test.ts +0 -128
  291. package/src/__tests__/print/DurableAgentRepository.test.ts +0 -184
  292. package/src/__tests__/readiness-fixtures.test.ts +0 -79
  293. package/src/__tests__/runtime/AgentRuntime.test.ts +0 -8
  294. package/src/__tests__/runtime/HerdrAgentDiscovery.test.ts +0 -131
  295. package/src/__tests__/runtime/HerdrAgentRuntime.test.ts +0 -377
  296. package/src/__tests__/runtime/ManagedAgentRuntime.test.ts +0 -590
  297. package/src/__tests__/terminal/GhosttyBackend.test.ts +0 -271
  298. package/src/__tests__/terminal/TerminalFocusManager.test.ts +0 -280
  299. package/src/__tests__/terminal/TmuxManager.test.ts +0 -185
  300. package/src/__tests__/terminal/TtyWriter.test.ts +0 -454
  301. package/src/__tests__/utils/AgentRegistry.test.ts +0 -532
  302. package/src/__tests__/utils/IncrementalJsonlSummary.test.ts +0 -414
  303. package/src/__tests__/utils/agent-requests.test.ts +0 -94
  304. package/src/__tests__/utils/conversationTail.bench.test.ts +0 -193
  305. package/src/__tests__/utils/conversationTailParity.test.ts +0 -365
  306. package/src/__tests__/utils/jsonlTail.test.ts +0 -317
  307. package/src/__tests__/utils/matching.test.ts +0 -234
  308. package/src/__tests__/utils/matchingConstants.test.ts +0 -40
  309. package/src/__tests__/utils/process.test.ts +0 -596
  310. package/src/__tests__/utils/session.test.ts +0 -158
  311. package/src/adapters/AgentAdapter.ts +0 -255
  312. package/src/capacity/index.ts +0 -127
  313. package/src/capacity/providers/anthropic.ts +0 -198
  314. package/src/capacity/providers/devin.ts +0 -121
  315. package/src/capacity/providers/openai-platform.ts +0 -150
  316. package/src/capacity/providers/openai-subscription.ts +0 -184
  317. package/src/capacity/providers/zai.ts +0 -155
  318. package/src/capacity/sources/claude.ts +0 -30
  319. package/src/capacity/sources/codex.ts +0 -251
  320. package/src/capacity/sources/devin.ts +0 -49
  321. package/src/capacity/sources/pi.ts +0 -131
  322. package/src/capacity/types.ts +0 -29
  323. package/src/database/connection.ts +0 -96
  324. package/src/database/index.ts +0 -7
  325. package/src/database/migrations/001_initial.sql +0 -12
  326. package/src/database/migrations/002_pins.sql +0 -1
  327. package/src/database/migrations/003_durable_agents.sql +0 -43
  328. package/src/database/migrations/004_codex_durable_sessions.sql +0 -1
  329. package/src/database/migrations/005_agent_runtime.sql +0 -2
  330. package/src/database/schema.ts +0 -64
  331. package/src/durable/DurableAgent.ts +0 -139
  332. package/src/durable/DurableAgentRepository.ts +0 -485
  333. package/src/durable/process.ts +0 -29
  334. package/src/durable/run.ts +0 -84
  335. package/src/durable/utils.ts +0 -66
  336. package/src/fixtures/bundle.ts +0 -130
  337. package/src/fixtures/capture.ts +0 -364
  338. package/src/harnesses/antigravity/AntigravityAgentMapper.ts +0 -34
  339. package/src/harnesses/antigravity/AntigravityCliAdapter.ts +0 -126
  340. package/src/harnesses/antigravity/AntigravitySessionLocator.ts +0 -75
  341. package/src/harnesses/antigravity/AntigravitySessionParser.ts +0 -252
  342. package/src/harnesses/claude/ClaudeAgentMapper.ts +0 -55
  343. package/src/harnesses/claude/ClaudeCodeAdapter.ts +0 -175
  344. package/src/harnesses/claude/ClaudeSessionLocator.ts +0 -358
  345. package/src/harnesses/claude/ClaudeSessionParser.ts +0 -524
  346. package/src/harnesses/claude/credentials.ts +0 -122
  347. package/src/harnesses/claude/durable/ClaudeCliProbe.ts +0 -57
  348. package/src/harnesses/claude/durable/ClaudePrintAgentService.ts +0 -79
  349. package/src/harnesses/claude/durable/ClaudePrintRunner.ts +0 -102
  350. package/src/harnesses/claude/durable/ClaudeStreamParser.ts +0 -108
  351. package/src/harnesses/claude/readiness.ts +0 -69
  352. package/src/harnesses/codex/CodexAdapter.ts +0 -337
  353. package/src/harnesses/codex/CodexAgentMapper.ts +0 -26
  354. package/src/harnesses/codex/CodexSessionLocator.ts +0 -509
  355. package/src/harnesses/codex/CodexSessionMapping.ts +0 -89
  356. package/src/harnesses/codex/CodexSessionParser.ts +0 -462
  357. package/src/harnesses/codex/credentials.ts +0 -81
  358. package/src/harnesses/codex/durable/CodexCliProbe.ts +0 -68
  359. package/src/harnesses/codex/durable/CodexPrintAgentService.ts +0 -79
  360. package/src/harnesses/codex/durable/CodexPrintRunner.ts +0 -104
  361. package/src/harnesses/codex/durable/CodexStreamParser.ts +0 -117
  362. package/src/harnesses/codex/readiness.ts +0 -72
  363. package/src/harnesses/copilot/CopilotAdapter.ts +0 -161
  364. package/src/harnesses/copilot/CopilotAgentMapper.ts +0 -27
  365. package/src/harnesses/copilot/CopilotSessionLocator.ts +0 -161
  366. package/src/harnesses/copilot/CopilotSessionParser.ts +0 -380
  367. package/src/harnesses/copilot/readiness.ts +0 -33
  368. package/src/harnesses/devin/DevinAdapter.ts +0 -212
  369. package/src/harnesses/devin/DevinAgentMapper.ts +0 -39
  370. package/src/harnesses/devin/DevinSessionLocator.ts +0 -230
  371. package/src/harnesses/devin/DevinSessionParser.ts +0 -227
  372. package/src/harnesses/devin/credentials.ts +0 -88
  373. package/src/harnesses/devin/readiness.ts +0 -36
  374. package/src/harnesses/gemini/GeminiAgentMapper.ts +0 -27
  375. package/src/harnesses/gemini/GeminiCliAdapter.ts +0 -272
  376. package/src/harnesses/gemini/GeminiSessionLocator.ts +0 -394
  377. package/src/harnesses/gemini/GeminiSessionParser.ts +0 -395
  378. package/src/harnesses/gemini/fileSignature.ts +0 -10
  379. package/src/harnesses/grok/GrokAgentMapper.ts +0 -32
  380. package/src/harnesses/grok/GrokCliAdapter.ts +0 -126
  381. package/src/harnesses/grok/GrokSessionLocator.ts +0 -179
  382. package/src/harnesses/grok/GrokSessionParser.ts +0 -251
  383. package/src/harnesses/index.ts +0 -32
  384. package/src/harnesses/kiro/KiroAdapter.ts +0 -143
  385. package/src/harnesses/kiro/KiroAgentMapper.ts +0 -34
  386. package/src/harnesses/kiro/KiroSessionLocator.ts +0 -143
  387. package/src/harnesses/kiro/KiroSessionParser.ts +0 -376
  388. package/src/harnesses/muse/MuseAdapter.ts +0 -157
  389. package/src/harnesses/muse/MuseAgentMapper.ts +0 -33
  390. package/src/harnesses/muse/MuseSessionLocator.ts +0 -286
  391. package/src/harnesses/muse/MuseSessionParser.ts +0 -435
  392. package/src/harnesses/muse/readiness.ts +0 -38
  393. package/src/harnesses/opencode/OpenCodeAdapter.ts +0 -110
  394. package/src/harnesses/opencode/OpenCodeAgentMapper.ts +0 -49
  395. package/src/harnesses/opencode/OpenCodeSessionLocator.ts +0 -151
  396. package/src/harnesses/opencode/OpenCodeSessionParser.ts +0 -146
  397. package/src/harnesses/opencode/readiness.ts +0 -48
  398. package/src/harnesses/pi/PiAdapter.ts +0 -197
  399. package/src/harnesses/pi/PiAgentMapper.ts +0 -27
  400. package/src/harnesses/pi/PiSessionLocator.ts +0 -288
  401. package/src/harnesses/pi/PiSessionParser.ts +0 -488
  402. package/src/harnesses/pi/PiSessionTracker.ts +0 -87
  403. package/src/harnesses/pi/credentials.ts +0 -129
  404. package/src/harnesses/pi/durable/PiCliProbe.ts +0 -56
  405. package/src/harnesses/pi/durable/PiPrintAgentService.ts +0 -77
  406. package/src/harnesses/pi/durable/PiPrintProtocol.ts +0 -41
  407. package/src/harnesses/pi/durable/PiPrintRunner.ts +0 -95
  408. package/src/harnesses/pi/durable/PiStreamParser.ts +0 -94
  409. package/src/harnesses/pi/readiness.ts +0 -104
  410. package/src/harnesses/readiness/AgentReadiness.ts +0 -91
  411. package/src/harnesses/readiness/checks.ts +0 -336
  412. package/src/harnesses/readiness/types.ts +0 -90
  413. package/src/harnesses/runtimeProfiles.ts +0 -105
  414. package/src/harnesses/shared.ts +0 -124
  415. package/src/index.ts +0 -70
  416. package/src/runtime/ManagedAgentRuntime.ts +0 -253
  417. package/src/runtime/RuntimeFactory.ts +0 -13
  418. package/src/runtime/errors.ts +0 -50
  419. package/src/runtime/herdr/HerdrAgentDiscovery.ts +0 -166
  420. package/src/runtime/herdr/HerdrAgentRuntime.ts +0 -216
  421. package/src/runtime/herdr/HerdrCliClient.ts +0 -78
  422. package/src/runtime/herdr/HerdrErrors.ts +0 -9
  423. package/src/runtime/herdr/HerdrResponseParsers.ts +0 -86
  424. package/src/runtime/herdr/HerdrRuntimeRef.ts +0 -41
  425. package/src/runtime/tmux/PidPolling.ts +0 -34
  426. package/src/runtime/tmux/TmuxAgentRuntime.ts +0 -113
  427. package/src/runtime/tmux/TmuxManager.ts +0 -102
  428. package/src/runtime/tmux/TmuxRuntimeRef.ts +0 -9
  429. package/src/runtime/types.ts +0 -56
  430. package/src/terminal/TerminalFocusManager.ts +0 -52
  431. package/src/terminal/TtyWriter.ts +0 -26
  432. package/src/terminal/backends/ghostty.ts +0 -180
  433. package/src/terminal/backends/index.ts +0 -23
  434. package/src/terminal/backends/iterm2.ts +0 -126
  435. package/src/terminal/backends/shared.ts +0 -47
  436. package/src/terminal/backends/terminal-app.ts +0 -122
  437. package/src/terminal/backends/tmux.ts +0 -62
  438. package/src/terminal/backends/wezterm.ts +0 -65
  439. package/src/terminal/types.ts +0 -23
  440. package/src/utils/AgentRegistry.ts +0 -351
  441. package/src/utils/IncrementalJsonlSummary.ts +0 -306
  442. package/src/utils/agent-requests.ts +0 -28
  443. package/src/utils/applescript.ts +0 -10
  444. package/src/utils/jsonlTail.ts +0 -349
  445. package/src/utils/matching.ts +0 -96
  446. package/src/utils/matchingConstants.ts +0 -15
  447. package/src/utils/process.ts +0 -604
  448. package/src/utils/session.ts +0 -144
  449. package/src/utils/sortAgents.ts +0 -54
  450. package/tsconfig.json +0 -11
  451. package/vitest.config.ts +0 -20
@@ -1,300 +0,0 @@
1
- /**
2
- * Tests for harnesses/claude/ClaudeSessionParser.ts — focused on stripping
3
- * harness-injected XML tags from conversation content.
4
- */
5
-
6
- import * as fs from "fs";
7
- import * as os from "os";
8
- import * as path from "path";
9
- import { ClaudeSessionParser } from "../../../harnesses/claude/ClaudeSessionParser.js";
10
-
11
- interface JsonlEntry {
12
- type: "user" | "assistant" | "system";
13
- message: {
14
- content:
15
- | string
16
- | Array<{
17
- type: string;
18
- text?: string;
19
- content?: string;
20
- name?: string;
21
- input?: unknown;
22
- is_error?: boolean;
23
- }>;
24
- };
25
- timestamp?: string;
26
- }
27
-
28
- function writeSession(entries: JsonlEntry[]): string {
29
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), "parser-test-"));
30
- const filePath = path.join(dir, "session.jsonl");
31
- fs.writeFileSync(filePath, entries.map((e) => JSON.stringify(e)).join("\n"));
32
- return filePath;
33
- }
34
-
35
- describe("ClaudeSessionParser.getConversation — harness tag stripping", () => {
36
- let parser: ClaudeSessionParser;
37
- const tempFiles: string[] = [];
38
-
39
- beforeEach(() => {
40
- parser = new ClaudeSessionParser();
41
- });
42
-
43
- afterEach(() => {
44
- for (const f of tempFiles) {
45
- try {
46
- fs.rmSync(path.dirname(f), { recursive: true, force: true });
47
- } catch {
48
- /* best effort */
49
- }
50
- }
51
- tempFiles.length = 0;
52
- });
53
-
54
- function makeSession(entries: JsonlEntry[]): string {
55
- const f = writeSession(entries);
56
- tempFiles.push(f);
57
- return f;
58
- }
59
-
60
- it("strips <system-reminder> blocks from text content", () => {
61
- const file = makeSession([
62
- {
63
- type: "assistant",
64
- message: {
65
- content: [
66
- {
67
- type: "text",
68
- text: "Real response here.\n<system-reminder>\nDo not mention this reminder.\n</system-reminder>\nMore response.",
69
- },
70
- ],
71
- },
72
- },
73
- ]);
74
-
75
- const conv = parser.getConversation(file);
76
- expect(conv).toHaveLength(1);
77
- expect(conv[0].content).toBe("Real response here.\n\nMore response.");
78
- });
79
-
80
- it("strips <local-command-stdout> blocks", () => {
81
- const file = makeSession([
82
- {
83
- type: "system",
84
- message: {
85
- content: "before <local-command-stdout>\nRunning...\nDone\n</local-command-stdout> after",
86
- },
87
- },
88
- ]);
89
-
90
- const conv = parser.getConversation(file);
91
- expect(conv[0].content).toBe("before after");
92
- });
93
-
94
- it("strips <user-prompt-submit-hook> blocks", () => {
95
- const file = makeSession([
96
- {
97
- type: "user",
98
- message: {
99
- content:
100
- "<user-prompt-submit-hook>hook output</user-prompt-submit-hook>\nactual question",
101
- },
102
- },
103
- ]);
104
-
105
- const conv = parser.getConversation(file);
106
- expect(conv[0].content).toBe("actual question");
107
- });
108
-
109
- it("strips bash and command stdout/stderr blocks", () => {
110
- const file = makeSession([
111
- {
112
- type: "assistant",
113
- message: {
114
- content: [
115
- {
116
- type: "text",
117
- text: "Output:\n<bash-input>ls</bash-input>\n<bash-stdout>file.txt</bash-stdout>\n<bash-stderr></bash-stderr>\n<command-stdout>x</command-stdout>\n<command-stderr>y</command-stderr>\nEnd.",
118
- },
119
- ],
120
- },
121
- },
122
- ]);
123
-
124
- const conv = parser.getConversation(file);
125
- expect(conv[0].content).toBe("Output:\n\n\n\n\n\nEnd.".replace(/\n{3,}/g, "\n\n"));
126
- expect(conv[0].content).not.toMatch(/<bash-/);
127
- expect(conv[0].content).not.toMatch(/<command-stdout>|<command-stderr>/);
128
- });
129
-
130
- it('collapses <command-name>/<command-args> into "/name args" shorthand', () => {
131
- const file = makeSession([
132
- {
133
- type: "user",
134
- message: {
135
- content:
136
- "<command-message>debug</command-message>\n<command-name>/debug</command-name>\n<command-args>fix the bug</command-args>",
137
- },
138
- },
139
- ]);
140
-
141
- const conv = parser.getConversation(file);
142
- expect(conv[0].content).toBe("/debug fix the bug");
143
- });
144
-
145
- it("handles <command-name> without <command-args>", () => {
146
- const file = makeSession([
147
- {
148
- type: "user",
149
- message: {
150
- content: "<command-message>clear</command-message>\n<command-name>/clear</command-name>",
151
- },
152
- },
153
- ]);
154
-
155
- const conv = parser.getConversation(file);
156
- expect(conv[0].content).toBe("/clear");
157
- });
158
-
159
- it("handles multiple harness tags mixed together", () => {
160
- const file = makeSession([
161
- {
162
- type: "user",
163
- message: {
164
- content: [
165
- {
166
- type: "text",
167
- text: "<system-reminder>ignore me</system-reminder>\n<command-message>build</command-message>\n<command-name>/build</command-name>\n<command-args>--watch</command-args>\n<local-command-stdout>build output here</local-command-stdout>",
168
- },
169
- ],
170
- },
171
- },
172
- ]);
173
-
174
- const conv = parser.getConversation(file);
175
- expect(conv[0].content).toBe("/build --watch");
176
- });
177
-
178
- it("leaves text without harness tags unchanged", () => {
179
- const file = makeSession([
180
- {
181
- type: "assistant",
182
- message: { content: [{ type: "text", text: "Hello, world!" }] },
183
- },
184
- ]);
185
-
186
- const conv = parser.getConversation(file);
187
- expect(conv[0].content).toBe("Hello, world!");
188
- });
189
-
190
- it("drops a message that becomes empty after stripping", () => {
191
- const file = makeSession([
192
- {
193
- type: "system",
194
- message: { content: "<system-reminder>only this</system-reminder>" },
195
- },
196
- {
197
- type: "assistant",
198
- message: { content: [{ type: "text", text: "kept" }] },
199
- },
200
- ]);
201
-
202
- const conv = parser.getConversation(file);
203
- expect(conv).toHaveLength(1);
204
- expect(conv[0].content).toBe("kept");
205
- });
206
-
207
- it("strips tags spanning multiple lines", () => {
208
- const multilineReminder = "<system-reminder>\nLine 1\nLine 2\nLine 3\n</system-reminder>";
209
- const file = makeSession([
210
- {
211
- type: "assistant",
212
- message: { content: [{ type: "text", text: `before\n${multilineReminder}\nafter` }] },
213
- },
214
- ]);
215
-
216
- const conv = parser.getConversation(file);
217
- expect(conv[0].content).toBe("before\n\nafter");
218
- });
219
- });
220
-
221
- describe("ClaudeSessionParser.readSession — UI-state entries ignored for status", () => {
222
- let parser: ClaudeSessionParser;
223
- const tempFiles: string[] = [];
224
-
225
- beforeEach(() => {
226
- parser = new ClaudeSessionParser();
227
- });
228
-
229
- afterEach(() => {
230
- for (const f of tempFiles) {
231
- try {
232
- fs.rmSync(path.dirname(f), { recursive: true, force: true });
233
- } catch {
234
- /* best effort */
235
- }
236
- }
237
- tempFiles.length = 0;
238
- });
239
-
240
- function writeRawSession(lines: object[]): string {
241
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), "parser-status-"));
242
- const filePath = path.join(dir, "session.jsonl");
243
- fs.writeFileSync(filePath, lines.map((l) => JSON.stringify(l)).join("\n"));
244
- tempFiles.push(filePath);
245
- return filePath;
246
- }
247
-
248
- const uiStateTypes = [
249
- "attachment",
250
- "permission-mode",
251
- "ai-title",
252
- "queued_command",
253
- "tools_changed",
254
- "model_changed",
255
- "hook_progress",
256
- ];
257
-
258
- for (const uiType of uiStateTypes) {
259
- it(`keeps lastEntryType from previous conversation turn when trailing entry is ${uiType}`, () => {
260
- const file = writeRawSession([
261
- { type: "user", timestamp: "2026-05-30T06:17:57.189Z", message: { content: "hello" } },
262
- { type: uiType, timestamp: "2026-05-30T06:17:57.201Z" },
263
- ]);
264
-
265
- const session = parser.readSession(file, "/test");
266
- expect(session?.lastEntryType).toBe("user");
267
- });
268
- }
269
-
270
- it("keeps lastEntryType from a user turn even with multiple trailing UI-state entries", () => {
271
- const file = writeRawSession([
272
- { type: "user", timestamp: "2026-05-30T06:17:57.189Z", message: { content: "hello" } },
273
- {
274
- type: "attachment",
275
- timestamp: "2026-05-30T06:17:57.200Z",
276
- attachment: { type: "task_reminder", content: [] },
277
- },
278
- { type: "permission-mode", timestamp: "2026-05-30T06:17:57.210Z", permissionMode: "default" },
279
- { type: "ai-title", timestamp: "2026-05-30T06:17:57.220Z" },
280
- ]);
281
-
282
- const session = parser.readSession(file, "/test");
283
- expect(session?.lastEntryType).toBe("user");
284
- });
285
-
286
- it("keeps lastEntryType from assistant turn when followed by UI-state events", () => {
287
- const file = writeRawSession([
288
- { type: "user", timestamp: "2026-05-30T06:17:00.000Z", message: { content: "go" } },
289
- {
290
- type: "assistant",
291
- timestamp: "2026-05-30T06:17:01.000Z",
292
- message: { content: [{ type: "text", text: "done" }] },
293
- },
294
- { type: "permission-mode", timestamp: "2026-05-30T06:17:02.000Z", permissionMode: "default" },
295
- ]);
296
-
297
- const session = parser.readSession(file, "/test");
298
- expect(session?.lastEntryType).toBe("assistant");
299
- });
300
- });
@@ -1,34 +0,0 @@
1
- import { describe, expect, it, vi } from "vitest";
2
- import { ClaudeCliProbe } from "../../../../harnesses/claude/durable/ClaudeCliProbe.js";
3
-
4
- describe("ClaudeCliProbe", () => {
5
- it("validates only version/help and requires the print session flags", async () => {
6
- const exec = vi
7
- .fn()
8
- .mockResolvedValueOnce({ stdout: "2.1.220\n", stderr: "" })
9
- .mockResolvedValueOnce({
10
- stdout: "--print --session-id --resume --output-format stream-json",
11
- stderr: "",
12
- });
13
-
14
- await expect(new ClaudeCliProbe({ exec }).validate()).resolves.toEqual({
15
- executable: "claude",
16
- version: "2.1.220",
17
- });
18
- expect(exec.mock.calls).toEqual([
19
- ["claude", ["--version"]],
20
- ["claude", ["--help"]],
21
- ]);
22
- });
23
-
24
- it("rejects a CLI missing a required capability", async () => {
25
- const exec = vi
26
- .fn()
27
- .mockResolvedValueOnce({ stdout: "old", stderr: "" })
28
- .mockResolvedValueOnce({ stdout: "--print only", stderr: "" });
29
-
30
- await expect(new ClaudeCliProbe({ exec }).validate()).rejects.toMatchObject({
31
- code: "CLAUDE_CLI_UNSUPPORTED",
32
- });
33
- });
34
- });
@@ -1,61 +0,0 @@
1
- import fs from "node:fs";
2
- import os from "node:os";
3
- import path from "node:path";
4
- import { afterEach, describe, expect, it, vi } from "vitest";
5
- import {
6
- DurableAgentRepository,
7
- type ProcessInspector,
8
- } from "../../../../durable/DurableAgentRepository.js";
9
- import { ClaudePrintAgentService } from "../../../../harnesses/claude/durable/ClaudePrintAgentService.js";
10
-
11
- const roots: string[] = [];
12
-
13
- afterEach(() => {
14
- for (const root of roots.splice(0)) fs.rmSync(root, { recursive: true, force: true });
15
- });
16
-
17
- describe("Claude durable-agent fake-provider journey", () => {
18
- it("creates without invocation, then starts and resumes the same session through stdin", async () => {
19
- const root = fs.mkdtempSync(path.join(os.tmpdir(), "durable-agent-integration-"));
20
- roots.push(root);
21
- const cwd = path.join(root, "project");
22
- fs.mkdirSync(cwd);
23
- const processInspector: ProcessInspector = {
24
- getIdentity: (pid) => ({ pid, startedAt: `process-${pid}` }),
25
- };
26
- const repository = new DurableAgentRepository({
27
- dbPath: path.join(root, "state", "agents.db"),
28
- processInspector,
29
- });
30
- const runner = {
31
- run: vi.fn().mockImplementation(async (request) => {
32
- await request.onSpawn({ pid: 42, startedAt: "process-42" });
33
- return {
34
- sessionId: request.agent.providerSessionId,
35
- result: `answer:${request.prompt}`,
36
- exitCode: 0,
37
- };
38
- }),
39
- };
40
- const service = new ClaudePrintAgentService({
41
- repository,
42
- probe: { validate: vi.fn() },
43
- runner,
44
- });
45
-
46
- const created = await service.create({ name: "reviewer", cwd });
47
-
48
- await expect(service.send(created.id, "first secret")).resolves.toMatchObject({
49
- result: "answer:first secret",
50
- });
51
- await expect(service.send(created.id, "follow up")).resolves.toMatchObject({
52
- result: "answer:follow up",
53
- });
54
-
55
- expect(runner.run.mock.calls[0][0]).toMatchObject({ firstRun: true, prompt: "first secret" });
56
- expect(runner.run.mock.calls[1][0]).toMatchObject({ firstRun: false, prompt: "follow up" });
57
-
58
- const persisted = await repository.getById(created.id);
59
- expect(persisted).toMatchObject({ state: "ready", sessionHealth: "healthy" });
60
- });
61
- });
@@ -1,129 +0,0 @@
1
- import { describe, expect, it, vi } from "vitest";
2
-
3
- describe("ClaudePrintAgentService", () => {
4
- it("validates before create and does not run Claude", async () => {
5
- const api = (await import("../../../../index.js")) as Record<string, unknown>;
6
- expect(api).toHaveProperty("ClaudePrintAgentService");
7
- const probe = {
8
- validate: vi.fn().mockResolvedValue({ executable: "claude", version: "2.1.220" }),
9
- };
10
- const repository = { create: vi.fn().mockResolvedValue({ id: "agent-id", name: "reviewer" }) };
11
- const runner = { run: vi.fn() };
12
- const Service = api.ClaudePrintAgentService as new (options: unknown) => any;
13
-
14
- await expect(
15
- new Service({ repository, probe, runner }).create({ name: "reviewer", cwd: "/project" }),
16
- ).resolves.toMatchObject({ id: "agent-id" });
17
- expect(probe.validate).toHaveBeenCalledOnce();
18
- expect(repository.create).toHaveBeenCalledWith({ name: "reviewer", cwd: "/project" });
19
- expect(runner.run).not.toHaveBeenCalled();
20
- });
21
-
22
- it("runs first and resumed sends and records provider identity/results", async () => {
23
- const api = (await import("../../../../index.js")) as Record<string, unknown>;
24
- const base = {
25
- id: "id",
26
- name: "reviewer",
27
- provider: "claude",
28
- providerSessionId: "session",
29
- sessionHealth: "uninitialized",
30
- };
31
- const repository = {
32
- resolve: vi.fn().mockResolvedValue(base),
33
- acquireRun: vi
34
- .fn()
35
- .mockResolvedValueOnce({ agent: base, token: "one" })
36
- .mockResolvedValueOnce({ agent: { ...base, sessionHealth: "healthy" }, token: "two" }),
37
- recordProviderProcess: vi.fn(),
38
- completeRun: vi.fn().mockResolvedValue({}),
39
- };
40
- const runner = {
41
- run: vi.fn().mockImplementation(async (request) => {
42
- await request.onSpawn({ pid: 42, startedAt: "start" });
43
- return { sessionId: "session", result: "answer", exitCode: 0 };
44
- }),
45
- };
46
- const Service = api.ClaudePrintAgentService as new (options: unknown) => any;
47
- const service = new Service({
48
- repository,
49
- probe: { validate: vi.fn() },
50
- runner,
51
- executable: "fake-claude",
52
- });
53
-
54
- await service.send("reviewer", "first");
55
- await service.send("id", "later");
56
-
57
- expect(runner.run.mock.calls[0][0]).toMatchObject({
58
- prompt: "first",
59
- firstRun: true,
60
- executable: "fake-claude",
61
- });
62
- expect(runner.run.mock.calls[1][0]).toMatchObject({
63
- prompt: "later",
64
- firstRun: false,
65
- executable: "fake-claude",
66
- });
67
- expect(repository.recordProviderProcess).toHaveBeenCalledWith("id", "one", {
68
- pid: 42,
69
- startedAt: "start",
70
- });
71
- expect(repository.completeRun).toHaveBeenCalledWith(
72
- "id",
73
- "one",
74
- expect.objectContaining({
75
- status: "succeeded",
76
- exitCode: 0,
77
- sessionHealth: "healthy",
78
- }),
79
- );
80
- });
81
-
82
- it("rejects a non-Claude target without acquiring or mutating it", async () => {
83
- const api = (await import("../../../../index.js")) as Record<string, unknown>;
84
- const Service = api.ClaudePrintAgentService as new (options: unknown) => any;
85
- const target = { id: "id", name: "reviewer", provider: "pi" };
86
- const repository = {
87
- resolve: vi.fn().mockResolvedValue(target),
88
- acquireRun: vi.fn(),
89
- recordProviderProcess: vi.fn(),
90
- completeRun: vi.fn(),
91
- };
92
-
93
- await expect(
94
- new Service({ repository, probe: { validate: vi.fn() }, runner: { run: vi.fn() } }).send(
95
- "reviewer",
96
- "x",
97
- ),
98
- ).rejects.toMatchObject({ code: "CLAUDE_PRINT_UNSUPPORTED" });
99
- expect(repository.acquireRun).not.toHaveBeenCalled();
100
- expect(repository.completeRun).not.toHaveBeenCalled();
101
- });
102
-
103
- it("does not turn a successful completion write failure into a second completion", async () => {
104
- const api = (await import("../../../../index.js")) as Record<string, unknown>;
105
- const Service = api.ClaudePrintAgentService as new (options: unknown) => any;
106
- const target = {
107
- id: "id",
108
- name: "reviewer",
109
- provider: "claude",
110
- providerSessionId: "session",
111
- sessionHealth: "healthy",
112
- };
113
- const completionFailure = new Error("completion failed");
114
- const repository = {
115
- resolve: vi.fn().mockResolvedValue(target),
116
- acquireRun: vi.fn().mockResolvedValue({ agent: target, token: "one" }),
117
- recordProviderProcess: vi.fn(),
118
- completeRun: vi.fn().mockRejectedValue(completionFailure),
119
- };
120
- const runner = {
121
- run: vi.fn().mockResolvedValue({ sessionId: "session", result: "answer", exitCode: 0 }),
122
- };
123
-
124
- await expect(
125
- new Service({ repository, probe: { validate: vi.fn() }, runner }).send("reviewer", "x"),
126
- ).rejects.toBe(completionFailure);
127
- expect(repository.completeRun).toHaveBeenCalledOnce();
128
- });
129
- });
@@ -1,152 +0,0 @@
1
- import { EventEmitter } from "node:events";
2
- import { PassThrough, Writable } from "node:stream";
3
- import { describe, expect, it, vi } from "vitest";
4
- import type { DurableAgent } from "../../../../durable/DurableAgent.js";
5
- import { ClaudePrintRunner } from "../../../../harnesses/claude/durable/ClaudePrintRunner.js";
6
-
7
- function agent(): DurableAgent {
8
- return {
9
- id: "11111111-1111-4111-8111-111111111111",
10
- name: "reviewer",
11
- provider: "claude",
12
- mode: "durable",
13
- cwd: "/project",
14
- providerSessionId: "22222222-2222-4222-8222-222222222222",
15
- state: "running",
16
- sessionHealth: "uninitialized",
17
- createdAt: "",
18
- updatedAt: "",
19
- lastActiveAt: null,
20
- lastResult: null,
21
- activeRun: null,
22
- };
23
- }
24
-
25
- function fakeSpawn(events: object[], exitCode = 0) {
26
- const calls: unknown[][] = [];
27
- const promptChunks: Buffer[] = [];
28
- const child = new EventEmitter() as any;
29
- child.pid = 4242;
30
- child.stdout = new PassThrough();
31
- child.stderr = new PassThrough();
32
- child.stdin = new Writable({
33
- write(chunk, _encoding, callback) {
34
- promptChunks.push(Buffer.from(chunk));
35
- callback();
36
- },
37
- final(callback) {
38
- for (const event of events) child.stdout.write(`${JSON.stringify(event)}\n`);
39
- child.stdout.end();
40
- queueMicrotask(() => child.emit("close", exitCode, null));
41
- callback();
42
- },
43
- });
44
- const spawn = vi.fn((...args: unknown[]) => {
45
- calls.push(args);
46
- return child;
47
- });
48
- return { spawn, calls, promptChunks };
49
- }
50
-
51
- describe("ClaudePrintRunner", () => {
52
- it("starts a caller-assigned session and persists provider identity before stdin", async () => {
53
- const fixture = fakeSpawn([
54
- { type: "system", subtype: "init", session_id: agent().providerSessionId },
55
- { type: "result", session_id: agent().providerSessionId, result: "done" },
56
- ]);
57
- let persisted = false;
58
- const runner = new ClaudePrintRunner({
59
- spawn: fixture.spawn,
60
- processInspector: {
61
- getIdentity: () => ({ pid: 4242, startedAt: "provider-start" }),
62
- },
63
- });
64
-
65
- const result = await runner.run({
66
- agent: agent(),
67
- prompt: "secret prompt",
68
- executable: "claude-test",
69
- firstRun: true,
70
- onSpawn: async () => {
71
- expect(fixture.promptChunks).toHaveLength(0);
72
- persisted = true;
73
- },
74
- });
75
-
76
- expect(persisted).toBe(true);
77
- expect(fixture.calls[0]).toEqual([
78
- "claude-test",
79
- [
80
- "-p",
81
- "--session-id",
82
- agent().providerSessionId,
83
- "--output-format",
84
- "stream-json",
85
- "--verbose",
86
- ],
87
- expect.objectContaining({ cwd: "/project", shell: false, stdio: ["pipe", "pipe", "pipe"] }),
88
- ]);
89
- expect(JSON.stringify(fixture.calls)).not.toContain("secret prompt");
90
- expect(Buffer.concat(fixture.promptChunks).toString()).toBe("secret prompt");
91
- expect(result).toEqual({ sessionId: agent().providerSessionId, result: "done", exitCode: 0 });
92
- });
93
-
94
- it("uses exact resume and rejects a mismatched result session", async () => {
95
- const fixture = fakeSpawn([{ type: "result", session_id: "wrong", result: "nope" }]);
96
- const runner = new ClaudePrintRunner({
97
- spawn: fixture.spawn,
98
- processInspector: {
99
- getIdentity: () => ({ pid: 4242, startedAt: "provider-start" }),
100
- },
101
- });
102
-
103
- await expect(
104
- runner.run({
105
- agent: agent(),
106
- prompt: "followup",
107
- executable: "claude",
108
- firstRun: false,
109
- onSpawn: vi.fn(),
110
- }),
111
- ).rejects.toMatchObject({ code: "CLAUDE_SESSION_MISMATCH" });
112
- expect(fixture.calls[0]![1]).toEqual([
113
- "-p",
114
- "--resume",
115
- agent().providerSessionId,
116
- "--output-format",
117
- "stream-json",
118
- "--verbose",
119
- ]);
120
- });
121
-
122
- it("does not disclose provider stderr in a failed-run error", async () => {
123
- const fixture = fakeSpawn([], 1);
124
- const runner = new ClaudePrintRunner({
125
- spawn: fixture.spawn,
126
- processInspector: {
127
- getIdentity: () => ({ pid: 4242, startedAt: "provider-start" }),
128
- },
129
- });
130
- fixture.spawn.mockImplementationOnce((...args: unknown[]) => {
131
- const child = (fakeSpawn([], 1).spawn as any)(...args);
132
- child.stdin = new Writable({
133
- final(callback) {
134
- child.stderr.write("secret prompt echoed by provider");
135
- child.stderr.end();
136
- queueMicrotask(() => child.emit("close", 1, null));
137
- callback();
138
- },
139
- });
140
- return child;
141
- });
142
-
143
- await expect(
144
- runner.run({
145
- agent: agent(),
146
- prompt: "secret prompt",
147
- firstRun: true,
148
- onSpawn: vi.fn(),
149
- }),
150
- ).rejects.not.toThrow(/secret prompt/);
151
- });
152
- });