Skip to content

Commit b359357

Browse files
committed
feat(tools): added workflow tools to agent tools dropdown for discoverability, enforce perms on client for redeploying via the agent
1 parent 0aec9ef commit b359357

File tree

3 files changed

+47
-5
lines changed

3 files changed

+47
-5
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/tool-input.tsx

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
Switch,
1717
Tooltip,
1818
} from '@/components/emcn'
19-
import { McpIcon } from '@/components/icons'
19+
import { McpIcon, WorkflowIcon } from '@/components/icons'
2020
import { cn } from '@/lib/core/utils/cn'
2121
import {
2222
getIssueBadgeLabel,
@@ -933,6 +933,13 @@ export function ToolInput({
933933
const forceRefreshMcpTools = useForceRefreshMcpTools()
934934
const openSettingsModal = useSettingsModalStore((state) => state.openModal)
935935
const mcpDataLoading = mcpLoading || mcpServersLoading
936+
937+
// Fetch workflows for the Workflows section in the dropdown
938+
const { data: workflowsList = [] } = useWorkflows(workspaceId, { syncRegistry: false })
939+
const availableWorkflows = useMemo(
940+
() => workflowsList.filter((w) => w.id !== workflowId),
941+
[workflowsList, workflowId]
942+
)
936943
const hasRefreshedRef = useRef(false)
937944

938945
const hasMcpTools = selectedTools.some((tool) => tool.type === 'mcp')
@@ -1735,6 +1742,36 @@ export function ToolInput({
17351742
})
17361743
}
17371744

1745+
// Workflows section - shows available workflows that can be executed as tools
1746+
if (availableWorkflows.length > 0) {
1747+
groups.push({
1748+
section: 'Workflows',
1749+
items: availableWorkflows.map((workflow) => ({
1750+
label: workflow.name,
1751+
value: `workflow-${workflow.id}`,
1752+
iconElement: createToolIcon('#6366F1', WorkflowIcon),
1753+
onSelect: () => {
1754+
const newTool: StoredTool = {
1755+
type: 'workflow',
1756+
title: 'Workflow',
1757+
toolId: 'workflow_executor',
1758+
params: {
1759+
workflowId: workflow.id,
1760+
},
1761+
isExpanded: true,
1762+
usageControl: 'auto',
1763+
}
1764+
setStoreValue([
1765+
...selectedTools.map((tool) => ({ ...tool, isExpanded: false })),
1766+
newTool,
1767+
])
1768+
setOpen(false)
1769+
},
1770+
disabled: isPreview || disabled,
1771+
})),
1772+
})
1773+
}
1774+
17381775
return groups
17391776
}, [
17401777
customTools,
@@ -1749,6 +1786,7 @@ export function ToolInput({
17491786
handleSelectTool,
17501787
permissionConfig.disableCustomTools,
17511788
permissionConfig.disableMcpTools,
1789+
availableWorkflows,
17521790
])
17531791

17541792
const toolRequiresOAuth = (toolId: string): boolean => {

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,11 +1021,11 @@ export const WorkflowBlock = memo(function WorkflowBlock({
10211021
<Tooltip.Trigger asChild>
10221022
<Badge
10231023
variant={!childIsDeployed ? 'red' : 'amber'}
1024-
className='cursor-pointer'
1024+
className={userPermissions.canAdmin ? 'cursor-pointer' : 'cursor-not-allowed'}
10251025
dot
10261026
onClick={(e) => {
10271027
e.stopPropagation()
1028-
if (childWorkflowId && !isDeploying) {
1028+
if (childWorkflowId && !isDeploying && userPermissions.canAdmin) {
10291029
deployWorkflow(childWorkflowId)
10301030
}
10311031
}}
@@ -1035,7 +1035,11 @@ export const WorkflowBlock = memo(function WorkflowBlock({
10351035
</Tooltip.Trigger>
10361036
<Tooltip.Content>
10371037
<span className='text-sm'>
1038-
{!childIsDeployed ? 'Click to deploy' : 'Click to redeploy'}
1038+
{!userPermissions.canAdmin
1039+
? 'Admin permission required to deploy'
1040+
: !childIsDeployed
1041+
? 'Click to deploy'
1042+
: 'Click to redeploy'}
10391043
</span>
10401044
</Tooltip.Content>
10411045
</Tooltip.Root>

apps/sim/tools/params.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export function getToolParametersConfig(
163163
id: 'workflowId',
164164
type: 'string',
165165
required: true,
166-
visibility: 'user-or-llm',
166+
visibility: 'user-only',
167167
description: 'The ID of the workflow to execute',
168168
uiComponent: {
169169
type: 'workflow-selector',

0 commit comments

Comments
 (0)