@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
package/src/runtime/types.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { AgentInfo } from "../adapters/AgentAdapter.js";
|
|
2
|
-
import type { TerminalLocation } from "../terminal/types.js";
|
|
3
|
-
import type { AgentRuntimeProvider } from "../utils/AgentRegistry.js";
|
|
4
|
-
|
|
5
|
-
export type AgentRuntimeAvailability =
|
|
6
|
-
| { ok: true; insideRuntime: boolean; currentPaneId?: string }
|
|
7
|
-
| { ok: false; reason: "binary-missing" | "backend-unreachable"; detail: string };
|
|
8
|
-
|
|
9
|
-
export interface RuntimeStartInput {
|
|
10
|
-
name: string;
|
|
11
|
-
cwd: string;
|
|
12
|
-
kind: string;
|
|
13
|
-
args: string[];
|
|
14
|
-
timeoutMs: number;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface RuntimeStartResult {
|
|
18
|
-
pid: number;
|
|
19
|
-
runtimeRef: unknown;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface RuntimeTargetInput {
|
|
23
|
-
agent: Pick<AgentInfo, "name" | "pid">;
|
|
24
|
-
runtimeRef: unknown | null;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface RuntimeSendInput extends RuntimeTargetInput {
|
|
28
|
-
prompt: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface RuntimeFocusInput extends RuntimeTargetInput {
|
|
32
|
-
focusManager: {
|
|
33
|
-
findTerminal(pid: number): Promise<TerminalLocation | null>;
|
|
34
|
-
focusTerminal(location: TerminalLocation): Promise<boolean>;
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface RuntimeStopInput extends RuntimeTargetInput {
|
|
39
|
-
killProcess?: (pid: number, signal: NodeJS.Signals) => void;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface RuntimeSendDeps {
|
|
43
|
-
focusManager: {
|
|
44
|
-
findTerminal(pid: number): Promise<TerminalLocation | null>;
|
|
45
|
-
};
|
|
46
|
-
writer?: (location: TerminalLocation, text: string) => Promise<void>;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface InteractiveAgentRuntime {
|
|
50
|
-
provider: AgentRuntimeProvider;
|
|
51
|
-
isAvailable(): Promise<AgentRuntimeAvailability>;
|
|
52
|
-
startAgent(input: RuntimeStartInput): Promise<RuntimeStartResult>;
|
|
53
|
-
send(input: RuntimeSendInput, deps?: RuntimeSendDeps): Promise<void>;
|
|
54
|
-
focus(input: RuntimeFocusInput): Promise<boolean>;
|
|
55
|
-
stop(input: RuntimeStopInput): Promise<void>;
|
|
56
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { getProcessTty } from "../utils/process.js";
|
|
2
|
-
import { TERMINAL_BACKENDS, terminalBackendFor } from "./backends/index.js";
|
|
3
|
-
import { TerminalType, type TerminalLocation } from "./types.js";
|
|
4
|
-
|
|
5
|
-
export { TerminalType };
|
|
6
|
-
export type { TerminalLocation };
|
|
7
|
-
|
|
8
|
-
/** Optional trace sink for terminal discovery and focus decisions. */
|
|
9
|
-
export type TerminalDebugLogger = (message: string) => void;
|
|
10
|
-
|
|
11
|
-
export class TerminalFocusManager {
|
|
12
|
-
constructor(private readonly debug?: TerminalDebugLogger) {}
|
|
13
|
-
|
|
14
|
-
async findTerminal(pid: number): Promise<TerminalLocation | null> {
|
|
15
|
-
const tty = getProcessTty(pid);
|
|
16
|
-
if (!tty || tty === "?") {
|
|
17
|
-
this.debug?.(`findTerminal(pid=${pid}): no usable TTY, cannot resolve terminal`);
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const fullTty = `/dev/${tty}`;
|
|
22
|
-
this.debug?.(`findTerminal(pid=${pid}): resolving terminal for ${fullTty}`);
|
|
23
|
-
|
|
24
|
-
for (const backend of TERMINAL_BACKENDS) {
|
|
25
|
-
const location = await backend.find(fullTty);
|
|
26
|
-
if (location) {
|
|
27
|
-
this.debug?.(`findTerminal: matched ${backend.label} (identifier=${location.identifier})`);
|
|
28
|
-
return location;
|
|
29
|
-
}
|
|
30
|
-
this.debug?.(`findTerminal: ${backend.label} no match`);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
this.debug?.("findTerminal: no emulator matched; returning UNKNOWN");
|
|
34
|
-
return { type: TerminalType.UNKNOWN, identifier: "", tty: fullTty };
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async focusTerminal(location: TerminalLocation): Promise<boolean> {
|
|
38
|
-
this.debug?.(
|
|
39
|
-
`focusTerminal: focusing ${location.type} (identifier=${location.identifier}, tty=${location.tty})`,
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
let success = false;
|
|
43
|
-
try {
|
|
44
|
-
success = (await terminalBackendFor(location.type)?.focus(location)) ?? false;
|
|
45
|
-
} catch {
|
|
46
|
-
success = false;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
this.debug?.(`focusTerminal: ${success ? "succeeded" : "failed"} for ${location.type}`);
|
|
50
|
-
return success;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { TERMINAL_BACKENDS, terminalBackendFor } from "./backends/index.js";
|
|
2
|
-
import type { TerminalLocation } from "./types.js";
|
|
3
|
-
|
|
4
|
-
const SUPPORTED = `Supported: ${TERMINAL_BACKENDS.map((backend) => backend.label).join(", ")}.`;
|
|
5
|
-
|
|
6
|
-
export class TtyWriter {
|
|
7
|
-
static async send(location: TerminalLocation, message: string): Promise<void> {
|
|
8
|
-
const backend = terminalBackendFor(location.type);
|
|
9
|
-
if (!backend) {
|
|
10
|
-
throw new Error(
|
|
11
|
-
`Cannot send input: unsupported terminal type "${location.type}". ${SUPPORTED}`,
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
await backend.send(location, message);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
static async sendKey(location: TerminalLocation, key: string): Promise<void> {
|
|
18
|
-
const backend = terminalBackendFor(location.type);
|
|
19
|
-
if (!backend) {
|
|
20
|
-
throw new Error(
|
|
21
|
-
`Cannot send key: unsupported terminal type "${location.type}". ${SUPPORTED}`,
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
await backend.sendKey(location, key);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { execFile } from "child_process";
|
|
2
|
-
import { writeFile } from "fs/promises";
|
|
3
|
-
import { promisify } from "util";
|
|
4
|
-
import { escapeAppleScript } from "../../utils/applescript.js";
|
|
5
|
-
import { getProcessCwdsAsync } from "../../utils/process.js";
|
|
6
|
-
import { TerminalType, type TerminalBackend, type TerminalLocation } from "../types.js";
|
|
7
|
-
import { CARRIAGE_RETURN, isProcessName, sleep } from "./shared.js";
|
|
8
|
-
|
|
9
|
-
const execFileAsync = promisify(execFile);
|
|
10
|
-
|
|
11
|
-
/** Separates fields in AppleScript output; never part of an id, title or path. */
|
|
12
|
-
const FIELD_SEPARATOR = "\x1f";
|
|
13
|
-
const MARKER_POLL_ATTEMPTS = 10;
|
|
14
|
-
const MARKER_POLL_INTERVAL_MS = 50;
|
|
15
|
-
|
|
16
|
-
interface GhosttyTerminal {
|
|
17
|
-
id: string;
|
|
18
|
-
name: string;
|
|
19
|
-
workingDirectory: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
interface ProcessRow {
|
|
23
|
-
pid: number;
|
|
24
|
-
ppid: number;
|
|
25
|
-
tty: string;
|
|
26
|
-
comm: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async function listProcesses(): Promise<ProcessRow[]> {
|
|
30
|
-
const { stdout } = await execFileAsync("ps", ["-Axo", "pid=,ppid=,tty=,comm="]);
|
|
31
|
-
const rows: ProcessRow[] = [];
|
|
32
|
-
for (const line of stdout.split("\n")) {
|
|
33
|
-
const match = line.trim().match(/^(\d+)\s+(\d+)\s+(\S+)\s+(.+)$/);
|
|
34
|
-
if (match) {
|
|
35
|
-
rows.push({ pid: Number(match[1]), ppid: Number(match[2]), tty: match[3], comm: match[4] });
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return rows;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async function listTerminals(): Promise<GhosttyTerminal[]> {
|
|
42
|
-
const script = `
|
|
43
|
-
tell application "Ghostty"
|
|
44
|
-
set out to ""
|
|
45
|
-
repeat with t in terminals
|
|
46
|
-
set out to out & (id of t) & (character id 31) & (name of t) & (character id 31) & (working directory of t) & linefeed
|
|
47
|
-
end repeat
|
|
48
|
-
return out
|
|
49
|
-
end tell`;
|
|
50
|
-
const { stdout } = await execFileAsync("osascript", ["-e", script]);
|
|
51
|
-
return stdout
|
|
52
|
-
.split("\n")
|
|
53
|
-
.map((line) => line.split(FIELD_SEPARATOR))
|
|
54
|
-
.filter((fields) => fields.length === 3 && fields[0])
|
|
55
|
-
.map(([id, name, workingDirectory]) => ({ id, name, workingDirectory }));
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** Run an AppleScript `command` with `t` bound to the located terminal; false if it is gone. */
|
|
59
|
-
async function onTerminal(location: TerminalLocation, command: string): Promise<boolean> {
|
|
60
|
-
const script = `
|
|
61
|
-
tell application "Ghostty"
|
|
62
|
-
set matches to (every terminal whose id is "${escapeAppleScript(location.identifier)}")
|
|
63
|
-
if (count of matches) is 0 then return "not_found"
|
|
64
|
-
set t to item 1 of matches
|
|
65
|
-
${command}
|
|
66
|
-
end tell
|
|
67
|
-
return "ok"`;
|
|
68
|
-
const { stdout } = await execFileAsync("osascript", ["-e", script]);
|
|
69
|
-
return stdout.trim() === "ok";
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** Set the window title of whatever terminal owns `tty` (OSC 2). */
|
|
73
|
-
async function writeTitle(tty: string, title: string): Promise<void> {
|
|
74
|
-
// eslint-disable-next-line no-control-regex
|
|
75
|
-
const safe = title.replace(/[\x00-\x1f\x7f]/g, "");
|
|
76
|
-
await writeFile(tty, `\x1b]2;${safe}\x07`, { flag: "a" });
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Ghostty's AppleScript terminals expose an id, title and working directory,
|
|
81
|
-
* but not their TTY. Find the one owning `tty` without guessing:
|
|
82
|
-
* 1. only TTYs whose session was started by a ghostty process qualify;
|
|
83
|
-
* 2. if exactly one terminal's working directory matches a process on this
|
|
84
|
-
* TTY, and no other Ghostty TTY has a process there, that is it;
|
|
85
|
-
* 3. otherwise briefly set a unique title on the TTY, find the terminal now
|
|
86
|
-
* showing it, and restore its previous title.
|
|
87
|
-
*/
|
|
88
|
-
async function findTerminalId(tty: string): Promise<string | null> {
|
|
89
|
-
const processes = await listProcesses();
|
|
90
|
-
const ghosttyPids = new Set(
|
|
91
|
-
processes.filter((p) => isProcessName(p.comm, "ghostty")).map((p) => p.pid),
|
|
92
|
-
);
|
|
93
|
-
if (ghosttyPids.size === 0) return null;
|
|
94
|
-
|
|
95
|
-
const ttyName = tty.replace(/^\/dev\//, "");
|
|
96
|
-
const ghosttyTtys = new Set(
|
|
97
|
-
processes.filter((p) => ghosttyPids.has(p.ppid) && p.tty !== "??").map((p) => p.tty),
|
|
98
|
-
);
|
|
99
|
-
if (!ghosttyTtys.has(ttyName)) return null;
|
|
100
|
-
|
|
101
|
-
const terminals = await listTerminals();
|
|
102
|
-
const sessionProcesses = processes.filter((p) => ghosttyTtys.has(p.tty));
|
|
103
|
-
const cwdByPid = await getProcessCwdsAsync(sessionProcesses.map((p) => p.pid));
|
|
104
|
-
const ownDirs = new Set<string>();
|
|
105
|
-
const otherDirs = new Set<string>();
|
|
106
|
-
for (const p of sessionProcesses) {
|
|
107
|
-
const cwd = cwdByPid.get(p.pid);
|
|
108
|
-
if (cwd) (p.tty === ttyName ? ownDirs : otherDirs).add(cwd);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Trust the directory only when exactly one terminal is in a folder no other Ghostty TTY uses.
|
|
112
|
-
const byDirectory = terminals.filter((t) => ownDirs.has(t.workingDirectory));
|
|
113
|
-
if (byDirectory.length === 1 && !otherDirs.has(byDirectory[0].workingDirectory)) {
|
|
114
|
-
return byDirectory[0].id;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const marker = `ai-devkit-${process.pid}-${Date.now()}`;
|
|
118
|
-
await writeTitle(tty, marker);
|
|
119
|
-
for (let attempt = 0; attempt < MARKER_POLL_ATTEMPTS; attempt++) {
|
|
120
|
-
const marked = (await listTerminals()).find((t) => t.name === marker);
|
|
121
|
-
if (marked) {
|
|
122
|
-
const previous = terminals.find((t) => t.id === marked.id)?.name ?? "";
|
|
123
|
-
await writeTitle(tty, previous);
|
|
124
|
-
return marked.id;
|
|
125
|
-
}
|
|
126
|
-
await sleep(MARKER_POLL_INTERVAL_MS);
|
|
127
|
-
}
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* A Ghostty `text:` action that writes `bytes` to the terminal as typed.
|
|
133
|
-
* Unlike `send key`, it does not go through the keyboard layout or input
|
|
134
|
-
* method, which can turn a digit key into another character.
|
|
135
|
-
*/
|
|
136
|
-
function textAction(bytes: string): string {
|
|
137
|
-
const escaped = Array.from(bytes, (char) => {
|
|
138
|
-
if (char === "\\") return "\\\\";
|
|
139
|
-
const code = char.charCodeAt(0);
|
|
140
|
-
return code >= 0x20 && code < 0x7f ? char : `\\x${code.toString(16).padStart(2, "0")}`;
|
|
141
|
-
}).join("");
|
|
142
|
-
return `perform action "${escapeAppleScript(`text:${escaped}`)}" on t`;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export const ghosttyBackend: TerminalBackend = {
|
|
146
|
-
type: TerminalType.GHOSTTY,
|
|
147
|
-
label: "Ghostty",
|
|
148
|
-
|
|
149
|
-
async find(tty) {
|
|
150
|
-
try {
|
|
151
|
-
const id = await findTerminalId(tty);
|
|
152
|
-
return id ? { type: TerminalType.GHOSTTY, identifier: id, tty } : null;
|
|
153
|
-
} catch {
|
|
154
|
-
// Ghostty not installed, not scriptable, or the TTY is not writable
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
async focus(location) {
|
|
160
|
-
return onTerminal(location, "focus t\n activate");
|
|
161
|
-
},
|
|
162
|
-
|
|
163
|
-
async send(location, message) {
|
|
164
|
-
if (!(await onTerminal(location, `input text "${escapeAppleScript(message)}" to t`))) {
|
|
165
|
-
throw new Error(`Ghostty terminal not found for TTY ${location.tty}`);
|
|
166
|
-
}
|
|
167
|
-
await sleep(150);
|
|
168
|
-
if (!(await onTerminal(location, textAction(CARRIAGE_RETURN)))) {
|
|
169
|
-
throw new Error(
|
|
170
|
-
`Ghostty terminal disappeared before Enter could be sent for TTY ${location.tty}`,
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
async sendKey(location, key) {
|
|
176
|
-
if (!(await onTerminal(location, textAction(key)))) {
|
|
177
|
-
throw new Error(`Ghostty terminal not found for TTY ${location.tty}`);
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { TerminalBackend } from "../types.js";
|
|
2
|
-
import { TerminalType } from "../types.js";
|
|
3
|
-
import { ghosttyBackend } from "./ghostty.js";
|
|
4
|
-
import { iterm2Backend } from "./iterm2.js";
|
|
5
|
-
import { terminalAppBackend } from "./terminal-app.js";
|
|
6
|
-
import { tmuxBackend } from "./tmux.js";
|
|
7
|
-
import { weztermBackend } from "./wezterm.js";
|
|
8
|
-
|
|
9
|
-
export const TERMINAL_BACKENDS: readonly TerminalBackend[] = [
|
|
10
|
-
tmuxBackend,
|
|
11
|
-
weztermBackend,
|
|
12
|
-
ghosttyBackend,
|
|
13
|
-
iterm2Backend,
|
|
14
|
-
terminalAppBackend,
|
|
15
|
-
];
|
|
16
|
-
|
|
17
|
-
const BACKENDS_BY_TYPE = new Map<TerminalType, TerminalBackend>(
|
|
18
|
-
TERMINAL_BACKENDS.map((backend) => [backend.type, backend]),
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
export function terminalBackendFor(type: TerminalType): TerminalBackend | undefined {
|
|
22
|
-
return BACKENDS_BY_TYPE.get(type);
|
|
23
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { execFile } from "child_process";
|
|
2
|
-
import { promisify } from "util";
|
|
3
|
-
import { escapeAppleScript } from "../../utils/applescript.js";
|
|
4
|
-
import { TerminalType, type TerminalBackend } from "../types.js";
|
|
5
|
-
import { appleScriptKeyAction, isProcessRunning, sleep } from "./shared.js";
|
|
6
|
-
|
|
7
|
-
const execFileAsync = promisify(execFile);
|
|
8
|
-
|
|
9
|
-
function sessionScript(tty: string, sessionCommand: string): string {
|
|
10
|
-
return `
|
|
11
|
-
tell application "iTerm"
|
|
12
|
-
set targetSession to missing value
|
|
13
|
-
repeat with w in windows
|
|
14
|
-
repeat with t in tabs of w
|
|
15
|
-
repeat with s in sessions of t
|
|
16
|
-
if tty of s is "${escapeAppleScript(tty)}" then
|
|
17
|
-
set targetSession to s
|
|
18
|
-
exit repeat
|
|
19
|
-
end if
|
|
20
|
-
end repeat
|
|
21
|
-
if targetSession is not missing value then exit repeat
|
|
22
|
-
end repeat
|
|
23
|
-
if targetSession is not missing value then exit repeat
|
|
24
|
-
end repeat
|
|
25
|
-
if targetSession is missing value then return "not_found"
|
|
26
|
-
tell targetSession to ${sessionCommand}
|
|
27
|
-
end tell
|
|
28
|
-
return "ok"`;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const iterm2Backend: TerminalBackend = {
|
|
32
|
-
type: TerminalType.ITERM2,
|
|
33
|
-
label: "iTerm2",
|
|
34
|
-
|
|
35
|
-
async find(tty) {
|
|
36
|
-
try {
|
|
37
|
-
if (!(await isProcessRunning("iTerm2"))) return null;
|
|
38
|
-
const script = `
|
|
39
|
-
tell application "iTerm"
|
|
40
|
-
repeat with w in windows
|
|
41
|
-
repeat with t in tabs of w
|
|
42
|
-
repeat with s in sessions of t
|
|
43
|
-
if tty of s is "${escapeAppleScript(tty)}" then
|
|
44
|
-
return "found"
|
|
45
|
-
end if
|
|
46
|
-
end repeat
|
|
47
|
-
end repeat
|
|
48
|
-
end repeat
|
|
49
|
-
end tell
|
|
50
|
-
`;
|
|
51
|
-
const { stdout } = await execFileAsync("osascript", ["-e", script]);
|
|
52
|
-
return stdout.trim() === "found" ? { type: TerminalType.ITERM2, identifier: tty, tty } : null;
|
|
53
|
-
} catch {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
async focus(location) {
|
|
59
|
-
const script = `
|
|
60
|
-
tell application "iTerm"
|
|
61
|
-
activate
|
|
62
|
-
repeat with w in windows
|
|
63
|
-
repeat with t in tabs of w
|
|
64
|
-
repeat with s in sessions of t
|
|
65
|
-
if tty of s is "${escapeAppleScript(location.tty)}" then
|
|
66
|
-
select s
|
|
67
|
-
return "true"
|
|
68
|
-
end if
|
|
69
|
-
end repeat
|
|
70
|
-
end repeat
|
|
71
|
-
end repeat
|
|
72
|
-
end tell
|
|
73
|
-
`;
|
|
74
|
-
const { stdout } = await execFileAsync("osascript", ["-e", script]);
|
|
75
|
-
return stdout.trim() === "true";
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
async send(location, message) {
|
|
79
|
-
const textScript = sessionScript(
|
|
80
|
-
location.tty,
|
|
81
|
-
`write text "${escapeAppleScript(message)}" newline no`,
|
|
82
|
-
);
|
|
83
|
-
const { stdout: textResult } = await execFileAsync("osascript", ["-e", textScript]);
|
|
84
|
-
if (textResult.trim() !== "ok") {
|
|
85
|
-
throw new Error(`iTerm2 session not found for TTY ${location.tty}`);
|
|
86
|
-
}
|
|
87
|
-
await sleep(150);
|
|
88
|
-
const enterScript = sessionScript(location.tty, 'write text "" newline yes');
|
|
89
|
-
const { stdout: enterResult } = await execFileAsync("osascript", ["-e", enterScript]);
|
|
90
|
-
if (enterResult.trim() !== "ok") {
|
|
91
|
-
throw new Error(
|
|
92
|
-
`iTerm2 session disappeared before Enter could be sent for TTY ${location.tty}`,
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
async sendKey(location, key) {
|
|
98
|
-
const script = `
|
|
99
|
-
tell application "iTerm"
|
|
100
|
-
set targetSession to missing value
|
|
101
|
-
repeat with w in windows
|
|
102
|
-
repeat with t in tabs of w
|
|
103
|
-
repeat with s in sessions of t
|
|
104
|
-
if tty of s is "${escapeAppleScript(location.tty)}" then
|
|
105
|
-
set targetSession to s
|
|
106
|
-
set frontmost of w to true
|
|
107
|
-
tell t to select
|
|
108
|
-
tell s to select
|
|
109
|
-
exit repeat
|
|
110
|
-
end if
|
|
111
|
-
end repeat
|
|
112
|
-
if targetSession is not missing value then exit repeat
|
|
113
|
-
end repeat
|
|
114
|
-
if targetSession is not missing value then exit repeat
|
|
115
|
-
end repeat
|
|
116
|
-
if targetSession is missing value then return "not_found"
|
|
117
|
-
activate
|
|
118
|
-
end tell
|
|
119
|
-
tell application "System Events" to ${appleScriptKeyAction(key)}
|
|
120
|
-
return "ok"`;
|
|
121
|
-
const { stdout } = await execFileAsync("osascript", ["-e", script]);
|
|
122
|
-
if (stdout.trim() !== "ok") {
|
|
123
|
-
throw new Error(`iTerm2 session not found for TTY ${location.tty}`);
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { execFile } from "child_process";
|
|
2
|
-
import { promisify } from "util";
|
|
3
|
-
import { escapeAppleScript } from "../../utils/applescript.js";
|
|
4
|
-
|
|
5
|
-
export const CARRIAGE_RETURN = "\x0d";
|
|
6
|
-
export const ESCAPE_BYTE = "\x1b";
|
|
7
|
-
const execFileAsync = promisify(execFile);
|
|
8
|
-
|
|
9
|
-
export function sleep(ms: number): Promise<void> {
|
|
10
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export async function execFileWithInput(
|
|
14
|
-
command: string,
|
|
15
|
-
args: string[],
|
|
16
|
-
input: string,
|
|
17
|
-
): Promise<void> {
|
|
18
|
-
await new Promise<void>((resolve, reject) => {
|
|
19
|
-
const child = execFile(command, args, (error) => {
|
|
20
|
-
if (error) reject(error);
|
|
21
|
-
else resolve();
|
|
22
|
-
});
|
|
23
|
-
if (!child.stdin) {
|
|
24
|
-
reject(new Error(`Cannot write stdin to ${command}`));
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
child.stdin.end(input);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function appleScriptKeyAction(key: string): string {
|
|
32
|
-
if (key === ESCAPE_BYTE) return "key code 53";
|
|
33
|
-
return `keystroke "${escapeAppleScript(key)}"`;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** Whether a `ps` comm value (bare name or full executable path) is `name`. */
|
|
37
|
-
export function isProcessName(comm: string, name: string): boolean {
|
|
38
|
-
return comm === name || comm.endsWith(`/${name}`);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export async function isProcessRunning(name: string): Promise<boolean> {
|
|
42
|
-
const { stdout } = await execFileAsync("ps", ["-Axo", "comm"]);
|
|
43
|
-
return stdout
|
|
44
|
-
.split("\n")
|
|
45
|
-
.map((line) => line.trim())
|
|
46
|
-
.some((command) => isProcessName(command, name));
|
|
47
|
-
}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { execFile } from "child_process";
|
|
2
|
-
import { promisify } from "util";
|
|
3
|
-
import { escapeAppleScript } from "../../utils/applescript.js";
|
|
4
|
-
import { TerminalType, type TerminalBackend } from "../types.js";
|
|
5
|
-
import { appleScriptKeyAction, isProcessRunning, sleep } from "./shared.js";
|
|
6
|
-
|
|
7
|
-
const execFileAsync = promisify(execFile);
|
|
8
|
-
|
|
9
|
-
function tabScript(tty: string, command: string): string {
|
|
10
|
-
return `
|
|
11
|
-
tell application "Terminal"
|
|
12
|
-
set targetTab to missing value
|
|
13
|
-
repeat with w in windows
|
|
14
|
-
repeat with i from 1 to count of tabs of w
|
|
15
|
-
set t to tab i of w
|
|
16
|
-
if tty of t is "${escapeAppleScript(tty)}" then
|
|
17
|
-
set targetTab to t
|
|
18
|
-
exit repeat
|
|
19
|
-
end if
|
|
20
|
-
end repeat
|
|
21
|
-
if targetTab is not missing value then exit repeat
|
|
22
|
-
end repeat
|
|
23
|
-
if targetTab is missing value then return "not_found"
|
|
24
|
-
${command}
|
|
25
|
-
end tell
|
|
26
|
-
return "ok"`;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const terminalAppBackend: TerminalBackend = {
|
|
30
|
-
type: TerminalType.TERMINAL_APP,
|
|
31
|
-
label: "Terminal.app",
|
|
32
|
-
|
|
33
|
-
async find(tty) {
|
|
34
|
-
try {
|
|
35
|
-
if (!(await isProcessRunning("Terminal"))) return null;
|
|
36
|
-
const script = `
|
|
37
|
-
tell application "Terminal"
|
|
38
|
-
repeat with w in windows
|
|
39
|
-
repeat with t in tabs of w
|
|
40
|
-
if tty of t is "${escapeAppleScript(tty)}" then
|
|
41
|
-
return "found"
|
|
42
|
-
end if
|
|
43
|
-
end repeat
|
|
44
|
-
end repeat
|
|
45
|
-
end tell
|
|
46
|
-
`;
|
|
47
|
-
const { stdout } = await execFileAsync("osascript", ["-e", script]);
|
|
48
|
-
return stdout.trim() === "found"
|
|
49
|
-
? { type: TerminalType.TERMINAL_APP, identifier: tty, tty }
|
|
50
|
-
: null;
|
|
51
|
-
} catch {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
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", ["-e", script]);
|
|
72
|
-
return stdout.trim() === "true";
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
async send(location, message) {
|
|
76
|
-
const textScript = tabScript(
|
|
77
|
-
location.tty,
|
|
78
|
-
`do script "${escapeAppleScript(message)}" in targetTab`,
|
|
79
|
-
);
|
|
80
|
-
const { stdout: textResult } = await execFileAsync("osascript", ["-e", textScript]);
|
|
81
|
-
if (textResult.trim() !== "ok") {
|
|
82
|
-
throw new Error(`Terminal.app tab not found for TTY ${location.tty}`);
|
|
83
|
-
}
|
|
84
|
-
await sleep(150);
|
|
85
|
-
const enterScript = tabScript(location.tty, 'do script "" in targetTab');
|
|
86
|
-
const { stdout: enterResult } = await execFileAsync("osascript", ["-e", enterScript]);
|
|
87
|
-
if (enterResult.trim() !== "ok") {
|
|
88
|
-
throw new Error(
|
|
89
|
-
`Terminal.app tab disappeared before Enter could be sent for TTY ${location.tty}`,
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
async sendKey(location, key) {
|
|
95
|
-
const script = `
|
|
96
|
-
tell application "Terminal"
|
|
97
|
-
set targetTab to missing value
|
|
98
|
-
set targetWindow to missing value
|
|
99
|
-
repeat with w in windows
|
|
100
|
-
repeat with i from 1 to count of tabs of w
|
|
101
|
-
set t to tab i of w
|
|
102
|
-
if tty of t is "${escapeAppleScript(location.tty)}" then
|
|
103
|
-
set targetTab to t
|
|
104
|
-
set targetWindow to w
|
|
105
|
-
exit repeat
|
|
106
|
-
end if
|
|
107
|
-
end repeat
|
|
108
|
-
if targetTab is not missing value then exit repeat
|
|
109
|
-
end repeat
|
|
110
|
-
if targetTab is missing value then return "not_found"
|
|
111
|
-
set selected of targetTab to true
|
|
112
|
-
set frontmost of targetWindow to true
|
|
113
|
-
activate
|
|
114
|
-
end tell
|
|
115
|
-
tell application "System Events" to ${appleScriptKeyAction(key)}
|
|
116
|
-
return "ok"`;
|
|
117
|
-
const { stdout } = await execFileAsync("osascript", ["-e", script]);
|
|
118
|
-
if (stdout.trim() !== "ok") {
|
|
119
|
-
throw new Error(`Terminal.app tab not found for TTY ${location.tty}`);
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
};
|