@ai-devkit/agent-manager 0.42.3 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AgentManager.d.ts +14 -5
- package/dist/AgentManager.d.ts.map +1 -1
- package/dist/AgentManager.js +32 -13
- package/dist/AgentManager.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +9 -4
- package/.swcrc +0 -27
- package/dist/__tests__/AgentManager.test.js +0 -1596
- package/dist/__tests__/AgentManager.test.js.map +0 -1
- package/dist/__tests__/adapters/IncrementalSessionRefresh.test.js +0 -486
- package/dist/__tests__/adapters/IncrementalSessionRefresh.test.js.map +0 -1
- package/dist/__tests__/adapters/adapterProcessImports.test.js +0 -52
- package/dist/__tests__/adapters/adapterProcessImports.test.js.map +0 -1
- package/dist/__tests__/adapters/adapterSnapshotCandidates.test.js +0 -247
- package/dist/__tests__/adapters/adapterSnapshotCandidates.test.js.map +0 -1
- package/dist/__tests__/capacity/anthropic.test.js +0 -115
- package/dist/__tests__/capacity/anthropic.test.js.map +0 -1
- package/dist/__tests__/capacity/boundaries.test.js +0 -45
- package/dist/__tests__/capacity/boundaries.test.js.map +0 -1
- package/dist/__tests__/capacity/claude.test.js +0 -485
- package/dist/__tests__/capacity/claude.test.js.map +0 -1
- package/dist/__tests__/capacity/codex.test.js +0 -339
- package/dist/__tests__/capacity/codex.test.js.map +0 -1
- package/dist/__tests__/capacity/devin.test.js +0 -239
- package/dist/__tests__/capacity/devin.test.js.map +0 -1
- package/dist/__tests__/capacity/index.test.js +0 -53
- package/dist/__tests__/capacity/index.test.js.map +0 -1
- package/dist/__tests__/capacity/openai.test.js +0 -687
- package/dist/__tests__/capacity/openai.test.js.map +0 -1
- package/dist/__tests__/capacity/wham.test.js +0 -159
- package/dist/__tests__/capacity/wham.test.js.map +0 -1
- package/dist/__tests__/capacity/zai.test.js +0 -212
- package/dist/__tests__/capacity/zai.test.js.map +0 -1
- package/dist/__tests__/fixtures.test.js +0 -218
- package/dist/__tests__/fixtures.test.js.map +0 -1
- package/dist/__tests__/harnesses/BoundedSummarySkip.test.js +0 -568
- package/dist/__tests__/harnesses/BoundedSummarySkip.test.js.map +0 -1
- package/dist/__tests__/harnesses/SessionSummaryEquivalence.test.js +0 -1089
- package/dist/__tests__/harnesses/SessionSummaryEquivalence.test.js.map +0 -1
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.js +0 -143
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.js.map +0 -1
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.js +0 -462
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/builtinAdapters.test.js +0 -33
- package/dist/__tests__/harnesses/builtinAdapters.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeAgentMapper.test.js +0 -79
- package/dist/__tests__/harnesses/claude/ClaudeAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeCodeAdapter.test.js +0 -1881
- package/dist/__tests__/harnesses/claude/ClaudeCodeAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeSessionLocator.test.js +0 -425
- package/dist/__tests__/harnesses/claude/ClaudeSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeSessionParser.test.js +0 -314
- package/dist/__tests__/harnesses/claude/ClaudeSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.js +0 -49
- package/dist/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.js +0 -76
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.js +0 -173
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.js +0 -181
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexAdapter.test.js +0 -685
- package/dist/__tests__/harnesses/codex/CodexAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexSessionLocator.test.js +0 -463
- package/dist/__tests__/harnesses/codex/CodexSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexSessionMapping.test.js +0 -86
- package/dist/__tests__/harnesses/codex/CodexSessionMapping.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexSessionParser.test.js +0 -254
- package/dist/__tests__/harnesses/codex/CodexSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexCliProbe.test.js +0 -121
- package/dist/__tests__/harnesses/codex/durable/CodexCliProbe.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.js +0 -84
- package/dist/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.js +0 -128
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.js +0 -246
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexPrintRunner.test.js +0 -384
- package/dist/__tests__/harnesses/codex/durable/CodexPrintRunner.test.js.map +0 -1
- package/dist/__tests__/harnesses/copilot/CopilotAdapter.test.js +0 -659
- package/dist/__tests__/harnesses/copilot/CopilotAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/copilot/CopilotRefreshIO.test.js +0 -290
- package/dist/__tests__/harnesses/copilot/CopilotRefreshIO.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinAdapter.test.js +0 -597
- package/dist/__tests__/harnesses/devin/DevinAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinAgentMapper.test.js +0 -99
- package/dist/__tests__/harnesses/devin/DevinAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinSessionLocator.test.js +0 -192
- package/dist/__tests__/harnesses/devin/DevinSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinSessionParser.test.js +0 -407
- package/dist/__tests__/harnesses/devin/DevinSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/fixtures.js +0 -95
- package/dist/__tests__/harnesses/devin/fixtures.js.map +0 -1
- package/dist/__tests__/harnesses/gemini/GeminiCliAdapter.test.js +0 -1454
- package/dist/__tests__/harnesses/gemini/GeminiCliAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/gemini/GeminiSessionJsonl.test.js +0 -491
- package/dist/__tests__/harnesses/gemini/GeminiSessionJsonl.test.js.map +0 -1
- package/dist/__tests__/harnesses/gemini/GeminiSessionLocator.test.js +0 -399
- package/dist/__tests__/harnesses/gemini/GeminiSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokAgentMapper.test.js +0 -56
- package/dist/__tests__/harnesses/grok/GrokAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokCliAdapter.test.js +0 -421
- package/dist/__tests__/harnesses/grok/GrokCliAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokIncrementalRefresh.test.js +0 -167
- package/dist/__tests__/harnesses/grok/GrokIncrementalRefresh.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokSessionLocator.test.js +0 -133
- package/dist/__tests__/harnesses/grok/GrokSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokSessionParser.test.js +0 -301
- package/dist/__tests__/harnesses/grok/GrokSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/kiro/KiroAdapter.test.js +0 -662
- package/dist/__tests__/harnesses/kiro/KiroAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseAdapter.test.js +0 -247
- package/dist/__tests__/harnesses/muse/MuseAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseAgentMapper.test.js +0 -81
- package/dist/__tests__/harnesses/muse/MuseAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseSessionLocator.test.js +0 -185
- package/dist/__tests__/harnesses/muse/MuseSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseSessionParser.test.js +0 -328
- package/dist/__tests__/harnesses/muse/MuseSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeAdapter.test.js +0 -213
- package/dist/__tests__/harnesses/opencode/OpenCodeAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.js +0 -108
- package/dist/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.js +0 -94
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionParser.test.js +0 -147
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiAdapter.test.js +0 -367
- package/dist/__tests__/harnesses/pi/PiAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiDiscoveryIO.test.js +0 -382
- package/dist/__tests__/harnesses/pi/PiDiscoveryIO.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiSessionParser.test.js +0 -416
- package/dist/__tests__/harnesses/pi/PiSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiSessionTracker.test.js +0 -108
- package/dist/__tests__/harnesses/pi/PiSessionTracker.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiCliProbe.test.js +0 -70
- package/dist/__tests__/harnesses/pi/durable/PiCliProbe.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.js +0 -43
- package/dist/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiPrintAgentService.test.js +0 -192
- package/dist/__tests__/harnesses/pi/durable/PiPrintAgentService.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiPrintProtocol.test.js +0 -119
- package/dist/__tests__/harnesses/pi/durable/PiPrintProtocol.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiPrintRunner.test.js +0 -382
- package/dist/__tests__/harnesses/pi/durable/PiPrintRunner.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiStreamParser.test.js +0 -34
- package/dist/__tests__/harnesses/pi/durable/PiStreamParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/readiness/AgentReadiness.test.js +0 -446
- package/dist/__tests__/harnesses/readiness/AgentReadiness.test.js.map +0 -1
- package/dist/__tests__/harnesses/runtimeProfiles.test.js +0 -101
- package/dist/__tests__/harnesses/runtimeProfiles.test.js.map +0 -1
- package/dist/__tests__/print/DurableAgent.test.js +0 -15
- package/dist/__tests__/print/DurableAgent.test.js.map +0 -1
- package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js +0 -186
- package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js.map +0 -1
- package/dist/__tests__/print/DurableAgentRepository.test.js +0 -249
- package/dist/__tests__/print/DurableAgentRepository.test.js.map +0 -1
- package/dist/__tests__/readiness-fixtures.test.js +0 -54
- package/dist/__tests__/readiness-fixtures.test.js.map +0 -1
- package/dist/__tests__/runtime/AgentRuntime.test.js +0 -13
- package/dist/__tests__/runtime/AgentRuntime.test.js.map +0 -1
- package/dist/__tests__/runtime/HerdrAgentDiscovery.test.js +0 -164
- package/dist/__tests__/runtime/HerdrAgentDiscovery.test.js.map +0 -1
- package/dist/__tests__/runtime/HerdrAgentRuntime.test.js +0 -488
- package/dist/__tests__/runtime/HerdrAgentRuntime.test.js.map +0 -1
- package/dist/__tests__/runtime/ManagedAgentRuntime.test.js +0 -637
- package/dist/__tests__/runtime/ManagedAgentRuntime.test.js.map +0 -1
- package/dist/__tests__/terminal/GhosttyBackend.test.js +0 -334
- package/dist/__tests__/terminal/GhosttyBackend.test.js.map +0 -1
- package/dist/__tests__/terminal/TerminalFocusManager.test.js +0 -253
- package/dist/__tests__/terminal/TerminalFocusManager.test.js.map +0 -1
- package/dist/__tests__/terminal/TmuxManager.test.js +0 -168
- package/dist/__tests__/terminal/TmuxManager.test.js.map +0 -1
- package/dist/__tests__/terminal/TtyWriter.test.js +0 -386
- package/dist/__tests__/terminal/TtyWriter.test.js.map +0 -1
- package/dist/__tests__/utils/AgentRegistry.test.js +0 -636
- package/dist/__tests__/utils/AgentRegistry.test.js.map +0 -1
- package/dist/__tests__/utils/IncrementalJsonlSummary.test.js +0 -650
- package/dist/__tests__/utils/IncrementalJsonlSummary.test.js.map +0 -1
- package/dist/__tests__/utils/agent-requests.test.js +0 -90
- package/dist/__tests__/utils/agent-requests.test.js.map +0 -1
- package/dist/__tests__/utils/conversationTail.bench.test.js +0 -258
- package/dist/__tests__/utils/conversationTail.bench.test.js.map +0 -1
- package/dist/__tests__/utils/conversationTailParity.test.js +0 -588
- package/dist/__tests__/utils/conversationTailParity.test.js.map +0 -1
- package/dist/__tests__/utils/jsonlTail.test.js +0 -360
- package/dist/__tests__/utils/jsonlTail.test.js.map +0 -1
- package/dist/__tests__/utils/matching.test.js +0 -324
- package/dist/__tests__/utils/matching.test.js.map +0 -1
- package/dist/__tests__/utils/matchingConstants.test.js +0 -35
- package/dist/__tests__/utils/matchingConstants.test.js.map +0 -1
- package/dist/__tests__/utils/process.test.js +0 -818
- package/dist/__tests__/utils/process.test.js.map +0 -1
- package/dist/__tests__/utils/session.test.js +0 -175
- package/dist/__tests__/utils/session.test.js.map +0 -1
- package/project.json +0 -29
- package/scripts/benchmark-cold-start.mjs +0 -350
- package/src/AgentManager.ts +0 -530
- package/src/__tests__/AgentManager.test.ts +0 -1483
- package/src/__tests__/adapters/IncrementalSessionRefresh.test.ts +0 -437
- package/src/__tests__/adapters/adapterProcessImports.test.ts +0 -58
- package/src/__tests__/adapters/adapterSnapshotCandidates.test.ts +0 -243
- package/src/__tests__/capacity/anthropic.test.ts +0 -105
- package/src/__tests__/capacity/boundaries.test.ts +0 -36
- package/src/__tests__/capacity/claude.test.ts +0 -462
- package/src/__tests__/capacity/codex.test.ts +0 -311
- package/src/__tests__/capacity/devin.test.ts +0 -210
- package/src/__tests__/capacity/fixtures/claude-credentials.json +0 -7
- package/src/__tests__/capacity/fixtures/claude-usage-malformed.json +0 -1
- package/src/__tests__/capacity/fixtures/claude-usage-partial.json +0 -15
- package/src/__tests__/capacity/fixtures/claude-usage.json +0 -63
- package/src/__tests__/capacity/fixtures/devin-config.json +0 -6
- package/src/__tests__/capacity/fixtures/devin-credentials.toml +0 -4
- package/src/__tests__/capacity/fixtures/devin-quota-nonplan.json +0 -5
- package/src/__tests__/capacity/fixtures/devin-quota.json +0 -10
- package/src/__tests__/capacity/fixtures/openai-auth.json +0 -6
- package/src/__tests__/capacity/fixtures/openai-codex-auth.json +0 -9
- package/src/__tests__/capacity/fixtures/openai-usage-completions.json +0 -67
- package/src/__tests__/capacity/fixtures/openai-usage-responses.json +0 -20
- package/src/__tests__/capacity/fixtures/wham-usage.json +0 -45
- package/src/__tests__/capacity/fixtures/zai-auth.json +0 -6
- package/src/__tests__/capacity/fixtures/zai-quota-invalid.json +0 -7
- package/src/__tests__/capacity/fixtures/zai-quota.json +0 -38
- package/src/__tests__/capacity/index.test.ts +0 -54
- package/src/__tests__/capacity/openai.test.ts +0 -571
- package/src/__tests__/capacity/wham.test.ts +0 -122
- package/src/__tests__/capacity/zai.test.ts +0 -151
- package/src/__tests__/fixtures.test.ts +0 -245
- package/src/__tests__/harnesses/BoundedSummarySkip.test.ts +0 -496
- package/src/__tests__/harnesses/SessionSummaryEquivalence.test.ts +0 -726
- package/src/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.ts +0 -133
- package/src/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.ts +0 -396
- package/src/__tests__/harnesses/builtinAdapters.test.ts +0 -33
- package/src/__tests__/harnesses/claude/ClaudeAgentMapper.test.ts +0 -84
- package/src/__tests__/harnesses/claude/ClaudeCodeAdapter.test.ts +0 -1793
- package/src/__tests__/harnesses/claude/ClaudeSessionLocator.test.ts +0 -423
- package/src/__tests__/harnesses/claude/ClaudeSessionParser.test.ts +0 -300
- package/src/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.ts +0 -34
- package/src/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.ts +0 -61
- package/src/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.ts +0 -129
- package/src/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.ts +0 -152
- package/src/__tests__/harnesses/codex/CodexAdapter.test.ts +0 -652
- package/src/__tests__/harnesses/codex/CodexSessionLocator.test.ts +0 -419
- package/src/__tests__/harnesses/codex/CodexSessionMapping.test.ts +0 -63
- package/src/__tests__/harnesses/codex/CodexSessionParser.test.ts +0 -192
- package/src/__tests__/harnesses/codex/durable/CodexCliProbe.test.ts +0 -80
- package/src/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.ts +0 -65
- package/src/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.ts +0 -104
- package/src/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.ts +0 -201
- package/src/__tests__/harnesses/codex/durable/CodexPrintRunner.test.ts +0 -299
- package/src/__tests__/harnesses/copilot/CopilotAdapter.test.ts +0 -614
- package/src/__tests__/harnesses/copilot/CopilotRefreshIO.test.ts +0 -270
- package/src/__tests__/harnesses/devin/DevinAdapter.test.ts +0 -290
- package/src/__tests__/harnesses/devin/DevinAgentMapper.test.ts +0 -101
- package/src/__tests__/harnesses/devin/DevinSessionLocator.test.ts +0 -139
- package/src/__tests__/harnesses/devin/DevinSessionParser.test.ts +0 -212
- package/src/__tests__/harnesses/devin/fixtures.ts +0 -144
- package/src/__tests__/harnesses/gemini/GeminiCliAdapter.test.ts +0 -1336
- package/src/__tests__/harnesses/gemini/GeminiSessionJsonl.test.ts +0 -402
- package/src/__tests__/harnesses/gemini/GeminiSessionLocator.test.ts +0 -396
- package/src/__tests__/harnesses/grok/GrokAgentMapper.test.ts +0 -57
- package/src/__tests__/harnesses/grok/GrokCliAdapter.test.ts +0 -376
- package/src/__tests__/harnesses/grok/GrokIncrementalRefresh.test.ts +0 -170
- package/src/__tests__/harnesses/grok/GrokSessionLocator.test.ts +0 -106
- package/src/__tests__/harnesses/grok/GrokSessionParser.test.ts +0 -230
- package/src/__tests__/harnesses/kiro/KiroAdapter.test.ts +0 -552
- package/src/__tests__/harnesses/muse/MuseAdapter.test.ts +0 -197
- package/src/__tests__/harnesses/muse/MuseAgentMapper.test.ts +0 -83
- package/src/__tests__/harnesses/muse/MuseSessionLocator.test.ts +0 -177
- package/src/__tests__/harnesses/muse/MuseSessionParser.test.ts +0 -279
- package/src/__tests__/harnesses/opencode/OpenCodeAdapter.test.ts +0 -215
- package/src/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.ts +0 -101
- package/src/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.ts +0 -84
- package/src/__tests__/harnesses/opencode/OpenCodeSessionParser.test.ts +0 -149
- package/src/__tests__/harnesses/pi/PiAdapter.test.ts +0 -325
- package/src/__tests__/harnesses/pi/PiDiscoveryIO.test.ts +0 -337
- package/src/__tests__/harnesses/pi/PiSessionParser.test.ts +0 -280
- package/src/__tests__/harnesses/pi/PiSessionTracker.test.ts +0 -79
- package/src/__tests__/harnesses/pi/durable/PiCliProbe.test.ts +0 -50
- package/src/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.ts +0 -33
- package/src/__tests__/harnesses/pi/durable/PiPrintAgentService.test.ts +0 -138
- package/src/__tests__/harnesses/pi/durable/PiPrintProtocol.test.ts +0 -71
- package/src/__tests__/harnesses/pi/durable/PiPrintRunner.test.ts +0 -252
- package/src/__tests__/harnesses/pi/durable/PiStreamParser.test.ts +0 -26
- package/src/__tests__/harnesses/readiness/AgentReadiness.test.ts +0 -362
- package/src/__tests__/harnesses/runtimeProfiles.test.ts +0 -123
- package/src/__tests__/print/DurableAgent.test.ts +0 -15
- package/src/__tests__/print/DurableAgentRepository.sqlite.test.ts +0 -128
- package/src/__tests__/print/DurableAgentRepository.test.ts +0 -184
- package/src/__tests__/readiness-fixtures.test.ts +0 -79
- package/src/__tests__/runtime/AgentRuntime.test.ts +0 -8
- package/src/__tests__/runtime/HerdrAgentDiscovery.test.ts +0 -131
- package/src/__tests__/runtime/HerdrAgentRuntime.test.ts +0 -377
- package/src/__tests__/runtime/ManagedAgentRuntime.test.ts +0 -590
- package/src/__tests__/terminal/GhosttyBackend.test.ts +0 -271
- package/src/__tests__/terminal/TerminalFocusManager.test.ts +0 -280
- package/src/__tests__/terminal/TmuxManager.test.ts +0 -185
- package/src/__tests__/terminal/TtyWriter.test.ts +0 -454
- package/src/__tests__/utils/AgentRegistry.test.ts +0 -532
- package/src/__tests__/utils/IncrementalJsonlSummary.test.ts +0 -414
- package/src/__tests__/utils/agent-requests.test.ts +0 -94
- package/src/__tests__/utils/conversationTail.bench.test.ts +0 -193
- package/src/__tests__/utils/conversationTailParity.test.ts +0 -365
- package/src/__tests__/utils/jsonlTail.test.ts +0 -317
- package/src/__tests__/utils/matching.test.ts +0 -234
- package/src/__tests__/utils/matchingConstants.test.ts +0 -40
- package/src/__tests__/utils/process.test.ts +0 -596
- package/src/__tests__/utils/session.test.ts +0 -158
- package/src/adapters/AgentAdapter.ts +0 -255
- package/src/capacity/index.ts +0 -127
- package/src/capacity/providers/anthropic.ts +0 -198
- package/src/capacity/providers/devin.ts +0 -121
- package/src/capacity/providers/openai-platform.ts +0 -150
- package/src/capacity/providers/openai-subscription.ts +0 -184
- package/src/capacity/providers/zai.ts +0 -155
- package/src/capacity/sources/claude.ts +0 -30
- package/src/capacity/sources/codex.ts +0 -251
- package/src/capacity/sources/devin.ts +0 -49
- package/src/capacity/sources/pi.ts +0 -131
- package/src/capacity/types.ts +0 -29
- package/src/database/connection.ts +0 -96
- package/src/database/index.ts +0 -7
- package/src/database/migrations/001_initial.sql +0 -12
- package/src/database/migrations/002_pins.sql +0 -1
- package/src/database/migrations/003_durable_agents.sql +0 -43
- package/src/database/migrations/004_codex_durable_sessions.sql +0 -1
- package/src/database/migrations/005_agent_runtime.sql +0 -2
- package/src/database/schema.ts +0 -64
- package/src/durable/DurableAgent.ts +0 -139
- package/src/durable/DurableAgentRepository.ts +0 -485
- package/src/durable/process.ts +0 -29
- package/src/durable/run.ts +0 -84
- package/src/durable/utils.ts +0 -66
- package/src/fixtures/bundle.ts +0 -130
- package/src/fixtures/capture.ts +0 -364
- package/src/harnesses/antigravity/AntigravityAgentMapper.ts +0 -34
- package/src/harnesses/antigravity/AntigravityCliAdapter.ts +0 -126
- package/src/harnesses/antigravity/AntigravitySessionLocator.ts +0 -75
- package/src/harnesses/antigravity/AntigravitySessionParser.ts +0 -252
- package/src/harnesses/claude/ClaudeAgentMapper.ts +0 -55
- package/src/harnesses/claude/ClaudeCodeAdapter.ts +0 -175
- package/src/harnesses/claude/ClaudeSessionLocator.ts +0 -358
- package/src/harnesses/claude/ClaudeSessionParser.ts +0 -524
- package/src/harnesses/claude/credentials.ts +0 -122
- package/src/harnesses/claude/durable/ClaudeCliProbe.ts +0 -57
- package/src/harnesses/claude/durable/ClaudePrintAgentService.ts +0 -79
- package/src/harnesses/claude/durable/ClaudePrintRunner.ts +0 -102
- package/src/harnesses/claude/durable/ClaudeStreamParser.ts +0 -108
- package/src/harnesses/claude/readiness.ts +0 -69
- package/src/harnesses/codex/CodexAdapter.ts +0 -337
- package/src/harnesses/codex/CodexAgentMapper.ts +0 -26
- package/src/harnesses/codex/CodexSessionLocator.ts +0 -509
- package/src/harnesses/codex/CodexSessionMapping.ts +0 -89
- package/src/harnesses/codex/CodexSessionParser.ts +0 -462
- package/src/harnesses/codex/credentials.ts +0 -81
- package/src/harnesses/codex/durable/CodexCliProbe.ts +0 -68
- package/src/harnesses/codex/durable/CodexPrintAgentService.ts +0 -79
- package/src/harnesses/codex/durable/CodexPrintRunner.ts +0 -104
- package/src/harnesses/codex/durable/CodexStreamParser.ts +0 -117
- package/src/harnesses/codex/readiness.ts +0 -72
- package/src/harnesses/copilot/CopilotAdapter.ts +0 -161
- package/src/harnesses/copilot/CopilotAgentMapper.ts +0 -27
- package/src/harnesses/copilot/CopilotSessionLocator.ts +0 -161
- package/src/harnesses/copilot/CopilotSessionParser.ts +0 -380
- package/src/harnesses/copilot/readiness.ts +0 -33
- package/src/harnesses/devin/DevinAdapter.ts +0 -212
- package/src/harnesses/devin/DevinAgentMapper.ts +0 -39
- package/src/harnesses/devin/DevinSessionLocator.ts +0 -230
- package/src/harnesses/devin/DevinSessionParser.ts +0 -227
- package/src/harnesses/devin/credentials.ts +0 -88
- package/src/harnesses/devin/readiness.ts +0 -36
- package/src/harnesses/gemini/GeminiAgentMapper.ts +0 -27
- package/src/harnesses/gemini/GeminiCliAdapter.ts +0 -272
- package/src/harnesses/gemini/GeminiSessionLocator.ts +0 -394
- package/src/harnesses/gemini/GeminiSessionParser.ts +0 -395
- package/src/harnesses/gemini/fileSignature.ts +0 -10
- package/src/harnesses/grok/GrokAgentMapper.ts +0 -32
- package/src/harnesses/grok/GrokCliAdapter.ts +0 -126
- package/src/harnesses/grok/GrokSessionLocator.ts +0 -179
- package/src/harnesses/grok/GrokSessionParser.ts +0 -251
- package/src/harnesses/index.ts +0 -32
- package/src/harnesses/kiro/KiroAdapter.ts +0 -143
- package/src/harnesses/kiro/KiroAgentMapper.ts +0 -34
- package/src/harnesses/kiro/KiroSessionLocator.ts +0 -143
- package/src/harnesses/kiro/KiroSessionParser.ts +0 -376
- package/src/harnesses/muse/MuseAdapter.ts +0 -157
- package/src/harnesses/muse/MuseAgentMapper.ts +0 -33
- package/src/harnesses/muse/MuseSessionLocator.ts +0 -286
- package/src/harnesses/muse/MuseSessionParser.ts +0 -435
- package/src/harnesses/muse/readiness.ts +0 -38
- package/src/harnesses/opencode/OpenCodeAdapter.ts +0 -110
- package/src/harnesses/opencode/OpenCodeAgentMapper.ts +0 -49
- package/src/harnesses/opencode/OpenCodeSessionLocator.ts +0 -151
- package/src/harnesses/opencode/OpenCodeSessionParser.ts +0 -146
- package/src/harnesses/opencode/readiness.ts +0 -48
- package/src/harnesses/pi/PiAdapter.ts +0 -197
- package/src/harnesses/pi/PiAgentMapper.ts +0 -27
- package/src/harnesses/pi/PiSessionLocator.ts +0 -288
- package/src/harnesses/pi/PiSessionParser.ts +0 -488
- package/src/harnesses/pi/PiSessionTracker.ts +0 -87
- package/src/harnesses/pi/credentials.ts +0 -129
- package/src/harnesses/pi/durable/PiCliProbe.ts +0 -56
- package/src/harnesses/pi/durable/PiPrintAgentService.ts +0 -77
- package/src/harnesses/pi/durable/PiPrintProtocol.ts +0 -41
- package/src/harnesses/pi/durable/PiPrintRunner.ts +0 -95
- package/src/harnesses/pi/durable/PiStreamParser.ts +0 -94
- package/src/harnesses/pi/readiness.ts +0 -104
- package/src/harnesses/readiness/AgentReadiness.ts +0 -91
- package/src/harnesses/readiness/checks.ts +0 -336
- package/src/harnesses/readiness/types.ts +0 -90
- package/src/harnesses/runtimeProfiles.ts +0 -105
- package/src/harnesses/shared.ts +0 -124
- package/src/index.ts +0 -70
- package/src/runtime/ManagedAgentRuntime.ts +0 -253
- package/src/runtime/RuntimeFactory.ts +0 -13
- package/src/runtime/errors.ts +0 -50
- package/src/runtime/herdr/HerdrAgentDiscovery.ts +0 -166
- package/src/runtime/herdr/HerdrAgentRuntime.ts +0 -216
- package/src/runtime/herdr/HerdrCliClient.ts +0 -78
- package/src/runtime/herdr/HerdrErrors.ts +0 -9
- package/src/runtime/herdr/HerdrResponseParsers.ts +0 -86
- package/src/runtime/herdr/HerdrRuntimeRef.ts +0 -41
- package/src/runtime/tmux/PidPolling.ts +0 -34
- package/src/runtime/tmux/TmuxAgentRuntime.ts +0 -113
- package/src/runtime/tmux/TmuxManager.ts +0 -102
- package/src/runtime/tmux/TmuxRuntimeRef.ts +0 -9
- package/src/runtime/types.ts +0 -56
- package/src/terminal/TerminalFocusManager.ts +0 -52
- package/src/terminal/TtyWriter.ts +0 -26
- package/src/terminal/backends/ghostty.ts +0 -180
- package/src/terminal/backends/index.ts +0 -23
- package/src/terminal/backends/iterm2.ts +0 -126
- package/src/terminal/backends/shared.ts +0 -47
- package/src/terminal/backends/terminal-app.ts +0 -122
- package/src/terminal/backends/tmux.ts +0 -62
- package/src/terminal/backends/wezterm.ts +0 -65
- package/src/terminal/types.ts +0 -23
- package/src/utils/AgentRegistry.ts +0 -351
- package/src/utils/IncrementalJsonlSummary.ts +0 -306
- package/src/utils/agent-requests.ts +0 -28
- package/src/utils/applescript.ts +0 -10
- package/src/utils/jsonlTail.ts +0 -349
- package/src/utils/matching.ts +0 -96
- package/src/utils/matchingConstants.ts +0 -15
- package/src/utils/process.ts +0 -604
- package/src/utils/session.ts +0 -144
- package/src/utils/sortAgents.ts +0 -54
- package/tsconfig.json +0 -11
- package/vitest.config.ts +0 -20
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
import { execFile } from "child_process";
|
|
2
|
-
import { writeFile } from "fs/promises";
|
|
3
|
-
import type { Mock } from "vitest";
|
|
4
|
-
|
|
5
|
-
import { ghosttyBackend } from "../../terminal/backends/ghostty.js";
|
|
6
|
-
import { TerminalType, type TerminalLocation } from "../../terminal/types.js";
|
|
7
|
-
import { TtyWriter } from "../../terminal/TtyWriter.js";
|
|
8
|
-
import { getProcessCwdsAsync } from "../../utils/process.js";
|
|
9
|
-
|
|
10
|
-
vi.mock("child_process", async () => {
|
|
11
|
-
const actual = await vi.importActual<typeof import("child_process")>("child_process");
|
|
12
|
-
return { ...actual, execFile: vi.fn() };
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
vi.mock("fs/promises", async () => {
|
|
16
|
-
const actual = await vi.importActual<typeof import("fs/promises")>("fs/promises");
|
|
17
|
-
return { ...actual, writeFile: vi.fn() };
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
vi.mock("../../utils/process.js", async () => {
|
|
21
|
-
const actual =
|
|
22
|
-
await vi.importActual<typeof import("../../utils/process.js")>("../../utils/process.js");
|
|
23
|
-
return { ...actual, getProcessCwdsAsync: vi.fn() };
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const mockedExecFile = execFile as unknown as Mock;
|
|
27
|
-
const mockedGetProcessCwds = getProcessCwdsAsync as unknown as Mock;
|
|
28
|
-
const mockedWriteFile = writeFile as unknown as Mock;
|
|
29
|
-
const SEP = "\x1f";
|
|
30
|
-
|
|
31
|
-
interface FakeTerminal {
|
|
32
|
-
id: string;
|
|
33
|
-
name: string;
|
|
34
|
-
dir: string;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Fake `ps`, process cwds and Ghostty AppleScript. `processes` rows are
|
|
39
|
-
* `pid ppid tty comm`; `cwds` maps pid to its working directory. Writing an
|
|
40
|
-
* OSC 2 title to a TTY renames the terminal listed in `ttyOwner`.
|
|
41
|
-
*/
|
|
42
|
-
function fakeSystem(opts: {
|
|
43
|
-
processes: string[];
|
|
44
|
-
cwds?: Record<number, string>;
|
|
45
|
-
terminals: FakeTerminal[];
|
|
46
|
-
ttyOwner?: Record<string, string>;
|
|
47
|
-
osascriptResult?: string;
|
|
48
|
-
}) {
|
|
49
|
-
const terminals = opts.terminals.map((t) => ({ ...t }));
|
|
50
|
-
mockedGetProcessCwds.mockImplementation(async (pids: number[]) => {
|
|
51
|
-
const cwds = new Map<number, string>();
|
|
52
|
-
for (const pid of pids) if (opts.cwds?.[pid]) cwds.set(pid, opts.cwds[pid]);
|
|
53
|
-
return cwds;
|
|
54
|
-
});
|
|
55
|
-
mockedWriteFile.mockImplementation(async (tty: string, data: string) => {
|
|
56
|
-
// eslint-disable-next-line no-control-regex
|
|
57
|
-
const title = /^\x1b\]2;(.*)\x07$/.exec(data)?.[1];
|
|
58
|
-
const owner = terminals.find((t) => t.id === opts.ttyOwner?.[tty]);
|
|
59
|
-
if (owner && title !== undefined) owner.name = title;
|
|
60
|
-
});
|
|
61
|
-
mockedExecFile.mockImplementation((...args: unknown[]) => {
|
|
62
|
-
const [cmd, argv] = args as [string, string[]];
|
|
63
|
-
const cb = args[args.length - 1] as (err: Error | null, r?: { stdout: string }) => void;
|
|
64
|
-
let stdout = "";
|
|
65
|
-
if (cmd === "ps") stdout = opts.processes.join("\n") + "\n";
|
|
66
|
-
else if (cmd === "osascript" && argv[1].includes("repeat with t in terminals")) {
|
|
67
|
-
stdout = terminals.map((t) => [t.id, t.name, t.dir].join(SEP)).join("\n") + "\n";
|
|
68
|
-
} else if (cmd === "osascript") stdout = opts.osascriptResult ?? "ok\n";
|
|
69
|
-
cb(null, { stdout });
|
|
70
|
-
return {};
|
|
71
|
-
});
|
|
72
|
-
return terminals;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const GHOSTTY = "500 1 ?? /Applications/Ghostty.app/Contents/MacOS/ghostty";
|
|
76
|
-
|
|
77
|
-
describe("Ghostty terminal backend", () => {
|
|
78
|
-
beforeEach(() => {
|
|
79
|
-
vi.clearAllMocks();
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
describe("find", () => {
|
|
83
|
-
it("ignores TTYs when Ghostty is not running", async () => {
|
|
84
|
-
fakeSystem({ processes: ["600 1 ttys001 /usr/bin/login"], terminals: [] });
|
|
85
|
-
|
|
86
|
-
expect(await ghosttyBackend.find("/dev/ttys001")).toBeNull();
|
|
87
|
-
expect(mockedExecFile).not.toHaveBeenCalledWith(
|
|
88
|
-
"osascript",
|
|
89
|
-
expect.anything(),
|
|
90
|
-
expect.anything(),
|
|
91
|
-
);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it("ignores TTYs whose session was not started by Ghostty", async () => {
|
|
95
|
-
fakeSystem({
|
|
96
|
-
processes: [GHOSTTY, "600 500 ttys001 /usr/bin/login", "700 1 ttys002 /usr/bin/login"],
|
|
97
|
-
terminals: [{ id: "T1", name: "zsh", dir: "/repo" }],
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
expect(await ghosttyBackend.find("/dev/ttys002")).toBeNull();
|
|
101
|
-
expect(mockedWriteFile).not.toHaveBeenCalled();
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it("matches by working directory when it pairs one terminal with one TTY", async () => {
|
|
105
|
-
fakeSystem({
|
|
106
|
-
processes: [
|
|
107
|
-
GHOSTTY,
|
|
108
|
-
"600 500 ttys001 /usr/bin/login",
|
|
109
|
-
"601 600 ttys001 -zsh",
|
|
110
|
-
"602 601 ttys001 claude",
|
|
111
|
-
"700 500 ttys002 /usr/bin/login",
|
|
112
|
-
"701 700 ttys002 -zsh",
|
|
113
|
-
],
|
|
114
|
-
cwds: { 601: "/repo/a", 602: "/repo/a", 701: "/repo/b" },
|
|
115
|
-
terminals: [
|
|
116
|
-
{ id: "T1", name: "claude", dir: "/repo/a" },
|
|
117
|
-
{ id: "T2", name: "zsh", dir: "/repo/b" },
|
|
118
|
-
],
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
expect(await ghosttyBackend.find("/dev/ttys001")).toEqual({
|
|
122
|
-
type: TerminalType.GHOSTTY,
|
|
123
|
-
identifier: "T1",
|
|
124
|
-
tty: "/dev/ttys001",
|
|
125
|
-
});
|
|
126
|
-
expect(mockedWriteFile).not.toHaveBeenCalled();
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it("uses a title marker when two terminals share the directory, then restores the title", async () => {
|
|
130
|
-
const terminals = fakeSystem({
|
|
131
|
-
processes: [
|
|
132
|
-
GHOSTTY,
|
|
133
|
-
"600 500 ttys001 /usr/bin/login",
|
|
134
|
-
"601 600 ttys001 claude",
|
|
135
|
-
"700 500 ttys002 /usr/bin/login",
|
|
136
|
-
"701 700 ttys002 codex",
|
|
137
|
-
],
|
|
138
|
-
cwds: { 601: "/repo", 701: "/repo" },
|
|
139
|
-
terminals: [
|
|
140
|
-
{ id: "T1", name: "first agent", dir: "/repo" },
|
|
141
|
-
{ id: "T2", name: "second agent", dir: "/repo" },
|
|
142
|
-
],
|
|
143
|
-
ttyOwner: { "/dev/ttys001": "T1", "/dev/ttys002": "T2" },
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
const location = await ghosttyBackend.find("/dev/ttys002");
|
|
147
|
-
|
|
148
|
-
expect(location?.identifier).toBe("T2");
|
|
149
|
-
const titles = mockedWriteFile.mock.calls.map(([tty, data]) => [tty, data]);
|
|
150
|
-
expect(titles).toHaveLength(2);
|
|
151
|
-
expect(titles[0][0]).toBe("/dev/ttys002");
|
|
152
|
-
// eslint-disable-next-line no-control-regex
|
|
153
|
-
expect(titles[0][1]).toMatch(/^\x1b\]2;ai-devkit-\d+-\d+\x07$/);
|
|
154
|
-
expect(titles[1]).toEqual(["/dev/ttys002", "\x1b]2;second agent\x07"]);
|
|
155
|
-
expect(terminals.find((t) => t.id === "T2")?.name).toBe("second agent");
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it("does not trust a unique directory match when another Ghostty TTY has a process there", async () => {
|
|
159
|
-
// T1's own working directory is unreported; T2 sits in the agent's directory.
|
|
160
|
-
fakeSystem({
|
|
161
|
-
processes: [
|
|
162
|
-
GHOSTTY,
|
|
163
|
-
"600 500 ttys001 /usr/bin/login",
|
|
164
|
-
"601 600 ttys001 claude",
|
|
165
|
-
"700 500 ttys002 /usr/bin/login",
|
|
166
|
-
"701 700 ttys002 -zsh",
|
|
167
|
-
],
|
|
168
|
-
cwds: { 601: "/repo", 701: "/repo" },
|
|
169
|
-
terminals: [
|
|
170
|
-
{ id: "T1", name: "claude", dir: "" },
|
|
171
|
-
{ id: "T2", name: "zsh", dir: "/repo" },
|
|
172
|
-
],
|
|
173
|
-
ttyOwner: { "/dev/ttys001": "T1", "/dev/ttys002": "T2" },
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
expect((await ghosttyBackend.find("/dev/ttys001"))?.identifier).toBe("T1");
|
|
177
|
-
expect(mockedWriteFile).toHaveBeenCalled();
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it("returns null when no terminal shows the marker", async () => {
|
|
181
|
-
vi.useFakeTimers();
|
|
182
|
-
try {
|
|
183
|
-
fakeSystem({
|
|
184
|
-
processes: [GHOSTTY, "600 500 ttys001 /usr/bin/login"],
|
|
185
|
-
terminals: [
|
|
186
|
-
{ id: "T1", name: "a", dir: "/x" },
|
|
187
|
-
{ id: "T2", name: "b", dir: "/y" },
|
|
188
|
-
],
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
const result = ghosttyBackend.find("/dev/ttys001");
|
|
192
|
-
await vi.runAllTimersAsync();
|
|
193
|
-
|
|
194
|
-
expect(await result).toBeNull();
|
|
195
|
-
} finally {
|
|
196
|
-
vi.useRealTimers();
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
it("returns null instead of throwing when Ghostty is not scriptable", async () => {
|
|
201
|
-
mockedGetProcessCwds.mockResolvedValue(new Map());
|
|
202
|
-
mockedExecFile.mockImplementation((...args: unknown[]) => {
|
|
203
|
-
const [cmd] = args as [string];
|
|
204
|
-
const cb = args[args.length - 1] as (err: Error | null, r?: { stdout: string }) => void;
|
|
205
|
-
if (cmd === "osascript") cb(new Error("Not authorized to send Apple events"));
|
|
206
|
-
else cb(null, { stdout: `${GHOSTTY}\n600 500 ttys001 /usr/bin/login\n` });
|
|
207
|
-
return {};
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
expect(await ghosttyBackend.find("/dev/ttys001")).toBeNull();
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
describe("focus, send and sendKey", () => {
|
|
215
|
-
const location: TerminalLocation = {
|
|
216
|
-
type: TerminalType.GHOSTTY,
|
|
217
|
-
identifier: "T1",
|
|
218
|
-
tty: "/dev/ttys001",
|
|
219
|
-
};
|
|
220
|
-
const scripts = () =>
|
|
221
|
-
mockedExecFile.mock.calls.filter(([cmd]) => cmd === "osascript").map(([, argv]) => argv[1]);
|
|
222
|
-
|
|
223
|
-
it("focuses the terminal by id and activates Ghostty", async () => {
|
|
224
|
-
fakeSystem({ processes: [], terminals: [] });
|
|
225
|
-
|
|
226
|
-
expect(await ghosttyBackend.focus(location)).toBe(true);
|
|
227
|
-
expect(scripts()[0]).toContain('every terminal whose id is "T1"');
|
|
228
|
-
expect(scripts()[0]).toContain("focus t");
|
|
229
|
-
expect(scripts()[0]).toContain("activate");
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
it("reports a failed focus when the terminal is gone", async () => {
|
|
233
|
-
fakeSystem({ processes: [], terminals: [], osascriptResult: "not_found\n" });
|
|
234
|
-
|
|
235
|
-
expect(await ghosttyBackend.focus(location)).toBe(false);
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
it("pastes the message with input text, then types a carriage return", async () => {
|
|
239
|
-
fakeSystem({ processes: [], terminals: [] });
|
|
240
|
-
|
|
241
|
-
await TtyWriter.send(location, 'say "hi"\nnext');
|
|
242
|
-
|
|
243
|
-
expect(scripts()).toHaveLength(2);
|
|
244
|
-
expect(scripts()[0]).toContain('input text "say \\"hi\\"\\nnext" to t');
|
|
245
|
-
expect(scripts()[1]).toContain('perform action "text:\\\\x0d" on t');
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
it("throws when the terminal is gone", async () => {
|
|
249
|
-
fakeSystem({ processes: [], terminals: [], osascriptResult: "not_found\n" });
|
|
250
|
-
|
|
251
|
-
await expect(TtyWriter.send(location, "hello")).rejects.toThrow(
|
|
252
|
-
"Ghostty terminal not found for TTY /dev/ttys001",
|
|
253
|
-
);
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
// Ghostty parses `text:` with Zig escapes; AppleScript doubles each backslash.
|
|
257
|
-
it.each([
|
|
258
|
-
["2", "text:2"],
|
|
259
|
-
["\x1b", "text:\\\\x1b"],
|
|
260
|
-
["\r", "text:\\\\x0d"],
|
|
261
|
-
["\\", "text:\\\\\\\\"],
|
|
262
|
-
])("types key %j with the Ghostty action %s", async (key, action) => {
|
|
263
|
-
fakeSystem({ processes: [], terminals: [] });
|
|
264
|
-
|
|
265
|
-
await TtyWriter.sendKey(location, key);
|
|
266
|
-
|
|
267
|
-
expect(scripts()[0]).toContain(`perform action "${action}" on t`);
|
|
268
|
-
expect(scripts()[0]).not.toContain("send key");
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
});
|
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
import { execFile } from "child_process";
|
|
2
|
-
import type { MockedFunction } from "vitest";
|
|
3
|
-
|
|
4
|
-
import { TerminalFocusManager, TerminalType } from "../../terminal/TerminalFocusManager.js";
|
|
5
|
-
import type { TerminalLocation } from "../../terminal/TerminalFocusManager.js";
|
|
6
|
-
import { getProcessTty } from "../../utils/process.js";
|
|
7
|
-
|
|
8
|
-
vi.mock("child_process", () => ({
|
|
9
|
-
execFile: vi.fn(),
|
|
10
|
-
}));
|
|
11
|
-
|
|
12
|
-
vi.mock("../../utils/process.js", async () => {
|
|
13
|
-
const actual =
|
|
14
|
-
await vi.importActual<typeof import("../../utils/process.js")>("../../utils/process.js");
|
|
15
|
-
return {
|
|
16
|
-
...actual,
|
|
17
|
-
getProcessTty: vi.fn(),
|
|
18
|
-
};
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
type ExecFileCb = (err: Error | null, result?: { stdout: string; stderr: string }) => void;
|
|
22
|
-
const mockedExecFile = execFile as unknown as MockedFunction<
|
|
23
|
-
(cmd: string, args: string[], cb: ExecFileCb) => void
|
|
24
|
-
>;
|
|
25
|
-
const mockedGetProcessTty = getProcessTty as MockedFunction<typeof getProcessTty>;
|
|
26
|
-
|
|
27
|
-
function setExecFileHandler(handler: (cmd: string, args: string[]) => string | Error) {
|
|
28
|
-
mockedExecFile.mockImplementation((cmd, args, cb) => {
|
|
29
|
-
const result = handler(cmd, args);
|
|
30
|
-
if (result instanceof Error) cb(result);
|
|
31
|
-
else cb(null, { stdout: result, stderr: "" });
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
describe("TerminalFocusManager", () => {
|
|
36
|
-
beforeEach(() => {
|
|
37
|
-
mockedExecFile.mockReset();
|
|
38
|
-
mockedGetProcessTty.mockReset();
|
|
39
|
-
mockedGetProcessTty.mockReturnValue("ttys000");
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("finds iTerm2 when the process is listed by full app binary path", async () => {
|
|
43
|
-
setExecFileHandler((cmd, args) => {
|
|
44
|
-
if (cmd === "tmux") return new Error("tmux not running");
|
|
45
|
-
if (cmd === "pgrep") return new Error("pgrep did not match GUI app");
|
|
46
|
-
if (cmd === "ps" && args.join(" ") === "-Axo comm") {
|
|
47
|
-
return "/Applications/iTerm.app/Contents/MacOS/iTerm2\n";
|
|
48
|
-
}
|
|
49
|
-
if (cmd === "osascript") return "found\n";
|
|
50
|
-
return "";
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const location = await new TerminalFocusManager().findTerminal(123);
|
|
54
|
-
|
|
55
|
-
expect(location).toEqual({
|
|
56
|
-
type: TerminalType.ITERM2,
|
|
57
|
-
identifier: "/dev/ttys000",
|
|
58
|
-
tty: "/dev/ttys000",
|
|
59
|
-
});
|
|
60
|
-
expect(mockedExecFile).not.toHaveBeenCalledWith(
|
|
61
|
-
"pgrep",
|
|
62
|
-
expect.any(Array),
|
|
63
|
-
expect.any(Function),
|
|
64
|
-
);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
describe("WezTerm", () => {
|
|
68
|
-
const listArgs = ["cli", "list", "--format", "json"];
|
|
69
|
-
|
|
70
|
-
it("finds the WezTerm pane whose tty_name matches the agent tty", async () => {
|
|
71
|
-
setExecFileHandler((cmd, args) => {
|
|
72
|
-
if (cmd === "tmux") return new Error("tmux not running");
|
|
73
|
-
if (cmd === "wezterm" && args.join(" ") === listArgs.join(" ")) {
|
|
74
|
-
return JSON.stringify([
|
|
75
|
-
{ pane_id: 3, tty_name: "/dev/ttys099", cwd: "/x" },
|
|
76
|
-
{ pane_id: 7, tty_name: "/dev/ttys000", cwd: "/y" },
|
|
77
|
-
]);
|
|
78
|
-
}
|
|
79
|
-
return "";
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
const location = await new TerminalFocusManager().findTerminal(123);
|
|
83
|
-
|
|
84
|
-
expect(location).toEqual({
|
|
85
|
-
type: TerminalType.WEZTERM,
|
|
86
|
-
identifier: "7",
|
|
87
|
-
tty: "/dev/ttys000",
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("skips the macOS AppleScript probes when WezTerm matches", async () => {
|
|
92
|
-
setExecFileHandler((cmd) => {
|
|
93
|
-
if (cmd === "tmux") return new Error("tmux not running");
|
|
94
|
-
if (cmd === "wezterm") {
|
|
95
|
-
return JSON.stringify([{ pane_id: 7, tty_name: "/dev/ttys000" }]);
|
|
96
|
-
}
|
|
97
|
-
return "";
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
await new TerminalFocusManager().findTerminal(123);
|
|
101
|
-
|
|
102
|
-
expect(mockedExecFile).not.toHaveBeenCalledWith(
|
|
103
|
-
"osascript",
|
|
104
|
-
expect.any(Array),
|
|
105
|
-
expect.any(Function),
|
|
106
|
-
);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it("returns UNKNOWN when WezTerm is installed but no pane matches the tty", async () => {
|
|
110
|
-
setExecFileHandler((cmd) => {
|
|
111
|
-
if (cmd === "tmux") return new Error("tmux not running");
|
|
112
|
-
if (cmd === "wezterm") {
|
|
113
|
-
return JSON.stringify([{ pane_id: 7, tty_name: "/dev/ttys099" }]);
|
|
114
|
-
}
|
|
115
|
-
return "";
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
const location = await new TerminalFocusManager().findTerminal(123);
|
|
119
|
-
|
|
120
|
-
expect(location?.type).toBe(TerminalType.UNKNOWN);
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it("returns UNKNOWN (without throwing) on malformed JSON from wezterm", async () => {
|
|
124
|
-
setExecFileHandler((cmd) => {
|
|
125
|
-
if (cmd === "tmux") return new Error("tmux not running");
|
|
126
|
-
if (cmd === "wezterm") return "not-json{";
|
|
127
|
-
return "";
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
const location = await new TerminalFocusManager().findTerminal(123);
|
|
131
|
-
|
|
132
|
-
expect(location?.type).toBe(TerminalType.UNKNOWN);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it("returns UNKNOWN when the wezterm binary is missing", async () => {
|
|
136
|
-
setExecFileHandler((cmd) => {
|
|
137
|
-
if (cmd === "tmux") return new Error("tmux not running");
|
|
138
|
-
if (cmd === "wezterm") return new Error("spawn wezterm ENOENT");
|
|
139
|
-
return "";
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
const location = await new TerminalFocusManager().findTerminal(123);
|
|
143
|
-
|
|
144
|
-
expect(location?.type).toBe(TerminalType.UNKNOWN);
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it("prefers tmux over WezTerm (tmux-inside-WezTerm resolves to tmux)", async () => {
|
|
148
|
-
setExecFileHandler((cmd) => {
|
|
149
|
-
if (cmd === "tmux") {
|
|
150
|
-
return `/dev/ttys000|my:0.1`;
|
|
151
|
-
}
|
|
152
|
-
if (cmd === "wezterm") {
|
|
153
|
-
return JSON.stringify([{ pane_id: 7, tty: "/dev/ttys000" }]);
|
|
154
|
-
}
|
|
155
|
-
return "";
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
const location = await new TerminalFocusManager().findTerminal(123);
|
|
159
|
-
|
|
160
|
-
expect(location).toEqual({
|
|
161
|
-
type: TerminalType.TMUX,
|
|
162
|
-
identifier: "my:0.1",
|
|
163
|
-
tty: "/dev/ttys000",
|
|
164
|
-
});
|
|
165
|
-
// WezTerm must not even be queried when tmux already matched.
|
|
166
|
-
expect(mockedExecFile).not.toHaveBeenCalledWith(
|
|
167
|
-
"wezterm",
|
|
168
|
-
expect.any(Array),
|
|
169
|
-
expect.any(Function),
|
|
170
|
-
);
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
describe("focusTerminal for WezTerm", () => {
|
|
175
|
-
const location: TerminalLocation = {
|
|
176
|
-
type: TerminalType.WEZTERM,
|
|
177
|
-
identifier: "7",
|
|
178
|
-
tty: "/dev/ttys000",
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
it("focuses the pane via wezterm cli activate-pane --pane-id", async () => {
|
|
182
|
-
setExecFileHandler((cmd, args) => {
|
|
183
|
-
if (cmd === "wezterm" && args.join(" ") === "cli activate-pane --pane-id 7") {
|
|
184
|
-
return "";
|
|
185
|
-
}
|
|
186
|
-
return "";
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
const ok = await new TerminalFocusManager().focusTerminal(location);
|
|
190
|
-
|
|
191
|
-
expect(ok).toBe(true);
|
|
192
|
-
expect(mockedExecFile).toHaveBeenCalledWith(
|
|
193
|
-
"wezterm",
|
|
194
|
-
["cli", "activate-pane", "--pane-id", "7"],
|
|
195
|
-
expect.any(Function),
|
|
196
|
-
);
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
it("returns false (without throwing) when focus fails", async () => {
|
|
200
|
-
setExecFileHandler((cmd) => {
|
|
201
|
-
if (cmd === "wezterm") return new Error("boom");
|
|
202
|
-
return "";
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
const ok = await new TerminalFocusManager().focusTerminal(location);
|
|
206
|
-
|
|
207
|
-
expect(ok).toBe(false);
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
describe("debug tracing", () => {
|
|
212
|
-
it("emits the matching decision path via the debug logger", async () => {
|
|
213
|
-
const debug = vi.fn();
|
|
214
|
-
setExecFileHandler((cmd, args) => {
|
|
215
|
-
if (cmd === "tmux") return new Error("tmux not running");
|
|
216
|
-
if (cmd === "wezterm" && args.join(" ").includes("cli list")) {
|
|
217
|
-
return JSON.stringify([{ pane_id: 7, tty_name: "/dev/ttys000" }]);
|
|
218
|
-
}
|
|
219
|
-
return "";
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
const location = await new TerminalFocusManager(debug).findTerminal(123);
|
|
223
|
-
|
|
224
|
-
expect(location?.type).toBe(TerminalType.WEZTERM);
|
|
225
|
-
const messages = debug.mock.calls.map((call) => call[0] as string);
|
|
226
|
-
expect(messages.some((m) => /pid=123/.test(m))).toBe(true);
|
|
227
|
-
expect(messages.some((m) => /tmux.*no match|tmux: no/i.test(m))).toBe(true);
|
|
228
|
-
expect(messages.some((m) => /wezterm/i.test(m))).toBe(true);
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
it("emits the focus decision path via the debug logger", async () => {
|
|
232
|
-
const debug = vi.fn();
|
|
233
|
-
setExecFileHandler((cmd, args) => {
|
|
234
|
-
if (cmd === "wezterm" && args.join(" ") === "cli activate-pane --pane-id 7") {
|
|
235
|
-
return "";
|
|
236
|
-
}
|
|
237
|
-
return "";
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
const ok = await new TerminalFocusManager(debug).focusTerminal({
|
|
241
|
-
type: TerminalType.WEZTERM,
|
|
242
|
-
identifier: "7",
|
|
243
|
-
tty: "/dev/ttys000",
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
expect(ok).toBe(true);
|
|
247
|
-
const messages = debug.mock.calls.map((call) => call[0] as string);
|
|
248
|
-
expect(messages.some((m) => /focusing wezterm/i.test(m))).toBe(true);
|
|
249
|
-
expect(messages.some((m) => /succeeded/i.test(m))).toBe(true);
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
it("finds Terminal.app when the process is listed by app bundle path", async () => {
|
|
254
|
-
setExecFileHandler((cmd, args) => {
|
|
255
|
-
if (cmd === "tmux") return new Error("tmux not running");
|
|
256
|
-
if (cmd === "pgrep") return new Error("pgrep did not match GUI app");
|
|
257
|
-
if (cmd === "ps" && args.join(" ") === "-Axo comm") {
|
|
258
|
-
return "/System/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal\n";
|
|
259
|
-
}
|
|
260
|
-
if (cmd === "osascript") {
|
|
261
|
-
const script = args[1] ?? "";
|
|
262
|
-
return script.includes('tell application "Terminal"') ? "found\n" : "";
|
|
263
|
-
}
|
|
264
|
-
return "";
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
const location = await new TerminalFocusManager().findTerminal(123);
|
|
268
|
-
|
|
269
|
-
expect(location).toEqual({
|
|
270
|
-
type: TerminalType.TERMINAL_APP,
|
|
271
|
-
identifier: "/dev/ttys000",
|
|
272
|
-
tty: "/dev/ttys000",
|
|
273
|
-
});
|
|
274
|
-
expect(mockedExecFile).not.toHaveBeenCalledWith(
|
|
275
|
-
"pgrep",
|
|
276
|
-
expect.any(Array),
|
|
277
|
-
expect.any(Function),
|
|
278
|
-
);
|
|
279
|
-
});
|
|
280
|
-
});
|