@juspay/neurolink 7.53.4 → 7.54.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 (48) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cli/commands/config.d.ts +18 -18
  3. package/dist/index.d.ts +1 -1
  4. package/dist/lib/agent/directTools.d.ts +3 -3
  5. package/dist/lib/index.d.ts +1 -1
  6. package/dist/lib/neurolink.js +2 -74
  7. package/dist/lib/providers/sagemaker/language-model.d.ts +2 -2
  8. package/dist/lib/types/common.d.ts +6 -5
  9. package/dist/lib/types/modelTypes.d.ts +31 -14
  10. package/dist/lib/types/tools.d.ts +16 -1
  11. package/dist/lib/types/utilities.d.ts +131 -0
  12. package/dist/lib/types/utilities.js +1 -1
  13. package/dist/lib/utils/errorHandling.d.ts +2 -28
  14. package/dist/lib/utils/errorHandling.js +1 -20
  15. package/dist/lib/utils/logger.d.ts +23 -23
  16. package/dist/lib/utils/logger.js +35 -0
  17. package/dist/lib/utils/modelRouter.d.ts +1 -17
  18. package/dist/lib/utils/optionsConversion.d.ts +0 -5
  19. package/dist/lib/utils/optionsUtils.d.ts +1 -70
  20. package/dist/lib/utils/parameterValidation.d.ts +9 -22
  21. package/dist/lib/utils/performance.d.ts +1 -13
  22. package/dist/lib/utils/promptRedaction.d.ts +1 -8
  23. package/dist/lib/utils/providerUtils.d.ts +2 -10
  24. package/dist/lib/utils/redis.d.ts +1 -1
  25. package/dist/lib/utils/redis.js +0 -1
  26. package/dist/lib/utils/retryHandler.d.ts +1 -8
  27. package/dist/neurolink.js +2 -74
  28. package/dist/providers/sagemaker/language-model.d.ts +2 -2
  29. package/dist/types/common.d.ts +6 -5
  30. package/dist/types/modelTypes.d.ts +17 -0
  31. package/dist/types/tools.d.ts +16 -1
  32. package/dist/types/utilities.d.ts +131 -0
  33. package/dist/types/utilities.js +1 -1
  34. package/dist/utils/errorHandling.d.ts +2 -28
  35. package/dist/utils/errorHandling.js +1 -20
  36. package/dist/utils/logger.d.ts +23 -23
  37. package/dist/utils/logger.js +35 -0
  38. package/dist/utils/modelRouter.d.ts +1 -17
  39. package/dist/utils/optionsConversion.d.ts +0 -5
  40. package/dist/utils/optionsUtils.d.ts +1 -70
  41. package/dist/utils/parameterValidation.d.ts +9 -22
  42. package/dist/utils/performance.d.ts +1 -13
  43. package/dist/utils/promptRedaction.d.ts +1 -8
  44. package/dist/utils/providerUtils.d.ts +2 -10
  45. package/dist/utils/redis.d.ts +1 -1
  46. package/dist/utils/redis.js +0 -1
  47. package/dist/utils/retryHandler.d.ts +1 -8
  48. package/package.json +1 -1
@@ -131,7 +131,7 @@ export declare class SageMakerLanguageModel implements LanguageModelV1 {
131
131
  provider: string;
132
132
  specificationVersion: string;
133
133
  endpointName: string;
134
- modelType: "custom" | "huggingface" | "mistral" | "llama" | "claude" | "jumpstart" | undefined;
134
+ modelType: "huggingface" | "mistral" | "custom" | "llama" | "claude" | "jumpstart" | undefined;
135
135
  region: string;
136
136
  };
