@elizaos/cli 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{chunk-2CUIHNPL.js → chunk-5GUS4CFO.js} +7 -2
- package/dist/{chunk-2ALAPQLV.js → chunk-E6XYTE3A.js} +296 -311
- package/dist/chunk-GXWWPFBO.js +39 -0
- package/dist/{chunk-I77ZRNYO.js → chunk-T2QDIXGU.js} +2 -2
- package/dist/commands/agent/actions/index.d.ts +5 -0
- package/dist/commands/agent/actions/index.js +2 -2
- package/dist/commands/agent/index.d.ts +2 -2
- package/dist/commands/agent/index.js +2 -2
- package/dist/commands/create/actions/index.js +3 -3
- package/dist/commands/create/index.js +4 -4
- package/dist/commands/shared/index.d.ts +11 -28
- package/dist/commands/shared/index.js +7 -3
- package/dist/index.js +541 -450
- package/dist/{registry-N626N4VG.js → registry-433S5F3Y.js} +2 -2
- package/dist/templates/plugin-quick-starter/.gitignore +66 -0
- package/dist/templates/plugin-quick-starter/.npmignore +5 -0
- package/dist/templates/plugin-quick-starter/package.json +11 -3
- package/dist/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +499 -146
- package/dist/templates/plugin-quick-starter/src/__tests__/test-utils.ts +316 -115
- package/dist/templates/plugin-quick-starter/src/plugin.ts +7 -13
- package/dist/templates/plugin-starter/.gitignore +66 -0
- package/dist/templates/plugin-starter/.npmignore +5 -0
- package/dist/templates/plugin-starter/README.md +1 -1
- package/dist/templates/plugin-starter/package.json +11 -3
- package/dist/templates/plugin-starter/src/__tests__/integration.test.ts +13 -13
- package/dist/templates/plugin-starter/src/__tests__/plugin.test.ts +556 -129
- package/dist/templates/plugin-starter/src/__tests__/test-utils.ts +347 -115
- package/dist/templates/plugin-starter/src/plugin.ts +18 -22
- package/dist/templates/project-starter/.gitignore +57 -0
- package/dist/templates/project-starter/.npmignore +11 -0
- package/dist/templates/project-starter/README.md +1 -1
- package/dist/templates/project-starter/package.json +4 -4
- package/dist/templates/project-starter/src/__tests__/env.test.ts +3 -1
- package/dist/templates/project-starter/src/__tests__/file-structure.test.ts +3 -2
- package/dist/templates/project-starter/src/__tests__/integration.test.ts +1 -1
- package/dist/templates/project-starter/tsup.config.ts +2 -1
- package/dist/templates/project-tee-starter/.dockerignore +64 -14
- package/dist/templates/project-tee-starter/.gitignore +57 -0
- package/dist/templates/project-tee-starter/.npmignore +6 -0
- package/dist/templates/project-tee-starter/Dockerfile +9 -5
- package/dist/templates/project-tee-starter/GUIDE.md +103 -42
- package/dist/templates/project-tee-starter/README.md +39 -19
- package/dist/templates/project-tee-starter/__tests__/build-order.test.ts +62 -0
- package/dist/templates/project-tee-starter/__tests__/character.test.ts +19 -17
- package/dist/templates/project-tee-starter/__tests__/config.test.ts +10 -3
- package/dist/templates/project-tee-starter/__tests__/env.test.ts +2 -1
- package/dist/templates/project-tee-starter/__tests__/file-structure.test.ts +14 -3
- package/dist/templates/project-tee-starter/__tests__/frontend.test.ts +459 -0
- package/dist/templates/project-tee-starter/__tests__/plugin.test.ts +4 -2
- package/dist/templates/project-tee-starter/__tests__/routes.test.ts +15 -6
- package/dist/templates/project-tee-starter/__tests__/tee-validation.test.ts +295 -0
- package/dist/templates/project-tee-starter/__tests__/vite-config-utils.ts +39 -0
- package/dist/templates/project-tee-starter/docker-compose.yaml +5 -2
- package/dist/templates/{plugin-starter/dist → project-tee-starter}/index.html +3 -3
- package/dist/templates/project-tee-starter/package.json +34 -14
- package/dist/templates/project-tee-starter/postcss.config.js +3 -0
- package/dist/templates/project-tee-starter/scripts/install-test-deps.js +52 -0
- package/dist/templates/project-tee-starter/scripts/test-all.sh +82 -0
- package/dist/templates/project-tee-starter/src/frontend/index.css +106 -0
- package/dist/templates/project-tee-starter/src/frontend/index.html +20 -0
- package/dist/templates/project-tee-starter/src/frontend/index.tsx +370 -0
- package/dist/templates/project-tee-starter/src/frontend/panels.tsx +17 -0
- package/dist/templates/project-tee-starter/src/frontend/utils.ts +6 -0
- package/dist/templates/project-tee-starter/src/index.ts +6 -6
- package/dist/templates/project-tee-starter/src/plugin.ts +209 -59
- package/dist/templates/project-tee-starter/tailwind.config.js +62 -0
- package/dist/templates/project-tee-starter/tsconfig.build.json +2 -2
- package/dist/templates/project-tee-starter/tsconfig.json +8 -5
- package/dist/templates/project-tee-starter/tsup.config.ts +3 -2
- package/dist/templates/project-tee-starter/vite.config.ts +39 -0
- package/dist/url-utils-CKc_Ebt_.d.ts +35 -0
- package/dist/{utils-H66532NB.js → utils-DBLSDYBF.js} +2 -2
- package/package.json +12 -7
- package/templates/plugin-quick-starter/.gitignore +66 -0
- package/templates/plugin-quick-starter/.npmignore +5 -0
- package/templates/plugin-quick-starter/package.json +11 -3
- package/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +499 -146
- package/templates/plugin-quick-starter/src/__tests__/test-utils.ts +316 -115
- package/templates/plugin-quick-starter/src/plugin.ts +7 -13
- package/templates/plugin-starter/.gitignore +66 -0
- package/templates/plugin-starter/.npmignore +5 -0
- package/templates/plugin-starter/README.md +1 -1
- package/templates/plugin-starter/package.json +11 -3
- package/templates/plugin-starter/src/__tests__/integration.test.ts +13 -13
- package/templates/plugin-starter/src/__tests__/plugin.test.ts +556 -129
- package/templates/plugin-starter/src/__tests__/test-utils.ts +347 -115
- package/templates/plugin-starter/src/plugin.ts +18 -22
- package/templates/project-starter/.gitignore +57 -0
- package/templates/project-starter/.npmignore +11 -0
- package/templates/project-starter/README.md +1 -1
- package/templates/project-starter/package.json +4 -4
- package/templates/project-starter/src/__tests__/env.test.ts +3 -1
- package/templates/project-starter/src/__tests__/file-structure.test.ts +3 -2
- package/templates/project-starter/src/__tests__/integration.test.ts +1 -1
- package/templates/project-starter/tsup.config.ts +2 -1
- package/templates/project-tee-starter/.dockerignore +64 -14
- package/templates/project-tee-starter/.gitignore +57 -0
- package/templates/project-tee-starter/.npmignore +6 -0
- package/templates/project-tee-starter/Dockerfile +9 -5
- package/templates/project-tee-starter/GUIDE.md +103 -42
- package/templates/project-tee-starter/README.md +39 -19
- package/templates/project-tee-starter/__tests__/build-order.test.ts +62 -0
- package/templates/project-tee-starter/__tests__/character.test.ts +19 -17
- package/templates/project-tee-starter/__tests__/config.test.ts +10 -3
- package/templates/project-tee-starter/__tests__/env.test.ts +2 -1
- package/templates/project-tee-starter/__tests__/file-structure.test.ts +14 -3
- package/templates/project-tee-starter/__tests__/frontend.test.ts +459 -0
- package/templates/project-tee-starter/__tests__/plugin.test.ts +4 -2
- package/templates/project-tee-starter/__tests__/routes.test.ts +15 -6
- package/templates/project-tee-starter/__tests__/tee-validation.test.ts +295 -0
- package/templates/project-tee-starter/__tests__/vite-config-utils.ts +39 -0
- package/templates/project-tee-starter/docker-compose.yaml +5 -2
- package/templates/{plugin-starter/dist → project-tee-starter}/index.html +3 -3
- package/templates/project-tee-starter/package.json +34 -14
- package/templates/project-tee-starter/postcss.config.js +3 -0
- package/templates/project-tee-starter/scripts/install-test-deps.js +52 -0
- package/templates/project-tee-starter/scripts/test-all.sh +82 -0
- package/templates/project-tee-starter/src/frontend/index.css +106 -0
- package/templates/project-tee-starter/src/frontend/index.html +20 -0
- package/templates/project-tee-starter/src/frontend/index.tsx +370 -0
- package/templates/project-tee-starter/src/frontend/panels.tsx +17 -0
- package/templates/project-tee-starter/src/frontend/utils.ts +6 -0
- package/templates/project-tee-starter/src/index.ts +6 -6
- package/templates/project-tee-starter/src/plugin.ts +209 -59
- package/templates/project-tee-starter/tailwind.config.js +62 -0
- package/templates/project-tee-starter/tsconfig.build.json +2 -2
- package/templates/project-tee-starter/tsconfig.json +8 -5
- package/templates/project-tee-starter/tsup.config.ts +3 -2
- package/templates/project-tee-starter/vite.config.ts +39 -0
- package/dist/chunk-4O6EZU37.js +0 -14
- package/dist/migration-guides/advanced-migration-guide.md +0 -459
- package/dist/migration-guides/completion-requirements.md +0 -379
- package/dist/migration-guides/integrated-migration-loop.md +0 -392
- package/dist/migration-guides/migration-guide.md +0 -712
- package/dist/migration-guides/prompt-and-generation-guide.md +0 -702
- package/dist/migration-guides/state-and-providers-guide.md +0 -544
- package/dist/migration-guides/testing-guide.md +0 -1021
- package/dist/templates/plugin-starter/dist/assets/index-CgkejLs_.css +0 -1
- package/dist/templates/plugin-starter/dist/assets/index-D1cHX53P.js +0 -49
- package/dist/templates/plugin-starter/dist/index.js +0 -387
- package/dist/templates/plugin-starter/dist/index.js.map +0 -1
- package/templates/plugin-starter/dist/.vite/manifest.json +0 -11
- package/templates/plugin-starter/dist/assets/index-CgkejLs_.css +0 -1
- package/templates/plugin-starter/dist/assets/index-D1cHX53P.js +0 -49
- package/templates/plugin-starter/dist/index.d.ts +0 -14
- package/templates/plugin-starter/dist/index.js +0 -387
- package/templates/plugin-starter/dist/index.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Plugin } from '@elizaos/core';
|
|
2
|
-
import { type IAgentRuntime,
|
|
2
|
+
import { type IAgentRuntime, logger, Service } from '@elizaos/core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { type DeriveKeyResponse, TappdClient } from '@phala/dstack-sdk';
|
|
5
5
|
import { type PrivateKeyAccount, privateKeyToAccount } from 'viem/accounts';
|
|
@@ -12,82 +12,189 @@ import crypto from 'node:crypto';
|
|
|
12
12
|
/**
|
|
13
13
|
* Define the configuration schema for the plugin with the following properties:
|
|
14
14
|
*
|
|
15
|
-
* @param {string}
|
|
15
|
+
* @param {string} TEE_MODE - The TEE mode (OFF, LOCAL, DOCKER, PRODUCTION)
|
|
16
|
+
* @param {string} TEE_VENDOR - The TEE vendor (must be 'phala')
|
|
17
|
+
* @param {string} WALLET_SECRET_SALT - The secret salt for the wallet (min length of 8)
|
|
16
18
|
* @returns {object} - The configured schema object
|
|
17
19
|
*/
|
|
18
20
|
const configSchema = z.object({
|
|
21
|
+
TEE_MODE: z
|
|
22
|
+
.string()
|
|
23
|
+
.optional()
|
|
24
|
+
.transform((val) => {
|
|
25
|
+
// Provide test defaults when NODE_ENV is test
|
|
26
|
+
if (process.env.NODE_ENV === 'test' && !val) {
|
|
27
|
+
return 'OFF';
|
|
28
|
+
}
|
|
29
|
+
return val;
|
|
30
|
+
})
|
|
31
|
+
.refine((val) => {
|
|
32
|
+
if (!val) return true; // Allow undefined in non-test environments
|
|
33
|
+
return ['OFF', 'LOCAL', 'DOCKER', 'PRODUCTION'].includes(val);
|
|
34
|
+
}, 'TEE_MODE must be one of: OFF, LOCAL, DOCKER, PRODUCTION'),
|
|
35
|
+
|
|
36
|
+
TEE_VENDOR: z
|
|
37
|
+
.string()
|
|
38
|
+
.optional()
|
|
39
|
+
.transform((val) => {
|
|
40
|
+
// Provide test defaults when NODE_ENV is test
|
|
41
|
+
if (process.env.NODE_ENV === 'test' && !val) {
|
|
42
|
+
return 'phala';
|
|
43
|
+
}
|
|
44
|
+
return val;
|
|
45
|
+
})
|
|
46
|
+
.refine((val) => {
|
|
47
|
+
if (!val) return true; // Allow undefined in non-test environments
|
|
48
|
+
return val === 'phala';
|
|
49
|
+
}, 'TEE_VENDOR must be: phala'),
|
|
50
|
+
|
|
19
51
|
WALLET_SECRET_SALT: z
|
|
20
52
|
.string()
|
|
21
|
-
.min(1, 'Wallet secret salt is not provided')
|
|
22
53
|
.optional()
|
|
23
54
|
.transform((val) => {
|
|
55
|
+
// SECURITY WARNING: Test defaults are ONLY for test environments
|
|
56
|
+
// NEVER use these defaults in production - always provide a secure salt
|
|
57
|
+
if (process.env.NODE_ENV === 'test' && !val) {
|
|
58
|
+
logger.debug('Using test default for WALLET_SECRET_SALT - NEVER use in production');
|
|
59
|
+
return 'test_default_salt_12345';
|
|
60
|
+
}
|
|
24
61
|
if (!val) {
|
|
25
62
|
logger.warn('Warning: Wallet secret salt is not provided');
|
|
26
63
|
}
|
|
27
64
|
return val;
|
|
28
|
-
})
|
|
65
|
+
})
|
|
66
|
+
.refine(
|
|
67
|
+
(val) => {
|
|
68
|
+
if (!val) return true; // Allow undefined in non-test environments
|
|
69
|
+
const trimmedVal = val.trim();
|
|
70
|
+
return trimmedVal.length >= 8 && trimmedVal.length <= 128;
|
|
71
|
+
},
|
|
72
|
+
(val) => {
|
|
73
|
+
if (!val) return { message: 'Wallet secret salt is required' };
|
|
74
|
+
const trimmedVal = val.trim();
|
|
75
|
+
if (trimmedVal.length < 8) {
|
|
76
|
+
return { message: 'Wallet secret salt must be at least 8 characters long for security' };
|
|
77
|
+
}
|
|
78
|
+
if (trimmedVal.length > 128) {
|
|
79
|
+
return { message: 'Wallet secret salt must not exceed 128 characters' };
|
|
80
|
+
}
|
|
81
|
+
return { message: 'Invalid wallet secret salt' };
|
|
82
|
+
}
|
|
83
|
+
),
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// Functional TEE service configuration
|
|
87
|
+
type TeeServiceConfig = {
|
|
88
|
+
teeClient: TappdClient;
|
|
89
|
+
secretSalt: string;
|
|
90
|
+
runtime: IAgentRuntime;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Creates a TEE service configuration object
|
|
95
|
+
*/
|
|
96
|
+
const createTeeServiceConfig = (runtime: IAgentRuntime): TeeServiceConfig => ({
|
|
97
|
+
teeClient: new TappdClient(),
|
|
98
|
+
secretSalt: process.env.WALLET_SECRET_SALT || 'secret_salt',
|
|
99
|
+
runtime,
|
|
29
100
|
});
|
|
30
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Derives ECDSA keypair from TEE response
|
|
104
|
+
*/
|
|
105
|
+
const deriveEcdsaKeypair = (deriveKeyResponse: DeriveKeyResponse): PrivateKeyAccount => {
|
|
106
|
+
const hex = keccak256(deriveKeyResponse.asUint8Array());
|
|
107
|
+
return privateKeyToAccount(hex);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Derives ED25519 keypair from TEE response
|
|
112
|
+
*/
|
|
113
|
+
const deriveEd25519Keypair = (deriveKeyResponse: DeriveKeyResponse): Keypair => {
|
|
114
|
+
const uint8ArrayDerivedKey = deriveKeyResponse.asUint8Array();
|
|
115
|
+
const hash = crypto.createHash('sha256');
|
|
116
|
+
hash.update(uint8ArrayDerivedKey);
|
|
117
|
+
const seed = hash.digest();
|
|
118
|
+
const seedArray = new Uint8Array(seed);
|
|
119
|
+
return Keypair.fromSeed(seedArray.slice(0, 32));
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Handles TEE key derivation and logging
|
|
124
|
+
*/
|
|
125
|
+
const handleTeeKeyDerivation = async (config: TeeServiceConfig): Promise<void> => {
|
|
126
|
+
try {
|
|
127
|
+
const deriveKeyResponse: DeriveKeyResponse = await config.teeClient.deriveKey(
|
|
128
|
+
config.secretSalt
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
// ECDSA Key
|
|
132
|
+
const ecdsaKeypair = deriveEcdsaKeypair(deriveKeyResponse);
|
|
133
|
+
|
|
134
|
+
// ED25519 Key
|
|
135
|
+
const ed25519Keypair = deriveEd25519Keypair(deriveKeyResponse);
|
|
136
|
+
|
|
137
|
+
logger.log('ECDSA Key Derived Successfully!');
|
|
138
|
+
logger.log('ECDSA Keypair:', ecdsaKeypair.address);
|
|
139
|
+
logger.log('ED25519 Keypair:', ed25519Keypair.publicKey);
|
|
140
|
+
|
|
141
|
+
const signature = await ecdsaKeypair.signMessage({ message: 'Hello, world!' });
|
|
142
|
+
logger.log('Sign message w/ ECDSA keypair: Hello world!, Signature: ', signature);
|
|
143
|
+
} catch (error) {
|
|
144
|
+
// Handle TEE connection errors gracefully
|
|
145
|
+
if (error instanceof Error && error.message.includes('ENOENT')) {
|
|
146
|
+
logger.warn('TEE daemon not available - running in non-TEE mode for testing');
|
|
147
|
+
logger.warn('To run with TEE, ensure tappd is running at /var/run/tappd.sock');
|
|
148
|
+
} else {
|
|
149
|
+
logger.error('Error connecting to TEE:', error);
|
|
150
|
+
}
|
|
151
|
+
// Continue without TEE functionality for testing
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Starts the TEE starter service using functional approach
|
|
157
|
+
*/
|
|
158
|
+
const startTeeService = async (runtime: IAgentRuntime): Promise<TeeServiceConfig> => {
|
|
159
|
+
logger.info("*** Starting Mr. TEE's custom service (Functional) ***");
|
|
160
|
+
|
|
161
|
+
const config = createTeeServiceConfig(runtime);
|
|
162
|
+
await handleTeeKeyDerivation(config);
|
|
163
|
+
|
|
164
|
+
return config;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Stops the TEE starter service using functional approach
|
|
169
|
+
*/
|
|
170
|
+
const stopTeeService = async (runtime: IAgentRuntime): Promise<void> => {
|
|
171
|
+
logger.info("*** Stopping Mr. TEE's custom service (Functional) ***");
|
|
172
|
+
// In functional approach, cleanup is handled here if needed
|
|
173
|
+
// No explicit service instance to stop
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* StarterService class for TEE functionality
|
|
178
|
+
*/
|
|
31
179
|
export class StarterService extends Service {
|
|
32
|
-
static serviceType = 'starter';
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
private secretSalt: string;
|
|
36
|
-
constructor(protected runtime: IAgentRuntime) {
|
|
180
|
+
public static serviceType = 'starter';
|
|
181
|
+
|
|
182
|
+
constructor(runtime: IAgentRuntime) {
|
|
37
183
|
super(runtime);
|
|
38
|
-
this.teeClient = new TappdClient();
|
|
39
|
-
this.secretSalt = process.env.WALLET_SECRET_SALT || 'secret_salt';
|
|
40
184
|
}
|
|
41
185
|
|
|
42
|
-
static async start(runtime: IAgentRuntime) {
|
|
43
|
-
logger.info("*** Starting Mr. TEE's custom service (StarterService) ***");
|
|
186
|
+
static async start(runtime: IAgentRuntime): Promise<StarterService> {
|
|
44
187
|
const service = new StarterService(runtime);
|
|
45
|
-
|
|
46
|
-
const deriveKeyResponse: DeriveKeyResponse = await service.teeClient.deriveKey(
|
|
47
|
-
service.secretSalt
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
// ECDSA Key
|
|
51
|
-
const hex = keccak256(deriveKeyResponse.asUint8Array());
|
|
52
|
-
const ecdsaKeypair: PrivateKeyAccount = privateKeyToAccount(hex);
|
|
53
|
-
|
|
54
|
-
// ED25519 Key
|
|
55
|
-
const uint8ArrayDerivedKey = deriveKeyResponse.asUint8Array();
|
|
56
|
-
const hash = crypto.createHash('sha256');
|
|
57
|
-
hash.update(uint8ArrayDerivedKey);
|
|
58
|
-
const seed = hash.digest();
|
|
59
|
-
const seedArray = new Uint8Array(seed);
|
|
60
|
-
const ed25519Keypair = Keypair.fromSeed(seedArray.slice(0, 32));
|
|
61
|
-
|
|
62
|
-
logger.log('ECDSA Key Derived Successfully!');
|
|
63
|
-
logger.log('ECDSA Keypair:', ecdsaKeypair.address);
|
|
64
|
-
logger.log('ED25519 Keypair:', ed25519Keypair.publicKey);
|
|
65
|
-
const signature = await ecdsaKeypair.signMessage({ message: 'Hello, world!' });
|
|
66
|
-
logger.log('Sign message w/ ECDSA keypair: Hello world!, Signature: ', signature);
|
|
67
|
-
} catch (error) {
|
|
68
|
-
// Handle TEE connection errors gracefully
|
|
69
|
-
if (error instanceof Error && error.message.includes('ENOENT')) {
|
|
70
|
-
logger.warn('TEE daemon not available - running in non-TEE mode for testing');
|
|
71
|
-
logger.warn('To run with TEE, ensure tappd is running at /var/run/tappd.sock');
|
|
72
|
-
} else {
|
|
73
|
-
logger.error('Error connecting to TEE:', error);
|
|
74
|
-
}
|
|
75
|
-
// Continue without TEE functionality for testing
|
|
76
|
-
}
|
|
188
|
+
await startTeeService(runtime);
|
|
77
189
|
return service;
|
|
78
190
|
}
|
|
79
191
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const service = runtime.getService(StarterService.serviceType);
|
|
83
|
-
if (!service) {
|
|
84
|
-
throw new Error('Mr. TEE custom service (StarterService) not found');
|
|
85
|
-
}
|
|
86
|
-
service.stop();
|
|
192
|
+
async stop(): Promise<void> {
|
|
193
|
+
await stopTeeService(this.runtime);
|
|
87
194
|
}
|
|
88
195
|
|
|
89
|
-
|
|
90
|
-
|
|
196
|
+
public get capabilityDescription(): string {
|
|
197
|
+
return 'This is a starter service, can be customized for Mr. TEE.';
|
|
91
198
|
}
|
|
92
199
|
}
|
|
93
200
|
|
|
@@ -96,12 +203,42 @@ const teeStarterPlugin: Plugin = {
|
|
|
96
203
|
description: "Mr. TEE's starter plugin - using plugin-tee for attestation",
|
|
97
204
|
config: {
|
|
98
205
|
TEE_MODE: process.env.TEE_MODE,
|
|
206
|
+
TEE_VENDOR: process.env.TEE_VENDOR,
|
|
99
207
|
WALLET_SECRET_SALT: process.env.WALLET_SECRET_SALT,
|
|
100
208
|
},
|
|
101
|
-
async init(config: Record<string, string
|
|
209
|
+
async init(config: Record<string, string>, runtime: IAgentRuntime) {
|
|
102
210
|
logger.info('*** Initializing Mr. TEE plugin ***');
|
|
103
211
|
try {
|
|
104
|
-
|
|
212
|
+
// Merge process.env values with config, config takes precedence
|
|
213
|
+
const mergedConfig = {
|
|
214
|
+
TEE_MODE: config.TEE_MODE ?? process.env.TEE_MODE,
|
|
215
|
+
TEE_VENDOR: config.TEE_VENDOR ?? process.env.TEE_VENDOR,
|
|
216
|
+
WALLET_SECRET_SALT: config.WALLET_SECRET_SALT ?? process.env.WALLET_SECRET_SALT,
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// Apply test defaults if in test environment
|
|
220
|
+
const isTestEnvironment = process.env.NODE_ENV === 'test' || process.argv.includes('test');
|
|
221
|
+
|
|
222
|
+
if (isTestEnvironment) {
|
|
223
|
+
// Apply test-only defaults - NEVER use these in production
|
|
224
|
+
mergedConfig.TEE_MODE = mergedConfig.TEE_MODE || 'OFF';
|
|
225
|
+
mergedConfig.TEE_VENDOR = mergedConfig.TEE_VENDOR || 'phala';
|
|
226
|
+
// Test salt - this is ONLY for test environments and should NEVER be used in production
|
|
227
|
+
mergedConfig.WALLET_SECRET_SALT =
|
|
228
|
+
mergedConfig.WALLET_SECRET_SALT || 'test_default_salt_12345';
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const validatedConfig = await configSchema.parseAsync(mergedConfig);
|
|
232
|
+
|
|
233
|
+
// Production safety check - ensure test defaults aren't used in production
|
|
234
|
+
if (
|
|
235
|
+
process.env.NODE_ENV === 'production' &&
|
|
236
|
+
validatedConfig.WALLET_SECRET_SALT === 'test_default_salt_12345'
|
|
237
|
+
) {
|
|
238
|
+
throw new Error(
|
|
239
|
+
'CRITICAL: Test salt detected in production environment. Please provide a secure WALLET_SECRET_SALT.'
|
|
240
|
+
);
|
|
241
|
+
}
|
|
105
242
|
|
|
106
243
|
// Set all environment variables at once
|
|
107
244
|
for (const [key, value] of Object.entries(validatedConfig)) {
|
|
@@ -132,6 +269,21 @@ const teeStarterPlugin: Plugin = {
|
|
|
132
269
|
});
|
|
133
270
|
},
|
|
134
271
|
},
|
|
272
|
+
{
|
|
273
|
+
name: 'TEE Status',
|
|
274
|
+
path: '/public/tee-status',
|
|
275
|
+
type: 'GET',
|
|
276
|
+
handler: async (
|
|
277
|
+
_req: Record<string, unknown>,
|
|
278
|
+
res: { json: (data: Record<string, unknown>) => void }
|
|
279
|
+
) => {
|
|
280
|
+
res.json({
|
|
281
|
+
status: 'active',
|
|
282
|
+
tee_enabled: process.env.TEE_MODE !== 'OFF',
|
|
283
|
+
vendor: process.env.TEE_VENDOR || 'phala',
|
|
284
|
+
});
|
|
285
|
+
},
|
|
286
|
+
},
|
|
135
287
|
],
|
|
136
288
|
events: {
|
|
137
289
|
MESSAGE_RECEIVED: [
|
|
@@ -159,9 +311,7 @@ const teeStarterPlugin: Plugin = {
|
|
|
159
311
|
],
|
|
160
312
|
},
|
|
161
313
|
// Enable this service to run when TEE mode is enabled
|
|
162
|
-
services: [
|
|
163
|
-
/* StarterService */
|
|
164
|
-
],
|
|
314
|
+
services: [StarterService],
|
|
165
315
|
actions: [],
|
|
166
316
|
providers: [],
|
|
167
317
|
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import tailwindcssAnimate from 'tailwindcss-animate';
|
|
2
|
+
|
|
3
|
+
/** @type {import('tailwindcss').Config} */
|
|
4
|
+
export default {
|
|
5
|
+
darkMode: ['class'],
|
|
6
|
+
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
|
|
7
|
+
theme: {
|
|
8
|
+
extend: {
|
|
9
|
+
container: {
|
|
10
|
+
center: true,
|
|
11
|
+
},
|
|
12
|
+
borderRadius: {
|
|
13
|
+
lg: 'var(--radius)',
|
|
14
|
+
md: 'calc(var(--radius) - 2px)',
|
|
15
|
+
sm: 'calc(var(--radius) - 4px)',
|
|
16
|
+
},
|
|
17
|
+
colors: {
|
|
18
|
+
background: 'hsl(var(--background))',
|
|
19
|
+
foreground: 'hsl(var(--foreground))',
|
|
20
|
+
card: {
|
|
21
|
+
DEFAULT: 'hsl(var(--card))',
|
|
22
|
+
foreground: 'hsl(var(--card-foreground))',
|
|
23
|
+
},
|
|
24
|
+
popover: {
|
|
25
|
+
DEFAULT: 'hsl(var(--popover))',
|
|
26
|
+
foreground: 'hsl(var(--popover-foreground))',
|
|
27
|
+
},
|
|
28
|
+
primary: {
|
|
29
|
+
DEFAULT: 'hsl(var(--primary))',
|
|
30
|
+
foreground: 'hsl(var(--primary-foreground))',
|
|
31
|
+
},
|
|
32
|
+
secondary: {
|
|
33
|
+
DEFAULT: 'hsl(var(--secondary))',
|
|
34
|
+
foreground: 'hsl(var(--secondary-foreground))',
|
|
35
|
+
},
|
|
36
|
+
muted: {
|
|
37
|
+
DEFAULT: 'hsl(var(--muted))',
|
|
38
|
+
foreground: 'hsl(var(--muted-foreground))',
|
|
39
|
+
},
|
|
40
|
+
accent: {
|
|
41
|
+
DEFAULT: 'hsl(var(--accent))',
|
|
42
|
+
foreground: 'hsl(var(--accent-foreground))',
|
|
43
|
+
},
|
|
44
|
+
destructive: {
|
|
45
|
+
DEFAULT: 'hsl(var(--destructive))',
|
|
46
|
+
foreground: 'hsl(var(--destructive-foreground))',
|
|
47
|
+
},
|
|
48
|
+
border: 'hsl(var(--border))',
|
|
49
|
+
input: 'hsl(var(--input))',
|
|
50
|
+
ring: 'hsl(var(--ring))',
|
|
51
|
+
chart: {
|
|
52
|
+
1: 'hsl(var(--chart-1))',
|
|
53
|
+
2: 'hsl(var(--chart-2))',
|
|
54
|
+
3: 'hsl(var(--chart-3))',
|
|
55
|
+
4: 'hsl(var(--chart-4))',
|
|
56
|
+
5: 'hsl(var(--chart-5))',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
plugins: [tailwindcssAnimate],
|
|
62
|
+
};
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
"declaration": true,
|
|
9
9
|
"emitDeclarationOnly": true
|
|
10
10
|
},
|
|
11
|
-
"include": ["src/**/*.ts"],
|
|
12
|
-
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"]
|
|
11
|
+
"include": ["src/index.ts", "src/plugin.ts", "src/frontend/**/*.ts", "src/frontend/**/*.tsx"],
|
|
12
|
+
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts", "src/__tests__/**/*"]
|
|
13
13
|
}
|
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"outDir": "dist",
|
|
3
|
+
"outDir": "./dist",
|
|
4
4
|
"rootDir": "src",
|
|
5
|
-
"lib": ["ESNext"],
|
|
5
|
+
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
|
6
6
|
"target": "ESNext",
|
|
7
7
|
"module": "Preserve",
|
|
8
8
|
"moduleResolution": "Bundler",
|
|
9
9
|
"strict": false,
|
|
10
10
|
"esModuleInterop": true,
|
|
11
11
|
"skipLibCheck": true,
|
|
12
|
-
"forceConsistentCasingInFileNames":
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"strictFunctionTypes": false,
|
|
14
|
+
"useUnknownInCatchVariables": false,
|
|
13
15
|
"allowImportingTsExtensions": true,
|
|
14
16
|
"declaration": true,
|
|
15
17
|
"emitDeclarationOnly": true,
|
|
16
18
|
"resolveJsonModule": true,
|
|
17
|
-
"noImplicitAny": false,
|
|
18
19
|
"allowJs": true,
|
|
19
20
|
"checkJs": false,
|
|
20
21
|
"noEmitOnError": false,
|
|
21
22
|
"moduleDetection": "force",
|
|
22
23
|
"allowArbitraryExtensions": true,
|
|
24
|
+
"jsx": "react-jsx",
|
|
23
25
|
"baseUrl": ".",
|
|
24
26
|
"paths": {
|
|
25
27
|
"@elizaos/core": ["../../core/src"],
|
|
26
28
|
"@elizaos/core/*": ["../../core/src/*"]
|
|
27
29
|
}
|
|
28
30
|
},
|
|
29
|
-
"include": ["src/**/*.ts"]
|
|
31
|
+
"include": ["src/**/*.ts", "src/**/*.tsx"],
|
|
32
|
+
"exclude": ["dist", "node_modules", "src/__tests__/**/*", "**/*.test.ts", "**/*.spec.ts"]
|
|
30
33
|
}
|
|
@@ -5,15 +5,16 @@ export default defineConfig({
|
|
|
5
5
|
outDir: 'dist',
|
|
6
6
|
tsconfig: './tsconfig.build.json', // Use build-specific tsconfig
|
|
7
7
|
sourcemap: true,
|
|
8
|
-
clean:
|
|
8
|
+
clean: false,
|
|
9
9
|
format: ['esm'], // Ensure you're targeting CommonJS
|
|
10
|
-
dts:
|
|
10
|
+
dts: true, // require DTS so we get d.ts in the dist folder on npm
|
|
11
11
|
external: [
|
|
12
12
|
'dotenv', // Externalize dotenv to prevent bundling
|
|
13
13
|
'fs', // Externalize fs to use Node.js built-in module
|
|
14
14
|
'path', // Externalize other built-ins if necessary
|
|
15
15
|
'https',
|
|
16
16
|
'http',
|
|
17
|
+
'@elizaos/core',
|
|
17
18
|
'zod',
|
|
18
19
|
],
|
|
19
20
|
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import react from '@vitejs/plugin-react';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
|
|
6
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
|
|
8
|
+
// https://vite.dev/config/
|
|
9
|
+
export default defineConfig({
|
|
10
|
+
plugins: [react()],
|
|
11
|
+
root: 'src/frontend',
|
|
12
|
+
build: {
|
|
13
|
+
outDir: '../../dist/frontend',
|
|
14
|
+
emptyOutDir: true,
|
|
15
|
+
rollupOptions: {
|
|
16
|
+
input: {
|
|
17
|
+
main: path.resolve(__dirname, 'src/frontend/index.html'),
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
optimizeDeps: {
|
|
22
|
+
include: ['react', 'react-dom', '@tanstack/react-query'],
|
|
23
|
+
},
|
|
24
|
+
resolve: {
|
|
25
|
+
alias: {
|
|
26
|
+
'@': path.resolve(__dirname, './src'),
|
|
27
|
+
'@elizaos/core': path.resolve(__dirname, '../../core/src'),
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
server: {
|
|
31
|
+
port: 5173,
|
|
32
|
+
proxy: {
|
|
33
|
+
'/api': {
|
|
34
|
+
target: 'http://localhost:3000',
|
|
35
|
+
changeOrigin: true,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
});
|
package/dist/chunk-4O6EZU37.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// src/commands/shared/url-utils.ts
|
|
2
|
-
function getAgentRuntimeUrl(opts) {
|
|
3
|
-
return opts.remoteUrl?.replace(/\/$/, "") || // Use the flag if provided
|
|
4
|
-
process.env.AGENT_RUNTIME_URL?.replace(/\/$/, "") || // Fallback to env var
|
|
5
|
-
`http://localhost:${opts.port || process.env.SERVER_PORT || "3000"}`;
|
|
6
|
-
}
|
|
7
|
-
function getAgentsBaseUrl(opts) {
|
|
8
|
-
return `${getAgentRuntimeUrl(opts)}/api/agents`;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
getAgentRuntimeUrl,
|
|
13
|
-
getAgentsBaseUrl
|
|
14
|
-
};
|