@@ -63,6 +63,7 @@ import { flowPlugin } from "@elizaos/plugin-flow";
63
63
import { fuelPlugin } from "@elizaos/plugin-fuel";
64
64
import { genLayerPlugin } from "@elizaos/plugin-genlayer";
65
65
import { imageGenerationPlugin } from "@elizaos/plugin-image-generation";
66
+ import { lensPlugin } from "@elizaos/plugin-lensNetwork";
66
67
import { multiversxPlugin } from "@elizaos/plugin-multiversx";
67
68
import { nearPlugin } from "@elizaos/plugin-near";
68
69
import { nftGenerationPlugin } from "@elizaos/plugin-nft-generation";
@@ -71,6 +72,7 @@ import { obsidianPlugin } from "@elizaos/plugin-obsidian";
71
72
import { sgxPlugin } from "@elizaos/plugin-sgx";
72
73
import { solanaPlugin } from "@elizaos/plugin-solana";
73
74
import { solanaAgentkitPlguin } from "@elizaos/plugin-solana-agentkit";
75
+ import { autonomePlugin } from "@elizaos/plugin-autonome";
74
76
import { storyPlugin } from "@elizaos/plugin-story";
75
77
import { suiPlugin } from "@elizaos/plugin-sui";
76
78
import { TEEMode, teePlugin } from "@elizaos/plugin-tee";
@@ -89,6 +91,7 @@ import { zksyncEraPlugin } from "@elizaos/plugin-zksync-era";
89
91
import { OpacityAdapter } from "@elizaos/plugin-opacity";
90
92
import { openWeatherPlugin } from "@elizaos/plugin-open-weather";
91
93
import { stargazePlugin } from "@elizaos/plugin-stargaze";
94
+ import { akashPlugin } from "@elizaos/plugin-akash";
92
95
import Database from "better-sqlite3";
93
96
import fs from "fs";
94
97
import net from "net";
@@ -142,10 +145,6 @@ function tryLoadFile(filePath: string): string | null {
142
145
}
143
146
}
144
147
145
- function isAllStrings(arr: unknown[]): boolean {
146
- return Array.isArray(arr) && arr.every((item) => typeof item === "string");
147
- }
148
-
149
148
export async function loadCharacters(
150
149
charactersArg: string
151
150
): Promise<Character[]> {
@@ -231,16 +230,9 @@ export async function loadCharacters(
231
230
}
232
231
233
232
// Handle plugins
234
- if (isAllStrings(character.plugins)) {
235
- elizaLogger.info("Plugins are: ", character.plugins);
236
- const importedPlugins = await Promise.all(
237
- character.plugins.map(async (plugin) => {
238
- const importedPlugin = await import(plugin);
239
- return importedPlugin.default;
240
- })
241
- );
242
- character.plugins = importedPlugins;
243
- }
233
+ character.plugins = await handlePluginImporting(
234
+ character.plugins
235
+ );
244
236
245
237
loadedCharacters.push(character);
246
238
elizaLogger.info(
@@ -263,6 +255,36 @@ export async function loadCharacters(
263
255
return loadedCharacters;
264
256
}
265
257
258
+ async function handlePluginImporting(plugins: string[]) {
259
+ if (plugins.length > 0) {
260
+ elizaLogger.info("Plugins are: ", plugins);
261
+ const importedPlugins = await Promise.all(
262
+ plugins.map(async (plugin) => {
263
+ try {
264
+ const importedPlugin = await import(plugin);
265
+ const functionName =
266
+ plugin
267
+ .replace("@elizaos/plugin-", "")
268
+ .replace(/-./g, (x) => x[1].toUpperCase()) +
269
+ "Plugin"; // Assumes plugin function is camelCased with Plugin suffix
270
+ return (
271
+ importedPlugin.default || importedPlugin[functionName]
272
+ );
273
+ } catch (importError) {
274
+ elizaLogger.error(
275
+ `Failed to import plugin: ${plugin}`,
276
+ importError
277
+ );
278
+ return []; // Return null for failed imports
279
+ }
280
+ })
281
+ );
282
+ return importedPlugins;
283
+ } else {
284
+ return [];
285
+ }
286
+ }
287
+
266
288
export function getTokenForProvider(
267
289
provider: ModelProviderName,
268
290
character: Character
@@ -618,6 +640,7 @@ export async function createAgent(
618
640
getSecret(character, "SOLANA_PRIVATE_KEY")
619
641
? solanaAgentkitPlguin
620
642
: null,
643
+ getSecret(character, "AUTONOME_JWT_TOKEN") ? autonomePlugin : null,
621
644
(getSecret(character, "NEAR_ADDRESS") ||
622
645
getSecret(character, "NEAR_WALLET_PUBLIC_KEY")) &&
623
646
getSecret(character, "NEAR_WALLET_SECRET_KEY")
@@ -695,6 +718,10 @@ export async function createAgent(
695
718
getSecret(character, "FLOW_PRIVATE_KEY")
696
719
? flowPlugin
697
720
: null,
721
+ getSecret(character, "LENS_ADDRESS") &&
722
+ getSecret(character, "LENS_PRIVATE_KEY")
723
+ ? lensPlugin
724
+ : null,
698
725
getSecret(character, "APTOS_PRIVATE_KEY") ? aptosPlugin : null,
699
726
getSecret(character, "MVX_PRIVATE_KEY") ? multiversxPlugin : null,
700
727
getSecret(character, "ZKSYNC_PRIVATE_KEY") ? zksyncEraPlugin : null,
@@ -738,6 +765,10 @@ export async function createAgent(
738
765
getSecret(character, "HYPERLIQUID_TESTNET")
739
766
? hyperliquidPlugin
740
767
: null,
768
+ getSecret(character, "AKASH_MNEMONIC") &&
769
+ getSecret(character, "AKASH_WALLET_ADDRESS")
770
+ ? akashPlugin
771
+ : null,
741
772
].filter(Boolean),
742
773
providers: [],
743
774
actions: [],
@@ -927,7 +958,10 @@ const startAgents = async () => {
927
958
}
928
959
929
960
// upload some agent functionality into directClient
930
- directClient.startAgent = async (character: Character) => {
961
+ directClient.startAgent = async (character) => {
962
+ // Handle plugins
963
+ character.plugins = await handlePluginImporting(character.plugins);
964
+
931
965
// wrap it so we don't have to inject directClient later
932
966
return startAgent(character, directClient);
933
967
};
0 commit comments