@ai-devkit/agent-manager 0.43.0 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (444) hide show
  1. package/package.json +8 -3
  2. package/.swcrc +0 -27
  3. package/dist/__tests__/AgentManager.test.js +0 -1727
  4. package/dist/__tests__/AgentManager.test.js.map +0 -1
  5. package/dist/__tests__/adapters/IncrementalSessionRefresh.test.js +0 -486
  6. package/dist/__tests__/adapters/IncrementalSessionRefresh.test.js.map +0 -1
  7. package/dist/__tests__/adapters/adapterProcessImports.test.js +0 -52
  8. package/dist/__tests__/adapters/adapterProcessImports.test.js.map +0 -1
  9. package/dist/__tests__/adapters/adapterSnapshotCandidates.test.js +0 -247
  10. package/dist/__tests__/adapters/adapterSnapshotCandidates.test.js.map +0 -1
  11. package/dist/__tests__/capacity/anthropic.test.js +0 -115
  12. package/dist/__tests__/capacity/anthropic.test.js.map +0 -1
  13. package/dist/__tests__/capacity/boundaries.test.js +0 -45
  14. package/dist/__tests__/capacity/boundaries.test.js.map +0 -1
  15. package/dist/__tests__/capacity/claude.test.js +0 -485
  16. package/dist/__tests__/capacity/claude.test.js.map +0 -1
  17. package/dist/__tests__/capacity/codex.test.js +0 -339
  18. package/dist/__tests__/capacity/codex.test.js.map +0 -1
  19. package/dist/__tests__/capacity/devin.test.js +0 -239
  20. package/dist/__tests__/capacity/devin.test.js.map +0 -1
  21. package/dist/__tests__/capacity/index.test.js +0 -53
  22. package/dist/__tests__/capacity/index.test.js.map +0 -1
  23. package/dist/__tests__/capacity/openai.test.js +0 -687
  24. package/dist/__tests__/capacity/openai.test.js.map +0 -1
  25. package/dist/__tests__/capacity/wham.test.js +0 -159
  26. package/dist/__tests__/capacity/wham.test.js.map +0 -1
  27. package/dist/__tests__/capacity/zai.test.js +0 -212
  28. package/dist/__tests__/capacity/zai.test.js.map +0 -1
  29. package/dist/__tests__/fixtures.test.js +0 -218
  30. package/dist/__tests__/fixtures.test.js.map +0 -1
  31. package/dist/__tests__/harnesses/BoundedSummarySkip.test.js +0 -568
  32. package/dist/__tests__/harnesses/BoundedSummarySkip.test.js.map +0 -1
  33. package/dist/__tests__/harnesses/SessionSummaryEquivalence.test.js +0 -1089
  34. package/dist/__tests__/harnesses/SessionSummaryEquivalence.test.js.map +0 -1
  35. package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.js +0 -143
  36. package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.js.map +0 -1
  37. package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.js +0 -462
  38. package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.js.map +0 -1
  39. package/dist/__tests__/harnesses/builtinAdapters.test.js +0 -33
  40. package/dist/__tests__/harnesses/builtinAdapters.test.js.map +0 -1
  41. package/dist/__tests__/harnesses/claude/ClaudeAgentMapper.test.js +0 -79
  42. package/dist/__tests__/harnesses/claude/ClaudeAgentMapper.test.js.map +0 -1
  43. package/dist/__tests__/harnesses/claude/ClaudeCodeAdapter.test.js +0 -1881
  44. package/dist/__tests__/harnesses/claude/ClaudeCodeAdapter.test.js.map +0 -1
  45. package/dist/__tests__/harnesses/claude/ClaudeSessionLocator.test.js +0 -425
  46. package/dist/__tests__/harnesses/claude/ClaudeSessionLocator.test.js.map +0 -1
  47. package/dist/__tests__/harnesses/claude/ClaudeSessionParser.test.js +0 -314
  48. package/dist/__tests__/harnesses/claude/ClaudeSessionParser.test.js.map +0 -1
  49. package/dist/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.js +0 -49
  50. package/dist/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.js.map +0 -1
  51. package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.js +0 -76
  52. package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.js.map +0 -1
  53. package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.js +0 -173
  54. package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.js.map +0 -1
  55. package/dist/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.js +0 -181
  56. package/dist/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.js.map +0 -1
  57. package/dist/__tests__/harnesses/codex/CodexAdapter.test.js +0 -685
  58. package/dist/__tests__/harnesses/codex/CodexAdapter.test.js.map +0 -1
  59. package/dist/__tests__/harnesses/codex/CodexSessionLocator.test.js +0 -463
  60. package/dist/__tests__/harnesses/codex/CodexSessionLocator.test.js.map +0 -1
  61. package/dist/__tests__/harnesses/codex/CodexSessionMapping.test.js +0 -86
  62. package/dist/__tests__/harnesses/codex/CodexSessionMapping.test.js.map +0 -1
  63. package/dist/__tests__/harnesses/codex/CodexSessionParser.test.js +0 -254
  64. package/dist/__tests__/harnesses/codex/CodexSessionParser.test.js.map +0 -1
  65. package/dist/__tests__/harnesses/codex/durable/CodexCliProbe.test.js +0 -121
  66. package/dist/__tests__/harnesses/codex/durable/CodexCliProbe.test.js.map +0 -1
  67. package/dist/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.js +0 -84
  68. package/dist/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.js.map +0 -1
  69. package/dist/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.js +0 -128
  70. package/dist/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.js.map +0 -1
  71. package/dist/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.js +0 -246
  72. package/dist/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.js.map +0 -1
  73. package/dist/__tests__/harnesses/codex/durable/CodexPrintRunner.test.js +0 -384
  74. package/dist/__tests__/harnesses/codex/durable/CodexPrintRunner.test.js.map +0 -1
  75. package/dist/__tests__/harnesses/copilot/CopilotAdapter.test.js +0 -659
  76. package/dist/__tests__/harnesses/copilot/CopilotAdapter.test.js.map +0 -1
  77. package/dist/__tests__/harnesses/copilot/CopilotRefreshIO.test.js +0 -290
  78. package/dist/__tests__/harnesses/copilot/CopilotRefreshIO.test.js.map +0 -1
  79. package/dist/__tests__/harnesses/devin/DevinAdapter.test.js +0 -597
  80. package/dist/__tests__/harnesses/devin/DevinAdapter.test.js.map +0 -1
  81. package/dist/__tests__/harnesses/devin/DevinAgentMapper.test.js +0 -99
  82. package/dist/__tests__/harnesses/devin/DevinAgentMapper.test.js.map +0 -1
  83. package/dist/__tests__/harnesses/devin/DevinSessionLocator.test.js +0 -192
  84. package/dist/__tests__/harnesses/devin/DevinSessionLocator.test.js.map +0 -1
  85. package/dist/__tests__/harnesses/devin/DevinSessionParser.test.js +0 -407
  86. package/dist/__tests__/harnesses/devin/DevinSessionParser.test.js.map +0 -1
  87. package/dist/__tests__/harnesses/devin/fixtures.js +0 -95
  88. package/dist/__tests__/harnesses/devin/fixtures.js.map +0 -1
  89. package/dist/__tests__/harnesses/gemini/GeminiCliAdapter.test.js +0 -1454
  90. package/dist/__tests__/harnesses/gemini/GeminiCliAdapter.test.js.map +0 -1
  91. package/dist/__tests__/harnesses/gemini/GeminiSessionJsonl.test.js +0 -491
  92. package/dist/__tests__/harnesses/gemini/GeminiSessionJsonl.test.js.map +0 -1
  93. package/dist/__tests__/harnesses/gemini/GeminiSessionLocator.test.js +0 -399
  94. package/dist/__tests__/harnesses/gemini/GeminiSessionLocator.test.js.map +0 -1
  95. package/dist/__tests__/harnesses/grok/GrokAgentMapper.test.js +0 -56
  96. package/dist/__tests__/harnesses/grok/GrokAgentMapper.test.js.map +0 -1
  97. package/dist/__tests__/harnesses/grok/GrokCliAdapter.test.js +0 -421
  98. package/dist/__tests__/harnesses/grok/GrokCliAdapter.test.js.map +0 -1
  99. package/dist/__tests__/harnesses/grok/GrokIncrementalRefresh.test.js +0 -167
  100. package/dist/__tests__/harnesses/grok/GrokIncrementalRefresh.test.js.map +0 -1
  101. package/dist/__tests__/harnesses/grok/GrokSessionLocator.test.js +0 -133
  102. package/dist/__tests__/harnesses/grok/GrokSessionLocator.test.js.map +0 -1
  103. package/dist/__tests__/harnesses/grok/GrokSessionParser.test.js +0 -301
  104. package/dist/__tests__/harnesses/grok/GrokSessionParser.test.js.map +0 -1
  105. package/dist/__tests__/harnesses/kiro/KiroAdapter.test.js +0 -662
  106. package/dist/__tests__/harnesses/kiro/KiroAdapter.test.js.map +0 -1
  107. package/dist/__tests__/harnesses/muse/MuseAdapter.test.js +0 -247
  108. package/dist/__tests__/harnesses/muse/MuseAdapter.test.js.map +0 -1
  109. package/dist/__tests__/harnesses/muse/MuseAgentMapper.test.js +0 -81
  110. package/dist/__tests__/harnesses/muse/MuseAgentMapper.test.js.map +0 -1
  111. package/dist/__tests__/harnesses/muse/MuseSessionLocator.test.js +0 -185
  112. package/dist/__tests__/harnesses/muse/MuseSessionLocator.test.js.map +0 -1
  113. package/dist/__tests__/harnesses/muse/MuseSessionParser.test.js +0 -328
  114. package/dist/__tests__/harnesses/muse/MuseSessionParser.test.js.map +0 -1
  115. package/dist/__tests__/harnesses/opencode/OpenCodeAdapter.test.js +0 -213
  116. package/dist/__tests__/harnesses/opencode/OpenCodeAdapter.test.js.map +0 -1
  117. package/dist/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.js +0 -108
  118. package/dist/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.js.map +0 -1
  119. package/dist/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.js +0 -94
  120. package/dist/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.js.map +0 -1
  121. package/dist/__tests__/harnesses/opencode/OpenCodeSessionParser.test.js +0 -147
  122. package/dist/__tests__/harnesses/opencode/OpenCodeSessionParser.test.js.map +0 -1
  123. package/dist/__tests__/harnesses/pi/PiAdapter.test.js +0 -367
  124. package/dist/__tests__/harnesses/pi/PiAdapter.test.js.map +0 -1
  125. package/dist/__tests__/harnesses/pi/PiDiscoveryIO.test.js +0 -382
  126. package/dist/__tests__/harnesses/pi/PiDiscoveryIO.test.js.map +0 -1
  127. package/dist/__tests__/harnesses/pi/PiSessionParser.test.js +0 -416
  128. package/dist/__tests__/harnesses/pi/PiSessionParser.test.js.map +0 -1
  129. package/dist/__tests__/harnesses/pi/PiSessionTracker.test.js +0 -108
  130. package/dist/__tests__/harnesses/pi/PiSessionTracker.test.js.map +0 -1
  131. package/dist/__tests__/harnesses/pi/durable/PiCliProbe.test.js +0 -70
  132. package/dist/__tests__/harnesses/pi/durable/PiCliProbe.test.js.map +0 -1
  133. package/dist/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.js +0 -43
  134. package/dist/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.js.map +0 -1
  135. package/dist/__tests__/harnesses/pi/durable/PiPrintAgentService.test.js +0 -192
  136. package/dist/__tests__/harnesses/pi/durable/PiPrintAgentService.test.js.map +0 -1
  137. package/dist/__tests__/harnesses/pi/durable/PiPrintProtocol.test.js +0 -119
  138. package/dist/__tests__/harnesses/pi/durable/PiPrintProtocol.test.js.map +0 -1
  139. package/dist/__tests__/harnesses/pi/durable/PiPrintRunner.test.js +0 -382
  140. package/dist/__tests__/harnesses/pi/durable/PiPrintRunner.test.js.map +0 -1
  141. package/dist/__tests__/harnesses/pi/durable/PiStreamParser.test.js +0 -34
  142. package/dist/__tests__/harnesses/pi/durable/PiStreamParser.test.js.map +0 -1
  143. package/dist/__tests__/harnesses/readiness/AgentReadiness.test.js +0 -446
  144. package/dist/__tests__/harnesses/readiness/AgentReadiness.test.js.map +0 -1
  145. package/dist/__tests__/harnesses/runtimeProfiles.test.js +0 -101
  146. package/dist/__tests__/harnesses/runtimeProfiles.test.js.map +0 -1
  147. package/dist/__tests__/print/DurableAgent.test.js +0 -15
  148. package/dist/__tests__/print/DurableAgent.test.js.map +0 -1
  149. package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js +0 -186
  150. package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js.map +0 -1
  151. package/dist/__tests__/print/DurableAgentRepository.test.js +0 -249
  152. package/dist/__tests__/print/DurableAgentRepository.test.js.map +0 -1
  153. package/dist/__tests__/readiness-fixtures.test.js +0 -54
  154. package/dist/__tests__/readiness-fixtures.test.js.map +0 -1
  155. package/dist/__tests__/runtime/AgentRuntime.test.js +0 -13
  156. package/dist/__tests__/runtime/AgentRuntime.test.js.map +0 -1
  157. package/dist/__tests__/runtime/HerdrAgentDiscovery.test.js +0 -164
  158. package/dist/__tests__/runtime/HerdrAgentDiscovery.test.js.map +0 -1
  159. package/dist/__tests__/runtime/HerdrAgentRuntime.test.js +0 -488
  160. package/dist/__tests__/runtime/HerdrAgentRuntime.test.js.map +0 -1
  161. package/dist/__tests__/runtime/ManagedAgentRuntime.test.js +0 -637
  162. package/dist/__tests__/runtime/ManagedAgentRuntime.test.js.map +0 -1
  163. package/dist/__tests__/terminal/GhosttyBackend.test.js +0 -334
  164. package/dist/__tests__/terminal/GhosttyBackend.test.js.map +0 -1
  165. package/dist/__tests__/terminal/TerminalFocusManager.test.js +0 -253
  166. package/dist/__tests__/terminal/TerminalFocusManager.test.js.map +0 -1
  167. package/dist/__tests__/terminal/TmuxManager.test.js +0 -168
  168. package/dist/__tests__/terminal/TmuxManager.test.js.map +0 -1
  169. package/dist/__tests__/terminal/TtyWriter.test.js +0 -386
  170. package/dist/__tests__/terminal/TtyWriter.test.js.map +0 -1
  171. package/dist/__tests__/utils/AgentRegistry.test.js +0 -636
  172. package/dist/__tests__/utils/AgentRegistry.test.js.map +0 -1
  173. package/dist/__tests__/utils/IncrementalJsonlSummary.test.js +0 -650
  174. package/dist/__tests__/utils/IncrementalJsonlSummary.test.js.map +0 -1
  175. package/dist/__tests__/utils/agent-requests.test.js +0 -90
  176. package/dist/__tests__/utils/agent-requests.test.js.map +0 -1
  177. package/dist/__tests__/utils/conversationTail.bench.test.js +0 -258
  178. package/dist/__tests__/utils/conversationTail.bench.test.js.map +0 -1
  179. package/dist/__tests__/utils/conversationTailParity.test.js +0 -588
  180. package/dist/__tests__/utils/conversationTailParity.test.js.map +0 -1
  181. package/dist/__tests__/utils/jsonlTail.test.js +0 -360
  182. package/dist/__tests__/utils/jsonlTail.test.js.map +0 -1
  183. package/dist/__tests__/utils/matching.test.js +0 -324
  184. package/dist/__tests__/utils/matching.test.js.map +0 -1
  185. package/dist/__tests__/utils/matchingConstants.test.js +0 -35
  186. package/dist/__tests__/utils/matchingConstants.test.js.map +0 -1
  187. package/dist/__tests__/utils/process.test.js +0 -818
  188. package/dist/__tests__/utils/process.test.js.map +0 -1
  189. package/dist/__tests__/utils/session.test.js +0 -175
  190. package/dist/__tests__/utils/session.test.js.map +0 -1
  191. package/project.json +0 -29
  192. package/scripts/benchmark-cold-start.mjs +0 -350
  193. package/src/AgentManager.ts +0 -559
  194. package/src/__tests__/AgentManager.test.ts +0 -1578
  195. package/src/__tests__/adapters/IncrementalSessionRefresh.test.ts +0 -437
  196. package/src/__tests__/adapters/adapterProcessImports.test.ts +0 -58
  197. package/src/__tests__/adapters/adapterSnapshotCandidates.test.ts +0 -243
  198. package/src/__tests__/capacity/anthropic.test.ts +0 -105
  199. package/src/__tests__/capacity/boundaries.test.ts +0 -36
  200. package/src/__tests__/capacity/claude.test.ts +0 -462
  201. package/src/__tests__/capacity/codex.test.ts +0 -311
  202. package/src/__tests__/capacity/devin.test.ts +0 -210
  203. package/src/__tests__/capacity/fixtures/claude-credentials.json +0 -7
  204. package/src/__tests__/capacity/fixtures/claude-usage-malformed.json +0 -1
  205. package/src/__tests__/capacity/fixtures/claude-usage-partial.json +0 -15
  206. package/src/__tests__/capacity/fixtures/claude-usage.json +0 -63
  207. package/src/__tests__/capacity/fixtures/devin-config.json +0 -6
  208. package/src/__tests__/capacity/fixtures/devin-credentials.toml +0 -4
  209. package/src/__tests__/capacity/fixtures/devin-quota-nonplan.json +0 -5
  210. package/src/__tests__/capacity/fixtures/devin-quota.json +0 -10
  211. package/src/__tests__/capacity/fixtures/openai-auth.json +0 -6
  212. package/src/__tests__/capacity/fixtures/openai-codex-auth.json +0 -9
  213. package/src/__tests__/capacity/fixtures/openai-usage-completions.json +0 -67
  214. package/src/__tests__/capacity/fixtures/openai-usage-responses.json +0 -20
  215. package/src/__tests__/capacity/fixtures/wham-usage.json +0 -45
  216. package/src/__tests__/capacity/fixtures/zai-auth.json +0 -6
  217. package/src/__tests__/capacity/fixtures/zai-quota-invalid.json +0 -7
  218. package/src/__tests__/capacity/fixtures/zai-quota.json +0 -38
  219. package/src/__tests__/capacity/index.test.ts +0 -54
  220. package/src/__tests__/capacity/openai.test.ts +0 -571
  221. package/src/__tests__/capacity/wham.test.ts +0 -122
  222. package/src/__tests__/capacity/zai.test.ts +0 -151
  223. package/src/__tests__/fixtures.test.ts +0 -245
  224. package/src/__tests__/harnesses/BoundedSummarySkip.test.ts +0 -496
  225. package/src/__tests__/harnesses/SessionSummaryEquivalence.test.ts +0 -726
  226. package/src/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.ts +0 -133
  227. package/src/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.ts +0 -396
  228. package/src/__tests__/harnesses/builtinAdapters.test.ts +0 -33
  229. package/src/__tests__/harnesses/claude/ClaudeAgentMapper.test.ts +0 -84
  230. package/src/__tests__/harnesses/claude/ClaudeCodeAdapter.test.ts +0 -1793
  231. package/src/__tests__/harnesses/claude/ClaudeSessionLocator.test.ts +0 -423
  232. package/src/__tests__/harnesses/claude/ClaudeSessionParser.test.ts +0 -300
  233. package/src/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.ts +0 -34
  234. package/src/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.ts +0 -61
  235. package/src/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.ts +0 -129
  236. package/src/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.ts +0 -152
  237. package/src/__tests__/harnesses/codex/CodexAdapter.test.ts +0 -652
  238. package/src/__tests__/harnesses/codex/CodexSessionLocator.test.ts +0 -419
  239. package/src/__tests__/harnesses/codex/CodexSessionMapping.test.ts +0 -63
  240. package/src/__tests__/harnesses/codex/CodexSessionParser.test.ts +0 -192
  241. package/src/__tests__/harnesses/codex/durable/CodexCliProbe.test.ts +0 -80
  242. package/src/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.ts +0 -65
  243. package/src/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.ts +0 -104
  244. package/src/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.ts +0 -201
  245. package/src/__tests__/harnesses/codex/durable/CodexPrintRunner.test.ts +0 -299
  246. package/src/__tests__/harnesses/copilot/CopilotAdapter.test.ts +0 -614
  247. package/src/__tests__/harnesses/copilot/CopilotRefreshIO.test.ts +0 -270
  248. package/src/__tests__/harnesses/devin/DevinAdapter.test.ts +0 -290
  249. package/src/__tests__/harnesses/devin/DevinAgentMapper.test.ts +0 -101
  250. package/src/__tests__/harnesses/devin/DevinSessionLocator.test.ts +0 -139
  251. package/src/__tests__/harnesses/devin/DevinSessionParser.test.ts +0 -212
  252. package/src/__tests__/harnesses/devin/fixtures.ts +0 -144
  253. package/src/__tests__/harnesses/gemini/GeminiCliAdapter.test.ts +0 -1336
  254. package/src/__tests__/harnesses/gemini/GeminiSessionJsonl.test.ts +0 -402
  255. package/src/__tests__/harnesses/gemini/GeminiSessionLocator.test.ts +0 -396
  256. package/src/__tests__/harnesses/grok/GrokAgentMapper.test.ts +0 -57
  257. package/src/__tests__/harnesses/grok/GrokCliAdapter.test.ts +0 -376
  258. package/src/__tests__/harnesses/grok/GrokIncrementalRefresh.test.ts +0 -170
  259. package/src/__tests__/harnesses/grok/GrokSessionLocator.test.ts +0 -106
  260. package/src/__tests__/harnesses/grok/GrokSessionParser.test.ts +0 -230
  261. package/src/__tests__/harnesses/kiro/KiroAdapter.test.ts +0 -552
  262. package/src/__tests__/harnesses/muse/MuseAdapter.test.ts +0 -197
  263. package/src/__tests__/harnesses/muse/MuseAgentMapper.test.ts +0 -83
  264. package/src/__tests__/harnesses/muse/MuseSessionLocator.test.ts +0 -177
  265. package/src/__tests__/harnesses/muse/MuseSessionParser.test.ts +0 -279
  266. package/src/__tests__/harnesses/opencode/OpenCodeAdapter.test.ts +0 -215
  267. package/src/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.ts +0 -101
  268. package/src/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.ts +0 -84
  269. package/src/__tests__/harnesses/opencode/OpenCodeSessionParser.test.ts +0 -149
  270. package/src/__tests__/harnesses/pi/PiAdapter.test.ts +0 -325
  271. package/src/__tests__/harnesses/pi/PiDiscoveryIO.test.ts +0 -337
  272. package/src/__tests__/harnesses/pi/PiSessionParser.test.ts +0 -280
  273. package/src/__tests__/harnesses/pi/PiSessionTracker.test.ts +0 -79
  274. package/src/__tests__/harnesses/pi/durable/PiCliProbe.test.ts +0 -50
  275. package/src/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.ts +0 -33
  276. package/src/__tests__/harnesses/pi/durable/PiPrintAgentService.test.ts +0 -138
  277. package/src/__tests__/harnesses/pi/durable/PiPrintProtocol.test.ts +0 -71
  278. package/src/__tests__/harnesses/pi/durable/PiPrintRunner.test.ts +0 -252
  279. package/src/__tests__/harnesses/pi/durable/PiStreamParser.test.ts +0 -26
  280. package/src/__tests__/harnesses/readiness/AgentReadiness.test.ts +0 -362
  281. package/src/__tests__/harnesses/runtimeProfiles.test.ts +0 -123
  282. package/src/__tests__/print/DurableAgent.test.ts +0 -15
  283. package/src/__tests__/print/DurableAgentRepository.sqlite.test.ts +0 -128
  284. package/src/__tests__/print/DurableAgentRepository.test.ts +0 -184
  285. package/src/__tests__/readiness-fixtures.test.ts +0 -79
  286. package/src/__tests__/runtime/AgentRuntime.test.ts +0 -8
  287. package/src/__tests__/runtime/HerdrAgentDiscovery.test.ts +0 -131
  288. package/src/__tests__/runtime/HerdrAgentRuntime.test.ts +0 -377
  289. package/src/__tests__/runtime/ManagedAgentRuntime.test.ts +0 -590
  290. package/src/__tests__/terminal/GhosttyBackend.test.ts +0 -271
  291. package/src/__tests__/terminal/TerminalFocusManager.test.ts +0 -280
  292. package/src/__tests__/terminal/TmuxManager.test.ts +0 -185
  293. package/src/__tests__/terminal/TtyWriter.test.ts +0 -454
  294. package/src/__tests__/utils/AgentRegistry.test.ts +0 -532
  295. package/src/__tests__/utils/IncrementalJsonlSummary.test.ts +0 -414
  296. package/src/__tests__/utils/agent-requests.test.ts +0 -94
  297. package/src/__tests__/utils/conversationTail.bench.test.ts +0 -193
  298. package/src/__tests__/utils/conversationTailParity.test.ts +0 -365
  299. package/src/__tests__/utils/jsonlTail.test.ts +0 -317
  300. package/src/__tests__/utils/matching.test.ts +0 -234
  301. package/src/__tests__/utils/matchingConstants.test.ts +0 -40
  302. package/src/__tests__/utils/process.test.ts +0 -596
  303. package/src/__tests__/utils/session.test.ts +0 -158
  304. package/src/adapters/AgentAdapter.ts +0 -255
  305. package/src/capacity/index.ts +0 -127
  306. package/src/capacity/providers/anthropic.ts +0 -198
  307. package/src/capacity/providers/devin.ts +0 -121
  308. package/src/capacity/providers/openai-platform.ts +0 -150
  309. package/src/capacity/providers/openai-subscription.ts +0 -184
  310. package/src/capacity/providers/zai.ts +0 -155
  311. package/src/capacity/sources/claude.ts +0 -30
  312. package/src/capacity/sources/codex.ts +0 -251
  313. package/src/capacity/sources/devin.ts +0 -49
  314. package/src/capacity/sources/pi.ts +0 -131
  315. package/src/capacity/types.ts +0 -29
  316. package/src/database/connection.ts +0 -96
  317. package/src/database/index.ts +0 -7
  318. package/src/database/migrations/001_initial.sql +0 -12
  319. package/src/database/migrations/002_pins.sql +0 -1
  320. package/src/database/migrations/003_durable_agents.sql +0 -43
  321. package/src/database/migrations/004_codex_durable_sessions.sql +0 -1
  322. package/src/database/migrations/005_agent_runtime.sql +0 -2
  323. package/src/database/schema.ts +0 -64
  324. package/src/durable/DurableAgent.ts +0 -139
  325. package/src/durable/DurableAgentRepository.ts +0 -485
  326. package/src/durable/process.ts +0 -29
  327. package/src/durable/run.ts +0 -84
  328. package/src/durable/utils.ts +0 -66
  329. package/src/fixtures/bundle.ts +0 -130
  330. package/src/fixtures/capture.ts +0 -364
  331. package/src/harnesses/antigravity/AntigravityAgentMapper.ts +0 -34
  332. package/src/harnesses/antigravity/AntigravityCliAdapter.ts +0 -126
  333. package/src/harnesses/antigravity/AntigravitySessionLocator.ts +0 -75
  334. package/src/harnesses/antigravity/AntigravitySessionParser.ts +0 -252
  335. package/src/harnesses/claude/ClaudeAgentMapper.ts +0 -55
  336. package/src/harnesses/claude/ClaudeCodeAdapter.ts +0 -175
  337. package/src/harnesses/claude/ClaudeSessionLocator.ts +0 -358
  338. package/src/harnesses/claude/ClaudeSessionParser.ts +0 -524
  339. package/src/harnesses/claude/credentials.ts +0 -122
  340. package/src/harnesses/claude/durable/ClaudeCliProbe.ts +0 -57
  341. package/src/harnesses/claude/durable/ClaudePrintAgentService.ts +0 -79
  342. package/src/harnesses/claude/durable/ClaudePrintRunner.ts +0 -102
  343. package/src/harnesses/claude/durable/ClaudeStreamParser.ts +0 -108
  344. package/src/harnesses/claude/readiness.ts +0 -69
  345. package/src/harnesses/codex/CodexAdapter.ts +0 -337
  346. package/src/harnesses/codex/CodexAgentMapper.ts +0 -26
  347. package/src/harnesses/codex/CodexSessionLocator.ts +0 -509
  348. package/src/harnesses/codex/CodexSessionMapping.ts +0 -89
  349. package/src/harnesses/codex/CodexSessionParser.ts +0 -462
  350. package/src/harnesses/codex/credentials.ts +0 -81
  351. package/src/harnesses/codex/durable/CodexCliProbe.ts +0 -68
  352. package/src/harnesses/codex/durable/CodexPrintAgentService.ts +0 -79
  353. package/src/harnesses/codex/durable/CodexPrintRunner.ts +0 -104
  354. package/src/harnesses/codex/durable/CodexStreamParser.ts +0 -117
  355. package/src/harnesses/codex/readiness.ts +0 -72
  356. package/src/harnesses/copilot/CopilotAdapter.ts +0 -161
  357. package/src/harnesses/copilot/CopilotAgentMapper.ts +0 -27
  358. package/src/harnesses/copilot/CopilotSessionLocator.ts +0 -161
  359. package/src/harnesses/copilot/CopilotSessionParser.ts +0 -380
  360. package/src/harnesses/copilot/readiness.ts +0 -33
  361. package/src/harnesses/devin/DevinAdapter.ts +0 -212
  362. package/src/harnesses/devin/DevinAgentMapper.ts +0 -39
  363. package/src/harnesses/devin/DevinSessionLocator.ts +0 -230
  364. package/src/harnesses/devin/DevinSessionParser.ts +0 -227
  365. package/src/harnesses/devin/credentials.ts +0 -88
  366. package/src/harnesses/devin/readiness.ts +0 -36
  367. package/src/harnesses/gemini/GeminiAgentMapper.ts +0 -27
  368. package/src/harnesses/gemini/GeminiCliAdapter.ts +0 -272
  369. package/src/harnesses/gemini/GeminiSessionLocator.ts +0 -394
  370. package/src/harnesses/gemini/GeminiSessionParser.ts +0 -395
  371. package/src/harnesses/gemini/fileSignature.ts +0 -10
  372. package/src/harnesses/grok/GrokAgentMapper.ts +0 -32
  373. package/src/harnesses/grok/GrokCliAdapter.ts +0 -126
  374. package/src/harnesses/grok/GrokSessionLocator.ts +0 -179
  375. package/src/harnesses/grok/GrokSessionParser.ts +0 -251
  376. package/src/harnesses/index.ts +0 -32
  377. package/src/harnesses/kiro/KiroAdapter.ts +0 -143
  378. package/src/harnesses/kiro/KiroAgentMapper.ts +0 -34
  379. package/src/harnesses/kiro/KiroSessionLocator.ts +0 -143
  380. package/src/harnesses/kiro/KiroSessionParser.ts +0 -376
  381. package/src/harnesses/muse/MuseAdapter.ts +0 -157
  382. package/src/harnesses/muse/MuseAgentMapper.ts +0 -33
  383. package/src/harnesses/muse/MuseSessionLocator.ts +0 -286
  384. package/src/harnesses/muse/MuseSessionParser.ts +0 -435
  385. package/src/harnesses/muse/readiness.ts +0 -38
  386. package/src/harnesses/opencode/OpenCodeAdapter.ts +0 -110
  387. package/src/harnesses/opencode/OpenCodeAgentMapper.ts +0 -49
  388. package/src/harnesses/opencode/OpenCodeSessionLocator.ts +0 -151
  389. package/src/harnesses/opencode/OpenCodeSessionParser.ts +0 -146
  390. package/src/harnesses/opencode/readiness.ts +0 -48
  391. package/src/harnesses/pi/PiAdapter.ts +0 -197
  392. package/src/harnesses/pi/PiAgentMapper.ts +0 -27
  393. package/src/harnesses/pi/PiSessionLocator.ts +0 -288
  394. package/src/harnesses/pi/PiSessionParser.ts +0 -488
  395. package/src/harnesses/pi/PiSessionTracker.ts +0 -87
  396. package/src/harnesses/pi/credentials.ts +0 -129
  397. package/src/harnesses/pi/durable/PiCliProbe.ts +0 -56
  398. package/src/harnesses/pi/durable/PiPrintAgentService.ts +0 -77
  399. package/src/harnesses/pi/durable/PiPrintProtocol.ts +0 -41
  400. package/src/harnesses/pi/durable/PiPrintRunner.ts +0 -95
  401. package/src/harnesses/pi/durable/PiStreamParser.ts +0 -94
  402. package/src/harnesses/pi/readiness.ts +0 -104
  403. package/src/harnesses/readiness/AgentReadiness.ts +0 -91
  404. package/src/harnesses/readiness/checks.ts +0 -336
  405. package/src/harnesses/readiness/types.ts +0 -90
  406. package/src/harnesses/runtimeProfiles.ts +0 -105
  407. package/src/harnesses/shared.ts +0 -124
  408. package/src/index.ts +0 -71
  409. package/src/runtime/ManagedAgentRuntime.ts +0 -253
  410. package/src/runtime/RuntimeFactory.ts +0 -13
  411. package/src/runtime/errors.ts +0 -50
  412. package/src/runtime/herdr/HerdrAgentDiscovery.ts +0 -166
  413. package/src/runtime/herdr/HerdrAgentRuntime.ts +0 -216
  414. package/src/runtime/herdr/HerdrCliClient.ts +0 -78
  415. package/src/runtime/herdr/HerdrErrors.ts +0 -9
  416. package/src/runtime/herdr/HerdrResponseParsers.ts +0 -86
  417. package/src/runtime/herdr/HerdrRuntimeRef.ts +0 -41
  418. package/src/runtime/tmux/PidPolling.ts +0 -34
  419. package/src/runtime/tmux/TmuxAgentRuntime.ts +0 -113
  420. package/src/runtime/tmux/TmuxManager.ts +0 -102
  421. package/src/runtime/tmux/TmuxRuntimeRef.ts +0 -9
  422. package/src/runtime/types.ts +0 -56
  423. package/src/terminal/TerminalFocusManager.ts +0 -52
  424. package/src/terminal/TtyWriter.ts +0 -26
  425. package/src/terminal/backends/ghostty.ts +0 -180
  426. package/src/terminal/backends/index.ts +0 -23
  427. package/src/terminal/backends/iterm2.ts +0 -126
  428. package/src/terminal/backends/shared.ts +0 -47
  429. package/src/terminal/backends/terminal-app.ts +0 -122
  430. package/src/terminal/backends/tmux.ts +0 -62
  431. package/src/terminal/backends/wezterm.ts +0 -65
  432. package/src/terminal/types.ts +0 -23
  433. package/src/utils/AgentRegistry.ts +0 -351
  434. package/src/utils/IncrementalJsonlSummary.ts +0 -306
  435. package/src/utils/agent-requests.ts +0 -28
  436. package/src/utils/applescript.ts +0 -10
  437. package/src/utils/jsonlTail.ts +0 -349
  438. package/src/utils/matching.ts +0 -96
  439. package/src/utils/matchingConstants.ts +0 -15
  440. package/src/utils/process.ts +0 -604
  441. package/src/utils/session.ts +0 -144
  442. package/src/utils/sortAgents.ts +0 -54
  443. package/tsconfig.json +0 -11
  444. package/vitest.config.ts +0 -20
