@elizaos/test-utils 1.5.4 → 1.5.5
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/index.d.ts +950 -0
- package/dist/index.js +523 -289
- package/dist/index.js.map +1 -25
- package/package.json +7 -6
- package/tsup.config.ts +20 -0
- package/dist/src/DatabaseTestRegistry.d.ts +0 -88
- package/dist/src/DatabaseTestRegistry.d.ts.map +0 -1
- package/dist/src/TestInfrastructure.d.ts +0 -64
- package/dist/src/TestInfrastructure.d.ts.map +0 -1
- package/dist/src/factories.d.ts +0 -141
- package/dist/src/factories.d.ts.map +0 -1
- package/dist/src/index.d.ts +0 -52
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/mocks/character.d.ts +0 -65
- package/dist/src/mocks/character.d.ts.map +0 -1
- package/dist/src/mocks/database.d.ts +0 -40
- package/dist/src/mocks/database.d.ts.map +0 -1
- package/dist/src/mocks/memory.d.ts +0 -106
- package/dist/src/mocks/memory.d.ts.map +0 -1
- package/dist/src/mocks/mockUtils.d.ts +0 -17
- package/dist/src/mocks/mockUtils.d.ts.map +0 -1
- package/dist/src/mocks/runtime.d.ts +0 -34
- package/dist/src/mocks/runtime.d.ts.map +0 -1
- package/dist/src/mocks/services.d.ts +0 -99
- package/dist/src/mocks/services.d.ts.map +0 -1
- package/dist/src/mocks/state.d.ts +0 -100
- package/dist/src/mocks/state.d.ts.map +0 -1
- package/dist/src/realRuntime.d.ts +0 -85
- package/dist/src/realRuntime.d.ts.map +0 -1
- package/dist/src/templates.d.ts +0 -123
- package/dist/src/templates.d.ts.map +0 -1
- package/dist/src/testDatabase.d.ts +0 -44
- package/dist/src/testDatabase.d.ts.map +0 -1
- package/dist/src/testModels.d.ts +0 -105
- package/dist/src/testModels.d.ts.map +0 -1
- package/dist/src/unifiedTestSuite.d.ts +0 -40
- package/dist/src/unifiedTestSuite.d.ts.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { AgentRuntime, logger as logger3, stringToUuid } from "@elizaos/core";
|
|
|
3
3
|
|
|
4
4
|
// ../../node_modules/uuid/dist/esm/stringify.js
|
|
5
5
|
var byteToHex = [];
|
|
6
|
-
for (let i = 0;i < 256; ++i) {
|
|
6
|
+
for (let i = 0; i < 256; ++i) {
|
|
7
7
|
byteToHex.push((i + 256).toString(16).slice(1));
|
|
8
8
|
}
|
|
9
9
|
function unsafeStringify(arr, offset = 0) {
|
|
@@ -43,7 +43,7 @@ function v4(options, buf, offset) {
|
|
|
43
43
|
if (offset < 0 || offset + 16 > buf.length) {
|
|
44
44
|
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
45
45
|
}
|
|
46
|
-
for (let i = 0;i < 16; ++i) {
|
|
46
|
+
for (let i = 0; i < 16; ++i) {
|
|
47
47
|
buf[offset + i] = rnds[i];
|
|
48
48
|
}
|
|
49
49
|
return buf;
|
|
@@ -51,11 +51,16 @@ function v4(options, buf, offset) {
|
|
|
51
51
|
return unsafeStringify(rnds);
|
|
52
52
|
}
|
|
53
53
|
var v4_default = v4;
|
|
54
|
+
|
|
54
55
|
// src/testDatabase.ts
|
|
55
56
|
import { logger } from "@elizaos/core";
|
|
56
|
-
|
|
57
|
-
testDatabases = new Map;
|
|
58
|
-
tempPaths = new Set;
|
|
57
|
+
var TestDatabaseManager = class {
|
|
58
|
+
testDatabases = /* @__PURE__ */ new Map();
|
|
59
|
+
tempPaths = /* @__PURE__ */ new Set();
|
|
60
|
+
/**
|
|
61
|
+
* Creates an isolated database for testing
|
|
62
|
+
* Uses PostgreSQL for testing when available, falls back to mock database
|
|
63
|
+
*/
|
|
59
64
|
async createIsolatedDatabase(testId) {
|
|
60
65
|
try {
|
|
61
66
|
logger.debug(`Creating isolated test database for ${testId}`);
|
|
@@ -75,17 +80,24 @@ class TestDatabaseManager {
|
|
|
75
80
|
if (!postgresUrl) {
|
|
76
81
|
throw new Error("PostgreSQL URL not available - falling back to mock database");
|
|
77
82
|
}
|
|
78
|
-
adapter = await sqlPlugin.createDatabaseAdapter(
|
|
79
|
-
|
|
80
|
-
|
|
83
|
+
adapter = await sqlPlugin.createDatabaseAdapter(
|
|
84
|
+
{
|
|
85
|
+
postgresUrl
|
|
86
|
+
},
|
|
87
|
+
"11111111-2222-3333-4444-555555555555"
|
|
88
|
+
);
|
|
81
89
|
logger.debug(`Successfully created PostgreSQL adapter for ${testId}`);
|
|
82
90
|
} catch (importError) {
|
|
83
|
-
logger.warn(
|
|
91
|
+
logger.warn(
|
|
92
|
+
`SQL plugin not available: ${importError instanceof Error ? importError.message : String(importError)} - falling back to mock database`
|
|
93
|
+
);
|
|
84
94
|
adapter = this.createMockDatabase(testId);
|
|
85
95
|
}
|
|
86
96
|
}
|
|
87
97
|
} catch (postgresError) {
|
|
88
|
-
logger.warn(
|
|
98
|
+
logger.warn(
|
|
99
|
+
`Failed to create PostgreSQL database: ${postgresError instanceof Error ? postgresError.message : String(postgresError)} - falling back to mock database`
|
|
100
|
+
);
|
|
89
101
|
adapter = this.createMockDatabase(testId);
|
|
90
102
|
}
|
|
91
103
|
await adapter.init();
|
|
@@ -93,32 +105,42 @@ class TestDatabaseManager {
|
|
|
93
105
|
logger.debug(`Successfully created isolated database for ${testId}`);
|
|
94
106
|
return adapter;
|
|
95
107
|
} catch (error) {
|
|
96
|
-
logger.error(
|
|
97
|
-
|
|
108
|
+
logger.error(
|
|
109
|
+
`Failed to create test database for ${testId}: ${error instanceof Error ? error.message : String(error)}`
|
|
110
|
+
);
|
|
111
|
+
throw new Error(
|
|
112
|
+
`Test database creation failed: ${error instanceof Error ? error.message : String(error)}`
|
|
113
|
+
);
|
|
98
114
|
}
|
|
99
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Creates a minimal mock database adapter for testing when real database unavailable
|
|
118
|
+
* This is a FUNCTIONAL mock that actually stores data in memory
|
|
119
|
+
*/
|
|
100
120
|
createMockDatabase(testId) {
|
|
101
121
|
const storage = {
|
|
102
|
-
agents: new Map,
|
|
103
|
-
entities: new Map,
|
|
104
|
-
memories: new Map,
|
|
105
|
-
relationships: new Map,
|
|
106
|
-
rooms: new Map,
|
|
107
|
-
participants: new Map,
|
|
108
|
-
cache: new Map,
|
|
109
|
-
worlds: new Map,
|
|
110
|
-
tasks: new Map,
|
|
111
|
-
logs: new Map
|
|
122
|
+
agents: /* @__PURE__ */ new Map(),
|
|
123
|
+
entities: /* @__PURE__ */ new Map(),
|
|
124
|
+
memories: /* @__PURE__ */ new Map(),
|
|
125
|
+
relationships: /* @__PURE__ */ new Map(),
|
|
126
|
+
rooms: /* @__PURE__ */ new Map(),
|
|
127
|
+
participants: /* @__PURE__ */ new Map(),
|
|
128
|
+
cache: /* @__PURE__ */ new Map(),
|
|
129
|
+
worlds: /* @__PURE__ */ new Map(),
|
|
130
|
+
tasks: /* @__PURE__ */ new Map(),
|
|
131
|
+
logs: /* @__PURE__ */ new Map()
|
|
112
132
|
};
|
|
113
133
|
const adapter = {
|
|
114
134
|
db: null,
|
|
135
|
+
// Mock database instance
|
|
115
136
|
async initialize() {
|
|
116
137
|
logger.debug(`Initialized mock database for ${testId}`);
|
|
117
138
|
},
|
|
118
139
|
async init() {
|
|
119
140
|
logger.debug(`Initialized mock database for ${testId}`);
|
|
120
141
|
},
|
|
121
|
-
async runMigrations() {
|
|
142
|
+
async runMigrations() {
|
|
143
|
+
},
|
|
122
144
|
async isReady() {
|
|
123
145
|
return true;
|
|
124
146
|
},
|
|
@@ -136,7 +158,8 @@ class TestDatabaseManager {
|
|
|
136
158
|
async getConnection() {
|
|
137
159
|
return null;
|
|
138
160
|
},
|
|
139
|
-
async ensureEmbeddingDimension() {
|
|
161
|
+
async ensureEmbeddingDimension() {
|
|
162
|
+
},
|
|
140
163
|
async getAgent(agentId) {
|
|
141
164
|
return storage.agents.get(agentId) || null;
|
|
142
165
|
},
|
|
@@ -159,6 +182,7 @@ class TestDatabaseManager {
|
|
|
159
182
|
async deleteAgent(agentId) {
|
|
160
183
|
return storage.agents.delete(agentId);
|
|
161
184
|
},
|
|
185
|
+
// Entity operations
|
|
162
186
|
async createEntity(entity) {
|
|
163
187
|
const id = entity.id || v4_default();
|
|
164
188
|
const fullEntity = { ...entity, id };
|
|
@@ -183,7 +207,9 @@ class TestDatabaseManager {
|
|
|
183
207
|
storage.entities.set(entity.id, entity);
|
|
184
208
|
},
|
|
185
209
|
async getEntitiesForRoom(roomId) {
|
|
186
|
-
const participants = Array.from(storage.participants.values()).filter(
|
|
210
|
+
const participants = Array.from(storage.participants.values()).filter(
|
|
211
|
+
(p) => p.roomId === roomId
|
|
212
|
+
);
|
|
187
213
|
const entities = [];
|
|
188
214
|
for (const participant of participants) {
|
|
189
215
|
const entity = storage.entities.get(participant.entityId);
|
|
@@ -193,6 +219,7 @@ class TestDatabaseManager {
|
|
|
193
219
|
}
|
|
194
220
|
return entities;
|
|
195
221
|
},
|
|
222
|
+
// Memory operations
|
|
196
223
|
async createMemory(memory, tableName = "messages", _unique = false) {
|
|
197
224
|
const id = memory.id || v4_default();
|
|
198
225
|
const fullMemory = {
|
|
@@ -201,7 +228,7 @@ class TestDatabaseManager {
|
|
|
201
228
|
createdAt: memory.createdAt || Date.now()
|
|
202
229
|
};
|
|
203
230
|
if (!storage.memories.has(tableName)) {
|
|
204
|
-
storage.memories.set(tableName, new Map);
|
|
231
|
+
storage.memories.set(tableName, /* @__PURE__ */ new Map());
|
|
205
232
|
}
|
|
206
233
|
storage.memories.get(tableName).set(id, fullMemory);
|
|
207
234
|
return id;
|
|
@@ -236,7 +263,9 @@ class TestDatabaseManager {
|
|
|
236
263
|
memories = memories.filter((m) => m.roomId === params.roomId);
|
|
237
264
|
}
|
|
238
265
|
if (params.query) {
|
|
239
|
-
memories = memories.filter(
|
|
266
|
+
memories = memories.filter(
|
|
267
|
+
(m) => m.content?.text?.toLowerCase().includes(params.query.toLowerCase())
|
|
268
|
+
);
|
|
240
269
|
}
|
|
241
270
|
return memories.slice(0, params.count || 10);
|
|
242
271
|
},
|
|
@@ -268,7 +297,9 @@ class TestDatabaseManager {
|
|
|
268
297
|
if (!tableData) {
|
|
269
298
|
return [];
|
|
270
299
|
}
|
|
271
|
-
let memories = Array.from(tableData.values()).filter(
|
|
300
|
+
let memories = Array.from(tableData.values()).filter(
|
|
301
|
+
(m) => params.roomIds.includes(m.roomId)
|
|
302
|
+
);
|
|
272
303
|
if (params.limit) {
|
|
273
304
|
memories = memories.slice(0, params.limit);
|
|
274
305
|
}
|
|
@@ -279,13 +310,13 @@ class TestDatabaseManager {
|
|
|
279
310
|
},
|
|
280
311
|
async log(params) {
|
|
281
312
|
if (!storage.logs) {
|
|
282
|
-
storage.logs = new Map;
|
|
313
|
+
storage.logs = /* @__PURE__ */ new Map();
|
|
283
314
|
}
|
|
284
315
|
const logId = v4_default();
|
|
285
316
|
storage.logs.set(logId, {
|
|
286
317
|
id: logId,
|
|
287
318
|
...params,
|
|
288
|
-
createdAt: new Date
|
|
319
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
289
320
|
});
|
|
290
321
|
},
|
|
291
322
|
async getLogs() {
|
|
@@ -301,6 +332,7 @@ class TestDatabaseManager {
|
|
|
301
332
|
}
|
|
302
333
|
return false;
|
|
303
334
|
},
|
|
335
|
+
// Room operations
|
|
304
336
|
async createRoom(room) {
|
|
305
337
|
const id = room.id || v4_default();
|
|
306
338
|
const fullRoom = { ...room, id };
|
|
@@ -310,8 +342,11 @@ class TestDatabaseManager {
|
|
|
310
342
|
return storage.rooms.get(roomId) || null;
|
|
311
343
|
},
|
|
312
344
|
async getRooms(worldId) {
|
|
313
|
-
return Array.from(storage.rooms.values()).filter(
|
|
345
|
+
return Array.from(storage.rooms.values()).filter(
|
|
346
|
+
(room) => !worldId || room.worldId === worldId
|
|
347
|
+
);
|
|
314
348
|
},
|
|
349
|
+
// Participant operations
|
|
315
350
|
async addParticipant(entityId, roomId) {
|
|
316
351
|
const participantId = `${entityId}-${roomId}`;
|
|
317
352
|
storage.participants.set(participantId, { entityId, roomId });
|
|
@@ -324,6 +359,7 @@ class TestDatabaseManager {
|
|
|
324
359
|
async getParticipantsForRoom(roomId) {
|
|
325
360
|
return Array.from(storage.participants.values()).filter((p) => p.roomId === roomId).map((p) => p.entityId);
|
|
326
361
|
},
|
|
362
|
+
// Cache operations
|
|
327
363
|
async setCache(key, value) {
|
|
328
364
|
storage.cache.set(key, {
|
|
329
365
|
value,
|
|
@@ -338,6 +374,7 @@ class TestDatabaseManager {
|
|
|
338
374
|
async deleteCache(key) {
|
|
339
375
|
return storage.cache.delete(key);
|
|
340
376
|
},
|
|
377
|
+
// World operations
|
|
341
378
|
async createWorld(world) {
|
|
342
379
|
const id = world.id || v4_default();
|
|
343
380
|
const fullWorld = { ...world, id };
|
|
@@ -350,6 +387,7 @@ class TestDatabaseManager {
|
|
|
350
387
|
async getAllWorlds() {
|
|
351
388
|
return Array.from(storage.worlds.values());
|
|
352
389
|
},
|
|
390
|
+
// Task operations
|
|
353
391
|
async createTask(task) {
|
|
354
392
|
const id = task.id || v4_default();
|
|
355
393
|
const fullTask = {
|
|
@@ -366,13 +404,16 @@ class TestDatabaseManager {
|
|
|
366
404
|
tasks = tasks.filter((task) => task.roomId === params.roomId);
|
|
367
405
|
}
|
|
368
406
|
if (params.tags) {
|
|
369
|
-
tasks = tasks.filter(
|
|
407
|
+
tasks = tasks.filter(
|
|
408
|
+
(task) => params.tags.some((tag) => task.tags.includes(tag))
|
|
409
|
+
);
|
|
370
410
|
}
|
|
371
411
|
return tasks;
|
|
372
412
|
},
|
|
373
413
|
async deleteTask(taskId) {
|
|
374
414
|
storage.tasks.delete(taskId);
|
|
375
415
|
},
|
|
416
|
+
// Relationship operations
|
|
376
417
|
async createRelationship(relationship) {
|
|
377
418
|
const id = v4_default();
|
|
378
419
|
const fullRelationship = { ...relationship, id };
|
|
@@ -382,7 +423,9 @@ class TestDatabaseManager {
|
|
|
382
423
|
async getRelationships(params) {
|
|
383
424
|
let relationships = Array.from(storage.relationships.values());
|
|
384
425
|
if (params.entityId) {
|
|
385
|
-
relationships = relationships.filter(
|
|
426
|
+
relationships = relationships.filter(
|
|
427
|
+
(rel) => rel.sourceEntityId === params.entityId || rel.targetEntityId === params.entityId
|
|
428
|
+
);
|
|
386
429
|
}
|
|
387
430
|
return relationships;
|
|
388
431
|
},
|
|
@@ -541,16 +584,20 @@ class TestDatabaseManager {
|
|
|
541
584
|
if (!entity?.components) {
|
|
542
585
|
return null;
|
|
543
586
|
}
|
|
544
|
-
return entity.components.find(
|
|
587
|
+
return entity.components.find(
|
|
588
|
+
(c) => c.type === type && (!worldId || c.worldId === worldId) && (!sourceEntityId || c.sourceEntityId === sourceEntityId)
|
|
589
|
+
) || null;
|
|
545
590
|
},
|
|
546
591
|
async getParticipantsForEntity(entityId) {
|
|
547
|
-
return Array.from(storage.participants.values()).filter(
|
|
592
|
+
return Array.from(storage.participants.values()).filter(
|
|
593
|
+
(p) => p.entityId === entityId
|
|
594
|
+
);
|
|
548
595
|
},
|
|
549
596
|
async getRoomsForParticipant(entityId) {
|
|
550
597
|
return Array.from(storage.participants.values()).filter((p) => p.entityId === entityId).map((p) => p.roomId);
|
|
551
598
|
},
|
|
552
599
|
async getRoomsForParticipants(userIds) {
|
|
553
|
-
const roomIds = new Set;
|
|
600
|
+
const roomIds = /* @__PURE__ */ new Set();
|
|
554
601
|
for (const participant of storage.participants.values()) {
|
|
555
602
|
if (userIds.includes(participant.entityId)) {
|
|
556
603
|
roomIds.add(participant.roomId);
|
|
@@ -561,10 +608,13 @@ class TestDatabaseManager {
|
|
|
561
608
|
async getParticipantUserState(_roomId, _entityId) {
|
|
562
609
|
return null;
|
|
563
610
|
},
|
|
564
|
-
async setParticipantUserState(_roomId, _entityId, _state) {
|
|
611
|
+
async setParticipantUserState(_roomId, _entityId, _state) {
|
|
612
|
+
},
|
|
565
613
|
async getRelationship(params) {
|
|
566
614
|
const relationships = Array.from(storage.relationships.values());
|
|
567
|
-
return relationships.find(
|
|
615
|
+
return relationships.find(
|
|
616
|
+
(r) => r.sourceEntityId === params.sourceEntityId && r.targetEntityId === params.targetEntityId
|
|
617
|
+
) || null;
|
|
568
618
|
},
|
|
569
619
|
async updateRelationship(relationship) {
|
|
570
620
|
if (!relationship.id || !storage.relationships.has(relationship.id)) {
|
|
@@ -597,7 +647,9 @@ class TestDatabaseManager {
|
|
|
597
647
|
if (!tableData) {
|
|
598
648
|
return [];
|
|
599
649
|
}
|
|
600
|
-
let memories = Array.from(tableData.values()).filter(
|
|
650
|
+
let memories = Array.from(tableData.values()).filter(
|
|
651
|
+
(m) => m.worldId === params.worldId
|
|
652
|
+
);
|
|
601
653
|
if (params.count) {
|
|
602
654
|
memories = memories.slice(0, params.count);
|
|
603
655
|
}
|
|
@@ -635,6 +687,9 @@ class TestDatabaseManager {
|
|
|
635
687
|
};
|
|
636
688
|
return adapter;
|
|
637
689
|
}
|
|
690
|
+
/**
|
|
691
|
+
* Cleanup a specific test database
|
|
692
|
+
*/
|
|
638
693
|
async cleanupDatabase(testId) {
|
|
639
694
|
try {
|
|
640
695
|
const adapter = this.testDatabases.get(testId);
|
|
@@ -644,17 +699,27 @@ class TestDatabaseManager {
|
|
|
644
699
|
logger.debug(`Cleaned up database for ${testId}`);
|
|
645
700
|
}
|
|
646
701
|
} catch (error) {
|
|
647
|
-
logger.warn(
|
|
702
|
+
logger.warn(
|
|
703
|
+
`Error cleaning up database ${testId}: ${error instanceof Error ? error.message : String(error)}`
|
|
704
|
+
);
|
|
648
705
|
}
|
|
649
706
|
}
|
|
707
|
+
/**
|
|
708
|
+
* Cleanup all test databases
|
|
709
|
+
*/
|
|
650
710
|
async cleanup() {
|
|
651
711
|
logger.debug("Cleaning up all test databases");
|
|
652
|
-
const cleanupPromises = Array.from(this.testDatabases.keys()).map(
|
|
712
|
+
const cleanupPromises = Array.from(this.testDatabases.keys()).map(
|
|
713
|
+
(testId) => this.cleanupDatabase(testId)
|
|
714
|
+
);
|
|
653
715
|
await Promise.all(cleanupPromises);
|
|
654
716
|
this.tempPaths.clear();
|
|
655
717
|
this.testDatabases.clear();
|
|
656
718
|
logger.debug("Successfully cleaned up all test databases");
|
|
657
719
|
}
|
|
720
|
+
/**
|
|
721
|
+
* Get statistics about test databases
|
|
722
|
+
*/
|
|
658
723
|
getStats() {
|
|
659
724
|
return {
|
|
660
725
|
activeDatabases: this.testDatabases.size,
|
|
@@ -662,19 +727,18 @@ class TestDatabaseManager {
|
|
|
662
727
|
memoryUsage: `${Math.round(process.memoryUsage().heapUsed / 1024 / 1024)}MB`
|
|
663
728
|
};
|
|
664
729
|
}
|
|
665
|
-
}
|
|
730
|
+
};
|
|
666
731
|
async function createTestDatabase(testId) {
|
|
667
732
|
const actualTestId = testId || `test-${v4_default().slice(0, 8)}`;
|
|
668
|
-
const manager = new TestDatabaseManager;
|
|
733
|
+
const manager = new TestDatabaseManager();
|
|
669
734
|
const adapter = await manager.createIsolatedDatabase(actualTestId);
|
|
670
735
|
return { adapter, manager, testId: actualTestId };
|
|
671
736
|
}
|
|
672
737
|
|
|
673
738
|
// src/testModels.ts
|
|
674
739
|
import { logger as logger2 } from "@elizaos/core";
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
responses = new Map;
|
|
740
|
+
var TestModelProvider = class {
|
|
741
|
+
responses = /* @__PURE__ */ new Map();
|
|
678
742
|
patterns = [];
|
|
679
743
|
defaultResponse;
|
|
680
744
|
contextHistory = [];
|
|
@@ -682,8 +746,12 @@ class TestModelProvider {
|
|
|
682
746
|
this.defaultResponse = defaultResponse;
|
|
683
747
|
this.addDefaultPatterns();
|
|
684
748
|
}
|
|
749
|
+
/**
|
|
750
|
+
* Add realistic default response patterns
|
|
751
|
+
*/
|
|
685
752
|
addDefaultPatterns() {
|
|
686
753
|
const defaultPatterns = [
|
|
754
|
+
// Greeting patterns
|
|
687
755
|
{
|
|
688
756
|
pattern: /^(hello|hi|hey|greetings)/i,
|
|
689
757
|
response: "Hello! How can I help you today?"
|
|
@@ -692,6 +760,7 @@ class TestModelProvider {
|
|
|
692
760
|
pattern: /(good morning|good afternoon|good evening)/i,
|
|
693
761
|
response: "Good day! What can I assist you with?"
|
|
694
762
|
},
|
|
763
|
+
// Task creation patterns
|
|
695
764
|
{
|
|
696
765
|
pattern: /(create|add|make).*?(todo|task|reminder)/i,
|
|
697
766
|
response: "I'll create that task for you right away. Let me add it to your todo list."
|
|
@@ -700,6 +769,7 @@ class TestModelProvider {
|
|
|
700
769
|
pattern: /(schedule|plan|organize)/i,
|
|
701
770
|
response: "I'll help you schedule that. Let me organize this for you."
|
|
702
771
|
},
|
|
772
|
+
// Information requests
|
|
703
773
|
{
|
|
704
774
|
pattern: /(search|find|look|query).*?(for|about)/i,
|
|
705
775
|
response: "Let me search for that information. I'll look into it right away."
|
|
@@ -708,6 +778,7 @@ class TestModelProvider {
|
|
|
708
778
|
pattern: /(what|how|when|where|why)/i,
|
|
709
779
|
response: "Let me find that information for you. I'll provide a detailed answer."
|
|
710
780
|
},
|
|
781
|
+
// Analysis and review
|
|
711
782
|
{
|
|
712
783
|
pattern: /(analyze|review|examine|check)/i,
|
|
713
784
|
response: "I'll analyze this carefully and provide my assessment with detailed insights."
|
|
@@ -716,6 +787,7 @@ class TestModelProvider {
|
|
|
716
787
|
pattern: /(explain|describe|tell me about)/i,
|
|
717
788
|
response: "I'll explain that in detail for you. Here's what you need to know."
|
|
718
789
|
},
|
|
790
|
+
// Action requests
|
|
719
791
|
{
|
|
720
792
|
pattern: /(send|email|message|notify)/i,
|
|
721
793
|
response: "I'll send that message for you. Let me take care of the communication."
|
|
@@ -724,6 +796,7 @@ class TestModelProvider {
|
|
|
724
796
|
pattern: /(delete|remove|cancel)/i,
|
|
725
797
|
response: "I'll remove that for you. Let me handle the deletion safely."
|
|
726
798
|
},
|
|
799
|
+
// File and data operations
|
|
727
800
|
{
|
|
728
801
|
pattern: /(save|store|backup)/i,
|
|
729
802
|
response: "I'll save that information securely. Your data will be stored properly."
|
|
@@ -732,6 +805,7 @@ class TestModelProvider {
|
|
|
732
805
|
pattern: /(load|open|access)/i,
|
|
733
806
|
response: "I'll access that resource for you. Let me retrieve the information."
|
|
734
807
|
},
|
|
808
|
+
// Problem solving
|
|
735
809
|
{
|
|
736
810
|
pattern: /(fix|repair|solve|troubleshoot)/i,
|
|
737
811
|
response: "I'll help troubleshoot this issue. Let me analyze the problem and find a solution."
|
|
@@ -740,6 +814,7 @@ class TestModelProvider {
|
|
|
740
814
|
pattern: /(help|assist|support)/i,
|
|
741
815
|
response: "I'm here to help! Let me assist you with whatever you need."
|
|
742
816
|
},
|
|
817
|
+
// Decision making
|
|
743
818
|
{
|
|
744
819
|
pattern: /(should|recommend|suggest|advise)/i,
|
|
745
820
|
response: "Based on the information provided, I'd recommend the following approach."
|
|
@@ -748,6 +823,7 @@ class TestModelProvider {
|
|
|
748
823
|
pattern: /(choose|select|decide)/i,
|
|
749
824
|
response: "Let me help you make that decision. Here are the key factors to consider."
|
|
750
825
|
},
|
|
826
|
+
// Confirmation and acknowledgment
|
|
751
827
|
{
|
|
752
828
|
pattern: /(yes|ok|okay|sure|agreed)/i,
|
|
753
829
|
response: "Understood! I'll proceed with that as requested."
|
|
@@ -756,6 +832,7 @@ class TestModelProvider {
|
|
|
756
832
|
pattern: /(no|stop|cancel|abort)/i,
|
|
757
833
|
response: "Alright, I'll stop that process. Is there anything else I can help with?"
|
|
758
834
|
},
|
|
835
|
+
// Complex reasoning patterns
|
|
759
836
|
{
|
|
760
837
|
pattern: /(if.*then|because|therefore|since)/i,
|
|
761
838
|
response: "I understand the logic. Let me work through this step by step."
|
|
@@ -764,6 +841,7 @@ class TestModelProvider {
|
|
|
764
841
|
pattern: /(compare|contrast|difference|similar)/i,
|
|
765
842
|
response: "I'll compare these options and highlight the key differences and similarities."
|
|
766
843
|
},
|
|
844
|
+
// Error handling
|
|
767
845
|
{
|
|
768
846
|
pattern: /(error|problem|issue|broken|failed)/i,
|
|
769
847
|
response: "I see there's an issue. Let me investigate the problem and find a solution."
|
|
@@ -771,6 +849,9 @@ class TestModelProvider {
|
|
|
771
849
|
];
|
|
772
850
|
this.patterns.push(...defaultPatterns);
|
|
773
851
|
}
|
|
852
|
+
/**
|
|
853
|
+
* Generate text response based on prompt
|
|
854
|
+
*/
|
|
774
855
|
async generateText(params) {
|
|
775
856
|
const prompt = params.prompt;
|
|
776
857
|
try {
|
|
@@ -790,20 +871,28 @@ class TestModelProvider {
|
|
|
790
871
|
this.addToHistory(prompt, intelligentResponse);
|
|
791
872
|
return intelligentResponse;
|
|
792
873
|
} catch (error) {
|
|
793
|
-
logger2.warn(
|
|
874
|
+
logger2.warn(
|
|
875
|
+
`Error in test model provider: ${error instanceof Error ? error.message : String(error)}`
|
|
876
|
+
);
|
|
794
877
|
return this.defaultResponse;
|
|
795
878
|
}
|
|
796
879
|
}
|
|
880
|
+
/**
|
|
881
|
+
* Generate embeddings for text (mock implementation with consistent vectors)
|
|
882
|
+
*/
|
|
797
883
|
async generateEmbedding(params) {
|
|
798
884
|
const text = params.text;
|
|
799
885
|
const hash = this.simpleHash(text);
|
|
800
886
|
const embedding = [];
|
|
801
|
-
for (let i = 0;i < 1536; i++) {
|
|
887
|
+
for (let i = 0; i < 1536; i++) {
|
|
802
888
|
const value = Math.sin(hash + i) * 0.5;
|
|
803
889
|
embedding.push(value);
|
|
804
890
|
}
|
|
805
891
|
return embedding;
|
|
806
892
|
}
|
|
893
|
+
/**
|
|
894
|
+
* Generate object-structured responses
|
|
895
|
+
*/
|
|
807
896
|
async generateObject(params) {
|
|
808
897
|
const prompt = params.prompt;
|
|
809
898
|
if (prompt.includes("thought") || prompt.includes("reasoning")) {
|
|
@@ -836,14 +925,23 @@ class TestModelProvider {
|
|
|
836
925
|
}
|
|
837
926
|
};
|
|
838
927
|
}
|
|
928
|
+
/**
|
|
929
|
+
* Make response more contextual based on prompt content
|
|
930
|
+
*/
|
|
839
931
|
makeContextual(response, prompt) {
|
|
840
932
|
const keyTerms = this.extractKeyTerms(prompt);
|
|
841
933
|
if (keyTerms.length > 0) {
|
|
842
934
|
const term = keyTerms[0];
|
|
843
|
-
return response.replace(
|
|
935
|
+
return response.replace(
|
|
936
|
+
/that|this|it/g,
|
|
937
|
+
term.length > 20 ? `that ${term.substring(0, 20)}...` : `that ${term}`
|
|
938
|
+
);
|
|
844
939
|
}
|
|
845
940
|
return response;
|
|
846
941
|
}
|
|
942
|
+
/**
|
|
943
|
+
* Generate intelligent default response based on prompt analysis
|
|
944
|
+
*/
|
|
847
945
|
generateIntelligentDefault(prompt) {
|
|
848
946
|
const lowerPrompt = prompt.toLowerCase();
|
|
849
947
|
if (lowerPrompt.includes("?")) {
|
|
@@ -860,8 +958,11 @@ class TestModelProvider {
|
|
|
860
958
|
}
|
|
861
959
|
return this.defaultResponse;
|
|
862
960
|
}
|
|
961
|
+
/**
|
|
962
|
+
* Extract key terms from prompt for contextualization
|
|
963
|
+
*/
|
|
863
964
|
extractKeyTerms(prompt) {
|
|
864
|
-
const commonWords = new Set([
|
|
965
|
+
const commonWords = /* @__PURE__ */ new Set([
|
|
865
966
|
"the",
|
|
866
967
|
"a",
|
|
867
968
|
"an",
|
|
@@ -912,43 +1013,64 @@ class TestModelProvider {
|
|
|
912
1013
|
const words = prompt.toLowerCase().replace(/[^\w\s]/g, " ").split(/\s+/).filter((word) => word.length > 2 && !commonWords.has(word));
|
|
913
1014
|
return [...new Set(words)].slice(0, 3);
|
|
914
1015
|
}
|
|
1016
|
+
/**
|
|
1017
|
+
* Simple hash function for deterministic embeddings
|
|
1018
|
+
*/
|
|
915
1019
|
simpleHash(str) {
|
|
916
1020
|
let hash = 0;
|
|
917
|
-
for (let i = 0;i < str.length; i++) {
|
|
1021
|
+
for (let i = 0; i < str.length; i++) {
|
|
918
1022
|
const char = str.charCodeAt(i);
|
|
919
1023
|
hash = (hash << 5) - hash + char;
|
|
920
1024
|
hash = hash & hash;
|
|
921
1025
|
}
|
|
922
1026
|
return Math.abs(hash);
|
|
923
1027
|
}
|
|
1028
|
+
/**
|
|
1029
|
+
* Add interaction to context history
|
|
1030
|
+
*/
|
|
924
1031
|
addToHistory(prompt, response) {
|
|
925
1032
|
this.contextHistory.push({ prompt, response });
|
|
926
1033
|
if (this.contextHistory.length > 10) {
|
|
927
1034
|
this.contextHistory.shift();
|
|
928
1035
|
}
|
|
929
1036
|
}
|
|
1037
|
+
/**
|
|
1038
|
+
* Set a specific response for a prompt
|
|
1039
|
+
*/
|
|
930
1040
|
setResponse(prompt, response) {
|
|
931
1041
|
this.responses.set(prompt, response);
|
|
932
1042
|
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Add a pattern-based response
|
|
1045
|
+
*/
|
|
933
1046
|
addPattern(pattern, response) {
|
|
934
1047
|
this.patterns.unshift({ pattern, response });
|
|
935
1048
|
}
|
|
1049
|
+
/**
|
|
1050
|
+
* Set the default response
|
|
1051
|
+
*/
|
|
936
1052
|
setDefaultResponse(response) {
|
|
937
1053
|
this.defaultResponse = response;
|
|
938
1054
|
}
|
|
1055
|
+
/**
|
|
1056
|
+
* Clear all custom responses and patterns
|
|
1057
|
+
*/
|
|
939
1058
|
clear() {
|
|
940
1059
|
this.responses.clear();
|
|
941
1060
|
this.patterns.length = 0;
|
|
942
1061
|
this.contextHistory.length = 0;
|
|
943
1062
|
this.addDefaultPatterns();
|
|
944
1063
|
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Get conversation history
|
|
1066
|
+
*/
|
|
945
1067
|
getHistory() {
|
|
946
1068
|
return [...this.contextHistory];
|
|
947
1069
|
}
|
|
948
|
-
}
|
|
949
|
-
function createTestModelProvider(
|
|
1070
|
+
};
|
|
1071
|
+
function createTestModelProvider(scenarios2 = [], defaultResponse) {
|
|
950
1072
|
const provider = new TestModelProvider(defaultResponse);
|
|
951
|
-
for (const scenario of
|
|
1073
|
+
for (const scenario of scenarios2) {
|
|
952
1074
|
if (scenario.prompt instanceof RegExp) {
|
|
953
1075
|
provider.addPattern(scenario.prompt, scenario.response);
|
|
954
1076
|
} else {
|
|
@@ -958,19 +1080,31 @@ function createTestModelProvider(scenarios = [], defaultResponse) {
|
|
|
958
1080
|
return provider;
|
|
959
1081
|
}
|
|
960
1082
|
function createSpecializedModelProvider(type) {
|
|
961
|
-
const provider = new TestModelProvider;
|
|
1083
|
+
const provider = new TestModelProvider();
|
|
962
1084
|
switch (type) {
|
|
963
1085
|
case "conversational":
|
|
964
|
-
provider.addPattern(
|
|
1086
|
+
provider.addPattern(
|
|
1087
|
+
/.*/,
|
|
1088
|
+
"That's interesting! Let me respond thoughtfully to what you've shared."
|
|
1089
|
+
);
|
|
965
1090
|
break;
|
|
966
1091
|
case "analytical":
|
|
967
|
-
provider.addPattern(
|
|
1092
|
+
provider.addPattern(
|
|
1093
|
+
/.*/,
|
|
1094
|
+
"Let me analyze this systematically. Based on the data and context provided, here's my assessment."
|
|
1095
|
+
);
|
|
968
1096
|
break;
|
|
969
1097
|
case "creative":
|
|
970
|
-
provider.addPattern(
|
|
1098
|
+
provider.addPattern(
|
|
1099
|
+
/.*/,
|
|
1100
|
+
"What a creative challenge! Let me think outside the box and explore innovative possibilities."
|
|
1101
|
+
);
|
|
971
1102
|
break;
|
|
972
1103
|
case "factual":
|
|
973
|
-
provider.addPattern(
|
|
1104
|
+
provider.addPattern(
|
|
1105
|
+
/.*/,
|
|
1106
|
+
"Based on factual information and established knowledge, here's an accurate response."
|
|
1107
|
+
);
|
|
974
1108
|
break;
|
|
975
1109
|
}
|
|
976
1110
|
return provider;
|
|
@@ -992,8 +1126,7 @@ function createModelHandler(provider) {
|
|
|
992
1126
|
}
|
|
993
1127
|
};
|
|
994
1128
|
}
|
|
995
|
-
|
|
996
|
-
class TestScenarioBuilder {
|
|
1129
|
+
var TestScenarioBuilder = class {
|
|
997
1130
|
scenarios = [];
|
|
998
1131
|
addGreeting(response = "Hello! How can I help you?") {
|
|
999
1132
|
this.scenarios.push({
|
|
@@ -1023,24 +1156,30 @@ class TestScenarioBuilder {
|
|
|
1023
1156
|
build(defaultResponse) {
|
|
1024
1157
|
return createTestModelProvider(this.scenarios, defaultResponse);
|
|
1025
1158
|
}
|
|
1026
|
-
}
|
|
1159
|
+
};
|
|
1027
1160
|
function scenarios() {
|
|
1028
|
-
return new TestScenarioBuilder;
|
|
1161
|
+
return new TestScenarioBuilder();
|
|
1029
1162
|
}
|
|
1030
1163
|
|
|
1031
1164
|
// src/realRuntime.ts
|
|
1032
|
-
|
|
1033
|
-
runtimes = new Map;
|
|
1165
|
+
var RuntimeTestHarness = class {
|
|
1166
|
+
runtimes = /* @__PURE__ */ new Map();
|
|
1034
1167
|
databaseManager;
|
|
1035
1168
|
testId;
|
|
1036
1169
|
constructor(testId) {
|
|
1037
1170
|
this.testId = testId || `test-${v4_default().slice(0, 8)}`;
|
|
1038
|
-
this.databaseManager = new TestDatabaseManager;
|
|
1171
|
+
this.databaseManager = new TestDatabaseManager();
|
|
1039
1172
|
}
|
|
1173
|
+
/**
|
|
1174
|
+
* Creates an AgentRuntime instance for testing
|
|
1175
|
+
* This uses the standard AgentRuntime - it will actually execute all functionality
|
|
1176
|
+
*/
|
|
1040
1177
|
async createTestRuntime(config) {
|
|
1041
1178
|
try {
|
|
1042
1179
|
logger3.info(`Creating real test runtime for ${this.testId}`);
|
|
1043
|
-
const databaseAdapter = await this.databaseManager.createIsolatedDatabase(
|
|
1180
|
+
const databaseAdapter = await this.databaseManager.createIsolatedDatabase(
|
|
1181
|
+
`${this.testId}-${Date.now()}`
|
|
1182
|
+
);
|
|
1044
1183
|
const runtime = new AgentRuntime({
|
|
1045
1184
|
character: config.character,
|
|
1046
1185
|
adapter: databaseAdapter
|
|
@@ -1058,10 +1197,18 @@ class RuntimeTestHarness {
|
|
|
1058
1197
|
logger3.info(`Successfully created real runtime ${runtime.agentId}`);
|
|
1059
1198
|
return runtime;
|
|
1060
1199
|
} catch (error) {
|
|
1061
|
-
logger3.error(
|
|
1062
|
-
|
|
1200
|
+
logger3.error(
|
|
1201
|
+
`Failed to create test runtime: ${error instanceof Error ? error.message : String(error)}`
|
|
1202
|
+
);
|
|
1203
|
+
throw new Error(
|
|
1204
|
+
`Test runtime creation failed: ${error instanceof Error ? error.message : String(error)}`
|
|
1205
|
+
);
|
|
1063
1206
|
}
|
|
1064
1207
|
}
|
|
1208
|
+
/**
|
|
1209
|
+
* Loads a plugin by name from the ElizaOS ecosystem
|
|
1210
|
+
* Uses dynamic imports to avoid circular dependencies during build
|
|
1211
|
+
*/
|
|
1065
1212
|
async loadPlugin(pluginName) {
|
|
1066
1213
|
try {
|
|
1067
1214
|
logger3.info(`Attempting to load plugin: ${pluginName}`);
|
|
@@ -1069,7 +1216,9 @@ class RuntimeTestHarness {
|
|
|
1069
1216
|
try {
|
|
1070
1217
|
pluginModule = await import(pluginName);
|
|
1071
1218
|
} catch (importError) {
|
|
1072
|
-
logger3.warn(
|
|
1219
|
+
logger3.warn(
|
|
1220
|
+
`Could not import ${pluginName}: ${importError instanceof Error ? importError.message : String(importError)}`
|
|
1221
|
+
);
|
|
1073
1222
|
throw importError;
|
|
1074
1223
|
}
|
|
1075
1224
|
const plugin = pluginModule.default || pluginModule[Object.keys(pluginModule)[0]];
|
|
@@ -1079,10 +1228,17 @@ class RuntimeTestHarness {
|
|
|
1079
1228
|
logger3.info(`Successfully loaded plugin: ${pluginName}`);
|
|
1080
1229
|
return plugin;
|
|
1081
1230
|
} catch (error) {
|
|
1082
|
-
logger3.error(
|
|
1083
|
-
|
|
1231
|
+
logger3.error(
|
|
1232
|
+
`Failed to load plugin ${pluginName}: ${error instanceof Error ? error.message : String(error)}`
|
|
1233
|
+
);
|
|
1234
|
+
throw new Error(
|
|
1235
|
+
`Plugin ${pluginName} must be available for testing. Install it before running tests. Error: ${error instanceof Error ? error.message : String(error)}`
|
|
1236
|
+
);
|
|
1084
1237
|
}
|
|
1085
1238
|
}
|
|
1239
|
+
/**
|
|
1240
|
+
* Creates a test model provider that gives realistic responses
|
|
1241
|
+
*/
|
|
1086
1242
|
createRealisticModelProvider(scenarios2) {
|
|
1087
1243
|
const defaultScenarios = [
|
|
1088
1244
|
{
|
|
@@ -1104,6 +1260,9 @@ class RuntimeTestHarness {
|
|
|
1104
1260
|
];
|
|
1105
1261
|
return createTestModelProvider(scenarios2 || defaultScenarios);
|
|
1106
1262
|
}
|
|
1263
|
+
/**
|
|
1264
|
+
* Executes a real message processing test
|
|
1265
|
+
*/
|
|
1107
1266
|
async processTestMessage(runtime, messageText, options = {}) {
|
|
1108
1267
|
const startTime = Date.now();
|
|
1109
1268
|
const roomId = options.roomId || stringToUuid(`test-room-${v4_default()}`);
|
|
@@ -1120,7 +1279,7 @@ class RuntimeTestHarness {
|
|
|
1120
1279
|
createdAt: Date.now()
|
|
1121
1280
|
};
|
|
1122
1281
|
const _messageId = await runtime.createMemory(memory, "messages");
|
|
1123
|
-
const responses = await runtime.processActions(memory, [],
|
|
1282
|
+
const responses = await runtime.processActions(memory, [], void 0, void 0);
|
|
1124
1283
|
const responseTime = Date.now() - startTime;
|
|
1125
1284
|
const result = {
|
|
1126
1285
|
scenarioName: `Process: "${messageText}"`,
|
|
@@ -1132,7 +1291,9 @@ class RuntimeTestHarness {
|
|
|
1132
1291
|
};
|
|
1133
1292
|
if (options.expectedActions && options.expectedActions.length > 0) {
|
|
1134
1293
|
const executedActions = await this.getExecutedActions(runtime, roomId);
|
|
1135
|
-
const missingActions = options.expectedActions.filter(
|
|
1294
|
+
const missingActions = options.expectedActions.filter(
|
|
1295
|
+
(action) => !executedActions.includes(action)
|
|
1296
|
+
);
|
|
1136
1297
|
if (missingActions.length > 0) {
|
|
1137
1298
|
result.passed = false;
|
|
1138
1299
|
result.errors.push(`Missing expected actions: ${missingActions.join(", ")}`);
|
|
@@ -1141,7 +1302,9 @@ class RuntimeTestHarness {
|
|
|
1141
1302
|
}
|
|
1142
1303
|
if (options.timeoutMs && responseTime > options.timeoutMs) {
|
|
1143
1304
|
result.passed = false;
|
|
1144
|
-
result.errors.push(
|
|
1305
|
+
result.errors.push(
|
|
1306
|
+
`Response time ${responseTime}ms exceeded timeout ${options.timeoutMs}ms`
|
|
1307
|
+
);
|
|
1145
1308
|
}
|
|
1146
1309
|
return result;
|
|
1147
1310
|
} catch (error) {
|
|
@@ -1155,6 +1318,9 @@ class RuntimeTestHarness {
|
|
|
1155
1318
|
};
|
|
1156
1319
|
}
|
|
1157
1320
|
}
|
|
1321
|
+
/**
|
|
1322
|
+
* Gets actions that were actually executed (not mocked)
|
|
1323
|
+
*/
|
|
1158
1324
|
async getExecutedActions(runtime, roomId) {
|
|
1159
1325
|
try {
|
|
1160
1326
|
const memories = await runtime.getMemories({
|
|
@@ -1170,10 +1336,15 @@ class RuntimeTestHarness {
|
|
|
1170
1336
|
}
|
|
1171
1337
|
return [...new Set(actions)];
|
|
1172
1338
|
} catch (error) {
|
|
1173
|
-
logger3.warn(
|
|
1339
|
+
logger3.warn(
|
|
1340
|
+
`Could not retrieve executed actions: ${error instanceof Error ? error.message : String(error)}`
|
|
1341
|
+
);
|
|
1174
1342
|
return [];
|
|
1175
1343
|
}
|
|
1176
1344
|
}
|
|
1345
|
+
/**
|
|
1346
|
+
* Validates that a runtime is actually functional
|
|
1347
|
+
*/
|
|
1177
1348
|
async validateRuntimeHealth(runtime) {
|
|
1178
1349
|
const issues = [];
|
|
1179
1350
|
const services = [];
|
|
@@ -1195,10 +1366,12 @@ class RuntimeTestHarness {
|
|
|
1195
1366
|
};
|
|
1196
1367
|
await runtime.createMemory(healthMemory, "test");
|
|
1197
1368
|
} catch (error) {
|
|
1198
|
-
issues.push(
|
|
1369
|
+
issues.push(
|
|
1370
|
+
`Database not functional: ${error instanceof Error ? error.message : String(error)}`
|
|
1371
|
+
);
|
|
1199
1372
|
}
|
|
1200
1373
|
try {
|
|
1201
|
-
const serviceMap = runtime.services || new Map;
|
|
1374
|
+
const serviceMap = runtime.services || /* @__PURE__ */ new Map();
|
|
1202
1375
|
for (const [name, service] of serviceMap) {
|
|
1203
1376
|
services.push(name);
|
|
1204
1377
|
if (!service) {
|
|
@@ -1206,12 +1379,16 @@ class RuntimeTestHarness {
|
|
|
1206
1379
|
}
|
|
1207
1380
|
}
|
|
1208
1381
|
} catch (error) {
|
|
1209
|
-
issues.push(
|
|
1382
|
+
issues.push(
|
|
1383
|
+
`Services not accessible: ${error instanceof Error ? error.message : String(error)}`
|
|
1384
|
+
);
|
|
1210
1385
|
}
|
|
1211
1386
|
try {
|
|
1212
1387
|
plugins.push(...runtime.plugins?.map((p) => p.name) || []);
|
|
1213
1388
|
} catch (error) {
|
|
1214
|
-
issues.push(
|
|
1389
|
+
issues.push(
|
|
1390
|
+
`Plugins not accessible: ${error instanceof Error ? error.message : String(error)}`
|
|
1391
|
+
);
|
|
1215
1392
|
}
|
|
1216
1393
|
return {
|
|
1217
1394
|
healthy: issues.length === 0,
|
|
@@ -1230,6 +1407,9 @@ class RuntimeTestHarness {
|
|
|
1230
1407
|
};
|
|
1231
1408
|
}
|
|
1232
1409
|
}
|
|
1410
|
+
/**
|
|
1411
|
+
* Cleanup all test resources
|
|
1412
|
+
*/
|
|
1233
1413
|
async cleanup() {
|
|
1234
1414
|
try {
|
|
1235
1415
|
logger3.info(`Cleaning up test harness ${this.testId}`);
|
|
@@ -1238,20 +1418,24 @@ class RuntimeTestHarness {
|
|
|
1238
1418
|
await runtime.stop();
|
|
1239
1419
|
logger3.debug(`Stopped runtime ${runtimeId}`);
|
|
1240
1420
|
} catch (error) {
|
|
1241
|
-
logger3.warn(
|
|
1421
|
+
logger3.warn(
|
|
1422
|
+
`Error stopping runtime ${runtimeId}: ${error instanceof Error ? error.message : String(error)}`
|
|
1423
|
+
);
|
|
1242
1424
|
}
|
|
1243
1425
|
}
|
|
1244
1426
|
this.runtimes.clear();
|
|
1245
1427
|
await this.databaseManager.cleanup();
|
|
1246
1428
|
logger3.info(`Successfully cleaned up test harness ${this.testId}`);
|
|
1247
1429
|
} catch (error) {
|
|
1248
|
-
logger3.error(
|
|
1430
|
+
logger3.error(
|
|
1431
|
+
`Error during cleanup: ${error instanceof Error ? error.message : String(error)}`
|
|
1432
|
+
);
|
|
1249
1433
|
throw error;
|
|
1250
1434
|
}
|
|
1251
1435
|
}
|
|
1252
|
-
}
|
|
1436
|
+
};
|
|
1253
1437
|
async function createTestRuntime(config = {}) {
|
|
1254
|
-
const harness = new RuntimeTestHarness;
|
|
1438
|
+
const harness = new RuntimeTestHarness();
|
|
1255
1439
|
const defaultCharacter = {
|
|
1256
1440
|
name: "TestAgent",
|
|
1257
1441
|
system: "You are a helpful test agent.",
|
|
@@ -1300,9 +1484,10 @@ async function runIntegrationTest(testName, testFn, config) {
|
|
|
1300
1484
|
}
|
|
1301
1485
|
}
|
|
1302
1486
|
}
|
|
1487
|
+
|
|
1303
1488
|
// src/templates.ts
|
|
1304
1489
|
import { logger as logger4 } from "@elizaos/core";
|
|
1305
|
-
|
|
1490
|
+
var TestTemplate = class {
|
|
1306
1491
|
config;
|
|
1307
1492
|
runtime;
|
|
1308
1493
|
constructor(config) {
|
|
@@ -1324,9 +1509,8 @@ class TestTemplate {
|
|
|
1324
1509
|
getConfig() {
|
|
1325
1510
|
return this.config;
|
|
1326
1511
|
}
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
class UnitTestTemplate extends TestTemplate {
|
|
1512
|
+
};
|
|
1513
|
+
var UnitTestTemplate = class extends TestTemplate {
|
|
1330
1514
|
testFunction;
|
|
1331
1515
|
constructor(config, testFunction) {
|
|
1332
1516
|
super(config);
|
|
@@ -1361,9 +1545,8 @@ class UnitTestTemplate extends TestTemplate {
|
|
|
1361
1545
|
await this.teardown();
|
|
1362
1546
|
}
|
|
1363
1547
|
}
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
class IntegrationTestTemplate extends TestTemplate {
|
|
1548
|
+
};
|
|
1549
|
+
var IntegrationTestTemplate = class extends TestTemplate {
|
|
1367
1550
|
testFunction;
|
|
1368
1551
|
character;
|
|
1369
1552
|
constructor(config, testFunction, character) {
|
|
@@ -1404,9 +1587,8 @@ class IntegrationTestTemplate extends TestTemplate {
|
|
|
1404
1587
|
await this.teardown();
|
|
1405
1588
|
}
|
|
1406
1589
|
}
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1409
|
-
class PluginTestTemplate extends TestTemplate {
|
|
1590
|
+
};
|
|
1591
|
+
var PluginTestTemplate = class extends TestTemplate {
|
|
1410
1592
|
plugin;
|
|
1411
1593
|
testFunction;
|
|
1412
1594
|
constructor(config, plugin, testFunction) {
|
|
@@ -1451,9 +1633,8 @@ class PluginTestTemplate extends TestTemplate {
|
|
|
1451
1633
|
await this.teardown();
|
|
1452
1634
|
}
|
|
1453
1635
|
}
|
|
1454
|
-
}
|
|
1455
|
-
|
|
1456
|
-
class ErrorTestTemplate extends TestTemplate {
|
|
1636
|
+
};
|
|
1637
|
+
var ErrorTestTemplate = class extends TestTemplate {
|
|
1457
1638
|
testFunction;
|
|
1458
1639
|
expectedError;
|
|
1459
1640
|
constructor(config, testFunction, expectedError) {
|
|
@@ -1486,15 +1667,14 @@ class ErrorTestTemplate extends TestTemplate {
|
|
|
1486
1667
|
name: this.config.name,
|
|
1487
1668
|
passed,
|
|
1488
1669
|
duration: Date.now() - startTime,
|
|
1489
|
-
error: passed ?
|
|
1670
|
+
error: passed ? void 0 : error instanceof Error ? error : new Error(String(error))
|
|
1490
1671
|
};
|
|
1491
1672
|
} finally {
|
|
1492
1673
|
await this.teardown();
|
|
1493
1674
|
}
|
|
1494
1675
|
}
|
|
1495
|
-
}
|
|
1496
|
-
|
|
1497
|
-
class PerformanceTestTemplate extends TestTemplate {
|
|
1676
|
+
};
|
|
1677
|
+
var PerformanceTestTemplate = class extends TestTemplate {
|
|
1498
1678
|
testFunction;
|
|
1499
1679
|
maxDuration;
|
|
1500
1680
|
maxMemoryMB;
|
|
@@ -1527,7 +1707,9 @@ class PerformanceTestTemplate extends TestTemplate {
|
|
|
1527
1707
|
passed = false;
|
|
1528
1708
|
}
|
|
1529
1709
|
if (memoryUsed > this.maxMemoryMB) {
|
|
1530
|
-
warnings.push(
|
|
1710
|
+
warnings.push(
|
|
1711
|
+
`Test exceeded max memory: ${memoryUsed.toFixed(2)}MB > ${this.maxMemoryMB}MB`
|
|
1712
|
+
);
|
|
1531
1713
|
passed = false;
|
|
1532
1714
|
}
|
|
1533
1715
|
return {
|
|
@@ -1552,9 +1734,8 @@ class PerformanceTestTemplate extends TestTemplate {
|
|
|
1552
1734
|
await this.teardown();
|
|
1553
1735
|
}
|
|
1554
1736
|
}
|
|
1555
|
-
}
|
|
1556
|
-
|
|
1557
|
-
class TestSuite {
|
|
1737
|
+
};
|
|
1738
|
+
var TestSuite = class {
|
|
1558
1739
|
tests = [];
|
|
1559
1740
|
name;
|
|
1560
1741
|
constructor(name) {
|
|
@@ -1572,9 +1753,9 @@ class TestSuite {
|
|
|
1572
1753
|
const result = await test.execute();
|
|
1573
1754
|
results.push(result);
|
|
1574
1755
|
if (result.passed) {
|
|
1575
|
-
logger4.info(
|
|
1756
|
+
logger4.info(`\u2713 ${result.name} (${result.duration}ms)`);
|
|
1576
1757
|
} else {
|
|
1577
|
-
logger4.error(
|
|
1758
|
+
logger4.error(`\u2717 ${result.name} (${result.duration}ms): ${result.error?.message}`);
|
|
1578
1759
|
}
|
|
1579
1760
|
} catch (error) {
|
|
1580
1761
|
const errorResult = {
|
|
@@ -1584,13 +1765,15 @@ class TestSuite {
|
|
|
1584
1765
|
error: error instanceof Error ? error : new Error(String(error))
|
|
1585
1766
|
};
|
|
1586
1767
|
results.push(errorResult);
|
|
1587
|
-
logger4.error(
|
|
1768
|
+
logger4.error(`\u2717 ${errorResult.name}: ${errorResult.error?.message}`);
|
|
1588
1769
|
}
|
|
1589
1770
|
}
|
|
1590
1771
|
const passed = results.filter((r) => r.passed).length;
|
|
1591
1772
|
const failed = results.length - passed;
|
|
1592
1773
|
const duration = Date.now() - startTime;
|
|
1593
|
-
logger4.info(
|
|
1774
|
+
logger4.info(
|
|
1775
|
+
`Test suite ${this.name} completed: ${passed}/${results.length} passed (${duration}ms)`
|
|
1776
|
+
);
|
|
1594
1777
|
return {
|
|
1595
1778
|
suiteName: this.name,
|
|
1596
1779
|
totalTests: results.length,
|
|
@@ -1600,24 +1783,28 @@ class TestSuite {
|
|
|
1600
1783
|
results
|
|
1601
1784
|
};
|
|
1602
1785
|
}
|
|
1603
|
-
}
|
|
1786
|
+
};
|
|
1604
1787
|
function createUnitTest(name, testFunction, options = {}) {
|
|
1605
|
-
return new UnitTestTemplate({ name, timeout:
|
|
1788
|
+
return new UnitTestTemplate({ name, timeout: 5e3, ...options }, testFunction);
|
|
1606
1789
|
}
|
|
1607
1790
|
function createIntegrationTest(name, testFunction, character, options = {}) {
|
|
1608
|
-
return new IntegrationTestTemplate({ name, timeout:
|
|
1791
|
+
return new IntegrationTestTemplate({ name, timeout: 3e4, ...options }, testFunction, character);
|
|
1609
1792
|
}
|
|
1610
1793
|
function createPluginTest(name, plugin, testFunction, options = {}) {
|
|
1611
|
-
return new PluginTestTemplate({ name, timeout:
|
|
1794
|
+
return new PluginTestTemplate({ name, timeout: 3e4, ...options }, plugin, testFunction);
|
|
1612
1795
|
}
|
|
1613
1796
|
function createErrorTest(name, testFunction, expectedError, options = {}) {
|
|
1614
|
-
return new ErrorTestTemplate({ name, timeout:
|
|
1797
|
+
return new ErrorTestTemplate({ name, timeout: 5e3, ...options }, testFunction, expectedError);
|
|
1615
1798
|
}
|
|
1616
1799
|
function createPerformanceTest(name, testFunction, maxDurationMs, maxMemoryMB, options = {}) {
|
|
1617
|
-
return new PerformanceTestTemplate(
|
|
1618
|
-
}
|
|
1619
|
-
|
|
1620
|
-
|
|
1800
|
+
return new PerformanceTestTemplate(
|
|
1801
|
+
{ name, timeout: maxDurationMs * 2, ...options },
|
|
1802
|
+
testFunction,
|
|
1803
|
+
maxDurationMs,
|
|
1804
|
+
maxMemoryMB
|
|
1805
|
+
);
|
|
1806
|
+
}
|
|
1807
|
+
var TestDataGenerator = class {
|
|
1621
1808
|
static generateUUID() {
|
|
1622
1809
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
1623
1810
|
const r = Math.random() * 16 | 0;
|
|
@@ -1652,7 +1839,8 @@ class TestDataGenerator {
|
|
|
1652
1839
|
...overrides
|
|
1653
1840
|
};
|
|
1654
1841
|
}
|
|
1655
|
-
}
|
|
1842
|
+
};
|
|
1843
|
+
|
|
1656
1844
|
// src/mocks/mockUtils.ts
|
|
1657
1845
|
function mock(implementation) {
|
|
1658
1846
|
const calls = [];
|
|
@@ -1736,25 +1924,28 @@ function createMockRuntime(overrides = {}) {
|
|
|
1736
1924
|
get: mock().mockResolvedValue(null)
|
|
1737
1925
|
};
|
|
1738
1926
|
const baseRuntime = {
|
|
1927
|
+
// Core Properties
|
|
1739
1928
|
agentId: "test-agent-id",
|
|
1740
1929
|
character: overrides.character || defaultCharacter,
|
|
1741
1930
|
providers: overrides.providers || [],
|
|
1742
1931
|
actions: overrides.actions || [],
|
|
1743
1932
|
evaluators: overrides.evaluators || [],
|
|
1744
1933
|
plugins: overrides.plugins || [],
|
|
1745
|
-
services: overrides.services || new Map,
|
|
1746
|
-
events: overrides.events || new Map,
|
|
1934
|
+
services: overrides.services || /* @__PURE__ */ new Map(),
|
|
1935
|
+
events: overrides.events || /* @__PURE__ */ new Map(),
|
|
1747
1936
|
fetch: overrides.fetch || null,
|
|
1748
1937
|
routes: overrides.routes || [],
|
|
1749
1938
|
logger: overrides.logger || console,
|
|
1939
|
+
// Database Properties
|
|
1750
1940
|
db: overrides.db || mockDb,
|
|
1751
|
-
|
|
1752
|
-
|
|
1941
|
+
// Core Runtime Methods
|
|
1942
|
+
registerPlugin: mock().mockResolvedValue(void 0),
|
|
1943
|
+
initialize: mock().mockResolvedValue(void 0),
|
|
1753
1944
|
getConnection: mock().mockResolvedValue(mockDb),
|
|
1754
1945
|
getService: mock().mockReturnValue(null),
|
|
1755
1946
|
getServicesByType: mock().mockReturnValue([]),
|
|
1756
|
-
getAllServices: mock().mockReturnValue(new Map),
|
|
1757
|
-
registerService: mock().mockResolvedValue(
|
|
1947
|
+
getAllServices: mock().mockReturnValue(/* @__PURE__ */ new Map()),
|
|
1948
|
+
registerService: mock().mockResolvedValue(void 0),
|
|
1758
1949
|
getServiceLoadPromise: mock().mockResolvedValue(null),
|
|
1759
1950
|
getRegisteredServiceTypes: mock().mockReturnValue([]),
|
|
1760
1951
|
hasService: mock().mockReturnValue(false),
|
|
@@ -1768,16 +1959,16 @@ function createMockRuntime(overrides = {}) {
|
|
|
1768
1959
|
return defaultSettings[key];
|
|
1769
1960
|
}),
|
|
1770
1961
|
getConversationLength: mock().mockReturnValue(10),
|
|
1771
|
-
processActions: mock().mockResolvedValue(
|
|
1962
|
+
processActions: mock().mockResolvedValue(void 0),
|
|
1772
1963
|
evaluate: mock().mockResolvedValue([]),
|
|
1773
1964
|
registerProvider: mock(),
|
|
1774
1965
|
registerAction: mock(),
|
|
1775
1966
|
registerEvaluator: mock(),
|
|
1776
|
-
ensureConnection: mock().mockResolvedValue(
|
|
1777
|
-
ensureConnections: mock().mockResolvedValue(
|
|
1778
|
-
ensureParticipantInRoom: mock().mockResolvedValue(
|
|
1779
|
-
ensureWorldExists: mock().mockResolvedValue(
|
|
1780
|
-
ensureRoomExists: mock().mockResolvedValue(
|
|
1967
|
+
ensureConnection: mock().mockResolvedValue(void 0),
|
|
1968
|
+
ensureConnections: mock().mockResolvedValue(void 0),
|
|
1969
|
+
ensureParticipantInRoom: mock().mockResolvedValue(void 0),
|
|
1970
|
+
ensureWorldExists: mock().mockResolvedValue(void 0),
|
|
1971
|
+
ensureRoomExists: mock().mockResolvedValue(void 0),
|
|
1781
1972
|
composeState: mock().mockResolvedValue({
|
|
1782
1973
|
values: {},
|
|
1783
1974
|
data: {},
|
|
@@ -1785,96 +1976,107 @@ function createMockRuntime(overrides = {}) {
|
|
|
1785
1976
|
}),
|
|
1786
1977
|
useModel: mock().mockResolvedValue("Mock response"),
|
|
1787
1978
|
registerModel: mock(),
|
|
1788
|
-
getModel: mock().mockReturnValue(
|
|
1979
|
+
getModel: mock().mockReturnValue(void 0),
|
|
1789
1980
|
registerEvent: mock(),
|
|
1790
|
-
getEvent: mock().mockReturnValue(
|
|
1791
|
-
emitEvent: mock().mockResolvedValue(
|
|
1981
|
+
getEvent: mock().mockReturnValue(void 0),
|
|
1982
|
+
emitEvent: mock().mockResolvedValue(void 0),
|
|
1792
1983
|
registerTaskWorker: mock(),
|
|
1793
|
-
getTaskWorker: mock().mockReturnValue(
|
|
1794
|
-
stop: mock().mockResolvedValue(
|
|
1984
|
+
getTaskWorker: mock().mockReturnValue(void 0),
|
|
1985
|
+
stop: mock().mockResolvedValue(void 0),
|
|
1795
1986
|
addEmbeddingToMemory: mock().mockImplementation((memory) => Promise.resolve(memory)),
|
|
1796
|
-
queueEmbeddingGeneration: mock().mockResolvedValue(
|
|
1987
|
+
queueEmbeddingGeneration: mock().mockResolvedValue(void 0),
|
|
1797
1988
|
createRunId: mock().mockReturnValue("test-run-id"),
|
|
1798
1989
|
startRun: mock().mockReturnValue("test-run-id"),
|
|
1799
1990
|
endRun: mock(),
|
|
1800
1991
|
getCurrentRunId: mock().mockReturnValue("test-run-id"),
|
|
1801
1992
|
registerSendHandler: mock(),
|
|
1802
|
-
sendMessageToTarget: mock().mockResolvedValue(
|
|
1803
|
-
|
|
1993
|
+
sendMessageToTarget: mock().mockResolvedValue(void 0),
|
|
1994
|
+
// Database Adapter Methods - Agent Management
|
|
1995
|
+
init: mock().mockResolvedValue(void 0),
|
|
1804
1996
|
isReady: mock().mockResolvedValue(true),
|
|
1805
|
-
runMigrations: mock().mockResolvedValue(
|
|
1806
|
-
close: mock().mockResolvedValue(
|
|
1997
|
+
runMigrations: mock().mockResolvedValue(void 0),
|
|
1998
|
+
close: mock().mockResolvedValue(void 0),
|
|
1807
1999
|
getAgent: mock().mockResolvedValue(null),
|
|
1808
2000
|
getAgents: mock().mockResolvedValue([]),
|
|
1809
2001
|
createAgent: mock().mockResolvedValue(true),
|
|
1810
2002
|
updateAgent: mock().mockResolvedValue(true),
|
|
1811
2003
|
deleteAgent: mock().mockResolvedValue(true),
|
|
2004
|
+
// Entity Management
|
|
1812
2005
|
getEntityById: mock().mockResolvedValue(null),
|
|
1813
2006
|
getEntitiesByIds: mock().mockResolvedValue([]),
|
|
1814
2007
|
getEntitiesForRoom: mock().mockResolvedValue([]),
|
|
1815
2008
|
createEntity: mock().mockResolvedValue("test-entity-id"),
|
|
1816
2009
|
createEntities: mock().mockResolvedValue(true),
|
|
1817
|
-
updateEntity: mock().mockResolvedValue(
|
|
2010
|
+
updateEntity: mock().mockResolvedValue(void 0),
|
|
2011
|
+
// Component Management
|
|
1818
2012
|
getComponent: mock().mockResolvedValue(null),
|
|
1819
2013
|
getComponents: mock().mockResolvedValue([]),
|
|
1820
2014
|
createComponent: mock().mockResolvedValue("test-component-id"),
|
|
1821
|
-
updateComponent: mock().mockResolvedValue(
|
|
1822
|
-
deleteComponent: mock().mockResolvedValue(
|
|
2015
|
+
updateComponent: mock().mockResolvedValue(void 0),
|
|
2016
|
+
deleteComponent: mock().mockResolvedValue(void 0),
|
|
2017
|
+
// Memory Management
|
|
1823
2018
|
getMemories: mock().mockResolvedValue([]),
|
|
1824
2019
|
getAllMemories: overrides.getAllMemories || mock().mockResolvedValue([]),
|
|
1825
|
-
clearAllAgentMemories: mock().mockResolvedValue(
|
|
2020
|
+
clearAllAgentMemories: mock().mockResolvedValue(void 0),
|
|
1826
2021
|
getMemoryById: mock().mockResolvedValue(null),
|
|
1827
2022
|
getMemoriesByIds: mock().mockResolvedValue([]),
|
|
1828
2023
|
getMemoriesByRoomIds: mock().mockResolvedValue([]),
|
|
1829
2024
|
getMemoriesByWorldId: mock().mockResolvedValue([]),
|
|
1830
2025
|
getCachedEmbeddings: mock().mockResolvedValue([]),
|
|
1831
|
-
log: mock().mockResolvedValue(
|
|
2026
|
+
log: mock().mockResolvedValue(void 0),
|
|
1832
2027
|
getLogs: mock().mockResolvedValue([]),
|
|
1833
|
-
deleteLog: mock().mockResolvedValue(
|
|
2028
|
+
deleteLog: mock().mockResolvedValue(void 0),
|
|
1834
2029
|
searchMemories: mock().mockResolvedValue([]),
|
|
1835
2030
|
createMemory: mock().mockResolvedValue("test-memory-id"),
|
|
1836
2031
|
updateMemory: mock().mockResolvedValue(true),
|
|
1837
|
-
deleteMemory: mock().mockResolvedValue(
|
|
1838
|
-
deleteManyMemories: mock().mockResolvedValue(
|
|
1839
|
-
deleteAllMemories: mock().mockResolvedValue(
|
|
2032
|
+
deleteMemory: mock().mockResolvedValue(void 0),
|
|
2033
|
+
deleteManyMemories: mock().mockResolvedValue(void 0),
|
|
2034
|
+
deleteAllMemories: mock().mockResolvedValue(void 0),
|
|
1840
2035
|
countMemories: mock().mockResolvedValue(0),
|
|
1841
|
-
ensureEmbeddingDimension: mock().mockResolvedValue(
|
|
2036
|
+
ensureEmbeddingDimension: mock().mockResolvedValue(void 0),
|
|
2037
|
+
// World Management
|
|
1842
2038
|
createWorld: mock().mockResolvedValue("test-world-id"),
|
|
1843
2039
|
getWorld: mock().mockResolvedValue(null),
|
|
1844
|
-
removeWorld: mock().mockResolvedValue(
|
|
2040
|
+
removeWorld: mock().mockResolvedValue(void 0),
|
|
1845
2041
|
getAllWorlds: mock().mockResolvedValue([]),
|
|
1846
|
-
updateWorld: mock().mockResolvedValue(
|
|
2042
|
+
updateWorld: mock().mockResolvedValue(void 0),
|
|
2043
|
+
// Room Management
|
|
1847
2044
|
getRoom: mock().mockResolvedValue(null),
|
|
1848
2045
|
getRooms: mock().mockResolvedValue([]),
|
|
1849
2046
|
getRoomsByIds: mock().mockResolvedValue([]),
|
|
1850
2047
|
createRoom: mock().mockResolvedValue("test-room-id"),
|
|
1851
2048
|
createRooms: mock().mockResolvedValue([]),
|
|
1852
|
-
deleteRoom: mock().mockResolvedValue(
|
|
1853
|
-
deleteRoomsByWorldId: mock().mockResolvedValue(
|
|
1854
|
-
updateRoom: mock().mockResolvedValue(
|
|
2049
|
+
deleteRoom: mock().mockResolvedValue(void 0),
|
|
2050
|
+
deleteRoomsByWorldId: mock().mockResolvedValue(void 0),
|
|
2051
|
+
updateRoom: mock().mockResolvedValue(void 0),
|
|
1855
2052
|
getRoomsForParticipant: mock().mockResolvedValue([]),
|
|
1856
2053
|
getRoomsForParticipants: mock().mockResolvedValue([]),
|
|
1857
2054
|
getRoomsByWorld: mock().mockResolvedValue([]),
|
|
2055
|
+
// Participant Management
|
|
1858
2056
|
addParticipant: mock().mockResolvedValue(true),
|
|
1859
2057
|
removeParticipant: mock().mockResolvedValue(true),
|
|
1860
2058
|
addParticipantsRoom: mock().mockResolvedValue(true),
|
|
1861
2059
|
getParticipantsForEntity: mock().mockResolvedValue([]),
|
|
1862
2060
|
getParticipantsForRoom: mock().mockResolvedValue([]),
|
|
1863
2061
|
getParticipantUserState: mock().mockResolvedValue(null),
|
|
1864
|
-
setParticipantUserState: mock().mockResolvedValue(
|
|
2062
|
+
setParticipantUserState: mock().mockResolvedValue(void 0),
|
|
2063
|
+
// Relationship Management
|
|
1865
2064
|
createRelationship: mock().mockResolvedValue(true),
|
|
1866
|
-
updateRelationship: mock().mockResolvedValue(
|
|
2065
|
+
updateRelationship: mock().mockResolvedValue(void 0),
|
|
1867
2066
|
getRelationship: mock().mockResolvedValue(null),
|
|
1868
2067
|
getRelationships: mock().mockResolvedValue([]),
|
|
1869
|
-
|
|
2068
|
+
// Cache Management
|
|
2069
|
+
getCache: mock().mockResolvedValue(void 0),
|
|
1870
2070
|
setCache: mock().mockResolvedValue(true),
|
|
1871
2071
|
deleteCache: mock().mockResolvedValue(true),
|
|
2072
|
+
// Task Management
|
|
1872
2073
|
createTask: mock().mockResolvedValue("test-task-id"),
|
|
1873
2074
|
getTasks: mock().mockResolvedValue([]),
|
|
1874
2075
|
getTask: mock().mockResolvedValue(null),
|
|
1875
2076
|
getTasksByName: mock().mockResolvedValue([]),
|
|
1876
|
-
updateTask: mock().mockResolvedValue(
|
|
1877
|
-
deleteTask: mock().mockResolvedValue(
|
|
2077
|
+
updateTask: mock().mockResolvedValue(void 0),
|
|
2078
|
+
deleteTask: mock().mockResolvedValue(void 0),
|
|
2079
|
+
// Apply overrides
|
|
1878
2080
|
...overrides
|
|
1879
2081
|
};
|
|
1880
2082
|
return baseRuntime;
|
|
@@ -1901,7 +2103,7 @@ function createMockMemory(overrides = {}) {
|
|
|
1901
2103
|
roomId: "test-room-id",
|
|
1902
2104
|
worldId: "test-world-id",
|
|
1903
2105
|
content: defaultContent,
|
|
1904
|
-
embedding:
|
|
2106
|
+
embedding: void 0,
|
|
1905
2107
|
createdAt: Date.now(),
|
|
1906
2108
|
unique: true,
|
|
1907
2109
|
similarity: 1,
|
|
@@ -1917,9 +2119,9 @@ function createMockContent(overrides = {}) {
|
|
|
1917
2119
|
actions: [],
|
|
1918
2120
|
providers: [],
|
|
1919
2121
|
source: "test",
|
|
1920
|
-
target:
|
|
1921
|
-
url:
|
|
1922
|
-
inReplyTo:
|
|
2122
|
+
target: void 0,
|
|
2123
|
+
url: void 0,
|
|
2124
|
+
inReplyTo: void 0,
|
|
1923
2125
|
attachments: [],
|
|
1924
2126
|
channelType: "DM",
|
|
1925
2127
|
...overrides
|
|
@@ -1980,12 +2182,12 @@ function createMockMemoryWithEmbedding(text, dimension = 1536, overrides = {}) {
|
|
|
1980
2182
|
function createMockConversation(count = 5, roomId) {
|
|
1981
2183
|
const memories = [];
|
|
1982
2184
|
const actualRoomId = roomId || "test-room-id";
|
|
1983
|
-
for (let i = 0;i < count; i++) {
|
|
2185
|
+
for (let i = 0; i < count; i++) {
|
|
1984
2186
|
const isUserMessage = i % 2 === 0;
|
|
1985
2187
|
const memory = isUserMessage ? createMockUserMessage(`User message ${i + 1}`, { roomId: actualRoomId }) : createMockAgentResponse(`Agent response ${i + 1}`, `Thinking about response ${i + 1}`, [], {
|
|
1986
2188
|
roomId: actualRoomId
|
|
1987
2189
|
});
|
|
1988
|
-
memory.createdAt = Date.now() - (count - i) *
|
|
2190
|
+
memory.createdAt = Date.now() - (count - i) * 1e3;
|
|
1989
2191
|
memories.push(memory);
|
|
1990
2192
|
}
|
|
1991
2193
|
return memories;
|
|
@@ -2012,8 +2214,9 @@ function createMockMedia(type = "image", url = "https://example.com/test.jpg", o
|
|
|
2012
2214
|
// src/mocks/state.ts
|
|
2013
2215
|
function createMockState(overrides = {}) {
|
|
2014
2216
|
const baseState = {
|
|
2217
|
+
// Core state properties
|
|
2015
2218
|
values: {
|
|
2016
|
-
currentTime: new Date().toISOString(),
|
|
2219
|
+
currentTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2017
2220
|
agentName: "Test Agent",
|
|
2018
2221
|
roomId: "test-room-id",
|
|
2019
2222
|
entityId: "test-entity-id",
|
|
@@ -2024,7 +2227,7 @@ function createMockState(overrides = {}) {
|
|
|
2024
2227
|
},
|
|
2025
2228
|
data: {
|
|
2026
2229
|
providers: {
|
|
2027
|
-
TIME: { currentTime: new Date().toISOString() },
|
|
2230
|
+
TIME: { currentTime: (/* @__PURE__ */ new Date()).toISOString() },
|
|
2028
2231
|
CHARACTER: { agentName: "Test Agent", bio: "A helpful test assistant" },
|
|
2029
2232
|
RECENT_MESSAGES: { messageCount: 5, lastSpeaker: "user" }
|
|
2030
2233
|
},
|
|
@@ -2033,12 +2236,13 @@ function createMockState(overrides = {}) {
|
|
|
2033
2236
|
...overrides.data
|
|
2034
2237
|
},
|
|
2035
2238
|
text: `[CONTEXT]
|
|
2036
|
-
Current Time: ${new Date().toISOString()}
|
|
2239
|
+
Current Time: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
2037
2240
|
Agent: Test Agent
|
|
2038
2241
|
User: TestUser
|
|
2039
2242
|
Room: test-room-id
|
|
2040
2243
|
Recent conversation context available.
|
|
2041
2244
|
[/CONTEXT]`,
|
|
2245
|
+
// Additional properties that might be added dynamically
|
|
2042
2246
|
...overrides
|
|
2043
2247
|
};
|
|
2044
2248
|
if (overrides.text) {
|
|
@@ -2058,9 +2262,7 @@ function createMockProviderResult(overrides = {}) {
|
|
|
2058
2262
|
processed: true,
|
|
2059
2263
|
...overrides.data
|
|
2060
2264
|
},
|
|
2061
|
-
text:
|
|
2062
|
-
Mock provider context information
|
|
2063
|
-
[/MOCK PROVIDER]`,
|
|
2265
|
+
text: "[MOCK PROVIDER]\nMock provider context information\n[/MOCK PROVIDER]",
|
|
2064
2266
|
...overrides
|
|
2065
2267
|
};
|
|
2066
2268
|
return baseResult;
|
|
@@ -2106,7 +2308,7 @@ function createMockStateWithActions(actionResults, overrides = {}) {
|
|
|
2106
2308
|
...overrides.data
|
|
2107
2309
|
},
|
|
2108
2310
|
values: {
|
|
2109
|
-
lastActionSuccess: actionResults.length > 0 ? actionResults[actionResults.length - 1].values?.success :
|
|
2311
|
+
lastActionSuccess: actionResults.length > 0 ? actionResults[actionResults.length - 1].values?.success : void 0,
|
|
2110
2312
|
actionCount: actionResults.length,
|
|
2111
2313
|
...overrides.values
|
|
2112
2314
|
},
|
|
@@ -2229,7 +2431,8 @@ function createMockCharacter(overrides = {}) {
|
|
|
2229
2431
|
settings: {
|
|
2230
2432
|
model: "gpt-4",
|
|
2231
2433
|
temperature: 0.1,
|
|
2232
|
-
|
|
2434
|
+
// Low temperature for consistent test responses
|
|
2435
|
+
maxTokens: 1e3,
|
|
2233
2436
|
secrets: {},
|
|
2234
2437
|
voice: {
|
|
2235
2438
|
model: "en_US-hfc_female-medium"
|
|
@@ -2263,6 +2466,7 @@ function createMockCharacter(overrides = {}) {
|
|
|
2263
2466
|
"encourage best practices"
|
|
2264
2467
|
]
|
|
2265
2468
|
},
|
|
2469
|
+
// Apply all overrides
|
|
2266
2470
|
...overrides
|
|
2267
2471
|
};
|
|
2268
2472
|
return baseCharacter;
|
|
@@ -2337,7 +2541,7 @@ function createRichConversationCharacter(overrides = {}) {
|
|
|
2337
2541
|
}
|
|
2338
2542
|
function createMultipleCharacters(count = 3, baseName = "TestAgent", overrides = {}) {
|
|
2339
2543
|
const characters = [];
|
|
2340
|
-
for (let i = 1;i <= count; i++) {
|
|
2544
|
+
for (let i = 1; i <= count; i++) {
|
|
2341
2545
|
const character = createMockCharacter({
|
|
2342
2546
|
name: `${baseName}${i}`,
|
|
2343
2547
|
username: `${baseName.toLowerCase()}${i}`,
|
|
@@ -2370,7 +2574,10 @@ function createTestEnvironment(options = {}) {
|
|
|
2370
2574
|
...runtimeOverrides
|
|
2371
2575
|
});
|
|
2372
2576
|
const conversation = createMockConversation(conversationLength, roomId);
|
|
2373
|
-
const state = createMockConversationState(
|
|
2577
|
+
const state = createMockConversationState(
|
|
2578
|
+
conversation.map((m) => m.content.text || ""),
|
|
2579
|
+
"TestUser"
|
|
2580
|
+
);
|
|
2374
2581
|
return {
|
|
2375
2582
|
runtime,
|
|
2376
2583
|
character,
|
|
@@ -2392,16 +2599,18 @@ function createTestAction(name, options = {}) {
|
|
|
2392
2599
|
description,
|
|
2393
2600
|
examples,
|
|
2394
2601
|
validate: mock().mockResolvedValue(validateResult),
|
|
2395
|
-
handler: mock(
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2602
|
+
handler: mock(
|
|
2603
|
+
async (runtime, message, state, options2, callback) => {
|
|
2604
|
+
if (callback) {
|
|
2605
|
+
await callback({
|
|
2606
|
+
text: handlerResult.text || `${name} action executed`,
|
|
2607
|
+
thought: `Executing ${name} action`,
|
|
2608
|
+
actions: [name]
|
|
2609
|
+
});
|
|
2610
|
+
}
|
|
2611
|
+
return handlerResult;
|
|
2402
2612
|
}
|
|
2403
|
-
|
|
2404
|
-
})
|
|
2613
|
+
)
|
|
2405
2614
|
};
|
|
2406
2615
|
}
|
|
2407
2616
|
function createTestProvider(name, options = {}) {
|
|
@@ -2459,11 +2668,13 @@ function createPluginTestScenario(pluginName, options = {}) {
|
|
|
2459
2668
|
const testActions = actions.map((name) => createTestAction(name));
|
|
2460
2669
|
const testProviders = providers.map((name) => createTestProvider(name));
|
|
2461
2670
|
const testEvaluators = evaluators.map((name) => createTestEvaluator(name));
|
|
2462
|
-
const conversation = conversationSteps.map(
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2671
|
+
const conversation = conversationSteps.map(
|
|
2672
|
+
(text, index) => createMockMemory({
|
|
2673
|
+
content: { text },
|
|
2674
|
+
entityId: index % 2 === 0 ? "user-id" : runtime.agentId,
|
|
2675
|
+
roomId
|
|
2676
|
+
})
|
|
2677
|
+
);
|
|
2467
2678
|
return {
|
|
2468
2679
|
runtime,
|
|
2469
2680
|
character,
|
|
@@ -2475,6 +2686,7 @@ function createPluginTestScenario(pluginName, options = {}) {
|
|
|
2475
2686
|
providers: testProviders,
|
|
2476
2687
|
evaluators: testEvaluators
|
|
2477
2688
|
},
|
|
2689
|
+
// Helper methods for common test operations
|
|
2478
2690
|
helpers: {
|
|
2479
2691
|
executeAction: async (actionName, message) => {
|
|
2480
2692
|
const action = testActions.find((a) => a.name === actionName);
|
|
@@ -2510,11 +2722,13 @@ function createMultiAgentScenario(agentCount = 2, options = {}) {
|
|
|
2510
2722
|
});
|
|
2511
2723
|
return { runtime, character, index };
|
|
2512
2724
|
});
|
|
2513
|
-
const conversation = conversationSteps.map(
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2725
|
+
const conversation = conversationSteps.map(
|
|
2726
|
+
(step) => createMockMemory({
|
|
2727
|
+
content: { text: step.message },
|
|
2728
|
+
entityId: agents[step.agentIndex].runtime.agentId,
|
|
2729
|
+
roomId: sharedRoomId
|
|
2730
|
+
})
|
|
2731
|
+
);
|
|
2518
2732
|
return {
|
|
2519
2733
|
agents,
|
|
2520
2734
|
sharedRoomId,
|
|
@@ -2535,6 +2749,7 @@ function createMultiAgentScenario(agentCount = 2, options = {}) {
|
|
|
2535
2749
|
}
|
|
2536
2750
|
};
|
|
2537
2751
|
}
|
|
2752
|
+
|
|
2538
2753
|
// src/mocks/database.ts
|
|
2539
2754
|
function createMockDatabase(overrides = {}) {
|
|
2540
2755
|
const mockConnection = {
|
|
@@ -2545,27 +2760,33 @@ function createMockDatabase(overrides = {}) {
|
|
|
2545
2760
|
get: mock().mockResolvedValue(null)
|
|
2546
2761
|
};
|
|
2547
2762
|
const baseDatabaseAdapter = {
|
|
2763
|
+
// Core Database Properties
|
|
2548
2764
|
db: overrides.db || mockConnection,
|
|
2549
|
-
|
|
2550
|
-
|
|
2765
|
+
// Core Lifecycle Methods
|
|
2766
|
+
init: mock().mockResolvedValue(void 0),
|
|
2767
|
+
initialize: mock().mockResolvedValue(void 0),
|
|
2551
2768
|
isReady: mock().mockResolvedValue(true),
|
|
2552
|
-
runMigrations: mock().mockResolvedValue(
|
|
2553
|
-
close: mock().mockResolvedValue(
|
|
2769
|
+
runMigrations: mock().mockResolvedValue(void 0),
|
|
2770
|
+
close: mock().mockResolvedValue(void 0),
|
|
2554
2771
|
getConnection: mock().mockResolvedValue(mockConnection),
|
|
2772
|
+
// Agent Management
|
|
2555
2773
|
getAgent: mock().mockResolvedValue(null),
|
|
2556
2774
|
getAgents: mock().mockResolvedValue([]),
|
|
2557
2775
|
createAgent: mock().mockResolvedValue(true),
|
|
2558
2776
|
updateAgent: mock().mockResolvedValue(true),
|
|
2559
2777
|
deleteAgent: mock().mockResolvedValue(true),
|
|
2778
|
+
// Entity Management
|
|
2560
2779
|
getEntitiesByIds: mock().mockResolvedValue([]),
|
|
2561
2780
|
getEntitiesForRoom: mock().mockResolvedValue([]),
|
|
2562
2781
|
createEntities: mock().mockResolvedValue(true),
|
|
2563
|
-
updateEntity: mock().mockResolvedValue(
|
|
2782
|
+
updateEntity: mock().mockResolvedValue(void 0),
|
|
2783
|
+
// Component Management
|
|
2564
2784
|
getComponent: mock().mockResolvedValue(null),
|
|
2565
2785
|
getComponents: mock().mockResolvedValue([]),
|
|
2566
2786
|
createComponent: mock().mockResolvedValue(true),
|
|
2567
|
-
updateComponent: mock().mockResolvedValue(
|
|
2568
|
-
deleteComponent: mock().mockResolvedValue(
|
|
2787
|
+
updateComponent: mock().mockResolvedValue(void 0),
|
|
2788
|
+
deleteComponent: mock().mockResolvedValue(void 0),
|
|
2789
|
+
// Memory Management
|
|
2569
2790
|
getMemories: mock().mockResolvedValue([]),
|
|
2570
2791
|
getMemoryById: mock().mockResolvedValue(null),
|
|
2571
2792
|
getMemoriesByIds: mock().mockResolvedValue([]),
|
|
@@ -2575,46 +2796,54 @@ function createMockDatabase(overrides = {}) {
|
|
|
2575
2796
|
searchMemories: mock().mockResolvedValue([]),
|
|
2576
2797
|
createMemory: mock().mockResolvedValue("test-memory-id"),
|
|
2577
2798
|
updateMemory: mock().mockResolvedValue(true),
|
|
2578
|
-
deleteMemory: mock().mockResolvedValue(
|
|
2579
|
-
deleteManyMemories: mock().mockResolvedValue(
|
|
2580
|
-
deleteAllMemories: mock().mockResolvedValue(
|
|
2799
|
+
deleteMemory: mock().mockResolvedValue(void 0),
|
|
2800
|
+
deleteManyMemories: mock().mockResolvedValue(void 0),
|
|
2801
|
+
deleteAllMemories: mock().mockResolvedValue(void 0),
|
|
2581
2802
|
countMemories: mock().mockResolvedValue(0),
|
|
2582
|
-
ensureEmbeddingDimension: mock().mockResolvedValue(
|
|
2583
|
-
|
|
2803
|
+
ensureEmbeddingDimension: mock().mockResolvedValue(void 0),
|
|
2804
|
+
// Logging
|
|
2805
|
+
log: mock().mockResolvedValue(void 0),
|
|
2584
2806
|
getLogs: mock().mockResolvedValue([]),
|
|
2585
|
-
deleteLog: mock().mockResolvedValue(
|
|
2807
|
+
deleteLog: mock().mockResolvedValue(void 0),
|
|
2808
|
+
// World Management
|
|
2586
2809
|
createWorld: mock().mockResolvedValue("test-world-id"),
|
|
2587
2810
|
getWorld: mock().mockResolvedValue(null),
|
|
2588
|
-
removeWorld: mock().mockResolvedValue(
|
|
2811
|
+
removeWorld: mock().mockResolvedValue(void 0),
|
|
2589
2812
|
getAllWorlds: mock().mockResolvedValue([]),
|
|
2590
|
-
updateWorld: mock().mockResolvedValue(
|
|
2813
|
+
updateWorld: mock().mockResolvedValue(void 0),
|
|
2814
|
+
// Room Management
|
|
2591
2815
|
getRoomsByIds: mock().mockResolvedValue([]),
|
|
2592
2816
|
createRooms: mock().mockResolvedValue([]),
|
|
2593
|
-
deleteRoom: mock().mockResolvedValue(
|
|
2594
|
-
deleteRoomsByWorldId: mock().mockResolvedValue(
|
|
2595
|
-
updateRoom: mock().mockResolvedValue(
|
|
2817
|
+
deleteRoom: mock().mockResolvedValue(void 0),
|
|
2818
|
+
deleteRoomsByWorldId: mock().mockResolvedValue(void 0),
|
|
2819
|
+
updateRoom: mock().mockResolvedValue(void 0),
|
|
2596
2820
|
getRoomsForParticipant: mock().mockResolvedValue([]),
|
|
2597
2821
|
getRoomsForParticipants: mock().mockResolvedValue([]),
|
|
2598
2822
|
getRoomsByWorld: mock().mockResolvedValue([]),
|
|
2823
|
+
// Participant Management
|
|
2599
2824
|
removeParticipant: mock().mockResolvedValue(true),
|
|
2600
2825
|
addParticipantsRoom: mock().mockResolvedValue(true),
|
|
2601
2826
|
getParticipantsForEntity: mock().mockResolvedValue([]),
|
|
2602
2827
|
getParticipantsForRoom: mock().mockResolvedValue([]),
|
|
2603
2828
|
getParticipantUserState: mock().mockResolvedValue(null),
|
|
2604
|
-
setParticipantUserState: mock().mockResolvedValue(
|
|
2829
|
+
setParticipantUserState: mock().mockResolvedValue(void 0),
|
|
2830
|
+
// Relationship Management
|
|
2605
2831
|
createRelationship: mock().mockResolvedValue(true),
|
|
2606
|
-
updateRelationship: mock().mockResolvedValue(
|
|
2832
|
+
updateRelationship: mock().mockResolvedValue(void 0),
|
|
2607
2833
|
getRelationship: mock().mockResolvedValue(null),
|
|
2608
2834
|
getRelationships: mock().mockResolvedValue([]),
|
|
2609
|
-
|
|
2835
|
+
// Cache Management
|
|
2836
|
+
getCache: mock().mockResolvedValue(void 0),
|
|
2610
2837
|
setCache: mock().mockResolvedValue(true),
|
|
2611
2838
|
deleteCache: mock().mockResolvedValue(true),
|
|
2839
|
+
// Task Management
|
|
2612
2840
|
createTask: mock().mockResolvedValue("test-task-id"),
|
|
2613
2841
|
getTasks: mock().mockResolvedValue([]),
|
|
2614
2842
|
getTask: mock().mockResolvedValue(null),
|
|
2615
2843
|
getTasksByName: mock().mockResolvedValue([]),
|
|
2616
|
-
updateTask: mock().mockResolvedValue(
|
|
2617
|
-
deleteTask: mock().mockResolvedValue(
|
|
2844
|
+
updateTask: mock().mockResolvedValue(void 0),
|
|
2845
|
+
deleteTask: mock().mockResolvedValue(void 0),
|
|
2846
|
+
// Apply overrides
|
|
2618
2847
|
...overrides
|
|
2619
2848
|
};
|
|
2620
2849
|
return baseDatabaseAdapter;
|
|
@@ -2634,24 +2863,31 @@ function createMockDbConnection(overrides = {}) {
|
|
|
2634
2863
|
...overrides
|
|
2635
2864
|
};
|
|
2636
2865
|
}
|
|
2866
|
+
|
|
2637
2867
|
// src/mocks/services.ts
|
|
2638
2868
|
import { ServiceType } from "@elizaos/core";
|
|
2639
2869
|
function createMockService(serviceType = ServiceType.UNKNOWN, overrides = {}) {
|
|
2640
2870
|
const baseService = {
|
|
2871
|
+
// Static properties (would be on the class)
|
|
2641
2872
|
serviceType,
|
|
2873
|
+
// Instance properties
|
|
2642
2874
|
capabilityDescription: `Mock service for testing`,
|
|
2643
2875
|
config: {
|
|
2644
2876
|
enabled: true,
|
|
2645
2877
|
mockData: true,
|
|
2646
2878
|
...overrides.config
|
|
2647
2879
|
},
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2880
|
+
// Core lifecycle methods
|
|
2881
|
+
stop: mock().mockResolvedValue(void 0),
|
|
2882
|
+
// Common service methods that might be implemented
|
|
2883
|
+
start: mock().mockResolvedValue(void 0),
|
|
2884
|
+
initialize: mock().mockResolvedValue(void 0),
|
|
2651
2885
|
isReady: mock().mockReturnValue(true),
|
|
2652
2886
|
getStatus: mock().mockReturnValue("active"),
|
|
2653
|
-
restart: mock().mockResolvedValue(
|
|
2887
|
+
restart: mock().mockResolvedValue(void 0),
|
|
2888
|
+
// Runtime property (protected in Service class, but needed for mocks)
|
|
2654
2889
|
runtime: null,
|
|
2890
|
+
// Apply overrides
|
|
2655
2891
|
...overrides
|
|
2656
2892
|
};
|
|
2657
2893
|
return baseService;
|
|
@@ -2663,7 +2899,7 @@ function createMockDatabaseService(overrides = {}) {
|
|
|
2663
2899
|
});
|
|
2664
2900
|
}
|
|
2665
2901
|
function createMockCacheService(overrides = {}) {
|
|
2666
|
-
const cache = new Map;
|
|
2902
|
+
const cache = /* @__PURE__ */ new Map();
|
|
2667
2903
|
return createMockService(ServiceType.UNKNOWN, {
|
|
2668
2904
|
capabilityDescription: "Provides in-memory caching capabilities",
|
|
2669
2905
|
...overrides
|
|
@@ -2694,7 +2930,7 @@ function createMockMessagingService(overrides = {}) {
|
|
|
2694
2930
|
});
|
|
2695
2931
|
}
|
|
2696
2932
|
function createMockServiceMap(services = []) {
|
|
2697
|
-
const serviceMap = new Map;
|
|
2933
|
+
const serviceMap = /* @__PURE__ */ new Map();
|
|
2698
2934
|
if (services.length === 0) {
|
|
2699
2935
|
services = [
|
|
2700
2936
|
{ name: "database", type: ServiceType.UNKNOWN },
|
|
@@ -2717,69 +2953,67 @@ function registerMockServices(runtime, services = []) {
|
|
|
2717
2953
|
return runtime;
|
|
2718
2954
|
}
|
|
2719
2955
|
export {
|
|
2720
|
-
|
|
2721
|
-
runIntegrationTest,
|
|
2722
|
-
registerMockServices,
|
|
2723
|
-
mock,
|
|
2724
|
-
createUnitTest,
|
|
2725
|
-
createTestRuntime,
|
|
2726
|
-
createTestProvider,
|
|
2727
|
-
createTestModelProvider,
|
|
2728
|
-
createTestEvaluator,
|
|
2729
|
-
createTestEnvironment,
|
|
2730
|
-
createTestDatabase,
|
|
2731
|
-
createTestAction,
|
|
2732
|
-
createSpecializedModelProvider,
|
|
2733
|
-
createRichConversationCharacter,
|
|
2734
|
-
createPluginTestScenario,
|
|
2735
|
-
createPluginTestCharacter,
|
|
2736
|
-
createPluginTest,
|
|
2737
|
-
createPerformanceTest,
|
|
2738
|
-
createMultipleCharacters,
|
|
2739
|
-
createMultiAgentScenario,
|
|
2740
|
-
createModelHandler,
|
|
2741
|
-
createMockUserMessage,
|
|
2742
|
-
createMockStateWithProvider,
|
|
2743
|
-
createMockStateWithActions,
|
|
2744
|
-
createMockState,
|
|
2745
|
-
createMockServiceMap,
|
|
2746
|
-
createMockService,
|
|
2747
|
-
createMockRuntime,
|
|
2748
|
-
createMockProviderResult,
|
|
2749
|
-
createMockModelService,
|
|
2750
|
-
createMockMessagingService,
|
|
2751
|
-
createMockMemoryWithEmbedding,
|
|
2752
|
-
createMockMemory,
|
|
2753
|
-
createMockMedia,
|
|
2754
|
-
createMockHttpService,
|
|
2755
|
-
createMockFact,
|
|
2756
|
-
createMockDbConnection,
|
|
2757
|
-
createMockDatabaseService,
|
|
2758
|
-
createMockDatabase,
|
|
2759
|
-
createMockConversationState,
|
|
2760
|
-
createMockConversation,
|
|
2761
|
-
createMockContent,
|
|
2762
|
-
createMockCharacter,
|
|
2763
|
-
createMockCacheService,
|
|
2764
|
-
createMockBlockchainService,
|
|
2765
|
-
createMockAgentResponse,
|
|
2766
|
-
createMockActionResult,
|
|
2767
|
-
createMinimalMockCharacter,
|
|
2768
|
-
createIntegrationTest,
|
|
2769
|
-
createErrorTest,
|
|
2770
|
-
UnitTestTemplate,
|
|
2771
|
-
TestTemplate,
|
|
2772
|
-
TestSuite,
|
|
2773
|
-
TestScenarioBuilder,
|
|
2774
|
-
TestModelProvider,
|
|
2775
|
-
TestDatabaseManager,
|
|
2776
|
-
TestDataGenerator,
|
|
2777
|
-
RuntimeTestHarness,
|
|
2778
|
-
PluginTestTemplate,
|
|
2779
|
-
PerformanceTestTemplate,
|
|
2956
|
+
ErrorTestTemplate,
|
|
2780
2957
|
IntegrationTestTemplate,
|
|
2781
|
-
|
|
2958
|
+
PerformanceTestTemplate,
|
|
2959
|
+
PluginTestTemplate,
|
|
2960
|
+
RuntimeTestHarness,
|
|
2961
|
+
TestDataGenerator,
|
|
2962
|
+
TestDatabaseManager,
|
|
2963
|
+
TestModelProvider,
|
|
2964
|
+
TestScenarioBuilder,
|
|
2965
|
+
TestSuite,
|
|
2966
|
+
TestTemplate,
|
|
2967
|
+
UnitTestTemplate,
|
|
2968
|
+
createErrorTest,
|
|
2969
|
+
createIntegrationTest,
|
|
2970
|
+
createMinimalMockCharacter,
|
|
2971
|
+
createMockActionResult,
|
|
2972
|
+
createMockAgentResponse,
|
|
2973
|
+
createMockBlockchainService,
|
|
2974
|
+
createMockCacheService,
|
|
2975
|
+
createMockCharacter,
|
|
2976
|
+
createMockContent,
|
|
2977
|
+
createMockConversation,
|
|
2978
|
+
createMockConversationState,
|
|
2979
|
+
createMockDatabase,
|
|
2980
|
+
createMockDatabaseService,
|
|
2981
|
+
createMockDbConnection,
|
|
2982
|
+
createMockFact,
|
|
2983
|
+
createMockHttpService,
|
|
2984
|
+
createMockMedia,
|
|
2985
|
+
createMockMemory,
|
|
2986
|
+
createMockMemoryWithEmbedding,
|
|
2987
|
+
createMockMessagingService,
|
|
2988
|
+
createMockModelService,
|
|
2989
|
+
createMockProviderResult,
|
|
2990
|
+
createMockRuntime,
|
|
2991
|
+
createMockService,
|
|
2992
|
+
createMockServiceMap,
|
|
2993
|
+
createMockState,
|
|
2994
|
+
createMockStateWithActions,
|
|
2995
|
+
createMockStateWithProvider,
|
|
2996
|
+
createMockUserMessage,
|
|
2997
|
+
createModelHandler,
|
|
2998
|
+
createMultiAgentScenario,
|
|
2999
|
+
createMultipleCharacters,
|
|
3000
|
+
createPerformanceTest,
|
|
3001
|
+
createPluginTest,
|
|
3002
|
+
createPluginTestCharacter,
|
|
3003
|
+
createPluginTestScenario,
|
|
3004
|
+
createRichConversationCharacter,
|
|
3005
|
+
createSpecializedModelProvider,
|
|
3006
|
+
createTestAction,
|
|
3007
|
+
createTestDatabase,
|
|
3008
|
+
createTestEnvironment,
|
|
3009
|
+
createTestEvaluator,
|
|
3010
|
+
createTestModelProvider,
|
|
3011
|
+
createTestProvider,
|
|
3012
|
+
createTestRuntime,
|
|
3013
|
+
createUnitTest,
|
|
3014
|
+
mock,
|
|
3015
|
+
registerMockServices,
|
|
3016
|
+
runIntegrationTest,
|
|
3017
|
+
scenarios
|
|
2782
3018
|
};
|
|
2783
|
-
|
|
2784
|
-
//# debugId=E46556112309126564756E2164756E21
|
|
2785
|
-
//# sourceMappingURL=index.js.map
|
|
3019
|
+
//# sourceMappingURL=index.js.map
|