@jsonstudio/rcc 0.89.3 → 0.89.164

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 (270) hide show
  1. package/README.md +240 -179
  2. package/config/modules.json +1 -11
  3. package/dist/build-info.js +2 -2
  4. package/dist/build-info.js.map +1 -1
  5. package/dist/client/gemini-cli/gemini-cli-protocol-client.d.ts +16 -0
  6. package/dist/client/gemini-cli/gemini-cli-protocol-client.js +56 -0
  7. package/dist/client/gemini-cli/gemini-cli-protocol-client.js.map +1 -0
  8. package/dist/client/openai/chat-protocol-client.js.map +1 -1
  9. package/dist/config/modules.json +1 -11
  10. package/dist/core/provider-health-manager.d.ts +17 -0
  11. package/dist/core/provider-health-manager.js +66 -0
  12. package/dist/core/provider-health-manager.js.map +1 -0
  13. package/dist/error-handling/route-error-hub.d.ts +48 -0
  14. package/dist/error-handling/route-error-hub.js +131 -0
  15. package/dist/error-handling/route-error-hub.js.map +1 -0
  16. package/dist/index.js +26 -1
  17. package/dist/index.js.map +1 -1
  18. package/dist/modules/llmswitch/bridge.d.ts +2 -0
  19. package/dist/modules/llmswitch/bridge.js +17 -0
  20. package/dist/modules/llmswitch/bridge.js.map +1 -1
  21. package/dist/modules/pipeline/utils/colored-logger.d.ts +14 -0
  22. package/dist/modules/pipeline/utils/colored-logger.js +48 -0
  23. package/dist/modules/pipeline/utils/colored-logger.js.map +1 -0
  24. package/dist/modules/pipeline/utils/debug-logger.d.ts +2 -0
  25. package/dist/modules/pipeline/utils/debug-logger.js +36 -0
  26. package/dist/modules/pipeline/utils/debug-logger.js.map +1 -1
  27. package/dist/providers/auth/gemini-cli-userinfo-helper.d.ts +53 -0
  28. package/dist/providers/auth/gemini-cli-userinfo-helper.js +152 -0
  29. package/dist/providers/auth/gemini-cli-userinfo-helper.js.map +1 -0
  30. package/dist/providers/auth/oauth-auth.js +3 -2
  31. package/dist/providers/auth/oauth-auth.js.map +1 -1
  32. package/dist/providers/auth/oauth-lifecycle.js +21 -20
  33. package/dist/providers/auth/oauth-lifecycle.js.map +1 -1
  34. package/dist/providers/auth/oauth-logger.d.ts +1 -0
  35. package/dist/providers/auth/oauth-logger.js +21 -0
  36. package/dist/providers/auth/oauth-logger.js.map +1 -0
  37. package/dist/providers/compat/compat-directory-loader.js +2 -55
  38. package/dist/providers/compat/compat-directory-loader.js.map +1 -1
  39. package/dist/providers/compat/compatibility-factory.d.ts +4 -4
  40. package/dist/providers/compat/compatibility-factory.js +108 -0
  41. package/dist/providers/compat/compatibility-factory.js.map +1 -1
  42. package/dist/providers/compat/glm/glm-compatibility.d.ts +2 -2
  43. package/dist/providers/compat/glm/glm-compatibility.js +7 -7
  44. package/dist/providers/compat/glm/glm-compatibility.js.map +1 -1
  45. package/dist/providers/compat/glm/index.js +0 -6
  46. package/dist/providers/compat/glm/index.js.map +1 -1
  47. package/dist/providers/compat/iflow/iflow-compatibility.d.ts +1 -1
  48. package/dist/providers/compat/iflow/iflow-compatibility.js +6 -6
  49. package/dist/providers/compat/iflow/iflow-compatibility.js.map +1 -1
  50. package/dist/providers/compat/index.d.ts +0 -6
  51. package/dist/providers/compat/index.js +0 -7
  52. package/dist/providers/compat/index.js.map +1 -1
  53. package/dist/providers/compat/lmstudio-compatibility.d.ts +2 -2
  54. package/dist/providers/compat/lmstudio-compatibility.js +4 -4
  55. package/dist/providers/compat/lmstudio-compatibility.js.map +1 -1
  56. package/dist/providers/compat/passthrough-compatibility.d.ts +1 -1
  57. package/dist/providers/compat/passthrough-compatibility.js +3 -3
  58. package/dist/providers/compat/passthrough-compatibility.js.map +1 -1
  59. package/dist/providers/compat/profiles/chat/glm/index.d.ts +6 -0
  60. package/dist/providers/compat/profiles/chat/glm/index.js +6 -0
  61. package/dist/providers/compat/profiles/chat/glm/index.js.map +1 -0
  62. package/dist/providers/compat/profiles/chat/iflow/index.d.ts +6 -0
  63. package/dist/providers/compat/profiles/chat/iflow/index.js +6 -0
  64. package/dist/providers/compat/profiles/chat/iflow/index.js.map +1 -0
  65. package/dist/providers/compat/profiles/chat/lmstudio/index.d.ts +6 -0
  66. package/dist/providers/compat/profiles/chat/lmstudio/index.js +6 -0
  67. package/dist/providers/compat/profiles/chat/lmstudio/index.js.map +1 -0
  68. package/dist/providers/compat/profiles/chat/qwen/index.d.ts +6 -0
  69. package/dist/providers/compat/profiles/chat/qwen/index.js +6 -0
  70. package/dist/providers/compat/profiles/chat/qwen/index.js.map +1 -0
  71. package/dist/providers/compat/profiles/compat/passthrough/index.d.ts +6 -0
  72. package/dist/providers/compat/profiles/compat/passthrough/index.js +6 -0
  73. package/dist/providers/compat/profiles/compat/passthrough/index.js.map +1 -0
  74. package/dist/providers/compat/profiles/responses/c4m/index.d.ts +6 -0
  75. package/dist/providers/compat/profiles/responses/c4m/index.js +6 -0
  76. package/dist/providers/compat/profiles/responses/c4m/index.js.map +1 -0
  77. package/dist/providers/compat/profiles/responses/default/index.d.ts +6 -0
  78. package/dist/providers/compat/profiles/responses/default/index.js +6 -0
  79. package/dist/providers/compat/profiles/responses/default/index.js.map +1 -0
  80. package/dist/providers/compat/profiles/responses/fai/index.d.ts +6 -0
  81. package/dist/providers/compat/profiles/responses/fai/index.js +6 -0
  82. package/dist/providers/compat/profiles/responses/fai/index.js.map +1 -0
  83. package/dist/providers/compat/profiles/responses/fc/index.d.ts +6 -0
  84. package/dist/providers/compat/profiles/responses/fc/index.js +6 -0
  85. package/dist/providers/compat/profiles/responses/fc/index.js.map +1 -0
  86. package/dist/providers/compat/qwen/index.js +0 -6
  87. package/dist/providers/compat/qwen/index.js.map +1 -1
  88. package/dist/providers/compat/qwen-compatibility.d.ts +2 -2
  89. package/dist/providers/compat/qwen-compatibility.js +4 -4
  90. package/dist/providers/compat/qwen-compatibility.js.map +1 -1
  91. package/dist/providers/compat/register-compat-module.d.ts +8 -0
  92. package/dist/providers/compat/register-compat-module.js +53 -0
  93. package/dist/providers/compat/register-compat-module.js.map +1 -0
  94. package/dist/providers/compat/responses/c4m-responses-compatibility.d.ts +6 -2
  95. package/dist/providers/compat/responses/c4m-responses-compatibility.js +85 -3
  96. package/dist/providers/compat/responses/c4m-responses-compatibility.js.map +1 -1
  97. package/dist/providers/compat/standard-compatibility-utils.js +45 -15
  98. package/dist/providers/compat/standard-compatibility-utils.js.map +1 -1
  99. package/dist/providers/core/api/provider-config.d.ts +1 -1
  100. package/dist/providers/core/api/provider-types.d.ts +3 -1
  101. package/dist/providers/core/api/provider-types.js +1 -0
  102. package/dist/providers/core/api/provider-types.js.map +1 -1
  103. package/dist/providers/core/config/service-profiles.js +5 -2
  104. package/dist/providers/core/config/service-profiles.js.map +1 -1
  105. package/dist/providers/core/runtime/base-provider.d.ts +3 -0
  106. package/dist/providers/core/runtime/base-provider.js +101 -6
  107. package/dist/providers/core/runtime/base-provider.js.map +1 -1
  108. package/dist/providers/core/runtime/gemini-cli-http-provider.d.ts +34 -0
  109. package/dist/providers/core/runtime/gemini-cli-http-provider.js +152 -0
  110. package/dist/providers/core/runtime/gemini-cli-http-provider.js.map +1 -0
  111. package/dist/providers/core/runtime/http-transport-provider.d.ts +1 -0
  112. package/dist/providers/core/runtime/http-transport-provider.js +178 -123
  113. package/dist/providers/core/runtime/http-transport-provider.js.map +1 -1
  114. package/dist/providers/core/runtime/provider-factory.d.ts +1 -1
  115. package/dist/providers/core/runtime/provider-factory.js +8 -0
  116. package/dist/providers/core/runtime/provider-factory.js.map +1 -1
  117. package/dist/providers/core/runtime/provider-runtime-metadata.d.ts +1 -0
  118. package/dist/providers/core/runtime/provider-runtime-metadata.js.map +1 -1
  119. package/dist/providers/core/runtime/responses-provider.d.ts +7 -0
  120. package/dist/providers/core/runtime/responses-provider.js +228 -12
  121. package/dist/providers/core/runtime/responses-provider.js.map +1 -1
  122. package/dist/providers/core/strategies/oauth-auth-code-flow.js +10 -9
  123. package/dist/providers/core/strategies/oauth-auth-code-flow.js.map +1 -1
  124. package/dist/providers/core/strategies/oauth-device-flow.js +10 -9
  125. package/dist/providers/core/strategies/oauth-device-flow.js.map +1 -1
  126. package/dist/providers/core/utils/provider-error-reporter.js +63 -15
  127. package/dist/providers/core/utils/provider-error-reporter.js.map +1 -1
  128. package/dist/providers/core/utils/provider-type-utils.d.ts +1 -1
  129. package/dist/providers/core/utils/provider-type-utils.js +6 -1
  130. package/dist/providers/core/utils/provider-type-utils.js.map +1 -1
  131. package/dist/providers/core/utils/snapshot-writer.d.ts +10 -0
  132. package/dist/providers/core/utils/snapshot-writer.js +85 -0
  133. package/dist/providers/core/utils/snapshot-writer.js.map +1 -1
  134. package/dist/providers/mock/mock-provider-runtime.js +44 -0
  135. package/dist/providers/mock/mock-provider-runtime.js.map +1 -1
  136. package/dist/providers/profile/provider-profile-loader.js +26 -19
  137. package/dist/providers/profile/provider-profile-loader.js.map +1 -1
  138. package/dist/providers/profile/provider-profile.d.ts +2 -2
  139. package/dist/server/handlers/chat-handler.js +9 -3
  140. package/dist/server/handlers/chat-handler.js.map +1 -1
  141. package/dist/server/handlers/handler-utils.d.ts +7 -1
  142. package/dist/server/handlers/handler-utils.js +64 -52
  143. package/dist/server/handlers/handler-utils.js.map +1 -1
  144. package/dist/server/handlers/messages-handler.js +9 -3
  145. package/dist/server/handlers/messages-handler.js.map +1 -1
  146. package/dist/server/handlers/responses-handler.js +21 -13
  147. package/dist/server/handlers/responses-handler.js.map +1 -1
  148. package/dist/server/runtime/http-server/colored-logger.d.ts +1 -0
  149. package/dist/server/runtime/http-server/colored-logger.js +33 -0
  150. package/dist/server/runtime/http-server/colored-logger.js.map +1 -0
  151. package/dist/server/runtime/http-server/index.d.ts +3 -0
  152. package/dist/server/runtime/http-server/index.js +76 -19
  153. package/dist/server/runtime/http-server/index.js.map +1 -1
  154. package/dist/server/runtime/http-server/provider-utils.d.ts +3 -1
  155. package/dist/server/runtime/http-server/provider-utils.js +12 -2
  156. package/dist/server/runtime/http-server/provider-utils.js.map +1 -1
  157. package/dist/server/runtime/http-server/request-executor.js +6 -2
  158. package/dist/server/runtime/http-server/request-executor.js.map +1 -1
  159. package/dist/server/runtime/http-server/routes.js +31 -11
  160. package/dist/server/runtime/http-server/routes.js.map +1 -1
  161. package/dist/server/runtime/http-server/types.d.ts +2 -1
  162. package/dist/utils/error-center-payload.d.ts +7 -0
  163. package/dist/utils/error-center-payload.js +67 -0
  164. package/dist/utils/error-center-payload.js.map +1 -0
  165. package/dist/utils/error-handler-registry.d.ts +7 -0
  166. package/dist/utils/error-handler-registry.js +44 -12
  167. package/dist/utils/error-handler-registry.js.map +1 -1
  168. package/node_modules/@jsonstudio/llms/dist/conversion/codecs/responses-openai-codec.js +16 -1
  169. package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-glm.json +17 -0
  170. package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-iflow.json +36 -0
  171. package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-lmstudio.json +37 -0
  172. package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-qwen.json +18 -0
  173. package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/responses-c4m.json +45 -0
  174. package/node_modules/@jsonstudio/llms/dist/conversion/config/compat-profiles.json +38 -0
  175. package/node_modules/@jsonstudio/llms/dist/conversion/config/sample-config.json +314 -0
  176. package/node_modules/@jsonstudio/llms/dist/conversion/config/version-switch.json +150 -0
  177. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-engine.d.ts +4 -0
  178. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-engine.js +667 -0
  179. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-profile-store.d.ts +2 -0
  180. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-profile-store.js +76 -0
  181. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-types.d.ts +62 -0
  182. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-types.js +1 -0
  183. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/hub-pipeline.d.ts +2 -0
  184. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/hub-pipeline.js +110 -29
  185. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage3_compat/index.d.ts +14 -0
  186. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage3_compat/index.js +23 -0
  187. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/stages/resp_outbound/resp_outbound_stage1_client_remap/index.js +34 -0
  188. package/node_modules/@jsonstudio/llms/dist/conversion/hub/process/chat-process.js +4 -1
  189. package/node_modules/@jsonstudio/llms/dist/conversion/hub/response/provider-response.js +26 -0
  190. package/node_modules/@jsonstudio/llms/dist/conversion/responses/responses-openai-bridge.d.ts +1 -0
  191. package/node_modules/@jsonstudio/llms/dist/conversion/responses/responses-openai-bridge.js +71 -0
  192. package/node_modules/@jsonstudio/llms/dist/conversion/shared/responses-conversation-store.d.ts +35 -0
  193. package/node_modules/@jsonstudio/llms/dist/conversion/shared/responses-conversation-store.js +64 -19
  194. package/node_modules/@jsonstudio/llms/dist/conversion/shared/tool-filter-pipeline.d.ts +21 -0
  195. package/node_modules/@jsonstudio/llms/dist/conversion/shared/tool-filter-pipeline.js +138 -22
  196. package/node_modules/@jsonstudio/llms/dist/conversion/shared/tool-governor.d.ts +21 -0
  197. package/node_modules/@jsonstudio/llms/dist/conversion/shared/tool-governor.js +116 -1
  198. package/node_modules/@jsonstudio/llms/dist/conversion/shared/tool-mapping.js +52 -2
  199. package/node_modules/@jsonstudio/llms/dist/filters/config/openai-openai.fieldmap.json +18 -0
  200. package/node_modules/@jsonstudio/llms/dist/filters/special/request-tools-normalize.js +20 -1
  201. package/node_modules/@jsonstudio/llms/dist/guidance/index.js +6 -2
  202. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/bootstrap.js +16 -7
  203. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/classifier.js +40 -37
  204. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/default-thinking-keywords.d.ts +1 -0
  205. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/default-thinking-keywords.js +13 -0
  206. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/engine.d.ts +39 -0
  207. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/engine.js +52 -11
  208. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/features.js +340 -11
  209. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/token-counter.d.ts +2 -0
  210. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/token-counter.js +105 -0
  211. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/types.d.ts +8 -0
  212. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/types.js +2 -2
  213. package/node_modules/@jsonstudio/llms/dist/sse/sse-to-json/builders/response-builder.d.ts +2 -0
  214. package/node_modules/@jsonstudio/llms/dist/sse/sse-to-json/builders/response-builder.js +53 -11
  215. package/node_modules/@jsonstudio/llms/dist/test-output/virtual-router/results.json +1 -0
  216. package/node_modules/@jsonstudio/llms/dist/test-output/virtual-router/summary.json +12 -0
  217. package/node_modules/@jsonstudio/llms/dist/tools/tool-registry.js +4 -3
  218. package/node_modules/@jsonstudio/llms/package.json +3 -3
  219. package/package.json +11 -9
  220. package/scripts/analyze-routing-classifier.mjs +166 -0
  221. package/scripts/analyze-routing-samples.mjs +216 -0
  222. package/scripts/analyze-thinking-keywords.mjs +17 -2
  223. package/scripts/build-core.mjs +8 -0
  224. package/scripts/classify-sample-tools.mjs +252 -0
  225. package/scripts/ensure-llmswitch-mode.mjs +95 -0
  226. package/scripts/gen-build-info.mjs +58 -4
  227. package/scripts/install-global.sh +1 -1
  228. package/scripts/install-release.sh +7 -0
  229. package/scripts/mock-provider/run-regressions.mjs +60 -14
  230. package/scripts/tests/apply-patch-loop.mjs +100 -9
  231. package/scripts/tests/golden-provider-cycle.mjs +12 -1
  232. package/scripts/tests/responses-provider-dry-run.mjs +15 -1
  233. package/scripts/tests/virtual-router-health.mjs +12 -5
  234. package/scripts/tools/capture-provider-goldens.mjs +75 -25
  235. package/scripts/tools/responses-golden-dry-run.mjs +17 -1
  236. package/scripts/tools/responses-provider-replay.mjs +17 -1
  237. package/scripts/tools/sync-ci-goldens.mjs +131 -0
  238. package/scripts/verification/samples/openai-chat-list-local-files.json +19 -796
  239. package/scripts/verify-e2e-toolcall.mjs +52 -0
  240. package/dist/providers/compat/config/index.d.ts +0 -1
  241. package/dist/providers/compat/config/index.js +0 -5
  242. package/dist/providers/compat/config/index.js.map +0 -1
  243. package/dist/providers/compat/iflow/index.d.ts +0 -27
  244. package/dist/providers/compat/iflow/index.js +0 -32
  245. package/dist/providers/compat/iflow/index.js.map +0 -1
  246. package/dist/providers/compat/lmstudio/index.d.ts +0 -4
  247. package/dist/providers/compat/lmstudio/index.js +0 -10
  248. package/dist/providers/compat/lmstudio/index.js.map +0 -1
  249. package/dist/providers/compat/passthrough/index.d.ts +0 -4
  250. package/dist/providers/compat/passthrough/index.js +0 -9
  251. package/dist/providers/compat/passthrough/index.js.map +0 -1
  252. package/dist/providers/compat/responses/index.d.ts +0 -1
  253. package/dist/providers/compat/responses/index.js +0 -8
  254. package/dist/providers/compat/responses/index.js.map +0 -1
  255. package/dist/providers/core/composite/compat/anthropic.d.ts +0 -3
  256. package/dist/providers/core/composite/compat/anthropic.js +0 -7
  257. package/dist/providers/core/composite/compat/anthropic.js.map +0 -1
  258. package/dist/providers/core/composite/compat/gemini.d.ts +0 -3
  259. package/dist/providers/core/composite/compat/gemini.js +0 -7
  260. package/dist/providers/core/composite/compat/gemini.js.map +0 -1
  261. package/dist/providers/core/composite/compat/openai-compat-aggregator.d.ts +0 -9
  262. package/dist/providers/core/composite/compat/openai-compat-aggregator.js +0 -135
  263. package/dist/providers/core/composite/compat/openai-compat-aggregator.js.map +0 -1
  264. package/dist/providers/core/composite/compat/responses.d.ts +0 -3
  265. package/dist/providers/core/composite/compat/responses.js +0 -91
  266. package/dist/providers/core/composite/compat/responses.js.map +0 -1
  267. package/dist/providers/core/composite/provider-composite.d.ts +0 -50
  268. package/dist/providers/core/composite/provider-composite.js +0 -235
  269. package/dist/providers/core/composite/provider-composite.js.map +0 -1
  270. package/scripts/tests/apply-patch-loop.mjs.bak +0 -363
