@ax-llm/ax 13.0.6 → 13.0.8

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.cts CHANGED
@@ -285,10 +285,64 @@ type AxInternalEmbedRequest<TEmbedModel> = Omit<AxEmbedRequest, 'embedModel'> &
285
285
  type AxRateLimiterFunction = <T = unknown>(reqFunc: () => Promise<T | ReadableStream<T>>, info: Readonly<{
286
286
  modelUsage?: AxModelUsage;
287
287
  }>) => Promise<T | ReadableStream<T>>;
288
- type AxLoggerTag = 'error' | 'warning' | 'functionName' | 'functionArg' | 'functionResult' | 'functionError' | 'firstFunction' | 'multipleFunctions' | 'responseContent' | 'responseDelta' | 'responseEnd' | 'requestStart' | 'requestContent' | 'systemContent' | 'userStart' | 'userContent' | 'assistantStart' | 'assistantContent' | 'assistantEnd' | 'discovery' | 'optimizer' | 'start' | 'end' | 'config' | 'phase' | 'progress' | 'result' | 'complete' | 'checkpoint';
289
- type AxLoggerFunction = (message: string, options?: {
290
- tags?: AxLoggerTag[];
291
- }) => void;
288
+ type AxLoggerData = {
289
+ name: 'ChatRequestChatPrompt';
290
+ step: number;
291
+ value: AxChatRequest['chatPrompt'];
292
+ } | {
293
+ name: 'FunctionResults';
294
+ value: AxFunctionResult[];
295
+ } | {
296
+ name: 'ChatResponseResults';
297
+ value: AxChatResponseResult[];
298
+ } | {
299
+ name: 'ChatResponseStreamingResult';
300
+ index: number;
301
+ value: AxChatResponseResult & {
302
+ delta?: string;
303
+ };
304
+ } | {
305
+ name: 'FunctionError';
306
+ index: number;
307
+ fixingInstructions: string;
308
+ error: unknown;
309
+ } | {
310
+ name: 'ValidationError';
311
+ index: number;
312
+ fixingInstructions: string;
313
+ error: unknown;
314
+ } | {
315
+ name: 'AssertionError';
316
+ index: number;
317
+ fixingInstructions: string;
318
+ error: unknown;
319
+ } | {
320
+ name: 'RefusalError';
321
+ index: number;
322
+ error: unknown;
323
+ } | {
324
+ name: 'ResultPickerUsed';
325
+ sampleCount: number;
326
+ selectedIndex: number;
327
+ latency: number;
328
+ } | {
329
+ name: 'Notification';
330
+ id: string;
331
+ value: string;
332
+ } | {
333
+ name: 'EmbedRequest';
334
+ embedModel: string;
335
+ value: readonly string[];
336
+ } | {
337
+ name: 'EmbedResponse';
338
+ totalEmbeddings: number;
339
+ value: {
340
+ length: number;
341
+ sample: number[];
342
+ truncated: boolean;
343
+ }[];
344
+ };
345
+ type AxLoggerFunction = (message: AxLoggerData) => void;
292
346
  type AxAIPromptConfig = {
293
347
  stream?: boolean;
294
348
  thinkingTokenBudget?: 'minimal' | 'low' | 'medium' | 'high' | 'highest' | 'none';
@@ -309,7 +363,7 @@ type AxAIServiceOptions = {
309
363
  type AxAIServiceActionOptions<TModel = unknown, TEmbedModel = unknown> = {
310
364
  ai?: Readonly<AxAIService<TModel, TEmbedModel>>;
311
365
  sessionId?: string;
312
- traceId?: string;
366
+ traceId?: string | undefined;
313
367
  timeout?: number;
314
368
  rateLimiter?: AxRateLimiterFunction;
315
369
  debug?: boolean;
@@ -317,6 +371,7 @@ type AxAIServiceActionOptions<TModel = unknown, TEmbedModel = unknown> = {
317
371
  traceContext?: Context;
318
372
  abortSignal?: AbortSignal;
319
373
  logger?: AxLoggerFunction;
374
+ stepIndex?: number;
320
375
  functionResultFormatter?: (result: unknown) => string;
321
376
  };
322
377
  interface AxAIService<TModel = unknown, TEmbedModel = unknown> {
@@ -2686,62 +2741,10 @@ declare class AxSignature {
2686
2741
  };
2687
2742
  }
2688
2743
 
2689
- type AxFieldValue = string | string[] | number | boolean | object | null | undefined | {
2690
- mimeType: string;
2691
- data: string;
2692
- } | {
2693
- mimeType: string;
2694
- data: string;
2695
- }[] | {
2696
- format?: 'wav';
2697
- data: string;
2698
- } | {
2699
- format?: 'wav';
2700
- data: string;
2701
- }[];
2702
- type AxGenIn = {
2703
- [key: string]: AxFieldValue;
2704
- };
2705
- type AxGenOut = {
2706
- [key: string]: AxFieldValue;
2707
- };
2708
- type AxMessage<IN extends AxGenIn> = {
2709
- role: 'user';
2710
- values: IN;
2711
- } | {
2712
- role: 'assistant';
2713
- values: IN;
2714
- };
2715
-
2716
- interface AxAssertion {
2717
- fn(values: Record<string, unknown>): Promise<boolean | undefined> | boolean | undefined;
2718
- message?: string;
2719
- }
2720
- interface AxStreamingAssertion {
2721
- fieldName: string;
2722
- fn(content: string, done?: boolean): boolean | undefined;
2723
- message?: string;
2724
- }
2725
- declare class AxAssertionError extends Error {
2726
- constructor({ message, }: Readonly<{
2727
- message: string;
2728
- }>);
2729
- getFixingInstructions: () => {
2730
- name: string;
2731
- title: string;
2732
- description: string;
2733
- }[];
2734
- toString(): string;
2735
- }
2736
-
2737
2744
  declare class AxMemory implements AxAIMemory {
2738
- private options?;
2739
2745
  private memories;
2740
2746
  private defaultMemory;
2741
- constructor(options?: {
2742
- debug?: boolean;
2743
- debugHideSystemPrompt?: boolean;
2744
- } | undefined);
2747
+ constructor();
2745
2748
  private getMemory;
2746
2749
  addRequest(value: AxChatRequest['chatPrompt'], sessionId?: string): void;
2747
2750
  addResponse(results: Readonly<AxChatResponseResult[]>, sessionId?: string): void;
@@ -2884,6 +2887,32 @@ declare class AxPromptTemplate {
2884
2887
  private defaultRenderInField;
2885
2888
  }
2886
2889
 
2890
+ type AxFieldValue = string | string[] | number | boolean | object | null | undefined | {
2891
+ mimeType: string;
2892
+ data: string;
2893
+ } | {
2894
+ mimeType: string;
2895
+ data: string;
2896
+ }[] | {
2897
+ format?: 'wav';
2898
+ data: string;
2899
+ } | {
2900
+ format?: 'wav';
2901
+ data: string;
2902
+ }[];
2903
+ type AxGenIn = {
2904
+ [key: string]: AxFieldValue;
2905
+ };
2906
+ type AxGenOut = {
2907
+ [key: string]: AxFieldValue;
2908
+ };
2909
+ type AxMessage<IN extends AxGenIn> = {
2910
+ role: 'user';
2911
+ values: IN;
2912
+ } | {
2913
+ role: 'assistant';
2914
+ values: IN;
2915
+ };
2887
2916
  type AxProgramTrace<IN extends AxGenIn, OUT extends AxGenOut> = {
2888
2917
  trace: OUT & IN;
2889
2918
  programId: string;
@@ -2932,7 +2961,6 @@ type AxProgramForwardOptions = {
2932
2961
  functionResultFormatter?: (result: unknown) => string;
2933
2962
  fastFail?: boolean;
2934
2963
  debug?: boolean;
2935
- debugHideSystemPrompt?: boolean;
2936
2964
  thinkingTokenBudget?: 'minimal' | 'low' | 'medium' | 'high' | 'highest' | 'none';
2937
2965
  showThoughts?: boolean;
2938
2966
  traceLabel?: string;
@@ -2954,6 +2982,10 @@ type AxGenDeltaOut<OUT extends AxGenOut> = {
2954
2982
  };
2955
2983
  type AxGenStreamingOut<OUT extends AxGenOut> = AsyncGenerator<AxGenDeltaOut<OUT>, void, unknown>;
2956
2984
  type AxSetExamplesOptions = {};
2985
+ interface AxForwardable<IN extends AxGenIn, OUT extends AxGenOut> {
2986
+ forward(ai: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramForwardOptions>): Promise<OUT>;
2987
+ streamingForward(ai: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramStreamingForwardOptions>): AxGenStreamingOut<OUT>;
2988
+ }
2957
2989
  interface AxTunable<IN extends AxGenIn, OUT extends AxGenOut> {
2958
2990
  setExamples: (examples: Readonly<AxProgramExamples<IN, OUT>>, options?: Readonly<AxSetExamplesOptions>) => void;
2959
2991
  setId: (id: string) => void;
@@ -2965,6 +2997,9 @@ interface AxUsable {
2965
2997
  getUsage: () => AxProgramUsage[];
2966
2998
  resetUsage: () => void;
2967
2999
  }
3000
+ interface AxProgrammable<IN extends AxGenIn, OUT extends AxGenOut> extends AxForwardable<IN, OUT>, AxTunable<IN, OUT>, AxUsable {
3001
+ getSignature: () => AxSignature;
3002
+ }
2968
3003
  type AxProgramUsage = AxChatResponse['modelUsage'] & {
2969
3004
  ai: string;
2970
3005
  model: string;
@@ -2973,77 +3008,26 @@ interface AxProgramOptions {
2973
3008
  description?: string;
2974
3009
  traceLabel?: string;
2975
3010
  }
2976
- declare class AxProgram<IN extends AxGenIn, OUT extends AxGenOut> implements AxTunable<IN, OUT>, AxUsable {
2977
- protected signature: AxSignature;
2978
- protected sigHash: string;
2979
- protected examples?: OUT[];
2980
- protected examplesOptions?: AxSetExamplesOptions;
2981
- protected demos?: OUT[];
2982
- protected trace?: OUT;
2983
- protected usage: AxProgramUsage[];
2984
- protected traceLabel?: string;
2985
- private key;
2986
- private children;
2987
- constructor(signature: NonNullable<ConstructorParameters<typeof AxSignature>[0]>, options?: Readonly<AxProgramOptions>);
2988
- getSignature(): AxSignature;
2989
- register(prog: Readonly<AxTunable<IN, OUT> & AxUsable>): void;
2990
- forward(_ai: Readonly<AxAIService>, _values: IN | AxMessage<IN>[], _options?: Readonly<AxProgramForwardOptions>): Promise<OUT>;
2991
- streamingForward(_ai: Readonly<AxAIService>, _values: IN | AxMessage<IN>[], _options?: Readonly<AxProgramStreamingForwardOptions>): AxGenStreamingOut<OUT>;
2992
- setId(id: string): void;
2993
- setParentId(parentId: string): void;
2994
- setExamples(examples: Readonly<AxProgramExamples<IN, OUT>>, options?: Readonly<AxSetExamplesOptions>): void;
2995
- private _setExamples;
2996
- getTraces(): AxProgramTrace<IN, OUT>[];
2997
- getUsage(): AxProgramUsage[];
2998
- resetUsage(): void;
2999
- setDemos(demos: readonly AxProgramDemos<IN, OUT>[]): void;
3000
- }
3001
3011
 
3002
- type AxRewriteIn = {
3003
- query: string;
3004
- };
3005
- type AxRewriteOut = {
3006
- rewrittenQuery: string;
3007
- };
3008
- type AxRerankerIn = {
3009
- query: string;
3010
- items: string[];
3011
- };
3012
- type AxRerankerOut = {
3013
- rankedItems: string[];
3014
- };
3015
- interface AxDBLoaderOptions {
3016
- chunker?: (text: string) => string[];
3017
- rewriter?: AxProgram<AxRewriteIn, AxRewriteOut>;
3018
- reranker?: AxProgram<AxRerankerIn, AxRerankerOut>;
3019
- }
3020
- interface AxDBManagerArgs {
3021
- ai: AxAIService;
3022
- db: AxDBService;
3023
- config?: AxDBLoaderOptions;
3012
+ interface AxAssertion {
3013
+ fn(values: Record<string, unknown>): Promise<boolean | undefined> | boolean | undefined;
3014
+ message?: string;
3024
3015
  }
3025
- interface AxDBMatch {
3026
- score: number;
3027
- text: string;
3016
+ interface AxStreamingAssertion {
3017
+ fieldName: string;
3018
+ fn(content: string, done?: boolean): boolean | undefined;
3019
+ message?: string;
3028
3020
  }
3029
- declare class AxDBManager {
3030
- private ai;
3031
- private db;
3032
- private chunker;
3033
- private rewriter?;
3034
- private reranker?;
3035
- constructor({ ai, db, config }: Readonly<AxDBManagerArgs>);
3036
- private defaultChunker;
3037
- insert: (text: Readonly<string | string[]>, options?: Readonly<{
3038
- batchSize?: number;
3039
- maxWordsPerChunk?: number;
3040
- minWordsPerChunk?: number;
3041
- abortSignal?: AbortSignal;
3042
- }>) => Promise<void>;
3043
- query: (query: Readonly<string | string[] | number | number[]>, { topPercent, abortSignal, }?: Readonly<{
3044
- topPercent?: number;
3045
- abortSignal?: AbortSignal;
3046
- }> | undefined) => Promise<AxDBMatch[][]>;
3021
+ declare class AxAssertionError extends Error {
3022
+ constructor({ message, }: Readonly<{
3023
+ message: string;
3024
+ }>);
3025
+ getFixingInstructions: () => {
3026
+ name: string;
3027
+ title: string;
3028
+ description: string;
3029
+ }[];
3030
+ toString(): string;
3047
3031
  }
3048
3032
 
3049
3033
  type AxFieldProcessorProcess = (value: AxFieldValue, context?: Readonly<{
@@ -3067,6 +3051,33 @@ interface AxFieldProcessor {
3067
3051
  process: AxFieldProcessorProcess | AxStreamingFieldProcessorProcess;
3068
3052
  }
3069
3053
 
3054
+ declare class AxProgram<IN extends AxGenIn, OUT extends AxGenOut> implements AxUsable {
3055
+ protected signature: AxSignature;
3056
+ protected sigHash: string;
3057
+ protected examples?: OUT[];
3058
+ protected examplesOptions?: AxSetExamplesOptions;
3059
+ protected demos?: OUT[];
3060
+ protected trace?: OUT;
3061
+ protected usage: AxProgramUsage[];
3062
+ protected traceLabel?: string;
3063
+ private key;
3064
+ private children;
3065
+ constructor(signature: ConstructorParameters<typeof AxSignature>[0], options?: Readonly<AxProgramOptions>);
3066
+ getSignature(): AxSignature;
3067
+ setSignature(signature: ConstructorParameters<typeof AxSignature>[0]): void;
3068
+ setDescription(description: string): void;
3069
+ private updateSignatureHash;
3070
+ register(prog: Readonly<AxTunable<IN, OUT> & AxUsable>): void;
3071
+ setId(id: string): void;
3072
+ setParentId(parentId: string): void;
3073
+ setExamples(examples: Readonly<AxProgramExamples<IN, OUT>>, options?: Readonly<AxSetExamplesOptions>): void;
3074
+ private _setExamples;
3075
+ getTraces(): AxProgramTrace<IN, OUT>[];
3076
+ getUsage(): AxProgramUsage[];
3077
+ resetUsage(): void;
3078
+ setDemos(demos: readonly AxProgramDemos<IN, OUT>[]): void;
3079
+ }
3080
+
3070
3081
  type AxGenerateResult<OUT extends AxGenOut> = OUT & {
3071
3082
  thought?: string;
3072
3083
  };
@@ -3090,7 +3101,7 @@ interface AxStreamingEvent<T> {
3090
3101
  functions?: AxChatResponseFunctionCall[];
3091
3102
  };
3092
3103
  }
3093
- declare class AxGen<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGenOut> extends AxProgram<IN, OUT> {
3104
+ declare class AxGen<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGenOut> extends AxProgram<IN, OUT> implements AxProgrammable<IN, OUT> {
3094
3105
  private promptTemplate;
3095
3106
  private asserts;
3096
3107
  private streamingAsserts;
@@ -3138,6 +3149,53 @@ declare class AxGenerateError extends Error {
3138
3149
  constructor(message: string, details: Readonly<AxGenerateErrorDetails>, options?: ErrorOptions);
3139
3150
  }
3140
3151
 
3152
+ type AxRewriteIn = {
3153
+ query: string;
3154
+ };
3155
+ type AxRewriteOut = {
3156
+ rewrittenQuery: string;
3157
+ };
3158
+ type AxRerankerIn = {
3159
+ query: string;
3160
+ items: string[];
3161
+ };
3162
+ type AxRerankerOut = {
3163
+ rankedItems: string[];
3164
+ };
3165
+ interface AxDBLoaderOptions {
3166
+ chunker?: (text: string) => string[];
3167
+ rewriter?: AxGen<AxRewriteIn, AxRewriteOut>;
3168
+ reranker?: AxGen<AxRerankerIn, AxRerankerOut>;
3169
+ }
3170
+ interface AxDBManagerArgs {
3171
+ ai: AxAIService;
3172
+ db: AxDBService;
3173
+ config?: AxDBLoaderOptions;
3174
+ }
3175
+ interface AxDBMatch {
3176
+ score: number;
3177
+ text: string;
3178
+ }
3179
+ declare class AxDBManager {
3180
+ private ai;
3181
+ private db;
3182
+ private chunker;
3183
+ private rewriter?;
3184
+ private reranker?;
3185
+ constructor({ ai, db, config }: Readonly<AxDBManagerArgs>);
3186
+ private defaultChunker;
3187
+ insert: (text: Readonly<string | string[]>, options?: Readonly<{
3188
+ batchSize?: number;
3189
+ maxWordsPerChunk?: number;
3190
+ minWordsPerChunk?: number;
3191
+ abortSignal?: AbortSignal;
3192
+ }>) => Promise<void>;
3193
+ query: (query: Readonly<string | string[] | number | number[]>, { topPercent, abortSignal, }?: Readonly<{
3194
+ topPercent?: number;
3195
+ abortSignal?: AbortSignal;
3196
+ }> | undefined) => Promise<AxDBMatch[][]>;
3197
+ }
3198
+
3141
3199
  declare class AxDefaultResultReranker extends AxGen<AxRerankerIn, AxRerankerOut> {
3142
3200
  constructor(options?: Readonly<AxProgramForwardOptions>);
3143
3201
  forward: (ai: Readonly<AxAIService>, input: Readonly<AxRerankerIn>, options?: Readonly<AxProgramForwardOptions>) => Promise<AxRerankerOut>;
@@ -3231,8 +3289,61 @@ declare const AxEvalUtil: {
3231
3289
  novelF1ScoreOptimized: typeof novelF1ScoreOptimized;
3232
3290
  };
3233
3291
 
3234
- type AxExample = Record<string, AxFieldValue>;
3235
- type AxMetricFn = <T extends AxGenOut = AxGenOut>(arg0: Readonly<{
3292
+ type AxOptimizerLoggerData = {
3293
+ name: 'OptimizationStart';
3294
+ value: {
3295
+ optimizerType: string;
3296
+ config: Record<string, unknown>;
3297
+ exampleCount: number;
3298
+ validationCount: number;
3299
+ };
3300
+ } | {
3301
+ name: 'RoundProgress';
3302
+ value: {
3303
+ round: number;
3304
+ totalRounds: number;
3305
+ currentScore: number;
3306
+ bestScore: number;
3307
+ configuration: Record<string, unknown>;
3308
+ };
3309
+ } | {
3310
+ name: 'EarlyStopping';
3311
+ value: {
3312
+ reason: string;
3313
+ finalScore: number;
3314
+ round: number;
3315
+ };
3316
+ } | {
3317
+ name: 'OptimizationComplete';
3318
+ value: {
3319
+ bestScore: number;
3320
+ bestConfiguration: Record<string, unknown>;
3321
+ stats: AxOptimizationStats;
3322
+ };
3323
+ } | {
3324
+ name: 'ConfigurationProposal';
3325
+ value: {
3326
+ type: 'instructions' | 'demos' | 'general';
3327
+ proposals: string[] | Record<string, unknown>[];
3328
+ count: number;
3329
+ };
3330
+ } | {
3331
+ name: 'BootstrappedDemos';
3332
+ value: {
3333
+ count: number;
3334
+ demos: unknown[];
3335
+ };
3336
+ } | {
3337
+ name: 'BestConfigFound';
3338
+ value: {
3339
+ config: Record<string, unknown>;
3340
+ score: number;
3341
+ };
3342
+ };
3343
+ type AxOptimizerLoggerFunction = (data: AxOptimizerLoggerData) => void;
3344
+
3345
+ type AxExample = Record<string, AxFieldValue>;
3346
+ type AxMetricFn = <T extends AxGenOut = AxGenOut>(arg0: Readonly<{
3236
3347
  prediction: T;
3237
3348
  example: AxExample;
3238
3349
  }>) => number | Promise<number>;
@@ -3251,6 +3362,7 @@ interface AxOptimizationProgress {
3251
3362
  successfulExamples: number;
3252
3363
  totalExamples: number;
3253
3364
  currentConfiguration?: Record<string, unknown>;
3365
+ bestConfiguration?: Record<string, unknown>;
3254
3366
  convergenceInfo?: {
3255
3367
  improvement: number;
3256
3368
  stagnationRounds: number;
@@ -3305,6 +3417,8 @@ type AxOptimizerArgs = {
3305
3417
  logger?: AxLoggerFunction;
3306
3418
  verbose?: boolean;
3307
3419
  seed?: number;
3420
+ debugOptimizer?: boolean;
3421
+ optimizerLogger?: AxOptimizerLoggerFunction;
3308
3422
  };
3309
3423
  interface AxOptimizationStats {
3310
3424
  totalCalls: number;
@@ -3316,6 +3430,8 @@ interface AxOptimizationStats {
3316
3430
  patienceExhausted: boolean;
3317
3431
  reason: string;
3318
3432
  };
3433
+ bestScore: number;
3434
+ bestConfiguration?: Record<string, unknown>;
3319
3435
  resourceUsage: {
3320
3436
  totalTokens: number;
3321
3437
  totalTime: number;
@@ -3422,7 +3538,7 @@ interface AxOptimizer<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGen
3422
3538
  * @param options Optional configuration options that can override constructor settings
3423
3539
  * @returns Optimization result containing demos, stats, and configuration
3424
3540
  */
3425
- compile(program: Readonly<AxProgram<IN, OUT>>, metricFn: AxMetricFn, options?: AxCompileOptions): Promise<AxOptimizerResult<OUT>>;
3541
+ compile(program: Readonly<AxGen<IN, OUT>>, metricFn: AxMetricFn, options?: AxCompileOptions): Promise<AxOptimizerResult<OUT>>;
3426
3542
  /**
3427
3543
  * Optimize a program with real-time streaming updates
3428
3544
  * @param program The program to optimize
@@ -3430,7 +3546,7 @@ interface AxOptimizer<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGen
3430
3546
  * @param options Optional configuration options
3431
3547
  * @returns Async iterator yielding optimization progress
3432
3548
  */
3433
- compileStream?(program: Readonly<AxProgram<IN, OUT>>, metricFn: AxMetricFn, options?: AxCompileOptions): AsyncIterableIterator<AxOptimizationProgress>;
3549
+ compileStream?(program: Readonly<AxGen<IN, OUT>>, metricFn: AxMetricFn, options?: AxCompileOptions): AsyncIterableIterator<AxOptimizationProgress>;
3434
3550
  /**
3435
3551
  * Multi-objective optimization using Pareto frontier
3436
3552
  * @param program The program to optimize
@@ -3438,7 +3554,7 @@ interface AxOptimizer<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGen
3438
3554
  * @param options Optional configuration options
3439
3555
  * @returns Pareto optimization result
3440
3556
  */
3441
- compilePareto?(program: Readonly<AxProgram<IN, OUT>>, metricFn: AxMultiMetricFn, options?: AxCompileOptions): Promise<AxParetoResult<OUT>>;
3557
+ compilePareto?(program: Readonly<AxGen<IN, OUT>>, metricFn: AxMultiMetricFn, options?: AxCompileOptions): Promise<AxParetoResult<OUT>>;
3442
3558
  /**
3443
3559
  * Get current optimization statistics
3444
3560
  * @returns Current optimization statistics
@@ -3468,7 +3584,7 @@ interface AxOptimizer<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGen
3468
3584
  * @param program Program to validate
3469
3585
  * @returns Validation result with any issues found
3470
3586
  */
3471
- validateProgram?(program: Readonly<AxProgram<IN, OUT>>): {
3587
+ validateProgram?(program: Readonly<AxGen<IN, OUT>>): {
3472
3588
  isValid: boolean;
3473
3589
  issues: string[];
3474
3590
  suggestions: string[];
@@ -3515,11 +3631,11 @@ interface AxMiPROOptimizerOptions {
3515
3631
  interface AxBootstrapCompileOptions extends AxCompileOptions {
3516
3632
  validationExamples?: readonly AxExample[];
3517
3633
  maxDemos?: number;
3518
- teacherProgram?: Readonly<AxProgram<AxGenIn, AxGenOut>>;
3634
+ teacherProgram?: Readonly<AxGen<AxGenIn, AxGenOut>>;
3519
3635
  }
3520
3636
  interface AxMiPROCompileOptions extends AxCompileOptions {
3521
3637
  validationExamples?: readonly AxExample[];
3522
- teacher?: Readonly<AxProgram<AxGenIn, AxGenOut>>;
3638
+ teacher?: Readonly<AxGen<AxGenIn, AxGenOut>>;
3523
3639
  auto?: 'light' | 'medium' | 'heavy';
3524
3640
  instructionCandidates?: string[];
3525
3641
  customProposer?: (context: Readonly<{
@@ -3563,6 +3679,8 @@ declare abstract class AxBaseOptimizer<IN extends AxGenIn = AxGenIn, OUT extends
3563
3679
  protected readonly resumeFromCheckpoint?: string;
3564
3680
  protected readonly logger?: AxLoggerFunction;
3565
3681
  protected readonly verbose?: boolean;
3682
+ protected readonly debugOptimizer: boolean;
3683
+ protected readonly optimizerLogger?: AxOptimizerLoggerFunction;
3566
3684
  private currentRound;
3567
3685
  private scoreHistory;
3568
3686
  private configurationHistory;
@@ -3627,23 +3745,15 @@ declare abstract class AxBaseOptimizer<IN extends AxGenIn = AxGenIn, OUT extends
3627
3745
  /**
3628
3746
  * Abstract method that must be implemented by concrete optimizers
3629
3747
  */
3630
- abstract compile(program: Readonly<AxProgram<IN, OUT>>, metricFn: AxMetricFn, options?: AxCompileOptions): Promise<AxOptimizerResult<OUT>>;
3748
+ abstract compile(program: Readonly<AxGen<IN, OUT>>, metricFn: AxMetricFn, options?: AxCompileOptions): Promise<AxOptimizerResult<OUT>>;
3631
3749
  /**
3632
- * Get current optimization statistics
3633
- */
3634
- getStats(): AxOptimizationStats;
3635
- /**
3636
- * Reset optimizer state for reuse with different programs
3637
- */
3638
- reset(): void;
3639
- /**
3640
- * Basic program validation that can be extended by concrete optimizers
3750
+ * Optimize a program with real-time streaming updates
3751
+ * @param program The program to optimize
3752
+ * @param metricFn Evaluation metric function
3753
+ * @param options Optional configuration options
3754
+ * @returns Async iterator yielding optimization progress
3641
3755
  */
3642
- validateProgram(program: Readonly<AxProgram<IN, OUT>>): {
3643
- isValid: boolean;
3644
- issues: string[];
3645
- suggestions: string[];
3646
- };
3756
+ compileStream(program: Readonly<AxGen<IN, OUT>>, metricFn: AxMetricFn, options?: AxCompileOptions): AsyncIterableIterator<AxOptimizationProgress>;
3647
3757
  /**
3648
3758
  * Multi-objective optimization using Pareto frontier
3649
3759
  * Default implementation that leverages the single-objective compile method
@@ -3652,7 +3762,7 @@ declare abstract class AxBaseOptimizer<IN extends AxGenIn = AxGenIn, OUT extends
3652
3762
  * @param options Optional configuration options
3653
3763
  * @returns Pareto optimization result with frontier of non-dominated solutions
3654
3764
  */
3655
- compilePareto(program: Readonly<AxProgram<IN, OUT>>, metricFn: AxMultiMetricFn, options?: AxCompileOptions): Promise<AxParetoResult<OUT>>;
3765
+ compilePareto(program: Readonly<AxGen<IN, OUT>>, metricFn: AxMultiMetricFn, options?: AxCompileOptions): Promise<AxParetoResult<OUT>>;
3656
3766
  /**
3657
3767
  * Generate solutions using different weighted combinations of objectives
3658
3768
  */
@@ -3711,8 +3821,7 @@ declare abstract class AxBaseOptimizer<IN extends AxGenIn = AxGenIn, OUT extends
3711
3821
  * Get the logger function with fallback hierarchy:
3712
3822
  * 1. Explicit logger passed to optimizer
3713
3823
  * 2. Logger from student AI service
3714
- * 3. Default optimizer logger
3715
- * 4. undefined if verbose is false
3824
+ * 3. undefined if verbose is false
3716
3825
  */
3717
3826
  protected getLogger(options?: AxCompileOptions): AxLoggerFunction | undefined;
3718
3827
  /**
@@ -3751,11 +3860,15 @@ declare abstract class AxBaseOptimizer<IN extends AxGenIn = AxGenIn, OUT extends
3751
3860
  * Record performance metrics
3752
3861
  */
3753
3862
  protected recordPerformanceMetrics(metricType: 'evaluation' | 'demo_generation' | 'metric_computation', duration: number, optimizerType: string): void;
3863
+ protected isOptimizerLoggingEnabled(options?: AxCompileOptions): boolean;
3864
+ protected getOptimizerLogger(options?: AxCompileOptions): AxOptimizerLoggerFunction | undefined;
3865
+ getStats(): AxOptimizationStats;
3866
+ reset(): void;
3754
3867
  }
3755
3868
 
3756
3869
  type AxEvaluateArgs<IN extends AxGenIn, OUT extends AxGenOut> = {
3757
3870
  ai: AxAIService;
3758
- program: Readonly<AxProgram<IN, OUT>>;
3871
+ program: Readonly<AxGen<IN, OUT>>;
3759
3872
  examples: Readonly<AxExample[]>;
3760
3873
  };
3761
3874
  declare class AxTestPrompt<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGenOut> {
@@ -3806,15 +3919,6 @@ declare class AxHFDataLoader {
3806
3919
 
3807
3920
  declare const axCreateDefaultColorLogger: (output?: (message: string) => void) => AxLoggerFunction;
3808
3921
  declare const axCreateDefaultTextLogger: (output?: (message: string) => void) => AxLoggerFunction;
3809
- /**
3810
- * Factory function to create an enhanced optimizer logger with clean visual formatting
3811
- * that works for all optimizer types using semantic tags for proper categorization
3812
- */
3813
- declare const axCreateOptimizerLogger: (output?: (message: string) => void) => AxLoggerFunction;
3814
- /**
3815
- * Default optimizer logger instance
3816
- */
3817
- declare const axDefaultOptimizerLogger: AxLoggerFunction;
3818
3922
 
3819
3923
  interface AxMetricsConfig {
3820
3924
  enabled: boolean;
@@ -3866,6 +3970,19 @@ declare const axCheckMetricsHealth: () => {
3866
3970
  declare const axUpdateMetricsConfig: (config: Readonly<Partial<AxMetricsConfig>>) => void;
3867
3971
  declare const axGetMetricsConfig: () => AxMetricsConfig;
3868
3972
 
3973
+ /**
3974
+ * Factory function to create a default optimizer logger with color formatting
3975
+ */
3976
+ declare const axCreateDefaultOptimizerColorLogger: (output?: (message: string) => void) => AxOptimizerLoggerFunction;
3977
+ /**
3978
+ * Factory function to create a text-only optimizer logger (no colors)
3979
+ */
3980
+ declare const axCreateDefaultOptimizerTextLogger: (output?: (message: string) => void) => AxOptimizerLoggerFunction;
3981
+ /**
3982
+ * Default optimizer logger instance with color formatting
3983
+ */
3984
+ declare const axDefaultOptimizerLogger: AxOptimizerLoggerFunction;
3985
+
3869
3986
  declare class AxBootstrapFewShot<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGenOut> extends AxBaseOptimizer<IN, OUT> {
3870
3987
  private maxRounds;
3871
3988
  private maxDemos;
@@ -3881,7 +3998,7 @@ declare class AxBootstrapFewShot<IN extends AxGenIn = AxGenIn, OUT extends AxGen
3881
3998
  options?: AxBootstrapOptimizerOptions;
3882
3999
  }>);
3883
4000
  private compileRound;
3884
- compile(program: Readonly<AxProgram<IN, OUT>>, metricFn: AxMetricFn, options?: AxBootstrapCompileOptions): Promise<AxOptimizerResult<OUT>>;
4001
+ compile(program: Readonly<AxGen<IN, OUT>>, metricFn: AxMetricFn, options?: AxBootstrapCompileOptions): Promise<AxOptimizerResult<OUT>>;
3885
4002
  }
3886
4003
 
3887
4004
  interface AxMiPROResult<IN extends AxGenIn, OUT extends AxGenOut> extends AxOptimizerResult<OUT> {
@@ -3960,7 +4077,7 @@ declare class AxMiPRO<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGen
3960
4077
  /**
3961
4078
  * The main compile method to run MIPROv2 optimization
3962
4079
  */
3963
- compile(program: Readonly<AxProgram<IN, OUT>>, metricFn: AxMetricFn, options?: AxCompileOptions): Promise<AxMiPROResult<IN, OUT>>;
4080
+ compile(program: Readonly<AxGen<IN, OUT>>, metricFn: AxMetricFn, options?: AxCompileOptions): Promise<AxMiPROResult<IN, OUT>>;
3964
4081
  /**
3965
4082
  * Applies a configuration to an AxGen instance
3966
4083
  */
@@ -3984,7 +4101,7 @@ declare class AxMiPRO<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGen
3984
4101
  * @param program Program to validate
3985
4102
  * @returns Validation result with any issues found
3986
4103
  */
3987
- validateProgram(program: Readonly<AxProgram<IN, OUT>>): {
4104
+ validateProgram(_program: Readonly<AxGen<IN, OUT>>): {
3988
4105
  isValid: boolean;
3989
4106
  issues: string[];
3990
4107
  suggestions: string[];
@@ -4079,7 +4196,97 @@ declare const f: {
4079
4196
  };
4080
4197
  };
4081
4198
 
4199
+ /**
4200
+ * Analyzes mapping functions to extract state dependencies.
4201
+ *
4202
+ * This class is crucial for the automatic parallelization feature of AxFlow.
4203
+ * It determines which fields in the state object a mapping function accesses,
4204
+ * which allows the execution planner to understand dependencies between steps
4205
+ * and optimize execution by running independent steps in parallel.
4206
+ *
4207
+ * The analyzer uses two complementary approaches:
4208
+ * 1. Static analysis of the function source code
4209
+ * 2. Dynamic proxy-based tracking as a fallback
4210
+ *
4211
+ * This dual approach ensures robust dependency detection even for complex
4212
+ * mapping functions that might use destructuring, computed property access,
4213
+ * or other advanced JavaScript patterns.
4214
+ */
4215
+ declare class AxFlowDependencyAnalyzer {
4216
+ /**
4217
+ * Analyzes a mapping function to determine which state fields it depends on.
4218
+ *
4219
+ * This method is called for every execute step to understand what data
4220
+ * the step needs from the current state. This information is used to:
4221
+ * - Build the dependency graph for parallel execution
4222
+ * - Ensure steps execute in the correct order
4223
+ * - Optimize performance by identifying independent operations
4224
+ *
4225
+ * The analysis process:
4226
+ * 1. First tries static analysis by parsing the function source
4227
+ * 2. Falls back to proxy-based tracking for complex cases
4228
+ * 3. Returns a list of field names that the mapping function accesses
4229
+ *
4230
+ * @param mapping - The mapping function that transforms state to node inputs
4231
+ * @param _nodeName - The name of the node (currently unused but kept for future use)
4232
+ * @returns Array of field names that the mapping function depends on
4233
+ *
4234
+ * @example
4235
+ * ```typescript
4236
+ * // For a mapping like: state => ({ query: state.userInput, context: state.previousResult })
4237
+ * // This would return: ['userInput', 'previousResult']
4238
+ * ```
4239
+ */
4240
+ analyzeMappingDependencies(mapping: (state: any) => any, _nodeName: string): string[];
4241
+ /**
4242
+ * Creates a tracking proxy for dependency analysis.
4243
+ *
4244
+ * This is a public method that creates a proxy to track property access patterns.
4245
+ * It's used for testing and advanced dependency analysis scenarios.
4246
+ *
4247
+ * @param target - The target object to wrap with a proxy
4248
+ * @param accessed - Array to collect accessed property names
4249
+ * @returns Proxy object that tracks property access
4250
+ */
4251
+ createTrackingProxy(target: any, accessed: string[]): any;
4252
+ /**
4253
+ * Parses function source code to extract state dependencies using static analysis.
4254
+ *
4255
+ * This method analyzes the source code of a function to find patterns like
4256
+ * `state.fieldName` and extracts the field names as dependencies.
4257
+ *
4258
+ * @param functionSource - The source code of the function to analyze
4259
+ * @returns Array of field names found in the source code
4260
+ */
4261
+ parseStaticDependencies(functionSource: string): string[];
4262
+ /**
4263
+ * Creates a proxy object that tracks property access for dependency analysis.
4264
+ *
4265
+ * This proxy intercepts all property access on the state object and records
4266
+ * which fields are being accessed. It's used as a fallback when static analysis
4267
+ * can't determine dependencies (e.g., for destructuring or computed properties).
4268
+ *
4269
+ * The proxy works by:
4270
+ * 1. Intercepting all property access via the 'get' trap
4271
+ * 2. Recording accessed property names in the dependencies array
4272
+ * 3. Returning nested proxies for chained property access
4273
+ *
4274
+ * This allows detection of complex access patterns like:
4275
+ * - Destructuring: const { field1, field2 } = state
4276
+ * - Computed properties: state[dynamicKey]
4277
+ * - Nested access: state.nested.field
4278
+ *
4279
+ * @param dependencies - Array to collect dependency names (modified in place)
4280
+ * @returns Proxy object that tracks property access
4281
+ */
4282
+ private createDependencyTracker;
4283
+ }
4284
+
4082
4285
  type AxFlowState = Record<string, unknown>;
4286
+ interface AxFlowNodeDefinition {
4287
+ inputs: Record<string, unknown>;
4288
+ outputs: Record<string, unknown>;
4289
+ }
4083
4290
  type AxFlowStepFunction = (state: AxFlowState, context: Readonly<{
4084
4291
  mainAi: AxAIService;
4085
4292
  mainOptions?: AxProgramForwardOptions;
@@ -4088,15 +4295,21 @@ interface AxFlowDynamicContext {
4088
4295
  ai?: AxAIService;
4089
4296
  options?: AxProgramForwardOptions;
4090
4297
  }
4091
- type GetGenIn<T extends AxGen<AxGenIn, AxGenOut>> = T extends AxGen<infer IN, AxGenOut> ? IN : never;
4092
- type GetGenOut<T extends AxGen<AxGenIn, AxGenOut>> = T extends AxGen<AxGenIn, infer OUT> ? OUT : never;
4298
+ type GetGenIn<T extends AxProgrammable<AxGenIn, AxGenOut>> = T extends AxProgrammable<infer IN, AxGenOut> ? IN : never;
4299
+ type GetGenOut<T extends AxProgrammable<AxGenIn, AxGenOut>> = T extends AxProgrammable<AxGenIn, infer OUT> ? OUT : never;
4093
4300
  type InferAxGen<TSig extends string> = TSig extends string ? AxGen<AxGenIn, AxGenOut> : never;
4094
4301
  type NodeResultKey<TNodeName extends string> = `${TNodeName}Result`;
4095
4302
  type AddNodeResult<TState extends AxFlowState, TNodeName extends string, TNodeOut extends AxGenOut> = TState & {
4096
4303
  [K in NodeResultKey<TNodeName>]: TNodeOut;
4097
4304
  };
4098
- type AxFlowTypedParallelBranch<TNodes extends Record<string, AxGen<any, any>>, TState extends AxFlowState> = (subFlow: AxFlowTypedSubContext<TNodes, TState>) => AxFlowTypedSubContext<TNodes, AxFlowState>;
4099
- interface AxFlowTypedSubContext<TNodes extends Record<string, AxGen<any, any>>, TState extends AxFlowState> {
4305
+ /**
4306
+ * Interface for flows that can be tuned, executed, and used in compositions.
4307
+ * Provides methods for building and executing complex AI workflows.
4308
+ */
4309
+ interface AxFlowable<IN extends AxGenIn, OUT extends AxGenOut> extends AxProgrammable<IN, OUT> {
4310
+ }
4311
+ type AxFlowTypedParallelBranch<TNodes extends Record<string, AxProgrammable<any, any>>, TState extends AxFlowState> = (subFlow: AxFlowTypedSubContext<TNodes, TState>) => AxFlowTypedSubContext<TNodes, AxFlowState>;
4312
+ interface AxFlowTypedSubContext<TNodes extends Record<string, AxProgrammable<any, any>>, TState extends AxFlowState> {
4100
4313
  execute<TNodeName extends keyof TNodes & string>(nodeName: TNodeName, mapping: (state: TState) => GetGenIn<TNodes[TNodeName]>, dynamicContext?: AxFlowDynamicContext): AxFlowTypedSubContext<TNodes, AddNodeResult<TState, TNodeName, GetGenOut<TNodes[TNodeName]>>>;
4101
4314
  map<TNewState extends AxFlowState>(transform: (state: TState) => TNewState): AxFlowTypedSubContext<TNodes, TNewState>;
4102
4315
  executeSteps(initialState: TState, context: Readonly<{
@@ -4113,8 +4326,13 @@ interface AxFlowSubContext {
4113
4326
  mainOptions?: AxProgramForwardOptions;
4114
4327
  }>): Promise<AxFlowState>;
4115
4328
  }
4329
+ interface AxFlowBranchContext {
4330
+ predicate: (state: AxFlowState) => unknown;
4331
+ branches: Map<unknown, AxFlowStepFunction[]>;
4332
+ currentBranchValue?: unknown;
4333
+ }
4116
4334
  interface AxFlowExecutionStep {
4117
- type: 'execute' | 'map' | 'other';
4335
+ type: 'execute' | 'map' | 'merge' | 'parallel-map' | 'parallel';
4118
4336
  nodeName?: string;
4119
4337
  dependencies: string[];
4120
4338
  produces: string[];
@@ -4125,6 +4343,207 @@ interface AxFlowParallelGroup {
4125
4343
  level: number;
4126
4344
  steps: AxFlowExecutionStep[];
4127
4345
  }
4346
+ interface AxFlowAutoParallelConfig {
4347
+ enabled: boolean;
4348
+ batchSize?: number;
4349
+ }
4350
+
4351
+ /**
4352
+ * Builds and manages the execution plan with automatic parallelization.
4353
+ *
4354
+ * This class is the core of AxFlow's performance optimization system.
4355
+ * It analyzes the dependency relationships between steps and creates
4356
+ * an optimized execution plan that maximizes parallelism while ensuring
4357
+ * correct execution order.
4358
+ *
4359
+ * Key responsibilities:
4360
+ * 1. **Dependency Analysis**: Tracks what fields each step depends on and produces
4361
+ * 2. **Parallel Grouping**: Groups independent steps that can run simultaneously
4362
+ * 3. **Execution Optimization**: Creates optimized execution functions that
4363
+ * run parallel groups concurrently
4364
+ * 4. **Signature Inference**: Provides data for automatic signature generation
4365
+ *
4366
+ * The planner works by building a directed acyclic graph (DAG) of dependencies
4367
+ * and then creating execution levels where all steps in a level can run in parallel.
4368
+ */
4369
+ declare class AxFlowExecutionPlanner {
4370
+ private steps;
4371
+ private parallelGroups;
4372
+ private readonly analyzer;
4373
+ private initialFields;
4374
+ /**
4375
+ * Adds an execution step to the plan for analysis and optimization.
4376
+ *
4377
+ * This method is called for every operation in the flow (execute, map, merge, etc.)
4378
+ * and performs dependency analysis to understand what the step needs and produces.
4379
+ * This information is crucial for building the parallel execution plan.
4380
+ *
4381
+ * The method handles different types of steps:
4382
+ * - **Execute steps**: LLM node operations that depend on specific state fields
4383
+ * - **Map steps**: Transformations that modify the state object
4384
+ * - **Merge steps**: Operations that combine results from branches or parallel operations
4385
+ * - **Other steps**: Generic operations that don't fit other categories
4386
+ *
4387
+ * @param stepFunction - The actual function to execute for this step
4388
+ * @param nodeName - Name of the node (for execute steps)
4389
+ * @param mapping - Function that maps state to node inputs (for execute steps)
4390
+ * @param stepType - Type of step for specialized analysis
4391
+ * @param mapTransform - Transformation function (for map steps)
4392
+ * @param mergeOptions - Options for merge operations (result key, merge function)
4393
+ */
4394
+ addExecutionStep(stepFunction: AxFlowStepFunction, nodeName?: string, mapping?: (state: any) => any, stepType?: 'execute' | 'map' | 'merge' | 'parallel-map' | 'parallel', mapTransform?: (state: any) => any, mergeOptions?: {
4395
+ resultKey?: string;
4396
+ mergeFunction?: (...args: any[]) => any;
4397
+ }): void;
4398
+ /**
4399
+ * Analyzes a map transformation function to determine what fields it produces.
4400
+ *
4401
+ * This is a challenging problem because map transformations can produce arbitrary
4402
+ * new fields based on complex logic. The method uses a mock state approach:
4403
+ * 1. Creates a mock state with sample data
4404
+ * 2. Runs the transformation on the mock state
4405
+ * 3. Analyzes the result to see what fields were produced
4406
+ *
4407
+ * This approach works for most common transformation patterns but may miss
4408
+ * edge cases where the transformation behavior depends on specific data values.
4409
+ *
4410
+ * @param mapTransform - The map transformation function to analyze
4411
+ * @returns Array of field names that the transformation produces
4412
+ */
4413
+ private analyzeMapTransformation;
4414
+ /**
4415
+ * Creates a mock state with sample data for transformation analysis.
4416
+ *
4417
+ * This method builds a representative state object that includes:
4418
+ * - Initial fields from the flow input
4419
+ * - Result fields from previous steps with realistic structure
4420
+ * - Sample data that allows transformations to execute
4421
+ *
4422
+ * The mock state is used to run map transformations in a controlled
4423
+ * environment to determine what fields they produce.
4424
+ *
4425
+ * @returns Mock state object with sample data
4426
+ */
4427
+ private createMockState;
4428
+ /**
4429
+ * Creates appropriate mock values based on field names and patterns.
4430
+ */
4431
+ private createMockValue;
4432
+ /**
4433
+ * Analyzes what fields are produced by conditional merge operations.
4434
+ *
4435
+ * Conditional merges are complex because they don't transform data like map operations,
4436
+ * but instead select which branch's results to use based on a condition.
4437
+ * The challenge is determining what fields will be available after the merge
4438
+ * without knowing which branch will be taken at runtime.
4439
+ *
4440
+ * This method uses heuristics to determine the likely output fields:
4441
+ * 1. Look at recent execute steps (likely branch operations)
4442
+ * 2. If found, use their output fields as potential merge results
4443
+ * 3. Fallback to all execute step fields if no recent pattern is found
4444
+ *
4445
+ * The analysis assumes that branches in a conditional merge will produce
4446
+ * similar types of fields, so we can use any branch's fields as representative
4447
+ * of what the merge might produce.
4448
+ *
4449
+ * @returns string[] - Array of field names that the merge operation might produce
4450
+ */
4451
+ private analyzeBranchMergeFields;
4452
+ /**
4453
+ * Sets the initial fields and triggers parallel group rebuilding.
4454
+ *
4455
+ * This method is called once the flow knows what input fields are available.
4456
+ * It triggers the parallel group analysis which determines the optimal
4457
+ * execution strategy for the entire flow.
4458
+ *
4459
+ * @param fields - Array of field names available at the start of execution
4460
+ */
4461
+ setInitialFields(fields: string[]): void;
4462
+ /**
4463
+ * Rebuilds the parallel execution groups based on step dependencies.
4464
+ *
4465
+ * This is the core algorithm that creates the parallel execution plan.
4466
+ * It uses a level-by-level approach:
4467
+ *
4468
+ * 1. **Level 0**: Steps with no dependencies (can run immediately)
4469
+ * 2. **Level 1**: Steps that depend only on Level 0 outputs
4470
+ * 3. **Level N**: Steps that depend on outputs from previous levels
4471
+ *
4472
+ * Steps within the same level can run in parallel because they don't
4473
+ * depend on each other's outputs.
4474
+ *
4475
+ * The algorithm ensures:
4476
+ * - Correct execution order (dependencies are satisfied)
4477
+ * - Maximum parallelism (independent steps run simultaneously)
4478
+ * - Deadlock prevention (circular dependencies are detected)
4479
+ *
4480
+ * Time complexity: O(n²) where n is the number of steps
4481
+ * Space complexity: O(n) for tracking processed steps and available fields
4482
+ */
4483
+ private rebuildParallelGroups;
4484
+ /**
4485
+ * Gets all fields produced by previous steps.
4486
+ *
4487
+ * This is used by steps that depend on "everything produced so far"
4488
+ * such as map transformations and merge operations.
4489
+ *
4490
+ * @returns Array of all field names produced by previous steps
4491
+ */
4492
+ private getAllProducedFields;
4493
+ /**
4494
+ * Creates optimized execution functions that implement the parallel execution plan.
4495
+ *
4496
+ * This method converts the parallel groups into actual executable functions.
4497
+ * It creates a series of steps where:
4498
+ * - Single-step groups execute directly
4499
+ * - Multi-step groups execute in parallel with batch size control
4500
+ * - Results are properly merged to maintain state consistency
4501
+ *
4502
+ * The optimized execution can significantly improve performance for flows
4503
+ * with independent operations, especially I/O-bound operations like LLM calls.
4504
+ *
4505
+ * Performance benefits:
4506
+ * - Reduces total execution time for independent operations
4507
+ * - Maximizes CPU and I/O utilization
4508
+ * - Maintains correctness through dependency management
4509
+ * - Controls resource usage through batch size limiting
4510
+ *
4511
+ * @param batchSize - Maximum number of concurrent operations (optional)
4512
+ * @returns Array of optimized step functions ready for execution
4513
+ */
4514
+ createOptimizedExecution(batchSize?: number): AxFlowStepFunction[];
4515
+ /**
4516
+ * Gets optimized execution steps for the flow.
4517
+ *
4518
+ * This method provides the optimized execution steps that can be used
4519
+ * to execute the flow with maximum parallelism while maintaining
4520
+ * dependency order.
4521
+ *
4522
+ * @returns Array of optimized step functions ready for execution
4523
+ */
4524
+ getOptimizedExecutionSteps(): AxFlowStepFunction[];
4525
+ /**
4526
+ * Gets detailed execution plan information for debugging and analysis.
4527
+ *
4528
+ * This method provides comprehensive information about the execution plan,
4529
+ * including step counts, parallel grouping details, and the complete
4530
+ * dependency structure. It's particularly useful for:
4531
+ * - Debugging execution flow issues
4532
+ * - Performance analysis and optimization
4533
+ * - Understanding parallelization effectiveness
4534
+ * - Monitoring execution plan complexity
4535
+ *
4536
+ * @returns Object containing detailed execution plan metrics and data
4537
+ */
4538
+ getExecutionPlan(): {
4539
+ totalSteps: number;
4540
+ parallelGroups: number;
4541
+ maxParallelism: number;
4542
+ steps: AxFlowExecutionStep[];
4543
+ groups: AxFlowParallelGroup[];
4544
+ };
4545
+ }
4546
+
4128
4547
  /**
4129
4548
  * AxFlow - A fluent, chainable API for building and orchestrating complex, stateful AI programs.
4130
4549
  *
@@ -4143,8 +4562,8 @@ interface AxFlowParallelGroup {
4143
4562
  * const result = await flow.forward(ai, { topic: "AI safety" })
4144
4563
  * ```
4145
4564
  */
4146
- declare class AxFlow<IN extends AxGenIn, OUT extends AxGenOut, TNodes extends Record<string, AxGen<any, any>> = Record<string, never>, // Node registry for type tracking
4147
- TState extends AxFlowState = IN> extends AxProgram<IN, OUT> {
4565
+ declare class AxFlow<IN extends AxGenIn, OUT extends AxGenOut, TNodes extends Record<string, AxProgrammable<any, any>> = Record<string, never>, // Node registry for type tracking
4566
+ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
4148
4567
  private readonly nodes;
4149
4568
  private readonly flowDefinition;
4150
4569
  private readonly nodeGenerators;
@@ -4153,9 +4572,80 @@ TState extends AxFlowState = IN> extends AxProgram<IN, OUT> {
4153
4572
  private branchContext;
4154
4573
  private readonly autoParallelConfig;
4155
4574
  private readonly executionPlanner;
4156
- constructor(signature?: NonNullable<ConstructorParameters<typeof AxSignature>[0]>, options?: {
4575
+ private program?;
4576
+ /**
4577
+ * Converts a string to camelCase for valid field names
4578
+ */
4579
+ private toCamelCase;
4580
+ /**
4581
+ * Infers the signature of the flow based on the execution plan and node definitions.
4582
+ * This is the core method that determines what input/output fields the flow should have
4583
+ * based on the nodes and operations defined in the flow.
4584
+ *
4585
+ * The inference process follows these steps:
4586
+ * 1. If no nodes are defined, return a default signature
4587
+ * 2. Analyze the execution plan to find all produced and consumed fields
4588
+ * 3. Determine input fields (consumed but not produced by any step)
4589
+ * 4. Determine output fields with special handling for final map/merge operations
4590
+ * 5. If no clear pattern is found, create a comprehensive signature from all nodes
4591
+ *
4592
+ * Special handling for final operations:
4593
+ * - Map operations: Use the fields produced by the map transformation
4594
+ * - Merge operations: Use fields from the merged branches or merge result
4595
+ * - Conditional merges: Analyze what fields the branches actually produce
4596
+ *
4597
+ * @returns AxSignature - The inferred signature for this flow
4598
+ */
4599
+ private inferSignatureFromFlow;
4600
+ constructor(options?: {
4157
4601
  autoParallel?: boolean;
4602
+ batchSize?: number;
4158
4603
  });
4604
+ /**
4605
+ * Initializes the program field every time something is added to the graph
4606
+ */
4607
+ private ensureProgram;
4608
+ setExamples(examples: Readonly<AxProgramExamples<IN, OUT>>, options?: Readonly<AxSetExamplesOptions>): void;
4609
+ setId(id: string): void;
4610
+ setParentId(parentId: string): void;
4611
+ getTraces(): AxProgramTrace<IN, OUT>[];
4612
+ setDemos(demos: readonly AxProgramDemos<IN, OUT>[]): void;
4613
+ getUsage(): AxProgramUsage[];
4614
+ resetUsage(): void;
4615
+ streamingForward(ai: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramStreamingForwardOptions>): AxGenStreamingOut<OUT>;
4616
+ /**
4617
+ * Executes the flow with the given AI service and input values.
4618
+ *
4619
+ * This is the main execution method that orchestrates the entire flow execution.
4620
+ * It handles several complex aspects:
4621
+ *
4622
+ * 1. **Dynamic Signature Inference**: If the flow was created with a default signature
4623
+ * but has nodes defined, it will infer the actual signature from the flow structure.
4624
+ *
4625
+ * 2. **Execution Mode Selection**: Chooses between optimized parallel execution
4626
+ * (when auto-parallel is enabled) or sequential execution based on configuration.
4627
+ *
4628
+ * 3. **State Management**: Maintains the evolving state object as it flows through
4629
+ * each step, accumulating results and transformations.
4630
+ *
4631
+ * 4. **Performance Optimization**: Uses the execution planner to identify
4632
+ * independent operations that can run in parallel, reducing total execution time.
4633
+ *
4634
+ * Execution Flow:
4635
+ * - Initialize state with input values
4636
+ * - Infer signature if needed (based on nodes and current signature)
4637
+ * - Choose execution strategy (parallel vs sequential)
4638
+ * - Execute all steps while maintaining state consistency
4639
+ * - Return final state cast to expected output type
4640
+ *
4641
+ * @param ai - The AI service to use as the default for all steps
4642
+ * @param values - The input values for the flow
4643
+ * @param options - Optional forward options to use as defaults (includes autoParallel override)
4644
+ * @returns Promise that resolves to the final output
4645
+ */
4646
+ forward(ai: Readonly<AxAIService>, values: IN | AxMessage<IN>[], options?: Readonly<AxProgramForwardOptions & {
4647
+ autoParallel?: boolean;
4648
+ }>): Promise<OUT>;
4159
4649
  /**
4160
4650
  * Declares a reusable computational node using a signature string.
4161
4651
  * Returns a new AxFlow type that tracks this node in the TNodes registry.
@@ -4194,24 +4684,6 @@ TState extends AxFlowState = IN> extends AxProgram<IN, OUT> {
4194
4684
  [K in TName]: AxGen<AxGenIn, AxGenOut>;
4195
4685
  }, // Add new node to registry
4196
4686
  TState>;
4197
- /**
4198
- * Declares a reusable computational node using an existing AxGen instance.
4199
- * This allows reusing pre-configured generators in the flow.
4200
- *
4201
- * @param name - The name of the node
4202
- * @param axgenInstance - Existing AxGen instance to use for this node
4203
- * @returns New AxFlow instance with updated TNodes type
4204
- *
4205
- * @example
4206
- * ```typescript
4207
- * const summarizer = new AxGen('text:string -> summary:string', { temperature: 0.1 })
4208
- * flow.node('summarizer', summarizer)
4209
- * ```
4210
- */
4211
- node<TName extends string, TGen extends AxGen<any, any>>(name: TName, axgenInstance: TGen): AxFlow<IN, OUT, TNodes & {
4212
- [K in TName]: TGen;
4213
- }, // Add new node to registry with exact type
4214
- TState>;
4215
4687
  /**
4216
4688
  * Declares a reusable computational node using a class that extends AxProgram.
4217
4689
  * This allows using custom program classes in the flow.
@@ -4228,10 +4700,22 @@ TState extends AxFlowState = IN> extends AxProgram<IN, OUT> {
4228
4700
  * flow.node('custom', CustomProgram)
4229
4701
  * ```
4230
4702
  */
4231
- node<TName extends string, TProgram extends new () => AxProgram<any, any>>(name: TName, programClass: TProgram): AxFlow<IN, OUT, TNodes & {
4703
+ node<TName extends string, TProgram extends new () => AxProgrammable<any, any>>(name: TName, programClass: TProgram): AxFlow<IN, OUT, TNodes & {
4232
4704
  [K in TName]: InstanceType<TProgram>;
4233
4705
  }, // Add new node to registry with exact type
4234
4706
  TState>;
4707
+ /**
4708
+ * Declares a reusable computational node using an AxProgrammable instance.
4709
+ * This allows using pre-configured AxGen instances or other programmable objects in the flow.
4710
+ *
4711
+ * @param name - The name of the node
4712
+ * @param programInstance - The AxProgrammable instance to use for this node
4713
+ * @returns New AxFlow instance with updated TNodes type
4714
+ */
4715
+ node<TName extends string, TProgram extends AxProgrammable<any, any>>(name: TName, programInstance: TProgram): AxFlow<IN, OUT, TNodes & {
4716
+ [K in TName]: TProgram;
4717
+ }, // Add new node to registry with exact type
4718
+ TState>;
4235
4719
  /**
4236
4720
  * Short alias for node() - supports signature strings, AxSignature instances, AxGen instances, and program classes
4237
4721
  */
@@ -4241,12 +4725,12 @@ TState extends AxFlowState = IN> extends AxProgram<IN, OUT> {
4241
4725
  n<TName extends string>(name: TName, signature: AxSignature, options?: Readonly<AxProgramForwardOptions>): AxFlow<IN, OUT, TNodes & {
4242
4726
  [K in TName]: AxGen<AxGenIn, AxGenOut>;
4243
4727
  }, TState>;
4244
- n<TName extends string, TGen extends AxGen<any, any>>(name: TName, axgenInstance: TGen): AxFlow<IN, OUT, TNodes & {
4245
- [K in TName]: TGen;
4246
- }, TState>;
4247
- n<TName extends string, TProgram extends new () => AxProgram<any, any>>(name: TName, programClass: TProgram): AxFlow<IN, OUT, TNodes & {
4728
+ n<TName extends string, TProgram extends new () => AxProgrammable<any, any>>(name: TName, programClass: TProgram): AxFlow<IN, OUT, TNodes & {
4248
4729
  [K in TName]: InstanceType<TProgram>;
4249
4730
  }, TState>;
4731
+ n<TName extends string, TProgram extends AxProgrammable<any, any>>(name: TName, programInstance: TProgram): AxFlow<IN, OUT, TNodes & {
4732
+ [K in TName]: TProgram;
4733
+ }, TState>;
4250
4734
  /**
4251
4735
  * Applies a synchronous transformation to the state object.
4252
4736
  * Returns a new AxFlow type with the evolved state.
@@ -4259,11 +4743,39 @@ TState extends AxFlowState = IN> extends AxProgram<IN, OUT> {
4259
4743
  * flow.map(state => ({ ...state, processedText: state.text.toLowerCase() }))
4260
4744
  * ```
4261
4745
  */
4262
- map<TNewState extends AxFlowState>(transform: (state: TState) => TNewState): AxFlow<IN, OUT, TNodes, TNewState>;
4746
+ map<TNewState extends AxFlowState>(transform: (_state: TState) => TNewState): AxFlow<IN, OUT, TNodes, TNewState>;
4263
4747
  /**
4264
- * Short alias for map()
4748
+ * Applies a transformation to the state object with optional parallel execution.
4749
+ * When parallel is enabled, the transform function should prepare data for parallel processing.
4750
+ * The actual parallel processing happens with the array of transforms provided.
4751
+ *
4752
+ * @param transforms - Array of transformation functions to apply in parallel
4753
+ * @param options - Options including parallel execution configuration
4754
+ * @returns New AxFlow instance with updated TState type
4755
+ *
4756
+ * @example
4757
+ * ```typescript
4758
+ * // Parallel map with multiple transforms
4759
+ * flow.map([
4760
+ * state => ({ ...state, result1: processA(state.data) }),
4761
+ * state => ({ ...state, result2: processB(state.data) }),
4762
+ * state => ({ ...state, result3: processC(state.data) })
4763
+ * ], { parallel: true })
4764
+ * ```
4265
4765
  */
4266
- m<TNewState extends AxFlowState>(transform: (state: TState) => TNewState): AxFlow<IN, OUT, TNodes, TNewState>;
4766
+ map<TNewState extends AxFlowState>(transforms: Array<(_state: TState) => TNewState>, options: {
4767
+ parallel: true;
4768
+ }): AxFlow<IN, OUT, TNodes, TNewState>;
4769
+ map<TNewState extends AxFlowState>(transform: (_state: TState) => TNewState, options?: {
4770
+ parallel?: boolean;
4771
+ }): AxFlow<IN, OUT, TNodes, TNewState>;
4772
+ /**
4773
+ * Short alias for map() - supports parallel option
4774
+ */
4775
+ m<TNewState extends AxFlowState>(transform: (_state: TState) => TNewState): AxFlow<IN, OUT, TNodes, TNewState>;
4776
+ m<TNewState extends AxFlowState>(transforms: Array<(_state: TState) => TNewState>, options: {
4777
+ parallel: true;
4778
+ }): AxFlow<IN, OUT, TNodes, TNewState>;
4267
4779
  /**
4268
4780
  * Labels a step for later reference (useful for feedback loops).
4269
4781
  *
@@ -4295,11 +4807,11 @@ TState extends AxFlowState = IN> extends AxProgram<IN, OUT> {
4295
4807
  * flow.execute('summarizer', state => ({ text: state.originalText }), { ai: cheapAI })
4296
4808
  * ```
4297
4809
  */
4298
- execute<TNodeName extends keyof TNodes & string>(nodeName: TNodeName, mapping: (state: TState) => GetGenIn<TNodes[TNodeName]>, dynamicContext?: AxFlowDynamicContext): AxFlow<IN, OUT, TNodes, AddNodeResult<TState, TNodeName, GetGenOut<TNodes[TNodeName]>>>;
4810
+ execute<TNodeName extends keyof TNodes & string>(nodeName: TNodeName, mapping: (_state: TState) => GetGenIn<TNodes[TNodeName]>, dynamicContext?: AxFlowDynamicContext): AxFlow<IN, OUT, TNodes, AddNodeResult<TState, TNodeName, GetGenOut<TNodes[TNodeName]>>>;
4299
4811
  /**
4300
4812
  * Short alias for execute()
4301
4813
  */
4302
- e<TNodeName extends keyof TNodes & string>(nodeName: TNodeName, mapping: (state: TState) => GetGenIn<TNodes[TNodeName]>, dynamicContext?: AxFlowDynamicContext): AxFlow<IN, OUT, TNodes, AddNodeResult<TState, TNodeName, GetGenOut<TNodes[TNodeName]>>>;
4814
+ e<TNodeName extends keyof TNodes & string>(nodeName: TNodeName, mapping: (_state: TState) => GetGenIn<TNodes[TNodeName]>, dynamicContext?: AxFlowDynamicContext): AxFlow<IN, OUT, TNodes, AddNodeResult<TState, TNodeName, GetGenOut<TNodes[TNodeName]>>>;
4303
4815
  /**
4304
4816
  * Starts a conditional branch based on a predicate function.
4305
4817
  *
@@ -4316,11 +4828,11 @@ TState extends AxFlowState = IN> extends AxProgram<IN, OUT> {
4316
4828
  * .merge()
4317
4829
  * ```
4318
4830
  */
4319
- branch(predicate: (state: TState) => unknown): this;
4831
+ branch(predicate: (_state: TState) => unknown): this;
4320
4832
  /**
4321
4833
  * Short alias for branch()
4322
4834
  */
4323
- b(predicate: (state: TState) => unknown): this;
4835
+ b(predicate: (_state: TState) => unknown): this;
4324
4836
  /**
4325
4837
  * Defines a branch case for the current branch context.
4326
4838
  *
@@ -4333,25 +4845,34 @@ TState extends AxFlowState = IN> extends AxProgram<IN, OUT> {
4333
4845
  */
4334
4846
  w(value: unknown): this;
4335
4847
  /**
4336
- * Ends the current branch and merges all branch paths back into the main flow.
4337
- * Optionally specify the explicit merged state type for better type safety.
4848
+ * Merges the results of conditional branches into a single execution path.
4849
+ *
4850
+ * This method is called after defining conditional branches with branch() and when() methods.
4851
+ * It creates a merge point where the flow continues with the results from whichever
4852
+ * branch was executed based on the branch condition.
4853
+ *
4854
+ * How conditional merging works:
4855
+ * 1. The branch predicate is evaluated against the current state
4856
+ * 2. The matching branch's steps are executed sequentially
4857
+ * 3. If no branch matches, the state is returned unchanged
4858
+ * 4. The merged result becomes the new state for subsequent steps
4338
4859
  *
4339
- * @param explicitMergedType - Optional type hint for the merged state (defaults to current TState)
4340
- * @returns AxFlow instance with the merged state type
4860
+ * Type safety note:
4861
+ * The TMergedState generic allows for type-level tracking of what fields
4862
+ * will be available after the merge, though runtime behavior depends on
4863
+ * which branch actually executes.
4864
+ *
4865
+ * @returns AxFlow with updated state type reflecting the merged result
4341
4866
  *
4342
4867
  * @example
4343
4868
  * ```typescript
4344
- * // Default behavior - preserves current TState
4345
- * flow.branch(state => state.type)
4346
- * .when('simple').execute('simpleProcessor', ...)
4347
- * .when('complex').execute('complexProcessor', ...)
4348
- * .merge()
4349
- *
4350
- * // Explicit type - specify exact merged state shape
4351
- * flow.branch(state => state.type)
4352
- * .when('simple').map(state => ({ result: state.simpleResult, method: 'simple' }))
4353
- * .when('complex').map(state => ({ result: state.complexResult, method: 'complex' }))
4354
- * .merge<{ result: string; method: string }>()
4869
+ * flow
4870
+ * .branch(state => state.complexity > 0.5)
4871
+ * .when(true)
4872
+ * .execute('complexProcessor', state => ({ input: state.text }))
4873
+ * .when(false)
4874
+ * .execute('simpleProcessor', state => ({ input: state.text }))
4875
+ * .merge() // Combines results from either branch
4355
4876
  * ```
4356
4877
  */
4357
4878
  merge<TMergedState extends AxFlowState = TState>(): AxFlow<IN, OUT, TNodes, TMergedState>;
@@ -4360,8 +4881,24 @@ TState extends AxFlowState = IN> extends AxProgram<IN, OUT> {
4360
4881
  */
4361
4882
  mg<TMergedState extends AxFlowState = TState>(): AxFlow<IN, OUT, TNodes, TMergedState>;
4362
4883
  /**
4363
- * Executes multiple operations in parallel and merges their results.
4364
- * Both typed and legacy untyped branches are supported.
4884
+ * Executes multiple operations in parallel and provides a merge method for combining results.
4885
+ *
4886
+ * This method enables true parallel execution of independent operations, which is particularly
4887
+ * useful for operations like:
4888
+ * - Multiple document retrievals
4889
+ * - Parallel processing of different data sources
4890
+ * - Independent LLM calls that can run simultaneously
4891
+ *
4892
+ * How parallel execution works:
4893
+ * 1. Each branch function receives a sub-context for defining operations
4894
+ * 2. All branches are executed simultaneously using Promise.all()
4895
+ * 3. Results are stored in _parallelResults for the merge operation
4896
+ * 4. The merge function combines the results into a single field
4897
+ *
4898
+ * Performance benefits:
4899
+ * - Reduces total execution time for independent operations
4900
+ * - Maximizes throughput for I/O-bound operations (like LLM calls)
4901
+ * - Maintains type safety through the merge operation
4365
4902
  *
4366
4903
  * @param branches - Array of functions that define parallel operations
4367
4904
  * @returns Object with merge method for combining results
@@ -4376,7 +4913,7 @@ TState extends AxFlowState = IN> extends AxProgram<IN, OUT> {
4376
4913
  * ```
4377
4914
  */
4378
4915
  parallel(branches: (AxFlowParallelBranch | AxFlowTypedParallelBranch<TNodes, TState>)[]): {
4379
- merge<T, TResultKey extends string>(resultKey: TResultKey, mergeFunction: (...results: unknown[]) => T): AxFlow<IN, OUT, TNodes, TState & {
4916
+ merge<T, TResultKey extends string>(resultKey: TResultKey, mergeFunction: (..._results: unknown[]) => T): AxFlow<IN, OUT, TNodes, TState & {
4380
4917
  [K in TResultKey]: T;
4381
4918
  }>;
4382
4919
  };
@@ -4384,7 +4921,7 @@ TState extends AxFlowState = IN> extends AxProgram<IN, OUT> {
4384
4921
  * Short alias for parallel()
4385
4922
  */
4386
4923
  p(branches: (AxFlowParallelBranch | AxFlowTypedParallelBranch<TNodes, TState>)[]): {
4387
- merge<T, TResultKey extends string>(resultKey: TResultKey, mergeFunction: (...results: unknown[]) => T): AxFlow<IN, OUT, TNodes, TState & {
4924
+ merge<T, TResultKey extends string>(resultKey: TResultKey, mergeFunction: (..._results: unknown[]) => T): AxFlow<IN, OUT, TNodes, TState & {
4388
4925
  [K in TResultKey]: T;
4389
4926
  }>;
4390
4927
  };
@@ -4404,11 +4941,11 @@ TState extends AxFlowState = IN> extends AxProgram<IN, OUT> {
4404
4941
  * .feedback(state => state.qualityCheckResult.confidence < 0.7, 'retry-point')
4405
4942
  * ```
4406
4943
  */
4407
- feedback(condition: (state: TState) => boolean, targetLabel: string, maxIterations?: number): this;
4944
+ feedback(condition: (_state: TState) => boolean, targetLabel: string, maxIterations?: number): this;
4408
4945
  /**
4409
4946
  * Short alias for feedback()
4410
4947
  */
4411
- fb(condition: (state: TState) => boolean, targetLabel: string, maxIterations?: number): this;
4948
+ fb(condition: (_state: TState) => boolean, targetLabel: string, maxIterations?: number): this;
4412
4949
  /**
4413
4950
  * Marks the beginning of a loop block.
4414
4951
  *
@@ -4427,7 +4964,7 @@ TState extends AxFlowState = IN> extends AxProgram<IN, OUT> {
4427
4964
  /**
4428
4965
  * Short alias for while()
4429
4966
  */
4430
- wh(condition: (state: TState) => boolean, maxIterations?: number): this;
4967
+ wh(condition: (_state: TState) => boolean, maxIterations?: number): this;
4431
4968
  /**
4432
4969
  * Marks the end of a loop block.
4433
4970
  *
@@ -4438,17 +4975,6 @@ TState extends AxFlowState = IN> extends AxProgram<IN, OUT> {
4438
4975
  * Short alias for endWhile()
4439
4976
  */
4440
4977
  end(): this;
4441
- /**
4442
- * Executes the flow with the given AI service and input values.
4443
- *
4444
- * @param ai - The AI service to use as the default for all steps
4445
- * @param values - The input values for the flow
4446
- * @param options - Optional forward options to use as defaults (includes autoParallel override)
4447
- * @returns Promise that resolves to the final output
4448
- */
4449
- forward(ai: Readonly<AxAIService>, values: IN, options?: Readonly<AxProgramForwardOptions & {
4450
- autoParallel?: boolean;
4451
- }>): Promise<OUT>;
4452
4978
  /**
4453
4979
  * Gets execution plan information for debugging automatic parallelization
4454
4980
  *
@@ -4462,6 +4988,22 @@ TState extends AxFlowState = IN> extends AxProgram<IN, OUT> {
4462
4988
  steps?: AxFlowExecutionStep[];
4463
4989
  groups?: AxFlowParallelGroup[];
4464
4990
  };
4991
+ getSignature(): AxSignature;
4992
+ }
4993
+
4994
+ /**
4995
+ * Implementation of the sub-context for parallel execution
4996
+ */
4997
+ declare class AxFlowSubContextImpl implements AxFlowSubContext {
4998
+ private readonly nodeGenerators;
4999
+ private readonly steps;
5000
+ constructor(nodeGenerators: Map<string, AxForwardable<AxGenIn, AxGenOut> & AxTunable<AxGenIn, AxGenOut> & AxUsable>);
5001
+ execute(nodeName: string, mapping: (state: AxFlowState) => Record<string, AxFieldValue>, dynamicContext?: AxFlowDynamicContext): this;
5002
+ map(transform: (state: AxFlowState) => AxFlowState): this;
5003
+ executeSteps(initialState: AxFlowState, context: Readonly<{
5004
+ mainAi: AxAIService;
5005
+ mainOptions?: AxProgramForwardOptions;
5006
+ }>): Promise<AxFlowState>;
4465
5007
  }
4466
5008
  /**
4467
5009
  * Typed implementation of the sub-context for parallel execution with full type safety
@@ -4596,18 +5138,18 @@ declare class AxEmbeddingAdapter {
4596
5138
  toFunction(): AxFunction;
4597
5139
  }
4598
5140
 
4599
- interface JSONRPCRequest<T> {
5141
+ interface AxMCPJSONRPCRequest<T> {
4600
5142
  jsonrpc: '2.0';
4601
5143
  id: string | number;
4602
5144
  method: string;
4603
5145
  params?: T;
4604
5146
  }
4605
- interface JSONRPCSuccessResponse<T = unknown> {
5147
+ interface AxMCPJSONRPCSuccessResponse<T = unknown> {
4606
5148
  jsonrpc: '2.0';
4607
5149
  id: string | number;
4608
5150
  result: T;
4609
5151
  }
4610
- interface JSONRPCErrorResponse {
5152
+ interface AxMCPJSONRPCErrorResponse {
4611
5153
  jsonrpc: '2.0';
4612
5154
  id: string | number;
4613
5155
  error: {
@@ -4616,8 +5158,38 @@ interface JSONRPCErrorResponse {
4616
5158
  data?: unknown;
4617
5159
  };
4618
5160
  }
4619
- type JSONRPCResponse<T = unknown> = JSONRPCSuccessResponse<T> | JSONRPCErrorResponse;
4620
- interface JSONRPCNotification {
5161
+ type AxMCPJSONRPCResponse<T = unknown> = AxMCPJSONRPCSuccessResponse<T> | AxMCPJSONRPCErrorResponse;
5162
+ interface AxMCPInitializeParams {
5163
+ protocolVersion: string;
5164
+ capabilities: Record<string, unknown>;
5165
+ clientInfo: {
5166
+ name: string;
5167
+ version: string;
5168
+ };
5169
+ }
5170
+ interface AxMCPInitializeResult {
5171
+ protocolVersion: string;
5172
+ capabilities: {
5173
+ tools?: unknown[];
5174
+ resources?: Record<string, unknown>;
5175
+ prompts?: unknown[];
5176
+ };
5177
+ serverInfo: {
5178
+ name: string;
5179
+ version: string;
5180
+ };
5181
+ }
5182
+ interface AxMCPFunctionDescription {
5183
+ name: string;
5184
+ description: string;
5185
+ inputSchema: AxFunctionJSONSchema;
5186
+ }
5187
+ interface AxMCPToolsListResult {
5188
+ name: string;
5189
+ description: string;
5190
+ tools: AxMCPFunctionDescription[];
5191
+ }
5192
+ interface AxMCPJSONRPCNotification {
4621
5193
  jsonrpc: '2.0';
4622
5194
  method: string;
4623
5195
  params?: Record<string, unknown>;
@@ -4629,12 +5201,12 @@ interface AxMCPTransport {
4629
5201
  * @param message The JSON-RPC request or notification to send
4630
5202
  * @returns A Promise that resolves to the JSON-RPC response
4631
5203
  */
4632
- send(message: Readonly<JSONRPCRequest<unknown>>): Promise<JSONRPCResponse<unknown>>;
5204
+ send(message: Readonly<AxMCPJSONRPCRequest<unknown>>): Promise<AxMCPJSONRPCResponse<unknown>>;
4633
5205
  /**
4634
5206
  * Sends a JSON-RPC notification
4635
5207
  * @param message The JSON-RPC notification to send
4636
5208
  */
4637
- sendNotification(message: Readonly<JSONRPCNotification>): Promise<void>;
5209
+ sendNotification(message: Readonly<AxMCPJSONRPCNotification>): Promise<void>;
4638
5210
  /**
4639
5211
  * Connects to the transport if needed
4640
5212
  * This method is optional and only required for transports that need connection setup
@@ -4707,8 +5279,8 @@ declare class AxMCPHTTPSSETransport implements AxMCPTransport {
4707
5279
  private eventSource?;
4708
5280
  constructor(sseUrl: string);
4709
5281
  connect(): Promise<void>;
4710
- send(message: JSONRPCRequest<unknown> | JSONRPCNotification): Promise<JSONRPCResponse<unknown>>;
4711
- sendNotification(message: Readonly<JSONRPCNotification>): Promise<void>;
5282
+ send(message: AxMCPJSONRPCRequest<unknown> | AxMCPJSONRPCNotification): Promise<AxMCPJSONRPCResponse<unknown>>;
5283
+ sendNotification(message: Readonly<AxMCPJSONRPCNotification>): Promise<void>;
4712
5284
  }
4713
5285
  interface AxMCPStreamableHTTPTransportOptions {
4714
5286
  /**
@@ -4753,7 +5325,7 @@ declare class AxMCPStreambleHTTPTransport implements AxMCPTransport {
4753
5325
  /**
4754
5326
  * Set a handler for incoming server messages (requests/notifications)
4755
5327
  */
4756
- setMessageHandler(handler: (message: JSONRPCRequest<unknown> | JSONRPCNotification) => void): void;
5328
+ setMessageHandler(handler: (message: AxMCPJSONRPCRequest<unknown> | AxMCPJSONRPCNotification) => void): void;
4757
5329
  connect(): Promise<void>;
4758
5330
  /**
4759
5331
  * Opens an SSE stream to listen for server-initiated messages
@@ -4763,9 +5335,9 @@ declare class AxMCPStreambleHTTPTransport implements AxMCPTransport {
4763
5335
  * Opens an SSE stream using fetch API to support custom headers
4764
5336
  */
4765
5337
  private openListeningStreamWithFetch;
4766
- send(message: Readonly<JSONRPCRequest<unknown>>): Promise<JSONRPCResponse<unknown>>;
5338
+ send(message: Readonly<AxMCPJSONRPCRequest<unknown>>): Promise<AxMCPJSONRPCResponse<unknown>>;
4767
5339
  private handleSSEResponse;
4768
- sendNotification(message: Readonly<JSONRPCNotification>): Promise<void>;
5340
+ sendNotification(message: Readonly<AxMCPJSONRPCNotification>): Promise<void>;
4769
5341
  /**
4770
5342
  * Explicitly terminate the session (if supported by server)
4771
5343
  */
@@ -4780,7 +5352,7 @@ declare class AxMCPStreambleHTTPTransport implements AxMCPTransport {
4780
5352
  * Interface for agents that can be used as child agents.
4781
5353
  * Provides methods to get the agent's function definition and features.
4782
5354
  */
4783
- interface AxAgentic<IN extends AxGenIn, OUT extends AxGenOut> extends AxTunable<IN, OUT>, AxUsable {
5355
+ interface AxAgentic<IN extends AxGenIn, OUT extends AxGenOut> extends AxProgrammable<IN, OUT> {
4784
5356
  getFunction(): AxFunction;
4785
5357
  getFeatures(): AxAgentFeatures;
4786
5358
  }
@@ -4846,6 +5418,8 @@ declare class AxAgent<IN extends AxGenIn, OUT extends AxGenOut> implements AxAge
4846
5418
  */
4847
5419
  setDescription(description: string): void;
4848
5420
  setDefinition(definition: string): void;
5421
+ getSignature(): AxSignature;
5422
+ setSignature(signature: NonNullable<ConstructorParameters<typeof AxSignature>[0]>): void;
4849
5423
  private getDebug;
4850
5424
  }
4851
5425
 
@@ -4949,4 +5523,4 @@ declare class AxRateLimiterTokenUsage {
4949
5523
  acquire(tokens: number): Promise<void>;
4950
5524
  }
4951
5525
 
4952
- 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, type AxAIPromptConfig, 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, AxAIServiceNetworkError, type AxAIServiceOptions, AxAIServiceResponseError, AxAIServiceStatusError, AxAIServiceStreamTerminatedError, AxAIServiceTimeoutError, AxAITogether, type AxAITogetherArgs, 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, AxFlowTypedSubContextImpl, 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 AxLoggerFunction, type AxLoggerTag, AxMCPClient, AxMCPHTTPSSETransport, type AxMCPStreamableHTTPTransportOptions, AxMCPStreambleHTTPTransport, 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 AxOptimizerMetricsConfig, type AxOptimizerMetricsInstruments, type AxOptimizerResult, type AxParetoResult, AxProgram, type AxProgramDemos, type AxProgramExamples, type AxProgramForwardOptions, type AxProgramOptions, type AxProgramStreamingForwardOptions, type AxProgramTrace, type AxProgramUsage, 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, axBaseAIDefaultConfig, axBaseAIDefaultCreativeConfig, axCheckMetricsHealth, axCreateDefaultColorLogger, axCreateDefaultTextLogger, axCreateOptimizerLogger, axDefaultMetricsConfig, axDefaultOptimizerLogger, axDefaultOptimizerMetricsConfig, axGetMetricsConfig, axGetOptimizerMetricsConfig, axGlobals, axModelInfoAnthropic, axModelInfoCohere, axModelInfoDeepSeek, axModelInfoGoogleGemini, axModelInfoGrok, axModelInfoGroq, axModelInfoHuggingFace, axModelInfoMistral, axModelInfoOpenAI, axModelInfoOpenAIResponses, axModelInfoReka, axModelInfoTogether, axSpanAttributes, axSpanEvents, axUpdateMetricsConfig, axUpdateOptimizerMetricsConfig, axValidateChatRequestMessage, axValidateChatResponseResult, f, s };
5526
+ 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, type AxAIPromptConfig, 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, AxAIServiceNetworkError, type AxAIServiceOptions, AxAIServiceResponseError, AxAIServiceStatusError, AxAIServiceStreamTerminatedError, AxAIServiceTimeoutError, AxAITogether, type AxAITogetherArgs, 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 AxProgramOptions, type AxProgramStreamingForwardOptions, 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, 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, axSpanAttributes, axSpanEvents, axUpdateMetricsConfig, axUpdateOptimizerMetricsConfig, axValidateChatRequestMessage, axValidateChatResponseResult, f, s };