@ax-llm/ax 13.0.24 → 14.0.1

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/index.d.ts CHANGED
@@ -74,6 +74,83 @@ declare class AxAIRefusalError extends Error {
74
74
  constructor(refusalMessage: string, model?: string | undefined, requestId?: string | undefined);
75
75
  toString(): string;
76
76
  }
77
+ /**
78
+ * Error thrown when an AI provider doesn't support a required media type.
79
+ *
80
+ * This error is thrown during content processing when a provider cannot handle
81
+ * a specific media type and no suitable fallback mechanism is available or configured.
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * try {
86
+ * await textOnlyProvider.chat(imageRequest);
87
+ * } catch (error) {
88
+ * if (error instanceof AxMediaNotSupportedError) {
89
+ * console.log(`${error.mediaType} not supported by ${error.provider}`);
90
+ * if (error.fallbackAvailable) {
91
+ * console.log('Consider using content processing services');
92
+ * }
93
+ * }
94
+ * }
95
+ * ```
96
+ */
97
+ declare class AxMediaNotSupportedError extends Error {
98
+ readonly mediaType: string;
99
+ readonly provider: string;
100
+ readonly fallbackAvailable: boolean;
101
+ /** ISO timestamp when the error occurred */
102
+ readonly timestamp: string;
103
+ /** Unique identifier for this error instance */
104
+ readonly errorId: string;
105
+ /**
106
+ * Creates a new media not supported error.
107
+ *
108
+ * @param mediaType - The type of media that is not supported (e.g., 'Images', 'Audio')
109
+ * @param provider - The name of the AI provider that doesn't support the media type
110
+ * @param fallbackAvailable - Whether fallback processing options are available
111
+ */
112
+ constructor(mediaType: string, provider: string, fallbackAvailable?: boolean);
113
+ toString(): string;
114
+ }
115
+ /**
116
+ * Error thrown when content processing/transformation fails.
117
+ *
118
+ * This error wraps underlying failures from content processing services like
119
+ * image-to-text, audio transcription, file text extraction, or URL content fetching.
120
+ * It provides context about what type of content was being processed and at which step.
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * try {
125
+ * await axProcessContentForProvider(content, provider, {
126
+ * imageToText: imageService.analyze
127
+ * });
128
+ * } catch (error) {
129
+ * if (error instanceof AxContentProcessingError) {
130
+ * console.log(`Failed processing ${error.contentType} during ${error.processingStep}`);
131
+ * console.log('Original error:', error.originalError.message);
132
+ * }
133
+ * }
134
+ * ```
135
+ */
136
+ declare class AxContentProcessingError extends Error {
137
+ readonly originalError: Error;
138
+ readonly contentType: string;
139
+ readonly processingStep: string;
140
+ /** ISO timestamp when the error occurred */
141
+ readonly timestamp: string;
142
+ /** Unique identifier for this error instance */
143
+ readonly errorId: string;
144
+ /**
145
+ * Creates a new content processing error.
146
+ *
147
+ * @param originalError - The underlying error that caused the processing failure
148
+ * @param contentType - The type of content being processed (e.g., 'image', 'audio', 'file')
149
+ * @param processingStep - The specific processing step that failed (e.g., 'vision analysis', 'transcription')
150
+ */
151
+ constructor(originalError: Error, contentType: string, processingStep: string);
152
+ toString(): string;
153
+ }
77
154
 
78
155
  type AxAIInputModelList<TModel, TEmbedModel, TModelKey> = (AxAIModelListBase<TModelKey> & {
79
156
  isInternal?: boolean;
@@ -109,6 +186,10 @@ type AxTokenUsage = {
109
186
  completionTokens: number;
110
187
  totalTokens: number;
111
188
  thoughtsTokens?: number;
189
+ reasoningTokens?: number;
190
+ cacheCreationTokens?: number;
191
+ cacheReadTokens?: number;
192
+ serviceTier?: 'standard' | 'priority' | 'batch';
112
193
  };
113
194
  type AxModelConfig = {
114
195
  maxTokens?: number;
@@ -168,9 +249,23 @@ type AxChatResponseResult = {
168
249
  url: string;
169
250
  title?: string;
170
251
  description?: string;
252
+ license?: string;
253
+ publicationDate?: string;
254
+ snippet?: string;
255
+ confidenceScore?: number;
171
256
  };
172
257
  }[];
173
258
  finishReason?: 'stop' | 'length' | 'function_call' | 'content_filter' | 'error';
259
+ logprobs?: {
260
+ content?: {
261
+ token: string;
262
+ logprob: number;
263
+ topLogprobs?: {
264
+ token: string;
265
+ logprob: number;
266
+ }[];
267
+ }[];
268
+ };
174
269
  };
175
270
  type AxModelUsage = {
176
271
  ai: string;
@@ -210,11 +305,55 @@ type AxChatRequest<TModel = string> = {
210
305
  image: string;
211
306
  details?: 'high' | 'low' | 'auto';
212
307
  cache?: boolean;
308
+ /** Optimization preference for image processing */
309
+ optimize?: 'quality' | 'size' | 'auto';
310
+ /** Fallback text description when images aren't supported */
311
+ altText?: string;
213
312
  } | {
214
313
  type: 'audio';
215
314
  data: string;
216
- format?: 'wav';
315
+ format?: 'wav' | 'mp3' | 'ogg';
217
316
  cache?: boolean;
317
+ /** Pre-transcribed text content for fallback */
318
+ transcription?: string;
319
+ /** Duration of audio in seconds */
320
+ duration?: number;
321
+ } | {
322
+ /** File content type with inline data */
323
+ type: 'file';
324
+ /** File data as base64 */
325
+ data: string;
326
+ /** Original filename */
327
+ filename?: string;
328
+ /** MIME type of the file */
329
+ mimeType: string;
330
+ cache?: boolean;
331
+ /** Pre-extracted text content for fallback */
332
+ extractedText?: string;
333
+ } | {
334
+ /** File content type with cloud storage URI */
335
+ type: 'file';
336
+ /** File URI (e.g., gs:// URL) */
337
+ fileUri: string;
338
+ /** Original filename */
339
+ filename?: string;
340
+ /** MIME type of the file */
341
+ mimeType: string;
342
+ cache?: boolean;
343
+ /** Pre-extracted text content for fallback */
344
+ extractedText?: string;
345
+ } | {
346
+ /** URL/Link content type */
347
+ type: 'url';
348
+ /** The URL to fetch content from */
349
+ url: string;
350
+ cache?: boolean;
351
+ /** Pre-fetched content for providers without web access */
352
+ cachedContent?: string;
353
+ /** Page title for context */
354
+ title?: string;
355
+ /** Page description for context */
356
+ description?: string;
218
357
  })[];
219
358
  } | {
220
359
  role: 'assistant';
@@ -236,6 +375,30 @@ type AxChatRequest<TModel = string> = {
236
375
  functionId: string;
237
376
  cache?: boolean;
238
377
  })[];
