@jsonstudio/rcc 0.89.164 → 0.89.333

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 +18 -15
  2. package/dist/build-info.js +3 -3
  3. package/dist/build-info.js.map +1 -1
  4. package/dist/cli.js +32 -0
  5. package/dist/cli.js.map +1 -1
  6. package/dist/client/gemini-cli/gemini-cli-protocol-client.js +28 -5
  7. package/dist/client/gemini-cli/gemini-cli-protocol-client.js.map +1 -1
  8. package/dist/error-handling/quiet-error-handling-center.d.ts +9 -0
  9. package/dist/error-handling/quiet-error-handling-center.js +141 -0
  10. package/dist/error-handling/quiet-error-handling-center.js.map +1 -0
  11. package/dist/error-handling/route-error-hub.js +8 -2
  12. package/dist/error-handling/route-error-hub.js.map +1 -1
  13. package/dist/modules/pipeline/utils/colored-logger.d.ts +2 -0
  14. package/dist/modules/pipeline/utils/colored-logger.js +20 -3
  15. package/dist/modules/pipeline/utils/colored-logger.js.map +1 -1
  16. package/dist/providers/auth/antigravity-userinfo-helper.d.ts +10 -0
  17. package/dist/providers/auth/antigravity-userinfo-helper.js +140 -0
  18. package/dist/providers/auth/antigravity-userinfo-helper.js.map +1 -0
  19. package/dist/providers/auth/oauth-lifecycle.js +140 -8
  20. package/dist/providers/auth/oauth-lifecycle.js.map +1 -1
  21. package/dist/providers/auth/token-scanner/index.d.ts +32 -0
  22. package/dist/providers/auth/token-scanner/index.js +86 -0
  23. package/dist/providers/auth/token-scanner/index.js.map +1 -0
  24. package/dist/providers/auth/tokenfile-auth.d.ts +17 -0
  25. package/dist/providers/auth/tokenfile-auth.js +27 -5
  26. package/dist/providers/auth/tokenfile-auth.js.map +1 -1
  27. package/dist/providers/core/api/provider-types.d.ts +10 -0
  28. package/dist/providers/core/config/oauth-flows.d.ts +2 -0
  29. package/dist/providers/core/config/oauth-flows.js.map +1 -1
  30. package/dist/providers/core/config/provider-oauth-configs.js +85 -0
  31. package/dist/providers/core/config/provider-oauth-configs.js.map +1 -1
  32. package/dist/providers/core/config/service-profiles.js +15 -1
  33. package/dist/providers/core/config/service-profiles.js.map +1 -1
  34. package/dist/providers/core/runtime/base-provider.d.ts +8 -1
  35. package/dist/providers/core/runtime/base-provider.js +176 -108
  36. package/dist/providers/core/runtime/base-provider.js.map +1 -1
  37. package/dist/providers/core/runtime/gemini-cli-http-provider.d.ts +9 -5
  38. package/dist/providers/core/runtime/gemini-cli-http-provider.js +271 -69
  39. package/dist/providers/core/runtime/gemini-cli-http-provider.js.map +1 -1
  40. package/dist/providers/core/runtime/gemini-http-provider.d.ts +1 -2
  41. package/dist/providers/core/runtime/gemini-http-provider.js +0 -12
  42. package/dist/providers/core/runtime/gemini-http-provider.js.map +1 -1
  43. package/dist/providers/core/runtime/http-request-executor.d.ts +42 -0
  44. package/dist/providers/core/runtime/http-request-executor.js +133 -0
  45. package/dist/providers/core/runtime/http-request-executor.js.map +1 -0
  46. package/dist/providers/core/runtime/http-transport-provider.d.ts +32 -12
  47. package/dist/providers/core/runtime/http-transport-provider.js +464 -426
  48. package/dist/providers/core/runtime/http-transport-provider.js.map +1 -1
  49. package/dist/providers/core/runtime/provider-error-classifier.d.ts +25 -0
  50. package/dist/providers/core/runtime/provider-error-classifier.js +149 -0
  51. package/dist/providers/core/runtime/provider-error-classifier.js.map +1 -0
  52. package/dist/providers/core/runtime/provider-error-types.d.ts +23 -0
  53. package/dist/providers/core/runtime/provider-error-types.js +2 -0
  54. package/dist/providers/core/runtime/provider-error-types.js.map +1 -0
  55. package/dist/providers/core/runtime/provider-factory.d.ts +1 -0
  56. package/dist/providers/core/runtime/provider-factory.js +43 -8
  57. package/dist/providers/core/runtime/provider-factory.js.map +1 -1
  58. package/dist/providers/core/runtime/responses-provider.d.ts +3 -3
  59. package/dist/providers/core/runtime/responses-provider.js +48 -114
  60. package/dist/providers/core/runtime/responses-provider.js.map +1 -1
  61. package/dist/providers/core/strategies/oauth-auth-code-flow.js +11 -3
  62. package/dist/providers/core/strategies/oauth-auth-code-flow.js.map +1 -1
  63. package/dist/providers/core/utils/http-client.d.ts +5 -0
  64. package/dist/providers/core/utils/http-client.js +29 -3
  65. package/dist/providers/core/utils/http-client.js.map +1 -1
  66. package/dist/providers/core/utils/provider-error-reporter.js +8 -2
  67. package/dist/providers/core/utils/provider-error-reporter.js.map +1 -1
  68. package/dist/providers/core/utils/snapshot-writer.js +5 -1
  69. package/dist/providers/core/utils/snapshot-writer.js.map +1 -1
  70. package/dist/providers/profile/provider-profile-loader.js +8 -4
  71. package/dist/providers/profile/provider-profile-loader.js.map +1 -1
  72. package/dist/runtime/runtime-flags.d.ts +4 -0
  73. package/dist/runtime/runtime-flags.js +32 -0
  74. package/dist/runtime/runtime-flags.js.map +1 -0
  75. package/dist/server/handlers/handler-utils.js +29 -2
  76. package/dist/server/handlers/handler-utils.js.map +1 -1
  77. package/dist/server/handlers/messages-handler.js +27 -26
  78. package/dist/server/handlers/messages-handler.js.map +1 -1
  79. package/dist/server/handlers/responses-handler.js +35 -1
  80. package/dist/server/handlers/responses-handler.js.map +1 -1
  81. package/dist/server/runtime/http-server/index.d.ts +1 -0
  82. package/dist/server/runtime/http-server/index.js +39 -4
  83. package/dist/server/runtime/http-server/index.js.map +1 -1
  84. package/dist/server/runtime/http-server/request-executor.d.ts +4 -0
  85. package/dist/server/runtime/http-server/request-executor.js +99 -4
  86. package/dist/server/runtime/http-server/request-executor.js.map +1 -1
  87. package/dist/server/utils/sse-request-parser.d.ts +1 -0
  88. package/dist/server/utils/sse-request-parser.js +17 -6
  89. package/dist/server/utils/sse-request-parser.js.map +1 -1
  90. package/dist/server/utils/warmup-detector.d.ts +7 -0
  91. package/dist/server/utils/warmup-detector.js +125 -0
  92. package/dist/server/utils/warmup-detector.js.map +1 -0
  93. package/dist/server/utils/warmup-storm-tracker.d.ts +9 -0
  94. package/dist/server/utils/warmup-storm-tracker.js +61 -0
  95. package/dist/server/utils/warmup-storm-tracker.js.map +1 -0
  96. package/dist/utils/debug-utils.js +14 -0
  97. package/dist/utils/debug-utils.js.map +1 -1
  98. package/dist/utils/error-handler-registry.js +6 -5
  99. package/dist/utils/error-handler-registry.js.map +1 -1
  100. package/dist/utils/error-handling-utils.js +4 -3
  101. package/dist/utils/error-handling-utils.js.map +1 -1
  102. package/dist/utils/log-helpers.d.ts +6 -0
  103. package/dist/utils/log-helpers.js +90 -0
  104. package/dist/utils/log-helpers.js.map +1 -0
  105. package/dist/utils/logger.d.ts +8 -0
  106. package/dist/utils/logger.js +55 -2
  107. package/dist/utils/logger.js.map +1 -1
  108. package/dist/utils/snapshot-writer.js +2 -6
  109. package/dist/utils/snapshot-writer.js.map +1 -1
  110. package/node_modules/@jsonstudio/llms/dist/conversion/codecs/gemini-openai-codec.js +15 -1
  111. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/auto-thinking.d.ts +6 -0
  112. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/auto-thinking.js +25 -0
  113. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/field-mapping.d.ts +14 -0
  114. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/field-mapping.js +155 -0
  115. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/glm-tool-extraction.d.ts +2 -0
  116. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/glm-tool-extraction.js +264 -0
  117. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/qwen-transform.d.ts +3 -0
  118. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/qwen-transform.js +209 -0
  119. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/request-rules.d.ts +24 -0
  120. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/request-rules.js +63 -0
  121. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-blacklist.d.ts +14 -0
  122. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-blacklist.js +85 -0
  123. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-normalize.d.ts +5 -0
  124. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-normalize.js +121 -0
  125. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-validate.d.ts +5 -0
  126. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-validate.js +76 -0
  127. package/{dist/providers/compat/utils/snapshot-writer.d.ts → node_modules/@jsonstudio/llms/dist/conversion/compat/actions/snapshot.d.ts} +2 -2
  128. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/snapshot.js +21 -0
  129. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/tool-schema.d.ts +6 -0
  130. package/{dist/providers/compat/glm/utils/tool-schema-helpers.js → node_modules/@jsonstudio/llms/dist/conversion/compat/actions/tool-schema.js} +6 -1
  131. package/{dist/providers/compat/filters → node_modules/@jsonstudio/llms/dist/conversion/compat/actions}/universal-shape-filter.d.ts +17 -22
  132. package/{dist/providers/compat/filters → node_modules/@jsonstudio/llms/dist/conversion/compat/actions}/universal-shape-filter.js +35 -99
  133. package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-glm.json +187 -13
  134. package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-iflow.json +177 -9
  135. package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-lmstudio.json +10 -2
  136. package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-qwen.json +14 -10
  137. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-engine.d.ts +7 -2
  138. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-engine.js +5 -665
  139. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.d.ts +9 -0
  140. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.js +845 -0
  141. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-types.d.ts +47 -0
  142. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/hub-pipeline.d.ts +2 -0
  143. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/hub-pipeline.js +35 -1
  144. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage3_compat/index.js +2 -2
  145. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/target-utils.js +3 -0
  146. package/node_modules/@jsonstudio/llms/dist/conversion/hub/response/response-runtime.js +19 -2
  147. package/node_modules/@jsonstudio/llms/dist/conversion/responses/responses-host-policy.d.ts +6 -0
  148. package/node_modules/@jsonstudio/llms/dist/conversion/responses/responses-host-policy.js +14 -0
  149. package/node_modules/@jsonstudio/llms/dist/conversion/responses/responses-openai-bridge.js +51 -2
  150. package/node_modules/@jsonstudio/llms/dist/conversion/shared/anthropic-message-utils.js +6 -0
  151. package/node_modules/@jsonstudio/llms/dist/conversion/shared/responses-reasoning-registry.d.ts +4 -0
  152. package/node_modules/@jsonstudio/llms/dist/conversion/shared/responses-reasoning-registry.js +62 -1
  153. package/node_modules/@jsonstudio/llms/dist/conversion/shared/responses-response-utils.js +23 -1
  154. package/node_modules/@jsonstudio/llms/dist/conversion/shared/tool-canonicalizer.d.ts +2 -0
  155. package/node_modules/@jsonstudio/llms/dist/conversion/shared/tool-filter-pipeline.js +11 -0
  156. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/bootstrap.js +251 -12
  157. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/classifier.js +11 -4
  158. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/context-advisor.d.ts +21 -0
  159. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/context-advisor.js +76 -0
  160. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/engine.d.ts +11 -0
  161. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/engine.js +187 -28
  162. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/features.js +22 -457
  163. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/health-manager.js +2 -7
  164. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/message-utils.d.ts +7 -0
  165. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/message-utils.js +66 -0
  166. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/provider-registry.js +6 -2
  167. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/token-estimator.d.ts +2 -0
  168. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/token-estimator.js +16 -0
  169. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/token-file-scanner.d.ts +15 -0
  170. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/token-file-scanner.js +56 -0
  171. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/tool-signals.d.ts +13 -0
  172. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/tool-signals.js +403 -0
  173. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/types.d.ts +21 -1
  174. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/types.js +1 -0
  175. package/node_modules/@jsonstudio/llms/package.json +2 -2
  176. package/package.json +13 -11
  177. package/scripts/README.md +26 -12
  178. package/scripts/auth-antigravity-token.mjs +64 -0
  179. package/scripts/auth-gemini-cli-token.mjs +96 -0
  180. package/scripts/auth-iflow-manual.mjs +81 -0
  181. package/scripts/auth-iflow-token-direct.mjs +87 -0
  182. package/scripts/auth-iflow-token.mjs +77 -0
  183. package/scripts/copy-compat-assets.mjs +3 -15
  184. package/scripts/install-verify.mjs +1 -0
  185. package/scripts/pack-mode.mjs +30 -1
  186. package/scripts/publish-rcc.mjs +31 -0
  187. package/scripts/replay-codex-sample.mjs +13 -8
  188. package/scripts/tests/chat-pipeline-blackbox.mjs +1 -1
  189. package/scripts/tools/capture-provider-goldens.mjs +8 -7
  190. package/scripts/verify-client-headers.mjs +224 -0
  191. package/dist/providers/compat/base-compatibility.d.ts +0 -27
  192. package/dist/providers/compat/base-compatibility.js +0 -143
  193. package/dist/providers/compat/base-compatibility.js.map +0 -1
  194. package/dist/providers/compat/compat-directory-loader.d.ts +0 -4
  195. package/dist/providers/compat/compat-directory-loader.js +0 -85
  196. package/dist/providers/compat/compat-directory-loader.js.map +0 -1
  197. package/dist/providers/compat/compatibility-adapter.d.ts +0 -18
  198. package/dist/providers/compat/compatibility-adapter.js +0 -104
  199. package/dist/providers/compat/compatibility-adapter.js.map +0 -1
  200. package/dist/providers/compat/compatibility-factory.d.ts +0 -57
  201. package/dist/providers/compat/compatibility-factory.js +0 -155
  202. package/dist/providers/compat/compatibility-factory.js.map +0 -1
  203. package/dist/providers/compat/compatibility-interface.d.ts +0 -35
  204. package/dist/providers/compat/compatibility-interface.js +0 -2
  205. package/dist/providers/compat/compatibility-interface.js.map +0 -1
  206. package/dist/providers/compat/compatibility-manager.d.ts +0 -85
  207. package/dist/providers/compat/compatibility-manager.js +0 -368
  208. package/dist/providers/compat/compatibility-manager.js.map +0 -1
  209. package/dist/providers/compat/config/config-compatibility.d.ts +0 -28
  210. package/dist/providers/compat/config/config-compatibility.js +0 -95
  211. package/dist/providers/compat/config/config-compatibility.js.map +0 -1
  212. package/dist/providers/compat/field-mapping.d.ts +0 -102
  213. package/dist/providers/compat/field-mapping.js +0 -447
  214. package/dist/providers/compat/field-mapping.js.map +0 -1
  215. package/dist/providers/compat/filters/blacklist-sanitizer.d.ts +0 -45
  216. package/dist/providers/compat/filters/blacklist-sanitizer.js +0 -133
  217. package/dist/providers/compat/filters/blacklist-sanitizer.js.map +0 -1
  218. package/dist/providers/compat/filters/response-blacklist-sanitizer.d.ts +0 -28
  219. package/dist/providers/compat/filters/response-blacklist-sanitizer.js +0 -138
  220. package/dist/providers/compat/filters/response-blacklist-sanitizer.js.map +0 -1
  221. package/dist/providers/compat/filters/universal-shape-filter.js.map +0 -1
  222. package/dist/providers/compat/glm/config/blacklist-rules.json +0 -22
  223. package/dist/providers/compat/glm/config/field-mappings.json +0 -92
  224. package/dist/providers/compat/glm/config/response-blacklist.json +0 -7
  225. package/dist/providers/compat/glm/config/shape-filters.json +0 -37
  226. package/dist/providers/compat/glm/field-mapping/field-mapping-processor.d.ts +0 -28
  227. package/dist/providers/compat/glm/field-mapping/field-mapping-processor.js +0 -306
  228. package/dist/providers/compat/glm/field-mapping/field-mapping-processor.js.map +0 -1
  229. package/dist/providers/compat/glm/functions/glm-processor.d.ts +0 -50
  230. package/dist/providers/compat/glm/functions/glm-processor.js +0 -134
  231. package/dist/providers/compat/glm/functions/glm-processor.js.map +0 -1
  232. package/dist/providers/compat/glm/glm-compatibility.d.ts +0 -34
  233. package/dist/providers/compat/glm/glm-compatibility.js +0 -117
  234. package/dist/providers/compat/glm/glm-compatibility.js.map +0 -1
  235. package/dist/providers/compat/glm/hooks/base-hook.d.ts +0 -21
  236. package/dist/providers/compat/glm/hooks/base-hook.js +0 -53
  237. package/dist/providers/compat/glm/hooks/base-hook.js.map +0 -1
  238. package/dist/providers/compat/glm/hooks/glm-request-validation-hook.d.ts +0 -24
  239. package/dist/providers/compat/glm/hooks/glm-request-validation-hook.js +0 -268
  240. package/dist/providers/compat/glm/hooks/glm-request-validation-hook.js.map +0 -1
  241. package/dist/providers/compat/glm/hooks/glm-response-normalization-hook.d.ts +0 -21
  242. package/dist/providers/compat/glm/hooks/glm-response-normalization-hook.js +0 -171
  243. package/dist/providers/compat/glm/hooks/glm-response-normalization-hook.js.map +0 -1
  244. package/dist/providers/compat/glm/hooks/glm-response-validation-hook.d.ts +0 -25
  245. package/dist/providers/compat/glm/hooks/glm-response-validation-hook.js +0 -236
  246. package/dist/providers/compat/glm/hooks/glm-response-validation-hook.js.map +0 -1
  247. package/dist/providers/compat/glm/hooks/glm-tool-cleaning-hook.d.ts +0 -26
  248. package/dist/providers/compat/glm/hooks/glm-tool-cleaning-hook.js +0 -186
  249. package/dist/providers/compat/glm/hooks/glm-tool-cleaning-hook.js.map +0 -1
  250. package/dist/providers/compat/glm/index.d.ts +0 -24
  251. package/dist/providers/compat/glm/index.js +0 -29
  252. package/dist/providers/compat/glm/index.js.map +0 -1
  253. package/dist/providers/compat/glm/utils/tool-schema-helpers.d.ts +0 -3
  254. package/dist/providers/compat/glm/utils/tool-schema-helpers.js.map +0 -1
  255. package/dist/providers/compat/iflow/config/field-mappings.json +0 -92
  256. package/dist/providers/compat/iflow/config/shape-filters.json +0 -37
  257. package/dist/providers/compat/iflow/field-mapping/iflow-field-mapping-processor.d.ts +0 -34
  258. package/dist/providers/compat/iflow/field-mapping/iflow-field-mapping-processor.js +0 -386
  259. package/dist/providers/compat/iflow/field-mapping/iflow-field-mapping-processor.js.map +0 -1
  260. package/dist/providers/compat/iflow/functions/iflow-processor.d.ts +0 -53
  261. package/dist/providers/compat/iflow/functions/iflow-processor.js +0 -215
  262. package/dist/providers/compat/iflow/functions/iflow-processor.js.map +0 -1
  263. package/dist/providers/compat/iflow/hooks/base-hook.d.ts +0 -23
  264. package/dist/providers/compat/iflow/hooks/base-hook.js +0 -59
  265. package/dist/providers/compat/iflow/hooks/base-hook.js.map +0 -1
  266. package/dist/providers/compat/iflow/hooks/iflow-request-validation-hook.d.ts +0 -23
  267. package/dist/providers/compat/iflow/hooks/iflow-request-validation-hook.js +0 -279
  268. package/dist/providers/compat/iflow/hooks/iflow-request-validation-hook.js.map +0 -1
  269. package/dist/providers/compat/iflow/hooks/iflow-response-normalization-hook.d.ts +0 -20
  270. package/dist/providers/compat/iflow/hooks/iflow-response-normalization-hook.js +0 -180
  271. package/dist/providers/compat/iflow/hooks/iflow-response-normalization-hook.js.map +0 -1
  272. package/dist/providers/compat/iflow/hooks/iflow-response-validation-hook.d.ts +0 -23
  273. package/dist/providers/compat/iflow/hooks/iflow-response-validation-hook.js +0 -232
  274. package/dist/providers/compat/iflow/hooks/iflow-response-validation-hook.js.map +0 -1
  275. package/dist/providers/compat/iflow/hooks/iflow-tool-cleaning-hook.d.ts +0 -25
  276. package/dist/providers/compat/iflow/hooks/iflow-tool-cleaning-hook.js +0 -216
  277. package/dist/providers/compat/iflow/hooks/iflow-tool-cleaning-hook.js.map +0 -1
  278. package/dist/providers/compat/iflow/iflow-compatibility.d.ts +0 -24
  279. package/dist/providers/compat/iflow/iflow-compatibility.js +0 -94
  280. package/dist/providers/compat/iflow/iflow-compatibility.js.map +0 -1
  281. package/dist/providers/compat/index.d.ts +0 -59
  282. package/dist/providers/compat/index.js +0 -83
  283. package/dist/providers/compat/index.js.map +0 -1
  284. package/dist/providers/compat/lmstudio-compatibility.d.ts +0 -44
  285. package/dist/providers/compat/lmstudio-compatibility.js +0 -193
  286. package/dist/providers/compat/lmstudio-compatibility.js.map +0 -1
  287. package/dist/providers/compat/passthrough-compatibility.d.ts +0 -29
  288. package/dist/providers/compat/passthrough-compatibility.js +0 -83
  289. package/dist/providers/compat/passthrough-compatibility.js.map +0 -1
  290. package/dist/providers/compat/profiles/chat/glm/index.d.ts +0 -6
  291. package/dist/providers/compat/profiles/chat/glm/index.js +0 -6
  292. package/dist/providers/compat/profiles/chat/glm/index.js.map +0 -1
  293. package/dist/providers/compat/profiles/chat/iflow/index.d.ts +0 -6
  294. package/dist/providers/compat/profiles/chat/iflow/index.js +0 -6
  295. package/dist/providers/compat/profiles/chat/iflow/index.js.map +0 -1
  296. package/dist/providers/compat/profiles/chat/lmstudio/index.d.ts +0 -6
  297. package/dist/providers/compat/profiles/chat/lmstudio/index.js +0 -6
  298. package/dist/providers/compat/profiles/chat/lmstudio/index.js.map +0 -1
  299. package/dist/providers/compat/profiles/chat/qwen/index.d.ts +0 -6
  300. package/dist/providers/compat/profiles/chat/qwen/index.js +0 -6
  301. package/dist/providers/compat/profiles/chat/qwen/index.js.map +0 -1
  302. package/dist/providers/compat/profiles/compat/passthrough/index.d.ts +0 -6
  303. package/dist/providers/compat/profiles/compat/passthrough/index.js +0 -6
  304. package/dist/providers/compat/profiles/compat/passthrough/index.js.map +0 -1
  305. package/dist/providers/compat/profiles/responses/c4m/index.d.ts +0 -6
  306. package/dist/providers/compat/profiles/responses/c4m/index.js +0 -6
  307. package/dist/providers/compat/profiles/responses/c4m/index.js.map +0 -1
  308. package/dist/providers/compat/profiles/responses/default/index.d.ts +0 -6
  309. package/dist/providers/compat/profiles/responses/default/index.js +0 -6
  310. package/dist/providers/compat/profiles/responses/default/index.js.map +0 -1
  311. package/dist/providers/compat/profiles/responses/fai/index.d.ts +0 -6
  312. package/dist/providers/compat/profiles/responses/fai/index.js +0 -6
  313. package/dist/providers/compat/profiles/responses/fai/index.js.map +0 -1
  314. package/dist/providers/compat/profiles/responses/fc/index.d.ts +0 -6
  315. package/dist/providers/compat/profiles/responses/fc/index.js +0 -6
  316. package/dist/providers/compat/profiles/responses/fc/index.js.map +0 -1
  317. package/dist/providers/compat/qwen/index.d.ts +0 -4
  318. package/dist/providers/compat/qwen/index.js +0 -6
  319. package/dist/providers/compat/qwen/index.js.map +0 -1
  320. package/dist/providers/compat/qwen-compatibility.d.ts +0 -52
  321. package/dist/providers/compat/qwen-compatibility.js +0 -330
  322. package/dist/providers/compat/qwen-compatibility.js.map +0 -1
  323. package/dist/providers/compat/register-compat-module.d.ts +0 -8
  324. package/dist/providers/compat/register-compat-module.js +0 -53
  325. package/dist/providers/compat/register-compat-module.js.map +0 -1
  326. package/dist/providers/compat/responses/c4m-responses-compatibility.d.ts +0 -27
  327. package/dist/providers/compat/responses/c4m-responses-compatibility.js +0 -197
  328. package/dist/providers/compat/responses/c4m-responses-compatibility.js.map +0 -1
  329. package/dist/providers/compat/standard-compatibility-utils.d.ts +0 -1
  330. package/dist/providers/compat/standard-compatibility-utils.js +0 -77
  331. package/dist/providers/compat/standard-compatibility-utils.js.map +0 -1
  332. package/dist/providers/compat/standard-compatibility.d.ts +0 -31
  333. package/dist/providers/compat/standard-compatibility.js +0 -118
  334. package/dist/providers/compat/standard-compatibility.js.map +0 -1
  335. package/dist/providers/compat/utils/snapshot-writer.js +0 -62
  336. package/dist/providers/compat/utils/snapshot-writer.js.map +0 -1
  337. package/scripts/check-glm-compat.mjs +0 -47
