@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,394 @@
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 Entity,
6
+ type Room,
7
+ type World,
8
+ type State,
9
+ type Content,
10
+ type UUID,
11
+ type Character,
12
+ type Provider,
13
+ type Action,
14
+ type Evaluator,
15
+ type Plugin,
16
+ type Service,
17
+ type ServiceTypeName,
18
+ type Route,
19
+ type HandlerCallback,
20
+ type SendHandlerFunction,
21
+ type TargetInfo,
22
+ type ModelTypeName,
23
+ type TaskWorker,
24
+ type Component,
25
+ type Relationship,
6
26
  ModelType,
7
- Service,
8
- State,
9
- UUID,
27
+ asUUID,
10
28
  logger,
11
29
  } from '@elizaos/core';
12
30
 
13
31
  /**
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
32
+ * Creates a UUID for testing
18
33
  */
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',
34
+ export function createUUID(): UUID {
35
+ return asUUID(crypto.randomUUID());
36
+ }
37
+
38
+ /**
39
+ * Creates a test character
40
+ */
41
+ export function createTestCharacter(overrides: Partial<Character> = {}): Character {
42
+ return {
43
+ id: createUUID(),
44
+ name: 'Test Character',
45
+ username: 'test-character',
46
+ bio: 'A test character for unit testing',
47
+ system: 'You are a helpful assistant for testing.',
48
+ plugins: [],
49
+ settings: {},
50
+ messageExamples: [],
51
+ topics: [],
52
+ adjectives: [],
53
+ style: { all: [], chat: [], post: [] },
54
+ secrets: {},
55
+ ...overrides,
56
+ };
57
+ }
58
+
59
+ /**
60
+ * Creates a test memory
61
+ */
62
+ export function createTestMemory(overrides: Partial<Memory> = {}): Memory {
63
+ const now = Date.now();
64
+ return {
65
+ id: createUUID(),
66
+ agentId: createUUID(),
67
+ entityId: createUUID(),
68
+ roomId: createUUID(),
69
+ content: {
70
+ text: 'Test message',
71
+ source: 'test',
27
72
  },
28
- services: new Map(),
73
+ createdAt: now,
74
+ ...overrides,
75
+ };
76
+ }
77
+
78
+ /**
79
+ * Creates a test state
80
+ */
81
+ export function createTestState(overrides: Partial<State> = {}): State {
82
+ return {
83
+ agentId: createUUID(),
84
+ roomId: createUUID(),
85
+ userId: createUUID(),
86
+ bio: 'Test bio',
87
+ lore: 'Test lore',
88
+ userName: 'Test User',
89
+ userBio: 'Test user bio',
90
+ actors: '',
91
+ recentMessages: '',
92
+ recentInteractions: '',
93
+ goals: 'Test goals',
94
+ image: '',
95
+ messageDirections: '',
96
+ values: {},
97
+ data: {},
98
+ text: '',
99
+ ...overrides,
100
+ };
101
+ }
102
+
103
+ /**
104
+ * Helper to create a mock function
105
+ */
106
+ function createMockFn<T extends (...args: any[]) => any>(
107
+ implementation?: T
108
+ ): ReturnType<typeof mock> {
109
+ return mock(implementation || (() => {}));
110
+ }
111
+
112
+ /**
113
+ * Creates a properly typed mock runtime
114
+ */
115
+ export function createMockRuntime(overrides: Partial<IAgentRuntime> = {}): IAgentRuntime {
116
+ const agentId = overrides.agentId || createUUID();
117
+ const character = overrides.character || createTestCharacter();
118
+
119
+ // Create base runtime object with all required properties
120
+ const mockRuntime: IAgentRuntime = {
121
+ // Properties
122
+ agentId,
123
+ character,
124
+ providers: [],
125
+ actions: [],
126
+ evaluators: [],
127
+ plugins: [],
128
+ services: new Map<ServiceTypeName, Service[]>(),
129
+ events: new Map(),
130
+ fetch: null,
131
+ routes: [],
132
+ logger: {
133
+ info: mock(() => {}),
134
+ warn: mock(() => {}),
135
+ error: mock(() => {}),
136
+ debug: mock(() => {}),
137
+ },
138
+ db: {},
139
+
140
+ // Database methods
141
+ initialize: mock().mockResolvedValue(undefined),
142
+ init: mock().mockResolvedValue(undefined),
143
+ runMigrations: mock().mockResolvedValue(undefined),
144
+ isReady: mock().mockResolvedValue(true),
145
+ close: mock().mockResolvedValue(undefined),
146
+ getConnection: mock().mockResolvedValue({}),
147
+
148
+ // Agent methods
149
+ getAgent: mock().mockResolvedValue(null),
150
+ getAgents: mock().mockResolvedValue([]),
151
+ createAgent: mock().mockResolvedValue(true),
152
+ updateAgent: mock().mockResolvedValue(true),
153
+ deleteAgent: mock().mockResolvedValue(true),
154
+
155
+ // Memory methods
156
+ createMemory: mock().mockImplementation(async (memory: Memory) => ({
157
+ ...memory,
158
+ id: memory.id || createUUID(),
159
+ })),
160
+ getMemories: mock().mockResolvedValue([]),
161
+ getMemoryById: mock().mockResolvedValue(null),
162
+ getMemoriesByIds: mock().mockResolvedValue([]),
163
+ getMemoriesByRoomIds: mock().mockResolvedValue([]),
164
+ searchMemories: mock().mockResolvedValue([]),
165
+
166
+ addEmbeddingToMemory: mock().mockImplementation(async (memory: Memory) => memory),
167
+ getAllMemories: mock().mockResolvedValue([]),
168
+ clearAllAgentMemories: mock().mockResolvedValue(undefined),
169
+ updateMemory: mock().mockResolvedValue(true),
170
+ deleteMemory: mock().mockResolvedValue(undefined),
171
+ deleteManyMemories: mock().mockResolvedValue(undefined),
172
+ deleteAllMemories: mock().mockResolvedValue(undefined),
173
+ countMemories: mock().mockResolvedValue(0),
174
+
175
+ // Entity methods
176
+ getEntitiesByIds: mock().mockResolvedValue([]),
177
+ getEntitiesForRoom: mock().mockResolvedValue([]),
178
+ createEntities: mock().mockResolvedValue(true),
179
+ updateEntity: mock().mockResolvedValue(undefined),
180
+ createEntity: mock().mockResolvedValue(true),
181
+ getEntityById: mock().mockResolvedValue(null),
182
+
183
+ // Room methods
184
+ createRoom: mock().mockImplementation(async () => createUUID()),
185
+ createRooms: mock().mockImplementation(async () => [createUUID()]),
186
+ getRoom: mock().mockResolvedValue(null),
187
+ getRooms: mock().mockResolvedValue([]),
188
+ getRoomsByIds: mock().mockResolvedValue([]),
189
+ getRoomsByWorld: mock().mockResolvedValue([]),
190
+ updateRoom: mock().mockResolvedValue(undefined),
191
+ deleteRoom: mock().mockResolvedValue(undefined),
192
+ deleteRoomsByWorldId: mock().mockResolvedValue(undefined),
193
+ addParticipant: mock().mockResolvedValue(true),
194
+ addParticipantsRoom: mock().mockResolvedValue(true),
195
+ removeParticipant: mock().mockResolvedValue(true),
196
+ getRoomsForParticipant: mock().mockResolvedValue([]),
197
+ getRoomsForParticipants: mock().mockResolvedValue([]),
198
+ getParticipantsForEntity: mock().mockResolvedValue([]),
199
+ getParticipantsForRoom: mock().mockResolvedValue([]),
200
+ getParticipantUserState: mock().mockResolvedValue(null),
201
+ setParticipantUserState: mock().mockResolvedValue(undefined),
29
202
 
30
- // Core methods
203
+ // Service methods
31
204
  getService: mock().mockReturnValue(null),
32
- registerService: mock(),
33
- getSetting: mock().mockReturnValue(null),
205
+ getServicesByType: mock().mockReturnValue([]),
206
+ getAllServices: mock().mockReturnValue(new Map()),
207
+ registerService: mock().mockResolvedValue(undefined),
208
+ getRegisteredServiceTypes: mock().mockReturnValue([]),
209
+ hasService: mock().mockReturnValue(false),
210
+
211
+ // Plugin/Action/Provider methods
212
+ registerPlugin: mock().mockResolvedValue(undefined),
213
+ registerProvider: mock().mockReturnValue(undefined),
214
+ registerAction: mock().mockReturnValue(undefined),
215
+ registerEvaluator: mock().mockReturnValue(undefined),
34
216
 
35
217
  // Model methods
36
- useModel: mock().mockImplementation((modelType, params) => {
218
+ registerModel: mock().mockReturnValue(undefined),
219
+ getModel: mock().mockReturnValue(undefined),
220
+ useModel: mock().mockImplementation(async (modelType: ModelTypeName) => {
37
221
  if (modelType === ModelType.TEXT_SMALL) {
38
- return Promise.resolve('Never gonna give you up, never gonna let you down');
222
+ return 'Never gonna give you up, never gonna let you down';
39
223
  } 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
- });
224
+ return 'Never gonna make you cry, never gonna say goodbye';
46
225
  }
47
- return Promise.resolve('Default response');
226
+ return 'Default model response';
48
227
  }),
49
228
 
50
- // Additional methods used in tests
51
- init: mock().mockResolvedValue(undefined),
229
+ // Event methods
230
+ registerEvent: mock().mockReturnValue(undefined),
231
+ getEvent: mock().mockReturnValue(undefined),
232
+ emitEvent: mock().mockResolvedValue(undefined),
233
+
234
+ // Settings methods
235
+ setSetting: mock().mockReturnValue(undefined),
236
+ getSetting: mock().mockImplementation((key: string) => {
237
+ if (key === 'EXAMPLE_PLUGIN_VARIABLE') return 'test-value';
238
+ return null;
239
+ }),
240
+
241
+ // Other methods
242
+ processActions: mock().mockResolvedValue(undefined),
243
+ evaluate: mock().mockResolvedValue(null),
244
+ ensureConnections: mock().mockResolvedValue(undefined),
245
+ ensureConnection: mock().mockResolvedValue(undefined),
246
+ getConversationLength: mock().mockReturnValue(10),
247
+ composeState: mock().mockImplementation(async () => createTestState()),
248
+ // Task methods
249
+ getTasks: mock().mockResolvedValue([]),
250
+ getTask: mock().mockResolvedValue(null),
251
+ getTasksByName: mock().mockResolvedValue([]),
252
+ createTask: mock().mockImplementation(async () => createUUID()),
253
+ updateTask: mock().mockResolvedValue(undefined),
254
+ deleteTask: mock().mockResolvedValue(undefined),
255
+ registerTaskWorker: mock().mockReturnValue(undefined),
256
+ getTaskWorker: mock().mockReturnValue(undefined),
257
+ stop: mock().mockResolvedValue(undefined),
258
+ createRunId: mock().mockImplementation(() => createUUID()),
259
+ startRun: mock().mockImplementation(() => createUUID()),
260
+ endRun: mock().mockReturnValue(undefined),
261
+ getCurrentRunId: mock().mockImplementation(() => createUUID()),
262
+ registerSendHandler: mock().mockReturnValue(undefined),
263
+ sendMessageToTarget: mock().mockResolvedValue(undefined),
264
+ registerDatabaseAdapter: mock().mockReturnValue(undefined),
265
+ log: mock().mockResolvedValue(undefined),
266
+ getLogs: mock().mockResolvedValue([]),
267
+ deleteLog: mock().mockResolvedValue(undefined),
268
+
269
+ // Component methods (from IDatabaseAdapter)
270
+ getComponent: mock().mockResolvedValue(null),
271
+ getComponents: mock().mockResolvedValue([]),
272
+ createComponent: mock().mockResolvedValue(true),
273
+ updateComponent: mock().mockResolvedValue(undefined),
274
+ deleteComponent: mock().mockResolvedValue(undefined),
275
+
276
+ // Relationship methods
277
+ createRelationship: mock().mockResolvedValue(true),
278
+ getRelationships: mock().mockResolvedValue([]),
279
+
280
+ getRelationship: mock().mockResolvedValue(null),
281
+ updateRelationship: mock().mockResolvedValue(undefined),
282
+
283
+ // Embedding methods
284
+ ensureEmbeddingDimension: mock().mockResolvedValue(undefined),
285
+ getCachedEmbeddings: mock().mockResolvedValue([]),
286
+
287
+ // World methods
288
+ getWorld: mock().mockResolvedValue(null),
289
+ createWorld: mock().mockImplementation(async () => createUUID()),
290
+ updateWorld: mock().mockResolvedValue(undefined),
291
+ removeWorld: mock().mockResolvedValue(undefined),
292
+ getAllWorlds: mock().mockResolvedValue([]),
293
+
294
+ // Required method that was missing
295
+ ensureParticipantInRoom: mock().mockResolvedValue(undefined),
296
+ ensureWorldExists: mock().mockResolvedValue(undefined),
297
+ ensureRoomExists: mock().mockResolvedValue(undefined),
298
+
299
+ // Cache methods
300
+ getCache: mock().mockResolvedValue(undefined),
301
+ setCache: mock().mockResolvedValue(true),
302
+ deleteCache: mock().mockResolvedValue(true),
303
+
304
+ // Other missing database methods
305
+ getMemoriesByWorldId: mock().mockResolvedValue([]),
306
+
307
+ // Apply any overrides
52
308
  ...overrides,
53
309
  };
