@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,571 +0,0 @@
|
|
|
1
|
-
import { readFile } from "node:fs/promises";
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { describe, expect, it, vi } from "vitest";
|
|
5
|
-
import { probeOpenAiCapacity } from "../../capacity/sources/pi.js";
|
|
6
|
-
import {
|
|
7
|
-
buildOpenAiPlatformCapacity,
|
|
8
|
-
parseOpenAiUsage,
|
|
9
|
-
} from "../../capacity/providers/openai-platform.js";
|
|
10
|
-
import { resolvePiOpenAiCredential as resolveOpenAiCredential } from "../../harnesses/pi/credentials.js";
|
|
11
|
-
|
|
12
|
-
const checkedAt = "2026-09-26T10:00:00.000Z";
|
|
13
|
-
const fixtureOauthAccess = "sample access value for tests";
|
|
14
|
-
const fakeJwt = (payload: string) =>
|
|
15
|
-
["test", Buffer.from(payload).toString("base64url"), "test"].join(".");
|
|
16
|
-
const fixture = (name: string) =>
|
|
17
|
-
readFile(fileURLToPath(new URL(`./fixtures/${name}`, import.meta.url)), "utf8");
|
|
18
|
-
const fixtureString = (name: string) =>
|
|
19
|
-
readFileSync(fileURLToPath(new URL(`./fixtures/${name}`, import.meta.url)), "utf8");
|
|
20
|
-
|
|
21
|
-
describe("OpenAI credential resolution", () => {
|
|
22
|
-
it("prefers OPENAI_API_KEY without reading Pi auth", async () => {
|
|
23
|
-
const readAuth = vi.fn(async () => fixture("openai-auth.json"));
|
|
24
|
-
await expect(
|
|
25
|
-
resolveOpenAiCredential({
|
|
26
|
-
env: { OPENAI_API_KEY: "env-openai-test-key" },
|
|
27
|
-
readFile: readAuth,
|
|
28
|
-
}),
|
|
29
|
-
).resolves.toEqual({ kind: "platform", key: "env-openai-test-key" });
|
|
30
|
-
expect(readAuth).not.toHaveBeenCalled();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("reads the Pi openai api_key credential from ~/.pi/agent/auth.json", async () => {
|
|
34
|
-
const readAuth = vi.fn(async () => fixture("openai-auth.json"));
|
|
35
|
-
await expect(
|
|
36
|
-
resolveOpenAiCredential({ env: { HOME: "/users/test" }, readFile: readAuth }),
|
|
37
|
-
).resolves.toEqual({ kind: "platform", key: "pi-openai-test-key" });
|
|
38
|
-
expect(readAuth).toHaveBeenCalledWith("/users/test/.pi/agent/auth.json", "utf8");
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it.each([
|
|
42
|
-
[
|
|
43
|
-
"missing",
|
|
44
|
-
async () => Promise.reject(Object.assign(new Error("missing"), { code: "ENOENT" })),
|
|
45
|
-
],
|
|
46
|
-
["invalid JSON", async () => "{"],
|
|
47
|
-
["wrong credential type", async () => JSON.stringify({ openai: { type: "oauth", key: "x" } })],
|
|
48
|
-
["missing key", async () => JSON.stringify({ openai: { type: "api_key" } })],
|
|
49
|
-
])("fails clearly for %s credentials without exposing file content", async (_name, readAuth) => {
|
|
50
|
-
await expect(
|
|
51
|
-
resolveOpenAiCredential({
|
|
52
|
-
env: { HOME: "/users/test" },
|
|
53
|
-
readFile: readAuth,
|
|
54
|
-
}),
|
|
55
|
-
).rejects.toThrow(/OpenAI credentials not found|OpenAI Pi auth file/);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
describe("OpenAI tiered credential resolution", () => {
|
|
60
|
-
const oauthFixture = () => fixture("openai-codex-auth.json");
|
|
61
|
-
const bothCredentials = JSON.stringify({
|
|
62
|
-
openai: { type: "api_key", key: "pi-openai-test-key" },
|
|
63
|
-
"openai-codex": {
|
|
64
|
-
type: "oauth",
|
|
65
|
-
access: fixtureOauthAccess,
|
|
66
|
-
refresh: "fixture-refresh-token",
|
|
67
|
-
expires: 1793000000000,
|
|
68
|
-
accountId: "fixture-chatgpt-account-id",
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("prefers the Pi openai platform credential over the openai-codex OAuth login", async () => {
|
|
73
|
-
await expect(
|
|
74
|
-
resolveOpenAiCredential({
|
|
75
|
-
env: { HOME: "/users/test" },
|
|
76
|
-
readFile: async () => bothCredentials,
|
|
77
|
-
}),
|
|
78
|
-
).resolves.toEqual({ kind: "platform", key: "pi-openai-test-key" });
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("resolves the Pi openai-codex OAuth login when no platform credential exists", async () => {
|
|
82
|
-
await expect(
|
|
83
|
-
resolveOpenAiCredential({
|
|
84
|
-
env: { HOME: "/users/test" },
|
|
85
|
-
readFile: async () => oauthFixture(),
|
|
86
|
-
}),
|
|
87
|
-
).resolves.toEqual({
|
|
88
|
-
kind: "oauth",
|
|
89
|
-
access: fixtureOauthAccess,
|
|
90
|
-
accountId: "fixture-chatgpt-account-id",
|
|
91
|
-
expiresMs: 1793000000000,
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("normalizes second-based expires values to epoch milliseconds", async () => {
|
|
96
|
-
const auth = JSON.stringify({
|
|
97
|
-
"openai-codex": {
|
|
98
|
-
type: "oauth",
|
|
99
|
-
access: "fixture-access",
|
|
100
|
-
refresh: "fixture-refresh",
|
|
101
|
-
expires: 1793000000,
|
|
102
|
-
accountId: "fixture-chatgpt-account-id",
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
await expect(
|
|
106
|
-
resolveOpenAiCredential({ env: { HOME: "/users/test" }, readFile: async () => auth }),
|
|
107
|
-
).resolves.toMatchObject({ kind: "oauth", expiresMs: 1793000000000 });
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it("keeps a null expiry for OAuth logins without usable expires metadata", async () => {
|
|
111
|
-
const auth = JSON.stringify({
|
|
112
|
-
"openai-codex": {
|
|
113
|
-
type: "oauth",
|
|
114
|
-
access: "fixture-access",
|
|
115
|
-
accountId: "fixture-chatgpt-account-id",
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
await expect(
|
|
119
|
-
resolveOpenAiCredential({ env: { HOME: "/users/test" }, readFile: async () => auth }),
|
|
120
|
-
).resolves.toMatchObject({ kind: "oauth", expiresMs: null });
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it.each([
|
|
124
|
-
["wrong credential type", JSON.stringify({ "openai-codex": { type: "api_key", key: "x" } })],
|
|
125
|
-
["missing access token", JSON.stringify({ "openai-codex": { type: "oauth", accountId: "a" } })],
|
|
126
|
-
["missing account id", JSON.stringify({ "openai-codex": { type: "oauth", access: "t" } })],
|
|
127
|
-
])(
|
|
128
|
-
"skips a malformed openai-codex credential (%s) with a sanitized error",
|
|
129
|
-
async (_name, auth) => {
|
|
130
|
-
await expect(
|
|
131
|
-
resolveOpenAiCredential({ env: { HOME: "/users/test" }, readFile: async () => auth }),
|
|
132
|
-
).rejects.toThrow("OpenAI credentials not found");
|
|
133
|
-
},
|
|
134
|
-
);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
describe("OpenAI OAuth capacity probe", () => {
|
|
138
|
-
const freshOauth = () => fixture("openai-codex-auth.json");
|
|
139
|
-
const whamResponse = () => new Response(fixtureString("wham-usage.json"), { status: 200 });
|
|
140
|
-
|
|
141
|
-
it("reports wham usage windows for a fresh Pi OAuth login", async () => {
|
|
142
|
-
const fetch = vi.fn(async () => whamResponse());
|
|
143
|
-
const report = await probeOpenAiCapacity({
|
|
144
|
-
checkedAt,
|
|
145
|
-
env: { HOME: "/users/test" },
|
|
146
|
-
readFile: async () => freshOauth(),
|
|
147
|
-
fetch,
|
|
148
|
-
});
|
|
149
|
-
expect(fetch).toHaveBeenCalledWith(
|
|
150
|
-
"https://chatgpt.com/backend-api/wham/usage",
|
|
151
|
-
expect.objectContaining({
|
|
152
|
-
method: "GET",
|
|
153
|
-
headers: {
|
|
154
|
-
Authorization: `Bearer ${fixtureOauthAccess}`,
|
|
155
|
-
"ChatGPT-Account-Id": "fixture-chatgpt-account-id",
|
|
156
|
-
},
|
|
157
|
-
}),
|
|
158
|
-
);
|
|
159
|
-
expect(report).toMatchObject({
|
|
160
|
-
harness: "pi",
|
|
161
|
-
provider: "openai",
|
|
162
|
-
generatedAt: checkedAt,
|
|
163
|
-
authenticated: true,
|
|
164
|
-
available: "yes",
|
|
165
|
-
creditsRemaining: 4.5,
|
|
166
|
-
});
|
|
167
|
-
expect(report.windows.map((window) => window.id)).toEqual([
|
|
168
|
-
"session",
|
|
169
|
-
"weekly",
|
|
170
|
-
"spend-control",
|
|
171
|
-
]);
|
|
172
|
-
expect(report.windows.at(-1)).toMatchObject({
|
|
173
|
-
label: "Spend control",
|
|
174
|
-
limitType: "CREDIT_LIMIT",
|
|
175
|
-
total: 3000,
|
|
176
|
-
current: 33.43525505065918,
|
|
177
|
-
remaining: 2966.564744949341,
|
|
178
|
-
});
|
|
179
|
-
expect(JSON.stringify(report)).not.toContain("fixture-signature");
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it("does not fetch and reports an authenticated-but-stale state for expired logins", async () => {
|
|
183
|
-
const staleAuth = JSON.stringify({
|
|
184
|
-
"openai-codex": {
|
|
185
|
-
type: "oauth",
|
|
186
|
-
access: "stale-fixture-access",
|
|
187
|
-
expires: 1790000000000,
|
|
188
|
-
accountId: "fixture-chatgpt-account-id",
|
|
189
|
-
},
|
|
190
|
-
});
|
|
191
|
-
const fetch = vi.fn();
|
|
192
|
-
const report = await probeOpenAiCapacity({
|
|
193
|
-
checkedAt,
|
|
194
|
-
env: { HOME: "/users/test" },
|
|
195
|
-
readFile: async () => staleAuth,
|
|
196
|
-
fetch,
|
|
197
|
-
});
|
|
198
|
-
expect(fetch).not.toHaveBeenCalled();
|
|
199
|
-
expect(report).toEqual({
|
|
200
|
-
harness: "pi",
|
|
201
|
-
provider: "openai",
|
|
202
|
-
generatedAt: checkedAt,
|
|
203
|
-
authenticated: true,
|
|
204
|
-
available: "unknown",
|
|
205
|
-
windows: [],
|
|
206
|
-
creditsRemaining: null,
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
it("treats second-based expiry metadata as stale the same way", async () => {
|
|
211
|
-
const staleAuth = JSON.stringify({
|
|
212
|
-
"openai-codex": {
|
|
213
|
-
type: "oauth",
|
|
214
|
-
access: "stale-fixture-access",
|
|
215
|
-
expires: 1790000000,
|
|
216
|
-
accountId: "fixture-chatgpt-account-id",
|
|
217
|
-
},
|
|
218
|
-
});
|
|
219
|
-
const fetch = vi.fn();
|
|
220
|
-
const report = await probeOpenAiCapacity({
|
|
221
|
-
checkedAt,
|
|
222
|
-
env: { HOME: "/users/test" },
|
|
223
|
-
readFile: async () => staleAuth,
|
|
224
|
-
fetch,
|
|
225
|
-
});
|
|
226
|
-
expect(fetch).not.toHaveBeenCalled();
|
|
227
|
-
expect(report.available).toBe("unknown");
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
it("falls back to the JWT exp when expires metadata is missing", async () => {
|
|
231
|
-
const expiredJwtAuth = JSON.stringify({
|
|
232
|
-
"openai-codex": {
|
|
233
|
-
type: "oauth",
|
|
234
|
-
access: fakeJwt(JSON.stringify({ exp: 1789000000 })),
|
|
235
|
-
accountId: "fixture-chatgpt-account-id",
|
|
236
|
-
},
|
|
237
|
-
});
|
|
238
|
-
const noFetch = vi.fn();
|
|
239
|
-
await expect(
|
|
240
|
-
probeOpenAiCapacity({
|
|
241
|
-
checkedAt,
|
|
242
|
-
env: { HOME: "/users/test" },
|
|
243
|
-
readFile: async () => expiredJwtAuth,
|
|
244
|
-
fetch: noFetch,
|
|
245
|
-
}),
|
|
246
|
-
).resolves.toMatchObject({ authenticated: true, available: "unknown" });
|
|
247
|
-
expect(noFetch).not.toHaveBeenCalled();
|
|
248
|
-
|
|
249
|
-
const futureJwtAuth = JSON.stringify({
|
|
250
|
-
"openai-codex": {
|
|
251
|
-
type: "oauth",
|
|
252
|
-
access: fakeJwt(JSON.stringify({ exp: 1793000000 })),
|
|
253
|
-
accountId: "fixture-chatgpt-account-id",
|
|
254
|
-
},
|
|
255
|
-
});
|
|
256
|
-
const fetch = vi.fn(async () => whamResponse());
|
|
257
|
-
await expect(
|
|
258
|
-
probeOpenAiCapacity({
|
|
259
|
-
checkedAt,
|
|
260
|
-
env: { HOME: "/users/test" },
|
|
261
|
-
readFile: async () => futureJwtAuth,
|
|
262
|
-
fetch,
|
|
263
|
-
}),
|
|
264
|
-
).resolves.toMatchObject({ authenticated: true, available: "yes" });
|
|
265
|
-
expect(fetch).toHaveBeenCalledOnce();
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
it("treats unparseable JWT payloads as unknown expiry and probes anyway", async () => {
|
|
269
|
-
const auth = JSON.stringify({
|
|
270
|
-
"openai-codex": {
|
|
271
|
-
type: "oauth",
|
|
272
|
-
access: fakeJwt("not-json"),
|
|
273
|
-
accountId: "fixture-chatgpt-account-id",
|
|
274
|
-
},
|
|
275
|
-
});
|
|
276
|
-
const fetch = vi.fn(async () => whamResponse());
|
|
277
|
-
await expect(
|
|
278
|
-
probeOpenAiCapacity({
|
|
279
|
-
checkedAt,
|
|
280
|
-
env: { HOME: "/users/test" },
|
|
281
|
-
readFile: async () => auth,
|
|
282
|
-
fetch,
|
|
283
|
-
}),
|
|
284
|
-
).resolves.toMatchObject({ authenticated: true, available: "yes" });
|
|
285
|
-
expect(fetch).toHaveBeenCalledOnce();
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
it("treats non-JWT and exp-less access tokens as unknown expiry and probes anyway", async () => {
|
|
289
|
-
for (const access of ["opaque-fixture-access", "h.eyJzdWIiOiJ4In0.s"]) {
|
|
290
|
-
const auth = JSON.stringify({
|
|
291
|
-
"openai-codex": {
|
|
292
|
-
type: "oauth",
|
|
293
|
-
access,
|
|
294
|
-
accountId: "fixture-chatgpt-account-id",
|
|
295
|
-
},
|
|
296
|
-
});
|
|
297
|
-
const fetch = vi.fn(async () => whamResponse());
|
|
298
|
-
await expect(
|
|
299
|
-
probeOpenAiCapacity({
|
|
300
|
-
checkedAt,
|
|
301
|
-
env: { HOME: "/users/test" },
|
|
302
|
-
readFile: async () => auth,
|
|
303
|
-
fetch,
|
|
304
|
-
}),
|
|
305
|
-
).resolves.toMatchObject({ authenticated: true, available: "yes" });
|
|
306
|
-
expect(fetch).toHaveBeenCalledOnce();
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
it("reports unknown availability when wham returns no usable windows", async () => {
|
|
311
|
-
const report = await probeOpenAiCapacity({
|
|
312
|
-
checkedAt,
|
|
313
|
-
env: { HOME: "/users/test" },
|
|
314
|
-
readFile: async () => freshOauth(),
|
|
315
|
-
fetch: vi.fn(async () => new Response("{}", { status: 200 })),
|
|
316
|
-
});
|
|
317
|
-
expect(report).toMatchObject({ authenticated: true, available: "unknown", windows: [] });
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
it("reports unauthenticated when wham rejects the OAuth token", async () => {
|
|
321
|
-
for (const status of [401, 403]) {
|
|
322
|
-
const report = await probeOpenAiCapacity({
|
|
323
|
-
checkedAt,
|
|
324
|
-
env: { HOME: "/users/test" },
|
|
325
|
-
readFile: async () => freshOauth(),
|
|
326
|
-
fetch: vi.fn(async () => new Response("denied", { status })),
|
|
327
|
-
});
|
|
328
|
-
expect(report).toMatchObject({
|
|
329
|
-
authenticated: false,
|
|
330
|
-
available: "unknown",
|
|
331
|
-
windows: [],
|
|
332
|
-
creditsRemaining: null,
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
it("throws sanitized errors for transport failures without leaking tokens", async () => {
|
|
338
|
-
const probe = (fetch: unknown) =>
|
|
339
|
-
probeOpenAiCapacity({
|
|
340
|
-
checkedAt,
|
|
341
|
-
env: { HOME: "/users/test" },
|
|
342
|
-
readFile: async () => freshOauth(),
|
|
343
|
-
fetch: fetch as typeof globalThis.fetch,
|
|
344
|
-
timeoutMs: 10,
|
|
345
|
-
});
|
|
346
|
-
await expect(
|
|
347
|
-
probe(
|
|
348
|
-
(_url: string, init: RequestInit) =>
|
|
349
|
-
new Promise((_resolve, reject) =>
|
|
350
|
-
init.signal?.addEventListener("abort", () => reject(new Error("aborted"))),
|
|
351
|
-
),
|
|
352
|
-
),
|
|
353
|
-
).rejects.toThrow("OpenAI usage request failed");
|
|
354
|
-
await expect(probe(vi.fn(async () => new Response("boom", { status: 503 })))).rejects.toThrow(
|
|
355
|
-
"OpenAI usage request failed: HTTP 503",
|
|
356
|
-
);
|
|
357
|
-
await expect(
|
|
358
|
-
probe(vi.fn(async () => new Response("not-json", { status: 200 }))),
|
|
359
|
-
).rejects.toThrow("OpenAI usage response is not valid JSON");
|
|
360
|
-
try {
|
|
361
|
-
await probe(vi.fn(async () => new Response("boom", { status: 503 })));
|
|
362
|
-
} catch (error) {
|
|
363
|
-
expect(String(error)).not.toContain("fixture-signature");
|
|
364
|
-
expect(String(error)).not.toContain("fixture-chatgpt-account-id");
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
describe("OpenAI usage mapping", () => {
|
|
370
|
-
it("sums per-model input and output tokens into UTC day buckets", async () => {
|
|
371
|
-
const buckets = parseOpenAiUsage(JSON.parse(await fixture("openai-usage-completions.json")));
|
|
372
|
-
expect(buckets).toEqual([
|
|
373
|
-
{ startMs: 1790380800000, tokens: 2000 },
|
|
374
|
-
{ startMs: 1790294400000, tokens: 5000 },
|
|
375
|
-
{ startMs: 1789862400000, tokens: 1000 },
|
|
376
|
-
{ startMs: 1789689600000, tokens: 19998 },
|
|
377
|
-
]);
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
it("keeps empty buckets and skips entries it cannot place in time", () => {
|
|
381
|
-
expect(
|
|
382
|
-
parseOpenAiUsage({
|
|
383
|
-
object: "list",
|
|
384
|
-
data: [
|
|
385
|
-
null,
|
|
386
|
-
42,
|
|
387
|
-
{ aggregation_timestamp: 1790380800 },
|
|
388
|
-
{ aggregation_timestamp: "yesterday", results: [] },
|
|
389
|
-
{ aggregation_timestamp: 1790294400, results: null },
|
|
390
|
-
],
|
|
391
|
-
}),
|
|
392
|
-
).toEqual([
|
|
393
|
-
{ startMs: 1790380800000, tokens: 0 },
|
|
394
|
-
{ startMs: 1790294400000, tokens: 0 },
|
|
395
|
-
]);
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
it("rejects responses without a usage data array", () => {
|
|
399
|
-
expect(() => parseOpenAiUsage({ object: "list" })).toThrow("Invalid OpenAI usage response");
|
|
400
|
-
expect(() => parseOpenAiUsage({ data: {} })).toThrow("Invalid OpenAI usage response");
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
it("builds today and 7-day windows without faked limits", async () => {
|
|
404
|
-
const buckets = [
|
|
405
|
-
...parseOpenAiUsage(JSON.parse(await fixture("openai-usage-completions.json"))),
|
|
406
|
-
...parseOpenAiUsage(JSON.parse(await fixture("openai-usage-responses.json"))),
|
|
407
|
-
];
|
|
408
|
-
const report = buildOpenAiPlatformCapacity(buckets, checkedAt);
|
|
409
|
-
expect(report).toMatchObject({
|
|
410
|
-
authenticated: true,
|
|
411
|
-
available: "yes",
|
|
412
|
-
creditsRemaining: null,
|
|
413
|
-
});
|
|
414
|
-
expect(report.windows).toEqual([
|
|
415
|
-
{
|
|
416
|
-
id: "openai:tokens:today",
|
|
417
|
-
label: "Tokens · today (UTC)",
|
|
418
|
-
limitType: "TOKENS_LIMIT",
|
|
419
|
-
durationMinutes: 1440,
|
|
420
|
-
usedPercent: null,
|
|
421
|
-
resetsAt: "2026-09-27T00:00:00.000Z",
|
|
422
|
-
total: null,
|
|
423
|
-
current: 2000,
|
|
424
|
-
remaining: null,
|
|
425
|
-
},
|
|
426
|
-
{
|
|
427
|
-
id: "openai:tokens:week",
|
|
428
|
-
label: "Tokens · 7 days",
|
|
429
|
-
limitType: "TOKENS_LIMIT",
|
|
430
|
-
durationMinutes: 10080,
|
|
431
|
-
usedPercent: null,
|
|
432
|
-
resetsAt: null,
|
|
433
|
-
total: null,
|
|
434
|
-
current: 13000,
|
|
435
|
-
remaining: null,
|
|
436
|
-
},
|
|
437
|
-
]);
|
|
438
|
-
});
|
|
439
|
-
|
|
440
|
-
it("reports zero usage for days without buckets", () => {
|
|
441
|
-
const report = buildOpenAiPlatformCapacity([], checkedAt);
|
|
442
|
-
expect(report.windows.map((window) => window.current)).toEqual([0, 0]);
|
|
443
|
-
expect(report.windows[0].resetsAt).toBe("2026-09-27T00:00:00.000Z");
|
|
444
|
-
});
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
describe("OpenAI request", () => {
|
|
448
|
-
it("GETs both usage endpoints for the trailing week with only Bearer authentication", async () => {
|
|
449
|
-
const fetch = vi.fn(async (url: string) =>
|
|
450
|
-
url.includes("/responses?")
|
|
451
|
-
? new Response(await fixture("openai-usage-responses.json"), {
|
|
452
|
-
status: 200,
|
|
453
|
-
})
|
|
454
|
-
: new Response(await fixture("openai-usage-completions.json"), {
|
|
455
|
-
status: 200,
|
|
456
|
-
}),
|
|
457
|
-
);
|
|
458
|
-
const report = await probeOpenAiCapacity({
|
|
459
|
-
checkedAt,
|
|
460
|
-
env: { OPENAI_API_KEY: "request-test-key" },
|
|
461
|
-
fetch,
|
|
462
|
-
});
|
|
463
|
-
const query = "start_time=1789812000&end_time=1790416800";
|
|
464
|
-
expect(fetch).toHaveBeenCalledTimes(2);
|
|
465
|
-
expect(fetch).toHaveBeenCalledWith(
|
|
466
|
-
`https://api.openai.com/v1/organization/usage/completions?${query}`,
|
|
467
|
-
expect.objectContaining({
|
|
468
|
-
method: "GET",
|
|
469
|
-
headers: { Authorization: "Bearer request-test-key" },
|
|
470
|
-
}),
|
|
471
|
-
);
|
|
472
|
-
expect(fetch).toHaveBeenCalledWith(
|
|
473
|
-
`https://api.openai.com/v1/organization/usage/responses?${query}`,
|
|
474
|
-
expect.objectContaining({
|
|
475
|
-
headers: { Authorization: "Bearer request-test-key" },
|
|
476
|
-
}),
|
|
477
|
-
);
|
|
478
|
-
expect(report.windows.map((window) => window.current)).toEqual([2000, 13000]);
|
|
479
|
-
expect(JSON.stringify(report)).not.toContain("request-test-key");
|
|
480
|
-
});
|
|
481
|
-
|
|
482
|
-
it("reports unauthenticated for rejected keys", async () => {
|
|
483
|
-
const report = await probeOpenAiCapacity({
|
|
484
|
-
checkedAt,
|
|
485
|
-
env: { OPENAI_API_KEY: "rejected-key" },
|
|
486
|
-
fetch: vi.fn(async () => new Response("denied", { status: 401 })),
|
|
487
|
-
});
|
|
488
|
-
expect(report).toMatchObject({
|
|
489
|
-
authenticated: false,
|
|
490
|
-
available: "unknown",
|
|
491
|
-
windows: [],
|
|
492
|
-
creditsRemaining: null,
|
|
493
|
-
});
|
|
494
|
-
});
|
|
495
|
-
|
|
496
|
-
it("degrades to authentication-only when usage requires an admin key", async () => {
|
|
497
|
-
const fetch = vi.fn(async (url: string) =>
|
|
498
|
-
url.endsWith("/models")
|
|
499
|
-
? new Response("{}", { status: 200 })
|
|
500
|
-
: new Response("forbidden", { status: 403 }),
|
|
501
|
-
);
|
|
502
|
-
const report = await probeOpenAiCapacity({
|
|
503
|
-
checkedAt,
|
|
504
|
-
env: { OPENAI_API_KEY: "member-key" },
|
|
505
|
-
fetch,
|
|
506
|
-
});
|
|
507
|
-
expect(fetch).toHaveBeenCalledWith(
|
|
508
|
-
"https://api.openai.com/v1/models",
|
|
509
|
-
expect.objectContaining({
|
|
510
|
-
headers: { Authorization: "Bearer member-key" },
|
|
511
|
-
}),
|
|
512
|
-
);
|
|
513
|
-
expect(report).toMatchObject({
|
|
514
|
-
authenticated: true,
|
|
515
|
-
available: "unknown",
|
|
516
|
-
windows: [],
|
|
517
|
-
});
|
|
518
|
-
});
|
|
519
|
-
|
|
520
|
-
it("falls back to unauthenticated when the degraded check rejects the key", async () => {
|
|
521
|
-
const fetch = vi.fn(async (url: string) =>
|
|
522
|
-
url.endsWith("/models")
|
|
523
|
-
? new Response("denied", { status: 401 })
|
|
524
|
-
: new Response("forbidden", { status: 403 }),
|
|
525
|
-
);
|
|
526
|
-
const report = await probeOpenAiCapacity({
|
|
527
|
-
checkedAt,
|
|
528
|
-
env: { OPENAI_API_KEY: "revoked-key" },
|
|
529
|
-
fetch,
|
|
530
|
-
});
|
|
531
|
-
expect(report).toMatchObject({ authenticated: false, windows: [] });
|
|
532
|
-
});
|
|
533
|
-
|
|
534
|
-
it("sanitizes network failures on the platform key path", async () => {
|
|
535
|
-
await expect(
|
|
536
|
-
probeOpenAiCapacity({
|
|
537
|
-
checkedAt,
|
|
538
|
-
env: { OPENAI_API_KEY: "network-key" },
|
|
539
|
-
fetch: vi.fn(async () => Promise.reject(new Error("ECONNRESET secret"))),
|
|
540
|
-
}),
|
|
541
|
-
).rejects.toThrow("OpenAI usage request failed");
|
|
542
|
-
await expect(
|
|
543
|
-
probeOpenAiCapacity({
|
|
544
|
-
checkedAt,
|
|
545
|
-
env: { OPENAI_API_KEY: "network-key" },
|
|
546
|
-
fetch: vi.fn(async (url: string) =>
|
|
547
|
-
url.endsWith("/models")
|
|
548
|
-
? Promise.reject(new Error("ECONNRESET secret"))
|
|
549
|
-
: new Response("forbidden", { status: 403 }),
|
|
550
|
-
),
|
|
551
|
-
}),
|
|
552
|
-
).rejects.toThrow("OpenAI usage request failed");
|
|
553
|
-
});
|
|
554
|
-
|
|
555
|
-
it("rejects other statuses and malformed JSON responses with sanitized errors", async () => {
|
|
556
|
-
await expect(
|
|
557
|
-
probeOpenAiCapacity({
|
|
558
|
-
checkedAt,
|
|
559
|
-
env: { OPENAI_API_KEY: "never-expose-this-key" },
|
|
560
|
-
fetch: vi.fn(async () => new Response("private body", { status: 503 })),
|
|
561
|
-
}),
|
|
562
|
-
).rejects.toThrow("OpenAI usage request failed: HTTP 503");
|
|
563
|
-
await expect(
|
|
564
|
-
probeOpenAiCapacity({
|
|
565
|
-
checkedAt,
|
|
566
|
-
env: { OPENAI_API_KEY: "never-expose-this-key" },
|
|
567
|
-
fetch: vi.fn(async () => new Response("not-json", { status: 200 })),
|
|
568
|
-
}),
|
|
569
|
-
).rejects.toThrow("OpenAI usage response is not valid JSON");
|
|
570
|
-
});
|
|
571
|
-
});
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { readFile } from "node:fs/promises";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { describe, expect, it } from "vitest";
|
|
4
|
-
import { parseWhamUsage, toRateWindow } from "../../capacity/providers/openai-subscription.js";
|
|
5
|
-
|
|
6
|
-
const fixture = (name: string) =>
|
|
7
|
-
readFile(fileURLToPath(new URL(`./fixtures/${name}`, import.meta.url)), "utf8");
|
|
8
|
-
|
|
9
|
-
describe("wham usage parsing", () => {
|
|
10
|
-
it("maps primary and secondary rate windows onto session and weekly", async () => {
|
|
11
|
-
const snapshot = parseWhamUsage(JSON.parse(await fixture("wham-usage.json")));
|
|
12
|
-
expect(snapshot.windows).toEqual([
|
|
13
|
-
{
|
|
14
|
-
id: "session",
|
|
15
|
-
label: "Session",
|
|
16
|
-
durationMinutes: 300,
|
|
17
|
-
usedPercent: 12.5,
|
|
18
|
-
resetsAt: "2026-09-27T13:52:07.000Z",
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
id: "weekly",
|
|
22
|
-
label: "Weekly",
|
|
23
|
-
durationMinutes: 10080,
|
|
24
|
-
usedPercent: 43.2,
|
|
25
|
-
resetsAt: "2026-10-04T08:52:07.000Z",
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
id: "spend-control",
|
|
29
|
-
label: "Spend control",
|
|
30
|
-
durationMinutes: null,
|
|
31
|
-
usedPercent: 1,
|
|
32
|
-
resetsAt: "2026-12-01T00:00:00.000Z",
|
|
33
|
-
limitType: "CREDIT_LIMIT",
|
|
34
|
-
total: 3000,
|
|
35
|
-
current: 33.43525505065918,
|
|
36
|
-
remaining: 2966.564744949341,
|
|
37
|
-
},
|
|
38
|
-
]);
|
|
39
|
-
expect(snapshot).toMatchObject({ authenticated: true, available: "yes" });
|
|
40
|
-
expect(snapshot.creditsRemaining).toBe(4.5);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("accepts epoch seconds and ISO strings for reset_at", () => {
|
|
44
|
-
expect(toRateWindow({ used_percent: 1, reset_at: 1_787_220_000 }, "a", "A")?.resetsAt).toBe(
|
|
45
|
-
"2026-08-20T10:00:00.000Z",
|
|
46
|
-
);
|
|
47
|
-
expect(
|
|
48
|
-
toRateWindow({ used_percent: 1, reset_at: "2026-08-20T10:00:00Z" }, "a", "A")?.resetsAt,
|
|
49
|
-
).toBe("2026-08-20T10:00:00.000Z");
|
|
50
|
-
expect(toRateWindow({ used_percent: 1, reset_at: "nope" }, "a", "A")?.resetsAt).toBeNull();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("maps additional_rate_limits into scoped windows and tolerates non-array values", () => {
|
|
54
|
-
const scoped = parseWhamUsage({
|
|
55
|
-
rate_limit: {},
|
|
56
|
-
additional_rate_limits: [
|
|
57
|
-
{
|
|
58
|
-
limit_name: "code-review",
|
|
59
|
-
rate_limit: {
|
|
60
|
-
primary_window: { used_percent: 10, limit_window_seconds: 3600, reset_at: 100 },
|
|
61
|
-
secondary_window: { used_percent: 20, limit_window_seconds: 7200, reset_at: 200 },
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
});
|
|
66
|
-
expect(scoped.windows.map((window) => window.id)).toEqual([
|
|
67
|
-
"code-review:primary",
|
|
68
|
-
"code-review:secondary",
|
|
69
|
-
]);
|
|
70
|
-
expect(parseWhamUsage({ additional_rate_limits: null }).windows).toEqual([]);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("falls back to positional ids and inline windows for degraded extra limits", () => {
|
|
74
|
-
const scoped = parseWhamUsage({
|
|
75
|
-
additional_rate_limits: [
|
|
76
|
-
null,
|
|
77
|
-
42,
|
|
78
|
-
{ primary_window: { used_percent: 5 } },
|
|
79
|
-
{ limit_name: "not/safe", primary_window: { used_percent: 6 } },
|
|
80
|
-
{ limit_name: "token-123456", primary_window: { used_percent: 7 } },
|
|
81
|
-
{ limit_name: "ok", secondary_window: { used_percent: 8 } },
|
|
82
|
-
],
|
|
83
|
-
});
|
|
84
|
-
expect(scoped.windows.map((window) => window.id)).toEqual([
|
|
85
|
-
"extra-3:primary",
|
|
86
|
-
"extra-4:primary",
|
|
87
|
-
"extra-5:primary",
|
|
88
|
-
"ok:secondary",
|
|
89
|
-
]);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it("parses non-object payloads into an empty snapshot", () => {
|
|
93
|
-
const emptySnapshot = {
|
|
94
|
-
authenticated: true,
|
|
95
|
-
available: "unknown",
|
|
96
|
-
windows: [],
|
|
97
|
-
creditsRemaining: null,
|
|
98
|
-
};
|
|
99
|
-
expect(parseWhamUsage(null)).toEqual(emptySnapshot);
|
|
100
|
-
expect(parseWhamUsage(42)).toEqual(emptySnapshot);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it("never invents usage for windows it cannot parse", () => {
|
|
104
|
-
const snapshot = parseWhamUsage({
|
|
105
|
-
rate_limit: {
|
|
106
|
-
primary_window: { limit_window_seconds: 18000 },
|
|
107
|
-
secondary_window: null,
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
expect(snapshot.windows).toEqual([
|
|
111
|
-
{
|
|
112
|
-
id: "session",
|
|
113
|
-
label: "Session",
|
|
114
|
-
durationMinutes: 300,
|
|
115
|
-
usedPercent: null,
|
|
116
|
-
resetsAt: null,
|
|
117
|
-
},
|
|
118
|
-
]);
|
|
119
|
-
expect(parseWhamUsage({}).creditsRemaining).toBeNull();
|
|
120
|
-
expect(parseWhamUsage({ credits: { balance: "nan" } }).creditsRemaining).toBeNull();
|
|
121
|
-
});
|
|
122
|
-
});
|