137
137
  /**
@@ -178,7 +178,7 @@ export declare class SageMakerLanguageModel implements LanguageModelV1 {
178
178
  provider: string;
179
179
  specificationVersion: string;
180
180
  endpointName: string;
181
- modelType: "custom" | "huggingface" | "mistral" | "llama" | "claude" | "jumpstart" | undefined;
181
+ modelType: "huggingface" | "mistral" | "custom" | "llama" | "claude" | "jumpstart" | undefined;
182
182
  region: string;
183
183
  };
184
184
  }
@@ -114,17 +114,18 @@ export type NeuroLinkEvents = {
114
114
  message: unknown;
115
115
  error: unknown;
116
116
  log: unknown;
117
+ "log-event": unknown;
117
118
  [key: string]: unknown;
118
119
  };
119
120
  /**
120
121
  * TypeScript utility for typed EventEmitter
121
122
  * Flexible interface to support both typed and legacy event patterns
122
123
  */
123
- export interface TypedEventEmitter<TEvents extends Record<string, unknown>> {
124
- on<K extends keyof TEvents>(event: K, listener: (...args: unknown[]) => void): this;
124
+ export type TypedEventEmitter<TEvents extends Record<string, unknown>> = {
125
+ on<K extends keyof TEvents>(event: K, listener: (...args: unknown[]) => void): TypedEventEmitter<TEvents>;
125
126
  emit<K extends keyof TEvents>(event: K, ...args: unknown[]): boolean;
126
- off<K extends keyof TEvents>(event: K, listener: (...args: unknown[]) => void): this;
127
- removeAllListeners<K extends keyof TEvents>(event?: K): this;
127
+ off<K extends keyof TEvents>(event: K, listener: (...args: unknown[]) => void): TypedEventEmitter<TEvents>;
128
+ removeAllListeners<K extends keyof TEvents>(event?: K): TypedEventEmitter<TEvents>;
128
129
  listenerCount<K extends keyof TEvents>(event: K): number;
129
130
  listeners<K extends keyof TEvents>(event: K): Array<(...args: unknown[]) => void>;
130
- }
131
+ };
@@ -5,6 +5,7 @@
5
5
  import { z } from "zod";
6
6
  import type { JsonValue } from "./common.js";
7
7
  import { AIProviderName } from "../constants/enums.js";
8
+ import type { TaskType } from "./taskClassificationTypes.js";
8
9
  /**
9
10
  * Model performance tier definition
10
11
  */
@@ -328,3 +329,19 @@ export type ModelComparison = {
328
329
  };
329
330
  };
330
331
  };
332
+ export type ModelRoute = {
333
+ provider: string;
334
+ model: string;
335
+ reasoning: string;
336
+ confidence: number;
337
+ };
338
+ export type ModelRoutingOptions = {
339
+ /** Override the task classification */
340
+ forceTaskType?: TaskType;
341
+ /** Require specific performance characteristics */
342
+ requireFast?: boolean;
343
+ /** Require specific capability (reasoning, creativity, etc.) */
344
+ requireCapability?: string;
345
+ /** Fallback strategy if primary choice fails */
346
+ fallbackStrategy?: "fast" | "reasoning" | "auto";
347
+ };
@@ -4,7 +4,8 @@
4
4
  */
5
5
  import { z } from "zod";
6
6
  import type { ErrorInfo, JsonObject, JsonValue, Result, UnknownRecord } from "./common.js";
7
- import type { StandardRecord, ZodUnknownSchema } from "./typeAliases.js";
7
+ import type { StandardRecord, StringArray, ZodUnknownSchema } from "./typeAliases.js";
8
+ import type { ValidationError } from "../utils/parameterValidation.js";
8
9
  /**
9
10
  * Commonly used Zod schema type aliases for cleaner type declarations
10
11
  */
@@ -336,6 +337,20 @@ export type ToolCallResult = {
336
337
  result: ToolResult;
337
338
  formattedForAI: string;
338
339
  };
340
+ /**
341
+ * Result of a validation operation
342
+ * Contains validation status, errors, warnings, and suggestions for improvement
343
+ */
344
+ export type EnhancedValidationResult = {
345
+ /** Whether the validation passed without errors */
346
+ isValid: boolean;
347
+ /** Array of validation errors that must be fixed */
348
+ errors: ValidationError[];
349
+ /** Array of warning messages that should be addressed */
350
+ warnings: string[];
351
+ /** Array of suggestions to improve the validated object */
352
+ suggestions: StringArray;
353
+ };
339
354
  /**
340
355
  * Type guard for tool result
341
356
  */
