@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,75 +0,0 @@
|
|
|
1
|
-
import * as path from "path";
|
|
2
|
-
import type { ProcessInfo } from "../../adapters/AgentAdapter.js";
|
|
3
|
-
import { safeReadFile } from "../../utils/session.js";
|
|
4
|
-
import { homeDir } from "../shared.js";
|
|
5
|
-
|
|
6
|
-
const REGISTRY_FILE = path.join("cache", "last_conversations.json");
|
|
7
|
-
const BRAIN_DIR = "brain";
|
|
8
|
-
const TRANSCRIPT_REL = path.join(".system_generated", "logs", "transcript.jsonl");
|
|
9
|
-
|
|
10
|
-
/** A workspace cwd and the conversation the CLI last used there. */
|
|
11
|
-
export interface AntigravityConversationRef {
|
|
12
|
-
cwd: string;
|
|
13
|
-
conversationId: string;
|
|
14
|
-
transcriptPath: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** A live `agy` process paired with its cwd and (if registered) conversation. */
|
|
18
|
-
export interface AntigravityProcessMatch {
|
|
19
|
-
process: ProcessInfo;
|
|
20
|
-
cwd: string;
|
|
21
|
-
conversation: AntigravityConversationRef | null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface AntigravitySessionLocatorOptions {
|
|
25
|
-
/** Overrides the base dir (defaults to ANTIGRAVITY_CLI_HOME or ~/.gemini/antigravity-cli). */
|
|
26
|
-
baseDir?: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export class AntigravitySessionLocator {
|
|
30
|
-
private readonly baseDir: string;
|
|
31
|
-
|
|
32
|
-
constructor(options: AntigravitySessionLocatorOptions = {}) {
|
|
33
|
-
this.baseDir =
|
|
34
|
-
options.baseDir ??
|
|
35
|
-
(process.env.ANTIGRAVITY_CLI_HOME || path.join(homeDir(), ".gemini", "antigravity-cli"));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** Pair live processes with their conversation, joined on the process cwd. */
|
|
39
|
-
matchRunningProcesses(processes: ProcessInfo[]): AntigravityProcessMatch[] {
|
|
40
|
-
const byCwd = new Map(this.listConversations().map((ref) => [ref.cwd, ref]));
|
|
41
|
-
return processes.map((proc) => {
|
|
42
|
-
const cwd = proc.cwd || "";
|
|
43
|
-
return { process: proc, cwd, conversation: byCwd.get(cwd) ?? null };
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Read cache/last_conversations.json, a `{ <cwd>: <conversationId> }` map the
|
|
49
|
-
* CLI rewrites as the current conversation per workspace changes.
|
|
50
|
-
*/
|
|
51
|
-
listConversations(): AntigravityConversationRef[] {
|
|
52
|
-
const content = safeReadFile(path.join(this.baseDir, REGISTRY_FILE));
|
|
53
|
-
if (content === undefined) return [];
|
|
54
|
-
|
|
55
|
-
let parsed: unknown;
|
|
56
|
-
try {
|
|
57
|
-
parsed = JSON.parse(content);
|
|
58
|
-
} catch {
|
|
59
|
-
return [];
|
|
60
|
-
}
|
|
61
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return [];
|
|
62
|
-
|
|
63
|
-
const refs: AntigravityConversationRef[] = [];
|
|
64
|
-
for (const [cwd, conversationId] of Object.entries(parsed as Record<string, unknown>)) {
|
|
65
|
-
if (cwd && typeof conversationId === "string" && conversationId) {
|
|
66
|
-
refs.push({ cwd, conversationId, transcriptPath: this.transcriptPath(conversationId) });
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return refs;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
private transcriptPath(conversationId: string): string {
|
|
73
|
-
return path.join(this.baseDir, BRAIN_DIR, conversationId, TRANSCRIPT_REL);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import type { ConversationMessage, ConversationOptions } from "../../adapters/AgentAdapter.js";
|
|
2
|
-
import { AgentStatus } from "../../adapters/AgentAdapter.js";
|
|
3
|
-
import {
|
|
4
|
-
IncrementalJsonlSummary,
|
|
5
|
-
reduceJsonlContent,
|
|
6
|
-
type JsonlSummaryBounds,
|
|
7
|
-
type JsonlSummaryReducer,
|
|
8
|
-
} from "../../utils/IncrementalJsonlSummary.js";
|
|
9
|
-
import { JsonlTailReader, normalizeTail } from "../../utils/jsonlTail.js";
|
|
10
|
-
import { safeReadFile, safeStat } from "../../utils/session.js";
|
|
11
|
-
import { flattenTextBlocks, isIdle, parseTimestamp } from "../shared.js";
|
|
12
|
-
|
|
13
|
-
/** One line of transcript.jsonl. */
|
|
14
|
-
interface TranscriptRecord {
|
|
15
|
-
source?: string;
|
|
16
|
-
type?: string;
|
|
17
|
-
created_at?: string;
|
|
18
|
-
content?: unknown;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** O(1) running summary folded from transcript records, never the turns themselves. */
|
|
22
|
-
interface AntigravitySummaryState {
|
|
23
|
-
/** A bounded cold start skipped the middle: later lines are not the session's first. */
|
|
24
|
-
pastHead?: boolean;
|
|
25
|
-
firstUserMessage?: string;
|
|
26
|
-
lastUserMessage?: string;
|
|
27
|
-
lastRole?: ConversationMessage["role"];
|
|
28
|
-
/** Latest `created_at` seen, in epoch ms. */
|
|
29
|
-
lastActiveMs?: number;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** Parsed state for a single conversation. */
|
|
33
|
-
export interface AntigravitySession {
|
|
34
|
-
sessionId: string;
|
|
35
|
-
projectPath: string;
|
|
36
|
-
sessionFilePath: string;
|
|
37
|
-
sessionStart: Date;
|
|
38
|
-
lastActive: Date;
|
|
39
|
-
firstUserMessage?: string;
|
|
40
|
-
lastUserMessage?: string;
|
|
41
|
-
lastRole?: ConversationMessage["role"];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface AntigravitySessionParserOptions {
|
|
45
|
-
/** Cold-start scan bounds for `readSessionIncremental` (see IncrementalJsonlSummary). */
|
|
46
|
-
summaryBounds?: JsonlSummaryBounds | false;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export class AntigravitySessionParser {
|
|
50
|
-
/** Incremental reader backing `getConversation({ tail })`. */
|
|
51
|
-
private readonly tailReader = new JsonlTailReader();
|
|
52
|
-
|
|
53
|
-
private readonly sessionCache: IncrementalJsonlSummary<AntigravitySummaryState>;
|
|
54
|
-
|
|
55
|
-
constructor(options: AntigravitySessionParserOptions = {}) {
|
|
56
|
-
this.sessionCache = new IncrementalJsonlSummary(this.summaryReducer, {
|
|
57
|
-
bounds: options.summaryBounds,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Parse a conversation's transcript.jsonl into an {@link AntigravitySession}.
|
|
63
|
-
* Returns null when the transcript is missing — there is no real session to
|
|
64
|
-
* surface.
|
|
65
|
-
*/
|
|
66
|
-
readSession(
|
|
67
|
-
conversationId: string,
|
|
68
|
-
transcriptPath: string,
|
|
69
|
-
projectPath: string,
|
|
70
|
-
): AntigravitySession | null {
|
|
71
|
-
const stat = safeStat(transcriptPath);
|
|
72
|
-
if (!stat) return null;
|
|
73
|
-
|
|
74
|
-
const content = safeReadFile(transcriptPath);
|
|
75
|
-
const state = content === undefined ? {} : reduceJsonlContent(this.summaryReducer, content);
|
|
76
|
-
return this.toSession(conversationId, transcriptPath, projectPath, stat, stat.mtime, state);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Same result as `readSession`, but backed by a per-instance incremental
|
|
81
|
-
* cache so repeated refreshes only parse bytes appended since the last call.
|
|
82
|
-
* Call `pruneSessionCache()` once per refresh to evict files no longer read.
|
|
83
|
-
*
|
|
84
|
-
* The first read of a large transcript is a bounded head + tail scan (see
|
|
85
|
-
* `summaryReducer.skip`).
|
|
86
|
-
*/
|
|
87
|
-
readSessionIncremental(
|
|
88
|
-
conversationId: string,
|
|
89
|
-
transcriptPath: string,
|
|
90
|
-
projectPath: string,
|
|
91
|
-
): AntigravitySession | null {
|
|
92
|
-
const stat = safeStat(transcriptPath);
|
|
93
|
-
if (!stat) return null;
|
|
94
|
-
|
|
95
|
-
// Present but unreadable: surface the session without a summary, like readSession.
|
|
96
|
-
const result = this.sessionCache.read(transcriptPath);
|
|
97
|
-
return this.toSession(
|
|
98
|
-
conversationId,
|
|
99
|
-
transcriptPath,
|
|
100
|
-
projectPath,
|
|
101
|
-
stat,
|
|
102
|
-
result?.mtime ?? stat.mtime,
|
|
103
|
-
result?.state ?? {},
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/** Evict cached summaries for files not read since the previous prune. */
|
|
108
|
-
pruneSessionCache(): void {
|
|
109
|
-
this.sessionCache.prune();
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
getConversation(transcriptPath: string, options?: ConversationOptions): ConversationMessage[] {
|
|
113
|
-
const verbose = options?.verbose ?? false;
|
|
114
|
-
const tail = normalizeTail(options?.tail);
|
|
115
|
-
if (tail === undefined) {
|
|
116
|
-
return this.parseTranscript(transcriptPath, verbose);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return this.tailReader.read(
|
|
120
|
-
transcriptPath,
|
|
121
|
-
tail,
|
|
122
|
-
{
|
|
123
|
-
parseLine: (line) => {
|
|
124
|
-
const record = this.parseRecord(line);
|
|
125
|
-
return record ? this.recordToMessage(record, verbose) : null;
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
String(verbose),
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* - last turn is an assistant reply → WAITING (awaiting input)
|
|
134
|
-
* - past the idle threshold → IDLE
|
|
135
|
-
* - otherwise (last turn was a user message, or unknown) → RUNNING
|
|
136
|
-
*/
|
|
137
|
-
determineStatus(session: AntigravitySession): AgentStatus {
|
|
138
|
-
if (session.lastRole === "assistant") {
|
|
139
|
-
return AgentStatus.WAITING;
|
|
140
|
-
}
|
|
141
|
-
if (isIdle(session.lastActive)) {
|
|
142
|
-
return AgentStatus.IDLE;
|
|
143
|
-
}
|
|
144
|
-
return AgentStatus.RUNNING;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Fold one transcript record into the O(1) summary: first/last user request,
|
|
149
|
-
* the role of the last user/assistant turn, and the latest `created_at`.
|
|
150
|
-
* Uses the same record rules as `getConversation` (see `recordToMessage`).
|
|
151
|
-
*
|
|
152
|
-
* `skip` (bounded cold start) keeps the head's first user request and resets
|
|
153
|
-
* the latest fields, so those come from the tail only; without a timestamp in
|
|
154
|
-
* the tail, `lastActive` falls back to the file mtime.
|
|
155
|
-
*/
|
|
156
|
-
private readonly summaryReducer: JsonlSummaryReducer<AntigravitySummaryState> = {
|
|
157
|
-
initial: () => ({}),
|
|
158
|
-
reduce: (state, value) => {
|
|
159
|
-
if (value === null || value === undefined) return state;
|
|
160
|
-
const record = value as TranscriptRecord;
|
|
161
|
-
|
|
162
|
-
let next = state;
|
|
163
|
-
const atMs = parseTimestamp(record.created_at)?.getTime();
|
|
164
|
-
if (atMs !== undefined && (next.lastActiveMs === undefined || atMs > next.lastActiveMs)) {
|
|
165
|
-
next = { ...next, lastActiveMs: atMs };
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const message = this.recordToMessage(record, false);
|
|
169
|
-
if (message?.role === "user") {
|
|
170
|
-
return {
|
|
171
|
-
...next,
|
|
172
|
-
firstUserMessage: next.firstUserMessage ?? (next.pastHead ? undefined : message.content),
|
|
173
|
-
lastUserMessage: message.content,
|
|
174
|
-
lastRole: "user",
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
if (message?.role === "assistant") return { ...next, lastRole: "assistant" };
|
|
178
|
-
return next;
|
|
179
|
-
},
|
|
180
|
-
skip: (state) => ({ pastHead: true, firstUserMessage: state.firstUserMessage }),
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
private toSession(
|
|
184
|
-
conversationId: string,
|
|
185
|
-
transcriptPath: string,
|
|
186
|
-
projectPath: string,
|
|
187
|
-
stat: { birthtime: Date },
|
|
188
|
-
mtime: Date,
|
|
189
|
-
state: AntigravitySummaryState,
|
|
190
|
-
): AntigravitySession {
|
|
191
|
-
return {
|
|
192
|
-
sessionId: conversationId,
|
|
193
|
-
projectPath,
|
|
194
|
-
sessionFilePath: transcriptPath,
|
|
195
|
-
sessionStart: stat.birthtime,
|
|
196
|
-
lastActive: state.lastActiveMs === undefined ? mtime : new Date(state.lastActiveMs),
|
|
197
|
-
firstUserMessage: state.firstUserMessage,
|
|
198
|
-
lastUserMessage: state.lastUserMessage,
|
|
199
|
-
lastRole: state.lastRole,
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/** Full pass over transcript.jsonl building every conversation turn. */
|
|
204
|
-
private parseTranscript(transcriptPath: string, verbose: boolean): ConversationMessage[] {
|
|
205
|
-
const content = safeReadFile(transcriptPath);
|
|
206
|
-
if (content === undefined) return [];
|
|
207
|
-
|
|
208
|
-
const messages: ConversationMessage[] = [];
|
|
209
|
-
for (const line of content.trim().split("\n")) {
|
|
210
|
-
const record = this.parseRecord(line);
|
|
211
|
-
const message = record ? this.recordToMessage(record, verbose) : null;
|
|
212
|
-
if (message) messages.push(message);
|
|
213
|
-
}
|
|
214
|
-
return messages;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
private parseRecord(line: string): TranscriptRecord | null {
|
|
218
|
-
if (!line.trim()) return null;
|
|
219
|
-
try {
|
|
220
|
-
return JSON.parse(line) as TranscriptRecord;
|
|
221
|
-
} catch {
|
|
222
|
-
return null;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* USER_INPUT records are user turns and PLANNER_RESPONSE records are the
|
|
228
|
-
* model's reply. Everything else — MODEL tool calls (RUN_COMMAND, ...) and
|
|
229
|
-
* SYSTEM records (history, checkpoints) — is execution detail, shown as a
|
|
230
|
-
* system message only in verbose mode.
|
|
231
|
-
*/
|
|
232
|
-
private recordToMessage(record: TranscriptRecord, verbose: boolean): ConversationMessage | null {
|
|
233
|
-
const text = flattenTextBlocks(record.content);
|
|
234
|
-
if (record.type === "USER_INPUT") {
|
|
235
|
-
const request = this.extractUserRequest(text);
|
|
236
|
-
return request === null ? null : { role: "user", content: request };
|
|
237
|
-
}
|
|
238
|
-
if (!text) return null;
|
|
239
|
-
if (record.type === "PLANNER_RESPONSE") return { role: "assistant", content: text };
|
|
240
|
-
return verbose ? { role: "system", content: text } : null;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* The prompt inside <USER_REQUEST>...</USER_REQUEST>, or the whole trimmed
|
|
245
|
-
* text when the record has no wrapper. Null for an unwrapped blank record.
|
|
246
|
-
*/
|
|
247
|
-
private extractUserRequest(text: string): string | null {
|
|
248
|
-
const match = text.match(/<USER_REQUEST>\s*([\s\S]*?)\s*<\/USER_REQUEST>/);
|
|
249
|
-
if (match) return match[1].trim();
|
|
250
|
-
return text.trim() || null;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { AgentInfo, ProcessInfo } from "../../adapters/AgentAdapter.js";
|
|
2
|
-
import { AgentStatus } from "../../adapters/AgentAdapter.js";
|
|
3
|
-
import { generateAgentName } from "../../utils/matching.js";
|
|
4
|
-
import type { SessionFile } from "../../utils/session.js";
|
|
5
|
-
import { ClaudeSessionParser, type ClaudeSession } from "./ClaudeSessionParser.js";
|
|
6
|
-
import { processOnlyAgent } from "../shared.js";
|
|
7
|
-
|
|
8
|
-
export interface ClaudeAgentLiveInfo {
|
|
9
|
-
pidStatus?: AgentStatus;
|
|
10
|
-
waitingFor?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface ClaudeSessionAgentInput {
|
|
14
|
-
session: ClaudeSession;
|
|
15
|
-
processInfo: ProcessInfo;
|
|
16
|
-
sessionFile: SessionFile;
|
|
17
|
-
liveInfo?: ClaudeAgentLiveInfo;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export class ClaudeAgentMapper {
|
|
21
|
-
constructor(private readonly parser: ClaudeSessionParser = new ClaudeSessionParser()) {}
|
|
22
|
-
|
|
23
|
-
mapSessionToAgent({
|
|
24
|
-
session,
|
|
25
|
-
processInfo,
|
|
26
|
-
sessionFile,
|
|
27
|
-
liveInfo,
|
|
28
|
-
}: ClaudeSessionAgentInput): AgentInfo {
|
|
29
|
-
// Live PID-file status is authoritative when present — JSONL-derived
|
|
30
|
-
// status mis-classifies sessions whose latest entry is a UI-state
|
|
31
|
-
// event like `permission-mode` or `ai-title`.
|
|
32
|
-
const status = liveInfo?.pidStatus ?? this.parser.determineStatus(session);
|
|
33
|
-
const baseSummary = session.lastUserMessage || "Session started";
|
|
34
|
-
const summary =
|
|
35
|
-
status === AgentStatus.WAITING && liveInfo?.waitingFor
|
|
36
|
-
? `${baseSummary} — waiting for ${liveInfo.waitingFor}`
|
|
37
|
-
: baseSummary;
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
name: generateAgentName(processInfo.cwd, processInfo.pid),
|
|
41
|
-
type: "claude",
|
|
42
|
-
status,
|
|
43
|
-
summary,
|
|
44
|
-
pid: processInfo.pid,
|
|
45
|
-
projectPath: sessionFile.resolvedCwd || processInfo.cwd || "",
|
|
46
|
-
sessionId: sessionFile.sessionId,
|
|
47
|
-
lastActive: session.lastActive,
|
|
48
|
-
sessionFilePath: sessionFile.filePath,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
mapProcessOnlyAgent(processInfo: ProcessInfo): AgentInfo {
|
|
53
|
-
return processOnlyAgent("claude", processInfo, { summary: "Claude Code process running" });
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import * as path from "path";
|
|
2
|
-
import type {
|
|
3
|
-
AgentAdapter,
|
|
4
|
-
AgentInfo,
|
|
5
|
-
ProcessInfo,
|
|
6
|
-
ConversationMessage,
|
|
7
|
-
ConversationOptions,
|
|
8
|
-
SessionSummary,
|
|
9
|
-
ListSessionsOptions,
|
|
10
|
-
AgentDetectionContext,
|
|
11
|
-
} from "../../adapters/AgentAdapter.js";
|
|
12
|
-
import { safeStat } from "../../utils/session.js";
|
|
13
|
-
import { ClaudeSessionParser } from "./ClaudeSessionParser.js";
|
|
14
|
-
import { ClaudeAgentMapper } from "./ClaudeAgentMapper.js";
|
|
15
|
-
import { ClaudeSessionLocator } from "./ClaudeSessionLocator.js";
|
|
16
|
-
import { findHarnessProcesses, homeDir, matchesExecutable } from "../shared.js";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Claude Code Adapter
|
|
20
|
-
*
|
|
21
|
-
* Detects Claude Code agents by:
|
|
22
|
-
* 1. Filtering Claude processes from a shared asynchronous process snapshot
|
|
23
|
-
* 2. Using snapshot CWD and start-time enrichment
|
|
24
|
-
* 3. Attempting authoritative PID-file matching via ~/.claude/sessions/<pid>.json
|
|
25
|
-
* 4. Falling back to CWD+birthtime heuristic (matchProcessesToSessions) for processes without a PID file
|
|
26
|
-
* 5. Extracting summary from last user message in session JSONL (incrementally
|
|
27
|
-
* cached across refreshes, so unchanged transcripts are not re-read)
|
|
28
|
-
*/
|
|
29
|
-
export class ClaudeCodeAdapter implements AgentAdapter {
|
|
30
|
-
readonly type = "claude" as const;
|
|
31
|
-
readonly processNames = ["claude"] as const;
|
|
32
|
-
|
|
33
|
-
private parser: ClaudeSessionParser;
|
|
34
|
-
private mapper: ClaudeAgentMapper;
|
|
35
|
-
private projectsDir: string;
|
|
36
|
-
private sessionsDir: string;
|
|
37
|
-
|
|
38
|
-
constructor() {
|
|
39
|
-
this.projectsDir = path.join(homeDir(), ".claude", "projects");
|
|
40
|
-
this.sessionsDir = path.join(homeDir(), ".claude", "sessions");
|
|
41
|
-
this.parser = new ClaudeSessionParser();
|
|
42
|
-
this.mapper = new ClaudeAgentMapper(this.parser);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
canHandle(processInfo: ProcessInfo): boolean {
|
|
46
|
-
return matchesExecutable(processInfo.command, "claude");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async detectAgents(context?: AgentDetectionContext): Promise<AgentInfo[]> {
|
|
50
|
-
try {
|
|
51
|
-
return await this.detectRunningAgents(context);
|
|
52
|
-
} finally {
|
|
53
|
-
// Drop cached summaries for sessions that were not part of this refresh
|
|
54
|
-
this.parser.pruneSessionCache();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
private async detectRunningAgents(context?: AgentDetectionContext): Promise<AgentInfo[]> {
|
|
59
|
-
const { processes } = await findHarnessProcesses(this, context);
|
|
60
|
-
if (processes.length === 0) {
|
|
61
|
-
return [];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const { direct, legacyMatches } = this.createLocator().matchRunningProcesses(processes);
|
|
65
|
-
|
|
66
|
-
const matchedPids = new Set([
|
|
67
|
-
...direct.map((d) => d.process.pid),
|
|
68
|
-
...legacyMatches.map((m) => m.process.pid),
|
|
69
|
-
]);
|
|
70
|
-
|
|
71
|
-
const agents: AgentInfo[] = [];
|
|
72
|
-
|
|
73
|
-
// Build agents from direct (resume + PID-file) matches
|
|
74
|
-
for (const match of direct) {
|
|
75
|
-
const { process: proc, sessionFile } = match;
|
|
76
|
-
const sessionData = this.parser.readSessionIncremental(
|
|
77
|
-
sessionFile.filePath,
|
|
78
|
-
sessionFile.resolvedCwd,
|
|
79
|
-
);
|
|
80
|
-
if (sessionData) {
|
|
81
|
-
agents.push(
|
|
82
|
-
this.mapper.mapSessionToAgent({
|
|
83
|
-
session: sessionData,
|
|
84
|
-
processInfo: proc,
|
|
85
|
-
sessionFile,
|
|
86
|
-
liveInfo: {
|
|
87
|
-
pidStatus: match.pidStatus,
|
|
88
|
-
waitingFor: match.waitingFor,
|
|
89
|
-
},
|
|
90
|
-
}),
|
|
91
|
-
);
|
|
92
|
-
} else {
|
|
93
|
-
matchedPids.delete(proc.pid);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Build agents from legacy matches
|
|
98
|
-
for (const match of legacyMatches) {
|
|
99
|
-
const sessionData = this.parser.readSessionIncremental(
|
|
100
|
-
match.session.filePath,
|
|
101
|
-
match.session.resolvedCwd,
|
|
102
|
-
);
|
|
103
|
-
if (sessionData) {
|
|
104
|
-
agents.push(
|
|
105
|
-
this.mapper.mapSessionToAgent({
|
|
106
|
-
session: sessionData,
|
|
107
|
-
processInfo: match.process,
|
|
108
|
-
sessionFile: match.session,
|
|
109
|
-
}),
|
|
110
|
-
);
|
|
111
|
-
} else {
|
|
112
|
-
matchedPids.delete(match.process.pid);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Any process with no match (direct or legacy) appears as IDLE
|
|
117
|
-
for (const proc of processes) {
|
|
118
|
-
if (!matchedPids.has(proc.pid)) {
|
|
119
|
-
agents.push(this.mapper.mapProcessOnlyAgent(proc));
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return agents;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
private createLocator(): ClaudeSessionLocator {
|
|
127
|
-
return new ClaudeSessionLocator({
|
|
128
|
-
projectsDir: this.projectsDir,
|
|
129
|
-
sessionsDir: this.sessionsDir,
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
getConversation(sessionFilePath: string, options?: ConversationOptions): ConversationMessage[] {
|
|
134
|
-
return this.parser.getConversation(sessionFilePath, options);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
async listSessions(opts?: ListSessionsOptions): Promise<SessionSummary[]> {
|
|
138
|
-
const filterCwd = opts?.cwd;
|
|
139
|
-
const candidates = this.createLocator().discoverHistoricalSessionFiles();
|
|
140
|
-
const summaries: SessionSummary[] = [];
|
|
141
|
-
|
|
142
|
-
for (const { filePath, defaultCwd } of candidates) {
|
|
143
|
-
const summary = this.toSessionSummary(filePath, defaultCwd);
|
|
144
|
-
if (!summary) continue;
|
|
145
|
-
if (filterCwd !== undefined && summary.cwd !== filterCwd) continue;
|
|
146
|
-
summaries.push(summary);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return summaries;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
async findSessionsById(sessionId: string): Promise<SessionSummary[]> {
|
|
153
|
-
return this.createLocator()
|
|
154
|
-
.findHistoricalSessionFilesById(sessionId)
|
|
155
|
-
.map(({ filePath, defaultCwd }) => this.toSessionSummary(filePath, defaultCwd))
|
|
156
|
-
.filter((summary): summary is SessionSummary => summary?.sessionId === sessionId);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
private toSessionSummary(filePath: string, defaultCwd: string): SessionSummary | null {
|
|
160
|
-
const session = this.parser.readSession(filePath, defaultCwd);
|
|
161
|
-
if (!session?.lastEntryType) return null;
|
|
162
|
-
|
|
163
|
-
const recordedCwd = session.lastCwd || defaultCwd;
|
|
164
|
-
const stat = safeStat(filePath);
|
|
165
|
-
return {
|
|
166
|
-
type: "claude",
|
|
167
|
-
sessionId: session.sessionId,
|
|
168
|
-
cwd: recordedCwd,
|
|
169
|
-
firstUserMessage: session.firstUserMessage || "",
|
|
170
|
-
lastActive: session.lastActive ?? stat?.mtime ?? new Date(),
|
|
171
|
-
startedAt: session.sessionStart ?? stat?.birthtime ?? stat?.mtime ?? new Date(),
|
|
172
|
-
sessionFilePath: filePath,
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
}
|