@jsonstudio/rcc 0.89.1189 → 0.89.1348

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 (337) hide show
  1. package/README.md +17 -0
  2. package/configsamples/config.json +426 -0
  3. package/configsamples/config.reference.json +58 -0
  4. package/configsamples/provider/crs/config.v1.json +46 -0
  5. package/configsamples/provider/glm/config.v1.json +81 -0
  6. package/configsamples/provider/glm-anthropic/config.v1.json +45 -0
  7. package/configsamples/provider/iflow/config.v1.json +74 -0
  8. package/configsamples/provider/kimi/config.v1.json +41 -0
  9. package/configsamples/provider/lmstudio/config.v1.json +101 -0
  10. package/configsamples/provider/mimo/config.v1.json +35 -0
  11. package/configsamples/provider/modelscope/config.v1.json +96 -0
  12. package/configsamples/provider/qwen/config.v1.json +38 -0
  13. package/configsamples/provider/tab/config.v1.json +50 -0
  14. package/configsamples/provider/tabglm/config.v1.json +49 -0
  15. package/dist/build-info.js +2 -2
  16. package/dist/cli/commands/code.js +12 -6
  17. package/dist/cli/commands/code.js.map +1 -1
  18. package/dist/cli/commands/config.d.ts +2 -1
  19. package/dist/cli/commands/config.js +74 -103
  20. package/dist/cli/commands/config.js.map +1 -1
  21. package/dist/cli/commands/examples.js +6 -6
  22. package/dist/cli/commands/examples.js.map +1 -1
  23. package/dist/cli/commands/init.d.ts +28 -0
  24. package/dist/cli/commands/init.js +91 -0
  25. package/dist/cli/commands/init.js.map +1 -0
  26. package/dist/cli/commands/port.js +10 -2
  27. package/dist/cli/commands/port.js.map +1 -1
  28. package/dist/cli/commands/restart.js +5 -2
  29. package/dist/cli/commands/restart.js.map +1 -1
  30. package/dist/cli/commands/start.js +25 -22
  31. package/dist/cli/commands/start.js.map +1 -1
  32. package/dist/cli/commands/status.js +1 -0
  33. package/dist/cli/commands/status.js.map +1 -1
  34. package/dist/cli/commands/stop.js +1 -0
  35. package/dist/cli/commands/stop.js.map +1 -1
  36. package/dist/cli/config/bundled-docs.d.ts +20 -0
  37. package/dist/cli/config/bundled-docs.js +91 -0
  38. package/dist/cli/config/bundled-docs.js.map +1 -0
  39. package/dist/cli/config/init-config.d.ts +36 -0
  40. package/dist/cli/config/init-config.js +180 -0
  41. package/dist/cli/config/init-config.js.map +1 -0
  42. package/dist/cli/config/init-provider-catalog.d.ts +8 -0
  43. package/dist/cli/config/init-provider-catalog.js +187 -0
  44. package/dist/cli/config/init-provider-catalog.js.map +1 -0
  45. package/dist/cli/register/init-command.d.ts +3 -0
  46. package/dist/cli/register/init-command.js +5 -0
  47. package/dist/cli/register/init-command.js.map +1 -0
  48. package/dist/cli.js +28 -3
  49. package/dist/cli.js.map +1 -1
  50. package/dist/client/gemini-cli/gemini-cli-protocol-client.js +1 -1
  51. package/dist/client/gemini-cli/gemini-cli-protocol-client.js.map +1 -1
  52. package/dist/config/risk-control-config.d.ts +94 -0
  53. package/dist/config/risk-control-config.js +196 -0
  54. package/dist/config/risk-control-config.js.map +1 -0
  55. package/dist/constants/index.d.ts +6 -0
  56. package/dist/constants/index.js +13 -0
  57. package/dist/constants/index.js.map +1 -1
  58. package/dist/docs/daemon-admin-ui.html +2113 -190
  59. package/dist/index.js +0 -1
  60. package/dist/index.js.map +1 -1
  61. package/dist/manager/modules/health/index.d.ts +1 -1
  62. package/dist/manager/modules/quota/antigravity-quota-manager.d.ts +70 -0
  63. package/dist/manager/modules/quota/antigravity-quota-manager.js +442 -0
  64. package/dist/manager/modules/quota/antigravity-quota-manager.js.map +1 -0
  65. package/dist/manager/modules/quota/index.d.ts +3 -127
  66. package/dist/manager/modules/quota/index.js +2 -1093
  67. package/dist/manager/modules/quota/index.js.map +1 -1
  68. package/dist/manager/modules/quota/provider-key-normalization.d.ts +3 -0
  69. package/dist/manager/modules/quota/provider-key-normalization.js +155 -0
  70. package/dist/manager/modules/quota/provider-key-normalization.js.map +1 -0
  71. package/dist/manager/modules/quota/provider-quota-daemon.cooldown.d.ts +9 -0
  72. package/dist/manager/modules/quota/provider-quota-daemon.cooldown.js +115 -0
  73. package/dist/manager/modules/quota/provider-quota-daemon.cooldown.js.map +1 -0
  74. package/dist/manager/modules/quota/provider-quota-daemon.d.ts +77 -0
  75. package/dist/manager/modules/quota/provider-quota-daemon.events.d.ts +12 -0
  76. package/dist/manager/modules/quota/provider-quota-daemon.events.js +237 -0
  77. package/dist/manager/modules/quota/provider-quota-daemon.events.js.map +1 -0
  78. package/dist/manager/modules/quota/provider-quota-daemon.js +404 -0
  79. package/dist/manager/modules/quota/provider-quota-daemon.js.map +1 -0
  80. package/dist/manager/modules/quota/provider-quota-daemon.model-backoff.d.ts +11 -0
  81. package/dist/manager/modules/quota/provider-quota-daemon.model-backoff.js +189 -0
  82. package/dist/manager/modules/quota/provider-quota-daemon.model-backoff.js.map +1 -0
  83. package/dist/manager/modules/quota/provider-quota-daemon.snapshot.d.ts +8 -0
  84. package/dist/manager/modules/quota/provider-quota-daemon.snapshot.js +96 -0
  85. package/dist/manager/modules/quota/provider-quota-daemon.snapshot.js.map +1 -0
  86. package/dist/manager/modules/quota/provider-quota-daemon.view.d.ts +19 -0
  87. package/dist/manager/modules/quota/provider-quota-daemon.view.js +37 -0
  88. package/dist/manager/modules/quota/provider-quota-daemon.view.js.map +1 -0
  89. package/dist/manager/modules/routing/index.d.ts +1 -0
  90. package/dist/manager/modules/routing/index.js +11 -25
  91. package/dist/manager/modules/routing/index.js.map +1 -1
  92. package/dist/manager/quota/provider-quota-center.d.ts +2 -0
  93. package/dist/manager/quota/provider-quota-center.js +80 -82
  94. package/dist/manager/quota/provider-quota-center.js.map +1 -1
  95. package/dist/modules/llmswitch/bridge.d.ts +16 -18
  96. package/dist/modules/llmswitch/bridge.js +314 -71
  97. package/dist/modules/llmswitch/bridge.js.map +1 -1
  98. package/dist/modules/llmswitch/core-loader.d.ts +4 -2
  99. package/dist/modules/llmswitch/core-loader.js +32 -20
  100. package/dist/modules/llmswitch/core-loader.js.map +1 -1
  101. package/dist/modules/pipeline/utils/colored-logger.js +3 -2
  102. package/dist/modules/pipeline/utils/colored-logger.js.map +1 -1
  103. package/dist/modules/pipeline/utils/debug-logger.js +1 -1
  104. package/dist/modules/pipeline/utils/debug-logger.js.map +1 -1
  105. package/dist/providers/auth/iflow-cookie-auth.js +0 -2
  106. package/dist/providers/auth/iflow-cookie-auth.js.map +1 -1
  107. package/dist/providers/auth/oauth-lifecycle.js +2 -23
  108. package/dist/providers/auth/oauth-lifecycle.js.map +1 -1
  109. package/dist/providers/core/config/camoufox-launcher.js +35 -4
  110. package/dist/providers/core/config/camoufox-launcher.js.map +1 -1
  111. package/dist/providers/core/runtime/antigravity-quota-client.js +6 -3
  112. package/dist/providers/core/runtime/antigravity-quota-client.js.map +1 -1
  113. package/dist/providers/core/runtime/base-provider.d.ts +2 -2
  114. package/dist/providers/core/runtime/base-provider.js +74 -69
  115. package/dist/providers/core/runtime/base-provider.js.map +1 -1
  116. package/dist/providers/core/runtime/gemini-cli-http-provider.js +6 -4
  117. package/dist/providers/core/runtime/gemini-cli-http-provider.js.map +1 -1
  118. package/dist/providers/core/runtime/http-request-executor.js +2 -2
  119. package/dist/providers/core/runtime/http-request-executor.js.map +1 -1
  120. package/dist/providers/core/runtime/http-transport-provider.d.ts +14 -0
  121. package/dist/providers/core/runtime/http-transport-provider.js +111 -5
  122. package/dist/providers/core/runtime/http-transport-provider.js.map +1 -1
  123. package/dist/providers/core/runtime/provider-error-classifier.js +10 -0
  124. package/dist/providers/core/runtime/provider-error-classifier.js.map +1 -1
  125. package/dist/providers/core/runtime/provider-factory.js +7 -5
  126. package/dist/providers/core/runtime/provider-factory.js.map +1 -1
  127. package/dist/providers/core/runtime/provider-runtime-metadata.d.ts +6 -0
  128. package/dist/providers/core/runtime/provider-runtime-metadata.js.map +1 -1
  129. package/dist/providers/core/runtime/responses-provider.d.ts +1 -7
  130. package/dist/providers/core/runtime/responses-provider.js +12 -93
  131. package/dist/providers/core/runtime/responses-provider.js.map +1 -1
  132. package/dist/providers/core/strategies/oauth-auth-code-flow.js +12 -8
  133. package/dist/providers/core/strategies/oauth-auth-code-flow.js.map +1 -1
  134. package/dist/providers/core/utils/http-client.js +16 -3
  135. package/dist/providers/core/utils/http-client.js.map +1 -1
  136. package/dist/providers/core/utils/provider-error-logger.d.ts +1 -1
  137. package/dist/providers/core/utils/provider-error-reporter.d.ts +3 -1
  138. package/dist/providers/core/utils/provider-error-reporter.js +3 -0
  139. package/dist/providers/core/utils/provider-error-reporter.js.map +1 -1
  140. package/dist/providers/core/utils/snapshot-writer.js +1 -4
  141. package/dist/providers/core/utils/snapshot-writer.js.map +1 -1
  142. package/dist/providers/mock/mock-provider-runtime.js +57 -27
  143. package/dist/providers/mock/mock-provider-runtime.js.map +1 -1
  144. package/dist/scripts/camoufox/launch-auth.mjs +193 -58
  145. package/dist/server/handlers/handler-utils.js +3 -2
  146. package/dist/server/handlers/handler-utils.js.map +1 -1
  147. package/dist/server/runtime/http-server/daemon-admin/auth-handler.d.ts +2 -0
  148. package/dist/server/runtime/http-server/daemon-admin/auth-handler.js +103 -0
  149. package/dist/server/runtime/http-server/daemon-admin/auth-handler.js.map +1 -0
  150. package/dist/server/runtime/http-server/daemon-admin/auth-session.d.ts +5 -0
  151. package/dist/server/runtime/http-server/daemon-admin/auth-session.js +77 -0
  152. package/dist/server/runtime/http-server/daemon-admin/auth-session.js.map +1 -0
  153. package/dist/server/runtime/http-server/daemon-admin/auth-store.d.ts +18 -0
  154. package/dist/server/runtime/http-server/daemon-admin/auth-store.js +89 -0
  155. package/dist/server/runtime/http-server/daemon-admin/auth-store.js.map +1 -0
  156. package/dist/server/runtime/http-server/daemon-admin/credentials-handler.js +1 -2
  157. package/dist/server/runtime/http-server/daemon-admin/credentials-handler.js.map +1 -1
  158. package/dist/server/runtime/http-server/daemon-admin/providers-handler.js +226 -24
  159. package/dist/server/runtime/http-server/daemon-admin/providers-handler.js.map +1 -1
  160. package/dist/server/runtime/http-server/daemon-admin/quota-handler.js +47 -8
  161. package/dist/server/runtime/http-server/daemon-admin/quota-handler.js.map +1 -1
  162. package/dist/server/runtime/http-server/daemon-admin/restart-handler.js +1 -1
  163. package/dist/server/runtime/http-server/daemon-admin/restart-handler.js.map +1 -1
  164. package/dist/server/runtime/http-server/daemon-admin/stats-handler.js +1 -1
  165. package/dist/server/runtime/http-server/daemon-admin/stats-handler.js.map +1 -1
  166. package/dist/server/runtime/http-server/daemon-admin/status-handler.js +68 -4
  167. package/dist/server/runtime/http-server/daemon-admin/status-handler.js.map +1 -1
  168. package/dist/server/runtime/http-server/daemon-admin-routes.d.ts +3 -4
  169. package/dist/server/runtime/http-server/daemon-admin-routes.js +9 -14
  170. package/dist/server/runtime/http-server/daemon-admin-routes.js.map +1 -1
  171. package/dist/server/runtime/http-server/executor-metadata.js +1 -1
  172. package/dist/server/runtime/http-server/executor-metadata.js.map +1 -1
  173. package/dist/server/runtime/http-server/executor-response.js +0 -16
  174. package/dist/server/runtime/http-server/executor-response.js.map +1 -1
  175. package/dist/server/runtime/http-server/hub-shadow-compare.d.ts +18 -0
  176. package/dist/server/runtime/http-server/hub-shadow-compare.js +256 -0
  177. package/dist/server/runtime/http-server/hub-shadow-compare.js.map +1 -0
  178. package/dist/server/runtime/http-server/index.d.ts +7 -2
  179. package/dist/server/runtime/http-server/index.js +287 -49
  180. package/dist/server/runtime/http-server/index.js.map +1 -1
  181. package/dist/server/runtime/http-server/middleware.js +19 -1
  182. package/dist/server/runtime/http-server/middleware.js.map +1 -1
  183. package/dist/server/runtime/http-server/request-executor.js +10 -19
  184. package/dist/server/runtime/http-server/request-executor.js.map +1 -1
  185. package/dist/server/runtime/http-server/routes.js +8 -2
  186. package/dist/server/runtime/http-server/routes.js.map +1 -1
  187. package/dist/server/runtime/http-server/session-dir.d.ts +2 -0
  188. package/dist/server/runtime/http-server/session-dir.js +59 -0
  189. package/dist/server/runtime/http-server/session-dir.js.map +1 -0
  190. package/dist/server/runtime/http-server/types.d.ts +0 -4
  191. package/dist/server/utils/utf8-chunk-buffer.js +6 -3
  192. package/dist/server/utils/utf8-chunk-buffer.js.map +1 -1
  193. package/dist/server/utils/warmup-storm-tracker.js +1 -1
  194. package/dist/server/utils/warmup-storm-tracker.js.map +1 -1
  195. package/dist/server-factory.d.ts +6 -28
  196. package/dist/server-factory.js +8 -93
  197. package/dist/server-factory.js.map +1 -1
  198. package/dist/token-daemon/index.js +2 -2
  199. package/dist/token-daemon/index.js.map +1 -1
  200. package/dist/token-daemon/provider-registry.js +0 -1
  201. package/dist/token-daemon/provider-registry.js.map +1 -1
  202. package/dist/token-daemon/server-utils.js +8 -9
  203. package/dist/token-daemon/server-utils.js.map +1 -1
  204. package/dist/token-daemon/token-utils.js +1 -1
  205. package/dist/token-daemon/token-utils.js.map +1 -1
  206. package/dist/tools/semantic-replay.js +2 -2
  207. package/dist/tools/semantic-replay.js.map +1 -1
  208. package/dist/tools/stats-request-events.d.ts +1 -1
  209. package/dist/tools/stats-usage.js +6 -3
  210. package/dist/tools/stats-usage.js.map +1 -1
  211. package/dist/utils/errorsamples.d.ts +5 -0
  212. package/dist/utils/errorsamples.js +27 -0
  213. package/dist/utils/errorsamples.js.map +1 -0
  214. package/dist/utils/llms-engine-shadow.d.ts +19 -0
  215. package/dist/utils/llms-engine-shadow.js +209 -0
  216. package/dist/utils/llms-engine-shadow.js.map +1 -0
  217. package/dist/utils/runtime-versions.d.ts +1 -0
  218. package/dist/utils/runtime-versions.js +39 -0
  219. package/dist/utils/runtime-versions.js.map +1 -0
  220. package/docs/ARCHITECTURE.md +402 -0
  221. package/docs/CODEX_AND_CLAUDE_CODE.md +69 -0
  222. package/docs/CONFIG_ARCHITECTURE.md +517 -0
  223. package/docs/ERROR_HANDLING_AUDIT.md +0 -0
  224. package/docs/GCLI2API_PARITY_GAPS.md +98 -0
  225. package/docs/INSTALLATION_AND_QUICKSTART.md +74 -0
  226. package/docs/INSTRUCTION_MARKUP.md +89 -0
  227. package/docs/MODULE_ENHANCEMENT_SYSTEM.md +666 -0
  228. package/docs/PORTS.md +36 -0
  229. package/docs/PROVIDERS_BUILTIN.md +111 -0
  230. package/docs/PROVIDER_TYPES.md +55 -0
  231. package/docs/SERVERTOOL_CLOCK_DESIGN.md +233 -0
  232. package/docs/USAGE_HANDLING_ANALYSIS.md +335 -0
  233. package/docs/USER_CONFIG_PARSER_CHANGES.md +175 -0
  234. package/docs/V3_INBOUND_OUTBOUND_DESIGN.md +86 -0
  235. package/docs/VIRTUAL_ROUTER_PRIORITY_AND_HEALTH.md +125 -0
  236. package/docs/anthropic-request-golden-samples.md +50 -0
  237. package/docs/ccr-alignment-enhancetool.md +105 -0
  238. package/docs/chat-glm-500-analysis.md +79 -0
  239. package/docs/chat-request-golden-samples.md +42 -0
  240. package/docs/chat-semantic-expansion-plan.md +82 -0
  241. package/docs/cli-command-inventory.md +76 -0
  242. package/docs/codex-samples-replay.md +50 -0
  243. package/docs/daemon-admin-api-design.md +350 -0
  244. package/docs/daemon-admin-module-structure.md +169 -0
  245. package/docs/daemon-admin-ui.html +3394 -0
  246. package/docs/debug-system-design.md +734 -0
  247. package/docs/debugging/gemini-sse-root-cause.md +52 -0
  248. package/docs/debugging/sse_encoding_failure_analysis.md +53 -0
  249. package/docs/dry-run/README.md +721 -0
  250. package/docs/error-handling-v2.md +92 -0
  251. package/docs/exec-command-guard-policy.example.v1.json +42 -0
  252. package/docs/fixes/gemini-protocol-mapping.md +57 -0
  253. package/docs/fixes/oauth-portal-timing-fix.md +202 -0
  254. package/docs/fixes/web-search-hop3-fix.md +265 -0
  255. package/docs/glm-api-reference.md +390 -0
  256. package/docs/glm-chat-completions.md +1779 -0
  257. package/docs/glm-history-inline-images.md +44 -0
  258. package/docs/golden-ci-library.md +66 -0
  259. package/docs/lmstudio-dry-run-summary.md +203 -0
  260. package/docs/lmstudio-tool-calling.md +214 -0
  261. package/docs/mapping-tables/anthropic-to-openai.json +290 -0
  262. package/docs/mapping-tables/iflow-to-openai.json +215 -0
  263. package/docs/mapping-tables/openai-passthrough.json +190 -0
  264. package/docs/mapping-tables/openai-to-iflow.json +227 -0
  265. package/docs/monitoring/Design.md +61 -0
  266. package/docs/multi-token-auth-guide.md +66 -0
  267. package/docs/oauth-authentication-guide.md +168 -0
  268. package/docs/oauth-iflow-implementation.md +153 -0
  269. package/docs/pipeline-routing-report.md +209 -0
  270. package/docs/plans/manager-daemon/PLAN.md +86 -0
  271. package/docs/plans/provider-config-v2-plan.md +176 -0
  272. package/docs/plans/provider-runtime-manager-plan.md +209 -0
  273. package/docs/plans/transparent-429-failover.md +89 -0
  274. package/docs/plans/unified-hub-framework-v1.md +245 -0
  275. package/docs/provider-config-v2-ui-design.md +181 -0
  276. package/docs/provider-quota-design.md +129 -0
  277. package/docs/providers/gemini-provider.md +62 -0
  278. package/docs/providers/lmstudio-v2-migration-report.md +102 -0
  279. package/docs/providers/provider-composite-design.md +142 -0
  280. package/docs/providers/provider-composite-testing.md +98 -0
  281. package/docs/providers/provider-type-only-migration.md +111 -0
  282. package/docs/rccx-wasm-migration.md +74 -0
  283. package/docs/refactoring/architecture-comparison-diagram.md +140 -0
  284. package/docs/refactoring/compatibility-v2-architecture-design.md +738 -0
  285. package/docs/refactoring/workflow-compatibility-refactoring-design.md +361 -0
  286. package/docs/reports/routing-classification-report.json +24 -0
  287. package/docs/reports/routing-classification-report.md +18 -0
  288. package/docs/reports/thinking-keywords-report.json +19 -0
  289. package/docs/responses/README.md +156 -0
  290. package/docs/responses-generic-provider.md +86 -0
  291. package/docs/responses-passthrough-provider-design.md +202 -0
  292. package/docs/routing-awrr-health-weighted-round-robin.md +179 -0
  293. package/docs/routing-instructions.md +393 -0
  294. package/docs/stop-message-auto.md +225 -0
  295. package/docs/streaming-flow.html +30 -0
  296. package/docs/streaming-flow.md +182 -0
  297. package/docs/token-daemon-preview.html +490 -0
  298. package/docs/token-refresh-daemon-plan.md +269 -0
  299. package/docs/transformation-tables/Gemini-FinishReason/345/256/214/346/225/264/350/275/254/346/215/242/350/241/250.json +233 -0
  300. package/docs/transformation-tables/README.md +225 -0
  301. package/docs/transformation-tables/claude-code-router-anthropic-to-gemini.json +283 -0
  302. package/docs/transformation-tables/claude-code-router-anthropic-to-openai.json +208 -0
  303. package/docs/transformation-tables/claude-code-router-openai-to-anthropic.json +261 -0
  304. package/docs/transformation-tables/claude-code-router-openai-to-gemini.json +208 -0
  305. package/docs/transformation-tables/claude-code-router-openai-to-lmstudio.json +182 -0
  306. package/docs/transformation-tables/claude-code-router-openai-to-ollama.json +250 -0
  307. package/docs/transformation-tables/claude-code-router-openai-to-textgenwebui.json +295 -0
  308. package/docs/transformation-tables/claude-code-router-provider-conversions.json +193 -0
  309. package/docs/transformation-tables//345/256/214/346/225/264/347/232/204/345/267/245/345/205/267/346/211/247/350/241/214/346/265/201/347/250/213/350/275/254/346/215/242/350/241/250.json +299 -0
  310. package/docs/transformation-tables//345/257/271/350/257/235/345/216/206/345/217/262/347/273/264/346/212/244/345/210/206/346/236/220.md +134 -0
  311. package/docs/transformation-tables//345/267/245/345/205/267/350/260/203/347/224/250/346/250/241/345/274/217/345/210/206/346/236/220.md +158 -0
  312. package/docs/transformation-tables//347/212/266/346/200/201/347/256/241/347/220/206/351/234/200/346/261/202/345/210/206/346/236/220.md +175 -0
  313. package/docs/transformation-tables//351/235/231/346/200/201/350/241/250vs/345/212/250/346/200/201/345/210/206/346/236/220.md +189 -0
  314. package/docs/transformation-tables//351/235/231/346/200/201/350/241/250/345/207/206/347/241/256/346/200/247/350/257/204/344/274/260.md +179 -0
  315. package/docs/transformation-tables//351/235/236/346/265/201/345/274/217/345/234/272/346/231/257/345/210/206/346/236/220.md +189 -0
  316. package/docs/v2-architecture/IMPLEMENTATION-ROADMAP.md +367 -0
  317. package/docs/v2-architecture/OPTIMIZED-DESIGN.md +827 -0
  318. package/docs/v2-architecture/PRERUN-CONNECTION-DESIGN.md +716 -0
  319. package/docs/v2-architecture/README.md +551 -0
  320. package/docs/verification/modelscope-verify.md +59 -0
  321. package/docs/web-search-service-design.md +322 -0
  322. package/package.json +12 -7
  323. package/scripts/camoufox/launch-auth.mjs +193 -58
  324. package/scripts/monitor-diff.mjs +126 -0
  325. package/scripts/pack-mode.mjs +19 -1
  326. package/scripts/pack-rcc.mjs +63 -0
  327. package/scripts/unified-hub-shadow-compare.mjs +33 -13
  328. package/scripts/verify-e2e-toolcall.mjs +115 -26
  329. package/dist/modules/llmswitch/pipeline-registry.d.ts +0 -57
  330. package/dist/modules/llmswitch/pipeline-registry.js +0 -229
  331. package/dist/modules/llmswitch/pipeline-registry.js.map +0 -1
  332. package/dist/server/RouteCodexServer.d.ts +0 -13
  333. package/dist/server/RouteCodexServer.js +0 -25
  334. package/dist/server/RouteCodexServer.js.map +0 -1
  335. package/dist/v2/conversion/hub/snapshot-recorder.d.ts +0 -12
  336. package/dist/v2/conversion/hub/snapshot-recorder.js +0 -22
  337. package/dist/v2/conversion/hub/snapshot-recorder.js.map +0 -1
