@elizaos/core 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.
Files changed (90) hide show
  1. package/README.md +0 -15
  2. package/dist/index.d.ts +4886 -3
  3. package/dist/index.js +5287 -4
  4. package/package.json +21 -39
  5. package/dist/browser/index.browser.js +0 -1109
  6. package/dist/browser/index.browser.js.map +0 -707
  7. package/dist/browser/index.d.ts +0 -3
  8. package/dist/node/index.d.ts +0 -3
  9. package/dist/node/index.node.js +0 -74530
  10. package/dist/node/index.node.js.map +0 -1027
  11. package/src/__tests__/action-chaining-simple.test.ts +0 -203
  12. package/src/__tests__/actions.test.ts +0 -218
  13. package/src/__tests__/buffer.test.ts +0 -337
  14. package/src/__tests__/character-validation.test.ts +0 -309
  15. package/src/__tests__/database.test.ts +0 -750
  16. package/src/__tests__/entities.test.ts +0 -727
  17. package/src/__tests__/env.test.ts +0 -23
  18. package/src/__tests__/environment.test.ts +0 -285
  19. package/src/__tests__/logger-browser-node.test.ts +0 -716
  20. package/src/__tests__/logger.test.ts +0 -403
  21. package/src/__tests__/messages.test.ts +0 -196
  22. package/src/__tests__/mockCharacter.ts +0 -544
  23. package/src/__tests__/parsing.test.ts +0 -58
  24. package/src/__tests__/prompts.test.ts +0 -159
  25. package/src/__tests__/roles.test.ts +0 -331
  26. package/src/__tests__/runtime-embedding.test.ts +0 -343
  27. package/src/__tests__/runtime.test.ts +0 -978
  28. package/src/__tests__/search.test.ts +0 -15
  29. package/src/__tests__/services-by-type.test.ts +0 -204
  30. package/src/__tests__/services.test.ts +0 -136
  31. package/src/__tests__/settings.test.ts +0 -810
  32. package/src/__tests__/utils.test.ts +0 -1105
  33. package/src/__tests__/uuid.test.ts +0 -94
  34. package/src/actions.ts +0 -122
  35. package/src/database.ts +0 -579
  36. package/src/entities.ts +0 -406
  37. package/src/index.browser.ts +0 -48
  38. package/src/index.node.ts +0 -39
  39. package/src/index.ts +0 -50
  40. package/src/logger.ts +0 -527
  41. package/src/prompts.ts +0 -243
  42. package/src/roles.ts +0 -85
  43. package/src/runtime.ts +0 -2514
  44. package/src/schemas/character.ts +0 -149
  45. package/src/search.ts +0 -1543
  46. package/src/sentry/instrument.browser.ts +0 -65
  47. package/src/sentry/instrument.node.ts +0 -57
  48. package/src/sentry/instrument.ts +0 -82
  49. package/src/services.ts +0 -105
  50. package/src/settings.ts +0 -409
  51. package/src/test_resources/constants.ts +0 -12
  52. package/src/test_resources/testSetup.ts +0 -21
  53. package/src/test_resources/types.ts +0 -22
  54. package/src/types/agent.ts +0 -112
  55. package/src/types/browser.ts +0 -145
  56. package/src/types/components.ts +0 -184
  57. package/src/types/database.ts +0 -348
  58. package/src/types/email.ts +0 -162
  59. package/src/types/environment.ts +0 -129
  60. package/src/types/events.ts +0 -249
  61. package/src/types/index.ts +0 -29
  62. package/src/types/knowledge.ts +0 -65
  63. package/src/types/lp.ts +0 -124
  64. package/src/types/memory.ts +0 -228
  65. package/src/types/message.ts +0 -233
  66. package/src/types/messaging.ts +0 -57
  67. package/src/types/model.ts +0 -359
  68. package/src/types/pdf.ts +0 -77
  69. package/src/types/plugin.ts +0 -78
  70. package/src/types/post.ts +0 -271
  71. package/src/types/primitives.ts +0 -97
  72. package/src/types/runtime.ts +0 -190
  73. package/src/types/service.ts +0 -198
  74. package/src/types/settings.ts +0 -30
  75. package/src/types/state.ts +0 -60
  76. package/src/types/task.ts +0 -72
  77. package/src/types/tee.ts +0 -107
  78. package/src/types/testing.ts +0 -30
  79. package/src/types/token.ts +0 -96
  80. package/src/types/transcription.ts +0 -133
  81. package/src/types/video.ts +0 -108
  82. package/src/types/wallet.ts +0 -56
  83. package/src/types/web-search.ts +0 -146
  84. package/src/utils/__tests__/buffer.test.ts +0 -80
  85. package/src/utils/__tests__/environment.test.ts +0 -58
  86. package/src/utils/__tests__/stringToUuid.test.ts +0 -88
  87. package/src/utils/buffer.ts +0 -312
  88. package/src/utils/environment.ts +0 -316
  89. package/src/utils/server-health.ts +0 -117
  90. package/src/utils.ts +0 -1076
