@@ -10,6 +10,7 @@ interface EmailOptions {
1010 subject ?: string ;
1111 body ?: string ;
1212 attach ?: string [ ] ;
13+ unreadOnly ?: boolean ;
1314}
1415
1516interface Attachment {
@@ -77,6 +78,9 @@ function showEmailHelp(): void {
7778 console . log ( ' ' + chalk . cyan ( 'npx atxp email claim-username' ) + ' ' + chalk . yellow ( '<name>' ) + ' ' + 'Claim a username ($1.00)' ) ;
7879 console . log ( ' ' + chalk . cyan ( 'npx atxp email release-username' ) + ' ' + 'Release your username' ) ;
7980 console . log ( ) ;
81+ console . log ( chalk . bold ( 'Inbox/Search Options:' ) ) ;
82+ console . log ( ' ' + chalk . yellow ( '--unread-only' ) + ' ' + 'Only show unread messages' ) ;
83+ console . log ( ) ;
8084 console . log ( chalk . bold ( 'Send/Reply Options:' ) ) ;
8185 console . log ( ' ' + chalk . yellow ( '--to' ) + ' ' + chalk . gray ( '<email>' ) + ' ' + 'Recipient email address (required for send)' ) ;
8286 console . log ( ' ' + chalk . yellow ( '--subject' ) + ' ' + chalk . gray ( '<text>' ) + ' ' + 'Email subject line (required for send)' ) ;
@@ -89,6 +93,7 @@ function showEmailHelp(): void {
8993 console . log ( ) ;
9094 console . log ( chalk . bold ( 'Examples:' ) ) ;
9195 console . log ( ' npx atxp email inbox' ) ;
96+ console . log ( ' npx atxp email inbox --unread-only' ) ;
9297 console . log ( ' npx atxp email read msg_abc123' ) ;
9398 console . log ( ' npx atxp email send --to user@example.com --subject "Hello" --body "Hi there!"' ) ;
9499 console . log ( ' npx atxp email send --to user@example.com --subject "Report" --body "See attached." --attach report.pdf' ) ;
@@ -125,7 +130,7 @@ export async function emailCommand(subCommand: string, options: EmailOptions, me
125130
126131 switch ( subCommand ) {
127132 case 'inbox' :
128- await checkInbox ( ) ;
133+ await checkInbox ( options . unreadOnly ) ;
129134 break ;
130135
131136 case 'read' :
@@ -141,7 +146,7 @@ export async function emailCommand(subCommand: string, options: EmailOptions, me
141146 break ;
142147
143148 case 'search' :
144- await searchEmails ( messageId ) ;
149+ await searchEmails ( messageId , options . unreadOnly ) ;
145150 break ;
146151
147152 case 'delete' :
@@ -168,8 +173,10 @@ export async function emailCommand(subCommand: string, options: EmailOptions, me
168173 }
169174}
170175
171- async function checkInbox ( ) : Promise < void > {
172- const result = await callTool ( SERVER , 'email_check_inbox' , { } ) ;
176+ async function checkInbox ( unreadOnly ?: boolean ) : Promise < void > {
177+ const args : Record < string , unknown > = { } ;
178+ if ( unreadOnly ) args . unreadOnly = true ;
179+ const result = await callTool ( SERVER , 'email_check_inbox' , args ) ;
173180
174181 try {
175182 const parsed = JSON . parse ( result ) ;
@@ -373,14 +380,16 @@ async function replyToEmail(messageId?: string, options?: EmailOptions): Promise
373380 }
374381}
375382
376- async function searchEmails ( query ?: string ) : Promise < void > {
383+ async function searchEmails ( query ?: string , unreadOnly ?: boolean ) : Promise < void > {
377384 if ( ! query ) {
378385 console . error ( chalk . red ( 'Error: search query is required' ) ) ;
379386 console . log ( `Usage: ${ chalk . cyan ( 'npx atxp email search <query>' ) } ` ) ;
380387 process . exit ( 1 ) ;
381388 }
382389
383- const result = await callTool ( SERVER , 'email_search' , { query } ) ;
390+ const args : Record < string , unknown > = { query } ;
391+ if ( unreadOnly ) args . unreadOnly = true ;
392+ const result = await callTool ( SERVER , 'email_search' , args ) ;
384393
385394 try {
386395 const parsed = JSON . parse ( result ) ;
0 commit comments