54
310
 
55
- // Merge with overrides
311
+ // Setup logger spies if not already overridden
312
+ if (!overrides.logger) {
313
+ spyOn(logger, 'info').mockImplementation(() => {});
314
+ spyOn(logger, 'warn').mockImplementation(() => {});
315
+ spyOn(logger, 'error').mockImplementation(() => {});
316
+ spyOn(logger, 'debug').mockImplementation(() => {});
317
+ }
318
+
56
319
  return mockRuntime;
57
320
  }
58
321
 
59
322
  /**
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
323
+ * Creates test fixtures for event payloads
64
324
  */
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,
325
+ export const testFixtures = {
326
+ messagePayload: (overrides: any = {}) => ({
71
327
  content: {
72
328
  text: 'Test message',
73
329
  source: 'test',
74
- } as Content,
75
- createdAt: Date.now(),
330
+ },
331
+ userId: createUUID(),
332
+ roomId: createUUID(),
333
+ runtime: createMockRuntime(),
334
+ source: 'test',
76
335
  ...overrides,
77
- };
78
- }
336
+ }),
337
+
338
+ worldPayload: (overrides: any = {}) => ({
339
+ content: {
340
+ text: 'World event',
341
+ world: 'test-world',
342
+ },
343
+ userId: createUUID(),
344
+ roomId: createUUID(),
345
+ runtime: createMockRuntime(),
346
+ source: 'test',
347
+ ...overrides,
348
+ }),
349
+ };
79
350
 
