@ai-devkit/agent-manager 0.43.0 → 0.44.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/harnesses/pi/PiAdapter.d.ts.map +1 -1
- package/dist/harnesses/pi/PiAdapter.js +9 -4
- package/dist/harnesses/pi/PiAdapter.js.map +1 -1
- package/package.json +8 -3
- package/.swcrc +0 -27
- package/dist/__tests__/AgentManager.test.js +0 -1727
- package/dist/__tests__/AgentManager.test.js.map +0 -1
- package/dist/__tests__/adapters/IncrementalSessionRefresh.test.js +0 -486
- package/dist/__tests__/adapters/IncrementalSessionRefresh.test.js.map +0 -1
- package/dist/__tests__/adapters/adapterProcessImports.test.js +0 -52
- package/dist/__tests__/adapters/adapterProcessImports.test.js.map +0 -1
- package/dist/__tests__/adapters/adapterSnapshotCandidates.test.js +0 -247
- package/dist/__tests__/adapters/adapterSnapshotCandidates.test.js.map +0 -1
- package/dist/__tests__/capacity/anthropic.test.js +0 -115
- package/dist/__tests__/capacity/anthropic.test.js.map +0 -1
- package/dist/__tests__/capacity/boundaries.test.js +0 -45
- package/dist/__tests__/capacity/boundaries.test.js.map +0 -1
- package/dist/__tests__/capacity/claude.test.js +0 -485
- package/dist/__tests__/capacity/claude.test.js.map +0 -1
- package/dist/__tests__/capacity/codex.test.js +0 -339
- package/dist/__tests__/capacity/codex.test.js.map +0 -1
- package/dist/__tests__/capacity/devin.test.js +0 -239
- package/dist/__tests__/capacity/devin.test.js.map +0 -1
- package/dist/__tests__/capacity/index.test.js +0 -53
- package/dist/__tests__/capacity/index.test.js.map +0 -1
- package/dist/__tests__/capacity/openai.test.js +0 -687
- package/dist/__tests__/capacity/openai.test.js.map +0 -1
- package/dist/__tests__/capacity/wham.test.js +0 -159
- package/dist/__tests__/capacity/wham.test.js.map +0 -1
- package/dist/__tests__/capacity/zai.test.js +0 -212
- package/dist/__tests__/capacity/zai.test.js.map +0 -1
- package/dist/__tests__/fixtures.test.js +0 -218
- package/dist/__tests__/fixtures.test.js.map +0 -1
- package/dist/__tests__/harnesses/BoundedSummarySkip.test.js +0 -568
- package/dist/__tests__/harnesses/BoundedSummarySkip.test.js.map +0 -1
- package/dist/__tests__/harnesses/SessionSummaryEquivalence.test.js +0 -1089
- package/dist/__tests__/harnesses/SessionSummaryEquivalence.test.js.map +0 -1
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.js +0 -143
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.js.map +0 -1
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.js +0 -462
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/builtinAdapters.test.js +0 -33
- package/dist/__tests__/harnesses/builtinAdapters.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeAgentMapper.test.js +0 -79
- package/dist/__tests__/harnesses/claude/ClaudeAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeCodeAdapter.test.js +0 -1881
- package/dist/__tests__/harnesses/claude/ClaudeCodeAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeSessionLocator.test.js +0 -425
- package/dist/__tests__/harnesses/claude/ClaudeSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeSessionParser.test.js +0 -314
- package/dist/__tests__/harnesses/claude/ClaudeSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.js +0 -49
- package/dist/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.js +0 -76
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.js +0 -173
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.js +0 -181
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexAdapter.test.js +0 -685
- package/dist/__tests__/harnesses/codex/CodexAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexSessionLocator.test.js +0 -463
- package/dist/__tests__/harnesses/codex/CodexSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexSessionMapping.test.js +0 -86
- package/dist/__tests__/harnesses/codex/CodexSessionMapping.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexSessionParser.test.js +0 -254
- package/dist/__tests__/harnesses/codex/CodexSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexCliProbe.test.js +0 -121
- package/dist/__tests__/harnesses/codex/durable/CodexCliProbe.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.js +0 -84
- package/dist/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.js +0 -128
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.js +0 -246
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexPrintRunner.test.js +0 -384
- package/dist/__tests__/harnesses/codex/durable/CodexPrintRunner.test.js.map +0 -1
- package/dist/__tests__/harnesses/copilot/CopilotAdapter.test.js +0 -659
- package/dist/__tests__/harnesses/copilot/CopilotAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/copilot/CopilotRefreshIO.test.js +0 -290
- package/dist/__tests__/harnesses/copilot/CopilotRefreshIO.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinAdapter.test.js +0 -597
- package/dist/__tests__/harnesses/devin/DevinAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinAgentMapper.test.js +0 -99
- package/dist/__tests__/harnesses/devin/DevinAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinSessionLocator.test.js +0 -192
- package/dist/__tests__/harnesses/devin/DevinSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinSessionParser.test.js +0 -407
- package/dist/__tests__/harnesses/devin/DevinSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/fixtures.js +0 -95
- package/dist/__tests__/harnesses/devin/fixtures.js.map +0 -1
- package/dist/__tests__/harnesses/gemini/GeminiCliAdapter.test.js +0 -1454
- package/dist/__tests__/harnesses/gemini/GeminiCliAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/gemini/GeminiSessionJsonl.test.js +0 -491
- package/dist/__tests__/harnesses/gemini/GeminiSessionJsonl.test.js.map +0 -1
- package/dist/__tests__/harnesses/gemini/GeminiSessionLocator.test.js +0 -399
- package/dist/__tests__/harnesses/gemini/GeminiSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokAgentMapper.test.js +0 -56
- package/dist/__tests__/harnesses/grok/GrokAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokCliAdapter.test.js +0 -421
- package/dist/__tests__/harnesses/grok/GrokCliAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokIncrementalRefresh.test.js +0 -167
- package/dist/__tests__/harnesses/grok/GrokIncrementalRefresh.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokSessionLocator.test.js +0 -133
- package/dist/__tests__/harnesses/grok/GrokSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokSessionParser.test.js +0 -301
- package/dist/__tests__/harnesses/grok/GrokSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/kiro/KiroAdapter.test.js +0 -662
- package/dist/__tests__/harnesses/kiro/KiroAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseAdapter.test.js +0 -247
- package/dist/__tests__/harnesses/muse/MuseAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseAgentMapper.test.js +0 -81
- package/dist/__tests__/harnesses/muse/MuseAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseSessionLocator.test.js +0 -185
- package/dist/__tests__/harnesses/muse/MuseSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseSessionParser.test.js +0 -328
- package/dist/__tests__/harnesses/muse/MuseSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeAdapter.test.js +0 -213
- package/dist/__tests__/harnesses/opencode/OpenCodeAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.js +0 -108
- package/dist/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.js +0 -94
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionParser.test.js +0 -147
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiAdapter.test.js +0 -367
- package/dist/__tests__/harnesses/pi/PiAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiDiscoveryIO.test.js +0 -382
- package/dist/__tests__/harnesses/pi/PiDiscoveryIO.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiSessionParser.test.js +0 -416
- package/dist/__tests__/harnesses/pi/PiSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiSessionTracker.test.js +0 -108
- package/dist/__tests__/harnesses/pi/PiSessionTracker.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiCliProbe.test.js +0 -70
- package/dist/__tests__/harnesses/pi/durable/PiCliProbe.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.js +0 -43
- package/dist/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiPrintAgentService.test.js +0 -192
- package/dist/__tests__/harnesses/pi/durable/PiPrintAgentService.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiPrintProtocol.test.js +0 -119
- package/dist/__tests__/harnesses/pi/durable/PiPrintProtocol.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiPrintRunner.test.js +0 -382
- package/dist/__tests__/harnesses/pi/durable/PiPrintRunner.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiStreamParser.test.js +0 -34
- package/dist/__tests__/harnesses/pi/durable/PiStreamParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/readiness/AgentReadiness.test.js +0 -446
- package/dist/__tests__/harnesses/readiness/AgentReadiness.test.js.map +0 -1
- package/dist/__tests__/harnesses/runtimeProfiles.test.js +0 -101
- package/dist/__tests__/harnesses/runtimeProfiles.test.js.map +0 -1
- package/dist/__tests__/print/DurableAgent.test.js +0 -15
- package/dist/__tests__/print/DurableAgent.test.js.map +0 -1
- package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js +0 -186
- package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js.map +0 -1
- package/dist/__tests__/print/DurableAgentRepository.test.js +0 -249
- package/dist/__tests__/print/DurableAgentRepository.test.js.map +0 -1
- package/dist/__tests__/readiness-fixtures.test.js +0 -54
- package/dist/__tests__/readiness-fixtures.test.js.map +0 -1
- package/dist/__tests__/runtime/AgentRuntime.test.js +0 -13
- package/dist/__tests__/runtime/AgentRuntime.test.js.map +0 -1
- package/dist/__tests__/runtime/HerdrAgentDiscovery.test.js +0 -164
- package/dist/__tests__/runtime/HerdrAgentDiscovery.test.js.map +0 -1
- package/dist/__tests__/runtime/HerdrAgentRuntime.test.js +0 -488
- package/dist/__tests__/runtime/HerdrAgentRuntime.test.js.map +0 -1
- package/dist/__tests__/runtime/ManagedAgentRuntime.test.js +0 -637
- package/dist/__tests__/runtime/ManagedAgentRuntime.test.js.map +0 -1
- package/dist/__tests__/terminal/GhosttyBackend.test.js +0 -334
- package/dist/__tests__/terminal/GhosttyBackend.test.js.map +0 -1
- package/dist/__tests__/terminal/TerminalFocusManager.test.js +0 -253
- package/dist/__tests__/terminal/TerminalFocusManager.test.js.map +0 -1
- package/dist/__tests__/terminal/TmuxManager.test.js +0 -168
- package/dist/__tests__/terminal/TmuxManager.test.js.map +0 -1
- package/dist/__tests__/terminal/TtyWriter.test.js +0 -386
- package/dist/__tests__/terminal/TtyWriter.test.js.map +0 -1
- package/dist/__tests__/utils/AgentRegistry.test.js +0 -636
- package/dist/__tests__/utils/AgentRegistry.test.js.map +0 -1
- package/dist/__tests__/utils/IncrementalJsonlSummary.test.js +0 -650
- package/dist/__tests__/utils/IncrementalJsonlSummary.test.js.map +0 -1
- package/dist/__tests__/utils/agent-requests.test.js +0 -90
- package/dist/__tests__/utils/agent-requests.test.js.map +0 -1
- package/dist/__tests__/utils/conversationTail.bench.test.js +0 -258
- package/dist/__tests__/utils/conversationTail.bench.test.js.map +0 -1
- package/dist/__tests__/utils/conversationTailParity.test.js +0 -588
- package/dist/__tests__/utils/conversationTailParity.test.js.map +0 -1
- package/dist/__tests__/utils/jsonlTail.test.js +0 -360
- package/dist/__tests__/utils/jsonlTail.test.js.map +0 -1
- package/dist/__tests__/utils/matching.test.js +0 -324
- package/dist/__tests__/utils/matching.test.js.map +0 -1
- package/dist/__tests__/utils/matchingConstants.test.js +0 -35
- package/dist/__tests__/utils/matchingConstants.test.js.map +0 -1
- package/dist/__tests__/utils/process.test.js +0 -818
- package/dist/__tests__/utils/process.test.js.map +0 -1
- package/dist/__tests__/utils/session.test.js +0 -175
- package/dist/__tests__/utils/session.test.js.map +0 -1
- package/project.json +0 -29
- package/scripts/benchmark-cold-start.mjs +0 -350
- package/src/AgentManager.ts +0 -559
- package/src/__tests__/AgentManager.test.ts +0 -1578
- package/src/__tests__/adapters/IncrementalSessionRefresh.test.ts +0 -437
- package/src/__tests__/adapters/adapterProcessImports.test.ts +0 -58
- package/src/__tests__/adapters/adapterSnapshotCandidates.test.ts +0 -243
- package/src/__tests__/capacity/anthropic.test.ts +0 -105
- package/src/__tests__/capacity/boundaries.test.ts +0 -36
- package/src/__tests__/capacity/claude.test.ts +0 -462
- package/src/__tests__/capacity/codex.test.ts +0 -311
- package/src/__tests__/capacity/devin.test.ts +0 -210
- package/src/__tests__/capacity/fixtures/claude-credentials.json +0 -7
- package/src/__tests__/capacity/fixtures/claude-usage-malformed.json +0 -1
- package/src/__tests__/capacity/fixtures/claude-usage-partial.json +0 -15
- package/src/__tests__/capacity/fixtures/claude-usage.json +0 -63
- package/src/__tests__/capacity/fixtures/devin-config.json +0 -6
- package/src/__tests__/capacity/fixtures/devin-credentials.toml +0 -4
- package/src/__tests__/capacity/fixtures/devin-quota-nonplan.json +0 -5
- package/src/__tests__/capacity/fixtures/devin-quota.json +0 -10
- package/src/__tests__/capacity/fixtures/openai-auth.json +0 -6
- package/src/__tests__/capacity/fixtures/openai-codex-auth.json +0 -9
- package/src/__tests__/capacity/fixtures/openai-usage-completions.json +0 -67
- package/src/__tests__/capacity/fixtures/openai-usage-responses.json +0 -20
- package/src/__tests__/capacity/fixtures/wham-usage.json +0 -45
- package/src/__tests__/capacity/fixtures/zai-auth.json +0 -6
- package/src/__tests__/capacity/fixtures/zai-quota-invalid.json +0 -7
- package/src/__tests__/capacity/fixtures/zai-quota.json +0 -38
- package/src/__tests__/capacity/index.test.ts +0 -54
- package/src/__tests__/capacity/openai.test.ts +0 -571
- package/src/__tests__/capacity/wham.test.ts +0 -122
- package/src/__tests__/capacity/zai.test.ts +0 -151
- package/src/__tests__/fixtures.test.ts +0 -245
- package/src/__tests__/harnesses/BoundedSummarySkip.test.ts +0 -496
- package/src/__tests__/harnesses/SessionSummaryEquivalence.test.ts +0 -726
- package/src/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.ts +0 -133
- package/src/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.ts +0 -396
- package/src/__tests__/harnesses/builtinAdapters.test.ts +0 -33
- package/src/__tests__/harnesses/claude/ClaudeAgentMapper.test.ts +0 -84
- package/src/__tests__/harnesses/claude/ClaudeCodeAdapter.test.ts +0 -1793
- package/src/__tests__/harnesses/claude/ClaudeSessionLocator.test.ts +0 -423
- package/src/__tests__/harnesses/claude/ClaudeSessionParser.test.ts +0 -300
- package/src/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.ts +0 -34
- package/src/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.ts +0 -61
- package/src/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.ts +0 -129
- package/src/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.ts +0 -152
- package/src/__tests__/harnesses/codex/CodexAdapter.test.ts +0 -652
- package/src/__tests__/harnesses/codex/CodexSessionLocator.test.ts +0 -419
- package/src/__tests__/harnesses/codex/CodexSessionMapping.test.ts +0 -63
- package/src/__tests__/harnesses/codex/CodexSessionParser.test.ts +0 -192
- package/src/__tests__/harnesses/codex/durable/CodexCliProbe.test.ts +0 -80
- package/src/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.ts +0 -65
- package/src/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.ts +0 -104
- package/src/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.ts +0 -201
- package/src/__tests__/harnesses/codex/durable/CodexPrintRunner.test.ts +0 -299
- package/src/__tests__/harnesses/copilot/CopilotAdapter.test.ts +0 -614
- package/src/__tests__/harnesses/copilot/CopilotRefreshIO.test.ts +0 -270
- package/src/__tests__/harnesses/devin/DevinAdapter.test.ts +0 -290
- package/src/__tests__/harnesses/devin/DevinAgentMapper.test.ts +0 -101
- package/src/__tests__/harnesses/devin/DevinSessionLocator.test.ts +0 -139
- package/src/__tests__/harnesses/devin/DevinSessionParser.test.ts +0 -212
- package/src/__tests__/harnesses/devin/fixtures.ts +0 -144
- package/src/__tests__/harnesses/gemini/GeminiCliAdapter.test.ts +0 -1336
- package/src/__tests__/harnesses/gemini/GeminiSessionJsonl.test.ts +0 -402
- package/src/__tests__/harnesses/gemini/GeminiSessionLocator.test.ts +0 -396
- package/src/__tests__/harnesses/grok/GrokAgentMapper.test.ts +0 -57
- package/src/__tests__/harnesses/grok/GrokCliAdapter.test.ts +0 -376
- package/src/__tests__/harnesses/grok/GrokIncrementalRefresh.test.ts +0 -170
- package/src/__tests__/harnesses/grok/GrokSessionLocator.test.ts +0 -106
- package/src/__tests__/harnesses/grok/GrokSessionParser.test.ts +0 -230
- package/src/__tests__/harnesses/kiro/KiroAdapter.test.ts +0 -552
- package/src/__tests__/harnesses/muse/MuseAdapter.test.ts +0 -197
- package/src/__tests__/harnesses/muse/MuseAgentMapper.test.ts +0 -83
- package/src/__tests__/harnesses/muse/MuseSessionLocator.test.ts +0 -177
- package/src/__tests__/harnesses/muse/MuseSessionParser.test.ts +0 -279
- package/src/__tests__/harnesses/opencode/OpenCodeAdapter.test.ts +0 -215
- package/src/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.ts +0 -101
- package/src/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.ts +0 -84
- package/src/__tests__/harnesses/opencode/OpenCodeSessionParser.test.ts +0 -149
- package/src/__tests__/harnesses/pi/PiAdapter.test.ts +0 -325
- package/src/__tests__/harnesses/pi/PiDiscoveryIO.test.ts +0 -337
- package/src/__tests__/harnesses/pi/PiSessionParser.test.ts +0 -280
- package/src/__tests__/harnesses/pi/PiSessionTracker.test.ts +0 -79
- package/src/__tests__/harnesses/pi/durable/PiCliProbe.test.ts +0 -50
- package/src/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.ts +0 -33
- package/src/__tests__/harnesses/pi/durable/PiPrintAgentService.test.ts +0 -138
- package/src/__tests__/harnesses/pi/durable/PiPrintProtocol.test.ts +0 -71
- package/src/__tests__/harnesses/pi/durable/PiPrintRunner.test.ts +0 -252
- package/src/__tests__/harnesses/pi/durable/PiStreamParser.test.ts +0 -26
- package/src/__tests__/harnesses/readiness/AgentReadiness.test.ts +0 -362
- package/src/__tests__/harnesses/runtimeProfiles.test.ts +0 -123
- package/src/__tests__/print/DurableAgent.test.ts +0 -15
- package/src/__tests__/print/DurableAgentRepository.sqlite.test.ts +0 -128
- package/src/__tests__/print/DurableAgentRepository.test.ts +0 -184
- package/src/__tests__/readiness-fixtures.test.ts +0 -79
- package/src/__tests__/runtime/AgentRuntime.test.ts +0 -8
- package/src/__tests__/runtime/HerdrAgentDiscovery.test.ts +0 -131
- package/src/__tests__/runtime/HerdrAgentRuntime.test.ts +0 -377
- package/src/__tests__/runtime/ManagedAgentRuntime.test.ts +0 -590
- package/src/__tests__/terminal/GhosttyBackend.test.ts +0 -271
- package/src/__tests__/terminal/TerminalFocusManager.test.ts +0 -280
- package/src/__tests__/terminal/TmuxManager.test.ts +0 -185
- package/src/__tests__/terminal/TtyWriter.test.ts +0 -454
- package/src/__tests__/utils/AgentRegistry.test.ts +0 -532
- package/src/__tests__/utils/IncrementalJsonlSummary.test.ts +0 -414
- package/src/__tests__/utils/agent-requests.test.ts +0 -94
- package/src/__tests__/utils/conversationTail.bench.test.ts +0 -193
- package/src/__tests__/utils/conversationTailParity.test.ts +0 -365
- package/src/__tests__/utils/jsonlTail.test.ts +0 -317
- package/src/__tests__/utils/matching.test.ts +0 -234
- package/src/__tests__/utils/matchingConstants.test.ts +0 -40
- package/src/__tests__/utils/process.test.ts +0 -596
- package/src/__tests__/utils/session.test.ts +0 -158
- package/src/adapters/AgentAdapter.ts +0 -255
- package/src/capacity/index.ts +0 -127
- package/src/capacity/providers/anthropic.ts +0 -198
- package/src/capacity/providers/devin.ts +0 -121
- package/src/capacity/providers/openai-platform.ts +0 -150
- package/src/capacity/providers/openai-subscription.ts +0 -184
- package/src/capacity/providers/zai.ts +0 -155
- package/src/capacity/sources/claude.ts +0 -30
- package/src/capacity/sources/codex.ts +0 -251
- package/src/capacity/sources/devin.ts +0 -49
- package/src/capacity/sources/pi.ts +0 -131
- package/src/capacity/types.ts +0 -29
- package/src/database/connection.ts +0 -96
- package/src/database/index.ts +0 -7
- package/src/database/migrations/001_initial.sql +0 -12
- package/src/database/migrations/002_pins.sql +0 -1
- package/src/database/migrations/003_durable_agents.sql +0 -43
- package/src/database/migrations/004_codex_durable_sessions.sql +0 -1
- package/src/database/migrations/005_agent_runtime.sql +0 -2
- package/src/database/schema.ts +0 -64
- package/src/durable/DurableAgent.ts +0 -139
- package/src/durable/DurableAgentRepository.ts +0 -485
- package/src/durable/process.ts +0 -29
- package/src/durable/run.ts +0 -84
- package/src/durable/utils.ts +0 -66
- package/src/fixtures/bundle.ts +0 -130
- package/src/fixtures/capture.ts +0 -364
- package/src/harnesses/antigravity/AntigravityAgentMapper.ts +0 -34
- package/src/harnesses/antigravity/AntigravityCliAdapter.ts +0 -126
- package/src/harnesses/antigravity/AntigravitySessionLocator.ts +0 -75
- package/src/harnesses/antigravity/AntigravitySessionParser.ts +0 -252
- package/src/harnesses/claude/ClaudeAgentMapper.ts +0 -55
- package/src/harnesses/claude/ClaudeCodeAdapter.ts +0 -175
- package/src/harnesses/claude/ClaudeSessionLocator.ts +0 -358
- package/src/harnesses/claude/ClaudeSessionParser.ts +0 -524
- package/src/harnesses/claude/credentials.ts +0 -122
- package/src/harnesses/claude/durable/ClaudeCliProbe.ts +0 -57
- package/src/harnesses/claude/durable/ClaudePrintAgentService.ts +0 -79
- package/src/harnesses/claude/durable/ClaudePrintRunner.ts +0 -102
- package/src/harnesses/claude/durable/ClaudeStreamParser.ts +0 -108
- package/src/harnesses/claude/readiness.ts +0 -69
- package/src/harnesses/codex/CodexAdapter.ts +0 -337
- package/src/harnesses/codex/CodexAgentMapper.ts +0 -26
- package/src/harnesses/codex/CodexSessionLocator.ts +0 -509
- package/src/harnesses/codex/CodexSessionMapping.ts +0 -89
- package/src/harnesses/codex/CodexSessionParser.ts +0 -462
- package/src/harnesses/codex/credentials.ts +0 -81
- package/src/harnesses/codex/durable/CodexCliProbe.ts +0 -68
- package/src/harnesses/codex/durable/CodexPrintAgentService.ts +0 -79
- package/src/harnesses/codex/durable/CodexPrintRunner.ts +0 -104
- package/src/harnesses/codex/durable/CodexStreamParser.ts +0 -117
- package/src/harnesses/codex/readiness.ts +0 -72
- package/src/harnesses/copilot/CopilotAdapter.ts +0 -161
- package/src/harnesses/copilot/CopilotAgentMapper.ts +0 -27
- package/src/harnesses/copilot/CopilotSessionLocator.ts +0 -161
- package/src/harnesses/copilot/CopilotSessionParser.ts +0 -380
- package/src/harnesses/copilot/readiness.ts +0 -33
- package/src/harnesses/devin/DevinAdapter.ts +0 -212
- package/src/harnesses/devin/DevinAgentMapper.ts +0 -39
- package/src/harnesses/devin/DevinSessionLocator.ts +0 -230
- package/src/harnesses/devin/DevinSessionParser.ts +0 -227
- package/src/harnesses/devin/credentials.ts +0 -88
- package/src/harnesses/devin/readiness.ts +0 -36
- package/src/harnesses/gemini/GeminiAgentMapper.ts +0 -27
- package/src/harnesses/gemini/GeminiCliAdapter.ts +0 -272
- package/src/harnesses/gemini/GeminiSessionLocator.ts +0 -394
- package/src/harnesses/gemini/GeminiSessionParser.ts +0 -395
- package/src/harnesses/gemini/fileSignature.ts +0 -10
- package/src/harnesses/grok/GrokAgentMapper.ts +0 -32
- package/src/harnesses/grok/GrokCliAdapter.ts +0 -126
- package/src/harnesses/grok/GrokSessionLocator.ts +0 -179
- package/src/harnesses/grok/GrokSessionParser.ts +0 -251
- package/src/harnesses/index.ts +0 -32
- package/src/harnesses/kiro/KiroAdapter.ts +0 -143
- package/src/harnesses/kiro/KiroAgentMapper.ts +0 -34
- package/src/harnesses/kiro/KiroSessionLocator.ts +0 -143
- package/src/harnesses/kiro/KiroSessionParser.ts +0 -376
- package/src/harnesses/muse/MuseAdapter.ts +0 -157
- package/src/harnesses/muse/MuseAgentMapper.ts +0 -33
- package/src/harnesses/muse/MuseSessionLocator.ts +0 -286
- package/src/harnesses/muse/MuseSessionParser.ts +0 -435
- package/src/harnesses/muse/readiness.ts +0 -38
- package/src/harnesses/opencode/OpenCodeAdapter.ts +0 -110
- package/src/harnesses/opencode/OpenCodeAgentMapper.ts +0 -49
- package/src/harnesses/opencode/OpenCodeSessionLocator.ts +0 -151
- package/src/harnesses/opencode/OpenCodeSessionParser.ts +0 -146
- package/src/harnesses/opencode/readiness.ts +0 -48
- package/src/harnesses/pi/PiAdapter.ts +0 -197
- package/src/harnesses/pi/PiAgentMapper.ts +0 -27
- package/src/harnesses/pi/PiSessionLocator.ts +0 -288
- package/src/harnesses/pi/PiSessionParser.ts +0 -488
- package/src/harnesses/pi/PiSessionTracker.ts +0 -87
- package/src/harnesses/pi/credentials.ts +0 -129
- package/src/harnesses/pi/durable/PiCliProbe.ts +0 -56
- package/src/harnesses/pi/durable/PiPrintAgentService.ts +0 -77
- package/src/harnesses/pi/durable/PiPrintProtocol.ts +0 -41
- package/src/harnesses/pi/durable/PiPrintRunner.ts +0 -95
- package/src/harnesses/pi/durable/PiStreamParser.ts +0 -94
- package/src/harnesses/pi/readiness.ts +0 -104
- package/src/harnesses/readiness/AgentReadiness.ts +0 -91
- package/src/harnesses/readiness/checks.ts +0 -336
- package/src/harnesses/readiness/types.ts +0 -90
- package/src/harnesses/runtimeProfiles.ts +0 -105
- package/src/harnesses/shared.ts +0 -124
- package/src/index.ts +0 -71
- package/src/runtime/ManagedAgentRuntime.ts +0 -253
- package/src/runtime/RuntimeFactory.ts +0 -13
- package/src/runtime/errors.ts +0 -50
- package/src/runtime/herdr/HerdrAgentDiscovery.ts +0 -166
- package/src/runtime/herdr/HerdrAgentRuntime.ts +0 -216
- package/src/runtime/herdr/HerdrCliClient.ts +0 -78
- package/src/runtime/herdr/HerdrErrors.ts +0 -9
- package/src/runtime/herdr/HerdrResponseParsers.ts +0 -86
- package/src/runtime/herdr/HerdrRuntimeRef.ts +0 -41
- package/src/runtime/tmux/PidPolling.ts +0 -34
- package/src/runtime/tmux/TmuxAgentRuntime.ts +0 -113
- package/src/runtime/tmux/TmuxManager.ts +0 -102
- package/src/runtime/tmux/TmuxRuntimeRef.ts +0 -9
- package/src/runtime/types.ts +0 -56
- package/src/terminal/TerminalFocusManager.ts +0 -52
- package/src/terminal/TtyWriter.ts +0 -26
- package/src/terminal/backends/ghostty.ts +0 -180
- package/src/terminal/backends/index.ts +0 -23
- package/src/terminal/backends/iterm2.ts +0 -126
- package/src/terminal/backends/shared.ts +0 -47
- package/src/terminal/backends/terminal-app.ts +0 -122
- package/src/terminal/backends/tmux.ts +0 -62
- package/src/terminal/backends/wezterm.ts +0 -65
- package/src/terminal/types.ts +0 -23
- package/src/utils/AgentRegistry.ts +0 -351
- package/src/utils/IncrementalJsonlSummary.ts +0 -306
- package/src/utils/agent-requests.ts +0 -28
- package/src/utils/applescript.ts +0 -10
- package/src/utils/jsonlTail.ts +0 -349
- package/src/utils/matching.ts +0 -96
- package/src/utils/matchingConstants.ts +0 -15
- package/src/utils/process.ts +0 -604
- package/src/utils/session.ts +0 -144
- package/src/utils/sortAgents.ts +0 -54
- package/tsconfig.json +0 -11
- package/vitest.config.ts +0 -20
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import * as path from "path";
|
|
2
|
-
import type { ProcessInfo } from "../../adapters/AgentAdapter.js";
|
|
3
|
-
import {
|
|
4
|
-
isDirectory,
|
|
5
|
-
isSafePathSegment,
|
|
6
|
-
safeReadFile,
|
|
7
|
-
safeReaddir,
|
|
8
|
-
safeStat,
|
|
9
|
-
} from "../../utils/session.js";
|
|
10
|
-
import { homeDir } from "../shared.js";
|
|
11
|
-
import { asRecord, type KiroSessionPaths } from "./KiroSessionParser.js";
|
|
12
|
-
|
|
13
|
-
/** A live Kiro process and the session whose lock it holds. */
|
|
14
|
-
export interface KiroProcessMatch {
|
|
15
|
-
process: ProcessInfo;
|
|
16
|
-
session: KiroSessionPaths;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface KiroSessionLocatorOptions {
|
|
20
|
-
/** Overrides ~/.kiro/sessions/cli. */
|
|
21
|
-
sessionsDir?: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
interface KiroLock {
|
|
25
|
-
sessionId: string;
|
|
26
|
-
pid: number;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export class KiroSessionLocator {
|
|
30
|
-
private readonly sessionsDir: string;
|
|
31
|
-
|
|
32
|
-
constructor(options: KiroSessionLocatorOptions = {}) {
|
|
33
|
-
this.sessionsDir = options.sessionsDir ?? path.join(homeDir(), ".kiro", "sessions", "cli");
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Pair `<session-id>.lock` files with running Kiro processes.
|
|
38
|
-
*
|
|
39
|
-
* @param snapshot every process collected for Kiro's process names, used to
|
|
40
|
-
* walk up from the lock's PID (often a `kiro-cli-chat acp` helper)
|
|
41
|
-
* @param kiroProcesses the top-level Kiro processes that become agents
|
|
42
|
-
* @param isKiro whether a process is a top-level Kiro process
|
|
43
|
-
*/
|
|
44
|
-
matchRunningProcesses(
|
|
45
|
-
snapshot: readonly ProcessInfo[],
|
|
46
|
-
kiroProcesses: readonly ProcessInfo[],
|
|
47
|
-
isKiro: (process: ProcessInfo) => boolean,
|
|
48
|
-
): KiroProcessMatch[] {
|
|
49
|
-
const byPid = new Map(snapshot.map((proc) => [proc.pid, proc]));
|
|
50
|
-
const matches: KiroProcessMatch[] = [];
|
|
51
|
-
|
|
52
|
-
for (const lock of this.discoverActiveLocks()) {
|
|
53
|
-
const proc =
|
|
54
|
-
this.findKiroAncestor(lock.pid, byPid, isKiro) ??
|
|
55
|
-
this.matchSoleProcessOnTty(byPid.get(lock.pid)?.tty, kiroProcesses);
|
|
56
|
-
if (proc) matches.push({ process: proc, session: this.sessionPaths(lock.sessionId) });
|
|
57
|
-
}
|
|
58
|
-
return matches;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** Every session with a transcript under the sessions dir. */
|
|
62
|
-
listSessions(): KiroSessionPaths[] {
|
|
63
|
-
if (!isDirectory(this.sessionsDir)) return [];
|
|
64
|
-
|
|
65
|
-
return safeReaddir(this.sessionsDir)
|
|
66
|
-
.filter((entry) => entry.endsWith(".jsonl"))
|
|
67
|
-
.map((entry) => this.sessionPaths(entry.slice(0, -".jsonl".length)));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/** The session stored as `<sessionId>.jsonl`, if it exists. */
|
|
71
|
-
findSession(sessionId: string): KiroSessionPaths | null {
|
|
72
|
-
if (!isSafePathSegment(sessionId)) return null;
|
|
73
|
-
const paths = this.sessionPaths(sessionId);
|
|
74
|
-
return safeStat(paths.transcriptPath)?.isFile() ? paths : null;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
private sessionPaths(sessionId: string): KiroSessionPaths {
|
|
78
|
-
return {
|
|
79
|
-
sessionId,
|
|
80
|
-
transcriptPath: path.join(this.sessionsDir, `${sessionId}.jsonl`),
|
|
81
|
-
metadataPath: path.join(this.sessionsDir, `${sessionId}.json`),
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
private discoverActiveLocks(): KiroLock[] {
|
|
86
|
-
if (!isDirectory(this.sessionsDir)) return [];
|
|
87
|
-
|
|
88
|
-
const locks: KiroLock[] = [];
|
|
89
|
-
for (const entry of safeReaddir(this.sessionsDir)) {
|
|
90
|
-
if (!entry.endsWith(".lock")) continue;
|
|
91
|
-
|
|
92
|
-
const content = safeReadFile(path.join(this.sessionsDir, entry));
|
|
93
|
-
if (content === undefined) continue;
|
|
94
|
-
|
|
95
|
-
let pid: number | null;
|
|
96
|
-
try {
|
|
97
|
-
pid = toPid(asRecord(JSON.parse(content))?.pid);
|
|
98
|
-
} catch {
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
if (pid !== null) locks.push({ sessionId: entry.slice(0, -".lock".length), pid });
|
|
102
|
-
}
|
|
103
|
-
return locks;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/** The outermost Kiro process on the lock PID's parent chain, if collected. */
|
|
107
|
-
private findKiroAncestor(
|
|
108
|
-
lockPid: number,
|
|
109
|
-
byPid: Map<number, ProcessInfo>,
|
|
110
|
-
isKiro: (process: ProcessInfo) => boolean,
|
|
111
|
-
): ProcessInfo | null {
|
|
112
|
-
let current = byPid.get(lockPid);
|
|
113
|
-
const seen = new Set<number>();
|
|
114
|
-
let resolved: ProcessInfo | null = null;
|
|
115
|
-
|
|
116
|
-
while (current && !seen.has(current.pid)) {
|
|
117
|
-
seen.add(current.pid);
|
|
118
|
-
if (isKiro(current)) resolved = current;
|
|
119
|
-
current = current.ppid === undefined ? undefined : byPid.get(current.ppid);
|
|
120
|
-
}
|
|
121
|
-
return resolved;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Fallback when the chain is broken (an uncollected intermediate process):
|
|
126
|
-
* attach to the only Kiro process on the lock holder's terminal.
|
|
127
|
-
*/
|
|
128
|
-
private matchSoleProcessOnTty(
|
|
129
|
-
tty: string | undefined,
|
|
130
|
-
kiroProcesses: readonly ProcessInfo[],
|
|
131
|
-
): ProcessInfo | null {
|
|
132
|
-
if (!tty || tty === "??" || tty === "?") return null;
|
|
133
|
-
const matches = kiroProcesses.filter((proc) => proc.tty === tty);
|
|
134
|
-
return matches.length === 1 ? matches[0] : null;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function toPid(value: unknown): number | null {
|
|
139
|
-
if (typeof value === "number" && Number.isSafeInteger(value) && value > 0) return value;
|
|
140
|
-
if (typeof value !== "string" || !/^\d+$/.test(value)) return null;
|
|
141
|
-
const parsed = Number(value);
|
|
142
|
-
return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : null;
|
|
143
|
-
}
|
|
@@ -1,376 +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 { isIdle, parseTimestamp } from "../shared.js";
|
|
12
|
-
|
|
13
|
-
type KiroRecord = Record<string, unknown>;
|
|
14
|
-
|
|
15
|
-
/** One line of <session-id>.jsonl. */
|
|
16
|
-
interface KiroLine {
|
|
17
|
-
kind?: string;
|
|
18
|
-
timestamp?: string;
|
|
19
|
-
data?: KiroRecord;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** The sibling <session-id>.json metadata file. */
|
|
23
|
-
interface KiroMetadata {
|
|
24
|
-
sessionId: string;
|
|
25
|
-
cwd: string;
|
|
26
|
-
title: string;
|
|
27
|
-
createdAt: Date | null;
|
|
28
|
-
updatedAt: Date | null;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** O(1) running summary folded from transcript lines, never the entries themselves. */
|
|
32
|
-
interface KiroSummaryState {
|
|
33
|
-
/** A bounded cold start skipped the middle: later lines are not the session's first. */
|
|
34
|
-
pastHead?: boolean;
|
|
35
|
-
firstUserMessage?: string;
|
|
36
|
-
lastUserMessage?: string;
|
|
37
|
-
/** First and last entry timestamps in file order, in epoch ms. */
|
|
38
|
-
firstTimestampMs?: number;
|
|
39
|
-
lastTimestampMs?: number;
|
|
40
|
-
lastEventKind?: string;
|
|
41
|
-
lastAssistantHasToolUse?: boolean;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface KiroSessionParserOptions {
|
|
45
|
-
/** Cold-start scan bounds for `readSessionIncremental` (see IncrementalJsonlSummary). */
|
|
46
|
-
summaryBounds?: JsonlSummaryBounds | false;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface KiroSessionPaths {
|
|
50
|
-
sessionId: string;
|
|
51
|
-
transcriptPath: string;
|
|
52
|
-
metadataPath: string;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface KiroSession {
|
|
56
|
-
sessionId: string;
|
|
57
|
-
projectPath: string;
|
|
58
|
-
sessionFilePath: string;
|
|
59
|
-
title: string;
|
|
60
|
-
firstUserMessage: string;
|
|
61
|
-
lastUserMessage?: string;
|
|
62
|
-
sessionStart: Date;
|
|
63
|
-
lastActive: Date;
|
|
64
|
-
lastEventKind?: string;
|
|
65
|
-
lastAssistantHasToolUse: boolean;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export class KiroSessionParser {
|
|
69
|
-
/** Incremental reader backing `getConversation({ tail })`. */
|
|
70
|
-
private readonly tailReader = new JsonlTailReader();
|
|
71
|
-
|
|
72
|
-
private readonly sessionCache: IncrementalJsonlSummary<KiroSummaryState>;
|
|
73
|
-
|
|
74
|
-
constructor(options: KiroSessionParserOptions = {}) {
|
|
75
|
-
this.sessionCache = new IncrementalJsonlSummary(this.summaryReducer, {
|
|
76
|
-
bounds: options.summaryBounds,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Parse a session from its transcript and metadata. Metadata wins for the
|
|
82
|
-
* session id, cwd and timestamps; `fallbackCwd` is used when it has no cwd.
|
|
83
|
-
* Returns null when the transcript is missing.
|
|
84
|
-
*/
|
|
85
|
-
readSession(paths: KiroSessionPaths, fallbackCwd = ""): KiroSession | null {
|
|
86
|
-
const stat = safeStat(paths.transcriptPath);
|
|
87
|
-
if (!stat?.isFile()) return null;
|
|
88
|
-
|
|
89
|
-
const content = safeReadFile(paths.transcriptPath);
|
|
90
|
-
const state = content === undefined ? {} : reduceJsonlContent(this.summaryReducer, content);
|
|
91
|
-
return this.toSession(paths, fallbackCwd, stat, state);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Same result as `readSession`, but the transcript summary is backed by a
|
|
96
|
-
* per-instance incremental cache, so repeated refreshes only parse bytes
|
|
97
|
-
* appended since the last call. The small metadata file is still read each
|
|
98
|
-
* time. Call `pruneSessionCache()` once per refresh.
|
|
99
|
-
*/
|
|
100
|
-
readSessionIncremental(paths: KiroSessionPaths, fallbackCwd = ""): KiroSession | null {
|
|
101
|
-
const stat = safeStat(paths.transcriptPath);
|
|
102
|
-
if (!stat?.isFile()) return null;
|
|
103
|
-
|
|
104
|
-
// Present but unreadable: surface the session without a summary, like readSession.
|
|
105
|
-
const state = this.sessionCache.read(paths.transcriptPath)?.state ?? {};
|
|
106
|
-
return this.toSession(paths, fallbackCwd, stat, state);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/** Evict cached summaries for files not read since the previous prune. */
|
|
110
|
-
pruneSessionCache(): void {
|
|
111
|
-
this.sessionCache.prune();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
getConversation(transcriptPath: string, options?: ConversationOptions): ConversationMessage[] {
|
|
115
|
-
const verbose = options?.verbose ?? false;
|
|
116
|
-
const tail = normalizeTail(options?.tail);
|
|
117
|
-
if (tail === undefined) {
|
|
118
|
-
return this.entriesToMessages(this.readJsonl(transcriptPath), verbose);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return this.tailReader.read(
|
|
122
|
-
transcriptPath,
|
|
123
|
-
tail,
|
|
124
|
-
{
|
|
125
|
-
parseLine: (line) => {
|
|
126
|
-
const entry = this.parseJsonlLine(line);
|
|
127
|
-
return entry ? this.entryToMessage(entry, verbose) : null;
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
String(verbose),
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* - last event is an assistant reply without a tool call → WAITING
|
|
136
|
-
* - past the idle threshold → IDLE
|
|
137
|
-
* - otherwise (user prompt, tool call or tool result) → RUNNING
|
|
138
|
-
*/
|
|
139
|
-
determineStatus(session: KiroSession): AgentStatus {
|
|
140
|
-
if (session.lastEventKind === "AssistantMessage" && !session.lastAssistantHasToolUse) {
|
|
141
|
-
return AgentStatus.WAITING;
|
|
142
|
-
}
|
|
143
|
-
if (isIdle(session.lastActive)) return AgentStatus.IDLE;
|
|
144
|
-
return AgentStatus.RUNNING;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Fold one transcript line into the O(1) summary. Uses the same entry rules
|
|
149
|
-
* as `getConversation` (see `entryToMessage`); non-object lines are ignored.
|
|
150
|
-
*
|
|
151
|
-
* `skip` (bounded cold start) keeps the head's first prompt and timestamp and
|
|
152
|
-
* resets the latest fields, so those come from the tail only.
|
|
153
|
-
*/
|
|
154
|
-
private readonly summaryReducer: JsonlSummaryReducer<KiroSummaryState> = {
|
|
155
|
-
initial: () => ({}),
|
|
156
|
-
reduce: (state, value) => {
|
|
157
|
-
const entry = asRecord(value) as KiroLine | null;
|
|
158
|
-
if (!entry) return state;
|
|
159
|
-
|
|
160
|
-
const next: KiroSummaryState = {
|
|
161
|
-
...state,
|
|
162
|
-
lastEventKind: entry.kind,
|
|
163
|
-
lastAssistantHasToolUse:
|
|
164
|
-
entry.kind === "AssistantMessage" && this.hasContentKind(entry, "toolUse"),
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
const timestampMs = parseTimestamp(this.entryTimestamp(entry))?.getTime();
|
|
168
|
-
if (timestampMs !== undefined) {
|
|
169
|
-
next.lastTimestampMs = timestampMs;
|
|
170
|
-
if (next.firstTimestampMs === undefined && !next.pastHead) {
|
|
171
|
-
next.firstTimestampMs = timestampMs;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const message = this.entryToMessage(entry, false);
|
|
176
|
-
if (message?.role === "user") {
|
|
177
|
-
next.lastUserMessage = message.content;
|
|
178
|
-
if (next.firstUserMessage === undefined && !next.pastHead) {
|
|
179
|
-
next.firstUserMessage = message.content;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return next;
|
|
183
|
-
},
|
|
184
|
-
skip: (state) => ({
|
|
185
|
-
pastHead: true,
|
|
186
|
-
firstUserMessage: state.firstUserMessage,
|
|
187
|
-
firstTimestampMs: state.firstTimestampMs,
|
|
188
|
-
}),
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
private toSession(
|
|
192
|
-
paths: KiroSessionPaths,
|
|
193
|
-
fallbackCwd: string,
|
|
194
|
-
stat: { birthtime: Date; mtime: Date },
|
|
195
|
-
state: KiroSummaryState,
|
|
196
|
-
): KiroSession {
|
|
197
|
-
const metadata = this.readMetadata(paths);
|
|
198
|
-
const firstTimestamp =
|
|
199
|
-
state.firstTimestampMs === undefined ? undefined : new Date(state.firstTimestampMs);
|
|
200
|
-
const lastTimestamp =
|
|
201
|
-
state.lastTimestampMs === undefined ? undefined : new Date(state.lastTimestampMs);
|
|
202
|
-
|
|
203
|
-
return {
|
|
204
|
-
sessionId: metadata.sessionId,
|
|
205
|
-
projectPath: metadata.cwd || fallbackCwd,
|
|
206
|
-
sessionFilePath: paths.transcriptPath,
|
|
207
|
-
title: metadata.title,
|
|
208
|
-
firstUserMessage: state.firstUserMessage ?? "",
|
|
209
|
-
lastUserMessage: state.lastUserMessage,
|
|
210
|
-
sessionStart: metadata.createdAt ?? firstTimestamp ?? stat.birthtime,
|
|
211
|
-
lastActive: metadata.updatedAt ?? lastTimestamp ?? stat.mtime,
|
|
212
|
-
lastEventKind: state.lastEventKind,
|
|
213
|
-
lastAssistantHasToolUse: state.lastAssistantHasToolUse ?? false,
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
private readMetadata({ sessionId, metadataPath }: KiroSessionPaths): KiroMetadata {
|
|
218
|
-
const empty: KiroMetadata = {
|
|
219
|
-
sessionId,
|
|
220
|
-
cwd: "",
|
|
221
|
-
title: "",
|
|
222
|
-
createdAt: null,
|
|
223
|
-
updatedAt: null,
|
|
224
|
-
};
|
|
225
|
-
const content = safeReadFile(metadataPath);
|
|
226
|
-
if (content === undefined) return empty;
|
|
227
|
-
|
|
228
|
-
let parsed: KiroRecord | null;
|
|
229
|
-
try {
|
|
230
|
-
parsed = asRecord(JSON.parse(content));
|
|
231
|
-
} catch {
|
|
232
|
-
return empty;
|
|
233
|
-
}
|
|
234
|
-
if (!parsed) return empty;
|
|
235
|
-
|
|
236
|
-
return {
|
|
237
|
-
sessionId: firstString(parsed.session_id, parsed.sessionId) ?? sessionId,
|
|
238
|
-
cwd: firstString(parsed.cwd) ?? "",
|
|
239
|
-
title: firstString(parsed.title) ?? "",
|
|
240
|
-
createdAt: parseTimestamp(parsed.created_at ?? parsed.createdAt),
|
|
241
|
-
updatedAt: parseTimestamp(parsed.updated_at ?? parsed.updatedAt),
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
private readJsonl(filePath: string): KiroLine[] {
|
|
246
|
-
const content = safeReadFile(filePath);
|
|
247
|
-
if (content === undefined) return [];
|
|
248
|
-
|
|
249
|
-
const entries: KiroLine[] = [];
|
|
250
|
-
for (const line of content.split(/\r?\n/)) {
|
|
251
|
-
const entry = this.parseJsonlLine(line);
|
|
252
|
-
if (entry) entries.push(entry);
|
|
253
|
-
}
|
|
254
|
-
return entries;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
private parseJsonlLine(line: string): KiroLine | null {
|
|
258
|
-
const trimmed = line.trim();
|
|
259
|
-
if (!trimmed) return null;
|
|
260
|
-
try {
|
|
261
|
-
return asRecord(JSON.parse(trimmed)) as KiroLine | null;
|
|
262
|
-
} catch {
|
|
263
|
-
return null;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
private entriesToMessages(entries: KiroLine[], verbose: boolean): ConversationMessage[] {
|
|
268
|
-
const messages: ConversationMessage[] = [];
|
|
269
|
-
for (const entry of entries) {
|
|
270
|
-
const message = this.entryToMessage(entry, verbose);
|
|
271
|
-
if (message) messages.push(message);
|
|
272
|
-
}
|
|
273
|
-
return messages;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Prompt → user, AssistantMessage → assistant (tool calls appended in
|
|
278
|
-
* verbose mode), ToolResults → system (verbose only).
|
|
279
|
-
*/
|
|
280
|
-
private entryToMessage(entry: KiroLine, verbose: boolean): ConversationMessage | null {
|
|
281
|
-
let role: ConversationMessage["role"];
|
|
282
|
-
let content: string;
|
|
283
|
-
|
|
284
|
-
if (entry.kind === "Prompt") {
|
|
285
|
-
role = "user";
|
|
286
|
-
content = this.textContent(entry);
|
|
287
|
-
} else if (entry.kind === "AssistantMessage") {
|
|
288
|
-
role = "assistant";
|
|
289
|
-
const parts = [this.textContent(entry)];
|
|
290
|
-
if (verbose) parts.push(...this.toolUseContent(entry));
|
|
291
|
-
content = parts.filter(Boolean).join("\n");
|
|
292
|
-
} else if (entry.kind === "ToolResults" && verbose) {
|
|
293
|
-
role = "system";
|
|
294
|
-
content = this.toolResultContent(entry).join("\n");
|
|
295
|
-
} else {
|
|
296
|
-
return null;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
if (!content) return null;
|
|
300
|
-
return {
|
|
301
|
-
role,
|
|
302
|
-
content,
|
|
303
|
-
timestamp: this.entryTimestamp(entry),
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
private textContent(entry: KiroLine): string {
|
|
308
|
-
return this.contentBlocks(entry)
|
|
309
|
-
.filter((block) => block.kind === "text")
|
|
310
|
-
.map((block) => (typeof block.data === "string" ? block.data : ""))
|
|
311
|
-
.filter(Boolean)
|
|
312
|
-
.join("");
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
private toolUseContent(entry: KiroLine): string[] {
|
|
316
|
-
return this.contentBlocks(entry)
|
|
317
|
-
.filter((block) => block.kind === "toolUse")
|
|
318
|
-
.map((block) => {
|
|
319
|
-
const data = asRecord(block.data);
|
|
320
|
-
const name = firstString(data?.name) ?? "unknown";
|
|
321
|
-
const input = formatValue(data?.input);
|
|
322
|
-
return `[Tool: ${name}]${input ? ` ${input}` : ""}`;
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
private toolResultContent(entry: KiroLine): string[] {
|
|
327
|
-
return this.contentBlocks(entry)
|
|
328
|
-
.filter((block) => block.kind === "toolResult")
|
|
329
|
-
.map((block) => {
|
|
330
|
-
const data = asRecord(block.data);
|
|
331
|
-
const prefix = data?.status === "error" ? "[Tool Error]" : "[Tool Result]";
|
|
332
|
-
const result = formatValue(data?.result ?? data?.results ?? data?.content);
|
|
333
|
-
return `${prefix}${result ? ` ${result}` : ""}`;
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
private contentBlocks(entry: KiroLine): Array<{ kind?: string; data?: unknown }> {
|
|
338
|
-
const content = entry.data?.content;
|
|
339
|
-
if (!Array.isArray(content)) return [];
|
|
340
|
-
return content
|
|
341
|
-
.map((block) => asRecord(block))
|
|
342
|
-
.filter((block): block is KiroRecord => block !== null);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
private hasContentKind(entry: KiroLine, kind: string): boolean {
|
|
346
|
-
return this.contentBlocks(entry).some((block) => block.kind === kind);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
/** The line's own timestamp, else `data.meta.timestamp` (epoch seconds/ms or ISO). */
|
|
350
|
-
private entryTimestamp(entry: KiroLine): string | undefined {
|
|
351
|
-
const direct = firstString(entry.timestamp);
|
|
352
|
-
if (direct) return direct;
|
|
353
|
-
|
|
354
|
-
const meta = asRecord(entry.data?.meta);
|
|
355
|
-
return parseTimestamp(meta?.timestamp)?.toISOString();
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
export function asRecord(value: unknown): KiroRecord | null {
|
|
360
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
361
|
-
return value as KiroRecord;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
function firstString(...values: unknown[]): string | undefined {
|
|
365
|
-
return values.find((value): value is string => typeof value === "string" && value.length > 0);
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
function formatValue(value: unknown): string {
|
|
369
|
-
if (typeof value === "string") return value;
|
|
370
|
-
if (value === undefined || value === null) return "";
|
|
371
|
-
try {
|
|
372
|
-
return JSON.stringify(value);
|
|
373
|
-
} catch {
|
|
374
|
-
return "";
|
|
375
|
-
}
|
|
376
|
-
}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import * as path from "path";
|
|
2
|
-
import type {
|
|
3
|
-
AgentAdapter,
|
|
4
|
-
AgentDetectionContext,
|
|
5
|
-
AgentInfo,
|
|
6
|
-
ConversationMessage,
|
|
7
|
-
ConversationOptions,
|
|
8
|
-
ListSessionsOptions,
|
|
9
|
-
ProcessInfo,
|
|
10
|
-
SessionSummary,
|
|
11
|
-
} from "../../adapters/AgentAdapter.js";
|
|
12
|
-
import { safeStat } from "../../utils/session.js";
|
|
13
|
-
import { MuseAgentMapper } from "./MuseAgentMapper.js";
|
|
14
|
-
import { MuseSessionLocator } from "./MuseSessionLocator.js";
|
|
15
|
-
import { MuseSessionParser } from "./MuseSessionParser.js";
|
|
16
|
-
import { findHarnessProcesses, homeDir } from "../shared.js";
|
|
17
|
-
|
|
18
|
-
export interface MuseAdapterOptions {
|
|
19
|
-
homeDir?: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Muse (Meta Muse Code) adapter.
|
|
24
|
-
*
|
|
25
|
-
* Detection joins two sources:
|
|
26
|
-
* 1. Live runtime entries (`~/.local/share/muse/runtime/muse/sessions/<id>.json`)
|
|
27
|
-
* matched to processes by `process_generation_hint: "pid=<n>"`.
|
|
28
|
-
* 2. The dated transcript archive (`sessions/yyyy/mm/dd/<uuid>/session.jsonl`).
|
|
29
|
-
*
|
|
30
|
-
* The launcher binary is versioned (`muse-bin-<version>-<build>`), so discovery
|
|
31
|
-
* uses `processNamePrefixes`; `canHandle` keeps the precise shape check.
|
|
32
|
-
*/
|
|
33
|
-
export class MuseAdapter implements AgentAdapter {
|
|
34
|
-
readonly type = "muse" as const;
|
|
35
|
-
readonly processNames = ["muse"] as const;
|
|
36
|
-
readonly processNamePrefixes = ["muse"] as const;
|
|
37
|
-
|
|
38
|
-
private readonly home: string;
|
|
39
|
-
private readonly parser: MuseSessionParser;
|
|
40
|
-
private readonly mapper: MuseAgentMapper;
|
|
41
|
-
|
|
42
|
-
constructor(options: MuseAdapterOptions = {}) {
|
|
43
|
-
this.home = options.homeDir ?? homeDir();
|
|
44
|
-
this.parser = new MuseSessionParser();
|
|
45
|
-
this.mapper = new MuseAgentMapper(this.parser);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
canHandle(processInfo: ProcessInfo): boolean {
|
|
49
|
-
const base = path.basename(processInfo.command.trim().split(/\s+/)[0] ?? "").toLowerCase();
|
|
50
|
-
return base === "muse" || base === "muse.exe" || base.startsWith("muse-bin-");
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async detectAgents(context?: AgentDetectionContext): Promise<AgentInfo[]> {
|
|
54
|
-
try {
|
|
55
|
-
return await this.detectRunningAgents(context);
|
|
56
|
-
} finally {
|
|
57
|
-
this.parser.pruneSessionCache();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
private async detectRunningAgents(context?: AgentDetectionContext): Promise<AgentInfo[]> {
|
|
62
|
-
const { processes } = await findHarnessProcesses(this, context);
|
|
63
|
-
if (processes.length === 0) return [];
|
|
64
|
-
|
|
65
|
-
const { direct, legacyMatches } = this.createLocator().matchRunningProcesses(processes);
|
|
66
|
-
const matchedPids = new Set([
|
|
67
|
-
...direct.map((d) => d.process.pid),
|
|
68
|
-
...legacyMatches.map((m) => m.process.pid),
|
|
69
|
-
]);
|
|
70
|
-
const agents: AgentInfo[] = [];
|
|
71
|
-
|
|
72
|
-
for (const match of direct) {
|
|
73
|
-
const sessionData = this.parser.readSessionIncremental(
|
|
74
|
-
match.sessionFile.filePath,
|
|
75
|
-
match.sessionFile.resolvedCwd,
|
|
76
|
-
);
|
|
77
|
-
if (sessionData) {
|
|
78
|
-
agents.push(
|
|
79
|
-
this.mapper.mapSessionToAgent({
|
|
80
|
-
session: sessionData,
|
|
81
|
-
processInfo: match.process,
|
|
82
|
-
sessionFile: match.sessionFile,
|
|
83
|
-
}),
|
|
84
|
-
);
|
|
85
|
-
} else {
|
|
86
|
-
matchedPids.delete(match.process.pid);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
for (const match of legacyMatches) {
|
|
91
|
-
const sessionData = this.parser.readSessionIncremental(
|
|
92
|
-
match.session.filePath,
|
|
93
|
-
match.session.resolvedCwd,
|
|
94
|
-
);
|
|
95
|
-
if (sessionData) {
|
|
96
|
-
agents.push(
|
|
97
|
-
this.mapper.mapSessionToAgent({
|
|
98
|
-
session: sessionData,
|
|
99
|
-
processInfo: match.process,
|
|
100
|
-
sessionFile: match.session,
|
|
101
|
-
}),
|
|
102
|
-
);
|
|
103
|
-
} else {
|
|
104
|
-
matchedPids.delete(match.process.pid);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
for (const proc of processes) {
|
|
109
|
-
if (!matchedPids.has(proc.pid)) {
|
|
110
|
-
agents.push(this.mapper.mapProcessOnlyAgent(proc));
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return agents;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
private createLocator(): MuseSessionLocator {
|
|
117
|
-
return new MuseSessionLocator({ homeDir: this.home });
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
getConversation(sessionFilePath: string, options?: ConversationOptions): ConversationMessage[] {
|
|
121
|
-
return this.parser.getConversation(sessionFilePath, options);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
async listSessions(opts?: ListSessionsOptions): Promise<SessionSummary[]> {
|
|
125
|
-
const filterCwd = opts?.cwd;
|
|
126
|
-
const summaries: SessionSummary[] = [];
|
|
127
|
-
for (const { filePath, defaultCwd } of this.createLocator().discoverHistoricalSessionFiles()) {
|
|
128
|
-
const summary = this.toSessionSummary(filePath, defaultCwd);
|
|
129
|
-
if (!summary) continue;
|
|
130
|
-
if (filterCwd !== undefined && summary.cwd !== filterCwd) continue;
|
|
131
|
-
summaries.push(summary);
|
|
132
|
-
}
|
|
133
|
-
return summaries;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
async findSessionsById(sessionId: string): Promise<SessionSummary[]> {
|
|
137
|
-
return this.createLocator()
|
|
138
|
-
.findHistoricalSessionFilesById(sessionId)
|
|
139
|
-
.map(({ filePath, defaultCwd }) => this.toSessionSummary(filePath, defaultCwd))
|
|
140
|
-
.filter((summary): summary is SessionSummary => summary?.sessionId === sessionId);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
private toSessionSummary(filePath: string, defaultCwd: string): SessionSummary | null {
|
|
144
|
-
const session = this.parser.readSession(filePath, defaultCwd);
|
|
145
|
-
if (!session?.lastSignal && !session?.firstUserMessage) return null;
|
|
146
|
-
const stat = safeStat(filePath);
|
|
147
|
-
return {
|
|
148
|
-
type: "muse",
|
|
149
|
-
sessionId: session.sessionId,
|
|
150
|
-
cwd: session.projectPath || defaultCwd,
|
|
151
|
-
firstUserMessage: session.firstUserMessage || "",
|
|
152
|
-
lastActive: session.lastActive ?? stat?.mtime ?? new Date(),
|
|
153
|
-
startedAt: session.sessionStart ?? stat?.birthtime ?? stat?.mtime ?? new Date(),
|
|
154
|
-
sessionFilePath: filePath,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { AgentInfo, ProcessInfo } from "../../adapters/AgentAdapter.js";
|
|
2
|
-
import { generateAgentName } from "../../utils/matching.js";
|
|
3
|
-
import type { SessionFile } from "../../utils/session.js";
|
|
4
|
-
import { MuseSessionParser, type MuseSession } from "./MuseSessionParser.js";
|
|
5
|
-
import { processOnlyAgent } from "../shared.js";
|
|
6
|
-
|
|
7
|
-
export interface MuseSessionAgentInput {
|
|
8
|
-
session: MuseSession;
|
|
9
|
-
processInfo: ProcessInfo;
|
|
10
|
-
sessionFile: SessionFile;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export class MuseAgentMapper {
|
|
14
|
-
constructor(private readonly parser: MuseSessionParser = new MuseSessionParser()) {}
|
|
15
|
-
|
|
16
|
-
mapSessionToAgent({ session, processInfo, sessionFile }: MuseSessionAgentInput): AgentInfo {
|
|
17
|
-
return {
|
|
18
|
-
name: generateAgentName(processInfo.cwd, processInfo.pid),
|
|
19
|
-
type: "muse",
|
|
20
|
-
status: this.parser.determineStatus(session),
|
|
21
|
-
summary: session.lastUserMessage || "Session started",
|
|
22
|
-
pid: processInfo.pid,
|
|
23
|
-
projectPath: session.projectPath || sessionFile.resolvedCwd || processInfo.cwd || "",
|
|
24
|
-
sessionId: sessionFile.sessionId,
|
|
25
|
-
lastActive: session.lastActive,
|
|
26
|
-
sessionFilePath: sessionFile.filePath,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
mapProcessOnlyAgent(processInfo: ProcessInfo): AgentInfo {
|
|
31
|
-
return processOnlyAgent("muse", processInfo, { summary: "Muse process running" });
|
|
32
|
-
}
|
|
33
|
-
}
|