@framers/agentos 0.1.194 → 0.1.195
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/core/providers/ApiKeyPoolRegistry.d.ts +18 -0
- package/dist/core/providers/ApiKeyPoolRegistry.d.ts.map +1 -0
- package/dist/core/providers/ApiKeyPoolRegistry.js +28 -0
- package/dist/core/providers/ApiKeyPoolRegistry.js.map +1 -0
- package/dist/core/providers/index.d.ts +4 -0
- package/dist/core/providers/index.d.ts.map +1 -0
- package/dist/core/providers/index.js +4 -0
- package/dist/core/providers/index.js.map +1 -0
- package/dist/core/providers/quotaErrors.d.ts +15 -0
- package/dist/core/providers/quotaErrors.d.ts.map +1 -0
- package/dist/core/providers/quotaErrors.js +33 -0
- package/dist/core/providers/quotaErrors.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/providers/ApiKeyPoolRegistry
|
|
3
|
+
*
|
|
4
|
+
* Singleton registry for API key pools keyed by environment variable name.
|
|
5
|
+
* Providers that share the same env var (e.g., all ElevenLabs providers
|
|
6
|
+
* share ELEVENLABS_API_KEY) get the same pool instance so exhaustion
|
|
7
|
+
* state is consistent across the process.
|
|
8
|
+
*/
|
|
9
|
+
import { ApiKeyPool, type ApiKeyPoolConfig } from './ApiKeyPool.js';
|
|
10
|
+
/**
|
|
11
|
+
* Get or create an ApiKeyPool for the given environment variable.
|
|
12
|
+
* Returns a singleton -- the same pool is returned on subsequent calls
|
|
13
|
+
* with the same env var name.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getKeyPool(envVar: string, config?: ApiKeyPoolConfig): ApiKeyPool;
|
|
16
|
+
/** Reset all pools. For testing only. */
|
|
17
|
+
export declare function resetAllPools(): void;
|
|
18
|
+
//# sourceMappingURL=ApiKeyPoolRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiKeyPoolRegistry.d.ts","sourceRoot":"","sources":["../../../src/core/providers/ApiKeyPoolRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAIpE;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,gBAAgB,GAAG,UAAU,CAOhF;AAED,yCAAyC;AACzC,wBAAgB,aAAa,IAAI,IAAI,CAEpC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/providers/ApiKeyPoolRegistry
|
|
3
|
+
*
|
|
4
|
+
* Singleton registry for API key pools keyed by environment variable name.
|
|
5
|
+
* Providers that share the same env var (e.g., all ElevenLabs providers
|
|
6
|
+
* share ELEVENLABS_API_KEY) get the same pool instance so exhaustion
|
|
7
|
+
* state is consistent across the process.
|
|
8
|
+
*/
|
|
9
|
+
import { ApiKeyPool } from './ApiKeyPool.js';
|
|
10
|
+
const pools = new Map();
|
|
11
|
+
/**
|
|
12
|
+
* Get or create an ApiKeyPool for the given environment variable.
|
|
13
|
+
* Returns a singleton -- the same pool is returned on subsequent calls
|
|
14
|
+
* with the same env var name.
|
|
15
|
+
*/
|
|
16
|
+
export function getKeyPool(envVar, config) {
|
|
17
|
+
let pool = pools.get(envVar);
|
|
18
|
+
if (!pool) {
|
|
19
|
+
pool = new ApiKeyPool(process.env[envVar] ?? '', config);
|
|
20
|
+
pools.set(envVar, pool);
|
|
21
|
+
}
|
|
22
|
+
return pool;
|
|
23
|
+
}
|
|
24
|
+
/** Reset all pools. For testing only. */
|
|
25
|
+
export function resetAllPools() {
|
|
26
|
+
pools.clear();
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=ApiKeyPoolRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiKeyPoolRegistry.js","sourceRoot":"","sources":["../../../src/core/providers/ApiKeyPoolRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAyB,MAAM,iBAAiB,CAAC;AAEpE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;AAE5C;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc,EAAE,MAAyB;IAClE,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,IAAI,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC;QACzD,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,yCAAyC;AACzC,MAAM,UAAU,aAAa;IAC3B,KAAK,CAAC,KAAK,EAAE,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAyB,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/providers/quotaErrors
|
|
3
|
+
*
|
|
4
|
+
* Detects quota-exhaustion and rate-limit errors across all provider APIs.
|
|
5
|
+
* Used by providers to decide when to rotate to the next API key.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Check if an HTTP error response indicates quota exhaustion or rate limiting.
|
|
9
|
+
*
|
|
10
|
+
* @param status - HTTP status code from the response.
|
|
11
|
+
* @param body - Response body text (can be empty).
|
|
12
|
+
* @returns `true` if this looks like a quota/rate-limit error.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isQuotaError(status: number, body: string): boolean;
|
|
15
|
+
//# sourceMappingURL=quotaErrors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quotaErrors.d.ts","sourceRoot":"","sources":["../../../src/core/providers/quotaErrors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAKlE"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/providers/quotaErrors
|
|
3
|
+
*
|
|
4
|
+
* Detects quota-exhaustion and rate-limit errors across all provider APIs.
|
|
5
|
+
* Used by providers to decide when to rotate to the next API key.
|
|
6
|
+
*/
|
|
7
|
+
/** Status codes that always indicate quota/rate-limit exhaustion. */
|
|
8
|
+
const QUOTA_STATUS_CODES = new Set([429, 402, 456]);
|
|
9
|
+
/** Substrings in response bodies that indicate quota exhaustion. */
|
|
10
|
+
const QUOTA_BODY_SIGNALS = [
|
|
11
|
+
'quota_exceeded',
|
|
12
|
+
'rate_limit_exceeded',
|
|
13
|
+
'insufficient_quota',
|
|
14
|
+
'overloaded_error',
|
|
15
|
+
'resource_exhausted',
|
|
16
|
+
'rate_limit',
|
|
17
|
+
];
|
|
18
|
+
/**
|
|
19
|
+
* Check if an HTTP error response indicates quota exhaustion or rate limiting.
|
|
20
|
+
*
|
|
21
|
+
* @param status - HTTP status code from the response.
|
|
22
|
+
* @param body - Response body text (can be empty).
|
|
23
|
+
* @returns `true` if this looks like a quota/rate-limit error.
|
|
24
|
+
*/
|
|
25
|
+
export function isQuotaError(status, body) {
|
|
26
|
+
if (QUOTA_STATUS_CODES.has(status))
|
|
27
|
+
return true;
|
|
28
|
+
if (!body)
|
|
29
|
+
return false;
|
|
30
|
+
const lower = body.toLowerCase();
|
|
31
|
+
return QUOTA_BODY_SIGNALS.some((signal) => lower.includes(signal));
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=quotaErrors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quotaErrors.js","sourceRoot":"","sources":["../../../src/core/providers/quotaErrors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qEAAqE;AACrE,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAEpD,oEAAoE;AACpE,MAAM,kBAAkB,GAAG;IACzB,gBAAgB;IAChB,qBAAqB;IACrB,oBAAoB;IACpB,kBAAkB;IAClB,oBAAoB;IACpB,YAAY;CACb,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,IAAY;IACvD,IAAI,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IAChD,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IACxB,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACjC,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AACrE,CAAC"}
|