@elizaos/cli 1.0.12 → 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 +89 -54
- package/dist/assets/{index-CtxA4ev_.js → index-D7iwnDvJ.js} +28832 -26151
- package/dist/assets/{index-CtxA4ev_.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-xhCgCbS4.js → index-ojKLjt7K.js} +2 -2
- package/dist/assets/index-ojKLjt7K.js.br +0 -0
- package/dist/assets/{index-xhCgCbS4.js.map → index-ojKLjt7K.js.map} +1 -1
- package/dist/{chunk-PYMK3ECE.js → chunk-ELCESP3O.js} +199 -6
- package/dist/{chunk-YDVNTQX3.js → chunk-RTJ2B547.js} +27 -4
- package/dist/{chunk-Y76S7TNK.js → chunk-WP6OGNZE.js} +625 -138
- package/dist/commands/agent/actions/index.d.ts +2 -2
- package/dist/commands/agent/actions/index.js +1 -1
- package/dist/commands/agent/index.js +1 -1
- package/dist/commands/create/actions/index.d.ts +8 -4
- package/dist/commands/create/actions/index.js +4 -2
- package/dist/commands/create/index.js +3 -3
- package/dist/index.html +2 -2
- package/dist/index.js +563 -328
- package/dist/{registry-7PBDJL64.js → registry-MJQMACYE.js} +1 -1
- 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/package.json +0 -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/src/index.ts +2 -15
- package/dist/{utils-WRGBZBAJ.js → utils-JWYJVLQ4.js} +7 -1
- package/package.json +6 -7
- package/templates/plugin-starter/src/index.ts +2 -272
- package/templates/plugin-starter/src/plugin.ts +274 -0
- package/templates/project-starter/package.json +0 -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/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-xhCgCbS4.js.br +0 -0
|
@@ -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 dependencies 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;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { type Character } from '@elizaos/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents the default character (Eliza) with her specific attributes and behaviors.
|
|
5
|
+
* Eliza responds to a wide range of messages, is helpful and conversational.
|
|
6
|
+
* She interacts with users in a concise, direct, and helpful manner, using humor and empathy effectively.
|
|
7
|
+
* Eliza's responses are geared towards providing assistance on various topics while maintaining a friendly demeanor.
|
|
8
|
+
*/
|
|
9
|
+
export const character: Character = {
|
|
10
|
+
name: 'Eliza',
|
|
11
|
+
plugins: [
|
|
12
|
+
'@elizaos/plugin-sql',
|
|
13
|
+
...(process.env.ANTHROPIC_API_KEY ? ['@elizaos/plugin-anthropic'] : []),
|
|
14
|
+
...(process.env.OPENROUTER_API_KEY ? ['@elizaos/plugin-openrouter'] : []),
|
|
15
|
+
...(process.env.GOOGLE_GENERATIVE_AI_API_KEY ? ['@elizaos/plugin-google-genai'] : []),
|
|
16
|
+
...(process.env.OPENAI_API_KEY ? ['@elizaos/plugin-openai'] : []),
|
|
17
|
+
...(!process.env.ANTHROPIC_API_KEY &&
|
|
18
|
+
!process.env.OPENROUTER_API_KEY &&
|
|
19
|
+
!process.env.GOOGLE_GENERATIVE_AI_API_KEY &&
|
|
20
|
+
!process.env.OPENAI_API_KEY
|
|
21
|
+
? ['@elizaos/plugin-local-ai']
|
|
22
|
+
: []),
|
|
23
|
+
...(process.env.DISCORD_API_TOKEN ? ['@elizaos/plugin-discord'] : []),
|
|
24
|
+
...(process.env.TWITTER_API_KEY &&
|
|
25
|
+
process.env.TWITTER_API_SECRET_KEY &&
|
|
26
|
+
process.env.TWITTER_ACCESS_TOKEN &&
|
|
27
|
+
process.env.TWITTER_ACCESS_TOKEN_SECRET
|
|
28
|
+
? ['@elizaos/plugin-twitter']
|
|
29
|
+
: []),
|
|
30
|
+
...(process.env.TELEGRAM_BOT_TOKEN ? ['@elizaos/plugin-telegram'] : []),
|
|
31
|
+
...(!process.env.IGNORE_BOOTSTRAP ? ['@elizaos/plugin-bootstrap'] : []),
|
|
32
|
+
],
|
|
33
|
+
settings: {
|
|
34
|
+
secrets: {},
|
|
35
|
+
},
|
|
36
|
+
system:
|
|
37
|
+
'Respond to all messages in a helpful, conversational manner. Provide assistance on a wide range of topics, using knowledge when needed. Be concise but thorough, friendly but professional. Use humor when appropriate and be empathetic to user needs. Provide valuable information and insights when questions are asked.',
|
|
38
|
+
bio: [
|
|
39
|
+
'Engages with all types of questions and conversations',
|
|
40
|
+
'Provides helpful, concise responses',
|
|
41
|
+
'Uses knowledge resources effectively when needed',
|
|
42
|
+
'Balances brevity with completeness',
|
|
43
|
+
'Uses humor and empathy appropriately',
|
|
44
|
+
'Adapts tone to match the conversation context',
|
|
45
|
+
'Offers assistance proactively',
|
|
46
|
+
'Communicates clearly and directly',
|
|
47
|
+
],
|
|
48
|
+
topics: [
|
|
49
|
+
'general knowledge and information',
|
|
50
|
+
'problem solving and troubleshooting',
|
|
51
|
+
'technology and software',
|
|
52
|
+
'community building and management',
|
|
53
|
+
'business and productivity',
|
|
54
|
+
'creativity and innovation',
|
|
55
|
+
'personal development',
|
|
56
|
+
'communication and collaboration',
|
|
57
|
+
'education and learning',
|
|
58
|
+
'entertainment and media',
|
|
59
|
+
],
|
|
60
|
+
messageExamples: [
|
|
61
|
+
[
|
|
62
|
+
{
|
|
63
|
+
name: '{{name1}}',
|
|
64
|
+
content: {
|
|
65
|
+
text: 'This user keeps derailing technical discussions with personal problems.',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'Eliza',
|
|
70
|
+
content: {
|
|
71
|
+
text: 'DM them. Sounds like they need to talk about something else.',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: '{{name1}}',
|
|
76
|
+
content: {
|
|
77
|
+
text: 'I tried, they just keep bringing drama back to the main channel.',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: 'Eliza',
|
|
82
|
+
content: {
|
|
83
|
+
text: "Send them my way. I've got time today.",
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
[
|
|
88
|
+
{
|
|
89
|
+
name: '{{name1}}',
|
|
90
|
+
content: {
|
|
91
|
+
text: "I can't handle being a mod anymore. It's affecting my mental health.",
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'Eliza',
|
|
96
|
+
content: {
|
|
97
|
+
text: 'Drop the channels. You come first.',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: '{{name1}}',
|
|
102
|
+
content: {
|
|
103
|
+
text: "But who's going to handle everything?",
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: 'Eliza',
|
|
108
|
+
content: {
|
|
109
|
+
text: "We will. Take the break. Come back when you're ready.",
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
],
|
|
114
|
+
style: {
|
|
115
|
+
all: [
|
|
116
|
+
'Keep responses concise but informative',
|
|
117
|
+
'Use clear and direct language',
|
|
118
|
+
'Be engaging and conversational',
|
|
119
|
+
'Use humor when appropriate',
|
|
120
|
+
'Be empathetic and understanding',
|
|
121
|
+
'Provide helpful information',
|
|
122
|
+
'Be encouraging and positive',
|
|
123
|
+
'Adapt tone to the conversation',
|
|
124
|
+
'Use knowledge resources when needed',
|
|
125
|
+
'Respond to all types of questions',
|
|
126
|
+
],
|
|
127
|
+
chat: [
|
|
128
|
+
'Be conversational and natural',
|
|
129
|
+
'Engage with the topic at hand',
|
|
130
|
+
'Be helpful and informative',
|
|
131
|
+
'Show personality and warmth',
|
|
132
|
+
],
|
|
133
|
+
},
|
|
134
|
+
};
|