@aigne/core 1.72.0-beta.3 → 1.72.0-beta.4

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 (93) hide show
  1. package/CHANGELOG.md +20 -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.js +30 -7
  31. package/lib/cjs/prompt/skills/afs/exec.js +17 -6
  32. package/lib/cjs/prompt/skills/afs/index.js +4 -1
  33. package/lib/cjs/prompt/skills/afs/list.js +26 -10
  34. package/lib/cjs/prompt/skills/afs/read.js +14 -3
  35. package/lib/cjs/prompt/skills/afs/rename.js +18 -4
  36. package/lib/cjs/prompt/skills/afs/search.js +21 -5
  37. package/lib/cjs/prompt/skills/afs/write.js +18 -4
  38. package/lib/cjs/prompt/template.d.ts +23 -23
  39. package/lib/dts/agents/agent.d.ts +31 -1
  40. package/lib/dts/agents/ai-agent.d.ts +7 -0
  41. package/lib/dts/agents/image-agent.d.ts +17 -1
  42. package/lib/dts/agents/image-model.d.ts +4 -4
  43. package/lib/dts/agents/mcp-agent.d.ts +17 -0
  44. package/lib/dts/agents/team-agent.d.ts +55 -0
  45. package/lib/dts/agents/transform-agent.d.ts +12 -0
  46. package/lib/dts/agents/video-model.d.ts +4 -4
  47. package/lib/dts/aigne/context.d.ts +2 -2
  48. package/lib/dts/loader/agent-yaml.d.ts +5 -67
  49. package/lib/dts/loader/agents.d.ts +4 -0
  50. package/lib/dts/loader/index.d.ts +18 -14
  51. package/lib/dts/loader/schema.d.ts +21 -6
  52. package/lib/dts/prompt/skills/afs/agent-skill/agent-skill.d.ts +17 -0
  53. package/lib/dts/prompt/skills/afs/agent-skill/skill-loader.d.ts +13 -0
  54. package/lib/dts/prompt/template.d.ts +25 -25
  55. package/lib/esm/agents/agent.d.ts +31 -1
  56. package/lib/esm/agents/agent.js +13 -0
  57. package/lib/esm/agents/ai-agent.d.ts +7 -0
  58. package/lib/esm/agents/ai-agent.js +85 -3
  59. package/lib/esm/agents/image-agent.d.ts +17 -1
  60. package/lib/esm/agents/image-agent.js +16 -0
  61. package/lib/esm/agents/image-model.d.ts +4 -4
  62. package/lib/esm/agents/mcp-agent.d.ts +17 -0
  63. package/lib/esm/agents/mcp-agent.js +18 -0
  64. package/lib/esm/agents/team-agent.d.ts +55 -0
  65. package/lib/esm/agents/team-agent.js +31 -0
  66. package/lib/esm/agents/transform-agent.d.ts +12 -0
  67. package/lib/esm/agents/transform-agent.js +13 -0
  68. package/lib/esm/agents/video-model.d.ts +4 -4
  69. package/lib/esm/aigne/context.d.ts +2 -2
  70. package/lib/esm/loader/agent-yaml.d.ts +5 -67
  71. package/lib/esm/loader/agent-yaml.js +4 -138
  72. package/lib/esm/loader/agents.d.ts +4 -0
  73. package/lib/esm/loader/agents.js +14 -0
  74. package/lib/esm/loader/index.d.ts +18 -14
  75. package/lib/esm/loader/index.js +21 -81
  76. package/lib/esm/loader/schema.d.ts +21 -6
  77. package/lib/esm/loader/schema.js +57 -0
  78. package/lib/esm/prompt/prompt-builder.js +1 -2
  79. package/lib/esm/prompt/skills/afs/agent-skill/agent-skill.d.ts +17 -0
  80. package/lib/esm/prompt/skills/afs/agent-skill/agent-skill.js +59 -0
  81. package/lib/esm/prompt/skills/afs/agent-skill/skill-loader.d.ts +13 -0
  82. package/lib/esm/prompt/skills/afs/agent-skill/skill-loader.js +53 -0
  83. package/lib/esm/prompt/skills/afs/delete.js +15 -3
  84. package/lib/esm/prompt/skills/afs/edit.js +30 -7
  85. package/lib/esm/prompt/skills/afs/exec.js +17 -6
  86. package/lib/esm/prompt/skills/afs/index.js +4 -1
  87. package/lib/esm/prompt/skills/afs/list.js +26 -10
  88. package/lib/esm/prompt/skills/afs/read.js +14 -3
  89. package/lib/esm/prompt/skills/afs/rename.js +18 -4
  90. package/lib/esm/prompt/skills/afs/search.js +21 -5
  91. package/lib/esm/prompt/skills/afs/write.js +18 -4
  92. package/lib/esm/prompt/template.d.ts +25 -25
  93. package/package.json +5 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.72.0-beta.4](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.72.0-beta.3...core-v1.72.0-beta.4) (2025-12-24)
