@@ -18,12 +18,14 @@ import {
1818 SelectTrigger ,
1919 SelectValue ,
2020} from '@/components/ui/select'
21+ import { OAuthProvider } from '@/lib/oauth'
2122import { cn } from '@/lib/utils'
2223import { useCustomToolsStore } from '@/stores/custom-tools/store'
2324import { useWorkflowStore } from '@/stores/workflows/workflow/store'
2425import { getAllBlocks } from '@/blocks'
2526import { getTool } from '@/tools'
2627import { useSubBlockValue } from '../../hooks/use-sub-block-value'
28+ import { CredentialSelector } from '../credential-selector/credential-selector'
2729import { ShortInput } from '../short-input'
2830import { CustomTool , CustomToolModal } from './components/custom-tool-modal/custom-tool-modal'
2931import { ToolCommand } from './components/tool-command/tool-command'
@@ -71,6 +73,12 @@ const getRequiredToolParams = (toolId: string): ToolParam[] => {
7173 } ) )
7274}
7375
76+ // Check if a tool requires OAuth
77+ const getOAuthConfig = ( toolId : string ) => {
78+ const tool = getTool ( toolId )
79+ return tool ?. oauth
80+ }
81+
7482// For custom tools, extract parameters from the schema
7583const getCustomToolParams = ( schema : any ) : ToolParam [ ] => {
7684 if ( ! schema ?. function ?. parameters ?. properties ) return [ ]
@@ -295,6 +303,22 @@ export function ToolInput({ blockId, subBlockId }: ToolInputProps) {
295303 )
296304 }
297305
306+ const handleCredentialChange = ( toolIndex : number , credentialId : string ) => {
307+ setValue (
308+ selectedTools . map ( ( tool , index ) =>
309+ index === toolIndex
310+ ? {
311+ ...tool ,
312+ params : {
313+ ...tool . params ,
314+ credential : credentialId ,
315+ } ,
316+ }
317+ : tool
318+ )
319+ )
320+ }
321+
298322 const toggleToolExpansion = ( toolIndex : number ) => {
299323 setValue (
300324 selectedTools . map ( ( tool , index ) =>
@@ -525,6 +549,30 @@ export function ToolInput({ blockId, subBlockId }: ToolInputProps) {
525549 </ div >
526550 ) }
527551
552+ { /* Add OAuth credential selector if the tool requires OAuth */ }
553+ { toolId &&
554+ ( ( ) => {
555+ const oauthConfig = getOAuthConfig ( toolId )
556+ if ( oauthConfig ?. required ) {
557+ return (
558+ < div className = "space-y-1.5 relative" >
559+ < div className = "text-xs font-medium text-muted-foreground" >
560+ Account
561+ </ div >
562+ < CredentialSelector
563+ value = { tool . params . credential || '' }
564+ onChange = { ( value ) => handleCredentialChange ( toolIndex , value ) }
565+ provider = { oauthConfig . provider as OAuthProvider }
566+ requiredScopes = { oauthConfig . additionalScopes || [ ] }
567+ label = { `Select ${ oauthConfig . provider } account` }
568+ serviceId = { oauthConfig . provider }
569+ />
570+ </ div >
571+ )
572+ }
573+ return null
574+ } ) ( ) }
575+
528576 { /* Existing parameters */ }
529577 { requiredParams . map ( ( param ) => (
530578 < div key = { param . id } className = "space-y-1.5 relative" >
0 commit comments