@aigne/core 1.57.4 → 1.58.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.
@@ -32,13 +32,13 @@ export declare const imageModelInputSchema: z.ZodObject<{
32
32
  }, "strip", z.ZodTypeAny, {
33
33
  prompt: string;
34
34
  model?: string | undefined;
35
- responseFormat?: "url" | "base64" | undefined;
35
+ responseFormat?: "base64" | "url" | undefined;
36
36
  image?: string | string[] | undefined;
37
37
  n?: number | undefined;
38
38
  }, {
39
39
  prompt: string;
40
40
  model?: string | undefined;
41
- responseFormat?: "url" | "base64" | undefined;
41
+ responseFormat?: "base64" | "url" | undefined;
42
42
  image?: string | string[] | undefined;
43
43
  n?: number | undefined;
44
44
  }>;
@@ -202,6 +202,8 @@ class AIGNEContext {
202
202
  return this.internal.events.emit(eventName, ...newArgs);
203
203
  }
204
204
  async trace(eventName, args, b) {
205
+ if (process.env.AIGNE_OBSERVABILITY_DISABLED)
206
+ return;
205
207
  const span = this.span;
206
208
  if (!span)
207
209
  return;
@@ -1,7 +1,7 @@
1
1
  import type { GetPromptResult } from "@modelcontextprotocol/sdk/types.js";
2
2
  import { Agent, type AgentInvokeOptions, type Message } from "../agents/agent.js";
3
- import type { AIAgent } from "../agents/ai-agent.js";
4
- import type { ChatModel, ChatModelInput } from "../agents/chat-model.js";
3
+ import { type AIAgent } from "../agents/ai-agent.js";
4
+ import { type ChatModel, type ChatModelInput } from "../agents/chat-model.js";
5
5
  import { ChatMessagesTemplate } from "./template.js";
6
6
  export interface PromptBuilderOptions {
7
7
  instructions?: string | ChatMessagesTemplate;
@@ -6,6 +6,9 @@ const yaml_1 = require("yaml");
6
6
  const zod_1 = require("zod");
7
7
  const zod_to_json_schema_1 = require("zod-to-json-schema");
8
8
  const agent_js_1 = require("../agents/agent.js");
9
+ const ai_agent_js_1 = require("../agents/ai-agent.js");
10
+ const chat_model_js_1 = require("../agents/chat-model.js");
11
+ const schema_js_1 = require("../loader/schema.js");
9
12
  const json_schema_js_1 = require("../utils/json-schema.js");
10
13
  const type_utils_js_1 = require("../utils/type-utils.js");
11
14
  const memory_message_template_js_1 = require("./prompts/memory-message-template.js");
@@ -37,11 +40,11 @@ class PromptBuilder {
37
40
  content = resource.text;
38
41
  }
39
42
  else if (typeof resource.blob === "string") {
40
- content = [{ type: "image_url", url: resource.blob }];
43
+ content = [{ type: "url", url: resource.blob }];
41
44
  }
42
45
  }
43
46
  else if (i.content.type === "image") {
44
- content = [{ type: "image_url", url: i.content.data }];
47
+ content = [{ type: "url", url: i.content.data }];
45
48
  }
46
49
  if (!content)
47
50
  throw new Error(`Unsupported content type ${i.content.type}`);
@@ -65,6 +68,7 @@ class PromptBuilder {
65
68
  responseFormat: options.agent?.structuredStreamMode
66
69
  ? undefined
67
70
  : this.buildResponseFormat(options),
71
+ fileOutputType: options.agent?.fileOutputType,
68
72
  ...this.buildTools(options),
69
73
  };
70
74
  }
@@ -83,6 +87,10 @@ class PromptBuilder {
83
87
  const messages = (await (typeof this.instructions === "string"
84
88
  ? template_js_1.ChatMessagesTemplate.from([template_js_1.SystemMessageTemplate.from(this.instructions)])
85
89
  : this.instructions)?.format(options.input, { workingDir: this.workingDir })) ?? [];
90
+ const fileInputKey = options.agent?.fileInputKey;
91
+ const files = (0, type_utils_js_1.flat)(fileInputKey
92
+ ? (0, type_utils_js_1.checkArguments)("Check input files", (0, schema_js_1.optionalize)(chat_model_js_1.fileUnionContentsSchema), input?.[fileInputKey])
93
+ : null);
86
94
  const memories = [];
87
95
  if (options.agent && options.context) {
88
96
  memories.push(...(await options.agent.retrieveMemories({ search: message }, { context: options.context })));
@@ -104,26 +112,68 @@ class PromptBuilder {
104
112
  },
105
113
  })));
