@ai-devkit/agent-manager 0.43.0 → 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/package.json +8 -3
- package/.swcrc +0 -27
- package/dist/__tests__/AgentManager.test.js +0 -1727
- package/dist/__tests__/AgentManager.test.js.map +0 -1
- package/dist/__tests__/adapters/IncrementalSessionRefresh.test.js +0 -486
- package/dist/__tests__/adapters/IncrementalSessionRefresh.test.js.map +0 -1
- package/dist/__tests__/adapters/adapterProcessImports.test.js +0 -52
- package/dist/__tests__/adapters/adapterProcessImports.test.js.map +0 -1
- package/dist/__tests__/adapters/adapterSnapshotCandidates.test.js +0 -247
- package/dist/__tests__/adapters/adapterSnapshotCandidates.test.js.map +0 -1
- package/dist/__tests__/capacity/anthropic.test.js +0 -115
- package/dist/__tests__/capacity/anthropic.test.js.map +0 -1
- package/dist/__tests__/capacity/boundaries.test.js +0 -45
- package/dist/__tests__/capacity/boundaries.test.js.map +0 -1
- package/dist/__tests__/capacity/claude.test.js +0 -485
- package/dist/__tests__/capacity/claude.test.js.map +0 -1
- package/dist/__tests__/capacity/codex.test.js +0 -339
- package/dist/__tests__/capacity/codex.test.js.map +0 -1
- package/dist/__tests__/capacity/devin.test.js +0 -239
- package/dist/__tests__/capacity/devin.test.js.map +0 -1
- package/dist/__tests__/capacity/index.test.js +0 -53
- package/dist/__tests__/capacity/index.test.js.map +0 -1
- package/dist/__tests__/capacity/openai.test.js +0 -687
- package/dist/__tests__/capacity/openai.test.js.map +0 -1
- package/dist/__tests__/capacity/wham.test.js +0 -159
- package/dist/__tests__/capacity/wham.test.js.map +0 -1
- package/dist/__tests__/capacity/zai.test.js +0 -212
- package/dist/__tests__/capacity/zai.test.js.map +0 -1
- package/dist/__tests__/fixtures.test.js +0 -218
- package/dist/__tests__/fixtures.test.js.map +0 -1
- package/dist/__tests__/harnesses/BoundedSummarySkip.test.js +0 -568
- package/dist/__tests__/harnesses/BoundedSummarySkip.test.js.map +0 -1
- package/dist/__tests__/harnesses/SessionSummaryEquivalence.test.js +0 -1089
- package/dist/__tests__/harnesses/SessionSummaryEquivalence.test.js.map +0 -1
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.js +0 -143
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.js.map +0 -1
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.js +0 -462
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/builtinAdapters.test.js +0 -33
- package/dist/__tests__/harnesses/builtinAdapters.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeAgentMapper.test.js +0 -79
- package/dist/__tests__/harnesses/claude/ClaudeAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeCodeAdapter.test.js +0 -1881
- package/dist/__tests__/harnesses/claude/ClaudeCodeAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeSessionLocator.test.js +0 -425
- package/dist/__tests__/harnesses/claude/ClaudeSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeSessionParser.test.js +0 -314
- package/dist/__tests__/harnesses/claude/ClaudeSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.js +0 -49
- package/dist/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.js +0 -76
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.js +0 -173
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.js +0 -181
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexAdapter.test.js +0 -685
- package/dist/__tests__/harnesses/codex/CodexAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexSessionLocator.test.js +0 -463
- package/dist/__tests__/harnesses/codex/CodexSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexSessionMapping.test.js +0 -86
- package/dist/__tests__/harnesses/codex/CodexSessionMapping.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexSessionParser.test.js +0 -254
- package/dist/__tests__/harnesses/codex/CodexSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexCliProbe.test.js +0 -121
- package/dist/__tests__/harnesses/codex/durable/CodexCliProbe.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.js +0 -84
- package/dist/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.js +0 -128
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.js +0 -246
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexPrintRunner.test.js +0 -384
- package/dist/__tests__/harnesses/codex/durable/CodexPrintRunner.test.js.map +0 -1
- package/dist/__tests__/harnesses/copilot/CopilotAdapter.test.js +0 -659
- package/dist/__tests__/harnesses/copilot/CopilotAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/copilot/CopilotRefreshIO.test.js +0 -290
- package/dist/__tests__/harnesses/copilot/CopilotRefreshIO.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinAdapter.test.js +0 -597
- package/dist/__tests__/harnesses/devin/DevinAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinAgentMapper.test.js +0 -99
- package/dist/__tests__/harnesses/devin/DevinAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinSessionLocator.test.js +0 -192
- package/dist/__tests__/harnesses/devin/DevinSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinSessionParser.test.js +0 -407
- package/dist/__tests__/harnesses/devin/DevinSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/fixtures.js +0 -95
- package/dist/__tests__/harnesses/devin/fixtures.js.map +0 -1
- package/dist/__tests__/harnesses/gemini/GeminiCliAdapter.test.js +0 -1454
- package/dist/__tests__/harnesses/gemini/GeminiCliAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/gemini/GeminiSessionJsonl.test.js +0 -491
- package/dist/__tests__/harnesses/gemini/GeminiSessionJsonl.test.js.map +0 -1
- package/dist/__tests__/harnesses/gemini/GeminiSessionLocator.test.js +0 -399
- package/dist/__tests__/harnesses/gemini/GeminiSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokAgentMapper.test.js +0 -56
- package/dist/__tests__/harnesses/grok/GrokAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokCliAdapter.test.js +0 -421
- package/dist/__tests__/harnesses/grok/GrokCliAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokIncrementalRefresh.test.js +0 -167
- package/dist/__tests__/harnesses/grok/GrokIncrementalRefresh.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokSessionLocator.test.js +0 -133
- package/dist/__tests__/harnesses/grok/GrokSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokSessionParser.test.js +0 -301
- package/dist/__tests__/harnesses/grok/GrokSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/kiro/KiroAdapter.test.js +0 -662
- package/dist/__tests__/harnesses/kiro/KiroAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseAdapter.test.js +0 -247
- package/dist/__tests__/harnesses/muse/MuseAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseAgentMapper.test.js +0 -81
- package/dist/__tests__/harnesses/muse/MuseAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseSessionLocator.test.js +0 -185
- package/dist/__tests__/harnesses/muse/MuseSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseSessionParser.test.js +0 -328
- package/dist/__tests__/harnesses/muse/MuseSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeAdapter.test.js +0 -213
- package/dist/__tests__/harnesses/opencode/OpenCodeAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.js +0 -108
- package/dist/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.js +0 -94
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionParser.test.js +0 -147
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiAdapter.test.js +0 -367
- package/dist/__tests__/harnesses/pi/PiAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiDiscoveryIO.test.js +0 -382
- package/dist/__tests__/harnesses/pi/PiDiscoveryIO.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiSessionParser.test.js +0 -416
- package/dist/__tests__/harnesses/pi/PiSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiSessionTracker.test.js +0 -108
- package/dist/__tests__/harnesses/pi/PiSessionTracker.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiCliProbe.test.js +0 -70
- package/dist/__tests__/harnesses/pi/durable/PiCliProbe.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.js +0 -43
- package/dist/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiPrintAgentService.test.js +0 -192
- package/dist/__tests__/harnesses/pi/durable/PiPrintAgentService.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiPrintProtocol.test.js +0 -119
- package/dist/__tests__/harnesses/pi/durable/PiPrintProtocol.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiPrintRunner.test.js +0 -382
- package/dist/__tests__/harnesses/pi/durable/PiPrintRunner.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiStreamParser.test.js +0 -34
- package/dist/__tests__/harnesses/pi/durable/PiStreamParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/readiness/AgentReadiness.test.js +0 -446
- package/dist/__tests__/harnesses/readiness/AgentReadiness.test.js.map +0 -1
- package/dist/__tests__/harnesses/runtimeProfiles.test.js +0 -101
- package/dist/__tests__/harnesses/runtimeProfiles.test.js.map +0 -1
- package/dist/__tests__/print/DurableAgent.test.js +0 -15
- package/dist/__tests__/print/DurableAgent.test.js.map +0 -1
- package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js +0 -186
- package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js.map +0 -1
- package/dist/__tests__/print/DurableAgentRepository.test.js +0 -249
- package/dist/__tests__/print/DurableAgentRepository.test.js.map +0 -1
- package/dist/__tests__/readiness-fixtures.test.js +0 -54
- package/dist/__tests__/readiness-fixtures.test.js.map +0 -1
- package/dist/__tests__/runtime/AgentRuntime.test.js +0 -13
- package/dist/__tests__/runtime/AgentRuntime.test.js.map +0 -1
- package/dist/__tests__/runtime/HerdrAgentDiscovery.test.js +0 -164
- package/dist/__tests__/runtime/HerdrAgentDiscovery.test.js.map +0 -1
- package/dist/__tests__/runtime/HerdrAgentRuntime.test.js +0 -488
- package/dist/__tests__/runtime/HerdrAgentRuntime.test.js.map +0 -1
- package/dist/__tests__/runtime/ManagedAgentRuntime.test.js +0 -637
- package/dist/__tests__/runtime/ManagedAgentRuntime.test.js.map +0 -1
- package/dist/__tests__/terminal/GhosttyBackend.test.js +0 -334
- package/dist/__tests__/terminal/GhosttyBackend.test.js.map +0 -1
- package/dist/__tests__/terminal/TerminalFocusManager.test.js +0 -253
- package/dist/__tests__/terminal/TerminalFocusManager.test.js.map +0 -1
- package/dist/__tests__/terminal/TmuxManager.test.js +0 -168
- package/dist/__tests__/terminal/TmuxManager.test.js.map +0 -1
- package/dist/__tests__/terminal/TtyWriter.test.js +0 -386
- package/dist/__tests__/terminal/TtyWriter.test.js.map +0 -1
- package/dist/__tests__/utils/AgentRegistry.test.js +0 -636
- package/dist/__tests__/utils/AgentRegistry.test.js.map +0 -1
- package/dist/__tests__/utils/IncrementalJsonlSummary.test.js +0 -650
- package/dist/__tests__/utils/IncrementalJsonlSummary.test.js.map +0 -1
- package/dist/__tests__/utils/agent-requests.test.js +0 -90
- package/dist/__tests__/utils/agent-requests.test.js.map +0 -1
- package/dist/__tests__/utils/conversationTail.bench.test.js +0 -258
- package/dist/__tests__/utils/conversationTail.bench.test.js.map +0 -1
- package/dist/__tests__/utils/conversationTailParity.test.js +0 -588
- package/dist/__tests__/utils/conversationTailParity.test.js.map +0 -1
- package/dist/__tests__/utils/jsonlTail.test.js +0 -360
- package/dist/__tests__/utils/jsonlTail.test.js.map +0 -1
- package/dist/__tests__/utils/matching.test.js +0 -324
- package/dist/__tests__/utils/matching.test.js.map +0 -1
- package/dist/__tests__/utils/matchingConstants.test.js +0 -35
- package/dist/__tests__/utils/matchingConstants.test.js.map +0 -1
- package/dist/__tests__/utils/process.test.js +0 -818
- package/dist/__tests__/utils/process.test.js.map +0 -1
- package/dist/__tests__/utils/session.test.js +0 -175
- package/dist/__tests__/utils/session.test.js.map +0 -1
- package/project.json +0 -29
- package/scripts/benchmark-cold-start.mjs +0 -350
- package/src/AgentManager.ts +0 -559
- package/src/__tests__/AgentManager.test.ts +0 -1578
- package/src/__tests__/adapters/IncrementalSessionRefresh.test.ts +0 -437
- package/src/__tests__/adapters/adapterProcessImports.test.ts +0 -58
- package/src/__tests__/adapters/adapterSnapshotCandidates.test.ts +0 -243
- package/src/__tests__/capacity/anthropic.test.ts +0 -105
- package/src/__tests__/capacity/boundaries.test.ts +0 -36
- package/src/__tests__/capacity/claude.test.ts +0 -462
- package/src/__tests__/capacity/codex.test.ts +0 -311
- package/src/__tests__/capacity/devin.test.ts +0 -210
- package/src/__tests__/capacity/fixtures/claude-credentials.json +0 -7
- package/src/__tests__/capacity/fixtures/claude-usage-malformed.json +0 -1
- package/src/__tests__/capacity/fixtures/claude-usage-partial.json +0 -15
- package/src/__tests__/capacity/fixtures/claude-usage.json +0 -63
- package/src/__tests__/capacity/fixtures/devin-config.json +0 -6
- package/src/__tests__/capacity/fixtures/devin-credentials.toml +0 -4
- package/src/__tests__/capacity/fixtures/devin-quota-nonplan.json +0 -5
- package/src/__tests__/capacity/fixtures/devin-quota.json +0 -10
- package/src/__tests__/capacity/fixtures/openai-auth.json +0 -6
- package/src/__tests__/capacity/fixtures/openai-codex-auth.json +0 -9
- package/src/__tests__/capacity/fixtures/openai-usage-completions.json +0 -67
- package/src/__tests__/capacity/fixtures/openai-usage-responses.json +0 -20
- package/src/__tests__/capacity/fixtures/wham-usage.json +0 -45
- package/src/__tests__/capacity/fixtures/zai-auth.json +0 -6
- package/src/__tests__/capacity/fixtures/zai-quota-invalid.json +0 -7
- package/src/__tests__/capacity/fixtures/zai-quota.json +0 -38
- package/src/__tests__/capacity/index.test.ts +0 -54
- package/src/__tests__/capacity/openai.test.ts +0 -571
- package/src/__tests__/capacity/wham.test.ts +0 -122
- package/src/__tests__/capacity/zai.test.ts +0 -151
- package/src/__tests__/fixtures.test.ts +0 -245
- package/src/__tests__/harnesses/BoundedSummarySkip.test.ts +0 -496
- package/src/__tests__/harnesses/SessionSummaryEquivalence.test.ts +0 -726
- package/src/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.ts +0 -133
- package/src/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.ts +0 -396
- package/src/__tests__/harnesses/builtinAdapters.test.ts +0 -33
- package/src/__tests__/harnesses/claude/ClaudeAgentMapper.test.ts +0 -84
- package/src/__tests__/harnesses/claude/ClaudeCodeAdapter.test.ts +0 -1793
- package/src/__tests__/harnesses/claude/ClaudeSessionLocator.test.ts +0 -423
- package/src/__tests__/harnesses/claude/ClaudeSessionParser.test.ts +0 -300
- package/src/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.ts +0 -34
- package/src/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.ts +0 -61
- package/src/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.ts +0 -129
- package/src/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.ts +0 -152
- package/src/__tests__/harnesses/codex/CodexAdapter.test.ts +0 -652
- package/src/__tests__/harnesses/codex/CodexSessionLocator.test.ts +0 -419
- package/src/__tests__/harnesses/codex/CodexSessionMapping.test.ts +0 -63
- package/src/__tests__/harnesses/codex/CodexSessionParser.test.ts +0 -192
- package/src/__tests__/harnesses/codex/durable/CodexCliProbe.test.ts +0 -80
- package/src/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.ts +0 -65
- package/src/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.ts +0 -104
- package/src/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.ts +0 -201
- package/src/__tests__/harnesses/codex/durable/CodexPrintRunner.test.ts +0 -299
- package/src/__tests__/harnesses/copilot/CopilotAdapter.test.ts +0 -614
- package/src/__tests__/harnesses/copilot/CopilotRefreshIO.test.ts +0 -270
- package/src/__tests__/harnesses/devin/DevinAdapter.test.ts +0 -290
- package/src/__tests__/harnesses/devin/DevinAgentMapper.test.ts +0 -101
- package/src/__tests__/harnesses/devin/DevinSessionLocator.test.ts +0 -139
- package/src/__tests__/harnesses/devin/DevinSessionParser.test.ts +0 -212
- package/src/__tests__/harnesses/devin/fixtures.ts +0 -144
- package/src/__tests__/harnesses/gemini/GeminiCliAdapter.test.ts +0 -1336
- package/src/__tests__/harnesses/gemini/GeminiSessionJsonl.test.ts +0 -402
- package/src/__tests__/harnesses/gemini/GeminiSessionLocator.test.ts +0 -396
- package/src/__tests__/harnesses/grok/GrokAgentMapper.test.ts +0 -57
- package/src/__tests__/harnesses/grok/GrokCliAdapter.test.ts +0 -376
- package/src/__tests__/harnesses/grok/GrokIncrementalRefresh.test.ts +0 -170
- package/src/__tests__/harnesses/grok/GrokSessionLocator.test.ts +0 -106
- package/src/__tests__/harnesses/grok/GrokSessionParser.test.ts +0 -230
- package/src/__tests__/harnesses/kiro/KiroAdapter.test.ts +0 -552
- package/src/__tests__/harnesses/muse/MuseAdapter.test.ts +0 -197
- package/src/__tests__/harnesses/muse/MuseAgentMapper.test.ts +0 -83
- package/src/__tests__/harnesses/muse/MuseSessionLocator.test.ts +0 -177
- package/src/__tests__/harnesses/muse/MuseSessionParser.test.ts +0 -279
- package/src/__tests__/harnesses/opencode/OpenCodeAdapter.test.ts +0 -215
- package/src/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.ts +0 -101
- package/src/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.ts +0 -84
- package/src/__tests__/harnesses/opencode/OpenCodeSessionParser.test.ts +0 -149
- package/src/__tests__/harnesses/pi/PiAdapter.test.ts +0 -325
- package/src/__tests__/harnesses/pi/PiDiscoveryIO.test.ts +0 -337
- package/src/__tests__/harnesses/pi/PiSessionParser.test.ts +0 -280
- package/src/__tests__/harnesses/pi/PiSessionTracker.test.ts +0 -79
- package/src/__tests__/harnesses/pi/durable/PiCliProbe.test.ts +0 -50
- package/src/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.ts +0 -33
- package/src/__tests__/harnesses/pi/durable/PiPrintAgentService.test.ts +0 -138
- package/src/__tests__/harnesses/pi/durable/PiPrintProtocol.test.ts +0 -71
- package/src/__tests__/harnesses/pi/durable/PiPrintRunner.test.ts +0 -252
- package/src/__tests__/harnesses/pi/durable/PiStreamParser.test.ts +0 -26
- package/src/__tests__/harnesses/readiness/AgentReadiness.test.ts +0 -362
- package/src/__tests__/harnesses/runtimeProfiles.test.ts +0 -123
- package/src/__tests__/print/DurableAgent.test.ts +0 -15
- package/src/__tests__/print/DurableAgentRepository.sqlite.test.ts +0 -128
- package/src/__tests__/print/DurableAgentRepository.test.ts +0 -184
- package/src/__tests__/readiness-fixtures.test.ts +0 -79
- package/src/__tests__/runtime/AgentRuntime.test.ts +0 -8
- package/src/__tests__/runtime/HerdrAgentDiscovery.test.ts +0 -131
- package/src/__tests__/runtime/HerdrAgentRuntime.test.ts +0 -377
- package/src/__tests__/runtime/ManagedAgentRuntime.test.ts +0 -590
- package/src/__tests__/terminal/GhosttyBackend.test.ts +0 -271
- package/src/__tests__/terminal/TerminalFocusManager.test.ts +0 -280
- package/src/__tests__/terminal/TmuxManager.test.ts +0 -185
- package/src/__tests__/terminal/TtyWriter.test.ts +0 -454
- package/src/__tests__/utils/AgentRegistry.test.ts +0 -532
- package/src/__tests__/utils/IncrementalJsonlSummary.test.ts +0 -414
- package/src/__tests__/utils/agent-requests.test.ts +0 -94
- package/src/__tests__/utils/conversationTail.bench.test.ts +0 -193
- package/src/__tests__/utils/conversationTailParity.test.ts +0 -365
- package/src/__tests__/utils/jsonlTail.test.ts +0 -317
- package/src/__tests__/utils/matching.test.ts +0 -234
- package/src/__tests__/utils/matchingConstants.test.ts +0 -40
- package/src/__tests__/utils/process.test.ts +0 -596
- package/src/__tests__/utils/session.test.ts +0 -158
- package/src/adapters/AgentAdapter.ts +0 -255
- package/src/capacity/index.ts +0 -127
- package/src/capacity/providers/anthropic.ts +0 -198
- package/src/capacity/providers/devin.ts +0 -121
- package/src/capacity/providers/openai-platform.ts +0 -150
- package/src/capacity/providers/openai-subscription.ts +0 -184
- package/src/capacity/providers/zai.ts +0 -155
- package/src/capacity/sources/claude.ts +0 -30
- package/src/capacity/sources/codex.ts +0 -251
- package/src/capacity/sources/devin.ts +0 -49
- package/src/capacity/sources/pi.ts +0 -131
- package/src/capacity/types.ts +0 -29
- package/src/database/connection.ts +0 -96
- package/src/database/index.ts +0 -7
- package/src/database/migrations/001_initial.sql +0 -12
- package/src/database/migrations/002_pins.sql +0 -1
- package/src/database/migrations/003_durable_agents.sql +0 -43
- package/src/database/migrations/004_codex_durable_sessions.sql +0 -1
- package/src/database/migrations/005_agent_runtime.sql +0 -2
- package/src/database/schema.ts +0 -64
- package/src/durable/DurableAgent.ts +0 -139
- package/src/durable/DurableAgentRepository.ts +0 -485
- package/src/durable/process.ts +0 -29
- package/src/durable/run.ts +0 -84
- package/src/durable/utils.ts +0 -66
- package/src/fixtures/bundle.ts +0 -130
- package/src/fixtures/capture.ts +0 -364
- package/src/harnesses/antigravity/AntigravityAgentMapper.ts +0 -34
- package/src/harnesses/antigravity/AntigravityCliAdapter.ts +0 -126
- package/src/harnesses/antigravity/AntigravitySessionLocator.ts +0 -75
- package/src/harnesses/antigravity/AntigravitySessionParser.ts +0 -252
- package/src/harnesses/claude/ClaudeAgentMapper.ts +0 -55
- package/src/harnesses/claude/ClaudeCodeAdapter.ts +0 -175
- package/src/harnesses/claude/ClaudeSessionLocator.ts +0 -358
- package/src/harnesses/claude/ClaudeSessionParser.ts +0 -524
- package/src/harnesses/claude/credentials.ts +0 -122
- package/src/harnesses/claude/durable/ClaudeCliProbe.ts +0 -57
- package/src/harnesses/claude/durable/ClaudePrintAgentService.ts +0 -79
- package/src/harnesses/claude/durable/ClaudePrintRunner.ts +0 -102
- package/src/harnesses/claude/durable/ClaudeStreamParser.ts +0 -108
- package/src/harnesses/claude/readiness.ts +0 -69
- package/src/harnesses/codex/CodexAdapter.ts +0 -337
- package/src/harnesses/codex/CodexAgentMapper.ts +0 -26
- package/src/harnesses/codex/CodexSessionLocator.ts +0 -509
- package/src/harnesses/codex/CodexSessionMapping.ts +0 -89
- package/src/harnesses/codex/CodexSessionParser.ts +0 -462
- package/src/harnesses/codex/credentials.ts +0 -81
- package/src/harnesses/codex/durable/CodexCliProbe.ts +0 -68
- package/src/harnesses/codex/durable/CodexPrintAgentService.ts +0 -79
- package/src/harnesses/codex/durable/CodexPrintRunner.ts +0 -104
- package/src/harnesses/codex/durable/CodexStreamParser.ts +0 -117
- package/src/harnesses/codex/readiness.ts +0 -72
- package/src/harnesses/copilot/CopilotAdapter.ts +0 -161
- package/src/harnesses/copilot/CopilotAgentMapper.ts +0 -27
- package/src/harnesses/copilot/CopilotSessionLocator.ts +0 -161
- package/src/harnesses/copilot/CopilotSessionParser.ts +0 -380
- package/src/harnesses/copilot/readiness.ts +0 -33
- package/src/harnesses/devin/DevinAdapter.ts +0 -212
- package/src/harnesses/devin/DevinAgentMapper.ts +0 -39
- package/src/harnesses/devin/DevinSessionLocator.ts +0 -230
- package/src/harnesses/devin/DevinSessionParser.ts +0 -227
- package/src/harnesses/devin/credentials.ts +0 -88
- package/src/harnesses/devin/readiness.ts +0 -36
- package/src/harnesses/gemini/GeminiAgentMapper.ts +0 -27
- package/src/harnesses/gemini/GeminiCliAdapter.ts +0 -272
- package/src/harnesses/gemini/GeminiSessionLocator.ts +0 -394
- package/src/harnesses/gemini/GeminiSessionParser.ts +0 -395
- package/src/harnesses/gemini/fileSignature.ts +0 -10
- package/src/harnesses/grok/GrokAgentMapper.ts +0 -32
- package/src/harnesses/grok/GrokCliAdapter.ts +0 -126
- package/src/harnesses/grok/GrokSessionLocator.ts +0 -179
- package/src/harnesses/grok/GrokSessionParser.ts +0 -251
- package/src/harnesses/index.ts +0 -32
- package/src/harnesses/kiro/KiroAdapter.ts +0 -143
- package/src/harnesses/kiro/KiroAgentMapper.ts +0 -34
- package/src/harnesses/kiro/KiroSessionLocator.ts +0 -143
- package/src/harnesses/kiro/KiroSessionParser.ts +0 -376
- package/src/harnesses/muse/MuseAdapter.ts +0 -157
- package/src/harnesses/muse/MuseAgentMapper.ts +0 -33
- package/src/harnesses/muse/MuseSessionLocator.ts +0 -286
- package/src/harnesses/muse/MuseSessionParser.ts +0 -435
- package/src/harnesses/muse/readiness.ts +0 -38
- package/src/harnesses/opencode/OpenCodeAdapter.ts +0 -110
- package/src/harnesses/opencode/OpenCodeAgentMapper.ts +0 -49
- package/src/harnesses/opencode/OpenCodeSessionLocator.ts +0 -151
- package/src/harnesses/opencode/OpenCodeSessionParser.ts +0 -146
- package/src/harnesses/opencode/readiness.ts +0 -48
- package/src/harnesses/pi/PiAdapter.ts +0 -197
- package/src/harnesses/pi/PiAgentMapper.ts +0 -27
- package/src/harnesses/pi/PiSessionLocator.ts +0 -288
- package/src/harnesses/pi/PiSessionParser.ts +0 -488
- package/src/harnesses/pi/PiSessionTracker.ts +0 -87
- package/src/harnesses/pi/credentials.ts +0 -129
- package/src/harnesses/pi/durable/PiCliProbe.ts +0 -56
- package/src/harnesses/pi/durable/PiPrintAgentService.ts +0 -77
- package/src/harnesses/pi/durable/PiPrintProtocol.ts +0 -41
- package/src/harnesses/pi/durable/PiPrintRunner.ts +0 -95
- package/src/harnesses/pi/durable/PiStreamParser.ts +0 -94
- package/src/harnesses/pi/readiness.ts +0 -104
- package/src/harnesses/readiness/AgentReadiness.ts +0 -91
- package/src/harnesses/readiness/checks.ts +0 -336
- package/src/harnesses/readiness/types.ts +0 -90
- package/src/harnesses/runtimeProfiles.ts +0 -105
- package/src/harnesses/shared.ts +0 -124
- package/src/index.ts +0 -71
- package/src/runtime/ManagedAgentRuntime.ts +0 -253
- package/src/runtime/RuntimeFactory.ts +0 -13
- package/src/runtime/errors.ts +0 -50
- package/src/runtime/herdr/HerdrAgentDiscovery.ts +0 -166
- package/src/runtime/herdr/HerdrAgentRuntime.ts +0 -216
- package/src/runtime/herdr/HerdrCliClient.ts +0 -78
- package/src/runtime/herdr/HerdrErrors.ts +0 -9
- package/src/runtime/herdr/HerdrResponseParsers.ts +0 -86
- package/src/runtime/herdr/HerdrRuntimeRef.ts +0 -41
- package/src/runtime/tmux/PidPolling.ts +0 -34
- package/src/runtime/tmux/TmuxAgentRuntime.ts +0 -113
- package/src/runtime/tmux/TmuxManager.ts +0 -102
- package/src/runtime/tmux/TmuxRuntimeRef.ts +0 -9
- package/src/runtime/types.ts +0 -56
- package/src/terminal/TerminalFocusManager.ts +0 -52
- package/src/terminal/TtyWriter.ts +0 -26
- package/src/terminal/backends/ghostty.ts +0 -180
- package/src/terminal/backends/index.ts +0 -23
- package/src/terminal/backends/iterm2.ts +0 -126
- package/src/terminal/backends/shared.ts +0 -47
- package/src/terminal/backends/terminal-app.ts +0 -122
- package/src/terminal/backends/tmux.ts +0 -62
- package/src/terminal/backends/wezterm.ts +0 -65
- package/src/terminal/types.ts +0 -23
- package/src/utils/AgentRegistry.ts +0 -351
- package/src/utils/IncrementalJsonlSummary.ts +0 -306
- package/src/utils/agent-requests.ts +0 -28
- package/src/utils/applescript.ts +0 -10
- package/src/utils/jsonlTail.ts +0 -349
- package/src/utils/matching.ts +0 -96
- package/src/utils/matchingConstants.ts +0 -15
- package/src/utils/process.ts +0 -604
- package/src/utils/session.ts +0 -144
- package/src/utils/sortAgents.ts +0 -54
- package/tsconfig.json +0 -11
- package/vitest.config.ts +0 -20
|
@@ -1,524 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
import type { ConversationMessage, ConversationOptions } from "../../adapters/AgentAdapter.js";
|
|
4
|
-
import { AgentStatus } from "../../adapters/AgentAdapter.js";
|
|
5
|
-
import {
|
|
6
|
-
IncrementalJsonlSummary,
|
|
7
|
-
reduceJsonlContent,
|
|
8
|
-
type JsonlSummaryBounds,
|
|
9
|
-
type JsonlSummaryReducer,
|
|
10
|
-
} from "../../utils/IncrementalJsonlSummary.js";
|
|
11
|
-
import { JsonlTailReader, normalizeTail } from "../../utils/jsonlTail.js";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Content block within a Claude Code JSONL message entry.
|
|
15
|
-
* Handles text, tool_use, and tool_result block types.
|
|
16
|
-
*/
|
|
17
|
-
export interface ContentBlock {
|
|
18
|
-
type?: string;
|
|
19
|
-
text?: string;
|
|
20
|
-
content?: string;
|
|
21
|
-
name?: string;
|
|
22
|
-
input?: Record<string, unknown>;
|
|
23
|
-
tool_use_id?: string;
|
|
24
|
-
is_error?: boolean;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* A single line entry in a Claude Code session JSONL file.
|
|
29
|
-
*
|
|
30
|
-
* Each line is an independent JSON object with a type discriminator:
|
|
31
|
-
* - "user" / "assistant" / "system" — conversation turns
|
|
32
|
-
* - "progress" / "thinking" — intermediate agent state
|
|
33
|
-
* - "last-prompt" / "file-history-snapshot" — metadata (not conversation state)
|
|
34
|
-
*/
|
|
35
|
-
export interface SessionEntry {
|
|
36
|
-
type?: string;
|
|
37
|
-
timestamp?: string;
|
|
38
|
-
cwd?: string;
|
|
39
|
-
message?: {
|
|
40
|
-
content?: string | ContentBlock[];
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Parsed session state extracted from a JSONL file.
|
|
46
|
-
* Aggregates data from all entries into a single summary.
|
|
47
|
-
*/
|
|
48
|
-
export interface ClaudeSession {
|
|
49
|
-
sessionId: string;
|
|
50
|
-
projectPath: string;
|
|
51
|
-
lastCwd?: string;
|
|
52
|
-
sessionStart: Date;
|
|
53
|
-
lastActive: Date;
|
|
54
|
-
lastEntryType?: string;
|
|
55
|
-
isInterrupted: boolean;
|
|
56
|
-
lastUserMessage?: string;
|
|
57
|
-
/** First meaningful user prompt in the session (post noise filter) */
|
|
58
|
-
firstUserMessage?: string;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* O(1) running summary folded from session entries; `toSession` turns it into
|
|
63
|
-
* a `ClaudeSession`. Timestamps are epoch ms so cached state stays immutable.
|
|
64
|
-
*/
|
|
65
|
-
interface ClaudeSummaryState {
|
|
66
|
-
seenFirstLine: boolean;
|
|
67
|
-
/** A bounded cold start skipped the middle: later lines are not the session's first. */
|
|
68
|
-
pastHead?: boolean;
|
|
69
|
-
sessionStartMs?: number;
|
|
70
|
-
lastActiveMs?: number;
|
|
71
|
-
lastCwd?: string;
|
|
72
|
-
lastEntryType?: string;
|
|
73
|
-
isInterrupted: boolean;
|
|
74
|
-
lastUserMessage?: string;
|
|
75
|
-
firstUserMessage?: string;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Top-level JSONL entry types that represent conversation/agent state.
|
|
80
|
-
*
|
|
81
|
-
* Only these types update `lastEntryType` for status determination. All
|
|
82
|
-
* other types Claude Code emits (`attachment`, `permission-mode`,
|
|
83
|
-
* `ai-title`, `queued_command`, `tools_changed`, `model_changed`,
|
|
84
|
-
* `hook_progress`, …) are UI-state events that must not overwrite the
|
|
85
|
-
* last conversation turn — otherwise polling between writes lands on a
|
|
86
|
-
* UI-state entry and `determineStatus` falls through to UNKNOWN.
|
|
87
|
-
*/
|
|
88
|
-
const CONVERSATION_ENTRY_TYPES = new Set(["user", "assistant", "system", "progress", "thinking"]);
|
|
89
|
-
|
|
90
|
-
export interface ClaudeSessionParserOptions {
|
|
91
|
-
/** Cold-start scan bounds for `readSessionIncremental` (see IncrementalJsonlSummary). */
|
|
92
|
-
summaryBounds?: JsonlSummaryBounds | false;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Parses Claude Code session JSONL files into structured data.
|
|
97
|
-
*
|
|
98
|
-
* Session files live at ~/.claude/projects/<encoded-cwd>/<session-id>.jsonl
|
|
99
|
-
* and contain one JSON object per line, each representing a conversation
|
|
100
|
-
* event (user turn, assistant response, tool call, etc.).
|
|
101
|
-
*/
|
|
102
|
-
export class ClaudeSessionParser {
|
|
103
|
-
/** Incremental reader backing `getConversation({ tail })`. */
|
|
104
|
-
private readonly tailReader = new JsonlTailReader();
|
|
105
|
-
|
|
106
|
-
private readonly sessionCache: IncrementalJsonlSummary<ClaudeSummaryState>;
|
|
107
|
-
|
|
108
|
-
constructor(options: ClaudeSessionParserOptions = {}) {
|
|
109
|
-
this.sessionCache = new IncrementalJsonlSummary(this.summaryReducer, {
|
|
110
|
-
bounds: options.summaryBounds,
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Parse a session JSONL file into a ClaudeSession summary.
|
|
116
|
-
*
|
|
117
|
-
* Iterates all lines to extract: session start time (from first entry),
|
|
118
|
-
* last activity timestamp, last entry type (for status), whether the
|
|
119
|
-
* session was interrupted, and the last meaningful user message.
|
|
120
|
-
*
|
|
121
|
-
* Returns null if the file is unreadable or empty.
|
|
122
|
-
*/
|
|
123
|
-
readSession(filePath: string, projectPath: string): ClaudeSession | null {
|
|
124
|
-
let content: string;
|
|
125
|
-
try {
|
|
126
|
-
content = fs.readFileSync(filePath, "utf-8");
|
|
127
|
-
} catch {
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return this.toSession(filePath, projectPath, reduceJsonlContent(this.summaryReducer, content));
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Same result as `readSession`, but backed by a per-instance incremental
|
|
136
|
-
* cache so repeated refreshes only parse bytes appended since the last call.
|
|
137
|
-
* Call `pruneSessionCache()` once per refresh to evict files no longer read.
|
|
138
|
-
*
|
|
139
|
-
* The first read of a large transcript is a bounded head + tail scan (see
|
|
140
|
-
* `summaryReducer.skip`); fields whose entries lie only in the skipped
|
|
141
|
-
* middle fall back to their defaults instead of forcing a full parse.
|
|
142
|
-
*/
|
|
143
|
-
readSessionIncremental(filePath: string, projectPath: string): ClaudeSession | null {
|
|
144
|
-
const result = this.sessionCache.read(filePath);
|
|
145
|
-
return result ? this.toSession(filePath, projectPath, result.state) : null;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/** Evict cached summaries for files not read since the previous prune. */
|
|
149
|
-
pruneSessionCache(): void {
|
|
150
|
-
this.sessionCache.prune();
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Fold one JSONL entry into the O(1) session summary. Mirrors the fields
|
|
155
|
-
* `readSession` exposes: session start comes from the first line only;
|
|
156
|
-
* everything else tracks the latest matching entry.
|
|
157
|
-
*
|
|
158
|
-
* `skip` (bounded cold start) keeps the head's session start and first user
|
|
159
|
-
* message and clears every "latest" field, so those come from the tail only:
|
|
160
|
-
* a first user message beyond the head stays undefined, and a last user
|
|
161
|
-
* message before the tail window stays undefined.
|
|
162
|
-
*/
|
|
163
|
-
private readonly summaryReducer: JsonlSummaryReducer<ClaudeSummaryState> = {
|
|
164
|
-
initial: () => ({ seenFirstLine: false, isInterrupted: false }),
|
|
165
|
-
reduce: (state, value) => {
|
|
166
|
-
const next: ClaudeSummaryState = { ...state, seenFirstLine: true };
|
|
167
|
-
if (!state.seenFirstLine) {
|
|
168
|
-
next.sessionStartMs = this.parseSessionStart(value);
|
|
169
|
-
}
|
|
170
|
-
if (!value || typeof value !== "object") {
|
|
171
|
-
return next;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const entry = value as SessionEntry;
|
|
175
|
-
if (entry.timestamp) {
|
|
176
|
-
const ts = new Date(entry.timestamp).getTime();
|
|
177
|
-
if (!Number.isNaN(ts)) {
|
|
178
|
-
next.lastActiveMs = ts;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if (typeof entry.cwd === "string" && entry.cwd.trim().length > 0) {
|
|
183
|
-
next.lastCwd = entry.cwd;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (entry.type && CONVERSATION_ENTRY_TYPES.has(entry.type)) {
|
|
187
|
-
next.lastEntryType = entry.type;
|
|
188
|
-
|
|
189
|
-
if (entry.type === "user") {
|
|
190
|
-
const msgContent = entry.message?.content;
|
|
191
|
-
next.isInterrupted =
|
|
192
|
-
Array.isArray(msgContent) &&
|
|
193
|
-
msgContent.some(
|
|
194
|
-
(c) =>
|
|
195
|
-
(c.type === "text" && c.text?.includes("[Request interrupted")) ||
|
|
196
|
-
(c.type === "tool_result" && c.content?.includes("[Request interrupted")),
|
|
197
|
-
);
|
|
198
|
-
|
|
199
|
-
const text = this.extractUserMessageText(msgContent);
|
|
200
|
-
if (text) {
|
|
201
|
-
next.lastUserMessage = text;
|
|
202
|
-
if (!next.firstUserMessage && !state.pastHead) {
|
|
203
|
-
next.firstUserMessage = text;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
} else {
|
|
207
|
-
next.isInterrupted = false;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
return next;
|
|
212
|
-
},
|
|
213
|
-
skip: (state) => ({
|
|
214
|
-
seenFirstLine: true,
|
|
215
|
-
pastHead: true,
|
|
216
|
-
sessionStartMs: state.sessionStartMs,
|
|
217
|
-
firstUserMessage: state.firstUserMessage,
|
|
218
|
-
isInterrupted: false,
|
|
219
|
-
}),
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
private toSession(
|
|
223
|
-
filePath: string,
|
|
224
|
-
projectPath: string,
|
|
225
|
-
state: ClaudeSummaryState,
|
|
226
|
-
): ClaudeSession {
|
|
227
|
-
const sessionStartMs = state.sessionStartMs ?? state.lastActiveMs;
|
|
228
|
-
return {
|
|
229
|
-
sessionId: path.basename(filePath, ".jsonl"),
|
|
230
|
-
projectPath: projectPath || state.lastCwd || "",
|
|
231
|
-
lastCwd: state.lastCwd,
|
|
232
|
-
sessionStart: sessionStartMs !== undefined ? new Date(sessionStartMs) : new Date(),
|
|
233
|
-
lastActive: state.lastActiveMs !== undefined ? new Date(state.lastActiveMs) : new Date(),
|
|
234
|
-
lastEntryType: state.lastEntryType,
|
|
235
|
-
isInterrupted: state.isInterrupted,
|
|
236
|
-
lastUserMessage: state.lastUserMessage,
|
|
237
|
-
firstUserMessage: state.firstUserMessage,
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Determine agent status from parsed session state.
|
|
243
|
-
*
|
|
244
|
-
* Status mapping:
|
|
245
|
-
* - "user" + interrupted → WAITING (agent finished, awaiting new input)
|
|
246
|
-
* - "user" + not interrupted → RUNNING (agent is processing)
|
|
247
|
-
* - "progress" / "thinking" → RUNNING
|
|
248
|
-
* - "assistant" → WAITING (agent responded, awaiting user)
|
|
249
|
-
* - "system" → IDLE
|
|
250
|
-
*/
|
|
251
|
-
determineStatus(session: ClaudeSession): AgentStatus {
|
|
252
|
-
if (!session.lastEntryType) {
|
|
253
|
-
return AgentStatus.UNKNOWN;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
if (session.lastEntryType === "user") {
|
|
257
|
-
return session.isInterrupted ? AgentStatus.WAITING : AgentStatus.RUNNING;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
if (session.lastEntryType === "progress" || session.lastEntryType === "thinking") {
|
|
261
|
-
return AgentStatus.RUNNING;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if (session.lastEntryType === "assistant") {
|
|
265
|
-
return AgentStatus.WAITING;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (session.lastEntryType === "system") {
|
|
269
|
-
return AgentStatus.IDLE;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
return AgentStatus.UNKNOWN;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Read the full conversation from a session JSONL file.
|
|
277
|
-
*
|
|
278
|
-
* Default mode returns only text content from user/assistant/system messages.
|
|
279
|
-
* Verbose mode also includes tool_use and tool_result blocks. With `tail`,
|
|
280
|
-
* only the last N messages are read (from the end of the file).
|
|
281
|
-
*/
|
|
282
|
-
getConversation(sessionFilePath: string, options?: ConversationOptions): ConversationMessage[] {
|
|
283
|
-
const verbose = options?.verbose ?? false;
|
|
284
|
-
const tail = normalizeTail(options?.tail);
|
|
285
|
-
if (tail !== undefined) {
|
|
286
|
-
return this.tailReader.read(
|
|
287
|
-
sessionFilePath,
|
|
288
|
-
tail,
|
|
289
|
-
{ parseLine: (line) => this.lineToMessage(line, verbose) },
|
|
290
|
-
String(verbose),
|
|
291
|
-
);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
let content: string;
|
|
295
|
-
try {
|
|
296
|
-
content = fs.readFileSync(sessionFilePath, "utf-8");
|
|
297
|
-
} catch {
|
|
298
|
-
return [];
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
const lines = content.trim().split("\n");
|
|
302
|
-
const messages: ConversationMessage[] = [];
|
|
303
|
-
|
|
304
|
-
for (const line of lines) {
|
|
305
|
-
const message = this.lineToMessage(line, verbose);
|
|
306
|
-
if (message) messages.push(message);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
return messages;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
/** Convert one JSONL line into a conversation message, or null when it is not one. */
|
|
313
|
-
private lineToMessage(line: string, verbose: boolean): ConversationMessage | null {
|
|
314
|
-
let entry: SessionEntry;
|
|
315
|
-
try {
|
|
316
|
-
entry = JSON.parse(line);
|
|
317
|
-
} catch {
|
|
318
|
-
return null;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
let role: ConversationMessage["role"];
|
|
322
|
-
if (entry.type === "user") {
|
|
323
|
-
role = "user";
|
|
324
|
-
} else if (entry.type === "assistant") {
|
|
325
|
-
role = "assistant";
|
|
326
|
-
} else if (entry.type === "system") {
|
|
327
|
-
role = "system";
|
|
328
|
-
} else {
|
|
329
|
-
return null;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
const text = this.extractConversationContent(entry.message?.content, role, verbose);
|
|
333
|
-
if (!text) return null;
|
|
334
|
-
|
|
335
|
-
return {
|
|
336
|
-
role,
|
|
337
|
-
content: text,
|
|
338
|
-
timestamp: entry.timestamp,
|
|
339
|
-
};
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* Parse session start time (epoch ms) from the first JSONL entry.
|
|
344
|
-
*
|
|
345
|
-
* Claude Code may emit a "file-history-snapshot" as the first entry,
|
|
346
|
-
* which stores its timestamp inside "snapshot.timestamp" rather than
|
|
347
|
-
* at the root level.
|
|
348
|
-
*/
|
|
349
|
-
private parseSessionStart(firstEntry: unknown): number | undefined {
|
|
350
|
-
if (!firstEntry || typeof firstEntry !== "object") {
|
|
351
|
-
return undefined;
|
|
352
|
-
}
|
|
353
|
-
const entry = firstEntry as { timestamp?: string; snapshot?: { timestamp?: string } };
|
|
354
|
-
const rawTs = entry.timestamp || entry.snapshot?.timestamp;
|
|
355
|
-
if (rawTs) {
|
|
356
|
-
const ts = new Date(rawTs).getTime();
|
|
357
|
-
if (!Number.isNaN(ts)) {
|
|
358
|
-
return ts;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
return undefined;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* Extract meaningful text from a user message content field.
|
|
366
|
-
*
|
|
367
|
-
* Handles multiple formats:
|
|
368
|
-
* - Plain string content
|
|
369
|
-
* - Array of content blocks (extracts first text block)
|
|
370
|
-
* - Skill slash-commands (<command-message> tags)
|
|
371
|
-
* - Expanded skill content (extracts ARGUMENTS line)
|
|
372
|
-
* - Filters noise messages (interruptions, tool loaded, session continued)
|
|
373
|
-
*/
|
|
374
|
-
private extractUserMessageText(
|
|
375
|
-
content: string | Array<{ type?: string; text?: string }> | undefined,
|
|
376
|
-
): string | undefined {
|
|
377
|
-
if (!content) {
|
|
378
|
-
return undefined;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
let raw: string | undefined;
|
|
382
|
-
|
|
383
|
-
if (typeof content === "string") {
|
|
384
|
-
raw = content.trim();
|
|
385
|
-
} else if (Array.isArray(content)) {
|
|
386
|
-
for (const block of content) {
|
|
387
|
-
if (block.type === "text" && block.text?.trim()) {
|
|
388
|
-
raw = block.text.trim();
|
|
389
|
-
break;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
if (!raw) {
|
|
395
|
-
return undefined;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
if (raw.startsWith("<command-message>")) {
|
|
399
|
-
return this.parseCommandMessage(raw);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
if (raw.startsWith("Base directory for this skill:")) {
|
|
403
|
-
const argsMatch = raw.match(/\nARGUMENTS:\s*(.+)/);
|
|
404
|
-
return argsMatch?.[1]?.trim() || undefined;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
if (isNoiseMessage(raw)) {
|
|
408
|
-
return undefined;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
return raw;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* Parse a <command-message> string into "/command args" format.
|
|
416
|
-
*/
|
|
417
|
-
private parseCommandMessage(raw: string): string | undefined {
|
|
418
|
-
const nameMatch = raw.match(/<command-name>([^<]+)<\/command-name>/);
|
|
419
|
-
const argsMatch = raw.match(/<command-args>([^<]+)<\/command-args>/);
|
|
420
|
-
const name = nameMatch?.[1]?.trim();
|
|
421
|
-
if (!name) {
|
|
422
|
-
return undefined;
|
|
423
|
-
}
|
|
424
|
-
const args = argsMatch?.[1]?.trim();
|
|
425
|
-
return args ? `${name} ${args}` : name;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* Extract displayable content from a message content field for conversation output.
|
|
430
|
-
*/
|
|
431
|
-
private extractConversationContent(
|
|
432
|
-
content: string | ContentBlock[] | undefined,
|
|
433
|
-
role: ConversationMessage["role"],
|
|
434
|
-
verbose: boolean,
|
|
435
|
-
): string | undefined {
|
|
436
|
-
if (!content) return undefined;
|
|
437
|
-
|
|
438
|
-
if (typeof content === "string") {
|
|
439
|
-
const cleaned = stripHarnessTags(content);
|
|
440
|
-
if (role === "user" && isNoiseMessage(cleaned)) return undefined;
|
|
441
|
-
return cleaned || undefined;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
if (!Array.isArray(content)) return undefined;
|
|
445
|
-
|
|
446
|
-
const parts: string[] = [];
|
|
447
|
-
|
|
448
|
-
for (const block of content) {
|
|
449
|
-
if (block.type === "text" && block.text?.trim()) {
|
|
450
|
-
const cleaned = stripHarnessTags(block.text);
|
|
451
|
-
if (!cleaned) continue;
|
|
452
|
-
if (role === "user" && isNoiseMessage(cleaned)) continue;
|
|
453
|
-
parts.push(cleaned);
|
|
454
|
-
} else if (block.type === "tool_use" && verbose) {
|
|
455
|
-
const inputSummary =
|
|
456
|
-
block.input?.file_path || block.input?.pattern || block.input?.command || "";
|
|
457
|
-
parts.push(`[Tool: ${block.name}]${inputSummary ? " " + inputSummary : ""}`);
|
|
458
|
-
} else if (block.type === "tool_result" && verbose) {
|
|
459
|
-
const truncated = truncateToolResult(block.content || "");
|
|
460
|
-
const prefix = block.is_error ? "[Tool Error]" : "[Tool Result]";
|
|
461
|
-
parts.push(`${prefix} ${truncated}`);
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
return parts.length > 0 ? parts.join("\n") : undefined;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
/**
|
|
470
|
-
* Tags whose entire block (including content) should be dropped — they are
|
|
471
|
-
* harness-injected prompt context (system reminders, hook output, command
|
|
472
|
-
* stdout), not meaningful conversation content.
|
|
473
|
-
*/
|
|
474
|
-
const HARNESS_DROP_TAGS = [
|
|
475
|
-
"system-reminder",
|
|
476
|
-
"local-command-stdout",
|
|
477
|
-
"local-command-stderr",
|
|
478
|
-
"user-prompt-submit-hook",
|
|
479
|
-
"command-stdout",
|
|
480
|
-
"command-stderr",
|
|
481
|
-
"bash-input",
|
|
482
|
-
"bash-stdout",
|
|
483
|
-
"bash-stderr",
|
|
484
|
-
"command-message",
|
|
485
|
-
] as const;
|
|
486
|
-
|
|
487
|
-
const HARNESS_DROP_RE = new RegExp(`<(${HARNESS_DROP_TAGS.join("|")})>[\\s\\S]*?</\\1>`, "g");
|
|
488
|
-
|
|
489
|
-
const COMMAND_INVOCATION_RE =
|
|
490
|
-
/<command-name>([^<]+)<\/command-name>(?:\s*<command-args>([\s\S]*?)<\/command-args>)?/g;
|
|
491
|
-
|
|
492
|
-
/**
|
|
493
|
-
* Remove harness-injected XML blocks from message text and collapse
|
|
494
|
-
* <command-name>/<command-args> pairs into a "/name args" shorthand.
|
|
495
|
-
*
|
|
496
|
-
* Returns the cleaned, trimmed text. Returns an empty string if nothing
|
|
497
|
-
* survives stripping.
|
|
498
|
-
*/
|
|
499
|
-
function stripHarnessTags(text: string): string {
|
|
500
|
-
let out = text.replace(HARNESS_DROP_RE, "");
|
|
501
|
-
|
|
502
|
-
out = out.replace(COMMAND_INVOCATION_RE, (_match, rawName: string, rawArgs?: string) => {
|
|
503
|
-
const name = rawName.trim();
|
|
504
|
-
const args = rawArgs?.trim();
|
|
505
|
-
return args ? `${name} ${args}` : name;
|
|
506
|
-
});
|
|
507
|
-
|
|
508
|
-
return out.replace(/\n{3,}/g, "\n\n").trim();
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
/** Check if a message is noise (not a meaningful user intent). */
|
|
512
|
-
function isNoiseMessage(text: string): boolean {
|
|
513
|
-
return (
|
|
514
|
-
text.startsWith("[Request interrupted") ||
|
|
515
|
-
text === "Tool loaded." ||
|
|
516
|
-
text.startsWith("This session is being continued")
|
|
517
|
-
);
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
function truncateToolResult(content: string, maxLength = 200): string {
|
|
521
|
-
const firstLine = content.split("\n")[0] || "";
|
|
522
|
-
if (firstLine.length <= maxLength) return firstLine;
|
|
523
|
-
return firstLine.slice(0, maxLength - 3) + "...";
|
|
524
|
-
}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { execFile } from "node:child_process";
|
|
2
|
-
import { readFile } from "node:fs/promises";
|
|
3
|
-
import { homedir } from "node:os";
|
|
4
|
-
import { isAbsolute, join, resolve } from "node:path";
|
|
5
|
-
import { promisify } from "node:util";
|
|
6
|
-
|
|
7
|
-
const execFileAsync = promisify(execFile);
|
|
8
|
-
const CLAUDE_KEYCHAIN_SERVICE = "Claude Code-credentials";
|
|
9
|
-
|
|
10
|
-
export type ClaudeCredentialOptions = {
|
|
11
|
-
env?: NodeJS.ProcessEnv;
|
|
12
|
-
readFile?: (path: string, encoding: BufferEncoding) => Promise<string>;
|
|
13
|
-
now?: () => Date;
|
|
14
|
-
cwd?: string;
|
|
15
|
-
platform?: NodeJS.Platform;
|
|
16
|
-
keychainRead?: (service: string) => Promise<string | null>;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
type Credential = { token: string | null; expired: boolean };
|
|
20
|
-
|
|
21
|
-
function record(value: unknown): Record<string, unknown> | null {
|
|
22
|
-
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
23
|
-
? (value as Record<string, unknown>)
|
|
24
|
-
: null;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function nonEmptyText(value: unknown): string | null {
|
|
28
|
-
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function credentialsPath(options: ClaudeCredentialOptions): string {
|
|
32
|
-
const env = options.env ?? process.env;
|
|
33
|
-
const configured = nonEmptyText(env.CLAUDE_CONFIG_DIR);
|
|
34
|
-
if (configured) {
|
|
35
|
-
const profileRoot = isAbsolute(configured)
|
|
36
|
-
? configured
|
|
37
|
-
: resolve(options.cwd ?? process.cwd(), configured);
|
|
38
|
-
return join(profileRoot, ".credentials.json");
|
|
39
|
-
}
|
|
40
|
-
return join(env.HOME || homedir(), ".claude", ".credentials.json");
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function credentialFromRoot(root: Record<string, unknown> | null, now: Date): Credential {
|
|
44
|
-
const oauth = record(root?.claudeAiOauth);
|
|
45
|
-
const token = nonEmptyText(oauth?.accessToken);
|
|
46
|
-
if (!token) return { token: null, expired: false };
|
|
47
|
-
const expired =
|
|
48
|
-
typeof oauth?.expiresAt === "number" &&
|
|
49
|
-
Number.isFinite(oauth.expiresAt) &&
|
|
50
|
-
oauth.expiresAt <= now.getTime();
|
|
51
|
-
return { token: expired ? null : token, expired };
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function credentialFromPayload(payload: string | null, now: Date): Credential {
|
|
55
|
-
if (!payload) return { token: null, expired: false };
|
|
56
|
-
try {
|
|
57
|
-
return credentialFromRoot(record(JSON.parse(payload)), now);
|
|
58
|
-
} catch {
|
|
59
|
-
return { token: null, expired: false };
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async function readProfileCredential(
|
|
64
|
-
options: ClaudeCredentialOptions,
|
|
65
|
-
now: Date,
|
|
66
|
-
): Promise<Credential> {
|
|
67
|
-
try {
|
|
68
|
-
const payload = await (options.readFile ?? readFile)(credentialsPath(options), "utf8");
|
|
69
|
-
return credentialFromPayload(payload, now);
|
|
70
|
-
} catch {
|
|
71
|
-
return { token: null, expired: false };
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
async function readClaudeKeychain(service: string): Promise<string | null> {
|
|
76
|
-
try {
|
|
77
|
-
const { stdout } = await execFileAsync(
|
|
78
|
-
"/usr/bin/security",
|
|
79
|
-
["find-generic-password", "-s", service, "-w"],
|
|
80
|
-
{ encoding: "utf8", timeout: 1500, maxBuffer: 1024 * 1024 },
|
|
81
|
-
);
|
|
82
|
-
return nonEmptyText(stdout);
|
|
83
|
-
} catch {
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async function readKeychainCredential(
|
|
89
|
-
options: ClaudeCredentialOptions,
|
|
90
|
-
now: Date,
|
|
91
|
-
): Promise<Credential> {
|
|
92
|
-
const env = options.env ?? process.env;
|
|
93
|
-
const usesDefaultProfile = !nonEmptyText(env.CLAUDE_CONFIG_DIR);
|
|
94
|
-
if (!usesDefaultProfile || (options.platform ?? process.platform) !== "darwin") {
|
|
95
|
-
return { token: null, expired: false };
|
|
96
|
-
}
|
|
97
|
-
try {
|
|
98
|
-
const payload = await (options.keychainRead ?? readClaudeKeychain)(CLAUDE_KEYCHAIN_SERVICE);
|
|
99
|
-
return credentialFromPayload(payload, now);
|
|
100
|
-
} catch {
|
|
101
|
-
return { token: null, expired: false };
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export async function resolveClaudeAnthropicToken(
|
|
106
|
-
options: ClaudeCredentialOptions = {},
|
|
107
|
-
): Promise<string> {
|
|
108
|
-
const env = options.env ?? process.env;
|
|
109
|
-
const environmentToken = nonEmptyText(env.CLAUDE_CODE_OAUTH_TOKEN);
|
|
110
|
-
if (environmentToken) return environmentToken;
|
|
111
|
-
|
|
112
|
-
const now = options.now?.() ?? new Date();
|
|
113
|
-
const profileCredential = await readProfileCredential(options, now);
|
|
114
|
-
if (profileCredential.token) return profileCredential.token;
|
|
115
|
-
|
|
116
|
-
const keychainCredential = await readKeychainCredential(options, now);
|
|
117
|
-
if (keychainCredential.token) return keychainCredential.token;
|
|
118
|
-
if (profileCredential.expired || keychainCredential.expired) {
|
|
119
|
-
throw new Error("Claude OAuth credentials expired");
|
|
120
|
-
}
|
|
121
|
-
throw new Error("Claude OAuth credentials not found or malformed");
|
|
122
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { execFile } from "child_process";
|
|
2
|
-
import { promisify } from "util";
|
|
3
|
-
import { ClaudePrintError } from "../../../durable/DurableAgent.js";
|
|
4
|
-
import { sanitizeText } from "../../../durable/utils.js";
|
|
5
|
-
|
|
6
|
-
type ExecResult = { stdout: string; stderr: string };
|
|
7
|
-
type Exec = (file: string, args: string[]) => Promise<ExecResult>;
|
|
8
|
-
|
|
9
|
-
const execFileAsync = promisify(execFile);
|
|
10
|
-
const REQUIRED = ["--print", "--session-id", "--resume", "--output-format", "stream-json"];
|
|
11
|
-
|
|
12
|
-
export interface ClaudeCliProbeOptions {
|
|
13
|
-
executable?: string;
|
|
14
|
-
exec?: Exec;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class ClaudeCliProbe {
|
|
18
|
-
private readonly executable: string;
|
|
19
|
-
private readonly exec: Exec;
|
|
20
|
-
|
|
21
|
-
constructor(options: ClaudeCliProbeOptions = {}) {
|
|
22
|
-
this.executable = options.executable ?? "claude";
|
|
23
|
-
this.exec =
|
|
24
|
-
options.exec ??
|
|
25
|
-
(async (file, args) => {
|
|
26
|
-
const result = await execFileAsync(file, args, {
|
|
27
|
-
encoding: "utf8",
|
|
28
|
-
maxBuffer: 1024 * 1024,
|
|
29
|
-
});
|
|
30
|
-
return { stdout: result.stdout, stderr: result.stderr };
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async validate(): Promise<{ executable: string; version: string }> {
|
|
35
|
-
try {
|
|
36
|
-
const versionResult = await this.exec(this.executable, ["--version"]);
|
|
37
|
-
const helpResult = await this.exec(this.executable, ["--help"]);
|
|
38
|
-
const missing = REQUIRED.filter((capability) => !helpResult.stdout.includes(capability));
|
|
39
|
-
if (missing.length > 0) {
|
|
40
|
-
throw new ClaudePrintError(
|
|
41
|
-
`Claude CLI does not support required print-mode capabilities: ${missing.join(", ")}.`,
|
|
42
|
-
"CLAUDE_CLI_UNSUPPORTED",
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
executable: this.executable,
|
|
47
|
-
version: sanitizeText(versionResult.stdout, 256) || "unknown",
|
|
48
|
-
};
|
|
49
|
-
} catch (error) {
|
|
50
|
-
if (error instanceof ClaudePrintError) throw error;
|
|
51
|
-
throw new ClaudePrintError(
|
|
52
|
-
`Claude CLI validation failed: ${sanitizeText((error as Error).message, 512)}`,
|
|
53
|
-
"CLAUDE_CLI_UNAVAILABLE",
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|