@@ -0,0 +1,45 @@
1
+ {
2
+ "id": "responses:c4m",
3
+ "protocol": "openai-responses",
4
+ "request": {
5
+ "mappings": [
6
+ {
7
+ "action": "remove",
8
+ "path": "max_tokens"
9
+ },
10
+ {
11
+ "action": "remove",
12
+ "path": "maxTokens"
13
+ },
14
+ {
15
+ "action": "remove",
16
+ "path": "max_output_tokens"
17
+ },
18
+ {
19
+ "action": "remove",
20
+ "path": "maxOutputTokens"
21
+ },
22
+ {
23
+ "action": "inject_instruction",
24
+ "sourcePath": "instructions",
25
+ "targetPath": "input",
26
+ "role": "system",
27
+ "contentType": "input_text",
28
+ "stripHtml": true,
29
+ "maxLengthEnv": [
30
+ "ROUTECODEX_C4M_INSTRUCTIONS_MAX",
31
+ "RCC_C4M_INSTRUCTIONS_MAX",
32
+ "ROUTECODEX_COMPAT_INSTRUCTIONS_MAX"
33
+ ]
34
+ }
35
+ ]
36
+ },
37
+ "response": {
38
+ "filters": [
39
+ {
40
+ "action": "rate_limit_text",
41
+ "needle": "The Codex-For.ME service is available, but you have reached the request limit"
42
+ }
43
+ ]
44
+ }
45
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "version": "1.0.0",
3
+ "profiles": {
4
+ "chat:iflow": {
5
+ "protocol": "openai-chat",
6
+ "direction": "request",
7
+ "mappings": [
8
+ {
9
+ "action": "remove",
10
+ "path": "messages[*].content[*].annotations"
11
+ }
12
+ ],
13
+ "filters": []
14
+ },
15
+ "chat:glm": {
16
+ "protocol": "openai-chat",
17
+ "direction": "request",
18
+ "mappings": [
19
+ {
20
+ "action": "rename",
21
+ "from": "response_format",
22
+ "to": "extra.response_format"
23
+ }
24
+ ],
25
+ "filters": []
26
+ },
27
+ "responses:c4m": {
28
+ "protocol": "openai-responses",
29
+ "direction": "response",
30
+ "filters": [
31
+ {
32
+ "action": "rate_limit_text",
33
+ "needle": "The Codex-For.ME service is available, but you have reached the request limit"
34
+ }
35
+ ]
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,314 @@
1
+ {
2
+ "version": "1.0.0",
3
+ "description": "LLM Switch Conversion 配置文件",
4
+ "lastModified": "2024-11-13T00:00:00.000Z",
5
+ "httpserver": {
6
+ "port": 5520,
7
+ "host": "0.0.0.0",
8
+ "timeout": 30000,
9
+ "cors": {
10
+ "enabled": true,
11
+ "origin": "*",
12
+ "methods": ["GET", "POST", "PUT", "DELETE", "OPTIONS"]
13
+ }
14
+ },
15
+ "virtualrouter": {
16
+ "inputProtocol": "openai",
17
+ "outputProtocol": "openai",
18
+ "providers": {
19
+ "chat-provider-1": {
20
+ "id": "chat-provider-1",
21
+ "enabled": true,
22
+ "type": "openai",
23
+ "name": "Generic Chat Provider",
24
+ "description": "Example chat-completions provider",
25
+ "baseUrl": "https://api.example.com/chat",
26
+ "apiVersion": "v1",
27
+ "compatibility": {
28
+ "type": "openai",
29
+ "features": ["streaming", "function-calling"]
30
+ },
31
+ "models": {
32
+ "chat-model-a": {
33
+ "displayName": "Chat-Model-A",
34
+ "description": "Latest chat model with improved reasoning",
35
+ "supportsStreaming": true,
36
+ "maxTokens": 128000,
37
+ "contextWindow": 128000,
38
+ "capabilities": ["text", "code", "reasoning", "tool-use"],
39
+ "pricing": {
40
+ "input": "0.001",
41
+ "output": "0.002",
42
+ "currency": "CNY"
43
+ },
44
+ "compatibility": {
45
+ "type": "openai",
46
+ "moduleConfig": {
47
+ "policy": {
48
+ "preflight": true
49
+ }
50
+ }
51
+ }
52
+ },
53
+ "chat-model-b": {
54
+ "displayName": "Chat-Model-B",
55
+ "description": "Lightweight chat model for faster responses",
56
+ "supportsStreaming": true,
57
+ "maxTokens": 8192,
58
+ "contextWindow": 8192,
59
+ "capabilities": ["text", "code", "basic-tool-use"],
60
+ "pricing": {
61
+ "input": "0.0005",
62
+ "output": "0.001",
63
+ "currency": "CNY"
64
+ },
65
+ "compatibility": {
66
+ "type": "openai",
67
+ "moduleConfig": {
68
+ "policy": {
69
+ "preflight": false
70
+ }
71
+ }
72
+ }
73
+ },
74
+ "chat-model-c": {
75
+ "displayName": "Chat-Model-C",
76
+ "description": "Ultra-fast chat model for quick responses",
77
+ "supportsStreaming": false,
78
+ "maxTokens": 4096,
79
+ "contextWindow": 4096,
80
+ "capabilities": ["text", "code"],
81
+ "pricing": {
82
+ "input": "0.0002",
83
+ "output": "0.0004",
84
+ "currency": "CNY"
85
+ },
86
+ "compatibility": {
87
+ "type": "openai",
88
+ "moduleConfig": {
89
+ "policy": {
90
+ "preflight": false
91
+ }
92
+ }
93
+ }
94
+ }
95
+ },
96
+ "apiKey": [
97
+ "your-api-key-here"
98
+ ],
99
+ "auth": {
100
+ "type": "apikey",
101
+ "apiKey": "your-api-key-here"
102
+ },
103
+ "rateLimit": {
104
+ "requestsPerMinute": 60,
105
+ "tokensPerMinute": 6000,
106
+ "concurrent": 5
107
+ },
108
+ "healthCheck": {
109
+ "enabled": true,
110
+ "endpoint": "/health",
111
+ "interval": 30000
112
+ }
113
+ },
114
+ "openai": {
115
+ "id": "openai",
116
+ "enabled": false,
117
+ "type": "openai",
118
+ "name": "OpenAI Provider",
119
+ "description": "Official OpenAI provider",
120
+ "baseUrl": "https://api.openai.com/v1",
121
+ "apiVersion": "v1",
122
+ "models": {
123
+ "gpt-4": {
124
+ "displayName": "GPT-4",
125
+ "supportsStreaming": true,
126
+ "maxTokens": 8192,
127
+ "contextWindow": 8192
128
+ },
129
+ "gpt-4-turbo": {
130
+ "displayName": "GPT-4 Turbo",
131
+ "supportsStreaming": true,
132
+ "maxTokens": 4096,
133
+ "contextWindow": 4096
134
+ },
135
+ "gpt-3.5-turbo": {
136
+ "displayName": "GPT-3.5 Turbo",
137
+ "supportsStreaming": true,
138
+ "maxTokens": 4096,
139
+ "contextWindow": 16384
140
+ }
141
+ },
142
+ "apiKey": [],
143
+ "auth": {
144
+ "type": "apikey"
145
+ },
146
+ "rateLimit": {
147
+ "requestsPerMinute": 3500,
148
+ "tokensPerMinute": 90000,
149
+ "concurrent": 100
150
+ }
151
+ },
152
+ "anthropic": {
153
+ "id": "anthropic",
154
+ "enabled": false,
155
+ "type": "anthropic",
156
+ "name": "Anthropic Claude Provider",
157
+ "description": "Anthropic Claude provider",
158
+ "baseUrl": "https://api.anthropic.com",
159
+ "apiVersion": "2023-06-01",
160
+ "models": {
161
+ "claude-3-sonnet": {
162
+ "displayName": "Claude 3 Sonnet",
163
+ "supportsStreaming": true,
164
+ "maxTokens": 200000,
165
+ "contextWindow": 200000
166
+ },
167
+ "claude-3-haiku": {
168
+ "displayName": "Claude 3 Haiku",
169
+ "supportsStreaming": false,
170
+ "maxTokens": 200000,
171
+ "contextWindow": 200000
172
+ }
173
+ },
174
+ "apiKey": [],
175
+ "auth": {
176
+ "type": "apikey"
177
+ },
178
+ "rateLimit": {
179
+ "requestsPerMinute": 1000,
180
+ "tokensPerMinute": 40000,
181
+ "concurrent": 5
182
+ }
183
+ }
184
+ },
185
+ "routing": {
186
+ "default": ["chat-provider-1.chat-model-a"],
187
+ "coding": ["chat-provider-1.chat-model-a"],
188
+ "longcontext": ["chat-provider-1.chat-model-a"],
189
+ "thinking": ["chat-provider-1.chat-model-a", "chat-model-b"],
190
+ "fast": ["chat-model-c"],
191
+ "vision": [],
192
+ "websearch": [],
193
+ "background": [],
194
+ "fallback": ["chat-provider-1.chat-model-b"]
195
+ },
196
+ "rules": {
197
+ "inputValidation": {
198
+ "enabled": true,
199
+ "strict": false,
200
+ "maxMessageLength": 100000,
201
+ "maxToolCount": 50
202
+ },
203
+ "outputValidation": {
204
+ "enabled": true,
205
+ "strict": false,
206
+ "maxResponseLength": 100000
207
+ },
208
+ "contentFiltering": {
209
+ "enabled": true,
210
+ "blockedWords": [],
211
+ "blockedPatterns": []
212
+ },
213
+ "rateLimiting": {
214
+ "enabled": true,
215
+ "perUser": {
216
+ "requestsPerMinute": 10,
217
+ "tokensPerMinute": 1000
218
+ },
219
+ "perProvider": {
220
+ "chat-provider-1": { "requestsPerMinute": 60, "tokensPerMinute": 6000 },
221
+ "openai": { "requestsPerMinute": 3500, "tokensPerMinute": 90000 },
222
+ "anthropic": { "requestsPerMinute": 1000, "tokensPerMinute": 40000 }
223
+ }
224
+ }
225
+ }
226
+ },
227
+ "serverTools": {
228
+ "replace": {
229
+ "web_fetch": {
230
+ "enabled": true,
231
+ "timeout": 30000,
232
+ "maxResponseSize": 1000000,
233
+ "allowedDomains": ["*"],
234
+ "blockedDomains": []
235
+ }
236
+ },
237
+ "custom": {
238
+ "enabled": false,
239
+ "tools": []
240
+ },
241
+ "enabled": true
242
+ },
243
+ "monitoring": {
244
+ "enabled": true,
245
+ "metrics": {
246
+ "requestCount": true,
247
+ "responseTime": true,
248
+ "errorRate": true,
249
+ "tokenUsage": true,
250
+ "providerPerformance": true
251
+ },
252
+ "logging": {
253
+ "level": "info",
254
+ "maxFileSize": "10MB",
255
+ "rotate": true,
256
+ "keepFiles": 7
257
+ },
258
+ "alerts": {
259
+ "errorRateThreshold": 0.05,
260
+ "responseTimeThreshold": 5000,
261
+ "tokenUsageThreshold": 10000
262
+ }
263
+ },
264
+ "conversion": {
265
+ "defaultVersion": "v2",
266
+ "passthrough": {
267
+ "enabled": true,
268
+ "criteria": {
269
+ "sameProtocol": true,
270
+ "sameProvider": true,
271
+ "minimalProcessing": true
272
+ }
273
+ },
274
+ "optimization": {
275
+ "enabled": true,
276
+ "caching": {
277
+ "enabled": true,
278
+ "maxSize": "100MB",
279
+ "ttl": 300000
280
+ },
281
+ "batching": {
282
+ "enabled": true,
283
+ "maxBatchSize": 10,
284
+ "maxBatchWaitTime": 100
285
+ }
286
+ }
287
+ },
288
+ "security": {
289
+ "apiKeyEncryption": {
290
+ "enabled": true,
291
+ "algorithm": "AES-256-GCM"
292
+ },
293
+ "requestValidation": {
294
+ "enabled": true,
295
+ "maxRequestSize": "10MB",
296
+ "allowedOrigins": ["*"],
297
+ "rateLimit": {
298
+ "enabled": true,
299
+ "requestsPerMinute": 1000,
300
+ "tokensPerMinute": 50000
301
+ }
302
+ },
303
+ "contentFiltering": {
304
+ "enabled": false,
305
+ "blockedContent": {
306
+ "profanity": false,
307
+ "personalData": false,
308
+ "malware": true,
309
+ "spam": true
310
+ },
311
+ "customFilters": []
312
+ }
313
+ }
314
+ }
@@ -0,0 +1,150 @@
1
+ {
2
+ "defaultVersion": "v2",
3
+ "envVarName": "LLMSWITCH_CONVERTER_VERSION",
4
+ "allowRuntimeSwitch": true,
5
+ "versionPriority": {
6
+ "v2": 1,
7
+ "v3": 2,
8
+ "auto": 0
9
+ },
10
+ "versionSettings": {
11
+ "v2": {
12
+ "description": "Legacy conversion-core implementation",
13
+ "stability": "stable",
14
+ "features": [
15
+ "proven_stability",
16
+ "comprehensive_coverage",
17
+ "extensive_testing"
18
+ ],
19
+ "performance": "baseline",
20
+ "recommendedFor": [
21
+ "production",
22
+ "legacy_compatibility",
23
+ "maximum_stability"
24
+ ]
25
+ },
26
+ "v3": {
27
+ "description": "New node-based pipeline architecture",
28
+ "stability": "beta",
29
+ "features": [
30
+ "intelligent_passthrough",
31
+ "node_based_processing",
32
+ "automatic_optimization",
33
+ "zero_config"
34
+ ],
35
+ "performance": "optimized",
36
+ "recommendedFor": [
37
+ "development",
38
+ "performance_critical",
39
+ "new_features"
40
+ ]
41
+ },
42
+ "auto": {
43
+ "description": "Automatically select best version based on request",
44
+ "stability": "dynamic",
45
+ "features": [
46
+ "smart_selection",
47
+ "performance_optimization",
48
+ "adaptive_behavior"
49
+ ],
50
+ "performance": "variable",
51
+ "recommendedFor": [
52
+ "testing",
53
+ "benchmarking",
54
+ "a_b_testing"
55
+ ]
56
+ }
57
+ },
58
+ "switchingRules": {
59
+ "autoSelection": {
60
+ "simpleRequests": {
61
+ "conditions": {
62
+ "messageCount": "<= 5",
63
+ "toolCount": 0,
64
+ "streaming": false
65
+ },
66
+ "preferredVersion": "v3",
67
+ "reason": "Simple requests benefit from v3 passthrough optimization"
68
+ },
69
+ "complexRequests": {
70
+ "conditions": {
71
+ "messageCount": "> 20",
72
+ "toolCount": "> 10",
73
+ "hasStreaming": true
74
+ },
75
+ "preferredVersion": "v2",
76
+ "reason": "Complex requests benefit from v2 stability"
77
+ },
78
+ "toolHeavyRequests": {
79
+ "conditions": {
80
+ "toolCount": "> 5",
81
+ "hasComplexTools": true
82
+ },
83
+ "preferredVersion": "v3",
84
+ "reason": "V3 has better tool processing architecture"
85
+ }
86
+ },
87
+ "fallbackRules": {
88
+ "v3FallbackToV2": {
89
+ "conditions": [
90
+ "conversion_error",
91
+ "timeout",
92
+ "unsupported_endpoint"
93
+ ],
94
+ "retryCount": 3
95
+ },
96
+ "v2FallbackToV3": {
97
+ "conditions": [
98
+ "performance_degradation",
99
+ "memory_pressure"
100
+ ],
101
+ "retryCount": 1
102
+ }
103
+ }
104
+ },
105
+ "monitoring": {
106
+ "enabled": true,
107
+ "metrics": [
108
+ "conversion_success_rate",
109
+ "average_latency",
110
+ "passthrough_rate",
111
+ "error_rate_by_version",
112
+ "performance_comparison"
113
+ ],
114
+ "alertThresholds": {
115
+ "errorRate": 0.05,
116
+ "latencyIncrease": 2.0,
117
+ "successRateDrop": 0.1
118
+ }
119
+ },
120
+ "hooks": {
121
+ "beforeSwitch": {
122
+ "logLevel": "info",
123
+ "metrics": true
124
+ },
125
+ "afterSwitch": {
126
+ "logLevel": "info",
127
+ "metrics": true,
128
+ "validate": true
129
+ },
130
+ "onError": {
131
+ "logLevel": "error",
132
+ "metrics": true,
133
+ "escalate": true
134
+ }
135
+ },
136
+ "testing": {
137
+ "enabled": false,
138
+ "canaryDeployment": {
139
+ "percentage": 0.1,
140
+ "version": "v3"
141
+ },
142
+ "abTesting": {
143
+ "enabled": false,
144
+ "split": {
145
+ "v2": 0.5,
146
+ "v3": 0.5
147
+ }
148
+ }
149
+ }
150
+ }
@@ -0,0 +1,4 @@
1
+ import type { JsonObject } from '../../types/json.js';
2
+ import type { CompatApplicationResult } from './compat-types.js';
3
+ export declare function applyRequestCompat(profileId: string | undefined, payload: JsonObject): CompatApplicationResult;
4
+ export declare function applyResponseCompat(profileId: string | undefined, payload: JsonObject): CompatApplicationResult;