@jsonstudio/rcc 0.89.168 → 0.89.524

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 (431) 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 +94 -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/commands/token-daemon.d.ts +2 -0
  9. package/dist/commands/token-daemon.js +183 -0
  10. package/dist/commands/token-daemon.js.map +1 -0
  11. package/dist/error-handling/quiet-error-handling-center.d.ts +9 -0
  12. package/dist/error-handling/quiet-error-handling-center.js +141 -0
  13. package/dist/error-handling/quiet-error-handling-center.js.map +1 -0
  14. package/dist/error-handling/route-error-hub.js +8 -2
  15. package/dist/error-handling/route-error-hub.js.map +1 -1
  16. package/dist/index.js +4 -3
  17. package/dist/index.js.map +1 -1
  18. package/dist/modules/llmswitch/bridge.d.ts +1 -1
  19. package/dist/modules/llmswitch/bridge.js +3 -2
  20. package/dist/modules/llmswitch/bridge.js.map +1 -1
  21. package/dist/modules/pipeline/utils/colored-logger.d.ts +2 -0
  22. package/dist/modules/pipeline/utils/colored-logger.js +22 -3
  23. package/dist/modules/pipeline/utils/colored-logger.js.map +1 -1
  24. package/dist/providers/auth/antigravity-userinfo-helper.d.ts +10 -0
  25. package/dist/providers/auth/antigravity-userinfo-helper.js +140 -0
  26. package/dist/providers/auth/antigravity-userinfo-helper.js.map +1 -0
  27. package/dist/providers/auth/gemini-cli-userinfo-helper.js +12 -2
  28. package/dist/providers/auth/gemini-cli-userinfo-helper.js.map +1 -1
  29. package/dist/providers/auth/oauth-lifecycle.js +395 -24
  30. package/dist/providers/auth/oauth-lifecycle.js.map +1 -1
  31. package/dist/providers/auth/token-scanner/index.d.ts +32 -0
  32. package/dist/providers/auth/token-scanner/index.js +86 -0
  33. package/dist/providers/auth/token-scanner/index.js.map +1 -0
  34. package/dist/providers/auth/tokenfile-auth.d.ts +17 -0
  35. package/dist/providers/auth/tokenfile-auth.js +27 -5
  36. package/dist/providers/auth/tokenfile-auth.js.map +1 -1
  37. package/dist/providers/core/api/provider-types.d.ts +10 -0
  38. package/dist/providers/core/config/oauth-flows.d.ts +25 -0
  39. package/dist/providers/core/config/oauth-flows.js +92 -5
  40. package/dist/providers/core/config/oauth-flows.js.map +1 -1
  41. package/dist/providers/core/config/provider-oauth-configs.js +93 -2
  42. package/dist/providers/core/config/provider-oauth-configs.js.map +1 -1
  43. package/dist/providers/core/config/service-profiles.js +18 -10
  44. package/dist/providers/core/config/service-profiles.js.map +1 -1
  45. package/dist/providers/core/runtime/base-provider.d.ts +2 -0
  46. package/dist/providers/core/runtime/base-provider.js +135 -15
  47. package/dist/providers/core/runtime/base-provider.js.map +1 -1
  48. package/dist/providers/core/runtime/gemini-cli-http-provider.d.ts +8 -3
  49. package/dist/providers/core/runtime/gemini-cli-http-provider.js +332 -67
  50. package/dist/providers/core/runtime/gemini-cli-http-provider.js.map +1 -1
  51. package/dist/providers/core/runtime/http-request-executor.d.ts +1 -0
  52. package/dist/providers/core/runtime/http-request-executor.js +41 -1
  53. package/dist/providers/core/runtime/http-request-executor.js.map +1 -1
  54. package/dist/providers/core/runtime/http-transport-provider.d.ts +27 -0
  55. package/dist/providers/core/runtime/http-transport-provider.js +342 -69
  56. package/dist/providers/core/runtime/http-transport-provider.js.map +1 -1
  57. package/dist/providers/core/runtime/provider-error-classifier.d.ts +2 -2
  58. package/dist/providers/core/runtime/provider-error-classifier.js +14 -4
  59. package/dist/providers/core/runtime/provider-error-classifier.js.map +1 -1
  60. package/dist/providers/core/runtime/provider-factory.d.ts +1 -0
  61. package/dist/providers/core/runtime/provider-factory.js +37 -8
  62. package/dist/providers/core/runtime/provider-factory.js.map +1 -1
  63. package/dist/providers/core/runtime/responses-provider.d.ts +3 -3
  64. package/dist/providers/core/runtime/responses-provider.js +56 -117
  65. package/dist/providers/core/runtime/responses-provider.js.map +1 -1
  66. package/dist/providers/core/runtime/vision-debug-utils.d.ts +13 -0
  67. package/dist/providers/core/runtime/vision-debug-utils.js +114 -0
  68. package/dist/providers/core/runtime/vision-debug-utils.js.map +1 -0
  69. package/dist/providers/core/strategies/oauth-auth-code-flow.js +82 -25
  70. package/dist/providers/core/strategies/oauth-auth-code-flow.js.map +1 -1
  71. package/dist/providers/core/utils/http-client.d.ts +5 -0
  72. package/dist/providers/core/utils/http-client.js +31 -4
  73. package/dist/providers/core/utils/http-client.js.map +1 -1
  74. package/dist/providers/core/utils/provider-error-reporter.js +8 -2
  75. package/dist/providers/core/utils/provider-error-reporter.js.map +1 -1
  76. package/dist/providers/core/utils/snapshot-writer.d.ts +1 -1
  77. package/dist/providers/core/utils/snapshot-writer.js +5 -1
  78. package/dist/providers/core/utils/snapshot-writer.js.map +1 -1
  79. package/dist/providers/profile/provider-profile-loader.js +8 -4
  80. package/dist/providers/profile/provider-profile-loader.js.map +1 -1
  81. package/dist/runtime/runtime-flags.d.ts +4 -0
  82. package/dist/runtime/runtime-flags.js +32 -0
  83. package/dist/runtime/runtime-flags.js.map +1 -0
  84. package/dist/server/handlers/handler-utils.js +29 -2
  85. package/dist/server/handlers/handler-utils.js.map +1 -1
  86. package/dist/server/handlers/messages-handler.js +27 -26
  87. package/dist/server/handlers/messages-handler.js.map +1 -1
  88. package/dist/server/handlers/responses-handler.js +35 -1
  89. package/dist/server/handlers/responses-handler.js.map +1 -1
  90. package/dist/server/handlers/sse-dispatcher.js +22 -2
  91. package/dist/server/handlers/sse-dispatcher.js.map +1 -1
  92. package/dist/server/runtime/http-server/index.d.ts +10 -0
  93. package/dist/server/runtime/http-server/index.js +551 -148
  94. package/dist/server/runtime/http-server/index.js.map +1 -1
  95. package/dist/server/runtime/http-server/request-executor.d.ts +14 -0
  96. package/dist/server/runtime/http-server/request-executor.js +638 -149
  97. package/dist/server/runtime/http-server/request-executor.js.map +1 -1
  98. package/dist/server/runtime/http-server/routes.d.ts +5 -0
  99. package/dist/server/runtime/http-server/routes.js +69 -0
  100. package/dist/server/runtime/http-server/routes.js.map +1 -1
  101. package/dist/server/runtime/http-server/runtime-manager.js +18 -0
  102. package/dist/server/runtime/http-server/runtime-manager.js.map +1 -1
  103. package/dist/server/utils/sse-request-parser.d.ts +1 -0
  104. package/dist/server/utils/sse-request-parser.js +17 -6
  105. package/dist/server/utils/sse-request-parser.js.map +1 -1
  106. package/dist/server/utils/utf8-chunk-buffer.d.ts +43 -0
  107. package/dist/server/utils/utf8-chunk-buffer.js +132 -0
  108. package/dist/server/utils/utf8-chunk-buffer.js.map +1 -0
  109. package/dist/server/utils/warmup-detector.d.ts +7 -0
  110. package/dist/server/utils/warmup-detector.js +125 -0
  111. package/dist/server/utils/warmup-detector.js.map +1 -0
  112. package/dist/server/utils/warmup-storm-tracker.d.ts +9 -0
  113. package/dist/server/utils/warmup-storm-tracker.js +61 -0
  114. package/dist/server/utils/warmup-storm-tracker.js.map +1 -0
  115. package/dist/token-daemon/index.d.ts +7 -0
  116. package/dist/token-daemon/index.js +242 -0
  117. package/dist/token-daemon/index.js.map +1 -0
  118. package/dist/token-daemon/server-utils.d.ts +33 -0
  119. package/dist/token-daemon/server-utils.js +155 -0
  120. package/dist/token-daemon/server-utils.js.map +1 -0
  121. package/dist/token-daemon/token-daemon.d.ts +20 -0
  122. package/dist/token-daemon/token-daemon.js +144 -0
  123. package/dist/token-daemon/token-daemon.js.map +1 -0
  124. package/dist/token-daemon/token-types.d.ts +44 -0
  125. package/dist/token-daemon/token-types.js +18 -0
  126. package/dist/token-daemon/token-types.js.map +1 -0
  127. package/dist/token-daemon/token-utils.d.ts +17 -0
  128. package/dist/token-daemon/token-utils.js +153 -0
  129. package/dist/token-daemon/token-utils.js.map +1 -0
  130. package/dist/tools/semantic-replay.js +7 -6
  131. package/dist/tools/semantic-replay.js.map +1 -1
  132. package/dist/utils/debug-utils.js +14 -0
  133. package/dist/utils/debug-utils.js.map +1 -1
  134. package/dist/utils/error-handler-registry.d.ts +36 -0
  135. package/dist/utils/error-handler-registry.js +99 -12
  136. package/dist/utils/error-handler-registry.js.map +1 -1
  137. package/dist/utils/error-handling-utils.js +4 -3
  138. package/dist/utils/error-handling-utils.js.map +1 -1
  139. package/dist/utils/log-helpers.d.ts +6 -0
  140. package/dist/utils/log-helpers.js +90 -0
  141. package/dist/utils/log-helpers.js.map +1 -0
  142. package/dist/utils/logger.d.ts +8 -0
  143. package/dist/utils/logger.js +55 -2
  144. package/dist/utils/logger.js.map +1 -1
  145. package/dist/utils/snapshot-writer.js +2 -6
  146. package/dist/utils/snapshot-writer.js.map +1 -1
  147. package/node_modules/@jsonstudio/llms/README.md +2 -0
  148. package/node_modules/@jsonstudio/llms/dist/conversion/codecs/gemini-openai-codec.js +152 -6
  149. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/auto-thinking.d.ts +6 -0
  150. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/auto-thinking.js +25 -0
  151. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/field-mapping.d.ts +14 -0
  152. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/field-mapping.js +155 -0
  153. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/gemini-web-search.d.ts +17 -0
  154. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/gemini-web-search.js +68 -0
  155. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/glm-image-content.d.ts +2 -0
  156. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/glm-image-content.js +83 -0
  157. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/glm-tool-extraction.d.ts +2 -0
  158. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/glm-tool-extraction.js +264 -0
  159. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/glm-vision-prompt.d.ts +11 -0
  160. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/glm-vision-prompt.js +177 -0
  161. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/glm-web-search.d.ts +2 -0
  162. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/glm-web-search.js +63 -0
  163. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/qwen-transform.d.ts +3 -0
  164. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/qwen-transform.js +209 -0
  165. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/request-rules.d.ts +24 -0
  166. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/request-rules.js +63 -0
  167. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-blacklist.d.ts +14 -0
  168. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-blacklist.js +85 -0
  169. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-normalize.d.ts +5 -0
  170. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-normalize.js +121 -0
  171. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-validate.d.ts +5 -0
  172. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-validate.js +76 -0
  173. package/{dist/providers/compat/utils/snapshot-writer.d.ts → node_modules/@jsonstudio/llms/dist/conversion/compat/actions/snapshot.d.ts} +2 -2
  174. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/snapshot.js +21 -0
  175. package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/tool-schema.d.ts +6 -0
  176. package/{dist/providers/compat/glm/utils/tool-schema-helpers.js → node_modules/@jsonstudio/llms/dist/conversion/compat/actions/tool-schema.js} +6 -1
  177. package/{dist/providers/compat/filters → node_modules/@jsonstudio/llms/dist/conversion/compat/actions}/universal-shape-filter.d.ts +17 -22
  178. package/{dist/providers/compat/filters → node_modules/@jsonstudio/llms/dist/conversion/compat/actions}/universal-shape-filter.js +46 -99
  179. package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-gemini.json +17 -0
  180. package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-glm.json +196 -13
  181. package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-iflow.json +194 -26
  182. package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-lmstudio.json +43 -35
  183. package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-qwen.json +20 -16
  184. package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/responses-c4m.json +42 -42
  185. package/node_modules/@jsonstudio/llms/dist/conversion/config/sample-config.json +1 -1
  186. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-engine.d.ts +7 -2
  187. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-engine.js +5 -665
  188. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.d.ts +9 -0
  189. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.js +869 -0
  190. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-types.d.ts +55 -0
  191. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/hub-pipeline.d.ts +2 -0
  192. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/hub-pipeline.js +74 -5
  193. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage3_compat/index.js +2 -2
  194. package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/target-utils.js +9 -0
  195. package/node_modules/@jsonstudio/llms/dist/conversion/hub/process/chat-process.js +213 -1
  196. package/node_modules/@jsonstudio/llms/dist/conversion/hub/response/provider-response.d.ts +34 -0
  197. package/node_modules/@jsonstudio/llms/dist/conversion/hub/response/provider-response.js +84 -24
  198. package/node_modules/@jsonstudio/llms/dist/conversion/hub/response/response-runtime.js +19 -2
  199. package/node_modules/@jsonstudio/llms/dist/conversion/hub/response/server-side-tools.d.ts +26 -0
  200. package/node_modules/@jsonstudio/llms/dist/conversion/hub/response/server-side-tools.js +383 -0
  201. package/node_modules/@jsonstudio/llms/dist/conversion/hub/semantic-mappers/gemini-mapper.js +241 -14
  202. package/node_modules/@jsonstudio/llms/dist/conversion/hub/semantic-mappers/responses-mapper.js +17 -1
  203. package/node_modules/@jsonstudio/llms/dist/conversion/hub/standardized-bridge.js +14 -0
  204. package/node_modules/@jsonstudio/llms/dist/conversion/hub/types/standardized.d.ts +1 -0
  205. package/node_modules/@jsonstudio/llms/dist/conversion/responses/responses-host-policy.d.ts +6 -0
  206. package/node_modules/@jsonstudio/llms/dist/conversion/responses/responses-host-policy.js +14 -0
  207. package/node_modules/@jsonstudio/llms/dist/conversion/responses/responses-openai-bridge.js +133 -5
  208. package/node_modules/@jsonstudio/llms/dist/conversion/shared/anthropic-message-utils.js +98 -3
  209. package/node_modules/@jsonstudio/llms/dist/conversion/shared/bridge-message-utils.js +137 -10
  210. package/node_modules/@jsonstudio/llms/dist/conversion/shared/responses-output-builder.js +43 -2
  211. package/node_modules/@jsonstudio/llms/dist/conversion/shared/responses-reasoning-registry.d.ts +4 -0
  212. package/node_modules/@jsonstudio/llms/dist/conversion/shared/responses-reasoning-registry.js +62 -1
  213. package/node_modules/@jsonstudio/llms/dist/conversion/shared/responses-response-utils.js +23 -1
  214. package/node_modules/@jsonstudio/llms/dist/conversion/shared/snapshot-utils.js +17 -47
  215. package/node_modules/@jsonstudio/llms/dist/conversion/shared/tool-canonicalizer.d.ts +2 -0
  216. package/node_modules/@jsonstudio/llms/dist/conversion/shared/tool-filter-pipeline.js +12 -0
  217. package/node_modules/@jsonstudio/llms/dist/conversion/shared/tool-mapping.js +25 -2
  218. package/node_modules/@jsonstudio/llms/dist/index.d.ts +1 -0
  219. package/node_modules/@jsonstudio/llms/dist/index.js +1 -0
  220. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/bootstrap.js +540 -36
  221. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/classifier.js +12 -11
  222. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/context-advisor.d.ts +19 -0
  223. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/context-advisor.js +64 -0
  224. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/engine.d.ts +26 -0
  225. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/engine.js +450 -54
  226. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/features.js +23 -458
  227. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/health-manager.js +2 -7
  228. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/message-utils.d.ts +7 -0
  229. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/message-utils.js +78 -0
  230. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/provider-registry.js +7 -2
  231. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/token-counter.js +14 -3
  232. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/token-estimator.d.ts +2 -0
  233. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/token-estimator.js +16 -0
  234. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/token-file-scanner.d.ts +15 -0
  235. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/token-file-scanner.js +56 -0
  236. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/tool-signals.d.ts +13 -0
  237. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/tool-signals.js +403 -0
  238. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/types.d.ts +86 -2
  239. package/node_modules/@jsonstudio/llms/dist/router/virtual-router/types.js +3 -1
  240. package/node_modules/@jsonstudio/llms/dist/servertool/engine.d.ts +27 -0
  241. package/node_modules/@jsonstudio/llms/dist/servertool/engine.js +60 -0
  242. package/node_modules/@jsonstudio/llms/dist/servertool/flow-types.d.ts +40 -0
  243. package/node_modules/@jsonstudio/llms/dist/servertool/flow-types.js +1 -0
  244. package/node_modules/@jsonstudio/llms/dist/servertool/handlers/vision.d.ts +1 -0
  245. package/node_modules/@jsonstudio/llms/dist/servertool/handlers/vision.js +194 -0
  246. package/node_modules/@jsonstudio/llms/dist/servertool/handlers/web-search.d.ts +1 -0
  247. package/node_modules/@jsonstudio/llms/dist/servertool/handlers/web-search.js +638 -0
  248. package/node_modules/@jsonstudio/llms/dist/servertool/orchestration-types.d.ts +33 -0
  249. package/node_modules/@jsonstudio/llms/dist/servertool/orchestration-types.js +1 -0
  250. package/node_modules/@jsonstudio/llms/dist/servertool/registry.d.ts +18 -0
  251. package/node_modules/@jsonstudio/llms/dist/servertool/registry.js +27 -0
  252. package/node_modules/@jsonstudio/llms/dist/servertool/server-side-tools.d.ts +8 -0
  253. package/node_modules/@jsonstudio/llms/dist/servertool/server-side-tools.js +208 -0
  254. package/node_modules/@jsonstudio/llms/dist/servertool/types.d.ts +88 -0
  255. package/node_modules/@jsonstudio/llms/dist/servertool/types.js +1 -0
  256. package/node_modules/@jsonstudio/llms/dist/servertool/vision-tool.d.ts +2 -0
  257. package/node_modules/@jsonstudio/llms/dist/servertool/vision-tool.js +185 -0
  258. package/node_modules/@jsonstudio/llms/dist/sse/json-to-sse/event-generators/responses.js +15 -3
  259. package/node_modules/@jsonstudio/llms/dist/sse/sse-to-json/builders/response-builder.js +6 -3
  260. package/node_modules/@jsonstudio/llms/dist/sse/sse-to-json/gemini-sse-to-json-converter.js +27 -1
  261. package/node_modules/@jsonstudio/llms/dist/sse/types/gemini-types.d.ts +20 -1
  262. package/node_modules/@jsonstudio/llms/dist/sse/types/responses-types.js +1 -1
  263. package/node_modules/@jsonstudio/llms/dist/telemetry/stats-center.d.ts +73 -0
  264. package/node_modules/@jsonstudio/llms/dist/telemetry/stats-center.js +280 -0
  265. package/node_modules/@jsonstudio/llms/package.json +2 -2
  266. package/package.json +11 -10
  267. package/scripts/README.md +26 -12
  268. package/scripts/auth-antigravity-token.mjs +64 -0
  269. package/scripts/auth-gemini-cli-token.mjs +96 -0
  270. package/scripts/auth-iflow-manual.mjs +81 -0
  271. package/scripts/auth-iflow-token-direct.mjs +87 -0
  272. package/scripts/auth-iflow-token.mjs +77 -0
  273. package/scripts/copy-compat-assets.mjs +3 -15
  274. package/scripts/install-verify.mjs +1 -0
  275. package/scripts/pack-mode.mjs +2 -1
  276. package/scripts/publish-rcc.mjs +20 -4
  277. package/scripts/replay-codex-sample.mjs +13 -8
  278. package/scripts/tests/chat-pipeline-blackbox.mjs +1 -1
  279. package/scripts/tests/virtual-router-health.mjs +141 -6
  280. package/scripts/tools/capture-provider-goldens.mjs +8 -7
  281. package/scripts/verify-client-headers.mjs +224 -0
  282. package/dist/providers/compat/base-compatibility.d.ts +0 -27
  283. package/dist/providers/compat/base-compatibility.js +0 -143
  284. package/dist/providers/compat/base-compatibility.js.map +0 -1
  285. package/dist/providers/compat/compat-directory-loader.d.ts +0 -4
  286. package/dist/providers/compat/compat-directory-loader.js +0 -85
  287. package/dist/providers/compat/compat-directory-loader.js.map +0 -1
  288. package/dist/providers/compat/compatibility-adapter.d.ts +0 -18
  289. package/dist/providers/compat/compatibility-adapter.js +0 -104
  290. package/dist/providers/compat/compatibility-adapter.js.map +0 -1
  291. package/dist/providers/compat/compatibility-factory.d.ts +0 -57
  292. package/dist/providers/compat/compatibility-factory.js +0 -155
  293. package/dist/providers/compat/compatibility-factory.js.map +0 -1
  294. package/dist/providers/compat/compatibility-interface.d.ts +0 -35
  295. package/dist/providers/compat/compatibility-interface.js +0 -2
  296. package/dist/providers/compat/compatibility-interface.js.map +0 -1
  297. package/dist/providers/compat/compatibility-manager.d.ts +0 -85
  298. package/dist/providers/compat/compatibility-manager.js +0 -368
  299. package/dist/providers/compat/compatibility-manager.js.map +0 -1
  300. package/dist/providers/compat/config/config-compatibility.d.ts +0 -28
  301. package/dist/providers/compat/config/config-compatibility.js +0 -95
  302. package/dist/providers/compat/config/config-compatibility.js.map +0 -1
  303. package/dist/providers/compat/field-mapping.d.ts +0 -102
  304. package/dist/providers/compat/field-mapping.js +0 -447
  305. package/dist/providers/compat/field-mapping.js.map +0 -1
  306. package/dist/providers/compat/filters/blacklist-sanitizer.d.ts +0 -45
  307. package/dist/providers/compat/filters/blacklist-sanitizer.js +0 -133
  308. package/dist/providers/compat/filters/blacklist-sanitizer.js.map +0 -1
  309. package/dist/providers/compat/filters/response-blacklist-sanitizer.d.ts +0 -28
  310. package/dist/providers/compat/filters/response-blacklist-sanitizer.js +0 -138
  311. package/dist/providers/compat/filters/response-blacklist-sanitizer.js.map +0 -1
  312. package/dist/providers/compat/filters/universal-shape-filter.js.map +0 -1
  313. package/dist/providers/compat/glm/config/blacklist-rules.json +0 -22
  314. package/dist/providers/compat/glm/config/field-mappings.json +0 -92
  315. package/dist/providers/compat/glm/config/response-blacklist.json +0 -7
  316. package/dist/providers/compat/glm/config/shape-filters.json +0 -37
  317. package/dist/providers/compat/glm/field-mapping/field-mapping-processor.d.ts +0 -28
  318. package/dist/providers/compat/glm/field-mapping/field-mapping-processor.js +0 -306
  319. package/dist/providers/compat/glm/field-mapping/field-mapping-processor.js.map +0 -1
  320. package/dist/providers/compat/glm/functions/glm-processor.d.ts +0 -50
  321. package/dist/providers/compat/glm/functions/glm-processor.js +0 -134
  322. package/dist/providers/compat/glm/functions/glm-processor.js.map +0 -1
  323. package/dist/providers/compat/glm/glm-compatibility.d.ts +0 -34
  324. package/dist/providers/compat/glm/glm-compatibility.js +0 -117
  325. package/dist/providers/compat/glm/glm-compatibility.js.map +0 -1
  326. package/dist/providers/compat/glm/hooks/base-hook.d.ts +0 -21
  327. package/dist/providers/compat/glm/hooks/base-hook.js +0 -53
  328. package/dist/providers/compat/glm/hooks/base-hook.js.map +0 -1
  329. package/dist/providers/compat/glm/hooks/glm-request-validation-hook.d.ts +0 -24
  330. package/dist/providers/compat/glm/hooks/glm-request-validation-hook.js +0 -268
  331. package/dist/providers/compat/glm/hooks/glm-request-validation-hook.js.map +0 -1
  332. package/dist/providers/compat/glm/hooks/glm-response-normalization-hook.d.ts +0 -21
  333. package/dist/providers/compat/glm/hooks/glm-response-normalization-hook.js +0 -171
  334. package/dist/providers/compat/glm/hooks/glm-response-normalization-hook.js.map +0 -1
  335. package/dist/providers/compat/glm/hooks/glm-response-validation-hook.d.ts +0 -25
  336. package/dist/providers/compat/glm/hooks/glm-response-validation-hook.js +0 -236
  337. package/dist/providers/compat/glm/hooks/glm-response-validation-hook.js.map +0 -1
  338. package/dist/providers/compat/glm/hooks/glm-tool-cleaning-hook.d.ts +0 -26
  339. package/dist/providers/compat/glm/hooks/glm-tool-cleaning-hook.js +0 -186
  340. package/dist/providers/compat/glm/hooks/glm-tool-cleaning-hook.js.map +0 -1
  341. package/dist/providers/compat/glm/index.d.ts +0 -24
  342. package/dist/providers/compat/glm/index.js +0 -29
  343. package/dist/providers/compat/glm/index.js.map +0 -1
  344. package/dist/providers/compat/glm/utils/tool-schema-helpers.d.ts +0 -3
  345. package/dist/providers/compat/glm/utils/tool-schema-helpers.js.map +0 -1
  346. package/dist/providers/compat/iflow/config/field-mappings.json +0 -92
  347. package/dist/providers/compat/iflow/config/shape-filters.json +0 -37
  348. package/dist/providers/compat/iflow/field-mapping/iflow-field-mapping-processor.d.ts +0 -34
  349. package/dist/providers/compat/iflow/field-mapping/iflow-field-mapping-processor.js +0 -386
  350. package/dist/providers/compat/iflow/field-mapping/iflow-field-mapping-processor.js.map +0 -1
  351. package/dist/providers/compat/iflow/functions/iflow-processor.d.ts +0 -53
  352. package/dist/providers/compat/iflow/functions/iflow-processor.js +0 -215
  353. package/dist/providers/compat/iflow/functions/iflow-processor.js.map +0 -1
  354. package/dist/providers/compat/iflow/hooks/base-hook.d.ts +0 -23
  355. package/dist/providers/compat/iflow/hooks/base-hook.js +0 -59
  356. package/dist/providers/compat/iflow/hooks/base-hook.js.map +0 -1
  357. package/dist/providers/compat/iflow/hooks/iflow-request-validation-hook.d.ts +0 -23
  358. package/dist/providers/compat/iflow/hooks/iflow-request-validation-hook.js +0 -279
  359. package/dist/providers/compat/iflow/hooks/iflow-request-validation-hook.js.map +0 -1
  360. package/dist/providers/compat/iflow/hooks/iflow-response-normalization-hook.d.ts +0 -20
  361. package/dist/providers/compat/iflow/hooks/iflow-response-normalization-hook.js +0 -180
  362. package/dist/providers/compat/iflow/hooks/iflow-response-normalization-hook.js.map +0 -1
  363. package/dist/providers/compat/iflow/hooks/iflow-response-validation-hook.d.ts +0 -23
  364. package/dist/providers/compat/iflow/hooks/iflow-response-validation-hook.js +0 -232
  365. package/dist/providers/compat/iflow/hooks/iflow-response-validation-hook.js.map +0 -1
  366. package/dist/providers/compat/iflow/hooks/iflow-tool-cleaning-hook.d.ts +0 -25
  367. package/dist/providers/compat/iflow/hooks/iflow-tool-cleaning-hook.js +0 -216
  368. package/dist/providers/compat/iflow/hooks/iflow-tool-cleaning-hook.js.map +0 -1
  369. package/dist/providers/compat/iflow/iflow-compatibility.d.ts +0 -24
  370. package/dist/providers/compat/iflow/iflow-compatibility.js +0 -94
  371. package/dist/providers/compat/iflow/iflow-compatibility.js.map +0 -1
  372. package/dist/providers/compat/index.d.ts +0 -59
  373. package/dist/providers/compat/index.js +0 -83
  374. package/dist/providers/compat/index.js.map +0 -1
  375. package/dist/providers/compat/lmstudio-compatibility.d.ts +0 -44
  376. package/dist/providers/compat/lmstudio-compatibility.js +0 -193
  377. package/dist/providers/compat/lmstudio-compatibility.js.map +0 -1
  378. package/dist/providers/compat/passthrough-compatibility.d.ts +0 -29
  379. package/dist/providers/compat/passthrough-compatibility.js +0 -83
  380. package/dist/providers/compat/passthrough-compatibility.js.map +0 -1
  381. package/dist/providers/compat/profiles/chat/glm/index.d.ts +0 -6
  382. package/dist/providers/compat/profiles/chat/glm/index.js +0 -6
  383. package/dist/providers/compat/profiles/chat/glm/index.js.map +0 -1
  384. package/dist/providers/compat/profiles/chat/iflow/index.d.ts +0 -6
  385. package/dist/providers/compat/profiles/chat/iflow/index.js +0 -6
  386. package/dist/providers/compat/profiles/chat/iflow/index.js.map +0 -1
  387. package/dist/providers/compat/profiles/chat/lmstudio/index.d.ts +0 -6
  388. package/dist/providers/compat/profiles/chat/lmstudio/index.js +0 -6
  389. package/dist/providers/compat/profiles/chat/lmstudio/index.js.map +0 -1
  390. package/dist/providers/compat/profiles/chat/qwen/index.d.ts +0 -6
  391. package/dist/providers/compat/profiles/chat/qwen/index.js +0 -6
  392. package/dist/providers/compat/profiles/chat/qwen/index.js.map +0 -1
  393. package/dist/providers/compat/profiles/compat/passthrough/index.d.ts +0 -6
  394. package/dist/providers/compat/profiles/compat/passthrough/index.js +0 -6
  395. package/dist/providers/compat/profiles/compat/passthrough/index.js.map +0 -1
  396. package/dist/providers/compat/profiles/responses/c4m/index.d.ts +0 -6
  397. package/dist/providers/compat/profiles/responses/c4m/index.js +0 -6
  398. package/dist/providers/compat/profiles/responses/c4m/index.js.map +0 -1
  399. package/dist/providers/compat/profiles/responses/default/index.d.ts +0 -6
  400. package/dist/providers/compat/profiles/responses/default/index.js +0 -6
  401. package/dist/providers/compat/profiles/responses/default/index.js.map +0 -1
  402. package/dist/providers/compat/profiles/responses/fai/index.d.ts +0 -6
  403. package/dist/providers/compat/profiles/responses/fai/index.js +0 -6
  404. package/dist/providers/compat/profiles/responses/fai/index.js.map +0 -1
  405. package/dist/providers/compat/profiles/responses/fc/index.d.ts +0 -6
  406. package/dist/providers/compat/profiles/responses/fc/index.js +0 -6
  407. package/dist/providers/compat/profiles/responses/fc/index.js.map +0 -1
  408. package/dist/providers/compat/qwen/index.d.ts +0 -4
  409. package/dist/providers/compat/qwen/index.js +0 -6
  410. package/dist/providers/compat/qwen/index.js.map +0 -1
  411. package/dist/providers/compat/qwen-compatibility.d.ts +0 -52
  412. package/dist/providers/compat/qwen-compatibility.js +0 -330
  413. package/dist/providers/compat/qwen-compatibility.js.map +0 -1
  414. package/dist/providers/compat/register-compat-module.d.ts +0 -8
  415. package/dist/providers/compat/register-compat-module.js +0 -53
  416. package/dist/providers/compat/register-compat-module.js.map +0 -1
  417. package/dist/providers/compat/responses/c4m-responses-compatibility.d.ts +0 -27
  418. package/dist/providers/compat/responses/c4m-responses-compatibility.js +0 -197
  419. package/dist/providers/compat/responses/c4m-responses-compatibility.js.map +0 -1
  420. package/dist/providers/compat/standard-compatibility-utils.d.ts +0 -1
  421. package/dist/providers/compat/standard-compatibility-utils.js +0 -77
  422. package/dist/providers/compat/standard-compatibility-utils.js.map +0 -1
  423. package/dist/providers/compat/standard-compatibility.d.ts +0 -31
  424. package/dist/providers/compat/standard-compatibility.js +0 -118
  425. package/dist/providers/compat/standard-compatibility.js.map +0 -1
  426. package/dist/providers/compat/utils/snapshot-writer.js +0 -62
  427. package/dist/providers/compat/utils/snapshot-writer.js.map +0 -1
  428. package/dist/tools/replay-request.d.ts +0 -0
  429. package/dist/tools/replay-request.js +0 -2
  430. package/dist/tools/replay-request.js.map +0 -1
  431. package/scripts/check-glm-compat.mjs +0 -47
