@aigne/agent-library 1.2.0 → 1.3.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 CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  - chore: release 1.2.0
4
4
 
5
+ ## [1.3.0](https://github.com/AIGNE-io/aigne-framework/compare/agent-library-v1.2.0...agent-library-v1.3.0) (2025-03-24)
6
+
7
+
8
+ ### Features
9
+
10
+ * **core:** add ChatModelClaude to use models of anthropic ([#30](https://github.com/AIGNE-io/aigne-framework/issues/30)) ([0a62a64](https://github.com/AIGNE-io/aigne-framework/commit/0a62a6499e3da723a4646e67952051708ce7de6a))
11
+ * **core:** add support for subscribing topics for agent memory ([#28](https://github.com/AIGNE-io/aigne-framework/issues/28)) ([eeecc67](https://github.com/AIGNE-io/aigne-framework/commit/eeecc67049a60ebcc4cdba0fbcd987b3d81f4af6))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * rename @aigne/core-next to @aigne/core ([3a81009](https://github.com/AIGNE-io/aigne-framework/commit/3a8100962c81813217b687ae28e8de604419c622))
17
+
5
18
  ## 1.1.0-beta.17 (2025-3-18)
6
19
 
7
20
  - chore: add support for esm module
@@ -1,7 +1,6 @@
1
- import type { AgentOptions, AgentOutput, Context } from "@aigne/core-next";
2
- import type { AgentInput } from "@aigne/core-next";
3
- import { Agent } from "@aigne/core-next";
1
+ import { Agent, type AgentOptions, type Context, type Message } from "@aigne/core";
4
2
  import { type FullPlanOutput, type Step } from "./orchestrator-prompts.js";
3
+ export * from "./orchestrator-prompts.js";
5
4
  export interface StepResult {
6
5
  step: Step;
7
6
  task_results: Array<TaskWithResult>;
@@ -11,23 +10,23 @@ export interface TaskWithResult {
11
10
  agent: string;
12
11
  result: string;
13
12
  }
14
- export interface PlanResult extends AgentOutput {
13
+ export interface PlanResult extends Message {
15
14
  objective: string;
16
15
  plan?: FullPlanOutput;
17
16
  is_complete?: boolean;
18
17
  result?: string;
19
18
  step_results: StepResult[];
20
19
  }
21
- export interface FullPlanInput extends AgentInput {
20
+ export interface FullPlanInput extends Message {
22
21
  objective: string;
23
22
  plan_result: string;
24
23
  agents: string;
25
24
  }
26
- export interface OrchestratorAgentOptions<I extends AgentInput = AgentInput, O extends AgentOutput = AgentOutput> extends AgentOptions<I, O> {
25
+ export interface OrchestratorAgentOptions<I extends Message = Message, O extends Message = Message> extends AgentOptions<I, O> {
27
26
  maxIterations?: number;
28
27
  }
29
- export declare class OrchestratorAgent<I extends AgentInput = AgentInput, O extends AgentOutput = AgentOutput> extends Agent<I, O> {
30
- static from<I extends AgentInput, O extends AgentOutput>(options: OrchestratorAgentOptions<I, O>): OrchestratorAgent<I, O>;
28
+ export declare class OrchestratorAgent<I extends Message = Message, O extends Message = Message> extends Agent<I, O> {
29
+ static from<I extends Message, O extends Message>(options: OrchestratorAgentOptions<I, O>): OrchestratorAgent<I, O>;
31
30
  constructor(options: OrchestratorAgentOptions<I, O>);
32
31
  private planner;
33
32
  private completer;
@@ -1,22 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.OrchestratorAgent = void 0;
4
- const core_next_1 = require("@aigne/core-next");
18
+ const core_1 = require("@aigne/core");
5
19
  const orchestrator_prompts_js_1 = require("./orchestrator-prompts.js");
6
20
  const DEFAULT_MAX_ITERATIONS = 30;
7
- class OrchestratorAgent extends core_next_1.Agent {
21
+ __exportStar(require("./orchestrator-prompts.js"), exports);
22
+ class OrchestratorAgent extends core_1.Agent {
8
23
  static from(options) {
9
24
  return new OrchestratorAgent(options);
10
25
  }
11
26
  constructor(options) {
12
27
  super({ ...options });
13
28
  this.maxIterations = options.maxIterations;
14
- this.planner = new core_next_1.AIAgent({
29
+ this.planner = new core_1.AIAgent({
15
30
  name: "llm_orchestration_planner",
16
31
  instructions: orchestrator_prompts_js_1.FULL_PLAN_PROMPT_TEMPLATE,
17
32
  outputSchema: orchestrator_prompts_js_1.FullPlanSchema,
18
33
  });
19
- this.completer = new core_next_1.AIAgent({
34
+ this.completer = new core_1.AIAgent({
20
35
  name: "llm_orchestration_completer",
21
36
  instructions: orchestrator_prompts_js_1.SYNTHESIZE_PLAN_PROMPT_TEMPLATE,
22
37
  outputSchema: this.outputSchema,
@@ -29,7 +44,7 @@ class OrchestratorAgent extends core_next_1.Agent {
29
44
  const model = context?.model;
30
45
  if (!model)
31
46
  throw new Error("model is required to run OrchestratorAgent");
32
- const objective = (0, core_next_1.getUserInputMessage)(input);
47
+ const objective = (0, core_1.getMessage)(input);
33
48
  if (!objective)
34
49
  throw new Error("Objective is required to run OrchestratorAgent");
35
50
  const result = {
@@ -42,7 +57,7 @@ class OrchestratorAgent extends core_next_1.Agent {
42
57
  const plan = await this.getFullPlan(objective, result, context);
43
58
  result.plan = plan;
44
59
  if (plan.is_complete) {
45
- return this.completer.call({ plan_result: this.formatPlanResult(result) }, context);
60
+ return context.call(this.completer, { plan_result: this.formatPlanResult(result) });
46
61
  }
47
62
  for (const step of plan.steps) {
48
63
  const stepResult = await this.executeStep(result, step, context);
@@ -57,7 +72,11 @@ class OrchestratorAgent extends core_next_1.Agent {
57
72
  Description: ${agent.description}
58
73
  Functions: ${agent.tools.map((tool) => `- ${tool.name} ${tool.description}`).join("\n")}`)
59
74
  .join("\n");
60
- return this.planner.call({ objective, plan_result: this.formatPlanResult(planResult), agents }, context);
75
+ return context.call(this.planner, {
76
+ objective,
77
+ plan_result: this.formatPlanResult(planResult),
78
+ agents,
79
+ });
61
80
  }
62
81
  async executeStep(previousResult, step, context) {
63
82
  const model = context?.model;
@@ -68,21 +87,21 @@ Functions: ${agent.tools.map((tool) => `- ${tool.name} ${tool.description}`).joi
68
87
  const agent = this.tools.find((agent) => agent.name === task.agent);
69
88
  if (!agent)
70
89
  throw new Error(`Agent ${task.agent} not found`);
71
- const prompt = core_next_1.PromptTemplate.from(orchestrator_prompts_js_1.TASK_PROMPT_TEMPLATE).format({
90
+ const prompt = core_1.PromptTemplate.from(orchestrator_prompts_js_1.TASK_PROMPT_TEMPLATE).format({
72
91
  objective: previousResult.objective,
73
92
  task: task.description,
74
93
  context: this.formatPlanResult(previousResult),
75
94
  });
76
95
  let result;
77
96
  if (agent.isCallable) {
78
- result = JSON.stringify(await agent.call(prompt, context));
97
+ result = JSON.stringify(await context.call(agent, prompt));
79
98
  }
80
99
  else {
81
- const executor = core_next_1.AIAgent.from({
100
+ const executor = core_1.AIAgent.from({
82
101
  instructions: prompt,
83
102
  tools: agent.tools,
84
103
  });
85
- result = JSON.stringify(await executor.call({}, context));
104
+ result = JSON.stringify(await context.call(executor, {}));
86
105
  }
87
106
  taskResults.push({ ...task, result });
88
107
  }
@@ -92,7 +111,7 @@ Functions: ${agent.tools.map((tool) => `- ${tool.name} ${tool.description}`).joi
92
111
  };
93
112
  }
94
113
  formatPlanResult(planResult) {
95
- return core_next_1.PromptTemplate.from(orchestrator_prompts_js_1.PLAN_RESULT_TEMPLATE).format({
114
+ return core_1.PromptTemplate.from(orchestrator_prompts_js_1.PLAN_RESULT_TEMPLATE).format({
96
115
  plan_objective: planResult.objective,
97
116
  steps_str: this.formatStepsResults(planResult.step_results),
98
117
  plan_status: planResult.is_complete ? "Complete" : "In Progress",
@@ -104,10 +123,10 @@ Functions: ${agent.tools.map((tool) => `- ${tool.name} ${tool.description}`).joi
104
123
  return "No steps executed yet";
105
124
  return stepResults
106
125
  .map((stepResult, index) => `${index + 1}:\n${stepResult.task_results.length
107
- ? core_next_1.PromptTemplate.from(orchestrator_prompts_js_1.STEP_RESULT_TEMPLATE).format({
126
+ ? core_1.PromptTemplate.from(orchestrator_prompts_js_1.STEP_RESULT_TEMPLATE).format({
108
127
  step_description: stepResult.step.description,
109
128
  tasks_str: stepResult.task_results
110
- .map((task) => `- ${core_next_1.PromptTemplate.from(orchestrator_prompts_js_1.TASK_RESULT_TEMPLATE).format({
129
+ .map((task) => `- ${core_1.PromptTemplate.from(orchestrator_prompts_js_1.TASK_RESULT_TEMPLATE).format({
111
130
  task_description: task.description,
112
131
  task_result: task.result,
113
132
  })}`)
@@ -1,7 +1,6 @@
1
- import type { AgentOptions, AgentOutput, Context } from "@aigne/core-next";
2
- import type { AgentInput } from "@aigne/core-next";
3
- import { Agent } from "@aigne/core-next";
1
+ import { Agent, type AgentOptions, type Context, type Message } from "@aigne/core";
4
2
  import { type FullPlanOutput, type Step } from "./orchestrator-prompts.js";
3
+ export * from "./orchestrator-prompts.js";
5
4
  export interface StepResult {
6
5
  step: Step;
7
6
  task_results: Array<TaskWithResult>;
@@ -11,23 +10,23 @@ export interface TaskWithResult {
11
10
  agent: string;
12
11
  result: string;
13
12
  }
14
- export interface PlanResult extends AgentOutput {
13
+ export interface PlanResult extends Message {
15
14
  objective: string;
16
15
  plan?: FullPlanOutput;
17
16
  is_complete?: boolean;
18
17
  result?: string;
19
18
  step_results: StepResult[];
20
19
  }
21
- export interface FullPlanInput extends AgentInput {
20
+ export interface FullPlanInput extends Message {
22
21
  objective: string;
23
22
  plan_result: string;
24
23
  agents: string;
25
24
  }
26
- export interface OrchestratorAgentOptions<I extends AgentInput = AgentInput, O extends AgentOutput = AgentOutput> extends AgentOptions<I, O> {
25
+ export interface OrchestratorAgentOptions<I extends Message = Message, O extends Message = Message> extends AgentOptions<I, O> {
27
26
  maxIterations?: number;
28
27
  }
29
- export declare class OrchestratorAgent<I extends AgentInput = AgentInput, O extends AgentOutput = AgentOutput> extends Agent<I, O> {
30
- static from<I extends AgentInput, O extends AgentOutput>(options: OrchestratorAgentOptions<I, O>): OrchestratorAgent<I, O>;
28
+ export declare class OrchestratorAgent<I extends Message = Message, O extends Message = Message> extends Agent<I, O> {
29
+ static from<I extends Message, O extends Message>(options: OrchestratorAgentOptions<I, O>): OrchestratorAgent<I, O>;
31
30
  constructor(options: OrchestratorAgentOptions<I, O>);
32
31
  private planner;
33
32
  private completer;
@@ -1,7 +1,6 @@
1
- import type { AgentOptions, AgentOutput, Context } from "@aigne/core-next";
2
- import type { AgentInput } from "@aigne/core-next";
3
- import { Agent } from "@aigne/core-next";
1
+ import { Agent, type AgentOptions, type Context, type Message } from "@aigne/core";
4
2
  import { type FullPlanOutput, type Step } from "./orchestrator-prompts.js";
3
+ export * from "./orchestrator-prompts.js";
5
4
  export interface StepResult {
6
5
  step: Step;
7
6
  task_results: Array<TaskWithResult>;
@@ -11,23 +10,23 @@ export interface TaskWithResult {
11
10
  agent: string;
12
11
  result: string;
13
12
  }
14
- export interface PlanResult extends AgentOutput {
13
+ export interface PlanResult extends Message {
15
14
  objective: string;
16
15
  plan?: FullPlanOutput;
17
16
  is_complete?: boolean;
18
17
  result?: string;
19
18
  step_results: StepResult[];
20
19
  }
21
- export interface FullPlanInput extends AgentInput {
20
+ export interface FullPlanInput extends Message {
22
21
  objective: string;
23
22
  plan_result: string;
24
23
  agents: string;
25
24
  }
26
- export interface OrchestratorAgentOptions<I extends AgentInput = AgentInput, O extends AgentOutput = AgentOutput> extends AgentOptions<I, O> {
25
+ export interface OrchestratorAgentOptions<I extends Message = Message, O extends Message = Message> extends AgentOptions<I, O> {
27
26
  maxIterations?: number;
28
27
  }
29
- export declare class OrchestratorAgent<I extends AgentInput = AgentInput, O extends AgentOutput = AgentOutput> extends Agent<I, O> {
30
- static from<I extends AgentInput, O extends AgentOutput>(options: OrchestratorAgentOptions<I, O>): OrchestratorAgent<I, O>;
28
+ export declare class OrchestratorAgent<I extends Message = Message, O extends Message = Message> extends Agent<I, O> {
29
+ static from<I extends Message, O extends Message>(options: OrchestratorAgentOptions<I, O>): OrchestratorAgent<I, O>;
31
30
  constructor(options: OrchestratorAgentOptions<I, O>);
32
31
  private planner;
33
32
  private completer;
@@ -1,6 +1,7 @@
1
- import { AIAgent, Agent, PromptTemplate, getUserInputMessage } from "@aigne/core-next";
1
+ import { AIAgent, Agent, PromptTemplate, getMessage, } from "@aigne/core";
2
2
  import { FULL_PLAN_PROMPT_TEMPLATE, FullPlanSchema, PLAN_RESULT_TEMPLATE, STEP_RESULT_TEMPLATE, SYNTHESIZE_PLAN_PROMPT_TEMPLATE, TASK_PROMPT_TEMPLATE, TASK_RESULT_TEMPLATE, } from "./orchestrator-prompts.js";
3
3
  const DEFAULT_MAX_ITERATIONS = 30;
4
+ export * from "./orchestrator-prompts.js";
4
5
  export class OrchestratorAgent extends Agent {
5
6
  static from(options) {
6
7
  return new OrchestratorAgent(options);
@@ -26,7 +27,7 @@ export class OrchestratorAgent extends Agent {
26
27
  const model = context?.model;
27
28
  if (!model)
28
29
  throw new Error("model is required to run OrchestratorAgent");
29
- const objective = getUserInputMessage(input);
30
+ const objective = getMessage(input);
30
31
  if (!objective)
31
32
  throw new Error("Objective is required to run OrchestratorAgent");
32
33
  const result = {
@@ -39,7 +40,7 @@ export class OrchestratorAgent extends Agent {
39
40
  const plan = await this.getFullPlan(objective, result, context);
40
41
  result.plan = plan;
41
42
  if (plan.is_complete) {
42
- return this.completer.call({ plan_result: this.formatPlanResult(result) }, context);
43
+ return context.call(this.completer, { plan_result: this.formatPlanResult(result) });
43
44
  }
44
45
  for (const step of plan.steps) {
45
46
  const stepResult = await this.executeStep(result, step, context);
@@ -54,7 +55,11 @@ export class OrchestratorAgent extends Agent {
54
55
  Description: ${agent.description}
55
56
  Functions: ${agent.tools.map((tool) => `- ${tool.name} ${tool.description}`).join("\n")}`)
56
57
  .join("\n");
57
- return this.planner.call({ objective, plan_result: this.formatPlanResult(planResult), agents }, context);
58
+ return context.call(this.planner, {
59
+ objective,
60
+ plan_result: this.formatPlanResult(planResult),
61
+ agents,
62
+ });
58
63
  }
59
64
  async executeStep(previousResult, step, context) {
60
65
  const model = context?.model;
@@ -72,14 +77,14 @@ Functions: ${agent.tools.map((tool) => `- ${tool.name} ${tool.description}`).joi
72
77
  });
73
78
  let result;
74
79
  if (agent.isCallable) {
75
- result = JSON.stringify(await agent.call(prompt, context));
80
+ result = JSON.stringify(await context.call(agent, prompt));
76
81
  }
77
82
  else {
78
83
  const executor = AIAgent.from({
79
84
  instructions: prompt,
80
85
  tools: agent.tools,
81
86
  });
82
- result = JSON.stringify(await executor.call({}, context));
87
+ result = JSON.stringify(await context.call(executor, {}));
83
88
  }
84
89
  taskResults.push({ ...task, result });
85
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/agent-library",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Collection of agent libraries for AIGNE framework",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "zod": "^3.24.2",
36
- "@aigne/core-next": "^1.2.0"
36
+ "@aigne/core": "^1.3.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/bun": "^1.2.5",
@@ -42,11 +42,10 @@
42
42
  "typescript": "^5.8.2"
43
43
  },
44
44
  "scripts": {
45
- "lint": "biome check",
46
- "lint:fix": "biome check --write",
45
+ "lint": "tsc --noEmit",
47
46
  "build": "tsc --build scripts/tsconfig.build.json",
48
47
  "clean": "rimraf lib coverage",
49
48
  "test": "bun test",
50
- "test:coverage": "bun test --coverage --coverage-reporter lcov"
49
+ "test:coverage": "bun test --coverage --coverage-reporter=lcov --coverage-reporter=text"
51
50
  }
52
51
  }