@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.
- package/README.md +18 -15
- package/dist/build-info.js +3 -3
- package/dist/build-info.js.map +1 -1
- package/dist/cli.js +32 -0
- package/dist/cli.js.map +1 -1
- package/dist/client/gemini-cli/gemini-cli-protocol-client.js +28 -5
- package/dist/client/gemini-cli/gemini-cli-protocol-client.js.map +1 -1
- package/dist/error-handling/quiet-error-handling-center.d.ts +9 -0
- package/dist/error-handling/quiet-error-handling-center.js +141 -0
- package/dist/error-handling/quiet-error-handling-center.js.map +1 -0
- package/dist/error-handling/route-error-hub.js +8 -2
- package/dist/error-handling/route-error-hub.js.map +1 -1
- package/dist/modules/pipeline/utils/colored-logger.d.ts +2 -0
- package/dist/modules/pipeline/utils/colored-logger.js +20 -3
- package/dist/modules/pipeline/utils/colored-logger.js.map +1 -1
- package/dist/providers/auth/antigravity-userinfo-helper.d.ts +10 -0
- package/dist/providers/auth/antigravity-userinfo-helper.js +140 -0
- package/dist/providers/auth/antigravity-userinfo-helper.js.map +1 -0
- package/dist/providers/auth/oauth-lifecycle.js +140 -8
- package/dist/providers/auth/oauth-lifecycle.js.map +1 -1
- package/dist/providers/auth/token-scanner/index.d.ts +32 -0
- package/dist/providers/auth/token-scanner/index.js +86 -0
- package/dist/providers/auth/token-scanner/index.js.map +1 -0
- package/dist/providers/auth/tokenfile-auth.d.ts +17 -0
- package/dist/providers/auth/tokenfile-auth.js +27 -5
- package/dist/providers/auth/tokenfile-auth.js.map +1 -1
- package/dist/providers/core/api/provider-types.d.ts +10 -0
- package/dist/providers/core/config/oauth-flows.d.ts +2 -0
- package/dist/providers/core/config/oauth-flows.js.map +1 -1
- package/dist/providers/core/config/provider-oauth-configs.js +85 -0
- package/dist/providers/core/config/provider-oauth-configs.js.map +1 -1
- package/dist/providers/core/config/service-profiles.js +15 -1
- package/dist/providers/core/config/service-profiles.js.map +1 -1
- package/dist/providers/core/runtime/base-provider.d.ts +8 -1
- package/dist/providers/core/runtime/base-provider.js +176 -108
- package/dist/providers/core/runtime/base-provider.js.map +1 -1
- package/dist/providers/core/runtime/gemini-cli-http-provider.d.ts +9 -5
- package/dist/providers/core/runtime/gemini-cli-http-provider.js +271 -69
- package/dist/providers/core/runtime/gemini-cli-http-provider.js.map +1 -1
- package/dist/providers/core/runtime/gemini-http-provider.d.ts +1 -2
- package/dist/providers/core/runtime/gemini-http-provider.js +0 -12
- package/dist/providers/core/runtime/gemini-http-provider.js.map +1 -1
- package/dist/providers/core/runtime/http-request-executor.d.ts +42 -0
- package/dist/providers/core/runtime/http-request-executor.js +133 -0
- package/dist/providers/core/runtime/http-request-executor.js.map +1 -0
- package/dist/providers/core/runtime/http-transport-provider.d.ts +32 -12
- package/dist/providers/core/runtime/http-transport-provider.js +464 -426
- package/dist/providers/core/runtime/http-transport-provider.js.map +1 -1
- package/dist/providers/core/runtime/provider-error-classifier.d.ts +25 -0
- package/dist/providers/core/runtime/provider-error-classifier.js +149 -0
- package/dist/providers/core/runtime/provider-error-classifier.js.map +1 -0
- package/dist/providers/core/runtime/provider-error-types.d.ts +23 -0
- package/dist/providers/core/runtime/provider-error-types.js +2 -0
- package/dist/providers/core/runtime/provider-error-types.js.map +1 -0
- package/dist/providers/core/runtime/provider-factory.d.ts +1 -0
- package/dist/providers/core/runtime/provider-factory.js +43 -8
- package/dist/providers/core/runtime/provider-factory.js.map +1 -1
- package/dist/providers/core/runtime/responses-provider.d.ts +3 -3
- package/dist/providers/core/runtime/responses-provider.js +48 -114
- package/dist/providers/core/runtime/responses-provider.js.map +1 -1
- package/dist/providers/core/strategies/oauth-auth-code-flow.js +11 -3
- package/dist/providers/core/strategies/oauth-auth-code-flow.js.map +1 -1
- package/dist/providers/core/utils/http-client.d.ts +5 -0
- package/dist/providers/core/utils/http-client.js +29 -3
- package/dist/providers/core/utils/http-client.js.map +1 -1
- package/dist/providers/core/utils/provider-error-reporter.js +8 -2
- package/dist/providers/core/utils/provider-error-reporter.js.map +1 -1
- package/dist/providers/core/utils/snapshot-writer.js +5 -1
- package/dist/providers/core/utils/snapshot-writer.js.map +1 -1
- package/dist/providers/profile/provider-profile-loader.js +8 -4
- package/dist/providers/profile/provider-profile-loader.js.map +1 -1
- package/dist/runtime/runtime-flags.d.ts +4 -0
- package/dist/runtime/runtime-flags.js +32 -0
- package/dist/runtime/runtime-flags.js.map +1 -0
- package/dist/server/handlers/handler-utils.js +29 -2
- package/dist/server/handlers/handler-utils.js.map +1 -1
- package/dist/server/handlers/messages-handler.js +27 -26
- package/dist/server/handlers/messages-handler.js.map +1 -1
- package/dist/server/handlers/responses-handler.js +35 -1
- package/dist/server/handlers/responses-handler.js.map +1 -1
- package/dist/server/runtime/http-server/index.d.ts +1 -0
- package/dist/server/runtime/http-server/index.js +39 -4
- package/dist/server/runtime/http-server/index.js.map +1 -1
- package/dist/server/runtime/http-server/request-executor.d.ts +4 -0
- package/dist/server/runtime/http-server/request-executor.js +99 -4
- package/dist/server/runtime/http-server/request-executor.js.map +1 -1
- package/dist/server/utils/sse-request-parser.d.ts +1 -0
- package/dist/server/utils/sse-request-parser.js +17 -6
- package/dist/server/utils/sse-request-parser.js.map +1 -1
- package/dist/server/utils/warmup-detector.d.ts +7 -0
- package/dist/server/utils/warmup-detector.js +125 -0
- package/dist/server/utils/warmup-detector.js.map +1 -0
- package/dist/server/utils/warmup-storm-tracker.d.ts +9 -0
- package/dist/server/utils/warmup-storm-tracker.js +61 -0
- package/dist/server/utils/warmup-storm-tracker.js.map +1 -0
- package/dist/utils/debug-utils.js +14 -0
- package/dist/utils/debug-utils.js.map +1 -1
- package/dist/utils/error-handler-registry.js +6 -5
- package/dist/utils/error-handler-registry.js.map +1 -1
- package/dist/utils/error-handling-utils.js +4 -3
- package/dist/utils/error-handling-utils.js.map +1 -1
- package/dist/utils/log-helpers.d.ts +6 -0
- package/dist/utils/log-helpers.js +90 -0
- package/dist/utils/log-helpers.js.map +1 -0
- package/dist/utils/logger.d.ts +8 -0
- package/dist/utils/logger.js +55 -2
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/snapshot-writer.js +2 -6
- package/dist/utils/snapshot-writer.js.map +1 -1
- package/node_modules/@jsonstudio/llms/dist/conversion/codecs/gemini-openai-codec.js +15 -1
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/auto-thinking.d.ts +6 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/auto-thinking.js +25 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/field-mapping.d.ts +14 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/field-mapping.js +155 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/glm-tool-extraction.d.ts +2 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/glm-tool-extraction.js +264 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/qwen-transform.d.ts +3 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/qwen-transform.js +209 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/request-rules.d.ts +24 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/request-rules.js +63 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-blacklist.d.ts +14 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-blacklist.js +85 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-normalize.d.ts +5 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-normalize.js +121 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-validate.d.ts +5 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/response-validate.js +76 -0
- package/{dist/providers/compat/utils/snapshot-writer.d.ts → node_modules/@jsonstudio/llms/dist/conversion/compat/actions/snapshot.d.ts} +2 -2
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/snapshot.js +21 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/actions/tool-schema.d.ts +6 -0
- package/{dist/providers/compat/glm/utils/tool-schema-helpers.js → node_modules/@jsonstudio/llms/dist/conversion/compat/actions/tool-schema.js} +6 -1
- package/{dist/providers/compat/filters → node_modules/@jsonstudio/llms/dist/conversion/compat/actions}/universal-shape-filter.d.ts +17 -22
- package/{dist/providers/compat/filters → node_modules/@jsonstudio/llms/dist/conversion/compat/actions}/universal-shape-filter.js +35 -99
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-glm.json +187 -13
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-iflow.json +177 -9
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-lmstudio.json +10 -2
- package/node_modules/@jsonstudio/llms/dist/conversion/compat/profiles/chat-qwen.json +14 -10
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-engine.d.ts +7 -2
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-engine.js +5 -665
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.d.ts +9 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-pipeline-executor.js +845 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/compat/compat-types.d.ts +47 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/hub-pipeline.d.ts +2 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/hub-pipeline.js +35 -1
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/stages/req_outbound/req_outbound_stage3_compat/index.js +2 -2
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/pipeline/target-utils.js +3 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/hub/response/response-runtime.js +19 -2
- package/node_modules/@jsonstudio/llms/dist/conversion/responses/responses-host-policy.d.ts +6 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/responses/responses-host-policy.js +14 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/responses/responses-openai-bridge.js +51 -2
- package/node_modules/@jsonstudio/llms/dist/conversion/shared/anthropic-message-utils.js +6 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/shared/responses-reasoning-registry.d.ts +4 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/shared/responses-reasoning-registry.js +62 -1
- package/node_modules/@jsonstudio/llms/dist/conversion/shared/responses-response-utils.js +23 -1
- package/node_modules/@jsonstudio/llms/dist/conversion/shared/tool-canonicalizer.d.ts +2 -0
- package/node_modules/@jsonstudio/llms/dist/conversion/shared/tool-filter-pipeline.js +11 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/bootstrap.js +251 -12
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/classifier.js +11 -4
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/context-advisor.d.ts +21 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/context-advisor.js +76 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/engine.d.ts +11 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/engine.js +187 -28
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/features.js +22 -457
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/health-manager.js +2 -7
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/message-utils.d.ts +7 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/message-utils.js +66 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/provider-registry.js +6 -2
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/token-estimator.d.ts +2 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/token-estimator.js +16 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/token-file-scanner.d.ts +15 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/token-file-scanner.js +56 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/tool-signals.d.ts +13 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/tool-signals.js +403 -0
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/types.d.ts +21 -1
- package/node_modules/@jsonstudio/llms/dist/router/virtual-router/types.js +1 -0
- package/node_modules/@jsonstudio/llms/package.json +2 -2
- package/package.json +13 -11
- package/scripts/README.md +26 -12
- package/scripts/auth-antigravity-token.mjs +64 -0
- package/scripts/auth-gemini-cli-token.mjs +96 -0
- package/scripts/auth-iflow-manual.mjs +81 -0
- package/scripts/auth-iflow-token-direct.mjs +87 -0
- package/scripts/auth-iflow-token.mjs +77 -0
- package/scripts/copy-compat-assets.mjs +3 -15
- package/scripts/install-verify.mjs +1 -0
- package/scripts/pack-mode.mjs +30 -1
- package/scripts/publish-rcc.mjs +31 -0
- package/scripts/replay-codex-sample.mjs +13 -8
- package/scripts/tests/chat-pipeline-blackbox.mjs +1 -1
- package/scripts/tools/capture-provider-goldens.mjs +8 -7
- package/scripts/verify-client-headers.mjs +224 -0
- package/dist/providers/compat/base-compatibility.d.ts +0 -27
- package/dist/providers/compat/base-compatibility.js +0 -143
- package/dist/providers/compat/base-compatibility.js.map +0 -1
- package/dist/providers/compat/compat-directory-loader.d.ts +0 -4
- package/dist/providers/compat/compat-directory-loader.js +0 -85
- package/dist/providers/compat/compat-directory-loader.js.map +0 -1
- package/dist/providers/compat/compatibility-adapter.d.ts +0 -18
- package/dist/providers/compat/compatibility-adapter.js +0 -104
- package/dist/providers/compat/compatibility-adapter.js.map +0 -1
- package/dist/providers/compat/compatibility-factory.d.ts +0 -57
- package/dist/providers/compat/compatibility-factory.js +0 -155
- package/dist/providers/compat/compatibility-factory.js.map +0 -1
- package/dist/providers/compat/compatibility-interface.d.ts +0 -35
- package/dist/providers/compat/compatibility-interface.js +0 -2
- package/dist/providers/compat/compatibility-interface.js.map +0 -1
- package/dist/providers/compat/compatibility-manager.d.ts +0 -85
- package/dist/providers/compat/compatibility-manager.js +0 -368
- package/dist/providers/compat/compatibility-manager.js.map +0 -1
- package/dist/providers/compat/config/config-compatibility.d.ts +0 -28
- package/dist/providers/compat/config/config-compatibility.js +0 -95
- package/dist/providers/compat/config/config-compatibility.js.map +0 -1
- package/dist/providers/compat/field-mapping.d.ts +0 -102
- package/dist/providers/compat/field-mapping.js +0 -447
- package/dist/providers/compat/field-mapping.js.map +0 -1
- package/dist/providers/compat/filters/blacklist-sanitizer.d.ts +0 -45
- package/dist/providers/compat/filters/blacklist-sanitizer.js +0 -133
- package/dist/providers/compat/filters/blacklist-sanitizer.js.map +0 -1
- package/dist/providers/compat/filters/response-blacklist-sanitizer.d.ts +0 -28
- package/dist/providers/compat/filters/response-blacklist-sanitizer.js +0 -138
- package/dist/providers/compat/filters/response-blacklist-sanitizer.js.map +0 -1
- package/dist/providers/compat/filters/universal-shape-filter.js.map +0 -1
- package/dist/providers/compat/glm/config/blacklist-rules.json +0 -22
- package/dist/providers/compat/glm/config/field-mappings.json +0 -92
- package/dist/providers/compat/glm/config/response-blacklist.json +0 -7
- package/dist/providers/compat/glm/config/shape-filters.json +0 -37
- package/dist/providers/compat/glm/field-mapping/field-mapping-processor.d.ts +0 -28
- package/dist/providers/compat/glm/field-mapping/field-mapping-processor.js +0 -306
- package/dist/providers/compat/glm/field-mapping/field-mapping-processor.js.map +0 -1
- package/dist/providers/compat/glm/functions/glm-processor.d.ts +0 -50
- package/dist/providers/compat/glm/functions/glm-processor.js +0 -134
- package/dist/providers/compat/glm/functions/glm-processor.js.map +0 -1
- package/dist/providers/compat/glm/glm-compatibility.d.ts +0 -34
- package/dist/providers/compat/glm/glm-compatibility.js +0 -117
- package/dist/providers/compat/glm/glm-compatibility.js.map +0 -1
- package/dist/providers/compat/glm/hooks/base-hook.d.ts +0 -21
- package/dist/providers/compat/glm/hooks/base-hook.js +0 -53
- package/dist/providers/compat/glm/hooks/base-hook.js.map +0 -1
- package/dist/providers/compat/glm/hooks/glm-request-validation-hook.d.ts +0 -24
- package/dist/providers/compat/glm/hooks/glm-request-validation-hook.js +0 -268
- package/dist/providers/compat/glm/hooks/glm-request-validation-hook.js.map +0 -1
- package/dist/providers/compat/glm/hooks/glm-response-normalization-hook.d.ts +0 -21
- package/dist/providers/compat/glm/hooks/glm-response-normalization-hook.js +0 -171
- package/dist/providers/compat/glm/hooks/glm-response-normalization-hook.js.map +0 -1
- package/dist/providers/compat/glm/hooks/glm-response-validation-hook.d.ts +0 -25
- package/dist/providers/compat/glm/hooks/glm-response-validation-hook.js +0 -236
- package/dist/providers/compat/glm/hooks/glm-response-validation-hook.js.map +0 -1
- package/dist/providers/compat/glm/hooks/glm-tool-cleaning-hook.d.ts +0 -26
- package/dist/providers/compat/glm/hooks/glm-tool-cleaning-hook.js +0 -186
- package/dist/providers/compat/glm/hooks/glm-tool-cleaning-hook.js.map +0 -1
- package/dist/providers/compat/glm/index.d.ts +0 -24
- package/dist/providers/compat/glm/index.js +0 -29
- package/dist/providers/compat/glm/index.js.map +0 -1
- package/dist/providers/compat/glm/utils/tool-schema-helpers.d.ts +0 -3
- package/dist/providers/compat/glm/utils/tool-schema-helpers.js.map +0 -1
- package/dist/providers/compat/iflow/config/field-mappings.json +0 -92
- package/dist/providers/compat/iflow/config/shape-filters.json +0 -37
- package/dist/providers/compat/iflow/field-mapping/iflow-field-mapping-processor.d.ts +0 -34
- package/dist/providers/compat/iflow/field-mapping/iflow-field-mapping-processor.js +0 -386
- package/dist/providers/compat/iflow/field-mapping/iflow-field-mapping-processor.js.map +0 -1
- package/dist/providers/compat/iflow/functions/iflow-processor.d.ts +0 -53
- package/dist/providers/compat/iflow/functions/iflow-processor.js +0 -215
- package/dist/providers/compat/iflow/functions/iflow-processor.js.map +0 -1
- package/dist/providers/compat/iflow/hooks/base-hook.d.ts +0 -23
- package/dist/providers/compat/iflow/hooks/base-hook.js +0 -59
- package/dist/providers/compat/iflow/hooks/base-hook.js.map +0 -1
- package/dist/providers/compat/iflow/hooks/iflow-request-validation-hook.d.ts +0 -23
- package/dist/providers/compat/iflow/hooks/iflow-request-validation-hook.js +0 -279
- package/dist/providers/compat/iflow/hooks/iflow-request-validation-hook.js.map +0 -1
- package/dist/providers/compat/iflow/hooks/iflow-response-normalization-hook.d.ts +0 -20
- package/dist/providers/compat/iflow/hooks/iflow-response-normalization-hook.js +0 -180
- package/dist/providers/compat/iflow/hooks/iflow-response-normalization-hook.js.map +0 -1
- package/dist/providers/compat/iflow/hooks/iflow-response-validation-hook.d.ts +0 -23
- package/dist/providers/compat/iflow/hooks/iflow-response-validation-hook.js +0 -232
- package/dist/providers/compat/iflow/hooks/iflow-response-validation-hook.js.map +0 -1
- package/dist/providers/compat/iflow/hooks/iflow-tool-cleaning-hook.d.ts +0 -25
- package/dist/providers/compat/iflow/hooks/iflow-tool-cleaning-hook.js +0 -216
- package/dist/providers/compat/iflow/hooks/iflow-tool-cleaning-hook.js.map +0 -1
- package/dist/providers/compat/iflow/iflow-compatibility.d.ts +0 -24
- package/dist/providers/compat/iflow/iflow-compatibility.js +0 -94
- package/dist/providers/compat/iflow/iflow-compatibility.js.map +0 -1
- package/dist/providers/compat/index.d.ts +0 -59
- package/dist/providers/compat/index.js +0 -83
- package/dist/providers/compat/index.js.map +0 -1
- package/dist/providers/compat/lmstudio-compatibility.d.ts +0 -44
- package/dist/providers/compat/lmstudio-compatibility.js +0 -193
- package/dist/providers/compat/lmstudio-compatibility.js.map +0 -1
- package/dist/providers/compat/passthrough-compatibility.d.ts +0 -29
- package/dist/providers/compat/passthrough-compatibility.js +0 -83
- package/dist/providers/compat/passthrough-compatibility.js.map +0 -1
- package/dist/providers/compat/profiles/chat/glm/index.d.ts +0 -6
- package/dist/providers/compat/profiles/chat/glm/index.js +0 -6
- package/dist/providers/compat/profiles/chat/glm/index.js.map +0 -1
- package/dist/providers/compat/profiles/chat/iflow/index.d.ts +0 -6
- package/dist/providers/compat/profiles/chat/iflow/index.js +0 -6
- package/dist/providers/compat/profiles/chat/iflow/index.js.map +0 -1
- package/dist/providers/compat/profiles/chat/lmstudio/index.d.ts +0 -6
- package/dist/providers/compat/profiles/chat/lmstudio/index.js +0 -6
- package/dist/providers/compat/profiles/chat/lmstudio/index.js.map +0 -1
- package/dist/providers/compat/profiles/chat/qwen/index.d.ts +0 -6
- package/dist/providers/compat/profiles/chat/qwen/index.js +0 -6
- package/dist/providers/compat/profiles/chat/qwen/index.js.map +0 -1
- package/dist/providers/compat/profiles/compat/passthrough/index.d.ts +0 -6
- package/dist/providers/compat/profiles/compat/passthrough/index.js +0 -6
- package/dist/providers/compat/profiles/compat/passthrough/index.js.map +0 -1
- package/dist/providers/compat/profiles/responses/c4m/index.d.ts +0 -6
- package/dist/providers/compat/profiles/responses/c4m/index.js +0 -6
- package/dist/providers/compat/profiles/responses/c4m/index.js.map +0 -1
- package/dist/providers/compat/profiles/responses/default/index.d.ts +0 -6
- package/dist/providers/compat/profiles/responses/default/index.js +0 -6
- package/dist/providers/compat/profiles/responses/default/index.js.map +0 -1
- package/dist/providers/compat/profiles/responses/fai/index.d.ts +0 -6
- package/dist/providers/compat/profiles/responses/fai/index.js +0 -6
- package/dist/providers/compat/profiles/responses/fai/index.js.map +0 -1
- package/dist/providers/compat/profiles/responses/fc/index.d.ts +0 -6
- package/dist/providers/compat/profiles/responses/fc/index.js +0 -6
- package/dist/providers/compat/profiles/responses/fc/index.js.map +0 -1
- package/dist/providers/compat/qwen/index.d.ts +0 -4
- package/dist/providers/compat/qwen/index.js +0 -6
- package/dist/providers/compat/qwen/index.js.map +0 -1
- package/dist/providers/compat/qwen-compatibility.d.ts +0 -52
- package/dist/providers/compat/qwen-compatibility.js +0 -330
- package/dist/providers/compat/qwen-compatibility.js.map +0 -1
- package/dist/providers/compat/register-compat-module.d.ts +0 -8
- package/dist/providers/compat/register-compat-module.js +0 -53
- package/dist/providers/compat/register-compat-module.js.map +0 -1
- package/dist/providers/compat/responses/c4m-responses-compatibility.d.ts +0 -27
- package/dist/providers/compat/responses/c4m-responses-compatibility.js +0 -197
- package/dist/providers/compat/responses/c4m-responses-compatibility.js.map +0 -1
- package/dist/providers/compat/standard-compatibility-utils.d.ts +0 -1
- package/dist/providers/compat/standard-compatibility-utils.js +0 -77
- package/dist/providers/compat/standard-compatibility-utils.js.map +0 -1
- package/dist/providers/compat/standard-compatibility.d.ts +0 -31
- package/dist/providers/compat/standard-compatibility.js +0 -118
- package/dist/providers/compat/standard-compatibility.js.map +0 -1
- package/dist/providers/compat/utils/snapshot-writer.js +0 -62
- package/dist/providers/compat/utils/snapshot-writer.js.map +0 -1
- package/scripts/check-glm-compat.mjs +0 -47
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { JsonObject, JsonValue } from '../../types/json.js';
|
|
2
|
+
import type { FilterConfig as ShapeFilterConfig } from '../../../compat/actions/universal-shape-filter.js';
|
|
3
|
+
import type { ResponseBlacklistConfig } from '../../../compat/actions/response-blacklist.js';
|
|
4
|
+
import type { FieldMapping } from '../../../compat/actions/field-mapping.js';
|
|
5
|
+
import type { RequestRulesConfig } from '../../../compat/actions/request-rules.js';
|
|
6
|
+
import type { AutoThinkingConfig } from '../../../compat/actions/auto-thinking.js';
|
|
7
|
+
import type { ResponseNormalizeConfig } from '../../../compat/actions/response-normalize.js';
|
|
8
|
+
import type { ResponseValidateConfig } from '../../../compat/actions/response-validate.js';
|
|
2
9
|
export type CompatDirection = 'request' | 'response';
|
|
3
10
|
export interface CompatProfileConfig {
|
|
4
11
|
id: string;
|
|
@@ -51,6 +58,46 @@ export type MappingInstruction = {
|
|
|
51
58
|
fallback?: JsonValue;
|
|
52
59
|
} | {
|
|
53
60
|
action: 'convert_responses_output_to_choices';
|
|
61
|
+
} | {
|
|
62
|
+
action: 'extract_glm_tool_markup';
|
|
63
|
+
} | {
|
|
64
|
+
action: 'dto_unwrap';
|
|
65
|
+
} | {
|
|
66
|
+
action: 'dto_rewrap';
|
|
67
|
+
} | {
|
|
68
|
+
action: 'shape_filter';
|
|
69
|
+
config: ShapeFilterConfig;
|
|
70
|
+
target?: CompatDirection;
|
|
71
|
+
} | {
|
|
72
|
+
action: 'field_map';
|
|
73
|
+
direction?: 'incoming' | 'outgoing';
|
|
74
|
+
config: FieldMapping[];
|
|
75
|
+
} | {
|
|
76
|
+
action: 'tool_schema_sanitize';
|
|
77
|
+
mode?: 'glm_shell';
|
|
78
|
+
} | {
|
|
79
|
+
action: 'apply_rules';
|
|
80
|
+
config: RequestRulesConfig;
|
|
81
|
+
} | {
|
|
82
|
+
action: 'auto_thinking';
|
|
83
|
+
config: AutoThinkingConfig;
|
|
84
|
+
} | {
|
|
85
|
+
action: 'snapshot';
|
|
86
|
+
phase: 'compat-pre' | 'compat-post';
|
|
87
|
+
channel?: string;
|
|
88
|
+
} | {
|
|
89
|
+
action: 'resp_blacklist';
|
|
90
|
+
config: ResponseBlacklistConfig;
|
|
91
|
+
} | {
|
|
92
|
+
action: 'response_normalize';
|
|
93
|
+
config?: ResponseNormalizeConfig;
|
|
94
|
+
} | {
|
|
95
|
+
action: 'response_validate';
|
|
96
|
+
config?: ResponseValidateConfig;
|
|
97
|
+
} | {
|
|
98
|
+
action: 'qwen_request_transform';
|
|
99
|
+
} | {
|
|
100
|
+
action: 'qwen_response_transform';
|
|
54
101
|
};
|
|
55
102
|
export type FilterInstruction = {
|
|
56
103
|
action: 'rate_limit_text';
|
|
@@ -142,6 +142,8 @@ export class HubPipeline {
|
|
|
142
142
|
catch {
|
|
143
143
|
// logging must not break routing
|
|
144
144
|
}
|
|
145
|
+
const outboundStream = this.resolveOutboundStreamIntent(routing.target?.streaming);
|
|
146
|
+
this.applyOutboundStreamPreference(workingRequest, outboundStream);
|
|
145
147
|
const outboundAdapterContext = this.buildAdapterContext(normalized, routing.target);
|
|
146
148
|
if (routing.target?.compatibilityProfile) {
|
|
147
149
|
outboundAdapterContext.compatibilityProfile = routing.target.compatibilityProfile;
|
|
@@ -226,7 +228,8 @@ export class HubPipeline {
|
|
|
226
228
|
stream: normalized.stream,
|
|
227
229
|
processMode: normalized.processMode,
|
|
228
230
|
routeHint: normalized.routeHint,
|
|
229
|
-
target: routing.target
|
|
231
|
+
target: routing.target,
|
|
232
|
+
...(typeof outboundStream === 'boolean' ? { providerStream: outboundStream } : {})
|
|
230
233
|
};
|
|
231
234
|
return {
|
|
232
235
|
requestId: normalized.id,
|
|
@@ -508,6 +511,37 @@ export class HubPipeline {
|
|
|
508
511
|
}
|
|
509
512
|
return undefined;
|
|
510
513
|
}
|
|
514
|
+
resolveOutboundStreamIntent(providerPreference) {
|
|
515
|
+
if (providerPreference === 'always') {
|
|
516
|
+
return true;
|
|
517
|
+
}
|
|
518
|
+
if (providerPreference === 'never') {
|
|
519
|
+
return false;
|
|
520
|
+
}
|
|
521
|
+
return undefined;
|
|
522
|
+
}
|
|
523
|
+
applyOutboundStreamPreference(request, stream) {
|
|
524
|
+
if (!request || typeof request !== 'object') {
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
const parameters = request.parameters || {};
|
|
528
|
+
const nextParameters = { ...parameters };
|
|
529
|
+
if (typeof stream === 'boolean') {
|
|
530
|
+
nextParameters.stream = stream;
|
|
531
|
+
}
|
|
532
|
+
else if ('stream' in nextParameters) {
|
|
533
|
+
delete nextParameters.stream;
|
|
534
|
+
}
|
|
535
|
+
request.parameters = nextParameters;
|
|
536
|
+
if (request.metadata && typeof request.metadata === 'object') {
|
|
537
|
+
if (typeof stream === 'boolean') {
|
|
538
|
+
request.metadata.outboundStream = stream;
|
|
539
|
+
}
|
|
540
|
+
else if ('outboundStream' in request.metadata) {
|
|
541
|
+
delete request.metadata.outboundStream;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
511
545
|
}
|
|
512
546
|
function normalizeToolCallIdStyleCandidate(value) {
|
|
513
547
|
if (typeof value !== 'string') {
|
|
@@ -5,7 +5,7 @@ function pickCompatProfile(adapterContext) {
|
|
|
5
5
|
}
|
|
6
6
|
export async function runReqOutboundStage3Compat(options) {
|
|
7
7
|
const profile = pickCompatProfile(options.adapterContext);
|
|
8
|
-
const result = applyRequestCompat(profile, options.payload);
|
|
8
|
+
const result = applyRequestCompat(profile, options.payload, { adapterContext: options.adapterContext });
|
|
9
9
|
options.stageRecorder?.record('req_outbound_stage3_compat', {
|
|
10
10
|
applied: Boolean(result.appliedProfile),
|
|
11
11
|
profile: result.appliedProfile || profile || 'passthrough'
|
|
@@ -14,7 +14,7 @@ export async function runReqOutboundStage3Compat(options) {
|
|
|
14
14
|
}
|
|
15
15
|
export function runRespInboundStageCompatResponse(options) {
|
|
16
16
|
const profile = pickCompatProfile(options.adapterContext);
|
|
17
|
-
const result = applyResponseCompat(profile, options.payload);
|
|
17
|
+
const result = applyResponseCompat(profile, options.payload, { adapterContext: options.adapterContext });
|
|
18
18
|
options.stageRecorder?.record('resp_inbound_stage_compat', {
|
|
19
19
|
applied: Boolean(result.appliedProfile),
|
|
20
20
|
profile: result.appliedProfile || profile || 'passthrough'
|
|
@@ -12,6 +12,9 @@ export function applyTargetMetadata(metadata, target, routeName, originalModel)
|
|
|
12
12
|
if (target.responsesConfig?.toolCallIdStyle) {
|
|
13
13
|
metadata.toolCallIdStyle = target.responsesConfig.toolCallIdStyle;
|
|
14
14
|
}
|
|
15
|
+
if (target.streaming) {
|
|
16
|
+
metadata.targetStreaming = target.streaming;
|
|
17
|
+
}
|
|
15
18
|
if (originalModel && typeof originalModel === 'string' && originalModel.trim()) {
|
|
16
19
|
const trimmed = originalModel.trim();
|
|
17
20
|
if (typeof metadata.originalModelId !== 'string' || !metadata.originalModelId) {
|
|
@@ -3,7 +3,7 @@ import { deriveToolCallKey } from '../../shared/tool-call-utils.js';
|
|
|
3
3
|
import { createBridgeActionState, runBridgeActionPipeline } from '../../shared/bridge-actions.js';
|
|
4
4
|
import { resolveBridgePolicy, resolvePolicyActions } from '../../shared/bridge-policies.js';
|
|
5
5
|
import { normalizeAnthropicToolName } from '../../shared/anthropic-message-utils.js';
|
|
6
|
-
import { registerResponsesReasoning, consumeResponsesReasoning, registerResponsesOutputTextMeta, consumeResponsesOutputTextMeta } from '../../shared/responses-reasoning-registry.js';
|
|
6
|
+
import { registerResponsesReasoning, consumeResponsesReasoning, registerResponsesOutputTextMeta, consumeResponsesOutputTextMeta, consumeResponsesPayloadSnapshot, registerResponsesPayloadSnapshot, consumeResponsesPassthrough, registerResponsesPassthrough } from '../../shared/responses-reasoning-registry.js';
|
|
7
7
|
function flattenAnthropicContent(content) {
|
|
8
8
|
if (typeof content === 'string')
|
|
9
9
|
return content;
|
|
@@ -262,6 +262,20 @@ export function buildOpenAIChatFromAnthropicMessage(payload, options) {
|
|
|
262
262
|
if (preservedOutputMeta) {
|
|
263
263
|
chatResponse.__responses_output_text_meta = preservedOutputMeta;
|
|
264
264
|
}
|
|
265
|
+
const payloadSnapshot = consumeResponsesPayloadSnapshot(chatResponse.id);
|
|
266
|
+
if (payloadSnapshot) {
|
|
267
|
+
registerResponsesPayloadSnapshot(chatResponse.id, payloadSnapshot);
|
|
268
|
+
if (typeof chatResponse.request_id !== 'string') {
|
|
269
|
+
chatResponse.request_id = chatResponse.id;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const passthroughPayload = consumeResponsesPassthrough(chatResponse.id);
|
|
273
|
+
if (passthroughPayload) {
|
|
274
|
+
registerResponsesPassthrough(chatResponse.id, passthroughPayload);
|
|
275
|
+
if (typeof chatResponse.request_id !== 'string') {
|
|
276
|
+
chatResponse.request_id = chatResponse.id;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
265
279
|
if (Object.keys(aliasCollector).length && !chatResponse.anthropicToolNameMap) {
|
|
266
280
|
chatResponse.anthropicToolNameMap = aliasCollector;
|
|
267
281
|
}
|
|
@@ -358,8 +372,11 @@ export function buildAnthropicResponseFromChat(chatResponse, options) {
|
|
|
358
372
|
default: return 'end_turn';
|
|
359
373
|
}
|
|
360
374
|
})();
|
|
375
|
+
const canonicalId = typeof chatResponse.request_id === 'string'
|
|
376
|
+
? chatResponse.request_id
|
|
377
|
+
: (typeof chatResponse.id === 'string' ? chatResponse.id : `resp_${Date.now()}`);
|
|
361
378
|
const raw = {
|
|
362
|
-
id:
|
|
379
|
+
id: canonicalId,
|
|
363
380
|
type: 'message',
|
|
364
381
|
role: 'assistant',
|
|
365
382
|
content: contentBlocks,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ResponsesRequestContext } from './responses-openai-bridge.js';
|
|
2
|
+
export interface ResponsesHostPolicyResult {
|
|
3
|
+
shouldStripHostManagedFields: boolean;
|
|
4
|
+
targetProtocol: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function evaluateResponsesHostPolicy(context?: ResponsesRequestContext, targetProtocol?: string): ResponsesHostPolicyResult;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function evaluateResponsesHostPolicy(context, targetProtocol) {
|
|
2
|
+
const protocol = typeof targetProtocol === 'string' && targetProtocol.trim()
|
|
3
|
+
? targetProtocol
|
|
4
|
+
: (typeof context?.targetProtocol === 'string' && context.targetProtocol.trim()
|
|
5
|
+
? context.targetProtocol
|
|
6
|
+
: 'responses');
|
|
7
|
+
const normalized = protocol.toLowerCase();
|
|
8
|
+
const shouldStrip = normalized !== 'openai-responses' &&
|
|
9
|
+
normalized !== 'responses';
|
|
10
|
+
return {
|
|
11
|
+
shouldStripHostManagedFields: shouldStrip,
|
|
12
|
+
targetProtocol: normalized
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ensureBridgeInstructions } from '../shared/bridge-instructions.js';
|
|
2
|
+
import { evaluateResponsesHostPolicy } from './responses-host-policy.js';
|
|
2
3
|
import { convertMessagesToBridgeInput, convertBridgeInputToChatMessages } from '../shared/bridge-message-utils.js';
|
|
3
4
|
import { createToolCallIdTransformer, enforceToolCallIdStyle, resolveToolCallIdStyle, stripInternalToolingMetadata, sanitizeResponsesFunctionName } from '../shared/responses-tool-utils.js';
|
|
4
5
|
import { mapBridgeToolsToChat, mapChatToolsToBridge } from '../shared/tool-mapping.js';
|
|
@@ -8,6 +9,7 @@ import { normalizeMessageReasoningTools } from '../shared/reasoning-tool-normali
|
|
|
8
9
|
import { createBridgeActionState, runBridgeActionPipeline } from '../shared/bridge-actions.js';
|
|
9
10
|
import { resolveBridgePolicy, resolvePolicyActions } from '../shared/bridge-policies.js';
|
|
10
11
|
import { buildResponsesOutputFromChat } from '../shared/responses-output-builder.js';
|
|
12
|
+
import { consumeResponsesPayloadSnapshot, consumeResponsesPassthrough } from '../shared/responses-reasoning-registry.js';
|
|
11
13
|
function isObject(v) {
|
|
12
14
|
return !!v && typeof v === 'object' && !Array.isArray(v);
|
|
13
15
|
}
|
|
@@ -257,12 +259,20 @@ export function buildResponsesRequestFromChat(payload, ctx, extras) {
|
|
|
257
259
|
else if (metadataExtraFields?.include !== undefined && out.include === undefined) {
|
|
258
260
|
out.include = metadataExtraFields.include;
|
|
259
261
|
}
|
|
260
|
-
|
|
262
|
+
const stripHostFields = shouldStripHostManagedFields(ctx);
|
|
263
|
+
if (stripHostFields) {
|
|
264
|
+
delete out.store;
|
|
265
|
+
}
|
|
266
|
+
else if (ctx?.store !== undefined && out.store === undefined) {
|
|
261
267
|
out.store = ctx.store;
|
|
262
268
|
}
|
|
263
269
|
else if (metadataExtraFields?.store !== undefined && out.store === undefined) {
|
|
264
270
|
out.store = metadataExtraFields.store;
|
|
265
271
|
}
|
|
272
|
+
else if (out.store === undefined) {
|
|
273
|
+
// Chat 入口无 store 概念,但 Responses provider 仍要求显式声明。
|
|
274
|
+
out.store = false;
|
|
275
|
+
}
|
|
266
276
|
if (ctx?.toolChoice !== undefined && out.tool_choice === undefined) {
|
|
267
277
|
out.tool_choice = ctx.toolChoice;
|
|
268
278
|
}
|
|
@@ -433,6 +443,17 @@ export function buildResponsesPayloadFromChat(payload, context) {
|
|
|
433
443
|
const response = unwrapData(payload);
|
|
434
444
|
if (!response || typeof response !== 'object')
|
|
435
445
|
return payload;
|
|
446
|
+
const snapshotKey = resolveSnapshotLookupKey(response, context);
|
|
447
|
+
if (snapshotKey) {
|
|
448
|
+
const passthrough = consumeResponsesPassthrough(snapshotKey);
|
|
449
|
+
if (passthrough) {
|
|
450
|
+
return passthrough;
|
|
451
|
+
}
|
|
452
|
+
const snapshot = consumeResponsesPayloadSnapshot(snapshotKey);
|
|
453
|
+
if (snapshot) {
|
|
454
|
+
return snapshot;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
436
457
|
if (response.object === 'response' && Array.isArray(response.output)) {
|
|
437
458
|
return response;
|
|
438
459
|
}
|
|
@@ -499,10 +520,22 @@ export function buildResponsesPayloadFromChat(payload, context) {
|
|
|
499
520
|
out.required_action = outputBuild.requiredAction;
|
|
500
521
|
// Do not inject captured tool results here; keep Chat back-half behavior standard.
|
|
501
522
|
if (context) {
|
|
502
|
-
for (const k of ['metadata', 'parallel_tool_calls', 'tool_choice', 'include'
|
|
523
|
+
for (const k of ['metadata', 'parallel_tool_calls', 'tool_choice', 'include']) {
|
|
503
524
|
if (context[k] !== undefined)
|
|
504
525
|
out[k] = context[k];
|
|
505
526
|
}
|
|
527
|
+
if (!shouldStripHostManagedFields(context) && context.store !== undefined) {
|
|
528
|
+
out.store = context.store;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
if (typeof response.request_id === 'string') {
|
|
532
|
+
out.request_id = response.request_id;
|
|
533
|
+
}
|
|
534
|
+
else if (typeof response.id === 'string') {
|
|
535
|
+
out.request_id = response.id;
|
|
536
|
+
}
|
|
537
|
+
else if (typeof context?.requestId === 'string') {
|
|
538
|
+
out.request_id = context.requestId;
|
|
506
539
|
}
|
|
507
540
|
if (out.metadata) {
|
|
508
541
|
stripInternalToolingMetadata(out.metadata);
|
|
@@ -524,6 +557,22 @@ function unwrapData(value) {
|
|
|
524
557
|
}
|
|
525
558
|
return current;
|
|
526
559
|
}
|
|
560
|
+
function resolveSnapshotLookupKey(response, context) {
|
|
561
|
+
if (typeof response?.request_id === 'string') {
|
|
562
|
+
return response.request_id;
|
|
563
|
+
}
|
|
564
|
+
if (typeof context?.requestId === 'string') {
|
|
565
|
+
return context.requestId;
|
|
566
|
+
}
|
|
567
|
+
if (typeof response?.id === 'string') {
|
|
568
|
+
return response.id;
|
|
569
|
+
}
|
|
570
|
+
return undefined;
|
|
571
|
+
}
|
|
572
|
+
function shouldStripHostManagedFields(context) {
|
|
573
|
+
const result = evaluateResponsesHostPolicy(context, typeof context?.targetProtocol === 'string' ? context?.targetProtocol : undefined);
|
|
574
|
+
return result.shouldStripHostManagedFields;
|
|
575
|
+
}
|
|
527
576
|
export function extractRequestIdFromResponse(response) {
|
|
528
577
|
if (response && typeof response === 'object' && 'metadata' in response && response.metadata && typeof response.metadata === 'object') {
|
|
529
578
|
const meta = response.metadata;
|
|
@@ -336,6 +336,12 @@ export function buildOpenAIChatFromAnthropic(payload) {
|
|
|
336
336
|
request.top_p = body.top_p;
|
|
337
337
|
if (typeof body.stream === 'boolean')
|
|
338
338
|
request.stream = body.stream;
|
|
339
|
+
if (typeof body.id === 'string') {
|
|
340
|
+
request.request_id = body.id;
|
|
341
|
+
}
|
|
342
|
+
else if (typeof body.request_id === 'string') {
|
|
343
|
+
request.request_id = body.request_id;
|
|
344
|
+
}
|
|
339
345
|
if ('tool_choice' in body)
|
|
340
346
|
request.tool_choice = body.tool_choice;
|
|
341
347
|
const normalizedTools = mapAnthropicToolsToChat(body.tools);
|
package/node_modules/@jsonstudio/llms/dist/conversion/shared/responses-reasoning-registry.d.ts
CHANGED
|
@@ -6,3 +6,7 @@ export declare function registerResponsesReasoning(id: unknown, segments: string
|
|
|
6
6
|
export declare function consumeResponsesReasoning(id: unknown): string[] | undefined;
|
|
7
7
|
export declare function registerResponsesOutputTextMeta(id: unknown, meta: ResponsesOutputTextMeta | undefined): void;
|
|
8
8
|
export declare function consumeResponsesOutputTextMeta(id: unknown): ResponsesOutputTextMeta | undefined;
|
|
9
|
+
export declare function registerResponsesPayloadSnapshot(id: unknown, snapshot: Record<string, unknown> | undefined): void;
|
|
10
|
+
export declare function consumeResponsesPayloadSnapshot(id: unknown): Record<string, unknown> | undefined;
|
|
11
|
+
export declare function registerResponsesPassthrough(id: unknown, payload: Record<string, unknown> | undefined): void;
|
|
12
|
+
export declare function consumeResponsesPassthrough(id: unknown): Record<string, unknown> | undefined;
|
package/node_modules/@jsonstudio/llms/dist/conversion/shared/responses-reasoning-registry.js
CHANGED
|
@@ -11,10 +11,27 @@ function pruneEntry(id) {
|
|
|
11
11
|
const entry = registry.get(id);
|
|
12
12
|
if (!entry)
|
|
13
13
|
return;
|
|
14
|
-
if (!entry.reasoning && !entry.outputText) {
|
|
14
|
+
if (!entry.reasoning && !entry.outputText && !entry.payloadSnapshot && !entry.passthroughPayload) {
|
|
15
15
|
registry.delete(id);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
+
function cloneSnapshot(snapshot) {
|
|
19
|
+
try {
|
|
20
|
+
const structuredCloneImpl = globalThis.structuredClone;
|
|
21
|
+
if (typeof structuredCloneImpl === 'function') {
|
|
22
|
+
return structuredCloneImpl(snapshot);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
/* ignore structuredClone failures */
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
return JSON.parse(JSON.stringify(snapshot));
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
18
35
|
export function registerResponsesReasoning(id, segments) {
|
|
19
36
|
if (typeof id !== 'string')
|
|
20
37
|
return;
|
|
@@ -59,3 +76,47 @@ export function consumeResponsesOutputTextMeta(id) {
|
|
|
59
76
|
pruneEntry(id);
|
|
60
77
|
return value;
|
|
61
78
|
}
|
|
79
|
+
export function registerResponsesPayloadSnapshot(id, snapshot) {
|
|
80
|
+
if (typeof id !== 'string')
|
|
81
|
+
return;
|
|
82
|
+
if (!snapshot || typeof snapshot !== 'object')
|
|
83
|
+
return;
|
|
84
|
+
const clone = cloneSnapshot(snapshot);
|
|
85
|
+
if (!clone)
|
|
86
|
+
return;
|
|
87
|
+
const entry = ensureEntry(id);
|
|
88
|
+
entry.payloadSnapshot = clone;
|
|
89
|
+
}
|
|
90
|
+
export function consumeResponsesPayloadSnapshot(id) {
|
|
91
|
+
if (typeof id !== 'string')
|
|
92
|
+
return undefined;
|
|
93
|
+
const entry = registry.get(id);
|
|
94
|
+
if (!entry?.payloadSnapshot)
|
|
95
|
+
return undefined;
|
|
96
|
+
const clone = cloneSnapshot(entry.payloadSnapshot) ?? entry.payloadSnapshot;
|
|
97
|
+
entry.payloadSnapshot = undefined;
|
|
98
|
+
pruneEntry(id);
|
|
99
|
+
return clone;
|
|
100
|
+
}
|
|
101
|
+
export function registerResponsesPassthrough(id, payload) {
|
|
102
|
+
if (typeof id !== 'string')
|
|
103
|
+
return;
|
|
104
|
+
if (!payload || typeof payload !== 'object')
|
|
105
|
+
return;
|
|
106
|
+
const clone = cloneSnapshot(payload);
|
|
107
|
+
if (!clone)
|
|
108
|
+
return;
|
|
109
|
+
const entry = ensureEntry(id);
|
|
110
|
+
entry.passthroughPayload = clone;
|
|
111
|
+
}
|
|
112
|
+
export function consumeResponsesPassthrough(id) {
|
|
113
|
+
if (typeof id !== 'string')
|
|
114
|
+
return undefined;
|
|
115
|
+
const entry = registry.get(id);
|
|
116
|
+
if (!entry?.passthroughPayload)
|
|
117
|
+
return undefined;
|
|
118
|
+
const clone = cloneSnapshot(entry.passthroughPayload) ?? entry.passthroughPayload;
|
|
119
|
+
entry.passthroughPayload = undefined;
|
|
120
|
+
pruneEntry(id);
|
|
121
|
+
return clone;
|
|
122
|
+
}
|
|
@@ -4,6 +4,7 @@ import { extractOutputSegments } from './output-content-normalizer.js';
|
|
|
4
4
|
import { sanitizeReasoningTaggedText } from './reasoning-utils.js';
|
|
5
5
|
import { createBridgeActionState, runBridgeActionPipeline } from './bridge-actions.js';
|
|
6
6
|
import { resolveBridgePolicy, resolvePolicyActions } from './bridge-policies.js';
|
|
7
|
+
import { registerResponsesPayloadSnapshot, registerResponsesPassthrough } from './responses-reasoning-registry.js';
|
|
7
8
|
function selectCallId(entry) {
|
|
8
9
|
const candidates = [
|
|
9
10
|
entry?.call_id,
|
|
@@ -153,13 +154,27 @@ function collectRawReasoningSegments(response) {
|
|
|
153
154
|
}
|
|
154
155
|
return segments;
|
|
155
156
|
}
|
|
157
|
+
function registerPassthroughSnapshot(payload) {
|
|
158
|
+
const ids = new Set();
|
|
159
|
+
const requestId = typeof payload?.request_id === 'string' ? payload.request_id.trim() : '';
|
|
160
|
+
const id = typeof payload?.id === 'string' ? payload.id.trim() : '';
|
|
161
|
+
if (requestId.length)
|
|
162
|
+
ids.add(requestId);
|
|
163
|
+
if (id.length)
|
|
164
|
+
ids.add(id);
|
|
165
|
+
for (const candidate of ids) {
|
|
166
|
+
registerResponsesPassthrough(candidate, payload);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
156
169
|
export function buildChatResponseFromResponses(payload) {
|
|
157
170
|
if (!payload || typeof payload !== 'object')
|
|
158
171
|
return payload;
|
|
159
172
|
const response = unwrapResponsesResponse(payload);
|
|
160
173
|
if (!response) {
|
|
161
|
-
if (Array.isArray(payload.choices))
|
|
174
|
+
if (Array.isArray(payload.choices)) {
|
|
175
|
+
registerPassthroughSnapshot(payload);
|
|
162
176
|
return payload;
|
|
177
|
+
}
|
|
163
178
|
return payload;
|
|
164
179
|
}
|
|
165
180
|
const id = typeof response.id === 'string' ? response.id : `resp_${Date.now()}`;
|
|
@@ -235,5 +250,12 @@ export function buildChatResponseFromResponses(payload) {
|
|
|
235
250
|
if (usage !== undefined) {
|
|
236
251
|
chat.usage = usage;
|
|
237
252
|
}
|
|
253
|
+
const requestId = typeof response.request_id === 'string'
|
|
254
|
+
? response.request_id
|
|
255
|
+
: (typeof response.id === 'string' ? response.id : undefined);
|
|
256
|
+
if (requestId) {
|
|
257
|
+
chat.request_id = requestId;
|
|
258
|
+
}
|
|
259
|
+
registerResponsesPayloadSnapshot(id, response);
|
|
238
260
|
return chat;
|
|
239
261
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FilterEngine } from '../../filters/index.js';
|
|
2
2
|
import { loadFieldMapConfig } from '../../filters/utils/fieldmap-loader.js';
|
|
3
|
+
import { normalizeChatResponseReasoningTools } from './reasoning-tool-normalizer.js';
|
|
3
4
|
import { createSnapshotWriter } from './snapshot-utils.js';
|
|
4
5
|
const REQUEST_FILTER_STAGES = [
|
|
5
6
|
'request_pre',
|
|
@@ -191,6 +192,16 @@ export async function runChatResponseToolFilters(chatJson, options = {}) {
|
|
|
191
192
|
snapshot(stage, payload);
|
|
192
193
|
};
|
|
193
194
|
recordStage('resp_process_tool_filters_input', chatJson);
|
|
195
|
+
try {
|
|
196
|
+
if (chatJson && typeof chatJson === 'object') {
|
|
197
|
+
normalizeChatResponseReasoningTools(chatJson, {
|
|
198
|
+
idPrefixBase: 'reasoning_choice'
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
// best-effort; do not block response flow on reasoning parsing issues
|
|
204
|
+
}
|
|
194
205
|
const engine = new FilterEngine();
|
|
195
206
|
const registeredStages = new Set();
|
|
196
207
|
const register = (filter) => {
|