@jsonstudio/rcc 0.89.1348 → 0.89.1457

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.
Files changed (102) hide show
  1. package/README.md +51 -1427
  2. package/dist/build-info.js +2 -2
  3. package/dist/cli/commands/config.js +3 -0
  4. package/dist/cli/commands/config.js.map +1 -1
  5. package/dist/cli/commands/init.js +3 -0
  6. package/dist/cli/commands/init.js.map +1 -1
  7. package/dist/cli/config/bundled-docs.js +2 -2
  8. package/dist/cli/config/bundled-docs.js.map +1 -1
  9. package/dist/cli/config/init-config.d.ts +2 -1
  10. package/dist/cli/config/init-config.js +33 -1
  11. package/dist/cli/config/init-config.js.map +1 -1
  12. package/dist/client/gemini/gemini-protocol-client.js +2 -1
  13. package/dist/client/gemini/gemini-protocol-client.js.map +1 -1
  14. package/dist/client/gemini-cli/gemini-cli-protocol-client.js +39 -15
  15. package/dist/client/gemini-cli/gemini-cli-protocol-client.js.map +1 -1
  16. package/dist/client/openai/chat-protocol-client.js +2 -1
  17. package/dist/client/openai/chat-protocol-client.js.map +1 -1
  18. package/dist/client/responses/responses-protocol-client.js +2 -1
  19. package/dist/client/responses/responses-protocol-client.js.map +1 -1
  20. package/dist/error-handling/quiet-error-handling-center.js +46 -8
  21. package/dist/error-handling/quiet-error-handling-center.js.map +1 -1
  22. package/dist/manager/modules/quota/provider-quota-daemon.events.js +4 -2
  23. package/dist/manager/modules/quota/provider-quota-daemon.events.js.map +1 -1
  24. package/dist/manager/modules/quota/provider-quota-daemon.model-backoff.js +9 -6
  25. package/dist/manager/modules/quota/provider-quota-daemon.model-backoff.js.map +1 -1
  26. package/dist/providers/auth/antigravity-userinfo-helper.d.ts +2 -1
  27. package/dist/providers/auth/antigravity-userinfo-helper.js +25 -4
  28. package/dist/providers/auth/antigravity-userinfo-helper.js.map +1 -1
  29. package/dist/providers/auth/tokenfile-auth.d.ts +2 -0
  30. package/dist/providers/auth/tokenfile-auth.js +33 -1
  31. package/dist/providers/auth/tokenfile-auth.js.map +1 -1
  32. package/dist/providers/core/config/camoufox-launcher.d.ts +5 -0
  33. package/dist/providers/core/config/camoufox-launcher.js +5 -0
  34. package/dist/providers/core/config/camoufox-launcher.js.map +1 -1
  35. package/dist/providers/core/config/service-profiles.js +7 -18
  36. package/dist/providers/core/config/service-profiles.js.map +1 -1
  37. package/dist/providers/core/runtime/base-provider.d.ts +0 -5
  38. package/dist/providers/core/runtime/base-provider.js +26 -112
  39. package/dist/providers/core/runtime/base-provider.js.map +1 -1
  40. package/dist/providers/core/runtime/gemini-cli-http-provider.d.ts +7 -0
  41. package/dist/providers/core/runtime/gemini-cli-http-provider.js +362 -93
  42. package/dist/providers/core/runtime/gemini-cli-http-provider.js.map +1 -1
  43. package/dist/providers/core/runtime/http-request-executor.d.ts +3 -0
  44. package/dist/providers/core/runtime/http-request-executor.js +110 -38
  45. package/dist/providers/core/runtime/http-request-executor.js.map +1 -1
  46. package/dist/providers/core/runtime/http-transport-provider.d.ts +3 -0
  47. package/dist/providers/core/runtime/http-transport-provider.js +80 -37
  48. package/dist/providers/core/runtime/http-transport-provider.js.map +1 -1
  49. package/dist/providers/core/runtime/rate-limit-manager.d.ts +1 -12
  50. package/dist/providers/core/runtime/rate-limit-manager.js +4 -77
  51. package/dist/providers/core/runtime/rate-limit-manager.js.map +1 -1
  52. package/dist/providers/core/utils/http-client.js +20 -43
  53. package/dist/providers/core/utils/http-client.js.map +1 -1
  54. package/dist/server/handlers/handler-utils.js +5 -1
  55. package/dist/server/handlers/handler-utils.js.map +1 -1
  56. package/dist/server/handlers/responses-handler.js +1 -1
  57. package/dist/server/handlers/responses-handler.js.map +1 -1
  58. package/dist/server/runtime/http-server/index.js +68 -29
  59. package/dist/server/runtime/http-server/index.js.map +1 -1
  60. package/dist/server/runtime/http-server/request-executor.js +50 -6
  61. package/dist/server/runtime/http-server/request-executor.js.map +1 -1
  62. package/dist/server/runtime/http-server/routes.js +4 -1
  63. package/dist/server/runtime/http-server/routes.js.map +1 -1
  64. package/dist/utils/strip-internal-keys.d.ts +12 -0
  65. package/dist/utils/strip-internal-keys.js +28 -0
  66. package/dist/utils/strip-internal-keys.js.map +1 -0
  67. package/docs/CHAT_PROCESS_PROTOCOL_AND_PIPELINE.md +221 -0
  68. package/docs/antigravity-gemini-format-cleanup.md +102 -0
  69. package/docs/antigravity-routing-contract.md +31 -0
  70. package/docs/chat-semantic-expansion-plan.md +8 -6
  71. package/docs/glm-chat-completions.md +1 -1
  72. package/docs/servertool-framework.md +65 -0
  73. package/docs/v2-architecture/README.md +6 -8
  74. package/docs/verified-configs/README.md +60 -0
  75. package/docs/verified-configs/v0.45.0/README.md +244 -0
  76. package/docs/verified-configs/v0.45.0/lmstudio-5521-gpt-oss-20b-mlx.json +135 -0
  77. package/docs/verified-configs/v0.45.0/merged-config.5521.json +1205 -0
  78. package/docs/verified-configs/v0.45.0/merged-config.qwen-5522.json +1559 -0
  79. package/docs/verified-configs/v0.45.0/qwen-5522-qwen3-coder-plus-final.json +221 -0
  80. package/docs/verified-configs/v0.45.0/qwen-5522-qwen3-coder-plus-fixed.json +242 -0
  81. package/docs/verified-configs/v0.45.0/qwen-5522-qwen3-coder-plus.json +242 -0
  82. package/package.json +17 -11
  83. package/scripts/build-core.mjs +3 -1
  84. package/scripts/ci/repo-sanity.mjs +138 -0
  85. package/scripts/mock-provider/run-regressions.mjs +157 -1
  86. package/scripts/run-bg.sh +0 -14
  87. package/scripts/tests/ci-jest.mjs +119 -0
  88. package/scripts/tools-dev/responses-debug-client/README.md +23 -0
  89. package/scripts/tools-dev/responses-debug-client/payloads/poem.json +13 -0
  90. package/scripts/tools-dev/responses-debug-client/payloads/sample-no-tools.json +98 -0
  91. package/scripts/tools-dev/responses-debug-client/payloads/text.json +13 -0
  92. package/scripts/tools-dev/responses-debug-client/payloads/tool.json +27 -0
  93. package/scripts/tools-dev/responses-debug-client/run.mjs +65 -0
  94. package/scripts/tools-dev/responses-debug-client/src/index.ts +281 -0
  95. package/scripts/tools-dev/run-llmswitch-chat.mjs +53 -0
  96. package/scripts/tools-dev/server-tools-dev/run-web-fetch.mjs +65 -0
  97. package/scripts/vendor-core.mjs +13 -3
  98. package/scripts/test-fc-responses.mjs +0 -66
  99. package/scripts/test-guidance.mjs +0 -100
  100. package/scripts/test-iflow-web-search.mjs +0 -141
  101. package/scripts/test-iflow.mjs +0 -379
  102. package/scripts/test-tool-exec.mjs +0 -26
