@aigne/agent-library 1.20.1 → 1.20.3

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
@@ -13,6 +13,31 @@
13
13
  * @aigne/core bumped to 1.22.0
14
14
  * @aigne/openai bumped to 0.3.4
15
15
 
16
+ ## [1.20.3](https://github.com/AIGNE-io/aigne-framework/compare/agent-library-v1.20.2...agent-library-v1.20.3) (2025-07-10)
17
+
18
+
19
+ ### Dependencies
20
+
21
+ * The following workspace dependencies were updated
22
+ * dependencies
23
+ * @aigne/core bumped to 1.33.0
24
+ * @aigne/openai bumped to 0.9.0
25
+
26
+ ## [1.20.2](https://github.com/AIGNE-io/aigne-framework/compare/agent-library-v1.20.1...agent-library-v1.20.2) (2025-07-09)
27
+
28
+
29
+ ### Bug Fixes
30
+
31
+ * resolve warning caused by dependencies. ([#237](https://github.com/AIGNE-io/aigne-framework/issues/237)) ([3ad7cc6](https://github.com/AIGNE-io/aigne-framework/commit/3ad7cc66b0c1ab425879176849af97c88c01b5a2))
32
+
33
+
34
+ ### Dependencies
35
+
36
+ * The following workspace dependencies were updated
37
+ * dependencies
38
+ * @aigne/core bumped to 1.32.2
39
+ * @aigne/openai bumped to 0.8.2
40
+
16
41
  ## [1.20.1](https://github.com/AIGNE-io/aigne-framework/compare/agent-library-v1.20.0...agent-library-v1.20.1) (2025-07-09)
17
42
 
18
43
 
package/README.md CHANGED
@@ -6,8 +6,6 @@
6
6
  [![NPM Version](https://img.shields.io/npm/v/@aigne/agent-library)](https://www.npmjs.com/package/@aigne/agent-library)
7
7
  [![Elastic-2.0 licensed](https://img.shields.io/npm/l/@aigne/agent-library)](https://github.com/AIGNE-io/aigne-framework/blob/main/LICENSE)
8
8
 
9
- **English** | [中文](README.zh.md)
10
-
11
9
  Collection of agent libraries for [AIGNE Framework](https://github.com/AIGNE-io/aigne-framework), providing pre-built agent implementations.
12
10
 
13
11
  ## Introduction
@@ -3,7 +3,7 @@ export interface TransformInput {
3
3
  responseSchema: string;
4
4
  responseSampleData?: string;
5
5
  sourceData?: string;
6
- sourceSchema?: string;
6
+ sourceSchema: string;
7
7
  instruction?: string;
8
8
  [key: string]: unknown;
9
9
  }
@@ -8,14 +8,9 @@ exports.generateMapping = generateMapping;
8
8
  const core_1 = require("@aigne/core");
9
9
  const mapper_js_1 = __importDefault(require("./agents/mapper.js"));
10
10
  const reviewer_js_1 = __importDefault(require("./agents/reviewer.js"));
11
- const tools_js_1 = require("./tools.js");
12
11
  async function generateMapping({ input, model, }) {
13
12
  if (!model)
14
13
  throw new Error("model is required to run data mapper");
15
- // if sourceSchema is not provided, generate it from sourceData
16
- if (!input.sourceSchema && input.sourceData) {
17
- input.sourceSchema = JSON.stringify((0, tools_js_1.getSchemaFromData)(JSON.parse(input.sourceData)));
18
- }
19
14
  const aigne = new core_1.AIGNE({ model, agents: [mapper_js_1.default, reviewer_js_1.default] });
20
15
  aigne.publish(core_1.UserInputTopic, input);
21
16
  const { message } = await aigne.subscribe(core_1.UserOutputTopic);
@@ -25,5 +20,5 @@ async function generateMapping({ input, model, }) {
25
20
  confidenceReasoning: message.confidenceReasoning || "",
26
21
  };
27
22
  }
28
- var tools_js_2 = require("./tools.js");
29
- Object.defineProperty(exports, "applyJsonata", { enumerable: true, get: function () { return tools_js_2.applyJsonata; } });
23
+ var tools_js_1 = require("./tools.js");
24
+ Object.defineProperty(exports, "applyJsonata", { enumerable: true, get: function () { return tools_js_1.applyJsonata; } });
@@ -5,12 +5,6 @@ export interface TransformResult {
5
5
  data?: unknown;
6
6
  error?: string;
7
7
  }
8
- /**
9
- * Extract JSON Schema from data
10
- * @param data Any data
11
- * @returns JSON Schema or null
12
- */
13
- export declare function getSchemaFromData(data: unknown): unknown;
14
8
  export declare function applyJsonataWithValidation(data: unknown, expr: string, schema: unknown): Promise<TransformResult>;
15
9
  export declare function applyJsonata(data: unknown, expr: string): Promise<unknown>;
16
10
  export declare function extendJsonata(expr: string): jsonata.Expression;
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getSchemaFromData = getSchemaFromData;
7
6
  exports.applyJsonataWithValidation = applyJsonataWithValidation;
8
7
  exports.applyJsonata = applyJsonata;
9
8
  exports.extendJsonata = extendJsonata;
@@ -11,17 +10,6 @@ exports.addNullableToOptional = addNullableToOptional;
11
10
  /* eslint-disable @typescript-eslint/no-explicit-any */
12
11
  const jsonata_1 = __importDefault(require("jsonata"));
13
12
  const jsonschema_1 = require("jsonschema");
14
- const to_json_schema_1 = __importDefault(require("to-json-schema"));
15
- /**
16
- * Extract JSON Schema from data
17
- * @param data Any data
18
- * @returns JSON Schema or null
19
- */
20
- function getSchemaFromData(data) {
21
- if (!data)
22
- return null;
23
- return (0, to_json_schema_1.default)(data);
24
- }
25
13
  async function applyJsonataWithValidation(data, expr, schema) {
26
14
  try {
27
15
  const result = await applyJsonata(data, expr);
@@ -3,7 +3,7 @@ export interface TransformInput {
3
3
  responseSchema: string;
4
4
  responseSampleData?: string;
5
5
  sourceData?: string;
6
- sourceSchema?: string;
6
+ sourceSchema: string;
7
7
  instruction?: string;
8
8
  [key: string]: unknown;
9
9
  }
@@ -5,12 +5,6 @@ export interface TransformResult {
5
5
  data?: unknown;
6
6
  error?: string;
7
7
  }
8
- /**
9
- * Extract JSON Schema from data
10
- * @param data Any data
11
- * @returns JSON Schema or null
12
- */
13
- export declare function getSchemaFromData(data: unknown): unknown;
14
8
  export declare function applyJsonataWithValidation(data: unknown, expr: string, schema: unknown): Promise<TransformResult>;
15
9
  export declare function applyJsonata(data: unknown, expr: string): Promise<unknown>;
16
10
  export declare function extendJsonata(expr: string): jsonata.Expression;
@@ -3,7 +3,7 @@ export interface TransformInput {
3
3
  responseSchema: string;
4
4
  responseSampleData?: string;
5
5
  sourceData?: string;
6
- sourceSchema?: string;
6
+ sourceSchema: string;
7
7
  instruction?: string;
8
8
  [key: string]: unknown;
9
9
  }
@@ -1,14 +1,9 @@
1
1
  import { AIGNE, UserInputTopic, UserOutputTopic } from "@aigne/core";
2
2
  import mapper from "./agents/mapper.js";
3
3
  import reviewer from "./agents/reviewer.js";
4
- import { getSchemaFromData } from "./tools.js";
5
4
  export async function generateMapping({ input, model, }) {
6
5
  if (!model)
7
6
  throw new Error("model is required to run data mapper");
8
- // if sourceSchema is not provided, generate it from sourceData
9
- if (!input.sourceSchema && input.sourceData) {
10
- input.sourceSchema = JSON.stringify(getSchemaFromData(JSON.parse(input.sourceData)));
11
- }
12
7
  const aigne = new AIGNE({ model, agents: [mapper, reviewer] });
13
8
  aigne.publish(UserInputTopic, input);
14
9
  const { message } = await aigne.subscribe(UserOutputTopic);
@@ -5,12 +5,6 @@ export interface TransformResult {
5
5
  data?: unknown;
6
6
  error?: string;
7
7
  }
8
- /**
9
- * Extract JSON Schema from data
10
- * @param data Any data
11
- * @returns JSON Schema or null
12
- */
13
- export declare function getSchemaFromData(data: unknown): unknown;
14
8
  export declare function applyJsonataWithValidation(data: unknown, expr: string, schema: unknown): Promise<TransformResult>;
15
9
  export declare function applyJsonata(data: unknown, expr: string): Promise<unknown>;
16
10
  export declare function extendJsonata(expr: string): jsonata.Expression;
@@ -1,17 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import jsonata from "jsonata";
3
3
  import { Validator } from "jsonschema";
4
- import toJsonSchema from "to-json-schema";
5
- /**
6
- * Extract JSON Schema from data
7
- * @param data Any data
8
- * @returns JSON Schema or null
9
- */
10
- export function getSchemaFromData(data) {
11
- if (!data)
12
- return null;
13
- return toJsonSchema(data);
14
- }
15
4
  export async function applyJsonataWithValidation(data, expr, schema) {
16
5
  try {
17
6
  const result = await applyJsonata(data, expr);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/agent-library",
3
- "version": "1.20.1",
3
+ "version": "1.20.3",
4
4
  "description": "Collection of agent libraries for AIGNE framework",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -43,17 +43,15 @@
43
43
  "fastq": "^1.19.1",
44
44
  "jsonata": "^2.0.6",
45
45
  "jsonschema": "^1.5.0",
46
- "to-json-schema": "^0.2.5",
47
46
  "uuid": "^11.1.0",
48
47
  "yaml": "^2.8.0",
49
48
  "zod": "^3.25.67",
50
- "@aigne/core": "^1.32.1",
51
- "@aigne/sqlite": "^0.3.0",
52
- "@aigne/openai": "^0.8.1"
49
+ "@aigne/core": "^1.33.0",
50
+ "@aigne/openai": "^0.9.0",
51
+ "@aigne/sqlite": "^0.3.0"
53
52
  },
54
53
  "devDependencies": {
55
54
  "@types/bun": "^1.2.17",
56
- "@types/to-json-schema": "^0.2.4",
57
55
  "npm-run-all": "^4.1.5",
58
56
  "rimraf": "^6.0.1",
59
57
  "typescript": "^5.8.3"
package/README.zh.md DELETED
@@ -1,135 +0,0 @@
1
- # @aigne/agent-library
2
-
3
- [![GitHub star chart](https://img.shields.io/github/stars/AIGNE-io/aigne-framework?style=flat-square)](https://star-history.com/#AIGNE-io/aigne-framework)
4
- [![Open Issues](https://img.shields.io/github/issues-raw/AIGNE-io/aigne-framework?style=flat-square)](https://github.com/AIGNE-io/aigne-framework/issues)
5
- [![codecov](https://codecov.io/gh/AIGNE-io/aigne-framework/graph/badge.svg?token=DO07834RQL)](https://codecov.io/gh/AIGNE-io/aigne-framework)
6
- [![NPM Version](https://img.shields.io/npm/v/@aigne/agent-library)](https://www.npmjs.com/package/@aigne/agent-library)
7
- [![Elastic-2.0 licensed](https://img.shields.io/npm/l/@aigne/agent-library)](https://github.com/AIGNE-io/aigne-framework/blob/main/LICENSE)
8
-
9
- [English](README.md) | **中文**
10
-
11
- [AIGNE 框架](https://github.com/AIGNE-io/aigne-framework)的代理库集合,提供预构建的代理实现。
12
-
13
- ## 简介
14
-
15
- `@aigne/agent-library` 是 [AIGNE 框架](https://github.com/AIGNE-io/aigne-framework)的代理库集合,为开发者提供预构建的代理实现。该库是基于 [@aigne/core](https://github.com/AIGNE-io/aigne-framework/tree/main/packages/core) 构建的,扩展了核心功能,使复杂工作流的编排更加简便。
16
-
17
- ## 特性
18
-
19
- * **编排代理**:提供 OrchestratorAgent 实现,用于协调多个代理之间的工作流
20
- * **任务并发**:支持并行执行多个任务,提高处理效率
21
- * **计划与执行**:自动生成执行计划并逐步执行
22
- * **结果合成**:智能合成多个步骤和任务的结果
23
- * **TypeScript 支持**:完整的类型定义,提供优秀的开发体验
24
-
25
- ## 安装
26
-
27
- #### 使用 npm
28
-
29
- ```bash
30
- npm install @aigne/agent-library @aigne/core
31
- ```
32
-
33
- ### 使用 yarn
34
-
35
- ```bash
36
- yarn add @aigne/agent-library @aigne/core
37
- ```
38
-
39
- ### 使用 pnpm
40
-
41
- ```bash
42
- pnpm add @aigne/agent-library @aigne/core
43
- ```
44
-
45
- ## 基本用法
46
-
47
- ```typescript
48
- import { OrchestratorAgent } from "@aigne/agent-library/orchestrator";
49
- import { AIGNE } from "@aigne/core";
50
- import { OpenAIChatModel } from "@aigne/core/models/openai-chat-model.js";
51
-
52
- // 创建 AI 模型实例
53
- const model = new OpenAIChatModel({
54
- apiKey: process.env.OPENAI_API_KEY,
55
- model: "gpt-4-turbo",
56
- });
57
-
58
- // 创建执行引擎
59
- const aigne = new AIGNE({ model });
60
-
61
- // 创建编排代理
62
- const orchestrator = new OrchestratorAgent({
63
- name: "主编排器",
64
- instructions: "你是一个任务编排器,负责协调多个专业代理完成复杂任务。",
65
- // 配置子代理和工具...
66
- });
67
-
68
- // 执行编排任务
69
- const result = await aigne.invoke(
70
- orchestrator,
71
- "分析这篇文章并生成摘要和关键词",
72
- );
73
-
74
- console.log(result);
75
- ```
76
-
77
- ## 提供的代理类型
78
-
79
- 该库目前提供了一种专业化的代理实现:
80
-
81
- * **编排代理(OrchestratorAgent)**:负责协调多个代理之间的工作,管理复杂工作流。它能够自动规划任务步骤,并在多个代理之间分配和执行任务,最后合成结果。
82
-
83
- ## 高级用法
84
-
85
- ### 创建编排工作流
86
-
87
- ```typescript
88
- import { OrchestratorAgent } from "@aigne/agent-library/orchestrator";
89
- import { AIAgent, AIGNE } from "@aigne/core";
90
- import { OpenAIChatModel } from "@aigne/core/models/openai-chat-model.js";
91
-
92
- const model = new OpenAIChatModel({
93
- apiKey: process.env.OPENAI_API_KEY,
94
- model: "gpt-4-turbo",
95
- });
96
-
97
- // 创建专业子代理
98
- const researchAgent = AIAgent.from({
99
- name: "研究员",
100
- instructions: "你是一位专业研究员,负责收集和分析信息。",
101
- outputKey: "research",
102
- });
103
-
104
- const writerAgent = AIAgent.from({
105
- name: "作家",
106
- instructions: "你是一位专业作家,负责创作高质量内容。",
107
- outputKey: "content",
108
- });
109
-
110
- const editorAgent = AIAgent.from({
111
- name: "编辑",
112
- instructions: "你是一位严格的编辑,负责检查内容质量和格式。",
113
- outputKey: "edited",
114
- });
115
-
116
- // 创建编排代理
117
- const orchestrator = new OrchestratorAgent({
118
- name: "工作流编排器",
119
- instructions: "你负责协调研究、写作和编辑流程。",
120
- skills: [researchAgent, writerAgent, editorAgent],
121
- // 可选配置
122
- maxIterations: 30, // 最大迭代次数
123
- tasksConcurrency: 5, // 任务并发数
124
- });
125
-
126
- // 使用编排代理
127
- const aigne = new AIGNE({ model });
128
- const result = await aigne.invoke(orchestrator, "关于人工智能在医疗领域的应用");
129
-
130
- console.log(result);
131
- ```
132
-
133
- ## 协议
134
-
135
- Elastic-2.0