@elizaos/core 1.5.3-beta.3 → 1.5.5-alpha.10

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 (181) hide show
  1. package/dist/actions.d.ts +23 -0
  2. package/dist/actions.d.ts.map +1 -0
  3. package/dist/browser/index.browser.js +172 -179
  4. package/dist/browser/index.browser.js.map +6 -197
  5. package/dist/browser/index.d.ts +2 -2
  6. package/dist/database.d.ts +481 -0
  7. package/dist/database.d.ts.map +1 -0
  8. package/dist/entities.d.ts +49 -0
  9. package/dist/entities.d.ts.map +1 -0
  10. package/{src/index.browser.ts → dist/index.browser.d.ts} +9 -21
  11. package/dist/index.browser.d.ts.map +1 -0
  12. package/dist/index.d.ts +27 -3
  13. package/dist/index.d.ts.map +1 -0
  14. package/{src/index.node.ts → dist/index.node.d.ts} +3 -16
  15. package/dist/index.node.d.ts.map +1 -0
  16. package/dist/logger.d.ts +47 -0
  17. package/dist/logger.d.ts.map +1 -0
  18. package/dist/node/index.d.ts +2 -2
  19. package/dist/node/index.node.js +15514 -439
  20. package/dist/node/index.node.js.map +139 -8
  21. package/dist/prompts.d.ts +8 -0
  22. package/dist/prompts.d.ts.map +1 -0
  23. package/dist/roles.d.ts +30 -0
  24. package/dist/roles.d.ts.map +1 -0
  25. package/dist/runtime.d.ts +328 -0
  26. package/dist/runtime.d.ts.map +1 -0
  27. package/dist/schemas/character.d.ts +228 -0
  28. package/dist/schemas/character.d.ts.map +1 -0
  29. package/dist/search.d.ts +317 -0
  30. package/dist/search.d.ts.map +1 -0
  31. package/dist/sentry/instrument.browser.d.ts +12 -0
  32. package/dist/sentry/instrument.browser.d.ts.map +1 -0
  33. package/dist/sentry/instrument.d.ts +12 -0
  34. package/dist/sentry/instrument.d.ts.map +1 -0
  35. package/dist/sentry/instrument.node.d.ts +11 -0
  36. package/dist/sentry/instrument.node.d.ts.map +1 -0
  37. package/dist/services.d.ts +49 -0
  38. package/dist/services.d.ts.map +1 -0
  39. package/dist/settings.d.ts +87 -0
  40. package/dist/settings.d.ts.map +1 -0
  41. package/{src/types/agent.ts → dist/types/agent.d.ts} +60 -74
  42. package/dist/types/agent.d.ts.map +1 -0
  43. package/dist/types/browser.d.ts +127 -0
  44. package/dist/types/browser.d.ts.map +1 -0
  45. package/dist/types/components.d.ts +135 -0
  46. package/dist/types/components.d.ts.map +1 -0
  47. package/dist/types/database.d.ts +278 -0
  48. package/dist/types/database.d.ts.map +1 -0
  49. package/dist/types/email.d.ts +143 -0
  50. package/dist/types/email.d.ts.map +1 -0
  51. package/dist/types/environment.d.ts +109 -0
  52. package/dist/types/environment.d.ts.map +1 -0
  53. package/dist/types/events.d.ts +207 -0
  54. package/dist/types/events.d.ts.map +1 -0
  55. package/{src/types/index.ts → dist/types/index.d.ts} +1 -0
  56. package/dist/types/index.d.ts.map +1 -0
  57. package/{src/types/knowledge.ts → dist/types/knowledge.d.ts} +18 -23
  58. package/dist/types/knowledge.d.ts.map +1 -0
  59. package/dist/types/lp.d.ts +115 -0
  60. package/dist/types/lp.d.ts.map +1 -0
  61. package/{src/types/memory.ts → dist/types/memory.d.ts} +69 -132
  62. package/dist/types/memory.d.ts.map +1 -0
  63. package/dist/types/message.d.ts +202 -0
  64. package/dist/types/message.d.ts.map +1 -0
  65. package/dist/types/messaging.d.ts +45 -0
  66. package/dist/types/messaging.d.ts.map +1 -0
  67. package/dist/types/model.d.ts +319 -0
  68. package/dist/types/model.d.ts.map +1 -0
  69. package/dist/types/pdf.d.ts +68 -0
  70. package/dist/types/pdf.d.ts.map +1 -0
  71. package/dist/types/plugin.d.ts +64 -0
  72. package/dist/types/plugin.d.ts.map +1 -0
  73. package/dist/types/post.d.ts +242 -0
  74. package/dist/types/post.d.ts.map +1 -0
  75. package/dist/types/primitives.d.ts +72 -0
  76. package/dist/types/primitives.d.ts.map +1 -0
  77. package/dist/types/runtime.d.ts +106 -0
  78. package/dist/types/runtime.d.ts.map +1 -0
  79. package/{src/types/service.ts → dist/types/service.d.ts} +69 -120
  80. package/dist/types/service.d.ts.map +1 -0
  81. package/dist/types/settings.d.ts +30 -0
  82. package/dist/types/settings.d.ts.map +1 -0
  83. package/{src/types/state.ts → dist/types/state.d.ts} +18 -19
  84. package/dist/types/state.d.ts.map +1 -0
  85. package/dist/types/task.d.ts +68 -0
  86. package/dist/types/task.d.ts.map +1 -0
  87. package/dist/types/tee.d.ts +97 -0
  88. package/dist/types/tee.d.ts.map +1 -0
  89. package/dist/types/testing.d.ts +29 -0
  90. package/dist/types/testing.d.ts.map +1 -0
  91. package/dist/types/token.d.ts +73 -0
  92. package/dist/types/token.d.ts.map +1 -0
  93. package/dist/types/transcription.d.ts +108 -0
  94. package/dist/types/transcription.d.ts.map +1 -0
  95. package/dist/types/video.d.ts +93 -0
  96. package/dist/types/video.d.ts.map +1 -0
  97. package/dist/types/wallet.d.ts +49 -0
  98. package/dist/types/wallet.d.ts.map +1 -0
  99. package/dist/types/web-search.d.ts +112 -0
  100. package/dist/types/web-search.d.ts.map +1 -0
  101. package/dist/utils/buffer.d.ts +105 -0
  102. package/dist/utils/buffer.d.ts.map +1 -0
  103. package/dist/utils/environment.d.ts +106 -0
  104. package/dist/utils/environment.d.ts.map +1 -0
  105. package/dist/utils/server-health.d.ts +23 -0
  106. package/dist/utils/server-health.d.ts.map +1 -0
  107. package/dist/utils.d.ts +177 -0
  108. package/dist/utils.d.ts.map +1 -0
  109. package/package.json +5 -5
  110. package/src/__tests__/action-chaining-simple.test.ts +0 -203
  111. package/src/__tests__/actions.test.ts +0 -218
  112. package/src/__tests__/buffer.test.ts +0 -337
  113. package/src/__tests__/character-validation.test.ts +0 -309
  114. package/src/__tests__/database.test.ts +0 -750
  115. package/src/__tests__/entities.test.ts +0 -727
  116. package/src/__tests__/env.test.ts +0 -23
  117. package/src/__tests__/environment.test.ts +0 -285
  118. package/src/__tests__/logger-browser-node.test.ts +0 -716
  119. package/src/__tests__/logger.test.ts +0 -403
  120. package/src/__tests__/messages.test.ts +0 -196
  121. package/src/__tests__/mockCharacter.ts +0 -544
  122. package/src/__tests__/parsing.test.ts +0 -58
  123. package/src/__tests__/prompts.test.ts +0 -159
  124. package/src/__tests__/roles.test.ts +0 -331
  125. package/src/__tests__/runtime-embedding.test.ts +0 -343
  126. package/src/__tests__/runtime.test.ts +0 -978
  127. package/src/__tests__/search.test.ts +0 -15
  128. package/src/__tests__/services-by-type.test.ts +0 -204
  129. package/src/__tests__/services.test.ts +0 -136
  130. package/src/__tests__/settings.test.ts +0 -810
  131. package/src/__tests__/utils.test.ts +0 -1105
  132. package/src/__tests__/uuid.test.ts +0 -94
  133. package/src/actions.ts +0 -122
  134. package/src/database.ts +0 -579
  135. package/src/entities.ts +0 -406
  136. package/src/index.ts +0 -50
  137. package/src/logger.ts +0 -527
  138. package/src/prompts.ts +0 -243
  139. package/src/roles.ts +0 -85
  140. package/src/runtime.ts +0 -2514
  141. package/src/schemas/character.ts +0 -149
  142. package/src/search.ts +0 -1543
  143. package/src/sentry/instrument.browser.ts +0 -65
  144. package/src/sentry/instrument.node.ts +0 -57
  145. package/src/sentry/instrument.ts +0 -82
  146. package/src/services.ts +0 -105
  147. package/src/settings.ts +0 -409
  148. package/src/test_resources/constants.ts +0 -12
  149. package/src/test_resources/testSetup.ts +0 -21
  150. package/src/test_resources/types.ts +0 -22
  151. package/src/types/browser.ts +0 -145
  152. package/src/types/components.ts +0 -184
  153. package/src/types/database.ts +0 -348
  154. package/src/types/email.ts +0 -162
  155. package/src/types/environment.ts +0 -129
  156. package/src/types/events.ts +0 -249
  157. package/src/types/lp.ts +0 -124
  158. package/src/types/message.ts +0 -233
  159. package/src/types/messaging.ts +0 -57
  160. package/src/types/model.ts +0 -359
  161. package/src/types/pdf.ts +0 -77
  162. package/src/types/plugin.ts +0 -78
  163. package/src/types/post.ts +0 -271
  164. package/src/types/primitives.ts +0 -97
  165. package/src/types/runtime.ts +0 -190
  166. package/src/types/settings.ts +0 -30
  167. package/src/types/task.ts +0 -72
  168. package/src/types/tee.ts +0 -107
  169. package/src/types/testing.ts +0 -30
  170. package/src/types/token.ts +0 -96
  171. package/src/types/transcription.ts +0 -133
  172. package/src/types/video.ts +0 -108
  173. package/src/types/wallet.ts +0 -56
  174. package/src/types/web-search.ts +0 -146
  175. package/src/utils/__tests__/buffer.test.ts +0 -80
  176. package/src/utils/__tests__/environment.test.ts +0 -58
  177. package/src/utils/__tests__/stringToUuid.test.ts +0 -88
  178. package/src/utils/buffer.ts +0 -312
  179. package/src/utils/environment.ts +0 -316
  180. package/src/utils/server-health.ts +0 -117
  181. 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
- });