@elizaos/cli 1.3.2 → 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.
- package/README.md +46 -0
- package/dist/{bun-exec-6CQHTS4F.js → bun-exec-ULMPAIQC.js} +1 -1
- package/dist/{chunk-E6XYTE3A.js → chunk-D3QSET5H.js} +69 -72
- package/dist/{chunk-FDEDLANP.js → chunk-FQYWRHLX.js} +1 -1
- package/dist/{chunk-T2QDIXGU.js → chunk-FSSUAWXQ.js} +3 -3
- package/dist/{chunk-D3Q2UZLZ.js → chunk-I4L4T7QX.js} +1 -1
- package/dist/{chunk-5GUS4CFO.js → chunk-SMZBJQJR.js} +1 -1
- package/dist/commands/agent/actions/index.js +3 -3
- package/dist/commands/agent/index.js +3 -3
- package/dist/commands/create/actions/index.js +4 -4
- package/dist/commands/create/index.js +5 -5
- package/dist/index.js +134 -109
- package/dist/{plugin-creator-H26ZLR6H.js → plugin-creator-TCUFII32.js} +2 -2
- package/dist/{registry-433S5F3Y.js → registry-RF6PW3EN.js} +3 -3
- package/dist/templates/plugin-quick-starter/README.md +52 -10
- package/dist/templates/plugin-quick-starter/package.json +2 -2
- package/dist/templates/plugin-quick-starter/src/__tests__/e2e/README.md +140 -0
- package/dist/templates/plugin-quick-starter/src/__tests__/e2e/plugin-quick-starter.e2e.ts +339 -0
- package/dist/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +55 -17
- package/dist/templates/plugin-quick-starter/src/plugin.ts +14 -14
- package/dist/templates/plugin-starter/README.md +124 -49
- package/dist/templates/plugin-starter/package.json +2 -2
- package/dist/templates/plugin-starter/src/__tests__/e2e/README.md +44 -9
- package/{templates/plugin-starter/src/__tests__/e2e/starter-plugin.ts → dist/templates/plugin-starter/src/__tests__/e2e/plugin-starter.e2e.ts} +13 -20
- package/dist/templates/plugin-starter/src/plugin.ts +5 -7
- package/dist/templates/project-starter/README.md +24 -11
- package/dist/templates/project-starter/package.json +4 -4
- package/dist/templates/project-starter/src/__tests__/actions.test.ts +2 -2
- package/dist/templates/project-starter/src/__tests__/e2e/README.md +103 -0
- package/dist/templates/project-starter/src/__tests__/e2e/project-starter.e2e.ts +575 -0
- package/dist/templates/project-starter/src/__tests__/integration.test.ts +1 -1
- package/dist/templates/project-starter/src/__tests__/models.test.ts +3 -3
- package/dist/templates/project-starter/src/__tests__/plugin.test.ts +3 -3
- package/dist/templates/project-starter/src/__tests__/provider.test.ts +2 -2
- package/dist/templates/project-starter/src/index.ts +4 -3
- package/dist/templates/project-starter/src/plugin.ts +5 -5
- package/dist/templates/project-tee-starter/README.md +44 -5
- package/dist/templates/project-tee-starter/package.json +4 -4
- package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/build-order.test.ts +1 -1
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/character.test.ts +1 -1
- package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/config.test.ts +1 -1
- package/dist/templates/project-tee-starter/src/__tests__/e2e/README.md +128 -0
- package/dist/templates/project-tee-starter/src/__tests__/e2e/project-tee-starter.e2e.ts +280 -0
- package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/env.test.ts +1 -1
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/error-handling.test.ts +2 -2
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/events.test.ts +1 -1
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/file-structure.test.ts +2 -2
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/integration.test.ts +2 -2
- package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/models.test.ts +1 -1
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/plugin.test.ts +1 -1
- package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/provider.test.ts +2 -2
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/routes.test.ts +1 -1
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/tee-validation.test.ts +1 -1
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/test-utils.ts +2 -2
- package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/vite-config-utils.ts +14 -2
- package/dist/templates/project-tee-starter/src/index.ts +2 -0
- package/dist/templates/project-tee-starter/src/plugin.ts +19 -7
- package/dist/{utils-DBLSDYBF.js → utils-5HPZSIF6.js} +3 -3
- package/package.json +6 -6
- package/templates/plugin-quick-starter/README.md +52 -10
- package/templates/plugin-quick-starter/package.json +2 -2
- package/templates/plugin-quick-starter/src/__tests__/e2e/README.md +140 -0
- package/templates/plugin-quick-starter/src/__tests__/e2e/plugin-quick-starter.e2e.ts +339 -0
- package/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +55 -17
- package/templates/plugin-quick-starter/src/plugin.ts +14 -14
- package/templates/plugin-starter/README.md +124 -49
- package/templates/plugin-starter/package.json +2 -2
- package/templates/plugin-starter/src/__tests__/e2e/README.md +44 -9
- package/{dist/templates/plugin-starter/src/__tests__/e2e/starter-plugin.ts → templates/plugin-starter/src/__tests__/e2e/plugin-starter.e2e.ts} +13 -20
- package/templates/plugin-starter/src/plugin.ts +5 -7
- package/templates/project-starter/README.md +24 -11
- package/templates/project-starter/package.json +4 -4
- package/templates/project-starter/src/__tests__/actions.test.ts +2 -2
- package/templates/project-starter/src/__tests__/e2e/README.md +103 -0
- package/templates/project-starter/src/__tests__/e2e/project-starter.e2e.ts +575 -0
- package/templates/project-starter/src/__tests__/integration.test.ts +1 -1
- package/templates/project-starter/src/__tests__/models.test.ts +3 -3
- package/templates/project-starter/src/__tests__/plugin.test.ts +3 -3
- package/templates/project-starter/src/__tests__/provider.test.ts +2 -2
- package/templates/project-starter/src/index.ts +4 -3
- package/templates/project-starter/src/plugin.ts +5 -5
- package/templates/project-tee-starter/README.md +44 -5
- package/templates/project-tee-starter/package.json +4 -4
- package/templates/project-tee-starter/{__tests__ → src/__tests__}/build-order.test.ts +1 -1
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/character.test.ts +1 -1
- package/templates/project-tee-starter/{__tests__ → src/__tests__}/config.test.ts +1 -1
- package/templates/project-tee-starter/src/__tests__/e2e/README.md +128 -0
- package/templates/project-tee-starter/src/__tests__/e2e/project-tee-starter.e2e.ts +280 -0
- package/templates/project-tee-starter/{__tests__ → src/__tests__}/env.test.ts +1 -1
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/error-handling.test.ts +2 -2
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/events.test.ts +1 -1
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/file-structure.test.ts +2 -2
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/integration.test.ts +2 -2
- package/templates/project-tee-starter/{__tests__ → src/__tests__}/models.test.ts +1 -1
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/plugin.test.ts +1 -1
- package/templates/project-tee-starter/{__tests__ → src/__tests__}/provider.test.ts +2 -2
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/routes.test.ts +1 -1
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/tee-validation.test.ts +1 -1
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/test-utils.ts +2 -2
- package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/vite-config-utils.ts +14 -2
- package/templates/project-tee-starter/src/index.ts +2 -0
- package/templates/project-tee-starter/src/plugin.ts +19 -7
- package/dist/templates/plugin-starter/src/tests.ts +0 -6
- package/dist/templates/project-starter/src/__tests__/e2e/index.ts +0 -14
- package/dist/templates/project-starter/src/__tests__/e2e/natural-language.test.ts +0 -246
- package/dist/templates/project-starter/src/__tests__/e2e/project.test.ts +0 -155
- package/dist/templates/project-starter/src/__tests__/e2e/starter-plugin.test.ts +0 -421
- package/dist/templates/project-tee-starter/e2e/project.test.ts +0 -38
- package/dist/templates/project-tee-starter/e2e/starter-plugin.test.ts +0 -92
- package/templates/plugin-starter/src/tests.ts +0 -6
- package/templates/project-starter/src/__tests__/e2e/index.ts +0 -14
- package/templates/project-starter/src/__tests__/e2e/natural-language.test.ts +0 -246
- package/templates/project-starter/src/__tests__/e2e/project.test.ts +0 -155
- package/templates/project-starter/src/__tests__/e2e/starter-plugin.test.ts +0 -421
- package/templates/project-tee-starter/e2e/project.test.ts +0 -38
- package/templates/project-tee-starter/e2e/starter-plugin.test.ts +0 -92
- /package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/actions.test.ts +0 -0
- /package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/frontend.test.ts +0 -0
- /package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/utils/core-test-utils.ts +0 -0
- /package/templates/project-tee-starter/{__tests__ → src/__tests__}/actions.test.ts +0 -0
- /package/templates/project-tee-starter/{__tests__ → src/__tests__}/frontend.test.ts +0 -0
- /package/templates/project-tee-starter/{__tests__ → src/__tests__}/utils/core-test-utils.ts +0 -0
|
@@ -1,421 +0,0 @@
|
|
|
1
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Starter Plugin E2E Test Suite
|
|
5
|
-
*
|
|
6
|
-
* This comprehensive test suite demonstrates how to write end-to-end tests for ElizaOS plugins.
|
|
7
|
-
* These tests run in a REAL runtime environment provided by `elizaos test`, meaning:
|
|
8
|
-
*
|
|
9
|
-
* - All services are actually initialized and running
|
|
10
|
-
* - The database is real (in-memory PGLite for testing)
|
|
11
|
-
* - Actions, providers, and events are fully functional
|
|
12
|
-
* - The agent's AI/LLM capabilities are active
|
|
13
|
-
*
|
|
14
|
-
* STRUCTURE OF AN E2E TEST:
|
|
15
|
-
* 1. Each test receives a live IAgentRuntime instance
|
|
16
|
-
* 2. You interact with the runtime as if it were production
|
|
17
|
-
* 3. Test success = no errors thrown, test failure = throw an error
|
|
18
|
-
*
|
|
19
|
-
* HOW TO ADD NEW TESTS:
|
|
20
|
-
* 1. Add a new object to the `tests` array with:
|
|
21
|
-
* - `name`: A descriptive name for your test
|
|
22
|
-
* - `fn`: An async function that receives the runtime
|
|
23
|
-
* 2. In your test function:
|
|
24
|
-
* - Set up any required state (rooms, messages, etc.)
|
|
25
|
-
* - Execute the functionality you want to test
|
|
26
|
-
* - Assert the results (throw errors on failure)
|
|
27
|
-
* 3. Keep tests independent - don't rely on other tests' state
|
|
28
|
-
*
|
|
29
|
-
* TESTING PATTERNS DEMONSTRATED:
|
|
30
|
-
* - Character configuration validation
|
|
31
|
-
* - Plugin initialization
|
|
32
|
-
* - Action execution (both direct and natural language)
|
|
33
|
-
* - Provider functionality
|
|
34
|
-
* - Service lifecycle management
|
|
35
|
-
* - Natural language understanding
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
// Define a minimal TestSuite interface that matches what's needed
|
|
39
|
-
interface TestSuite {
|
|
40
|
-
name: string;
|
|
41
|
-
description: string;
|
|
42
|
-
tests: Array<{
|
|
43
|
-
name: string;
|
|
44
|
-
fn: (runtime: any) => Promise<any>;
|
|
45
|
-
}>;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Define minimal interfaces for the types we need
|
|
49
|
-
type UUID = `${string}-${string}-${string}-${string}-${string}`;
|
|
50
|
-
|
|
51
|
-
interface Memory {
|
|
52
|
-
entityId: UUID;
|
|
53
|
-
roomId: UUID;
|
|
54
|
-
content: {
|
|
55
|
-
text: string;
|
|
56
|
-
source: string;
|
|
57
|
-
actions?: string[];
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
interface State {
|
|
62
|
-
values: Record<string, any>;
|
|
63
|
-
data: Record<string, any>;
|
|
64
|
-
text: string;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
interface Content {
|
|
68
|
-
text: string;
|
|
69
|
-
source?: string;
|
|
70
|
-
actions?: string[];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export class StarterTestSuite implements TestSuite {
|
|
74
|
-
name = 'starter';
|
|
75
|
-
description = 'E2E tests for the starter project demonstrating comprehensive testing patterns';
|
|
76
|
-
|
|
77
|
-
tests = [
|
|
78
|
-
{
|
|
79
|
-
/**
|
|
80
|
-
* Test 1: Character Configuration Validation
|
|
81
|
-
* This test ensures that the character is properly configured with all required fields.
|
|
82
|
-
* It's a good first test because it validates the basic setup before testing functionality.
|
|
83
|
-
*/
|
|
84
|
-
name: 'Character configuration test',
|
|
85
|
-
fn: async (runtime: any) => {
|
|
86
|
-
const character = runtime.character;
|
|
87
|
-
const requiredFields = ['name', 'bio', 'plugins', 'system', 'messageExamples'];
|
|
88
|
-
const missingFields = requiredFields.filter((field) => !(field in character));
|
|
89
|
-
|
|
90
|
-
if (missingFields.length > 0) {
|
|
91
|
-
throw new Error(`Missing required fields: ${missingFields.join(', ')}`);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Additional character property validations
|
|
95
|
-
if (character.name !== 'Eliza') {
|
|
96
|
-
throw new Error(`Expected character name to be 'Eliza', got '${character.name}'`);
|
|
97
|
-
}
|
|
98
|
-
if (!Array.isArray(character.plugins)) {
|
|
99
|
-
throw new Error('Character plugins should be an array');
|
|
100
|
-
}
|
|
101
|
-
if (!character.system) {
|
|
102
|
-
throw new Error('Character system prompt is required');
|
|
103
|
-
}
|
|
104
|
-
if (!Array.isArray(character.bio)) {
|
|
105
|
-
throw new Error('Character bio should be an array');
|
|
106
|
-
}
|
|
107
|
-
if (!Array.isArray(character.messageExamples)) {
|
|
108
|
-
throw new Error('Character message examples should be an array');
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
{
|
|
114
|
-
/**
|
|
115
|
-
* Test 2: Plugin Initialization
|
|
116
|
-
* This test verifies that plugins can be registered with the runtime.
|
|
117
|
-
* It's important to test this separately from action execution to isolate issues.
|
|
118
|
-
*/
|
|
119
|
-
name: 'Plugin initialization test',
|
|
120
|
-
fn: async (runtime: any) => {
|
|
121
|
-
// Test plugin initialization with empty config
|
|
122
|
-
try {
|
|
123
|
-
await runtime.registerPlugin({
|
|
124
|
-
name: 'starter',
|
|
125
|
-
description: 'A starter plugin for Eliza',
|
|
126
|
-
init: async () => {},
|
|
127
|
-
config: {},
|
|
128
|
-
});
|
|
129
|
-
} catch (error) {
|
|
130
|
-
throw new Error(`Failed to register plugin: ${(error as Error).message}`);
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
|
|
135
|
-
{
|
|
136
|
-
/**
|
|
137
|
-
* Test 3: Direct Action Execution
|
|
138
|
-
* This test explicitly requests the HELLO_WORLD action to verify it works correctly.
|
|
139
|
-
* This is useful for testing that the action itself is functioning before testing
|
|
140
|
-
* natural language understanding.
|
|
141
|
-
*/
|
|
142
|
-
name: 'Hello world action test - Direct execution',
|
|
143
|
-
fn: async (runtime: any) => {
|
|
144
|
-
const message: Memory = {
|
|
145
|
-
entityId: uuidv4() as UUID,
|
|
146
|
-
roomId: uuidv4() as UUID,
|
|
147
|
-
content: {
|
|
148
|
-
text: 'Can you say hello?',
|
|
149
|
-
source: 'test',
|
|
150
|
-
actions: ['HELLO_WORLD'], // Explicitly request the HELLO_WORLD action
|
|
151
|
-
},
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
const state: State = {
|
|
155
|
-
values: {},
|
|
156
|
-
data: {},
|
|
157
|
-
text: '',
|
|
158
|
-
};
|
|
159
|
-
let responseReceived = false;
|
|
160
|
-
|
|
161
|
-
// Test the hello world action
|
|
162
|
-
try {
|
|
163
|
-
await runtime.processActions(message, [], state, async (content: Content) => {
|
|
164
|
-
if (content.text === 'hello world!' && content.actions?.includes('HELLO_WORLD')) {
|
|
165
|
-
responseReceived = true;
|
|
166
|
-
}
|
|
167
|
-
return [];
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
if (!responseReceived) {
|
|
171
|
-
// Try directly executing the action if processActions didn't work
|
|
172
|
-
const helloWorldAction = runtime.actions.find((a: any) => a.name === 'HELLO_WORLD');
|
|
173
|
-
if (helloWorldAction) {
|
|
174
|
-
await helloWorldAction.handler(
|
|
175
|
-
runtime,
|
|
176
|
-
message,
|
|
177
|
-
state,
|
|
178
|
-
{},
|
|
179
|
-
async (content: Content) => {
|
|
180
|
-
if (content.text === 'hello world!' && content.actions?.includes('HELLO_WORLD')) {
|
|
181
|
-
responseReceived = true;
|
|
182
|
-
}
|
|
183
|
-
return [];
|
|
184
|
-
},
|
|
185
|
-
[]
|
|
186
|
-
);
|
|
187
|
-
} else {
|
|
188
|
-
throw new Error('HELLO_WORLD action not found in runtime.actions');
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (!responseReceived) {
|
|
193
|
-
throw new Error('Hello world action did not produce expected response');
|
|
194
|
-
}
|
|
195
|
-
} catch (error) {
|
|
196
|
-
throw new Error(`Hello world action test failed: ${(error as Error).message}`);
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
|
|
201
|
-
{
|
|
202
|
-
/**
|
|
203
|
-
* Test 4: Natural Language Understanding - Hello World
|
|
204
|
-
* This is the KEY TEST that demonstrates how the agent should naturally understand
|
|
205
|
-
* a request to say "hello world" without explicitly specifying the action.
|
|
206
|
-
*
|
|
207
|
-
* This test simulates a real conversation where:
|
|
208
|
-
* 1. The user asks the agent to say "hello world" in natural language
|
|
209
|
-
* 2. The agent understands the request and decides to use the HELLO_WORLD action
|
|
210
|
-
* 3. The agent responds with "hello world!"
|
|
211
|
-
*
|
|
212
|
-
* This tests the full AI pipeline: understanding → decision making → action execution
|
|
213
|
-
*/
|
|
214
|
-
name: 'Natural language hello world test',
|
|
215
|
-
fn: async (runtime: any) => {
|
|
216
|
-
// Create a unique room for this conversation
|
|
217
|
-
const roomId = uuidv4() as UUID;
|
|
218
|
-
const userId = uuidv4() as UUID;
|
|
219
|
-
|
|
220
|
-
try {
|
|
221
|
-
// Step 1: Send a natural language message asking for hello world
|
|
222
|
-
// Note: We do NOT specify any actions - the agent must understand and decide
|
|
223
|
-
const userMessage: Memory = {
|
|
224
|
-
entityId: userId,
|
|
225
|
-
roomId: roomId,
|
|
226
|
-
content: {
|
|
227
|
-
text: 'Please say hello world', // Natural language request
|
|
228
|
-
source: 'test',
|
|
229
|
-
// No actions specified - agent must understand the intent
|
|
230
|
-
},
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
// Step 2: Process the message through the agent's full pipeline
|
|
234
|
-
// This includes:
|
|
235
|
-
// - Natural language understanding
|
|
236
|
-
// - Intent recognition
|
|
237
|
-
// - Action selection
|
|
238
|
-
// - Response generation
|
|
239
|
-
let agentResponse: string | null = null;
|
|
240
|
-
let actionUsed: string | null = null;
|
|
241
|
-
|
|
242
|
-
// Set up a callback to capture the agent's response
|
|
243
|
-
const responseCallback = async (content: Content) => {
|
|
244
|
-
agentResponse = content.text;
|
|
245
|
-
if (content.actions && content.actions.length > 0) {
|
|
246
|
-
actionUsed = content.actions[0];
|
|
247
|
-
}
|
|
248
|
-
return [];
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
// Process the message - this simulates a real conversation
|
|
252
|
-
await runtime.processMessage(userMessage, [], responseCallback);
|
|
253
|
-
|
|
254
|
-
// Alternative approach if processMessage isn't available
|
|
255
|
-
if (!agentResponse) {
|
|
256
|
-
// Try using the evaluate method which processes messages through the full pipeline
|
|
257
|
-
const state: State = {
|
|
258
|
-
values: {},
|
|
259
|
-
data: {},
|
|
260
|
-
text: userMessage.content.text,
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
const result = await runtime.evaluate(userMessage, state, responseCallback);
|
|
264
|
-
|
|
265
|
-
// If evaluate doesn't work, try the action selection pipeline
|
|
266
|
-
if (!agentResponse && runtime.evaluateActions) {
|
|
267
|
-
const selectedActions = await runtime.evaluateActions(userMessage, state);
|
|
268
|
-
|
|
269
|
-
if (selectedActions && selectedActions.length > 0) {
|
|
270
|
-
// Execute the selected action
|
|
271
|
-
const action = runtime.actions.find((a: any) => a.name === selectedActions[0]);
|
|
272
|
-
if (action) {
|
|
273
|
-
await action.handler(runtime, userMessage, state, {}, responseCallback, []);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// Step 3: Verify the agent understood and responded correctly
|
|
280
|
-
if (!agentResponse) {
|
|
281
|
-
throw new Error('Agent did not respond to natural language request');
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// Check that the response contains "hello world" (case insensitive)
|
|
285
|
-
const responseText = (agentResponse || '') as string;
|
|
286
|
-
if (!responseText.toLowerCase().includes('hello world')) {
|
|
287
|
-
throw new Error(
|
|
288
|
-
`Agent response did not contain "hello world". Got: "${agentResponse}"`
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
// Optionally verify that the HELLO_WORLD action was used
|
|
293
|
-
if (actionUsed && actionUsed !== 'HELLO_WORLD') {
|
|
294
|
-
console.log(`Note: Agent used action "${actionUsed}" instead of "HELLO_WORLD"`);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// Test passed! The agent successfully understood the natural language request
|
|
298
|
-
// and responded with "hello world"
|
|
299
|
-
} catch (error) {
|
|
300
|
-
throw new Error(`Natural language hello world test failed: ${(error as Error).message}`);
|
|
301
|
-
}
|
|
302
|
-
},
|
|
303
|
-
},
|
|
304
|
-
|
|
305
|
-
{
|
|
306
|
-
/**
|
|
307
|
-
* Test 5: Provider Functionality
|
|
308
|
-
* Providers supply context to the agent. This test verifies that our
|
|
309
|
-
* HELLO_WORLD_PROVIDER is functioning and returning the expected data.
|
|
310
|
-
*/
|
|
311
|
-
name: 'Hello world provider test',
|
|
312
|
-
fn: async (runtime: any) => {
|
|
313
|
-
const message: Memory = {
|
|
314
|
-
entityId: uuidv4() as UUID,
|
|
315
|
-
roomId: uuidv4() as UUID,
|
|
316
|
-
content: {
|
|
317
|
-
text: 'What can you provide?',
|
|
318
|
-
source: 'test',
|
|
319
|
-
},
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
const state: State = {
|
|
323
|
-
values: {},
|
|
324
|
-
data: {},
|
|
325
|
-
text: '',
|
|
326
|
-
};
|
|
327
|
-
|
|
328
|
-
// Test the hello world provider
|
|
329
|
-
try {
|
|
330
|
-
if (!runtime.providers || runtime.providers.length === 0) {
|
|
331
|
-
throw new Error('No providers found in runtime');
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
// Find the specific provider we want to test
|
|
335
|
-
const helloWorldProvider = runtime.providers.find(
|
|
336
|
-
(p: any) => p.name === 'HELLO_WORLD_PROVIDER'
|
|
337
|
-
);
|
|
338
|
-
|
|
339
|
-
if (!helloWorldProvider) {
|
|
340
|
-
throw new Error('HELLO_WORLD_PROVIDER not found in runtime providers');
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
const result = await helloWorldProvider.get(runtime, message, state);
|
|
344
|
-
|
|
345
|
-
if (result.text !== 'I am a provider') {
|
|
346
|
-
throw new Error(`Expected provider to return "I am a provider", got "${result.text}"`);
|
|
347
|
-
}
|
|
348
|
-
} catch (error) {
|
|
349
|
-
throw new Error(`Hello world provider test failed: ${(error as Error).message}`);
|
|
350
|
-
}
|
|
351
|
-
},
|
|
352
|
-
},
|
|
353
|
-
|
|
354
|
-
{
|
|
355
|
-
/**
|
|
356
|
-
* Test 6: Service Lifecycle Management
|
|
357
|
-
* Services are long-running components. This test verifies that our
|
|
358
|
-
* starter service can be properly started, accessed, and stopped.
|
|
359
|
-
*/
|
|
360
|
-
name: 'Starter service test',
|
|
361
|
-
fn: async (runtime: any) => {
|
|
362
|
-
// Test service registration and lifecycle
|
|
363
|
-
try {
|
|
364
|
-
const service = runtime.getService('starter');
|
|
365
|
-
if (!service) {
|
|
366
|
-
throw new Error('Starter service not found');
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
if (
|
|
370
|
-
service.capabilityDescription !==
|
|
371
|
-
'This is a starter service which is attached to the agent through the starter plugin.'
|
|
372
|
-
) {
|
|
373
|
-
throw new Error('Incorrect service capability description');
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
await service.stop();
|
|
377
|
-
} catch (error) {
|
|
378
|
-
throw new Error(`Starter service test failed: ${(error as Error).message}`);
|
|
379
|
-
}
|
|
380
|
-
},
|
|
381
|
-
},
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* TEMPLATE: How to add a new E2E test
|
|
385
|
-
* Copy this template and modify it for your specific test case
|
|
386
|
-
*/
|
|
387
|
-
/*
|
|
388
|
-
{
|
|
389
|
-
name: 'My new feature test',
|
|
390
|
-
fn: async (runtime: any) => {
|
|
391
|
-
try {
|
|
392
|
-
// 1. Set up test data
|
|
393
|
-
const testData = {
|
|
394
|
-
// Your test setup here
|
|
395
|
-
};
|
|
396
|
-
|
|
397
|
-
// 2. Execute the feature
|
|
398
|
-
const result = await runtime.someMethod(testData);
|
|
399
|
-
|
|
400
|
-
// 3. Verify the results
|
|
401
|
-
if (!result) {
|
|
402
|
-
throw new Error('Expected result but got nothing');
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
if (result.someProperty !== 'expected value') {
|
|
406
|
-
throw new Error(`Expected 'expected value' but got '${result.someProperty}'`);
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
// Test passed if we reach here without throwing
|
|
410
|
-
} catch (error) {
|
|
411
|
-
// Always wrap errors with context for easier debugging
|
|
412
|
-
throw new Error(`My new feature test failed: ${error.message}`);
|
|
413
|
-
}
|
|
414
|
-
},
|
|
415
|
-
},
|
|
416
|
-
*/
|
|
417
|
-
];
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
// Export a default instance of the test suite for the E2E test runner
|
|
421
|
-
export default new StarterTestSuite();
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { TestSuite, IAgentRuntime } from '@elizaos/core';
|
|
2
|
-
import { character as mrTeeCharacter } from '../src/index';
|
|
3
|
-
|
|
4
|
-
export class MrTeeProjectTestSuite implements TestSuite {
|
|
5
|
-
name = 'mr-tee-project';
|
|
6
|
-
description = 'E2E tests for Mr. TEE project-specific features';
|
|
7
|
-
|
|
8
|
-
tests = [
|
|
9
|
-
{
|
|
10
|
-
name: 'Mr. TEE Project runtime environment test',
|
|
11
|
-
fn: async (runtime: IAgentRuntime) => {
|
|
12
|
-
try {
|
|
13
|
-
if (!runtime.character) {
|
|
14
|
-
throw new Error('Character not loaded in runtime');
|
|
15
|
-
}
|
|
16
|
-
if (runtime.character.name !== mrTeeCharacter.name) {
|
|
17
|
-
throw new Error(
|
|
18
|
-
`Expected character name to be ${mrTeeCharacter.name}, got ${runtime.character.name}`
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
if (!runtime.character.system?.includes('Mr. TEE')) {
|
|
22
|
-
throw new Error('Character system prompt does not contain "Mr. TEE"');
|
|
23
|
-
}
|
|
24
|
-
const hasTeePlugin = runtime.character.plugins?.some(
|
|
25
|
-
(p) => typeof p === 'string' && p.includes('tee')
|
|
26
|
-
);
|
|
27
|
-
if (!hasTeePlugin) {
|
|
28
|
-
throw new Error('Character does not have TEE plugin');
|
|
29
|
-
}
|
|
30
|
-
} catch (error) {
|
|
31
|
-
throw new Error(`Mr. TEE Project runtime environment test failed: ${error.message}`);
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default new MrTeeProjectTestSuite();
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { character } from '../src/index';
|
|
2
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
3
|
-
|
|
4
|
-
// Define a minimal TestSuite interface that matches what's needed
|
|
5
|
-
interface TestSuite {
|
|
6
|
-
name: string;
|
|
7
|
-
description: string;
|
|
8
|
-
tests: Array<{
|
|
9
|
-
name: string;
|
|
10
|
-
fn: (runtime: any) => Promise<any>;
|
|
11
|
-
}>;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// Define minimal interfaces for the types we need
|
|
15
|
-
type UUID = `${string}-${string}-${string}-${string}-${string}`;
|
|
16
|
-
|
|
17
|
-
interface Memory {
|
|
18
|
-
entityId: UUID;
|
|
19
|
-
roomId: UUID;
|
|
20
|
-
content: {
|
|
21
|
-
text: string;
|
|
22
|
-
source: string;
|
|
23
|
-
actions?: string[];
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface State {
|
|
28
|
-
values: Record<string, any>;
|
|
29
|
-
data: Record<string, any>;
|
|
30
|
-
text: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
interface Content {
|
|
34
|
-
text: string;
|
|
35
|
-
source?: string;
|
|
36
|
-
actions?: string[];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export class StarterTestSuite implements TestSuite {
|
|
40
|
-
name = 'starter';
|
|
41
|
-
description = 'E2E tests for the starter project';
|
|
42
|
-
|
|
43
|
-
tests = [
|
|
44
|
-
{
|
|
45
|
-
name: 'Character configuration test',
|
|
46
|
-
fn: async (runtime: any) => {
|
|
47
|
-
const requiredFields = ['name', 'bio', 'plugins', 'system', 'messageExamples'];
|
|
48
|
-
const missingFields = requiredFields.filter((field) => !(field in character));
|
|
49
|
-
|
|
50
|
-
if (missingFields.length > 0) {
|
|
51
|
-
throw new Error(`Missing required fields: ${missingFields.join(', ')}`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Additional character property validations
|
|
55
|
-
if (character.name !== 'Mr. TEE') {
|
|
56
|
-
throw new Error(`Expected character name to be 'Mr. TEE', got '${character.name}'`);
|
|
57
|
-
}
|
|
58
|
-
if (!Array.isArray(character.plugins)) {
|
|
59
|
-
throw new Error('Character plugins should be an array');
|
|
60
|
-
}
|
|
61
|
-
if (!character.system) {
|
|
62
|
-
throw new Error('Character system prompt is required');
|
|
63
|
-
}
|
|
64
|
-
if (!Array.isArray(character.bio)) {
|
|
65
|
-
throw new Error('Character bio should be an array');
|
|
66
|
-
}
|
|
67
|
-
if (!Array.isArray(character.messageExamples)) {
|
|
68
|
-
throw new Error('Character message examples should be an array');
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
name: 'Plugin initialization test',
|
|
74
|
-
fn: async (runtime: any) => {
|
|
75
|
-
// Test plugin initialization with empty config
|
|
76
|
-
try {
|
|
77
|
-
await runtime.registerPlugin({
|
|
78
|
-
name: 'starter',
|
|
79
|
-
description: 'A starter plugin for Eliza',
|
|
80
|
-
init: async () => {},
|
|
81
|
-
config: {},
|
|
82
|
-
});
|
|
83
|
-
} catch (error) {
|
|
84
|
-
throw new Error(`Failed to register plugin: ${error.message}`);
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
];
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Export a default instance of the test suite for the E2E test runner
|
|
92
|
-
export default new StarterTestSuite();
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* E2E Test Suite Exports
|
|
3
|
-
*
|
|
4
|
-
* This file exports all E2E test suites for the ElizaOS test runner.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import projectTestSuite from './project.test';
|
|
8
|
-
import starterTestSuite from './starter-plugin.test';
|
|
9
|
-
import naturalLanguageTestSuite from './natural-language.test';
|
|
10
|
-
|
|
11
|
-
// Export test suites for the test runner to discover
|
|
12
|
-
export const testSuites = [projectTestSuite, starterTestSuite, naturalLanguageTestSuite];
|
|
13
|
-
|
|
14
|
-
export default testSuites;
|