@aigne/core 1.72.0-beta.3 → 1.72.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.
Files changed (99) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/lib/cjs/agents/agent.d.ts +31 -1
  3. package/lib/cjs/agents/agent.js +13 -0
  4. package/lib/cjs/agents/ai-agent.d.ts +7 -0
  5. package/lib/cjs/agents/ai-agent.js +85 -3
  6. package/lib/cjs/agents/image-agent.d.ts +17 -1
  7. package/lib/cjs/agents/image-agent.js +16 -0
  8. package/lib/cjs/agents/image-model.d.ts +4 -4
  9. package/lib/cjs/agents/mcp-agent.d.ts +17 -0
  10. package/lib/cjs/agents/mcp-agent.js +18 -0
  11. package/lib/cjs/agents/team-agent.d.ts +55 -0
  12. package/lib/cjs/agents/team-agent.js +31 -0
  13. package/lib/cjs/agents/transform-agent.d.ts +12 -0
  14. package/lib/cjs/agents/transform-agent.js +13 -0
  15. package/lib/cjs/agents/video-model.d.ts +4 -4
  16. package/lib/cjs/loader/agent-yaml.d.ts +5 -67
  17. package/lib/cjs/loader/agent-yaml.js +4 -139
  18. package/lib/cjs/loader/agents.d.ts +4 -0
  19. package/lib/cjs/loader/agents.js +17 -0
  20. package/lib/cjs/loader/index.d.ts +18 -14
  21. package/lib/cjs/loader/index.js +20 -81
  22. package/lib/cjs/loader/schema.d.ts +21 -6
  23. package/lib/cjs/loader/schema.js +60 -1
  24. package/lib/cjs/prompt/prompt-builder.js +0 -1
  25. package/lib/cjs/prompt/skills/afs/agent-skill/agent-skill.d.ts +17 -0
  26. package/lib/cjs/prompt/skills/afs/agent-skill/agent-skill.js +63 -0
  27. package/lib/cjs/prompt/skills/afs/agent-skill/skill-loader.d.ts +13 -0
  28. package/lib/cjs/prompt/skills/afs/agent-skill/skill-loader.js +61 -0
  29. package/lib/cjs/prompt/skills/afs/delete.js +15 -3
  30. package/lib/cjs/prompt/skills/afs/edit.d.ts +6 -9
  31. package/lib/cjs/prompt/skills/afs/edit.js +85 -59
  32. package/lib/cjs/prompt/skills/afs/exec.js +17 -6
  33. package/lib/cjs/prompt/skills/afs/index.js +4 -1
  34. package/lib/cjs/prompt/skills/afs/list.js +26 -10
  35. package/lib/cjs/prompt/skills/afs/read.d.ts +6 -2
  36. package/lib/cjs/prompt/skills/afs/read.js +62 -15
  37. package/lib/cjs/prompt/skills/afs/rename.js +18 -4
  38. package/lib/cjs/prompt/skills/afs/search.js +21 -5
  39. package/lib/cjs/prompt/skills/afs/write.js +20 -6
  40. package/lib/cjs/prompt/template.d.ts +23 -23
  41. package/lib/dts/agents/agent.d.ts +31 -1
  42. package/lib/dts/agents/ai-agent.d.ts +7 -0
  43. package/lib/dts/agents/image-agent.d.ts +17 -1
  44. package/lib/dts/agents/image-model.d.ts +4 -4
  45. package/lib/dts/agents/mcp-agent.d.ts +17 -0
  46. package/lib/dts/agents/team-agent.d.ts +55 -0
  47. package/lib/dts/agents/transform-agent.d.ts +12 -0
  48. package/lib/dts/agents/video-model.d.ts +4 -4
  49. package/lib/dts/aigne/context.d.ts +2 -2
  50. package/lib/dts/loader/agent-yaml.d.ts +5 -67
  51. package/lib/dts/loader/agents.d.ts +4 -0
  52. package/lib/dts/loader/index.d.ts +18 -14
  53. package/lib/dts/loader/schema.d.ts +21 -6
  54. package/lib/dts/prompt/skills/afs/agent-skill/agent-skill.d.ts +17 -0
  55. package/lib/dts/prompt/skills/afs/agent-skill/skill-loader.d.ts +13 -0
  56. package/lib/dts/prompt/skills/afs/edit.d.ts +6 -9
  57. package/lib/dts/prompt/skills/afs/read.d.ts +6 -2
  58. package/lib/dts/prompt/template.d.ts +25 -25
  59. package/lib/esm/agents/agent.d.ts +31 -1
  60. package/lib/esm/agents/agent.js +13 -0
  61. package/lib/esm/agents/ai-agent.d.ts +7 -0
  62. package/lib/esm/agents/ai-agent.js +85 -3
  63. package/lib/esm/agents/image-agent.d.ts +17 -1
  64. package/lib/esm/agents/image-agent.js +16 -0
  65. package/lib/esm/agents/image-model.d.ts +4 -4
  66. package/lib/esm/agents/mcp-agent.d.ts +17 -0
  67. package/lib/esm/agents/mcp-agent.js +18 -0
  68. package/lib/esm/agents/team-agent.d.ts +55 -0
  69. package/lib/esm/agents/team-agent.js +31 -0
  70. package/lib/esm/agents/transform-agent.d.ts +12 -0
  71. package/lib/esm/agents/transform-agent.js +13 -0
  72. package/lib/esm/agents/video-model.d.ts +4 -4
  73. package/lib/esm/aigne/context.d.ts +2 -2
  74. package/lib/esm/loader/agent-yaml.d.ts +5 -67
  75. package/lib/esm/loader/agent-yaml.js +4 -138
  76. package/lib/esm/loader/agents.d.ts +4 -0
  77. package/lib/esm/loader/agents.js +14 -0
  78. package/lib/esm/loader/index.d.ts +18 -14
  79. package/lib/esm/loader/index.js +21 -81
  80. package/lib/esm/loader/schema.d.ts +21 -6
  81. package/lib/esm/loader/schema.js +57 -0
  82. package/lib/esm/prompt/prompt-builder.js +1 -2
  83. package/lib/esm/prompt/skills/afs/agent-skill/agent-skill.d.ts +17 -0
  84. package/lib/esm/prompt/skills/afs/agent-skill/agent-skill.js +59 -0
  85. package/lib/esm/prompt/skills/afs/agent-skill/skill-loader.d.ts +13 -0
  86. package/lib/esm/prompt/skills/afs/agent-skill/skill-loader.js +53 -0
  87. package/lib/esm/prompt/skills/afs/delete.js +15 -3
  88. package/lib/esm/prompt/skills/afs/edit.d.ts +6 -9
  89. package/lib/esm/prompt/skills/afs/edit.js +85 -59
  90. package/lib/esm/prompt/skills/afs/exec.js +17 -6
  91. package/lib/esm/prompt/skills/afs/index.js +4 -1
  92. package/lib/esm/prompt/skills/afs/list.js +26 -10
  93. package/lib/esm/prompt/skills/afs/read.d.ts +6 -2
  94. package/lib/esm/prompt/skills/afs/read.js +62 -15
  95. package/lib/esm/prompt/skills/afs/rename.js +18 -4
  96. package/lib/esm/prompt/skills/afs/search.js +21 -5
  97. package/lib/esm/prompt/skills/afs/write.js +20 -6
  98. package/lib/esm/prompt/template.d.ts +25 -25
  99. package/package.json +5 -4
