Skip to content

Commit 26afc73

Browse files
committed
chore: remove duplicate error checking + fallback to env vars for mailosaur
1 parent 931e48e commit 26afc73

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

packages/shortest/src/browser/core/browser-tool.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,12 +459,27 @@ export class BrowserTool extends BaseBrowserTool {
459459

460460
case "check_email": {
461461
if (!this.mailosaurTool) {
462-
if (!this.config.mailosaur) {
463-
throw new ToolError("Mailosaur configuration required");
462+
const mailosaurAPIKey =
463+
this.config.mailosaur?.apiKey || process.env.MAILOSAUR_API_KEY;
464+
const mailosaurServerId =
465+
this.config.mailosaur?.serverId ||
466+
process.env.MAILOSAUR_SERVER_ID;
467+
468+
if (!mailosaurAPIKey) {
469+
throw new ToolError("Mailosaur API key is required");
464470
}
471+
472+
if (!mailosaurServerId) {
473+
throw new ToolError("Mailosaur server ID is required");
474+
}
475+
476+
if (!input.email) {
477+
throw new ToolError("Mailosaur email address is required");
478+
}
479+
465480
this.mailosaurTool = new MailosaurTool({
466-
apiKey: this.config.mailosaur.apiKey,
467-
serverId: this.config.mailosaur.serverId,
481+
apiKey: mailosaurAPIKey,
482+
serverId: mailosaurServerId,
468483
emailAddress: input.email,
469484
});
470485
}

packages/shortest/src/browser/integrations/mailosaur.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,8 @@ export class MailosaurTool {
99
constructor(config: {
1010
apiKey: string;
1111
serverId: string;
12-
emailAddress?: string;
12+
emailAddress: string;
1313
}) {
14-
if (!config.apiKey || !config.serverId) {
15-
throw new ToolError("Mailosaur configuration missing required fields");
16-
} else if (!config.emailAddress) {
17-
throw new ToolError("Mailosaur email address is required");
18-
}
19-
2014
this.client = new Mailosaur(config.apiKey);
2115
this.serverId = config.serverId;
2216
this.emailAddress = config.emailAddress;

0 commit comments

Comments
 (0)