@@ -21,8 +21,9 @@ export const GmailBlock: BlockConfig<GmailToolResponse> = {
2121 layout : 'full' ,
2222 options : [
2323 { label : 'Send Email' , id : 'send_gmail' } ,
24- // { label: 'Read Email', id: 'read_gmail' },
24+ { label : 'Read Email' , id : 'read_gmail' } ,
2525 { label : 'Draft Email' , id : 'draft_gmail' } ,
26+ { label : 'Search Email' , id : 'search_gmail' } ,
2627 ] ,
2728 } ,
2829 // Gmail Credentials
@@ -67,77 +68,73 @@ export const GmailBlock: BlockConfig<GmailToolResponse> = {
6768 condition : { field : 'operation' , value : [ 'send_gmail' , 'draft_gmail' ] } ,
6869 } ,
6970 // Read Email Fields - Add folder selector
70- // {
71- // id: 'folder',
72- // title: 'Label',
73- // type: 'folder-selector',
74- // layout: 'full',
75- // provider: 'google-email',
76- // serviceId: 'gmail',
77- // requiredScopes: [
78- // // 'https://www.googleapis.com/auth/gmail.readonly',
79- // 'https://www.googleapis.com/auth/gmail.labels',
80- // ],
81- // placeholder: 'Select Gmail label/folder',
82- // condition: { field: 'operation', value: 'read_gmail' },
83- // },
84- // {
85- // id: 'unreadOnly',
86- // title: 'Unread Only',
87- // type: 'switch',
88- // layout: 'full',
89- // condition: { field: 'operation', value: 'read_gmail' },
90- // },
91- // {
92- // id: 'maxResults',
93- // title: 'Number of Emails',
94- // type: 'short-input',
95- // layout: 'full',
96- // placeholder: 'Number of emails to retrieve (default: 1, max: 10)',
97- // condition: { field: 'operation', value: 'read_gmail' },
98- // },
99- // {
100- // id: 'messageId',
101- // title: 'Message ID',
102- // type: 'short-input',
103- // layout: 'full',
104- // placeholder: 'Enter message ID to read (optional)',
105- // condition: {
106- // field: 'operation',
107- // value: 'read_gmail',
108- // and: {
109- // field: 'folder',
110- // value: '',
111- // },
112- // },
113- // },
114- // // Search Fields
115- // {
116- // id: 'query',
117- // title: 'Search Query',
118- // type: 'short-input',
119- // layout: 'full',
120- // placeholder: 'Enter search terms',
121- // condition: { field: 'operation', value: 'search_gmail' },
122- // },
123- // {
124- // id: 'maxResults',
125- // title: 'Max Results',
126- // type: 'short-input',
127- // layout: 'full',
128- // placeholder: 'Maximum number of results (default: 10)',
129- // condition: { field: 'operation', value: 'search_gmail' },
130- // },
71+ {
72+ id : 'folder' ,
73+ title : 'Label' ,
74+ type : 'folder-selector' ,
75+ layout : 'full' ,
76+ provider : 'google-email' ,
77+ serviceId : 'gmail' ,
78+ requiredScopes : [
79+ 'https://www.googleapis.com/auth/gmail.readonly' ,
80+ 'https://www.googleapis.com/auth/gmail.labels' ,
81+ ] ,
82+ placeholder : 'Select Gmail label/folder' ,
83+ condition : { field : 'operation' , value : 'read_gmail' } ,
84+ } ,
85+ {
86+ id : 'unreadOnly' ,
87+ title : 'Unread Only' ,
88+ type : 'switch' ,
89+ layout : 'full' ,
90+ condition : { field : 'operation' , value : 'read_gmail' } ,
91+ } ,
92+ {
93+ id : 'messageId' ,
94+ title : 'Message ID' ,
95+ type : 'short-input' ,
96+ layout : 'full' ,
97+ placeholder : 'Enter message ID to read (optional)' ,
98+ condition : {
99+ field : 'operation' ,
100+ value : 'read_gmail' ,
101+ and : {
102+ field : 'folder' ,
103+ value : '' ,
104+ } ,
105+ } ,
106+ } ,
107+ // Search Fields
108+ {
109+ id : 'query' ,
110+ title : 'Search Query' ,
111+ type : 'short-input' ,
112+ layout : 'full' ,
113+ placeholder : 'Enter search terms' ,
114+ condition : { field : 'operation' , value : 'search_gmail' } ,
115+ } ,
116+ {
117+ id : 'maxResults' ,
118+ title : 'Max Results' ,
119+ type : 'short-input' ,
120+ layout : 'full' ,
121+ placeholder : 'Maximum number of results (default: 10)' ,
122+ condition : { field : 'operation' , value : [ 'search_gmail' , 'read_gmail' ] } ,
123+ } ,
131124 ] ,
132125 tools : {
133- access : [ 'gmail_send' , 'gmail_draft' ] ,
126+ access : [ 'gmail_send' , 'gmail_draft' , 'gmail_read' , 'gmail_search' ] ,
134127 config : {
135128 tool : ( params ) => {
136129 switch ( params . operation ) {
137130 case 'send_gmail' :
138131 return 'gmail_send'
139132 case 'draft_gmail' :
140133 return 'gmail_draft'
134+ case 'search_gmail' :
135+ return 'gmail_search'
136+ case 'read_gmail' :
137+ return 'gmail_read'
141138 default :
142139 throw new Error ( `Invalid Gmail operation: ${ params . operation } ` )
143140 }
@@ -146,9 +143,9 @@ export const GmailBlock: BlockConfig<GmailToolResponse> = {
146143 // Pass the credential directly from the credential field
147144 const { credential, ...rest } = params
148145
149- // Set default folder to INBOX if not specified
150- if ( rest . operation === 'read_gmail' && ! rest . folder ) {
151- rest . folder = 'INBOX'
146+ // Ensure folder is always provided for read_gmail operation
147+ if ( rest . operation === 'read_gmail' ) {
148+ rest . folder = rest . folder || 'INBOX'
152149 }
153150
154151 return {
0 commit comments