Skip to content

Commit b2919ba

Browse files
committed
Fix fast edit route
1 parent dd314de commit b2919ba

File tree

1 file changed

+0
-103
lines changed

1 file changed

+0
-103
lines changed

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

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { type NextRequest, NextResponse } from 'next/server'
1919
import { validateOAuthAccessToken } from '@/lib/auth/oauth-token'
2020
import { getHighestPrioritySubscription } from '@/lib/billing/core/subscription'
2121
import { ORCHESTRATION_TIMEOUT_MS, SIM_AGENT_API_URL } from '@/lib/copilot/constants'
22-
import { orchestrateCopilotStream } from '@/lib/copilot/orchestrator'
2322
import { orchestrateSubagentStream } from '@/lib/copilot/orchestrator/subagent'
2423
import {
2524
executeToolServerSide,
@@ -29,10 +28,6 @@ import { DIRECT_TOOL_DEFS, SUBAGENT_TOOL_DEFS } from '@/lib/copilot/tools/mcp/de
2928
import { env } from '@/lib/core/config/env'
3029
import { RateLimiter } from '@/lib/core/rate-limiter'
3130
import { getBaseUrl } from '@/lib/core/utils/urls'
32-
import {
33-
authorizeWorkflowByWorkspacePermission,
34-
resolveWorkflowIdForUser,
35-
} from '@/lib/workflows/utils'
3631

3732
const logger = createLogger('CopilotMcpAPI')
3833
const mcpRateLimiter = new RateLimiter()
@@ -665,110 +660,12 @@ async function handleDirectToolCall(
665660
}
666661
}
667662

668-
/**
669-
* Build mode uses the main chat orchestrator with the 'fast' command instead of
670-
* the subagent endpoint. In Go, 'build' is not a registered subagent — it's a mode
671-
* (ModeFast) on the main chat processor that bypasses subagent orchestration and
672-
* executes all tools directly.
673-
*/
674-
async function handleBuildToolCall(
675-
args: Record<string, unknown>,
676-
userId: string,
677-
abortSignal?: AbortSignal
678-
): Promise<CallToolResult> {
679-
try {
680-
const requestText = (args.request as string) || JSON.stringify(args)
681-
const workflowId = args.workflowId as string | undefined
682-
683-
const resolved = workflowId
684-
? await (async () => {
685-
const authorization = await authorizeWorkflowByWorkspacePermission({
686-
workflowId,
687-
userId,
688-
action: 'read',
689-
})
690-
return authorization.allowed ? { workflowId } : null
691-
})()
692-
: await resolveWorkflowIdForUser(userId)
693-
694-
if (!resolved?.workflowId) {
695-
return {
696-
content: [
697-
{
698-
type: 'text',
699-
text: JSON.stringify(
700-
{
701-
success: false,
702-
error: 'workflowId is required for build. Call create_workflow first.',
703-
},
704-
null,
705-
2
706-
),
707-
},
708-
],
709-
isError: true,
710-
}
711-
}
712-
713-
const chatId = randomUUID()
714-
715-
const requestPayload = {
716-
message: requestText,
717-
workflowId: resolved.workflowId,
718-
userId,
719-
model: DEFAULT_COPILOT_MODEL,
720-
mode: 'agent',
721-
commands: ['fast'],
722-
messageId: randomUUID(),
723-
chatId,
724-
}
725-
726-
const result = await orchestrateCopilotStream(requestPayload, {
727-
userId,
728-
workflowId: resolved.workflowId,
729-
chatId,
730-
goRoute: '/api/mcp',
731-
autoExecuteTools: true,
732-
timeout: 300000,
733-
interactive: false,
734-
abortSignal,
735-
})
736-
737-
const responseData = {
738-
success: result.success,
739-
content: result.content,
740-
toolCalls: result.toolCalls,
741-
error: result.error,
742-
}
743-
744-
return {
745-
content: [{ type: 'text', text: JSON.stringify(responseData, null, 2) }],
746-
isError: !result.success,
747-
}
748-
} catch (error) {
749-
logger.error('Build tool call failed', { error })
750-
return {
751-
content: [
752-
{
753-
type: 'text',
754-
text: `Build failed: ${error instanceof Error ? error.message : String(error)}`,
755-
},
756-
],
757-
isError: true,
758-
}
759-
}
760-
}
761-
762663
async function handleSubagentToolCall(
763664
toolDef: (typeof SUBAGENT_TOOL_DEFS)[number],
764665
args: Record<string, unknown>,
765666
userId: string,
766667
abortSignal?: AbortSignal
767668
): Promise<CallToolResult> {
768-
if (toolDef.agentId === 'build') {
769-
return handleBuildToolCall(args, userId, abortSignal)
770-
}
771-
772669
try {
773670
const requestText =
774671
(args.request as string) ||

0 commit comments

Comments
 (0)