@@ -1,179 +0,0 @@
1
- import * as path from "path";
2
- import type { ProcessInfo } from "../../adapters/AgentAdapter.js";
3
- import {
4
- isDirectory,
5
- isSafePathSegment,
6
- safeReadFile,
7
- safeReaddir,
8
- safeStat,
9
- } from "../../utils/session.js";
10
- import { homeDir } from "../shared.js";
11
- import { CHAT_HISTORY_FILE } from "./GrokSessionParser.js";
12
-
13
- const ACTIVE_SESSIONS_FILE = "active_sessions.json";
14
- const CWD_FILE = ".cwd";
15
-
16
- /** One entry of ~/.grok/active_sessions.json. */
17
- interface ActiveSessionEntry {
18
- pid?: number;
19
- cwd?: string;
20
- opened_at?: number | string;
21
- }
22
-
23
- /** A live Grok process paired with its resolved cwd and (if any) session dir. */
24
- export interface GrokProcessMatch {
25
- process: ProcessInfo;
26
- cwd: string;
27
- sessionDir: string | null;
28
- }
29
-
30
- /** A historical session dir plus the cwd decoded from its group dir. */
31
- export interface GrokSessionDir {
32
- sessionDir: string;
33
- defaultCwd: string;
34
- }
35
-
36
- export interface GrokSessionLocatorOptions {
37
- /** Overrides the ~/.grok base directory (defaults to GROK_HOME or ~/.grok). */
38
- baseDir?: string;
39
- }
40
-
41
- export class GrokSessionLocator {
42
- private readonly baseDir: string;
43
- private readonly sessionsDir: string;
44
-
45
- constructor(options: GrokSessionLocatorOptions = {}) {
46
- // GROK_HOME overrides the ~/.grok base directory; sessions live under
47
- // <base>/sessions/ and the active-session registry at
48
- // <base>/active_sessions.json.
49
- this.baseDir = options.baseDir ?? (process.env.GROK_HOME || path.join(homeDir(), ".grok"));
50
- this.sessionsDir = path.join(this.baseDir, "sessions");
51
- }
52
-
53
- /**
54
- * Pair live Grok processes with their session dirs.
55
- *
56
- * active_sessions.json is the authoritative pid -> cwd map for live
57
- * sessions; the lsof-derived process cwd is only a fallback. The most
58
- * recently active session under that cwd's group dir is picked.
59
- */
60
- matchRunningProcesses(processes: ProcessInfo[]): GrokProcessMatch[] {
61
- const pidToCwd = this.readActiveSessions();
62
- return processes.map((proc) => {
63
- const cwd = pidToCwd.get(proc.pid) || proc.cwd || "";
64
- return { process: proc, cwd, sessionDir: cwd ? this.latestSessionDir(cwd) : null };
65
- });
66
- }
67
-
68
- /** Every session dir under ~/.grok/sessions/, across all project groups. */
69
- discoverHistoricalSessionDirs(): GrokSessionDir[] {
70
- const results: GrokSessionDir[] = [];
71
- for (const { groupDir, defaultCwd } of this.listGroups()) {
72
- for (const sessionDir of this.listSessionDirs(groupDir)) {
73
- results.push({ sessionDir, defaultCwd });
74
- }
75
- }
76
- return results;
77
- }
78
-
79
- /** Session dirs named exactly `sessionId`, across all project groups. */
80
- findHistoricalSessionDirsById(sessionId: string): GrokSessionDir[] {
81
- if (!isSafePathSegment(sessionId)) return [];
82
-
83
- const results: GrokSessionDir[] = [];
84
- for (const { groupDir, defaultCwd } of this.listGroups()) {
85
- const sessionDir = path.join(groupDir, sessionId);
86
- if (isDirectory(sessionDir)) {
87
- results.push({ sessionDir, defaultCwd });
88
- }
89
- }
90
- return results;
91
- }
92
-
93
- /**
94
- * Read ~/.grok/active_sessions.json into a pid -> cwd map. Grok writes one
95
- * { pid, cwd, opened_at } entry per running session and removes it on exit,
96
- * so this is the reliable way to learn a live process's working directory.
97
- */
98
- private readActiveSessions(): Map<number, string> {
99
- const map = new Map<number, string>();
100
- const content = safeReadFile(path.join(this.baseDir, ACTIVE_SESSIONS_FILE));
101
- if (content === undefined) return map;
102
-
103
- let entries: unknown;
104
- try {
105
- entries = JSON.parse(content);
106
- } catch {
107
- return map;
108
- }
109
- if (!Array.isArray(entries)) return map;
110
-
111
- for (const entry of entries as ActiveSessionEntry[]) {
112
- if (typeof entry?.pid === "number" && typeof entry?.cwd === "string" && entry.cwd) {
113
- map.set(entry.pid, entry.cwd);
114
- }
115
- }
116
- return map;
117
- }
118
-
119
- /**
120
- * Return the most recently active session subdirectory for a cwd, i.e. the
121
- * ~/.grok/sessions/<encodeURIComponent(cwd)>/<id>/ whose chat_history.jsonl
122
- * was written last. Returns null when the group dir or any transcript is
123
- * missing.
124
- */
125
- private latestSessionDir(cwd: string): string | null {
126
- const groupDir = path.join(this.sessionsDir, encodeURIComponent(cwd));
127
- if (!isDirectory(groupDir)) return null;
128
-
129
- let best: { dir: string; mtimeMs: number } | null = null;
130
- for (const sessionDir of this.listSessionDirs(groupDir)) {
131
- const stat = safeStat(path.join(sessionDir, CHAT_HISTORY_FILE));
132
- if (!stat) continue;
133
- if (!best || stat.mtimeMs > best.mtimeMs) {
134
- best = { dir: sessionDir, mtimeMs: stat.mtimeMs };
135
- }
136
- }
137
- return best?.dir ?? null;
138
- }
139
-
140
- private listGroups(): Array<{ groupDir: string; defaultCwd: string }> {
141
- if (!isDirectory(this.sessionsDir)) return [];
142
-
143
- const groups: Array<{ groupDir: string; defaultCwd: string }> = [];
144
- for (const groupName of safeReaddir(this.sessionsDir)) {
145
- const groupDir = path.join(this.sessionsDir, groupName);
146
- if (!isDirectory(groupDir)) continue;
147
- groups.push({ groupDir, defaultCwd: this.decodeGroupCwd(groupName, groupDir) });
148
- }
149
- return groups;
150
- }
151
-
152
- /**
153
- * Full paths of the session subdirectories directly under a group dir,
154
- * skipping any non-directory entries (e.g. prompt_history.jsonl).
155
- */
156
- private listSessionDirs(groupDir: string): string[] {
157
- return safeReaddir(groupDir)
158
- .map((sessionId) => path.join(groupDir, sessionId))
159
- .filter((sessionDir) => isDirectory(sessionDir));
160
- }
161
-
162
- /**
163
- * Resolve the working directory a session group dir was created for.
164
- *
165
- * The common case is `decodeURIComponent(<group-name>)`. For paths whose
166
- * encoded form exceeds the filesystem limit Grok uses a slug+hash and records
167
- * the original path in a `.cwd` file inside the group — prefer that when
168
- * present.
169
- */
170
- private decodeGroupCwd(groupName: string, groupDir: string): string {
171
- const fromFile = safeReadFile(path.join(groupDir, CWD_FILE));
172
- if (fromFile !== undefined && fromFile.trim()) return fromFile.trim();
173
- try {
174
- return decodeURIComponent(groupName);
175
- } catch {
176
- return "";
177
- }
178
- }
179
- }
@@ -1,251 +0,0 @@
1
- import * as path from "path";
2
- import type { ConversationMessage, ConversationOptions } from "../../adapters/AgentAdapter.js";
3
- import { AgentStatus } from "../../adapters/AgentAdapter.js";
4
- import {
5
- IncrementalJsonlSummary,
6
- reduceJsonlContent,
7
- type JsonlSummaryBounds,
8
- type JsonlSummaryReducer,
9
- } from "../../utils/IncrementalJsonlSummary.js";
10
- import { JsonlTailReader, normalizeTail } from "../../utils/jsonlTail.js";
11
- import { safeReadFile, safeStat } from "../../utils/session.js";
12
- import { flattenTextBlocks, isIdle } from "../shared.js";
13
-
14
- export const CHAT_HISTORY_FILE = "chat_history.jsonl";
15
-
16
- /** One line of chat_history.jsonl. */
17
- interface ChatRecord {
18
- type?: string;
19
- content?: unknown;
20
- }
21
-
22
- /**
23
- * O(1) running summary folded from chat records: only the first/last real
24
- * prompt and the role of the last user/assistant turn, never the turns.
25
- */
26
- interface GrokSummaryState {
27
- /** A bounded cold start skipped the middle: later lines are not the session's first. */
28
- pastHead?: boolean;
29
- firstUserMessage?: string;
30
- lastUserMessage?: string;
31
- lastRole?: ConversationMessage["role"];
32
- }
33
-
34
- /** Parsed state for a single ~/.grok/sessions/<cwd>/<id>/ directory. */
35
- export interface GrokSession {
36
- sessionId: string;
37
- projectPath: string;
38
- sessionFilePath: string;
39
- sessionStart: Date;
40
- lastActive: Date;
41
- firstUserMessage?: string;
42
- lastUserMessage?: string;
43
- lastRole?: ConversationMessage["role"];
44
- }
45
-
46
- export interface GrokSessionParserOptions {
47
- /** Cold-start scan bounds for `readSessionIncremental` (see IncrementalJsonlSummary). */
48
- summaryBounds?: JsonlSummaryBounds | false;
49
- }
50
-
51
- export class GrokSessionParser {
52
- /** Incremental reader backing `getConversation({ tail })`. */
53
- private readonly tailReader = new JsonlTailReader();
54
-
55
- private readonly sessionCache: IncrementalJsonlSummary<GrokSummaryState>;
56
-
57
- constructor(options: GrokSessionParserOptions = {}) {
58
- this.sessionCache = new IncrementalJsonlSummary(this.summaryReducer, {
59
- bounds: options.summaryBounds,
60
- });
61
- }
62
-
63
- /**
64
- * Parse a session directory into a {@link GrokSession} from its
65
- * chat_history.jsonl transcript. Returns null when the transcript is
66
- * missing — i.e. there is no real session to surface.
67
- */
68
- readSession(sessionDir: string, defaultCwd: string): GrokSession | null {
69
- const chatPath = path.join(sessionDir, CHAT_HISTORY_FILE);
70
- const chatStat = safeStat(chatPath);
71
- if (!chatStat) return null;
72
-
73
- const content = safeReadFile(chatPath);
74
- const state = content === undefined ? {} : reduceJsonlContent(this.summaryReducer, content);
75
- return this.toSession(sessionDir, defaultCwd, chatPath, chatStat.mtime, state);
76
- }
77
-
78
- /**
79
- * Same result as `readSession`, but backed by a per-instance incremental
80
- * cache so repeated refreshes only parse bytes appended since the last call.
81
- * Call `pruneSessionCache()` once per refresh to evict files no longer read.
82
- *
83
- * The first read of a large transcript is a bounded head + tail scan (see
84
- * `summaryReducer.skip`); fields whose entries lie only in the skipped
85
- * middle fall back to their defaults instead of forcing a full parse.
86
- */
87
- readSessionIncremental(sessionDir: string, defaultCwd: string): GrokSession | null {
88
- const chatPath = path.join(sessionDir, CHAT_HISTORY_FILE);
89
- const result = this.sessionCache.read(chatPath);
90
- if (result) {
91
- return this.toSession(sessionDir, defaultCwd, chatPath, result.mtime, result.state);
92
- }
93
- // Present but unreadable: surface the session without a summary, like readSession.
94
- const chatStat = safeStat(chatPath);
95
- return chatStat ? this.toSession(sessionDir, defaultCwd, chatPath, chatStat.mtime, {}) : null;
96
- }
97
-
98
- /** Evict cached summaries for files not read since the previous prune. */
99
- pruneSessionCache(): void {
100
- this.sessionCache.prune();
101
- }
102
-
103
- /** Accepts a session dir or an explicit chat_history.jsonl path. */
104
- getConversation(sessionPath: string, options?: ConversationOptions): ConversationMessage[] {
105
- const chatPath = this.resolveChatPath(sessionPath);
106
- const verbose = options?.verbose ?? false;
107
- const tail = normalizeTail(options?.tail);
108
- if (tail !== undefined) {
109
- return this.tailReader.read(
110
- chatPath,
111
- tail,
112
- { parseLine: (line) => this.lineToMessage(line, verbose) },
113
- String(verbose),
114
- );
115
- }
116
- return this.parseChatHistory(chatPath, verbose);
117
- }
118
-
119
- /**
120
- * Determine agent status from parsed session state.
121
- *
122
- * - last transcript turn is an assistant message → WAITING (awaiting input)
123
- * - past the idle threshold → IDLE
124
- * - otherwise (last turn was a user message, or unknown) → RUNNING
125
- */
126
- determineStatus(session: GrokSession): AgentStatus {
127
- if (session.lastRole === "assistant") {
128
- return AgentStatus.WAITING;
129
- }
130
- if (isIdle(session.lastActive)) {
131
- return AgentStatus.IDLE;
132
- }
133
- return AgentStatus.RUNNING;
134
- }
135
-
136
- /**
137
- * Fold one chat_history.jsonl entry into the O(1) summary. Uses the same
138
- * record rules as `getConversation` (see `toMessage`), minus system records.
139
- *
140
- * `skip` (bounded cold start) keeps the head's first user message and
141
- * clears the last user message and last role, so those come from the tail
142
- * only. A first user message beyond the head stays undefined rather than
143
- * being filled from the tail; latest fields before the tail window stay
144
- * undefined.
145
- */
146
- private readonly summaryReducer: JsonlSummaryReducer<GrokSummaryState> = {
147
- initial: () => ({}),
148
- reduce: (state, value) => {
149
- const message = this.toMessage(value, false);
150
- if (!message) return state;
151
- if (message.role === "user") {
152
- return {
153
- ...state,
154
- firstUserMessage:
155
- state.firstUserMessage ?? (state.pastHead ? undefined : message.content),
156
- lastUserMessage: message.content,
157
- lastRole: "user",
158
- };
159
- }
160
- return { ...state, lastRole: message.role };
161
- },
162
- skip: (state) => ({ pastHead: true, firstUserMessage: state.firstUserMessage }),
163
- };
164
-
165
- private toSession(
166
- sessionDir: string,
167
- defaultCwd: string,
168
- chatPath: string,
169
- lastActive: Date,
170
- state: GrokSummaryState,
171
- ): GrokSession {
172
- const dirStat = safeStat(sessionDir);
173
- return {
174
- sessionId: path.basename(sessionDir),
175
- projectPath: defaultCwd,
176
- sessionFilePath: chatPath,
177
- sessionStart: dirStat?.birthtime || lastActive,
178
- lastActive,
179
- firstUserMessage: state.firstUserMessage,
180
- lastUserMessage: state.lastUserMessage,
181
- lastRole: state.lastRole,
182
- };
183
- }
184
-
185
- /** Full pass over chat_history.jsonl building every conversation turn. */
186
- private parseChatHistory(chatPath: string, verbose: boolean): ConversationMessage[] {
187
- const content = safeReadFile(chatPath);
188
- if (content === undefined) return [];
189
-
190
- const messages: ConversationMessage[] = [];
191
- for (const line of content.trim().split("\n")) {
192
- const message = this.lineToMessage(line, verbose);
193
- if (message) messages.push(message);
194
- }
195
- return messages;
196
- }
197
-
198
- /**
199
- * Map one parsed chat record to a conversation turn, or null to skip it.
200
- * Each record is a { type: 'system' | 'user' | 'assistant', content } object
201
- * where content is either a string or an array of { type: 'text', text } blocks.
202
- *
203
- * Grok wraps the real user prompt in <user_query>...</user_query>; the other
204
- * user records are context injections (<user_info>, <system-reminder>, ...)
205
- * and are skipped so the summary is the actual prompt, not boilerplate.
206
- */
207
- private toMessage(value: unknown, verbose: boolean): ConversationMessage | null {
208
- if (!value || typeof value !== "object") return null;
209
- const record = value as ChatRecord;
210
-
211
- const text = flattenTextBlocks(record.content);
212
- if (record.type === "user") {
213
- const query = this.extractUserQuery(text);
214
- return query === null ? null : { role: "user", content: query };
215
- }
216
- if (record.type === "assistant") {
217
- return text ? { role: "assistant", content: text } : null;
218
- }
219
- if (verbose && record.type === "system") {
220
- return text ? { role: "system", content: text } : null;
221
- }
222
- return null;
223
- }
224
-
225
- /** Convert one chat_history.jsonl line into a message, or null when it is not one. */
226
- private lineToMessage(line: string, verbose: boolean): ConversationMessage | null {
227
- if (!line.trim()) return null;
228
-
229
- let record: unknown;
230
- try {
231
- record = JSON.parse(line);
232
- } catch {
233
- return null;
234
- }
235
- return this.toMessage(record, verbose);
236
- }
237
-
238
- /**
239
- * Extract the prompt inside <user_query>...</user_query>. Returns null when
240
- * the record has no such tag (a context injection rather than a prompt).
241
- */
242
- private extractUserQuery(text: string): string | null {
243
- const match = text.match(/<user_query>\s*([\s\S]*?)\s*<\/user_query>/);
244
- return match ? match[1].trim() : null;
245
- }
246
-
247
- /** Resolve a session dir or an explicit chat_history.jsonl path to the file. */
248
- private resolveChatPath(sessionPath: string): string {
249
- return sessionPath.endsWith(".jsonl") ? sessionPath : path.join(sessionPath, CHAT_HISTORY_FILE);
250
- }
251
- }
@@ -1,32 +0,0 @@
1
- import type { AgentAdapter } from "../adapters/AgentAdapter.js";
2
- import { AntigravityCliAdapter } from "./antigravity/AntigravityCliAdapter.js";
3
- import { ClaudeCodeAdapter } from "./claude/ClaudeCodeAdapter.js";
4
- import { CodexAdapter } from "./codex/CodexAdapter.js";
5
- import { CopilotAdapter } from "./copilot/CopilotAdapter.js";
6
- import { GeminiCliAdapter } from "./gemini/GeminiCliAdapter.js";
7
- import { GrokCliAdapter } from "./grok/GrokCliAdapter.js";
8
- import { KiroAdapter } from "./kiro/KiroAdapter.js";
9
- import { OpenCodeAdapter } from "./opencode/OpenCodeAdapter.js";
10
- import { PiAdapter } from "./pi/PiAdapter.js";
11
- import { DevinAdapter } from "./devin/DevinAdapter.js";
12
- import { MuseAdapter } from "./muse/MuseAdapter.js";
13
-
14
- /**
15
- * One instance of every built-in harness adapter, in registration order
16
- * (which is also the order agents are listed in). Register a new harness here.
17
- */
18
- export function createBuiltinAdapters(): AgentAdapter[] {
19
- return [
20
- new ClaudeCodeAdapter(),
21
- new CodexAdapter(),
22
- new CopilotAdapter(),
23
- new GeminiCliAdapter(),
24
- new GrokCliAdapter(),
25
- new KiroAdapter(),
26
- new AntigravityCliAdapter(),
27
- new OpenCodeAdapter(),
28
- new PiAdapter(),
29
- new DevinAdapter(),
30
- new MuseAdapter(),
31
- ];
32
- }
@@ -1,143 +0,0 @@
1
- import * as path from "path";
2
- import type {
3
- AgentAdapter,
4
- AgentInfo,
5
- ProcessInfo,
6
- ConversationMessage,
7
- ConversationOptions,
8
- SessionSummary,
9
- ListSessionsOptions,
10
- AgentDetectionContext,
11
- } from "../../adapters/AgentAdapter.js";
12
- import { executablePath } from "../../utils/process.js";
13
- import { findHarnessProcesses } from "../shared.js";
14
- import { KiroAgentMapper } from "./KiroAgentMapper.js";
15
- import { KiroSessionLocator } from "./KiroSessionLocator.js";
16
- import { KiroSessionParser, type KiroSession } from "./KiroSessionParser.js";
17
-
18
- const KIRO_BASENAMES = new Set(["kiro-cli", "kiro"]);
19
- const SCRIPT_RUNTIMES = new Set(["node", "bun"]);
20
-
21
- /**
22
- * Kiro Adapter
23
- *
24
- * Detects running Kiro agents by matching the PID in each
25
- * ~/.kiro/sessions/cli/<session-id>.lock to a running Kiro process (walking up
26
- * from helper processes such as `kiro-cli-chat acp`), then reading the sibling
27
- * <session-id>.json metadata and <session-id>.jsonl transcript.
28
- */
29
- export class KiroAdapter implements AgentAdapter {
30
- readonly type = "kiro" as const;
31
- /**
32
- * Also collects the helpers between a lock holder and its kiro-cli, such as
33
- * the bundled `bun … tui.js`; `canHandle` still decides which are agents.
34
- */
35
- readonly processNames = ["kiro-cli", "kiro", "kiro-cli-chat", "node", "bun"] as const;
36
-
37
- private parser: KiroSessionParser;
38
- private mapper: KiroAgentMapper;
39
- private locator: KiroSessionLocator;
40
-
41
- constructor() {
42
- this.parser = new KiroSessionParser();
43
- this.mapper = new KiroAgentMapper(this.parser);
44
- this.locator = new KiroSessionLocator();
45
- }
46
-
47
- canHandle(processInfo: ProcessInfo): boolean {
48
- return this.isKiroExecutable(processInfo.command);
49
- }
50
-
51
- async detectAgents(context?: AgentDetectionContext): Promise<AgentInfo[]> {
52
- try {
53
- return await this.detectRunningAgents(context);
54
- } finally {
55
- // Drop cached summaries for sessions that were not part of this refresh
56
- this.parser.pruneSessionCache();
57
- }
58
- }
59
-
60
- private async detectRunningAgents(context?: AgentDetectionContext): Promise<AgentInfo[]> {
61
- const { relevant, processes } = await findHarnessProcesses(this, context);
62
- if (processes.length === 0) return [];
63
-
64
- const agents: AgentInfo[] = [];
65
- const matchedPids = new Set<number>();
66
- for (const match of this.locator.matchRunningProcesses(relevant, processes, (process) =>
67
- this.canHandle(process),
68
- )) {
69
- const session = this.parser.readSessionIncremental(match.session, match.process.cwd);
70
- if (!session) continue;
71
-
72
- agents.push(this.mapper.mapSessionToAgent({ session, processInfo: match.process }));
73
- matchedPids.add(match.process.pid);
74
- }
75
-
76
- for (const proc of processes) {
77
- if (!matchedPids.has(proc.pid)) {
78
- agents.push(this.mapper.mapProcessOnlyAgent(proc));
79
- }
80
- }
81
- return agents;
82
- }
83
-
84
- getConversation(sessionFilePath: string, options?: ConversationOptions): ConversationMessage[] {
85
- return this.parser.getConversation(sessionFilePath, options);
86
- }
87
-
88
- async listSessions(opts?: ListSessionsOptions): Promise<SessionSummary[]> {
89
- const summaries: SessionSummary[] = [];
90
- for (const paths of this.locator.listSessions()) {
91
- const session = this.parser.readSession(paths);
92
- if (!session) continue;
93
- if (opts?.cwd !== undefined && session.projectPath !== opts.cwd) continue;
94
-
95
- summaries.push(this.toSessionSummary(session));
96
- }
97
- return summaries;
98
- }
99
-
100
- async findSessionsById(sessionId: string): Promise<SessionSummary[]> {
101
- const paths = this.locator.findSession(sessionId);
102
- const session = paths ? this.parser.readSession(paths) : null;
103
- // listSessions reports the metadata's id, so only an exact match counts.
104
- return session?.sessionId === sessionId ? [this.toSessionSummary(session)] : [];
105
- }
106
-
107
- private toSessionSummary(session: KiroSession): SessionSummary {
108
- return {
109
- type: this.type,
110
- sessionId: session.sessionId,
111
- cwd: session.projectPath,
112
- firstUserMessage: session.firstUserMessage,
113
- lastActive: session.lastActive,
114
- startedAt: session.sessionStart,
115
- sessionFilePath: session.sessionFilePath,
116
- };
117
- }
118
-
119
- /** `kiro-cli` / `kiro`, directly or as a script run by node or bun. */
120
- private isKiroExecutable(command: string): boolean {
121
- const trimmed = command.trim();
122
- const executable = executablePath(trimmed);
123
- if (!executable) return false;
124
-
125
- const executableName = kiroBasename(executable);
126
- if (KIRO_BASENAMES.has(executableName)) return true;
127
- if (!SCRIPT_RUNTIMES.has(executableName)) return false;
128
-
129
- const args = trimmed.slice(executable.length).trim().split(/\s+/);
130
- const scriptIndex = args.findIndex((token) => token !== "" && !token.startsWith("-"));
131
- if (scriptIndex === -1) return false;
132
- // The script path may also contain spaces; resolve it like argv[0].
133
- const script = executablePath(args.slice(scriptIndex).join(" "));
134
- return KIRO_BASENAMES.has(kiroBasename(script));
135
- }
136
- }
137
-
138
- function kiroBasename(executable: string): string {
139
- return path
140
- .basename(executable.replace(/\\/g, "/"))
141
- .toLowerCase()
142
- .replace(/\.(exe|js)$/, "");
143
- }
@@ -1,34 +0,0 @@
1
- import type { AgentInfo, ProcessInfo } from "../../adapters/AgentAdapter.js";
2
- import { generateAgentName } from "../../utils/matching.js";
3
- import { processOnlyAgent, SUMMARY_MAX_LENGTH, truncate } from "../shared.js";
4
- import { KiroSessionParser, type KiroSession } from "./KiroSessionParser.js";
5
-
6
- export interface KiroSessionAgentInput {
7
- session: KiroSession;
8
- processInfo: ProcessInfo;
9
- }
10
-
11
- export class KiroAgentMapper {
12
- constructor(private readonly parser: KiroSessionParser = new KiroSessionParser()) {}
13
-
14
- mapSessionToAgent({ session, processInfo }: KiroSessionAgentInput): AgentInfo {
15
- return {
16
- name: generateAgentName(session.projectPath, processInfo.pid),
17
- type: "kiro",
18
- status: this.parser.determineStatus(session),
19
- summary: truncate(
20
- session.lastUserMessage || session.title || "Kiro session active",
21
- SUMMARY_MAX_LENGTH,
22
- ),
23
- pid: processInfo.pid,
24
- projectPath: session.projectPath,
25
- sessionId: session.sessionId,
26
- lastActive: session.lastActive,
27
- sessionFilePath: session.sessionFilePath,
28
- };
29
- }
30
-
31
- mapProcessOnlyAgent(processInfo: ProcessInfo): AgentInfo {
32
- return processOnlyAgent("kiro", processInfo, { summary: "Kiro process running" });
33
- }
34
- }