@juspay/neurolink 7.36.0 → 7.37.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/config/taskClassificationConfig.d.ts +51 -0
  3. package/dist/config/taskClassificationConfig.js +148 -0
  4. package/dist/lib/config/taskClassificationConfig.d.ts +51 -0
  5. package/dist/lib/config/taskClassificationConfig.js +148 -0
  6. package/dist/lib/neurolink.d.ts +20 -0
  7. package/dist/lib/neurolink.js +268 -5
  8. package/dist/lib/types/index.d.ts +2 -0
  9. package/dist/lib/types/index.js +2 -0
  10. package/dist/lib/types/taskClassificationTypes.d.ts +52 -0
  11. package/dist/lib/types/taskClassificationTypes.js +5 -0
  12. package/dist/lib/utils/modelRouter.d.ts +107 -0
  13. package/dist/lib/utils/modelRouter.js +292 -0
  14. package/dist/lib/utils/promptRedaction.d.ts +29 -0
  15. package/dist/lib/utils/promptRedaction.js +62 -0
  16. package/dist/lib/utils/taskClassificationUtils.d.ts +55 -0
  17. package/dist/lib/utils/taskClassificationUtils.js +149 -0
  18. package/dist/lib/utils/taskClassifier.d.ts +23 -0
  19. package/dist/lib/utils/taskClassifier.js +94 -0
  20. package/dist/neurolink.d.ts +20 -0
  21. package/dist/neurolink.js +268 -5
  22. package/dist/types/index.d.ts +2 -0
  23. package/dist/types/index.js +2 -0
  24. package/dist/types/taskClassificationTypes.d.ts +52 -0
  25. package/dist/types/taskClassificationTypes.js +5 -0
  26. package/dist/utils/modelRouter.d.ts +107 -0
  27. package/dist/utils/modelRouter.js +292 -0
  28. package/dist/utils/promptRedaction.d.ts +29 -0
  29. package/dist/utils/promptRedaction.js +62 -0
  30. package/dist/utils/taskClassificationUtils.d.ts +55 -0
  31. package/dist/utils/taskClassificationUtils.js +149 -0
  32. package/dist/utils/taskClassifier.d.ts +23 -0
  33. package/dist/utils/taskClassifier.js +94 -0
  34. package/package.json +1 -1
@@ -35,6 +35,9 @@ import { getConversationMessages, storeConversationTurn, } from "./utils/convers
35
35
  import { ExternalServerManager } from "./mcp/externalServerManager.js";
36
36
  // Import direct tools server for automatic registration
37
37
  import { directToolsServer } from "./mcp/servers/agent/directToolsServer.js";
38
+ // Import orchestration components
39
+ import { ModelRouter } from "./utils/modelRouter.js";
40
+ import { BinaryTaskClassifier } from "./utils/taskClassifier.js";
38
41
  import { isNonNullObject } from "./utils/typeUtils.js";
39
42
  // Core types imported from "./types/index.js"