@@ -1,6 +1,17 @@
1
1
  /**
2
2
  * Utility module types - extracted from utils module files
3
3
  */
4
+ import { ErrorCategory, ErrorSeverity } from "../constants/enums.js";
5
+ import type { UnifiedGenerationOptions } from "./generateTypes.js";
6
+ import type { ExecutionContext } from "./tools.js";
7
+ /**
8
+ * Represents the available logging severity levels.
9
+ * - debug: Detailed information for debugging purposes
10
+ * - info: General information about system operation
11
+ * - warn: Potential issues that don't prevent operation
12
+ * - error: Critical issues that may cause failures
13
+ */
14
+ export type LogLevel = "debug" | "info" | "warn" | "error";
4
15
  export type TimeoutConfig = {
5
16
  operation: string;
6
17
  timeout?: number | string;
@@ -40,6 +51,126 @@ export type ParsedProxyConfig = {
40
51
  };
41
52
  cleanUrl: string;
42
53
  };
54
+ /**
55
+ * Represents a single log entry in the logging system.
56
+ * Each entry contains metadata about the log event along with the actual message.
57
+ */
58
+ export type LogEntry = {
59
+ /** The severity level of the log entry */
60
+ level: LogLevel;
61
+ /** The text message to be logged */
62
+ message: string;
63
+ /** When the log entry was created */
64
+ timestamp: Date;
65
+ /** Optional additional data associated with the log entry (objects, arrays, etc.) */
66
+ data?: unknown;
67
+ };
68
+ export type StructuredError = {
69
+ code: string;
70
+ message: string;
71
+ category: ErrorCategory;
72
+ severity: ErrorSeverity;
73
+ retriable: boolean;
74
+ context?: Record<string, unknown>;
75
+ originalError?: Error;
76
+ timestamp: Date;
77
+ toolName?: string;
78
+ serverId?: string;
79
+ };
80
+ /**
81
+ * Enhancement types for different optimization strategies
82
+ */
83
+ export type EnhancementType = "streaming-optimization" | "mcp-integration" | "legacy-migration" | "context-conversion" | "domain-configuration" | "batch-parallel-enhancement" | "batch-hybrid-enhancement" | "batch-dependency-enhancement";
84
+ /**
85
+ * Enhancement options for modifying GenerateOptions
86
+ */
87
+ export type EnhancementOptions = {
88
+ enhancementType: EnhancementType;
89
+ streamingOptions?: {
90
+ enabled?: boolean;
91
+ chunkSize?: number;
92
+ bufferSize?: number;
93
+ enableProgress?: boolean;
94
+ preferStreaming?: boolean;
95
+ };
96
+ mcpOptions?: {
97
+ enableToolRegistry?: boolean;
98
+ contextAware?: boolean;
99
+ executionContext?: ExecutionContext;
100
+ };
101
+ legacyMigration?: {
102
+ legacyContext?: Record<string, unknown>;
103
+ domainType?: string;
104
+ preserveFields?: boolean;
105
+ };
106
+ domainConfiguration?: {
107
+ domainType: string;
108
+ keyTerms?: string[];
109
+ failurePatterns?: string[];
110
+ successPatterns?: string[];
111
+ evaluationCriteria?: Record<string, unknown>;
112
+ };
113
+ performance?: {
114
+ enableAnalytics?: boolean;
115
+ enableEvaluation?: boolean;
116
+ timeout?: number;
117
+ };
118
+ };
119
+ /**
120
+ * Enhancement result with metadata
121
+ */
122
+ export type EnhancementResult = {
123
+ options: UnifiedGenerationOptions;
124
+ metadata: {
125
+ enhancementApplied: boolean;
126
+ enhancementType: EnhancementType;
127
+ processingTime: number;
128
+ configurationUsed: Record<string, unknown>;
129
+ warnings: string[];
130
+ recommendations: string[];
131
+ };
132
+ };
133
+ /**
134
+ * Plugin-based conflict detection system
135
+ * Extensible and configurable enhancement conflict resolution
136
+ */
137
+ export type ConflictDetectionPlugin = {
138
+ /** Plugin name for identification */
139
+ name: string;
140
+ /** Plugin version for compatibility checks */
141
+ version: string;
142
+ /** Check if two enhancement types conflict */
143
+ detectConflict(enhancementA: EnhancementType, enhancementB: EnhancementType, optionsA?: EnhancementOptions, optionsB?: EnhancementOptions): boolean;
144
+ /** Get conflict severity (low, medium, high) */
145
+ getConflictSeverity?(enhancementA: EnhancementType, enhancementB: EnhancementType): "low" | "medium" | "high";
146
+ /** Suggest resolution strategies */
147
+ suggestResolution?(enhancementA: EnhancementType, enhancementB: EnhancementType): string[];
148
+ };
149
+ export type RetryOptions = {
150
+ maxAttempts?: number;
151
+ initialDelay?: number;
152
+ maxDelay?: number;
153
+ backoffMultiplier?: number;
154
+ retryCondition?: (error: unknown) => boolean;
155
+ onRetry?: (attempt: number, error: unknown) => void;
156
+ };
157
+ export type PromptRedactionOptions = {
158
+ /** Maximum length of redacted prompt */
159
+ maxLength?: number;
160
+ /** Whether to show word count */
161
+ showWordCount?: boolean;
162
+ /** Mask character to use for redaction */
163
+ maskChar?: string;
164
+ };
165
+ /**
166
+ * Validation results for environment variables
167
+ */
168
+ export type EnvVarValidationResult = {
169
+ isValid: boolean;
170
+ missingVars: string[];
171
+ invalidVars: string[];
172
+ warnings: string[];
173
+ };
43
174
  /**
44
175
  * Interface for mem0 Memory instance methods based on actual mem0ai/oss API
45
176
  */
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Utility module types - extracted from utils module files
3
3
  */
