@ai-devkit/agent-manager 0.42.3 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AgentManager.d.ts +14 -5
- package/dist/AgentManager.d.ts.map +1 -1
- package/dist/AgentManager.js +32 -13
- package/dist/AgentManager.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +9 -4
- package/.swcrc +0 -27
- package/dist/__tests__/AgentManager.test.js +0 -1596
- package/dist/__tests__/AgentManager.test.js.map +0 -1
- package/dist/__tests__/adapters/IncrementalSessionRefresh.test.js +0 -486
- package/dist/__tests__/adapters/IncrementalSessionRefresh.test.js.map +0 -1
- package/dist/__tests__/adapters/adapterProcessImports.test.js +0 -52
- package/dist/__tests__/adapters/adapterProcessImports.test.js.map +0 -1
- package/dist/__tests__/adapters/adapterSnapshotCandidates.test.js +0 -247
- package/dist/__tests__/adapters/adapterSnapshotCandidates.test.js.map +0 -1
- package/dist/__tests__/capacity/anthropic.test.js +0 -115
- package/dist/__tests__/capacity/anthropic.test.js.map +0 -1
- package/dist/__tests__/capacity/boundaries.test.js +0 -45
- package/dist/__tests__/capacity/boundaries.test.js.map +0 -1
- package/dist/__tests__/capacity/claude.test.js +0 -485
- package/dist/__tests__/capacity/claude.test.js.map +0 -1
- package/dist/__tests__/capacity/codex.test.js +0 -339
- package/dist/__tests__/capacity/codex.test.js.map +0 -1
- package/dist/__tests__/capacity/devin.test.js +0 -239
- package/dist/__tests__/capacity/devin.test.js.map +0 -1
- package/dist/__tests__/capacity/index.test.js +0 -53
- package/dist/__tests__/capacity/index.test.js.map +0 -1
- package/dist/__tests__/capacity/openai.test.js +0 -687
- package/dist/__tests__/capacity/openai.test.js.map +0 -1
- package/dist/__tests__/capacity/wham.test.js +0 -159
- package/dist/__tests__/capacity/wham.test.js.map +0 -1
- package/dist/__tests__/capacity/zai.test.js +0 -212
- package/dist/__tests__/capacity/zai.test.js.map +0 -1
- package/dist/__tests__/fixtures.test.js +0 -218
- package/dist/__tests__/fixtures.test.js.map +0 -1
- package/dist/__tests__/harnesses/BoundedSummarySkip.test.js +0 -568
- package/dist/__tests__/harnesses/BoundedSummarySkip.test.js.map +0 -1
- package/dist/__tests__/harnesses/SessionSummaryEquivalence.test.js +0 -1089
- package/dist/__tests__/harnesses/SessionSummaryEquivalence.test.js.map +0 -1
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.js +0 -143
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.js.map +0 -1
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.js +0 -462
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/builtinAdapters.test.js +0 -33
- package/dist/__tests__/harnesses/builtinAdapters.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeAgentMapper.test.js +0 -79
- package/dist/__tests__/harnesses/claude/ClaudeAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeCodeAdapter.test.js +0 -1881
- package/dist/__tests__/harnesses/claude/ClaudeCodeAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeSessionLocator.test.js +0 -425
- package/dist/__tests__/harnesses/claude/ClaudeSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeSessionParser.test.js +0 -314
- package/dist/__tests__/harnesses/claude/ClaudeSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.js +0 -49
- package/dist/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.js +0 -76
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.js +0 -173
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.js +0 -181
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexAdapter.test.js +0 -685
- package/dist/__tests__/harnesses/codex/CodexAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexSessionLocator.test.js +0 -463
- package/dist/__tests__/harnesses/codex/CodexSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexSessionMapping.test.js +0 -86
- package/dist/__tests__/harnesses/codex/CodexSessionMapping.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexSessionParser.test.js +0 -254
- package/dist/__tests__/harnesses/codex/CodexSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexCliProbe.test.js +0 -121
- package/dist/__tests__/harnesses/codex/durable/CodexCliProbe.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.js +0 -84
- package/dist/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.js +0 -128
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.js +0 -246
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexPrintRunner.test.js +0 -384
- package/dist/__tests__/harnesses/codex/durable/CodexPrintRunner.test.js.map +0 -1
- package/dist/__tests__/harnesses/copilot/CopilotAdapter.test.js +0 -659
- package/dist/__tests__/harnesses/copilot/CopilotAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/copilot/CopilotRefreshIO.test.js +0 -290
- package/dist/__tests__/harnesses/copilot/CopilotRefreshIO.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinAdapter.test.js +0 -597
- package/dist/__tests__/harnesses/devin/DevinAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinAgentMapper.test.js +0 -99
- package/dist/__tests__/harnesses/devin/DevinAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinSessionLocator.test.js +0 -192
- package/dist/__tests__/harnesses/devin/DevinSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinSessionParser.test.js +0 -407
- package/dist/__tests__/harnesses/devin/DevinSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/fixtures.js +0 -95
- package/dist/__tests__/harnesses/devin/fixtures.js.map +0 -1
- package/dist/__tests__/harnesses/gemini/GeminiCliAdapter.test.js +0 -1454
- package/dist/__tests__/harnesses/gemini/GeminiCliAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/gemini/GeminiSessionJsonl.test.js +0 -491
- package/dist/__tests__/harnesses/gemini/GeminiSessionJsonl.test.js.map +0 -1
- package/dist/__tests__/harnesses/gemini/GeminiSessionLocator.test.js +0 -399
- package/dist/__tests__/harnesses/gemini/GeminiSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokAgentMapper.test.js +0 -56
- package/dist/__tests__/harnesses/grok/GrokAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokCliAdapter.test.js +0 -421
- package/dist/__tests__/harnesses/grok/GrokCliAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokIncrementalRefresh.test.js +0 -167
- package/dist/__tests__/harnesses/grok/GrokIncrementalRefresh.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokSessionLocator.test.js +0 -133
- package/dist/__tests__/harnesses/grok/GrokSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokSessionParser.test.js +0 -301
- package/dist/__tests__/harnesses/grok/GrokSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/kiro/KiroAdapter.test.js +0 -662
- package/dist/__tests__/harnesses/kiro/KiroAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseAdapter.test.js +0 -247
- package/dist/__tests__/harnesses/muse/MuseAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseAgentMapper.test.js +0 -81
- package/dist/__tests__/harnesses/muse/MuseAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseSessionLocator.test.js +0 -185
- package/dist/__tests__/harnesses/muse/MuseSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseSessionParser.test.js +0 -328
- package/dist/__tests__/harnesses/muse/MuseSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeAdapter.test.js +0 -213
- package/dist/__tests__/harnesses/opencode/OpenCodeAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.js +0 -108
- package/dist/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.js +0 -94
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionParser.test.js +0 -147
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiAdapter.test.js +0 -367
- package/dist/__tests__/harnesses/pi/PiAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiDiscoveryIO.test.js +0 -382
- package/dist/__tests__/harnesses/pi/PiDiscoveryIO.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiSessionParser.test.js +0 -416
- package/dist/__tests__/harnesses/pi/PiSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiSessionTracker.test.js +0 -108
- package/dist/__tests__/harnesses/pi/PiSessionTracker.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiCliProbe.test.js +0 -70
- package/dist/__tests__/harnesses/pi/durable/PiCliProbe.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.js +0 -43
- package/dist/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiPrintAgentService.test.js +0 -192
- package/dist/__tests__/harnesses/pi/durable/PiPrintAgentService.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiPrintProtocol.test.js +0 -119
- package/dist/__tests__/harnesses/pi/durable/PiPrintProtocol.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiPrintRunner.test.js +0 -382
- package/dist/__tests__/harnesses/pi/durable/PiPrintRunner.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiStreamParser.test.js +0 -34
- package/dist/__tests__/harnesses/pi/durable/PiStreamParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/readiness/AgentReadiness.test.js +0 -446
- package/dist/__tests__/harnesses/readiness/AgentReadiness.test.js.map +0 -1
- package/dist/__tests__/harnesses/runtimeProfiles.test.js +0 -101
- package/dist/__tests__/harnesses/runtimeProfiles.test.js.map +0 -1
- package/dist/__tests__/print/DurableAgent.test.js +0 -15
- package/dist/__tests__/print/DurableAgent.test.js.map +0 -1
- package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js +0 -186
- package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js.map +0 -1
- package/dist/__tests__/print/DurableAgentRepository.test.js +0 -249
- package/dist/__tests__/print/DurableAgentRepository.test.js.map +0 -1
- package/dist/__tests__/readiness-fixtures.test.js +0 -54
- package/dist/__tests__/readiness-fixtures.test.js.map +0 -1
- package/dist/__tests__/runtime/AgentRuntime.test.js +0 -13
- package/dist/__tests__/runtime/AgentRuntime.test.js.map +0 -1
- package/dist/__tests__/runtime/HerdrAgentDiscovery.test.js +0 -164
- package/dist/__tests__/runtime/HerdrAgentDiscovery.test.js.map +0 -1
- package/dist/__tests__/runtime/HerdrAgentRuntime.test.js +0 -488
- package/dist/__tests__/runtime/HerdrAgentRuntime.test.js.map +0 -1
- package/dist/__tests__/runtime/ManagedAgentRuntime.test.js +0 -637
- package/dist/__tests__/runtime/ManagedAgentRuntime.test.js.map +0 -1
- package/dist/__tests__/terminal/GhosttyBackend.test.js +0 -334
- package/dist/__tests__/terminal/GhosttyBackend.test.js.map +0 -1
- package/dist/__tests__/terminal/TerminalFocusManager.test.js +0 -253
- package/dist/__tests__/terminal/TerminalFocusManager.test.js.map +0 -1
- package/dist/__tests__/terminal/TmuxManager.test.js +0 -168
- package/dist/__tests__/terminal/TmuxManager.test.js.map +0 -1
- package/dist/__tests__/terminal/TtyWriter.test.js +0 -386
- package/dist/__tests__/terminal/TtyWriter.test.js.map +0 -1
- package/dist/__tests__/utils/AgentRegistry.test.js +0 -636
- package/dist/__tests__/utils/AgentRegistry.test.js.map +0 -1
- package/dist/__tests__/utils/IncrementalJsonlSummary.test.js +0 -650
- package/dist/__tests__/utils/IncrementalJsonlSummary.test.js.map +0 -1
- package/dist/__tests__/utils/agent-requests.test.js +0 -90
- package/dist/__tests__/utils/agent-requests.test.js.map +0 -1
- package/dist/__tests__/utils/conversationTail.bench.test.js +0 -258
- package/dist/__tests__/utils/conversationTail.bench.test.js.map +0 -1
- package/dist/__tests__/utils/conversationTailParity.test.js +0 -588
- package/dist/__tests__/utils/conversationTailParity.test.js.map +0 -1
- package/dist/__tests__/utils/jsonlTail.test.js +0 -360
- package/dist/__tests__/utils/jsonlTail.test.js.map +0 -1
- package/dist/__tests__/utils/matching.test.js +0 -324
- package/dist/__tests__/utils/matching.test.js.map +0 -1
- package/dist/__tests__/utils/matchingConstants.test.js +0 -35
- package/dist/__tests__/utils/matchingConstants.test.js.map +0 -1
- package/dist/__tests__/utils/process.test.js +0 -818
- package/dist/__tests__/utils/process.test.js.map +0 -1
- package/dist/__tests__/utils/session.test.js +0 -175
- package/dist/__tests__/utils/session.test.js.map +0 -1
- package/project.json +0 -29
- package/scripts/benchmark-cold-start.mjs +0 -350
- package/src/AgentManager.ts +0 -530
- package/src/__tests__/AgentManager.test.ts +0 -1483
- package/src/__tests__/adapters/IncrementalSessionRefresh.test.ts +0 -437
- package/src/__tests__/adapters/adapterProcessImports.test.ts +0 -58
- package/src/__tests__/adapters/adapterSnapshotCandidates.test.ts +0 -243
- package/src/__tests__/capacity/anthropic.test.ts +0 -105
- package/src/__tests__/capacity/boundaries.test.ts +0 -36
- package/src/__tests__/capacity/claude.test.ts +0 -462
- package/src/__tests__/capacity/codex.test.ts +0 -311
- package/src/__tests__/capacity/devin.test.ts +0 -210
- package/src/__tests__/capacity/fixtures/claude-credentials.json +0 -7
- package/src/__tests__/capacity/fixtures/claude-usage-malformed.json +0 -1
- package/src/__tests__/capacity/fixtures/claude-usage-partial.json +0 -15
- package/src/__tests__/capacity/fixtures/claude-usage.json +0 -63
- package/src/__tests__/capacity/fixtures/devin-config.json +0 -6
- package/src/__tests__/capacity/fixtures/devin-credentials.toml +0 -4
- package/src/__tests__/capacity/fixtures/devin-quota-nonplan.json +0 -5
- package/src/__tests__/capacity/fixtures/devin-quota.json +0 -10
- package/src/__tests__/capacity/fixtures/openai-auth.json +0 -6
- package/src/__tests__/capacity/fixtures/openai-codex-auth.json +0 -9
- package/src/__tests__/capacity/fixtures/openai-usage-completions.json +0 -67
- package/src/__tests__/capacity/fixtures/openai-usage-responses.json +0 -20
- package/src/__tests__/capacity/fixtures/wham-usage.json +0 -45
- package/src/__tests__/capacity/fixtures/zai-auth.json +0 -6
- package/src/__tests__/capacity/fixtures/zai-quota-invalid.json +0 -7
- package/src/__tests__/capacity/fixtures/zai-quota.json +0 -38
- package/src/__tests__/capacity/index.test.ts +0 -54
- package/src/__tests__/capacity/openai.test.ts +0 -571
- package/src/__tests__/capacity/wham.test.ts +0 -122
- package/src/__tests__/capacity/zai.test.ts +0 -151
- package/src/__tests__/fixtures.test.ts +0 -245
- package/src/__tests__/harnesses/BoundedSummarySkip.test.ts +0 -496
- package/src/__tests__/harnesses/SessionSummaryEquivalence.test.ts +0 -726
- package/src/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.ts +0 -133
- package/src/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.ts +0 -396
- package/src/__tests__/harnesses/builtinAdapters.test.ts +0 -33
- package/src/__tests__/harnesses/claude/ClaudeAgentMapper.test.ts +0 -84
- package/src/__tests__/harnesses/claude/ClaudeCodeAdapter.test.ts +0 -1793
- package/src/__tests__/harnesses/claude/ClaudeSessionLocator.test.ts +0 -423
- package/src/__tests__/harnesses/claude/ClaudeSessionParser.test.ts +0 -300
- package/src/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.ts +0 -34
- package/src/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.ts +0 -61
- package/src/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.ts +0 -129
- package/src/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.ts +0 -152
- package/src/__tests__/harnesses/codex/CodexAdapter.test.ts +0 -652
- package/src/__tests__/harnesses/codex/CodexSessionLocator.test.ts +0 -419
- package/src/__tests__/harnesses/codex/CodexSessionMapping.test.ts +0 -63
- package/src/__tests__/harnesses/codex/CodexSessionParser.test.ts +0 -192
- package/src/__tests__/harnesses/codex/durable/CodexCliProbe.test.ts +0 -80
- package/src/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.ts +0 -65
- package/src/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.ts +0 -104
- package/src/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.ts +0 -201
- package/src/__tests__/harnesses/codex/durable/CodexPrintRunner.test.ts +0 -299
- package/src/__tests__/harnesses/copilot/CopilotAdapter.test.ts +0 -614
- package/src/__tests__/harnesses/copilot/CopilotRefreshIO.test.ts +0 -270
- package/src/__tests__/harnesses/devin/DevinAdapter.test.ts +0 -290
- package/src/__tests__/harnesses/devin/DevinAgentMapper.test.ts +0 -101
- package/src/__tests__/harnesses/devin/DevinSessionLocator.test.ts +0 -139
- package/src/__tests__/harnesses/devin/DevinSessionParser.test.ts +0 -212
- package/src/__tests__/harnesses/devin/fixtures.ts +0 -144
- package/src/__tests__/harnesses/gemini/GeminiCliAdapter.test.ts +0 -1336
- package/src/__tests__/harnesses/gemini/GeminiSessionJsonl.test.ts +0 -402
- package/src/__tests__/harnesses/gemini/GeminiSessionLocator.test.ts +0 -396
- package/src/__tests__/harnesses/grok/GrokAgentMapper.test.ts +0 -57
- package/src/__tests__/harnesses/grok/GrokCliAdapter.test.ts +0 -376
- package/src/__tests__/harnesses/grok/GrokIncrementalRefresh.test.ts +0 -170
- package/src/__tests__/harnesses/grok/GrokSessionLocator.test.ts +0 -106
- package/src/__tests__/harnesses/grok/GrokSessionParser.test.ts +0 -230
- package/src/__tests__/harnesses/kiro/KiroAdapter.test.ts +0 -552
- package/src/__tests__/harnesses/muse/MuseAdapter.test.ts +0 -197
- package/src/__tests__/harnesses/muse/MuseAgentMapper.test.ts +0 -83
- package/src/__tests__/harnesses/muse/MuseSessionLocator.test.ts +0 -177
- package/src/__tests__/harnesses/muse/MuseSessionParser.test.ts +0 -279
- package/src/__tests__/harnesses/opencode/OpenCodeAdapter.test.ts +0 -215
- package/src/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.ts +0 -101
- package/src/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.ts +0 -84
- package/src/__tests__/harnesses/opencode/OpenCodeSessionParser.test.ts +0 -149
- package/src/__tests__/harnesses/pi/PiAdapter.test.ts +0 -325
- package/src/__tests__/harnesses/pi/PiDiscoveryIO.test.ts +0 -337
- package/src/__tests__/harnesses/pi/PiSessionParser.test.ts +0 -280
- package/src/__tests__/harnesses/pi/PiSessionTracker.test.ts +0 -79
- package/src/__tests__/harnesses/pi/durable/PiCliProbe.test.ts +0 -50
- package/src/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.ts +0 -33
- package/src/__tests__/harnesses/pi/durable/PiPrintAgentService.test.ts +0 -138
- package/src/__tests__/harnesses/pi/durable/PiPrintProtocol.test.ts +0 -71
- package/src/__tests__/harnesses/pi/durable/PiPrintRunner.test.ts +0 -252
- package/src/__tests__/harnesses/pi/durable/PiStreamParser.test.ts +0 -26
- package/src/__tests__/harnesses/readiness/AgentReadiness.test.ts +0 -362
- package/src/__tests__/harnesses/runtimeProfiles.test.ts +0 -123
- package/src/__tests__/print/DurableAgent.test.ts +0 -15
- package/src/__tests__/print/DurableAgentRepository.sqlite.test.ts +0 -128
- package/src/__tests__/print/DurableAgentRepository.test.ts +0 -184
- package/src/__tests__/readiness-fixtures.test.ts +0 -79
- package/src/__tests__/runtime/AgentRuntime.test.ts +0 -8
- package/src/__tests__/runtime/HerdrAgentDiscovery.test.ts +0 -131
- package/src/__tests__/runtime/HerdrAgentRuntime.test.ts +0 -377
- package/src/__tests__/runtime/ManagedAgentRuntime.test.ts +0 -590
- package/src/__tests__/terminal/GhosttyBackend.test.ts +0 -271
- package/src/__tests__/terminal/TerminalFocusManager.test.ts +0 -280
- package/src/__tests__/terminal/TmuxManager.test.ts +0 -185
- package/src/__tests__/terminal/TtyWriter.test.ts +0 -454
- package/src/__tests__/utils/AgentRegistry.test.ts +0 -532
- package/src/__tests__/utils/IncrementalJsonlSummary.test.ts +0 -414
- package/src/__tests__/utils/agent-requests.test.ts +0 -94
- package/src/__tests__/utils/conversationTail.bench.test.ts +0 -193
- package/src/__tests__/utils/conversationTailParity.test.ts +0 -365
- package/src/__tests__/utils/jsonlTail.test.ts +0 -317
- package/src/__tests__/utils/matching.test.ts +0 -234
- package/src/__tests__/utils/matchingConstants.test.ts +0 -40
- package/src/__tests__/utils/process.test.ts +0 -596
- package/src/__tests__/utils/session.test.ts +0 -158
- package/src/adapters/AgentAdapter.ts +0 -255
- package/src/capacity/index.ts +0 -127
- package/src/capacity/providers/anthropic.ts +0 -198
- package/src/capacity/providers/devin.ts +0 -121
- package/src/capacity/providers/openai-platform.ts +0 -150
- package/src/capacity/providers/openai-subscription.ts +0 -184
- package/src/capacity/providers/zai.ts +0 -155
- package/src/capacity/sources/claude.ts +0 -30
- package/src/capacity/sources/codex.ts +0 -251
- package/src/capacity/sources/devin.ts +0 -49
- package/src/capacity/sources/pi.ts +0 -131
- package/src/capacity/types.ts +0 -29
- package/src/database/connection.ts +0 -96
- package/src/database/index.ts +0 -7
- package/src/database/migrations/001_initial.sql +0 -12
- package/src/database/migrations/002_pins.sql +0 -1
- package/src/database/migrations/003_durable_agents.sql +0 -43
- package/src/database/migrations/004_codex_durable_sessions.sql +0 -1
- package/src/database/migrations/005_agent_runtime.sql +0 -2
- package/src/database/schema.ts +0 -64
- package/src/durable/DurableAgent.ts +0 -139
- package/src/durable/DurableAgentRepository.ts +0 -485
- package/src/durable/process.ts +0 -29
- package/src/durable/run.ts +0 -84
- package/src/durable/utils.ts +0 -66
- package/src/fixtures/bundle.ts +0 -130
- package/src/fixtures/capture.ts +0 -364
- package/src/harnesses/antigravity/AntigravityAgentMapper.ts +0 -34
- package/src/harnesses/antigravity/AntigravityCliAdapter.ts +0 -126
- package/src/harnesses/antigravity/AntigravitySessionLocator.ts +0 -75
- package/src/harnesses/antigravity/AntigravitySessionParser.ts +0 -252
- package/src/harnesses/claude/ClaudeAgentMapper.ts +0 -55
- package/src/harnesses/claude/ClaudeCodeAdapter.ts +0 -175
- package/src/harnesses/claude/ClaudeSessionLocator.ts +0 -358
- package/src/harnesses/claude/ClaudeSessionParser.ts +0 -524
- package/src/harnesses/claude/credentials.ts +0 -122
- package/src/harnesses/claude/durable/ClaudeCliProbe.ts +0 -57
- package/src/harnesses/claude/durable/ClaudePrintAgentService.ts +0 -79
- package/src/harnesses/claude/durable/ClaudePrintRunner.ts +0 -102
- package/src/harnesses/claude/durable/ClaudeStreamParser.ts +0 -108
- package/src/harnesses/claude/readiness.ts +0 -69
- package/src/harnesses/codex/CodexAdapter.ts +0 -337
- package/src/harnesses/codex/CodexAgentMapper.ts +0 -26
- package/src/harnesses/codex/CodexSessionLocator.ts +0 -509
- package/src/harnesses/codex/CodexSessionMapping.ts +0 -89
- package/src/harnesses/codex/CodexSessionParser.ts +0 -462
- package/src/harnesses/codex/credentials.ts +0 -81
- package/src/harnesses/codex/durable/CodexCliProbe.ts +0 -68
- package/src/harnesses/codex/durable/CodexPrintAgentService.ts +0 -79
- package/src/harnesses/codex/durable/CodexPrintRunner.ts +0 -104
- package/src/harnesses/codex/durable/CodexStreamParser.ts +0 -117
- package/src/harnesses/codex/readiness.ts +0 -72
- package/src/harnesses/copilot/CopilotAdapter.ts +0 -161
- package/src/harnesses/copilot/CopilotAgentMapper.ts +0 -27
- package/src/harnesses/copilot/CopilotSessionLocator.ts +0 -161
- package/src/harnesses/copilot/CopilotSessionParser.ts +0 -380
- package/src/harnesses/copilot/readiness.ts +0 -33
- package/src/harnesses/devin/DevinAdapter.ts +0 -212
- package/src/harnesses/devin/DevinAgentMapper.ts +0 -39
- package/src/harnesses/devin/DevinSessionLocator.ts +0 -230
- package/src/harnesses/devin/DevinSessionParser.ts +0 -227
- package/src/harnesses/devin/credentials.ts +0 -88
- package/src/harnesses/devin/readiness.ts +0 -36
- package/src/harnesses/gemini/GeminiAgentMapper.ts +0 -27
- package/src/harnesses/gemini/GeminiCliAdapter.ts +0 -272
- package/src/harnesses/gemini/GeminiSessionLocator.ts +0 -394
- package/src/harnesses/gemini/GeminiSessionParser.ts +0 -395
- package/src/harnesses/gemini/fileSignature.ts +0 -10
- package/src/harnesses/grok/GrokAgentMapper.ts +0 -32
- package/src/harnesses/grok/GrokCliAdapter.ts +0 -126
- package/src/harnesses/grok/GrokSessionLocator.ts +0 -179
- package/src/harnesses/grok/GrokSessionParser.ts +0 -251
- package/src/harnesses/index.ts +0 -32
- package/src/harnesses/kiro/KiroAdapter.ts +0 -143
- package/src/harnesses/kiro/KiroAgentMapper.ts +0 -34
- package/src/harnesses/kiro/KiroSessionLocator.ts +0 -143
- package/src/harnesses/kiro/KiroSessionParser.ts +0 -376
- package/src/harnesses/muse/MuseAdapter.ts +0 -157
- package/src/harnesses/muse/MuseAgentMapper.ts +0 -33
- package/src/harnesses/muse/MuseSessionLocator.ts +0 -286
- package/src/harnesses/muse/MuseSessionParser.ts +0 -435
- package/src/harnesses/muse/readiness.ts +0 -38
- package/src/harnesses/opencode/OpenCodeAdapter.ts +0 -110
- package/src/harnesses/opencode/OpenCodeAgentMapper.ts +0 -49
- package/src/harnesses/opencode/OpenCodeSessionLocator.ts +0 -151
- package/src/harnesses/opencode/OpenCodeSessionParser.ts +0 -146
- package/src/harnesses/opencode/readiness.ts +0 -48
- package/src/harnesses/pi/PiAdapter.ts +0 -197
- package/src/harnesses/pi/PiAgentMapper.ts +0 -27
- package/src/harnesses/pi/PiSessionLocator.ts +0 -288
- package/src/harnesses/pi/PiSessionParser.ts +0 -488
- package/src/harnesses/pi/PiSessionTracker.ts +0 -87
- package/src/harnesses/pi/credentials.ts +0 -129
- package/src/harnesses/pi/durable/PiCliProbe.ts +0 -56
- package/src/harnesses/pi/durable/PiPrintAgentService.ts +0 -77
- package/src/harnesses/pi/durable/PiPrintProtocol.ts +0 -41
- package/src/harnesses/pi/durable/PiPrintRunner.ts +0 -95
- package/src/harnesses/pi/durable/PiStreamParser.ts +0 -94
- package/src/harnesses/pi/readiness.ts +0 -104
- package/src/harnesses/readiness/AgentReadiness.ts +0 -91
- package/src/harnesses/readiness/checks.ts +0 -336
- package/src/harnesses/readiness/types.ts +0 -90
- package/src/harnesses/runtimeProfiles.ts +0 -105
- package/src/harnesses/shared.ts +0 -124
- package/src/index.ts +0 -70
- package/src/runtime/ManagedAgentRuntime.ts +0 -253
- package/src/runtime/RuntimeFactory.ts +0 -13
- package/src/runtime/errors.ts +0 -50
- package/src/runtime/herdr/HerdrAgentDiscovery.ts +0 -166
- package/src/runtime/herdr/HerdrAgentRuntime.ts +0 -216
- package/src/runtime/herdr/HerdrCliClient.ts +0 -78
- package/src/runtime/herdr/HerdrErrors.ts +0 -9
- package/src/runtime/herdr/HerdrResponseParsers.ts +0 -86
- package/src/runtime/herdr/HerdrRuntimeRef.ts +0 -41
- package/src/runtime/tmux/PidPolling.ts +0 -34
- package/src/runtime/tmux/TmuxAgentRuntime.ts +0 -113
- package/src/runtime/tmux/TmuxManager.ts +0 -102
- package/src/runtime/tmux/TmuxRuntimeRef.ts +0 -9
- package/src/runtime/types.ts +0 -56
- package/src/terminal/TerminalFocusManager.ts +0 -52
- package/src/terminal/TtyWriter.ts +0 -26
- package/src/terminal/backends/ghostty.ts +0 -180
- package/src/terminal/backends/index.ts +0 -23
- package/src/terminal/backends/iterm2.ts +0 -126
- package/src/terminal/backends/shared.ts +0 -47
- package/src/terminal/backends/terminal-app.ts +0 -122
- package/src/terminal/backends/tmux.ts +0 -62
- package/src/terminal/backends/wezterm.ts +0 -65
- package/src/terminal/types.ts +0 -23
- package/src/utils/AgentRegistry.ts +0 -351
- package/src/utils/IncrementalJsonlSummary.ts +0 -306
- package/src/utils/agent-requests.ts +0 -28
- package/src/utils/applescript.ts +0 -10
- package/src/utils/jsonlTail.ts +0 -349
- package/src/utils/matching.ts +0 -96
- package/src/utils/matchingConstants.ts +0 -15
- package/src/utils/process.ts +0 -604
- package/src/utils/session.ts +0 -144
- package/src/utils/sortAgents.ts +0 -54
- package/tsconfig.json +0 -11
- package/vitest.config.ts +0 -20
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
import Database from "better-sqlite3";
|
|
4
|
-
import type { ListSessionsOptions, SessionSummary } from "../../adapters/AgentAdapter.js";
|
|
5
|
-
import { OpenCodeSessionParser } from "./OpenCodeSessionParser.js";
|
|
6
|
-
import { homeDir } from "../shared.js";
|
|
7
|
-
|
|
8
|
-
const SESSION_REF_SEP = "::";
|
|
9
|
-
|
|
10
|
-
function encodeOpenCodeSessionRef(dbPath: string, sessionId: string): string {
|
|
11
|
-
return `${dbPath}${SESSION_REF_SEP}${sessionId}`;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface OpenCodeSession {
|
|
15
|
-
sessionId: string;
|
|
16
|
-
directory: string;
|
|
17
|
-
timeCreated: number;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface OpenCodeSessionRow {
|
|
21
|
-
id: string;
|
|
22
|
-
directory: string;
|
|
23
|
-
timeCreated: number;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export class OpenCodeSessionLocator {
|
|
27
|
-
private readonly dbPath: string;
|
|
28
|
-
private db: Database.Database | null = null;
|
|
29
|
-
|
|
30
|
-
constructor(
|
|
31
|
-
dbPath = OpenCodeSessionLocator.resolveDbPath(),
|
|
32
|
-
private readonly parser: OpenCodeSessionParser = new OpenCodeSessionParser(),
|
|
33
|
-
) {
|
|
34
|
-
this.dbPath = dbPath;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
static resolveDbPath(): string {
|
|
38
|
-
const xdg = process.env.XDG_DATA_HOME;
|
|
39
|
-
const base = xdg || path.join(homeDir(), ".local", "share");
|
|
40
|
-
return path.join(base, "opencode", "opencode.db");
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
openDb(): Database.Database | null {
|
|
44
|
-
if (this.db) return this.db;
|
|
45
|
-
if (!fs.existsSync(this.dbPath)) return null;
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
this.db = new Database(this.dbPath, { readonly: true });
|
|
49
|
-
return this.db;
|
|
50
|
-
} catch {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
close(): void {
|
|
56
|
-
if (this.db) {
|
|
57
|
-
try {
|
|
58
|
-
this.db.close();
|
|
59
|
-
} catch {
|
|
60
|
-
/* ignore */
|
|
61
|
-
}
|
|
62
|
-
this.db = null;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
findSessionForDirectory(db: Database.Database, directory: string): OpenCodeSession | null {
|
|
67
|
-
try {
|
|
68
|
-
const row = db
|
|
69
|
-
.prepare<[string], { id: string; directory: string; time_created: number }>(`
|
|
70
|
-
SELECT id, directory, time_created
|
|
71
|
-
FROM session
|
|
72
|
-
WHERE directory = ?
|
|
73
|
-
ORDER BY time_created DESC
|
|
74
|
-
LIMIT 1
|
|
75
|
-
`)
|
|
76
|
-
.get(directory);
|
|
77
|
-
|
|
78
|
-
if (!row) return null;
|
|
79
|
-
return { sessionId: row.id, directory: row.directory, timeCreated: row.time_created };
|
|
80
|
-
} catch {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
listSessions(opts?: ListSessionsOptions): SessionSummary[] {
|
|
86
|
-
const db = this.openDb();
|
|
87
|
-
if (!db) return [];
|
|
88
|
-
|
|
89
|
-
try {
|
|
90
|
-
const rows = db
|
|
91
|
-
.prepare<[], OpenCodeSessionRow>(`
|
|
92
|
-
SELECT id, directory, time_created AS timeCreated
|
|
93
|
-
FROM session
|
|
94
|
-
ORDER BY time_created DESC
|
|
95
|
-
`)
|
|
96
|
-
.all();
|
|
97
|
-
|
|
98
|
-
const summaries: SessionSummary[] = [];
|
|
99
|
-
|
|
100
|
-
for (const row of rows) {
|
|
101
|
-
if (opts?.cwd !== undefined && row.directory !== opts.cwd) continue;
|
|
102
|
-
|
|
103
|
-
summaries.push(this.toSessionSummary(db, row));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return summaries;
|
|
107
|
-
} catch {
|
|
108
|
-
this.close();
|
|
109
|
-
return [];
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
findSessionsById(sessionId: string): SessionSummary[] {
|
|
114
|
-
const db = this.openDb();
|
|
115
|
-
if (!db) return [];
|
|
116
|
-
|
|
117
|
-
try {
|
|
118
|
-
const row = db
|
|
119
|
-
.prepare<[string], OpenCodeSessionRow>(`
|
|
120
|
-
SELECT id, directory, time_created AS timeCreated
|
|
121
|
-
FROM session
|
|
122
|
-
WHERE id = ?
|
|
123
|
-
`)
|
|
124
|
-
.get(sessionId);
|
|
125
|
-
return row ? [this.toSessionSummary(db, row)] : [];
|
|
126
|
-
} catch {
|
|
127
|
-
this.close();
|
|
128
|
-
return [];
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
private toSessionSummary(db: Database.Database, row: OpenCodeSessionRow): SessionSummary {
|
|
133
|
-
const stats = this.parser.getSessionStats(db, row.id);
|
|
134
|
-
const lastActive =
|
|
135
|
-
stats.lastTimeUpdated > 0 ? new Date(stats.lastTimeUpdated) : new Date(row.timeCreated);
|
|
136
|
-
|
|
137
|
-
return {
|
|
138
|
-
type: "opencode",
|
|
139
|
-
sessionId: row.id,
|
|
140
|
-
cwd: row.directory,
|
|
141
|
-
firstUserMessage: stats.summary,
|
|
142
|
-
lastActive,
|
|
143
|
-
startedAt: new Date(row.timeCreated),
|
|
144
|
-
sessionFilePath: encodeOpenCodeSessionRef(this.dbPath, row.id),
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
get dbFilePath(): string {
|
|
149
|
-
return this.dbPath;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import type { ConversationMessage, ConversationOptions } from "../../adapters/AgentAdapter.js";
|
|
2
|
-
import { sliceTail } from "../../utils/jsonlTail.js";
|
|
3
|
-
import type Database from "better-sqlite3";
|
|
4
|
-
|
|
5
|
-
export interface OpenCodeSessionStats {
|
|
6
|
-
lastRole: string | null;
|
|
7
|
-
lastTimeUpdated: number;
|
|
8
|
-
/** OpenCode writes `time.completed` on the assistant message only when the turn finishes. */
|
|
9
|
-
lastAssistantCompleted: boolean;
|
|
10
|
-
lastAssistantErrored: boolean;
|
|
11
|
-
summary: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface OpenCodePartData {
|
|
15
|
-
type?: string;
|
|
16
|
-
text?: string;
|
|
17
|
-
reasoning?: string;
|
|
18
|
-
tool?: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const EMPTY_STATS: OpenCodeSessionStats = {
|
|
22
|
-
lastRole: null,
|
|
23
|
-
lastTimeUpdated: 0,
|
|
24
|
-
lastAssistantCompleted: false,
|
|
25
|
-
lastAssistantErrored: false,
|
|
26
|
-
summary: "",
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export class OpenCodeSessionParser {
|
|
30
|
-
getConversation(
|
|
31
|
-
db: Database.Database,
|
|
32
|
-
sessionId: string,
|
|
33
|
-
options?: ConversationOptions,
|
|
34
|
-
): ConversationMessage[] {
|
|
35
|
-
const verbose = options?.verbose ?? false;
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
const rows = db
|
|
39
|
-
.prepare<[string], { role: string; partData: string; timeCreated: number }>(`
|
|
40
|
-
SELECT json_extract(m.data, '$.role') AS role,
|
|
41
|
-
p.data AS partData,
|
|
42
|
-
p.time_created AS timeCreated
|
|
43
|
-
FROM part p
|
|
44
|
-
JOIN message m ON p.message_id = m.id
|
|
45
|
-
WHERE p.session_id = ?
|
|
46
|
-
ORDER BY p.time_created ASC
|
|
47
|
-
`)
|
|
48
|
-
.all(sessionId);
|
|
49
|
-
|
|
50
|
-
const messages: ConversationMessage[] = [];
|
|
51
|
-
|
|
52
|
-
for (const row of rows) {
|
|
53
|
-
const partData = this.parsePartData(row.partData);
|
|
54
|
-
if (!partData) continue;
|
|
55
|
-
|
|
56
|
-
const role = row.role === "user" ? "user" : "assistant";
|
|
57
|
-
|
|
58
|
-
if (partData.type === "text" && partData.text) {
|
|
59
|
-
messages.push({ role, content: partData.text });
|
|
60
|
-
} else if (partData.type === "reasoning" && verbose) {
|
|
61
|
-
const text = partData.reasoning || partData.text || "";
|
|
62
|
-
if (text) messages.push({ role: "assistant", content: `[thinking] ${text}` });
|
|
63
|
-
} else if (partData.type === "tool" && verbose) {
|
|
64
|
-
const toolName = partData.tool || "tool";
|
|
65
|
-
messages.push({ role: "assistant", content: `[tool: ${toolName}]` });
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return sliceTail(messages, options?.tail);
|
|
70
|
-
} catch {
|
|
71
|
-
return [];
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
getSessionStats(db: Database.Database, sessionId: string): OpenCodeSessionStats {
|
|
76
|
-
try {
|
|
77
|
-
// Order by time_created — time_updated can lag when OpenCode appends
|
|
78
|
-
// metadata (e.g. summary diffs) to user messages after a turn finishes.
|
|
79
|
-
const last = db
|
|
80
|
-
.prepare<[string], { role: string; timeUpdated: number }>(`
|
|
81
|
-
SELECT json_extract(data, '$.role') AS role,
|
|
82
|
-
time_updated AS timeUpdated
|
|
83
|
-
FROM message
|
|
84
|
-
WHERE session_id = ?
|
|
85
|
-
ORDER BY time_created DESC
|
|
86
|
-
LIMIT 1
|
|
87
|
-
`)
|
|
88
|
-
.get(sessionId);
|
|
89
|
-
|
|
90
|
-
const heartbeat = db
|
|
91
|
-
.prepare<[string], { maxUpdated: number }>(`
|
|
92
|
-
SELECT MAX(time_updated) AS maxUpdated FROM message WHERE session_id = ?
|
|
93
|
-
`)
|
|
94
|
-
.get(sessionId);
|
|
95
|
-
|
|
96
|
-
const lastAssistant = db
|
|
97
|
-
.prepare<
|
|
98
|
-
[string],
|
|
99
|
-
{
|
|
100
|
-
completed: number | null;
|
|
101
|
-
errored: number | null;
|
|
102
|
-
}
|
|
103
|
-
>(`
|
|
104
|
-
SELECT json_extract(data, '$.time.completed') AS completed,
|
|
105
|
-
json_extract(data, '$.time.error') AS errored
|
|
106
|
-
FROM message
|
|
107
|
-
WHERE session_id = ? AND json_extract(data, '$.role') = 'assistant'
|
|
108
|
-
ORDER BY time_created DESC
|
|
109
|
-
LIMIT 1
|
|
110
|
-
`)
|
|
111
|
-
.get(sessionId);
|
|
112
|
-
|
|
113
|
-
const first = db
|
|
114
|
-
.prepare<[string], { text: string }>(`
|
|
115
|
-
SELECT json_extract(p.data, '$.text') AS text
|
|
116
|
-
FROM part p
|
|
117
|
-
JOIN message m ON p.message_id = m.id
|
|
118
|
-
WHERE p.session_id = ?
|
|
119
|
-
AND json_extract(m.data, '$.role') = 'user'
|
|
120
|
-
AND json_extract(p.data, '$.type') = 'text'
|
|
121
|
-
AND json_extract(p.data, '$.text') IS NOT NULL
|
|
122
|
-
ORDER BY p.time_created ASC
|
|
123
|
-
LIMIT 1
|
|
124
|
-
`)
|
|
125
|
-
.get(sessionId);
|
|
126
|
-
|
|
127
|
-
return {
|
|
128
|
-
lastRole: last?.role ?? null,
|
|
129
|
-
lastTimeUpdated: heartbeat?.maxUpdated ?? last?.timeUpdated ?? 0,
|
|
130
|
-
lastAssistantCompleted: lastAssistant?.completed != null,
|
|
131
|
-
lastAssistantErrored: lastAssistant?.errored != null,
|
|
132
|
-
summary: first?.text?.trim() ?? "",
|
|
133
|
-
};
|
|
134
|
-
} catch {
|
|
135
|
-
return EMPTY_STATS;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
private parsePartData(partData: string): OpenCodePartData | null {
|
|
140
|
-
try {
|
|
141
|
-
return JSON.parse(partData) as OpenCodePartData;
|
|
142
|
-
} catch {
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AuthReadinessCheck,
|
|
3
|
-
HarnessReadinessProfile,
|
|
4
|
-
ReadinessRuntime,
|
|
5
|
-
} from "../readiness/types.js";
|
|
6
|
-
|
|
7
|
-
const ANSI_ESCAPE_PATTERN = new RegExp(`${String.fromCharCode(27)}\\[[0-?]*[ -/]*[@-~]`, "g");
|
|
8
|
-
|
|
9
|
-
function authProviderNames(output: string): string[] {
|
|
10
|
-
const names = new Set<string>();
|
|
11
|
-
for (const line of output.replace(ANSI_ESCAPE_PATTERN, "").split(/\r?\n/)) {
|
|
12
|
-
const match = /^\s*[●*+-]\s+(.+?)\s*$/.exec(line);
|
|
13
|
-
if (!match) continue;
|
|
14
|
-
const name = match[1].replace(/\s+(?:api|oauth|[\w-]*token|[A-Z][A-Z0-9_]+)$/i, "").trim();
|
|
15
|
-
if (name && !/^\d+\s+(?:credentials?|environment variables?)$/i.test(name)) names.add(name);
|
|
16
|
-
}
|
|
17
|
-
return [...names].sort();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async function authCheck(runtime: ReadinessRuntime): Promise<AuthReadinessCheck> {
|
|
21
|
-
try {
|
|
22
|
-
const result = await runtime.runCommand("opencode", ["auth", "list"]);
|
|
23
|
-
const availableProviders = authProviderNames(result.stdout);
|
|
24
|
-
const authenticated = availableProviders.length > 0;
|
|
25
|
-
return {
|
|
26
|
-
state: authenticated ? "authenticated" : "unauthenticated",
|
|
27
|
-
source: "opencode auth list",
|
|
28
|
-
provider: null,
|
|
29
|
-
availableProviders,
|
|
30
|
-
status: authenticated ? "pass" : "fail",
|
|
31
|
-
errors: authenticated ? [] : ["OpenCode has no configured credentials"],
|
|
32
|
-
};
|
|
33
|
-
} catch {
|
|
34
|
-
return {
|
|
35
|
-
state: "unknown",
|
|
36
|
-
source: "opencode auth list",
|
|
37
|
-
provider: null,
|
|
38
|
-
availableProviders: [],
|
|
39
|
-
status: "warn",
|
|
40
|
-
errors: ["OpenCode authentication probe failed"],
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export const openCodeReadiness: HarnessReadinessProfile = {
|
|
46
|
-
configDir: ".config/opencode",
|
|
47
|
-
auth: authCheck,
|
|
48
|
-
};
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
import type {
|
|
4
|
-
AgentAdapter,
|
|
5
|
-
AgentInfo,
|
|
6
|
-
ProcessInfo,
|
|
7
|
-
ConversationMessage,
|
|
8
|
-
ConversationOptions,
|
|
9
|
-
SessionSummary,
|
|
10
|
-
ListSessionsOptions,
|
|
11
|
-
AgentDetectionContext,
|
|
12
|
-
} from "../../adapters/AgentAdapter.js";
|
|
13
|
-
import { executableBasename } from "../../utils/process.js";
|
|
14
|
-
import { AgentRegistry } from "../../utils/AgentRegistry.js";
|
|
15
|
-
import { PiAgentMapper } from "./PiAgentMapper.js";
|
|
16
|
-
import { PiSessionLocator } from "./PiSessionLocator.js";
|
|
17
|
-
import { PiSessionParser } from "./PiSessionParser.js";
|
|
18
|
-
import { PiSessionTracker } from "./PiSessionTracker.js";
|
|
19
|
-
import { findHarnessProcesses, homeDir } from "../shared.js";
|
|
20
|
-
|
|
21
|
-
interface MappedAgentResult {
|
|
22
|
-
agents: AgentInfo[];
|
|
23
|
-
fallback: ProcessInfo[];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface SessionFileMatch {
|
|
27
|
-
process: ProcessInfo;
|
|
28
|
-
filePath: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export class PiAdapter implements AgentAdapter {
|
|
32
|
-
readonly type = "pi" as const;
|
|
33
|
-
readonly processNames = ["pi", "node"] as const;
|
|
34
|
-
|
|
35
|
-
private readonly piSessionsDir: string;
|
|
36
|
-
private readonly trackerPath: string;
|
|
37
|
-
private readonly registry: AgentRegistry;
|
|
38
|
-
private readonly parser: PiSessionParser;
|
|
39
|
-
private readonly mapper: PiAgentMapper;
|
|
40
|
-
/** Kept across refreshes so live discovery can reuse its head and no-match caches. */
|
|
41
|
-
private readonly liveLocator: PiSessionLocator;
|
|
42
|
-
|
|
43
|
-
constructor(registry: AgentRegistry = AgentRegistry.default()) {
|
|
44
|
-
const piAgentDir = path.join(homeDir(), ".pi", "agent");
|
|
45
|
-
this.piSessionsDir = path.join(piAgentDir, "sessions");
|
|
46
|
-
this.trackerPath = path.join(piAgentDir, "sessions.json");
|
|
47
|
-
this.registry = registry;
|
|
48
|
-
this.parser = new PiSessionParser();
|
|
49
|
-
this.mapper = new PiAgentMapper(this.parser);
|
|
50
|
-
this.liveLocator = this.createLocator();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
canHandle(processInfo: ProcessInfo): boolean {
|
|
54
|
-
return this.isPiExecutable(processInfo.command);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async detectAgents(context?: AgentDetectionContext): Promise<AgentInfo[]> {
|
|
58
|
-
try {
|
|
59
|
-
return await this.detectRunningAgents(context);
|
|
60
|
-
} finally {
|
|
61
|
-
// Drop cached summaries for sessions that were not part of this refresh
|
|
62
|
-
this.parser.pruneSessionCache();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private async detectRunningAgents(context?: AgentDetectionContext): Promise<AgentInfo[]> {
|
|
67
|
-
const processes = await this.getPiProcesses(context);
|
|
68
|
-
if (processes.length === 0) return [];
|
|
69
|
-
|
|
70
|
-
const cacheResult = this.mapRegistryCache(processes);
|
|
71
|
-
const trackerResult = this.mapTrackerMatches(cacheResult.fallback);
|
|
72
|
-
const locatorResult = this.liveLocator.matchRunningProcesses(trackerResult.fallback);
|
|
73
|
-
const legacyResult = this.mapLegacyMatches(locatorResult.legacyMatches);
|
|
74
|
-
const unmatchedProcesses = this.findUnmatchedProcesses(
|
|
75
|
-
locatorResult.fallback,
|
|
76
|
-
legacyResult.agents,
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
return [
|
|
80
|
-
...cacheResult.agents,
|
|
81
|
-
...trackerResult.agents,
|
|
82
|
-
...legacyResult.agents,
|
|
83
|
-
...unmatchedProcesses.map((processInfo) => this.mapper.mapProcessOnlyAgent(processInfo)),
|
|
84
|
-
];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
getConversation(sessionFilePath: string, options?: ConversationOptions): ConversationMessage[] {
|
|
88
|
-
return this.parser.getConversation(sessionFilePath, options);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
async listSessions(opts?: ListSessionsOptions): Promise<SessionSummary[]> {
|
|
92
|
-
const summaries: SessionSummary[] = [];
|
|
93
|
-
|
|
94
|
-
for (const filePath of this.createLocator().discoverHistoricalSessionFiles()) {
|
|
95
|
-
const summary = this.parser.fileToSessionSummary(filePath);
|
|
96
|
-
if (!summary) continue;
|
|
97
|
-
if (opts?.cwd !== undefined && summary.cwd !== opts.cwd) continue;
|
|
98
|
-
summaries.push(summary);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return summaries;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
async findSessionsById(sessionId: string): Promise<SessionSummary[]> {
|
|
105
|
-
const summaries: SessionSummary[] = [];
|
|
106
|
-
const filePaths = this.createLocator().findHistoricalSessionFilesById(sessionId);
|
|
107
|
-
for (const filePath of filePaths) {
|
|
108
|
-
const summary = this.parser.fileToSessionSummary(filePath);
|
|
109
|
-
if (summary?.sessionId === sessionId) summaries.push(summary);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (summaries.length > 0) return summaries;
|
|
113
|
-
return (await this.listSessions()).filter((summary) => summary.sessionId === sessionId);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
private async getPiProcesses(context?: AgentDetectionContext): Promise<ProcessInfo[]> {
|
|
117
|
-
return (await findHarnessProcesses(this, context)).processes;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
private createLocator(): PiSessionLocator {
|
|
121
|
-
return new PiSessionLocator({ sessionsDir: this.piSessionsDir }, this.parser);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
private createTracker(): PiSessionTracker {
|
|
125
|
-
return new PiSessionTracker({
|
|
126
|
-
sessionsDir: this.piSessionsDir,
|
|
127
|
-
trackerPath: this.trackerPath,
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
private mapRegistryCache(processes: ProcessInfo[]): MappedAgentResult {
|
|
132
|
-
const matches: SessionFileMatch[] = [];
|
|
133
|
-
const fallback: ProcessInfo[] = [];
|
|
134
|
-
const byPid = new Map(this.registry.list().map((entry) => [entry.pid, entry]));
|
|
135
|
-
|
|
136
|
-
for (const processInfo of processes) {
|
|
137
|
-
const entry = byPid.get(processInfo.pid);
|
|
138
|
-
if (
|
|
139
|
-
!entry ||
|
|
140
|
-
entry.type !== this.type ||
|
|
141
|
-
!entry.sessionFilePath ||
|
|
142
|
-
!fs.existsSync(entry.sessionFilePath)
|
|
143
|
-
) {
|
|
144
|
-
fallback.push(processInfo);
|
|
145
|
-
continue;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
matches.push({ process: processInfo, filePath: entry.sessionFilePath });
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const mapped = this.mapSessionFileMatches(matches);
|
|
152
|
-
return { agents: mapped.agents, fallback: [...fallback, ...mapped.fallback] };
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
private mapTrackerMatches(processes: ProcessInfo[]): MappedAgentResult {
|
|
156
|
-
const { matches, fallback } = this.createTracker().match(processes);
|
|
157
|
-
const mapped = this.mapSessionFileMatches(matches);
|
|
158
|
-
return { agents: mapped.agents, fallback: [...fallback, ...mapped.fallback] };
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
private mapLegacyMatches(
|
|
162
|
-
matches: Array<{ process: ProcessInfo; session: { filePath: string } }>,
|
|
163
|
-
): MappedAgentResult {
|
|
164
|
-
return this.mapSessionFileMatches(
|
|
165
|
-
matches.map((match) => ({ process: match.process, filePath: match.session.filePath })),
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
private mapSessionFileMatches(matches: SessionFileMatch[]): MappedAgentResult {
|
|
170
|
-
const agents: AgentInfo[] = [];
|
|
171
|
-
const fallback: ProcessInfo[] = [];
|
|
172
|
-
|
|
173
|
-
for (const match of matches) {
|
|
174
|
-
const session = this.parser.readSessionIncremental(match.filePath, match.process.cwd);
|
|
175
|
-
if (session) {
|
|
176
|
-
agents.push(this.mapper.mapSessionToAgent(session, match.process, match.filePath));
|
|
177
|
-
} else {
|
|
178
|
-
fallback.push(match.process);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return { agents, fallback };
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
private findUnmatchedProcesses(processes: ProcessInfo[], agents: AgentInfo[]): ProcessInfo[] {
|
|
186
|
-
const matchedPids = new Set(agents.map((agent) => agent.pid));
|
|
187
|
-
return processes.filter((processInfo) => !matchedPids.has(processInfo.pid));
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
private isPiExecutable(command: string): boolean {
|
|
191
|
-
for (const token of command.trim().split(/\s+/)) {
|
|
192
|
-
const base = executableBasename(token);
|
|
193
|
-
if (base === "pi" || base === "pi.exe" || base === "pi.js") return true;
|
|
194
|
-
}
|
|
195
|
-
return false;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { AgentInfo, ProcessInfo } from "../../adapters/AgentAdapter.js";
|
|
2
|
-
import { generateAgentName } from "../../utils/matching.js";
|
|
3
|
-
import { type PiSession, PiSessionParser } from "./PiSessionParser.js";
|
|
4
|
-
import { processOnlyAgent } from "../shared.js";
|
|
5
|
-
|
|
6
|
-
export class PiAgentMapper {
|
|
7
|
-
constructor(private readonly parser: PiSessionParser = new PiSessionParser()) {}
|
|
8
|
-
|
|
9
|
-
mapSessionToAgent(session: PiSession, processInfo: ProcessInfo, filePath: string): AgentInfo {
|
|
10
|
-
const projectPath = session.projectPath || processInfo.cwd || "";
|
|
11
|
-
return {
|
|
12
|
-
name: generateAgentName(projectPath, processInfo.pid),
|
|
13
|
-
type: "pi",
|
|
14
|
-
status: this.parser.determineStatus(session),
|
|
15
|
-
summary: session.summary || "Pi session active",
|
|
16
|
-
pid: processInfo.pid,
|
|
17
|
-
projectPath,
|
|
18
|
-
sessionId: session.sessionId,
|
|
19
|
-
lastActive: session.lastActive,
|
|
20
|
-
sessionFilePath: filePath,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
mapProcessOnlyAgent(processInfo: ProcessInfo): AgentInfo {
|
|
25
|
-
return processOnlyAgent("pi", processInfo, { summary: "Pi process running" });
|
|
26
|
-
}
|
|
27
|
-
}
|