@elizaos/cli 1.0.11 → 1.0.13
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 +93 -58
- package/dist/assets/{index-Cuyjmso1.js → index-D7iwnDvJ.js} +49286 -45738
- package/dist/assets/{index-Cuyjmso1.js.map → index-D7iwnDvJ.js.map} +1 -1
- package/dist/assets/index-Hst_nvMK.css +1 -0
- package/dist/assets/index-Hst_nvMK.css.br +0 -0
- package/dist/assets/{index-poChVCDJ.js → index-ojKLjt7K.js} +2 -2
- package/dist/assets/index-ojKLjt7K.js.br +0 -0
- package/dist/assets/{index-poChVCDJ.js.map → index-ojKLjt7K.js.map} +1 -1
- package/dist/assets/vendor-DSdxb8P-.js.map +1 -1
- package/dist/chunk-AQ6OMR2A.js +14 -0
- package/dist/{chunk-HBV76MGW.js → chunk-ELCESP3O.js} +242 -23
- package/dist/chunk-KB3JDWUI.js +106 -0
- package/dist/{chunk-TPLM6M7M.js → chunk-RTJ2B547.js} +31 -8
- package/dist/chunk-WP6OGNZE.js +5859 -0
- package/dist/commands/agent/actions/index.d.ts +2 -2
- package/dist/commands/agent/actions/index.js +3 -3
- package/dist/commands/agent/index.js +3 -3
- package/dist/commands/create/actions/index.d.ts +8 -4
- package/dist/commands/create/actions/index.js +6 -4
- package/dist/commands/create/index.js +5 -5
- package/dist/commands/shared/index.js +1 -1
- package/dist/index.html +2 -2
- package/dist/index.js +707 -7831
- package/dist/migrator-UQ4XFYE5.js +744 -0
- package/dist/{plugin-creator-T4K2673C.js → plugin-creator-TLQLTQIB.js} +8 -11
- package/dist/{registry-PTOPJQEB.js → registry-MJQMACYE.js} +3 -3
- package/dist/templates/plugin-starter/bunfig.toml +5 -1
- package/dist/templates/plugin-starter/package.json +6 -8
- package/dist/templates/plugin-starter/scripts/install-test-deps.js +50 -0
- package/dist/templates/plugin-starter/src/index.ts +2 -272
- package/dist/templates/plugin-starter/src/plugin.ts +274 -0
- package/dist/templates/project-starter/bunfig.toml +13 -1
- package/dist/templates/project-starter/package.json +14 -20
- package/dist/templates/project-starter/scripts/install-test-deps.js +51 -0
- package/dist/templates/project-starter/src/__tests__/config.test.ts +9 -9
- package/dist/templates/project-starter/src/__tests__/error-handling.test.ts +11 -11
- package/dist/templates/project-starter/src/__tests__/events.test.ts +6 -6
- package/dist/templates/project-starter/src/__tests__/integration.test.ts +11 -11
- package/dist/templates/project-starter/src/__tests__/routes.test.ts +2 -2
- package/dist/templates/project-starter/src/character.ts +134 -0
- package/dist/templates/project-starter/src/index.ts +3 -133
- package/dist/templates/project-starter/tsconfig.json +2 -2
- package/dist/templates/project-tee-starter/__tests__/env.test.ts +10 -6
- package/dist/templates/project-tee-starter/bunfig.toml +13 -1
- package/dist/templates/project-tee-starter/e2e/project.test.ts +1 -1
- package/dist/templates/project-tee-starter/e2e/starter-plugin.test.ts +1 -1
- package/dist/templates/project-tee-starter/package.json +3 -3
- package/dist/templates/project-tee-starter/src/index.ts +2 -15
- package/dist/{utils-TDE6Y3CB.js → utils-JWYJVLQ4.js} +15 -3
- package/package.json +28 -57
- package/templates/plugin-starter/bunfig.toml +5 -1
- package/templates/plugin-starter/package.json +6 -8
- package/templates/plugin-starter/scripts/install-test-deps.js +50 -0
- package/templates/plugin-starter/src/index.ts +2 -272
- package/templates/plugin-starter/src/plugin.ts +274 -0
- package/templates/project-starter/bunfig.toml +13 -1
- package/templates/project-starter/package.json +14 -20
- package/templates/project-starter/scripts/install-test-deps.js +51 -0
- package/templates/project-starter/src/__tests__/config.test.ts +9 -9
- package/templates/project-starter/src/__tests__/error-handling.test.ts +11 -11
- package/templates/project-starter/src/__tests__/events.test.ts +6 -6
- package/templates/project-starter/src/__tests__/integration.test.ts +11 -11
- package/templates/project-starter/src/__tests__/routes.test.ts +2 -2
- package/templates/project-starter/src/character.ts +134 -0
- package/templates/project-starter/src/index.ts +3 -133
- package/templates/project-starter/tsconfig.json +2 -2
- package/templates/project-tee-starter/__tests__/env.test.ts +10 -6
- package/templates/project-tee-starter/bunfig.toml +13 -1
- package/templates/project-tee-starter/e2e/project.test.ts +1 -1
- package/templates/project-tee-starter/e2e/starter-plugin.test.ts +1 -1
- package/templates/project-tee-starter/package.json +3 -3
- package/templates/project-tee-starter/src/index.ts +2 -15
- package/dist/assets/index-Df1AFSuJ.css +0 -1
- package/dist/assets/index-Df1AFSuJ.css.br +0 -0
- package/dist/assets/index-poChVCDJ.js.br +0 -0
- package/dist/chunk-2GXSCVA2.js +0 -2057
- package/dist/chunk-567UPUC7.js +0 -52
- package/dist/chunk-LQ6XHF53.js +0 -19487
- package/dist/chunk-QLKBXRME.js +0 -11101
- package/dist/chunk-WS4DWCDZ.js +0 -892
- package/dist/fileFromPath-KB6XMTJ4.js +0 -133
- package/dist/migrator-JREQPDN3.js +0 -7523
- package/dist/pglite.data +0 -0
- package/dist/pglite.wasm +0 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { existsSync, readFileSync } from 'fs';
|
|
4
|
+
import { execSync } from 'child_process';
|
|
5
|
+
import { join } from 'path';
|
|
6
|
+
|
|
7
|
+
const testDependencies = {
|
|
8
|
+
'@cypress/react': '^9.0.1',
|
|
9
|
+
'@testing-library/cypress': '^10.0.3',
|
|
10
|
+
cypress: '^14.4.1',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function isInstalled(packageName) {
|
|
14
|
+
try {
|
|
15
|
+
const packageJsonPath = join(process.cwd(), 'package.json');
|
|
16
|
+
if (existsSync(packageJsonPath)) {
|
|
17
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
18
|
+
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
19
|
+
return packageName in deps;
|
|
20
|
+
}
|
|
21
|
+
} catch (error) {
|
|
22
|
+
// Silent fail, will install if error
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function installTestDependencies() {
|
|
28
|
+
const missingDeps = Object.entries(testDependencies)
|
|
29
|
+
.filter(([name]) => !isInstalled(name))
|
|
30
|
+
.map(([name, version]) => `${name}@${version}`);
|
|
31
|
+
|
|
32
|
+
if (missingDeps.length === 0) {
|
|
33
|
+
console.log('✓ Test dependencies already installed');
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
console.log('Installing test dependencies...');
|
|
38
|
+
try {
|
|
39
|
+
execSync(`bun add -d ${missingDeps.join(' ')}`, {
|
|
40
|
+
stdio: 'inherit',
|
|
41
|
+
cwd: process.cwd(),
|
|
42
|
+
});
|
|
43
|
+
console.log('✓ Test dependencies installed successfully');
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error('Failed to install test dependencies:', error.message);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
installTestDependencies();
|
|
@@ -1,274 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
type Action,
|
|
4
|
-
type Content,
|
|
5
|
-
type GenerateTextParams,
|
|
6
|
-
type HandlerCallback,
|
|
7
|
-
type IAgentRuntime,
|
|
8
|
-
type Memory,
|
|
9
|
-
ModelType,
|
|
10
|
-
type Provider,
|
|
11
|
-
type ProviderResult,
|
|
12
|
-
Service,
|
|
13
|
-
type State,
|
|
14
|
-
logger,
|
|
15
|
-
} from '@elizaos/core';
|
|
16
|
-
import { z } from 'zod';
|
|
17
|
-
import { StarterPluginTestSuite } from './tests';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Defines the configuration schema for a plugin, including the validation rules for the plugin name.
|
|
21
|
-
*
|
|
22
|
-
* @type {import('zod').ZodObject<{ EXAMPLE_PLUGIN_VARIABLE: import('zod').ZodString }>}
|
|
23
|
-
*/
|
|
24
|
-
const configSchema = z.object({
|
|
25
|
-
EXAMPLE_PLUGIN_VARIABLE: z
|
|
26
|
-
.string()
|
|
27
|
-
.min(1, 'Example plugin variable is not provided')
|
|
28
|
-
.optional()
|
|
29
|
-
.transform((val) => {
|
|
30
|
-
if (!val) {
|
|
31
|
-
logger.warn('Example plugin variable is not provided (this is expected)');
|
|
32
|
-
}
|
|
33
|
-
return val;
|
|
34
|
-
}),
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Example HelloWorld action
|
|
39
|
-
* This demonstrates the simplest possible action structure
|
|
40
|
-
*/
|
|
41
|
-
/**
|
|
42
|
-
* Action representing a hello world message.
|
|
43
|
-
* @typedef {Object} Action
|
|
44
|
-
* @property {string} name - The name of the action.
|
|
45
|
-
* @property {string[]} similes - An array of related actions.
|
|
46
|
-
* @property {string} description - A brief description of the action.
|
|
47
|
-
* @property {Function} validate - Asynchronous function to validate the action.
|
|
48
|
-
* @property {Function} handler - Asynchronous function to handle the action and generate a response.
|
|
49
|
-
* @property {Object[]} examples - An array of example inputs and expected outputs for the action.
|
|
50
|
-
*/
|
|
51
|
-
const helloWorldAction: Action = {
|
|
52
|
-
name: 'HELLO_WORLD',
|
|
53
|
-
similes: ['GREET', 'SAY_HELLO'],
|
|
54
|
-
description: 'Responds with a simple hello world message',
|
|
55
|
-
|
|
56
|
-
validate: async (
|
|
57
|
-
_runtime: IAgentRuntime,
|
|
58
|
-
_message: Memory,
|
|
59
|
-
_state: State | undefined
|
|
60
|
-
): Promise<boolean> => {
|
|
61
|
-
// Always valid
|
|
62
|
-
return true;
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
handler: async (
|
|
66
|
-
_runtime: IAgentRuntime,
|
|
67
|
-
message: Memory,
|
|
68
|
-
_state: State | undefined,
|
|
69
|
-
_options: any,
|
|
70
|
-
callback?: HandlerCallback,
|
|
71
|
-
_responses?: Memory[]
|
|
72
|
-
) => {
|
|
73
|
-
try {
|
|
74
|
-
logger.info('Handling HELLO_WORLD action');
|
|
75
|
-
|
|
76
|
-
// Simple response content
|
|
77
|
-
const responseContent: Content = {
|
|
78
|
-
text: 'hello world!',
|
|
79
|
-
actions: ['HELLO_WORLD'],
|
|
80
|
-
source: message.content.source,
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
// Call back with the hello world message if callback is provided
|
|
84
|
-
if (callback) {
|
|
85
|
-
await callback(responseContent);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return responseContent;
|
|
89
|
-
} catch (error) {
|
|
90
|
-
logger.error('Error in HELLO_WORLD action:', error);
|
|
91
|
-
throw error;
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
examples: [
|
|
96
|
-
[
|
|
97
|
-
{
|
|
98
|
-
name: '{{name1}}',
|
|
99
|
-
content: {
|
|
100
|
-
text: 'Can you say hello?',
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
name: '{{name2}}',
|
|
105
|
-
content: {
|
|
106
|
-
text: 'hello world!',
|
|
107
|
-
actions: ['HELLO_WORLD'],
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
],
|
|
111
|
-
],
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Example Hello World Provider
|
|
116
|
-
* This demonstrates the simplest possible provider implementation
|
|
117
|
-
*/
|
|
118
|
-
const helloWorldProvider: Provider = {
|
|
119
|
-
name: 'HELLO_WORLD_PROVIDER',
|
|
120
|
-
description: 'A simple example provider',
|
|
121
|
-
|
|
122
|
-
get: async (
|
|
123
|
-
_runtime: IAgentRuntime,
|
|
124
|
-
_message: Memory,
|
|
125
|
-
_state: State | undefined
|
|
126
|
-
): Promise<ProviderResult> => {
|
|
127
|
-
return {
|
|
128
|
-
text: 'I am a provider',
|
|
129
|
-
values: {},
|
|
130
|
-
data: {},
|
|
131
|
-
};
|
|
132
|
-
},
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
export class StarterService extends Service {
|
|
136
|
-
static serviceType = 'starter';
|
|
137
|
-
capabilityDescription =
|
|
138
|
-
'This is a starter service which is attached to the agent through the starter plugin.';
|
|
139
|
-
constructor(protected runtime: IAgentRuntime) {
|
|
140
|
-
super(runtime);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
static async start(runtime: IAgentRuntime) {
|
|
144
|
-
logger.info(`*** Starting starter service - MODIFIED: ${new Date().toISOString()} ***`);
|
|
145
|
-
const service = new StarterService(runtime);
|
|
146
|
-
return service;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
static async stop(runtime: IAgentRuntime) {
|
|
150
|
-
logger.info('*** TESTING DEV MODE - STOP MESSAGE CHANGED! ***');
|
|
151
|
-
// get the service from the runtime
|
|
152
|
-
const service = runtime.getService(StarterService.serviceType);
|
|
153
|
-
if (!service) {
|
|
154
|
-
throw new Error('Starter service not found');
|
|
155
|
-
}
|
|
156
|
-
service.stop();
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
async stop() {
|
|
160
|
-
logger.info('*** THIRD CHANGE - TESTING FILE WATCHING! ***');
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export const starterPlugin: Plugin = {
|
|
165
|
-
name: 'plugin-starter',
|
|
166
|
-
description: 'Plugin starter for elizaOS',
|
|
167
|
-
config: {
|
|
168
|
-
EXAMPLE_PLUGIN_VARIABLE: process.env.EXAMPLE_PLUGIN_VARIABLE,
|
|
169
|
-
},
|
|
170
|
-
async init(config: Record<string, string>) {
|
|
171
|
-
logger.info('*** TESTING DEV MODE - PLUGIN MODIFIED AND RELOADED! ***');
|
|
172
|
-
try {
|
|
173
|
-
const validatedConfig = await configSchema.parseAsync(config);
|
|
174
|
-
|
|
175
|
-
// Set all environment variables at once
|
|
176
|
-
for (const [key, value] of Object.entries(validatedConfig)) {
|
|
177
|
-
if (value) process.env[key] = value;
|
|
178
|
-
}
|
|
179
|
-
} catch (error) {
|
|
180
|
-
if (error instanceof z.ZodError) {
|
|
181
|
-
throw new Error(
|
|
182
|
-
`Invalid plugin configuration: ${error.errors.map((e) => e.message).join(', ')}`
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
throw error;
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
models: {
|
|
189
|
-
[ModelType.TEXT_SMALL]: async (
|
|
190
|
-
_runtime,
|
|
191
|
-
{ prompt, stopSequences = [] }: GenerateTextParams
|
|
192
|
-
) => {
|
|
193
|
-
return 'Never gonna give you up, never gonna let you down, never gonna run around and desert you...';
|
|
194
|
-
},
|
|
195
|
-
[ModelType.TEXT_LARGE]: async (
|
|
196
|
-
_runtime,
|
|
197
|
-
{
|
|
198
|
-
prompt,
|
|
199
|
-
stopSequences = [],
|
|
200
|
-
maxTokens = 8192,
|
|
201
|
-
temperature = 0.7,
|
|
202
|
-
frequencyPenalty = 0.7,
|
|
203
|
-
presencePenalty = 0.7,
|
|
204
|
-
}: GenerateTextParams
|
|
205
|
-
) => {
|
|
206
|
-
return 'Never gonna make you cry, never gonna say goodbye, never gonna tell a lie and hurt you...';
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
routes: [
|
|
210
|
-
{
|
|
211
|
-
name: 'hello-world-route',
|
|
212
|
-
path: '/helloworld',
|
|
213
|
-
type: 'GET',
|
|
214
|
-
handler: async (_req: any, res: any) => {
|
|
215
|
-
// send a response
|
|
216
|
-
res.json({
|
|
217
|
-
message: 'Hello World!',
|
|
218
|
-
});
|
|
219
|
-
},
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
name: 'current-time-route',
|
|
223
|
-
path: '/api/time',
|
|
224
|
-
type: 'GET',
|
|
225
|
-
handler: async (_req: any, res: any) => {
|
|
226
|
-
// Return current time in various formats
|
|
227
|
-
const now = new Date();
|
|
228
|
-
res.json({
|
|
229
|
-
timestamp: now.toISOString(),
|
|
230
|
-
unix: Math.floor(now.getTime() / 1000),
|
|
231
|
-
formatted: now.toLocaleString(),
|
|
232
|
-
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
233
|
-
});
|
|
234
|
-
},
|
|
235
|
-
},
|
|
236
|
-
],
|
|
237
|
-
events: {
|
|
238
|
-
MESSAGE_RECEIVED: [
|
|
239
|
-
async (params) => {
|
|
240
|
-
logger.debug('MESSAGE_RECEIVED event received');
|
|
241
|
-
// print the keys
|
|
242
|
-
logger.debug(Object.keys(params));
|
|
243
|
-
},
|
|
244
|
-
],
|
|
245
|
-
VOICE_MESSAGE_RECEIVED: [
|
|
246
|
-
async (params) => {
|
|
247
|
-
logger.debug('VOICE_MESSAGE_RECEIVED event received');
|
|
248
|
-
// print the keys
|
|
249
|
-
logger.debug(Object.keys(params));
|
|
250
|
-
},
|
|
251
|
-
],
|
|
252
|
-
WORLD_CONNECTED: [
|
|
253
|
-
async (params) => {
|
|
254
|
-
logger.debug('WORLD_CONNECTED event received');
|
|
255
|
-
// print the keys
|
|
256
|
-
logger.debug(Object.keys(params));
|
|
257
|
-
},
|
|
258
|
-
],
|
|
259
|
-
WORLD_JOINED: [
|
|
260
|
-
async (params) => {
|
|
261
|
-
logger.debug('WORLD_JOINED event received');
|
|
262
|
-
// print the keys
|
|
263
|
-
logger.debug(Object.keys(params));
|
|
264
|
-
},
|
|
265
|
-
],
|
|
266
|
-
},
|
|
267
|
-
services: [StarterService],
|
|
268
|
-
actions: [helloWorldAction],
|
|
269
|
-
providers: [helloWorldProvider],
|
|
270
|
-
tests: [StarterPluginTestSuite],
|
|
271
|
-
// dependencies: ['@elizaos/plugin-knowledge'], <--- plugin dependecies go here (if requires another plugin)
|
|
272
|
-
};
|
|
1
|
+
import { starterPlugin } from './plugin';
|
|
273
2
|
|
|
3
|
+
export { starterPlugin, StarterService } from './plugin';
|
|
274
4
|
export default starterPlugin;
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import type { Plugin } from '@elizaos/core';
|
|
2
|
+
import {
|
|
3
|
+
type Action,
|
|
4
|
+
type Content,
|
|
5
|
+
type GenerateTextParams,
|
|
6
|
+
type HandlerCallback,
|
|
7
|
+
type IAgentRuntime,
|
|
8
|
+
type Memory,
|
|
9
|
+
ModelType,
|
|
10
|
+
type Provider,
|
|
11
|
+
type ProviderResult,
|
|
12
|
+
Service,
|
|
13
|
+
type State,
|
|
14
|
+
logger,
|
|
15
|
+
} from '@elizaos/core';
|
|
16
|
+
import { z } from 'zod';
|
|
17
|
+
import { StarterPluginTestSuite } from './tests';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Defines the configuration schema for a plugin, including the validation rules for the plugin name.
|
|
21
|
+
*
|
|
22
|
+
* @type {import('zod').ZodObject<{ EXAMPLE_PLUGIN_VARIABLE: import('zod').ZodString }>}
|
|
23
|
+
*/
|
|
24
|
+
const configSchema = z.object({
|
|
25
|
+
EXAMPLE_PLUGIN_VARIABLE: z
|
|
26
|
+
.string()
|
|
27
|
+
.min(1, 'Example plugin variable is not provided')
|
|
28
|
+
.optional()
|
|
29
|
+
.transform((val) => {
|
|
30
|
+
if (!val) {
|
|
31
|
+
logger.warn('Example plugin variable is not provided (this is expected)');
|
|
32
|
+
}
|
|
33
|
+
return val;
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Example HelloWorld action
|
|
39
|
+
* This demonstrates the simplest possible action structure
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* Action representing a hello world message.
|
|
43
|
+
* @typedef {Object} Action
|
|
44
|
+
* @property {string} name - The name of the action.
|
|
45
|
+
* @property {string[]} similes - An array of related actions.
|
|
46
|
+
* @property {string} description - A brief description of the action.
|
|
47
|
+
* @property {Function} validate - Asynchronous function to validate the action.
|
|
48
|
+
* @property {Function} handler - Asynchronous function to handle the action and generate a response.
|
|
49
|
+
* @property {Object[]} examples - An array of example inputs and expected outputs for the action.
|
|
50
|
+
*/
|
|
51
|
+
const helloWorldAction: Action = {
|
|
52
|
+
name: 'HELLO_WORLD',
|
|
53
|
+
similes: ['GREET', 'SAY_HELLO'],
|
|
54
|
+
description: 'Responds with a simple hello world message',
|
|
55
|
+
|
|
56
|
+
validate: async (
|
|
57
|
+
_runtime: IAgentRuntime,
|
|
58
|
+
_message: Memory,
|
|
59
|
+
_state: State | undefined
|
|
60
|
+
): Promise<boolean> => {
|
|
61
|
+
// Always valid
|
|
62
|
+
return true;
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
handler: async (
|
|
66
|
+
_runtime: IAgentRuntime,
|
|
67
|
+
message: Memory,
|
|
68
|
+
_state: State | undefined,
|
|
69
|
+
_options: any,
|
|
70
|
+
callback?: HandlerCallback,
|
|
71
|
+
_responses?: Memory[]
|
|
72
|
+
) => {
|
|
73
|
+
try {
|
|
74
|
+
logger.info('Handling HELLO_WORLD action');
|
|
75
|
+
|
|
76
|
+
// Simple response content
|
|
77
|
+
const responseContent: Content = {
|
|
78
|
+
text: 'hello world!',
|
|
79
|
+
actions: ['HELLO_WORLD'],
|
|
80
|
+
source: message.content.source,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// Call back with the hello world message if callback is provided
|
|
84
|
+
if (callback) {
|
|
85
|
+
await callback(responseContent);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return responseContent;
|
|
89
|
+
} catch (error) {
|
|
90
|
+
logger.error('Error in HELLO_WORLD action:', error);
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
examples: [
|
|
96
|
+
[
|
|
97
|
+
{
|
|
98
|
+
name: '{{name1}}',
|
|
99
|
+
content: {
|
|
100
|
+
text: 'Can you say hello?',
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: '{{name2}}',
|
|
105
|
+
content: {
|
|
106
|
+
text: 'hello world!',
|
|
107
|
+
actions: ['HELLO_WORLD'],
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
],
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Example Hello World Provider
|
|
116
|
+
* This demonstrates the simplest possible provider implementation
|
|
117
|
+
*/
|
|
118
|
+
const helloWorldProvider: Provider = {
|
|
119
|
+
name: 'HELLO_WORLD_PROVIDER',
|
|
120
|
+
description: 'A simple example provider',
|
|
121
|
+
|
|
122
|
+
get: async (
|
|
123
|
+
_runtime: IAgentRuntime,
|
|
124
|
+
_message: Memory,
|
|
125
|
+
_state: State | undefined
|
|
126
|
+
): Promise<ProviderResult> => {
|
|
127
|
+
return {
|
|
128
|
+
text: 'I am a provider',
|
|
129
|
+
values: {},
|
|
130
|
+
data: {},
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export class StarterService extends Service {
|
|
136
|
+
static serviceType = 'starter';
|
|
137
|
+
capabilityDescription =
|
|
138
|
+
'This is a starter service which is attached to the agent through the starter plugin.';
|
|
139
|
+
constructor(protected runtime: IAgentRuntime) {
|
|
140
|
+
super(runtime);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
static async start(runtime: IAgentRuntime) {
|
|
144
|
+
logger.info(`*** Starting starter service - MODIFIED: ${new Date().toISOString()} ***`);
|
|
145
|
+
const service = new StarterService(runtime);
|
|
146
|
+
return service;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
static async stop(runtime: IAgentRuntime) {
|
|
150
|
+
logger.info('*** TESTING DEV MODE - STOP MESSAGE CHANGED! ***');
|
|
151
|
+
// get the service from the runtime
|
|
152
|
+
const service = runtime.getService(StarterService.serviceType);
|
|
153
|
+
if (!service) {
|
|
154
|
+
throw new Error('Starter service not found');
|
|
155
|
+
}
|
|
156
|
+
service.stop();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async stop() {
|
|
160
|
+
logger.info('*** THIRD CHANGE - TESTING FILE WATCHING! ***');
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export const starterPlugin: Plugin = {
|
|
165
|
+
name: 'plugin-starter',
|
|
166
|
+
description: 'Plugin starter for elizaOS',
|
|
167
|
+
config: {
|
|
168
|
+
EXAMPLE_PLUGIN_VARIABLE: process.env.EXAMPLE_PLUGIN_VARIABLE,
|
|
169
|
+
},
|
|
170
|
+
async init(config: Record<string, string>) {
|
|
171
|
+
logger.info('*** TESTING DEV MODE - PLUGIN MODIFIED AND RELOADED! ***');
|
|
172
|
+
try {
|
|
173
|
+
const validatedConfig = await configSchema.parseAsync(config);
|
|
174
|
+
|
|
175
|
+
// Set all environment variables at once
|
|
176
|
+
for (const [key, value] of Object.entries(validatedConfig)) {
|
|
177
|
+
if (value) process.env[key] = value;
|
|
178
|
+
}
|
|
179
|
+
} catch (error) {
|
|
180
|
+
if (error instanceof z.ZodError) {
|
|
181
|
+
throw new Error(
|
|
182
|
+
`Invalid plugin configuration: ${error.errors.map((e) => e.message).join(', ')}`
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
models: {
|
|
189
|
+
[ModelType.TEXT_SMALL]: async (
|
|
190
|
+
_runtime,
|
|
191
|
+
{ prompt, stopSequences = [] }: GenerateTextParams
|
|
192
|
+
) => {
|
|
193
|
+
return 'Never gonna give you up, never gonna let you down, never gonna run around and desert you...';
|
|
194
|
+
},
|
|
195
|
+
[ModelType.TEXT_LARGE]: async (
|
|
196
|
+
_runtime,
|
|
197
|
+
{
|
|
198
|
+
prompt,
|
|
199
|
+
stopSequences = [],
|
|
200
|
+
maxTokens = 8192,
|
|
201
|
+
temperature = 0.7,
|
|
202
|
+
frequencyPenalty = 0.7,
|
|
203
|
+
presencePenalty = 0.7,
|
|
204
|
+
}: GenerateTextParams
|
|
205
|
+
) => {
|
|
206
|
+
return 'Never gonna make you cry, never gonna say goodbye, never gonna tell a lie and hurt you...';
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
routes: [
|
|
210
|
+
{
|
|
211
|
+
name: 'hello-world-route',
|
|
212
|
+
path: '/helloworld',
|
|
213
|
+
type: 'GET',
|
|
214
|
+
handler: async (_req: any, res: any) => {
|
|
215
|
+
// send a response
|
|
216
|
+
res.json({
|
|
217
|
+
message: 'Hello World!',
|
|
218
|
+
});
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
name: 'current-time-route',
|
|
223
|
+
path: '/api/time',
|
|
224
|
+
type: 'GET',
|
|
225
|
+
handler: async (_req: any, res: any) => {
|
|
226
|
+
// Return current time in various formats
|
|
227
|
+
const now = new Date();
|
|
228
|
+
res.json({
|
|
229
|
+
timestamp: now.toISOString(),
|
|
230
|
+
unix: Math.floor(now.getTime() / 1000),
|
|
231
|
+
formatted: now.toLocaleString(),
|
|
232
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
233
|
+
});
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
events: {
|
|
238
|
+
MESSAGE_RECEIVED: [
|
|
239
|
+
async (params) => {
|
|
240
|
+
logger.debug('MESSAGE_RECEIVED event received');
|
|
241
|
+
// print the keys
|
|
242
|
+
logger.debug(Object.keys(params));
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
VOICE_MESSAGE_RECEIVED: [
|
|
246
|
+
async (params) => {
|
|
247
|
+
logger.debug('VOICE_MESSAGE_RECEIVED event received');
|
|
248
|
+
// print the keys
|
|
249
|
+
logger.debug(Object.keys(params));
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
WORLD_CONNECTED: [
|
|
253
|
+
async (params) => {
|
|
254
|
+
logger.debug('WORLD_CONNECTED event received');
|
|
255
|
+
// print the keys
|
|
256
|
+
logger.debug(Object.keys(params));
|
|
257
|
+
},
|
|
258
|
+
],
|
|
259
|
+
WORLD_JOINED: [
|
|
260
|
+
async (params) => {
|
|
261
|
+
logger.debug('WORLD_JOINED event received');
|
|
262
|
+
// print the keys
|
|
263
|
+
logger.debug(Object.keys(params));
|
|
264
|
+
},
|
|
265
|
+
],
|
|
266
|
+
},
|
|
267
|
+
services: [StarterService],
|
|
268
|
+
actions: [helloWorldAction],
|
|
269
|
+
providers: [helloWorldProvider],
|
|
270
|
+
tests: [StarterPluginTestSuite],
|
|
271
|
+
// dependencies: ['@elizaos/plugin-knowledge'], <--- plugin dependecies go here (if requires another plugin)
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
export default starterPlugin;
|
|
@@ -3,4 +3,16 @@ timeout = 60000
|
|
|
3
3
|
coverage = true
|
|
4
4
|
|
|
5
5
|
[test.env]
|
|
6
|
-
NODE_ENV = "test"
|
|
6
|
+
NODE_ENV = "test"
|
|
7
|
+
|
|
8
|
+
coverage-exclude = [
|
|
9
|
+
"**/dist/**",
|
|
10
|
+
"**/build/**",
|
|
11
|
+
"**/chunk-*.js",
|
|
12
|
+
"**/*.chunk.js",
|
|
13
|
+
"**/node_modules/**",
|
|
14
|
+
"**/*.min.js",
|
|
15
|
+
"**/*.bundle.js",
|
|
16
|
+
"**/coverage/**",
|
|
17
|
+
"**/.turbo/**",
|
|
18
|
+
]
|
|
@@ -28,11 +28,8 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@elizaos/cli": "1.0.
|
|
32
|
-
"@elizaos/core": "1.0.
|
|
33
|
-
"@elizaos/plugin-bootstrap": "1.0.9",
|
|
34
|
-
"@elizaos/plugin-discord": "1.0.10",
|
|
35
|
-
"@elizaos/plugin-sql": "1.0.9",
|
|
31
|
+
"@elizaos/cli": "1.0.12",
|
|
32
|
+
"@elizaos/core": "1.0.12",
|
|
36
33
|
"@tanstack/react-query": "^5.29.0",
|
|
37
34
|
"clsx": "^2.1.1",
|
|
38
35
|
"react": "^18.3.1",
|
|
@@ -42,13 +39,9 @@
|
|
|
42
39
|
"zod": "3.24.2"
|
|
43
40
|
},
|
|
44
41
|
"devDependencies": {
|
|
45
|
-
"@cypress/react": "^9.0.1",
|
|
46
|
-
"@cypress/vite-dev-server": "^6.0.3",
|
|
47
|
-
"@testing-library/cypress": "^10.0.3",
|
|
48
42
|
"@types/react": "^18.3.3",
|
|
49
43
|
"@types/react-dom": "^18.3.0",
|
|
50
44
|
"@vitejs/plugin-react": "^4.3.1",
|
|
51
|
-
"cypress": "^14.4.1",
|
|
52
45
|
"prettier": "3.5.3",
|
|
53
46
|
"tsup": "8.5.0",
|
|
54
47
|
"typescript": "^5.6.3",
|
|
@@ -61,20 +54,21 @@
|
|
|
61
54
|
"lint": "prettier --write ./src",
|
|
62
55
|
"type-check": "tsc --noEmit",
|
|
63
56
|
"type-check:watch": "tsc --noEmit --watch",
|
|
64
|
-
"test:component": "bun test",
|
|
65
|
-
"test:e2e": "bun test",
|
|
66
|
-
"test": "bun run test:component && bun run test:e2e",
|
|
67
|
-
"test:coverage": "bun test --coverage",
|
|
68
|
-
"test:watch": "bun test --watch",
|
|
57
|
+
"test:component": "bun run test:install && bun test",
|
|
58
|
+
"test:e2e": "bun run test:install && bun test",
|
|
59
|
+
"test": "bun run test:install && bun run test:component && bun run test:e2e",
|
|
60
|
+
"test:coverage": "bun run test:install && bun test --coverage",
|
|
61
|
+
"test:watch": "bun run test:install && bun test --watch",
|
|
62
|
+
"test:install": "node scripts/install-test-deps.js",
|
|
69
63
|
"format": "prettier --write ./src",
|
|
70
64
|
"format:check": "prettier --check ./src",
|
|
71
65
|
"check-all": "bun run type-check && bun run format:check && bun run test",
|
|
72
|
-
"cy:open": "cypress open",
|
|
73
|
-
"cy:run": "cypress run --component",
|
|
74
|
-
"cy:test": "cypress run --component --reporter spec",
|
|
75
|
-
"cypress:component": "cypress run --component",
|
|
76
|
-
"cypress:e2e": "cypress run --e2e",
|
|
77
|
-
"cypress:open": "cypress open"
|
|
66
|
+
"cy:open": "bun run test:install && cypress open",
|
|
67
|
+
"cy:run": "bun run test:install && cypress run --component",
|
|
68
|
+
"cy:test": "bun run test:install && cypress run --component --reporter spec",
|
|
69
|
+
"cypress:component": "bun run test:install && cypress run --component",
|
|
70
|
+
"cypress:e2e": "bun run test:install && cypress run --e2e",
|
|
71
|
+
"cypress:open": "bun run test:install && cypress open"
|
|
78
72
|
},
|
|
79
73
|
"publishConfig": {
|
|
80
74
|
"access": "public"
|