@@ -53,7 +53,7 @@ import {
53
53
webhookPlugin ,
54
54
} from "@elizaos/plugin-coinbase" ;
55
55
import { coinmarketcapPlugin } from "@elizaos/plugin-coinmarketcap" ;
56
- import { coinPricePlugin } from "@elizaos/plugin-coinprice " ;
56
+ import { coingeckoPlugin } from "@elizaos/plugin-coingecko " ;
57
57
import { confluxPlugin } from "@elizaos/plugin-conflux" ;
58
58
import { createCosmosPlugin } from "@elizaos/plugin-cosmos" ;
59
59
import { cronosZkEVMPlugin } from "@elizaos/plugin-cronoszkevm" ;
@@ -68,17 +68,18 @@ import { nearPlugin } from "@elizaos/plugin-near";
68
68
import { nftGenerationPlugin } from "@elizaos/plugin-nft-generation" ;
69
69
import { createNodePlugin } from "@elizaos/plugin-node" ;
70
70
import { obsidianPlugin } from "@elizaos/plugin-obsidian" ;
71
+ import { sgxPlugin } from "@elizaos/plugin-sgx" ;
71
72
import { solanaPlugin } from "@elizaos/plugin-solana" ;
72
73
import { solanaAgentkitPlguin } from "@elizaos/plugin-solana-agentkit" ;
73
74
import { storyPlugin } from "@elizaos/plugin-story" ;
74
75
import { suiPlugin } from "@elizaos/plugin-sui" ;
75
- import { sgxPlugin } from "@elizaos/plugin-sgx" ;
76
76
import { TEEMode , teePlugin } from "@elizaos/plugin-tee" ;
77
77
import { teeLogPlugin } from "@elizaos/plugin-tee-log" ;
78
78
import { teeMarlinPlugin } from "@elizaos/plugin-tee-marlin" ;
79
79
import { tonPlugin } from "@elizaos/plugin-ton" ;
80
80
import { webSearchPlugin } from "@elizaos/plugin-web-search" ;
81
81
82
+ import { coingeckoPlugin } from "@elizaos/plugin-coingecko" ;
82
83
import { giphyPlugin } from "@elizaos/plugin-giphy" ;
83
84
import { letzAIPlugin } from "@elizaos/plugin-letzai" ;
84
85
import { thirdwebPlugin } from "@elizaos/plugin-thirdweb" ;
@@ -141,10 +142,6 @@ function tryLoadFile(filePath: string): string | null {
141
142
}
142
143
}
143
144
144
- function isAllStrings ( arr : unknown [ ] ) : boolean {
145
- return Array . isArray ( arr ) && arr . every ( ( item ) => typeof item === "string" ) ;
146
- }
147
-
148
145
export async function loadCharacters (
149
146
charactersArg : string
150
147
) : Promise < Character [ ] > {
@@ -230,16 +227,9 @@ export async function loadCharacters(
230
227
}
231
228
232
229
// Handle plugins
233
- if ( isAllStrings ( character . plugins ) ) {
234
- elizaLogger . info ( "Plugins are: " , character . plugins ) ;
235
- const importedPlugins = await Promise . all (
236
- character . plugins . map ( async ( plugin ) => {
237
- const importedPlugin = await import ( plugin ) ;
238
- return importedPlugin . default ;
239
- } )
240
- ) ;
241
- character . plugins = importedPlugins ;
242
- }
230
+ character . plugins = await handlePluginImporting (
231
+ character . plugins
232
+ ) ;
243
233
244
234
loadedCharacters . push ( character ) ;
245
235
elizaLogger . info (
@@ -262,6 +252,36 @@ export async function loadCharacters(
262
252
return loadedCharacters ;
263
253
}
264
254
255
+ async function handlePluginImporting ( plugins : string [ ] ) {
256
+ if ( plugins . length > 0 ) {
257
+ elizaLogger . info ( "Plugins are: " , plugins ) ;
258
+ const importedPlugins = await Promise . all (
259
+ plugins . map ( async ( plugin ) => {
260
+ try {
261
+ const importedPlugin = await import ( plugin ) ;
262
+ const functionName =
263
+ plugin
264
+ . replace ( "@elizaos/plugin-" , "" )
265
+ . replace ( / - ./ g, ( x ) => x [ 1 ] . toUpperCase ( ) ) +
266
+ "Plugin" ; // Assumes plugin function is camelCased with Plugin suffix
267
+ return (
268
+ importedPlugin . default || importedPlugin [ functionName ]
269
+ ) ;
270
+ } catch ( importError ) {
271
+ elizaLogger . error (
272
+ `Failed to import plugin: ${ plugin } ` ,
273
+ importError
274
+ ) ;
275
+ return [ ] ; // Return null for failed imports
276
+ }
277
+ } )
278
+ ) ;
279
+ return importedPlugins ;
280
+ } else {
281
+ return [ ] ;
282
+ }
283
+ }
284
+
265
285
export function getTokenForProvider (
266
286
provider : ModelProviderName ,
267
287
character : Character
@@ -608,7 +628,6 @@ export async function createAgent(
608
628
? confluxPlugin
609
629
: null ,
610
630
nodePlugin ,
611
- coinPricePlugin ,
612
631
getSecret ( character , "TAVILY_API_KEY" ) ? webSearchPlugin : null ,
613
632
getSecret ( character , "SOLANA_PUBLIC_KEY" ) ||
614
633
( getSecret ( character , "WALLET_PUBLIC_KEY" ) &&
@@ -668,9 +687,9 @@ export async function createAgent(
668
687
: [ ] ) ,
669
688
...( teeMode !== TEEMode . OFF && walletSecretSalt ? [ teePlugin ] : [ ] ) ,
670
689
getSecret ( character , "SGX" ) ? sgxPlugin : null ,
671
- ( getSecret ( character , "ENABLE_TEE_LOG" ) &&
672
- ( ( teeMode !== TEEMode . OFF && walletSecretSalt ) ||
673
- getSecret ( character , "SGX" ) ) )
690
+ getSecret ( character , "ENABLE_TEE_LOG" ) &&
691
+ ( ( teeMode !== TEEMode . OFF && walletSecretSalt ) ||
692
+ getSecret ( character , "SGX" ) )
674
693
? teeLogPlugin
675
694
: null ,
676
695
getSecret ( character , "COINBASE_API_KEY" ) &&
@@ -679,7 +698,10 @@ export async function createAgent(
679
698
? webhookPlugin
680
699
: null ,
681
700
goatPlugin ,
682
- getSecret ( character , "COINGECKO_API_KEY" ) ? coingeckoPlugin : null ,
701
+ getSecret ( character , "COINGECKO_API_KEY" ) ||
702
+ getSecret ( character , "COINGECKO_PRO_API_KEY" )
703
+ ? coingeckoPlugin
704
+ : null ,
683
705
getSecret ( character , "EVM_PROVIDER_URL" ) ? goatPlugin : null ,
684
706
getSecret ( character , "ABSTRACT_PRIVATE_KEY" )
685
707
? abstractPlugin
@@ -918,7 +940,10 @@ const startAgents = async () => {
918
940
}
919
941
920
942
// upload some agent functionality into directClient
921
- directClient . startAgent = async ( character : Character ) => {
943
+ directClient . startAgent = async ( character ) => {
944
+ // Handle plugins
945
+ character . plugins = await handlePluginImporting ( character . plugins ) ;
946
+
922
947
// wrap it so we don't have to inject directClient later
923
948
return startAgent ( character , directClient ) ;
924
949
} ;
0 commit comments