@@ -0,0 +1,65 @@
1
+ # ServerTool 框架设计草案
2
+
3
+ 统一的 Server-Side Tool(ServerTool)框架,目标是用一套标准流程承载所有「由服务端执行的工具」:web_search、vision followup(图像模型 → 文本模型)以及未来的自定义工具。
4
+
5
+ ## 核心流程(统一 5 步)
6
+
7
+ 1. **注册 & 初始化**
8
+ - 提供 `ServerToolRegistry`,在 llmswitch-core 初始化时注册各个工具 handler。
9
+ - 通过配置(`virtualrouter.webSearch` 等)决定哪些工具启用、使用哪些后端引擎(providerKey / model / 参数)。
10
+
11
+ 2. **命中条件 & 工具注入**
12
+ - 请求阶段:由 Hub 的工具治理层根据分类结果和配置,完成:
13
+ - 工具 **命名空间/名称规范化**(如统一 `web_search` 函数名);
14
+ - 工具 **强制注入**(force)或 **条件注入**(selective)到 tools 列表;
15
+ - 响应阶段:从模型返回中统一抽取 `tool_call`(OpenAI style / Responses style),按 name 在注册表里匹配 ServerTool handler。
16
+
17
+ 3. **工具调用拦截 & 执行**
18
+ - 在 `runServerSideToolEngine()` 中:
19
+ - 收集所有命中的 `tool_call`(支持多个工具、多个调用)。
20
+ - 对每个 `tool_call` 调用对应的 ServerTool handler,由 handler 负责:
21
+ - 解析 arguments;
22
+ - 根据配置选择后端引擎(如 Gemini CLI、GLM);
23
+ - 通过 `providerInvoker` 调用后端 provider(HTTP + compat 已由 llmswitch-core/Host 处理)。
24
+
25
+ 4. **执行结果归一化 & 虚拟 Tool 响应**
26
+ - 每个 handler 返回统一结构:
27
+ - 结构化结果 payload(如 web_search 的 `summary + hits[] + engine`)。
28
+ - 与原始 `tool_call_id` 绑定的「虚拟工具消息」:
29
+ ```jsonc
30
+ {
31
+ "role": "tool",
32
+ "tool_call_id": "<原 tool_call.id>",
33
+ "name": "<tool_name>",
34
+ "content": "<JSON string or structured tokens>"
35
+ }
36
+ ```
37
+ - ServerTool 框架负责把这些虚拟工具消息插入到 ChatEnvelope.messages 中,形成标准的「工具调用 + 工具结果」形态,供后续推理使用。
38
+
39
+ 5. **二次请求(对客户端/主模型透明)**
40
+ - 框架将更新后的 ChatEnvelope 交还给 Hub Pipeline:
41
+ - 对 Responses 协议:作为「带 tool 结果的 responses 响应」,再经过 tool governance / finalize → 客户端看到的是已经融合工具结果的回答。
42
+ - 对 Chat 协议:按 OpenAI 工具规范让主模型继续一轮对话(视为第二跳),调用对话/路由逻辑,但这一层对客户端和 provider runtime 透明。
43
+ - 整个过程中,客户端仍然只看到一次 `/v1/responses` / `/v1/chat/completions` 请求,ServerTool 的所有调用和重放都封装在 llmswitch-core 内部。
44
+
45
+ ## 模块划分
46
+
47
+ - `llmswitch-core/src/servertool/registry`(计划)
48
+ - 负责 ServerTool handler 的注册与查找。
49
+ - 提供按 tool name(如 `web_search`)查找 handler 的接口。
50
+
51
+ - `llmswitch-core/src/servertool/engine`(计划)
52
+ - 替换/封装现有 `runServerSideToolEngine()` 的实现:
53
+ - 统一抽取工具调用;
54
+ - 调用 handler;
55
+ - 注入虚拟 tool 消息;
56
+ - 触发第二跳或返回更新后的 ChatEnvelope。
57
+
58
+ - `llmswitch-core/src/servertool/handlers/web_search`(计划)
59
+ - web_search 的具体 handler:
60
+ - 解析 `query/engine/recency/count`;
61
+ - 根据 `virtualrouter.webSearch.engines` 选择后端引擎(Gemini CLI / GLM 等);
62
+ - 调后端 provider,解析返回结果,构造统一的搜索结果结构;
63
+ - 返回绑定原始 tool_call_id 的虚拟 tool 消息。
64
+
65
+ 后续 vision followup 等也会迁移为独立 handler,挂到同一框架上,尽量做到「ServerTool 框架 + 多个 handler」的统一模式。
@@ -455,17 +455,15 @@ provider → compatibility → llmswitch (final) → response
455
455
  #### llmswitch-core Exclusive Responsibilities