80
351
  /**
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
352
+ * Type guard to check if a value is a mock function
85
353
  */
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
- };
354
+ export function isMockFunction(value: any): value is ReturnType<typeof mock> {
355
+ return value && typeof value.mock === 'object';
97
356
  }
98
357
 
99
358
  /**
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
359
+ * Helper to assert spy was called with specific arguments
104
360
  */
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
- });
361
+ export function assertSpyCalledWith(spy: any, ...args: any[]) {
362
+ if (!isMockFunction(spy)) {
363
+ throw new Error('Not a mock function');
364
+ }
125
365
 
126
- return {
127
- mockRuntime,
128
- mockMessage,
129
- mockState,
130
- callbackFn,
131
- };
366
+ const calls = spy.mock.calls;
367
+ const found = calls.some((call: any[]) =>
368
+ args.every((arg, index) => {
369
+ if (typeof arg === 'object' && arg !== null) {
370
+ return JSON.stringify(arg) === JSON.stringify(call[index]);
371
+ }
372
+ return arg === call[index];
373
+ })
374
+ );
375
+
376
+ if (!found) {
377
+ throw new Error(`Spy was not called with expected arguments: ${JSON.stringify(args)}`);
378
+ }
132
379
  }
133
380
 
134
381
  /**
135
- * Type definition for the mock runtime
382
+ * Setup logger spies for testing
136
383
  */
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
384
  export function setupLoggerSpies() {
155
385
  spyOn(logger, 'info').mockImplementation(() => {});
156
- spyOn(logger, 'error').mockImplementation(() => {});
157
386
  spyOn(logger, 'warn').mockImplementation(() => {});
387
+ spyOn(logger, 'error').mockImplementation(() => {});
158
388
  spyOn(logger, 'debug').mockImplementation(() => {});
159
-
160
- // allow tests to restore originals
161
- return () => mock.restore();
162
389
  }
