@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,17 +1,29 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
|
|
4
|
+
// Default output directories
|
|
5
|
+
const DEFAULT_VITE_OUT_DIR = 'dist/frontend';
|
|
6
|
+
const DEFAULT_VITE_VAR_DIR = 'dist/.vite';
|
|
7
|
+
|
|
4
8
|
/**
|
|
5
9
|
* Extracts the Vite output directory from vite.config.ts
|
|
6
10
|
*/
|
|
7
11
|
export async function getViteOutDir(rootDir: string): Promise<string> {
|
|
8
12
|
const viteConfigPath = path.join(rootDir, 'vite.config.ts');
|
|
13
|
+
|
|
14
|
+
// Check if vite config exists
|
|
15
|
+
if (!fs.existsSync(viteConfigPath)) {
|
|
16
|
+
// Return default if config doesn't exist
|
|
17
|
+
return DEFAULT_VITE_OUT_DIR;
|
|
18
|
+
}
|
|
19
|
+
|
|
9
20
|
const configContent = await fs.promises.readFile(viteConfigPath, 'utf-8');
|
|
10
21
|
|
|
11
22
|
// Extract the outDir value using regex
|
|
12
23
|
const outDirMatch = configContent.match(/outDir\s*:\s*['"`]([^'"`]+)['"`]/);
|
|
13
24
|
if (!outDirMatch) {
|
|
14
|
-
|
|
25
|
+
// Return default output directory if outDir configuration is not found in vite.config.ts
|
|
26
|
+
return DEFAULT_VITE_OUT_DIR;
|
|
15
27
|
}
|
|
16
28
|
|
|
17
29
|
let outDir = outDirMatch[1];
|
|
@@ -24,7 +36,7 @@ export async function getViteOutDir(rootDir: string): Promise<string> {
|
|
|
24
36
|
outDir = outDir.replace('${outDir}', varMatch[1]);
|
|
25
37
|
} else {
|
|
26
38
|
// Default fallback
|
|
27
|
-
outDir =
|
|
39
|
+
outDir = DEFAULT_VITE_VAR_DIR;
|
|
28
40
|
}
|
|
29
41
|
}
|
|
30
42
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { logger, type IAgentRuntime, type Project, type ProjectAgent } from '@elizaos/core';
|
|
2
2
|
import teeStarterPlugin, { StarterService } from './plugin.ts';
|
|
3
3
|
import { mrTeeCharacter as character } from './character.ts';
|
|
4
|
+
import ProjectTeeStarterTestSuite from './__tests__/e2e/project-tee-starter.e2e';
|
|
4
5
|
|
|
5
6
|
const initCharacter = ({ runtime }: { runtime: IAgentRuntime }) => {
|
|
6
7
|
logger.info(`Initializing character: ${character.name}`);
|
|
@@ -10,6 +11,7 @@ const initCharacter = ({ runtime }: { runtime: IAgentRuntime }) => {
|
|
|
10
11
|
export const projectAgent: ProjectAgent = {
|
|
11
12
|
character,
|
|
12
13
|
init: async (runtime: IAgentRuntime) => await initCharacter({ runtime }),
|
|
14
|
+
tests: [ProjectTeeStarterTestSuite], // Export tests from ProjectAgent
|
|
13
15
|
};
|
|
14
16
|
|
|
15
17
|
const project: Project = {
|
|
@@ -119,6 +119,18 @@ const deriveEd25519Keypair = (deriveKeyResponse: DeriveKeyResponse): Keypair =>
|
|
|
119
119
|
return Keypair.fromSeed(seedArray.slice(0, 32));
|
|
120
120
|
};
|
|
121
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Checks if an error is a TEE connection error
|
|
124
|
+
* @param error The error to check
|
|
125
|
+
* @returns True if the error is a TEE connection error
|
|
126
|
+
*/
|
|
127
|
+
const isTeeConnectionError = (error: unknown): boolean => {
|
|
128
|
+
return (
|
|
129
|
+
error instanceof Error &&
|
|
130
|
+
(error.message.includes('ENOENT') || error.message.includes('Failed to connect'))
|
|
131
|
+
);
|
|
132
|
+
};
|
|
133
|
+
|
|
122
134
|
/**
|
|
123
135
|
* Handles TEE key derivation and logging
|
|
124
136
|
*/
|
|
@@ -135,18 +147,18 @@ const handleTeeKeyDerivation = async (config: TeeServiceConfig): Promise<void> =
|
|
|
135
147
|
const ed25519Keypair = deriveEd25519Keypair(deriveKeyResponse);
|
|
136
148
|
|
|
137
149
|
logger.log('ECDSA Key Derived Successfully!');
|
|
138
|
-
logger.log('ECDSA Keypair:'
|
|
139
|
-
logger.log('ED25519 Keypair:'
|
|
150
|
+
logger.log({ address: ecdsaKeypair.address }, 'ECDSA Keypair:');
|
|
151
|
+
logger.log({ publicKey: ed25519Keypair.publicKey }, 'ED25519 Keypair:');
|
|
140
152
|
|
|
141
153
|
const signature = await ecdsaKeypair.signMessage({ message: 'Hello, world!' });
|
|
142
|
-
logger.log('Sign message w/ ECDSA keypair: Hello world!, Signature:
|
|
154
|
+
logger.log({ signature }, 'Sign message w/ ECDSA keypair: Hello world!, Signature:');
|
|
143
155
|
} catch (error) {
|
|
144
156
|
// Handle TEE connection errors gracefully
|
|
145
|
-
if (error
|
|
157
|
+
if (isTeeConnectionError(error)) {
|
|
146
158
|
logger.warn('TEE daemon not available - running in non-TEE mode for testing');
|
|
147
159
|
logger.warn('To run with TEE, ensure tappd is running at /var/run/tappd.sock');
|
|
148
160
|
} else {
|
|
149
|
-
logger.error
|
|
161
|
+
logger.warn({ error }, 'TEE daemon connection failed, running in non-TEE mode:');
|
|
150
162
|
}
|
|
151
163
|
// Continue without TEE functionality for testing
|
|
152
164
|
}
|
|
@@ -289,8 +301,8 @@ const teeStarterPlugin: Plugin = {
|
|
|
289
301
|
MESSAGE_RECEIVED: [
|
|
290
302
|
async (params) => {
|
|
291
303
|
logger.info(
|
|
292
|
-
|
|
293
|
-
|
|
304
|
+
{ preview: params.message?.content?.text?.substring(0, 50) },
|
|
305
|
+
'[MR_TEE_PLUGIN] MESSAGE_RECEIVED event'
|
|
294
306
|
);
|
|
295
307
|
},
|
|
296
308
|
],
|
|
@@ -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;
|
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
import { type TestSuite } from '@elizaos/core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Natural Language E2E Test Suite
|
|
5
|
-
*
|
|
6
|
-
* This suite tests the agent's ability to respond to natural language inputs,
|
|
7
|
-
* including the requested "hello world" test.
|
|
8
|
-
*
|
|
9
|
-
* HOW TO ADD NEW NATURAL LANGUAGE TESTS:
|
|
10
|
-
* 1. Add a new test object to the `tests` array
|
|
11
|
-
* 2. Create a message with natural language content
|
|
12
|
-
* 3. Process it through the runtime
|
|
13
|
-
* 4. Verify the agent's response makes sense
|
|
14
|
-
*
|
|
15
|
-
* These tests use the REAL runtime with actual language processing,
|
|
16
|
-
* so responses may vary based on the model and character configuration.
|
|
17
|
-
*/
|
|
18
|
-
export class NaturalLanguageTestSuite implements TestSuite {
|
|
19
|
-
name = 'natural-language';
|
|
20
|
-
description = 'E2E tests for natural language processing and agent responses';
|
|
21
|
-
|
|
22
|
-
tests = [
|
|
23
|
-
{
|
|
24
|
-
name: 'Agent responds to hello world',
|
|
25
|
-
fn: async (runtime: any) => {
|
|
26
|
-
/**
|
|
27
|
-
* This test verifies that the agent can respond appropriately
|
|
28
|
-
* to a simple "hello world" greeting.
|
|
29
|
-
*/
|
|
30
|
-
try {
|
|
31
|
-
// Create a unique room for this test
|
|
32
|
-
const roomId = `test-room-hello-${Date.now()}`;
|
|
33
|
-
const userId = 'test-user-hello';
|
|
34
|
-
|
|
35
|
-
// Create a message saying "hello world"
|
|
36
|
-
const helloMessage = {
|
|
37
|
-
id: `msg-${Date.now()}`,
|
|
38
|
-
userId: userId,
|
|
39
|
-
agentId: runtime.agentId,
|
|
40
|
-
roomId: roomId,
|
|
41
|
-
content: {
|
|
42
|
-
text: 'hello world',
|
|
43
|
-
type: 'text',
|
|
44
|
-
},
|
|
45
|
-
createdAt: Date.now(),
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
console.log('Sending hello world message to agent...');
|
|
49
|
-
|
|
50
|
-
// Process the message through the runtime
|
|
51
|
-
// This will trigger the agent to generate a response
|
|
52
|
-
await runtime.processMessage(helloMessage);
|
|
53
|
-
|
|
54
|
-
// Give the agent a moment to process and respond
|
|
55
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
56
|
-
|
|
57
|
-
// Retrieve messages from the conversation
|
|
58
|
-
const messages = await runtime.messageManager.getMessages({
|
|
59
|
-
roomId,
|
|
60
|
-
limit: 10,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
console.log(`Retrieved ${messages.length} messages from conversation`);
|
|
64
|
-
|
|
65
|
-
// Verify we have at least 2 messages (user + agent)
|
|
66
|
-
if (messages.length < 2) {
|
|
67
|
-
throw new Error(`Expected at least 2 messages, got ${messages.length}`);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Find the agent's response
|
|
71
|
-
const agentResponse = messages.find(
|
|
72
|
-
(m: any) =>
|
|
73
|
-
m.userId === runtime.agentId && m.roomId === roomId && m.id !== helloMessage.id
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
if (!agentResponse) {
|
|
77
|
-
throw new Error('Agent did not respond to hello world message');
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
console.log('Agent response:', agentResponse.content.text);
|
|
81
|
-
|
|
82
|
-
// Verify the response contains a greeting
|
|
83
|
-
const responseText = agentResponse.content.text.toLowerCase();
|
|
84
|
-
const greetingWords = ['hello', 'hi', 'hey', 'greetings', 'welcome'];
|
|
85
|
-
|
|
86
|
-
const containsGreeting = greetingWords.some((word) => responseText.includes(word));
|
|
87
|
-
|
|
88
|
-
if (!containsGreeting) {
|
|
89
|
-
throw new Error(
|
|
90
|
-
`Agent response did not contain a greeting. ` +
|
|
91
|
-
`Response was: "${agentResponse.content.text}"`
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
console.log('✓ Agent successfully responded to hello world');
|
|
96
|
-
} catch (error) {
|
|
97
|
-
throw new Error(`Hello world test failed: ${(error as Error).message}`);
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
{
|
|
103
|
-
name: 'Agent responds to casual greeting',
|
|
104
|
-
fn: async (runtime: any) => {
|
|
105
|
-
/**
|
|
106
|
-
* Test various casual greetings to ensure the agent
|
|
107
|
-
* responds appropriately to different forms of hello.
|
|
108
|
-
*/
|
|
109
|
-
try {
|
|
110
|
-
const greetings = ['hey there!', 'hi, how are you?', 'good morning!', 'whats up?'];
|
|
111
|
-
|
|
112
|
-
for (const greeting of greetings) {
|
|
113
|
-
const roomId = `test-room-greeting-${Date.now()}-${Math.random()}`;
|
|
114
|
-
const userId = 'test-user-greeting';
|
|
115
|
-
|
|
116
|
-
const message = {
|
|
117
|
-
id: `msg-${Date.now()}-${Math.random()}`,
|
|
118
|
-
userId: userId,
|
|
119
|
-
agentId: runtime.agentId,
|
|
120
|
-
roomId: roomId,
|
|
121
|
-
content: {
|
|
122
|
-
text: greeting,
|
|
123
|
-
type: 'text',
|
|
124
|
-
},
|
|
125
|
-
createdAt: Date.now(),
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
console.log(`Testing greeting: "${greeting}"`);
|
|
129
|
-
|
|
130
|
-
await runtime.processMessage(message);
|
|
131
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
132
|
-
|
|
133
|
-
const messages = await runtime.messageManager.getMessages({
|
|
134
|
-
roomId,
|
|
135
|
-
limit: 10,
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
const agentResponse = messages.find(
|
|
139
|
-
(m: any) => m.userId === runtime.agentId && m.id !== message.id
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
if (!agentResponse) {
|
|
143
|
-
throw new Error(`Agent did not respond to greeting: "${greeting}"`);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// Just verify we got a response - content may vary
|
|
147
|
-
if (!agentResponse.content.text || agentResponse.content.text.length < 2) {
|
|
148
|
-
throw new Error(`Agent gave empty response to: "${greeting}"`);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
console.log(`✓ Agent responded to: "${greeting}"`);
|
|
152
|
-
}
|
|
153
|
-
} catch (error) {
|
|
154
|
-
throw new Error(`Casual greeting test failed: ${(error as Error).message}`);
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
{
|
|
160
|
-
name: 'Agent maintains conversation context',
|
|
161
|
-
fn: async (runtime: any) => {
|
|
162
|
-
/**
|
|
163
|
-
* Test that the agent remembers context from previous messages
|
|
164
|
-
* in the same conversation.
|
|
165
|
-
*/
|
|
166
|
-
try {
|
|
167
|
-
const roomId = `test-room-context-${Date.now()}`;
|
|
168
|
-
const userId = 'test-user-context';
|
|
169
|
-
|
|
170
|
-
// First message - introduce a topic
|
|
171
|
-
const firstMessage = {
|
|
172
|
-
id: `msg-1-${Date.now()}`,
|
|
173
|
-
userId: userId,
|
|
174
|
-
agentId: runtime.agentId,
|
|
175
|
-
roomId: roomId,
|
|
176
|
-
content: {
|
|
177
|
-
text: "My favorite color is blue. What's yours?",
|
|
178
|
-
type: 'text',
|
|
179
|
-
},
|
|
180
|
-
createdAt: Date.now(),
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
console.log('Sending first message about favorite color...');
|
|
184
|
-
await runtime.processMessage(firstMessage);
|
|
185
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
186
|
-
|
|
187
|
-
// Second message - reference the topic
|
|
188
|
-
const secondMessage = {
|
|
189
|
-
id: `msg-2-${Date.now()}`,
|
|
190
|
-
userId: userId,
|
|
191
|
-
agentId: runtime.agentId,
|
|
192
|
-
roomId: roomId,
|
|
193
|
-
content: {
|
|
194
|
-
text: 'Why did you choose that color?',
|
|
195
|
-
type: 'text',
|
|
196
|
-
},
|
|
197
|
-
createdAt: Date.now() + 1000,
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
console.log('Sending follow-up question...');
|
|
201
|
-
await runtime.processMessage(secondMessage);
|
|
202
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
203
|
-
|
|
204
|
-
// Get all messages
|
|
205
|
-
const messages = await runtime.messageManager.getMessages({
|
|
206
|
-
roomId,
|
|
207
|
-
limit: 10,
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
// Should have at least 4 messages (2 user + 2 agent)
|
|
211
|
-
if (messages.length < 4) {
|
|
212
|
-
throw new Error(`Expected at least 4 messages, got ${messages.length}`);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// Find the agent's second response
|
|
216
|
-
const agentResponses = messages.filter((m: any) => m.userId === runtime.agentId);
|
|
217
|
-
if (agentResponses.length < 2) {
|
|
218
|
-
throw new Error('Agent did not respond to both messages');
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// The second response should reference colors or the previous conversation
|
|
222
|
-
const secondResponse = agentResponses[agentResponses.length - 1];
|
|
223
|
-
const responseText = secondResponse.content.text.toLowerCase();
|
|
224
|
-
|
|
225
|
-
// Check if the response shows context awareness
|
|
226
|
-
const contextWords = ['color', 'blue', 'favorite', 'chose', 'choice', 'because'];
|
|
227
|
-
const hasContext = contextWords.some((word) => responseText.includes(word));
|
|
228
|
-
|
|
229
|
-
if (!hasContext) {
|
|
230
|
-
console.warn(
|
|
231
|
-
'Agent response may not show context awareness. ' +
|
|
232
|
-
`Response: "${secondResponse.content.text}"`
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
console.log('✓ Agent maintained conversation context');
|
|
237
|
-
} catch (error) {
|
|
238
|
-
throw new Error(`Context test failed: ${(error as Error).message}`);
|
|
239
|
-
}
|
|
240
|
-
},
|
|
241
|
-
},
|
|
242
|
-
];
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// Export a default instance for the test runner
|
|
246
|
-
export default new NaturalLanguageTestSuite();
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { type TestSuite } from '@elizaos/core';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Project E2E Test Suite
|
|
5
|
-
*
|
|
6
|
-
* This file demonstrates how to write end-to-end (E2E) tests for ElizaOS projects.
|
|
7
|
-
* E2E tests are run using the `elizaos test` command, which provides a REAL runtime
|
|
8
|
-
* environment with actual database, services, and plugin initialization.
|
|
9
|
-
*
|
|
10
|
-
* Key differences from unit tests:
|
|
11
|
-
* - E2E tests receive a fully initialized IAgentRuntime instance
|
|
12
|
-
* - The runtime has a real database (in-memory PGLite for testing)
|
|
13
|
-
* - All plugins and services are actually initialized and running
|
|
14
|
-
* - You can test real agent interactions and behaviors
|
|
15
|
-
*
|
|
16
|
-
* HOW TO ADD NEW E2E TESTS:
|
|
17
|
-
* 1. Add a new test object to the `tests` array below
|
|
18
|
-
* 2. Each test should have a descriptive `name` and async `fn` function
|
|
19
|
-
* 3. The test function receives a real runtime instance as its parameter
|
|
20
|
-
* 4. Use the runtime to simulate real agent interactions
|
|
21
|
-
* 5. Throw an error if the test fails (assertions that fail should throw)
|
|
22
|
-
*
|
|
23
|
-
* IMPORTANT: These tests run in a real environment, so:
|
|
24
|
-
* - Don't use mocks or stubs - everything is real
|
|
25
|
-
* - Tests may be slower than unit tests due to real operations
|
|
26
|
-
* - Each test should be independent and not rely on previous test state
|
|
27
|
-
*/
|
|
28
|
-
export class ProjectTestSuite implements TestSuite {
|
|
29
|
-
name = 'project';
|
|
30
|
-
description = 'E2E tests for project-specific features';
|
|
31
|
-
|
|
32
|
-
tests = [
|
|
33
|
-
{
|
|
34
|
-
name: 'Project runtime environment test',
|
|
35
|
-
fn: async (runtime: any) => {
|
|
36
|
-
/**
|
|
37
|
-
* This test verifies that the project's runtime environment is set up correctly.
|
|
38
|
-
* It's a basic smoke test to ensure the character and core systems are loaded.
|
|
39
|
-
*/
|
|
40
|
-
try {
|
|
41
|
-
// Verify character is loaded
|
|
42
|
-
if (!runtime.character) {
|
|
43
|
-
throw new Error('Character not loaded in runtime');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Verify expected character properties
|
|
47
|
-
const character = runtime.character;
|
|
48
|
-
if (!character.name) {
|
|
49
|
-
throw new Error('Character name is missing');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Verify the character has the expected name
|
|
53
|
-
if (character.name !== 'Eliza') {
|
|
54
|
-
throw new Error(`Expected character name 'Eliza', got '${character.name}'`);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Verify character has required configuration
|
|
58
|
-
if (!character.system) {
|
|
59
|
-
throw new Error('Character system prompt is missing');
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (!Array.isArray(character.bio)) {
|
|
63
|
-
throw new Error('Character bio should be an array');
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (!Array.isArray(character.messageExamples)) {
|
|
67
|
-
throw new Error('Character message examples should be an array');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Verify plugins are loaded (if specified in character)
|
|
71
|
-
if (character.plugins && !Array.isArray(character.plugins)) {
|
|
72
|
-
throw new Error('Character plugins should be an array');
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Test passed - no need to return anything
|
|
76
|
-
// The test framework considers it successful if no error is thrown
|
|
77
|
-
} catch (error) {
|
|
78
|
-
// Re-throw with more context for debugging
|
|
79
|
-
throw new Error(`Project runtime environment test failed: ${(error as Error).message}`);
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Example: How to add a new test that checks if services are initialized
|
|
86
|
-
* Uncomment and modify this template for your own tests
|
|
87
|
-
*/
|
|
88
|
-
/*
|
|
89
|
-
{
|
|
90
|
-
name: 'Services initialization test',
|
|
91
|
-
fn: async (runtime: any) => {
|
|
92
|
-
// Example: Check if a specific service is available
|
|
93
|
-
const myService = runtime.getService('my-service-name');
|
|
94
|
-
if (!myService) {
|
|
95
|
-
throw new Error('Expected service not found');
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Example: Test service functionality
|
|
99
|
-
const result = await myService.doSomething();
|
|
100
|
-
if (!result) {
|
|
101
|
-
throw new Error('Service did not return expected result');
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
*/
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Example: How to test agent message processing
|
|
109
|
-
* This shows how to simulate a conversation with the agent
|
|
110
|
-
*/
|
|
111
|
-
/*
|
|
112
|
-
{
|
|
113
|
-
name: 'Agent conversation test',
|
|
114
|
-
fn: async (runtime: any) => {
|
|
115
|
-
// Create a test room/conversation
|
|
116
|
-
const roomId = `test-room-${Date.now()}`;
|
|
117
|
-
|
|
118
|
-
// Simulate sending a message to the agent
|
|
119
|
-
const userMessage = {
|
|
120
|
-
userId: 'test-user',
|
|
121
|
-
roomId: roomId,
|
|
122
|
-
content: { text: 'Hello agent!' },
|
|
123
|
-
// Add other required message properties
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
// Process the message through the runtime
|
|
127
|
-
await runtime.processMessage(userMessage);
|
|
128
|
-
|
|
129
|
-
// Retrieve messages from the conversation
|
|
130
|
-
const messages = await runtime.messageManager.getMessages({ roomId });
|
|
131
|
-
|
|
132
|
-
// Verify the agent responded
|
|
133
|
-
if (messages.length < 2) {
|
|
134
|
-
throw new Error('Agent did not respond to message');
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Check the agent's response
|
|
138
|
-
const agentResponse = messages.find(m => m.userId === runtime.agentId);
|
|
139
|
-
if (!agentResponse) {
|
|
140
|
-
throw new Error('Could not find agent response');
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Verify response content
|
|
144
|
-
if (!agentResponse.content.text.toLowerCase().includes('hello')) {
|
|
145
|
-
throw new Error('Agent response did not contain expected greeting');
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
*/
|
|
150
|
-
];
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Export a default instance of the test suite for the E2E test runner
|
|
154
|
-
// The test runner will automatically discover and run this suite
|
|
155
|
-
export default new ProjectTestSuite();
|