@ai-devkit/agent-manager 0.43.0 → 0.44.1
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/harnesses/pi/PiAdapter.d.ts.map +1 -1
- package/dist/harnesses/pi/PiAdapter.js +9 -4
- package/dist/harnesses/pi/PiAdapter.js.map +1 -1
- package/package.json +8 -3
- package/.swcrc +0 -27
- package/dist/__tests__/AgentManager.test.js +0 -1727
- 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 -559
- package/src/__tests__/AgentManager.test.ts +0 -1578
- 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 -71
- 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,185 +0,0 @@
|
|
|
1
|
-
import { execFile } from "child_process";
|
|
2
|
-
import type { MockedFunction } from "vitest";
|
|
3
|
-
import { TmuxManager } from "../../runtime/tmux/TmuxManager.js";
|
|
4
|
-
|
|
5
|
-
vi.mock("child_process", () => ({
|
|
6
|
-
execFile: vi.fn(),
|
|
7
|
-
}));
|
|
8
|
-
|
|
9
|
-
type ExecFileCb = (err: Error | null, result?: { stdout: string; stderr: string }) => void;
|
|
10
|
-
const mockedExecFile = execFile as unknown as MockedFunction<
|
|
11
|
-
(cmd: string, args: string[], cb: ExecFileCb) => void
|
|
12
|
-
>;
|
|
13
|
-
|
|
14
|
-
/** Drive the promisified execFile mock with a per-call handler. */
|
|
15
|
-
function setExecFileHandler(handler: (cmd: string, args: string[]) => string | Error) {
|
|
16
|
-
mockedExecFile.mockImplementation((_cmd, _args, cb) => {
|
|
17
|
-
const result = handler(_cmd, _args);
|
|
18
|
-
if (result instanceof Error) cb(result);
|
|
19
|
-
else cb(null, { stdout: result, stderr: "" });
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
describe("TmuxManager", () => {
|
|
24
|
-
let tmux: TmuxManager;
|
|
25
|
-
|
|
26
|
-
beforeEach(() => {
|
|
27
|
-
tmux = new TmuxManager();
|
|
28
|
-
mockedExecFile.mockReset();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
describe("isAvailable", () => {
|
|
32
|
-
it("returns true when `tmux -V` succeeds", async () => {
|
|
33
|
-
setExecFileHandler(() => "tmux 3.4");
|
|
34
|
-
expect(await tmux.isAvailable()).toBe(true);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("returns false when tmux is missing", async () => {
|
|
38
|
-
setExecFileHandler(() => new Error("ENOENT"));
|
|
39
|
-
expect(await tmux.isAvailable()).toBe(false);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
describe("sessionExists", () => {
|
|
44
|
-
it("returns true when has-session succeeds", async () => {
|
|
45
|
-
setExecFileHandler(() => "");
|
|
46
|
-
expect(await tmux.sessionExists("foo")).toBe(true);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("returns false when has-session fails", async () => {
|
|
50
|
-
setExecFileHandler(() => new Error("no session"));
|
|
51
|
-
expect(await tmux.sessionExists("foo")).toBe(false);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
describe("createSession", () => {
|
|
56
|
-
it("issues `tmux new-session -d -s <name> -c <cwd>`", async () => {
|
|
57
|
-
setExecFileHandler(() => "");
|
|
58
|
-
await tmux.createSession("foo", "/work");
|
|
59
|
-
expect(mockedExecFile).toHaveBeenCalledWith(
|
|
60
|
-
"tmux",
|
|
61
|
-
["new-session", "-d", "-s", "foo", "-c", "/work"],
|
|
62
|
-
expect.any(Function),
|
|
63
|
-
);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
describe("sendKeys", () => {
|
|
68
|
-
it("appends Enter so the command runs", async () => {
|
|
69
|
-
setExecFileHandler(() => "");
|
|
70
|
-
await tmux.sendKeys("foo", "claude");
|
|
71
|
-
expect(mockedExecFile).toHaveBeenCalledWith(
|
|
72
|
-
"tmux",
|
|
73
|
-
["send-keys", "-t", "foo", "claude", "Enter"],
|
|
74
|
-
expect.any(Function),
|
|
75
|
-
);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
describe("killSession", () => {
|
|
80
|
-
it("swallows errors when session is already gone", async () => {
|
|
81
|
-
setExecFileHandler(() => new Error("can't find session"));
|
|
82
|
-
await expect(tmux.killSession("foo")).resolves.toBeUndefined();
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
describe("findAgentPid", () => {
|
|
87
|
-
const matchesClaude = (cmd: string) => cmd.split(/\s+/)[0]?.endsWith("claude") ?? false;
|
|
88
|
-
|
|
89
|
-
it("returns null when the session has no pane", async () => {
|
|
90
|
-
setExecFileHandler((cmd, args) => {
|
|
91
|
-
if (args[0] === "list-panes") return new Error("no session");
|
|
92
|
-
return "";
|
|
93
|
-
});
|
|
94
|
-
expect(await tmux.findAgentPid("foo", matchesClaude)).toBeNull();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("returns null when no descendant matches", async () => {
|
|
98
|
-
// pane PID 100; child 200 is "node /unrelated" — no match
|
|
99
|
-
setExecFileHandler((cmd, args) => {
|
|
100
|
-
if (cmd === "tmux" && args[0] === "list-panes") return "100\n";
|
|
101
|
-
if (cmd === "pgrep" && args[1] === "100") return "200\n";
|
|
102
|
-
if (cmd === "pgrep") return new Error("no children");
|
|
103
|
-
if (cmd === "ps" && args[1] === "200") return "node /unrelated";
|
|
104
|
-
return "";
|
|
105
|
-
});
|
|
106
|
-
expect(await tmux.findAgentPid("foo", matchesClaude)).toBeNull();
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it("returns the matching pane PID when the agent replaces the shell", async () => {
|
|
110
|
-
setExecFileHandler((cmd, args) => {
|
|
111
|
-
if (cmd === "tmux" && args[0] === "list-panes") return "100\n";
|
|
112
|
-
if (cmd === "pgrep") return new Error("no children");
|
|
113
|
-
if (cmd === "ps" && args[1] === "100") return "/usr/local/bin/claude";
|
|
114
|
-
return "";
|
|
115
|
-
});
|
|
116
|
-
expect(await tmux.findAgentPid("foo", matchesClaude)).toBe(100);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it("returns the matching descendant when found", async () => {
|
|
120
|
-
// pane 100 → child 200 (claude) — no grandchildren
|
|
121
|
-
setExecFileHandler((cmd, args) => {
|
|
122
|
-
if (cmd === "tmux") return "100\n";
|
|
123
|
-
if (cmd === "pgrep" && args[1] === "100") return "200\n";
|
|
124
|
-
if (cmd === "pgrep") return new Error("no children");
|
|
125
|
-
if (cmd === "ps" && args[1] === "200") return "claude";
|
|
126
|
-
return "";
|
|
127
|
-
});
|
|
128
|
-
expect(await tmux.findAgentPid("foo", matchesClaude)).toBe(200);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it("prefers the deepest match (wrapper case)", async () => {
|
|
132
|
-
// pane 100 → 200 (claude wrapper, matches) → 300 (claude, matches, deeper)
|
|
133
|
-
setExecFileHandler((cmd, args) => {
|
|
134
|
-
if (cmd === "tmux") return "100\n";
|
|
135
|
-
if (cmd === "pgrep" && args[1] === "100") return "200\n";
|
|
136
|
-
if (cmd === "pgrep" && args[1] === "200") return "300\n";
|
|
137
|
-
if (cmd === "pgrep") return new Error("no children");
|
|
138
|
-
if (cmd === "ps" && args[1] === "200") return "/usr/local/bin/claude";
|
|
139
|
-
if (cmd === "ps" && args[1] === "300") return "/usr/local/lib/claude";
|
|
140
|
-
return "";
|
|
141
|
-
});
|
|
142
|
-
expect(await tmux.findAgentPid("foo", matchesClaude)).toBe(300);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it("skips non-matching subprocesses (MCP child case)", async () => {
|
|
146
|
-
// pane 100 → 200 (claude, matches) → 300 (mcp-server, no match)
|
|
147
|
-
setExecFileHandler((cmd, args) => {
|
|
148
|
-
if (cmd === "tmux") return "100\n";
|
|
149
|
-
if (cmd === "pgrep" && args[1] === "100") return "200\n";
|
|
150
|
-
if (cmd === "pgrep" && args[1] === "200") return "300\n";
|
|
151
|
-
if (cmd === "pgrep") return new Error("no children");
|
|
152
|
-
if (cmd === "ps" && args[1] === "200") return "claude";
|
|
153
|
-
if (cmd === "ps" && args[1] === "300") return "node mcp-server.js";
|
|
154
|
-
return "";
|
|
155
|
-
});
|
|
156
|
-
expect(await tmux.findAgentPid("foo", matchesClaude)).toBe(200);
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it("handles the gemini Node-script shape via a token-scan matcher", async () => {
|
|
160
|
-
const matchesGemini = (cmd: string) =>
|
|
161
|
-
cmd.split(/\s+/).some((t) => t.endsWith("/gemini") || t === "gemini");
|
|
162
|
-
setExecFileHandler((cmd, args) => {
|
|
163
|
-
if (cmd === "tmux") return "100\n";
|
|
164
|
-
if (cmd === "pgrep" && args[1] === "100") return "200\n";
|
|
165
|
-
if (cmd === "pgrep") return new Error("no children");
|
|
166
|
-
if (cmd === "ps" && args[1] === "200") return "node /opt/homebrew/bin/gemini --foo";
|
|
167
|
-
return "";
|
|
168
|
-
});
|
|
169
|
-
expect(await tmux.findAgentPid("foo", matchesGemini)).toBe(200);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it("handles multiple children at the same level", async () => {
|
|
173
|
-
// pane 100 → [200 (nope), 201 (claude)]
|
|
174
|
-
setExecFileHandler((cmd, args) => {
|
|
175
|
-
if (cmd === "tmux") return "100\n";
|
|
176
|
-
if (cmd === "pgrep" && args[1] === "100") return "200\n201\n";
|
|
177
|
-
if (cmd === "pgrep") return new Error("no children");
|
|
178
|
-
if (cmd === "ps" && args[1] === "200") return "bash";
|
|
179
|
-
if (cmd === "ps" && args[1] === "201") return "claude";
|
|
180
|
-
return "";
|
|
181
|
-
});
|
|
182
|
-
expect(await tmux.findAgentPid("foo", matchesClaude)).toBe(201);
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
});
|
|
@@ -1,454 +0,0 @@
|
|
|
1
|
-
import type { Mock } from "vitest";
|
|
2
|
-
|
|
3
|
-
import { TtyWriter } from "../../terminal/TtyWriter.js";
|
|
4
|
-
import { TerminalType } from "../../terminal/TerminalFocusManager.js";
|
|
5
|
-
import type { TerminalLocation } from "../../terminal/TerminalFocusManager.js";
|
|
6
|
-
import { execFile } from "child_process";
|
|
7
|
-
|
|
8
|
-
vi.mock("child_process", async () => {
|
|
9
|
-
const actual = await vi.importActual<typeof import("child_process")>("child_process");
|
|
10
|
-
return {
|
|
11
|
-
...actual,
|
|
12
|
-
execFile: vi.fn(),
|
|
13
|
-
};
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
const mockedExecFile = execFile as unknown as Mock;
|
|
17
|
-
|
|
18
|
-
function mockExecFileSuccess(stdout = "") {
|
|
19
|
-
mockedExecFile.mockImplementation((...args: unknown[]) => {
|
|
20
|
-
const cb = args[args.length - 1] as (
|
|
21
|
-
err: Error | null,
|
|
22
|
-
result: { stdout: string },
|
|
23
|
-
stderr: string,
|
|
24
|
-
) => void;
|
|
25
|
-
cb(null, { stdout }, "");
|
|
26
|
-
return { stdin: { end: vi.fn() } };
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function mockExecFileError(message: string) {
|
|
31
|
-
mockedExecFile.mockImplementation((...args: unknown[]) => {
|
|
32
|
-
const cb = args[args.length - 1] as (err: Error | null, result: null, stderr: string) => void;
|
|
33
|
-
cb(new Error(message), null, "");
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
describe("TtyWriter", () => {
|
|
38
|
-
beforeEach(() => {
|
|
39
|
-
vi.clearAllMocks();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
describe("tmux", () => {
|
|
43
|
-
const location: TerminalLocation = {
|
|
44
|
-
type: TerminalType.TMUX,
|
|
45
|
-
identifier: "main:0.1",
|
|
46
|
-
tty: "/dev/ttys030",
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
it("pastes message in bracketed paste mode and sends Enter separately", async () => {
|
|
50
|
-
mockExecFileSuccess();
|
|
51
|
-
const message = "line 1\nline 2\n";
|
|
52
|
-
|
|
53
|
-
await TtyWriter.send(location, message);
|
|
54
|
-
|
|
55
|
-
const loadArgs = mockedExecFile.mock.calls[0]?.[1] as string[];
|
|
56
|
-
const bufferName = loadArgs[2];
|
|
57
|
-
expect(bufferName).toMatch(/^ai-devkit-send-/);
|
|
58
|
-
expect(mockedExecFile).toHaveBeenNthCalledWith(
|
|
59
|
-
1,
|
|
60
|
-
"tmux",
|
|
61
|
-
["load-buffer", "-b", bufferName, "-"],
|
|
62
|
-
expect.any(Function),
|
|
63
|
-
);
|
|
64
|
-
expect(mockedExecFile.mock.results[0]?.value.stdin.end).toHaveBeenCalledWith(message);
|
|
65
|
-
expect(mockedExecFile).toHaveBeenNthCalledWith(
|
|
66
|
-
2,
|
|
67
|
-
"tmux",
|
|
68
|
-
["paste-buffer", "-t", "main:0.1", "-b", bufferName, "-p", "-d"],
|
|
69
|
-
expect.any(Function),
|
|
70
|
-
);
|
|
71
|
-
expect(mockedExecFile).toHaveBeenNthCalledWith(
|
|
72
|
-
3,
|
|
73
|
-
"tmux",
|
|
74
|
-
["send-keys", "-t", "main:0.1", "Enter"],
|
|
75
|
-
expect.any(Function),
|
|
76
|
-
);
|
|
77
|
-
expect(mockedExecFile).toHaveBeenCalledTimes(3);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("throws on tmux failure", async () => {
|
|
81
|
-
mockExecFileError("tmux not running");
|
|
82
|
-
|
|
83
|
-
await expect(TtyWriter.send(location, "hello")).rejects.toThrow("tmux not running");
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
describe("iTerm2", () => {
|
|
88
|
-
const location: TerminalLocation = {
|
|
89
|
-
type: TerminalType.ITERM2,
|
|
90
|
-
identifier: "/dev/ttys030",
|
|
91
|
-
tty: "/dev/ttys030",
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
it("sends message via osascript with execFile (no shell)", async () => {
|
|
95
|
-
mockExecFileSuccess("ok");
|
|
96
|
-
|
|
97
|
-
await TtyWriter.send(location, "hello");
|
|
98
|
-
|
|
99
|
-
// First call: send text without newline
|
|
100
|
-
expect(mockedExecFile).toHaveBeenCalledWith(
|
|
101
|
-
"osascript",
|
|
102
|
-
["-e", expect.stringContaining('write text "hello" newline no')],
|
|
103
|
-
expect.any(Function),
|
|
104
|
-
);
|
|
105
|
-
// Second call: send Enter via separate write text with newline
|
|
106
|
-
expect(mockedExecFile).toHaveBeenCalledWith(
|
|
107
|
-
"osascript",
|
|
108
|
-
["-e", expect.stringContaining('write text "" newline yes')],
|
|
109
|
-
expect.any(Function),
|
|
110
|
-
);
|
|
111
|
-
expect(mockedExecFile).toHaveBeenCalledTimes(2);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("escapes special characters in message", async () => {
|
|
115
|
-
mockExecFileSuccess("ok");
|
|
116
|
-
|
|
117
|
-
await TtyWriter.send(location, 'say "hi" \\ there');
|
|
118
|
-
|
|
119
|
-
expect(mockedExecFile).toHaveBeenCalledWith(
|
|
120
|
-
"osascript",
|
|
121
|
-
["-e", expect.stringContaining('write text "say \\"hi\\" \\\\ there" newline no')],
|
|
122
|
-
expect.any(Function),
|
|
123
|
-
);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it("escapes newlines in message", async () => {
|
|
127
|
-
mockExecFileSuccess("ok");
|
|
128
|
-
|
|
129
|
-
await TtyWriter.send(location, "line1\nline2");
|
|
130
|
-
|
|
131
|
-
expect(mockedExecFile).toHaveBeenCalledWith(
|
|
132
|
-
"osascript",
|
|
133
|
-
["-e", expect.stringContaining('write text "line1\\nline2" newline no')],
|
|
134
|
-
expect.any(Function),
|
|
135
|
-
);
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it("throws when session not found", async () => {
|
|
139
|
-
mockExecFileSuccess("not_found");
|
|
140
|
-
|
|
141
|
-
await expect(TtyWriter.send(location, "test")).rejects.toThrow("iTerm2 session not found");
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it("throws when session disappears before Enter", async () => {
|
|
145
|
-
// First call succeeds (text sent), second returns not_found
|
|
146
|
-
let callCount = 0;
|
|
147
|
-
mockedExecFile.mockImplementation((...args: unknown[]) => {
|
|
148
|
-
const cb = args[args.length - 1] as (
|
|
149
|
-
err: Error | null,
|
|
150
|
-
result: { stdout: string },
|
|
151
|
-
stderr: string,
|
|
152
|
-
) => void;
|
|
153
|
-
callCount++;
|
|
154
|
-
cb(null, { stdout: callCount === 1 ? "ok" : "not_found" }, "");
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
await expect(TtyWriter.send(location, "test")).rejects.toThrow(
|
|
158
|
-
"iTerm2 session disappeared before Enter",
|
|
159
|
-
);
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
describe("Terminal.app", () => {
|
|
164
|
-
const location: TerminalLocation = {
|
|
165
|
-
type: TerminalType.TERMINAL_APP,
|
|
166
|
-
identifier: "/dev/ttys030",
|
|
167
|
-
tty: "/dev/ttys030",
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
it("sends message via do script (not System Events)", async () => {
|
|
171
|
-
mockExecFileSuccess("ok");
|
|
172
|
-
|
|
173
|
-
await TtyWriter.send(location, "hello");
|
|
174
|
-
|
|
175
|
-
// First call: send text via do script
|
|
176
|
-
const firstCallArgs = (mockedExecFile.mock.calls[0] as unknown[])[1] as string[];
|
|
177
|
-
const textScript = firstCallArgs[1];
|
|
178
|
-
expect(textScript).toContain('do script "hello" in targetTab');
|
|
179
|
-
expect(textScript).not.toContain("keystroke");
|
|
180
|
-
expect(textScript).not.toContain("key code 36");
|
|
181
|
-
|
|
182
|
-
// Second call: send Enter via separate do script
|
|
183
|
-
const secondCallArgs = (mockedExecFile.mock.calls[1] as unknown[])[1] as string[];
|
|
184
|
-
const enterScript = secondCallArgs[1];
|
|
185
|
-
expect(enterScript).toContain('do script "" in targetTab');
|
|
186
|
-
|
|
187
|
-
expect(mockedExecFile).toHaveBeenCalledTimes(2);
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it("throws when tab not found", async () => {
|
|
191
|
-
mockExecFileSuccess("not_found");
|
|
192
|
-
|
|
193
|
-
await expect(TtyWriter.send(location, "test")).rejects.toThrow("Terminal.app tab not found");
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
it("throws when tab disappears before Enter", async () => {
|
|
197
|
-
let callCount = 0;
|
|
198
|
-
mockedExecFile.mockImplementation((...args: unknown[]) => {
|
|
199
|
-
const cb = args[args.length - 1] as (
|
|
200
|
-
err: Error | null,
|
|
201
|
-
result: { stdout: string },
|
|
202
|
-
stderr: string,
|
|
203
|
-
) => void;
|
|
204
|
-
callCount++;
|
|
205
|
-
cb(null, { stdout: callCount === 1 ? "ok" : "not_found" }, "");
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
await expect(TtyWriter.send(location, "test")).rejects.toThrow(
|
|
209
|
-
"Terminal.app tab disappeared before Enter",
|
|
210
|
-
);
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
describe("WezTerm", () => {
|
|
215
|
-
const location: TerminalLocation = {
|
|
216
|
-
type: TerminalType.WEZTERM,
|
|
217
|
-
identifier: "7",
|
|
218
|
-
tty: "/dev/ttys030",
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
it("sends the message via stdin and Enter as a separate send-text call", async () => {
|
|
222
|
-
mockExecFileSuccess();
|
|
223
|
-
|
|
224
|
-
await TtyWriter.send(location, "continue");
|
|
225
|
-
|
|
226
|
-
// Step 1: message body via stdin, not argv, so prompt contents are
|
|
227
|
-
// not exposed through process listings.
|
|
228
|
-
expect(mockedExecFile).toHaveBeenCalledWith(
|
|
229
|
-
"wezterm",
|
|
230
|
-
["cli", "send-text", "--pane-id", "7"],
|
|
231
|
-
expect.any(Function),
|
|
232
|
-
);
|
|
233
|
-
expect(mockedExecFile.mock.results[0]?.value.stdin.end).toHaveBeenCalledWith("continue");
|
|
234
|
-
// Step 2: Enter as a single carriage return (0x0d) with --no-paste,
|
|
235
|
-
// so the CR is delivered literally (not wrapped in paste brackets).
|
|
236
|
-
// execFile passes the actual CR byte (JS '\x0d'); the equivalent
|
|
237
|
-
// shell command is:
|
|
238
|
-
// wezterm cli send-text --pane-id <id> --no-paste $'\x0d'
|
|
239
|
-
expect(mockedExecFile).toHaveBeenCalledWith(
|
|
240
|
-
"wezterm",
|
|
241
|
-
["cli", "send-text", "--pane-id", "7", "--no-paste", "\x0d"],
|
|
242
|
-
expect.any(Function),
|
|
243
|
-
);
|
|
244
|
-
expect(mockedExecFile).toHaveBeenCalledTimes(2);
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
it("passes the Enter byte as the carriage return (0x0d), not newline", async () => {
|
|
248
|
-
mockExecFileSuccess();
|
|
249
|
-
|
|
250
|
-
await TtyWriter.send(location, "continue");
|
|
251
|
-
|
|
252
|
-
// The Enter call is the second invocation; its last argv element is
|
|
253
|
-
// a single byte equal to char code 13 (0x0d).
|
|
254
|
-
const enterCall = mockedExecFile.mock.calls[1];
|
|
255
|
-
const enterArgs = enterCall[1] as string[];
|
|
256
|
-
const enterByte = enterArgs[enterArgs.length - 1];
|
|
257
|
-
expect(enterByte).toHaveLength(1);
|
|
258
|
-
expect(enterByte.charCodeAt(0)).toBe(0x0d);
|
|
259
|
-
expect(enterArgs).toContain("--no-paste");
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
it("keeps the whole message out of argv and writes it verbatim to stdin", async () => {
|
|
263
|
-
mockExecFileSuccess();
|
|
264
|
-
const hostile = "echo pwned; $(rm -rf /) `whoami` | cat\nline2";
|
|
265
|
-
|
|
266
|
-
await TtyWriter.send(location, hostile);
|
|
267
|
-
|
|
268
|
-
// The message is written verbatim to stdin, not built into a shell
|
|
269
|
-
// string or exposed as a process argument.
|
|
270
|
-
const textCall = mockedExecFile.mock.calls[0];
|
|
271
|
-
const textArgs = textCall[1] as string[];
|
|
272
|
-
expect(textArgs).toEqual(["cli", "send-text", "--pane-id", "7"]);
|
|
273
|
-
expect(textCall[2]).toBeTypeOf("function");
|
|
274
|
-
expect(mockedExecFile.mock.results[0]?.value.stdin.end).toHaveBeenCalledWith(hostile);
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
it("uses the pane id from location.identifier", async () => {
|
|
278
|
-
mockExecFileSuccess();
|
|
279
|
-
const pane42 = { ...location, identifier: "42" };
|
|
280
|
-
|
|
281
|
-
await TtyWriter.send(pane42, "hi");
|
|
282
|
-
|
|
283
|
-
expect(mockedExecFile).toHaveBeenCalledWith(
|
|
284
|
-
"wezterm",
|
|
285
|
-
["cli", "send-text", "--pane-id", "42"],
|
|
286
|
-
expect.any(Function),
|
|
287
|
-
);
|
|
288
|
-
expect(mockedExecFile.mock.results[0]?.value.stdin.end).toHaveBeenCalledWith("hi");
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
it("throws when the text send fails", async () => {
|
|
292
|
-
mockExecFileError("wezterm send-text failed");
|
|
293
|
-
|
|
294
|
-
await expect(TtyWriter.send(location, "hello")).rejects.toThrow("wezterm send-text failed");
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
describe("unsupported terminal", () => {
|
|
299
|
-
it("throws for unknown terminal type", async () => {
|
|
300
|
-
const location: TerminalLocation = {
|
|
301
|
-
type: TerminalType.UNKNOWN,
|
|
302
|
-
identifier: "",
|
|
303
|
-
tty: "/dev/ttys030",
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
await expect(TtyWriter.send(location, "test")).rejects.toThrow(
|
|
307
|
-
"Cannot send input: unsupported terminal type",
|
|
308
|
-
);
|
|
309
|
-
});
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
describe("sendKey — tmux", () => {
|
|
313
|
-
const location: TerminalLocation = {
|
|
314
|
-
type: TerminalType.TMUX,
|
|
315
|
-
identifier: "main:0.1",
|
|
316
|
-
tty: "/dev/ttys030",
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
it("sends key via tmux send-keys directly (no paste buffer, no auto-Enter)", async () => {
|
|
320
|
-
mockExecFileSuccess();
|
|
321
|
-
|
|
322
|
-
await TtyWriter.sendKey(location, "1");
|
|
323
|
-
|
|
324
|
-
expect(mockedExecFile).toHaveBeenCalledTimes(1);
|
|
325
|
-
expect(mockedExecFile).toHaveBeenCalledWith(
|
|
326
|
-
"tmux",
|
|
327
|
-
["send-keys", "-t", "main:0.1", "1"],
|
|
328
|
-
expect.any(Function),
|
|
329
|
-
);
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
it("passes through named keys like Enter", async () => {
|
|
333
|
-
mockExecFileSuccess();
|
|
334
|
-
await TtyWriter.sendKey(location, "Enter");
|
|
335
|
-
expect(mockedExecFile).toHaveBeenCalledWith(
|
|
336
|
-
"tmux",
|
|
337
|
-
["send-keys", "-t", "main:0.1", "Enter"],
|
|
338
|
-
expect.any(Function),
|
|
339
|
-
);
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
it('translates Esc byte (\\x1b) to the named "Escape" key', async () => {
|
|
343
|
-
mockExecFileSuccess();
|
|
344
|
-
await TtyWriter.sendKey(location, "\x1b");
|
|
345
|
-
expect(mockedExecFile).toHaveBeenCalledWith(
|
|
346
|
-
"tmux",
|
|
347
|
-
["send-keys", "-t", "main:0.1", "Escape"],
|
|
348
|
-
expect.any(Function),
|
|
349
|
-
);
|
|
350
|
-
});
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
describe("sendKey — WezTerm", () => {
|
|
354
|
-
const location: TerminalLocation = {
|
|
355
|
-
type: TerminalType.WEZTERM,
|
|
356
|
-
identifier: "7",
|
|
357
|
-
tty: "/dev/ttys030",
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
it("uses wezterm cli send-text --no-paste to deliver a raw key", async () => {
|
|
361
|
-
mockExecFileSuccess();
|
|
362
|
-
|
|
363
|
-
await TtyWriter.sendKey(location, "1");
|
|
364
|
-
|
|
365
|
-
expect(mockedExecFile).toHaveBeenCalledTimes(1);
|
|
366
|
-
expect(mockedExecFile).toHaveBeenCalledWith(
|
|
367
|
-
"wezterm",
|
|
368
|
-
["cli", "send-text", "--pane-id", "7", "--no-paste", "1"],
|
|
369
|
-
expect.any(Function),
|
|
370
|
-
);
|
|
371
|
-
});
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
describe("sendKey — iTerm2", () => {
|
|
375
|
-
const location: TerminalLocation = {
|
|
376
|
-
type: TerminalType.ITERM2,
|
|
377
|
-
identifier: "/dev/ttys030",
|
|
378
|
-
tty: "/dev/ttys030",
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
it("uses System Events keystroke after activating the iTerm2 session", async () => {
|
|
382
|
-
mockExecFileSuccess("ok");
|
|
383
|
-
|
|
384
|
-
await TtyWriter.sendKey(location, "2");
|
|
385
|
-
|
|
386
|
-
const args = (mockedExecFile.mock.calls[0] as unknown[])[1] as string[];
|
|
387
|
-
const script = args[1];
|
|
388
|
-
expect(script).toContain('tell application "iTerm"');
|
|
389
|
-
expect(script).toContain('tell application "System Events" to keystroke "2"');
|
|
390
|
-
expect(mockedExecFile).toHaveBeenCalledTimes(1);
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
it("translates Esc byte (\\x1b) to AppleScript `key code 53`", async () => {
|
|
394
|
-
mockExecFileSuccess("ok");
|
|
395
|
-
await TtyWriter.sendKey(location, "\x1b");
|
|
396
|
-
const args = (mockedExecFile.mock.calls[0] as unknown[])[1] as string[];
|
|
397
|
-
const script = args[1];
|
|
398
|
-
expect(script).toContain('tell application "System Events" to key code 53');
|
|
399
|
-
expect(script).not.toContain("keystroke");
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
it("throws when session not found", async () => {
|
|
403
|
-
mockExecFileSuccess("not_found");
|
|
404
|
-
await expect(TtyWriter.sendKey(location, "1")).rejects.toThrow("iTerm2 session not found");
|
|
405
|
-
});
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
describe("sendKey — Terminal.app", () => {
|
|
409
|
-
const location: TerminalLocation = {
|
|
410
|
-
type: TerminalType.TERMINAL_APP,
|
|
411
|
-
identifier: "/dev/ttys030",
|
|
412
|
-
tty: "/dev/ttys030",
|
|
413
|
-
};
|
|
414
|
-
|
|
415
|
-
it("uses System Events keystroke after selecting the Terminal.app tab", async () => {
|
|
416
|
-
mockExecFileSuccess("ok");
|
|
417
|
-
|
|
418
|
-
await TtyWriter.sendKey(location, "3");
|
|
419
|
-
|
|
420
|
-
const args = (mockedExecFile.mock.calls[0] as unknown[])[1] as string[];
|
|
421
|
-
const script = args[1];
|
|
422
|
-
expect(script).toContain('tell application "Terminal"');
|
|
423
|
-
expect(script).toContain('tell application "System Events" to keystroke "3"');
|
|
424
|
-
expect(mockedExecFile).toHaveBeenCalledTimes(1);
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
it("translates Esc byte (\\x1b) to AppleScript `key code 53`", async () => {
|
|
428
|
-
mockExecFileSuccess("ok");
|
|
429
|
-
await TtyWriter.sendKey(location, "\x1b");
|
|
430
|
-
const args = (mockedExecFile.mock.calls[0] as unknown[])[1] as string[];
|
|
431
|
-
const script = args[1];
|
|
432
|
-
expect(script).toContain('tell application "System Events" to key code 53');
|
|
433
|
-
expect(script).not.toContain("keystroke");
|
|
434
|
-
});
|
|
435
|
-
|
|
436
|
-
it("throws when tab not found", async () => {
|
|
437
|
-
mockExecFileSuccess("not_found");
|
|
438
|
-
await expect(TtyWriter.sendKey(location, "1")).rejects.toThrow("Terminal.app tab not found");
|
|
439
|
-
});
|
|
440
|
-
});
|
|
441
|
-
|
|
442
|
-
describe("sendKey — unsupported terminal", () => {
|
|
443
|
-
it("throws for unknown terminal type", async () => {
|
|
444
|
-
const location: TerminalLocation = {
|
|
445
|
-
type: TerminalType.UNKNOWN,
|
|
446
|
-
identifier: "",
|
|
447
|
-
tty: "/dev/ttys030",
|
|
448
|
-
};
|
|
449
|
-
await expect(TtyWriter.sendKey(location, "1")).rejects.toThrow(
|
|
450
|
-
"Cannot send key: unsupported terminal type",
|
|
451
|
-
);
|
|
452
|
-
});
|
|
453
|
-
});
|
|
454
|
-
});
|