390
+
391
+ /**
392
+ * Type definition for the mock runtime (for backward compatibility)
393
+ */
394
+ export type MockRuntime = IAgentRuntime;
@@ -70,23 +70,18 @@ const helloWorldAction: Action = {
70
70
  _responses?: Memory[]
71
71
  ): Promise<ActionResult> => {
72
72
  try {
73
- logger.info('Handling HELLO_WORLD action');
73
+ const response = 'Hello world!';
74
74
 
75
- // Simple response content for callback
76
- const responseContent: Content = {
77
- text: 'hello world!',
78
- actions: ['HELLO_WORLD'],
79
- source: message.content.source,
80
- };
81
-
82
- // Call back with the hello world message if callback is provided
83
75
  if (callback) {
84
- await callback(responseContent);
76
+ await callback({
77
+ text: response,
78
+ actions: ['HELLO_WORLD'],
79
+ source: message.content.source,
80
+ });
85
81
  }
86
82
 
87
- // Return ActionResult
88
83
  return {
89
- text: 'hello world!',
84
+ text: response,
90
85
  success: true,
91
86
  data: {
92
87
  actions: ['HELLO_WORLD'],
@@ -94,7 +89,7 @@ const helloWorldAction: Action = {
94
89
  },
95
90
  };
96
91
  } catch (error) {
97
- logger.error('Error in HELLO_WORLD action:', error);
92
+ logger.error('Error in HelloWorld action:', error);
98
93
  return {
99
94
  success: false,
100
95
  error: error instanceof Error ? error : new Error(String(error)),
@@ -105,15 +100,16 @@ const helloWorldAction: Action = {
105
100
  examples: [
106
101
  [
107
102
  {
108
- name: '{{name1}}',
103
+ name: '{{userName}}',
109
104
  content: {
110
- text: 'Can you say hello?',
105
+ text: 'hello',
106
+ actions: [],
111
107
  },
112
108
  },
113
109
  {
114
- name: '{{name2}}',
110
+ name: '{{agentName}}',
115
111
  content: {
116
- text: 'hello world!',
112
+ text: 'Hello world!',
117
113
  actions: ['HELLO_WORLD'],
118
114
  },
119
115
  },
@@ -151,13 +147,13 @@ export class StarterService extends Service {
151
147
  }
152
148
 
153
149
  static async start(runtime: IAgentRuntime) {
154
- logger.info(`*** Starting starter service - MODIFIED: ${new Date().toISOString()} ***`);
150
+ logger.info('Starting starter service');
155
151
  const service = new StarterService(runtime);
156
152
  return service;
157
153
  }
158
154
 
159
155
  static async stop(runtime: IAgentRuntime) {
160
- logger.info('*** TESTING DEV MODE - STOP MESSAGE CHANGED! ***');
156
+ logger.info('Stopping starter service');
161
157
  // get the service from the runtime
162
158
  const service = runtime.getService(StarterService.serviceType);
163
159
  if (!service) {
@@ -167,7 +163,7 @@ export class StarterService extends Service {
167
163
  }
168
164
 
169
165
  async stop() {
170
- logger.info('*** THIRD CHANGE - TESTING FILE WATCHING! ***');
166
+ logger.info('Stopping StarterService');
171
167
  }
172
168
  }
173
169
 
@@ -178,7 +174,7 @@ export const starterPlugin: Plugin = {
178
174
  EXAMPLE_PLUGIN_VARIABLE: process.env.EXAMPLE_PLUGIN_VARIABLE,
179
175
  },
180
176
  async init(config: Record<string, string>) {
181
- logger.info('*** TESTING DEV MODE - PLUGIN MODIFIED AND RELOADED! ***');
177
+ logger.debug('Plugin initialized');
182
178
  try {
183
179
  const validatedConfig = await configSchema.parseAsync(config);
184
180
 
@@ -278,7 +274,7 @@ export const starterPlugin: Plugin = {
278
274
  actions: [helloWorldAction],
279
275
  providers: [helloWorldProvider],
280
276
  tests: [StarterPluginTestSuite],
281
- // dependencies: ['@elizaos/plugin-knowledge'], <--- plugin dependecies go here (if requires another plugin)
277
+ // dependencies: ['@elizaos/plugin-knowledge'], <--- plugin dependencies go here (if requires another plugin)
282
278
  };
283
279
 
284
280
  export default starterPlugin;
@@ -0,0 +1,57 @@
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/
@@ -0,0 +1,11 @@
1
+ .turbo
2
+ dist
3
+ node_modules
4
+ .env
5
+ *.env
6
+ .env.local
7
+ generatedImages/
8
+ models/
9
+ .eliza/
10
+ .elizadb*
11
+ cache/
@@ -62,7 +62,7 @@ ElizaOS provides a comprehensive testing structure for projects:
62
62
 
63
63
  ### Writing Tests
64
64
 
65
- Component tests use Vitest:
65
+ Component tests use bun:test:
66
66
 
67
67
  ```typescript
68
68
  // Unit test example (__tests__/config.test.ts)