@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.
- package/README.md +1 -1
- package/dist/{chunk-2CUIHNPL.js → chunk-5GUS4CFO.js} +7 -2
- package/dist/{chunk-2ALAPQLV.js → chunk-E6XYTE3A.js} +296 -311
- package/dist/chunk-GXWWPFBO.js +39 -0
- package/dist/{chunk-I77ZRNYO.js → chunk-T2QDIXGU.js} +2 -2
- package/dist/commands/agent/actions/index.d.ts +5 -0
- package/dist/commands/agent/actions/index.js +2 -2
- package/dist/commands/agent/index.d.ts +2 -2
- package/dist/commands/agent/index.js +2 -2
- package/dist/commands/create/actions/index.js +3 -3
- package/dist/commands/create/index.js +4 -4
- package/dist/commands/shared/index.d.ts +11 -28
- package/dist/commands/shared/index.js +7 -3
- package/dist/index.js +541 -450
- package/dist/{registry-N626N4VG.js → registry-433S5F3Y.js} +2 -2
- package/dist/templates/plugin-quick-starter/.gitignore +66 -0
- package/dist/templates/plugin-quick-starter/.npmignore +5 -0
- package/dist/templates/plugin-quick-starter/package.json +11 -3
- package/dist/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +499 -146
- package/dist/templates/plugin-quick-starter/src/__tests__/test-utils.ts +316 -115
- package/dist/templates/plugin-quick-starter/src/plugin.ts +7 -13
- package/dist/templates/plugin-starter/.gitignore +66 -0
- package/dist/templates/plugin-starter/.npmignore +5 -0
- package/dist/templates/plugin-starter/README.md +1 -1
- package/dist/templates/plugin-starter/package.json +11 -3
- package/dist/templates/plugin-starter/src/__tests__/integration.test.ts +13 -13
- package/dist/templates/plugin-starter/src/__tests__/plugin.test.ts +556 -129
- package/dist/templates/plugin-starter/src/__tests__/test-utils.ts +347 -115
- package/dist/templates/plugin-starter/src/plugin.ts +18 -22
- package/dist/templates/project-starter/.gitignore +57 -0
- package/dist/templates/project-starter/.npmignore +11 -0
- package/dist/templates/project-starter/README.md +1 -1
- package/dist/templates/project-starter/package.json +4 -4
- package/dist/templates/project-starter/src/__tests__/env.test.ts +3 -1
- package/dist/templates/project-starter/src/__tests__/file-structure.test.ts +3 -2
- package/dist/templates/project-starter/src/__tests__/integration.test.ts +1 -1
- package/dist/templates/project-starter/tsup.config.ts +2 -1
- package/dist/templates/project-tee-starter/.dockerignore +64 -14
- package/dist/templates/project-tee-starter/.gitignore +57 -0
- package/dist/templates/project-tee-starter/.npmignore +6 -0
- package/dist/templates/project-tee-starter/Dockerfile +9 -5
- package/dist/templates/project-tee-starter/GUIDE.md +103 -42
- package/dist/templates/project-tee-starter/README.md +39 -19
- package/dist/templates/project-tee-starter/__tests__/build-order.test.ts +62 -0
- package/dist/templates/project-tee-starter/__tests__/character.test.ts +19 -17
- package/dist/templates/project-tee-starter/__tests__/config.test.ts +10 -3
- package/dist/templates/project-tee-starter/__tests__/env.test.ts +2 -1
- package/dist/templates/project-tee-starter/__tests__/file-structure.test.ts +14 -3
- package/dist/templates/project-tee-starter/__tests__/frontend.test.ts +459 -0
- package/dist/templates/project-tee-starter/__tests__/plugin.test.ts +4 -2
- package/dist/templates/project-tee-starter/__tests__/routes.test.ts +15 -6
- package/dist/templates/project-tee-starter/__tests__/tee-validation.test.ts +295 -0
- package/dist/templates/project-tee-starter/__tests__/vite-config-utils.ts +39 -0
- package/dist/templates/project-tee-starter/docker-compose.yaml +5 -2
- package/dist/templates/{plugin-starter/dist → project-tee-starter}/index.html +3 -3
- package/dist/templates/project-tee-starter/package.json +34 -14
- package/dist/templates/project-tee-starter/postcss.config.js +3 -0
- package/dist/templates/project-tee-starter/scripts/install-test-deps.js +52 -0
- package/dist/templates/project-tee-starter/scripts/test-all.sh +82 -0
- package/dist/templates/project-tee-starter/src/frontend/index.css +106 -0
- package/dist/templates/project-tee-starter/src/frontend/index.html +20 -0
- package/dist/templates/project-tee-starter/src/frontend/index.tsx +370 -0
- package/dist/templates/project-tee-starter/src/frontend/panels.tsx +17 -0
- package/dist/templates/project-tee-starter/src/frontend/utils.ts +6 -0
- package/dist/templates/project-tee-starter/src/index.ts +6 -6
- package/dist/templates/project-tee-starter/src/plugin.ts +209 -59
- package/dist/templates/project-tee-starter/tailwind.config.js +62 -0
- package/dist/templates/project-tee-starter/tsconfig.build.json +2 -2
- package/dist/templates/project-tee-starter/tsconfig.json +8 -5
- package/dist/templates/project-tee-starter/tsup.config.ts +3 -2
- package/dist/templates/project-tee-starter/vite.config.ts +39 -0
- package/dist/url-utils-CKc_Ebt_.d.ts +35 -0
- package/dist/{utils-H66532NB.js → utils-DBLSDYBF.js} +2 -2
- package/package.json +12 -7
- package/templates/plugin-quick-starter/.gitignore +66 -0
- package/templates/plugin-quick-starter/.npmignore +5 -0
- package/templates/plugin-quick-starter/package.json +11 -3
- package/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +499 -146
- package/templates/plugin-quick-starter/src/__tests__/test-utils.ts +316 -115
- package/templates/plugin-quick-starter/src/plugin.ts +7 -13
- package/templates/plugin-starter/.gitignore +66 -0
- package/templates/plugin-starter/.npmignore +5 -0
- package/templates/plugin-starter/README.md +1 -1
- package/templates/plugin-starter/package.json +11 -3
- package/templates/plugin-starter/src/__tests__/integration.test.ts +13 -13
- package/templates/plugin-starter/src/__tests__/plugin.test.ts +556 -129
- package/templates/plugin-starter/src/__tests__/test-utils.ts +347 -115
- package/templates/plugin-starter/src/plugin.ts +18 -22
- package/templates/project-starter/.gitignore +57 -0
- package/templates/project-starter/.npmignore +11 -0
- package/templates/project-starter/README.md +1 -1
- package/templates/project-starter/package.json +4 -4
- package/templates/project-starter/src/__tests__/env.test.ts +3 -1
- package/templates/project-starter/src/__tests__/file-structure.test.ts +3 -2
- package/templates/project-starter/src/__tests__/integration.test.ts +1 -1
- package/templates/project-starter/tsup.config.ts +2 -1
- package/templates/project-tee-starter/.dockerignore +64 -14
- package/templates/project-tee-starter/.gitignore +57 -0
- package/templates/project-tee-starter/.npmignore +6 -0
- package/templates/project-tee-starter/Dockerfile +9 -5
- package/templates/project-tee-starter/GUIDE.md +103 -42
- package/templates/project-tee-starter/README.md +39 -19
- package/templates/project-tee-starter/__tests__/build-order.test.ts +62 -0
- package/templates/project-tee-starter/__tests__/character.test.ts +19 -17
- package/templates/project-tee-starter/__tests__/config.test.ts +10 -3
- package/templates/project-tee-starter/__tests__/env.test.ts +2 -1
- package/templates/project-tee-starter/__tests__/file-structure.test.ts +14 -3
- package/templates/project-tee-starter/__tests__/frontend.test.ts +459 -0
- package/templates/project-tee-starter/__tests__/plugin.test.ts +4 -2
- package/templates/project-tee-starter/__tests__/routes.test.ts +15 -6
- package/templates/project-tee-starter/__tests__/tee-validation.test.ts +295 -0
- package/templates/project-tee-starter/__tests__/vite-config-utils.ts +39 -0
- package/templates/project-tee-starter/docker-compose.yaml +5 -2
- package/templates/{plugin-starter/dist → project-tee-starter}/index.html +3 -3
- package/templates/project-tee-starter/package.json +34 -14
- package/templates/project-tee-starter/postcss.config.js +3 -0
- package/templates/project-tee-starter/scripts/install-test-deps.js +52 -0
- package/templates/project-tee-starter/scripts/test-all.sh +82 -0
- package/templates/project-tee-starter/src/frontend/index.css +106 -0
- package/templates/project-tee-starter/src/frontend/index.html +20 -0
- package/templates/project-tee-starter/src/frontend/index.tsx +370 -0
- package/templates/project-tee-starter/src/frontend/panels.tsx +17 -0
- package/templates/project-tee-starter/src/frontend/utils.ts +6 -0
- package/templates/project-tee-starter/src/index.ts +6 -6
- package/templates/project-tee-starter/src/plugin.ts +209 -59
- package/templates/project-tee-starter/tailwind.config.js +62 -0
- package/templates/project-tee-starter/tsconfig.build.json +2 -2
- package/templates/project-tee-starter/tsconfig.json +8 -5
- package/templates/project-tee-starter/tsup.config.ts +3 -2
- package/templates/project-tee-starter/vite.config.ts +39 -0
- package/dist/chunk-4O6EZU37.js +0 -14
- package/dist/migration-guides/advanced-migration-guide.md +0 -459
- package/dist/migration-guides/completion-requirements.md +0 -379
- package/dist/migration-guides/integrated-migration-loop.md +0 -392
- package/dist/migration-guides/migration-guide.md +0 -712
- package/dist/migration-guides/prompt-and-generation-guide.md +0 -702
- package/dist/migration-guides/state-and-providers-guide.md +0 -544
- package/dist/migration-guides/testing-guide.md +0 -1021
- package/dist/templates/plugin-starter/dist/assets/index-CgkejLs_.css +0 -1
- package/dist/templates/plugin-starter/dist/assets/index-D1cHX53P.js +0 -49
- package/dist/templates/plugin-starter/dist/index.js +0 -387
- package/dist/templates/plugin-starter/dist/index.js.map +0 -1
- package/templates/plugin-starter/dist/.vite/manifest.json +0 -11
- package/templates/plugin-starter/dist/assets/index-CgkejLs_.css +0 -1
- package/templates/plugin-starter/dist/assets/index-D1cHX53P.js +0 -49
- package/templates/plugin-starter/dist/index.d.ts +0 -14
- package/templates/plugin-starter/dist/index.js +0 -387
- 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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
8
|
-
State,
|
|
9
|
-
UUID,
|
|
12
|
+
asUUID,
|
|
10
13
|
logger,
|
|
11
14
|
} from '@elizaos/core';
|
|
12
15
|
|
|
13
16
|
/**
|
|
14
|
-
* Creates a
|
|
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
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
58
|
+
createdAt: now,
|
|
59
|
+
...overrides,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
29
62
|
|
|
30
|
-
|
|
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
|
-
|
|
33
|
-
|
|
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
|
-
|
|
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
|
|
197
|
+
return 'Never gonna give you up, never gonna let you down';
|
|
39
198
|
} else if (modelType === ModelType.TEXT_LARGE) {
|
|
40
|
-
return
|
|
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
|
|
201
|
+
return 'Default model response';
|
|
48
202
|
}),
|
|
49
203
|
|
|
50
|
-
//
|
|
51
|
-
|
|
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
|
-
//
|
|
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
|
|
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
|
|
66
|
-
|
|
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
|
-
}
|
|
75
|
-
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
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(
|
|
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:
|
|
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/
|
|
@@ -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.
|
|
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
|
|
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
|
-
"
|
|
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",
|