@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
|
@@ -95,7 +95,7 @@ const helloWorldAction: Action = {
|
|
|
95
95
|
success: true,
|
|
96
96
|
};
|
|
97
97
|
} catch (error) {
|
|
98
|
-
logger.error('Error in HELLO_WORLD action:'
|
|
98
|
+
logger.error({ error }, 'Error in HELLO_WORLD action:');
|
|
99
99
|
|
|
100
100
|
return {
|
|
101
101
|
text: 'Failed to send hello world greeting',
|
|
@@ -248,28 +248,28 @@ const plugin: Plugin = {
|
|
|
248
248
|
async (params) => {
|
|
249
249
|
logger.info('MESSAGE_RECEIVED event received');
|
|
250
250
|
// print the keys
|
|
251
|
-
logger.info(Object.keys(params));
|
|
251
|
+
logger.info({ keys: Object.keys(params) }, 'MESSAGE_RECEIVED param keys');
|
|
252
252
|
},
|
|
253
253
|
],
|
|
254
254
|
VOICE_MESSAGE_RECEIVED: [
|
|
255
255
|
async (params) => {
|
|
256
256
|
logger.info('VOICE_MESSAGE_RECEIVED event received');
|
|
257
257
|
// print the keys
|
|
258
|
-
logger.info(Object.keys(params));
|
|
258
|
+
logger.info({ keys: Object.keys(params) }, 'VOICE_MESSAGE_RECEIVED param keys');
|
|
259
259
|
},
|
|
260
260
|
],
|
|
261
261
|
WORLD_CONNECTED: [
|
|
262
262
|
async (params) => {
|
|
263
263
|
logger.info('WORLD_CONNECTED event received');
|
|
264
264
|
// print the keys
|
|
265
|
-
logger.info(Object.keys(params));
|
|
265
|
+
logger.info({ keys: Object.keys(params) }, 'WORLD_CONNECTED param keys');
|
|
266
266
|
},
|
|
267
267
|
],
|
|
268
268
|
WORLD_JOINED: [
|
|
269
269
|
async (params) => {
|
|
270
270
|
logger.info('WORLD_JOINED event received');
|
|
271
271
|
// print the keys
|
|
272
|
-
logger.info(Object.keys(params));
|
|
272
|
+
logger.info({ keys: Object.keys(params) }, 'WORLD_JOINED param keys');
|
|
273
273
|
},
|
|
274
274
|
],
|
|
275
275
|
},
|
|
@@ -104,17 +104,56 @@ project-tee-starter/
|
|
|
104
104
|
|
|
105
105
|
## 🧪 Testing
|
|
106
106
|
|
|
107
|
+
ElizaOS employs a dual testing strategy:
|
|
108
|
+
|
|
109
|
+
1. **Component Tests** (`src/__tests__/*.test.ts`)
|
|
110
|
+
|
|
111
|
+
- Run with Bun's native test runner
|
|
112
|
+
- Fast, isolated tests using mocks
|
|
113
|
+
- Perfect for TDD and component logic
|
|
114
|
+
|
|
115
|
+
2. **E2E Tests** (`src/__tests__/e2e/*.e2e.ts`)
|
|
116
|
+
- Run with ElizaOS custom test runner
|
|
117
|
+
- Real runtime with actual database (PGLite)
|
|
118
|
+
- Test complete user scenarios including TEE functionality
|
|
119
|
+
|
|
120
|
+
### Test Structure
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
src/
|
|
124
|
+
__tests__/ # All tests live inside src
|
|
125
|
+
*.test.ts # Component tests (use Bun test runner)
|
|
126
|
+
e2e/ # E2E tests (use ElizaOS test runner)
|
|
127
|
+
project-tee-starter.e2e.ts # E2E test suite with TEE-specific tests
|
|
128
|
+
README.md # E2E testing documentation
|
|
129
|
+
index.ts # Export tests here: tests: [ProjectTeeStarterTestSuite]
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Running Tests
|
|
133
|
+
|
|
107
134
|
```bash
|
|
108
|
-
# Run all tests
|
|
109
|
-
|
|
135
|
+
# Run all tests (component + e2e)
|
|
136
|
+
elizaos test
|
|
110
137
|
|
|
111
138
|
# Component tests only
|
|
112
|
-
|
|
139
|
+
elizaos test component
|
|
140
|
+
|
|
141
|
+
# E2E tests only
|
|
142
|
+
elizaos test e2e
|
|
113
143
|
|
|
114
|
-
# E2E tests
|
|
115
|
-
|
|
144
|
+
# With specific port for E2E tests
|
|
145
|
+
elizaos test --port 4000
|
|
116
146
|
```
|
|
117
147
|
|
|
148
|
+
### TEE-Specific Testing
|
|
149
|
+
|
|
150
|
+
The E2E tests include TEE-specific scenarios:
|
|
151
|
+
|
|
152
|
+
- TEE service availability checks
|
|
153
|
+
- Attestation action registration
|
|
154
|
+
- Secure memory operations
|
|
155
|
+
- Concurrent secure operations handling
|
|
156
|
+
|
|
118
157
|
## 🚀 Deployment
|
|
119
158
|
|
|
120
159
|
### Local Development
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"GUIDE.md"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@elizaos/cli": "1.
|
|
37
|
-
"@elizaos/core": "1.
|
|
38
|
-
"@elizaos/plugin-bootstrap": "1.
|
|
36
|
+
"@elizaos/cli": "1.4.2",
|
|
37
|
+
"@elizaos/core": "1.4.2",
|
|
38
|
+
"@elizaos/plugin-bootstrap": "1.4.2",
|
|
39
39
|
"@elizaos/plugin-redpill": "1.2.1",
|
|
40
|
-
"@elizaos/plugin-sql": "1.
|
|
40
|
+
"@elizaos/plugin-sql": "1.4.2",
|
|
41
41
|
"@phala/dstack-sdk": "0.1.11",
|
|
42
42
|
"@solana/web3.js": "1.98.2",
|
|
43
43
|
"@tanstack/react-query": "^5.29.0",
|
|
@@ -5,7 +5,7 @@ import { $ } from 'bun';
|
|
|
5
5
|
import { getViteOutDir } from './vite-config-utils';
|
|
6
6
|
|
|
7
7
|
describe('Build Order Integration Test', () => {
|
|
8
|
-
const rootDir = path.resolve(__dirname, '..');
|
|
8
|
+
const rootDir = path.resolve(__dirname, '..', '..');
|
|
9
9
|
const distDir = path.join(rootDir, 'dist');
|
|
10
10
|
let viteBuildDir: string;
|
|
11
11
|
const tsupBuildMarker = path.join(distDir, 'index.js'); // TSup creates this
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# E2E Tests for Project TEE Starter
|
|
2
|
+
|
|
3
|
+
This directory contains end-to-end tests for the ElizaOS project TEE (Trusted Execution Environment) starter template.
|
|
4
|
+
|
|
5
|
+
## ElizaOS Testing Philosophy
|
|
6
|
+
|
|
7
|
+
ElizaOS employs a dual testing strategy:
|
|
8
|
+
|
|
9
|
+
1. **Component Tests** (`src/__tests__/*.test.ts`)
|
|
10
|
+
|
|
11
|
+
- Run with Bun's native test runner
|
|
12
|
+
- Fast, isolated tests using mocks
|
|
13
|
+
- Perfect for TDD and component logic
|
|
14
|
+
- Command: `bun test`
|
|
15
|
+
|
|
16
|
+
2. **E2E Tests** (`src/__tests__/e2e/*.e2e.ts`)
|
|
17
|
+
- Run with ElizaOS custom test runner
|
|
18
|
+
- Real runtime with actual database (PGLite)
|
|
19
|
+
- Test complete user scenarios
|
|
20
|
+
- Command: `elizaos test --type e2e`
|
|
21
|
+
|
|
22
|
+
## Overview
|
|
23
|
+
|
|
24
|
+
E2E tests run in a real ElizaOS runtime environment, allowing you to test your TEE-enabled project's behavior as it would work in production. These tests include validation of TEE-specific functionality such as attestation, secure operations, and cryptographic features.
|
|
25
|
+
|
|
26
|
+
## Test Structure
|
|
27
|
+
|
|
28
|
+
- **ProjectTeeStarterTestSuite** - Main test suite containing all e2e tests
|
|
29
|
+
- `tee_project_should_initialize_correctly` - Verifies TEE project and runtime initialization
|
|
30
|
+
- `tee_character_should_be_loaded_correctly` - Checks character configuration including TEE settings
|
|
31
|
+
- `tee_service_should_be_available` - Tests TEE service registration and availability
|
|
32
|
+
- `tee_attestation_action_should_be_registered` - Validates TEE-specific actions
|
|
33
|
+
- `agent_should_respond_with_tee_awareness` - Tests agent's understanding of TEE capabilities
|
|
34
|
+
- `secure_memory_operations_should_work` - Validates secure data handling
|
|
35
|
+
- `tee_plugin_integration_should_work` - Tests TEE plugin integration
|
|
36
|
+
- `concurrent_secure_operations_should_be_handled` - Tests concurrent secure operations
|
|
37
|
+
- `tee_configuration_should_be_valid` - Validates TEE-specific configuration
|
|
38
|
+
|
|
39
|
+
## Integration with Project
|
|
40
|
+
|
|
41
|
+
E2E tests are integrated directly into your project through the main index.ts file:
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
// src/index.ts
|
|
45
|
+
import { ProjectTeeStarterTestSuite } from './__tests__/e2e/project-tee-starter.e2e';
|
|
46
|
+
|
|
47
|
+
export const project: Project = {
|
|
48
|
+
agents: [projectAgent],
|
|
49
|
+
tests: [ProjectTeeStarterTestSuite], // Direct import!
|
|
50
|
+
};
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Running Tests
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Run all tests (component + e2e)
|
|
57
|
+
elizaos test
|
|
58
|
+
|
|
59
|
+
# Run only e2e tests (slower, full integration)
|
|
60
|
+
elizaos test --type e2e
|
|
61
|
+
|
|
62
|
+
# Run only component tests (fast, for TDD)
|
|
63
|
+
bun test
|
|
64
|
+
# or
|
|
65
|
+
elizaos test --type component
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## TEE-Specific Testing Considerations
|
|
69
|
+
|
|
70
|
+
### Development Environment
|
|
71
|
+
|
|
72
|
+
- TEE hardware features may not be available in development
|
|
73
|
+
- Tests gracefully handle missing TEE services with warnings
|
|
74
|
+
- Mock TEE services can be used for development testing
|
|
75
|
+
|
|
76
|
+
### Production Environment
|
|
77
|
+
|
|
78
|
+
- Full TEE capabilities should be available
|
|
79
|
+
- Attestation endpoints should be configured
|
|
80
|
+
- Secure key storage should be operational
|
|
81
|
+
|
|
82
|
+
### Configuration
|
|
83
|
+
|
|
84
|
+
TEE-specific environment variables:
|
|
85
|
+
|
|
86
|
+
- `TEE_MODE`: Enable/disable TEE mode
|
|
87
|
+
- `TEE_ATTESTATION_ENDPOINT`: Attestation service endpoint
|
|
88
|
+
- `TEE_PROVIDER`: TEE provider (e.g., 'phala', 'sgx')
|
|
89
|
+
|
|
90
|
+
## Implementation Details
|
|
91
|
+
|
|
92
|
+
1. **Direct Import**: Tests are imported directly from the e2e test file
|
|
93
|
+
2. **Project Integration**: The test suite is added to the project's `tests` array
|
|
94
|
+
3. **TEE Detection**: Tests detect and adapt to TEE availability
|
|
95
|
+
4. **Secure Operations**: Tests validate secure data handling and cryptographic operations
|
|
96
|
+
5. **Runtime Access**: Each test receives a real runtime instance with full access to:
|
|
97
|
+
- TEE services and attestation
|
|
98
|
+
- Secure memory operations
|
|
99
|
+
- Cryptographic functions
|
|
100
|
+
- All standard ElizaOS features
|
|
101
|
+
|
|
102
|
+
## Key Differences from Standard Project Tests
|
|
103
|
+
|
|
104
|
+
- **Export Location**: Tests are exported from the `ProjectAgent` in `src/index.ts` (not directly from `Project`)
|
|
105
|
+
- **TEE Service Testing**: Additional tests for TEE service availability
|
|
106
|
+
- **Attestation Validation**: Tests for attestation generation and verification
|
|
107
|
+
- **Secure Operations**: Validation of secure data handling
|
|
108
|
+
- **Hardware Adaptation**: Tests adapt to TEE hardware availability
|
|
109
|
+
- **Cryptographic Features**: Testing of signing and verification operations
|
|
110
|
+
|
|
111
|
+
## Writing New Tests
|
|
112
|
+
|
|
113
|
+
See the comprehensive documentation at the top of `project-tee-starter.e2e.ts` for detailed instructions on adding new tests.
|
|
114
|
+
|
|
115
|
+
## Best Practices
|
|
116
|
+
|
|
117
|
+
1. **Hardware Independence**: Write tests that work with or without TEE hardware
|
|
118
|
+
2. **Security Validation**: Test security features without exposing sensitive data
|
|
119
|
+
3. **Attestation Mocking**: Use mock attestation in development environments
|
|
120
|
+
4. **Error Handling**: Test both successful and failed secure operations
|
|
121
|
+
5. **Configuration Testing**: Validate all TEE-specific configuration options
|
|
122
|
+
|
|
123
|
+
## Known Considerations
|
|
124
|
+
|
|
125
|
+
- TEE features may require specific hardware or cloud environments
|
|
126
|
+
- Some cryptographic operations may be simulated in development
|
|
127
|
+
- Attestation verification requires connection to attestation services
|
|
128
|
+
- Performance characteristics may differ between TEE and non-TEE environments
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Content,
|
|
3
|
+
type HandlerCallback,
|
|
4
|
+
type IAgentRuntime,
|
|
5
|
+
type Memory,
|
|
6
|
+
type UUID,
|
|
7
|
+
ChannelType,
|
|
8
|
+
logger,
|
|
9
|
+
} from '@elizaos/core';
|
|
10
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* E2E Test Suite for Project TEE Starter
|
|
14
|
+
* ======================================
|
|
15
|
+
*
|
|
16
|
+
* This test suite validates TEE (Trusted Execution Environment) specific functionality
|
|
17
|
+
* while gracefully handling non-TEE environments where tests are expected to fail.
|
|
18
|
+
*
|
|
19
|
+
* TEST CATEGORIES:
|
|
20
|
+
* ---------------
|
|
21
|
+
* 1. ALWAYS PASS: Basic project setup tests that work in any environment
|
|
22
|
+
* 2. TEE-OPTIONAL: Tests that check for TEE features but pass with warnings if unavailable
|
|
23
|
+
* 3. TEE-REQUIRED: Tests that only pass in actual TEE environments (skip otherwise)
|
|
24
|
+
*
|
|
25
|
+
* ENVIRONMENT DETECTION:
|
|
26
|
+
* ---------------------
|
|
27
|
+
* Tests detect TEE availability by checking:
|
|
28
|
+
* - TEE service registration
|
|
29
|
+
* - TEE-specific environment variables
|
|
30
|
+
* - Embedding model availability
|
|
31
|
+
* - Database schema completeness
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
interface TestCase {
|
|
35
|
+
name: string;
|
|
36
|
+
category?: 'always-pass' | 'tee-optional' | 'tee-required';
|
|
37
|
+
fn: (runtime: IAgentRuntime) => Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export class ProjectTeeStarterTestSuite {
|
|
41
|
+
name = 'Project TEE Starter E2E Tests';
|
|
42
|
+
description = 'E2E tests for TEE-specific project features with graceful fallbacks';
|
|
43
|
+
|
|
44
|
+
// Helper to detect TEE environment
|
|
45
|
+
private async detectTeeEnvironment(runtime: IAgentRuntime): Promise<{
|
|
46
|
+
hasService: boolean;
|
|
47
|
+
hasEndpoint: boolean;
|
|
48
|
+
hasEmbeddings: boolean;
|
|
49
|
+
isFullTee: boolean;
|
|
50
|
+
}> {
|
|
51
|
+
const teeService = runtime.getService('tee') || runtime.getService('mr-tee-service');
|
|
52
|
+
const hasEndpoint = !!runtime.getSetting('TEE_ATTESTATION_ENDPOINT');
|
|
53
|
+
|
|
54
|
+
// Check for embedding capability
|
|
55
|
+
let hasEmbeddings = false;
|
|
56
|
+
try {
|
|
57
|
+
// Check if embedding model is available via service
|
|
58
|
+
const embeddingService = runtime.getService('embedding');
|
|
59
|
+
hasEmbeddings = !!embeddingService;
|
|
60
|
+
} catch {
|
|
61
|
+
hasEmbeddings = false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
hasService: !!teeService,
|
|
66
|
+
hasEndpoint,
|
|
67
|
+
hasEmbeddings,
|
|
68
|
+
isFullTee: !!teeService && hasEndpoint && hasEmbeddings,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
tests: TestCase[] = [
|
|
73
|
+
// ALWAYS PASS: Basic project validation
|
|
74
|
+
{
|
|
75
|
+
name: 'tee_project_should_initialize_correctly',
|
|
76
|
+
category: 'always-pass',
|
|
77
|
+
fn: async (runtime: IAgentRuntime) => {
|
|
78
|
+
if (!runtime.agentId) {
|
|
79
|
+
throw new Error('Agent ID is not set');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
logger.info(`✓ TEE Project initialized with agent ID: ${runtime.agentId}`);
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
{
|
|
87
|
+
name: 'tee_character_should_be_loaded_correctly',
|
|
88
|
+
category: 'always-pass',
|
|
89
|
+
fn: async (runtime: IAgentRuntime) => {
|
|
90
|
+
if (!runtime.character.name) {
|
|
91
|
+
throw new Error('Character name is not set');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (!runtime.character.bio || runtime.character.bio.length === 0) {
|
|
95
|
+
throw new Error('Character bio is not set');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
logger.info(`✓ TEE Character "${runtime.character.name}" loaded successfully`);
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
// TEE-OPTIONAL: Features that may or may not be available
|
|
103
|
+
{
|
|
104
|
+
name: 'tee_service_availability_check',
|
|
105
|
+
category: 'tee-optional',
|
|
106
|
+
fn: async (runtime: IAgentRuntime) => {
|
|
107
|
+
const env = await this.detectTeeEnvironment(runtime);
|
|
108
|
+
|
|
109
|
+
if (env.hasService) {
|
|
110
|
+
logger.info('✓ TEE service is available and registered');
|
|
111
|
+
} else {
|
|
112
|
+
logger.info('⚠ TEE service not available (expected in non-TEE environments)');
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// This test always passes - it's just informational
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
{
|
|
120
|
+
name: 'tee_configuration_check',
|
|
121
|
+
category: 'tee-optional',
|
|
122
|
+
fn: async (runtime: IAgentRuntime) => {
|
|
123
|
+
const env = await this.detectTeeEnvironment(runtime);
|
|
124
|
+
const plugins = runtime.character.plugins || [];
|
|
125
|
+
const teePlugins = plugins.filter(
|
|
126
|
+
(p) => p.toLowerCase().includes('tee') || p.toLowerCase().includes('attestation')
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
logger.info(`✓ Found ${teePlugins.length} TEE-related plugins: ${teePlugins.join(', ')}`);
|
|
130
|
+
logger.info(`✓ TEE mode configured: ${env.isFullTee ? 'FULL' : 'OFF'}`);
|
|
131
|
+
|
|
132
|
+
if (!env.hasEndpoint) {
|
|
133
|
+
logger.info('⚠ TEE_ATTESTATION_ENDPOINT not configured (expected in development)');
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
{
|
|
139
|
+
name: 'tee_plugin_integration_check',
|
|
140
|
+
category: 'tee-optional',
|
|
141
|
+
fn: async (runtime: IAgentRuntime) => {
|
|
142
|
+
const plugins = runtime.character.plugins || [];
|
|
143
|
+
const hasTeePlugin = plugins.some(
|
|
144
|
+
(p) => p.toLowerCase().includes('tee') || p === 'mr-tee-starter-plugin'
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
if (hasTeePlugin) {
|
|
148
|
+
logger.info('✓ TEE plugin is loaded in character configuration');
|
|
149
|
+
} else {
|
|
150
|
+
logger.info('⚠ No TEE plugin in character configuration');
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
// TEE-REQUIRED: Tests that only work in full TEE environments
|
|
156
|
+
{
|
|
157
|
+
name: 'secure_attestation_flow',
|
|
158
|
+
category: 'tee-required',
|
|
159
|
+
fn: async (runtime: IAgentRuntime) => {
|
|
160
|
+
const env = await this.detectTeeEnvironment(runtime);
|
|
161
|
+
|
|
162
|
+
if (!env.isFullTee) {
|
|
163
|
+
logger.info('⚠ Skipping attestation test (requires full TEE environment)');
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Test attestation action availability
|
|
168
|
+
const attestationAction = runtime.actions.find((a) =>
|
|
169
|
+
a.name.toLowerCase().includes('attest')
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
if (!attestationAction) {
|
|
173
|
+
throw new Error('Attestation action not found in TEE environment');
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
logger.info('✓ Attestation flow validated');
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
{
|
|
181
|
+
name: 'secure_memory_operations_with_embeddings',
|
|
182
|
+
category: 'tee-required',
|
|
183
|
+
fn: async (runtime: IAgentRuntime) => {
|
|
184
|
+
const env = await this.detectTeeEnvironment(runtime);
|
|
185
|
+
|
|
186
|
+
if (!env.hasEmbeddings) {
|
|
187
|
+
logger.info('⚠ Skipping embedding test (requires embedding model)');
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
try {
|
|
192
|
+
const testContent = 'Secure TEE test message';
|
|
193
|
+
|
|
194
|
+
// Create a test memory with content
|
|
195
|
+
const testMemory: Memory = {
|
|
196
|
+
id: uuidv4() as UUID,
|
|
197
|
+
entityId: uuidv4() as UUID,
|
|
198
|
+
agentId: runtime.agentId,
|
|
199
|
+
roomId: uuidv4() as UUID,
|
|
200
|
+
content: {
|
|
201
|
+
text: testContent,
|
|
202
|
+
action: null,
|
|
203
|
+
} as Content,
|
|
204
|
+
createdAt: Date.now(),
|
|
205
|
+
embedding: [], // Would be populated by embedding service
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
await runtime.createMemory(testMemory, 'messages', false);
|
|
209
|
+
logger.info('✓ Secure memory operations with embeddings working');
|
|
210
|
+
} catch (error) {
|
|
211
|
+
logger.info(`⚠ Embedding test failed: ${error.message}`);
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
|
|
216
|
+
{
|
|
217
|
+
name: 'tee_agent_message_processing',
|
|
218
|
+
category: 'tee-required',
|
|
219
|
+
fn: async (runtime: IAgentRuntime) => {
|
|
220
|
+
const env = await this.detectTeeEnvironment(runtime);
|
|
221
|
+
|
|
222
|
+
if (!env.isFullTee) {
|
|
223
|
+
logger.info('⚠ Skipping message processing test (requires full TEE environment)');
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
try {
|
|
228
|
+
const testMessage: Memory = {
|
|
229
|
+
id: uuidv4() as UUID,
|
|
230
|
+
entityId: uuidv4() as UUID,
|
|
231
|
+
agentId: runtime.agentId,
|
|
232
|
+
roomId: uuidv4() as UUID,
|
|
233
|
+
content: {
|
|
234
|
+
text: 'Test TEE secure message processing',
|
|
235
|
+
action: null,
|
|
236
|
+
} as Content,
|
|
237
|
+
createdAt: Date.now(),
|
|
238
|
+
embedding: [],
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
await runtime.createMemory(testMessage, 'messages', false);
|
|
242
|
+
logger.info('✓ TEE message processing completed');
|
|
243
|
+
} catch (error) {
|
|
244
|
+
logger.info(`⚠ Message processing test failed: ${error.message}`);
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
|
|
249
|
+
// Database connectivity test (handles schema differences)
|
|
250
|
+
{
|
|
251
|
+
name: 'database_connectivity_and_schema',
|
|
252
|
+
category: 'tee-optional',
|
|
253
|
+
fn: async (runtime: IAgentRuntime) => {
|
|
254
|
+
try {
|
|
255
|
+
// Try a simple query that should work regardless of schema
|
|
256
|
+
const testRoomId = uuidv4() as UUID;
|
|
257
|
+
const memories = await runtime.getMemories({
|
|
258
|
+
roomId: testRoomId,
|
|
259
|
+
count: 1,
|
|
260
|
+
tableName: 'messages',
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
logger.info('✓ Database connection is working');
|
|
264
|
+
} catch (error) {
|
|
265
|
+
// Check if it's a schema issue
|
|
266
|
+
if (error.message?.includes('embeddings.dim_384')) {
|
|
267
|
+
logger.info(
|
|
268
|
+
'⚠ Database schema missing embedding columns (expected without embedding model)'
|
|
269
|
+
);
|
|
270
|
+
} else {
|
|
271
|
+
logger.info(`⚠ Database test failed: ${error.message}`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
];
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Export the test suite for the test runner
|
|
280
|
+
export default new ProjectTeeStarterTestSuite();
|
|
@@ -4,7 +4,7 @@ import { describe, expect, it } from 'bun:test';
|
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
|
|
6
6
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
const projectRoot = path.resolve(__dirname, '..');
|
|
7
|
+
const projectRoot = path.resolve(__dirname, '..', '..');
|
|
8
8
|
|
|
9
9
|
describe('Environment Setup', () => {
|
|
10
10
|
it('should verify configuration files exist', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect } from 'bun:test';
|
|
2
|
-
import teeStarterPlugin from '../
|
|
3
|
-
import { mrTeeCharacter } from '../
|
|
2
|
+
import teeStarterPlugin from '../plugin';
|
|
3
|
+
import { mrTeeCharacter } from '../character';
|
|
4
4
|
|
|
5
5
|
describe('Error Handling', () => {
|
|
6
6
|
describe('Plugin Error Handling', () => {
|
|
@@ -15,7 +15,7 @@ function directoryExists(dirPath: string): boolean {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
describe('Project Structure Validation', () => {
|
|
18
|
-
const rootDir = path.resolve(__dirname, '..');
|
|
18
|
+
const rootDir = path.resolve(__dirname, '..', '..');
|
|
19
19
|
const distDir = path.join(rootDir, 'dist');
|
|
20
20
|
|
|
21
21
|
beforeAll(async () => {
|
|
@@ -29,7 +29,7 @@ describe('Project Structure Validation', () => {
|
|
|
29
29
|
describe('Directory Structure', () => {
|
|
30
30
|
it('should have the expected directory structure', () => {
|
|
31
31
|
expect(directoryExists(path.join(rootDir, 'src'))).toBe(true);
|
|
32
|
-
expect(directoryExists(path.join(rootDir, '__tests__'))).toBe(true);
|
|
32
|
+
expect(directoryExists(path.join(rootDir, 'src', '__tests__'))).toBe(true);
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
it('should have a dist directory after building', () => {
|
|
@@ -2,8 +2,8 @@ import { describe, expect, it, spyOn, beforeAll, afterAll } from 'bun:test';
|
|
|
2
2
|
import * as fs from 'node:fs';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
4
|
import { logger, IAgentRuntime, Plugin } from '@elizaos/core';
|
|
5
|
-
import { character } from '../
|
|
6
|
-
import plugin from '../
|
|
5
|
+
import { character } from '../index';
|
|
6
|
+
import plugin from '../plugin';
|
|
7
7
|
import { createMockRuntime } from './test-utils';
|
|
8
8
|
import * as os from 'node:os';
|
|
9
9
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from 'bun:test';
|
|
2
|
-
import teeStarterPlugin from '../
|
|
2
|
+
import teeStarterPlugin from '../plugin';
|
|
3
3
|
|
|
4
4
|
describe('Plugin Models', () => {
|
|
5
5
|
it('should not have custom models (using plugin-tee and other plugins for model handling)', () => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { describe, expect, it, spyOn, beforeAll, afterAll } from 'bun:test';
|
|
2
|
-
import plugin from '../
|
|
2
|
+
import plugin from '../plugin';
|
|
3
3
|
import type { IAgentRuntime, Memory, State, Provider } from '@elizaos/core';
|
|
4
4
|
import { logger } from '@elizaos/core';
|
|
5
5
|
import { v4 as uuidv4 } from 'uuid';
|
|
6
6
|
import dotenv from 'dotenv';
|
|
7
|
-
import teeStarterPlugin from '../
|
|
7
|
+
import teeStarterPlugin from '../plugin';
|
|
8
8
|
|
|
9
9
|
// Setup environment variables
|
|
10
10
|
dotenv.config();
|
|
@@ -10,7 +10,7 @@ const mockLogger = {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
// We'll test the validation logic by importing the plugin and testing its init method
|
|
13
|
-
import teeStarterPlugin from '../
|
|
13
|
+
import teeStarterPlugin from '../plugin';
|
|
14
14
|
|
|
15
15
|
// Mock runtime for testing
|
|
16
16
|
const mockRuntime = {} as IAgentRuntime;
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
documentTestResult,
|
|
8
8
|
runCoreActionTests,
|
|
9
9
|
} from './utils/core-test-utils';
|
|
10
|
-
import { mrTeeCharacter } from '../
|
|
11
|
-
import plugin from '../
|
|
10
|
+
import { mrTeeCharacter } from '../character';
|
|
11
|
+
import plugin from '../plugin';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Creates an enhanced mock runtime for testing that includes the project's
|