Skip to content

Commit 7dc258a

Browse files
committed
file/folder tools
1 parent b06c3eb commit 7dc258a

File tree

11 files changed

+126
-125
lines changed

11 files changed

+126
-125
lines changed

apps/sim/app/api/mcp/copilot/route.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,10 @@ Sim is a workflow automation platform. Workflows are visual pipelines of connect
122122
123123
1. \`list_workspaces\` → know where to work
124124
2. \`create_workflow(name, workspaceId)\` → get a workflowId
125-
3. \`sim_build(request, workflowId)\` → plan and build in one pass
125+
3. \`sim_workflow(request, workflowId)\` → plan and build in one pass
126126
4. \`sim_test(request, workflowId)\` → verify it works
127127
5. \`sim_deploy("deploy as api", workflowId)\` → make it accessible externally (optional)
128128
129-
For fine-grained control, use \`sim_plan\` → \`sim_edit\` instead of \`sim_build\`. Pass the plan object from sim_plan EXACTLY as-is to sim_edit's context.plan field.
130-
131129
### Working with Existing Workflows
132130
133131
When the user refers to a workflow by name or description ("the email one", "my Slack bot"):
@@ -670,7 +668,7 @@ async function handleDirectToolCall(
670668

671669
/**
672670
* Build mode uses the main chat orchestrator with the 'fast' command instead of
673-
* the subagent endpoint. In Go, 'build' is not a registered subagent — it's a mode
671+
* the subagent endpoint. In Go, 'workflow' is not a registered subagent — it's a mode
674672
* (ModeFast) on the main chat processor that bypasses subagent orchestration and
675673
* executes all tools directly.
676674
*/
@@ -768,7 +766,7 @@ async function handleSubagentToolCall(
768766
userId: string,
769767
abortSignal?: AbortSignal
770768
): Promise<CallToolResult> {
771-
if (toolDef.agentId === 'build') {
769+
if (toolDef.agentId === 'workflow') {
772770
return handleBuildToolCall(args, userId, abortSignal)
773771
}
774772

apps/sim/app/workspace/[workspaceId]/home/components/message-content/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const TOOL_ICONS: Record<string, IconComponent> = {
4343
workspace_file: File,
4444
create_workflow: Layout,
4545
edit_workflow: Pencil,
46-
build: Hammer,
46+
workflow: Hammer,
4747
run: PlayOutline,
4848
deploy: Rocket,
4949
auth: Integration,

apps/sim/app/workspace/[workspaceId]/home/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {
22
Agent,
33
Auth,
4-
Build,
54
CreateWorkflow,
65
Debug,
76
Deploy,
@@ -26,6 +25,7 @@ import {
2625
Table,
2726
UserMemory,
2827
UserTable,
28+
Workflow,
2929
WorkspaceFile,
3030
} from '@/lib/copilot/generated/tool-catalog-v1'
3131
import type { ChatContext } from '@/stores/panel'
@@ -173,7 +173,7 @@ export interface ChatMessage {
173173
}
174174

175175
export const SUBAGENT_LABELS: Record<string, string> = {
176-
build: 'Build agent',
176+
workflow: 'Workflow agent',
177177
deploy: 'Deploy agent',
178178
auth: 'Integration agent',
179179
research: 'Research agent',
@@ -276,7 +276,7 @@ export const TOOL_UI_METADATA: Record<string, ToolUIMetadata> = {
276276
phaseLabel: 'Resource',
277277
phase: 'resource',
278278
},
279-
[Build.id]: { title: 'Building', phaseLabel: 'Build', phase: 'subagent' },
279+
[Workflow.id]: { title: 'Managing workflow', phaseLabel: 'Workflow', phase: 'subagent' },
280280
[Run.id]: { title: 'Running', phaseLabel: 'Run', phase: 'subagent' },
281281
[Deploy.id]: { title: 'Deploying', phaseLabel: 'Deploy', phase: 'subagent' },
282282
[Auth.id]: {

apps/sim/lib/copilot/chat/persisted-message.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('persisted-message', () => {
2020
{
2121
type: 'tool_call',
2222
timestamp: Date.now(),
23-
calledBy: 'build',
23+
calledBy: 'workflow',
2424
toolCall: {
2525
id: 'tool-1',
2626
name: 'read',
@@ -46,7 +46,7 @@ describe('persisted-message', () => {
4646
state: 'success',
4747
params: { path: 'foo.txt' },
4848
result: { success: true, output: { ok: true } },
49-
calledBy: 'build',
49+
calledBy: 'workflow',
5050
},
5151
},
5252
{

apps/sim/lib/copilot/chat/workspace-context.ts

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export interface WorkspaceMdData {
4545
description?: string | null
4646
isDeployed: boolean
4747
lastRunAt?: Date | null
48+
folderPath?: string | null
4849
}>
4950
knowledgeBases: Array<{
5051
id: string
@@ -92,15 +93,40 @@ export function buildWorkspaceMd(data: WorkspaceMdData): string {
9293
}
9394

9495
if (data.workflows.length > 0) {
95-
const lines = data.workflows.map((wf) => {
96-
const parts = [`- **${wf.name}** (${wf.id})`]
97-
if (wf.description) parts.push(` ${wf.description}`)
96+
const rootWorkflows: typeof data.workflows = []
97+
const folderWorkflows = new Map<string, typeof data.workflows>()
98+
99+
for (const wf of data.workflows) {
100+
if (wf.folderPath) {
101+
const existing = folderWorkflows.get(wf.folderPath) ?? []
102+
existing.push(wf)
103+
folderWorkflows.set(wf.folderPath, existing)
104+
} else {
105+
rootWorkflows.push(wf)
106+
}
107+
}
108+
109+
const formatWf = (wf: (typeof data.workflows)[0], indent: string) => {
110+
const parts = [`${indent}- **${wf.name}** (${wf.id})`]
111+
if (wf.description) parts.push(`${indent} ${wf.description}`)
98112
const flags: string[] = []
99113
if (wf.isDeployed) flags.push('deployed')
100114
if (wf.lastRunAt) flags.push(`last run: ${wf.lastRunAt.toISOString().split('T')[0]}`)
101115
if (flags.length > 0) parts[0] += ` — ${flags.join(', ')}`
102116
return parts.join('\n')
103-
})
117+
}
118+
119+
const lines: string[] = []
120+
for (const wf of rootWorkflows) {
121+
lines.push(formatWf(wf, ''))
122+
}
123+
const sortedFolders = [...folderWorkflows.entries()].sort((a, b) => a[0].localeCompare(b[0]))
124+
for (const [folder, wfs] of sortedFolders) {
125+
lines.push(`- 📁 **${folder}/**`)
126+
for (const wf of wfs) {
127+
lines.push(formatWf(wf, ' '))
128+
}
129+
}
104130
sections.push(`## Workflows (${data.workflows.length})\n${lines.join('\n')}`)
105131
} else {
106132
sections.push('## Workflows (0)\n(none)')

apps/sim/lib/copilot/generated/tool-catalog-v1.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export interface ToolCatalogEntry {
99
id:
1010
| 'agent'
1111
| 'auth'
12-
| 'build'
1312
| 'check_deployment_status'
1413
| 'complete_job'
1514
| 'context_write'
@@ -84,13 +83,13 @@ export interface ToolCatalogEntry {
8483
| 'update_workspace_mcp_server'
8584
| 'user_memory'
8685
| 'user_table'
86+
| 'workflow'
8787
| 'workspace_file'
8888
internal?: boolean
8989
mode: 'async' | 'sync'
9090
name:
9191
| 'agent'
9292
| 'auth'
93-
| 'build'
9493
| 'check_deployment_status'
9594
| 'complete_job'
9695
| 'context_write'
@@ -165,13 +164,13 @@ export interface ToolCatalogEntry {
165164
| 'update_workspace_mcp_server'
166165
| 'user_memory'
167166
| 'user_table'
167+
| 'workflow'
168168
| 'workspace_file'
169169
requiredPermission?: 'admin' | 'write'
170170
requiresConfirmation?: boolean
171171
subagentId?:
172172
| 'agent'
173173
| 'auth'
174-
| 'build'
175174
| 'debug'
176175
| 'deploy'
177176
| 'file_write'
@@ -181,6 +180,7 @@ export interface ToolCatalogEntry {
181180
| 'run'
182181
| 'superagent'
183182
| 'table'
183+
| 'workflow'
184184
}
185185

186186
export const Agent: ToolCatalogEntry = {
@@ -202,15 +202,6 @@ export const Auth: ToolCatalogEntry = {
202202
internal: true,
203203
}
204204

205-
export const Build: ToolCatalogEntry = {
206-
id: 'build',
207-
name: 'build',
208-
executor: 'subagent',
209-
mode: 'async',
210-
subagentId: 'build',
211-
internal: true,
212-
}
213-
214205
export const CheckDeploymentStatus: ToolCatalogEntry = {
215206
id: 'check_deployment_status',
216207
name: 'check_deployment_status',
@@ -801,6 +792,15 @@ export const UserTable: ToolCatalogEntry = {
801792
requiresConfirmation: true,
802793
}
803794

795+
export const Workflow: ToolCatalogEntry = {
796+
id: 'workflow',
797+
name: 'workflow',
798+
executor: 'subagent',
799+
mode: 'async',
800+
subagentId: 'workflow',
801+
internal: true,
802+
}
803+
804804
export const WorkspaceFile: ToolCatalogEntry = {
805805
id: 'workspace_file',
806806
name: 'workspace_file',
@@ -812,7 +812,6 @@ export const WorkspaceFile: ToolCatalogEntry = {
812812
export const TOOL_CATALOG: Record<string, ToolCatalogEntry> = {
813813
[Agent.id]: Agent,
814814
[Auth.id]: Auth,
815-
[Build.id]: Build,
816815
[CheckDeploymentStatus.id]: CheckDeploymentStatus,
817816
[CompleteJob.id]: CompleteJob,
818817
[ContextWrite.id]: ContextWrite,
@@ -887,5 +886,6 @@ export const TOOL_CATALOG: Record<string, ToolCatalogEntry> = {
887886
[UpdateWorkspaceMcpServer.id]: UpdateWorkspaceMcpServer,
888887
[UserMemory.id]: UserMemory,
889888
[UserTable.id]: UserTable,
889+
[Workflow.id]: Workflow,
890890
[WorkspaceFile.id]: WorkspaceFile,
891891
}

apps/sim/lib/copilot/request/handlers/handlers.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ describe('sse-handlers tool lifecycle', () => {
132132
context.subAgentParentStack = ['parent-1']
133133
context.toolCalls.set('parent-1', {
134134
id: 'parent-1',
135-
name: 'build',
135+
name: 'workflow',
136136
status: 'pending',
137137
startTime: Date.now(),
138138
})
139139

140140
await subAgentHandlers.tool(
141141
{
142142
type: MothershipStreamV1EventType.tool,
143-
scope: { lane: 'subagent', parentToolCallId: 'parent-1', agentId: 'build' },
143+
scope: { lane: 'subagent', parentToolCallId: 'parent-1', agentId: 'workflow' },
144144
payload: {
145145
toolCallId: 'sub-tool-1',
146146
toolName: 'create_workflow',
@@ -158,7 +158,7 @@ describe('sse-handlers tool lifecycle', () => {
158158
await subAgentHandlers.tool(
159159
{
160160
type: MothershipStreamV1EventType.tool,
161-
scope: { lane: 'subagent', parentToolCallId: 'parent-1', agentId: 'build' },
161+
scope: { lane: 'subagent', parentToolCallId: 'parent-1', agentId: 'workflow' },
162162
payload: {
163163
toolCallId: 'sub-tool-1',
164164
toolName: 'create_workflow',

apps/sim/lib/copilot/tools/client/tool-display-registry.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -371,20 +371,20 @@ const META_manage_skill: ToolMetadata = {
371371
},
372372
}
373373

374-
const META_build: ToolMetadata = {
374+
const META_workflow: ToolMetadata = {
375375
displayNames: {
376-
[ClientToolCallState.generating]: { text: 'Building', icon: Loader2 },
377-
[ClientToolCallState.pending]: { text: 'Building', icon: Loader2 },
378-
[ClientToolCallState.executing]: { text: 'Building', icon: Loader2 },
379-
[ClientToolCallState.success]: { text: 'Built', icon: Wrench },
380-
[ClientToolCallState.error]: { text: 'Failed to build', icon: XCircle },
381-
[ClientToolCallState.rejected]: { text: 'Skipped build', icon: XCircle },
382-
[ClientToolCallState.aborted]: { text: 'Aborted build', icon: XCircle },
376+
[ClientToolCallState.generating]: { text: 'Managing workflow', icon: Loader2 },
377+
[ClientToolCallState.pending]: { text: 'Managing workflow', icon: Loader2 },
378+
[ClientToolCallState.executing]: { text: 'Managing workflow', icon: Loader2 },
379+
[ClientToolCallState.success]: { text: 'Done', icon: Wrench },
380+
[ClientToolCallState.error]: { text: 'Failed', icon: XCircle },
381+
[ClientToolCallState.rejected]: { text: 'Skipped', icon: XCircle },
382+
[ClientToolCallState.aborted]: { text: 'Aborted', icon: XCircle },
383383
},
384384
uiConfig: {
385385
subagent: {
386-
streamingLabel: 'Building',
387-
completedLabel: 'Built',
386+
streamingLabel: 'Managing workflow',
387+
completedLabel: 'Done',
388388
shouldCollapse: true,
389389
outputArtifacts: [],
390390
},
@@ -2298,7 +2298,7 @@ const TOOL_METADATA_BY_ID: Record<string, ToolMetadata> = {
22982298
checkoff_todo: META_checkoff_todo,
22992299
crawl_website: META_crawl_website,
23002300
create_workspace_mcp_server: META_create_workspace_mcp_server,
2301-
build: META_build,
2301+
workflow: META_workflow,
23022302
create_folder: META_create_folder,
23032303
create_workflow: META_create_workflow,
23042304
agent: META_agent,

0 commit comments

Comments
 (0)