@ai-devkit/agent-manager 0.42.3 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AgentManager.d.ts +14 -5
- package/dist/AgentManager.d.ts.map +1 -1
- package/dist/AgentManager.js +32 -13
- package/dist/AgentManager.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +9 -4
- package/.swcrc +0 -27
- package/dist/__tests__/AgentManager.test.js +0 -1596
- package/dist/__tests__/AgentManager.test.js.map +0 -1
- package/dist/__tests__/adapters/IncrementalSessionRefresh.test.js +0 -486
- package/dist/__tests__/adapters/IncrementalSessionRefresh.test.js.map +0 -1
- package/dist/__tests__/adapters/adapterProcessImports.test.js +0 -52
- package/dist/__tests__/adapters/adapterProcessImports.test.js.map +0 -1
- package/dist/__tests__/adapters/adapterSnapshotCandidates.test.js +0 -247
- package/dist/__tests__/adapters/adapterSnapshotCandidates.test.js.map +0 -1
- package/dist/__tests__/capacity/anthropic.test.js +0 -115
- package/dist/__tests__/capacity/anthropic.test.js.map +0 -1
- package/dist/__tests__/capacity/boundaries.test.js +0 -45
- package/dist/__tests__/capacity/boundaries.test.js.map +0 -1
- package/dist/__tests__/capacity/claude.test.js +0 -485
- package/dist/__tests__/capacity/claude.test.js.map +0 -1
- package/dist/__tests__/capacity/codex.test.js +0 -339
- package/dist/__tests__/capacity/codex.test.js.map +0 -1
- package/dist/__tests__/capacity/devin.test.js +0 -239
- package/dist/__tests__/capacity/devin.test.js.map +0 -1
- package/dist/__tests__/capacity/index.test.js +0 -53
- package/dist/__tests__/capacity/index.test.js.map +0 -1
- package/dist/__tests__/capacity/openai.test.js +0 -687
- package/dist/__tests__/capacity/openai.test.js.map +0 -1
- package/dist/__tests__/capacity/wham.test.js +0 -159
- package/dist/__tests__/capacity/wham.test.js.map +0 -1
- package/dist/__tests__/capacity/zai.test.js +0 -212
- package/dist/__tests__/capacity/zai.test.js.map +0 -1
- package/dist/__tests__/fixtures.test.js +0 -218
- package/dist/__tests__/fixtures.test.js.map +0 -1
- package/dist/__tests__/harnesses/BoundedSummarySkip.test.js +0 -568
- package/dist/__tests__/harnesses/BoundedSummarySkip.test.js.map +0 -1
- package/dist/__tests__/harnesses/SessionSummaryEquivalence.test.js +0 -1089
- package/dist/__tests__/harnesses/SessionSummaryEquivalence.test.js.map +0 -1
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.js +0 -143
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.js.map +0 -1
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.js +0 -462
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/builtinAdapters.test.js +0 -33
- package/dist/__tests__/harnesses/builtinAdapters.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeAgentMapper.test.js +0 -79
- package/dist/__tests__/harnesses/claude/ClaudeAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeCodeAdapter.test.js +0 -1881
- package/dist/__tests__/harnesses/claude/ClaudeCodeAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeSessionLocator.test.js +0 -425
- package/dist/__tests__/harnesses/claude/ClaudeSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeSessionParser.test.js +0 -314
- package/dist/__tests__/harnesses/claude/ClaudeSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.js +0 -49
- package/dist/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.js +0 -76
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.js +0 -173
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.js +0 -181
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexAdapter.test.js +0 -685
- package/dist/__tests__/harnesses/codex/CodexAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexSessionLocator.test.js +0 -463
- package/dist/__tests__/harnesses/codex/CodexSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexSessionMapping.test.js +0 -86
- package/dist/__tests__/harnesses/codex/CodexSessionMapping.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexSessionParser.test.js +0 -254
- package/dist/__tests__/harnesses/codex/CodexSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexCliProbe.test.js +0 -121
- package/dist/__tests__/harnesses/codex/durable/CodexCliProbe.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.js +0 -84
- package/dist/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.js +0 -128
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.js +0 -246
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexPrintRunner.test.js +0 -384
- package/dist/__tests__/harnesses/codex/durable/CodexPrintRunner.test.js.map +0 -1
- package/dist/__tests__/harnesses/copilot/CopilotAdapter.test.js +0 -659
- package/dist/__tests__/harnesses/copilot/CopilotAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/copilot/CopilotRefreshIO.test.js +0 -290
- package/dist/__tests__/harnesses/copilot/CopilotRefreshIO.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinAdapter.test.js +0 -597
- package/dist/__tests__/harnesses/devin/DevinAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinAgentMapper.test.js +0 -99
- package/dist/__tests__/harnesses/devin/DevinAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinSessionLocator.test.js +0 -192
- package/dist/__tests__/harnesses/devin/DevinSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinSessionParser.test.js +0 -407
- package/dist/__tests__/harnesses/devin/DevinSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/fixtures.js +0 -95
- package/dist/__tests__/harnesses/devin/fixtures.js.map +0 -1
- package/dist/__tests__/harnesses/gemini/GeminiCliAdapter.test.js +0 -1454
- package/dist/__tests__/harnesses/gemini/GeminiCliAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/gemini/GeminiSessionJsonl.test.js +0 -491
- package/dist/__tests__/harnesses/gemini/GeminiSessionJsonl.test.js.map +0 -1
- package/dist/__tests__/harnesses/gemini/GeminiSessionLocator.test.js +0 -399
- package/dist/__tests__/harnesses/gemini/GeminiSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokAgentMapper.test.js +0 -56
- package/dist/__tests__/harnesses/grok/GrokAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokCliAdapter.test.js +0 -421
- package/dist/__tests__/harnesses/grok/GrokCliAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokIncrementalRefresh.test.js +0 -167
- package/dist/__tests__/harnesses/grok/GrokIncrementalRefresh.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokSessionLocator.test.js +0 -133
- package/dist/__tests__/harnesses/grok/GrokSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokSessionParser.test.js +0 -301
- package/dist/__tests__/harnesses/grok/GrokSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/kiro/KiroAdapter.test.js +0 -662
- package/dist/__tests__/harnesses/kiro/KiroAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseAdapter.test.js +0 -247
- package/dist/__tests__/harnesses/muse/MuseAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseAgentMapper.test.js +0 -81
- package/dist/__tests__/harnesses/muse/MuseAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseSessionLocator.test.js +0 -185
- package/dist/__tests__/harnesses/muse/MuseSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseSessionParser.test.js +0 -328
- package/dist/__tests__/harnesses/muse/MuseSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeAdapter.test.js +0 -213
- package/dist/__tests__/harnesses/opencode/OpenCodeAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.js +0 -108
- package/dist/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.js +0 -94
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionParser.test.js +0 -147
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiAdapter.test.js +0 -367
- package/dist/__tests__/harnesses/pi/PiAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiDiscoveryIO.test.js +0 -382
- package/dist/__tests__/harnesses/pi/PiDiscoveryIO.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiSessionParser.test.js +0 -416
- package/dist/__tests__/harnesses/pi/PiSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiSessionTracker.test.js +0 -108
- package/dist/__tests__/harnesses/pi/PiSessionTracker.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiCliProbe.test.js +0 -70
- package/dist/__tests__/harnesses/pi/durable/PiCliProbe.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.js +0 -43
- package/dist/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiPrintAgentService.test.js +0 -192
- package/dist/__tests__/harnesses/pi/durable/PiPrintAgentService.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiPrintProtocol.test.js +0 -119
- package/dist/__tests__/harnesses/pi/durable/PiPrintProtocol.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiPrintRunner.test.js +0 -382
- package/dist/__tests__/harnesses/pi/durable/PiPrintRunner.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiStreamParser.test.js +0 -34
- package/dist/__tests__/harnesses/pi/durable/PiStreamParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/readiness/AgentReadiness.test.js +0 -446
- package/dist/__tests__/harnesses/readiness/AgentReadiness.test.js.map +0 -1
- package/dist/__tests__/harnesses/runtimeProfiles.test.js +0 -101
- package/dist/__tests__/harnesses/runtimeProfiles.test.js.map +0 -1
- package/dist/__tests__/print/DurableAgent.test.js +0 -15
- package/dist/__tests__/print/DurableAgent.test.js.map +0 -1
- package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js +0 -186
- package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js.map +0 -1
- package/dist/__tests__/print/DurableAgentRepository.test.js +0 -249
- package/dist/__tests__/print/DurableAgentRepository.test.js.map +0 -1
- package/dist/__tests__/readiness-fixtures.test.js +0 -54
- package/dist/__tests__/readiness-fixtures.test.js.map +0 -1
- package/dist/__tests__/runtime/AgentRuntime.test.js +0 -13
- package/dist/__tests__/runtime/AgentRuntime.test.js.map +0 -1
- package/dist/__tests__/runtime/HerdrAgentDiscovery.test.js +0 -164
- package/dist/__tests__/runtime/HerdrAgentDiscovery.test.js.map +0 -1
- package/dist/__tests__/runtime/HerdrAgentRuntime.test.js +0 -488
- package/dist/__tests__/runtime/HerdrAgentRuntime.test.js.map +0 -1
- package/dist/__tests__/runtime/ManagedAgentRuntime.test.js +0 -637
- package/dist/__tests__/runtime/ManagedAgentRuntime.test.js.map +0 -1
- package/dist/__tests__/terminal/GhosttyBackend.test.js +0 -334
- package/dist/__tests__/terminal/GhosttyBackend.test.js.map +0 -1
- package/dist/__tests__/terminal/TerminalFocusManager.test.js +0 -253
- package/dist/__tests__/terminal/TerminalFocusManager.test.js.map +0 -1
- package/dist/__tests__/terminal/TmuxManager.test.js +0 -168
- package/dist/__tests__/terminal/TmuxManager.test.js.map +0 -1
- package/dist/__tests__/terminal/TtyWriter.test.js +0 -386
- package/dist/__tests__/terminal/TtyWriter.test.js.map +0 -1
- package/dist/__tests__/utils/AgentRegistry.test.js +0 -636
- package/dist/__tests__/utils/AgentRegistry.test.js.map +0 -1
- package/dist/__tests__/utils/IncrementalJsonlSummary.test.js +0 -650
- package/dist/__tests__/utils/IncrementalJsonlSummary.test.js.map +0 -1
- package/dist/__tests__/utils/agent-requests.test.js +0 -90
- package/dist/__tests__/utils/agent-requests.test.js.map +0 -1
- package/dist/__tests__/utils/conversationTail.bench.test.js +0 -258
- package/dist/__tests__/utils/conversationTail.bench.test.js.map +0 -1
- package/dist/__tests__/utils/conversationTailParity.test.js +0 -588
- package/dist/__tests__/utils/conversationTailParity.test.js.map +0 -1
- package/dist/__tests__/utils/jsonlTail.test.js +0 -360
- package/dist/__tests__/utils/jsonlTail.test.js.map +0 -1
- package/dist/__tests__/utils/matching.test.js +0 -324
- package/dist/__tests__/utils/matching.test.js.map +0 -1
- package/dist/__tests__/utils/matchingConstants.test.js +0 -35
- package/dist/__tests__/utils/matchingConstants.test.js.map +0 -1
- package/dist/__tests__/utils/process.test.js +0 -818
- package/dist/__tests__/utils/process.test.js.map +0 -1
- package/dist/__tests__/utils/session.test.js +0 -175
- package/dist/__tests__/utils/session.test.js.map +0 -1
- package/project.json +0 -29
- package/scripts/benchmark-cold-start.mjs +0 -350
- package/src/AgentManager.ts +0 -530
- package/src/__tests__/AgentManager.test.ts +0 -1483
- package/src/__tests__/adapters/IncrementalSessionRefresh.test.ts +0 -437
- package/src/__tests__/adapters/adapterProcessImports.test.ts +0 -58
- package/src/__tests__/adapters/adapterSnapshotCandidates.test.ts +0 -243
- package/src/__tests__/capacity/anthropic.test.ts +0 -105
- package/src/__tests__/capacity/boundaries.test.ts +0 -36
- package/src/__tests__/capacity/claude.test.ts +0 -462
- package/src/__tests__/capacity/codex.test.ts +0 -311
- package/src/__tests__/capacity/devin.test.ts +0 -210
- package/src/__tests__/capacity/fixtures/claude-credentials.json +0 -7
- package/src/__tests__/capacity/fixtures/claude-usage-malformed.json +0 -1
- package/src/__tests__/capacity/fixtures/claude-usage-partial.json +0 -15
- package/src/__tests__/capacity/fixtures/claude-usage.json +0 -63
- package/src/__tests__/capacity/fixtures/devin-config.json +0 -6
- package/src/__tests__/capacity/fixtures/devin-credentials.toml +0 -4
- package/src/__tests__/capacity/fixtures/devin-quota-nonplan.json +0 -5
- package/src/__tests__/capacity/fixtures/devin-quota.json +0 -10
- package/src/__tests__/capacity/fixtures/openai-auth.json +0 -6
- package/src/__tests__/capacity/fixtures/openai-codex-auth.json +0 -9
- package/src/__tests__/capacity/fixtures/openai-usage-completions.json +0 -67
- package/src/__tests__/capacity/fixtures/openai-usage-responses.json +0 -20
- package/src/__tests__/capacity/fixtures/wham-usage.json +0 -45
- package/src/__tests__/capacity/fixtures/zai-auth.json +0 -6
- package/src/__tests__/capacity/fixtures/zai-quota-invalid.json +0 -7
- package/src/__tests__/capacity/fixtures/zai-quota.json +0 -38
- package/src/__tests__/capacity/index.test.ts +0 -54
- package/src/__tests__/capacity/openai.test.ts +0 -571
- package/src/__tests__/capacity/wham.test.ts +0 -122
- package/src/__tests__/capacity/zai.test.ts +0 -151
- package/src/__tests__/fixtures.test.ts +0 -245
- package/src/__tests__/harnesses/BoundedSummarySkip.test.ts +0 -496
- package/src/__tests__/harnesses/SessionSummaryEquivalence.test.ts +0 -726
- package/src/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.ts +0 -133
- package/src/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.ts +0 -396
- package/src/__tests__/harnesses/builtinAdapters.test.ts +0 -33
- package/src/__tests__/harnesses/claude/ClaudeAgentMapper.test.ts +0 -84
- package/src/__tests__/harnesses/claude/ClaudeCodeAdapter.test.ts +0 -1793
- package/src/__tests__/harnesses/claude/ClaudeSessionLocator.test.ts +0 -423
- package/src/__tests__/harnesses/claude/ClaudeSessionParser.test.ts +0 -300
- package/src/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.ts +0 -34
- package/src/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.ts +0 -61
- package/src/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.ts +0 -129
- package/src/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.ts +0 -152
- package/src/__tests__/harnesses/codex/CodexAdapter.test.ts +0 -652
- package/src/__tests__/harnesses/codex/CodexSessionLocator.test.ts +0 -419
- package/src/__tests__/harnesses/codex/CodexSessionMapping.test.ts +0 -63
- package/src/__tests__/harnesses/codex/CodexSessionParser.test.ts +0 -192
- package/src/__tests__/harnesses/codex/durable/CodexCliProbe.test.ts +0 -80
- package/src/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.ts +0 -65
- package/src/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.ts +0 -104
- package/src/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.ts +0 -201
- package/src/__tests__/harnesses/codex/durable/CodexPrintRunner.test.ts +0 -299
- package/src/__tests__/harnesses/copilot/CopilotAdapter.test.ts +0 -614
- package/src/__tests__/harnesses/copilot/CopilotRefreshIO.test.ts +0 -270
- package/src/__tests__/harnesses/devin/DevinAdapter.test.ts +0 -290
- package/src/__tests__/harnesses/devin/DevinAgentMapper.test.ts +0 -101
- package/src/__tests__/harnesses/devin/DevinSessionLocator.test.ts +0 -139
- package/src/__tests__/harnesses/devin/DevinSessionParser.test.ts +0 -212
- package/src/__tests__/harnesses/devin/fixtures.ts +0 -144
- package/src/__tests__/harnesses/gemini/GeminiCliAdapter.test.ts +0 -1336
- package/src/__tests__/harnesses/gemini/GeminiSessionJsonl.test.ts +0 -402
- package/src/__tests__/harnesses/gemini/GeminiSessionLocator.test.ts +0 -396
- package/src/__tests__/harnesses/grok/GrokAgentMapper.test.ts +0 -57
- package/src/__tests__/harnesses/grok/GrokCliAdapter.test.ts +0 -376
- package/src/__tests__/harnesses/grok/GrokIncrementalRefresh.test.ts +0 -170
- package/src/__tests__/harnesses/grok/GrokSessionLocator.test.ts +0 -106
- package/src/__tests__/harnesses/grok/GrokSessionParser.test.ts +0 -230
- package/src/__tests__/harnesses/kiro/KiroAdapter.test.ts +0 -552
- package/src/__tests__/harnesses/muse/MuseAdapter.test.ts +0 -197
- package/src/__tests__/harnesses/muse/MuseAgentMapper.test.ts +0 -83
- package/src/__tests__/harnesses/muse/MuseSessionLocator.test.ts +0 -177
- package/src/__tests__/harnesses/muse/MuseSessionParser.test.ts +0 -279
- package/src/__tests__/harnesses/opencode/OpenCodeAdapter.test.ts +0 -215
- package/src/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.ts +0 -101
- package/src/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.ts +0 -84
- package/src/__tests__/harnesses/opencode/OpenCodeSessionParser.test.ts +0 -149
- package/src/__tests__/harnesses/pi/PiAdapter.test.ts +0 -325
- package/src/__tests__/harnesses/pi/PiDiscoveryIO.test.ts +0 -337
- package/src/__tests__/harnesses/pi/PiSessionParser.test.ts +0 -280
- package/src/__tests__/harnesses/pi/PiSessionTracker.test.ts +0 -79
- package/src/__tests__/harnesses/pi/durable/PiCliProbe.test.ts +0 -50
- package/src/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.ts +0 -33
- package/src/__tests__/harnesses/pi/durable/PiPrintAgentService.test.ts +0 -138
- package/src/__tests__/harnesses/pi/durable/PiPrintProtocol.test.ts +0 -71
- package/src/__tests__/harnesses/pi/durable/PiPrintRunner.test.ts +0 -252
- package/src/__tests__/harnesses/pi/durable/PiStreamParser.test.ts +0 -26
- package/src/__tests__/harnesses/readiness/AgentReadiness.test.ts +0 -362
- package/src/__tests__/harnesses/runtimeProfiles.test.ts +0 -123
- package/src/__tests__/print/DurableAgent.test.ts +0 -15
- package/src/__tests__/print/DurableAgentRepository.sqlite.test.ts +0 -128
- package/src/__tests__/print/DurableAgentRepository.test.ts +0 -184
- package/src/__tests__/readiness-fixtures.test.ts +0 -79
- package/src/__tests__/runtime/AgentRuntime.test.ts +0 -8
- package/src/__tests__/runtime/HerdrAgentDiscovery.test.ts +0 -131
- package/src/__tests__/runtime/HerdrAgentRuntime.test.ts +0 -377
- package/src/__tests__/runtime/ManagedAgentRuntime.test.ts +0 -590
- package/src/__tests__/terminal/GhosttyBackend.test.ts +0 -271
- package/src/__tests__/terminal/TerminalFocusManager.test.ts +0 -280
- package/src/__tests__/terminal/TmuxManager.test.ts +0 -185
- package/src/__tests__/terminal/TtyWriter.test.ts +0 -454
- package/src/__tests__/utils/AgentRegistry.test.ts +0 -532
- package/src/__tests__/utils/IncrementalJsonlSummary.test.ts +0 -414
- package/src/__tests__/utils/agent-requests.test.ts +0 -94
- package/src/__tests__/utils/conversationTail.bench.test.ts +0 -193
- package/src/__tests__/utils/conversationTailParity.test.ts +0 -365
- package/src/__tests__/utils/jsonlTail.test.ts +0 -317
- package/src/__tests__/utils/matching.test.ts +0 -234
- package/src/__tests__/utils/matchingConstants.test.ts +0 -40
- package/src/__tests__/utils/process.test.ts +0 -596
- package/src/__tests__/utils/session.test.ts +0 -158
- package/src/adapters/AgentAdapter.ts +0 -255
- package/src/capacity/index.ts +0 -127
- package/src/capacity/providers/anthropic.ts +0 -198
- package/src/capacity/providers/devin.ts +0 -121
- package/src/capacity/providers/openai-platform.ts +0 -150
- package/src/capacity/providers/openai-subscription.ts +0 -184
- package/src/capacity/providers/zai.ts +0 -155
- package/src/capacity/sources/claude.ts +0 -30
- package/src/capacity/sources/codex.ts +0 -251
- package/src/capacity/sources/devin.ts +0 -49
- package/src/capacity/sources/pi.ts +0 -131
- package/src/capacity/types.ts +0 -29
- package/src/database/connection.ts +0 -96
- package/src/database/index.ts +0 -7
- package/src/database/migrations/001_initial.sql +0 -12
- package/src/database/migrations/002_pins.sql +0 -1
- package/src/database/migrations/003_durable_agents.sql +0 -43
- package/src/database/migrations/004_codex_durable_sessions.sql +0 -1
- package/src/database/migrations/005_agent_runtime.sql +0 -2
- package/src/database/schema.ts +0 -64
- package/src/durable/DurableAgent.ts +0 -139
- package/src/durable/DurableAgentRepository.ts +0 -485
- package/src/durable/process.ts +0 -29
- package/src/durable/run.ts +0 -84
- package/src/durable/utils.ts +0 -66
- package/src/fixtures/bundle.ts +0 -130
- package/src/fixtures/capture.ts +0 -364
- package/src/harnesses/antigravity/AntigravityAgentMapper.ts +0 -34
- package/src/harnesses/antigravity/AntigravityCliAdapter.ts +0 -126
- package/src/harnesses/antigravity/AntigravitySessionLocator.ts +0 -75
- package/src/harnesses/antigravity/AntigravitySessionParser.ts +0 -252
- package/src/harnesses/claude/ClaudeAgentMapper.ts +0 -55
- package/src/harnesses/claude/ClaudeCodeAdapter.ts +0 -175
- package/src/harnesses/claude/ClaudeSessionLocator.ts +0 -358
- package/src/harnesses/claude/ClaudeSessionParser.ts +0 -524
- package/src/harnesses/claude/credentials.ts +0 -122
- package/src/harnesses/claude/durable/ClaudeCliProbe.ts +0 -57
- package/src/harnesses/claude/durable/ClaudePrintAgentService.ts +0 -79
- package/src/harnesses/claude/durable/ClaudePrintRunner.ts +0 -102
- package/src/harnesses/claude/durable/ClaudeStreamParser.ts +0 -108
- package/src/harnesses/claude/readiness.ts +0 -69
- package/src/harnesses/codex/CodexAdapter.ts +0 -337
- package/src/harnesses/codex/CodexAgentMapper.ts +0 -26
- package/src/harnesses/codex/CodexSessionLocator.ts +0 -509
- package/src/harnesses/codex/CodexSessionMapping.ts +0 -89
- package/src/harnesses/codex/CodexSessionParser.ts +0 -462
- package/src/harnesses/codex/credentials.ts +0 -81
- package/src/harnesses/codex/durable/CodexCliProbe.ts +0 -68
- package/src/harnesses/codex/durable/CodexPrintAgentService.ts +0 -79
- package/src/harnesses/codex/durable/CodexPrintRunner.ts +0 -104
- package/src/harnesses/codex/durable/CodexStreamParser.ts +0 -117
- package/src/harnesses/codex/readiness.ts +0 -72
- package/src/harnesses/copilot/CopilotAdapter.ts +0 -161
- package/src/harnesses/copilot/CopilotAgentMapper.ts +0 -27
- package/src/harnesses/copilot/CopilotSessionLocator.ts +0 -161
- package/src/harnesses/copilot/CopilotSessionParser.ts +0 -380
- package/src/harnesses/copilot/readiness.ts +0 -33
- package/src/harnesses/devin/DevinAdapter.ts +0 -212
- package/src/harnesses/devin/DevinAgentMapper.ts +0 -39
- package/src/harnesses/devin/DevinSessionLocator.ts +0 -230
- package/src/harnesses/devin/DevinSessionParser.ts +0 -227
- package/src/harnesses/devin/credentials.ts +0 -88
- package/src/harnesses/devin/readiness.ts +0 -36
- package/src/harnesses/gemini/GeminiAgentMapper.ts +0 -27
- package/src/harnesses/gemini/GeminiCliAdapter.ts +0 -272
- package/src/harnesses/gemini/GeminiSessionLocator.ts +0 -394
- package/src/harnesses/gemini/GeminiSessionParser.ts +0 -395
- package/src/harnesses/gemini/fileSignature.ts +0 -10
- package/src/harnesses/grok/GrokAgentMapper.ts +0 -32
- package/src/harnesses/grok/GrokCliAdapter.ts +0 -126
- package/src/harnesses/grok/GrokSessionLocator.ts +0 -179
- package/src/harnesses/grok/GrokSessionParser.ts +0 -251
- package/src/harnesses/index.ts +0 -32
- package/src/harnesses/kiro/KiroAdapter.ts +0 -143
- package/src/harnesses/kiro/KiroAgentMapper.ts +0 -34
- package/src/harnesses/kiro/KiroSessionLocator.ts +0 -143
- package/src/harnesses/kiro/KiroSessionParser.ts +0 -376
- package/src/harnesses/muse/MuseAdapter.ts +0 -157
- package/src/harnesses/muse/MuseAgentMapper.ts +0 -33
- package/src/harnesses/muse/MuseSessionLocator.ts +0 -286
- package/src/harnesses/muse/MuseSessionParser.ts +0 -435
- package/src/harnesses/muse/readiness.ts +0 -38
- package/src/harnesses/opencode/OpenCodeAdapter.ts +0 -110
- package/src/harnesses/opencode/OpenCodeAgentMapper.ts +0 -49
- package/src/harnesses/opencode/OpenCodeSessionLocator.ts +0 -151
- package/src/harnesses/opencode/OpenCodeSessionParser.ts +0 -146
- package/src/harnesses/opencode/readiness.ts +0 -48
- package/src/harnesses/pi/PiAdapter.ts +0 -197
- package/src/harnesses/pi/PiAgentMapper.ts +0 -27
- package/src/harnesses/pi/PiSessionLocator.ts +0 -288
- package/src/harnesses/pi/PiSessionParser.ts +0 -488
- package/src/harnesses/pi/PiSessionTracker.ts +0 -87
- package/src/harnesses/pi/credentials.ts +0 -129
- package/src/harnesses/pi/durable/PiCliProbe.ts +0 -56
- package/src/harnesses/pi/durable/PiPrintAgentService.ts +0 -77
- package/src/harnesses/pi/durable/PiPrintProtocol.ts +0 -41
- package/src/harnesses/pi/durable/PiPrintRunner.ts +0 -95
- package/src/harnesses/pi/durable/PiStreamParser.ts +0 -94
- package/src/harnesses/pi/readiness.ts +0 -104
- package/src/harnesses/readiness/AgentReadiness.ts +0 -91
- package/src/harnesses/readiness/checks.ts +0 -336
- package/src/harnesses/readiness/types.ts +0 -90
- package/src/harnesses/runtimeProfiles.ts +0 -105
- package/src/harnesses/shared.ts +0 -124
- package/src/index.ts +0 -70
- package/src/runtime/ManagedAgentRuntime.ts +0 -253
- package/src/runtime/RuntimeFactory.ts +0 -13
- package/src/runtime/errors.ts +0 -50
- package/src/runtime/herdr/HerdrAgentDiscovery.ts +0 -166
- package/src/runtime/herdr/HerdrAgentRuntime.ts +0 -216
- package/src/runtime/herdr/HerdrCliClient.ts +0 -78
- package/src/runtime/herdr/HerdrErrors.ts +0 -9
- package/src/runtime/herdr/HerdrResponseParsers.ts +0 -86
- package/src/runtime/herdr/HerdrRuntimeRef.ts +0 -41
- package/src/runtime/tmux/PidPolling.ts +0 -34
- package/src/runtime/tmux/TmuxAgentRuntime.ts +0 -113
- package/src/runtime/tmux/TmuxManager.ts +0 -102
- package/src/runtime/tmux/TmuxRuntimeRef.ts +0 -9
- package/src/runtime/types.ts +0 -56
- package/src/terminal/TerminalFocusManager.ts +0 -52
- package/src/terminal/TtyWriter.ts +0 -26
- package/src/terminal/backends/ghostty.ts +0 -180
- package/src/terminal/backends/index.ts +0 -23
- package/src/terminal/backends/iterm2.ts +0 -126
- package/src/terminal/backends/shared.ts +0 -47
- package/src/terminal/backends/terminal-app.ts +0 -122
- package/src/terminal/backends/tmux.ts +0 -62
- package/src/terminal/backends/wezterm.ts +0 -65
- package/src/terminal/types.ts +0 -23
- package/src/utils/AgentRegistry.ts +0 -351
- package/src/utils/IncrementalJsonlSummary.ts +0 -306
- package/src/utils/agent-requests.ts +0 -28
- package/src/utils/applescript.ts +0 -10
- package/src/utils/jsonlTail.ts +0 -349
- package/src/utils/matching.ts +0 -96
- package/src/utils/matchingConstants.ts +0 -15
- package/src/utils/process.ts +0 -604
- package/src/utils/session.ts +0 -144
- package/src/utils/sortAgents.ts +0 -54
- package/tsconfig.json +0 -11
- package/vitest.config.ts +0 -20
|
@@ -1,365 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parity between `getConversation(path, { tail })` (backward/incremental
|
|
3
|
-
* JSONL read) and the last N messages of a full parse, for every JSONL-based
|
|
4
|
-
* adapter. Fixtures are synthetic and built from the entry shapes used in each
|
|
5
|
-
* adapter's own tests (including verbose-only records, noise, malformed lines
|
|
6
|
-
* and mirrored Codex events), repeated until the file spans more than two 64 KiB
|
|
7
|
-
* chunks.
|
|
8
|
-
*/
|
|
9
|
-
import * as fs from "fs";
|
|
10
|
-
import * as os from "os";
|
|
11
|
-
import * as path from "path";
|
|
12
|
-
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
13
|
-
import type { ConversationMessage, ConversationOptions } from "../../adapters/AgentAdapter.js";
|
|
14
|
-
import { AntigravityCliAdapter } from "../../harnesses/antigravity/AntigravityCliAdapter.js";
|
|
15
|
-
import { KiroAdapter } from "../../harnesses/kiro/KiroAdapter.js";
|
|
16
|
-
import { ClaudeSessionParser } from "../../harnesses/claude/ClaudeSessionParser.js";
|
|
17
|
-
import { CodexSessionParser } from "../../harnesses/codex/CodexSessionParser.js";
|
|
18
|
-
import { CopilotSessionParser } from "../../harnesses/copilot/CopilotSessionParser.js";
|
|
19
|
-
import { GrokSessionParser } from "../../harnesses/grok/GrokSessionParser.js";
|
|
20
|
-
import { PiSessionParser } from "../../harnesses/pi/PiSessionParser.js";
|
|
21
|
-
|
|
22
|
-
type GetConversation = (p: string, o?: ConversationOptions) => ConversationMessage[];
|
|
23
|
-
|
|
24
|
-
interface AdapterCase {
|
|
25
|
-
name: string;
|
|
26
|
-
fileName: string;
|
|
27
|
-
create: () => GetConversation;
|
|
28
|
-
/** Lines (already serialized, may include malformed ones) for turn `i`. */
|
|
29
|
-
turn: (i: number) => string[];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const j = (value: unknown): string => JSON.stringify(value);
|
|
33
|
-
const pad = (i: number): string => (i % 5 === 0 ? ` ${"lorem ipsum ".repeat(500)}` : "");
|
|
34
|
-
const ts = (i: number, s = 0): string =>
|
|
35
|
-
new Date(Date.UTC(2026, 0, 1, 0, 0, i * 10 + s)).toISOString();
|
|
36
|
-
|
|
37
|
-
const cases: AdapterCase[] = [
|
|
38
|
-
{
|
|
39
|
-
name: "claude",
|
|
40
|
-
fileName: "claude.jsonl",
|
|
41
|
-
create: () => {
|
|
42
|
-
const parser = new ClaudeSessionParser();
|
|
43
|
-
return (p, o) => parser.getConversation(p, o);
|
|
44
|
-
},
|
|
45
|
-
turn: (i) => [
|
|
46
|
-
j({ type: "file-history-snapshot", snapshot: { timestamp: ts(i) } }),
|
|
47
|
-
j({ type: "user", timestamp: ts(i, 1), message: { content: `question ${i}${pad(i)}` } }),
|
|
48
|
-
j({
|
|
49
|
-
type: "assistant",
|
|
50
|
-
timestamp: ts(i, 2),
|
|
51
|
-
message: {
|
|
52
|
-
content: [
|
|
53
|
-
{ type: "text", text: `answer ${i} ✓` },
|
|
54
|
-
{ type: "tool_use", name: "Read", input: { file_path: `/f${i}.ts` } },
|
|
55
|
-
],
|
|
56
|
-
},
|
|
57
|
-
}),
|
|
58
|
-
j({
|
|
59
|
-
type: "user",
|
|
60
|
-
timestamp: ts(i, 3),
|
|
61
|
-
message: {
|
|
62
|
-
content: [{ type: "tool_result", content: `result ${i}\nmore`, is_error: i % 4 === 0 }],
|
|
63
|
-
},
|
|
64
|
-
}),
|
|
65
|
-
j({
|
|
66
|
-
type: "user",
|
|
67
|
-
timestamp: ts(i, 4),
|
|
68
|
-
message: { content: "<system-reminder>hidden</system-reminder>" },
|
|
69
|
-
}),
|
|
70
|
-
j({ type: "progress", timestamp: ts(i, 5) }),
|
|
71
|
-
i % 5 === 0 ? '{"type":"user","message":' : "",
|
|
72
|
-
j({ type: "system", timestamp: ts(i, 6), message: { content: `system ${i}` } }),
|
|
73
|
-
],
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
name: "codex",
|
|
77
|
-
fileName: "codex.jsonl",
|
|
78
|
-
create: () => {
|
|
79
|
-
const parser = new CodexSessionParser();
|
|
80
|
-
return (p, o) => parser.getConversation(p, o);
|
|
81
|
-
},
|
|
82
|
-
turn: (i) => {
|
|
83
|
-
const turnId = `turn-${i}`;
|
|
84
|
-
const userResponse = j({
|
|
85
|
-
type: "response_item",
|
|
86
|
-
timestamp: ts(i, 1),
|
|
87
|
-
payload: {
|
|
88
|
-
type: "message",
|
|
89
|
-
role: "user",
|
|
90
|
-
content: [{ type: "input_text", text: `fix bug ${i}${pad(i)}` }],
|
|
91
|
-
internal_chat_message_metadata_passthrough: { turn_id: turnId },
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
const userEvent = j({
|
|
95
|
-
type: "event_msg",
|
|
96
|
-
timestamp: ts(i, 1),
|
|
97
|
-
payload: {
|
|
98
|
-
type: "item_completed",
|
|
99
|
-
turn_id: turnId,
|
|
100
|
-
item: { type: "UserMessage", content: [{ type: "text", text: `fix bug ${i}${pad(i)}` }] },
|
|
101
|
-
},
|
|
102
|
-
});
|
|
103
|
-
const agentEvent = j({
|
|
104
|
-
type: "event_msg",
|
|
105
|
-
timestamp: ts(i, 5),
|
|
106
|
-
payload: {
|
|
107
|
-
type: "item_completed",
|
|
108
|
-
turn_id: turnId,
|
|
109
|
-
item: { type: "AgentMessage", content: [{ type: "Text", text: `found issue ${i}` }] },
|
|
110
|
-
},
|
|
111
|
-
});
|
|
112
|
-
const agentResponse = j({
|
|
113
|
-
type: "response_item",
|
|
114
|
-
timestamp: ts(i, 6),
|
|
115
|
-
payload: {
|
|
116
|
-
type: "message",
|
|
117
|
-
role: "assistant",
|
|
118
|
-
content: [{ type: "output_text", text: `found issue ${i}` }],
|
|
119
|
-
internal_chat_message_metadata_passthrough: { turn_id: turnId },
|
|
120
|
-
},
|
|
121
|
-
});
|
|
122
|
-
return [
|
|
123
|
-
...(i === 0 ? [j({ type: "session_meta", payload: { id: "s", cwd: "/repo" } })] : []),
|
|
124
|
-
// Alternate which half of a mirrored pair is written first.
|
|
125
|
-
...(i % 2 ? [userEvent, userResponse] : [userResponse, userEvent]),
|
|
126
|
-
j({
|
|
127
|
-
type: "event_msg",
|
|
128
|
-
timestamp: ts(i, 2),
|
|
129
|
-
payload: { type: "agent_reasoning", message: `thinking ${i}` },
|
|
130
|
-
}),
|
|
131
|
-
j({
|
|
132
|
-
type: "response_item",
|
|
133
|
-
timestamp: ts(i, 3),
|
|
134
|
-
payload: { type: "function_call", name: "shell" },
|
|
135
|
-
}),
|
|
136
|
-
j({ type: "event_msg", timestamp: ts(i, 4), payload: { type: "token_count" } }),
|
|
137
|
-
...(i % 2 ? [agentResponse, agentEvent] : [agentEvent, agentResponse]),
|
|
138
|
-
j({
|
|
139
|
-
type: "event_msg",
|
|
140
|
-
timestamp: ts(i, 7),
|
|
141
|
-
payload: { type: "agent_message", message: `legacy ${i}` },
|
|
142
|
-
}),
|
|
143
|
-
i % 3 === 0
|
|
144
|
-
? j({
|
|
145
|
-
type: "event_msg",
|
|
146
|
-
timestamp: ts(i, 8),
|
|
147
|
-
payload: { type: "task_complete", message: `done ${i}` },
|
|
148
|
-
})
|
|
149
|
-
: "",
|
|
150
|
-
];
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
name: "copilot",
|
|
155
|
-
fileName: "events.jsonl",
|
|
156
|
-
create: () => {
|
|
157
|
-
const parser = new CopilotSessionParser();
|
|
158
|
-
return (p, o) => parser.getConversation(p, o);
|
|
159
|
-
},
|
|
160
|
-
turn: (i) => [
|
|
161
|
-
i === 0
|
|
162
|
-
? j({ type: "session.start", data: { sessionId: "s", context: { cwd: "/repo" } } })
|
|
163
|
-
: "",
|
|
164
|
-
j({ type: "user.message", timestamp: ts(i, 1), data: { content: `hello ${i}${pad(i)}` } }),
|
|
165
|
-
j({ type: "session.warning", timestamp: ts(i, 2), data: { message: `warn ${i}` } }),
|
|
166
|
-
j({
|
|
167
|
-
type: "tool.execution_complete",
|
|
168
|
-
timestamp: ts(i, 3),
|
|
169
|
-
data: { result: { content: `tool ${i}` } },
|
|
170
|
-
}),
|
|
171
|
-
j({ type: "assistant.message", timestamp: ts(i, 4), data: {} }),
|
|
172
|
-
j({ type: "assistant.message", timestamp: ts(i, 5), data: { content: `hi ${i}` } }),
|
|
173
|
-
" ",
|
|
174
|
-
],
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
name: "grok",
|
|
178
|
-
fileName: "chat_history.jsonl",
|
|
179
|
-
create: () => {
|
|
180
|
-
const parser = new GrokSessionParser();
|
|
181
|
-
return (p, o) => parser.getConversation(p, o);
|
|
182
|
-
},
|
|
183
|
-
turn: (i) => [
|
|
184
|
-
j({ type: "system", content: `system prompt ${i}` }),
|
|
185
|
-
j({ type: "user", content: "<user_info>ctx</user_info>" }),
|
|
186
|
-
j({
|
|
187
|
-
type: "user",
|
|
188
|
-
content: [{ type: "text", text: `<user_query>ask ${i}${pad(i)}</user_query>` }],
|
|
189
|
-
}),
|
|
190
|
-
j({ type: "assistant", content: [{ type: "text", text: `reply ${i}` }] }),
|
|
191
|
-
j({ type: "assistant", content: "" }),
|
|
192
|
-
],
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
name: "pi",
|
|
196
|
-
fileName: "pi.jsonl",
|
|
197
|
-
create: () => {
|
|
198
|
-
const parser = new PiSessionParser();
|
|
199
|
-
return (p, o) => parser.getConversation(p, o);
|
|
200
|
-
},
|
|
201
|
-
turn: (i) => [
|
|
202
|
-
i === 0 ? j({ type: "session", id: "s", cwd: "/repo", timestamp: ts(0) }) : "",
|
|
203
|
-
j({ type: "model_change", id: `m${i}`, timestamp: ts(i), modelId: "x" }),
|
|
204
|
-
j({
|
|
205
|
-
type: "message",
|
|
206
|
-
timestamp: ts(i, 1),
|
|
207
|
-
message: { role: "user", content: [{ type: "text", text: `hello ${i}${pad(i)}` }] },
|
|
208
|
-
}) + "\r",
|
|
209
|
-
j({ type: "message", timestamp: ts(i, 2), message: { role: "system", content: `sys ${i}` } }),
|
|
210
|
-
j({
|
|
211
|
-
type: "message",
|
|
212
|
-
timestamp: ts(i, 3),
|
|
213
|
-
message: { role: "assistant", content: [{ type: "text", text: `Hello ${i}` }] },
|
|
214
|
-
}),
|
|
215
|
-
"[1,2,3]",
|
|
216
|
-
],
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
name: "kiro",
|
|
220
|
-
fileName: "kiro.jsonl",
|
|
221
|
-
create: () => {
|
|
222
|
-
const adapter = new KiroAdapter();
|
|
223
|
-
return (p, o) => adapter.getConversation(p, o);
|
|
224
|
-
},
|
|
225
|
-
turn: (i) => [
|
|
226
|
-
j({
|
|
227
|
-
version: "v1",
|
|
228
|
-
kind: "Prompt",
|
|
229
|
-
data: {
|
|
230
|
-
content: [{ kind: "text", data: `do ${i}${pad(i)}` }],
|
|
231
|
-
meta: { timestamp: 1_700_000_000 + i },
|
|
232
|
-
},
|
|
233
|
-
}),
|
|
234
|
-
j({
|
|
235
|
-
version: "v1",
|
|
236
|
-
kind: "AssistantMessage",
|
|
237
|
-
data: {
|
|
238
|
-
content: [
|
|
239
|
-
{
|
|
240
|
-
kind: "toolUse",
|
|
241
|
-
data: { toolUseId: `t${i}`, name: "shell", input: { command: `ls ${i}` } },
|
|
242
|
-
},
|
|
243
|
-
],
|
|
244
|
-
},
|
|
245
|
-
}),
|
|
246
|
-
j({
|
|
247
|
-
version: "v1",
|
|
248
|
-
kind: "ToolResults",
|
|
249
|
-
data: {
|
|
250
|
-
content: [
|
|
251
|
-
{
|
|
252
|
-
kind: "toolResult",
|
|
253
|
-
data: { toolUseId: `t${i}`, status: "success", result: `out ${i}` },
|
|
254
|
-
},
|
|
255
|
-
],
|
|
256
|
-
},
|
|
257
|
-
}),
|
|
258
|
-
j({
|
|
259
|
-
version: "v1",
|
|
260
|
-
kind: "AssistantMessage",
|
|
261
|
-
data: { content: [{ kind: "text", data: `done ${i}` }] },
|
|
262
|
-
}),
|
|
263
|
-
],
|
|
264
|
-
},
|
|
265
|
-
{
|
|
266
|
-
name: "antigravity",
|
|
267
|
-
fileName: "transcript.jsonl",
|
|
268
|
-
create: () => {
|
|
269
|
-
const adapter = new AntigravityCliAdapter();
|
|
270
|
-
return (p, o) => adapter.getConversation(p, o);
|
|
271
|
-
},
|
|
272
|
-
turn: (i) => [
|
|
273
|
-
j({
|
|
274
|
-
source: "USER_EXPLICIT",
|
|
275
|
-
type: "USER_INPUT",
|
|
276
|
-
created_at: ts(i, 1),
|
|
277
|
-
content: `<USER_REQUEST>\nrequest ${i}${pad(i)}\n</USER_REQUEST>\n<ADDITIONAL_CONTEXT>x</ADDITIONAL_CONTEXT>`,
|
|
278
|
-
}),
|
|
279
|
-
j({ source: "MODEL", type: "RUN_COMMAND", created_at: ts(i, 2), content: `ls ${i}` }),
|
|
280
|
-
j({ source: "SYSTEM", type: "CHECKPOINT", created_at: ts(i, 3), content: `checkpoint ${i}` }),
|
|
281
|
-
j({
|
|
282
|
-
source: "MODEL",
|
|
283
|
-
type: "PLANNER_RESPONSE",
|
|
284
|
-
created_at: ts(i, 4),
|
|
285
|
-
content: `planned ${i}`,
|
|
286
|
-
}),
|
|
287
|
-
j({ source: "USER_EXPLICIT", type: "USER_INPUT", created_at: ts(i, 5), content: " " }),
|
|
288
|
-
],
|
|
289
|
-
},
|
|
290
|
-
];
|
|
291
|
-
|
|
292
|
-
function build(c: AdapterCase, from: number, to: number): string {
|
|
293
|
-
const lines: string[] = [];
|
|
294
|
-
for (let i = from; i < to; i++) lines.push(...c.turn(i));
|
|
295
|
-
return lines.join("\n") + "\n";
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
const TAILS = [1, 2, 3, 7, 20, 64];
|
|
299
|
-
|
|
300
|
-
describe.each(cases)("getConversation tail parity: $name", (c) => {
|
|
301
|
-
let tmpDir: string;
|
|
302
|
-
let file: string;
|
|
303
|
-
|
|
304
|
-
beforeEach(() => {
|
|
305
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), `tail-parity-${c.name}-`));
|
|
306
|
-
file = path.join(tmpDir, c.fileName);
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
afterEach(() => {
|
|
310
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
const expectParity = (getConversation: GetConversation, verbose: boolean): void => {
|
|
314
|
-
const full = getConversation(file, { verbose });
|
|
315
|
-
for (const tail of [...TAILS, full.length, full.length + 5]) {
|
|
316
|
-
const expected = full.slice(-tail);
|
|
317
|
-
expect(getConversation(file, { verbose, tail })).toEqual(expected);
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
it("matches the last N of a full parse across chunk boundaries (verbose and not)", () => {
|
|
322
|
-
fs.writeFileSync(file, build(c, 0, 120));
|
|
323
|
-
expect(fs.statSync(file).size).toBeGreaterThan(2 * 64 * 1024);
|
|
324
|
-
|
|
325
|
-
const getConversation = c.create();
|
|
326
|
-
expect(getConversation(file).length).toBeGreaterThan(64);
|
|
327
|
-
expectParity(getConversation, false);
|
|
328
|
-
expectParity(getConversation, true);
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
it("stays equal to a full parse across appends, truncation and rotation", () => {
|
|
332
|
-
const getConversation = c.create();
|
|
333
|
-
fs.writeFileSync(file, build(c, 0, 80));
|
|
334
|
-
expectParity(getConversation, false);
|
|
335
|
-
|
|
336
|
-
for (let round = 0; round < 3; round++) {
|
|
337
|
-
fs.appendFileSync(file, build(c, 80 + round * 3, 83 + round * 3));
|
|
338
|
-
expectParity(getConversation, false);
|
|
339
|
-
expectParity(getConversation, true);
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
// Append a turn split mid-line, as a writer flushing partially would.
|
|
343
|
-
const next = build(c, 200, 201);
|
|
344
|
-
const cut = Math.floor(next.length / 2);
|
|
345
|
-
fs.appendFileSync(file, next.slice(0, cut));
|
|
346
|
-
expectParity(getConversation, false);
|
|
347
|
-
fs.appendFileSync(file, next.slice(cut));
|
|
348
|
-
expectParity(getConversation, false);
|
|
349
|
-
|
|
350
|
-
// Truncate in place to a shorter transcript.
|
|
351
|
-
fs.writeFileSync(file, build(c, 300, 304));
|
|
352
|
-
expectParity(getConversation, false);
|
|
353
|
-
|
|
354
|
-
// Rotate: replace with a larger file at a new inode.
|
|
355
|
-
const staging = path.join(tmpDir, "staging.jsonl");
|
|
356
|
-
fs.writeFileSync(staging, build(c, 400, 460));
|
|
357
|
-
fs.renameSync(staging, file);
|
|
358
|
-
expectParity(getConversation, false);
|
|
359
|
-
expectParity(getConversation, true);
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
it("returns an empty list for a missing transcript", () => {
|
|
363
|
-
expect(c.create()(path.join(tmpDir, "missing", c.fileName), { tail: 20 })).toEqual([]);
|
|
364
|
-
});
|
|
365
|
-
});
|
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import * as os from "os";
|
|
3
|
-
import * as path from "path";
|
|
4
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
-
import type { ConversationMessage } from "../../adapters/AgentAdapter.js";
|
|
6
|
-
import { JsonlTailReader, type JsonlTailSource } from "../../utils/jsonlTail.js";
|
|
7
|
-
|
|
8
|
-
const readBytes = vi.hoisted(() => ({ total: 0 }));
|
|
9
|
-
|
|
10
|
-
vi.mock("fs", async (importOriginal) => {
|
|
11
|
-
const actual = await importOriginal<typeof import("fs")>();
|
|
12
|
-
const readSync = ((...args: Parameters<typeof actual.readSync>) => {
|
|
13
|
-
const n = (actual.readSync as (...a: unknown[]) => number)(...args);
|
|
14
|
-
readBytes.total += n;
|
|
15
|
-
return n;
|
|
16
|
-
}) as typeof actual.readSync;
|
|
17
|
-
const readFileSync = ((...args: Parameters<typeof actual.readFileSync>) => {
|
|
18
|
-
const out = (actual.readFileSync as (...a: unknown[]) => string | Buffer)(...args);
|
|
19
|
-
readBytes.total += Buffer.byteLength(out as string);
|
|
20
|
-
return out;
|
|
21
|
-
}) as typeof actual.readFileSync;
|
|
22
|
-
return { ...actual, readSync, readFileSync, default: { ...actual, readSync, readFileSync } };
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
interface Line {
|
|
26
|
-
role?: ConversationMessage["role"];
|
|
27
|
-
text?: string;
|
|
28
|
-
key?: string;
|
|
29
|
-
mirror?: boolean;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** Line-independent source: every line with role+text is one message. */
|
|
33
|
-
const simpleSource: JsonlTailSource<ConversationMessage> = {
|
|
34
|
-
parseLine(line) {
|
|
35
|
-
let entry: Line;
|
|
36
|
-
try {
|
|
37
|
-
entry = JSON.parse(line);
|
|
38
|
-
} catch {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
if (!entry.role || !entry.text) return null;
|
|
42
|
-
return { role: entry.role, content: entry.text };
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
function fullParse(content: string): ConversationMessage[] {
|
|
47
|
-
const out: ConversationMessage[] = [];
|
|
48
|
-
for (const line of content.trim().split("\n")) {
|
|
49
|
-
const message = simpleSource.parseLine(line);
|
|
50
|
-
if (message) out.push(message as ConversationMessage);
|
|
51
|
-
}
|
|
52
|
-
return out;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Source whose output depends on other lines: a "mirror" line is dropped
|
|
57
|
-
* when a non-mirror line with the same key exists anywhere in the window
|
|
58
|
-
* (modeled on Codex's event_msg/response_item de-duplication).
|
|
59
|
-
*/
|
|
60
|
-
interface KeyedItem {
|
|
61
|
-
key?: string;
|
|
62
|
-
mirror: boolean;
|
|
63
|
-
message: ConversationMessage;
|
|
64
|
-
}
|
|
65
|
-
const dedupSource: JsonlTailSource<KeyedItem> = {
|
|
66
|
-
parseLine(line) {
|
|
67
|
-
let entry: Line;
|
|
68
|
-
try {
|
|
69
|
-
entry = JSON.parse(line);
|
|
70
|
-
} catch {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
if (!entry.role || !entry.text) return null;
|
|
74
|
-
return {
|
|
75
|
-
key: entry.key,
|
|
76
|
-
mirror: entry.mirror === true,
|
|
77
|
-
message: { role: entry.role, content: entry.text },
|
|
78
|
-
};
|
|
79
|
-
},
|
|
80
|
-
finalize(items) {
|
|
81
|
-
const primary = new Set(items.filter((i) => !i.mirror && i.key).map((i) => i.key));
|
|
82
|
-
return items.filter((i) => !(i.mirror && i.key && primary.has(i.key))).map((i) => i.message);
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
function dedupFullParse(content: string): ConversationMessage[] {
|
|
87
|
-
const items: KeyedItem[] = [];
|
|
88
|
-
for (const line of content.trim().split("\n")) {
|
|
89
|
-
const item = dedupSource.parseLine(line);
|
|
90
|
-
if (item) items.push(item);
|
|
91
|
-
}
|
|
92
|
-
return dedupSource.finalize!(items);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const last = <T>(arr: T[], n: number): T[] => (arr.length > n ? arr.slice(-n) : arr);
|
|
96
|
-
|
|
97
|
-
describe("JsonlTailReader", () => {
|
|
98
|
-
let tmpDir: string;
|
|
99
|
-
let file: string;
|
|
100
|
-
|
|
101
|
-
beforeEach(() => {
|
|
102
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "jsonl-tail-"));
|
|
103
|
-
file = path.join(tmpDir, "session.jsonl");
|
|
104
|
-
readBytes.total = 0;
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
afterEach(() => {
|
|
108
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
function mixedContent(count: number): string {
|
|
112
|
-
const lines: string[] = [];
|
|
113
|
-
for (let i = 0; i < count; i++) {
|
|
114
|
-
if (i % 7 === 3) lines.push("not json {");
|
|
115
|
-
if (i % 11 === 5) lines.push("");
|
|
116
|
-
if (i % 5 === 0) lines.push(JSON.stringify({ type: "noise", i }));
|
|
117
|
-
const text = i % 13 === 0 ? `big ${i} ${"x".repeat(300)}` : `msg ${i} ünïcødé ✓ 🚀`;
|
|
118
|
-
lines.push(JSON.stringify({ role: i % 2 ? "assistant" : "user", text }));
|
|
119
|
-
}
|
|
120
|
-
return lines.join("\n") + "\n";
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
it("matches the last N of a full parse for every tail and chunk size", () => {
|
|
124
|
-
const content = mixedContent(60);
|
|
125
|
-
fs.writeFileSync(file, content);
|
|
126
|
-
const full = fullParse(content);
|
|
127
|
-
|
|
128
|
-
for (const chunkSize of [7, 64, 333, 65536]) {
|
|
129
|
-
for (let tail = 1; tail <= full.length + 2; tail++) {
|
|
130
|
-
const reader = new JsonlTailReader({ chunkSize });
|
|
131
|
-
expect(reader.read(file, tail, simpleSource)).toEqual(last(full, tail));
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it("handles lines longer than the chunk size and multi-byte characters across chunks", () => {
|
|
137
|
-
const lines = [
|
|
138
|
-
JSON.stringify({ role: "user", text: "é".repeat(5000) }),
|
|
139
|
-
JSON.stringify({ role: "assistant", text: "🚀".repeat(3000) }),
|
|
140
|
-
JSON.stringify({ role: "user", text: "short" }),
|
|
141
|
-
];
|
|
142
|
-
const content = lines.join("\n");
|
|
143
|
-
fs.writeFileSync(file, content);
|
|
144
|
-
|
|
145
|
-
const reader = new JsonlTailReader({ chunkSize: 100 });
|
|
146
|
-
expect(reader.read(file, 3, simpleSource)).toEqual(fullParse(content));
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it("returns an empty list for missing and empty files", () => {
|
|
150
|
-
const reader = new JsonlTailReader();
|
|
151
|
-
expect(reader.read(path.join(tmpDir, "missing.jsonl"), 5, simpleSource)).toEqual([]);
|
|
152
|
-
fs.writeFileSync(file, "");
|
|
153
|
-
expect(reader.read(file, 5, simpleSource)).toEqual([]);
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it("reads only a bounded window from the end on the first call", () => {
|
|
157
|
-
const content = mixedContent(20000);
|
|
158
|
-
fs.writeFileSync(file, content);
|
|
159
|
-
const reader = new JsonlTailReader({ chunkSize: 4096 });
|
|
160
|
-
|
|
161
|
-
readBytes.total = 0;
|
|
162
|
-
const result = reader.read(file, 20, simpleSource);
|
|
163
|
-
|
|
164
|
-
expect(result).toEqual(last(fullParse(content), 20));
|
|
165
|
-
expect(readBytes.total).toBeLessThanOrEqual(4 * 4096);
|
|
166
|
-
expect(content.length).toBeGreaterThan(100 * 4096);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it("does not read the file again when it is unchanged", () => {
|
|
170
|
-
fs.writeFileSync(file, mixedContent(50));
|
|
171
|
-
const reader = new JsonlTailReader();
|
|
172
|
-
const first = reader.read(file, 10, simpleSource);
|
|
173
|
-
|
|
174
|
-
readBytes.total = 0;
|
|
175
|
-
expect(reader.read(file, 10, simpleSource)).toEqual(first);
|
|
176
|
-
expect(readBytes.total).toBe(0);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it("parses only appended bytes on later polls", () => {
|
|
180
|
-
const chunkSize = 4096;
|
|
181
|
-
let content = mixedContent(5000);
|
|
182
|
-
fs.writeFileSync(file, content);
|
|
183
|
-
const reader = new JsonlTailReader({ chunkSize });
|
|
184
|
-
reader.read(file, 20, simpleSource);
|
|
185
|
-
|
|
186
|
-
for (let round = 0; round < 3; round++) {
|
|
187
|
-
const appended = mixedContent(3 + round).replace(/msg /g, `r${round} `);
|
|
188
|
-
fs.appendFileSync(file, appended);
|
|
189
|
-
content += appended;
|
|
190
|
-
|
|
191
|
-
readBytes.total = 0;
|
|
192
|
-
const result = reader.read(file, 20, simpleSource);
|
|
193
|
-
expect(result).toEqual(last(fullParse(content), 20));
|
|
194
|
-
expect(readBytes.total).toBeLessThanOrEqual(Buffer.byteLength(appended) + chunkSize);
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
it("includes an unterminated final line and re-reads it once completed", () => {
|
|
199
|
-
const head = [
|
|
200
|
-
JSON.stringify({ role: "user", text: "one" }),
|
|
201
|
-
JSON.stringify({ role: "assistant", text: "two" }),
|
|
202
|
-
].join("\n");
|
|
203
|
-
fs.writeFileSync(file, head + "\n" + '{"role":"user","te');
|
|
204
|
-
const reader = new JsonlTailReader({ chunkSize: 16 });
|
|
205
|
-
expect(reader.read(file, 5, simpleSource)).toEqual(fullParse(head));
|
|
206
|
-
|
|
207
|
-
fs.appendFileSync(file, 'xt":"three"}');
|
|
208
|
-
const complete = fs.readFileSync(file, "utf-8");
|
|
209
|
-
expect(reader.read(file, 5, simpleSource)).toEqual(fullParse(complete));
|
|
210
|
-
expect(reader.read(file, 5, simpleSource).at(-1)).toEqual({ role: "user", content: "three" });
|
|
211
|
-
|
|
212
|
-
fs.appendFileSync(file, "\n" + JSON.stringify({ role: "assistant", text: "four" }) + "\n");
|
|
213
|
-
expect(reader.read(file, 5, simpleSource)).toEqual(fullParse(fs.readFileSync(file, "utf-8")));
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
it("resets when the file shrinks (truncation)", () => {
|
|
217
|
-
fs.writeFileSync(file, mixedContent(40));
|
|
218
|
-
const reader = new JsonlTailReader({ chunkSize: 64 });
|
|
219
|
-
reader.read(file, 5, simpleSource);
|
|
220
|
-
|
|
221
|
-
const replacement = [
|
|
222
|
-
JSON.stringify({ role: "user", text: "fresh start" }),
|
|
223
|
-
JSON.stringify({ role: "assistant", text: "ok" }),
|
|
224
|
-
].join("\n");
|
|
225
|
-
fs.writeFileSync(file, replacement + "\n");
|
|
226
|
-
expect(reader.read(file, 5, simpleSource)).toEqual(fullParse(replacement));
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
it("resets when the file is replaced by a new inode (rotation)", () => {
|
|
230
|
-
const original = mixedContent(10);
|
|
231
|
-
fs.writeFileSync(file, original);
|
|
232
|
-
const reader = new JsonlTailReader({ chunkSize: 64 });
|
|
233
|
-
reader.read(file, 5, simpleSource);
|
|
234
|
-
|
|
235
|
-
// A larger replacement at a new inode must not be treated as an append.
|
|
236
|
-
const rotated = mixedContent(30).replace(/msg /g, "rotated ");
|
|
237
|
-
const staging = path.join(tmpDir, "staging.jsonl");
|
|
238
|
-
fs.writeFileSync(staging, rotated);
|
|
239
|
-
fs.renameSync(staging, file);
|
|
240
|
-
|
|
241
|
-
expect(reader.read(file, 5, simpleSource)).toEqual(last(fullParse(rotated), 5));
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
it("keeps cache entries separate per variant and per tail", () => {
|
|
245
|
-
const content = mixedContent(30);
|
|
246
|
-
fs.writeFileSync(file, content);
|
|
247
|
-
const reader = new JsonlTailReader();
|
|
248
|
-
const full = fullParse(content);
|
|
249
|
-
const onlyUsers: JsonlTailSource<ConversationMessage> = {
|
|
250
|
-
parseLine: (line) => {
|
|
251
|
-
const m = simpleSource.parseLine(line);
|
|
252
|
-
return m && (m as ConversationMessage).role === "user" ? m : null;
|
|
253
|
-
},
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
expect(reader.read(file, 3, simpleSource, "all")).toEqual(last(full, 3));
|
|
257
|
-
expect(reader.read(file, 3, onlyUsers, "users")).toEqual(
|
|
258
|
-
last(
|
|
259
|
-
full.filter((m) => m.role === "user"),
|
|
260
|
-
3,
|
|
261
|
-
),
|
|
262
|
-
);
|
|
263
|
-
expect(reader.read(file, 6, simpleSource, "all")).toEqual(last(full, 6));
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
it("applies finalize over the window, including lines appended later", () => {
|
|
267
|
-
const lines = [
|
|
268
|
-
{ role: "user", text: "hello", key: "k1" },
|
|
269
|
-
{ role: "user", text: "hello", key: "k1", mirror: true },
|
|
270
|
-
{ role: "assistant", text: "reply", key: "k2", mirror: true },
|
|
271
|
-
].map((l) => JSON.stringify(l));
|
|
272
|
-
let content = lines.join("\n") + "\n";
|
|
273
|
-
fs.writeFileSync(file, content);
|
|
274
|
-
const reader = new JsonlTailReader({ chunkSize: 16 });
|
|
275
|
-
|
|
276
|
-
expect(reader.read(file, 10, dedupSource, "", 4)).toEqual(dedupFullParse(content));
|
|
277
|
-
|
|
278
|
-
// The primary for k2 arrives after its mirror; the mirror must disappear.
|
|
279
|
-
const primary = JSON.stringify({ role: "assistant", text: "reply", key: "k2" }) + "\n";
|
|
280
|
-
fs.appendFileSync(file, primary);
|
|
281
|
-
content += primary;
|
|
282
|
-
expect(reader.read(file, 10, dedupSource, "", 4)).toEqual(dedupFullParse(content));
|
|
283
|
-
expect(dedupFullParse(content)).toHaveLength(2);
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
it("stays correct for long append sequences while bounding the retained window", () => {
|
|
287
|
-
fs.writeFileSync(file, "");
|
|
288
|
-
const reader = new JsonlTailReader({ chunkSize: 64 });
|
|
289
|
-
let content = "";
|
|
290
|
-
for (let i = 0; i < 200; i++) {
|
|
291
|
-
const chunk =
|
|
292
|
-
JSON.stringify({ role: "user", text: `q${i}`, key: `u${i}` }) +
|
|
293
|
-
"\n" +
|
|
294
|
-
JSON.stringify({ role: "user", text: `q${i}`, key: `u${i}`, mirror: true }) +
|
|
295
|
-
"\n";
|
|
296
|
-
fs.appendFileSync(file, chunk);
|
|
297
|
-
content += chunk;
|
|
298
|
-
expect(reader.read(file, 5, dedupSource, "", 4)).toEqual(last(dedupFullParse(content), 5));
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
it("evicts least-recently-used files beyond maxFiles", () => {
|
|
303
|
-
const reader = new JsonlTailReader({ maxFiles: 2 });
|
|
304
|
-
const files = ["a", "b", "c"].map((name) => {
|
|
305
|
-
const p = path.join(tmpDir, `${name}.jsonl`);
|
|
306
|
-
fs.writeFileSync(p, mixedContent(5));
|
|
307
|
-
return p;
|
|
308
|
-
});
|
|
309
|
-
for (const p of files) reader.read(p, 3, simpleSource);
|
|
310
|
-
|
|
311
|
-
readBytes.total = 0;
|
|
312
|
-
reader.read(files[2], 3, simpleSource);
|
|
313
|
-
expect(readBytes.total).toBe(0);
|
|
314
|
-
reader.read(files[0], 3, simpleSource);
|
|
315
|
-
expect(readBytes.total).toBeGreaterThan(0);
|
|
316
|
-
});
|
|
317
|
-
});
|