@aigne/agent-library 1.24.0-beta.3 → 1.24.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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,21 @@
7
7
  * @aigne/core bumped to 1.22.0
8
8
  * @aigne/openai bumped to 0.3.4
9
9
 
10
+ ## [1.24.0-beta.4](https://github.com/AIGNE-io/aigne-framework/compare/agent-library-v1.24.0-beta.3...agent-library-v1.24.0-beta.4) (2025-12-24)
11
+
12
+
13
+ ### Features
14
+
15
+ * add Agent Skill support ([#787](https://github.com/AIGNE-io/aigne-framework/issues/787)) ([f04fbe7](https://github.com/AIGNE-io/aigne-framework/commit/f04fbe76ec24cf3c59c74adf92d87b0c3784a8f7))
16
+
17
+
18
+ ### Dependencies
19
+
20
+ * The following workspace dependencies were updated
21
+ * dependencies
22
+ * @aigne/core bumped to 1.72.0-beta.4
23
+ * @aigne/openai bumped to 0.16.16-beta.4
24
+
10
25
  ## [1.24.0-beta.3](https://github.com/AIGNE-io/aigne-framework/compare/agent-library-v1.24.0-beta.2...agent-library-v1.24.0-beta.3) (2025-12-19)
11
26
 
12
27
 
@@ -3,6 +3,7 @@ import { Agent, type AgentInvokeOptions, type AgentOptions, type AgentResponseSt
3
3
  import { type NestAgentSchema } from "@aigne/core/loader/agent-yaml.js";
4
4
  import { type LoadOptions } from "@aigne/core/loader/index.js";
5
5
  import { type SandboxRuntimeConfig } from "@anthropic-ai/sandbox-runtime";
6
+ import z from "zod";
6
7
  export interface BashAgentOptions extends AgentOptions<BashAgentInput, BashAgentOutput> {
7
8
  sandbox?: Partial<{
8
9
  [K in keyof SandboxRuntimeConfig]: Partial<SandboxRuntimeConfig[K]>;
@@ -59,6 +60,53 @@ export interface BashAgentOutput extends Message {
59
60
  }
60
61
  export declare class BashAgent extends Agent<BashAgentInput, BashAgentOutput> {
61
62
  options: BashAgentOptions;
63
+ tag: string;
64
+ static schema({ filepath }: {
65
+ filepath: string;
66
+ }): z.ZodObject<{
67
+ sandbox: z.ZodType<boolean | {
68
+ [x: string]: z.ZodTypeAny | undefined;
69
+ } | undefined, z.ZodTypeDef, boolean | {
70
+ [x: string]: z.ZodTypeAny | undefined;
71
+ } | undefined>;
72
+ inputKey: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
73
+ timeout: z.ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
74
+ permissions: z.ZodType<{
75
+ allow?: string[] | undefined;
76
+ deny?: string[] | undefined;
77
+ guard?: NestAgentSchema | undefined;
78
+ defaultMode?: "allow" | "ask" | "deny" | undefined;
79
+ } | undefined, z.ZodTypeDef, {
80
+ allow?: string[] | undefined;
81
+ deny?: string[] | undefined;
82
+ guard?: NestAgentSchema | undefined;
83
+ defaultMode?: "allow" | "ask" | "deny" | undefined;
84
+ } | undefined>;
85
+ }, "strip", z.ZodTypeAny, {
86
+ sandbox?: boolean | {
87
+ [x: string]: z.ZodTypeAny | undefined;
88
+ } | undefined;
89
+ inputKey?: string | undefined;
90
+ timeout?: number | undefined;
91
+ permissions?: {
92
+ allow?: string[] | undefined;
93
+ deny?: string[] | undefined;
94
+ guard?: NestAgentSchema | undefined;
95
+ defaultMode?: "allow" | "ask" | "deny" | undefined;
96
+ } | undefined;
97
+ }, {
98
+ sandbox?: boolean | {
99
+ [x: string]: z.ZodTypeAny | undefined;
100
+ } | undefined;
101
+ inputKey?: string | undefined;
102
+ timeout?: number | undefined;
103
+ permissions?: {
104
+ allow?: string[] | undefined;
105
+ deny?: string[] | undefined;
106
+ guard?: NestAgentSchema | undefined;
107
+ defaultMode?: "allow" | "ask" | "deny" | undefined;
108
+ } | undefined;
109
+ }>;
62
110
  static load(options: {
63
111
  filepath: string;
64
112
  parsed: LoadBashAgentOptions;
@@ -48,15 +48,30 @@ let sandboxInitialization;
48
48
  const mutex = new mutex_js_1.Mutex();
49
49
  class BashAgent extends core_1.Agent {
50
50
  options;
51
+ tag = "Bash";
52
+ static schema({ filepath }) {
53
+ const nestAgentSchema = (0, agent_yaml_js_1.getNestAgentSchema)({ filepath });
54
+ return (0, schema_js_1.camelizeSchema)(zod_1.default.object({
55
+ sandbox: (0, schema_js_1.optionalize)(zod_1.default.union([makeShapePropertiesOptions(sandbox_runtime_1.SandboxRuntimeConfigSchema, 2), zod_1.default.boolean()])),
56
+ inputKey: (0, schema_js_1.optionalize)(zod_1.default.string().describe("The input key for the bash script.")),
57
+ timeout: (0, schema_js_1.optionalize)(zod_1.default.number().describe("Timeout for script execution in milliseconds.")),
58
+ permissions: (0, schema_js_1.optionalize)((0, schema_js_1.camelizeSchema)(zod_1.default.object({
59
+ allow: (0, schema_js_1.optionalize)(zod_1.default.array(zod_1.default.string())),
60
+ deny: (0, schema_js_1.optionalize)(zod_1.default.array(zod_1.default.string())),
61
+ defaultMode: (0, schema_js_1.optionalize)(zod_1.default.enum(["allow", "ask", "deny"])),
62
+ guard: (0, schema_js_1.optionalize)(nestAgentSchema),
63
+ }))),
64
+ }));
65
+ }
51
66
  static async load(options) {
52
- const schema = getBashAgentSchema({ filepath: options.filepath });
53
- const parsed = await schema.parseAsync(options.parsed);
67
+ const valid = await BashAgent.schema(options).parseAsync(options.parsed);
54
68
  return new BashAgent({
55
- ...parsed,
69
+ ...options.parsed,
70
+ ...valid,
56
71
  permissions: {
57
- ...parsed.permissions,
58
- guard: parsed.permissions?.guard
59
- ? await (0, index_js_1.loadNestAgent)(options.filepath, parsed.permissions.guard, options.options ?? {}, {
72
+ ...valid.permissions,
73
+ guard: valid.permissions?.guard
74
+ ? await (0, index_js_1.loadNestAgent)(options.filepath, valid.permissions.guard, options.options ?? {}, {
60
75
  outputSchema: zod_1.default.object({
61
76
  approved: zod_1.default.boolean().describe("Whether the command is approved by the user."),
62
77
  reason: zod_1.default.string().describe("Optional reason for rejection.").optional(),
@@ -334,20 +349,6 @@ When to use:
334
349
  }
335
350
  exports.BashAgent = BashAgent;
336
351
  exports.default = BashAgent;
337
- function getBashAgentSchema({ filepath }) {
338
- const nestAgentSchema = (0, agent_yaml_js_1.getNestAgentSchema)({ filepath });
339
- return (0, schema_js_1.camelizeSchema)(zod_1.default.object({
340
- sandbox: (0, schema_js_1.optionalize)(zod_1.default.union([makeShapePropertiesOptions(sandbox_runtime_1.SandboxRuntimeConfigSchema, 2), zod_1.default.boolean()])),
341
- inputKey: (0, schema_js_1.optionalize)(zod_1.default.string().describe("The input key for the bash script.")),
342
- timeout: (0, schema_js_1.optionalize)(zod_1.default.number().describe("Timeout for script execution in milliseconds.")),
343
- permissions: (0, schema_js_1.optionalize)((0, schema_js_1.camelizeSchema)(zod_1.default.object({
344
- allow: (0, schema_js_1.optionalize)(zod_1.default.array(zod_1.default.string())),
345
- deny: (0, schema_js_1.optionalize)(zod_1.default.array(zod_1.default.string())),
346
- defaultMode: (0, schema_js_1.optionalize)(zod_1.default.enum(["allow", "ask", "deny"])),
347
- guard: (0, schema_js_1.optionalize)(nestAgentSchema),
348
- }))),
349
- }));
350
- }
351
352
  function makeShapePropertiesOptions(schema, depth = 1) {
352
353
  return zod_1.default.object(Object.fromEntries(Object.entries(schema.shape).map(([key, value]) => {
353
354
  const isObject = value instanceof zod_1.ZodObject;
@@ -1,6 +1,8 @@
1
1
  import { type AgentInvokeOptions, type AgentOptions, AIAgent, type AIAgentOptions, type Message, type PromptBuilder } from "@aigne/core";
2
- import { type Instructions, type NestAgentSchema } from "@aigne/core/loader/agent-yaml.js";
3
- import { type LoadOptions } from "@aigne/core/loader/index.js";
2
+ import { type NestAgentSchema } from "@aigne/core/loader/agent-yaml.js";
3
+ import type { AgentLoadOptions } from "@aigne/core/loader/index.js";
4
+ import { type Instructions } from "@aigne/core/loader/schema.js";
5
+ import { type ZodType } from "zod";
4
6
  import { type StateManagementOptions } from "./type.js";
5
7
  /**
6
8
  * Configuration options for the Orchestrator Agent
@@ -17,17 +19,11 @@ export interface OrchestratorAgentOptions<I extends Message = Message, O extends
17
19
  stateManagement?: StateManagementOptions;
18
20
  concurrency?: number;
19
21
  }
20
- export interface LoadOrchestratorAgentOptions<I extends Message = Message, O extends Message = Message> extends Omit<AIAgentOptions<I, O>, "instructions"> {
21
- objective?: string | PromptBuilder | Instructions;
22
- planner?: NestAgentSchema | {
23
- instructions?: string | PromptBuilder | Instructions;
24
- };
25
- worker?: NestAgentSchema | {
26
- instructions?: string | PromptBuilder | Instructions;
27
- };
28
- completer?: NestAgentSchema | {
29
- instructions?: string | PromptBuilder | Instructions;
30
- };
22
+ export interface LoadOrchestratorAgentOptions {
23
+ objective?: string | Instructions;
24
+ planner?: NestAgentSchema;
25
+ worker?: NestAgentSchema;
26
+ completer?: NestAgentSchema;
31
27
  stateManagement?: StateManagementOptions;
32
28
  }
33
29
  /**
@@ -47,10 +43,13 @@ export interface LoadOrchestratorAgentOptions<I extends Message = Message, O ext
47
43
  */
48
44
  export declare class OrchestratorAgent<I extends Message = Message, O extends Message = Message> extends AIAgent<I, O> {
49
45
  tag: string;
46
+ static schema<T>({ filepath }: {
47
+ filepath: string;
48
+ }): ZodType<T>;
50
49
  static load<I extends Message = Message, O extends Message = Message>({ filepath, parsed, options, }: {
51
50
  filepath: string;
52
- parsed: AgentOptions<I, O> & LoadOrchestratorAgentOptions<I, O>;
53
- options?: LoadOptions;
51
+ parsed: LoadOrchestratorAgentOptions & AgentOptions<I, O>;
52
+ options?: AgentLoadOptions;
54
53
  }): Promise<OrchestratorAgent<I, O>>;
55
54
  /**
56
55
  * Factory method to create an OrchestratorAgent instance
@@ -36,7 +36,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.OrchestratorAgent = void 0;
37
37
  const core_1 = require("@aigne/core");
38
38
  const agent_yaml_js_1 = require("@aigne/core/loader/agent-yaml.js");
39
- const index_js_1 = require("@aigne/core/loader/index.js");
40
39
  const schema_js_1 = require("@aigne/core/loader/schema.js");
41
40
  const agent_utils_js_1 = require("@aigne/core/utils/agent-utils.js");
42
41
  const fastq = __importStar(require("@aigne/core/utils/queue.js"));
@@ -90,28 +89,41 @@ const DEFAULT_CONCURRENCY = 5;
90
89
  */
91
90
  class OrchestratorAgent extends core_1.AIAgent {
92
91
  tag = "OrchestratorAgent";
93
- static async load({ filepath, parsed, options = {}, }) {
94
- const schema = getOrchestratorAgentSchema({ filepath });
95
- const valid = await schema.parseAsync(parsed);
92
+ static schema({ filepath }) {
93
+ const nestAgentSchema = (0, agent_yaml_js_1.getNestAgentSchema)({ filepath });
94
+ const instructionsSchema = (0, schema_js_1.getInstructionsSchema)({ filepath });
95
+ return (0, schema_js_1.camelizeSchema)(zod_1.z.object({
96
+ objective: (0, schema_js_1.optionalize)(instructionsSchema),
97
+ planner: (0, schema_js_1.optionalize)(nestAgentSchema),
98
+ worker: (0, schema_js_1.optionalize)(nestAgentSchema),
99
+ completer: (0, schema_js_1.optionalize)(nestAgentSchema),
100
+ stateManagement: (0, schema_js_1.optionalize)((0, schema_js_1.camelizeSchema)(type_js_1.stateManagementOptionsSchema)),
101
+ concurrency: (0, schema_js_1.optionalize)(zod_1.z.number().int().min(1).default(DEFAULT_CONCURRENCY)),
102
+ }));
103
+ }
104
+ static async load({ filepath, parsed, options, }) {
105
+ const valid = await OrchestratorAgent.schema({
106
+ filepath,
107
+ }).parseAsync(parsed);
96
108
  return new OrchestratorAgent({
97
109
  ...parsed,
98
- objective: valid.objective && (0, index_js_1.instructionsToPromptBuilder)(valid.objective),
110
+ objective: valid.objective ? (0, schema_js_1.instructionsToPromptBuilder)(valid.objective) : undefined,
99
111
  planner: valid.planner
100
- ? (await (0, index_js_1.loadNestAgent)(filepath, valid.planner, options, {
112
+ ? (await options?.loadNestAgent(filepath, valid.planner, options, {
101
113
  ...defaultPlannerOptions,
102
114
  afs: parsed.afs,
103
115
  skills: parsed.skills,
104
116
  }))
105
117
  : undefined,
106
118
  worker: valid.worker
107
- ? (await (0, index_js_1.loadNestAgent)(filepath, valid.worker, options, {
119
+ ? (await options?.loadNestAgent(filepath, valid.worker, options, {
108
120
  ...defaultWorkerOptions,
109
121
  afs: parsed.afs,
110
122
  skills: parsed.skills,
111
123
  }))
112
124
  : undefined,
113
125
  completer: valid.completer
114
- ? (await (0, index_js_1.loadNestAgent)(filepath, valid.completer, options, {
126
+ ? (await options?.loadNestAgent(filepath, valid.completer, options, {
115
127
  ...defaultCompleterOptions,
116
128
  outputSchema: parsed.outputSchema,
117
129
  afs: parsed.afs,
@@ -272,15 +284,3 @@ class OrchestratorAgent extends core_1.AIAgent {
272
284
  }
273
285
  exports.OrchestratorAgent = OrchestratorAgent;
274
286
  exports.default = OrchestratorAgent;
275
- function getOrchestratorAgentSchema({ filepath }) {
276
- const nestAgentSchema = (0, agent_yaml_js_1.getNestAgentSchema)({ filepath });
277
- const instructionsSchema = (0, agent_yaml_js_1.getInstructionsSchema)({ filepath });
278
- return (0, schema_js_1.camelizeSchema)(zod_1.z.object({
279
- objective: (0, schema_js_1.optionalize)(instructionsSchema),
280
- planner: (0, schema_js_1.optionalize)(nestAgentSchema),
281
- worker: (0, schema_js_1.optionalize)(nestAgentSchema),
282
- completer: (0, schema_js_1.optionalize)(nestAgentSchema),
283
- stateManagement: (0, schema_js_1.optionalize)((0, schema_js_1.camelizeSchema)(type_js_1.stateManagementOptionsSchema)),
284
- concurrency: (0, schema_js_1.optionalize)(zod_1.z.number().int().min(1).default(DEFAULT_CONCURRENCY)),
285
- }));
286
- }
@@ -3,6 +3,7 @@ import { Agent, type AgentInvokeOptions, type AgentOptions, type AgentResponseSt
3
3
  import { type NestAgentSchema } from "@aigne/core/loader/agent-yaml.js";
4
4
  import { type LoadOptions } from "@aigne/core/loader/index.js";
5
5
  import { type SandboxRuntimeConfig } from "@anthropic-ai/sandbox-runtime";
6
+ import z from "zod";
6
7
  export interface BashAgentOptions extends AgentOptions<BashAgentInput, BashAgentOutput> {
7
8
  sandbox?: Partial<{
8
9
  [K in keyof SandboxRuntimeConfig]: Partial<SandboxRuntimeConfig[K]>;
@@ -59,6 +60,53 @@ export interface BashAgentOutput extends Message {
59
60
  }
60
61
  export declare class BashAgent extends Agent<BashAgentInput, BashAgentOutput> {
61
62
  options: BashAgentOptions;
63
+ tag: string;
64
+ static schema({ filepath }: {
65
+ filepath: string;
66
+ }): z.ZodObject<{
67
+ sandbox: z.ZodType<boolean | {
68
+ [x: string]: z.ZodTypeAny | undefined;
69
+ } | undefined, z.ZodTypeDef, boolean | {
70
+ [x: string]: z.ZodTypeAny | undefined;
71
+ } | undefined>;
72
+ inputKey: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
73
+ timeout: z.ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
74
+ permissions: z.ZodType<{
75
+ allow?: string[] | undefined;
76
+ deny?: string[] | undefined;
77
+ guard?: NestAgentSchema | undefined;
78
+ defaultMode?: "allow" | "ask" | "deny" | undefined;
79
+ } | undefined, z.ZodTypeDef, {
80
+ allow?: string[] | undefined;
81
+ deny?: string[] | undefined;
82
+ guard?: NestAgentSchema | undefined;
83
+ defaultMode?: "allow" | "ask" | "deny" | undefined;
84
+ } | undefined>;
85
+ }, "strip", z.ZodTypeAny, {
86
+ sandbox?: boolean | {
87
+ [x: string]: z.ZodTypeAny | undefined;
88
+ } | undefined;
89
+ inputKey?: string | undefined;
90
+ timeout?: number | undefined;
91
+ permissions?: {
92
+ allow?: string[] | undefined;
93
+ deny?: string[] | undefined;
94
+ guard?: NestAgentSchema | undefined;
95
+ defaultMode?: "allow" | "ask" | "deny" | undefined;
96
+ } | undefined;
97
+ }, {
98
+ sandbox?: boolean | {
99
+ [x: string]: z.ZodTypeAny | undefined;
100
+ } | undefined;
101
+ inputKey?: string | undefined;
102
+ timeout?: number | undefined;
103
+ permissions?: {
104
+ allow?: string[] | undefined;
105
+ deny?: string[] | undefined;
106
+ guard?: NestAgentSchema | undefined;
107
+ defaultMode?: "allow" | "ask" | "deny" | undefined;
108
+ } | undefined;
109
+ }>;
62
110
  static load(options: {
63
111
  filepath: string;
64
112
  parsed: LoadBashAgentOptions;
@@ -1,6 +1,8 @@
1
1
  import { type AgentInvokeOptions, type AgentOptions, AIAgent, type AIAgentOptions, type Message, type PromptBuilder } from "@aigne/core";
2
- import { type Instructions, type NestAgentSchema } from "@aigne/core/loader/agent-yaml.js";
3
- import { type LoadOptions } from "@aigne/core/loader/index.js";
2
+ import { type NestAgentSchema } from "@aigne/core/loader/agent-yaml.js";
3
+ import type { AgentLoadOptions } from "@aigne/core/loader/index.js";
4
+ import { type Instructions } from "@aigne/core/loader/schema.js";
5
+ import { type ZodType } from "zod";
4
6
  import { type StateManagementOptions } from "./type.js";
5
7
  /**
6
8
  * Configuration options for the Orchestrator Agent
@@ -17,17 +19,11 @@ export interface OrchestratorAgentOptions<I extends Message = Message, O extends
17
19
  stateManagement?: StateManagementOptions;
18
20
  concurrency?: number;
19
21
  }
20
- export interface LoadOrchestratorAgentOptions<I extends Message = Message, O extends Message = Message> extends Omit<AIAgentOptions<I, O>, "instructions"> {
21
- objective?: string | PromptBuilder | Instructions;
22
- planner?: NestAgentSchema | {
23
- instructions?: string | PromptBuilder | Instructions;
24
- };
25
- worker?: NestAgentSchema | {
26
- instructions?: string | PromptBuilder | Instructions;
27
- };
28
- completer?: NestAgentSchema | {
29
- instructions?: string | PromptBuilder | Instructions;
30
- };
22
+ export interface LoadOrchestratorAgentOptions {
23
+ objective?: string | Instructions;
24
+ planner?: NestAgentSchema;
25
+ worker?: NestAgentSchema;
26
+ completer?: NestAgentSchema;
31
27
  stateManagement?: StateManagementOptions;
32
28
  }
33
29
  /**
@@ -47,10 +43,13 @@ export interface LoadOrchestratorAgentOptions<I extends Message = Message, O ext
47
43
  */
48
44
  export declare class OrchestratorAgent<I extends Message = Message, O extends Message = Message> extends AIAgent<I, O> {
49
45
  tag: string;
46
+ static schema<T>({ filepath }: {
47
+ filepath: string;
48
+ }): ZodType<T>;
50
49
  static load<I extends Message = Message, O extends Message = Message>({ filepath, parsed, options, }: {
51
50
  filepath: string;
52
- parsed: AgentOptions<I, O> & LoadOrchestratorAgentOptions<I, O>;
53
- options?: LoadOptions;
51
+ parsed: LoadOrchestratorAgentOptions & AgentOptions<I, O>;
52
+ options?: AgentLoadOptions;
54
53
  }): Promise<OrchestratorAgent<I, O>>;
55
54
  /**
56
55
  * Factory method to create an OrchestratorAgent instance
@@ -3,6 +3,7 @@ import { Agent, type AgentInvokeOptions, type AgentOptions, type AgentResponseSt
3
3
  import { type NestAgentSchema } from "@aigne/core/loader/agent-yaml.js";
4
4
  import { type LoadOptions } from "@aigne/core/loader/index.js";
5
5
  import { type SandboxRuntimeConfig } from "@anthropic-ai/sandbox-runtime";
6
+ import z from "zod";
6
7
  export interface BashAgentOptions extends AgentOptions<BashAgentInput, BashAgentOutput> {
7
8
  sandbox?: Partial<{
8
9
  [K in keyof SandboxRuntimeConfig]: Partial<SandboxRuntimeConfig[K]>;
@@ -59,6 +60,53 @@ export interface BashAgentOutput extends Message {
59
60
  }
60
61
  export declare class BashAgent extends Agent<BashAgentInput, BashAgentOutput> {
61
62
  options: BashAgentOptions;
63
+ tag: string;
64
+ static schema({ filepath }: {
65
+ filepath: string;
66
+ }): z.ZodObject<{
67
+ sandbox: z.ZodType<boolean | {
68
+ [x: string]: z.ZodTypeAny | undefined;
69
+ } | undefined, z.ZodTypeDef, boolean | {
70
+ [x: string]: z.ZodTypeAny | undefined;
71
+ } | undefined>;
72
+ inputKey: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
73
+ timeout: z.ZodType<number | undefined, z.ZodTypeDef, number | undefined>;
74
+ permissions: z.ZodType<{
75
+ allow?: string[] | undefined;
76
+ deny?: string[] | undefined;
77
+ guard?: NestAgentSchema | undefined;
78
+ defaultMode?: "allow" | "ask" | "deny" | undefined;
79
+ } | undefined, z.ZodTypeDef, {
80
+ allow?: string[] | undefined;
81
+ deny?: string[] | undefined;
82
+ guard?: NestAgentSchema | undefined;
83
+ defaultMode?: "allow" | "ask" | "deny" | undefined;
84
+ } | undefined>;
85
+ }, "strip", z.ZodTypeAny, {
86
+ sandbox?: boolean | {
87
+ [x: string]: z.ZodTypeAny | undefined;
88
+ } | undefined;
89
+ inputKey?: string | undefined;
90
+ timeout?: number | undefined;
91
+ permissions?: {
92
+ allow?: string[] | undefined;
93
+ deny?: string[] | undefined;
94
+ guard?: NestAgentSchema | undefined;
95
+ defaultMode?: "allow" | "ask" | "deny" | undefined;
96
+ } | undefined;
97
+ }, {
98
+ sandbox?: boolean | {
99
+ [x: string]: z.ZodTypeAny | undefined;
100
+ } | undefined;
101
+ inputKey?: string | undefined;
102
+ timeout?: number | undefined;
103
+ permissions?: {
104
+ allow?: string[] | undefined;
105
+ deny?: string[] | undefined;
106
+ guard?: NestAgentSchema | undefined;
107
+ defaultMode?: "allow" | "ask" | "deny" | undefined;
108
+ } | undefined;
109
+ }>;
62
110
  static load(options: {
63
111
  filepath: string;
64
112
  parsed: LoadBashAgentOptions;
@@ -12,15 +12,30 @@ let sandboxInitialization;
12
12
  const mutex = new Mutex();
13
13
  export class BashAgent extends Agent {
14
14
  options;
15
+ tag = "Bash";
16
+ static schema({ filepath }) {
17
+ const nestAgentSchema = getNestAgentSchema({ filepath });
18
+ return camelizeSchema(z.object({
19
+ sandbox: optionalize(z.union([makeShapePropertiesOptions(SandboxRuntimeConfigSchema, 2), z.boolean()])),
20
+ inputKey: optionalize(z.string().describe("The input key for the bash script.")),
21
+ timeout: optionalize(z.number().describe("Timeout for script execution in milliseconds.")),
22
+ permissions: optionalize(camelizeSchema(z.object({
23
+ allow: optionalize(z.array(z.string())),
24
+ deny: optionalize(z.array(z.string())),
25
+ defaultMode: optionalize(z.enum(["allow", "ask", "deny"])),
26
+ guard: optionalize(nestAgentSchema),
27
+ }))),
28
+ }));
29
+ }
15
30
  static async load(options) {
16
- const schema = getBashAgentSchema({ filepath: options.filepath });
17
- const parsed = await schema.parseAsync(options.parsed);
31
+ const valid = await BashAgent.schema(options).parseAsync(options.parsed);
18
32
  return new BashAgent({
19
- ...parsed,
33
+ ...options.parsed,
34
+ ...valid,
20
35
  permissions: {
21
- ...parsed.permissions,
22
- guard: parsed.permissions?.guard
23
- ? await loadNestAgent(options.filepath, parsed.permissions.guard, options.options ?? {}, {
36
+ ...valid.permissions,
37
+ guard: valid.permissions?.guard
38
+ ? await loadNestAgent(options.filepath, valid.permissions.guard, options.options ?? {}, {
24
39
  outputSchema: z.object({
25
40
  approved: z.boolean().describe("Whether the command is approved by the user."),
26
41
  reason: z.string().describe("Optional reason for rejection.").optional(),
@@ -297,20 +312,6 @@ When to use:
297
312
  }
298
313
  }
299
314
  export default BashAgent;
300
- function getBashAgentSchema({ filepath }) {
301
- const nestAgentSchema = getNestAgentSchema({ filepath });
302
- return camelizeSchema(z.object({
303
- sandbox: optionalize(z.union([makeShapePropertiesOptions(SandboxRuntimeConfigSchema, 2), z.boolean()])),
304
- inputKey: optionalize(z.string().describe("The input key for the bash script.")),
305
- timeout: optionalize(z.number().describe("Timeout for script execution in milliseconds.")),
306
- permissions: optionalize(camelizeSchema(z.object({
307
- allow: optionalize(z.array(z.string())),
308
- deny: optionalize(z.array(z.string())),
309
- defaultMode: optionalize(z.enum(["allow", "ask", "deny"])),
310
- guard: optionalize(nestAgentSchema),
311
- }))),
312
- }));
313
- }
314
315
  function makeShapePropertiesOptions(schema, depth = 1) {
315
316
  return z.object(Object.fromEntries(Object.entries(schema.shape).map(([key, value]) => {
316
317
  const isObject = value instanceof ZodObject;
@@ -1,6 +1,8 @@
1
1
  import { type AgentInvokeOptions, type AgentOptions, AIAgent, type AIAgentOptions, type Message, type PromptBuilder } from "@aigne/core";
2
- import { type Instructions, type NestAgentSchema } from "@aigne/core/loader/agent-yaml.js";
3
- import { type LoadOptions } from "@aigne/core/loader/index.js";
2
+ import { type NestAgentSchema } from "@aigne/core/loader/agent-yaml.js";
3
+ import type { AgentLoadOptions } from "@aigne/core/loader/index.js";
4
+ import { type Instructions } from "@aigne/core/loader/schema.js";
5
+ import { type ZodType } from "zod";
4
6
  import { type StateManagementOptions } from "./type.js";
5
7
  /**
6
8
  * Configuration options for the Orchestrator Agent
@@ -17,17 +19,11 @@ export interface OrchestratorAgentOptions<I extends Message = Message, O extends
17
19
  stateManagement?: StateManagementOptions;
18
20
  concurrency?: number;
19
21
  }
20
- export interface LoadOrchestratorAgentOptions<I extends Message = Message, O extends Message = Message> extends Omit<AIAgentOptions<I, O>, "instructions"> {
21
- objective?: string | PromptBuilder | Instructions;
22
- planner?: NestAgentSchema | {
23
- instructions?: string | PromptBuilder | Instructions;
24
- };
25
- worker?: NestAgentSchema | {
26
- instructions?: string | PromptBuilder | Instructions;
27
- };
28
- completer?: NestAgentSchema | {
29
- instructions?: string | PromptBuilder | Instructions;
30
- };
22
+ export interface LoadOrchestratorAgentOptions {
23
+ objective?: string | Instructions;
24
+ planner?: NestAgentSchema;
25
+ worker?: NestAgentSchema;
26
+ completer?: NestAgentSchema;
31
27
  stateManagement?: StateManagementOptions;
32
28
  }
33
29
  /**
@@ -47,10 +43,13 @@ export interface LoadOrchestratorAgentOptions<I extends Message = Message, O ext
47
43
  */
48
44
  export declare class OrchestratorAgent<I extends Message = Message, O extends Message = Message> extends AIAgent<I, O> {
49
45
  tag: string;
46
+ static schema<T>({ filepath }: {
47
+ filepath: string;
48
+ }): ZodType<T>;
50
49
  static load<I extends Message = Message, O extends Message = Message>({ filepath, parsed, options, }: {
51
50
  filepath: string;
52
- parsed: AgentOptions<I, O> & LoadOrchestratorAgentOptions<I, O>;
53
- options?: LoadOptions;
51
+ parsed: LoadOrchestratorAgentOptions & AgentOptions<I, O>;
52
+ options?: AgentLoadOptions;
54
53
  }): Promise<OrchestratorAgent<I, O>>;
55
54
  /**
56
55
  * Factory method to create an OrchestratorAgent instance
@@ -1,7 +1,6 @@
1
1
  import { AIAgent, } from "@aigne/core";
2
- import { getInstructionsSchema, getNestAgentSchema, } from "@aigne/core/loader/agent-yaml.js";
3
- import { instructionsToPromptBuilder, loadNestAgent, } from "@aigne/core/loader/index.js";
4
- import { camelizeSchema, optionalize } from "@aigne/core/loader/schema.js";
2
+ import { getNestAgentSchema } from "@aigne/core/loader/agent-yaml.js";
3
+ import { camelizeSchema, getInstructionsSchema, instructionsToPromptBuilder, optionalize, } from "@aigne/core/loader/schema.js";
5
4
  import { isAgent } from "@aigne/core/utils/agent-utils.js";
6
5
  import * as fastq from "@aigne/core/utils/queue.js";
7
6
  import { estimateTokens } from "@aigne/core/utils/token-estimator.js";
@@ -54,28 +53,41 @@ const DEFAULT_CONCURRENCY = 5;
54
53
  */
55
54
  export class OrchestratorAgent extends AIAgent {
56
55
  tag = "OrchestratorAgent";
57
- static async load({ filepath, parsed, options = {}, }) {
58
- const schema = getOrchestratorAgentSchema({ filepath });
59
- const valid = await schema.parseAsync(parsed);
56
+ static schema({ filepath }) {
57
+ const nestAgentSchema = getNestAgentSchema({ filepath });
58
+ const instructionsSchema = getInstructionsSchema({ filepath });
59
+ return camelizeSchema(z.object({
60
+ objective: optionalize(instructionsSchema),
61
+ planner: optionalize(nestAgentSchema),
62
+ worker: optionalize(nestAgentSchema),
63
+ completer: optionalize(nestAgentSchema),
64
+ stateManagement: optionalize(camelizeSchema(stateManagementOptionsSchema)),
65
+ concurrency: optionalize(z.number().int().min(1).default(DEFAULT_CONCURRENCY)),
66
+ }));
67
+ }
68
+ static async load({ filepath, parsed, options, }) {
69
+ const valid = await OrchestratorAgent.schema({
70
+ filepath,
71
+ }).parseAsync(parsed);
60
72
  return new OrchestratorAgent({
61
73
  ...parsed,
62
- objective: valid.objective && instructionsToPromptBuilder(valid.objective),
74
+ objective: valid.objective ? instructionsToPromptBuilder(valid.objective) : undefined,
63
75
  planner: valid.planner
64
- ? (await loadNestAgent(filepath, valid.planner, options, {
76
+ ? (await options?.loadNestAgent(filepath, valid.planner, options, {
65
77
  ...defaultPlannerOptions,
66
78
  afs: parsed.afs,
67
79
  skills: parsed.skills,
68
80
  }))
69
81
  : undefined,
70
82
  worker: valid.worker
71
- ? (await loadNestAgent(filepath, valid.worker, options, {
83
+ ? (await options?.loadNestAgent(filepath, valid.worker, options, {
72
84
  ...defaultWorkerOptions,
73
85
  afs: parsed.afs,
74
86
  skills: parsed.skills,
75
87
  }))
76
88
  : undefined,
77
89
  completer: valid.completer
78
- ? (await loadNestAgent(filepath, valid.completer, options, {
90
+ ? (await options?.loadNestAgent(filepath, valid.completer, options, {
79
91
  ...defaultCompleterOptions,
80
92
  outputSchema: parsed.outputSchema,
81
93
  afs: parsed.afs,
@@ -235,15 +247,3 @@ export class OrchestratorAgent extends AIAgent {
235
247
  }
236
248
  }
237
249
  export default OrchestratorAgent;
238
- function getOrchestratorAgentSchema({ filepath }) {
239
- const nestAgentSchema = getNestAgentSchema({ filepath });
240
- const instructionsSchema = getInstructionsSchema({ filepath });
241
- return camelizeSchema(z.object({
242
- objective: optionalize(instructionsSchema),
243
- planner: optionalize(nestAgentSchema),
244
- worker: optionalize(nestAgentSchema),
245
- completer: optionalize(nestAgentSchema),
246
- stateManagement: optionalize(camelizeSchema(stateManagementOptionsSchema)),
247
- concurrency: optionalize(z.number().int().min(1).default(DEFAULT_CONCURRENCY)),
248
- }));
249
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/agent-library",
3
- "version": "1.24.0-beta.3",
3
+ "version": "1.24.0-beta.4",
4
4
  "description": "Collection of agent libraries for AIGNE framework",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -57,9 +57,9 @@
57
57
  "yaml": "^2.8.1",
58
58
  "zod": "^3.25.67",
59
59
  "zod-to-json-schema": "^3.24.6",
60
- "@aigne/core": "^1.72.0-beta.3",
60
+ "@aigne/core": "^1.72.0-beta.4",
61
61
  "@aigne/sqlite": "^0.4.9-beta",
62
- "@aigne/openai": "^0.16.16-beta.3"
62
+ "@aigne/openai": "^0.16.16-beta.4"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@types/bun": "^1.2.22",