@falai/agent 1.1.0 → 1.1.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/dist/adapters/MemoryAdapter.d.ts.map +1 -1
- package/dist/adapters/MemoryAdapter.js +2 -1
- package/dist/adapters/MemoryAdapter.js.map +1 -1
- package/dist/adapters/MongoAdapter.d.ts.map +1 -1
- package/dist/adapters/MongoAdapter.js +2 -1
- package/dist/adapters/MongoAdapter.js.map +1 -1
- package/dist/adapters/OpenSearchAdapter.d.ts.map +1 -1
- package/dist/adapters/OpenSearchAdapter.js +2 -1
- package/dist/adapters/OpenSearchAdapter.js.map +1 -1
- package/dist/adapters/PostgreSQLAdapter.d.ts.map +1 -1
- package/dist/adapters/PostgreSQLAdapter.js +2 -1
- package/dist/adapters/PostgreSQLAdapter.js.map +1 -1
- package/dist/adapters/PrismaAdapter.d.ts.map +1 -1
- package/dist/adapters/PrismaAdapter.js +2 -1
- package/dist/adapters/PrismaAdapter.js.map +1 -1
- package/dist/adapters/RedisAdapter.d.ts.map +1 -1
- package/dist/adapters/RedisAdapter.js.map +1 -1
- package/dist/adapters/SQLiteAdapter.d.ts.map +1 -1
- package/dist/adapters/SQLiteAdapter.js.map +1 -1
- package/dist/cjs/adapters/MemoryAdapter.d.ts.map +1 -1
- package/dist/cjs/adapters/MemoryAdapter.js +2 -1
- package/dist/cjs/adapters/MemoryAdapter.js.map +1 -1
- package/dist/cjs/adapters/MongoAdapter.d.ts.map +1 -1
- package/dist/cjs/adapters/MongoAdapter.js +2 -1
- package/dist/cjs/adapters/MongoAdapter.js.map +1 -1
- package/dist/cjs/adapters/OpenSearchAdapter.d.ts.map +1 -1
- package/dist/cjs/adapters/OpenSearchAdapter.js +2 -1
- package/dist/cjs/adapters/OpenSearchAdapter.js.map +1 -1
- package/dist/cjs/adapters/PostgreSQLAdapter.d.ts.map +1 -1
- package/dist/cjs/adapters/PostgreSQLAdapter.js +2 -1
- package/dist/cjs/adapters/PostgreSQLAdapter.js.map +1 -1
- package/dist/cjs/adapters/PrismaAdapter.d.ts.map +1 -1
- package/dist/cjs/adapters/PrismaAdapter.js +2 -1
- package/dist/cjs/adapters/PrismaAdapter.js.map +1 -1
- package/dist/cjs/adapters/RedisAdapter.d.ts.map +1 -1
- package/dist/cjs/adapters/RedisAdapter.js.map +1 -1
- package/dist/cjs/adapters/SQLiteAdapter.d.ts.map +1 -1
- package/dist/cjs/adapters/SQLiteAdapter.js.map +1 -1
- package/dist/cjs/core/Agent.d.ts +202 -67
- package/dist/cjs/core/Agent.d.ts.map +1 -1
- package/dist/cjs/core/Agent.js +366 -158
- package/dist/cjs/core/Agent.js.map +1 -1
- package/dist/cjs/core/BatchExecutor.js +5 -6
- package/dist/cjs/core/BatchExecutor.js.map +1 -1
- package/dist/cjs/core/BatchPromptBuilder.d.ts.map +1 -1
- package/dist/cjs/core/BatchPromptBuilder.js +5 -2
- package/dist/cjs/core/BatchPromptBuilder.js.map +1 -1
- package/dist/cjs/core/ResponseEngine.d.ts.map +1 -1
- package/dist/cjs/core/ResponseEngine.js +6 -3
- package/dist/cjs/core/ResponseEngine.js.map +1 -1
- package/dist/cjs/core/ResponseModal.d.ts.map +1 -1
- package/dist/cjs/core/ResponseModal.js +18 -17
- package/dist/cjs/core/ResponseModal.js.map +1 -1
- package/dist/cjs/core/RoutingEngine.d.ts.map +1 -1
- package/dist/cjs/core/RoutingEngine.js +8 -73
- package/dist/cjs/core/RoutingEngine.js.map +1 -1
- package/dist/cjs/core/SessionManager.d.ts.map +1 -1
- package/dist/cjs/core/SessionManager.js +4 -11
- package/dist/cjs/core/SessionManager.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/session.d.ts +6 -0
- package/dist/cjs/utils/session.d.ts.map +1 -1
- package/dist/cjs/utils/session.js +26 -8
- package/dist/cjs/utils/session.js.map +1 -1
- package/dist/core/Agent.d.ts +202 -67
- package/dist/core/Agent.d.ts.map +1 -1
- package/dist/core/Agent.js +366 -158
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/BatchExecutor.js +6 -7
- package/dist/core/BatchExecutor.js.map +1 -1
- package/dist/core/BatchPromptBuilder.d.ts.map +1 -1
- package/dist/core/BatchPromptBuilder.js +5 -2
- package/dist/core/BatchPromptBuilder.js.map +1 -1
- package/dist/core/ResponseEngine.d.ts.map +1 -1
- package/dist/core/ResponseEngine.js +6 -3
- package/dist/core/ResponseEngine.js.map +1 -1
- package/dist/core/ResponseModal.d.ts.map +1 -1
- package/dist/core/ResponseModal.js +18 -17
- package/dist/core/ResponseModal.js.map +1 -1
- package/dist/core/RoutingEngine.d.ts.map +1 -1
- package/dist/core/RoutingEngine.js +8 -73
- package/dist/core/RoutingEngine.js.map +1 -1
- package/dist/core/SessionManager.d.ts.map +1 -1
- package/dist/core/SessionManager.js +4 -11
- package/dist/core/SessionManager.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/session.d.ts +6 -0
- package/dist/utils/session.d.ts.map +1 -1
- package/dist/utils/session.js +26 -8
- package/dist/utils/session.js.map +1 -1
- package/docs/api/README.md +33 -4
- package/docs/api/overview.md +9 -5
- package/docs/architecture/data-extraction-flow.md +17 -19
- package/docs/core/conversation-flows/data-collection.md +9 -3
- package/docs/core/conversation-flows/route-dsl.md +8 -1
- package/docs/core/error-handling.md +3 -4
- package/docs/core/persistence/session-storage.md +12 -0
- package/examples/integrations/database-integration.ts +10 -9
- package/examples/persistence/custom-adapter.ts +12 -15
- package/package.json +2 -2
- package/src/adapters/MemoryAdapter.ts +6 -8
- package/src/adapters/MongoAdapter.ts +6 -8
- package/src/adapters/OpenSearchAdapter.ts +6 -8
- package/src/adapters/PostgreSQLAdapter.ts +6 -8
- package/src/adapters/PrismaAdapter.ts +4 -6
- package/src/adapters/RedisAdapter.ts +4 -7
- package/src/adapters/SQLiteAdapter.ts +6 -9
- package/src/core/Agent.ts +427 -195
- package/src/core/BatchExecutor.ts +129 -129
- package/src/core/BatchPromptBuilder.ts +41 -38
- package/src/core/ResponseEngine.ts +56 -53
- package/src/core/ResponseModal.ts +79 -81
- package/src/core/RoutingEngine.ts +67 -149
- package/src/core/SessionManager.ts +4 -13
- package/src/index.ts +11 -11
- package/src/utils/session.ts +48 -10
package/dist/cjs/core/Agent.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Agent = void 0;
|
|
7
|
+
const types_1 = require("../types");
|
|
7
8
|
const utils_1 = require("../utils");
|
|
8
9
|
const Route_1 = require("./Route");
|
|
9
10
|
const PersistenceManager_1 = require("./PersistenceManager");
|
|
@@ -39,14 +40,14 @@ class RouteConfigurationError extends Error {
|
|
|
39
40
|
class Agent {
|
|
40
41
|
constructor(options) {
|
|
41
42
|
this.options = options;
|
|
42
|
-
this.
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
48
|
-
this.
|
|
49
|
-
this.
|
|
43
|
+
this._terms = [];
|
|
44
|
+
this._guidelines = [];
|
|
45
|
+
this._tools = [];
|
|
46
|
+
this._routes = [];
|
|
47
|
+
this._rules = [];
|
|
48
|
+
this._prohibitions = [];
|
|
49
|
+
this._knowledgeBase = {};
|
|
50
|
+
this._collectedData = {};
|
|
50
51
|
// Set log level based on debug option
|
|
51
52
|
if (options.debug) {
|
|
52
53
|
utils_1.logger.setLevel(utils_1.LoggerLevel.DEBUG);
|
|
@@ -57,31 +58,31 @@ class Agent {
|
|
|
57
58
|
}
|
|
58
59
|
// Initialize and validate agent-level schema if provided
|
|
59
60
|
if (options.schema) {
|
|
60
|
-
this.
|
|
61
|
-
this.validateSchema(this.
|
|
61
|
+
this._schema = options.schema;
|
|
62
|
+
this.validateSchema(this._schema);
|
|
62
63
|
utils_1.logger.debug("[Agent] Agent-level schema initialized and validated");
|
|
63
64
|
}
|
|
64
65
|
// Initialize context if provided
|
|
65
|
-
this.
|
|
66
|
+
this._context = options.context;
|
|
66
67
|
// Initialize collected data with initial data if provided
|
|
67
68
|
if (options.initialData) {
|
|
68
|
-
if (this.
|
|
69
|
+
if (this._schema) {
|
|
69
70
|
const validation = this.validateData(options.initialData);
|
|
70
71
|
if (!validation.valid) {
|
|
71
72
|
throw new Error(`Initial data validation failed: ${validation.errors.map(e => e.message).join(', ')}`);
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
|
-
this.
|
|
75
|
-
utils_1.logger.debug("[Agent] Initial data set:", this.
|
|
75
|
+
this._collectedData = { ...options.initialData };
|
|
76
|
+
utils_1.logger.debug("[Agent] Initial data set:", this._collectedData);
|
|
76
77
|
}
|
|
77
78
|
// Initialize current session if provided
|
|
78
|
-
this.
|
|
79
|
+
this._currentSession = options.session;
|
|
79
80
|
// Initialize routing engine
|
|
80
|
-
this.
|
|
81
|
+
this._routingEngine = new RoutingEngine_1.RoutingEngine({
|
|
81
82
|
routeSwitchMargin: options.routeSwitchMargin,
|
|
82
83
|
});
|
|
83
84
|
// Initialize ResponseModal for handling all response generation
|
|
84
|
-
this.
|
|
85
|
+
this._responseModal = new ResponseModal_1.ResponseModal(this);
|
|
85
86
|
// Initialize persistence if configured
|
|
86
87
|
if (options.persistence) {
|
|
87
88
|
try {
|
|
@@ -95,7 +96,7 @@ class Agent {
|
|
|
95
96
|
if (!options.persistence.adapter.messageRepository) {
|
|
96
97
|
throw new Error("Persistence adapter must provide a messageRepository");
|
|
97
98
|
}
|
|
98
|
-
this.
|
|
99
|
+
this._persistenceManager = new PersistenceManager_1.PersistenceManager(options.persistence);
|
|
99
100
|
// Initialize the adapter if it has an initialize method
|
|
100
101
|
if (options.persistence.adapter.initialize) {
|
|
101
102
|
options.persistence.adapter.initialize().catch((error) => {
|
|
@@ -127,10 +128,10 @@ class Agent {
|
|
|
127
128
|
}
|
|
128
129
|
// Initialize agent-level rules and prohibitions
|
|
129
130
|
if (options.rules) {
|
|
130
|
-
this.
|
|
131
|
+
this._rules = [...options.rules];
|
|
131
132
|
}
|
|
132
133
|
if (options.prohibitions) {
|
|
133
|
-
this.
|
|
134
|
+
this._prohibitions = [...options.prohibitions];
|
|
134
135
|
}
|
|
135
136
|
if (options.routes) {
|
|
136
137
|
options.routes.forEach((routeOptions) => {
|
|
@@ -139,10 +140,10 @@ class Agent {
|
|
|
139
140
|
}
|
|
140
141
|
// Initialize knowledge base
|
|
141
142
|
if (options.knowledgeBase) {
|
|
142
|
-
this.
|
|
143
|
+
this._knowledgeBase = { ...options.knowledgeBase };
|
|
143
144
|
}
|
|
144
145
|
// Initialize session manager with reference to this agent for bidirectional sync
|
|
145
|
-
this.session = new SessionManager_1.SessionManager(this.
|
|
146
|
+
this.session = new SessionManager_1.SessionManager(this._persistenceManager, this);
|
|
146
147
|
// Initialize tool manager with proper type inference
|
|
147
148
|
this.tool = new ToolManager_1.ToolManager(this);
|
|
148
149
|
// Store sessionId for later use in getOrCreate calls
|
|
@@ -152,8 +153,8 @@ class Agent {
|
|
|
152
153
|
this.session.getOrCreate(options.sessionId).then((session) => {
|
|
153
154
|
// Sync session data to agent collected data
|
|
154
155
|
if (session.data && Object.keys(session.data).length > 0) {
|
|
155
|
-
this.
|
|
156
|
-
utils_1.logger.debug("[Agent] Synced session data to collected data:", this.
|
|
156
|
+
this._collectedData = { ...session.data };
|
|
157
|
+
utils_1.logger.debug("[Agent] Synced session data to collected data:", this._collectedData);
|
|
157
158
|
}
|
|
158
159
|
}).catch((err) => {
|
|
159
160
|
utils_1.logger.error("Failed to start session", err);
|
|
@@ -183,16 +184,16 @@ class Agent {
|
|
|
183
184
|
* Validate data against the agent-level schema
|
|
184
185
|
*/
|
|
185
186
|
validateData(data) {
|
|
186
|
-
if (!this.
|
|
187
|
+
if (!this._schema) {
|
|
187
188
|
// No schema defined, consider all data valid
|
|
188
189
|
return { valid: true, errors: [], warnings: [] };
|
|
189
190
|
}
|
|
190
191
|
const errors = [];
|
|
191
192
|
const warnings = [];
|
|
192
193
|
// Basic validation - check if provided fields exist in schema
|
|
193
|
-
if (this.
|
|
194
|
+
if (this._schema.properties) {
|
|
194
195
|
for (const [key, value] of Object.entries(data)) {
|
|
195
|
-
if (!(key in this.
|
|
196
|
+
if (!(key in this._schema.properties)) {
|
|
196
197
|
errors.push({
|
|
197
198
|
field: key,
|
|
198
199
|
value,
|
|
@@ -203,8 +204,8 @@ class Agent {
|
|
|
203
204
|
}
|
|
204
205
|
}
|
|
205
206
|
// Check required fields if specified
|
|
206
|
-
if (this.
|
|
207
|
-
for (const requiredField of this.
|
|
207
|
+
if (this._schema.required && Array.isArray(this._schema.required)) {
|
|
208
|
+
for (const requiredField of this._schema.required) {
|
|
208
209
|
if (!(requiredField in data) || data[requiredField] === undefined) {
|
|
209
210
|
warnings.push({
|
|
210
211
|
field: requiredField,
|
|
@@ -227,11 +228,11 @@ class Agent {
|
|
|
227
228
|
* @returns true if field exists in schema or no schema is defined, false otherwise
|
|
228
229
|
*/
|
|
229
230
|
isValidSchemaField(field) {
|
|
230
|
-
if (!this.
|
|
231
|
+
if (!this._schema || !this._schema.properties) {
|
|
231
232
|
// No schema defined, consider all fields valid
|
|
232
233
|
return true;
|
|
233
234
|
}
|
|
234
|
-
return field in this.
|
|
235
|
+
return field in this._schema.properties;
|
|
235
236
|
}
|
|
236
237
|
/**
|
|
237
238
|
* Get the current collected data
|
|
@@ -239,7 +240,7 @@ class Agent {
|
|
|
239
240
|
getCollectedData() {
|
|
240
241
|
// Ensure agent collected data is synced with session
|
|
241
242
|
this.syncSessionDataToCollectedData();
|
|
242
|
-
return { ...this.
|
|
243
|
+
return { ...this._collectedData };
|
|
243
244
|
}
|
|
244
245
|
/**
|
|
245
246
|
* Update collected data with validation
|
|
@@ -257,80 +258,366 @@ class Agent {
|
|
|
257
258
|
utils_1.logger.warn(`[Agent] Data validation warnings: ${warningMessages}`);
|
|
258
259
|
}
|
|
259
260
|
// Merge updates with current data
|
|
260
|
-
const previousData = { ...this.
|
|
261
|
-
this.
|
|
262
|
-
...this.
|
|
261
|
+
const previousData = { ...this._collectedData };
|
|
262
|
+
this._collectedData = {
|
|
263
|
+
...this._collectedData,
|
|
263
264
|
...updates
|
|
264
265
|
};
|
|
265
266
|
// Trigger agent-level lifecycle hook if configured
|
|
266
267
|
if (this.options.hooks?.onDataUpdate) {
|
|
267
|
-
this.
|
|
268
|
+
this._collectedData = await this.options.hooks.onDataUpdate(this._collectedData, previousData);
|
|
268
269
|
}
|
|
269
270
|
// Update current session if it exists to keep it in sync
|
|
270
|
-
if (this.
|
|
271
|
-
this.
|
|
271
|
+
if (this._currentSession) {
|
|
272
|
+
this._currentSession = (0, utils_1.mergeCollected)(this._currentSession, this._collectedData);
|
|
272
273
|
}
|
|
273
274
|
// Also update the session manager's session data (avoid circular call)
|
|
274
275
|
const sessionManagerSession = this.session.current;
|
|
275
276
|
if (sessionManagerSession) {
|
|
276
|
-
sessionManagerSession.data = { ...this.
|
|
277
|
+
sessionManagerSession.data = { ...this._collectedData };
|
|
277
278
|
sessionManagerSession.metadata.lastUpdatedAt = new Date();
|
|
278
279
|
}
|
|
279
280
|
utils_1.logger.debug("[Agent] Collected data updated:", updates);
|
|
280
281
|
}
|
|
282
|
+
// ---------------------------------------------------------------------------
|
|
283
|
+
// Property accessors (get / set)
|
|
284
|
+
// ---------------------------------------------------------------------------
|
|
281
285
|
/**
|
|
282
286
|
* Get agent name
|
|
283
287
|
*/
|
|
284
288
|
get name() {
|
|
285
289
|
return this.options.name;
|
|
286
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* Set agent name
|
|
293
|
+
*/
|
|
294
|
+
set name(value) {
|
|
295
|
+
this.options.name = value;
|
|
296
|
+
}
|
|
287
297
|
/**
|
|
288
298
|
* Get agent description
|
|
289
299
|
*/
|
|
290
300
|
get description() {
|
|
291
301
|
return this.options.description;
|
|
292
302
|
}
|
|
303
|
+
/**
|
|
304
|
+
* Set agent description
|
|
305
|
+
*/
|
|
306
|
+
set description(value) {
|
|
307
|
+
this.options.description = value;
|
|
308
|
+
}
|
|
293
309
|
/**
|
|
294
310
|
* Get agent goal
|
|
295
311
|
*/
|
|
296
312
|
get goal() {
|
|
297
313
|
return this.options.goal;
|
|
298
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* Set agent goal
|
|
317
|
+
*/
|
|
318
|
+
set goal(value) {
|
|
319
|
+
this.options.goal = value;
|
|
320
|
+
}
|
|
299
321
|
/**
|
|
300
322
|
* Get agent identity
|
|
301
323
|
*/
|
|
302
324
|
get identity() {
|
|
303
325
|
return this.options.identity;
|
|
304
326
|
}
|
|
327
|
+
/**
|
|
328
|
+
* Set agent identity
|
|
329
|
+
*/
|
|
330
|
+
set identity(value) {
|
|
331
|
+
this.options.identity = value;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Get agent personality
|
|
335
|
+
*/
|
|
336
|
+
get personality() {
|
|
337
|
+
return this.options.personality;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Set agent personality
|
|
341
|
+
*/
|
|
342
|
+
set personality(value) {
|
|
343
|
+
this.options.personality = value;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Get whether debug mode is enabled
|
|
347
|
+
*/
|
|
348
|
+
get debug() {
|
|
349
|
+
return this.options.debug ?? false;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Set debug mode (also updates logger level)
|
|
353
|
+
*/
|
|
354
|
+
set debug(value) {
|
|
355
|
+
this.options.debug = value;
|
|
356
|
+
utils_1.logger.setLevel(value ? utils_1.LoggerLevel.DEBUG : utils_1.LoggerLevel.INFO);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Get the AI provider
|
|
360
|
+
*/
|
|
361
|
+
get provider() {
|
|
362
|
+
return this.options.provider;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Set the AI provider
|
|
366
|
+
*/
|
|
367
|
+
set provider(value) {
|
|
368
|
+
this.options.provider = value;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Get the composition mode
|
|
372
|
+
*/
|
|
373
|
+
get compositionMode() {
|
|
374
|
+
return this.options.compositionMode ?? types_1.CompositionMode.FLUID;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Set the composition mode
|
|
378
|
+
*/
|
|
379
|
+
set compositionMode(value) {
|
|
380
|
+
this.options.compositionMode = value;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Get the route switch margin
|
|
384
|
+
* @default 15
|
|
385
|
+
*/
|
|
386
|
+
get routeSwitchMargin() {
|
|
387
|
+
return this.options.routeSwitchMargin ?? 15;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Set the route switch margin
|
|
391
|
+
*/
|
|
392
|
+
set routeSwitchMargin(value) {
|
|
393
|
+
this.options.routeSwitchMargin = value;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Get the maximum steps per batch
|
|
397
|
+
* @default 1
|
|
398
|
+
*/
|
|
399
|
+
get maxStepsPerBatch() {
|
|
400
|
+
return this.options.maxStepsPerBatch ?? 1;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Set the maximum steps per batch
|
|
404
|
+
*/
|
|
405
|
+
set maxStepsPerBatch(value) {
|
|
406
|
+
this.options.maxStepsPerBatch = value;
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Get all terms
|
|
410
|
+
*/
|
|
411
|
+
get terms() {
|
|
412
|
+
return [...this._terms];
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Get all guidelines
|
|
416
|
+
*/
|
|
417
|
+
get guidelines() {
|
|
418
|
+
return [...this._guidelines];
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Get all tools
|
|
422
|
+
*/
|
|
423
|
+
get tools() {
|
|
424
|
+
return [...this._tools];
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Get all routes
|
|
428
|
+
*/
|
|
429
|
+
get routes() {
|
|
430
|
+
return [...this._routes];
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Get agent-level rules
|
|
434
|
+
*/
|
|
435
|
+
get rules() {
|
|
436
|
+
return [...this._rules];
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Set agent-level rules
|
|
440
|
+
*/
|
|
441
|
+
set rules(value) {
|
|
442
|
+
this._rules = [...value];
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Get agent-level prohibitions
|
|
446
|
+
*/
|
|
447
|
+
get prohibitions() {
|
|
448
|
+
return [...this._prohibitions];
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Set agent-level prohibitions
|
|
452
|
+
*/
|
|
453
|
+
set prohibitions(value) {
|
|
454
|
+
this._prohibitions = [...value];
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Get current schema
|
|
458
|
+
*/
|
|
459
|
+
get schema() {
|
|
460
|
+
return this._schema;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Set schema (validates structure)
|
|
464
|
+
*/
|
|
465
|
+
set schema(value) {
|
|
466
|
+
if (value) {
|
|
467
|
+
this.validateSchema(value);
|
|
468
|
+
}
|
|
469
|
+
this._schema = value;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Get the agent's knowledge base
|
|
473
|
+
*/
|
|
474
|
+
get knowledgeBase() {
|
|
475
|
+
return { ...this._knowledgeBase };
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Set the agent's knowledge base
|
|
479
|
+
*/
|
|
480
|
+
set knowledgeBase(value) {
|
|
481
|
+
this._knowledgeBase = { ...value };
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Get the current session (if set)
|
|
485
|
+
*/
|
|
486
|
+
get currentSession() {
|
|
487
|
+
return this._currentSession;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Set the current session for convenience methods
|
|
491
|
+
* Set to undefined to clear the current session
|
|
492
|
+
*/
|
|
493
|
+
set currentSession(value) {
|
|
494
|
+
this._currentSession = value;
|
|
495
|
+
}
|
|
496
|
+
// ---------------------------------------------------------------------------
|
|
497
|
+
// Deprecated method-based accessors (for backward compatibility)
|
|
498
|
+
// ---------------------------------------------------------------------------
|
|
499
|
+
/**
|
|
500
|
+
* Get all terms
|
|
501
|
+
* @deprecated Use `agent.terms` instead
|
|
502
|
+
*/
|
|
503
|
+
getTerms() {
|
|
504
|
+
return this.terms;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Get all tools
|
|
508
|
+
* @deprecated Use `agent.tools` instead
|
|
509
|
+
*/
|
|
510
|
+
getTools() {
|
|
511
|
+
return this.tools;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Get all guidelines
|
|
515
|
+
* @deprecated Use `agent.guidelines` instead
|
|
516
|
+
*/
|
|
517
|
+
getGuidelines() {
|
|
518
|
+
return this.guidelines;
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Get all routes
|
|
522
|
+
* @deprecated Use `agent.routes` instead
|
|
523
|
+
*/
|
|
524
|
+
getRoutes() {
|
|
525
|
+
return this.routes;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Get agent-level rules
|
|
529
|
+
* @deprecated Use `agent.rules` instead
|
|
530
|
+
*/
|
|
531
|
+
getRules() {
|
|
532
|
+
return this.rules;
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Get agent-level prohibitions
|
|
536
|
+
* @deprecated Use `agent.prohibitions` instead
|
|
537
|
+
*/
|
|
538
|
+
getProhibitions() {
|
|
539
|
+
return this.prohibitions;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Get current schema
|
|
543
|
+
* @deprecated Use `agent.schema` instead
|
|
544
|
+
*/
|
|
545
|
+
getSchema() {
|
|
546
|
+
return this.schema;
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Get the agent's knowledge base
|
|
550
|
+
* @deprecated Use `agent.knowledgeBase` instead
|
|
551
|
+
*/
|
|
552
|
+
getKnowledgeBase() {
|
|
553
|
+
return this.knowledgeBase;
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Get the current session (if set)
|
|
557
|
+
* @deprecated Use `agent.currentSession` instead
|
|
558
|
+
*/
|
|
559
|
+
getCurrentSession() {
|
|
560
|
+
return this.currentSession;
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Set the current session for convenience methods
|
|
564
|
+
* @deprecated Use `agent.currentSession = session` instead
|
|
565
|
+
* @param session - Session step to use for subsequent calls
|
|
566
|
+
*/
|
|
567
|
+
setCurrentSession(session) {
|
|
568
|
+
this.currentSession = session;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Clear the current session
|
|
572
|
+
* @deprecated Use `agent.currentSession = undefined` instead
|
|
573
|
+
*/
|
|
574
|
+
clearCurrentSession() {
|
|
575
|
+
this._currentSession = undefined;
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Get the persistence manager (if configured)
|
|
579
|
+
*/
|
|
580
|
+
getPersistenceManager() {
|
|
581
|
+
return this._persistenceManager;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Check if persistence is enabled
|
|
585
|
+
*/
|
|
586
|
+
hasPersistence() {
|
|
587
|
+
return this._persistenceManager !== undefined;
|
|
588
|
+
}
|
|
589
|
+
// ---------------------------------------------------------------------------
|
|
590
|
+
// Core methods
|
|
591
|
+
// ---------------------------------------------------------------------------
|
|
305
592
|
/**
|
|
306
593
|
* Create a new route (journey) using agent-level data type
|
|
307
594
|
*/
|
|
308
595
|
createRoute(options) {
|
|
309
596
|
// Validate that requiredFields exist in agent schema
|
|
310
|
-
if (options.requiredFields && this.
|
|
311
|
-
const invalidRequiredFields = options.requiredFields.filter(field => !(String(field) in this.
|
|
597
|
+
if (options.requiredFields && this._schema?.properties) {
|
|
598
|
+
const invalidRequiredFields = options.requiredFields.filter(field => !(String(field) in this._schema.properties));
|
|
312
599
|
if (invalidRequiredFields.length > 0) {
|
|
313
600
|
throw new RouteConfigurationError(options.title, invalidRequiredFields.map(f => String(f)), `Invalid required fields in route '${options.title}': ${invalidRequiredFields.join(', ')}. ` +
|
|
314
|
-
`Must be valid keys from agent schema. Available fields: ${Object.keys(this.
|
|
601
|
+
`Must be valid keys from agent schema. Available fields: ${Object.keys(this._schema.properties).join(', ')}.`);
|
|
315
602
|
}
|
|
316
603
|
}
|
|
317
604
|
// Validate that optionalFields exist in agent schema
|
|
318
|
-
if (options.optionalFields && this.
|
|
319
|
-
const invalidOptionalFields = options.optionalFields.filter(field => !(String(field) in this.
|
|
605
|
+
if (options.optionalFields && this._schema?.properties) {
|
|
606
|
+
const invalidOptionalFields = options.optionalFields.filter(field => !(String(field) in this._schema.properties));
|
|
320
607
|
if (invalidOptionalFields.length > 0) {
|
|
321
608
|
throw new RouteConfigurationError(options.title, invalidOptionalFields.map(f => String(f)), `Invalid optional fields in route '${options.title}': ${invalidOptionalFields.join(', ')}. ` +
|
|
322
|
-
`Must be valid keys from agent schema. Available fields: ${Object.keys(this.
|
|
609
|
+
`Must be valid keys from agent schema. Available fields: ${Object.keys(this._schema.properties).join(', ')}.`);
|
|
323
610
|
}
|
|
324
611
|
}
|
|
325
612
|
const route = new Route_1.Route(options, this);
|
|
326
|
-
this.
|
|
613
|
+
this._routes.push(route);
|
|
327
614
|
return route;
|
|
328
615
|
}
|
|
329
616
|
/**
|
|
330
617
|
* Create a domain term for the glossary
|
|
331
618
|
*/
|
|
332
619
|
createTerm(term) {
|
|
333
|
-
this.
|
|
620
|
+
this._terms.push(term);
|
|
334
621
|
return this;
|
|
335
622
|
}
|
|
336
623
|
/**
|
|
@@ -339,10 +626,10 @@ class Agent {
|
|
|
339
626
|
createGuideline(guideline) {
|
|
340
627
|
const guidelineWithId = {
|
|
341
628
|
...guideline,
|
|
342
|
-
id: guideline.id || `guideline_${this.
|
|
629
|
+
id: guideline.id || `guideline_${this._guidelines.length}`,
|
|
343
630
|
enabled: guideline.enabled !== false, // Default to true
|
|
344
631
|
};
|
|
345
|
-
this.
|
|
632
|
+
this._guidelines.push(guidelineWithId);
|
|
346
633
|
return this;
|
|
347
634
|
}
|
|
348
635
|
/**
|
|
@@ -356,7 +643,7 @@ class Agent {
|
|
|
356
643
|
throw new Error('Invalid tool: must have id and handler properties');
|
|
357
644
|
}
|
|
358
645
|
// Add directly to agent's tools array, preserving the TResult type
|
|
359
|
-
this.
|
|
646
|
+
this._tools.push(tool);
|
|
360
647
|
utils_1.logger.debug(`[Agent] Added tool to agent scope: ${tool.id}`);
|
|
361
648
|
return this;
|
|
362
649
|
}
|
|
@@ -370,7 +657,7 @@ class Agent {
|
|
|
370
657
|
if (!tool || !tool.id || !tool.handler) {
|
|
371
658
|
throw new Error('Invalid tool: must have id and handler properties');
|
|
372
659
|
}
|
|
373
|
-
this.
|
|
660
|
+
this._tools.push(tool);
|
|
374
661
|
utils_1.logger.debug(`[Agent] Created tool (legacy): ${tool.id}`);
|
|
375
662
|
return this;
|
|
376
663
|
}
|
|
@@ -384,7 +671,7 @@ class Agent {
|
|
|
384
671
|
if (!tool || !tool.id || !tool.handler) {
|
|
385
672
|
throw new Error(`Invalid tool in batch: must have id and handler properties (tool: ${tool?.id || 'unknown'})`);
|
|
386
673
|
}
|
|
387
|
-
this.
|
|
674
|
+
this._tools.push(tool);
|
|
388
675
|
});
|
|
389
676
|
utils_1.logger.debug(`[Agent] Registered ${tools.length} tools`);
|
|
390
677
|
return this;
|
|
@@ -394,23 +681,23 @@ class Agent {
|
|
|
394
681
|
* Triggers both agent-level and route-specific onContextUpdate lifecycle hooks if configured
|
|
395
682
|
*/
|
|
396
683
|
async updateContext(updates) {
|
|
397
|
-
const previousContext = this.
|
|
684
|
+
const previousContext = this._context;
|
|
398
685
|
// Merge updates with current context
|
|
399
|
-
this.
|
|
400
|
-
...this.
|
|
686
|
+
this._context = {
|
|
687
|
+
...this._context,
|
|
401
688
|
...updates,
|
|
402
689
|
};
|
|
403
690
|
// Trigger route-specific lifecycle hook if configured and session has current route
|
|
404
|
-
if (this.
|
|
405
|
-
const currentRoute = this.
|
|
691
|
+
if (this._currentSession?.currentRoute) {
|
|
692
|
+
const currentRoute = this._routes.find((r) => r.id === this._currentSession.currentRoute?.id);
|
|
406
693
|
if (currentRoute?.hooks?.onContextUpdate &&
|
|
407
694
|
previousContext !== undefined) {
|
|
408
|
-
await currentRoute.handleContextUpdate(this.
|
|
695
|
+
await currentRoute.handleContextUpdate(this._context, previousContext);
|
|
409
696
|
}
|
|
410
697
|
}
|
|
411
698
|
// Trigger agent-level lifecycle hook if configured
|
|
412
699
|
if (this.options.hooks?.onContextUpdate && previousContext !== undefined) {
|
|
413
|
-
await this.options.hooks.onContextUpdate(this.
|
|
700
|
+
await this.options.hooks.onContextUpdate(this._context, previousContext);
|
|
414
701
|
}
|
|
415
702
|
}
|
|
416
703
|
/**
|
|
@@ -427,7 +714,7 @@ class Agent {
|
|
|
427
714
|
};
|
|
428
715
|
// Trigger route-specific lifecycle hook if configured and session has a current route
|
|
429
716
|
if (session.currentRoute) {
|
|
430
|
-
const currentRoute = this.
|
|
717
|
+
const currentRoute = this._routes.find((r) => r.id === session.currentRoute?.id);
|
|
431
718
|
if (currentRoute?.hooks?.onDataUpdate) {
|
|
432
719
|
newCollected = await currentRoute.handleDataUpdate(newCollected, previousCollected);
|
|
433
720
|
}
|
|
@@ -437,7 +724,7 @@ class Agent {
|
|
|
437
724
|
newCollected = (await this.options.hooks.onDataUpdate(newCollected, previousCollected));
|
|
438
725
|
}
|
|
439
726
|
// Update agent's collected data to stay in sync
|
|
440
|
-
this.
|
|
727
|
+
this._collectedData = { ...newCollected };
|
|
441
728
|
// Return updated session
|
|
442
729
|
return (0, utils_1.mergeCollected)(session, newCollected);
|
|
443
730
|
}
|
|
@@ -450,33 +737,21 @@ class Agent {
|
|
|
450
737
|
return await this.options.contextProvider();
|
|
451
738
|
}
|
|
452
739
|
// Otherwise return the stored context
|
|
453
|
-
return this.
|
|
454
|
-
}
|
|
455
|
-
/**
|
|
456
|
-
* Get current schema
|
|
457
|
-
*/
|
|
458
|
-
getSchema() {
|
|
459
|
-
return this.schema;
|
|
740
|
+
return this._context;
|
|
460
741
|
}
|
|
461
742
|
/**
|
|
462
743
|
* Generate a response based on history and context as a stream
|
|
463
744
|
*/
|
|
464
745
|
async *respondStream(params) {
|
|
465
746
|
// Delegate to ResponseModal
|
|
466
|
-
yield* this.
|
|
747
|
+
yield* this._responseModal.respondStream(params);
|
|
467
748
|
}
|
|
468
749
|
/**
|
|
469
750
|
* Generate a response based on history and context
|
|
470
751
|
*/
|
|
471
752
|
async respond(params) {
|
|
472
753
|
// Delegate to ResponseModal
|
|
473
|
-
return this.
|
|
474
|
-
}
|
|
475
|
-
/**
|
|
476
|
-
* Get all routes
|
|
477
|
-
*/
|
|
478
|
-
getRoutes() {
|
|
479
|
-
return [...this.routes];
|
|
754
|
+
return this._responseModal.respond(params);
|
|
480
755
|
}
|
|
481
756
|
/**
|
|
482
757
|
* Get agent options
|
|
@@ -490,7 +765,7 @@ class Agent {
|
|
|
490
765
|
* @internal Used by ResponseModal
|
|
491
766
|
*/
|
|
492
767
|
getRoutingEngine() {
|
|
493
|
-
return this.
|
|
768
|
+
return this._routingEngine;
|
|
494
769
|
}
|
|
495
770
|
/**
|
|
496
771
|
* Get the updateData method bound to this agent
|
|
@@ -499,36 +774,6 @@ class Agent {
|
|
|
499
774
|
getUpdateDataMethod() {
|
|
500
775
|
return this.updateData.bind(this);
|
|
501
776
|
}
|
|
502
|
-
/**
|
|
503
|
-
* Get all terms
|
|
504
|
-
*/
|
|
505
|
-
getTerms() {
|
|
506
|
-
return [...this.terms];
|
|
507
|
-
}
|
|
508
|
-
/**
|
|
509
|
-
* Get all tools
|
|
510
|
-
*/
|
|
511
|
-
getTools() {
|
|
512
|
-
return [...this.tools];
|
|
513
|
-
}
|
|
514
|
-
/**
|
|
515
|
-
* Get all guidelines
|
|
516
|
-
*/
|
|
517
|
-
getGuidelines() {
|
|
518
|
-
return [...this.guidelines];
|
|
519
|
-
}
|
|
520
|
-
/**
|
|
521
|
-
* Get agent-level rules
|
|
522
|
-
*/
|
|
523
|
-
getRules() {
|
|
524
|
-
return [...this.agentRules];
|
|
525
|
-
}
|
|
526
|
-
/**
|
|
527
|
-
* Get agent-level prohibitions
|
|
528
|
-
*/
|
|
529
|
-
getProhibitions() {
|
|
530
|
-
return [...this.agentProhibitions];
|
|
531
|
-
}
|
|
532
777
|
/**
|
|
533
778
|
* Evaluate and match active guidelines based on their conditions
|
|
534
779
|
* Returns guidelines that should be active given the current context
|
|
@@ -537,7 +782,7 @@ class Agent {
|
|
|
537
782
|
const templateContext = { context, session, history, data: session?.data };
|
|
538
783
|
const evaluator = (0, utils_1.createConditionEvaluator)(templateContext);
|
|
539
784
|
const matches = [];
|
|
540
|
-
for (const guideline of this.
|
|
785
|
+
for (const guideline of this._guidelines) {
|
|
541
786
|
// Skip disabled guidelines
|
|
542
787
|
if (guideline.enabled === false) {
|
|
543
788
|
continue;
|
|
@@ -569,37 +814,6 @@ class Agent {
|
|
|
569
814
|
}
|
|
570
815
|
return matches;
|
|
571
816
|
}
|
|
572
|
-
/**
|
|
573
|
-
* Get the agent's knowledge base
|
|
574
|
-
*/
|
|
575
|
-
getKnowledgeBase() {
|
|
576
|
-
return { ...this.knowledgeBase };
|
|
577
|
-
}
|
|
578
|
-
/**
|
|
579
|
-
* Get the persistence manager (if configured)
|
|
580
|
-
*/
|
|
581
|
-
getPersistenceManager() {
|
|
582
|
-
return this.persistenceManager;
|
|
583
|
-
}
|
|
584
|
-
/**
|
|
585
|
-
* Check if persistence is enabled
|
|
586
|
-
*/
|
|
587
|
-
hasPersistence() {
|
|
588
|
-
return this.persistenceManager !== undefined;
|
|
589
|
-
}
|
|
590
|
-
/**
|
|
591
|
-
* Set the current session for convenience methods
|
|
592
|
-
* @param session - Session step to use for subsequent calls
|
|
593
|
-
*/
|
|
594
|
-
setCurrentSession(session) {
|
|
595
|
-
this.currentSession = session;
|
|
596
|
-
}
|
|
597
|
-
/**
|
|
598
|
-
* Get the current session (if set)
|
|
599
|
-
*/
|
|
600
|
-
getCurrentSession() {
|
|
601
|
-
return this.currentSession;
|
|
602
|
-
}
|
|
603
817
|
/**
|
|
604
818
|
* Execute a prepare or finalize function/tool
|
|
605
819
|
* @internal Used by ResponseModal
|
|
@@ -650,12 +864,6 @@ class Agent {
|
|
|
650
864
|
}
|
|
651
865
|
}
|
|
652
866
|
}
|
|
653
|
-
/**
|
|
654
|
-
* Clear the current session
|
|
655
|
-
*/
|
|
656
|
-
clearCurrentSession() {
|
|
657
|
-
this.currentSession = undefined;
|
|
658
|
-
}
|
|
659
867
|
/**
|
|
660
868
|
* Sync session data to agent collected data
|
|
661
869
|
* @internal Used to keep agent and session data in sync
|
|
@@ -663,8 +871,8 @@ class Agent {
|
|
|
663
871
|
syncSessionDataToCollectedData() {
|
|
664
872
|
const sessionData = this.session.getData();
|
|
665
873
|
if (sessionData && Object.keys(sessionData).length > 0) {
|
|
666
|
-
this.
|
|
667
|
-
utils_1.logger.debug("[Agent] Synced session data to collected data:", this.
|
|
874
|
+
this._collectedData = { ...sessionData };
|
|
875
|
+
utils_1.logger.debug("[Agent] Synced session data to collected data:", this._collectedData);
|
|
668
876
|
}
|
|
669
877
|
}
|
|
670
878
|
/**
|
|
@@ -676,10 +884,10 @@ class Agent {
|
|
|
676
884
|
// Ensure agent collected data is synced with session
|
|
677
885
|
this.syncSessionDataToCollectedData();
|
|
678
886
|
// If we have a current session, use session data
|
|
679
|
-
if (this.
|
|
887
|
+
if (this._currentSession) {
|
|
680
888
|
// With agent-level data, all routes share the same data structure
|
|
681
889
|
// No need for route-specific data access
|
|
682
|
-
return (this.
|
|
890
|
+
return (this._currentSession.data) || {};
|
|
683
891
|
}
|
|
684
892
|
// Otherwise, return agent-level collected data
|
|
685
893
|
return this.getCollectedData();
|
|
@@ -702,22 +910,22 @@ class Agent {
|
|
|
702
910
|
* }
|
|
703
911
|
*/
|
|
704
912
|
async nextStepRoute(routeIdOrTitle, session, condition, history) {
|
|
705
|
-
const targetSession = session || this.
|
|
913
|
+
const targetSession = session || this._currentSession;
|
|
706
914
|
if (!targetSession) {
|
|
707
915
|
throw new Error("No session provided and no current session available. Please provide a session to transition.");
|
|
708
916
|
}
|
|
709
917
|
// Find target route by ID or title
|
|
710
|
-
const targetRoute = this.
|
|
918
|
+
const targetRoute = this._routes.find((r) => r.id === routeIdOrTitle || r.title === routeIdOrTitle);
|
|
711
919
|
if (!targetRoute) {
|
|
712
|
-
throw new Error(`Route not found: ${routeIdOrTitle}. Available routes: ${this.
|
|
920
|
+
throw new Error(`Route not found: ${routeIdOrTitle}. Available routes: ${this._routes
|
|
713
921
|
.map((r) => r.title)
|
|
714
922
|
.join(", ")}`);
|
|
715
923
|
}
|
|
716
924
|
const templateContext = (0, utils_1.createTemplateContext)({
|
|
717
|
-
context: this.
|
|
925
|
+
context: this._context,
|
|
718
926
|
session,
|
|
719
927
|
history,
|
|
720
|
-
data: this.
|
|
928
|
+
data: this._currentSession?.data,
|
|
721
929
|
});
|
|
722
930
|
const renderedCondition = await (0, utils_1.render)(condition, templateContext);
|
|
723
931
|
const updatedSession = {
|
|
@@ -729,8 +937,8 @@ class Agent {
|
|
|
729
937
|
},
|
|
730
938
|
};
|
|
731
939
|
// Update current session if using it
|
|
732
|
-
if (!session && this.
|
|
733
|
-
this.
|
|
940
|
+
if (!session && this._currentSession) {
|
|
941
|
+
this._currentSession = updatedSession;
|
|
734
942
|
}
|
|
735
943
|
utils_1.logger.debug(`[Agent] Set pending transition to route: ${targetRoute.title}`);
|
|
736
944
|
return updatedSession;
|
|
@@ -741,7 +949,7 @@ class Agent {
|
|
|
741
949
|
*/
|
|
742
950
|
async chat(message, options) {
|
|
743
951
|
// Delegate to ResponseModal.generate()
|
|
744
|
-
return this.
|
|
952
|
+
return this._responseModal.generate(message, options);
|
|
745
953
|
}
|
|
746
954
|
/**
|
|
747
955
|
* Modern streaming API - simple interface like chat() but returns a stream
|
|
@@ -749,7 +957,7 @@ class Agent {
|
|
|
749
957
|
*/
|
|
750
958
|
async *stream(message, options) {
|
|
751
959
|
// Delegate to ResponseModal with the same options structure as chat()
|
|
752
|
-
yield* this.
|
|
960
|
+
yield* this._responseModal.stream(message, {
|
|
753
961
|
history: options?.history,
|
|
754
962
|
contextOverride: options?.contextOverride,
|
|
755
963
|
signal: options?.signal,
|