@@ -102,8 +102,8 @@ import net from "net";
102
102
import path from "path" ;
103
103
import { fileURLToPath } from "url" ;
104
104
import yargs from "yargs" ;
105
- import { Plugin } from "@ai16z/eliza/src/types " ;
106
- import { dominosPlugin } from "@elizaos/plugin-dominos" ;
105
+ import { Plugin } from "@elizaos/core " ;
106
+ import { dominosPlugin } from "@elizaos/plugin-dominos" ;
107
107
108
108
const __filename = fileURLToPath ( import . meta. url ) ; // get the resolved path to the file
109
109
const __dirname = path . dirname ( __filename ) ; // get the name of the directory
@@ -121,6 +121,10 @@ const logFetch = async (url: string, options: any) => {
121
121
return fetch ( url , options ) ;
122
122
} ;
123
123
124
+ function isAllStrings ( arr : unknown [ ] ) : boolean {
125
+ return Array . isArray ( arr ) && arr . every ( ( item ) => typeof item === "string" ) ;
126
+ }
127
+
124
128
export function parseArguments ( ) : {
125
129
character ?: string ;
126
130
characters ?: string ;
@@ -153,14 +157,29 @@ function tryLoadFile(filePath: string): string | null {
153
157
function mergeCharacters ( base : Character , child : Character ) : Character {
154
158
const mergeObjects = ( baseObj : any , childObj : any ) => {
155
159
const result : any = { } ;
156
- const keys = new Set ( [ ...Object . keys ( baseObj || { } ) , ...Object . keys ( childObj || { } ) ] ) ;
157
- keys . forEach ( key => {
158
- if ( typeof baseObj [ key ] === 'object' && typeof childObj [ key ] === 'object' && ! Array . isArray ( baseObj [ key ] ) && ! Array . isArray ( childObj [ key ] ) ) {
160
+ const keys = new Set ( [
161
+ ...Object . keys ( baseObj || { } ) ,
162
+ ...Object . keys ( childObj || { } ) ,
163
+ ] ) ;
164
+ keys . forEach ( ( key ) => {
165
+ if (
166
+ typeof baseObj [ key ] === "object" &&
167
+ typeof childObj [ key ] === "object" &&
168
+ ! Array . isArray ( baseObj [ key ] ) &&
169
+ ! Array . isArray ( childObj [ key ] )
170
+ ) {
159
171
result [ key ] = mergeObjects ( baseObj [ key ] , childObj [ key ] ) ;
160
- } else if ( Array . isArray ( baseObj [ key ] ) || Array . isArray ( childObj [ key ] ) ) {
161
- result [ key ] = [ ...( baseObj [ key ] || [ ] ) , ...( childObj [ key ] || [ ] ) ] ;
172
+ } else if (
173
+ Array . isArray ( baseObj [ key ] ) ||
174
+ Array . isArray ( childObj [ key ] )
175
+ ) {
176
+ result [ key ] = [
177
+ ...( baseObj [ key ] || [ ] ) ,
178
+ ...( childObj [ key ] || [ ] ) ,
179
+ ] ;
162
180
} else {
163
- result [ key ] = childObj [ key ] !== undefined ? childObj [ key ] : baseObj [ key ] ;
181
+ result [ key ] =
182
+ childObj [ key ] !== undefined ? childObj [ key ] : baseObj [ key ] ;
164
183
}
165
184
} ) ;
166
185
return result ;
@@ -175,32 +194,36 @@ async function loadCharacter(filePath: string): Promise<Character> {
175
194
let character = JSON . parse ( content ) ;
176
195
validateCharacterConfig ( character ) ;
177
196
178
- // .id isn't really valid
179
- const characterId = character . id || character . name ;
180
- const characterPrefix = `CHARACTER.${ characterId . toUpperCase ( ) . replace ( / / g, "_" ) } .` ;
181
- const characterSettings = Object . entries ( process . env )
182
- . filter ( ( [ key ] ) => key . startsWith ( characterPrefix ) )
183
- . reduce ( ( settings , [ key , value ] ) => {
184
- const settingKey = key . slice ( characterPrefix . length ) ;
185
- return { ...settings , [ settingKey ] : value } ;
186
- } , { } ) ;
187
- if ( Object . keys ( characterSettings ) . length > 0 ) {
188
- character . settings = character . settings || { } ;
189
- character . settings . secrets = {
190
- ...characterSettings ,
191
- ...character . settings . secrets ,
192
- } ;
193
- }
194
- // Handle plugins
195
- character . plugins = await handlePluginImporting (
196
- character . plugins
197
- ) ;
197
+ // .id isn't really valid
198
+ const characterId = character . id || character . name ;
199
+ const characterPrefix = `CHARACTER.${ characterId . toUpperCase ( ) . replace ( / / g, "_" ) } .` ;
200
+ const characterSettings = Object . entries ( process . env )
201
+ . filter ( ( [ key ] ) => key . startsWith ( characterPrefix ) )
202
+ . reduce ( ( settings , [ key , value ] ) => {
203
+ const settingKey = key . slice ( characterPrefix . length ) ;
204
+ return { ...settings , [ settingKey ] : value } ;
205
+ } , { } ) ;
206
+ if ( Object . keys ( characterSettings ) . length > 0 ) {
207
+ character . settings = character . settings || { } ;
208
+ character . settings . secrets = {
209
+ ...characterSettings ,
210
+ ...character . settings . secrets ,
211
+ } ;
212
+ }
213
+ // Handle plugins
214
+ character . plugins = await handlePluginImporting ( character . plugins ) ;
198
215
if ( character . extends ) {
199
- elizaLogger . info ( `Merging ${ character . name } character with parent characters` ) ;
216
+ elizaLogger . info (
217
+ `Merging ${ character . name } character with parent characters`
218
+ ) ;
200
219
for ( const extendPath of character . extends ) {
201
- const baseCharacter = await loadCharacter ( path . resolve ( path . dirname ( filePath ) , extendPath ) ) ;
220
+ const baseCharacter = await loadCharacter (
221
+ path . resolve ( path . dirname ( filePath ) , extendPath )
222
+ ) ;
202
223
character = mergeCharacters ( baseCharacter , character ) ;
203
- elizaLogger . info ( `Merged ${ character . name } with ${ baseCharacter . name } ` ) ;
224
+ elizaLogger . info (
225
+ `Merged ${ character . name } with ${ baseCharacter . name } `
226
+ ) ;
204
227
}
205
228
}
206
229
return character ;
@@ -289,7 +312,7 @@ export async function loadCharacters(
289
312
...character . settings . secrets ,
290
313
} ;
291
314
}
292
-
315
+
293
316
function isPlugin ( value : any ) : value is Plugin {
294
317
return (
295
318
typeof value === "object" &&
@@ -307,7 +330,7 @@ export async function loadCharacters(
307
330
( value . clients === undefined ||
308
331
Array . isArray ( value . clients ) )
309
332
) ;
310
- }
333
+ }
311
334
312
335
// Handle plugins
313
336
if ( isAllStrings ( character . plugins ) ) {
@@ -555,7 +578,9 @@ function initializeDatabase(dataDir: string) {
555
578
// Test the connection
556
579
db . init ( )
557
580
. then ( ( ) => {
558
- elizaLogger . success ( "Successfully connected to Supabase database" ) ;
581
+ elizaLogger . success (
582
+ "Successfully connected to Supabase database"
583
+ ) ;
559
584
} )
560
585
. catch ( ( error ) => {
561
586
elizaLogger . error ( "Failed to connect to Supabase:" , error ) ;
@@ -572,7 +597,9 @@ function initializeDatabase(dataDir: string) {
572
597
// Test the connection
573
598
db . init ( )
574
599
. then ( ( ) => {
575
- elizaLogger . success ( "Successfully connected to PostgreSQL database" ) ;
600
+ elizaLogger . success (
601
+ "Successfully connected to PostgreSQL database"
602
+ ) ;
576
603
} )
577
604
. catch ( ( error ) => {
578
605
elizaLogger . error ( "Failed to connect to PostgreSQL:" , error ) ;
@@ -587,14 +614,17 @@ function initializeDatabase(dataDir: string) {
587
614
} ) ;
588
615
return db ;
589
616
} else {
590
- const filePath = process . env . SQLITE_FILE ?? path . resolve ( dataDir , "db.sqlite" ) ;
617
+ const filePath =
618
+ process . env . SQLITE_FILE ?? path . resolve ( dataDir , "db.sqlite" ) ;
591
619
elizaLogger . info ( `Initializing SQLite database at ${ filePath } ...` ) ;
592
620
const db = new SqliteDatabaseAdapter ( new Database ( filePath ) ) ;
593
621
594
622
// Test the connection
595
623
db . init ( )
596
624
. then ( ( ) => {
597
- elizaLogger . success ( "Successfully connected to SQLite database" ) ;
625
+ elizaLogger . success (
626
+ "Successfully connected to SQLite database"
627
+ ) ;
598
628
} )
599
629
. catch ( ( error ) => {
600
630
elizaLogger . error ( "Failed to connect to SQLite:" , error ) ;
@@ -772,7 +802,8 @@ export async function createAgent(
772
802
if (
773
803
process . env . PRIMUS_APP_ID &&
774
804
process . env . PRIMUS_APP_SECRET &&
775
- process . env . VERIFIABLE_INFERENCE_ENABLED === "true" ) {
805
+ process . env . VERIFIABLE_INFERENCE_ENABLED === "true"
806
+ ) {
776
807
verifiableInferenceAdapter = new PrimusAdapter ( {
777
808
appId : process . env . PRIMUS_APP_ID ,
778
809
appSecret : process . env . PRIMUS_APP_SECRET ,
@@ -934,9 +965,7 @@ export async function createAgent(
934
965
getSecret ( character , "AKASH_WALLET_ADDRESS" )
935
966
? akashPlugin
936
967
: null ,
937
- getSecret ( character , "QUAI_PRIVATE_KEY" )
938
- ? quaiPlugin
939
- : null ,
968
+ getSecret ( character , "QUAI_PRIVATE_KEY" ) ? quaiPlugin : null ,
940
969
] . filter ( Boolean ) ,
941
970
providers : [ ] ,
942
971
actions : [ ] ,
0 commit comments