@ai-devkit/agent-manager 0.31.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AgentManager.d.ts +3 -3
- package/dist/AgentManager.d.ts.map +1 -1
- package/dist/AgentManager.js +80 -79
- package/dist/AgentManager.js.map +1 -1
- package/dist/__tests__/AgentManager.test.js +413 -388
- package/dist/__tests__/AgentManager.test.js.map +1 -1
- package/dist/__tests__/adapters/ClaudeCodeAdapter.test.js +642 -642
- package/dist/__tests__/adapters/ClaudeCodeAdapter.test.js.map +1 -1
- package/dist/__tests__/adapters/CodexAdapter.test.js +322 -2321
- package/dist/__tests__/adapters/CodexAdapter.test.js.map +1 -1
- package/dist/__tests__/adapters/CopilotAdapter.test.js +254 -248
- package/dist/__tests__/adapters/CopilotAdapter.test.js.map +1 -1
- package/dist/__tests__/adapters/GeminiCliAdapter.test.js +564 -558
- package/dist/__tests__/adapters/GeminiCliAdapter.test.js.map +1 -1
- package/dist/__tests__/adapters/GrokCliAdapter.test.js +114 -114
- package/dist/__tests__/adapters/GrokCliAdapter.test.js.map +1 -1
- package/dist/__tests__/adapters/OpenCodeAdapter.test.js +169 -169
- package/dist/__tests__/adapters/OpenCodeAdapter.test.js.map +1 -1
- package/dist/__tests__/capacity/codex.test.js +93 -93
- package/dist/__tests__/capacity/codex.test.js.map +1 -1
- package/dist/__tests__/capacity/index.test.js +17 -17
- package/dist/__tests__/capacity/index.test.js.map +1 -1
- package/dist/__tests__/durable/CodexCliProbe.test.js +60 -60
- package/dist/__tests__/durable/CodexCliProbe.test.js.map +1 -1
- package/dist/__tests__/durable/CodexDurableAgentRepository.test.js +28 -28
- package/dist/__tests__/durable/CodexDurableAgentRepository.test.js.map +1 -1
- package/dist/__tests__/durable/CodexPrintAgent.integration.test.js +30 -30
- package/dist/__tests__/durable/CodexPrintAgent.integration.test.js.map +1 -1
- package/dist/__tests__/durable/CodexPrintAgentService.test.js +71 -71
- package/dist/__tests__/durable/CodexPrintAgentService.test.js.map +1 -1
- package/dist/__tests__/durable/CodexPrintRunner.test.js +125 -125
- package/dist/__tests__/durable/CodexPrintRunner.test.js.map +1 -1
- package/dist/__tests__/print/ClaudeCliProbe.test.js +20 -20
- package/dist/__tests__/print/ClaudeCliProbe.test.js.map +1 -1
- package/dist/__tests__/print/ClaudePrintAgent.integration.test.js +20 -20
- package/dist/__tests__/print/ClaudePrintAgent.integration.test.js.map +1 -1
- package/dist/__tests__/print/ClaudePrintAgentService.test.js +58 -58
- package/dist/__tests__/print/ClaudePrintAgentService.test.js.map +1 -1
- package/dist/__tests__/print/ClaudePrintRunner.test.js +55 -55
- package/dist/__tests__/print/ClaudePrintRunner.test.js.map +1 -1
- package/dist/__tests__/print/DurableAgent.test.js +9 -9
- package/dist/__tests__/print/DurableAgent.test.js.map +1 -1
- package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js +40 -40
- package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js.map +1 -1
- package/dist/__tests__/print/DurableAgentRepository.test.js +66 -66
- package/dist/__tests__/print/DurableAgentRepository.test.js.map +1 -1
- package/dist/__tests__/providers/claude/ClaudeAgentMapper.test.js +34 -34
- package/dist/__tests__/providers/claude/ClaudeAgentMapper.test.js.map +1 -1
- package/dist/__tests__/providers/claude/ClaudeSessionLocator.test.js +132 -132
- package/dist/__tests__/providers/claude/ClaudeSessionLocator.test.js.map +1 -1
- package/dist/__tests__/providers/codex/CodexSessionLocator.test.js +194 -0
- package/dist/__tests__/providers/codex/CodexSessionLocator.test.js.map +1 -0
- package/dist/__tests__/providers/codex/CodexSessionMapping.test.js +86 -0
- package/dist/__tests__/providers/codex/CodexSessionMapping.test.js.map +1 -0
- package/dist/__tests__/providers/codex/CodexSessionParser.test.js +254 -0
- package/dist/__tests__/providers/codex/CodexSessionParser.test.js.map +1 -0
- package/dist/__tests__/providers/pi/PiAdapter.test.js +337 -0
- package/dist/__tests__/providers/pi/PiAdapter.test.js.map +1 -0
- package/dist/__tests__/providers/pi/PiSessionParser.test.js +246 -0
- package/dist/__tests__/providers/pi/PiSessionParser.test.js.map +1 -0
- package/dist/__tests__/providers/pi/PiSessionTracker.test.js +108 -0
- package/dist/__tests__/providers/pi/PiSessionTracker.test.js.map +1 -0
- package/dist/__tests__/providers/pi/durable/PiCliProbe.test.js +33 -33
- package/dist/__tests__/providers/pi/durable/PiCliProbe.test.js.map +1 -1
- package/dist/__tests__/providers/pi/durable/PiDurableAgentRepository.test.js +16 -16
- package/dist/__tests__/providers/pi/durable/PiDurableAgentRepository.test.js.map +1 -1
- package/dist/__tests__/providers/pi/durable/PiPrintAgentService.test.js +52 -52
- package/dist/__tests__/providers/pi/durable/PiPrintAgentService.test.js.map +1 -1
- package/dist/__tests__/providers/pi/durable/PiPrintProtocol.test.js +44 -44
- package/dist/__tests__/providers/pi/durable/PiPrintProtocol.test.js.map +1 -1
- package/dist/__tests__/providers/pi/durable/PiPrintRunner.test.js +126 -126
- package/dist/__tests__/providers/pi/durable/PiPrintRunner.test.js.map +1 -1
- package/dist/__tests__/providers/pi/durable/PiStreamParser.test.js +14 -14
- package/dist/__tests__/providers/pi/durable/PiStreamParser.test.js.map +1 -1
- package/dist/__tests__/readiness/AgentReadiness.test.js +301 -0
- package/dist/__tests__/readiness/AgentReadiness.test.js.map +1 -0
- package/dist/__tests__/runtime/AgentRuntime.test.js +13 -0
- package/dist/__tests__/runtime/AgentRuntime.test.js.map +1 -0
- package/dist/__tests__/runtime/HerdrAgentRuntime.test.js +452 -0
- package/dist/__tests__/runtime/HerdrAgentRuntime.test.js.map +1 -0
- package/dist/__tests__/runtime/ManagedAgentRuntime.test.js +588 -0
- package/dist/__tests__/runtime/ManagedAgentRuntime.test.js.map +1 -0
- package/dist/__tests__/terminal/TerminalFocusManager.test.js +100 -100
- package/dist/__tests__/terminal/TerminalFocusManager.test.js.map +1 -1
- package/dist/__tests__/terminal/TmuxManager.test.js +101 -101
- package/dist/__tests__/terminal/TmuxManager.test.js.map +1 -1
- package/dist/__tests__/terminal/TtyWriter.test.js +185 -185
- package/dist/__tests__/terminal/TtyWriter.test.js.map +1 -1
- package/dist/__tests__/utils/AgentRegistry.test.js +335 -217
- package/dist/__tests__/utils/AgentRegistry.test.js.map +1 -1
- package/dist/__tests__/utils/ClaudeSessionParser.test.js +103 -101
- package/dist/__tests__/utils/ClaudeSessionParser.test.js.map +1 -1
- package/dist/__tests__/utils/agent-requests.test.js +43 -43
- package/dist/__tests__/utils/agent-requests.test.js.map +1 -1
- package/dist/__tests__/utils/agents.test.js +17 -17
- package/dist/__tests__/utils/agents.test.js.map +1 -1
- package/dist/__tests__/utils/matching.test.js +92 -92
- package/dist/__tests__/utils/matching.test.js.map +1 -1
- package/dist/__tests__/utils/process.test.js +108 -108
- package/dist/__tests__/utils/process.test.js.map +1 -1
- package/dist/__tests__/utils/session.test.js +53 -53
- package/dist/__tests__/utils/session.test.js.map +1 -1
- package/dist/adapters/AgentAdapter.d.ts +2 -2
- package/dist/adapters/AgentAdapter.d.ts.map +1 -1
- package/dist/adapters/AgentAdapter.js +1 -1
- package/dist/adapters/AgentAdapter.js.map +1 -1
- package/dist/adapters/CopilotAdapter.d.ts +2 -2
- package/dist/adapters/CopilotAdapter.d.ts.map +1 -1
- package/dist/adapters/CopilotAdapter.js +51 -51
- package/dist/adapters/CopilotAdapter.js.map +1 -1
- package/dist/adapters/GeminiCliAdapter.d.ts +2 -2
- package/dist/adapters/GeminiCliAdapter.d.ts.map +1 -1
- package/dist/adapters/GeminiCliAdapter.js +86 -86
- package/dist/adapters/GeminiCliAdapter.js.map +1 -1
- package/dist/adapters/GrokCliAdapter.d.ts +1 -1
- package/dist/adapters/GrokCliAdapter.d.ts.map +1 -1
- package/dist/adapters/GrokCliAdapter.js +80 -80
- package/dist/adapters/GrokCliAdapter.js.map +1 -1
- package/dist/adapters/OpenCodeAdapter.d.ts +1 -1
- package/dist/adapters/OpenCodeAdapter.d.ts.map +1 -1
- package/dist/adapters/OpenCodeAdapter.js +37 -36
- package/dist/adapters/OpenCodeAdapter.js.map +1 -1
- package/dist/adapters/index.d.ts +9 -9
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +8 -8
- package/dist/adapters/index.js.map +1 -1
- package/dist/capacity/codex.d.ts +3 -3
- package/dist/capacity/codex.d.ts.map +1 -1
- package/dist/capacity/codex.js +57 -57
- package/dist/capacity/codex.js.map +1 -1
- package/dist/capacity/index.d.ts +3 -3
- package/dist/capacity/index.d.ts.map +1 -1
- package/dist/capacity/index.js +8 -8
- package/dist/capacity/index.js.map +1 -1
- package/dist/capacity/types.d.ts +1 -1
- package/dist/capacity/types.js.map +1 -1
- package/dist/database/connection.d.ts +1 -1
- package/dist/database/connection.d.ts.map +1 -1
- package/dist/database/connection.js +15 -15
- package/dist/database/connection.js.map +1 -1
- package/dist/database/index.d.ts +3 -3
- package/dist/database/index.d.ts.map +1 -1
- package/dist/database/index.js +2 -2
- package/dist/database/index.js.map +1 -1
- package/dist/database/migrations/005_agent_runtime.sql +2 -0
- package/dist/database/schema.d.ts +1 -1
- package/dist/database/schema.d.ts.map +1 -1
- package/dist/database/schema.js +7 -7
- package/dist/database/schema.js.map +1 -1
- package/dist/durable/DurableAgent.d.ts +9 -9
- package/dist/durable/DurableAgent.d.ts.map +1 -1
- package/dist/durable/DurableAgent.js +16 -16
- package/dist/durable/DurableAgent.js.map +1 -1
- package/dist/durable/DurableAgentRepository.d.ts +4 -4
- package/dist/durable/DurableAgentRepository.d.ts.map +1 -1
- package/dist/durable/DurableAgentRepository.js +49 -48
- package/dist/durable/DurableAgentRepository.js.map +1 -1
- package/dist/durable/process.d.ts +1 -1
- package/dist/durable/process.d.ts.map +1 -1
- package/dist/durable/process.js +14 -14
- package/dist/durable/process.js.map +1 -1
- package/dist/durable/run.d.ts +2 -2
- package/dist/durable/run.d.ts.map +1 -1
- package/dist/durable/run.js +6 -6
- package/dist/durable/run.js.map +1 -1
- package/dist/durable/utils.d.ts +1 -1
- package/dist/durable/utils.d.ts.map +1 -1
- package/dist/durable/utils.js +4 -4
- package/dist/durable/utils.js.map +1 -1
- package/dist/index.d.ts +46 -41
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -25
- package/dist/index.js.map +1 -1
- package/dist/providers/claude/ClaudeAgentMapper.d.ts +4 -4
- package/dist/providers/claude/ClaudeAgentMapper.d.ts.map +1 -1
- package/dist/providers/claude/ClaudeAgentMapper.js +10 -10
- package/dist/providers/claude/ClaudeAgentMapper.js.map +1 -1
- package/dist/providers/claude/ClaudeCodeAdapter.d.ts +1 -1
- package/dist/providers/claude/ClaudeCodeAdapter.d.ts.map +1 -1
- package/dist/providers/claude/ClaudeCodeAdapter.js +14 -14
- package/dist/providers/claude/ClaudeCodeAdapter.js.map +1 -1
- package/dist/providers/claude/ClaudeSessionLocator.d.ts +4 -4
- package/dist/providers/claude/ClaudeSessionLocator.d.ts.map +1 -1
- package/dist/providers/claude/ClaudeSessionLocator.js +79 -79
- package/dist/providers/claude/ClaudeSessionLocator.js.map +1 -1
- package/dist/providers/claude/ClaudeSessionParser.d.ts +2 -2
- package/dist/providers/claude/ClaudeSessionParser.d.ts.map +1 -1
- package/dist/providers/claude/ClaudeSessionParser.js +99 -99
- package/dist/providers/claude/ClaudeSessionParser.js.map +1 -1
- package/dist/providers/claude/durable/ClaudeCliProbe.d.ts.map +1 -1
- package/dist/providers/claude/durable/ClaudeCliProbe.js +16 -16
- package/dist/providers/claude/durable/ClaudeCliProbe.js.map +1 -1
- package/dist/providers/claude/durable/ClaudePrintAgentService.d.ts +5 -5
- package/dist/providers/claude/durable/ClaudePrintAgentService.d.ts.map +1 -1
- package/dist/providers/claude/durable/ClaudePrintAgentService.js +10 -10
- package/dist/providers/claude/durable/ClaudePrintAgentService.js.map +1 -1
- package/dist/providers/claude/durable/ClaudePrintRunner.d.ts +4 -4
- package/dist/providers/claude/durable/ClaudePrintRunner.d.ts.map +1 -1
- package/dist/providers/claude/durable/ClaudePrintRunner.js +18 -18
- package/dist/providers/claude/durable/ClaudePrintRunner.js.map +1 -1
- package/dist/providers/claude/durable/ClaudeStreamParser.d.ts +2 -2
- package/dist/providers/claude/durable/ClaudeStreamParser.d.ts.map +1 -1
- package/dist/providers/claude/durable/ClaudeStreamParser.js +17 -17
- package/dist/providers/claude/durable/ClaudeStreamParser.js.map +1 -1
- package/dist/providers/codex/CodexAdapter.d.ts +27 -0
- package/dist/providers/codex/CodexAdapter.d.ts.map +1 -0
- package/dist/providers/codex/CodexAdapter.js +162 -0
- package/dist/providers/codex/CodexAdapter.js.map +1 -0
- package/dist/providers/codex/CodexAgentMapper.d.ts +9 -0
- package/dist/providers/codex/CodexAgentMapper.d.ts.map +1 -0
- package/dist/providers/codex/CodexAgentMapper.js +35 -0
- package/dist/providers/codex/CodexAgentMapper.js.map +1 -0
- package/dist/providers/codex/CodexSessionLocator.d.ts +44 -0
- package/dist/providers/codex/CodexSessionLocator.d.ts.map +1 -0
- package/dist/providers/codex/CodexSessionLocator.js +207 -0
- package/dist/providers/codex/CodexSessionLocator.js.map +1 -0
- package/dist/providers/codex/CodexSessionMapping.d.ts +23 -0
- package/dist/providers/codex/CodexSessionMapping.d.ts.map +1 -0
- package/dist/providers/codex/CodexSessionMapping.js +68 -0
- package/dist/providers/codex/CodexSessionMapping.js.map +1 -0
- package/dist/providers/codex/CodexSessionParser.d.ts +58 -0
- package/dist/providers/codex/CodexSessionParser.d.ts.map +1 -0
- package/dist/providers/codex/CodexSessionParser.js +262 -0
- package/dist/providers/codex/CodexSessionParser.js.map +1 -0
- package/dist/providers/codex/durable/CodexCliProbe.d.ts.map +1 -1
- package/dist/providers/codex/durable/CodexCliProbe.js +22 -22
- package/dist/providers/codex/durable/CodexCliProbe.js.map +1 -1
- package/dist/providers/codex/durable/CodexPrintAgentService.d.ts +6 -6
- package/dist/providers/codex/durable/CodexPrintAgentService.d.ts.map +1 -1
- package/dist/providers/codex/durable/CodexPrintAgentService.js +10 -10
- package/dist/providers/codex/durable/CodexPrintAgentService.js.map +1 -1
- package/dist/providers/codex/durable/CodexPrintRunner.d.ts +4 -4
- package/dist/providers/codex/durable/CodexPrintRunner.d.ts.map +1 -1
- package/dist/providers/codex/durable/CodexPrintRunner.js +20 -20
- package/dist/providers/codex/durable/CodexPrintRunner.js.map +1 -1
- package/dist/providers/codex/durable/CodexStreamParser.d.ts +2 -2
- package/dist/providers/codex/durable/CodexStreamParser.d.ts.map +1 -1
- package/dist/providers/codex/durable/CodexStreamParser.js +21 -21
- package/dist/providers/codex/durable/CodexStreamParser.js.map +1 -1
- package/dist/providers/pi/PiAdapter.d.ts +28 -0
- package/dist/providers/pi/PiAdapter.d.ts.map +1 -0
- package/dist/providers/pi/PiAdapter.js +153 -0
- package/dist/providers/pi/PiAdapter.js.map +1 -0
- package/dist/providers/pi/PiAgentMapper.d.ts +9 -0
- package/dist/providers/pi/PiAgentMapper.d.ts.map +1 -0
- package/dist/providers/pi/PiAgentMapper.js +37 -0
- package/dist/providers/pi/PiAgentMapper.js.map +1 -0
- package/dist/providers/pi/PiSessionLocator.d.ts +23 -0
- package/dist/providers/pi/PiSessionLocator.d.ts.map +1 -0
- package/dist/providers/pi/PiSessionLocator.js +79 -0
- package/dist/providers/pi/PiSessionLocator.js.map +1 -0
- package/dist/providers/pi/PiSessionParser.d.ts +36 -0
- package/dist/providers/pi/PiSessionParser.d.ts.map +1 -0
- package/dist/providers/pi/PiSessionParser.js +191 -0
- package/dist/providers/pi/PiSessionParser.js.map +1 -0
- package/dist/providers/pi/PiSessionTracker.d.ts +23 -0
- package/dist/providers/pi/PiSessionTracker.d.ts.map +1 -0
- package/dist/providers/pi/PiSessionTracker.js +69 -0
- package/dist/providers/pi/PiSessionTracker.js.map +1 -0
- package/dist/providers/pi/durable/PiCliProbe.d.ts.map +1 -1
- package/dist/providers/pi/durable/PiCliProbe.js +15 -15
- package/dist/providers/pi/durable/PiCliProbe.js.map +1 -1
- package/dist/providers/pi/durable/PiPrintAgentService.d.ts +6 -6
- package/dist/providers/pi/durable/PiPrintAgentService.d.ts.map +1 -1
- package/dist/providers/pi/durable/PiPrintAgentService.js +10 -10
- package/dist/providers/pi/durable/PiPrintAgentService.js.map +1 -1
- package/dist/providers/pi/durable/PiPrintProtocol.d.ts.map +1 -1
- package/dist/providers/pi/durable/PiPrintProtocol.js +18 -18
- package/dist/providers/pi/durable/PiPrintProtocol.js.map +1 -1
- package/dist/providers/pi/durable/PiPrintRunner.d.ts +4 -4
- package/dist/providers/pi/durable/PiPrintRunner.d.ts.map +1 -1
- package/dist/providers/pi/durable/PiPrintRunner.js +15 -15
- package/dist/providers/pi/durable/PiPrintRunner.js.map +1 -1
- package/dist/providers/pi/durable/PiStreamParser.d.ts +1 -1
- package/dist/providers/pi/durable/PiStreamParser.d.ts.map +1 -1
- package/dist/providers/pi/durable/PiStreamParser.js +16 -16
- package/dist/providers/pi/durable/PiStreamParser.js.map +1 -1
- package/dist/readiness/AgentReadiness.d.ts +67 -0
- package/dist/readiness/AgentReadiness.d.ts.map +1 -0
- package/dist/readiness/AgentReadiness.js +614 -0
- package/dist/readiness/AgentReadiness.js.map +1 -0
- package/dist/runtime/ManagedAgentRuntime.d.ts +69 -0
- package/dist/runtime/ManagedAgentRuntime.d.ts.map +1 -0
- package/dist/runtime/ManagedAgentRuntime.js +156 -0
- package/dist/runtime/ManagedAgentRuntime.js.map +1 -0
- package/dist/runtime/RuntimeFactory.d.ts +4 -0
- package/dist/runtime/RuntimeFactory.d.ts.map +1 -0
- package/dist/runtime/RuntimeFactory.js +11 -0
- package/dist/runtime/RuntimeFactory.js.map +1 -0
- package/dist/runtime/errors.d.ts +27 -0
- package/dist/runtime/errors.d.ts.map +1 -0
- package/dist/runtime/errors.js +42 -0
- package/dist/runtime/errors.js.map +1 -0
- package/dist/runtime/herdr/HerdrAgentRuntime.d.ts +31 -0
- package/dist/runtime/herdr/HerdrAgentRuntime.d.ts.map +1 -0
- package/dist/runtime/herdr/HerdrAgentRuntime.js +184 -0
- package/dist/runtime/herdr/HerdrAgentRuntime.js.map +1 -0
- package/dist/runtime/herdr/HerdrCliClient.d.ts +13 -0
- package/dist/runtime/herdr/HerdrCliClient.d.ts.map +1 -0
- package/dist/runtime/herdr/HerdrCliClient.js +60 -0
- package/dist/runtime/herdr/HerdrCliClient.js.map +1 -0
- package/dist/runtime/herdr/HerdrErrors.d.ts +7 -0
- package/dist/runtime/herdr/HerdrErrors.d.ts.map +1 -0
- package/dist/runtime/herdr/HerdrErrors.js +10 -0
- package/dist/runtime/herdr/HerdrErrors.js.map +1 -0
- package/dist/runtime/herdr/HerdrResponseParsers.d.ts +14 -0
- package/dist/runtime/herdr/HerdrResponseParsers.d.ts.map +1 -0
- package/dist/runtime/herdr/HerdrResponseParsers.js +96 -0
- package/dist/runtime/herdr/HerdrResponseParsers.js.map +1 -0
- package/dist/runtime/herdr/HerdrRuntimeRef.d.ts +9 -0
- package/dist/runtime/herdr/HerdrRuntimeRef.d.ts.map +1 -0
- package/dist/runtime/herdr/HerdrRuntimeRef.js +33 -0
- package/dist/runtime/herdr/HerdrRuntimeRef.js.map +1 -0
- package/dist/runtime/tmux/PidPolling.d.ts +5 -0
- package/dist/runtime/tmux/PidPolling.d.ts.map +1 -0
- package/dist/runtime/tmux/PidPolling.js +24 -0
- package/dist/runtime/tmux/PidPolling.js.map +1 -0
- package/dist/runtime/tmux/TmuxAgentRuntime.d.ts +17 -0
- package/dist/runtime/tmux/TmuxAgentRuntime.d.ts.map +1 -0
- package/dist/runtime/tmux/TmuxAgentRuntime.js +80 -0
- package/dist/runtime/tmux/TmuxAgentRuntime.js.map +1 -0
- package/dist/runtime/tmux/TmuxRuntimeRef.d.ts +5 -0
- package/dist/runtime/tmux/TmuxRuntimeRef.d.ts.map +1 -0
- package/dist/runtime/tmux/TmuxRuntimeRef.js +9 -0
- package/dist/runtime/tmux/TmuxRuntimeRef.js.map +1 -0
- package/dist/runtime/types.d.ts +54 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +3 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/terminal/TerminalFocusManager.d.ts.map +1 -1
- package/dist/terminal/TerminalFocusManager.js +50 -50
- package/dist/terminal/TerminalFocusManager.js.map +1 -1
- package/dist/terminal/TmuxManager.d.ts.map +1 -1
- package/dist/terminal/TmuxManager.js +47 -47
- package/dist/terminal/TmuxManager.js.map +1 -1
- package/dist/terminal/TtyWriter.d.ts +1 -1
- package/dist/terminal/TtyWriter.d.ts.map +1 -1
- package/dist/terminal/TtyWriter.js +89 -89
- package/dist/terminal/TtyWriter.js.map +1 -1
- package/dist/terminal/index.d.ts +4 -4
- package/dist/terminal/index.js +3 -3
- package/dist/terminal/index.js.map +1 -1
- package/dist/utils/AgentRegistry.d.ts +10 -2
- package/dist/utils/AgentRegistry.d.ts.map +1 -1
- package/dist/utils/AgentRegistry.js +57 -24
- package/dist/utils/AgentRegistry.js.map +1 -1
- package/dist/utils/agent-requests.d.ts.map +1 -1
- package/dist/utils/agent-requests.js +5 -5
- package/dist/utils/agent-requests.js.map +1 -1
- package/dist/utils/agents.d.ts +2 -2
- package/dist/utils/agents.d.ts.map +1 -1
- package/dist/utils/agents.js +15 -15
- package/dist/utils/agents.js.map +1 -1
- package/dist/utils/applescript.js +1 -1
- package/dist/utils/applescript.js.map +1 -1
- package/dist/utils/index.d.ts +6 -6
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +4 -4
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/matching.d.ts +2 -2
- package/dist/utils/matching.d.ts.map +1 -1
- package/dist/utils/matching.js +4 -4
- package/dist/utils/matching.js.map +1 -1
- package/dist/utils/process.d.ts +1 -1
- package/dist/utils/process.d.ts.map +1 -1
- package/dist/utils/process.js +74 -74
- package/dist/utils/process.js.map +1 -1
- package/dist/utils/session.d.ts +1 -1
- package/dist/utils/session.d.ts.map +1 -1
- package/dist/utils/session.js +7 -7
- package/dist/utils/session.js.map +1 -1
- package/dist/utils/sortAgents.d.ts +2 -2
- package/dist/utils/sortAgents.d.ts.map +1 -1
- package/dist/utils/sortAgents.js +5 -5
- package/dist/utils/sortAgents.js.map +1 -1
- package/package.json +18 -19
- package/src/AgentManager.ts +283 -281
- package/src/__tests__/AgentManager.test.ts +917 -907
- package/src/__tests__/adapters/ClaudeCodeAdapter.test.ts +1657 -1368
- package/src/__tests__/adapters/CodexAdapter.test.ts +365 -1698
- package/src/__tests__/adapters/CopilotAdapter.test.ts +576 -481
- package/src/__tests__/adapters/GeminiCliAdapter.test.ts +1189 -1157
- package/src/__tests__/adapters/GrokCliAdapter.test.ts +325 -272
- package/src/__tests__/adapters/OpenCodeAdapter.test.ts +510 -455
- package/src/__tests__/capacity/codex.test.ts +178 -91
- package/src/__tests__/capacity/index.test.ts +27 -18
- package/src/__tests__/durable/CodexCliProbe.test.ts +75 -53
- package/src/__tests__/durable/CodexDurableAgentRepository.test.ts +51 -40
- package/src/__tests__/durable/CodexPrintAgent.integration.test.ts +89 -64
- package/src/__tests__/durable/CodexPrintAgentService.test.ts +196 -118
- package/src/__tests__/durable/CodexPrintRunner.test.ts +282 -162
- package/src/__tests__/fixtures/fake-claude.cjs +20 -13
- package/src/__tests__/fixtures/fake-codex.cjs +41 -30
- package/src/__tests__/print/ClaudeCliProbe.test.ts +27 -21
- package/src/__tests__/print/ClaudePrintAgent.integration.test.ts +48 -40
- package/src/__tests__/print/ClaudePrintAgentService.test.ts +118 -67
- package/src/__tests__/print/ClaudePrintRunner.test.ts +136 -83
- package/src/__tests__/print/DurableAgent.test.ts +19 -16
- package/src/__tests__/print/DurableAgentRepository.sqlite.test.ts +109 -86
- package/src/__tests__/print/DurableAgentRepository.test.ts +170 -137
- package/src/__tests__/providers/claude/ClaudeAgentMapper.test.ts +65 -65
- package/src/__tests__/providers/claude/ClaudeSessionLocator.test.ts +400 -377
- package/src/__tests__/providers/codex/CodexSessionLocator.test.ts +182 -0
- package/src/__tests__/providers/codex/CodexSessionMapping.test.ts +63 -0
- package/src/__tests__/providers/codex/CodexSessionParser.test.ts +192 -0
- package/src/__tests__/providers/pi/PiAdapter.test.ts +310 -0
- package/src/__tests__/providers/pi/PiSessionParser.test.ts +190 -0
- package/src/__tests__/providers/pi/PiSessionTracker.test.ts +79 -0
- package/src/__tests__/providers/pi/durable/PiCliProbe.test.ts +48 -32
- package/src/__tests__/providers/pi/durable/PiDurableAgentRepository.test.ts +24 -23
- package/src/__tests__/providers/pi/durable/PiPrintAgentService.test.ts +131 -59
- package/src/__tests__/providers/pi/durable/PiPrintProtocol.test.ts +66 -28
- package/src/__tests__/providers/pi/durable/PiPrintRunner.test.ts +236 -90
- package/src/__tests__/providers/pi/durable/PiStreamParser.test.ts +20 -18
- package/src/__tests__/readiness/AgentReadiness.test.ts +242 -0
- package/src/__tests__/runtime/AgentRuntime.test.ts +8 -0
- package/src/__tests__/runtime/HerdrAgentRuntime.test.ts +358 -0
- package/src/__tests__/runtime/ManagedAgentRuntime.test.ts +555 -0
- package/src/__tests__/terminal/TerminalFocusManager.test.ts +254 -253
- package/src/__tests__/terminal/TmuxManager.test.ts +157 -157
- package/src/__tests__/terminal/TtyWriter.test.ts +423 -419
- package/src/__tests__/utils/AgentRegistry.test.ts +506 -402
- package/src/__tests__/utils/ClaudeSessionParser.test.ts +276 -242
- package/src/__tests__/utils/agent-requests.test.ts +76 -56
- package/src/__tests__/utils/agents.test.ts +20 -20
- package/src/__tests__/utils/matching.test.ts +206 -171
- package/src/__tests__/utils/process.test.ts +276 -262
- package/src/__tests__/utils/session.test.ts +133 -139
- package/src/adapters/AgentAdapter.ts +134 -126
- package/src/adapters/CopilotAdapter.ts +405 -395
- package/src/adapters/GeminiCliAdapter.ts +598 -600
- package/src/adapters/GrokCliAdapter.ts +353 -342
- package/src/adapters/OpenCodeAdapter.ts +285 -259
- package/src/adapters/index.ts +15 -9
- package/src/capacity/codex.ts +137 -84
- package/src/capacity/index.ts +18 -13
- package/src/capacity/types.ts +1 -1
- package/src/database/connection.ts +73 -68
- package/src/database/index.ts +6 -6
- package/src/database/migrations/005_agent_runtime.sql +2 -0
- package/src/database/schema.ts +40 -38
- package/src/durable/DurableAgent.ts +85 -85
- package/src/durable/DurableAgentRepository.ts +409 -260
- package/src/durable/process.ts +22 -21
- package/src/durable/run.ts +61 -51
- package/src/durable/utils.ts +46 -41
- package/src/index.ts +145 -86
- package/src/providers/claude/ClaudeAgentMapper.ts +51 -50
- package/src/providers/claude/ClaudeCodeAdapter.ts +144 -136
- package/src/providers/claude/ClaudeSessionLocator.ts +291 -293
- package/src/providers/claude/ClaudeSessionParser.ts +322 -338
- package/src/providers/claude/durable/ClaudeCliProbe.ts +42 -37
- package/src/providers/claude/durable/ClaudePrintAgentService.ts +63 -50
- package/src/providers/claude/durable/ClaudePrintRunner.ts +79 -69
- package/src/providers/claude/durable/ClaudeStreamParser.ts +91 -62
- package/src/providers/codex/CodexAdapter.ts +205 -0
- package/src/providers/codex/CodexAgentMapper.ts +35 -0
- package/src/providers/codex/CodexSessionLocator.ts +279 -0
- package/src/providers/codex/CodexSessionMapping.ts +89 -0
- package/src/providers/codex/CodexSessionParser.ts +385 -0
- package/src/providers/codex/durable/CodexCliProbe.ts +50 -42
- package/src/providers/codex/durable/CodexPrintAgentService.ts +63 -49
- package/src/providers/codex/durable/CodexPrintRunner.ts +79 -69
- package/src/providers/codex/durable/CodexStreamParser.ts +97 -84
- package/src/providers/pi/PiAdapter.ts +183 -0
- package/src/providers/pi/PiAgentMapper.ts +36 -0
- package/src/providers/pi/PiSessionLocator.ts +95 -0
- package/src/providers/pi/PiSessionParser.ts +284 -0
- package/src/providers/pi/PiSessionTracker.ts +87 -0
- package/src/providers/pi/durable/PiCliProbe.ts +42 -34
- package/src/providers/pi/durable/PiPrintAgentService.ts +61 -53
- package/src/providers/pi/durable/PiPrintProtocol.ts +31 -29
- package/src/providers/pi/durable/PiPrintRunner.ts +75 -68
- package/src/providers/pi/durable/PiStreamParser.ts +82 -72
- package/src/readiness/AgentReadiness.ts +727 -0
- package/src/runtime/ManagedAgentRuntime.ts +266 -0
- package/src/runtime/RuntimeFactory.ts +13 -0
- package/src/runtime/errors.ts +50 -0
- package/src/runtime/herdr/HerdrAgentRuntime.ts +190 -0
- package/src/runtime/herdr/HerdrCliClient.ts +78 -0
- package/src/runtime/herdr/HerdrErrors.ts +9 -0
- package/src/runtime/herdr/HerdrResponseParsers.ts +76 -0
- package/src/runtime/herdr/HerdrRuntimeRef.ts +41 -0
- package/src/runtime/tmux/PidPolling.ts +34 -0
- package/src/runtime/tmux/TmuxAgentRuntime.ts +113 -0
- package/src/runtime/tmux/TmuxRuntimeRef.ts +9 -0
- package/src/runtime/types.ts +56 -0
- package/src/terminal/TerminalFocusManager.ts +215 -212
- package/src/terminal/TmuxManager.ts +99 -92
- package/src/terminal/TtyWriter.ts +203 -194
- package/src/terminal/index.ts +4 -4
- package/src/utils/AgentRegistry.ts +299 -238
- package/src/utils/agent-requests.ts +16 -16
- package/src/utils/agents.ts +41 -38
- package/src/utils/applescript.ts +4 -4
- package/src/utils/index.ts +12 -6
- package/src/utils/matching.ts +43 -43
- package/src/utils/process.ts +261 -258
- package/src/utils/session.ts +66 -66
- package/src/utils/sortAgents.ts +35 -33
- package/tsconfig.json +2 -8
- package/vitest.config.ts +16 -16
- package/.eslintrc.json +0 -31
- package/dist/__tests__/adapters/PiAdapter.test.js +0 -618
- package/dist/__tests__/adapters/PiAdapter.test.js.map +0 -1
- package/dist/__tests__/database/DurableAgentsDatabase.test.js +0 -128
- package/dist/__tests__/database/DurableAgentsDatabase.test.js.map +0 -1
- package/dist/adapters/CodexAdapter.d.ts +0 -109
- package/dist/adapters/CodexAdapter.d.ts.map +0 -1
- package/dist/adapters/CodexAdapter.js +0 -710
- package/dist/adapters/CodexAdapter.js.map +0 -1
- package/dist/adapters/PiAdapter.d.ts +0 -63
- package/dist/adapters/PiAdapter.d.ts.map +0 -1
- package/dist/adapters/PiAdapter.js +0 -453
- package/dist/adapters/PiAdapter.js.map +0 -1
- package/src/__tests__/adapters/PiAdapter.test.ts +0 -458
- package/src/__tests__/database/DurableAgentsDatabase.test.ts +0 -102
- package/src/adapters/CodexAdapter.ts +0 -923
- package/src/adapters/PiAdapter.ts +0 -598
|
@@ -2,509 +2,604 @@
|
|
|
2
2
|
* Tests for CopilotAdapter
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { MockedFunction } from
|
|
6
|
-
import * as fs from
|
|
7
|
-
import * as os from
|
|
8
|
-
import * as path from
|
|
9
|
-
|
|
10
|
-
import { CopilotAdapter } from
|
|
11
|
-
import type { ProcessInfo } from
|
|
12
|
-
import { AgentStatus } from
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
5
|
+
import type { MockedFunction } from "vitest";
|
|
6
|
+
import * as fs from "fs";
|
|
7
|
+
import * as os from "os";
|
|
8
|
+
import * as path from "path";
|
|
9
|
+
|
|
10
|
+
import { CopilotAdapter } from "../../adapters/CopilotAdapter.js";
|
|
11
|
+
import type { ProcessInfo } from "../../adapters/AgentAdapter.js";
|
|
12
|
+
import { AgentStatus } from "../../adapters/AgentAdapter.js";
|
|
13
|
+
import {
|
|
14
|
+
listAgentProcesses,
|
|
15
|
+
enrichProcesses,
|
|
16
|
+
captureProcessSnapshot,
|
|
17
|
+
} from "../../utils/process.js";
|
|
18
|
+
import { generateAgentName } from "../../utils/matching.js";
|
|
19
|
+
import { AgentRegistry } from "../../utils/AgentRegistry.js";
|
|
20
|
+
|
|
21
|
+
vi.mock("../../utils/process.js", async (importOriginal) => {
|
|
22
|
+
const actual = (await importOriginal()) as typeof import("../../utils/process.js");
|
|
23
|
+
return {
|
|
24
|
+
...actual,
|
|
25
|
+
listAgentProcesses: vi.fn(),
|
|
26
|
+
enrichProcesses: vi.fn(),
|
|
27
|
+
captureProcessSnapshot: vi.fn(),
|
|
28
|
+
};
|
|
25
29
|
});
|
|
26
30
|
|
|
27
|
-
vi.mock(
|
|
28
|
-
|
|
31
|
+
vi.mock("../../utils/matching.js", () => ({
|
|
32
|
+
generateAgentName: vi.fn(),
|
|
29
33
|
}));
|
|
30
34
|
|
|
31
35
|
const mockedListAgentProcesses = listAgentProcesses as MockedFunction<typeof listAgentProcesses>;
|
|
32
36
|
const mockedEnrichProcesses = enrichProcesses as MockedFunction<typeof enrichProcesses>;
|
|
33
|
-
const mockedCaptureProcessSnapshot = captureProcessSnapshot as MockedFunction<
|
|
37
|
+
const mockedCaptureProcessSnapshot = captureProcessSnapshot as MockedFunction<
|
|
38
|
+
typeof captureProcessSnapshot
|
|
39
|
+
>;
|
|
34
40
|
const mockedGenerateAgentName = generateAgentName as MockedFunction<typeof generateAgentName>;
|
|
35
41
|
|
|
36
|
-
describe(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
42
|
+
describe("CopilotAdapter", () => {
|
|
43
|
+
let adapter: CopilotAdapter;
|
|
44
|
+
let tmpDir: string;
|
|
45
|
+
let sessionStateDir: string;
|
|
46
|
+
|
|
47
|
+
beforeEach(() => {
|
|
48
|
+
adapter = new CopilotAdapter();
|
|
49
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "copilot-test-"));
|
|
50
|
+
sessionStateDir = path.join(tmpDir, "session-state");
|
|
51
|
+
fs.mkdirSync(sessionStateDir, { recursive: true });
|
|
52
|
+
(adapter as any).sessionStateDir = sessionStateDir;
|
|
53
|
+
|
|
54
|
+
mockedListAgentProcesses.mockReset();
|
|
55
|
+
mockedEnrichProcesses.mockReset();
|
|
56
|
+
mockedCaptureProcessSnapshot.mockReset();
|
|
57
|
+
mockedGenerateAgentName.mockReset();
|
|
58
|
+
mockedEnrichProcesses.mockImplementation((procs) => procs);
|
|
59
|
+
// Compatibility shim for standalone adapter discovery; the manager captures once and slices by name.
|
|
60
|
+
mockedCaptureProcessSnapshot.mockImplementation(async (names) =>
|
|
61
|
+
enrichProcesses(names.flatMap((name) => listAgentProcesses(name))),
|
|
62
|
+
);
|
|
63
|
+
mockedGenerateAgentName.mockImplementation(
|
|
64
|
+
(cwd, pid) => `${path.basename(cwd) || "unknown"} (${pid})`,
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
afterEach(() => {
|
|
69
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
function writeSession(
|
|
73
|
+
sessionId: string,
|
|
74
|
+
options: {
|
|
75
|
+
events?: Array<object | string>;
|
|
76
|
+
workspace?: Record<string, string>;
|
|
77
|
+
lockPid?: number | string;
|
|
78
|
+
},
|
|
79
|
+
): string {
|
|
80
|
+
const sessionDir = path.join(sessionStateDir, sessionId);
|
|
81
|
+
fs.mkdirSync(sessionDir, { recursive: true });
|
|
82
|
+
|
|
83
|
+
if (options.events) {
|
|
84
|
+
const lines = options.events.map((entry) =>
|
|
85
|
+
typeof entry === "string" ? entry : JSON.stringify(entry),
|
|
86
|
+
);
|
|
87
|
+
fs.writeFileSync(path.join(sessionDir, "events.jsonl"), lines.join("\n"));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (options.workspace) {
|
|
91
|
+
const lines = Object.entries(options.workspace).map(([key, value]) => `${key}: ${value}`);
|
|
92
|
+
fs.writeFileSync(path.join(sessionDir, "workspace.yaml"), lines.join("\n"));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (options.lockPid !== undefined) {
|
|
96
|
+
fs.writeFileSync(path.join(sessionDir, `inuse.${options.lockPid}.lock`), "");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return sessionDir;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function sessionStart(
|
|
103
|
+
sessionId: string,
|
|
104
|
+
cwd: string,
|
|
105
|
+
startTime = "2026-06-09T09:50:00.000Z",
|
|
106
|
+
): object {
|
|
107
|
+
return {
|
|
108
|
+
type: "session.start",
|
|
109
|
+
data: {
|
|
110
|
+
sessionId,
|
|
111
|
+
startTime,
|
|
112
|
+
context: {
|
|
113
|
+
cwd,
|
|
114
|
+
gitRoot: cwd,
|
|
115
|
+
branch: "main",
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
timestamp: startTime,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
describe("initialization", () => {
|
|
123
|
+
it("exposes copilot type", () => {
|
|
124
|
+
expect(adapter.type).toBe("copilot");
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
describe("canHandle", () => {
|
|
129
|
+
it("returns true for copilot commands", () => {
|
|
130
|
+
expect(adapter.canHandle({ pid: 1, command: "copilot", cwd: "/repo", tty: "ttys001" })).toBe(
|
|
131
|
+
true,
|
|
132
|
+
);
|
|
58
133
|
});
|
|
59
134
|
|
|
60
|
-
|
|
61
|
-
|
|
135
|
+
it("returns true for full-path Homebrew copilot commands", () => {
|
|
136
|
+
expect(
|
|
137
|
+
adapter.canHandle({
|
|
138
|
+
pid: 2,
|
|
139
|
+
command: "/opt/homebrew/Caskroom/copilot-cli/1.0.60/copilot",
|
|
140
|
+
cwd: "/repo",
|
|
141
|
+
tty: "ttys002",
|
|
142
|
+
}),
|
|
143
|
+
).toBe(true);
|
|
62
144
|
});
|
|
63
145
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
146
|
+
it("returns true for copilot.exe commands", () => {
|
|
147
|
+
expect(
|
|
148
|
+
adapter.canHandle({
|
|
149
|
+
pid: 3,
|
|
150
|
+
command: "/usr/bin/copilot.exe",
|
|
151
|
+
cwd: "/repo",
|
|
152
|
+
tty: "ttys003",
|
|
153
|
+
}),
|
|
154
|
+
).toBe(true);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("returns false when copilot appears only in an argument", () => {
|
|
158
|
+
expect(
|
|
159
|
+
adapter.canHandle({
|
|
160
|
+
pid: 4,
|
|
161
|
+
command: "node /repo/copilot-plugin/index.js",
|
|
162
|
+
cwd: "/repo",
|
|
163
|
+
tty: "ttys004",
|
|
164
|
+
}),
|
|
165
|
+
).toBe(false);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
describe("detectAgents", () => {
|
|
170
|
+
it("returns empty list when no copilot process is running", async () => {
|
|
171
|
+
mockedListAgentProcesses.mockReturnValue([]);
|
|
172
|
+
|
|
173
|
+
const agents = await adapter.detectAgents();
|
|
174
|
+
|
|
175
|
+
expect(agents).toEqual([]);
|
|
176
|
+
expect(mockedListAgentProcesses).toHaveBeenCalledWith("copilot");
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it("maps matching inuse lock and events to an active agent", async () => {
|
|
180
|
+
const processes: ProcessInfo[] = [
|
|
181
|
+
{
|
|
182
|
+
pid: 14096,
|
|
183
|
+
command: "/opt/homebrew/Caskroom/copilot-cli/1.0.60/copilot",
|
|
184
|
+
cwd: "/repo",
|
|
185
|
+
tty: "ttys001",
|
|
70
186
|
},
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
187
|
+
];
|
|
188
|
+
mockedListAgentProcesses.mockReturnValue(processes);
|
|
189
|
+
mockedEnrichProcesses.mockReturnValue(processes);
|
|
190
|
+
writeSession("sess-a", {
|
|
191
|
+
lockPid: 14096,
|
|
192
|
+
events: [
|
|
193
|
+
sessionStart("sess-a", "/repo", "2026-06-09T09:50:00.000Z"),
|
|
194
|
+
{
|
|
195
|
+
type: "user.message",
|
|
196
|
+
data: { content: "Build the Copilot adapter" },
|
|
197
|
+
timestamp: new Date().toISOString(),
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
type: "assistant.message",
|
|
201
|
+
data: { content: "I will inspect the code." },
|
|
202
|
+
timestamp: new Date().toISOString(),
|
|
203
|
+
},
|
|
204
|
+
],
|
|
205
|
+
workspace: {
|
|
206
|
+
id: "sess-a",
|
|
207
|
+
cwd: "/fallback",
|
|
208
|
+
name: "Fallback Name",
|
|
209
|
+
created_at: "2026-06-09T09:49:00.000Z",
|
|
210
|
+
updated_at: "2026-06-09T09:51:00.000Z",
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
const agents = await adapter.detectAgents();
|
|
215
|
+
|
|
216
|
+
expect(agents).toHaveLength(1);
|
|
217
|
+
expect(agents[0]).toMatchObject({
|
|
218
|
+
type: "copilot",
|
|
219
|
+
status: AgentStatus.WAITING,
|
|
220
|
+
pid: 14096,
|
|
221
|
+
projectPath: "/repo",
|
|
222
|
+
sessionId: "sess-a",
|
|
223
|
+
summary: "Build the Copilot adapter",
|
|
224
|
+
sessionFilePath: path.join(sessionStateDir, "sess-a", "events.jsonl"),
|
|
225
|
+
});
|
|
226
|
+
});
|
|
93
227
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
228
|
+
it("ignores invalid and unmatched lock PIDs", async () => {
|
|
229
|
+
const processes: ProcessInfo[] = [
|
|
230
|
+
{ pid: 100, command: "copilot", cwd: "/repo", tty: "ttys001" },
|
|
231
|
+
];
|
|
232
|
+
mockedListAgentProcesses.mockReturnValue(processes);
|
|
233
|
+
mockedEnrichProcesses.mockReturnValue(processes);
|
|
234
|
+
writeSession("invalid", {
|
|
235
|
+
lockPid: "not-a-pid",
|
|
236
|
+
events: [sessionStart("invalid", "/invalid")],
|
|
237
|
+
});
|
|
238
|
+
writeSession("unmatched", {
|
|
239
|
+
lockPid: 999999,
|
|
240
|
+
events: [sessionStart("unmatched", "/unmatched")],
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
const agents = await adapter.detectAgents();
|
|
244
|
+
|
|
245
|
+
expect(agents).toHaveLength(1);
|
|
246
|
+
expect(agents[0]).toMatchObject({
|
|
247
|
+
pid: 100,
|
|
248
|
+
sessionId: "pid-100",
|
|
249
|
+
summary: "Copilot process running",
|
|
250
|
+
});
|
|
251
|
+
});
|
|
109
252
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
253
|
+
it("falls back to process-only agent when no session lock matches", async () => {
|
|
254
|
+
const processes: ProcessInfo[] = [
|
|
255
|
+
{ pid: 200, command: "copilot", cwd: "/repo-b", tty: "ttys002" },
|
|
256
|
+
];
|
|
257
|
+
mockedListAgentProcesses.mockReturnValue(processes);
|
|
258
|
+
mockedEnrichProcesses.mockReturnValue(processes);
|
|
259
|
+
|
|
260
|
+
const agents = await adapter.detectAgents();
|
|
261
|
+
|
|
262
|
+
expect(agents).toHaveLength(1);
|
|
263
|
+
expect(agents[0]).toMatchObject({
|
|
264
|
+
type: "copilot",
|
|
265
|
+
status: AgentStatus.RUNNING,
|
|
266
|
+
pid: 200,
|
|
267
|
+
projectPath: "/repo-b",
|
|
268
|
+
sessionId: "pid-200",
|
|
269
|
+
summary: "Copilot process running",
|
|
270
|
+
});
|
|
114
271
|
});
|
|
115
272
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
cwd: '/repo',
|
|
139
|
-
tty: 'ttys004',
|
|
140
|
-
})).toBe(false);
|
|
141
|
-
});
|
|
273
|
+
it("suppresses wrapper process-only agents before the session lock exists", async () => {
|
|
274
|
+
const processes: ProcessInfo[] = [
|
|
275
|
+
{ pid: 86800, command: "copilot", cwd: "/repo", tty: "ttys001", ppid: 84174 },
|
|
276
|
+
{
|
|
277
|
+
pid: 86810,
|
|
278
|
+
command: "/custom/install/copilot",
|
|
279
|
+
cwd: "/repo",
|
|
280
|
+
tty: "ttys001",
|
|
281
|
+
ppid: 86800,
|
|
282
|
+
},
|
|
283
|
+
];
|
|
284
|
+
mockedListAgentProcesses.mockReturnValue(processes);
|
|
285
|
+
mockedEnrichProcesses.mockReturnValue(processes);
|
|
286
|
+
|
|
287
|
+
const agents = await adapter.detectAgents();
|
|
288
|
+
|
|
289
|
+
expect(agents).toHaveLength(1);
|
|
290
|
+
expect(agents[0]).toMatchObject({
|
|
291
|
+
pid: 86810,
|
|
292
|
+
sessionId: "pid-86810",
|
|
293
|
+
summary: "Copilot process running",
|
|
294
|
+
});
|
|
142
295
|
});
|
|
143
296
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
type: 'copilot',
|
|
181
|
-
status: AgentStatus.WAITING,
|
|
182
|
-
pid: 14096,
|
|
183
|
-
projectPath: '/repo',
|
|
184
|
-
sessionId: 'sess-a',
|
|
185
|
-
summary: 'Build the Copilot adapter',
|
|
186
|
-
sessionFilePath: path.join(sessionStateDir, 'sess-a', 'events.jsonl'),
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it('ignores invalid and unmatched lock PIDs', async () => {
|
|
191
|
-
const processes: ProcessInfo[] = [
|
|
192
|
-
{ pid: 100, command: 'copilot', cwd: '/repo', tty: 'ttys001' },
|
|
193
|
-
];
|
|
194
|
-
mockedListAgentProcesses.mockReturnValue(processes);
|
|
195
|
-
mockedEnrichProcesses.mockReturnValue(processes);
|
|
196
|
-
writeSession('invalid', {
|
|
197
|
-
lockPid: 'not-a-pid',
|
|
198
|
-
events: [sessionStart('invalid', '/invalid')],
|
|
199
|
-
});
|
|
200
|
-
writeSession('unmatched', {
|
|
201
|
-
lockPid: 999999,
|
|
202
|
-
events: [sessionStart('unmatched', '/unmatched')],
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
const agents = await adapter.detectAgents();
|
|
206
|
-
|
|
207
|
-
expect(agents).toHaveLength(1);
|
|
208
|
-
expect(agents[0]).toMatchObject({
|
|
209
|
-
pid: 100,
|
|
210
|
-
sessionId: 'pid-100',
|
|
211
|
-
summary: 'Copilot process running',
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
it('falls back to process-only agent when no session lock matches', async () => {
|
|
216
|
-
const processes: ProcessInfo[] = [
|
|
217
|
-
{ pid: 200, command: 'copilot', cwd: '/repo-b', tty: 'ttys002' },
|
|
218
|
-
];
|
|
219
|
-
mockedListAgentProcesses.mockReturnValue(processes);
|
|
220
|
-
mockedEnrichProcesses.mockReturnValue(processes);
|
|
221
|
-
|
|
222
|
-
const agents = await adapter.detectAgents();
|
|
223
|
-
|
|
224
|
-
expect(agents).toHaveLength(1);
|
|
225
|
-
expect(agents[0]).toMatchObject({
|
|
226
|
-
type: 'copilot',
|
|
227
|
-
status: AgentStatus.RUNNING,
|
|
228
|
-
pid: 200,
|
|
229
|
-
projectPath: '/repo-b',
|
|
230
|
-
sessionId: 'pid-200',
|
|
231
|
-
summary: 'Copilot process running',
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
it('suppresses wrapper process-only agents before the session lock exists', async () => {
|
|
236
|
-
const processes: ProcessInfo[] = [
|
|
237
|
-
{ pid: 86800, command: 'copilot', cwd: '/repo', tty: 'ttys001', ppid: 84174 },
|
|
238
|
-
{ pid: 86810, command: '/custom/install/copilot', cwd: '/repo', tty: 'ttys001', ppid: 86800 },
|
|
239
|
-
];
|
|
240
|
-
mockedListAgentProcesses.mockReturnValue(processes);
|
|
241
|
-
mockedEnrichProcesses.mockReturnValue(processes);
|
|
242
|
-
|
|
243
|
-
const agents = await adapter.detectAgents();
|
|
244
|
-
|
|
245
|
-
expect(agents).toHaveLength(1);
|
|
246
|
-
expect(agents[0]).toMatchObject({
|
|
247
|
-
pid: 86810,
|
|
248
|
-
sessionId: 'pid-86810',
|
|
249
|
-
summary: 'Copilot process running',
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
it('carries the managed wrapper name to a process-only child before the session lock exists', async () => {
|
|
254
|
-
const registry = new AgentRegistry(path.join(tmpDir, 'agents.json'));
|
|
255
|
-
adapter = new CopilotAdapter(registry);
|
|
256
|
-
(adapter as any).sessionStateDir = sessionStateDir;
|
|
257
|
-
const processes: ProcessInfo[] = [
|
|
258
|
-
{ pid: 86800, command: 'copilot', cwd: '/repo', tty: 'ttys001', ppid: 84174 },
|
|
259
|
-
{ pid: 86810, command: '/custom/install/copilot', cwd: '/repo', tty: 'ttys001', ppid: 86800 },
|
|
260
|
-
];
|
|
261
|
-
registry.register({
|
|
262
|
-
name: 'copilot-started',
|
|
263
|
-
type: 'copilot',
|
|
264
|
-
pid: 86800,
|
|
265
|
-
tmuxSession: 'copilot-started',
|
|
266
|
-
cwd: '/repo',
|
|
267
|
-
startedAt: '2026-06-13T19:15:16.211Z',
|
|
268
|
-
sessionId: 'pid-86800',
|
|
269
|
-
sessionFilePath: '',
|
|
270
|
-
});
|
|
271
|
-
mockedListAgentProcesses.mockReturnValue(processes);
|
|
272
|
-
mockedEnrichProcesses.mockReturnValue(processes);
|
|
273
|
-
|
|
274
|
-
const agents = await adapter.detectAgents();
|
|
275
|
-
|
|
276
|
-
expect(agents).toHaveLength(1);
|
|
277
|
-
expect(agents[0]).toMatchObject({
|
|
278
|
-
name: 'copilot-started',
|
|
279
|
-
pid: 86810,
|
|
280
|
-
sessionId: 'pid-86810',
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
it('does not add duplicate process-only agent for wrapper process in the same terminal', async () => {
|
|
285
|
-
const processes: ProcessInfo[] = [
|
|
286
|
-
{ pid: 14095, command: 'copilot', cwd: '/repo', tty: 'ttys001' },
|
|
287
|
-
{ pid: 14096, command: '/opt/homebrew/Caskroom/copilot-cli/1.0.60/copilot', cwd: '/repo', tty: 'ttys001' },
|
|
288
|
-
];
|
|
289
|
-
mockedListAgentProcesses.mockReturnValue(processes);
|
|
290
|
-
mockedEnrichProcesses.mockReturnValue(processes);
|
|
291
|
-
writeSession('sess-wrapper', {
|
|
292
|
-
lockPid: 14096,
|
|
293
|
-
events: [
|
|
294
|
-
sessionStart('sess-wrapper', '/repo', '2026-06-09T09:50:00.000Z'),
|
|
295
|
-
{ type: 'user.message', data: { content: 'hello' }, timestamp: new Date().toISOString() },
|
|
296
|
-
],
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
const agents = await adapter.detectAgents();
|
|
300
|
-
|
|
301
|
-
expect(agents).toHaveLength(1);
|
|
302
|
-
expect(agents[0]).toMatchObject({
|
|
303
|
-
pid: 14096,
|
|
304
|
-
sessionId: 'sess-wrapper',
|
|
305
|
-
});
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
it('carries the managed wrapper name to a lock-backed child process', async () => {
|
|
309
|
-
const registry = new AgentRegistry(path.join(tmpDir, 'agents.json'));
|
|
310
|
-
adapter = new CopilotAdapter(registry);
|
|
311
|
-
(adapter as any).sessionStateDir = sessionStateDir;
|
|
312
|
-
const processes: ProcessInfo[] = [
|
|
313
|
-
{ pid: 14095, command: 'copilot', cwd: '/repo', tty: 'ttys001', ppid: 84174 },
|
|
314
|
-
{ pid: 14096, command: '/opt/homebrew/Caskroom/copilot-cli/1.0.60/copilot', cwd: '/repo', tty: 'ttys001', ppid: 14095 },
|
|
315
|
-
];
|
|
316
|
-
registry.register({
|
|
317
|
-
name: 'copilot-started',
|
|
318
|
-
type: 'copilot',
|
|
319
|
-
pid: 14095,
|
|
320
|
-
tmuxSession: 'copilot-started',
|
|
321
|
-
cwd: '/repo',
|
|
322
|
-
startedAt: '2026-06-13T19:15:16.211Z',
|
|
323
|
-
sessionId: 'pid-14095',
|
|
324
|
-
sessionFilePath: '',
|
|
325
|
-
});
|
|
326
|
-
mockedListAgentProcesses.mockReturnValue(processes);
|
|
327
|
-
mockedEnrichProcesses.mockReturnValue(processes);
|
|
328
|
-
writeSession('sess-wrapper', {
|
|
329
|
-
lockPid: 14096,
|
|
330
|
-
events: [
|
|
331
|
-
sessionStart('sess-wrapper', '/repo', '2026-06-09T09:50:00.000Z'),
|
|
332
|
-
{ type: 'user.message', data: { content: 'hello' }, timestamp: new Date().toISOString() },
|
|
333
|
-
],
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
const agents = await adapter.detectAgents();
|
|
337
|
-
|
|
338
|
-
expect(agents).toHaveLength(1);
|
|
339
|
-
expect(agents[0]).toMatchObject({
|
|
340
|
-
name: 'copilot-started',
|
|
341
|
-
pid: 14096,
|
|
342
|
-
sessionId: 'sess-wrapper',
|
|
343
|
-
});
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
it('uses workspace metadata when events are missing', async () => {
|
|
347
|
-
const processes: ProcessInfo[] = [
|
|
348
|
-
{ pid: 300, command: 'copilot', cwd: '/proc-cwd', tty: 'ttys003' },
|
|
349
|
-
];
|
|
350
|
-
mockedListAgentProcesses.mockReturnValue(processes);
|
|
351
|
-
mockedEnrichProcesses.mockReturnValue(processes);
|
|
352
|
-
writeSession('workspace-only', {
|
|
353
|
-
lockPid: 300,
|
|
354
|
-
workspace: {
|
|
355
|
-
id: 'workspace-only',
|
|
356
|
-
cwd: '/workspace-cwd',
|
|
357
|
-
name: 'Workspace Session',
|
|
358
|
-
created_at: '2026-06-09T09:00:00.000Z',
|
|
359
|
-
updated_at: '2026-06-09T09:10:00.000Z',
|
|
360
|
-
},
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
const agents = await adapter.detectAgents();
|
|
364
|
-
|
|
365
|
-
expect(agents).toHaveLength(1);
|
|
366
|
-
expect(agents[0]).toMatchObject({
|
|
367
|
-
pid: 300,
|
|
368
|
-
projectPath: '/workspace-cwd',
|
|
369
|
-
sessionId: 'workspace-only',
|
|
370
|
-
summary: 'Workspace Session',
|
|
371
|
-
});
|
|
372
|
-
});
|
|
297
|
+
it("carries the managed wrapper name to a process-only child before the session lock exists", async () => {
|
|
298
|
+
const registry = new AgentRegistry(path.join(tmpDir, "agents.json"));
|
|
299
|
+
adapter = new CopilotAdapter(registry);
|
|
300
|
+
(adapter as any).sessionStateDir = sessionStateDir;
|
|
301
|
+
const processes: ProcessInfo[] = [
|
|
302
|
+
{ pid: 86800, command: "copilot", cwd: "/repo", tty: "ttys001", ppid: 84174 },
|
|
303
|
+
{
|
|
304
|
+
pid: 86810,
|
|
305
|
+
command: "/custom/install/copilot",
|
|
306
|
+
cwd: "/repo",
|
|
307
|
+
tty: "ttys001",
|
|
308
|
+
ppid: 86800,
|
|
309
|
+
},
|
|
310
|
+
];
|
|
311
|
+
registry.register({
|
|
312
|
+
name: "copilot-started",
|
|
313
|
+
type: "copilot",
|
|
314
|
+
pid: 86800,
|
|
315
|
+
runtime: "tmux",
|
|
316
|
+
runtimeRef: { session: "copilot-started" },
|
|
317
|
+
cwd: "/repo",
|
|
318
|
+
startedAt: "2026-06-13T19:15:16.211Z",
|
|
319
|
+
sessionId: "pid-86800",
|
|
320
|
+
sessionFilePath: "",
|
|
321
|
+
});
|
|
322
|
+
mockedListAgentProcesses.mockReturnValue(processes);
|
|
323
|
+
mockedEnrichProcesses.mockReturnValue(processes);
|
|
324
|
+
|
|
325
|
+
const agents = await adapter.detectAgents();
|
|
326
|
+
|
|
327
|
+
expect(agents).toHaveLength(1);
|
|
328
|
+
expect(agents[0]).toMatchObject({
|
|
329
|
+
name: "copilot-started",
|
|
330
|
+
pid: 86810,
|
|
331
|
+
sessionId: "pid-86810",
|
|
332
|
+
});
|
|
373
333
|
});
|
|
374
334
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
335
|
+
it("does not add duplicate process-only agent for wrapper process in the same terminal", async () => {
|
|
336
|
+
const processes: ProcessInfo[] = [
|
|
337
|
+
{ pid: 14095, command: "copilot", cwd: "/repo", tty: "ttys001" },
|
|
338
|
+
{
|
|
339
|
+
pid: 14096,
|
|
340
|
+
command: "/opt/homebrew/Caskroom/copilot-cli/1.0.60/copilot",
|
|
341
|
+
cwd: "/repo",
|
|
342
|
+
tty: "ttys001",
|
|
343
|
+
},
|
|
344
|
+
];
|
|
345
|
+
mockedListAgentProcesses.mockReturnValue(processes);
|
|
346
|
+
mockedEnrichProcesses.mockReturnValue(processes);
|
|
347
|
+
writeSession("sess-wrapper", {
|
|
348
|
+
lockPid: 14096,
|
|
349
|
+
events: [
|
|
350
|
+
sessionStart("sess-wrapper", "/repo", "2026-06-09T09:50:00.000Z"),
|
|
351
|
+
{ type: "user.message", data: { content: "hello" }, timestamp: new Date().toISOString() },
|
|
352
|
+
],
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
const agents = await adapter.detectAgents();
|
|
356
|
+
|
|
357
|
+
expect(agents).toHaveLength(1);
|
|
358
|
+
expect(agents[0]).toMatchObject({
|
|
359
|
+
pid: 14096,
|
|
360
|
+
sessionId: "sess-wrapper",
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
it("carries the managed wrapper name to a lock-backed child process", async () => {
|
|
365
|
+
const registry = new AgentRegistry(path.join(tmpDir, "agents.json"));
|
|
366
|
+
adapter = new CopilotAdapter(registry);
|
|
367
|
+
(adapter as any).sessionStateDir = sessionStateDir;
|
|
368
|
+
const processes: ProcessInfo[] = [
|
|
369
|
+
{ pid: 14095, command: "copilot", cwd: "/repo", tty: "ttys001", ppid: 84174 },
|
|
370
|
+
{
|
|
371
|
+
pid: 14096,
|
|
372
|
+
command: "/opt/homebrew/Caskroom/copilot-cli/1.0.60/copilot",
|
|
373
|
+
cwd: "/repo",
|
|
374
|
+
tty: "ttys001",
|
|
375
|
+
ppid: 14095,
|
|
376
|
+
},
|
|
377
|
+
];
|
|
378
|
+
registry.register({
|
|
379
|
+
name: "copilot-started",
|
|
380
|
+
type: "copilot",
|
|
381
|
+
pid: 14095,
|
|
382
|
+
runtime: "tmux",
|
|
383
|
+
runtimeRef: { session: "copilot-started" },
|
|
384
|
+
cwd: "/repo",
|
|
385
|
+
startedAt: "2026-06-13T19:15:16.211Z",
|
|
386
|
+
sessionId: "pid-14095",
|
|
387
|
+
sessionFilePath: "",
|
|
388
|
+
});
|
|
389
|
+
mockedListAgentProcesses.mockReturnValue(processes);
|
|
390
|
+
mockedEnrichProcesses.mockReturnValue(processes);
|
|
391
|
+
writeSession("sess-wrapper", {
|
|
392
|
+
lockPid: 14096,
|
|
393
|
+
events: [
|
|
394
|
+
sessionStart("sess-wrapper", "/repo", "2026-06-09T09:50:00.000Z"),
|
|
395
|
+
{ type: "user.message", data: { content: "hello" }, timestamp: new Date().toISOString() },
|
|
396
|
+
],
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
const agents = await adapter.detectAgents();
|
|
400
|
+
|
|
401
|
+
expect(agents).toHaveLength(1);
|
|
402
|
+
expect(agents[0]).toMatchObject({
|
|
403
|
+
name: "copilot-started",
|
|
404
|
+
pid: 14096,
|
|
405
|
+
sessionId: "sess-wrapper",
|
|
406
|
+
});
|
|
428
407
|
});
|
|
429
408
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
409
|
+
it("uses workspace metadata when events are missing", async () => {
|
|
410
|
+
const processes: ProcessInfo[] = [
|
|
411
|
+
{ pid: 300, command: "copilot", cwd: "/proc-cwd", tty: "ttys003" },
|
|
412
|
+
];
|
|
413
|
+
mockedListAgentProcesses.mockReturnValue(processes);
|
|
414
|
+
mockedEnrichProcesses.mockReturnValue(processes);
|
|
415
|
+
writeSession("workspace-only", {
|
|
416
|
+
lockPid: 300,
|
|
417
|
+
workspace: {
|
|
418
|
+
id: "workspace-only",
|
|
419
|
+
cwd: "/workspace-cwd",
|
|
420
|
+
name: "Workspace Session",
|
|
421
|
+
created_at: "2026-06-09T09:00:00.000Z",
|
|
422
|
+
updated_at: "2026-06-09T09:10:00.000Z",
|
|
423
|
+
},
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
const agents = await adapter.detectAgents();
|
|
427
|
+
|
|
428
|
+
expect(agents).toHaveLength(1);
|
|
429
|
+
expect(agents[0]).toMatchObject({
|
|
430
|
+
pid: 300,
|
|
431
|
+
projectPath: "/workspace-cwd",
|
|
432
|
+
sessionId: "workspace-only",
|
|
433
|
+
summary: "Workspace Session",
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
describe("getConversation", () => {
|
|
439
|
+
it("parses user and assistant message events", () => {
|
|
440
|
+
const sessionDir = writeSession("conv", {
|
|
441
|
+
events: [
|
|
442
|
+
sessionStart("conv", "/repo"),
|
|
443
|
+
{
|
|
444
|
+
type: "user.message",
|
|
445
|
+
data: { content: "hello" },
|
|
446
|
+
timestamp: "2026-06-09T09:50:01.000Z",
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
type: "assistant.message",
|
|
450
|
+
data: { content: "Hi there" },
|
|
451
|
+
timestamp: "2026-06-09T09:50:02.000Z",
|
|
452
|
+
},
|
|
453
|
+
],
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
const messages = adapter.getConversation(path.join(sessionDir, "events.jsonl"));
|
|
457
|
+
|
|
458
|
+
expect(messages).toEqual([
|
|
459
|
+
{ role: "user", content: "hello", timestamp: "2026-06-09T09:50:01.000Z" },
|
|
460
|
+
{ role: "assistant", content: "Hi there", timestamp: "2026-06-09T09:50:02.000Z" },
|
|
461
|
+
]);
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
it("includes system/info/warning messages only in verbose mode", () => {
|
|
465
|
+
const sessionDir = writeSession("verbose", {
|
|
466
|
+
events: [
|
|
467
|
+
{
|
|
468
|
+
type: "session.warning",
|
|
469
|
+
data: { message: "MCP failed" },
|
|
470
|
+
timestamp: "2026-06-09T09:50:01.000Z",
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
type: "tool.execution_complete",
|
|
474
|
+
data: { result: { content: "Tool result" } },
|
|
475
|
+
timestamp: "2026-06-09T09:50:02.000Z",
|
|
476
|
+
},
|
|
477
|
+
],
|
|
478
|
+
});
|
|
479
|
+
const filePath = path.join(sessionDir, "events.jsonl");
|
|
480
|
+
|
|
481
|
+
expect(adapter.getConversation(filePath)).toEqual([]);
|
|
482
|
+
expect(adapter.getConversation(filePath, { verbose: true })).toEqual([
|
|
483
|
+
{ role: "system", content: "MCP failed", timestamp: "2026-06-09T09:50:01.000Z" },
|
|
484
|
+
{ role: "system", content: "Tool result", timestamp: "2026-06-09T09:50:02.000Z" },
|
|
485
|
+
]);
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
it("skips malformed JSONL lines and missing text", () => {
|
|
489
|
+
const sessionDir = writeSession("malformed", {
|
|
490
|
+
events: [
|
|
491
|
+
"not json",
|
|
492
|
+
{
|
|
493
|
+
type: "user.message",
|
|
494
|
+
data: { content: "valid" },
|
|
495
|
+
timestamp: "2026-06-09T09:50:01.000Z",
|
|
496
|
+
},
|
|
497
|
+
{ type: "assistant.message", data: {}, timestamp: "2026-06-09T09:50:02.000Z" },
|
|
498
|
+
],
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
const messages = adapter.getConversation(path.join(sessionDir, "events.jsonl"));
|
|
502
|
+
|
|
503
|
+
expect(messages).toEqual([
|
|
504
|
+
{ role: "user", content: "valid", timestamp: "2026-06-09T09:50:01.000Z" },
|
|
505
|
+
]);
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
it("returns empty array for missing file", () => {
|
|
509
|
+
expect(adapter.getConversation(path.join(tmpDir, "missing.jsonl"))).toEqual([]);
|
|
510
|
+
});
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
describe("listSessions", () => {
|
|
514
|
+
it("returns historical sessions without active locks", async () => {
|
|
515
|
+
writeSession("history-a", {
|
|
516
|
+
events: [
|
|
517
|
+
sessionStart("history-a", "/repo-a", "2026-06-09T09:00:00.000Z"),
|
|
518
|
+
{
|
|
519
|
+
type: "user.message",
|
|
520
|
+
data: { content: "first user" },
|
|
521
|
+
timestamp: "2026-06-09T09:00:01.000Z",
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
type: "assistant.message",
|
|
525
|
+
data: { content: "answer" },
|
|
526
|
+
timestamp: "2026-06-09T09:00:02.000Z",
|
|
527
|
+
},
|
|
528
|
+
],
|
|
529
|
+
});
|
|
530
|
+
writeSession("history-b", {
|
|
531
|
+
events: [
|
|
532
|
+
sessionStart("history-b", "/repo-b", "2026-06-09T10:00:00.000Z"),
|
|
533
|
+
{
|
|
534
|
+
type: "user.message",
|
|
535
|
+
data: { content: "other user" },
|
|
536
|
+
timestamp: "2026-06-09T10:00:01.000Z",
|
|
537
|
+
},
|
|
538
|
+
],
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
const sessions = await adapter.listSessions();
|
|
542
|
+
|
|
543
|
+
expect(sessions).toHaveLength(2);
|
|
544
|
+
const byId = Object.fromEntries(sessions.map((session) => [session.sessionId, session]));
|
|
545
|
+
expect(byId["history-a"]).toMatchObject({
|
|
546
|
+
type: "copilot",
|
|
547
|
+
cwd: "/repo-a",
|
|
548
|
+
firstUserMessage: "first user",
|
|
549
|
+
sessionFilePath: path.join(sessionStateDir, "history-a", "events.jsonl"),
|
|
550
|
+
});
|
|
551
|
+
expect(byId["history-b"]).toMatchObject({
|
|
552
|
+
type: "copilot",
|
|
553
|
+
cwd: "/repo-b",
|
|
554
|
+
firstUserMessage: "other user",
|
|
555
|
+
});
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
it("applies strict cwd filter", async () => {
|
|
559
|
+
writeSession("keep", { events: [sessionStart("keep", "/repo")] });
|
|
560
|
+
writeSession("drop", { events: [sessionStart("drop", "/other")] });
|
|
561
|
+
|
|
562
|
+
const sessions = await adapter.listSessions({ cwd: "/repo" });
|
|
563
|
+
|
|
564
|
+
expect(sessions).toHaveLength(1);
|
|
565
|
+
expect(sessions[0].sessionId).toBe("keep");
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
it("uses workspace fallback for historical sessions without events", async () => {
|
|
569
|
+
writeSession("workspace-history", {
|
|
570
|
+
workspace: {
|
|
571
|
+
id: "workspace-history",
|
|
572
|
+
cwd: "/workspace-repo",
|
|
573
|
+
name: "Workspace History",
|
|
574
|
+
created_at: "2026-06-09T08:00:00.000Z",
|
|
575
|
+
updated_at: "2026-06-09T08:10:00.000Z",
|
|
576
|
+
},
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
const sessions = await adapter.listSessions();
|
|
580
|
+
|
|
581
|
+
expect(sessions).toHaveLength(1);
|
|
582
|
+
expect(sessions[0]).toMatchObject({
|
|
583
|
+
type: "copilot",
|
|
584
|
+
sessionId: "workspace-history",
|
|
585
|
+
cwd: "/workspace-repo",
|
|
586
|
+
firstUserMessage: "",
|
|
587
|
+
sessionFilePath: path.join(sessionStateDir, "workspace-history", "events.jsonl"),
|
|
588
|
+
});
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
it("skips session directories without events or workspace metadata", async () => {
|
|
592
|
+
fs.mkdirSync(path.join(sessionStateDir, "empty"), { recursive: true });
|
|
593
|
+
|
|
594
|
+
const sessions = await adapter.listSessions();
|
|
595
|
+
|
|
596
|
+
expect(sessions).toEqual([]);
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
it("returns empty when session-state directory does not exist", async () => {
|
|
600
|
+
(adapter as any).sessionStateDir = path.join(tmpDir, "missing");
|
|
601
|
+
|
|
602
|
+
await expect(adapter.listSessions()).resolves.toEqual([]);
|
|
509
603
|
});
|
|
604
|
+
});
|
|
510
605
|
});
|