@ai-devkit/agent-manager 0.43.0 → 0.44.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/harnesses/pi/PiAdapter.d.ts.map +1 -1
- package/dist/harnesses/pi/PiAdapter.js +9 -4
- package/dist/harnesses/pi/PiAdapter.js.map +1 -1
- package/package.json +8 -3
- package/.swcrc +0 -27
- package/dist/__tests__/AgentManager.test.js +0 -1727
- package/dist/__tests__/AgentManager.test.js.map +0 -1
- package/dist/__tests__/adapters/IncrementalSessionRefresh.test.js +0 -486
- package/dist/__tests__/adapters/IncrementalSessionRefresh.test.js.map +0 -1
- package/dist/__tests__/adapters/adapterProcessImports.test.js +0 -52
- package/dist/__tests__/adapters/adapterProcessImports.test.js.map +0 -1
- package/dist/__tests__/adapters/adapterSnapshotCandidates.test.js +0 -247
- package/dist/__tests__/adapters/adapterSnapshotCandidates.test.js.map +0 -1
- package/dist/__tests__/capacity/anthropic.test.js +0 -115
- package/dist/__tests__/capacity/anthropic.test.js.map +0 -1
- package/dist/__tests__/capacity/boundaries.test.js +0 -45
- package/dist/__tests__/capacity/boundaries.test.js.map +0 -1
- package/dist/__tests__/capacity/claude.test.js +0 -485
- package/dist/__tests__/capacity/claude.test.js.map +0 -1
- package/dist/__tests__/capacity/codex.test.js +0 -339
- package/dist/__tests__/capacity/codex.test.js.map +0 -1
- package/dist/__tests__/capacity/devin.test.js +0 -239
- package/dist/__tests__/capacity/devin.test.js.map +0 -1
- package/dist/__tests__/capacity/index.test.js +0 -53
- package/dist/__tests__/capacity/index.test.js.map +0 -1
- package/dist/__tests__/capacity/openai.test.js +0 -687
- package/dist/__tests__/capacity/openai.test.js.map +0 -1
- package/dist/__tests__/capacity/wham.test.js +0 -159
- package/dist/__tests__/capacity/wham.test.js.map +0 -1
- package/dist/__tests__/capacity/zai.test.js +0 -212
- package/dist/__tests__/capacity/zai.test.js.map +0 -1
- package/dist/__tests__/fixtures.test.js +0 -218
- package/dist/__tests__/fixtures.test.js.map +0 -1
- package/dist/__tests__/harnesses/BoundedSummarySkip.test.js +0 -568
- package/dist/__tests__/harnesses/BoundedSummarySkip.test.js.map +0 -1
- package/dist/__tests__/harnesses/SessionSummaryEquivalence.test.js +0 -1089
- package/dist/__tests__/harnesses/SessionSummaryEquivalence.test.js.map +0 -1
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.js +0 -143
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.js.map +0 -1
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.js +0 -462
- package/dist/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/builtinAdapters.test.js +0 -33
- package/dist/__tests__/harnesses/builtinAdapters.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeAgentMapper.test.js +0 -79
- package/dist/__tests__/harnesses/claude/ClaudeAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeCodeAdapter.test.js +0 -1881
- package/dist/__tests__/harnesses/claude/ClaudeCodeAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeSessionLocator.test.js +0 -425
- package/dist/__tests__/harnesses/claude/ClaudeSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/ClaudeSessionParser.test.js +0 -314
- package/dist/__tests__/harnesses/claude/ClaudeSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.js +0 -49
- package/dist/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.js +0 -76
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.js +0 -173
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.js.map +0 -1
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.js +0 -181
- package/dist/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexAdapter.test.js +0 -685
- package/dist/__tests__/harnesses/codex/CodexAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexSessionLocator.test.js +0 -463
- package/dist/__tests__/harnesses/codex/CodexSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexSessionMapping.test.js +0 -86
- package/dist/__tests__/harnesses/codex/CodexSessionMapping.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/CodexSessionParser.test.js +0 -254
- package/dist/__tests__/harnesses/codex/CodexSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexCliProbe.test.js +0 -121
- package/dist/__tests__/harnesses/codex/durable/CodexCliProbe.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.js +0 -84
- package/dist/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.js +0 -128
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.js +0 -246
- package/dist/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.js.map +0 -1
- package/dist/__tests__/harnesses/codex/durable/CodexPrintRunner.test.js +0 -384
- package/dist/__tests__/harnesses/codex/durable/CodexPrintRunner.test.js.map +0 -1
- package/dist/__tests__/harnesses/copilot/CopilotAdapter.test.js +0 -659
- package/dist/__tests__/harnesses/copilot/CopilotAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/copilot/CopilotRefreshIO.test.js +0 -290
- package/dist/__tests__/harnesses/copilot/CopilotRefreshIO.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinAdapter.test.js +0 -597
- package/dist/__tests__/harnesses/devin/DevinAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinAgentMapper.test.js +0 -99
- package/dist/__tests__/harnesses/devin/DevinAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinSessionLocator.test.js +0 -192
- package/dist/__tests__/harnesses/devin/DevinSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/DevinSessionParser.test.js +0 -407
- package/dist/__tests__/harnesses/devin/DevinSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/devin/fixtures.js +0 -95
- package/dist/__tests__/harnesses/devin/fixtures.js.map +0 -1
- package/dist/__tests__/harnesses/gemini/GeminiCliAdapter.test.js +0 -1454
- package/dist/__tests__/harnesses/gemini/GeminiCliAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/gemini/GeminiSessionJsonl.test.js +0 -491
- package/dist/__tests__/harnesses/gemini/GeminiSessionJsonl.test.js.map +0 -1
- package/dist/__tests__/harnesses/gemini/GeminiSessionLocator.test.js +0 -399
- package/dist/__tests__/harnesses/gemini/GeminiSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokAgentMapper.test.js +0 -56
- package/dist/__tests__/harnesses/grok/GrokAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokCliAdapter.test.js +0 -421
- package/dist/__tests__/harnesses/grok/GrokCliAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokIncrementalRefresh.test.js +0 -167
- package/dist/__tests__/harnesses/grok/GrokIncrementalRefresh.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokSessionLocator.test.js +0 -133
- package/dist/__tests__/harnesses/grok/GrokSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/grok/GrokSessionParser.test.js +0 -301
- package/dist/__tests__/harnesses/grok/GrokSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/kiro/KiroAdapter.test.js +0 -662
- package/dist/__tests__/harnesses/kiro/KiroAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseAdapter.test.js +0 -247
- package/dist/__tests__/harnesses/muse/MuseAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseAgentMapper.test.js +0 -81
- package/dist/__tests__/harnesses/muse/MuseAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseSessionLocator.test.js +0 -185
- package/dist/__tests__/harnesses/muse/MuseSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/muse/MuseSessionParser.test.js +0 -328
- package/dist/__tests__/harnesses/muse/MuseSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeAdapter.test.js +0 -213
- package/dist/__tests__/harnesses/opencode/OpenCodeAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.js +0 -108
- package/dist/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.js +0 -94
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.js.map +0 -1
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionParser.test.js +0 -147
- package/dist/__tests__/harnesses/opencode/OpenCodeSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiAdapter.test.js +0 -367
- package/dist/__tests__/harnesses/pi/PiAdapter.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiDiscoveryIO.test.js +0 -382
- package/dist/__tests__/harnesses/pi/PiDiscoveryIO.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiSessionParser.test.js +0 -416
- package/dist/__tests__/harnesses/pi/PiSessionParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/PiSessionTracker.test.js +0 -108
- package/dist/__tests__/harnesses/pi/PiSessionTracker.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiCliProbe.test.js +0 -70
- package/dist/__tests__/harnesses/pi/durable/PiCliProbe.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.js +0 -43
- package/dist/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiPrintAgentService.test.js +0 -192
- package/dist/__tests__/harnesses/pi/durable/PiPrintAgentService.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiPrintProtocol.test.js +0 -119
- package/dist/__tests__/harnesses/pi/durable/PiPrintProtocol.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiPrintRunner.test.js +0 -382
- package/dist/__tests__/harnesses/pi/durable/PiPrintRunner.test.js.map +0 -1
- package/dist/__tests__/harnesses/pi/durable/PiStreamParser.test.js +0 -34
- package/dist/__tests__/harnesses/pi/durable/PiStreamParser.test.js.map +0 -1
- package/dist/__tests__/harnesses/readiness/AgentReadiness.test.js +0 -446
- package/dist/__tests__/harnesses/readiness/AgentReadiness.test.js.map +0 -1
- package/dist/__tests__/harnesses/runtimeProfiles.test.js +0 -101
- package/dist/__tests__/harnesses/runtimeProfiles.test.js.map +0 -1
- package/dist/__tests__/print/DurableAgent.test.js +0 -15
- package/dist/__tests__/print/DurableAgent.test.js.map +0 -1
- package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js +0 -186
- package/dist/__tests__/print/DurableAgentRepository.sqlite.test.js.map +0 -1
- package/dist/__tests__/print/DurableAgentRepository.test.js +0 -249
- package/dist/__tests__/print/DurableAgentRepository.test.js.map +0 -1
- package/dist/__tests__/readiness-fixtures.test.js +0 -54
- package/dist/__tests__/readiness-fixtures.test.js.map +0 -1
- package/dist/__tests__/runtime/AgentRuntime.test.js +0 -13
- package/dist/__tests__/runtime/AgentRuntime.test.js.map +0 -1
- package/dist/__tests__/runtime/HerdrAgentDiscovery.test.js +0 -164
- package/dist/__tests__/runtime/HerdrAgentDiscovery.test.js.map +0 -1
- package/dist/__tests__/runtime/HerdrAgentRuntime.test.js +0 -488
- package/dist/__tests__/runtime/HerdrAgentRuntime.test.js.map +0 -1
- package/dist/__tests__/runtime/ManagedAgentRuntime.test.js +0 -637
- package/dist/__tests__/runtime/ManagedAgentRuntime.test.js.map +0 -1
- package/dist/__tests__/terminal/GhosttyBackend.test.js +0 -334
- package/dist/__tests__/terminal/GhosttyBackend.test.js.map +0 -1
- package/dist/__tests__/terminal/TerminalFocusManager.test.js +0 -253
- package/dist/__tests__/terminal/TerminalFocusManager.test.js.map +0 -1
- package/dist/__tests__/terminal/TmuxManager.test.js +0 -168
- package/dist/__tests__/terminal/TmuxManager.test.js.map +0 -1
- package/dist/__tests__/terminal/TtyWriter.test.js +0 -386
- package/dist/__tests__/terminal/TtyWriter.test.js.map +0 -1
- package/dist/__tests__/utils/AgentRegistry.test.js +0 -636
- package/dist/__tests__/utils/AgentRegistry.test.js.map +0 -1
- package/dist/__tests__/utils/IncrementalJsonlSummary.test.js +0 -650
- package/dist/__tests__/utils/IncrementalJsonlSummary.test.js.map +0 -1
- package/dist/__tests__/utils/agent-requests.test.js +0 -90
- package/dist/__tests__/utils/agent-requests.test.js.map +0 -1
- package/dist/__tests__/utils/conversationTail.bench.test.js +0 -258
- package/dist/__tests__/utils/conversationTail.bench.test.js.map +0 -1
- package/dist/__tests__/utils/conversationTailParity.test.js +0 -588
- package/dist/__tests__/utils/conversationTailParity.test.js.map +0 -1
- package/dist/__tests__/utils/jsonlTail.test.js +0 -360
- package/dist/__tests__/utils/jsonlTail.test.js.map +0 -1
- package/dist/__tests__/utils/matching.test.js +0 -324
- package/dist/__tests__/utils/matching.test.js.map +0 -1
- package/dist/__tests__/utils/matchingConstants.test.js +0 -35
- package/dist/__tests__/utils/matchingConstants.test.js.map +0 -1
- package/dist/__tests__/utils/process.test.js +0 -818
- package/dist/__tests__/utils/process.test.js.map +0 -1
- package/dist/__tests__/utils/session.test.js +0 -175
- package/dist/__tests__/utils/session.test.js.map +0 -1
- package/project.json +0 -29
- package/scripts/benchmark-cold-start.mjs +0 -350
- package/src/AgentManager.ts +0 -559
- package/src/__tests__/AgentManager.test.ts +0 -1578
- package/src/__tests__/adapters/IncrementalSessionRefresh.test.ts +0 -437
- package/src/__tests__/adapters/adapterProcessImports.test.ts +0 -58
- package/src/__tests__/adapters/adapterSnapshotCandidates.test.ts +0 -243
- package/src/__tests__/capacity/anthropic.test.ts +0 -105
- package/src/__tests__/capacity/boundaries.test.ts +0 -36
- package/src/__tests__/capacity/claude.test.ts +0 -462
- package/src/__tests__/capacity/codex.test.ts +0 -311
- package/src/__tests__/capacity/devin.test.ts +0 -210
- package/src/__tests__/capacity/fixtures/claude-credentials.json +0 -7
- package/src/__tests__/capacity/fixtures/claude-usage-malformed.json +0 -1
- package/src/__tests__/capacity/fixtures/claude-usage-partial.json +0 -15
- package/src/__tests__/capacity/fixtures/claude-usage.json +0 -63
- package/src/__tests__/capacity/fixtures/devin-config.json +0 -6
- package/src/__tests__/capacity/fixtures/devin-credentials.toml +0 -4
- package/src/__tests__/capacity/fixtures/devin-quota-nonplan.json +0 -5
- package/src/__tests__/capacity/fixtures/devin-quota.json +0 -10
- package/src/__tests__/capacity/fixtures/openai-auth.json +0 -6
- package/src/__tests__/capacity/fixtures/openai-codex-auth.json +0 -9
- package/src/__tests__/capacity/fixtures/openai-usage-completions.json +0 -67
- package/src/__tests__/capacity/fixtures/openai-usage-responses.json +0 -20
- package/src/__tests__/capacity/fixtures/wham-usage.json +0 -45
- package/src/__tests__/capacity/fixtures/zai-auth.json +0 -6
- package/src/__tests__/capacity/fixtures/zai-quota-invalid.json +0 -7
- package/src/__tests__/capacity/fixtures/zai-quota.json +0 -38
- package/src/__tests__/capacity/index.test.ts +0 -54
- package/src/__tests__/capacity/openai.test.ts +0 -571
- package/src/__tests__/capacity/wham.test.ts +0 -122
- package/src/__tests__/capacity/zai.test.ts +0 -151
- package/src/__tests__/fixtures.test.ts +0 -245
- package/src/__tests__/harnesses/BoundedSummarySkip.test.ts +0 -496
- package/src/__tests__/harnesses/SessionSummaryEquivalence.test.ts +0 -726
- package/src/__tests__/harnesses/antigravity/AntigravityCliAdapter.subprocess.test.ts +0 -133
- package/src/__tests__/harnesses/antigravity/AntigravityCliAdapter.test.ts +0 -396
- package/src/__tests__/harnesses/builtinAdapters.test.ts +0 -33
- package/src/__tests__/harnesses/claude/ClaudeAgentMapper.test.ts +0 -84
- package/src/__tests__/harnesses/claude/ClaudeCodeAdapter.test.ts +0 -1793
- package/src/__tests__/harnesses/claude/ClaudeSessionLocator.test.ts +0 -423
- package/src/__tests__/harnesses/claude/ClaudeSessionParser.test.ts +0 -300
- package/src/__tests__/harnesses/claude/durable/ClaudeCliProbe.test.ts +0 -34
- package/src/__tests__/harnesses/claude/durable/ClaudePrintAgent.integration.test.ts +0 -61
- package/src/__tests__/harnesses/claude/durable/ClaudePrintAgentService.test.ts +0 -129
- package/src/__tests__/harnesses/claude/durable/ClaudePrintRunner.test.ts +0 -152
- package/src/__tests__/harnesses/codex/CodexAdapter.test.ts +0 -652
- package/src/__tests__/harnesses/codex/CodexSessionLocator.test.ts +0 -419
- package/src/__tests__/harnesses/codex/CodexSessionMapping.test.ts +0 -63
- package/src/__tests__/harnesses/codex/CodexSessionParser.test.ts +0 -192
- package/src/__tests__/harnesses/codex/durable/CodexCliProbe.test.ts +0 -80
- package/src/__tests__/harnesses/codex/durable/CodexDurableAgentRepository.test.ts +0 -65
- package/src/__tests__/harnesses/codex/durable/CodexPrintAgent.integration.test.ts +0 -104
- package/src/__tests__/harnesses/codex/durable/CodexPrintAgentService.test.ts +0 -201
- package/src/__tests__/harnesses/codex/durable/CodexPrintRunner.test.ts +0 -299
- package/src/__tests__/harnesses/copilot/CopilotAdapter.test.ts +0 -614
- package/src/__tests__/harnesses/copilot/CopilotRefreshIO.test.ts +0 -270
- package/src/__tests__/harnesses/devin/DevinAdapter.test.ts +0 -290
- package/src/__tests__/harnesses/devin/DevinAgentMapper.test.ts +0 -101
- package/src/__tests__/harnesses/devin/DevinSessionLocator.test.ts +0 -139
- package/src/__tests__/harnesses/devin/DevinSessionParser.test.ts +0 -212
- package/src/__tests__/harnesses/devin/fixtures.ts +0 -144
- package/src/__tests__/harnesses/gemini/GeminiCliAdapter.test.ts +0 -1336
- package/src/__tests__/harnesses/gemini/GeminiSessionJsonl.test.ts +0 -402
- package/src/__tests__/harnesses/gemini/GeminiSessionLocator.test.ts +0 -396
- package/src/__tests__/harnesses/grok/GrokAgentMapper.test.ts +0 -57
- package/src/__tests__/harnesses/grok/GrokCliAdapter.test.ts +0 -376
- package/src/__tests__/harnesses/grok/GrokIncrementalRefresh.test.ts +0 -170
- package/src/__tests__/harnesses/grok/GrokSessionLocator.test.ts +0 -106
- package/src/__tests__/harnesses/grok/GrokSessionParser.test.ts +0 -230
- package/src/__tests__/harnesses/kiro/KiroAdapter.test.ts +0 -552
- package/src/__tests__/harnesses/muse/MuseAdapter.test.ts +0 -197
- package/src/__tests__/harnesses/muse/MuseAgentMapper.test.ts +0 -83
- package/src/__tests__/harnesses/muse/MuseSessionLocator.test.ts +0 -177
- package/src/__tests__/harnesses/muse/MuseSessionParser.test.ts +0 -279
- package/src/__tests__/harnesses/opencode/OpenCodeAdapter.test.ts +0 -215
- package/src/__tests__/harnesses/opencode/OpenCodeAgentMapper.test.ts +0 -101
- package/src/__tests__/harnesses/opencode/OpenCodeSessionLocator.test.ts +0 -84
- package/src/__tests__/harnesses/opencode/OpenCodeSessionParser.test.ts +0 -149
- package/src/__tests__/harnesses/pi/PiAdapter.test.ts +0 -325
- package/src/__tests__/harnesses/pi/PiDiscoveryIO.test.ts +0 -337
- package/src/__tests__/harnesses/pi/PiSessionParser.test.ts +0 -280
- package/src/__tests__/harnesses/pi/PiSessionTracker.test.ts +0 -79
- package/src/__tests__/harnesses/pi/durable/PiCliProbe.test.ts +0 -50
- package/src/__tests__/harnesses/pi/durable/PiDurableAgentRepository.test.ts +0 -33
- package/src/__tests__/harnesses/pi/durable/PiPrintAgentService.test.ts +0 -138
- package/src/__tests__/harnesses/pi/durable/PiPrintProtocol.test.ts +0 -71
- package/src/__tests__/harnesses/pi/durable/PiPrintRunner.test.ts +0 -252
- package/src/__tests__/harnesses/pi/durable/PiStreamParser.test.ts +0 -26
- package/src/__tests__/harnesses/readiness/AgentReadiness.test.ts +0 -362
- package/src/__tests__/harnesses/runtimeProfiles.test.ts +0 -123
- package/src/__tests__/print/DurableAgent.test.ts +0 -15
- package/src/__tests__/print/DurableAgentRepository.sqlite.test.ts +0 -128
- package/src/__tests__/print/DurableAgentRepository.test.ts +0 -184
- package/src/__tests__/readiness-fixtures.test.ts +0 -79
- package/src/__tests__/runtime/AgentRuntime.test.ts +0 -8
- package/src/__tests__/runtime/HerdrAgentDiscovery.test.ts +0 -131
- package/src/__tests__/runtime/HerdrAgentRuntime.test.ts +0 -377
- package/src/__tests__/runtime/ManagedAgentRuntime.test.ts +0 -590
- package/src/__tests__/terminal/GhosttyBackend.test.ts +0 -271
- package/src/__tests__/terminal/TerminalFocusManager.test.ts +0 -280
- package/src/__tests__/terminal/TmuxManager.test.ts +0 -185
- package/src/__tests__/terminal/TtyWriter.test.ts +0 -454
- package/src/__tests__/utils/AgentRegistry.test.ts +0 -532
- package/src/__tests__/utils/IncrementalJsonlSummary.test.ts +0 -414
- package/src/__tests__/utils/agent-requests.test.ts +0 -94
- package/src/__tests__/utils/conversationTail.bench.test.ts +0 -193
- package/src/__tests__/utils/conversationTailParity.test.ts +0 -365
- package/src/__tests__/utils/jsonlTail.test.ts +0 -317
- package/src/__tests__/utils/matching.test.ts +0 -234
- package/src/__tests__/utils/matchingConstants.test.ts +0 -40
- package/src/__tests__/utils/process.test.ts +0 -596
- package/src/__tests__/utils/session.test.ts +0 -158
- package/src/adapters/AgentAdapter.ts +0 -255
- package/src/capacity/index.ts +0 -127
- package/src/capacity/providers/anthropic.ts +0 -198
- package/src/capacity/providers/devin.ts +0 -121
- package/src/capacity/providers/openai-platform.ts +0 -150
- package/src/capacity/providers/openai-subscription.ts +0 -184
- package/src/capacity/providers/zai.ts +0 -155
- package/src/capacity/sources/claude.ts +0 -30
- package/src/capacity/sources/codex.ts +0 -251
- package/src/capacity/sources/devin.ts +0 -49
- package/src/capacity/sources/pi.ts +0 -131
- package/src/capacity/types.ts +0 -29
- package/src/database/connection.ts +0 -96
- package/src/database/index.ts +0 -7
- package/src/database/migrations/001_initial.sql +0 -12
- package/src/database/migrations/002_pins.sql +0 -1
- package/src/database/migrations/003_durable_agents.sql +0 -43
- package/src/database/migrations/004_codex_durable_sessions.sql +0 -1
- package/src/database/migrations/005_agent_runtime.sql +0 -2
- package/src/database/schema.ts +0 -64
- package/src/durable/DurableAgent.ts +0 -139
- package/src/durable/DurableAgentRepository.ts +0 -485
- package/src/durable/process.ts +0 -29
- package/src/durable/run.ts +0 -84
- package/src/durable/utils.ts +0 -66
- package/src/fixtures/bundle.ts +0 -130
- package/src/fixtures/capture.ts +0 -364
- package/src/harnesses/antigravity/AntigravityAgentMapper.ts +0 -34
- package/src/harnesses/antigravity/AntigravityCliAdapter.ts +0 -126
- package/src/harnesses/antigravity/AntigravitySessionLocator.ts +0 -75
- package/src/harnesses/antigravity/AntigravitySessionParser.ts +0 -252
- package/src/harnesses/claude/ClaudeAgentMapper.ts +0 -55
- package/src/harnesses/claude/ClaudeCodeAdapter.ts +0 -175
- package/src/harnesses/claude/ClaudeSessionLocator.ts +0 -358
- package/src/harnesses/claude/ClaudeSessionParser.ts +0 -524
- package/src/harnesses/claude/credentials.ts +0 -122
- package/src/harnesses/claude/durable/ClaudeCliProbe.ts +0 -57
- package/src/harnesses/claude/durable/ClaudePrintAgentService.ts +0 -79
- package/src/harnesses/claude/durable/ClaudePrintRunner.ts +0 -102
- package/src/harnesses/claude/durable/ClaudeStreamParser.ts +0 -108
- package/src/harnesses/claude/readiness.ts +0 -69
- package/src/harnesses/codex/CodexAdapter.ts +0 -337
- package/src/harnesses/codex/CodexAgentMapper.ts +0 -26
- package/src/harnesses/codex/CodexSessionLocator.ts +0 -509
- package/src/harnesses/codex/CodexSessionMapping.ts +0 -89
- package/src/harnesses/codex/CodexSessionParser.ts +0 -462
- package/src/harnesses/codex/credentials.ts +0 -81
- package/src/harnesses/codex/durable/CodexCliProbe.ts +0 -68
- package/src/harnesses/codex/durable/CodexPrintAgentService.ts +0 -79
- package/src/harnesses/codex/durable/CodexPrintRunner.ts +0 -104
- package/src/harnesses/codex/durable/CodexStreamParser.ts +0 -117
- package/src/harnesses/codex/readiness.ts +0 -72
- package/src/harnesses/copilot/CopilotAdapter.ts +0 -161
- package/src/harnesses/copilot/CopilotAgentMapper.ts +0 -27
- package/src/harnesses/copilot/CopilotSessionLocator.ts +0 -161
- package/src/harnesses/copilot/CopilotSessionParser.ts +0 -380
- package/src/harnesses/copilot/readiness.ts +0 -33
- package/src/harnesses/devin/DevinAdapter.ts +0 -212
- package/src/harnesses/devin/DevinAgentMapper.ts +0 -39
- package/src/harnesses/devin/DevinSessionLocator.ts +0 -230
- package/src/harnesses/devin/DevinSessionParser.ts +0 -227
- package/src/harnesses/devin/credentials.ts +0 -88
- package/src/harnesses/devin/readiness.ts +0 -36
- package/src/harnesses/gemini/GeminiAgentMapper.ts +0 -27
- package/src/harnesses/gemini/GeminiCliAdapter.ts +0 -272
- package/src/harnesses/gemini/GeminiSessionLocator.ts +0 -394
- package/src/harnesses/gemini/GeminiSessionParser.ts +0 -395
- package/src/harnesses/gemini/fileSignature.ts +0 -10
- package/src/harnesses/grok/GrokAgentMapper.ts +0 -32
- package/src/harnesses/grok/GrokCliAdapter.ts +0 -126
- package/src/harnesses/grok/GrokSessionLocator.ts +0 -179
- package/src/harnesses/grok/GrokSessionParser.ts +0 -251
- package/src/harnesses/index.ts +0 -32
- package/src/harnesses/kiro/KiroAdapter.ts +0 -143
- package/src/harnesses/kiro/KiroAgentMapper.ts +0 -34
- package/src/harnesses/kiro/KiroSessionLocator.ts +0 -143
- package/src/harnesses/kiro/KiroSessionParser.ts +0 -376
- package/src/harnesses/muse/MuseAdapter.ts +0 -157
- package/src/harnesses/muse/MuseAgentMapper.ts +0 -33
- package/src/harnesses/muse/MuseSessionLocator.ts +0 -286
- package/src/harnesses/muse/MuseSessionParser.ts +0 -435
- package/src/harnesses/muse/readiness.ts +0 -38
- package/src/harnesses/opencode/OpenCodeAdapter.ts +0 -110
- package/src/harnesses/opencode/OpenCodeAgentMapper.ts +0 -49
- package/src/harnesses/opencode/OpenCodeSessionLocator.ts +0 -151
- package/src/harnesses/opencode/OpenCodeSessionParser.ts +0 -146
- package/src/harnesses/opencode/readiness.ts +0 -48
- package/src/harnesses/pi/PiAdapter.ts +0 -197
- package/src/harnesses/pi/PiAgentMapper.ts +0 -27
- package/src/harnesses/pi/PiSessionLocator.ts +0 -288
- package/src/harnesses/pi/PiSessionParser.ts +0 -488
- package/src/harnesses/pi/PiSessionTracker.ts +0 -87
- package/src/harnesses/pi/credentials.ts +0 -129
- package/src/harnesses/pi/durable/PiCliProbe.ts +0 -56
- package/src/harnesses/pi/durable/PiPrintAgentService.ts +0 -77
- package/src/harnesses/pi/durable/PiPrintProtocol.ts +0 -41
- package/src/harnesses/pi/durable/PiPrintRunner.ts +0 -95
- package/src/harnesses/pi/durable/PiStreamParser.ts +0 -94
- package/src/harnesses/pi/readiness.ts +0 -104
- package/src/harnesses/readiness/AgentReadiness.ts +0 -91
- package/src/harnesses/readiness/checks.ts +0 -336
- package/src/harnesses/readiness/types.ts +0 -90
- package/src/harnesses/runtimeProfiles.ts +0 -105
- package/src/harnesses/shared.ts +0 -124
- package/src/index.ts +0 -71
- package/src/runtime/ManagedAgentRuntime.ts +0 -253
- package/src/runtime/RuntimeFactory.ts +0 -13
- package/src/runtime/errors.ts +0 -50
- package/src/runtime/herdr/HerdrAgentDiscovery.ts +0 -166
- package/src/runtime/herdr/HerdrAgentRuntime.ts +0 -216
- package/src/runtime/herdr/HerdrCliClient.ts +0 -78
- package/src/runtime/herdr/HerdrErrors.ts +0 -9
- package/src/runtime/herdr/HerdrResponseParsers.ts +0 -86
- package/src/runtime/herdr/HerdrRuntimeRef.ts +0 -41
- package/src/runtime/tmux/PidPolling.ts +0 -34
- package/src/runtime/tmux/TmuxAgentRuntime.ts +0 -113
- package/src/runtime/tmux/TmuxManager.ts +0 -102
- package/src/runtime/tmux/TmuxRuntimeRef.ts +0 -9
- package/src/runtime/types.ts +0 -56
- package/src/terminal/TerminalFocusManager.ts +0 -52
- package/src/terminal/TtyWriter.ts +0 -26
- package/src/terminal/backends/ghostty.ts +0 -180
- package/src/terminal/backends/index.ts +0 -23
- package/src/terminal/backends/iterm2.ts +0 -126
- package/src/terminal/backends/shared.ts +0 -47
- package/src/terminal/backends/terminal-app.ts +0 -122
- package/src/terminal/backends/tmux.ts +0 -62
- package/src/terminal/backends/wezterm.ts +0 -65
- package/src/terminal/types.ts +0 -23
- package/src/utils/AgentRegistry.ts +0 -351
- package/src/utils/IncrementalJsonlSummary.ts +0 -306
- package/src/utils/agent-requests.ts +0 -28
- package/src/utils/applescript.ts +0 -10
- package/src/utils/jsonlTail.ts +0 -349
- package/src/utils/matching.ts +0 -96
- package/src/utils/matchingConstants.ts +0 -15
- package/src/utils/process.ts +0 -604
- package/src/utils/session.ts +0 -144
- package/src/utils/sortAgents.ts +0 -54
- package/tsconfig.json +0 -11
- package/vitest.config.ts +0 -20
|
@@ -1,414 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import * as os from "os";
|
|
3
|
-
import * as path from "path";
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
DEFAULT_HEAD_BYTES,
|
|
7
|
-
DEFAULT_TAIL_BYTES,
|
|
8
|
-
IncrementalJsonlSummary,
|
|
9
|
-
reduceJsonlContent,
|
|
10
|
-
type JsonlSummaryReducer,
|
|
11
|
-
} from "../../utils/IncrementalJsonlSummary.js";
|
|
12
|
-
|
|
13
|
-
vi.mock("fs", async (importOriginal) => {
|
|
14
|
-
const actual = (await importOriginal()) as typeof import("fs");
|
|
15
|
-
return { ...actual, readSync: vi.fn(actual.readSync), readFileSync: vi.fn(actual.readFileSync) };
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
const mockedReadSync = vi.mocked(fs.readSync);
|
|
19
|
-
const mockedReadFileSync = vi.mocked(fs.readFileSync);
|
|
20
|
-
|
|
21
|
-
/** Records every parsed entry (malformed lines as "<bad>") plus a running count. */
|
|
22
|
-
interface RecordingState {
|
|
23
|
-
count: number;
|
|
24
|
-
entries: unknown[];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const recordingReducer: JsonlSummaryReducer<RecordingState> = {
|
|
28
|
-
initial: () => ({ count: 0, entries: [] }),
|
|
29
|
-
reduce: (state, entry) => ({
|
|
30
|
-
count: state.count + 1,
|
|
31
|
-
entries: [...state.entries, entry === undefined ? "<bad>" : entry],
|
|
32
|
-
}),
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
function bytesRead(): number {
|
|
36
|
-
let total = 0;
|
|
37
|
-
for (const result of mockedReadSync.mock.results) {
|
|
38
|
-
if (result.type === "return") total += result.value as number;
|
|
39
|
-
}
|
|
40
|
-
for (const result of mockedReadFileSync.mock.results) {
|
|
41
|
-
if (result.type === "return") total += Buffer.byteLength(result.value as string | Buffer);
|
|
42
|
-
}
|
|
43
|
-
return total;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function line(value: unknown): string {
|
|
47
|
-
return `${JSON.stringify(value)}\n`;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
describe("reduceJsonlContent", () => {
|
|
51
|
-
it("folds non-blank lines, passing undefined for malformed JSON", () => {
|
|
52
|
-
const state = reduceJsonlContent(recordingReducer, '\n \n{"a":1}\nnot json\n\n{"b":2}');
|
|
53
|
-
expect(state.entries).toEqual([{ a: 1 }, "<bad>", { b: 2 }]);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("returns the initial state for empty content", () => {
|
|
57
|
-
expect(reduceJsonlContent(recordingReducer, "")).toEqual({ count: 0, entries: [] });
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
describe("IncrementalJsonlSummary", () => {
|
|
62
|
-
let tmpDir: string;
|
|
63
|
-
let filePath: string;
|
|
64
|
-
let cache: IncrementalJsonlSummary<RecordingState>;
|
|
65
|
-
|
|
66
|
-
beforeEach(() => {
|
|
67
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "incremental-jsonl-"));
|
|
68
|
-
filePath = path.join(tmpDir, "session.jsonl");
|
|
69
|
-
cache = new IncrementalJsonlSummary(recordingReducer);
|
|
70
|
-
mockedReadSync.mockClear();
|
|
71
|
-
mockedReadFileSync.mockClear();
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
afterEach(() => {
|
|
75
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("returns null for a missing file", () => {
|
|
79
|
-
expect(cache.read(path.join(tmpDir, "missing.jsonl"))).toBeNull();
|
|
80
|
-
expect(cache.size).toBe(0);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("summarizes a file and reports its size and mtime", () => {
|
|
84
|
-
fs.writeFileSync(filePath, line({ a: 1 }) + line({ b: 2 }));
|
|
85
|
-
const stat = fs.statSync(filePath);
|
|
86
|
-
|
|
87
|
-
const result = cache.read(filePath);
|
|
88
|
-
|
|
89
|
-
expect(result?.state.entries).toEqual([{ a: 1 }, { b: 2 }]);
|
|
90
|
-
expect(result?.size).toBe(stat.size);
|
|
91
|
-
expect(result?.mtime).toEqual(stat.mtime);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it("reads 0 bytes when the file is unchanged", () => {
|
|
95
|
-
fs.writeFileSync(filePath, line({ a: 1 }) + line({ b: 2 }));
|
|
96
|
-
const first = cache.read(filePath);
|
|
97
|
-
mockedReadSync.mockClear();
|
|
98
|
-
mockedReadFileSync.mockClear();
|
|
99
|
-
|
|
100
|
-
const second = cache.read(filePath);
|
|
101
|
-
|
|
102
|
-
expect(bytesRead()).toBe(0);
|
|
103
|
-
expect(second?.state).toEqual(first?.state);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it("reads only the appended bytes when the file grows", () => {
|
|
107
|
-
fs.writeFileSync(filePath, line({ a: "x".repeat(200_000) }));
|
|
108
|
-
cache.read(filePath);
|
|
109
|
-
mockedReadSync.mockClear();
|
|
110
|
-
|
|
111
|
-
const appended = line({ b: 2 }) + line({ c: 3 });
|
|
112
|
-
fs.appendFileSync(filePath, appended);
|
|
113
|
-
const result = cache.read(filePath);
|
|
114
|
-
|
|
115
|
-
expect(bytesRead()).toBe(Buffer.byteLength(appended));
|
|
116
|
-
expect(result?.state.entries.slice(1)).toEqual([{ b: 2 }, { c: 3 }]);
|
|
117
|
-
expect(result?.state.count).toBe(3);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it("handles lines spanning read chunks and multi-byte characters", () => {
|
|
121
|
-
const small = new IncrementalJsonlSummary(recordingReducer, { chunkSize: 7 });
|
|
122
|
-
const entries = [{ text: "héllo wörld 👋" }, { text: "日本語のテキスト" }, { n: 3 }];
|
|
123
|
-
fs.writeFileSync(filePath, entries.map(line).join(""));
|
|
124
|
-
|
|
125
|
-
expect(small.read(filePath)?.state.entries).toEqual(entries);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it("does not reduce an unterminated line until it is complete, without duplicating it", () => {
|
|
129
|
-
fs.writeFileSync(filePath, line({ a: 1 }) + '{"b":');
|
|
130
|
-
expect(cache.read(filePath)?.state.entries).toEqual([{ a: 1 }]);
|
|
131
|
-
|
|
132
|
-
fs.appendFileSync(filePath, "2");
|
|
133
|
-
expect(cache.read(filePath)?.state.entries).toEqual([{ a: 1 }]);
|
|
134
|
-
|
|
135
|
-
fs.appendFileSync(filePath, "}\n");
|
|
136
|
-
expect(cache.read(filePath)?.state.entries).toEqual([{ a: 1 }, { b: 2 }]);
|
|
137
|
-
|
|
138
|
-
fs.appendFileSync(filePath, line({ c: 3 }));
|
|
139
|
-
expect(cache.read(filePath)?.state.entries).toEqual([{ a: 1 }, { b: 2 }, { c: 3 }]);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it("includes a valid unterminated last line in the result but re-reads it once terminated", () => {
|
|
143
|
-
fs.writeFileSync(filePath, line({ a: 1 }) + '{"b":2}');
|
|
144
|
-
expect(cache.read(filePath)?.state.entries).toEqual([{ a: 1 }, { b: 2 }]);
|
|
145
|
-
|
|
146
|
-
fs.appendFileSync(filePath, "\n" + line({ c: 3 }));
|
|
147
|
-
expect(cache.read(filePath)?.state.entries).toEqual([{ a: 1 }, { b: 2 }, { c: 3 }]);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it("matches a one-shot fold for every split point of an appended file", () => {
|
|
151
|
-
const content = [
|
|
152
|
-
line({ a: 1 }),
|
|
153
|
-
"\n",
|
|
154
|
-
"garbage\n",
|
|
155
|
-
line({ b: "ünïcode" }),
|
|
156
|
-
line({ c: [1, 2, 3] }),
|
|
157
|
-
'{"d":4}',
|
|
158
|
-
].join("");
|
|
159
|
-
const buffer = Buffer.from(content);
|
|
160
|
-
const expected = reduceJsonlContent(recordingReducer, content);
|
|
161
|
-
|
|
162
|
-
for (let split = 0; split <= buffer.length; split++) {
|
|
163
|
-
const splitCache = new IncrementalJsonlSummary(recordingReducer, { chunkSize: 5 });
|
|
164
|
-
fs.writeFileSync(filePath, buffer.subarray(0, split));
|
|
165
|
-
splitCache.read(filePath);
|
|
166
|
-
fs.appendFileSync(filePath, buffer.subarray(split));
|
|
167
|
-
expect(splitCache.read(filePath)?.state).toEqual(expected);
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it("rebuilds when the file shrinks", () => {
|
|
172
|
-
fs.writeFileSync(filePath, line({ a: 1 }) + line({ b: 2 }));
|
|
173
|
-
cache.read(filePath);
|
|
174
|
-
|
|
175
|
-
fs.writeFileSync(filePath, line({ z: 9 }));
|
|
176
|
-
|
|
177
|
-
expect(cache.read(filePath)?.state.entries).toEqual([{ z: 9 }]);
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it("rebuilds when the file is replaced by a different inode", () => {
|
|
181
|
-
fs.writeFileSync(filePath, line({ a: 1 }));
|
|
182
|
-
cache.read(filePath);
|
|
183
|
-
|
|
184
|
-
const replacement = path.join(tmpDir, "replacement.jsonl");
|
|
185
|
-
fs.writeFileSync(replacement, line({ a: 1 }) + line({ rotated: true }));
|
|
186
|
-
fs.renameSync(replacement, filePath);
|
|
187
|
-
|
|
188
|
-
expect(cache.read(filePath)?.state.entries).toEqual([{ a: 1 }, { rotated: true }]);
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
it("rebuilds when the size is unchanged but the mtime moved", () => {
|
|
192
|
-
fs.writeFileSync(filePath, line({ a: 1 }));
|
|
193
|
-
cache.read(filePath);
|
|
194
|
-
|
|
195
|
-
fs.writeFileSync(filePath, line({ b: 2 }));
|
|
196
|
-
const future = new Date(Date.now() + 10_000);
|
|
197
|
-
fs.utimesSync(filePath, future, future);
|
|
198
|
-
|
|
199
|
-
expect(cache.read(filePath)?.state.entries).toEqual([{ b: 2 }]);
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
it("drops the entry when a cached file disappears", () => {
|
|
203
|
-
fs.writeFileSync(filePath, line({ a: 1 }));
|
|
204
|
-
cache.read(filePath);
|
|
205
|
-
fs.rmSync(filePath);
|
|
206
|
-
|
|
207
|
-
expect(cache.read(filePath)).toBeNull();
|
|
208
|
-
expect(cache.size).toBe(0);
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it("evicts entries not read since the previous prune", () => {
|
|
212
|
-
const other = path.join(tmpDir, "other.jsonl");
|
|
213
|
-
fs.writeFileSync(filePath, line({ a: 1 }));
|
|
214
|
-
fs.writeFileSync(other, line({ b: 2 }));
|
|
215
|
-
|
|
216
|
-
cache.read(filePath);
|
|
217
|
-
cache.read(other);
|
|
218
|
-
cache.prune();
|
|
219
|
-
expect(cache.size).toBe(2);
|
|
220
|
-
|
|
221
|
-
cache.read(filePath);
|
|
222
|
-
cache.prune();
|
|
223
|
-
expect(cache.size).toBe(1);
|
|
224
|
-
|
|
225
|
-
cache.prune();
|
|
226
|
-
expect(cache.size).toBe(0);
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
it("keeps only reducer state and stat metadata per entry", () => {
|
|
230
|
-
fs.writeFileSync(filePath, line({ a: "x".repeat(10_000) }) + '{"partial":');
|
|
231
|
-
cache.read(filePath);
|
|
232
|
-
|
|
233
|
-
const entry = (cache as any).entries.get(filePath);
|
|
234
|
-
expect(Object.keys(entry).sort()).toEqual(
|
|
235
|
-
[
|
|
236
|
-
"committed",
|
|
237
|
-
"dev",
|
|
238
|
-
"discarding",
|
|
239
|
-
"ino",
|
|
240
|
-
"mtime",
|
|
241
|
-
"mtimeMs",
|
|
242
|
-
"offset",
|
|
243
|
-
"seen",
|
|
244
|
-
"size",
|
|
245
|
-
"skippedBytes",
|
|
246
|
-
"state",
|
|
247
|
-
].sort(),
|
|
248
|
-
);
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
describe("IncrementalJsonlSummary bounded cold start", () => {
|
|
253
|
-
let tmpDir: string;
|
|
254
|
-
let filePath: string;
|
|
255
|
-
|
|
256
|
-
/** Records entries plus how many times the middle of the file was skipped. */
|
|
257
|
-
interface GapState extends RecordingState {
|
|
258
|
-
gaps: number;
|
|
259
|
-
}
|
|
260
|
-
const gapReducer: JsonlSummaryReducer<GapState> = {
|
|
261
|
-
initial: () => ({ count: 0, entries: [], gaps: 0 }),
|
|
262
|
-
reduce: (state, entry) => ({
|
|
263
|
-
...state,
|
|
264
|
-
count: state.count + 1,
|
|
265
|
-
entries: [...state.entries, entry === undefined ? "<bad>" : entry],
|
|
266
|
-
}),
|
|
267
|
-
skip: (state) => ({ ...state, gaps: state.gaps + 1 }),
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
const bounds = { headBytes: 64, tailBytes: 128 };
|
|
271
|
-
const pad = (n: number) => line({ pad: "p".repeat(n) });
|
|
272
|
-
|
|
273
|
-
beforeEach(() => {
|
|
274
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "bounded-jsonl-"));
|
|
275
|
-
filePath = path.join(tmpDir, "session.jsonl");
|
|
276
|
-
mockedReadSync.mockClear();
|
|
277
|
-
mockedReadFileSync.mockClear();
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
afterEach(() => {
|
|
281
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
it("parses the whole file when it fits within head + tail", () => {
|
|
285
|
-
const content = line({ a: 1 }) + pad(100) + line({ z: 9 });
|
|
286
|
-
expect(Buffer.byteLength(content)).toBeLessThanOrEqual(192);
|
|
287
|
-
fs.writeFileSync(filePath, content);
|
|
288
|
-
|
|
289
|
-
const result = new IncrementalJsonlSummary(gapReducer, { bounds }).read(filePath);
|
|
290
|
-
|
|
291
|
-
expect(result?.state).toEqual(reduceJsonlContent(gapReducer, content));
|
|
292
|
-
expect(result?.skippedBytes).toBe(0);
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
it("folds head lines, then skip(), then tail lines, reading at most head + tail + 1 bytes", () => {
|
|
296
|
-
const tail = line({ y: 8 }) + line({ z: 9 });
|
|
297
|
-
const content = line({ a: 1 }) + pad(40) + pad(1000) + pad(40) + tail;
|
|
298
|
-
fs.writeFileSync(filePath, content);
|
|
299
|
-
|
|
300
|
-
const result = new IncrementalJsonlSummary(gapReducer, { bounds }).read(filePath);
|
|
301
|
-
|
|
302
|
-
// +1: the byte before the tail window tells whether it starts on a line boundary
|
|
303
|
-
expect(bytesRead()).toBeLessThanOrEqual(bounds.headBytes + bounds.tailBytes + 1);
|
|
304
|
-
expect(result?.state.gaps).toBe(1);
|
|
305
|
-
expect(result?.state.entries[0]).toEqual({ a: 1 });
|
|
306
|
-
expect(result?.state.entries.slice(-2)).toEqual([{ y: 8 }, { z: 9 }]);
|
|
307
|
-
expect(result?.state.entries).not.toContainEqual({ pad: "p".repeat(1000) });
|
|
308
|
-
expect(result?.size).toBe(Buffer.byteLength(content));
|
|
309
|
-
expect(result?.skippedBytes).toBe(Buffer.byteLength(content) - 64 - 128);
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
it("drops lines that straddle the head cap or the tail window start", () => {
|
|
313
|
-
const content = line({ a: 1 }) + pad(500) + line({ z: 9 });
|
|
314
|
-
fs.writeFileSync(filePath, content);
|
|
315
|
-
|
|
316
|
-
const result = new IncrementalJsonlSummary(gapReducer, { bounds }).read(filePath);
|
|
317
|
-
|
|
318
|
-
expect(result?.state.entries).toEqual([{ a: 1 }, { z: 9 }]);
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
it("folds the first tail line when the tail window starts exactly on a line boundary", () => {
|
|
322
|
-
const tail = line({ y: 8 }) + line({ z: 9 });
|
|
323
|
-
fs.writeFileSync(filePath, line({ a: 1 }) + pad(1000) + tail);
|
|
324
|
-
|
|
325
|
-
const result = new IncrementalJsonlSummary(gapReducer, {
|
|
326
|
-
bounds: { headBytes: 64, tailBytes: Buffer.byteLength(tail) },
|
|
327
|
-
}).read(filePath);
|
|
328
|
-
|
|
329
|
-
expect(result?.skippedBytes).toBeGreaterThan(0);
|
|
330
|
-
expect(result?.state.entries).toEqual([{ a: 1 }, { y: 8 }, { z: 9 }]);
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
it("still drops the partial line when the tail window starts one byte into it", () => {
|
|
334
|
-
const tail = line({ y: 8 }) + line({ z: 9 });
|
|
335
|
-
fs.writeFileSync(filePath, line({ a: 1 }) + pad(1000) + tail);
|
|
336
|
-
|
|
337
|
-
const result = new IncrementalJsonlSummary(gapReducer, {
|
|
338
|
-
bounds: { headBytes: 64, tailBytes: Buffer.byteLength(tail) - 1 },
|
|
339
|
-
}).read(filePath);
|
|
340
|
-
|
|
341
|
-
expect(result?.state.entries).toEqual([{ a: 1 }, { z: 9 }]);
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
it("folds nothing from a tail window that holds no line start", () => {
|
|
345
|
-
const content = line({ a: 1 }) + line({ big: "b".repeat(1000) });
|
|
346
|
-
fs.writeFileSync(filePath, content);
|
|
347
|
-
|
|
348
|
-
const result = new IncrementalJsonlSummary(gapReducer, { bounds }).read(filePath);
|
|
349
|
-
|
|
350
|
-
expect(result?.state.entries).toEqual([{ a: 1 }]);
|
|
351
|
-
expect(result?.state.gaps).toBe(1);
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
it("seeds the cache at end of file, so later appends read only the new bytes", () => {
|
|
355
|
-
const cache = new IncrementalJsonlSummary(gapReducer, { bounds });
|
|
356
|
-
fs.writeFileSync(filePath, line({ a: 1 }) + pad(1000) + line({ z: 9 }));
|
|
357
|
-
cache.read(filePath);
|
|
358
|
-
mockedReadSync.mockClear();
|
|
359
|
-
|
|
360
|
-
const appended = line({ n: 10 });
|
|
361
|
-
fs.appendFileSync(filePath, appended);
|
|
362
|
-
const result = cache.read(filePath);
|
|
363
|
-
|
|
364
|
-
expect(bytesRead()).toBe(Buffer.byteLength(appended));
|
|
365
|
-
expect(result?.state.entries.slice(-2)).toEqual([{ z: 9 }, { n: 10 }]);
|
|
366
|
-
expect(result?.state.gaps).toBe(1);
|
|
367
|
-
expect(result?.skippedBytes).toBeGreaterThan(0);
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
it("resynchronises on the next newline when the tail window ended inside a line", () => {
|
|
371
|
-
const cache = new IncrementalJsonlSummary(gapReducer, { bounds });
|
|
372
|
-
fs.writeFileSync(filePath, line({ a: 1 }) + '{"big":"' + "b".repeat(1000));
|
|
373
|
-
expect(cache.read(filePath)?.state.entries).toEqual([{ a: 1 }]);
|
|
374
|
-
|
|
375
|
-
fs.appendFileSync(filePath, '"}\n' + line({ n: 10 }));
|
|
376
|
-
|
|
377
|
-
expect(cache.read(filePath)?.state.entries).toEqual([{ a: 1 }, { n: 10 }]);
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
it("uses the bounded scan again when rebuilding a replaced file", () => {
|
|
381
|
-
const cache = new IncrementalJsonlSummary(gapReducer, { bounds });
|
|
382
|
-
fs.writeFileSync(filePath, line({ a: 1 }));
|
|
383
|
-
cache.read(filePath);
|
|
384
|
-
|
|
385
|
-
const replacement = path.join(tmpDir, "replacement.jsonl");
|
|
386
|
-
fs.writeFileSync(replacement, line({ b: 2 }) + pad(1000) + line({ z: 9 }));
|
|
387
|
-
fs.renameSync(replacement, filePath);
|
|
388
|
-
mockedReadSync.mockClear();
|
|
389
|
-
|
|
390
|
-
const result = cache.read(filePath);
|
|
391
|
-
// +1: the byte before the tail window tells whether it starts on a line boundary
|
|
392
|
-
expect(bytesRead()).toBeLessThanOrEqual(bounds.headBytes + bounds.tailBytes + 1);
|
|
393
|
-
expect(result?.state.entries).toEqual([{ b: 2 }, { z: 9 }]);
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
it("folds tail lines straight onto the head state when the reducer has no skip()", () => {
|
|
397
|
-
fs.writeFileSync(filePath, line({ a: 1 }) + pad(1000) + line({ z: 9 }));
|
|
398
|
-
const result = new IncrementalJsonlSummary(recordingReducer, { bounds }).read(filePath);
|
|
399
|
-
expect(result?.state).toEqual({ count: 2, entries: [{ a: 1 }, { z: 9 }] });
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
it("parses from byte 0 when bounds are disabled", () => {
|
|
403
|
-
const content = line({ a: 1 }) + pad(1000) + line({ z: 9 });
|
|
404
|
-
fs.writeFileSync(filePath, content);
|
|
405
|
-
const result = new IncrementalJsonlSummary(gapReducer, { bounds: false }).read(filePath);
|
|
406
|
-
expect(result?.state).toEqual(reduceJsonlContent(gapReducer, content));
|
|
407
|
-
expect(result?.skippedBytes).toBe(0);
|
|
408
|
-
});
|
|
409
|
-
|
|
410
|
-
it("defaults to a 1 MiB head and 4 MiB tail", () => {
|
|
411
|
-
expect(DEFAULT_HEAD_BYTES).toBe(1024 * 1024);
|
|
412
|
-
expect(DEFAULT_TAIL_BYTES).toBe(4 * 1024 * 1024);
|
|
413
|
-
});
|
|
414
|
-
});
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { mkdtempSync, rmSync, writeFileSync } from "fs";
|
|
2
|
-
import { tmpdir } from "os";
|
|
3
|
-
import { join } from "path";
|
|
4
|
-
import {
|
|
5
|
-
getAgentRequestPath,
|
|
6
|
-
readLatestAgentRequest,
|
|
7
|
-
writeAgentRequest,
|
|
8
|
-
type AgentRequest,
|
|
9
|
-
} from "../../utils/agent-requests.js";
|
|
10
|
-
|
|
11
|
-
describe("agent-requests", () => {
|
|
12
|
-
let homeDir: string;
|
|
13
|
-
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
homeDir = mkdtempSync(join(tmpdir(), "agent-requests-test-"));
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
afterEach(() => {
|
|
19
|
-
rmSync(homeDir, { recursive: true, force: true });
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
describe("getAgentRequestPath", () => {
|
|
23
|
-
it("returns ~/.ai-devkit/agent-requests/<sessionId>.json", () => {
|
|
24
|
-
expect(getAgentRequestPath(homeDir, "abc-123")).toBe(
|
|
25
|
-
join(homeDir, ".ai-devkit", "agent-requests", "abc-123.json"),
|
|
26
|
-
);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe("writeAgentRequest", () => {
|
|
31
|
-
it("creates the directory and file on first write", () => {
|
|
32
|
-
const entry: AgentRequest = {
|
|
33
|
-
sessionId: "sess-1",
|
|
34
|
-
toolName: "Bash",
|
|
35
|
-
toolInput: { command: "ls /tmp" },
|
|
36
|
-
timestamp: "2026-06-29T00:00:00.000Z",
|
|
37
|
-
};
|
|
38
|
-
writeAgentRequest(homeDir, entry);
|
|
39
|
-
|
|
40
|
-
expect(readLatestAgentRequest(homeDir, "sess-1")).toEqual(entry);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("overwrites an existing entry on subsequent writes", () => {
|
|
44
|
-
const first: AgentRequest = {
|
|
45
|
-
sessionId: "sess-2",
|
|
46
|
-
toolName: "Bash",
|
|
47
|
-
toolInput: { command: "echo first" },
|
|
48
|
-
timestamp: "2026-06-29T00:00:01.000Z",
|
|
49
|
-
};
|
|
50
|
-
const second: AgentRequest = {
|
|
51
|
-
sessionId: "sess-2",
|
|
52
|
-
toolName: "Bash",
|
|
53
|
-
toolInput: { command: "echo second" },
|
|
54
|
-
timestamp: "2026-06-29T00:00:02.000Z",
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
writeAgentRequest(homeDir, first);
|
|
58
|
-
writeAgentRequest(homeDir, second);
|
|
59
|
-
|
|
60
|
-
expect(readLatestAgentRequest(homeDir, "sess-2")).toEqual(second);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
describe("readLatestAgentRequest", () => {
|
|
65
|
-
it("returns null when no file exists for the session", () => {
|
|
66
|
-
expect(readLatestAgentRequest(homeDir, "no-such-session")).toBeNull();
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("returns null when the file contains malformed JSON", () => {
|
|
70
|
-
const entry: AgentRequest = {
|
|
71
|
-
sessionId: "bad",
|
|
72
|
-
toolName: "Bash",
|
|
73
|
-
toolInput: {},
|
|
74
|
-
timestamp: "2026-06-29T00:00:00.000Z",
|
|
75
|
-
};
|
|
76
|
-
writeAgentRequest(homeDir, entry);
|
|
77
|
-
writeFileSync(getAgentRequestPath(homeDir, "bad"), "NOT JSON{{{", "utf-8");
|
|
78
|
-
|
|
79
|
-
expect(readLatestAgentRequest(homeDir, "bad")).toBeNull();
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("returns the stored entry when the file is valid", () => {
|
|
83
|
-
const entry: AgentRequest = {
|
|
84
|
-
sessionId: "good",
|
|
85
|
-
toolName: "AskUserQuestion",
|
|
86
|
-
toolInput: { question: "Which option?", options: ["A", "B"] },
|
|
87
|
-
timestamp: "2026-06-29T12:00:00.000Z",
|
|
88
|
-
};
|
|
89
|
-
writeAgentRequest(homeDir, entry);
|
|
90
|
-
|
|
91
|
-
expect(readLatestAgentRequest(homeDir, "good")).toEqual(entry);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
});
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Large-transcript measurement for `getConversation({ tail })` (issue #260).
|
|
3
|
-
*
|
|
4
|
-
* Skipped by default. Run with:
|
|
5
|
-
* AI_DEVKIT_TAIL_BENCH=1 npx vitest run src/__tests__/utils/conversationTail.bench.test.ts
|
|
6
|
-
*
|
|
7
|
-
* Generates a synthetic ~400 MB transcript per adapter under os.tmpdir(),
|
|
8
|
-
* counts bytes read through `fs`, and checks the acceptance limits: the first
|
|
9
|
-
* tail read reads <= 2 MB in <= 50 ms, and a poll after appending K bytes
|
|
10
|
-
* reads <= K + 64 KiB. The file is deleted afterwards.
|
|
11
|
-
*/
|
|
12
|
-
import * as fs from "fs";
|
|
13
|
-
import * as os from "os";
|
|
14
|
-
import * as path from "path";
|
|
15
|
-
import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
|
|
16
|
-
import { ClaudeSessionParser } from "../../harnesses/claude/ClaudeSessionParser.js";
|
|
17
|
-
import { CodexSessionParser } from "../../harnesses/codex/CodexSessionParser.js";
|
|
18
|
-
|
|
19
|
-
const readBytes = vi.hoisted(() => ({ total: 0 }));
|
|
20
|
-
|
|
21
|
-
vi.mock("fs", async (importOriginal) => {
|
|
22
|
-
const actual = await importOriginal<typeof import("fs")>();
|
|
23
|
-
const readSync = ((...args: Parameters<typeof actual.readSync>) => {
|
|
24
|
-
const n = (actual.readSync as (...a: unknown[]) => number)(...args);
|
|
25
|
-
readBytes.total += n;
|
|
26
|
-
return n;
|
|
27
|
-
}) as typeof actual.readSync;
|
|
28
|
-
const readFileSync = ((...args: Parameters<typeof actual.readFileSync>) => {
|
|
29
|
-
const out = (actual.readFileSync as (...a: unknown[]) => string | Buffer)(...args);
|
|
30
|
-
readBytes.total += typeof out === "string" ? Buffer.byteLength(out) : out.length;
|
|
31
|
-
return out;
|
|
32
|
-
}) as typeof actual.readFileSync;
|
|
33
|
-
return { ...actual, readSync, readFileSync, default: { ...actual, readSync, readFileSync } };
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const TARGET_BYTES = 400 * 1024 * 1024;
|
|
37
|
-
const TAIL = 20;
|
|
38
|
-
const MB = 1024 * 1024;
|
|
39
|
-
|
|
40
|
-
function writeLargeFile(file: string, header: string[], turn: (i: number) => string[]): void {
|
|
41
|
-
const fd = fs.openSync(file, "w");
|
|
42
|
-
try {
|
|
43
|
-
fs.writeSync(fd, header.map((l) => l + "\n").join(""));
|
|
44
|
-
let written = 0;
|
|
45
|
-
let i = 0;
|
|
46
|
-
while (written < TARGET_BYTES) {
|
|
47
|
-
const parts: string[] = [];
|
|
48
|
-
for (let k = 0; k < 500; k++, i++) {
|
|
49
|
-
for (const line of turn(i)) parts.push(line, "\n");
|
|
50
|
-
}
|
|
51
|
-
const block = parts.join("");
|
|
52
|
-
fs.writeSync(fd, block);
|
|
53
|
-
written += Buffer.byteLength(block);
|
|
54
|
-
}
|
|
55
|
-
} finally {
|
|
56
|
-
fs.closeSync(fd);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const filler = "x".repeat(2000);
|
|
61
|
-
|
|
62
|
-
const adapters = [
|
|
63
|
-
{
|
|
64
|
-
name: "codex",
|
|
65
|
-
create: () => new CodexSessionParser(),
|
|
66
|
-
header: [JSON.stringify({ type: "session_meta", payload: { id: "bench", cwd: "/repo" } })],
|
|
67
|
-
turn: (i: number) => {
|
|
68
|
-
const turnId = `t${i}`;
|
|
69
|
-
return [
|
|
70
|
-
JSON.stringify({
|
|
71
|
-
type: "response_item",
|
|
72
|
-
timestamp: "2026-01-01T00:00:00Z",
|
|
73
|
-
payload: {
|
|
74
|
-
type: "message",
|
|
75
|
-
role: "user",
|
|
76
|
-
content: [{ type: "input_text", text: `question ${i}` }],
|
|
77
|
-
internal_chat_message_metadata_passthrough: { turn_id: turnId },
|
|
78
|
-
},
|
|
79
|
-
}),
|
|
80
|
-
JSON.stringify({
|
|
81
|
-
type: "event_msg",
|
|
82
|
-
payload: {
|
|
83
|
-
type: "item_completed",
|
|
84
|
-
turn_id: turnId,
|
|
85
|
-
item: { type: "UserMessage", content: [{ type: "text", text: `question ${i}` }] },
|
|
86
|
-
},
|
|
87
|
-
}),
|
|
88
|
-
JSON.stringify({
|
|
89
|
-
type: "response_item",
|
|
90
|
-
payload: { type: "function_call_output", output: filler },
|
|
91
|
-
}),
|
|
92
|
-
JSON.stringify({
|
|
93
|
-
type: "event_msg",
|
|
94
|
-
payload: { type: "agent_message", message: `answer ${i}` },
|
|
95
|
-
}),
|
|
96
|
-
];
|
|
97
|
-
},
|
|
98
|
-
appendTurn: (i: number) =>
|
|
99
|
-
JSON.stringify({
|
|
100
|
-
type: "event_msg",
|
|
101
|
-
payload: { type: "agent_message", message: `appended ${i}` },
|
|
102
|
-
}),
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
name: "claude",
|
|
106
|
-
create: () => new ClaudeSessionParser(),
|
|
107
|
-
header: [JSON.stringify({ type: "file-history-snapshot", snapshot: {} })],
|
|
108
|
-
turn: (i: number) => [
|
|
109
|
-
JSON.stringify({ type: "user", message: { content: `question ${i}` } }),
|
|
110
|
-
JSON.stringify({
|
|
111
|
-
type: "assistant",
|
|
112
|
-
message: { content: [{ type: "tool_use", name: "Bash", input: { command: "ls" } }] },
|
|
113
|
-
}),
|
|
114
|
-
JSON.stringify({
|
|
115
|
-
type: "user",
|
|
116
|
-
message: { content: [{ type: "tool_result", content: filler }] },
|
|
117
|
-
}),
|
|
118
|
-
JSON.stringify({
|
|
119
|
-
type: "assistant",
|
|
120
|
-
message: { content: [{ type: "text", text: `answer ${i}` }] },
|
|
121
|
-
}),
|
|
122
|
-
],
|
|
123
|
-
appendTurn: (i: number) =>
|
|
124
|
-
JSON.stringify({
|
|
125
|
-
type: "assistant",
|
|
126
|
-
message: { content: [{ type: "text", text: `appended ${i}` }] },
|
|
127
|
-
}),
|
|
128
|
-
},
|
|
129
|
-
];
|
|
130
|
-
|
|
131
|
-
describe.skipIf(!process.env.AI_DEVKIT_TAIL_BENCH)(
|
|
132
|
-
"getConversation tail on a 400 MB transcript",
|
|
133
|
-
() => {
|
|
134
|
-
let tmpDir: string;
|
|
135
|
-
|
|
136
|
-
beforeAll(() => {
|
|
137
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "tail-bench-"));
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
afterAll(() => {
|
|
141
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it.each(adapters)(
|
|
145
|
-
"$name: first call and incremental polls stay within the byte/time budget",
|
|
146
|
-
(adapter) => {
|
|
147
|
-
const file = path.join(tmpDir, `${adapter.name}.jsonl`);
|
|
148
|
-
writeLargeFile(file, adapter.header, adapter.turn);
|
|
149
|
-
const size = fs.statSync(file).size;
|
|
150
|
-
expect(size).toBeGreaterThanOrEqual(TARGET_BYTES);
|
|
151
|
-
|
|
152
|
-
const parser = adapter.create();
|
|
153
|
-
readBytes.total = 0;
|
|
154
|
-
const rssBefore = process.memoryUsage().rss;
|
|
155
|
-
const start = performance.now();
|
|
156
|
-
const messages = parser.getConversation(file, { tail: TAIL });
|
|
157
|
-
const firstMs = performance.now() - start;
|
|
158
|
-
const firstRead = readBytes.total;
|
|
159
|
-
const rssDelta = process.memoryUsage().rss - rssBefore;
|
|
160
|
-
|
|
161
|
-
expect(messages).toHaveLength(TAIL);
|
|
162
|
-
expect(messages.at(-1)?.content).toMatch(/^answer \d+$/);
|
|
163
|
-
|
|
164
|
-
const polls: string[] = [];
|
|
165
|
-
for (let round = 0; round < 3; round++) {
|
|
166
|
-
const appended = adapter.appendTurn(round) + "\n";
|
|
167
|
-
fs.appendFileSync(file, appended);
|
|
168
|
-
readBytes.total = 0;
|
|
169
|
-
const t0 = performance.now();
|
|
170
|
-
const next = parser.getConversation(file, { tail: TAIL });
|
|
171
|
-
const pollMs = performance.now() - t0;
|
|
172
|
-
expect(next.at(-1)?.content).toBe(`appended ${round}`);
|
|
173
|
-
expect(next).toHaveLength(TAIL);
|
|
174
|
-
const k = Buffer.byteLength(appended);
|
|
175
|
-
expect(readBytes.total).toBeLessThanOrEqual(k + 64 * 1024);
|
|
176
|
-
polls.push(`K=${k}B read=${readBytes.total}B ${pollMs.toFixed(2)}ms`);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
console.log(
|
|
180
|
-
`[${adapter.name}] file=${(size / MB).toFixed(1)} MB first call: ` +
|
|
181
|
-
`read=${(firstRead / 1024).toFixed(1)} KiB, ${firstMs.toFixed(2)} ms, ` +
|
|
182
|
-
`rssDelta=${(rssDelta / MB).toFixed(1)} MB; polls: ${polls.join("; ")}`,
|
|
183
|
-
);
|
|
184
|
-
|
|
185
|
-
expect(firstRead).toBeLessThanOrEqual(2 * MB);
|
|
186
|
-
expect(firstMs).toBeLessThanOrEqual(50);
|
|
187
|
-
|
|
188
|
-
fs.rmSync(file, { force: true });
|
|
189
|
-
},
|
|
190
|
-
120_000,
|
|
191
|
-
);
|
|
192
|
-
},
|
|
193
|
-
);
|