@aigne/agent-library 1.8.1 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/README.md +26 -15
- package/README.zh.md +12 -9
- package/lib/cjs/fs-memory/index.js +4 -4
- package/lib/cjs/orchestrator/index.d.ts +3 -3
- package/lib/cjs/orchestrator/index.js +6 -6
- package/lib/dts/orchestrator/index.d.ts +3 -3
- package/lib/esm/fs-memory/index.js +4 -4
- package/lib/esm/orchestrator/index.d.ts +3 -3
- package/lib/esm/orchestrator/index.js +6 -6
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
- chore: release 1.2.0
|
|
4
4
|
|
|
5
|
+
## [1.10.0](https://github.com/AIGNE-io/aigne-framework/compare/agent-library-v1.9.0...agent-library-v1.10.0) (2025-05-25)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* add user context support ([#131](https://github.com/AIGNE-io/aigne-framework/issues/131)) ([4dd9d20](https://github.com/AIGNE-io/aigne-framework/commit/4dd9d20953f6ac33933723db56efd9b44bafeb02))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Dependencies
|
|
14
|
+
|
|
15
|
+
* The following workspace dependencies were updated
|
|
16
|
+
* dependencies
|
|
17
|
+
* @aigne/core bumped to 1.17.0
|
|
18
|
+
|
|
19
|
+
## [1.9.0](https://github.com/AIGNE-io/aigne-framework/compare/agent-library-v1.8.1...agent-library-v1.9.0) (2025-05-23)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* **models:** publish model adapters as standalone packages ([#126](https://github.com/AIGNE-io/aigne-framework/issues/126)) ([588b8ae](https://github.com/AIGNE-io/aigne-framework/commit/588b8aea6abcee5fa87def1358bf51f84021c6ef))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Dependencies
|
|
28
|
+
|
|
29
|
+
* The following workspace dependencies were updated
|
|
30
|
+
* dependencies
|
|
31
|
+
* @aigne/core bumped to 1.16.0
|
|
32
|
+
|
|
5
33
|
## [1.8.1](https://github.com/AIGNE-io/aigne-framework/compare/agent-library-v1.8.0...agent-library-v1.8.1) (2025-05-15)
|
|
6
34
|
|
|
7
35
|
|
package/README.md
CHANGED
|
@@ -16,11 +16,11 @@ Collection of agent libraries for [AIGNE Framework](https://github.com/AIGNE-io/
|
|
|
16
16
|
|
|
17
17
|
## Features
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
* **Orchestrator Agent**: Provides OrchestratorAgent implementation for coordinating workflows between multiple agents
|
|
20
|
+
* **Task Concurrency**: Supports parallel execution of multiple tasks to improve processing efficiency
|
|
21
|
+
* **Planning & Execution**: Automatically generates execution plans and executes them step by step
|
|
22
|
+
* **Result Synthesis**: Intelligently synthesizes results from multiple steps and tasks
|
|
23
|
+
* **TypeScript Support**: Complete type definitions providing an excellent development experience
|
|
24
24
|
|
|
25
25
|
## Installation
|
|
26
26
|
|
|
@@ -61,12 +61,16 @@ const aigne = new AIGNE({ model });
|
|
|
61
61
|
// Create orchestrator agent
|
|
62
62
|
const orchestrator = new OrchestratorAgent({
|
|
63
63
|
name: "MainOrchestrator",
|
|
64
|
-
instructions:
|
|
64
|
+
instructions:
|
|
65
|
+
"You are a task orchestrator responsible for coordinating multiple specialized agents to complete complex tasks.",
|
|
65
66
|
// Configure sub-agents and tools...
|
|
66
67
|
});
|
|
67
68
|
|
|
68
69
|
// Execute orchestration task
|
|
69
|
-
const result = await aigne.invoke(
|
|
70
|
+
const result = await aigne.invoke(
|
|
71
|
+
orchestrator,
|
|
72
|
+
"Analyze this article and generate a summary and keywords",
|
|
73
|
+
);
|
|
70
74
|
console.log(result);
|
|
71
75
|
```
|
|
72
76
|
|
|
@@ -74,7 +78,7 @@ console.log(result);
|
|
|
74
78
|
|
|
75
79
|
The library currently provides one specialized agent implementation:
|
|
76
80
|
|
|
77
|
-
|
|
81
|
+
* **Orchestrator Agent (OrchestratorAgent)**: Responsible for coordinating work between multiple agents and managing complex workflows. It can automatically plan task steps, distribute and execute tasks across multiple agents, and finally synthesize the results.
|
|
78
82
|
|
|
79
83
|
## Advanced Usage
|
|
80
84
|
|
|
@@ -93,36 +97,43 @@ const model = new OpenAIChatModel({
|
|
|
93
97
|
// Create specialized sub-agents
|
|
94
98
|
const researchAgent = AIAgent.from({
|
|
95
99
|
name: "Researcher",
|
|
96
|
-
instructions:
|
|
100
|
+
instructions:
|
|
101
|
+
"You are a professional researcher responsible for collecting and analyzing information.",
|
|
97
102
|
outputKey: "research",
|
|
98
103
|
});
|
|
99
104
|
|
|
100
105
|
const writerAgent = AIAgent.from({
|
|
101
106
|
name: "Writer",
|
|
102
|
-
instructions:
|
|
107
|
+
instructions:
|
|
108
|
+
"You are a professional writer responsible for creating high-quality content.",
|
|
103
109
|
outputKey: "content",
|
|
104
110
|
});
|
|
105
111
|
|
|
106
112
|
const editorAgent = AIAgent.from({
|
|
107
113
|
name: "Editor",
|
|
108
|
-
instructions:
|
|
114
|
+
instructions:
|
|
115
|
+
"You are a strict editor responsible for checking content quality and formatting.",
|
|
109
116
|
outputKey: "edited",
|
|
110
117
|
});
|
|
111
118
|
|
|
112
119
|
// Create orchestrator agent
|
|
113
120
|
const orchestrator = new OrchestratorAgent({
|
|
114
121
|
name: "WorkflowOrchestrator",
|
|
115
|
-
instructions:
|
|
122
|
+
instructions:
|
|
123
|
+
"You are responsible for coordinating research, writing, and editing processes.",
|
|
116
124
|
skills: [researchAgent, writerAgent, editorAgent],
|
|
117
125
|
// Optional configuration
|
|
118
|
-
maxIterations: 30,
|
|
119
|
-
tasksConcurrency: 5,
|
|
126
|
+
maxIterations: 30, // Maximum number of iterations
|
|
127
|
+
tasksConcurrency: 5, // Task concurrency
|
|
120
128
|
});
|
|
121
129
|
|
|
122
130
|
// Use the orchestrator agent
|
|
123
131
|
const aigne = new AIGNE({ model });
|
|
124
132
|
|
|
125
|
-
const result = await aigne.invoke(
|
|
133
|
+
const result = await aigne.invoke(
|
|
134
|
+
orchestrator,
|
|
135
|
+
"Applications of artificial intelligence in healthcare",
|
|
136
|
+
);
|
|
126
137
|
|
|
127
138
|
console.log(result);
|
|
128
139
|
```
|
package/README.zh.md
CHANGED
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
|
|
17
17
|
## 特性
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
* **编排代理**:提供 OrchestratorAgent 实现,用于协调多个代理之间的工作流
|
|
20
|
+
* **任务并发**:支持并行执行多个任务,提高处理效率
|
|
21
|
+
* **计划与执行**:自动生成执行计划并逐步执行
|
|
22
|
+
* **结果合成**:智能合成多个步骤和任务的结果
|
|
23
|
+
* **TypeScript 支持**:完整的类型定义,提供优秀的开发体验
|
|
24
24
|
|
|
25
25
|
## 安装
|
|
26
26
|
|
|
@@ -66,7 +66,10 @@ const orchestrator = new OrchestratorAgent({
|
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
// 执行编排任务
|
|
69
|
-
const result = await aigne.invoke(
|
|
69
|
+
const result = await aigne.invoke(
|
|
70
|
+
orchestrator,
|
|
71
|
+
"分析这篇文章并生成摘要和关键词",
|
|
72
|
+
);
|
|
70
73
|
|
|
71
74
|
console.log(result);
|
|
72
75
|
```
|
|
@@ -75,7 +78,7 @@ console.log(result);
|
|
|
75
78
|
|
|
76
79
|
该库目前提供了一种专业化的代理实现:
|
|
77
80
|
|
|
78
|
-
|
|
81
|
+
* **编排代理(OrchestratorAgent)**:负责协调多个代理之间的工作,管理复杂工作流。它能够自动规划任务步骤,并在多个代理之间分配和执行任务,最后合成结果。
|
|
79
82
|
|
|
80
83
|
## 高级用法
|
|
81
84
|
|
|
@@ -116,8 +119,8 @@ const orchestrator = new OrchestratorAgent({
|
|
|
116
119
|
instructions: "你负责协调研究、写作和编辑流程。",
|
|
117
120
|
skills: [researchAgent, writerAgent, editorAgent],
|
|
118
121
|
// 可选配置
|
|
119
|
-
maxIterations: 30,
|
|
120
|
-
tasksConcurrency: 5,
|
|
122
|
+
maxIterations: 30, // 最大迭代次数
|
|
123
|
+
tasksConcurrency: 5, // 任务并发数
|
|
121
124
|
});
|
|
122
125
|
|
|
123
126
|
// 使用编排代理
|
|
@@ -64,11 +64,11 @@ class FSMemoryRetriever extends index_js_1.MemoryRetriever {
|
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
agent;
|
|
67
|
-
async process(input,
|
|
67
|
+
async process(input, options) {
|
|
68
68
|
if (!(await (0, fs_js_1.exists)(this.options.memoryFileName)))
|
|
69
69
|
return { memories: [] };
|
|
70
70
|
const allMemory = await (0, promises_1.readFile)(this.options.memoryFileName, "utf-8");
|
|
71
|
-
const { memories } = await context.invoke(this.agent, { ...input, allMemory });
|
|
71
|
+
const { memories } = await options.context.invoke(this.agent, { ...input, allMemory });
|
|
72
72
|
const result = memories.map((memory) => ({
|
|
73
73
|
id: (0, index_js_1.newMemoryId)(),
|
|
74
74
|
content: memory.content,
|
|
@@ -97,11 +97,11 @@ class FSMemoryRecorder extends index_js_1.MemoryRecorder {
|
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
agent;
|
|
100
|
-
async process(input,
|
|
100
|
+
async process(input, options) {
|
|
101
101
|
const allMemory = (await (0, fs_js_1.exists)(this.options.memoryFileName))
|
|
102
102
|
? await (0, promises_1.readFile)(this.options.memoryFileName, "utf-8")
|
|
103
103
|
: "";
|
|
104
|
-
const { memories } = await context.invoke(this.agent, { ...input, allMemory });
|
|
104
|
+
const { memories } = await options.context.invoke(this.agent, { ...input, allMemory });
|
|
105
105
|
const raw = (0, yaml_1.stringify)(memories.map((i) => ({
|
|
106
106
|
content: i.content,
|
|
107
107
|
})));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Agent, type
|
|
1
|
+
import { Agent, type AgentInvokeOptions, type AgentOptions, type Message } from "@aigne/core";
|
|
2
2
|
import { type FullPlanOutput, type StepWithResult } from "./orchestrator-prompts.js";
|
|
3
3
|
/**
|
|
4
4
|
* Re-export orchestrator prompt templates and related types
|
|
@@ -95,10 +95,10 @@ export declare class OrchestratorAgent<I extends Message = Message, O extends Me
|
|
|
95
95
|
* c. Otherwise, execute steps in the plan
|
|
96
96
|
*
|
|
97
97
|
* @param input - Input message containing the objective
|
|
98
|
-
* @param
|
|
98
|
+
* @param options - Agent invocation options
|
|
99
99
|
* @returns Processing result
|
|
100
100
|
*/
|
|
101
|
-
process(input: I,
|
|
101
|
+
process(input: I, options: AgentInvokeOptions): Promise<O>;
|
|
102
102
|
private getFullPlanInput;
|
|
103
103
|
private getFullPlan;
|
|
104
104
|
private synthesizePlanResult;
|
|
@@ -102,11 +102,11 @@ class OrchestratorAgent extends core_1.Agent {
|
|
|
102
102
|
* c. Otherwise, execute steps in the plan
|
|
103
103
|
*
|
|
104
104
|
* @param input - Input message containing the objective
|
|
105
|
-
* @param
|
|
105
|
+
* @param options - Agent invocation options
|
|
106
106
|
* @returns Processing result
|
|
107
107
|
*/
|
|
108
|
-
async process(input,
|
|
109
|
-
const { model } = context;
|
|
108
|
+
async process(input, options) {
|
|
109
|
+
const { model } = options.context;
|
|
110
110
|
if (!model)
|
|
111
111
|
throw new Error("model is required to run OrchestratorAgent");
|
|
112
112
|
const objective = (0, core_1.getMessage)(input);
|
|
@@ -119,13 +119,13 @@ class OrchestratorAgent extends core_1.Agent {
|
|
|
119
119
|
let iterations = 0;
|
|
120
120
|
const maxIterations = this.maxIterations ?? DEFAULT_MAX_ITERATIONS;
|
|
121
121
|
while (iterations++ < maxIterations) {
|
|
122
|
-
const plan = await this.getFullPlan(result, context);
|
|
122
|
+
const plan = await this.getFullPlan(result, options.context);
|
|
123
123
|
result.plan = plan;
|
|
124
124
|
if (plan.isComplete) {
|
|
125
|
-
return this.synthesizePlanResult(result, context);
|
|
125
|
+
return this.synthesizePlanResult(result, options.context);
|
|
126
126
|
}
|
|
127
127
|
for (const step of plan.steps) {
|
|
128
|
-
const stepResult = await this.executeStep(result, step, context);
|
|
128
|
+
const stepResult = await this.executeStep(result, step, options.context);
|
|
129
129
|
result.steps.push(stepResult);
|
|
130
130
|
}
|
|
131
131
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Agent, type
|
|
1
|
+
import { Agent, type AgentInvokeOptions, type AgentOptions, type Message } from "@aigne/core";
|
|
2
2
|
import { type FullPlanOutput, type StepWithResult } from "./orchestrator-prompts.js";
|
|
3
3
|
/**
|
|
4
4
|
* Re-export orchestrator prompt templates and related types
|
|
@@ -95,10 +95,10 @@ export declare class OrchestratorAgent<I extends Message = Message, O extends Me
|
|
|
95
95
|
* c. Otherwise, execute steps in the plan
|
|
96
96
|
*
|
|
97
97
|
* @param input - Input message containing the objective
|
|
98
|
-
* @param
|
|
98
|
+
* @param options - Agent invocation options
|
|
99
99
|
* @returns Processing result
|
|
100
100
|
*/
|
|
101
|
-
process(input: I,
|
|
101
|
+
process(input: I, options: AgentInvokeOptions): Promise<O>;
|
|
102
102
|
private getFullPlanInput;
|
|
103
103
|
private getFullPlan;
|
|
104
104
|
private synthesizePlanResult;
|
|
@@ -60,11 +60,11 @@ class FSMemoryRetriever extends MemoryRetriever {
|
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
agent;
|
|
63
|
-
async process(input,
|
|
63
|
+
async process(input, options) {
|
|
64
64
|
if (!(await exists(this.options.memoryFileName)))
|
|
65
65
|
return { memories: [] };
|
|
66
66
|
const allMemory = await readFile(this.options.memoryFileName, "utf-8");
|
|
67
|
-
const { memories } = await context.invoke(this.agent, { ...input, allMemory });
|
|
67
|
+
const { memories } = await options.context.invoke(this.agent, { ...input, allMemory });
|
|
68
68
|
const result = memories.map((memory) => ({
|
|
69
69
|
id: newMemoryId(),
|
|
70
70
|
content: memory.content,
|
|
@@ -93,11 +93,11 @@ class FSMemoryRecorder extends MemoryRecorder {
|
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
agent;
|
|
96
|
-
async process(input,
|
|
96
|
+
async process(input, options) {
|
|
97
97
|
const allMemory = (await exists(this.options.memoryFileName))
|
|
98
98
|
? await readFile(this.options.memoryFileName, "utf-8")
|
|
99
99
|
: "";
|
|
100
|
-
const { memories } = await context.invoke(this.agent, { ...input, allMemory });
|
|
100
|
+
const { memories } = await options.context.invoke(this.agent, { ...input, allMemory });
|
|
101
101
|
const raw = stringify(memories.map((i) => ({
|
|
102
102
|
content: i.content,
|
|
103
103
|
})));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Agent, type
|
|
1
|
+
import { Agent, type AgentInvokeOptions, type AgentOptions, type Message } from "@aigne/core";
|
|
2
2
|
import { type FullPlanOutput, type StepWithResult } from "./orchestrator-prompts.js";
|
|
3
3
|
/**
|
|
4
4
|
* Re-export orchestrator prompt templates and related types
|
|
@@ -95,10 +95,10 @@ export declare class OrchestratorAgent<I extends Message = Message, O extends Me
|
|
|
95
95
|
* c. Otherwise, execute steps in the plan
|
|
96
96
|
*
|
|
97
97
|
* @param input - Input message containing the objective
|
|
98
|
-
* @param
|
|
98
|
+
* @param options - Agent invocation options
|
|
99
99
|
* @returns Processing result
|
|
100
100
|
*/
|
|
101
|
-
process(input: I,
|
|
101
|
+
process(input: I, options: AgentInvokeOptions): Promise<O>;
|
|
102
102
|
private getFullPlanInput;
|
|
103
103
|
private getFullPlan;
|
|
104
104
|
private synthesizePlanResult;
|
|
@@ -82,11 +82,11 @@ export class OrchestratorAgent extends Agent {
|
|
|
82
82
|
* c. Otherwise, execute steps in the plan
|
|
83
83
|
*
|
|
84
84
|
* @param input - Input message containing the objective
|
|
85
|
-
* @param
|
|
85
|
+
* @param options - Agent invocation options
|
|
86
86
|
* @returns Processing result
|
|
87
87
|
*/
|
|
88
|
-
async process(input,
|
|
89
|
-
const { model } = context;
|
|
88
|
+
async process(input, options) {
|
|
89
|
+
const { model } = options.context;
|
|
90
90
|
if (!model)
|
|
91
91
|
throw new Error("model is required to run OrchestratorAgent");
|
|
92
92
|
const objective = getMessage(input);
|
|
@@ -99,13 +99,13 @@ export class OrchestratorAgent extends Agent {
|
|
|
99
99
|
let iterations = 0;
|
|
100
100
|
const maxIterations = this.maxIterations ?? DEFAULT_MAX_ITERATIONS;
|
|
101
101
|
while (iterations++ < maxIterations) {
|
|
102
|
-
const plan = await this.getFullPlan(result, context);
|
|
102
|
+
const plan = await this.getFullPlan(result, options.context);
|
|
103
103
|
result.plan = plan;
|
|
104
104
|
if (plan.isComplete) {
|
|
105
|
-
return this.synthesizePlanResult(result, context);
|
|
105
|
+
return this.synthesizePlanResult(result, options.context);
|
|
106
106
|
}
|
|
107
107
|
for (const step of plan.steps) {
|
|
108
|
-
const stepResult = await this.executeStep(result, step, context);
|
|
108
|
+
const stepResult = await this.executeStep(result, step, options.context);
|
|
109
109
|
result.steps.push(stepResult);
|
|
110
110
|
}
|
|
111
111
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/agent-library",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Collection of agent libraries for AIGNE framework",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"fastq": "^1.19.1",
|
|
43
43
|
"yaml": "^2.7.1",
|
|
44
44
|
"zod": "^3.24.4",
|
|
45
|
-
"@aigne/core": "^1.
|
|
45
|
+
"@aigne/core": "^1.17.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/bun": "^1.2.12",
|