@aigne/core 1.60.3 → 1.61.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/lib/cjs/agents/ai-agent.d.ts +9 -8
  3. package/lib/cjs/agents/ai-agent.js +9 -9
  4. package/lib/cjs/agents/chat-model.d.ts +14 -250
  5. package/lib/cjs/agents/chat-model.js +11 -101
  6. package/lib/cjs/agents/image-agent.d.ts +3 -0
  7. package/lib/cjs/agents/image-agent.js +5 -1
  8. package/lib/cjs/agents/image-model.d.ts +164 -30
  9. package/lib/cjs/agents/image-model.js +29 -29
  10. package/lib/cjs/agents/model.d.ts +236 -0
  11. package/lib/cjs/agents/model.js +103 -0
  12. package/lib/cjs/index.d.ts +1 -0
  13. package/lib/cjs/index.js +1 -0
  14. package/lib/cjs/loader/agent-js.d.ts +1 -2
  15. package/lib/cjs/loader/agent-js.js +4 -4
  16. package/lib/cjs/loader/index.d.ts +0 -1
  17. package/lib/cjs/loader/index.js +1 -2
  18. package/lib/cjs/prompt/prompt-builder.d.ts +1 -1
  19. package/lib/cjs/prompt/prompt-builder.js +11 -11
  20. package/lib/dts/agents/ai-agent.d.ts +9 -8
  21. package/lib/dts/agents/chat-model.d.ts +14 -250
  22. package/lib/dts/agents/image-agent.d.ts +3 -0
  23. package/lib/dts/agents/image-model.d.ts +164 -30
  24. package/lib/dts/agents/model.d.ts +236 -0
  25. package/lib/dts/index.d.ts +1 -0
  26. package/lib/dts/loader/agent-js.d.ts +1 -2
  27. package/lib/dts/loader/index.d.ts +0 -1
  28. package/lib/dts/prompt/prompt-builder.d.ts +1 -1
  29. package/lib/esm/agents/ai-agent.d.ts +9 -8
  30. package/lib/esm/agents/ai-agent.js +8 -8
  31. package/lib/esm/agents/chat-model.d.ts +14 -250
  32. package/lib/esm/agents/chat-model.js +7 -94
  33. package/lib/esm/agents/image-agent.d.ts +3 -0
  34. package/lib/esm/agents/image-agent.js +5 -1
  35. package/lib/esm/agents/image-model.d.ts +164 -30
  36. package/lib/esm/agents/image-model.js +29 -29
  37. package/lib/esm/agents/model.d.ts +236 -0
  38. package/lib/esm/agents/model.js +96 -0
  39. package/lib/esm/index.d.ts +1 -0
  40. package/lib/esm/index.js +1 -0
  41. package/lib/esm/loader/agent-js.d.ts +1 -2
  42. package/lib/esm/loader/agent-js.js +4 -4
  43. package/lib/esm/loader/index.d.ts +0 -1
  44. package/lib/esm/loader/index.js +1 -2
  45. package/lib/esm/prompt/prompt-builder.d.ts +1 -1
  46. package/lib/esm/prompt/prompt-builder.js +10 -10
  47. package/package.json +2 -2
@@ -2,9 +2,11 @@ import { type ZodObject, type ZodType } from "zod";
2
2
  import { PromptBuilder } from "../prompt/prompt-builder.js";
3
3
  import { Agent, type AgentInvokeOptions, type AgentOptions, type Message } from "./agent.js";
4
4
  import { type ImageModelOutput } from "./image-model.js";
5
+ import { type FileType } from "./model.js";
5
6
  export interface ImageAgentOptions<I extends Message = any, O extends ImageModelOutput = any> extends Omit<AgentOptions<I, O>, "outputSchema"> {
6
7
  instructions: string | PromptBuilder;
7
8
  modelOptions?: Record<string, any>;
9
+ outputFileType?: FileType;
8
10
  }
