Skip to content

Commit

Permalink
feat: make NodePlugin and GoatPlugin creation conditional
Browse files Browse the repository at this point in the history
- NodePlugin is now only created when all required AWS credentials are present
  (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION, AWS_S3_BUCKET)
- GoatPlugin is now only created when ALCHEMY_API_KEY is present
- Added type annotations for plugins to handle undefined cases

These changes prevent unnecessary plugin initialization when required
credentials are missing and improve type safety.

Issues introduced in: elizaOS#941 and
elizaOS#898
  • Loading branch information
jnaulty committed Dec 11, 2024
1 parent f913d15 commit ca49c0e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,12 @@ export async function createAgent(
character.name
);

nodePlugin ??= createNodePlugin();
nodePlugin ??= (
getSecret(character, "AWS_ACCESS_KEY_ID") &&
getSecret(character, "AWS_SECRET_ACCESS_KEY") &&
getSecret(character, "AWS_REGION") &&
getSecret(character, "AWS_S3_BUCKET")
) ? createNodePlugin() : undefined;

const teeMode = getSecret(character, "TEE_MODE") || "OFF";
const walletSecretSalt = getSecret(character, "WALLET_SECRET_SALT");
Expand All @@ -384,9 +389,12 @@ export async function createAgent(
throw new Error("Invalid TEE configuration");
}

const goatPlugin = await createGoatPlugin((secret) =>
getSecret(character, secret)
);
let goatPlugin: any | undefined;
if (getSecret(character, "ALCHEMY_API_KEY")) {
goatPlugin = await createGoatPlugin((secret) =>
getSecret(character, secret)
);
}

return new AgentRuntime({
databaseAdapter: db,
Expand Down

0 comments on commit ca49c0e

Please sign in to comment.