106
114
  }
107
- if (message) {
108
- messages.push({
109
- role: "user",
110
- content: message,
111
- });
115
+ if (message || files.length) {
116
+ const content = [];
117
+ if (message)
118
+ content.push({ type: "text", text: message });
119
+ if (files.length)
120
+ content.push(...files);
121
+ messages.push({ role: "user", content });
112
122
  }
113
123
  return messages;
114
124
  }
115
125
  async convertMemoriesToMessages(memories, options) {
116
126
  const messages = [];
117
127
  const other = [];
128
+ const inputKey = options.agent?.inputKey;
129
+ const fileInputKey = options.agent?.fileInputKey;
130
+ const outputKey = options.agent?.outputKey || ai_agent_js_1.DEFAULT_OUTPUT_KEY;
131
+ const fileOutputKey = options.agent?.fileOutputKey || ai_agent_js_1.DEFAULT_FILE_OUTPUT_KEY;
118
132
  const stringOrStringify = (value) => typeof value === "string" ? value : (0, yaml_1.stringify)(value);
119
- for (const { content } of memories) {
120
- if ((0, type_utils_js_1.isRecord)(content) && "input" in content && "output" in content) {
121
- if (!(0, type_utils_js_1.isNil)(content.input) && content.input !== "") {
122
- messages.push({ role: "user", content: stringOrStringify(content.input) });
133
+ const convertMemoryToMessage = async (content) => {
134
+ const { input, output } = content;
135
+ if (!input || !output)
136
+ return [];
137
+ const result = [];
138
+ const userMessageContent = [];
139
+ if (typeof input === "object") {
140
+ const inputMessage = inputKey ? Reflect.get(input, inputKey) : undefined;
141
+ const inputFiles = fileInputKey ? Reflect.get(input, fileInputKey) : undefined;
142
+ if (inputMessage) {
143
+ userMessageContent.push({ type: "text", text: stringOrStringify(inputMessage) });
123
144
  }
124
- if (!(0, type_utils_js_1.isNil)(content.output) && content.output !== "") {
125
- messages.push({ role: "agent", content: stringOrStringify(content.output) });
145
+ if (inputFiles) {
146
+ userMessageContent.push(...(0, type_utils_js_1.flat)((0, type_utils_js_1.checkArguments)("Check memory input files", (0, schema_js_1.optionalize)(chat_model_js_1.fileUnionContentsSchema), inputFiles)));
147
+ }
148
+ }
149
+ if (!userMessageContent.length) {
150
+ userMessageContent.push({ type: "text", text: stringOrStringify(input) });
151
+ }
152
+ result.push({ role: "user", content: userMessageContent });
153
+ const agentMessageContent = [];
154
+ if (typeof output === "object") {
155
+ const outputMessage = Reflect.get(output, outputKey);
156
+ const outputFiles = Reflect.get(output, fileOutputKey);
157
+ if (outputMessage) {
158
+ agentMessageContent.push({ type: "text", text: stringOrStringify(outputMessage) });
126
159
  }
160
+ if (outputFiles) {
161
+ agentMessageContent.push(...(0, type_utils_js_1.flat)((0, type_utils_js_1.checkArguments)("Check memory output files", (0, schema_js_1.optionalize)(chat_model_js_1.fileUnionContentsSchema), outputFiles)));
162
+ }
163
+ }
164
+ if (!agentMessageContent.length) {
165
+ agentMessageContent.push({ type: "text", text: stringOrStringify(output) });
166
+ }
167
+ result.push({ role: "agent", content: agentMessageContent });
168
+ return result;
169
+ };
170
+ for (const { content } of memories) {
171
+ if ((0, type_utils_js_1.isRecord)(content) &&
172
+ "input" in content &&
173
+ content.input &&
174
+ "output" in content &&
175
+ content.output) {
176
+ messages.push(...(await convertMemoryToMessage(content)));
127
177
  }
128
178
  else {
129
179
  other.push(content);
@@ -1,9 +1,10 @@
1
1
  import { type ZodObject, type ZodType, z } from "zod";
2
2
  import { PromptBuilder } from "../prompt/prompt-builder.js";
3
3
  import { Agent, type AgentInvokeOptions, type AgentOptions, type AgentProcessAsyncGenerator, type Message } from "./agent.js";
4
- import type { ChatModel, ChatModelInput } from "./chat-model.js";
4
+ import type { ChatModel, ChatModelInput, FileOutputType } from "./chat-model.js";
5
5
  import type { GuideRailAgentOutput } from "./guide-rail-agent.js";
6
6
  export declare const DEFAULT_OUTPUT_KEY = "message";
7
+ export declare const DEFAULT_FILE_OUTPUT_KEY = "files";
7
8
  /**
8
9
  * Configuration options for an AI Agent
9
10
  *
@@ -31,12 +32,15 @@ export interface AIAgentOptions<I extends Message = Message, O extends Message =
31
32
  * Pick a message from input to use as the user's message
32
33
  */
33
34
  inputKey?: string;
35
+ fileInputKey?: string;
34
36
  /**
35
37
  * Custom key to use for text output in the response
36
38
  *
37
39
  * Defaults to `message` if not specified
38
40
  */
39
41
  outputKey?: string;
42
+ fileOutputKey?: string;
43
+ fileOutputType?: FileOutputType;
40
44
  /**
41
45
  * Controls how the agent uses tools during execution
42
46
  *
@@ -217,6 +221,7 @@ export declare class AIAgent<I extends Message = any, O extends Message = any> e
217
221
  * Pick a message from input to use as the user's message
218
222
  */
219
223
  inputKey?: string;
224
+ fileInputKey?: string;
220
225
  /**
221
226
  * Custom key to use for text output in the response
222
227
  *
@@ -225,6 +230,8 @@ export declare class AIAgent<I extends Message = any, O extends Message = any> e
225
230
  * {@includeCode ../../test/agents/ai-agent.test.ts#example-ai-agent-custom-output-key}
226
231
  */
227
232
  outputKey: string;
233
+ fileOutputKey: string;
234
+ fileOutputType?: FileOutputType;
228
235
  /**
229
236
  * Controls how the agent uses tools during execution
230
237
  *
@@ -104,6 +104,10 @@ export declare abstract class ChatModel extends Agent<ChatModelInput, ChatModelO
104
104
  * @returns A promise or direct value containing the model's response
105
105
  */
106
106
  abstract process(input: ChatModelInput, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<ChatModelOutput>>;
107
+ transformFileOutput(input: ChatModelInput, data: FileUnionContent, options: AgentInvokeOptions): Promise<FileUnionContent>;
108
+ static getFileExtension(type: string): string | undefined;
109
+ static getMimeType(filename: string): string | undefined;
110
+ protected downloadFile(url: string): Promise<Response>;
107
111
  }
108
112
  /**
109
113
  * Input message format for ChatModel
@@ -128,6 +132,7 @@ export interface ChatModelInput extends Message {
128
132
  * Specifies the expected response format
129
133
  */
130
134
  responseFormat?: ChatModelInputResponseFormat;
135
+ fileOutputType?: FileOutputType;
131
136
  /**
132
137
  * List of tools available for the model to use
133
138
  */
@@ -190,7 +195,7 @@ export interface ChatModelInputMessage {
190
195
  *
191
196
  * Can be a simple string, or a mixed array of text and image content
192
197
  */
193
- export type ChatModelInputMessageContent = string | (TextContent | ImageUrlContent)[];
198
+ export type ChatModelInputMessageContent = string | UnionContent[];
194
199
  /**
195
200
  * Text content type
196
201
  *
@@ -200,15 +205,304 @@ export type TextContent = {
200
205
  type: "text";
201
206
  text: string;
202
207
  };
208
+ export declare const textContentSchema: z.ZodObject<{
209
+ type: z.ZodLiteral<"text">;
210
+ text: z.ZodString;
211
+ }, "strip", z.ZodTypeAny, {
212
+ type: "text";
213
+ text: string;
214
+ }, {
215
+ type: "text";
216
+ text: string;
217
+ }>;
218
+ export interface FileContentBase {
219
+ filename?: string;
220
+ mimeType?: string;
221
+ }
222
+ export declare const fileContentBaseSchema: z.ZodObject<{
223
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
224
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
225
+ }, "strip", z.ZodTypeAny, {
226
+ filename?: string | undefined;
227
+ mimeType?: string | undefined;
228
+ }, {
229
+ filename?: string | undefined;
230
+ mimeType?: string | undefined;
231
+ }>;
203
232
  /**
204
233
  * Image URL content type
205
234
  *
206
235
  * Used for image parts of message content, referencing images via URL
207
236
  */
208
- export type ImageUrlContent = {
209
- type: "image_url";
237
+ export interface UrlContent extends FileContentBase {
238
+ type: "url";
210
239
  url: string;
211
- };
240
+ }
241
+ export declare const urlContentSchema: z.ZodObject<{
242
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
243
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
244
+ } & {
245
+ type: z.ZodLiteral<"url">;
246
+ url: z.ZodString;
247
+ }, "strip", z.ZodTypeAny, {
248
+ type: "url";
249
+ url: string;
250
+ filename?: string | undefined;
251
+ mimeType?: string | undefined;
252
+ }, {
253
+ type: "url";
254
+ url: string;
255
+ filename?: string | undefined;
256
+ mimeType?: string | undefined;
257
+ }>;
258
+ export interface FileContent extends FileContentBase {
259
+ type: "file";
260
+ data: string;
261
+ }
262
+ export declare const fileContentSchema: z.ZodObject<{
263
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
264
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
265
+ } & {
266
+ type: z.ZodLiteral<"file">;
267
+ data: z.ZodString;
268
+ }, "strip", z.ZodTypeAny, {
269
+ type: "file";
270
+ data: string;
271
+ filename?: string | undefined;
272
+ mimeType?: string | undefined;
273
+ }, {
274
+ type: "file";
275
+ data: string;
276
+ filename?: string | undefined;
277
+ mimeType?: string | undefined;
278
+ }>;
279
+ export interface LocalContent extends FileContentBase {
280
+ type: "local";
281
+ path: string;
282
+ }
283
+ export declare const localContentSchema: z.ZodObject<{
284
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
285
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
286
+ } & {
287
+ type: z.ZodLiteral<"local">;
288
+ path: z.ZodString;
289
+ }, "strip", z.ZodTypeAny, {
290
+ path: string;
291
+ type: "local";
292
+ filename?: string | undefined;
293
+ mimeType?: string | undefined;
294
+ }, {
295
+ path: string;
296
+ type: "local";
297
+ filename?: string | undefined;
298
+ mimeType?: string | undefined;
299
+ }>;
300
+ export type FileUnionContent = LocalContent | UrlContent | FileContent;
301
+ export declare const fileUnionContentSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
302
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
303
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
304
+ } & {
305
+ type: z.ZodLiteral<"local">;
306
+ path: z.ZodString;
307
+ }, "strip", z.ZodTypeAny, {
308
+ path: string;
309
+ type: "local";
310
+ filename?: string | undefined;
311
+ mimeType?: string | undefined;
312
+ }, {
313
+ path: string;
314
+ type: "local";
315
+ filename?: string | undefined;
316
+ mimeType?: string | undefined;
317
+ }>, z.ZodObject<{
318
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
319
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
320
+ } & {
321
+ type: z.ZodLiteral<"url">;
322
+ url: z.ZodString;
323
+ }, "strip", z.ZodTypeAny, {
324
+ type: "url";
325
+ url: string;
326
+ filename?: string | undefined;
327
+ mimeType?: string | undefined;
328
+ }, {
329
+ type: "url";
330
+ url: string;
331
+ filename?: string | undefined;
332
+ mimeType?: string | undefined;
333
+ }>, z.ZodObject<{
334
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
335
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
336
+ } & {
337
+ type: z.ZodLiteral<"file">;
338
+ data: z.ZodString;
339
+ }, "strip", z.ZodTypeAny, {
340
+ type: "file";
341
+ data: string;
342
+ filename?: string | undefined;
343
+ mimeType?: string | undefined;
344
+ }, {
345
+ type: "file";
346
+ data: string;
347
+ filename?: string | undefined;
348
+ mimeType?: string | undefined;
349
+ }>]>;
350
+ export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
351
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
352
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
353
+ } & {
354
+ type: z.ZodLiteral<"local">;
355
+ path: z.ZodString;
356
+ }, "strip", z.ZodTypeAny, {
357
+ path: string;
358
+ type: "local";
359
+ filename?: string | undefined;
360
+ mimeType?: string | undefined;
361
+ }, {
362
+ path: string;
363
+ type: "local";
364
+ filename?: string | undefined;
365
+ mimeType?: string | undefined;
366
+ }>, z.ZodObject<{
367
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
368
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
369
+ } & {
370
+ type: z.ZodLiteral<"url">;
371
+ url: z.ZodString;
372
+ }, "strip", z.ZodTypeAny, {
373
+ type: "url";
374
+ url: string;
375
+ filename?: string | undefined;
376
+ mimeType?: string | undefined;
377
+ }, {
378
+ type: "url";
379
+ url: string;
380
+ filename?: string | undefined;
381
+ mimeType?: string | undefined;
382
+ }>, z.ZodObject<{
383
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
384
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
385
+ } & {
386
+ type: z.ZodLiteral<"file">;
387
+ data: z.ZodString;
388
+ }, "strip", z.ZodTypeAny, {
389
+ type: "file";
390
+ data: string;
391
+ filename?: string | undefined;
392
+ mimeType?: string | undefined;
393
+ }, {
394
+ type: "file";
395
+ data: string;
396
+ filename?: string | undefined;
397
+ mimeType?: string | undefined;
398
+ }>]>, z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
399
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
400
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
401
+ } & {
402
+ type: z.ZodLiteral<"local">;
403
+ path: z.ZodString;
404
+ }, "strip", z.ZodTypeAny, {
405
+ path: string;
406
+ type: "local";
407
+ filename?: string | undefined;
408
+ mimeType?: string | undefined;
409
+ }, {
410
+ path: string;
411
+ type: "local";
412
+ filename?: string | undefined;
413
+ mimeType?: string | undefined;
414
+ }>, z.ZodObject<{
415
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
416
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
417
+ } & {
418
+ type: z.ZodLiteral<"url">;
419
+ url: z.ZodString;
420
+ }, "strip", z.ZodTypeAny, {
421
+ type: "url";
422
+ url: string;
423
+ filename?: string | undefined;
424
+ mimeType?: string | undefined;
425
+ }, {
426
+ type: "url";
427
+ url: string;
428
+ filename?: string | undefined;
429
+ mimeType?: string | undefined;
430
+ }>, z.ZodObject<{
431
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
432
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
433
+ } & {
434
+ type: z.ZodLiteral<"file">;
435
+ data: z.ZodString;
436
+ }, "strip", z.ZodTypeAny, {
437
+ type: "file";
438
+ data: string;
439
+ filename?: string | undefined;
440
+ mimeType?: string | undefined;
441
+ }, {
442
+ type: "file";
443
+ data: string;
444
+ filename?: string | undefined;
445
+ mimeType?: string | undefined;
446
+ }>]>, "many">]>;
447
+ export type UnionContent = TextContent | FileUnionContent;
448
+ export declare const unionContentSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
449
+ type: z.ZodLiteral<"text">;
450
+ text: z.ZodString;
451
+ }, "strip", z.ZodTypeAny, {
452
+ type: "text";
453
+ text: string;
454
+ }, {
455
+ type: "text";
456
+ text: string;
457
+ }>, z.ZodObject<{
458
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
459
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
460
+ } & {
461
+ type: z.ZodLiteral<"local">;
462
+ path: z.ZodString;
463
+ }, "strip", z.ZodTypeAny, {
464
+ path: string;
465
+ type: "local";
466
+ filename?: string | undefined;
467
+ mimeType?: string | undefined;
468
+ }, {
469
+ path: string;
470
+ type: "local";
471
+ filename?: string | undefined;
472
+ mimeType?: string | undefined;
473
+ }>, z.ZodObject<{
474
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
475
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
476
+ } & {
477
+ type: z.ZodLiteral<"url">;
478
+ url: z.ZodString;
479
+ }, "strip", z.ZodTypeAny, {
480
+ type: "url";
481
+ url: string;
482
+ filename?: string | undefined;
483
+ mimeType?: string | undefined;
484
+ }, {
485
+ type: "url";
486
+ url: string;
487
+ filename?: string | undefined;
488
+ mimeType?: string | undefined;
489
+ }>, z.ZodObject<{
490
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
491
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
492
+ } & {
493
+ type: z.ZodLiteral<"file">;
494
+ data: z.ZodString;
495
+ }, "strip", z.ZodTypeAny, {
496
+ type: "file";
497
+ data: string;
498
+ filename?: string | undefined;
499
+ mimeType?: string | undefined;
500
+ }, {
501
+ type: "file";
502
+ data: string;
503
+ filename?: string | undefined;
504
+ mimeType?: string | undefined;
505
+ }>]>;
212
506
  /**
213
507
  * Model response format settings
214
508
  *
@@ -277,6 +571,7 @@ export type ChatModelInputToolChoice = "auto" | "none" | "required" | {
277
571
  description?: string;
278
572
  };
279
573
  };
574
+ export type Modality = "text" | "image" | "audio";
280
575
  /**
281
576
  * Model-specific configuration options
282
577
  *
@@ -307,6 +602,7 @@ export interface ChatModelOptions {
307
602
  * Whether to allow parallel tool calls
308
603
  */
