@elizaos/cli 1.3.1 → 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.
Files changed (198) hide show
  1. package/README.md +47 -1
  2. package/dist/{bun-exec-6CQHTS4F.js → bun-exec-ULMPAIQC.js} +1 -1
  3. package/dist/{chunk-2ALAPQLV.js → chunk-D3QSET5H.js} +342 -360
  4. package/dist/{chunk-FDEDLANP.js → chunk-FQYWRHLX.js} +1 -1
  5. package/dist/{chunk-RM6LUTKD.js → chunk-FSSUAWXQ.js} +3 -3
  6. package/dist/chunk-GXWWPFBO.js +39 -0
  7. package/dist/{chunk-D3Q2UZLZ.js → chunk-I4L4T7QX.js} +1 -1
  8. package/dist/{chunk-KDNV7EA5.js → chunk-SMZBJQJR.js} +1 -1
  9. package/dist/commands/agent/actions/index.d.ts +5 -0
  10. package/dist/commands/agent/actions/index.js +4 -4
  11. package/dist/commands/agent/index.d.ts +2 -2
  12. package/dist/commands/agent/index.js +4 -4
  13. package/dist/commands/create/actions/index.js +5 -5
  14. package/dist/commands/create/index.js +6 -6
  15. package/dist/commands/shared/index.d.ts +11 -28
  16. package/dist/commands/shared/index.js +7 -3
  17. package/dist/index.js +599 -483
  18. package/dist/{plugin-creator-H26ZLR6H.js → plugin-creator-TCUFII32.js} +2 -2
  19. package/dist/{registry-N626N4VG.js → registry-RF6PW3EN.js} +4 -4
  20. package/dist/templates/plugin-quick-starter/README.md +52 -10
  21. package/dist/templates/plugin-quick-starter/package.json +10 -3
  22. package/dist/templates/plugin-quick-starter/src/__tests__/e2e/README.md +140 -0
  23. package/dist/templates/plugin-quick-starter/src/__tests__/e2e/plugin-quick-starter.e2e.ts +339 -0
  24. package/dist/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +537 -146
  25. package/dist/templates/plugin-quick-starter/src/__tests__/test-utils.ts +316 -115
  26. package/dist/templates/plugin-quick-starter/src/plugin.ts +20 -26
  27. package/dist/templates/plugin-starter/README.md +124 -49
  28. package/dist/templates/plugin-starter/package.json +10 -3
  29. package/dist/templates/plugin-starter/src/__tests__/e2e/README.md +44 -9
  30. package/{templates/plugin-starter/src/__tests__/e2e/starter-plugin.ts → dist/templates/plugin-starter/src/__tests__/e2e/plugin-starter.e2e.ts} +13 -20
  31. package/dist/templates/plugin-starter/src/__tests__/integration.test.ts +13 -13
  32. package/dist/templates/plugin-starter/src/__tests__/plugin.test.ts +556 -129
  33. package/dist/templates/plugin-starter/src/__tests__/test-utils.ts +347 -115
  34. package/dist/templates/plugin-starter/src/plugin.ts +21 -27
  35. package/dist/templates/project-starter/README.md +25 -12
  36. package/dist/templates/project-starter/package.json +4 -4
  37. package/dist/templates/project-starter/src/__tests__/actions.test.ts +2 -2
  38. package/dist/templates/project-starter/src/__tests__/e2e/README.md +103 -0
  39. package/dist/templates/project-starter/src/__tests__/e2e/project-starter.e2e.ts +575 -0
  40. package/dist/templates/project-starter/src/__tests__/env.test.ts +3 -1
  41. package/dist/templates/project-starter/src/__tests__/file-structure.test.ts +3 -2
  42. package/dist/templates/project-starter/src/__tests__/integration.test.ts +2 -2
  43. package/dist/templates/project-starter/src/__tests__/models.test.ts +3 -3
  44. package/dist/templates/project-starter/src/__tests__/plugin.test.ts +3 -3
  45. package/dist/templates/project-starter/src/__tests__/provider.test.ts +2 -2
  46. package/dist/templates/project-starter/src/index.ts +4 -3
  47. package/dist/templates/project-starter/src/plugin.ts +5 -5
  48. package/dist/templates/project-starter/tsup.config.ts +2 -1
  49. package/dist/templates/project-tee-starter/.dockerignore +64 -14
  50. package/dist/templates/project-tee-starter/Dockerfile +9 -5
  51. package/dist/templates/project-tee-starter/GUIDE.md +103 -42
  52. package/dist/templates/project-tee-starter/README.md +83 -24
  53. package/dist/templates/project-tee-starter/docker-compose.yaml +5 -2
  54. package/dist/templates/{plugin-starter/dist → project-tee-starter}/index.html +3 -3
  55. package/dist/templates/project-tee-starter/package.json +34 -14
  56. package/dist/templates/project-tee-starter/postcss.config.js +3 -0
  57. package/dist/templates/project-tee-starter/scripts/install-test-deps.js +52 -0
  58. package/dist/templates/project-tee-starter/scripts/test-all.sh +82 -0
  59. package/dist/templates/project-tee-starter/src/__tests__/build-order.test.ts +62 -0
  60. package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/character.test.ts +20 -18
  61. package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/config.test.ts +11 -4
  62. package/dist/templates/project-tee-starter/src/__tests__/e2e/README.md +128 -0
  63. package/dist/templates/project-tee-starter/src/__tests__/e2e/project-tee-starter.e2e.ts +280 -0
  64. package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/env.test.ts +3 -2
  65. package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/error-handling.test.ts +2 -2
  66. package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/events.test.ts +1 -1
  67. package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/file-structure.test.ts +16 -5
  68. package/dist/templates/project-tee-starter/src/__tests__/frontend.test.ts +459 -0
  69. package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/integration.test.ts +2 -2
  70. package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/models.test.ts +1 -1
  71. package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/plugin.test.ts +5 -3
  72. package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/provider.test.ts +2 -2
  73. package/dist/templates/project-tee-starter/src/__tests__/routes.test.ts +30 -0
  74. package/dist/templates/project-tee-starter/src/__tests__/tee-validation.test.ts +295 -0
  75. package/{templates/project-tee-starter → dist/templates/project-tee-starter/src}/__tests__/test-utils.ts +2 -2
  76. package/dist/templates/project-tee-starter/src/__tests__/vite-config-utils.ts +51 -0
  77. package/dist/templates/project-tee-starter/src/frontend/index.css +106 -0
  78. package/dist/templates/project-tee-starter/src/frontend/index.html +20 -0
  79. package/dist/templates/project-tee-starter/src/frontend/index.tsx +370 -0
  80. package/dist/templates/project-tee-starter/src/frontend/panels.tsx +17 -0
  81. package/dist/templates/project-tee-starter/src/frontend/utils.ts +6 -0
  82. package/dist/templates/project-tee-starter/src/index.ts +8 -6
  83. package/dist/templates/project-tee-starter/src/plugin.ts +223 -61
  84. package/dist/templates/project-tee-starter/tailwind.config.js +62 -0
  85. package/dist/templates/project-tee-starter/tsconfig.build.json +2 -2
  86. package/dist/templates/project-tee-starter/tsconfig.json +8 -5
  87. package/dist/templates/project-tee-starter/tsup.config.ts +3 -2
  88. package/dist/templates/project-tee-starter/vite.config.ts +39 -0
  89. package/dist/url-utils-CKc_Ebt_.d.ts +35 -0
  90. package/dist/{utils-H66532NB.js → utils-5HPZSIF6.js} +4 -4
  91. package/package.json +7 -6
  92. package/templates/plugin-quick-starter/README.md +52 -10
  93. package/templates/plugin-quick-starter/package.json +10 -3
  94. package/templates/plugin-quick-starter/src/__tests__/e2e/README.md +140 -0
  95. package/templates/plugin-quick-starter/src/__tests__/e2e/plugin-quick-starter.e2e.ts +339 -0
  96. package/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +537 -146
  97. package/templates/plugin-quick-starter/src/__tests__/test-utils.ts +316 -115
  98. package/templates/plugin-quick-starter/src/plugin.ts +20 -26
  99. package/templates/plugin-starter/README.md +124 -49
  100. package/templates/plugin-starter/package.json +10 -3
  101. package/templates/plugin-starter/src/__tests__/e2e/README.md +44 -9
  102. package/{dist/templates/plugin-starter/src/__tests__/e2e/starter-plugin.ts → templates/plugin-starter/src/__tests__/e2e/plugin-starter.e2e.ts} +13 -20
  103. package/templates/plugin-starter/src/__tests__/integration.test.ts +13 -13
  104. package/templates/plugin-starter/src/__tests__/plugin.test.ts +556 -129
  105. package/templates/plugin-starter/src/__tests__/test-utils.ts +347 -115
  106. package/templates/plugin-starter/src/plugin.ts +21 -27
  107. package/templates/project-starter/README.md +25 -12
  108. package/templates/project-starter/package.json +4 -4
  109. package/templates/project-starter/src/__tests__/actions.test.ts +2 -2
  110. package/templates/project-starter/src/__tests__/e2e/README.md +103 -0
  111. package/templates/project-starter/src/__tests__/e2e/project-starter.e2e.ts +575 -0
  112. package/templates/project-starter/src/__tests__/env.test.ts +3 -1
  113. package/templates/project-starter/src/__tests__/file-structure.test.ts +3 -2
  114. package/templates/project-starter/src/__tests__/integration.test.ts +2 -2
  115. package/templates/project-starter/src/__tests__/models.test.ts +3 -3
  116. package/templates/project-starter/src/__tests__/plugin.test.ts +3 -3
  117. package/templates/project-starter/src/__tests__/provider.test.ts +2 -2
  118. package/templates/project-starter/src/index.ts +4 -3
  119. package/templates/project-starter/src/plugin.ts +5 -5
  120. package/templates/project-starter/tsup.config.ts +2 -1
  121. package/templates/project-tee-starter/.dockerignore +64 -14
  122. package/templates/project-tee-starter/Dockerfile +9 -5
  123. package/templates/project-tee-starter/GUIDE.md +103 -42
  124. package/templates/project-tee-starter/README.md +83 -24
  125. package/templates/project-tee-starter/docker-compose.yaml +5 -2
  126. package/templates/{plugin-starter/dist → project-tee-starter}/index.html +3 -3
  127. package/templates/project-tee-starter/package.json +34 -14
  128. package/templates/project-tee-starter/postcss.config.js +3 -0
  129. package/templates/project-tee-starter/scripts/install-test-deps.js +52 -0
  130. package/templates/project-tee-starter/scripts/test-all.sh +82 -0
  131. package/templates/project-tee-starter/src/__tests__/build-order.test.ts +62 -0
  132. package/templates/project-tee-starter/{__tests__ → src/__tests__}/character.test.ts +20 -18
  133. package/templates/project-tee-starter/{__tests__ → src/__tests__}/config.test.ts +11 -4
  134. package/templates/project-tee-starter/src/__tests__/e2e/README.md +128 -0
  135. package/templates/project-tee-starter/src/__tests__/e2e/project-tee-starter.e2e.ts +280 -0
  136. package/templates/project-tee-starter/{__tests__ → src/__tests__}/env.test.ts +3 -2
  137. package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/error-handling.test.ts +2 -2
  138. package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/events.test.ts +1 -1
  139. package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/file-structure.test.ts +16 -5
  140. package/templates/project-tee-starter/src/__tests__/frontend.test.ts +459 -0
  141. package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/integration.test.ts +2 -2
  142. package/templates/project-tee-starter/{__tests__ → src/__tests__}/models.test.ts +1 -1
  143. package/templates/project-tee-starter/{__tests__ → src/__tests__}/plugin.test.ts +5 -3
  144. package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/provider.test.ts +2 -2
  145. package/templates/project-tee-starter/src/__tests__/routes.test.ts +30 -0
  146. package/templates/project-tee-starter/src/__tests__/tee-validation.test.ts +295 -0
  147. package/{dist/templates/project-tee-starter → templates/project-tee-starter/src}/__tests__/test-utils.ts +2 -2
  148. package/templates/project-tee-starter/src/__tests__/vite-config-utils.ts +51 -0
  149. package/templates/project-tee-starter/src/frontend/index.css +106 -0
  150. package/templates/project-tee-starter/src/frontend/index.html +20 -0
  151. package/templates/project-tee-starter/src/frontend/index.tsx +370 -0
  152. package/templates/project-tee-starter/src/frontend/panels.tsx +17 -0
  153. package/templates/project-tee-starter/src/frontend/utils.ts +6 -0
  154. package/templates/project-tee-starter/src/index.ts +8 -6
  155. package/templates/project-tee-starter/src/plugin.ts +223 -61
  156. package/templates/project-tee-starter/tailwind.config.js +62 -0
  157. package/templates/project-tee-starter/tsconfig.build.json +2 -2
  158. package/templates/project-tee-starter/tsconfig.json +8 -5
  159. package/templates/project-tee-starter/tsup.config.ts +3 -2
  160. package/templates/project-tee-starter/vite.config.ts +39 -0
  161. package/dist/chunk-4O6EZU37.js +0 -14
  162. package/dist/migration-guides/advanced-migration-guide.md +0 -459
  163. package/dist/migration-guides/completion-requirements.md +0 -379
  164. package/dist/migration-guides/integrated-migration-loop.md +0 -392
  165. package/dist/migration-guides/migration-guide.md +0 -712
  166. package/dist/migration-guides/prompt-and-generation-guide.md +0 -702
  167. package/dist/migration-guides/state-and-providers-guide.md +0 -544
  168. package/dist/migration-guides/testing-guide.md +0 -1021
  169. package/dist/templates/plugin-starter/dist/assets/index-CgkejLs_.css +0 -1
  170. package/dist/templates/plugin-starter/dist/assets/index-D1cHX53P.js +0 -49
  171. package/dist/templates/plugin-starter/dist/index.js +0 -387
  172. package/dist/templates/plugin-starter/dist/index.js.map +0 -1
  173. package/dist/templates/plugin-starter/src/tests.ts +0 -6
  174. package/dist/templates/project-starter/src/__tests__/e2e/index.ts +0 -14
  175. package/dist/templates/project-starter/src/__tests__/e2e/natural-language.test.ts +0 -246
  176. package/dist/templates/project-starter/src/__tests__/e2e/project.test.ts +0 -155
  177. package/dist/templates/project-starter/src/__tests__/e2e/starter-plugin.test.ts +0 -421
  178. package/dist/templates/project-tee-starter/__tests__/routes.test.ts +0 -21
  179. package/dist/templates/project-tee-starter/e2e/project.test.ts +0 -38
  180. package/dist/templates/project-tee-starter/e2e/starter-plugin.test.ts +0 -92
  181. package/templates/plugin-starter/dist/.vite/manifest.json +0 -11
  182. package/templates/plugin-starter/dist/assets/index-CgkejLs_.css +0 -1
  183. package/templates/plugin-starter/dist/assets/index-D1cHX53P.js +0 -49
  184. package/templates/plugin-starter/dist/index.d.ts +0 -14
  185. package/templates/plugin-starter/dist/index.js +0 -387
  186. package/templates/plugin-starter/dist/index.js.map +0 -1
  187. package/templates/plugin-starter/src/tests.ts +0 -6
  188. package/templates/project-starter/src/__tests__/e2e/index.ts +0 -14
  189. package/templates/project-starter/src/__tests__/e2e/natural-language.test.ts +0 -246
  190. package/templates/project-starter/src/__tests__/e2e/project.test.ts +0 -155
  191. package/templates/project-starter/src/__tests__/e2e/starter-plugin.test.ts +0 -421
  192. package/templates/project-tee-starter/__tests__/routes.test.ts +0 -21
  193. package/templates/project-tee-starter/e2e/project.test.ts +0 -38
  194. package/templates/project-tee-starter/e2e/starter-plugin.test.ts +0 -92
  195. /package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/actions.test.ts +0 -0
  196. /package/dist/templates/project-tee-starter/{__tests__ → src/__tests__}/utils/core-test-utils.ts +0 -0
  197. /package/templates/project-tee-starter/{__tests__ → src/__tests__}/actions.test.ts +0 -0
  198. /package/templates/project-tee-starter/{__tests__ → src/__tests__}/utils/core-test-utils.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  import type { Plugin } from '@elizaos/core';
