@wengine-ai/llms 2.3.2435 → 2.3.2437
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/api/routes.d.ts +1 -0
- package/dist/ccr/chat-completion-capture.d.ts +3 -0
- package/dist/ccr/config.d.ts +2 -0
- package/dist/ccr/effective-input-usage.d.ts +35 -0
- package/dist/ccr/plugin-install-routes.d.ts +6 -1
- package/dist/ccr/request-pipeline.d.ts +0 -23
- package/dist/ccr/usage-merge.d.ts +2 -0
- package/dist/ccr/usage-store.d.ts +21 -43
- package/dist/cjs/server.cjs +228 -234
- package/dist/cjs/server.cjs.map +4 -4
- package/dist/esm/server.mjs +228 -234
- package/dist/esm/server.mjs.map +4 -4
- package/dist/index.html +29 -29
- package/dist/provider-plugins/host.d.ts +1 -1
- package/dist/provider-plugins/types.d.ts +6 -0
- package/dist/services/quota-adapters.d.ts +10 -1
- package/dist/services/step-plan-quota.d.ts +35 -0
- package/dist/types/llm.d.ts +19 -0
- package/dist/utils/cache.d.ts +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -93,6 +93,8 @@ npm install -g @wengine-ai/claude-code-router-next@latest && ccr restart
|
|
|
93
93
|
|
|
94
94
|
| 版本 | 发布内容 |
|
|
95
95
|
| --- | --- |
|
|
96
|
+
| **v2.3.2437** | CCR Desktop 新增 Windows x64 安装包、登录启动、通用设置、供应商与插件管理、项目搜索及用量自动刷新。本版也更新了额度展示、用量统计和 Gemini、Codex 的请求处理。 |
|
|
97
|
+
| **v2.3.2436** | Agy ACP 供应商支持工具调用:插件把调用方的工具通过只监听 127.0.0.1 的本地 MCP 服务发布给 agent,调用方收到 `tool_calls`,带回结果的后续请求续跑同一个 ACP 回合;agent 不执行任何工具,桥的凭据只传给 agent 子进程。卡片补全连接/断开/模型同步/模型隐藏闭环,并支持 agy 首次使用自动安装与 Google 账号登录。用量记录保留上游稳定错误码,Chat Completions 的最终结果按实际服务方记入。 |
|
|
96
98
|
| **v2.3.2435** | 修复流式 Chat 请求启用用量统计时被 Codex 拒绝的问题。CCR 转为 Responses 请求时会移除 Chat 专用的 include_usage 字段。 |
|
|
97
99
|
| **v2.3.2434** | Chat Completions 按模型族配置切换备用通道。Anthropic 备用通道返回标准 Chat 格式,调用记录按实际服务方记入最终结果。带工具的模型族请求会跳过纯文本 Agy ACP。 |
|
|
98
100
|
| **v2.3.2433** | <ul><li>**桌面控制中心套件**:菜单栏全供应商额度面板(K/M/B + 焦点看门狗防卡死)、独立本地控制中心与内置网关运行时、项目配置页(按项目路由/别名/客户端接管)。</li><li>**桌面用量分析**:缓存感知有效输入总 tokens(不重复计数)、模型/提供方/日期缓存列、纯 CSS 图表、分页调用记录(成功率/TTFT/速度)。</li><li>**火山 Coding Plan 配额**(AK/SK 本地凭证面板 + SigV4 适配);**Kimi 5h 窗口恢复**(上游缺 remaining 时不再消失)。</li><li>**Codex 套餐升级配额恢复 + UI HTML 协商缓存 + 卡片确认居中模态 + 冷却中同步模型可点**;插件:codex 1.0.14 / kiro 0.1.3 / workbuddy 1.0.3 / gemini-oauth 1.0.14。</li></ul> |
|
|
@@ -101,8 +103,6 @@ npm install -g @wengine-ai/claude-code-router-next@latest && ccr restart
|
|
|
101
103
|
| **v2.3.2430** | <ul><li>**Gemini OAuth 长会话 400 修复(插件 1.0.11)**:无签名的工具调用历史补哨兵、伪造/非法/外部(GLM 24位 hex)签名在发送前拦截;带 schema 的客户端 `web_search` 不再被误转成 Google 内置搜索。111 条消息/39 个工具的失败会话重放流式与非流式均 200。</li><li>**Gemini 流式缓存命中统计恢复(插件 1.0.11)**:收尾空文本帧携带的 `cachedContentTokenCount` 与 `finishReason` 不再被整帧丢弃,流式请求的缓存命中/最终 token 数/stop reason 正确记录(实测 ~93k token 提示词缓存命中 91067,此前恒为 0)。</li></ul> |
|
|
102
104
|
| **v2.3.2429** | <ul><li>**Codex 手动用量重置**:卡片展示赠送的重置次数(来自上游),确认弹窗是唯一消耗入口;同步锁拒绝并发重复点击,重试复用幂等键,丢失响应不双花;kiro 0.1.1 随包发布。</li><li>**Gemini 传输与配额修复**:省略 Content-Type 时识别 Code Assist SSE;配额走共享管线;恢复后不再残留失败横幅。</li><li>**精确模型路由修复**:供应商显式暴露的模型 id 短路家族路由,Gemini 的 Claude 模型可按名称直达。</li><li>**Codex 掉登录修复**:剥离 Responses input 中的 thinking 字段(上游 400 根因);成功输出清除错误残留。</li></ul> |
|
|
103
105
|
| **v2.3.2428** | <ul><li>**配额适配器 gzip 修复**:经代理的配额请求固定 `Accept-Encoding: identity`,避免 undici 未解压 gzip 导致解析失败、卡片不显示用量(智谱等供应商恢复配额展示)。</li></ul> |
|
|
104
|
-
| **v2.3.2427** | <ul><li>**配额窗口过期修复**:重置时间已过的窗口不再被当作当前用量展示,卡片回退到本地 token 统计,不再卡死在旧百分比上。</li></ul> |
|
|
105
|
-
| **v2.3.2426** | <ul><li>**Gemini (Antigravity) 模型隐藏/恢复**:卡片列出可见模型 chips(带隐藏按钮)与隐藏列表(恢复/全部恢复);隐藏时自动清理 Router 引用并回退默认路由,失败完整回滚。</li></ul> |
|
|
106
106
|
|
|
107
107
|
> 仅保留最近 10 个版本,更早版本的发布摘要见 [CHANGELOG-archive.md](./CHANGELOG-archive.md),完整详细变更记录见 [CHANGELOG.md](./CHANGELOG.md)。
|
|
108
108
|
|
package/dist/api/routes.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import { type InputUsageCapture } from "./effective-input-usage";
|
|
1
2
|
import type { Usage } from "../utils/cache";
|
|
2
3
|
export interface ChatCompletionCapture {
|
|
3
4
|
usage?: Usage & {
|
|
4
5
|
usage_estimated?: boolean;
|
|
5
6
|
};
|
|
7
|
+
inputUsage?: InputUsageCapture;
|
|
6
8
|
ttft?: number;
|
|
7
9
|
finished?: boolean;
|
|
8
10
|
streamError?: boolean;
|
|
9
11
|
rateLimited?: boolean;
|
|
12
|
+
streamErrorCode?: string;
|
|
10
13
|
unbookedAttempt?: {
|
|
11
14
|
provider: string;
|
|
12
15
|
model: string;
|
package/dist/ccr/config.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export declare const interpolateEnvVars: (obj: any) => any;
|
|
1
2
|
export declare const initDir: () => Promise<void>;
|
|
2
3
|
export declare const readConfigFileRaw: () => Promise<any>;
|
|
3
4
|
export declare const readConfigFile: () => Promise<any>;
|
|
5
|
+
export declare const readConfigFileSafe: (jsonPath?: string) => Promise<any>;
|
|
4
6
|
export declare const backupConfigFile: () => Promise<string | null>;
|
|
5
7
|
export declare const writeConfigFile: (config: any) => Promise<void>;
|
|
6
8
|
/**
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type UsageFormat = "chat" | "responses" | "anthropic" | "anthropic-inclusive";
|
|
2
|
+
type InputUsage = {
|
|
3
|
+
input?: number;
|
|
4
|
+
read?: number;
|
|
5
|
+
write?: number;
|
|
6
|
+
estimated?: boolean;
|
|
7
|
+
kiroChat?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type InputUsageCapture = {
|
|
10
|
+
format: UsageFormat;
|
|
11
|
+
usage: InputUsage;
|
|
12
|
+
};
|
|
13
|
+
/** Keep the earliest source format when a request runs through multiple converters. */
|
|
14
|
+
export declare function startInputUsageCapture(request: {
|
|
15
|
+
sourceInputUsage?: InputUsageCapture;
|
|
16
|
+
} | undefined, format: UsageFormat): {
|
|
17
|
+
format: UsageFormat;
|
|
18
|
+
usage: {};
|
|
19
|
+
} | undefined;
|
|
20
|
+
/** Observe original counters before normalization fills missing cache buckets with zero. */
|
|
21
|
+
export declare function captureInputUsage(capture: InputUsageCapture | undefined, frame: any): void;
|
|
22
|
+
/** Inclusive input for a request whose source protocol was captured.
|
|
23
|
+
*
|
|
24
|
+
* Chat/Responses prompts already contain cached tokens; standard Anthropic
|
|
25
|
+
* counts add both cache buckets; Kiro Chat folds reads into prompt_tokens and
|
|
26
|
+
* reports writes separately. The total is normalized strictly from the reported
|
|
27
|
+
* counters (an omitted bucket is zero) — never padded with a router estimate.
|
|
28
|
+
* When no usage counters were reported at all the inclusive input is unknown and
|
|
29
|
+
* the result is null rather than an approximation. Provider-estimated counts keep
|
|
30
|
+
* their known-protocol normalization and stay flagged as estimated. */
|
|
31
|
+
export declare function effectiveInputUsage(capture: InputUsageCapture | undefined): {
|
|
32
|
+
effectiveInputTokens: number | null;
|
|
33
|
+
effectiveInputTokensSource?: "estimated";
|
|
34
|
+
};
|
|
35
|
+
export {};
|
|
@@ -8,11 +8,14 @@
|
|
|
8
8
|
* upsert plugins.json. Nothing hot-loads; callers restart via the existing
|
|
9
9
|
* POST /api/restart flow.
|
|
10
10
|
*
|
|
11
|
+
* POST /api/plugins/install-pinned additionally requires the confirmed release
|
|
12
|
+
* and the previous install identity (null for a new install).
|
|
13
|
+
*
|
|
11
14
|
* GET /api/plugins/catalog — npm registry search for installable provider
|
|
12
15
|
* plugins (marker keyword), merged/deduped, with installed state. Registry
|
|
13
16
|
* failures degrade to an empty list + warning, never a 500.
|
|
14
17
|
*
|
|
15
|
-
*
|
|
18
|
+
* Marketplace routes are LOCAL-ONLY (socket-address identity + loopback Origin/Host
|
|
16
19
|
* pinning, mirroring the workbuddy admin-route guard) on top of the normal
|
|
17
20
|
* CCR auth pipeline. Responses never include npm stderr, registry URLs or any
|
|
18
21
|
* credential material.
|
|
@@ -31,6 +34,8 @@ export interface CatalogEntry {
|
|
|
31
34
|
version: string;
|
|
32
35
|
installed: boolean;
|
|
33
36
|
installedVersion: string | null;
|
|
37
|
+
/** Manifest id when the recorded npm source identifies this package. */
|
|
38
|
+
installedName?: string;
|
|
34
39
|
/**
|
|
35
40
|
* Present only when npm offers a newer valid semantic version than the
|
|
36
41
|
* installed manifest. Local preview builds and a stale search index must
|
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CCR request pipeline — explicit, ordered hooks for the CCR runtime.
|
|
3
|
-
*
|
|
4
|
-
* Hook order (enforced by namespace phases + sequential global registration):
|
|
5
|
-
* 1. onRequest: request timing (requestStartTime)
|
|
6
|
-
* 2. namespace preHandler: request normalize
|
|
7
|
-
* 3. namespace preHandler: adapter
|
|
8
|
-
* 4. global preHandler: auth/client context
|
|
9
|
-
* 5. global preHandler: agent mutation
|
|
10
|
-
* 6. namespace preHandler: router
|
|
11
|
-
* 7. namespace preHandler: provider model normalization
|
|
12
|
-
* 8. handler: routes.ts handleTransformerEndpoint
|
|
13
|
-
* 9. onSend: agent tool rewrite + usage/upstream-model capture
|
|
14
|
-
* 10. onResponse: TTFT/speed/health/final usage record
|
|
15
|
-
*
|
|
16
|
-
* Fastify runs ancestor preHandler hooks before child plugin hooks. To enforce
|
|
17
|
-
* adapter → auth/client → agent → router without relying on registration timing,
|
|
18
|
-
* the namespace registers a single ordered dispatcher (see Server.registerNamespace)
|
|
19
|
-
* whose phases invoke the global callbacks between adapter and router.
|
|
20
|
-
*
|
|
21
|
-
* The pipeline is registered by createCcrServer AFTER admin routes and BEFORE
|
|
22
|
-
* namespace registration + listen, so all hooks are in deterministic order.
|
|
23
|
-
*/
|
|
24
1
|
import { EventEmitter } from "node:events";
|
|
25
2
|
import { isRateLimitMessage } from "../services/rate-limit";
|
|
26
3
|
export { isRateLimitMessage };
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export declare function getUsageCacheReadInputTokens(usage: any): number;
|
|
8
8
|
export declare function getUsageCacheCreationInputTokens(usage: any): number;
|
|
9
|
+
/** The ACP plugin's Chat prompt count includes both cache buckets. */
|
|
10
|
+
export declare function getAcpUncachedPromptTokens(usage: any): number | undefined;
|
|
9
11
|
/**
|
|
10
12
|
* Normalize a raw usage object (from Anthropic, OpenAI Chat Completions, or
|
|
11
13
|
* OpenAI Responses APIs) into a common shape with input_tokens / output_tokens
|
|
@@ -12,6 +12,8 @@ export interface UsageRecord {
|
|
|
12
12
|
clientType?: string;
|
|
13
13
|
stream: boolean;
|
|
14
14
|
usageEstimated?: boolean;
|
|
15
|
+
effectiveInputTokens: number | null;
|
|
16
|
+
effectiveInputTokensSource?: "estimated";
|
|
15
17
|
inputTokens: number;
|
|
16
18
|
outputTokens: number;
|
|
17
19
|
cacheReadInputTokens: number;
|
|
@@ -23,59 +25,27 @@ export interface UsageRecord {
|
|
|
23
25
|
errorMessage?: string;
|
|
24
26
|
responseBody?: string;
|
|
25
27
|
}
|
|
28
|
+
type UsageRecordInput = Omit<UsageRecord, "effectiveInputTokens"> & {
|
|
29
|
+
effectiveInputTokens?: number | null;
|
|
30
|
+
};
|
|
26
31
|
export interface UsageSummary {
|
|
27
32
|
estimatedCount: number;
|
|
28
33
|
totalRequests: number;
|
|
29
34
|
successCount: number;
|
|
30
35
|
errorCount: number;
|
|
36
|
+
totalEffectiveInputTokens: number | null;
|
|
31
37
|
totalInputTokens: number;
|
|
32
38
|
totalOutputTokens: number;
|
|
33
39
|
totalCacheReadInputTokens: number;
|
|
34
40
|
totalCacheCreationInputTokens: number;
|
|
35
41
|
avgTtft: number | null;
|
|
36
42
|
avgTokensPerSecond: number | null;
|
|
37
|
-
byModel: Record<string,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}>;
|
|
44
|
-
byProvider: Record<string, {
|
|
45
|
-
count: number;
|
|
46
|
-
inputTokens: number;
|
|
47
|
-
outputTokens: number;
|
|
48
|
-
cacheReadInputTokens: number;
|
|
49
|
-
cacheCreationInputTokens: number;
|
|
50
|
-
}>;
|
|
51
|
-
byScenario: Record<string, {
|
|
52
|
-
count: number;
|
|
53
|
-
inputTokens: number;
|
|
54
|
-
outputTokens: number;
|
|
55
|
-
cacheReadInputTokens: number;
|
|
56
|
-
cacheCreationInputTokens: number;
|
|
57
|
-
}>;
|
|
58
|
-
byFamily: Record<string, {
|
|
59
|
-
count: number;
|
|
60
|
-
inputTokens: number;
|
|
61
|
-
outputTokens: number;
|
|
62
|
-
cacheReadInputTokens: number;
|
|
63
|
-
cacheCreationInputTokens: number;
|
|
64
|
-
}>;
|
|
65
|
-
byDay: Record<string, {
|
|
66
|
-
count: number;
|
|
67
|
-
inputTokens: number;
|
|
68
|
-
outputTokens: number;
|
|
69
|
-
cacheReadInputTokens: number;
|
|
70
|
-
cacheCreationInputTokens: number;
|
|
71
|
-
}>;
|
|
72
|
-
byClient: Record<string, {
|
|
73
|
-
count: number;
|
|
74
|
-
inputTokens: number;
|
|
75
|
-
outputTokens: number;
|
|
76
|
-
cacheReadInputTokens: number;
|
|
77
|
-
cacheCreationInputTokens: number;
|
|
78
|
-
}>;
|
|
43
|
+
byModel: Record<string, SummaryBucket>;
|
|
44
|
+
byProvider: Record<string, SummaryBucket>;
|
|
45
|
+
byScenario: Record<string, SummaryBucket>;
|
|
46
|
+
byFamily: Record<string, SummaryBucket>;
|
|
47
|
+
byDay: Record<string, SummaryBucket>;
|
|
48
|
+
byClient: Record<string, SummaryBucket>;
|
|
79
49
|
}
|
|
80
50
|
export interface UsageQueryFilters {
|
|
81
51
|
startTime?: string;
|
|
@@ -96,7 +66,15 @@ export interface UsageQueryResult {
|
|
|
96
66
|
page: number;
|
|
97
67
|
pageSize: number;
|
|
98
68
|
}
|
|
99
|
-
|
|
69
|
+
type SummaryBucket = {
|
|
70
|
+
effectiveInputTokens: number | null;
|
|
71
|
+
count: number;
|
|
72
|
+
inputTokens: number;
|
|
73
|
+
outputTokens: number;
|
|
74
|
+
cacheReadInputTokens: number;
|
|
75
|
+
cacheCreationInputTokens: number;
|
|
76
|
+
};
|
|
77
|
+
export declare function append(record: UsageRecordInput): void;
|
|
100
78
|
export declare function query(filters: UsageQueryFilters): UsageQueryResult;
|
|
101
79
|
export declare function querySummary(startTime?: string, endTime?: string, status?: UsageStatus): UsageSummary;
|
|
102
80
|
export declare function clear(beforeDate?: string): void;
|