@aigne/core 1.65.0-beta.3 → 1.65.0-beta.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.65.0-beta.5](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.65.0-beta.4...core-v1.65.0-beta.5) (2025-10-31)
4
+
5
+
6
+ ### Features
7
+
8
+ * **core:** add json/yaml stringify filters for prompt template ([#685](https://github.com/AIGNE-io/aigne-framework/issues/685)) ([4e414bf](https://github.com/AIGNE-io/aigne-framework/commit/4e414bf5a43d0677fb16fcdceacaed501542ee85))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **models:** add image parameters support for video generation ([#684](https://github.com/AIGNE-io/aigne-framework/issues/684)) ([b048b7f](https://github.com/AIGNE-io/aigne-framework/commit/b048b7f92bd7a532dbdbeb6fb5fa5499bae6b953))
14
+
15
+
16
+ ### Dependencies
17
+
18
+ * The following workspace dependencies were updated
19
+ * dependencies
20
+ * @aigne/observability-api bumped to 0.11.4-beta.2
21
+
22
+ ## [1.65.0-beta.4](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.65.0-beta.3...core-v1.65.0-beta.4) (2025-10-29)
23
+
24
+
25
+ ### Features
26
+
27
+ * add reasoningEffort option for chat model ([#680](https://github.com/AIGNE-io/aigne-framework/issues/680)) ([f69d232](https://github.com/AIGNE-io/aigne-framework/commit/f69d232d714d4a3e4946bdc8c6598747c9bcbd57))
28
+
29
+
30
+ ### Dependencies
31
+
32
+ * The following workspace dependencies were updated
33
+ * dependencies
34
+ * @aigne/observability-api bumped to 0.11.4-beta.1
35
+
3
36
  ## [1.65.0-beta.3](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.65.0-beta.2...core-v1.65.0-beta.3) (2025-10-28)
4
37
 
5
38
 
@@ -341,7 +341,7 @@ class AIAgent extends agent_js_1.Agent {
341
341
  }
342
342
  const { toolCalls, json, text, files } = modelOutput;
343
343
  if (toolCalls?.length) {
344
- if (!this.keepTextInToolUses) {
344
+ if (this.keepTextInToolUses !== true) {
345
345
  yield { delta: { json: { [outputKey]: "" } } };
346
346
  }
347
347
  else {
@@ -388,6 +388,7 @@ export interface ChatModelInputOptions {
388
388
  parallelToolCalls?: boolean;
389
389
  modalities?: Modality[];
390
390
  preferInputFileType?: "file" | "url";
391
+ reasoningEffort?: number | "minimal" | "low" | "medium" | "high";
391
392
  }
392
393
  /**
393
394
  * Output message format for ChatModel
@@ -337,6 +337,15 @@ const modelOptionsSchema = zod_1.z.object({
337
337
  presencePenalty: zod_1.z.number().optional(),
338
338
  parallelToolCalls: zod_1.z.boolean().optional().default(true),
339
339
  modalities: zod_1.z.array(zod_1.z.enum(["text", "image", "audio"])).optional(),
340
+ reasoningEffort: zod_1.z
341
+ .union([
342
+ zod_1.z.number(),
343
+ zod_1.z.literal("minimal"),
344
+ zod_1.z.literal("low"),
345
+ zod_1.z.literal("medium"),
346
+ zod_1.z.literal("high"),
347
+ ])
348
+ .optional(),
340
349
  });
341
350
  const chatModelOptionsSchema = agent_js_1.agentOptionsSchema.extend({
342
351
  model: zod_1.z.string().optional(),
@@ -28,6 +28,7 @@ export interface VideoModelInput extends Message {
28
28
  seconds?: string;
29
29
  outputFileType?: FileType;
30
30
  modelOptions?: VideoModelInputOptions;
31
+ image?: FileUnionContent;
31
32
  }
32
33
  export interface VideoModelInputOptions extends Record<string, unknown> {
33
34
  model?: string;
@@ -39,10 +40,75 @@ export declare const videoModelInputSchema: z.ZodObject<{
39
40
  seconds: z.ZodOptional<z.ZodString>;
40
41
  outputFileType: z.ZodOptional<z.ZodEnum<["local", "file", "url"]>>;
41
42
  modelOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
43
+ image: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
44
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
45
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
46
+ } & {
47
+ type: z.ZodLiteral<"local">;
48
+ path: z.ZodString;
49
+ }, "strip", z.ZodTypeAny, {
50
+ path: string;
51
+ type: "local";
52
+ filename?: string | undefined;
53
+ mimeType?: string | undefined;
54
+ }, {
55
+ path: string;
56
+ type: "local";
57
+ filename?: string | undefined;
58
+ mimeType?: string | undefined;
59
+ }>, z.ZodObject<{
60
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
61
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
62
+ } & {
63
+ type: z.ZodLiteral<"url">;
64
+ url: z.ZodString;
65
+ }, "strip", z.ZodTypeAny, {
66
+ type: "url";
67
+ url: string;
68
+ filename?: string | undefined;
69
+ mimeType?: string | undefined;
70
+ }, {
71
+ type: "url";
72
+ url: string;
73
+ filename?: string | undefined;
74
+ mimeType?: string | undefined;
75
+ }>, z.ZodObject<{
76
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
77
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
78
+ } & {
79
+ type: z.ZodLiteral<"file">;
80
+ data: z.ZodString;
81
+ }, "strip", z.ZodTypeAny, {
82
+ type: "file";
83
+ data: string;
84
+ filename?: string | undefined;
85
+ mimeType?: string | undefined;
86
+ }, {
87
+ type: "file";
88
+ data: string;
89
+ filename?: string | undefined;
90
+ mimeType?: string | undefined;
91
+ }>]>>;
42
92
  }, "strip", z.ZodTypeAny, {
43
93
  prompt: string;
44
94
  model?: string | undefined;
45
95
  modelOptions?: Record<string, unknown> | undefined;
96
+ image?: {
97
+ type: "url";
98
+ url: string;
99
+ filename?: string | undefined;
100
+ mimeType?: string | undefined;
101
+ } | {
102
+ type: "file";
103
+ data: string;
104
+ filename?: string | undefined;
105
+ mimeType?: string | undefined;
106
+ } | {
107
+ path: string;
108
+ type: "local";
109
+ filename?: string | undefined;
110
+ mimeType?: string | undefined;
111
+ } | undefined;
46
112
  outputFileType?: "local" | "file" | "url" | undefined;
47
113
  size?: string | undefined;
48
114
  seconds?: string | undefined;
@@ -50,6 +116,22 @@ export declare const videoModelInputSchema: z.ZodObject<{
50
116
  prompt: string;
51
117
  model?: string | undefined;
52
118
  modelOptions?: Record<string, unknown> | undefined;
119
+ image?: {
120
+ type: "url";
121
+ url: string;
122
+ filename?: string | undefined;
123
+ mimeType?: string | undefined;
124
+ } | {
125
+ type: "file";
126
+ data: string;
127
+ filename?: string | undefined;
128
+ mimeType?: string | undefined;
129
+ } | {
130
+ path: string;
131
+ type: "local";
132
+ filename?: string | undefined;
133
+ mimeType?: string | undefined;
134
+ } | undefined;
53
135
  outputFileType?: "local" | "file" | "url" | undefined;
54
136
  size?: string | undefined;
55
137
  seconds?: string | undefined;
@@ -56,6 +56,7 @@ exports.videoModelInputSchema = zod_1.z.object({
56
56
  seconds: zod_1.z.string().optional().describe("Duration of the video in seconds"),
57
57
  outputFileType: model_js_1.fileTypeSchema.optional(),
58
58
  modelOptions: zod_1.z.record(zod_1.z.unknown()).optional(),
59
+ image: model_js_1.fileUnionContentSchema.optional(),
59
60
  });
60
61
  exports.videoModelOutputSchema = zod_1.z.object({
61
62
  videos: zod_1.z.array(model_js_1.fileUnionContentSchema),
@@ -18,6 +18,7 @@ export interface LoadOptions {
18
18
  create: (options?: Record<string, any>) => PromiseOrValue<AFSModule>;
19
19
  }[];
20
20
  };
21
+ aigne?: z.infer<typeof aigneFileSchema>;
21
22
  }
22
23
  export declare function load(path: string, options?: LoadOptions): Promise<AIGNEOptions>;
23
24
  export declare function loadAgent(path: string, options?: LoadOptions, agentOptions?: AgentOptions): Promise<Agent>;
@@ -37,12 +38,14 @@ declare const aigneFileSchema: z.ZodObject<{
37
38
  topP: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
38
39
  frequencyPenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
39
40
  presencePenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
41
+ thinkingEffort: ZodType<number | "high" | "medium" | "low" | "minimal" | undefined, z.ZodTypeDef, number | "high" | "medium" | "low" | "minimal" | undefined>;
40
42
  }, z.ZodTypeAny, "passthrough"> | undefined, z.ZodTypeDef, z.objectInputType<{
41
43
  model: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
42
44
  temperature: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
43
45
  topP: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
44
46
  frequencyPenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
45
47
  presencePenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
48
+ thinkingEffort: ZodType<number | "high" | "medium" | "low" | "minimal" | undefined, z.ZodTypeDef, number | "high" | "medium" | "low" | "minimal" | undefined>;
46
49
  }, z.ZodTypeAny, "passthrough"> | undefined>;
47
50
  imageModel: ZodType<z.objectInputType<{
48
51
  model: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
@@ -70,6 +73,7 @@ declare const aigneFileSchema: z.ZodObject<{
70
73
  topP: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
71
74
  frequencyPenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
72
75
  presencePenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
76
+ thinkingEffort: ZodType<number | "high" | "medium" | "low" | "minimal" | undefined, z.ZodTypeDef, number | "high" | "medium" | "low" | "minimal" | undefined>;
73
77
  }, z.ZodTypeAny, "passthrough"> | undefined;
74
78
  name?: string | undefined;
75
79
  description?: string | undefined;
@@ -92,6 +96,7 @@ declare const aigneFileSchema: z.ZodObject<{
92
96
  topP: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
93
97
  frequencyPenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
94
98
  presencePenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
99
+ thinkingEffort: ZodType<number | "high" | "medium" | "low" | "minimal" | undefined, z.ZodTypeDef, number | "high" | "medium" | "low" | "minimal" | undefined>;
95
100
  }, z.ZodTypeAny, "passthrough"> | undefined;
96
101
  name?: string | undefined;
97
102
  description?: string | undefined;
@@ -30,7 +30,7 @@ async function load(path, options = {}) {
30
30
  const allAgentPaths = new Set((0, type_utils_js_1.flat)(aigne.agents, aigne.skills, aigne.mcpServer?.agents, aigne.cli?.chat, aigne.cli?.agents?.flatMap((i) => (typeof i === "string" ? i : flatCliAgents(i)))).map((i) => index_js_1.nodejs.path.join(rootDir, i)));
31
31
  const allAgents = {};
32
32
  for (const path of allAgentPaths) {
33
- allAgents[path] = await loadAgent(path, options);
33
+ allAgents[path] = await loadAgent(path, { ...options, aigne });
34
34
  }
35
35
  const pickAgent = (path) => allAgents[index_js_1.nodejs.path.join(rootDir, path)];
36
36
  const pickAgents = (paths) => paths.map((filename) => pickAgent(filename)).filter(type_utils_js_1.isNonNullable);
@@ -134,10 +134,13 @@ async function parseAgent(path, agent, options, agentOptions) {
134
134
  });
135
135
  }
136
136
  const model = agent.model && typeof options?.model === "function"
137
- ? await options.model(agent.model)
137
+ ? await options.model({ ...options.aigne?.model, ...(0, type_utils_js_1.omitBy)(agent.model, (v) => (0, type_utils_js_1.isNil)(v)) })
138
138
  : undefined;
139
139
  const imageModel = agent.imageModel && typeof options?.imageModel === "function"
140
- ? await options.imageModel(agent.imageModel)
140
+ ? await options.imageModel({
141
+ ...options.aigne?.imageModel,
142
+ ...(0, type_utils_js_1.omitBy)(agent.imageModel, (v) => (0, type_utils_js_1.isNil)(v)),
143
+ })
141
144
  : undefined;
142
145
  const baseOptions = {
143
146
  ...agentOptions,
@@ -35,18 +35,21 @@ declare const chatModelObjectSchema: z.ZodObject<{
35
35
  topP: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
36
36
  frequencyPenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
37
37
  presencePenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
38
+ thinkingEffort: ZodType<number | "high" | "medium" | "low" | "minimal" | undefined, z.ZodTypeDef, number | "high" | "medium" | "low" | "minimal" | undefined>;
38
39
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
39
40
  model: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
40
41
  temperature: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
41
42
  topP: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
42
43
  frequencyPenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
43
44
  presencePenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
45
+ thinkingEffort: ZodType<number | "high" | "medium" | "low" | "minimal" | undefined, z.ZodTypeDef, number | "high" | "medium" | "low" | "minimal" | undefined>;
44
46
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
45
47
  model: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
46
48
  temperature: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
47
49
  topP: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
48
50
  frequencyPenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
49
51
  presencePenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
52
+ thinkingEffort: ZodType<number | "high" | "medium" | "low" | "minimal" | undefined, z.ZodTypeDef, number | "high" | "medium" | "low" | "minimal" | undefined>;
50
53
  }, z.ZodTypeAny, "passthrough">>;
51
54
  export declare const chatModelSchema: typeof chatModelObjectSchema;
52
55
  declare const imageModelObjectSchema: z.ZodObject<{
@@ -67,13 +67,25 @@ const chatModelObjectSchema = camelizeSchema(zod_1.z
67
67
  topP: optionalize(zod_1.z.number().min(0)),
68
68
  frequencyPenalty: optionalize(zod_1.z.number().min(-2).max(2)),
69
69
  presencePenalty: optionalize(zod_1.z.number().min(-2).max(2)),
70
+ thinkingEffort: optionalize(zod_1.z.union([
71
+ zod_1.z.number().int(),
72
+ zod_1.z.literal("high"),
73
+ zod_1.z.literal("medium"),
74
+ zod_1.z.literal("low"),
75
+ zod_1.z.literal("minimal"),
76
+ ])),
70
77
  })
71
78
  .passthrough());
72
79
  exports.chatModelSchema = zod_1.z
73
80
  .preprocess((v) => {
74
81
  if (!(0, type_utils_js_1.isRecord)(v))
75
82
  return v;
76
- return { ...v, model: v.model || `${v.provider || ""}:${v.name || ""}` };
83
+ return {
84
+ ...v,
85
+ model: v.model ||
86
+ (v.provider && v.name ? `${v.provider || ""}:${v.name || ""}` : undefined) ||
87
+ undefined,
88
+ };
77
89
  }, zod_1.z.union([zod_1.z.string(), chatModelObjectSchema]))
78
90
  .transform((v) => typeof v === "string" ? { model: v } : v);
79
91
  const imageModelObjectSchema = camelizeSchema(zod_1.z
@@ -0,0 +1,2 @@
1
+ import type { Environment } from "nunjucks";
2
+ export declare function setupFilters(env: Environment): void;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setupFilters = setupFilters;
4
+ const yaml_1 = require("yaml");
5
+ function setupFilters(env) {
6
+ env.addFilter("yaml.stringify", (obj) => {
7
+ return (0, yaml_1.stringify)(obj);
8
+ });
9
+ env.addFilter("json.stringify", (obj, ...args) => {
10
+ return JSON.stringify(obj, ...args);
11
+ });
12
+ }
@@ -10,6 +10,7 @@ const index_js_1 = require("@aigne/platform-helpers/nodejs/index.js");
10
10
  const nunjucks_1 = __importDefault(require("nunjucks"));
11
11
  const zod_1 = require("zod");
12
12
  const type_utils_js_1 = require("../utils/type-utils.js");
13
+ const index_js_2 = require("./filters/index.js");
13
14
  nunjucks_1.default.runtime.suppressValue = (v) => {
14
15
  if ((0, type_utils_js_1.isNil)(v))
15
16
  return "";
@@ -28,6 +29,7 @@ class PromptTemplate {
28
29
  if (options?.workingDir) {
29
30
  env = new nunjucks_1.default.Environment(new CustomLoader({ workingDir: options.workingDir }));
30
31
  }
32
+ (0, index_js_2.setupFilters)(env);
31
33
  return new Promise((resolve, reject) => env.renderString(this.template, variables, (err, res) => {
32
34
  if (err || !res) {
33
35
  reject(err || new Error(`Failed to render template: ${this.template}`));
@@ -388,6 +388,7 @@ export interface ChatModelInputOptions {
388
388
  parallelToolCalls?: boolean;
389
389
  modalities?: Modality[];
390
390
  preferInputFileType?: "file" | "url";
391
+ reasoningEffort?: number | "minimal" | "low" | "medium" | "high";
391
392
  }
392
393
  /**
393
394
  * Output message format for ChatModel
@@ -28,6 +28,7 @@ export interface VideoModelInput extends Message {
28
28
  seconds?: string;
29
29
  outputFileType?: FileType;
30
30
  modelOptions?: VideoModelInputOptions;
31
+ image?: FileUnionContent;
31
32
  }
32
33
  export interface VideoModelInputOptions extends Record<string, unknown> {
33
34
  model?: string;
@@ -39,10 +40,75 @@ export declare const videoModelInputSchema: z.ZodObject<{
39
40
  seconds: z.ZodOptional<z.ZodString>;
40
41
  outputFileType: z.ZodOptional<z.ZodEnum<["local", "file", "url"]>>;
41
42
  modelOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
43
+ image: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
44
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
45
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
46
+ } & {
47
+ type: z.ZodLiteral<"local">;
48
+ path: z.ZodString;
49
+ }, "strip", z.ZodTypeAny, {
50
+ path: string;
51
+ type: "local";
52
+ filename?: string | undefined;
53
+ mimeType?: string | undefined;
54
+ }, {
55
+ path: string;
56
+ type: "local";
57
+ filename?: string | undefined;
58
+ mimeType?: string | undefined;
59
+ }>, z.ZodObject<{
60
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
61
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
62
+ } & {
63
+ type: z.ZodLiteral<"url">;
64
+ url: z.ZodString;
65
+ }, "strip", z.ZodTypeAny, {
66
+ type: "url";
67
+ url: string;
68
+ filename?: string | undefined;
69
+ mimeType?: string | undefined;
70
+ }, {
71
+ type: "url";
72
+ url: string;
73
+ filename?: string | undefined;
74
+ mimeType?: string | undefined;
75
+ }>, z.ZodObject<{
76
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
77
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
78
+ } & {
79
+ type: z.ZodLiteral<"file">;
80
+ data: z.ZodString;
81
+ }, "strip", z.ZodTypeAny, {
82
+ type: "file";
83
+ data: string;
84
+ filename?: string | undefined;
85
+ mimeType?: string | undefined;
86
+ }, {
87
+ type: "file";
88
+ data: string;
89
+ filename?: string | undefined;
90
+ mimeType?: string | undefined;
91
+ }>]>>;
42
92
  }, "strip", z.ZodTypeAny, {
43
93
  prompt: string;
44
94
  model?: string | undefined;
45
95
  modelOptions?: Record<string, unknown> | undefined;
96
+ image?: {
97
+ type: "url";
98
+ url: string;
99
+ filename?: string | undefined;
100
+ mimeType?: string | undefined;
101
+ } | {
102
+ type: "file";
103
+ data: string;
104
+ filename?: string | undefined;
105
+ mimeType?: string | undefined;
106
+ } | {
107
+ path: string;
108
+ type: "local";
109
+ filename?: string | undefined;
110
+ mimeType?: string | undefined;
111
+ } | undefined;
46
112
  outputFileType?: "local" | "file" | "url" | undefined;
47
113
  size?: string | undefined;
48
114
  seconds?: string | undefined;
@@ -50,6 +116,22 @@ export declare const videoModelInputSchema: z.ZodObject<{
50
116
  prompt: string;
51
117
  model?: string | undefined;
52
118
  modelOptions?: Record<string, unknown> | undefined;
119
+ image?: {
120
+ type: "url";
121
+ url: string;
122
+ filename?: string | undefined;
123
+ mimeType?: string | undefined;
124
+ } | {
125
+ type: "file";
126
+ data: string;
127
+ filename?: string | undefined;
128
+ mimeType?: string | undefined;
129
+ } | {
130
+ path: string;
131
+ type: "local";
132
+ filename?: string | undefined;
133
+ mimeType?: string | undefined;
134
+ } | undefined;
53
135
  outputFileType?: "local" | "file" | "url" | undefined;
54
136
  size?: string | undefined;
55
137
  seconds?: string | undefined;
@@ -18,6 +18,7 @@ export interface LoadOptions {
18
18
  create: (options?: Record<string, any>) => PromiseOrValue<AFSModule>;
19
19
  }[];
20
20
  };
21
+ aigne?: z.infer<typeof aigneFileSchema>;
21
22
  }
22
23
  export declare function load(path: string, options?: LoadOptions): Promise<AIGNEOptions>;
23
24
  export declare function loadAgent(path: string, options?: LoadOptions, agentOptions?: AgentOptions): Promise<Agent>;
@@ -37,12 +38,14 @@ declare const aigneFileSchema: z.ZodObject<{
37
38
  topP: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
38
39
  frequencyPenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
39
40
  presencePenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
41
+ thinkingEffort: ZodType<number | "high" | "medium" | "low" | "minimal" | undefined, z.ZodTypeDef, number | "high" | "medium" | "low" | "minimal" | undefined>;
40
42
  }, z.ZodTypeAny, "passthrough"> | undefined, z.ZodTypeDef, z.objectInputType<{
41
43
  model: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
42
44
  temperature: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
43
45
  topP: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
44
46
  frequencyPenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
45
47
  presencePenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
48
+ thinkingEffort: ZodType<number | "high" | "medium" | "low" | "minimal" | undefined, z.ZodTypeDef, number | "high" | "medium" | "low" | "minimal" | undefined>;
46
49
  }, z.ZodTypeAny, "passthrough"> | undefined>;
47
50
  imageModel: ZodType<z.objectInputType<{
48
51
  model: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
@@ -70,6 +73,7 @@ declare const aigneFileSchema: z.ZodObject<{
70
73
  topP: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
71
74
  frequencyPenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
72
75
  presencePenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
76
+ thinkingEffort: ZodType<number | "high" | "medium" | "low" | "minimal" | undefined, z.ZodTypeDef, number | "high" | "medium" | "low" | "minimal" | undefined>;
73
77
  }, z.ZodTypeAny, "passthrough"> | undefined;
74
78
  name?: string | undefined;
75
79
  description?: string | undefined;
@@ -92,6 +96,7 @@ declare const aigneFileSchema: z.ZodObject<{
92
96
  topP: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
93
97
  frequencyPenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
94
98
  presencePenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
99
+ thinkingEffort: ZodType<number | "high" | "medium" | "low" | "minimal" | undefined, z.ZodTypeDef, number | "high" | "medium" | "low" | "minimal" | undefined>;
95
100
  }, z.ZodTypeAny, "passthrough"> | undefined;
96
101
  name?: string | undefined;
97
102
  description?: string | undefined;
@@ -35,18 +35,21 @@ declare const chatModelObjectSchema: z.ZodObject<{
35
35
  topP: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
36
36
  frequencyPenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
37
37
  presencePenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
38
+ thinkingEffort: ZodType<number | "high" | "medium" | "low" | "minimal" | undefined, z.ZodTypeDef, number | "high" | "medium" | "low" | "minimal" | undefined>;
38
39
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
39
40
  model: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
40
41
  temperature: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
41
42
  topP: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
42
43
  frequencyPenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
43
44
  presencePenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
45
+ thinkingEffort: ZodType<number | "high" | "medium" | "low" | "minimal" | undefined, z.ZodTypeDef, number | "high" | "medium" | "low" | "minimal" | undefined>;
44
46
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
45
47
  model: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
46
48
  temperature: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
47
49
  topP: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
48
50
  frequencyPenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
49
51
  presencePenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
52
+ thinkingEffort: ZodType<number | "high" | "medium" | "low" | "minimal" | undefined, z.ZodTypeDef, number | "high" | "medium" | "low" | "minimal" | undefined>;
50
53
  }, z.ZodTypeAny, "passthrough">>;
51
54
  export declare const chatModelSchema: typeof chatModelObjectSchema;
52
55
  declare const imageModelObjectSchema: z.ZodObject<{
@@ -0,0 +1,2 @@
1
+ import type { Environment } from "nunjucks";
2
+ export declare function setupFilters(env: Environment): void;
@@ -305,7 +305,7 @@ export class AIAgent extends Agent {
305
305
  }
306
306
  const { toolCalls, json, text, files } = modelOutput;
307
307
  if (toolCalls?.length) {
308
- if (!this.keepTextInToolUses) {
308
+ if (this.keepTextInToolUses !== true) {
309
309
  yield { delta: { json: { [outputKey]: "" } } };
310
310
  }
311
311
  else {
@@ -388,6 +388,7 @@ export interface ChatModelInputOptions {
388
388
  parallelToolCalls?: boolean;
389
389
  modalities?: Modality[];
390
390
  preferInputFileType?: "file" | "url";
391
+ reasoningEffort?: number | "minimal" | "low" | "medium" | "high";
391
392
  }
392
393
  /**
393
394
  * Output message format for ChatModel
@@ -299,6 +299,15 @@ const modelOptionsSchema = z.object({
299
299
  presencePenalty: z.number().optional(),
300
300
  parallelToolCalls: z.boolean().optional().default(true),
301
301
  modalities: z.array(z.enum(["text", "image", "audio"])).optional(),
302
+ reasoningEffort: z
303
+ .union([
304
+ z.number(),
305
+ z.literal("minimal"),
306
+ z.literal("low"),
307
+ z.literal("medium"),
308
+ z.literal("high"),
309
+ ])
310
+ .optional(),
302
311
  });
303
312
  const chatModelOptionsSchema = agentOptionsSchema.extend({
304
313
  model: z.string().optional(),
@@ -28,6 +28,7 @@ export interface VideoModelInput extends Message {
28
28
  seconds?: string;
29
29
  outputFileType?: FileType;
30
30
  modelOptions?: VideoModelInputOptions;
31
+ image?: FileUnionContent;
31
32
  }
32
33
  export interface VideoModelInputOptions extends Record<string, unknown> {
33
34
  model?: string;
@@ -39,10 +40,75 @@ export declare const videoModelInputSchema: z.ZodObject<{
39
40
  seconds: z.ZodOptional<z.ZodString>;
40
41
  outputFileType: z.ZodOptional<z.ZodEnum<["local", "file", "url"]>>;
41
42
  modelOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
43
+ image: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
44
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
45
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
46
+ } & {
47
+ type: z.ZodLiteral<"local">;
48
+ path: z.ZodString;
49
+ }, "strip", z.ZodTypeAny, {
50
+ path: string;
51
+ type: "local";
52
+ filename?: string | undefined;
53
+ mimeType?: string | undefined;
54
+ }, {
55
+ path: string;
56
+ type: "local";
57
+ filename?: string | undefined;
58
+ mimeType?: string | undefined;
59
+ }>, z.ZodObject<{
60
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
61
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
62
+ } & {
63
+ type: z.ZodLiteral<"url">;
64
+ url: z.ZodString;
65
+ }, "strip", z.ZodTypeAny, {
66
+ type: "url";
67
+ url: string;
68
+ filename?: string | undefined;
69
+ mimeType?: string | undefined;
70
+ }, {
71
+ type: "url";
72
+ url: string;
73
+ filename?: string | undefined;
74
+ mimeType?: string | undefined;
75
+ }>, z.ZodObject<{
76
+ filename: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
77
+ mimeType: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
78
+ } & {
79
+ type: z.ZodLiteral<"file">;
80
+ data: z.ZodString;
81
+ }, "strip", z.ZodTypeAny, {
82
+ type: "file";
83
+ data: string;
84
+ filename?: string | undefined;
85
+ mimeType?: string | undefined;
86
+ }, {
87
+ type: "file";
88
+ data: string;
89
+ filename?: string | undefined;
90
+ mimeType?: string | undefined;
91
+ }>]>>;
42
92
  }, "strip", z.ZodTypeAny, {
43
93
  prompt: string;
44
94
  model?: string | undefined;
45
95
  modelOptions?: Record<string, unknown> | undefined;
96
+ image?: {
97
+ type: "url";
98
+ url: string;
99
+ filename?: string | undefined;
100
+ mimeType?: string | undefined;
101
+ } | {
102
+ type: "file";
103
+ data: string;
104
+ filename?: string | undefined;
105
+ mimeType?: string | undefined;
106
+ } | {
107
+ path: string;
108
+ type: "local";
109
+ filename?: string | undefined;
110
+ mimeType?: string | undefined;
111
+ } | undefined;
46
112
  outputFileType?: "local" | "file" | "url" | undefined;
47
113
  size?: string | undefined;
48
114
  seconds?: string | undefined;
@@ -50,6 +116,22 @@ export declare const videoModelInputSchema: z.ZodObject<{
50
116
  prompt: string;
51
117
  model?: string | undefined;
52
118
  modelOptions?: Record<string, unknown> | undefined;
119
+ image?: {
120
+ type: "url";
121
+ url: string;
122
+ filename?: string | undefined;
123
+ mimeType?: string | undefined;
124
+ } | {
125
+ type: "file";
126
+ data: string;
127
+ filename?: string | undefined;
128
+ mimeType?: string | undefined;
129
+ } | {
130
+ path: string;
131
+ type: "local";
132
+ filename?: string | undefined;
133
+ mimeType?: string | undefined;
134
+ } | undefined;
53
135
  outputFileType?: "local" | "file" | "url" | undefined;
54
136
  size?: string | undefined;
55
137
  seconds?: string | undefined;
@@ -52,6 +52,7 @@ export const videoModelInputSchema = z.object({
52
52
  seconds: z.string().optional().describe("Duration of the video in seconds"),
53
53
  outputFileType: fileTypeSchema.optional(),
54
54
  modelOptions: z.record(z.unknown()).optional(),
55
+ image: fileUnionContentSchema.optional(),
55
56
  });
56
57
  export const videoModelOutputSchema = z.object({
57
58
  videos: z.array(fileUnionContentSchema),
@@ -18,6 +18,7 @@ export interface LoadOptions {
18
18
  create: (options?: Record<string, any>) => PromiseOrValue<AFSModule>;
19
19
  }[];
20
20
  };
21
+ aigne?: z.infer<typeof aigneFileSchema>;
21
22
  }
22
23
  export declare function load(path: string, options?: LoadOptions): Promise<AIGNEOptions>;
23
24
  export declare function loadAgent(path: string, options?: LoadOptions, agentOptions?: AgentOptions): Promise<Agent>;
@@ -37,12 +38,14 @@ declare const aigneFileSchema: z.ZodObject<{
37
38
  topP: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
38
39
  frequencyPenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
39
40
  presencePenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
41
+ thinkingEffort: ZodType<number | "high" | "medium" | "low" | "minimal" | undefined, z.ZodTypeDef, number | "high" | "medium" | "low" | "minimal" | undefined>;
40
42
  }, z.ZodTypeAny, "passthrough"> | undefined, z.ZodTypeDef, z.objectInputType<{
41
43
  model: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
42
44
  temperature: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
43
45
  topP: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
44
46
  frequencyPenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
45
47
  presencePenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
48
+ thinkingEffort: ZodType<number | "high" | "medium" | "low" | "minimal" | undefined, z.ZodTypeDef, number | "high" | "medium" | "low" | "minimal" | undefined>;
46
49
  }, z.ZodTypeAny, "passthrough"> | undefined>;
47
50
  imageModel: ZodType<z.objectInputType<{
48
51
  model: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
@@ -70,6 +73,7 @@ declare const aigneFileSchema: z.ZodObject<{
70
73
  topP: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
71
74
  frequencyPenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
72
75
  presencePenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
76
+ thinkingEffort: ZodType<number | "high" | "medium" | "low" | "minimal" | undefined, z.ZodTypeDef, number | "high" | "medium" | "low" | "minimal" | undefined>;
73
77
  }, z.ZodTypeAny, "passthrough"> | undefined;
74
78
  name?: string | undefined;
75
79
  description?: string | undefined;
@@ -92,6 +96,7 @@ declare const aigneFileSchema: z.ZodObject<{
92
96
  topP: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
93
97
  frequencyPenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
94
98
  presencePenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
99
+ thinkingEffort: ZodType<number | "high" | "medium" | "low" | "minimal" | undefined, z.ZodTypeDef, number | "high" | "medium" | "low" | "minimal" | undefined>;
95
100
  }, z.ZodTypeAny, "passthrough"> | undefined;
96
101
  name?: string | undefined;
97
102
  description?: string | undefined;
@@ -10,7 +10,7 @@ import { TeamAgent } from "../agents/team-agent.js";
10
10
  import { TransformAgent } from "../agents/transform-agent.js";
11
11
  import { PromptBuilder } from "../prompt/prompt-builder.js";
12
12
  import { ChatMessagesTemplate, parseChatMessages } from "../prompt/template.js";
13
- import { flat, isNonNullable, tryOrThrow } from "../utils/type-utils.js";
13
+ import { flat, isNil, isNonNullable, omitBy, tryOrThrow, } from "../utils/type-utils.js";
14
14
  import { loadAgentFromJsFile } from "./agent-js.js";
15
15
  import { loadAgentFromYamlFile } from "./agent-yaml.js";
16
16
  import { camelizeSchema, chatModelSchema, imageModelSchema, optionalize } from "./schema.js";
@@ -25,7 +25,7 @@ export async function load(path, options = {}) {
25
25
  const allAgentPaths = new Set(flat(aigne.agents, aigne.skills, aigne.mcpServer?.agents, aigne.cli?.chat, aigne.cli?.agents?.flatMap((i) => (typeof i === "string" ? i : flatCliAgents(i)))).map((i) => nodejs.path.join(rootDir, i)));
26
26
  const allAgents = {};
27
27
  for (const path of allAgentPaths) {
28
- allAgents[path] = await loadAgent(path, options);
28
+ allAgents[path] = await loadAgent(path, { ...options, aigne });
29
29
  }
30
30
  const pickAgent = (path) => allAgents[nodejs.path.join(rootDir, path)];
31
31
  const pickAgents = (paths) => paths.map((filename) => pickAgent(filename)).filter(isNonNullable);
@@ -129,10 +129,13 @@ async function parseAgent(path, agent, options, agentOptions) {
129
129
  });
130
130
  }
131
131
  const model = agent.model && typeof options?.model === "function"
132
- ? await options.model(agent.model)
132
+ ? await options.model({ ...options.aigne?.model, ...omitBy(agent.model, (v) => isNil(v)) })
133
133
  : undefined;
134
134
  const imageModel = agent.imageModel && typeof options?.imageModel === "function"
135
- ? await options.imageModel(agent.imageModel)
135
+ ? await options.imageModel({
136
+ ...options.aigne?.imageModel,
137
+ ...omitBy(agent.imageModel, (v) => isNil(v)),
138
+ })
136
139
  : undefined;
137
140
  const baseOptions = {
138
141
  ...agentOptions,
@@ -35,18 +35,21 @@ declare const chatModelObjectSchema: z.ZodObject<{
35
35
  topP: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
36
36
  frequencyPenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
37
37
  presencePenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
38
+ thinkingEffort: ZodType<number | "high" | "medium" | "low" | "minimal" | undefined, z.ZodTypeDef, number | "high" | "medium" | "low" | "minimal" | undefined>;
38
39
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
39
40
  model: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
40
41
  temperature: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
41
42
  topP: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
42
43
  frequencyPenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
43
44
  presencePenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
45
+ thinkingEffort: ZodType<number | "high" | "medium" | "low" | "minimal" | undefined, z.ZodTypeDef, number | "high" | "medium" | "low" | "minimal" | undefined>;
44
46
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
45
47
  model: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
46
48
  temperature: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
47
49
  topP: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
48
50
  frequencyPenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
49
51
  presencePenalty: ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
52
+ thinkingEffort: ZodType<number | "high" | "medium" | "low" | "minimal" | undefined, z.ZodTypeDef, number | "high" | "medium" | "low" | "minimal" | undefined>;
50
53
  }, z.ZodTypeAny, "passthrough">>;
51
54
  export declare const chatModelSchema: typeof chatModelObjectSchema;
52
55
  declare const imageModelObjectSchema: z.ZodObject<{
@@ -61,13 +61,25 @@ const chatModelObjectSchema = camelizeSchema(z
61
61
  topP: optionalize(z.number().min(0)),
62
62
  frequencyPenalty: optionalize(z.number().min(-2).max(2)),
63
63
  presencePenalty: optionalize(z.number().min(-2).max(2)),
64
+ thinkingEffort: optionalize(z.union([
65
+ z.number().int(),
66
+ z.literal("high"),
67
+ z.literal("medium"),
68
+ z.literal("low"),
69
+ z.literal("minimal"),
70
+ ])),
64
71
  })
65
72
  .passthrough());
66
73
  export const chatModelSchema = z
67
74
  .preprocess((v) => {
68
75
  if (!isRecord(v))
69
76
  return v;
70
- return { ...v, model: v.model || `${v.provider || ""}:${v.name || ""}` };
77
+ return {
78
+ ...v,
79
+ model: v.model ||
80
+ (v.provider && v.name ? `${v.provider || ""}:${v.name || ""}` : undefined) ||
81
+ undefined,
82
+ };
71
83
  }, z.union([z.string(), chatModelObjectSchema]))
72
84
  .transform((v) => typeof v === "string" ? { model: v } : v);
73
85
  const imageModelObjectSchema = camelizeSchema(z
@@ -0,0 +1,2 @@
1
+ import type { Environment } from "nunjucks";
2
+ export declare function setupFilters(env: Environment): void;
@@ -0,0 +1,9 @@
1
+ import { stringify } from "yaml";
2
+ export function setupFilters(env) {
3
+ env.addFilter("yaml.stringify", (obj) => {
4
+ return stringify(obj);
5
+ });
6
+ env.addFilter("json.stringify", (obj, ...args) => {
7
+ return JSON.stringify(obj, ...args);
8
+ });
9
+ }
@@ -2,6 +2,7 @@ import { nodejs } from "@aigne/platform-helpers/nodejs/index.js";
2
2
  import nunjucks from "nunjucks";
3
3
  import { z } from "zod";
4
4
  import { isNil, omitBy } from "../utils/type-utils.js";
5
+ import { setupFilters } from "./filters/index.js";
5
6
  nunjucks.runtime.suppressValue = (v) => {
6
7
  if (isNil(v))
7
8
  return "";
@@ -20,6 +21,7 @@ export class PromptTemplate {
20
21
  if (options?.workingDir) {
21
22
  env = new nunjucks.Environment(new CustomLoader({ workingDir: options.workingDir }));
22
23
  }
24
+ setupFilters(env);
23
25
  return new Promise((resolve, reject) => env.renderString(this.template, variables, (err, res) => {
24
26
  if (err || !res) {
25
27
  reject(err || new Error(`Failed to render template: ${this.template}`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/core",
3
- "version": "1.65.0-beta.3",
3
+ "version": "1.65.0-beta.5",
4
4
  "description": "The functional core of agentic AI",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -92,7 +92,7 @@
92
92
  "zod-from-json-schema": "^0.0.5",
93
93
  "zod-to-json-schema": "^3.24.6",
94
94
  "@aigne/afs": "^1.1.1-beta",
95
- "@aigne/observability-api": "^0.11.4-beta",
95
+ "@aigne/observability-api": "^0.11.4-beta.2",
96
96
  "@aigne/platform-helpers": "^0.6.3"
97
97
  },
98
98
  "devDependencies": {