@aigne/core 1.39.0 → 1.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -12,6 +12,20 @@
12
12
  * dependencies
13
13
  * @aigne/observability bumped to 0.1.0
14
14
 
15
+ ## [1.41.0](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.40.0...core-v1.41.0) (2025-07-31)
16
+
17
+
18
+ ### Features
19
+
20
+ * **cli:** add alias support for agent ([#297](https://github.com/AIGNE-io/aigne-framework/issues/297)) ([fa166ab](https://github.com/AIGNE-io/aigne-framework/commit/fa166ab66d19e89ddd32c34e1470450eb4fbdbbd))
21
+
22
+ ## [1.40.0](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.39.0...core-v1.40.0) (2025-07-31)
23
+
24
+
25
+ ### Features
26
+
27
+ * **cli:** support dynamic download and execution of doc-smith app ([#293](https://github.com/AIGNE-io/aigne-framework/issues/293)) ([4c40077](https://github.com/AIGNE-io/aigne-framework/commit/4c40077bacef076bc4b098879e948ef866218e39))
28
+
15
29
  ## [1.39.0](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.38.1...core-v1.39.0) (2025-07-28)
16
30
 
17
31
 
@@ -61,6 +61,10 @@ export interface AgentOptions<I extends Message = Message, O extends Message = M
61
61
  * if not specified
62
62
  */
63
63
  name?: string;
64
+ /**
65
+ * Alias for the agent, can be used to refer to the agent by multiple names, especially in AIGNE CLI
66
+ */
67
+ alias?: string[];
64
68
  /**
65
69
  * Description of the agent
66
70
  *
@@ -232,6 +236,10 @@ export declare abstract class Agent<I extends Message = any, O extends Message =
232
236
  * Defaults to the class constructor name if not specified in options
233
237
  */
234
238
  readonly name: string;
239
+ /**
240
+ * Alias for the agent, can be used to refer to the agent by multiple names, especially in AIGNE CLI
241
+ */
242
+ readonly alias?: string[];
235
243
  /**
236
244
  * Default topic this agent subscribes to
237
245
  *
@@ -102,6 +102,7 @@ class Agent {
102
102
  constructor(options = {}) {
103
103
  const { inputSchema, outputSchema } = options;
104
104
  this.name = options.name || this.constructor.name;
105
+ this.alias = options.alias;
105
106
  this.description = options.description;
106
107
  if (inputSchema)
107
108
  checkAgentInputOutputSchema(inputSchema);
@@ -170,6 +171,10 @@ class Agent {
170
171
  * Defaults to the class constructor name if not specified in options
171
172
  */
172
173
  name;
174
+ /**
175
+ * Alias for the agent, can be used to refer to the agent by multiple names, especially in AIGNE CLI
176
+ */
177
+ alias;
173
178
  /**
174
179
  * Default topic this agent subscribes to
175
180
  *
@@ -35,6 +35,12 @@ export interface AIGNEOptions {
35
35
  * Agents to use for the AIGNE instance.
36
36
  */
37
37
  agents?: Agent[];
38
+ mcpServer?: {
39
+ agents?: Agent[];
40
+ };
41
+ cli?: {
42
+ agents?: Agent[];
43
+ };
38
44
  /**
39
45
  * Limits for the AIGNE instance, such as timeout, max tokens, max invocations, etc.
40
46
  */
@@ -112,6 +118,16 @@ export declare class AIGNE<U extends UserContext = UserContext> {
112
118
  readonly agents: Agent<any, any>[] & {
113
119
  [key: string]: Agent<any, any>;
114
120
  };
121
+ readonly mcpServer: {
122
+ agents: Agent<any, any>[] & {
123
+ [key: string]: Agent<any, any>;
124
+ };
125
+ };
126
+ readonly cli: {
127
+ agents: Agent<any, any>[] & {
128
+ [key: string]: Agent<any, any>;
129
+ };
130
+ };
115
131
  /**
116
132
  * Observer for the AIGNE instance.
117
133
  */
@@ -31,6 +31,7 @@ class AIGNE {
31
31
  static async load(path, options) {
32
32
  const { model, agents = [], skills = [], ...aigne } = await (0, index_js_1.load)({ ...options, path });
33
33
  return new AIGNE({
34
+ ...aigne,
34
35
  ...options,
35
36
  rootDir: aigne.rootDir,
36
37
  model: options?.model || model,
@@ -61,6 +62,10 @@ class AIGNE {
61
62
  this.skills.push(...options.skills);
62
63
  if (options?.agents?.length)
63
64
  this.addAgent(...options.agents);
65
+ if (options?.mcpServer?.agents?.length)
66
+ this.mcpServer.agents.push(...options.mcpServer.agents);
67
+ if (options?.cli?.agents?.length)
68
+ this.cli.agents.push(...options.cli.agents);
64
69
  this.observer?.serve();
65
70
  this.initProcessExitHandler();
66
71
  }
@@ -100,6 +105,12 @@ class AIGNE {
100
105
  * Provides indexed access by agent name.
101
106
  */
102
107
  agents = (0, type_utils_js_1.createAccessorArray)([], (arr, name) => arr.find((i) => i.name === name));
108
+ mcpServer = {
109
+ agents: (0, type_utils_js_1.createAccessorArray)([], (arr, name) => arr.find((i) => i.name === name)),
110
+ };
111
+ cli = {
112
+ agents: (0, type_utils_js_1.createAccessorArray)([], (arr, name) => arr.find((i) => i.name === name)),
113
+ };
103
114
  /**
104
115
  * Observer for the AIGNE instance.
105
116
  */
@@ -32,6 +32,7 @@ async function parseAgentFile(path, data) {
32
32
  }));
33
33
  const baseAgentSchema = zod_1.z.object({
34
34
  name: (0, schema_js_1.optionalize)(zod_1.z.string()),
35
+ alias: (0, schema_js_1.optionalize)(zod_1.z.array(zod_1.z.string())),
35
36
  description: (0, schema_js_1.optionalize)(zod_1.z.string()),
36
37
  inputSchema: (0, schema_js_1.optionalize)((0, schema_js_1.inputOutputSchema)({ path })).transform((v) => v ? (0, json_schema_to_zod_1.jsonSchemaToZod)(v) : undefined),
37
38
  defaultInput: (0, schema_js_1.optionalize)(schema_js_1.defaultInputSchema),
@@ -67,6 +67,16 @@ declare const aigneFileSchema: z.ZodObject<{
67
67
  } | undefined>;
68
68
  agents: z.ZodType<string[] | undefined, z.ZodTypeDef, string[] | undefined>;
69
69
  skills: z.ZodType<string[] | undefined, z.ZodTypeDef, string[] | undefined>;
70
+ mcpServer: z.ZodType<{
71
+ agents?: string[] | undefined;
72
+ } | undefined, z.ZodTypeDef, {
73
+ agents?: string[] | undefined;
74
+ } | undefined>;
75
+ cli: z.ZodType<{
76
+ agents?: string[] | undefined;
77
+ } | undefined, z.ZodTypeDef, {
78
+ agents?: string[] | undefined;
79
+ } | undefined>;
70
80
  }, "strip", z.ZodTypeAny, {
71
81
  name?: string | undefined;
72
82
  description?: string | undefined;
@@ -80,6 +90,12 @@ declare const aigneFileSchema: z.ZodObject<{
80
90
  provider?: string | null | undefined;
81
91
  } | undefined;
82
92
  agents?: string[] | undefined;
93
+ mcpServer?: {
94
+ agents?: string[] | undefined;
95
+ } | undefined;
96
+ cli?: {
97
+ agents?: string[] | undefined;
98
+ } | undefined;
83
99
  }, {
84
100
  name?: string | undefined;
85
101
  description?: string | undefined;
@@ -93,6 +109,12 @@ declare const aigneFileSchema: z.ZodObject<{
93
109
  provider?: string | null | undefined;
94
110
  } | undefined;
95
111
  agents?: string[] | undefined;
112
+ mcpServer?: {
113
+ agents?: string[] | undefined;
114
+ } | undefined;
115
+ cli?: {
116
+ agents?: string[] | undefined;
117
+ } | undefined;
96
118
  }>;
97
119
  export declare function loadAIGNEFile(path: string): Promise<{
98
120
  aigne: z.infer<typeof aigneFileSchema>;
@@ -1,14 +1,10 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.load = load;
7
4
  exports.loadAgent = loadAgent;
8
5
  exports.loadModel = loadModel;
9
6
  exports.loadAIGNEFile = loadAIGNEFile;
10
7
  const index_js_1 = require("@aigne/platform-helpers/nodejs/index.js");
11
- const camelize_ts_1 = __importDefault(require("camelize-ts"));
12
8
  const yaml_1 = require("yaml");
13
9
  const zod_1 = require("zod");
14
10
  const agent_js_1 = require("../agents/agent.js");
@@ -24,8 +20,9 @@ const schema_js_1 = require("./schema.js");
24
20
  const AIGNE_FILE_NAME = ["aigne.yaml", "aigne.yml"];
25
21
  async function load(options) {
26
22
  const { aigne, rootDir } = await loadAIGNEFile(options.path);
27
- const agents = await Promise.all((aigne.agents ?? []).map((filename) => loadAgent(index_js_1.nodejs.path.join(rootDir, filename), options)));
28
- const skills = await Promise.all((aigne.skills ?? []).map((filename) => loadAgent(index_js_1.nodejs.path.join(rootDir, filename), options)));
23
+ const allAgentPaths = new Set((0, type_utils_js_1.flat)(aigne.agents, aigne.skills, aigne.mcpServer?.agents, aigne.cli?.agents).map((i) => index_js_1.nodejs.path.join(rootDir, i)));
24
+ const allAgents = Object.fromEntries(await Promise.all(Array.from(allAgentPaths).map(async (path) => [path, await loadAgent(path, options)])));
25
+ const pickAgents = (paths) => paths.map((filename) => allAgents[index_js_1.nodejs.path.join(rootDir, filename)]).filter(type_utils_js_1.isNonNullable);
29
26
  return {
30
27
  ...aigne,
31
28
  rootDir,
@@ -35,8 +32,14 @@ async function load(options) {
35
32
  create: (options) => new i(options),
36
33
  }
37
34
  : i), aigne.model),
38
- agents,
39
- skills,
35
+ agents: pickAgents(aigne.agents ?? []),
36
+ skills: pickAgents(aigne.skills ?? []),
37
+ mcpServer: {
38
+ agents: pickAgents(aigne.mcpServer?.agents ?? []),
39
+ },
40
+ cli: {
41
+ agents: pickAgents(aigne.cli?.agents ?? []),
42
+ },
40
43
  };
41
44
  }
42
45
  async function loadAgent(path, options, agentOptions) {
@@ -176,32 +179,34 @@ async function loadModel(models, model, modelOptions, accessKeyOptions) {
176
179
  modelOptions: { ...params, ...modelOptions },
177
180
  });
178
181
  }
179
- const aigneFileSchema = zod_1.z.object({
182
+ const aigneFileSchema = (0, schema_js_1.camelizeSchema)(zod_1.z.object({
180
183
  name: (0, schema_js_1.optionalize)(zod_1.z.string()),
181
184
  description: (0, schema_js_1.optionalize)(zod_1.z.string()),
182
185
  model: (0, schema_js_1.optionalize)(zod_1.z.union([
183
186
  zod_1.z.string(),
184
- zod_1.z.object({
187
+ (0, schema_js_1.camelizeSchema)(zod_1.z.object({
185
188
  provider: zod_1.z.string().nullish(),
186
189
  name: zod_1.z.string().nullish(),
187
190
  temperature: zod_1.z.number().min(0).max(2).nullish(),
188
191
  topP: zod_1.z.number().min(0).nullish(),
189
192
  frequencyPenalty: zod_1.z.number().min(-2).max(2).nullish(),
190
193
  presencePenalty: zod_1.z.number().min(-2).max(2).nullish(),
191
- }),
194
+ })),
192
195
  ])).transform((v) => (typeof v === "string" ? { name: v } : v)),
193
196
  agents: (0, schema_js_1.optionalize)(zod_1.z.array(zod_1.z.string())),
194
197
  skills: (0, schema_js_1.optionalize)(zod_1.z.array(zod_1.z.string())),
195
- });
198
+ mcpServer: (0, schema_js_1.optionalize)(zod_1.z.object({
199
+ agents: (0, schema_js_1.optionalize)(zod_1.z.array(zod_1.z.string())),
200
+ })),
201
+ cli: (0, schema_js_1.optionalize)(zod_1.z.object({
202
+ agents: (0, schema_js_1.optionalize)(zod_1.z.array(zod_1.z.string())),
203
+ })),
204
+ }));
196
205
  async function loadAIGNEFile(path) {
197
206
  const file = await findAIGNEFile(path);
198
207
  const raw = await (0, type_utils_js_1.tryOrThrow)(() => index_js_1.nodejs.fs.readFile(file, "utf8"), (error) => new Error(`Failed to load aigne.yaml from ${file}: ${error.message}`));
199
- const json = (0, type_utils_js_1.tryOrThrow)(() => (0, camelize_ts_1.default)((0, yaml_1.parse)(raw)), (error) => new Error(`Failed to parse aigne.yaml from ${file}: ${error.message}`));
200
- const aigne = (0, type_utils_js_1.tryOrThrow)(() => aigneFileSchema.parse({
201
- ...json,
202
- model: json.model ?? json.chatModel,
203
- skills: json.skills ?? json.tools,
204
- }), (error) => new Error(`Failed to validate aigne.yaml from ${file}: ${error.message}`));
208
+ const json = (0, type_utils_js_1.tryOrThrow)(() => (0, yaml_1.parse)(raw), (error) => new Error(`Failed to parse aigne.yaml from ${file}: ${error.message}`));
209
+ const aigne = (0, type_utils_js_1.tryOrThrow)(() => aigneFileSchema.parse({ ...json, model: json.model ?? json.chat_model ?? json.chatModel }), (error) => new Error(`Failed to validate aigne.yaml from ${file}: ${error.message}`));
205
210
  return { aigne, rootDir: index_js_1.nodejs.path.dirname(file) };
206
211
  }
207
212
  async function findAIGNEFile(path) {
@@ -30,6 +30,6 @@ export declare const defaultInputSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.
30
30
  $get: string;
31
31
  }>, z.ZodUnknown]>>;
32
32
  export declare function optionalize<T>(schema: ZodType<T>): ZodType<T | undefined>;
33
- export declare function camelizeSchema<T>(schema: ZodType<T>, { shallow }?: {
33
+ export declare function camelizeSchema<T extends ZodType>(schema: T, { shallow }?: {
34
34
  shallow?: boolean;
35
- }): ZodType<T>;
35
+ }): T;
@@ -61,6 +61,10 @@ export interface AgentOptions<I extends Message = Message, O extends Message = M
61
61
  * if not specified
62
62
  */
63
63
  name?: string;
64
+ /**
65
+ * Alias for the agent, can be used to refer to the agent by multiple names, especially in AIGNE CLI
66
+ */
67
+ alias?: string[];
64
68
  /**
65
69
  * Description of the agent
66
70
  *
@@ -232,6 +236,10 @@ export declare abstract class Agent<I extends Message = any, O extends Message =
232
236
  * Defaults to the class constructor name if not specified in options
233
237
  */
234
238
  readonly name: string;
239
+ /**
240
+ * Alias for the agent, can be used to refer to the agent by multiple names, especially in AIGNE CLI
241
+ */
242
+ readonly alias?: string[];
235
243
  /**
236
244
  * Default topic this agent subscribes to
237
245
  *
@@ -35,6 +35,12 @@ export interface AIGNEOptions {
35
35
  * Agents to use for the AIGNE instance.
36
36
  */
37
37
  agents?: Agent[];
38
+ mcpServer?: {
39
+ agents?: Agent[];
40
+ };
41
+ cli?: {
42
+ agents?: Agent[];
43
+ };
38
44
  /**
39
45
  * Limits for the AIGNE instance, such as timeout, max tokens, max invocations, etc.
40
46
  */
@@ -112,6 +118,16 @@ export declare class AIGNE<U extends UserContext = UserContext> {
112
118
  readonly agents: Agent<any, any>[] & {
113
119
  [key: string]: Agent<any, any>;
114
120
  };
121
+ readonly mcpServer: {
122
+ agents: Agent<any, any>[] & {
123
+ [key: string]: Agent<any, any>;
124
+ };
125
+ };
126
+ readonly cli: {
127
+ agents: Agent<any, any>[] & {
128
+ [key: string]: Agent<any, any>;
129
+ };
130
+ };
115
131
  /**
116
132
  * Observer for the AIGNE instance.
117
133
  */
@@ -67,6 +67,16 @@ declare const aigneFileSchema: z.ZodObject<{
67
67
  } | undefined>;
68
68
  agents: z.ZodType<string[] | undefined, z.ZodTypeDef, string[] | undefined>;
69
69
  skills: z.ZodType<string[] | undefined, z.ZodTypeDef, string[] | undefined>;
70
+ mcpServer: z.ZodType<{
71
+ agents?: string[] | undefined;
72
+ } | undefined, z.ZodTypeDef, {
73
+ agents?: string[] | undefined;
74
+ } | undefined>;
75
+ cli: z.ZodType<{
76
+ agents?: string[] | undefined;
77
+ } | undefined, z.ZodTypeDef, {
78
+ agents?: string[] | undefined;
79
+ } | undefined>;
70
80
  }, "strip", z.ZodTypeAny, {
71
81
  name?: string | undefined;
72
82
  description?: string | undefined;
@@ -80,6 +90,12 @@ declare const aigneFileSchema: z.ZodObject<{
80
90
  provider?: string | null | undefined;
81
91
  } | undefined;
82
92
  agents?: string[] | undefined;
93
+ mcpServer?: {
94
+ agents?: string[] | undefined;
95
+ } | undefined;
96
+ cli?: {
97
+ agents?: string[] | undefined;
98
+ } | undefined;
83
99
  }, {
84
100
  name?: string | undefined;
85
101
  description?: string | undefined;
@@ -93,6 +109,12 @@ declare const aigneFileSchema: z.ZodObject<{
93
109
  provider?: string | null | undefined;
94
110
  } | undefined;
95
111
  agents?: string[] | undefined;
112
+ mcpServer?: {
113
+ agents?: string[] | undefined;
114
+ } | undefined;
115
+ cli?: {
116
+ agents?: string[] | undefined;
117
+ } | undefined;
96
118
  }>;
97
119
  export declare function loadAIGNEFile(path: string): Promise<{
98
120
  aigne: z.infer<typeof aigneFileSchema>;
@@ -30,6 +30,6 @@ export declare const defaultInputSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.
30
30
  $get: string;
31
31
  }>, z.ZodUnknown]>>;
32
32
  export declare function optionalize<T>(schema: ZodType<T>): ZodType<T | undefined>;
33
- export declare function camelizeSchema<T>(schema: ZodType<T>, { shallow }?: {
33
+ export declare function camelizeSchema<T extends ZodType>(schema: T, { shallow }?: {
34
34
  shallow?: boolean;
35
- }): ZodType<T>;
35
+ }): T;
@@ -61,6 +61,10 @@ export interface AgentOptions<I extends Message = Message, O extends Message = M
61
61
  * if not specified
62
62
  */
63
63
  name?: string;
64
+ /**
65
+ * Alias for the agent, can be used to refer to the agent by multiple names, especially in AIGNE CLI
66
+ */
67
+ alias?: string[];
64
68
  /**
65
69
  * Description of the agent
66
70
  *
@@ -232,6 +236,10 @@ export declare abstract class Agent<I extends Message = any, O extends Message =
232
236
  * Defaults to the class constructor name if not specified in options
233
237
  */
234
238
  readonly name: string;
239
+ /**
240
+ * Alias for the agent, can be used to refer to the agent by multiple names, especially in AIGNE CLI
241
+ */
242
+ readonly alias?: string[];
235
243
  /**
236
244
  * Default topic this agent subscribes to
237
245
  *
@@ -57,6 +57,7 @@ export class Agent {
57
57
  constructor(options = {}) {
58
58
  const { inputSchema, outputSchema } = options;
59
59
  this.name = options.name || this.constructor.name;
60
+ this.alias = options.alias;
60
61
  this.description = options.description;
61
62
  if (inputSchema)
62
63
  checkAgentInputOutputSchema(inputSchema);
@@ -125,6 +126,10 @@ export class Agent {
125
126
  * Defaults to the class constructor name if not specified in options
126
127
  */
127
128
  name;
129
+ /**
130
+ * Alias for the agent, can be used to refer to the agent by multiple names, especially in AIGNE CLI
131
+ */
132
+ alias;
128
133
  /**
129
134
  * Default topic this agent subscribes to
130
135
  *
@@ -35,6 +35,12 @@ export interface AIGNEOptions {
35
35
  * Agents to use for the AIGNE instance.
36
36
  */
37
37
  agents?: Agent[];
38
+ mcpServer?: {
39
+ agents?: Agent[];
40
+ };
41
+ cli?: {
42
+ agents?: Agent[];
43
+ };
38
44
  /**
39
45
  * Limits for the AIGNE instance, such as timeout, max tokens, max invocations, etc.
40
46
  */
@@ -112,6 +118,16 @@ export declare class AIGNE<U extends UserContext = UserContext> {
112
118
  readonly agents: Agent<any, any>[] & {
113
119
  [key: string]: Agent<any, any>;
114
120
  };
121
+ readonly mcpServer: {
122
+ agents: Agent<any, any>[] & {
123
+ [key: string]: Agent<any, any>;
124
+ };
125
+ };
126
+ readonly cli: {
127
+ agents: Agent<any, any>[] & {
128
+ [key: string]: Agent<any, any>;
129
+ };
130
+ };
115
131
  /**
116
132
  * Observer for the AIGNE instance.
117
133
  */
@@ -28,6 +28,7 @@ export class AIGNE {
28
28
  static async load(path, options) {
29
29
  const { model, agents = [], skills = [], ...aigne } = await load({ ...options, path });
30
30
  return new AIGNE({
31
+ ...aigne,
31
32
  ...options,
32
33
  rootDir: aigne.rootDir,
33
34
  model: options?.model || model,
@@ -58,6 +59,10 @@ export class AIGNE {
58
59
  this.skills.push(...options.skills);
59
60
  if (options?.agents?.length)
60
61
  this.addAgent(...options.agents);
62
+ if (options?.mcpServer?.agents?.length)
63
+ this.mcpServer.agents.push(...options.mcpServer.agents);
64
+ if (options?.cli?.agents?.length)
65
+ this.cli.agents.push(...options.cli.agents);
61
66
  this.observer?.serve();
62
67
  this.initProcessExitHandler();
63
68
  }
@@ -97,6 +102,12 @@ export class AIGNE {
97
102
  * Provides indexed access by agent name.
98
103
  */
99
104
  agents = createAccessorArray([], (arr, name) => arr.find((i) => i.name === name));
105
+ mcpServer = {
106
+ agents: createAccessorArray([], (arr, name) => arr.find((i) => i.name === name)),
107
+ };
108
+ cli = {
109
+ agents: createAccessorArray([], (arr, name) => arr.find((i) => i.name === name)),
110
+ };
100
111
  /**
101
112
  * Observer for the AIGNE instance.
102
113
  */
@@ -28,6 +28,7 @@ export async function parseAgentFile(path, data) {
28
28
  }));
29
29
  const baseAgentSchema = z.object({
30
30
  name: optionalize(z.string()),
31
+ alias: optionalize(z.array(z.string())),
31
32
  description: optionalize(z.string()),
32
33
  inputSchema: optionalize(inputOutputSchema({ path })).transform((v) => v ? jsonSchemaToZod(v) : undefined),
33
34
  defaultInput: optionalize(defaultInputSchema),
@@ -67,6 +67,16 @@ declare const aigneFileSchema: z.ZodObject<{
67
67
  } | undefined>;
68
68
  agents: z.ZodType<string[] | undefined, z.ZodTypeDef, string[] | undefined>;
69
69
  skills: z.ZodType<string[] | undefined, z.ZodTypeDef, string[] | undefined>;
70
+ mcpServer: z.ZodType<{
71
+ agents?: string[] | undefined;
72
+ } | undefined, z.ZodTypeDef, {
73
+ agents?: string[] | undefined;
74
+ } | undefined>;
75
+ cli: z.ZodType<{
76
+ agents?: string[] | undefined;
77
+ } | undefined, z.ZodTypeDef, {
78
+ agents?: string[] | undefined;
79
+ } | undefined>;
70
80
  }, "strip", z.ZodTypeAny, {
71
81
  name?: string | undefined;
72
82
  description?: string | undefined;
@@ -80,6 +90,12 @@ declare const aigneFileSchema: z.ZodObject<{
80
90
  provider?: string | null | undefined;
81
91
  } | undefined;
82
92
  agents?: string[] | undefined;
93
+ mcpServer?: {
94
+ agents?: string[] | undefined;
95
+ } | undefined;
96
+ cli?: {
97
+ agents?: string[] | undefined;
98
+ } | undefined;
83
99
  }, {
84
100
  name?: string | undefined;
85
101
  description?: string | undefined;
@@ -93,6 +109,12 @@ declare const aigneFileSchema: z.ZodObject<{
93
109
  provider?: string | null | undefined;
94
110
  } | undefined;
95
111
  agents?: string[] | undefined;
112
+ mcpServer?: {
113
+ agents?: string[] | undefined;
114
+ } | undefined;
115
+ cli?: {
116
+ agents?: string[] | undefined;
117
+ } | undefined;
96
118
  }>;
97
119
  export declare function loadAIGNEFile(path: string): Promise<{
98
120
  aigne: z.infer<typeof aigneFileSchema>;
@@ -1,5 +1,4 @@
1
1
  import { nodejs } from "@aigne/platform-helpers/nodejs/index.js";
2
- import camelize from "camelize-ts";
3
2
  import { parse } from "yaml";
4
3
  import { z } from "zod";
5
4
  import { Agent, FunctionAgent } from "../agents/agent.js";
@@ -8,15 +7,16 @@ import { MCPAgent } from "../agents/mcp-agent.js";
8
7
  import { TeamAgent } from "../agents/team-agent.js";
9
8
  import { TransformAgent } from "../agents/transform-agent.js";
10
9
  import { PromptBuilder } from "../prompt/prompt-builder.js";
11
- import { isNonNullable, tryOrThrow } from "../utils/type-utils.js";
10
+ import { flat, isNonNullable, tryOrThrow } from "../utils/type-utils.js";
12
11
  import { loadAgentFromJsFile } from "./agent-js.js";
13
12
  import { loadAgentFromYamlFile } from "./agent-yaml.js";
14
- import { optionalize } from "./schema.js";
13
+ import { camelizeSchema, optionalize } from "./schema.js";
15
14
  const AIGNE_FILE_NAME = ["aigne.yaml", "aigne.yml"];
16
15
  export async function load(options) {
17
16
  const { aigne, rootDir } = await loadAIGNEFile(options.path);
18
- const agents = await Promise.all((aigne.agents ?? []).map((filename) => loadAgent(nodejs.path.join(rootDir, filename), options)));
19
- const skills = await Promise.all((aigne.skills ?? []).map((filename) => loadAgent(nodejs.path.join(rootDir, filename), options)));
17
+ const allAgentPaths = new Set(flat(aigne.agents, aigne.skills, aigne.mcpServer?.agents, aigne.cli?.agents).map((i) => nodejs.path.join(rootDir, i)));
18
+ const allAgents = Object.fromEntries(await Promise.all(Array.from(allAgentPaths).map(async (path) => [path, await loadAgent(path, options)])));
19
+ const pickAgents = (paths) => paths.map((filename) => allAgents[nodejs.path.join(rootDir, filename)]).filter(isNonNullable);
20
20
  return {
21
21
  ...aigne,
22
22
  rootDir,
@@ -26,8 +26,14 @@ export async function load(options) {
26
26
  create: (options) => new i(options),
27
27
  }
28
28
  : i), aigne.model),
29
- agents,
30
- skills,
29
+ agents: pickAgents(aigne.agents ?? []),
30
+ skills: pickAgents(aigne.skills ?? []),
31
+ mcpServer: {
32
+ agents: pickAgents(aigne.mcpServer?.agents ?? []),
33
+ },
34
+ cli: {
35
+ agents: pickAgents(aigne.cli?.agents ?? []),
36
+ },
31
37
  };
32
38
  }
33
39
  export async function loadAgent(path, options, agentOptions) {
@@ -167,32 +173,34 @@ export async function loadModel(models, model, modelOptions, accessKeyOptions) {
167
173
  modelOptions: { ...params, ...modelOptions },
168
174
  });
169
175
  }
170
- const aigneFileSchema = z.object({
176
+ const aigneFileSchema = camelizeSchema(z.object({
171
177
  name: optionalize(z.string()),
172
178
  description: optionalize(z.string()),
173
179
  model: optionalize(z.union([
174
180
  z.string(),
175
- z.object({
181
+ camelizeSchema(z.object({
176
182
  provider: z.string().nullish(),
177
183
  name: z.string().nullish(),
178
184
  temperature: z.number().min(0).max(2).nullish(),
179
185
  topP: z.number().min(0).nullish(),
180
186
  frequencyPenalty: z.number().min(-2).max(2).nullish(),
181
187
  presencePenalty: z.number().min(-2).max(2).nullish(),
182
- }),
188
+ })),
183
189
  ])).transform((v) => (typeof v === "string" ? { name: v } : v)),
184
190
  agents: optionalize(z.array(z.string())),
185
191
  skills: optionalize(z.array(z.string())),
186
- });
192
+ mcpServer: optionalize(z.object({
193
+ agents: optionalize(z.array(z.string())),
194
+ })),
195
+ cli: optionalize(z.object({
196
+ agents: optionalize(z.array(z.string())),
197
+ })),
198
+ }));
187
199
  export async function loadAIGNEFile(path) {
188
200
  const file = await findAIGNEFile(path);
189
201
  const raw = await tryOrThrow(() => nodejs.fs.readFile(file, "utf8"), (error) => new Error(`Failed to load aigne.yaml from ${file}: ${error.message}`));
190
- const json = tryOrThrow(() => camelize(parse(raw)), (error) => new Error(`Failed to parse aigne.yaml from ${file}: ${error.message}`));
191
- const aigne = tryOrThrow(() => aigneFileSchema.parse({
192
- ...json,
193
- model: json.model ?? json.chatModel,
194
- skills: json.skills ?? json.tools,
195
- }), (error) => new Error(`Failed to validate aigne.yaml from ${file}: ${error.message}`));
202
+ const json = tryOrThrow(() => parse(raw), (error) => new Error(`Failed to parse aigne.yaml from ${file}: ${error.message}`));
203
+ const aigne = tryOrThrow(() => aigneFileSchema.parse({ ...json, model: json.model ?? json.chat_model ?? json.chatModel }), (error) => new Error(`Failed to validate aigne.yaml from ${file}: ${error.message}`));
196
204
  return { aigne, rootDir: nodejs.path.dirname(file) };
197
205
  }
198
206
  async function findAIGNEFile(path) {
@@ -30,6 +30,6 @@ export declare const defaultInputSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.
30
30
  $get: string;
31
31
  }>, z.ZodUnknown]>>;
32
32
  export declare function optionalize<T>(schema: ZodType<T>): ZodType<T | undefined>;
33
- export declare function camelizeSchema<T>(schema: ZodType<T>, { shallow }?: {
33
+ export declare function camelizeSchema<T extends ZodType>(schema: T, { shallow }?: {
34
34
  shallow?: boolean;
35
- }): ZodType<T>;
35
+ }): T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/core",
3
- "version": "1.39.0",
3
+ "version": "1.41.0",
4
4
  "description": "AIGNE core library for building AI-powered applications",
5
5
  "publishConfig": {
6
6
  "access": "public"