@@ -3,26 +3,51 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AFSReadAgent = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const base_js_1 = require("./base.js");
6
+ const DEFAULT_LINE_LIMIT = 2000;
7
+ const MAX_LINE_LENGTH = 2000;
6
8
  class AFSReadAgent extends base_js_1.AFSSkillBase {
7
9
  constructor(options) {
8
10
  super({
9
11
  name: "afs_read",
10
- description: "Read complete file contents. Use when you need to review, analyze, or understand file content before making changes.",
12
+ description: `Read file contents from the Agentic File System (AFS)
13
+ - Returns the content of a file at the specified AFS path
14
+ - By default reads up to ${DEFAULT_LINE_LIMIT} lines, use offset/limit for large files
15
+ - Lines longer than ${MAX_LINE_LENGTH} characters will be truncated
16
+
17
+ Usage:
18
+ - The path must be an absolute AFS path starting with "/" (e.g., "/docs/readme.md")
19
+ - Use offset to start reading from a specific line (0-based)
20
+ - Use limit to control number of lines returned (default: ${DEFAULT_LINE_LIMIT})
21
+ - Check truncated field to know if file was partially returned`,
11
22
  ...options,
12
23
  inputSchema: zod_1.z.object({
13
- path: zod_1.z.string().describe("Absolute file path to read"),
14
- withLineNumbers: zod_1.z
15
- .boolean()
24
+ path: zod_1.z
25
+ .string()
26
+ .describe("Absolute AFS path to the file to read (e.g., '/docs/readme.md'). Must start with '/'"),
27
+ offset: zod_1.z
28
+ .number()
29
+ .int()
30
+ .min(0)
16
31
  .optional()
17
- .describe("Include line numbers in output (required when planning to edit the file)"),
32
+ .describe("Line number to start reading from (0-based, default: 0)"),
33
+ limit: zod_1.z
34
+ .number()
35
+ .int()
36
+ .min(1)
37
+ .max(DEFAULT_LINE_LIMIT)
38
+ .optional()
39
+ .describe(`Maximum number of lines to read (default: ${DEFAULT_LINE_LIMIT})`),
18
40
  }),
19
41
  outputSchema: zod_1.z.object({
20
42
  status: zod_1.z.string(),
21
43
  tool: zod_1.z.string(),
22
44
  path: zod_1.z.string(),
23
- withLineNumbers: zod_1.z.boolean().optional(),
24
45
  data: zod_1.z.custom().optional(),
25
46
  message: zod_1.z.string().optional(),
47
+ totalLines: zod_1.z.number().optional(),
48
+ returnedLines: zod_1.z.number().optional(),
49
+ truncated: zod_1.z.boolean().optional(),
50
+ offset: zod_1.z.number().optional(),
26
51
  }),
27
52
  });
28
53
  }
@@ -30,22 +55,44 @@ class AFSReadAgent extends base_js_1.AFSSkillBase {
30
55
  if (!this.afs)
31
56
  throw new Error("AFS is not configured for this agent.");
32
57
  const result = await this.afs.read(input.path);
33
- let content = result.data?.content;
34
- if (input.withLineNumbers && typeof content === "string") {
35
- content = content
36
- .split("\n")
37
- .map((line, idx) => `${idx + 1}| ${line}`)
38
- .join("\n");
58
+ if (!result.data?.content || typeof result.data.content !== "string") {
59
+ return {
60
+ status: "success",
61
+ tool: "afs_read",
62
+ path: input.path,
63
+ ...result,
64
+ };
65
+ }
66
+ const offset = input.offset ?? 0;
67
+ const limit = input.limit ?? DEFAULT_LINE_LIMIT;
68
+ const allLines = result.data.content.split("\n");
69
+ const totalLines = allLines.length;
70
+ // Apply offset and limit
71
+ const selectedLines = allLines.slice(offset, offset + limit);
72
+ // Truncate long lines
73
+ const processedLines = selectedLines.map((line) => line.length > MAX_LINE_LENGTH ? `${line.substring(0, MAX_LINE_LENGTH)}... [truncated]` : line);
74
+ const returnedLines = processedLines.length;
75
+ const truncated = offset > 0 || offset + limit < totalLines;
76
+ const processedContent = processedLines.join("\n");
77
+ let message;
78
+ if (truncated) {
79
+ const startLine = offset + 1;
80
+ const endLine = offset + returnedLines;
81
+ message = `Showing lines ${startLine}-${endLine} of ${totalLines}. Use offset/limit to read more.`;
39
82
  }
40
83
  return {
41
84
  status: "success",
42
85
  tool: "afs_read",
43
86
  path: input.path,
44
- withLineNumbers: input.withLineNumbers,
87
+ totalLines,
88
+ returnedLines,
89
+ truncated,
90
+ offset,
91
+ message,
45
92
  ...result,
46
- data: result.data && {
93
+ data: {
47
94
  ...result.data,
48
- content,
95
+ content: processedContent,
49
96
  },
50
97
  };
51
98
  }
@@ -7,16 +7,30 @@ class AFSRenameAgent extends base_js_1.AFSSkillBase {
7
7
  constructor(options) {
8
8
  super({
9
9
  name: "afs_rename",
10
- description: "Rename or move files and directories. Use when reorganizing files, changing names, or moving to different locations.",
10
+ description: `Rename or move files and directories within the Agentic File System (AFS)
11
+ - Renames a file or directory to a new name
12
+ - Can also move files/directories to a different location
13
+ - Optionally overwrites existing files at the destination
14
+
15
+ Usage:
16
+ - Both paths must be absolute AFS paths starting with "/" (e.g., "/docs/old-name.md" -> "/docs/new-name.md")
17
+ - This is NOT a local system file path - it operates within the AFS virtual file system
18
+ - To move a file, specify a different directory in newPath (e.g., "/docs/file.md" -> "/archive/file.md")
19
+ - If newPath already exists, the operation will fail unless overwrite=true
20
+ - Moving directories moves all contents recursively`,
11
21
  ...options,
12
22
  inputSchema: zod_1.z.object({
13
- oldPath: zod_1.z.string().describe("Absolute current file or directory path"),
14
- newPath: zod_1.z.string().describe("Absolute new file or directory path"),
23
+ oldPath: zod_1.z
24
+ .string()
25
+ .describe("Current absolute AFS path (e.g., '/docs/old-name.md'). Must start with '/'"),
26
+ newPath: zod_1.z
27
+ .string()
28
+ .describe("New absolute AFS path (e.g., '/docs/new-name.md'). Must start with '/'"),
15
29
  overwrite: zod_1.z
16
30
  .boolean()
17
31
  .optional()
18
32
  .default(false)
19
- .describe("Overwrite if destination exists (default: false)"),
33
+ .describe("Set to true to overwrite if destination already exists. Default: false (fails if exists)"),
20
34
  }),
21
35
  outputSchema: zod_1.z.object({
22
36
  status: zod_1.z.string(),
@@ -7,18 +7,34 @@ class AFSSearchAgent extends base_js_1.AFSSkillBase {
7
7
  constructor(options) {
8
8
  super({
9
9
  name: "afs_search",
10
- description: "Search file contents by keywords. Use when finding files containing specific text or code patterns.",
10
+ description: `Search file contents within the Agentic File System (AFS)
11
+ - Searches for files containing specific text, keywords, or patterns
12
+ - Returns matching entries with their content and metadata
13
+ - Supports case-sensitive and case-insensitive search modes
14
+ - Use this tool when you need to find files by their content
15
+
16
+ Usage:
17
+ - The path must be an absolute AFS path starting with "/" (e.g., "/", "/docs", "/memory")
18
+ - This is NOT a local system file path - it operates within the AFS virtual file system
19
+ - The query can be keywords, phrases, or text patterns to search for
20
+ - Use limit to control the number of results returned
21
+ - Search is case-insensitive by default; set caseSensitive to true for exact case matching`,
11
22
  ...options,
12
23
  inputSchema: zod_1.z.object({
13
- path: zod_1.z.string().describe("Absolute directory path to search in"),
14
- query: zod_1.z.string().describe("Search keywords or patterns"),
24
+ path: zod_1.z
25
+ .string()
26
+ .describe("Absolute AFS path to search in (e.g., '/', '/docs', '/memory'). Must start with '/'"),
27
+ query: zod_1.z.string().describe("Text, keywords, or patterns to search for in file contents"),
15
28
  options: zod_1.z
16
29
  .object({
17
- limit: zod_1.z.number().optional().describe("Max results to return"),
30
+ limit: zod_1.z
31
+ .number()
32
+ .optional()
33
+ .describe("Maximum number of results to return. Useful for limiting output size"),
18
34
  caseSensitive: zod_1.z
19
35
  .boolean()
20
36
  .optional()
21
- .describe("Case-sensitive search (default: false)"),
37
+ .describe("Set to true for case-sensitive matching. Default: false (case-insensitive)"),
22
38
  })
23
39
  .optional(),
24
40
  }),
@@ -7,16 +7,30 @@ class AFSWriteAgent extends base_js_1.AFSSkillBase {
7
7
  constructor(options) {
8
8
  super({
9
9
  name: "afs_write",
10
- description: "Create new file or append content to existing file. Use when creating files, rewriting entire files, or appending to files.",
10
+ description: `Write or create files in the Agentic File System (AFS)
11
+ - Creates a new file or overwrites an existing file with the provided content
12
+ - Supports append mode to add content to the end of existing files
13
+ - Use this tool when creating new files or completely replacing file contents
14
+
15
+ Usage:
16
+ - The path must be an absolute AFS path starting with "/" (e.g., "/docs/new-file.md", "/memory/user/notes")
17
+ - This is NOT a local system file path - it operates within the AFS virtual file system
18
+ - By default, this tool overwrites the entire file content
19
+ - Use append mode to add content to the end of an existing file without replacing it
20
+ - For partial edits to existing files, prefer using afs_edit instead`,
11
21
  ...options,
12
22
  inputSchema: zod_1.z.object({
13
- path: zod_1.z.string().describe("Absolute file path to write"),
14
- content: zod_1.z.string().describe("Complete file content or content to append"),
23
+ path: zod_1.z
24
+ .string()
25
+ .describe("Absolute AFS path for the file to write (e.g., '/docs/new-file.md'). Must start with '/'"),
26
+ content: zod_1.z
27
+ .string()
28
+ .describe("The content to write to the file. In overwrite mode, this replaces the entire file"),
15
29
  append: zod_1.z
16
30
  .boolean()
17
31
  .optional()
18
32
  .default(false)
19
- .describe("Append mode: add content to end of file (default: false, overwrites file)"),
33
+ .describe("Set to true to append content to the end of an existing file. Default: false (overwrites entire file)"),
20
34
  }),
21
35
  outputSchema: zod_1.z.object({
22
36
  status: zod_1.z.string(),
@@ -29,7 +43,7 @@ class AFSWriteAgent extends base_js_1.AFSSkillBase {
29
43
  async process(input, _options) {
30
44
  if (!this.afs)
31
45
  throw new Error("AFS is not configured for this agent.");
32
- const result = await this.afs.write(input.path, {
46
+ const _result = await this.afs.write(input.path, {
33
47
  content: input.content,
34
48
  }, {
35
49
  append: input.append ?? false,
@@ -38,7 +52,7 @@ class AFSWriteAgent extends base_js_1.AFSSkillBase {
38
52
  status: "success",
39
53
  tool: "afs_write",
40
54
  path: input.path,
41
- ...result,
55
+ message: "File written successfully",
42
56
  };
43
57
  }
44
58
  }
@@ -42,7 +42,7 @@ export declare class AgentMessageTemplate extends ChatMessageTemplate {
42
42
  static from(template?: ChatModelInputMessage["content"], toolCalls?: ChatModelOutputToolCall[], name?: string, options?: FormatOptions, cacheControl?: ChatModelInputMessage["cacheControl"]): AgentMessageTemplate;
43
43
  constructor(content?: ChatModelInputMessage["content"], toolCalls?: ChatModelOutputToolCall[] | undefined, name?: string, options?: FormatOptions, cacheControl?: ChatModelInputMessage["cacheControl"]);
44
44
  format(_variables?: Record<string, unknown>, _options?: FormatOptions): Promise<{
45
- role: "agent" | "system" | "user" | "tool";
45
+ role: "system" | "user" | "agent" | "tool";
46
46
  name: string | undefined;
47
47
  content: ChatModelInputMessageContent | undefined;
48
48
  toolCalls: ChatModelOutputToolCall[] | undefined;
@@ -54,7 +54,7 @@ export declare class ToolMessageTemplate extends ChatMessageTemplate {
54
54
  static from(content: object | string, toolCallId: string, name?: string, options?: FormatOptions, cacheControl?: ChatModelInputMessage["cacheControl"]): ToolMessageTemplate;
55
55
  constructor(content: object | string, toolCallId: string, name?: string, options?: FormatOptions, cacheControl?: ChatModelInputMessage["cacheControl"]);
56
56
  format(_variables?: Record<string, unknown>, _options?: FormatOptions): Promise<{
57
- role: "agent" | "system" | "user" | "tool";
57
+ role: "system" | "user" | "agent" | "tool";
58
58
  name: string | undefined;
59
59
  content: ChatModelInputMessageContent | undefined;
60
60
  toolCallId: string;
@@ -83,21 +83,21 @@ declare const chatMessageSchema: z.ZodUnion<[z.ZodObject<{
83
83
  ttl?: "5m" | "1h" | undefined;
84
84
  }>>;
85
85
  }, "strip", z.ZodTypeAny, {
86
- role: "system";
87
86
  content: string;
88
- name?: string | undefined;
87
+ role: "system";
89
88
  cacheControl?: {
90
89
  type: "ephemeral";
91
90
  ttl?: "5m" | "1h" | undefined;
92
91
  } | undefined;
92
+ name?: string | undefined;
93
93
  }, {
94
- role: "system";
95
94
  content: string;
96
- name?: string | undefined;
95
+ role: "system";
97
96
  cacheControl?: {
98
97
  type: "ephemeral";
99
98
  ttl?: "5m" | "1h" | undefined;
100
99
  } | undefined;
100
+ name?: string | undefined;
101
101
  }>, z.ZodObject<{
102
102
  role: z.ZodLiteral<"user">;
103
103
  content: z.ZodString;
@@ -113,21 +113,21 @@ declare const chatMessageSchema: z.ZodUnion<[z.ZodObject<{
113
113
  ttl?: "5m" | "1h" | undefined;
114
114
  }>>;
115
115
  }, "strip", z.ZodTypeAny, {
116
- role: "user";
117
116
  content: string;
118
- name?: string | undefined;
117
+ role: "user";
119
118
  cacheControl?: {
120
119
  type: "ephemeral";
121
120
  ttl?: "5m" | "1h" | undefined;
122
121
  } | undefined;
122
+ name?: string | undefined;
123
123
  }, {
124
- role: "user";
125
124
  content: string;
126
- name?: string | undefined;
125
+ role: "user";
127
126
  cacheControl?: {
128
127
  type: "ephemeral";
129
128
  ttl?: "5m" | "1h" | undefined;
130
129
  } | undefined;
130
+ name?: string | undefined;
131
131
  }>, z.ZodObject<{
132
132
  role: z.ZodLiteral<"agent">;
133
133
  content: z.ZodOptional<z.ZodString>;
@@ -172,8 +172,11 @@ declare const chatMessageSchema: z.ZodUnion<[z.ZodObject<{
172
172
  }>>;
173
173
  }, "strip", z.ZodTypeAny, {
174
174
  role: "agent";
175
- name?: string | undefined;
176
175
  content?: string | undefined;
176
+ cacheControl?: {
177
+ type: "ephemeral";
178
+ ttl?: "5m" | "1h" | undefined;
179
+ } | undefined;
177
180
  toolCalls?: {
178
181
  function: {
179
182
  name: string;
@@ -182,14 +185,14 @@ declare const chatMessageSchema: z.ZodUnion<[z.ZodObject<{
182
185
  type: "function";
183
186
  id: string;
184
187
  }[] | undefined;
188
+ name?: string | undefined;
189
+ }, {
190
+ role: "agent";
191
+ content?: string | undefined;
185
192
  cacheControl?: {
186
193
  type: "ephemeral";
187
194
  ttl?: "5m" | "1h" | undefined;
188
195
  } | undefined;
189
- }, {
190
- role: "agent";
191
- name?: string | undefined;
192
- content?: string | undefined;
193
196
  toolCalls?: {
194
197
  function: {
195
198
  name: string;
@@ -198,10 +201,7 @@ declare const chatMessageSchema: z.ZodUnion<[z.ZodObject<{
198
201
  type: "function";
199
202
  id: string;
200
203
  }[] | undefined;
201
- cacheControl?: {
202
- type: "ephemeral";
203
- ttl?: "5m" | "1h" | undefined;
204
- } | undefined;
204
+ name?: string | undefined;
205
205
  }>, z.ZodObject<{
206
206
  role: z.ZodLiteral<"tool">;
207
207
  content: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>, string, string | Record<string, unknown>>;
@@ -218,23 +218,23 @@ declare const chatMessageSchema: z.ZodUnion<[z.ZodObject<{
218
218
  ttl?: "5m" | "1h" | undefined;
219
219
  }>>;
220
220
  }, "strip", z.ZodTypeAny, {
221
- role: "tool";
222
221
  content: string;
222
+ role: "tool";
223
223
  toolCallId: string;
224
- name?: string | undefined;
225
224
  cacheControl?: {
226
225
  type: "ephemeral";
227
226
  ttl?: "5m" | "1h" | undefined;
228
227
  } | undefined;
228
+ name?: string | undefined;
229
229
  }, {
230
- role: "tool";
231
230
  content: string | Record<string, unknown>;
231
+ role: "tool";
232
232
  toolCallId: string;
233
- name?: string | undefined;
234
233
  cacheControl?: {
235
234
  type: "ephemeral";
236
235
  ttl?: "5m" | "1h" | undefined;
237
236
  } | undefined;
237
+ name?: string | undefined;
238
238
  }>]>;
239
239
  export declare function safeParseChatMessages(messages: unknown): ChatMessageTemplate[] | undefined;
240
240
  export declare function parseChatMessages(messages: (z.infer<typeof chatMessageSchema> & {
@@ -1,7 +1,7 @@
1
1
  import { AFS, type AFSExecOptions, type AFSExecResult, type AFSListOptions, type AFSListResult, type AFSModule, type AFSOptions, type AFSReadResult, type AFSSearchOptions } from "@aigne/afs";
2
2
  import { nodejs } from "@aigne/platform-helpers/nodejs/index.js";
3
3
  import type * as prompts from "@inquirer/prompts";
4
- import { type ZodObject, type ZodType } from "zod";
4
+ import { type ZodObject, type ZodType, z } from "zod";
5
5
  import type { AgentEvent, Context, UserContext } from "../aigne/context.js";
6
6
  import type { MessagePayload } from "../aigne/message-queue.js";
7
7
  import type { ContextUsage } from "../aigne/usage.js";
@@ -783,6 +783,25 @@ export interface AgentResponseProgress {
783
783
  } | {
784
784
  event: "agentFailed";
785
785
  error: Error;
786
+ } | {
787
+ event: "message";
788
+ role: "user" | "agent";
789
+ message: ({
790
+ type: "text";
791
+ content: string;
792
+ } | {
793
+ type: "thinking";
794
+ thoughts: string;
795
+ } | {
796
+ type: "tool_use";
797
+ toolUseId: string;
798
+ name: string;
799
+ input: unknown;
800
+ } | {
801
+ type: "tool_result";
802
+ toolUseId: string;
803
+ content: unknown;
804
+ })[];
786
805
  }) & Omit<AgentEvent, "agent"> & {
787
806
  agent: {
788
807
  name: string;
@@ -870,6 +889,17 @@ export interface FunctionAgentOptions<I extends Message = Message, O extends Mes
870
889
  */
871
890
  export declare class FunctionAgent<I extends Message = Message, O extends Message = Message> extends Agent<I, O> {
872
891
  tag: string;
892
+ static schema(): ZodObject<{
893
+ process: ZodType<FunctionAgentFn>;
894
+ }, "strip", z.ZodTypeAny, {
895
+ process: FunctionAgentFn<any, any, FunctionAgent<any, any>>;
896
+ }, {
897
+ process: FunctionAgentFn<any, any, FunctionAgent<any, any>>;
898
+ }>;
899
+ static load<I extends Message = any, O extends Message = any>(options: {
900
+ filepath: string;
901
+ parsed: object;
902
+ }): Promise<Agent<I, O>>;
873
903
  /**
874
904
  * Create a function agent from a function or options
875
905
  *
@@ -188,6 +188,13 @@ export declare const aiAgentOptionsSchema: ZodObject<{
188
188
  */
189
189
  export declare class AIAgent<I extends Message = any, O extends Message = any> extends Agent<I, O> {
190
190
  tag: string;
191
+ static schema<T>({ filepath }: {
192
+ filepath: string;
193
+ }): ZodType<T>;
194
+ static load<I extends Message = any, O extends Message = any>(options: {
195
+ filepath: string;
196
+ parsed: object;
197
+ }): Promise<Agent<I, O>>;
191
198
  /**
192
199
  * Create an AIAgent with the specified options
193
200
  *
@@ -1,4 +1,4 @@
1
- import { type ZodObject, type ZodType } from "zod";
1
+ import z, { 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";
@@ -13,6 +13,22 @@ export declare const imageAgentOptionsSchema: ZodObject<{
13
13
  }>;
14
14
  export declare class ImageAgent<I extends Message = any, O extends ImageModelOutput = any> extends Agent<I, O> {
15
15
  tag: string;
16
+ static schema({ filepath }: {
17
+ filepath: string;
18
+ }): z.ZodObject<{
19
+ instructions: z.ZodType<import("../loader/schema.js").Instructions, z.ZodTypeDef, import("../loader/schema.js").Instructions>;
20
+ inputFileKey: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
21
+ }, "strip", z.ZodTypeAny, {
22
+ instructions: import("../loader/schema.js").Instructions;
23
+ inputFileKey?: string | undefined;
24
+ }, {
25
+ instructions: import("../loader/schema.js").Instructions;
26
+ inputFileKey?: string | undefined;
27
+ }>;
28
+ static load<I extends Message = any, O extends Message = any>(options: {
29
+ filepath: string;
30
+ parsed: object;
31
+ }): Promise<Agent<I, O>>;
16
32
  static from<I extends Message = any, O extends ImageModelOutput = any>(options: ImageAgentOptions<I, O>): ImageAgent<I, O>;
17
33
  constructor(options: ImageAgentOptions<I, O>);
18
34
  instructions: PromptBuilder;
@@ -91,6 +91,7 @@ export declare const imageModelInputSchema: z.ZodObject<{
91
91
  }, "strip", z.ZodTypeAny, {
92
92
  prompt: string;
93
93
  modelOptions?: Record<string, unknown> | undefined;
94
+ outputFileType?: "local" | "url" | "file" | undefined;
94
95
  image?: ({
95
96
  type: "url";
96
97
  url: string;
@@ -107,11 +108,11 @@ export declare const imageModelInputSchema: z.ZodObject<{
107
108
  filename?: string | undefined;
108
109
  mimeType?: string | undefined;
109
110
  })[] | undefined;
110
- outputFileType?: "local" | "file" | "url" | undefined;
111
111
  n?: number | undefined;
112
112
  }, {
113
113
  prompt: string;
114
114
  modelOptions?: Record<string, unknown> | undefined;
115
+ outputFileType?: "local" | "url" | "file" | undefined;
115
116
  image?: ({
116
117
  type: "url";
117
118
  url: string;
@@ -128,7 +129,6 @@ export declare const imageModelInputSchema: z.ZodObject<{
128
129
  filename?: string | undefined;
129
130
  mimeType?: string | undefined;
130
131
  })[] | undefined;
131
- outputFileType?: "local" | "file" | "url" | undefined;
132
132
  n?: number | undefined;
133
133
  }>;
134
134
  export interface ImageModelOutput extends Message {
@@ -232,7 +232,6 @@ export declare const imageModelOutputSchema: z.ZodObject<{
232
232
  filename?: string | undefined;
233
233
  mimeType?: string | undefined;
234
234
  })[];
235
- model?: string | undefined;
236
235
  usage?: {
237
236
  inputTokens: number;
238
237
  outputTokens: number;
@@ -241,6 +240,7 @@ export declare const imageModelOutputSchema: z.ZodObject<{
241
240
  cacheReadInputTokens?: number | undefined;
242
241
  creditPrefix?: "$" | "€" | "¥" | undefined;
243
242
  } | undefined;
243
+ model?: string | undefined;
244
244
  }, {
245
245
  images: ({
246
246
  type: "url";
@@ -258,7 +258,6 @@ export declare const imageModelOutputSchema: z.ZodObject<{
258
258
  filename?: string | undefined;
259
259
  mimeType?: string | undefined;
260
260
  })[];
261
- model?: string | undefined;
262
261
  usage?: {
263
262
  inputTokens: number;
264
263
  outputTokens: number;
@@ -267,4 +266,5 @@ export declare const imageModelOutputSchema: z.ZodObject<{
267
266
  cacheReadInputTokens?: number | undefined;
268
267
  creditPrefix?: "$" | "€" | "¥" | undefined;
269
268
  } | undefined;
269
+ model?: string | undefined;
270
270
  }>;
@@ -58,6 +58,23 @@ export type SSEServerParameters = {
58
58
  */
59
59
  export declare class MCPAgent extends Agent {
60
60
  tag: string;
61
+ static schema(): z.ZodObject<{
62
+ url: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
63
+ command: ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
64
+ args: ZodType<string[] | undefined, z.ZodTypeDef, string[] | undefined>;
65
+ }, "strip", z.ZodTypeAny, {
66
+ url?: string | undefined;
67
+ args?: string[] | undefined;
68
+ command?: string | undefined;
69
+ }, {
70
+ url?: string | undefined;
71
+ args?: string[] | undefined;
72
+ command?: string | undefined;
73
+ }>;
74
+ static load<I extends Message = any, O extends Message = any>(options: {
75
+ filepath: string;
76
+ parsed: object;
77
+ }): Promise<Agent<I, O>>;
61
78
  /**
62
79
  * Create an MCPAgent from a connection to an SSE server.
63
80
  *
@@ -1,3 +1,5 @@
1
+ import { z } from "zod";
2
+ import type { AgentLoadOptions } from "../loader/index.js";
1
3
  import { type PromiseOrValue } from "../utils/type-utils.js";
2
4
  import { Agent, type AgentInvokeOptions, type AgentOptions, type AgentProcessResult, type Message } from "./agent.js";
3
5
  /**
@@ -200,6 +202,59 @@ export interface TeamAgentOptions<I extends Message, O extends Message> extends
200
202
  */
201
203
  export declare class TeamAgent<I extends Message, O extends Message> extends Agent<I, O> {
202
204
  tag: string;
205
+ static schema({ filepath }: {
206
+ filepath: string;
207
+ }): z.ZodObject<{
208
+ mode: z.ZodType<ProcessMode | undefined, z.ZodTypeDef, ProcessMode | undefined>;
209
+ iterateOn: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
210
+ concurrency: z.ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
211
+ iterateWithPreviousOutput: z.ZodType<boolean | undefined, z.ZodTypeDef, boolean | undefined>;
212
+ includeAllStepsOutput: z.ZodType<boolean | undefined, z.ZodTypeDef, boolean | undefined>;
213
+ reflection: z.ZodType<{
214
+ reviewer: import("../loader/agent-yaml.js").NestAgentSchema;
215
+ isApproved: string;
216
+ maxIterations?: number | undefined;
217
+ returnLastOnMaxIterations?: boolean | undefined;
218
+ customErrorMessage?: string | undefined;
219
+ } | undefined, z.ZodTypeDef, {
220
+ reviewer: import("../loader/agent-yaml.js").NestAgentSchema;
221
+ isApproved: string;
222
+ maxIterations?: number | undefined;
223
+ returnLastOnMaxIterations?: boolean | undefined;
224
+ customErrorMessage?: string | undefined;
225
+ } | undefined>;
226
+ }, "strip", z.ZodTypeAny, {
227
+ mode?: ProcessMode | undefined;
228
+ reflection?: {
229
+ reviewer: import("../loader/agent-yaml.js").NestAgentSchema;
230
+ isApproved: string;
231
+ maxIterations?: number | undefined;
232
+ returnLastOnMaxIterations?: boolean | undefined;
233
+ customErrorMessage?: string | undefined;
234
+ } | undefined;
235
+ iterateOn?: string | undefined;
236
+ concurrency?: number | undefined;
237
+ iterateWithPreviousOutput?: boolean | undefined;
238
+ includeAllStepsOutput?: boolean | undefined;
239
+ }, {
240
+ mode?: ProcessMode | undefined;
241
+ reflection?: {
242
+ reviewer: import("../loader/agent-yaml.js").NestAgentSchema;
243
+ isApproved: string;
244
+ maxIterations?: number | undefined;
245
+ returnLastOnMaxIterations?: boolean | undefined;
246
+ customErrorMessage?: string | undefined;
247
+ } | undefined;
248
+ iterateOn?: string | undefined;
249
+ concurrency?: number | undefined;
250
+ iterateWithPreviousOutput?: boolean | undefined;
251
+ includeAllStepsOutput?: boolean | undefined;
252
+ }>;
253
+ static load<I extends Message = any, O extends Message = any>(options: {
254
+ filepath: string;
255
+ parsed: object;
256
+ options: AgentLoadOptions;
257
+ }): Promise<Agent<I, O>>;
203
258
  /**
204
259
  * Create a TeamAgent from the provided options.
205
260
  *
@@ -1,3 +1,4 @@
1
+ import { z } from "zod";
1
2
  import { Agent, type AgentOptions, type Message } from "./agent.js";
2
3
  /**
3
4
  * Configuration options for TransformAgent
@@ -47,6 +48,17 @@ export interface TransformAgentOptions<I extends Message, O extends Message> ext
47
48
  */
48
49
  export declare class TransformAgent<I extends Message = Message, O extends Message = Message> extends Agent<I, O> {
49
50
  static type: string;
51
+ static schema(): z.ZodObject<{
52
+ jsonata: z.ZodString;
53
+ }, "strip", z.ZodTypeAny, {
54
+ jsonata: string;
55
+ }, {
56
+ jsonata: string;
57
+ }>;
58
+ static load<I extends Message = any, O extends Message = any>(options: {
59
+ filepath: string;
60
+ parsed: object;
61
+ }): Promise<Agent<I, O>>;
50
62
  /**
51
63
  * Factory method to create a new TransformAgent instance
52
64
  *