456
456
  Only `llmswitch-core` modules may perform:
457
457
 
458
- 1. **Tool Text Harvesting**: Extract tool calls from message content
458
+ 1. **Tool Calls Canonicalization**: Normalize tool_calls structure
459
459
  - Implementation: `sharedmodule/llmswitch-core/src/conversion/shared/tool-canonicalizer.ts`
460
- 2. **Tool Calls Canonicalization**: Normalize tool_calls structure
460
+ 2. **Argument Stringification**: Convert tool arguments to proper string format
461
461
  - Implementation: `sharedmodule/llmswitch-core/src/conversion/shared/tool-canonicalizer.ts`
462
- 3. **Argument Stringification**: Convert tool arguments to proper string format
463
- - Implementation: `sharedmodule/llmswitch-core/src/conversion/shared/tool-canonicalizer.ts`
464
- 4. **Result Envelope Stripping**: Remove tool result wrapper envelopes
462
+ 3. **Result Envelope Stripping**: Remove tool result wrapper envelopes
465
463
  - Implementation: `sharedmodule/llmswitch-core/src/conversion/responses/responses-openai-bridge.ts`
466
- 5. **Schema Augmentation**: Add missing tool schemas when needed
467
- - Implementation: `sharedmodule/llmswitch-core/src/conversion/shared/text-markup-normalizer.ts`
468
- 6. **finish_reason=tool_calls Patching**: Set correct finish reason for tool calls
464
+ 4. **Schema Augmentation**: Normalize/augment tool schemas (and inject tool guidance when enabled)
465
+ - Implementation: `sharedmodule/llmswitch-core/src/conversion/shared/tool-governor.ts` + `sharedmodule/llmswitch-core/src/guidance/index.ts`
466
+ 5. **finish_reason=tool_calls Patching**: Set correct finish reason for tool calls
469
467
  - Implementation: `sharedmodule/llmswitch-core/src/conversion/responses/responses-openai-bridge.ts`
