@elizaos/test-utils 1.4.5 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/index.js +289 -523
  2. package/dist/index.js.map +25 -1
  3. package/dist/src/DatabaseTestRegistry.d.ts +88 -0
  4. package/dist/src/DatabaseTestRegistry.d.ts.map +1 -0
  5. package/dist/src/TestInfrastructure.d.ts +64 -0
  6. package/dist/src/TestInfrastructure.d.ts.map +1 -0
  7. package/dist/src/factories.d.ts +141 -0
  8. package/dist/src/factories.d.ts.map +1 -0
  9. package/dist/src/index.d.ts +52 -0
  10. package/dist/src/index.d.ts.map +1 -0
  11. package/dist/src/mocks/character.d.ts +65 -0
  12. package/dist/src/mocks/character.d.ts.map +1 -0
  13. package/dist/src/mocks/database.d.ts +40 -0
  14. package/dist/src/mocks/database.d.ts.map +1 -0
  15. package/dist/src/mocks/memory.d.ts +106 -0
  16. package/dist/src/mocks/memory.d.ts.map +1 -0
  17. package/dist/src/mocks/mockUtils.d.ts +17 -0
  18. package/dist/src/mocks/mockUtils.d.ts.map +1 -0
  19. package/dist/src/mocks/runtime.d.ts +34 -0
  20. package/dist/src/mocks/runtime.d.ts.map +1 -0
  21. package/dist/src/mocks/services.d.ts +99 -0
  22. package/dist/src/mocks/services.d.ts.map +1 -0
  23. package/dist/src/mocks/state.d.ts +100 -0
  24. package/dist/src/mocks/state.d.ts.map +1 -0
  25. package/dist/src/realRuntime.d.ts +85 -0
  26. package/dist/src/realRuntime.d.ts.map +1 -0
  27. package/dist/src/templates.d.ts +123 -0
  28. package/dist/src/templates.d.ts.map +1 -0
  29. package/dist/src/testDatabase.d.ts +44 -0
  30. package/dist/src/testDatabase.d.ts.map +1 -0
  31. package/dist/src/testModels.d.ts +105 -0
  32. package/dist/src/testModels.d.ts.map +1 -0
  33. package/dist/src/unifiedTestSuite.d.ts +40 -0
  34. package/dist/src/unifiedTestSuite.d.ts.map +1 -0
  35. package/dist/tsconfig.build.tsbuildinfo +1 -0
  36. package/package.json +6 -7
  37. package/dist/index.d.ts +0 -950
  38. package/tsup.config.ts +0 -20
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Database testing registry - ensures consistent database testing across all packages
3
+ * Replaces fragile database adapter fallback logic with explicit test database management
4
+ */
5
+ import type { IDatabaseAdapter } from '@elizaos/core';
6
+ export interface DatabaseTestCapabilities {
7
+ isReady: boolean;
8
+ tables: string[];
9
+ supportsTransactions: boolean;
10
+ adapter: string;
11
+ }
12
+ export interface TestDatabaseConfig {
13
+ /** Database type preference */
14
+ preferredAdapter: 'postgresql' | 'auto';
15
+ /** Whether to allow fallback to mock */
16
+ allowMockFallback: boolean;
17
+ /** Test isolation level */
18
+ isolation: 'shared' | 'per-test' | 'per-suite';
19
+ /** Connection timeout */
20
+ timeoutMs: number;
21
+ /** Test data persistence */
22
+ persistData: boolean;
23
+ }
24
+ export declare const DEFAULT_TEST_DB_CONFIG: TestDatabaseConfig;
25
+ /**
26
+ * Centralized database testing management
27
+ */
28
+ export declare class DatabaseTestRegistry {
29
+ private static instance;
30
+ private adapterCache;
31
+ private testDatabases;
32
+ private defaultConfig;
33
+ private constructor();
34
+ static getInstance(config?: TestDatabaseConfig): DatabaseTestRegistry;
35
+ /**
36
+ * Get a test database adapter with explicit requirements
37
+ */
38
+ getTestDatabase(testId: string, config?: Partial<TestDatabaseConfig>): Promise<TestDatabaseInstance>;
39
+ private createTestDatabase;
40
+ private createMockAdapter;
41
+ private getAdapterCapabilities;
42
+ private initializeTestSchema;
43
+ private validateDatabaseInstance;
44
+ /**
45
+ * Clean up a specific test database
46
+ */
47
+ cleanupTestDatabase(testId: string): Promise<void>;
48
+ /**
49
+ * Clean up all test databases
50
+ */
51
+ cleanupAll(): Promise<void>;
52
+ /**
53
+ * Validate test requirements before running tests
54
+ */
55
+ validateTestRequirements(requirements: DatabaseTestRequirements): Promise<DatabaseValidationResult>;
56
+ /**
57
+ * Get test database statistics
58
+ */
59
+ getTestDatabaseStats(): TestDatabaseStats;
60
+ }
61
+ export interface TestDatabaseInstance {
62
+ testId: string;
63
+ adapter: IDatabaseAdapter;
64
+ capabilities: DatabaseTestCapabilities;
65
+ config: TestDatabaseConfig;
66
+ createdAt: Date;
67
+ adapterType: string;
68
+ }
69
+ export interface DatabaseTestRequirements {
70
+ requiredAdapters: 'postgresql'[];
71
+ performanceRequirements?: {
72
+ maxQueryTime: number;
73
+ maxConnectionTime: number;
74
+ };
75
+ }
76
+ export interface DatabaseValidationResult {
77
+ isValid: boolean;
78
+ _errors: string[];
79
+ warnings: string[];
80
+ recommendations: string[];
81
+ }
82
+ export interface TestDatabaseStats {
83
+ totalDatabases: number;
84
+ adapterTypes: Map<string, number>;
85
+ oldestDatabase: TestDatabaseInstance | null;
86
+ newestDatabase: TestDatabaseInstance | null;
87
+ }
88
+ //# sourceMappingURL=DatabaseTestRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DatabaseTestRegistry.d.ts","sourceRoot":"","sources":["../../src/DatabaseTestRegistry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAQ,MAAM,eAAe,CAAC;AAE5D,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,+BAA+B;IAC/B,gBAAgB,EAAE,YAAY,GAAG,MAAM,CAAC;IACxC,wCAAwC;IACxC,iBAAiB,EAAE,OAAO,CAAC;IAC3B,2BAA2B;IAC3B,SAAS,EAAE,QAAQ,GAAG,UAAU,GAAG,WAAW,CAAC;IAC/C,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,4BAA4B;IAC5B,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,sBAA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AAM,EAAE,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,cAAc,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC5C,cAAc,EAAE,oBAAoB,GAAG,IAAI,CAAC;CAC7C"}
@@ -0,0 +1,64 @@
1
+ import type { IAgentRuntime, IDatabaseAdapter, UUID, Memory } from '@elizaos/core';
2
+ export interface TestEnvironmentConfig {
3
+ /** Test isolation level */
4
+ isolation: 'unit' | 'integration' | 'e2e';
5
+ /** Use real database vs in-memory */
6
+ useRealDatabase: boolean;
7
+ /** Performance thresholds */
8
+ performanceThresholds?: PerformanceThresholds;
9
+ /** Test data configuration */
10
+ testData?: TestDataConfig;
11
+ }
12
+ export interface PerformanceThresholds {
13
+ actionExecution: number;
14
+ memoryRetrieval: number;
15
+ databaseQuery: number;
16
+ modelInference: number;
17
+ }
18
+ export interface TestDataConfig {
19
+ entities: number;
20
+ memories: number;
21
+ messages: number;
22
+ relationships: number;
23
+ }
24
+ export declare const DEFAULT_PERFORMANCE_THRESHOLDS: PerformanceThresholds;
25
+ export declare const DEFAULT_TEST_DATA: TestDataConfig;
26
+ /**
27
+ * Test environment manager - ensures proper setup/teardown
28
+ */
29
+ export declare class TestEnvironment {
30
+ private static activeEnvironments;
31
+ private runtime;
32
+ private databaseAdapter;
33
+ private testId;
34
+ private config;
35
+ constructor(testId: string, config: TestEnvironmentConfig);
36
+ static create(testId: string, config?: Partial<TestEnvironmentConfig>): Promise<TestEnvironment>;
37
+ private setup;
38
+ private createTestCharacter;
39
+ private seedTestData;
40
+ teardown(): Promise<void>;
41
+ private cleanupTestData;
42
+ static teardownAll(): Promise<void>;
43
+ get testRuntime(): IAgentRuntime;
44
+ get testDatabase(): IDatabaseAdapter;
45
+ /**
46
+ * Performance monitoring wrapper
47
+ */
48
+ measurePerformance<T>(operation: () => Promise<T>, threshold: keyof PerformanceThresholds, description: string): Promise<T>;
49
+ }
50
+ /**
51
+ * Test data builder for creating realistic test scenarios
52
+ */
53
+ export declare class TestDataBuilder {
54
+ static createEntity(runtime: IAgentRuntime, data: {
55
+ names: string[];
56
+ metadata?: Record<string, any>;
57
+ }): Promise<UUID>;
58
+ static createTestConversation(runtime: IAgentRuntime, participants: string[], messageCount?: number): Promise<{
59
+ roomId: `${string}-${string}-${string}-${string}-${string}`;
60
+ messages: Memory[];
61
+ }>;
62
+ static createTestMemories(runtime: IAgentRuntime, roomId: string, count?: number): Promise<Memory[]>;
63
+ }
64
+ //# sourceMappingURL=TestInfrastructure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestInfrastructure.d.ts","sourceRoot":"","sources":["../../src/TestInfrastructure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,IAAI,EAAa,MAAM,EAAE,MAAM,eAAe,CAAC;AAK9F,MAAM,WAAW,qBAAqB;IACpC,2BAA2B;IAC3B,SAAS,EAAE,MAAM,GAAG,aAAa,GAAG,KAAK,CAAC;IAC1C,qCAAqC;IACrC,eAAe,EAAE,OAAO,CAAC;IACzB,6BAA6B;IAC7B,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;IAC9C,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CA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aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,MAAW;CAkB3F"}
@@ -0,0 +1,141 @@
1
+ /**
2
+ * @fileoverview Factory functions for creating complete test scenarios
3
+ *
4
+ * This module provides high-level factory functions that combine multiple
5
+ * mock objects to create realistic testing scenarios.
6
+ */
7
+ import type { IAgentRuntime, Memory, State, Action, Provider, Evaluator, UUID, ActionResult } from '@elizaos/core';
8
+ /**
9
+ * Create a complete test environment with runtime, character, and conversation
10
+ *
11
+ * @param options - Configuration options for the test environment
12
+ * @returns Complete test environment
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { createTestEnvironment } from '@elizaos/core/test-utils';
17
+ *
18
+ * const { runtime, character, conversation } = createTestEnvironment({
19
+ * characterName: 'TestBot',
20
+ * conversationLength: 5,
21
+ * roomId: 'test-room-123'
22
+ * });
23
+ * ```
24
+ */
25
+ export declare function createTestEnvironment(options?: {
26
+ characterName?: string;
27
+ conversationLength?: number;
28
+ roomId?: UUID;
29
+ plugins?: string[];
30
+ runtimeOverrides?: any;
31
+ characterOverrides?: any;
32
+ }): {
33
+ runtime: IAgentRuntime;
34
+ character: import("@elizaos/core").Character;
35
+ conversation: Memory[];
36
+ state: State;
37
+ roomId: `${string}-${string}-${string}-${string}-${string}`;
38
+ };
39
+ /**
40
+ * Create a test action with complete mock setup
41
+ *
42
+ * @param name - Action name
43
+ * @param options - Action configuration options
44
+ * @returns Mock action with handlers
45
+ */
46
+ export declare function createTestAction(name: string, options?: {
47
+ description?: string;
48
+ validateResult?: boolean;
49
+ handlerResult?: ActionResult;
50
+ examples?: any[];
51
+ }): Action;
52
+ /**
53
+ * Create a test provider with complete mock setup
54
+ *
55
+ * @param name - Provider name
56
+ * @param options - Provider configuration options
57
+ * @returns Mock provider
58
+ */
59
+ export declare function createTestProvider(name: string, options?: {
60
+ description?: string;
61
+ text?: string;
62
+ values?: Record<string, any>;
63
+ data?: Record<string, any>;
64
+ dynamic?: boolean;
65
+ isPrivate?: boolean;
66
+ }): Provider;
67
+ /**
68
+ * Create a test evaluator with complete mock setup
69
+ *
70
+ * @param name - Evaluator name
71
+ * @param options - Evaluator configuration options
72
+ * @returns Mock evaluator
73
+ */
74
+ export declare function createTestEvaluator(name: string, options?: {
75
+ description?: string;
76
+ alwaysRun?: boolean;
77
+ validateResult?: boolean;
78
+ handlerResult?: any;
79
+ }): Evaluator;
80
+ /**
81
+ * Create a complete plugin test scenario
82
+ *
83
+ * @param pluginName - Name of the plugin being tested
84
+ * @param options - Plugin test configuration
85
+ * @returns Complete plugin test scenario
86
+ */
87
+ export declare function createPluginTestScenario(pluginName: string, options?: {
88
+ actions?: string[];
89
+ providers?: string[];
90
+ evaluators?: string[];
91
+ services?: string[];
92
+ conversationSteps?: string[];
93
+ }): {
94
+ runtime: IAgentRuntime;
95
+ character: import("@elizaos/core").Character;
96
+ state: State;
97
+ roomId: `${string}-${string}-${string}-${string}-${string}`;
98
+ conversation: Memory[];
99
+ components: {
100
+ actions: Action[];
101
+ providers: Provider[];
102
+ evaluators: Evaluator[];
103
+ };
104
+ helpers: {
105
+ executeAction: (actionName: string, message?: Memory) => Promise<void | ActionResult>;
106
+ getProviderData: (providerName: string, message?: Memory) => Promise<import("@elizaos/core").ProviderResult>;
107
+ runEvaluator: (evaluatorName: string, message?: Memory) => Promise<void | ActionResult>;
108
+ };
109
+ };
110
+ /**
111
+ * Create a multi-agent test scenario
112
+ *
113
+ * @param agentCount - Number of agents to create
114
+ * @param options - Multi-agent test configuration
115
+ * @returns Multi-agent test scenario
116
+ */
117
+ export declare function createMultiAgentScenario(agentCount?: number, options?: {
118
+ sharedRoomId?: UUID;
119
+ agentNames?: string[];
120
+ conversationSteps?: Array<{
121
+ agentIndex: number;
122
+ message: string;
123
+ }>;
124
+ }): {
125
+ agents: {
126
+ runtime: IAgentRuntime;
127
+ character: import("@elizaos/core").Character;
128
+ index: number;
129
+ }[];
130
+ sharedRoomId: `${string}-${string}-${string}-${string}-${string}`;
131
+ conversation: Memory[];
132
+ helpers: {
133
+ sendMessage: (agentIndex: number, text: string) => Memory;
134
+ getAgentByName: (name: string) => {
135
+ runtime: IAgentRuntime;
136
+ character: import("@elizaos/core").Character;
137
+ index: number;
138
+ };
139
+ };
140
+ };
141
+ //# sourceMappingURL=factories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factories.d.ts","sourceRoot":"","sources":["../../src/factories.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,aAAa,EACb,MAAM,EACN,KAAK,EACL,MAAM,EACN,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,YAAY,EAEb,MAAM,eAAe,CAAC;AAOvB;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,GAAE;IACP,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,gBAAgB,CAAC,EAAE,GAAG,CAAC;IACvB,kBAAkB,CAAC,EAAE,GAAG,CAAC;CACrB;;;;;;EAwCP;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IACP,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC;CACb,GACL,MAAM,CAoCR;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IACP,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,IAAI,CAAC,EAAE,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runtime testing infrastructure.
5
+ *
6
+ * **RECOMMENDED**: Use real runtime testing for reliable, production-like validation
7
+ * **LEGACY**: Mock utilities are deprecated due to false confidence issues
8
+ *
9
+ * Real runtime testing:
10
+ * - Uses actual AgentRuntime instances
11
+ * - Tests real functionality, not mocks
12
+ * - Catches actual bugs that mocks miss
13
+ * - Provides genuine confidence in code reliability
14
+ *
15
+ * @example Real Runtime Testing (Recommended)
16
+ * ```typescript
17
+ * import { createTestRuntime, runIntegrationTest } from '@elizaos/core/test-utils';
18
+ *
19
+ * const result = await runIntegrationTest('Test name', async (runtime) => {
20
+ * const response = await runtime.processMessage({
21
+ * content: { text: 'Hello, world!' },
22
+ * entityId: 'test-user',
23
+ * roomId: 'test-room',
24
+ * });
25
+ *
26
+ * // Test actual functionality
27
+ * expect(response.content.text).toBeDefined();
28
+ * });
29
+ * ```
30
+ *
31
+ * @example Legacy Mock Testing (Deprecated)
32
+ * ```typescript
33
+ * import { createMockRuntime, createMockMemory } from '@elizaos/core/test-utils';
34
+ *
35
+ * const mockRuntime = createMockRuntime({
36
+ * getSetting: mock().mockReturnValue('test-value')
37
+ * });
38
+ * ```
39
+ */
40
+ export * from './realRuntime';
41
+ export * from './templates';
42
+ export * from './testDatabase';
43
+ export * from './testModels';
44
+ export * from './factories';
45
+ export * from './mocks/character';
46
+ export * from './mocks/database';
47
+ export * from './mocks/memory';
48
+ export * from './mocks/mockUtils';
49
+ export * from './mocks/runtime';
50
+ export * from './mocks/services';
51
+ export * from './mocks/state';
52
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAKH,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAK7B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @fileoverview Mock implementations for Character and related interfaces
3
+ *
4
+ * This module provides comprehensive mock implementations for character objects,
5
+ * agent configurations, and personality definitions.
6
+ */
7
+ import type { Character } from '@elizaos/core';
8
+ /**
9
+ * Type representing overrides for Character mock creation
10
+ */
11
+ export type MockCharacterOverrides = Partial<Character>;
12
+ /**
13
+ * Create a comprehensive mock Character with intelligent defaults
14
+ *
15
+ * This function provides a fully-featured character mock that includes
16
+ * realistic personality traits, message examples, and configuration.
17
+ *
18
+ * @param overrides - Partial object to override specific properties
19
+ * @returns Complete mock Character object
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * import { createMockCharacter } from '@elizaos/core/test-utils';
24
+ *
25
+ * const mockCharacter = createMockCharacter({
26
+ * name: 'CustomAgent',
27
+ * bio: ['A specialized test agent'],
28
+ * plugins: ['@elizaos/plugin-test']
29
+ * });
30
+ * ```
31
+ */
32
+ export declare function createMockCharacter(overrides?: MockCharacterOverrides): Character;
33
+ /**
34
+ * Create a minimal mock character with only required fields
35
+ *
36
+ * @param name - Character name
37
+ * @param overrides - Additional overrides
38
+ * @returns Minimal mock character
39
+ */
40
+ export declare function createMinimalMockCharacter(name?: string, overrides?: MockCharacterOverrides): Character;
41
+ /**
42
+ * Create a mock character for specific plugin testing
43
+ *
44
+ * @param pluginName - Name of the plugin to test
45
+ * @param overrides - Additional overrides
46
+ * @returns Plugin-specific mock character
47
+ */
48
+ export declare function createPluginTestCharacter(pluginName: string, overrides?: MockCharacterOverrides): Character;
49
+ /**
50
+ * Create a mock character with extensive conversation examples
51
+ *
52
+ * @param overrides - Additional overrides
53
+ * @returns Character with rich conversation examples
54
+ */
55
+ export declare function createRichConversationCharacter(overrides?: MockCharacterOverrides): Character;
56
+ /**
57
+ * Create multiple mock characters for multi-agent testing
58
+ *
59
+ * @param count - Number of characters to create
60
+ * @param baseName - Base name for characters (will be numbered)
61
+ * @param overrides - Common overrides for all characters
62
+ * @returns Array of mock characters
63
+ */
64
+ export declare function createMultipleCharacters(count?: number, baseName?: string, overrides?: MockCharacterOverrides): Character[];
65
+ //# sourceMappingURL=character.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"character.d.ts","sourceRoot":"","sources":["../../../src/mocks/character.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAwB,MAAM,eAAe,CAAC;AAErE;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAExD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,GAAE,sBAA2B,GAAG,SAAS,CAuIrF;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,GAAE,MAA2B,EACjC,SAAS,GAAE,sBAA2B,GACrC,SAAS,CAcX;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,MAAM,EAClB,SAAS,GAAE,sBAA2B,GACrC,SAAS,CASX;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,SAAS,GAAE,sBAA2B,GAAG,SAAS,CA2CjG;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,GAAE,MAAU,EACjB,QAAQ,GAAE,MAAoB,EAC9B,SAAS,GAAE,sBAA2B,GACrC,SAAS,EAAE,CAgBb"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @fileoverview Mock implementations for IDatabaseAdapter and related database interfaces
3
+ *
4
+ * This module provides comprehensive mock implementations for database operations,
5
+ * supporting both unit and integration testing scenarios.
6
+ */
7
+ import type { IDatabaseAdapter } from '@elizaos/core';
8
+ /**
9
+ * Type representing overrides for IDatabaseAdapter mock creation
10
+ */
11
+ export type MockDatabaseOverrides = Partial<IDatabaseAdapter>;
12
+ /**
13
+ * Create a comprehensive mock of IDatabaseAdapter with intelligent defaults
14
+ *
15
+ * This function provides a fully-featured database adapter mock that implements
16
+ * all database operations with sensible defaults and proper return types.
17
+ *
18
+ * @param overrides - Partial object to override specific methods or properties
19
+ * @returns Complete mock implementation of IDatabaseAdapter
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * import { createMockDatabase } from '@elizaos/core/test-utils';
24
+ * import { mock } from 'bun:test';
25
+ *
26
+ * const mockDb = createMockDatabase({
27
+ * getMemories: mock().mockResolvedValue([mockMemory]),
28
+ * createMemory: mock().mockResolvedValue('memory-id')
29
+ * });
30
+ * ```
31
+ */
32
+ export declare function createMockDatabase(overrides?: MockDatabaseOverrides): IDatabaseAdapter;
33
+ /**
34
+ * Create a simple mock database connection object
35
+ *
36
+ * @param overrides - Partial object to override specific methods
37
+ * @returns Mock database connection
38
+ */
39
+ export declare function createMockDbConnection(overrides?: any): any;
40
+ //# sourceMappingURL=database.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../src/mocks/database.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAQ,MAAM,eAAe,CAAC;AAG5D;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,GAAE,qBAA0B,GAAG,gBAAgB,CAgH1F;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,GAAE,GAAQ,OAczD"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * @fileoverview Mock implementations for Memory and related interfaces
3
+ *
4
+ * This module provides comprehensive mock implementations for memory objects,
5
+ * content structures, and memory-related operations.
6
+ */
7
+ import type { Content, Media, Memory, UUID } from '@elizaos/core';
8
+ /**
9
+ * Type representing overrides for Memory mock creation
10
+ */
11
+ export type MockMemoryOverrides = Partial<Memory>;
12
+ /**
13
+ * Type representing overrides for Content mock creation
14
+ */
15
+ export type MockContentOverrides = Partial<Content>;
16
+ /**
17
+ * Create a comprehensive mock Memory object with intelligent defaults
18
+ *
19
+ * This function provides a fully-featured memory mock that includes
20
+ * realistic content, metadata, and proper typing.
21
+ *
22
+ * @param overrides - Partial object to override specific properties
23
+ * @returns Complete mock Memory object
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * import { createMockMemory } from '@elizaos/core/test-utils';
28
+ *
29
+ * const mockMessage = createMockMemory({
30
+ * content: { text: 'Hello, world!' },
31
+ * entityId: 'user-123'
32
+ * });
33
+ * ```
34
+ */
35
+ export declare function createMockMemory(overrides?: MockMemoryOverrides): Memory;
36
+ /**
37
+ * Create a mock Content object with intelligent defaults
38
+ *
39
+ * @param overrides - Partial object to override specific properties
40
+ * @returns Complete mock Content object
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * import { createMockContent } from '@elizaos/core/test-utils';
45
+ *
46
+ * const mockContent = createMockContent({
47
+ * text: 'Custom message',
48
+ * actions: ['SEND_MESSAGE']
49
+ * });
50
+ * ```
51
+ */
52
+ export declare function createMockContent(overrides?: MockContentOverrides): Content;
53
+ /**
54
+ * Create a mock conversation memory (user message)
55
+ *
56
+ * @param text - The message text
57
+ * @param overrides - Additional overrides
58
+ * @returns Mock user message memory
59
+ */
60
+ export declare function createMockUserMessage(text: string, overrides?: MockMemoryOverrides): Memory;
61
+ /**
62
+ * Create a mock agent response memory
63
+ *
64
+ * @param text - The response text
65
+ * @param thought - Optional internal thought
66
+ * @param actions - Optional actions executed
67
+ * @param overrides - Additional overrides
68
+ * @returns Mock agent response memory
69
+ */
70
+ export declare function createMockAgentResponse(text: string, thought?: string, actions?: string[], overrides?: MockMemoryOverrides): Memory;
71
+ /**
72
+ * Create a mock fact memory for knowledge storage
73
+ *
74
+ * @param fact - The factual claim
75
+ * @param confidence - Confidence level (0-1)
76
+ * @param overrides - Additional overrides
77
+ * @returns Mock fact memory
78
+ */
79
+ export declare function createMockFact(fact: string, confidence?: number, overrides?: MockMemoryOverrides): Memory;
80
+ /**
81
+ * Create a mock memory with embedding vector
82
+ *
83
+ * @param text - The text content
84
+ * @param dimension - Embedding dimension (default: 1536 for OpenAI)
85
+ * @param overrides - Additional overrides
86
+ * @returns Mock memory with embedding
87
+ */
88
+ export declare function createMockMemoryWithEmbedding(text: string, dimension?: number, overrides?: MockMemoryOverrides): Memory;
89
+ /**
90
+ * Create a batch of mock conversation memories
91
+ *
92
+ * @param count - Number of memories to create
93
+ * @param roomId - Room ID for all memories
94
+ * @returns Array of mock conversation memories
95
+ */
96
+ export declare function createMockConversation(count?: number, roomId?: UUID): Memory[];
97
+ /**
98
+ * Create a mock Media attachment
99
+ *
100
+ * @param type - Media type
101
+ * @param url - Media URL
102
+ * @param overrides - Additional overrides
103
+ * @returns Mock Media object
104
+ */
105
+ export declare function createMockMedia(type?: 'image' | 'video' | 'audio' | 'document', url?: string, overrides?: Partial<Media>): Media;
106
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/mocks/memory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAEV,OAAO,EACP,KAAK,EACL,MAAM,EAGN,IAAI,EACL,MAAM,eAAe,CAAC;AAGvB;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAElD;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,GAAE,mBAAwB,GAAG,MAAM,CA8B5E;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,GAAE,oBAAyB,GAAG,OAAO,CAgB/E;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,mBAAwB,GAAG,MAAM,CAY/F;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,GAAE,MAAM,EAAO,EACtB,SAAS,GAAE,mBAAwB,GAClC,MAAM,CAeR;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,UAAU,GAAE,MAAY,EACxB,SAAS,GAAE,mBAAwB,GAClC,MAAM,CAaR;AAED;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,MAAM,EACZ,SAAS,GAAE,MAAa,EACxB,SAAS,GAAE,mBAAwB,GAClC,MAAM,CAQR;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,GAAE,MAAU,EAAE,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,EAAE,CAkBjF;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,IAAI,GAAE,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,UAAoB,EACxD,GAAG,GAAE,MAAuC,EAC5C,SAAS,GAAE,OAAO,CAAC,KAAK,CAAM,GAC7B,KAAK,CAkBP"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Simple mock utility for test utils that doesn't depend on bun:test
3
+ */
4
+ export interface MockFunction<T = any> {
5
+ (...args: any[]): T;
6
+ mockReturnValue: (value: T) => MockFunction<T>;
7
+ mockResolvedValue: (value: T) => MockFunction<T>;
8
+ mockRejectedValue: (error: any) => MockFunction<T>;
9
+ mockImplementation: (fn: (...args: any[]) => T) => MockFunction<T>;
10
+ calls: any[][];
11
+ mock: {
12
+ calls: any[][];
13
+ results: any[];
14
+ };
15
+ }
16
+ export declare function mock<T = any>(implementation?: (...args: any[]) => T): MockFunction<T>;
17
+ //# sourceMappingURL=mockUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mockUtils.d.ts","sourceRoot":"","sources":["../../../src/mocks/mockUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,GAAG;IACnC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IACpB,eAAe,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC;IAC/C,iBAAiB,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC;IACjD,iBAAiB,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC;IACnD,kBAAkB,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC;IACnE,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC;IAGf,IAAI,EAAE;QACJ,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC;QACf,OAAO,EAAE,GAAG,EAAE,CAAC;KAChB,CAAC;CACH;AAED,wBAAgB,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,cAAc,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CA8DrF"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @fileoverview Mock implementations for IAgentRuntime and related interfaces
3
+ *
4
+ * This module provides comprehensive mock implementations for the core runtime interfaces,
5
+ * designed to support both unit testing and integration testing scenarios.
6
+ */
7
+ import type { IAgentRuntime, IDatabaseAdapter } from '@elizaos/core';
8
+ /**
9
+ * Type representing overrides for IAgentRuntime mock creation
10
+ */
11
+ export type MockRuntimeOverrides = Partial<IAgentRuntime & IDatabaseAdapter>;
12
+ /**
13
+ * Create a comprehensive mock of IAgentRuntime with intelligent defaults
14
+ *
15
+ * This function provides a fully-featured mock that implements both IAgentRuntime
16
+ * and IDatabaseAdapter interfaces, ensuring compatibility with all test scenarios.
17
+ *
18
+ * @param overrides - Partial object to override specific methods or properties
19
+ * @returns Complete mock implementation of IAgentRuntime
20
+ *
21
+ * @deprecated Use real runtime testing instead: import { createTestRuntime } from '@elizaos/core/test-utils'
22
+ *
23
+ * @example Legacy Mock Testing (Deprecated)
24
+ * ```typescript
25
+ * import { createMockRuntime } from '@elizaos/core/test-utils';
26
+ *
27
+ * const mockRuntime = createMockRuntime({
28
+ * getSetting: () => 'test-api-key',
29
+ * useModel: () => Promise.resolve('mock response')
30
+ * });
31
+ * ```
32
+ */
33
+ export declare function createMockRuntime(overrides?: MockRuntimeOverrides): IAgentRuntime;
34
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/mocks/runtime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAEV,aAAa,EACb,gBAAgB,EAIjB,MAAM,eAAe,CAAC;AAGvB;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,aAAa,GAAG,gBAAgB,CAAC,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,GAAE,oBAAyB,GAAG,aAAa,CA6MrF"}