378
+ /** Provider capability preferences and requirements */
379
+ capabilities?: {
380
+ /** Whether the request requires image support */
381
+ requiresImages?: boolean;
382
+ /** Whether the request requires audio support */
383
+ requiresAudio?: boolean;
384
+ /** Whether the request requires file support */
385
+ requiresFiles?: boolean;
386
+ /** Whether the request requires web search capabilities */
387
+ requiresWebSearch?: boolean;
388
+ /** How to handle unsupported content types */
389
+ fallbackBehavior?: 'error' | 'degrade' | 'skip';
390
+ };
391
+ /** Content processing preferences and hints */
392
+ processing?: {
393
+ /** Whether to apply image compression */
394
+ imageCompression?: boolean;
395
+ /** Whether to apply audio transcription */
396
+ audioTranscription?: boolean;
397
+ /** Whether to extract text from files */
398
+ fileTextExtraction?: boolean;
399
+ /** Whether to fetch content from URLs */
400
+ urlContentFetching?: boolean;
401
+ };
239
402
  functions?: Readonly<{
240
403
  name: string;
241
404
  description: string;
@@ -400,6 +563,60 @@ interface AxAIFeatures {
400
563
  functionCot?: boolean;
401
564
  hasThinkingBudget?: boolean;
402
565
  hasShowThoughts?: boolean;
566
+ /** Enhanced media capability specifications */
567
+ media: {
568
+ /** Image processing capabilities */
569
+ images: {
570
+ /** Whether the provider supports image inputs */
571
+ supported: boolean;
572
+ /** Supported image MIME types (e.g., ['image/jpeg', 'image/png']) */
573
+ formats: string[];
574
+ /** Maximum image size in bytes */
575
+ maxSize?: number;
576
+ /** Supported detail/quality levels for image processing */
577
+ detailLevels?: ('high' | 'low' | 'auto')[];
578
+ };
579
+ /** Audio processing capabilities */
580
+ audio: {
581
+ /** Whether the provider supports audio inputs */
582
+ supported: boolean;
583
+ /** Supported audio formats (e.g., ['wav', 'mp3']) */
584
+ formats: string[];
585
+ /** Maximum audio duration in seconds */
586
+ maxDuration?: number;
587
+ };
588
+ /** File processing capabilities */
589
+ files: {
590
+ /** Whether the provider supports file inputs */
591
+ supported: boolean;
592
+ /** Supported file MIME types (e.g., ['application/pdf', 'text/plain']) */
593
+ formats: string[];
594
+ /** Maximum file size in bytes */
595
+ maxSize?: number;
596
+ /** How files are uploaded to the provider */
597
+ uploadMethod: 'inline' | 'upload' | 'cloud' | 'none';
598
+ };
599
+ /** URL and web content capabilities */
600
+ urls: {
601
+ /** Whether the provider supports URL inputs */
602
+ supported: boolean;
603
+ /** Whether the provider can perform web searches */
604
+ webSearch: boolean;
605
+ /** Whether the provider can fetch web page content */
606
+ contextFetching: boolean;
607
+ };
608
+ };
609
+ /** Content caching capabilities */
610
+ caching: {
611
+ /** Whether the provider supports content caching */
612
+ supported: boolean;
613
+ /** Types of caching available */
614
+ types: ('ephemeral' | 'persistent')[];
615
+ };
616
+ /** Whether the provider supports thinking/reasoning modes */
617
+ thinking: boolean;
618
+ /** Whether the provider supports multi-turn conversations */
619
+ multiTurn: boolean;
403
620
  }
404
621
  interface AxBaseAIArgs<TModel, TEmbedModel, TModelKey> {
405
622
  name: string;
@@ -1097,6 +1314,307 @@ declare class AxBalancer<TServices extends readonly AxAIService<any, any, any>[]
1097
1314
  getLogger(): AxLoggerFunction;
1098
1315
  }
1099
1316
 
1317
+ /**
1318
+ * Configuration options for content processing and fallback behavior
1319
+ */
1320
+ interface ProcessingOptions {
1321
+ /** How to handle unsupported content types: 'error' throws, 'degrade' converts to text, 'skip' omits */
1322
+ fallbackBehavior?: 'error' | 'degrade' | 'skip';
1323
+ /** Service to convert images to text descriptions */
1324
+ imageToText?: (imageData: string) => Promise<string>;
1325
+ /** Service to convert audio to text transcriptions */
1326
+ audioToText?: (audioData: string, format?: string) => Promise<string>;
1327
+ /** Service to extract text from files */
1328
+ fileToText?: (fileData: string, mimeType: string) => Promise<string>;
1329
+ /** Service to fetch and extract text from URLs */
1330
+ urlToText?: (url: string) => Promise<string>;
1331
+ }
1332
+ /**
1333
+ * Represents processed content that has been converted to text format
1334
+ */
1335
+ interface ProcessedContent {
1336
+ /** Content type after processing (always 'text') */
1337
+ type: 'text';
1338
+ /** The processed text content */
1339
+ text: string;
1340
+ }
1341
+ /**
1342
+ * Indicates what types of media content are present in a request
1343
+ */
1344
+ interface MediaRequirements {
1345
+ /** Whether the content includes images */
1346
+ hasImages: boolean;
1347
+ /** Whether the content includes audio */
1348
+ hasAudio: boolean;
1349
+ /** Whether the content includes files */
1350
+ hasFiles: boolean;
1351
+ /** Whether the content includes URLs */
1352
+ hasUrls: boolean;
1353
+ }
1354
+ /**
1355
+ * Processes content for a specific AI provider, handling unsupported media types.
1356
+ *
1357
+ * This function takes mixed content (text, images, audio, files, URLs) and transforms
1358
+ * it to formats supported by the target provider. Unsupported content types are
1359
+ * handled according to the fallback behavior:
1360
+ * - 'error': Throws AxMediaNotSupportedError
1361
+ * - 'degrade': Converts to text using fallback services or alt text
1362
+ * - 'skip': Omits the unsupported content
1363
+ *
1364
+ * @param content - The content to process (string, object, or array of content items)
1365
+ * @param provider - The target AI service provider
1366
+ * @param options - Processing options including fallback behavior and conversion services
1367
+ * @returns Promise resolving to array of processed content items (all converted to text)
1368
+ * @throws AxMediaNotSupportedError when fallbackBehavior is 'error' and content is unsupported
1369
+ * @throws AxContentProcessingError when a conversion service fails
1370
+ *
1371
+ * @example
1372
+ * ```typescript
1373
+ * const processed = await axProcessContentForProvider(
1374
+ * [
1375
+ * { type: 'text', text: 'Analyze this:' },
1376
+ * { type: 'image', image: 'base64...', altText: 'Chart showing sales data' }
1377
+ * ],
1378
+ * textOnlyProvider,
1379
+ * {
1380
+ * fallbackBehavior: 'degrade',
1381
+ * imageToText: async (data) => await visionService.describe(data)
1382
+ * }
1383
+ * );
1384
+ * // Result: [{ type: 'text', text: 'Analyze this:' }, { type: 'text', text: 'Chart showing sales data' }]
1385
+ * ```
1386
+ */
1387
+ declare function axProcessContentForProvider(content: any, provider: AxAIService, options?: ProcessingOptions): Promise<ProcessedContent[]>;
1388
+ /**
1389
+ * Analyzes a chat prompt to determine what media types it contains.
1390
+ *
1391
+ * Scans through chat messages to identify the types of media content present,
1392
+ * which can be used for provider capability matching and routing decisions.
1393
+ *
1394
+ * @param chatPrompt - Array of chat messages to analyze
1395
+ * @returns Object indicating which media types are present in the chat prompt
1396
+ *
1397
+ * @example
1398
+ * ```typescript
1399
+ * const requirements = axAnalyzeChatPromptRequirements([
1400
+ * {
1401
+ * role: 'user',
1402
+ * content: [
1403
+ * { type: 'text', text: 'Analyze this:' },
1404
+ * { type: 'image', image: 'base64...' },
1405
+ * { type: 'file', filename: 'report.pdf' }
1406
+ * ]
1407
+ * }
1408
+ * ]);
1409
+ * // Result: { hasImages: true, hasAudio: false, hasFiles: true, hasUrls: false }
1410
+ * ```
1411
+ */
1412
+ declare function axAnalyzeChatPromptRequirements(chatPrompt: any[]): MediaRequirements;
1413
+
1414
+ /**
1415
+ * Represents a provider's compatibility score for a specific request
1416
+ */
1417
+ interface ProviderCapabilityScore {
1418
+ /** The AI service provider */
1419
+ provider: AxAIService;
1420
+ /** Numerical score based on capability match (higher is better) */
1421
+ score: number;
1422
+ /** List of capabilities the provider is missing for this request */
1423
+ missingCapabilities: string[];
1424
+ /** List of capabilities the provider supports for this request */
1425
+ supportedCapabilities: string[];
1426
+ }
1427
+ /**
1428
+ * Result of validating whether a provider can handle a request
1429
+ */
1430
+ interface CapabilityValidationResult {
1431
+ /** Whether the provider fully supports the request */
1432
+ isSupported: boolean;
1433
+ /** List of capabilities the provider is missing */
1434
+ missingCapabilities: string[];
1435
+ /** Non-critical issues or limitations */
1436
+ warnings: string[];
1437
+ /** Suggested alternatives for missing capabilities */
1438
+ alternatives: string[];
1439
+ }
1440
+ /**
1441
+ * Analyzes a chat request to determine what capabilities it requires from AI providers.
1442
+ *
1443
+ * This function examines the request content to identify:
1444
+ * - Media types (images, audio, files, URLs)
1445
+ * - Function calling requirements
1446
+ * - Streaming requirements
1447
+ * - Caching requirements
1448
+ * - Token usage estimation
1449
+ *
1450
+ * @param request - The chat request to analyze
1451
+ * @returns Object containing detailed capability requirements and token estimation
1452
+ *
1453
+ * @example
1454
+ * ```typescript
1455
+ * const requirements = axAnalyzeRequestRequirements({
1456
+ * chatPrompt: [{
1457
+ * role: 'user',
1458
+ * content: [
1459
+ * { type: 'text', text: 'Analyze this image:' },
1460
+ * { type: 'image', image: 'base64...', details: 'high' }
1461
+ * ]
1462
+ * }]
1463
+ * });
1464
+ *
1465
+ * console.log(requirements.hasImages); // true
1466
+ * console.log(requirements.estimatedTokens); // ~95
1467
+ * ```
1468
+ */
1469
+ declare function axAnalyzeRequestRequirements(request: AxChatRequest): MediaRequirements & {
1470
+ requiresFunctions: boolean;
1471
+ requiresStreaming: boolean;
1472
+ requiresCaching: boolean;
1473
+ contentTypes: Set<string>;
1474
+ estimatedTokens: number;
1475
+ };
1476
+ /**
1477
+ * Validates whether an AI provider can handle a request with specific requirements.
1478
+ *
1479
+ * Compares the provider's feature set against the analyzed request requirements
1480
+ * to determine compatibility, missing capabilities, and potential issues.
1481
+ *
1482
+ * @param provider - The AI service provider to validate
1483
+ * @param requirements - Requirements object from axAnalyzeRequestRequirements()
1484
+ * @returns Validation result with support status, missing capabilities, and alternatives
1485
+ *
1486
+ * @example
1487
+ * ```typescript
1488
+ * const requirements = axAnalyzeRequestRequirements(request);
1489
+ * const validation = axValidateProviderCapabilities(openaiProvider, requirements);
1490
+ *
1491
+ * if (!validation.isSupported) {
1492
+ * console.log('Missing:', validation.missingCapabilities);
1493
+ * console.log('Try:', validation.alternatives);
1494
+ * }
1495
+ * ```
1496
+ */
1497
+ declare function axValidateProviderCapabilities(provider: AxAIService, requirements: ReturnType<typeof axAnalyzeRequestRequirements>): CapabilityValidationResult;
1498
+ /**
1499
+ * Scores multiple AI providers based on how well they meet request requirements.
1500
+ *
1501
+ * Uses a weighted scoring system where providers earn points for supported capabilities:
1502
+ * - Base functionality: +10 points
1503
+ * - Media support (images/audio/files/URLs): +25 points each
1504
+ * - Core features (functions/streaming/caching): +8-15 points each
1505
+ * - Missing critical capabilities: -10 points each
1506
+ * - Bonus points for advanced features (large file support, persistent caching, etc.)
1507
+ *
1508
+ * @param providers - Array of AI service providers to score
1509
+ * @param requirements - Requirements object from axAnalyzeRequestRequirements()
1510
+ * @returns Array of scored providers sorted by score (highest first)
1511
+ *
1512
+ * @example
1513
+ * ```typescript
1514
+ * const requirements = axAnalyzeRequestRequirements(request);
1515
+ * const scores = axScoreProvidersForRequest([openai, gemini, cohere], requirements);
1516
+ *
1517
+ * console.log(`Best: ${scores[0].provider.getName()} (${scores[0].score} points)`);
1518
+ * console.log(`Supports: ${scores[0].supportedCapabilities.join(', ')}`);
1519
+ * ```
1520
+ */
1521
+ declare function axScoreProvidersForRequest(providers: AxAIService[], requirements: ReturnType<typeof axAnalyzeRequestRequirements>): ProviderCapabilityScore[];
1522
+ /**
1523
+ * Automatically selects the optimal AI provider for a given request.
1524
+ *
1525
+ * Analyzes the request requirements, scores available providers, and returns
1526
+ * the best match based on capability compatibility and scoring algorithm.
1527
+ *
1528
+ * @param request - The chat request to find a provider for
1529
+ * @param availableProviders - Array of available AI service providers
1530
+ * @param options - Selection options
1531
+ * @param options.requireExactMatch - Only return providers with full capability support
1532
+ * @param options.allowDegradation - Allow providers that require content processing fallbacks
1533
+ * @returns The optimal AI service provider
1534
+ * @throws Error if no suitable provider found or requirements not met
1535
+ *
1536
+ * @example
1537
+ * ```typescript
1538
+ * // Automatic selection with degradation allowed
1539
+ * const provider = axSelectOptimalProvider(
1540
+ * multiModalRequest,
1541
+ * [openai, gemini, cohere],
1542
+ * { allowDegradation: true }
1543
+ * );
1544
+ *
1545
+ * // Strict matching - must support all features natively
1546
+ * const provider = axSelectOptimalProvider(
1547
+ * imageRequest,
1548
+ * [openai, gemini],
1549
+ * { requireExactMatch: true }
1550
+ * );
1551
+ * ```
1552
+ */
1553
+ declare function axSelectOptimalProvider(request: AxChatRequest, availableProviders: AxAIService[], options?: {
1554
+ requireExactMatch?: boolean;
1555
+ allowDegradation?: boolean;
1556
+ }): AxAIService;
1557
+ /**
1558
+ * Generates a comprehensive compatibility report for a request across all providers.
1559
+ *
1560
+ * Provides detailed analysis including requirement breakdown, provider scoring,
1561
+ * recommendations, and human-readable compatibility summary.
1562
+ *
1563
+ * @param request - The chat request to analyze
1564
+ * @param availableProviders - Array of available AI service providers
1565
+ * @returns Comprehensive compatibility report with analysis and recommendations
1566
+ *
1567
+ * @example
1568
+ * ```typescript
1569
+ * const report = axGetCompatibilityReport(request, [openai, gemini, cohere]);
1570
+ *
1571
+ * console.log(report.summary); // "OpenAI supports 4/4 requirements (100% compatibility)"
1572
+ * console.log('Requirements:', report.requirements);
1573
+ *
1574
+ * for (const score of report.providerScores) {
1575
+ * console.log(`${score.provider.getName()}: ${score.score} points`);
1576
+ * console.log(` Missing: ${score.missingCapabilities.join(', ')}`);
1577
+ * }
1578
+ * ```
1579
+ */
1580
+ declare function axGetCompatibilityReport(request: AxChatRequest, availableProviders: AxAIService[]): {
1581
+ requirements: ReturnType<typeof axAnalyzeRequestRequirements>;
1582
+ providerScores: ProviderCapabilityScore[];
1583
+ recommendedProvider: AxAIService | null;
1584
+ summary: string;
1585
+ };
1586
+ /**
1587
+ * Filters providers that support a specific media type.
1588
+ *
1589
+ * @param providers - Array of AI service providers to filter
1590
+ * @param mediaType - The media type to check support for
1591
+ * @returns Array of providers that support the specified media type
1592
+ *
1593
+ * @example
1594
+ * ```typescript
1595
+ * const imageProviders = axGetProvidersWithMediaSupport(allProviders, 'images');
1596
+ * console.log(`${imageProviders.length} providers support images`);
1597
+ * ```
1598
+ */
1599
+ declare function axGetProvidersWithMediaSupport(providers: AxAIService[], mediaType: 'images' | 'audio' | 'files' | 'urls'): AxAIService[];
1600
+ /**
1601
+ * Analyzes format compatibility across providers for a specific media type.
1602
+ *
1603
+ * @param providers - Array of AI service providers to analyze
1604
+ * @param mediaType - The media type to check format support for
1605
+ * @returns Object mapping each supported format to the providers that support it
1606
+ *
1607
+ * @example
1608
+ * ```typescript
1609
+ * const compatibility = axGetFormatCompatibility(allProviders, 'images');
1610
+ * console.log('JPEG support:', compatibility['image/jpeg']?.map(p => p.getName()));
1611
+ * console.log('PNG support:', compatibility['image/png']?.map(p => p.getName()));
1612
+ * ```
1613
+ */
1614
+ declare function axGetFormatCompatibility(providers: AxAIService[], mediaType: 'images' | 'audio' | 'files'): {
1615
+ [format: string]: AxAIService[];
1616
+ };
1617
+
1100
1618
  /**
1101
1619
  * Cohere: Models for text generation
1102
1620
  */
@@ -1685,10 +2203,7 @@ declare class AxMockAIService<TModelKey> implements AxAIService<unknown, unknown
1685
2203
  getLastUsedModelConfig(): AxModelConfig | undefined;
1686
2204
  getName(): string;
1687
2205
  getId(): string;
1688
- getFeatures(_model?: string): {
1689
- functions: boolean;
1690
- streaming: boolean;
1691
- };
2206
+ getFeatures(_model?: string): AxAIFeatures;
1692
2207
  getModelList(): AxAIModelList<TModelKey> | undefined;
1693
2208
  getMetrics(): AxAIServiceMetrics;
1694
2209
  chat(req: Readonly<AxChatRequest<unknown>>, _options?: Readonly<AxAIServiceOptions>): Promise<AxChatResponse | ReadableStream<AxChatResponse>>;
@@ -1751,11 +2266,7 @@ declare class AxMultiServiceRouter<TServices extends readonly (AxAIService | AxA
1751
2266
  * If a model key is provided, delegate to the corresponding service's features.
1752
2267
  * Otherwise, returns a default feature set.
1753
2268
  */
1754
- getFeatures(model?: TModelKey): {
1755
- functions: boolean;
1756
- streaming: boolean;
1757
- functionCot?: boolean;
1758
- };
2269
+ getFeatures(model?: TModelKey): AxAIFeatures;
1759
2270
  /**
1760
2271
  * Returns aggregated metrics from the underlying service.
1761
2272
  * Uses the metrics from the last service that was used,
@@ -2453,6 +2964,235 @@ declare class AxAIReka<TModelKey> extends AxBaseAI<AxAIRekaModel, undefined, AxA
2453
2964
  */
2454
2965
  declare const axModelInfoReka: AxModelInfo[];
2455
2966
 
2967
+ /**
2968
+ * Services for converting unsupported content types to text or optimized formats
2969
+ */
2970
+ interface AxContentProcessingServices {
2971
+ /** Service to convert images to text descriptions */
2972
+ imageToText?: (imageData: string) => Promise<string>;
2973
+ /** Service to convert audio to text transcriptions */
2974
+ audioToText?: (audioData: string, format?: string) => Promise<string>;
2975
+ /** Service to extract text from files */
2976
+ fileToText?: (fileData: string, mimeType: string) => Promise<string>;
2977
+ /** Service to fetch and extract text from URLs */
2978
+ urlToText?: (url: string) => Promise<string>;
2979
+ /** Service to optimize images for size/quality */
2980
+ imageOptimization?: (imageData: string, options: OptimizationOptions) => Promise<string>;
2981
+ }
2982
+ /**
2983
+ * Options for image optimization processing
2984
+ */
2985
+ interface OptimizationOptions {
2986
+ /** Image quality (0-100) */
2987
+ quality?: number;
2988
+ /** Maximum file size in bytes */
2989
+ maxSize?: number;
2990
+ /** Target image format */
2991
+ format?: 'jpeg' | 'png' | 'webp';
2992
+ }
2993
+ /**
2994
+ * Configuration for multi-provider routing with fallback capabilities
2995
+ */
2996
+ interface AxMultiProviderConfig {
2997
+ /** Provider hierarchy for routing */
2998
+ providers: {
2999
+ /** Primary provider to try first */
3000
+ primary: AxAIService;
3001
+ /** Alternative providers for fallback */
3002
+ alternatives: AxAIService[];
3003
+ };
3004
+ /** Routing behavior configuration */
3005
+ routing: {
3006
+ /** Order of preferences when selecting providers */
3007
+ preferenceOrder: ('capability' | 'cost' | 'speed' | 'quality')[];
3008
+ /** Capability matching requirements */
3009
+ capability: {
3010
+ /** Only use providers with full capability support */
3011
+ requireExactMatch: boolean;
3012
+ /** Allow providers that require content processing fallbacks */
3013
+ allowDegradation: boolean;
3014
+ };
3015
+ };
3016
+ /** Content processing services for unsupported media types */
3017
+ processing: AxContentProcessingServices;
3018
+ }
3019
+ /**
3020
+ * Result of the routing process including provider selection and processing information
3021
+ */
3022
+ interface AxRoutingResult {
3023
+ /** The selected AI service provider */
3024
+ provider: AxAIService;
3025
+ /** List of content processing steps that were applied */
3026
+ processingApplied: string[];
3027
+ /** List of capability degradations that occurred */
3028
+ degradations: string[];
3029
+ /** Non-critical warnings about the routing decision */
3030
+ warnings: string[];
3031
+ }
3032
+ /**
3033
+ * Multi-provider router that automatically selects optimal AI providers and handles content processing.
3034
+ *
3035
+ * The router analyzes requests to determine capability requirements, scores available providers,
3036
+ * and automatically handles content transformation for unsupported media types. It provides
3037
+ * graceful degradation and fallback mechanisms for robust multi-modal AI applications.
3038
+ *
3039
+ * @example
3040
+ * ```typescript
3041
+ * const router = new AxProviderRouter({
3042
+ * providers: {
3043
+ * primary: openaiProvider,
3044
+ * alternatives: [geminiProvider, cohereProvider]
3045
+ * },
3046
+ * routing: {
3047
+ * preferenceOrder: ['capability', 'quality'],
3048
+ * capability: {
3049
+ * requireExactMatch: false,
3050
+ * allowDegradation: true
3051
+ * }
3052
+ * },
3053
+ * processing: {
3054
+ * imageToText: async (data) => await visionService.describe(data),
3055
+ * audioToText: async (data) => await speechService.transcribe(data)
3056
+ * }
3057
+ * });
3058
+ *
3059
+ * const result = await router.chat(multiModalRequest);
3060
+ * console.log(`Used: ${result.routing.provider.getName()}`);
3061
+ * ```
3062
+ */
3063
+ declare class AxProviderRouter {
3064
+ private providers;
3065
+ private processingServices;
3066
+ private config;
3067
+ /**
3068
+ * Creates a new provider router with the specified configuration.
3069
+ *
3070
+ * @param config - Router configuration including providers, routing preferences, and processing services
3071
+ */
3072
+ constructor(config: AxMultiProviderConfig);
3073
+ /**
3074
+ * Routes a chat request to the most appropriate provider with automatic content processing.
3075
+ *
3076
+ * This method analyzes the request, selects the optimal provider, preprocesses content
3077
+ * for compatibility, and executes the request with fallback support.
3078
+ *
3079
+ * @param request - The chat request to process
3080
+ * @param options - Extended options including fallback providers and routing preferences
3081
+ * @param options.fallbackProviders - Additional providers to try if primary selection fails
3082
+ * @param options.processingOptions - Content processing options and conversion services
3083
+ * @param options.routingOptions - Provider selection and routing behavior options
3084
+ * @param options.routingOptions.requireExactMatch - Only use providers with full capability support
3085
+ * @param options.routingOptions.allowDegradation - Allow content processing for unsupported types
3086
+ * @param options.routingOptions.maxRetries - Maximum number of fallback providers to try
3087
+ * @returns Promise resolving to the AI response and routing information
3088
+ * @throws AxMediaNotSupportedError when no suitable provider can handle the request
3089
+ *
3090
+ * @example
3091
+ * ```typescript
3092
+ * const result = await router.chat(
3093
+ * { chatPrompt: [{ role: 'user', content: [{ type: 'image', image: '...' }] }] },
3094
+ * {
3095
+ * processingOptions: { fallbackBehavior: 'degrade' },
3096
+ * routingOptions: { allowDegradation: true }
3097
+ * }
3098
+ * );
3099
+ *
3100
+ * console.log(`Provider: ${result.routing.provider.getName()}`);
3101
+ * console.log(`Processing applied: ${result.routing.processingApplied}`);
3102
+ * ```
3103
+ */
3104
+ chat(request: AxChatRequest, options?: AxAIServiceOptions & {
3105
+ fallbackProviders?: AxAIService[];
3106
+ processingOptions?: ProcessingOptions;
3107
+ routingOptions?: {
3108
+ requireExactMatch?: boolean;
3109
+ allowDegradation?: boolean;
3110
+ maxRetries?: number;
3111
+ };
3112
+ }): Promise<{
3113
+ response: AxChatResponse | ReadableStream<AxChatResponse>;
3114
+ routing: AxRoutingResult;
3115
+ }>;
3116
+ /**
3117
+ * Preprocesses request content for the target provider
3118
+ */
3119
+ private preprocessRequest;
3120
+ /**
3121
+ * Selects provider with graceful degradation
3122
+ */
3123
+ private selectProviderWithDegradation;
3124
+ /**
3125
+ * Tries fallback providers when primary provider fails
3126
+ */
3127
+ private tryFallbackProviders;
3128
+ /**
3129
+ * Gets routing recommendation without executing the request.
3130
+ *
3131
+ * Analyzes the request and returns routing information including which provider
3132
+ * would be selected, what processing would be applied, and any degradations or warnings.
3133
+ *
3134
+ * @param request - The chat request to analyze
3135
+ * @returns Promise resolving to routing result with provider selection and processing info
3136
+ *
3137
+ * @example
3138
+ * ```typescript
3139
+ * const recommendation = await router.getRoutingRecommendation(request);
3140
+ * console.log(`Would use: ${recommendation.provider.getName()}`);
3141
+ * console.log(`Degradations: ${recommendation.degradations.join(', ')}`);
3142
+ * ```
3143
+ */
3144
+ getRoutingRecommendation(request: AxChatRequest): Promise<AxRoutingResult>;
3145
+ /**
3146
+ * Validates whether the configured providers can handle a specific request.
3147
+ *
3148
+ * Performs pre-flight validation to check if the request can be successfully
3149
+ * processed by available providers, identifies potential issues, and provides
3150
+ * recommendations for improving compatibility.
3151
+ *
3152
+ * @param request - The chat request to validate
3153
+ * @returns Promise resolving to validation result with handling capability and recommendations
3154
+ *
3155
+ * @example
3156
+ * ```typescript
3157
+ * const validation = await router.validateRequest(request);
3158
+ * if (!validation.canHandle) {
3159
+ * console.log('Issues:', validation.issues);
3160
+ * console.log('Recommendations:', validation.recommendations);
3161
+ * }
3162
+ * ```
3163
+ */
3164
+ validateRequest(request: AxChatRequest): Promise<{
3165
+ canHandle: boolean;
3166
+ issues: string[];
3167
+ recommendations: string[];
3168
+ }>;
3169
+ /**
3170
+ * Gets detailed statistics about the router's provider capabilities.
3171
+ *
3172
+ * Returns information about available providers, their supported capabilities,
3173
+ * and routing recommendations for analysis and debugging purposes.
3174
+ *
3175
+ * @returns Object containing provider statistics and capability matrix
3176
+ *
3177
+ * @example
3178
+ * ```typescript
3179
+ * const stats = router.getRoutingStats();
3180
+ * console.log(`Total providers: ${stats.totalProviders}`);
3181
+ * console.log('Capabilities:');
3182
+ * for (const [capability, providers] of Object.entries(stats.capabilityMatrix)) {
3183
+ * console.log(` ${capability}: ${providers.join(', ')}`);
3184
+ * }
3185
+ * ```
3186
+ */
3187
+ getRoutingStats(): {
3188
+ totalProviders: number;
3189
+ capabilityMatrix: {
3190
+ [capability: string]: string[];
3191
+ };
3192
+ recommendedProvider: string;
3193
+ };
3194
+ }
3195
+
2456
3196
  type TogetherAIConfig = AxAIOpenAIConfig<string, unknown>;
2457
3197
  declare const axAITogetherDefaultConfig: () => TogetherAIConfig;
2458
3198
  type AxAITogetherArgs<TModelKey> = AxAIOpenAIArgs<'together', string, unknown, TModelKey>;
@@ -2718,16 +3458,45 @@ type ExtractModelKeysAndValues<T> = T extends readonly {
2718
3458
  type InferTModelKey<T> = T extends {
2719
3459
  models: infer M;
2720
3460
  } ? ExtractModelKeysAndValues<M> : string;
3461
+ /**
3462
+ * Factory function for creating AxAI instances with type safety.
3463
+ * This is the recommended way to create AxAI instances instead of using the constructor.
3464
+ *
3465
+ * @param options - Configuration options for the AI service
3466
+ * @returns A properly typed AxAI instance
3467
+ *
3468
+ * @example
3469
+ * ```typescript
3470
+ * const ai = ai({
3471
+ * name: 'openai',
3472
+ * apiKey: process.env.OPENAI_APIKEY!
3473
+ * });
3474
+ * ```
3475
+ */
3476
+ declare function ai<const T extends AxAIArgs<any>>(options: T): AxAI<InferTModelKey<T>>;
2721
3477
  declare class AxAI<TModelKey = string> implements AxAIService<any, any, TModelKey> {
2722
3478
  private ai;
2723
3479
  static create<const T extends AxAIArgs<any>>(options: T): AxAI<InferTModelKey<T>>;
3480
+ /**
3481
+ * @deprecated Use `AxAI.create()` or `ai()` function instead for better type safety.
3482
+ * This constructor will be removed in v15.0.0.
3483
+ *
3484
+ * Migration timeline:
3485
+ * - v13.0.24+: Deprecation warnings (current)
3486
+ * - v14.0.0: Runtime console warnings
3487
+ * - v15.0.0: Complete removal
3488
+ *
3489
+ * @example
3490
+ * ```typescript
3491
+ * // Instead of: new AxAI({ name: 'openai', apiKey: '...' })
3492
+ * // Use: AxAI.create({ name: 'openai', apiKey: '...' })
3493
+ * // Or: ai({ name: 'openai', apiKey: '...' })
3494
+ * ```
3495
+ */
2724
3496
  constructor(options: Readonly<AxAIArgs<TModelKey>>);
2725
3497
  getName(): string;
2726
3498
  getId(): string;
2727
- getFeatures(model?: string): {
2728
- functions: boolean;
2729
- streaming: boolean;
2730
- };
3499
+ getFeatures(model?: string): AxAIFeatures;
2731
3500
  getModelList(): AxAIModelList<TModelKey> | undefined;
2732
3501
  getLastUsedChatModel(): any;
2733
3502
  getLastUsedEmbedModel(): any;
@@ -2908,61 +3677,6 @@ interface AxAIMemory {
2908
3677
  rewindToTag(name: string, sessionId?: string): AxMemoryData;
2909
3678
  }
2910
3679
 
2911
- interface AxField {
2912
- name: string;
2913
- title?: string;
2914
- description?: string;
2915
- type?: {
2916
- name: 'string' | 'number' | 'boolean' | 'json' | 'image' | 'audio' | 'date' | 'datetime' | 'class' | 'code';
2917
- isArray?: boolean;
2918
- options?: string[];
2919
- };
2920
- isOptional?: boolean;
2921
- isInternal?: boolean;
2922
- }
2923
- type AxIField = Omit<AxField, 'title'> & {
2924
- title: string;
2925
- };
2926
- interface AxSignatureConfig {
2927
- description?: string;
2928
- inputs: readonly AxField[];
2929
- outputs: readonly AxField[];
2930
- }
2931
- declare class AxSignature {
2932
- private description?;
2933
- private inputFields;
2934
- private outputFields;
2935
- private sigHash;
2936
- private sigString;
2937
- private validatedAtHash?;
2938
- constructor(signature?: Readonly<AxSignature | string | AxSignatureConfig>);
2939
- private parseParsedField;
2940
- private parseField;
2941
- setDescription: (desc: string) => void;
2942
- addInputField: (field: Readonly<AxField>) => void;
2943
- addOutputField: (field: Readonly<AxField>) => void;
2944
- setInputFields: (fields: readonly AxField[]) => void;
2945
- setOutputFields: (fields: readonly AxField[]) => void;
2946
- getInputFields: () => Readonly<AxIField[]>;
2947
- getOutputFields: () => Readonly<AxIField[]>;
2948
- getDescription: () => string | undefined;
2949
- private invalidateValidationCache;
2950
- private toTitle;
2951
- toJSONSchema: () => AxFunctionJSONSchema;
2952
- private updateHashLight;
2953
- private updateHash;
2954
- private validateSignatureConsistency;
2955
- validate: () => boolean;
2956
- hash: () => string;
2957
- toString: () => string;
2958
- toJSON: () => {
2959
- id: string;
2960
- description: string | undefined;
2961
- inputFields: AxIField[];
2962
- outputFields: AxIField[];
2963
- };
2964
- }
2965
-
2966
3680
  declare class AxMemory implements AxAIMemory {
2967
3681
  private memories;
2968
3682
  private defaultMemory;
@@ -2993,11 +3707,36 @@ declare class AxMemory implements AxAIMemory {
2993
3707
  image: string;
2994
3708
  details?: "high" | "low" | "auto";
2995
3709
  cache?: boolean;
3710
+ optimize?: "quality" | "size" | "auto";
3711
+ altText?: string;
2996
3712
  } | {
2997
3713
  type: "audio";
2998
3714
  data: string;
2999
- format?: "wav";
3715
+ format?: "wav" | "mp3" | "ogg";
3716
+ cache?: boolean;
3717
+ transcription?: string;
3718
+ duration?: number;
3719
+ } | {
3720
+ type: "file";
3721
+ data: string;
3722
+ filename?: string;
3723
+ mimeType: string;
3724
+ cache?: boolean;
3725
+ extractedText?: string;
3726
+ } | {
3727
+ type: "file";
3728
+ fileUri: string;
3729
+ filename?: string;
3730
+ mimeType: string;
3731
+ cache?: boolean;
3732
+ extractedText?: string;
3733
+ } | {
3734
+ type: "url";
3735
+ url: string;
3000
3736
  cache?: boolean;
3737
+ cachedContent?: string;
3738
+ title?: string;
3739
+ description?: string;
3001
3740
  })[];
3002
3741
  } | {
3003
3742
  role: "assistant";
@@ -3078,7 +3817,7 @@ declare class AxPromptTemplate {
3078
3817
  private readonly functions?;
3079
3818
  constructor(sig: Readonly<AxSignature>, options?: Readonly<AxPromptTemplateOptions>, fieldTemplates?: Record<string, AxFieldTemplateFn>);
3080
3819
  private renderSingleValueUserContent;
3081
- render: <T extends AxGenIn>(values: T | ReadonlyArray<AxMessage<T>>, // Allow T (AxGenIn) or array of AxMessages
3820
+ render: <T = any>(values: T | ReadonlyArray<AxMessage<T>>, // Allow T or array of AxMessages
3082
3821
  { examples, demos, }: Readonly<{
3083
3822
  skipSystemPrompt?: boolean;
3084
3823
  examples?: Record<string, AxFieldValue>[];
@@ -3096,11 +3835,36 @@ declare class AxPromptTemplate {
3096
3835
  image: string;
3097
3836
  details?: "high" | "low" | "auto";
3098
3837
  cache?: boolean;
3838
+ optimize?: "quality" | "size" | "auto";
3839
+ altText?: string;
3099
3840
  } | {
3100
3841
  type: "audio";
3101
3842
  data: string;
3102
- format?: "wav";
3843
+ format?: "wav" | "mp3" | "ogg";
3844
+ cache?: boolean;
3845
+ transcription?: string;
3846
+ duration?: number;
3847
+ } | {
3848
+ type: "file";
3849
+ data: string;
3850
+ filename?: string;
3851
+ mimeType: string;
3852
+ cache?: boolean;
3853
+ extractedText?: string;
3854
+ } | {
3855
+ type: "file";
3856
+ fileUri: string;
3857
+ filename?: string;
3858
+ mimeType: string;
3103
3859
  cache?: boolean;
3860
+ extractedText?: string;
3861
+ } | {
3862
+ type: "url";
3863
+ url: string;
3864
+ cache?: boolean;
3865
+ cachedContent?: string;
3866
+ title?: string;
3867
+ description?: string;
3104
3868
  })[];
3105
3869
  private renderExamples;
3106
3870
  private renderDemos;
@@ -3109,6 +3873,168 @@ declare class AxPromptTemplate {
3109
3873
  private defaultRenderInField;
3110
3874
  }
3111
3875
 
3876
+ /**
3877
+ * A map of string type names to their corresponding TypeScript types.
3878
+ * Maps signature type strings to actual TypeScript types for type inference.
3879
+ */
3880
+ interface TypeMap {
3881
+ string: string;
3882
+ number: number;
3883
+ boolean: boolean;
3884
+ json: any;
3885
+ date: Date;
3886
+ datetime: Date;
3887
+ image: {
3888
+ mimeType: string;
3889
+ data: string;
3890
+ };
3891
+ audio: {
3892
+ format?: 'wav';
3893
+ data: string;
3894
+ };
3895
+ file: {
3896
+ mimeType: string;
3897
+ data: string;
3898
+ } | {
3899
+ mimeType: string;
3900
+ fileUri: string;
3901
+ };
3902
+ url: string;
3903
+ code: string;
3904
+ }
3905
+ type ParseClassOptions<S extends string> = S extends `${infer First},${infer Rest}` ? Trim<First> | ParseClassOptions<Trim<Rest>> : S extends `${infer First}|${infer Rest}` ? Trim<First> | ParseClassOptions<Trim<Rest>> : S extends `${infer First} | ${infer Rest}` ? Trim<First> | ParseClassOptions<Trim<Rest>> : S extends `${infer First}, ${infer Rest}` ? Trim<First> | ParseClassOptions<Trim<Rest>> : Trim<S>;
3906
+ type ResolveType<T extends string> = T extends keyof TypeMap ? TypeMap[T] : T extends `${infer BaseType}[]` ? BaseType extends keyof TypeMap ? TypeMap[BaseType][] : any[] : T extends `class[]|${infer Options}` ? ParseClassOptions<Options>[] : T extends `class|${infer Options}` ? ParseClassOptions<Options> : T extends 'class' ? string : any;
3907
+ type Trim<S extends string> = S extends ` ${infer T}` ? Trim<T> : S extends `\n${infer T}` ? Trim<T> : S extends `\t${infer T}` ? Trim<T> : S extends `\r${infer T}` ? Trim<T> : S extends `${infer U} ` ? Trim<U> : S extends `${infer U}\n` ? Trim<U> : S extends `${infer U}\t` ? Trim<U> : S extends `${infer U}\r` ? Trim<U> : S;
3908
+ type ParseField<S extends string> = S extends `${infer Name}?` ? {
3909
+ name: Trim<Name>;
3910
+ optional: true;
3911
+ } : {
3912
+ name: Trim<S>;
3913
+ optional: false;
3914
+ };
3915
+ type ExtractType<S extends string> = S extends `class[] "${infer Options}" "${infer _Desc}"` ? `class[]|${Options}` : S extends `class[] "${infer Options}"` ? `class[]|${Options}` : S extends `class "${infer Options}" "${infer _Desc}"` ? `class|${Options}` : S extends `class "${infer Options}"` ? `class|${Options}` : S extends `${infer Type}[] "${infer _Desc}"` ? `${Type}[]` : S extends `${infer Type}[]` ? `${Type}[]` : S extends `${infer Type} "${infer _Desc}"` ? Type : S;
3916
+ type ParseNameAndType<S extends string> = S extends `${infer Name}:${infer TypePart}` ? ParseField<Name> & {
3917
+ type: Trim<ExtractType<Trim<TypePart>>>;
3918
+ } : S extends `${infer Name} "${infer _Description}"` ? ParseField<Name> & {
3919
+ type: 'string';
3920
+ } : ParseField<S> & {
3921
+ type: 'string';
3922
+ };
3923
+ /**
3924
+ * Advanced field splitting that respects quotes using a state machine approach.
3925
+ *
3926
+ * This type-level parser solves the core problem of parsing comma-separated fields
3927
+ * when commas can appear both as field separators AND inside quoted strings.
3928
+ *
3929
+ * PROBLEM EXAMPLE:
3930
+ * Input: 'sourceType:class "class1, class2, class3", relevantContext:string, sources:string'
3931
+ *
3932
+ * Simple comma splitting would incorrectly produce:
3933
+ * ['sourceType:class "class1', ' class2', ' class3"', ' relevantContext:string', ' sources:string']
3934
+ *
3935
+ * This parser correctly produces:
3936
+ * ['sourceType:class "class1, class2, class3"', 'relevantContext:string', 'sources:string']
3937
+ *
3938
+ * ALGORITHM:
3939
+ * 1. Process each character in the input string one by one
3940
+ * 2. Track whether we're currently inside or outside quotes
3941
+ * 3. When encountering a quote ("), toggle the quote state
3942
+ * 4. When encountering a comma (,):
3943
+ * - If inside quotes: treat as literal character, add to current field
3944
+ * - If outside quotes: treat as field separator, complete current field and start new one
3945
+ * 5. For all other characters: add to current field being built
3946
+ *
3947
+ * STATE PARAMETERS:
3948
+ * @param S - The remaining string to process
3949
+ * @param Current - The current field being built character by character
3950
+ * @param InQuote - Boolean state tracking if we're inside quotes
3951
+ * @param Result - Accumulator array of completed fields
3952
+ */
3953
+ type SplitFieldsRespectingQuotes<S extends string, Current extends string = '', InQuote extends boolean = false, Result extends string[] = []> = S extends `${infer Char}${infer Rest}` ? Char extends '"' ? SplitFieldsRespectingQuotes<Rest, `${Current}${Char}`, InQuote extends true ? false : true, Result> : Char extends ',' ? InQuote extends true ? SplitFieldsRespectingQuotes<Rest, `${Current}${Char}`, InQuote, Result> : Rest extends ` ${infer RestTrimmed}` ? SplitFieldsRespectingQuotes<RestTrimmed, '', false, [
3954
+ ...Result,
3955
+ Current
3956
+ ]> : SplitFieldsRespectingQuotes<Rest, '', false, [...Result, Current]> : SplitFieldsRespectingQuotes<Rest, `${Current}${Char}`, InQuote, Result> : Current extends '' ? Result : [...Result, Current];
3957
+ /**
3958
+ * Convert string array to parsed field objects.
3959
+ *
3960
+ * Takes the array of field strings produced by SplitFieldsRespectingQuotes
3961
+ * and converts each string into a structured field object with name, type, and optional properties.
3962
+ *
3963
+ * EXAMPLE:
3964
+ * Input: ['sourceType:class "class1, class2, class3"', 'relevantContext:string', 'sources:string']
3965
+ * Output: [
3966
+ * { name: 'sourceType', type: 'class|class1, class2, class3', optional: false },
3967
+ * { name: 'relevantContext', type: 'string', optional: false },
3968
+ * { name: 'sources', type: 'string', optional: false }
3969
+ * ]
3970
+ */
3971
+ type StringArrayToFields<T extends readonly string[]> = T extends readonly [
3972
+ infer First,
3973
+ ...infer Rest
3974
+ ] ? First extends string ? Rest extends readonly string[] ? [ParseNameAndType<Trim<First>>, ...StringArrayToFields<Rest>] : [ParseNameAndType<Trim<First>>] : [] : [];
3975
+ /**
3976
+ * Main field parser using the quote-aware splitter.
3977
+ *
3978
+ * This is the entry point for parsing a field list string into typed field objects.
3979
+ * It combines the quote-aware splitting with field object conversion to produce
3980
+ * the final tuple that BuildObject can use for type inference.
3981
+ *
3982
+ * FLOW:
3983
+ * 1. SplitFieldsRespectingQuotes: 'field1, field2' -> ['field1', 'field2']
3984
+ * 2. StringArrayToFields: ['field1', 'field2'] -> [FieldObj1, FieldObj2]
3985
+ * 3. BuildObject: [FieldObj1, FieldObj2] -> { field1: Type1, field2: Type2 }
3986
+ */
3987
+ type ParseFields<S extends string> = StringArrayToFields<SplitFieldsRespectingQuotes<S>>;
3988
+ /**
3989
+ * Builds a TypeScript object type from a readonly tuple of field definitions,
3990
+ * supporting both required and optional fields.
3991
+ */
3992
+ type BuildObject<T extends readonly {
3993
+ name: string;
3994
+ type: string;
3995
+ optional: boolean;
3996
+ }[]> = {
3997
+ -readonly [K in T[number] as K['optional'] extends false ? K['name'] : never]: ResolveType<K['type']>;
3998
+ } & {
3999
+ -readonly [K in T[number] as K['optional'] extends true ? K['name'] : never]?: ResolveType<K['type']>;
4000
+ };
4001
+ type StripSignatureDescription<S extends string> = S extends `"${infer _Desc}" ${infer Rest}` ? Trim<Rest> : S;
4002
+ /**
4003
+ * The main signature parser that handles the complete parsing pipeline.
4004
+ *
4005
+ * This is the top-level type that users interact with. It takes a signature string
4006
+ * and produces TypeScript types for both inputs and outputs with proper type inference.
4007
+ *
4008
+ * SIGNATURE FORMAT:
4009
+ * "[description] inputField1:type1, inputField2:type2 -> outputField1:type1, outputField2:type2"
4010
+ *
4011
+ * EXAMPLES:
4012
+ * Simple: 'userQuery:string -> response:string'
4013
+ * Complex: 'searchQuery:string -> sourceType:class "class1, class2, class3", context:string'
4014
+ * With description: '"Analyze text" text:string -> sentiment:class "positive, negative", confidence:number'
4015
+ *
4016
+ * PROCESSING STEPS:
4017
+ * 1. StripSignatureDescription: Remove optional description at start
4018
+ * 2. Split on " -> " to separate inputs from outputs
4019
+ * 3. ParseFields: Use quote-aware parsing for both input and output field lists
4020
+ * 4. BuildObject: Convert field tuples to TypeScript object types
4021
+ *
4022
+ * RESULT TYPE:
4023
+ * {
4024
+ * inputs: { [fieldName]: FieldType },
4025
+ * outputs: { [fieldName]: FieldType }
4026
+ * }
4027
+ *
4028
+ * Where FieldType is inferred from the signature (string, number, 'option1'|'option2', etc.)
4029
+ */
4030
+ type ParseSignature<S extends string> = StripSignatureDescription<Trim<S>> extends `${infer Inputs} -> ${infer Outputs}` ? {
4031
+ inputs: BuildObject<ParseFields<Trim<Inputs>>>;
4032
+ outputs: BuildObject<ParseFields<Trim<Outputs>>>;
4033
+ } : {
4034
+ inputs: Record<string, any>;
4035
+ outputs: Record<string, any>;
4036
+ };
4037
+
3112
4038
  type AxFieldValue = string | string[] | number | boolean | object | null | undefined | {
3113
4039
  mimeType: string;
3114
4040
  data: string;
@@ -3128,23 +4054,32 @@ type AxGenIn = {
3128
4054
  type AxGenOut = {
3129
4055
  [key: string]: AxFieldValue;
3130
4056
  };
3131
- type AxMessage<IN extends AxGenIn> = {
4057
+ /**
4058
+ * @deprecated AxMessage will be updated to a new design within this major version.
4059
+ * The current structure will be replaced in v15.0.0.
4060
+ *
4061
+ * Migration timeline:
4062
+ * - v14.0.0+: Deprecation warnings (current)
4063
+ * - v14.x: New message design introduced alongside existing
4064
+ * - v15.0.0: Complete replacement with new design
4065
+ */
4066
+ type AxMessage<IN> = {
3132
4067
  role: 'user';
3133
4068
  values: IN;
3134
4069
  } | {
3135
4070
  role: 'assistant';
3136
4071
  values: IN;
3137
4072
  };
3138
- type AxProgramTrace<IN extends AxGenIn, OUT extends AxGenOut> = {
4073
+ type AxProgramTrace<IN, OUT> = {
3139
4074
  trace: OUT & IN;
3140
4075
  programId: string;
3141
4076
  };
3142
- type AxProgramDemos<IN extends AxGenIn, OUT extends AxGenOut> = {
4077
+ type AxProgramDemos<IN, OUT> = {
3143
4078
  traces: (OUT & IN)[];
3144
4079
  programId: string;
3145
4080
  };
3146
- type AxProgramExamples<IN extends AxGenIn, OUT extends AxGenOut> = AxProgramDemos<IN, OUT> | AxProgramDemos<IN, OUT>['traces'];
3147
- type AxResultPickerFunctionFieldResults<OUT extends AxGenOut> = {
4081
+ type AxProgramExamples<IN, OUT> = AxProgramDemos<IN, OUT> | AxProgramDemos<IN, OUT>['traces'];
4082
+ type AxResultPickerFunctionFieldResults<OUT> = {
3148
4083
  type: 'fields';
3149
4084
  results: readonly {
3150
4085
  index: number;
@@ -3162,7 +4097,7 @@ type AxResultPickerFunctionFunctionResults = {
3162
4097
  isError?: boolean;
3163
4098
  }[];
3164
4099
  };
3165
- type AxResultPickerFunction<OUT extends AxGenOut> = (data: AxResultPickerFunctionFieldResults<OUT> | AxResultPickerFunctionFunctionResults) => number | Promise<number>;
4100
+ type AxResultPickerFunction<OUT> = (data: AxResultPickerFunctionFieldResults<OUT> | AxResultPickerFunctionFunctionResults) => number | Promise<number>;
3166
4101
  type AxProgramForwardOptions<MODEL> = AxAIServiceOptions & {
3167
4102
  maxRetries?: number;
3168
4103
  maxSteps?: number;
@@ -3195,18 +4130,18 @@ type AxProgramStreamingForwardOptions<MODEL> = Omit<AxProgramForwardOptions<MODE
3195
4130
  type AxAIServiceModelType<T extends Readonly<AxAIService<any, any, any>>> = T extends Readonly<AxAIService<infer TModel, any, infer TModelKey>> ? TModel extends unknown ? TModelKey : TModel | TModelKey : never;
3196
4131
  type AxProgramForwardOptionsWithModels<T extends Readonly<AxAIService<any, any, any>>> = AxProgramForwardOptions<AxAIServiceModelType<T>>;
3197
4132
  type AxProgramStreamingForwardOptionsWithModels<T extends Readonly<AxAIService<any, any, any>>> = AxProgramStreamingForwardOptions<AxAIServiceModelType<T>>;
3198
- type AxGenDeltaOut<OUT extends AxGenOut> = {
4133
+ type AxGenDeltaOut<OUT> = {
3199
4134
  version: number;
3200
4135
  index: number;
3201
4136
  delta: Partial<OUT>;
3202
4137
  };
3203
- type AxGenStreamingOut<OUT extends AxGenOut> = AsyncGenerator<AxGenDeltaOut<OUT>, void, unknown>;
4138
+ type AxGenStreamingOut<OUT> = AsyncGenerator<AxGenDeltaOut<OUT>, void, unknown>;
3204
4139
  type AxSetExamplesOptions = {};
3205
- interface AxForwardable<IN extends AxGenIn, OUT extends AxGenOut, TModelKey> {
4140
+ interface AxForwardable<IN, OUT, TModelKey> {
3206
4141
  forward(ai: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramForwardOptions<TModelKey>>): Promise<OUT>;
3207
4142
  streamingForward(ai: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramStreamingForwardOptions<TModelKey>>): AxGenStreamingOut<OUT>;
3208
4143
  }
3209
- interface AxTunable<IN extends AxGenIn, OUT extends AxGenOut> {
4144
+ interface AxTunable<IN, OUT> {
3210
4145
  setExamples: (examples: Readonly<AxProgramExamples<IN, OUT>>, options?: Readonly<AxSetExamplesOptions>) => void;
3211
4146
  setId: (id: string) => void;
3212
4147
  setParentId: (parentId: string) => void;
@@ -3217,7 +4152,7 @@ interface AxUsable {
3217
4152
  getUsage: () => AxProgramUsage[];
3218
4153
  resetUsage: () => void;
3219
4154
  }
3220
- interface AxProgrammable<IN extends AxGenIn, OUT extends AxGenOut, TModelKey = string> extends AxForwardable<IN, OUT, TModelKey>, AxTunable<IN, OUT>, AxUsable {
4155
+ interface AxProgrammable<IN, OUT, TModelKey = string> extends AxForwardable<IN, OUT, TModelKey>, AxTunable<IN, OUT>, AxUsable {
3221
4156
  getSignature: () => AxSignature;
3222
4157
  }
3223
4158
  type AxProgramUsage = AxChatResponse['modelUsage'] & {
@@ -3229,6 +4164,219 @@ interface AxProgramOptions {
3229
4164
  traceLabel?: string;
3230
4165
  }
3231
4166
 
4167
+ interface AxFieldType {
4168
+ readonly type: 'string' | 'number' | 'boolean' | 'json' | 'image' | 'audio' | 'file' | 'url' | 'date' | 'datetime' | 'class' | 'code';
4169
+ readonly isArray?: boolean;
4170
+ readonly options?: readonly string[];
4171
+ readonly description?: string;
4172
+ readonly isOptional?: boolean;
4173
+ readonly isInternal?: boolean;
4174
+ }
4175
+ declare class AxSignatureBuilder<_TInput extends Record<string, any> = {}, _TOutput extends Record<string, any> = {}> {
4176
+ private inputFields;
4177
+ private outputFields;
4178
+ private desc?;
4179
+ /**
4180
+ * Add an input field to the signature
4181
+ * @param name - Field name
4182
+ * @param fieldInfo - Field type created with f.string(), f.number(), etc.
4183
+ * @param prepend - If true, adds field to the beginning of input fields
4184
+ */
4185
+ input<K extends string, T extends AxFluentFieldInfo<any, any, any, any> | AxFluentFieldType>(name: K, fieldInfo: T, prepend?: boolean): AxSignatureBuilder<_TInput & Record<K, InferFluentType<T>>, _TOutput>;
4186
+ /**
4187
+ * Add an output field to the signature
4188
+ * @param name - Field name
4189
+ * @param fieldInfo - Field type created with f.string(), f.number(), etc.
4190
+ * @param prepend - If true, adds field to the beginning of output fields
4191
+ */
4192
+ output<K extends string, T extends AxFluentFieldInfo<any, any, any, any> | AxFluentFieldType>(name: K, fieldInfo: T, prepend?: boolean): AxSignatureBuilder<_TInput, _TOutput & Record<K, InferFluentType<T>>>;
4193
+ /**
4194
+ * Set the description for the signature
4195
+ * @param description - Description text
4196
+ */
4197
+ description(description: string): AxSignatureBuilder<_TInput, _TOutput>;
4198
+ /**
4199
+ * Build the final AxSignature instance
4200
+ */
4201
+ build(): AxSignature<_TInput, _TOutput>;
4202
+ }
4203
+ declare class AxFluentFieldType implements AxFieldType {
4204
+ readonly type: AxFieldType['type'];
4205
+ readonly isArray?: boolean;
4206
+ readonly options?: readonly string[];
4207
+ readonly description?: string;
4208
+ readonly isOptional?: boolean;
4209
+ readonly isInternal?: boolean;
4210
+ constructor(fieldType: AxFieldType);
4211
+ optional(): AxFluentFieldType;
4212
+ array(): AxFluentFieldType;
4213
+ internal(): AxFluentFieldType;
4214
+ }
4215
+ declare const f: (() => AxSignatureBuilder) & {
4216
+ string: (desc?: string) => AxFluentFieldType;
4217
+ number: (desc?: string) => AxFluentFieldType;
4218
+ boolean: (desc?: string) => AxFluentFieldType;
4219
+ json: (desc?: string) => AxFluentFieldType;
4220
+ datetime: (desc?: string) => AxFluentFieldType;
4221
+ date: (desc?: string) => AxFluentFieldType;
4222
+ class: <const TOptions extends readonly string[]>(options: TOptions, desc?: string) => AxFluentFieldType;
4223
+ image: (desc?: string) => AxFluentFieldType;
4224
+ audio: (desc?: string) => AxFluentFieldType;
4225
+ file: (desc?: string) => AxFluentFieldType;
4226
+ url: (desc?: string) => AxFluentFieldType;
4227
+ code: (language?: string, desc?: string) => AxFluentFieldType;
4228
+ array: <T extends AxFluentFieldInfo<any, any, any, any>>(baseType: T) => AxFluentFieldInfo<T["type"], true, T["options"], T["isOptional"]>;
4229
+ optional: <T extends AxFluentFieldInfo<any, any, any, any>>(baseType: T) => AxFluentFieldInfo<T["type"], T["isArray"], T["options"], true>;
4230
+ internal: <T extends AxFluentFieldInfo<any, any, any, any>>(baseType: T) => T & {
4231
+ readonly isInternal: true;
4232
+ };
4233
+ legacyArray: <T extends AxFieldType>(baseType: T) => T & {
4234
+ readonly isArray: true;
4235
+ };
4236
+ legacyOptional: <T extends AxFieldType>(baseType: T) => T & {
4237
+ readonly isOptional: true;
4238
+ };
4239
+ legacyInternal: <T extends AxFieldType>(baseType: T) => T & {
4240
+ readonly isInternal: true;
4241
+ };
4242
+ };
4243
+ interface AxField {
4244
+ name: string;
4245
+ title?: string;
4246
+ description?: string;
4247
+ type?: {
4248
+ name: 'string' | 'number' | 'boolean' | 'json' | 'image' | 'audio' | 'file' | 'url' | 'date' | 'datetime' | 'class' | 'code';
4249
+ isArray?: boolean;
4250
+ options?: string[];
4251
+ };
4252
+ isOptional?: boolean;
4253
+ isInternal?: boolean;
4254
+ }
4255
+ type AxIField = Omit<AxField, 'title'> & {
4256
+ title: string;
4257
+ };
4258
+ type InferFieldValueType<T> = T extends AxFieldType | AxFluentFieldType ? T['type'] extends 'string' ? T['isArray'] extends true ? string[] : string : T['type'] extends 'number' ? T['isArray'] extends true ? number[] : number : T['type'] extends 'boolean' ? T['isArray'] extends true ? boolean[] : boolean : T['type'] extends 'json' ? T['isArray'] extends true ? any[] : any : T['type'] extends 'date' ? T['isArray'] extends true ? Date[] : Date : T['type'] extends 'datetime' ? T['isArray'] extends true ? Date[] : Date : T['type'] extends 'image' ? T['isArray'] extends true ? {
4259
+ mimeType: string;
4260
+ data: string;
4261
+ }[] : {
4262
+ mimeType: string;
4263
+ data: string;
4264
+ } : T['type'] extends 'audio' ? T['isArray'] extends true ? {
4265
+ format?: 'wav';
4266
+ data: string;
4267
+ }[] : {
4268
+ format?: 'wav';
4269
+ data: string;
4270
+ } : T['type'] extends 'file' ? T['isArray'] extends true ? ({
4271
+ mimeType: string;
4272
+ data: string;
4273
+ } | {
4274
+ mimeType: string;
4275
+ fileUri: string;
4276
+ })[] : {
4277
+ mimeType: string;
4278
+ data: string;
4279
+ } | {
4280
+ mimeType: string;
4281
+ fileUri: string;
4282
+ } : T['type'] extends 'url' ? T['isArray'] extends true ? string[] : string : T['type'] extends 'code' ? T['isArray'] extends true ? string[] : string : T['type'] extends 'class' ? T['options'] extends readonly (infer U)[] ? T['isArray'] extends true ? U[] : U : T['isArray'] extends true ? string[] : string : any : any;
4283
+ interface AxFluentFieldInfo<TType extends AxFieldType['type'] = AxFieldType['type'], TIsArray extends boolean = false, TOptions extends readonly string[] = readonly string[], TIsOptional extends boolean = false> {
4284
+ readonly type: TType;
4285
+ readonly isArray?: TIsArray;
4286
+ readonly options?: TOptions;
4287
+ readonly description?: string;
4288
+ readonly isOptional?: TIsOptional;
4289
+ readonly isInternal?: boolean;
4290
+ }
4291
+ type InferFluentType<T extends AxFluentFieldInfo<any, any, any, any> | AxFluentFieldType> = T['type'] extends 'string' ? T['isArray'] extends true ? string[] : string : T['type'] extends 'number' ? T['isArray'] extends true ? number[] : number : T['type'] extends 'boolean' ? T['isArray'] extends true ? boolean[] : boolean : T['type'] extends 'json' ? T['isArray'] extends true ? any[] : any : T['type'] extends 'date' ? T['isArray'] extends true ? Date[] : Date : T['type'] extends 'datetime' ? T['isArray'] extends true ? Date[] : Date : T['type'] extends 'image' ? T['isArray'] extends true ? {
4292
+ mimeType: string;
4293
+ data: string;
4294
+ }[] : {
4295
+ mimeType: string;
4296
+ data: string;
4297
+ } : T['type'] extends 'audio' ? T['isArray'] extends true ? {
4298
+ format?: 'wav';
4299
+ data: string;
4300
+ }[] : {
4301
+ format?: 'wav';
4302
+ data: string;
4303
+ } : T['type'] extends 'file' ? T['isArray'] extends true ? ({
4304
+ mimeType: string;
4305
+ data: string;
4306
+ } | {
4307
+ mimeType: string;
4308
+ fileUri: string;
4309
+ })[] : {
4310
+ mimeType: string;
4311
+ data: string;
4312
+ } | {
4313
+ mimeType: string;
4314
+ fileUri: string;
4315
+ } : T['type'] extends 'url' ? T['isArray'] extends true ? string[] : string : T['type'] extends 'code' ? T['isArray'] extends true ? string[] : string : T['type'] extends 'class' ? T['options'] extends readonly (infer U)[] ? T['isArray'] extends true ? U[] : U : T['isArray'] extends true ? string[] : string : any;
4316
+ interface AxSignatureConfig {
4317
+ description?: string;
4318
+ inputs: readonly AxField[];
4319
+ outputs: readonly AxField[];
4320
+ }
4321
+ declare class AxSignature<_TInput extends Record<string, any> = Record<string, any>, _TOutput extends Record<string, any> = Record<string, any>> {
4322
+ private description?;
4323
+ private inputFields;
4324
+ private outputFields;
4325
+ private sigHash;
4326
+ private sigString;
4327
+ private validatedAtHash?;
4328
+ /**
4329
+ * @deprecated Use `AxSignature.create()` for better type safety instead of the constructor.
4330
+ * This constructor will be removed in v15.0.0.
4331
+ *
4332
+ * Migration timeline:
4333
+ * - v13.0.24+: Deprecation warnings (current)
4334
+ * - v14.0.0: Runtime console warnings
4335
+ * - v15.0.0: Complete removal
4336
+ *
4337
+ * @example
4338
+ * ```typescript
4339
+ * // Instead of: new AxSignature('userInput:string -> responseText:string')
4340
+ * // Use: AxSignature.create('userInput:string -> responseText:string')
4341
+ * ```
4342
+ */
4343
+ constructor(signature?: Readonly<AxSignature | string | AxSignatureConfig>);
4344
+ /**
4345
+ * Static factory method for type inference.
4346
+ * Creates a typed AxSignature instance from a signature string.
4347
+ */
4348
+ static create<const T extends string>(signature: T): AxSignature<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>;
4349
+ private parseParsedField;
4350
+ private parseField;
4351
+ setDescription: (desc: string) => void;
4352
+ addInputField: (field: Readonly<AxField>) => void;
4353
+ addOutputField: (field: Readonly<AxField>) => void;
4354
+ setInputFields: (fields: readonly AxField[]) => void;
4355
+ setOutputFields: (fields: readonly AxField[]) => void;
4356
+ getInputFields: () => Readonly<AxIField[]>;
4357
+ getOutputFields: () => Readonly<AxIField[]>;
4358
+ getDescription: () => string | undefined;
4359
+ appendInputField: <K extends string, T extends AxFieldType>(name: K, fieldType: T) => AxSignature<_TInput & Record<K, InferFieldValueType<T>>, _TOutput>;
4360
+ prependInputField: <K extends string, T extends AxFieldType>(name: K, fieldType: T) => AxSignature<Record<K, InferFieldValueType<T>> & _TInput, _TOutput>;
4361
+ appendOutputField: <K extends string, T extends AxFieldType>(name: K, fieldType: T) => AxSignature<_TInput, _TOutput & Record<K, InferFieldValueType<T>>>;
4362
+ prependOutputField: <K extends string, T extends AxFieldType>(name: K, fieldType: T) => AxSignature<_TInput, Record<K, InferFieldValueType<T>> & _TOutput>;
4363
+ private invalidateValidationCache;
4364
+ private toTitle;
4365
+ toJSONSchema: () => AxFunctionJSONSchema;
4366
+ private updateHashLight;
4367
+ private updateHash;
4368
+ private validateSignatureConsistency;
4369
+ validate: () => boolean;
4370
+ hash: () => string;
4371
+ toString: () => string;
4372
+ toJSON: () => {
4373
+ id: string;
4374
+ description: string | undefined;
4375
+ inputFields: AxIField[];
4376
+ outputFields: AxIField[];
4377
+ };
4378
+ }
4379
+
3232
4380
  interface AxAssertion {
3233
4381
  fn(values: Record<string, unknown>): Promise<boolean | undefined> | boolean | undefined;
3234
4382
  message?: string;
@@ -3271,7 +4419,7 @@ interface AxFieldProcessor {
3271
4419
  process: AxFieldProcessorProcess | AxStreamingFieldProcessorProcess;
3272
4420
  }
3273
4421
 
3274
- declare class AxProgram<IN extends AxGenIn, OUT extends AxGenOut> implements AxUsable {
4422
+ declare class AxProgram<IN, OUT> implements AxUsable {
3275
4423
  protected signature: AxSignature;
3276
4424
  protected sigHash: string;
3277
4425
  protected examples?: OUT[];
@@ -3298,7 +4446,7 @@ declare class AxProgram<IN extends AxGenIn, OUT extends AxGenOut> implements AxU
3298
4446
  setDemos(demos: readonly AxProgramDemos<IN, OUT>[]): void;
3299
4447
  }
3300
4448
 
3301
- type AxGenerateResult<OUT extends AxGenOut> = OUT & {
4449
+ type AxGenerateResult<OUT> = OUT & {
3302
4450
  thought?: string;
3303
4451
  };
3304
4452
  interface AxResponseHandlerArgs<T> {
@@ -3322,7 +4470,7 @@ interface AxStreamingEvent<T> {
3322
4470
  functions?: AxChatResponseFunctionCall[];
3323
4471
  };
3324
4472
  }
3325
- declare class AxGen<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGenOut> extends AxProgram<IN, OUT> implements AxProgrammable<IN, OUT> {
4473
+ declare class AxGen<IN = any, OUT extends AxGenOut = any> extends AxProgram<IN, OUT> implements AxProgrammable<IN, OUT> {
3326
4474
  private promptTemplate;
3327
4475
  private asserts;
3328
4476
  private streamingAsserts;
@@ -3332,7 +4480,7 @@ declare class AxGen<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGenOu
3332
4480
  private streamingFieldProcessors;
3333
4481
  private excludeContentFromTrace;
3334
4482
  private thoughtFieldName;
3335
- constructor(signature: NonNullable<ConstructorParameters<typeof AxSignature>[0]>, options?: Readonly<AxProgramForwardOptions<any>>);
4483
+ constructor(signature: NonNullable<ConstructorParameters<typeof AxSignature>[0]> | AxSignature<any, any>, options?: Readonly<AxProgramForwardOptions<any>>);
3336
4484
  private getSignatureName;
3337
4485
  private getMetricsInstruments;
3338
4486
  updateMeter(meter?: Meter): void;
@@ -3564,12 +4712,12 @@ type AxOptimizerLoggerData = {
3564
4712
  type AxOptimizerLoggerFunction = (data: AxOptimizerLoggerData) => void;
3565
4713
 
3566
4714
  type AxExample = Record<string, AxFieldValue>;
3567
- type AxMetricFn = <T extends AxGenOut = AxGenOut>(arg0: Readonly<{
4715
+ type AxMetricFn = <T = any>(arg0: Readonly<{
3568
4716
  prediction: T;
3569
4717
  example: AxExample;
3570
4718
  }>) => number | Promise<number>;
3571
4719
  type AxMetricFnArgs = Parameters<AxMetricFn>[0];
3572
- type AxMultiMetricFn = <T extends AxGenOut = AxGenOut>(arg0: Readonly<{
4720
+ type AxMultiMetricFn = <T = any>(arg0: Readonly<{
3573
4721
  prediction: T;
3574
4722
  example: AxExample;
3575
4723
  }>) => Record<string, number>;
@@ -3625,6 +4773,28 @@ type AxOptimizerArgs = {
3625
4773
  studentAI: AxAIService;
3626
4774
  teacherAI?: AxAIService;
3627
4775
  examples: readonly AxExample[];
4776
+ optimizerEndpoint?: string;
4777
+ optimizerTimeout?: number;
4778
+ optimizerRetries?: number;
4779
+ numCandidates?: number;
4780
+ initTemperature?: number;
4781
+ maxBootstrappedDemos?: number;
4782
+ maxLabeledDemos?: number;
4783
+ numTrials?: number;
4784
+ minibatch?: boolean;
4785
+ minibatchSize?: number;
4786
+ minibatchFullEvalSteps?: number;
4787
+ programAwareProposer?: boolean;
4788
+ dataAwareProposer?: boolean;
4789
+ viewDataBatchSize?: number;
4790
+ tipAwareProposer?: boolean;
4791
+ fewshotAwareProposer?: boolean;
4792
+ earlyStoppingTrials?: number;
4793
+ minImprovementThreshold?: number;
4794
+ bayesianOptimization?: boolean;
4795
+ acquisitionFunction?: 'expected_improvement' | 'upper_confidence_bound' | 'probability_improvement';
4796
+ explorationWeight?: number;
4797
+ sampleCount?: number;
3628
4798
  validationSet?: readonly AxExample[];
3629
4799
  minSuccessRate?: number;
3630
4800
  targetScore?: number;
@@ -3717,17 +4887,17 @@ interface AxOptimizerMetricsInstruments {
3717
4887
  }
3718
4888
  declare const axUpdateOptimizerMetricsConfig: (config: Readonly<Partial<AxOptimizerMetricsConfig>>) => void;
3719
4889
  declare const axGetOptimizerMetricsConfig: () => AxOptimizerMetricsConfig;
3720
- interface AxOptimizerResult<OUT extends AxGenOut> {
3721
- demos?: AxProgramDemos<AxGenIn, OUT>[];
4890
+ interface AxOptimizerResult<OUT> {
4891
+ demos?: AxProgramDemos<any, OUT>[];
3722
4892
  stats: AxOptimizationStats;
3723
4893
  bestScore: number;
3724
4894
  finalConfiguration?: Record<string, unknown>;
3725
4895
  scoreHistory?: number[];
3726
4896
  configurationHistory?: Record<string, unknown>[];
3727
4897
  }
3728
- interface AxParetoResult<OUT extends AxGenOut = AxGenOut> extends AxOptimizerResult<OUT> {
4898
+ interface AxParetoResult<OUT = any> extends AxOptimizerResult<OUT> {
3729
4899
  paretoFront: ReadonlyArray<{
3730
- demos: readonly AxProgramDemos<AxGenIn, OUT>[];
4900
+ demos: readonly AxProgramDemos<any, OUT>[];
3731
4901
  scores: Readonly<Record<string, number>>;
3732
4902
  configuration: Readonly<Record<string, unknown>>;
3733
4903
  dominatedSolutions: number;
@@ -3751,7 +4921,7 @@ interface AxCompileOptions {
3751
4921
  overrideCheckpointInterval?: number;
3752
4922
  saveCheckpointOnComplete?: boolean;
3753
4923
  }
3754
- interface AxOptimizer<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGenOut> {
4924
+ interface AxOptimizer<IN = any, OUT extends AxGenOut = any> {
3755
4925
  /**
3756
4926
  * Optimize a program using the provided metric function
3757
4927
  * @param program The program to optimize (moved from constructor)
@@ -3852,11 +5022,11 @@ interface AxMiPROOptimizerOptions {
3852
5022
  interface AxBootstrapCompileOptions extends AxCompileOptions {
3853
5023
  validationExamples?: readonly AxExample[];
3854
5024
  maxDemos?: number;
3855
- teacherProgram?: Readonly<AxGen<AxGenIn, AxGenOut>>;
5025
+ teacherProgram?: Readonly<AxGen<any, any>>;
3856
5026
  }
3857
5027
  interface AxMiPROCompileOptions extends AxCompileOptions {
3858
5028
  validationExamples?: readonly AxExample[];
3859
- teacher?: Readonly<AxGen<AxGenIn, AxGenOut>>;
5029
+ teacher?: Readonly<AxGen<any, any>>;
3860
5030
  auto?: 'light' | 'medium' | 'heavy';
3861
5031
  instructionCandidates?: string[];
3862
5032
  customProposer?: (context: Readonly<{
@@ -3883,7 +5053,7 @@ declare class AxDefaultCostTracker implements AxCostTracker {
3883
5053
  * Abstract base class for optimizers that provides common functionality
3884
5054
  * and standardized handling of AxOptimizerArgs
3885
5055
  */
3886
- declare abstract class AxBaseOptimizer<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGenOut> implements AxOptimizer<IN, OUT> {
5056
+ declare abstract class AxBaseOptimizer<IN = any, OUT extends AxGenOut = any> implements AxOptimizer<IN, OUT> {
3887
5057
  protected readonly studentAI: AxAIService;
3888
5058
  protected readonly teacherAI?: AxAIService;
3889
5059
  protected readonly examples: readonly AxExample[];
@@ -4206,7 +5376,7 @@ declare const axCreateDefaultOptimizerTextLogger: (output?: (message: string) =>
4206
5376
  */
4207
5377
  declare const axDefaultOptimizerLogger: AxOptimizerLoggerFunction;
4208
5378
 
4209
- declare class AxBootstrapFewShot<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGenOut> extends AxBaseOptimizer<IN, OUT> {
5379
+ declare class AxBootstrapFewShot<IN = any, OUT extends AxGenOut = any> extends AxBaseOptimizer<IN, OUT> {
4210
5380
  private maxRounds;
4211
5381
  private maxDemos;
4212
5382
  private maxExamples;
@@ -4249,9 +5419,8 @@ declare class AxMiPRO<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGen
4249
5419
  private sampleCount;
4250
5420
  private miproConfigHistory;
4251
5421
  private surrogateModel;
4252
- constructor(args: Readonly<AxOptimizerArgs & {
4253
- options?: AxMiPROOptimizerOptions;
4254
- }>);
5422
+ private pythonClient?;
5423
+ constructor(args: Readonly<AxOptimizerArgs>);
4255
5424
  /**
4256
5425
  * Configures the optimizer for light, medium, or heavy optimization
4257
5426
  * @param level The optimization level: "light", "medium", or "heavy"
@@ -4357,17 +5526,29 @@ declare class AxMiPRO<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGen
4357
5526
  * Selects the next configuration to evaluate using Bayesian optimization
4358
5527
  */
4359
5528
  private selectConfigurationViaBayesianOptimization;
5529
+ /**
5530
+ * Python-based compilation method
5531
+ *
5532
+ * This is a simplified implementation that demonstrates integration
5533
+ * with the Python optimizer service. For now, it focuses on basic
5534
+ * parameter optimization rather than full MiPRO functionality.
5535
+ */
5536
+ private compilePython;
5537
+ /**
5538
+ * Simplified evaluation method for Python optimization
5539
+ */
5540
+ private evaluateConfiguration;
4360
5541
  }
4361
5542
 
4362
- type AxInstanceRegistryItem<T extends AxTunable<IN, OUT>, IN extends AxGenIn, OUT extends AxGenOut> = T & AxUsable;
4363
- declare class AxInstanceRegistry<T extends AxTunable<IN, OUT>, IN extends AxGenIn, OUT extends AxGenOut> {
5543
+ type AxInstanceRegistryItem<T extends AxTunable<IN, OUT>, IN, OUT> = T & AxUsable;
5544
+ declare class AxInstanceRegistry<T extends AxTunable<IN, OUT>, IN, OUT> {
4364
5545
  private reg;
4365
5546
  constructor();
4366
5547
  register(instance: AxInstanceRegistryItem<T, IN, OUT>): void;
4367
5548
  [Symbol.iterator](): Generator<AxInstanceRegistryItem<T, IN, OUT>, void, unknown>;
4368
5549
  }
4369
5550
 
4370
- interface AxSamplePickerOptions<OUT extends AxGenOut> {
5551
+ interface AxSamplePickerOptions<OUT> {
4371
5552
  resultPicker?: AxResultPickerFunction<OUT>;
4372
5553
  }
4373
5554
 
@@ -4383,45 +5564,8 @@ declare const AxStringUtil: {
4383
5564
  batchArray: <T>(arr: readonly T[], size: number) => T[][];
4384
5565
  };
4385
5566
 
4386
- type AxSignatureTemplateValue = string | AxFieldType | AxFieldDescriptor | AxSignature;
4387
- interface AxFieldType {
4388
- readonly type: 'string' | 'number' | 'boolean' | 'json' | 'image' | 'audio' | 'date' | 'datetime' | 'class' | 'code';
4389
- readonly isArray?: boolean;
4390
- readonly options?: readonly string[];
4391
- readonly description?: string;
4392
- readonly isOptional?: boolean;
4393
- readonly isInternal?: boolean;
4394
- }
4395
- interface AxFieldDescriptor {
4396
- readonly name: string;
4397
- readonly type?: AxFieldType;
4398
- readonly description?: string;
4399
- readonly isOptional?: boolean;
4400
- readonly isInternal?: boolean;
4401
- }
4402
- declare function s(strings: TemplateStringsArray, ...values: readonly AxSignatureTemplateValue[]): AxSignature;
4403
- declare function ax<IN extends AxGenIn = AxGenIn, OUT extends AxGenerateResult<AxGenOut> = AxGenerateResult<AxGenOut>>(strings: TemplateStringsArray, ...values: readonly AxSignatureTemplateValue[]): AxGen<IN, OUT>;
4404
- declare const f: {
4405
- string: (desc?: string) => AxFieldType;
4406
- number: (desc?: string) => AxFieldType;
4407
- boolean: (desc?: string) => AxFieldType;
4408
- date: (desc?: string) => AxFieldType;
4409
- datetime: (desc?: string) => AxFieldType;
4410
- json: (desc?: string) => AxFieldType;
4411
- image: (desc?: string) => AxFieldType;
4412
- audio: (desc?: string) => AxFieldType;
4413
- class: (options: readonly string[], desc?: string) => AxFieldType;
4414
- code: (language: string, desc?: string) => AxFieldType;
4415
- array: <T extends AxFieldType>(baseType: T) => T & {
4416
- readonly isArray: true;
4417
- };
4418
- optional: <T extends AxFieldType>(baseType: T) => T & {
4419
- readonly isOptional: true;
4420
- };
4421
- internal: <T extends AxFieldType>(baseType: T) => T & {
4422
- readonly isInternal: true;
4423
- };
4424
- };
5567
+ declare function s<const T extends string>(signature: T): AxSignature<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>;
5568
+ declare function ax<const T extends string>(signature: T, options?: Readonly<AxProgramForwardOptions<any>>): AxGen<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>;
4425
5569
 
4426
5570
  /**
4427
5571
  * Analyzes mapping functions to extract state dependencies.
@@ -4522,18 +5666,18 @@ interface AxFlowDynamicContext<T extends Readonly<AxAIService>> {
4522
5666
  ai?: T;
4523
5667
  options?: AxProgramForwardOptions<NonNullable<ReturnType<T['getModelList']>>[number]['key']>;
4524
5668
  }
4525
- type GetGenIn<T extends AxProgrammable<AxGenIn, AxGenOut>> = T extends AxProgrammable<infer IN, AxGenOut> ? IN : never;
4526
- type GetGenOut<T extends AxProgrammable<AxGenIn, AxGenOut>> = T extends AxProgrammable<AxGenIn, infer OUT> ? OUT : never;
4527
- type InferAxGen<TSig extends string> = TSig extends string ? AxGen<AxGenIn, AxGenOut> : never;
5669
+ type GetGenIn<T extends AxProgrammable<any, any>> = T extends AxProgrammable<infer IN, any> ? IN : never;
5670
+ type GetGenOut<T extends AxProgrammable<any, any>> = T extends AxProgrammable<any, infer OUT> ? OUT : never;
5671
+ type InferAxGen<TSig extends string> = AxGen<ParseSignature<TSig>['inputs'], ParseSignature<TSig>['outputs']>;
4528
5672
  type NodeResultKey<TNodeName extends string> = `${TNodeName}Result`;
4529
- type AddNodeResult<TState extends AxFlowState, TNodeName extends string, TNodeOut extends AxGenOut> = TState & {
5673
+ type AddNodeResult<TState extends AxFlowState, TNodeName extends string, TNodeOut> = TState & {
4530
5674
  [K in NodeResultKey<TNodeName>]: TNodeOut;
4531
5675
  };
4532
5676
  /**
4533
5677
  * Interface for flows that can be tuned, executed, and used in compositions.
4534
5678
  * Provides methods for building and executing complex AI workflows.
4535
5679
  */
4536
- interface AxFlowable<IN extends AxGenIn, OUT extends AxGenOut> extends AxProgrammable<IN, OUT> {
5680
+ interface AxFlowable<IN, OUT> extends AxProgrammable<IN, OUT> {
4537
5681
  }
4538
5682
  type AxFlowTypedParallelBranch<TNodes extends Record<string, AxProgrammable<any, any>>, TState extends AxFlowState> = (subFlow: AxFlowTypedSubContext<TNodes, TState>) => AxFlowTypedSubContext<TNodes, AxFlowState>;
4539
5683
  interface AxFlowTypedSubContext<TNodes extends Record<string, AxProgrammable<any, any>>, TState extends AxFlowState> {
@@ -4795,6 +5939,92 @@ declare class AxFlowExecutionPlanner {
4795
5939
  };
4796
5940
  }
4797
5941
 
5942
+ /**
5943
+ * Data types for different AxFlow logging events
5944
+ */
5945
+ interface AxFlowLoggerData {
5946
+ name: string;
5947
+ timestamp: number;
5948
+ [key: string]: unknown;
5949
+ }
5950
+ interface AxFlowStartData extends AxFlowLoggerData {
5951
+ name: 'FlowStart';
5952
+ inputFields: string[];
5953
+ totalSteps: number;
5954
+ parallelGroups: number;
5955
+ maxParallelism: number;
5956
+ autoParallelEnabled: boolean;
5957
+ }
5958
+ interface AxFlowStepStartData extends AxFlowLoggerData {
5959
+ name: 'StepStart';
5960
+ stepIndex: number;
5961
+ stepType: 'execute' | 'map' | 'merge' | 'parallel-map' | 'parallel' | 'derive' | 'branch' | 'feedback' | 'while' | 'other';
5962
+ nodeName?: string;
5963
+ dependencies: string[];
5964
+ produces: string[];
5965
+ state: AxFlowState;
5966
+ }
5967
+ interface AxFlowStepCompleteData extends AxFlowLoggerData {
5968
+ name: 'StepComplete';
5969
+ stepIndex: number;
5970
+ stepType: 'execute' | 'map' | 'merge' | 'parallel-map' | 'parallel' | 'derive' | 'branch' | 'feedback' | 'while' | 'other';
5971
+ nodeName?: string;
5972
+ executionTime: number;
5973
+ state: AxFlowState;
5974
+ newFields?: string[];
5975
+ result?: any;
5976
+ }
5977
+ interface AxFlowParallelGroupStartData extends AxFlowLoggerData {
5978
+ name: 'ParallelGroupStart';
5979
+ groupLevel: number;
5980
+ stepsCount: number;
5981
+ stepTypes: string[];
5982
+ }
5983
+ interface AxFlowParallelGroupCompleteData extends AxFlowLoggerData {
5984
+ name: 'ParallelGroupComplete';
5985
+ groupLevel: number;
5986
+ stepsCount: number;
5987
+ executionTime: number;
5988
+ }
5989
+ interface AxFlowBranchEvaluationData extends AxFlowLoggerData {
5990
+ name: 'BranchEvaluation';
5991
+ branchValue: unknown;
5992
+ hasMatchingBranch: boolean;
5993
+ branchStepsCount: number;
5994
+ }
5995
+ interface AxFlowCompleteData extends AxFlowLoggerData {
5996
+ name: 'FlowComplete';
5997
+ totalExecutionTime: number;
5998
+ finalState: AxFlowState;
5999
+ outputFields: string[];
6000
+ stepsExecuted: number;
6001
+ }
6002
+ interface AxFlowErrorData extends AxFlowLoggerData {
6003
+ name: 'FlowError';
6004
+ error: string;
6005
+ stepIndex?: number;
6006
+ stepType?: string;
6007
+ nodeName?: string;
6008
+ state?: AxFlowState;
6009
+ }
6010
+ type AxFlowLogData = AxFlowStartData | AxFlowStepStartData | AxFlowStepCompleteData | AxFlowParallelGroupStartData | AxFlowParallelGroupCompleteData | AxFlowBranchEvaluationData | AxFlowCompleteData | AxFlowErrorData;
6011
+ /**
6012
+ * Function type for AxFlow logging
6013
+ */
6014
+ type AxFlowLoggerFunction = (data: AxFlowLogData) => void;
6015
+ /**
6016
+ * Factory function to create a colorized AxFlow logger
6017
+ */
6018
+ declare const axCreateFlowColorLogger: (output?: (message: string) => void) => AxFlowLoggerFunction;
6019
+ /**
6020
+ * Factory function to create a text-only AxFlow logger (no colors)
6021
+ */
6022
+ declare const axCreateFlowTextLogger: (output?: (message: string) => void) => AxFlowLoggerFunction;
6023
+ /**
6024
+ * Default AxFlow logger with colors
6025
+ */
6026
+ declare const axDefaultFlowLogger: AxFlowLoggerFunction;
6027
+
4798
6028
  /**
4799
6029
  * AxFlow - A fluent, chainable API for building and orchestrating complex, stateful AI programs.
4800
6030
  *
@@ -4813,7 +6043,7 @@ declare class AxFlowExecutionPlanner {
4813
6043
  * const result = await flow.forward(ai, { topic: "AI safety" })
4814
6044
  * ```
4815
6045
  */
4816
- declare class AxFlow<IN extends AxGenIn, OUT extends AxGenOut, TNodes extends Record<string, AxProgrammable<any, any>> = Record<string, never>, // Node registry for type tracking
6046
+ declare class AxFlow<IN extends Record<string, any>, OUT, TNodes extends Record<string, AxProgrammable<any, any>> = Record<string, never>, // Node registry for type tracking
4817
6047
  TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
4818
6048
  private readonly nodes;
4819
6049
  private readonly flowDefinition;
@@ -4826,10 +6056,28 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
4826
6056
  private program?;
4827
6057
  private nodeUsage;
4828
6058
  private nodeTraces;
6059
+ private readonly flowLogger?;
6060
+ private readonly timingLogger?;
4829
6061
  /**
4830
6062
  * Converts a string to camelCase for valid field names
4831
6063
  */
4832
6064
  private toCamelCase;
6065
+ /**
6066
+ * Executes a list of steps with comprehensive logging
6067
+ */
6068
+ private executeStepsWithLogging;
6069
+ /**
6070
+ * Determines the type of a step function for logging purposes
6071
+ */
6072
+ private getStepType;
6073
+ /**
6074
+ * Gets metadata about a step for logging purposes
6075
+ */
6076
+ private getStepMetadata;
6077
+ /**
6078
+ * Extracts node name from step function source code
6079
+ */
6080
+ private extractNodeNameFromSource;
4833
6081
  /**
4834
6082
  * Infers the signature of the flow based on the execution plan and node definitions.
4835
6083
  * This is the core method that determines what input/output fields the flow should have
@@ -4853,7 +6101,20 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
4853
6101
  constructor(options?: {
4854
6102
  autoParallel?: boolean;
4855
6103
  batchSize?: number;
6104
+ logger?: AxFlowLoggerFunction;
6105
+ debug?: boolean;
4856
6106
  });
6107
+ /**
6108
+ * Static factory method to create a new AxFlow instance with proper type safety
6109
+ * @param options - Optional configuration for the flow
6110
+ * @returns New AxFlow instance with type-safe defaults
6111
+ */
6112
+ static create<IN extends Record<string, any> = Record<string, never>, OUT = {}, TNodes extends Record<string, AxProgrammable<any, any>> = Record<string, never>, TState extends AxFlowState = IN>(options?: {
6113
+ autoParallel?: boolean;
6114
+ batchSize?: number;
6115
+ logger?: AxFlowLoggerFunction;
6116
+ debug?: boolean;
6117
+ }): AxFlow<IN, OUT, TNodes, TState>;
4857
6118
  /**
4858
6119
  * Initializes the program field every time something is added to the graph
4859
6120
  */
@@ -4946,7 +6207,7 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
4946
6207
  *
4947
6208
  * @example
4948
6209
  * ```
4949
- * const sig = new AxSignature('text:string -> summary:string')
6210
+ * const sig = s('text:string -> summary:string')
4950
6211
  * flow.node('summarizer', sig, { temperature: 0.1 })
4951
6212
  * ```
4952
6213
  */
@@ -5014,6 +6275,22 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
5014
6275
  * ```
5015
6276
  */
5016
6277
  map<TNewState extends AxFlowState>(transform: (_state: TState) => TNewState): AxFlow<IN, OUT, TNodes, TNewState>;
6278
+ /**
6279
+ * Applies an asynchronous transformation to the state object.
6280
+ * Returns a new AxFlow type with the evolved state.
6281
+ *
6282
+ * @param transform - Async function that takes the current state and returns a promise of new state
6283
+ * @returns New AxFlow instance with updated TState type
6284
+ *
6285
+ * @example
6286
+ * ```
6287
+ * flow.map(async state => ({
6288
+ * ...state,
6289
+ * apiResult: await fetchDataFromAPI(state.query)
6290
+ * }))
6291
+ * ```
6292
+ */
6293
+ map<TNewState extends AxFlowState>(transform: (_state: TState) => Promise<TNewState>): AxFlow<IN, OUT, TNodes, TNewState>;
5017
6294
  /**
5018
6295
  * Applies a transformation to the state object with optional parallel execution.
5019
6296
  * When parallel is enabled, the transform function should prepare data for parallel processing.
@@ -5036,16 +6313,65 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
5036
6313
  map<TNewState extends AxFlowState>(transforms: Array<(_state: TState) => TNewState>, options: {
5037
6314
  parallel: true;
5038
6315
  }): AxFlow<IN, OUT, TNodes, TNewState>;
5039
- map<TNewState extends AxFlowState>(transform: (_state: TState) => TNewState, options?: {
6316
+ /**
6317
+ * Applies async transformations to the state object with optional parallel execution.
6318
+ * When parallel is enabled, all async transforms are executed concurrently.
6319
+ *
6320
+ * @param transforms - Array of async transformation functions to apply in parallel
6321
+ * @param options - Options including parallel execution configuration
6322
+ * @returns New AxFlow instance with updated TState type
6323
+ *
6324
+ * @example
6325
+ * ```
6326
+ * // Parallel async map with multiple transforms
6327
+ * flow.map([
6328
+ * async state => ({ ...state, result1: await apiCall1(state.data) }),
6329
+ * async state => ({ ...state, result2: await apiCall2(state.data) }),
6330
+ * async state => ({ ...state, result3: await apiCall3(state.data) })
6331
+ * ], { parallel: true })
6332
+ * ```
6333
+ */
6334
+ map<TNewState extends AxFlowState>(transforms: Array<(_state: TState) => Promise<TNewState>>, options: {
6335
+ parallel: true;
6336
+ }): AxFlow<IN, OUT, TNodes, TNewState>;
6337
+ map<TNewState extends AxFlowState>(transform: (_state: TState) => TNewState | Promise<TNewState>, options?: {
5040
6338
  parallel?: boolean;
5041
6339
  }): AxFlow<IN, OUT, TNodes, TNewState>;
5042
6340
  /**
5043
- * Short alias for map() - supports parallel option
6341
+ * Short alias for map() - supports parallel option and async functions
5044
6342
  */
5045
6343
  m<TNewState extends AxFlowState>(transform: (_state: TState) => TNewState): AxFlow<IN, OUT, TNodes, TNewState>;
6344
+ m<TNewState extends AxFlowState>(transform: (_state: TState) => Promise<TNewState>): AxFlow<IN, OUT, TNodes, TNewState>;
5046
6345
  m<TNewState extends AxFlowState>(transforms: Array<(_state: TState) => TNewState>, options: {
5047
6346
  parallel: true;
5048
6347
  }): AxFlow<IN, OUT, TNodes, TNewState>;
6348
+ m<TNewState extends AxFlowState>(transforms: Array<(_state: TState) => Promise<TNewState>>, options: {
6349
+ parallel: true;
6350
+ }): AxFlow<IN, OUT, TNodes, TNewState>;
6351
+ /**
6352
+ * Terminal transformation that sets the final output type of the flow.
6353
+ * Use this as the last transformation to get proper type inference for the flow result.
6354
+ *
6355
+ * @param transform - Function that transforms the current state to the final output
6356
+ * @returns A new flow with the output type set to the transform result
6357
+ *
6358
+ * @example
6359
+ * ```typescript
6360
+ * const flow = flow<{ input: string }>()
6361
+ * .map(state => ({ ...state, processed: true }))
6362
+ * .returns(state => ({
6363
+ * result: state.processed ? "done" : "pending"
6364
+ * })) // TypeScript now knows the output is { result: string }
6365
+ * ```
6366
+ */
6367
+ returns<TNewOut extends Record<string, unknown>>(transform: (_state: TState) => TNewOut): AxFlow<IN, TNewOut, TNodes, TState>;
6368
+ /**
6369
+ * Short alias for returns() - r() is to returns() as m() is to map()
6370
+ *
6371
+ * @param transform - Function that transforms the current state to the final output
6372
+ * @returns A new flow with the output type set to the transform result
6373
+ */
6374
+ r<TNewOut extends Record<string, unknown>>(transform: (_state: TState) => TNewOut): AxFlow<IN, TNewOut, TNodes, TState>;
5049
6375
  /**
5050
6376
  * Labels a step for later reference (useful for feedback loops).
5051
6377
  *
@@ -5284,7 +6610,146 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
5284
6610
  groups?: AxFlowParallelGroup[];
5285
6611
  };
5286
6612
  getSignature(): AxSignature;
6613
+ /**
6614
+ * Creates a new AxFlow node from an existing signature by extending it with additional fields.
6615
+ *
6616
+ * @param name - The name of the new node
6617
+ * @param baseSignature - The base signature to extend (string or AxSignature)
6618
+ * @param extensions - Object defining how to extend the signature
6619
+ * @returns New AxFlow instance with the extended node
6620
+ *
6621
+ * @example
6622
+ * ```typescript
6623
+ * // Create a chain-of-thought node
6624
+ * flow.nodeExtended('reasoner', 'question:string -> answer:string', {
6625
+ * prependOutputs: [
6626
+ * { name: 'reasoning', type: f.internal(f.string('Step-by-step reasoning')) }
6627
+ * ]
6628
+ * })
6629
+ *
6630
+ * // Create a node with context and confidence
6631
+ * flow.nodeExtended('analyzer', 'input:string -> output:string', {
6632
+ * appendInputs: [{ name: 'context', type: f.optional(f.string('Context')) }],
6633
+ * appendOutputs: [{ name: 'confidence', type: f.number('Confidence score') }]
6634
+ * })
6635
+ * ```
6636
+ */
6637
+ nodeExtended<TName extends string>(name: TName, baseSignature: string | AxSignature, extensions: {
6638
+ prependInputs?: Array<{
6639
+ name: string;
6640
+ type: AxFieldType;
6641
+ }>;
6642
+ appendInputs?: Array<{
6643
+ name: string;
6644
+ type: AxFieldType;
6645
+ }>;
6646
+ prependOutputs?: Array<{
6647
+ name: string;
6648
+ type: AxFieldType;
6649
+ }>;
6650
+ appendOutputs?: Array<{
6651
+ name: string;
6652
+ type: AxFieldType;
6653
+ }>;
6654
+ }): AxFlow<IN, OUT, TNodes & {
6655
+ [K in TName]: AxGen<AxGenIn, AxGenOut>;
6656
+ }, TState>;
6657
+ /**
6658
+ * Short alias for nodeExtended() - creates nodes with extended signatures
6659
+ */
6660
+ nx<TName extends string>(name: TName, baseSignature: string | AxSignature, extensions: {
6661
+ prependInputs?: Array<{
6662
+ name: string;
6663
+ type: AxFieldType;
6664
+ }>;
6665
+ appendInputs?: Array<{
6666
+ name: string;
6667
+ type: AxFieldType;
6668
+ }>;
6669
+ prependOutputs?: Array<{
6670
+ name: string;
6671
+ type: AxFieldType;
6672
+ }>;
6673
+ appendOutputs?: Array<{
6674
+ name: string;
6675
+ type: AxFieldType;
6676
+ }>;
6677
+ }): AxFlow<IN, OUT, TNodes & {
6678
+ [K in TName]: AxGen<AxGenIn, AxGenOut>;
6679
+ }, TState>;
6680
+ /**
6681
+ * Applies a final transformation to the state object that updates both state and output type.
6682
+ * This is specifically designed for terminal transformations that shape the final output.
6683
+ *
6684
+ * @param transform - Function that takes the current state and returns the final output
6685
+ * @returns New AxFlow instance with updated OUT and TState types
6686
+ *
6687
+ * @example
6688
+ * ```
6689
+ * const result = await flow
6690
+ * .node('analyzer', 'userQuestion:string -> analysisResult:string')
6691
+ * .execute('analyzer', state => ({ userQuestion: state.userQuestion }))
6692
+ * .mapOutput(state => ({
6693
+ * // Note: Node results are typed as AxFieldValue, so you may need to cast
6694
+ * finalAnswer: state.analyzerResult.analysisResult as string
6695
+ * }))
6696
+ * .forward(ai, { userQuestion: 'test' });
6697
+ *
6698
+ * // result is typed as { finalAnswer: string }
6699
+ * ```
6700
+ */
6701
+ mapOutput<TOutput>(transform: (_state: TState) => TOutput): AxFlow<IN, TOutput, TNodes, TOutput & TState>;
6702
+ /**
6703
+ * Short alias for mapOutput()
6704
+ */
6705
+ mo<TOutput>(transform: (_state: TState) => TOutput): AxFlow<IN, TOutput, TNodes, TOutput & TState>;
5287
6706
  }
6707
+ /**
6708
+ * Factory function to create a new AxFlow instance
6709
+ * Similar to ai() for AI services, this creates a fluent flow
6710
+ *
6711
+ * @param options - Optional configuration for the flow
6712
+ * @returns New AxFlow instance
6713
+ *
6714
+ * @example
6715
+ * ```typescript
6716
+ * // Input type is required - provides type safety throughout the flow
6717
+ * const workflow = flow<{ userInput: string }>()
6718
+ * .node('summarizer', 'documentText:string -> summaryText:string')
6719
+ * .execute('summarizer', state => ({ documentText: state.userInput }));
6720
+ *
6721
+ * // Complex input types work great for multi-field workflows
6722
+ * const complexFlow = flow<{ userQuestion: string; context: string }>()
6723
+ * .map(state => ({
6724
+ * ...state,
6725
+ * processedQuestion: state.userQuestion.toUpperCase() // TypeScript knows this exists!
6726
+ * }));
6727
+ * ```
6728
+ */
6729
+ /**
6730
+ * Creates a new AxFlow instance with required input type specification.
6731
+ *
6732
+ * The input type must be specified upfront to enable proper type inference
6733
+ * throughout the flow construction and execution.
6734
+ *
6735
+ * @example
6736
+ * ```typescript
6737
+ * // ✅ Define input type upfront for better type safety
6738
+ * const workflow = flow<{ userInput: string, options?: any }>()
6739
+ * .map(state => ({ ...state, processedInput: state.userInput.toUpperCase() }))
6740
+ * .node('analyzer', 'processedInput:string -> result:string')
6741
+ *
6742
+ * // ✅ Simple input types work too
6743
+ * const simpleFlow = flow<{ documentText: string }>()
6744
+ * .node('summarizer', 'documentText:string -> summary:string')
6745
+ * ```
6746
+ */
6747
+ declare function flow<TInput extends Record<string, any>, TOutput = {}>(options?: {
6748
+ autoParallel?: boolean;
6749
+ batchSize?: number;
6750
+ logger?: AxFlowLoggerFunction;
6751
+ debug?: boolean;
6752
+ }): AxFlow<TInput, TOutput, {}, TInput>;
5288
6753
 
5289
6754
  /**
5290
6755
  * Implementation of the sub-context for parallel execution
@@ -5666,6 +7131,29 @@ interface AxAgentFeatures {
5666
7131
  /**
5667
7132
  * An AI agent that can process inputs using an AI service and coordinate with child agents.
5668
7133
  * Supports features like smart model routing and automatic input field passing to child agents.
7134
+ *
7135
+ * @deprecated Use the `agent()` factory function instead of instantiating this class directly.
7136
+ * The factory function provides better type inference and cleaner syntax.
7137
+ * This class will be removed in v15.0.0.
7138
+ *
7139
+ * Migration timeline:
7140
+ * - v13.0.24+: Deprecation warnings (current)
7141
+ * - v14.0.0: Runtime console warnings
7142
+ * - v15.0.0: Complete removal
7143
+ *
7144
+ * @example
7145
+ * // Old (deprecated):
7146
+ * const myAgent = new AxAgent({
7147
+ * name: 'myAgent',
7148
+ * description: 'An agent that does something',
7149
+ * signature: 'userInput:string -> responseText:string'
7150
+ * });
7151
+ *
7152
+ * // New (recommended):
7153
+ * const myAgent = agent('userInput:string -> responseText:string', {
7154
+ * name: 'myAgent',
7155
+ * description: 'An agent that does something'
7156
+ * });
5669
7157
  */
5670
7158
  declare class AxAgent<IN extends AxGenIn, OUT extends AxGenOut> implements AxAgentic<IN, OUT> {
5671
7159
  private ai?;
@@ -5686,6 +7174,28 @@ declare class AxAgent<IN extends AxGenIn, OUT extends AxGenOut> implements AxAge
5686
7174
  agents?: AxAgentic<IN, OUT>[];
5687
7175
  functions?: AxInputFunctionType;
5688
7176
  }>, options?: Readonly<AxAgentOptions>);
7177
+ /**
7178
+ * Creates a new AxAgent instance with type-safe signature parsing.
7179
+ * This is the recommended way to create agents with string-based signatures.
7180
+ *
7181
+ * @param signature - The signature string defining input/output fields
7182
+ * @param config - Agent configuration including name, description, etc.
7183
+ * @returns A new AxAgent instance with inferred types
7184
+ *
7185
+ * @example
7186
+ * ```typescript
7187
+ * const agent = AxAgent.create(
7188
+ * 'userInput:string "User question" -> responseText:string "Agent response"',
7189
+ * {
7190
+ * name: 'helpfulAgent',
7191
+ * description: 'An agent that provides helpful responses to user questions',
7192
+ * definition: 'You are a helpful assistant that provides clear, accurate responses to user questions.',
7193
+ * ai: llm
7194
+ * }
7195
+ * );
7196
+ * ```
7197
+ */
7198
+ static create<const T extends string>(signature: T, config: AxAgentConfig<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>): AxAgent<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>;
5689
7199
  setExamples(examples: Readonly<AxProgramExamples<IN, OUT>>, options?: Readonly<AxSetExamplesOptions>): void;
5690
7200
  setId(id: string): void;
5691
7201
  setParentId(parentId: string): void;
@@ -5717,35 +7227,220 @@ declare class AxAgent<IN extends AxGenIn, OUT extends AxGenOut> implements AxAge
5717
7227
  setSignature(signature: NonNullable<ConstructorParameters<typeof AxSignature>[0]>): void;
5718
7228
  private getDebug;
5719
7229
  }
5720
-
5721
- declare class AxChainOfThought<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGenOut> extends AxGen<IN, OUT> {
5722
- constructor(signature: Readonly<AxSignature | string>, options?: Readonly<AxProgramForwardOptions<string> & {
5723
- setVisibleReasoning?: boolean;
5724
- }>);
7230
+ /**
7231
+ * Configuration options for creating an agent using the agent() factory function.
7232
+ */
7233
+ interface AxAgentConfig<IN extends AxGenIn, OUT extends AxGenOut> extends AxAgentOptions {
7234
+ ai?: AxAIService;
7235
+ name: string;
7236
+ description: string;
7237
+ definition?: string;
7238
+ agents?: AxAgentic<IN, OUT>[];
7239
+ functions?: AxInputFunctionType;
5725
7240
  }
7241
+ /**
7242
+ * Creates a strongly-typed AI agent from a string signature.
7243
+ * This is the recommended way to create agents, providing better type inference and cleaner syntax.
7244
+ *
7245
+ * @param signature - The input/output signature as a string (e.g., "userInput:string -> responseText:string")
7246
+ * @param config - Configuration options for the agent
7247
+ * @returns A typed agent instance
7248
+ *
7249
+ * @example
7250
+ * ```typescript
7251
+ * const myAgent = agent('userInput:string -> responseText:string', {
7252
+ * name: 'myAgent',
7253
+ * description: 'An agent that processes user input and returns a response',
7254
+ * definition: 'You are a helpful assistant that responds to user queries...'
7255
+ * });
7256
+ *
7257
+ * // With child agents
7258
+ * const parentAgent = agent('taskDescription:string -> completedTask:string', {
7259
+ * name: 'parentAgent',
7260
+ * description: 'Coordinates child agents to complete tasks',
7261
+ * agents: [childAgent1, childAgent2]
7262
+ * });
7263
+ *
7264
+ * // Type-safe usage
7265
+ * const result = await myAgent.forward(ai, { userInput: 'Hello!' });
7266
+ * console.log(result.responseText); // TypeScript knows this exists
7267
+ * ```
7268
+ */
7269
+ declare function agent<const T extends string>(signature: T, config: AxAgentConfig<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>): AxAgent<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>;
5726
7270
 
5727
- declare class AxRAG extends AxChainOfThought<{
5728
- context: string[];
5729
- question: string;
7271
+ /**
7272
+ * Advanced Multi-hop RAG with iterative query refinement, context accumulation,
7273
+ * parallel sub-queries, and self-healing quality feedback loops
7274
+ *
7275
+ * @param queryFn - Function to execute search queries and return results
7276
+ * @param options - Configuration options
7277
+ * @returns AxFlow instance with advanced RAG capability
7278
+ */
7279
+ declare const axRAG: (queryFn: (query: string) => Promise<string>, options?: {
7280
+ maxHops?: number;
7281
+ qualityThreshold?: number;
7282
+ maxIterations?: number;
7283
+ qualityTarget?: number;
7284
+ disableQualityHealing?: boolean;
7285
+ logger?: AxFlowLoggerFunction;
7286
+ debug?: boolean;
7287
+ }) => AxFlow<{
7288
+ originalQuestion: string;
5730
7289
  }, {
5731
- answer: string;
5732
- }> {
5733
- private genQuery;
5734
- private queryFn;
5735
- private maxHops;
5736
- constructor(queryFn: (query: string) => Promise<string>, options: Readonly<AxProgramForwardOptions<string> & {
5737
- maxHops?: number;
5738
- }>);
5739
- forward<T extends Readonly<AxAIService>>(ai: T, values: {
5740
- context: string[];
5741
- question: string;
5742
- } | AxMessage<{
5743
- context: string[];
5744
- question: string;
5745
- }>[], options?: Readonly<AxProgramForwardOptionsWithModels<T>>): Promise<{
5746
- answer: string;
5747
- }>;
5748
- }
7290
+ finalAnswer: string;
7291
+ totalHops: number;
7292
+ retrievedContexts: string[];
7293
+ iterationCount: number;
7294
+ healingAttempts: number;
7295
+ qualityAchieved: number;
7296
+ }, {
7297
+ queryGenerator: InferAxGen<"originalQuestion:string, previousContext?:string -> searchQuery:string, queryReasoning:string">;
7298
+ } & {
7299
+ contextualizer: InferAxGen<"retrievedDocument:string, accumulatedContext?:string -> enhancedContext:string">;
7300
+ } & {
7301
+ qualityAssessor: InferAxGen<"currentContext:string, originalQuestion:string -> completenessScore:number, missingAspects:string[]">;
7302
+ } & {
7303
+ questionDecomposer: InferAxGen<"complexQuestion:string -> subQuestions:string[], decompositionReason:string">;
7304
+ } & {
7305
+ evidenceSynthesizer: InferAxGen<"collectedEvidence:string[], originalQuestion:string -> synthesizedEvidence:string, evidenceGaps:string[]">;
7306
+ } & {
7307
+ gapAnalyzer: InferAxGen<"synthesizedEvidence:string, evidenceGaps:string[], originalQuestion:string -> needsMoreInfo:boolean, focusedQueries:string[]">;
7308
+ } & {
7309
+ answerGenerator: InferAxGen<"finalContext:string, originalQuestion:string -> comprehensiveAnswer:string, confidenceLevel:number">;
7310
+ } & {
7311
+ queryRefiner: InferAxGen<"originalQuestion:string, currentContext:string, missingAspects:string[] -> refinedQuery:string">;
7312
+ } & {
7313
+ qualityValidator: InferAxGen<"generatedAnswer:string, userQuery:string -> qualityScore:number, issues:string[]">;
7314
+ } & {
7315
+ answerHealer: InferAxGen<"originalAnswer:string, healingDocument:string, issues?:string[] -> healedAnswer:string">;
7316
+ }, {
7317
+ currentAnswer: string;
7318
+ currentQuality: number;
7319
+ currentIssues: string[];
7320
+ shouldContinueHealing: boolean;
7321
+ healingResult: {
7322
+ healingDocument: string;
7323
+ };
7324
+ healingAttempts: number;
7325
+ allEvidence: string[];
7326
+ evidenceSources: string[];
7327
+ needsMoreInfo: boolean;
7328
+ synthesizedEvidence: string;
7329
+ retrievalResults: string[];
7330
+ currentQueries: string[];
7331
+ iteration: number;
7332
+ searchQuery: string;
7333
+ accumulatedContext: string;
7334
+ retrievedContexts: string[];
7335
+ completenessScore: number;
7336
+ shouldContinue: boolean;
7337
+ retrievalResult: {
7338
+ retrievedDocument: string;
7339
+ retrievalConfidence: number;
7340
+ };
7341
+ currentHop: number;
7342
+ maxHops: number;
7343
+ qualityThreshold: number;
7344
+ maxIterations: number;
7345
+ qualityTarget: number;
7346
+ disableQualityHealing: boolean;
7347
+ originalQuestion: string;
7348
+ queryGeneratorResult: BuildObject<[{
7349
+ name: "searchQuery";
7350
+ optional: false;
7351
+ } & {
7352
+ type: "string";
7353
+ }, {
7354
+ name: "queryReasoning";
7355
+ optional: false;
7356
+ } & {
7357
+ type: "string";
7358
+ }]>;
7359
+ contextualizerResult: BuildObject<[{
7360
+ name: "enhancedContext";
7361
+ optional: false;
7362
+ } & {
7363
+ type: "string";
7364
+ }]>;
7365
+ qualityAssessorResult: BuildObject<[{
7366
+ name: "completenessScore";
7367
+ optional: false;
7368
+ } & {
7369
+ type: "number";
7370
+ }, {
7371
+ name: "missingAspects";
7372
+ optional: false;
7373
+ } & {
7374
+ type: "string[]";
7375
+ }]>;
7376
+ queryRefinerResult: BuildObject<[{
7377
+ name: "refinedQuery";
7378
+ optional: false;
7379
+ } & {
7380
+ type: "string";
7381
+ }]>;
7382
+ questionDecomposerResult: BuildObject<[{
7383
+ name: "subQuestions";
7384
+ optional: false;
7385
+ } & {
7386
+ type: "string[]";
7387
+ }, {
7388
+ name: "decompositionReason";
7389
+ optional: false;
7390
+ } & {
7391
+ type: "string";
7392
+ }]>;
7393
+ evidenceSynthesizerResult: BuildObject<[{
7394
+ name: "synthesizedEvidence";
7395
+ optional: false;
7396
+ } & {
7397
+ type: "string";
7398
+ }, {
7399
+ name: "evidenceGaps";
7400
+ optional: false;
7401
+ } & {
7402
+ type: "string[]";
7403
+ }]>;
7404
+ gapAnalyzerResult: BuildObject<[{
7405
+ name: "needsMoreInfo";
7406
+ optional: false;
7407
+ } & {
7408
+ type: "boolean";
7409
+ }, {
7410
+ name: "focusedQueries";
7411
+ optional: false;
7412
+ } & {
7413
+ type: "string[]";
7414
+ }]>;
7415
+ answerGeneratorResult: BuildObject<[{
7416
+ name: "comprehensiveAnswer";
7417
+ optional: false;
7418
+ } & {
7419
+ type: "string";
7420
+ }, {
7421
+ name: "confidenceLevel";
7422
+ optional: false;
7423
+ } & {
7424
+ type: "number";
7425
+ }]>;
7426
+ qualityValidatorResult: BuildObject<[{
7427
+ name: "qualityScore";
7428
+ optional: false;
7429
+ } & {
7430
+ type: "number";
7431
+ }, {
7432
+ name: "issues";
7433
+ optional: false;
7434
+ } & {
7435
+ type: "string[]";
7436
+ }]>;
7437
+ answerHealerResult: BuildObject<[{
7438
+ name: "healedAnswer";
7439
+ optional: false;
7440
+ } & {
7441
+ type: "string";
7442
+ }]>;
7443
+ }>;
5749
7444
 
5750
7445
  declare const axSpanAttributes: {
5751
7446
  LLM_SYSTEM: string;
@@ -5818,4 +7513,4 @@ declare class AxRateLimiterTokenUsage {
5818
7513
  acquire(tokens: number): Promise<void>;
5819
7514
  }
5820
7515
 
5821
- export { AxAI, AxAIAnthropic, type AxAIAnthropicArgs, type AxAIAnthropicChatError, type AxAIAnthropicChatRequest, type AxAIAnthropicChatRequestCacheParam, type AxAIAnthropicChatResponse, type AxAIAnthropicChatResponseDelta, type AxAIAnthropicConfig, type AxAIAnthropicContentBlockDeltaEvent, type AxAIAnthropicContentBlockStartEvent, type AxAIAnthropicContentBlockStopEvent, type AxAIAnthropicErrorEvent, type AxAIAnthropicMessageDeltaEvent, type AxAIAnthropicMessageStartEvent, type AxAIAnthropicMessageStopEvent, AxAIAnthropicModel, type AxAIAnthropicPingEvent, type AxAIAnthropicThinkingConfig, type AxAIAnthropicThinkingTokenBudgetLevels, AxAIAnthropicVertexModel, type AxAIArgs, AxAIAzureOpenAI, type AxAIAzureOpenAIArgs, type AxAIAzureOpenAIConfig, AxAICohere, type AxAICohereArgs, type AxAICohereChatRequest, type AxAICohereChatRequestToolResults, type AxAICohereChatResponse, type AxAICohereChatResponseDelta, type AxAICohereChatResponseToolCalls, type AxAICohereConfig, AxAICohereEmbedModel, type AxAICohereEmbedRequest, type AxAICohereEmbedResponse, AxAICohereModel, AxAIDeepSeek, type AxAIDeepSeekArgs, AxAIDeepSeekModel, type AxAIEmbedModels, type AxAIFeatures, AxAIGoogleGemini, type AxAIGoogleGeminiArgs, type AxAIGoogleGeminiBatchEmbedRequest, type AxAIGoogleGeminiBatchEmbedResponse, type AxAIGoogleGeminiChatRequest, type AxAIGoogleGeminiChatResponse, type AxAIGoogleGeminiChatResponseDelta, type AxAIGoogleGeminiConfig, type AxAIGoogleGeminiContent, type AxAIGoogleGeminiContentPart, AxAIGoogleGeminiEmbedModel, AxAIGoogleGeminiEmbedTypes, type AxAIGoogleGeminiGenerationConfig, AxAIGoogleGeminiModel, type AxAIGoogleGeminiOptionsTools, AxAIGoogleGeminiSafetyCategory, type AxAIGoogleGeminiSafetySettings, AxAIGoogleGeminiSafetyThreshold, type AxAIGoogleGeminiThinkingConfig, type AxAIGoogleGeminiThinkingTokenBudgetLevels, type AxAIGoogleGeminiTool, type AxAIGoogleGeminiToolConfig, type AxAIGoogleGeminiToolFunctionDeclaration, type AxAIGoogleGeminiToolGoogleSearchRetrieval, type AxAIGoogleVertexBatchEmbedRequest, type AxAIGoogleVertexBatchEmbedResponse, AxAIGrok, type AxAIGrokArgs, type AxAIGrokChatRequest, AxAIGrokEmbedModels, AxAIGrokModel, type AxAIGrokOptionsTools, type AxAIGrokSearchSource, AxAIGroq, type AxAIGroqArgs, AxAIGroqModel, AxAIHuggingFace, type AxAIHuggingFaceArgs, type AxAIHuggingFaceConfig, AxAIHuggingFaceModel, type AxAIHuggingFaceRequest, type AxAIHuggingFaceResponse, type AxAIInputModelList, type AxAIMemory, type AxAIMetricsInstruments, AxAIMistral, type AxAIMistralArgs, type AxAIMistralChatRequest, AxAIMistralEmbedModels, AxAIMistralModel, type AxAIModelList, type AxAIModelListBase, type AxAIModels, AxAIOllama, type AxAIOllamaAIConfig, type AxAIOllamaArgs, AxAIOpenAI, type AxAIOpenAIAnnotation, type AxAIOpenAIArgs, AxAIOpenAIBase, type AxAIOpenAIBaseArgs, type AxAIOpenAIChatRequest, type AxAIOpenAIChatResponse, type AxAIOpenAIChatResponseDelta, type AxAIOpenAIConfig, AxAIOpenAIEmbedModel, type AxAIOpenAIEmbedRequest, type AxAIOpenAIEmbedResponse, type AxAIOpenAILogprob, AxAIOpenAIModel, type AxAIOpenAIResponseDelta, AxAIOpenAIResponses, type AxAIOpenAIResponsesArgs, AxAIOpenAIResponsesBase, type AxAIOpenAIResponsesCodeInterpreterToolCall, type AxAIOpenAIResponsesComputerToolCall, type AxAIOpenAIResponsesConfig, type AxAIOpenAIResponsesContentPartAddedEvent, type AxAIOpenAIResponsesContentPartDoneEvent, type AxAIOpenAIResponsesDefineFunctionTool, type AxAIOpenAIResponsesErrorEvent, type AxAIOpenAIResponsesFileSearchCallCompletedEvent, type AxAIOpenAIResponsesFileSearchCallInProgressEvent, type AxAIOpenAIResponsesFileSearchCallSearchingEvent, type AxAIOpenAIResponsesFileSearchToolCall, type AxAIOpenAIResponsesFunctionCallArgumentsDeltaEvent, type AxAIOpenAIResponsesFunctionCallArgumentsDoneEvent, type AxAIOpenAIResponsesFunctionCallItem, type AxAIOpenAIResponsesImageGenerationCallCompletedEvent, type AxAIOpenAIResponsesImageGenerationCallGeneratingEvent, type AxAIOpenAIResponsesImageGenerationCallInProgressEvent, type AxAIOpenAIResponsesImageGenerationCallPartialImageEvent, type AxAIOpenAIResponsesImageGenerationToolCall, AxAIOpenAIResponsesImpl, type AxAIOpenAIResponsesInputAudioContentPart, type AxAIOpenAIResponsesInputContentPart, type AxAIOpenAIResponsesInputFunctionCallItem, type AxAIOpenAIResponsesInputFunctionCallOutputItem, type AxAIOpenAIResponsesInputImageUrlContentPart, type AxAIOpenAIResponsesInputItem, type AxAIOpenAIResponsesInputMessageItem, type AxAIOpenAIResponsesInputTextContentPart, type AxAIOpenAIResponsesLocalShellToolCall, type AxAIOpenAIResponsesMCPCallArgumentsDeltaEvent, type AxAIOpenAIResponsesMCPCallArgumentsDoneEvent, type AxAIOpenAIResponsesMCPCallCompletedEvent, type AxAIOpenAIResponsesMCPCallFailedEvent, type AxAIOpenAIResponsesMCPCallInProgressEvent, type AxAIOpenAIResponsesMCPListToolsCompletedEvent, type AxAIOpenAIResponsesMCPListToolsFailedEvent, type AxAIOpenAIResponsesMCPListToolsInProgressEvent, type AxAIOpenAIResponsesMCPToolCall, AxAIOpenAIResponsesModel, type AxAIOpenAIResponsesOutputItem, type AxAIOpenAIResponsesOutputItemAddedEvent, type AxAIOpenAIResponsesOutputItemDoneEvent, type AxAIOpenAIResponsesOutputMessageItem, type AxAIOpenAIResponsesOutputRefusalContentPart, type AxAIOpenAIResponsesOutputTextAnnotationAddedEvent, type AxAIOpenAIResponsesOutputTextContentPart, type AxAIOpenAIResponsesOutputTextDeltaEvent, type AxAIOpenAIResponsesOutputTextDoneEvent, type AxAIOpenAIResponsesReasoningDeltaEvent, type AxAIOpenAIResponsesReasoningDoneEvent, type AxAIOpenAIResponsesReasoningItem, type AxAIOpenAIResponsesReasoningSummaryDeltaEvent, type AxAIOpenAIResponsesReasoningSummaryDoneEvent, type AxAIOpenAIResponsesReasoningSummaryPart, type AxAIOpenAIResponsesReasoningSummaryPartAddedEvent, type AxAIOpenAIResponsesReasoningSummaryPartDoneEvent, type AxAIOpenAIResponsesReasoningSummaryTextDeltaEvent, type AxAIOpenAIResponsesReasoningSummaryTextDoneEvent, type AxAIOpenAIResponsesRefusalDeltaEvent, type AxAIOpenAIResponsesRefusalDoneEvent, type AxAIOpenAIResponsesRequest, type AxAIOpenAIResponsesResponse, type AxAIOpenAIResponsesResponseCompletedEvent, type AxAIOpenAIResponsesResponseCreatedEvent, type AxAIOpenAIResponsesResponseDelta, type AxAIOpenAIResponsesResponseFailedEvent, type AxAIOpenAIResponsesResponseInProgressEvent, type AxAIOpenAIResponsesResponseIncompleteEvent, type AxAIOpenAIResponsesResponseQueuedEvent, type AxAIOpenAIResponsesStreamEvent, type AxAIOpenAIResponsesStreamEventBase, type AxAIOpenAIResponsesToolCall, type AxAIOpenAIResponsesToolCallBase, type AxAIOpenAIResponsesToolChoice, type AxAIOpenAIResponsesToolDefinition, type AxAIOpenAIResponsesWebSearchCallCompletedEvent, type AxAIOpenAIResponsesWebSearchCallInProgressEvent, type AxAIOpenAIResponsesWebSearchCallSearchingEvent, type AxAIOpenAIResponsesWebSearchToolCall, type AxAIOpenAIUrlCitation, type AxAIOpenAIUsage, AxAIRefusalError, AxAIReka, type AxAIRekaArgs, type AxAIRekaChatRequest, type AxAIRekaChatResponse, type AxAIRekaChatResponseDelta, type AxAIRekaConfig, AxAIRekaModel, type AxAIRekaUsage, type AxAIService, AxAIServiceAbortedError, type AxAIServiceActionOptions, AxAIServiceAuthenticationError, AxAIServiceError, type AxAIServiceImpl, type AxAIServiceMetrics, type AxAIServiceModelType, AxAIServiceNetworkError, type AxAIServiceOptions, AxAIServiceResponseError, AxAIServiceStatusError, AxAIServiceStreamTerminatedError, AxAIServiceTimeoutError, AxAITogether, type AxAITogetherArgs, AxAIWebLLM, type AxAIWebLLMArgs, type AxAIWebLLMChatRequest, type AxAIWebLLMChatResponse, type AxAIWebLLMChatResponseDelta, type AxAIWebLLMConfig, type AxAIWebLLMEmbedModel, type AxAIWebLLMEmbedRequest, type AxAIWebLLMEmbedResponse, AxAIWebLLMModel, type AxAPI, type AxAPIConfig, AxAgent, type AxAgentFeatures, type AxAgentOptions, type AxAgentic, AxApacheTika, type AxApacheTikaArgs, type AxApacheTikaConvertOptions, type AxAssertion, AxAssertionError, AxBalancer, type AxBalancerOptions, AxBaseAI, type AxBaseAIArgs, AxBaseOptimizer, type AxBootstrapCompileOptions, AxBootstrapFewShot, type AxBootstrapOptimizerOptions, AxChainOfThought, type AxChatRequest, type AxChatResponse, type AxChatResponseFunctionCall, type AxChatResponseResult, type AxCheckpointLoadFn, type AxCheckpointSaveFn, type AxCompileOptions, type AxCostTracker, type AxCostTrackerOptions, AxDB, type AxDBArgs, AxDBBase, type AxDBBaseArgs, type AxDBBaseOpOptions, AxDBCloudflare, type AxDBCloudflareArgs, type AxDBCloudflareOpOptions, type AxDBLoaderOptions, AxDBManager, type AxDBManagerArgs, type AxDBMatch, AxDBMemory, type AxDBMemoryArgs, type AxDBMemoryOpOptions, AxDBPinecone, type AxDBPineconeArgs, type AxDBPineconeOpOptions, type AxDBQueryRequest, type AxDBQueryResponse, type AxDBQueryService, type AxDBService, type AxDBState, type AxDBUpsertRequest, type AxDBUpsertResponse, AxDBWeaviate, type AxDBWeaviateArgs, type AxDBWeaviateOpOptions, type AxDataRow, AxDefaultCostTracker, AxDefaultResultReranker, type AxDockerContainer, AxDockerSession, type AxEmbedRequest, type AxEmbedResponse, AxEmbeddingAdapter, type AxErrorCategory, AxEvalUtil, type AxEvaluateArgs, type AxExample, type AxField, type AxFieldDescriptor, type AxFieldProcessor, type AxFieldProcessorProcess, type AxFieldTemplateFn, type AxFieldType, type AxFieldValue, AxFlow, type AxFlowAutoParallelConfig, type AxFlowBranchContext, AxFlowDependencyAnalyzer, type AxFlowDynamicContext, AxFlowExecutionPlanner, type AxFlowExecutionStep, type AxFlowNodeDefinition, type AxFlowParallelBranch, type AxFlowParallelGroup, type AxFlowState, type AxFlowStepFunction, type AxFlowSubContext, AxFlowSubContextImpl, type AxFlowTypedParallelBranch, type AxFlowTypedSubContext, AxFlowTypedSubContextImpl, type AxFlowable, type AxForwardable, type AxFunction, AxFunctionError, type AxFunctionHandler, type AxFunctionJSONSchema, AxFunctionProcessor, type AxFunctionResult, type AxFunctionResultFormatter, AxGen, type AxGenDeltaOut, type AxGenIn, type AxGenMetricsInstruments, type AxGenOut, type AxGenStreamingOut, AxGenerateError, type AxGenerateErrorDetails, type AxGenerateResult, AxHFDataLoader, type AxIField, type AxInputFunctionType, AxInstanceRegistry, type AxInternalChatRequest, type AxInternalEmbedRequest, AxLLMRequestTypeValues, type AxLoggerData, type AxLoggerFunction, AxMCPClient, type AxMCPFunctionDescription, AxMCPHTTPSSETransport, type AxMCPInitializeParams, type AxMCPInitializeResult, type AxMCPJSONRPCErrorResponse, type AxMCPJSONRPCNotification, type AxMCPJSONRPCRequest, type AxMCPJSONRPCResponse, type AxMCPJSONRPCSuccessResponse, type AxMCPStreamableHTTPTransportOptions, AxMCPStreambleHTTPTransport, type AxMCPToolsListResult, type AxMCPTransport, AxMemory, type AxMemoryData, type AxMessage, type AxMetricFn, type AxMetricFnArgs, type AxMetricsConfig, AxMiPRO, type AxMiPROCompileOptions, type AxMiPROOptimizerOptions, type AxMiPROResult, AxMockAIService, type AxMockAIServiceConfig, type AxModelConfig, type AxModelInfo, type AxModelInfoWithProvider, type AxModelUsage, type AxMultiMetricFn, AxMultiServiceRouter, type AxOptimizationCheckpoint, type AxOptimizationProgress, type AxOptimizationStats, type AxOptimizer, type AxOptimizerArgs, type AxOptimizerLoggerData, type AxOptimizerLoggerFunction, type AxOptimizerMetricsConfig, type AxOptimizerMetricsInstruments, type AxOptimizerResult, type AxParetoResult, AxProgram, type AxProgramDemos, type AxProgramExamples, type AxProgramForwardOptions, type AxProgramForwardOptionsWithModels, type AxProgramOptions, type AxProgramStreamingForwardOptions, type AxProgramStreamingForwardOptionsWithModels, type AxProgramTrace, type AxProgramUsage, type AxProgrammable, AxPromptTemplate, type AxPromptTemplateOptions, AxRAG, type AxRateLimiterFunction, AxRateLimiterTokenUsage, type AxRateLimiterTokenUsageOptions, type AxRerankerIn, type AxRerankerOut, type AxResponseHandlerArgs, type AxResultPickerFunction, type AxResultPickerFunctionFieldResults, type AxResultPickerFunctionFunctionResults, type AxRewriteIn, type AxRewriteOut, type AxSamplePickerOptions, type AxSetExamplesOptions, AxSignature, type AxSignatureConfig, type AxSignatureTemplateValue, AxSimpleClassifier, AxSimpleClassifierClass, type AxSimpleClassifierForwardOptions, AxSpanKindValues, type AxStreamingAssertion, type AxStreamingEvent, type AxStreamingFieldProcessorProcess, AxStringUtil, AxTestPrompt, type AxTokenUsage, type AxTunable, type AxUsable, ax, axAIAnthropicDefaultConfig, axAIAnthropicVertexDefaultConfig, axAIAzureOpenAIBestConfig, axAIAzureOpenAICreativeConfig, axAIAzureOpenAIDefaultConfig, axAIAzureOpenAIFastConfig, axAICohereCreativeConfig, axAICohereDefaultConfig, axAIDeepSeekCodeConfig, axAIDeepSeekDefaultConfig, axAIGoogleGeminiDefaultConfig, axAIGoogleGeminiDefaultCreativeConfig, axAIGrokBestConfig, axAIGrokDefaultConfig, axAIHuggingFaceCreativeConfig, axAIHuggingFaceDefaultConfig, axAIMistralBestConfig, axAIMistralDefaultConfig, axAIOllamaDefaultConfig, axAIOllamaDefaultCreativeConfig, axAIOpenAIBestConfig, axAIOpenAICreativeConfig, axAIOpenAIDefaultConfig, axAIOpenAIFastConfig, axAIOpenAIResponsesBestConfig, axAIOpenAIResponsesCreativeConfig, axAIOpenAIResponsesDefaultConfig, axAIRekaBestConfig, axAIRekaCreativeConfig, axAIRekaDefaultConfig, axAIRekaFastConfig, axAITogetherDefaultConfig, axAIWebLLMCreativeConfig, axAIWebLLMDefaultConfig, axBaseAIDefaultConfig, axBaseAIDefaultCreativeConfig, axCheckMetricsHealth, axCreateDefaultColorLogger, axCreateDefaultOptimizerColorLogger, axCreateDefaultOptimizerTextLogger, axCreateDefaultTextLogger, axDefaultMetricsConfig, axDefaultOptimizerLogger, axDefaultOptimizerMetricsConfig, axGetMetricsConfig, axGetOptimizerMetricsConfig, axGlobals, axModelInfoAnthropic, axModelInfoCohere, axModelInfoDeepSeek, axModelInfoGoogleGemini, axModelInfoGrok, axModelInfoGroq, axModelInfoHuggingFace, axModelInfoMistral, axModelInfoOpenAI, axModelInfoOpenAIResponses, axModelInfoReka, axModelInfoTogether, axModelInfoWebLLM, axSpanAttributes, axSpanEvents, axUpdateMetricsConfig, axUpdateOptimizerMetricsConfig, axValidateChatRequestMessage, axValidateChatResponseResult, f, s };
7516
+ export { AxAI, AxAIAnthropic, type AxAIAnthropicArgs, type AxAIAnthropicChatError, type AxAIAnthropicChatRequest, type AxAIAnthropicChatRequestCacheParam, type AxAIAnthropicChatResponse, type AxAIAnthropicChatResponseDelta, type AxAIAnthropicConfig, type AxAIAnthropicContentBlockDeltaEvent, type AxAIAnthropicContentBlockStartEvent, type AxAIAnthropicContentBlockStopEvent, type AxAIAnthropicErrorEvent, type AxAIAnthropicMessageDeltaEvent, type AxAIAnthropicMessageStartEvent, type AxAIAnthropicMessageStopEvent, AxAIAnthropicModel, type AxAIAnthropicPingEvent, type AxAIAnthropicThinkingConfig, type AxAIAnthropicThinkingTokenBudgetLevels, AxAIAnthropicVertexModel, type AxAIArgs, AxAIAzureOpenAI, type AxAIAzureOpenAIArgs, type AxAIAzureOpenAIConfig, AxAICohere, type AxAICohereArgs, type AxAICohereChatRequest, type AxAICohereChatRequestToolResults, type AxAICohereChatResponse, type AxAICohereChatResponseDelta, type AxAICohereChatResponseToolCalls, type AxAICohereConfig, AxAICohereEmbedModel, type AxAICohereEmbedRequest, type AxAICohereEmbedResponse, AxAICohereModel, AxAIDeepSeek, type AxAIDeepSeekArgs, AxAIDeepSeekModel, type AxAIEmbedModels, type AxAIFeatures, AxAIGoogleGemini, type AxAIGoogleGeminiArgs, type AxAIGoogleGeminiBatchEmbedRequest, type AxAIGoogleGeminiBatchEmbedResponse, type AxAIGoogleGeminiChatRequest, type AxAIGoogleGeminiChatResponse, type AxAIGoogleGeminiChatResponseDelta, type AxAIGoogleGeminiConfig, type AxAIGoogleGeminiContent, type AxAIGoogleGeminiContentPart, AxAIGoogleGeminiEmbedModel, AxAIGoogleGeminiEmbedTypes, type AxAIGoogleGeminiGenerationConfig, AxAIGoogleGeminiModel, type AxAIGoogleGeminiOptionsTools, AxAIGoogleGeminiSafetyCategory, type AxAIGoogleGeminiSafetySettings, AxAIGoogleGeminiSafetyThreshold, type AxAIGoogleGeminiThinkingConfig, type AxAIGoogleGeminiThinkingTokenBudgetLevels, type AxAIGoogleGeminiTool, type AxAIGoogleGeminiToolConfig, type AxAIGoogleGeminiToolFunctionDeclaration, type AxAIGoogleGeminiToolGoogleSearchRetrieval, type AxAIGoogleVertexBatchEmbedRequest, type AxAIGoogleVertexBatchEmbedResponse, AxAIGrok, type AxAIGrokArgs, type AxAIGrokChatRequest, AxAIGrokEmbedModels, AxAIGrokModel, type AxAIGrokOptionsTools, type AxAIGrokSearchSource, AxAIGroq, type AxAIGroqArgs, AxAIGroqModel, AxAIHuggingFace, type AxAIHuggingFaceArgs, type AxAIHuggingFaceConfig, AxAIHuggingFaceModel, type AxAIHuggingFaceRequest, type AxAIHuggingFaceResponse, type AxAIInputModelList, type AxAIMemory, type AxAIMetricsInstruments, AxAIMistral, type AxAIMistralArgs, type AxAIMistralChatRequest, AxAIMistralEmbedModels, AxAIMistralModel, type AxAIModelList, type AxAIModelListBase, type AxAIModels, AxAIOllama, type AxAIOllamaAIConfig, type AxAIOllamaArgs, AxAIOpenAI, type AxAIOpenAIAnnotation, type AxAIOpenAIArgs, AxAIOpenAIBase, type AxAIOpenAIBaseArgs, type AxAIOpenAIChatRequest, type AxAIOpenAIChatResponse, type AxAIOpenAIChatResponseDelta, type AxAIOpenAIConfig, AxAIOpenAIEmbedModel, type AxAIOpenAIEmbedRequest, type AxAIOpenAIEmbedResponse, type AxAIOpenAILogprob, AxAIOpenAIModel, type AxAIOpenAIResponseDelta, AxAIOpenAIResponses, type AxAIOpenAIResponsesArgs, AxAIOpenAIResponsesBase, type AxAIOpenAIResponsesCodeInterpreterToolCall, type AxAIOpenAIResponsesComputerToolCall, type AxAIOpenAIResponsesConfig, type AxAIOpenAIResponsesContentPartAddedEvent, type AxAIOpenAIResponsesContentPartDoneEvent, type AxAIOpenAIResponsesDefineFunctionTool, type AxAIOpenAIResponsesErrorEvent, type AxAIOpenAIResponsesFileSearchCallCompletedEvent, type AxAIOpenAIResponsesFileSearchCallInProgressEvent, type AxAIOpenAIResponsesFileSearchCallSearchingEvent, type AxAIOpenAIResponsesFileSearchToolCall, type AxAIOpenAIResponsesFunctionCallArgumentsDeltaEvent, type AxAIOpenAIResponsesFunctionCallArgumentsDoneEvent, type AxAIOpenAIResponsesFunctionCallItem, type AxAIOpenAIResponsesImageGenerationCallCompletedEvent, type AxAIOpenAIResponsesImageGenerationCallGeneratingEvent, type AxAIOpenAIResponsesImageGenerationCallInProgressEvent, type AxAIOpenAIResponsesImageGenerationCallPartialImageEvent, type AxAIOpenAIResponsesImageGenerationToolCall, AxAIOpenAIResponsesImpl, type AxAIOpenAIResponsesInputAudioContentPart, type AxAIOpenAIResponsesInputContentPart, type AxAIOpenAIResponsesInputFunctionCallItem, type AxAIOpenAIResponsesInputFunctionCallOutputItem, type AxAIOpenAIResponsesInputImageUrlContentPart, type AxAIOpenAIResponsesInputItem, type AxAIOpenAIResponsesInputMessageItem, type AxAIOpenAIResponsesInputTextContentPart, type AxAIOpenAIResponsesLocalShellToolCall, type AxAIOpenAIResponsesMCPCallArgumentsDeltaEvent, type AxAIOpenAIResponsesMCPCallArgumentsDoneEvent, type AxAIOpenAIResponsesMCPCallCompletedEvent, type AxAIOpenAIResponsesMCPCallFailedEvent, type AxAIOpenAIResponsesMCPCallInProgressEvent, type AxAIOpenAIResponsesMCPListToolsCompletedEvent, type AxAIOpenAIResponsesMCPListToolsFailedEvent, type AxAIOpenAIResponsesMCPListToolsInProgressEvent, type AxAIOpenAIResponsesMCPToolCall, AxAIOpenAIResponsesModel, type AxAIOpenAIResponsesOutputItem, type AxAIOpenAIResponsesOutputItemAddedEvent, type AxAIOpenAIResponsesOutputItemDoneEvent, type AxAIOpenAIResponsesOutputMessageItem, type AxAIOpenAIResponsesOutputRefusalContentPart, type AxAIOpenAIResponsesOutputTextAnnotationAddedEvent, type AxAIOpenAIResponsesOutputTextContentPart, type AxAIOpenAIResponsesOutputTextDeltaEvent, type AxAIOpenAIResponsesOutputTextDoneEvent, type AxAIOpenAIResponsesReasoningDeltaEvent, type AxAIOpenAIResponsesReasoningDoneEvent, type AxAIOpenAIResponsesReasoningItem, type AxAIOpenAIResponsesReasoningSummaryDeltaEvent, type AxAIOpenAIResponsesReasoningSummaryDoneEvent, type AxAIOpenAIResponsesReasoningSummaryPart, type AxAIOpenAIResponsesReasoningSummaryPartAddedEvent, type AxAIOpenAIResponsesReasoningSummaryPartDoneEvent, type AxAIOpenAIResponsesReasoningSummaryTextDeltaEvent, type AxAIOpenAIResponsesReasoningSummaryTextDoneEvent, type AxAIOpenAIResponsesRefusalDeltaEvent, type AxAIOpenAIResponsesRefusalDoneEvent, type AxAIOpenAIResponsesRequest, type AxAIOpenAIResponsesResponse, type AxAIOpenAIResponsesResponseCompletedEvent, type AxAIOpenAIResponsesResponseCreatedEvent, type AxAIOpenAIResponsesResponseDelta, type AxAIOpenAIResponsesResponseFailedEvent, type AxAIOpenAIResponsesResponseInProgressEvent, type AxAIOpenAIResponsesResponseIncompleteEvent, type AxAIOpenAIResponsesResponseQueuedEvent, type AxAIOpenAIResponsesStreamEvent, type AxAIOpenAIResponsesStreamEventBase, type AxAIOpenAIResponsesToolCall, type AxAIOpenAIResponsesToolCallBase, type AxAIOpenAIResponsesToolChoice, type AxAIOpenAIResponsesToolDefinition, type AxAIOpenAIResponsesWebSearchCallCompletedEvent, type AxAIOpenAIResponsesWebSearchCallInProgressEvent, type AxAIOpenAIResponsesWebSearchCallSearchingEvent, type AxAIOpenAIResponsesWebSearchToolCall, type AxAIOpenAIUrlCitation, type AxAIOpenAIUsage, AxAIRefusalError, AxAIReka, type AxAIRekaArgs, type AxAIRekaChatRequest, type AxAIRekaChatResponse, type AxAIRekaChatResponseDelta, type AxAIRekaConfig, AxAIRekaModel, type AxAIRekaUsage, type AxAIService, AxAIServiceAbortedError, type AxAIServiceActionOptions, AxAIServiceAuthenticationError, AxAIServiceError, type AxAIServiceImpl, type AxAIServiceMetrics, type AxAIServiceModelType, AxAIServiceNetworkError, type AxAIServiceOptions, AxAIServiceResponseError, AxAIServiceStatusError, AxAIServiceStreamTerminatedError, AxAIServiceTimeoutError, AxAITogether, type AxAITogetherArgs, AxAIWebLLM, type AxAIWebLLMArgs, type AxAIWebLLMChatRequest, type AxAIWebLLMChatResponse, type AxAIWebLLMChatResponseDelta, type AxAIWebLLMConfig, type AxAIWebLLMEmbedModel, type AxAIWebLLMEmbedRequest, type AxAIWebLLMEmbedResponse, AxAIWebLLMModel, type AxAPI, type AxAPIConfig, AxAgent, type AxAgentConfig, type AxAgentFeatures, type AxAgentOptions, type AxAgentic, AxApacheTika, type AxApacheTikaArgs, type AxApacheTikaConvertOptions, type AxAssertion, AxAssertionError, AxBalancer, type AxBalancerOptions, AxBaseAI, type AxBaseAIArgs, AxBaseOptimizer, type AxBootstrapCompileOptions, AxBootstrapFewShot, type AxBootstrapOptimizerOptions, type AxChatRequest, type AxChatResponse, type AxChatResponseFunctionCall, type AxChatResponseResult, type AxCheckpointLoadFn, type AxCheckpointSaveFn, type AxCompileOptions, AxContentProcessingError, type AxContentProcessingServices, type AxCostTracker, type AxCostTrackerOptions, AxDB, type AxDBArgs, AxDBBase, type AxDBBaseArgs, type AxDBBaseOpOptions, AxDBCloudflare, type AxDBCloudflareArgs, type AxDBCloudflareOpOptions, type AxDBLoaderOptions, AxDBManager, type AxDBManagerArgs, type AxDBMatch, AxDBMemory, type AxDBMemoryArgs, type AxDBMemoryOpOptions, AxDBPinecone, type AxDBPineconeArgs, type AxDBPineconeOpOptions, type AxDBQueryRequest, type AxDBQueryResponse, type AxDBQueryService, type AxDBService, type AxDBState, type AxDBUpsertRequest, type AxDBUpsertResponse, AxDBWeaviate, type AxDBWeaviateArgs, type AxDBWeaviateOpOptions, type AxDataRow, AxDefaultCostTracker, AxDefaultResultReranker, type AxDockerContainer, AxDockerSession, type AxEmbedRequest, type AxEmbedResponse, AxEmbeddingAdapter, type AxErrorCategory, AxEvalUtil, type AxEvaluateArgs, type AxExample, type AxField, type AxFieldProcessor, type AxFieldProcessorProcess, type AxFieldTemplateFn, type AxFieldType, type AxFieldValue, AxFlow, type AxFlowAutoParallelConfig, type AxFlowBranchContext, type AxFlowBranchEvaluationData, type AxFlowCompleteData, AxFlowDependencyAnalyzer, type AxFlowDynamicContext, type AxFlowErrorData, AxFlowExecutionPlanner, type AxFlowExecutionStep, type AxFlowLogData, type AxFlowLoggerData, type AxFlowLoggerFunction, type AxFlowNodeDefinition, type AxFlowParallelBranch, type AxFlowParallelGroup, type AxFlowParallelGroupCompleteData, type AxFlowParallelGroupStartData, type AxFlowStartData, type AxFlowState, type AxFlowStepCompleteData, type AxFlowStepFunction, type AxFlowStepStartData, type AxFlowSubContext, AxFlowSubContextImpl, type AxFlowTypedParallelBranch, type AxFlowTypedSubContext, AxFlowTypedSubContextImpl, type AxFlowable, type AxFluentFieldInfo, AxFluentFieldType, type AxForwardable, type AxFunction, AxFunctionError, type AxFunctionHandler, type AxFunctionJSONSchema, AxFunctionProcessor, type AxFunctionResult, type AxFunctionResultFormatter, AxGen, type AxGenDeltaOut, type AxGenIn, type AxGenMetricsInstruments, type AxGenOut, type AxGenStreamingOut, AxGenerateError, type AxGenerateErrorDetails, type AxGenerateResult, AxHFDataLoader, type AxIField, type AxInputFunctionType, AxInstanceRegistry, type AxInternalChatRequest, type AxInternalEmbedRequest, AxLLMRequestTypeValues, type AxLoggerData, type AxLoggerFunction, AxMCPClient, type AxMCPFunctionDescription, AxMCPHTTPSSETransport, type AxMCPInitializeParams, type AxMCPInitializeResult, type AxMCPJSONRPCErrorResponse, type AxMCPJSONRPCNotification, type AxMCPJSONRPCRequest, type AxMCPJSONRPCResponse, type AxMCPJSONRPCSuccessResponse, type AxMCPStreamableHTTPTransportOptions, AxMCPStreambleHTTPTransport, type AxMCPToolsListResult, type AxMCPTransport, AxMediaNotSupportedError, AxMemory, type AxMemoryData, type AxMessage, type AxMetricFn, type AxMetricFnArgs, type AxMetricsConfig, AxMiPRO, type AxMiPROCompileOptions, type AxMiPROOptimizerOptions, type AxMiPROResult, AxMockAIService, type AxMockAIServiceConfig, type AxModelConfig, type AxModelInfo, type AxModelInfoWithProvider, type AxModelUsage, type AxMultiMetricFn, type AxMultiProviderConfig, AxMultiServiceRouter, type AxOptimizationCheckpoint, type AxOptimizationProgress, type AxOptimizationStats, type AxOptimizer, type AxOptimizerArgs, type AxOptimizerLoggerData, type AxOptimizerLoggerFunction, type AxOptimizerMetricsConfig, type AxOptimizerMetricsInstruments, type AxOptimizerResult, type AxParetoResult, AxProgram, type AxProgramDemos, type AxProgramExamples, type AxProgramForwardOptions, type AxProgramForwardOptionsWithModels, type AxProgramOptions, type AxProgramStreamingForwardOptions, type AxProgramStreamingForwardOptionsWithModels, type AxProgramTrace, type AxProgramUsage, type AxProgrammable, AxPromptTemplate, type AxPromptTemplateOptions, AxProviderRouter, type AxRateLimiterFunction, AxRateLimiterTokenUsage, type AxRateLimiterTokenUsageOptions, type AxRerankerIn, type AxRerankerOut, type AxResponseHandlerArgs, type AxResultPickerFunction, type AxResultPickerFunctionFieldResults, type AxResultPickerFunctionFunctionResults, type AxRewriteIn, type AxRewriteOut, type AxRoutingResult, type AxSamplePickerOptions, type AxSetExamplesOptions, AxSignature, AxSignatureBuilder, type AxSignatureConfig, AxSimpleClassifier, AxSimpleClassifierClass, type AxSimpleClassifierForwardOptions, AxSpanKindValues, type AxStreamingAssertion, type AxStreamingEvent, type AxStreamingFieldProcessorProcess, AxStringUtil, AxTestPrompt, type AxTokenUsage, type AxTunable, type AxUsable, agent, ai, ax, axAIAnthropicDefaultConfig, axAIAnthropicVertexDefaultConfig, axAIAzureOpenAIBestConfig, axAIAzureOpenAICreativeConfig, axAIAzureOpenAIDefaultConfig, axAIAzureOpenAIFastConfig, axAICohereCreativeConfig, axAICohereDefaultConfig, axAIDeepSeekCodeConfig, axAIDeepSeekDefaultConfig, axAIGoogleGeminiDefaultConfig, axAIGoogleGeminiDefaultCreativeConfig, axAIGrokBestConfig, axAIGrokDefaultConfig, axAIHuggingFaceCreativeConfig, axAIHuggingFaceDefaultConfig, axAIMistralBestConfig, axAIMistralDefaultConfig, axAIOllamaDefaultConfig, axAIOllamaDefaultCreativeConfig, axAIOpenAIBestConfig, axAIOpenAICreativeConfig, axAIOpenAIDefaultConfig, axAIOpenAIFastConfig, axAIOpenAIResponsesBestConfig, axAIOpenAIResponsesCreativeConfig, axAIOpenAIResponsesDefaultConfig, axAIRekaBestConfig, axAIRekaCreativeConfig, axAIRekaDefaultConfig, axAIRekaFastConfig, axAITogetherDefaultConfig, axAIWebLLMCreativeConfig, axAIWebLLMDefaultConfig, axAnalyzeChatPromptRequirements, axAnalyzeRequestRequirements, axBaseAIDefaultConfig, axBaseAIDefaultCreativeConfig, axCheckMetricsHealth, axCreateDefaultColorLogger, axCreateDefaultOptimizerColorLogger, axCreateDefaultOptimizerTextLogger, axCreateDefaultTextLogger, axCreateFlowColorLogger, axCreateFlowTextLogger, axDefaultFlowLogger, axDefaultMetricsConfig, axDefaultOptimizerLogger, axDefaultOptimizerMetricsConfig, axGetCompatibilityReport, axGetFormatCompatibility, axGetMetricsConfig, axGetOptimizerMetricsConfig, axGetProvidersWithMediaSupport, axGlobals, axModelInfoAnthropic, axModelInfoCohere, axModelInfoDeepSeek, axModelInfoGoogleGemini, axModelInfoGrok, axModelInfoGroq, axModelInfoHuggingFace, axModelInfoMistral, axModelInfoOpenAI, axModelInfoOpenAIResponses, axModelInfoReka, axModelInfoTogether, axModelInfoWebLLM, axProcessContentForProvider, axRAG, axScoreProvidersForRequest, axSelectOptimalProvider, axSpanAttributes, axSpanEvents, axUpdateMetricsConfig, axUpdateOptimizerMetricsConfig, axValidateChatRequestMessage, axValidateChatResponseResult, axValidateProviderCapabilities, f, flow, s };