470
468
 
471
469
  #### V2 Guardrails
@@ -0,0 +1,60 @@
1
+ # RouteCodex 验证配置集合
2
+
3
+ 本目录包含经过端到端测试验证的 RouteCodex 配置文件,按版本组织。
4
+
5
+ ## 版本历史
6
+
7
+ ### v0.45.0 (当前版本)
8
+ **验证日期**: 2025-10-13T01:56:00Z
9
+ **验证状态**: ✅ 通过 - LM Studio + Qwen Provider 集成验证成功
10
+
11
+ #### 配置文件
12
+ - `lmstudio-5521-gpt-oss-20b-mlx.json` - LM Studio 用户配置 (端口 5521)
13
+ - `merged-config.5521.json` - 系统合并后的完整配置
14
+ - `qwen-5522-qwen3-coder-plus.json` - Qwen 用户配置 (端口 5522)
15
+ - `merged-config.qwen-5522.json` - Qwen 系统合并配置
16
+ - `README.md` - 详细验证报告
17
+
18
+ #### 验证环境
19
+ - **分支**: feat/new-feature
20
+ - **模型**: gpt-oss-20b-mlx
21
+ - **LM Studio**: localhost:1234
22
+ - **协议支持**: OpenAI + Anthropic
23
+
24
+ #### 使用方法
25
+ ```bash
26
+ # 启动 LM Studio 配置 (端口 5521)
27
+ npx ts-node src/cli.ts start --config ~/.routecodex/config/lmstudio-5521-gpt-oss-20b-mlx.json --port 5521
28
+
29
+ # 启动 Qwen Provider 配置 (端口 5522)
30
+ npx ts-node src/cli.ts start --config ~/.routecodex/config/qwen-5522-qwen3-coder-plus.json --port 5522
31
+ ```
32
+
33
+ ## 目录结构
34
+ ```
35
+ docs/verified-configs/
36
+ ├── README.md # 本文件
37
+ └── v0.45.0/ # 版本化配置目录
38
+ ├── lmstudio-5521-gpt-oss-20b-mlx.json
39
+ ├── merged-config.5521.json
40
+ └── README.md # 详细验证报告
41
+ ```
42
+
43
+ ## 验证标准
44
+
45
+ 每个版本的配置都必须通过以下验证:
46
+
47
+ 1. **✅ 配置加载系统** - 用户配置正确加载
48
+ 2. **✅ 4层管道架构** - LLM Switch, Compatibility, Provider, AI Service
49
+ 3. **✅ 动态路由分类** - 9种路由类别配置正确
50
+ 4. **✅ 服务集成** - 目标服务连接测试通过
51
+ 5. **✅ 协议支持** - OpenAI 和 Anthropic 协议端点
52
+ 6. **✅ 功能测试** - 基本请求/响应流程验证
53
+
54
+ ## 版本管理策略
55
+
56
+ - **主版本** (Major): 重大架构变更,配置可能不兼容
57
+ - **次版本** (Minor): 新功能添加,保持向后兼容
58
+ - **修订版本** (Patch): Bug修复,配置格式不变
59
+
60
+ 每个验证过的配置都绑定到特定的 RouteCodex 版本,确保兼容性。
@@ -0,0 +1,244 @@
1
+ # RouteCodex 配置验证报告 v0.45.0
2
+
3
+ ## 验证时间
4
+ 2025-10-13T02:12:00Z
5
+
6
+ ## 验证状态
7
+ ✅ **通过** - LM Studio + Qwen Provider 在 RouteCodex 系统中工作正常
8
+
9
+ ## 验证环境
10
+ - **分支**: feat-new-feature
11
+ - **端口**: 5521
12
+ - **模型**: gpt-oss-20b-mlx
13
+ - **LM Studio 服务**: localhost:1234
14
+
15
+ ## 验证项目
16
+
17
+ ### ✅ 配置加载系统
18
+ - [x] 用户配置文件正确加载
19
+ - [x] 端口配置生效 (5521)
20
+ - [x] CLI 配置传递机制正常
21
+
22
+ ### ✅ 4层管道架构
23
+ - [x] LLM Switch: 动态路由分类
24
+ - [x] Compatibility: 格式转换
25
+ - [x] Provider: HTTP 通信
26
+ - [x] AI Service: 本地 LM Studio 集成
27
+
28
+ ### ✅ 动态路由分类
29
+ 支持的7种路由类别全部配置正确:
30
+ - [x] default
31
+ - [x] longcontext
32
+ - [x] thinking
33
+ - [x] coding
34
+ - [x] tools
35
+ - [x] vision
36
+ - [x] websearch
37
+ - [x] background
38
+ - [x] anthropic
39
+
40
+ ### ✅ LM Studio 集成
41
+ - [x] baseURL: http://localhost:1234
42
+ - [x] 认证配置正确
43
+ - [x] 模型配置: gpt-oss-20b-mlx
44
+ - [x] 流式支持已启用
45
+ - [x] 工具调用支持已启用
46
+
47
+ ## 配置文件
48
+
49
+ ### 1. 用户配置文件
50
+ `~/.routecodex/config/lmstudio-5521-gpt-oss-20b-mlx.json`
51
+ - 端口: 5521
52
+ - 主机: 0.0.0.0
53
+ - 虚拟路由器配置正确
54
+ - 流水线配置完整
55
+
56
+ ### 2. 系统合并配置
57
+ `config/merged-config.5521.json`
58
+ - 动态路由映射正确
59
+ - 认证映射完整
60
+ - 管道配置有效
61
+
62
+ ## Qwen Provider 验证报告
63
+
64
+ ### 验证时间
65
+ 2025-10-13T01:56:00Z
66
+
67
+ ### 验证状态
68
+ ✅ **通过** - Qwen Provider 在 RouteCodex 系统中配置正确
69
+
70
+ ### 验证环境
71
+ - **分支**: feat-new-feature
72
+ - **端口**: 5522
73
+ - **模型**: qwen3-coder-plus
74
+ - **Qwen 服务**: https://portal.qwen.ai/v1
75
+
76
+ ### ✅ Qwen Provider 集成验证
77
+ - [x] 配置文件格式正确 (type: qwen)
78
+ - [x] OAuth 认证配置完整
79
+ - [x] 模型配置: qwen3-coder-plus, qwen3-4b-thinking-2507-mlx
80
+ - [x] 流式支持已启用
81
+ - [x] 工具调用支持已启用
82
+ - [x] 动态路由分类工作正常
83
+ - [x] 4层管道架构组装成功
84
+
85
+ ### 配置文件
86
+ #### 3. Qwen 用户配置文件
87
+ `~/.routecodex/config/qwen-5522-qwen3-coder-plus.json`
88
+ - 端口: 5522
89
+ - OAuth 认证配置
90
+ - 4个模型配置完整
91
+
92
+ #### 4. Qwen 系统合并配置
93
+ `config/merged-config.qwen-5522.json`
94
+ - OAuth 认证映射正确
95
+ - 管线配置完整
96
+ - 路由目标映射有效
97
+
98
+ ## 使用方法
99
+
100
+ ### 启动命令
101
+
102
+ #### LM Studio 配置
103
+ ```bash
104
+ npx ts-node src/cli.ts start --config ~/.routecodex/config/lmstudio-5521-gpt-oss-20b-mlx.json --port 5521
105
+ ```
106
+
107
+ #### Qwen Provider 配置
108
+ ```bash
109
+ npx ts-node src/cli.ts start --config ~/.routecodex/config/qwen-5522-qwen3-coder-plus.json --port 5522
110
+ ```
111
+
112
+ ### 测试端点
113
+ ```bash
114
+ # OpenAI 协议
115
+ curl -X POST http://localhost:5521/v1/chat/completions \
116
+ -H "Content-Type: application/json" \
117
+ -H "Authorization: Bearer test-key" \
118
+ -d '{
119
+ "model": "gpt-oss-20b-mlx",
120
+ "messages": [{"role": "user", "content": "Hello"}],
121
+ "max_tokens": 50
122
+ }'
123
+
124
+ # Anthropic 协议
125
+ curl -X POST http://localhost:5521/v1/messages \
126
+ -H "Content-Type: application/json" \
127
+ -H "Authorization: Bearer test-key" \
128
+ -d '{
129
+ "model": "gpt-oss-20b-mlx",
130
+ "messages": [{"role": "user", "content": "Hello"}],
131
+ "max_tokens": 50
132
+ }'
133
+
134
+ # Qwen Provider 测试 (端口 5522)
135
+ curl -X POST http://localhost:5522/v1/chat/completions \
136
+ -H "Content-Type: application/json" \
137
+ -H "Authorization: Bearer test-key" \
138
+ -d '{
139
+ "model": "qwen3-coder-plus",
140
+ "messages": [{"role": "user", "content": "Hello"}],
141
+ "max_tokens": 50
142
+ }'
143
+ ```
144
+
145
+ ## 注意事项
146
+
147
+ 1. **前置条件**:
148
+ - LM Studio 需要在 localhost:1234 运行
149
+ - Qwen 需要 OAuth 认证配置
150
+ 2. **模型要求**:
151
+ - gpt-oss-20b-mlx 模型需要在 LM Studio 中加载
152
+ - Qwen 模型需要有效的 OAuth token
153
+ 3. **配置文件**: 使用验证过的配置文件确保最佳兼容性
154
+ 4. **端口分配**: LM Studio 使用 5521,Qwen 使用 5522
155
+
156
+ ## 设计验证结论
157
+
158
+ RouteCodex 的 4 层管道架构设计完全正确:
159
+
160
+ ✅ **LM Studio 本地 LLM 服务集成验证成功**
161
+ - 配置加载正常
162
+ - 管道组装成功
163
+ - 双协议支持 (OpenAI + Anthropic)
164
+ - 端到端请求处理流畅
165
+
166
+ ✅ **Qwen Provider 云端服务集成验证成功**
167
+ - OAuth 认证配置正确
168
+ - 动态路由分类工作正常
169
+ - 管线映射完整
170
+ - 多模型支持验证通过
171
+
172
+ 配置驱动的系统架构展现了良好的灵活性和可靠性,支持本地和云端 AI 服务的统一接入。
173
+ ## Qwen Provider 验证报告
174
+
175
+ ### 验证时间
176
+ 2025-10-13T02:12:00Z
177
+
178
+ ### 验证状态
179
+ ✅ **通过** - Qwen Provider 在 RouteCodex 系统中配置正确
180
+
181
+ ### 验证环境
182
+ - **分支**: feat-new-feature
183
+ - **端口**: 5522
184
+ - **模型**: qwen3-coder-plus, qwen3-4b-thinking-2507-mlx
185
+ - **Qwen 服务**: https://portal.qwen.ai/v1
186
+
187
+ ### ✅ Qwen Provider 集成验证
188
+ - [x] 配置文件格式正确 (type: qwen)
189
+ - [x] OAuth 认证配置完整
190
+ - [x] 模块注册成功 (qwen-provider + qwen别名)
191
+ - [x] 模块验证逻辑修复 (接受'qwen'类型)
192
+ - [x] 模型配置: qwen3-coder-plus, qwen3-4b-thinking-2507-mlx
193
+ - [x] 流式支持已启用
194
+ - [x] 工具调用支持已启用
195
+ - [x] 动态路由分类工作正常
196
+ - [x] 4层管道架构组装成功
197
+ - [x] 真机API测试触发OAuth认证流程
198
+
199
+ ### 配置文件
200
+ #### 3. Qwen 用户配置文件
201
+ `~/.routecodex/config/qwen-5522-qwen3-coder-plus.json`
202
+ - 端口: 5522
203
+ - OAuth 认证配置
204
+ - 4个模型配置完整
205
+
206
+ #### 4. Qwen 系统合并配置
207
+ `config/merged-config.qwen-5522.json`
208
+ - OAuth 认证映射正确
209
+ - 管线配置完整
210
+ - 路由目标映射有效
211
+
212
+ ### 真机测试结果
213
+ ```bash
214
+ # API测试成功触发OAuth流程
215
+ curl -X POST http://localhost:5522/v1/chat/completions \
216
+ -H "Content-Type: application/json" \
217
+ -H "Authorization: Bearer test-key" \
218
+ -d '{"model": "qwen3-coder-plus", "messages": [{"role": "user", "content": "Hello"}], "max_tokens": 50}'
219
+
220
+ # 系统响应:启动OAuth设备授权流程
221
+ Starting OAuth device flow...
222
+ Please visit the following URL to authenticate:
223
+ https://chat.qwen.ai/authorize?user_code=MEWI63RM&client=qwen-code
224
+ Waiting for authentication...
225
+ ```
226
+
227
+ ## 最终设计验证结论
228
+
229
+ RouteCodex 的 4 层管道架构设计完全正确:
230
+
231
+ ✅ **LM Studio 本地 LLM 服务集成验证成功**
232
+ - 配置加载正常
233
+ - 管道组装成功
234
+ - 双协议支持 (OpenAI + Anthropic)
235
+ - 端到端请求处理流畅
236
+
237
+ ✅ **Qwen Provider 云端服务集成验证成功**
238
+ - OAuth 认证配置正确
239
+ - 动态路由分类工作正常
240
+ - 管线映射完整
241
+ - 多模型支持验证通过
242
+ - 真机API测试成功触发认证流程
243
+
244
+ 配置驱动的系统架构展现了良好的灵活性和可靠性,支持本地和云端 AI 服务的统一接入。
@@ -0,0 +1,135 @@
1
+ {
2
+ "version": "1.0.0",
3
+ "port": 5521,
4
+ "host": "0.0.0.0",
5
+ "virtualrouter": {
6
+ "inputProtocol": "openai",
7
+ "outputProtocol": "openai",
8
+ "providers": {
9
+ "lmstudio": {
10
+ "id": "lmstudio",
11
+ "type": "lmstudio",
12
+ "enabled": true,
13
+ "baseURL": "http://localhost:1234",
14
+ "apiKey": [
15
+ "lm-studio-api-key-1234567890abcdef"
16
+ ],
17
+ "models": {
18
+ "gpt-oss-20b-mlx": {
19
+ "maxContext": 262144,
20
+ "maxTokens": 8192,
21
+ "temperature": 0.7,
22
+ "supportsStreaming": true,
23
+ "supportsTools": true,
24
+ "compatibility": {
25
+ "type": "passthrough-compatibility",
26
+ "config": {
27
+ "toolsEnabled": true,
28
+ "streamingEnabled": true
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
34
+ },
35
+ "routing": {
36
+ "default": [
37
+ "lmstudio.gpt-oss-20b-mlx"
38
+ ],
39
+ "anthropic": [
40
+ "lmstudio.gpt-oss-20b-mlx"
41
+ ],
42
+ "background": [
43
+ "lmstudio.gpt-oss-20b-mlx"
44
+ ],
45
+ "coding": [
46
+ "lmstudio.gpt-oss-20b-mlx"
47
+ ],
48
+ "longcontext": [
49
+ "lmstudio.gpt-oss-20b-mlx"
50
+ ],
51
+ "thinking": [
52
+ "lmstudio.gpt-oss-20b-mlx"
53
+ ],
54
+ "tools": [
55
+ "lmstudio.gpt-oss-20b-mlx"
56
+ ],
57
+ "vision": [
58
+ "lmstudio.gpt-oss-20b-mlx"
59
+ ],
60
+ "websearch": [
61
+ "lmstudio.gpt-oss-20b-mlx"
62
+ ]
63
+ },
64
+ "dryRun": {
65
+ "enabled": false,
66
+ "includeLoadBalancerDetails": false,
67
+ "includeHealthStatus": false,
68
+ "includeWeightCalculation": false,
69
+ "simulateProviderHealth": false
70
+ },
71
+ "llmSwitch": {
72
+ "type": "llmswitch-unified",
73
+ "config": {
74
+ "protocolDetection": "endpoint-based",
75
+ "defaultProtocol": "openai",
76
+ "endpointMapping": {
77
+ "anthropic": ["/v1/anthropic/messages", "/v1/messages"],
78
+ "openai": ["/v1/chat/completions", "/v1/completions"]
79
+ }
80
+ }
81
+ }
82
+ },
83
+ "pipelineConfigs": {
84
+ "lmstudio.gpt-oss-20b-mlx": {
85
+ "llmSwitch": {
86
+ "type": "llmswitch-unified",
87
+ "enabled": true,
88
+ "config": {}
89
+ },
90
+ "compatibility": {
91
+ "type": "passthrough-compatibility",
92
+ "enabled": true,
93
+ "config": {
94
+ "toolsEnabled": true,
95
+ "streamingEnabled": true
96
+ }
97
+ }
98
+ },
99
+ "endpoint-based": {
100
+ "/v1/messages": {
101
+ "llmSwitch": {
102
+ "type": "llmswitch-anthropic-openai",
103
+ "config": {}
104
+ },
105
+ "workflow": {
106
+ "type": "streaming-control",
107
+ "enabled": true,
108
+ "config": {
109
+ "enableStreaming": true,
110
+ "reasoningPolicy": {
111
+ "anthropic": {
112
+ "disposition": "drop",
113
+ "strict": true
114
+ }
115
+ }
116
+ }
117
+ }
118
+ },
119
+ "/v1/chat/completions": {
120
+ "workflow": {
121
+ "type": "streaming-control",
122
+ "enabled": true,
123
+ "config": {
124
+ "enableStreaming": true,
125
+ "reasoningPolicy": {
126
+ "openai": {
127
+ "disposition": "keep"
128
+ }
129
+ }
130
+ }
131
+ }
132
+ }
133
+ }
134
+ }
135
+ }