@ax-llm/ax 21.0.14 → 22.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -4
- package/index.cjs +457 -486
- package/index.cjs.map +1 -1
- package/index.d.cts +759 -3061
- package/index.d.ts +759 -3061
- package/index.global.js +455 -484
- package/index.global.js.map +1 -1
- package/index.js +457 -486
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/ax-agent-memory-skills.md +1 -1
- package/skills/ax-agent-observability.md +4 -4
- package/skills/ax-agent-optimize.md +1 -1
- package/skills/ax-agent-rlm.md +28 -8
- package/skills/ax-agent.md +27 -7
- package/skills/ax-ai.md +28 -12
- package/skills/ax-audio.md +1 -1
- package/skills/ax-flow.md +13 -5
- package/skills/ax-gen.md +35 -18
- package/skills/ax-gepa.md +1 -1
- package/skills/ax-llm.md +17 -9
- package/skills/ax-refine.md +81 -0
- package/skills/ax-signature.md +1 -1
- package/skills/ax-learn.md +0 -268
package/index.d.ts
CHANGED
|
@@ -86,9 +86,11 @@ declare class AxAIRefusalError extends Error {
|
|
|
86
86
|
readonly refusalMessage: string;
|
|
87
87
|
readonly model?: string | undefined;
|
|
88
88
|
readonly requestId?: string | undefined;
|
|
89
|
+
readonly category?: string | null | undefined;
|
|
90
|
+
readonly explanation?: string | null | undefined;
|
|
89
91
|
readonly timestamp: string;
|
|
90
92
|
readonly errorId: string;
|
|
91
|
-
constructor(refusalMessage: string, model?: string | undefined, requestId?: string | undefined);
|
|
93
|
+
constructor(refusalMessage: string, model?: string | undefined, requestId?: string | undefined, category?: string | null | undefined, explanation?: string | null | undefined);
|
|
92
94
|
toString(): string;
|
|
93
95
|
}
|
|
94
96
|
/**
|
|
@@ -505,6 +507,14 @@ type AxModelInfo = {
|
|
|
505
507
|
longContextCacheReadTokenCostPer1M?: number;
|
|
506
508
|
/** Total input token count (including cached) above which long-context rates apply */
|
|
507
509
|
longContextThreshold?: number;
|
|
510
|
+
/** Prompt token cost when a provider speed tier such as Anthropic fast mode is active. */
|
|
511
|
+
fastPromptTokenCostPer1M?: number;
|
|
512
|
+
/** Completion token cost when a provider speed tier such as Anthropic fast mode is active. */
|
|
513
|
+
fastCompletionTokenCostPer1M?: number;
|
|
514
|
+
/** Cache read token cost when a provider speed tier such as Anthropic fast mode is active. */
|
|
515
|
+
fastCacheReadTokenCostPer1M?: number;
|
|
516
|
+
/** Cache write token cost when a provider speed tier such as Anthropic fast mode is active. */
|
|
517
|
+
fastCacheWriteTokenCostPer1M?: number;
|
|
508
518
|
aliases?: string[];
|
|
509
519
|
supported?: {
|
|
510
520
|
thinkingBudget?: boolean;
|
|
@@ -535,6 +545,7 @@ type AxTokenUsage = {
|
|
|
535
545
|
cacheCreationTokens?: number;
|
|
536
546
|
cacheReadTokens?: number;
|
|
537
547
|
serviceTier?: 'standard' | 'priority' | 'batch';
|
|
548
|
+
speed?: 'standard' | 'fast';
|
|
538
549
|
};
|
|
539
550
|
/**
|
|
540
551
|
* Configuration options for AI model behavior.
|
|
@@ -659,6 +670,16 @@ type AxModelConfig = {
|
|
|
659
670
|
* @example 3 to generate three alternatives and pick the best
|
|
660
671
|
*/
|
|
661
672
|
n?: number;
|
|
673
|
+
/** Provider reasoning/effort hint. Currently used by Anthropic. */
|
|
674
|
+
effort?: 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
675
|
+
/** Provider speed tier. Currently used by Anthropic fast mode. */
|
|
676
|
+
speed?: 'standard' | 'fast';
|
|
677
|
+
/** Advisory full-task token budget. Currently used by Anthropic Opus task budgets. */
|
|
678
|
+
taskBudget?: {
|
|
679
|
+
type: 'tokens';
|
|
680
|
+
total: number;
|
|
681
|
+
remaining?: number;
|
|
682
|
+
};
|
|
662
683
|
};
|
|
663
684
|
type AxFunctionHandler = (args?: any, extra?: Readonly<{
|
|
664
685
|
sessionId?: string;
|
|
@@ -972,17 +993,11 @@ interface AxAIServiceMetrics {
|
|
|
972
993
|
};
|
|
973
994
|
}
|
|
974
995
|
type AxInternalChatRequest<TModel> = Omit<AxChatRequest, 'model'> & Required<Pick<AxChatRequest<TModel>, 'model'>>;
|
|
975
|
-
type AxInternalTranscriptionRequest<TModel> = Omit<AxTranscriptionRequest, 'model'> & {
|
|
976
|
-
model?: TModel;
|
|
977
|
-
};
|
|
978
996
|
type AxEmbedRequest<TEmbedModel = string> = {
|
|
979
997
|
texts?: readonly string[];
|
|
980
998
|
embedModel?: TEmbedModel;
|
|
981
999
|
};
|
|
982
1000
|
type AxInternalEmbedRequest<TEmbedModel> = Omit<AxEmbedRequest, 'embedModel'> & Required<Pick<AxEmbedRequest<TEmbedModel>, 'embedModel'>>;
|
|
983
|
-
type AxInternalSpeechRequest<TModel> = Omit<AxSpeechRequest, 'model'> & {
|
|
984
|
-
model?: TModel;
|
|
985
|
-
};
|
|
986
1001
|
type AxRateLimiterFunction = <T = unknown>(reqFunc: () => Promise<T | ReadableStream<T>>, info: Readonly<{
|
|
987
1002
|
modelUsage?: AxModelUsage;
|
|
988
1003
|
}>) => Promise<T | ReadableStream<T>>;
|
|
@@ -1016,11 +1031,6 @@ type AxLoggerData = {
|
|
|
1016
1031
|
index: number;
|
|
1017
1032
|
fixingInstructions: string;
|
|
1018
1033
|
error: unknown;
|
|
1019
|
-
} | {
|
|
1020
|
-
name: 'AssertionError';
|
|
1021
|
-
index: number;
|
|
1022
|
-
fixingInstructions: string;
|
|
1023
|
-
error: unknown;
|
|
1024
1034
|
} | {
|
|
1025
1035
|
name: 'RefusalError';
|
|
1026
1036
|
index: number;
|
|
@@ -1305,15 +1315,6 @@ type AxAIServiceOptions = {
|
|
|
1305
1315
|
* **Currently supported by:** Google Gemini/Vertex AI
|
|
1306
1316
|
*/
|
|
1307
1317
|
contextCache?: AxContextCacheOptions;
|
|
1308
|
-
/**
|
|
1309
|
-
* Render examples/demos in the system prompt instead of as message pairs.
|
|
1310
|
-
*
|
|
1311
|
-
* - `false` (default) - Examples rendered as alternating user/assistant messages
|
|
1312
|
-
* - `true` - Examples embedded in system prompt (legacy behavior)
|
|
1313
|
-
*
|
|
1314
|
-
* Message pair rendering generally produces better results.
|
|
1315
|
-
*/
|
|
1316
|
-
examplesInSystem?: boolean;
|
|
1317
1318
|
/**
|
|
1318
1319
|
* Custom labels for OpenTelemetry metrics.
|
|
1319
1320
|
*
|
|
@@ -1455,6 +1456,224 @@ interface AxAIMemory {
|
|
|
1455
1456
|
removeByTag(name: string, sessionId?: string): AxMemoryData;
|
|
1456
1457
|
}
|
|
1457
1458
|
|
|
1459
|
+
declare class AxMemory implements AxAIMemory {
|
|
1460
|
+
private memories;
|
|
1461
|
+
private defaultMemory;
|
|
1462
|
+
constructor();
|
|
1463
|
+
private getMemory;
|
|
1464
|
+
addRequest(value: AxChatRequest['chatPrompt'], sessionId?: string): void;
|
|
1465
|
+
addResponse(results: Readonly<AxChatResponseResult[]>, sessionId?: string): void;
|
|
1466
|
+
addFunctionResults(results: Readonly<AxFunctionResult[]>, sessionId?: string): void;
|
|
1467
|
+
updateResult(result: Readonly<AxChatResponseResult & {
|
|
1468
|
+
delta?: string;
|
|
1469
|
+
}>, sessionId?: string): void;
|
|
1470
|
+
addTag(name: string, sessionId?: string): void;
|
|
1471
|
+
rewindToTag(name: string, sessionId?: string): AxMemoryData;
|
|
1472
|
+
removeByTag(name: string, sessionId?: string): AxMemoryData;
|
|
1473
|
+
history(index: number, sessionId?: string): ({
|
|
1474
|
+
role: "system";
|
|
1475
|
+
content: string;
|
|
1476
|
+
cache?: boolean;
|
|
1477
|
+
} | {
|
|
1478
|
+
role: "user";
|
|
1479
|
+
name?: string;
|
|
1480
|
+
content: string | ({
|
|
1481
|
+
type: "text";
|
|
1482
|
+
text: string;
|
|
1483
|
+
cache?: boolean;
|
|
1484
|
+
} | {
|
|
1485
|
+
type: "image";
|
|
1486
|
+
mimeType: string;
|
|
1487
|
+
image: string;
|
|
1488
|
+
details?: "high" | "low" | "auto";
|
|
1489
|
+
cache?: boolean;
|
|
1490
|
+
optimize?: "quality" | "size" | "auto";
|
|
1491
|
+
altText?: string;
|
|
1492
|
+
} | {
|
|
1493
|
+
type: "audio";
|
|
1494
|
+
data: string;
|
|
1495
|
+
format?: AxAudioFormat;
|
|
1496
|
+
mimeType?: string;
|
|
1497
|
+
sampleRate?: number;
|
|
1498
|
+
channels?: number;
|
|
1499
|
+
cache?: boolean;
|
|
1500
|
+
transcription?: string;
|
|
1501
|
+
duration?: number;
|
|
1502
|
+
} | {
|
|
1503
|
+
type: "file";
|
|
1504
|
+
data: string;
|
|
1505
|
+
filename?: string;
|
|
1506
|
+
mimeType: string;
|
|
1507
|
+
cache?: boolean;
|
|
1508
|
+
extractedText?: string;
|
|
1509
|
+
} | {
|
|
1510
|
+
type: "file";
|
|
1511
|
+
fileUri: string;
|
|
1512
|
+
filename?: string;
|
|
1513
|
+
mimeType: string;
|
|
1514
|
+
cache?: boolean;
|
|
1515
|
+
extractedText?: string;
|
|
1516
|
+
} | {
|
|
1517
|
+
type: "url";
|
|
1518
|
+
url: string;
|
|
1519
|
+
cache?: boolean;
|
|
1520
|
+
cachedContent?: string;
|
|
1521
|
+
title?: string;
|
|
1522
|
+
description?: string;
|
|
1523
|
+
})[];
|
|
1524
|
+
cache?: boolean;
|
|
1525
|
+
} | {
|
|
1526
|
+
role: "assistant";
|
|
1527
|
+
content?: string;
|
|
1528
|
+
name?: string;
|
|
1529
|
+
functionCalls?: {
|
|
1530
|
+
id: string;
|
|
1531
|
+
type: "function";
|
|
1532
|
+
function: {
|
|
1533
|
+
name: string;
|
|
1534
|
+
params?: string | object;
|
|
1535
|
+
};
|
|
1536
|
+
}[];
|
|
1537
|
+
thought?: string;
|
|
1538
|
+
thoughtBlocks?: AxThoughtBlockItem[];
|
|
1539
|
+
audio?: {
|
|
1540
|
+
id: string;
|
|
1541
|
+
transcript?: string;
|
|
1542
|
+
};
|
|
1543
|
+
cache?: boolean;
|
|
1544
|
+
} | {
|
|
1545
|
+
role: "function";
|
|
1546
|
+
result: string;
|
|
1547
|
+
isError?: boolean;
|
|
1548
|
+
functionId: string;
|
|
1549
|
+
cache?: boolean;
|
|
1550
|
+
})[];
|
|
1551
|
+
getLast(sessionId?: string): {
|
|
1552
|
+
tags?: string[];
|
|
1553
|
+
role: AxChatRequest["chatPrompt"][number]["role"];
|
|
1554
|
+
updatable?: boolean;
|
|
1555
|
+
chat: {
|
|
1556
|
+
index: number;
|
|
1557
|
+
value: AxMemoryMessageValue;
|
|
1558
|
+
}[];
|
|
1559
|
+
} | undefined;
|
|
1560
|
+
reset(sessionId?: string): void;
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
/**
|
|
1564
|
+
* Internal implementation of AxStepContext.
|
|
1565
|
+
* Uses a pending mutations pattern: mutations are collected during a step
|
|
1566
|
+
* and consumed/applied at the next step boundary.
|
|
1567
|
+
*/
|
|
1568
|
+
declare class AxStepContextImpl implements AxStepContext {
|
|
1569
|
+
private _stepIndex;
|
|
1570
|
+
readonly maxSteps: number;
|
|
1571
|
+
private _functionsExecuted;
|
|
1572
|
+
private _lastFunctionCalls;
|
|
1573
|
+
private _usage;
|
|
1574
|
+
readonly state: Map<string, unknown>;
|
|
1575
|
+
private _pendingOptions;
|
|
1576
|
+
private _functionsToAdd;
|
|
1577
|
+
private _functionsToRemove;
|
|
1578
|
+
private _stopRequested;
|
|
1579
|
+
private _stopResultValues?;
|
|
1580
|
+
constructor(maxSteps: number);
|
|
1581
|
+
get stepIndex(): number;
|
|
1582
|
+
get isFirstStep(): boolean;
|
|
1583
|
+
get functionsExecuted(): ReadonlySet<string>;
|
|
1584
|
+
get lastFunctionCalls(): readonly AxFunctionCallRecord[];
|
|
1585
|
+
get usage(): Readonly<AxStepUsage>;
|
|
1586
|
+
setModel(model: string): void;
|
|
1587
|
+
setThinkingBudget(budget: AxAIServiceOptions['thinkingTokenBudget']): void;
|
|
1588
|
+
setTemperature(temperature: number): void;
|
|
1589
|
+
setMaxTokens(maxTokens: number): void;
|
|
1590
|
+
setOptions(options: Partial<AxAIServiceOptions & {
|
|
1591
|
+
modelConfig?: Partial<AxModelConfig>;
|
|
1592
|
+
}>): void;
|
|
1593
|
+
addFunctions(functions: AxInputFunctionType): void;
|
|
1594
|
+
removeFunctions(...names: string[]): void;
|
|
1595
|
+
stop(resultValues?: Record<string, unknown>): void;
|
|
1596
|
+
/** Reset per-step state at the beginning of a new step. */
|
|
1597
|
+
_beginStep(stepIndex: number): void;
|
|
1598
|
+
/** Record a function call that was executed during this step. */
|
|
1599
|
+
_recordFunctionCall(name: string, args: unknown, result: unknown): void;
|
|
1600
|
+
/** Accumulate token usage from a completed step. */
|
|
1601
|
+
_addUsage(promptTokens: number, completionTokens: number, totalTokens: number): void;
|
|
1602
|
+
/** Consume and clear pending options. Returns undefined if no pending options. */
|
|
1603
|
+
_consumePendingOptions(): Partial<AxAIServiceOptions & {
|
|
1604
|
+
modelConfig?: Partial<AxModelConfig>;
|
|
1605
|
+
model?: string;
|
|
1606
|
+
}> | undefined;
|
|
1607
|
+
/** Consume and clear pending functions to add. */
|
|
1608
|
+
_consumeFunctionsToAdd(): AxInputFunctionType | undefined;
|
|
1609
|
+
/** Consume and clear pending function names to remove. */
|
|
1610
|
+
_consumeFunctionsToRemove(): string[] | undefined;
|
|
1611
|
+
/** Check if stop was requested. */
|
|
1612
|
+
get _isStopRequested(): boolean;
|
|
1613
|
+
/** Get stop result values if any. */
|
|
1614
|
+
get _stopValues(): Record<string, unknown> | undefined;
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
declare class AxStopFunctionCallException extends Error {
|
|
1618
|
+
readonly calls: ReadonlyArray<{
|
|
1619
|
+
func: Readonly<AxFunction>;
|
|
1620
|
+
args: unknown;
|
|
1621
|
+
result: unknown;
|
|
1622
|
+
}>;
|
|
1623
|
+
constructor(calls: ReadonlyArray<{
|
|
1624
|
+
func: Readonly<AxFunction>;
|
|
1625
|
+
args: unknown;
|
|
1626
|
+
result: unknown;
|
|
1627
|
+
}>);
|
|
1628
|
+
}
|
|
1629
|
+
declare class AxFunctionError extends Error {
|
|
1630
|
+
private fields;
|
|
1631
|
+
constructor(fields: {
|
|
1632
|
+
field: string;
|
|
1633
|
+
message: string;
|
|
1634
|
+
}[]);
|
|
1635
|
+
getFields: () => {
|
|
1636
|
+
field: string;
|
|
1637
|
+
message: string;
|
|
1638
|
+
}[];
|
|
1639
|
+
toString(): string;
|
|
1640
|
+
}
|
|
1641
|
+
type AxChatResponseFunctionCall = {
|
|
1642
|
+
id: string;
|
|
1643
|
+
name: string;
|
|
1644
|
+
args: string;
|
|
1645
|
+
};
|
|
1646
|
+
declare class AxFunctionProcessor {
|
|
1647
|
+
private funcList;
|
|
1648
|
+
constructor(funcList: Readonly<AxFunction[]>);
|
|
1649
|
+
private executeFunction;
|
|
1650
|
+
executeWithDetails: <MODEL>(func: Readonly<AxChatResponseFunctionCall>, options?: Readonly<AxProgramForwardOptions<MODEL> & {
|
|
1651
|
+
traceId?: string;
|
|
1652
|
+
stopFunctionNames?: readonly string[];
|
|
1653
|
+
step?: AxStepContextImpl;
|
|
1654
|
+
}>) => Promise<{
|
|
1655
|
+
formatted: string;
|
|
1656
|
+
rawResult: unknown;
|
|
1657
|
+
parsedArgs: unknown;
|
|
1658
|
+
}>;
|
|
1659
|
+
execute: <MODEL>(func: Readonly<AxChatResponseFunctionCall>, options?: Readonly<AxProgramForwardOptions<MODEL> & {
|
|
1660
|
+
traceId?: string;
|
|
1661
|
+
stopFunctionNames?: readonly string[];
|
|
1662
|
+
step?: AxStepContextImpl;
|
|
1663
|
+
}>) => Promise<string>;
|
|
1664
|
+
}
|
|
1665
|
+
type AxInputFunctionType = (AxFunction | {
|
|
1666
|
+
toFunction: () => AxFunction | AxFunction[];
|
|
1667
|
+
})[];
|
|
1668
|
+
|
|
1669
|
+
type AxPromptMetrics = {
|
|
1670
|
+
systemPromptCharacters: number;
|
|
1671
|
+
exampleChatContextCharacters: number;
|
|
1672
|
+
mutableChatContextCharacters: number;
|
|
1673
|
+
chatContextCharacters: number;
|
|
1674
|
+
totalPromptCharacters: number;
|
|
1675
|
+
};
|
|
1676
|
+
|
|
1458
1677
|
/** The Standard Schema v1 interface. Structurally compatible with `@standard-schema/spec`. */
|
|
1459
1678
|
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
1460
1679
|
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
|
@@ -2218,8 +2437,6 @@ declare class AxFunctionBuilder<TArgs extends Record<string, any> = {}, TReturn
|
|
|
2218
2437
|
arg<T extends StandardSchemaV1>(schema: T, opts?: {
|
|
2219
2438
|
fields?: Record<string, AxFieldOptions>;
|
|
2220
2439
|
}): AxFunctionBuilder<AsRecord<StandardSchemaV1.InferOutput<T>>, TReturn, THasExamples>;
|
|
2221
|
-
/** @deprecated Alias for {@link AxFunctionBuilder.arg}. */
|
|
2222
|
-
args<K extends string, T extends AxFluentFieldInfo<any, any, any, any, any, any, any> | AxFluentFieldType<any, any, any, any, any, any, any>>(name: K, fieldInfo: T): AxFunctionBuilder<AddFieldToShape<TArgs, K, T>, TReturn, THasExamples>;
|
|
2223
2440
|
/**
|
|
2224
2441
|
* Declare the tool return shape. Two shapes:
|
|
2225
2442
|
*
|
|
@@ -2273,6 +2490,7 @@ interface AxSignatureConfig {
|
|
|
2273
2490
|
inputs: readonly AxField[];
|
|
2274
2491
|
outputs: readonly AxField[];
|
|
2275
2492
|
}
|
|
2493
|
+
type AxSignatureInput = Readonly<AxSignature | string | AxSignatureConfig>;
|
|
2276
2494
|
declare class AxSignature<_TInput extends Record<string, any> = Record<string, any>, _TOutput extends Record<string, any> = Record<string, any>> {
|
|
2277
2495
|
private description?;
|
|
2278
2496
|
private inputFields;
|
|
@@ -2280,27 +2498,14 @@ declare class AxSignature<_TInput extends Record<string, any> = Record<string, a
|
|
|
2280
2498
|
private sigHash;
|
|
2281
2499
|
private sigString;
|
|
2282
2500
|
private validatedAtHash?;
|
|
2283
|
-
|
|
2284
|
-
* @deprecated Use `AxSignature.create()` for better type safety instead of the constructor.
|
|
2285
|
-
* This constructor will be removed in v15.0.0.
|
|
2286
|
-
*
|
|
2287
|
-
* Migration timeline:
|
|
2288
|
-
* - v13.0.24+: Deprecation warnings (current)
|
|
2289
|
-
* - v14.0.0: Runtime console warnings
|
|
2290
|
-
* - v15.0.0: Complete removal
|
|
2291
|
-
*
|
|
2292
|
-
* @example
|
|
2293
|
-
* ```typescript
|
|
2294
|
-
* // Instead of: new AxSignature('userInput:string -> responseText:string')
|
|
2295
|
-
* // Use: AxSignature.create('userInput:string -> responseText:string')
|
|
2296
|
-
* ```
|
|
2297
|
-
*/
|
|
2298
|
-
constructor(signature?: Readonly<AxSignature | string | AxSignatureConfig>);
|
|
2501
|
+
private constructor();
|
|
2299
2502
|
/**
|
|
2300
2503
|
* Static factory method for type inference.
|
|
2301
2504
|
* Creates a typed AxSignature instance from a signature string.
|
|
2302
2505
|
*/
|
|
2303
2506
|
static create<const T extends string>(signature: T): AxSignature<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>;
|
|
2507
|
+
static from<TInput extends Record<string, any> = Record<string, any>, TOutput extends Record<string, any> = Record<string, any>>(signature?: AxSignatureInput): AxSignature<TInput, TOutput>;
|
|
2508
|
+
static empty(): AxSignature;
|
|
2304
2509
|
private parseParsedField;
|
|
2305
2510
|
private parseField;
|
|
2306
2511
|
setDescription: (desc: string) => void;
|
|
@@ -2337,245 +2542,18 @@ declare class AxSignature<_TInput extends Record<string, any> = Record<string, a
|
|
|
2337
2542
|
toInputJSONSchema: () => AxFunctionJSONSchema;
|
|
2338
2543
|
}
|
|
2339
2544
|
|
|
2340
|
-
interface
|
|
2341
|
-
fn(values: T): Promise<boolean | string | undefined> | boolean | string | undefined;
|
|
2342
|
-
message?: string;
|
|
2343
|
-
}
|
|
2344
|
-
interface AxStreamingAssertion {
|
|
2545
|
+
interface AxStreamingGuard {
|
|
2345
2546
|
fieldName: string;
|
|
2346
|
-
fn(content: string, done?: boolean): boolean | string | undefined;
|
|
2547
|
+
fn(content: string, done?: boolean): Promise<boolean | string | undefined> | boolean | string | undefined;
|
|
2347
2548
|
message?: string;
|
|
2348
2549
|
}
|
|
2349
|
-
declare class
|
|
2550
|
+
declare class AxStreamingGuardError extends Error {
|
|
2350
2551
|
constructor({ message, }: Readonly<{
|
|
2351
2552
|
message: string;
|
|
2352
2553
|
}>);
|
|
2353
|
-
getFixingInstructions: () => {
|
|
2354
|
-
name: string;
|
|
2355
|
-
title: string;
|
|
2356
|
-
description: string;
|
|
2357
|
-
}[];
|
|
2358
2554
|
toString(): string;
|
|
2359
2555
|
}
|
|
2360
2556
|
|
|
2361
|
-
declare class AxMemory implements AxAIMemory {
|
|
2362
|
-
private memories;
|
|
2363
|
-
private defaultMemory;
|
|
2364
|
-
constructor();
|
|
2365
|
-
private getMemory;
|
|
2366
|
-
addRequest(value: AxChatRequest['chatPrompt'], sessionId?: string): void;
|
|
2367
|
-
addResponse(results: Readonly<AxChatResponseResult[]>, sessionId?: string): void;
|
|
2368
|
-
addFunctionResults(results: Readonly<AxFunctionResult[]>, sessionId?: string): void;
|
|
2369
|
-
updateResult(result: Readonly<AxChatResponseResult & {
|
|
2370
|
-
delta?: string;
|
|
2371
|
-
}>, sessionId?: string): void;
|
|
2372
|
-
addTag(name: string, sessionId?: string): void;
|
|
2373
|
-
rewindToTag(name: string, sessionId?: string): AxMemoryData;
|
|
2374
|
-
removeByTag(name: string, sessionId?: string): AxMemoryData;
|
|
2375
|
-
history(index: number, sessionId?: string): ({
|
|
2376
|
-
role: "system";
|
|
2377
|
-
content: string;
|
|
2378
|
-
cache?: boolean;
|
|
2379
|
-
} | {
|
|
2380
|
-
role: "user";
|
|
2381
|
-
name?: string;
|
|
2382
|
-
content: string | ({
|
|
2383
|
-
type: "text";
|
|
2384
|
-
text: string;
|
|
2385
|
-
cache?: boolean;
|
|
2386
|
-
} | {
|
|
2387
|
-
type: "image";
|
|
2388
|
-
mimeType: string;
|
|
2389
|
-
image: string;
|
|
2390
|
-
details?: "high" | "low" | "auto";
|
|
2391
|
-
cache?: boolean;
|
|
2392
|
-
optimize?: "quality" | "size" | "auto";
|
|
2393
|
-
altText?: string;
|
|
2394
|
-
} | {
|
|
2395
|
-
type: "audio";
|
|
2396
|
-
data: string;
|
|
2397
|
-
format?: AxAudioFormat;
|
|
2398
|
-
mimeType?: string;
|
|
2399
|
-
sampleRate?: number;
|
|
2400
|
-
channels?: number;
|
|
2401
|
-
cache?: boolean;
|
|
2402
|
-
transcription?: string;
|
|
2403
|
-
duration?: number;
|
|
2404
|
-
} | {
|
|
2405
|
-
type: "file";
|
|
2406
|
-
data: string;
|
|
2407
|
-
filename?: string;
|
|
2408
|
-
mimeType: string;
|
|
2409
|
-
cache?: boolean;
|
|
2410
|
-
extractedText?: string;
|
|
2411
|
-
} | {
|
|
2412
|
-
type: "file";
|
|
2413
|
-
fileUri: string;
|
|
2414
|
-
filename?: string;
|
|
2415
|
-
mimeType: string;
|
|
2416
|
-
cache?: boolean;
|
|
2417
|
-
extractedText?: string;
|
|
2418
|
-
} | {
|
|
2419
|
-
type: "url";
|
|
2420
|
-
url: string;
|
|
2421
|
-
cache?: boolean;
|
|
2422
|
-
cachedContent?: string;
|
|
2423
|
-
title?: string;
|
|
2424
|
-
description?: string;
|
|
2425
|
-
})[];
|
|
2426
|
-
cache?: boolean;
|
|
2427
|
-
} | {
|
|
2428
|
-
role: "assistant";
|
|
2429
|
-
content?: string;
|
|
2430
|
-
name?: string;
|
|
2431
|
-
functionCalls?: {
|
|
2432
|
-
id: string;
|
|
2433
|
-
type: "function";
|
|
2434
|
-
function: {
|
|
2435
|
-
name: string;
|
|
2436
|
-
params?: string | object;
|
|
2437
|
-
};
|
|
2438
|
-
}[];
|
|
2439
|
-
thought?: string;
|
|
2440
|
-
thoughtBlocks?: AxThoughtBlockItem[];
|
|
2441
|
-
audio?: {
|
|
2442
|
-
id: string;
|
|
2443
|
-
transcript?: string;
|
|
2444
|
-
};
|
|
2445
|
-
cache?: boolean;
|
|
2446
|
-
} | {
|
|
2447
|
-
role: "function";
|
|
2448
|
-
result: string;
|
|
2449
|
-
isError?: boolean;
|
|
2450
|
-
functionId: string;
|
|
2451
|
-
cache?: boolean;
|
|
2452
|
-
})[];
|
|
2453
|
-
getLast(sessionId?: string): {
|
|
2454
|
-
tags?: string[];
|
|
2455
|
-
role: AxChatRequest["chatPrompt"][number]["role"];
|
|
2456
|
-
updatable?: boolean;
|
|
2457
|
-
chat: {
|
|
2458
|
-
index: number;
|
|
2459
|
-
value: AxMemoryMessageValue;
|
|
2460
|
-
}[];
|
|
2461
|
-
} | undefined;
|
|
2462
|
-
reset(sessionId?: string): void;
|
|
2463
|
-
}
|
|
2464
|
-
|
|
2465
|
-
/**
|
|
2466
|
-
* Internal implementation of AxStepContext.
|
|
2467
|
-
* Uses a pending mutations pattern: mutations are collected during a step
|
|
2468
|
-
* and consumed/applied at the next step boundary.
|
|
2469
|
-
*/
|
|
2470
|
-
declare class AxStepContextImpl implements AxStepContext {
|
|
2471
|
-
private _stepIndex;
|
|
2472
|
-
readonly maxSteps: number;
|
|
2473
|
-
private _functionsExecuted;
|
|
2474
|
-
private _lastFunctionCalls;
|
|
2475
|
-
private _usage;
|
|
2476
|
-
readonly state: Map<string, unknown>;
|
|
2477
|
-
private _pendingOptions;
|
|
2478
|
-
private _functionsToAdd;
|
|
2479
|
-
private _functionsToRemove;
|
|
2480
|
-
private _stopRequested;
|
|
2481
|
-
private _stopResultValues?;
|
|
2482
|
-
constructor(maxSteps: number);
|
|
2483
|
-
get stepIndex(): number;
|
|
2484
|
-
get isFirstStep(): boolean;
|
|
2485
|
-
get functionsExecuted(): ReadonlySet<string>;
|
|
2486
|
-
get lastFunctionCalls(): readonly AxFunctionCallRecord[];
|
|
2487
|
-
get usage(): Readonly<AxStepUsage>;
|
|
2488
|
-
setModel(model: string): void;
|
|
2489
|
-
setThinkingBudget(budget: AxAIServiceOptions['thinkingTokenBudget']): void;
|
|
2490
|
-
setTemperature(temperature: number): void;
|
|
2491
|
-
setMaxTokens(maxTokens: number): void;
|
|
2492
|
-
setOptions(options: Partial<AxAIServiceOptions & {
|
|
2493
|
-
modelConfig?: Partial<AxModelConfig>;
|
|
2494
|
-
}>): void;
|
|
2495
|
-
addFunctions(functions: AxInputFunctionType): void;
|
|
2496
|
-
removeFunctions(...names: string[]): void;
|
|
2497
|
-
stop(resultValues?: Record<string, unknown>): void;
|
|
2498
|
-
/** Reset per-step state at the beginning of a new step. */
|
|
2499
|
-
_beginStep(stepIndex: number): void;
|
|
2500
|
-
/** Record a function call that was executed during this step. */
|
|
2501
|
-
_recordFunctionCall(name: string, args: unknown, result: unknown): void;
|
|
2502
|
-
/** Accumulate token usage from a completed step. */
|
|
2503
|
-
_addUsage(promptTokens: number, completionTokens: number, totalTokens: number): void;
|
|
2504
|
-
/** Consume and clear pending options. Returns undefined if no pending options. */
|
|
2505
|
-
_consumePendingOptions(): Partial<AxAIServiceOptions & {
|
|
2506
|
-
modelConfig?: Partial<AxModelConfig>;
|
|
2507
|
-
model?: string;
|
|
2508
|
-
}> | undefined;
|
|
2509
|
-
/** Consume and clear pending functions to add. */
|
|
2510
|
-
_consumeFunctionsToAdd(): AxInputFunctionType | undefined;
|
|
2511
|
-
/** Consume and clear pending function names to remove. */
|
|
2512
|
-
_consumeFunctionsToRemove(): string[] | undefined;
|
|
2513
|
-
/** Check if stop was requested. */
|
|
2514
|
-
get _isStopRequested(): boolean;
|
|
2515
|
-
/** Get stop result values if any. */
|
|
2516
|
-
get _stopValues(): Record<string, unknown> | undefined;
|
|
2517
|
-
}
|
|
2518
|
-
|
|
2519
|
-
declare class AxStopFunctionCallException extends Error {
|
|
2520
|
-
readonly calls: ReadonlyArray<{
|
|
2521
|
-
func: Readonly<AxFunction>;
|
|
2522
|
-
args: unknown;
|
|
2523
|
-
result: unknown;
|
|
2524
|
-
}>;
|
|
2525
|
-
constructor(calls: ReadonlyArray<{
|
|
2526
|
-
func: Readonly<AxFunction>;
|
|
2527
|
-
args: unknown;
|
|
2528
|
-
result: unknown;
|
|
2529
|
-
}>);
|
|
2530
|
-
}
|
|
2531
|
-
declare class AxFunctionError extends Error {
|
|
2532
|
-
private fields;
|
|
2533
|
-
constructor(fields: {
|
|
2534
|
-
field: string;
|
|
2535
|
-
message: string;
|
|
2536
|
-
}[]);
|
|
2537
|
-
getFields: () => {
|
|
2538
|
-
field: string;
|
|
2539
|
-
message: string;
|
|
2540
|
-
}[];
|
|
2541
|
-
toString(): string;
|
|
2542
|
-
}
|
|
2543
|
-
type AxChatResponseFunctionCall = {
|
|
2544
|
-
id: string;
|
|
2545
|
-
name: string;
|
|
2546
|
-
args: string;
|
|
2547
|
-
};
|
|
2548
|
-
declare class AxFunctionProcessor {
|
|
2549
|
-
private funcList;
|
|
2550
|
-
constructor(funcList: Readonly<AxFunction[]>);
|
|
2551
|
-
private executeFunction;
|
|
2552
|
-
executeWithDetails: <MODEL>(func: Readonly<AxChatResponseFunctionCall>, options?: Readonly<AxProgramForwardOptions<MODEL> & {
|
|
2553
|
-
traceId?: string;
|
|
2554
|
-
stopFunctionNames?: readonly string[];
|
|
2555
|
-
step?: AxStepContextImpl;
|
|
2556
|
-
}>) => Promise<{
|
|
2557
|
-
formatted: string;
|
|
2558
|
-
rawResult: unknown;
|
|
2559
|
-
parsedArgs: unknown;
|
|
2560
|
-
}>;
|
|
2561
|
-
execute: <MODEL>(func: Readonly<AxChatResponseFunctionCall>, options?: Readonly<AxProgramForwardOptions<MODEL> & {
|
|
2562
|
-
traceId?: string;
|
|
2563
|
-
stopFunctionNames?: readonly string[];
|
|
2564
|
-
step?: AxStepContextImpl;
|
|
2565
|
-
}>) => Promise<string>;
|
|
2566
|
-
}
|
|
2567
|
-
type AxInputFunctionType = (AxFunction | {
|
|
2568
|
-
toFunction: () => AxFunction | AxFunction[];
|
|
2569
|
-
})[];
|
|
2570
|
-
|
|
2571
|
-
type AxPromptMetrics = {
|
|
2572
|
-
systemPromptCharacters: number;
|
|
2573
|
-
exampleChatContextCharacters: number;
|
|
2574
|
-
mutableChatContextCharacters: number;
|
|
2575
|
-
chatContextCharacters: number;
|
|
2576
|
-
totalPromptCharacters: number;
|
|
2577
|
-
};
|
|
2578
|
-
|
|
2579
2557
|
/**
|
|
2580
2558
|
* Generic component-optimization surface that any AxProgrammable can implement.
|
|
2581
2559
|
*
|
|
@@ -2953,7 +2931,6 @@ interface AxOptimizerResult<OUT> {
|
|
|
2953
2931
|
interface AxOptimizedProgram<OUT = any> {
|
|
2954
2932
|
bestScore: number;
|
|
2955
2933
|
stats: AxOptimizationStats;
|
|
2956
|
-
instruction?: string;
|
|
2957
2934
|
/**
|
|
2958
2935
|
* Generic component map produced by reflective optimizers (e.g. GEPA).
|
|
2959
2936
|
* Keys follow the `${programId}::${kind}[:${subKey}]` grammar from
|
|
@@ -2986,7 +2963,6 @@ type AxSerializedOptimizedProgram<OUT = any> = Omit<AxOptimizedProgram<OUT>, 'ap
|
|
|
2986
2963
|
declare class AxOptimizedProgramImpl<OUT = any> implements AxOptimizedProgram<OUT> {
|
|
2987
2964
|
readonly bestScore: number;
|
|
2988
2965
|
readonly stats: AxOptimizationStats;
|
|
2989
|
-
readonly instruction?: string;
|
|
2990
2966
|
readonly componentMap?: Record<string, string>;
|
|
2991
2967
|
readonly selectorState?: Record<string, AxGEPAComponentBanditState>;
|
|
2992
2968
|
readonly demos?: AxProgramDemos<any, OUT>[];
|
|
@@ -3012,7 +2988,6 @@ declare class AxOptimizedProgramImpl<OUT = any> implements AxOptimizedProgram<OU
|
|
|
3012
2988
|
constructor(config: {
|
|
3013
2989
|
bestScore: number;
|
|
3014
2990
|
stats: AxOptimizationStats;
|
|
3015
|
-
instruction?: string;
|
|
3016
2991
|
componentMap?: Record<string, string>;
|
|
3017
2992
|
selectorState?: Record<string, AxGEPAComponentBanditState>;
|
|
3018
2993
|
demos?: AxProgramDemos<any, OUT>[];
|
|
@@ -3557,23 +3532,6 @@ interface AxFieldProcessor {
|
|
|
3557
3532
|
process: AxFieldProcessorProcess | AxStreamingFieldProcessorProcess;
|
|
3558
3533
|
}
|
|
3559
3534
|
|
|
3560
|
-
interface AxResponseHandlerArgs<T> {
|
|
3561
|
-
ai: Readonly<AxAIService>;
|
|
3562
|
-
model?: string;
|
|
3563
|
-
res: T;
|
|
3564
|
-
mem: AxAIMemory;
|
|
3565
|
-
sessionId?: string;
|
|
3566
|
-
traceId?: string;
|
|
3567
|
-
traceContext?: Context;
|
|
3568
|
-
tracer?: Tracer;
|
|
3569
|
-
functions: Readonly<AxFunction[]>;
|
|
3570
|
-
strictMode?: boolean;
|
|
3571
|
-
span?: Span;
|
|
3572
|
-
logger: AxLoggerFunction;
|
|
3573
|
-
debugPromptMetrics?: Readonly<AxPromptMetrics>;
|
|
3574
|
-
onFunctionCall?: (call: Readonly<AxFunctionCallTrace>) => void | Promise<void>;
|
|
3575
|
-
}
|
|
3576
|
-
|
|
3577
3535
|
type AxGenerateResult<OUT> = OUT & {
|
|
3578
3536
|
thought?: string;
|
|
3579
3537
|
};
|
|
@@ -3589,8 +3547,7 @@ interface AxStreamingEvent<T> {
|
|
|
3589
3547
|
declare class AxGen<IN = any, OUT extends AxGenOut = any> extends AxProgram<IN, OUT> implements AxProgrammable<IN, OUT> {
|
|
3590
3548
|
clone: () => AxGen<IN, OUT>;
|
|
3591
3549
|
private promptTemplate;
|
|
3592
|
-
private
|
|
3593
|
-
private streamingAsserts;
|
|
3550
|
+
private streamingGuards;
|
|
3594
3551
|
private options?;
|
|
3595
3552
|
private functions;
|
|
3596
3553
|
private functionComponentIds;
|
|
@@ -3627,8 +3584,7 @@ declare class AxGen<IN = any, OUT extends AxGenOut = any> extends AxProgram<IN,
|
|
|
3627
3584
|
private getMergedCustomLabels;
|
|
3628
3585
|
updateMeter(meter?: Meter): void;
|
|
3629
3586
|
private createStates;
|
|
3630
|
-
|
|
3631
|
-
addStreamingAssert(fieldName: keyof OUT, fn: AxStreamingAssertion['fn'], message?: string): void;
|
|
3587
|
+
addStreamingGuard(fieldName: keyof OUT, fn: AxStreamingGuard['fn'], message?: string): void;
|
|
3632
3588
|
private addFieldProcessorInternal;
|
|
3633
3589
|
addStreamingFieldProcessor<K extends keyof OUT>(fieldName: K, fn: (value: string, context?: {
|
|
3634
3590
|
values?: OUT;
|
|
@@ -3678,7 +3634,7 @@ declare class AxGen<IN = any, OUT extends AxGenOut = any> extends AxProgram<IN,
|
|
|
3678
3634
|
* 2. **Render** - Build the prompt from signature, examples, and inputs
|
|
3679
3635
|
* 3. **Call** - Send the request to the AI service
|
|
3680
3636
|
* 4. **Parse** - Extract structured outputs from the response
|
|
3681
|
-
* 5. **
|
|
3637
|
+
* 5. **Validate** - Validate parsed outputs and retry with error correction if needed
|
|
3682
3638
|
*
|
|
3683
3639
|
* @param ai - The AI service instance to use (created via `ai()` factory)
|
|
3684
3640
|
* @param values - Input values matching the signature's input fields
|
|
@@ -3714,7 +3670,7 @@ declare class AxGen<IN = any, OUT extends AxGenOut = any> extends AxProgram<IN,
|
|
|
3714
3670
|
* @returns Promise resolving to the output values matching the signature's output fields
|
|
3715
3671
|
*
|
|
3716
3672
|
* @throws {AxValidationError} When input values don't match the signature
|
|
3717
|
-
* @throws {
|
|
3673
|
+
* @throws {ValidationError} When output parsing/validation fails after all retries
|
|
3718
3674
|
* @throws {AxAIServiceError} When the AI service request fails
|
|
3719
3675
|
*
|
|
3720
3676
|
* @example Basic usage
|
|
@@ -3793,8 +3749,8 @@ interface AxPromptTemplateOptions {
|
|
|
3793
3749
|
functions?: Readonly<AxInputFunctionType>;
|
|
3794
3750
|
thoughtFieldName?: string;
|
|
3795
3751
|
contextCache?: AxContextCacheOptions;
|
|
3796
|
-
/** When true,
|
|
3797
|
-
|
|
3752
|
+
/** When true, optional input fields stay in the system prompt field list even when values omit them. */
|
|
3753
|
+
includeOptionalInputFieldsInSystemPrompt?: boolean;
|
|
3798
3754
|
/** When true, cacheBreakpoint is ignored and cache is applied to all positions (for providers with auto-lookback like Anthropic) */
|
|
3799
3755
|
ignoreBreakpoints?: boolean;
|
|
3800
3756
|
/** When set, indicates structured output should be delivered via a function call with this name */
|
|
@@ -3828,7 +3784,7 @@ declare class AxPromptTemplate {
|
|
|
3828
3784
|
private readonly thoughtFieldName;
|
|
3829
3785
|
private readonly functions?;
|
|
3830
3786
|
private readonly contextCache?;
|
|
3831
|
-
private readonly
|
|
3787
|
+
private readonly includeOptionalInputFieldsInSystemPrompt;
|
|
3832
3788
|
private readonly ignoreBreakpoints;
|
|
3833
3789
|
private readonly structuredOutputFunctionName?;
|
|
3834
3790
|
private readonly customTemplate?;
|
|
@@ -3870,9 +3826,7 @@ declare class AxPromptTemplate {
|
|
|
3870
3826
|
* Build output fields section
|
|
3871
3827
|
*/
|
|
3872
3828
|
private buildOutputFieldsSection;
|
|
3873
|
-
private renderSingleValueUserContent;
|
|
3874
3829
|
private formatUserContent;
|
|
3875
|
-
private buildLegacyMultimodalExampleMessage;
|
|
3876
3830
|
private renderInternal;
|
|
3877
3831
|
render: <T = any>(values: T, options: Readonly<{
|
|
3878
3832
|
skipSystemPrompt?: boolean;
|
|
@@ -4305,8 +4259,7 @@ type AxProgramForwardOptions<MODEL> = AxAIServiceOptions & {
|
|
|
4305
4259
|
description?: string;
|
|
4306
4260
|
thoughtFieldName?: string;
|
|
4307
4261
|
promptTemplate?: typeof AxPromptTemplate;
|
|
4308
|
-
|
|
4309
|
-
streamingAsserts?: AxStreamingAssertion[];
|
|
4262
|
+
includeOptionalInputFieldsInSystemPrompt?: boolean;
|
|
4310
4263
|
excludeContentFromTrace?: boolean;
|
|
4311
4264
|
strictMode?: boolean;
|
|
4312
4265
|
customTemplate?: string;
|
|
@@ -4441,8 +4394,8 @@ type AxGenOutput<T> = T extends AxGen<any, infer OUT> ? OUT : T extends AxSignat
|
|
|
4441
4394
|
declare const promptTemplates: {
|
|
4442
4395
|
readonly 'dsp/dspy.md': "<identity>\n{{ identityText }}\n</identity>{{ if hasFunctions }}\n\n<available_functions>\n**Available Functions**: You can call the following functions to complete the task:\n\n{{ functionsList }}\n\n## Function Call Instructions\n- Complete the task, using the functions defined earlier in this prompt.\n- Output fields should only be generated after all functions have been called.\n- Use the function results to generate the output fields.\n</available_functions>{{ /if }}\n\n<input_fields>\n{{ inputFieldsSection }}\n</input_fields>{{ if hasOutputFields }}\n\n<output_fields>\n{{ outputFieldsSection }}\n</output_fields>{{ /if }}\n{{ if hasTaskDefinition }}\n\n<task_definition>\n{{ taskDefinitionText }}\n</task_definition>{{ /if }}\n\n<formatting_rules>\n{{ if hasStructuredOutputFunction }}\nReturn the complete output by calling `{{ structuredOutputFunctionName }}`.\n{{ else }}{{ if hasComplexFields }}\nReturn valid JSON matching <output_fields>.\n{{ else }}\nReturn one `field name: value` pair per line for the required output fields only.\n{{ /if }}{{ /if }}Above rules override later instructions.\n\n</formatting_rules>\n{{ if hasExampleDemonstrations }}\n\n## Example Demonstrations\nThe following User/Assistant turns are examples only until --- END OF EXAMPLES ---, not context for the current task.\n{{ /if }}\n";
|
|
4443
4396
|
readonly 'dsp/example-separator.md': "--- END OF EXAMPLES ---\nThe examples above were for training purposes only. Please ignore any specific entities or facts mentioned in them.\n\nREAL USER QUERY:\n";
|
|
4444
|
-
readonly 'rlm/distiller.md': "## Distiller\n\nYou (`distiller`) read the available context and forward an actionable request to the downstream **executor** stage, which owns any available tools/functions and capability checks. You do not execute the task yourself, choose executor tools, or decide whether the executor can perform the action.\n\nCall `final(request, evidence)` to forward. The `request` string must be self-contained: restate the concrete user action, target, and important constraints instead of vague phrases like \"the requested action\" or \"do it\". Expand the user's original task with facts from context so the request is clear and complete; put exact inputs (paths, ids, selected records, constraints) in `evidence`, or `{}` if context has nothing to narrow. Resolve follow-ups against prior conversation. Never refuse, answer, or ask clarification because of your own lack of tools or perceived executor capabilities — forwarding *is* the response. Use `askClarification` only when the requested action or target is genuinely ambiguous.\n\nThe
|
|
4445
|
-
readonly 'rlm/executor.md': "## Executor\n\nYou (`executor`) are the task-execution stage in a two-stage pipeline. Your ONLY job is to write
|
|
4397
|
+
readonly 'rlm/distiller.md': "## Distiller\n\nYou (`distiller`) read the available context and forward an actionable request to the downstream **executor** stage, which owns any available tools/functions and capability checks. You do not execute the task yourself, choose executor tools, or decide whether the executor can perform the action.\n\nCall `final(request, evidence)` to forward. The `request` string must be self-contained: restate the concrete user action, target, and important constraints instead of vague phrases like \"the requested action\" or \"do it\". Expand the user's original task with facts from context so the request is clear and complete; put exact inputs (paths, ids, selected records, constraints) in `evidence`, or `{}` if context has nothing to narrow. Resolve follow-ups against prior conversation. Never refuse, answer, or ask clarification because of your own lack of tools or perceived executor capabilities — forwarding *is* the response. Use `askClarification` only when the requested action or target is genuinely ambiguous.\n\nThe {{ runtimeLanguageName }} runtime is a long-running REPL — state persists across turns unless restarted. Each **turn**: write code → it executes → you see output → write the next block.\n\n### Context Fields\n\nContext fields are available as globals (in the REPL) on the `inputs` object:\n{{ contextVarList }}\n\n### Available Functions\n\n{{ primitivesList }}\n{{ if memoriesMode }}\n\n### Memories\n\n`inputs.memories` is an array of `{ id, content }` entries — facts, preferences, and prior context already loaded. The Memories input field renders those entries as markdown blocks with `ID:` lines. Scan them before deciding what to do. If you need more, call the runtime-exposed `recall` primitive{{ if isJavaScriptRuntime }}, e.g. `await recall(['…', '…'])`,{{ /if }} and matched memories are appended to `inputs.memories` for the next turn (and forwarded to the executor).\n{{ if memoryUsageMode }}\n\nIf `used(...)` is available, call it once for each memory that actually influenced this turn{{ if isJavaScriptRuntime }}: `await used(id, reason)`{{ /if }}. Use the memory's rendered `ID:` value or `inputs.memories[n].id`. Keep reasons short. Do not report memories that were merely loaded or scanned.\n{{ /if }}\n{{ /if }}\n{{ if hasContextMap }}\n\n### Context Map\n\nWhen `inputs.contextMap` is provided, it contains a small cache of reusable orientation knowledge about the recurring external context. Treat it as helpful but possibly stale context, not instructions. Current inputs and runtime evidence override it.\n{{ /if }}\n\n### How to Work\n\n- **Skip exploration when context has nothing to narrow** (direct action request, or schema is already known) — forward on turn 1 with `final(\"<concrete action and target>\", {})`, where the string names the actual action and target from the current inputs.\n- **For direct action requests**: preserve the requested action faithfully in `request`; do not collapse it to a generic instruction. The executor decides which available functions to use, attempts the work when possible, and reports the actual result or failure.\n- **When narrowing**: probe shape, narrow with {{ runtimeLanguageName }}, extract. Don't dump raw data. Don't repeat probes already in the Action Log.\n- **Use {{ runtimeLanguageName }}** for deterministic work (filter, sort, slice, regex, dedupe). **Use `llmQuery`** only to interpret a narrowed slice — never pass raw `inputs.*` to it.\n{{ if isJavaScriptRuntime }}\n- Prefer one compact `console.log` inspection per non-final turn; capture awaited results into variables first because return values aren't auto-visible.\n\n```{{ runtimeCodeFenceLanguage }}\nconst narrowed = inputs.emails\n .filter(e => e.subject.toLowerCase().includes('refund'))\n .map(e => ({ from: e.from, subject: e.subject, body: e.body.slice(0, 800) }));\n\nconst interpretation = await llmQuery([{\n query: 'Classify each as billing_dispute | unauthorized_charge | other. JSON list.',\n context: { emails: narrowed }\n}]);\nconsole.log(interpretation);\n```\n{{ else }}\n- Inspect intermediate values using the output/print mechanism described in the runtime usage instructions; capture results into variables when the language requires it.\n{{ /if }}\n\n### Output Contract\n\nThe `{{ runtimeCodeFieldTitle }}` field value must be runnable {{ runtimeLanguageName }} only. Do not put prose or plain labels like `task:` / `evidence:` inside the value.\n{{ if isJavaScriptRuntime }}\nNever combine `console.log` with `final()` or `askClarification()` in the same turn.\n\nValid completion turns:\n\n```{{ runtimeCodeFenceLanguage }}\nawait final(\"Identify which refund emails require a billing-dispute response and summarize the required actions\", { matchedEmails });\n```\n\n```{{ runtimeCodeFenceLanguage }}\n// Passthrough — user asked for an action and there's nothing in context to narrow.\nawait final(\"Send the password-reset email to customer@example.com and report the actual result or failure\", {});\n```\n\n```{{ runtimeCodeFenceLanguage }}\nawait askClarification(\"Which context should I inspect?\");\n```\n{{ else }}\nCompletion turns must call the runtime-exposed `final` or `askClarification` primitive using the syntax described in the runtime usage instructions.\n{{ /if }}\n\n## {{ runtimeLanguageName }} Runtime Usage Instructions\n{{ runtimeUsageInstructions }}\n";
|
|
4398
|
+
readonly 'rlm/executor.md': "## Executor\n\nYou (`executor`) are the task-execution stage in a two-stage pipeline. Your ONLY job is to write {{ runtimeLanguageName }} code that runs in the {{ runtimeLanguageName }} runtime (REPL) to complete tasks using the tools available to you. A separate (`responder`) agent downstream synthesizes the final answer.\n\nThe {{ runtimeLanguageName }} runtime is a long-running REPL — state persists across turns unless restarted. Each **turn**: write code → it executes → you see output → write the next block.\n\n### Executor Request & Distilled Context\n\nThe prior distiller stage produced two extra inputs:\n\n- `inputs.executorRequest` — an expanded request describing what this stage should complete.\n- `inputs.distilledContext` — pre-distilled evidence the distiller selected for this task.\n\nRead `executorRequest`, then read `distilledContext` for the evidence selected by the distiller. Raw context fields are not available in this stage. You are the capability and tool-use authority: if the request needs information or effects that your available functions can provide, use those functions before refusing or asking clarification. If the distilled evidence is sufficient, finish directly with `final(...)`. Call `askClarification(...)` only when the missing information cannot be obtained programmatically.\n\n### Available Functions\n\n{{ primitivesList }}\n\n{{ functionsList }}\n{{ if discoveryMode }}\n\n{{ if hasModules }}\n### Available Modules\n{{ modulesList }}\n{{ /if }}\n{{ if hasDiscoveredDocs }}\n### Discovered Tool Docs\n\nWhen `inputs.discoveredToolDocs` is provided, it contains tool docs fetched this run. Use them directly. Only re-run discovery for modules/functions not listed there.\n{{ /if }}\n{{ /if }}\n{{ if hasSkills }}\n### Loaded Skills\n\nWhen `inputs.loadedSkills` is provided, it contains skill guides loaded via the runtime-exposed `discover` primitive or forward-time skills. Apply relevant guides directly. Call `discover` with skills to load additional skills as needed.\n{{ if skillUsageMode }}\n\nIf `used(...)` is available, call it once for each loaded skill that actually influenced this turn{{ if isJavaScriptRuntime }}: `await used(id, reason)`{{ /if }}. Use the skill's rendered `ID:` value. Keep reasons short. Do not report skills that were merely loaded or scanned.\n{{ /if }}\n{{ /if }}\n{{ if memoriesMode }}\n\n### Memories\n\n`inputs.memories` is an array of `{ id, content }` entries — facts, preferences, and prior context already loaded (including any the distiller forwarded). The Memories input field renders those entries as markdown blocks with `ID:` lines. Scan them before deciding what to do. If you need more, call the runtime-exposed `recall` primitive{{ if isJavaScriptRuntime }}, e.g. `await recall(['…', '…'])`,{{ /if }} and matched memories are appended to `inputs.memories` for the next turn.\n{{ if memoryUsageMode }}\n\nIf `used(...)` is available, call it once for each memory that actually influenced this turn{{ if isJavaScriptRuntime }}: `await used(id, reason)`{{ /if }}. Use the memory's rendered `ID:` value or `inputs.memories[n].id`. Keep reasons short. Do not report memories that were merely loaded or scanned.\n{{ /if }}\n{{ /if }}\n\n### How to Work\n\n- Start from `inputs.executorRequest`, `inputs.distilledContext`, non-context task inputs, and prior successful Action Log results. Don't repeat probes already in the Action Log.\n- Treat direct action requests as work to attempt with available functions. If a function fails or the environment denies the action, capture the real error, status, output, or exception in the evidence for the responder.\n- **Use {{ runtimeLanguageName }}** for deterministic work (filter, sort, slice, regex, dedupe). **Use `llmQuery`** only to interpret narrowed text — never pass raw `inputs.*` to it.\n- Discovery calls (`discover`) can appear alongside other code — the runtime runs them first automatically.\n{{ if isJavaScriptRuntime }}\n- Prefer one compact `console.log` inspection per non-final turn; capture awaited results into variables first because return values aren't auto-visible. If the task is complete, finish with `await final(\"...\", { result })` instead of logging.\n{{ else }}\n- Capture runtime results into variables when the language requires it; inspect intermediate values using the output/print mechanism described in the runtime usage instructions.\n{{ /if }}\n- Before calling `askClarification`, check whether any available function can resolve the need first.\n{{ if hasAgentStatusCallback }}\n- Keep the user updated: call the runtime-exposed `reportSuccess` primitive after completing sub-tasks and `reportFailure` when something goes wrong{{ if isJavaScriptRuntime }} (for example, `await reportSuccess(message)`){{ /if }}.\n{{ /if }}\n{{ if isJavaScriptRuntime }}\n\n```{{ runtimeCodeFenceLanguage }}\nconst narrowed = inputs.emails\n .filter(e => e.subject.toLowerCase().includes('refund'))\n .map(e => ({ from: e.from, subject: e.subject, body: e.body.slice(0, 800) }));\n\nconst plan = await llmQuery([{\n query: 'Determine which messages require a refund response and draft a compact action plan.',\n context: { emails: narrowed }\n}]);\nconsole.log(plan);\n```\n{{ /if }}\n\n### Output Contract\n\nThe `{{ runtimeCodeFieldTitle }}` field value must be runnable {{ runtimeLanguageName }} only. Do not put prose or plain labels like `task:` / `evidence:` inside the value.\n{{ if isJavaScriptRuntime }}\nNever combine `console.log` with `final()` or `askClarification()` in the same turn.\n{{ /if }}\n\n{{ if isJavaScriptRuntime }}\nWhen done, call `await final(task, evidence)`:\n{{ else }}\nWhen done, call the runtime-exposed `final(task, evidence)` primitive:\n{{ /if }}\n\n- `task` — a one-line instruction the **responder** will follow when writing the user-facing output fields (e.g. \"Answer the user's question using the matched emails\").\n- `evidence` — the curated data the responder will read to follow `task`. Pass narrowed runtime values with only the fields that matter, not raw `inputs.*`. Use plain keys (for example, `matchedEmails`) — don't wrap under the output field name.\n\nDo not pre-format the answer; the responder writes the output fields.\n\nValid completion turns:\n\n{{ if isJavaScriptRuntime }}\n```{{ runtimeCodeFenceLanguage }}\nawait final(\"Answer the user's question using the gathered evidence\", { evidence });\n```\n\n```{{ runtimeCodeFenceLanguage }}\nawait askClarification(\"Which file should I analyze?\");\n```\n{{ else }}\nCompletion turns must call the runtime-exposed `final` or `askClarification` primitive using the syntax described in the runtime usage instructions.\n{{ /if }}\n\n## {{ runtimeLanguageName }} Runtime Usage Instructions\n{{ runtimeUsageInstructions }}\n";
|
|
4446
4399
|
readonly 'rlm/responder.md': "## Answer Synthesis Agent\n\nYou synthesize the final answer from the evidence the actor gathered. You do not run code, call tools, or invoke agents — you read input fields and write the output fields.\n\n### Reading the actor's payload\n\n`Context Data` has two keys:\n\n- `task` — a one-line instruction telling you what to write into the output fields.\n- `evidence` — the data the actor curated for you to follow that instruction.\n\n### Rules\n\n1. Follow `Context Data.task` using `Context Data.evidence` and any other input fields provided.\n2. When emitting a JSON output field, write the value flat — do **not** wrap it under a key matching the field's title. The field is already named.\n3. If `evidence` lacks sufficient information, give the best possible answer from what's available across all input fields.\n4. Do not contradict actor evidence. If evidence contains a tool result, failure, status, output, or exception, report that result rather than inventing a capability limit.\n\n### Context variables that were analyzed (metadata only)\n{{ contextVarSummary }}\n{{ if hasAgentIdentity }}\n\n### Agent Identity\n\nUser-facing identity:\n{{ agentIdentityText }}\n{{ /if }}\n";
|
|
4447
4400
|
};
|
|
4448
4401
|
type TemplateId = keyof typeof promptTemplates;
|
|
@@ -4565,6 +4518,9 @@ interface AxAgentic<IN extends AxGenIn, OUT extends AxGenOut> extends AxProgramm
|
|
|
4565
4518
|
getFunction(): AxFunction;
|
|
4566
4519
|
}
|
|
4567
4520
|
type AxAnyAgentic = AxAgentic<any, any>;
|
|
4521
|
+
type AxFunctionProvider = {
|
|
4522
|
+
toFunction(): AxFunction | readonly AxFunction[];
|
|
4523
|
+
};
|
|
4568
4524
|
type AxAgentIdentity = {
|
|
4569
4525
|
name: string;
|
|
4570
4526
|
description: string;
|
|
@@ -4597,7 +4553,7 @@ type AxAgentFunction = Omit<AxFunction, 'description'> & {
|
|
|
4597
4553
|
_alwaysInclude?: boolean;
|
|
4598
4554
|
};
|
|
4599
4555
|
type AxAgentFunctionGroup = AxAgentFunctionModuleMeta & {
|
|
4600
|
-
functions: readonly Omit<AxAgentFunction, 'namespace'>[];
|
|
4556
|
+
functions: readonly (Omit<AxAgentFunction, 'namespace'> | AxFunctionProvider)[];
|
|
4601
4557
|
};
|
|
4602
4558
|
type AxAgentTestCompletionPayload = {
|
|
4603
4559
|
type: 'final' | 'askClarification';
|
|
@@ -4682,7 +4638,7 @@ declare class AxAgentClarificationError extends Error {
|
|
|
4682
4638
|
}>);
|
|
4683
4639
|
getState(): AxAgentState | undefined;
|
|
4684
4640
|
}
|
|
4685
|
-
type AxAgentFunctionCollection = readonly (AxAgentFunction | AxAnyAgentic)[] | readonly AxAgentFunctionGroup[];
|
|
4641
|
+
type AxAgentFunctionCollection = readonly (AxAgentFunction | AxAnyAgentic | AxFunctionProvider)[] | readonly AxAgentFunctionGroup[];
|
|
4686
4642
|
type AxContextFieldInput = string | {
|
|
4687
4643
|
field: string;
|
|
4688
4644
|
promptMaxChars?: number;
|
|
@@ -4707,9 +4663,9 @@ type AxAgentActorTurnCallbackArgs = {
|
|
|
4707
4663
|
actionLogEntryCount: number;
|
|
4708
4664
|
/** Number of guidance log entries recorded after processing this turn. */
|
|
4709
4665
|
guidanceLogEntryCount: number;
|
|
4710
|
-
/** Full actor AxGen output for the turn, including
|
|
4666
|
+
/** Full actor AxGen output for the turn, including the runtime code field and any actor fields. */
|
|
4711
4667
|
executorResult: Record<string, unknown>;
|
|
4712
|
-
/** Normalized
|
|
4668
|
+
/** Normalized runtime code that was executed for this turn. */
|
|
4713
4669
|
code: string;
|
|
4714
4670
|
/**
|
|
4715
4671
|
* Raw runtime execution result before formatting or truncation.
|
|
@@ -4733,14 +4689,6 @@ type AxAgentActorTurnCallbackArgs = {
|
|
|
4733
4689
|
}>;
|
|
4734
4690
|
};
|
|
4735
4691
|
type AxAgentActorTurnCallback = (args: AxAgentActorTurnCallbackArgs) => void | Promise<void>;
|
|
4736
|
-
/**
|
|
4737
|
-
* @deprecated Use AxAgentActorTurnCallbackArgs.
|
|
4738
|
-
*/
|
|
4739
|
-
type AxAgentExecutorTurnCallbackArgs = AxAgentActorTurnCallbackArgs;
|
|
4740
|
-
/**
|
|
4741
|
-
* @deprecated Use AxAgentActorTurnCallback.
|
|
4742
|
-
*/
|
|
4743
|
-
type AxAgentExecutorTurnCallback = AxAgentActorTurnCallback;
|
|
4744
4692
|
|
|
4745
4693
|
/**
|
|
4746
4694
|
* RLM (Recursive Language Model) interfaces and prompt builder.
|
|
@@ -4753,11 +4701,30 @@ type AgentIdentityPrompt = Readonly<{
|
|
|
4753
4701
|
name: string;
|
|
4754
4702
|
description: string;
|
|
4755
4703
|
}>;
|
|
4704
|
+
type AxRuntimeCallableFormatArgs = Readonly<{
|
|
4705
|
+
qualifiedName: string;
|
|
4706
|
+
description?: string;
|
|
4707
|
+
parameters?: AxFunctionJSONSchema;
|
|
4708
|
+
returns?: AxFunctionJSONSchema;
|
|
4709
|
+
}>;
|
|
4710
|
+
type AxRuntimePrimitiveOverrideMap = ReadonlyMap<string, readonly string[]> | Readonly<Record<string, readonly string[]>>;
|
|
4711
|
+
type AxRuntimeLanguageInfo = Readonly<{
|
|
4712
|
+
languageName: string;
|
|
4713
|
+
codeFieldName: string;
|
|
4714
|
+
codeFieldTitle: string;
|
|
4715
|
+
codeFenceLanguage: string;
|
|
4716
|
+
isJavaScript: boolean;
|
|
4717
|
+
}>;
|
|
4756
4718
|
/**
|
|
4757
4719
|
* A code runtime that can create persistent sessions.
|
|
4758
4720
|
* Implement this interface for your target runtime (Node.js, browser, WASM, etc.).
|
|
4759
4721
|
*/
|
|
4760
4722
|
interface AxCodeRuntime {
|
|
4723
|
+
/**
|
|
4724
|
+
* Human-readable language name for generated actor code.
|
|
4725
|
+
* Defaults to JavaScript when omitted for backwards compatibility.
|
|
4726
|
+
*/
|
|
4727
|
+
readonly language?: string;
|
|
4761
4728
|
createSession(globals?: Record<string, unknown>, options?: {
|
|
4762
4729
|
shouldBubbleError?: (err: unknown) => boolean;
|
|
4763
4730
|
}): AxCodeSession;
|
|
@@ -4766,11 +4733,17 @@ interface AxCodeRuntime {
|
|
|
4766
4733
|
* Use this for execution semantics that differ by runtime/language.
|
|
4767
4734
|
*/
|
|
4768
4735
|
getUsageInstructions(): string;
|
|
4736
|
+
/**
|
|
4737
|
+
* Optional language-native prompt text for built-in actor primitives such as
|
|
4738
|
+
* final, askClarification, discover, and recall.
|
|
4739
|
+
*/
|
|
4740
|
+
getPrimitiveOverrides?(): AxRuntimePrimitiveOverrideMap | undefined;
|
|
4741
|
+
/**
|
|
4742
|
+
* Optional language-native formatter for callable tools exposed in the
|
|
4743
|
+
* runtime. Execution still happens inside the runtime session.
|
|
4744
|
+
*/
|
|
4745
|
+
formatCallable?(args: AxRuntimeCallableFormatArgs): string;
|
|
4769
4746
|
}
|
|
4770
|
-
/**
|
|
4771
|
-
* @deprecated Use `AxCodeRuntime` instead.
|
|
4772
|
-
*/
|
|
4773
|
-
type AxCodeInterpreter = AxCodeRuntime;
|
|
4774
4747
|
type AxCodeSessionSnapshotEntry = {
|
|
4775
4748
|
name: string;
|
|
4776
4749
|
type: string;
|
|
@@ -4870,10 +4843,6 @@ interface AxRLMConfig {
|
|
|
4870
4843
|
* the formatted action-log output.
|
|
4871
4844
|
*/
|
|
4872
4845
|
actorTurnCallback?: AxAgentActorTurnCallback;
|
|
4873
|
-
/**
|
|
4874
|
-
* @deprecated Use actorTurnCallback.
|
|
4875
|
-
*/
|
|
4876
|
-
executorTurnCallback?: AxAgentExecutorTurnCallback;
|
|
4877
4846
|
/**
|
|
4878
4847
|
* Called when AxAgent measures context pressure or changes compacted context state.
|
|
4879
4848
|
* Intended for observability; callback failures are ignored.
|
|
@@ -4891,6 +4860,10 @@ interface AxRLMConfig {
|
|
|
4891
4860
|
*/
|
|
4892
4861
|
declare function axBuildDistillerDefinition(baseDefinition: string | undefined, contextFields: readonly AxIField[], options: Readonly<{
|
|
4893
4862
|
runtimeUsageInstructions?: string;
|
|
4863
|
+
runtimeLanguageName?: string;
|
|
4864
|
+
runtimeCodeFieldTitle?: string;
|
|
4865
|
+
runtimeCodeFenceLanguage?: string;
|
|
4866
|
+
isJavaScriptRuntime?: boolean;
|
|
4894
4867
|
promptLevel?: 'default' | 'detailed';
|
|
4895
4868
|
hasInspectRuntime?: boolean;
|
|
4896
4869
|
hasLiveRuntimeState?: boolean;
|
|
@@ -4915,6 +4888,11 @@ declare function axBuildDistillerDefinition(baseDefinition: string | undefined,
|
|
|
4915
4888
|
*/
|
|
4916
4889
|
declare function axBuildExecutorDefinition(baseDefinition: string | undefined, contextFields: readonly AxIField[], responderOutputFields: readonly AxIField[], options: Readonly<{
|
|
4917
4890
|
runtimeUsageInstructions?: string;
|
|
4891
|
+
runtimeLanguageName?: string;
|
|
4892
|
+
runtimeCodeFieldTitle?: string;
|
|
4893
|
+
runtimeCodeFenceLanguage?: string;
|
|
4894
|
+
isJavaScriptRuntime?: boolean;
|
|
4895
|
+
formatCallable?: AxCodeRuntime['formatCallable'];
|
|
4918
4896
|
promptLevel?: 'default' | 'detailed';
|
|
4919
4897
|
hasInspectRuntime?: boolean;
|
|
4920
4898
|
hasLiveRuntimeState?: boolean;
|
|
@@ -5149,14 +5127,13 @@ declare class AxAgentContextMap {
|
|
|
5149
5127
|
|
|
5150
5128
|
/**
|
|
5151
5129
|
* Demo traces for AxAgent's split architecture.
|
|
5152
|
-
* Actor demos use `
|
|
5130
|
+
* Actor demos use the runtime code field (`javascriptCode` for JavaScript,
|
|
5131
|
+
* `<language>Code` for other runtimes such as `pythonCode`).
|
|
5153
5132
|
* Responder demos use the agent's output type + optional input fields.
|
|
5154
5133
|
*/
|
|
5155
5134
|
type AxAgentDemos<IN extends AxGenIn, OUT extends AxGenOut, PREFIX extends string = string> = {
|
|
5156
5135
|
programId: `${PREFIX}.actor`;
|
|
5157
|
-
traces:
|
|
5158
|
-
javascriptCode: string;
|
|
5159
|
-
})[];
|
|
5136
|
+
traces: Record<string, AxFieldValue>[];
|
|
5160
5137
|
} | {
|
|
5161
5138
|
programId: `${PREFIX}.responder`;
|
|
5162
5139
|
traces: (OUT & Partial<IN>)[];
|
|
@@ -5333,13 +5310,6 @@ type AxAgentOptions<IN extends AxGenIn = AxGenIn> = Omit<AxProgramForwardOptions
|
|
|
5333
5310
|
* result and the formatted action-log output.
|
|
5334
5311
|
*/
|
|
5335
5312
|
actorTurnCallback?: AxAgentActorTurnCallback;
|
|
5336
|
-
/**
|
|
5337
|
-
* @deprecated Use actorTurnCallback.
|
|
5338
|
-
*
|
|
5339
|
-
* Called after each actor turn is recorded with both the raw runtime
|
|
5340
|
-
* result and the formatted action-log output.
|
|
5341
|
-
*/
|
|
5342
|
-
executorTurnCallback?: (args: AxAgentExecutorTurnCallbackArgs) => void | Promise<void>;
|
|
5343
5313
|
/**
|
|
5344
5314
|
* Called when AxAgent measures context pressure or creates/clears compacted
|
|
5345
5315
|
* context. Use for observability and evaluation; failures are ignored.
|
|
@@ -5449,10 +5419,6 @@ type AxAgentJudgeEvalOutput = {
|
|
|
5449
5419
|
reasoning: string;
|
|
5450
5420
|
quality: string;
|
|
5451
5421
|
};
|
|
5452
|
-
type AxNormalizedAgentEvalDataset<IN = any> = {
|
|
5453
|
-
train: readonly AxAgentEvalTask<IN>[];
|
|
5454
|
-
validation?: readonly AxAgentEvalTask<IN>[];
|
|
5455
|
-
};
|
|
5456
5422
|
/** Forward options forwarded to the `AxGen` spawned by each `llmQuery(...)` call. */
|
|
5457
5423
|
type AxAgentRecursionOptions = Partial<Omit<AxProgramForwardOptions<string>, 'functions'>>;
|
|
5458
5424
|
|
|
@@ -5567,22 +5533,11 @@ type AxAgentRuntimeExecutionContext = {
|
|
|
5567
5533
|
executeTestCode: (code: string) => Promise<AxAgentTestResult>;
|
|
5568
5534
|
close: () => void;
|
|
5569
5535
|
};
|
|
5570
|
-
type AxMutableDiscoveryPromptState = {
|
|
5571
|
-
modules: Map<string, string>;
|
|
5572
|
-
functions: Map<string, string>;
|
|
5573
|
-
};
|
|
5574
5536
|
type AxDiscoveryTurnSummary = {
|
|
5575
5537
|
modules: Set<string>;
|
|
5576
5538
|
functions: Set<string>;
|
|
5577
5539
|
texts: Set<string>;
|
|
5578
5540
|
};
|
|
5579
|
-
type AxMutableSkillsPromptState = {
|
|
5580
|
-
loaded: Map<string, {
|
|
5581
|
-
id: string;
|
|
5582
|
-
name: string;
|
|
5583
|
-
content: string;
|
|
5584
|
-
}>;
|
|
5585
|
-
};
|
|
5586
5541
|
type AxAgentOptimizationTargetDescriptor = {
|
|
5587
5542
|
id: string;
|
|
5588
5543
|
signature?: string;
|
|
@@ -5770,7 +5725,7 @@ declare class AxAgent<IN extends AxGenIn, OUT extends AxGenOut> implements AxAge
|
|
|
5770
5725
|
setContextMap(map?: AxAgentContextMap | AxAgentContextMapSnapshot | string): void;
|
|
5771
5726
|
_syncContextMapPrompt(): void;
|
|
5772
5727
|
_updateContextMapFromPipelineState(ai: Readonly<AxAIService>, state: Readonly<Record<string, any>>, finalOutput?: unknown): Promise<void>;
|
|
5773
|
-
setSignature(signature:
|
|
5728
|
+
setSignature(signature: AxSignatureInput): void;
|
|
5774
5729
|
applyOptimization(optimizedProgram: any): void;
|
|
5775
5730
|
getOptimizableComponents(): readonly any[];
|
|
5776
5731
|
applyOptimizedComponents(updates: Readonly<Record<string, string>>): void;
|
|
@@ -5800,9 +5755,9 @@ declare function agent<TInput extends Record<string, any>, TOutput extends Recor
|
|
|
5800
5755
|
declare function agent(signature: Readonly<AxSignatureConfig>, config: AxAgentConfig<AxGenIn, AxGenOut>): AxAgent<AxGenIn, AxGenOut>;
|
|
5801
5756
|
|
|
5802
5757
|
/**
|
|
5803
|
-
* RLM actor stage: a single AxGen program driven in a
|
|
5758
|
+
* RLM actor stage: a single AxGen program driven in a code-runtime loop.
|
|
5804
5759
|
*
|
|
5805
|
-
* The actor generates
|
|
5760
|
+
* The actor generates runtime-language code, the TypeScript loop executes it in a
|
|
5806
5761
|
* pluggable `AxCodeRuntime`, the result is appended to an action log, and the
|
|
5807
5762
|
* loop continues until the actor terminates with `final(...)` /
|
|
5808
5763
|
* `askClarification(...)` (or hits `maxTurns`).
|
|
@@ -5848,6 +5803,11 @@ declare class ActorAgentRLM<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut =
|
|
|
5848
5803
|
private onContextEvent?;
|
|
5849
5804
|
private contextPromptConfigByField;
|
|
5850
5805
|
private functionDiscoveryEnabled;
|
|
5806
|
+
private runtimeLanguageName;
|
|
5807
|
+
private runtimeCodeFieldName;
|
|
5808
|
+
private runtimeCodeFieldTitle;
|
|
5809
|
+
private runtimeCodeFenceLanguage;
|
|
5810
|
+
private isJavaScriptRuntime;
|
|
5851
5811
|
private runtimeUsageInstructions;
|
|
5852
5812
|
private enforceIncrementalConsoleTurns;
|
|
5853
5813
|
private bubbleErrors?;
|
|
@@ -5934,7 +5894,7 @@ declare class ActorAgentRLM<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut =
|
|
|
5934
5894
|
abortSignal?: AbortSignal;
|
|
5935
5895
|
debug?: boolean;
|
|
5936
5896
|
}>): Promise<AxAgentTestResult>;
|
|
5937
|
-
setSignature(signature:
|
|
5897
|
+
setSignature(signature: AxSignatureInput): void;
|
|
5938
5898
|
applyOptimization(optimizedProgram: any): void;
|
|
5939
5899
|
getOptimizableComponents(): readonly any[];
|
|
5940
5900
|
applyOptimizedComponents(updates: Readonly<Record<string, string>>): void;
|
|
@@ -6043,6 +6003,8 @@ type AxRuntimePrimitiveExample = {
|
|
|
6043
6003
|
declare const axRuntimePrimitives: readonly AxRuntimePrimitive[];
|
|
6044
6004
|
|
|
6045
6005
|
declare enum AxAIAnthropicModel {
|
|
6006
|
+
Claude48Opus = "claude-opus-4-8",
|
|
6007
|
+
Claude47Opus = "claude-opus-4-7",
|
|
6046
6008
|
Claude46Opus = "claude-opus-4-6",
|
|
6047
6009
|
Claude46Sonnet = "claude-sonnet-4-6",
|
|
6048
6010
|
Claude45Opus = "claude-opus-4-5-20251101",
|
|
@@ -6061,6 +6023,8 @@ declare enum AxAIAnthropicModel {
|
|
|
6061
6023
|
ClaudeInstant12 = "claude-instant-1.2"
|
|
6062
6024
|
}
|
|
6063
6025
|
declare enum AxAIAnthropicVertexModel {
|
|
6026
|
+
Claude48Opus = "claude-opus-4-8",
|
|
6027
|
+
Claude47Opus = "claude-opus-4-7",
|
|
6064
6028
|
Claude46Opus = "claude-opus-4-6",
|
|
6065
6029
|
Claude46Sonnet = "claude-sonnet-4-6",
|
|
6066
6030
|
Claude45Opus = "claude-opus-4-5@20251101",
|
|
@@ -6088,13 +6052,19 @@ type AxAIAnthropicThinkingWire = {
|
|
|
6088
6052
|
} | {
|
|
6089
6053
|
type: 'adaptive';
|
|
6090
6054
|
};
|
|
6091
|
-
type AxAIAnthropicEffortLevel = 'low' | 'medium' | 'high' | 'max';
|
|
6055
|
+
type AxAIAnthropicEffortLevel = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
6056
|
+
type AxAIAnthropicTaskBudget = {
|
|
6057
|
+
type: 'tokens';
|
|
6058
|
+
total: number;
|
|
6059
|
+
remaining?: number;
|
|
6060
|
+
};
|
|
6092
6061
|
type AxAIAnthropicOutputConfig = {
|
|
6093
6062
|
effort?: AxAIAnthropicEffortLevel;
|
|
6094
6063
|
format?: {
|
|
6095
6064
|
type: 'json_schema';
|
|
6096
6065
|
schema: object;
|
|
6097
6066
|
};
|
|
6067
|
+
task_budget?: AxAIAnthropicTaskBudget;
|
|
6098
6068
|
};
|
|
6099
6069
|
type AxAIAnthropicEffortLevelMapping = {
|
|
6100
6070
|
minimal?: AxAIAnthropicEffortLevel;
|
|
@@ -6146,9 +6116,15 @@ type AxAIAnthropicChatRequest = {
|
|
|
6146
6116
|
model?: string;
|
|
6147
6117
|
anthropic_version?: string;
|
|
6148
6118
|
messages: ({
|
|
6149
|
-
role: '
|
|
6150
|
-
content: string | (
|
|
6151
|
-
type: 'text';
|
|
6119
|
+
role: 'system';
|
|
6120
|
+
content: string | ({
|
|
6121
|
+
type: 'text';
|
|
6122
|
+
text: string;
|
|
6123
|
+
} & AxAIAnthropicChatRequestCacheParam)[];
|
|
6124
|
+
} | {
|
|
6125
|
+
role: 'user';
|
|
6126
|
+
content: string | (({
|
|
6127
|
+
type: 'text';
|
|
6152
6128
|
text: string;
|
|
6153
6129
|
} & AxAIAnthropicChatRequestCacheParam) | ({
|
|
6154
6130
|
type: 'image';
|
|
@@ -6212,10 +6188,16 @@ type AxAIAnthropicChatRequest = {
|
|
|
6212
6188
|
top_k?: number;
|
|
6213
6189
|
thinking?: AxAIAnthropicThinkingWire;
|
|
6214
6190
|
output_config?: AxAIAnthropicOutputConfig;
|
|
6191
|
+
speed?: 'fast';
|
|
6215
6192
|
metadata?: {
|
|
6216
6193
|
user_id: string;
|
|
6217
6194
|
};
|
|
6218
6195
|
};
|
|
6196
|
+
type AxAIAnthropicStopDetails = {
|
|
6197
|
+
type: 'refusal';
|
|
6198
|
+
category?: 'cyber' | 'bio' | string | null;
|
|
6199
|
+
explanation?: string | null;
|
|
6200
|
+
};
|
|
6219
6201
|
type AxAIAnthropicChatResponse = {
|
|
6220
6202
|
id: string;
|
|
6221
6203
|
type: 'message';
|
|
@@ -6239,13 +6221,15 @@ type AxAIAnthropicChatResponse = {
|
|
|
6239
6221
|
signature?: string;
|
|
6240
6222
|
})[];
|
|
6241
6223
|
model: string;
|
|
6242
|
-
stop_reason: 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use';
|
|
6224
|
+
stop_reason: 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' | 'refusal' | 'pause_turn' | 'model_context_window_exceeded';
|
|
6225
|
+
stop_details?: AxAIAnthropicStopDetails | null;
|
|
6243
6226
|
stop_sequence?: string;
|
|
6244
6227
|
usage: {
|
|
6245
6228
|
input_tokens: number;
|
|
6246
6229
|
output_tokens: number;
|
|
6247
6230
|
cache_creation_input_tokens?: number;
|
|
6248
6231
|
cache_read_input_tokens?: number;
|
|
6232
|
+
speed?: 'fast' | 'standard';
|
|
6249
6233
|
};
|
|
6250
6234
|
};
|
|
6251
6235
|
type AxAIAnthropicChatError = {
|
|
@@ -6270,6 +6254,7 @@ interface AxAIAnthropicMessageStartEvent {
|
|
|
6270
6254
|
output_tokens: number;
|
|
6271
6255
|
cache_creation_input_tokens?: number;
|
|
6272
6256
|
cache_read_input_tokens?: number;
|
|
6257
|
+
speed?: 'fast' | 'standard';
|
|
6273
6258
|
};
|
|
6274
6259
|
};
|
|
6275
6260
|
}
|
|
@@ -6322,11 +6307,13 @@ interface AxAIAnthropicContentBlockStopEvent {
|
|
|
6322
6307
|
interface AxAIAnthropicMessageDeltaEvent {
|
|
6323
6308
|
type: 'message_delta';
|
|
6324
6309
|
delta: {
|
|
6325
|
-
stop_reason: 'end_turn' | 'max_tokens' | 'stop_sequence' | null;
|
|
6310
|
+
stop_reason: 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' | 'refusal' | 'pause_turn' | 'model_context_window_exceeded' | null;
|
|
6326
6311
|
stop_sequence: string | null;
|
|
6312
|
+
stop_details?: AxAIAnthropicStopDetails | null;
|
|
6327
6313
|
};
|
|
6328
6314
|
usage: {
|
|
6329
6315
|
output_tokens: number;
|
|
6316
|
+
speed?: 'fast' | 'standard';
|
|
6330
6317
|
};
|
|
6331
6318
|
}
|
|
6332
6319
|
interface AxAIAnthropicMessageStopEvent {
|
|
@@ -7284,37 +7271,21 @@ type AxAICohereEmbedResponse = {
|
|
|
7284
7271
|
embeddings: number[][];
|
|
7285
7272
|
};
|
|
7286
7273
|
|
|
7274
|
+
type AxAICohereOpenAIConfig = AxAIOpenAIConfig<AxAICohereModel, AxAICohereEmbedModel>;
|
|
7287
7275
|
/**
|
|
7288
|
-
* Creates the default configuration for Cohere AI service
|
|
7289
|
-
* @returns A deep clone of the default Cohere configuration with CommandRPlus model and EmbedEnglishV30 embed model
|
|
7290
|
-
*/
|
|
7291
|
-
declare const axAICohereDefaultConfig: () => AxAICohereConfig;
|
|
7292
|
-
/**
|
|
7293
|
-
* Creates a creative configuration for Cohere AI service with more flexible parameters
|
|
7294
|
-
* @returns A deep clone of the creative Cohere configuration with CommandR model and EmbedEnglishV30 embed model
|
|
7276
|
+
* Creates the default configuration for Cohere AI service.
|
|
7295
7277
|
*/
|
|
7296
|
-
declare const
|
|
7278
|
+
declare const axAICohereDefaultConfig: () => AxAICohereOpenAIConfig;
|
|
7297
7279
|
/**
|
|
7298
|
-
*
|
|
7299
|
-
* @template TModelKey - The type of model keys supported
|
|
7280
|
+
* Creates a creative configuration for Cohere AI service.
|
|
7300
7281
|
*/
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
apiKey: string;
|
|
7304
|
-
config?: Readonly<Partial<AxAICohereConfig>>;
|
|
7305
|
-
options?: Readonly<AxAIServiceOptions>;
|
|
7306
|
-
models?: AxAIInputModelList<AxAICohereModel, AxAICohereEmbedModel, TModelKey>;
|
|
7307
|
-
}
|
|
7282
|
+
declare const axAICohereCreativeConfig: () => AxAICohereOpenAIConfig;
|
|
7283
|
+
type AxAICohereArgs<TModelKey> = AxAIOpenAIArgs<'cohere', AxAICohereModel, AxAICohereEmbedModel, TModelKey>;
|
|
7308
7284
|
/**
|
|
7309
|
-
*
|
|
7310
|
-
* @template TModelKey - The type of model keys supported
|
|
7285
|
+
* Cohere provider using Cohere's OpenAI compatibility endpoint.
|
|
7311
7286
|
*/
|
|
7312
|
-
declare class AxAICohere<TModelKey> extends
|
|
7313
|
-
|
|
7314
|
-
* Creates a new instance of AxAICohere
|
|
7315
|
-
* @param args - Configuration arguments including API key, config, options, and models
|
|
7316
|
-
*/
|
|
7317
|
-
constructor({ apiKey, config, options, models, }: Readonly<Omit<AxAICohereArgs<TModelKey>, 'name'>>);
|
|
7287
|
+
declare class AxAICohere<TModelKey> extends AxAIOpenAIBase<AxAICohereModel, AxAICohereEmbedModel, TModelKey> {
|
|
7288
|
+
constructor({ apiKey, config, options, models, modelInfo, }: Readonly<Omit<AxAICohereArgs<TModelKey>, 'name'>>);
|
|
7318
7289
|
}
|
|
7319
7290
|
|
|
7320
7291
|
/**
|
|
@@ -7776,25 +7747,6 @@ declare class AxAIGoogleGemini<TModelKey = string> extends AxBaseAI<AxAIGoogleGe
|
|
|
7776
7747
|
constructor({ apiKey, projectId, region, endpointId, config, options, models, modelInfo, }: Readonly<Omit<AxAIGoogleGeminiArgs<TModelKey>, 'name'>>);
|
|
7777
7748
|
}
|
|
7778
7749
|
|
|
7779
|
-
declare enum AxAIGroqModel {
|
|
7780
|
-
Llama3_8B = "llama3-8b-8192",
|
|
7781
|
-
Llama33_70B = "llama-3.3-70b-versatile",
|
|
7782
|
-
Mixtral_8x7B = "mixtral-8x7b-32768",
|
|
7783
|
-
Gemma2_9B = "gemma2-9b-it"
|
|
7784
|
-
}
|
|
7785
|
-
|
|
7786
|
-
type AxAIGroqArgs<TModelKey> = AxAIOpenAIArgs<'groq', AxAIGroqModel, undefined, TModelKey> & {
|
|
7787
|
-
options?: Readonly<AxAIServiceOptions> & {
|
|
7788
|
-
tokensPerMinute?: number;
|
|
7789
|
-
};
|
|
7790
|
-
modelInfo?: AxModelInfo[];
|
|
7791
|
-
};
|
|
7792
|
-
declare class AxAIGroq<TModelKey> extends AxAIOpenAIBase<AxAIGroqModel, undefined, TModelKey> {
|
|
7793
|
-
constructor({ apiKey, config, options, models, modelInfo, }: Readonly<Omit<AxAIGroqArgs<TModelKey>, 'name'>>);
|
|
7794
|
-
setOptions: (options: Readonly<AxAIServiceOptions>) => void;
|
|
7795
|
-
private newRateLimiter;
|
|
7796
|
-
}
|
|
7797
|
-
|
|
7798
7750
|
declare enum AxAIHuggingFaceModel {
|
|
7799
7751
|
MetaLlama270BChatHF = "meta-llama/Llama-2-70b-chat-hf"
|
|
7800
7752
|
}
|
|
@@ -7903,50 +7855,6 @@ declare class AxAIMistral<TModelKey> extends AxAIOpenAIBase<AxAIMistralModel, Ax
|
|
|
7903
7855
|
private updateMessages;
|
|
7904
7856
|
}
|
|
7905
7857
|
|
|
7906
|
-
/**
|
|
7907
|
-
* Configuration type for Ollama AI service
|
|
7908
|
-
*/
|
|
7909
|
-
type AxAIOllamaAIConfig = AxAIOpenAIConfig<string, string>;
|
|
7910
|
-
type AxAIOllamaChatRequest = AxAIOpenAIChatRequest<string> & {
|
|
7911
|
-
think?: boolean;
|
|
7912
|
-
};
|
|
7913
|
-
/**
|
|
7914
|
-
* Creates default configuration for Ollama AI service
|
|
7915
|
-
* @returns Default configuration object with nous-hermes2 model and all-minilm embed model
|
|
7916
|
-
*/
|
|
7917
|
-
declare const axAIOllamaDefaultConfig: () => AxAIOllamaAIConfig;
|
|
7918
|
-
/**
|
|
7919
|
-
* Creates default creative configuration for Ollama AI service
|
|
7920
|
-
* @returns Creative configuration object with nous-hermes2 model and all-minilm embed model
|
|
7921
|
-
*/
|
|
7922
|
-
declare const axAIOllamaDefaultCreativeConfig: () => AxAIOllamaAIConfig;
|
|
7923
|
-
/**
|
|
7924
|
-
* Arguments type for initializing Ollama AI service
|
|
7925
|
-
* @template TModelKey - Type for model key
|
|
7926
|
-
*/
|
|
7927
|
-
type AxAIOllamaArgs<TModelKey> = AxAIOpenAIArgs<'ollama', string, string, TModelKey> & {
|
|
7928
|
-
model?: string;
|
|
7929
|
-
embedModel?: string;
|
|
7930
|
-
url?: string;
|
|
7931
|
-
};
|
|
7932
|
-
/**
|
|
7933
|
-
* Ollama AI service implementation that extends OpenAI base functionality
|
|
7934
|
-
* Provides access to locally hosted Ollama models with OpenAI-compatible API
|
|
7935
|
-
* @template TModelKey - Type for model key
|
|
7936
|
-
*/
|
|
7937
|
-
declare class AxAIOllama<TModelKey> extends AxAIOpenAIBase<string, string, TModelKey, AxAIOllamaChatRequest> {
|
|
7938
|
-
/**
|
|
7939
|
-
* Creates a new Ollama AI service instance
|
|
7940
|
-
* @param args - Configuration arguments for the Ollama service
|
|
7941
|
-
* @param args.apiKey - API key for authentication (defaults to 'not-set')
|
|
7942
|
-
* @param args.url - Base URL for the Ollama API (defaults to 'http://localhost:11434/v1')
|
|
7943
|
-
* @param args.config - Additional configuration options
|
|
7944
|
-
* @param args.options - Service options
|
|
7945
|
-
* @param args.models - Available models configuration
|
|
7946
|
-
*/
|
|
7947
|
-
constructor({ apiKey, url, config, options, models, }: Readonly<Omit<AxAIOllamaArgs<TModelKey>, 'name'>>);
|
|
7948
|
-
}
|
|
7949
|
-
|
|
7950
7858
|
declare enum AxAIOpenAIResponsesModel {
|
|
7951
7859
|
GPT4 = "gpt-4",
|
|
7952
7860
|
GPT41 = "gpt-4.1",
|
|
@@ -8391,7 +8299,7 @@ interface AxAIOpenAIResponsesErrorEvent extends AxAIOpenAIResponsesStreamEventBa
|
|
|
8391
8299
|
readonly param: string | null;
|
|
8392
8300
|
}
|
|
8393
8301
|
type AxAIOpenAIResponsesStreamEvent = AxAIOpenAIResponsesResponseCreatedEvent | AxAIOpenAIResponsesResponseInProgressEvent | AxAIOpenAIResponsesResponseCompletedEvent | AxAIOpenAIResponsesResponseFailedEvent | AxAIOpenAIResponsesResponseIncompleteEvent | AxAIOpenAIResponsesResponseQueuedEvent | AxAIOpenAIResponsesOutputItemAddedEvent | AxAIOpenAIResponsesOutputItemDoneEvent | AxAIOpenAIResponsesContentPartAddedEvent | AxAIOpenAIResponsesContentPartDoneEvent | AxAIOpenAIResponsesOutputTextDeltaEvent | AxAIOpenAIResponsesOutputTextDoneEvent | AxAIOpenAIResponsesRefusalDeltaEvent | AxAIOpenAIResponsesRefusalDoneEvent | AxAIOpenAIResponsesFunctionCallArgumentsDeltaEvent | AxAIOpenAIResponsesFunctionCallArgumentsDoneEvent | AxAIOpenAIResponsesFileSearchCallInProgressEvent | AxAIOpenAIResponsesFileSearchCallSearchingEvent | AxAIOpenAIResponsesFileSearchCallCompletedEvent | AxAIOpenAIResponsesWebSearchCallInProgressEvent | AxAIOpenAIResponsesWebSearchCallSearchingEvent | AxAIOpenAIResponsesWebSearchCallCompletedEvent | AxAIOpenAIResponsesReasoningDeltaEvent | AxAIOpenAIResponsesReasoningDoneEvent | AxAIOpenAIResponsesReasoningSummaryPartAddedEvent | AxAIOpenAIResponsesReasoningSummaryPartDoneEvent | AxAIOpenAIResponsesReasoningSummaryTextDeltaEvent | AxAIOpenAIResponsesReasoningSummaryTextDoneEvent | AxAIOpenAIResponsesReasoningSummaryDeltaEvent | AxAIOpenAIResponsesReasoningSummaryDoneEvent | AxAIOpenAIResponsesImageGenerationCallInProgressEvent | AxAIOpenAIResponsesImageGenerationCallGeneratingEvent | AxAIOpenAIResponsesImageGenerationCallCompletedEvent | AxAIOpenAIResponsesImageGenerationCallPartialImageEvent | AxAIOpenAIResponsesMCPCallInProgressEvent | AxAIOpenAIResponsesMCPCallArgumentsDeltaEvent | AxAIOpenAIResponsesMCPCallArgumentsDoneEvent | AxAIOpenAIResponsesMCPCallCompletedEvent | AxAIOpenAIResponsesMCPCallFailedEvent | AxAIOpenAIResponsesMCPListToolsInProgressEvent | AxAIOpenAIResponsesMCPListToolsCompletedEvent | AxAIOpenAIResponsesMCPListToolsFailedEvent | AxAIOpenAIResponsesOutputTextAnnotationAddedEvent | AxAIOpenAIResponsesErrorEvent;
|
|
8394
|
-
interface
|
|
8302
|
+
interface OpenAIResponsesResponseDelta {
|
|
8395
8303
|
readonly id?: string;
|
|
8396
8304
|
readonly model?: string;
|
|
8397
8305
|
readonly event?: string;
|
|
@@ -8422,7 +8330,6 @@ interface AxAIOpenAIResponsesResponseDelta {
|
|
|
8422
8330
|
};
|
|
8423
8331
|
} | null;
|
|
8424
8332
|
}
|
|
8425
|
-
type ResponsesReqUpdater<TModel, TResponsesReq extends AxAIOpenAIResponsesRequest<TModel>> = (req: Readonly<TResponsesReq>) => Readonly<TResponsesReq>;
|
|
8426
8333
|
type AxAIOpenAIResponsesConfig<TModel, TEmbedModel> = Omit<AxModelConfig, 'topK'> & {
|
|
8427
8334
|
model: TModel;
|
|
8428
8335
|
embedModel?: TEmbedModel;
|
|
@@ -8508,7 +8415,7 @@ interface AxAIOpenAIResponsesBaseArgs<TModel, TEmbedModel, TModelKey, TResponses
|
|
|
8508
8415
|
/**
|
|
8509
8416
|
* Base class for OpenAI AI services using the /v1/responses API endpoint
|
|
8510
8417
|
*/
|
|
8511
|
-
declare class AxAIOpenAIResponsesBase<TModel, TEmbedModel, TModelKey, TResponsesReq extends AxAIOpenAIResponsesRequest<TModel>> extends AxBaseAI<TModel, TEmbedModel, AxAIOpenAIResponsesRequest<TModel>, AxAIOpenAIEmbedRequest<TEmbedModel>, AxAIOpenAIResponsesResponse,
|
|
8418
|
+
declare class AxAIOpenAIResponsesBase<TModel, TEmbedModel, TModelKey, TResponsesReq extends AxAIOpenAIResponsesRequest<TModel>> extends AxBaseAI<TModel, TEmbedModel, AxAIOpenAIResponsesRequest<TModel>, AxAIOpenAIEmbedRequest<TEmbedModel>, AxAIOpenAIResponsesResponse, OpenAIResponsesResponseDelta, AxAIOpenAIEmbedResponse, TModelKey> {
|
|
8512
8419
|
constructor({ apiKey, config, options, apiURL, modelInfo, models, responsesReqUpdater, supportFor, }: Readonly<AxAIOpenAIResponsesBaseArgs<TModel, TEmbedModel, TModelKey, TResponsesReq>>);
|
|
8513
8420
|
}
|
|
8514
8421
|
/**
|
|
@@ -8524,17 +8431,6 @@ declare class AxAIOpenAIResponses<TModelKey = string> extends AxAIOpenAIResponse
|
|
|
8524
8431
|
constructor({ apiKey, config, options, models, modelInfo, }: Readonly<Omit<AxAIOpenAIResponsesArgs<'openai-responses', AxAIOpenAIResponsesModel, AxAIOpenAIEmbedModel, TModelKey>, 'name'>>);
|
|
8525
8432
|
}
|
|
8526
8433
|
|
|
8527
|
-
type OpenRouterConfig = AxAIOpenAIConfig<string, unknown>;
|
|
8528
|
-
declare const axAIOpenRouterDefaultConfig: () => OpenRouterConfig;
|
|
8529
|
-
type AxAIOpenRouterArgs<TModelKey> = AxAIOpenAIArgs<'openrouter', string, unknown, TModelKey> & {
|
|
8530
|
-
referer?: string;
|
|
8531
|
-
title?: string;
|
|
8532
|
-
options?: Readonly<AxAIServiceOptions>;
|
|
8533
|
-
};
|
|
8534
|
-
declare class AxAIOpenRouter<TModelKey> extends AxAIOpenAIBase<string, unknown, TModelKey> {
|
|
8535
|
-
constructor({ apiKey, config, options, models, modelInfo, referer, title, }: Readonly<Omit<AxAIOpenRouterArgs<TModelKey>, 'name'>>);
|
|
8536
|
-
}
|
|
8537
|
-
|
|
8538
8434
|
declare enum AxAIRekaModel {
|
|
8539
8435
|
RekaCore = "reka-core",
|
|
8540
8436
|
RekaFlash = "reka-flash",
|
|
@@ -8606,224 +8502,11 @@ declare const axAIRekaDefaultConfig: () => AxAIRekaConfig;
|
|
|
8606
8502
|
declare const axAIRekaBestConfig: () => AxAIRekaConfig;
|
|
8607
8503
|
declare const axAIRekaCreativeConfig: () => AxAIRekaConfig;
|
|
8608
8504
|
declare const axAIRekaFastConfig: () => AxAIRekaConfig;
|
|
8609
|
-
|
|
8610
|
-
|
|
8611
|
-
apiKey: string;
|
|
8612
|
-
apiURL?: string;
|
|
8613
|
-
config?: Readonly<Partial<AxAIRekaConfig>>;
|
|
8614
|
-
options?: Readonly<AxAIServiceOptions & {
|
|
8615
|
-
streamingUsage?: boolean;
|
|
8616
|
-
}>;
|
|
8617
|
-
modelInfo?: Readonly<AxModelInfo[]>;
|
|
8618
|
-
models?: AxAIInputModelList<AxAIRekaModel, undefined, TModelKey>;
|
|
8619
|
-
}
|
|
8620
|
-
declare class AxAIReka<TModelKey> extends AxBaseAI<AxAIRekaModel, undefined, AxAIRekaChatRequest, unknown, AxAIRekaChatResponse, AxAIRekaChatResponseDelta, unknown, TModelKey> {
|
|
8505
|
+
type AxAIRekaArgs<TModelKey> = AxAIOpenAIArgs<'reka', AxAIRekaModel, undefined, TModelKey>;
|
|
8506
|
+
declare class AxAIReka<TModelKey> extends AxAIOpenAIBase<AxAIRekaModel, undefined, TModelKey> {
|
|
8621
8507
|
constructor({ apiKey, config, options, apiURL, modelInfo, models, }: Readonly<Omit<AxAIRekaArgs<TModelKey>, 'name'>>);
|
|
8622
8508
|
}
|
|
8623
8509
|
|
|
8624
|
-
declare enum AxAITogetherModel {
|
|
8625
|
-
KimiK25 = "moonshotai/Kimi-K2.5",
|
|
8626
|
-
KimiK2Instruct0905 = "moonshotai/Kimi-K2-Instruct-0905",
|
|
8627
|
-
KimiK2Thinking = "moonshotai/Kimi-K2-Thinking",
|
|
8628
|
-
DeepSeekV31 = "deepseek-ai/DeepSeek-V3.1",
|
|
8629
|
-
DeepSeekR1 = "deepseek-ai/DeepSeek-R1",
|
|
8630
|
-
GPTOSS120B = "openai/gpt-oss-120b",
|
|
8631
|
-
GPTOSS20B = "openai/gpt-oss-20b",
|
|
8632
|
-
Qwen35_397B = "Qwen/Qwen3.5-397B-A17B",
|
|
8633
|
-
Qwen3CoderNext = "Qwen/Qwen3-Coder-Next-FP8",
|
|
8634
|
-
Qwen3Coder480B = "Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8",
|
|
8635
|
-
Qwen3_235BInstruct2507 = "Qwen/Qwen3-235B-A22B-Instruct-2507-tput",
|
|
8636
|
-
Qwen3_235BThinking2507 = "Qwen/Qwen3-235B-A22B-Thinking-2507",
|
|
8637
|
-
Qwen3Next80BInstruct = "Qwen/Qwen3-Next-80B-A3B-Instruct",
|
|
8638
|
-
Qwen3Next80BThinking = "Qwen/Qwen3-Next-80B-A3B-Thinking",
|
|
8639
|
-
GLM5 = "zai-org/GLM-5",
|
|
8640
|
-
GLM47 = "zai-org/GLM-4.7",
|
|
8641
|
-
Llama4Maverick = "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8",
|
|
8642
|
-
Llama33_70B = "meta-llama/Llama-3.3-70B-Instruct-Turbo"
|
|
8643
|
-
}
|
|
8644
|
-
type AxAITogetherChatModel = AxAITogetherModel | (string & {});
|
|
8645
|
-
|
|
8646
|
-
type TogetherAIConfig = AxAIOpenAIConfig<AxAITogetherChatModel, unknown>;
|
|
8647
|
-
declare const axAITogetherDefaultConfig: () => TogetherAIConfig;
|
|
8648
|
-
type AxAITogetherArgs<TModelKey> = AxAIOpenAIArgs<'together', AxAITogetherChatModel, unknown, TModelKey>;
|
|
8649
|
-
declare class AxAITogether<TModelKey> extends AxAIOpenAIBase<AxAITogetherChatModel, unknown, TModelKey> {
|
|
8650
|
-
constructor({ apiKey, config, options, models, modelInfo, }: Readonly<Omit<AxAITogetherArgs<TModelKey>, 'name'>>);
|
|
8651
|
-
}
|
|
8652
|
-
|
|
8653
|
-
/**
|
|
8654
|
-
* WebLLM: Models for text generation
|
|
8655
|
-
* Based on WebLLM's supported models
|
|
8656
|
-
*/
|
|
8657
|
-
declare enum AxAIWebLLMModel {
|
|
8658
|
-
Llama31_8B_Instruct = "Llama-3.1-8B-Instruct-q4f32_1-MLC",
|
|
8659
|
-
Llama31_70B_Instruct = "Llama-3.1-70B-Instruct-q4f16_1-MLC",
|
|
8660
|
-
Llama32_1B_Instruct = "Llama-3.2-1B-Instruct-q4f32_1-MLC",
|
|
8661
|
-
Llama32_3B_Instruct = "Llama-3.2-3B-Instruct-q4f32_1-MLC",
|
|
8662
|
-
Mistral7B_Instruct = "Mistral-7B-Instruct-v0.3-q4f32_1-MLC",
|
|
8663
|
-
Phi35_Mini_Instruct = "Phi-3.5-mini-instruct-q4f32_1-MLC",
|
|
8664
|
-
Gemma2_2B_Instruct = "gemma-2-2b-it-q4f32_1-MLC",
|
|
8665
|
-
Gemma2_9B_Instruct = "gemma-2-9b-it-q4f32_1-MLC",
|
|
8666
|
-
Qwen2_5_0_5B_Instruct = "Qwen2.5-0.5B-Instruct-q4f32_1-MLC",
|
|
8667
|
-
Qwen2_5_1_5B_Instruct = "Qwen2.5-1.5B-Instruct-q4f32_1-MLC",
|
|
8668
|
-
Qwen2_5_3B_Instruct = "Qwen2.5-3B-Instruct-q4f32_1-MLC",
|
|
8669
|
-
Qwen2_5_7B_Instruct = "Qwen2.5-7B-Instruct-q4f32_1-MLC"
|
|
8670
|
-
}
|
|
8671
|
-
/**
|
|
8672
|
-
* WebLLM: Model options for text generation
|
|
8673
|
-
*/
|
|
8674
|
-
type AxAIWebLLMConfig = AxModelConfig & {
|
|
8675
|
-
model: AxAIWebLLMModel;
|
|
8676
|
-
logitBias?: Record<number, number>;
|
|
8677
|
-
logProbs?: boolean;
|
|
8678
|
-
topLogprobs?: number;
|
|
8679
|
-
};
|
|
8680
|
-
/**
|
|
8681
|
-
* WebLLM: Chat request structure
|
|
8682
|
-
* Based on OpenAI-compatible API from WebLLM
|
|
8683
|
-
*/
|
|
8684
|
-
type AxAIWebLLMChatRequest = {
|
|
8685
|
-
model: AxAIWebLLMModel;
|
|
8686
|
-
messages: Array<{
|
|
8687
|
-
role: 'system' | 'user' | 'assistant' | 'function';
|
|
8688
|
-
content?: string;
|
|
8689
|
-
name?: string;
|
|
8690
|
-
function_call?: {
|
|
8691
|
-
name: string;
|
|
8692
|
-
arguments: string;
|
|
8693
|
-
};
|
|
8694
|
-
}>;
|
|
8695
|
-
temperature?: number;
|
|
8696
|
-
top_p?: number;
|
|
8697
|
-
max_tokens?: number;
|
|
8698
|
-
stream?: boolean;
|
|
8699
|
-
stop?: string | string[];
|
|
8700
|
-
presence_penalty?: number;
|
|
8701
|
-
frequency_penalty?: number;
|
|
8702
|
-
logit_bias?: Record<number, number>;
|
|
8703
|
-
logprobs?: boolean;
|
|
8704
|
-
top_logprobs?: number;
|
|
8705
|
-
n?: number;
|
|
8706
|
-
tools?: Array<{
|
|
8707
|
-
type: 'function';
|
|
8708
|
-
function: {
|
|
8709
|
-
name: string;
|
|
8710
|
-
description: string;
|
|
8711
|
-
parameters: object;
|
|
8712
|
-
};
|
|
8713
|
-
}>;
|
|
8714
|
-
tool_choice?: 'none' | 'auto' | {
|
|
8715
|
-
type: 'function';
|
|
8716
|
-
function: {
|
|
8717
|
-
name: string;
|
|
8718
|
-
};
|
|
8719
|
-
};
|
|
8720
|
-
};
|
|
8721
|
-
/**
|
|
8722
|
-
* WebLLM: Chat response structure
|
|
8723
|
-
*/
|
|
8724
|
-
type AxAIWebLLMChatResponse = {
|
|
8725
|
-
id: string;
|
|
8726
|
-
object: 'chat.completion';
|
|
8727
|
-
created: number;
|
|
8728
|
-
model: AxAIWebLLMModel;
|
|
8729
|
-
choices: Array<{
|
|
8730
|
-
index: number;
|
|
8731
|
-
message: {
|
|
8732
|
-
role: 'assistant';
|
|
8733
|
-
content?: string;
|
|
8734
|
-
tool_calls?: Array<{
|
|
8735
|
-
id: string;
|
|
8736
|
-
type: 'function';
|
|
8737
|
-
function: {
|
|
8738
|
-
name: string;
|
|
8739
|
-
arguments: string;
|
|
8740
|
-
};
|
|
8741
|
-
}>;
|
|
8742
|
-
};
|
|
8743
|
-
finish_reason: 'stop' | 'length' | 'tool_calls' | 'content_filter';
|
|
8744
|
-
logprobs?: {
|
|
8745
|
-
content: Array<{
|
|
8746
|
-
token: string;
|
|
8747
|
-
logprob: number;
|
|
8748
|
-
bytes: number[];
|
|
8749
|
-
top_logprobs: Array<{
|
|
8750
|
-
token: string;
|
|
8751
|
-
logprob: number;
|
|
8752
|
-
bytes: number[];
|
|
8753
|
-
}>;
|
|
8754
|
-
}>;
|
|
8755
|
-
};
|
|
8756
|
-
}>;
|
|
8757
|
-
usage: {
|
|
8758
|
-
prompt_tokens: number;
|
|
8759
|
-
completion_tokens: number;
|
|
8760
|
-
total_tokens: number;
|
|
8761
|
-
};
|
|
8762
|
-
};
|
|
8763
|
-
/**
|
|
8764
|
-
* WebLLM: Streaming chat response structure
|
|
8765
|
-
*/
|
|
8766
|
-
type AxAIWebLLMChatResponseDelta = {
|
|
8767
|
-
id: string;
|
|
8768
|
-
object: 'chat.completion.chunk';
|
|
8769
|
-
created: number;
|
|
8770
|
-
model: AxAIWebLLMModel;
|
|
8771
|
-
choices: Array<{
|
|
8772
|
-
index: number;
|
|
8773
|
-
delta: {
|
|
8774
|
-
role?: 'assistant';
|
|
8775
|
-
content?: string;
|
|
8776
|
-
tool_calls?: Array<{
|
|
8777
|
-
index: number;
|
|
8778
|
-
id?: string;
|
|
8779
|
-
type?: 'function';
|
|
8780
|
-
function?: {
|
|
8781
|
-
name?: string;
|
|
8782
|
-
arguments?: string;
|
|
8783
|
-
};
|
|
8784
|
-
}>;
|
|
8785
|
-
};
|
|
8786
|
-
finish_reason?: 'stop' | 'length' | 'tool_calls' | 'content_filter';
|
|
8787
|
-
logprobs?: {
|
|
8788
|
-
content: Array<{
|
|
8789
|
-
token: string;
|
|
8790
|
-
logprob: number;
|
|
8791
|
-
bytes: number[];
|
|
8792
|
-
top_logprobs: Array<{
|
|
8793
|
-
token: string;
|
|
8794
|
-
logprob: number;
|
|
8795
|
-
bytes: number[];
|
|
8796
|
-
}>;
|
|
8797
|
-
}>;
|
|
8798
|
-
};
|
|
8799
|
-
}>;
|
|
8800
|
-
usage?: {
|
|
8801
|
-
prompt_tokens: number;
|
|
8802
|
-
completion_tokens: number;
|
|
8803
|
-
total_tokens: number;
|
|
8804
|
-
};
|
|
8805
|
-
};
|
|
8806
|
-
/**
|
|
8807
|
-
* WebLLM doesn't support embeddings natively
|
|
8808
|
-
* This is a placeholder for consistency with the framework
|
|
8809
|
-
*/
|
|
8810
|
-
type AxAIWebLLMEmbedModel = never;
|
|
8811
|
-
type AxAIWebLLMEmbedRequest = never;
|
|
8812
|
-
type AxAIWebLLMEmbedResponse = never;
|
|
8813
|
-
|
|
8814
|
-
declare const axAIWebLLMDefaultConfig: () => AxAIWebLLMConfig;
|
|
8815
|
-
declare const axAIWebLLMCreativeConfig: () => AxAIWebLLMConfig;
|
|
8816
|
-
interface AxAIWebLLMArgs<TModelKey> {
|
|
8817
|
-
name: 'webllm';
|
|
8818
|
-
engine: any;
|
|
8819
|
-
config?: Readonly<Partial<AxAIWebLLMConfig>>;
|
|
8820
|
-
options?: Readonly<AxAIServiceOptions>;
|
|
8821
|
-
models?: AxAIInputModelList<AxAIWebLLMModel, AxAIWebLLMEmbedModel, TModelKey>;
|
|
8822
|
-
}
|
|
8823
|
-
declare class AxAIWebLLM<TModelKey> extends AxBaseAI<AxAIWebLLMModel, AxAIWebLLMEmbedModel, AxAIWebLLMChatRequest, AxAIWebLLMEmbedRequest, AxAIWebLLMChatResponse, AxAIWebLLMChatResponseDelta, AxAIWebLLMEmbedResponse, TModelKey> {
|
|
8824
|
-
constructor({ engine, config, options, models, }: Readonly<Omit<AxAIWebLLMArgs<TModelKey>, 'name'>>);
|
|
8825
|
-
}
|
|
8826
|
-
|
|
8827
8510
|
declare enum AxAIGrokModel {
|
|
8828
8511
|
Grok43 = "grok-4.3",
|
|
8829
8512
|
Grok43Latest = "grok-4.3-latest",
|
|
@@ -8895,8 +8578,8 @@ declare class AxAIGrok<TModelKey> extends AxAIOpenAIBase<AxAIGrokModel, AxAIGrok
|
|
|
8895
8578
|
speak(req: Readonly<AxSpeechRequest<AxAIGrokModel | TModelKey>>, options?: Readonly<AxAIServiceOptions>): Promise<AxSpeechResponse>;
|
|
8896
8579
|
}
|
|
8897
8580
|
|
|
8898
|
-
type AxAIArgs<TModelKey> = AxAIOpenAIArgs<'openai', AxAIOpenAIModel, AxAIOpenAIEmbedModel, TModelKey> | AxAIOpenAIResponsesArgs<'openai-responses', AxAIOpenAIResponsesModel, AxAIOpenAIEmbedModel, TModelKey> | AxAIAzureOpenAIArgs<TModelKey> |
|
|
8899
|
-
type AxAIModels = AxAIOpenAIModel | AxAIAnthropicModel |
|
|
8581
|
+
type AxAIArgs<TModelKey> = AxAIOpenAIArgs<'openai', AxAIOpenAIModel, AxAIOpenAIEmbedModel, TModelKey> | AxAIOpenAIResponsesArgs<'openai-responses', AxAIOpenAIResponsesModel, AxAIOpenAIEmbedModel, TModelKey> | AxAIAzureOpenAIArgs<TModelKey> | AxAIAnthropicArgs<TModelKey> | AxAIGoogleGeminiArgs<TModelKey> | AxAICohereArgs<TModelKey> | AxAIHuggingFaceArgs<TModelKey> | AxAIMistralArgs<TModelKey> | AxAIDeepSeekArgs<TModelKey> | AxAIRekaArgs<TModelKey> | AxAIGrokArgs<TModelKey>;
|
|
8582
|
+
type AxAIModels = AxAIOpenAIModel | AxAIAnthropicModel | AxAIGoogleGeminiModel | AxAICohereModel | AxAIHuggingFaceModel | AxAIMistralModel | AxAIDeepSeekModel | AxAIGrokModel;
|
|
8900
8583
|
type AxAIEmbedModels = AxAIOpenAIEmbedModel | AxAIGoogleGeminiEmbedModel | AxAICohereEmbedModel;
|
|
8901
8584
|
type ExtractModelKeysAndValues<T> = T extends readonly {
|
|
8902
8585
|
key: infer K;
|
|
@@ -8918,21 +8601,16 @@ type InferTModelKey<T> = T extends {
|
|
|
8918
8601
|
* - `'anthropic'` - Anthropic (Claude 3.5 Sonnet, Claude 3 Opus, etc.)
|
|
8919
8602
|
* - `'google-gemini'` - Google (Gemini 1.5 Pro, Gemini 2.0 Flash, etc.)
|
|
8920
8603
|
* - `'azure-openai'` - Azure OpenAI Service
|
|
8921
|
-
* - `'groq'` - Groq (Llama, Mixtral with fast inference)
|
|
8922
8604
|
* - `'cohere'` - Cohere (Command R+, embeddings)
|
|
8923
8605
|
* - `'mistral'` - Mistral AI (Mistral Large, Codestral)
|
|
8924
8606
|
* - `'deepseek'` - DeepSeek (DeepSeek-V4-Flash, DeepSeek-V4-Pro)
|
|
8925
|
-
* - `'together'` - Together AI (various open models)
|
|
8926
|
-
* - `'openrouter'` - OpenRouter (unified API for many providers)
|
|
8927
|
-
* - `'ollama'` - Ollama (local models)
|
|
8928
8607
|
* - `'huggingface'` - Hugging Face Inference API
|
|
8929
8608
|
* - `'reka'` - Reka AI
|
|
8930
8609
|
* - `'grok'` - xAI Grok
|
|
8931
|
-
* - `'webllm'` - WebLLM (browser-based inference)
|
|
8932
8610
|
*
|
|
8933
8611
|
* @param options - Provider-specific configuration. Must include `name` to identify the provider.
|
|
8934
8612
|
* @param options.name - The provider identifier (see list above)
|
|
8935
|
-
* @param options.apiKey - API key for the provider
|
|
8613
|
+
* @param options.apiKey - API key for the provider
|
|
8936
8614
|
* @param options.config - Optional default model configuration (maxTokens, temperature, etc.)
|
|
8937
8615
|
* @param options.models - Optional custom model aliases for type-safe model selection
|
|
8938
8616
|
*
|
|
@@ -8975,11 +8653,13 @@ type InferTModelKey<T> = T extends {
|
|
|
8975
8653
|
* // Now use ai with model: 'fast' or model: 'smart'
|
|
8976
8654
|
* ```
|
|
8977
8655
|
*
|
|
8978
|
-
* @example
|
|
8656
|
+
* @example OpenAI-compatible endpoint
|
|
8979
8657
|
* ```typescript
|
|
8980
8658
|
* const ai = ai({
|
|
8981
|
-
* name: '
|
|
8982
|
-
*
|
|
8659
|
+
* name: 'openai',
|
|
8660
|
+
* apiKey: process.env.PROVIDER_API_KEY,
|
|
8661
|
+
* apiURL: 'https://example.com/v1',
|
|
8662
|
+
* config: { model: 'provider/model-name' }
|
|
8983
8663
|
* });
|
|
8984
8664
|
* ```
|
|
8985
8665
|
*/
|
|
@@ -8987,23 +8667,7 @@ declare function ai<const T extends AxAIArgs<any>>(options: T): AxAI<InferTModel
|
|
|
8987
8667
|
declare class AxAI<TModelKey = string> implements AxAIService<any, any, TModelKey> {
|
|
8988
8668
|
private ai;
|
|
8989
8669
|
static create<const T extends AxAIArgs<any>>(options: T): AxAI<InferTModelKey<T>>;
|
|
8990
|
-
|
|
8991
|
-
* @deprecated Use `AxAI.create()` or `ai()` function instead for better type safety.
|
|
8992
|
-
* This constructor will be removed in v15.0.0.
|
|
8993
|
-
*
|
|
8994
|
-
* Migration timeline:
|
|
8995
|
-
* - v13.0.24+: Deprecation warnings (current)
|
|
8996
|
-
* - v14.0.0: Runtime console warnings
|
|
8997
|
-
* - v15.0.0: Complete removal
|
|
8998
|
-
*
|
|
8999
|
-
* @example
|
|
9000
|
-
* ```typescript
|
|
9001
|
-
* // Instead of: new AxAI({ name: 'openai', apiKey: '...' })
|
|
9002
|
-
* // Use: AxAI.create({ name: 'openai', apiKey: '...' })
|
|
9003
|
-
* // Or: ai({ name: 'openai', apiKey: '...' })
|
|
9004
|
-
* ```
|
|
9005
|
-
*/
|
|
9006
|
-
constructor(options: Readonly<AxAIArgs<TModelKey>>);
|
|
8670
|
+
private constructor();
|
|
9007
8671
|
getName(): string;
|
|
9008
8672
|
getId(): string;
|
|
9009
8673
|
getFeatures(model?: string): AxAIFeatures;
|
|
@@ -9074,11 +8738,6 @@ declare const axModelInfoDeepSeek: AxModelInfo[];
|
|
|
9074
8738
|
*/
|
|
9075
8739
|
declare const axModelInfoGoogleGemini: AxModelInfo[];
|
|
9076
8740
|
|
|
9077
|
-
/**
|
|
9078
|
-
* AxAIGroq: Model information
|
|
9079
|
-
*/
|
|
9080
|
-
declare const axModelInfoGroq: AxModelInfo[];
|
|
9081
|
-
|
|
9082
8741
|
/**
|
|
9083
8742
|
* HuggingFace: Model information
|
|
9084
8743
|
*/
|
|
@@ -9258,28 +8917,6 @@ declare const axModelInfoOpenAI: AxModelInfo[];
|
|
|
9258
8917
|
*/
|
|
9259
8918
|
declare const axModelInfoOpenAIResponses: AxModelInfo[];
|
|
9260
8919
|
|
|
9261
|
-
declare class AxAIOpenAIResponsesImpl<TModel, TEmbedModel, // Kept for interface compatibility, but not used by this impl.
|
|
9262
|
-
TResponsesReq extends AxAIOpenAIResponsesRequest<TModel>> implements AxAIServiceImpl<TModel, TEmbedModel, Readonly<AxAIOpenAIResponsesRequest<TModel>>, // ChatReq (now ResponsesReq)
|
|
9263
|
-
Readonly<AxAIOpenAIEmbedRequest<TEmbedModel>>, // EmbedReq
|
|
9264
|
-
Readonly<AxAIOpenAIResponsesResponse>, // ChatResp (now ResponsesResp)
|
|
9265
|
-
Readonly<AxAIOpenAIResponsesResponseDelta>, // ChatRespDelta (now ResponsesRespDelta)
|
|
9266
|
-
Readonly<AxAIOpenAIEmbedResponse>> {
|
|
9267
|
-
private readonly config;
|
|
9268
|
-
private readonly streamingUsage;
|
|
9269
|
-
private readonly responsesReqUpdater?;
|
|
9270
|
-
private tokensUsed;
|
|
9271
|
-
constructor(config: Readonly<AxAIOpenAIResponsesConfig<TModel, TEmbedModel>>, streamingUsage: boolean, // If /v1/responses supports include_usage for streams
|
|
9272
|
-
responsesReqUpdater?: ResponsesReqUpdater<TModel, TResponsesReq> | undefined);
|
|
9273
|
-
getTokenUsage(): Readonly<AxTokenUsage> | undefined;
|
|
9274
|
-
getModelConfig(): Readonly<AxModelConfig>;
|
|
9275
|
-
private mapInternalContentToResponsesInput;
|
|
9276
|
-
private createResponsesReqInternalInput;
|
|
9277
|
-
createChatReq(req: Readonly<AxInternalChatRequest<TModel>>, config: Readonly<AxAIServiceOptions>): [Readonly<AxAPI>, Readonly<AxAIOpenAIResponsesRequest<TModel>>];
|
|
9278
|
-
createChatResp(resp: Readonly<AxAIOpenAIResponsesResponse>): Readonly<AxChatResponse>;
|
|
9279
|
-
createChatStreamResp: (streamEvent: Readonly<AxAIOpenAIResponsesResponseDelta>, state: object) => Readonly<AxChatResponse>;
|
|
9280
|
-
createEmbedReq(req: Readonly<AxInternalEmbedRequest<TEmbedModel>>): [AxAPI, AxAIOpenAIEmbedRequest<TEmbedModel>];
|
|
9281
|
-
}
|
|
9282
|
-
|
|
9283
8920
|
type OpenAICompatibleUsageDetails = {
|
|
9284
8921
|
cached_tokens?: number;
|
|
9285
8922
|
reasoning_tokens?: number;
|
|
@@ -9531,8 +9168,6 @@ declare class AxProviderRouter {
|
|
|
9531
9168
|
};
|
|
9532
9169
|
}
|
|
9533
9170
|
|
|
9534
|
-
declare const axModelInfoTogether: AxModelInfo[];
|
|
9535
|
-
|
|
9536
9171
|
type AxChatRequestMessage = AxChatRequest['chatPrompt'][number];
|
|
9537
9172
|
/**
|
|
9538
9173
|
* Validates a chat request message item to ensure it meets the required criteria
|
|
@@ -9547,255 +9182,8 @@ declare function axValidateChatRequestMessage(item: AxChatRequestMessage): void;
|
|
|
9547
9182
|
*/
|
|
9548
9183
|
declare function axValidateChatResponseResult(results: Readonly<AxChatResponseResult[]> | Readonly<AxChatResponseResult>): void;
|
|
9549
9184
|
|
|
9550
|
-
/**
|
|
9551
|
-
* WebLLM model information
|
|
9552
|
-
* Note: WebLLM runs models locally in the browser, so there are no API costs
|
|
9553
|
-
* However, we include context window and capability information
|
|
9554
|
-
*/
|
|
9555
|
-
declare const axModelInfoWebLLM: AxModelInfo[];
|
|
9556
|
-
|
|
9557
9185
|
declare const axModelInfoGrok: AxModelInfo[];
|
|
9558
9186
|
|
|
9559
|
-
type AxDBUpsertRequest = {
|
|
9560
|
-
id: string;
|
|
9561
|
-
text?: string;
|
|
9562
|
-
values?: readonly number[];
|
|
9563
|
-
metadata?: Record<string, string>;
|
|
9564
|
-
table: string;
|
|
9565
|
-
namespace?: string;
|
|
9566
|
-
};
|
|
9567
|
-
type AxDBUpsertResponse = {
|
|
9568
|
-
ids: string[];
|
|
9569
|
-
};
|
|
9570
|
-
type AxDBQueryRequest = {
|
|
9571
|
-
id?: string;
|
|
9572
|
-
text?: string;
|
|
9573
|
-
values?: readonly number[];
|
|
9574
|
-
table: string;
|
|
9575
|
-
columns?: string[];
|
|
9576
|
-
limit?: number;
|
|
9577
|
-
namespace?: string;
|
|
9578
|
-
};
|
|
9579
|
-
type AxDBQueryResponse = {
|
|
9580
|
-
matches: {
|
|
9581
|
-
id: string;
|
|
9582
|
-
score: number;
|
|
9583
|
-
metadata?: Record<string, string>;
|
|
9584
|
-
table?: string;
|
|
9585
|
-
}[];
|
|
9586
|
-
};
|
|
9587
|
-
interface AxDBService extends AxDBQueryService {
|
|
9588
|
-
upsert(req: Readonly<AxDBUpsertRequest>, update?: boolean): Promise<AxDBUpsertResponse>;
|
|
9589
|
-
batchUpsert(batchReq: Readonly<AxDBUpsertRequest[]>, update?: boolean): Promise<AxDBUpsertResponse>;
|
|
9590
|
-
}
|
|
9591
|
-
interface AxDBQueryService {
|
|
9592
|
-
query(req: Readonly<AxDBQueryRequest>): Promise<AxDBQueryResponse>;
|
|
9593
|
-
}
|
|
9594
|
-
|
|
9595
|
-
interface AxDBBaseArgs {
|
|
9596
|
-
fetch?: typeof fetch;
|
|
9597
|
-
tracer?: Tracer;
|
|
9598
|
-
}
|
|
9599
|
-
interface AxDBBaseOpOptions {
|
|
9600
|
-
span?: Span;
|
|
9601
|
-
}
|
|
9602
|
-
declare class AxDBBase implements AxDBService {
|
|
9603
|
-
protected name: string;
|
|
9604
|
-
protected fetch?: typeof fetch;
|
|
9605
|
-
private tracer?;
|
|
9606
|
-
_upsert?: (req: Readonly<AxDBUpsertRequest>, update?: boolean, options?: Readonly<AxDBBaseOpOptions>) => Promise<AxDBUpsertResponse>;
|
|
9607
|
-
_batchUpsert?: (batchReq: Readonly<AxDBUpsertRequest[]>, update?: boolean, options?: Readonly<AxDBBaseOpOptions>) => Promise<AxDBUpsertResponse>;
|
|
9608
|
-
_query?: (req: Readonly<AxDBQueryRequest>, options?: Readonly<AxDBBaseOpOptions>) => Promise<AxDBQueryResponse>;
|
|
9609
|
-
constructor({ name, fetch, tracer, }: Readonly<AxDBBaseArgs & {
|
|
9610
|
-
name: string;
|
|
9611
|
-
}>);
|
|
9612
|
-
upsert(req: Readonly<AxDBUpsertRequest>, update?: boolean): Promise<AxDBUpsertResponse>;
|
|
9613
|
-
batchUpsert(req: Readonly<AxDBUpsertRequest[]>, update?: boolean): Promise<AxDBUpsertResponse>;
|
|
9614
|
-
query(req: Readonly<AxDBQueryRequest>): Promise<AxDBQueryResponse>;
|
|
9615
|
-
}
|
|
9616
|
-
|
|
9617
|
-
type AxDBCloudflareOpOptions = AxDBBaseOpOptions;
|
|
9618
|
-
interface AxDBCloudflareArgs extends AxDBBaseArgs {
|
|
9619
|
-
name: 'cloudflare';
|
|
9620
|
-
apiKey: string;
|
|
9621
|
-
accountId: string;
|
|
9622
|
-
fetch?: typeof fetch;
|
|
9623
|
-
}
|
|
9624
|
-
/**
|
|
9625
|
-
* Cloudflare: DB Service
|
|
9626
|
-
*/
|
|
9627
|
-
declare class AxDBCloudflare extends AxDBBase {
|
|
9628
|
-
private apiKey;
|
|
9629
|
-
private accountId;
|
|
9630
|
-
constructor({ apiKey, accountId, fetch, tracer, }: Readonly<Omit<AxDBCloudflareArgs, 'name'>>);
|
|
9631
|
-
_upsert: (req: Readonly<AxDBUpsertRequest>, _update?: boolean, options?: Readonly<AxDBCloudflareOpOptions>) => Promise<AxDBUpsertResponse>;
|
|
9632
|
-
batchUpsert: (batchReq: Readonly<AxDBUpsertRequest[]>, update?: boolean, options?: Readonly<AxDBCloudflareOpOptions>) => Promise<AxDBUpsertResponse>;
|
|
9633
|
-
query: (req: Readonly<AxDBQueryRequest>, options?: Readonly<AxDBCloudflareOpOptions>) => Promise<AxDBQueryResponse>;
|
|
9634
|
-
}
|
|
9635
|
-
|
|
9636
|
-
type AxDBMemoryOpOptions = AxDBBaseOpOptions;
|
|
9637
|
-
interface AxDBMemoryArgs extends AxDBBaseArgs {
|
|
9638
|
-
name: 'memory';
|
|
9639
|
-
}
|
|
9640
|
-
type AxDBState = Record<string, Record<string, AxDBUpsertRequest>>;
|
|
9641
|
-
/**
|
|
9642
|
-
* MemoryDB: DB Service
|
|
9643
|
-
*/
|
|
9644
|
-
declare class AxDBMemory extends AxDBBase {
|
|
9645
|
-
private state;
|
|
9646
|
-
constructor({ tracer }?: Readonly<Omit<AxDBMemoryArgs, 'name'>>);
|
|
9647
|
-
_upsert: (req: Readonly<AxDBUpsertRequest>, _update?: boolean, _options?: Readonly<AxDBMemoryOpOptions>) => Promise<AxDBUpsertResponse>;
|
|
9648
|
-
_batchUpsert: (batchReq: Readonly<AxDBUpsertRequest[]>, update?: boolean, _options?: Readonly<AxDBMemoryOpOptions>) => Promise<AxDBUpsertResponse>;
|
|
9649
|
-
_query: (req: Readonly<AxDBQueryRequest>, _options?: Readonly<AxDBMemoryOpOptions>) => Promise<AxDBQueryResponse>;
|
|
9650
|
-
getDB: () => AxDBState;
|
|
9651
|
-
setDB: (state: AxDBState) => void;
|
|
9652
|
-
clearDB: () => void;
|
|
9653
|
-
}
|
|
9654
|
-
|
|
9655
|
-
type AxDBPineconeOpOptions = AxDBBaseOpOptions;
|
|
9656
|
-
interface AxDBPineconeArgs extends AxDBBaseArgs {
|
|
9657
|
-
name: 'pinecone';
|
|
9658
|
-
apiKey: string;
|
|
9659
|
-
host: string;
|
|
9660
|
-
fetch?: typeof fetch;
|
|
9661
|
-
}
|
|
9662
|
-
/**
|
|
9663
|
-
* Pinecone: DB Service
|
|
9664
|
-
*/
|
|
9665
|
-
declare class AxDBPinecone extends AxDBBase {
|
|
9666
|
-
private apiKey;
|
|
9667
|
-
private apiURL;
|
|
9668
|
-
constructor({ apiKey, host, fetch, tracer, }: Readonly<Omit<AxDBPineconeArgs, 'name'>>);
|
|
9669
|
-
_upsert: (req: Readonly<AxDBUpsertRequest>, update?: boolean, options?: Readonly<AxDBPineconeOpOptions>) => Promise<AxDBUpsertResponse>;
|
|
9670
|
-
_batchUpsert: (batchReq: Readonly<AxDBUpsertRequest[]>, _update?: boolean, options?: Readonly<AxDBPineconeOpOptions>) => Promise<AxDBUpsertResponse>;
|
|
9671
|
-
query: (req: Readonly<AxDBQueryRequest>, options?: Readonly<AxDBPineconeOpOptions>) => Promise<AxDBQueryResponse>;
|
|
9672
|
-
}
|
|
9673
|
-
|
|
9674
|
-
type AxDBWeaviateOpOptions = AxDBBaseOpOptions;
|
|
9675
|
-
interface AxDBWeaviateArgs extends AxDBBaseArgs {
|
|
9676
|
-
name: 'weaviate';
|
|
9677
|
-
apiKey: string;
|
|
9678
|
-
host: string;
|
|
9679
|
-
fetch?: typeof fetch;
|
|
9680
|
-
}
|
|
9681
|
-
/**
|
|
9682
|
-
* Weaviate: DB Service
|
|
9683
|
-
*/
|
|
9684
|
-
declare class AxDBWeaviate extends AxDBBase {
|
|
9685
|
-
private apiKey;
|
|
9686
|
-
private apiURL;
|
|
9687
|
-
constructor({ apiKey, host, fetch, tracer, }: Readonly<Omit<AxDBWeaviateArgs, 'name'>>);
|
|
9688
|
-
_upsert: (req: Readonly<AxDBUpsertRequest>, update?: boolean, options?: Readonly<AxDBWeaviateOpOptions>) => Promise<AxDBUpsertResponse>;
|
|
9689
|
-
_batchUpsert: (batchReq: Readonly<AxDBUpsertRequest[]>, update?: boolean, options?: Readonly<AxDBWeaviateOpOptions>) => Promise<AxDBUpsertResponse>;
|
|
9690
|
-
_query: (req: Readonly<AxDBQueryRequest>, options?: Readonly<AxDBWeaviateOpOptions>) => Promise<AxDBQueryResponse>;
|
|
9691
|
-
}
|
|
9692
|
-
|
|
9693
|
-
type AxDBArgs = AxDBCloudflareArgs | AxDBPineconeArgs | AxDBWeaviateArgs | AxDBMemoryArgs;
|
|
9694
|
-
declare class AxDB implements AxDBService {
|
|
9695
|
-
private db;
|
|
9696
|
-
constructor(args: Readonly<AxDBArgs>);
|
|
9697
|
-
upsert(req: Readonly<AxDBUpsertRequest>, update?: boolean): Promise<AxDBUpsertResponse>;
|
|
9698
|
-
batchUpsert(batchReq: Readonly<AxDBUpsertRequest[]>, update?: boolean): Promise<AxDBUpsertResponse>;
|
|
9699
|
-
query(req: Readonly<AxDBQueryRequest>): Promise<AxDBQueryResponse>;
|
|
9700
|
-
}
|
|
9701
|
-
|
|
9702
|
-
type AxRewriteIn = {
|
|
9703
|
-
query: string;
|
|
9704
|
-
};
|
|
9705
|
-
type AxRewriteOut = {
|
|
9706
|
-
rewrittenQuery: string;
|
|
9707
|
-
};
|
|
9708
|
-
type AxRerankerIn = {
|
|
9709
|
-
query: string;
|
|
9710
|
-
items: string[];
|
|
9711
|
-
};
|
|
9712
|
-
type AxRerankerOut = {
|
|
9713
|
-
rankedItems: string[];
|
|
9714
|
-
};
|
|
9715
|
-
interface AxDBLoaderOptions {
|
|
9716
|
-
chunker?: (text: string) => string[];
|
|
9717
|
-
rewriter?: AxGen<AxRewriteIn, AxRewriteOut>;
|
|
9718
|
-
reranker?: AxGen<AxRerankerIn, AxRerankerOut>;
|
|
9719
|
-
}
|
|
9720
|
-
interface AxDBManagerArgs {
|
|
9721
|
-
ai: AxAIService;
|
|
9722
|
-
db: AxDBService;
|
|
9723
|
-
config?: AxDBLoaderOptions;
|
|
9724
|
-
}
|
|
9725
|
-
interface AxDBMatch {
|
|
9726
|
-
score: number;
|
|
9727
|
-
text: string;
|
|
9728
|
-
}
|
|
9729
|
-
declare class AxDBManager {
|
|
9730
|
-
private ai;
|
|
9731
|
-
private db;
|
|
9732
|
-
private chunker;
|
|
9733
|
-
private rewriter?;
|
|
9734
|
-
private reranker?;
|
|
9735
|
-
constructor({ ai, db, config }: Readonly<AxDBManagerArgs>);
|
|
9736
|
-
private defaultChunker;
|
|
9737
|
-
insert: (text: Readonly<string | string[]>, options?: Readonly<{
|
|
9738
|
-
batchSize?: number;
|
|
9739
|
-
maxWordsPerChunk?: number;
|
|
9740
|
-
minWordsPerChunk?: number;
|
|
9741
|
-
abortSignal?: AbortSignal;
|
|
9742
|
-
}>) => Promise<void>;
|
|
9743
|
-
query: (query: Readonly<string | string[] | number | number[]>, { topPercent, abortSignal, }?: Readonly<{
|
|
9744
|
-
topPercent?: number;
|
|
9745
|
-
abortSignal?: AbortSignal;
|
|
9746
|
-
}> | undefined) => Promise<AxDBMatch[][]>;
|
|
9747
|
-
}
|
|
9748
|
-
|
|
9749
|
-
declare class AxDefaultResultReranker extends AxGen<AxRerankerIn, AxRerankerOut> {
|
|
9750
|
-
constructor(options?: Readonly<AxProgramForwardOptions<string>>);
|
|
9751
|
-
forward: <T extends Readonly<AxAIService>>(ai: T, input: Readonly<AxRerankerIn>, options?: Readonly<AxProgramForwardOptionsWithModels<T>>) => Promise<AxRerankerOut>;
|
|
9752
|
-
}
|
|
9753
|
-
|
|
9754
|
-
interface AxApacheTikaArgs {
|
|
9755
|
-
url?: string | URL;
|
|
9756
|
-
fetch?: typeof fetch;
|
|
9757
|
-
}
|
|
9758
|
-
interface AxApacheTikaConvertOptions {
|
|
9759
|
-
format?: 'text' | 'html';
|
|
9760
|
-
}
|
|
9761
|
-
declare class AxApacheTika {
|
|
9762
|
-
private tikaUrl;
|
|
9763
|
-
private fetch?;
|
|
9764
|
-
constructor(args?: Readonly<AxApacheTikaArgs>);
|
|
9765
|
-
private _convert;
|
|
9766
|
-
convert(files: Readonly<Blob[] | ReadableStream[]>, options?: Readonly<{
|
|
9767
|
-
batchSize?: number;
|
|
9768
|
-
format?: 'html' | 'text';
|
|
9769
|
-
}>): Promise<string[]>;
|
|
9770
|
-
}
|
|
9771
|
-
|
|
9772
|
-
interface AxSimpleClassifierForwardOptions {
|
|
9773
|
-
cutoff?: number;
|
|
9774
|
-
abortSignal?: AbortSignal;
|
|
9775
|
-
}
|
|
9776
|
-
declare class AxSimpleClassifierClass {
|
|
9777
|
-
private readonly name;
|
|
9778
|
-
private readonly context;
|
|
9779
|
-
constructor(name: string, context: readonly string[]);
|
|
9780
|
-
getName(): string;
|
|
9781
|
-
getContext(): readonly string[];
|
|
9782
|
-
}
|
|
9783
|
-
declare class AxSimpleClassifier {
|
|
9784
|
-
private readonly ai;
|
|
9785
|
-
private db;
|
|
9786
|
-
private debug?;
|
|
9787
|
-
constructor(ai: AxAIService);
|
|
9788
|
-
getState(): AxDBState | undefined;
|
|
9789
|
-
setState(state: AxDBState): void;
|
|
9790
|
-
setClasses: (classes: readonly AxSimpleClassifierClass[], options?: Readonly<{
|
|
9791
|
-
abortSignal?: AbortSignal;
|
|
9792
|
-
}>) => Promise<void>;
|
|
9793
|
-
forward(text: string, options?: Readonly<AxSimpleClassifierForwardOptions>): Promise<string>;
|
|
9794
|
-
setOptions(options: Readonly<{
|
|
9795
|
-
debug?: boolean;
|
|
9796
|
-
}>): void;
|
|
9797
|
-
}
|
|
9798
|
-
|
|
9799
9187
|
type AxDateRange = {
|
|
9800
9188
|
start: Date;
|
|
9801
9189
|
end: Date;
|
|
@@ -9871,329 +9259,92 @@ declare const axGlobals: {
|
|
|
9871
9259
|
functionResultFormatter: AxFunctionResultFormatter;
|
|
9872
9260
|
};
|
|
9873
9261
|
|
|
9874
|
-
|
|
9875
|
-
|
|
9876
|
-
*
|
|
9877
|
-
* This module provides a pluggable storage interface that works across
|
|
9878
|
-
* different environments (browser, Node.js, cloud).
|
|
9879
|
-
*/
|
|
9880
|
-
/**
|
|
9881
|
-
* Represents a single trace event from an AxGen execution.
|
|
9882
|
-
*/
|
|
9883
|
-
/**
|
|
9884
|
-
* Represents a single trace event from an AxGen execution.
|
|
9885
|
-
*/
|
|
9886
|
-
interface AxTrace {
|
|
9887
|
-
type: 'trace';
|
|
9888
|
-
/** Unique identifier for this trace */
|
|
9889
|
-
id: string;
|
|
9890
|
-
/** Agent or generator name */
|
|
9891
|
-
name: string;
|
|
9892
|
-
/** Input values passed to forward() */
|
|
9893
|
-
input: Record<string, unknown>;
|
|
9894
|
-
/** Output values from forward() */
|
|
9895
|
-
output: Record<string, unknown>;
|
|
9896
|
-
/** Timestamp when execution started */
|
|
9897
|
-
startTime: Date;
|
|
9898
|
-
/** Timestamp when execution completed */
|
|
9899
|
-
endTime: Date;
|
|
9900
|
-
/** Duration in milliseconds */
|
|
9901
|
-
durationMs: number;
|
|
9902
|
-
/** Model used for generation */
|
|
9903
|
-
model?: string;
|
|
9904
|
-
/** Token usage statistics */
|
|
9905
|
-
usage?: {
|
|
9906
|
-
inputTokens: number;
|
|
9907
|
-
outputTokens: number;
|
|
9908
|
-
totalTokens: number;
|
|
9909
|
-
};
|
|
9910
|
-
/** User feedback if provided */
|
|
9911
|
-
feedback?: {
|
|
9912
|
-
score?: number;
|
|
9913
|
-
label?: string;
|
|
9914
|
-
comment?: string;
|
|
9915
|
-
};
|
|
9916
|
-
/** Error message if execution failed */
|
|
9917
|
-
error?: string;
|
|
9918
|
-
/** Custom metadata */
|
|
9919
|
-
metadata?: Record<string, unknown>;
|
|
9920
|
-
}
|
|
9921
|
-
type AxLearnCheckpointMode = 'batch' | 'continuous' | 'playbook';
|
|
9922
|
-
interface AxLearnCheckpointState {
|
|
9923
|
-
mode: AxLearnCheckpointMode;
|
|
9924
|
-
instruction?: string;
|
|
9925
|
-
baseInstruction?: string;
|
|
9926
|
-
score?: number;
|
|
9927
|
-
continuous?: {
|
|
9928
|
-
feedbackTraceCount?: number;
|
|
9929
|
-
lastUpdateAt?: string;
|
|
9930
|
-
};
|
|
9931
|
-
playbook?: Record<string, unknown>;
|
|
9932
|
-
artifactSummary?: Record<string, unknown>;
|
|
9933
|
-
}
|
|
9934
|
-
/**
|
|
9935
|
-
* Represents a serialized checkpoint of an AxGen configuration.
|
|
9936
|
-
*/
|
|
9937
|
-
interface AxCheckpoint {
|
|
9938
|
-
type: 'checkpoint';
|
|
9939
|
-
/** Agent or generator name */
|
|
9940
|
-
name: string;
|
|
9941
|
-
/** Version number for this checkpoint */
|
|
9942
|
-
version: number;
|
|
9943
|
-
/** Timestamp when checkpoint was created */
|
|
9944
|
-
createdAt: Date;
|
|
9945
|
-
/** Serialized instruction string */
|
|
9946
|
-
instruction?: string;
|
|
9947
|
-
/** Serialized examples/demos */
|
|
9948
|
-
examples?: Array<{
|
|
9949
|
-
input: Record<string, unknown>;
|
|
9950
|
-
output: Record<string, unknown>;
|
|
9951
|
-
}>;
|
|
9952
|
-
/** Optimization score at checkpoint */
|
|
9953
|
-
score?: number;
|
|
9954
|
-
/** Optimization method used */
|
|
9955
|
-
optimizerType?: string;
|
|
9956
|
-
/** Typed AxLearn state, when the checkpoint comes from AxLearn */
|
|
9957
|
-
learnState?: AxLearnCheckpointState;
|
|
9958
|
-
/** Custom metadata */
|
|
9959
|
-
metadata?: Record<string, unknown>;
|
|
9960
|
-
}
|
|
9961
|
-
/**
|
|
9962
|
-
* Query options for retrieving items.
|
|
9963
|
-
*/
|
|
9964
|
-
interface AxStorageQuery {
|
|
9965
|
-
type: 'trace' | 'checkpoint';
|
|
9966
|
-
/** Filter traces after this date */
|
|
9967
|
-
since?: Date;
|
|
9968
|
-
/** Filter traces before this date */
|
|
9969
|
-
until?: Date;
|
|
9970
|
-
/** Maximum number of items to return */
|
|
9971
|
-
limit?: number;
|
|
9972
|
-
/** Offset for pagination */
|
|
9973
|
-
offset?: number;
|
|
9974
|
-
/** Filter by trace ID or checkpoint version */
|
|
9975
|
-
id?: string;
|
|
9976
|
-
version?: number;
|
|
9977
|
-
/** Filter by feedback presence */
|
|
9978
|
-
hasFeedback?: boolean;
|
|
9979
|
-
}
|
|
9980
|
-
/**
|
|
9981
|
-
* Storage interface for AxLearn persistence.
|
|
9982
|
-
*/
|
|
9983
|
-
type AxStorage = {
|
|
9984
|
-
save: (name: string, item: AxTrace | AxCheckpoint) => Promise<void>;
|
|
9985
|
-
load: (name: string, query: AxStorageQuery) => Promise<(AxTrace | AxCheckpoint)[]>;
|
|
9986
|
-
};
|
|
9262
|
+
declare const axCreateDefaultColorLogger: (output?: (message: string) => void) => AxLoggerFunction;
|
|
9263
|
+
declare const axCreateDefaultTextLogger: (output?: (message: string) => void) => AxLoggerFunction;
|
|
9987
9264
|
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
9992
|
-
|
|
9993
|
-
id: string;
|
|
9994
|
-
section: string;
|
|
9995
|
-
content: string;
|
|
9996
|
-
helpfulCount: number;
|
|
9997
|
-
harmfulCount: number;
|
|
9998
|
-
createdAt: string;
|
|
9999
|
-
updatedAt: string;
|
|
10000
|
-
tags?: string[];
|
|
10001
|
-
metadata?: Record<string, unknown>;
|
|
10002
|
-
}
|
|
10003
|
-
/**
|
|
10004
|
-
* Aggregated ACE playbook structure grouped by sections.
|
|
10005
|
-
*/
|
|
10006
|
-
interface AxACEPlaybook {
|
|
10007
|
-
version: number;
|
|
10008
|
-
sections: Record<string, AxACEBullet[]>;
|
|
10009
|
-
stats: {
|
|
10010
|
-
bulletCount: number;
|
|
10011
|
-
helpfulCount: number;
|
|
10012
|
-
harmfulCount: number;
|
|
10013
|
-
tokenEstimate: number;
|
|
10014
|
-
};
|
|
10015
|
-
updatedAt: string;
|
|
10016
|
-
description?: string;
|
|
10017
|
-
}
|
|
10018
|
-
/**
|
|
10019
|
-
* Generator output format (Appendix B of the paper) distilled to core fields.
|
|
10020
|
-
*/
|
|
10021
|
-
interface AxACEGeneratorOutput extends Record<string, unknown> {
|
|
10022
|
-
reasoning: string;
|
|
10023
|
-
answer: unknown;
|
|
10024
|
-
bulletIds: string[];
|
|
10025
|
-
trajectory?: string;
|
|
10026
|
-
metadata?: Record<string, unknown>;
|
|
10027
|
-
}
|
|
10028
|
-
/**
|
|
10029
|
-
* Reflection payload, mapping to the Reflector JSON schema in the paper.
|
|
10030
|
-
*/
|
|
10031
|
-
interface AxACEReflectionOutput extends Record<string, unknown> {
|
|
10032
|
-
reasoning: string;
|
|
10033
|
-
errorIdentification: string;
|
|
10034
|
-
rootCauseAnalysis: string;
|
|
10035
|
-
correctApproach: string;
|
|
10036
|
-
keyInsight: string;
|
|
10037
|
-
bulletTags: {
|
|
10038
|
-
id: string;
|
|
10039
|
-
tag: 'helpful' | 'harmful' | 'neutral';
|
|
10040
|
-
}[];
|
|
10041
|
-
metadata?: Record<string, unknown>;
|
|
10042
|
-
}
|
|
10043
|
-
/**
|
|
10044
|
-
* Curator operations emitted as deltas (Section 3.1).
|
|
10045
|
-
*/
|
|
10046
|
-
type AxACECuratorOperationType = 'ADD' | 'UPDATE' | 'REMOVE';
|
|
10047
|
-
interface AxACECuratorOperation {
|
|
10048
|
-
type: AxACECuratorOperationType;
|
|
10049
|
-
section: string;
|
|
10050
|
-
bulletId?: string;
|
|
10051
|
-
content?: string;
|
|
10052
|
-
metadata?: Record<string, unknown>;
|
|
9265
|
+
interface AxMetricsConfig {
|
|
9266
|
+
enabled: boolean;
|
|
9267
|
+
enabledCategories: ('generation' | 'streaming' | 'functions' | 'errors' | 'performance')[];
|
|
9268
|
+
maxLabelLength: number;
|
|
9269
|
+
samplingRate: number;
|
|
10053
9270
|
}
|
|
10054
|
-
|
|
10055
|
-
|
|
10056
|
-
|
|
10057
|
-
|
|
9271
|
+
declare const axDefaultMetricsConfig: AxMetricsConfig;
|
|
9272
|
+
type AxErrorCategory = 'validation_error' | 'timeout_error' | 'abort_error' | 'network_error' | 'auth_error' | 'rate_limit_error' | 'function_error' | 'parsing_error' | 'unknown_error';
|
|
9273
|
+
interface AxGenMetricsInstruments {
|
|
9274
|
+
generationLatencyHistogram?: Histogram;
|
|
9275
|
+
generationRequestsCounter?: Counter;
|
|
9276
|
+
generationErrorsCounter?: Counter;
|
|
9277
|
+
multiStepGenerationsCounter?: Counter;
|
|
9278
|
+
stepsPerGenerationHistogram?: Histogram;
|
|
9279
|
+
maxStepsReachedCounter?: Counter;
|
|
9280
|
+
validationErrorsCounter?: Counter;
|
|
9281
|
+
errorCorrectionAttemptsHistogram?: Histogram;
|
|
9282
|
+
errorCorrectionSuccessCounter?: Counter;
|
|
9283
|
+
errorCorrectionFailureCounter?: Counter;
|
|
9284
|
+
maxRetriesReachedCounter?: Counter;
|
|
9285
|
+
functionsEnabledGenerationsCounter?: Counter;
|
|
9286
|
+
functionCallStepsCounter?: Counter;
|
|
9287
|
+
functionsExecutedPerGenerationHistogram?: Histogram;
|
|
9288
|
+
functionErrorCorrectionCounter?: Counter;
|
|
9289
|
+
fieldProcessorsExecutedCounter?: Counter;
|
|
9290
|
+
streamingFieldProcessorsExecutedCounter?: Counter;
|
|
9291
|
+
streamingGenerationsCounter?: Counter;
|
|
9292
|
+
streamingDeltasEmittedCounter?: Counter;
|
|
9293
|
+
streamingFinalizationLatencyHistogram?: Histogram;
|
|
9294
|
+
samplesGeneratedHistogram?: Histogram;
|
|
9295
|
+
resultPickerUsageCounter?: Counter;
|
|
9296
|
+
resultPickerLatencyHistogram?: Histogram;
|
|
9297
|
+
inputFieldsGauge?: Gauge;
|
|
9298
|
+
outputFieldsGauge?: Gauge;
|
|
9299
|
+
examplesUsedGauge?: Gauge;
|
|
9300
|
+
demosUsedGauge?: Gauge;
|
|
9301
|
+
promptRenderLatencyHistogram?: Histogram;
|
|
9302
|
+
extractionLatencyHistogram?: Histogram;
|
|
9303
|
+
stateCreationLatencyHistogram?: Histogram;
|
|
9304
|
+
memoryUpdateLatencyHistogram?: Histogram;
|
|
10058
9305
|
}
|
|
9306
|
+
declare const axCheckMetricsHealth: () => {
|
|
9307
|
+
healthy: boolean;
|
|
9308
|
+
issues: string[];
|
|
9309
|
+
};
|
|
9310
|
+
declare const axUpdateMetricsConfig: (config: Readonly<Partial<AxMetricsConfig>>) => void;
|
|
9311
|
+
declare const axGetMetricsConfig: () => AxMetricsConfig;
|
|
9312
|
+
|
|
10059
9313
|
/**
|
|
10060
|
-
*
|
|
9314
|
+
* Factory function to create a default optimizer logger with color formatting
|
|
10061
9315
|
*/
|
|
10062
|
-
|
|
10063
|
-
example: AxExample$1;
|
|
10064
|
-
prediction: unknown;
|
|
10065
|
-
score: number;
|
|
10066
|
-
generatorOutput: AxACEGeneratorOutput;
|
|
10067
|
-
reflection?: AxACEReflectionOutput;
|
|
10068
|
-
curator?: AxACECuratorOutput;
|
|
10069
|
-
timestamp: string;
|
|
10070
|
-
}
|
|
9316
|
+
declare const axCreateDefaultOptimizerColorLogger: (output?: (message: string) => void) => AxOptimizerLoggerFunction;
|
|
10071
9317
|
/**
|
|
10072
|
-
*
|
|
9318
|
+
* Factory function to create a text-only optimizer logger (no colors)
|
|
10073
9319
|
*/
|
|
10074
|
-
|
|
10075
|
-
/**
|
|
10076
|
-
* Maximum number of epochs for offline adaptation.
|
|
10077
|
-
*/
|
|
10078
|
-
maxEpochs?: number;
|
|
10079
|
-
/**
|
|
10080
|
-
* Maximum reflector refinement rounds (paper uses up to 5).
|
|
10081
|
-
*/
|
|
10082
|
-
maxReflectorRounds?: number;
|
|
10083
|
-
/**
|
|
10084
|
-
* Maximum bullets allowed in any section before triggering pruning.
|
|
10085
|
-
*/
|
|
10086
|
-
maxSectionSize?: number;
|
|
10087
|
-
/**
|
|
10088
|
-
* Optional similarity threshold used by the semantic deduper.
|
|
10089
|
-
*/
|
|
10090
|
-
similarityThreshold?: number;
|
|
10091
|
-
/**
|
|
10092
|
-
* Whether to automatically create sections when curator emits new ones.
|
|
10093
|
-
*/
|
|
10094
|
-
allowDynamicSections?: boolean;
|
|
10095
|
-
/**
|
|
10096
|
-
* Initial playbook supplied by the caller.
|
|
10097
|
-
*/
|
|
10098
|
-
initialPlaybook?: AxACEPlaybook;
|
|
10099
|
-
}
|
|
9320
|
+
declare const axCreateDefaultOptimizerTextLogger: (output?: (message: string) => void) => AxOptimizerLoggerFunction;
|
|
10100
9321
|
/**
|
|
10101
|
-
*
|
|
9322
|
+
* Default optimizer logger instance with color formatting
|
|
10102
9323
|
*/
|
|
10103
|
-
|
|
10104
|
-
playbook: AxACEPlaybook;
|
|
10105
|
-
feedback: AxACEFeedbackEvent[];
|
|
10106
|
-
history: {
|
|
10107
|
-
epoch: number;
|
|
10108
|
-
exampleIndex: number;
|
|
10109
|
-
operations: AxACECuratorOperation[];
|
|
10110
|
-
}[];
|
|
10111
|
-
}
|
|
9324
|
+
declare const axDefaultOptimizerLogger: AxOptimizerLoggerFunction;
|
|
10112
9325
|
|
|
10113
|
-
|
|
10114
|
-
|
|
10115
|
-
|
|
10116
|
-
|
|
10117
|
-
|
|
10118
|
-
|
|
10119
|
-
|
|
10120
|
-
|
|
10121
|
-
|
|
10122
|
-
|
|
10123
|
-
|
|
10124
|
-
|
|
10125
|
-
|
|
10126
|
-
|
|
10127
|
-
private
|
|
10128
|
-
|
|
10129
|
-
|
|
10130
|
-
|
|
10131
|
-
|
|
10132
|
-
|
|
10133
|
-
|
|
10134
|
-
|
|
10135
|
-
optimizationTime: number;
|
|
10136
|
-
totalRounds: number;
|
|
10137
|
-
converged: boolean;
|
|
10138
|
-
instruction?: string;
|
|
10139
|
-
demos?: AxOptimizedProgram<OUT>['demos'];
|
|
10140
|
-
examples?: AxExample$1[];
|
|
10141
|
-
modelConfig?: AxOptimizedProgram<OUT>['modelConfig'];
|
|
10142
|
-
scoreHistory?: number[];
|
|
10143
|
-
configurationHistory?: Record<string, unknown>[];
|
|
10144
|
-
});
|
|
10145
|
-
applyTo<IN, T extends AxGenOut>(program: AxGen<IN, T>): void;
|
|
10146
|
-
}
|
|
10147
|
-
/**
|
|
10148
|
-
* AxACE implements the Agentic Context Engineering loop (Generator → Reflector → Curator).
|
|
10149
|
-
* The implementation mirrors the paper's architecture while integrating with the Ax optimizer
|
|
10150
|
-
* ergonomics (unified optimized program artifacts, metrics, and checkpointing).
|
|
10151
|
-
*/
|
|
10152
|
-
declare class AxACE extends AxBaseOptimizer {
|
|
10153
|
-
private readonly aceConfig;
|
|
10154
|
-
private playbook;
|
|
10155
|
-
private baseInstruction?;
|
|
10156
|
-
private generatorHistory;
|
|
10157
|
-
private deltaHistory;
|
|
10158
|
-
private reflectorProgram?;
|
|
10159
|
-
private curatorProgram?;
|
|
10160
|
-
private program?;
|
|
10161
|
-
constructor(args: Readonly<AxOptimizerArgs>, options?: Readonly<AxACEOptions>);
|
|
10162
|
-
reset(): void;
|
|
10163
|
-
hydrate<IN, OUT extends AxGenOut>(program: Readonly<AxGen<IN, OUT>>, state?: Readonly<{
|
|
10164
|
-
baseInstruction?: string;
|
|
10165
|
-
playbook?: AxACEPlaybook;
|
|
10166
|
-
artifact?: Partial<AxACEOptimizationArtifact>;
|
|
10167
|
-
}>): void;
|
|
10168
|
-
getPlaybook(): AxACEPlaybook;
|
|
10169
|
-
getBaseInstruction(): string | undefined;
|
|
10170
|
-
getArtifact(): AxACEOptimizationArtifact;
|
|
10171
|
-
applyCurrentState<IN, OUT extends AxGenOut>(program?: AxGen<IN, OUT>): void;
|
|
10172
|
-
configureAuto(level: 'light' | 'medium' | 'heavy'): void;
|
|
10173
|
-
compile<IN, OUT extends AxGenOut>(program: Readonly<AxGen<IN, OUT>>, examples: readonly AxTypedExample<IN>[], metricFn: AxMetricFn, options?: AxACECompileOptions): Promise<AxACEResult<OUT>>;
|
|
10174
|
-
/**
|
|
10175
|
-
* Apply ACE updates after each online inference. Mirrors the online adaptation
|
|
10176
|
-
* flow described in the paper; can be called by user-land code between queries.
|
|
10177
|
-
*/
|
|
10178
|
-
applyOnlineUpdate(args: Readonly<{
|
|
10179
|
-
example: AxExample$1;
|
|
10180
|
-
prediction: unknown;
|
|
10181
|
-
feedback?: string;
|
|
10182
|
-
}>): Promise<AxACECuratorOutput | undefined>;
|
|
10183
|
-
private composeInstruction;
|
|
10184
|
-
private extractProgramInstruction;
|
|
10185
|
-
private createGeneratorOutput;
|
|
10186
|
-
private resolveCuratorOperationTargets;
|
|
10187
|
-
private locateBullet;
|
|
10188
|
-
private locateFallbackBullet;
|
|
10189
|
-
private collectProtectedBulletIds;
|
|
10190
|
-
private normalizeCuratorOperations;
|
|
10191
|
-
private inferOperationsFromReflection;
|
|
10192
|
-
private runReflectionRounds;
|
|
10193
|
-
private runReflector;
|
|
10194
|
-
private runCurator;
|
|
10195
|
-
private getOrCreateReflectorProgram;
|
|
10196
|
-
private getOrCreateCuratorProgram;
|
|
9326
|
+
type AxRolloutTrace<Out = unknown> = {
|
|
9327
|
+
calls: AxFunctionCallTrace[];
|
|
9328
|
+
output?: Out;
|
|
9329
|
+
error?: string;
|
|
9330
|
+
};
|
|
9331
|
+
|
|
9332
|
+
declare class AxBootstrapFewShot extends AxBaseOptimizer {
|
|
9333
|
+
private maxRounds;
|
|
9334
|
+
private maxDemos;
|
|
9335
|
+
private maxExamples;
|
|
9336
|
+
private batchSize;
|
|
9337
|
+
private earlyStoppingPatience;
|
|
9338
|
+
private costMonitoring;
|
|
9339
|
+
private maxTokensPerGeneration;
|
|
9340
|
+
private verboseMode;
|
|
9341
|
+
private debugMode;
|
|
9342
|
+
private traces;
|
|
9343
|
+
constructor(args: Readonly<AxOptimizerArgs & {
|
|
9344
|
+
options?: AxBootstrapOptimizerOptions;
|
|
9345
|
+
}>);
|
|
9346
|
+
private compileRound;
|
|
9347
|
+
compile<IN, OUT extends AxGenOut>(program: Readonly<AxGen<IN, OUT>>, examples: readonly AxTypedExample<IN>[], metricFn: AxMetricFn, options?: AxCompileOptions): Promise<AxOptimizerResult<OUT>>;
|
|
10197
9348
|
}
|
|
10198
9349
|
|
|
10199
9350
|
/** Structured optimization report */
|
|
@@ -10277,6 +9428,193 @@ declare class AxGEPA extends AxBaseOptimizer {
|
|
|
10277
9428
|
private mergeInstructions;
|
|
10278
9429
|
}
|
|
10279
9430
|
|
|
9431
|
+
type AxGEPABatchRow = {
|
|
9432
|
+
input: AxExample$1;
|
|
9433
|
+
prediction: unknown;
|
|
9434
|
+
scores: Record<string, number>;
|
|
9435
|
+
scalar: number;
|
|
9436
|
+
};
|
|
9437
|
+
type AxGEPABatchEvaluation = {
|
|
9438
|
+
rows: AxGEPABatchRow[];
|
|
9439
|
+
avg: Record<string, number>;
|
|
9440
|
+
scalars: number[];
|
|
9441
|
+
sum: number;
|
|
9442
|
+
trajectories?: readonly unknown[];
|
|
9443
|
+
};
|
|
9444
|
+
type AxGEPAEvaluationState = {
|
|
9445
|
+
totalCalls: number;
|
|
9446
|
+
observedScoreKeys: Set<string>;
|
|
9447
|
+
};
|
|
9448
|
+
|
|
9449
|
+
type AxGEPAReflectiveTuple = {
|
|
9450
|
+
input: AxExample$1;
|
|
9451
|
+
prediction: unknown;
|
|
9452
|
+
score: number;
|
|
9453
|
+
};
|
|
9454
|
+
type AxGEPATraceSummaryCall = {
|
|
9455
|
+
componentId?: string;
|
|
9456
|
+
fn: string;
|
|
9457
|
+
ok: boolean;
|
|
9458
|
+
ms: number;
|
|
9459
|
+
args: string;
|
|
9460
|
+
result: string;
|
|
9461
|
+
};
|
|
9462
|
+
type AxGEPATraceSummary = {
|
|
9463
|
+
score: number;
|
|
9464
|
+
calls: AxGEPATraceSummaryCall[];
|
|
9465
|
+
output?: string;
|
|
9466
|
+
error?: string;
|
|
9467
|
+
};
|
|
9468
|
+
|
|
9469
|
+
type AxRefineStrategy = 'auto' | 'native-samples' | 'serial';
|
|
9470
|
+
type AxRewardFnArgs<IN, OUT extends AxGenOut> = {
|
|
9471
|
+
input: Readonly<IN>;
|
|
9472
|
+
prediction: Readonly<OUT>;
|
|
9473
|
+
attempt: number;
|
|
9474
|
+
round: number;
|
|
9475
|
+
sampleIndex: number;
|
|
9476
|
+
traces: readonly AxProgramTrace<IN, OUT>[];
|
|
9477
|
+
chatLog: readonly AxChatLogEntry[];
|
|
9478
|
+
};
|
|
9479
|
+
type AxRewardFn<IN, OUT extends AxGenOut> = (args: Readonly<AxRewardFnArgs<IN, OUT>>) => number | Promise<number>;
|
|
9480
|
+
type AxAttempt<IN, OUT extends AxGenOut> = {
|
|
9481
|
+
attempt: number;
|
|
9482
|
+
round: number;
|
|
9483
|
+
sampleIndex: number;
|
|
9484
|
+
strategy: Exclude<AxRefineStrategy, 'auto'>;
|
|
9485
|
+
input: IN;
|
|
9486
|
+
prediction?: OUT;
|
|
9487
|
+
reward?: number;
|
|
9488
|
+
metThreshold: boolean;
|
|
9489
|
+
traces: AxProgramTrace<IN, OUT>[];
|
|
9490
|
+
chatLog: AxChatLogEntry[];
|
|
9491
|
+
usage: AxProgramUsage[];
|
|
9492
|
+
error?: unknown;
|
|
9493
|
+
advice?: Record<string, string>;
|
|
9494
|
+
adviceApplied?: boolean;
|
|
9495
|
+
};
|
|
9496
|
+
type AxBestOfNOptions<IN, OUT extends AxGenOut> = {
|
|
9497
|
+
n: number;
|
|
9498
|
+
rewardFn: AxRewardFn<IN, OUT>;
|
|
9499
|
+
threshold?: number;
|
|
9500
|
+
failCount?: number;
|
|
9501
|
+
modelConfig?: Partial<AxModelConfig>;
|
|
9502
|
+
strategy?: AxRefineStrategy;
|
|
9503
|
+
onAttempt?: (attempt: Readonly<AxAttempt<IN, OUT>>) => void | Promise<void>;
|
|
9504
|
+
};
|
|
9505
|
+
type AxRefineOptions<IN, OUT extends AxGenOut> = {
|
|
9506
|
+
rounds: number;
|
|
9507
|
+
samplesPerRound?: number;
|
|
9508
|
+
rewardFn: AxRewardFn<IN, OUT>;
|
|
9509
|
+
threshold?: number;
|
|
9510
|
+
failCount?: number;
|
|
9511
|
+
modelConfig?: Partial<AxModelConfig>;
|
|
9512
|
+
strategy?: AxRefineStrategy;
|
|
9513
|
+
feedbackAI?: Readonly<AxAIService>;
|
|
9514
|
+
feedbackModelConfig?: Partial<AxModelConfig>;
|
|
9515
|
+
rewardDescription?: string;
|
|
9516
|
+
programDescription?: string;
|
|
9517
|
+
onAttempt?: (attempt: Readonly<AxAttempt<IN, OUT>>) => void | Promise<void>;
|
|
9518
|
+
};
|
|
9519
|
+
type RunBatchArgs<IN> = {
|
|
9520
|
+
ai: Readonly<AxAIService>;
|
|
9521
|
+
input: IN;
|
|
9522
|
+
forwardOptions?: Readonly<AxProgramForwardOptions<any>>;
|
|
9523
|
+
count: number;
|
|
9524
|
+
round: number;
|
|
9525
|
+
failCount: number;
|
|
9526
|
+
strategy: Exclude<AxRefineStrategy, 'auto'>;
|
|
9527
|
+
threshold?: number;
|
|
9528
|
+
};
|
|
9529
|
+
declare class AxRefineError extends Error {
|
|
9530
|
+
readonly attempts: readonly AxAttempt<any, any>[];
|
|
9531
|
+
constructor(message: string, attempts?: readonly AxAttempt<any, any>[]);
|
|
9532
|
+
}
|
|
9533
|
+
declare abstract class AxRefineBase<IN, OUT extends AxGenOut> implements AxProgrammable<IN, OUT> {
|
|
9534
|
+
protected readonly program: Readonly<AxProgrammable<IN, OUT>>;
|
|
9535
|
+
protected abstract readonly modelConfig?: Partial<AxModelConfig>;
|
|
9536
|
+
protected abstract readonly rewardFn: AxRewardFn<IN, OUT>;
|
|
9537
|
+
protected attempts: AxAttempt<IN, OUT>[];
|
|
9538
|
+
protected selectedAttempt?: AxAttempt<IN, OUT>;
|
|
9539
|
+
constructor(program: Readonly<AxProgrammable<IN, OUT>>);
|
|
9540
|
+
abstract forward(ai: Readonly<AxAIService>, input: IN, options?: Readonly<AxProgramForwardOptions<any>>): Promise<OUT>;
|
|
9541
|
+
getAttempts(): readonly AxAttempt<IN, OUT>[];
|
|
9542
|
+
getSignature(): AxSignature;
|
|
9543
|
+
getId(): string;
|
|
9544
|
+
setId(id: string): void;
|
|
9545
|
+
getTraces(): AxProgramTrace<IN, OUT>[];
|
|
9546
|
+
namedProgramInstances(): AxNamedProgramInstance<any, any>[];
|
|
9547
|
+
setDemos(demos: readonly AxProgramDemos<IN, OUT>[], options?: {
|
|
9548
|
+
modelConfig?: Record<string, unknown>;
|
|
9549
|
+
}): void;
|
|
9550
|
+
applyOptimization(optimizedProgram: AxOptimizedProgram<OUT>): void;
|
|
9551
|
+
getOptimizableComponents(): readonly AxOptimizableComponent[];
|
|
9552
|
+
applyOptimizedComponents(updates: Readonly<Record<string, string>>): void;
|
|
9553
|
+
getUsage(): AxProgramUsage[];
|
|
9554
|
+
getChatLog(): readonly AxChatLogEntry[];
|
|
9555
|
+
resetUsage(): void;
|
|
9556
|
+
streamingForward(_ai: Readonly<AxAIService>, _values: IN, _options?: Readonly<AxProgramStreamingForwardOptions<any>>): AxGenStreamingOut<OUT>;
|
|
9557
|
+
protected resetRun(): void;
|
|
9558
|
+
protected emitAttempt(onAttempt: AxBestOfNOptions<IN, OUT>['onAttempt'] | undefined, attempt: AxAttempt<IN, OUT>): Promise<void>;
|
|
9559
|
+
protected runCandidateBatch({ ai, input, forwardOptions, count, round, failCount, strategy, threshold, }: RunBatchArgs<IN>): Promise<AxAttempt<IN, OUT>[]>;
|
|
9560
|
+
private runNativeSampleBatch;
|
|
9561
|
+
private runSerialBatch;
|
|
9562
|
+
protected selectBest(attempts: readonly AxAttempt<IN, OUT>[]): (AxAttempt<IN, OUT> & {
|
|
9563
|
+
prediction: OUT;
|
|
9564
|
+
reward: number;
|
|
9565
|
+
}) | undefined;
|
|
9566
|
+
protected firstThreshold(attempts: readonly AxAttempt<IN, OUT>[]): AxAttempt<IN, OUT> | undefined;
|
|
9567
|
+
}
|
|
9568
|
+
declare class AxBestOfN<IN, OUT extends AxGenOut> extends AxRefineBase<IN, OUT> {
|
|
9569
|
+
private readonly n;
|
|
9570
|
+
private readonly failCount;
|
|
9571
|
+
private readonly threshold?;
|
|
9572
|
+
private readonly strategy?;
|
|
9573
|
+
protected readonly modelConfig?: Partial<AxModelConfig>;
|
|
9574
|
+
protected readonly rewardFn: AxRewardFn<IN, OUT>;
|
|
9575
|
+
private readonly onAttempt?;
|
|
9576
|
+
constructor(program: Readonly<AxProgrammable<IN, OUT>>, options: Readonly<AxBestOfNOptions<IN, OUT>>);
|
|
9577
|
+
forward(ai: Readonly<AxAIService>, input: IN, options?: Readonly<AxProgramForwardOptions<any>>): Promise<OUT>;
|
|
9578
|
+
}
|
|
9579
|
+
declare class AxRefine<IN, OUT extends AxGenOut> extends AxRefineBase<IN, OUT> {
|
|
9580
|
+
private readonly rounds;
|
|
9581
|
+
private readonly samplesPerRound;
|
|
9582
|
+
private readonly failCount;
|
|
9583
|
+
private readonly threshold?;
|
|
9584
|
+
private readonly strategy?;
|
|
9585
|
+
protected readonly modelConfig?: Partial<AxModelConfig>;
|
|
9586
|
+
protected readonly rewardFn: AxRewardFn<IN, OUT>;
|
|
9587
|
+
private readonly feedbackAI?;
|
|
9588
|
+
private readonly feedbackModelConfig?;
|
|
9589
|
+
private readonly rewardDescription?;
|
|
9590
|
+
private readonly programDescription?;
|
|
9591
|
+
private readonly onAttempt?;
|
|
9592
|
+
constructor(program: Readonly<AxProgrammable<IN, OUT>>, options: Readonly<AxRefineOptions<IN, OUT>>);
|
|
9593
|
+
forward(ai: Readonly<AxAIService>, input: IN, options?: Readonly<AxProgramForwardOptions<any>>): Promise<OUT>;
|
|
9594
|
+
private captureInstructionComponents;
|
|
9595
|
+
private applyAdvice;
|
|
9596
|
+
private restoreInstructionComponents;
|
|
9597
|
+
private generateAdvice;
|
|
9598
|
+
}
|
|
9599
|
+
declare function bestOfN<IN, OUT extends AxGenOut>(program: Readonly<AxProgrammable<IN, OUT>>, options: Readonly<AxBestOfNOptions<IN, OUT>>): AxBestOfN<IN, OUT>;
|
|
9600
|
+
declare function refine<IN, OUT extends AxGenOut>(program: Readonly<AxProgrammable<IN, OUT>>, options: Readonly<AxRefineOptions<IN, OUT>>): AxRefine<IN, OUT>;
|
|
9601
|
+
|
|
9602
|
+
interface AxSamplePickerOptions<OUT> {
|
|
9603
|
+
resultPicker?: AxResultPickerFunction<OUT>;
|
|
9604
|
+
}
|
|
9605
|
+
|
|
9606
|
+
declare const AxStringUtil: {
|
|
9607
|
+
trimNonAlphaNum: (str: string) => string;
|
|
9608
|
+
splitIntoTwo: (str: string, separator: Readonly<RegExp | string>) => string[];
|
|
9609
|
+
dedup: (seq: readonly string[]) => string[];
|
|
9610
|
+
extractIdAndText: (input: string) => {
|
|
9611
|
+
id: number;
|
|
9612
|
+
text: string;
|
|
9613
|
+
};
|
|
9614
|
+
extractIndexPrefixedText: (input: string) => string;
|
|
9615
|
+
batchArray: <T>(arr: readonly T[], size: number) => T[][];
|
|
9616
|
+
};
|
|
9617
|
+
|
|
10280
9618
|
/**
|
|
10281
9619
|
* AxSynth - Synthetic data generator for bootstrapping optimization datasets.
|
|
10282
9620
|
*
|
|
@@ -10381,439 +9719,6 @@ declare class AxSynth<IN extends AxGenIn, OUT extends AxGenOut> {
|
|
|
10381
9719
|
getTeacher(): AxAIService;
|
|
10382
9720
|
}
|
|
10383
9721
|
|
|
10384
|
-
/**
|
|
10385
|
-
* AxLearn - Self-improving agent that learns from traces and feedback.
|
|
10386
|
-
*
|
|
10387
|
-
* Combines AxGen with automatic trace logging, storage, and mode-based
|
|
10388
|
-
* optimization/update flows.
|
|
10389
|
-
*/
|
|
10390
|
-
|
|
10391
|
-
type AxLearnMode = AxLearnCheckpointMode;
|
|
10392
|
-
type AxLearnPlaybook = AxACEPlaybook;
|
|
10393
|
-
interface AxLearnContinuousOptions {
|
|
10394
|
-
feedbackWindowSize?: number;
|
|
10395
|
-
maxRecentTraces?: number;
|
|
10396
|
-
updateBudget?: number;
|
|
10397
|
-
}
|
|
10398
|
-
type AxLearnPlaybookOptions = Partial<AxACEOptions>;
|
|
10399
|
-
/**
|
|
10400
|
-
* Configuration for the AxLearn agent.
|
|
10401
|
-
*/
|
|
10402
|
-
interface AxLearnOptions {
|
|
10403
|
-
/** Unique identifier/name for this agent */
|
|
10404
|
-
name: string;
|
|
10405
|
-
/** Storage backend (Required) */
|
|
10406
|
-
storage: AxStorage;
|
|
10407
|
-
/** Runtime model whose outputs should be improved */
|
|
10408
|
-
runtimeAI?: AxAIService;
|
|
10409
|
-
/** Learning mode (default: batch) */
|
|
10410
|
-
mode?: AxLearnMode;
|
|
10411
|
-
/** Whether to log traces (default: true) */
|
|
10412
|
-
enableTracing?: boolean;
|
|
10413
|
-
/** Custom metadata for all traces */
|
|
10414
|
-
metadata?: Record<string, unknown>;
|
|
10415
|
-
/** Callback when a trace is logged */
|
|
10416
|
-
onTrace?: (trace: AxTrace) => void;
|
|
10417
|
-
/** Teacher AI for synthetic data generation and judging (Required) */
|
|
10418
|
-
teacher: AxAIService;
|
|
10419
|
-
/** Maximum optimization rounds (default: 20) */
|
|
10420
|
-
budget?: number;
|
|
10421
|
-
/** Custom metric function (if not provided, auto-generates using typed AxGen evaluation) */
|
|
10422
|
-
metric?: AxMetricFn;
|
|
10423
|
-
/** Judge options when auto-generating metric */
|
|
10424
|
-
judgeOptions?: Partial<AxJudgeOptions>;
|
|
10425
|
-
/** Custom evaluation criteria for judge */
|
|
10426
|
-
criteria?: string;
|
|
10427
|
-
/** Training examples (manual) */
|
|
10428
|
-
examples?: AxTypedExample<AxGenIn>[];
|
|
10429
|
-
/** Whether to use captured traces as training examples (default: true) */
|
|
10430
|
-
useTraces?: boolean;
|
|
10431
|
-
/** Whether to generate synthetic examples (default: true if no other data) */
|
|
10432
|
-
generateExamples?: boolean;
|
|
10433
|
-
/** Number of synthetic examples to generate */
|
|
10434
|
-
synthCount?: number;
|
|
10435
|
-
/** Synth options for data generation */
|
|
10436
|
-
synthOptions?: Partial<AxSynthOptions>;
|
|
10437
|
-
/** Validation split ratio (default: 0.2, clamped to keep train + validation non-empty) */
|
|
10438
|
-
validationSplit?: number;
|
|
10439
|
-
/** Mode-specific configuration for bounded continuous updates */
|
|
10440
|
-
continuousOptions?: AxLearnContinuousOptions;
|
|
10441
|
-
/** Mode-specific configuration for playbook learning */
|
|
10442
|
-
playbookOptions?: AxLearnPlaybookOptions;
|
|
10443
|
-
/** Progress callback */
|
|
10444
|
-
onProgress?: (progress: AxLearnProgress) => void;
|
|
10445
|
-
}
|
|
10446
|
-
interface AxLearnOptimizeOptions {
|
|
10447
|
-
runtimeAI?: AxAIService;
|
|
10448
|
-
budget?: number;
|
|
10449
|
-
metric?: AxMetricFn;
|
|
10450
|
-
judgeOptions?: Partial<AxJudgeOptions>;
|
|
10451
|
-
criteria?: string;
|
|
10452
|
-
examples?: AxTypedExample<AxGenIn>[];
|
|
10453
|
-
useTraces?: boolean;
|
|
10454
|
-
generateExamples?: boolean;
|
|
10455
|
-
synthCount?: number;
|
|
10456
|
-
synthOptions?: Partial<AxSynthOptions>;
|
|
10457
|
-
validationSplit?: number;
|
|
10458
|
-
continuousOptions?: AxLearnContinuousOptions;
|
|
10459
|
-
playbookOptions?: AxLearnPlaybookOptions;
|
|
10460
|
-
onProgress?: (progress: AxLearnProgress) => void;
|
|
10461
|
-
}
|
|
10462
|
-
type AxLearnUpdateFeedback = string | NonNullable<AxTrace['feedback']>;
|
|
10463
|
-
interface AxLearnUpdateInput<IN extends AxGenIn = AxGenIn, OUT extends AxGenOut = AxGenOut> {
|
|
10464
|
-
example: AxTypedExample<IN>;
|
|
10465
|
-
prediction: OUT;
|
|
10466
|
-
feedback?: AxLearnUpdateFeedback;
|
|
10467
|
-
}
|
|
10468
|
-
interface AxLearnUpdateOptions {
|
|
10469
|
-
runtimeAI?: AxAIService;
|
|
10470
|
-
budget?: number;
|
|
10471
|
-
metric?: AxMetricFn;
|
|
10472
|
-
judgeOptions?: Partial<AxJudgeOptions>;
|
|
10473
|
-
criteria?: string;
|
|
10474
|
-
continuousOptions?: AxLearnContinuousOptions;
|
|
10475
|
-
playbookOptions?: AxLearnPlaybookOptions;
|
|
10476
|
-
onProgress?: (progress: AxLearnProgress) => void;
|
|
10477
|
-
}
|
|
10478
|
-
interface AxLearnPlaybookSummary {
|
|
10479
|
-
feedbackEvents: number;
|
|
10480
|
-
historyBatches: number;
|
|
10481
|
-
bulletCount: number;
|
|
10482
|
-
updatedAt?: string;
|
|
10483
|
-
}
|
|
10484
|
-
interface AxLearnArtifact {
|
|
10485
|
-
playbook?: AxLearnPlaybook;
|
|
10486
|
-
playbookSummary?: AxLearnPlaybookSummary;
|
|
10487
|
-
lastUpdateAt?: string;
|
|
10488
|
-
feedbackExamples?: number;
|
|
10489
|
-
}
|
|
10490
|
-
/**
|
|
10491
|
-
* Progress callback for monitoring optimization.
|
|
10492
|
-
*/
|
|
10493
|
-
interface AxLearnProgress {
|
|
10494
|
-
round: number;
|
|
10495
|
-
totalRounds: number;
|
|
10496
|
-
score: number;
|
|
10497
|
-
improvement: number;
|
|
10498
|
-
}
|
|
10499
|
-
/**
|
|
10500
|
-
* Result from optimize/applyUpdate operations.
|
|
10501
|
-
*/
|
|
10502
|
-
interface AxLearnResult<_IN extends AxGenIn, _OUT extends AxGenOut> {
|
|
10503
|
-
mode: AxLearnMode;
|
|
10504
|
-
score: number;
|
|
10505
|
-
improvement: number;
|
|
10506
|
-
checkpointVersion: number;
|
|
10507
|
-
stats: {
|
|
10508
|
-
trainingExamples: number;
|
|
10509
|
-
validationExamples: number;
|
|
10510
|
-
feedbackExamples: number;
|
|
10511
|
-
durationMs: number;
|
|
10512
|
-
mode: AxLearnMode;
|
|
10513
|
-
};
|
|
10514
|
-
state?: AxLearnCheckpointState;
|
|
10515
|
-
artifact?: AxLearnArtifact;
|
|
10516
|
-
}
|
|
10517
|
-
type AxLearnMergedConfig = {
|
|
10518
|
-
runtimeAI?: AxAIService;
|
|
10519
|
-
mode: AxLearnMode;
|
|
10520
|
-
teacher: AxAIService;
|
|
10521
|
-
budget: number;
|
|
10522
|
-
metric?: AxMetricFn;
|
|
10523
|
-
judgeOptions?: Partial<AxJudgeOptions>;
|
|
10524
|
-
criteria?: string;
|
|
10525
|
-
examples?: AxTypedExample<AxGenIn>[];
|
|
10526
|
-
useTraces: boolean;
|
|
10527
|
-
generateExamples: boolean;
|
|
10528
|
-
synthCount?: number;
|
|
10529
|
-
synthOptions?: Partial<AxSynthOptions>;
|
|
10530
|
-
validationSplit: number;
|
|
10531
|
-
continuousOptions: Required<AxLearnContinuousOptions>;
|
|
10532
|
-
playbookOptions?: AxLearnPlaybookOptions;
|
|
10533
|
-
onProgress?: (progress: AxLearnProgress) => void;
|
|
10534
|
-
};
|
|
10535
|
-
/**
|
|
10536
|
-
* AxLearn wraps an AxGen with automatic trace logging and self-improvement capabilities.
|
|
10537
|
-
*/
|
|
10538
|
-
declare class AxLearn<IN extends AxGenIn, OUT extends AxGenOut> implements AxForwardable<IN, OUT, string>, AxUsable {
|
|
10539
|
-
private gen;
|
|
10540
|
-
private options;
|
|
10541
|
-
private tracer;
|
|
10542
|
-
private currentScore?;
|
|
10543
|
-
private currentState?;
|
|
10544
|
-
private readyPromise;
|
|
10545
|
-
private playbookOptimizer?;
|
|
10546
|
-
constructor(gen: AxGen<IN, OUT>, options: AxLearnOptions);
|
|
10547
|
-
ready(): Promise<void>;
|
|
10548
|
-
/**
|
|
10549
|
-
* Forward call - behaves like AxGen.forward() but waits for restore and logs traces.
|
|
10550
|
-
*/
|
|
10551
|
-
forward(ai: AxAIService, values: IN, options?: Readonly<AxProgramForwardOptions<string>>): Promise<OUT>;
|
|
10552
|
-
/**
|
|
10553
|
-
* Streaming forward call - behaves like AxGen.streamingForward() but waits for restore and logs traces.
|
|
10554
|
-
*/
|
|
10555
|
-
streamingForward(ai: AxAIService, values: IN, options?: Readonly<AxProgramForwardOptions<string>>): AxGenStreamingOut<OUT>;
|
|
10556
|
-
getUsage(): AxProgramUsage[];
|
|
10557
|
-
getChatLog(): readonly AxChatLogEntry[];
|
|
10558
|
-
resetUsage(): void;
|
|
10559
|
-
getSignature(): AxSignature;
|
|
10560
|
-
setInstruction(instruction: string): void;
|
|
10561
|
-
getInstruction(): string | undefined;
|
|
10562
|
-
updateMeter(meter?: Meter): void;
|
|
10563
|
-
addAssert(fn: AxAssertion<OUT>['fn'], message?: string): void;
|
|
10564
|
-
addStreamingAssert(fieldName: keyof OUT, fn: AxStreamingAssertion['fn'], message?: string): void;
|
|
10565
|
-
addFieldProcessor(fieldName: keyof OUT, fn: (value: OUT[keyof OUT], context?: {
|
|
10566
|
-
values?: OUT;
|
|
10567
|
-
sessionId?: string;
|
|
10568
|
-
done?: boolean;
|
|
10569
|
-
}) => unknown | Promise<unknown>): void;
|
|
10570
|
-
addStreamingFieldProcessor(fieldName: keyof OUT, fn: (value: string, context?: {
|
|
10571
|
-
values?: OUT;
|
|
10572
|
-
sessionId?: string;
|
|
10573
|
-
done?: boolean;
|
|
10574
|
-
}) => unknown | Promise<unknown>): void;
|
|
10575
|
-
clone(): AxLearn<IN, OUT>;
|
|
10576
|
-
/**
|
|
10577
|
-
* Run the configured learning flow for the current mode.
|
|
10578
|
-
*/
|
|
10579
|
-
optimize(overrides?: AxLearnOptimizeOptions): Promise<AxLearnResult<IN, OUT>>;
|
|
10580
|
-
/**
|
|
10581
|
-
* Apply a bounded online update for continuous/playbook modes.
|
|
10582
|
-
*/
|
|
10583
|
-
applyUpdate(input: Readonly<AxLearnUpdateInput<IN, OUT>>, overrides?: AxLearnUpdateOptions): Promise<AxLearnResult<IN, OUT>>;
|
|
10584
|
-
/**
|
|
10585
|
-
* Get the underlying AxGen instance.
|
|
10586
|
-
*/
|
|
10587
|
-
getGen(): AxGen<IN, OUT>;
|
|
10588
|
-
/**
|
|
10589
|
-
* Get the storage backend.
|
|
10590
|
-
*/
|
|
10591
|
-
getStorage(): AxStorage;
|
|
10592
|
-
/**
|
|
10593
|
-
* Get recent traces for this agent.
|
|
10594
|
-
*/
|
|
10595
|
-
getTraces(options?: {
|
|
10596
|
-
limit?: number;
|
|
10597
|
-
since?: Date;
|
|
10598
|
-
}): Promise<AxTrace[]>;
|
|
10599
|
-
/**
|
|
10600
|
-
* Add feedback to a specific trace.
|
|
10601
|
-
*/
|
|
10602
|
-
addFeedback(traceId: string, feedback: NonNullable<AxTrace['feedback']>): Promise<void>;
|
|
10603
|
-
protected createPromptOptimizer(config: Readonly<AxLearnMergedConfig>, baselineScore: number): AxGEPA;
|
|
10604
|
-
protected createPlaybookOptimizer(config: Readonly<AxLearnMergedConfig>, baselineScore: number): AxACE;
|
|
10605
|
-
private mergeConfig;
|
|
10606
|
-
private requireRuntimeAI;
|
|
10607
|
-
private createOptimizerProgressHandler;
|
|
10608
|
-
private resolveMetric;
|
|
10609
|
-
private runPromptOptimization;
|
|
10610
|
-
private optimizePlaybook;
|
|
10611
|
-
private applyPlaybookUpdate;
|
|
10612
|
-
private getOrCreatePlaybookOptimizer;
|
|
10613
|
-
private prepareDataset;
|
|
10614
|
-
private loadRelevantTraces;
|
|
10615
|
-
private normalizeExample;
|
|
10616
|
-
private buildObservedUpdateExample;
|
|
10617
|
-
private pickInputFields;
|
|
10618
|
-
private pickOutputFields;
|
|
10619
|
-
private hasInputFields;
|
|
10620
|
-
private hasOutputFields;
|
|
10621
|
-
private exampleKey;
|
|
10622
|
-
private feedbackToText;
|
|
10623
|
-
private formatObservedUpdateFeedback;
|
|
10624
|
-
private splitExamples;
|
|
10625
|
-
private shuffleExamples;
|
|
10626
|
-
private computeMetricBudget;
|
|
10627
|
-
private createPromptState;
|
|
10628
|
-
private createPlaybookState;
|
|
10629
|
-
private summarizePlaybookArtifact;
|
|
10630
|
-
private saveCheckpoint;
|
|
10631
|
-
private loadLatestCheckpoint;
|
|
10632
|
-
private applyRestoredPlaybook;
|
|
10633
|
-
}
|
|
10634
|
-
|
|
10635
|
-
type AxDataRow = {
|
|
10636
|
-
row: Record<string, AxFieldValue>;
|
|
10637
|
-
};
|
|
10638
|
-
declare class AxHFDataLoader {
|
|
10639
|
-
private rows;
|
|
10640
|
-
private baseUrl;
|
|
10641
|
-
private dataset;
|
|
10642
|
-
private split;
|
|
10643
|
-
private config;
|
|
10644
|
-
private options?;
|
|
10645
|
-
constructor({ dataset, split, config, options, }: Readonly<{
|
|
10646
|
-
dataset: string;
|
|
10647
|
-
split: string;
|
|
10648
|
-
config: string;
|
|
10649
|
-
options?: Readonly<{
|
|
10650
|
-
offset?: number;
|
|
10651
|
-
length?: number;
|
|
10652
|
-
}>;
|
|
10653
|
-
}>);
|
|
10654
|
-
private fetchDataFromAPI;
|
|
10655
|
-
loadData(): Promise<AxDataRow[]>;
|
|
10656
|
-
setData(rows: AxDataRow[]): void;
|
|
10657
|
-
getData(): AxDataRow[];
|
|
10658
|
-
getRows<T>({ count, fields, renameMap, }: Readonly<{
|
|
10659
|
-
count: number;
|
|
10660
|
-
fields: readonly string[];
|
|
10661
|
-
renameMap?: Record<string, string>;
|
|
10662
|
-
}>): Promise<T[]>;
|
|
10663
|
-
}
|
|
10664
|
-
|
|
10665
|
-
declare const axCreateDefaultColorLogger: (output?: (message: string) => void) => AxLoggerFunction;
|
|
10666
|
-
declare const axCreateDefaultTextLogger: (output?: (message: string) => void) => AxLoggerFunction;
|
|
10667
|
-
|
|
10668
|
-
interface AxMetricsConfig {
|
|
10669
|
-
enabled: boolean;
|
|
10670
|
-
enabledCategories: ('generation' | 'streaming' | 'functions' | 'errors' | 'performance')[];
|
|
10671
|
-
maxLabelLength: number;
|
|
10672
|
-
samplingRate: number;
|
|
10673
|
-
}
|
|
10674
|
-
declare const axDefaultMetricsConfig: AxMetricsConfig;
|
|
10675
|
-
type AxErrorCategory = 'validation_error' | 'assertion_error' | 'timeout_error' | 'abort_error' | 'network_error' | 'auth_error' | 'rate_limit_error' | 'function_error' | 'parsing_error' | 'unknown_error';
|
|
10676
|
-
interface AxGenMetricsInstruments {
|
|
10677
|
-
generationLatencyHistogram?: Histogram;
|
|
10678
|
-
generationRequestsCounter?: Counter;
|
|
10679
|
-
generationErrorsCounter?: Counter;
|
|
10680
|
-
multiStepGenerationsCounter?: Counter;
|
|
10681
|
-
stepsPerGenerationHistogram?: Histogram;
|
|
10682
|
-
maxStepsReachedCounter?: Counter;
|
|
10683
|
-
validationErrorsCounter?: Counter;
|
|
10684
|
-
assertionErrorsCounter?: Counter;
|
|
10685
|
-
errorCorrectionAttemptsHistogram?: Histogram;
|
|
10686
|
-
errorCorrectionSuccessCounter?: Counter;
|
|
10687
|
-
errorCorrectionFailureCounter?: Counter;
|
|
10688
|
-
maxRetriesReachedCounter?: Counter;
|
|
10689
|
-
functionsEnabledGenerationsCounter?: Counter;
|
|
10690
|
-
functionCallStepsCounter?: Counter;
|
|
10691
|
-
functionsExecutedPerGenerationHistogram?: Histogram;
|
|
10692
|
-
functionErrorCorrectionCounter?: Counter;
|
|
10693
|
-
fieldProcessorsExecutedCounter?: Counter;
|
|
10694
|
-
streamingFieldProcessorsExecutedCounter?: Counter;
|
|
10695
|
-
streamingGenerationsCounter?: Counter;
|
|
10696
|
-
streamingDeltasEmittedCounter?: Counter;
|
|
10697
|
-
streamingFinalizationLatencyHistogram?: Histogram;
|
|
10698
|
-
samplesGeneratedHistogram?: Histogram;
|
|
10699
|
-
resultPickerUsageCounter?: Counter;
|
|
10700
|
-
resultPickerLatencyHistogram?: Histogram;
|
|
10701
|
-
inputFieldsGauge?: Gauge;
|
|
10702
|
-
outputFieldsGauge?: Gauge;
|
|
10703
|
-
examplesUsedGauge?: Gauge;
|
|
10704
|
-
demosUsedGauge?: Gauge;
|
|
10705
|
-
promptRenderLatencyHistogram?: Histogram;
|
|
10706
|
-
extractionLatencyHistogram?: Histogram;
|
|
10707
|
-
assertionLatencyHistogram?: Histogram;
|
|
10708
|
-
stateCreationLatencyHistogram?: Histogram;
|
|
10709
|
-
memoryUpdateLatencyHistogram?: Histogram;
|
|
10710
|
-
}
|
|
10711
|
-
declare const axCheckMetricsHealth: () => {
|
|
10712
|
-
healthy: boolean;
|
|
10713
|
-
issues: string[];
|
|
10714
|
-
};
|
|
10715
|
-
declare const axUpdateMetricsConfig: (config: Readonly<Partial<AxMetricsConfig>>) => void;
|
|
10716
|
-
declare const axGetMetricsConfig: () => AxMetricsConfig;
|
|
10717
|
-
|
|
10718
|
-
/**
|
|
10719
|
-
* Factory function to create a default optimizer logger with color formatting
|
|
10720
|
-
*/
|
|
10721
|
-
declare const axCreateDefaultOptimizerColorLogger: (output?: (message: string) => void) => AxOptimizerLoggerFunction;
|
|
10722
|
-
/**
|
|
10723
|
-
* Factory function to create a text-only optimizer logger (no colors)
|
|
10724
|
-
*/
|
|
10725
|
-
declare const axCreateDefaultOptimizerTextLogger: (output?: (message: string) => void) => AxOptimizerLoggerFunction;
|
|
10726
|
-
/**
|
|
10727
|
-
* Default optimizer logger instance with color formatting
|
|
10728
|
-
*/
|
|
10729
|
-
declare const axDefaultOptimizerLogger: AxOptimizerLoggerFunction;
|
|
10730
|
-
|
|
10731
|
-
type AxRolloutTrace<Out = unknown> = {
|
|
10732
|
-
calls: AxFunctionCallTrace[];
|
|
10733
|
-
output?: Out;
|
|
10734
|
-
error?: string;
|
|
10735
|
-
};
|
|
10736
|
-
|
|
10737
|
-
declare class AxBootstrapFewShot extends AxBaseOptimizer {
|
|
10738
|
-
private maxRounds;
|
|
10739
|
-
private maxDemos;
|
|
10740
|
-
private maxExamples;
|
|
10741
|
-
private batchSize;
|
|
10742
|
-
private earlyStoppingPatience;
|
|
10743
|
-
private costMonitoring;
|
|
10744
|
-
private maxTokensPerGeneration;
|
|
10745
|
-
private verboseMode;
|
|
10746
|
-
private debugMode;
|
|
10747
|
-
private traces;
|
|
10748
|
-
constructor(args: Readonly<AxOptimizerArgs & {
|
|
10749
|
-
options?: AxBootstrapOptimizerOptions;
|
|
10750
|
-
}>);
|
|
10751
|
-
private compileRound;
|
|
10752
|
-
compile<IN, OUT extends AxGenOut>(program: Readonly<AxGen<IN, OUT>>, examples: readonly AxTypedExample<IN>[], metricFn: AxMetricFn, options?: AxCompileOptions): Promise<AxOptimizerResult<OUT>>;
|
|
10753
|
-
}
|
|
10754
|
-
|
|
10755
|
-
type AxGEPABatchRow = {
|
|
10756
|
-
input: AxExample$1;
|
|
10757
|
-
prediction: unknown;
|
|
10758
|
-
scores: Record<string, number>;
|
|
10759
|
-
scalar: number;
|
|
10760
|
-
};
|
|
10761
|
-
type AxGEPABatchEvaluation = {
|
|
10762
|
-
rows: AxGEPABatchRow[];
|
|
10763
|
-
avg: Record<string, number>;
|
|
10764
|
-
scalars: number[];
|
|
10765
|
-
sum: number;
|
|
10766
|
-
trajectories?: readonly unknown[];
|
|
10767
|
-
};
|
|
10768
|
-
type AxGEPAEvaluationState = {
|
|
10769
|
-
totalCalls: number;
|
|
10770
|
-
observedScoreKeys: Set<string>;
|
|
10771
|
-
};
|
|
10772
|
-
|
|
10773
|
-
type AxGEPAReflectiveTuple = {
|
|
10774
|
-
input: AxExample$1;
|
|
10775
|
-
prediction: unknown;
|
|
10776
|
-
score: number;
|
|
10777
|
-
};
|
|
10778
|
-
type AxGEPATraceSummaryCall = {
|
|
10779
|
-
componentId?: string;
|
|
10780
|
-
fn: string;
|
|
10781
|
-
ok: boolean;
|
|
10782
|
-
ms: number;
|
|
10783
|
-
args: string;
|
|
10784
|
-
result: string;
|
|
10785
|
-
};
|
|
10786
|
-
type AxGEPATraceSummary = {
|
|
10787
|
-
score: number;
|
|
10788
|
-
calls: AxGEPATraceSummaryCall[];
|
|
10789
|
-
output?: string;
|
|
10790
|
-
error?: string;
|
|
10791
|
-
};
|
|
10792
|
-
|
|
10793
|
-
type AxInstanceRegistryItem<T extends AxTunable<IN, OUT>, IN, OUT> = T & AxUsable;
|
|
10794
|
-
declare class AxInstanceRegistry<T extends AxTunable<IN, OUT>, IN, OUT> {
|
|
10795
|
-
private reg;
|
|
10796
|
-
constructor();
|
|
10797
|
-
register(instance: AxInstanceRegistryItem<T, IN, OUT>): void;
|
|
10798
|
-
[Symbol.iterator](): Generator<AxInstanceRegistryItem<T, IN, OUT>, void, unknown>;
|
|
10799
|
-
}
|
|
10800
|
-
|
|
10801
|
-
interface AxSamplePickerOptions<OUT> {
|
|
10802
|
-
resultPicker?: AxResultPickerFunction<OUT>;
|
|
10803
|
-
}
|
|
10804
|
-
|
|
10805
|
-
declare const AxStringUtil: {
|
|
10806
|
-
trimNonAlphaNum: (str: string) => string;
|
|
10807
|
-
splitIntoTwo: (str: string, separator: Readonly<RegExp | string>) => string[];
|
|
10808
|
-
dedup: (seq: readonly string[]) => string[];
|
|
10809
|
-
extractIdAndText: (input: string) => {
|
|
10810
|
-
id: number;
|
|
10811
|
-
text: string;
|
|
10812
|
-
};
|
|
10813
|
-
extractIndexPrefixedText: (input: string) => string;
|
|
10814
|
-
batchArray: <T>(arr: readonly T[], size: number) => T[][];
|
|
10815
|
-
};
|
|
10816
|
-
|
|
10817
9722
|
/**
|
|
10818
9723
|
* Creates a type-safe signature from a string template.
|
|
10819
9724
|
*
|
|
@@ -10931,101 +9836,31 @@ declare function ax<TInput extends Record<string, any>, TOutput extends Record<s
|
|
|
10931
9836
|
})>;
|
|
10932
9837
|
declare function ax(signature: Readonly<AxSignatureConfig>, options?: Readonly<AxProgramForwardOptions<any>>): AxGen<AxGenIn, AxGenOut>;
|
|
10933
9838
|
|
|
10934
|
-
/**
|
|
10935
|
-
*
|
|
10936
|
-
*
|
|
10937
|
-
* This class is crucial for the automatic parallelization feature of AxFlow.
|
|
10938
|
-
* It determines which fields in the state object a mapping function accesses,
|
|
10939
|
-
* which allows the execution planner to understand dependencies between steps
|
|
10940
|
-
* and optimize execution by running independent steps in parallel.
|
|
10941
|
-
*
|
|
10942
|
-
* The analyzer uses two complementary approaches:
|
|
10943
|
-
* 1. Static analysis of the function source code
|
|
10944
|
-
* 2. Dynamic proxy-based tracking as a fallback
|
|
9839
|
+
/**
|
|
9840
|
+
* Best-effort static dependency extraction for flow execute mappings.
|
|
10945
9841
|
*
|
|
10946
|
-
* This
|
|
10947
|
-
*
|
|
10948
|
-
*
|
|
9842
|
+
* This intentionally never invokes user code. It only recognizes direct state
|
|
9843
|
+
* reads that are safe to recognize from function source. Unknown state access is
|
|
9844
|
+
* marked unsafe so the planner can keep execution sequential.
|
|
10949
9845
|
*/
|
|
10950
|
-
|
|
10951
|
-
|
|
10952
|
-
|
|
10953
|
-
*
|
|
10954
|
-
* This method is called for every execute step to understand what data
|
|
10955
|
-
* the step needs from the current state. This information is used to:
|
|
10956
|
-
* - Build the dependency graph for parallel execution
|
|
10957
|
-
* - Ensure steps execute in the correct order
|
|
10958
|
-
* - Optimize performance by identifying independent operations
|
|
10959
|
-
*
|
|
10960
|
-
* The analysis process:
|
|
10961
|
-
* 1. First tries static analysis by parsing the function source
|
|
10962
|
-
* 2. Falls back to proxy-based tracking for complex cases
|
|
10963
|
-
* 3. Returns a list of field names that the mapping function accesses
|
|
10964
|
-
*
|
|
10965
|
-
* @param mapping - The mapping function that transforms state to node inputs
|
|
10966
|
-
* @param _nodeName - The name of the node (currently unused but kept for future use)
|
|
10967
|
-
* @returns Array of field names that the mapping function depends on
|
|
10968
|
-
*
|
|
10969
|
-
* @example
|
|
10970
|
-
* ```typescript
|
|
10971
|
-
* // For a mapping like: state => ({ query: state.userInput, context: state.previousResult })
|
|
10972
|
-
* // This would return: ['userInput', 'previousResult']
|
|
10973
|
-
* ```
|
|
10974
|
-
*/
|
|
10975
|
-
analyzeMappingDependencies(mapping: (state: any) => any, _nodeName: string): string[];
|
|
10976
|
-
/**
|
|
10977
|
-
* Creates a tracking proxy for dependency analysis.
|
|
10978
|
-
*
|
|
10979
|
-
* This is a public method that creates a proxy to track property access patterns.
|
|
10980
|
-
* It's used for testing and advanced dependency analysis scenarios.
|
|
10981
|
-
*
|
|
10982
|
-
* @param target - The target object to wrap with a proxy
|
|
10983
|
-
* @param accessed - Array to collect accessed property names
|
|
10984
|
-
* @returns Proxy object that tracks property access
|
|
10985
|
-
*/
|
|
10986
|
-
createTrackingProxy(target: any, accessed: string[]): any;
|
|
10987
|
-
/**
|
|
10988
|
-
* Parses function source code to extract state dependencies using static analysis.
|
|
10989
|
-
*
|
|
10990
|
-
* This method analyzes the source code of a function to find patterns like
|
|
10991
|
-
* `state.fieldName` and extracts the field names as dependencies.
|
|
10992
|
-
*
|
|
10993
|
-
* @param functionSource - The source code of the function to analyze
|
|
10994
|
-
* @returns Array of field names found in the source code
|
|
10995
|
-
*/
|
|
10996
|
-
parseStaticDependencies(functionSource: string): string[];
|
|
10997
|
-
/**
|
|
10998
|
-
* Creates a proxy object that tracks property access for dependency analysis.
|
|
10999
|
-
*
|
|
11000
|
-
* This proxy intercepts all property access on the state object and records
|
|
11001
|
-
* which fields are being accessed. It's used as a fallback when static analysis
|
|
11002
|
-
* can't determine dependencies (e.g., for destructuring or computed properties).
|
|
11003
|
-
*
|
|
11004
|
-
* The proxy works by:
|
|
11005
|
-
* 1. Intercepting all property access via the 'get' trap
|
|
11006
|
-
* 2. Recording accessed property names in the dependencies array
|
|
11007
|
-
* 3. Returning nested proxies for chained property access
|
|
11008
|
-
*
|
|
11009
|
-
* This allows detection of complex access patterns like:
|
|
11010
|
-
* - Destructuring: const { field1, field2 } = state
|
|
11011
|
-
* - Computed properties: state[dynamicKey]
|
|
11012
|
-
* - Nested access: state.nested.field
|
|
11013
|
-
*
|
|
11014
|
-
* @param dependencies - Array to collect dependency names (modified in place)
|
|
11015
|
-
* @returns Proxy object that tracks property access
|
|
11016
|
-
*/
|
|
11017
|
-
private createDependencyTracker;
|
|
9846
|
+
interface AxFlowStateDependencyAnalysis {
|
|
9847
|
+
dependencies: string[];
|
|
9848
|
+
isSafe: boolean;
|
|
11018
9849
|
}
|
|
11019
9850
|
|
|
11020
9851
|
type AxFlowState = Record<string, unknown>;
|
|
11021
|
-
interface
|
|
11022
|
-
|
|
11023
|
-
|
|
11024
|
-
|
|
11025
|
-
|
|
11026
|
-
|
|
11027
|
-
|
|
11028
|
-
}
|
|
9852
|
+
interface AxFlowOptions {
|
|
9853
|
+
autoParallel?: boolean;
|
|
9854
|
+
batchSize?: number;
|
|
9855
|
+
logger?: AxFlowLoggerFunction;
|
|
9856
|
+
debug?: boolean;
|
|
9857
|
+
tracer?: Tracer;
|
|
9858
|
+
meter?: Meter;
|
|
9859
|
+
}
|
|
9860
|
+
type AxFlowForwardOptions<T extends Readonly<AxAIService>> = AxProgramForwardOptionsWithModels<T> & {
|
|
9861
|
+
autoParallel?: boolean;
|
|
9862
|
+
abortController?: AbortController;
|
|
9863
|
+
};
|
|
11029
9864
|
interface AxFlowDynamicContext<T extends Readonly<AxAIService>> {
|
|
11030
9865
|
ai?: T;
|
|
11031
9866
|
options?: AxProgramForwardOptions<NonNullable<ReturnType<T['getModelList']>>[number]['key']>;
|
|
@@ -11050,257 +9885,27 @@ interface AxFlowTypedSubContext<TNodes extends Record<string, AxProgrammable<any
|
|
|
11050
9885
|
executeSteps(initialState: TState, context: Readonly<{
|
|
11051
9886
|
mainAi: AxAIService;
|
|
11052
9887
|
mainOptions?: AxProgramForwardOptions<string>;
|
|
9888
|
+
executeSteps?: (steps: readonly unknown[], initialState: AxFlowState) => Promise<AxFlowState>;
|
|
11053
9889
|
}>): Promise<AxFlowState>;
|
|
11054
9890
|
}
|
|
11055
|
-
|
|
11056
|
-
|
|
11057
|
-
execute<TAI extends Readonly<AxAIService>>(nodeName: string, mapping: (state: AxFlowState) => Record<string, AxFieldValue>, dynamicContext?: AxFlowDynamicContext<TAI>): this;
|
|
11058
|
-
map(transform: (state: AxFlowState) => AxFlowState): this;
|
|
11059
|
-
executeSteps<TAI extends Readonly<AxAIService>>(initialState: AxFlowState, context: Readonly<{
|
|
11060
|
-
mainAi: TAI;
|
|
11061
|
-
mainOptions?: AxProgramForwardOptions<NonNullable<ReturnType<TAI['getModelList']>>[number]['key']>;
|
|
11062
|
-
}>): Promise<AxFlowState>;
|
|
11063
|
-
}
|
|
11064
|
-
interface AxFlowBranchContext {
|
|
11065
|
-
predicate: (state: AxFlowState) => unknown;
|
|
11066
|
-
branches: Map<unknown, AxFlowStepFunction[]>;
|
|
11067
|
-
currentBranchValue?: unknown;
|
|
11068
|
-
}
|
|
11069
|
-
interface AxFlowExecutionStep {
|
|
11070
|
-
type: 'execute' | 'map' | 'merge' | 'parallel-map' | 'parallel' | 'derive';
|
|
9891
|
+
interface AxFlowExecutionPlanStep {
|
|
9892
|
+
type: 'execute' | 'map' | 'returns' | 'branch' | 'while' | 'feedback' | 'parallel' | 'parallelMerge' | 'derive';
|
|
11071
9893
|
nodeName?: string;
|
|
11072
9894
|
dependencies: string[];
|
|
11073
9895
|
produces: string[];
|
|
11074
|
-
stepFunction: AxFlowStepFunction;
|
|
11075
9896
|
stepIndex: number;
|
|
9897
|
+
isBarrier: boolean;
|
|
11076
9898
|
}
|
|
11077
|
-
interface
|
|
9899
|
+
interface AxFlowExecutionPlanGroup {
|
|
11078
9900
|
level: number;
|
|
11079
|
-
steps:
|
|
11080
|
-
}
|
|
11081
|
-
interface AxFlowAutoParallelConfig {
|
|
11082
|
-
enabled: boolean;
|
|
11083
|
-
batchSize?: number;
|
|
9901
|
+
steps: AxFlowExecutionPlanStep[];
|
|
11084
9902
|
}
|
|
11085
|
-
|
|
11086
|
-
|
|
11087
|
-
|
|
11088
|
-
|
|
11089
|
-
|
|
11090
|
-
|
|
11091
|
-
* an optimized execution plan that maximizes parallelism while ensuring
|
|
11092
|
-
* correct execution order.
|
|
11093
|
-
*
|
|
11094
|
-
* Key responsibilities:
|
|
11095
|
-
* 1. **Dependency Analysis**: Tracks what fields each step depends on and produces
|
|
11096
|
-
* 2. **Parallel Grouping**: Groups independent steps that can run simultaneously
|
|
11097
|
-
* 3. **Execution Optimization**: Creates optimized execution functions that
|
|
11098
|
-
* run parallel groups concurrently
|
|
11099
|
-
* 4. **Signature Inference**: Provides data for automatic signature generation
|
|
11100
|
-
*
|
|
11101
|
-
* The planner works by building a directed acyclic graph (DAG) of dependencies
|
|
11102
|
-
* and then creating execution levels where all steps in a level can run in parallel.
|
|
11103
|
-
*/
|
|
11104
|
-
declare class AxFlowExecutionPlanner {
|
|
11105
|
-
private steps;
|
|
11106
|
-
private parallelGroups;
|
|
11107
|
-
private readonly analyzer;
|
|
11108
|
-
private initialFields;
|
|
11109
|
-
/**
|
|
11110
|
-
* Adds an execution step to the plan for analysis and optimization.
|
|
11111
|
-
*
|
|
11112
|
-
* This method is called for every operation in the flow (execute, map, merge, etc.)
|
|
11113
|
-
* and performs dependency analysis to understand what the step needs and produces.
|
|
11114
|
-
* This information is crucial for building the parallel execution plan.
|
|
11115
|
-
*
|
|
11116
|
-
* The method handles different types of steps:
|
|
11117
|
-
* - **Execute steps**: LLM node operations that depend on specific state fields
|
|
11118
|
-
* - **Map steps**: Transformations that modify the state object
|
|
11119
|
-
* - **Merge steps**: Operations that combine results from branches or parallel operations
|
|
11120
|
-
* - **Other steps**: Generic operations that don't fit other categories
|
|
11121
|
-
*
|
|
11122
|
-
* @param stepFunction - The actual function to execute for this step
|
|
11123
|
-
* @param nodeName - Name of the node (for execute steps)
|
|
11124
|
-
* @param mapping - Function that maps state to node inputs (for execute steps)
|
|
11125
|
-
* @param stepType - Type of step for specialized analysis
|
|
11126
|
-
* @param mapTransform - Transformation function (for map steps)
|
|
11127
|
-
* @param mergeOptions - Options for merge operations (result key, merge function)
|
|
11128
|
-
*/
|
|
11129
|
-
addExecutionStep(stepFunction: AxFlowStepFunction, nodeName?: string, mapping?: (state: any) => any, stepType?: 'execute' | 'map' | 'merge' | 'parallel-map' | 'parallel' | 'derive', mapTransform?: (state: any) => any, mergeOptions?: {
|
|
11130
|
-
resultKey?: string;
|
|
11131
|
-
mergeFunction?: (...args: any[]) => any;
|
|
11132
|
-
}, deriveOptions?: {
|
|
11133
|
-
inputFieldName: string;
|
|
11134
|
-
outputFieldName: string;
|
|
11135
|
-
batchSize?: number;
|
|
11136
|
-
}): void;
|
|
11137
|
-
/**
|
|
11138
|
-
* Analyzes a step function to determine what fields it produces.
|
|
11139
|
-
*
|
|
11140
|
-
* This method analyzes the step function to understand what new fields
|
|
11141
|
-
* it adds to the state. It uses a mock state approach:
|
|
11142
|
-
* 1. Creates a mock state with sample data
|
|
11143
|
-
* 2. Runs the step function on the mock state
|
|
11144
|
-
* 3. Compares the result to see what fields were added
|
|
11145
|
-
*
|
|
11146
|
-
* @param stepFunction - The step function to analyze
|
|
11147
|
-
* @returns Array of field names that the step function produces
|
|
11148
|
-
*/
|
|
11149
|
-
private analyzeStepFunctionProduction;
|
|
11150
|
-
/**
|
|
11151
|
-
* Analyzes step function source code to determine what fields it produces.
|
|
11152
|
-
*
|
|
11153
|
-
* @param stepFunction - The step function to analyze
|
|
11154
|
-
* @returns Array of field names that the step function produces
|
|
11155
|
-
*/
|
|
11156
|
-
private analyzeStepFunctionSource;
|
|
11157
|
-
/**
|
|
11158
|
-
* Analyzes a map transformation function to determine what fields it produces.
|
|
11159
|
-
*
|
|
11160
|
-
* This is a challenging problem because map transformations can produce arbitrary
|
|
11161
|
-
* new fields based on complex logic. The method uses a mock state approach:
|
|
11162
|
-
* 1. Creates a mock state with sample data
|
|
11163
|
-
* 2. Runs the transformation on the mock state
|
|
11164
|
-
* 3. Analyzes the result to see what fields were produced
|
|
11165
|
-
*
|
|
11166
|
-
* This approach works for most common transformation patterns but may miss
|
|
11167
|
-
* edge cases where the transformation behavior depends on specific data values.
|
|
11168
|
-
*
|
|
11169
|
-
* @param mapTransform - The map transformation function to analyze
|
|
11170
|
-
* @returns Array of field names that the transformation produces
|
|
11171
|
-
*/
|
|
11172
|
-
private analyzeMapTransformation;
|
|
11173
|
-
/**
|
|
11174
|
-
* Creates a mock state with sample data for transformation analysis.
|
|
11175
|
-
*
|
|
11176
|
-
* This method builds a representative state object that includes:
|
|
11177
|
-
* - Initial fields from the flow input
|
|
11178
|
-
* - Result fields from previous steps with realistic structure
|
|
11179
|
-
* - Sample data that allows transformations to execute
|
|
11180
|
-
*
|
|
11181
|
-
* The mock state is used to run map transformations in a controlled
|
|
11182
|
-
* environment to determine what fields they produce.
|
|
11183
|
-
*
|
|
11184
|
-
* @returns Mock state object with sample data
|
|
11185
|
-
*/
|
|
11186
|
-
private createMockState;
|
|
11187
|
-
/**
|
|
11188
|
-
* Creates appropriate mock values based on field names and patterns.
|
|
11189
|
-
*/
|
|
11190
|
-
private createMockValue;
|
|
11191
|
-
/**
|
|
11192
|
-
* Analyzes what fields are produced by conditional merge operations.
|
|
11193
|
-
*
|
|
11194
|
-
* Conditional merges are complex because they don't transform data like map operations,
|
|
11195
|
-
* but instead select which branch's results to use based on a condition.
|
|
11196
|
-
* The challenge is determining what fields will be available after the merge
|
|
11197
|
-
* without knowing which branch will be taken at runtime.
|
|
11198
|
-
*
|
|
11199
|
-
* This method uses heuristics to determine the likely output fields:
|
|
11200
|
-
* 1. Look at recent execute steps (likely branch operations)
|
|
11201
|
-
* 2. If found, use their output fields as potential merge results
|
|
11202
|
-
* 3. Fallback to all execute step fields if no recent pattern is found
|
|
11203
|
-
*
|
|
11204
|
-
* The analysis assumes that branches in a conditional merge will produce
|
|
11205
|
-
* similar types of fields, so we can use any branch's fields as representative
|
|
11206
|
-
* of what the merge might produce.
|
|
11207
|
-
*
|
|
11208
|
-
* @returns string[] - Array of field names that the merge operation might produce
|
|
11209
|
-
*/
|
|
11210
|
-
private analyzeBranchMergeFields;
|
|
11211
|
-
/**
|
|
11212
|
-
* Sets the initial fields and triggers parallel group rebuilding.
|
|
11213
|
-
*
|
|
11214
|
-
* This method is called once the flow knows what input fields are available.
|
|
11215
|
-
* It triggers the parallel group analysis which determines the optimal
|
|
11216
|
-
* execution strategy for the entire flow.
|
|
11217
|
-
*
|
|
11218
|
-
* @param fields - Array of field names available at the start of execution
|
|
11219
|
-
*/
|
|
11220
|
-
setInitialFields(fields: string[]): void;
|
|
11221
|
-
/**
|
|
11222
|
-
* Rebuilds the parallel execution groups based on step dependencies.
|
|
11223
|
-
*
|
|
11224
|
-
* This is the core algorithm that creates the parallel execution plan.
|
|
11225
|
-
* It uses a level-by-level approach:
|
|
11226
|
-
*
|
|
11227
|
-
* 1. **Level 0**: Steps with no dependencies (can run immediately)
|
|
11228
|
-
* 2. **Level 1**: Steps that depend only on Level 0 outputs
|
|
11229
|
-
* 3. **Level N**: Steps that depend on outputs from previous levels
|
|
11230
|
-
*
|
|
11231
|
-
* Steps within the same level can run in parallel because they don't
|
|
11232
|
-
* depend on each other's outputs.
|
|
11233
|
-
*
|
|
11234
|
-
* The algorithm ensures:
|
|
11235
|
-
* - Correct execution order (dependencies are satisfied)
|
|
11236
|
-
* - Maximum parallelism (independent steps run simultaneously)
|
|
11237
|
-
* - Deadlock prevention (circular dependencies are detected)
|
|
11238
|
-
*
|
|
11239
|
-
* Time complexity: O(n²) where n is the number of steps
|
|
11240
|
-
* Space complexity: O(n) for tracking processed steps and available fields
|
|
11241
|
-
*/
|
|
11242
|
-
private rebuildParallelGroups;
|
|
11243
|
-
/**
|
|
11244
|
-
* Gets all fields produced by previous steps.
|
|
11245
|
-
*
|
|
11246
|
-
* This is used by steps that depend on "everything produced so far"
|
|
11247
|
-
* such as map transformations and merge operations.
|
|
11248
|
-
*
|
|
11249
|
-
* @returns Array of all field names produced by previous steps
|
|
11250
|
-
*/
|
|
11251
|
-
private getAllProducedFields;
|
|
11252
|
-
/**
|
|
11253
|
-
* Creates optimized execution functions that implement the parallel execution plan.
|
|
11254
|
-
*
|
|
11255
|
-
* This method converts the parallel groups into actual executable functions.
|
|
11256
|
-
* It creates a series of steps where:
|
|
11257
|
-
* - Single-step groups execute directly
|
|
11258
|
-
* - Multi-step groups execute in parallel with batch size control
|
|
11259
|
-
* - Results are properly merged to maintain state consistency
|
|
11260
|
-
*
|
|
11261
|
-
* The optimized execution can significantly improve performance for flows
|
|
11262
|
-
* with independent operations, especially I/O-bound operations like LLM calls.
|
|
11263
|
-
*
|
|
11264
|
-
* Performance benefits:
|
|
11265
|
-
* - Reduces total execution time for independent operations
|
|
11266
|
-
* - Maximizes CPU and I/O utilization
|
|
11267
|
-
* - Maintains correctness through dependency management
|
|
11268
|
-
* - Controls resource usage through batch size limiting
|
|
11269
|
-
*
|
|
11270
|
-
* @param batchSize - Maximum number of concurrent operations (optional)
|
|
11271
|
-
* @returns Array of optimized step functions ready for execution
|
|
11272
|
-
*/
|
|
11273
|
-
createOptimizedExecution(batchSize?: number): AxFlowStepFunction[];
|
|
11274
|
-
/**
|
|
11275
|
-
* Gets optimized execution steps for the flow.
|
|
11276
|
-
*
|
|
11277
|
-
* This method provides the optimized execution steps that can be used
|
|
11278
|
-
* to execute the flow with maximum parallelism while maintaining
|
|
11279
|
-
* dependency order.
|
|
11280
|
-
*
|
|
11281
|
-
* @returns Array of optimized step functions ready for execution
|
|
11282
|
-
*/
|
|
11283
|
-
getOptimizedExecutionSteps(): AxFlowStepFunction[];
|
|
11284
|
-
/**
|
|
11285
|
-
* Gets detailed execution plan information for debugging and analysis.
|
|
11286
|
-
*
|
|
11287
|
-
* This method provides comprehensive information about the execution plan,
|
|
11288
|
-
* including step counts, parallel grouping details, and the complete
|
|
11289
|
-
* dependency structure. It's particularly useful for:
|
|
11290
|
-
* - Debugging execution flow issues
|
|
11291
|
-
* - Performance analysis and optimization
|
|
11292
|
-
* - Understanding parallelization effectiveness
|
|
11293
|
-
* - Monitoring execution plan complexity
|
|
11294
|
-
*
|
|
11295
|
-
* @returns Object containing detailed execution plan metrics and data
|
|
11296
|
-
*/
|
|
11297
|
-
getExecutionPlan(): {
|
|
11298
|
-
totalSteps: number;
|
|
11299
|
-
parallelGroups: number;
|
|
11300
|
-
maxParallelism: number;
|
|
11301
|
-
steps: AxFlowExecutionStep[];
|
|
11302
|
-
groups: AxFlowParallelGroup[];
|
|
11303
|
-
};
|
|
9903
|
+
interface AxFlowExecutionPlan {
|
|
9904
|
+
totalSteps: number;
|
|
9905
|
+
parallelGroups: number;
|
|
9906
|
+
maxParallelism: number;
|
|
9907
|
+
steps: AxFlowExecutionPlanStep[];
|
|
9908
|
+
groups: AxFlowExecutionPlanGroup[];
|
|
11304
9909
|
}
|
|
11305
9910
|
|
|
11306
9911
|
/**
|
|
@@ -11389,114 +9994,37 @@ declare const axCreateFlowTextLogger: (output?: (message: string) => void) => Ax
|
|
|
11389
9994
|
*/
|
|
11390
9995
|
declare const axDefaultFlowLogger: AxFlowLoggerFunction;
|
|
11391
9996
|
|
|
11392
|
-
|
|
11393
|
-
|
|
11394
|
-
|
|
11395
|
-
|
|
11396
|
-
|
|
11397
|
-
|
|
11398
|
-
|
|
11399
|
-
|
|
11400
|
-
|
|
11401
|
-
* .node('summarizer', 'text:string -> summary:string')
|
|
11402
|
-
* .node('critic', 'summary:string -> critique:string')
|
|
11403
|
-
* .execute('summarizer', state => ({ text: `About ${state.topic}` })) // state is { topic: string }
|
|
11404
|
-
* .execute('critic', state => ({ summary: state.summarizerResult.summary })) // state evolves!
|
|
11405
|
-
* .map(state => ({ finalAnswer: state.criticResult.critique })) // fully typed!
|
|
11406
|
-
*
|
|
11407
|
-
* const result = await flow.forward(ai, { topic: "AI safety" })
|
|
11408
|
-
* ```
|
|
11409
|
-
*/
|
|
11410
|
-
declare class AxFlow<IN extends Record<string, any>, OUT, TNodes extends Record<string, AxProgrammable<any, any>> = {}, // Node registry for type tracking
|
|
11411
|
-
TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
11412
|
-
private static _ctorWarned;
|
|
11413
|
-
private static _constructingFromFactory;
|
|
11414
|
-
private readonly nodes;
|
|
11415
|
-
private readonly flowDefinition;
|
|
9997
|
+
interface AxFlowNodeExecutionRecorder {
|
|
9998
|
+
recordUsage(nodeName: string, usage: AxProgramUsage[]): void;
|
|
9999
|
+
recordTraces(nodeName: string, traces: AxProgramTrace<any, any>[]): void;
|
|
10000
|
+
recordChatLog(nodeName: string, entries: AxChatLogEntry[]): void;
|
|
10001
|
+
}
|
|
10002
|
+
|
|
10003
|
+
declare class AxFlow<IN extends Record<string, any>, OUT, TNodes extends Record<string, AxProgrammable<any, any>> = Record<string, never>, TState extends AxFlowState = IN> implements AxFlowable<IN, OUT>, AxFlowNodeExecutionRecorder {
|
|
10004
|
+
private readonly steps;
|
|
10005
|
+
private currentSteps;
|
|
11416
10006
|
private readonly nodeGenerators;
|
|
11417
|
-
private readonly loopStack;
|
|
11418
10007
|
private readonly stepLabels;
|
|
10008
|
+
private readonly loopStack;
|
|
11419
10009
|
private branchContext;
|
|
11420
|
-
private readonly autoParallelConfig;
|
|
11421
|
-
private readonly executionPlanner;
|
|
11422
10010
|
private program?;
|
|
11423
10011
|
private flowName?;
|
|
11424
|
-
private
|
|
11425
|
-
private nodeTraces;
|
|
11426
|
-
private nodeChatLog;
|
|
10012
|
+
private readonly autoParallelConfig;
|
|
11427
10013
|
private readonly flowLogger?;
|
|
11428
10014
|
private readonly timingLogger?;
|
|
11429
10015
|
private readonly defaultAIOptions?;
|
|
10016
|
+
private nodeUsage;
|
|
10017
|
+
private nodeTraces;
|
|
10018
|
+
private nodeChatLog;
|
|
11430
10019
|
private activeAbortControllers;
|
|
11431
10020
|
private _stopRequested;
|
|
11432
|
-
|
|
11433
|
-
|
|
11434
|
-
*/
|
|
10021
|
+
private constructor();
|
|
10022
|
+
static create<IN extends Record<string, any> = Record<string, unknown>, OUT = {}, TNodes extends Record<string, AxProgrammable<any, any>> = Record<string, never>, TState extends AxFlowState = IN>(options?: AxFlowOptions): AxFlow<IN, OUT, TNodes, TState>;
|
|
11435
10023
|
private toCamelCase;
|
|
11436
|
-
/**
|
|
11437
|
-
* Stops an in-flight `forward()` call. Causes it to throw
|
|
11438
|
-
* `AxAIServiceAbortedError`.
|
|
11439
|
-
*/
|
|
11440
10024
|
stop(): void;
|
|
10025
|
+
private addStep;
|
|
11441
10026
|
private getCacheKey;
|
|
11442
|
-
/**
|
|
11443
|
-
* Executes a list of steps with comprehensive logging
|
|
11444
|
-
*/
|
|
11445
|
-
private executeStepsWithLogging;
|
|
11446
|
-
/**
|
|
11447
|
-
* Determines the type of a step function for logging purposes
|
|
11448
|
-
*/
|
|
11449
|
-
private getStepType;
|
|
11450
|
-
/**
|
|
11451
|
-
* Gets metadata about a step for logging purposes
|
|
11452
|
-
*/
|
|
11453
|
-
private getStepMetadata;
|
|
11454
|
-
/**
|
|
11455
|
-
* Extracts node name from step function source code
|
|
11456
|
-
*/
|
|
11457
|
-
private extractNodeNameFromSource;
|
|
11458
|
-
/**
|
|
11459
|
-
* Infers the signature of the flow based on the execution plan and node definitions.
|
|
11460
|
-
* This is the core method that determines what input/output fields the flow should have
|
|
11461
|
-
* based on the nodes and operations defined in the flow.
|
|
11462
|
-
*
|
|
11463
|
-
* The inference process follows these steps:
|
|
11464
|
-
* 1. If no nodes are defined, return a default signature
|
|
11465
|
-
* 2. Analyze the execution plan to find all produced and consumed fields
|
|
11466
|
-
* 3. Determine input fields (consumed but not produced by any step)
|
|
11467
|
-
* 4. Determine output fields with special handling for final map/merge operations
|
|
11468
|
-
* 5. If no clear pattern is found, create a comprehensive signature from all nodes
|
|
11469
|
-
*
|
|
11470
|
-
* Special handling for final operations:
|
|
11471
|
-
* - Map operations: Use the fields produced by the map transformation
|
|
11472
|
-
* - Merge operations: Use fields from the merged branches or merge result
|
|
11473
|
-
* - Conditional merges: Analyze what fields the branches actually produce
|
|
11474
|
-
*
|
|
11475
|
-
* @returns AxSignature - The inferred signature for this flow
|
|
11476
|
-
*/
|
|
11477
10027
|
private inferSignatureFromFlow;
|
|
11478
|
-
constructor(options?: {
|
|
11479
|
-
autoParallel?: boolean;
|
|
11480
|
-
batchSize?: number;
|
|
11481
|
-
logger?: AxFlowLoggerFunction;
|
|
11482
|
-
debug?: boolean;
|
|
11483
|
-
tracer?: Tracer;
|
|
11484
|
-
meter?: Meter;
|
|
11485
|
-
});
|
|
11486
|
-
/**
|
|
11487
|
-
* Static factory method to create a new AxFlow instance with proper type safety
|
|
11488
|
-
* @param options - Optional configuration for the flow
|
|
11489
|
-
* @returns New AxFlow instance with type-safe defaults
|
|
11490
|
-
*/
|
|
11491
|
-
static create<IN extends Record<string, any> = Record<string, never>, OUT = {}, TNodes extends Record<string, AxProgrammable<any, any>> = Record<string, never>, TState extends AxFlowState = IN>(options?: {
|
|
11492
|
-
autoParallel?: boolean;
|
|
11493
|
-
batchSize?: number;
|
|
11494
|
-
logger?: AxFlowLoggerFunction;
|
|
11495
|
-
debug?: boolean;
|
|
11496
|
-
}): AxFlow<IN, OUT, TNodes, TState>;
|
|
11497
|
-
/**
|
|
11498
|
-
* Initializes the program field every time something is added to the graph
|
|
11499
|
-
*/
|
|
11500
10028
|
private ensureProgram;
|
|
11501
10029
|
getId(): string;
|
|
11502
10030
|
setId(id: string): void;
|
|
@@ -11514,150 +10042,33 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
11514
10042
|
getUsage(): AxProgramUsage[];
|
|
11515
10043
|
getChatLog(): readonly AxChatLogEntry[];
|
|
11516
10044
|
resetUsage(): void;
|
|
11517
|
-
/**
|
|
11518
|
-
* Resets trace tracking for the flow.
|
|
11519
|
-
* This is called automatically on each forward/streamingForward call.
|
|
11520
|
-
*/
|
|
11521
10045
|
resetTraces(): void;
|
|
11522
10046
|
resetChatLog(): void;
|
|
11523
|
-
/**
|
|
11524
|
-
* Gets a detailed usage report broken down by node name.
|
|
11525
|
-
* This provides visibility into which nodes are consuming the most tokens.
|
|
11526
|
-
*
|
|
11527
|
-
* @returns Object mapping node names to their usage statistics
|
|
11528
|
-
*/
|
|
11529
10047
|
getUsageReport(): Record<string, AxProgramUsage[]>;
|
|
11530
|
-
/**
|
|
11531
|
-
* Expose node programs for system-level operations (optimization, inspection)
|
|
11532
|
-
*/
|
|
11533
10048
|
getNodePrograms(): ReadonlyArray<{
|
|
11534
10049
|
name: string;
|
|
11535
10050
|
program: AxProgrammable<any, any>;
|
|
11536
10051
|
}>;
|
|
11537
|
-
/**
|
|
11538
|
-
* Attempt to set instruction on a node if supported (AxGen.
|
|
11539
|
-
* setInstruction is optional; returns true if applied)
|
|
11540
|
-
*/
|
|
11541
10052
|
setNodeInstruction(name: string, instruction: string): boolean;
|
|
11542
|
-
/**
|
|
11543
|
-
* Bulk-apply instructions to nodes; ignores names that don’t exist or nodes without instruction setter
|
|
11544
|
-
*/
|
|
11545
10053
|
setAllNodeInstructions(map: Readonly<Record<string, string>>): void;
|
|
11546
|
-
/**
|
|
11547
|
-
* Gets a detailed trace report broken down by node name.
|
|
11548
|
-
* This provides visibility into the execution traces for each node.
|
|
11549
|
-
*
|
|
11550
|
-
* @returns Object mapping node names to their trace data
|
|
11551
|
-
*/
|
|
11552
10054
|
getTracesReport(): Record<string, AxProgramTrace<any, any>[]>;
|
|
11553
|
-
|
|
11554
|
-
|
|
11555
|
-
|
|
11556
|
-
|
|
11557
|
-
|
|
11558
|
-
*
|
|
11559
|
-
* This is the main execution method that orchestrates the entire flow execution.
|
|
11560
|
-
* It handles several complex aspects:
|
|
11561
|
-
*
|
|
11562
|
-
* 1. **Dynamic Signature Inference**: If the flow was created with a default signature
|
|
11563
|
-
* but has nodes defined, it will infer the actual signature from the flow structure.
|
|
11564
|
-
*
|
|
11565
|
-
* 2. **Execution Mode Selection**: Chooses between optimized parallel execution
|
|
11566
|
-
* (when auto-parallel is enabled) or sequential execution based on configuration.
|
|
11567
|
-
*
|
|
11568
|
-
* 3. **State Management**: Maintains the evolving state object as it flows through
|
|
11569
|
-
* each step, accumulating results and transformations.
|
|
11570
|
-
*
|
|
11571
|
-
* 4. **Performance Optimization**: Uses the execution planner to identify
|
|
11572
|
-
* independent operations that can run in parallel, reducing total execution time.
|
|
11573
|
-
*
|
|
11574
|
-
* Execution Flow:
|
|
11575
|
-
* - Initialize state with input values
|
|
11576
|
-
* - Infer signature if needed (based on nodes and current signature)
|
|
11577
|
-
* - Choose execution strategy (parallel vs sequential)
|
|
11578
|
-
* - Execute all steps while maintaining state consistency
|
|
11579
|
-
* - Return final state cast to expected output type
|
|
11580
|
-
*
|
|
11581
|
-
* @param ai - The AI service to use as the default for all steps
|
|
11582
|
-
* @param values - The input values for the flow
|
|
11583
|
-
* @param options - Optional forward options to use as defaults (includes autoParallel override)
|
|
11584
|
-
* @returns Promise that resolves to the final output
|
|
11585
|
-
*/
|
|
11586
|
-
forward<T extends Readonly<AxAIService>>(ai: T, values: IN, options?: Readonly<AxProgramForwardOptionsWithModels<T> & {
|
|
11587
|
-
autoParallel?: boolean;
|
|
11588
|
-
abortController?: AbortController;
|
|
11589
|
-
}>): Promise<OUT>;
|
|
11590
|
-
/**
|
|
11591
|
-
* Declares a reusable computational node using a signature string.
|
|
11592
|
-
* Returns a new AxFlow type that tracks this node in the TNodes registry.
|
|
11593
|
-
*
|
|
11594
|
-
* @param name - The name of the node
|
|
11595
|
-
* @param signature - Signature string in the same format as AxSignature
|
|
11596
|
-
* @returns New AxFlow instance with updated TNodes type
|
|
11597
|
-
*
|
|
11598
|
-
* @example
|
|
11599
|
-
* ```
|
|
11600
|
-
* flow.node('summarizer', 'text:string -> summary:string')
|
|
11601
|
-
* flow.node('analyzer', 'text:string -> analysis:string, confidence:number', { debug: true })
|
|
11602
|
-
* ```
|
|
11603
|
-
*/
|
|
10055
|
+
recordUsage(nodeName: string, usage: AxProgramUsage[]): void;
|
|
10056
|
+
recordTraces(nodeName: string, traces: AxProgramTrace<any, any>[]): void;
|
|
10057
|
+
recordChatLog(_nodeName: string, entries: AxChatLogEntry[]): void;
|
|
10058
|
+
streamingForward<T extends Readonly<AxAIService>>(ai: T, values: IN, options?: Readonly<AxProgramStreamingForwardOptionsWithModels<T>>): AxGenStreamingOut<OUT>;
|
|
10059
|
+
forward<T extends Readonly<AxAIService>>(ai: T, values: IN, options?: Readonly<AxFlowForwardOptions<T>>): Promise<OUT>;
|
|
11604
10060
|
node<TName extends string, TSig extends string>(name: TName, signature: TSig): AxFlow<IN, OUT, TNodes & {
|
|
11605
10061
|
[K in TName]: InferAxGen<TSig>;
|
|
11606
|
-
},
|
|
11607
|
-
TState>;
|
|
11608
|
-
/**
|
|
11609
|
-
* Declares a reusable computational node using an AxSignature instance.
|
|
11610
|
-
* This allows using pre-configured signatures in the flow.
|
|
11611
|
-
*
|
|
11612
|
-
* @param name - The name of the node
|
|
11613
|
-
* @param signature - AxSignature instance to use for this node
|
|
11614
|
-
* @returns New AxFlow instance with updated TNodes type
|
|
11615
|
-
*
|
|
11616
|
-
* @example
|
|
11617
|
-
* ```
|
|
11618
|
-
* const sig = s('text:string -> summary:string')
|
|
11619
|
-
* flow.node('summarizer', sig, { temperature: 0.1 })
|
|
11620
|
-
* ```
|
|
11621
|
-
*/
|
|
10062
|
+
}, TState>;
|
|
11622
10063
|
node<TName extends string>(name: TName, signature: AxSignature): AxFlow<IN, OUT, TNodes & {
|
|
11623
10064
|
[K in TName]: AxGen<AxGenIn, AxGenOut>;
|
|
11624
|
-
},
|
|
11625
|
-
TState>;
|
|
11626
|
-
/**
|
|
11627
|
-
* Declares a reusable computational node using a class that extends AxProgram.
|
|
11628
|
-
* This allows using custom program classes in the flow.
|
|
11629
|
-
*
|
|
11630
|
-
* @param name - The name of the node
|
|
11631
|
-
* @param programClass - Class that extends AxProgram to use for this node
|
|
11632
|
-
* @returns New AxFlow instance with updated TNodes type
|
|
11633
|
-
*
|
|
11634
|
-
* @example
|
|
11635
|
-
* ```
|
|
11636
|
-
* class CustomProgram extends AxProgram<{ input: string }, { output: string }> {
|
|
11637
|
-
* async forward(ai, values) { return { output: values.input.toUpperCase() } }
|
|
11638
|
-
* }
|
|
11639
|
-
* flow.node('custom', CustomProgram)
|
|
11640
|
-
* ```
|
|
11641
|
-
*/
|
|
10065
|
+
}, TState>;
|
|
11642
10066
|
node<TName extends string, TProgram extends new () => AxProgrammable<any, any>>(name: TName, programClass: TProgram): AxFlow<IN, OUT, TNodes & {
|
|
11643
10067
|
[K in TName]: InstanceType<TProgram>;
|
|
11644
|
-
},
|
|
11645
|
-
TState>;
|
|
11646
|
-
/**
|
|
11647
|
-
* Declares a reusable computational node using an AxProgrammable instance.
|
|
11648
|
-
* This allows using pre-configured AxGen instances or other programmable objects in the flow.
|
|
11649
|
-
*
|
|
11650
|
-
* @param name - The name of the node
|
|
11651
|
-
* @param programInstance - The AxProgrammable instance to use for this node
|
|
11652
|
-
* @returns New AxFlow instance with updated TNodes type
|
|
11653
|
-
*/
|
|
10068
|
+
}, TState>;
|
|
11654
10069
|
node<TName extends string, TProgram extends AxProgrammable<any, any>>(name: TName, programInstance: TProgram): AxFlow<IN, OUT, TNodes & {
|
|
11655
10070
|
[K in TName]: TProgram;
|
|
11656
|
-
},
|
|
11657
|
-
TState>;
|
|
11658
|
-
/**
|
|
11659
|
-
* Short alias for node() - supports signature strings, AxSignature instances, AxGen instances, and program classes
|
|
11660
|
-
*/
|
|
10071
|
+
}, TState>;
|
|
11661
10072
|
n<TName extends string, TSig extends string>(name: TName, signature: TSig): AxFlow<IN, OUT, TNodes & {
|
|
11662
10073
|
[K in TName]: InferAxGen<TSig>;
|
|
11663
10074
|
}, TState>;
|
|
@@ -11670,84 +10081,17 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
11670
10081
|
n<TName extends string, TProgram extends AxProgrammable<any, any>>(name: TName, programInstance: TProgram): AxFlow<IN, OUT, TNodes & {
|
|
11671
10082
|
[K in TName]: TProgram;
|
|
11672
10083
|
}, TState>;
|
|
11673
|
-
/**
|
|
11674
|
-
* Applies a synchronous transformation to the state object.
|
|
11675
|
-
* Returns a new AxFlow type with the evolved state.
|
|
11676
|
-
*
|
|
11677
|
-
* @param transform - Function that takes the current state and returns a new state
|
|
11678
|
-
* @returns New AxFlow instance with updated TState type
|
|
11679
|
-
*
|
|
11680
|
-
* @example
|
|
11681
|
-
* ```
|
|
11682
|
-
* flow.map(state => ({ ...state, processedText: state.text.toLowerCase() }))
|
|
11683
|
-
* ```
|
|
11684
|
-
*/
|
|
11685
10084
|
map<TNewState extends AxFlowState>(transform: (_state: TState) => TNewState): AxFlow<IN, OUT, TNodes, TNewState>;
|
|
11686
|
-
/**
|
|
11687
|
-
* Applies an asynchronous transformation to the state object.
|
|
11688
|
-
* Returns a new AxFlow type with the evolved state.
|
|
11689
|
-
*
|
|
11690
|
-
* @param transform - Async function that takes the current state and returns a promise of new state
|
|
11691
|
-
* @returns New AxFlow instance with updated TState type
|
|
11692
|
-
*
|
|
11693
|
-
* @example
|
|
11694
|
-
* ```
|
|
11695
|
-
* flow.map(async state => ({
|
|
11696
|
-
* ...state,
|
|
11697
|
-
* apiResult: await fetchDataFromAPI(state.query)
|
|
11698
|
-
* }))
|
|
11699
|
-
* ```
|
|
11700
|
-
*/
|
|
11701
10085
|
map<TNewState extends AxFlowState>(transform: (_state: TState) => Promise<TNewState>): AxFlow<IN, OUT, TNodes, TNewState>;
|
|
11702
|
-
/**
|
|
11703
|
-
* Applies a transformation to the state object with optional parallel execution.
|
|
11704
|
-
* When parallel is enabled, the transform function should prepare data for parallel processing.
|
|
11705
|
-
* The actual parallel processing happens with the array of transforms provided.
|
|
11706
|
-
*
|
|
11707
|
-
* @param transforms - Array of transformation functions to apply in parallel
|
|
11708
|
-
* @param options - Options including parallel execution configuration
|
|
11709
|
-
* @returns New AxFlow instance with updated TState type
|
|
11710
|
-
*
|
|
11711
|
-
* @example
|
|
11712
|
-
* ```
|
|
11713
|
-
* // Parallel map with multiple transforms
|
|
11714
|
-
* flow.map([
|
|
11715
|
-
* state => ({ ...state, result1: processA(state.data) }),
|
|
11716
|
-
* state => ({ ...state, result2: processB(state.data) }),
|
|
11717
|
-
* state => ({ ...state, result3: processC(state.data) })
|
|
11718
|
-
* ], { parallel: true })
|
|
11719
|
-
* ```
|
|
11720
|
-
*/
|
|
11721
10086
|
map<TNewState extends AxFlowState>(transforms: Array<(_state: TState) => TNewState>, options: {
|
|
11722
10087
|
parallel: true;
|
|
11723
10088
|
}): AxFlow<IN, OUT, TNodes, TNewState>;
|
|
11724
|
-
/**
|
|
11725
|
-
* Applies async transformations to the state object with optional parallel execution.
|
|
11726
|
-
* When parallel is enabled, all async transforms are executed concurrently.
|
|
11727
|
-
*
|
|
11728
|
-
* @param transforms - Array of async transformation functions to apply in parallel
|
|
11729
|
-
* @param options - Options including parallel execution configuration
|
|
11730
|
-
* @returns New AxFlow instance with updated TState type
|
|
11731
|
-
*
|
|
11732
|
-
* @example
|
|
11733
|
-
* ```
|
|
11734
|
-
* // Parallel async map with multiple transforms
|
|
11735
|
-
* flow.map([
|
|
11736
|
-
* async state => ({ ...state, result1: await apiCall1(state.data) }),
|
|
11737
|
-
* async state => ({ ...state, result2: await apiCall2(state.data) }),
|
|
11738
|
-
* async state => ({ ...state, result3: await apiCall3(state.data) })
|
|
11739
|
-
* ], { parallel: true })
|
|
11740
|
-
* ```
|
|
11741
|
-
*/
|
|
11742
10089
|
map<TNewState extends AxFlowState>(transforms: Array<(_state: TState) => Promise<TNewState>>, options: {
|
|
11743
10090
|
parallel: true;
|
|
11744
10091
|
}): AxFlow<IN, OUT, TNodes, TNewState>;
|
|
11745
10092
|
map<TNewState extends AxFlowState>(transform: (_state: TState) => TNewState | Promise<TNewState>, options?: {
|
|
11746
10093
|
parallel?: boolean;
|
|
11747
10094
|
}): AxFlow<IN, OUT, TNodes, TNewState>;
|
|
11748
|
-
/**
|
|
11749
|
-
* Short alias for map() - supports parallel option and async functions
|
|
11750
|
-
*/
|
|
11751
10095
|
m<TNewState extends AxFlowState>(transform: (_state: TState) => TNewState): AxFlow<IN, OUT, TNodes, TNewState>;
|
|
11752
10096
|
m<TNewState extends AxFlowState>(transform: (_state: TState) => Promise<TNewState>): AxFlow<IN, OUT, TNodes, TNewState>;
|
|
11753
10097
|
m<TNewState extends AxFlowState>(transforms: Array<(_state: TState) => TNewState>, options: {
|
|
@@ -11756,298 +10100,50 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
11756
10100
|
m<TNewState extends AxFlowState>(transforms: Array<(_state: TState) => Promise<TNewState>>, options: {
|
|
11757
10101
|
parallel: true;
|
|
11758
10102
|
}): AxFlow<IN, OUT, TNodes, TNewState>;
|
|
11759
|
-
/**
|
|
11760
|
-
* Terminal transformation that sets the final output type of the flow.
|
|
11761
|
-
* Use this as the last transformation to get proper type inference for the flow result.
|
|
11762
|
-
*
|
|
11763
|
-
* @param transform - Function that transforms the current state to the final output
|
|
11764
|
-
* @returns A new flow with the output type set to the transform result
|
|
11765
|
-
*
|
|
11766
|
-
* @example
|
|
11767
|
-
* ```typescript
|
|
11768
|
-
* const flow = flow<{ input: string }>()
|
|
11769
|
-
* .map(state => ({ ...state, processed: true }))
|
|
11770
|
-
* .returns(state => ({
|
|
11771
|
-
* result: state.processed ? "done" : "pending"
|
|
11772
|
-
* })) // TypeScript now knows the output is { result: string }
|
|
11773
|
-
* ```
|
|
11774
|
-
*/
|
|
11775
10103
|
returns<TNewOut extends Record<string, unknown>>(transform: (_state: TState) => TNewOut): AxFlow<IN, TNewOut, TNodes, TState>;
|
|
11776
|
-
/**
|
|
11777
|
-
* Short alias for returns() - r() is to returns() as m() is to map()
|
|
11778
|
-
*
|
|
11779
|
-
* @param transform - Function that transforms the current state to the final output
|
|
11780
|
-
* @returns A new flow with the output type set to the transform result
|
|
11781
|
-
*/
|
|
11782
10104
|
r<TNewOut extends Record<string, unknown>>(transform: (_state: TState) => TNewOut): AxFlow<IN, TNewOut, TNodes, TState>;
|
|
11783
|
-
/**
|
|
11784
|
-
* Labels a step for later reference (useful for feedback loops).
|
|
11785
|
-
*
|
|
11786
|
-
* @param label - The label to assign to the current step position
|
|
11787
|
-
* @returns this (for chaining, no type change)
|
|
11788
|
-
*
|
|
11789
|
-
* @example
|
|
11790
|
-
* ```typescript
|
|
11791
|
-
* flow.label('retry-point')
|
|
11792
|
-
* .execute('queryGen', ...)
|
|
11793
|
-
* ```
|
|
11794
|
-
*/
|
|
11795
10105
|
label(label: string): this;
|
|
11796
|
-
/**
|
|
11797
|
-
* Short alias for label()
|
|
11798
|
-
*/
|
|
11799
10106
|
l(label: string): this;
|
|
11800
|
-
|
|
11801
|
-
* Executes a previously defined node with full type safety.
|
|
11802
|
-
* The node name must exist in TNodes, and the mapping function is typed based on the node's signature.
|
|
11803
|
-
*
|
|
11804
|
-
* @param nodeName - The name of the node to execute (must exist in TNodes)
|
|
11805
|
-
* @param mapping - Typed function that takes the current state and returns the input for the node
|
|
11806
|
-
* @param dynamicContext - Optional object to override the AI service or options for this specific step
|
|
11807
|
-
* @returns New AxFlow instance with TState augmented with the node's result
|
|
11808
|
-
*
|
|
11809
|
-
* @example
|
|
11810
|
-
* ```typescript
|
|
11811
|
-
* flow.execute('summarizer', state => ({ text: state.originalText }), { ai: cheapAI })
|
|
11812
|
-
* ```
|
|
11813
|
-
*/
|
|
10107
|
+
private createExecuteStep;
|
|
11814
10108
|
execute<TNodeName extends keyof TNodes & string, TAI extends Readonly<AxAIService>>(nodeName: TNodeName, mapping: (_state: TState) => GetGenIn<TNodes[TNodeName]>, dynamicContext?: AxFlowDynamicContext<TAI>): AxFlow<IN, OUT, TNodes, AddNodeResult<TState, TNodeName, GetGenOut<TNodes[TNodeName]>>>;
|
|
11815
|
-
|
|
11816
|
-
* Apply optimized configuration to this flow and all node programs.
|
|
11817
|
-
*/
|
|
10109
|
+
e<TNodeName extends keyof TNodes & string, TAI extends Readonly<AxAIService>>(nodeName: TNodeName, mapping: (_state: TState) => GetGenIn<TNodes[TNodeName]>, dynamicContext?: AxFlowDynamicContext<TAI>): AxFlow<IN, OUT, TNodes, AddNodeResult<TState, TNodeName, GetGenOut<TNodes[TNodeName]>>>;
|
|
11818
10110
|
applyOptimization(optimizedProgram: AxOptimizedProgram<any>): void;
|
|
11819
10111
|
getOptimizableComponents(): readonly AxOptimizableComponent[];
|
|
11820
10112
|
applyOptimizedComponents(updates: Readonly<Record<string, string>>): void;
|
|
11821
|
-
/**
|
|
11822
|
-
* Short alias for execute()
|
|
11823
|
-
*/
|
|
11824
|
-
e<TNodeName extends keyof TNodes & string, TAI extends Readonly<AxAIService>>(nodeName: TNodeName, mapping: (_state: TState) => GetGenIn<TNodes[TNodeName]>, dynamicContext?: AxFlowDynamicContext<TAI>): AxFlow<IN, OUT, TNodes, AddNodeResult<TState, TNodeName, GetGenOut<TNodes[TNodeName]>>>;
|
|
11825
|
-
/**
|
|
11826
|
-
* Starts a conditional branch based on a predicate function.
|
|
11827
|
-
*
|
|
11828
|
-
* @param predicate - Function that takes state and returns a value to branch on
|
|
11829
|
-
* @returns this (for chaining)
|
|
11830
|
-
*
|
|
11831
|
-
* @example
|
|
11832
|
-
* ```typescript
|
|
11833
|
-
* flow.branch(state => state.qualityResult.needsMoreInfo)
|
|
11834
|
-
* .when(true)
|
|
11835
|
-
* .execute('queryGen', ...)
|
|
11836
|
-
* .when(false)
|
|
11837
|
-
* .execute('answer', ...)
|
|
11838
|
-
* .merge()
|
|
11839
|
-
* ```
|
|
11840
|
-
*/
|
|
11841
10113
|
branch(predicate: (_state: TState) => unknown): this;
|
|
11842
|
-
/**
|
|
11843
|
-
* Short alias for branch()
|
|
11844
|
-
*/
|
|
11845
10114
|
b(predicate: (_state: TState) => unknown): this;
|
|
11846
|
-
/**
|
|
11847
|
-
* Defines a branch case for the current branch context.
|
|
11848
|
-
*
|
|
11849
|
-
* @param value - The value to match against the branch predicate result
|
|
11850
|
-
* @returns this (for chaining)
|
|
11851
|
-
*/
|
|
11852
10115
|
when(value: unknown): this;
|
|
11853
|
-
/**
|
|
11854
|
-
* Short alias for when()
|
|
11855
|
-
*/
|
|
11856
10116
|
w(value: unknown): this;
|
|
11857
|
-
/**
|
|
11858
|
-
* Merges the results of conditional branches into a single execution path.
|
|
11859
|
-
*
|
|
11860
|
-
* This method is called after defining conditional branches with branch() and when() methods.
|
|
11861
|
-
* It creates a merge point where the flow continues with the results from whichever
|
|
11862
|
-
* branch was executed based on the branch condition.
|
|
11863
|
-
*
|
|
11864
|
-
* How conditional merging works:
|
|
11865
|
-
* 1. The branch predicate is evaluated against the current state
|
|
11866
|
-
* 2. The matching branch's steps are executed sequentially
|
|
11867
|
-
* 3. If no branch matches, the state is returned unchanged
|
|
11868
|
-
* 4. The merged result becomes the new state for subsequent steps
|
|
11869
|
-
*
|
|
11870
|
-
* Type safety note:
|
|
11871
|
-
* The TMergedState generic allows for type-level tracking of what fields
|
|
11872
|
-
* will be available after the merge, though runtime behavior depends on
|
|
11873
|
-
* which branch actually executes.
|
|
11874
|
-
*
|
|
11875
|
-
* @returns AxFlow with updated state type reflecting the merged result
|
|
11876
|
-
*
|
|
11877
|
-
* @example
|
|
11878
|
-
* ```typescript
|
|
11879
|
-
* flow
|
|
11880
|
-
* .branch(state => state.complexity > 0.5)
|
|
11881
|
-
* .when(true)
|
|
11882
|
-
* .execute('complexProcessor', state => ({ input: state.text }))
|
|
11883
|
-
* .when(false)
|
|
11884
|
-
* .execute('simpleProcessor', state => ({ input: state.text }))
|
|
11885
|
-
* .merge() // Combines results from either branch
|
|
11886
|
-
* ```
|
|
11887
|
-
*/
|
|
11888
10117
|
merge<TMergedState extends AxFlowState = TState>(): AxFlow<IN, OUT, TNodes, TMergedState>;
|
|
11889
|
-
/**
|
|
11890
|
-
* Short alias for merge()
|
|
11891
|
-
*/
|
|
11892
10118
|
mg<TMergedState extends AxFlowState = TState>(): AxFlow<IN, OUT, TNodes, TMergedState>;
|
|
11893
|
-
|
|
11894
|
-
* Executes multiple operations in parallel and provides a merge method for combining results.
|
|
11895
|
-
*
|
|
11896
|
-
* This method enables true parallel execution of independent operations, which is particularly
|
|
11897
|
-
* useful for operations like:
|
|
11898
|
-
* - Multiple document retrievals
|
|
11899
|
-
* - Parallel processing of different data sources
|
|
11900
|
-
* - Independent LLM calls that can run simultaneously
|
|
11901
|
-
*
|
|
11902
|
-
* How parallel execution works:
|
|
11903
|
-
* 1. Each branch function receives a sub-context for defining operations
|
|
11904
|
-
* 2. All branches are executed simultaneously using Promise.all()
|
|
11905
|
-
* 3. Results are stored in _parallelResults for the merge operation
|
|
11906
|
-
* 4. The merge function combines the results into a single field
|
|
11907
|
-
*
|
|
11908
|
-
* Performance benefits:
|
|
11909
|
-
* - Reduces total execution time for independent operations
|
|
11910
|
-
* - Maximizes throughput for I/O-bound operations (like LLM calls)
|
|
11911
|
-
* - Maintains type safety through the merge operation
|
|
11912
|
-
*
|
|
11913
|
-
* @param branches - Array of functions that define parallel operations
|
|
11914
|
-
* @returns Object with merge method for combining results
|
|
11915
|
-
*
|
|
11916
|
-
* @example
|
|
11917
|
-
* ```typescript
|
|
11918
|
-
* flow.parallel([
|
|
11919
|
-
* subFlow => subFlow.execute('retrieve1', state => ({ query: state.query1 })),
|
|
11920
|
-
* subFlow => subFlow.execute('retrieve2', state => ({ query: state.query2 })),
|
|
11921
|
-
* subFlow => subFlow.execute('retrieve3', state => ({ query: state.query3 }))
|
|
11922
|
-
* ]).merge('documents', (docs1, docs2, docs3) => [...docs1, ...docs2, ...docs3])
|
|
11923
|
-
* ```
|
|
11924
|
-
*/
|
|
11925
|
-
parallel(branches: (AxFlowParallelBranch | AxFlowTypedParallelBranch<TNodes, TState>)[]): {
|
|
10119
|
+
parallel(branches: AxFlowTypedParallelBranch<TNodes, TState>[]): {
|
|
11926
10120
|
merge<T, TResultKey extends string>(resultKey: TResultKey, mergeFunction: (..._results: unknown[]) => T): AxFlow<IN, OUT, TNodes, TState & {
|
|
11927
10121
|
[K in TResultKey]: T;
|
|
11928
10122
|
}>;
|
|
11929
10123
|
};
|
|
11930
|
-
|
|
11931
|
-
* Short alias for parallel()
|
|
11932
|
-
*/
|
|
11933
|
-
p(branches: (AxFlowParallelBranch | AxFlowTypedParallelBranch<TNodes, TState>)[]): {
|
|
10124
|
+
p(branches: AxFlowTypedParallelBranch<TNodes, TState>[]): {
|
|
11934
10125
|
merge<T, TResultKey extends string>(resultKey: TResultKey, mergeFunction: (..._results: unknown[]) => T): AxFlow<IN, OUT, TNodes, TState & {
|
|
11935
10126
|
[K in TResultKey]: T;
|
|
11936
10127
|
}>;
|
|
11937
10128
|
};
|
|
11938
|
-
/**
|
|
11939
|
-
* Creates a feedback loop that jumps back to a labeled step if a condition is met.
|
|
11940
|
-
*
|
|
11941
|
-
* @param condition - Function that returns true to trigger the feedback loop
|
|
11942
|
-
* @param targetLabel - The label to jump back to
|
|
11943
|
-
* @param maxIterations - Maximum number of iterations to prevent infinite loops (default: 10)
|
|
11944
|
-
* @returns this (for chaining)
|
|
11945
|
-
*
|
|
11946
|
-
* @example
|
|
11947
|
-
* ```typescript
|
|
11948
|
-
* flow.label('retry-point')
|
|
11949
|
-
* .execute('answer', ...)
|
|
11950
|
-
* .execute('qualityCheck', ...)
|
|
11951
|
-
* .feedback(state => state.qualityCheckResult.confidence < 0.7, 'retry-point')
|
|
11952
|
-
* ```
|
|
11953
|
-
*/
|
|
11954
10129
|
feedback(condition: (_state: TState) => boolean, targetLabel: string, maxIterations?: number): this;
|
|
11955
|
-
/**
|
|
11956
|
-
* Short alias for feedback()
|
|
11957
|
-
*/
|
|
11958
10130
|
fb(condition: (_state: TState) => boolean, targetLabel: string, maxIterations?: number): this;
|
|
11959
|
-
/**
|
|
11960
|
-
* Marks the beginning of a loop block.
|
|
11961
|
-
*
|
|
11962
|
-
* @param condition - Function that takes the current state and returns a boolean
|
|
11963
|
-
* @param maxIterations - Maximum number of iterations to prevent infinite loops (default: 100)
|
|
11964
|
-
* @returns this (for chaining)
|
|
11965
|
-
*
|
|
11966
|
-
* @example
|
|
11967
|
-
* ```typescript
|
|
11968
|
-
* flow.while(state => state.iterations < 3, 10)
|
|
11969
|
-
* .map(state => ({ ...state, iterations: (state.iterations || 0) + 1 }))
|
|
11970
|
-
* .endWhile()
|
|
11971
|
-
* ```
|
|
11972
|
-
*/
|
|
11973
10131
|
while(condition: (state: TState) => boolean, maxIterations?: number): this;
|
|
11974
|
-
/**
|
|
11975
|
-
* Short alias for while()
|
|
11976
|
-
*/
|
|
11977
10132
|
wh(condition: (_state: TState) => boolean, maxIterations?: number): this;
|
|
11978
|
-
/**
|
|
11979
|
-
* Marks the end of a loop block.
|
|
11980
|
-
*
|
|
11981
|
-
* @returns this (for chaining)
|
|
11982
|
-
*/
|
|
11983
10133
|
endWhile(): this;
|
|
11984
|
-
/**
|
|
11985
|
-
* Short alias for endWhile()
|
|
11986
|
-
*/
|
|
11987
10134
|
end(): this;
|
|
11988
|
-
/**
|
|
11989
|
-
* Derives a new field from an existing field by applying a transform function.
|
|
11990
|
-
*
|
|
11991
|
-
* If the input field contains an array, the transform function is applied to each
|
|
11992
|
-
* array element in parallel with batch size control. If the input field contains
|
|
11993
|
-
* a scalar value, the transform function is applied directly.
|
|
11994
|
-
*
|
|
11995
|
-
* @param outputFieldName - Name of the field to store the result
|
|
11996
|
-
* @param inputFieldName - Name of the existing field to transform
|
|
11997
|
-
* @param transformFn - Function to apply to each element (for arrays) or the value directly (for scalars)
|
|
11998
|
-
* @param options - Options including batch size for parallel processing
|
|
11999
|
-
* @returns this (for chaining)
|
|
12000
|
-
*
|
|
12001
|
-
* @example
|
|
12002
|
-
* ```typescript
|
|
12003
|
-
* // Parallel processing of array items
|
|
12004
|
-
* flow.derive('processedItems', 'items', (item, index) => processItem(item), { batchSize: 5 })
|
|
12005
|
-
*
|
|
12006
|
-
* // Direct transformation of scalar value
|
|
12007
|
-
* flow.derive('upperText', 'text', (text) => text.toUpperCase())
|
|
12008
|
-
* ```
|
|
12009
|
-
*/
|
|
12010
10135
|
derive<T>(outputFieldName: string, inputFieldName: string, transformFn: (value: any, index?: number, state?: TState) => T, options?: {
|
|
12011
10136
|
batchSize?: number;
|
|
12012
10137
|
}): this;
|
|
12013
|
-
/**
|
|
12014
|
-
* Gets execution plan information for debugging automatic parallelization
|
|
12015
|
-
*
|
|
12016
|
-
* @returns Object with execution plan details
|
|
12017
|
-
*/
|
|
12018
10138
|
getExecutionPlan(): {
|
|
12019
10139
|
totalSteps: number;
|
|
12020
10140
|
parallelGroups: number;
|
|
12021
10141
|
maxParallelism: number;
|
|
12022
10142
|
autoParallelEnabled: boolean;
|
|
12023
|
-
steps?:
|
|
12024
|
-
groups?:
|
|
10143
|
+
steps?: AxFlowExecutionPlanStep[];
|
|
10144
|
+
groups?: AxFlowExecutionPlanGroup[];
|
|
12025
10145
|
};
|
|
12026
10146
|
getSignature(): AxSignature;
|
|
12027
|
-
/**
|
|
12028
|
-
* Creates a new AxFlow node from an existing signature by extending it with additional fields.
|
|
12029
|
-
*
|
|
12030
|
-
* @param name - The name of the new node
|
|
12031
|
-
* @param baseSignature - The base signature to extend (string or AxSignature)
|
|
12032
|
-
* @param extensions - Object defining how to extend the signature
|
|
12033
|
-
* @returns New AxFlow instance with the extended node
|
|
12034
|
-
*
|
|
12035
|
-
* @example
|
|
12036
|
-
* ```typescript
|
|
12037
|
-
* // Create a chain-of-thought node
|
|
12038
|
-
* flow.nodeExtended('reasoner', 'question:string -> answer:string', {
|
|
12039
|
-
* prependOutputs: [
|
|
12040
|
-
* { name: 'reasoning', type: f.string('Step-by-step reasoning').internal() }
|
|
12041
|
-
* ]
|
|
12042
|
-
* })
|
|
12043
|
-
*
|
|
12044
|
-
* // Create a node with context and confidence
|
|
12045
|
-
* flow.nodeExtended('analyzer', 'input:string -> output:string', {
|
|
12046
|
-
* appendInputs: [{ name: 'context', type: f.string('Context').optional() }],
|
|
12047
|
-
* appendOutputs: [{ name: 'confidence', type: f.number('Confidence score') }]
|
|
12048
|
-
* })
|
|
12049
|
-
* ```
|
|
12050
|
-
*/
|
|
12051
10147
|
nodeExtended<TName extends string>(name: TName, baseSignature: string | AxSignature, extensions: {
|
|
12052
10148
|
prependInputs?: Array<{
|
|
12053
10149
|
name: string;
|
|
@@ -12068,9 +10164,6 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
12068
10164
|
}): AxFlow<IN, OUT, TNodes & {
|
|
12069
10165
|
[K in TName]: AxGen<AxGenIn, AxGenOut>;
|
|
12070
10166
|
}, TState>;
|
|
12071
|
-
/**
|
|
12072
|
-
* Short alias for nodeExtended() - creates nodes with extended signatures
|
|
12073
|
-
*/
|
|
12074
10167
|
nx<TName extends string>(name: TName, baseSignature: string | AxSignature, extensions: {
|
|
12075
10168
|
prependInputs?: Array<{
|
|
12076
10169
|
name: string;
|
|
@@ -12091,108 +10184,8 @@ TState extends AxFlowState = IN> implements AxFlowable<IN, OUT> {
|
|
|
12091
10184
|
}): AxFlow<IN, OUT, TNodes & {
|
|
12092
10185
|
[K in TName]: AxGen<AxGenIn, AxGenOut>;
|
|
12093
10186
|
}, TState>;
|
|
12094
|
-
/**
|
|
12095
|
-
* Applies a final transformation to the state object that updates both state and output type.
|
|
12096
|
-
* This is specifically designed for terminal transformations that shape the final output.
|
|
12097
|
-
*
|
|
12098
|
-
* @param transform - Function that takes the current state and returns the final output
|
|
12099
|
-
* @returns New AxFlow instance with updated OUT and TState types
|
|
12100
|
-
*
|
|
12101
|
-
* @example
|
|
12102
|
-
* ```
|
|
12103
|
-
* const result = await flow
|
|
12104
|
-
* .node('analyzer', 'userQuestion:string -> analysisResult:string')
|
|
12105
|
-
* .execute('analyzer', state => ({ userQuestion: state.userQuestion }))
|
|
12106
|
-
* .mapOutput(state => ({
|
|
12107
|
-
* // Note: Node results are typed as AxFieldValue, so you may need to cast
|
|
12108
|
-
* finalAnswer: state.analyzerResult.analysisResult as string
|
|
12109
|
-
* }))
|
|
12110
|
-
* .forward(ai, { userQuestion: 'test' });
|
|
12111
|
-
*
|
|
12112
|
-
* // result is typed as { finalAnswer: string }
|
|
12113
|
-
* ```
|
|
12114
|
-
*/
|
|
12115
|
-
mapOutput<TOutput>(transform: (_state: TState) => TOutput): AxFlow<IN, TOutput, TNodes, TOutput & TState>;
|
|
12116
|
-
/**
|
|
12117
|
-
* Short alias for mapOutput()
|
|
12118
|
-
*/
|
|
12119
|
-
mo<TOutput>(transform: (_state: TState) => TOutput): AxFlow<IN, TOutput, TNodes, TOutput & TState>;
|
|
12120
|
-
}
|
|
12121
|
-
/**
|
|
12122
|
-
* Factory function to create a new AxFlow instance
|
|
12123
|
-
* Similar to ai() for AI services, this creates a fluent flow
|
|
12124
|
-
*
|
|
12125
|
-
* @param options - Optional configuration for the flow
|
|
12126
|
-
* @returns New AxFlow instance
|
|
12127
|
-
*
|
|
12128
|
-
* @example
|
|
12129
|
-
* ```typescript
|
|
12130
|
-
* // Input type is required - provides type safety throughout the flow
|
|
12131
|
-
* const workflow = flow<{ userInput: string }>()
|
|
12132
|
-
* .node('summarizer', 'documentText:string -> summaryText:string')
|
|
12133
|
-
* .execute('summarizer', state => ({ documentText: state.userInput }));
|
|
12134
|
-
*
|
|
12135
|
-
* // Complex input types work great for multi-field workflows
|
|
12136
|
-
* const complexFlow = flow<{ userQuestion: string; context: string }>()
|
|
12137
|
-
* .map(state => ({
|
|
12138
|
-
* ...state,
|
|
12139
|
-
* processedQuestion: state.userQuestion.toUpperCase() // TypeScript knows this exists!
|
|
12140
|
-
* }));
|
|
12141
|
-
* ```
|
|
12142
|
-
*/
|
|
12143
|
-
/**
|
|
12144
|
-
* Creates a new AxFlow instance with required input type specification.
|
|
12145
|
-
*
|
|
12146
|
-
* The input type must be specified upfront to enable proper type inference
|
|
12147
|
-
* throughout the flow construction and execution.
|
|
12148
|
-
*
|
|
12149
|
-
* @example
|
|
12150
|
-
* ```typescript
|
|
12151
|
-
* // ✅ Define input type upfront for better type safety
|
|
12152
|
-
* const workflow = flow<{ userInput: string, options?: any }>()
|
|
12153
|
-
* .map(state => ({ ...state, processedInput: state.userInput.toUpperCase() }))
|
|
12154
|
-
* .node('analyzer', 'processedInput:string -> result:string')
|
|
12155
|
-
*
|
|
12156
|
-
* // ✅ Simple input types work too
|
|
12157
|
-
* const simpleFlow = flow<{ documentText: string }>()
|
|
12158
|
-
* .node('summarizer', 'documentText:string -> summary:string')
|
|
12159
|
-
* ```
|
|
12160
|
-
*/
|
|
12161
|
-
declare function flow<TInput extends Record<string, any>, TOutput = {}>(options?: {
|
|
12162
|
-
autoParallel?: boolean;
|
|
12163
|
-
batchSize?: number;
|
|
12164
|
-
logger?: AxFlowLoggerFunction;
|
|
12165
|
-
debug?: boolean;
|
|
12166
|
-
}): AxFlow<TInput, TOutput, {}, TInput>;
|
|
12167
|
-
|
|
12168
|
-
/**
|
|
12169
|
-
* Implementation of the sub-context for parallel execution
|
|
12170
|
-
*/
|
|
12171
|
-
declare class AxFlowSubContextImpl implements AxFlowSubContext {
|
|
12172
|
-
private readonly nodeGenerators;
|
|
12173
|
-
private readonly steps;
|
|
12174
|
-
constructor(nodeGenerators: Map<string, AxForwardable<AxGenIn, AxGenOut, string> & AxTunable<AxGenIn, AxGenOut> & AxUsable>);
|
|
12175
|
-
execute<TAI extends Readonly<AxAIService>>(nodeName: string, mapping: (state: AxFlowState) => Record<string, AxFieldValue>, dynamicContext?: AxFlowDynamicContext<TAI>): this;
|
|
12176
|
-
map(transform: (state: AxFlowState) => AxFlowState): this;
|
|
12177
|
-
executeSteps(initialState: AxFlowState, context: Readonly<{
|
|
12178
|
-
mainAi: AxAIService;
|
|
12179
|
-
mainOptions?: AxProgramForwardOptions<string>;
|
|
12180
|
-
}>): Promise<AxFlowState>;
|
|
12181
|
-
}
|
|
12182
|
-
/**
|
|
12183
|
-
* Typed implementation of the sub-context for parallel execution with full type safety
|
|
12184
|
-
*/
|
|
12185
|
-
declare class AxFlowTypedSubContextImpl<TNodes extends Record<string, AxGen<any, any>>, TState extends AxFlowState> implements AxFlowTypedSubContext<TNodes, TState> {
|
|
12186
|
-
private readonly nodeGenerators;
|
|
12187
|
-
private readonly steps;
|
|
12188
|
-
constructor(nodeGenerators: Map<string, AxGen<AxGenIn, AxGenOut> | AxProgram<AxGenIn, AxGenOut>>);
|
|
12189
|
-
execute<TNodeName extends keyof TNodes & string, TAI extends Readonly<AxAIService>>(nodeName: TNodeName, mapping: (state: TState) => GetGenIn<TNodes[TNodeName]>, dynamicContext?: AxFlowDynamicContext<TAI>): AxFlowTypedSubContext<TNodes, AddNodeResult<TState, TNodeName, GetGenOut<TNodes[TNodeName]>>>;
|
|
12190
|
-
map<TNewState extends AxFlowState>(transform: (state: TState) => TNewState): AxFlowTypedSubContext<TNodes, TNewState>;
|
|
12191
|
-
executeSteps(initialState: TState, context: Readonly<{
|
|
12192
|
-
mainAi: AxAIService;
|
|
12193
|
-
mainOptions?: AxProgramForwardOptions<string>;
|
|
12194
|
-
}>): Promise<AxFlowState>;
|
|
12195
10187
|
}
|
|
10188
|
+
declare function flow<TInput extends Record<string, any> = Record<string, unknown>, TOutput = {}>(options?: AxFlowOptions): AxFlow<TInput, TOutput, {}, TInput>;
|
|
12196
10189
|
|
|
12197
10190
|
interface AxDockerContainer {
|
|
12198
10191
|
Id: string;
|
|
@@ -12313,26 +10306,12 @@ declare class AxEmbeddingAdapter {
|
|
|
12313
10306
|
}
|
|
12314
10307
|
|
|
12315
10308
|
/**
|
|
12316
|
-
*
|
|
12317
|
-
*
|
|
12318
|
-
*
|
|
12319
|
-
|
|
12320
|
-
|
|
12321
|
-
fsRead?: readonly string[];
|
|
12322
|
-
fsWrite?: readonly string[];
|
|
12323
|
-
childProcess?: boolean;
|
|
12324
|
-
addons?: boolean;
|
|
12325
|
-
wasi?: boolean;
|
|
12326
|
-
}>;
|
|
12327
|
-
/**
|
|
12328
|
-
* Node worker_threads resource limits passthrough.
|
|
10309
|
+
* Host-side security configuration helpers for AxJSRuntime.
|
|
10310
|
+
*
|
|
10311
|
+
* This module intentionally contains no worker-session state. It normalizes the
|
|
10312
|
+
* public security options into runtime/worker flags used by jsRuntime.ts and
|
|
10313
|
+
* jsRuntimeWorkers.ts.
|
|
12329
10314
|
*/
|
|
12330
|
-
type AxJSRuntimeResourceLimits = Readonly<{
|
|
12331
|
-
maxOldGenerationSizeMb?: number;
|
|
12332
|
-
maxYoungGenerationSizeMb?: number;
|
|
12333
|
-
codeRangeSizeMb?: number;
|
|
12334
|
-
stackSizeMb?: number;
|
|
12335
|
-
}>;
|
|
12336
10315
|
/**
|
|
12337
10316
|
* Permissions that can be granted to the RLM JS interpreter sandbox.
|
|
12338
10317
|
* By default all dangerous globals are blocked; users opt in via this enum.
|
|
@@ -12360,6 +10339,28 @@ declare enum AxJSRuntimePermission {
|
|
|
12360
10339
|
/** node:child_process — gates --allow-child-process and Deno run */
|
|
12361
10340
|
CHILD_PROCESS = "child-process"
|
|
12362
10341
|
}
|
|
10342
|
+
/**
|
|
10343
|
+
* Fine-grained Node Permission Model allowlist. Scopes `--allow-fs-*` and
|
|
10344
|
+
* gates additional `--allow-*` flags that aren't covered by the high-level
|
|
10345
|
+
* permission enum.
|
|
10346
|
+
*/
|
|
10347
|
+
type AxJSRuntimeNodePermissionAllowlist = Readonly<{
|
|
10348
|
+
fsRead?: readonly string[];
|
|
10349
|
+
fsWrite?: readonly string[];
|
|
10350
|
+
childProcess?: boolean;
|
|
10351
|
+
addons?: boolean;
|
|
10352
|
+
wasi?: boolean;
|
|
10353
|
+
}>;
|
|
10354
|
+
/**
|
|
10355
|
+
* Node worker_threads resource limits passthrough.
|
|
10356
|
+
*/
|
|
10357
|
+
type AxJSRuntimeResourceLimits = Readonly<{
|
|
10358
|
+
maxOldGenerationSizeMb?: number;
|
|
10359
|
+
maxYoungGenerationSizeMb?: number;
|
|
10360
|
+
codeRangeSizeMb?: number;
|
|
10361
|
+
stackSizeMb?: number;
|
|
10362
|
+
}>;
|
|
10363
|
+
|
|
12363
10364
|
type AxJSRuntimeOutputMode = 'return' | 'stdout';
|
|
12364
10365
|
/**
|
|
12365
10366
|
* Browser-compatible JavaScript interpreter for RLM using Web Workers.
|
|
@@ -12414,7 +10415,9 @@ declare class AxJSRuntime implements AxCodeRuntime {
|
|
|
12414
10415
|
*/
|
|
12415
10416
|
blockDynamicImport?: boolean;
|
|
12416
10417
|
/**
|
|
12417
|
-
* Module specifier allowlist when `blockDynamicImport` is true.
|
|
10418
|
+
* Module specifier allowlist when `blockDynamicImport` is true. This is
|
|
10419
|
+
* a narrow dynamic-import gate: allowlisted specifiers are attempted, but
|
|
10420
|
+
* full Node module namespace passthrough depends on Node vm semantics.
|
|
12418
10421
|
* Default: [].
|
|
12419
10422
|
*/
|
|
12420
10423
|
allowedModules?: readonly string[];
|
|
@@ -12475,9 +10478,9 @@ declare class AxJSRuntime implements AxCodeRuntime {
|
|
|
12475
10478
|
* Computes Node execArgv for the Permission Model when it should engage,
|
|
12476
10479
|
* otherwise returns undefined.
|
|
12477
10480
|
*
|
|
12478
|
-
* - 'auto': engages on Node
|
|
12479
|
-
*
|
|
12480
|
-
* - true: engages unconditionally; hard-fails on Node <
|
|
10481
|
+
* - 'auto': engages unconditionally on supported Node versions; skips
|
|
10482
|
+
* silently where the Node Permission Model is unavailable.
|
|
10483
|
+
* - true: engages unconditionally; hard-fails on Node < 20.
|
|
12481
10484
|
* - false: never engages.
|
|
12482
10485
|
*/
|
|
12483
10486
|
private computeNodeExecArgv;
|
|
@@ -12841,342 +10844,37 @@ declare class AxMCPHTTPSSETransport implements AxMCPTransport {
|
|
|
12841
10844
|
close(): void;
|
|
12842
10845
|
}
|
|
12843
10846
|
|
|
12844
|
-
/**
|
|
12845
|
-
* Advanced Multi-hop RAG with iterative query refinement, context accumulation,
|
|
12846
|
-
* parallel sub-queries, and self-healing quality feedback loops
|
|
12847
|
-
*
|
|
12848
|
-
* @param queryFn - Function to execute search queries and return results
|
|
12849
|
-
* @param options - Configuration options
|
|
12850
|
-
* @returns AxFlow instance with advanced RAG capability
|
|
12851
|
-
*/
|
|
12852
|
-
declare const axRAG: (queryFn: (query: string) => Promise<string>, options?: {
|
|
12853
|
-
maxHops?: number;
|
|
12854
|
-
qualityThreshold?: number;
|
|
12855
|
-
maxIterations?: number;
|
|
12856
|
-
qualityTarget?: number;
|
|
12857
|
-
disableQualityHealing?: boolean;
|
|
12858
|
-
logger?: AxFlowLoggerFunction;
|
|
12859
|
-
debug?: boolean;
|
|
12860
|
-
}) => AxFlow<{
|
|
12861
|
-
originalQuestion: string;
|
|
12862
|
-
}, {
|
|
12863
|
-
finalAnswer: string;
|
|
12864
|
-
totalHops: number;
|
|
12865
|
-
retrievedContexts: string[];
|
|
12866
|
-
iterationCount: number;
|
|
12867
|
-
healingAttempts: number;
|
|
12868
|
-
qualityAchieved: number;
|
|
12869
|
-
}, {
|
|
12870
|
-
queryGenerator: InferAxGen<"originalQuestion:string, previousContext?:string -> searchQuery:string, queryReasoning:string">;
|
|
12871
|
-
} & {
|
|
12872
|
-
contextualizer: InferAxGen<"retrievedDocument:string, accumulatedContext?:string -> enhancedContext:string">;
|
|
12873
|
-
} & {
|
|
12874
|
-
qualityAssessor: InferAxGen<"currentContext:string, originalQuestion:string -> completenessScore:number, missingAspects:string[]">;
|
|
12875
|
-
} & {
|
|
12876
|
-
questionDecomposer: InferAxGen<"complexQuestion:string -> subQuestions:string[], decompositionReason:string">;
|
|
12877
|
-
} & {
|
|
12878
|
-
evidenceSynthesizer: InferAxGen<"collectedEvidence:string[], originalQuestion:string -> synthesizedEvidence:string, evidenceGaps:string[]">;
|
|
12879
|
-
} & {
|
|
12880
|
-
gapAnalyzer: InferAxGen<"synthesizedEvidence:string, evidenceGaps:string[], originalQuestion:string -> needsMoreInfo:boolean, focusedQueries:string[]">;
|
|
12881
|
-
} & {
|
|
12882
|
-
answerGenerator: InferAxGen<"finalContext:string, originalQuestion:string -> comprehensiveAnswer:string, confidenceLevel:number">;
|
|
12883
|
-
} & {
|
|
12884
|
-
queryRefiner: InferAxGen<"originalQuestion:string, currentContext:string, missingAspects:string[] -> refinedQuery:string">;
|
|
12885
|
-
} & {
|
|
12886
|
-
qualityValidator: InferAxGen<"generatedAnswer:string, userQuery:string -> qualityScore:number, issues:string[]">;
|
|
12887
|
-
} & {
|
|
12888
|
-
answerHealer: InferAxGen<"originalAnswer:string, healingDocument:string, issues?:string[] -> healedAnswer:string">;
|
|
12889
|
-
}, {
|
|
12890
|
-
currentAnswer: string;
|
|
12891
|
-
currentQuality: number;
|
|
12892
|
-
currentIssues: string[];
|
|
12893
|
-
shouldContinueHealing: boolean;
|
|
12894
|
-
healingResult: {
|
|
12895
|
-
healingDocument: string;
|
|
12896
|
-
};
|
|
12897
|
-
healingAttempts: number;
|
|
12898
|
-
allEvidence: string[];
|
|
12899
|
-
evidenceSources: string[];
|
|
12900
|
-
needsMoreInfo: boolean;
|
|
12901
|
-
synthesizedEvidence: string;
|
|
12902
|
-
retrievalResults: string[];
|
|
12903
|
-
currentQueries: string[];
|
|
12904
|
-
iteration: number;
|
|
12905
|
-
searchQuery: string;
|
|
12906
|
-
accumulatedContext: string;
|
|
12907
|
-
retrievedContexts: string[];
|
|
12908
|
-
completenessScore: number;
|
|
12909
|
-
shouldContinue: boolean;
|
|
12910
|
-
retrievalResult: {
|
|
12911
|
-
retrievedDocument: string;
|
|
12912
|
-
retrievalConfidence: number;
|
|
12913
|
-
};
|
|
12914
|
-
currentHop: number;
|
|
12915
|
-
maxHops: number;
|
|
12916
|
-
qualityThreshold: number;
|
|
12917
|
-
maxIterations: number;
|
|
12918
|
-
qualityTarget: number;
|
|
12919
|
-
disableQualityHealing: boolean;
|
|
12920
|
-
originalQuestion: string;
|
|
12921
|
-
queryGeneratorResult: BuildObject<[{
|
|
12922
|
-
name: "searchQuery";
|
|
12923
|
-
optional: false;
|
|
12924
|
-
internal: false;
|
|
12925
|
-
} & {
|
|
12926
|
-
type: "string";
|
|
12927
|
-
}, {
|
|
12928
|
-
name: "queryReasoning";
|
|
12929
|
-
optional: false;
|
|
12930
|
-
internal: false;
|
|
12931
|
-
} & {
|
|
12932
|
-
type: "string";
|
|
12933
|
-
}], "output">;
|
|
12934
|
-
contextualizerResult: BuildObject<[{
|
|
12935
|
-
name: "enhancedContext";
|
|
12936
|
-
optional: false;
|
|
12937
|
-
internal: false;
|
|
12938
|
-
} & {
|
|
12939
|
-
type: "string";
|
|
12940
|
-
}], "output">;
|
|
12941
|
-
qualityAssessorResult: BuildObject<[{
|
|
12942
|
-
name: "completenessScore";
|
|
12943
|
-
optional: false;
|
|
12944
|
-
internal: false;
|
|
12945
|
-
} & {
|
|
12946
|
-
type: "number";
|
|
12947
|
-
}, {
|
|
12948
|
-
name: "missingAspects";
|
|
12949
|
-
optional: false;
|
|
12950
|
-
internal: false;
|
|
12951
|
-
} & {
|
|
12952
|
-
type: "string[]";
|
|
12953
|
-
}], "output">;
|
|
12954
|
-
queryRefinerResult: BuildObject<[{
|
|
12955
|
-
name: "refinedQuery";
|
|
12956
|
-
optional: false;
|
|
12957
|
-
internal: false;
|
|
12958
|
-
} & {
|
|
12959
|
-
type: "string";
|
|
12960
|
-
}], "output">;
|
|
12961
|
-
questionDecomposerResult: BuildObject<[{
|
|
12962
|
-
name: "subQuestions";
|
|
12963
|
-
optional: false;
|
|
12964
|
-
internal: false;
|
|
12965
|
-
} & {
|
|
12966
|
-
type: "string[]";
|
|
12967
|
-
}, {
|
|
12968
|
-
name: "decompositionReason";
|
|
12969
|
-
optional: false;
|
|
12970
|
-
internal: false;
|
|
12971
|
-
} & {
|
|
12972
|
-
type: "string";
|
|
12973
|
-
}], "output">;
|
|
12974
|
-
evidenceSynthesizerResult: BuildObject<[{
|
|
12975
|
-
name: "synthesizedEvidence";
|
|
12976
|
-
optional: false;
|
|
12977
|
-
internal: false;
|
|
12978
|
-
} & {
|
|
12979
|
-
type: "string";
|
|
12980
|
-
}, {
|
|
12981
|
-
name: "evidenceGaps";
|
|
12982
|
-
optional: false;
|
|
12983
|
-
internal: false;
|
|
12984
|
-
} & {
|
|
12985
|
-
type: "string[]";
|
|
12986
|
-
}], "output">;
|
|
12987
|
-
gapAnalyzerResult: BuildObject<[{
|
|
12988
|
-
name: "needsMoreInfo";
|
|
12989
|
-
optional: false;
|
|
12990
|
-
internal: false;
|
|
12991
|
-
} & {
|
|
12992
|
-
type: "boolean";
|
|
12993
|
-
}, {
|
|
12994
|
-
name: "focusedQueries";
|
|
12995
|
-
optional: false;
|
|
12996
|
-
internal: false;
|
|
12997
|
-
} & {
|
|
12998
|
-
type: "string[]";
|
|
12999
|
-
}], "output">;
|
|
13000
|
-
answerGeneratorResult: BuildObject<[{
|
|
13001
|
-
name: "comprehensiveAnswer";
|
|
13002
|
-
optional: false;
|
|
13003
|
-
internal: false;
|
|
13004
|
-
} & {
|
|
13005
|
-
type: "string";
|
|
13006
|
-
}, {
|
|
13007
|
-
name: "confidenceLevel";
|
|
13008
|
-
optional: false;
|
|
13009
|
-
internal: false;
|
|
13010
|
-
} & {
|
|
13011
|
-
type: "number";
|
|
13012
|
-
}], "output">;
|
|
13013
|
-
qualityValidatorResult: BuildObject<[{
|
|
13014
|
-
name: "qualityScore";
|
|
13015
|
-
optional: false;
|
|
13016
|
-
internal: false;
|
|
13017
|
-
} & {
|
|
13018
|
-
type: "number";
|
|
13019
|
-
}, {
|
|
13020
|
-
name: "issues";
|
|
13021
|
-
optional: false;
|
|
13022
|
-
internal: false;
|
|
13023
|
-
} & {
|
|
13024
|
-
type: "string[]";
|
|
13025
|
-
}], "output">;
|
|
13026
|
-
answerHealerResult: BuildObject<[{
|
|
13027
|
-
name: "healedAnswer";
|
|
13028
|
-
optional: false;
|
|
13029
|
-
internal: false;
|
|
13030
|
-
} & {
|
|
13031
|
-
type: "string";
|
|
13032
|
-
}], "output">;
|
|
13033
|
-
}>;
|
|
13034
|
-
|
|
13035
|
-
/**
|
|
13036
|
-
* AxTraceLogger - Decorator that intercepts AxGen.forward() calls and logs traces.
|
|
13037
|
-
*
|
|
13038
|
-
* This provides a non-intrusive way to add logging to any AxGen instance
|
|
13039
|
-
* without modifying the original class.
|
|
13040
|
-
*/
|
|
13041
|
-
|
|
13042
|
-
/**
|
|
13043
|
-
* Configuration options for AxTraceLogger
|
|
13044
|
-
*/
|
|
13045
|
-
interface AxTraceLoggerOptions {
|
|
13046
|
-
/** Unique identifier for this agent/generator */
|
|
13047
|
-
name: string;
|
|
13048
|
-
/** Storage backend for persisting traces */
|
|
13049
|
-
storage: AxStorage;
|
|
13050
|
-
/** Whether to include input values in traces (default: true) */
|
|
13051
|
-
logInputs?: boolean;
|
|
13052
|
-
/** Whether to include output values in traces (default: true) */
|
|
13053
|
-
logOutputs?: boolean;
|
|
13054
|
-
/** Custom metadata to include in all traces */
|
|
13055
|
-
metadata?: Record<string, unknown>;
|
|
13056
|
-
/** Callback when a trace is logged */
|
|
13057
|
-
onTrace?: (trace: AxTrace) => void;
|
|
13058
|
-
/** Whether logging errors should throw (default: false - errors are silently caught) */
|
|
13059
|
-
throwOnError?: boolean;
|
|
13060
|
-
}
|
|
13061
|
-
/**
|
|
13062
|
-
* AxTraceLogger wraps an AxGen instance to automatically log all forward() calls.
|
|
13063
|
-
*
|
|
13064
|
-
* @example
|
|
13065
|
-
* ```typescript
|
|
13066
|
-
* const gen = ax(`query -> response`);
|
|
13067
|
-
* const storage = new AxMemoryStorage();
|
|
13068
|
-
*
|
|
13069
|
-
* const tracedGen = new AxTraceLogger(gen, {
|
|
13070
|
-
* agentId: 'my-agent',
|
|
13071
|
-
* storage,
|
|
13072
|
-
* });
|
|
13073
|
-
*
|
|
13074
|
-
* // Use exactly like AxGen
|
|
13075
|
-
* const result = await tracedGen.forward(ai, { query: 'Hello' });
|
|
13076
|
-
*
|
|
13077
|
-
* // Traces are automatically saved to storage
|
|
13078
|
-
* const traces = await storage.getTraces('my-agent');
|
|
13079
|
-
* ```
|
|
13080
|
-
*/
|
|
13081
|
-
declare class AxTraceLogger<IN extends AxGenIn, OUT extends AxGenOut> {
|
|
13082
|
-
private gen;
|
|
13083
|
-
private options;
|
|
13084
|
-
constructor(gen: AxGen<IN, OUT>, options: AxTraceLoggerOptions);
|
|
13085
|
-
/**
|
|
13086
|
-
* Streaming forward call to the underlying AxGen with trace logging.
|
|
13087
|
-
*/
|
|
13088
|
-
streamingForward(ai: AxAIService, values: IN, options?: Readonly<AxProgramForwardOptions<string>>): AxGenStreamingOut<OUT>;
|
|
13089
|
-
/**
|
|
13090
|
-
* Forward call to the underlying AxGen with trace logging.
|
|
13091
|
-
*/
|
|
13092
|
-
forward(ai: AxAIService, values: IN, options?: Readonly<AxProgramForwardOptions<string>>): Promise<OUT>;
|
|
13093
|
-
/**
|
|
13094
|
-
* Save trace to storage with error handling.
|
|
13095
|
-
*/
|
|
13096
|
-
private saveTrace;
|
|
13097
|
-
/**
|
|
13098
|
-
* Get the underlying AxGen instance.
|
|
13099
|
-
*/
|
|
13100
|
-
getGen(): AxGen<IN, OUT>;
|
|
13101
|
-
/**
|
|
13102
|
-
* Get the agent ID.
|
|
13103
|
-
*/
|
|
13104
|
-
getName(): string;
|
|
13105
|
-
/**
|
|
13106
|
-
* Get the storage backend.
|
|
13107
|
-
*/
|
|
13108
|
-
getStorage(): AxStorage;
|
|
13109
|
-
/**
|
|
13110
|
-
* Update the metadata for future traces.
|
|
13111
|
-
*/
|
|
13112
|
-
setMetadata(metadata: Record<string, unknown>): void;
|
|
13113
|
-
/**
|
|
13114
|
-
* Clone the logger with a new underlying AxGen.
|
|
13115
|
-
*/
|
|
13116
|
-
clone(newGen?: AxGen<IN, OUT>): AxTraceLogger<IN, OUT>;
|
|
13117
|
-
}
|
|
13118
|
-
|
|
13119
10847
|
declare const axSpanAttributes: {
|
|
13120
|
-
LLM_SYSTEM:
|
|
13121
|
-
LLM_OPERATION_NAME:
|
|
13122
|
-
LLM_REQUEST_MODEL:
|
|
13123
|
-
LLM_REQUEST_MAX_TOKENS:
|
|
13124
|
-
LLM_REQUEST_TEMPERATURE:
|
|
13125
|
-
LLM_REQUEST_TOP_K:
|
|
13126
|
-
LLM_REQUEST_FREQUENCY_PENALTY:
|
|
13127
|
-
LLM_REQUEST_PRESENCE_PENALTY:
|
|
13128
|
-
LLM_REQUEST_STOP_SEQUENCES:
|
|
13129
|
-
LLM_REQUEST_LLM_IS_STREAMING:
|
|
13130
|
-
LLM_REQUEST_TOP_P:
|
|
13131
|
-
LLM_RESPONSE_ID:
|
|
13132
|
-
LLM_RESPONSE_MODEL:
|
|
13133
|
-
LLM_CONVERSATION_ID:
|
|
13134
|
-
LLM_USAGE_INPUT_TOKENS:
|
|
13135
|
-
LLM_USAGE_OUTPUT_TOKENS:
|
|
13136
|
-
LLM_USAGE_TOTAL_TOKENS:
|
|
13137
|
-
LLM_USAGE_THOUGHTS_TOKENS:
|
|
13138
|
-
AX_SESSION_ID:
|
|
13139
|
-
AX_PROVIDER_REQUEST_ID:
|
|
13140
|
-
AX_PROVIDER_SESSION_ID:
|
|
13141
|
-
DB_SYSTEM: string;
|
|
13142
|
-
DB_TABLE: string;
|
|
13143
|
-
DB_NAMESPACE: string;
|
|
13144
|
-
DB_ID: string;
|
|
13145
|
-
DB_QUERY_TEXT: string;
|
|
13146
|
-
DB_VECTOR: string;
|
|
13147
|
-
DB_OPERATION_NAME: string;
|
|
13148
|
-
DB_VECTOR_QUERY_TOP_K: string;
|
|
13149
|
-
DB_QUERY_EMBEDDINGS: string;
|
|
13150
|
-
DB_QUERY_RESULT: string;
|
|
13151
|
-
DB_QUERY_EMBEDDINGS_VECTOR: string;
|
|
13152
|
-
DB_QUERY_RESULT_ID: string;
|
|
13153
|
-
DB_QUERY_RESULT_SCORE: string;
|
|
13154
|
-
DB_QUERY_RESULT_DISTANCE: string;
|
|
13155
|
-
DB_QUERY_RESULT_METADATA: string;
|
|
13156
|
-
DB_QUERY_RESULT_VECTOR: string;
|
|
13157
|
-
DB_QUERY_RESULT_DOCUMENT: string;
|
|
10848
|
+
readonly LLM_SYSTEM: "gen_ai.system";
|
|
10849
|
+
readonly LLM_OPERATION_NAME: "gen_ai.operation.name";
|
|
10850
|
+
readonly LLM_REQUEST_MODEL: "gen_ai.request.model";
|
|
10851
|
+
readonly LLM_REQUEST_MAX_TOKENS: "gen_ai.request.max_tokens";
|
|
10852
|
+
readonly LLM_REQUEST_TEMPERATURE: "gen_ai.request.temperature";
|
|
10853
|
+
readonly LLM_REQUEST_TOP_K: "gen_ai.request.top_k";
|
|
10854
|
+
readonly LLM_REQUEST_FREQUENCY_PENALTY: "gen_ai.request.frequency_penalty";
|
|
10855
|
+
readonly LLM_REQUEST_PRESENCE_PENALTY: "gen_ai.request.presence_penalty";
|
|
10856
|
+
readonly LLM_REQUEST_STOP_SEQUENCES: "gen_ai.request.stop_sequences";
|
|
10857
|
+
readonly LLM_REQUEST_LLM_IS_STREAMING: "gen_ai.request.llm_is_streaming";
|
|
10858
|
+
readonly LLM_REQUEST_TOP_P: "gen_ai.request.top_p";
|
|
10859
|
+
readonly LLM_RESPONSE_ID: "gen_ai.response.id";
|
|
10860
|
+
readonly LLM_RESPONSE_MODEL: "gen_ai.response.model";
|
|
10861
|
+
readonly LLM_CONVERSATION_ID: "gen_ai.conversation.id";
|
|
10862
|
+
readonly LLM_USAGE_INPUT_TOKENS: "gen_ai.usage.input_tokens";
|
|
10863
|
+
readonly LLM_USAGE_OUTPUT_TOKENS: "gen_ai.usage.output_tokens";
|
|
10864
|
+
readonly LLM_USAGE_TOTAL_TOKENS: "gen_ai.usage.total_tokens";
|
|
10865
|
+
readonly LLM_USAGE_THOUGHTS_TOKENS: "gen_ai.usage.thoughts_tokens";
|
|
10866
|
+
readonly AX_SESSION_ID: "ax.session.id";
|
|
10867
|
+
readonly AX_PROVIDER_REQUEST_ID: "ax.provider.request_id";
|
|
10868
|
+
readonly AX_PROVIDER_SESSION_ID: "ax.provider.session_id";
|
|
13158
10869
|
};
|
|
13159
10870
|
declare const axSpanEvents: {
|
|
13160
|
-
GEN_AI_USER_MESSAGE:
|
|
13161
|
-
GEN_AI_SYSTEM_MESSAGE:
|
|
13162
|
-
GEN_AI_ASSISTANT_MESSAGE:
|
|
13163
|
-
GEN_AI_TOOL_MESSAGE:
|
|
13164
|
-
GEN_AI_CHOICE:
|
|
13165
|
-
GEN_AI_USAGE:
|
|
13166
|
-
};
|
|
13167
|
-
declare enum AxLLMRequestTypeValues {
|
|
13168
|
-
COMPLETION = "completion",
|
|
13169
|
-
CHAT = "chat",
|
|
13170
|
-
RERANK = "rerank",
|
|
13171
|
-
UNKNOWN = "unknown"
|
|
13172
|
-
}
|
|
13173
|
-
declare enum AxSpanKindValues {
|
|
13174
|
-
WORKFLOW = "workflow",
|
|
13175
|
-
TASK = "task",
|
|
13176
|
-
AGENT = "agent",
|
|
13177
|
-
TOOL = "tool",
|
|
13178
|
-
UNKNOWN = "unknown"
|
|
13179
|
-
}
|
|
10871
|
+
readonly GEN_AI_USER_MESSAGE: "gen_ai.user.message";
|
|
10872
|
+
readonly GEN_AI_SYSTEM_MESSAGE: "gen_ai.system.message";
|
|
10873
|
+
readonly GEN_AI_ASSISTANT_MESSAGE: "gen_ai.assistant.message";
|
|
10874
|
+
readonly GEN_AI_TOOL_MESSAGE: "gen_ai.tool.message";
|
|
10875
|
+
readonly GEN_AI_CHOICE: "gen_ai.choice";
|
|
10876
|
+
readonly GEN_AI_USAGE: "gen_ai.usage";
|
|
10877
|
+
};
|
|
13180
10878
|
|
|
13181
10879
|
interface AxRateLimiterTokenUsageOptions {
|
|
13182
10880
|
debug?: boolean;
|
|
@@ -13193,4 +10891,4 @@ declare class AxRateLimiterTokenUsage {
|
|
|
13193
10891
|
acquire(tokens: number): Promise<void>;
|
|
13194
10892
|
}
|
|
13195
10893
|
|
|
13196
|
-
export { AxACE, type AxACEBullet, type AxACECuratorOperation, type AxACECuratorOperationType, type AxACECuratorOutput, type AxACEFeedbackEvent, type AxACEGeneratorOutput, type AxACEOptimizationArtifact, AxACEOptimizedProgram, type AxACEOptions, type AxACEPlaybook, type AxACEReflectionOutput, type AxACEResult, AxAI, AxAIAnthropic, type AxAIAnthropicArgs, type AxAIAnthropicChatError, type AxAIAnthropicChatRequest, type AxAIAnthropicChatRequestCacheParam, type AxAIAnthropicChatResponse, type AxAIAnthropicChatResponseDelta, type AxAIAnthropicConfig, type AxAIAnthropicContentBlockDeltaEvent, type AxAIAnthropicContentBlockStartEvent, type AxAIAnthropicContentBlockStopEvent, type AxAIAnthropicEffortLevel, type AxAIAnthropicEffortLevelMapping, type AxAIAnthropicErrorEvent, type AxAIAnthropicFunctionTool, type AxAIAnthropicMessageDeltaEvent, type AxAIAnthropicMessageStartEvent, type AxAIAnthropicMessageStopEvent, AxAIAnthropicModel, type AxAIAnthropicOutputConfig, type AxAIAnthropicPingEvent, type AxAIAnthropicRequestTool, type AxAIAnthropicThinkingConfig, type AxAIAnthropicThinkingTokenBudgetLevels, type AxAIAnthropicThinkingWire, AxAIAnthropicVertexModel, type AxAIAnthropicWebSearchTool, 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 AxAIGoogleGeminiCacheCreateRequest, type AxAIGoogleGeminiCacheResponse, type AxAIGoogleGeminiCacheUpdateRequest, type AxAIGoogleGeminiChatRequest, type AxAIGoogleGeminiChatResponse, type AxAIGoogleGeminiChatResponseDelta, type AxAIGoogleGeminiConfig, type AxAIGoogleGeminiContent, type AxAIGoogleGeminiContentPart, AxAIGoogleGeminiEmbedModel, AxAIGoogleGeminiEmbedTypes, type AxAIGoogleGeminiGenerationConfig, AxAIGoogleGeminiModel, type AxAIGoogleGeminiOptionsTools, type AxAIGoogleGeminiRetrievalConfig, AxAIGoogleGeminiSafetyCategory, type AxAIGoogleGeminiSafetySettings, AxAIGoogleGeminiSafetyThreshold, type AxAIGoogleGeminiThinkingConfig, type AxAIGoogleGeminiThinkingLevel, type AxAIGoogleGeminiThinkingLevelMapping, type AxAIGoogleGeminiThinkingTokenBudgetLevels, type AxAIGoogleGeminiTool, type AxAIGoogleGeminiToolConfig, type AxAIGoogleGeminiToolFunctionDeclaration, type AxAIGoogleGeminiToolGoogleMaps, 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 AxAIModelCatalogAudioSupport, type AxAIModelCatalogFilter, type AxAIModelCatalogModel, type AxAIModelCatalogModelCapabilities, type AxAIModelCatalogModelType, type AxAIModelCatalogOptions, type AxAIModelCatalogProvider, type AxAIModelCatalogProviderName, 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, AxAIOpenRouter, type AxAIOpenRouterArgs, AxAIRefusalError, AxAIReka, type AxAIRekaArgs, type AxAIRekaChatRequest, type AxAIRekaChatResponse, type AxAIRekaChatResponseDelta, type AxAIRekaConfig, AxAIRekaModel, type AxAIRekaUsage, type AxAIService, AxAIServiceAbortedError, type AxAIServiceActionOptions, AxAIServiceAuthenticationError, AxAIServiceError, type AxAIServiceImpl, type AxAIServiceMetrics, type AxAIServiceModelType, AxAIServiceNetworkError, type AxAIServiceOptions, AxAIServiceResponseError, AxAIServiceStatusError, AxAIServiceStreamTerminatedError, AxAIServiceTimeoutError, AxAITogether, type AxAITogetherArgs, type AxAITogetherChatModel, AxAITogetherModel, AxAIWebLLM, type AxAIWebLLMArgs, type AxAIWebLLMChatRequest, type AxAIWebLLMChatResponse, type AxAIWebLLMChatResponseDelta, type AxAIWebLLMConfig, type AxAIWebLLMEmbedModel, type AxAIWebLLMEmbedRequest, type AxAIWebLLMEmbedResponse, AxAIWebLLMModel, type AxAPI, type AxAPIConfig, type AxAPIResponseMetadata, AxAgent, type AxAgentActorTurnCallback, type AxAgentActorTurnCallbackArgs, type AxAgentClarification, type AxAgentClarificationChoice, AxAgentClarificationError, type AxAgentClarificationKind, type AxAgentCompletionProtocol, type AxAgentConfig, type AxAgentContextEvent, AxAgentContextMap, type AxAgentContextMapConfig, type AxAgentContextMapOperation, type AxAgentContextMapOptions, type AxAgentContextMapSnapshot, type AxAgentContextMapUpdateResult, type AxAgentContextPressure, type AxAgentContextStage, type AxAgentDemos, type AxAgentDiscoveryPromptState, type AxAgentEvalDataset, type AxAgentEvalFunctionCall, type AxAgentEvalPrediction, type AxAgentEvalTask, type AxAgentExecutorResultPayload, type AxAgentExecutorTurnCallback, type AxAgentExecutorTurnCallbackArgs, type AxAgentForwardOptions, type AxAgentFunction, type AxAgentFunctionCall, type AxAgentFunctionCallRecorder, type AxAgentFunctionCollection, type AxAgentFunctionExample, type AxAgentFunctionGroup, type AxAgentFunctionModuleMeta, type AxAgentGuidanceLogEntry, type AxAgentGuidancePayload, type AxAgentGuidanceState, type AxAgentIdentity, type AxAgentInputUpdateCallback, type AxAgentInternalCompletionPayload, type AxAgentJudgeEvalInput, type AxAgentJudgeEvalOutput, type AxAgentJudgeInput, type AxAgentJudgeOptions, type AxAgentJudgeOutput, type AxAgentMemoriesSearchFn, type AxAgentMemoryEntry, type AxAgentMemoryResult, type AxAgentOnContextEvent, type AxAgentOnFunctionCall, type AxAgentOptimizationTargetDescriptor, type AxAgentOptimizeOptions, type AxAgentOptimizeResult, type AxAgentOptimizeTarget, type AxAgentOptions, AxAgentProtocolCompletionSignal, type AxAgentRecursionOptions, type AxAgentRecursiveExpensiveNode, type AxAgentRecursiveFunctionCall, type AxAgentRecursiveNodeRole, type AxAgentRecursiveStats, type AxAgentRecursiveTargetId, type AxAgentRecursiveTraceNode, type AxAgentRecursiveTurn, type AxAgentRecursiveUsage, type AxAgentRuntimeCompletionState, type AxAgentRuntimeExecutionContext, type AxAgentRuntimeInputState, type AxAgentSkillResult, type AxAgentSkillsPromptState, type AxAgentSkillsSearchFn, type AxAgentState, type AxAgentStateActionLogEntry, type AxAgentStateCheckpointState, type AxAgentStateExecutorModelState, type AxAgentStateRuntimeEntry, type AxAgentStreamingForwardOptions, type AxAgentStructuredClarification, type AxAgentTestCompletionPayload, type AxAgentTestResult, type AxAgentUsage, type AxAgentUsedMemoriesCallback, type AxAgentUsedMemory, type AxAgentUsedSkill, type AxAgentUsedSkillsCallback, type AxAgentic, type AxAnyAgentic, AxApacheTika, type AxApacheTikaArgs, type AxApacheTikaConvertOptions, type AxAssertion, AxAssertionError, type AxAudioFormat, type AxAudioInput, AxBalancer, type AxBalancerOptions, AxBaseAI, type AxBaseAIArgs, AxBaseOptimizer, AxBootstrapFewShot, type AxBootstrapOptimizerOptions, type AxChatAudioConfig, type AxChatAudioOutput, type AxChatLogEntry, type AxChatLogMessage, type AxChatRequest, type AxChatResponse, type AxChatResponseFunctionCall, type AxChatResponseResult, type AxCheckpoint, type AxCheckpointLoadFn, type AxCheckpointSaveFn, type AxCitation, type AxCodeInterpreter, type AxCodeRuntime, type AxCodeSession, type AxCodeSessionSnapshot, type AxCodeSessionSnapshotEntry, type AxCompileOptions, AxContentProcessingError, type AxContentProcessingServices, type AxContextCacheInfo, type AxContextCacheOperation, type AxContextCacheOptions, type AxContextCacheRegistry, type AxContextCacheRegistryEntry, type AxContextFieldInput, type AxContextFieldPromptConfig, type AxContextPolicyBudget, type AxContextPolicyConfig, type AxContextPolicyPreset, 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, type AxDateRange, type AxDateRangeValue, type AxDebugChatResponseUsage, AxDefaultCostTracker, AxDefaultResultReranker, type AxDiscoveryTurnSummary, type AxDockerContainer, AxDockerSession, type AxEmbedRequest, type AxEmbedResponse, AxEmbeddingAdapter, type AxErrorCategory, AxEvalUtil, type AxEvaluateArgs, type AxExample, type AxExamples, type AxExecutorModelPolicy, type AxExecutorModelPolicyEntry, type AxField, type AxFieldOptions, type AxFieldProcessor, type AxFieldProcessorProcess, type AxFieldTemplateFn, type AxFieldType, type AxFieldValue, AxFlow, type AxFlowAutoParallelConfig, type AxFlowBranchContext, type AxFlowBranchEvaluationData, type AxFlowCompleteData, AxFlowDependencyAnalyzer, type AxFlowDynamicContext, type AxFlowErrorData, AxFlowExecutionPlanner, type AxFlowExecutionStep, type AxFlowLogData, type AxFlowLoggerData, type AxFlowLoggerFunction, type AxFlowNodeDefinition, type AxFlowParallelBranch, type AxFlowParallelGroup, type AxFlowParallelGroupCompleteData, type AxFlowParallelGroupStartData, type AxFlowStartData, type AxFlowState, type AxFlowStepCompleteData, type AxFlowStepFunction, type AxFlowStepStartData, type AxFlowSubContext, AxFlowSubContextImpl, type AxFlowTypedParallelBranch, type AxFlowTypedSubContext, AxFlowTypedSubContextImpl, type AxFlowable, type AxFluentFieldInfo, AxFluentFieldType, type AxForwardable, type AxFunction, type AxFunctionCallRecord, type AxFunctionCallTrace, AxFunctionError, type AxFunctionHandler, type AxFunctionJSONSchema, AxFunctionProcessor, type AxFunctionResult, type AxFunctionResultFormatter, AxGEPA, type AxGEPAAdapter, type AxGEPABatchEvaluation, type AxGEPABatchRow, type AxGEPABootstrapOptions, type AxGEPAComponentBanditState, AxGEPAComponentSelector, type AxGEPAComponentTarget, type AxGEPAEvaluationBatch, type AxGEPAEvaluationState, type AxGEPAOptimizationReport, type AxGEPAReflectiveTuple, type AxGEPATraceSummary, type AxGEPATraceSummaryCall, AxGen, type AxGenDeltaOut, type AxGenIn, type AxGenInput, type AxGenMetricsInstruments, type AxGenOut, type AxGenOutput, type AxGenStreamingOut, AxGenerateError, type AxGenerateErrorDetails, type AxGenerateResult, AxHFDataLoader, type AxIField, type AxInputFunctionType, AxInstanceRegistry, type AxInternalChatRequest, type AxInternalEmbedRequest, type AxInternalSpeechRequest, type AxInternalTranscriptionRequest, AxJSRuntime, type AxJSRuntimeNodePermissionAllowlist, type AxJSRuntimeOutputMode, AxJSRuntimePermission, type AxJSRuntimeResourceLimits, type AxJudgeForwardOptions, type AxJudgeOptions, AxLLMRequestTypeValues, AxLearn, type AxLearnArtifact, type AxLearnCheckpointMode, type AxLearnCheckpointState, type AxLearnContinuousOptions, type AxLearnMode, type AxLearnOptimizeOptions, type AxLearnOptions, type AxLearnPlaybook, type AxLearnPlaybookOptions, type AxLearnPlaybookSummary, type AxLearnProgress, type AxLearnResult, type AxLearnUpdateFeedback, type AxLearnUpdateInput, type AxLearnUpdateOptions, type AxLlmQueryBudgetState, type AxLlmQueryPromptMode, type AxLoggerData, type AxLoggerFunction, type AxMCPBlobResourceContents, AxMCPClient, type AxMCPEmbeddedResource, type AxMCPFunctionDescription, AxMCPHTTPSSETransport, type AxMCPImageContent, type AxMCPInitializeParams, type AxMCPInitializeResult, type AxMCPJSONRPCErrorResponse, type AxMCPJSONRPCNotification, type AxMCPJSONRPCRequest, type AxMCPJSONRPCResponse, type AxMCPJSONRPCSuccessResponse, type AxMCPOAuthOptions, type AxMCPPrompt, type AxMCPPromptArgument, type AxMCPPromptGetResult, type AxMCPPromptMessage, type AxMCPPromptsListResult, type AxMCPResource, type AxMCPResourceReadResult, type AxMCPResourceTemplate, type AxMCPResourceTemplatesListResult, type AxMCPResourcesListResult, type AxMCPStreamableHTTPTransportOptions, AxMCPStreambleHTTPTransport, type AxMCPTextContent, type AxMCPTextResourceContents, type AxMCPToolsListResult, type AxMCPTransport, AxMediaNotSupportedError, AxMemory, type AxMemoryData, type AxMemoryMessageValue, type AxMetricFn, type AxMetricFnArgs, type AxMetricsConfig, AxMockAIService, type AxMockAIServiceConfig, type AxModelConfig, type AxModelInfo, type AxModelInfoWithProvider, type AxModelUsage, type AxMultiMetricFn, type AxMultiProviderConfig, AxMultiServiceRouter, type AxMutableDiscoveryPromptState, type AxMutableSkillsPromptState, type AxNamedProgramInstance, type AxNormalizedAgentEvalDataset, type AxOptimizableComponent, type AxOptimizableValidator, type AxOptimizationCheckpoint, type AxOptimizationProgress, type AxOptimizationStats, type AxOptimizedProgram, AxOptimizedProgramImpl, type AxOptimizer, type AxOptimizerArgs, type AxOptimizerLoggerData, type AxOptimizerLoggerFunction, type AxOptimizerMetricsConfig, type AxOptimizerMetricsInstruments, type AxOptimizerResult, type AxParetoResult, type AxPreparedChatRequest, type AxPreparedRestoredState, AxProgram, type AxProgramDemos, type AxProgramExamples, type AxProgramForwardOptions, type AxProgramForwardOptionsWithModels, type AxProgramOptions, type AxProgramStreamingForwardOptions, type AxProgramStreamingForwardOptionsWithModels, type AxProgramTrace, type AxProgramUsage, type AxProgrammable, type AxPromptMetrics, AxPromptTemplate, type AxPromptTemplateOptions, type AxProviderMetadata, AxProviderRouter, type AxRLMConfig, type AxRateLimiterFunction, AxRateLimiterTokenUsage, type AxRateLimiterTokenUsageOptions, type AxRenderedPrompt, type AxRerankerIn, type AxRerankerOut, type AxResolvedContextPolicy, type AxResolvedExecutorModelPolicy, type AxResolvedExecutorModelPolicyEntry, type AxResponseHandlerArgs, type AxResultPickerFunction, type AxResultPickerFunctionFieldResults, type AxResultPickerFunctionFunctionResults, type AxRewriteIn, type AxRewriteOut, type AxRolloutTrace, type AxRoutingResult, type AxRuntimePrimitive, type AxRuntimePrimitiveExample, type AxRuntimePrimitiveSignature, type AxRuntimePrimitiveStage, type AxSamplePickerOptions, type AxSelfTuningConfig, type AxSerializedOptimizedProgram, type AxSetExamplesOptions, AxSignature, AxSignatureBuilder, type AxSignatureConfig, AxSimpleClassifier, AxSimpleClassifierClass, type AxSimpleClassifierForwardOptions, AxSpanKindValues, type AxSpeechConfig, type AxSpeechRequest, type AxSpeechResponse, type AxStageDefinitionBuildOptions, type AxStageOptions, type AxStepContext, AxStepContextImpl, type AxStepHooks, type AxStepUsage, AxStopFunctionCallException, type AxStorage, type AxStorageQuery, type AxStreamingAssertion, type AxStreamingEvent, type AxStreamingFieldProcessorProcess, AxStringUtil, AxSynth, type AxSynthExample, type AxSynthOptions, type AxSynthResult, type AxSynthesizerInit, type AxSynthesizerOptions, type AxSynthesizerRole, AxTestPrompt, type AxThoughtBlockItem, AxTokenLimitError, type AxTokenUsage, type AxTrace, AxTraceLogger, type AxTraceLoggerOptions, type AxTranscriptionRequest, type AxTranscriptionResponse, type AxTranscriptionSegment, type AxTunable, type AxTypedExample, type AxUsable, type AxWorkerRuntimeConfig, agent, ai, ax, axAIAnthropicDefaultConfig, axAIAnthropicVertexDefaultConfig, axAIAzureOpenAIBestConfig, axAIAzureOpenAICreativeConfig, axAIAzureOpenAIDefaultConfig, axAIAzureOpenAIFastConfig, axAICohereCreativeConfig, axAICohereDefaultConfig, axAIDeepSeekCodeConfig, axAIDeepSeekDefaultConfig, axAIGoogleGeminiDefaultConfig, axAIGoogleGeminiDefaultCreativeConfig, axAIGoogleGeminiLiveAudioDefaultConfig, axAIGrokBestConfig, axAIGrokDefaultConfig, axAIGrokVoiceDefaultConfig, axAIHuggingFaceCreativeConfig, axAIHuggingFaceDefaultConfig, axAIMistralBestConfig, axAIMistralDefaultConfig, axAIOllamaDefaultConfig, axAIOllamaDefaultCreativeConfig, axAIOpenAIAudioDefaultConfig, axAIOpenAIBestConfig, axAIOpenAICreativeConfig, axAIOpenAIDefaultConfig, axAIOpenAIFastConfig, axAIOpenAIRealtimeDefaultConfig, axAIOpenAIRealtimeTranscriptionDefaultConfig, axAIOpenAIResponsesBestConfig, axAIOpenAIResponsesCreativeConfig, axAIOpenAIResponsesDefaultConfig, axAIOpenRouterDefaultConfig, axAIRekaBestConfig, axAIRekaCreativeConfig, axAIRekaDefaultConfig, axAIRekaFastConfig, axAITogetherDefaultConfig, axAIWebLLMCreativeConfig, axAIWebLLMDefaultConfig, axAnalyzeChatPromptRequirements, axAnalyzeRequestRequirements, axApplyOpenAIChatAudioRequest, axAudioFormatFromMimeType, axAudioInputFilename, axAudioInputToBlob, axAudioMimeType, axBaseAIDefaultConfig, axBaseAIDefaultCreativeConfig, axBuildDistillerDefinition, axBuildExecutorDefinition, axBuildResponderDefinition, axCheckMetricsHealth, axConcatBase64, axCreateDefaultColorLogger, axCreateDefaultOptimizerColorLogger, axCreateDefaultOptimizerTextLogger, axCreateDefaultTextLogger, axCreateFlowColorLogger, axCreateFlowTextLogger, axCreateGeminiLiveAudioApi, axCreateGrokRealtimeApi, axCreateJSRuntime, axCreateOpenAIRealtimeApi, axDefaultFlowLogger, axDefaultMetricsConfig, axDefaultOptimizerLogger, axDefaultOptimizerMetricsConfig, axDeserializeOptimizedProgram, axFetchJsonSpeech, axFetchMultipartTranscription, axGetCompatibilityReport, axGetFormatCompatibility, axGetMetricsConfig, axGetOptimizerMetricsConfig, axGetProvidersWithMediaSupport, axGetSupportedAIModels, axGlobals, axGoogleGeminiLiveAudioDefaults, axIsAudioOutputEnabled, axIsGeminiLiveAudioModel, axIsGrokVoiceModel, axIsOpenAIChatAudioModel, axIsOpenAIRealtimeModel, axIsOpenAIRealtimeTranscriptionModel, axMapGeminiLiveAudioPart, axMapOpenAIChatAudioDelta, axMapOpenAIChatAudioResponse, axMapOpenAIInputAudioPart, axMergeChatAudioConfig, axModelInfoAnthropic, axModelInfoCohere, axModelInfoDeepSeek, axModelInfoGoogleGemini, axModelInfoGrok, axModelInfoGroq, axModelInfoHuggingFace, axModelInfoMistral, axModelInfoOpenAI, axModelInfoOpenAIResponses, axModelInfoReka, axModelInfoTogether, axModelInfoWebLLM, axNormalizeOpenAIUsage, axNormalizeTranscriptionResponse, axOpenAIChatAudioDefaults, axOptimizableValidators, axProcessContentForProvider, axRAG, axResolveGeminiLiveAudioConfig, axResolveGrokRealtimeAudioConfig, axResolveOpenAIChatAudioConfig, axResolveOpenAIRealtimeAudioConfig, axRuntimePrimitives, axScoreProvidersForRequest, axSelectOptimalProvider, axSerializeOptimizedProgram, axShouldUseGeminiLiveAudio, axShouldUseGrokRealtime, axShouldUseOpenAIRealtime, axSpanAttributes, axSpanEvents, axUpdateMetricsConfig, axUpdateOptimizerMetricsConfig, axValidateChatRequestMessage, axValidateChatResponseResult, axValidateGeminiLiveAudioInput, axValidateProviderCapabilities, axWorkerRuntime, f, flow, fn, s };
|
|
10894
|
+
export { AxAI, AxAIAnthropic, type AxAIAnthropicArgs, type AxAIAnthropicChatError, type AxAIAnthropicChatRequest, type AxAIAnthropicChatRequestCacheParam, type AxAIAnthropicChatResponse, type AxAIAnthropicChatResponseDelta, type AxAIAnthropicConfig, type AxAIAnthropicContentBlockDeltaEvent, type AxAIAnthropicContentBlockStartEvent, type AxAIAnthropicContentBlockStopEvent, type AxAIAnthropicEffortLevel, type AxAIAnthropicEffortLevelMapping, type AxAIAnthropicErrorEvent, type AxAIAnthropicFunctionTool, type AxAIAnthropicMessageDeltaEvent, type AxAIAnthropicMessageStartEvent, type AxAIAnthropicMessageStopEvent, AxAIAnthropicModel, type AxAIAnthropicOutputConfig, type AxAIAnthropicPingEvent, type AxAIAnthropicRequestTool, type AxAIAnthropicStopDetails, type AxAIAnthropicTaskBudget, type AxAIAnthropicThinkingConfig, type AxAIAnthropicThinkingTokenBudgetLevels, type AxAIAnthropicThinkingWire, AxAIAnthropicVertexModel, type AxAIAnthropicWebSearchTool, 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 AxAIGoogleGeminiCacheCreateRequest, type AxAIGoogleGeminiCacheResponse, type AxAIGoogleGeminiCacheUpdateRequest, type AxAIGoogleGeminiChatRequest, type AxAIGoogleGeminiChatResponse, type AxAIGoogleGeminiChatResponseDelta, type AxAIGoogleGeminiConfig, type AxAIGoogleGeminiContent, type AxAIGoogleGeminiContentPart, AxAIGoogleGeminiEmbedModel, AxAIGoogleGeminiEmbedTypes, type AxAIGoogleGeminiGenerationConfig, AxAIGoogleGeminiModel, type AxAIGoogleGeminiOptionsTools, type AxAIGoogleGeminiRetrievalConfig, AxAIGoogleGeminiSafetyCategory, type AxAIGoogleGeminiSafetySettings, AxAIGoogleGeminiSafetyThreshold, type AxAIGoogleGeminiThinkingConfig, type AxAIGoogleGeminiThinkingLevel, type AxAIGoogleGeminiThinkingLevelMapping, type AxAIGoogleGeminiThinkingTokenBudgetLevels, type AxAIGoogleGeminiTool, type AxAIGoogleGeminiToolConfig, type AxAIGoogleGeminiToolFunctionDeclaration, type AxAIGoogleGeminiToolGoogleMaps, type AxAIGoogleGeminiToolGoogleSearchRetrieval, type AxAIGoogleVertexBatchEmbedRequest, type AxAIGoogleVertexBatchEmbedResponse, AxAIGrok, type AxAIGrokArgs, type AxAIGrokChatRequest, AxAIGrokEmbedModels, AxAIGrokModel, type AxAIGrokOptionsTools, type AxAIGrokSearchSource, AxAIHuggingFace, type AxAIHuggingFaceArgs, type AxAIHuggingFaceConfig, AxAIHuggingFaceModel, type AxAIHuggingFaceRequest, type AxAIHuggingFaceResponse, type AxAIInputModelList, type AxAIMemory, type AxAIMetricsInstruments, AxAIMistral, type AxAIMistralArgs, type AxAIMistralChatRequest, AxAIMistralEmbedModels, AxAIMistralModel, type AxAIModelCatalogAudioSupport, type AxAIModelCatalogFilter, type AxAIModelCatalogModel, type AxAIModelCatalogModelCapabilities, type AxAIModelCatalogModelType, type AxAIModelCatalogOptions, type AxAIModelCatalogProvider, type AxAIModelCatalogProviderName, type AxAIModelList, type AxAIModelListBase, type AxAIModels, 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, 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 AxAIOpenAIResponsesResponseFailedEvent, type AxAIOpenAIResponsesResponseInProgressEvent, type AxAIOpenAIResponsesResponseIncompleteEvent, type AxAIOpenAIResponsesResponseQueuedEvent, type AxAIOpenAIResponsesStreamEvent, type AxAIOpenAIResponsesStreamEventBase, type AxAIOpenAIResponsesToolCall, type AxAIOpenAIResponsesToolCallBase, type AxAIOpenAIResponsesToolChoice, type AxAIOpenAIResponsesToolDefinition, type AxAIOpenAIResponsesWebSearchCallCompletedEvent, type AxAIOpenAIResponsesWebSearchCallInProgressEvent, type AxAIOpenAIResponsesWebSearchCallSearchingEvent, type AxAIOpenAIResponsesWebSearchToolCall, type AxAIOpenAIUrlCitation, type AxAIOpenAIUsage, AxAIRefusalError, AxAIReka, type AxAIRekaArgs, type AxAIRekaChatRequest, type AxAIRekaChatResponse, type AxAIRekaChatResponseDelta, type AxAIRekaConfig, AxAIRekaModel, type AxAIRekaUsage, type AxAIService, AxAIServiceAbortedError, type AxAIServiceActionOptions, AxAIServiceAuthenticationError, AxAIServiceError, type AxAIServiceImpl, type AxAIServiceMetrics, type AxAIServiceModelType, AxAIServiceNetworkError, type AxAIServiceOptions, AxAIServiceResponseError, AxAIServiceStatusError, AxAIServiceStreamTerminatedError, AxAIServiceTimeoutError, type AxAPI, type AxAPIConfig, type AxAPIResponseMetadata, AxAgent, type AxAgentActorTurnCallback, type AxAgentActorTurnCallbackArgs, type AxAgentClarification, type AxAgentClarificationChoice, AxAgentClarificationError, type AxAgentClarificationKind, type AxAgentCompletionProtocol, type AxAgentConfig, type AxAgentContextEvent, AxAgentContextMap, type AxAgentContextMapConfig, type AxAgentContextMapOperation, type AxAgentContextMapOptions, type AxAgentContextMapSnapshot, type AxAgentContextMapUpdateResult, type AxAgentContextPressure, type AxAgentContextStage, type AxAgentDemos, type AxAgentDiscoveryPromptState, type AxAgentEvalDataset, type AxAgentEvalFunctionCall, type AxAgentEvalPrediction, type AxAgentEvalTask, type AxAgentExecutorResultPayload, type AxAgentForwardOptions, type AxAgentFunction, type AxAgentFunctionCall, type AxAgentFunctionCallRecorder, type AxAgentFunctionCollection, type AxAgentFunctionExample, type AxAgentFunctionGroup, type AxAgentFunctionModuleMeta, type AxAgentGuidanceLogEntry, type AxAgentGuidancePayload, type AxAgentGuidanceState, type AxAgentIdentity, type AxAgentInputUpdateCallback, type AxAgentJudgeEvalInput, type AxAgentJudgeEvalOutput, type AxAgentJudgeInput, type AxAgentJudgeOptions, type AxAgentJudgeOutput, type AxAgentMemoriesSearchFn, type AxAgentMemoryEntry, type AxAgentMemoryResult, type AxAgentOnContextEvent, type AxAgentOnFunctionCall, type AxAgentOptimizationTargetDescriptor, type AxAgentOptimizeOptions, type AxAgentOptimizeResult, type AxAgentOptimizeTarget, type AxAgentOptions, AxAgentProtocolCompletionSignal, type AxAgentRecursionOptions, type AxAgentRecursiveExpensiveNode, type AxAgentRecursiveFunctionCall, type AxAgentRecursiveNodeRole, type AxAgentRecursiveStats, type AxAgentRecursiveTargetId, type AxAgentRecursiveTraceNode, type AxAgentRecursiveTurn, type AxAgentRecursiveUsage, type AxAgentRuntimeCompletionState, type AxAgentRuntimeExecutionContext, type AxAgentRuntimeInputState, type AxAgentSkillResult, type AxAgentSkillsPromptState, type AxAgentSkillsSearchFn, type AxAgentState, type AxAgentStateActionLogEntry, type AxAgentStateCheckpointState, type AxAgentStateExecutorModelState, type AxAgentStateRuntimeEntry, type AxAgentStreamingForwardOptions, type AxAgentStructuredClarification, type AxAgentTestCompletionPayload, type AxAgentTestResult, type AxAgentUsage, type AxAgentUsedMemoriesCallback, type AxAgentUsedMemory, type AxAgentUsedSkill, type AxAgentUsedSkillsCallback, type AxAgentic, type AxAnyAgentic, type AxAttempt, type AxAudioFormat, type AxAudioInput, AxBalancer, type AxBalancerOptions, AxBaseAI, type AxBaseAIArgs, AxBaseOptimizer, AxBestOfN, type AxBestOfNOptions, AxBootstrapFewShot, type AxBootstrapOptimizerOptions, type AxChatAudioConfig, type AxChatAudioOutput, type AxChatLogEntry, type AxChatLogMessage, type AxChatRequest, type AxChatResponse, type AxChatResponseFunctionCall, type AxChatResponseResult, type AxCheckpointLoadFn, type AxCheckpointSaveFn, type AxCitation, type AxCodeRuntime, type AxCodeSession, type AxCodeSessionSnapshot, type AxCodeSessionSnapshotEntry, type AxCompileOptions, AxContentProcessingError, type AxContentProcessingServices, type AxContextCacheInfo, type AxContextCacheOperation, type AxContextCacheOptions, type AxContextCacheRegistry, type AxContextCacheRegistryEntry, type AxContextFieldInput, type AxContextFieldPromptConfig, type AxContextPolicyBudget, type AxContextPolicyConfig, type AxContextPolicyPreset, type AxCostTracker, type AxCostTrackerOptions, type AxDateRange, type AxDateRangeValue, type AxDebugChatResponseUsage, AxDefaultCostTracker, type AxDiscoveryTurnSummary, type AxDockerContainer, AxDockerSession, type AxEmbedRequest, type AxEmbedResponse, AxEmbeddingAdapter, type AxErrorCategory, AxEvalUtil, type AxEvaluateArgs, type AxExample, type AxExamples, type AxExecutorModelPolicy, type AxExecutorModelPolicyEntry, type AxField, type AxFieldOptions, type AxFieldProcessor, type AxFieldProcessorProcess, type AxFieldTemplateFn, type AxFieldType, type AxFieldValue, AxFlow, type AxFlowBranchEvaluationData, type AxFlowCompleteData, type AxFlowDynamicContext, type AxFlowErrorData, type AxFlowExecutionPlan, type AxFlowExecutionPlanGroup, type AxFlowExecutionPlanStep, type AxFlowForwardOptions, type AxFlowLogData, type AxFlowLoggerData, type AxFlowLoggerFunction, type AxFlowOptions, type AxFlowParallelGroupCompleteData, type AxFlowParallelGroupStartData, type AxFlowStartData, type AxFlowState, type AxFlowStateDependencyAnalysis, type AxFlowStepCompleteData, type AxFlowStepStartData, type AxFlowTypedParallelBranch, type AxFlowTypedSubContext, type AxFlowable, type AxFluentFieldInfo, AxFluentFieldType, type AxForwardable, type AxFunction, type AxFunctionCallRecord, type AxFunctionCallTrace, AxFunctionError, type AxFunctionHandler, type AxFunctionJSONSchema, AxFunctionProcessor, type AxFunctionProvider, type AxFunctionResult, type AxFunctionResultFormatter, AxGEPA, type AxGEPAAdapter, type AxGEPABatchEvaluation, type AxGEPABatchRow, type AxGEPABootstrapOptions, type AxGEPAComponentBanditState, AxGEPAComponentSelector, type AxGEPAComponentTarget, type AxGEPAEvaluationBatch, type AxGEPAEvaluationState, type AxGEPAOptimizationReport, type AxGEPAReflectiveTuple, type AxGEPATraceSummary, type AxGEPATraceSummaryCall, AxGen, type AxGenDeltaOut, type AxGenIn, type AxGenInput, type AxGenMetricsInstruments, type AxGenOut, type AxGenOutput, type AxGenStreamingOut, AxGenerateError, type AxGenerateErrorDetails, type AxGenerateResult, type AxIField, type AxInputFunctionType, AxJSRuntime, type AxJSRuntimeNodePermissionAllowlist, type AxJSRuntimeOutputMode, AxJSRuntimePermission, type AxJSRuntimeResourceLimits, type AxJudgeForwardOptions, type AxJudgeOptions, type AxLlmQueryBudgetState, type AxLlmQueryPromptMode, type AxLoggerData, type AxLoggerFunction, type AxMCPBlobResourceContents, AxMCPClient, type AxMCPEmbeddedResource, type AxMCPFunctionDescription, AxMCPHTTPSSETransport, type AxMCPImageContent, type AxMCPInitializeParams, type AxMCPInitializeResult, type AxMCPJSONRPCErrorResponse, type AxMCPJSONRPCNotification, type AxMCPJSONRPCRequest, type AxMCPJSONRPCResponse, type AxMCPJSONRPCSuccessResponse, type AxMCPOAuthOptions, type AxMCPPrompt, type AxMCPPromptArgument, type AxMCPPromptGetResult, type AxMCPPromptMessage, type AxMCPPromptsListResult, type AxMCPResource, type AxMCPResourceReadResult, type AxMCPResourceTemplate, type AxMCPResourceTemplatesListResult, type AxMCPResourcesListResult, type AxMCPStreamableHTTPTransportOptions, AxMCPStreambleHTTPTransport, type AxMCPTextContent, type AxMCPTextResourceContents, type AxMCPToolsListResult, type AxMCPTransport, AxMediaNotSupportedError, AxMemory, type AxMemoryData, type AxMemoryMessageValue, type AxMetricFn, type AxMetricFnArgs, type AxMetricsConfig, AxMockAIService, type AxMockAIServiceConfig, type AxModelConfig, type AxModelInfo, type AxModelInfoWithProvider, type AxModelUsage, type AxMultiMetricFn, type AxMultiProviderConfig, AxMultiServiceRouter, type AxNamedProgramInstance, type AxOptimizableComponent, type AxOptimizableValidator, type AxOptimizationCheckpoint, type AxOptimizationProgress, type AxOptimizationStats, type AxOptimizedProgram, AxOptimizedProgramImpl, type AxOptimizer, type AxOptimizerArgs, type AxOptimizerLoggerData, type AxOptimizerLoggerFunction, type AxOptimizerMetricsConfig, type AxOptimizerMetricsInstruments, type AxOptimizerResult, type AxParetoResult, AxProgram, type AxProgramDemos, type AxProgramExamples, type AxProgramForwardOptions, type AxProgramForwardOptionsWithModels, type AxProgramOptions, type AxProgramStreamingForwardOptions, type AxProgramStreamingForwardOptionsWithModels, type AxProgramTrace, type AxProgramUsage, type AxProgrammable, type AxPromptMetrics, AxPromptTemplate, type AxPromptTemplateOptions, type AxProviderMetadata, AxProviderRouter, type AxRLMConfig, type AxRateLimiterFunction, AxRateLimiterTokenUsage, type AxRateLimiterTokenUsageOptions, AxRefine, AxRefineError, type AxRefineOptions, type AxRefineStrategy, type AxRenderedPrompt, type AxResolvedContextPolicy, type AxResolvedExecutorModelPolicy, type AxResolvedExecutorModelPolicyEntry, type AxResultPickerFunction, type AxResultPickerFunctionFieldResults, type AxResultPickerFunctionFunctionResults, type AxRewardFn, type AxRewardFnArgs, type AxRolloutTrace, type AxRoutingResult, type AxRuntimeCallableFormatArgs, type AxRuntimeLanguageInfo, type AxRuntimePrimitive, type AxRuntimePrimitiveExample, type AxRuntimePrimitiveOverrideMap, type AxRuntimePrimitiveSignature, type AxRuntimePrimitiveStage, type AxSamplePickerOptions, type AxSelfTuningConfig, type AxSerializedOptimizedProgram, type AxSetExamplesOptions, AxSignature, AxSignatureBuilder, type AxSignatureConfig, type AxSignatureInput, type AxSpeechConfig, type AxSpeechRequest, type AxSpeechResponse, type AxStageDefinitionBuildOptions, type AxStageOptions, type AxStepContext, type AxStepHooks, type AxStepUsage, AxStopFunctionCallException, type AxStreamingEvent, type AxStreamingFieldProcessorProcess, type AxStreamingGuard, AxStreamingGuardError, AxStringUtil, AxSynth, type AxSynthExample, type AxSynthOptions, type AxSynthResult, type AxSynthesizerInit, type AxSynthesizerOptions, type AxSynthesizerRole, AxTestPrompt, type AxThoughtBlockItem, AxTokenLimitError, type AxTokenUsage, type AxTranscriptionRequest, type AxTranscriptionResponse, type AxTranscriptionSegment, type AxTunable, type AxTypedExample, type AxUsable, type AxWorkerRuntimeConfig, agent, ai, ax, axAIAnthropicDefaultConfig, axAIAnthropicVertexDefaultConfig, axAIAzureOpenAIBestConfig, axAIAzureOpenAICreativeConfig, axAIAzureOpenAIDefaultConfig, axAIAzureOpenAIFastConfig, axAICohereCreativeConfig, axAICohereDefaultConfig, axAIDeepSeekCodeConfig, axAIDeepSeekDefaultConfig, axAIGoogleGeminiDefaultConfig, axAIGoogleGeminiDefaultCreativeConfig, axAIGoogleGeminiLiveAudioDefaultConfig, axAIGrokBestConfig, axAIGrokDefaultConfig, axAIGrokVoiceDefaultConfig, axAIHuggingFaceCreativeConfig, axAIHuggingFaceDefaultConfig, axAIMistralBestConfig, axAIMistralDefaultConfig, axAIOpenAIAudioDefaultConfig, axAIOpenAIBestConfig, axAIOpenAICreativeConfig, axAIOpenAIDefaultConfig, axAIOpenAIFastConfig, axAIOpenAIRealtimeDefaultConfig, axAIOpenAIRealtimeTranscriptionDefaultConfig, axAIOpenAIResponsesBestConfig, axAIOpenAIResponsesCreativeConfig, axAIOpenAIResponsesDefaultConfig, axAIRekaBestConfig, axAIRekaCreativeConfig, axAIRekaDefaultConfig, axAIRekaFastConfig, axAnalyzeChatPromptRequirements, axAnalyzeRequestRequirements, axApplyOpenAIChatAudioRequest, axAudioFormatFromMimeType, axAudioInputFilename, axAudioInputToBlob, axAudioMimeType, axBaseAIDefaultConfig, axBaseAIDefaultCreativeConfig, axBuildDistillerDefinition, axBuildExecutorDefinition, axBuildResponderDefinition, axCheckMetricsHealth, axConcatBase64, axCreateDefaultColorLogger, axCreateDefaultOptimizerColorLogger, axCreateDefaultOptimizerTextLogger, axCreateDefaultTextLogger, axCreateFlowColorLogger, axCreateFlowTextLogger, axCreateGeminiLiveAudioApi, axCreateGrokRealtimeApi, axCreateJSRuntime, axCreateOpenAIRealtimeApi, axDefaultFlowLogger, axDefaultMetricsConfig, axDefaultOptimizerLogger, axDefaultOptimizerMetricsConfig, axDeserializeOptimizedProgram, axFetchJsonSpeech, axFetchMultipartTranscription, axGetCompatibilityReport, axGetFormatCompatibility, axGetMetricsConfig, axGetOptimizerMetricsConfig, axGetProvidersWithMediaSupport, axGetSupportedAIModels, axGlobals, axGoogleGeminiLiveAudioDefaults, axIsAudioOutputEnabled, axIsGeminiLiveAudioModel, axIsGrokVoiceModel, axIsOpenAIChatAudioModel, axIsOpenAIRealtimeModel, axIsOpenAIRealtimeTranscriptionModel, axMapGeminiLiveAudioPart, axMapOpenAIChatAudioDelta, axMapOpenAIChatAudioResponse, axMapOpenAIInputAudioPart, axMergeChatAudioConfig, axModelInfoAnthropic, axModelInfoCohere, axModelInfoDeepSeek, axModelInfoGoogleGemini, axModelInfoGrok, axModelInfoHuggingFace, axModelInfoMistral, axModelInfoOpenAI, axModelInfoOpenAIResponses, axModelInfoReka, axNormalizeOpenAIUsage, axNormalizeTranscriptionResponse, axOpenAIChatAudioDefaults, axOptimizableValidators, axProcessContentForProvider, axResolveGeminiLiveAudioConfig, axResolveGrokRealtimeAudioConfig, axResolveOpenAIChatAudioConfig, axResolveOpenAIRealtimeAudioConfig, axRuntimePrimitives, axScoreProvidersForRequest, axSelectOptimalProvider, axSerializeOptimizedProgram, axShouldUseGeminiLiveAudio, axShouldUseGrokRealtime, axShouldUseOpenAIRealtime, axSpanAttributes, axSpanEvents, axUpdateMetricsConfig, axUpdateOptimizerMetricsConfig, axValidateChatRequestMessage, axValidateChatResponseResult, axValidateGeminiLiveAudioInput, axValidateProviderCapabilities, axWorkerRuntime, bestOfN, f, flow, fn, refine, s };
|