@@ -0,0 +1,56 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import os from 'os';
4
+ const TOKEN_FILE_PATTERN = /^([a-z0-9_-]+)-oauth-(\d+)(?:-(.+))?\.json$/i;
5
+ /**
6
+ * 扫描本地 RouteCodex auth 目录中的 OAuth token 文件。
7
+ *
8
+ * 约定:
9
+ * - 目录: ~/.routecodex/auth
10
+ * - 文件名: <provider>-oauth-<sequence>[-<alias>].json
11
+ *
12
+ * 仅在 Node 环境下使用;如果环境不满足,返回空列表。
13
+ */
14
+ export function scanOAuthTokenFiles(oauthProviderId, authDir) {
15
+ if (!isNodeEnvironment()) {
16
+ return [];
17
+ }
18
+ const provider = oauthProviderId.trim().toLowerCase();
19
+ if (!provider) {
20
+ return [];
21
+ }
22
+ const baseDir = authDir && authDir.trim()
23
+ ? authDir.trim()
24
+ : path.join(os.homedir(), '.routecodex', 'auth');
25
+ let entries;
26
+ try {
27
+ entries = fs.readdirSync(baseDir);
28
+ }
29
+ catch {
30
+ return [];
31
+ }
32
+ const matches = [];
33
+ for (const entry of entries) {
34
+ if (!entry.endsWith('.json'))
35
+ continue;
36
+ const match = entry.match(TOKEN_FILE_PATTERN);
37
+ if (!match)
38
+ continue;
39
+ const [, providerPrefix, sequenceStr, alias] = match;
40
+ if (providerPrefix.toLowerCase() !== provider)
41
+ continue;
42
+ const sequence = parseInt(sequenceStr, 10);
43
+ if (!Number.isFinite(sequence) || sequence <= 0)
44
+ continue;
45
+ matches.push({
46
+ filePath: path.join(baseDir, entry),
47
+ sequence,
48
+ alias: alias || 'default'
49
+ });
50
+ }
51
+ matches.sort((a, b) => a.sequence - b.sequence);
52
+ return matches;
53
+ }
54
+ function isNodeEnvironment() {
55
+ return typeof process !== 'undefined' && !!process.release && process.release.name === 'node';
56
+ }
@@ -0,0 +1,13 @@
1
+ import type { StandardizedMessage, StandardizedRequest } from '../../conversion/hub/types/standardized.js';
2
+ export type ToolCategory = 'read' | 'write' | 'search' | 'other';
3
+ export type ToolClassification = {
4
+ category: ToolCategory;
5
+ name: string;
6
+ commandSnippet?: string;
7
+ };
8
+ export declare function detectVisionTool(request: StandardizedRequest): boolean;
9
+ export declare function detectCodingTool(request: StandardizedRequest): boolean;
10
+ export declare function detectWebTool(request: StandardizedRequest): boolean;
11
+ export declare function extractMeaningfulDeclaredToolNames(tools: StandardizedRequest['tools'] | undefined): string[];
12
+ export declare function detectLastAssistantToolCategory(messages: StandardizedMessage[]): ToolClassification | undefined;
13
+ export declare function canonicalizeToolName(rawName: string): string;
@@ -0,0 +1,403 @@
1
+ const WEB_TOOL_KEYWORDS = ['websearch', 'web_search', 'web-search', 'webfetch', 'web_fetch', 'web_request', 'search_web', 'internet_search'];
2
+ const READ_TOOL_EXACT = new Set([
3
+ 'read_file',
4
+ 'read_text',
5
+ 'view_file',
6
+ 'view_code',
7
+ 'view_document',
8
+ 'open_file',
9
+ 'get_file',
10
+ 'download_file',
11
+ 'describe_current_request',
12
+ 'list_dir',
13
+ 'list_directory',
14
+ 'list_files',
15
+ 'list_documents',
16
+ 'list_resources',
17
+ 'search_files',
18
+ 'find_files'
19
+ ]);
20
+ const WRITE_TOOL_EXACT = new Set([
21
+ 'apply_patch',
22
+ 'write_file',
23
+ 'create_file',
24
+ 'modify_file',
25
+ 'edit_file',
26
+ 'update_file',
27
+ 'save_file',
28
+ 'append_file',
29
+ 'replace_file',
30
+ 'delete_file',
31
+ 'remove_file',
32
+ 'rename_file',
33
+ 'move_file',
34
+ 'copy_file',
35
+ 'mkdir',
36
+ 'rmdir'
37
+ ]);
38
+ const SEARCH_TOOL_EXACT = new Set(['websearch', 'web_search', 'search_web', 'internet_search', 'webfetch', 'web_fetch']);
39
+ const READ_TOOL_KEYWORDS = ['read', 'list', 'view', 'download', 'open', 'show', 'fetch', 'inspect'];
40
+ const WRITE_TOOL_KEYWORDS = ['write', 'patch', 'modify', 'edit', 'create', 'update', 'append', 'replace', 'delete', 'remove'];
41
+ const SEARCH_TOOL_KEYWORDS = ['search', 'websearch', 'web_fetch', 'webfetch', 'web-request', 'web_request', 'internet'];
42
+ const SHELL_TOOL_NAMES = new Set(['shell_command', 'shell', 'bash']);
43
+ const DECLARED_TOOL_IGNORE = new Set(['exec_command']);
44
+ const SHELL_HEREDOC_PATTERN = /<<\s*['"]?[a-z0-9_-]+/i;
45
+ const SHELL_WRITE_PATTERNS = [
46
+ 'apply_patch',
47
+ 'sed -i',
48
+ 'perl -pi',
49
+ 'tee ',
50
+ 'cat <<',
51
+ 'cat >',
52
+ 'printf >',
53
+ 'touch ',
54
+ 'truncate',
55
+ 'mkdir',
56
+ 'mktemp',
57
+ 'rmdir',
58
+ 'rm ',
59
+ 'rm-',
60
+ 'unlink',
61
+ 'mv ',
62
+ 'cp ',
63
+ 'ln -',
64
+ 'chmod',
65
+ 'chown',
66
+ 'chgrp',
67
+ 'tar ',
68
+ 'git add',
69
+ 'git commit',
70
+ 'git apply',
71
+ 'git am',
72
+ 'git rebase',
73
+ 'git checkout',
74
+ 'git merge',
75
+ 'patch <<',
76
+ 'npm install',
77
+ 'pnpm install',
78
+ 'yarn add',
79
+ 'yarn install',
80
+ 'pip install',
81
+ 'pip3 install',
82
+ 'brew install',
83
+ 'cargo add',
84
+ 'cargo install',
85
+ 'go install',
86
+ 'make install'
87
+ ];
88
+ const SHELL_SEARCH_PATTERNS = [
89
+ 'rg ',
90
+ 'rg-',
91
+ 'grep ',
92
+ 'grep-',
93
+ 'ripgrep',
94
+ 'find ',
95
+ 'fd ',
96
+ 'locate ',
97
+ 'search ',
98
+ 'ack ',
99
+ 'ag ',
100
+ 'where ',
101
+ 'which ',
102
+ 'codesearch'
103
+ ];
104
+ const SHELL_READ_PATTERNS = [
105
+ 'ls',
106
+ 'dir ',
107
+ 'pwd',
108
+ 'cat ',
109
+ 'type ',
110
+ 'head ',
111
+ 'tail ',
112
+ 'stat',
113
+ 'tree',
114
+ 'wc ',
115
+ 'du ',
116
+ 'printf "',
117
+ 'python - <<',
118
+ 'python -c',
119
+ 'node - <<',
120
+ 'node -e'
121
+ ];
122
+ export function detectVisionTool(request) {
123
+ if (!Array.isArray(request.tools)) {
124
+ return false;
125
+ }
126
+ return request.tools.some((tool) => {
127
+ const functionName = extractToolName(tool);
128
+ const description = extractToolDescription(tool);
129
+ return /vision|image|picture|photo/i.test(functionName) || /vision|image|picture|photo/i.test(description || '');
130
+ });
131
+ }
132
+ export function detectCodingTool(request) {
133
+ if (!Array.isArray(request.tools)) {
134
+ return false;
135
+ }
136
+ return request.tools.some((tool) => {
137
+ const functionName = extractToolName(tool).toLowerCase();
138
+ const description = (extractToolDescription(tool) || '').toLowerCase();
139
+ if (!functionName && !description) {
140
+ return false;
141
+ }
142
+ if (WRITE_TOOL_EXACT.has(functionName)) {
143
+ return true;
144
+ }
145
+ return WRITE_TOOL_KEYWORDS.some((keyword) => functionName.includes(keyword.toLowerCase()) || description.includes(keyword.toLowerCase()));
146
+ });
147
+ }
148
+ export function detectWebTool(request) {
149
+ if (!Array.isArray(request.tools)) {
150
+ return false;
151
+ }
152
+ return request.tools.some((tool) => {
153
+ const functionName = extractToolName(tool);
154
+ const description = extractToolDescription(tool);
155
+ const normalizedName = functionName.toLowerCase();
156
+ const normalizedDesc = (description || '').toLowerCase();
157
+ return (WEB_TOOL_KEYWORDS.some((keyword) => normalizedName.includes(keyword)) ||
158
+ WEB_TOOL_KEYWORDS.some((keyword) => normalizedDesc.includes(keyword)));
159
+ });
160
+ }
161
+ export function extractMeaningfulDeclaredToolNames(tools) {
162
+ if (!Array.isArray(tools) || tools.length === 0) {
163
+ return [];
164
+ }
165
+ const names = [];
166
+ for (const tool of tools) {
167
+ const rawName = extractToolName(tool);
168
+ if (!rawName) {
169
+ continue;
170
+ }
171
+ const canonical = canonicalizeToolName(rawName).toLowerCase();
172
+ if (!canonical || DECLARED_TOOL_IGNORE.has(canonical)) {
173
+ continue;
174
+ }
175
+ names.push(rawName);
176
+ }
177
+ return names;
178
+ }
179
+ export function detectLastAssistantToolCategory(messages) {
180
+ for (let idx = messages.length - 1; idx >= 0; idx -= 1) {
181
+ const msg = messages[idx];
182
+ if (!msg || !Array.isArray(msg.tool_calls) || msg.tool_calls.length === 0) {
183
+ continue;
184
+ }
185
+ let fallback;
186
+ for (const call of msg.tool_calls) {
187
+ const classification = classifyToolCall(call);
188
+ if (!classification) {
189
+ continue;
190
+ }
191
+ if (!fallback) {
192
+ fallback = classification;
193
+ }
194
+ if (classification.category !== 'other') {
195
+ return classification;
196
+ }
197
+ }
198
+ if (fallback) {
199
+ return fallback;
200
+ }
201
+ }
202
+ return undefined;
203
+ }
204
+ function classifyToolCall(call) {
205
+ if (!call || typeof call !== 'object') {
206
+ return undefined;
207
+ }
208
+ const functionName = typeof call?.function?.name === 'string' && call.function.name.trim()
209
+ ? canonicalizeToolName(call.function.name)
210
+ : '';
211
+ if (!functionName) {
212
+ return undefined;
213
+ }
214
+ const argsObject = parseToolArguments(call?.function?.arguments);
215
+ const commandText = extractCommandText(argsObject);
216
+ const nameCategory = categorizeToolName(functionName);
217
+ const snippet = buildCommandSnippet(commandText);
218
+ if (nameCategory === 'write' || nameCategory === 'read' || nameCategory === 'search') {
219
+ return { category: nameCategory, name: functionName, commandSnippet: snippet };
220
+ }
221
+ if (SHELL_TOOL_NAMES.has(functionName)) {
222
+ const shellCategory = classifyShellCommand(commandText);
223
+ return { category: shellCategory, name: functionName, commandSnippet: snippet };
224
+ }
225
+ if (commandText) {
226
+ const derivedCategory = classifyShellCommand(commandText);
227
+ if (derivedCategory !== 'other') {
228
+ return { category: derivedCategory, name: functionName, commandSnippet: snippet };
229
+ }
230
+ }
231
+ return { category: 'other', name: functionName, commandSnippet: snippet };
232
+ }
233
+ function extractToolName(tool) {
234
+ if (!tool || typeof tool !== 'object') {
235
+ return '';
236
+ }
237
+ const candidate = tool;
238
+ const fromFunction = candidate.function;
239
+ if (fromFunction && typeof fromFunction.name === 'string' && fromFunction.name.trim()) {
240
+ return fromFunction.name;
241
+ }
242
+ if (typeof candidate.name === 'string' && candidate.name.trim()) {
243
+ return candidate.name;
244
+ }
245
+ return '';
246
+ }
247
+ function extractToolDescription(tool) {
248
+ if (!tool || typeof tool !== 'object') {
249
+ return '';
250
+ }
251
+ const candidate = tool;
252
+ const fromFunction = candidate.function;
253
+ if (fromFunction && typeof fromFunction.description === 'string' && fromFunction.description.trim()) {
254
+ return fromFunction.description;
255
+ }
256
+ if (typeof candidate.description === 'string' && candidate.description.trim()) {
257
+ return candidate.description;
258
+ }
259
+ return '';
260
+ }
261
+ export function canonicalizeToolName(rawName) {
262
+ const trimmed = rawName.trim();
263
+ const markerIndex = trimmed.indexOf('arg_');
264
+ if (markerIndex > 0) {
265
+ return trimmed.slice(0, markerIndex);
266
+ }
267
+ return trimmed;
268
+ }
269
+ function parseToolArguments(rawArguments) {
270
+ if (!rawArguments) {
271
+ return undefined;
272
+ }
273
+ if (typeof rawArguments === 'string') {
274
+ try {
275
+ return JSON.parse(rawArguments);
276
+ }
277
+ catch {
278
+ return rawArguments;
279
+ }
280
+ }
281
+ if (typeof rawArguments === 'object') {
282
+ return rawArguments;
283
+ }
284
+ return undefined;
285
+ }
286
+ function extractCommandText(args) {
287
+ if (!args) {
288
+ return '';
289
+ }
290
+ if (typeof args === 'string') {
291
+ return args;
292
+ }
293
+ if (Array.isArray(args)) {
294
+ return args.map((item) => (typeof item === 'string' ? item : '')).filter(Boolean).join(' ');
295
+ }
296
+ if (typeof args === 'object') {
297
+ const record = args;
298
+ const stringKeys = ['command', 'cmd', 'input', 'code', 'script', 'text', 'prompt'];
299
+ for (const key of stringKeys) {
300
+ const value = record[key];
301
+ if (typeof value === 'string' && value.trim()) {
302
+ return value;
303
+ }
304
+ if (Array.isArray(value)) {
305
+ const joined = value.map((item) => (typeof item === 'string' ? item : '')).filter(Boolean).join(' ');
306
+ if (joined.trim()) {
307
+ return joined;
308
+ }
309
+ }
310
+ }
311
+ const nestedArgs = record.args;
312
+ if (typeof nestedArgs === 'string' && nestedArgs.trim()) {
313
+ return nestedArgs;
314
+ }
315
+ if (Array.isArray(nestedArgs)) {
316
+ const joined = nestedArgs.map((item) => (typeof item === 'string' ? item : '')).filter(Boolean).join(' ');
317
+ if (joined.trim()) {
318
+ return joined;
319
+ }
320
+ }
321
+ }
322
+ return '';
323
+ }
324
+ function buildCommandSnippet(commandText) {
325
+ if (!commandText) {
326
+ return undefined;
327
+ }
328
+ const collapsed = commandText.replace(/\s+/g, ' ').trim();
329
+ if (!collapsed) {
330
+ return undefined;
331
+ }
332
+ const limit = 80;
333
+ if (collapsed.length <= limit) {
334
+ return collapsed;
335
+ }
336
+ return `${collapsed.slice(0, limit)}…`;
337
+ }
338
+ function categorizeToolName(name) {
339
+ const normalized = name.toLowerCase();
340
+ if (SEARCH_TOOL_EXACT.has(normalized) ||
341
+ SEARCH_TOOL_KEYWORDS.some((keyword) => normalized.includes(keyword.toLowerCase()))) {
342
+ return 'search';
343
+ }
344
+ if (READ_TOOL_EXACT.has(normalized) ||
345
+ READ_TOOL_KEYWORDS.some((keyword) => normalized.includes(keyword.toLowerCase()))) {
346
+ return 'read';
347
+ }
348
+ if (WRITE_TOOL_EXACT.has(normalized) ||
349
+ WRITE_TOOL_KEYWORDS.some((keyword) => normalized.includes(keyword.toLowerCase()))) {
350
+ return 'write';
351
+ }
352
+ return 'other';
353
+ }
354
+ function classifyShellCommand(command) {
355
+ if (!command) {
356
+ return 'other';
357
+ }
358
+ if (SHELL_HEREDOC_PATTERN.test(command)) {
359
+ return 'write';
360
+ }
361
+ const segments = splitCommandSegments(command).map(stripShellWrapper);
362
+ if (segments.some((segment) => matchesAnyPattern(segment, SHELL_WRITE_PATTERNS))) {
363
+ return 'write';
364
+ }
365
+ if (segments.some((segment) => matchesAnyPattern(segment, SHELL_SEARCH_PATTERNS))) {
366
+ return 'search';
367
+ }
368
+ if (segments.some((segment) => matchesAnyPattern(segment, SHELL_READ_PATTERNS))) {
369
+ return 'read';
370
+ }
371
+ const stripped = stripShellWrapper(command);
372
+ if (matchesAnyPattern(stripped, SHELL_WRITE_PATTERNS)) {
373
+ return 'write';
374
+ }
375
+ if (matchesAnyPattern(stripped, SHELL_SEARCH_PATTERNS)) {
376
+ return 'search';
377
+ }
378
+ if (matchesAnyPattern(stripped, SHELL_READ_PATTERNS)) {
379
+ return 'read';
380
+ }
381
+ return 'other';
382
+ }
383
+ function splitCommandSegments(command) {
384
+ return command
385
+ .split(/(?:\r?\n|&&|\|\||;)/)
386
+ .map((segment) => segment.trim())
387
+ .filter(Boolean);
388
+ }
389
+ function stripShellWrapper(command) {
390
+ if (!command) {
391
+ return '';
392
+ }
393
+ const wrappers = ['bash -lc', 'sh -c', 'zsh -c'];
394
+ for (const wrapper of wrappers) {
395
+ if (command.startsWith(wrapper)) {
396
+ return command.slice(wrapper.length).trim();
397
+ }
398
+ }
399
+ return command.trim();
400
+ }
401
+ function matchesAnyPattern(command, patterns) {
402
+ return patterns.some((pattern) => command.includes(pattern));
403
+ }
@@ -2,9 +2,11 @@
2
2
  * Virtual Router 类型定义
3
3
  */
4
4
  import type { StandardizedRequest } from '../../conversion/hub/types/standardized.js';
5
+ export declare const DEFAULT_MODEL_CONTEXT_TOKENS = 200000;
5
6
  export declare const DEFAULT_ROUTE = "default";
6
7
  export declare const ROUTE_PRIORITY: string[];
7
8
  export type RoutingPools = Record<string, string[]>;
9
+ export type StreamingPreference = 'auto' | 'always' | 'never';
8
10
  export interface ProviderAuthConfig {
9
11
  type: 'apiKey' | 'oauth';
10
12
  secretRef?: string;
@@ -32,6 +34,8 @@ export interface ProviderProfile {
32
34
  modelId?: string;
33
35
  processMode?: 'chat' | 'passthrough';
34
36
  responsesConfig?: ResponsesProviderConfig;
37
+ streaming?: StreamingPreference;
38
+ maxContextTokens?: number;
35
39
  }
36
40
  export interface ProviderRuntimeProfile {
37
41
  runtimeKey: string;
@@ -46,6 +50,11 @@ export interface ProviderRuntimeProfile {
46
50
  modelId?: string;
47
51
  processMode?: 'chat' | 'passthrough';
48
52
  responsesConfig?: ResponsesProviderConfig;
53
+ streaming?: StreamingPreference;
54
+ modelStreaming?: Record<string, StreamingPreference>;
55
+ modelContextTokens?: Record<string, number>;
56
+ defaultContextTokens?: number;
57
+ maxContextTokens?: number;
49
58
  }
50
59
  export interface VirtualRouterClassifierConfig {
51
60
  longContextThresholdTokens?: number;
@@ -69,6 +78,12 @@ export interface VirtualRouterConfig {
69
78
  classifier: VirtualRouterClassifierConfig;
70
79
  loadBalancing?: LoadBalancingPolicy;
71
80
  health?: ProviderHealthConfig;
81
+ contextRouting?: VirtualRouterContextRoutingConfig;
82
+ }
83
+ export interface VirtualRouterContextRoutingConfig {
84
+ warnRatio: number;
85
+ hardLimit?: boolean;
86
+ fallbackRoute?: string;
72
87
  }
73
88
  export type VirtualRouterProviderDefinition = Record<string, unknown>;
74
89
  export interface VirtualRouterBootstrapInput extends Record<string, unknown> {
@@ -78,6 +93,7 @@ export interface VirtualRouterBootstrapInput extends Record<string, unknown> {
78
93
  classifier?: VirtualRouterClassifierConfig;
79
94
  loadBalancing?: LoadBalancingPolicy;
80
95
  health?: ProviderHealthConfig;
96
+ contextRouting?: VirtualRouterContextRoutingConfig;
81
97
  }
82
98
  export type ProviderRuntimeMap = Record<string, ProviderRuntimeProfile>;
83
99
  export interface VirtualRouterBootstrapResult {
@@ -117,7 +133,9 @@ export interface RoutingFeatures {
117
133
  hasThinkingKeyword: boolean;
118
134
  estimatedTokens: number;
119
135
  lastAssistantToolCategory?: 'read' | 'write' | 'search' | 'other';
120
- lastAssistantToolName?: string;
136
+ lastAssistantToolSnippet?: string;
137
+ lastAssistantToolLabel?: string;
138
+ latestMessageFromUser?: boolean;
121
139
  metadata: RouterMetadataInput;
122
140
  }
123
141
  export interface ClassificationResult {
@@ -144,6 +162,8 @@ export interface TargetMetadata {
144
162
  modelId: string;
145
163
  processMode?: 'chat' | 'passthrough';
146
164
  responsesConfig?: ResponsesProviderConfig;
165
+ streaming?: StreamingPreference;
166
+ maxContextTokens?: number;
147
167
  }
148
168
  export interface ResponsesProviderConfig {
149
169
  toolCallIdStyle?: 'fc' | 'preserve';
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Virtual Router 类型定义
3
3
  */
4
+ export const DEFAULT_MODEL_CONTEXT_TOKENS = 200_000;
4
5
  export const DEFAULT_ROUTE = 'default';
5
6
  export const ROUTE_PRIORITY = [
6
7
  'vision',
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsonstudio/llms",
3
- "version": "0.6.104",
3
+ "version": "0.6.203",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -25,7 +25,7 @@
25
25
  "test:looprt:gemini": "npm run build && node scripts/tests/loop-rt-gemini.mjs",
26
26
  "replay:responses:chat-sse": "node scripts/exp3-responses-sse-to-chat-sse.mjs",
27
27
  "replay:responses:loop": "node scripts/exp4-responses-sse-loop.mjs",
28
- "test:virtual-router": "npm run build:dev && node scripts/tests/virtual-router-dry-run.mjs",
28
+ "test:virtual-router": "npm run build:dev && node scripts/tests/virtual-router-dry-run.mjs && node scripts/tests/virtual-router-context.mjs",
29
29
  "test:virtual-router-health": "npm run build:dev && node scripts/tests/virtual-router-health.mjs"
30
30
  },
31
31
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsonstudio/rcc",
3
- "version": "0.89.164",
3
+ "version": "0.89.333",
4
4
  "description": "Multi-provider OpenAI proxy server with anthropic/responses/chat support (dev)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -39,13 +39,14 @@
39
39
  "build:watch": "tsc --watch",
40
40
  "start": "npm run -s start:bg",
41
41
  "dev": "tsx watch src/index.ts",
42
- "test": "jest",
43
- "test:watch": "jest --watch",
44
- "test:coverage": "jest --coverage",
45
- "test:integration": "jest --testPathPattern=integration",
46
- "test:e2e": "jest --testPathPattern=e2e",
47
- "test:performance": "jest --testPathPattern=performance",
48
- "test:protocol": "jest --testPathPattern=protocol-tools-e2e.spec.ts --runInBand --detectOpenHandles --forceExit",
42
+ "jest:run": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js",
43
+ "test": "npm run jest:run",
44
+ "test:watch": "npm run jest:run -- --watch",
45
+ "test:coverage": "npm run jest:run -- --coverage",
46
+ "test:integration": "npm run jest:run -- --testPathPattern=integration",
47
+ "test:e2e": "npm run jest:run -- --testPathPattern=e2e",
48
+ "test:performance": "npm run jest:run -- --testPathPattern=performance",
49
+ "test:protocol": "npm run jest:run -- --testPathPattern=protocol-tools-e2e.spec.ts --runInBand --detectOpenHandles --forceExit",
49
50
  "test:dry-run": "node tests/basic-dry-run.mjs",
50
51
  "test:lmstudio-dryrun": "node tests/lmstudio-tools-bidir-dry-run.mjs",
51
52
  "lint": "eslint --no-eslintrc -c .eslintrc.json src --ext .ts --no-cache",
@@ -83,7 +84,7 @@
83
84
  "start:verify:fg": "node scripts/start-verify.mjs --mode fg --timeout 90",
84
85
  "rc-config": "node scripts/rc-config.mjs",
85
86
  "config:validate:providers": "node scripts/validate-config-providers.mjs",
86
- "verify:e2e-toolcall": "node scripts/verify-e2e-toolcall.mjs",
87
+ "verify:e2e-toolcall": "node scripts/verify-e2e-toolcall.mjs && node scripts/verify-client-headers.mjs",
87
88
  "test:anthropic-roundtrip": "node scripts/tests/anthropic-roundtrip.mjs",
88
89
  "replay:codex-sample": "node scripts/replay-codex-sample.mjs",
89
90
  "config:update:providers": "node scripts/update-config-providers.mjs",
@@ -120,11 +121,12 @@
120
121
  "sync:ci-goldens": "node scripts/tools/sync-ci-goldens.mjs",
121
122
  "mock:extract": "node scripts/mock-provider/extract.mjs",
122
123
  "mock:validate": "node scripts/mock-provider/validate.mjs",
123
- "mock:clean": "node scripts/mock-provider/clean.mjs"
124
+ "mock:clean": "node scripts/mock-provider/clean.mjs",
125
+ "publish:rcc": "node scripts/publish-rcc.mjs"
124
126
  },
125
127
  "dependencies": {
126
128
  "@anthropic-ai/sdk": "^0.65.0",
127
- "@jsonstudio/llms": "^0.6.104",
129
+ "@jsonstudio/llms": "^0.6.203",
128
130
  "@lmstudio/sdk": "^1.5.0",
129
131
  "@radix-ui/react-switch": "^1.2.6",
130
132
  "@types/socket.io": "^3.0.1",
package/scripts/README.md CHANGED
@@ -1,20 +1,34 @@
1
- # RouteCodex 构建和安装脚本
1
+ # Build & Install Scripts
2
2
 
3
- 本目录包含用于自动构建和安装 RouteCodex 的脚本。
3
+ > **AGENTS.md rules apply** – always build shared modules first, never skip verification, never mix dev/release modes.
4
4
 
5
- ## 唯一安装脚本
6
-
7
- ### install-user-global.sh(推荐)
5
+ ## Dev CLI (routecodex)
8
6
 
9
7
  ```bash
10
- # 一键构建并全局安装(使用 npm 默认全局路径,不修改前缀)
8
+ # 1. build sharedmodule first
9
+ npm --prefix sharedmodule/llmswitch-core run build
10
+
11
+ # 2. build host
12
+ cd - && npm run build:dev
13
+
14
+ # 3. install globally
11
15
  npm run install:global
12
16
  ```
13
17
 
14
- 脚本流程:
15
- - 构建 sharedmodule/llmswitch-core 与根包
16
- - npm pack 生成 tgz
17
- - 卸载全局旧版 routecodex
18
- - npm install -g 安装新版本
18
+ ## Release CLI (rcc)
19
+
20
+ ```bash
21
+ # 1. build sharedmodule first
22
+ npm --prefix sharedmodule/llmswitch-core run build
23
+
24
+ # 2. build release variant
25
+ npm run build:release
26
+
27
+ # 3. install globally
28
+ npm run install:release
29
+ ```
30
+
31
+ ## Verification
19
32
 
20
- > 说明:其余安装脚本已移除,请统一使用上述命令。
33
+ - Never use `ROUTECODEX_VERIFY_SKIP=1`; golden samples are up-to-date.
34
+ - CI runs `npm run build:dev && npm run build:release` with full verification.