@wengine-ai/llms 2.3.234 → 2.3.236
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 +2 -2
- package/dist/ccr/config.d.ts +6 -0
- package/dist/cjs/server.cjs +52 -52
- package/dist/cjs/server.cjs.map +3 -3
- package/dist/clients/adapters.d.ts +0 -1
- package/dist/esm/server.mjs +44 -44
- package/dist/esm/server.mjs.map +3 -3
- package/dist/index.html +24 -24
- package/dist/services/quota-adapters.d.ts +19 -0
- package/dist/types/llm.d.ts +9 -0
- package/package.json +2 -2
- package/vitest.config.ts +16 -1
|
@@ -13,4 +13,23 @@ export interface ProviderQuotaResult {
|
|
|
13
13
|
export interface QuotaAdapter {
|
|
14
14
|
queryQuota(provider: LLMProvider, timeoutMs: number, proxyUrl?: string): Promise<ProviderQuotaResult | null>;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Parse the response payload from the cs-data.qianwenai.com tokenplan usage
|
|
18
|
+
* endpoint into a ProviderQuotaResult.
|
|
19
|
+
*
|
|
20
|
+
* Confirmed response shape (authenticated sample):
|
|
21
|
+
* payload.data.DataV2.data.data = {
|
|
22
|
+
* per5HourPercentage: 0.0663, // fraction in [0,1] used this 5h window
|
|
23
|
+
* per1WeekPercentage: 0.3743, // fraction in [0,1] used this 7d window
|
|
24
|
+
* per5HourResetTime: 1784546640000, // ms epoch, 5h window reset
|
|
25
|
+
* per1WeekResetTime: 1785058140000 // ms epoch, 7d window reset
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* The endpoint returns USAGE FRACTIONS, not absolute token counts. We map each
|
|
29
|
+
* fraction to a percentage display: used = fraction*100, limit = 100, which the
|
|
30
|
+
* UI renders as "6.6%" (matching the Zhipu TOKENS_LIMIT percentage path). The
|
|
31
|
+
* gateway error envelope (success:false / errorCode) is rejected up front so
|
|
32
|
+
* an unauthenticated NotLogined response is never mined for quota.
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseAliyunTokenPlanUsage(payload: any): ProviderQuotaResult | null;
|
|
16
35
|
export declare function getQuotaAdapter(baseUrl: string): QuotaAdapter | null;
|
package/dist/types/llm.d.ts
CHANGED
|
@@ -174,6 +174,13 @@ export interface LLMProvider {
|
|
|
174
174
|
models: string[];
|
|
175
175
|
/** Optional token for quota/billing APIs that require separate authentication (e.g. Zhipu web console JWT) */
|
|
176
176
|
quotaToken?: string;
|
|
177
|
+
/**
|
|
178
|
+
* Optional sec_token for the Aliyun Bailian console official quota API
|
|
179
|
+
* (efm-fe 3.5.613 format). When present, the AliyunTokenPlanQuotaAdapter
|
|
180
|
+
* prefers the official bailian-cs.console.aliyun.com gateway and falls
|
|
181
|
+
* back to the legacy cs-data.qianwenai.com endpoint on failure.
|
|
182
|
+
*/
|
|
183
|
+
quotaSecToken?: string;
|
|
177
184
|
transformer?: {
|
|
178
185
|
[key: string]: {
|
|
179
186
|
use?: Transformer[];
|
|
@@ -211,6 +218,8 @@ export interface ConfigProvider {
|
|
|
211
218
|
models: string[];
|
|
212
219
|
/** Optional token for quota/billing APIs that require separate authentication */
|
|
213
220
|
quota_token?: string;
|
|
221
|
+
/** Optional sec_token for the Aliyun Bailian console official quota API (efm-fe 3.5.613 format) */
|
|
222
|
+
quota_sec_token?: string;
|
|
214
223
|
transformer: {
|
|
215
224
|
use?: string[] | Array<any>[];
|
|
216
225
|
} & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wengine-ai/llms",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.236",
|
|
4
4
|
"description": "A universal LLM API transformation server",
|
|
5
5
|
"main": "dist/cjs/server.cjs",
|
|
6
6
|
"module": "dist/esm/server.mjs",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"uuid": "^11.1.0",
|
|
53
53
|
"@fastify/multipart": "^9.0.0",
|
|
54
54
|
"@fastify/static": "^8.2.0",
|
|
55
|
-
"@wengine-ai/claude-code-router-shared": "
|
|
55
|
+
"@wengine-ai/claude-code-router-shared": "^2.3.236",
|
|
56
56
|
"adm-zip": "^0.5.16",
|
|
57
57
|
"better-sqlite3": "^12.10.0",
|
|
58
58
|
"rotating-file-stream": "^3.2.7"
|
package/vitest.config.ts
CHANGED
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
import { defineConfig } from "vitest/config";
|
|
2
2
|
import path from "path";
|
|
3
|
+
import { mkdirSync, rmSync } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
|
|
6
|
+
// Isolated HOME for tests. The temp dir is created at config-load time so its
|
|
7
|
+
// path can be passed through the `env` option, which vitest propagates to every
|
|
8
|
+
// worker. Mutating process.env inside globalSetup does NOT reliably reach worker
|
|
9
|
+
// threads (the prior approach silently left CCR_CONFIG_DIR empty, so HOME_DIR
|
|
10
|
+
// fell back to the user's real ~/.claude-code-router and tests wrote real state).
|
|
11
|
+
// A deterministic path lets the globalSetup teardown clean the same directory.
|
|
12
|
+
const TEST_HOME = path.join(tmpdir(), "ccr-core-test-home");
|
|
13
|
+
rmSync(TEST_HOME, { recursive: true, force: true });
|
|
14
|
+
mkdirSync(TEST_HOME, { recursive: true });
|
|
3
15
|
|
|
4
16
|
export default defineConfig({
|
|
5
17
|
test: {
|
|
6
18
|
include: ["src/__tests__/**/*.test.ts"],
|
|
19
|
+
globalSetup: ["./src/__tests__/setup.ts"],
|
|
20
|
+
env: {
|
|
21
|
+
CCR_CONFIG_DIR: TEST_HOME,
|
|
22
|
+
},
|
|
7
23
|
},
|
|
8
24
|
resolve: {
|
|
9
25
|
alias: {
|
|
10
26
|
"@": path.resolve(__dirname, "src"),
|
|
11
|
-
"@wengine-ai/claude-code-router-shared": path.resolve(__dirname, "../shared/src/index.ts"),
|
|
12
27
|
},
|
|
13
28
|
},
|
|
14
29
|
});
|