@aigne/core 1.16.0 → 1.18.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 +37 -16
- package/lib/cjs/agents/agent.d.ts +69 -37
- package/lib/cjs/agents/agent.js +93 -65
- package/lib/cjs/agents/ai-agent.d.ts +4 -7
- package/lib/cjs/agents/ai-agent.js +10 -19
- package/lib/cjs/agents/chat-model.d.ts +7 -8
- package/lib/cjs/agents/chat-model.js +9 -9
- package/lib/cjs/agents/mcp-agent.d.ts +4 -5
- package/lib/cjs/agents/mcp-agent.js +7 -13
- package/lib/cjs/agents/team-agent.d.ts +7 -8
- package/lib/cjs/agents/team-agent.js +10 -10
- package/lib/cjs/agents/user-agent.d.ts +4 -5
- package/lib/cjs/agents/user-agent.js +11 -12
- package/lib/cjs/aigne/aigne.d.ts +10 -9
- package/lib/cjs/aigne/aigne.js +5 -4
- package/lib/cjs/aigne/context.d.ts +18 -9
- package/lib/cjs/aigne/context.js +23 -12
- package/lib/cjs/aigne/message-queue.d.ts +6 -2
- package/lib/cjs/aigne/message-queue.js +2 -2
- package/lib/cjs/index.d.ts +3 -1
- package/lib/cjs/index.js +3 -1
- package/lib/cjs/loader/agent-js.d.ts +1 -1
- package/lib/cjs/loader/agent-yaml.d.ts +3 -2
- package/lib/cjs/loader/agent-yaml.js +3 -2
- package/lib/cjs/loader/index.d.ts +5 -1
- package/lib/cjs/loader/index.js +25 -16
- package/lib/cjs/memory/memory.d.ts +3 -2
- package/lib/cjs/memory/memory.js +1 -1
- package/lib/cjs/memory/retriever.d.ts +2 -2
- package/lib/cjs/prompt/prompt-builder.d.ts +9 -7
- package/lib/cjs/prompt/prompt-builder.js +14 -10
- package/lib/cjs/prompt/template.js +1 -3
- package/lib/cjs/utils/logger.js +3 -3
- package/lib/cjs/utils/nodejs.d.ts +8 -0
- package/lib/cjs/utils/nodejs.js +24 -0
- package/lib/cjs/utils/type-utils.d.ts +2 -2
- package/lib/dts/agents/agent.d.ts +69 -37
- package/lib/dts/agents/ai-agent.d.ts +4 -7
- package/lib/dts/agents/chat-model.d.ts +7 -8
- package/lib/dts/agents/mcp-agent.d.ts +4 -5
- package/lib/dts/agents/team-agent.d.ts +7 -8
- package/lib/dts/agents/user-agent.d.ts +4 -5
- package/lib/dts/aigne/aigne.d.ts +10 -9
- package/lib/dts/aigne/context.d.ts +18 -9
- package/lib/dts/aigne/message-queue.d.ts +6 -2
- package/lib/dts/index.d.ts +3 -1
- package/lib/dts/loader/agent-js.d.ts +1 -1
- package/lib/dts/loader/agent-yaml.d.ts +3 -2
- package/lib/dts/loader/index.d.ts +5 -1
- package/lib/dts/memory/memory.d.ts +3 -2
- package/lib/dts/memory/retriever.d.ts +2 -2
- package/lib/dts/prompt/prompt-builder.d.ts +9 -7
- package/lib/dts/utils/nodejs.d.ts +8 -0
- package/lib/dts/utils/type-utils.d.ts +2 -2
- package/lib/esm/agents/agent.d.ts +69 -37
- package/lib/esm/agents/agent.js +94 -66
- package/lib/esm/agents/ai-agent.d.ts +4 -7
- package/lib/esm/agents/ai-agent.js +10 -19
- package/lib/esm/agents/chat-model.d.ts +7 -8
- package/lib/esm/agents/chat-model.js +9 -9
- package/lib/esm/agents/mcp-agent.d.ts +4 -5
- package/lib/esm/agents/mcp-agent.js +7 -13
- package/lib/esm/agents/team-agent.d.ts +7 -8
- package/lib/esm/agents/team-agent.js +10 -10
- package/lib/esm/agents/user-agent.d.ts +4 -5
- package/lib/esm/agents/user-agent.js +10 -11
- package/lib/esm/aigne/aigne.d.ts +10 -9
- package/lib/esm/aigne/aigne.js +5 -4
- package/lib/esm/aigne/context.d.ts +18 -9
- package/lib/esm/aigne/context.js +24 -10
- package/lib/esm/aigne/message-queue.d.ts +6 -2
- package/lib/esm/aigne/message-queue.js +2 -2
- package/lib/esm/index.d.ts +3 -1
- package/lib/esm/index.js +3 -1
- package/lib/esm/loader/agent-js.d.ts +1 -1
- package/lib/esm/loader/agent-yaml.d.ts +3 -2
- package/lib/esm/loader/agent-yaml.js +3 -2
- package/lib/esm/loader/index.d.ts +5 -1
- package/lib/esm/loader/index.js +25 -16
- package/lib/esm/memory/memory.d.ts +3 -2
- package/lib/esm/memory/memory.js +2 -2
- package/lib/esm/memory/retriever.d.ts +2 -2
- package/lib/esm/prompt/prompt-builder.d.ts +9 -7
- package/lib/esm/prompt/prompt-builder.js +15 -11
- package/lib/esm/prompt/template.js +1 -3
- package/lib/esm/utils/logger.js +3 -3
- package/lib/esm/utils/nodejs.d.ts +8 -0
- package/lib/esm/utils/nodejs.js +21 -0
- package/lib/esm/utils/type-utils.d.ts +2 -2
- package/package.json +4 -3
- package/lib/cjs/memory/default-memory.d.ts +0 -16
- package/lib/cjs/memory/default-memory.js +0 -70
- package/lib/cjs/utils/fs.d.ts +0 -2
- package/lib/cjs/utils/fs.js +0 -25
- package/lib/dts/memory/default-memory.d.ts +0 -16
- package/lib/dts/utils/fs.d.ts +0 -2
- package/lib/esm/memory/default-memory.d.ts +0 -16
- package/lib/esm/memory/default-memory.js +0 -63
- package/lib/esm/utils/fs.d.ts +0 -2
- package/lib/esm/utils/fs.js +0 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
## [1.
|
|
1
|
+
## [1.17.0](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.16.0...core-v1.17.0) (2025-05-25)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Features
|
|
5
5
|
|
|
6
|
-
* add
|
|
7
|
-
* add OrchestratorAgent in agent library ([25a5e9e](https://github.com/AIGNE-io/aigne-framework/commit/25a5e9e6c60d747c8bf484ac884b31dc02c14757))
|
|
8
|
-
* add sequential and parallel helper function ([a295697](https://github.com/AIGNE-io/aigne-framework/commit/a295697b5694754e02954fc5c7f382a3b219a3ab))
|
|
9
|
-
* add support for MCP resources ([1ded2fb](https://github.com/AIGNE-io/aigne-framework/commit/1ded2fbf222fa8984e75df0852ff384524f73b04))
|
|
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
|
-
* **prompt-builder:** support chat history in PromptBuilder ([6ca05f2](https://github.com/AIGNE-io/aigne-framework/commit/6ca05f28eddb683a4f1e228865f8bbf8a8e190f1))
|
|
13
|
-
* support run puppeteer example chat loop in terminal ([85ce7f8](https://github.com/AIGNE-io/aigne-framework/commit/85ce7f8de8b443c86e50815dd7bcab99f869c4ce))
|
|
14
|
-
* use PromptBuilder instead of string instructions ([e4cb2cb](https://github.com/AIGNE-io/aigne-framework/commit/e4cb2cb6baf4f9bcef390567a4a174e9246c29a3))
|
|
6
|
+
* add user context support ([#131](https://github.com/AIGNE-io/aigne-framework/issues/131)) ([4dd9d20](https://github.com/AIGNE-io/aigne-framework/commit/4dd9d20953f6ac33933723db56efd9b44bafeb02))
|
|
15
7
|
|
|
8
|
+
## [1.18.0](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.17.0...core-v1.18.0) (2025-05-29)
|
|
16
9
|
|
|
17
|
-
### Bug Fixes
|
|
18
10
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* add memory agents support for client agent ([#139](https://github.com/AIGNE-io/aigne-framework/issues/139)) ([57044fa](https://github.com/AIGNE-io/aigne-framework/commit/57044fa87b8abcba395cd05f941d6d312ab65764))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Dependencies
|
|
17
|
+
|
|
18
|
+
* The following workspace dependencies were updated
|
|
19
|
+
* dependencies
|
|
20
|
+
* @aigne/platform-helpers bumped to 0.1.0
|
|
24
21
|
|
|
25
22
|
## [1.16.0](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.15.0...core-v1.16.0) (2025-05-23)
|
|
26
23
|
|
|
@@ -201,6 +198,30 @@
|
|
|
201
198
|
|
|
202
199
|
* **core:** use system message as user message for claude model if needed ([#32](https://github.com/AIGNE-io/aigne-framework/issues/32)) ([316a6d5](https://github.com/AIGNE-io/aigne-framework/commit/316a6d51f885cceee4020c24695f6588f6b7425f))
|
|
203
200
|
|
|
201
|
+
## [1.3.0](https://github.com/AIGNE-io/aigne-framework/compare/core-v1.2.0...core-v1.3.0) (2025-03-24)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
### Features
|
|
205
|
+
|
|
206
|
+
* add Agent FunctionAgent AIAgent MCPAgent and ExecutionEngine ([4d2a5a1](https://github.com/AIGNE-io/aigne-framework/commit/4d2a5a1b3366b8f935f50a0937c2da6e49073348))
|
|
207
|
+
* add OrchestratorAgent in agent library ([25a5e9e](https://github.com/AIGNE-io/aigne-framework/commit/25a5e9e6c60d747c8bf484ac884b31dc02c14757))
|
|
208
|
+
* add sequential and parallel helper function ([a295697](https://github.com/AIGNE-io/aigne-framework/commit/a295697b5694754e02954fc5c7f382a3b219a3ab))
|
|
209
|
+
* add support for MCP resources ([1ded2fb](https://github.com/AIGNE-io/aigne-framework/commit/1ded2fbf222fa8984e75df0852ff384524f73b04))
|
|
210
|
+
* **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))
|
|
211
|
+
* **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))
|
|
212
|
+
* **prompt-builder:** support chat history in PromptBuilder ([6ca05f2](https://github.com/AIGNE-io/aigne-framework/commit/6ca05f28eddb683a4f1e228865f8bbf8a8e190f1))
|
|
213
|
+
* support run puppeteer example chat loop in terminal ([85ce7f8](https://github.com/AIGNE-io/aigne-framework/commit/85ce7f8de8b443c86e50815dd7bcab99f869c4ce))
|
|
214
|
+
* use PromptBuilder instead of string instructions ([e4cb2cb](https://github.com/AIGNE-io/aigne-framework/commit/e4cb2cb6baf4f9bcef390567a4a174e9246c29a3))
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
### Bug Fixes
|
|
218
|
+
|
|
219
|
+
* **AIAgent:** should pass both arguments (model generated) and input (user input) to tool ([c49d64e](https://github.com/AIGNE-io/aigne-framework/commit/c49d64ee35f7efd83b0f82f43205bb1c40f999e8))
|
|
220
|
+
* **core:** enforce stricter input/output type checks ([#26](https://github.com/AIGNE-io/aigne-framework/issues/26)) ([ef8cf53](https://github.com/AIGNE-io/aigne-framework/commit/ef8cf53586aff08a809909c56ab2a20f215fa129))
|
|
221
|
+
* **MCP:** catch list resource error treat as empty list ([1885fab](https://github.com/AIGNE-io/aigne-framework/commit/1885fab3585e0dd1467b127e5b47cd0b98282bab))
|
|
222
|
+
* rename @aigne/core-next to @aigne/core ([3a81009](https://github.com/AIGNE-io/aigne-framework/commit/3a8100962c81813217b687ae28e8de604419c622))
|
|
223
|
+
* use text resource from MCP correctly ([8b9eba8](https://github.com/AIGNE-io/aigne-framework/commit/8b9eba83352ec096a2a5d4f410d4c4bde7420bce))
|
|
224
|
+
|
|
204
225
|
## [1.2.0](https://github.com/AIGNE-io/aigne-framework/compare/core-next-v1.1.0...core-next-v1.2.0) (2025-03-18)
|
|
205
226
|
|
|
206
227
|
- chore: release v1.2.0
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { inspect } from "node:util";
|
|
2
1
|
import { ZodObject, type ZodType } from "zod";
|
|
3
|
-
import type { Context } from "../aigne/context.js";
|
|
2
|
+
import type { Context, UserContext } from "../aigne/context.js";
|
|
4
3
|
import type { MessagePayload } from "../aigne/message-queue.js";
|
|
5
|
-
import type { MemoryAgent } from "../memory/memory.js";
|
|
4
|
+
import type { Memory, MemoryAgent } from "../memory/memory.js";
|
|
5
|
+
import type { MemoryRecorderInput } from "../memory/recorder.js";
|
|
6
|
+
import type { MemoryRetrieverInput } from "../memory/retriever.js";
|
|
7
|
+
import { nodejs } from "../utils/nodejs.js";
|
|
6
8
|
import { type Nullish, type PromiseOrValue, type XOr } from "../utils/type-utils.js";
|
|
7
9
|
import type { GuideRailAgent, GuideRailAgentOutput } from "./guide-rail-agent.js";
|
|
8
10
|
import { type TransferAgentOutput } from "./types.js";
|
|
@@ -95,11 +97,29 @@ export interface AgentOptions<I extends Message = Message, O extends Message = M
|
|
|
95
97
|
* One or more memory agents this agent can use
|
|
96
98
|
*/
|
|
97
99
|
memory?: MemoryAgent | MemoryAgent[];
|
|
100
|
+
/**
|
|
101
|
+
* Maximum number of memory items to retrieve
|
|
102
|
+
*/
|
|
103
|
+
maxRetrieveMemoryCount?: number;
|
|
98
104
|
}
|
|
99
105
|
export declare const agentOptionsSchema: ZodObject<{
|
|
100
106
|
[key in keyof AgentOptions]: ZodType<AgentOptions[key]>;
|
|
101
107
|
}>;
|
|
102
|
-
export interface AgentInvokeOptions {
|
|
108
|
+
export interface AgentInvokeOptions<U extends UserContext = UserContext> {
|
|
109
|
+
/**
|
|
110
|
+
* The execution context for the agent
|
|
111
|
+
*
|
|
112
|
+
* The context provides the runtime environment for agent execution, including:
|
|
113
|
+
* - Event emission and subscription management
|
|
114
|
+
* - Inter-agent communication and message passing
|
|
115
|
+
* - Resource usage tracking and limits enforcement
|
|
116
|
+
* - Timeout and status management
|
|
117
|
+
* - Memory and state management across agent invocations
|
|
118
|
+
*
|
|
119
|
+
* Each agent invocation requires a context to coordinate with the broader
|
|
120
|
+
* agent system and maintain proper isolation and resource control.
|
|
121
|
+
*/
|
|
122
|
+
context: Context<U>;
|
|
103
123
|
/**
|
|
104
124
|
* Whether to enable streaming response
|
|
105
125
|
*
|
|
@@ -111,6 +131,8 @@ export interface AgentInvokeOptions {
|
|
|
111
131
|
* and returns the final JSON result
|
|
112
132
|
*/
|
|
113
133
|
streaming?: boolean;
|
|
134
|
+
userContext?: U;
|
|
135
|
+
memories?: Pick<Memory, "content">[];
|
|
114
136
|
}
|
|
115
137
|
/**
|
|
116
138
|
* Agent is the base class for all agents.
|
|
@@ -135,11 +157,24 @@ export interface AgentInvokeOptions {
|
|
|
135
157
|
* {@includeCode ../../test/agents/agent.test.ts#example-custom-agent}
|
|
136
158
|
*/
|
|
137
159
|
export declare abstract class Agent<I extends Message = Message, O extends Message = Message> {
|
|
160
|
+
/**
|
|
161
|
+
* Custom object inspection behavior
|
|
162
|
+
*
|
|
163
|
+
* When using Node.js's util.inspect function to inspect an agent,
|
|
164
|
+
* only the agent's name will be shown, making output more concise
|
|
165
|
+
*
|
|
166
|
+
* @returns Agent name
|
|
167
|
+
*/
|
|
168
|
+
[nodejs.customInspect]: () => string;
|
|
138
169
|
constructor(options?: AgentOptions<I, O>);
|
|
139
170
|
/**
|
|
140
171
|
* List of memories this agent can use
|
|
141
172
|
*/
|
|
142
173
|
readonly memories: MemoryAgent[];
|
|
174
|
+
/**
|
|
175
|
+
* Maximum number of memory items to retrieve
|
|
176
|
+
*/
|
|
177
|
+
maxRetrieveMemoryCount?: number;
|
|
143
178
|
/**
|
|
144
179
|
* Lifecycle hooks for agent processing.
|
|
145
180
|
*
|
|
@@ -278,11 +313,15 @@ export declare abstract class Agent<I extends Message = Message, O extends Messa
|
|
|
278
313
|
/**
|
|
279
314
|
* Check context status to ensure it hasn't timed out
|
|
280
315
|
*
|
|
281
|
-
* @param
|
|
316
|
+
* @param options Invocation options containing context
|
|
282
317
|
* @throws Error if the context has timed out
|
|
283
318
|
*/
|
|
284
319
|
private checkContextStatus;
|
|
285
320
|
private newDefaultContext;
|
|
321
|
+
retrieveMemories(input: Pick<MemoryRetrieverInput, "limit"> & {
|
|
322
|
+
search?: Message | string;
|
|
323
|
+
}, options: Pick<AgentInvokeOptions, "context">): Promise<Pick<Memory, "content">[]>;
|
|
324
|
+
recordMemories(input: MemoryRecorderInput, options: Pick<AgentInvokeOptions, "context">): Promise<void>;
|
|
286
325
|
/**
|
|
287
326
|
* Invoke the agent with regular (non-streaming) response
|
|
288
327
|
*
|
|
@@ -290,7 +329,6 @@ export declare abstract class Agent<I extends Message = Message, O extends Messa
|
|
|
290
329
|
* suitable for scenarios where a complete result is needed at once.
|
|
291
330
|
*
|
|
292
331
|
* @param input Input message to the agent, can be a string or structured object
|
|
293
|
-
* @param context Execution context, providing environment and resource access
|
|
294
332
|
* @param options Invocation options, must set streaming to false or leave unset
|
|
295
333
|
* @returns Final JSON response
|
|
296
334
|
*
|
|
@@ -298,7 +336,7 @@ export declare abstract class Agent<I extends Message = Message, O extends Messa
|
|
|
298
336
|
* Here's an example of invoking an agent with regular mode:
|
|
299
337
|
* {@includeCode ../../test/agents/agent.test.ts#example-invoke}
|
|
300
338
|
*/
|
|
301
|
-
invoke(input: I | string,
|
|
339
|
+
invoke(input: I | string, options?: Partial<AgentInvokeOptions> & {
|
|
302
340
|
streaming?: false;
|
|
303
341
|
}): Promise<O>;
|
|
304
342
|
/**
|
|
@@ -309,7 +347,6 @@ export declare abstract class Agent<I extends Message = Message, O extends Messa
|
|
|
309
347
|
* chat bot typing effects.
|
|
310
348
|
*
|
|
311
349
|
* @param input Input message to the agent, can be a string or structured object
|
|
312
|
-
* @param context Execution context, providing environment and resource access
|
|
313
350
|
* @param options Invocation options, must set streaming to true for this overload
|
|
314
351
|
* @returns Streaming response object
|
|
315
352
|
*
|
|
@@ -317,7 +354,7 @@ export declare abstract class Agent<I extends Message = Message, O extends Messa
|
|
|
317
354
|
* Here's an example of invoking an agent with streaming response:
|
|
318
355
|
* {@includeCode ../../test/agents/agent.test.ts#example-invoke-streaming}
|
|
319
356
|
*/
|
|
320
|
-
invoke(input: I | string,
|
|
357
|
+
invoke(input: I | string, options: Partial<AgentInvokeOptions> & {
|
|
321
358
|
streaming: true;
|
|
322
359
|
}): Promise<AgentResponseStream<O>>;
|
|
323
360
|
/**
|
|
@@ -326,12 +363,11 @@ export declare abstract class Agent<I extends Message = Message, O extends Messa
|
|
|
326
363
|
* Returns either streaming or regular response based on the streaming parameter in options
|
|
327
364
|
*
|
|
328
365
|
* @param input Input message to the agent
|
|
329
|
-
* @param context Execution context
|
|
330
366
|
* @param options Invocation options
|
|
331
367
|
* @returns Agent response (streaming or regular)
|
|
332
368
|
*/
|
|
333
|
-
invoke(input: I | string,
|
|
334
|
-
protected invokeSkill<I extends Message, O extends Message>(skill: Agent<I, O>, input: I,
|
|
369
|
+
invoke(input: I | string, options?: Partial<AgentInvokeOptions>): Promise<AgentResponse<O>>;
|
|
370
|
+
protected invokeSkill<I extends Message, O extends Message>(skill: Agent<I, O>, input: I, options: AgentInvokeOptions): Promise<O>;
|
|
335
371
|
/**
|
|
336
372
|
* Process agent output
|
|
337
373
|
*
|
|
@@ -339,7 +375,7 @@ export declare abstract class Agent<I extends Message = Message, O extends Messa
|
|
|
339
375
|
*
|
|
340
376
|
* @param input Original input message
|
|
341
377
|
* @param output Raw output produced by the agent
|
|
342
|
-
* @param
|
|
378
|
+
* @param options Invocation options
|
|
343
379
|
* @returns Final processed output
|
|
344
380
|
*/
|
|
345
381
|
private processAgentOutput;
|
|
@@ -349,7 +385,7 @@ export declare abstract class Agent<I extends Message = Message, O extends Messa
|
|
|
349
385
|
* Logs error information, triggers failure events, and re-throws the error
|
|
350
386
|
*
|
|
351
387
|
* @param error Caught error
|
|
352
|
-
* @param
|
|
388
|
+
* @param options Invocation options
|
|
353
389
|
*/
|
|
354
390
|
private processAgentError;
|
|
355
391
|
/**
|
|
@@ -358,10 +394,10 @@ export declare abstract class Agent<I extends Message = Message, O extends Messa
|
|
|
358
394
|
* If the context has a maximum invocation limit set, checks if the limit
|
|
359
395
|
* has been exceeded and increments the invocation counter
|
|
360
396
|
*
|
|
361
|
-
* @param context
|
|
397
|
+
* @param options Invocation options containing context and limits
|
|
362
398
|
* @throws Error if maximum invocation limit is exceeded
|
|
363
399
|
*/
|
|
364
|
-
protected checkAgentInvokesUsage(
|
|
400
|
+
protected checkAgentInvokesUsage(options: AgentInvokeOptions): void;
|
|
365
401
|
/**
|
|
366
402
|
* Pre-processing operations before handling input
|
|
367
403
|
*
|
|
@@ -370,9 +406,9 @@ export declare abstract class Agent<I extends Message = Message, O extends Messa
|
|
|
370
406
|
* - Verifying invocation limits
|
|
371
407
|
*
|
|
372
408
|
* @param _ Input message (unused)
|
|
373
|
-
* @param
|
|
409
|
+
* @param options Options for agent invocation
|
|
374
410
|
*/
|
|
375
|
-
protected preprocess(_: I,
|
|
411
|
+
protected preprocess(_: I, options: AgentInvokeOptions): Promise<void>;
|
|
376
412
|
private checkResponseByGuideRails;
|
|
377
413
|
private runGuideRails;
|
|
378
414
|
/**
|
|
@@ -400,10 +436,10 @@ export declare abstract class Agent<I extends Message = Message, O extends Messa
|
|
|
400
436
|
*
|
|
401
437
|
* @param input Input message
|
|
402
438
|
* @param output Output message
|
|
403
|
-
* @param
|
|
439
|
+
* @param options Options for agent invocation
|
|
404
440
|
*/
|
|
405
|
-
protected postprocess(input: I, output: O,
|
|
406
|
-
protected publishToTopics(output: Message,
|
|
441
|
+
protected postprocess(input: I, output: O, options: AgentInvokeOptions): Promise<void>;
|
|
442
|
+
protected publishToTopics(output: Message, options: AgentInvokeOptions): Promise<void>;
|
|
407
443
|
/**
|
|
408
444
|
* Core processing method of the agent, must be implemented in subclasses
|
|
409
445
|
*
|
|
@@ -415,7 +451,7 @@ export declare abstract class Agent<I extends Message = Message, O extends Messa
|
|
|
415
451
|
* - Another agent instance (transfer agent)
|
|
416
452
|
*
|
|
417
453
|
* @param input Input message
|
|
418
|
-
* @param
|
|
454
|
+
* @param options Options for agent invocation
|
|
419
455
|
* @returns Processing result
|
|
420
456
|
*
|
|
421
457
|
* @example
|
|
@@ -434,7 +470,7 @@ export declare abstract class Agent<I extends Message = Message, O extends Messa
|
|
|
434
470
|
* Example of transfer to another agent:
|
|
435
471
|
* {@includeCode ../../test/agents/agent.test.ts#example-process-transfer}
|
|
436
472
|
*/
|
|
437
|
-
abstract process(input: I,
|
|
473
|
+
abstract process(input: I, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<O>>;
|
|
438
474
|
/**
|
|
439
475
|
* Shut down the agent and clean up resources
|
|
440
476
|
*
|
|
@@ -449,15 +485,6 @@ export declare abstract class Agent<I extends Message = Message, O extends Messa
|
|
|
449
485
|
* {@includeCode ../../test/agents/agent.test.ts#example-agent-shutdown-by-using}
|
|
450
486
|
*/
|
|
451
487
|
shutdown(): Promise<void>;
|
|
452
|
-
/**
|
|
453
|
-
* Custom object inspection behavior
|
|
454
|
-
*
|
|
455
|
-
* When using Node.js's util.inspect function to inspect an agent,
|
|
456
|
-
* only the agent's name will be shown, making output more concise
|
|
457
|
-
*
|
|
458
|
-
* @returns Agent name
|
|
459
|
-
*/
|
|
460
|
-
[inspect.custom](): string;
|
|
461
488
|
/**
|
|
462
489
|
* Async dispose method for shutdown the agent
|
|
463
490
|
*
|
|
@@ -484,6 +511,7 @@ export interface AgentHooks<I extends Message = Message, O extends Message = Mes
|
|
|
484
511
|
* @param event Object containing the input message
|
|
485
512
|
*/
|
|
486
513
|
onStart?: (event: {
|
|
514
|
+
context: Context;
|
|
487
515
|
input: I;
|
|
488
516
|
}) => PromiseOrValue<void>;
|
|
489
517
|
/**
|
|
@@ -496,6 +524,7 @@ export interface AgentHooks<I extends Message = Message, O extends Message = Mes
|
|
|
496
524
|
* @param event Object containing the input message and either output or error
|
|
497
525
|
*/
|
|
498
526
|
onEnd?: (event: XOr<{
|
|
527
|
+
context: Context;
|
|
499
528
|
input: I;
|
|
500
529
|
output: O;
|
|
501
530
|
error: Error;
|
|
@@ -509,6 +538,7 @@ export interface AgentHooks<I extends Message = Message, O extends Message = Mes
|
|
|
509
538
|
* @param event Object containing the skill being used and input message
|
|
510
539
|
*/
|
|
511
540
|
onSkillStart?: (event: {
|
|
541
|
+
context: Context;
|
|
512
542
|
skill: Agent;
|
|
513
543
|
input: I;
|
|
514
544
|
}) => PromiseOrValue<void>;
|
|
@@ -522,6 +552,7 @@ export interface AgentHooks<I extends Message = Message, O extends Message = Mes
|
|
|
522
552
|
* @param event Object containing the skill used, input message, and either output or error
|
|
523
553
|
*/
|
|
524
554
|
onSkillEnd?: (event: XOr<{
|
|
555
|
+
context: Context;
|
|
525
556
|
skill: Agent;
|
|
526
557
|
input: I;
|
|
527
558
|
output: O;
|
|
@@ -537,6 +568,7 @@ export interface AgentHooks<I extends Message = Message, O extends Message = Mes
|
|
|
537
568
|
* @param event Object containing the source agent, target agent, and input message
|
|
538
569
|
*/
|
|
539
570
|
onHandoff?: (event: {
|
|
571
|
+
context: Context;
|
|
540
572
|
source: Agent;
|
|
541
573
|
target: Agent;
|
|
542
574
|
input: I;
|
|
@@ -587,7 +619,7 @@ export interface AgentResponseDelta<T> {
|
|
|
587
619
|
}> | Partial<{
|
|
588
620
|
[key: string]: string;
|
|
589
621
|
}>;
|
|
590
|
-
json?: Partial<T | TransferAgentOutput
|
|
622
|
+
json?: Partial<T> | TransferAgentOutput;
|
|
591
623
|
};
|
|
592
624
|
}
|
|
593
625
|
/**
|
|
@@ -619,7 +651,7 @@ export declare function jsonDelta<T extends Message>(jsonDelta: NonNullable<Agen
|
|
|
619
651
|
*
|
|
620
652
|
* @template O Agent output message type
|
|
621
653
|
*/
|
|
622
|
-
export type AgentProcessAsyncGenerator<O extends Message> = AsyncGenerator<AgentResponseChunk<O>, Partial<O | TransferAgentOutput
|
|
654
|
+
export type AgentProcessAsyncGenerator<O extends Message> = AsyncGenerator<AgentResponseChunk<O>, Partial<O> | TransferAgentOutput | undefined | void>;
|
|
623
655
|
/**
|
|
624
656
|
* Result type for agent processing method, can be:
|
|
625
657
|
* - Direct or streaming response
|
|
@@ -709,10 +741,10 @@ export declare class FunctionAgent<I extends Message = Message, O extends Messag
|
|
|
709
741
|
* Process input implementation, calls the configured processing function
|
|
710
742
|
*
|
|
711
743
|
* @param input Input message
|
|
712
|
-
* @param
|
|
744
|
+
* @param options Invocation options
|
|
713
745
|
* @returns Processing result
|
|
714
746
|
*/
|
|
715
|
-
process(input: I,
|
|
747
|
+
process(input: I, options: AgentInvokeOptions): PromiseOrValue<AgentProcessResult<O>>;
|
|
716
748
|
}
|
|
717
749
|
/**
|
|
718
750
|
* Function type for function agents
|
|
@@ -725,4 +757,4 @@ export declare class FunctionAgent<I extends Message = Message, O extends Messag
|
|
|
725
757
|
* @param context Execution context
|
|
726
758
|
* @returns Processing result, can be synchronous or asynchronous
|
|
727
759
|
*/
|
|
728
|
-
export type FunctionAgentFn<I extends Message = any, O extends Message = any> = (input: I,
|
|
760
|
+
export type FunctionAgentFn<I extends Message = any, O extends Message = any> = (input: I, options: AgentInvokeOptions) => PromiseOrValue<AgentProcessResult<O>>;
|