opencode-qwen-auth 0.2.0 → 0.3.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/README.md +65 -21
- package/dist/src/cli/install.js +2 -2
- package/dist/src/cli/install.js.map +1 -1
- package/dist/src/plugin/account.d.ts +15 -2
- package/dist/src/plugin/account.d.ts.map +1 -1
- package/dist/src/plugin/account.js +53 -3
- package/dist/src/plugin/account.js.map +1 -1
- package/dist/src/plugin/config/index.d.ts +1 -1
- package/dist/src/plugin/config/index.d.ts.map +1 -1
- package/dist/src/plugin/config/index.js.map +1 -1
- package/dist/src/plugin/config/loader.d.ts +4 -1
- package/dist/src/plugin/config/loader.d.ts.map +1 -1
- package/dist/src/plugin/config/loader.js +21 -3
- package/dist/src/plugin/config/loader.js.map +1 -1
- package/dist/src/plugin/config/schema.d.ts +97 -3
- package/dist/src/plugin/config/schema.d.ts.map +1 -1
- package/dist/src/plugin/config/schema.js +17 -2
- package/dist/src/plugin/config/schema.js.map +1 -1
- package/dist/src/plugin/rotation.d.ts +208 -0
- package/dist/src/plugin/rotation.d.ts.map +1 -0
- package/dist/src/plugin/rotation.js +334 -0
- package/dist/src/plugin/rotation.js.map +1 -0
- package/dist/src/plugin.d.ts.map +1 -1
- package/dist/src/plugin.js +56 -2
- package/dist/src/plugin.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { QWEN_DEFAULT_API_BASE_URL, QWEN_DEFAULT_CLIENT_ID, QWEN_OAUTH_BASE_URL, } from "../../constants";
|
|
3
|
+
export const HealthScoreConfigSchema = z.object({
|
|
4
|
+
initial: z.number().min(0).max(100).default(70),
|
|
5
|
+
success_reward: z.number().default(1),
|
|
6
|
+
rate_limit_penalty: z.number().max(0).default(-10),
|
|
7
|
+
failure_penalty: z.number().max(0).default(-20),
|
|
8
|
+
recovery_rate_per_hour: z.number().min(0).default(2),
|
|
9
|
+
min_usable: z.number().min(0).max(100).default(50),
|
|
10
|
+
});
|
|
11
|
+
export const TokenBucketConfigSchema = z.object({
|
|
12
|
+
max_tokens: z.number().min(1).default(50),
|
|
13
|
+
regeneration_rate_per_minute: z.number().min(0).default(6),
|
|
14
|
+
});
|
|
3
15
|
export const QwenConfigSchema = z.object({
|
|
4
16
|
client_id: z.string().default(QWEN_DEFAULT_CLIENT_ID),
|
|
5
17
|
oauth_base_url: z.string().default(QWEN_OAUTH_BASE_URL),
|
|
6
18
|
base_url: z.string().default(QWEN_DEFAULT_API_BASE_URL),
|
|
7
19
|
rotation_strategy: z
|
|
8
|
-
.enum(["round-robin", "sequential"])
|
|
9
|
-
.default("
|
|
20
|
+
.enum(["round-robin", "sequential", "hybrid"])
|
|
21
|
+
.default("hybrid"),
|
|
10
22
|
proactive_refresh: z.boolean().default(true),
|
|
11
23
|
refresh_window_seconds: z.number().min(0).default(300),
|
|
12
24
|
max_rate_limit_wait_seconds: z.number().min(0).default(300),
|
|
13
25
|
quiet_mode: z.boolean().default(false),
|
|
26
|
+
pid_offset_enabled: z.boolean().default(false),
|
|
27
|
+
health_score: HealthScoreConfigSchema.optional(),
|
|
28
|
+
token_bucket: TokenBucketConfigSchema.optional(),
|
|
14
29
|
});
|
|
15
30
|
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/plugin/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,sBAAsB,CAAC;IACrD,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,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
+
*
|
|
4
|
+
* Implements advanced account selection algorithms:
|
|
5
|
+
* - Health Score: Track account wellness based on success/failure
|
|
6
|
+
* - Token Bucket: Client-side rate limiting to prevent 429s
|
|
7
|
+
* - LRU Selection: Prefer accounts with longest rest periods
|
|
8
|
+
* - Hybrid Selection: Weighted combination of all signals
|
|
9
|
+
*
|
|
10
|
+
* Used by 'hybrid' strategy for improved load distribution.
|
|
11
|
+
*/
|
|
12
|
+
export interface HealthScoreConfig {
|
|
13
|
+
/** Initial score for new accounts (default: 70) */
|
|
14
|
+
initial: number;
|
|
15
|
+
/** Points added on successful request (default: 1) */
|
|
16
|
+
successReward: number;
|
|
17
|
+
/** Points removed on rate limit (default: -10) */
|
|
18
|
+
rateLimitPenalty: number;
|
|
19
|
+
/** Points removed on failure (auth, network, etc.) (default: -20) */
|
|
20
|
+
failurePenalty: number;
|
|
21
|
+
/** Points recovered per hour of rest (default: 2) */
|
|
22
|
+
recoveryRatePerHour: number;
|
|
23
|
+
/** Minimum score to be considered usable (default: 50) */
|
|
24
|
+
minUsable: number;
|
|
25
|
+
/** Maximum score cap (default: 100) */
|
|
26
|
+
maxScore: number;
|
|
27
|
+
}
|
|
28
|
+
export declare const DEFAULT_HEALTH_SCORE_CONFIG: HealthScoreConfig;
|
|
29
|
+
export interface HealthScoreState {
|
|
30
|
+
score: number;
|
|
31
|
+
lastUpdated: number;
|
|
32
|
+
lastSuccess: number;
|
|
33
|
+
consecutiveFailures: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Tracks health scores for accounts.
|
|
37
|
+
* Higher score = healthier account = preferred for selection.
|
|
38
|
+
*/
|
|
39
|
+
export declare class HealthScoreTracker {
|
|
40
|
+
private readonly scores;
|
|
41
|
+
readonly config: HealthScoreConfig;
|
|
42
|
+
constructor(config?: Partial<HealthScoreConfig>);
|
|
43
|
+
/**
|
|
44
|
+
* Get current health score for an account, applying time-based recovery.
|
|
45
|
+
*/
|
|
46
|
+
getScore(accountIndex: number): number;
|
|
47
|
+
/**
|
|
48
|
+
* Record a successful request - improves health score.
|
|
49
|
+
*/
|
|
50
|
+
recordSuccess(accountIndex: number): void;
|
|
51
|
+
/**
|
|
52
|
+
* Record a rate limit hit - moderate penalty.
|
|
53
|
+
*/
|
|
54
|
+
recordRateLimit(accountIndex: number): void;
|
|
55
|
+
/**
|
|
56
|
+
* Record a failure (auth, network, etc.) - larger penalty.
|
|
57
|
+
*/
|
|
58
|
+
recordFailure(accountIndex: number): void;
|
|
59
|
+
/**
|
|
60
|
+
* Check if account is healthy enough to use.
|
|
61
|
+
*/
|
|
62
|
+
isUsable(accountIndex: number): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Get consecutive failure count for an account.
|
|
65
|
+
*/
|
|
66
|
+
getConsecutiveFailures(accountIndex: number): number;
|
|
67
|
+
/**
|
|
68
|
+
* Reset health state for an account (e.g., after removal).
|
|
69
|
+
*/
|
|
70
|
+
reset(accountIndex: number): void;
|
|
71
|
+
/**
|
|
72
|
+
* Export state for persistence.
|
|
73
|
+
*/
|
|
74
|
+
toJSON(): Record<string, HealthScoreState>;
|
|
75
|
+
/**
|
|
76
|
+
* Load state from persisted data.
|
|
77
|
+
*/
|
|
78
|
+
loadFromJSON(data: Record<string, HealthScoreState>): void;
|
|
79
|
+
/**
|
|
80
|
+
* Get all scores for debugging/logging.
|
|
81
|
+
*/
|
|
82
|
+
getSnapshot(): Map<number, {
|
|
83
|
+
score: number;
|
|
84
|
+
consecutiveFailures: number;
|
|
85
|
+
}>;
|
|
86
|
+
}
|
|
87
|
+
export interface TokenBucketConfig {
|
|
88
|
+
/** Maximum tokens per account (default: 50) */
|
|
89
|
+
maxTokens: number;
|
|
90
|
+
/** Tokens regenerated per minute (default: 6) */
|
|
91
|
+
regenerationRatePerMinute: number;
|
|
92
|
+
/** Initial tokens for new accounts (default: 50) */
|
|
93
|
+
initialTokens: number;
|
|
94
|
+
}
|
|
95
|
+
export declare const DEFAULT_TOKEN_BUCKET_CONFIG: TokenBucketConfig;
|
|
96
|
+
export interface TokenBucketState {
|
|
97
|
+
tokens: number;
|
|
98
|
+
lastUpdated: number;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Client-side rate limiting using Token Bucket algorithm.
|
|
102
|
+
* Helps prevent hitting server 429s by tracking "cost" of requests.
|
|
103
|
+
*/
|
|
104
|
+
export declare class TokenBucketTracker {
|
|
105
|
+
private readonly buckets;
|
|
106
|
+
private readonly config;
|
|
107
|
+
constructor(config?: Partial<TokenBucketConfig>);
|
|
108
|
+
/**
|
|
109
|
+
* Get current token balance for an account, applying regeneration.
|
|
110
|
+
*/
|
|
111
|
+
getTokens(accountIndex: number): number;
|
|
112
|
+
/**
|
|
113
|
+
* Check if account has enough tokens for a request.
|
|
114
|
+
* @param cost Cost of the request (default: 1)
|
|
115
|
+
*/
|
|
116
|
+
hasTokens(accountIndex: number, cost?: number): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Consume tokens for a request.
|
|
119
|
+
* @returns true if tokens were consumed, false if insufficient
|
|
120
|
+
*/
|
|
121
|
+
consume(accountIndex: number, cost?: number): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Refund tokens (e.g., if request wasn't actually sent).
|
|
124
|
+
*/
|
|
125
|
+
refund(accountIndex: number, amount?: number): void;
|
|
126
|
+
/**
|
|
127
|
+
* Get max tokens config value.
|
|
128
|
+
*/
|
|
129
|
+
getMaxTokens(): number;
|
|
130
|
+
/**
|
|
131
|
+
* Export state for persistence.
|
|
132
|
+
*/
|
|
133
|
+
toJSON(): Record<string, TokenBucketState>;
|
|
134
|
+
/**
|
|
135
|
+
* Load state from persisted data.
|
|
136
|
+
*/
|
|
137
|
+
loadFromJSON(data: Record<string, TokenBucketState>): void;
|
|
138
|
+
}
|
|
139
|
+
export interface AccountWithMetrics {
|
|
140
|
+
index: number;
|
|
141
|
+
lastUsed: number;
|
|
142
|
+
healthScore: number;
|
|
143
|
+
tokens: number;
|
|
144
|
+
isRateLimited: boolean;
|
|
145
|
+
}
|
|
146
|
+
export interface ScoreBreakdown {
|
|
147
|
+
health: number;
|
|
148
|
+
tokens: number;
|
|
149
|
+
freshness: number;
|
|
150
|
+
}
|
|
151
|
+
export interface HybridSelectionResult {
|
|
152
|
+
index: number;
|
|
153
|
+
score: number;
|
|
154
|
+
breakdown: ScoreBreakdown;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Calculate hybrid score for an account.
|
|
158
|
+
* Score = (health × 2) + (tokens × 5) + (freshness × 0.1)
|
|
159
|
+
*
|
|
160
|
+
* Weight breakdown:
|
|
161
|
+
* - Token balance: 50% influence (500 points max)
|
|
162
|
+
* - Health score: 20% influence (200 points max)
|
|
163
|
+
* - Freshness (LRU): 36% influence (360 points max)
|
|
164
|
+
*/
|
|
165
|
+
export declare function calculateHybridScore(account: AccountWithMetrics, maxTokens: number): {
|
|
166
|
+
score: number;
|
|
167
|
+
breakdown: ScoreBreakdown;
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Select account using hybrid strategy.
|
|
171
|
+
*
|
|
172
|
+
* Algorithm:
|
|
173
|
+
* 1. Filter available accounts (not rate-limited, healthy, has tokens)
|
|
174
|
+
* 2. Calculate priority score for each
|
|
175
|
+
* 3. Sort by score descending
|
|
176
|
+
* 4. Return the best candidate (deterministic - highest score)
|
|
177
|
+
*
|
|
178
|
+
* @param accounts - All accounts with their metrics
|
|
179
|
+
* @param minHealthScore - Minimum health score to be considered (default: 50)
|
|
180
|
+
* @param maxTokens - Maximum tokens for percentage calculation (default: 50)
|
|
181
|
+
* @returns Best account selection result, or null if none available
|
|
182
|
+
*/
|
|
183
|
+
export declare function selectHybridAccount(accounts: AccountWithMetrics[], minHealthScore?: number, maxTokens?: number): HybridSelectionResult | null;
|
|
184
|
+
/**
|
|
185
|
+
* Get the global health score tracker instance.
|
|
186
|
+
* Creates one with default config if not initialized.
|
|
187
|
+
*/
|
|
188
|
+
export declare function getHealthTracker(): HealthScoreTracker;
|
|
189
|
+
/**
|
|
190
|
+
* Initialize the global health tracker with custom config.
|
|
191
|
+
* Call this at plugin startup if custom config is needed.
|
|
192
|
+
*/
|
|
193
|
+
export declare function initHealthTracker(config?: Partial<HealthScoreConfig>): HealthScoreTracker;
|
|
194
|
+
/**
|
|
195
|
+
* Get the global token bucket tracker instance.
|
|
196
|
+
* Creates one with default config if not initialized.
|
|
197
|
+
*/
|
|
198
|
+
export declare function getTokenTracker(): TokenBucketTracker;
|
|
199
|
+
/**
|
|
200
|
+
* Initialize the global token tracker with custom config.
|
|
201
|
+
* Call this at plugin startup if custom config is needed.
|
|
202
|
+
*/
|
|
203
|
+
export declare function initTokenTracker(config?: Partial<TokenBucketConfig>): TokenBucketTracker;
|
|
204
|
+
/**
|
|
205
|
+
* Reset all global trackers. Used for testing.
|
|
206
|
+
*/
|
|
207
|
+
export declare function resetTrackers(): void;
|
|
208
|
+
//# sourceMappingURL=rotation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rotation.d.ts","sourceRoot":"","sources":["../../../src/plugin/rotation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,MAAM,WAAW,iBAAiB;IAChC,mDAAmD;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,aAAa,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,gBAAgB,EAAE,MAAM,CAAC;IACzB,qEAAqE;IACrE,cAAc,EAAE,MAAM,CAAC;IACvB,qDAAqD;IACrD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,0DAA0D;IAC1D,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,2BAA2B,EAAE,iBAQzC,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,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E,MAAM,CAAC;IAAC,SAAS,EAAE,cAAc,CAAA;CAAE,CAmB9C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,kBAAkB,EAAE,EAC9B,cAAc,SAAK,EACnB,SAAS,SAAK,GACb,qBAAqB,GAAG,IAAI,CAyB9B;AASD;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,kBAAkB,CAKrD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAClC,kBAAkB,CAGpB;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,kBAAkB,CAKpD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAClC,kBAAkB,CAGpB;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAGpC"}
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Account Rotation System
|
|
3
|
+
*
|
|
4
|
+
* Implements advanced account selection algorithms:
|
|
5
|
+
* - Health Score: Track account wellness based on success/failure
|
|
6
|
+
* - Token Bucket: Client-side rate limiting to prevent 429s
|
|
7
|
+
* - LRU Selection: Prefer accounts with longest rest periods
|
|
8
|
+
* - Hybrid Selection: Weighted combination of all signals
|
|
9
|
+
*
|
|
10
|
+
* Used by 'hybrid' strategy for improved load distribution.
|
|
11
|
+
*/
|
|
12
|
+
export const DEFAULT_HEALTH_SCORE_CONFIG = {
|
|
13
|
+
initial: 70,
|
|
14
|
+
successReward: 1,
|
|
15
|
+
rateLimitPenalty: -10,
|
|
16
|
+
failurePenalty: -20,
|
|
17
|
+
recoveryRatePerHour: 2,
|
|
18
|
+
minUsable: 50,
|
|
19
|
+
maxScore: 100,
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Tracks health scores for accounts.
|
|
23
|
+
* Higher score = healthier account = preferred for selection.
|
|
24
|
+
*/
|
|
25
|
+
export class HealthScoreTracker {
|
|
26
|
+
scores = new Map();
|
|
27
|
+
config;
|
|
28
|
+
constructor(config = {}) {
|
|
29
|
+
this.config = { ...DEFAULT_HEALTH_SCORE_CONFIG, ...config };
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get current health score for an account, applying time-based recovery.
|
|
33
|
+
*/
|
|
34
|
+
getScore(accountIndex) {
|
|
35
|
+
const state = this.scores.get(accountIndex);
|
|
36
|
+
if (!state) {
|
|
37
|
+
return this.config.initial;
|
|
38
|
+
}
|
|
39
|
+
// Apply passive recovery based on time since last update
|
|
40
|
+
const now = Date.now();
|
|
41
|
+
const hoursSinceUpdate = (now - state.lastUpdated) / (1000 * 60 * 60);
|
|
42
|
+
const recoveredPoints = Math.floor(hoursSinceUpdate * this.config.recoveryRatePerHour);
|
|
43
|
+
return Math.min(this.config.maxScore, state.score + recoveredPoints);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Record a successful request - improves health score.
|
|
47
|
+
*/
|
|
48
|
+
recordSuccess(accountIndex) {
|
|
49
|
+
const now = Date.now();
|
|
50
|
+
const current = this.getScore(accountIndex);
|
|
51
|
+
this.scores.set(accountIndex, {
|
|
52
|
+
score: Math.min(this.config.maxScore, current + this.config.successReward),
|
|
53
|
+
lastUpdated: now,
|
|
54
|
+
lastSuccess: now,
|
|
55
|
+
consecutiveFailures: 0,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Record a rate limit hit - moderate penalty.
|
|
60
|
+
*/
|
|
61
|
+
recordRateLimit(accountIndex) {
|
|
62
|
+
const now = Date.now();
|
|
63
|
+
const state = this.scores.get(accountIndex);
|
|
64
|
+
const current = this.getScore(accountIndex);
|
|
65
|
+
this.scores.set(accountIndex, {
|
|
66
|
+
score: Math.max(0, current + this.config.rateLimitPenalty),
|
|
67
|
+
lastUpdated: now,
|
|
68
|
+
lastSuccess: state?.lastSuccess ?? 0,
|
|
69
|
+
consecutiveFailures: (state?.consecutiveFailures ?? 0) + 1,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Record a failure (auth, network, etc.) - larger penalty.
|
|
74
|
+
*/
|
|
75
|
+
recordFailure(accountIndex) {
|
|
76
|
+
const now = Date.now();
|
|
77
|
+
const state = this.scores.get(accountIndex);
|
|
78
|
+
const current = this.getScore(accountIndex);
|
|
79
|
+
this.scores.set(accountIndex, {
|
|
80
|
+
score: Math.max(0, current + this.config.failurePenalty),
|
|
81
|
+
lastUpdated: now,
|
|
82
|
+
lastSuccess: state?.lastSuccess ?? 0,
|
|
83
|
+
consecutiveFailures: (state?.consecutiveFailures ?? 0) + 1,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Check if account is healthy enough to use.
|
|
88
|
+
*/
|
|
89
|
+
isUsable(accountIndex) {
|
|
90
|
+
return this.getScore(accountIndex) >= this.config.minUsable;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get consecutive failure count for an account.
|
|
94
|
+
*/
|
|
95
|
+
getConsecutiveFailures(accountIndex) {
|
|
96
|
+
return this.scores.get(accountIndex)?.consecutiveFailures ?? 0;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Reset health state for an account (e.g., after removal).
|
|
100
|
+
*/
|
|
101
|
+
reset(accountIndex) {
|
|
102
|
+
this.scores.delete(accountIndex);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Export state for persistence.
|
|
106
|
+
*/
|
|
107
|
+
toJSON() {
|
|
108
|
+
const result = {};
|
|
109
|
+
for (const [index, state] of this.scores) {
|
|
110
|
+
result[String(index)] = { ...state };
|
|
111
|
+
}
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Load state from persisted data.
|
|
116
|
+
*/
|
|
117
|
+
loadFromJSON(data) {
|
|
118
|
+
this.scores.clear();
|
|
119
|
+
for (const [key, state] of Object.entries(data)) {
|
|
120
|
+
const index = Number.parseInt(key, 10);
|
|
121
|
+
if (!Number.isNaN(index) && state) {
|
|
122
|
+
this.scores.set(index, { ...state });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Get all scores for debugging/logging.
|
|
128
|
+
*/
|
|
129
|
+
getSnapshot() {
|
|
130
|
+
const result = new Map();
|
|
131
|
+
for (const [index] of this.scores) {
|
|
132
|
+
result.set(index, {
|
|
133
|
+
score: this.getScore(index),
|
|
134
|
+
consecutiveFailures: this.getConsecutiveFailures(index),
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
export const DEFAULT_TOKEN_BUCKET_CONFIG = {
|
|
141
|
+
maxTokens: 50,
|
|
142
|
+
regenerationRatePerMinute: 6,
|
|
143
|
+
initialTokens: 50,
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Client-side rate limiting using Token Bucket algorithm.
|
|
147
|
+
* Helps prevent hitting server 429s by tracking "cost" of requests.
|
|
148
|
+
*/
|
|
149
|
+
export class TokenBucketTracker {
|
|
150
|
+
buckets = new Map();
|
|
151
|
+
config;
|
|
152
|
+
constructor(config = {}) {
|
|
153
|
+
this.config = { ...DEFAULT_TOKEN_BUCKET_CONFIG, ...config };
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Get current token balance for an account, applying regeneration.
|
|
157
|
+
*/
|
|
158
|
+
getTokens(accountIndex) {
|
|
159
|
+
const state = this.buckets.get(accountIndex);
|
|
160
|
+
if (!state) {
|
|
161
|
+
return this.config.initialTokens;
|
|
162
|
+
}
|
|
163
|
+
const now = Date.now();
|
|
164
|
+
const minutesSinceUpdate = (now - state.lastUpdated) / (1000 * 60);
|
|
165
|
+
const recoveredTokens = minutesSinceUpdate * this.config.regenerationRatePerMinute;
|
|
166
|
+
return Math.min(this.config.maxTokens, state.tokens + recoveredTokens);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Check if account has enough tokens for a request.
|
|
170
|
+
* @param cost Cost of the request (default: 1)
|
|
171
|
+
*/
|
|
172
|
+
hasTokens(accountIndex, cost = 1) {
|
|
173
|
+
return this.getTokens(accountIndex) >= cost;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Consume tokens for a request.
|
|
177
|
+
* @returns true if tokens were consumed, false if insufficient
|
|
178
|
+
*/
|
|
179
|
+
consume(accountIndex, cost = 1) {
|
|
180
|
+
const current = this.getTokens(accountIndex);
|
|
181
|
+
if (current < cost) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
this.buckets.set(accountIndex, {
|
|
185
|
+
tokens: current - cost,
|
|
186
|
+
lastUpdated: Date.now(),
|
|
187
|
+
});
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Refund tokens (e.g., if request wasn't actually sent).
|
|
192
|
+
*/
|
|
193
|
+
refund(accountIndex, amount = 1) {
|
|
194
|
+
const current = this.getTokens(accountIndex);
|
|
195
|
+
this.buckets.set(accountIndex, {
|
|
196
|
+
tokens: Math.min(this.config.maxTokens, current + amount),
|
|
197
|
+
lastUpdated: Date.now(),
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Get max tokens config value.
|
|
202
|
+
*/
|
|
203
|
+
getMaxTokens() {
|
|
204
|
+
return this.config.maxTokens;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Export state for persistence.
|
|
208
|
+
*/
|
|
209
|
+
toJSON() {
|
|
210
|
+
const result = {};
|
|
211
|
+
for (const [index, state] of this.buckets) {
|
|
212
|
+
result[String(index)] = { ...state };
|
|
213
|
+
}
|
|
214
|
+
return result;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Load state from persisted data.
|
|
218
|
+
*/
|
|
219
|
+
loadFromJSON(data) {
|
|
220
|
+
this.buckets.clear();
|
|
221
|
+
for (const [key, state] of Object.entries(data)) {
|
|
222
|
+
const index = Number.parseInt(key, 10);
|
|
223
|
+
if (!Number.isNaN(index) && state) {
|
|
224
|
+
this.buckets.set(index, { ...state });
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Calculate hybrid score for an account.
|
|
231
|
+
* Score = (health × 2) + (tokens × 5) + (freshness × 0.1)
|
|
232
|
+
*
|
|
233
|
+
* Weight breakdown:
|
|
234
|
+
* - Token balance: 50% influence (500 points max)
|
|
235
|
+
* - Health score: 20% influence (200 points max)
|
|
236
|
+
* - Freshness (LRU): 36% influence (360 points max)
|
|
237
|
+
*/
|
|
238
|
+
export function calculateHybridScore(account, maxTokens) {
|
|
239
|
+
const healthComponent = account.healthScore * 2; // 0-200
|
|
240
|
+
const tokenComponent = (account.tokens / maxTokens) * 100 * 5; // 0-500
|
|
241
|
+
const secondsSinceUsed = Math.max(0, (Date.now() - account.lastUsed) / 1000);
|
|
242
|
+
const freshnessComponent = Math.min(secondsSinceUsed, 3600) * 0.1; // 0-360
|
|
243
|
+
const score = Math.max(0, healthComponent + tokenComponent + freshnessComponent);
|
|
244
|
+
return {
|
|
245
|
+
score,
|
|
246
|
+
breakdown: {
|
|
247
|
+
health: healthComponent,
|
|
248
|
+
tokens: tokenComponent,
|
|
249
|
+
freshness: freshnessComponent,
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Select account using hybrid strategy.
|
|
255
|
+
*
|
|
256
|
+
* Algorithm:
|
|
257
|
+
* 1. Filter available accounts (not rate-limited, healthy, has tokens)
|
|
258
|
+
* 2. Calculate priority score for each
|
|
259
|
+
* 3. Sort by score descending
|
|
260
|
+
* 4. Return the best candidate (deterministic - highest score)
|
|
261
|
+
*
|
|
262
|
+
* @param accounts - All accounts with their metrics
|
|
263
|
+
* @param minHealthScore - Minimum health score to be considered (default: 50)
|
|
264
|
+
* @param maxTokens - Maximum tokens for percentage calculation (default: 50)
|
|
265
|
+
* @returns Best account selection result, or null if none available
|
|
266
|
+
*/
|
|
267
|
+
export function selectHybridAccount(accounts, minHealthScore = 50, maxTokens = 50) {
|
|
268
|
+
const nonRateLimited = accounts.filter((acc) => !acc.isRateLimited);
|
|
269
|
+
if (nonRateLimited.length === 0) {
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
const idealCandidates = nonRateLimited.filter((acc) => acc.healthScore >= minHealthScore && acc.tokens >= 1);
|
|
273
|
+
const candidatesToScore = idealCandidates.length > 0 ? idealCandidates : nonRateLimited;
|
|
274
|
+
const scored = candidatesToScore
|
|
275
|
+
.map((acc) => {
|
|
276
|
+
const { score, breakdown } = calculateHybridScore(acc, maxTokens);
|
|
277
|
+
return {
|
|
278
|
+
index: acc.index,
|
|
279
|
+
score,
|
|
280
|
+
breakdown,
|
|
281
|
+
};
|
|
282
|
+
})
|
|
283
|
+
.sort((a, b) => b.score - a.score);
|
|
284
|
+
return scored[0] ?? null;
|
|
285
|
+
}
|
|
286
|
+
// ============================================================================
|
|
287
|
+
// SINGLETON TRACKERS
|
|
288
|
+
// ============================================================================
|
|
289
|
+
let globalHealthTracker = null;
|
|
290
|
+
let globalTokenTracker = null;
|
|
291
|
+
/**
|
|
292
|
+
* Get the global health score tracker instance.
|
|
293
|
+
* Creates one with default config if not initialized.
|
|
294
|
+
*/
|
|
295
|
+
export function getHealthTracker() {
|
|
296
|
+
if (!globalHealthTracker) {
|
|
297
|
+
globalHealthTracker = new HealthScoreTracker();
|
|
298
|
+
}
|
|
299
|
+
return globalHealthTracker;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Initialize the global health tracker with custom config.
|
|
303
|
+
* Call this at plugin startup if custom config is needed.
|
|
304
|
+
*/
|
|
305
|
+
export function initHealthTracker(config) {
|
|
306
|
+
globalHealthTracker = new HealthScoreTracker(config);
|
|
307
|
+
return globalHealthTracker;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Get the global token bucket tracker instance.
|
|
311
|
+
* Creates one with default config if not initialized.
|
|
312
|
+
*/
|
|
313
|
+
export function getTokenTracker() {
|
|
314
|
+
if (!globalTokenTracker) {
|
|
315
|
+
globalTokenTracker = new TokenBucketTracker();
|
|
316
|
+
}
|
|
317
|
+
return globalTokenTracker;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Initialize the global token tracker with custom config.
|
|
321
|
+
* Call this at plugin startup if custom config is needed.
|
|
322
|
+
*/
|
|
323
|
+
export function initTokenTracker(config) {
|
|
324
|
+
globalTokenTracker = new TokenBucketTracker(config);
|
|
325
|
+
return globalTokenTracker;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Reset all global trackers. Used for testing.
|
|
329
|
+
*/
|
|
330
|
+
export function resetTrackers() {
|
|
331
|
+
globalHealthTracker = null;
|
|
332
|
+
globalTokenTracker = null;
|
|
333
|
+
}
|
|
334
|
+
//# sourceMappingURL=rotation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rotation.js","sourceRoot":"","sources":["../../../src/plugin/rotation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAuBH,MAAM,CAAC,MAAM,2BAA2B,GAAsB;IAC5D,OAAO,EAAE,EAAE;IACX,aAAa,EAAE,CAAC;IAChB,gBAAgB,EAAE,CAAC,EAAE;IACrB,cAAc,EAAE,CAAC,EAAE;IACnB,mBAAmB,EAAE,CAAC;IACtB,SAAS,EAAE,EAAE;IACb,QAAQ,EAAE,GAAG;CACd,CAAC;AASF;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IACZ,MAAM,GAAG,IAAI,GAAG,EAA4B,CAAC;IACrD,MAAM,CAAoB;IAEnC,YAAY,SAAqC,EAAE;QACjD,IAAI,CAAC,MAAM,GAAG,EAAE,G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GAAG,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACrD,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,kBAAkB,GAAG,IAAI,kBAAkB,EAAE,CAAC;IAChD,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAmC;IAEnC,kBAAkB,GAAG,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACpD,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,mBAAmB,GAAG,IAAI,CAAC;IAC3B,kBAAkB,GAAG,IAAI,CAAC;AAC5B,CAAC"}
|
package/dist/src/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AA4FlD,iBAAS,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAcjD;AAED,iBAAS,gBAAgB,CACvB,KAAK,EAAE,WAAW,GAAG,GAAG,EACxB,OAAO,CAAC,EAAE,MAAM,GACf;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAgDjB;AA0HD,eAAO,MAAM,qBAAqB,GAC/B,YAAY,MAAM,KAAG,MA+XrB,CAAC;AAEJ,eAAO,MAAM,kBAAkB,QAAgC,CAAC;AAChE,eAAO,MAAM,eAAe,QAAqB,CAAC;AAElD,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,CAAC;AAElD,eAAe,eAAe,CAAC"}
|