@aigne/core 1.15.0 → 1.17.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 +22 -0
- package/README.md +9 -7
- package/README.zh.md +9 -7
- package/lib/cjs/agents/agent.d.ts +168 -29
- package/lib/cjs/agents/agent.js +152 -56
- package/lib/cjs/agents/ai-agent.d.ts +7 -7
- package/lib/cjs/agents/ai-agent.js +19 -15
- package/lib/{esm/models → cjs/agents}/chat-model.d.ts +29 -19
- package/lib/cjs/{models → agents}/chat-model.js +56 -15
- package/lib/cjs/agents/guide-rail-agent.d.ts +62 -0
- package/lib/cjs/agents/guide-rail-agent.js +14 -0
- package/lib/cjs/agents/mcp-agent.d.ts +3 -4
- package/lib/cjs/agents/mcp-agent.js +11 -11
- 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 -4
- package/lib/cjs/agents/user-agent.js +10 -10
- package/lib/cjs/aigne/aigne.d.ts +13 -11
- package/lib/cjs/aigne/aigne.js +7 -6
- package/lib/cjs/aigne/context.d.ts +19 -8
- package/lib/cjs/aigne/context.js +27 -7
- package/lib/cjs/index.d.ts +2 -1
- package/lib/cjs/index.js +2 -1
- package/lib/cjs/loader/agent-yaml.d.ts +2 -2
- package/lib/cjs/loader/index.d.ts +18 -11
- package/lib/cjs/loader/index.js +8 -27
- package/lib/cjs/memory/default-memory/default-memory-storage/index.d.ts +30 -0
- package/lib/cjs/memory/default-memory/default-memory-storage/index.js +69 -0
- package/lib/cjs/memory/default-memory/default-memory-storage/migrate.d.ts +7 -0
- package/lib/cjs/memory/default-memory/default-memory-storage/migrate.js +53 -0
- package/lib/cjs/memory/default-memory/default-memory-storage/migrations/20250523165801-init.d.ts +7 -0
- package/lib/cjs/memory/default-memory/default-memory-storage/migrations/20250523165801-init.js +33 -0
- package/lib/cjs/memory/default-memory/default-memory-storage/models/memory.d.ts +10 -0
- package/lib/cjs/memory/default-memory/default-memory-storage/models/memory.js +32 -0
- package/lib/cjs/memory/default-memory/index.d.ts +10 -0
- package/lib/cjs/memory/{default-memory.js → default-memory/index.js} +16 -25
- package/lib/cjs/memory/default-memory/storage.d.ts +13 -0
- package/lib/cjs/memory/default-memory/storage.js +6 -0
- 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 +10 -4
- package/lib/cjs/prompt/prompt-builder.js +4 -4
- package/lib/cjs/prompt/template.d.ts +3 -3
- package/lib/cjs/utils/json-schema.js +1 -1
- package/lib/cjs/utils/logger.d.ts +33 -8
- package/lib/cjs/utils/logger.js +63 -5
- package/lib/cjs/utils/model-utils.d.ts +1 -1
- package/lib/cjs/utils/stream-utils.d.ts +3 -1
- package/lib/cjs/utils/stream-utils.js +31 -1
- package/lib/cjs/utils/type-utils.d.ts +7 -2
- package/lib/dts/agents/agent.d.ts +168 -29
- package/lib/dts/agents/ai-agent.d.ts +7 -7
- package/lib/{cjs/models → dts/agents}/chat-model.d.ts +29 -19
- package/lib/dts/agents/guide-rail-agent.d.ts +62 -0
- package/lib/dts/agents/mcp-agent.d.ts +3 -4
- package/lib/dts/agents/team-agent.d.ts +7 -8
- package/lib/dts/agents/user-agent.d.ts +4 -4
- package/lib/dts/aigne/aigne.d.ts +13 -11
- package/lib/dts/aigne/context.d.ts +19 -8
- package/lib/dts/index.d.ts +2 -1
- package/lib/dts/loader/agent-yaml.d.ts +2 -2
- package/lib/dts/loader/index.d.ts +18 -11
- package/lib/dts/memory/default-memory/default-memory-storage/index.d.ts +30 -0
- package/lib/dts/memory/default-memory/default-memory-storage/migrate.d.ts +7 -0
- package/lib/dts/memory/default-memory/default-memory-storage/migrations/20250523165801-init.d.ts +7 -0
- package/lib/dts/memory/default-memory/default-memory-storage/models/memory.d.ts +10 -0
- package/lib/dts/memory/default-memory/index.d.ts +10 -0
- package/lib/dts/memory/default-memory/storage.d.ts +13 -0
- 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 +10 -4
- package/lib/dts/prompt/template.d.ts +3 -3
- package/lib/dts/utils/logger.d.ts +33 -8
- package/lib/dts/utils/model-utils.d.ts +1 -1
- package/lib/dts/utils/stream-utils.d.ts +3 -1
- package/lib/dts/utils/type-utils.d.ts +7 -2
- package/lib/esm/agents/agent.d.ts +168 -29
- package/lib/esm/agents/agent.js +152 -56
- package/lib/esm/agents/ai-agent.d.ts +7 -7
- package/lib/esm/agents/ai-agent.js +18 -14
- package/lib/{dts/models → esm/agents}/chat-model.d.ts +29 -19
- package/lib/esm/{models → agents}/chat-model.js +56 -15
- package/lib/esm/agents/guide-rail-agent.d.ts +62 -0
- package/lib/esm/agents/guide-rail-agent.js +11 -0
- package/lib/esm/agents/mcp-agent.d.ts +3 -4
- package/lib/esm/agents/mcp-agent.js +11 -11
- 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 -4
- package/lib/esm/agents/user-agent.js +10 -10
- package/lib/esm/aigne/aigne.d.ts +13 -11
- package/lib/esm/aigne/aigne.js +7 -6
- package/lib/esm/aigne/context.d.ts +19 -8
- package/lib/esm/aigne/context.js +28 -8
- package/lib/esm/index.d.ts +2 -1
- package/lib/esm/index.js +2 -1
- package/lib/esm/loader/agent-yaml.d.ts +2 -2
- package/lib/esm/loader/index.d.ts +18 -11
- package/lib/esm/loader/index.js +8 -27
- package/lib/esm/memory/default-memory/default-memory-storage/index.d.ts +30 -0
- package/lib/esm/memory/default-memory/default-memory-storage/index.js +64 -0
- package/lib/esm/memory/default-memory/default-memory-storage/migrate.d.ts +7 -0
- package/lib/esm/memory/default-memory/default-memory-storage/migrate.js +16 -0
- package/lib/esm/memory/default-memory/default-memory-storage/migrations/20250523165801-init.d.ts +7 -0
- package/lib/esm/memory/default-memory/default-memory-storage/migrations/20250523165801-init.js +28 -0
- package/lib/esm/memory/default-memory/default-memory-storage/models/memory.d.ts +10 -0
- package/lib/esm/memory/default-memory/default-memory-storage/models/memory.js +29 -0
- package/lib/esm/memory/default-memory/index.d.ts +10 -0
- package/lib/esm/memory/{default-memory.js → default-memory/index.js} +15 -24
- package/lib/esm/memory/default-memory/storage.d.ts +13 -0
- package/lib/esm/memory/default-memory/storage.js +2 -0
- 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 +10 -4
- package/lib/esm/prompt/prompt-builder.js +4 -4
- package/lib/esm/prompt/template.d.ts +3 -3
- package/lib/esm/utils/json-schema.js +1 -1
- package/lib/esm/utils/logger.d.ts +33 -8
- package/lib/esm/utils/logger.js +61 -4
- package/lib/esm/utils/model-utils.d.ts +1 -1
- package/lib/esm/utils/stream-utils.d.ts +3 -1
- package/lib/esm/utils/stream-utils.js +29 -1
- package/lib/esm/utils/type-utils.d.ts +7 -2
- package/package.json +4 -20
- package/lib/cjs/client/client.d.ts +0 -97
- package/lib/cjs/client/client.js +0 -87
- package/lib/cjs/client/index.d.ts +0 -1
- package/lib/cjs/client/index.js +0 -17
- package/lib/cjs/memory/default-memory.d.ts +0 -16
- package/lib/cjs/models/bedrock-chat-model.d.ts +0 -79
- package/lib/cjs/models/bedrock-chat-model.js +0 -303
- package/lib/cjs/models/claude-chat-model.d.ts +0 -114
- package/lib/cjs/models/claude-chat-model.js +0 -317
- package/lib/cjs/models/deepseek-chat-model.d.ts +0 -23
- package/lib/cjs/models/deepseek-chat-model.js +0 -35
- package/lib/cjs/models/gemini-chat-model.d.ts +0 -23
- package/lib/cjs/models/gemini-chat-model.js +0 -35
- package/lib/cjs/models/ollama-chat-model.d.ts +0 -22
- package/lib/cjs/models/ollama-chat-model.js +0 -34
- package/lib/cjs/models/open-router-chat-model.d.ts +0 -22
- package/lib/cjs/models/open-router-chat-model.js +0 -34
- package/lib/cjs/models/openai-chat-model.d.ts +0 -166
- package/lib/cjs/models/openai-chat-model.js +0 -415
- package/lib/cjs/models/xai-chat-model.d.ts +0 -21
- package/lib/cjs/models/xai-chat-model.js +0 -33
- package/lib/cjs/server/error.d.ts +0 -15
- package/lib/cjs/server/error.js +0 -22
- package/lib/cjs/server/index.d.ts +0 -2
- package/lib/cjs/server/index.js +0 -18
- package/lib/cjs/server/server.d.ts +0 -135
- package/lib/cjs/server/server.js +0 -187
- package/lib/dts/client/client.d.ts +0 -97
- package/lib/dts/client/index.d.ts +0 -1
- package/lib/dts/memory/default-memory.d.ts +0 -16
- package/lib/dts/models/bedrock-chat-model.d.ts +0 -79
- package/lib/dts/models/claude-chat-model.d.ts +0 -114
- package/lib/dts/models/deepseek-chat-model.d.ts +0 -23
- package/lib/dts/models/gemini-chat-model.d.ts +0 -23
- package/lib/dts/models/ollama-chat-model.d.ts +0 -22
- package/lib/dts/models/open-router-chat-model.d.ts +0 -22
- package/lib/dts/models/openai-chat-model.d.ts +0 -166
- package/lib/dts/models/xai-chat-model.d.ts +0 -21
- package/lib/dts/server/error.d.ts +0 -15
- package/lib/dts/server/index.d.ts +0 -2
- package/lib/dts/server/server.d.ts +0 -135
- package/lib/esm/client/client.d.ts +0 -97
- package/lib/esm/client/client.js +0 -83
- package/lib/esm/client/index.d.ts +0 -1
- package/lib/esm/client/index.js +0 -1
- package/lib/esm/memory/default-memory.d.ts +0 -16
- package/lib/esm/models/bedrock-chat-model.d.ts +0 -79
- package/lib/esm/models/bedrock-chat-model.js +0 -298
- package/lib/esm/models/claude-chat-model.d.ts +0 -114
- package/lib/esm/models/claude-chat-model.js +0 -310
- package/lib/esm/models/deepseek-chat-model.d.ts +0 -23
- package/lib/esm/models/deepseek-chat-model.js +0 -31
- package/lib/esm/models/gemini-chat-model.d.ts +0 -23
- package/lib/esm/models/gemini-chat-model.js +0 -31
- package/lib/esm/models/ollama-chat-model.d.ts +0 -22
- package/lib/esm/models/ollama-chat-model.js +0 -30
- package/lib/esm/models/open-router-chat-model.d.ts +0 -22
- package/lib/esm/models/open-router-chat-model.js +0 -30
- package/lib/esm/models/openai-chat-model.d.ts +0 -166
- package/lib/esm/models/openai-chat-model.js +0 -405
- package/lib/esm/models/xai-chat-model.d.ts +0 -21
- package/lib/esm/models/xai-chat-model.js +0 -29
- package/lib/esm/server/error.d.ts +0 -15
- package/lib/esm/server/error.js +0 -18
- package/lib/esm/server/index.d.ts +0 -2
- package/lib/esm/server/index.js +0 -2
- package/lib/esm/server/server.d.ts +0 -135
- package/lib/esm/server/server.js +0 -180
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReadableStream } from "node:stream/web";
|
|
2
2
|
import type { Context } from "../aigne/context.js";
|
|
3
3
|
import { type MessagePayload } from "../aigne/message-queue.js";
|
|
4
|
-
import { Agent, type AgentOptions, type AgentProcessResult, type FunctionAgentFn, type Message } from "./agent.js";
|
|
4
|
+
import { Agent, type AgentInvokeOptions, type AgentOptions, type AgentProcessResult, type FunctionAgentFn, type Message } from "./agent.js";
|
|
5
5
|
export interface UserAgentOptions<I extends Message = Message, O extends Message = Message> extends AgentOptions<I, O> {
|
|
6
6
|
context: Context;
|
|
7
7
|
process?: FunctionAgentFn<I, O>;
|
|
@@ -14,14 +14,14 @@ export declare class UserAgent<I extends Message = Message, O extends Message =
|
|
|
14
14
|
private _process?;
|
|
15
15
|
private activeAgent?;
|
|
16
16
|
protected subscribeToTopics(context: Pick<Context, "subscribe">): void;
|
|
17
|
-
protected publishToTopics(output: O,
|
|
17
|
+
protected publishToTopics(output: O, options: AgentInvokeOptions): Promise<void>;
|
|
18
18
|
invoke: Agent<I, O>["invoke"];
|
|
19
|
-
process(input: I,
|
|
19
|
+
process(input: I, options: AgentInvokeOptions): Promise<AgentProcessResult<O>>;
|
|
20
20
|
publish: Context["publish"];
|
|
21
21
|
subscribe: Context["subscribe"];
|
|
22
22
|
unsubscribe: Context["unsubscribe"];
|
|
23
23
|
get stream(): ReadableStream<MessagePayload & {
|
|
24
24
|
topic: string;
|
|
25
25
|
}>;
|
|
26
|
-
protected checkAgentInvokesUsage(
|
|
26
|
+
protected checkAgentInvokesUsage(_options: AgentInvokeOptions): void;
|
|
27
27
|
}
|
package/lib/dts/aigne/aigne.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Agent, type AgentResponse, type AgentResponseStream, type Message } from "../agents/agent.js";
|
|
2
|
+
import { ChatModel } from "../agents/chat-model.js";
|
|
2
3
|
import type { UserAgent } from "../agents/user-agent.js";
|
|
3
|
-
import {
|
|
4
|
-
import { AIGNEContext, type InvokeOptions } from "./context.js";
|
|
4
|
+
import { type LoadOptions } from "../loader/index.js";
|
|
5
|
+
import { AIGNEContext, type Context, type InvokeOptions, type UserContext } from "./context.js";
|
|
5
6
|
import { type MessagePayload, MessageQueue, type MessageQueueListener, type Unsubscribe } from "./message-queue.js";
|
|
6
7
|
import type { ContextLimits } from "./usage.js";
|
|
7
8
|
/**
|
|
@@ -45,7 +46,7 @@ export interface AIGNEOptions {
|
|
|
45
46
|
* Here's an example of how to use AIGNE with streaming response:
|
|
46
47
|
* {@includeCode ../../test/aigne/aigne.test.ts#example-streaming}
|
|
47
48
|
*/
|
|
48
|
-
export declare class AIGNE {
|
|
49
|
+
export declare class AIGNE<U extends UserContext = UserContext> {
|
|
49
50
|
/**
|
|
50
51
|
* Loads an AIGNE instance from a directory containing an aigne.yaml file and agent definitions.
|
|
51
52
|
* This static method provides a convenient way to initialize an AIGNE system from configuration files.
|
|
@@ -54,7 +55,7 @@ export declare class AIGNE {
|
|
|
54
55
|
* @param options - Options to override the loaded configuration.
|
|
55
56
|
* @returns A fully initialized AIGNE instance with configured agents and skills.
|
|
56
57
|
*/
|
|
57
|
-
static load(path: string, options
|
|
58
|
+
static load(path: string, options: AIGNEOptions & Pick<LoadOptions, "models">): Promise<AIGNE>;
|
|
58
59
|
/**
|
|
59
60
|
* Creates a new AIGNE instance with the specified options.
|
|
60
61
|
*
|
|
@@ -110,7 +111,7 @@ export declare class AIGNE {
|
|
|
110
111
|
*
|
|
111
112
|
* @returns A new AIGNEContext instance bound to this AIGNE.
|
|
112
113
|
*/
|
|
113
|
-
newContext(): AIGNEContext;
|
|
114
|
+
newContext(options?: Partial<Context>): AIGNEContext;
|
|
114
115
|
/**
|
|
115
116
|
* Creates a user agent for consistent interactions with a specified agent.
|
|
116
117
|
* This method allows you to create a wrapper around an agent for repeated invocations.
|
|
@@ -133,7 +134,7 @@ export declare class AIGNE {
|
|
|
133
134
|
* @param options.streaming - Must be false to return a response stream
|
|
134
135
|
* @returns A promise resolving to a tuple containing the agent's response and the final active agent
|
|
135
136
|
*/
|
|
136
|
-
invoke<I extends Message, O extends Message>(agent: Agent<I, O>, message: I | string, options: InvokeOptions & {
|
|
137
|
+
invoke<I extends Message, O extends Message>(agent: Agent<I, O>, message: I | string, options: InvokeOptions<U> & {
|
|
137
138
|
returnActiveAgent: true;
|
|
138
139
|
streaming?: false;
|
|
139
140
|
}): Promise<[O, Agent]>;
|
|
@@ -147,7 +148,7 @@ export declare class AIGNE {
|
|
|
147
148
|
* @param options.streaming - Must be true to return a response stream
|
|
148
149
|
* @returns A promise resolving to a tuple containing the agent's response stream and a promise for the final agent
|
|
149
150
|
*/
|
|
150
|
-
invoke<I extends Message, O extends Message>(agent: Agent<I, O>, message: I | string, options: InvokeOptions & {
|
|
151
|
+
invoke<I extends Message, O extends Message>(agent: Agent<I, O>, message: I | string, options: InvokeOptions<U> & {
|
|
151
152
|
returnActiveAgent: true;
|
|
152
153
|
streaming: true;
|
|
153
154
|
}): Promise<[AgentResponseStream<O>, Promise<Agent>]>;
|
|
@@ -164,7 +165,7 @@ export declare class AIGNE {
|
|
|
164
165
|
* Here's a simple example of how to invoke an agent:
|
|
165
166
|
* {@includeCode ../../test/aigne/aigne.test.ts#example-simple}
|
|
166
167
|
*/
|
|
167
|
-
invoke<I extends Message, O extends Message>(agent: Agent<I, O>, message: I | string, options?: InvokeOptions & {
|
|
168
|
+
invoke<I extends Message, O extends Message>(agent: Agent<I, O>, message: I | string, options?: InvokeOptions<U> & {
|
|
168
169
|
returnActiveAgent?: false;
|
|
169
170
|
streaming?: false;
|
|
170
171
|
}): Promise<O>;
|
|
@@ -181,7 +182,7 @@ export declare class AIGNE {
|
|
|
181
182
|
* Here's an example of how to invoke an agent with streaming response:
|
|
182
183
|
* {@includeCode ../../test/aigne/aigne.test.ts#example-streaming}
|
|
183
184
|
*/
|
|
184
|
-
invoke<I extends Message, O extends Message>(agent: Agent<I, O>, message: I | string, options: InvokeOptions & {
|
|
185
|
+
invoke<I extends Message, O extends Message>(agent: Agent<I, O>, message: I | string, options: InvokeOptions<U> & {
|
|
185
186
|
returnActiveAgent?: false;
|
|
186
187
|
streaming: true;
|
|
187
188
|
}): Promise<AgentResponseStream<O>>;
|
|
@@ -195,7 +196,7 @@ export declare class AIGNE {
|
|
|
195
196
|
* @returns Either a UserAgent (when no message provided) or a promise resolving to the agent's response
|
|
196
197
|
* with optional active agent information based on the provided options
|
|
197
198
|
*/
|
|
198
|
-
invoke<I extends Message, O extends Message>(agent: Agent<I, O>, message?: I | string, options?: InvokeOptions): UserAgent<I, O> | Promise<AgentResponse<O> | [AgentResponse<O>, Agent]>;
|
|
199
|
+
invoke<I extends Message, O extends Message>(agent: Agent<I, O>, message?: I | string, options?: InvokeOptions<U>): UserAgent<I, O> | Promise<AgentResponse<O> | [AgentResponse<O>, Agent]>;
|
|
199
200
|
/**
|
|
200
201
|
* Publishes a message to the message queue for inter-agent communication.
|
|
201
202
|
* This method broadcasts a message to all subscribers of the specified topic(s).
|
|
@@ -203,12 +204,13 @@ export declare class AIGNE {
|
|
|
203
204
|
*
|
|
204
205
|
* @param topic - The topic or array of topics to publish the message to
|
|
205
206
|
* @param payload - The message payload to be delivered to subscribers
|
|
207
|
+
* @param options - Optional configuration parameters for the publish operation
|
|
206
208
|
*
|
|
207
209
|
* @example
|
|
208
210
|
* Here's an example of how to publish a message:
|
|
209
211
|
* {@includeCode ../../test/aigne/aigne.test.ts#example-publish-message}
|
|
210
212
|
*/
|
|
211
|
-
publish(topic: string | string[], payload: Omit<MessagePayload, "context"> | Message | string): void;
|
|
213
|
+
publish(topic: string | string[], payload: Omit<MessagePayload, "context"> | Message | string, options?: InvokeOptions<U>): void;
|
|
212
214
|
/**
|
|
213
215
|
* Subscribes to receive the next message on a specific topic.
|
|
214
216
|
* This overload returns a Promise that resolves with the next message published to the topic.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import EventEmitter from "node:events";
|
|
2
2
|
import { Agent, type AgentInvokeOptions, type AgentProcessAsyncGenerator, type AgentResponse, type AgentResponseStream, type Message } from "../agents/agent.js";
|
|
3
|
+
import type { ChatModel } from "../agents/chat-model.js";
|
|
3
4
|
import { UserAgent } from "../agents/user-agent.js";
|
|
4
|
-
import type { ChatModel } from "../models/chat-model.js";
|
|
5
5
|
import { type OmitPropertiesFromArrayFirstElement } from "../utils/type-utils.js";
|
|
6
6
|
import type { Args, Listener, TypedEventEmitter } from "../utils/typed-event-emtter.js";
|
|
7
7
|
import { type MessagePayload, MessageQueue, type MessageQueueListener, type Unsubscribe } from "./message-queue.js";
|
|
@@ -38,19 +38,27 @@ export type ContextEmitEventMap = {
|
|
|
38
38
|
/**
|
|
39
39
|
* @hidden
|
|
40
40
|
*/
|
|
41
|
-
export interface InvokeOptions extends AgentInvokeOptions {
|
|
41
|
+
export interface InvokeOptions<U extends UserContext = UserContext> extends Partial<Omit<AgentInvokeOptions<U>, "context">> {
|
|
42
42
|
returnActiveAgent?: boolean;
|
|
43
43
|
disableTransfer?: boolean;
|
|
44
|
+
sourceAgent?: Agent;
|
|
45
|
+
userContext?: U;
|
|
44
46
|
}
|
|
45
47
|
/**
|
|
46
48
|
* @hidden
|
|
47
49
|
*/
|
|
48
|
-
export interface
|
|
50
|
+
export interface UserContext extends Record<string, unknown> {
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* @hidden
|
|
54
|
+
*/
|
|
55
|
+
export interface Context<U extends UserContext = UserContext> extends TypedEventEmitter<ContextEventMap, ContextEmitEventMap> {
|
|
49
56
|
model?: ChatModel;
|
|
50
57
|
skills?: Agent[];
|
|
51
58
|
usage: ContextUsage;
|
|
52
59
|
limits?: ContextLimits;
|
|
53
60
|
status?: "normal" | "timeout";
|
|
61
|
+
userContext: U;
|
|
54
62
|
/**
|
|
55
63
|
* Create a user agent to consistently invoke an agent
|
|
56
64
|
* @param agent Agent to invoke
|
|
@@ -91,7 +99,7 @@ export interface Context extends TypedEventEmitter<ContextEventMap, ContextEmitE
|
|
|
91
99
|
* @param topic topic name, or an array of topic names
|
|
92
100
|
* @param payload message to publish
|
|
93
101
|
*/
|
|
94
|
-
publish(topic: string | string[], payload: Omit<MessagePayload, "context"> | Message | string): void;
|
|
102
|
+
publish(topic: string | string[], payload: Omit<MessagePayload, "context"> | Message | string, options?: InvokeOptions): void;
|
|
95
103
|
subscribe(topic: string | string[], listener?: undefined): Promise<MessagePayload>;
|
|
96
104
|
subscribe(topic: string | string[], listener: MessageQueueListener): Unsubscribe;
|
|
97
105
|
subscribe(topic: string | string[], listener?: MessageQueueListener): Unsubscribe | Promise<MessagePayload>;
|
|
@@ -113,15 +121,17 @@ export interface Context extends TypedEventEmitter<ContextEventMap, ContextEmitE
|
|
|
113
121
|
* @hidden
|
|
114
122
|
*/
|
|
115
123
|
export declare class AIGNEContext implements Context {
|
|
116
|
-
constructor(parent
|
|
124
|
+
constructor(...[parent, ...args]: ConstructorParameters<typeof AIGNEContextShared>);
|
|
117
125
|
parentId?: string;
|
|
118
126
|
id: string;
|
|
119
|
-
readonly internal:
|
|
127
|
+
readonly internal: AIGNEContextShared;
|
|
120
128
|
get model(): ChatModel | undefined;
|
|
121
129
|
get skills(): Agent<Message, Message>[] | undefined;
|
|
122
130
|
get limits(): ContextLimits | undefined;
|
|
123
131
|
get status(): "normal" | "timeout";
|
|
124
132
|
get usage(): ContextUsage;
|
|
133
|
+
get userContext(): Context["userContext"];
|
|
134
|
+
set userContext(userContext: Context["userContext"]);
|
|
125
135
|
newContext({ reset }?: {
|
|
126
136
|
reset?: boolean;
|
|
127
137
|
}): AIGNEContext;
|
|
@@ -134,17 +144,18 @@ export declare class AIGNEContext implements Context {
|
|
|
134
144
|
once<K extends keyof ContextEventMap>(eventName: K, listener: Listener<K, ContextEventMap>): this;
|
|
135
145
|
off<K extends keyof ContextEventMap>(eventName: K, listener: Listener<K, ContextEventMap>): this;
|
|
136
146
|
}
|
|
137
|
-
declare class
|
|
147
|
+
declare class AIGNEContextShared {
|
|
138
148
|
private readonly parent?;
|
|
139
149
|
constructor(parent?: (Pick<Context, "model" | "skills" | "limits"> & {
|
|
140
150
|
messageQueue?: MessageQueue;
|
|
141
|
-
}) | undefined);
|
|
151
|
+
}) | undefined, overrides?: Partial<Context>);
|
|
142
152
|
readonly messageQueue: MessageQueue;
|
|
143
153
|
readonly events: EventEmitter<ContextEventMap>;
|
|
144
154
|
get model(): ChatModel | undefined;
|
|
145
155
|
get skills(): Agent<Message, Message>[] | undefined;
|
|
146
156
|
get limits(): ContextLimits | undefined;
|
|
147
157
|
usage: ContextUsage;
|
|
158
|
+
userContext: Context["userContext"];
|
|
148
159
|
private abortController;
|
|
149
160
|
private timer?;
|
|
150
161
|
private initTimeout;
|
package/lib/dts/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export * from "./agents/agent.js";
|
|
2
2
|
export * from "./agents/ai-agent.js";
|
|
3
|
+
export * from "./agents/chat-model.js";
|
|
4
|
+
export * from "./agents/guide-rail-agent.js";
|
|
3
5
|
export * from "./agents/mcp-agent.js";
|
|
4
6
|
export * from "./agents/team-agent.js";
|
|
5
7
|
export * from "./agents/types.js";
|
|
6
8
|
export * from "./agents/user-agent.js";
|
|
7
9
|
export * from "./aigne/index.js";
|
|
8
|
-
export * from "./models/chat-model.js";
|
|
9
10
|
export * from "./prompt/prompt-builder.js";
|
|
10
11
|
export * from "./prompt/template.js";
|
|
@@ -14,16 +14,16 @@ export declare function loadAgentFromYamlFile(path: string): Promise<{
|
|
|
14
14
|
}, {
|
|
15
15
|
[x: string]: any;
|
|
16
16
|
}> | undefined;
|
|
17
|
-
toolChoice?: AIAgentToolChoice | undefined;
|
|
18
17
|
outputSchema?: ZodObject<Record<string, ZodType<any, z.ZodTypeDef, any>>, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
19
18
|
[x: string]: any;
|
|
20
19
|
}, {
|
|
21
20
|
[x: string]: any;
|
|
22
21
|
}> | undefined;
|
|
23
22
|
outputKey?: string | undefined;
|
|
23
|
+
toolChoice?: AIAgentToolChoice | undefined;
|
|
24
24
|
} | {
|
|
25
25
|
type: "mcp";
|
|
26
26
|
url?: string | undefined;
|
|
27
|
-
command?: string | undefined;
|
|
28
27
|
args?: string[] | undefined;
|
|
28
|
+
command?: string | undefined;
|
|
29
29
|
}>;
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import type { Camelize } from "camelize-ts";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import { type Agent } from "../agents/agent.js";
|
|
3
|
-
import type { ChatModel, ChatModelOptions } from "../
|
|
4
|
+
import type { ChatModel, ChatModelOptions } from "../agents/chat-model.js";
|
|
4
5
|
export interface LoadOptions {
|
|
6
|
+
models: {
|
|
7
|
+
new (parameters: {
|
|
8
|
+
model?: string;
|
|
9
|
+
modelOptions?: ChatModelOptions;
|
|
10
|
+
}): ChatModel;
|
|
11
|
+
}[];
|
|
5
12
|
path: string;
|
|
6
13
|
}
|
|
7
14
|
export declare function load(options: LoadOptions): Promise<{
|
|
@@ -15,12 +22,12 @@ export declare function load(options: LoadOptions): Promise<{
|
|
|
15
22
|
temperature?: number | null | undefined;
|
|
16
23
|
provider?: string | null | undefined;
|
|
17
24
|
top_p?: number | null | undefined;
|
|
18
|
-
|
|
25
|
+
frequency_penalty?: number | null | undefined;
|
|
19
26
|
presence_penalty?: number | null | undefined;
|
|
20
27
|
} | null | undefined;
|
|
21
28
|
}>;
|
|
22
29
|
export declare function loadAgent(path: string): Promise<Agent>;
|
|
23
|
-
export declare function loadModel(model?: z.infer<typeof aigneFileSchema>["chat_model"]
|
|
30
|
+
export declare function loadModel(models: LoadOptions["models"], model?: Camelize<z.infer<typeof aigneFileSchema>["chat_model"]>, modelOptions?: ChatModelOptions): Promise<ChatModel | undefined>;
|
|
24
31
|
declare const aigneFileSchema: z.ZodObject<{
|
|
25
32
|
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
26
33
|
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -29,35 +36,35 @@ declare const aigneFileSchema: z.ZodObject<{
|
|
|
29
36
|
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
30
37
|
temperature: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
31
38
|
top_p: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
32
|
-
|
|
39
|
+
frequency_penalty: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
33
40
|
presence_penalty: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
34
41
|
}, "strip", z.ZodTypeAny, {
|
|
35
42
|
name?: string | null | undefined;
|
|
36
43
|
temperature?: number | null | undefined;
|
|
37
44
|
provider?: string | null | undefined;
|
|
38
45
|
top_p?: number | null | undefined;
|
|
39
|
-
|
|
46
|
+
frequency_penalty?: number | null | undefined;
|
|
40
47
|
presence_penalty?: number | null | undefined;
|
|
41
48
|
}, {
|
|
42
49
|
name?: string | null | undefined;
|
|
43
50
|
temperature?: number | null | undefined;
|
|
44
51
|
provider?: string | null | undefined;
|
|
45
52
|
top_p?: number | null | undefined;
|
|
46
|
-
|
|
53
|
+
frequency_penalty?: number | null | undefined;
|
|
47
54
|
presence_penalty?: number | null | undefined;
|
|
48
55
|
}>]>>>, {
|
|
49
56
|
name?: string | null | undefined;
|
|
50
57
|
temperature?: number | null | undefined;
|
|
51
58
|
provider?: string | null | undefined;
|
|
52
59
|
top_p?: number | null | undefined;
|
|
53
|
-
|
|
60
|
+
frequency_penalty?: number | null | undefined;
|
|
54
61
|
presence_penalty?: number | null | undefined;
|
|
55
62
|
} | null | undefined, string | {
|
|
56
63
|
name?: string | null | undefined;
|
|
57
64
|
temperature?: number | null | undefined;
|
|
58
65
|
provider?: string | null | undefined;
|
|
59
66
|
top_p?: number | null | undefined;
|
|
60
|
-
|
|
67
|
+
frequency_penalty?: number | null | undefined;
|
|
61
68
|
presence_penalty?: number | null | undefined;
|
|
62
69
|
} | null | undefined>;
|
|
63
70
|
agents: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
|
|
@@ -71,7 +78,7 @@ declare const aigneFileSchema: z.ZodObject<{
|
|
|
71
78
|
temperature?: number | null | undefined;
|
|
72
79
|
provider?: string | null | undefined;
|
|
73
80
|
top_p?: number | null | undefined;
|
|
74
|
-
|
|
81
|
+
frequency_penalty?: number | null | undefined;
|
|
75
82
|
presence_penalty?: number | null | undefined;
|
|
76
83
|
} | null | undefined;
|
|
77
84
|
agents?: string[] | null | undefined;
|
|
@@ -84,7 +91,7 @@ declare const aigneFileSchema: z.ZodObject<{
|
|
|
84
91
|
temperature?: number | null | undefined;
|
|
85
92
|
provider?: string | null | undefined;
|
|
86
93
|
top_p?: number | null | undefined;
|
|
87
|
-
|
|
94
|
+
frequency_penalty?: number | null | undefined;
|
|
88
95
|
presence_penalty?: number | null | undefined;
|
|
89
96
|
} | null | undefined;
|
|
90
97
|
agents?: string[] | null | undefined;
|
|
@@ -98,7 +105,7 @@ export declare function loadAIGNEFile(path: string): Promise<{
|
|
|
98
105
|
temperature?: number | null | undefined;
|
|
99
106
|
provider?: string | null | undefined;
|
|
100
107
|
top_p?: number | null | undefined;
|
|
101
|
-
|
|
108
|
+
frequency_penalty?: number | null | undefined;
|
|
102
109
|
presence_penalty?: number | null | undefined;
|
|
103
110
|
} | null | undefined;
|
|
104
111
|
agents?: string[] | null | undefined;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AgentInvokeOptions } from "../../../agents/agent.js";
|
|
2
|
+
import "sqlite3";
|
|
3
|
+
import { Sequelize } from "sequelize";
|
|
4
|
+
import type { Context } from "../../../aigne/context.js";
|
|
5
|
+
import type { PromiseOrValue } from "../../../utils/type-utils.js";
|
|
6
|
+
import type { Memory } from "../../memory.js";
|
|
7
|
+
import { MemoryStorage } from "../storage.js";
|
|
8
|
+
export interface DefaultMemoryStorageOptions {
|
|
9
|
+
path?: string;
|
|
10
|
+
getSessionId?: (context: Context) => PromiseOrValue<string>;
|
|
11
|
+
}
|
|
12
|
+
export declare class DefaultMemoryStorage extends MemoryStorage {
|
|
13
|
+
options?: DefaultMemoryStorageOptions | undefined;
|
|
14
|
+
memories: {
|
|
15
|
+
[groupId: string]: Memory[];
|
|
16
|
+
};
|
|
17
|
+
constructor(options?: DefaultMemoryStorageOptions | undefined);
|
|
18
|
+
private _models?;
|
|
19
|
+
private get models();
|
|
20
|
+
private convertMemory;
|
|
21
|
+
search(query: {
|
|
22
|
+
limit?: number;
|
|
23
|
+
}, { context }: AgentInvokeOptions): Promise<{
|
|
24
|
+
result: Memory[];
|
|
25
|
+
}>;
|
|
26
|
+
create(memory: Pick<Memory, "content">, { context }: AgentInvokeOptions): Promise<{
|
|
27
|
+
result: Memory;
|
|
28
|
+
}>;
|
|
29
|
+
}
|
|
30
|
+
export declare function initSequelize(path?: string): Sequelize;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Sequelize } from "sequelize";
|
|
2
|
+
import { type MigrateDownOptions, type MigrateUpOptions } from "umzug";
|
|
3
|
+
export declare const migrate: (sequelize: Sequelize, { type, upOptions, downOptions, }?: {
|
|
4
|
+
type?: "up" | "down";
|
|
5
|
+
upOptions?: MigrateUpOptions;
|
|
6
|
+
downOptions?: MigrateDownOptions;
|
|
7
|
+
}) => Promise<void>;
|
package/lib/dts/memory/default-memory/default-memory-storage/migrations/20250523165801-init.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type QueryInterface } from "sequelize";
|
|
2
|
+
export declare const up: ({ context: queryInterface }: {
|
|
3
|
+
context: QueryInterface;
|
|
4
|
+
}) => Promise<void>;
|
|
5
|
+
export declare const down: ({ context: queryInterface }: {
|
|
6
|
+
context: QueryInterface;
|
|
7
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type CreationOptional, type InferAttributes, type InferCreationAttributes, Model } from "sequelize";
|
|
2
|
+
import type { ModelStatic, Sequelize } from "sequelize";
|
|
3
|
+
export interface Memory extends Model<InferAttributes<Memory>, InferCreationAttributes<Memory>> {
|
|
4
|
+
id: CreationOptional<string>;
|
|
5
|
+
createdAt: CreationOptional<Date>;
|
|
6
|
+
updatedAt: CreationOptional<Date>;
|
|
7
|
+
sessionId?: string | null;
|
|
8
|
+
content: unknown;
|
|
9
|
+
}
|
|
10
|
+
export declare function initMemoryModel(sequelize: Sequelize): ModelStatic<Memory>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MemoryAgent, type MemoryAgentOptions } from "../memory.js";
|
|
2
|
+
import { type DefaultMemoryStorageOptions } from "./default-memory-storage/index.js";
|
|
3
|
+
import { MemoryStorage } from "./storage.js";
|
|
4
|
+
export interface DefaultMemoryOptions extends Partial<MemoryAgentOptions> {
|
|
5
|
+
storage?: MemoryStorage | DefaultMemoryStorageOptions;
|
|
6
|
+
}
|
|
7
|
+
export declare class DefaultMemory extends MemoryAgent {
|
|
8
|
+
constructor(options?: DefaultMemoryOptions);
|
|
9
|
+
storage: MemoryStorage;
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { AgentInvokeOptions } from "../../agents/agent.js";
|
|
2
|
+
import type { Memory } from "../memory.js";
|
|
3
|
+
export declare abstract class MemoryStorage {
|
|
4
|
+
abstract create(memory: Pick<Memory, "content">, options: AgentInvokeOptions): Promise<{
|
|
5
|
+
result: Memory;
|
|
6
|
+
}>;
|
|
7
|
+
abstract search(query: {
|
|
8
|
+
search?: string;
|
|
9
|
+
limit?: number;
|
|
10
|
+
}, options: AgentInvokeOptions): Promise<{
|
|
11
|
+
result: Memory[];
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Agent, type AgentOptions, type Message } from "../agents/agent.js";
|
|
1
|
+
import { Agent, type AgentInvokeOptions, type AgentOptions, type Message } from "../agents/agent.js";
|
|
2
2
|
import type { Context } from "../aigne/context.js";
|
|
3
3
|
import type { MessagePayload } from "../aigne/message-queue.js";
|
|
4
4
|
import type { MemoryRecorder, MemoryRecorderInput, MemoryRecorderOutput } from "./recorder.js";
|
|
5
5
|
import type { MemoryRetriever, MemoryRetrieverInput, MemoryRetrieverOutput } from "./retriever.js";
|
|
6
6
|
export interface Memory {
|
|
7
7
|
id: string;
|
|
8
|
+
sessionId?: string | null;
|
|
8
9
|
content: unknown;
|
|
9
10
|
createdAt: string;
|
|
10
11
|
}
|
|
@@ -62,7 +63,7 @@ export declare class MemoryAgent extends Agent {
|
|
|
62
63
|
* MemoryAgent doesn't directly process messages like other agents, so this method
|
|
63
64
|
* throws an error when called. Use the specialized retrieve() and record() methods instead.
|
|
64
65
|
*/
|
|
65
|
-
process(_input: Message,
|
|
66
|
+
process(_input: Message, _options: AgentInvokeOptions): Promise<Message>;
|
|
66
67
|
/**
|
|
67
68
|
* Retrieves memories based on the provided input criteria.
|
|
68
69
|
*
|
|
@@ -39,11 +39,11 @@ export declare const memoryRetrieverInputSchema: z.ZodObject<{
|
|
|
39
39
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
40
40
|
search: z.ZodOptional<z.ZodString>;
|
|
41
41
|
}, "strip", z.ZodTypeAny, {
|
|
42
|
-
limit?: number | undefined;
|
|
43
42
|
search?: string | undefined;
|
|
44
|
-
}, {
|
|
45
43
|
limit?: number | undefined;
|
|
44
|
+
}, {
|
|
46
45
|
search?: string | undefined;
|
|
46
|
+
limit?: number | undefined;
|
|
47
47
|
}>;
|
|
48
48
|
/**
|
|
49
49
|
* @hidden
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import type { GetPromptResult } from "@modelcontextprotocol/sdk/types.js";
|
|
2
2
|
import { Agent, type Message } from "../agents/agent.js";
|
|
3
3
|
import type { AIAgent } from "../agents/ai-agent.js";
|
|
4
|
+
import type { ChatModel, ChatModelInput } from "../agents/chat-model.js";
|
|
4
5
|
import type { Context } from "../aigne/context.js";
|
|
5
6
|
import type { MemoryAgent } from "../memory/memory.js";
|
|
6
|
-
import type { ChatModel, ChatModelInput } from "../models/chat-model.js";
|
|
7
7
|
import { ChatMessagesTemplate } from "./template.js";
|
|
8
8
|
export declare const MESSAGE_KEY = "$message";
|
|
9
|
-
export declare function createMessage<
|
|
9
|
+
export declare function createMessage<V extends Message>(message: string, variables?: V): {
|
|
10
|
+
[MESSAGE_KEY]: string;
|
|
11
|
+
} & typeof variables;
|
|
12
|
+
export declare function createMessage<I extends Message, V extends Message>(message: I, variables?: V): I & typeof variables;
|
|
13
|
+
export declare function createMessage<I extends Message, V extends Message>(message: string | I, variables?: V): ({
|
|
14
|
+
[MESSAGE_KEY]: string;
|
|
15
|
+
} | I) & typeof variables;
|
|
10
16
|
export declare function getMessage(input: Message): string | undefined;
|
|
11
17
|
export interface PromptBuilderOptions {
|
|
12
18
|
instructions?: string | ChatMessagesTemplate;
|
|
13
19
|
}
|
|
14
|
-
export interface
|
|
20
|
+
export interface PromptBuildOptions {
|
|
15
21
|
memory?: MemoryAgent | MemoryAgent[];
|
|
16
22
|
context: Context;
|
|
17
23
|
agent?: AIAgent;
|
|
@@ -32,7 +38,7 @@ export declare class PromptBuilder {
|
|
|
32
38
|
private static fromMCPPromptResult;
|
|
33
39
|
constructor(options?: PromptBuilderOptions);
|
|
34
40
|
instructions?: string | ChatMessagesTemplate;
|
|
35
|
-
build(options:
|
|
41
|
+
build(options: PromptBuildOptions): Promise<ChatModelInput & {
|
|
36
42
|
toolAgents?: Agent[];
|
|
37
43
|
}>;
|
|
38
44
|
private buildMessages;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChatModelInputMessage, ChatModelInputMessageContent, ChatModelOutputToolCall } from "../
|
|
1
|
+
import type { ChatModelInputMessage, ChatModelInputMessageContent, ChatModelOutputToolCall } from "../agents/chat-model.js";
|
|
2
2
|
export declare class PromptTemplate {
|
|
3
3
|
template: string;
|
|
4
4
|
static from(template: string): PromptTemplate;
|
|
@@ -24,7 +24,7 @@ export declare class AgentMessageTemplate extends ChatMessageTemplate {
|
|
|
24
24
|
constructor(content?: ChatModelInputMessage["content"], toolCalls?: ChatModelOutputToolCall[] | undefined, name?: string);
|
|
25
25
|
format(variables?: Record<string, unknown>): {
|
|
26
26
|
toolCalls: ChatModelOutputToolCall[] | undefined;
|
|
27
|
-
role: import("../
|
|
27
|
+
role: import("../agents/chat-model.js").Role;
|
|
28
28
|
content?: ChatModelInputMessageContent;
|
|
29
29
|
toolCallId?: string;
|
|
30
30
|
name?: string;
|
|
@@ -36,7 +36,7 @@ export declare class ToolMessageTemplate extends ChatMessageTemplate {
|
|
|
36
36
|
constructor(content: object | string, toolCallId: string, name?: string);
|
|
37
37
|
format(variables?: Record<string, unknown>): {
|
|
38
38
|
toolCallId: string;
|
|
39
|
-
role: import("../
|
|
39
|
+
role: import("../agents/chat-model.js").Role;
|
|
40
40
|
content?: ChatModelInputMessageContent;
|
|
41
41
|
toolCalls?: {
|
|
42
42
|
id: string;
|
|
@@ -1,8 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
export declare enum LogLevel {
|
|
2
|
+
ERROR = "error",
|
|
3
|
+
WARN = "warn",
|
|
4
|
+
INFO = "info",
|
|
5
|
+
DEBUG = "debug"
|
|
6
|
+
}
|
|
7
|
+
export declare class Logger {
|
|
8
|
+
constructor(options: {
|
|
9
|
+
level: LogLevel;
|
|
10
|
+
ns: string;
|
|
11
|
+
});
|
|
12
|
+
level: LogLevel;
|
|
13
|
+
private debugLogger;
|
|
14
|
+
private infoLogger;
|
|
15
|
+
private warnLogger;
|
|
16
|
+
private errorLogger;
|
|
17
|
+
logMessage: {
|
|
18
|
+
(...data: any[]): void;
|
|
19
|
+
(...data: any[]): void;
|
|
20
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
21
|
+
};
|
|
22
|
+
logError: {
|
|
23
|
+
(...data: any[]): void;
|
|
24
|
+
(...data: any[]): void;
|
|
25
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
26
|
+
};
|
|
27
|
+
debug(message: string, ...args: unknown[]): void;
|
|
28
|
+
info(message: string, ...args: unknown[]): void;
|
|
29
|
+
warn(message: string, ...args: unknown[]): void;
|
|
30
|
+
error(message: string, ...args: unknown[]): void;
|
|
31
|
+
enabled(level: LogLevel): boolean;
|
|
32
|
+
}
|
|
33
|
+
export declare const logger: Logger;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ChatModelOutputUsage } from "../
|
|
1
|
+
import type { ChatModelOutputUsage } from "../agents/chat-model.js";
|
|
2
2
|
import type { Nullish } from "./type-utils.js";
|
|
3
3
|
export declare function mergeUsage(...usages: Nullish<ChatModelOutputUsage>[]): ChatModelOutputUsage;
|
|
@@ -6,7 +6,7 @@ export declare function mergeAgentResponseChunk<T extends Message>(output: T, ch
|
|
|
6
6
|
export declare function agentResponseStreamToObject<T extends Message>(stream: AgentResponseStream<T> | AgentProcessAsyncGenerator<T>): Promise<T>;
|
|
7
7
|
export declare function asyncGeneratorToReadableStream<T extends Message>(generator: AgentProcessAsyncGenerator<T>): AgentResponseStream<T>;
|
|
8
8
|
export declare function onAgentResponseStreamEnd<T extends Message>(stream: AgentResponseStream<T>, callback: (result: T) => PromiseOrValue<Partial<T> | void>, options?: {
|
|
9
|
-
errorCallback?: (error: Error) => Error
|
|
9
|
+
errorCallback?: (error: Error) => PromiseOrValue<Error>;
|
|
10
10
|
processChunk?: (chunk: AgentResponseChunk<T>) => AgentResponseChunk<T>;
|
|
11
11
|
}): ReadableStream<any>;
|
|
12
12
|
export declare function isAsyncGenerator<T extends AsyncGenerator>(value: AsyncGenerator | unknown): value is T;
|
|
@@ -19,3 +19,5 @@ export declare function readableStreamToArray<T>(stream: ReadableStream<T>, opti
|
|
|
19
19
|
catchError?: false;
|
|
20
20
|
}): Promise<T[]>;
|
|
21
21
|
export declare function stringToAgentResponseStream(str: string, key?: "text" | typeof MESSAGE_KEY | string): AgentResponseStream<Message>;
|
|
22
|
+
export declare function toReadableStream(stream: NodeJS.ReadStream): ReadableStream<Uint8Array<ArrayBufferLike>>;
|
|
23
|
+
export declare function readAllString(stream: NodeJS.ReadStream | ReadableStream): Promise<string>;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { type ZodType } from "zod";
|
|
1
|
+
import { type ZodType, z } from "zod";
|
|
2
2
|
export type PromiseOrValue<T> = T | Promise<T>;
|
|
3
3
|
export type Nullish<T> = T | null | undefined | void;
|
|
4
4
|
export type OmitPropertiesFromArrayFirstElement<T extends unknown[], K extends string | number | symbol> = T extends [infer U, ...infer Rest] ? [Omit<U, K>, ...Rest] : never;
|
|
5
|
+
export type XOr<T, K extends keyof T, O extends keyof T> = (Omit<T, O> & {
|
|
6
|
+
[key in O]?: undefined;
|
|
7
|
+
}) | (Omit<T, K> & {
|
|
8
|
+
[key in K]?: undefined;
|
|
9
|
+
});
|
|
5
10
|
export declare function isNil(value: unknown): value is null | undefined;
|
|
6
11
|
export declare function isRecord<T>(value: unknown): value is Record<string, T>;
|
|
7
12
|
export declare function isEmpty(obj: unknown): boolean;
|
|
@@ -15,6 +20,6 @@ export declare function orArrayToArray<T>(value?: T | T[]): T[];
|
|
|
15
20
|
export declare function createAccessorArray<T>(array: T[], accessor: (array: T[], name: string) => T | undefined): T[] & {
|
|
16
21
|
[key: string]: T;
|
|
17
22
|
};
|
|
18
|
-
export declare function checkArguments<T>(prefix: string, schema:
|
|
23
|
+
export declare function checkArguments<T extends ZodType>(prefix: string, schema: T, args: unknown): z.infer<T>;
|
|
19
24
|
export declare function tryOrThrow<P extends PromiseOrValue<unknown>>(fn: () => P, error: string | Error | ((error: Error) => Error)): P;
|
|
20
25
|
export declare function tryOrThrow<P extends PromiseOrValue<unknown>>(fn: () => P, error?: Nullish<string | Error | ((error: Error) => Nullish<Error>)>): P | undefined;
|