mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-15 10:30:37 +09:00
refactor(quota): move provider quota logic into adapter layer, add unit tests
- Extract all Anthropic credential/API logic into claude-local/src/server/quota.ts - Extract all OpenAI/WHAM credential/API logic into codex-local/src/server/quota.ts - Add optional getQuotaWindows() to ServerAdapterModule in adapter-utils - Rewrite quota-windows.ts as a 29-line thin aggregator with zero provider knowledge - Wire getQuotaWindows into adapter registry for claude-local and codex-local - Add 47 unit tests covering toPercent, secondsToWindowLabel, WHAM normalization, readClaudeToken, readCodexToken, fetchClaudeQuota, fetchCodexQuota, fetchWithTimeout - Add 8 unit tests covering parseDateRange validation and byProvider pro-rata math Adding a third provider now requires only touching that provider's adapter.
This commit is contained in:
parent
f383a37b01
commit
656b4659fc
10 changed files with 1149 additions and 262 deletions
|
|
@ -3,12 +3,14 @@ import {
|
|||
execute as claudeExecute,
|
||||
testEnvironment as claudeTestEnvironment,
|
||||
sessionCodec as claudeSessionCodec,
|
||||
getQuotaWindows as claudeGetQuotaWindows,
|
||||
} from "@paperclipai/adapter-claude-local/server";
|
||||
import { agentConfigurationDoc as claudeAgentConfigurationDoc, models as claudeModels } from "@paperclipai/adapter-claude-local";
|
||||
import {
|
||||
execute as codexExecute,
|
||||
testEnvironment as codexTestEnvironment,
|
||||
sessionCodec as codexSessionCodec,
|
||||
getQuotaWindows as codexGetQuotaWindows,
|
||||
} from "@paperclipai/adapter-codex-local/server";
|
||||
import { agentConfigurationDoc as codexAgentConfigurationDoc, models as codexModels } from "@paperclipai/adapter-codex-local";
|
||||
import {
|
||||
|
|
@ -71,6 +73,7 @@ const claudeLocalAdapter: ServerAdapterModule = {
|
|||
models: claudeModels,
|
||||
supportsLocalAgentJwt: true,
|
||||
agentConfigurationDoc: claudeAgentConfigurationDoc,
|
||||
getQuotaWindows: claudeGetQuotaWindows,
|
||||
};
|
||||
|
||||
const codexLocalAdapter: ServerAdapterModule = {
|
||||
|
|
@ -82,6 +85,7 @@ const codexLocalAdapter: ServerAdapterModule = {
|
|||
listModels: listCodexModels,
|
||||
supportsLocalAgentJwt: true,
|
||||
agentConfigurationDoc: codexAgentConfigurationDoc,
|
||||
getQuotaWindows: codexGetQuotaWindows,
|
||||
};
|
||||
|
||||
const cursorLocalAdapter: ServerAdapterModule = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue