@elizaos/cli 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/README.md +1 -1
  2. package/dist/{chunk-2CUIHNPL.js → chunk-5GUS4CFO.js} +7 -2
  3. package/dist/{chunk-2ALAPQLV.js → chunk-E6XYTE3A.js} +296 -311
  4. package/dist/chunk-GXWWPFBO.js +39 -0
  5. package/dist/{chunk-I77ZRNYO.js → chunk-T2QDIXGU.js} +2 -2
  6. package/dist/commands/agent/actions/index.d.ts +5 -0
  7. package/dist/commands/agent/actions/index.js +2 -2
  8. package/dist/commands/agent/index.d.ts +2 -2
  9. package/dist/commands/agent/index.js +2 -2
  10. package/dist/commands/create/actions/index.js +3 -3
  11. package/dist/commands/create/index.js +4 -4
  12. package/dist/commands/shared/index.d.ts +11 -28
  13. package/dist/commands/shared/index.js +7 -3
  14. package/dist/index.js +541 -450
  15. package/dist/{registry-N626N4VG.js → registry-433S5F3Y.js} +2 -2
  16. package/dist/templates/plugin-quick-starter/.gitignore +66 -0
  17. package/dist/templates/plugin-quick-starter/.npmignore +5 -0
  18. package/dist/templates/plugin-quick-starter/package.json +11 -3
  19. package/dist/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +499 -146
  20. package/dist/templates/plugin-quick-starter/src/__tests__/test-utils.ts +316 -115
  21. package/dist/templates/plugin-quick-starter/src/plugin.ts +7 -13
  22. package/dist/templates/plugin-starter/.gitignore +66 -0
  23. package/dist/templates/plugin-starter/.npmignore +5 -0
  24. package/dist/templates/plugin-starter/README.md +1 -1
  25. package/dist/templates/plugin-starter/package.json +11 -3
  26. package/dist/templates/plugin-starter/src/__tests__/integration.test.ts +13 -13
  27. package/dist/templates/plugin-starter/src/__tests__/plugin.test.ts +556 -129
  28. package/dist/templates/plugin-starter/src/__tests__/test-utils.ts +347 -115
  29. package/dist/templates/plugin-starter/src/plugin.ts +18 -22
  30. package/dist/templates/project-starter/.gitignore +57 -0
  31. package/dist/templates/project-starter/.npmignore +11 -0
  32. package/dist/templates/project-starter/README.md +1 -1
  33. package/dist/templates/project-starter/package.json +4 -4
  34. package/dist/templates/project-starter/src/__tests__/env.test.ts +3 -1
  35. package/dist/templates/project-starter/src/__tests__/file-structure.test.ts +3 -2
  36. package/dist/templates/project-starter/src/__tests__/integration.test.ts +1 -1
  37. package/dist/templates/project-starter/tsup.config.ts +2 -1
  38. package/dist/templates/project-tee-starter/.dockerignore +64 -14
  39. package/dist/templates/project-tee-starter/.gitignore +57 -0
  40. package/dist/templates/project-tee-starter/.npmignore +6 -0
  41. package/dist/templates/project-tee-starter/Dockerfile +9 -5
  42. package/dist/templates/project-tee-starter/GUIDE.md +103 -42
  43. package/dist/templates/project-tee-starter/README.md +39 -19
  44. package/dist/templates/project-tee-starter/__tests__/build-order.test.ts +62 -0
  45. package/dist/templates/project-tee-starter/__tests__/character.test.ts +19 -17
  46. package/dist/templates/project-tee-starter/__tests__/config.test.ts +10 -3
  47. package/dist/templates/project-tee-starter/__tests__/env.test.ts +2 -1
  48. package/dist/templates/project-tee-starter/__tests__/file-structure.test.ts +14 -3
  49. package/dist/templates/project-tee-starter/__tests__/frontend.test.ts +459 -0
  50. package/dist/templates/project-tee-starter/__tests__/plugin.test.ts +4 -2
  51. package/dist/templates/project-tee-starter/__tests__/routes.test.ts +15 -6
  52. package/dist/templates/project-tee-starter/__tests__/tee-validation.test.ts +295 -0
  53. package/dist/templates/project-tee-starter/__tests__/vite-config-utils.ts +39 -0
  54. package/dist/templates/project-tee-starter/docker-compose.yaml +5 -2
  55. package/dist/templates/{plugin-starter/dist → project-tee-starter}/index.html +3 -3
  56. package/dist/templates/project-tee-starter/package.json +34 -14
  57. package/dist/templates/project-tee-starter/postcss.config.js +3 -0
  58. package/dist/templates/project-tee-starter/scripts/install-test-deps.js +52 -0
  59. package/dist/templates/project-tee-starter/scripts/test-all.sh +82 -0
  60. package/dist/templates/project-tee-starter/src/frontend/index.css +106 -0
  61. package/dist/templates/project-tee-starter/src/frontend/index.html +20 -0
  62. package/dist/templates/project-tee-starter/src/frontend/index.tsx +370 -0
  63. package/dist/templates/project-tee-starter/src/frontend/panels.tsx +17 -0
  64. package/dist/templates/project-tee-starter/src/frontend/utils.ts +6 -0
  65. package/dist/templates/project-tee-starter/src/index.ts +6 -6
  66. package/dist/templates/project-tee-starter/src/plugin.ts +209 -59
  67. package/dist/templates/project-tee-starter/tailwind.config.js +62 -0
  68. package/dist/templates/project-tee-starter/tsconfig.build.json +2 -2
  69. package/dist/templates/project-tee-starter/tsconfig.json +8 -5
  70. package/dist/templates/project-tee-starter/tsup.config.ts +3 -2
  71. package/dist/templates/project-tee-starter/vite.config.ts +39 -0
  72. package/dist/url-utils-CKc_Ebt_.d.ts +35 -0
  73. package/dist/{utils-H66532NB.js → utils-DBLSDYBF.js} +2 -2
  74. package/package.json +12 -7
  75. package/templates/plugin-quick-starter/.gitignore +66 -0
  76. package/templates/plugin-quick-starter/.npmignore +5 -0
  77. package/templates/plugin-quick-starter/package.json +11 -3
  78. package/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +499 -146
  79. package/templates/plugin-quick-starter/src/__tests__/test-utils.ts +316 -115
  80. package/templates/plugin-quick-starter/src/plugin.ts +7 -13
  81. package/templates/plugin-starter/.gitignore +66 -0
  82. package/templates/plugin-starter/.npmignore +5 -0
  83. package/templates/plugin-starter/README.md +1 -1
  84. package/templates/plugin-starter/package.json +11 -3
  85. package/templates/plugin-starter/src/__tests__/integration.test.ts +13 -13
  86. package/templates/plugin-starter/src/__tests__/plugin.test.ts +556 -129
  87. package/templates/plugin-starter/src/__tests__/test-utils.ts +347 -115
  88. package/templates/plugin-starter/src/plugin.ts +18 -22
  89. package/templates/project-starter/.gitignore +57 -0
  90. package/templates/project-starter/.npmignore +11 -0
  91. package/templates/project-starter/README.md +1 -1
  92. package/templates/project-starter/package.json +4 -4
  93. package/templates/project-starter/src/__tests__/env.test.ts +3 -1
  94. package/templates/project-starter/src/__tests__/file-structure.test.ts +3 -2
  95. package/templates/project-starter/src/__tests__/integration.test.ts +1 -1
  96. package/templates/project-starter/tsup.config.ts +2 -1
  97. package/templates/project-tee-starter/.dockerignore +64 -14
  98. package/templates/project-tee-starter/.gitignore +57 -0
  99. package/templates/project-tee-starter/.npmignore +6 -0
  100. package/templates/project-tee-starter/Dockerfile +9 -5
  101. package/templates/project-tee-starter/GUIDE.md +103 -42
  102. package/templates/project-tee-starter/README.md +39 -19
  103. package/templates/project-tee-starter/__tests__/build-order.test.ts +62 -0
  104. package/templates/project-tee-starter/__tests__/character.test.ts +19 -17
  105. package/templates/project-tee-starter/__tests__/config.test.ts +10 -3
  106. package/templates/project-tee-starter/__tests__/env.test.ts +2 -1
  107. package/templates/project-tee-starter/__tests__/file-structure.test.ts +14 -3
  108. package/templates/project-tee-starter/__tests__/frontend.test.ts +459 -0
  109. package/templates/project-tee-starter/__tests__/plugin.test.ts +4 -2
  110. package/templates/project-tee-starter/__tests__/routes.test.ts +15 -6
  111. package/templates/project-tee-starter/__tests__/tee-validation.test.ts +295 -0
  112. package/templates/project-tee-starter/__tests__/vite-config-utils.ts +39 -0
  113. package/templates/project-tee-starter/docker-compose.yaml +5 -2
  114. package/templates/{plugin-starter/dist → project-tee-starter}/index.html +3 -3
  115. package/templates/project-tee-starter/package.json +34 -14
  116. package/templates/project-tee-starter/postcss.config.js +3 -0
  117. package/templates/project-tee-starter/scripts/install-test-deps.js +52 -0
  118. package/templates/project-tee-starter/scripts/test-all.sh +82 -0
  119. package/templates/project-tee-starter/src/frontend/index.css +106 -0
  120. package/templates/project-tee-starter/src/frontend/index.html +20 -0
  121. package/templates/project-tee-starter/src/frontend/index.tsx +370 -0
  122. package/templates/project-tee-starter/src/frontend/panels.tsx +17 -0
  123. package/templates/project-tee-starter/src/frontend/utils.ts +6 -0
  124. package/templates/project-tee-starter/src/index.ts +6 -6
  125. package/templates/project-tee-starter/src/plugin.ts +209 -59
  126. package/templates/project-tee-starter/tailwind.config.js +62 -0
  127. package/templates/project-tee-starter/tsconfig.build.json +2 -2
  128. package/templates/project-tee-starter/tsconfig.json +8 -5
  129. package/templates/project-tee-starter/tsup.config.ts +3 -2
  130. package/templates/project-tee-starter/vite.config.ts +39 -0
  131. package/dist/chunk-4O6EZU37.js +0 -14
  132. package/dist/migration-guides/advanced-migration-guide.md +0 -459
  133. package/dist/migration-guides/completion-requirements.md +0 -379
  134. package/dist/migration-guides/integrated-migration-loop.md +0 -392
  135. package/dist/migration-guides/migration-guide.md +0 -712
  136. package/dist/migration-guides/prompt-and-generation-guide.md +0 -702
  137. package/dist/migration-guides/state-and-providers-guide.md +0 -544
  138. package/dist/migration-guides/testing-guide.md +0 -1021
  139. package/dist/templates/plugin-starter/dist/assets/index-CgkejLs_.css +0 -1
  140. package/dist/templates/plugin-starter/dist/assets/index-D1cHX53P.js +0 -49
  141. package/dist/templates/plugin-starter/dist/index.js +0 -387
  142. package/dist/templates/plugin-starter/dist/index.js.map +0 -1
  143. package/templates/plugin-starter/dist/.vite/manifest.json +0 -11
  144. package/templates/plugin-starter/dist/assets/index-CgkejLs_.css +0 -1
  145. package/templates/plugin-starter/dist/assets/index-D1cHX53P.js +0 -49
  146. package/templates/plugin-starter/dist/index.d.ts +0 -14
  147. package/templates/plugin-starter/dist/index.js +0 -387
  148. package/templates/plugin-starter/dist/index.js.map +0 -1
@@ -1,162 +1,363 @@
1
1
  import { mock, spyOn } from 'bun:test';
2
2
  import {
3
- Content,
4
- IAgentRuntime,
5
- Memory,
3
+ type IAgentRuntime,
4
+ type Memory,
5
+ type State,
6
+ type Content,
7
+ type UUID,
8
+ type Character,
9
+ type Service,
10
+ type ServiceTypeName,
6
11
  ModelType,
7
- Service,
8
- State,
9
- UUID,
12
+ asUUID,
10
13
  logger,
11
14
  } from '@elizaos/core';
12
15
 
13
16
  /**
14
- * Creates a mock runtime for testing
15
- *
16
- * @param overrides - Optional overrides for the default mock methods and properties
17
- * @returns A mock runtime for testing
17
+ * Creates a UUID for testing
18
18
  */
19
- export function createMockRuntime(overrides: Partial<MockRuntime> = {}): MockRuntime {
20
- // Create base mock runtime with defaults
21
- const mockRuntime: MockRuntime = {
22
- // Core properties
23
- agentId: 'test-agent-id' as UUID,
24
- character: {
25
- name: 'Test Character',
26
- bio: 'This is a test character for testing',
19
+ export function createUUID(): UUID {
20
+ return asUUID(crypto.randomUUID());
21
+ }
22
+
23
+ /**
24
+ * Creates a test character
25
+ */
26
+ export function createTestCharacter(overrides: Partial<Character> = {}): Character {
27
+ return {
28
+ id: createUUID(),
29
+ name: 'Test Character',
30
+ username: 'test-character',
31
+ bio: 'A test character for unit testing',
32
+ system: 'You are a helpful assistant for testing.',
33
+ plugins: [],
34
+ settings: {},
35
+ messageExamples: [],
36
+ topics: [],
37
+ adjectives: [],
38
+ style: { all: [], chat: [], post: [] },
39
+ secrets: {},
40
+ ...overrides,
41
+ };
42
+ }
43
+
44
+ /**
45
+ * Creates a test memory
46
+ */
47
+ export function createTestMemory(overrides: Partial<Memory> = {}): Memory {
48
+ const now = Date.now();
49
+ return {
50
+ id: createUUID(),
51
+ agentId: createUUID(),
52
+ entityId: createUUID(),
53
+ roomId: createUUID(),
54
+ content: {
55
+ text: 'Test message',
56
+ source: 'test',
27
57
  },
28
- services: new Map(),
58
+ createdAt: now,
59
+ ...overrides,
60
+ };
61
+ }
29
62
 
30
- // Core methods
63
+ /**
64
+ * Creates a test state
65
+ */
66
+ export function createTestState(overrides: Partial<State> = {}): State {
67
+ return {
68
+ agentId: createUUID(),
69
+ roomId: createUUID(),
70
+ userId: createUUID(),
71
+ bio: 'Test bio',
72
+ lore: 'Test lore',
73
+ userName: 'Test User',
74
+ userBio: 'Test user bio',
75
+ actors: '',
76
+ recentMessages: '',
77
+ recentInteractions: '',
78
+ goals: 'Test goals',
79
+ image: '',
80
+ messageDirections: '',
81
+ values: {},
82
+ data: {},
83
+ text: '',
84
+ ...overrides,
85
+ };
86
+ }
87
+
88
+ /**
89
+ * Creates a properly typed mock runtime
90
+ */
91
+ export function createMockRuntime(overrides: Partial<IAgentRuntime> = {}): IAgentRuntime {
92
+ const agentId = overrides.agentId || createUUID();
93
+ const character = overrides.character || createTestCharacter();
94
+
95
+ // Create base runtime object with all required properties
96
+ const mockRuntime: IAgentRuntime = {
97
+ // Properties
98
+ agentId,
99
+ character,
100
+ providers: [],
101
+ actions: [],
102
+ evaluators: [],
103
+ plugins: [],
104
+ services: new Map<ServiceTypeName, Service[]>(),
105
+ events: new Map(),
106
+ fetch: null,
107
+ routes: [],
108
+ logger: {
109
+ info: mock(() => {}),
110
+ warn: mock(() => {}),
111
+ error: mock(() => {}),
112
+ debug: mock(() => {}),
113
+ },
114
+ db: {},
115
+
116
+ // Database methods
117
+ initialize: mock().mockResolvedValue(undefined),
118
+ init: mock().mockResolvedValue(undefined),
119
+ runMigrations: mock().mockResolvedValue(undefined),
120
+ isReady: mock().mockResolvedValue(true),
121
+ close: mock().mockResolvedValue(undefined),
122
+ getConnection: mock().mockResolvedValue({}),
123
+
124
+ // Agent methods
125
+ getAgent: mock().mockResolvedValue(null),
126
+ getAgents: mock().mockResolvedValue([]),
127
+ createAgent: mock().mockResolvedValue(true),
128
+ updateAgent: mock().mockResolvedValue(true),
129
+ deleteAgent: mock().mockResolvedValue(true),
130
+
131
+ // Memory methods
132
+ createMemory: mock().mockImplementation(async (memory: Memory) => ({
133
+ ...memory,
134
+ id: memory.id || createUUID(),
135
+ })),
136
+ getMemories: mock().mockResolvedValue([]),
137
+ getMemoryById: mock().mockResolvedValue(null),
138
+ getMemoriesByIds: mock().mockResolvedValue([]),
139
+ getMemoriesByRoomIds: mock().mockResolvedValue([]),
140
+ searchMemories: mock().mockResolvedValue([]),
141
+ addEmbeddingToMemory: mock().mockImplementation(async (memory: Memory) => memory),
142
+ getAllMemories: mock().mockResolvedValue([]),
143
+ clearAllAgentMemories: mock().mockResolvedValue(undefined),
144
+ updateMemory: mock().mockResolvedValue(true),
145
+ deleteMemory: mock().mockResolvedValue(undefined),
146
+ deleteManyMemories: mock().mockResolvedValue(undefined),
147
+ deleteAllMemories: mock().mockResolvedValue(undefined),
148
+ countMemories: mock().mockResolvedValue(0),
149
+
150
+ // Entity methods
151
+ getEntitiesByIds: mock().mockResolvedValue([]),
152
+ getEntitiesForRoom: mock().mockResolvedValue([]),
153
+ createEntities: mock().mockResolvedValue(true),
154
+ updateEntity: mock().mockResolvedValue(undefined),
155
+ createEntity: mock().mockResolvedValue(true),
156
+ getEntityById: mock().mockResolvedValue(null),
157
+
158
+ // Room methods
159
+ createRoom: mock().mockImplementation(async () => createUUID()),
160
+ createRooms: mock().mockImplementation(async () => [createUUID()]),
161
+ getRoom: mock().mockResolvedValue(null),
162
+ getRooms: mock().mockResolvedValue([]),
163
+ getRoomsByIds: mock().mockResolvedValue([]),
164
+ getRoomsByWorld: mock().mockResolvedValue([]),
165
+ updateRoom: mock().mockResolvedValue(undefined),
166
+ deleteRoom: mock().mockResolvedValue(undefined),
167
+ deleteRoomsByWorldId: mock().mockResolvedValue(undefined),
168
+ addParticipant: mock().mockResolvedValue(true),
169
+ addParticipantsRoom: mock().mockResolvedValue(true),
170
+ removeParticipant: mock().mockResolvedValue(true),
171
+ getRoomsForParticipant: mock().mockResolvedValue([]),
172
+ getRoomsForParticipants: mock().mockResolvedValue([]),
173
+ getParticipantsForEntity: mock().mockResolvedValue([]),
174
+ getParticipantsForRoom: mock().mockResolvedValue([]),
175
+ getParticipantUserState: mock().mockResolvedValue(null),
176
+ setParticipantUserState: mock().mockResolvedValue(undefined),
177
+
178
+ // Service methods
31
179
  getService: mock().mockReturnValue(null),
32
- registerService: mock(),
33
- getSetting: mock().mockReturnValue(null),
180
+ getServicesByType: mock().mockReturnValue([]),
181
+ getAllServices: mock().mockReturnValue(new Map()),
182
+ registerService: mock().mockResolvedValue(undefined),
183
+ getRegisteredServiceTypes: mock().mockReturnValue([]),
184
+ hasService: mock().mockReturnValue(false),
185
+
186
+ // Plugin/Action/Provider methods
187
+ registerPlugin: mock().mockResolvedValue(undefined),
188
+ registerProvider: mock().mockReturnValue(undefined),
189
+ registerAction: mock().mockReturnValue(undefined),
190
+ registerEvaluator: mock().mockReturnValue(undefined),
34
191
 
35
192
  // Model methods
36
- useModel: mock().mockImplementation((modelType, params) => {
193
+ registerModel: mock().mockReturnValue(undefined),
194
+ getModel: mock().mockReturnValue(undefined),
195
+ useModel: mock().mockImplementation(async (modelType: string) => {
37
196
  if (modelType === ModelType.TEXT_SMALL) {
38
- return Promise.resolve('Never gonna give you up, never gonna let you down');
197
+ return 'Never gonna give you up, never gonna let you down';
39
198
  } else if (modelType === ModelType.TEXT_LARGE) {
40
- return Promise.resolve('Never gonna make you cry, never gonna say goodbye');
41
- } else if (modelType === ModelType.OBJECT_LARGE) {
42
- return Promise.resolve({
43
- thought: 'I should respond in a friendly way',
44
- message: 'Hello there! How can I help you today?',
45
- });
199
+ return 'Never gonna make you cry, never gonna say goodbye';
46
200
  }
47
- return Promise.resolve('Default response');
201
+ return 'Default model response';
48
202
  }),
49
203
 
50
- // Additional methods used in tests
51
- init: mock().mockResolvedValue(undefined),
204
+ // Event methods
205
+ registerEvent: mock().mockReturnValue(undefined),
206
+ getEvent: mock().mockReturnValue(undefined),
207
+ emitEvent: mock().mockResolvedValue(undefined),
208
+
209
+ // Settings methods
210
+ setSetting: mock().mockReturnValue(undefined),
211
+ getSetting: mock().mockImplementation((key: string) => {
212
+ if (key === 'EXAMPLE_PLUGIN_VARIABLE') return 'test-value';
213
+ return null;
214
+ }),
215
+
216
+ // Other methods
217
+ processActions: mock().mockResolvedValue(undefined),
218
+ evaluate: mock().mockResolvedValue(null),
219
+ ensureConnections: mock().mockResolvedValue(undefined),
220
+ ensureConnection: mock().mockResolvedValue(undefined),
221
+ getConversationLength: mock().mockReturnValue(10),
222
+ composeState: mock().mockImplementation(async () => createTestState()),
223
+ // Task methods
224
+ getTasks: mock().mockResolvedValue([]),
225
+ getTask: mock().mockResolvedValue(null),
226
+ getTasksByName: mock().mockResolvedValue([]),
227
+ createTask: mock().mockImplementation(async () => createUUID()),
228
+ updateTask: mock().mockResolvedValue(undefined),
229
+ deleteTask: mock().mockResolvedValue(undefined),
230
+ registerTaskWorker: mock().mockReturnValue(undefined),
231
+ getTaskWorker: mock().mockReturnValue(undefined),
232
+ stop: mock().mockResolvedValue(undefined),
233
+ createRunId: mock().mockImplementation(() => createUUID()),
234
+ startRun: mock().mockImplementation(() => createUUID()),
235
+ endRun: mock().mockReturnValue(undefined),
236
+ getCurrentRunId: mock().mockImplementation(() => createUUID()),
237
+ registerSendHandler: mock().mockReturnValue(undefined),
238
+ sendMessageToTarget: mock().mockResolvedValue(undefined),
239
+ registerDatabaseAdapter: mock().mockReturnValue(undefined),
240
+ log: mock().mockResolvedValue(undefined),
241
+ getLogs: mock().mockResolvedValue([]),
242
+ deleteLog: mock().mockResolvedValue(undefined),
243
+
244
+ // Component methods (from IDatabaseAdapter)
245
+ getComponent: mock().mockResolvedValue(null),
246
+ getComponents: mock().mockResolvedValue([]),
247
+ createComponent: mock().mockResolvedValue(true),
248
+ updateComponent: mock().mockResolvedValue(undefined),
249
+ deleteComponent: mock().mockResolvedValue(undefined),
250
+
251
+ // Relationship methods
252
+ createRelationship: mock().mockResolvedValue(true),
253
+ getRelationships: mock().mockResolvedValue([]),
254
+ getRelationship: mock().mockResolvedValue(null),
255
+ updateRelationship: mock().mockResolvedValue(undefined),
256
+
257
+ // Embedding methods
258
+ ensureEmbeddingDimension: mock().mockResolvedValue(undefined),
259
+ getCachedEmbeddings: mock().mockResolvedValue([]),
260
+
261
+ // World methods
262
+ getWorld: mock().mockResolvedValue(null),
263
+ createWorld: mock().mockImplementation(async () => createUUID()),
264
+ updateWorld: mock().mockResolvedValue(undefined),
265
+ removeWorld: mock().mockResolvedValue(undefined),
266
+ getAllWorlds: mock().mockResolvedValue([]),
267
+
268
+ // Required method that was missing
269
+ ensureParticipantInRoom: mock().mockResolvedValue(undefined),
270
+ ensureWorldExists: mock().mockResolvedValue(undefined),
271
+ ensureRoomExists: mock().mockResolvedValue(undefined),
272
+
273
+ // Cache methods
274
+ getCache: mock().mockResolvedValue(undefined),
275
+ setCache: mock().mockResolvedValue(true),
276
+ deleteCache: mock().mockResolvedValue(true),
277
+
278
+ // Other missing database methods
279
+ getMemoriesByWorldId: mock().mockResolvedValue([]),
280
+
281
+ // Apply any overrides
52
282
  ...overrides,
53
283
  };
54
284
 
55
- // Merge with overrides
285
+ // Setup logger spies if not already overridden
286
+ if (!overrides.logger) {
287
+ spyOn(logger, 'info').mockImplementation(() => {});
288
+ spyOn(logger, 'warn').mockImplementation(() => {});
289
+ spyOn(logger, 'error').mockImplementation(() => {});
290
+ spyOn(logger, 'debug').mockImplementation(() => {});
291
+ }
292
+
56
293
  return mockRuntime;
57
294
  }
58
295
 
59
296
  /**
60
- * Creates a mock Memory object for testing
61
- *
62
- * @param overrides - Optional overrides for the default memory properties
63
- * @returns A mock memory object
297
+ * Creates test fixtures for event payloads
64
298
  */
65
- export function createMockMemory(overrides: Partial<Memory> = {}): Partial<Memory> {
66
- return {
67
- id: 'test-message-id' as UUID,
68
- roomId: 'test-room-id' as UUID,
69
- entityId: 'test-entity-id' as UUID,
70
- agentId: 'test-agent-id' as UUID,
299
+ export const testFixtures = {
300
+ messagePayload: (overrides: any = {}) => ({
71
301
  content: {
72
302
  text: 'Test message',
73
303
  source: 'test',
74
- } as Content,
75
- createdAt: Date.now(),
304
+ },
305
+ userId: createUUID(),
306
+ roomId: createUUID(),
307
+ runtime: createMockRuntime(),
308
+ source: 'test',
76
309
  ...overrides,
77
- };
78
- }
310
+ }),
311
+
312
+ worldPayload: (overrides: any = {}) => ({
313
+ content: {
314
+ text: 'World event',
315
+ world: 'test-world',
316
+ },
317
+ userId: createUUID(),
318
+ roomId: createUUID(),
319
+ runtime: createMockRuntime(),
320
+ source: 'test',
321
+ ...overrides,
322
+ }),
323
+ };
79
324
 
80
325
  /**
81
- * Creates a mock State object for testing
82
- *
83
- * @param overrides - Optional overrides for the default state properties
84
- * @returns A mock state object
326
+ * Type guard to check if a value is a mock function
85
327
  */
86
- export function createMockState(overrides: Partial<State> = {}): Partial<State> {
87
- return {
88
- ...overrides,
89
- values: {
90
- recentMessages: 'User: Test message',
91
- ...overrides.values,
92
- },
93
- data: {
94
- ...overrides.data,
95
- },
96
- };
328
+ export function isMockFunction(value: any): value is ReturnType<typeof mock> {
329
+ return value && typeof value.mock === 'object';
97
330
  }
98
331
 
99
332
  /**
100
- * Creates a standardized setup for testing with consistent mock objects
101
- *
102
- * @param overrides - Optional overrides for default mock implementations
103
- * @returns An object containing mockRuntime, mockMessage, mockState, and callbackFn
333
+ * Helper to assert spy was called with specific arguments
104
334
  */
105
- export function setupTest(
106
- overrides: {
107
- runtimeOverrides?: Partial<MockRuntime>;
108
- messageOverrides?: Partial<Memory>;
109
- stateOverrides?: Partial<State>;
110
- } = {}
111
- ) {
112
- // Create mock callback function
113
- const callbackFn = mock();
114
-
115
- // Create a message
116
- const mockMessage = createMockMemory(overrides.messageOverrides);
117
-
118
- // Create a state object
119
- const mockState = createMockState(overrides.stateOverrides);
120
-
121
- // Create a mock runtime
122
- const mockRuntime = createMockRuntime({
123
- ...overrides.runtimeOverrides,
124
- });
335
+ export function assertSpyCalledWith(spy: any, ...args: any[]) {
336
+ if (!isMockFunction(spy)) {
337
+ throw new Error('Not a mock function');
338
+ }
125
339
 
126
- return {
127
- mockRuntime,
128
- mockMessage,
129
- mockState,
130
- callbackFn,
131
- };
340
+ const calls = spy.mock.calls;
341
+ const found = calls.some((call: any[]) =>
342
+ args.every((arg, index) => {
343
+ if (typeof arg === 'object' && arg !== null) {
344
+ return JSON.stringify(arg) === JSON.stringify(call[index]);
345
+ }
346
+ return arg === call[index];
347
+ })
348
+ );
349
+
350
+ if (!found) {
351
+ throw new Error(`Spy was not called with expected arguments: ${JSON.stringify(args)}`);
352
+ }
132
353
  }
133
354
 
134
355
  /**
135
- * Type definition for the mock runtime
356
+ * Setup logger spies for testing
136
357
  */
137
- export interface MockRuntime {
138
- agentId: UUID;
139
- character: {
140
- name: string;
141
- bio: string;
142
- [key: string]: any;
143
- };
144
- services: Map<string, Service>;
145
- getService: ReturnType<typeof mock>;
146
- registerService: ReturnType<typeof mock>;
147
- getSetting: ReturnType<typeof mock>;
148
- useModel: ReturnType<typeof mock>;
149
- init: ReturnType<typeof mock>;
150
- [key: string]: any;
151
- }
152
-
153
- // Add spy on logger for common usage in tests
154
358
  export function setupLoggerSpies() {
155
359
  spyOn(logger, 'info').mockImplementation(() => {});
156
- spyOn(logger, 'error').mockImplementation(() => {});
157
360
  spyOn(logger, 'warn').mockImplementation(() => {});
361
+ spyOn(logger, 'error').mockImplementation(() => {});
158
362
  spyOn(logger, 'debug').mockImplementation(() => {});
159
-
160
- // allow tests to restore originals
161
- return () => mock.restore();
162
363
  }
@@ -74,23 +74,18 @@ const helloWorldAction: Action = {
74
74
  _responses?: Memory[]
75
75
  ): Promise<ActionResult> => {
76
76
  try {
77
- logger.info('Handling HELLO_WORLD action');
77
+ const response = 'Hello world!';
78
78
 
79
- // Simple response content for callback
80
- const responseContent: Content = {
81
- text: 'hello world!',
82
- actions: ['HELLO_WORLD'],
83
- source: message.content.source,
84
- };
85
-
86
- // Call back with the hello world message if callback is provided
87
79
  if (callback) {
88
- await callback(responseContent);
80
+ await callback({
81
+ text: response,
82
+ actions: ['HELLO_WORLD'],
83
+ source: message.content.source,
84
+ });
89
85
  }
90
86
 
91
- // Return ActionResult
92
87
  return {
93
- text: 'hello world!',
88
+ text: response,
94
89
  success: true,
95
90
  data: {
96
91
  actions: ['HELLO_WORLD'],
@@ -98,7 +93,6 @@ const helloWorldAction: Action = {
98
93
  },
99
94
  };
100
95
  } catch (error) {
101
- logger.error('Error in HELLO_WORLD action:', error);
102
96
  return {
103
97
  success: false,
104
98
  error: error instanceof Error ? error : new Error(String(error)),
@@ -0,0 +1,66 @@
1
+ # Build outputs
2
+ dist/
3
+ node_modules/
4
+
5
+ # Environment files
6
+ .env
7
+ .env.local
8
+ .env.production
9
+ .env.staging
10
+ .env.development
11
+ .env.bak
12
+ *.env
13
+
14
+ # OS files
15
+ .DS_Store
16
+ Thumbs.db
17
+
18
+ # IDE files
19
+ .vscode/
20
+ .idea/
21
+ *.swp
22
+ *.swo
23
+
24
+ # Logs
25
+ *.log
26
+ npm-debug.log*
27
+ yarn-debug.log*
28
+ yarn-error.log*
29
+
30
+ # Runtime data
31
+ pids/
32
+ *.pid
33
+ *.seed
34
+ *.pid.lock
35
+
36
+ # Coverage directory used by tools like istanbul
37
+ coverage/
38
+
39
+ # Cache directories
40
+ .cache/
41
+ .npm/
42
+ .eslintcache
43
+
44
+ # Temporary folders
45
+ tmp/
46
+ temp/
47
+
48
+ # Database files
49
+ *.db
50
+ *.pglite
51
+ *.pglite3
52
+
53
+ # ElizaOS specific
54
+ .eliza/
55
+ .elizadb/
56
+ pglite/
57
+ cache/
58
+
59
+ generatedImages/
60
+ images/
61
+ data/
62
+ .eliza
63
+ .elizadb-test
64
+
65
+ dist/
66
+ coverage/
@@ -0,0 +1,5 @@
1
+ .turbo
2
+ node_modules
3
+ .env
4
+ *.env
5
+ .env.local
@@ -55,7 +55,7 @@ ElizaOS provides a comprehensive testing structure for plugins:
55
55
 
56
56
  ### Writing Tests
57
57
 
58
- Component tests use Vitest:
58
+ Component tests use bun:test:
59
59
 
60
60
  ```typescript
61
61
  // Unit test example (__tests__/plugin.test.ts)
@@ -36,11 +36,12 @@
36
36
  "dist",
37
37
  "README.md",
38
38
  ".npmignore",
39
+ ".gitignore",
39
40
  "package.json",
40
41
  "tsup.config.ts"
41
42
  ],
42
43
  "dependencies": {
43
- "@elizaos/core": "1.3.0",
44
+ "@elizaos/core": "1.3.2",
44
45
  "@tanstack/react-query": "^5.80.7",
45
46
  "clsx": "^2.1.1",
46
47
  "tailwind-merge": "^3.3.1",
@@ -49,7 +50,7 @@
49
50
  "zod": "3.24.2"
50
51
  },
51
52
  "devDependencies": {
52
- "@elizaos/cli": "1.2.10",
53
+ "@elizaos/cli": "1.3.2",
53
54
  "@tailwindcss/vite": "^4.1.10",
54
55
  "@vitejs/plugin-react-swc": "^3.10.2",
55
56
  "dotenv": "16.4.5",
@@ -63,6 +64,7 @@
63
64
  "dev": "elizaos dev",
64
65
  "build": "tsc --noEmit && vite build && tsup",
65
66
  "lint": "prettier --write ./src",
67
+ "postinstall": "node -e \"const fs=require('fs');const path=require('path');const zodPath=path.join('node_modules','zod');if(fs.existsSync(zodPath)){fs.writeFileSync(path.join(zodPath,'v3.js'),'module.exports=require(\\\"./lib/index.js\\\");');fs.writeFileSync(path.join(zodPath,'v3.d.ts'),'export * from \\\"./lib/index\\\";');}\" || true",
66
68
  "test:component": "bun run test:install && bun test",
67
69
  "test:e2e": "bun run test:install && bun test",
68
70
  "test:e2e:manual": "bun run test:install && node scripts/test-e2e-manual.js",
@@ -76,7 +78,13 @@
76
78
  "access": "public"
77
79
  },
78
80
  "resolutions": {
79
- "zod": "3.24.2"
81
+ "// Note": "langchain 0.3.30 fixes @langchain/core zod/v3 import issues",
82
+ "zod": "3.24.2",
83
+ "langchain": "0.3.30",
84
+ "@langchain/core": "0.3.30"
85
+ },
86
+ "overrides": {
87
+ "@langchain/core": "0.3.30"
80
88
  },
81
89
  "agentConfig": {
82
90
  "pluginType": "elizaos:plugin:1.0.0",