2
- import { type IAgentRuntime, Service, logger } from '@elizaos/core';
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,201 @@ 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} WALLET_SECRET_SALT - The secret salt for the wallet (min length of 1, optional)
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
+ * Checks if an error is a TEE connection error
124
+ * @param error The error to check
125
+ * @returns True if the error is a TEE connection error
126
+ */
127
+ const isTeeConnectionError = (error: unknown): boolean => {
128
+ return (
129
+ error instanceof Error &&
130
+ (error.message.includes('ENOENT') || error.message.includes('Failed to connect'))
131
+ );
132
+ };
133
+
134
+ /**
135
+ * Handles TEE key derivation and logging
136
+ */
137
+ const handleTeeKeyDerivation = async (config: TeeServiceConfig): Promise<void> => {
138
+ try {
139
+ const deriveKeyResponse: DeriveKeyResponse = await config.teeClient.deriveKey(
140
+ config.secretSalt
141
+ );
142
+
143
+ // ECDSA Key
144
+ const ecdsaKeypair = deriveEcdsaKeypair(deriveKeyResponse);
145
+
146
+ // ED25519 Key
147
+ const ed25519Keypair = deriveEd25519Keypair(deriveKeyResponse);
148
+
149
+ logger.log('ECDSA Key Derived Successfully!');
150
+ logger.log({ address: ecdsaKeypair.address }, 'ECDSA Keypair:');
151
+ logger.log({ publicKey: ed25519Keypair.publicKey }, 'ED25519 Keypair:');
152
+
153
+ const signature = await ecdsaKeypair.signMessage({ message: 'Hello, world!' });
154
+ logger.log({ signature }, 'Sign message w/ ECDSA keypair: Hello world!, Signature:');
155
+ } catch (error) {
156
+ // Handle TEE connection errors gracefully
157
+ if (isTeeConnectionError(error)) {
158
+ logger.warn('TEE daemon not available - running in non-TEE mode for testing');
159
+ logger.warn('To run with TEE, ensure tappd is running at /var/run/tappd.sock');
160
+ } else {
161
+ logger.warn({ error }, 'TEE daemon connection failed, running in non-TEE mode:');
162
+ }
163
+ // Continue without TEE functionality for testing
164
+ }
165
+ };
166
+
167
+ /**
168
+ * Starts the TEE starter service using functional approach
169
+ */
170
+ const startTeeService = async (runtime: IAgentRuntime): Promise<TeeServiceConfig> => {
171
+ logger.info("*** Starting Mr. TEE's custom service (Functional) ***");
172
+
173
+ const config = createTeeServiceConfig(runtime);
174
+ await handleTeeKeyDerivation(config);
175
+
176
+ return config;
177
+ };
178
+
179
+ /**
180
+ * Stops the TEE starter service using functional approach
181
+ */
182
+ const stopTeeService = async (runtime: IAgentRuntime): Promise<void> => {
183
+ logger.info("*** Stopping Mr. TEE's custom service (Functional) ***");
184
+ // In functional approach, cleanup is handled here if needed
185
+ // No explicit service instance to stop
186
+ };
187
+
188
+ /**
189
+ * StarterService class for TEE functionality
190
+ */
31
191
  export class StarterService extends Service {
32
- static serviceType = 'starter';
33
- capabilityDescription = 'This is a starter service, can be customized for Mr. TEE.';
34
- private teeClient: TappdClient;
35
- private secretSalt: string;
36
- constructor(protected runtime: IAgentRuntime) {
192
+ public static serviceType = 'starter';
193
+
194
+ constructor(runtime: IAgentRuntime) {
37
195
  super(runtime);
38
- this.teeClient = new TappdClient();
39
- this.secretSalt = process.env.WALLET_SECRET_SALT || 'secret_salt';
40
196
  }
41
197
 
42
- static async start(runtime: IAgentRuntime) {
43
- logger.info("*** Starting Mr. TEE's custom service (StarterService) ***");
198
+ static async start(runtime: IAgentRuntime): Promise<StarterService> {
44
199
  const service = new StarterService(runtime);
45
- try {
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
- }
200
+ await startTeeService(runtime);
77
201
  return service;
78
202
  }
79
203
 
80
- static async stop(runtime: IAgentRuntime) {
81
- logger.info("*** Stopping Mr. TEE's custom service (StarterService) ***");
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();
204
+ async stop(): Promise<void> {
205
+ await stopTeeService(this.runtime);
87
206
  }
88
207
 
89
- async stop() {
90
- logger.info("*** Stopping Mr. TEE's custom service instance (StarterService) ***");
208
+ public get capabilityDescription(): string {
209
+ return 'This is a starter service, can be customized for Mr. TEE.';
91
210
  }
92
211
  }
93
212
 
@@ -96,12 +215,42 @@ const teeStarterPlugin: Plugin = {
96
215
  description: "Mr. TEE's starter plugin - using plugin-tee for attestation",
97
216
  config: {
98
217
  TEE_MODE: process.env.TEE_MODE,
218
+ TEE_VENDOR: process.env.TEE_VENDOR,
99
219
  WALLET_SECRET_SALT: process.env.WALLET_SECRET_SALT,
100
220
  },
101
- async init(config: Record<string, string>) {
221
+ async init(config: Record<string, string>, runtime: IAgentRuntime) {
102
222
  logger.info('*** Initializing Mr. TEE plugin ***');
103
223
  try {
104
- const validatedConfig = await configSchema.parseAsync(config);
224
+ // Merge process.env values with config, config takes precedence
225
+ const mergedConfig = {
226
+ TEE_MODE: config.TEE_MODE ?? process.env.TEE_MODE,
227
+ TEE_VENDOR: config.TEE_VENDOR ?? process.env.TEE_VENDOR,
228
+ WALLET_SECRET_SALT: config.WALLET_SECRET_SALT ?? process.env.WALLET_SECRET_SALT,
229
+ };
230
+
231
+ // Apply test defaults if in test environment
232
+ const isTestEnvironment = process.env.NODE_ENV === 'test' || process.argv.includes('test');
233
+
234
+ if (isTestEnvironment) {
235
+ // Apply test-only defaults - NEVER use these in production
236
+ mergedConfig.TEE_MODE = mergedConfig.TEE_MODE || 'OFF';
237
+ mergedConfig.TEE_VENDOR = mergedConfig.TEE_VENDOR || 'phala';
238
+ // Test salt - this is ONLY for test environments and should NEVER be used in production
239
+ mergedConfig.WALLET_SECRET_SALT =
240
+ mergedConfig.WALLET_SECRET_SALT || 'test_default_salt_12345';
241
+ }
242
+
243
+ const validatedConfig = await configSchema.parseAsync(mergedConfig);
244
+
245
+ // Production safety check - ensure test defaults aren't used in production
246
+ if (
247
+ process.env.NODE_ENV === 'production' &&
248
+ validatedConfig.WALLET_SECRET_SALT === 'test_default_salt_12345'
249
+ ) {
250
+ throw new Error(
251
+ 'CRITICAL: Test salt detected in production environment. Please provide a secure WALLET_SECRET_SALT.'
252
+ );
253
+ }
105
254
 
106
255
  // Set all environment variables at once
107
256
  for (const [key, value] of Object.entries(validatedConfig)) {
@@ -132,13 +281,28 @@ const teeStarterPlugin: Plugin = {
132
281
  });
133
282
  },
134
283
  },
284
+ {
285
+ name: 'TEE Status',
286
+ path: '/public/tee-status',
287
+ type: 'GET',
288
+ handler: async (
289
+ _req: Record<string, unknown>,
290
+ res: { json: (data: Record<string, unknown>) => void }
291
+ ) => {
292
+ res.json({
293
+ status: 'active',
294
+ tee_enabled: process.env.TEE_MODE !== 'OFF',
295
+ vendor: process.env.TEE_VENDOR || 'phala',
296
+ });
297
+ },
298
+ },
135
299
  ],
136
300
  events: {
137
301
  MESSAGE_RECEIVED: [
138
302
  async (params) => {
139
303
  logger.info(
140
- '[MR_TEE_PLUGIN] MESSAGE_RECEIVED event',
141
- params.message?.content?.text?.substring(0, 50)
304
+ { preview: params.message?.content?.text?.substring(0, 50) },
305
+ '[MR_TEE_PLUGIN] MESSAGE_RECEIVED event'
142
306
  );
143
307
  },
144
308
  ],
@@ -159,9 +323,7 @@ const teeStarterPlugin: Plugin = {
159
323
  ],
160
324
  },
161
325
  // Enable this service to run when TEE mode is enabled
162
- services: [
163
- /* StarterService */
164
- ],
326
+ services: [StarterService],
165
327
  actions: [],
166
328
  providers: [],
167
329
  };
@@ -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": false,
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: true,
8
+ clean: false,
9
9
  format: ['esm'], // Ensure you're targeting CommonJS
10
- dts: false, // Skip DTS generation to avoid external import issues // Ensure you're targeting CommonJS
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
+ });
@@ -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
- };