Skip to content

Commit c673200

Browse files
committed
Fix bugs
1 parent 72229a3 commit c673200

File tree

3 files changed

+51
-1
lines changed
  • apps/sim
    • app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/tool-call
    • lib/copilot/tools/client/other
    • stores/panel/copilot

3 files changed

+51
-1
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/tool-call/tool-call.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,8 @@ function getSubagentLabels(toolName: string, isStreaming: boolean): string {
328328
return isStreaming ? 'Touring' : 'Tour complete'
329329
case 'info':
330330
return isStreaming ? 'Getting info' : 'Info retrieved'
331+
case 'workflow':
332+
return isStreaming ? 'Managing workflow' : 'Workflow managed'
331333
default:
332334
return isStreaming ? 'Processing' : 'Processed'
333335
}
@@ -806,7 +808,7 @@ export function ToolCall({ toolCall: toolCallProp, toolCallId, onStateChange }:
806808
if (toolCall.name === 'checkoff_todo' || toolCall.name === 'mark_todo_in_progress') return null
807809

808810
// Special rendering for subagent tools - only show the collapsible SubAgentContent
809-
const SUBAGENT_TOOLS = ['plan', 'edit', 'debug', 'test', 'deploy', 'auth', 'research', 'knowledge', 'custom_tool', 'tour', 'info']
811+
const SUBAGENT_TOOLS = ['plan', 'edit', 'debug', 'test', 'deploy', 'auth', 'research', 'knowledge', 'custom_tool', 'tour', 'info', 'workflow']
810812
const isSubagentTool = SUBAGENT_TOOLS.includes(toolCall.name)
811813
if (isSubagentTool && toolCall.subAgentBlocks && toolCall.subAgentBlocks.length > 0) {
812814
return (
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { GitBranch, Loader2, XCircle } from 'lucide-react'
2+
import {
3+
BaseClientTool,
4+
type BaseClientToolMetadata,
5+
ClientToolCallState,
6+
} from '@/lib/copilot/tools/client/base-tool'
7+
8+
interface WorkflowArgs {
9+
instruction: string
10+
}
11+
12+
/**
13+
* Workflow tool that spawns a subagent to manage workflows.
14+
* This tool auto-executes and the actual work is done by the workflow subagent.
15+
* The subagent's output is streamed as nested content under this tool call.
16+
*/
17+
export class WorkflowClientTool extends BaseClientTool {
18+
static readonly id = 'workflow'
19+
20+
constructor(toolCallId: string) {
21+
super(toolCallId, WorkflowClientTool.id, WorkflowClientTool.metadata)
22+
}
23+
24+
static readonly metadata: BaseClientToolMetadata = {
25+
displayNames: {
26+
[ClientToolCallState.generating]: { text: 'Managing workflow', icon: Loader2 },
27+
[ClientToolCallState.pending]: { text: 'Managing workflow', icon: Loader2 },
28+
[ClientToolCallState.executing]: { text: 'Managing workflow', icon: Loader2 },
29+
[ClientToolCallState.success]: { text: 'Workflow managed', icon: GitBranch },
30+
[ClientToolCallState.error]: { text: 'Failed to manage workflow', icon: XCircle },
31+
[ClientToolCallState.rejected]: { text: 'Workflow skipped', icon: XCircle },
32+
[ClientToolCallState.aborted]: { text: 'Workflow aborted', icon: XCircle },
33+
},
34+
}
35+
36+
/**
37+
* Execute the workflow tool.
38+
* This just marks the tool as executing - the actual workflow work is done server-side
39+
* by the workflow subagent, and its output is streamed as subagent events.
40+
*/
41+
async execute(_args?: WorkflowArgs): Promise<void> {
42+
this.setState(ClientToolCallState.executing)
43+
}
44+
}
45+

apps/sim/stores/panel/copilot/store.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { KnowledgeClientTool } from '@/lib/copilot/tools/client/other/knowledge'
4646
import { CustomToolClientTool } from '@/lib/copilot/tools/client/other/custom-tool'
4747
import { TourClientTool } from '@/lib/copilot/tools/client/other/tour'
4848
import { InfoClientTool } from '@/lib/copilot/tools/client/other/info'
49+
import { WorkflowClientTool } from '@/lib/copilot/tools/client/other/workflow'
4950
import { createExecutionContext, getTool } from '@/lib/copilot/tools/client/registry'
5051
import { GetCredentialsClientTool } from '@/lib/copilot/tools/client/user/get-credentials'
5152
import { SetEnvironmentVariablesClientTool } from '@/lib/copilot/tools/client/user/set-environment-variables'
@@ -99,6 +100,7 @@ const CLIENT_TOOL_INSTANTIATORS: Record<string, (id: string) => any> = {
99100
custom_tool: (id) => new CustomToolClientTool(id),
100101
tour: (id) => new TourClientTool(id),
101102
info: (id) => new InfoClientTool(id),
103+
workflow: (id) => new WorkflowClientTool(id),
102104
run_workflow: (id) => new RunWorkflowClientTool(id),
103105
get_workflow_console: (id) => new GetWorkflowConsoleClientTool(id),
104106
get_blocks_and_tools: (id) => new GetBlocksAndToolsClientTool(id),
@@ -151,6 +153,7 @@ export const CLASS_TOOL_METADATA: Record<string, BaseClientToolMetadata | undefi
151153
custom_tool: (CustomToolClientTool as any)?.metadata,
152154
tour: (TourClientTool as any)?.metadata,
153155
info: (InfoClientTool as any)?.metadata,
156+
workflow: (WorkflowClientTool as any)?.metadata,
154157
run_workflow: (RunWorkflowClientTool as any)?.metadata,
155158
get_workflow_console: (GetWorkflowConsoleClientTool as any)?.metadata,
156159
get_blocks_and_tools: (GetBlocksAndToolsClientTool as any)?.metadata,

0 commit comments

Comments
 (0)