40
43
  export class NeuroLink {
@@ -75,6 +78,8 @@ export class NeuroLink {
75
78
  conversationMemory;
76
79
  conversationMemoryNeedsInit = false;
77
80
  conversationMemoryConfig;
81
+ // Add orchestration property
82
+ enableOrchestration;
78
83
  /**
79
84
  * Creates a new NeuroLink instance for AI text generation with MCP tool integration.
80
85
  *
@@ -83,6 +88,7 @@ export class NeuroLink {
83
88
  * @param config.conversationMemory.enabled - Whether to enable conversation memory (default: false)
84
89
  * @param config.conversationMemory.maxSessions - Maximum number of concurrent sessions (default: 100)
85
90
  * @param config.conversationMemory.maxTurnsPerSession - Maximum conversation turns per session (default: 50)
91
+ * @param config.enableOrchestration - Whether to enable smart model orchestration (default: false)
86
92
  *
87
93
  * @example
88
94
  * ```typescript
@@ -97,6 +103,11 @@ export class NeuroLink {
97
103
  * maxTurnsPerSession: 20
98
104
  * }
99
105
  * });
106
+ *
107
+ * // With orchestration enabled
108
+ * const neurolink = new NeuroLink({
109
+ * enableOrchestration: true
110
+ * });
100
111
  * ```
101
112
  *
102
113
  * @throws {Error} When provider registry setup fails
@@ -112,6 +123,8 @@ export class NeuroLink {
112
123
  const constructorStartTime = Date.now();
113
124
  const constructorHrTimeStart = process.hrtime.bigint();
114
125
  const constructorId = `neurolink-constructor-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
126
+ // Initialize orchestration setting
127
+ this.enableOrchestration = config?.enableOrchestration ?? false;
115
128
  this.logConstructorStart(constructorId, constructorStartTime, constructorHrTimeStart, config);
116
129
  this.initializeProviderRegistry(constructorId, constructorStartTime, constructorHrTimeStart);
117
130
  this.initializeConversationMemory(config, constructorId, constructorStartTime, constructorHrTimeStart);
@@ -758,6 +771,206 @@ export class NeuroLink {
758
771
  mcpLogger.debug("💡 Memory cleanup suggestion: MCP initialization used significant memory. Consider calling MemoryManager.forceGC() after heavy operations.");
759
772
  }
760
773
  }
774
+ /**
775
+ * Apply orchestration to determine optimal provider and model
776
+ * @param options - Original GenerateOptions
777
+ * @returns Modified options with orchestrated provider marked in context, or empty object if validation fails
778
+ */
779
+ async applyOrchestration(options) {
780
+ const startTime = Date.now();
781
+ try {
782
+ // Ensure input.text exists before proceeding
783
+ if (!options.input?.text || typeof options.input.text !== "string") {
784
+ logger.debug("Orchestration skipped - no valid input text", {
785
+ hasInput: !!options.input,
786
+ hasText: !!options.input?.text,
787
+ textType: typeof options.input?.text,
788
+ });
789
+ return {}; // Return empty object to preserve existing fallback behavior
790
+ }
791
+ // Compute classification once to avoid duplicate calls
792
+ const classification = BinaryTaskClassifier.classify(options.input.text);
793
+ // Use the model router to get the optimal route
794
+ const route = ModelRouter.route(options.input.text);
795
+ // Validate that the routed provider is available and configured
796
+ const isProviderAvailable = await this.hasProviderEnvVars(route.provider);
797
+ if (!isProviderAvailable && route.provider !== "ollama") {
798
+ logger.debug("Orchestration provider validation failed", {
799
+ taskType: classification.type,
800
+ routedProvider: route.provider,
801
+ routedModel: route.model,
802
+ reason: "Provider not configured or missing environment variables",
803
+ orchestrationTime: `${Date.now() - startTime}ms`,
804
+ });
805
+ return {}; // Return empty object to preserve existing fallback behavior
806
+ }
807
+ // For Ollama, check if service is running and model is available
808
+ if (route.provider === "ollama") {
809
+ try {
810
+ const response = await fetch("http://localhost:11434/api/tags", {
811
+ method: "GET",
812
+ signal: AbortSignal.timeout(2000),
813
+ });
814
+ if (!response.ok) {
815
+ logger.debug("Orchestration provider validation failed", {
816
+ taskType: classification.type,
817
+ routedProvider: route.provider,
818
+ routedModel: route.model,
819
+ reason: "Ollama service not responding",
820
+ orchestrationTime: `${Date.now() - startTime}ms`,
821
+ });
822
+ return {}; // Return empty object to preserve existing fallback behavior
823
+ }
824
+ const { models } = await response.json();
825
+ const modelIsAvailable = models.some((m) => m.name === (route.model || "llama3.2:latest"));
826
+ if (!modelIsAvailable) {
827
+ logger.debug("Orchestration provider validation failed", {
828
+ taskType: classification.type,
829
+ routedProvider: route.provider,
830
+ routedModel: route.model,
831
+ reason: `Ollama model '${route.model || "llama3.2:latest"}' not found`,
832
+ orchestrationTime: `${Date.now() - startTime}ms`,
833
+ });
834
+ return {}; // Return empty object to preserve existing fallback behavior
835
+ }
836
+ }
837
+ catch (error) {
838
+ logger.debug("Orchestration provider validation failed", {
839
+ taskType: classification.type,
840
+ routedProvider: route.provider,
841
+ routedModel: route.model,
842
+ reason: error instanceof Error ? error.message : "Ollama service check failed",
843
+ orchestrationTime: `${Date.now() - startTime}ms`,
844
+ });
845
+ return {}; // Return empty object to preserve existing fallback behavior
846
+ }
847
+ }
848
+ logger.debug("Orchestration route determined", {
849
+ taskType: classification.type,
850
+ selectedProvider: route.provider,
851
+ selectedModel: route.model,
852
+ confidence: route.confidence,
853
+ reasoning: route.reasoning,
854
+ orchestrationTime: `${Date.now() - startTime}ms`,
855
+ });
856
+ // Mark preferred provider in context instead of directly setting provider
857
+ // This preserves global fallback behavior while indicating orchestration preference
858
+ return {
859
+ model: route.model,
860
+ context: {
861
+ ...(options.context || {}),
862
+ __orchestratedPreferredProvider: route.provider,
863
+ },
864
+ };
865
+ }
866
+ catch (error) {
867
+ logger.error("Orchestration failed", {
868
+ error: error instanceof Error ? error.message : String(error),
869
+ orchestrationTime: `${Date.now() - startTime}ms`,
870
+ });
871
+ throw error;
872
+ }
873
+ }
874
+ /**
875
+ * Apply orchestration to determine optimal provider and model for streaming
876
+ * @param options - Original StreamOptions
877
+ * @returns Modified options with orchestrated provider marked in context, or empty object if validation fails
878
+ */
879
+ async applyStreamOrchestration(options) {
880
+ const startTime = Date.now();
881
+ try {
882
+ // Ensure input.text exists before proceeding
883
+ if (!options.input?.text || typeof options.input.text !== "string") {
884
+ logger.debug("Stream orchestration skipped - no valid input text", {
885
+ hasInput: !!options.input,
886
+ hasText: !!options.input?.text,
887
+ textType: typeof options.input?.text,
888
+ });
889
+ return {}; // Return empty object to preserve existing fallback behavior
890
+ }
891
+ // Compute classification once to avoid duplicate calls
892
+ const classification = BinaryTaskClassifier.classify(options.input.text);
893
+ // Use the model router to get the optimal route
894
+ const route = ModelRouter.route(options.input.text);
895
+ // Validate that the routed provider is available and configured
896
+ const isProviderAvailable = await this.hasProviderEnvVars(route.provider);
897
+ if (!isProviderAvailable && route.provider !== "ollama") {
898
+ logger.debug("Stream orchestration provider validation failed", {
899
+ taskType: classification.type,
900
+ routedProvider: route.provider,
901
+ routedModel: route.model,
902
+ reason: "Provider not configured or missing environment variables",
903
+ orchestrationTime: `${Date.now() - startTime}ms`,
904
+ });
905
+ return {}; // Return empty object to preserve existing fallback behavior
906
+ }
907
+ // For Ollama, check if service is running and model is available
908
+ if (route.provider === "ollama") {
909
+ try {
910
+ const response = await fetch("http://localhost:11434/api/tags", {
911
+ method: "GET",
912
+ signal: AbortSignal.timeout(2000),
913
+ });
914
+ if (!response.ok) {
915
+ logger.debug("Stream orchestration provider validation failed", {
916
+ taskType: classification.type,
917
+ routedProvider: route.provider,
918
+ routedModel: route.model,
919
+ reason: "Ollama service not responding",
920
+ orchestrationTime: `${Date.now() - startTime}ms`,
921
+ });
922
+ return {}; // Return empty object to preserve existing fallback behavior
923
+ }
924
+ const { models } = await response.json();
925
+ const modelIsAvailable = models.some((m) => m.name === (route.model || "llama3.2:latest"));
926
+ if (!modelIsAvailable) {
927
+ logger.debug("Stream orchestration provider validation failed", {
928
+ taskType: classification.type,
929
+ routedProvider: route.provider,
930
+ routedModel: route.model,
931
+ reason: `Ollama model '${route.model || "llama3.2:latest"}' not found`,
932
+ orchestrationTime: `${Date.now() - startTime}ms`,
933
+ });
934
+ return {}; // Return empty object to preserve existing fallback behavior
935
+ }
936
+ }
937
+ catch (error) {
938
+ logger.debug("Stream orchestration provider validation failed", {
939
+ taskType: classification.type,
940
+ routedProvider: route.provider,
941
+ routedModel: route.model,
942
+ reason: error instanceof Error ? error.message : "Ollama service check failed",
943
+ orchestrationTime: `${Date.now() - startTime}ms`,
944
+ });
945
+ return {}; // Return empty object to preserve existing fallback behavior
946
+ }
947
+ }
948
+ logger.debug("Stream orchestration route determined", {
949
+ taskType: classification.type,
950
+ selectedProvider: route.provider,
951
+ selectedModel: route.model,
952
+ confidence: route.confidence,
953
+ reasoning: route.reasoning,
954
+ orchestrationTime: `${Date.now() - startTime}ms`,
955
+ });
956
+ // Mark preferred provider in context instead of directly setting provider
957
+ // This preserves global fallback behavior while indicating orchestration preference
958
+ return {
959
+ model: route.model,
960
+ context: {
961
+ ...(options.context || {}),
962
+ __orchestratedPreferredProvider: route.provider,
963
+ },
964
+ };
965
+ }
966
+ catch (error) {
967
+ logger.error("Stream orchestration failed", {
968
+ error: error instanceof Error ? error.message : String(error),
969
+ orchestrationTime: `${Date.now() - startTime}ms`,
970
+ });
971
+ throw error;
972
+ }
973
+ }
761
974
  /**
762
975
  * MAIN ENTRY POINT: Enhanced generate method with new function signature
763
976
  * Replaces both generateText and legacy methods
@@ -833,6 +1046,27 @@ export class NeuroLink {
833
1046
  throw new Error("Input text is required and must be a non-empty string");
834
1047
  }
835
1048
  const startTime = Date.now();
1049
+ // Apply orchestration if enabled and no specific provider/model requested
1050
+ if (this.enableOrchestration && !options.provider && !options.model) {
1051
+ try {
1052
+ const orchestratedOptions = await this.applyOrchestration(options);
1053
+ logger.debug("Orchestration applied", {
1054
+ originalProvider: options.provider || "auto",
1055
+ orchestratedProvider: orchestratedOptions.provider,
1056
+ orchestratedModel: orchestratedOptions.model,
1057
+ prompt: options.input.text.substring(0, 100),
1058
+ });
1059
+ // Use orchestrated options
1060
+ Object.assign(options, orchestratedOptions);
1061
+ }
1062
+ catch (error) {
1063
+ logger.warn("Orchestration failed, continuing with original options", {
1064
+ error: error instanceof Error ? error.message : String(error),
1065
+ originalProvider: options.provider || "auto",
1066
+ });
1067
+ // Continue with original options if orchestration fails
1068
+ }
1069
+ }
836
1070
  // Emit generation start event (NeuroLink format - keep existing)
837
1071
  this.emitter.emit("generation:start", {
838
1072
  provider: options.provider || "auto",
@@ -1429,14 +1663,21 @@ export class NeuroLink {
1429
1663
  "ollama",
1430
1664
  ];
1431
1665
  const requestedProvider = options.provider === "auto" ? undefined : options.provider;
1432
- // If specific provider requested, only use that provider (no fallback)
1433
- const tryProviders = requestedProvider
1434
- ? [requestedProvider]
1435
- : providerPriority;
1666
+ // Check for orchestrated preferred provider in context
1667
+ const preferredOrchestrated = options.context && typeof options.context === 'object' && '__orchestratedPreferredProvider' in options.context
1668
+ ? options.context.__orchestratedPreferredProvider
1669
+ : undefined;
1670
+ // Build provider list with orchestrated preference first, then fallback to full list
1671
+ const tryProviders = preferredOrchestrated
1672
+ ? [preferredOrchestrated, ...providerPriority.filter((p) => p !== preferredOrchestrated)]
1673
+ : requestedProvider
1674
+ ? [requestedProvider]
1675
+ : providerPriority;
1436
1676
  logger.debug(`[${functionTag}] Starting direct generation`, {
1437
1677
  requestedProvider: requestedProvider || "auto",
1678
+ preferredOrchestrated: preferredOrchestrated || "none",
1438
1679
  tryProviders,
1439
- allowFallback: !requestedProvider,
1680
+ allowFallback: !requestedProvider || !!preferredOrchestrated,
1440
1681
  });
1441
1682
  let lastError = null;
1442
1683
  // Try each provider in order
@@ -1651,6 +1892,28 @@ export class NeuroLink {
1651
1892
  await this.initializeConversationMemoryForGeneration(streamId, startTime, hrTimeStart);
1652
1893
  // Initialize MCP
1653
1894
  await this.initializeMCP();
1895
+ const _originalPrompt = options.input.text;
1896
+ // Apply orchestration if enabled and no specific provider/model requested
1897
+ if (this.enableOrchestration && !options.provider && !options.model) {
1898
+ try {
1899
+ const orchestratedOptions = await this.applyStreamOrchestration(options);
1900
+ logger.debug("Stream orchestration applied", {
1901
+ originalProvider: options.provider || "auto",
1902
+ orchestratedProvider: orchestratedOptions.provider,
1903
+ orchestratedModel: orchestratedOptions.model,
1904
+ prompt: options.input.text?.substring(0, 100),
1905
+ });
1906
+ // Use orchestrated options
1907
+ Object.assign(options, orchestratedOptions);
1908
+ }
1909
+ catch (error) {
1910
+ logger.warn("Stream orchestration failed, continuing with original options", {
1911
+ error: error instanceof Error ? error.message : String(error),
1912
+ originalProvider: options.provider || "auto",
1913
+ });
1914
+ // Continue with original options if orchestration fails
1915
+ }
1916
+ }
1654
1917
  factoryResult = processStreamingFactoryOptions(options);
1655
1918
  enhancedOptions = createCleanStreamOptions(options);
1656
1919
  if (options.input?.text) {
@@ -5,10 +5,12 @@ export * from "./common.js";
5
5
  export * from "./tools.js";
6
6
  export * from "./providers.js";
7
7
  export * from "./cli.js";
8
+ export * from "./taskClassificationTypes.js";
8
9
  export type { Unknown, UnknownRecord, UnknownArray, JsonValue, JsonObject, JsonArray, ErrorInfo, Result, FunctionParameters, } from "./common.js";
9
10
  export type { ToolArgs, ToolContext, ToolResult, ToolDefinition, SimpleTool, AvailableTool, ToolExecution, } from "./tools.js";
10
11
  export type { AISDKModel, ProviderError, ProviderConfig } from "./providers.js";
11
12
  export type { BaseCommandArgs, GenerateCommandArgs, MCPCommandArgs, ModelsCommandArgs, CommandResult, GenerateResult, StreamChunk, } from "./cli.js";
13
+ export type { TaskType, TaskClassification, ClassificationScores, ClassificationStats, ClassificationValidation, } from "./taskClassificationTypes.js";
12
14
  export type { MCPTransportType, MCPServerConnectionStatus, MCPServerCategory, MCPServerStatus, MCPDiscoveredServer, MCPConnectedServer, MCPToolInfo, MCPExecutableTool, MCPServerMetadata, MCPToolMetadata, MCPServerRegistryEntry, } from "./mcpTypes.js";
13
15
  export type { ExternalMCPServerInstance, ExternalMCPServerStatus, ExternalMCPToolInfo, ExternalMCPServerHealth, ExternalMCPConfigValidation, ExternalMCPOperationResult, ExternalMCPToolContext, ExternalMCPToolResult, ExternalMCPServerEvents, ExternalMCPManagerConfig, } from "./externalMcp.js";
14
16
  export type { ModelCapability, ModelUseCase, ModelFilter, ModelResolutionContext, ModelStats, ModelPricing, } from "./providers.js";
@@ -9,6 +9,8 @@ export * from "./tools.js";
9
9
  export * from "./providers.js";
10
10
  // CLI types
11
11
  export * from "./cli.js";
12
+ // Task classification types
13
+ export * from "./taskClassificationTypes.js";
12
14
  // Generate types - NEW
13
15
  export * from "./generateTypes.js";
14
16
  // Analytics types - NEW
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Task Classification Types
3
+ * Type definitions for the task classification system
4
+ */
5
+ /**
6
+ * Supported task types for classification
7
+ */
8
+ export type TaskType = "fast" | "reasoning";
9
+ /**
10
+ * Result of task classification analysis
11
+ */
12
+ export interface TaskClassification {
13
+ /** The classified task type */
14
+ type: TaskType;
15
+ /** Confidence score (0-1) in the classification */
16
+ confidence: number;
17
+ /** Human-readable explanation of the classification decision */
18
+ reasoning: string;
19
+ }
20
+ /**
21
+ * Internal scoring data used during classification analysis
22
+ */
23
+ export interface ClassificationScores {
24
+ /** Score indicating likelihood of fast task */
25
+ fastScore: number;
26
+ /** Score indicating likelihood of reasoning task */
27
+ reasoningScore: number;
28
+ /** Array of reasons contributing to the scores */
29
+ reasons: string[];
30
+ }
31
+ /**
32
+ * Statistics for batch classification analysis
33
+ */
34
+ export interface ClassificationStats {
35
+ /** Total number of prompts analyzed */
36
+ total: number;
37
+ /** Number of prompts classified as fast */
38
+ fast: number;
39
+ /** Number of prompts classified as reasoning */
40
+ reasoning: number;
41
+ /** Average confidence across all classifications */
42
+ averageConfidence: number;
43
+ }
44
+ /**
45
+ * Validation result for testing classification accuracy
46
+ */
47
+ export interface ClassificationValidation {
48
+ /** Whether the classification matched the expected result */
49
+ correct: boolean;
50
+ /** The actual classification result */
51
+ classification: TaskClassification;
52
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Task Classification Types
3
+ * Type definitions for the task classification system
4
+ */
5
+ export {};
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Model Router for NeuroLink Orchestration
3
+ * Routes tasks to optimal models based on classification and requirements
4
+ */
5
+ import type { TaskType } from "../types/taskClassificationTypes.js";
6
+ export interface ModelRoute {
7
+ provider: string;
8
+ model: string;
9
+ reasoning: string;
10
+ confidence: number;
11
+ }
12
+ export interface ModelRoutingOptions {
13
+ /** Override the task classification */
14
+ forceTaskType?: TaskType;
15
+ /** Require specific performance characteristics */
16
+ requireFast?: boolean;
17
+ /** Require specific capability (reasoning, creativity, etc.) */
18
+ requireCapability?: string;
19
+ /** Fallback strategy if primary choice fails */
20
+ fallbackStrategy?: "fast" | "reasoning" | "auto";
21
+ }
22
+ /**
23
+ * Model configurations for different task types and providers
24
+ */
25
+ declare const MODEL_CONFIGS: {
26
+ readonly fast: {
27
+ readonly primary: {
28
+ readonly provider: "vertex";
29
+ readonly model: "gemini-2.5-flash";
30
+ readonly capabilities: readonly ["speed", "general", "code", "basic-reasoning"];
31
+ readonly avgResponseTime: 800;
32
+ readonly costPerToken: 0.0001;
33
+ readonly reasoning: "Optimized for speed and efficiency via Vertex AI";
34
+ };
35
+ readonly fallback: {
36
+ readonly provider: "vertex";
37
+ readonly model: "gemini-2.5-pro";
38
+ readonly capabilities: readonly ["speed", "general", "basic-reasoning"];
39
+ readonly avgResponseTime: 1200;
40
+ readonly costPerToken: 0.0002;
41
+ readonly reasoning: "Vertex AI Gemini Pro fallback";
42
+ };
43
+ };
44
+ readonly reasoning: {
45
+ readonly primary: {
46
+ readonly provider: "vertex";
47
+ readonly model: "claude-sonnet-4@20250514";
48
+ readonly capabilities: readonly ["reasoning", "analysis", "complex-logic", "code", "creativity"];
49
+ readonly avgResponseTime: 3000;
50
+ readonly costPerToken: 0.003;
51
+ readonly reasoning: "Advanced reasoning and analysis via Claude Sonnet 4 on Vertex AI";
52
+ };
53
+ readonly fallback: {
54
+ readonly provider: "vertex";
55
+ readonly model: "claude-opus-4@20250514";
56
+ readonly capabilities: readonly ["reasoning", "analysis", "complex-logic", "code", "creativity", "agentic"];
57
+ readonly avgResponseTime: 4000;
58
+ readonly costPerToken: 0.005;
59
+ readonly reasoning: "Claude Opus 4 fallback on Vertex AI for most complex tasks";
60
+ };
61
+ };
62
+ };
63
+ /**
64
+ * Model Router
65
+ * Intelligently routes tasks to optimal models based on classification
66
+ */
67
+ export declare class ModelRouter {
68
+ /**
69
+ * Route a prompt to the optimal model configuration
70
+ */
71
+ static route(prompt: string, options?: ModelRoutingOptions): ModelRoute;
72
+ /**
73
+ * Get fallback route if primary route fails
74
+ */
75
+ static getFallbackRoute(prompt: string, primaryRoute: ModelRoute, options?: ModelRoutingOptions): ModelRoute;
76
+ /**
77
+ * Determine task type from a model route
78
+ */
79
+ private static getTaskTypeFromRoute;
80
+ /**
81
+ * Get all available model configurations
82
+ */
83
+ static getAvailableModels(): typeof MODEL_CONFIGS;
84
+ /**
85
+ * Validate model availability for a given route
86
+ */
87
+ static validateRoute(route: ModelRoute): Promise<boolean>;
88
+ /**
89
+ * Get routing statistics for multiple prompts
90
+ */
91
+ static getRoutingStats(prompts: string[]): {
92
+ total: number;
93
+ fastRoutes: number;
94
+ reasoningRoutes: number;
95
+ averageConfidence: number;
96
+ providerDistribution: Record<string, number>;
97
+ };
98
+ /**
99
+ * Estimate cost and performance for a route
100
+ */
101
+ static getRouteEstimates(route: ModelRoute, estimatedTokens?: number): {
102
+ estimatedCost: number;
103
+ estimatedResponseTime: number;
104
+ capabilities: string[];
105
+ };
106
+ }
107
+ export {};