309
604
  parallelToolCalls?: boolean;
605
+ modalities?: Modality[];
310
606
  }
311
607
  /**
312
608
  * Output message format for ChatModel
@@ -342,6 +638,11 @@ export interface ChatModelOutput extends Message {
342
638
  * Model name or version used
343
639
  */
344
640
  model?: string;
641
+ files?: FileUnionContent[];
642
+ }
643
+ export declare enum FileOutputType {
644
+ local = "local",
645
+ file = "file"
345
646
  }
346
647
  /**
347
648
  * Tool call information in model output
@@ -32,13 +32,13 @@ export declare const imageModelInputSchema: z.ZodObject<{
32
32
  }, "strip", z.ZodTypeAny, {
33
33
  prompt: string;
34
34
  model?: string | undefined;
35
- responseFormat?: "url" | "base64" | undefined;
35
+ responseFormat?: "base64" | "url" | undefined;
36
36
  image?: string | string[] | undefined;
37
37
  n?: number | undefined;
38
38
  }, {
39
39
  prompt: string;
40
40
  model?: string | undefined;
41
- responseFormat?: "url" | "base64" | undefined;
41
+ responseFormat?: "base64" | "url" | undefined;
42
42
  image?: string | string[] | undefined;
43
43
  n?: number | undefined;
44
44
  }>;
@@ -1,7 +1,7 @@
1
1
  import type { GetPromptResult } from "@modelcontextprotocol/sdk/types.js";
2
2
  import { Agent, type AgentInvokeOptions, type Message } from "../agents/agent.js";
3
- import type { AIAgent } from "../agents/ai-agent.js";
4
- import type { ChatModel, ChatModelInput } from "../agents/chat-model.js";
3
+ import { type AIAgent } from "../agents/ai-agent.js";
4
+ import { type ChatModel, type ChatModelInput } from "../agents/chat-model.js";
5
5
  import { ChatMessagesTemplate } from "./template.js";
6
6
  export interface PromptBuilderOptions {
7
7
  instructions?: string | ChatMessagesTemplate;
@@ -1,9 +1,10 @@
1
1
  import { type ZodObject, type ZodType, z } from "zod";
2
2
  import { PromptBuilder } from "../prompt/prompt-builder.js";
3
3
  import { Agent, type AgentInvokeOptions, type AgentOptions, type AgentProcessAsyncGenerator, type Message } from "./agent.js";
4
- import type { ChatModel, ChatModelInput } from "./chat-model.js";
4
+ import type { ChatModel, ChatModelInput, FileOutputType } from "./chat-model.js";
5
5
  import type { GuideRailAgentOutput } from "./guide-rail-agent.js";
6
6
  export declare const DEFAULT_OUTPUT_KEY = "message";
7
+ export declare const DEFAULT_FILE_OUTPUT_KEY = "files";
7
8
  /**
8
9
  * Configuration options for an AI Agent
9
10
  *
@@ -31,12 +32,15 @@ export interface AIAgentOptions<I extends Message = Message, O extends Message =
31
32
  * Pick a message from input to use as the user's message
32
33
  */
33
34
  inputKey?: string;
35
+ fileInputKey?: string;
34
36
  /**
35
37
  * Custom key to use for text output in the response
36
38
  *
37
39
  * Defaults to `message` if not specified
38
40
  */
39
41
  outputKey?: string;
42
+ fileOutputKey?: string;
43
+ fileOutputType?: FileOutputType;
40
44
  /**
41
45
  * Controls how the agent uses tools during execution
42
46
  *
@@ -217,6 +221,7 @@ export declare class AIAgent<I extends Message = any, O extends Message = any> e
217
221
  * Pick a message from input to use as the user's message
218
222
  */
219
223
  inputKey?: string;
224
+ fileInputKey?: string;
220
225
  /**
221
226
  * Custom key to use for text output in the response
222
227
  *
@@ -225,6 +230,8 @@ export declare class AIAgent<I extends Message = any, O extends Message = any> e
225
230
  * {@includeCode ../../test/agents/ai-agent.test.ts#example-ai-agent-custom-output-key}
226
231
  */
227
232
  outputKey: string;
233
+ fileOutputKey: string;
234
+ fileOutputType?: FileOutputType;
228
235
  /**
229
236
  * Controls how the agent uses tools during execution
230
237
  *