@@ -1,15 +0,0 @@
1
- import { describe, it, expect } from 'bun:test';
2
- import { BM25 } from '../search';
3
-
4
- describe('BM25 search', () => {
5
- it('indexes documents and finds matches', () => {
6
- const docs = [
7
- { text: 'hello world' },
8
- { text: 'another document' },
9
- { text: 'world of javascript' },
10
- ];
11
- const bm = new BM25(docs, { fieldBoosts: { text: 1 } });
12
- const results = bm.search('world');
13
- expect(results[0].index).toBe(0);
14
- });
15
- });
@@ -1,204 +0,0 @@
1
- import { describe, it, expect, beforeEach } from 'bun:test';
2
- import { AgentRuntime } from '../runtime';
3
- import { ServiceType, UUID } from '../types';
4
- import { Service } from '../types/service';
5
- import { IAgentRuntime } from '../types/runtime';
6
- import { v4 as uuidv4 } from 'uuid';
7
-
8
- // Mock service classes for testing
9
- class MockWalletService1 extends Service {
10
- static override readonly serviceType = ServiceType.WALLET;
11
- readonly capabilityDescription = 'Mock wallet service 1';
12
-
13
- constructor(runtime: IAgentRuntime) {
14
- super(runtime);
15
- }
16
-
17
- static async start(runtime: IAgentRuntime): Promise<MockWalletService1> {
18
- return new MockWalletService1(runtime);
19
- }
20
-
21
- async stop(): Promise<void> {
22
- // Mock stop implementation
23
- }
24
- }
25
-
26
- class MockWalletService2 extends Service {
27
- static override readonly serviceType = ServiceType.WALLET;
28
- readonly capabilityDescription = 'Mock wallet service 2';
29
-
30
- constructor(runtime: IAgentRuntime) {
31
- super(runtime);
32
- }
33
-
34
- static async start(runtime: IAgentRuntime): Promise<MockWalletService2> {
35
- return new MockWalletService2(runtime);
36
- }
37
-
38
- async stop(): Promise<void> {
39
- // Mock stop implementation
40
- }
41
- }
42
-
43
- class MockPdfService extends Service {
44
- static override readonly serviceType = ServiceType.PDF;
45
- readonly capabilityDescription = 'Mock PDF service';
46
-
47
- constructor(runtime: IAgentRuntime) {
48
- super(runtime);
49
- }
50
-
51
- static async start(runtime: IAgentRuntime): Promise<MockPdfService> {
52
- return new MockPdfService(runtime);
53
- }
54
-
55
- async stop(): Promise<void> {
56
- // Mock stop implementation
57
- }
58
- }
59
-
60
- describe('Service Type System', () => {
61
- let runtime: AgentRuntime;
62
-
63
- beforeEach(() => {
64
- runtime = new AgentRuntime({
65
- agentId: uuidv4() as UUID,
66
- character: {
67
- name: 'Test Agent',
68
- username: 'test',
69
- clients: [],
70
- },
71
- });
72
- });
73
-
74
- describe('Multiple services of same type', () => {
75
- it('should allow registering multiple services of the same type', async () => {
76
- // Register two wallet services
77
- await runtime.registerService(MockWalletService1);
78
- await runtime.registerService(MockWalletService2);
79
-
80
- // Both should be registered
81
- expect(runtime.hasService(ServiceType.WALLET)).toBe(true);
82
-
83
- // Get all wallet services
84
- const walletServices = runtime.getServicesByType(ServiceType.WALLET);
85
- expect(walletServices).toHaveLength(2);
86
-
87
- // Check that both service instances are different
88
- expect(walletServices[0]).toBeInstanceOf(MockWalletService1);
89
- expect(walletServices[1]).toBeInstanceOf(MockWalletService2);
90
- });
91
-
92
- it('should return first service when using getService', async () => {
93
- // Register two wallet services
94
- await runtime.registerService(MockWalletService1);
95
- await runtime.registerService(MockWalletService2);
96
-
97
- // getService should return the first registered service
98
- const firstService = runtime.getService(ServiceType.WALLET);
99
- expect(firstService).toBeInstanceOf(MockWalletService1);
100
- });
101
-
102
- it('should return empty array for non-existent service type', () => {
103
- const services = runtime.getServicesByType('non-existent-type');
104
- expect(services).toHaveLength(0);
105
- });
106
-
107
- it('should return null for non-existent service type with getService', () => {
108
- const service = runtime.getService('non-existent-type');
109
- expect(service).toBe(null);
110
- });
111
- });
112
-
113
- describe('Mixed service types', () => {
114
- it('should handle multiple service types correctly', async () => {
115
- // Register services of different types
116
- await runtime.registerService(MockWalletService1);
117
- await runtime.registerService(MockWalletService2);
118
- await runtime.registerService(MockPdfService);
119
-
120
- // Check wallet services
121
- const walletServices = runtime.getServicesByType(ServiceType.WALLET);
122
- expect(walletServices).toHaveLength(2);
123
-
124
- // Check PDF services
125
- const pdfServices = runtime.getServicesByType(ServiceType.PDF);
126
- expect(pdfServices).toHaveLength(1);
127
- expect(pdfServices[0]).toBeInstanceOf(MockPdfService);
128
-
129
- // Check non-existent service type
130
- const videoServices = runtime.getServicesByType(ServiceType.VIDEO);
131
- expect(videoServices).toHaveLength(0);
132
- });
133
-
134
- it('should return correct services with getAllServices', async () => {
135
- await runtime.registerService(MockWalletService1);
136
- await runtime.registerService(MockWalletService2);
137
- await runtime.registerService(MockPdfService);
138
-
139
- const allServices = runtime.getAllServices();
140
-
141
- // Should have 2 service types
142
- expect(allServices.size).toBe(2);
143
-
144
- // Wallet type should have 2 services
145
- expect(allServices.get(ServiceType.WALLET)).toHaveLength(2);
146
-
147
- // PDF type should have 1 service
148
- expect(allServices.get(ServiceType.PDF)).toHaveLength(1);
149
- });
150
- });
151
-
152
- describe('Service type validation', () => {
153
- it('should handle hasService correctly with multiple services', async () => {
154
- expect(runtime.hasService(ServiceType.WALLET)).toBe(false);
155
-
156
- await runtime.registerService(MockWalletService1);
157
- expect(runtime.hasService(ServiceType.WALLET)).toBe(true);
158
-
159
- await runtime.registerService(MockWalletService2);
160
- expect(runtime.hasService(ServiceType.WALLET)).toBe(true);
161
- });
162
-
163
- it('should return correct service types with getRegisteredServiceTypes', async () => {
164
- await runtime.registerService(MockWalletService1);
165
- await runtime.registerService(MockPdfService);
166
-
167
- const serviceTypes = runtime.getRegisteredServiceTypes();
168
- expect(serviceTypes).toContain(ServiceType.WALLET);
169
- expect(serviceTypes).toContain(ServiceType.PDF);
170
- expect(serviceTypes).toHaveLength(2);
171
- });
172
- });
173
-
174
- describe('Service lifecycle', () => {
175
- it('should stop all services of all types', async () => {
176
- await runtime.registerService(MockWalletService1);
177
- await runtime.registerService(MockWalletService2);
178
- await runtime.registerService(MockPdfService);
179
-
180
- // Mock the stop methods to track calls
181
- const stopCalls: string[] = [];
182
-
183
- const walletServices = runtime.getServicesByType(ServiceType.WALLET);
184
- const pdfServices = runtime.getServicesByType(ServiceType.PDF);
185
-
186
- walletServices[0].stop = async () => {
187
- stopCalls.push('wallet1');
188
- };
189
- walletServices[1].stop = async () => {
190
- stopCalls.push('wallet2');
191
- };
192
- pdfServices[0].stop = async () => {
193
- stopCalls.push('pdf');
194
- };
195
-
196
- await runtime.stop();
197
-
198
- expect(stopCalls).toContain('wallet1');
199
- expect(stopCalls).toContain('wallet2');
200
- expect(stopCalls).toContain('pdf');
201
- expect(stopCalls).toHaveLength(3);
202
- });
203
- });
204
- });
@@ -1,136 +0,0 @@
1
- import { describe, it, expect, mock } from 'bun:test';
2
- import { createService, defineService } from '../services';
3
- import { Service } from '../types';
4
- import type { IAgentRuntime } from '../types';
5
-
6
- describe('service builder', () => {
7
- // Mock runtime
8
- const mockRuntime = {} as IAgentRuntime;
9
-
10
- it('createService builds custom class', async () => {
11
- const Builder = createService('TEST')
12
- .withDescription('d')
13
- .withStart(
14
- async () =>
15
- new (class extends Service {
16
- capabilityDescription = 'Test service';
17
- async stop() {}
18
- })()
19
- )
20
- .build();
21
- const instance = await (Builder as any).start(mockRuntime);
22
- expect(instance).toBeInstanceOf(Service);
23
- await instance.stop();
24
- });
25
-
26
- it('defineService builds from definition', async () => {
27
- const Def = defineService({
28
- serviceType: 'DEF' as any,
29
- description: 'desc',
30
- start: async () =>
31
- new (class extends Service {
32
- capabilityDescription = 'Definition service';
33
- async stop() {}
34
- })(),
35
- });
36
- const instance = await (Def as any).start(mockRuntime);
37
- expect(instance).toBeInstanceOf(Service);
38
- await instance.stop();
39
- });
40
-
41
- it('should throw error when start function is not defined', async () => {
42
- // This test covers lines 59-60 - error when startFn is not defined
43
- const Builder = createService('NO_START').withDescription('Service without start').build();
44
-
45
- await expect((Builder as any).start(mockRuntime)).rejects.toThrow(
46
- 'Start function not defined for service NO_START'
47
- );
48
- });
49
-
50
- it('should call custom stop function when provided', async () => {
51
- // This test covers lines 65-68 - custom stopFn execution
52
- const stopFn = mock().mockResolvedValue(undefined);
53
-
54
- const Builder = createService('WITH_STOP')
55
- .withDescription('Service with custom stop')
56
- .withStart(
57
- async () =>
58
- new (class extends Service {
59
- capabilityDescription = 'Service with stop';
60
- async stop() {}
61
- })()
62
- )
63
- .withStop(stopFn)
64
- .build();
65
-
66
- await (Builder as any).start(mockRuntime);
67
- const builtInstance = new Builder();
68
- await builtInstance.stop();
69
-
70
- expect(stopFn).toHaveBeenCalled();
71
- });
72
-
73
- it('should handle service without stop function', async () => {
74
- // This test ensures the else branch (no stopFn) is covered
75
- const Builder = createService('NO_STOP')
76
- .withDescription('Service without custom stop')
77
- .withStart(
78
- async () =>
79
- new (class extends Service {
80
- capabilityDescription = 'Service without stop';
81
- async stop() {}
82
- })()
83
- )
84
- .build();
85
-
86
- const builtInstance = new Builder();
87
- // Should not throw when no stopFn is provided
88
- await expect(builtInstance.stop()).resolves.toBeUndefined();
89
- });
90
-
91
- it('defineService should provide default stop function', async () => {
92
- // This test covers the default stop function in defineService
93
- const Def = defineService({
94
- serviceType: 'DEF_NO_STOP' as any,
95
- description: 'Definition without stop',
96
- start: async () =>
97
- new (class extends Service {
98
- capabilityDescription = 'Definition without stop';
99
- async stop() {}
100
- })(),
101
- // Note: no stop function provided
102
- });
103
-
104
- await (Def as any).start(mockRuntime);
105
- const defInstance = new Def();
106
- // Should not throw when using default stop
107
- expect(defInstance.stop()).resolves.toBeUndefined();
108
- });
109
-
110
- it('should set all properties correctly with chaining', () => {
111
- // Test the full builder chain
112
- const description = 'Test service description';
113
- const serviceType = 'CHAINED_SERVICE';
114
-
115
- const builder = createService(serviceType);
116
- const withDesc = builder.withDescription(description);
117
-
118
- // Verify chaining returns the same instance
119
- expect(withDesc).toBe(builder);
120
-
121
- const startFn = async () =>
122
- new (class extends Service {
123
- capabilityDescription = 'Chained service';
124
- async stop() {}
125
- })();
126
- const withStart = withDesc.withStart(startFn);
127
- expect(withStart).toBe(builder);
128
-
129
- const stopFn = async () => {};
130
- const withStop = withStart.withStop(stopFn);
131
- expect(withStop).toBe(builder);
132
-
133
- const BuiltClass = withStop.build();
134
- expect((BuiltClass as any).serviceType).toBe(serviceType);
135
- });
136
- });