@@ -6,6 +6,7 @@ import type {
66 SmartleadCampaignAnalyticsByDate ,
77 SmartleadCampaignLead ,
88 SmartleadCampaignLeadStats ,
9+ SmartleadEmailAccount ,
910 SmartleadLead ,
1011 SmartleadLeadCampaignData ,
1112 SmartleadLeadCategory ,
@@ -450,6 +451,50 @@ export function isOk(record: Record<string, unknown>): boolean {
450451 return record . ok === true
451452}
452453
454+ /**
455+ * Selects the email-account fields explicitly rather than passing the record
456+ * through. Smartlead returns the mailbox credentials on these endpoints —
457+ * `password` in plaintext on the by-id and campaign routes, base64-encoded on the
458+ * list route, plus `imap_password` — and a passthrough would surface them in
459+ * workflow output, logs, and model context.
460+ */
461+ export function mapEmailAccount ( value : unknown ) : SmartleadEmailAccount {
462+ const record = toRecord ( value )
463+
464+ return {
465+ id : toNullableNumber ( record . id ) ,
466+ from_name : toStringOrNull ( record . from_name ) ,
467+ from_email : toStringOrNull ( record . from_email ) ,
468+ username : toStringOrNull ( record . username ) ,
469+ type : toStringOrNull ( record . type ) ,
470+ smtp_host : toStringOrNull ( record . smtp_host ) ,
471+ smtp_port : toNullableNumber ( record . smtp_port ) ,
472+ smtp_port_type : toStringOrNull ( record . smtp_port_type ) ,
473+ imap_host : toStringOrNull ( record . imap_host ) ,
474+ imap_port : toNullableNumber ( record . imap_port ) ,
475+ imap_port_type : toStringOrNull ( record . imap_port_type ) ,
476+ is_smtp_success : toNullableBoolean ( record . is_smtp_success ) ,
477+ is_imap_success : toNullableBoolean ( record . is_imap_success ) ,
478+ smtp_failure_error : toStringOrNull ( record . smtp_failure_error ) ,
479+ imap_failure_error : toStringOrNull ( record . imap_failure_error ) ,
480+ message_per_day : toNullableNumber ( record . message_per_day ) ,
481+ daily_sent_count : toNullableNumber ( record . daily_sent_count ) ,
482+ campaign_count : toNullableNumber ( record . campaign_count ) ,
483+ signature : toStringOrNull ( record . signature ) ,
484+ custom_tracking_domain : toStringOrNull ( record . custom_tracking_domain ) ,
485+ bcc_email : toStringOrNull ( record . bcc_email ) ,
486+ different_reply_to_address : toStringOrNull ( record . different_reply_to_address ) ,
487+ client_id : toNullableNumber ( record . client_id ) ,
488+ is_suspended : toNullableBoolean ( record . is_suspended ) ,
489+ warmup_status : isRecordLike ( record . warmup_details )
490+ ? toStringOrNull ( record . warmup_details . status )
491+ : null ,
492+ tags : toArray ( record . tags ) ,
493+ created_at : toStringOrNull ( record . created_at ) ,
494+ updated_at : toStringOrNull ( record . updated_at ) ,
495+ }
496+ }
497+
453498export function mapLeadList ( value : unknown ) : SmartleadLeadList {
454499 const record = toRecord ( value )
455500
@@ -866,6 +911,51 @@ export const listWebhooksOutputs = {
866911
867912export const upsertWebhookOutputs = webhookProperties satisfies NonNullable < ToolConfig [ 'outputs' ] >
868913
914+ const emailAccountProperties = {
915+ id : { type : 'number' , description : 'Email account ID, used to attach it to a campaign' } ,
916+ from_name : { type : 'string' , description : 'Sender display name' , optional : true } ,
917+ from_email : { type : 'string' , description : 'Sender email address' } ,
918+ username : { type : 'string' , description : 'Mailbox username' , optional : true } ,
919+ type : { type : 'string' , description : 'Account type (GMAIL, OUTLOOK, SMTP)' , optional : true } ,
920+ smtp_host : { type : 'string' , description : 'SMTP host' , optional : true } ,
921+ smtp_port : { type : 'number' , description : 'SMTP port' , optional : true } ,
922+ smtp_port_type : { type : 'string' , description : 'SMTP encryption type' , optional : true } ,
923+ imap_host : { type : 'string' , description : 'IMAP host' , optional : true } ,
924+ imap_port : { type : 'number' , description : 'IMAP port' , optional : true } ,
925+ imap_port_type : { type : 'string' , description : 'IMAP encryption type' , optional : true } ,
926+ is_smtp_success : { type : 'boolean' , description : 'Whether SMTP verification succeeded' } ,
927+ is_imap_success : { type : 'boolean' , description : 'Whether IMAP verification succeeded' } ,
928+ smtp_failure_error : { type : 'string' , description : 'Last SMTP error' , optional : true } ,
929+ imap_failure_error : { type : 'string' , description : 'Last IMAP error' , optional : true } ,
930+ message_per_day : { type : 'number' , description : 'Daily sending cap' , optional : true } ,
931+ daily_sent_count : { type : 'number' , description : 'Messages sent today' , optional : true } ,
932+ campaign_count : { type : 'number' , description : 'Campaigns using this account' , optional : true } ,
933+ signature : { type : 'string' , description : 'Email signature HTML' , optional : true } ,
934+ custom_tracking_domain : { type : 'string' , description : 'Custom tracking domain' , optional : true } ,
935+ bcc_email : { type : 'string' , description : 'BCC address' , optional : true } ,
936+ different_reply_to_address : { type : 'string' , description : 'Reply-to address' , optional : true } ,
937+ client_id : { type : 'number' , description : 'Owning client ID' , optional : true } ,
938+ is_suspended : {
939+ type : 'boolean' ,
940+ description : 'Whether the account is suspended' ,
941+ optional : true ,
942+ } ,
943+ warmup_status : { type : 'string' , description : 'Warmup status' , optional : true } ,
944+ tags : { type : 'array' , description : 'Tags applied to the account' } ,
945+ created_at : { type : 'string' , description : 'Creation timestamp' , optional : true } ,
946+ updated_at : { type : 'string' , description : 'Last update timestamp' , optional : true } ,
947+ } satisfies Record < string , OutputProperty >
948+
949+ /** Credentials are intentionally absent — see `mapEmailAccount`. */
950+ export const emailAccountsOutputs = {
951+ accounts : {
952+ type : 'array' ,
953+ description : 'Email accounts, excluding their stored mailbox credentials' ,
954+ items : { type : 'object' , properties : emailAccountProperties } ,
955+ } ,
956+ count : { type : 'number' , description : 'Number of accounts returned' } ,
957+ } satisfies NonNullable < ToolConfig [ 'outputs' ] >
958+
869959export const duplicateCampaignOutputs = {
870960 success : { type : 'boolean' , description : 'Whether Smartlead duplicated the campaign' } ,
871961 id : { type : 'number' , description : 'ID of the newly created campaign' } ,
0 commit comments