@@ -0,0 +1,551 @@
1
+ # V2 Pipeline Architecture Design
2
+
3
+ > **Status**: This blueprint is frozen. Current implementation follows AGENTS.md principles (single execution path, no bypasses). This doc is retained for historical reference only; do not use as current architecture guidance.
4
+
5
+ ## 🎯 Design Objectives
6
+
7
+ This document outlines the V2 pipeline architecture design for RouteCodex, focusing on:
8
+
9
+ 1. **Gradual Migration**: V2 refactoring with seamless V1/V2 switching
10
+ 2. **Virtual Pipeline**: Dynamic routing replacing static assembly
11
+ 3. **Unified Configuration**: Complete V2 configuration system
12
+ 4. **System Integration Hooks**: Global hooks for request lifecycle management
13
+
14
+ ## 🏗️ Overall Architecture
15
+
16
+ ### Architecture Comparison
17
+
18
+ ```
19
+ ┌─────────────────────────────────────────────────────────────────┐
20
+ │ V1/V2 Dual Mode Architecture │
21
+ ├─────────────────────────────────────────────────────────────────┤
22
+ │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
23
+ │ │ Mode Switch │ │ Route Selector│ │ Config Manager │ │
24
+ │ │ (Feature Flag) │ │ (Route Selector)│ │ (Config Manager) │ │
25
+ │ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
26
+ │ │ │ │ │
27
+ │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
28
+ │ │ V1 Static │ │ V2 Virtual │ │ System Hooks │ │
29
+ │ │ (Static Build) │ │ (Dynamic Route) │ │ (System Hooks) │ │
30
+ │ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
31
+ └─────────────────────────────────────────────────────────────────┘
32
+ ```
33
+
34
+ ## 📋 Phase 1: V2 Virtual Pipeline Architecture
35
+
36
+ ### 1.1 Core Design Concept
37
+
38
+ **V1 Static Assembly** (Current):
39
+ ```
40
+ Request → Pre-assembled Pipeline → Static Module Chain → Response
41
+ [Provider][Compatibility][LLMSwitch] (Pre-instantiated)
42
+ ```
43
+
44
+ **V2 Virtual Pipeline** (New Design):
45
+ ```
46
+ Request → Route Decision → Dynamic Module Connection → Response
47
+
48
+ [Module Registry] → [Runtime Assembly] → [Temporary Connection] → [Request Process] → [Auto Cleanup]
49
+ ```
50
+
51
+ ### 1.2 V2 Core Components
52
+
53
+ #### A. Module Registry (ModuleRegistry)
54
+ ```typescript
55
+ // src/modules/pipeline/v2/core/module-registry.ts
56
+ export class V2ModuleRegistry {
57
+ private modules = new Map<string, ModuleFactory>();
58
+ private instances = new Map<string, ModuleInstance>();
59
+
60
+ // Register module factory (not instance)
61
+ register(type: string, factory: ModuleFactory): void
62
+
63
+ // Create module instance on demand (lazy loading)
64
+ createInstance(type: string, config: ModuleConfig): Promise<ModuleInstance>
65
+
66
+ // Get or create instance (singleton pattern)
67
+ getOrCreateInstance(type: string, config: ModuleConfig): Promise<ModuleInstance>
68
+
69
+ // Cleanup idle instances (memory management)
70
+ cleanupIdleInstances(): void
71
+ }
72
+ ```
73
+
74
+ #### B. Dynamic Router (DynamicRouter)
75
+ ```typescript
76
+ // src/modules/pipeline/v2/core/dynamic-router.ts
77
+ export class DynamicRouter {
78
+ constructor(
79
+ private moduleRegistry: V2ModuleRegistry,
80
+ private routeTable: RouteTable
81
+ ) {}
82
+
83
+ // Route request dynamically to module chain
84
+ async route(request: PipelineRequest): Promise<ModuleChain>
85
+
86
+ // Build temporary module connection
87
+ private async buildModuleChain(route: Route): Promise<ModuleChain>
88
+
89
+ // Execute module chain processing
90
+ async executeChain(chain: ModuleChain, request: PipelineRequest): Promise<PipelineResponse>
91
+ }
92
+ ```
93
+
94
+ #### C. Module Chain Manager (ChainManager)
95
+ ```typescript
96
+ // src/modules/pipeline/v2/core/chain-manager.ts
97
+ export class ModuleChain {
98
+ readonly id: string;
99
+ readonly modules: ModuleInstance[];
100
+ readonly connections: ModuleConnection[];
101
+
102
+ // Execute chain processing
103
+ async process(request: PipelineRequest): Promise<PipelineResponse>
104
+
105
+ // Auto cleanup connections
106
+ async cleanup(): Promise<void>
107
+ }
108
+
109
+ export class ModuleConnection {
110
+ constructor(
111
+ public from: ModuleInstance,
112
+ public to: ModuleInstance,
113
+ public transform?: (data: any) => any
114
+ ) {}
115
+ }
116
+ ```
117
+
118
+ ### 1.3 Virtual Pipeline Lifecycle
119
+
120
+ ```
121
+ 1. Request Enter → 2. Route Analysis → 3. Module Lookup → 4. Instance Check → 5. Dynamic Connection
122
+ ↓ ↓ ↓ ↓ ↓
123
+ [Request Parse] → [Route Table Match] → [Module Registry] → [Instance Cache] → [Temporary Chain Build]
124
+ ↓ ↓ ↓ ↓ ↓
125
+ 6. Chain Execute → 7. Response Return → 8. Connection Cleanup → 9. Instance Recycling → 10. Log Recording
126
+ [Data Processing] → [Result Return] → [Auto Disconnect] → [Cache Retention] → [Audit Trail]
127
+ ```
128
+
129
+ ## 📋 Phase 2: V2 Unified Configuration System
130
+
131
+ ### 2.1 V2 Configuration Schema Design
132
+
133
+ ```typescript
134
+ // src/config/v2-config-schema.ts
135
+ export interface V2SystemConfig {
136
+ version: '2.0';
137
+
138
+ // System switch configuration
139
+ system: {
140
+ mode: 'v1' | 'v2' | 'hybrid';
141
+ featureFlags: Record<string, boolean>;
142
+ };
143
+
144
+ // Global hooks configuration
145
+ hooks: SystemHooksConfig;
146
+
147
+ // V2 virtual pipeline configuration
148
+ virtualPipelines: {
149
+ routeTable: RouteTableConfig;
150
+ moduleRegistry: ModuleRegistryConfig;
151
+ chainManagement: ChainManagementConfig;
152
+ };
153
+
154
+ // V1 configuration compatibility (auto convert)
155
+ legacy?: V1Config;
156
+ }
157
+
158
+ export interface RouteTableConfig {
159
+ routes: RouteDefinition[];
160
+ defaultRoute: string;
161
+ // Note: No fallback strategies - fail fast when routing fails
162
+ }
163
+
164
+ export interface RouteDefinition {
165
+ id: string;
166
+ pattern: RequestPattern;
167
+ modules: string[]; // Module type array, not instances
168
+ config: RouteConfig;
169
+ priority: number;
170
+ }
171
+ ```
172
+
173
+ ### 2.2 Configuration Migration Adapter
174
+
175
+ ```typescript
176
+ // src/config/v2-migration-adapter.ts
177
+ export class V2MigrationAdapter {
178
+ // Auto convert V1 configuration to V2 format
179
+ static migrateV1Config(v1Config: V1Config): V2SystemConfig {
180
+ return {
181
+ version: '2.0',
182
+ system: { mode: 'v2', featureFlags: {} },
183
+ hooks: this.extractHooksFromV1(v1Config),
184
+ virtualPipelines: this.convertPipelinesToVirtual(v1Config),
185
+ legacy: v1Config // Keep original config for rollback
186
+ };
187
+ }
188
+
189
+ // Generate migration report
190
+ static generateMigrationReport(v1Config: V1Config): MigrationReport {
191
+ return {
192
+ breakingChanges: [],
193
+ newFeatures: [],
194
+ manualSteps: [],
195
+ estimatedEffort: 'low'
196
+ };
197
+ }
198
+ }
199
+ ```
200
+
201
+ ## 📋 Phase 3: V1/V2 Dual Mode Switch System
202
+
203
+ ### 3.1 Switch Design
204
+
205
+ ```typescript
206
+ // src/core/system-mode-switch.ts
207
+ export class SystemModeSwitch {
208
+ private currentMode: 'v1' | 'v2' = 'v1';
209
+ private v1Assembler?: V1PipelineAssembler;
210
+ private v2Router?: V2DynamicRouter;
211
+
212
+ // Runtime mode switching
213
+ async switchMode(mode: 'v1' | 'v2'): Promise<void> {
214
+ if (mode === this.currentMode) return;
215
+
216
+ // 1. Stop current mode
217
+ await this.stopCurrentMode();
218
+
219
+ // 2. Start target mode
220
+ await this.startTargetMode(mode);
221
+
222
+ // 3. Validate switch success
223
+ await this.validateModeSwitch(mode);
224
+
225
+ this.currentMode = mode;
226
+ }
227
+
228
+ // Handle request (auto route to current mode)
229
+ async handleRequest(request: PipelineRequest): Promise<PipelineResponse> {
230
+ return this.currentMode === 'v1'
231
+ ? this.v1Assembler!.process(request)
232
+ : this.v2Router!.route(request);
233
+ }
234
+ }
235
+ ```
236
+
237
+ ### 3.2 Hybrid Mode Design
238
+
239
+ ```typescript
240
+ // src/core/hybrid-mode-manager.ts
241
+ export class HybridModeManager {
242
+ // Select V1 or V2 based on request characteristics
243
+ selectMode(request: PipelineRequest): 'v1' | 'v2' {
244
+ // Decision based on request features, config flags, runtime state
245
+ if (this.shouldUseV2(request)) return 'v2';
246
+ return 'v1';
247
+ }
248
+
249
+ // Gradual traffic switching
250
+ async gradualTransition(percentage: number): Promise<void> {
251
+ // Gradually increase V2 traffic ratio
252
+ // Monitor key metrics
253
+ // Auto rollback mechanism
254
+ }
255
+ }
256
+ ```
257
+
258
+ ## 📋 Phase 4: System Integration Hooks
259
+
260
+ ### 4.1 Hooks Architecture Design
261
+
262
+ ```typescript
263
+ // src/hooks/system-hooks.ts
264
+ export interface SystemHooks {
265
+ // Request lifecycle hooks
266
+ onRequest?: (request: PipelineRequest) => PipelineRequest | Promise<PipelineRequest>;
267
+ beforeRoute?: (request: PipelineRequest) => void | Promise<void>;
268
+ afterRoute?: (route: Route) => void | Promise<void>;
269
+ beforeModule?: (module: ModuleInstance, data: any) => any | Promise<any>;
270
+ afterModule?: (module: ModuleInstance, result: any) => any | Promise<any>;
271
+ onResponse?: (response: PipelineResponse) => PipelineResponse | Promise<PipelineResponse>;
272
+
273
+ // System lifecycle hooks
274
+ onModeSwitch?: (from: string, to: string) => void | Promise<void>;
275
+ onError?: (error: Error, context: any) => void | Promise<void>;
276
+ onMetric?: (metric: SystemMetric) => void | Promise<void>;
277
+ }
278
+
279
+ export class SystemHookManager {
280
+ private hooks = new Map<string, SystemHook[]>();
281
+
282
+ // Register hook
283
+ register(event: string, hook: SystemHook): void
284
+
285
+ // Execute hook chain
286
+ async execute(event: string, data: any): Promise<any>
287
+
288
+ // Dynamic enable/disable hook
289
+ toggle(event: string, enabled: boolean): void
290
+ }
291
+ ```
292
+
293
+ ### 4.2 Built-in System Hooks
294
+
295
+ ```typescript
296
+ // src/hooks/builtin-hooks.ts
297
+ export class BuiltinHooks {
298
+ // Request tracking hook
299
+ static requestTracer: SystemHook = {
300
+ onRequest: async (request) => {
301
+ request.traceId = generateTraceId();
302
+ request.startTime = Date.now();
303
+ return request;
304
+ },
305
+ onResponse: async (response) => {
306
+ const duration = Date.now() - response.request.startTime;
307
+ metrics.record('request.duration', duration);
308
+ return response;
309
+ }
310
+ };
311
+
312
+ // Mode switch hook
313
+ static modeSwitchLogger: SystemHook = {
314
+ onModeSwitch: async (from, to) => {
315
+ logger.info(`System mode switched from ${from} to ${to}`, {
316
+ timestamp: new Date().toISOString(),
317
+ trigger: 'manual'
318
+ });
319
+ }
320
+ };
321
+
322
+ // Error logging hook (NO auto fallback - fail fast)
323
+ static errorLogger: SystemHook = {
324
+ onError: async (error, context) => {
325
+ // Log detailed error information for manual intervention
326
+ logger.error('V2 error detected', {
327
+ error: error.message,
328
+ stack: error.stack,
329
+ context: {
330
+ mode: context.mode,
331
+ requestId: context.requestId,
332
+ routeId: context.routeId,
333
+ timestamp: new Date().toISOString()
334
+ }
335
+ });
336
+
337
+ // Emit metrics for monitoring
338
+ metrics.increment('v2.errors.total', {
339
+ errorType: error.constructor.name,
340
+ mode: context.mode
341
+ });
342
+ }
343
+ };
344
+ }
345
+ ```
346
+
347
+ ## 📋 Phase 5: Monitoring and Observability
348
+
349
+ ### 5.1 V2 Specific Monitoring Metrics
350
+
351
+ ```typescript
352
+ // src/monitoring/v2-metrics.ts
353
+ export class V2Metrics {
354
+ // Dynamic routing metrics
355
+ routeCacheHitRate: Gauge;
356
+ moduleChainBuildTime: Histogram;
357
+ activeConnections: Gauge;
358
+
359
+ // Module instance metrics
360
+ moduleInstanceCount: Gauge;
361
+ moduleInstanceMemoryUsage: Gauge;
362
+ moduleIdleTime: Histogram;
363
+
364
+ // Mode switching metrics
365
+ modeSwitchCount: Counter;
366
+ modeSwitchLatency: Histogram;
367
+ v1VsV2RequestRatio: Gauge;
368
+ }
369
+ ```
370
+
371
+ ### 5.2 Debug Tools
372
+
373
+ ```typescript
374
+ // src/debugging/v2-debug-tools.ts
375
+ export class V2DebugTools {
376
+ // Visualize dynamic routing
377
+ async visualizeRoute(request: PipelineRequest): Promise<RouteVisualization>
378
+
379
+ // Module chain tracing
380
+ async traceModuleChain(chainId: string): Promise<ChainTrace>
381
+
382
+ // Performance analysis
383
+ async analyzePerformance(timeRange: TimeRange): Promise<PerformanceReport>
384
+
385
+ // Configuration validation
386
+ async validateV2Config(config: V2SystemConfig): Promise<ValidationReport>
387
+ }
388
+ ```
389
+
390
+ ## 🔧 Compatibility Layer Responsibilities
391
+
392
+ ### Field Mapping + Format Conversion + Provider-Specific Processing
393
+
394
+ **Compatibility层核心职责**:将特定Provider的响应格式转换为标准OpenAI格式,支持配置驱动的字段映射、格式转换和清理。
395
+
396
+ #### 核心功能组件
397
+
398
+ 1. **字段映射 (Field Mappings)**
399
+ - 将Provider特有字段映射到OpenAI标准字段
400
+ - 清理Provider特有的多余字段
401
+ - 保持字段语义的一致性
402
+
403
+ 2. **格式转换 (Format Conversions)**
404
+ - 标准化日期时间格式
405
+ - 转换使用统计格式
406
+ - 处理特殊字段的格式要求
407
+
408
+ 3. **供应商特定处理 (Provider-Specific Processing)**
409
+ - Provider特有的清理逻辑
410
+ - Provider特有的格式转换
411
+ - 基于配置的条件处理
412
+
413
+ 4. **Hooks机制**
414
+ - **beforeFieldMapping**: 字段映射前的预处理
415
+ - **afterFieldMapping**: 字段映射后的后处理
416
+ - 只处理字段映射相关的逻辑,不涉及工具处理
417
+
418
+ #### 配置驱动示例
419
+
420
+ ```typescript
421
+ 'glm-compatibility-config': {
422
+ fieldMappings: {
423
+ request: { 'model': 'model', 'messages': 'messages' },
424
+ response: {
425
+ 'choices': 'choices',
426
+ 'usage': 'usage',
427
+ 'thought': null // 清理GLM特有字段
428
+ }
429
+ },
430
+ formatConversions: {
431
+ reasoningContent: {
432
+ source: 'thought',
433
+ target: 'reasoning_content',
434
+ transform: 'extract_and_format'
435
+ }
436
+ },
437
+ hooks: {
438
+ beforeFieldMapping: ['glm-request-preprocessor'],
439
+ afterFieldMapping: ['glm-response-postprocessor']
440
+ }
441
+ }
442
+ ```
443
+
444
+ ## 🔧 Tools Unique Entrance (Principle 1-3)
445
+
446
+ ### Mandatory Tool Processing Contract
447
+
448
+ **V2 enforces llmswitch-core as the ONLY module that can touch tool calls**. This is non-negotiable and enforced at schema validation time.
449
+
450
+ #### Required Module Order
451
+ ```
452
+ provider → compatibility → llmswitch (final) → response
453
+ ```
454
+
455
+ #### llmswitch-core Exclusive Responsibilities
456
+ Only `llmswitch-core` modules may perform:
457
+
458
+ 1. **Tool Text Harvesting**: Extract tool calls from message content
459
+ - Implementation: `sharedmodule/llmswitch-core/src/conversion/shared/tool-canonicalizer.ts`
460
+ 2. **Tool Calls Canonicalization**: Normalize tool_calls structure
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
465
+ - 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
469
+ - Implementation: `sharedmodule/llmswitch-core/src/conversion/responses/responses-openai-bridge.ts`
470
+
471
+ #### V2 Guardrails
472
+ - Any chain where non-llmswitch module references tool handling is rejected
473
+ - Compatibility modules can only perform field mappings and format conversions (no tool logic)
474
+ - Server/hook layers cannot modify tool calls directly
475
+ - Tool validation must use llmswitch-core validators only
476
+ - Compatibility层的hooks只处理字段映射相关的供应商特定逻辑,不涉及工具处理
477
+
478
+ #### Schema-Level Validation Enforcement
479
+ ```typescript
480
+ // Schema validation at assembly time
481
+ export class V2SchemaValidator {
482
+ static validateModuleOrder(route: RouteDefinition): ValidationResult {
483
+ // Required order: provider → compatibility → llmswitch (must be last)
484
+ const moduleTypes = route.modules.map(m => m.type);
485
+
486
+ if (moduleTypes[moduleTypes.length - 1] !== 'llmswitch') {
487
+ throw new ConfigValidationError(
488
+ `Route ${route.id} violates ToolsUniqueEntrance: llmswitch must be last module`,
489
+ ['routes', route.id, 'modules', 'order']
490
+ );
491
+ }
492
+
493
+ return { isValid: true, errors: [] };
494
+ }
495
+ }
496
+ ```
497
+
498
+ All configurations must pass schema validation at assembly time, with violations resulting in `ConfigValidationError` that exposes the exact config path for debugging.
499
+
500
+ ## 🚀 Implementation Roadmap
501
+
502
+ ### Phase 1: V2 Basic Architecture (3-4 days)
503
+ - [ ] Implement V2ModuleRegistry
504
+ - [ ] Implement DynamicRouter and ModuleChain
505
+ - [ ] Create V2 configuration schema
506
+ - [ ] Implement V2MigrationAdapter
507
+
508
+ ### Phase 2: Switch Mechanism (2-3 days)
509
+ - [ ] Implement SystemModeSwitch
510
+ - [ ] Implement HybridModeManager
511
+ - [ ] Add mode switching API
512
+ - [ ] Implement auto rollback mechanism
513
+
514
+ ### Phase 3: System Hooks (2 days)
515
+ - [ ] Implement SystemHookManager
516
+ - [ ] Create BuiltinHooks collection
517
+ - [ ] Integrate into request lifecycle
518
+ - [ ] Add hook configuration management
519
+
520
+ ### Phase 4: Monitoring & Debugging (1-2 days)
521
+ - [ ] Implement V2Metrics
522
+ - [ ] Create V2DebugTools
523
+ - [ ] Integrate into existing monitoring system
524
+ - [ ] Add debugging API endpoints
525
+
526
+ ### Phase 5: Testing & Validation (2-3 days)
527
+ - [ ] Unit test coverage
528
+ - [ ] Integration test validation
529
+ - [ ] Performance benchmark testing
530
+ - [ ] Stress test validation
531
+
532
+ ## 🎯 Key Advantages
533
+
534
+ 1. **Zero Risk Migration**: Switch back to V1 anytime, ensure business continuity
535
+ 2. **Resource Optimization**: Virtual pipeline avoids large number of pre-built instances
536
+ 3. **Flexible Routing**: Support dynamic routing decisions based on request characteristics
537
+ 4. **System Observability**: Global hooks provide complete request lifecycle intervention capability
538
+ 5. **Configuration Unification**: V2 configuration backward compatible, smooth migration
539
+
540
+ ## 📊 Risk Assessment
541
+
542
+ | Risk Item | Level | Mitigation Measures |
543
+ |-----------|-------|---------------------|
544
+ | Performance Regression | Medium | Instance caching + warmup mechanism + performance monitoring |
545
+ | Switch Failure | Low | Auto rollback + health check + state validation |
546
+ | Configuration Compatibility | Medium | Auto migration + configuration validation + manual adjustment tools |
547
+ | Memory Leaks | Medium | Auto cleanup + instance pool management + memory monitoring |
548
+
549
+ ---
550
+
551
+ *This design document serves as the blueprint for V2 architecture implementation. All components should follow these design principles and interfaces.*
@@ -0,0 +1,59 @@
1
+ # ModelScope 独立验证记录
2
+
3
+ - 日期: 2025-09-26
4
+ - 配置文件: `~/.routecodex/config/modelscope.json`
5
+ - 监听端口: 5507(示例环境)
6
+
7
+ ## 验证范围
8
+
9
+ - 非流式 Chat Completions:返回 OpenAI 标准结构(`id/object/created/model/choices/usage`)
10
+ - 流式 Chat Completions(SSE):`object: chat.completion.chunk`,`delta.content` 正常输出,`[DONE]` 终止
11
+ - 严格 JSON 模式:`response_format: { "type": "json_object" }` 时,`message.content` 清洗为纯 JSON 字符串
12
+ - 429 调度:由 PipelineManager 统一处理,多 Key/Pipeline 轮询重试;全部枯竭才返回 429
13
+ - 统一响应头:`x-request-id`、`Cache-Control: no-store`、`Content-Type: application/json; charset=utf-8`
14
+
15
+ ## 快速验证命令
16
+
17
+ 非流式:
18
+
19
+ ```
20
+ curl -i -sS -H 'Content-Type: application/json' \
21
+ -X POST http://localhost:5507/v1/chat/completions \
22
+ -d '{
23
+ "model": "Qwen/Qwen3-Coder-480B-A35B-Instruct",
24
+ "messages": [{"role":"user","content":"Hello from ModelScope test."}],
25
+ "stream": false
26
+ }'
27
+ ```
28
+
29
+ 流式:
30
+
31
+ ```
32
+ curl -sS -N -H 'Content-Type: application/json' \
33
+ -X POST http://localhost:5507/v1/chat/completions \
34
+ -d '{
35
+ "model": "Qwen/Qwen3-Coder-480B-A35B-Instruct",
36
+ "messages": [{"role":"user","content":"Stream a short reply."}],
37
+ "stream": true
38
+ }'
39
+ ```
40
+
41
+ 严格 JSON 模式:
42
+
43
+ ```
44
+ curl -i -sS -H 'Content-Type: application/json' \
45
+ -X POST http://localhost:5507/v1/chat/completions \
46
+ -d '{
47
+ "model": "Qwen/Qwen3-Coder-480B-A35B-Instruct",
48
+ "messages": [{"role":"user","content":"只返回一个JSON对象:{\"ok\":true}"}],
49
+ "response_format": { "type": "json_object" },
50
+ "stream": false
51
+ }'
52
+ ```
53
+
54
+ ## 日志与追踪
55
+
56
+ - 运行日志:`server-modelscope.log`
57
+ - DebugCenter:`~/.routecodex/logs/debug-center.log`
58
+ - 关联方式:使用响应头 `x-request-id` 在日志中检索对应请求链路
59
+