Skip to content

Commit ee4f4c8

Browse files
committed
fix: Fix the issue where running the program throws an error when the plugins field in the .character.json file is configured with plugin names.
1 parent 0191936 commit ee4f4c8

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

agent/src/index.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ export function parseArguments(): {
6565
}
6666
}
6767

68+
function isAllStrings(arr: unknown[]): boolean {
69+
return Array.isArray(arr) && arr.every((item) => typeof item === "string");
70+
}
71+
6872
export async function loadCharacters(
6973
charactersArg: string
7074
): Promise<Character[]> {
@@ -85,15 +89,15 @@ export async function loadCharacters(
8589
validateCharacterConfig(character);
8690

8791
// is there a "plugins" field?
88-
if (character.plugins) {
92+
if (isAllStrings(character.plugins)) {
8993
console.log("Plugins are: ", character.plugins);
9094

9195
const importedPlugins = await Promise.all(
9296
character.plugins.map(async (plugin) => {
9397
// if the plugin name doesnt start with @eliza,
9498

9599
const importedPlugin = await import(plugin);
96-
return importedPlugin;
100+
return importedPlugin.default;
97101
})
98102
);
99103

packages/core/src/enviroment.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ export const CharacterSchema = z.object({
7979
adjectives: z.array(z.string()),
8080
knowledge: z.array(z.string()).optional(),
8181
clients: z.array(z.nativeEnum(Clients)),
82-
plugins: z.array(PluginSchema),
82+
plugins: z.union([
83+
z.array(z.string()),
84+
z.array(PluginSchema),
85+
]),
8386
settings: z
8487
.object({
8588
secrets: z.record(z.string()).optional(),

0 commit comments

Comments
 (0)