4
+
5
+
6
+ ### Features
7
+
8
+ * add Agent Skill support ([#787](https://github.com/AIGNE-io/aigne-framework/issues/787)) ([f04fbe7](https://github.com/AIGNE-io/aigne-framework/commit/f04fbe76ec24cf3c59c74adf92d87b0c3784a8f7))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **cli:** improve terminal outputs ([#847](https://github.com/AIGNE-io/aigne-framework/issues/847)) ([329e91b](https://github.com/AIGNE-io/aigne-framework/commit/329e91bc3323f72fc8a2d278ff5e6bba9adbd6e0))
14
+
15
+
16
+ ### Dependencies
17
+
18
+ * The following workspace dependencies were updated
19
+ * dependencies
20
+ * @aigne/afs bumped to 1.4.0-beta.3
21
+ * @aigne/afs-history bumped to 1.2.0-beta.3
22
+
3
23
  ## [1.72.0-beta.3](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.72.0-beta.2...core-v1.72.0-beta.3) (2025-12-19)
4
24
 
5
25
 
@@ -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
  *
@@ -53,6 +53,7 @@ const nunjucks_1 = __importDefault(require("nunjucks"));
53
53
  const ufo_1 = require("ufo");
54
54
  const zod_1 = require("zod");
55
55
  const zod_to_json_schema_1 = require("zod-to-json-schema");
56
+ const function_agent_js_1 = require("../loader/function-agent.js");
56
57
  const agent_utils_js_1 = require("../utils/agent-utils.js");
57
58
  const json_schema_js_1 = require("../utils/json-schema.js");
58
59
  const logger_js_1 = require("../utils/logger.js");
@@ -873,6 +874,18 @@ function checkAgentInputOutputSchema(schema) {
873
874
  */
874
875
  class FunctionAgent extends Agent {
875
876
  tag = "FunctionAgent";
877
+ static schema() {
878
+ return zod_1.z.object({
879
+ process: zod_1.z.preprocess((v) => (typeof v === "string" ? (0, function_agent_js_1.codeToFunctionAgentFn)(v) : v), zod_1.z.custom()),
880
+ });
881
+ }
882
+ static async load(options) {
883
+ const valid = await FunctionAgent.schema().parseAsync(options.parsed);
884
+ return new FunctionAgent({
885
+ ...options.parsed,
886
+ process: valid.process,
887
+ });
888
+ }
876
889
  /**
877
890
  * Create a function agent from a function or options
878
891
  *
@@ -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
  *
@@ -35,10 +35,12 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.AIAgent = exports.aiAgentOptionsSchema = exports.aiAgentToolChoiceSchema = exports.AIAgentToolChoice = exports.DEFAULT_OUTPUT_FILE_KEY = exports.DEFAULT_OUTPUT_KEY = void 0;
37
37
  const zod_1 = require("zod");
38
+ const schema_js_1 = require("../loader/schema.js");
38
39
  const prompt_builder_js_1 = require("../prompt/prompt-builder.js");
39
40
  const structured_stream_instructions_js_1 = require("../prompt/prompts/structured-stream-instructions.js");
40
41
  const template_js_1 = require("../prompt/template.js");
41
42
  const fastq = __importStar(require("../utils/queue.js"));
43
+ const stream_utils_js_1 = require("../utils/stream-utils.js");
42
44
  const structured_stream_extractor_js_1 = require("../utils/structured-stream-extractor.js");
43
45
  const type_utils_js_1 = require("../utils/type-utils.js");
44
46
  const agent_js_1 = require("./agent.js");
@@ -120,6 +122,32 @@ exports.aiAgentOptionsSchema = agent_js_1.agentOptionsSchema.extend({
120
122
  */
121
123
  class AIAgent extends agent_js_1.Agent {
122
124
  tag = "AIAgent";
125
+ static schema({ filepath }) {
126
+ const instructionsSchema = (0, schema_js_1.getInstructionsSchema)({ filepath });
127
+ return (0, schema_js_1.camelizeSchema)(zod_1.z.object({
128
+ instructions: (0, schema_js_1.optionalize)(instructionsSchema),
129
+ autoReorderSystemMessages: (0, schema_js_1.optionalize)(zod_1.z.boolean()),
130
+ autoMergeSystemMessages: (0, schema_js_1.optionalize)(zod_1.z.boolean()),
131
+ inputKey: (0, schema_js_1.optionalize)(zod_1.z.string()),
132
+ outputKey: (0, schema_js_1.optionalize)(zod_1.z.string()),
133
+ inputFileKey: (0, schema_js_1.optionalize)(zod_1.z.string()),
134
+ outputFileKey: (0, schema_js_1.optionalize)(zod_1.z.string()),
135
+ toolChoice: (0, schema_js_1.optionalize)(zod_1.z.nativeEnum(AIAgentToolChoice)),
136
+ toolCallsConcurrency: (0, schema_js_1.optionalize)(zod_1.z.number().int().min(0)),
137
+ keepTextInToolUses: (0, schema_js_1.optionalize)(zod_1.z.boolean()),
138
+ catchToolsError: (0, schema_js_1.optionalize)(zod_1.z.boolean()),
139
+ structuredStreamMode: (0, schema_js_1.optionalize)(zod_1.z.boolean()),
140
+ }));
141
+ }
142
+ static async load(options) {
143
+ const schema = AIAgent.schema(options);
144
+ const valid = await schema.parseAsync(options.parsed);
145
+ return new AIAgent({
146
+ ...options.parsed,
147
+ ...valid,
148
+ instructions: valid.instructions && (0, schema_js_1.instructionsToPromptBuilder)(valid.instructions),
149
+ });
150
+ }
123
151
  /**
124
152
  * Create an AIAgent with the specified options
125
153
  *
@@ -316,6 +344,16 @@ class AIAgent extends agent_js_1.Agent {
316
344
  }
317
345
  const toolCallMessages = [];
318
346
  const outputKey = this.outputKey;
347
+ const inputMessage = this.inputKey ? input[this.inputKey] : undefined;
348
+ if (inputMessage) {
349
+ yield {
350
+ progress: {
351
+ event: "message",
352
+ role: "user",
353
+ message: [{ type: "text", content: inputMessage }],
354
+ },
355
+ };
356
+ }
319
357
  for (;;) {
320
358
  const modelOutput = {};
321
359
  let stream = await this.invokeChildAgent(model, { ...modelInput, messages: modelInput.messages.concat(toolCallMessages) }, { ...options, streaming: true });
@@ -325,12 +363,12 @@ class AIAgent extends agent_js_1.Agent {
325
363
  }
326
364
  let isTextIgnored = false;
327
365
  for await (const value of stream) {
366
+ (0, stream_utils_js_1.mergeAgentResponseChunk)(modelOutput, value);
328
367
  if ((0, agent_js_1.isAgentResponseDelta)(value)) {
329
368
  if (!isTextIgnored && value.delta.text?.text) {
330
369
  yield { delta: { text: { [outputKey]: value.delta.text.text } } };
331
370
  }
332
371
  if (value.delta.json) {
333
- Object.assign(modelOutput, value.delta.json);
334
372
  if (this.structuredStreamMode) {
335
373
  yield { delta: { json: value.delta.json.json } };
336
374
  if (!isTextIgnored && modelOutput.json && this.ignoreTextOfStructuredStreamMode) {
@@ -340,13 +378,23 @@ class AIAgent extends agent_js_1.Agent {
340
378
  }
341
379
  }
342
380
  }
343
- const { toolCalls, json, text, files } = modelOutput;
381
+ const { toolCalls, json, text, thoughts, files } = modelOutput;
382
+ if (text) {
383
+ yield {
384
+ progress: { event: "message", role: "agent", message: [{ type: "text", content: text }] },
385
+ };
386
+ }
387
+ if (thoughts) {
388
+ yield {
389
+ progress: { event: "message", role: "agent", message: [{ type: "thinking", thoughts }] },
390
+ };
391
+ }
344
392
  if (toolCalls?.length) {
345
393
  if (this.keepTextInToolUses !== true) {
346
394
  yield { delta: { json: { [outputKey]: "" } } };
347
395
  }
348
396
  else {
349
- yield { delta: { text: { [outputKey]: "\n" } } };
397
+ yield { delta: { text: { [outputKey]: "\n\n" } } };
350
398
  }
351
399
  const executedToolCalls = [];
352
400
  let error;
@@ -376,6 +424,20 @@ class AIAgent extends agent_js_1.Agent {
376
424
  const tool = toolsMap.get(call.function.name);
377
425
  if (!tool)
378
426
  throw new Error(`Tool not found: ${call.function.name}`);
427
+ yield {
428
+ progress: {
429
+ event: "message",
430
+ role: "agent",
431
+ message: [
432
+ {
433
+ type: "tool_use",
434
+ name: call.function.name,
435
+ input: call.function.arguments,
436
+ toolUseId: call.id,
437
+ },
438
+ ],
439
+ },
440
+ };
379
441
  queue.push({ tool, call });
380
442
  }
381
443
  await queue.drained();
@@ -383,6 +445,21 @@ class AIAgent extends agent_js_1.Agent {
383
445
  throw error;
384
446
  // Continue LLM function calling loop if any tools were executed
385
447
  if (executedToolCalls.length) {
448
+ for (const { call, output } of executedToolCalls) {
449
+ yield {
450
+ progress: {
451
+ event: "message",
452
+ role: "agent",
453
+ message: [
454
+ {
455
+ type: "tool_result",
456
+ toolUseId: call.id,
457
+ content: output,
458
+ },
459
+ ],
460
+ },
461
+ };
462
+ }
386
463
  const transferOutput = executedToolCalls.find((i) => (0, types_js_1.isTransferAgentOutput)(i.output))?.output;
387
464
  if (transferOutput)
388
465
  return transferOutput;
@@ -403,6 +480,11 @@ class AIAgent extends agent_js_1.Agent {
403
480
  if (!(0, type_utils_js_1.isEmpty)(result)) {
404
481
  yield { delta: { json: result } };
405
482
  }
483
+ if (text) {
484
+ yield {
485
+ progress: { event: "message", role: "agent", message: [{ type: "text", content: text }] },
486
+ };
487
+ }
406
488
  return;
407
489
  }
408
490
  }
@@ -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;
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ImageAgent = exports.imageAgentOptionsSchema = void 0;
7
7
  const zod_1 = __importDefault(require("zod"));
8
+ const schema_js_1 = require("../loader/schema.js");
8
9
  const prompt_builder_js_1 = require("../prompt/prompt-builder.js");
9
10
  const type_utils_js_1 = require("../utils/type-utils.js");
10
11
  const agent_js_1 = require("./agent.js");
@@ -16,6 +17,21 @@ exports.imageAgentOptionsSchema = agent_js_1.agentOptionsSchema.extend({
16
17
  });
17
18
  class ImageAgent extends agent_js_1.Agent {
18
19
  tag = "ImageAgent";
20
+ static schema({ filepath }) {
21
+ const instructionsSchema = (0, schema_js_1.getInstructionsSchema)({ filepath });
22
+ return (0, schema_js_1.camelizeSchema)(zod_1.default.object({
23
+ instructions: instructionsSchema,
24
+ inputFileKey: (0, schema_js_1.optionalize)(zod_1.default.string()),
25
+ }));
26
+ }
27
+ static async load(options) {
28
+ const valid = await ImageAgent.schema({ filepath: options.filepath }).parseAsync(options.parsed);
29
+ return new ImageAgent({
30
+ ...options.parsed,
31
+ ...valid,
32
+ instructions: (0, schema_js_1.instructionsToPromptBuilder)(valid.instructions),
33
+ });
34
+ }
19
35
  static from(options) {
20
36
  return new ImageAgent(options);
21
37
  }
@@ -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
  *
@@ -41,6 +41,7 @@ const sse_js_1 = require("@modelcontextprotocol/sdk/client/sse.js");
41
41
  const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/client/streamableHttp.js");
42
42
  const uriTemplate_js_1 = require("@modelcontextprotocol/sdk/shared/uriTemplate.js");
43
43
  const zod_1 = require("zod");
44
+ const schema_js_1 = require("../loader/schema.js");
44
45
  const logger_js_1 = require("../utils/logger.js");
45
46
  const mcp_utils_js_1 = require("../utils/mcp-utils.js");
46
47
  const type_utils_js_1 = require("../utils/type-utils.js");
@@ -85,6 +86,23 @@ function getMCPServerString(options) {
85
86
  */
86
87
  class MCPAgent extends agent_js_1.Agent {
87
88
  tag = "MCPAgent";
89
+ static schema() {
90
+ return zod_1.z.object({
91
+ url: (0, schema_js_1.optionalize)(zod_1.z.string()),
92
+ command: (0, schema_js_1.optionalize)(zod_1.z.string()),
93
+ args: (0, schema_js_1.optionalize)(zod_1.z.array(zod_1.z.string())),
94
+ });
95
+ }
96
+ static async load(options) {
97
+ const valid = await MCPAgent.schema().parseAsync(options.parsed);
98
+ if (!valid.url && !valid.command) {
99
+ throw new Error(`Missing url or command in mcp agent: ${options.filepath}`);
100
+ }
101
+ return MCPAgent.from({
102
+ ...options.parsed,
103
+ ...valid,
104
+ });
105
+ }
88
106
  static from(options) {
89
107
  (0, type_utils_js_1.checkArguments)("MCPAgent.from", mcpAgentOptionsSchema, options);
90
108
  if (isSSEServerParameters(options)) {
@@ -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
  *
@@ -39,6 +39,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.TeamAgent = exports.DEFAULT_REFLECTION_MAX_ITERATIONS = exports.ProcessMode = void 0;
40
40
  const node_assert_1 = __importDefault(require("node:assert"));
41
41
  const immer_1 = require("immer");
42
+ const zod_1 = require("zod");
43
+ const agent_yaml_js_1 = require("../loader/agent-yaml.js");
44
+ const schema_js_1 = require("../loader/schema.js");
42
45
  const fastq = __importStar(require("../utils/queue.js"));
43
46
  const stream_utils_js_1 = require("../utils/stream-utils.js");
44
47
  const type_utils_js_1 = require("../utils/type-utils.js");
@@ -86,6 +89,34 @@ exports.DEFAULT_REFLECTION_MAX_ITERATIONS = 3;
86
89
  */
87
90
  class TeamAgent extends agent_js_1.Agent {
88
91
  tag = "TeamAgent";
92
+ static schema({ filepath }) {
93
+ const nestAgentSchema = (0, agent_yaml_js_1.getNestAgentSchema)({ filepath });
94
+ return zod_1.z.object({
95
+ mode: (0, schema_js_1.optionalize)(zod_1.z.nativeEnum(ProcessMode)),
96
+ iterateOn: (0, schema_js_1.optionalize)(zod_1.z.string()),
97
+ concurrency: (0, schema_js_1.optionalize)(zod_1.z.number().int().min(1)),
98
+ iterateWithPreviousOutput: (0, schema_js_1.optionalize)(zod_1.z.boolean()),
99
+ includeAllStepsOutput: (0, schema_js_1.optionalize)(zod_1.z.boolean()),
100
+ reflection: (0, schema_js_1.camelizeSchema)((0, schema_js_1.optionalize)(zod_1.z.object({
101
+ reviewer: nestAgentSchema,
102
+ isApproved: zod_1.z.string(),
103
+ maxIterations: (0, schema_js_1.optionalize)(zod_1.z.number().int().min(1)),
104
+ returnLastOnMaxIterations: (0, schema_js_1.optionalize)(zod_1.z.boolean()),
105
+ customErrorMessage: (0, schema_js_1.optionalize)(zod_1.z.string()),
106
+ }))),
107
+ });
108
+ }
109
+ static async load(options) {
110
+ const valid = await TeamAgent.schema({ filepath: options.filepath }).parseAsync(options.parsed);
111
+ return TeamAgent.from({
112
+ ...options.parsed,
113
+ ...valid,
114
+ reflection: valid.reflection && {
115
+ ...valid.reflection,
116
+ reviewer: await options.options.loadNestAgent(options.filepath, valid.reflection.reviewer, options.options),
117
+ },
118
+ });
119
+ }
89
120
  /**
90
121
  * Create a TeamAgent from the provided options.
91
122
  *
@@ -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
  *
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.TransformAgent = void 0;
7
7
  const jsonata_1 = __importDefault(require("jsonata"));
8
+ const zod_1 = require("zod");
8
9
  const agent_js_1 = require("./agent.js");
9
10
  /**
10
11
  * TransformAgent - A specialized agent for data transformation using JSONata expressions
@@ -23,6 +24,18 @@ const agent_js_1 = require("./agent.js");
23
24
  */
24
25
  class TransformAgent extends agent_js_1.Agent {
25
26
  static type = "TransformAgent";
27
+ static schema() {
28
+ return zod_1.z.object({
29
+ jsonata: zod_1.z.string(),
30
+ });
31
+ }
32
+ static async load(options) {
33
+ const parsed = await TransformAgent.schema().parseAsync(options.parsed);
34
+ return TransformAgent.from({
35
+ ...options.parsed,
36
+ ...parsed,
37
+ });
38
+ }
26
39
  /**
27
40
  * Factory method to create a new TransformAgent instance
28
41
  *
@@ -94,6 +94,7 @@ export declare const videoModelInputSchema: z.ZodObject<{
94
94
  prompt: string;
95
95
  model?: string | undefined;
96
96
  modelOptions?: Record<string, unknown> | undefined;
97
+ outputFileType?: "local" | "url" | "file" | undefined;
97
98
  image?: {
98
99
  type: "url";
99
100
  url: string;
@@ -110,13 +111,13 @@ export declare const videoModelInputSchema: z.ZodObject<{
110
111
  filename?: string | undefined;
111
112
  mimeType?: string | undefined;
112
113
  } | undefined;
113
- outputFileType?: "local" | "file" | "url" | undefined;
114
114
  size?: string | undefined;
115
115
  seconds?: string | undefined;
116
116
  }, {
117
117
  prompt: string;
118
118
  model?: string | undefined;
119
119
  modelOptions?: Record<string, unknown> | undefined;
120
+ outputFileType?: "local" | "url" | "file" | undefined;
120
121
  image?: {
121
122
  type: "url";
122
123
  url: string;
@@ -133,7 +134,6 @@ export declare const videoModelInputSchema: z.ZodObject<{
133
134
  filename?: string | undefined;
134
135
  mimeType?: string | undefined;
135
136
  } | undefined;
136
- outputFileType?: "local" | "file" | "url" | undefined;
137
137
  size?: string | undefined;
138
138
  seconds?: string | undefined;
139
139
  }>;
@@ -240,7 +240,6 @@ export declare const videoModelOutputSchema: z.ZodObject<{
240
240
  filename?: string | undefined;
241
241
  mimeType?: string | undefined;
242
242
  })[];
243
- model?: string | undefined;
244
243
  usage?: {
245
244
  inputTokens: number;
246
245
  outputTokens: number;
@@ -249,6 +248,7 @@ export declare const videoModelOutputSchema: z.ZodObject<{
249
248
  cacheReadInputTokens?: number | undefined;
250
249
  creditPrefix?: "$" | "€" | "¥" | undefined;
251
250
  } | undefined;
251
+ model?: string | undefined;
252
252
  seconds?: number | undefined;
253
253
  }, {
254
254
  videos: ({
@@ -267,7 +267,6 @@ export declare const videoModelOutputSchema: z.ZodObject<{
267
267
  filename?: string | undefined;
268
268
  mimeType?: string | undefined;
269
269
  })[];
270
- model?: string | undefined;
271
270
  usage?: {
272
271
  inputTokens: number;
273
272
  outputTokens: number;
@@ -276,5 +275,6 @@ export declare const videoModelOutputSchema: z.ZodObject<{
276
275
  cacheReadInputTokens?: number | undefined;
277
276
  creditPrefix?: "$" | "€" | "¥" | undefined;
278
277
  } | undefined;
278
+ model?: string | undefined;
279
279
  seconds?: number | undefined;
280
280
  }>;