@ax-llm/ax 14.0.0 → 14.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +207 -207
- package/index.cjs.map +1 -1
- package/index.d.cts +96 -12
- package/index.d.ts +96 -12
- package/index.global.js +56 -56
- package/index.global.js.map +1 -1
- package/index.js +209 -209
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.cts
CHANGED
|
@@ -319,12 +319,24 @@ type AxChatRequest<TModel = string> = {
|
|
|
319
319
|
/** Duration of audio in seconds */
|
|
320
320
|
duration?: number;
|
|
321
321
|
} | {
|
|
322
|
-
/** File content type */
|
|
322
|
+
/** File content type with inline data */
|
|
323
323
|
type: 'file';
|
|
324
|
-
/** File data as base64
|
|
324
|
+
/** File data as base64 */
|
|
325
325
|
data: string;
|
|
326
326
|
/** Original filename */
|
|
327
|
-
filename
|
|
327
|
+
filename?: string;
|
|
328
|
+
/** MIME type of the file */
|
|
329
|
+
mimeType: string;
|
|
330
|
+
cache?: boolean;
|
|
331
|
+
/** Pre-extracted text content for fallback */
|
|
332
|
+
extractedText?: string;
|
|
333
|
+
} | {
|
|
334
|
+
/** File content type with cloud storage URI */
|
|
335
|
+
type: 'file';
|
|
336
|
+
/** File URI (e.g., gs:// URL) */
|
|
337
|
+
fileUri: string;
|
|
338
|
+
/** Original filename */
|
|
339
|
+
filename?: string;
|
|
328
340
|
/** MIME type of the file */
|
|
329
341
|
mimeType: string;
|
|
330
342
|
cache?: boolean;
|
|
@@ -1225,7 +1237,7 @@ declare class AxAIOpenAIBase<TModel, TEmbedModel, TModelKey, TChatReq extends Ax
|
|
|
1225
1237
|
constructor({ apiKey, config, options, apiURL, modelInfo, models, chatReqUpdater, supportFor, }: Readonly<Omit<AxAIOpenAIBaseArgs<TModel, TEmbedModel, TModelKey, TChatReq>, 'name'>>);
|
|
1226
1238
|
}
|
|
1227
1239
|
declare class AxAIOpenAI<TModelKey = string> extends AxAIOpenAIBase<AxAIOpenAIModel, AxAIOpenAIEmbedModel, TModelKey> {
|
|
1228
|
-
constructor({ apiKey, config, options, models, modelInfo, }: Readonly<Omit<AxAIOpenAIArgs<'openai', AxAIOpenAIModel, AxAIOpenAIEmbedModel, TModelKey>, 'name'>>);
|
|
1240
|
+
constructor({ apiKey, apiURL, config, options, models, modelInfo, }: Readonly<Omit<AxAIOpenAIArgs<'openai', AxAIOpenAIModel, AxAIOpenAIEmbedModel, TModelKey>, 'name'>>);
|
|
1229
1241
|
}
|
|
1230
1242
|
|
|
1231
1243
|
declare const axAIAzureOpenAIDefaultConfig: () => AxAIOpenAIConfig<AxAIOpenAIModel, AxAIOpenAIEmbedModel>;
|
|
@@ -3707,7 +3719,14 @@ declare class AxMemory implements AxAIMemory {
|
|
|
3707
3719
|
} | {
|
|
3708
3720
|
type: "file";
|
|
3709
3721
|
data: string;
|
|
3710
|
-
filename
|
|
3722
|
+
filename?: string;
|
|
3723
|
+
mimeType: string;
|
|
3724
|
+
cache?: boolean;
|
|
3725
|
+
extractedText?: string;
|
|
3726
|
+
} | {
|
|
3727
|
+
type: "file";
|
|
3728
|
+
fileUri: string;
|
|
3729
|
+
filename?: string;
|
|
3711
3730
|
mimeType: string;
|
|
3712
3731
|
cache?: boolean;
|
|
3713
3732
|
extractedText?: string;
|
|
@@ -3828,7 +3847,14 @@ declare class AxPromptTemplate {
|
|
|
3828
3847
|
} | {
|
|
3829
3848
|
type: "file";
|
|
3830
3849
|
data: string;
|
|
3831
|
-
filename
|
|
3850
|
+
filename?: string;
|
|
3851
|
+
mimeType: string;
|
|
3852
|
+
cache?: boolean;
|
|
3853
|
+
extractedText?: string;
|
|
3854
|
+
} | {
|
|
3855
|
+
type: "file";
|
|
3856
|
+
fileUri: string;
|
|
3857
|
+
filename?: string;
|
|
3832
3858
|
mimeType: string;
|
|
3833
3859
|
cache?: boolean;
|
|
3834
3860
|
extractedText?: string;
|
|
@@ -3869,6 +3895,9 @@ interface TypeMap {
|
|
|
3869
3895
|
file: {
|
|
3870
3896
|
mimeType: string;
|
|
3871
3897
|
data: string;
|
|
3898
|
+
} | {
|
|
3899
|
+
mimeType: string;
|
|
3900
|
+
fileUri: string;
|
|
3872
3901
|
};
|
|
3873
3902
|
url: string;
|
|
3874
3903
|
code: string;
|
|
@@ -4025,6 +4054,15 @@ type AxGenIn = {
|
|
|
4025
4054
|
type AxGenOut = {
|
|
4026
4055
|
[key: string]: AxFieldValue;
|
|
4027
4056
|
};
|
|
4057
|
+
/**
|
|
4058
|
+
* @deprecated AxMessage will be updated to a new design within this major version.
|
|
4059
|
+
* The current structure will be replaced in v15.0.0.
|
|
4060
|
+
*
|
|
4061
|
+
* Migration timeline:
|
|
4062
|
+
* - v14.0.0+: Deprecation warnings (current)
|
|
4063
|
+
* - v14.x: New message design introduced alongside existing
|
|
4064
|
+
* - v15.0.0: Complete replacement with new design
|
|
4065
|
+
*/
|
|
4028
4066
|
type AxMessage<IN> = {
|
|
4029
4067
|
role: 'user';
|
|
4030
4068
|
values: IN;
|
|
@@ -4075,6 +4113,7 @@ type AxProgramForwardOptions<MODEL> = AxAIServiceOptions & {
|
|
|
4075
4113
|
functionResultFormatter?: (result: unknown) => string;
|
|
4076
4114
|
fastFail?: boolean;
|
|
4077
4115
|
showThoughts?: boolean;
|
|
4116
|
+
functionCallMode?: 'auto' | 'native' | 'prompt';
|
|
4078
4117
|
traceLabel?: string;
|
|
4079
4118
|
description?: string;
|
|
4080
4119
|
thoughtFieldName?: string;
|
|
@@ -4229,12 +4268,18 @@ type InferFieldValueType<T> = T extends AxFieldType | AxFluentFieldType ? T['typ
|
|
|
4229
4268
|
}[] : {
|
|
4230
4269
|
format?: 'wav';
|
|
4231
4270
|
data: string;
|
|
4232
|
-
} : T['type'] extends 'file' ? T['isArray'] extends true ? {
|
|
4271
|
+
} : T['type'] extends 'file' ? T['isArray'] extends true ? ({
|
|
4233
4272
|
mimeType: string;
|
|
4234
4273
|
data: string;
|
|
4235
|
-
}
|
|
4274
|
+
} | {
|
|
4275
|
+
mimeType: string;
|
|
4276
|
+
fileUri: string;
|
|
4277
|
+
})[] : {
|
|
4236
4278
|
mimeType: string;
|
|
4237
4279
|
data: string;
|
|
4280
|
+
} | {
|
|
4281
|
+
mimeType: string;
|
|
4282
|
+
fileUri: string;
|
|
4238
4283
|
} : T['type'] extends 'url' ? T['isArray'] extends true ? string[] : string : T['type'] extends 'code' ? T['isArray'] extends true ? string[] : string : T['type'] extends 'class' ? T['options'] extends readonly (infer U)[] ? T['isArray'] extends true ? U[] : U : T['isArray'] extends true ? string[] : string : any : any;
|
|
4239
4284
|
interface AxFluentFieldInfo<TType extends AxFieldType['type'] = AxFieldType['type'], TIsArray extends boolean = false, TOptions extends readonly string[] = readonly string[], TIsOptional extends boolean = false> {
|
|
4240
4285
|
readonly type: TType;
|
|
@@ -4256,12 +4301,18 @@ type InferFluentType<T extends AxFluentFieldInfo<any, any, any, any> | AxFluentF
|
|
|
4256
4301
|
}[] : {
|
|
4257
4302
|
format?: 'wav';
|
|
4258
4303
|
data: string;
|
|
4259
|
-
} : T['type'] extends 'file' ? T['isArray'] extends true ? {
|
|
4304
|
+
} : T['type'] extends 'file' ? T['isArray'] extends true ? ({
|
|
4260
4305
|
mimeType: string;
|
|
4261
4306
|
data: string;
|
|
4262
|
-
}
|
|
4307
|
+
} | {
|
|
4308
|
+
mimeType: string;
|
|
4309
|
+
fileUri: string;
|
|
4310
|
+
})[] : {
|
|
4263
4311
|
mimeType: string;
|
|
4264
4312
|
data: string;
|
|
4313
|
+
} | {
|
|
4314
|
+
mimeType: string;
|
|
4315
|
+
fileUri: string;
|
|
4265
4316
|
} : T['type'] extends 'url' ? T['isArray'] extends true ? string[] : string : T['type'] extends 'code' ? T['isArray'] extends true ? string[] : string : T['type'] extends 'class' ? T['options'] extends readonly (infer U)[] ? T['isArray'] extends true ? U[] : U : T['isArray'] extends true ? string[] : string : any;
|
|
4266
4317
|
interface AxSignatureConfig {
|
|
4267
4318
|
description?: string;
|
|
@@ -4319,6 +4370,26 @@ declare class AxSignature<_TInput extends Record<string, any> = Record<string, a
|
|
|
4319
4370
|
validate: () => boolean;
|
|
4320
4371
|
hash: () => string;
|
|
4321
4372
|
toString: () => string;
|
|
4373
|
+
/**
|
|
4374
|
+
* Inject tool schemas as optional output fields for signature tool calling
|
|
4375
|
+
* Uses dot notation for nested parameters (jq-like syntax)
|
|
4376
|
+
*/
|
|
4377
|
+
injectToolFields(tools: readonly AxFunction[]): AxSignature<_TInput, _TOutput>;
|
|
4378
|
+
/**
|
|
4379
|
+
* Generate signature fields for tool parameters using dot notation
|
|
4380
|
+
*/
|
|
4381
|
+
private generateToolParameterFields;
|
|
4382
|
+
/**
|
|
4383
|
+
* Infer signature field type from JSON Schema parameter
|
|
4384
|
+
*/
|
|
4385
|
+
private inferParameterType;
|
|
4386
|
+
/**
|
|
4387
|
+
* Format parameter title for display
|
|
4388
|
+
*/
|
|
4389
|
+
private formatParameterTitle;
|
|
4390
|
+
private sanitizeFieldName;
|
|
4391
|
+
private formatTitle;
|
|
4392
|
+
private inferToolFieldType;
|
|
4322
4393
|
toJSON: () => {
|
|
4323
4394
|
id: string;
|
|
4324
4395
|
description: string | undefined;
|
|
@@ -4430,6 +4501,7 @@ declare class AxGen<IN = any, OUT extends AxGenOut = any> extends AxProgram<IN,
|
|
|
4430
4501
|
private streamingFieldProcessors;
|
|
4431
4502
|
private excludeContentFromTrace;
|
|
4432
4503
|
private thoughtFieldName;
|
|
4504
|
+
private signatureToolCallingManager?;
|
|
4433
4505
|
constructor(signature: NonNullable<ConstructorParameters<typeof AxSignature>[0]> | AxSignature<any, any>, options?: Readonly<AxProgramForwardOptions<any>>);
|
|
4434
4506
|
private getSignatureName;
|
|
4435
4507
|
private getMetricsInstruments;
|
|
@@ -5516,6 +5588,7 @@ declare const AxStringUtil: {
|
|
|
5516
5588
|
|
|
5517
5589
|
declare function s<const T extends string>(signature: T): AxSignature<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>;
|
|
5518
5590
|
declare function ax<const T extends string>(signature: T, options?: Readonly<AxProgramForwardOptions<any>>): AxGen<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>;
|
|
5591
|
+
declare function ax<TInput extends Record<string, any>, TOutput extends Record<string, any>>(signature: AxSignature<TInput, TOutput>, options?: Readonly<AxProgramForwardOptions<any>>): AxGen<TInput, TOutput>;
|
|
5519
5592
|
|
|
5520
5593
|
/**
|
|
5521
5594
|
* Analyzes mapping functions to extract state dependencies.
|
|
@@ -7113,6 +7186,7 @@ declare class AxAgent<IN extends AxGenIn, OUT extends AxGenOut> implements AxAge
|
|
|
7113
7186
|
private disableSmartModelRouting?;
|
|
7114
7187
|
private excludeFieldsFromPassthrough;
|
|
7115
7188
|
private debug?;
|
|
7189
|
+
private options?;
|
|
7116
7190
|
private name;
|
|
7117
7191
|
private func;
|
|
7118
7192
|
constructor({ ai, name, description, definition, signature, agents, functions, }: Readonly<{
|
|
@@ -7189,21 +7263,30 @@ interface AxAgentConfig<IN extends AxGenIn, OUT extends AxGenOut> extends AxAgen
|
|
|
7189
7263
|
functions?: AxInputFunctionType;
|
|
7190
7264
|
}
|
|
7191
7265
|
/**
|
|
7192
|
-
* Creates a strongly-typed AI agent from a
|
|
7266
|
+
* Creates a strongly-typed AI agent from a signature.
|
|
7193
7267
|
* This is the recommended way to create agents, providing better type inference and cleaner syntax.
|
|
7268
|
+
* Supports both string signatures and AxSignature objects.
|
|
7194
7269
|
*
|
|
7195
|
-
* @param signature - The input/output signature as a string
|
|
7270
|
+
* @param signature - The input/output signature as a string or AxSignature object
|
|
7196
7271
|
* @param config - Configuration options for the agent
|
|
7197
7272
|
* @returns A typed agent instance
|
|
7198
7273
|
*
|
|
7199
7274
|
* @example
|
|
7200
7275
|
* ```typescript
|
|
7276
|
+
* // Using string signature
|
|
7201
7277
|
* const myAgent = agent('userInput:string -> responseText:string', {
|
|
7202
7278
|
* name: 'myAgent',
|
|
7203
7279
|
* description: 'An agent that processes user input and returns a response',
|
|
7204
7280
|
* definition: 'You are a helpful assistant that responds to user queries...'
|
|
7205
7281
|
* });
|
|
7206
7282
|
*
|
|
7283
|
+
* // Using AxSignature object
|
|
7284
|
+
* const sig = s('userInput:string -> responseText:string');
|
|
7285
|
+
* const myAgent2 = agent(sig, {
|
|
7286
|
+
* name: 'myAgent2',
|
|
7287
|
+
* description: 'Same agent but using AxSignature object'
|
|
7288
|
+
* });
|
|
7289
|
+
*
|
|
7207
7290
|
* // With child agents
|
|
7208
7291
|
* const parentAgent = agent('taskDescription:string -> completedTask:string', {
|
|
7209
7292
|
* name: 'parentAgent',
|
|
@@ -7217,6 +7300,7 @@ interface AxAgentConfig<IN extends AxGenIn, OUT extends AxGenOut> extends AxAgen
|
|
|
7217
7300
|
* ```
|
|
7218
7301
|
*/
|
|
7219
7302
|
declare function agent<const T extends string>(signature: T, config: AxAgentConfig<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>): AxAgent<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>;
|
|
7303
|
+
declare function agent<TInput extends Record<string, any>, TOutput extends Record<string, any>>(signature: AxSignature<TInput, TOutput>, config: AxAgentConfig<TInput, TOutput>): AxAgent<TInput, TOutput>;
|
|
7220
7304
|
|
|
7221
7305
|
/**
|
|
7222
7306
|
* Advanced Multi-hop RAG with iterative query refinement, context accumulation,
|
package/index.d.ts
CHANGED
|
@@ -319,12 +319,24 @@ type AxChatRequest<TModel = string> = {
|
|
|
319
319
|
/** Duration of audio in seconds */
|
|
320
320
|
duration?: number;
|
|
321
321
|
} | {
|
|
322
|
-
/** File content type */
|
|
322
|
+
/** File content type with inline data */
|
|
323
323
|
type: 'file';
|
|
324
|
-
/** File data as base64
|
|
324
|
+
/** File data as base64 */
|
|
325
325
|
data: string;
|
|
326
326
|
/** Original filename */
|
|
327
|
-
filename
|
|
327
|
+
filename?: string;
|
|
328
|
+
/** MIME type of the file */
|
|
329
|
+
mimeType: string;
|
|
330
|
+
cache?: boolean;
|
|
331
|
+
/** Pre-extracted text content for fallback */
|
|
332
|
+
extractedText?: string;
|
|
333
|
+
} | {
|
|
334
|
+
/** File content type with cloud storage URI */
|
|
335
|
+
type: 'file';
|
|
336
|
+
/** File URI (e.g., gs:// URL) */
|
|
337
|
+
fileUri: string;
|
|
338
|
+
/** Original filename */
|
|
339
|
+
filename?: string;
|
|
328
340
|
/** MIME type of the file */
|
|
329
341
|
mimeType: string;
|
|
330
342
|
cache?: boolean;
|
|
@@ -1225,7 +1237,7 @@ declare class AxAIOpenAIBase<TModel, TEmbedModel, TModelKey, TChatReq extends Ax
|
|
|
1225
1237
|
constructor({ apiKey, config, options, apiURL, modelInfo, models, chatReqUpdater, supportFor, }: Readonly<Omit<AxAIOpenAIBaseArgs<TModel, TEmbedModel, TModelKey, TChatReq>, 'name'>>);
|
|
1226
1238
|
}
|
|
1227
1239
|
declare class AxAIOpenAI<TModelKey = string> extends AxAIOpenAIBase<AxAIOpenAIModel, AxAIOpenAIEmbedModel, TModelKey> {
|
|
1228
|
-
constructor({ apiKey, config, options, models, modelInfo, }: Readonly<Omit<AxAIOpenAIArgs<'openai', AxAIOpenAIModel, AxAIOpenAIEmbedModel, TModelKey>, 'name'>>);
|
|
1240
|
+
constructor({ apiKey, apiURL, config, options, models, modelInfo, }: Readonly<Omit<AxAIOpenAIArgs<'openai', AxAIOpenAIModel, AxAIOpenAIEmbedModel, TModelKey>, 'name'>>);
|
|
1229
1241
|
}
|
|
1230
1242
|
|
|
1231
1243
|
declare const axAIAzureOpenAIDefaultConfig: () => AxAIOpenAIConfig<AxAIOpenAIModel, AxAIOpenAIEmbedModel>;
|
|
@@ -3707,7 +3719,14 @@ declare class AxMemory implements AxAIMemory {
|
|
|
3707
3719
|
} | {
|
|
3708
3720
|
type: "file";
|
|
3709
3721
|
data: string;
|
|
3710
|
-
filename
|
|
3722
|
+
filename?: string;
|
|
3723
|
+
mimeType: string;
|
|
3724
|
+
cache?: boolean;
|
|
3725
|
+
extractedText?: string;
|
|
3726
|
+
} | {
|
|
3727
|
+
type: "file";
|
|
3728
|
+
fileUri: string;
|
|
3729
|
+
filename?: string;
|
|
3711
3730
|
mimeType: string;
|
|
3712
3731
|
cache?: boolean;
|
|
3713
3732
|
extractedText?: string;
|
|
@@ -3828,7 +3847,14 @@ declare class AxPromptTemplate {
|
|
|
3828
3847
|
} | {
|
|
3829
3848
|
type: "file";
|
|
3830
3849
|
data: string;
|
|
3831
|
-
filename
|
|
3850
|
+
filename?: string;
|
|
3851
|
+
mimeType: string;
|
|
3852
|
+
cache?: boolean;
|
|
3853
|
+
extractedText?: string;
|
|
3854
|
+
} | {
|
|
3855
|
+
type: "file";
|
|
3856
|
+
fileUri: string;
|
|
3857
|
+
filename?: string;
|
|
3832
3858
|
mimeType: string;
|
|
3833
3859
|
cache?: boolean;
|
|
3834
3860
|
extractedText?: string;
|
|
@@ -3869,6 +3895,9 @@ interface TypeMap {
|
|
|
3869
3895
|
file: {
|
|
3870
3896
|
mimeType: string;
|
|
3871
3897
|
data: string;
|
|
3898
|
+
} | {
|
|
3899
|
+
mimeType: string;
|
|
3900
|
+
fileUri: string;
|
|
3872
3901
|
};
|
|
3873
3902
|
url: string;
|
|
3874
3903
|
code: string;
|
|
@@ -4025,6 +4054,15 @@ type AxGenIn = {
|
|
|
4025
4054
|
type AxGenOut = {
|
|
4026
4055
|
[key: string]: AxFieldValue;
|
|
4027
4056
|
};
|
|
4057
|
+
/**
|
|
4058
|
+
* @deprecated AxMessage will be updated to a new design within this major version.
|
|
4059
|
+
* The current structure will be replaced in v15.0.0.
|
|
4060
|
+
*
|
|
4061
|
+
* Migration timeline:
|
|
4062
|
+
* - v14.0.0+: Deprecation warnings (current)
|
|
4063
|
+
* - v14.x: New message design introduced alongside existing
|
|
4064
|
+
* - v15.0.0: Complete replacement with new design
|
|
4065
|
+
*/
|
|
4028
4066
|
type AxMessage<IN> = {
|
|
4029
4067
|
role: 'user';
|
|
4030
4068
|
values: IN;
|
|
@@ -4075,6 +4113,7 @@ type AxProgramForwardOptions<MODEL> = AxAIServiceOptions & {
|
|
|
4075
4113
|
functionResultFormatter?: (result: unknown) => string;
|
|
4076
4114
|
fastFail?: boolean;
|
|
4077
4115
|
showThoughts?: boolean;
|
|
4116
|
+
functionCallMode?: 'auto' | 'native' | 'prompt';
|
|
4078
4117
|
traceLabel?: string;
|
|
4079
4118
|
description?: string;
|
|
4080
4119
|
thoughtFieldName?: string;
|
|
@@ -4229,12 +4268,18 @@ type InferFieldValueType<T> = T extends AxFieldType | AxFluentFieldType ? T['typ
|
|
|
4229
4268
|
}[] : {
|
|
4230
4269
|
format?: 'wav';
|
|
4231
4270
|
data: string;
|
|
4232
|
-
} : T['type'] extends 'file' ? T['isArray'] extends true ? {
|
|
4271
|
+
} : T['type'] extends 'file' ? T['isArray'] extends true ? ({
|
|
4233
4272
|
mimeType: string;
|
|
4234
4273
|
data: string;
|
|
4235
|
-
}
|
|
4274
|
+
} | {
|
|
4275
|
+
mimeType: string;
|
|
4276
|
+
fileUri: string;
|
|
4277
|
+
})[] : {
|
|
4236
4278
|
mimeType: string;
|
|
4237
4279
|
data: string;
|
|
4280
|
+
} | {
|
|
4281
|
+
mimeType: string;
|
|
4282
|
+
fileUri: string;
|
|
4238
4283
|
} : T['type'] extends 'url' ? T['isArray'] extends true ? string[] : string : T['type'] extends 'code' ? T['isArray'] extends true ? string[] : string : T['type'] extends 'class' ? T['options'] extends readonly (infer U)[] ? T['isArray'] extends true ? U[] : U : T['isArray'] extends true ? string[] : string : any : any;
|
|
4239
4284
|
interface AxFluentFieldInfo<TType extends AxFieldType['type'] = AxFieldType['type'], TIsArray extends boolean = false, TOptions extends readonly string[] = readonly string[], TIsOptional extends boolean = false> {
|
|
4240
4285
|
readonly type: TType;
|
|
@@ -4256,12 +4301,18 @@ type InferFluentType<T extends AxFluentFieldInfo<any, any, any, any> | AxFluentF
|
|
|
4256
4301
|
}[] : {
|
|
4257
4302
|
format?: 'wav';
|
|
4258
4303
|
data: string;
|
|
4259
|
-
} : T['type'] extends 'file' ? T['isArray'] extends true ? {
|
|
4304
|
+
} : T['type'] extends 'file' ? T['isArray'] extends true ? ({
|
|
4260
4305
|
mimeType: string;
|
|
4261
4306
|
data: string;
|
|
4262
|
-
}
|
|
4307
|
+
} | {
|
|
4308
|
+
mimeType: string;
|
|
4309
|
+
fileUri: string;
|
|
4310
|
+
})[] : {
|
|
4263
4311
|
mimeType: string;
|
|
4264
4312
|
data: string;
|
|
4313
|
+
} | {
|
|
4314
|
+
mimeType: string;
|
|
4315
|
+
fileUri: string;
|
|
4265
4316
|
} : T['type'] extends 'url' ? T['isArray'] extends true ? string[] : string : T['type'] extends 'code' ? T['isArray'] extends true ? string[] : string : T['type'] extends 'class' ? T['options'] extends readonly (infer U)[] ? T['isArray'] extends true ? U[] : U : T['isArray'] extends true ? string[] : string : any;
|
|
4266
4317
|
interface AxSignatureConfig {
|
|
4267
4318
|
description?: string;
|
|
@@ -4319,6 +4370,26 @@ declare class AxSignature<_TInput extends Record<string, any> = Record<string, a
|
|
|
4319
4370
|
validate: () => boolean;
|
|
4320
4371
|
hash: () => string;
|
|
4321
4372
|
toString: () => string;
|
|
4373
|
+
/**
|
|
4374
|
+
* Inject tool schemas as optional output fields for signature tool calling
|
|
4375
|
+
* Uses dot notation for nested parameters (jq-like syntax)
|
|
4376
|
+
*/
|
|
4377
|
+
injectToolFields(tools: readonly AxFunction[]): AxSignature<_TInput, _TOutput>;
|
|
4378
|
+
/**
|
|
4379
|
+
* Generate signature fields for tool parameters using dot notation
|
|
4380
|
+
*/
|
|
4381
|
+
private generateToolParameterFields;
|
|
4382
|
+
/**
|
|
4383
|
+
* Infer signature field type from JSON Schema parameter
|
|
4384
|
+
*/
|
|
4385
|
+
private inferParameterType;
|
|
4386
|
+
/**
|
|
4387
|
+
* Format parameter title for display
|
|
4388
|
+
*/
|
|
4389
|
+
private formatParameterTitle;
|
|
4390
|
+
private sanitizeFieldName;
|
|
4391
|
+
private formatTitle;
|
|
4392
|
+
private inferToolFieldType;
|
|
4322
4393
|
toJSON: () => {
|
|
4323
4394
|
id: string;
|
|
4324
4395
|
description: string | undefined;
|
|
@@ -4430,6 +4501,7 @@ declare class AxGen<IN = any, OUT extends AxGenOut = any> extends AxProgram<IN,
|
|
|
4430
4501
|
private streamingFieldProcessors;
|
|
4431
4502
|
private excludeContentFromTrace;
|
|
4432
4503
|
private thoughtFieldName;
|
|
4504
|
+
private signatureToolCallingManager?;
|
|
4433
4505
|
constructor(signature: NonNullable<ConstructorParameters<typeof AxSignature>[0]> | AxSignature<any, any>, options?: Readonly<AxProgramForwardOptions<any>>);
|
|
4434
4506
|
private getSignatureName;
|
|
4435
4507
|
private getMetricsInstruments;
|
|
@@ -5516,6 +5588,7 @@ declare const AxStringUtil: {
|
|
|
5516
5588
|
|
|
5517
5589
|
declare function s<const T extends string>(signature: T): AxSignature<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>;
|
|
5518
5590
|
declare function ax<const T extends string>(signature: T, options?: Readonly<AxProgramForwardOptions<any>>): AxGen<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>;
|
|
5591
|
+
declare function ax<TInput extends Record<string, any>, TOutput extends Record<string, any>>(signature: AxSignature<TInput, TOutput>, options?: Readonly<AxProgramForwardOptions<any>>): AxGen<TInput, TOutput>;
|
|
5519
5592
|
|
|
5520
5593
|
/**
|
|
5521
5594
|
* Analyzes mapping functions to extract state dependencies.
|
|
@@ -7113,6 +7186,7 @@ declare class AxAgent<IN extends AxGenIn, OUT extends AxGenOut> implements AxAge
|
|
|
7113
7186
|
private disableSmartModelRouting?;
|
|
7114
7187
|
private excludeFieldsFromPassthrough;
|
|
7115
7188
|
private debug?;
|
|
7189
|
+
private options?;
|
|
7116
7190
|
private name;
|
|
7117
7191
|
private func;
|
|
7118
7192
|
constructor({ ai, name, description, definition, signature, agents, functions, }: Readonly<{
|
|
@@ -7189,21 +7263,30 @@ interface AxAgentConfig<IN extends AxGenIn, OUT extends AxGenOut> extends AxAgen
|
|
|
7189
7263
|
functions?: AxInputFunctionType;
|
|
7190
7264
|
}
|
|
7191
7265
|
/**
|
|
7192
|
-
* Creates a strongly-typed AI agent from a
|
|
7266
|
+
* Creates a strongly-typed AI agent from a signature.
|
|
7193
7267
|
* This is the recommended way to create agents, providing better type inference and cleaner syntax.
|
|
7268
|
+
* Supports both string signatures and AxSignature objects.
|
|
7194
7269
|
*
|
|
7195
|
-
* @param signature - The input/output signature as a string
|
|
7270
|
+
* @param signature - The input/output signature as a string or AxSignature object
|
|
7196
7271
|
* @param config - Configuration options for the agent
|
|
7197
7272
|
* @returns A typed agent instance
|
|
7198
7273
|
*
|
|
7199
7274
|
* @example
|
|
7200
7275
|
* ```typescript
|
|
7276
|
+
* // Using string signature
|
|
7201
7277
|
* const myAgent = agent('userInput:string -> responseText:string', {
|
|
7202
7278
|
* name: 'myAgent',
|
|
7203
7279
|
* description: 'An agent that processes user input and returns a response',
|
|
7204
7280
|
* definition: 'You are a helpful assistant that responds to user queries...'
|
|
7205
7281
|
* });
|
|
7206
7282
|
*
|
|
7283
|
+
* // Using AxSignature object
|
|
7284
|
+
* const sig = s('userInput:string -> responseText:string');
|
|
7285
|
+
* const myAgent2 = agent(sig, {
|
|
7286
|
+
* name: 'myAgent2',
|
|
7287
|
+
* description: 'Same agent but using AxSignature object'
|
|
7288
|
+
* });
|
|
7289
|
+
*
|
|
7207
7290
|
* // With child agents
|
|
7208
7291
|
* const parentAgent = agent('taskDescription:string -> completedTask:string', {
|
|
7209
7292
|
* name: 'parentAgent',
|
|
@@ -7217,6 +7300,7 @@ interface AxAgentConfig<IN extends AxGenIn, OUT extends AxGenOut> extends AxAgen
|
|
|
7217
7300
|
* ```
|
|
7218
7301
|
*/
|
|
7219
7302
|
declare function agent<const T extends string>(signature: T, config: AxAgentConfig<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>): AxAgent<ParseSignature<T>['inputs'], ParseSignature<T>['outputs']>;
|
|
7303
|
+
declare function agent<TInput extends Record<string, any>, TOutput extends Record<string, any>>(signature: AxSignature<TInput, TOutput>, config: AxAgentConfig<TInput, TOutput>): AxAgent<TInput, TOutput>;
|
|
7220
7304
|
|
|
7221
7305
|
/**
|
|
7222
7306
|
* Advanced Multi-hop RAG with iterative query refinement, context accumulation,
|