@ai-devkit/agent-manager 0.37.0 → 0.39.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 +0 -4
- package/dist/AgentManager.d.ts.map +1 -1
- package/dist/AgentManager.js +2 -2
- package/dist/AgentManager.js.map +1 -1
- package/dist/__tests__/capacity/anthropic.test.js +115 -0
- package/dist/__tests__/capacity/anthropic.test.js.map +1 -0
- package/dist/__tests__/capacity/boundaries.test.js +45 -0
- package/dist/__tests__/capacity/boundaries.test.js.map +1 -0
- package/dist/__tests__/capacity/claude.test.js +3 -3
- package/dist/__tests__/capacity/claude.test.js.map +1 -1
- package/dist/__tests__/capacity/codex.test.js +3 -1
- package/dist/__tests__/capacity/codex.test.js.map +1 -1
- package/dist/__tests__/capacity/openai.test.js +21 -12
- package/dist/__tests__/capacity/openai.test.js.map +1 -1
- package/dist/__tests__/capacity/wham.test.js +1 -1
- package/dist/__tests__/capacity/wham.test.js.map +1 -1
- package/dist/__tests__/capacity/zai.test.js +7 -8
- package/dist/__tests__/capacity/zai.test.js.map +1 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.js +2 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.js.map +1 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.js.map +1 -1
- package/dist/__tests__/harnesses/codex/durable/CodexCliProbe.test.js +7 -15
- package/dist/__tests__/harnesses/codex/durable/CodexCliProbe.test.js.map +1 -1
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.js +3 -1
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.js.map +1 -1
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.js +11 -26
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.js.map +1 -1
- package/dist/__tests__/harnesses/codex/durable/CodexPrintRunner.test.js +3 -7
- package/dist/__tests__/harnesses/codex/durable/CodexPrintRunner.test.js.map +1 -1
- package/dist/__tests__/harnesses/devin/DevinAdapter.test.js +597 -0
- package/dist/__tests__/harnesses/devin/DevinAdapter.test.js.map +1 -0
- package/dist/__tests__/harnesses/devin/DevinAgentMapper.test.js +91 -0
- package/dist/__tests__/harnesses/devin/DevinAgentMapper.test.js.map +1 -0
- package/dist/__tests__/harnesses/devin/DevinSessionLocator.test.js +192 -0
- package/dist/__tests__/harnesses/devin/DevinSessionLocator.test.js.map +1 -0
- package/dist/__tests__/harnesses/devin/DevinSessionParser.test.js +407 -0
- package/dist/__tests__/harnesses/devin/DevinSessionParser.test.js.map +1 -0
- package/dist/__tests__/harnesses/devin/fixtures.js +95 -0
- package/dist/__tests__/harnesses/devin/fixtures.js.map +1 -0
- package/dist/__tests__/harnesses/pi/durable/PiCliProbe.test.js +5 -11
- package/dist/__tests__/harnesses/pi/durable/PiCliProbe.test.js.map +1 -1
- package/dist/__tests__/harnesses/pi/durable/PiPrintAgentService.test.js +9 -19
- package/dist/__tests__/harnesses/pi/durable/PiPrintAgentService.test.js.map +1 -1
- package/dist/__tests__/harnesses/pi/durable/PiPrintRunner.test.js +3 -7
- package/dist/__tests__/harnesses/pi/durable/PiPrintRunner.test.js.map +1 -1
- package/dist/__tests__/{readiness → harnesses/readiness}/AgentReadiness.test.js +95 -11
- package/dist/__tests__/harnesses/readiness/AgentReadiness.test.js.map +1 -0
- package/dist/__tests__/harnesses/runtimeProfiles.test.js +89 -0
- package/dist/__tests__/harnesses/runtimeProfiles.test.js.map +1 -0
- package/dist/__tests__/print/DurableAgent.test.js +4 -6
- package/dist/__tests__/print/DurableAgent.test.js.map +1 -1
- package/dist/__tests__/print/DurableAgentRepository.test.js +1 -12
- package/dist/__tests__/print/DurableAgentRepository.test.js.map +1 -1
- package/dist/__tests__/runtime/ManagedAgentRuntime.test.js.map +1 -1
- package/dist/__tests__/terminal/GhosttyBackend.test.js +334 -0
- package/dist/__tests__/terminal/GhosttyBackend.test.js.map +1 -0
- package/dist/__tests__/terminal/TmuxManager.test.js +1 -1
- package/dist/__tests__/terminal/TmuxManager.test.js.map +1 -1
- package/dist/adapters/AgentAdapter.d.ts +1 -1
- package/dist/adapters/AgentAdapter.d.ts.map +1 -1
- package/dist/adapters/AgentAdapter.js +2 -1
- package/dist/adapters/AgentAdapter.js.map +1 -1
- package/dist/capacity/index.d.ts +9 -19
- package/dist/capacity/index.d.ts.map +1 -1
- package/dist/capacity/index.js +11 -4
- package/dist/capacity/index.js.map +1 -1
- package/dist/capacity/providers/anthropic.d.ts +9 -0
- package/dist/capacity/providers/anthropic.d.ts.map +1 -0
- package/dist/capacity/{claude.js → providers/anthropic.js} +10 -128
- package/dist/capacity/providers/anthropic.js.map +1 -0
- package/dist/capacity/providers/openai-platform.d.ts +14 -0
- package/dist/capacity/providers/openai-platform.d.ts.map +1 -0
- package/dist/capacity/providers/openai-platform.js +120 -0
- package/dist/capacity/providers/openai-platform.js.map +1 -0
- package/dist/capacity/providers/openai-subscription.d.ts +20 -0
- package/dist/capacity/providers/openai-subscription.d.ts.map +1 -0
- package/dist/capacity/providers/openai-subscription.js +129 -0
- package/dist/capacity/providers/openai-subscription.js.map +1 -0
- package/dist/capacity/providers/zai.d.ts +8 -0
- package/dist/capacity/providers/zai.d.ts.map +1 -0
- package/dist/capacity/{zai.js → providers/zai.js} +17 -62
- package/dist/capacity/providers/zai.js.map +1 -0
- package/dist/capacity/sources/claude.d.ts +9 -0
- package/dist/capacity/sources/claude.d.ts.map +1 -0
- package/dist/capacity/sources/claude.js +17 -0
- package/dist/capacity/sources/claude.js.map +1 -0
- package/dist/capacity/{codex.d.ts → sources/codex.d.ts} +5 -9
- package/dist/capacity/sources/codex.d.ts.map +1 -0
- package/dist/capacity/{codex.js → sources/codex.js} +31 -84
- package/dist/capacity/sources/codex.js.map +1 -0
- package/dist/capacity/sources/pi.d.ts +30 -0
- package/dist/capacity/sources/pi.d.ts.map +1 -0
- package/dist/capacity/sources/pi.js +81 -0
- package/dist/capacity/sources/pi.js.map +1 -0
- package/dist/capacity/types.d.ts +2 -0
- package/dist/capacity/types.d.ts.map +1 -1
- package/dist/capacity/types.js +1 -1
- package/dist/capacity/types.js.map +1 -1
- package/dist/harnesses/claude/credentials.d.ts +10 -0
- package/dist/harnesses/claude/credentials.d.ts.map +1 -0
- package/dist/harnesses/claude/credentials.js +112 -0
- package/dist/harnesses/claude/credentials.js.map +1 -0
- package/dist/harnesses/claude/readiness.d.ts +3 -0
- package/dist/harnesses/claude/readiness.d.ts.map +1 -0
- package/dist/harnesses/claude/readiness.js +63 -0
- package/dist/harnesses/claude/readiness.js.map +1 -0
- package/dist/harnesses/codex/credentials.d.ts +15 -0
- package/dist/harnesses/codex/credentials.d.ts.map +1 -0
- package/dist/harnesses/codex/credentials.js +58 -0
- package/dist/harnesses/codex/credentials.js.map +1 -0
- package/dist/harnesses/codex/readiness.d.ts +3 -0
- package/dist/harnesses/codex/readiness.d.ts.map +1 -0
- package/dist/harnesses/codex/readiness.js +60 -0
- package/dist/harnesses/codex/readiness.js.map +1 -0
- package/dist/harnesses/copilot/readiness.d.ts +3 -0
- package/dist/harnesses/copilot/readiness.d.ts.map +1 -0
- package/dist/harnesses/copilot/readiness.js +39 -0
- package/dist/harnesses/copilot/readiness.js.map +1 -0
- package/dist/harnesses/devin/DevinAdapter.d.ts +39 -0
- package/dist/harnesses/devin/DevinAdapter.d.ts.map +1 -0
- package/dist/harnesses/devin/DevinAdapter.js +177 -0
- package/dist/harnesses/devin/DevinAdapter.js.map +1 -0
- package/dist/harnesses/devin/DevinAgentMapper.d.ts +11 -0
- package/dist/harnesses/devin/DevinAgentMapper.d.ts.map +1 -0
- package/dist/harnesses/devin/DevinAgentMapper.js +35 -0
- package/dist/harnesses/devin/DevinAgentMapper.js.map +1 -0
- package/dist/harnesses/devin/DevinSessionLocator.d.ts +46 -0
- package/dist/harnesses/devin/DevinSessionLocator.d.ts.map +1 -0
- package/dist/harnesses/devin/DevinSessionLocator.js +176 -0
- package/dist/harnesses/devin/DevinSessionLocator.js.map +1 -0
- package/dist/harnesses/devin/DevinSessionParser.d.ts +29 -0
- package/dist/harnesses/devin/DevinSessionParser.d.ts.map +1 -0
- package/dist/harnesses/devin/DevinSessionParser.js +166 -0
- package/dist/harnesses/devin/DevinSessionParser.js.map +1 -0
- package/dist/harnesses/devin/readiness.d.ts +3 -0
- package/dist/harnesses/devin/readiness.d.ts.map +1 -0
- package/dist/harnesses/devin/readiness.js +39 -0
- package/dist/harnesses/devin/readiness.js.map +1 -0
- package/dist/harnesses/index.d.ts.map +1 -1
- package/dist/harnesses/index.js +3 -1
- package/dist/harnesses/index.js.map +1 -1
- package/dist/harnesses/opencode/readiness.d.ts +3 -0
- package/dist/harnesses/opencode/readiness.d.ts.map +1 -0
- package/dist/harnesses/opencode/readiness.js +50 -0
- package/dist/harnesses/opencode/readiness.js.map +1 -0
- package/dist/harnesses/pi/credentials.d.ts +22 -0
- package/dist/harnesses/pi/credentials.d.ts.map +1 -0
- package/dist/harnesses/pi/credentials.js +98 -0
- package/dist/harnesses/pi/credentials.js.map +1 -0
- package/dist/harnesses/pi/readiness.d.ts +3 -0
- package/dist/harnesses/pi/readiness.d.ts.map +1 -0
- package/dist/harnesses/pi/readiness.js +96 -0
- package/dist/harnesses/pi/readiness.js.map +1 -0
- package/dist/harnesses/readiness/AgentReadiness.d.ts +6 -0
- package/dist/harnesses/readiness/AgentReadiness.d.ts.map +1 -0
- package/dist/harnesses/readiness/AgentReadiness.js +70 -0
- package/dist/harnesses/readiness/AgentReadiness.js.map +1 -0
- package/dist/harnesses/readiness/checks.d.ts +31 -0
- package/dist/harnesses/readiness/checks.d.ts.map +1 -0
- package/dist/harnesses/readiness/checks.js +270 -0
- package/dist/harnesses/readiness/checks.js.map +1 -0
- package/dist/{readiness/AgentReadiness.d.ts → harnesses/readiness/types.d.ts} +19 -10
- package/dist/harnesses/readiness/types.d.ts.map +1 -0
- package/dist/harnesses/readiness/types.js +4 -0
- package/dist/harnesses/readiness/types.js.map +1 -0
- package/dist/harnesses/runtimeProfiles.d.ts +11 -0
- package/dist/harnesses/runtimeProfiles.d.ts.map +1 -0
- package/dist/harnesses/runtimeProfiles.js +100 -0
- package/dist/harnesses/runtimeProfiles.js.map +1 -0
- package/dist/index.d.ts +16 -42
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -23
- package/dist/index.js.map +1 -1
- package/dist/runtime/ManagedAgentRuntime.d.ts +3 -3
- package/dist/runtime/ManagedAgentRuntime.d.ts.map +1 -1
- package/dist/runtime/ManagedAgentRuntime.js +6 -20
- package/dist/runtime/ManagedAgentRuntime.js.map +1 -1
- package/dist/runtime/herdr/HerdrAgentDiscovery.d.ts.map +1 -1
- package/dist/runtime/herdr/HerdrAgentDiscovery.js +2 -43
- package/dist/runtime/herdr/HerdrAgentDiscovery.js.map +1 -1
- package/dist/runtime/tmux/PidPolling.d.ts +1 -1
- package/dist/runtime/tmux/PidPolling.d.ts.map +1 -1
- package/dist/runtime/tmux/PidPolling.js.map +1 -1
- package/dist/runtime/tmux/TmuxAgentRuntime.d.ts +1 -1
- package/dist/runtime/tmux/TmuxAgentRuntime.d.ts.map +1 -1
- package/dist/runtime/tmux/TmuxAgentRuntime.js +1 -1
- package/dist/runtime/tmux/TmuxAgentRuntime.js.map +1 -1
- package/dist/runtime/tmux/TmuxManager.d.ts +12 -0
- package/dist/runtime/tmux/TmuxManager.d.ts.map +1 -0
- package/dist/{terminal → runtime/tmux}/TmuxManager.js +9 -28
- package/dist/runtime/tmux/TmuxManager.js.map +1 -0
- package/dist/runtime/types.d.ts +1 -1
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/types.js.map +1 -1
- package/dist/terminal/TerminalFocusManager.d.ts +4 -32
- package/dist/terminal/TerminalFocusManager.d.ts.map +1 -1
- package/dist/terminal/TerminalFocusManager.js +17 -267
- package/dist/terminal/TerminalFocusManager.js.map +1 -1
- package/dist/terminal/TtyWriter.d.ts +1 -44
- package/dist/terminal/TtyWriter.d.ts.map +1 -1
- package/dist/terminal/TtyWriter.js +12 -347
- package/dist/terminal/TtyWriter.js.map +1 -1
- package/dist/terminal/backends/ghostty.d.ts +3 -0
- package/dist/terminal/backends/ghostty.d.ts.map +1 -0
- package/dist/terminal/backends/ghostty.js +161 -0
- package/dist/terminal/backends/ghostty.js.map +1 -0
- package/dist/terminal/backends/index.d.ts +5 -0
- package/dist/terminal/backends/index.d.ts.map +1 -0
- package/dist/terminal/backends/index.js +21 -0
- package/dist/terminal/backends/index.js.map +1 -0
- package/dist/terminal/backends/iterm2.d.ts +3 -0
- package/dist/terminal/backends/iterm2.d.ts.map +1 -0
- package/dist/terminal/backends/iterm2.js +135 -0
- package/dist/terminal/backends/iterm2.js.map +1 -0
- package/dist/terminal/backends/shared.d.ts +9 -0
- package/dist/terminal/backends/shared.d.ts.map +1 -0
- package/dist/terminal/backends/shared.js +38 -0
- package/dist/terminal/backends/shared.js.map +1 -0
- package/dist/terminal/backends/terminal-app.d.ts +3 -0
- package/dist/terminal/backends/terminal-app.d.ts.map +1 -0
- package/dist/terminal/backends/terminal-app.js +129 -0
- package/dist/terminal/backends/terminal-app.js.map +1 -0
- package/dist/terminal/backends/tmux.d.ts +3 -0
- package/dist/terminal/backends/tmux.d.ts.map +1 -0
- package/dist/terminal/backends/tmux.js +76 -0
- package/dist/terminal/backends/tmux.js.map +1 -0
- package/dist/terminal/backends/wezterm.d.ts +3 -0
- package/dist/terminal/backends/wezterm.d.ts.map +1 -0
- package/dist/terminal/backends/wezterm.js +71 -0
- package/dist/terminal/backends/wezterm.js.map +1 -0
- package/dist/terminal/types.d.ts +22 -0
- package/dist/terminal/types.d.ts.map +1 -0
- package/dist/terminal/types.js +11 -0
- package/dist/terminal/types.js.map +1 -0
- package/dist/utils/process.d.ts +2 -0
- package/dist/utils/process.d.ts.map +1 -1
- package/dist/utils/process.js +3 -0
- package/dist/utils/process.js.map +1 -1
- package/package.json +1 -1
- package/src/AgentManager.ts +1 -1
- package/src/__tests__/capacity/anthropic.test.ts +105 -0
- package/src/__tests__/capacity/boundaries.test.ts +36 -0
- package/src/__tests__/capacity/claude.test.ts +3 -8
- package/src/__tests__/capacity/codex.test.ts +12 -35
- package/src/__tests__/capacity/fixtures/openai-codex-auth.json +1 -1
- package/src/__tests__/capacity/openai.test.ts +15 -15
- package/src/__tests__/capacity/wham.test.ts +1 -1
- package/src/__tests__/capacity/zai.test.ts +27 -62
- package/src/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.ts +2 -2
- package/src/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.ts +1 -1
- package/src/__tests__/harnesses/codex/durable/CodexCliProbe.test.ts +14 -19
- package/src/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.ts +3 -3
- package/src/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.ts +24 -30
- package/src/__tests__/harnesses/codex/durable/CodexPrintRunner.test.ts +4 -8
- package/src/__tests__/harnesses/devin/DevinAdapter.test.ts +292 -0
- package/src/__tests__/harnesses/devin/DevinAgentMapper.test.ts +88 -0
- package/src/__tests__/harnesses/devin/DevinSessionLocator.test.ts +139 -0
- package/src/__tests__/harnesses/devin/DevinSessionParser.test.ts +218 -0
- package/src/__tests__/harnesses/devin/fixtures.ts +144 -0
- package/src/__tests__/harnesses/pi/durable/PiCliProbe.test.ts +7 -11
- package/src/__tests__/harnesses/pi/durable/PiPrintAgentService.test.ts +19 -22
- package/src/__tests__/harnesses/pi/durable/PiPrintRunner.test.ts +7 -8
- package/src/__tests__/{readiness → harnesses/readiness}/AgentReadiness.test.ts +77 -9
- package/src/__tests__/harnesses/runtimeProfiles.test.ts +110 -0
- package/src/__tests__/print/DurableAgent.test.ts +4 -13
- package/src/__tests__/print/DurableAgentRepository.test.ts +1 -13
- package/src/__tests__/runtime/ManagedAgentRuntime.test.ts +1 -1
- package/src/__tests__/terminal/GhosttyBackend.test.ts +271 -0
- package/src/__tests__/terminal/TmuxManager.test.ts +1 -1
- package/src/adapters/AgentAdapter.ts +1 -0
- package/src/capacity/index.ts +29 -23
- package/src/capacity/{claude.ts → providers/anthropic.ts} +16 -131
- package/src/capacity/providers/openai-platform.ts +150 -0
- package/src/capacity/{wham.ts → providers/openai-subscription.ts} +86 -8
- package/src/capacity/{zai.ts → providers/zai.ts} +29 -111
- package/src/capacity/sources/claude.ts +30 -0
- package/src/capacity/{codex.ts → sources/codex.ts} +54 -124
- package/src/capacity/sources/pi.ts +131 -0
- package/src/capacity/types.ts +3 -0
- package/src/harnesses/claude/credentials.ts +122 -0
- package/src/harnesses/claude/readiness.ts +69 -0
- package/src/harnesses/codex/credentials.ts +81 -0
- package/src/harnesses/codex/readiness.ts +72 -0
- package/src/harnesses/copilot/readiness.ts +33 -0
- package/src/harnesses/devin/DevinAdapter.ts +224 -0
- package/src/harnesses/devin/DevinAgentMapper.ts +43 -0
- package/src/harnesses/devin/DevinSessionLocator.ts +230 -0
- package/src/harnesses/devin/DevinSessionParser.ts +236 -0
- package/src/harnesses/devin/readiness.ts +36 -0
- package/src/harnesses/index.ts +2 -0
- package/src/harnesses/opencode/readiness.ts +48 -0
- package/src/harnesses/pi/credentials.ts +129 -0
- package/src/harnesses/pi/readiness.ts +104 -0
- package/src/harnesses/readiness/AgentReadiness.ts +89 -0
- package/src/harnesses/readiness/checks.ts +336 -0
- package/src/harnesses/readiness/types.ts +90 -0
- package/src/{utils/agents.ts → harnesses/runtimeProfiles.ts} +35 -38
- package/src/index.ts +15 -128
- package/src/runtime/ManagedAgentRuntime.ts +7 -22
- package/src/runtime/herdr/HerdrAgentDiscovery.ts +3 -19
- package/src/runtime/tmux/PidPolling.ts +1 -1
- package/src/runtime/tmux/TmuxAgentRuntime.ts +1 -1
- package/src/{terminal → runtime/tmux}/TmuxManager.ts +9 -30
- package/src/runtime/types.ts +1 -1
- package/src/terminal/TerminalFocusManager.ts +19 -292
- package/src/terminal/TtyWriter.ts +15 -335
- package/src/terminal/backends/ghostty.ts +180 -0
- package/src/terminal/backends/index.ts +23 -0
- package/src/terminal/backends/iterm2.ts +126 -0
- package/src/terminal/backends/shared.ts +47 -0
- package/src/terminal/backends/terminal-app.ts +122 -0
- package/src/terminal/backends/tmux.ts +62 -0
- package/src/terminal/backends/wezterm.ts +65 -0
- package/src/terminal/types.ts +23 -0
- package/src/utils/process.ts +5 -0
- package/dist/__tests__/readiness/AgentReadiness.test.js.map +0 -1
- package/dist/__tests__/utils/agents.test.js +0 -93
- package/dist/__tests__/utils/agents.test.js.map +0 -1
- package/dist/capacity/claude.d.ts +0 -17
- package/dist/capacity/claude.d.ts.map +0 -1
- package/dist/capacity/claude.js.map +0 -1
- package/dist/capacity/codex.d.ts.map +0 -1
- package/dist/capacity/codex.js.map +0 -1
- package/dist/capacity/openai.d.ts +0 -47
- package/dist/capacity/openai.d.ts.map +0 -1
- package/dist/capacity/openai.js +0 -307
- package/dist/capacity/openai.js.map +0 -1
- package/dist/capacity/wham.d.ts +0 -16
- package/dist/capacity/wham.d.ts.map +0 -1
- package/dist/capacity/wham.js +0 -66
- package/dist/capacity/wham.js.map +0 -1
- package/dist/capacity/zai.d.ts +0 -14
- package/dist/capacity/zai.d.ts.map +0 -1
- package/dist/capacity/zai.js.map +0 -1
- package/dist/readiness/AgentReadiness.d.ts.map +0 -1
- package/dist/readiness/AgentReadiness.js +0 -614
- package/dist/readiness/AgentReadiness.js.map +0 -1
- package/dist/terminal/TmuxManager.d.ts +0 -28
- package/dist/terminal/TmuxManager.d.ts.map +0 -1
- package/dist/terminal/TmuxManager.js.map +0 -1
- package/dist/terminal/index.d.ts +0 -5
- package/dist/terminal/index.d.ts.map +0 -1
- package/dist/terminal/index.js +0 -5
- package/dist/terminal/index.js.map +0 -1
- package/dist/utils/agents.d.ts +0 -16
- package/dist/utils/agents.d.ts.map +0 -1
- package/dist/utils/agents.js +0 -117
- package/dist/utils/agents.js.map +0 -1
- package/dist/utils/index.d.ts +0 -8
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -6
- package/dist/utils/index.js.map +0 -1
- package/src/__tests__/utils/agents.test.ts +0 -105
- package/src/capacity/openai.ts +0 -355
- package/src/readiness/AgentReadiness.ts +0 -730
- package/src/terminal/index.ts +0 -4
- package/src/utils/index.ts +0 -14
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iterm2.d.ts","sourceRoot":"","sources":["../../../src/terminal/backends/iterm2.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AA2BjE,eAAO,MAAM,aAAa,EAAE,eA+F3B,CAAC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { execFile } from "child_process";
|
|
2
|
+
import { promisify } from "util";
|
|
3
|
+
import { escapeAppleScript } from "../../utils/applescript.js";
|
|
4
|
+
import { TerminalType } from "../types.js";
|
|
5
|
+
import { appleScriptKeyAction, isProcessRunning, sleep } from "./shared.js";
|
|
6
|
+
const execFileAsync = promisify(execFile);
|
|
7
|
+
function sessionScript(tty, sessionCommand) {
|
|
8
|
+
return `
|
|
9
|
+
tell application "iTerm"
|
|
10
|
+
set targetSession to missing value
|
|
11
|
+
repeat with w in windows
|
|
12
|
+
repeat with t in tabs of w
|
|
13
|
+
repeat with s in sessions of t
|
|
14
|
+
if tty of s is "${escapeAppleScript(tty)}" then
|
|
15
|
+
set targetSession to s
|
|
16
|
+
exit repeat
|
|
17
|
+
end if
|
|
18
|
+
end repeat
|
|
19
|
+
if targetSession is not missing value then exit repeat
|
|
20
|
+
end repeat
|
|
21
|
+
if targetSession is not missing value then exit repeat
|
|
22
|
+
end repeat
|
|
23
|
+
if targetSession is missing value then return "not_found"
|
|
24
|
+
tell targetSession to ${sessionCommand}
|
|
25
|
+
end tell
|
|
26
|
+
return "ok"`;
|
|
27
|
+
}
|
|
28
|
+
export const iterm2Backend = {
|
|
29
|
+
type: TerminalType.ITERM2,
|
|
30
|
+
label: "iTerm2",
|
|
31
|
+
async find (tty) {
|
|
32
|
+
try {
|
|
33
|
+
if (!await isProcessRunning("iTerm2")) return null;
|
|
34
|
+
const script = `
|
|
35
|
+
tell application "iTerm"
|
|
36
|
+
repeat with w in windows
|
|
37
|
+
repeat with t in tabs of w
|
|
38
|
+
repeat with s in sessions of t
|
|
39
|
+
if tty of s is "${escapeAppleScript(tty)}" then
|
|
40
|
+
return "found"
|
|
41
|
+
end if
|
|
42
|
+
end repeat
|
|
43
|
+
end repeat
|
|
44
|
+
end repeat
|
|
45
|
+
end tell
|
|
46
|
+
`;
|
|
47
|
+
const { stdout } = await execFileAsync("osascript", [
|
|
48
|
+
"-e",
|
|
49
|
+
script
|
|
50
|
+
]);
|
|
51
|
+
return stdout.trim() === "found" ? {
|
|
52
|
+
type: TerminalType.ITERM2,
|
|
53
|
+
identifier: tty,
|
|
54
|
+
tty
|
|
55
|
+
} : null;
|
|
56
|
+
} catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
async focus (location) {
|
|
61
|
+
const script = `
|
|
62
|
+
tell application "iTerm"
|
|
63
|
+
activate
|
|
64
|
+
repeat with w in windows
|
|
65
|
+
repeat with t in tabs of w
|
|
66
|
+
repeat with s in sessions of t
|
|
67
|
+
if tty of s is "${escapeAppleScript(location.tty)}" then
|
|
68
|
+
select s
|
|
69
|
+
return "true"
|
|
70
|
+
end if
|
|
71
|
+
end repeat
|
|
72
|
+
end repeat
|
|
73
|
+
end repeat
|
|
74
|
+
end tell
|
|
75
|
+
`;
|
|
76
|
+
const { stdout } = await execFileAsync("osascript", [
|
|
77
|
+
"-e",
|
|
78
|
+
script
|
|
79
|
+
]);
|
|
80
|
+
return stdout.trim() === "true";
|
|
81
|
+
},
|
|
82
|
+
async send (location, message) {
|
|
83
|
+
const textScript = sessionScript(location.tty, `write text "${escapeAppleScript(message)}" newline no`);
|
|
84
|
+
const { stdout: textResult } = await execFileAsync("osascript", [
|
|
85
|
+
"-e",
|
|
86
|
+
textScript
|
|
87
|
+
]);
|
|
88
|
+
if (textResult.trim() !== "ok") {
|
|
89
|
+
throw new Error(`iTerm2 session not found for TTY ${location.tty}`);
|
|
90
|
+
}
|
|
91
|
+
await sleep(150);
|
|
92
|
+
const enterScript = sessionScript(location.tty, 'write text "" newline yes');
|
|
93
|
+
const { stdout: enterResult } = await execFileAsync("osascript", [
|
|
94
|
+
"-e",
|
|
95
|
+
enterScript
|
|
96
|
+
]);
|
|
97
|
+
if (enterResult.trim() !== "ok") {
|
|
98
|
+
throw new Error(`iTerm2 session disappeared before Enter could be sent for TTY ${location.tty}`);
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
async sendKey (location, key) {
|
|
102
|
+
const script = `
|
|
103
|
+
tell application "iTerm"
|
|
104
|
+
set targetSession to missing value
|
|
105
|
+
repeat with w in windows
|
|
106
|
+
repeat with t in tabs of w
|
|
107
|
+
repeat with s in sessions of t
|
|
108
|
+
if tty of s is "${escapeAppleScript(location.tty)}" then
|
|
109
|
+
set targetSession to s
|
|
110
|
+
set frontmost of w to true
|
|
111
|
+
tell t to select
|
|
112
|
+
tell s to select
|
|
113
|
+
exit repeat
|
|
114
|
+
end if
|
|
115
|
+
end repeat
|
|
116
|
+
if targetSession is not missing value then exit repeat
|
|
117
|
+
end repeat
|
|
118
|
+
if targetSession is not missing value then exit repeat
|
|
119
|
+
end repeat
|
|
120
|
+
if targetSession is missing value then return "not_found"
|
|
121
|
+
activate
|
|
122
|
+
end tell
|
|
123
|
+
tell application "System Events" to ${appleScriptKeyAction(key)}
|
|
124
|
+
return "ok"`;
|
|
125
|
+
const { stdout } = await execFileAsync("osascript", [
|
|
126
|
+
"-e",
|
|
127
|
+
script
|
|
128
|
+
]);
|
|
129
|
+
if (stdout.trim() !== "ok") {
|
|
130
|
+
throw new Error(`iTerm2 session not found for TTY ${location.tty}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
//# sourceMappingURL=iterm2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/terminal/backends/iterm2.ts"],"sourcesContent":["import { execFile } from \"child_process\";\nimport { promisify } from \"util\";\nimport { escapeAppleScript } from \"../../utils/applescript.js\";\nimport { TerminalType, type TerminalBackend } from \"../types.js\";\nimport { appleScriptKeyAction, isProcessRunning, sleep } from \"./shared.js\";\n\nconst execFileAsync = promisify(execFile);\n\nfunction sessionScript(tty: string, sessionCommand: string): string {\n return `\ntell application \"iTerm\"\n set targetSession to missing value\n repeat with w in windows\n repeat with t in tabs of w\n repeat with s in sessions of t\n if tty of s is \"${escapeAppleScript(tty)}\" then\n set targetSession to s\n exit repeat\n end if\n end repeat\n if targetSession is not missing value then exit repeat\n end repeat\n if targetSession is not missing value then exit repeat\n end repeat\n if targetSession is missing value then return \"not_found\"\n tell targetSession to ${sessionCommand}\nend tell\nreturn \"ok\"`;\n}\n\nexport const iterm2Backend: TerminalBackend = {\n type: TerminalType.ITERM2,\n label: \"iTerm2\",\n\n async find(tty) {\n try {\n if (!(await isProcessRunning(\"iTerm2\"))) return null;\n const script = `\n tell application \"iTerm\"\n repeat with w in windows\n repeat with t in tabs of w\n repeat with s in sessions of t\n if tty of s is \"${escapeAppleScript(tty)}\" then\n return \"found\"\n end if\n end repeat\n end repeat\n end repeat\n end tell\n `;\n const { stdout } = await execFileAsync(\"osascript\", [\"-e\", script]);\n return stdout.trim() === \"found\" ? { type: TerminalType.ITERM2, identifier: tty, tty } : null;\n } catch {\n return null;\n }\n },\n\n async focus(location) {\n const script = `\n tell application \"iTerm\"\n activate\n repeat with w in windows\n repeat with t in tabs of w\n repeat with s in sessions of t\n if tty of s is \"${escapeAppleScript(location.tty)}\" then\n select s\n return \"true\"\n end if\n end repeat\n end repeat\n end repeat\n end tell\n `;\n const { stdout } = await execFileAsync(\"osascript\", [\"-e\", script]);\n return stdout.trim() === \"true\";\n },\n\n async send(location, message) {\n const textScript = sessionScript(\n location.tty,\n `write text \"${escapeAppleScript(message)}\" newline no`,\n );\n const { stdout: textResult } = await execFileAsync(\"osascript\", [\"-e\", textScript]);\n if (textResult.trim() !== \"ok\") {\n throw new Error(`iTerm2 session not found for TTY ${location.tty}`);\n }\n await sleep(150);\n const enterScript = sessionScript(location.tty, 'write text \"\" newline yes');\n const { stdout: enterResult } = await execFileAsync(\"osascript\", [\"-e\", enterScript]);\n if (enterResult.trim() !== \"ok\") {\n throw new Error(\n `iTerm2 session disappeared before Enter could be sent for TTY ${location.tty}`,\n );\n }\n },\n\n async sendKey(location, key) {\n const script = `\ntell application \"iTerm\"\n set targetSession to missing value\n repeat with w in windows\n repeat with t in tabs of w\n repeat with s in sessions of t\n if tty of s is \"${escapeAppleScript(location.tty)}\" then\n set targetSession to s\n set frontmost of w to true\n tell t to select\n tell s to select\n exit repeat\n end if\n end repeat\n if targetSession is not missing value then exit repeat\n end repeat\n if targetSession is not missing value then exit repeat\n end repeat\n if targetSession is missing value then return \"not_found\"\n activate\nend tell\ntell application \"System Events\" to ${appleScriptKeyAction(key)}\nreturn \"ok\"`;\n const { stdout } = await execFileAsync(\"osascript\", [\"-e\", script]);\n if (stdout.trim() !== \"ok\") {\n throw new Error(`iTerm2 session not found for TTY ${location.tty}`);\n }\n },\n};\n"],"names":["execFile","promisify","escapeAppleScript","TerminalType","appleScriptKeyAction","isProcessRunning","sleep","execFileAsync","sessionScript","tty","sessionCommand","iterm2Backend","type","ITERM2","label","find","script","stdout","trim","identifier","focus","location","send","message","textScript","textResult","Error","enterScript","enterResult","sendKey","key"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,SAAS,QAAQ,OAAO;AACjC,SAASC,iBAAiB,QAAQ,6BAA6B;AAC/D,SAASC,YAAY,QAA8B,cAAc;AACjE,SAASC,oBAAoB,EAAEC,gBAAgB,EAAEC,KAAK,QAAQ,cAAc;AAE5E,MAAMC,gBAAgBN,UAAUD;AAEhC,SAASQ,cAAcC,GAAW,EAAEC,cAAsB;IACxD,OAAO,CAAC;;;;;;w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rB,cAAc,aAAa;YAAC;YAAMoB;SAAY;QACpF,IAAIC,YAAYV,IAAI,OAAO,MAAM;YAC/B,MAAM,IAAIQ,MACR,CAAC,8DAA8D,EAAEL,SAASZ,GAAG,EAAE;QAEnF;IACF;IAEA,MAAMoB,SAAQR,QAAQ,EAAES,GAAG;QACzB,MAAMd,SAAS,CAAC;;;;;;wBAMI,EAAEd,kBAAkBmB,SAASZ,GAAG,EAAE;;;;;;;;;;;;;;;oCAetB,EAAEL,qBAAqB0B,KAAK;WACrD,CAAC;QACR,MAAM,EAAEb,MAAM,EAAE,GAAG,MAAMV,cAAc,aAAa;YAAC;YAAMS;SAAO;QAClE,IAAIC,OAAOC,IAAI,OAAO,MAAM;YAC1B,MAAM,IAAIQ,MAAM,CAAC,iCAAiC,EAAEL,SAASZ,GAAG,EAAE;QACpE;IACF;AACF,EAAE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const CARRIAGE_RETURN = "\r";
|
|
2
|
+
export declare const ESCAPE_BYTE = "\u001B";
|
|
3
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
4
|
+
export declare function execFileWithInput(command: string, args: string[], input: string): Promise<void>;
|
|
5
|
+
export declare function appleScriptKeyAction(key: string): string;
|
|
6
|
+
/** Whether a `ps` comm value (bare name or full executable path) is `name`. */
|
|
7
|
+
export declare function isProcessName(comm: string, name: string): boolean;
|
|
8
|
+
export declare function isProcessRunning(name: string): Promise<boolean>;
|
|
9
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/terminal/backends/shared.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,eAAe,OAAS,CAAC;AACtC,eAAO,MAAM,WAAW,WAAS,CAAC;AAGlC,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAYf;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGxD;AAED,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAEjE;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAMrE"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { execFile } from "child_process";
|
|
2
|
+
import { promisify } from "util";
|
|
3
|
+
import { escapeAppleScript } from "../../utils/applescript.js";
|
|
4
|
+
export const CARRIAGE_RETURN = "\x0d";
|
|
5
|
+
export const ESCAPE_BYTE = "\x1b";
|
|
6
|
+
const execFileAsync = promisify(execFile);
|
|
7
|
+
export function sleep(ms) {
|
|
8
|
+
return new Promise((resolve)=>setTimeout(resolve, ms));
|
|
9
|
+
}
|
|
10
|
+
export async function execFileWithInput(command, args, input) {
|
|
11
|
+
await new Promise((resolve, reject)=>{
|
|
12
|
+
const child = execFile(command, args, (error)=>{
|
|
13
|
+
if (error) reject(error);
|
|
14
|
+
else resolve();
|
|
15
|
+
});
|
|
16
|
+
if (!child.stdin) {
|
|
17
|
+
reject(new Error(`Cannot write stdin to ${command}`));
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
child.stdin.end(input);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export function appleScriptKeyAction(key) {
|
|
24
|
+
if (key === ESCAPE_BYTE) return "key code 53";
|
|
25
|
+
return `keystroke "${escapeAppleScript(key)}"`;
|
|
26
|
+
}
|
|
27
|
+
/** Whether a `ps` comm value (bare name or full executable path) is `name`. */ export function isProcessName(comm, name) {
|
|
28
|
+
return comm === name || comm.endsWith(`/${name}`);
|
|
29
|
+
}
|
|
30
|
+
export async function isProcessRunning(name) {
|
|
31
|
+
const { stdout } = await execFileAsync("ps", [
|
|
32
|
+
"-Axo",
|
|
33
|
+
"comm"
|
|
34
|
+
]);
|
|
35
|
+
return stdout.split("\n").map((line)=>line.trim()).some((command)=>isProcessName(command, name));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/terminal/backends/shared.ts"],"sourcesContent":["import { execFile } from \"child_process\";\nimport { promisify } from \"util\";\nimport { escapeAppleScript } from \"../../utils/applescript.js\";\n\nexport const CARRIAGE_RETURN = \"\\x0d\";\nexport const ESCAPE_BYTE = \"\\x1b\";\nconst execFileAsync = promisify(execFile);\n\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport async function execFileWithInput(\n command: string,\n args: string[],\n input: string,\n): Promise<void> {\n await new Promise<void>((resolve, reject) => {\n const child = execFile(command, args, (error) => {\n if (error) reject(error);\n else resolve();\n });\n if (!child.stdin) {\n reject(new Error(`Cannot write stdin to ${command}`));\n return;\n }\n child.stdin.end(input);\n });\n}\n\nexport function appleScriptKeyAction(key: string): string {\n if (key === ESCAPE_BYTE) return \"key code 53\";\n return `keystroke \"${escapeAppleScript(key)}\"`;\n}\n\n/** Whether a `ps` comm value (bare name or full executable path) is `name`. */\nexport function isProcessName(comm: string, name: string): boolean {\n return comm === name || comm.endsWith(`/${name}`);\n}\n\nexport async function isProcessRunning(name: string): Promise<boolean> {\n const { stdout } = await execFileAsync(\"ps\", [\"-Axo\", \"comm\"]);\n return stdout\n .split(\"\\n\")\n .map((line) => line.trim())\n .some((command) => isProcessName(command, name));\n}\n"],"names":["execFile","promisify","escapeAppleScript","CARRIAGE_RETURN","ESCAPE_BYTE","execFileAsync","sleep","ms","Promise","resolve","setTimeout","execFileWithInput","command","args","input","reject","child","error","stdin","Error","end","appleScriptKeyAction","key","isProcessName","comm","name","endsWith","isProcessRunning","stdout","split","map","line","trim","some"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,SAAS,QAAQ,OAAO;AACjC,SAASC,iBAAiB,QAAQ,6BAA6B;AAE/D,OAAO,MAAMC,kBAAkB,OAAO;AACtC,OAAO,MAAMC,cAAc,OAAO;AAClC,MAAMC,gBAAgBJ,UAAUD;AAEhC,OAAO,SAASM,MAAMC,EAAU;IAC9B,OAAO,IAAIC,QAAQ,CAACC,UAAYC,WAAWD,SAASF;AACtD;AAEA,OAAO,eAAeI,kBACpBC,OAAe,EACfC,IAAc,EACdC,KAAa;IAEb,MAAM,IAAIN,QAAc,CAACC,SAASM;QAChC,MAAMC,QAAQhB,SAASY,SAASC,MAAM,CAACI;YACrC,IAAIA,OAAOF,OAAOE;iBACbR;QACP;QACA,IAAI,CAACO,MAAME,KAAK,EAAE;YAChBH,OAAO,IAAII,MAAM,CAAC,sBAAsB,EAAEP,SAAS;YACnD;QACF;QACAI,MAAME,KAAK,CAACE,GAAG,CAACN;IAClB;AACF;AAEA,OAAO,SAASO,qBAAqBC,GAAW;IAC9C,IAAIA,QAAQlB,aAAa,OAAO;IAChC,OAAO,CAAC,WAAW,EAAEF,kBAAkBoB,KAAK,CAAC,CAAC;AAChD;AAEA,6EAA6E,GAC7E,OAAO,SAASC,cAAcC,IAAY,EAAEC,IAAY;IACtD,OAAOD,SAASC,QAAQD,KAAKE,QAAQ,CAAC,CAAC,CAAC,EAAED,MAAM;AAClD;AAEA,OAAO,eAAeE,iBAAiBF,IAAY;IACjD,MAAM,EAAEG,MAAM,EAAE,GAAG,MAAMvB,cAAc,MAAM;QAAC;QAAQ;KAAO;IAC7D,OAAOuB,OACJC,KAAK,CAAC,MACNC,GAAG,CAAC,CAACC,OAASA,KAAKC,IAAI,IACvBC,IAAI,CAAC,CAACrB,UAAYW,cAAcX,SAASa;AAC9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-app.d.ts","sourceRoot":"","sources":["../../../src/terminal/backends/terminal-app.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAyBjE,eAAO,MAAM,kBAAkB,EAAE,eA6FhC,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { execFile } from "child_process";
|
|
2
|
+
import { promisify } from "util";
|
|
3
|
+
import { escapeAppleScript } from "../../utils/applescript.js";
|
|
4
|
+
import { TerminalType } from "../types.js";
|
|
5
|
+
import { appleScriptKeyAction, isProcessRunning, sleep } from "./shared.js";
|
|
6
|
+
const execFileAsync = promisify(execFile);
|
|
7
|
+
function tabScript(tty, command) {
|
|
8
|
+
return `
|
|
9
|
+
tell application "Terminal"
|
|
10
|
+
set targetTab to missing value
|
|
11
|
+
repeat with w in windows
|
|
12
|
+
repeat with i from 1 to count of tabs of w
|
|
13
|
+
set t to tab i of w
|
|
14
|
+
if tty of t is "${escapeAppleScript(tty)}" then
|
|
15
|
+
set targetTab to t
|
|
16
|
+
exit repeat
|
|
17
|
+
end if
|
|
18
|
+
end repeat
|
|
19
|
+
if targetTab is not missing value then exit repeat
|
|
20
|
+
end repeat
|
|
21
|
+
if targetTab is missing value then return "not_found"
|
|
22
|
+
${command}
|
|
23
|
+
end tell
|
|
24
|
+
return "ok"`;
|
|
25
|
+
}
|
|
26
|
+
export const terminalAppBackend = {
|
|
27
|
+
type: TerminalType.TERMINAL_APP,
|
|
28
|
+
label: "Terminal.app",
|
|
29
|
+
async find (tty) {
|
|
30
|
+
try {
|
|
31
|
+
if (!await isProcessRunning("Terminal")) return null;
|
|
32
|
+
const script = `
|
|
33
|
+
tell application "Terminal"
|
|
34
|
+
repeat with w in windows
|
|
35
|
+
repeat with t in tabs of w
|
|
36
|
+
if tty of t is "${escapeAppleScript(tty)}" then
|
|
37
|
+
return "found"
|
|
38
|
+
end if
|
|
39
|
+
end repeat
|
|
40
|
+
end repeat
|
|
41
|
+
end tell
|
|
42
|
+
`;
|
|
43
|
+
const { stdout } = await execFileAsync("osascript", [
|
|
44
|
+
"-e",
|
|
45
|
+
script
|
|
46
|
+
]);
|
|
47
|
+
return stdout.trim() === "found" ? {
|
|
48
|
+
type: TerminalType.TERMINAL_APP,
|
|
49
|
+
identifier: tty,
|
|
50
|
+
tty
|
|
51
|
+
} : null;
|
|
52
|
+
} catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
async focus (location) {
|
|
57
|
+
const script = `
|
|
58
|
+
tell application "Terminal"
|
|
59
|
+
activate
|
|
60
|
+
repeat with w in windows
|
|
61
|
+
repeat with t in tabs of w
|
|
62
|
+
if tty of t is "${escapeAppleScript(location.tty)}" then
|
|
63
|
+
set index of w to 1
|
|
64
|
+
set selected tab of w to t
|
|
65
|
+
return "true"
|
|
66
|
+
end if
|
|
67
|
+
end repeat
|
|
68
|
+
end repeat
|
|
69
|
+
end tell
|
|
70
|
+
`;
|
|
71
|
+
const { stdout } = await execFileAsync("osascript", [
|
|
72
|
+
"-e",
|
|
73
|
+
script
|
|
74
|
+
]);
|
|
75
|
+
return stdout.trim() === "true";
|
|
76
|
+
},
|
|
77
|
+
async send (location, message) {
|
|
78
|
+
const textScript = tabScript(location.tty, `do script "${escapeAppleScript(message)}" in targetTab`);
|
|
79
|
+
const { stdout: textResult } = await execFileAsync("osascript", [
|
|
80
|
+
"-e",
|
|
81
|
+
textScript
|
|
82
|
+
]);
|
|
83
|
+
if (textResult.trim() !== "ok") {
|
|
84
|
+
throw new Error(`Terminal.app tab not found for TTY ${location.tty}`);
|
|
85
|
+
}
|
|
86
|
+
await sleep(150);
|
|
87
|
+
const enterScript = tabScript(location.tty, 'do script "" in targetTab');
|
|
88
|
+
const { stdout: enterResult } = await execFileAsync("osascript", [
|
|
89
|
+
"-e",
|
|
90
|
+
enterScript
|
|
91
|
+
]);
|
|
92
|
+
if (enterResult.trim() !== "ok") {
|
|
93
|
+
throw new Error(`Terminal.app tab disappeared before Enter could be sent for TTY ${location.tty}`);
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
async sendKey (location, key) {
|
|
97
|
+
const script = `
|
|
98
|
+
tell application "Terminal"
|
|
99
|
+
set targetTab to missing value
|
|
100
|
+
set targetWindow to missing value
|
|
101
|
+
repeat with w in windows
|
|
102
|
+
repeat with i from 1 to count of tabs of w
|
|
103
|
+
set t to tab i of w
|
|
104
|
+
if tty of t is "${escapeAppleScript(location.tty)}" then
|
|
105
|
+
set targetTab to t
|
|
106
|
+
set targetWindow to w
|
|
107
|
+
exit repeat
|
|
108
|
+
end if
|
|
109
|
+
end repeat
|
|
110
|
+
if targetTab is not missing value then exit repeat
|
|
111
|
+
end repeat
|
|
112
|
+
if targetTab is missing value then return "not_found"
|
|
113
|
+
set selected of targetTab to true
|
|
114
|
+
set frontmost of targetWindow to true
|
|
115
|
+
activate
|
|
116
|
+
end tell
|
|
117
|
+
tell application "System Events" to ${appleScriptKeyAction(key)}
|
|
118
|
+
return "ok"`;
|
|
119
|
+
const { stdout } = await execFileAsync("osascript", [
|
|
120
|
+
"-e",
|
|
121
|
+
script
|
|
122
|
+
]);
|
|
123
|
+
if (stdout.trim() !== "ok") {
|
|
124
|
+
throw new Error(`Terminal.app tab not found for TTY ${location.tty}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
//# sourceMappingURL=terminal-app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/terminal/backends/terminal-app.ts"],"sourcesContent":["import { execFile } from \"child_process\";\nimport { promisify } from \"util\";\nimport { escapeAppleScript } from \"../../utils/applescript.js\";\nimport { TerminalType, type TerminalBackend } from \"../types.js\";\nimport { appleScriptKeyAction, isProcessRunning, sleep } from \"./shared.js\";\n\nconst execFileAsync = promisify(execFile);\n\nfunction tabScript(tty: string, command: string): string {\n return `\ntell application \"Terminal\"\n set targetTab to missing value\n repeat with w in windows\n repeat with i from 1 to count of tabs of w\n set t to tab i of w\n if tty of t is \"${escapeAppleScript(tty)}\" then\n set targetTab to t\n exit repeat\n end if\n end repeat\n if targetTab is not missing value then exit repeat\n end repeat\n if targetTab is missing value then return \"not_found\"\n ${command}\nend tell\nreturn \"ok\"`;\n}\n\nexport const terminalAppBackend: TerminalBackend = {\n type: TerminalType.TERMINAL_APP,\n label: \"Terminal.app\",\n\n async find(tty) {\n try {\n if (!(await isProcessRunning(\"Terminal\"))) return null;\n const script = `\n tell application \"Terminal\"\n repeat with w in windows\n repeat with t in tabs of w\n if tty of t is \"${escapeAppleScript(tty)}\" then\n return \"found\"\n end if\n end repeat\n end repeat\n end tell\n `;\n const { stdout } = await execFileAsync(\"osascript\", [\"-e\", script]);\n return stdout.trim() === \"found\"\n ? { type: TerminalType.TERMINAL_APP, identifier: tty, tty }\n : null;\n } catch {\n return null;\n }\n },\n\n async focus(location) {\n const script = `\n tell application \"Terminal\"\n activate\n repeat with w in windows\n repeat with t in tabs of w\n if tty of t is \"${escapeAppleScript(location.tty)}\" then\n set index of w to 1\n set selected tab of w to t\n return \"true\"\n end if\n end repeat\n end repeat\n end tell\n `;\n const { stdout } = await execFileAsync(\"osascript\", [\"-e\", script]);\n return stdout.trim() === \"true\";\n },\n\n async send(location, message) {\n const textScript = tabScript(\n location.tty,\n `do script \"${escapeAppleScript(message)}\" in targetTab`,\n );\n const { stdout: textResult } = await execFileAsync(\"osascript\", [\"-e\", textScript]);\n if (textResult.trim() !== \"ok\") {\n throw new Error(`Terminal.app tab not found for TTY ${location.tty}`);\n }\n await sleep(150);\n const enterScript = tabScript(location.tty, 'do script \"\" in targetTab');\n const { stdout: enterResult } = await execFileAsync(\"osascript\", [\"-e\", enterScript]);\n if (enterResult.trim() !== \"ok\") {\n throw new Error(\n `Terminal.app tab disappeared before Enter could be sent for TTY ${location.tty}`,\n );\n }\n },\n\n async sendKey(location, key) {\n const script = `\ntell application \"Terminal\"\n set targetTab to missing value\n set targetWindow to missing value\n repeat with w in windows\n repeat with i from 1 to count of tabs of w\n set t to tab i of w\n if tty of t is \"${escapeAppleScript(location.tty)}\" then\n set targetTab to t\n set targetWindow to w\n exit repeat\n end if\n end repeat\n if targetTab is not missing value then exit repeat\n end repeat\n if targetTab is missing value then return \"not_found\"\n set selected of targetTab to true\n set frontmost of targetWindow to true\n activate\nend tell\ntell application \"System Events\" to ${appleScriptKeyAction(key)}\nreturn \"ok\"`;\n const { stdout } = await execFileAsync(\"osascript\", [\"-e\", script]);\n if (stdout.trim() !== \"ok\") {\n throw new Error(`Terminal.app tab not found for TTY ${location.tty}`);\n }\n },\n};\n"],"names":["execFile","promisify","escapeAppleScript","TerminalType","appleScriptKeyAction","isProcessRunning","sleep","execFileAsync","tabScript","tty","command","terminalAppBackend","type","TERMINAL_APP","label","find","script","stdout","trim","identifier","focus","location","send","message","textScript","textResult","Error","enterScript","enterResult","sendKey","key"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,SAAS,QAAQ,OAAO;AACjC,SAASC,iBAAiB,QAAQ,6BAA6B;AAC/D,SAASC,YAAY,QAA8B,cAAc;AACjE,SAASC,oBAAoB,EAAEC,gBAAgB,EAAEC,KAAK,QAAQ,cAAc;AAE5E,MAAMC,gBAAgBN,UAAUD;AAEhC,SAASQ,UAAUC,GAAW,EAAEC,OAAe;IAC7C,OAAO,CAAC;;;;;;sBAMY,EAAER,kBAAkBO,KAAK;;;;;;;;EAQ7C,EAAEC,QAAQ;;WAED,CAAC;AACZ;AAEA,OAAO,MAAMC,qBAAsC;IACjDC,MAAMT,aAAaU,YAAY;IAC/BC,OAAO;IAEP,MAAMC,MAAKN,GAAG;QACZ,IAAI;YACF,IAAI,CAAE,MAAMJ,iBAAiB,aAAc,OAAO;YAClD,MAAMW,SAAS,CAAC;;;;8BAIQ,EAAEd,kBAAkBO,KAAK;;;;;;MAMjD,CAAC;YACD,MAAM,EAAEQ,MAAM,EAAE,GAAG,MAAMV,cAA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MAAMV,cAAc,aAAa;YAAC;YAAMS;SAAO;QAClE,IAAIC,OAAOC,IAAI,OAAO,MAAM;YAC1B,MAAM,IAAIQ,MAAM,CAAC,mCAAmC,EAAEL,SAASZ,GAAG,EAAE;QACtE;IACF;AACF,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tmux.d.ts","sourceRoot":"","sources":["../../../src/terminal/backends/tmux.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAKjE,eAAO,MAAM,WAAW,EAAE,eAsDzB,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { execFile } from "child_process";
|
|
2
|
+
import { promisify } from "util";
|
|
3
|
+
import { TerminalType } from "../types.js";
|
|
4
|
+
import { ESCAPE_BYTE, execFileWithInput, sleep } from "./shared.js";
|
|
5
|
+
const execFileAsync = promisify(execFile);
|
|
6
|
+
export const tmuxBackend = {
|
|
7
|
+
type: TerminalType.TMUX,
|
|
8
|
+
label: "tmux",
|
|
9
|
+
async find (tty) {
|
|
10
|
+
try {
|
|
11
|
+
const { stdout } = await execFileAsync("tmux", [
|
|
12
|
+
"list-panes",
|
|
13
|
+
"-a",
|
|
14
|
+
"-F",
|
|
15
|
+
"#{pane_tty}|#{session_name}:#{window_index}.#{pane_index}"
|
|
16
|
+
]);
|
|
17
|
+
for (const line of stdout.trim().split("\n")){
|
|
18
|
+
if (!line.trim()) continue;
|
|
19
|
+
const [paneTty, identifier] = line.split("|");
|
|
20
|
+
if (paneTty === tty && identifier) {
|
|
21
|
+
return {
|
|
22
|
+
type: TerminalType.TMUX,
|
|
23
|
+
identifier,
|
|
24
|
+
tty
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
} catch {
|
|
29
|
+
// tmux might not be installed or running
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
},
|
|
33
|
+
async focus (location) {
|
|
34
|
+
await execFileAsync("tmux", [
|
|
35
|
+
"switch-client",
|
|
36
|
+
"-t",
|
|
37
|
+
location.identifier
|
|
38
|
+
]);
|
|
39
|
+
return true;
|
|
40
|
+
},
|
|
41
|
+
async send (location, message) {
|
|
42
|
+
const bufferName = `ai-devkit-send-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
43
|
+
await execFileWithInput("tmux", [
|
|
44
|
+
"load-buffer",
|
|
45
|
+
"-b",
|
|
46
|
+
bufferName,
|
|
47
|
+
"-"
|
|
48
|
+
], message);
|
|
49
|
+
await execFileAsync("tmux", [
|
|
50
|
+
"paste-buffer",
|
|
51
|
+
"-t",
|
|
52
|
+
location.identifier,
|
|
53
|
+
"-b",
|
|
54
|
+
bufferName,
|
|
55
|
+
"-p",
|
|
56
|
+
"-d"
|
|
57
|
+
]);
|
|
58
|
+
await sleep(150);
|
|
59
|
+
await execFileAsync("tmux", [
|
|
60
|
+
"send-keys",
|
|
61
|
+
"-t",
|
|
62
|
+
location.identifier,
|
|
63
|
+
"Enter"
|
|
64
|
+
]);
|
|
65
|
+
},
|
|
66
|
+
async sendKey (location, key) {
|
|
67
|
+
await execFileAsync("tmux", [
|
|
68
|
+
"send-keys",
|
|
69
|
+
"-t",
|
|
70
|
+
location.identifier,
|
|
71
|
+
key === ESCAPE_BYTE ? "Escape" : key
|
|
72
|
+
]);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
//# sourceMappingURL=tmux.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/terminal/backends/tmux.ts"],"sourcesContent":["import { execFile } from \"child_process\";\nimport { promisify } from \"util\";\nimport { TerminalType, type TerminalBackend } from \"../types.js\";\nimport { ESCAPE_BYTE, execFileWithInput, sleep } from \"./shared.js\";\n\nconst execFileAsync = promisify(execFile);\n\nexport const tmuxBackend: TerminalBackend = {\n type: TerminalType.TMUX,\n label: \"tmux\",\n\n async find(tty) {\n try {\n const { stdout } = await execFileAsync(\"tmux\", [\n \"list-panes\",\n \"-a\",\n \"-F\",\n \"#{pane_tty}|#{session_name}:#{window_index}.#{pane_index}\",\n ]);\n for (const line of stdout.trim().split(\"\\n\")) {\n if (!line.trim()) continue;\n const [paneTty, identifier] = line.split(\"|\");\n if (paneTty === tty && identifier) {\n return { type: TerminalType.TMUX, identifier, tty };\n }\n }\n } catch {\n // tmux might not be installed or running\n }\n return null;\n },\n\n async focus(location) {\n await execFileAsync(\"tmux\", [\"switch-client\", \"-t\", location.identifier]);\n return true;\n },\n\n async send(location, message) {\n const bufferName = `ai-devkit-send-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2)}`;\n await execFileWithInput(\"tmux\", [\"load-buffer\", \"-b\", bufferName, \"-\"], message);\n await execFileAsync(\"tmux\", [\n \"paste-buffer\",\n \"-t\",\n location.identifier,\n \"-b\",\n bufferName,\n \"-p\",\n \"-d\",\n ]);\n await sleep(150);\n await execFileAsync(\"tmux\", [\"send-keys\", \"-t\", location.identifier, \"Enter\"]);\n },\n\n async sendKey(location, key) {\n await execFileAsync(\"tmux\", [\n \"send-keys\",\n \"-t\",\n location.identifier,\n key === ESCAPE_BYTE ? \"Escape\" : key,\n ]);\n },\n};\n"],"names":["execFile","promisify","TerminalType","ESCAPE_BYTE","execFileWithInput","sleep","execFileAsync","tmuxBackend","type","TMUX","label","find","tty","stdout","line","trim","split","paneTty","identifier","focus","location","send","message","bufferName","process","pid","Date","now","Math","random","toString","slice","sendKey","key"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,SAAS,QAAQ,OAAO;AACjC,SAASC,YAAY,QAA8B,cAAc;AACjE,SAASC,WAAW,EAAEC,iBAAiB,EAAEC,KAAK,QAAQ,cAAc;AAEpE,MAAMC,gBAAgBL,UAAUD;AAEhC,OAAO,MAAMO,cAA+B;IAC1CC,MAAMN,aAAaO,IAAI;IACvBC,OAAO;IAEP,MAAMC,MAAKC,GAAG;QACZ,IAA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m.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAUjE,eAAO,MAAM,cAAc,EAAE,eAoD5B,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { execFile } from "child_process";
|
|
2
|
+
import { promisify } from "util";
|
|
3
|
+
import { TerminalType } from "../types.js";
|
|
4
|
+
import { CARRIAGE_RETURN, execFileWithInput, sleep } from "./shared.js";
|
|
5
|
+
const execFileAsync = promisify(execFile);
|
|
6
|
+
export const weztermBackend = {
|
|
7
|
+
type: TerminalType.WEZTERM,
|
|
8
|
+
label: "wezterm",
|
|
9
|
+
async find (tty) {
|
|
10
|
+
try {
|
|
11
|
+
const { stdout } = await execFileAsync("wezterm", [
|
|
12
|
+
"cli",
|
|
13
|
+
"list",
|
|
14
|
+
"--format",
|
|
15
|
+
"json"
|
|
16
|
+
]);
|
|
17
|
+
const panes = JSON.parse(stdout);
|
|
18
|
+
if (!Array.isArray(panes)) return null;
|
|
19
|
+
for (const pane of panes){
|
|
20
|
+
if (pane?.tty_name === tty && pane.pane_id != null) {
|
|
21
|
+
return {
|
|
22
|
+
type: TerminalType.WEZTERM,
|
|
23
|
+
identifier: String(pane.pane_id),
|
|
24
|
+
tty
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
} catch {
|
|
29
|
+
// wezterm might not be installed, running, or returning valid JSON
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
},
|
|
33
|
+
async focus (location) {
|
|
34
|
+
await execFileAsync("wezterm", [
|
|
35
|
+
"cli",
|
|
36
|
+
"activate-pane",
|
|
37
|
+
"--pane-id",
|
|
38
|
+
location.identifier
|
|
39
|
+
]);
|
|
40
|
+
return true;
|
|
41
|
+
},
|
|
42
|
+
async send (location, message) {
|
|
43
|
+
await execFileWithInput("wezterm", [
|
|
44
|
+
"cli",
|
|
45
|
+
"send-text",
|
|
46
|
+
"--pane-id",
|
|
47
|
+
location.identifier
|
|
48
|
+
], message);
|
|
49
|
+
await sleep(150);
|
|
50
|
+
await execFileAsync("wezterm", [
|
|
51
|
+
"cli",
|
|
52
|
+
"send-text",
|
|
53
|
+
"--pane-id",
|
|
54
|
+
location.identifier,
|
|
55
|
+
"--no-paste",
|
|
56
|
+
CARRIAGE_RETURN
|
|
57
|
+
]);
|
|
58
|
+
},
|
|
59
|
+
async sendKey (location, key) {
|
|
60
|
+
await execFileAsync("wezterm", [
|
|
61
|
+
"cli",
|
|
62
|
+
"send-text",
|
|
63
|
+
"--pane-id",
|
|
64
|
+
location.identifier,
|
|
65
|
+
"--no-paste",
|
|
66
|
+
key
|
|
67
|
+
]);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=wezterm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/terminal/backends/wezterm.ts"],"sourcesContent":["import { execFile } from \"child_process\";\nimport { promisify } from \"util\";\nimport { TerminalType, type TerminalBackend } from \"../types.js\";\nimport { CARRIAGE_RETURN, execFileWithInput, sleep } from \"./shared.js\";\n\nconst execFileAsync = promisify(execFile);\n\ninterface WeztermPaneEntry {\n pane_id?: number;\n tty_name?: string | null;\n}\n\nexport const weztermBackend: TerminalBackend = {\n type: TerminalType.WEZTERM,\n label: \"wezterm\",\n\n async find(tty) {\n try {\n const { stdout } = await execFileAsync(\"wezterm\", [\"cli\", \"list\", \"--format\", \"json\"]);\n const panes = JSON.parse(stdout) as WeztermPaneEntry[];\n if (!Array.isArray(panes)) return null;\n for (const pane of panes) {\n if (pane?.tty_name === tty && pane.pane_id != null) {\n return { type: TerminalType.WEZTERM, identifier: String(pane.pane_id), tty };\n }\n }\n } catch {\n // wezterm might not be installed, running, or returning valid JSON\n }\n return null;\n },\n\n async focus(location) {\n await execFileAsync(\"wezterm\", [\"cli\", \"activate-pane\", \"--pane-id\", location.identifier]);\n return true;\n },\n\n async send(location, message) {\n await execFileWithInput(\n \"wezterm\",\n [\"cli\", \"send-text\", \"--pane-id\", location.identifier],\n message,\n );\n await sleep(150);\n await execFileAsync(\"wezterm\", [\n \"cli\",\n \"send-text\",\n \"--pane-id\",\n location.identifier,\n \"--no-paste\",\n CARRIAGE_RETURN,\n ]);\n },\n\n async sendKey(location, key) {\n await execFileAsync(\"wezterm\", [\n \"cli\",\n \"send-text\",\n \"--pane-id\",\n location.identifier,\n \"--no-paste\",\n key,\n ]);\n },\n};\n"],"names":["execFile","promisify","TerminalType","CARRIAGE_RETURN","execFileWithInput","sleep","execFileAsync","weztermBackend","type","WEZTERM","label","find","tty","stdout","panes","JSON","parse","Array","isArray","pane","tty_name","pane_id","identifier","String","focus","location","send","message","sendKey","key"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,SAAS,QAAQ,OAAO;AACjC,SAASC,YAAY,QAA8B,cAAc;AACjE,SAASC,eAAe,EAAEC,iBAAiB,EAAEC,KAAK,QAAQ,cAAc;AAExE,MAAMC,gBAAgBL,UAAUD;AAOhC,OAAO,MAAMO,iBAAkC;IAC7CC,MAAMN,aAAaO,OAAO;IAC1BC,OAAO;IAEP,MAAMC,MAAKC,GAAG;QACZ,IAAI;YACF,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAMP,cAAc,WAAW;gBAAC;gBAAO;gBAAQ;gBAAY;aAAO;YACrF,MAAMQ,QAAQC,KAAKC,KAAK,CAACH;YACzB,IAAI,CAACI,MAAMC,OAAO,CAACJ,QAAQ,OAAO;YAClC,KAAK,MAAMK,QAAQL,MAAO;gBACxB,IAAIK,MAAMC,aAAaR,OAAOO,KAAKE,OAAO,IAAI,MAAM;oBAClD,OAAO;wBAAEb,MAAMN,aAAaO,OAAO;wBAAEa,YAAYC,OAAOJ,KAAKE,OAAO;wBAAGT;oBAAI;gBAC7E;YACF;QACF,EAAE,OAAM;QACN,mEAAmE;QACrE;QACA,OAAO;IACT;IAEA,MAAMY,OAAMC,QAAQ;QAClB,MAAMnB,cAAc,WAAW;YAAC;YAAO;YAAiB;YAAamB,SAASH,UAAU;SAAC;QACzF,OAAO;IACT;IAEA,MAAMI,MAAKD,QAAQ,EAAEE,OAAO;QAC1B,MAAMvB,kBACJ,WACA;YAAC;YAAO;YAAa;YAAaqB,SAASH,UAAU;SAAC,EACtDK;QAEF,MAAMtB,MAAM;QACZ,MAAMC,cAAc,WAAW;YAC7B;YACA;YACA;YACAmB,SAASH,UAAU;YACnB;YACAnB;SACD;IACH;IAEA,MAAMyB,SAAQH,QAAQ,EAAEI,GAAG;QACzB,MAAMvB,cAAc,WAAW;YAC7B;YACA;YACA;YACAmB,SAASH,UAAU;YACnB;YACAO;SACD;IACH;AACF,EAAE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare enum TerminalType {
|
|
2
|
+
TMUX = "tmux",
|
|
3
|
+
WEZTERM = "wezterm",
|
|
4
|
+
GHOSTTY = "ghostty",
|
|
5
|
+
ITERM2 = "iterm2",
|
|
6
|
+
TERMINAL_APP = "terminal-app",
|
|
7
|
+
UNKNOWN = "unknown"
|
|
8
|
+
}
|
|
9
|
+
export interface TerminalLocation {
|
|
10
|
+
type: TerminalType;
|
|
11
|
+
identifier: string;
|
|
12
|
+
tty: string;
|
|
13
|
+
}
|
|
14
|
+
export interface TerminalBackend {
|
|
15
|
+
readonly type: Exclude<TerminalType, TerminalType.UNKNOWN>;
|
|
16
|
+
readonly label: string;
|
|
17
|
+
find(tty: string): Promise<TerminalLocation | null>;
|
|
18
|
+
focus(location: TerminalLocation): Promise<boolean>;
|
|
19
|
+
send(location: TerminalLocation, message: string): Promise<void>;
|
|
20
|
+
sendKey(location: TerminalLocation, key: string): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/terminal/types.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,YAAY,iBAAiB;IAC7B,OAAO,YAAY;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,YAAY,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAC3D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IACpD,KAAK,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACpD,IAAI,CAAC,QAAQ,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,OAAO,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export var TerminalType = /*#__PURE__*/ function(TerminalType) {
|
|
2
|
+
TerminalType["TMUX"] = "tmux";
|
|
3
|
+
TerminalType["WEZTERM"] = "wezterm";
|
|
4
|
+
TerminalType["GHOSTTY"] = "ghostty";
|
|
5
|
+
TerminalType["ITERM2"] = "iterm2";
|
|
6
|
+
TerminalType["TERMINAL_APP"] = "terminal-app";
|
|
7
|
+
TerminalType["UNKNOWN"] = "unknown";
|
|
8
|
+
return TerminalType;
|
|
9
|
+
}({});
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/terminal/types.ts"],"sourcesContent":["export enum TerminalType {\n TMUX = \"tmux\",\n WEZTERM = \"wezterm\",\n GHOSTTY = \"ghostty\",\n ITERM2 = \"iterm2\",\n TERMINAL_APP = \"terminal-app\",\n UNKNOWN = \"unknown\",\n}\n\nexport interface TerminalLocation {\n type: TerminalType;\n identifier: string;\n tty: string;\n}\n\nexport interface TerminalBackend {\n readonly type: Exclude<TerminalType, TerminalType.UNKNOWN>;\n readonly label: string;\n find(tty: string): Promise<TerminalLocation | null>;\n focus(location: TerminalLocation): Promise<boolean>;\n send(location: TerminalLocation, message: string): Promise<void>;\n sendKey(location: TerminalLocation, key: string): Promise<void>;\n}\n"],"names":["TerminalType"],"mappings":"AAAA,OAAO,IAAA,AAAKA,sCAAAA;;;;;;;WAAAA;MAOX"}
|
package/dist/utils/process.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ export interface ProcessSnapshotOptions {
|
|
|
41
41
|
isCandidate?: (process: ProcessInfo) => boolean;
|
|
42
42
|
}
|
|
43
43
|
export type ProcessSnapshotCapture = (namePatterns: readonly string[], options?: ProcessSnapshotOptions) => Promise<ProcessInfo[]>;
|
|
44
|
+
/** Working directories of `pids` (async `lsof`); PIDs it cannot read are omitted. */
|
|
45
|
+
export declare function getProcessCwdsAsync(pids: number[]): Promise<Map<number, string>>;
|
|
44
46
|
/**
|
|
45
47
|
* Create a snapshot capture function with its own start-time cache.
|
|
46
48
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/utils/process.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAmB/D;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAWtD;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE1D;AAkCD,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,SAA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ist/utils/process.js
CHANGED
|
@@ -161,6 +161,9 @@ function parseProcessList(output, namePatterns) {
|
|
|
161
161
|
matched
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
|
+
/** Working directories of `pids` (async `lsof`); PIDs it cannot read are omitted. */ export function getProcessCwdsAsync(pids) {
|
|
165
|
+
return batchGetProcessCwdsAsync(execFileText, pids);
|
|
166
|
+
}
|
|
164
167
|
async function batchGetProcessCwdsAsync(exec, pids) {
|
|
165
168
|
const result = new Map();
|
|
166
169
|
if (pids.length === 0) return result;
|