@falai/agent 0.9.0-alpha-2 → 0.9.2
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/README.md +42 -34
- package/dist/cjs/src/core/Agent.d.ts +48 -44
- package/dist/cjs/src/core/Agent.d.ts.map +1 -1
- package/dist/cjs/src/core/Agent.js +151 -1110
- package/dist/cjs/src/core/Agent.js.map +1 -1
- package/dist/cjs/src/core/ResponseModal.d.ts +211 -0
- package/dist/cjs/src/core/ResponseModal.d.ts.map +1 -0
- package/dist/cjs/src/core/ResponseModal.js +1394 -0
- package/dist/cjs/src/core/ResponseModal.js.map +1 -0
- package/dist/cjs/src/core/ResponsePipeline.d.ts +8 -4
- package/dist/cjs/src/core/ResponsePipeline.d.ts.map +1 -1
- package/dist/cjs/src/core/ResponsePipeline.js +48 -20
- package/dist/cjs/src/core/ResponsePipeline.js.map +1 -1
- package/dist/cjs/src/core/Route.d.ts +12 -5
- package/dist/cjs/src/core/Route.d.ts.map +1 -1
- package/dist/cjs/src/core/Route.js +26 -5
- package/dist/cjs/src/core/Route.js.map +1 -1
- package/dist/cjs/src/core/RoutingEngine.d.ts +5 -0
- package/dist/cjs/src/core/RoutingEngine.d.ts.map +1 -1
- package/dist/cjs/src/core/RoutingEngine.js +37 -25
- package/dist/cjs/src/core/RoutingEngine.js.map +1 -1
- package/dist/cjs/src/core/SessionManager.d.ts +9 -1
- package/dist/cjs/src/core/SessionManager.d.ts.map +1 -1
- package/dist/cjs/src/core/SessionManager.js +27 -5
- package/dist/cjs/src/core/SessionManager.js.map +1 -1
- package/dist/cjs/src/core/Step.d.ts +60 -7
- package/dist/cjs/src/core/Step.d.ts.map +1 -1
- package/dist/cjs/src/core/Step.js +151 -4
- package/dist/cjs/src/core/Step.js.map +1 -1
- package/dist/cjs/src/core/ToolManager.d.ts +234 -0
- package/dist/cjs/src/core/ToolManager.d.ts.map +1 -0
- package/dist/cjs/src/core/ToolManager.js +1117 -0
- package/dist/cjs/src/core/ToolManager.js.map +1 -0
- package/dist/cjs/src/index.d.ts +5 -4
- package/dist/cjs/src/index.d.ts.map +1 -1
- package/dist/cjs/src/index.js +11 -3
- package/dist/cjs/src/index.js.map +1 -1
- package/dist/cjs/src/types/agent.d.ts +2 -1
- package/dist/cjs/src/types/agent.d.ts.map +1 -1
- package/dist/cjs/src/types/ai.d.ts +1 -1
- package/dist/cjs/src/types/ai.d.ts.map +1 -1
- package/dist/cjs/src/types/index.d.ts +3 -2
- package/dist/cjs/src/types/index.d.ts.map +1 -1
- package/dist/cjs/src/types/index.js +3 -1
- package/dist/cjs/src/types/index.js.map +1 -1
- package/dist/cjs/src/types/route.d.ts +6 -4
- package/dist/cjs/src/types/route.d.ts.map +1 -1
- package/dist/cjs/src/types/tool.d.ts +84 -14
- package/dist/cjs/src/types/tool.d.ts.map +1 -1
- package/dist/cjs/src/types/tool.js +13 -0
- package/dist/cjs/src/types/tool.js.map +1 -1
- package/dist/cjs/src/utils/clone.d.ts.map +1 -1
- package/dist/cjs/src/utils/clone.js +0 -4
- package/dist/cjs/src/utils/clone.js.map +1 -1
- package/dist/cjs/src/utils/history.d.ts +30 -1
- package/dist/cjs/src/utils/history.d.ts.map +1 -1
- package/dist/cjs/src/utils/history.js +169 -23
- package/dist/cjs/src/utils/history.js.map +1 -1
- package/dist/cjs/src/utils/index.d.ts +1 -1
- package/dist/cjs/src/utils/index.d.ts.map +1 -1
- package/dist/cjs/src/utils/index.js +5 -1
- package/dist/cjs/src/utils/index.js.map +1 -1
- package/dist/src/core/Agent.d.ts +48 -44
- package/dist/src/core/Agent.d.ts.map +1 -1
- package/dist/src/core/Agent.js +152 -1111
- package/dist/src/core/Agent.js.map +1 -1
- package/dist/src/core/ResponseModal.d.ts +211 -0
- package/dist/src/core/ResponseModal.d.ts.map +1 -0
- package/dist/src/core/ResponseModal.js +1389 -0
- package/dist/src/core/ResponseModal.js.map +1 -0
- package/dist/src/core/ResponsePipeline.d.ts +8 -4
- package/dist/src/core/ResponsePipeline.d.ts.map +1 -1
- package/dist/src/core/ResponsePipeline.js +48 -20
- package/dist/src/core/ResponsePipeline.js.map +1 -1
- package/dist/src/core/Route.d.ts +12 -5
- package/dist/src/core/Route.d.ts.map +1 -1
- package/dist/src/core/Route.js +26 -5
- package/dist/src/core/Route.js.map +1 -1
- package/dist/src/core/RoutingEngine.d.ts +5 -0
- package/dist/src/core/RoutingEngine.d.ts.map +1 -1
- package/dist/src/core/RoutingEngine.js +37 -25
- package/dist/src/core/RoutingEngine.js.map +1 -1
- package/dist/src/core/SessionManager.d.ts +9 -1
- package/dist/src/core/SessionManager.d.ts.map +1 -1
- package/dist/src/core/SessionManager.js +27 -5
- package/dist/src/core/SessionManager.js.map +1 -1
- package/dist/src/core/Step.d.ts +60 -7
- package/dist/src/core/Step.d.ts.map +1 -1
- package/dist/src/core/Step.js +151 -4
- package/dist/src/core/Step.js.map +1 -1
- package/dist/src/core/ToolManager.d.ts +234 -0
- package/dist/src/core/ToolManager.d.ts.map +1 -0
- package/dist/src/core/ToolManager.js +1111 -0
- package/dist/src/core/ToolManager.js.map +1 -0
- package/dist/src/index.d.ts +5 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/types/agent.d.ts +2 -1
- package/dist/src/types/agent.d.ts.map +1 -1
- package/dist/src/types/ai.d.ts +1 -1
- package/dist/src/types/ai.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +3 -2
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/index.js +1 -0
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/route.d.ts +6 -4
- package/dist/src/types/route.d.ts.map +1 -1
- package/dist/src/types/tool.d.ts +84 -14
- package/dist/src/types/tool.d.ts.map +1 -1
- package/dist/src/types/tool.js +12 -1
- package/dist/src/types/tool.js.map +1 -1
- package/dist/src/utils/clone.d.ts.map +1 -1
- package/dist/src/utils/clone.js +0 -4
- package/dist/src/utils/clone.js.map +1 -1
- package/dist/src/utils/history.d.ts +30 -1
- package/dist/src/utils/history.d.ts.map +1 -1
- package/dist/src/utils/history.js +165 -23
- package/dist/src/utils/history.js.map +1 -1
- package/dist/src/utils/index.d.ts +1 -1
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/index.js +1 -1
- package/dist/src/utils/index.js.map +1 -1
- package/docs/CONTRIBUTING.md +40 -0
- package/docs/README.md +14 -6
- package/docs/api/README.md +235 -45
- package/docs/api/overview.md +140 -33
- package/docs/core/agent/session-management.md +152 -5
- package/docs/core/ai-integration/response-processing.md +115 -4
- package/docs/core/conversation-flows/routes.md +130 -0
- package/docs/core/error-handling.md +638 -0
- package/docs/core/tools/tool-definition.md +684 -60
- package/docs/core/tools/tool-scoping.md +244 -53
- package/docs/guides/error-handling-patterns.md +578 -0
- package/docs/guides/getting-started/README.md +139 -28
- package/docs/guides/migration/README.md +72 -0
- package/docs/guides/migration/response-modal-refactor.md +518 -0
- package/examples/advanced-patterns/knowledge-based-agent.ts +6 -6
- package/examples/advanced-patterns/persistent-onboarding.ts +30 -43
- package/examples/advanced-patterns/streaming-responses.ts +169 -96
- package/examples/ai-providers/anthropic-integration.ts +9 -5
- package/examples/ai-providers/openai-integration.ts +11 -7
- package/examples/core-concepts/basic-agent.ts +106 -67
- package/examples/core-concepts/modern-streaming-api.ts +309 -0
- package/examples/core-concepts/schema-driven-extraction.ts +10 -7
- package/examples/core-concepts/session-management.ts +71 -18
- package/examples/integrations/healthcare-integration.ts +15 -29
- package/examples/integrations/server-session-management.ts +3 -3
- package/examples/persistence/memory-sessions.ts +3 -3
- package/examples/tools/basic-tools.ts +293 -89
- package/examples/tools/data-enrichment-tools.ts +185 -75
- package/package.json +1 -1
- package/src/core/Agent.ts +190 -1529
- package/src/core/ResponseModal.ts +1798 -0
- package/src/core/ResponsePipeline.ts +83 -57
- package/src/core/Route.ts +39 -12
- package/src/core/RoutingEngine.ts +46 -42
- package/src/core/SessionManager.ts +39 -7
- package/src/core/Step.ts +198 -20
- package/src/core/ToolManager.ts +1394 -0
- package/src/index.ts +19 -3
- package/src/types/agent.ts +2 -1
- package/src/types/ai.ts +1 -1
- package/src/types/index.ts +13 -2
- package/src/types/route.ts +6 -4
- package/src/types/tool.ts +116 -25
- package/src/utils/clone.ts +6 -8
- package/src/utils/history.ts +190 -27
- package/src/utils/index.ts +4 -0
- package/dist/cjs/src/core/ToolExecutor.d.ts +0 -45
- package/dist/cjs/src/core/ToolExecutor.d.ts.map +0 -1
- package/dist/cjs/src/core/ToolExecutor.js +0 -84
- package/dist/cjs/src/core/ToolExecutor.js.map +0 -1
- package/dist/src/core/ToolExecutor.d.ts +0 -45
- package/dist/src/core/ToolExecutor.d.ts.map +0 -1
- package/dist/src/core/ToolExecutor.js +0 -80
- package/dist/src/core/ToolExecutor.js.map +0 -1
- package/docs/core/tools/tool-execution.md +0 -815
- package/src/core/ToolExecutor.ts +0 -126
package/README.md
CHANGED
|
@@ -185,7 +185,7 @@ const agent = new Agent({
|
|
|
185
185
|
name: "Assistant",
|
|
186
186
|
description: "A helpful assistant",
|
|
187
187
|
provider: new GeminiProvider({
|
|
188
|
-
apiKey: process.env.GEMINI_API_KEY
|
|
188
|
+
apiKey: process.env.GEMINI_API_KEY!,
|
|
189
189
|
model: "models/gemini-2.5-flash",
|
|
190
190
|
}),
|
|
191
191
|
});
|
|
@@ -216,44 +216,41 @@ console.log(response.message);
|
|
|
216
216
|
|
|
217
217
|
## 🔧 Advanced Step Configuration
|
|
218
218
|
|
|
219
|
-
###
|
|
219
|
+
### Simple Tool Creation
|
|
220
220
|
|
|
221
|
-
|
|
221
|
+
Create tools with minimal boilerplate using the unified Tool interface:
|
|
222
222
|
|
|
223
223
|
```typescript
|
|
224
|
-
//
|
|
225
|
-
|
|
224
|
+
// Create a simple tool with the unified interface
|
|
225
|
+
agent.addTool({
|
|
226
226
|
id: "validate_user",
|
|
227
|
+
name: "User Data Validator",
|
|
227
228
|
description: "Validate user data before processing",
|
|
228
229
|
parameters: { type: "object", properties: {} },
|
|
229
|
-
handler: ({ context, data }) => {
|
|
230
|
-
// Validation logic
|
|
230
|
+
handler: async ({ context, data, updateData }) => {
|
|
231
|
+
// Validation logic with helper methods
|
|
231
232
|
if (!data.email?.includes("@")) {
|
|
232
233
|
throw new Error("Invalid email address");
|
|
233
234
|
}
|
|
234
|
-
|
|
235
|
+
|
|
236
|
+
// Mark as validated using helper method
|
|
237
|
+
await updateData({ emailValidated: true });
|
|
238
|
+
|
|
239
|
+
return "User validation completed successfully";
|
|
235
240
|
},
|
|
236
|
-
};
|
|
241
|
+
});
|
|
237
242
|
|
|
238
|
-
// Use tools in step lifecycle
|
|
243
|
+
// Use tools in conversation flows and step lifecycle
|
|
239
244
|
agent.createRoute({
|
|
240
245
|
title: "User Registration",
|
|
241
|
-
schema: {
|
|
242
|
-
/* ... */
|
|
243
|
-
},
|
|
244
246
|
steps: [
|
|
245
247
|
{
|
|
246
248
|
id: "collect_info",
|
|
247
249
|
description: "Collect user information",
|
|
248
250
|
collect: ["name", "email"],
|
|
249
251
|
prompt: "Please provide your name and email.",
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
{
|
|
253
|
-
id: "send_welcome",
|
|
254
|
-
description: "Send welcome email",
|
|
255
|
-
prompt: "Welcome! Check your email for confirmation.",
|
|
256
|
-
prepare: "send_welcome_email", // Tool ID string - sends email before AI responds
|
|
252
|
+
prepare: "validate_user", // Tool executes before AI response
|
|
253
|
+
tools: ["validate_user"], // Tool available during conversation
|
|
257
254
|
},
|
|
258
255
|
],
|
|
259
256
|
});
|
|
@@ -261,10 +258,11 @@ agent.createRoute({
|
|
|
261
258
|
|
|
262
259
|
**Benefits:**
|
|
263
260
|
|
|
264
|
-
- ✅ **
|
|
265
|
-
- ✅ **
|
|
266
|
-
- ✅ **
|
|
267
|
-
- ✅ **
|
|
261
|
+
- ✅ **Simple API** - Unified Tool interface with minimal complexity
|
|
262
|
+
- ✅ **Type Safety** - Full TypeScript support with automatic inference
|
|
263
|
+
- ✅ **Flexible Returns** - Return simple values or complex ToolResult objects
|
|
264
|
+
- ✅ **Helper Methods** - Built-in context and data update utilities
|
|
265
|
+
- ✅ **Lifecycle Integration** - Use tools as prepare/finalize hooks in steps
|
|
268
266
|
|
|
269
267
|
---
|
|
270
268
|
|
|
@@ -278,7 +276,6 @@ import {
|
|
|
278
276
|
OpenAIProvider,
|
|
279
277
|
createMessageEvent,
|
|
280
278
|
EventSource,
|
|
281
|
-
type Tool,
|
|
282
279
|
} from "@falai/agent";
|
|
283
280
|
|
|
284
281
|
// 1️⃣ Define the data you want to collect
|
|
@@ -320,18 +317,29 @@ const agent = new Agent<{}, HotelBookingData>({
|
|
|
320
317
|
}
|
|
321
318
|
});
|
|
322
319
|
|
|
323
|
-
// 3️⃣ Define a tool
|
|
324
|
-
|
|
320
|
+
// 3️⃣ Define a tool using the unified Tool interface
|
|
321
|
+
agent.addTool({
|
|
325
322
|
id: "book_hotel",
|
|
323
|
+
name: "Hotel Booking System",
|
|
326
324
|
description: "Books a hotel once all information is collected.",
|
|
327
325
|
parameters: { type: "object", properties: {} },
|
|
328
|
-
handler: ({ data }) => {
|
|
329
|
-
// Tool receives complete agent data
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
326
|
+
handler: async ({ context, data, updateContext }) => {
|
|
327
|
+
// Tool receives complete agent data with simplified context and helper methods
|
|
328
|
+
const bookingId = await hotelAPI.createBooking({
|
|
329
|
+
hotel: data.hotelName,
|
|
330
|
+
date: data.date,
|
|
331
|
+
guests: data.guests,
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
// Use helper method to update context
|
|
335
|
+
await updateContext({
|
|
336
|
+
lastBookingId: bookingId,
|
|
337
|
+
lastBookingDate: new Date().toISOString(),
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
return `Booking confirmed! Confirmation #${bookingId} for ${data.guests} guests at ${data.hotelName} on ${data.date}`;
|
|
333
341
|
},
|
|
334
|
-
};
|
|
342
|
+
});
|
|
335
343
|
|
|
336
344
|
// 4️⃣ Create a route with required fields specification
|
|
337
345
|
agent.createRoute({
|
|
@@ -369,7 +377,7 @@ agent.createRoute({
|
|
|
369
377
|
id: "confirm_booking",
|
|
370
378
|
description: "Confirm and book the hotel",
|
|
371
379
|
prompt: "Let me confirm your booking details.",
|
|
372
|
-
tools: [
|
|
380
|
+
tools: ["book_hotel"], // Reference tool by ID
|
|
373
381
|
requires: ["hotelName", "date", "guests"],
|
|
374
382
|
},
|
|
375
383
|
],
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Core Agent implementation
|
|
3
3
|
*/
|
|
4
|
-
import type { AgentOptions, Term, Guideline, Tool, Event, RouteOptions, SessionState, Template,
|
|
4
|
+
import type { AgentOptions, Term, Guideline, Tool, Event, RouteOptions, SessionState, Template, AgentResponseStreamChunk, AgentResponse, StructuredSchema, ValidationResult } from "../types";
|
|
5
|
+
import type { StreamOptions, GenerateOptions, RespondParams } from "./ResponseModal";
|
|
5
6
|
import { Route } from "./Route";
|
|
7
|
+
import { Step } from "./Step";
|
|
6
8
|
import { PersistenceManager } from "./PersistenceManager";
|
|
7
9
|
import { SessionManager } from "./SessionManager";
|
|
10
|
+
import { RoutingEngine } from "./RoutingEngine";
|
|
11
|
+
import { ToolManager } from "./ToolManager";
|
|
8
12
|
/**
|
|
9
13
|
* Main Agent class with generic context and data support
|
|
10
14
|
*/
|
|
@@ -17,14 +21,15 @@ export declare class Agent<TContext = any, TData = any> {
|
|
|
17
21
|
private context;
|
|
18
22
|
private persistenceManager;
|
|
19
23
|
private routingEngine;
|
|
20
|
-
private
|
|
21
|
-
private responsePipeline;
|
|
24
|
+
private responseModal;
|
|
22
25
|
private currentSession?;
|
|
23
26
|
private knowledgeBase;
|
|
24
27
|
private schema?;
|
|
25
28
|
private collectedData;
|
|
26
29
|
/** Public session manager for easy session management */
|
|
27
30
|
session: SessionManager<TData>;
|
|
31
|
+
/** Public tool manager for simplified tool creation and management */
|
|
32
|
+
tool: ToolManager<TContext, TData>;
|
|
28
33
|
constructor(options: AgentOptions<TContext, TData>);
|
|
29
34
|
/**
|
|
30
35
|
* Validate the agent-level schema structure
|
|
@@ -78,13 +83,19 @@ export declare class Agent<TContext = any, TData = any> {
|
|
|
78
83
|
*/
|
|
79
84
|
createGuideline(guideline: Guideline<TContext, TData>): this;
|
|
80
85
|
/**
|
|
81
|
-
*
|
|
86
|
+
* Add a tool to the agent using the unified Tool interface
|
|
87
|
+
* Creates and adds the tool to agent scope in one operation (BREAKING CHANGE: replaces createTool)
|
|
82
88
|
*/
|
|
83
|
-
|
|
89
|
+
addTool<TResult = any>(tool: Tool<TContext, TData, TResult>): this;
|
|
90
|
+
/**
|
|
91
|
+
* Register a tool at the agent level (legacy method for backward compatibility)
|
|
92
|
+
* @deprecated Use addTool() with Tool interface instead
|
|
93
|
+
*/
|
|
94
|
+
createTool<TResult = any>(tool: Tool<TContext, TData, TResult>): this;
|
|
84
95
|
/**
|
|
85
96
|
* Register multiple tools at the agent level
|
|
86
97
|
*/
|
|
87
|
-
registerTools(tools: Tool<TContext, TData,
|
|
98
|
+
registerTools<TResult = any>(tools: Tool<TContext, TData, TResult>[]): this;
|
|
88
99
|
/**
|
|
89
100
|
* Update the agent's context
|
|
90
101
|
* Triggers both agent-level and route-specific onContextUpdate lifecycle hooks if configured
|
|
@@ -107,51 +118,38 @@ export declare class Agent<TContext = any, TData = any> {
|
|
|
107
118
|
/**
|
|
108
119
|
* Generate a response based on history and context as a stream
|
|
109
120
|
*/
|
|
110
|
-
respondStream(params:
|
|
111
|
-
history: History;
|
|
112
|
-
step?: StepRef;
|
|
113
|
-
session?: SessionState<TData>;
|
|
114
|
-
contextOverride?: Partial<TContext>;
|
|
115
|
-
signal?: AbortSignal;
|
|
116
|
-
}): AsyncGenerator<AgentResponseStreamChunk<TData>>;
|
|
121
|
+
respondStream(params: RespondParams<TContext, TData>): AsyncGenerator<AgentResponseStreamChunk<TData>>;
|
|
117
122
|
/**
|
|
118
123
|
* Generate a response based on history and context
|
|
119
124
|
*/
|
|
120
|
-
respond(params:
|
|
121
|
-
history: History;
|
|
122
|
-
step?: StepRef;
|
|
123
|
-
session?: SessionState<TData>;
|
|
124
|
-
contextOverride?: Partial<TContext>;
|
|
125
|
-
signal?: AbortSignal;
|
|
126
|
-
}): Promise<AgentResponse<TData>>;
|
|
125
|
+
respond(params: RespondParams<TContext, TData>): Promise<AgentResponse<TData>>;
|
|
127
126
|
/**
|
|
128
127
|
* Get all routes
|
|
129
128
|
*/
|
|
130
129
|
getRoutes(): Route<TContext, TData>[];
|
|
131
130
|
/**
|
|
132
|
-
* Get
|
|
131
|
+
* Get agent options
|
|
132
|
+
* @internal Used by ResponseModal
|
|
133
133
|
*/
|
|
134
|
-
|
|
134
|
+
getAgentOptions(): AgentOptions<TContext, TData>;
|
|
135
135
|
/**
|
|
136
|
-
* Get
|
|
136
|
+
* Get routing engine
|
|
137
|
+
* @internal Used by ResponseModal
|
|
137
138
|
*/
|
|
138
|
-
|
|
139
|
+
getRoutingEngine(): RoutingEngine<TContext, TData>;
|
|
139
140
|
/**
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
* @private
|
|
141
|
+
* Get the updateData method bound to this agent
|
|
142
|
+
* @internal Used by ResponseModal
|
|
143
143
|
*/
|
|
144
|
-
|
|
144
|
+
getUpdateDataMethod(): (session: SessionState<TData>, dataUpdate: Partial<TData>) => Promise<SessionState<TData>>;
|
|
145
145
|
/**
|
|
146
|
-
*
|
|
147
|
-
* @private
|
|
146
|
+
* Get all terms
|
|
148
147
|
*/
|
|
149
|
-
|
|
148
|
+
getTerms(): Term<TContext, TData>[];
|
|
150
149
|
/**
|
|
151
|
-
*
|
|
152
|
-
* @private
|
|
150
|
+
* Get all tools
|
|
153
151
|
*/
|
|
154
|
-
|
|
152
|
+
getTools(): Tool<TContext, TData>[];
|
|
155
153
|
/**
|
|
156
154
|
* Get all guidelines
|
|
157
155
|
*/
|
|
@@ -160,11 +158,6 @@ export declare class Agent<TContext = any, TData = any> {
|
|
|
160
158
|
* Get the agent's knowledge base
|
|
161
159
|
*/
|
|
162
160
|
getKnowledgeBase(): Record<string, unknown>;
|
|
163
|
-
/**
|
|
164
|
-
* Merge terms with route-specific taking precedence on conflicts
|
|
165
|
-
* @private
|
|
166
|
-
*/
|
|
167
|
-
private mergeTerms;
|
|
168
161
|
/**
|
|
169
162
|
* Get the persistence manager (if configured)
|
|
170
163
|
*/
|
|
@@ -182,10 +175,20 @@ export declare class Agent<TContext = any, TData = any> {
|
|
|
182
175
|
* Get the current session (if set)
|
|
183
176
|
*/
|
|
184
177
|
getCurrentSession(): SessionState | undefined;
|
|
178
|
+
/**
|
|
179
|
+
* Execute a prepare or finalize function/tool
|
|
180
|
+
* @internal Used by ResponseModal
|
|
181
|
+
*/
|
|
182
|
+
executePrepareFinalize(prepareOrFinalize: string | Tool<TContext, TData> | ((context: TContext, data?: Partial<TData>) => void | Promise<void>) | undefined, context: TContext, data?: Partial<TData>, route?: Route<TContext, TData>, step?: Step<TContext, TData>): Promise<void>;
|
|
185
183
|
/**
|
|
186
184
|
* Clear the current session
|
|
187
185
|
*/
|
|
188
186
|
clearCurrentSession(): void;
|
|
187
|
+
/**
|
|
188
|
+
* Sync session data to agent collected data
|
|
189
|
+
* @internal Used to keep agent and session data in sync
|
|
190
|
+
*/
|
|
191
|
+
private syncSessionDataToCollectedData;
|
|
189
192
|
/**
|
|
190
193
|
* Get collected data from current session or agent-level collected data
|
|
191
194
|
* @param routeId - Optional route ID to get data for (uses current route if not provided)
|
|
@@ -214,10 +217,11 @@ export declare class Agent<TContext = any, TData = any> {
|
|
|
214
217
|
* Simplified respond method using SessionManager
|
|
215
218
|
* Automatically manages conversation history through the session
|
|
216
219
|
*/
|
|
217
|
-
chat(message?: string, options?:
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
chat(message?: string, options?: GenerateOptions<TContext>): Promise<AgentResponse<TData>>;
|
|
221
|
+
/**
|
|
222
|
+
* Modern streaming API - simple interface like chat() but returns a stream
|
|
223
|
+
* Automatically manages conversation history through the session
|
|
224
|
+
*/
|
|
225
|
+
stream(message?: string, options?: StreamOptions<TContext>): AsyncGenerator<AgentResponseStreamChunk<TData>>;
|
|
222
226
|
}
|
|
223
227
|
//# sourceMappingURL=Agent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Agent.d.ts","sourceRoot":"","sources":["../../../../src/core/Agent.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,KAAK,EACL,YAAY,EACZ,YAAY,
|
|
1
|
+
{"version":3,"file":"Agent.d.ts","sourceRoot":"","sources":["../../../../src/core/Agent.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,KAAK,EACL,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,wBAAwB,EACxB,aAAa,EACb,gBAAgB,EAEhB,gBAAgB,EAEjB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAQrF,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAsB5C;;GAEG;AAEH,qBAAa,KAAK,CAAC,QAAQ,GAAG,GAAG,EAAE,KAAK,GAAG,GAAG;IAoBhC,OAAO,CAAC,QA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