@elizaos/cli 1.3.1 → 1.4.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 (198) hide show
  1. package/README.md +47 -1
  2. package/dist/{bun-exec-6CQHTS4F.js → bun-exec-ULMPAIQC.js} +1 -1
  3. package/dist/{chunk-2ALAPQLV.js → chunk-D3QSET5H.js} +342 -360
  4. package/dist/{chunk-FDEDLANP.js → chunk-FQYWRHLX.js} +1 -1
  5. package/dist/{chunk-RM6LUTKD.js → chunk-FSSUAWXQ.js} +3 -3
  6. package/dist/chunk-GXWWPFBO.js +39 -0
  7. package/dist/{chunk-D3Q2UZLZ.js → chunk-I4L4T7QX.js} +1 -1
  8. package/dist/{chunk-KDNV7EA5.js → chunk-SMZBJQJR.js} +1 -1
  9. package/dist/commands/agent/actions/index.d.ts +5 -0
  10. package/dist/commands/agent/actions/index.js +4 -4
  11. package/dist/commands/agent/index.d.ts +2 -2
  12. package/dist/commands/agent/index.js +4 -4
  13. package/dist/commands/create/actions/index.js +5 -5
  14. package/dist/commands/create/index.js +6 -6
  15. package/dist/commands/shared/index.d.ts +11 -28
  16. package/dist/commands/shared/index.js +7 -3
  17. package/dist/index.js +599 -483
  18. package/dist/{plugin-creator-H26ZLR6H.js → plugin-creator-TCUFII32.js} +2 -2
  19. package/dist/{registry-N626N4VG.js → registry-RF6PW3EN.js} +4 -4
  20. package/dist/templates/plugin-quick-starter/README.md +52 -10
  21. package/dist/templates/plugin-quick-starter/package.json +10 -3
  22. package/dist/templates/plugin-quick-starter/src/__tests__/e2e/README.md +140 -0
  23. package/dist/templates/plugin-quick-starter/src/__tests__/e2e/plugin-quick-starter.e2e.ts +339 -0
  24. package/dist/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +537 -146
  25. package/dist/templates/plugin-quick-starter/src/__tests__/test-utils.ts +316 -115
  26. package/dist/templates/plugin-quick-starter/src/plugin.ts +20 -26
  27. package/dist/templates/plugin-starter/README.md +124 -49
  28. package/dist/templates/plugin-starter/package.json +10 -3
  29. package/dist/templates/plugin-starter/src/__tests__/e2e/README.md +44 -9
  30. package/{templates/plugin-starter/src/__tests__/e2e/starter-plugin.ts → dist/templates/plugin-starter/src/__tests__/e2e/plugin-starter.e2e.ts} +13 -20
  31. package/dist/templates/plugin-starter/src/__tests__/integration.test.ts +13 -13
  32. package/dist/templates/plugin-starter/src/__tests__/plugin.test.ts +556 -129
  33. package/dist/templates/plugin-starter/src/__tests__/test-utils.ts +347 -115
  34. package/dist/templates/plugin-starter/src/plugin.ts +21 -27
  35. package/dist/templates/project-starter/README.md +25 -12
  36. package/dist/templates/project-starter/package.json +4 -4
  37. package/dist/templates/project-starter/src/__tests__/actions.test.ts +2 -2
  38. package/dist/templates/project-starter/src/__tests__/e2e/README.md +103 -0
  39. package/dist/templates/project-starter/src/__tests__/e2e/project-starter.e2e.ts +575 -0
  40. package/dist/templates/project-starter/src/__tests__/env.test.ts +3 -1
  41. package/dist/templates/project-starter/src/__tests__/file-structure.test.ts +3 -2
  42. package/dist/templates/project-starter/src/__tests__/integration.test.ts +2 -2
  43. package/dist/templates/project-starter/src/__tests__/models.test.ts +3 -3
  44. package/dist/templates/project-starter/src/__tests__/plugin.test.ts +3 -3
  45. package/dist/templates/project-starter/src/__tests__/provider.test.ts +2 -2
  46. package/dist/templates/project-starter/src/index.ts +4 -3
  47. package/dist/templates/project-starter/src/plugin.ts +5 -5
  48. package/dist/templates/project-starter/tsup.config.ts +2 -1
  49. package/dist/templates/project-tee-starter/.dockerignore +64 -14
  50. package/dist/templates/project-tee-starter/Dockerfile +9 -5
  51. package/dist/templates/project-tee-starter/GUIDE.md +103 -42
  52. package/dist/templates/project-tee-starter/README.md +83 -24
  53. package/dist/templates/project-tee-starter/docker-compose.yaml +5 -2
  54. package/dist/templates/{plugin-starter/dist → project-tee-starter}/index.html +3 -3
  55. package/dist/templates/project-tee-starter/package.json +34 -14
  56. package/dist/templates/project-tee-starter/postcss.config.js +3 -0
  57. package/dist/templates/project-tee-starter/scripts/install-test-deps.js +52 -0
  58. package/dist/templates/project-tee-starter/scripts/test-all.sh +82 -0
  59. package/dist/templates/project-tee-starter/src/__tests__/build-order.test.ts +62 -0
  60. package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/character.test.ts +20 -18
  61. package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/config.test.ts +11 -4
  62. package/dist/templates/project-tee-starter/src/__tests__/e2e/README.md +128 -0
  63. package/dist/templates/project-tee-starter/src/__tests__/e2e/project-tee-starter.e2e.ts +280 -0
  64. package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/env.test.ts +3 -2
  65. package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/error-handling.test.ts +2 -2
  66. package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/events.test.ts +1 -1
  67. package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/file-structure.test.ts +16 -5
  68. package/dist/templates/project-tee-starter/src/__tests__/frontend.test.ts +459 -0
  69. package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/integration.test.ts +2 -2
  70. package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/models.test.ts +1 -1
  71. package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/plugin.test.ts +5 -3
  72. package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/provider.test.ts +2 -2
  73. package/dist/templates/project-tee-starter/src/__tests__/routes.test.ts +30 -0
  74. package/dist/templates/project-tee-starter/src/__tests__/tee-validation.test.ts +295 -0
  75. package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/test-utils.ts +2 -2
  76. package/dist/templates/project-tee-starter/src/__tests__/vite-config-utils.ts +51 -0
  77. package/dist/templates/project-tee-starter/src/frontend/index.css +106 -0
  78. package/dist/templates/project-tee-starter/src/frontend/index.html +20 -0
  79. package/dist/templates/project-tee-starter/src/frontend/index.tsx +370 -0
  80. package/dist/templates/project-tee-starter/src/frontend/panels.tsx +17 -0
  81. package/dist/templates/project-tee-starter/src/frontend/utils.ts +6 -0
  82. package/dist/templates/project-tee-starter/src/index.ts +8 -6
  83. package/dist/templates/project-tee-starter/src/plugin.ts +223 -61
  84. package/dist/templates/project-tee-starter/tailwind.config.js +62 -0
  85. package/dist/templates/project-tee-starter/tsconfig.build.json +2 -2
  86. package/dist/templates/project-tee-starter/tsconfig.json +8 -5
  87. package/dist/templates/project-tee-starter/tsup.config.ts +3 -2
  88. package/dist/templates/project-tee-starter/vite.config.ts +39 -0
  89. package/dist/url-utils-CKc_Ebt_.d.ts +35 -0
  90. package/dist/{utils-H66532NB.js → utils-5HPZSIF6.js} +4 -4
  91. package/package.json +7 -6
  92. package/templates/plugin-quick-starter/README.md +52 -10
  93. package/templates/plugin-quick-starter/package.json +10 -3
  94. package/templates/plugin-quick-starter/src/__tests__/e2e/README.md +140 -0
  95. package/templates/plugin-quick-starter/src/__tests__/e2e/plugin-quick-starter.e2e.ts +339 -0
  96. package/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +537 -146
  97. package/templates/plugin-quick-starter/src/__tests__/test-utils.ts +316 -115
  98. package/templates/plugin-quick-starter/src/plugin.ts +20 -26
  99. package/templates/plugin-starter/README.md +124 -49
  100. package/templates/plugin-starter/package.json +10 -3
  101. package/templates/plugin-starter/src/__tests__/e2e/README.md +44 -9
  102. package/{dist/templates/plugin-starter/src/__tests__/e2e/starter-plugin.ts → templates/plugin-starter/src/__tests__/e2e/plugin-starter.e2e.ts} +13 -20
  103. package/templates/plugin-starter/src/__tests__/integration.test.ts +13 -13
  104. package/templates/plugin-starter/src/__tests__/plugin.test.ts +556 -129
  105. package/templates/plugin-starter/src/__tests__/test-utils.ts +347 -115
  106. package/templates/plugin-starter/src/plugin.ts +21 -27
  107. package/templates/project-starter/README.md +25 -12
  108. package/templates/project-starter/package.json +4 -4
  109. package/templates/project-starter/src/__tests__/actions.test.ts +2 -2
  110. package/templates/project-starter/src/__tests__/e2e/README.md +103 -0
  111. package/templates/project-starter/src/__tests__/e2e/project-starter.e2e.ts +575 -0
  112. package/templates/project-starter/src/__tests__/env.test.ts +3 -1
  113. package/templates/project-starter/src/__tests__/file-structure.test.ts +3 -2
  114. package/templates/project-starter/src/__tests__/integration.test.ts +2 -2
  115. package/templates/project-starter/src/__tests__/models.test.ts +3 -3
  116. package/templates/project-starter/src/__tests__/plugin.test.ts +3 -3
  117. package/templates/project-starter/src/__tests__/provider.test.ts +2 -2
  118. package/templates/project-starter/src/index.ts +4 -3
  119. package/templates/project-starter/src/plugin.ts +5 -5
  120. package/templates/project-starter/tsup.config.ts +2 -1
  121. package/templates/project-tee-starter/.dockerignore +64 -14
  122. package/templates/project-tee-starter/Dockerfile +9 -5
  123. package/templates/project-tee-starter/GUIDE.md +103 -42
  124. package/templates/project-tee-starter/README.md +83 -24
  125. package/templates/project-tee-starter/docker-compose.yaml +5 -2
  126. package/templates/{plugin-starter/dist → project-tee-starter}/index.html +3 -3
  127. package/templates/project-tee-starter/package.json +34 -14
  128. package/templates/project-tee-starter/postcss.config.js +3 -0
  129. package/templates/project-tee-starter/scripts/install-test-deps.js +52 -0
  130. package/templates/project-tee-starter/scripts/test-all.sh +82 -0
  131. package/templates/project-tee-starter/src/__tests__/build-order.test.ts +62 -0
  132. package/templates/project-tee-starter/{__tests__ → src/__tests__}/character.test.ts +20 -18
  133. package/templates/project-tee-starter/{__tests__ → src/__tests__}/config.test.ts +11 -4
  134. package/templates/project-tee-starter/src/__tests__/e2e/README.md +128 -0
  135. package/templates/project-tee-starter/src/__tests__/e2e/project-tee-starter.e2e.ts +280 -0
  136. package/templates/project-tee-starter/{__tests__ → src/__tests__}/env.test.ts +3 -2
  137. package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/error-handling.test.ts +2 -2
  138. package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/events.test.ts +1 -1
  139. package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/file-structure.test.ts +16 -5
  140. package/templates/project-tee-starter/src/__tests__/frontend.test.ts +459 -0
  141. package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/integration.test.ts +2 -2
  142. package/templates/project-tee-starter/{__tests__ → src/__tests__}/models.test.ts +1 -1
  143. package/templates/project-tee-starter/{__tests__ → src/__tests__}/plugin.test.ts +5 -3
  144. package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/provider.test.ts +2 -2
  145. package/templates/project-tee-starter/src/__tests__/routes.test.ts +30 -0
  146. package/templates/project-tee-starter/src/__tests__/tee-validation.test.ts +295 -0
  147. package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/test-utils.ts +2 -2
  148. package/templates/project-tee-starter/src/__tests__/vite-config-utils.ts +51 -0
  149. package/templates/project-tee-starter/src/frontend/index.css +106 -0
  150. package/templates/project-tee-starter/src/frontend/index.html +20 -0
  151. package/templates/project-tee-starter/src/frontend/index.tsx +370 -0
  152. package/templates/project-tee-starter/src/frontend/panels.tsx +17 -0
  153. package/templates/project-tee-starter/src/frontend/utils.ts +6 -0
  154. package/templates/project-tee-starter/src/index.ts +8 -6
  155. package/templates/project-tee-starter/src/plugin.ts +223 -61
  156. package/templates/project-tee-starter/tailwind.config.js +62 -0
  157. package/templates/project-tee-starter/tsconfig.build.json +2 -2
  158. package/templates/project-tee-starter/tsconfig.json +8 -5
  159. package/templates/project-tee-starter/tsup.config.ts +3 -2
  160. package/templates/project-tee-starter/vite.config.ts +39 -0
  161. package/dist/chunk-4O6EZU37.js +0 -14
  162. package/dist/migration-guides/advanced-migration-guide.md +0 -459
  163. package/dist/migration-guides/completion-requirements.md +0 -379
  164. package/dist/migration-guides/integrated-migration-loop.md +0 -392
  165. package/dist/migration-guides/migration-guide.md +0 -712
  166. package/dist/migration-guides/prompt-and-generation-guide.md +0 -702
  167. package/dist/migration-guides/state-and-providers-guide.md +0 -544
  168. package/dist/migration-guides/testing-guide.md +0 -1021
  169. package/dist/templates/plugin-starter/dist/assets/index-CgkejLs_.css +0 -1
  170. package/dist/templates/plugin-starter/dist/assets/index-D1cHX53P.js +0 -49
  171. package/dist/templates/plugin-starter/dist/index.js +0 -387
  172. package/dist/templates/plugin-starter/dist/index.js.map +0 -1
  173. package/dist/templates/plugin-starter/src/tests.ts +0 -6
  174. package/dist/templates/project-starter/src/__tests__/e2e/index.ts +0 -14
  175. package/dist/templates/project-starter/src/__tests__/e2e/natural-language.test.ts +0 -246
  176. package/dist/templates/project-starter/src/__tests__/e2e/project.test.ts +0 -155
  177. package/dist/templates/project-starter/src/__tests__/e2e/starter-plugin.test.ts +0 -421
  178. package/dist/templates/project-tee-starter/__tests__/routes.test.ts +0 -21
  179. package/dist/templates/project-tee-starter/e2e/project.test.ts +0 -38
  180. package/dist/templates/project-tee-starter/e2e/starter-plugin.test.ts +0 -92
  181. package/templates/plugin-starter/dist/.vite/manifest.json +0 -11
  182. package/templates/plugin-starter/dist/assets/index-CgkejLs_.css +0 -1
  183. package/templates/plugin-starter/dist/assets/index-D1cHX53P.js +0 -49
  184. package/templates/plugin-starter/dist/index.d.ts +0 -14
  185. package/templates/plugin-starter/dist/index.js +0 -387
  186. package/templates/plugin-starter/dist/index.js.map +0 -1
  187. package/templates/plugin-starter/src/tests.ts +0 -6
  188. package/templates/project-starter/src/__tests__/e2e/index.ts +0 -14
  189. package/templates/project-starter/src/__tests__/e2e/natural-language.test.ts +0 -246
  190. package/templates/project-starter/src/__tests__/e2e/project.test.ts +0 -155
  191. package/templates/project-starter/src/__tests__/e2e/starter-plugin.test.ts +0 -421
  192. package/templates/project-tee-starter/__tests__/routes.test.ts +0 -21
  193. package/templates/project-tee-starter/e2e/project.test.ts +0 -38
  194. package/templates/project-tee-starter/e2e/starter-plugin.test.ts +0 -92
  195. /package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/actions.test.ts +0 -0
  196. /package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/utils/core-test-utils.ts +0 -0
  197. /package/templates/project-tee-starter/{__tests__ → src/__tests__}/actions.test.ts +0 -0
  198. /package/templates/project-tee-starter/{__tests__ → src/__tests__}/utils/core-test-utils.ts +0 -0
