@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,337 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Refresh-path I/O tests for Pi live-session discovery: cost must follow live
|
|
3
|
-
* processes, not the number of historical Pi session files.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import * as fs from "fs";
|
|
7
|
-
import * as os from "os";
|
|
8
|
-
import * as path from "path";
|
|
9
|
-
|
|
10
|
-
import type { ProcessInfo } from "../../../adapters/AgentAdapter.js";
|
|
11
|
-
import { PiAdapter } from "../../../harnesses/pi/PiAdapter.js";
|
|
12
|
-
import { AgentRegistry } from "../../../utils/AgentRegistry.js";
|
|
13
|
-
|
|
14
|
-
vi.mock("fs", async (importOriginal) => {
|
|
15
|
-
const actual = (await importOriginal()) as typeof import("fs");
|
|
16
|
-
return {
|
|
17
|
-
...actual,
|
|
18
|
-
openSync: vi.fn(actual.openSync),
|
|
19
|
-
readSync: vi.fn(actual.readSync),
|
|
20
|
-
readFileSync: vi.fn(actual.readFileSync),
|
|
21
|
-
readdirSync: vi.fn(actual.readdirSync),
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const mockedOpenSync = vi.mocked(fs.openSync);
|
|
26
|
-
const mockedReadSync = vi.mocked(fs.readSync);
|
|
27
|
-
const mockedReadFileSync = vi.mocked(fs.readFileSync);
|
|
28
|
-
const mockedReaddirSync = vi.mocked(fs.readdirSync);
|
|
29
|
-
|
|
30
|
-
const HEAD_LIMIT = 64 * 1024;
|
|
31
|
-
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
32
|
-
|
|
33
|
-
/** Bytes read from `filePath` via readFileSync or fd reads since the last `resetReads()`. */
|
|
34
|
-
function bytesReadFrom(filePath: string): number {
|
|
35
|
-
// fds are reused after close, so attribute each read to the latest open of that fd
|
|
36
|
-
const opens = mockedOpenSync.mock.calls.map((call, index) => ({
|
|
37
|
-
path: String(call[0]),
|
|
38
|
-
fd: mockedOpenSync.mock.results[index]?.value as number,
|
|
39
|
-
order: mockedOpenSync.mock.invocationCallOrder[index],
|
|
40
|
-
}));
|
|
41
|
-
|
|
42
|
-
let total = 0;
|
|
43
|
-
mockedReadSync.mock.calls.forEach((call, index) => {
|
|
44
|
-
const result = mockedReadSync.mock.results[index];
|
|
45
|
-
const order = mockedReadSync.mock.invocationCallOrder[index];
|
|
46
|
-
const open = opens.filter((o) => o.fd === call[0] && o.order < order).at(-1);
|
|
47
|
-
if (result?.type === "return" && open?.path === filePath) {
|
|
48
|
-
total += result.value as number;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
mockedReadFileSync.mock.calls.forEach((call, index) => {
|
|
52
|
-
const result = mockedReadFileSync.mock.results[index];
|
|
53
|
-
if (result?.type === "return" && String(call[0]) === filePath) {
|
|
54
|
-
total += Buffer.byteLength(result.value as string | Buffer);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
return total;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function resetReads(): void {
|
|
61
|
-
mockedOpenSync.mockClear();
|
|
62
|
-
mockedReadSync.mockClear();
|
|
63
|
-
mockedReadFileSync.mockClear();
|
|
64
|
-
mockedReaddirSync.mockClear();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function jsonl(entries: unknown[]): string {
|
|
68
|
-
return entries.map((entry) => `${JSON.stringify(entry)}\n`).join("");
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function encodeProjectDir(cwd: string): string {
|
|
72
|
-
return `--${cwd.replace(/^\//, "").replace(/\//g, "-")}--`;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/** Pi's session file name for a session created at `createdAt`. */
|
|
76
|
-
function sessionFileName(createdAt: Date, sessionId: string): string {
|
|
77
|
-
return `${createdAt.toISOString().replace(/[:.]/g, "-")}_${sessionId}.jsonl`;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
describe("Pi live discovery I/O", () => {
|
|
81
|
-
let originalHome: string | undefined;
|
|
82
|
-
let tmpHome: string;
|
|
83
|
-
let sessionsDir: string;
|
|
84
|
-
let adapter: PiAdapter;
|
|
85
|
-
|
|
86
|
-
beforeEach(() => {
|
|
87
|
-
originalHome = process.env.HOME;
|
|
88
|
-
tmpHome = fs.mkdtempSync(path.join(os.tmpdir(), "pi-discovery-io-"));
|
|
89
|
-
process.env.HOME = tmpHome;
|
|
90
|
-
sessionsDir = path.join(tmpHome, ".pi", "agent", "sessions");
|
|
91
|
-
fs.mkdirSync(sessionsDir, { recursive: true });
|
|
92
|
-
adapter = new PiAdapter(new AgentRegistry(path.join(tmpHome, "agents.json")));
|
|
93
|
-
resetReads();
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
afterEach(() => {
|
|
97
|
-
process.env.HOME = originalHome;
|
|
98
|
-
fs.rmSync(tmpHome, { recursive: true, force: true });
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
function writeSession(cwd: string, createdAt: Date, sessionId: string, body = ""): string {
|
|
102
|
-
const projectDir = path.join(sessionsDir, encodeProjectDir(cwd));
|
|
103
|
-
fs.mkdirSync(projectDir, { recursive: true });
|
|
104
|
-
const filePath = path.join(projectDir, sessionFileName(createdAt, sessionId));
|
|
105
|
-
fs.writeFileSync(
|
|
106
|
-
filePath,
|
|
107
|
-
jsonl([
|
|
108
|
-
{
|
|
109
|
-
type: "session",
|
|
110
|
-
version: 3,
|
|
111
|
-
id: sessionId,
|
|
112
|
-
timestamp: createdAt.toISOString(),
|
|
113
|
-
cwd,
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
type: "message",
|
|
117
|
-
timestamp: createdAt.toISOString(),
|
|
118
|
-
message: {
|
|
119
|
-
role: "user",
|
|
120
|
-
content: [{ type: "text", text: `prompt ${sessionId}` }],
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
]) + body,
|
|
124
|
-
);
|
|
125
|
-
return filePath;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function makeProcess(pid: number, cwd: string, startTime: Date): ProcessInfo {
|
|
129
|
-
return { pid, command: "pi", cwd, tty: "ttys001", startTime };
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/** Session files (under the sessions tree) opened or read since the last reset. */
|
|
133
|
-
function sessionFilesTouched(): string[] {
|
|
134
|
-
const paths = [
|
|
135
|
-
...mockedOpenSync.mock.calls.map((call) => String(call[0])),
|
|
136
|
-
...mockedReadFileSync.mock.calls.map((call) => String(call[0])),
|
|
137
|
-
];
|
|
138
|
-
return [...new Set(paths.filter((p) => p.startsWith(sessionsDir + path.sep)))].sort();
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function sessionBytesRead(): number {
|
|
142
|
-
return sessionFilesTouched().reduce((sum, filePath) => sum + bytesReadFrom(filePath), 0);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
it("opens only in-window files of the process project dir, heads only, then nothing", async () => {
|
|
146
|
-
const liveCwd = "/repo/live-project";
|
|
147
|
-
const startTime = new Date(Date.now() - 2 * DAY_MS);
|
|
148
|
-
const proc = makeProcess(4242, liveCwd, startTime);
|
|
149
|
-
|
|
150
|
-
// 1,000 historical sessions: 950 in other projects, 49 old ones in the live
|
|
151
|
-
// project, plus one created right after the process started.
|
|
152
|
-
let count = 0;
|
|
153
|
-
for (let project = 0; project < 50; project++) {
|
|
154
|
-
for (let i = 0; i < 19; i++) {
|
|
155
|
-
writeSession(
|
|
156
|
-
`/repo/other-${project}`,
|
|
157
|
-
new Date(startTime.getTime() + (i - 9) * 1000),
|
|
158
|
-
`other-${project}-${i}`,
|
|
159
|
-
);
|
|
160
|
-
count++;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
for (let i = 0; i < 49; i++) {
|
|
164
|
-
writeSession(liveCwd, new Date(startTime.getTime() - (i + 1) * DAY_MS), `old-${i}`);
|
|
165
|
-
count++;
|
|
166
|
-
}
|
|
167
|
-
const bigBody = jsonl(
|
|
168
|
-
Array.from({ length: 2000 }, (_, i) => ({
|
|
169
|
-
type: "message",
|
|
170
|
-
timestamp: new Date(startTime.getTime() + i).toISOString(),
|
|
171
|
-
message: { role: "assistant", content: `reply ${i} ${"x".repeat(80)}` },
|
|
172
|
-
})),
|
|
173
|
-
);
|
|
174
|
-
const inWindow = writeSession(
|
|
175
|
-
liveCwd,
|
|
176
|
-
new Date(startTime.getTime() + 10_000),
|
|
177
|
-
"in-window",
|
|
178
|
-
bigBody,
|
|
179
|
-
);
|
|
180
|
-
count++;
|
|
181
|
-
expect(count).toBe(1000);
|
|
182
|
-
expect(fs.statSync(inWindow).size).toBeGreaterThan(HEAD_LIMIT);
|
|
183
|
-
|
|
184
|
-
const first = await adapter.detectAgents({ processes: [proc] });
|
|
185
|
-
|
|
186
|
-
// Unmatched: the only in-window file's birthtime is "now", not near start
|
|
187
|
-
expect(first).toHaveLength(1);
|
|
188
|
-
expect(first[0]).toMatchObject({ pid: 4242, sessionId: "pid-4242" });
|
|
189
|
-
expect(sessionFilesTouched()).toEqual([inWindow]);
|
|
190
|
-
expect(
|
|
191
|
-
mockedReadFileSync.mock.calls.some((c) => String(c[0]).startsWith(sessionsDir + path.sep)),
|
|
192
|
-
).toBe(false);
|
|
193
|
-
expect(bytesReadFrom(inWindow)).toBeGreaterThan(0);
|
|
194
|
-
expect(bytesReadFrom(inWindow)).toBeLessThanOrEqual(HEAD_LIMIT);
|
|
195
|
-
// Only the live project dir is listed, never the whole history tree
|
|
196
|
-
const listed = mockedReaddirSync.mock.calls
|
|
197
|
-
.map((c) => String(c[0]))
|
|
198
|
-
.filter((p) => p.startsWith(sessionsDir + path.sep));
|
|
199
|
-
expect(listed).toEqual([path.join(sessionsDir, encodeProjectDir(liveCwd))]);
|
|
200
|
-
|
|
201
|
-
resetReads();
|
|
202
|
-
const second = await adapter.detectAgents({ processes: [proc] });
|
|
203
|
-
|
|
204
|
-
expect(second).toEqual([expect.objectContaining({ pid: 4242, sessionId: "pid-4242" })]);
|
|
205
|
-
expect(sessionFilesTouched()).toEqual([]);
|
|
206
|
-
expect(sessionBytesRead()).toBe(0);
|
|
207
|
-
expect(
|
|
208
|
-
mockedReaddirSync.mock.calls.some((c) => String(c[0]).startsWith(sessionsDir + path.sep)),
|
|
209
|
-
).toBe(false);
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
it("re-checks a no-match project dir when a session file is added", async () => {
|
|
213
|
-
const cwd = "/repo/added-later";
|
|
214
|
-
const startTime = new Date(Date.now() - 2 * DAY_MS);
|
|
215
|
-
const proc = makeProcess(5151, cwd, startTime);
|
|
216
|
-
writeSession(cwd, new Date(startTime.getTime() - DAY_MS), "stale");
|
|
217
|
-
|
|
218
|
-
await adapter.detectAgents({ processes: [proc] });
|
|
219
|
-
expect(sessionFilesTouched()).toEqual([]);
|
|
220
|
-
|
|
221
|
-
resetReads();
|
|
222
|
-
await adapter.detectAgents({ processes: [proc] });
|
|
223
|
-
expect(mockedReaddirSync).not.toHaveBeenCalledWith(
|
|
224
|
-
path.join(sessionsDir, encodeProjectDir(cwd)),
|
|
225
|
-
);
|
|
226
|
-
|
|
227
|
-
const added = writeSession(cwd, new Date(startTime.getTime() + 5_000), "added");
|
|
228
|
-
resetReads();
|
|
229
|
-
await adapter.detectAgents({ processes: [proc] });
|
|
230
|
-
|
|
231
|
-
expect(sessionFilesTouched()).toEqual([added]);
|
|
232
|
-
expect(bytesReadFrom(added)).toBeLessThanOrEqual(HEAD_LIMIT);
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
it("re-checks a no-match project dir when a new process needs it", async () => {
|
|
236
|
-
const cwd = "/repo/new-process";
|
|
237
|
-
const oldStart = new Date(Date.now() - 2 * DAY_MS);
|
|
238
|
-
await adapter.detectAgents({
|
|
239
|
-
processes: [makeProcess(6161, cwd, oldStart)],
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
const sessionFile = writeSession(cwd, new Date(), "fresh");
|
|
243
|
-
const oldProc = makeProcess(6161, cwd, oldStart);
|
|
244
|
-
await adapter.detectAgents({ processes: [oldProc] });
|
|
245
|
-
|
|
246
|
-
// A new process started now must still be matched to the fresh session
|
|
247
|
-
const agents = await adapter.detectAgents({
|
|
248
|
-
processes: [oldProc, makeProcess(6262, cwd, new Date())],
|
|
249
|
-
});
|
|
250
|
-
expect(agents).toEqual(
|
|
251
|
-
expect.arrayContaining([
|
|
252
|
-
expect.objectContaining({
|
|
253
|
-
pid: 6262,
|
|
254
|
-
sessionId: "fresh",
|
|
255
|
-
sessionFilePath: sessionFile,
|
|
256
|
-
}),
|
|
257
|
-
expect.objectContaining({ pid: 6161, sessionId: "pid-6161" }),
|
|
258
|
-
]),
|
|
259
|
-
);
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
it("hands a session to the losing rival once the matched process exits", async () => {
|
|
263
|
-
const cwd = "/repo/rivals";
|
|
264
|
-
const now = Date.now();
|
|
265
|
-
const sessionFile = writeSession(cwd, new Date(now), "shared");
|
|
266
|
-
const winner = makeProcess(7171, cwd, new Date(now));
|
|
267
|
-
const loser = makeProcess(7272, cwd, new Date(now + 60_000));
|
|
268
|
-
|
|
269
|
-
const both = await adapter.detectAgents({ processes: [winner, loser] });
|
|
270
|
-
expect(both).toEqual(
|
|
271
|
-
expect.arrayContaining([
|
|
272
|
-
expect.objectContaining({ pid: 7171, sessionId: "shared" }),
|
|
273
|
-
expect.objectContaining({ pid: 7272, sessionId: "pid-7272" }),
|
|
274
|
-
]),
|
|
275
|
-
);
|
|
276
|
-
|
|
277
|
-
const alone = await adapter.detectAgents({ processes: [loser] });
|
|
278
|
-
expect(alone).toEqual([
|
|
279
|
-
expect.objectContaining({
|
|
280
|
-
pid: 7272,
|
|
281
|
-
sessionId: "shared",
|
|
282
|
-
sessionFilePath: sessionFile,
|
|
283
|
-
}),
|
|
284
|
-
]);
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
it("reads 0 bytes of an unchanged matched session and only appended bytes after growth", async () => {
|
|
288
|
-
const cwd = "/repo/matched";
|
|
289
|
-
const now = new Date();
|
|
290
|
-
const sessionFile = writeSession(cwd, now, "matched-session");
|
|
291
|
-
const proc = makeProcess(8181, cwd, now);
|
|
292
|
-
|
|
293
|
-
const first = await adapter.detectAgents({ processes: [proc] });
|
|
294
|
-
expect(first).toEqual([
|
|
295
|
-
expect.objectContaining({
|
|
296
|
-
pid: 8181,
|
|
297
|
-
sessionId: "matched-session",
|
|
298
|
-
summary: "prompt matched-session",
|
|
299
|
-
}),
|
|
300
|
-
]);
|
|
301
|
-
|
|
302
|
-
resetReads();
|
|
303
|
-
await adapter.detectAgents({ processes: [proc] });
|
|
304
|
-
expect(sessionBytesRead()).toBe(0);
|
|
305
|
-
|
|
306
|
-
const appended = jsonl([
|
|
307
|
-
{
|
|
308
|
-
type: "message",
|
|
309
|
-
timestamp: new Date().toISOString(),
|
|
310
|
-
message: { role: "user", content: "follow-up prompt" },
|
|
311
|
-
},
|
|
312
|
-
]);
|
|
313
|
-
fs.appendFileSync(sessionFile, appended);
|
|
314
|
-
resetReads();
|
|
315
|
-
const third = await adapter.detectAgents({ processes: [proc] });
|
|
316
|
-
|
|
317
|
-
expect(third).toEqual([expect.objectContaining({ pid: 8181, summary: "follow-up prompt" })]);
|
|
318
|
-
expect(bytesReadFrom(sessionFile)).toBe(Buffer.byteLength(appended));
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
it("serves tracker-matched sessions from the incremental cache", async () => {
|
|
322
|
-
const cwd = "/repo/tracked";
|
|
323
|
-
const sessionFile = writeSession(cwd, new Date(), "tracked-session");
|
|
324
|
-
fs.writeFileSync(
|
|
325
|
-
path.join(tmpHome, ".pi", "agent", "sessions.json"),
|
|
326
|
-
JSON.stringify({ 9191: sessionFile }),
|
|
327
|
-
);
|
|
328
|
-
const proc = makeProcess(9191, cwd, new Date(Date.now() - DAY_MS));
|
|
329
|
-
|
|
330
|
-
await adapter.detectAgents({ processes: [proc] });
|
|
331
|
-
resetReads();
|
|
332
|
-
const agents = await adapter.detectAgents({ processes: [proc] });
|
|
333
|
-
|
|
334
|
-
expect(agents).toEqual([expect.objectContaining({ sessionId: "tracked-session" })]);
|
|
335
|
-
expect(bytesReadFrom(sessionFile)).toBe(0);
|
|
336
|
-
});
|
|
337
|
-
});
|
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import * as os from "os";
|
|
3
|
-
import * as path from "path";
|
|
4
|
-
|
|
5
|
-
import { AgentStatus } from "../../../adapters/AgentAdapter.js";
|
|
6
|
-
import { PiSessionParser } from "../../../harnesses/pi/PiSessionParser.js";
|
|
7
|
-
|
|
8
|
-
describe("PiSessionParser", () => {
|
|
9
|
-
let tmpDir: string;
|
|
10
|
-
let parser: PiSessionParser;
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "pi-parser-test-"));
|
|
14
|
-
parser = new PiSessionParser();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
afterEach(() => {
|
|
18
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("reads session metadata, summary, timestamps, and status signal", () => {
|
|
22
|
-
const filePath = writeJsonl("session.jsonl", [
|
|
23
|
-
{
|
|
24
|
-
type: "session_meta",
|
|
25
|
-
timestamp: "2026-06-10T08:58:20.754Z",
|
|
26
|
-
sessionId: "sess-101",
|
|
27
|
-
cwd: "/repo/project-a",
|
|
28
|
-
},
|
|
29
|
-
{ role: "user", timestamp: "2026-06-10T08:58:21.000Z", content: "implement Pi adapter" },
|
|
30
|
-
{ role: "assistant", timestamp: new Date().toISOString(), content: "working on it" },
|
|
31
|
-
]);
|
|
32
|
-
|
|
33
|
-
const session = parser.readSession(filePath);
|
|
34
|
-
|
|
35
|
-
expect(session).toMatchObject({
|
|
36
|
-
sessionId: "sess-101",
|
|
37
|
-
projectPath: "/repo/project-a",
|
|
38
|
-
summary: "implement Pi adapter",
|
|
39
|
-
lastRole: "assistant",
|
|
40
|
-
});
|
|
41
|
-
expect(session?.sessionStart.toISOString()).toBe("2026-06-10T08:58:20.754Z");
|
|
42
|
-
expect(parser.determineStatus(session!)).toBe(AgentStatus.WAITING);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("uses the filename session id fallback and reports running when the latest message is from the user", () => {
|
|
46
|
-
const filePath = writeJsonl("plain-session.jsonl", [
|
|
47
|
-
{ role: "user", timestamp: new Date().toISOString(), content: "still working" },
|
|
48
|
-
]);
|
|
49
|
-
|
|
50
|
-
const session = parser.readSession(filePath);
|
|
51
|
-
|
|
52
|
-
expect(session).toMatchObject({
|
|
53
|
-
sessionId: "plain-session",
|
|
54
|
-
summary: "still working",
|
|
55
|
-
lastRole: "user",
|
|
56
|
-
});
|
|
57
|
-
expect(parser.determineStatus(session!)).toBe(AgentStatus.RUNNING);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("truncates long user prompts in detected session summaries", () => {
|
|
61
|
-
const longPrompt = "x".repeat(140);
|
|
62
|
-
const filePath = writeJsonl("session.jsonl", [
|
|
63
|
-
{
|
|
64
|
-
type: "session",
|
|
65
|
-
timestamp: "2026-06-10T08:58:20.754Z",
|
|
66
|
-
id: "sess-long",
|
|
67
|
-
cwd: "/repo/project-long-summary",
|
|
68
|
-
},
|
|
69
|
-
{ role: "user", timestamp: "2026-06-10T08:58:21.000Z", content: longPrompt },
|
|
70
|
-
]);
|
|
71
|
-
|
|
72
|
-
const session = parser.readSession(filePath);
|
|
73
|
-
|
|
74
|
-
expect(session?.summary).toHaveLength(120);
|
|
75
|
-
expect(session?.summary.endsWith("...")).toBe(true);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("reads user and assistant conversation messages from JSONL", () => {
|
|
79
|
-
const filePath = writeJsonl("conversation.jsonl", [
|
|
80
|
-
{ role: "system", timestamp: "2026-06-10T08:58:20.000Z", content: "hidden" },
|
|
81
|
-
{ role: "user", timestamp: "2026-06-10T08:58:21.000Z", content: "hello pi" },
|
|
82
|
-
{
|
|
83
|
-
type: "assistant",
|
|
84
|
-
timestamp: "2026-06-10T08:58:22.000Z",
|
|
85
|
-
message: { content: "hello human" },
|
|
86
|
-
},
|
|
87
|
-
"{not json",
|
|
88
|
-
]);
|
|
89
|
-
|
|
90
|
-
expect(parser.getConversation(filePath)).toEqual([
|
|
91
|
-
{ role: "user", content: "hello pi", timestamp: "2026-06-10T08:58:21.000Z" },
|
|
92
|
-
{ role: "assistant", content: "hello human", timestamp: "2026-06-10T08:58:22.000Z" },
|
|
93
|
-
]);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it("includes system entries only in verbose conversation mode", () => {
|
|
97
|
-
const filePath = writeJsonl("verbose.jsonl", [
|
|
98
|
-
{ role: "system", timestamp: "2026-06-10T08:58:20.000Z", content: "model changed" },
|
|
99
|
-
{ role: "user", timestamp: "2026-06-10T08:58:21.000Z", content: "visible" },
|
|
100
|
-
]);
|
|
101
|
-
|
|
102
|
-
expect(parser.getConversation(filePath)).toEqual([
|
|
103
|
-
{ role: "user", content: "visible", timestamp: "2026-06-10T08:58:21.000Z" },
|
|
104
|
-
]);
|
|
105
|
-
expect(parser.getConversation(filePath, { verbose: true })).toEqual([
|
|
106
|
-
{ role: "system", content: "model changed", timestamp: "2026-06-10T08:58:20.000Z" },
|
|
107
|
-
{ role: "user", content: "visible", timestamp: "2026-06-10T08:58:21.000Z" },
|
|
108
|
-
]);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it("reads real Pi message entries with nested role and text parts", () => {
|
|
112
|
-
const filePath = writeJsonl("real.jsonl", [
|
|
113
|
-
{
|
|
114
|
-
type: "session",
|
|
115
|
-
version: 3,
|
|
116
|
-
id: "sess-real",
|
|
117
|
-
timestamp: "2026-06-10T13:27:17.581Z",
|
|
118
|
-
cwd: "/repo/project-real",
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
type: "model_change",
|
|
122
|
-
id: "model-1",
|
|
123
|
-
timestamp: "2026-06-10T13:27:17.655Z",
|
|
124
|
-
modelId: "claude-sonnet-4-6",
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
type: "message",
|
|
128
|
-
id: "msg-user",
|
|
129
|
-
timestamp: "2026-06-10T13:27:37.975Z",
|
|
130
|
-
message: {
|
|
131
|
-
role: "user",
|
|
132
|
-
content: [{ type: "text", text: "hello" }],
|
|
133
|
-
timestamp: 1781098057974,
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
type: "message",
|
|
138
|
-
id: "msg-assistant",
|
|
139
|
-
timestamp: "2026-06-10T13:27:40.161Z",
|
|
140
|
-
message: {
|
|
141
|
-
role: "assistant",
|
|
142
|
-
content: [{ type: "text", text: "Hello! How can I help you today?" }],
|
|
143
|
-
provider: "anthropic",
|
|
144
|
-
model: "claude-sonnet-4-6",
|
|
145
|
-
timestamp: 1781098058012,
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
]);
|
|
149
|
-
|
|
150
|
-
expect(parser.getConversation(filePath)).toEqual([
|
|
151
|
-
{ role: "user", content: "hello", timestamp: "2026-06-10T13:27:37.975Z" },
|
|
152
|
-
{
|
|
153
|
-
role: "assistant",
|
|
154
|
-
content: "Hello! How can I help you today?",
|
|
155
|
-
timestamp: "2026-06-10T13:27:40.161Z",
|
|
156
|
-
},
|
|
157
|
-
]);
|
|
158
|
-
expect(parser.readSession(filePath)).toMatchObject({
|
|
159
|
-
sessionId: "sess-real",
|
|
160
|
-
summary: "hello",
|
|
161
|
-
lastActive: new Date("2026-06-10T13:27:40.161Z"),
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it("builds historical summaries from the first user message", () => {
|
|
166
|
-
const filePath = writeJsonl("summary.jsonl", [
|
|
167
|
-
{ timestamp: "2026-06-10T08:58:20.754Z", sessionId: "sess-g", cwd: "/repo/project-g" },
|
|
168
|
-
{ role: "user", timestamp: "2026-06-10T08:58:21.000Z", content: "first matching message" },
|
|
169
|
-
]);
|
|
170
|
-
|
|
171
|
-
expect(parser.fileToSessionSummary(filePath)).toMatchObject({
|
|
172
|
-
type: "pi",
|
|
173
|
-
sessionId: "sess-g",
|
|
174
|
-
cwd: "/repo/project-g",
|
|
175
|
-
firstUserMessage: "first matching message",
|
|
176
|
-
sessionFilePath: filePath,
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
describe("readSessionIncremental", () => {
|
|
181
|
-
const fixtures: Array<Array<Record<string, unknown> | string>> = [
|
|
182
|
-
[
|
|
183
|
-
{ type: "session", id: "sess-a", timestamp: "2026-06-10T08:58:20.754Z", cwd: "/repo/a" },
|
|
184
|
-
{ role: "system", timestamp: "2026-06-10T08:58:21.000Z", content: "model changed" },
|
|
185
|
-
{ role: "user", timestamp: "2026-06-10T08:58:22.000Z", content: "first" },
|
|
186
|
-
{ role: "assistant", timestamp: "2026-06-10T08:58:23.000Z", content: "reply" },
|
|
187
|
-
{ role: "user", timestamp: "bad-date", content: "x".repeat(200) },
|
|
188
|
-
{ role: "system", content: "trailing system" },
|
|
189
|
-
],
|
|
190
|
-
[{ role: "user", content: "no timestamps or id" }, "{not json", "[1,2]", "42"],
|
|
191
|
-
[
|
|
192
|
-
{
|
|
193
|
-
payload: { sessionId: "nested", cwd: "/repo/nested", timestamp: "2026-06-10T08:00:00Z" },
|
|
194
|
-
},
|
|
195
|
-
{ data: { role: "assistant", content: [{ type: "text", text: "nested reply" }] } },
|
|
196
|
-
],
|
|
197
|
-
["{not json", " "],
|
|
198
|
-
];
|
|
199
|
-
|
|
200
|
-
it.each(fixtures.map((entries, index) => [index, entries] as const))(
|
|
201
|
-
"matches readSession for fixture %i",
|
|
202
|
-
(_index, entries) => {
|
|
203
|
-
const filePath = writeJsonl("equivalence.jsonl", entries);
|
|
204
|
-
expect(parser.readSessionIncremental(filePath, "/fallback")).toEqual(
|
|
205
|
-
parser.readSession(filePath, "/fallback"),
|
|
206
|
-
);
|
|
207
|
-
},
|
|
208
|
-
);
|
|
209
|
-
|
|
210
|
-
it("folds appended lines into the cached summary", () => {
|
|
211
|
-
const filePath = writeJsonl("append.jsonl", [
|
|
212
|
-
{ type: "session", id: "sess-append", timestamp: "2026-06-10T08:58:20.754Z", cwd: "/r" },
|
|
213
|
-
{ role: "user", timestamp: "2026-06-10T08:58:21.000Z", content: "before" },
|
|
214
|
-
]);
|
|
215
|
-
expect(parser.readSessionIncremental(filePath)?.summary).toBe("before");
|
|
216
|
-
|
|
217
|
-
const next = { role: "user", timestamp: "2026-06-10T09:00:00.000Z", content: "after" };
|
|
218
|
-
fs.appendFileSync(filePath, `\n${JSON.stringify(next)}\n`);
|
|
219
|
-
|
|
220
|
-
const session = parser.readSessionIncremental(filePath);
|
|
221
|
-
expect(session).toEqual(parser.readSession(filePath));
|
|
222
|
-
expect(session).toMatchObject({ summary: "after", sessionId: "sess-append" });
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
describe("readSessionHead", () => {
|
|
227
|
-
it("stops reading once the header gives session id and cwd", () => {
|
|
228
|
-
const filePath = writeJsonl("head.jsonl", [
|
|
229
|
-
{ type: "session", id: "sess-head", timestamp: "2026-06-10T08:58:20.754Z", cwd: "/repo/h" },
|
|
230
|
-
...Array.from({ length: 5000 }, (_, i) => ({ role: "assistant", content: `line ${i}` })),
|
|
231
|
-
]);
|
|
232
|
-
|
|
233
|
-
const head = parser.readSessionHead(filePath);
|
|
234
|
-
|
|
235
|
-
expect(head).toMatchObject({ sessionId: "sess-head", projectPath: "/repo/h" });
|
|
236
|
-
expect(head?.complete).toBe(false);
|
|
237
|
-
expect(head!.bytesRead).toBeLessThanOrEqual(4 * 1024);
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
it("never reads more than the byte cap", () => {
|
|
241
|
-
const filePath = writeJsonl(
|
|
242
|
-
"no-header.jsonl",
|
|
243
|
-
Array.from({ length: 5000 }, (_, i) => ({ role: "assistant", content: `line ${i}` })),
|
|
244
|
-
);
|
|
245
|
-
expect(fs.statSync(filePath).size).toBeGreaterThan(64 * 1024);
|
|
246
|
-
|
|
247
|
-
expect(parser.readSessionHead(filePath)).toEqual({ bytesRead: 64 * 1024, complete: false });
|
|
248
|
-
expect(parser.readSessionHead(filePath, 1000)?.bytesRead).toBe(1000);
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
it("uses an unterminated last line only when it ends the file", () => {
|
|
252
|
-
const whole = writeJsonl("whole.jsonl", [{ id: "sess-whole", cwd: "/repo/whole" }]);
|
|
253
|
-
expect(parser.readSessionHead(whole)).toMatchObject({
|
|
254
|
-
sessionId: "sess-whole",
|
|
255
|
-
projectPath: "/repo/whole",
|
|
256
|
-
complete: true,
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
const cut = writeJsonl("cut.jsonl", [
|
|
260
|
-
{ id: "sess-cut", cwd: "/repo/cut", pad: "y".repeat(50) },
|
|
261
|
-
]);
|
|
262
|
-
expect(parser.readSessionHead(cut, 20)).toEqual({ bytesRead: 20, complete: false });
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
it("returns null for a missing file", () => {
|
|
266
|
-
expect(parser.readSessionHead(path.join(tmpDir, "missing.jsonl"))).toBeNull();
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
function writeJsonl(name: string, entries: Array<Record<string, unknown> | string>): string {
|
|
271
|
-
const filePath = path.join(tmpDir, name);
|
|
272
|
-
fs.writeFileSync(
|
|
273
|
-
filePath,
|
|
274
|
-
entries
|
|
275
|
-
.map((entry) => (typeof entry === "string" ? entry : JSON.stringify(entry)))
|
|
276
|
-
.join("\n"),
|
|
277
|
-
);
|
|
278
|
-
return filePath;
|
|
279
|
-
}
|
|
280
|
-
});
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import * as os from "os";
|
|
3
|
-
import * as path from "path";
|
|
4
|
-
|
|
5
|
-
import type { ProcessInfo } from "../../../adapters/AgentAdapter.js";
|
|
6
|
-
import { PiSessionTracker } from "../../../harnesses/pi/PiSessionTracker.js";
|
|
7
|
-
|
|
8
|
-
describe("PiSessionTracker", () => {
|
|
9
|
-
let tmpHome: string;
|
|
10
|
-
let sessionsDir: string;
|
|
11
|
-
let trackerPath: string;
|
|
12
|
-
let tracker: PiSessionTracker;
|
|
13
|
-
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
tmpHome = fs.mkdtempSync(path.join(os.tmpdir(), "pi-tracker-test-"));
|
|
16
|
-
sessionsDir = path.join(tmpHome, ".pi", "agent", "sessions");
|
|
17
|
-
trackerPath = path.join(tmpHome, ".pi", "agent", "sessions.json");
|
|
18
|
-
fs.mkdirSync(sessionsDir, { recursive: true });
|
|
19
|
-
tracker = new PiSessionTracker({ sessionsDir, trackerPath });
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
afterEach(() => {
|
|
23
|
-
fs.rmSync(tmpHome, { recursive: true, force: true });
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("matches trusted tracker session files by PID", () => {
|
|
27
|
-
const proc = makeProcess({ pid: 101 });
|
|
28
|
-
const sessionFile = writeSessionFile("project-a/session.jsonl");
|
|
29
|
-
writeTracker({ 101: sessionFile });
|
|
30
|
-
|
|
31
|
-
expect(tracker.match([proc])).toEqual({
|
|
32
|
-
matches: [{ process: proc, filePath: sessionFile }],
|
|
33
|
-
fallback: [],
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("ignores malformed tracker metadata", () => {
|
|
38
|
-
const proc = makeProcess({ pid: 303 });
|
|
39
|
-
fs.writeFileSync(trackerPath, "{bad json");
|
|
40
|
-
|
|
41
|
-
expect(tracker.match([proc])).toEqual({
|
|
42
|
-
matches: [],
|
|
43
|
-
fallback: [proc],
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("does not trust tracker paths outside the Pi sessions directory", () => {
|
|
48
|
-
const proc = makeProcess({ pid: 404 });
|
|
49
|
-
const outside = path.join(tmpHome, "outside.jsonl");
|
|
50
|
-
fs.writeFileSync(outside, JSON.stringify({ role: "user", content: "nope" }));
|
|
51
|
-
writeTracker({ 404: outside });
|
|
52
|
-
|
|
53
|
-
expect(tracker.match([proc])).toEqual({
|
|
54
|
-
matches: [],
|
|
55
|
-
fallback: [proc],
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
function makeProcess(overrides: Partial<ProcessInfo>): ProcessInfo {
|
|
60
|
-
return {
|
|
61
|
-
pid: 1,
|
|
62
|
-
command: "pi",
|
|
63
|
-
cwd: "/repo",
|
|
64
|
-
tty: "ttys001",
|
|
65
|
-
...overrides,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function writeTracker(entries: Record<number, string>): void {
|
|
70
|
-
fs.writeFileSync(trackerPath, JSON.stringify(entries));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function writeSessionFile(relativePath: string): string {
|
|
74
|
-
const filePath = path.join(sessionsDir, relativePath);
|
|
75
|
-
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
76
|
-
fs.writeFileSync(filePath, JSON.stringify({ role: "user", content: "hello" }));
|
|
77
|
-
return filePath;
|
|
78
|
-
}
|
|
79
|
-
});
|