4
- export {};
4
+ import { ErrorCategory, ErrorSeverity } from "../constants/enums.js";
@@ -2,34 +2,8 @@
2
2
  * Robust Error Handling Utilities for NeuroLink
3
3
  * Provides structured error management for tool execution and system operations
4
4
  */
5
- export declare enum ErrorCategory {
6
- VALIDATION = "validation",
7
- TIMEOUT = "timeout",
8
- NETWORK = "network",
9
- RESOURCE = "resource",
10
- PERMISSION = "permission",
11
- CONFIGURATION = "configuration",
12
- EXECUTION = "execution",
13
- SYSTEM = "system"
14
- }
15
- export declare enum ErrorSeverity {
16
- LOW = "low",
17
- MEDIUM = "medium",
18
- HIGH = "high",
19
- CRITICAL = "critical"
20
- }
21
- export type StructuredError = {
22
- code: string;
23
- message: string;
24
- category: ErrorCategory;
25
- severity: ErrorSeverity;
26
- retriable: boolean;
27
- context?: Record<string, unknown>;
28
- originalError?: Error;
29
- timestamp: Date;
30
- toolName?: string;
31
- serverId?: string;
32
- };
5
+ import { ErrorCategory, ErrorSeverity } from "../constants/enums.js";
6
+ import type { StructuredError } from "../types/utilities.js";
33
7
  export declare const ERROR_CODES: {
34
8
  readonly TOOL_NOT_FOUND: "TOOL_NOT_FOUND";
35
9
  readonly TOOL_EXECUTION_FAILED: "TOOL_EXECUTION_FAILED";
@@ -2,27 +2,8 @@
2
2
  * Robust Error Handling Utilities for NeuroLink
3
3
  * Provides structured error management for tool execution and system operations
4
4
  */
5
+ import { ErrorCategory, ErrorSeverity } from "../constants/enums.js";
5
6
  import { logger } from "./logger.js";
6
- // Error categories for proper handling
7
- export var ErrorCategory;
8
- (function (ErrorCategory) {
9
- ErrorCategory["VALIDATION"] = "validation";
10
- ErrorCategory["TIMEOUT"] = "timeout";
11
- ErrorCategory["NETWORK"] = "network";
12
- ErrorCategory["RESOURCE"] = "resource";
13
- ErrorCategory["PERMISSION"] = "permission";
14
- ErrorCategory["CONFIGURATION"] = "configuration";
15
- ErrorCategory["EXECUTION"] = "execution";
16
- ErrorCategory["SYSTEM"] = "system";
17
- })(ErrorCategory || (ErrorCategory = {}));
18
- // Error severity levels
19
- export var ErrorSeverity;
20
- (function (ErrorSeverity) {
21
- ErrorSeverity["LOW"] = "low";
22
- ErrorSeverity["MEDIUM"] = "medium";
23
- ErrorSeverity["HIGH"] = "high";
24
- ErrorSeverity["CRITICAL"] = "critical";
25
- })(ErrorSeverity || (ErrorSeverity = {}));
26
7
  // Error codes for different scenarios
27
8
  export const ERROR_CODES = {
28
9
  // Tool errors
@@ -13,34 +13,28 @@
13
13
  * - Structured data support for complex objects
14
14
  * - Tabular data display
15
15
  */
16
- /**
17
- * Represents the available logging severity levels.
18
- * - debug: Detailed information for debugging purposes
19
- * - info: General information about system operation
20
- * - warn: Potential issues that don't prevent operation
21
- * - error: Critical issues that may cause failures
22
- */
23
- export type LogLevel = "debug" | "info" | "warn" | "error";
24
- /**
25
- * Represents a single log entry in the logging system.
26
- * Each entry contains metadata about the log event along with the actual message.
27
- */
28
- interface LogEntry {
29
- /** The severity level of the log entry */
30
- level: LogLevel;
31
- /** The text message to be logged */
32
- message: string;
33
- /** When the log entry was created */
34
- timestamp: Date;
35
- /** Optional additional data associated with the log entry (objects, arrays, etc.) */
36
- data?: unknown;
37
- }
16
+ import type { LogEntry, LogLevel } from "../types/utilities.js";
38
17
  declare class NeuroLinkLogger {
39
18
  private logLevel;
40
19
  private logs;
41
20
  private maxLogs;
42
21
  private isDebugMode;
22
+ private eventEmitter?;
43
23
  constructor();
24
+ /**
25
+ * Sets the event emitter that will receive log events.
26
+ * When set, all log operations will emit a "log-event" event.
27
+ *
28
+ * @param emitter - The event emitter instance
29
+ */
30
+ setEventEmitter(emitter: {
31
+ emit: (event: string, ...args: unknown[]) => boolean;
32
+ }): void;
33
+ /**
34
+ * Clears the event emitter reference.
35
+ * Should be called when a NeuroLink instance is disposed to prevent memory leaks.
36
+ */
37
+ clearEventEmitter(): void;
44
38
  /**
45
39
  * Sets the minimum log level that will be processed and output.
46
40
  * Log messages with a level lower than this will be ignored.
@@ -84,6 +78,7 @@ declare class NeuroLinkLogger {
84
78
  * 2. Storing entries in the log history
85
79
  * 3. Managing log rotation to prevent memory issues
86
80
  * 4. Outputting formatted logs to the console
81
+ * 5. Emitting log events if an event emitter is configured
87
82
  *
88
83
  * This is the central method called by all specific logging methods (debug, info, etc.)
89
84
  *
@@ -185,6 +180,7 @@ declare class NeuroLinkLogger {
185
180
  * - Unconditional logging (always, table)
186
181
  * - Log level control and configuration
187
182
  * - Log history management
183
+ * - Event emission for all log operations (when emitter is configured)
188
184
  */
189
185
  export declare const logger: {
190
186
  debug: (...args: unknown[]) => void;
@@ -196,6 +192,10 @@ export declare const logger: {
196
192
  setLogLevel: (level: LogLevel) => void;
197
193
  getLogs: (level?: LogLevel) => LogEntry[];
198
194
  clearLogs: () => void;
195
+ setEventEmitter: (emitter: {
196
+ emit: (event: string, ...args: unknown[]) => boolean;
197
+ }) => void;
198
+ clearEventEmitter: () => void;
199
199
  };
200
200
  /**
201
201
  * MCP compatibility exports - all use the same unified logger instance.
@@ -236,4 +236,4 @@ export declare const LogLevels: {
236
236
  readonly warn: "warn";
237
237
  readonly error: "error";
238
238
  };
239
- export type { LogEntry };
239
+ export {};
@@ -25,6 +25,7 @@ class NeuroLinkLogger {
25
25
  logs = [];
26
26
  maxLogs = 1000;
27
27
  isDebugMode;
28
+ eventEmitter;
28
29
  constructor() {
29
30
  // Cache debug mode check to avoid repeated array searches
30
31
  this.isDebugMode =
@@ -36,6 +37,22 @@ class NeuroLinkLogger {
36
37
  this.logLevel = envLevel;
37
38
  }
38
39
  }
40
+ /**
41
+ * Sets the event emitter that will receive log events.
42
+ * When set, all log operations will emit a "log-event" event.
43
+ *
44
+ * @param emitter - The event emitter instance
45
+ */
46
+ setEventEmitter(emitter) {
47
+ this.eventEmitter = emitter;
48
+ }
49
+ /**
50
+ * Clears the event emitter reference.
51
+ * Should be called when a NeuroLink instance is disposed to prevent memory leaks.
52
+ */
53
+ clearEventEmitter() {
54
+ this.eventEmitter = undefined;
55
+ }
39
56
  /**
40
57
  * Sets the minimum log level that will be processed and output.
41
58
  * Log messages with a level lower than this will be ignored.
@@ -106,6 +123,7 @@ class NeuroLinkLogger {
106
123
  * 2. Storing entries in the log history
107
124
  * 3. Managing log rotation to prevent memory issues
108
125
  * 4. Outputting formatted logs to the console
126
+ * 5. Emitting log events if an event emitter is configured
109
127
  *
110
128
  * This is the central method called by all specific logging methods (debug, info, etc.)
111
129
  *
@@ -123,6 +141,20 @@ class NeuroLinkLogger {
123
141
  timestamp: new Date(),
124
142
  data,
125
143
  };
144
+ // Emit log event if emitter is configured
145
+ if (this.eventEmitter) {
146
+ try {
147
+ this.eventEmitter.emit("log-event", {
148
+ level,
149
+ message,
150
+ timestamp: new Date().getTime(),
151
+ data,
152
+ });
153
+ }
154
+ catch {
155
+ // Silently ignore emitter errors to avoid disrupting logging
156
+ }
157
+ }
126
158
  // Store log entry
127
159
  this.logs.push(entry);
128
160
  // Trim old logs
@@ -277,6 +309,7 @@ function processLoggerArgs(args, logMethod) {
277
309
  * - Unconditional logging (always, table)
278
310
  * - Log level control and configuration
279
311
  * - Log history management
312
+ * - Event emission for all log operations (when emitter is configured)
280
313
  */
281
314
  export const logger = {
282
315
  debug: (...args) => {
@@ -309,6 +342,8 @@ export const logger = {
309
342
  setLogLevel: (level) => neuroLinkLogger.setLogLevel(level),
310
343
  getLogs: (level) => neuroLinkLogger.getLogs(level),
311
344
  clearLogs: () => neuroLinkLogger.clearLogs(),
345
+ setEventEmitter: (emitter) => neuroLinkLogger.setEventEmitter(emitter),
346
+ clearEventEmitter: () => neuroLinkLogger.clearEventEmitter(),
312
347
  };
313
348
  /**
314
349
  * MCP compatibility exports - all use the same unified logger instance.
@@ -2,23 +2,7 @@
2
2
  * Model Router for NeuroLink Orchestration
3
3
  * Routes tasks to optimal models based on classification and requirements
4
4
  */
5
- import type { TaskType } from "../types/taskClassificationTypes.js";
6
- export type ModelRoute = {
7
- provider: string;
8
- model: string;
9
- reasoning: string;
10
- confidence: number;
11
- };
12
- export type 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
- };
5
+ import type { ModelRoute, ModelRoutingOptions } from "../types/modelTypes.js";
22
6
  /**
23
7
  * Model configurations for different task types and providers
24
8
  */
@@ -17,11 +17,6 @@ export declare function convertGenerateToStreamOptions(generateOptions: Generate
17
17
  * Useful for fallback scenarios and unified processing
18
18
  */
19
19
  export declare function convertStreamToGenerateOptions(streamOptions: StreamOptions): GenerateOptions;
20
- /**
21
- * Create a unified options interface that works with both methods
22
- * Useful for factory utilities that need to work with either type
23
- */
24
- export type UnifiedOptions = GenerateOptions & StreamOptions;
25
20
  /**
26
21
  * Check if options object has factory configuration
27
22
  * Useful for determining if enhanced processing is needed
@@ -5,60 +5,7 @@
5
5
  */
6
6
  import type { GenerateOptions, UnifiedGenerationOptions } from "../types/generateTypes.js";
7
7
  import type { StreamOptions } from "../types/streamTypes.js";
8
- import type { ExecutionContext } from "../types/tools.js";
9
- /**
10
- * Enhancement types for different optimization strategies
11
- */
12
- export type EnhancementType = "streaming-optimization" | "mcp-integration" | "legacy-migration" | "context-conversion" | "domain-configuration" | "batch-parallel-enhancement" | "batch-hybrid-enhancement" | "batch-dependency-enhancement";
13
- /**
14
- * Enhancement options for modifying GenerateOptions
15
- */
16
- export interface EnhancementOptions {
17
- enhancementType: EnhancementType;
18
- streamingOptions?: {
19
- enabled?: boolean;
20
- chunkSize?: number;
21
- bufferSize?: number;
22
- enableProgress?: boolean;
23
- preferStreaming?: boolean;
24
- };
25
- mcpOptions?: {
26
- enableToolRegistry?: boolean;
27
- contextAware?: boolean;
28
- executionContext?: ExecutionContext;
29
- };
30
- legacyMigration?: {
31
- legacyContext?: Record<string, unknown>;
32
- domainType?: string;
33
- preserveFields?: boolean;
34
- };
35
- domainConfiguration?: {
36
- domainType: string;
37
- keyTerms?: string[];
38
- failurePatterns?: string[];
39
- successPatterns?: string[];
40
- evaluationCriteria?: Record<string, unknown>;
41
- };
42
- performance?: {
43
- enableAnalytics?: boolean;
44
- enableEvaluation?: boolean;
45
- timeout?: number;
46
- };
47
- }
48
- /**
49
- * Enhancement result with metadata
50
- */
51
- export interface EnhancementResult {
52
- options: UnifiedGenerationOptions;
53
- metadata: {
54
- enhancementApplied: boolean;
55
- enhancementType: EnhancementType;
56
- processingTime: number;
57
- configurationUsed: Record<string, unknown>;
58
- warnings: string[];
59
- recommendations: string[];
60
- };
61
- }
8
+ import type { ConflictDetectionPlugin, EnhancementOptions, EnhancementResult, EnhancementType } from "../types/utilities.js";
62
9
  /**
63
10
  * Options Enhancement Utility Class
64
11
  * Main utility for enhancing GenerateOptions with factory patterns
@@ -176,22 +123,6 @@ export declare function migrateLegacyContext(options: GenerateOptions, legacyCon
176
123
  * Automatically detects independent enhancements for parallel processing
177
124
  */
178
125
  export declare function batchEnhance(options: GenerateOptions, enhancements: EnhancementOptions[]): EnhancementResult;
179
- /**
180
- * Plugin-based conflict detection system
181
- * Extensible and configurable enhancement conflict resolution
182
- */
183
- export interface ConflictDetectionPlugin {
184
- /** Plugin name for identification */
185
- name: string;
186
- /** Plugin version for compatibility checks */
187
- version: string;
188
- /** Check if two enhancement types conflict */
189
- detectConflict(enhancementA: EnhancementType, enhancementB: EnhancementType, optionsA?: EnhancementOptions, optionsB?: EnhancementOptions): boolean;
190
- /** Get conflict severity (low, medium, high) */
191
- getConflictSeverity?(enhancementA: EnhancementType, enhancementB: EnhancementType): "low" | "medium" | "high";
192
- /** Suggest resolution strategies */
193
- suggestResolution?(enhancementA: EnhancementType, enhancementB: EnhancementType): string[];
194
- }
195
126
  /**
196
127
  * Plugin registry for managing conflict detection plugins
197
128
  */
@@ -3,6 +3,7 @@
3
3
  * Provides consistent parameter validation across all tool interfaces
4
4
  */
5
5
  import type { ValidationSchema, StringArray } from "../types/typeAliases.js";
6
+ import type { EnhancedValidationResult } from "../types/tools.js";
6
7
  /**
7
8
  * Custom error class for parameter validation failures
8
9
  * Provides detailed information about validation errors including field context and suggestions
@@ -20,20 +21,6 @@ export declare class ValidationError extends Error {
20
21
  */
21
22
  constructor(message: string, field?: string | undefined, code?: string | undefined, suggestions?: StringArray | undefined);
22
23
  }
23
- /**
24
- * Result of a validation operation
25
- * Contains validation status, errors, warnings, and suggestions for improvement
26
- */
27
- export interface ValidationResult {
28
- /** Whether the validation passed without errors */
29
- isValid: boolean;
30
- /** Array of validation errors that must be fixed */
31
- errors: ValidationError[];
32
- /** Array of warning messages that should be addressed */
33
- warnings: string[];
34
- /** Array of suggestions to improve the validated object */
35
- suggestions: StringArray;
36
- }
37
24
  /**
38
25
  * Validate that a string parameter is present and non-empty
39
26
  */
@@ -61,23 +48,23 @@ export declare function validateToolDescription(description: unknown): Validatio
61
48
  /**
62
49
  * Validate MCP tool structure comprehensively
63
50
  */
64
- export declare function validateMCPTool(tool: unknown): ValidationResult;
51
+ export declare function validateMCPTool(tool: unknown): EnhancedValidationResult;
65
52
  /**
66
53
  * Validate text generation options
67
54
  */
68
- export declare function validateTextGenerationOptions(options: unknown): ValidationResult;
55
+ export declare function validateTextGenerationOptions(options: unknown): EnhancedValidationResult;
69
56
  /**
70
57
  * Validate stream options
71
58
  */
72
- export declare function validateStreamOptions(options: unknown): ValidationResult;
59
+ export declare function validateStreamOptions(options: unknown): EnhancedValidationResult;
73
60
  /**
74
61
  * Validate generate options (unified interface)
75
62
  */
76
- export declare function validateGenerateOptions(options: unknown): ValidationResult;
63
+ export declare function validateGenerateOptions(options: unknown): EnhancedValidationResult;
77
64
  /**
78
65
  * Validate tool execution parameters
79
66
  */
80
- export declare function validateToolExecutionParams(toolName: string, params: unknown, expectedSchema?: ValidationSchema): ValidationResult;
67
+ export declare function validateToolExecutionParams(toolName: string, params: unknown, expectedSchema?: ValidationSchema): EnhancedValidationResult;
81
68
  /**
82
69
  * Validate multiple tools at once
83
70
  */
@@ -85,13 +72,13 @@ export declare function validateToolBatch(tools: Record<string, unknown>): {
85
72
  isValid: boolean;
86
73
  validTools: string[];
87
74
  invalidTools: string[];
88
- results: Record<string, ValidationResult>;
75
+ results: Record<string, EnhancedValidationResult>;
89
76
  };
90
77
  /**
91
78
  * Create a validation error summary for logging
92
79
  */
93
- export declare function createValidationSummary(result: ValidationResult): string;
80
+ export declare function createValidationSummary(result: EnhancedValidationResult): string;
94
81
  /**
95
82
  * Check if validation result has only warnings (no errors)
96
83
  */
97
- export declare function hasOnlyWarnings(result: ValidationResult): boolean;
84
+ export declare function hasOnlyWarnings(result: EnhancedValidationResult): boolean;