diff --git a/agent/src/index.ts b/agent/src/index.ts index ae98fd47fc..ab888ec2f2 100644 --- a/agent/src/index.ts +++ b/agent/src/index.ts @@ -83,6 +83,10 @@ function tryLoadFile(filePath: string): string | null { } } +function isAllStrings(arr: unknown[]): boolean { + return Array.isArray(arr) && arr.every((item) => typeof item === "string"); +} + export async function loadCharacters( charactersArg: string ): Promise { @@ -149,12 +153,12 @@ export async function loadCharacters( validateCharacterConfig(character); // Handle plugins - if (character.plugins) { + if (isAllStrings(character.plugins)) { elizaLogger.info("Plugins are: ", character.plugins); const importedPlugins = await Promise.all( character.plugins.map(async (plugin) => { const importedPlugin = await import(plugin); - return importedPlugin; + return importedPlugin.default; }) ); character.plugins = importedPlugins; diff --git a/packages/core/src/enviroment.ts b/packages/core/src/enviroment.ts index 197f18c004..8e5f338936 100644 --- a/packages/core/src/enviroment.ts +++ b/packages/core/src/enviroment.ts @@ -78,7 +78,10 @@ export const CharacterSchema = z.object({ adjectives: z.array(z.string()), knowledge: z.array(z.string()).optional(), clients: z.array(z.nativeEnum(Clients)), - plugins: z.array(PluginSchema), + plugins: z.union([ + z.array(z.string()), + z.array(PluginSchema), + ]), settings: z .object({ secrets: z.record(z.string()).optional(),