Skip to content

Commit d728ae6

Browse files
committed
improvement(tools): added supabase to tool use and fixed tool search
1 parent 33c5c52 commit d728ae6

File tree

4 files changed

+93
-54
lines changed

4 files changed

+93
-54
lines changed

sim/app/w/[id]/components/workflow-block/components/sub-block/components/tool-input/tool-input.tsx

Lines changed: 64 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export function ToolInput({ blockId, subBlockId }: ToolInputProps) {
130130
const [open, setOpen] = useState(false)
131131
const [customToolModalOpen, setCustomToolModalOpen] = useState(false)
132132
const [editingToolIndex, setEditingToolIndex] = useState<number | null>(null)
133+
const [searchQuery, setSearchQuery] = useState('')
133134
const isWide = useWorkflowStore((state) => state.blocks[blockId]?.isWide)
134135
const customTools = useCustomToolsStore((state) => state.getAllTools())
135136

@@ -346,7 +347,7 @@ export function ToolInput({ blockId, subBlockId }: ToolInputProps) {
346347
</PopoverTrigger>
347348
<PopoverContent className="p-0 w-[200px]" align="start">
348349
<ToolCommand.Root filter={customFilter}>
349-
<ToolCommand.Input placeholder="Search tools..." />
350+
<ToolCommand.Input placeholder="Search tools..." onValueChange={setSearchQuery} />
350351
<ToolCommand.List>
351352
<ToolCommand.Empty>No tools found</ToolCommand.Empty>
352353
<ToolCommand.Group>
@@ -421,27 +422,31 @@ export function ToolInput({ blockId, subBlockId }: ToolInputProps) {
421422
)}
422423

423424
{/* Display built-in tools */}
424-
<div className="px-2 pt-2.5 pb-0.5 text-xs font-medium text-muted-foreground">
425-
Built-in Tools
426-
</div>
427-
<ToolCommand.Group className="-mx-1 -px-1">
428-
{toolBlocks.map((block) => (
429-
<ToolCommand.Item
430-
key={block.type}
431-
value={block.name}
432-
onSelect={() => handleSelectTool(block)}
433-
className="flex items-center gap-2 cursor-pointer"
434-
>
435-
<div
436-
className="flex items-center justify-center w-6 h-6 rounded"
437-
style={{ backgroundColor: block.bgColor }}
438-
>
439-
<IconComponent icon={block.icon} className="w-4 h-4 text-white" />
440-
</div>
441-
<span className="truncate max-w-[140px]">{block.name}</span>
442-
</ToolCommand.Item>
443-
))}
444-
</ToolCommand.Group>
425+
{toolBlocks.some((block) => customFilter(block.name, searchQuery || '') > 0) && (
426+
<>
427+
<div className="px-2 pt-2.5 pb-0.5 text-xs font-medium text-muted-foreground">
428+
Built-in Tools
429+
</div>
430+
<ToolCommand.Group className="-mx-1 -px-1">
431+
{toolBlocks.map((block) => (
432+
<ToolCommand.Item
433+
key={block.type}
434+
value={block.name}
435+
onSelect={() => handleSelectTool(block)}
436+
className="flex items-center gap-2 cursor-pointer"
437+
>
438+
<div
439+
className="flex items-center justify-center w-6 h-6 rounded"
440+
style={{ backgroundColor: block.bgColor }}
441+
>
442+
<IconComponent icon={block.icon} className="w-4 h-4 text-white" />
443+
</div>
444+
<span className="truncate max-w-[140px]">{block.name}</span>
445+
</ToolCommand.Item>
446+
))}
447+
</ToolCommand.Group>
448+
</>
449+
)}
445450
</ToolCommand.Group>
446451
</ToolCommand.List>
447452
</ToolCommand.Root>
@@ -577,7 +582,15 @@ export function ToolInput({ blockId, subBlockId }: ToolInputProps) {
577582
{requiredParams.map((param) => (
578583
<div key={param.id} className="space-y-1.5 relative">
579584
<div className="text-xs font-medium text-muted-foreground">
580-
{param.id === 'apiKey' ? 'API Key' : param.id}
585+
{param.id === 'apiKey'
586+
? 'API Key'
587+
: param.id.length === 1 ||
588+
param.id.includes('_') ||
589+
param.id.includes('-')
590+
? param.id.toUpperCase()
591+
: param.id.match(/^[a-z]+$/)
592+
? param.id.charAt(0).toUpperCase() + param.id.slice(1)
593+
: param.id}
581594
</div>
582595
<div className="relative">
583596
<ShortInput
@@ -616,7 +629,7 @@ export function ToolInput({ blockId, subBlockId }: ToolInputProps) {
616629
</PopoverTrigger>
617630
<PopoverContent className="p-0 w-[200px]" align="start">
618631
<ToolCommand.Root filter={customFilter}>
619-
<ToolCommand.Input placeholder="Search tools..." />
632+
<ToolCommand.Input placeholder="Search tools..." onValueChange={setSearchQuery} />
620633
<ToolCommand.List>
621634
<ToolCommand.Empty>No tools found.</ToolCommand.Empty>
622635
<ToolCommand.Group>
@@ -691,27 +704,33 @@ export function ToolInput({ blockId, subBlockId }: ToolInputProps) {
691704
)}
692705

693706
{/* Display built-in tools */}
694-
<div className="px-2 pt-2.5 pb-0.5 text-xs font-medium text-muted-foreground">
695-
Built-in Tools
696-
</div>
697-
<ToolCommand.Group className="-mx-1 -px-1">
698-
{toolBlocks.map((block) => (
699-
<ToolCommand.Item
700-
key={block.type}
701-
value={block.name}
702-
onSelect={() => handleSelectTool(block)}
703-
className="flex items-center gap-2 cursor-pointer"
704-
>
705-
<div
706-
className="flex items-center justify-center w-6 h-6 rounded"
707-
style={{ backgroundColor: block.bgColor }}
708-
>
709-
<IconComponent icon={block.icon} className="w-4 h-4 text-white" />
710-
</div>
711-
<span className="truncate max-w-[140px]">{block.name}</span>
712-
</ToolCommand.Item>
713-
))}
714-
</ToolCommand.Group>
707+
{toolBlocks.some(
708+
(block) => customFilter(block.name, searchQuery || '') > 0
709+
) && (
710+
<>
711+
<div className="px-2 pt-2.5 pb-0.5 text-xs font-medium text-muted-foreground">
712+
Built-in Tools
713+
</div>
714+
<ToolCommand.Group className="-mx-1 -px-1">
715+
{toolBlocks.map((block) => (
716+
<ToolCommand.Item
717+
key={block.type}
718+
value={block.name}
719+
onSelect={() => handleSelectTool(block)}
720+
className="flex items-center gap-2 cursor-pointer"
721+
>
722+
<div
723+
className="flex items-center justify-center w-6 h-6 rounded"
724+
style={{ backgroundColor: block.bgColor }}
725+
>
726+
<IconComponent icon={block.icon} className="w-4 h-4 text-white" />
727+
</div>
728+
<span className="truncate max-w-[140px]">{block.name}</span>
729+
</ToolCommand.Item>
730+
))}
731+
</ToolCommand.Group>
732+
</>
733+
)}
715734
</ToolCommand.Group>
716735
</ToolCommand.List>
717736
</ToolCommand.Root>

sim/blocks/blocks/supabase.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ export const SupabaseBlock: BlockConfig<SupabaseResponse> = {
100100
},
101101
},
102102
inputs: {
103-
operation: { type: 'string', required: true },
104-
projectId: { type: 'string', required: true },
105-
table: { type: 'string', required: true },
106-
apiKey: { type: 'string', required: true },
103+
operation: { type: 'string', required: true, requiredForToolCall: true },
104+
projectId: { type: 'string', required: true, requiredForToolCall: true },
105+
table: { type: 'string', required: true, requiredForToolCall: true },
106+
apiKey: { type: 'string', required: true, requiredForToolCall: true },
107107
// Insert operation inputs
108-
data: { type: 'string', required: false },
108+
data: { type: 'string', required: false, requiredForToolCall: true },
109109
},
110110
outputs: {
111111
response: {

sim/tools/supabase/insert.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,18 @@ export const insertTool: ToolConfig<SupabaseInsertParams, SupabaseInsertResponse
1212
additionalScopes: ['database.write', 'projects.read'],
1313
},
1414
params: {
15-
apiKey: { type: 'string', required: true },
16-
projectId: { type: 'string', required: true },
15+
apiKey: {
16+
type: 'string',
17+
required: true,
18+
requiredForToolCall: true,
19+
description: 'Your Supabase client anon key'
20+
},
21+
projectId: {
22+
type: 'string',
23+
required: true,
24+
requiredForToolCall: true,
25+
description: 'Your Supabase project ID (e.g., jdrkgepadsdopsntdlom)'
26+
},
1727
table: { type: 'string', required: true },
1828
data: { type: 'any', required: true },
1929
},

sim/tools/supabase/query.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,18 @@ export const queryTool: ToolConfig<SupabaseQueryParams, SupabaseQueryResponse> =
1212
additionalScopes: ['database.read', 'projects.read'],
1313
},
1414
params: {
15-
apiKey: { type: 'string', required: true },
16-
projectId: { type: 'string', required: true },
15+
apiKey: {
16+
type: 'string',
17+
required: true,
18+
requiredForToolCall: true,
19+
description: 'Your Supabase client anon key'
20+
},
21+
projectId: {
22+
type: 'string',
23+
required: true,
24+
requiredForToolCall: true,
25+
description: 'Your Supabase project ID (e.g., jdrkgepadsdopsntdlom)'
26+
},
1727
table: { type: 'string', required: true },
1828
filter: { type: 'object', required: false },
1929
},

0 commit comments

Comments
 (0)