@elizaos/core 1.5.4 → 1.5.5
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 +0 -15
- package/dist/index.d.ts +4886 -3
- package/dist/index.js +5287 -4
- package/package.json +21 -39
- package/dist/browser/index.browser.js +0 -1109
- package/dist/browser/index.browser.js.map +0 -707
- package/dist/browser/index.d.ts +0 -3
- package/dist/node/index.d.ts +0 -3
- package/dist/node/index.node.js +0 -74530
- package/dist/node/index.node.js.map +0 -1027
- package/src/__tests__/action-chaining-simple.test.ts +0 -203
- package/src/__tests__/actions.test.ts +0 -218
- package/src/__tests__/buffer.test.ts +0 -337
- package/src/__tests__/character-validation.test.ts +0 -309
- package/src/__tests__/database.test.ts +0 -750
- package/src/__tests__/entities.test.ts +0 -727
- package/src/__tests__/env.test.ts +0 -23
- package/src/__tests__/environment.test.ts +0 -285
- package/src/__tests__/logger-browser-node.test.ts +0 -716
- package/src/__tests__/logger.test.ts +0 -403
- package/src/__tests__/messages.test.ts +0 -196
- package/src/__tests__/mockCharacter.ts +0 -544
- package/src/__tests__/parsing.test.ts +0 -58
- package/src/__tests__/prompts.test.ts +0 -159
- package/src/__tests__/roles.test.ts +0 -331
- package/src/__tests__/runtime-embedding.test.ts +0 -343
- package/src/__tests__/runtime.test.ts +0 -978
- package/src/__tests__/search.test.ts +0 -15
- package/src/__tests__/services-by-type.test.ts +0 -204
- package/src/__tests__/services.test.ts +0 -136
- package/src/__tests__/settings.test.ts +0 -810
- package/src/__tests__/utils.test.ts +0 -1105
- package/src/__tests__/uuid.test.ts +0 -94
- package/src/actions.ts +0 -122
- package/src/database.ts +0 -579
- package/src/entities.ts +0 -406
- package/src/index.browser.ts +0 -48
- package/src/index.node.ts +0 -39
- package/src/index.ts +0 -50
- package/src/logger.ts +0 -527
- package/src/prompts.ts +0 -243
- package/src/roles.ts +0 -85
- package/src/runtime.ts +0 -2514
- package/src/schemas/character.ts +0 -149
- package/src/search.ts +0 -1543
- package/src/sentry/instrument.browser.ts +0 -65
- package/src/sentry/instrument.node.ts +0 -57
- package/src/sentry/instrument.ts +0 -82
- package/src/services.ts +0 -105
- package/src/settings.ts +0 -409
- package/src/test_resources/constants.ts +0 -12
- package/src/test_resources/testSetup.ts +0 -21
- package/src/test_resources/types.ts +0 -22
- package/src/types/agent.ts +0 -112
- package/src/types/browser.ts +0 -145
- package/src/types/components.ts +0 -184
- package/src/types/database.ts +0 -348
- package/src/types/email.ts +0 -162
- package/src/types/environment.ts +0 -129
- package/src/types/events.ts +0 -249
- package/src/types/index.ts +0 -29
- package/src/types/knowledge.ts +0 -65
- package/src/types/lp.ts +0 -124
- package/src/types/memory.ts +0 -228
- package/src/types/message.ts +0 -233
- package/src/types/messaging.ts +0 -57
- package/src/types/model.ts +0 -359
- package/src/types/pdf.ts +0 -77
- package/src/types/plugin.ts +0 -78
- package/src/types/post.ts +0 -271
- package/src/types/primitives.ts +0 -97
- package/src/types/runtime.ts +0 -190
- package/src/types/service.ts +0 -198
- package/src/types/settings.ts +0 -30
- package/src/types/state.ts +0 -60
- package/src/types/task.ts +0 -72
- package/src/types/tee.ts +0 -107
- package/src/types/testing.ts +0 -30
- package/src/types/token.ts +0 -96
- package/src/types/transcription.ts +0 -133
- package/src/types/video.ts +0 -108
- package/src/types/wallet.ts +0 -56
- package/src/types/web-search.ts +0 -146
- package/src/utils/__tests__/buffer.test.ts +0 -80
- package/src/utils/__tests__/environment.test.ts +0 -58
- package/src/utils/__tests__/stringToUuid.test.ts +0 -88
- package/src/utils/buffer.ts +0 -312
- package/src/utils/environment.ts +0 -316
- package/src/utils/server-health.ts +0 -117
- package/src/utils.ts +0 -1076
package/src/settings.ts
DELETED
|
@@ -1,409 +0,0 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
import crypto from 'crypto-browserify';
|
|
3
|
-
import { createUniqueUuid } from './entities';
|
|
4
|
-
import { getEnv } from './utils/environment';
|
|
5
|
-
import { BufferUtils } from './utils/buffer';
|
|
6
|
-
import { logger } from './logger';
|
|
7
|
-
import type {
|
|
8
|
-
Character,
|
|
9
|
-
IAgentRuntime,
|
|
10
|
-
OnboardingConfig,
|
|
11
|
-
Setting,
|
|
12
|
-
World,
|
|
13
|
-
WorldSettings,
|
|
14
|
-
} from './types';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Creates a Setting object from a configSetting object by omitting the 'value' property.
|
|
18
|
-
*
|
|
19
|
-
* @param {Omit<Setting, 'value'>} configSetting - The configSetting object to create the Setting from.
|
|
20
|
-
* @returns {Setting} A new Setting object created from the provided configSetting object.
|
|
21
|
-
*/
|
|
22
|
-
export function createSettingFromConfig(configSetting: Omit<Setting, 'value'>): Setting {
|
|
23
|
-
return {
|
|
24
|
-
name: configSetting.name,
|
|
25
|
-
description: configSetting.description,
|
|
26
|
-
usageDescription: configSetting.usageDescription || '',
|
|
27
|
-
value: null,
|
|
28
|
-
required: configSetting.required,
|
|
29
|
-
validation: configSetting.validation || undefined,
|
|
30
|
-
public: configSetting.public || false,
|
|
31
|
-
secret: configSetting.secret || false,
|
|
32
|
-
dependsOn: configSetting.dependsOn || [],
|
|
33
|
-
onSetAction: configSetting.onSetAction || undefined,
|
|
34
|
-
visibleIf: configSetting.visibleIf || undefined,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Retrieves the salt based on env variable SECRET_SALT
|
|
40
|
-
*
|
|
41
|
-
* @returns {string} The salt for the agent.
|
|
42
|
-
*/
|
|
43
|
-
export function getSalt(): string {
|
|
44
|
-
const secretSalt = getEnv('SECRET_SALT', 'secretsalt') || 'secretsalt';
|
|
45
|
-
|
|
46
|
-
if (secretSalt === 'secretsalt') {
|
|
47
|
-
logger.error('SECRET_SALT is not set or using default value');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const salt = secretSalt;
|
|
51
|
-
|
|
52
|
-
//logger.debug(`Generated salt with length: ${salt.length} (truncated for security)`);
|
|
53
|
-
return salt;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Common encryption function for string values
|
|
58
|
-
* @param {string} value - The string value to encrypt
|
|
59
|
-
* @param {string} salt - The salt to use for encryption
|
|
60
|
-
* @returns {string} - The encrypted value in 'iv:encrypted' format
|
|
61
|
-
*/
|
|
62
|
-
export function encryptStringValue(value: string, salt: string): string {
|
|
63
|
-
// Check if value is undefined or null
|
|
64
|
-
if (value === undefined || value === null) {
|
|
65
|
-
logger.debug('Attempted to encrypt undefined or null value');
|
|
66
|
-
return value; // Return the value as is (undefined or null)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (typeof value === 'boolean' || typeof value === 'number') {
|
|
70
|
-
logger.debug('Value is a boolean or number, returning as is');
|
|
71
|
-
return value;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (typeof value !== 'string') {
|
|
75
|
-
logger.debug(`Value is not a string (type: ${typeof value}), returning as is`);
|
|
76
|
-
return value;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Check if value is already encrypted (has the format "iv:encrypted")
|
|
80
|
-
const parts = value.split(':');
|
|
81
|
-
if (parts.length === 2) {
|
|
82
|
-
try {
|
|
83
|
-
// Try to parse the first part as hex to see if it's already encrypted
|
|
84
|
-
const possibleIv = BufferUtils.fromHex(parts[0]);
|
|
85
|
-
if (possibleIv.length === 16) {
|
|
86
|
-
// Value is likely already encrypted, return as is
|
|
87
|
-
logger.debug('Value appears to be already encrypted, skipping re-encryption');
|
|
88
|
-
return value;
|
|
89
|
-
}
|
|
90
|
-
} catch (e) {
|
|
91
|
-
// Not a valid hex string, proceed with encryption
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Create key and iv from the salt
|
|
96
|
-
const key = crypto.createHash('sha256').update(salt).digest().slice(0, 32);
|
|
97
|
-
const iv = BufferUtils.randomBytes(16);
|
|
98
|
-
|
|
99
|
-
// Encrypt the value
|
|
100
|
-
const cipher = crypto.createCipheriv('aes-256-cbc', key, iv);
|
|
101
|
-
let encrypted = cipher.update(value, 'utf8', 'hex');
|
|
102
|
-
encrypted += cipher.final('hex');
|
|
103
|
-
|
|
104
|
-
// Store IV with the encrypted value so we can decrypt it later
|
|
105
|
-
return `${BufferUtils.toHex(iv)}:${encrypted}`;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Common decryption function for string values
|
|
110
|
-
* @param {string} value - The encrypted value in 'iv:encrypted' format
|
|
111
|
-
* @param {string} salt - The salt to use for decryption
|
|
112
|
-
* @returns {string} - The decrypted string value
|
|
113
|
-
*/
|
|
114
|
-
export function decryptStringValue(value: string, salt: string): string {
|
|
115
|
-
try {
|
|
116
|
-
// Check if value is undefined or null
|
|
117
|
-
if (value === undefined || value === null) {
|
|
118
|
-
//logger.debug('Attempted to decrypt undefined or null value');
|
|
119
|
-
return value; // Return the value as is (undefined or null)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (typeof value === 'boolean' || typeof value === 'number') {
|
|
123
|
-
//logger.debug('Value is a boolean or number, returning as is');
|
|
124
|
-
return value;
|
|
125
|
-
}
|
|
126
|
-
if (typeof value !== 'string') {
|
|
127
|
-
logger.debug(`Value is not a string (type: ${typeof value}), returning as is`);
|
|
128
|
-
return value;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Split the IV and encrypted value
|
|
132
|
-
const parts = value.split(':');
|
|
133
|
-
if (parts.length !== 2) {
|
|
134
|
-
/*
|
|
135
|
-
logger.debug(
|
|
136
|
-
`Invalid encrypted value format - expected 'iv:encrypted', returning original value`
|
|
137
|
-
);
|
|
138
|
-
*/
|
|
139
|
-
return value; // Return the original value without decryption
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const iv = BufferUtils.fromHex(parts[0]);
|
|
143
|
-
const encrypted = parts[1];
|
|
144
|
-
|
|
145
|
-
// Verify IV length
|
|
146
|
-
if (iv.length !== 16) {
|
|
147
|
-
if (iv.length) {
|
|
148
|
-
logger.debug(`Invalid IV length (${iv.length}) - expected 16 bytes`);
|
|
149
|
-
}
|
|
150
|
-
return value; // Return the original value without decryption
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Create key from the salt
|
|
154
|
-
const key = crypto.createHash('sha256').update(salt).digest().slice(0, 32);
|
|
155
|
-
|
|
156
|
-
// Decrypt the value
|
|
157
|
-
const decipher = crypto.createDecipheriv('aes-256-cbc', key, iv);
|
|
158
|
-
let decrypted = decipher.update(encrypted, 'hex', 'utf8');
|
|
159
|
-
decrypted += decipher.final('utf8');
|
|
160
|
-
|
|
161
|
-
return decrypted;
|
|
162
|
-
} catch (error) {
|
|
163
|
-
logger.error(`Error decrypting value: ${error}`);
|
|
164
|
-
// Return the encrypted value on error
|
|
165
|
-
return value;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Applies salt to the value of a setting
|
|
171
|
-
* Only applies to secret settings with string values
|
|
172
|
-
*/
|
|
173
|
-
export function saltSettingValue(setting: Setting, salt: string): Setting {
|
|
174
|
-
const settingCopy = { ...setting };
|
|
175
|
-
|
|
176
|
-
// Only encrypt string values in secret settings
|
|
177
|
-
if (setting.secret === true && typeof setting.value === 'string' && setting.value) {
|
|
178
|
-
settingCopy.value = encryptStringValue(setting.value, salt);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return settingCopy;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Removes salt from the value of a setting
|
|
186
|
-
* Only applies to secret settings with string values
|
|
187
|
-
*/
|
|
188
|
-
export function unsaltSettingValue(setting: Setting, salt: string): Setting {
|
|
189
|
-
const settingCopy = { ...setting };
|
|
190
|
-
|
|
191
|
-
// Only decrypt string values in secret settings
|
|
192
|
-
if (setting.secret === true && typeof setting.value === 'string' && setting.value) {
|
|
193
|
-
settingCopy.value = decryptStringValue(setting.value, salt);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return settingCopy;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Applies salt to all settings in a WorldSettings object
|
|
201
|
-
*/
|
|
202
|
-
export function saltWorldSettings(worldSettings: WorldSettings, salt: string): WorldSettings {
|
|
203
|
-
const saltedSettings: WorldSettings = {};
|
|
204
|
-
|
|
205
|
-
for (const [key, setting] of Object.entries(worldSettings)) {
|
|
206
|
-
saltedSettings[key] = saltSettingValue(setting, salt);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return saltedSettings;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Removes salt from all settings in a WorldSettings object
|
|
214
|
-
*/
|
|
215
|
-
export function unsaltWorldSettings(worldSettings: WorldSettings, salt: string): WorldSettings {
|
|
216
|
-
const unsaltedSettings: WorldSettings = {};
|
|
217
|
-
|
|
218
|
-
for (const [key, setting] of Object.entries(worldSettings)) {
|
|
219
|
-
unsaltedSettings[key] = unsaltSettingValue(setting, salt);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return unsaltedSettings;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Updates settings state in world metadata
|
|
227
|
-
*/
|
|
228
|
-
export async function updateWorldSettings(
|
|
229
|
-
runtime: IAgentRuntime,
|
|
230
|
-
serverId: string,
|
|
231
|
-
worldSettings: WorldSettings
|
|
232
|
-
): Promise<boolean> {
|
|
233
|
-
const worldId = createUniqueUuid(runtime, serverId);
|
|
234
|
-
const world = await runtime.getWorld(worldId);
|
|
235
|
-
|
|
236
|
-
if (!world) {
|
|
237
|
-
logger.error(`No world found for server ${serverId}`);
|
|
238
|
-
return false;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// Initialize metadata if it doesn't exist
|
|
242
|
-
if (!world.metadata) {
|
|
243
|
-
world.metadata = {};
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// Apply salt to settings before saving
|
|
247
|
-
const salt = getSalt();
|
|
248
|
-
const saltedSettings = saltWorldSettings(worldSettings, salt);
|
|
249
|
-
|
|
250
|
-
// Update settings state
|
|
251
|
-
world.metadata.settings = saltedSettings;
|
|
252
|
-
|
|
253
|
-
// Save updated world
|
|
254
|
-
await runtime.updateWorld(world);
|
|
255
|
-
|
|
256
|
-
return true;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Gets settings state from world metadata
|
|
261
|
-
*/
|
|
262
|
-
export async function getWorldSettings(
|
|
263
|
-
runtime: IAgentRuntime,
|
|
264
|
-
serverId: string
|
|
265
|
-
): Promise<WorldSettings | null> {
|
|
266
|
-
const worldId = createUniqueUuid(runtime, serverId);
|
|
267
|
-
const world = await runtime.getWorld(worldId);
|
|
268
|
-
|
|
269
|
-
if (!world || !world.metadata?.settings) {
|
|
270
|
-
return null;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// Get settings from metadata
|
|
274
|
-
const saltedSettings = world.metadata.settings as WorldSettings;
|
|
275
|
-
|
|
276
|
-
// Remove salt from settings before returning
|
|
277
|
-
const salt = getSalt();
|
|
278
|
-
return unsaltWorldSettings(saltedSettings, salt);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Initializes settings configuration for a server
|
|
283
|
-
*/
|
|
284
|
-
export async function initializeOnboarding(
|
|
285
|
-
runtime: IAgentRuntime,
|
|
286
|
-
world: World,
|
|
287
|
-
config: OnboardingConfig
|
|
288
|
-
): Promise<WorldSettings | null> {
|
|
289
|
-
// Check if settings state already exists
|
|
290
|
-
if (world.metadata?.settings) {
|
|
291
|
-
logger.info(`Onboarding state already exists for server ${world.serverId}`);
|
|
292
|
-
// Get settings from metadata and remove salt
|
|
293
|
-
const saltedSettings = world.metadata.settings as WorldSettings;
|
|
294
|
-
const salt = getSalt();
|
|
295
|
-
return unsaltWorldSettings(saltedSettings, salt);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
// Create new settings state
|
|
299
|
-
const worldSettings: WorldSettings = {};
|
|
300
|
-
|
|
301
|
-
// Initialize settings from config
|
|
302
|
-
if (config.settings) {
|
|
303
|
-
for (const [key, configSetting] of Object.entries(config.settings)) {
|
|
304
|
-
worldSettings[key] = createSettingFromConfig(configSetting);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
// Save settings state to world metadata
|
|
309
|
-
if (!world.metadata) {
|
|
310
|
-
world.metadata = {};
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// No need to salt here as the settings are just initialized with null values
|
|
314
|
-
world.metadata.settings = worldSettings;
|
|
315
|
-
|
|
316
|
-
await runtime.updateWorld(world);
|
|
317
|
-
|
|
318
|
-
logger.info(`Initialized settings config for server ${world.serverId}`);
|
|
319
|
-
return worldSettings;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* Encrypts sensitive data in a Character object
|
|
324
|
-
* @param {Character} character - The character object to encrypt secrets for
|
|
325
|
-
* @returns {Character} - A copy of the character with encrypted secrets
|
|
326
|
-
*/
|
|
327
|
-
export function encryptedCharacter(character: Character): Character {
|
|
328
|
-
// Create a deep copy to avoid modifying the original
|
|
329
|
-
const encryptedChar = JSON.parse(JSON.stringify(character));
|
|
330
|
-
const salt = getSalt();
|
|
331
|
-
|
|
332
|
-
// Encrypt character.settings.secrets if it exists
|
|
333
|
-
if (encryptedChar.settings?.secrets) {
|
|
334
|
-
encryptedChar.settings.secrets = encryptObjectValues(encryptedChar.settings.secrets, salt);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
// Encrypt character.secrets if it exists
|
|
338
|
-
if (encryptedChar.secrets) {
|
|
339
|
-
encryptedChar.secrets = encryptObjectValues(encryptedChar.secrets, salt);
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
return encryptedChar;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Decrypts sensitive data in a Character object
|
|
347
|
-
* @param {Character} character - The character object with encrypted secrets
|
|
348
|
-
* @param {IAgentRuntime} runtime - The runtime information needed for salt generation
|
|
349
|
-
* @returns {Character} - A copy of the character with decrypted secrets
|
|
350
|
-
*/
|
|
351
|
-
export function decryptedCharacter(character: Character, _runtime: IAgentRuntime): Character {
|
|
352
|
-
// Create a deep copy to avoid modifying the original
|
|
353
|
-
const decryptedChar = JSON.parse(JSON.stringify(character));
|
|
354
|
-
const salt = getSalt();
|
|
355
|
-
|
|
356
|
-
// Decrypt character.settings.secrets if it exists
|
|
357
|
-
if (decryptedChar.settings?.secrets) {
|
|
358
|
-
decryptedChar.settings.secrets = decryptObjectValues(decryptedChar.settings.secrets, salt);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
// Decrypt character.secrets if it exists
|
|
362
|
-
if (decryptedChar.secrets) {
|
|
363
|
-
decryptedChar.secrets = decryptObjectValues(decryptedChar.secrets, salt);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
return decryptedChar;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* Helper function to encrypt all string values in an object
|
|
371
|
-
* @param {Record<string, any>} obj - Object with values to encrypt
|
|
372
|
-
* @param {string} salt - The salt to use for encryption
|
|
373
|
-
* @returns {Record<string, any>} - Object with encrypted values
|
|
374
|
-
*/
|
|
375
|
-
export function encryptObjectValues(obj: Record<string, any>, salt: string): Record<string, any> {
|
|
376
|
-
const result: Record<string, any> = {};
|
|
377
|
-
|
|
378
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
379
|
-
if (typeof value === 'string' && value) {
|
|
380
|
-
result[key] = encryptStringValue(value, salt);
|
|
381
|
-
} else {
|
|
382
|
-
result[key] = value;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
return result;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* Helper function to decrypt all string values in an object
|
|
391
|
-
* @param {Record<string, any>} obj - Object with encrypted values
|
|
392
|
-
* @param {string} salt - The salt to use for decryption
|
|
393
|
-
* @returns {Record<string, any>} - Object with decrypted values
|
|
394
|
-
*/
|
|
395
|
-
export function decryptObjectValues(obj: Record<string, any>, salt: string): Record<string, any> {
|
|
396
|
-
const result: Record<string, any> = {};
|
|
397
|
-
|
|
398
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
399
|
-
if (typeof value === 'string' && value) {
|
|
400
|
-
result[key] = decryptStringValue(value, salt);
|
|
401
|
-
} else {
|
|
402
|
-
result[key] = value;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
return result;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
export { decryptStringValue as decryptSecret };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { UUID } from '@elizaos/core';
|
|
2
|
-
|
|
3
|
-
export const SERVER_URL = 'http://localhost:7998';
|
|
4
|
-
export const SUPABASE_URL = 'https://pronvzrzfwsptkojvudd.supabase.co';
|
|
5
|
-
export const SUPABASE_ANON_KEY =
|
|
6
|
-
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InByb252enJ6ZndzcHRrb2p2dWRkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDY4NTYwNDcsImV4cCI6MjAyMjQzMjA0N30.I6_-XrqssUb2SWYg5DjsUqSodNS3_RPoET3-aPdqywM';
|
|
7
|
-
export const TEST_EMAIL = 'testuser123@example.com';
|
|
8
|
-
export const TEST_PASSWORD = 'mock_password_123!@#';
|
|
9
|
-
export const TEST_EMAIL_2 = 'testuser234@example.com';
|
|
10
|
-
export const TEST_PASSWORD_2 = 'mock_password_234!@#';
|
|
11
|
-
|
|
12
|
-
export const zeroUuid = '00000000-0000-0000-0000-000000000000' as UUID;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import dotenv from 'dotenv';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
|
-
|
|
5
|
-
// Get the current file's directory
|
|
6
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
-
const __dirname = path.dirname(__filename);
|
|
8
|
-
|
|
9
|
-
// Resolve paths relative to packages/core directory
|
|
10
|
-
const packageRoot = path.resolve(__dirname, '../..');
|
|
11
|
-
const envTestPath = path.join(packageRoot, '.env.test');
|
|
12
|
-
const envPath = path.join(packageRoot, '.env');
|
|
13
|
-
|
|
14
|
-
const result = dotenv.config({ path: envTestPath });
|
|
15
|
-
if (result.error) {
|
|
16
|
-
console.error('Error loading .env.test. Loading .env instead');
|
|
17
|
-
const result2 = dotenv.config({ path: envPath });
|
|
18
|
-
if (result2.error) {
|
|
19
|
-
console.error('Error loading .env:', result2.error);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Interface representing a User.
|
|
3
|
-
* @typedef {Object} User
|
|
4
|
-
* @property {string} id - The user's ID.
|
|
5
|
-
* @property {string} [email] - The user's email (optional).
|
|
6
|
-
* @property {string} [phone] - The user's phone number (optional).
|
|
7
|
-
* @property {string} [role] - The user's role (optional).
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Represents a User with optional properties.
|
|
11
|
-
* @typedef {Object} User
|
|
12
|
-
* @property {string} id - The unique identifier for the user.
|
|
13
|
-
* @property {string} [email] - The email address of the user (optional).
|
|
14
|
-
* @property {string} [phone] - The phone number of the user (optional).
|
|
15
|
-
* @property {string} [role] - The role of the user (optional).
|
|
16
|
-
*/
|
|
17
|
-
export interface User {
|
|
18
|
-
id: string;
|
|
19
|
-
email?: string;
|
|
20
|
-
phone?: string;
|
|
21
|
-
role?: string;
|
|
22
|
-
}
|
package/src/types/agent.ts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import type { DirectoryItem } from './knowledge';
|
|
2
|
-
import type { Content, UUID } from './primitives';
|
|
3
|
-
import type { State } from './state';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Example message for demonstration
|
|
7
|
-
*/
|
|
8
|
-
export interface MessageExample {
|
|
9
|
-
/** Associated user */
|
|
10
|
-
name: string;
|
|
11
|
-
|
|
12
|
-
/** Message content */
|
|
13
|
-
content: Content;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type TemplateType =
|
|
17
|
-
| string
|
|
18
|
-
| ((options: { state: State | { [key: string]: string } }) => string);
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Configuration for an agent's character, defining its personality, knowledge, and capabilities.
|
|
22
|
-
* This is a central piece of an agent's definition, used by the `AgentRuntime` to initialize and operate the agent.
|
|
23
|
-
* It includes:
|
|
24
|
-
* - `id`: Optional unique identifier for the character.
|
|
25
|
-
* - `name`, `username`: Identifying names for the character.
|
|
26
|
-
* - `system`: A system prompt that guides the agent's overall behavior.
|
|
27
|
-
* - `templates`: A map of prompt templates for various situations (e.g., message generation, summarization).
|
|
28
|
-
* - `bio`: A textual biography or description of the character.
|
|
29
|
-
* - `messageExamples`, `postExamples`: Examples of how the character communicates.
|
|
30
|
-
* - `topics`, `adjectives`: Keywords describing the character's knowledge areas and traits.
|
|
31
|
-
* - `knowledge`: Paths to knowledge files or directories to be loaded into the agent's memory.
|
|
32
|
-
* - `plugins`: A list of plugin names to be loaded for this character.
|
|
33
|
-
* - `settings`, `secrets`: Configuration key-value pairs, with secrets being handled more securely.
|
|
34
|
-
* - `style`: Guidelines for the character's writing style in different contexts (chat, post).
|
|
35
|
-
*/
|
|
36
|
-
export interface Character {
|
|
37
|
-
/** Optional unique identifier */
|
|
38
|
-
id?: UUID;
|
|
39
|
-
|
|
40
|
-
/** Character name */
|
|
41
|
-
name: string;
|
|
42
|
-
|
|
43
|
-
/** Optional username */
|
|
44
|
-
username?: string;
|
|
45
|
-
|
|
46
|
-
/** Optional system prompt */
|
|
47
|
-
system?: string;
|
|
48
|
-
|
|
49
|
-
/** Optional prompt templates */
|
|
50
|
-
templates?: {
|
|
51
|
-
[key: string]: TemplateType;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/** Character biography */
|
|
55
|
-
bio: string | string[];
|
|
56
|
-
|
|
57
|
-
/** Example messages */
|
|
58
|
-
messageExamples?: MessageExample[][];
|
|
59
|
-
|
|
60
|
-
/** Example posts */
|
|
61
|
-
postExamples?: string[];
|
|
62
|
-
|
|
63
|
-
/** Known topics */
|
|
64
|
-
topics?: string[];
|
|
65
|
-
|
|
66
|
-
/** Character traits */
|
|
67
|
-
adjectives?: string[];
|
|
68
|
-
|
|
69
|
-
/** Optional knowledge base */
|
|
70
|
-
knowledge?: (string | { path: string; shared?: boolean } | DirectoryItem)[];
|
|
71
|
-
|
|
72
|
-
/** Available plugins */
|
|
73
|
-
plugins?: string[];
|
|
74
|
-
|
|
75
|
-
/** Optional configuration */
|
|
76
|
-
settings?: {
|
|
77
|
-
[key: string]: string | boolean | number | Record<string, any>;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/** Optional secrets */
|
|
81
|
-
secrets?: {
|
|
82
|
-
[key: string]: string | boolean | number;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
/** Writing style guides */
|
|
86
|
-
style?: {
|
|
87
|
-
all?: string[];
|
|
88
|
-
chat?: string[];
|
|
89
|
-
post?: string[];
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export enum AgentStatus {
|
|
94
|
-
ACTIVE = 'active',
|
|
95
|
-
INACTIVE = 'inactive',
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Represents an operational agent, extending the `Character` definition with runtime status and timestamps.
|
|
100
|
-
* While `Character` defines the blueprint, `Agent` represents an instantiated and potentially running version.
|
|
101
|
-
* It includes:
|
|
102
|
-
* - `enabled`: A boolean indicating if the agent is currently active or disabled.
|
|
103
|
-
* - `status`: The current operational status, typically `AgentStatus.ACTIVE` or `AgentStatus.INACTIVE`.
|
|
104
|
-
* - `createdAt`, `updatedAt`: Timestamps for when the agent record was created and last updated in the database.
|
|
105
|
-
* This interface is primarily used by the `IDatabaseAdapter` for agent management.
|
|
106
|
-
*/
|
|
107
|
-
export interface Agent extends Character {
|
|
108
|
-
enabled?: boolean;
|
|
109
|
-
status?: AgentStatus;
|
|
110
|
-
createdAt: number;
|
|
111
|
-
updatedAt: number;
|
|
112
|
-
}
|