@@ -11,7 +11,6 @@ import { SlackClientInterface } from "@elizaos/client-slack";
11
11
import { TelegramClientInterface } from "@elizaos/client-telegram" ;
12
12
import { TwitterClientInterface } from "@elizaos/client-twitter" ;
13
13
// import { ReclaimAdapter } from "@elizaos/plugin-reclaim";
14
- import { DirectClient } from "@elizaos/client-direct" ;
15
14
import { PrimusAdapter } from "@elizaos/plugin-primus" ;
16
15
17
16
import {
@@ -102,7 +101,7 @@ import net from "net";
102
101
import path from "path" ;
103
102
import { fileURLToPath } from "url" ;
104
103
import yargs from "yargs" ;
105
- import { createNFTCollectionsPlugin } from "@ai16z /plugin-nft-collections" ;
104
+ import { createNFTCollectionsPlugin } from "@elizaos /plugin-nft-collections" ;
106
105
107
106
const __filename = fileURLToPath ( import . meta. url ) ; // get the resolved path to the file
108
107
const __dirname = path . dirname ( __filename ) ; // get the name of the directory
@@ -152,14 +151,29 @@ function tryLoadFile(filePath: string): string | null {
152
151
function mergeCharacters ( base : Character , child : Character ) : Character {
153
152
const mergeObjects = ( baseObj : any , childObj : any ) => {
154
153
const result : any = { } ;
155
- const keys = new Set ( [ ...Object . keys ( baseObj || { } ) , ...Object . keys ( childObj || { } ) ] ) ;
156
- keys . forEach ( key => {
157
- if ( typeof baseObj [ key ] === 'object' && typeof childObj [ key ] === 'object' && ! Array . isArray ( baseObj [ key ] ) && ! Array . isArray ( childObj [ key ] ) ) {
154
+ const keys = new Set ( [
155
+ ...Object . keys ( baseObj || { } ) ,
156
+ ...Object . keys ( childObj || { } ) ,
157
+ ] ) ;
158
+ keys . forEach ( ( key ) => {
159
+ if (
160
+ typeof baseObj [ key ] === "object" &&
161
+ typeof childObj [ key ] === "object" &&
162
+ ! Array . isArray ( baseObj [ key ] ) &&
163
+ ! Array . isArray ( childObj [ key ] )
164
+ ) {
158
165
result [ key ] = mergeObjects ( baseObj [ key ] , childObj [ key ] ) ;
159
- } else if ( Array . isArray ( baseObj [ key ] ) || Array . isArray ( childObj [ key ] ) ) {
160
- result [ key ] = [ ...( baseObj [ key ] || [ ] ) , ...( childObj [ key ] || [ ] ) ] ;
166
+ } else if (
167
+ Array . isArray ( baseObj [ key ] ) ||
168
+ Array . isArray ( childObj [ key ] )
169
+ ) {
170
+ result [ key ] = [
171
+ ...( baseObj [ key ] || [ ] ) ,
172
+ ...( childObj [ key ] || [ ] ) ,
173
+ ] ;
161
174
} else {
162
- result [ key ] = childObj [ key ] !== undefined ? childObj [ key ] : baseObj [ key ] ;
175
+ result [ key ] =
176
+ childObj [ key ] !== undefined ? childObj [ key ] : baseObj [ key ] ;
163
177
}
164
178
} ) ;
165
179
return result ;
@@ -174,32 +188,36 @@ async function loadCharacter(filePath: string): Promise<Character> {
174
188
let character = JSON . parse ( content ) ;
175
189
validateCharacterConfig ( character ) ;
176
190
177
- // .id isn't really valid
178
- const characterId = character . id || character . name ;
179
- const characterPrefix = `CHARACTER.${ characterId . toUpperCase ( ) . replace ( / / g, "_" ) } .` ;
180
- const characterSettings = Object . entries ( process . env )
181
- . filter ( ( [ key ] ) => key . startsWith ( characterPrefix ) )
182
- . reduce ( ( settings , [ key , value ] ) => {
183
- const settingKey = key . slice ( characterPrefix . length ) ;
184
- return { ...settings , [ settingKey ] : value } ;
185
- } , { } ) ;
186
- if ( Object . keys ( characterSettings ) . length > 0 ) {
187
- character . settings = character . settings || { } ;
188
- character . settings . secrets = {
189
- ...characterSettings ,
190
- ...character . settings . secrets ,
191
- } ;
192
- }
193
- // Handle plugins
194
- character . plugins = await handlePluginImporting (
195
- character . plugins
196
- ) ;
191
+ // .id isn't really valid
192
+ const characterId = character . id || character . name ;
193
+ const characterPrefix = `CHARACTER.${ characterId . toUpperCase ( ) . replace ( / / g, "_" ) } .` ;
194
+ const characterSettings = Object . entries ( process . env )
195
+ . filter ( ( [ key ] ) => key . startsWith ( characterPrefix ) )
196
+ . reduce ( ( settings , [ key , value ] ) => {
197
+ const settingKey = key . slice ( characterPrefix . length ) ;
198
+ return { ...settings , [ settingKey ] : value } ;
199
+ } , { } ) ;
200
+ if ( Object . keys ( characterSettings ) . length > 0 ) {
201
+ character . settings = character . settings || { } ;
202
+ character . settings . secrets = {
203
+ ...characterSettings ,
204
+ ...character . settings . secrets ,
205
+ } ;
206
+ }
207
+ // Handle plugins
208
+ character . plugins = await handlePluginImporting ( character . plugins ) ;
197
209
if ( character . extends ) {
198
- elizaLogger . info ( `Merging ${ character . name } character with parent characters` ) ;
210
+ elizaLogger . info (
211
+ `Merging ${ character . name } character with parent characters`
212
+ ) ;
199
213
for ( const extendPath of character . extends ) {
200
- const baseCharacter = await loadCharacter ( path . resolve ( path . dirname ( filePath ) , extendPath ) ) ;
214
+ const baseCharacter = await loadCharacter (
215
+ path . resolve ( path . dirname ( filePath ) , extendPath )
216
+ ) ;
201
217
character = mergeCharacters ( baseCharacter , character ) ;
202
- elizaLogger . info ( `Merged ${ character . name } with ${ baseCharacter . name } ` ) ;
218
+ elizaLogger . info (
219
+ `Merged ${ character . name } with ${ baseCharacter . name } `
220
+ ) ;
203
221
}
204
222
}
205
223
return character ;
@@ -467,7 +485,9 @@ function initializeDatabase(dataDir: string) {
467
485
// Test the connection
468
486
db . init ( )
469
487
. then ( ( ) => {
470
- elizaLogger . success ( "Successfully connected to Supabase database" ) ;
488
+ elizaLogger . success (
489
+ "Successfully connected to Supabase database"
490
+ ) ;
471
491
} )
472
492
. catch ( ( error ) => {
473
493
elizaLogger . error ( "Failed to connect to Supabase:" , error ) ;
@@ -484,7 +504,9 @@ function initializeDatabase(dataDir: string) {
484
504
// Test the connection
485
505
db . init ( )
486
506
. then ( ( ) => {
487
- elizaLogger . success ( "Successfully connected to PostgreSQL database" ) ;
507
+ elizaLogger . success (
508
+ "Successfully connected to PostgreSQL database"
509
+ ) ;
488
510
} )
489
511
. catch ( ( error ) => {
490
512
elizaLogger . error ( "Failed to connect to PostgreSQL:" , error ) ;
@@ -499,14 +521,17 @@ function initializeDatabase(dataDir: string) {
499
521
} ) ;
500
522
return db ;
501
523
} else {
502
- const filePath = process . env . SQLITE_FILE ?? path . resolve ( dataDir , "db.sqlite" ) ;
524
+ const filePath =
525
+ process . env . SQLITE_FILE ?? path . resolve ( dataDir , "db.sqlite" ) ;
503
526
elizaLogger . info ( `Initializing SQLite database at ${ filePath } ...` ) ;
504
527
const db = new SqliteDatabaseAdapter ( new Database ( filePath ) ) ;
505
528
506
529
// Test the connection
507
530
db . init ( )
508
531
. then ( ( ) => {
509
- elizaLogger . success ( "Successfully connected to SQLite database" ) ;
532
+ elizaLogger . success (
533
+ "Successfully connected to SQLite database"
534
+ ) ;
510
535
} )
511
536
. catch ( ( error ) => {
512
537
elizaLogger . error ( "Failed to connect to SQLite:" , error ) ;
@@ -684,7 +709,8 @@ export async function createAgent(
684
709
if (
685
710
process . env . PRIMUS_APP_ID &&
686
711
process . env . PRIMUS_APP_SECRET &&
687
- process . env . VERIFIABLE_INFERENCE_ENABLED === "true" ) {
712
+ process . env . VERIFIABLE_INFERENCE_ENABLED === "true"
713
+ ) {
688
714
verifiableInferenceAdapter = new PrimusAdapter ( {
689
715
appId : process . env . PRIMUS_APP_ID ,
690
716
appSecret : process . env . PRIMUS_APP_SECRET ,
@@ -846,9 +872,7 @@ export async function createAgent(
846
872
getSecret ( character , "AKASH_WALLET_ADDRESS" )
847
873
? akashPlugin
848
874
: null ,
849
- getSecret ( character , "QUAI_PRIVATE_KEY" )
850
- ? quaiPlugin
851
- : null ,
875
+ getSecret ( character , "QUAI_PRIVATE_KEY" ) ? quaiPlugin : null ,
852
876
getSecret ( character , "RESERVOIR_API_KEY" )
853
877
? createNFTCollectionsPlugin ( )
854
878
: null ,
@@ -1063,4 +1087,4 @@ const startAgents = async () => {
1063
1087
startAgents ( ) . catch ( ( error ) => {
1064
1088
elizaLogger . error ( "Unhandled error in startAgents:" , error ) ;
1065
1089
process . exit ( 1 ) ;
1066
- } ) ;
1090
+ } ) ;
0 commit comments