9
11
  export declare const imageAgentOptionsSchema: ZodObject<{
10
12
  [key in keyof ImageAgentOptions]: ZodType<ImageAgentOptions[key]>;
@@ -15,5 +17,6 @@ export declare class ImageAgent<I extends Message = any, O extends ImageModelOut
15
17
  constructor(options: ImageAgentOptions<I, O>);
16
18
  instructions: PromptBuilder;
17
19
  modelOptions?: Record<string, any>;
20
+ outputFileType?: FileType;
18
21
  process(input: I, options: AgentInvokeOptions): Promise<O>;
19
22
  }
@@ -9,9 +9,11 @@ const prompt_builder_js_1 = require("../prompt/prompt-builder.js");
9
9
  const type_utils_js_1 = require("../utils/type-utils.js");
10
10
  const agent_js_1 = require("./agent.js");
11
11
  const image_model_js_1 = require("./image-model.js");
12
+ const model_js_1 = require("./model.js");
12
13
  exports.imageAgentOptionsSchema = agent_js_1.agentOptionsSchema.extend({
13
14
  instructions: zod_1.default.union([zod_1.default.string(), zod_1.default.custom()]),
14
15
  modelOptions: zod_1.default.record(zod_1.default.any()).optional(),
16
+ outputFileType: model_js_1.fileTypeSchema.optional(),
15
17
  });
16
18
  class ImageAgent extends agent_js_1.Agent {
17
19
  tag = "ImageAgent";
@@ -26,15 +28,17 @@ class ImageAgent extends agent_js_1.Agent {
26
28
  ? prompt_builder_js_1.PromptBuilder.from(options.instructions)
27
29
  : options.instructions;
28
30
  this.modelOptions = options.modelOptions;
31
+ this.outputFileType = options.outputFileType;
29
32
  }
30
33
  instructions;
31
34
  modelOptions;
35
+ outputFileType;
32
36
  async process(input, options) {
33
37
  const imageModel = this.imageModel || options.imageModel || options.context.imageModel;
34
38
  if (!imageModel)
35
39
  throw new Error("image model is required to run ImageAgent");
36
40
  const { prompt } = await this.instructions.buildImagePrompt({ input });
37
- return (await this.invokeChildAgent(imageModel, { ...input, ...this.modelOptions, prompt }, { ...options, streaming: false }));
41
+ return (await this.invokeChildAgent(imageModel, { ...input, modelOptions: this.modelOptions, prompt, outputFileType: this.outputFileType }, { ...options, streaming: false }));
38
42
  }
39
43
  }
40
44
  exports.ImageAgent = ImageAgent;
@@ -1,10 +1,11 @@
1
- import { z } from "zod";
1
+ import { type ZodType, z } from "zod";
2
2
  import type { PromiseOrValue } from "../utils/type-utils.js";
3
- import { Agent, type AgentInvokeOptions, type AgentOptions, type AgentProcessResult, type Message } from "./agent.js";
3
+ import type { AgentInvokeOptions, AgentOptions, AgentProcessResult, AgentResponse, AgentResponseStream, Message } from "./agent.js";
4
4
  import { type ChatModelOutputUsage } from "./chat-model.js";
5
+ import { type FileType, type FileUnionContent, Model } from "./model.js";
5
6
  export interface ImageModelOptions<I extends ImageModelInput = ImageModelInput, O extends ImageModelOutput = ImageModelOutput> extends Omit<AgentOptions<I, O>, "model"> {
6
7
  }
