@vybestack/llxprt-code-core 0.1.19-alpha → 0.1.19-gamma
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 +49 -2
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/src/auth/anthropic-device-flow.d.ts +53 -0
- package/dist/src/auth/anthropic-device-flow.js +208 -0
- package/dist/src/auth/anthropic-device-flow.js.map +1 -0
- package/dist/src/auth/precedence.d.ts +55 -0
- package/dist/src/auth/precedence.js +211 -0
- package/dist/src/auth/precedence.js.map +1 -0
- package/dist/src/auth/qwen-device-flow.d.ts +45 -0
- package/dist/src/auth/qwen-device-flow.js +179 -0
- package/dist/src/auth/qwen-device-flow.js.map +1 -0
- package/dist/src/auth/token-store.d.ts +66 -0
- package/dist/src/auth/token-store.js +151 -0
- package/dist/src/auth/token-store.js.map +1 -0
- package/dist/src/auth/types.d.ts +130 -0
- package/dist/src/auth/types.js +60 -0
- package/dist/src/auth/types.js.map +1 -0
- package/dist/src/code_assist/converter.d.ts +2 -1
- package/dist/src/code_assist/converter.js +1 -1
- package/dist/src/code_assist/converter.js.map +1 -1
- package/dist/src/code_assist/oauth2.js +2 -1
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/config/config.d.ts +61 -2
- package/dist/src/config/config.js +134 -4
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/endpoints.d.ts +60 -0
- package/dist/src/config/endpoints.js +126 -0
- package/dist/src/config/endpoints.js.map +1 -0
- package/dist/src/config/profileManager.d.ts +14 -4
- package/dist/src/config/profileManager.js +90 -11
- package/dist/src/config/profileManager.js.map +1 -1
- package/dist/src/core/client.js +9 -12
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/contentGenerator.d.ts +4 -1
- package/dist/src/core/contentGenerator.js +3 -0
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/logger.d.ts +1 -0
- package/dist/src/core/logger.js +18 -0
- package/dist/src/core/logger.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.d.ts +24 -0
- package/dist/src/core/loggingContentGenerator.js +89 -0
- package/dist/src/core/loggingContentGenerator.js.map +1 -0
- package/dist/src/core/nonInteractiveToolExecutor.js +17 -0
- package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
- package/dist/src/core/subagent.js +12 -10
- package/dist/src/core/subagent.js.map +1 -1
- package/dist/src/ide/ide-client.d.ts +1 -1
- package/dist/src/ide/ide-client.js +21 -7
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.js +12 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/providers/BaseProvider.d.ts +149 -0
- package/dist/src/providers/BaseProvider.js +315 -0
- package/dist/src/providers/BaseProvider.js.map +1 -0
- package/dist/src/providers/IProvider.d.ts +1 -0
- package/dist/src/providers/IProviderManager.d.ts +5 -0
- package/dist/src/providers/LoggingProviderWrapper.d.ts +54 -0
- package/dist/src/providers/LoggingProviderWrapper.js +350 -0
- package/dist/src/providers/LoggingProviderWrapper.js.map +1 -0
- package/dist/src/providers/ProviderManager.d.ts +20 -1
- package/dist/src/providers/ProviderManager.js +236 -14
- package/dist/src/providers/ProviderManager.js.map +1 -1
- package/dist/src/providers/anthropic/AnthropicProvider.d.ts +20 -6
- package/dist/src/providers/anthropic/AnthropicProvider.js +172 -26
- package/dist/src/providers/anthropic/AnthropicProvider.js.map +1 -1
- package/dist/src/providers/gemini/GeminiProvider.d.ts +16 -7
- package/dist/src/providers/gemini/GeminiProvider.js +163 -148
- package/dist/src/providers/gemini/GeminiProvider.js.map +1 -1
- package/dist/src/providers/logging/ProviderContentExtractor.d.ts +27 -0
- package/dist/src/providers/logging/ProviderContentExtractor.js +198 -0
- package/dist/src/providers/logging/ProviderContentExtractor.js.map +1 -0
- package/dist/src/providers/logging/ProviderPerformanceTracker.d.ts +43 -0
- package/dist/src/providers/logging/ProviderPerformanceTracker.js +98 -0
- package/dist/src/providers/logging/ProviderPerformanceTracker.js.map +1 -0
- package/dist/src/providers/openai/OpenAIProvider.d.ts +53 -6
- package/dist/src/providers/openai/OpenAIProvider.js +373 -40
- package/dist/src/providers/openai/OpenAIProvider.js.map +1 -1
- package/dist/src/providers/openai/RESPONSES_API_MODELS.d.ts +1 -1
- package/dist/src/providers/openai/RESPONSES_API_MODELS.js +1 -0
- package/dist/src/providers/openai/RESPONSES_API_MODELS.js.map +1 -1
- package/dist/src/providers/openai/syntheticToolResponses.d.ts +52 -0
- package/dist/src/providers/openai/syntheticToolResponses.js +129 -0
- package/dist/src/providers/openai/syntheticToolResponses.js.map +1 -0
- package/dist/src/providers/types.d.ts +47 -0
- package/dist/src/services/git-stats-service.d.ts +32 -0
- package/dist/src/services/git-stats-service.js +22 -0
- package/dist/src/services/git-stats-service.js.map +1 -0
- package/dist/src/services/loopDetectionService.js +10 -6
- package/dist/src/services/loopDetectionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.js +44 -8
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/settings/SettingsService.d.ts +32 -0
- package/dist/src/settings/SettingsService.js +204 -0
- package/dist/src/settings/SettingsService.js.map +1 -0
- package/dist/src/settings/settingsServiceInstance.d.ts +12 -0
- package/dist/src/settings/settingsServiceInstance.js +24 -0
- package/dist/src/settings/settingsServiceInstance.js.map +1 -0
- package/dist/src/settings/types.d.ts +141 -0
- package/dist/src/settings/types.js +5 -0
- package/dist/src/settings/types.js.map +1 -0
- package/dist/src/storage/ConversationFileWriter.d.ts +16 -0
- package/dist/src/storage/ConversationFileWriter.js +69 -0
- package/dist/src/storage/ConversationFileWriter.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +8 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +56 -3
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +5 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +11 -0
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/constants.d.ts +5 -0
- package/dist/src/telemetry/constants.js +5 -0
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +5 -1
- package/dist/src/telemetry/loggers.js +87 -1
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/metrics.d.ts +2 -1
- package/dist/src/telemetry/metrics.js +7 -1
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/tool-call-decision.d.ts +13 -0
- package/dist/src/telemetry/tool-call-decision.js +29 -0
- package/dist/src/telemetry/tool-call-decision.js.map +1 -0
- package/dist/src/telemetry/types.d.ts +56 -1
- package/dist/src/telemetry/types.js +123 -0
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +2 -1
- package/dist/src/telemetry/uiTelemetry.js +1 -1
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/tools/diffOptions.d.ts +2 -0
- package/dist/src/tools/diffOptions.js +28 -0
- package/dist/src/tools/diffOptions.js.map +1 -1
- package/dist/src/tools/edit.d.ts +4 -0
- package/dist/src/tools/edit.js +38 -8
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +4 -3
- package/dist/src/tools/mcp-client.js +23 -6
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/read-file.js +34 -2
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/todo-pause.d.ts +22 -0
- package/dist/src/tools/todo-pause.js +93 -0
- package/dist/src/tools/todo-pause.js.map +1 -0
- package/dist/src/tools/tool-error.d.ts +4 -0
- package/dist/src/tools/tool-error.js +4 -0
- package/dist/src/tools/tool-error.js.map +1 -1
- package/dist/src/tools/tool-registry.js +3 -3
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tools.d.ts +7 -0
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/write-file.d.ts +4 -0
- package/dist/src/tools/write-file.js +90 -16
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/types/modelParams.d.ts +2 -0
- package/dist/src/utils/environmentContext.js +1 -1
- package/dist/src/utils/errors.d.ts +3 -0
- package/dist/src/utils/errors.js +6 -0
- package/dist/src/utils/errors.js.map +1 -1
- package/dist/src/utils/fileUtils.d.ts +7 -0
- package/dist/src/utils/fileUtils.js +9 -0
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/package.json +4 -2
- package/dist/src/code_assist/converter.test.d.ts +0 -6
- package/dist/src/code_assist/converter.test.js +0 -232
- package/dist/src/code_assist/converter.test.js.map +0 -1
- package/dist/src/code_assist/oauth2.test.d.ts +0 -6
- package/dist/src/code_assist/oauth2.test.js +0 -370
- package/dist/src/code_assist/oauth2.test.js.map +0 -1
- package/dist/src/code_assist/server.test.d.ts +0 -6
- package/dist/src/code_assist/server.test.js +0 -131
- package/dist/src/code_assist/server.test.js.map +0 -1
- package/dist/src/code_assist/setup.test.d.ts +0 -6
- package/dist/src/code_assist/setup.test.js +0 -65
- package/dist/src/code_assist/setup.test.js.map +0 -1
- package/dist/src/config/config.alwaysAllow.test.d.ts +0 -6
- package/dist/src/config/config.alwaysAllow.test.js +0 -84
- package/dist/src/config/config.alwaysAllow.test.js.map +0 -1
- package/dist/src/config/config.test.d.ts +0 -6
- package/dist/src/config/config.test.js +0 -369
- package/dist/src/config/config.test.js.map +0 -1
- package/dist/src/config/flashFallback.test.d.ts +0 -6
- package/dist/src/config/flashFallback.test.js +0 -91
- package/dist/src/config/flashFallback.test.js.map +0 -1
- package/dist/src/core/client.test.d.ts +0 -6
- package/dist/src/core/client.test.js +0 -1322
- package/dist/src/core/client.test.js.map +0 -1
- package/dist/src/core/contentGenerator.test.d.ts +0 -6
- package/dist/src/core/contentGenerator.test.js +0 -103
- package/dist/src/core/contentGenerator.test.js.map +0 -1
- package/dist/src/core/coreToolScheduler.test.d.ts +0 -6
- package/dist/src/core/coreToolScheduler.test.js +0 -637
- package/dist/src/core/coreToolScheduler.test.js.map +0 -1
- package/dist/src/core/geminiChat.test.d.ts +0 -6
- package/dist/src/core/geminiChat.test.js +0 -425
- package/dist/src/core/geminiChat.test.js.map +0 -1
- package/dist/src/core/googleGenAIWrapper.test.d.ts +0 -6
- package/dist/src/core/googleGenAIWrapper.test.js +0 -104
- package/dist/src/core/googleGenAIWrapper.test.js.map +0 -1
- package/dist/src/core/logger.test.d.ts +0 -6
- package/dist/src/core/logger.test.js +0 -438
- package/dist/src/core/logger.test.js.map +0 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.d.ts +0 -6
- package/dist/src/core/nonInteractiveToolExecutor.test.js +0 -165
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +0 -1
- package/dist/src/core/prompts-async.test.d.ts +0 -6
- package/dist/src/core/prompts-async.test.js +0 -115
- package/dist/src/core/prompts-async.test.js.map +0 -1
- package/dist/src/core/prompts.test.d.ts +0 -6
- package/dist/src/core/prompts.test.js +0 -68
- package/dist/src/core/prompts.test.js.map +0 -1
- package/dist/src/core/subagent.test.d.ts +0 -6
- package/dist/src/core/subagent.test.js +0 -519
- package/dist/src/core/subagent.test.js.map +0 -1
- package/dist/src/core/tokenLimits.test.d.ts +0 -6
- package/dist/src/core/tokenLimits.test.js +0 -66
- package/dist/src/core/tokenLimits.test.js.map +0 -1
- package/dist/src/core/turn.test.d.ts +0 -6
- package/dist/src/core/turn.test.js +0 -366
- package/dist/src/core/turn.test.js.map +0 -1
- package/dist/src/hooks/tool-render-suppression-hook.test.d.ts +0 -6
- package/dist/src/hooks/tool-render-suppression-hook.test.js +0 -59
- package/dist/src/hooks/tool-render-suppression-hook.test.js.map +0 -1
- package/dist/src/ide/ide-installer.test.d.ts +0 -6
- package/dist/src/ide/ide-installer.test.js +0 -55
- package/dist/src/ide/ide-installer.test.js.map +0 -1
- package/dist/src/ide/ideContext.test.d.ts +0 -6
- package/dist/src/ide/ideContext.test.js +0 -265
- package/dist/src/ide/ideContext.test.js.map +0 -1
- package/dist/src/index.test.d.ts +0 -6
- package/dist/src/index.test.js +0 -12
- package/dist/src/index.test.js.map +0 -1
- package/dist/src/integration-tests/todo-system.test.d.ts +0 -6
- package/dist/src/integration-tests/todo-system.test.js +0 -46
- package/dist/src/integration-tests/todo-system.test.js.map +0 -1
- package/dist/src/mcp/google-auth-provider.test.d.ts +0 -6
- package/dist/src/mcp/google-auth-provider.test.js +0 -54
- package/dist/src/mcp/google-auth-provider.test.js.map +0 -1
- package/dist/src/mcp/oauth-provider.test.d.ts +0 -6
- package/dist/src/mcp/oauth-provider.test.js +0 -602
- package/dist/src/mcp/oauth-provider.test.js.map +0 -1
- package/dist/src/mcp/oauth-token-storage.test.d.ts +0 -6
- package/dist/src/mcp/oauth-token-storage.test.js +0 -205
- package/dist/src/mcp/oauth-token-storage.test.js.map +0 -1
- package/dist/src/mcp/oauth-utils.test.d.ts +0 -6
- package/dist/src/mcp/oauth-utils.test.js +0 -144
- package/dist/src/mcp/oauth-utils.test.js.map +0 -1
- package/dist/src/parsers/TextToolCallParser.multibyte.test.d.ts +0 -1
- package/dist/src/parsers/TextToolCallParser.multibyte.test.js +0 -42
- package/dist/src/parsers/TextToolCallParser.multibyte.test.js.map +0 -1
- package/dist/src/parsers/TextToolCallParser.test.d.ts +0 -1
- package/dist/src/parsers/TextToolCallParser.test.js +0 -225
- package/dist/src/parsers/TextToolCallParser.test.js.map +0 -1
- package/dist/src/prompt-config/TemplateEngine.test.d.ts +0 -1
- package/dist/src/prompt-config/TemplateEngine.test.js +0 -494
- package/dist/src/prompt-config/TemplateEngine.test.js.map +0 -1
- package/dist/src/prompt-config/prompt-cache.test.d.ts +0 -6
- package/dist/src/prompt-config/prompt-cache.test.js +0 -437
- package/dist/src/prompt-config/prompt-cache.test.js.map +0 -1
- package/dist/src/prompt-config/prompt-installer.test.d.ts +0 -7
- package/dist/src/prompt-config/prompt-installer.test.js +0 -503
- package/dist/src/prompt-config/prompt-installer.test.js.map +0 -1
- package/dist/src/prompt-config/prompt-loader.test.d.ts +0 -5
- package/dist/src/prompt-config/prompt-loader.test.js +0 -413
- package/dist/src/prompt-config/prompt-loader.test.js.map +0 -1
- package/dist/src/prompt-config/prompt-resolver.test.d.ts +0 -1
- package/dist/src/prompt-config/prompt-resolver.test.js +0 -529
- package/dist/src/prompt-config/prompt-resolver.test.js.map +0 -1
- package/dist/src/prompt-config/prompt-service.test.d.ts +0 -1
- package/dist/src/prompt-config/prompt-service.test.js +0 -811
- package/dist/src/prompt-config/prompt-service.test.js.map +0 -1
- package/dist/src/providers/ProviderManager.gemini-switch.test.d.ts +0 -6
- package/dist/src/providers/ProviderManager.gemini-switch.test.js +0 -57
- package/dist/src/providers/ProviderManager.gemini-switch.test.js.map +0 -1
- package/dist/src/providers/ProviderManager.test.d.ts +0 -6
- package/dist/src/providers/ProviderManager.test.js +0 -284
- package/dist/src/providers/ProviderManager.test.js.map +0 -1
- package/dist/src/providers/adapters/GeminiCompatibleWrapper.test.d.ts +0 -6
- package/dist/src/providers/adapters/GeminiCompatibleWrapper.test.js +0 -273
- package/dist/src/providers/adapters/GeminiCompatibleWrapper.test.js.map +0 -1
- package/dist/src/providers/anthropic/AnthropicProvider.modelParams.test.d.ts +0 -1
- package/dist/src/providers/anthropic/AnthropicProvider.modelParams.test.js +0 -48
- package/dist/src/providers/anthropic/AnthropicProvider.modelParams.test.js.map +0 -1
- package/dist/src/providers/anthropic/AnthropicProvider.test.d.ts +0 -1
- package/dist/src/providers/anthropic/AnthropicProvider.test.js +0 -487
- package/dist/src/providers/anthropic/AnthropicProvider.test.js.map +0 -1
- package/dist/src/providers/gemini/GeminiProvider.integration.test.d.ts +0 -6
- package/dist/src/providers/gemini/GeminiProvider.integration.test.js +0 -126
- package/dist/src/providers/gemini/GeminiProvider.integration.test.js.map +0 -1
- package/dist/src/providers/gemini/GeminiProvider.test.d.ts +0 -6
- package/dist/src/providers/gemini/GeminiProvider.test.js +0 -136
- package/dist/src/providers/gemini/GeminiProvider.test.js.map +0 -1
- package/dist/src/providers/integration/multi-provider.integration.test.d.ts +0 -6
- package/dist/src/providers/integration/multi-provider.integration.test.js +0 -292
- package/dist/src/providers/integration/multi-provider.integration.test.js.map +0 -1
- package/dist/src/providers/openai/ConversationCache.accumTokens.test.d.ts +0 -1
- package/dist/src/providers/openai/ConversationCache.accumTokens.test.js +0 -97
- package/dist/src/providers/openai/ConversationCache.accumTokens.test.js.map +0 -1
- package/dist/src/providers/openai/ConversationCache.test.d.ts +0 -1
- package/dist/src/providers/openai/ConversationCache.test.js +0 -113
- package/dist/src/providers/openai/ConversationCache.test.js.map +0 -1
- package/dist/src/providers/openai/OpenAIProvider.callResponses.stateless.test.d.ts +0 -1
- package/dist/src/providers/openai/OpenAIProvider.callResponses.stateless.test.js +0 -189
- package/dist/src/providers/openai/OpenAIProvider.callResponses.stateless.test.js.map +0 -1
- package/dist/src/providers/openai/OpenAIProvider.integration.test.d.ts +0 -6
- package/dist/src/providers/openai/OpenAIProvider.integration.test.js +0 -125
- package/dist/src/providers/openai/OpenAIProvider.integration.test.js.map +0 -1
- package/dist/src/providers/openai/OpenAIProvider.responses.test.d.ts +0 -1
- package/dist/src/providers/openai/OpenAIProvider.responses.test.js +0 -350
- package/dist/src/providers/openai/OpenAIProvider.responses.test.js.map +0 -1
- package/dist/src/providers/openai/OpenAIProvider.responsesIntegration.test.d.ts +0 -1
- package/dist/src/providers/openai/OpenAIProvider.responsesIntegration.test.js +0 -213
- package/dist/src/providers/openai/OpenAIProvider.responsesIntegration.test.js.map +0 -1
- package/dist/src/providers/openai/OpenAIProvider.shouldUseResponses.test.d.ts +0 -1
- package/dist/src/providers/openai/OpenAIProvider.shouldUseResponses.test.js +0 -59
- package/dist/src/providers/openai/OpenAIProvider.shouldUseResponses.test.js.map +0 -1
- package/dist/src/providers/openai/OpenAIProvider.stateful.integration.test.d.ts +0 -6
- package/dist/src/providers/openai/OpenAIProvider.stateful.integration.test.js +0 -105
- package/dist/src/providers/openai/OpenAIProvider.stateful.integration.test.js.map +0 -1
- package/dist/src/providers/openai/OpenAIProvider.switch.test.d.ts +0 -1
- package/dist/src/providers/openai/OpenAIProvider.switch.test.js +0 -256
- package/dist/src/providers/openai/OpenAIProvider.switch.test.js.map +0 -1
- package/dist/src/providers/openai/OpenAIProvider.test.d.ts +0 -16
- package/dist/src/providers/openai/OpenAIProvider.test.js +0 -620
- package/dist/src/providers/openai/OpenAIProvider.test.js.map +0 -1
- package/dist/src/providers/openai/ResponsesContextTrim.integration.test.d.ts +0 -1
- package/dist/src/providers/openai/ResponsesContextTrim.integration.test.js +0 -210
- package/dist/src/providers/openai/ResponsesContextTrim.integration.test.js.map +0 -1
- package/dist/src/providers/openai/__tests__/formatArrayResponse.test.d.ts +0 -1
- package/dist/src/providers/openai/__tests__/formatArrayResponse.test.js +0 -65
- package/dist/src/providers/openai/__tests__/formatArrayResponse.test.js.map +0 -1
- package/dist/src/providers/openai/buildResponsesRequest.stripToolCalls.test.d.ts +0 -1
- package/dist/src/providers/openai/buildResponsesRequest.stripToolCalls.test.js +0 -129
- package/dist/src/providers/openai/buildResponsesRequest.stripToolCalls.test.js.map +0 -1
- package/dist/src/providers/openai/buildResponsesRequest.test.d.ts +0 -1
- package/dist/src/providers/openai/buildResponsesRequest.test.js +0 -406
- package/dist/src/providers/openai/buildResponsesRequest.test.js.map +0 -1
- package/dist/src/providers/openai/buildResponsesRequest.undefined.test.d.ts +0 -1
- package/dist/src/providers/openai/buildResponsesRequest.undefined.test.js +0 -50
- package/dist/src/providers/openai/buildResponsesRequest.undefined.test.js.map +0 -1
- package/dist/src/providers/openai/estimateRemoteTokens.test.d.ts +0 -1
- package/dist/src/providers/openai/estimateRemoteTokens.test.js +0 -125
- package/dist/src/providers/openai/estimateRemoteTokens.test.js.map +0 -1
- package/dist/src/providers/openai/parseResponsesStream.responsesToolCalls.test.d.ts +0 -1
- package/dist/src/providers/openai/parseResponsesStream.responsesToolCalls.test.js +0 -192
- package/dist/src/providers/openai/parseResponsesStream.responsesToolCalls.test.js.map +0 -1
- package/dist/src/providers/openai/parseResponsesStream.test.d.ts +0 -1
- package/dist/src/providers/openai/parseResponsesStream.test.js +0 -151
- package/dist/src/providers/openai/parseResponsesStream.test.js.map +0 -1
- package/dist/src/services/fileDiscoveryService.test.d.ts +0 -6
- package/dist/src/services/fileDiscoveryService.test.js +0 -143
- package/dist/src/services/fileDiscoveryService.test.js.map +0 -1
- package/dist/src/services/gitService.test.d.ts +0 -6
- package/dist/src/services/gitService.test.js +0 -209
- package/dist/src/services/gitService.test.js.map +0 -1
- package/dist/src/services/loopDetectionService.test.d.ts +0 -6
- package/dist/src/services/loopDetectionService.test.js +0 -345
- package/dist/src/services/loopDetectionService.test.js.map +0 -1
- package/dist/src/services/shellExecutionService.multibyte.test.d.ts +0 -6
- package/dist/src/services/shellExecutionService.multibyte.test.js +0 -72
- package/dist/src/services/shellExecutionService.multibyte.test.js.map +0 -1
- package/dist/src/services/shellExecutionService.test.d.ts +0 -6
- package/dist/src/services/shellExecutionService.test.js +0 -272
- package/dist/src/services/shellExecutionService.test.js.map +0 -1
- package/dist/src/services/shellExecutionService.windows.multibyte.test.d.ts +0 -6
- package/dist/src/services/shellExecutionService.windows.multibyte.test.js +0 -98
- package/dist/src/services/shellExecutionService.windows.multibyte.test.js.map +0 -1
- package/dist/src/services/shellExecutionService.windows.test.d.ts +0 -6
- package/dist/src/services/shellExecutionService.windows.test.js +0 -79
- package/dist/src/services/shellExecutionService.windows.test.js.map +0 -1
- package/dist/src/services/tool-call-tracker-service.test.d.ts +0 -6
- package/dist/src/services/tool-call-tracker-service.test.js +0 -99
- package/dist/src/services/tool-call-tracker-service.test.js.map +0 -1
- package/dist/src/telemetry/loggers.test.d.ts +0 -6
- package/dist/src/telemetry/loggers.test.js +0 -572
- package/dist/src/telemetry/loggers.test.js.map +0 -1
- package/dist/src/telemetry/metrics.test.d.ts +0 -6
- package/dist/src/telemetry/metrics.test.js +0 -162
- package/dist/src/telemetry/metrics.test.js.map +0 -1
- package/dist/src/telemetry/telemetry.test.d.ts +0 -6
- package/dist/src/telemetry/telemetry.test.js +0 -54
- package/dist/src/telemetry/telemetry.test.js.map +0 -1
- package/dist/src/telemetry/uiTelemetry.test.d.ts +0 -6
- package/dist/src/telemetry/uiTelemetry.test.js +0 -517
- package/dist/src/telemetry/uiTelemetry.test.js.map +0 -1
- package/dist/src/tools/ToolFormatter.test.d.ts +0 -16
- package/dist/src/tools/ToolFormatter.test.js +0 -349
- package/dist/src/tools/ToolFormatter.test.js.map +0 -1
- package/dist/src/tools/ToolFormatter.toResponsesTool.test.d.ts +0 -1
- package/dist/src/tools/ToolFormatter.toResponsesTool.test.js +0 -241
- package/dist/src/tools/ToolFormatter.toResponsesTool.test.js.map +0 -1
- package/dist/src/tools/edit.test.d.ts +0 -6
- package/dist/src/tools/edit.test.js +0 -688
- package/dist/src/tools/edit.test.js.map +0 -1
- package/dist/src/tools/glob.test.d.ts +0 -6
- package/dist/src/tools/glob.test.js +0 -332
- package/dist/src/tools/glob.test.js.map +0 -1
- package/dist/src/tools/grep.test.d.ts +0 -6
- package/dist/src/tools/grep.test.js +0 -272
- package/dist/src/tools/grep.test.js.map +0 -1
- package/dist/src/tools/ls.test.d.ts +0 -6
- package/dist/src/tools/ls.test.js +0 -357
- package/dist/src/tools/ls.test.js.map +0 -1
- package/dist/src/tools/mcp-client.test.d.ts +0 -6
- package/dist/src/tools/mcp-client.test.js +0 -575
- package/dist/src/tools/mcp-client.test.js.map +0 -1
- package/dist/src/tools/mcp-tool.test.d.ts +0 -6
- package/dist/src/tools/mcp-tool.test.js +0 -501
- package/dist/src/tools/mcp-tool.test.js.map +0 -1
- package/dist/src/tools/memoryTool.test.d.ts +0 -6
- package/dist/src/tools/memoryTool.test.js +0 -266
- package/dist/src/tools/memoryTool.test.js.map +0 -1
- package/dist/src/tools/modifiable-tool.test.d.ts +0 -6
- package/dist/src/tools/modifiable-tool.test.js +0 -193
- package/dist/src/tools/modifiable-tool.test.js.map +0 -1
- package/dist/src/tools/read-file.test.d.ts +0 -6
- package/dist/src/tools/read-file.test.js +0 -313
- package/dist/src/tools/read-file.test.js.map +0 -1
- package/dist/src/tools/read-many-files.test.d.ts +0 -6
- package/dist/src/tools/read-many-files.test.js +0 -644
- package/dist/src/tools/read-many-files.test.js.map +0 -1
- package/dist/src/tools/shell.multibyte.test.d.ts +0 -6
- package/dist/src/tools/shell.multibyte.test.js +0 -75
- package/dist/src/tools/shell.multibyte.test.js.map +0 -1
- package/dist/src/tools/shell.test.d.ts +0 -6
- package/dist/src/tools/shell.test.js +0 -350
- package/dist/src/tools/shell.test.js.map +0 -1
- package/dist/src/tools/todo-read.test.d.ts +0 -6
- package/dist/src/tools/todo-read.test.js +0 -162
- package/dist/src/tools/todo-read.test.js.map +0 -1
- package/dist/src/tools/todo-schemas.test.d.ts +0 -6
- package/dist/src/tools/todo-schemas.test.js +0 -341
- package/dist/src/tools/todo-schemas.test.js.map +0 -1
- package/dist/src/tools/todo-store.test.d.ts +0 -6
- package/dist/src/tools/todo-store.test.js +0 -169
- package/dist/src/tools/todo-store.test.js.map +0 -1
- package/dist/src/tools/todo-write.test.d.ts +0 -6
- package/dist/src/tools/todo-write.test.js +0 -226
- package/dist/src/tools/todo-write.test.js.map +0 -1
- package/dist/src/tools/tool-registry.test.d.ts +0 -6
- package/dist/src/tools/tool-registry.test.js +0 -468
- package/dist/src/tools/tool-registry.test.js.map +0 -1
- package/dist/src/tools/tools.test.d.ts +0 -6
- package/dist/src/tools/tools.test.js +0 -117
- package/dist/src/tools/tools.test.js.map +0 -1
- package/dist/src/tools/web-fetch.integration.test.d.ts +0 -6
- package/dist/src/tools/web-fetch.integration.test.js +0 -532
- package/dist/src/tools/web-fetch.integration.test.js.map +0 -1
- package/dist/src/tools/web-search.test.d.ts +0 -6
- package/dist/src/tools/web-search.test.js +0 -229
- package/dist/src/tools/web-search.test.js.map +0 -1
- package/dist/src/tools/write-file.test.d.ts +0 -6
- package/dist/src/tools/write-file.test.js +0 -464
- package/dist/src/tools/write-file.test.js.map +0 -1
- package/dist/src/utils/bfsFileSearch.test.d.ts +0 -6
- package/dist/src/utils/bfsFileSearch.test.js +0 -191
- package/dist/src/utils/bfsFileSearch.test.js.map +0 -1
- package/dist/src/utils/editCorrector.test.d.ts +0 -6
- package/dist/src/utils/editCorrector.test.js +0 -564
- package/dist/src/utils/editCorrector.test.js.map +0 -1
- package/dist/src/utils/editor.test.d.ts +0 -6
- package/dist/src/utils/editor.test.js +0 -445
- package/dist/src/utils/editor.test.js.map +0 -1
- package/dist/src/utils/environmentContext.test.d.ts +0 -6
- package/dist/src/utils/environmentContext.test.js +0 -139
- package/dist/src/utils/environmentContext.test.js.map +0 -1
- package/dist/src/utils/errorReporting.test.d.ts +0 -6
- package/dist/src/utils/errorReporting.test.js +0 -130
- package/dist/src/utils/errorReporting.test.js.map +0 -1
- package/dist/src/utils/fileUtils.test.d.ts +0 -6
- package/dist/src/utils/fileUtils.test.js +0 -363
- package/dist/src/utils/fileUtils.test.js.map +0 -1
- package/dist/src/utils/filesearch/crawlCache.test.d.ts +0 -6
- package/dist/src/utils/filesearch/crawlCache.test.js +0 -103
- package/dist/src/utils/filesearch/crawlCache.test.js.map +0 -1
- package/dist/src/utils/filesearch/fileSearch.test.d.ts +0 -6
- package/dist/src/utils/filesearch/fileSearch.test.js +0 -654
- package/dist/src/utils/filesearch/fileSearch.test.js.map +0 -1
- package/dist/src/utils/filesearch/ignore.test.d.ts +0 -6
- package/dist/src/utils/filesearch/ignore.test.js +0 -57
- package/dist/src/utils/filesearch/ignore.test.js.map +0 -1
- package/dist/src/utils/filesearch/result-cache.test.d.ts +0 -6
- package/dist/src/utils/filesearch/result-cache.test.js +0 -47
- package/dist/src/utils/filesearch/result-cache.test.js.map +0 -1
- package/dist/src/utils/flashFallback.integration.test.d.ts +0 -6
- package/dist/src/utils/flashFallback.integration.test.js +0 -120
- package/dist/src/utils/flashFallback.integration.test.js.map +0 -1
- package/dist/src/utils/generateContentResponseUtilities.test.d.ts +0 -6
- package/dist/src/utils/generateContentResponseUtilities.test.js +0 -273
- package/dist/src/utils/generateContentResponseUtilities.test.js.map +0 -1
- package/dist/src/utils/getFolderStructure.test.d.ts +0 -6
- package/dist/src/utils/getFolderStructure.test.js +0 -282
- package/dist/src/utils/getFolderStructure.test.js.map +0 -1
- package/dist/src/utils/gitIgnoreParser.test.d.ts +0 -6
- package/dist/src/utils/gitIgnoreParser.test.js +0 -154
- package/dist/src/utils/gitIgnoreParser.test.js.map +0 -1
- package/dist/src/utils/memoryDiscovery.test.d.ts +0 -6
- package/dist/src/utils/memoryDiscovery.test.js +0 -181
- package/dist/src/utils/memoryDiscovery.test.js.map +0 -1
- package/dist/src/utils/memoryImportProcessor.test.d.ts +0 -6
- package/dist/src/utils/memoryImportProcessor.test.js +0 -715
- package/dist/src/utils/memoryImportProcessor.test.js.map +0 -1
- package/dist/src/utils/nextSpeakerChecker.test.d.ts +0 -6
- package/dist/src/utils/nextSpeakerChecker.test.js +0 -172
- package/dist/src/utils/nextSpeakerChecker.test.js.map +0 -1
- package/dist/src/utils/partUtils.test.d.ts +0 -6
- package/dist/src/utils/partUtils.test.js +0 -130
- package/dist/src/utils/partUtils.test.js.map +0 -1
- package/dist/src/utils/paths.test.d.ts +0 -6
- package/dist/src/utils/paths.test.js +0 -153
- package/dist/src/utils/paths.test.js.map +0 -1
- package/dist/src/utils/retry.test.d.ts +0 -6
- package/dist/src/utils/retry.test.js +0 -322
- package/dist/src/utils/retry.test.js.map +0 -1
- package/dist/src/utils/safeJsonStringify.test.d.ts +0 -6
- package/dist/src/utils/safeJsonStringify.test.js +0 -61
- package/dist/src/utils/safeJsonStringify.test.js.map +0 -1
- package/dist/src/utils/sanitization.test.d.ts +0 -6
- package/dist/src/utils/sanitization.test.js +0 -81
- package/dist/src/utils/sanitization.test.js.map +0 -1
- package/dist/src/utils/schemaValidator.test.d.ts +0 -6
- package/dist/src/utils/schemaValidator.test.js +0 -146
- package/dist/src/utils/schemaValidator.test.js.map +0 -1
- package/dist/src/utils/secure-browser-launcher.test.d.ts +0 -6
- package/dist/src/utils/secure-browser-launcher.test.js +0 -149
- package/dist/src/utils/secure-browser-launcher.test.js.map +0 -1
- package/dist/src/utils/shell-utils.shellReplacement.test.d.ts +0 -6
- package/dist/src/utils/shell-utils.shellReplacement.test.js +0 -149
- package/dist/src/utils/shell-utils.shellReplacement.test.js.map +0 -1
- package/dist/src/utils/shell-utils.test.d.ts +0 -6
- package/dist/src/utils/shell-utils.test.js +0 -200
- package/dist/src/utils/shell-utils.test.js.map +0 -1
- package/dist/src/utils/summarizer.test.d.ts +0 -6
- package/dist/src/utils/summarizer.test.js +0 -131
- package/dist/src/utils/summarizer.test.js.map +0 -1
- package/dist/src/utils/systemEncoding.test.d.ts +0 -6
- package/dist/src/utils/systemEncoding.test.js +0 -368
- package/dist/src/utils/systemEncoding.test.js.map +0 -1
- package/dist/src/utils/toolOutputLimiter.test.d.ts +0 -6
- package/dist/src/utils/toolOutputLimiter.test.js +0 -164
- package/dist/src/utils/toolOutputLimiter.test.js.map +0 -1
- package/dist/src/utils/unicodeUtils.test.d.ts +0 -6
- package/dist/src/utils/unicodeUtils.test.js +0 -120
- package/dist/src/utils/unicodeUtils.test.js.map +0 -1
- package/dist/src/utils/user_account.test.d.ts +0 -6
- package/dist/src/utils/user_account.test.js +0 -153
- package/dist/src/utils/user_account.test.js.map +0 -1
- package/dist/src/utils/user_id.test.d.ts +0 -6
- package/dist/src/utils/user_id.test.js +0 -21
- package/dist/src/utils/user_id.test.js.map +0 -1
- package/dist/src/utils/workspaceContext.test.d.ts +0 -6
- package/dist/src/utils/workspaceContext.test.js +0 -209
- package/dist/src/utils/workspaceContext.test.js.map +0 -1
|
@@ -23,25 +23,59 @@ import { estimateMessagesTokens, estimateRemoteTokens, } from './estimateRemoteT
|
|
|
23
23
|
// ConversationContext removed - using inline conversation ID generation
|
|
24
24
|
import { parseResponsesStream, parseErrorResponse, } from './parseResponsesStream.js';
|
|
25
25
|
import { buildResponsesRequest } from './buildResponsesRequest.js';
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
import { BaseProvider } from '../BaseProvider.js';
|
|
27
|
+
import { isQwenEndpoint, generateOAuthEndpointMismatchError, } from '../../config/endpoints.js';
|
|
28
|
+
import { getSettingsService } from '../../settings/settingsServiceInstance.js';
|
|
29
|
+
export class OpenAIProvider extends BaseProvider {
|
|
28
30
|
openai;
|
|
29
31
|
currentModel = 'gpt-4.1';
|
|
30
|
-
apiKey;
|
|
31
32
|
baseURL;
|
|
32
|
-
|
|
33
|
+
providerConfig;
|
|
33
34
|
toolFormatter;
|
|
34
35
|
toolFormatOverride;
|
|
35
36
|
conversationCache;
|
|
36
37
|
modelParams;
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
_cachedClient;
|
|
39
|
+
_cachedClientKey;
|
|
40
|
+
constructor(apiKey, baseURL, config, oauthManager) {
|
|
41
|
+
// Initialize base provider with auth configuration
|
|
42
|
+
// Check if we should enable OAuth for Qwen
|
|
43
|
+
// Enable OAuth if: 1) we have an oauth manager, and 2) either the baseURL is a Qwen endpoint OR no baseURL/apiKey is provided
|
|
44
|
+
const shouldEnableQwenOAuth = !!oauthManager &&
|
|
45
|
+
(isQwenEndpoint(baseURL || '') ||
|
|
46
|
+
(!baseURL && (!apiKey || apiKey === '')) ||
|
|
47
|
+
baseURL === 'https://portal.qwen.ai/v1');
|
|
48
|
+
if (process.env.DEBUG) {
|
|
49
|
+
console.log(`[OpenAI Constructor] baseURL: ${baseURL}, apiKey: ${apiKey?.substring(0, 10) || 'none'}, oauthManager: ${!!oauthManager}, shouldEnableQwenOAuth: ${shouldEnableQwenOAuth}`);
|
|
50
|
+
}
|
|
51
|
+
const baseConfig = {
|
|
52
|
+
name: 'openai',
|
|
53
|
+
apiKey,
|
|
54
|
+
baseURL,
|
|
55
|
+
cliKey: !apiKey || apiKey === '' ? undefined : apiKey, // Don't set cliKey if no API key to allow OAuth
|
|
56
|
+
envKeyNames: ['OPENAI_API_KEY'],
|
|
57
|
+
isOAuthEnabled: shouldEnableQwenOAuth,
|
|
58
|
+
oauthProvider: shouldEnableQwenOAuth ? 'qwen' : undefined,
|
|
59
|
+
oauthManager,
|
|
60
|
+
};
|
|
61
|
+
super(baseConfig);
|
|
39
62
|
this.baseURL = baseURL;
|
|
40
|
-
this.
|
|
63
|
+
this.providerConfig = config;
|
|
41
64
|
this.toolFormatter = new ToolFormatter();
|
|
42
65
|
this.conversationCache = new ConversationCache();
|
|
66
|
+
// Initialize from SettingsService
|
|
67
|
+
this.initializeFromSettings().catch((error) => {
|
|
68
|
+
if (process.env.DEBUG) {
|
|
69
|
+
console.warn('Failed to initialize OpenAI provider from SettingsService:', error);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
// Set appropriate default model based on the provider
|
|
73
|
+
if (shouldEnableQwenOAuth || isQwenEndpoint(baseURL || '')) {
|
|
74
|
+
// Default to Qwen model when using Qwen endpoints
|
|
75
|
+
this.currentModel = 'qwen3-coder-plus';
|
|
76
|
+
}
|
|
43
77
|
const clientOptions = {
|
|
44
|
-
apiKey,
|
|
78
|
+
apiKey: apiKey || 'placeholder', // OpenAI client requires a string, use placeholder if OAuth will be used
|
|
45
79
|
// Allow browser environment if explicitly configured
|
|
46
80
|
dangerouslyAllowBrowser: config?.allowBrowserEnvironment || false,
|
|
47
81
|
};
|
|
@@ -50,9 +84,87 @@ export class OpenAIProvider {
|
|
|
50
84
|
clientOptions.baseURL = baseURL;
|
|
51
85
|
}
|
|
52
86
|
this.openai = new OpenAI(clientOptions);
|
|
87
|
+
this._cachedClientKey = apiKey; // Track the initial key used
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Implementation of BaseProvider abstract method
|
|
91
|
+
* Determines if this provider supports OAuth authentication
|
|
92
|
+
*/
|
|
93
|
+
supportsOAuth() {
|
|
94
|
+
// Only support Qwen OAuth for Qwen endpoints
|
|
95
|
+
// Use baseProviderConfig.baseURL if this.baseURL not set yet (during constructor)
|
|
96
|
+
const baseURL = this.baseURL ||
|
|
97
|
+
this.baseProviderConfig.baseURL ||
|
|
98
|
+
'https://api.openai.com/v1';
|
|
99
|
+
return isQwenEndpoint(baseURL);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Helper method to determine if we're using Qwen (via OAuth or direct endpoint)
|
|
103
|
+
*/
|
|
104
|
+
isUsingQwen() {
|
|
105
|
+
// Check if we're using qwen format based on tool format detection
|
|
106
|
+
const toolFormat = this.detectToolFormat();
|
|
107
|
+
return toolFormat === 'qwen';
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Update the OpenAI client with resolved authentication if needed
|
|
111
|
+
*/
|
|
112
|
+
async updateClientWithResolvedAuth() {
|
|
113
|
+
const resolvedKey = await this.getAuthToken();
|
|
114
|
+
if (!resolvedKey) {
|
|
115
|
+
// Provide specific error message based on endpoint validation
|
|
116
|
+
const endpoint = this.baseURL || 'https://api.openai.com/v1';
|
|
117
|
+
if (this.isOAuthEnabled() && !this.supportsOAuth()) {
|
|
118
|
+
throw new Error(generateOAuthEndpointMismatchError(endpoint, 'qwen'));
|
|
119
|
+
}
|
|
120
|
+
throw new Error('No authentication available for OpenAI API calls');
|
|
121
|
+
}
|
|
122
|
+
// Check if we're using Qwen OAuth and need to update the baseURL
|
|
123
|
+
let effectiveBaseURL = this.baseURL;
|
|
124
|
+
// Debug logging
|
|
125
|
+
if (process.env.DEBUG) {
|
|
126
|
+
console.log(`[OpenAI] updateClientWithResolvedAuth - OAuth enabled: ${this.isOAuthEnabled()}, OAuth provider: ${this.baseProviderConfig.oauthProvider}, baseURL: ${this.baseURL}, resolvedKey: ${resolvedKey?.substring(0, 10)}...`);
|
|
127
|
+
}
|
|
128
|
+
if (this.isOAuthEnabled() &&
|
|
129
|
+
this.baseProviderConfig.oauthProvider === 'qwen') {
|
|
130
|
+
// Get the OAuth token to check for resource_url
|
|
131
|
+
const oauthManager = this.baseProviderConfig.oauthManager;
|
|
132
|
+
if (oauthManager?.getOAuthToken) {
|
|
133
|
+
const oauthToken = await oauthManager.getOAuthToken('qwen');
|
|
134
|
+
if (process.env.DEBUG) {
|
|
135
|
+
console.log(`[OpenAI] OAuth token retrieved, resource_url: ${oauthToken?.resource_url}, access_token: ${oauthToken?.access_token?.substring(0, 10)}...`);
|
|
136
|
+
}
|
|
137
|
+
if (oauthToken?.resource_url) {
|
|
138
|
+
// Use the resource_url from the OAuth token
|
|
139
|
+
effectiveBaseURL = `https://${oauthToken.resource_url}/v1`;
|
|
140
|
+
if (process.env.DEBUG) {
|
|
141
|
+
console.log(`[OpenAI] Using Qwen OAuth endpoint: ${effectiveBaseURL}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// Only update client if the key or URL has changed
|
|
147
|
+
if (this._cachedClientKey !== resolvedKey ||
|
|
148
|
+
this.baseURL !== effectiveBaseURL) {
|
|
149
|
+
const clientOptions = {
|
|
150
|
+
apiKey: resolvedKey,
|
|
151
|
+
// Allow browser environment if explicitly configured
|
|
152
|
+
dangerouslyAllowBrowser: this.providerConfig?.allowBrowserEnvironment || false,
|
|
153
|
+
};
|
|
154
|
+
// Only include baseURL if it's defined
|
|
155
|
+
if (effectiveBaseURL) {
|
|
156
|
+
clientOptions.baseURL = effectiveBaseURL;
|
|
157
|
+
}
|
|
158
|
+
this.openai = new OpenAI(clientOptions);
|
|
159
|
+
this._cachedClientKey = resolvedKey;
|
|
160
|
+
// Update the baseURL to track changes
|
|
161
|
+
if (effectiveBaseURL !== this.baseURL) {
|
|
162
|
+
this.baseURL = effectiveBaseURL;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
53
165
|
}
|
|
54
166
|
requiresTextToolCallParsing() {
|
|
55
|
-
if (this.
|
|
167
|
+
if (this.providerConfig?.enableTextToolCallParsing === false) {
|
|
56
168
|
return false;
|
|
57
169
|
}
|
|
58
170
|
// Check if current tool format requires text-based parsing
|
|
@@ -61,7 +173,7 @@ export class OpenAIProvider {
|
|
|
61
173
|
if (textBasedFormats.includes(currentFormat)) {
|
|
62
174
|
return true;
|
|
63
175
|
}
|
|
64
|
-
const configuredModels = this.
|
|
176
|
+
const configuredModels = this.providerConfig?.textToolCallModels || [];
|
|
65
177
|
return configuredModels.includes(this.currentModel);
|
|
66
178
|
}
|
|
67
179
|
getToolFormat() {
|
|
@@ -70,15 +182,16 @@ export class OpenAIProvider {
|
|
|
70
182
|
return this.toolFormatOverride;
|
|
71
183
|
}
|
|
72
184
|
// Check for settings override
|
|
73
|
-
if (this.
|
|
74
|
-
return this.
|
|
185
|
+
if (this.providerConfig?.providerToolFormatOverrides?.[this.name]) {
|
|
186
|
+
return this.providerConfig.providerToolFormatOverrides[this.name];
|
|
75
187
|
}
|
|
76
188
|
// Auto-detect tool format based on model or base URL
|
|
77
189
|
if (this.currentModel.includes('deepseek') ||
|
|
78
190
|
this.baseURL?.includes('deepseek')) {
|
|
79
191
|
return 'deepseek';
|
|
80
192
|
}
|
|
81
|
-
|
|
193
|
+
// Check for Qwen - including OAuth authenticated Qwen
|
|
194
|
+
if (this.isUsingQwen()) {
|
|
82
195
|
return 'qwen';
|
|
83
196
|
}
|
|
84
197
|
// Default to OpenAI format
|
|
@@ -90,7 +203,7 @@ export class OpenAIProvider {
|
|
|
90
203
|
return false;
|
|
91
204
|
}
|
|
92
205
|
// Check settings override - if explicitly set to false, always respect that
|
|
93
|
-
if (this.
|
|
206
|
+
if (this.providerConfig?.openaiResponsesEnabled === false) {
|
|
94
207
|
return false;
|
|
95
208
|
}
|
|
96
209
|
// Never use Responses API for non-OpenAI providers (those with custom base URLs)
|
|
@@ -102,8 +215,13 @@ export class OpenAIProvider {
|
|
|
102
215
|
return RESPONSES_API_MODELS.some((responsesModel) => model.startsWith(responsesModel));
|
|
103
216
|
}
|
|
104
217
|
async callResponsesEndpoint(messages, tools, options) {
|
|
105
|
-
// Check if API key is available
|
|
106
|
-
|
|
218
|
+
// Check if API key is available (using resolved authentication)
|
|
219
|
+
const apiKey = await this.getAuthToken();
|
|
220
|
+
if (!apiKey) {
|
|
221
|
+
const endpoint = this.baseURL || 'https://api.openai.com/v1';
|
|
222
|
+
if (this.isOAuthEnabled() && !this.supportsOAuth()) {
|
|
223
|
+
throw new Error(generateOAuthEndpointMismatchError(endpoint, 'qwen'));
|
|
224
|
+
}
|
|
107
225
|
throw new Error('OpenAI API key is required to make API calls');
|
|
108
226
|
}
|
|
109
227
|
// Remove the stateful mode error to allow O3 to work with conversation IDs
|
|
@@ -135,10 +253,13 @@ export class OpenAIProvider {
|
|
|
135
253
|
const formattedTools = tools
|
|
136
254
|
? this.toolFormatter.toResponsesTool(tools)
|
|
137
255
|
: undefined;
|
|
256
|
+
// Patch messages to include synthetic responses for cancelled tools
|
|
257
|
+
const { SyntheticToolResponseHandler } = await import('./syntheticToolResponses.js');
|
|
258
|
+
const patchedMessages = SyntheticToolResponseHandler.patchMessageHistory(messages);
|
|
138
259
|
// Build the request
|
|
139
260
|
const request = buildResponsesRequest({
|
|
140
261
|
model: this.currentModel,
|
|
141
|
-
messages,
|
|
262
|
+
messages: patchedMessages,
|
|
142
263
|
tools: formattedTools,
|
|
143
264
|
stream: options?.stream ?? true,
|
|
144
265
|
conversationId: options?.conversationId,
|
|
@@ -157,7 +278,7 @@ export class OpenAIProvider {
|
|
|
157
278
|
const response = await fetch(responsesURL, {
|
|
158
279
|
method: 'POST',
|
|
159
280
|
headers: {
|
|
160
|
-
Authorization: `Bearer ${
|
|
281
|
+
Authorization: `Bearer ${apiKey}`,
|
|
161
282
|
'Content-Type': 'application/json; charset=utf-8',
|
|
162
283
|
},
|
|
163
284
|
body: bodyBlob,
|
|
@@ -192,7 +313,7 @@ export class OpenAIProvider {
|
|
|
192
313
|
const retryResponse = await fetch(responsesURL, {
|
|
193
314
|
method: 'POST',
|
|
194
315
|
headers: {
|
|
195
|
-
Authorization: `Bearer ${
|
|
316
|
+
Authorization: `Bearer ${apiKey}`,
|
|
196
317
|
'Content-Type': 'application/json; charset=utf-8',
|
|
197
318
|
},
|
|
198
319
|
body: retryBodyBlob,
|
|
@@ -286,11 +407,18 @@ export class OpenAIProvider {
|
|
|
286
407
|
})();
|
|
287
408
|
}
|
|
288
409
|
async getModels() {
|
|
289
|
-
// Check if API key is available
|
|
290
|
-
|
|
410
|
+
// Check if API key is available (using resolved authentication)
|
|
411
|
+
const apiKey = await this.getAuthToken();
|
|
412
|
+
if (!apiKey) {
|
|
413
|
+
const endpoint = this.baseURL || 'https://api.openai.com/v1';
|
|
414
|
+
if (this.isOAuthEnabled() && !this.supportsOAuth()) {
|
|
415
|
+
throw new Error(generateOAuthEndpointMismatchError(endpoint, 'qwen'));
|
|
416
|
+
}
|
|
291
417
|
throw new Error('OpenAI API key is required to fetch models');
|
|
292
418
|
}
|
|
293
419
|
try {
|
|
420
|
+
// Get resolved authentication and update client if needed
|
|
421
|
+
await this.updateClientWithResolvedAuth();
|
|
294
422
|
const response = await this.openai.models.list();
|
|
295
423
|
const models = [];
|
|
296
424
|
for await (const model of response) {
|
|
@@ -311,6 +439,18 @@ export class OpenAIProvider {
|
|
|
311
439
|
console.error('Error fetching models from OpenAI:', error);
|
|
312
440
|
}
|
|
313
441
|
// Return a hardcoded list as fallback
|
|
442
|
+
// Check if this is a Qwen endpoint
|
|
443
|
+
if (isQwenEndpoint(this.baseURL || '')) {
|
|
444
|
+
return [
|
|
445
|
+
{
|
|
446
|
+
id: 'qwen3-coder-plus',
|
|
447
|
+
name: 'qwen3-coder-plus',
|
|
448
|
+
provider: 'openai',
|
|
449
|
+
supportedToolFormats: ['openai'],
|
|
450
|
+
},
|
|
451
|
+
];
|
|
452
|
+
}
|
|
453
|
+
// Default OpenAI models
|
|
314
454
|
return [
|
|
315
455
|
{
|
|
316
456
|
id: 'gpt-4o',
|
|
@@ -340,8 +480,13 @@ export class OpenAIProvider {
|
|
|
340
480
|
}
|
|
341
481
|
}
|
|
342
482
|
async *generateChatCompletion(messages, tools, _toolFormat) {
|
|
343
|
-
// Check if API key is available
|
|
344
|
-
|
|
483
|
+
// Check if API key is available (using resolved authentication)
|
|
484
|
+
const apiKey = await this.getAuthToken();
|
|
485
|
+
if (!apiKey) {
|
|
486
|
+
const endpoint = this.baseURL || 'https://api.openai.com/v1';
|
|
487
|
+
if (this.isOAuthEnabled() && !this.supportsOAuth()) {
|
|
488
|
+
throw new Error(generateOAuthEndpointMismatchError(endpoint, 'qwen'));
|
|
489
|
+
}
|
|
345
490
|
throw new Error('OpenAI API key is required to generate completions');
|
|
346
491
|
}
|
|
347
492
|
// Check if we should use responses endpoint
|
|
@@ -372,14 +517,17 @@ export class OpenAIProvider {
|
|
|
372
517
|
: null;
|
|
373
518
|
// Get current tool format (with override support)
|
|
374
519
|
const currentToolFormat = this.getToolFormat();
|
|
375
|
-
// Format tools using
|
|
376
|
-
const formattedTools = tools
|
|
377
|
-
? this.toolFormatter.toProviderFormat(tools, currentToolFormat)
|
|
378
|
-
: undefined;
|
|
520
|
+
// Format tools using formatToolsForAPI method
|
|
521
|
+
const formattedTools = tools ? this.formatToolsForAPI(tools) : undefined;
|
|
379
522
|
// Get stream_options from ephemeral settings (not model params)
|
|
380
|
-
const streamOptions = this.
|
|
523
|
+
const streamOptions = this.providerConfig?.getEphemeralSettings?.()?.['stream-options'];
|
|
381
524
|
// Default stream_options to { include_usage: true } unless explicitly set
|
|
382
525
|
const finalStreamOptions = streamOptions !== undefined ? streamOptions : { include_usage: true };
|
|
526
|
+
// Get resolved authentication and update client if needed
|
|
527
|
+
await this.updateClientWithResolvedAuth();
|
|
528
|
+
if (process.env.DEBUG) {
|
|
529
|
+
console.log(`[OpenAI] About to make API call with model: ${this.currentModel}, baseURL: ${this.openai.baseURL}, apiKey: ${this.openai.apiKey?.substring(0, 10)}...`);
|
|
530
|
+
}
|
|
383
531
|
// Build request params with exact order from original
|
|
384
532
|
const stream = await this.openai.chat.completions.create({
|
|
385
533
|
model: this.currentModel,
|
|
@@ -389,7 +537,7 @@ export class OpenAIProvider {
|
|
|
389
537
|
? { stream_options: finalStreamOptions }
|
|
390
538
|
: {}),
|
|
391
539
|
tools: formattedTools,
|
|
392
|
-
tool_choice: tools
|
|
540
|
+
tool_choice: this.getToolChoiceForFormat(tools),
|
|
393
541
|
...this.modelParams,
|
|
394
542
|
});
|
|
395
543
|
let fullContent = '';
|
|
@@ -402,7 +550,7 @@ export class OpenAIProvider {
|
|
|
402
550
|
const delta = chunk.choices[0]?.delta;
|
|
403
551
|
if (delta?.content) {
|
|
404
552
|
// Enhanced debug logging to understand streaming behavior
|
|
405
|
-
if (process.env.DEBUG && this.
|
|
553
|
+
if (process.env.DEBUG && this.isUsingQwen()) {
|
|
406
554
|
console.log(`[OpenAIProvider/${this.currentModel}] Chunk:`, {
|
|
407
555
|
content: delta.content,
|
|
408
556
|
contentLength: delta.content.length,
|
|
@@ -412,7 +560,7 @@ export class OpenAIProvider {
|
|
|
412
560
|
}
|
|
413
561
|
// For text-based models, don't yield content chunks yet
|
|
414
562
|
if (!parser) {
|
|
415
|
-
if (this.
|
|
563
|
+
if (this.isUsingQwen()) {
|
|
416
564
|
const isWhitespaceOnly = delta.content.trim() === '';
|
|
417
565
|
if (isWhitespaceOnly) {
|
|
418
566
|
// Buffer whitespace-only chunk
|
|
@@ -459,7 +607,7 @@ export class OpenAIProvider {
|
|
|
459
607
|
}
|
|
460
608
|
}
|
|
461
609
|
// Flush any remaining pending whitespace for Qwen
|
|
462
|
-
if (pendingWhitespace && this.
|
|
610
|
+
if (pendingWhitespace && this.isUsingQwen() && !parser) {
|
|
463
611
|
if (process.env.DEBUG) {
|
|
464
612
|
console.log(`[OpenAIProvider/${this.currentModel}] Flushing trailing pending whitespace (len=${pendingWhitespace.length}) at stream end`);
|
|
465
613
|
}
|
|
@@ -503,7 +651,7 @@ export class OpenAIProvider {
|
|
|
503
651
|
else {
|
|
504
652
|
// Standard OpenAI tool call handling
|
|
505
653
|
if (accumulatedToolCalls.length > 0) {
|
|
506
|
-
if (process.env.DEBUG && this.
|
|
654
|
+
if (process.env.DEBUG && this.isUsingQwen()) {
|
|
507
655
|
console.log(`[OpenAIProvider/${this.currentModel}] Final message with tool calls:`, {
|
|
508
656
|
contentLength: fullContent.length,
|
|
509
657
|
content: fullContent.substring(0, 200) +
|
|
@@ -513,7 +661,7 @@ export class OpenAIProvider {
|
|
|
513
661
|
});
|
|
514
662
|
}
|
|
515
663
|
// For Qwen models, don't duplicate content if we've already streamed it
|
|
516
|
-
const shouldOmitContent = hasStreamedContent && this.
|
|
664
|
+
const shouldOmitContent = hasStreamedContent && this.isUsingQwen();
|
|
517
665
|
if (shouldOmitContent) {
|
|
518
666
|
// Only yield tool calls with empty content to avoid duplication
|
|
519
667
|
yield {
|
|
@@ -544,40 +692,94 @@ export class OpenAIProvider {
|
|
|
544
692
|
}
|
|
545
693
|
}
|
|
546
694
|
setModel(modelId) {
|
|
695
|
+
// Update SettingsService as the source of truth
|
|
696
|
+
this.setModelInSettings(modelId).catch((error) => {
|
|
697
|
+
if (process.env.DEBUG) {
|
|
698
|
+
console.warn('Failed to persist model to SettingsService:', error);
|
|
699
|
+
}
|
|
700
|
+
});
|
|
701
|
+
// Keep local cache for performance
|
|
547
702
|
this.currentModel = modelId;
|
|
548
703
|
}
|
|
549
704
|
getCurrentModel() {
|
|
550
|
-
|
|
705
|
+
// Try to get from SettingsService first (source of truth)
|
|
706
|
+
try {
|
|
707
|
+
const settingsService = getSettingsService();
|
|
708
|
+
const providerSettings = settingsService.getProviderSettings(this.name);
|
|
709
|
+
if (providerSettings.model) {
|
|
710
|
+
return providerSettings.model;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
catch (error) {
|
|
714
|
+
if (process.env.DEBUG) {
|
|
715
|
+
console.warn('Failed to get model from SettingsService:', error);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
// Fall back to cached value or default
|
|
719
|
+
return this.currentModel || this.getDefaultModel();
|
|
720
|
+
}
|
|
721
|
+
getDefaultModel() {
|
|
722
|
+
// Return the default model for this provider
|
|
723
|
+
// This can be overridden based on configuration or endpoint
|
|
724
|
+
if (this.isUsingQwen()) {
|
|
725
|
+
return 'qwen3-coder-plus';
|
|
726
|
+
}
|
|
727
|
+
return 'gpt-4.1';
|
|
551
728
|
}
|
|
552
729
|
setApiKey(apiKey) {
|
|
553
|
-
|
|
730
|
+
// Call base provider implementation
|
|
731
|
+
super.setApiKey?.(apiKey);
|
|
732
|
+
// Persist to SettingsService if available
|
|
733
|
+
this.setApiKeyInSettings(apiKey).catch((error) => {
|
|
734
|
+
if (process.env.DEBUG) {
|
|
735
|
+
console.warn('Failed to persist API key to SettingsService:', error);
|
|
736
|
+
}
|
|
737
|
+
});
|
|
554
738
|
// Create a new OpenAI client with the updated API key
|
|
555
739
|
const clientOptions = {
|
|
556
740
|
apiKey,
|
|
557
|
-
dangerouslyAllowBrowser: this.
|
|
741
|
+
dangerouslyAllowBrowser: this.providerConfig?.allowBrowserEnvironment || false,
|
|
558
742
|
};
|
|
559
743
|
// Only include baseURL if it's defined
|
|
560
744
|
if (this.baseURL) {
|
|
561
745
|
clientOptions.baseURL = this.baseURL;
|
|
562
746
|
}
|
|
563
747
|
this.openai = new OpenAI(clientOptions);
|
|
748
|
+
this._cachedClientKey = apiKey; // Update cached key
|
|
564
749
|
}
|
|
565
750
|
setBaseUrl(baseUrl) {
|
|
566
751
|
// If no baseUrl is provided, clear to default (undefined)
|
|
567
752
|
this.baseURL = baseUrl && baseUrl.trim() !== '' ? baseUrl : undefined;
|
|
753
|
+
// Persist to SettingsService if available
|
|
754
|
+
this.setBaseUrlInSettings(this.baseURL).catch((error) => {
|
|
755
|
+
if (process.env.DEBUG) {
|
|
756
|
+
console.warn('Failed to persist base URL to SettingsService:', error);
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
// Update OAuth configuration based on endpoint validation
|
|
760
|
+
// Enable OAuth for Qwen endpoints if we have an OAuth manager
|
|
761
|
+
const shouldEnableQwenOAuth = !!this.baseProviderConfig.oauthManager &&
|
|
762
|
+
(isQwenEndpoint(this.baseURL || '') ||
|
|
763
|
+
this.baseURL === 'https://portal.qwen.ai/v1');
|
|
764
|
+
this.updateOAuthConfig(shouldEnableQwenOAuth, shouldEnableQwenOAuth ? 'qwen' : undefined, this.baseProviderConfig.oauthManager);
|
|
765
|
+
// Call base provider implementation
|
|
766
|
+
super.setBaseUrl?.(baseUrl);
|
|
568
767
|
// Create a new OpenAI client with the updated (or cleared) base URL
|
|
569
768
|
const clientOptions = {
|
|
570
|
-
|
|
571
|
-
|
|
769
|
+
// Use existing key or empty string as placeholder
|
|
770
|
+
apiKey: this._cachedClientKey || 'placeholder',
|
|
771
|
+
dangerouslyAllowBrowser: this.providerConfig?.allowBrowserEnvironment || false,
|
|
572
772
|
};
|
|
573
773
|
// Only include baseURL if it's defined
|
|
574
774
|
if (this.baseURL) {
|
|
575
775
|
clientOptions.baseURL = this.baseURL;
|
|
576
776
|
}
|
|
577
777
|
this.openai = new OpenAI(clientOptions);
|
|
778
|
+
// Clear cached key to force re-resolution on next API call
|
|
779
|
+
this._cachedClientKey = undefined;
|
|
578
780
|
}
|
|
579
781
|
setConfig(config) {
|
|
580
|
-
this.
|
|
782
|
+
this.providerConfig = config;
|
|
581
783
|
}
|
|
582
784
|
setToolFormatOverride(format) {
|
|
583
785
|
this.toolFormatOverride = format || undefined;
|
|
@@ -633,6 +835,12 @@ export class OpenAIProvider {
|
|
|
633
835
|
else {
|
|
634
836
|
this.modelParams = { ...this.modelParams, ...params };
|
|
635
837
|
}
|
|
838
|
+
// Persist to SettingsService if available
|
|
839
|
+
this.setModelParamsInSettings(this.modelParams).catch((error) => {
|
|
840
|
+
if (process.env.DEBUG) {
|
|
841
|
+
console.warn('Failed to persist model params to SettingsService:', error);
|
|
842
|
+
}
|
|
843
|
+
});
|
|
636
844
|
}
|
|
637
845
|
/**
|
|
638
846
|
* Get current model parameters
|
|
@@ -641,5 +849,130 @@ export class OpenAIProvider {
|
|
|
641
849
|
getModelParams() {
|
|
642
850
|
return this.modelParams;
|
|
643
851
|
}
|
|
852
|
+
/**
|
|
853
|
+
* Initialize provider configuration from SettingsService
|
|
854
|
+
*/
|
|
855
|
+
async initializeFromSettings() {
|
|
856
|
+
try {
|
|
857
|
+
const _settingsService = getSettingsService();
|
|
858
|
+
// Load saved model if available
|
|
859
|
+
const savedModel = await this.getModelFromSettings();
|
|
860
|
+
if (savedModel) {
|
|
861
|
+
this.currentModel = savedModel;
|
|
862
|
+
}
|
|
863
|
+
// Load saved base URL if available
|
|
864
|
+
const savedBaseUrl = await this.getBaseUrlFromSettings();
|
|
865
|
+
if (savedBaseUrl !== undefined) {
|
|
866
|
+
this.baseURL = savedBaseUrl;
|
|
867
|
+
}
|
|
868
|
+
// Load saved model parameters if available
|
|
869
|
+
const savedParams = await this.getModelParamsFromSettings();
|
|
870
|
+
if (savedParams) {
|
|
871
|
+
this.modelParams = savedParams;
|
|
872
|
+
}
|
|
873
|
+
if (process.env.DEBUG) {
|
|
874
|
+
console.log(`[OpenAI] Initialized from SettingsService - model: ${this.currentModel}, baseURL: ${this.baseURL}, params:`, this.modelParams);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
catch (error) {
|
|
878
|
+
if (process.env.DEBUG) {
|
|
879
|
+
console.error('Failed to initialize OpenAI provider from SettingsService:', error);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* Check if the provider is authenticated using any available method
|
|
885
|
+
* Uses the base provider's isAuthenticated implementation
|
|
886
|
+
*/
|
|
887
|
+
async isAuthenticated() {
|
|
888
|
+
return super.isAuthenticated();
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* Detect the appropriate tool format for the current model/configuration
|
|
892
|
+
* @returns The detected tool format
|
|
893
|
+
*/
|
|
894
|
+
detectToolFormat() {
|
|
895
|
+
try {
|
|
896
|
+
const settingsService = getSettingsService();
|
|
897
|
+
// First check SettingsService for toolFormat override in provider settings
|
|
898
|
+
// Note: This is synchronous access to cached settings, not async
|
|
899
|
+
const currentSettings = settingsService['settings'];
|
|
900
|
+
const providerSettings = currentSettings?.providers?.[this.name];
|
|
901
|
+
const toolFormatOverride = providerSettings?.toolFormat;
|
|
902
|
+
// If explicitly set to a specific format (not 'auto'), use it
|
|
903
|
+
if (toolFormatOverride && toolFormatOverride !== 'auto') {
|
|
904
|
+
return toolFormatOverride;
|
|
905
|
+
}
|
|
906
|
+
// Auto-detect based on model name if set to 'auto' or not set
|
|
907
|
+
const modelName = this.currentModel.toLowerCase();
|
|
908
|
+
// Check for GLM-4.5 models (glm-4.5, glm-4-5)
|
|
909
|
+
if (modelName.includes('glm-4.5') || modelName.includes('glm-4-5')) {
|
|
910
|
+
return 'qwen';
|
|
911
|
+
}
|
|
912
|
+
// Check for qwen models
|
|
913
|
+
if (modelName.includes('qwen')) {
|
|
914
|
+
return 'qwen';
|
|
915
|
+
}
|
|
916
|
+
// Default to 'openai' format
|
|
917
|
+
return 'openai';
|
|
918
|
+
}
|
|
919
|
+
catch (error) {
|
|
920
|
+
if (process.env.DEBUG) {
|
|
921
|
+
console.warn('Failed to detect tool format from SettingsService:', error);
|
|
922
|
+
}
|
|
923
|
+
// Fallback detection without SettingsService
|
|
924
|
+
const modelName = this.currentModel.toLowerCase();
|
|
925
|
+
if (modelName.includes('glm-4.5') || modelName.includes('glm-4-5')) {
|
|
926
|
+
return 'qwen';
|
|
927
|
+
}
|
|
928
|
+
if (modelName.includes('qwen')) {
|
|
929
|
+
return 'qwen';
|
|
930
|
+
}
|
|
931
|
+
return 'openai';
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Get appropriate tool_choice value based on detected tool format
|
|
936
|
+
* @param tools Array of tools (if any)
|
|
937
|
+
* @returns Appropriate tool_choice value for the current format
|
|
938
|
+
*/
|
|
939
|
+
getToolChoiceForFormat(tools) {
|
|
940
|
+
if (!tools || tools.length === 0) {
|
|
941
|
+
return undefined;
|
|
942
|
+
}
|
|
943
|
+
// For all formats, use 'auto' (standard behavior)
|
|
944
|
+
// Future enhancement: different formats may need different tool_choice values
|
|
945
|
+
return 'auto';
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
948
|
+
* Format tools for API based on detected tool format
|
|
949
|
+
* @param tools Array of tools to format
|
|
950
|
+
* @returns Formatted tools for API consumption
|
|
951
|
+
*/
|
|
952
|
+
formatToolsForAPI(tools) {
|
|
953
|
+
// For now, always use OpenAI format through OpenRouter
|
|
954
|
+
// TODO: Investigate if OpenRouter needs special handling for GLM/Qwen
|
|
955
|
+
// const detectedFormat = this.detectToolFormat();
|
|
956
|
+
// if (detectedFormat === 'qwen') {
|
|
957
|
+
// // Convert OpenAI format to Qwen format: {name, description, parameters} without type/function wrapper
|
|
958
|
+
// return tools.map((tool) => ({
|
|
959
|
+
// name: tool.function.name,
|
|
960
|
+
// description: tool.function.description,
|
|
961
|
+
// parameters: tool.function.parameters,
|
|
962
|
+
// }));
|
|
963
|
+
// }
|
|
964
|
+
// For all formats, use the existing ToolFormatter
|
|
965
|
+
return this.toolFormatter.toProviderFormat(tools, 'openai');
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* Parse tool response from API (placeholder for future response parsing)
|
|
969
|
+
* @param response The raw API response
|
|
970
|
+
* @returns Parsed tool response
|
|
971
|
+
*/
|
|
972
|
+
parseToolResponse(response) {
|
|
973
|
+
// TODO: Implement response parsing based on detected format
|
|
974
|
+
// For now, return the response as-is
|
|
975
|
+
return response;
|
|
976
|
+
}
|
|
644
977
|
}
|
|
645
978
|
//# sourceMappingURL=OpenAIProvider.js.map
|