@@ -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
  }
@@ -51,9 +51,9 @@ const configSchema = z.object({
51
51
  * @property {Function} handler - Asynchronous function to handle the action and generate a response.
52
52
  * @property {Object[]} examples - An array of example inputs and expected outputs for the action.
53
53
  */
54
- const helloWorldAction: Action = {
55
- name: 'HELLO_WORLD',
56
- similes: ['GREET', 'SAY_HELLO'],
54
+ const quickAction: Action = {
55
+ name: 'QUICK_ACTION',
56
+ similes: ['GREET', 'SAY_HELLO', 'HELLO_WORLD'],
57
57
  description: 'Responds with a simple hello world message',
58
58
 
59
59
  validate: async (
@@ -74,31 +74,25 @@ 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: ['QUICK_ACTION'],
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
- actions: ['HELLO_WORLD'],
91
+ actions: ['QUICK_ACTION'],
97
92
  source: message.content.source,
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)),
@@ -118,7 +112,7 @@ const helloWorldAction: Action = {
118
112
  name: '{{name2}}',
119
113
  content: {
120
114
  text: 'hello world!',
121
- actions: ['HELLO_WORLD'],
115
+ actions: ['QUICK_ACTION'],
122
116
  },
123
117
  },
124
118
  ],
@@ -129,8 +123,8 @@ const helloWorldAction: Action = {
129
123
  * Example Hello World Provider
130
124
  * This demonstrates the simplest possible provider implementation
131
125
  */
132
- const helloWorldProvider: Provider = {
133
- name: 'HELLO_WORLD_PROVIDER',
126
+ const quickProvider: Provider = {
127
+ name: 'QUICK_PROVIDER',
134
128
  description: 'A simple example provider',
135
129
 
136
130
  get: async (
@@ -241,31 +235,31 @@ export const starterPlugin: Plugin = {
241
235
  [EventType.MESSAGE_RECEIVED]: [
242
236
  async (params: MessagePayload) => {
243
237
  logger.debug('MESSAGE_RECEIVED event received');
244
- logger.debug('Message:', params.message);
238
+ logger.debug({ message: params.message }, 'Message:');
245
239
  },
246
240
  ],
247
241
  [EventType.VOICE_MESSAGE_RECEIVED]: [
248
242
  async (params: MessagePayload) => {
249
243
  logger.debug('VOICE_MESSAGE_RECEIVED event received');
250
- logger.debug('Message:', params.message);
244
+ logger.debug({ message: params.message }, 'Message:');
251
245
  },
252
246
  ],
253
247
  [EventType.WORLD_CONNECTED]: [
254
248
  async (params: WorldPayload) => {
255
249
  logger.debug('WORLD_CONNECTED event received');
256
- logger.debug('World:', params.world);
250
+ logger.debug({ world: params.world }, 'World:');
257
251
  },
258
252
  ],
259
253
  [EventType.WORLD_JOINED]: [
260
254
  async (params: WorldPayload) => {
261
255
  logger.debug('WORLD_JOINED event received');
262
- logger.debug('World:', params.world);
256
+ logger.debug({ world: params.world }, 'World:');
263
257
  },
264
258
  ],
265
259
  },
266
260
  services: [StarterService],
267
- actions: [helloWorldAction],
268
- providers: [helloWorldProvider],
261
+ actions: [quickAction],
262
+ providers: [quickProvider],
269
263
  // dependencies: ['@elizaos/plugin-knowledge'], <--- plugin dependencies go here (if requires another plugin)
270
264
  };
271
265