7
- export declare abstract class ImageModel<I extends ImageModelInput = ImageModelInput, O extends ImageModelOutput = ImageModelOutput> extends Agent<I, O> {
8
+ export declare abstract class ImageModel<I extends ImageModelInput = ImageModelInput, O extends ImageModelOutput = ImageModelOutput> extends Model<I, O> {
8
9
  tag: string;
9
10
  constructor(options?: ImageModelOptions<I, O>);
10
11
  get credential(): PromiseOrValue<{
@@ -15,36 +16,118 @@ export declare abstract class ImageModel<I extends ImageModelInput = ImageModelI
15
16
  protected preprocess(input: I, options: AgentInvokeOptions): Promise<void>;
16
17
  protected postprocess(input: I, output: O, options: AgentInvokeOptions): Promise<void>;
17
18
  abstract process(input: I, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<O>>;
18
- protected downloadFile(url: string, timeout?: number): Promise<Response>;
19
+ protected processAgentOutput(input: I, output: Exclude<AgentResponse<O>, AgentResponseStream<O>>, options: AgentInvokeOptions): Promise<O>;
19
20
  }
21
+ export type ImageModelInputImage = FileUnionContent[];
20
22
  export interface ImageModelInput extends Message {
21
- model?: string;
22
- image?: string | string[];
23
23
  prompt: string;
24
+ image?: ImageModelInputImage;
24
25
  n?: number;
25
- responseFormat?: "url" | "base64";
26
+ outputFileType?: FileType;
27
+ modelOptions?: ImageModelInputOptions;
28
+ }
29
+ export interface ImageModelInputOptions extends Record<string, unknown> {
30
+ model?: string;
26
31
  }
27
32
  export declare const imageModelInputSchema: z.ZodObject<{
28
- model: z.ZodOptional<z.ZodString>;
29
- image: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
30
33
  prompt: z.ZodString;
34
+ image: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
35
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
36
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
37
+ } & {
38
+ type: z.ZodLiteral<"local">;
39
+ path: z.ZodString;
40
+ }, "strip", z.ZodTypeAny, {
41
+ path: string;
42
+ type: "local";
43
+ filename?: string | undefined;
44
+ mimeType?: string | undefined;
45
+ }, {
46
+ path: string;
47
+ type: "local";
48
+ filename?: string | undefined;
49
+ mimeType?: string | undefined;
50
+ }>, z.ZodObject<{
51
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
52
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
53
+ } & {
54
+ type: z.ZodLiteral<"url">;
55
+ url: z.ZodString;
56
+ }, "strip", z.ZodTypeAny, {
57
+ type: "url";
58
+ url: string;
59
+ filename?: string | undefined;
60
+ mimeType?: string | undefined;
61
+ }, {
62
+ type: "url";
63
+ url: string;
64
+ filename?: string | undefined;
65
+ mimeType?: string | undefined;
66
+ }>, z.ZodObject<{
67
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
68
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
69
+ } & {
70
+ type: z.ZodLiteral<"file">;
71
+ data: z.ZodString;
72
+ }, "strip", z.ZodTypeAny, {
73
+ type: "file";
74
+ data: string;
75
+ filename?: string | undefined;
76
+ mimeType?: string | undefined;
77
+ }, {
78
+ type: "file";
79
+ data: string;
80
+ filename?: string | undefined;
81
+ mimeType?: string | undefined;
82
+ }>]>, "many">>;
31
83
  n: z.ZodOptional<z.ZodNumber>;
32
- responseFormat: z.ZodOptional<z.ZodEnum<["url", "base64"]>>;
84
+ outputFileType: z.ZodOptional<z.ZodEnum<["local", "file"]>>;
85
+ modelOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
33
86
  }, "strip", z.ZodTypeAny, {
34
87
  prompt: string;
35
- model?: string | undefined;
36
- image?: string | string[] | undefined;
37
- responseFormat?: "base64" | "url" | undefined;
88
+ modelOptions?: Record<string, unknown> | undefined;
89
+ image?: ({
90
+ type: "url";
91
+ url: string;
92
+ filename?: string | undefined;
93
+ mimeType?: string | undefined;
94
+ } | {
95
+ type: "file";
96
+ data: string;
97
+ filename?: string | undefined;
98
+ mimeType?: string | undefined;
99
+ } | {
100
+ path: string;
101
+ type: "local";
102
+ filename?: string | undefined;
103
+ mimeType?: string | undefined;
104
+ })[] | undefined;
105
+ outputFileType?: "local" | "file" | undefined;
38
106
  n?: number | undefined;
39
107
  }, {
40
108
  prompt: string;
41
- model?: string | undefined;
42
- image?: string | string[] | undefined;
43
- responseFormat?: "base64" | "url" | undefined;
109
+ modelOptions?: Record<string, unknown> | undefined;
110
+ image?: ({
111
+ type: "url";
112
+ url: string;
113
+ filename?: string | undefined;
114
+ mimeType?: string | undefined;
115
+ } | {
116
+ type: "file";
117
+ data: string;
118
+ filename?: string | undefined;
119
+ mimeType?: string | undefined;
120
+ } | {
121
+ path: string;
122
+ type: "local";
123
+ filename?: string | undefined;
124
+ mimeType?: string | undefined;
125
+ })[] | undefined;
126
+ outputFileType?: "local" | "file" | undefined;
44
127
  n?: number | undefined;
45
128
  }>;
46
129
  export interface ImageModelOutput extends Message {
47
- images: ImageModelOutputImage[];
130
+ images: FileUnionContent[];
48
131
  /**
49
132
  * Token usage statistics
50
133
  */
@@ -54,26 +137,55 @@ export interface ImageModelOutput extends Message {
54
137
  */
55
138
  model?: string;
56
139
  }
57
- export type ImageModelOutputImage = ImageModelOutputImageUrl | ImageModelOutputImageBase64;
58
- export interface ImageModelOutputImageUrl {
59
- url: string;
60
- }
61
- export interface ImageModelOutputImageBase64 {
62
- base64: string;
63
- }
64
140
  export declare const imageModelOutputSchema: z.ZodObject<{
65
- images: z.ZodArray<z.ZodUnion<[z.ZodObject<{
141
+ images: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
142
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
143
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
144
+ } & {
145
+ type: z.ZodLiteral<"local">;
146
+ path: z.ZodString;
147
+ }, "strip", z.ZodTypeAny, {
148
+ path: string;
149
+ type: "local";
150
+ filename?: string | undefined;
151
+ mimeType?: string | undefined;
152
+ }, {
153
+ path: string;
154
+ type: "local";
155
+ filename?: string | undefined;
156
+ mimeType?: string | undefined;
157
+ }>, z.ZodObject<{
158
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
159
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
160
+ } & {
161
+ type: z.ZodLiteral<"url">;
66
162
  url: z.ZodString;
67
163
  }, "strip", z.ZodTypeAny, {
164
+ type: "url";
68
165
  url: string;
166
+ filename?: string | undefined;
167
+ mimeType?: string | undefined;
69
168
  }, {
169
+ type: "url";
70
170
  url: string;
171
+ filename?: string | undefined;
172
+ mimeType?: string | undefined;
71
173
  }>, z.ZodObject<{
72
- base64: z.ZodString;
174
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
175
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
176
+ } & {
177
+ type: z.ZodLiteral<"file">;
178
+ data: z.ZodString;
73
179
  }, "strip", z.ZodTypeAny, {
74
- base64: string;
180
+ type: "file";
181
+ data: string;
182
+ filename?: string | undefined;
183
+ mimeType?: string | undefined;
75
184
  }, {
76
- base64: string;
185
+ type: "file";
186
+ data: string;
187
+ filename?: string | undefined;
188
+ mimeType?: string | undefined;
77
189
  }>]>, "many">;
78
190
  usage: z.ZodOptional<z.ZodObject<{
79
191
  inputTokens: z.ZodNumber;
@@ -91,9 +203,20 @@ export declare const imageModelOutputSchema: z.ZodObject<{
91
203
  model: z.ZodOptional<z.ZodString>;
92
204
  }, "strip", z.ZodTypeAny, {
93
205
  images: ({
206
+ type: "url";
94
207
  url: string;
208
+ filename?: string | undefined;
209
+ mimeType?: string | undefined;
210
+ } | {
211
+ type: "file";
212
+ data: string;
213
+ filename?: string | undefined;
214
+ mimeType?: string | undefined;
95
215
  } | {
96
- base64: string;
216
+ path: string;
217
+ type: "local";
218
+ filename?: string | undefined;
219
+ mimeType?: string | undefined;
97
220
  })[];
98
221
  model?: string | undefined;
99
222
  usage?: {
@@ -103,9 +226,20 @@ export declare const imageModelOutputSchema: z.ZodObject<{
103
226
  } | undefined;
104
227
  }, {
105
228
  images: ({
229
+ type: "url";
106
230
  url: string;
231
+ filename?: string | undefined;
232
+ mimeType?: string | undefined;
233
+ } | {
234
+ type: "file";
235
+ data: string;
236
+ filename?: string | undefined;
237
+ mimeType?: string | undefined;
107
238
  } | {
108
- base64: string;
239
+ path: string;
240
+ type: "local";
241
+ filename?: string | undefined;
242
+ mimeType?: string | undefined;
109
243
  })[];
110
244
  model?: string | undefined;
111
245
  usage?: {
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.imageModelOutputSchema = exports.imageModelInputSchema = exports.ImageModel = void 0;
4
+ const index_js_1 = require("@aigne/platform-helpers/nodejs/index.js");
4
5
  const zod_1 = require("zod");
5
- const agent_js_1 = require("./agent.js");
6
6
  const chat_model_js_1 = require("./chat-model.js");
7
- class ImageModel extends agent_js_1.Agent {
7
+ const model_js_1 = require("./model.js");
8
+ class ImageModel extends model_js_1.Model {
8
9
  tag = "ImageModelAgent";
9
10
  constructor(options) {
10
11
  super({
@@ -23,6 +24,20 @@ class ImageModel extends agent_js_1.Agent {
23
24
  if (limits?.maxTokens && usedTokens >= limits.maxTokens) {
24
25
  throw new Error(`Exceeded max tokens ${usedTokens}/${limits.maxTokens}`);
25
26
  }
27
+ if (input.image) {
28
+ input.image = await Promise.all(input.image.map(async (item) => {
29
+ if (item.type === "local") {
30
+ return {
31
+ ...item,
32
+ type: "file",
33
+ data: await index_js_1.nodejs.fs.readFile(item.path, "base64"),
34
+ path: undefined,
35
+ mimeType: item.mimeType || ImageModel.getMimeType(item.filename || item.path),
36
+ };
37
+ }
38
+ return item;
39
+ }));
40
+ }
26
41
  }
27
42
  async postprocess(input, output, options) {
28
43
  super.postprocess(input, output, options);
@@ -34,42 +49,27 @@ class ImageModel extends agent_js_1.Agent {
34
49
  options.context.usage.aigneHubCredits += usage.aigneHubCredits;
35
50
  }
36
51
  }
37
- async downloadFile(url, timeout = 30000) {
38
- const controller = new AbortController();
39
- const timeoutId = setTimeout(() => controller.abort(), timeout);
40
- try {
41
- const response = await fetch(url, { signal: controller.signal });
42
- if (!response.ok) {
43
- const text = await response.text().catch(() => null);
44
- throw new Error(`Failed to download content from ${url}, ${response.status} ${response.statusText} ${text}`);
45
- }
46
- return response;
47
- }
48
- finally {
49
- clearTimeout(timeoutId);
52
+ async processAgentOutput(input, output, options) {
53
+ if (output.images) {
54
+ const images = zod_1.z.array(model_js_1.fileUnionContentSchema).parse(output.images);
55
+ output = {
56
+ ...output,
57
+ images: await Promise.all(images.map((image) => this.transformFileType(input.outputFileType, image, options))),
58
+ };
50
59
  }
60
+ return super.processAgentOutput(input, output, options);
51
61
  }
52
62
  }
53
63
  exports.ImageModel = ImageModel;
54
64
  exports.imageModelInputSchema = zod_1.z.object({
55
- model: zod_1.z.string().optional(),
56
- image: zod_1.z
57
- .union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())])
58
- .optional()
59
- .describe("Image URL or base64 string(s) used for editing"),
60
65
  prompt: zod_1.z.string(),
66
+ image: zod_1.z.array(model_js_1.fileUnionContentSchema).optional().describe("Images used for editing"),
61
67
  n: zod_1.z.number().int().min(1).optional(),
62
- responseFormat: zod_1.z.enum(["url", "base64"]).optional(),
68
+ outputFileType: model_js_1.fileTypeSchema.optional(),
69
+ modelOptions: zod_1.z.record(zod_1.z.unknown()).optional(),
63
70
  });
64
71
  exports.imageModelOutputSchema = zod_1.z.object({
65
- images: zod_1.z.array(zod_1.z.union([
66
- zod_1.z.object({
67
- url: zod_1.z.string(),
68
- }),
69
- zod_1.z.object({
70
- base64: zod_1.z.string(),
71
- }),
72
- ])),
72
+ images: zod_1.z.array(model_js_1.fileUnionContentSchema),
73
73
  usage: chat_model_js_1.chatModelOutputUsageSchema.optional(),
74
74
  model: zod_1.z.string().optional(),
75
75
  });
@@ -0,0 +1,236 @@
1
+ import { z } from "zod";
2
+ import { Agent, type AgentInvokeOptions, type Message } from "./agent.js";
3
+ export declare abstract class Model<I extends Message = any, O extends Message = any> extends Agent<I, O> {
4
+ transformFileType(fileType: "file", data: FileUnionContent, options: AgentInvokeOptions): Promise<FileContent>;
5
+ transformFileType(fileType: "local" | undefined, data: FileUnionContent, options: AgentInvokeOptions): Promise<LocalContent>;
6
+ transformFileType(fileType: FileType | undefined, data: FileUnionContent, options: AgentInvokeOptions): Promise<FileUnionContent>;
7
+ static getFileExtension(type: string): string | undefined;
8
+ static getMimeType(filename: string): string | undefined;
9
+ downloadFile(url: string): Promise<Response>;
10
+ }
11
+ export type FileType = "local" | "file";
12
+ export declare const fileTypeSchema: z.ZodEnum<["local", "file"]>;
13
+ export interface FileContentBase {
14
+ filename?: string;
15
+ mimeType?: string;
16
+ }
17
+ export declare const fileContentBaseSchema: z.ZodObject<{
18
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
19
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ filename?: string | undefined;
22
+ mimeType?: string | undefined;
23
+ }, {
24
+ filename?: string | undefined;
25
+ mimeType?: string | undefined;
26
+ }>;
27
+ export interface UrlContent extends FileContentBase {
28
+ type: "url";
29
+ url: string;
30
+ }
31
+ export declare const urlContentSchema: z.ZodObject<{
32
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
33
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
34
+ } & {
35
+ type: z.ZodLiteral<"url">;
36
+ url: z.ZodString;
37
+ }, "strip", z.ZodTypeAny, {
38
+ type: "url";
39
+ url: string;
40
+ filename?: string | undefined;
41
+ mimeType?: string | undefined;
42
+ }, {
43
+ type: "url";
44
+ url: string;
45
+ filename?: string | undefined;
46
+ mimeType?: string | undefined;
47
+ }>;
48
+ export interface FileContent extends FileContentBase {
49
+ type: "file";
50
+ data: string;
51
+ }
52
+ export declare const fileContentSchema: z.ZodObject<{
53
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
54
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
55
+ } & {
56
+ type: z.ZodLiteral<"file">;
57
+ data: z.ZodString;
58
+ }, "strip", z.ZodTypeAny, {
59
+ type: "file";
60
+ data: string;
61
+ filename?: string | undefined;
62
+ mimeType?: string | undefined;
63
+ }, {
64
+ type: "file";
65
+ data: string;
66
+ filename?: string | undefined;
67
+ mimeType?: string | undefined;
68
+ }>;
69
+ export interface LocalContent extends FileContentBase {
70
+ type: "local";
71
+ path: string;
72
+ }
73
+ export declare const localContentSchema: z.ZodObject<{
74
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
75
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
76
+ } & {
77
+ type: z.ZodLiteral<"local">;
78
+ path: z.ZodString;
79
+ }, "strip", z.ZodTypeAny, {
80
+ path: string;
81
+ type: "local";
82
+ filename?: string | undefined;
83
+ mimeType?: string | undefined;
84
+ }, {
85
+ path: string;
86
+ type: "local";
87
+ filename?: string | undefined;
88
+ mimeType?: string | undefined;
89
+ }>;
90
+ export type FileUnionContent = LocalContent | UrlContent | FileContent;
91
+ export declare const fileUnionContentSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
92
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
93
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
94
+ } & {
95
+ type: z.ZodLiteral<"local">;
96
+ path: z.ZodString;
97
+ }, "strip", z.ZodTypeAny, {
98
+ path: string;
99
+ type: "local";
100
+ filename?: string | undefined;
101
+ mimeType?: string | undefined;
102
+ }, {
103
+ path: string;
104
+ type: "local";
105
+ filename?: string | undefined;
106
+ mimeType?: string | undefined;
107
+ }>, z.ZodObject<{
108
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
109
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
110
+ } & {
111
+ type: z.ZodLiteral<"url">;
112
+ url: z.ZodString;
113
+ }, "strip", z.ZodTypeAny, {
114
+ type: "url";
115
+ url: string;
116
+ filename?: string | undefined;
117
+ mimeType?: string | undefined;
118
+ }, {
119
+ type: "url";
120
+ url: string;
121
+ filename?: string | undefined;
122
+ mimeType?: string | undefined;
123
+ }>, z.ZodObject<{
124
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
125
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
126
+ } & {
127
+ type: z.ZodLiteral<"file">;
128
+ data: z.ZodString;
129
+ }, "strip", z.ZodTypeAny, {
130
+ type: "file";
131
+ data: string;
132
+ filename?: string | undefined;
133
+ mimeType?: string | undefined;
134
+ }, {
135
+ type: "file";
136
+ data: string;
137
+ filename?: string | undefined;
138
+ mimeType?: string | undefined;
139
+ }>]>;
140
+ export declare const fileUnionContentsSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
141
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
142
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
143
+ } & {
144
+ type: z.ZodLiteral<"local">;
145
+ path: z.ZodString;
146
+ }, "strip", z.ZodTypeAny, {
147
+ path: string;
148
+ type: "local";
149
+ filename?: string | undefined;
150
+ mimeType?: string | undefined;
151
+ }, {
152
+ path: string;
153
+ type: "local";
154
+ filename?: string | undefined;
155
+ mimeType?: string | undefined;
156
+ }>, z.ZodObject<{
157
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
158
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
159
+ } & {
160
+ type: z.ZodLiteral<"url">;
161
+ url: z.ZodString;
162
+ }, "strip", z.ZodTypeAny, {
163
+ type: "url";
164
+ url: string;
165
+ filename?: string | undefined;
166
+ mimeType?: string | undefined;
167
+ }, {
168
+ type: "url";
169
+ url: string;
170
+ filename?: string | undefined;
171
+ mimeType?: string | undefined;
172
+ }>, z.ZodObject<{
173
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
174
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
175
+ } & {
176
+ type: z.ZodLiteral<"file">;
177
+ data: z.ZodString;
178
+ }, "strip", z.ZodTypeAny, {
179
+ type: "file";
180
+ data: string;
181
+ filename?: string | undefined;
182
+ mimeType?: string | undefined;
183
+ }, {
184
+ type: "file";
185
+ data: string;
186
+ filename?: string | undefined;
187
+ mimeType?: string | undefined;
188
+ }>]>, z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
189
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
190
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
191
+ } & {
192
+ type: z.ZodLiteral<"local">;
193
+ path: z.ZodString;
194
+ }, "strip", z.ZodTypeAny, {
195
+ path: string;
196
+ type: "local";
197
+ filename?: string | undefined;
198
+ mimeType?: string | undefined;
199
+ }, {
200
+ path: string;
201
+ type: "local";
202
+ filename?: string | undefined;
203
+ mimeType?: string | undefined;
204
+ }>, z.ZodObject<{
205
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
206
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
207
+ } & {
208
+ type: z.ZodLiteral<"url">;
209
+ url: z.ZodString;
210
+ }, "strip", z.ZodTypeAny, {
211
+ type: "url";
212
+ url: string;
213
+ filename?: string | undefined;
214
+ mimeType?: string | undefined;
215
+ }, {
216
+ type: "url";
217
+ url: string;
218
+ filename?: string | undefined;
219
+ mimeType?: string | undefined;
220
+ }>, z.ZodObject<{
221
+ filename: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
222
+ mimeType: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
223
+ } & {
224
+ type: z.ZodLiteral<"file">;
225
+ data: z.ZodString;
226
+ }, "strip", z.ZodTypeAny, {
227
+ type: "file";
228
+ data: string;
229
+ filename?: string | undefined;
230
+ mimeType?: string | undefined;
231
+ }, {
232
+ type: "file";
233
+ data: string;
234
+ filename?: string | undefined;
235
+ mimeType?: string | undefined;
236
+ }>]>, "many">]>;