@juspay/neurolink 9.65.1 → 9.66.0
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/CHANGELOG.md +8 -0
- package/dist/adapters/video/videoAnalyzer.d.ts +1 -1
- package/dist/agent/directTools.d.ts +9 -17
- package/dist/agent/directTools.js +1 -5
- package/dist/autoresearch/tools.d.ts +2 -214
- package/dist/autoresearch/tools.js +1 -1
- package/dist/browser/neurolink.min.js +388 -386
- package/dist/cli/commands/proxy.js +154 -5
- package/dist/client/reactHooks.js +16 -8
- package/dist/client/reactHooks.tsx +24 -9
- package/dist/core/baseProvider.d.ts +1 -6
- package/dist/core/baseProvider.js +1 -1
- package/dist/core/modules/GenerationHandler.d.ts +2 -2
- package/dist/core/modules/GenerationHandler.js +3 -1
- package/dist/core/modules/MessageBuilder.d.ts +1 -15
- package/dist/core/modules/MessageBuilder.js +0 -14
- package/dist/core/modules/StreamHandler.js +1 -1
- package/dist/core/modules/ToolsManager.d.ts +1 -17
- package/dist/core/modules/ToolsManager.js +1 -17
- package/dist/core/streamAnalytics.js +1 -1
- package/dist/evaluation/contextBuilder.d.ts +1 -4
- package/dist/evaluation/contextBuilder.js +0 -3
- package/dist/evaluation/index.d.ts +1 -4
- package/dist/evaluation/index.js +0 -3
- package/dist/files/fileTools.d.ts +2 -18
- package/dist/files/fileTools.js +3 -19
- package/dist/lib/adapters/video/videoAnalyzer.d.ts +1 -1
- package/dist/lib/agent/directTools.d.ts +9 -17
- package/dist/lib/agent/directTools.js +1 -5
- package/dist/lib/autoresearch/tools.d.ts +2 -214
- package/dist/lib/autoresearch/tools.js +1 -1
- package/dist/lib/client/reactHooks.js +16 -8
- package/dist/lib/core/baseProvider.d.ts +1 -6
- package/dist/lib/core/baseProvider.js +1 -1
- package/dist/lib/core/modules/GenerationHandler.d.ts +2 -2
- package/dist/lib/core/modules/GenerationHandler.js +3 -1
- package/dist/lib/core/modules/MessageBuilder.d.ts +1 -15
- package/dist/lib/core/modules/MessageBuilder.js +0 -14
- package/dist/lib/core/modules/StreamHandler.js +1 -1
- package/dist/lib/core/modules/ToolsManager.d.ts +1 -17
- package/dist/lib/core/modules/ToolsManager.js +1 -17
- package/dist/lib/core/streamAnalytics.js +1 -1
- package/dist/lib/evaluation/contextBuilder.d.ts +1 -4
- package/dist/lib/evaluation/contextBuilder.js +0 -3
- package/dist/lib/evaluation/index.d.ts +1 -4
- package/dist/lib/evaluation/index.js +0 -3
- package/dist/lib/files/fileTools.d.ts +2 -18
- package/dist/lib/files/fileTools.js +3 -19
- package/dist/lib/memory/memoryRetrievalTools.d.ts +2 -126
- package/dist/lib/memory/memoryRetrievalTools.js +1 -9
- package/dist/lib/middleware/builtin/autoEvaluation.d.ts +0 -3
- package/dist/lib/middleware/builtin/autoEvaluation.js +0 -3
- package/dist/lib/middleware/builtin/guardrails.js +1 -1
- package/dist/lib/middleware/builtin/lifecycle.d.ts +0 -9
- package/dist/lib/middleware/builtin/lifecycle.js +0 -9
- package/dist/lib/middleware/factory.d.ts +1 -1
- package/dist/lib/middleware/factory.js +1 -1
- package/dist/lib/middleware/registry.d.ts +1 -1
- package/dist/lib/neurolink.d.ts +14 -2
- package/dist/lib/neurolink.js +46 -18
- package/dist/lib/processors/media/AudioProcessor.js +8 -3
- package/dist/lib/providers/amazonBedrock.js +1 -2
- package/dist/lib/providers/amazonSagemaker.d.ts +1 -7
- package/dist/lib/providers/amazonSagemaker.js +0 -6
- package/dist/lib/providers/anthropic.d.ts +1 -1
- package/dist/lib/providers/anthropic.js +2 -1
- package/dist/lib/providers/anthropicBaseProvider.d.ts +1 -1
- package/dist/lib/providers/anthropicBaseProvider.js +2 -1
- package/dist/lib/providers/azureOpenai.d.ts +1 -1
- package/dist/lib/providers/azureOpenai.js +2 -1
- package/dist/lib/providers/cloudflare.d.ts +1 -1
- package/dist/lib/providers/cloudflare.js +2 -1
- package/dist/lib/providers/cohere.d.ts +1 -1
- package/dist/lib/providers/cohere.js +2 -1
- package/dist/lib/providers/deepseek.d.ts +1 -1
- package/dist/lib/providers/deepseek.js +2 -1
- package/dist/lib/providers/fireworks.d.ts +1 -1
- package/dist/lib/providers/fireworks.js +2 -1
- package/dist/lib/providers/googleAiStudio.d.ts +1 -1
- package/dist/lib/providers/googleAiStudio.js +0 -1
- package/dist/lib/providers/googleNativeGemini3.d.ts +1 -1
- package/dist/lib/providers/googleNativeGemini3.js +1 -1
- package/dist/lib/providers/googleVertex.d.ts +1 -1
- package/dist/lib/providers/googleVertex.js +0 -1
- package/dist/lib/providers/groq.d.ts +1 -1
- package/dist/lib/providers/groq.js +2 -1
- package/dist/lib/providers/huggingFace.d.ts +1 -1
- package/dist/lib/providers/huggingFace.js +3 -1
- package/dist/lib/providers/ideogram.d.ts +1 -1
- package/dist/lib/providers/jina.d.ts +1 -1
- package/dist/lib/providers/litellm.d.ts +1 -1
- package/dist/lib/providers/litellm.js +12 -6
- package/dist/lib/providers/llamaCpp.d.ts +1 -1
- package/dist/lib/providers/llamaCpp.js +2 -1
- package/dist/lib/providers/lmStudio.d.ts +1 -1
- package/dist/lib/providers/lmStudio.js +2 -1
- package/dist/lib/providers/mistral.d.ts +1 -1
- package/dist/lib/providers/mistral.js +2 -1
- package/dist/lib/providers/nvidiaNim.d.ts +1 -1
- package/dist/lib/providers/nvidiaNim.js +2 -1
- package/dist/lib/providers/ollama.d.ts +1 -1
- package/dist/lib/providers/ollama.js +1 -2
- package/dist/lib/providers/openAI.d.ts +1 -1
- package/dist/lib/providers/openAI.js +3 -1
- package/dist/lib/providers/openRouter.d.ts +1 -1
- package/dist/lib/providers/openRouter.js +3 -1
- package/dist/lib/providers/openaiCompatible.d.ts +1 -1
- package/dist/lib/providers/openaiCompatible.js +3 -1
- package/dist/lib/providers/perplexity.d.ts +1 -1
- package/dist/lib/providers/perplexity.js +2 -1
- package/dist/lib/providers/providerTypeUtils.d.ts +2 -7
- package/dist/lib/providers/providerTypeUtils.js +0 -6
- package/dist/lib/providers/recraft.d.ts +1 -1
- package/dist/lib/providers/replicate.d.ts +1 -1
- package/dist/lib/providers/stability.d.ts +1 -1
- package/dist/lib/providers/togetherAi.d.ts +1 -1
- package/dist/lib/providers/togetherAi.js +2 -1
- package/dist/lib/providers/voyage.d.ts +1 -1
- package/dist/lib/providers/xai.d.ts +1 -1
- package/dist/lib/providers/xai.js +2 -1
- package/dist/lib/proxy/claudeFormat.d.ts +0 -15
- package/dist/lib/proxy/claudeFormat.js +1 -11
- package/dist/lib/proxy/modelRouter.d.ts +5 -1
- package/dist/lib/proxy/modelRouter.js +8 -0
- package/dist/lib/proxy/openaiFormat.d.ts +137 -0
- package/dist/lib/proxy/openaiFormat.js +801 -0
- package/dist/lib/proxy/proxyTranslationEngine.d.ts +124 -0
- package/dist/lib/proxy/proxyTranslationEngine.js +679 -0
- package/dist/lib/rag/ragIntegration.d.ts +1 -12
- package/dist/lib/rag/ragIntegration.js +0 -8
- package/dist/lib/server/routes/claudeProxyRoutes.d.ts +6 -5
- package/dist/lib/server/routes/claudeProxyRoutes.js +22 -355
- package/dist/lib/server/routes/index.d.ts +1 -0
- package/dist/lib/server/routes/index.js +10 -2
- package/dist/lib/server/routes/openaiProxyRoutes.d.ts +30 -0
- package/dist/lib/server/routes/openaiProxyRoutes.js +337 -0
- package/dist/lib/tasks/tools/taskTools.d.ts +2 -117
- package/dist/lib/tasks/tools/taskTools.js +1 -10
- package/dist/lib/types/aliases.d.ts +1 -1
- package/dist/lib/types/conversation.d.ts +1 -0
- package/dist/lib/types/evaluation.d.ts +1 -5
- package/dist/lib/types/evaluation.js +0 -4
- package/dist/lib/types/generate.d.ts +2 -22
- package/dist/lib/types/guardrails.d.ts +1 -1
- package/dist/lib/types/middleware.d.ts +8 -3
- package/dist/lib/types/providers.d.ts +2 -1
- package/dist/lib/types/proxy.d.ts +179 -0
- package/dist/lib/types/rag.d.ts +1 -1
- package/dist/lib/types/rag.js +0 -6
- package/dist/lib/types/server.d.ts +3 -0
- package/dist/lib/types/stream.d.ts +2 -11
- package/dist/lib/types/tools.d.ts +2 -1
- package/dist/lib/utils/generation.d.ts +8 -0
- package/dist/lib/utils/generation.js +9 -0
- package/dist/lib/utils/generationErrors.d.ts +10 -0
- package/dist/lib/utils/generationErrors.js +11 -0
- package/dist/lib/utils/messageBuilder.d.ts +1 -6
- package/dist/lib/utils/messageBuilder.js +0 -5
- package/dist/lib/utils/noOutputSentinel.d.ts +0 -13
- package/dist/lib/utils/noOutputSentinel.js +1 -14
- package/dist/lib/utils/providerRetry.js +1 -1
- package/dist/lib/utils/tool.d.ts +8 -0
- package/dist/lib/utils/tool.js +9 -0
- package/dist/lib/utils/toolCallRepair.d.ts +1 -16
- package/dist/lib/utils/toolCallRepair.js +1 -16
- package/dist/lib/utils/toolChoice.d.ts +1 -1
- package/dist/lib/utils/videoAnalysisProcessor.d.ts +1 -8
- package/dist/lib/utils/videoAnalysisProcessor.js +0 -7
- package/dist/memory/memoryRetrievalTools.d.ts +2 -126
- package/dist/memory/memoryRetrievalTools.js +1 -9
- package/dist/middleware/builtin/autoEvaluation.d.ts +0 -3
- package/dist/middleware/builtin/autoEvaluation.js +0 -3
- package/dist/middleware/builtin/guardrails.js +1 -1
- package/dist/middleware/builtin/lifecycle.d.ts +0 -9
- package/dist/middleware/builtin/lifecycle.js +0 -9
- package/dist/middleware/factory.d.ts +1 -1
- package/dist/middleware/factory.js +1 -1
- package/dist/middleware/registry.d.ts +1 -1
- package/dist/neurolink.d.ts +14 -2
- package/dist/neurolink.js +46 -18
- package/dist/processors/media/AudioProcessor.js +8 -3
- package/dist/providers/amazonBedrock.js +1 -2
- package/dist/providers/amazonSagemaker.d.ts +1 -7
- package/dist/providers/amazonSagemaker.js +0 -6
- package/dist/providers/anthropic.d.ts +1 -1
- package/dist/providers/anthropic.js +2 -1
- package/dist/providers/anthropicBaseProvider.d.ts +1 -1
- package/dist/providers/anthropicBaseProvider.js +2 -1
- package/dist/providers/azureOpenai.d.ts +1 -1
- package/dist/providers/azureOpenai.js +2 -1
- package/dist/providers/cloudflare.d.ts +1 -1
- package/dist/providers/cloudflare.js +2 -1
- package/dist/providers/cohere.d.ts +1 -1
- package/dist/providers/cohere.js +2 -1
- package/dist/providers/deepseek.d.ts +1 -1
- package/dist/providers/deepseek.js +2 -1
- package/dist/providers/fireworks.d.ts +1 -1
- package/dist/providers/fireworks.js +2 -1
- package/dist/providers/googleAiStudio.d.ts +1 -1
- package/dist/providers/googleNativeGemini3.d.ts +1 -1
- package/dist/providers/googleNativeGemini3.js +1 -1
- package/dist/providers/googleVertex.d.ts +1 -1
- package/dist/providers/groq.d.ts +1 -1
- package/dist/providers/groq.js +2 -1
- package/dist/providers/huggingFace.d.ts +1 -1
- package/dist/providers/huggingFace.js +3 -1
- package/dist/providers/ideogram.d.ts +1 -1
- package/dist/providers/jina.d.ts +1 -1
- package/dist/providers/litellm.d.ts +1 -1
- package/dist/providers/litellm.js +12 -6
- package/dist/providers/llamaCpp.d.ts +1 -1
- package/dist/providers/llamaCpp.js +2 -1
- package/dist/providers/lmStudio.d.ts +1 -1
- package/dist/providers/lmStudio.js +2 -1
- package/dist/providers/mistral.d.ts +1 -1
- package/dist/providers/mistral.js +2 -1
- package/dist/providers/nvidiaNim.d.ts +1 -1
- package/dist/providers/nvidiaNim.js +2 -1
- package/dist/providers/ollama.d.ts +1 -1
- package/dist/providers/ollama.js +1 -2
- package/dist/providers/openAI.d.ts +1 -1
- package/dist/providers/openAI.js +3 -1
- package/dist/providers/openRouter.d.ts +1 -1
- package/dist/providers/openRouter.js +3 -1
- package/dist/providers/openaiCompatible.d.ts +1 -1
- package/dist/providers/openaiCompatible.js +3 -1
- package/dist/providers/perplexity.d.ts +1 -1
- package/dist/providers/perplexity.js +2 -1
- package/dist/providers/providerTypeUtils.d.ts +2 -7
- package/dist/providers/providerTypeUtils.js +0 -6
- package/dist/providers/recraft.d.ts +1 -1
- package/dist/providers/replicate.d.ts +1 -1
- package/dist/providers/stability.d.ts +1 -1
- package/dist/providers/togetherAi.d.ts +1 -1
- package/dist/providers/togetherAi.js +2 -1
- package/dist/providers/voyage.d.ts +1 -1
- package/dist/providers/xai.d.ts +1 -1
- package/dist/providers/xai.js +2 -1
- package/dist/proxy/claudeFormat.d.ts +0 -15
- package/dist/proxy/claudeFormat.js +1 -11
- package/dist/proxy/modelRouter.d.ts +5 -1
- package/dist/proxy/modelRouter.js +8 -0
- package/dist/proxy/openaiFormat.d.ts +137 -0
- package/dist/proxy/openaiFormat.js +800 -0
- package/dist/proxy/proxyTranslationEngine.d.ts +124 -0
- package/dist/proxy/proxyTranslationEngine.js +678 -0
- package/dist/rag/ragIntegration.d.ts +1 -12
- package/dist/rag/ragIntegration.js +0 -8
- package/dist/server/routes/claudeProxyRoutes.d.ts +6 -5
- package/dist/server/routes/claudeProxyRoutes.js +22 -355
- package/dist/server/routes/index.d.ts +1 -0
- package/dist/server/routes/index.js +10 -2
- package/dist/server/routes/openaiProxyRoutes.d.ts +30 -0
- package/dist/server/routes/openaiProxyRoutes.js +336 -0
- package/dist/tasks/tools/taskTools.d.ts +2 -117
- package/dist/tasks/tools/taskTools.js +1 -10
- package/dist/types/aliases.d.ts +1 -1
- package/dist/types/conversation.d.ts +1 -0
- package/dist/types/evaluation.d.ts +1 -5
- package/dist/types/evaluation.js +0 -4
- package/dist/types/generate.d.ts +2 -22
- package/dist/types/guardrails.d.ts +1 -1
- package/dist/types/middleware.d.ts +8 -3
- package/dist/types/providers.d.ts +2 -1
- package/dist/types/proxy.d.ts +179 -0
- package/dist/types/rag.d.ts +1 -1
- package/dist/types/rag.js +0 -6
- package/dist/types/server.d.ts +3 -0
- package/dist/types/stream.d.ts +2 -11
- package/dist/types/tools.d.ts +2 -1
- package/dist/utils/generation.d.ts +8 -0
- package/dist/utils/generation.js +8 -0
- package/dist/utils/generationErrors.d.ts +10 -0
- package/dist/utils/generationErrors.js +10 -0
- package/dist/utils/messageBuilder.d.ts +1 -6
- package/dist/utils/messageBuilder.js +0 -5
- package/dist/utils/noOutputSentinel.d.ts +0 -13
- package/dist/utils/noOutputSentinel.js +1 -14
- package/dist/utils/providerRetry.js +1 -1
- package/dist/utils/tool.d.ts +8 -0
- package/dist/utils/tool.js +8 -0
- package/dist/utils/toolCallRepair.d.ts +1 -16
- package/dist/utils/toolCallRepair.js +1 -16
- package/dist/utils/toolChoice.d.ts +1 -1
- package/dist/utils/videoAnalysisProcessor.d.ts +1 -8
- package/dist/utils/videoAnalysisProcessor.js +0 -7
- package/package.json +2 -3
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lifecycle Middleware
|
|
3
|
-
*
|
|
4
|
-
* Provides onFinish, onError, and onChunk callbacks for observing
|
|
5
|
-
* generation and streaming lifecycle events.
|
|
6
|
-
*
|
|
7
|
-
* This middleware is automatically enabled when lifecycle callbacks
|
|
8
|
-
* (onFinish, onError, onChunk) are passed in GenerateOptions or StreamOptions.
|
|
9
|
-
*/
|
|
10
1
|
import type { NeuroLinkMiddleware, LifecycleMiddlewareConfig } from "../../types/index.js";
|
|
11
2
|
export declare function createLifecycleMiddleware(config?: LifecycleMiddlewareConfig): NeuroLinkMiddleware;
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lifecycle Middleware
|
|
3
|
-
*
|
|
4
|
-
* Provides onFinish, onError, and onChunk callbacks for observing
|
|
5
|
-
* generation and streaming lifecycle events.
|
|
6
|
-
*
|
|
7
|
-
* This middleware is automatically enabled when lifecycle callbacks
|
|
8
|
-
* (onFinish, onError, onChunk) are passed in GenerateOptions or StreamOptions.
|
|
9
|
-
*/
|
|
10
1
|
import { logger } from "../../utils/logger.js";
|
|
11
2
|
import { isRecoverableError } from "../../utils/errorHandling.js";
|
|
12
3
|
import { fireOnErrorOnce } from "../../utils/lifecycleCallbacks.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { LanguageModel } from "ai";
|
|
2
1
|
import type { MiddlewareContext, MiddlewareConfig, MiddlewareFactoryOptions, MiddlewareChainStats, MiddlewarePreset, NeuroLinkMiddleware, MiddlewareRegistrationOptions } from "../types/index.js";
|
|
3
2
|
import { MiddlewareRegistry } from "./registry.js";
|
|
3
|
+
import type { LanguageModel } from "../types/index.js";
|
|
4
4
|
/**
|
|
5
5
|
* Middleware factory for creating and applying middleware chains.
|
|
6
6
|
* Each factory instance manages its own registry and configuration.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { wrapLanguageModel } from "ai";
|
|
2
1
|
import { MiddlewareRegistry } from "./registry.js";
|
|
3
2
|
import { createAnalyticsMiddleware } from "./builtin/analytics.js";
|
|
4
3
|
import { createGuardrailsMiddleware } from "./builtin/guardrails.js";
|
|
5
4
|
import { createAutoEvaluationMiddleware } from "./builtin/autoEvaluation.js";
|
|
6
5
|
import { createLifecycleMiddleware } from "./builtin/lifecycle.js";
|
|
7
6
|
import { logger } from "../utils/logger.js";
|
|
7
|
+
import { wrapLanguageModel } from "../utils/generation.js";
|
|
8
8
|
/**
|
|
9
9
|
* Middleware factory for creating and applying middleware chains.
|
|
10
10
|
* Each factory instance manages its own registry and configuration.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { LanguageModelMiddleware } from "ai";
|
|
2
1
|
import type { NeuroLinkMiddleware, MiddlewareConfig, MiddlewareContext, MiddlewareRegistrationOptions, MiddlewareExecutionResult } from "../types/index.js";
|
|
2
|
+
import type { LanguageModelMiddleware } from "../types/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Manages the registration, configuration, and execution of middleware for a single factory instance.
|
|
5
5
|
*/
|
package/dist/neurolink.d.ts
CHANGED
|
@@ -58,8 +58,6 @@ export declare const NEUROLINK_BRAND: unique symbol;
|
|
|
58
58
|
*/
|
|
59
59
|
export declare function isNeuroLink(value: unknown): value is NeuroLink;
|
|
60
60
|
export declare class NeuroLink {
|
|
61
|
-
/** @internal Brand for cross-module identification — see {@link isNeuroLink}. */
|
|
62
|
-
readonly [NEUROLINK_BRAND]: true;
|
|
63
61
|
private mcpInitialized;
|
|
64
62
|
private mcpSkipped;
|
|
65
63
|
private mcpInitPromise;
|
|
@@ -683,6 +681,20 @@ export declare class NeuroLink {
|
|
|
683
681
|
* Attempt MCP generation with retry logic
|
|
684
682
|
*/
|
|
685
683
|
private attemptMCPGeneration;
|
|
684
|
+
/**
|
|
685
|
+
* Non-retryable tool-error predicate shared by `performMCPGenerationRetries`
|
|
686
|
+
* and `tryMCPGeneration`. Returns `true` when the error indicates the model
|
|
687
|
+
* hallucinated a tool name or sent invalid arguments — retrying would
|
|
688
|
+
* re-trigger the same deterministic failure with the same tool set.
|
|
689
|
+
*
|
|
690
|
+
* Belt-and-suspenders: prefers class-identity `.isInstance()` (stable across
|
|
691
|
+
* Phase 5+ native substitution) but falls back to `error.name` and message
|
|
692
|
+
* substring checks so cross-module-boundary errors (Jest, bundlers, wrapped
|
|
693
|
+
* errors) are still caught. The name fallback covers both
|
|
694
|
+
* `AI_InvalidToolInputError` (current v5/v6 SDK) and the legacy
|
|
695
|
+
* `AI_InvalidToolArgumentsError` (v4).
|
|
696
|
+
*/
|
|
697
|
+
private static isNonRetryableToolError;
|
|
686
698
|
/**
|
|
687
699
|
* Perform MCP generation with retry logic
|
|
688
700
|
*/
|
package/dist/neurolink.js
CHANGED
|
@@ -23,6 +23,7 @@ import { ErrorCategory, ErrorSeverity } from "./constants/enums.js";
|
|
|
23
23
|
import { CIRCUIT_BREAKER, CIRCUIT_BREAKER_RESET_MS, MEMORY_THRESHOLDS, NANOSECOND_TO_MS_DIVISOR, PERFORMANCE_THRESHOLDS, PROVIDER_TIMEOUTS, RETRY_ATTEMPTS, RETRY_DELAYS, TOOL_TIMEOUTS, } from "./constants/index.js";
|
|
24
24
|
import { checkContextBudget } from "./context/budgetChecker.js";
|
|
25
25
|
import { ContextCompactor } from "./context/contextCompactor.js";
|
|
26
|
+
import { InvalidToolInputError, NoSuchToolError, } from "./utils/generationErrors.js";
|
|
26
27
|
import { emergencyContentTruncation } from "./context/emergencyTruncation.js";
|
|
27
28
|
import { getContextOverflowProvider, isContextOverflowError, parseProviderOverflowDetails, } from "./context/errorDetection.js";
|
|
28
29
|
import { ContextBudgetExceededError } from "./context/errors.js";
|
|
@@ -4292,6 +4293,43 @@ Current user's request: ${currentInput}`;
|
|
|
4292
4293
|
}
|
|
4293
4294
|
return null;
|
|
4294
4295
|
}
|
|
4296
|
+
/**
|
|
4297
|
+
* Non-retryable tool-error predicate shared by `performMCPGenerationRetries`
|
|
4298
|
+
* and `tryMCPGeneration`. Returns `true` when the error indicates the model
|
|
4299
|
+
* hallucinated a tool name or sent invalid arguments — retrying would
|
|
4300
|
+
* re-trigger the same deterministic failure with the same tool set.
|
|
4301
|
+
*
|
|
4302
|
+
* Belt-and-suspenders: prefers class-identity `.isInstance()` (stable across
|
|
4303
|
+
* Phase 5+ native substitution) but falls back to `error.name` and message
|
|
4304
|
+
* substring checks so cross-module-boundary errors (Jest, bundlers, wrapped
|
|
4305
|
+
* errors) are still caught. The name fallback covers both
|
|
4306
|
+
* `AI_InvalidToolInputError` (current v5/v6 SDK) and the legacy
|
|
4307
|
+
* `AI_InvalidToolArgumentsError` (v4).
|
|
4308
|
+
*/
|
|
4309
|
+
static isNonRetryableToolError(error) {
|
|
4310
|
+
// Class-identity path: only meaningful when the throw really is an Error.
|
|
4311
|
+
if (error instanceof Error &&
|
|
4312
|
+
(NoSuchToolError.isInstance(error) ||
|
|
4313
|
+
InvalidToolInputError.isInstance(error))) {
|
|
4314
|
+
return true;
|
|
4315
|
+
}
|
|
4316
|
+
// Duck-type fallback for non-Error throws, wrapped errors, or values that
|
|
4317
|
+
// serialize to JSON without preserving the prototype chain. Extract name
|
|
4318
|
+
// and message defensively — `error` may be `null`, a string, or an object
|
|
4319
|
+
// with non-string `name`/`message` properties.
|
|
4320
|
+
const errAny = error;
|
|
4321
|
+
const maybeName = errAny && typeof errAny.name === "string" ? errAny.name : "";
|
|
4322
|
+
const maybeMessage = errAny && typeof errAny.message === "string"
|
|
4323
|
+
? errAny.message
|
|
4324
|
+
: String(error ?? "");
|
|
4325
|
+
return (maybeName === "AI_NoSuchToolError" ||
|
|
4326
|
+
maybeName === "AI_InvalidToolInputError" ||
|
|
4327
|
+
maybeName === "AI_InvalidToolArgumentsError" ||
|
|
4328
|
+
maybeMessage.includes("NoSuchToolError") ||
|
|
4329
|
+
maybeMessage.includes("InvalidToolInputError") ||
|
|
4330
|
+
maybeMessage.includes("InvalidToolArgumentsError") ||
|
|
4331
|
+
maybeMessage.includes("Model tried to call unavailable tool"));
|
|
4332
|
+
}
|
|
4295
4333
|
/**
|
|
4296
4334
|
* Perform MCP generation with retry logic
|
|
4297
4335
|
*/
|
|
@@ -4353,15 +4391,10 @@ Current user's request: ${currentInput}`;
|
|
|
4353
4391
|
willRetry: attempt < maxAttempts,
|
|
4354
4392
|
retryCount,
|
|
4355
4393
|
});
|
|
4356
|
-
// Check for non-retryable errors —
|
|
4357
|
-
//
|
|
4358
|
-
//
|
|
4359
|
-
|
|
4360
|
-
const isToolError = error instanceof Error &&
|
|
4361
|
-
(error.name === "AI_NoSuchToolError" ||
|
|
4362
|
-
error.name === "AI_InvalidToolArgumentsError" ||
|
|
4363
|
-
error.message.includes("NoSuchToolError") ||
|
|
4364
|
-
error.message.includes("Model tried to call unavailable tool"));
|
|
4394
|
+
// Check for non-retryable errors — see NeuroLink.isNonRetryableToolError.
|
|
4395
|
+
// Skipping remaining retries when the model hallucinated a tool name or
|
|
4396
|
+
// sent bad arguments avoids re-triggering the same deterministic failure.
|
|
4397
|
+
const isToolError = NeuroLink.isNonRetryableToolError(error);
|
|
4365
4398
|
const isNonRetryable = isContextOverflowError(error) ||
|
|
4366
4399
|
isToolError ||
|
|
4367
4400
|
isNonRetryableProviderError(error) ||
|
|
@@ -4434,15 +4467,10 @@ Current user's request: ${currentInput}`;
|
|
|
4434
4467
|
mcpLogger.debug(`[${functionTag}] AbortError detected, rethrowing`);
|
|
4435
4468
|
throw error;
|
|
4436
4469
|
}
|
|
4437
|
-
// Propagate non-retryable errors
|
|
4438
|
-
//
|
|
4439
|
-
//
|
|
4440
|
-
const isToolError = error
|
|
4441
|
-
(error.name === "AI_NoSuchToolError" ||
|
|
4442
|
-
error.name === "AI_InvalidToolArgumentsError" ||
|
|
4443
|
-
(error.message &&
|
|
4444
|
-
(error.message.includes("NoSuchToolError") ||
|
|
4445
|
-
error.message.includes("Model tried to call unavailable tool"))));
|
|
4470
|
+
// Propagate non-retryable tool errors — see NeuroLink.isNonRetryableToolError.
|
|
4471
|
+
// The caller's retry loop detects this and breaks immediately instead of
|
|
4472
|
+
// retrying the same deterministic failure.
|
|
4473
|
+
const isToolError = NeuroLink.isNonRetryableToolError(error);
|
|
4446
4474
|
if (isToolError) {
|
|
4447
4475
|
mcpLogger.warn(`[${functionTag}] Non-retryable tool error, rethrowing`, {
|
|
4448
4476
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
import { BaseFileProcessor } from "../base/BaseFileProcessor.js";
|
|
40
40
|
import { SIZE_LIMITS_MB } from "../config/index.js";
|
|
41
41
|
import { FileErrorCode } from "../errors/index.js";
|
|
42
|
+
import { withTimeout } from "../../utils/timeout.js";
|
|
42
43
|
let _musicMetadata = null;
|
|
43
44
|
async function loadMusicMetadata() {
|
|
44
45
|
if (_musicMetadata) {
|
|
@@ -354,13 +355,17 @@ export class AudioProcessor extends BaseFileProcessor {
|
|
|
354
355
|
}
|
|
355
356
|
try {
|
|
356
357
|
// Dynamic imports to avoid loading these modules when transcription is not needed
|
|
357
|
-
const [{ createOpenAI }, { experimental_transcribe }] = await Promise.all([import("@ai-sdk/openai"), import("
|
|
358
|
+
const [{ createOpenAI }, { experimental_transcribe }] = await Promise.all([import("@ai-sdk/openai"), import("../../utils/generation.js")]);
|
|
358
359
|
const openai = createOpenAI({ apiKey });
|
|
359
360
|
const model = openai.transcription("whisper-1");
|
|
360
|
-
|
|
361
|
+
// Wrap in withTimeout — large audio files can take a while, but a
|
|
362
|
+
// stalled request shouldn't block the processor forever. The outer
|
|
363
|
+
// catch swallows any error (transcription is best-effort), so a
|
|
364
|
+
// TimeoutError ends up in the same fallback path as other failures.
|
|
365
|
+
const result = await withTimeout(experimental_transcribe({
|
|
361
366
|
model,
|
|
362
367
|
audio: buffer,
|
|
363
|
-
});
|
|
368
|
+
}), AUDIO_CONFIG.TRANSCRIPTION_TIMEOUT_MS, "openai-whisper", "generate");
|
|
364
369
|
if (result.text && result.text.trim().length > 0) {
|
|
365
370
|
return {
|
|
366
371
|
transcript: result.text.trim(),
|
|
@@ -1314,8 +1314,7 @@ export class AmazonBedrockProvider extends BaseProvider {
|
|
|
1314
1314
|
}
|
|
1315
1315
|
// Get all available tools
|
|
1316
1316
|
// BaseProvider.stream() pre-merges base tools + external tools into options.tools
|
|
1317
|
-
const aiTools = options.tools ||
|
|
1318
|
-
(await this.getAllTools());
|
|
1317
|
+
const aiTools = options.tools || (await this.getAllTools());
|
|
1319
1318
|
const allTools = this.convertAISDKToolsToToolDefinitions(aiTools);
|
|
1320
1319
|
const toolConfig = this.formatToolsForBedrock(allTools);
|
|
1321
1320
|
const convertedMessages = this.convertToAWSMessages(this.conversationHistory);
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Amazon SageMaker Provider Implementation (Simplified)
|
|
3
|
-
*
|
|
4
|
-
* This module provides a simplified SageMaker provider that extends BaseProvider
|
|
5
|
-
* and integrates with the NeuroLink ecosystem using existing patterns.
|
|
6
|
-
*/
|
|
7
|
-
import type { LanguageModel, Schema } from "ai";
|
|
8
1
|
import type { ZodType } from "zod";
|
|
9
2
|
import type { AIProviderName } from "../constants/enums.js";
|
|
10
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
11
4
|
import type { NeuroLink } from "../neurolink.js";
|
|
12
5
|
import type { StreamOptions, StreamResult } from "../types/index.js";
|
|
6
|
+
import type { LanguageModel, Schema } from "../types/index.js";
|
|
13
7
|
/**
|
|
14
8
|
* Amazon SageMaker Provider extending BaseProvider
|
|
15
9
|
*/
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Amazon SageMaker Provider Implementation (Simplified)
|
|
3
|
-
*
|
|
4
|
-
* This module provides a simplified SageMaker provider that extends BaseProvider
|
|
5
|
-
* and integrates with the NeuroLink ecosystem using existing patterns.
|
|
6
|
-
*/
|
|
7
1
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
8
2
|
import { logger } from "../utils/logger.js";
|
|
9
3
|
import { withSpan } from "../telemetry/withSpan.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type LanguageModel } from "ai";
|
|
2
1
|
import { type AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { AnthropicProviderConfig, StreamOptions, StreamResult, ValidationSchema, EnhancedGenerateResult, TextGenerationOptions, AnthropicAuthMethod, AnthropicResponseMetadata, ClaudeSubscriptionTier, ClaudeUsageInfo } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Beta headers for Claude Code integration.
|
|
7
7
|
* These enable experimental features:
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
2
2
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
3
|
-
import { stepCountIs, streamText } from "ai";
|
|
4
3
|
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync, } from "fs";
|
|
5
4
|
import { homedir } from "os";
|
|
6
5
|
import { join } from "path";
|
|
@@ -19,6 +18,8 @@ import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../
|
|
|
19
18
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
20
19
|
import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
|
|
21
20
|
import { getModelId } from "./providerTypeUtils.js";
|
|
21
|
+
import { stepCountIs } from "../utils/tool.js";
|
|
22
|
+
import { streamText } from "../utils/generation.js";
|
|
22
23
|
/**
|
|
23
24
|
* Beta headers for Claude Code integration.
|
|
24
25
|
* These enable experimental features:
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type LanguageModel, type Schema } from "ai";
|
|
2
1
|
import type { ZodType } from "zod";
|
|
3
2
|
import { type AIProviderName } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import type { StreamOptions, StreamResult } from "../types/index.js";
|
|
5
|
+
import type { LanguageModel, Schema } from "../types/index.js";
|
|
6
6
|
/**
|
|
7
7
|
* Anthropic provider implementation using BaseProvider pattern
|
|
8
8
|
* Migrated from direct API calls to Vercel AI SDK (@ai-sdk/anthropic)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
2
2
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
3
|
-
import { NoOutputGeneratedError, streamText, } from "ai";
|
|
4
3
|
import { AnthropicModels } from "../constants/enums.js";
|
|
5
4
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
6
5
|
import { AuthenticationError, NetworkError, ProviderError, RateLimitError, } from "../types/index.js";
|
|
@@ -11,6 +10,8 @@ import { createAnthropicBaseConfig, validateApiKey, } from "../utils/providerCon
|
|
|
11
10
|
import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../utils/timeout.js";
|
|
12
11
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
13
12
|
import { getModelId } from "./providerTypeUtils.js";
|
|
13
|
+
import { NoOutputGeneratedError } from "../utils/generationErrors.js";
|
|
14
|
+
import { streamText } from "../utils/generation.js";
|
|
14
15
|
const streamTracer = trace.getTracer("neurolink.provider.anthropic");
|
|
15
16
|
/**
|
|
16
17
|
* Anthropic provider implementation using BaseProvider pattern
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type LanguageModel } from "ai";
|
|
2
1
|
import { type AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { StreamOptions, StreamResult, NeurolinkCredentials } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
export declare class AzureOpenAIProvider extends BaseProvider {
|
|
6
6
|
private apiKey;
|
|
7
7
|
private resourceName;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createAzure } from "@ai-sdk/azure";
|
|
2
|
-
import { stepCountIs, streamText } from "ai";
|
|
3
2
|
import { APIVersions } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
@@ -10,6 +9,8 @@ import { logger } from "../utils/logger.js";
|
|
|
10
9
|
import { createAzureAPIKeyConfig, createAzureEndpointConfig, validateApiKey, } from "../utils/providerConfig.js";
|
|
11
10
|
import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../utils/timeout.js";
|
|
12
11
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
12
|
+
import { stepCountIs } from "../utils/tool.js";
|
|
13
|
+
import { streamText } from "../utils/generation.js";
|
|
13
14
|
export class AzureOpenAIProvider extends BaseProvider {
|
|
14
15
|
apiKey;
|
|
15
16
|
resourceName;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Cloudflare Workers AI Provider
|
|
7
7
|
*
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
|
-
import { stepCountIs, streamText } from "ai";
|
|
3
2
|
import { CloudflareModels } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
@@ -14,6 +13,8 @@ import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../
|
|
|
14
13
|
import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
|
|
15
14
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
16
15
|
import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
|
|
16
|
+
import { stepCountIs } from "../utils/tool.js";
|
|
17
|
+
import { streamText } from "../utils/generation.js";
|
|
17
18
|
/**
|
|
18
19
|
* Cloudflare Workers AI exposes an OpenAI-compatible endpoint scoped per
|
|
19
20
|
* account: `https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/v1`.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Cohere Provider
|
|
7
7
|
*
|
package/dist/providers/cohere.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
|
-
import { stepCountIs, streamText } from "ai";
|
|
3
2
|
import { CohereModels } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
@@ -14,6 +13,8 @@ import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../
|
|
|
14
13
|
import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
|
|
15
14
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
16
15
|
import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
|
|
16
|
+
import { stepCountIs } from "../utils/tool.js";
|
|
17
|
+
import { streamText } from "../utils/generation.js";
|
|
17
18
|
/**
|
|
18
19
|
* Cohere uses an OpenAI-compatible endpoint at /compatibility/v1 that
|
|
19
20
|
* accepts the same chat-completions shape. Embeddings + Rerank live on
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* DeepSeek Provider
|
|
7
7
|
* OpenAI-compatible chat completions; supports deepseek-chat (V3) and
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|
2
|
-
import { stepCountIs, streamText } from "ai";
|
|
3
2
|
import { DeepSeekModels } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
@@ -14,6 +13,8 @@ import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../
|
|
|
14
13
|
import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
|
|
15
14
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
16
15
|
import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
|
|
16
|
+
import { stepCountIs } from "../utils/tool.js";
|
|
17
|
+
import { streamText } from "../utils/generation.js";
|
|
17
18
|
const makeLoggingFetch = (provider) => {
|
|
18
19
|
const base = createProxyFetch();
|
|
19
20
|
return (async (input, init) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Fireworks AI Provider
|
|
7
7
|
*
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
|
-
import { stepCountIs, streamText } from "ai";
|
|
3
2
|
import { FireworksModels } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
@@ -14,6 +13,8 @@ import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../
|
|
|
14
13
|
import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
|
|
15
14
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
16
15
|
import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
|
|
16
|
+
import { stepCountIs } from "../utils/tool.js";
|
|
17
|
+
import { streamText } from "../utils/generation.js";
|
|
17
18
|
const FIREWORKS_DEFAULT_BASE_URL = "https://api.fireworks.ai/inference/v1";
|
|
18
19
|
const getFireworksApiKey = () => validateApiKey(createFireworksConfig());
|
|
19
20
|
const getDefaultFireworksModel = () => getProviderModel("FIREWORKS_MODEL", FireworksModels.DEEPSEEK_V4_PRO);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type LanguageModel, type Schema } from "ai";
|
|
2
1
|
import { type AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { ZodUnknownSchema, EnhancedGenerateResult, TextGenerationOptions, StreamOptions, StreamResult } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel, Schema } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Google AI Studio provider implementation using BaseProvider
|
|
7
7
|
* Migrated from original GoogleAIStudio class to new factory pattern
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* This module extracts the functions that are duplicated between the two
|
|
9
9
|
* providers so they can share a single implementation.
|
|
10
10
|
*/
|
|
11
|
-
import { type Tool } from "ai";
|
|
12
11
|
import type { ThinkingConfig, ChatMessage, CollectedChunkResult, MinimalChatMessage, NativeFunctionCall, NativeFunctionResponse, NativeToolDeclarationsResult, NativeToolsConfig, TextChannel, VertexNativePart, GeminiMultimodalInput } from "../types/index.js";
|
|
12
|
+
import type { Tool } from "../types/index.js";
|
|
13
13
|
export declare function sanitizeForGoogleFunctionName(name: string): string;
|
|
14
14
|
/**
|
|
15
15
|
* Resolve a sanitized Gemini tool name to one that is both unique within
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
import { randomUUID } from "node:crypto";
|
|
12
12
|
import { existsSync, readFileSync } from "node:fs";
|
|
13
13
|
import { extname } from "node:path";
|
|
14
|
-
import { jsonSchema as aiJsonSchema, tool as createAISDKTool, } from "ai";
|
|
15
14
|
import { DEFAULT_MAX_STEPS, DEFAULT_TOOL_MAX_RETRIES, } from "../core/constants.js";
|
|
16
15
|
import { logger } from "../utils/logger.js";
|
|
17
16
|
import { convertZodToJsonSchema, ensureNestedSchemaTypes, inlineJsonSchema, isZodSchema, normalizeJsonSchemaObject, } from "../utils/schemaConversion.js";
|
|
18
17
|
import { createNativeThinkingConfig } from "../utils/thinkingConfig.js";
|
|
18
|
+
import { jsonSchema as aiJsonSchema, tool as createAISDKTool, } from "../utils/tool.js";
|
|
19
19
|
// ── Functions ──
|
|
20
20
|
/**
|
|
21
21
|
* Google's `function_declarations[].name` validator regex.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ZodType } from "zod";
|
|
2
|
-
import { type Schema, type LanguageModel } from "ai";
|
|
3
2
|
import { AIProviderName } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import type { EnhancedGenerateResult, TextGenerationOptions, StreamOptions, StreamResult } from "../types/index.js";
|
|
5
|
+
import type { Schema, LanguageModel } from "../types/index.js";
|
|
6
6
|
/**
|
|
7
7
|
* Resolve the effective Vertex region for a given model.
|
|
8
8
|
*
|
package/dist/providers/groq.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Groq Provider
|
|
7
7
|
*
|
package/dist/providers/groq.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
|
-
import { stepCountIs, streamText } from "ai";
|
|
3
2
|
import { GroqModels } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
@@ -14,6 +13,8 @@ import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../
|
|
|
14
13
|
import { emitToolEndFromStepFinish } from "../utils/toolEndEmitter.js";
|
|
15
14
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
16
15
|
import { toAnalyticsStreamResult } from "./providerTypeUtils.js";
|
|
16
|
+
import { stepCountIs } from "../utils/tool.js";
|
|
17
|
+
import { streamText } from "../utils/generation.js";
|
|
17
18
|
const GROQ_DEFAULT_BASE_URL = "https://api.groq.com/openai/v1";
|
|
18
19
|
const getGroqApiKey = () => validateApiKey(createGroqConfig());
|
|
19
20
|
const getDefaultGroqModel = () => getProviderModel("GROQ_MODEL", GroqModels.LLAMA_3_3_70B_VERSATILE);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type LanguageModel, type Schema } from "ai";
|
|
2
1
|
import type { ZodType } from "zod";
|
|
3
2
|
import type { AIProviderName } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import type { NeurolinkCredentials, StreamOptions, StreamResult } from "../types/index.js";
|
|
5
|
+
import type { LanguageModel, Schema } from "../types/index.js";
|
|
6
6
|
/**
|
|
7
7
|
* HuggingFace Provider - BaseProvider Implementation
|
|
8
8
|
* Using AI SDK with HuggingFace's OpenAI-compatible endpoint
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2
|
-
import { NoOutputGeneratedError, stepCountIs, streamText, } from "ai";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import { DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
5
4
|
import { createProxyFetch } from "../proxy/proxyFetch.js";
|
|
@@ -10,6 +9,9 @@ import { buildNoOutputSentinel, detectPostStreamNoOutput, stampNoOutputSpan, } f
|
|
|
10
9
|
import { createHuggingFaceConfig, getProviderModel, validateApiKey, } from "../utils/providerConfig.js";
|
|
11
10
|
import { composeAbortSignals, createTimeoutController, TimeoutError, } from "../utils/timeout.js";
|
|
12
11
|
import { resolveToolChoice } from "../utils/toolChoice.js";
|
|
12
|
+
import { NoOutputGeneratedError } from "../utils/generationErrors.js";
|
|
13
|
+
import { stepCountIs } from "../utils/tool.js";
|
|
14
|
+
import { streamText } from "../utils/generation.js";
|
|
13
15
|
// Configuration helpers - now using consolidated utility
|
|
14
16
|
const getHuggingFaceApiKey = () => {
|
|
15
17
|
return validateApiKey(createHuggingFaceConfig());
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { EnhancedGenerateResult, NeurolinkCredentials, StreamOptions, StreamResult, TextGenerationOptions, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Ideogram Provider — direct image generation with strong typography.
|
|
7
7
|
*
|
package/dist/providers/jina.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { LanguageModel } from "ai";
|
|
2
1
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
4
3
|
import type { NeurolinkCredentials, StreamOptions, StreamResult, ValidationSchema } from "../types/index.js";
|
|
4
|
+
import type { LanguageModel } from "../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Jina AI Provider — embeddings + reranking.
|
|
7
7
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type LanguageModel, type Schema } from "ai";
|
|
2
1
|
import type { ZodType } from "zod";
|
|
3
2
|
import type { AIProviderName } from "../constants/enums.js";
|
|
4
3
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
4
|
import type { StreamOptions, StreamResult } from "../types/index.js";
|
|
5
|
+
import type { LanguageModel, Schema } from "../types/index.js";
|
|
6
6
|
/**
|
|
7
7
|
* LiteLLM Provider - BaseProvider Implementation
|
|
8
8
|
* Provides access to 100+ models via LiteLLM proxy server
|