@elizaos/cli 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{chunk-2CUIHNPL.js → chunk-5GUS4CFO.js} +7 -2
- package/dist/{chunk-2ALAPQLV.js → chunk-E6XYTE3A.js} +296 -311
- package/dist/chunk-GXWWPFBO.js +39 -0
- package/dist/{chunk-I77ZRNYO.js → chunk-T2QDIXGU.js} +2 -2
- package/dist/commands/agent/actions/index.d.ts +5 -0
- package/dist/commands/agent/actions/index.js +2 -2
- package/dist/commands/agent/index.d.ts +2 -2
- package/dist/commands/agent/index.js +2 -2
- package/dist/commands/create/actions/index.js +3 -3
- package/dist/commands/create/index.js +4 -4
- package/dist/commands/shared/index.d.ts +11 -28
- package/dist/commands/shared/index.js +7 -3
- package/dist/index.js +541 -450
- package/dist/{registry-N626N4VG.js → registry-433S5F3Y.js} +2 -2
- package/dist/templates/plugin-quick-starter/.gitignore +66 -0
- package/dist/templates/plugin-quick-starter/.npmignore +5 -0
- package/dist/templates/plugin-quick-starter/package.json +11 -3
- package/dist/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +499 -146
- package/dist/templates/plugin-quick-starter/src/__tests__/test-utils.ts +316 -115
- package/dist/templates/plugin-quick-starter/src/plugin.ts +7 -13
- package/dist/templates/plugin-starter/.gitignore +66 -0
- package/dist/templates/plugin-starter/.npmignore +5 -0
- package/dist/templates/plugin-starter/README.md +1 -1
- package/dist/templates/plugin-starter/package.json +11 -3
- package/dist/templates/plugin-starter/src/__tests__/integration.test.ts +13 -13
- package/dist/templates/plugin-starter/src/__tests__/plugin.test.ts +556 -129
- package/dist/templates/plugin-starter/src/__tests__/test-utils.ts +347 -115
- package/dist/templates/plugin-starter/src/plugin.ts +18 -22
- package/dist/templates/project-starter/.gitignore +57 -0
- package/dist/templates/project-starter/.npmignore +11 -0
- package/dist/templates/project-starter/README.md +1 -1
- package/dist/templates/project-starter/package.json +4 -4
- package/dist/templates/project-starter/src/__tests__/env.test.ts +3 -1
- package/dist/templates/project-starter/src/__tests__/file-structure.test.ts +3 -2
- package/dist/templates/project-starter/src/__tests__/integration.test.ts +1 -1
- package/dist/templates/project-starter/tsup.config.ts +2 -1
- package/dist/templates/project-tee-starter/.dockerignore +64 -14
- package/dist/templates/project-tee-starter/.gitignore +57 -0
- package/dist/templates/project-tee-starter/.npmignore +6 -0
- package/dist/templates/project-tee-starter/Dockerfile +9 -5
- package/dist/templates/project-tee-starter/GUIDE.md +103 -42
- package/dist/templates/project-tee-starter/README.md +39 -19
- package/dist/templates/project-tee-starter/__tests__/build-order.test.ts +62 -0
- package/dist/templates/project-tee-starter/__tests__/character.test.ts +19 -17
- package/dist/templates/project-tee-starter/__tests__/config.test.ts +10 -3
- package/dist/templates/project-tee-starter/__tests__/env.test.ts +2 -1
- package/dist/templates/project-tee-starter/__tests__/file-structure.test.ts +14 -3
- package/dist/templates/project-tee-starter/__tests__/frontend.test.ts +459 -0
- package/dist/templates/project-tee-starter/__tests__/plugin.test.ts +4 -2
- package/dist/templates/project-tee-starter/__tests__/routes.test.ts +15 -6
- package/dist/templates/project-tee-starter/__tests__/tee-validation.test.ts +295 -0
- package/dist/templates/project-tee-starter/__tests__/vite-config-utils.ts +39 -0
- package/dist/templates/project-tee-starter/docker-compose.yaml +5 -2
- package/dist/templates/{plugin-starter/dist → project-tee-starter}/index.html +3 -3
- package/dist/templates/project-tee-starter/package.json +34 -14
- package/dist/templates/project-tee-starter/postcss.config.js +3 -0
- package/dist/templates/project-tee-starter/scripts/install-test-deps.js +52 -0
- package/dist/templates/project-tee-starter/scripts/test-all.sh +82 -0
- package/dist/templates/project-tee-starter/src/frontend/index.css +106 -0
- package/dist/templates/project-tee-starter/src/frontend/index.html +20 -0
- package/dist/templates/project-tee-starter/src/frontend/index.tsx +370 -0
- package/dist/templates/project-tee-starter/src/frontend/panels.tsx +17 -0
- package/dist/templates/project-tee-starter/src/frontend/utils.ts +6 -0
- package/dist/templates/project-tee-starter/src/index.ts +6 -6
- package/dist/templates/project-tee-starter/src/plugin.ts +209 -59
- package/dist/templates/project-tee-starter/tailwind.config.js +62 -0
- package/dist/templates/project-tee-starter/tsconfig.build.json +2 -2
- package/dist/templates/project-tee-starter/tsconfig.json +8 -5
- package/dist/templates/project-tee-starter/tsup.config.ts +3 -2
- package/dist/templates/project-tee-starter/vite.config.ts +39 -0
- package/dist/url-utils-CKc_Ebt_.d.ts +35 -0
- package/dist/{utils-H66532NB.js → utils-DBLSDYBF.js} +2 -2
- package/package.json +12 -7
- package/templates/plugin-quick-starter/.gitignore +66 -0
- package/templates/plugin-quick-starter/.npmignore +5 -0
- package/templates/plugin-quick-starter/package.json +11 -3
- package/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +499 -146
- package/templates/plugin-quick-starter/src/__tests__/test-utils.ts +316 -115
- package/templates/plugin-quick-starter/src/plugin.ts +7 -13
- package/templates/plugin-starter/.gitignore +66 -0
- package/templates/plugin-starter/.npmignore +5 -0
- package/templates/plugin-starter/README.md +1 -1
- package/templates/plugin-starter/package.json +11 -3
- package/templates/plugin-starter/src/__tests__/integration.test.ts +13 -13
- package/templates/plugin-starter/src/__tests__/plugin.test.ts +556 -129
- package/templates/plugin-starter/src/__tests__/test-utils.ts +347 -115
- package/templates/plugin-starter/src/plugin.ts +18 -22
- package/templates/project-starter/.gitignore +57 -0
- package/templates/project-starter/.npmignore +11 -0
- package/templates/project-starter/README.md +1 -1
- package/templates/project-starter/package.json +4 -4
- package/templates/project-starter/src/__tests__/env.test.ts +3 -1
- package/templates/project-starter/src/__tests__/file-structure.test.ts +3 -2
- package/templates/project-starter/src/__tests__/integration.test.ts +1 -1
- package/templates/project-starter/tsup.config.ts +2 -1
- package/templates/project-tee-starter/.dockerignore +64 -14
- package/templates/project-tee-starter/.gitignore +57 -0
- package/templates/project-tee-starter/.npmignore +6 -0
- package/templates/project-tee-starter/Dockerfile +9 -5
- package/templates/project-tee-starter/GUIDE.md +103 -42
- package/templates/project-tee-starter/README.md +39 -19
- package/templates/project-tee-starter/__tests__/build-order.test.ts +62 -0
- package/templates/project-tee-starter/__tests__/character.test.ts +19 -17
- package/templates/project-tee-starter/__tests__/config.test.ts +10 -3
- package/templates/project-tee-starter/__tests__/env.test.ts +2 -1
- package/templates/project-tee-starter/__tests__/file-structure.test.ts +14 -3
- package/templates/project-tee-starter/__tests__/frontend.test.ts +459 -0
- package/templates/project-tee-starter/__tests__/plugin.test.ts +4 -2
- package/templates/project-tee-starter/__tests__/routes.test.ts +15 -6
- package/templates/project-tee-starter/__tests__/tee-validation.test.ts +295 -0
- package/templates/project-tee-starter/__tests__/vite-config-utils.ts +39 -0
- package/templates/project-tee-starter/docker-compose.yaml +5 -2
- package/templates/{plugin-starter/dist → project-tee-starter}/index.html +3 -3
- package/templates/project-tee-starter/package.json +34 -14
- package/templates/project-tee-starter/postcss.config.js +3 -0
- package/templates/project-tee-starter/scripts/install-test-deps.js +52 -0
- package/templates/project-tee-starter/scripts/test-all.sh +82 -0
- package/templates/project-tee-starter/src/frontend/index.css +106 -0
- package/templates/project-tee-starter/src/frontend/index.html +20 -0
- package/templates/project-tee-starter/src/frontend/index.tsx +370 -0
- package/templates/project-tee-starter/src/frontend/panels.tsx +17 -0
- package/templates/project-tee-starter/src/frontend/utils.ts +6 -0
- package/templates/project-tee-starter/src/index.ts +6 -6
- package/templates/project-tee-starter/src/plugin.ts +209 -59
- package/templates/project-tee-starter/tailwind.config.js +62 -0
- package/templates/project-tee-starter/tsconfig.build.json +2 -2
- package/templates/project-tee-starter/tsconfig.json +8 -5
- package/templates/project-tee-starter/tsup.config.ts +3 -2
- package/templates/project-tee-starter/vite.config.ts +39 -0
- package/dist/chunk-4O6EZU37.js +0 -14
- package/dist/migration-guides/advanced-migration-guide.md +0 -459
- package/dist/migration-guides/completion-requirements.md +0 -379
- package/dist/migration-guides/integrated-migration-loop.md +0 -392
- package/dist/migration-guides/migration-guide.md +0 -712
- package/dist/migration-guides/prompt-and-generation-guide.md +0 -702
- package/dist/migration-guides/state-and-providers-guide.md +0 -544
- package/dist/migration-guides/testing-guide.md +0 -1021
- package/dist/templates/plugin-starter/dist/assets/index-CgkejLs_.css +0 -1
- package/dist/templates/plugin-starter/dist/assets/index-D1cHX53P.js +0 -49
- package/dist/templates/plugin-starter/dist/index.js +0 -387
- package/dist/templates/plugin-starter/dist/index.js.map +0 -1
- package/templates/plugin-starter/dist/.vite/manifest.json +0 -11
- package/templates/plugin-starter/dist/assets/index-CgkejLs_.css +0 -1
- package/templates/plugin-starter/dist/assets/index-D1cHX53P.js +0 -49
- package/templates/plugin-starter/dist/index.d.ts +0 -14
- package/templates/plugin-starter/dist/index.js +0 -387
- package/templates/plugin-starter/dist/index.js.map +0 -1
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { describe, test, expect, beforeEach, afterEach } from 'bun:test';
|
|
2
|
+
import { logger, type IAgentRuntime } from '@elizaos/core';
|
|
3
|
+
|
|
4
|
+
// Mock logger to avoid console noise during tests
|
|
5
|
+
const mockLogger = {
|
|
6
|
+
info: () => {},
|
|
7
|
+
warn: () => {},
|
|
8
|
+
error: () => {},
|
|
9
|
+
debug: () => {},
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// We'll test the validation logic by importing the plugin and testing its init method
|
|
13
|
+
import teeStarterPlugin from '../src/plugin';
|
|
14
|
+
|
|
15
|
+
// Mock runtime for testing
|
|
16
|
+
const mockRuntime = {} as IAgentRuntime;
|
|
17
|
+
|
|
18
|
+
describe('TEE Environment Validation', () => {
|
|
19
|
+
// Store original environment variables
|
|
20
|
+
const originalEnv = { ...process.env };
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
// Clear relevant environment variables for clean test state
|
|
24
|
+
delete process.env.TEE_MODE;
|
|
25
|
+
delete process.env.TEE_VENDOR;
|
|
26
|
+
delete process.env.WALLET_SECRET_SALT;
|
|
27
|
+
// Also clear NODE_ENV to avoid test environment defaults
|
|
28
|
+
delete process.env.NODE_ENV;
|
|
29
|
+
|
|
30
|
+
// Mock logger to avoid noise
|
|
31
|
+
Object.assign(logger, mockLogger);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
// Restore original environment
|
|
36
|
+
process.env = { ...originalEnv };
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe('TEE_MODE Case Sensitivity', () => {
|
|
40
|
+
test('should reject lowercase tee_mode values', async () => {
|
|
41
|
+
const lowercaseValues = ['off', 'local', 'docker', 'production'];
|
|
42
|
+
|
|
43
|
+
for (const value of lowercaseValues) {
|
|
44
|
+
// Set the invalid lowercase value
|
|
45
|
+
process.env.NODE_ENV = 'production'; // Avoid test defaults
|
|
46
|
+
process.env.TEE_MODE = value;
|
|
47
|
+
process.env.TEE_VENDOR = 'phala'; // Valid vendor
|
|
48
|
+
process.env.WALLET_SECRET_SALT = 'test_salt_123';
|
|
49
|
+
|
|
50
|
+
// Attempt to initialize plugin - should fail
|
|
51
|
+
await expect(async () => {
|
|
52
|
+
await teeStarterPlugin.init?.({}, mockRuntime);
|
|
53
|
+
}).toThrow(`TEE_MODE must be one of: OFF, LOCAL, DOCKER, PRODUCTION`);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('should accept uppercase TEE_MODE values', async () => {
|
|
58
|
+
const uppercaseValues = ['OFF', 'LOCAL', 'DOCKER', 'PRODUCTION'];
|
|
59
|
+
|
|
60
|
+
for (const value of uppercaseValues) {
|
|
61
|
+
// Set valid uppercase value
|
|
62
|
+
process.env.NODE_ENV = 'production'; // Avoid test defaults
|
|
63
|
+
process.env.TEE_MODE = value;
|
|
64
|
+
process.env.TEE_VENDOR = 'phala';
|
|
65
|
+
process.env.WALLET_SECRET_SALT = 'test_salt_123';
|
|
66
|
+
|
|
67
|
+
// Should not throw
|
|
68
|
+
let error = null;
|
|
69
|
+
try {
|
|
70
|
+
await teeStarterPlugin.init?.({}, mockRuntime);
|
|
71
|
+
} catch (e) {
|
|
72
|
+
error = e;
|
|
73
|
+
}
|
|
74
|
+
expect(error).toBeNull();
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('should provide helpful error message for common lowercase mistakes', async () => {
|
|
79
|
+
const testCases = [
|
|
80
|
+
{ input: 'off', expected: 'OFF' },
|
|
81
|
+
{ input: 'local', expected: 'LOCAL' },
|
|
82
|
+
{ input: 'docker', expected: 'DOCKER' },
|
|
83
|
+
{ input: 'production', expected: 'PRODUCTION' },
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
for (const { input, expected } of testCases) {
|
|
87
|
+
process.env.NODE_ENV = 'production'; // Avoid test defaults
|
|
88
|
+
process.env.TEE_MODE = input;
|
|
89
|
+
process.env.TEE_VENDOR = 'phala';
|
|
90
|
+
process.env.WALLET_SECRET_SALT = 'test_salt_123';
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
await teeStarterPlugin.init?.({}, mockRuntime);
|
|
94
|
+
expect.unreachable('Should have thrown validation error');
|
|
95
|
+
} catch (error) {
|
|
96
|
+
expect(error instanceof Error).toBe(true);
|
|
97
|
+
const errorMessage = (error as Error).message;
|
|
98
|
+
expect(errorMessage).toContain('TEE_MODE must be one of: OFF, LOCAL, DOCKER, PRODUCTION');
|
|
99
|
+
// The error should help users understand they need uppercase
|
|
100
|
+
expect(errorMessage).toMatch(/OFF|LOCAL|DOCKER|PRODUCTION/);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
describe('TEE_VENDOR Validation', () => {
|
|
107
|
+
test('should only accept "phala" as TEE_VENDOR', async () => {
|
|
108
|
+
const invalidVendors = ['intel', 'amd', 'arm', 'unknown', 'PHALA', 'Phala'];
|
|
109
|
+
|
|
110
|
+
for (const vendor of invalidVendors) {
|
|
111
|
+
process.env.NODE_ENV = 'production'; // Avoid test defaults
|
|
112
|
+
process.env.TEE_MODE = 'OFF';
|
|
113
|
+
process.env.TEE_VENDOR = vendor;
|
|
114
|
+
process.env.WALLET_SECRET_SALT = 'test_salt_123';
|
|
115
|
+
|
|
116
|
+
await expect(async () => {
|
|
117
|
+
await teeStarterPlugin.init?.({}, mockRuntime);
|
|
118
|
+
}).toThrow('TEE_VENDOR must be: phala');
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test('should accept "phala" as valid TEE_VENDOR', async () => {
|
|
123
|
+
process.env.NODE_ENV = 'production'; // Avoid test defaults
|
|
124
|
+
process.env.TEE_MODE = 'OFF';
|
|
125
|
+
process.env.TEE_VENDOR = 'phala';
|
|
126
|
+
process.env.WALLET_SECRET_SALT = 'test_salt_123';
|
|
127
|
+
|
|
128
|
+
let error = null;
|
|
129
|
+
try {
|
|
130
|
+
await teeStarterPlugin.init?.({}, mockRuntime);
|
|
131
|
+
} catch (e) {
|
|
132
|
+
error = e;
|
|
133
|
+
}
|
|
134
|
+
expect(error).toBeNull();
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe('WALLET_SECRET_SALT Validation', () => {
|
|
139
|
+
test('should require minimum salt length when explicitly provided', async () => {
|
|
140
|
+
// Note: Since we're in a test environment, we need to test the validation
|
|
141
|
+
// logic that happens before test defaults are applied
|
|
142
|
+
const shortSalts = ['short'];
|
|
143
|
+
|
|
144
|
+
for (const salt of shortSalts) {
|
|
145
|
+
// Remove argv test detection temporarily to test validation
|
|
146
|
+
const originalArgv = process.argv;
|
|
147
|
+
process.argv = ['node', 'script.js']; // Remove test from argv
|
|
148
|
+
|
|
149
|
+
process.env.NODE_ENV = 'production';
|
|
150
|
+
process.env.TEE_MODE = 'OFF';
|
|
151
|
+
process.env.TEE_VENDOR = 'phala';
|
|
152
|
+
process.env.WALLET_SECRET_SALT = salt;
|
|
153
|
+
|
|
154
|
+
try {
|
|
155
|
+
await expect(async () => {
|
|
156
|
+
await teeStarterPlugin.init?.({}, mockRuntime);
|
|
157
|
+
}).toThrow('Wallet secret salt must be at least 8 characters long for security');
|
|
158
|
+
} finally {
|
|
159
|
+
// Restore original argv
|
|
160
|
+
process.argv = originalArgv;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
test('should accept valid salt length', async () => {
|
|
166
|
+
// Make sure we're not in test environment
|
|
167
|
+
process.env.NODE_ENV = 'production';
|
|
168
|
+
process.env.TEE_MODE = 'OFF';
|
|
169
|
+
process.env.TEE_VENDOR = 'phala';
|
|
170
|
+
process.env.WALLET_SECRET_SALT = 'valid_salt_123';
|
|
171
|
+
|
|
172
|
+
let error = null;
|
|
173
|
+
try {
|
|
174
|
+
await teeStarterPlugin.init?.({}, mockRuntime);
|
|
175
|
+
} catch (e) {
|
|
176
|
+
error = e;
|
|
177
|
+
}
|
|
178
|
+
expect(error).toBeNull();
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test('should reject salt that is too long', async () => {
|
|
182
|
+
const longSalt = 'a'.repeat(129); // 129 characters (max is 128)
|
|
183
|
+
|
|
184
|
+
// Make sure we're not in test environment
|
|
185
|
+
process.env.NODE_ENV = 'production';
|
|
186
|
+
process.env.TEE_MODE = 'OFF';
|
|
187
|
+
process.env.TEE_VENDOR = 'phala';
|
|
188
|
+
process.env.WALLET_SECRET_SALT = longSalt;
|
|
189
|
+
|
|
190
|
+
await expect(async () => {
|
|
191
|
+
await teeStarterPlugin.init?.({}, mockRuntime);
|
|
192
|
+
}).toThrow('Wallet secret salt must not exceed 128 characters');
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
describe('Test Environment Defaults', () => {
|
|
197
|
+
test('should provide defaults in test environment when NODE_ENV=test', async () => {
|
|
198
|
+
// Set test environment
|
|
199
|
+
process.env.NODE_ENV = 'test';
|
|
200
|
+
|
|
201
|
+
// Don't set any TEE environment variables
|
|
202
|
+
delete process.env.TEE_MODE;
|
|
203
|
+
delete process.env.TEE_VENDOR;
|
|
204
|
+
delete process.env.WALLET_SECRET_SALT;
|
|
205
|
+
|
|
206
|
+
// Should not throw - test environment provides defaults
|
|
207
|
+
let error = null;
|
|
208
|
+
try {
|
|
209
|
+
await teeStarterPlugin.init?.({}, mockRuntime);
|
|
210
|
+
} catch (e) {
|
|
211
|
+
error = e;
|
|
212
|
+
}
|
|
213
|
+
expect(error).toBeNull();
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
test('should use provided values over defaults even in test environment', async () => {
|
|
217
|
+
process.env.NODE_ENV = 'test';
|
|
218
|
+
process.env.TEE_MODE = 'PRODUCTION';
|
|
219
|
+
process.env.TEE_VENDOR = 'phala';
|
|
220
|
+
process.env.WALLET_SECRET_SALT = 'explicit_test_salt_123';
|
|
221
|
+
|
|
222
|
+
// Should not throw and should use the explicit values
|
|
223
|
+
let error = null;
|
|
224
|
+
try {
|
|
225
|
+
await teeStarterPlugin.init?.({}, mockRuntime);
|
|
226
|
+
} catch (e) {
|
|
227
|
+
error = e;
|
|
228
|
+
}
|
|
229
|
+
expect(error).toBeNull();
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
describe('Edge Cases', () => {
|
|
234
|
+
test('should handle undefined environment variables gracefully in test mode', async () => {
|
|
235
|
+
// Set test environment to get defaults
|
|
236
|
+
process.env.NODE_ENV = 'test';
|
|
237
|
+
|
|
238
|
+
// Explicitly set to undefined (simulating missing env vars)
|
|
239
|
+
process.env.TEE_MODE = undefined as any;
|
|
240
|
+
process.env.TEE_VENDOR = undefined as any;
|
|
241
|
+
process.env.WALLET_SECRET_SALT = undefined as any;
|
|
242
|
+
|
|
243
|
+
// Should use defaults and not throw in test environment
|
|
244
|
+
let error = null;
|
|
245
|
+
try {
|
|
246
|
+
await teeStarterPlugin.init?.({}, mockRuntime);
|
|
247
|
+
} catch (e) {
|
|
248
|
+
error = e;
|
|
249
|
+
}
|
|
250
|
+
expect(error).toBeNull();
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
test('should treat empty string environment variables as falsy and apply defaults in test mode', async () => {
|
|
254
|
+
// In test environment, empty strings are treated as falsy and defaults are applied
|
|
255
|
+
process.env.NODE_ENV = 'test';
|
|
256
|
+
process.env.TEE_MODE = ''; // Empty string is falsy, will use default 'OFF'
|
|
257
|
+
process.env.TEE_VENDOR = ''; // Empty string is falsy, will use default 'phala'
|
|
258
|
+
process.env.WALLET_SECRET_SALT = ''; // Empty string is falsy, will use default test salt
|
|
259
|
+
|
|
260
|
+
// Should NOT throw because defaults are applied for falsy values in test mode
|
|
261
|
+
let error = null;
|
|
262
|
+
try {
|
|
263
|
+
await teeStarterPlugin.init?.({}, mockRuntime);
|
|
264
|
+
} catch (e) {
|
|
265
|
+
error = e;
|
|
266
|
+
}
|
|
267
|
+
expect(error).toBeNull();
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
test('should handle whitespace in environment variables', async () => {
|
|
271
|
+
// Remove test detection to ensure whitespace validation is tested
|
|
272
|
+
const originalArgv = process.argv;
|
|
273
|
+
const originalExpect = (global as any).expect;
|
|
274
|
+
|
|
275
|
+
try {
|
|
276
|
+
process.argv = ['node', 'script.js']; // Remove test from argv
|
|
277
|
+
delete (global as any).expect; // Remove expect global
|
|
278
|
+
|
|
279
|
+
process.env.NODE_ENV = 'production';
|
|
280
|
+
process.env.TEE_MODE = ' OFF '; // Whitespace around valid value
|
|
281
|
+
process.env.TEE_VENDOR = ' phala '; // Whitespace around valid value
|
|
282
|
+
process.env.WALLET_SECRET_SALT = ' test_salt_123 '; // Whitespace around valid value
|
|
283
|
+
|
|
284
|
+
// Whitespace should cause validation failure (no auto-trim)
|
|
285
|
+
await expect(async () => {
|
|
286
|
+
await teeStarterPlugin.init?.({}, mockRuntime);
|
|
287
|
+
}).toThrow();
|
|
288
|
+
} finally {
|
|
289
|
+
// Restore original values
|
|
290
|
+
process.argv = originalArgv;
|
|
291
|
+
(global as any).expect = originalExpect;
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Extracts the Vite output directory from vite.config.ts
|
|
6
|
+
*/
|
|
7
|
+
export async function getViteOutDir(rootDir: string): Promise<string> {
|
|
8
|
+
const viteConfigPath = path.join(rootDir, 'vite.config.ts');
|
|
9
|
+
const configContent = await fs.promises.readFile(viteConfigPath, 'utf-8');
|
|
10
|
+
|
|
11
|
+
// Extract the outDir value using regex
|
|
12
|
+
const outDirMatch = configContent.match(/outDir\s*:\s*['"`]([^'"`]+)['"`]/);
|
|
13
|
+
if (!outDirMatch) {
|
|
14
|
+
throw new Error('Could not find outDir in vite.config.ts');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let outDir = outDirMatch[1];
|
|
18
|
+
|
|
19
|
+
// Handle variable references like ${outDir}
|
|
20
|
+
if (outDir.includes('${')) {
|
|
21
|
+
// Look for the variable definition
|
|
22
|
+
const varMatch = configContent.match(/const\s+outDir\s*=\s*['"`]([^'"`]+)['"`]/);
|
|
23
|
+
if (varMatch) {
|
|
24
|
+
outDir = outDir.replace('${outDir}', varMatch[1]);
|
|
25
|
+
} else {
|
|
26
|
+
// Default fallback
|
|
27
|
+
outDir = 'dist/.vite';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// The outDir in vite.config.ts is relative to the root option (src/frontend)
|
|
32
|
+
// We need to normalize it to be relative to the project root
|
|
33
|
+
if (outDir.startsWith('../../')) {
|
|
34
|
+
// Convert ../../dist/frontend to dist/frontend
|
|
35
|
+
outDir = outDir.replace('../../', '');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return outDir;
|
|
39
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
version: '3'
|
|
1
|
+
version: '3.8'
|
|
2
2
|
services:
|
|
3
3
|
postgres:
|
|
4
4
|
image: ankane/pgvector:latest
|
|
@@ -22,9 +22,9 @@ services:
|
|
|
22
22
|
elizaos:
|
|
23
23
|
image: ${DOCKER_IMAGE}
|
|
24
24
|
container_name: elizaos
|
|
25
|
-
command: sh -c "bun run start"
|
|
26
25
|
volumes:
|
|
27
26
|
- /var/run/tappd.sock:/var/run/tappd.sock
|
|
27
|
+
- /var/run/dstack.sock:/var/run/dstack.sock
|
|
28
28
|
environment:
|
|
29
29
|
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
|
30
30
|
- SERVER_PORT=${SERVER_PORT}
|
|
@@ -39,6 +39,9 @@ services:
|
|
|
39
39
|
- REDPILL_API_KEY=${REDPILL_API_KEY}
|
|
40
40
|
- ELEVENLABS_API_KEY=${ELEVENLABS_API_KEY}
|
|
41
41
|
- ELEVENLABS_VOICE_ID=${ELEVENLABS_VOICE_ID}
|
|
42
|
+
- ELIZA_UI_ENABLE=${ELIZA_UI_ENABLE:-true}
|
|
43
|
+
- NODE_ENV=${NODE_ENV:-production}
|
|
44
|
+
- LOG_LEVEL=${LOG_LEVEL:-info}
|
|
42
45
|
ports:
|
|
43
46
|
- '3000:3000'
|
|
44
47
|
- '50000-50100:50000-50100/udp'
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>Agent Plugin View</title>
|
|
8
|
-
<script type="module" crossorigin src="./assets/index-D1cHX53P.js"></script>
|
|
9
|
-
<link rel="stylesheet" crossorigin href="./assets/index-CgkejLs_.css">
|
|
7
|
+
<title>Mr. TEE Agent Plugin View</title>
|
|
10
8
|
</head>
|
|
9
|
+
|
|
11
10
|
<body>
|
|
12
11
|
<div id="root"></div>
|
|
12
|
+
<script type="module" src="/src/frontend/index.tsx"></script>
|
|
13
13
|
</body>
|
|
14
14
|
</html>
|
|
@@ -33,31 +33,51 @@
|
|
|
33
33
|
"GUIDE.md"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@elizaos/cli": "1.3.
|
|
37
|
-
"@elizaos/core": "1.3.
|
|
38
|
-
"@elizaos/plugin-
|
|
39
|
-
"@elizaos/plugin-
|
|
36
|
+
"@elizaos/cli": "1.3.2",
|
|
37
|
+
"@elizaos/core": "1.3.2",
|
|
38
|
+
"@elizaos/plugin-bootstrap": "1.3.2",
|
|
39
|
+
"@elizaos/plugin-redpill": "1.2.1",
|
|
40
|
+
"@elizaos/plugin-sql": "1.3.2",
|
|
40
41
|
"@phala/dstack-sdk": "0.1.11",
|
|
41
42
|
"@solana/web3.js": "1.98.2",
|
|
43
|
+
"@tanstack/react-query": "^5.29.0",
|
|
44
|
+
"clsx": "^2.1.1",
|
|
45
|
+
"react": "^18.3.1",
|
|
46
|
+
"react-dom": "^18.3.1",
|
|
47
|
+
"tailwind-merge": "^2.6.0",
|
|
48
|
+
"tailwindcss": "^4.1.10",
|
|
42
49
|
"viem": "2.30.1",
|
|
43
50
|
"zod": "3.24.2"
|
|
44
51
|
},
|
|
45
52
|
"devDependencies": {
|
|
53
|
+
"@types/jsdom": "^21.1.7",
|
|
54
|
+
"@types/node": "^24.1.0",
|
|
55
|
+
"@types/react": "^18.3.3",
|
|
56
|
+
"@types/react-dom": "^18.3.0",
|
|
57
|
+
"@vitejs/plugin-react": "^4.3.1",
|
|
58
|
+
"jsdom": "^26.1.0",
|
|
46
59
|
"prettier": "3.5.3",
|
|
47
|
-
"tsup": "8.5.0"
|
|
60
|
+
"tsup": "8.5.0",
|
|
61
|
+
"typescript": "^5.6.3",
|
|
62
|
+
"vite": "^6.0.1"
|
|
48
63
|
},
|
|
49
64
|
"scripts": {
|
|
50
65
|
"start": "elizaos start",
|
|
51
66
|
"dev": "elizaos dev",
|
|
52
|
-
"build": "tsup",
|
|
53
|
-
"lint": "prettier --write ./src
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"test": "bun run test:
|
|
57
|
-
"test:
|
|
58
|
-
"test:
|
|
59
|
-
"
|
|
60
|
-
"
|
|
67
|
+
"build": "tsc --noEmit && vite build && tsup",
|
|
68
|
+
"lint": "prettier --write ./src",
|
|
69
|
+
"type-check": "tsc --noEmit",
|
|
70
|
+
"type-check:watch": "tsc --noEmit --watch",
|
|
71
|
+
"test:component": "bun run test:install && bun test",
|
|
72
|
+
"test:e2e": "bun run test:install && bun test __tests__/integration.test.ts",
|
|
73
|
+
"test:frontend": "bun run test:install && bun test __tests__/frontend.test.ts",
|
|
74
|
+
"test": "bun run test:install && bun run test:component && bun run test:e2e && bun run test:frontend",
|
|
75
|
+
"test:coverage": "bun run test:install && bun test --coverage",
|
|
76
|
+
"test:watch": "bun run test:install && bun test --watch",
|
|
77
|
+
"test:install": "node scripts/install-test-deps.js",
|
|
78
|
+
"format": "prettier --write ./src",
|
|
79
|
+
"format:check": "prettier --check ./src",
|
|
80
|
+
"check-all": "bun run type-check && bun run format:check && bun run test"
|
|
61
81
|
},
|
|
62
82
|
"publishConfig": {
|
|
63
83
|
"access": "public"
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
import { existsSync, readFileSync } from 'fs';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
|
|
6
|
+
const testDependencies = {
|
|
7
|
+
// Cypress dependencies removed - using bun test instead
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
function isInstalled(packageName) {
|
|
11
|
+
try {
|
|
12
|
+
const packageJsonPath = join(process.cwd(), 'package.json');
|
|
13
|
+
if (existsSync(packageJsonPath)) {
|
|
14
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
15
|
+
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
16
|
+
return packageName in deps;
|
|
17
|
+
}
|
|
18
|
+
} catch (error) {
|
|
19
|
+
// Silent fail, will install if error
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function installTestDependencies() {
|
|
25
|
+
const missingDeps = Object.entries(testDependencies)
|
|
26
|
+
.filter(([name]) => !isInstalled(name))
|
|
27
|
+
.map(([name, version]) => `${name}@${version}`);
|
|
28
|
+
|
|
29
|
+
if (missingDeps.length === 0) {
|
|
30
|
+
console.log('✓ Test dependencies already installed');
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
console.log('Installing test dependencies...');
|
|
35
|
+
try {
|
|
36
|
+
const proc = Bun.spawnSync(['bun', 'add', '-d', ...missingDeps], {
|
|
37
|
+
stdout: 'inherit',
|
|
38
|
+
stderr: 'inherit',
|
|
39
|
+
cwd: process.cwd(),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (proc.exitCode !== 0) {
|
|
43
|
+
throw new Error('bun add command failed');
|
|
44
|
+
}
|
|
45
|
+
console.log('✓ Test dependencies installed successfully');
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error('Failed to install test dependencies:', error.message);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
installTestDependencies();
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Exit on error
|
|
4
|
+
set -e
|
|
5
|
+
|
|
6
|
+
# Colors for output
|
|
7
|
+
GREEN='\033[0;32m'
|
|
8
|
+
RED='\033[0;31m'
|
|
9
|
+
BLUE='\033[0;34m'
|
|
10
|
+
NC='\033[0m' # No Color
|
|
11
|
+
|
|
12
|
+
echo -e "${BLUE}Starting comprehensive test suite for project-tee-starter...${NC}"
|
|
13
|
+
|
|
14
|
+
# Function to run tests and capture results
|
|
15
|
+
run_test() {
|
|
16
|
+
local test_name=$1
|
|
17
|
+
local test_command=$2
|
|
18
|
+
|
|
19
|
+
echo -e "\n${BLUE}Running ${test_name}...${NC}"
|
|
20
|
+
|
|
21
|
+
if eval "$test_command"; then
|
|
22
|
+
echo -e "${GREEN}✓ ${test_name} passed${NC}"
|
|
23
|
+
return 0
|
|
24
|
+
else
|
|
25
|
+
echo -e "${RED}✗ ${test_name} failed${NC}"
|
|
26
|
+
return 1
|
|
27
|
+
fi
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
# Track overall success
|
|
31
|
+
all_passed=true
|
|
32
|
+
|
|
33
|
+
# 1. Type checking
|
|
34
|
+
if ! run_test "TypeScript type checking" "bun run type-check"; then
|
|
35
|
+
all_passed=false
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
# 2. Build test
|
|
39
|
+
if ! run_test "Build process" "bun run build"; then
|
|
40
|
+
all_passed=false
|
|
41
|
+
echo -e "${RED}Build failed, skipping further tests${NC}"
|
|
42
|
+
exit 1
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
# 3. Unit tests
|
|
46
|
+
if ! run_test "Unit tests" "bun test"; then
|
|
47
|
+
all_passed=false
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
# 4. E2E tests (if server is running)
|
|
51
|
+
if lsof -Pi :3000 -sTCP:LISTEN -t >/dev/null; then
|
|
52
|
+
if ! run_test "E2E tests" "elizaos test e2e"; then
|
|
53
|
+
all_passed=false
|
|
54
|
+
fi
|
|
55
|
+
else
|
|
56
|
+
echo -e "${BLUE}Skipping E2E tests (server not running on port 3000)${NC}"
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
# 5. Component tests with bun test
|
|
60
|
+
if ! run_test "Component tests" "bun test __tests__/frontend.test.ts"; then
|
|
61
|
+
all_passed=false
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
# 6. Build validation
|
|
65
|
+
if ! run_test "Build output validation" "test -f dist/src/index.js && test -f dist/index.d.ts"; then
|
|
66
|
+
all_passed=false
|
|
67
|
+
fi
|
|
68
|
+
|
|
69
|
+
# 7. Frontend build validation
|
|
70
|
+
if ! run_test "Frontend build validation" "test -f dist/frontend/index.html"; then
|
|
71
|
+
all_passed=false
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
# Final report
|
|
75
|
+
echo -e "\n${BLUE}========================================${NC}"
|
|
76
|
+
if [ "$all_passed" = true ]; then
|
|
77
|
+
echo -e "${GREEN}All tests passed! 🎉${NC}"
|
|
78
|
+
exit 0
|
|
79
|
+
else
|
|
80
|
+
echo -e "${RED}Some tests failed. Please review the output above.${NC}"
|
|
81
|
+
exit 1
|
|
82
|
+
fi
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
@import 'tailwindcss';
|
|
2
|
+
@config "../../tailwind.config.js";
|
|
3
|
+
|
|
4
|
+
@layer base {
|
|
5
|
+
:root {
|
|
6
|
+
--background: 0 0% 97.65%;
|
|
7
|
+
--foreground: 0 0% 12.55%;
|
|
8
|
+
--muted: 0 0% 93.73%;
|
|
9
|
+
--muted-foreground: 0 0% 39.22%;
|
|
10
|
+
--popover: 0 0% 98.82%;
|
|
11
|
+
--popover-foreground: 0 0% 12.55%;
|
|
12
|
+
--card: 0 0% 98.82%;
|
|
13
|
+
--card-foreground: 0 0% 12.55%;
|
|
14
|
+
--border: 0 0% 84.71%;
|
|
15
|
+
--input: 0 0% 94.12%;
|
|
16
|
+
--primary: 22.93 92.59% 52.35%;
|
|
17
|
+
--primary-foreground: 44 0% 100%;
|
|
18
|
+
--secondary: 34.05 100% 85.49%;
|
|
19
|
+
--secondary-foreground: 16.27 50.43% 22.94%;
|
|
20
|
+
--accent: 0 0% 90.98%;
|
|
21
|
+
--accent-foreground: 0 0% 12.55%;
|
|
22
|
+
--destructive: 10.16 77.87% 53.92%;
|
|
23
|
+
--destructive-foreground: 0 0% 100%;
|
|
24
|
+
--ring: 24.8 79.79% 63.14%;
|
|
25
|
+
--chart-1: 22.93 92.59% 52.35%;
|
|
26
|
+
--chart-2: 34.05 100% 85.49%;
|
|
27
|
+
--chart-3: 0 0% 90.98%;
|
|
28
|
+
--chart-4: 34.05 100% 88.49%;
|
|
29
|
+
--chart-5: 22.93 95.59% 52.35%;
|
|
30
|
+
--radius: 0.5rem;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.dark {
|
|
34
|
+
--background: 0 0% 6.67%;
|
|
35
|
+
--foreground: 0 0% 93.33%;
|
|
36
|
+
--muted: 0 0% 13.33%;
|
|
37
|
+
--muted-foreground: 0 0% 70.59%;
|
|
38
|
+
--popover: 0 0% 9.8%;
|
|
39
|
+
--popover-foreground: 0 0% 93.33%;
|
|
40
|
+
--card: 0 0% 9.8%;
|
|
41
|
+
--card-foreground: 0 0% 93.33%;
|
|
42
|
+
--border: 44 14% 11%;
|
|
43
|
+
--input: 0 0% 28.24%;
|
|
44
|
+
--primary: 22.93 92.59% 52.35%;
|
|
45
|
+
--primary-foreground: 29.51 0% 100%;
|
|
46
|
+
--secondary: 28.5 64.52% 12.16%;
|
|
47
|
+
--secondary-foreground: 29.51 100% 88.04%;
|
|
48
|
+
--accent: 0 0% 16.47%;
|
|
49
|
+
--accent-foreground: 0 0% 93.33%;
|
|
50
|
+
--destructive: 10.16 77.87% 53.92%;
|
|
51
|
+
--destructive-foreground: 0 0% 100%;
|
|
52
|
+
--ring: 23.11 59.8% 40%;
|
|
53
|
+
--chart-1: 22.93 92.59% 52.35%;
|
|
54
|
+
--chart-2: 28.5 64.52% 12.16%;
|
|
55
|
+
--chart-3: 0 0% 16.47%;
|
|
56
|
+
--chart-4: 28.5 64.52% 15.16%;
|
|
57
|
+
--chart-5: 22.93 95.59% 52.35%;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@layer base {
|
|
62
|
+
* {
|
|
63
|
+
@apply border-border;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
body {
|
|
67
|
+
@apply bg-background text-foreground;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* Force dark mode */
|
|
72
|
+
:root {
|
|
73
|
+
color-scheme: dark;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
body {
|
|
77
|
+
@apply font-mono bg-background text-foreground;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* TEE-specific styling */
|
|
81
|
+
.tee-status-badge {
|
|
82
|
+
@apply inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.tee-status-badge.connected {
|
|
86
|
+
@apply bg-green-900 text-green-300;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.tee-status-badge.disconnected {
|
|
90
|
+
@apply bg-red-900 text-red-300;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.tee-status-badge.loading {
|
|
94
|
+
@apply bg-yellow-900 text-yellow-300;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/* Loading animation */
|
|
98
|
+
@keyframes spin {
|
|
99
|
+
to {
|
|
100
|
+
transform: rotate(360deg);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.animate-spin {
|
|
105
|
+
animation: spin 1s linear infinite;
|
|
106
|
+
}
|