@@ -1,6 +1,14 @@
1
- import type { UnknownObject } from '../../../modules/pipeline/types/common-types.js';
2
- import type { CompatibilityContext } from '../compatibility-interface.js';
3
- type FilterConfig = {
1
+ import type { AdapterContext } from '../../hub/types/chat-envelope.js';
2
+ import type { JsonObject } from '../../hub/types/json.js';
3
+ type RequestMessagesRule = {
4
+ when?: {
5
+ role?: 'system' | 'user' | 'assistant' | 'tool';
6
+ hasToolCalls?: boolean;
7
+ };
8
+ action: 'drop' | 'keep' | 'set';
9
+ set?: Record<string, unknown>;
10
+ };
11
+ export interface FilterConfig {
4
12
  request: {
5
13
  allowTopLevel: string[];
6
14
  messages: {
@@ -16,14 +24,7 @@ type FilterConfig = {
16
24
  assistantToolCalls?: {
17
25
  functionArgumentsType?: 'object' | 'string';
18
26
  };
19
- messagesRules?: Array<{
20
- when?: {
21
- role?: 'system' | 'user' | 'assistant' | 'tool';
22
- hasToolCalls?: boolean;
23
- };
24
- action: 'drop' | 'keep' | 'set';
25
- set?: Record<string, unknown>;
26
- }>;
27
+ messagesRules?: RequestMessagesRule[];
27
28
  };
28
29
  response: {
29
30
  allowTopLevel: string[];
@@ -46,22 +47,16 @@ type FilterConfig = {
46
47
  allow: string[];
47
48
  };
48
49
  };
49
- };
50
+ }
50
51
  export declare class UniversalShapeFilter {
51
- private cfg;
52
- private readonly configPath?;
53
- private readonly inlineConfig?;
54
- constructor(options?: {
55
- configPath?: string;
56
- config?: FilterConfig;
57
- });
58
- initialize(): Promise<void>;
52
+ private readonly cfg;
53
+ constructor(config: FilterConfig);
54
+ applyRequestFilter(payload: JsonObject): JsonObject;
55
+ applyResponseFilter(payload: JsonObject, ctx?: AdapterContext): JsonObject;
59
56
  private shallowPick;
60
57
  private toObjectArgs;
61
58
  private toStringArgs;
62
59
  private normalizeToolContent;
63
- applyRequestFilter(payload: UnknownObject): Promise<UnknownObject>;
64
- applyResponseFilter(payload: UnknownObject, _ctx?: CompatibilityContext): Promise<UnknownObject>;
65
60
  private normalizeRequestMessages;
66
61
  private normalizeSingleMessage;
67
62
  private normalizeAssistantToolCalls;
@@ -1,5 +1,3 @@
1
- import * as fs from 'fs/promises';
2
- import * as path from 'path';
3
1
  const DEFAULT_TOOL_OUTPUT = 'Command succeeded (no output).';
4
2
  function isRecord(value) {
5
3
  return typeof value === 'object' && value !== null && !Array.isArray(value);
@@ -14,55 +12,43 @@ function hasArrayItems(value) {
14
12
  return Array.isArray(value) && value.length > 0;
15
13
  }
16
14
  export class UniversalShapeFilter {
17
- cfg = null;
18
- configPath;
19
- inlineConfig;
20
- constructor(options = {}) {
21
- this.configPath = options.configPath;
22
- this.inlineConfig = options.config;
15
+ cfg;
16
+ constructor(config) {
17
+ this.cfg = config;
23
18
  }
24
- async initialize() {
25
- if (this.inlineConfig) {
26
- this.cfg = this.inlineConfig;
27
- return;
28
- }
29
- const file = this.configPath ? (path.isAbsolute(this.configPath) ? this.configPath : path.join(process.cwd(), this.configPath)) : '';
30
- if (file) {
31
- try {
32
- const text = await fs.readFile(file, 'utf-8');
33
- this.cfg = JSON.parse(text);
34
- return;
35
- }
36
- catch { /* fallthrough to default */ }
37
- }
38
- this.cfg = {
39
- request: {
40
- allowTopLevel: ['model', 'messages', 'stream', 'thinking', 'do_sample', 'temperature', 'top_p', 'max_tokens', 'tool_stream', 'tools', 'tool_choice', 'stop', 'response_format', 'request_id', 'user_id'],
41
- messages: { allowedRoles: ['system', 'user', 'assistant', 'tool'], assistantWithToolCallsContentNull: true, toolContentStringify: true },
42
- tools: { normalize: true, forceToolChoiceAuto: true },
43
- assistantToolCalls: { functionArgumentsType: 'string' } // 修复:默认使用string格式而不是object
44
- },
45
- response: {
46
- // 保留 Responses 协议关键字段,避免在合成/转换前被丢弃
47
- allowTopLevel: [
48
- 'id', 'request_id', 'created', 'model',
49
- 'choices', 'usage', 'video_result', 'web_search', 'content_filter',
50
- // Responses 专有/常见:
51
- 'required_action', 'output', 'output_text', 'status'
52
- ],
53
- choices: {
54
- required: true,
55
- message: {
56
- allow: ['role', 'content', 'reasoning_content', 'audio', 'tool_calls'],
57
- roleDefault: 'assistant',
58
- contentNullWhenToolCalls: true,
59
- tool_calls: { function: { nameRequired: true, argumentsType: 'string' } }
60
- },
61
- finish_reason: ['stop', 'tool_calls', 'length', 'sensitive', 'network_error']
62
- },
63
- usage: { allow: ['prompt_tokens', 'completion_tokens', 'prompt_tokens_details', 'total_tokens'] }
19
+ applyRequestFilter(payload) {
20
+ const cfg = this.cfg;
21
+ const allow = new Set(cfg.request.allowTopLevel);
22
+ const src = toRecord(payload);
23
+ const out = {};
24
+ for (const key of Object.keys(src)) {
25
+ if (allow.has(key)) {
26
+ out[key] = src[key];
64
27
  }
65
- };
28
+ }
29
+ const normalizedMessages = this.normalizeRequestMessages(out.messages, cfg.request);
30
+ out.messages = normalizedMessages;
31
+ this.normalizeTools(out, cfg.request);
32
+ this.cleanupToolChoice(out);
33
+ return out;
34
+ }
35
+ applyResponseFilter(payload, ctx) {
36
+ const envFlag = String(process.env.RCC_COMPAT_FILTER_OFF_RESPONSES || '1').toLowerCase();
37
+ const envBypass = !(envFlag === '0' || envFlag === 'false' || envFlag === 'off');
38
+ const entryEndpoint = ctx?.entryEndpoint ?? ctx?.endpoint;
39
+ const entry = typeof entryEndpoint === 'string' ? entryEndpoint.toLowerCase() : '';
40
+ if (entry === '/v1/responses' || envBypass) {
41
+ return payload;
42
+ }
43
+ const cfg = this.cfg;
44
+ const src = toRecord(payload);
45
+ const out = this.shallowPick(src, cfg.response.allowTopLevel);
46
+ const choices = Array.isArray(src.choices) ? src.choices : [];
47
+ out.choices = choices.map((choice, idx) => this.normalizeResponseChoice(choice, idx, cfg.response));
48
+ if (src.usage && typeof src.usage === 'object') {
49
+ out.usage = this.shallowPick(src.usage, cfg.response.usage?.allow || []);
50
+ }
51
+ return out;
66
52
  }
67
53
  shallowPick(obj, allow) {
68
54
  if (!isRecord(obj)) {
@@ -119,51 +105,6 @@ export class UniversalShapeFilter {
119
105
  return DEFAULT_TOOL_OUTPUT;
120
106
  }
121
107
  }
122
- async applyRequestFilter(payload) {
123
- const cfg = this.cfg;
124
- const allow = new Set(cfg.request.allowTopLevel);
125
- const src = toRecord(payload);
126
- const out = {};
127
- for (const key of Object.keys(src)) {
128
- if (allow.has(key)) {
129
- out[key] = src[key];
130
- }
131
- }
132
- const normalizedMessages = this.normalizeRequestMessages(out.messages, cfg.request);
133
- out.messages = normalizedMessages;
134
- this.normalizeTools(out, cfg.request);
135
- this.cleanupToolChoice(out);
136
- return out;
137
- }
138
- async applyResponseFilter(payload, _ctx) {
139
- // Bypass shape filtering by default to keep system running; can be turned off via env.
140
- // Default: RCC_COMPAT_FILTER_OFF_RESPONSES is treated as ON unless explicitly set to 0/false/off.
141
- const envFlag = String(process.env.RCC_COMPAT_FILTER_OFF_RESPONSES || '1').toLowerCase();
142
- const envBypass = !(envFlag === '0' || envFlag === 'false' || envFlag === 'off');
143
- try {
144
- const ctx = _ctx;
145
- const entryEndpoint = typeof ctx?.entryEndpoint === 'string' ? ctx.entryEndpoint : undefined;
146
- const fallbackEndpoint = typeof ctx?.endpoint === 'string' ? ctx.endpoint : undefined;
147
- const entry = String(entryEndpoint ?? fallbackEndpoint ?? '').toLowerCase();
148
- if (entry === '/v1/responses' || envBypass) {
149
- return payload;
150
- }
151
- }
152
- catch {
153
- if (envBypass) {
154
- return payload;
155
- }
156
- }
157
- const cfg = this.cfg;
158
- const src = toRecord(payload);
159
- const out = this.shallowPick(src, cfg.response.allowTopLevel);
160
- const choices = Array.isArray(src.choices) ? src.choices : [];
161
- out.choices = choices.map((choice, idx) => this.normalizeResponseChoice(choice, idx, cfg.response));
162
- if (src.usage && typeof src.usage === 'object') {
163
- out.usage = this.shallowPick(src.usage, cfg.response.usage?.allow || []);
164
- }
165
- return out;
166
- }
167
108
  normalizeRequestMessages(messages, requestCfg) {
168
109
  const entries = toArray(messages);
169
110
  const normalized = entries.map(entry => this.normalizeSingleMessage(entry, requestCfg));
@@ -186,6 +127,17 @@ export class UniversalShapeFilter {
186
127
  normalized.tool_call_id = msg.tool_call_id;
187
128
  }
188
129
  }
130
+ else if (Array.isArray(msg.content)) {
131
+ normalized.content = msg.content.map((part) => {
132
+ if (typeof part === 'string') {
133
+ return part;
134
+ }
135
+ if (isRecord(part)) {
136
+ return { ...part };
137
+ }
138
+ return part;
139
+ });
140
+ }
189
141
  else {
190
142
  normalized.content = (msg.content !== null && msg.content !== undefined) ? String(msg.content) : '';
191
143
  }
@@ -435,12 +387,7 @@ export class UniversalShapeFilter {
435
387
  if (typeof tc.id === 'string') {
436
388
  normalized.id = tc.id;
437
389
  }
438
- if (tc.mcp) {
439
- const existing = isRecord(normalized._glm) ? normalized._glm : {};
440
- normalized._glm = { ...existing, mcp: tc.mcp };
441
- }
442
390
  return normalized;
443
391
  });
444
392
  }
445
393
  }
446
- //# sourceMappingURL=universal-shape-filter.js.map
@@ -0,0 +1,17 @@
1
+ {
2
+ "id": "chat:gemini",
3
+ "protocol": "gemini-chat",
4
+ "request": {
5
+ "mappings": [
6
+ { "action": "snapshot", "phase": "compat-pre" },
7
+ {
8
+ "action": "gemini_web_search_request"
9
+ },
10
+ { "action": "snapshot", "phase": "compat-post" }
11
+ ]
12
+ },
13
+ "response": {
14
+ "mappings": []
15
+ }
16
+ }
17
+
@@ -1,17 +1,200 @@
1
1
  {
2
- "id": "chat:glm",
3
- "protocol": "openai-chat",
4
- "direction": "request",
2
+ "id": "chat:glm",
3
+ "protocol": "openai-chat",
4
+ "request": {
5
5
  "mappings": [
6
- {
7
- "action": "rename",
8
- "from": "response_format",
9
- "to": "metadata.generation.response_format"
10
- },
11
- {
12
- "action": "remove",
13
- "path": "metadata.clientModelId"
6
+ { "action": "snapshot", "phase": "compat-pre" },
7
+ { "action": "dto_unwrap" },
8
+ {
9
+ "action": "glm_image_content"
10
+ },
11
+ {
12
+ "action": "glm_vision_prompt"
13
+ },
14
+ {
15
+ "action": "rename",
16
+ "from": "response_format",
17
+ "to": "metadata.generation.response_format"
18
+ },
19
+ {
20
+ "action": "remove",
21
+ "path": "metadata.clientModelId"
22
+ },
23
+ {
24
+ "action": "shape_filter",
25
+ "target": "request",
26
+ "config": {
27
+ "request": {
28
+ "allowTopLevel": [
29
+ "model", "messages", "stream", "thinking", "do_sample", "temperature", "top_p",
30
+ "max_tokens", "tools", "tool_choice", "stop", "response_format", "web_search"
31
+ ],
32
+ "messages": {
33
+ "allowedRoles": ["system", "user", "assistant", "tool"],
34
+ "assistantWithToolCallsContentNull": true,
35
+ "toolContentStringify": false
36
+ },
37
+ "messagesRules": [],
38
+ "tools": {
39
+ "normalize": false,
40
+ "forceToolChoiceAuto": true
41
+ },
42
+ "assistantToolCalls": { "functionArgumentsType": "string" }
43
+ },
44
+ "response": {
45
+ "allowTopLevel": [
46
+ "id", "request_id", "created", "model",
47
+ "choices", "usage", "video_result", "web_search", "content_filter",
48
+ "required_action", "output", "output_text", "status"
49
+ ],
50
+ "choices": {
51
+ "required": true,
52
+ "message": {
53
+ "allow": ["role", "content", "reasoning_content", "audio", "tool_calls"],
54
+ "roleDefault": "assistant",
55
+ "contentNullWhenToolCalls": true,
56
+ "tool_calls": { "function": { "nameRequired": true, "argumentsType": "string" } }
57
+ },
58
+ "finish_reason": ["stop", "tool_calls", "length", "sensitive", "network_error"]
59
+ },
60
+ "usage": { "allow": ["prompt_tokens", "completion_tokens", "prompt_tokens_details", "total_tokens"] }
61
+ }
14
62
  }
15
- ],
16
- "filters": []
63
+ },
64
+ {
65
+ "action": "apply_rules",
66
+ "config": {
67
+ "tools": {
68
+ "function": {
69
+ "removeKeys": ["strict", "json_schema"]
70
+ }
71
+ },
72
+ "messages": {
73
+ "assistantToolCalls": {
74
+ "function": {
75
+ "removeKeys": ["strict"]
76
+ }
77
+ }
78
+ },
79
+ "topLevel": {
80
+ "conditional": [
81
+ { "when": { "tools": "empty" }, "remove": ["tool_choice"] }
82
+ ]
83
+ }
84
+ }
85
+ },
86
+ {
87
+ "action": "field_map",
88
+ "direction": "incoming",
89
+ "config": [
90
+ { "sourcePath": "usage.prompt_tokens", "targetPath": "usage.input_tokens", "type": "number" },
91
+ { "sourcePath": "usage.completion_tokens", "targetPath": "usage.output_tokens", "type": "number" },
92
+ { "sourcePath": "created", "targetPath": "created_at", "type": "number" },
93
+ { "sourcePath": "request_id", "targetPath": "request_id", "type": "string" },
94
+ { "sourcePath": "model", "targetPath": "model", "type": "string", "transform": "normalizeModelName" },
95
+ {
96
+ "sourcePath": "choices[*].message.tool_calls[*].function.arguments",
97
+ "targetPath": "choices[*].message.tool_calls[*].function.arguments",
98
+ "type": "string"
99
+ }
100
+ ]
101
+ },
102
+ { "action": "tool_schema_sanitize", "mode": "glm_shell" },
103
+ {
104
+ "action": "glm_web_search_request"
105
+ },
106
+ {
107
+ "action": "auto_thinking",
108
+ "config": {
109
+ "modelPrefixes": ["glm-4.7", "glm-4.6", "glm-4.5", "glm-z1"],
110
+ "excludePrefixes": ["glm-4.6v"]
111
+ }
112
+ },
113
+ { "action": "snapshot", "phase": "compat-post" },
114
+ { "action": "dto_rewrap" }
115
+ ]
116
+ },
117
+ "response": {
118
+ "mappings": [
119
+ { "action": "snapshot", "phase": "compat-pre" },
120
+ { "action": "dto_unwrap" },
121
+ {
122
+ "action": "resp_blacklist",
123
+ "config": {
124
+ "paths": ["usage.prompt_tokens_details.cached_tokens"],
125
+ "keepCritical": true
126
+ }
127
+ },
128
+ {
129
+ "action": "shape_filter",
130
+ "target": "response",
131
+ "config": {
132
+ "request": {
133
+ "allowTopLevel": [
134
+ "model", "messages", "stream", "thinking", "do_sample", "temperature", "top_p",
135
+ "max_tokens", "tools", "tool_choice", "stop", "response_format"
136
+ ],
137
+ "messages": {
138
+ "allowedRoles": ["system", "user", "assistant", "tool"],
139
+ "assistantWithToolCallsContentNull": true,
140
+ "toolContentStringify": false
141
+ },
142
+ "messagesRules": [],
143
+ "tools": {
144
+ "normalize": false,
145
+ "forceToolChoiceAuto": true
146
+ },
147
+ "assistantToolCalls": { "functionArgumentsType": "string" }
148
+ },
149
+ "response": {
150
+ "allowTopLevel": [
151
+ "id", "request_id", "created", "model",
152
+ "choices", "usage", "video_result", "web_search", "content_filter",
153
+ "required_action", "output", "output_text", "status"
154
+ ],
155
+ "choices": {
156
+ "required": true,
157
+ "message": {
158
+ "allow": ["role", "content", "reasoning_content", "audio", "tool_calls"],
159
+ "roleDefault": "assistant",
160
+ "contentNullWhenToolCalls": true,
161
+ "tool_calls": { "function": { "nameRequired": true, "argumentsType": "string" } }
162
+ },
163
+ "finish_reason": ["stop", "tool_calls", "length", "sensitive", "network_error"]
164
+ },
165
+ "usage": { "allow": ["prompt_tokens", "completion_tokens", "prompt_tokens_details", "total_tokens"] }
166
+ }
167
+ }
168
+ },
169
+ {
170
+ "action": "field_map",
171
+ "direction": "outgoing",
172
+ "config": [
173
+ { "sourcePath": "usage.input_tokens", "targetPath": "usage.prompt_tokens", "type": "number" },
174
+ { "sourcePath": "usage.output_tokens", "targetPath": "usage.completion_tokens", "type": "number" },
175
+ { "sourcePath": "usage.total_input_tokens", "targetPath": "usage.prompt_tokens", "type": "number" },
176
+ { "sourcePath": "usage.total_output_tokens", "targetPath": "usage.completion_tokens", "type": "number" },
177
+ { "sourcePath": "created_at", "targetPath": "created", "type": "number" },
178
+ { "sourcePath": "request_id", "targetPath": "request_id", "type": "string" },
179
+ {
180
+ "sourcePath": "choices[*].finish_reason",
181
+ "targetPath": "choices[*].finish_reason",
182
+ "type": "string",
183
+ "transform": "normalizeFinishReason"
184
+ },
185
+ {
186
+ "sourcePath": "choices[*].message.tool_calls[*].function.arguments",
187
+ "targetPath": "choices[*].message.tool_calls[*].function.arguments",
188
+ "type": "string"
189
+ }
190
+ ]
191
+ },
192
+ { "action": "tool_schema_sanitize", "mode": "glm_shell" },
193
+ { "action": "response_normalize" },
194
+ { "action": "extract_glm_tool_markup" },
195
+ { "action": "response_validate" },
196
+ { "action": "snapshot", "phase": "compat-post" },
197
+ { "action": "dto_rewrap" }
198
+ ]
199
+ }
17
200
  }