Skip to content

Commit bb44074

Browse files
committed
Merge remote-tracking branch 'origin/staging' into feat/canonical-subblock
2 parents a06360c + ce3ddb6 commit bb44074

File tree

85 files changed

+14427
-2117
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+14427
-2117
lines changed

apps/docs/tsconfig.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
"next-env.d.ts",
1212
"**/*.ts",
1313
"**/*.tsx",
14-
".next/types/**/*.ts",
1514
"content/docs/execution/index.mdx",
16-
"content/docs/connections/index.mdx",
17-
".next/dev/types/**/*.ts"
15+
"content/docs/connections/index.mdx"
1816
],
19-
"exclude": ["node_modules"]
17+
"exclude": ["node_modules", ".next"]
2018
}

apps/sim/app/_shell/providers/posthog-provider.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ export function PostHogProvider({ children }: { children: React.ReactNode }) {
1616
ui_host: 'https://us.posthog.com',
1717
defaults: '2025-05-24',
1818
person_profiles: 'identified_only',
19-
capture_pageview: true,
19+
autocapture: false,
20+
capture_pageview: false,
2021
capture_pageleave: false,
2122
capture_performance: false,
23+
capture_dead_clicks: false,
24+
enable_heatmaps: false,
2225
session_recording: {
2326
maskAllInputs: false,
2427
maskInputOptions: {
@@ -29,13 +32,7 @@ export function PostHogProvider({ children }: { children: React.ReactNode }) {
2932
recordHeaders: false,
3033
recordBody: false,
3134
},
32-
autocapture: {
33-
dom_event_allowlist: ['click', 'submit', 'change'],
34-
element_allowlist: ['button', 'a', 'input'],
35-
},
36-
capture_dead_clicks: false,
3735
persistence: 'localStorage+cookie',
38-
enable_heatmaps: false,
3936
})
4037
}
4138
}, [])

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

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { getSession } from '@/lib/auth'
88
import { generateChatTitle } from '@/lib/copilot/chat-title'
99
import { getCopilotModel } from '@/lib/copilot/config'
1010
import { SIM_AGENT_API_URL_DEFAULT, SIM_AGENT_VERSION } from '@/lib/copilot/constants'
11+
import { COPILOT_MODEL_IDS, COPILOT_REQUEST_MODES } from '@/lib/copilot/models'
1112
import {
1213
authenticateCopilotRequestSessionOnly,
1314
createBadRequestResponse,
@@ -40,34 +41,8 @@ const ChatMessageSchema = z.object({
4041
userMessageId: z.string().optional(), // ID from frontend for the user message
4142
chatId: z.string().optional(),
4243
workflowId: z.string().min(1, 'Workflow ID is required'),
43-
model: z
44-
.enum([
45-
'gpt-5-fast',
46-
'gpt-5',
47-
'gpt-5-medium',
48-
'gpt-5-high',
49-
'gpt-5.1-fast',
50-
'gpt-5.1',
51-
'gpt-5.1-medium',
52-
'gpt-5.1-high',
53-
'gpt-5-codex',
54-
'gpt-5.1-codex',
55-
'gpt-5.2',
56-
'gpt-5.2-codex',
57-
'gpt-5.2-pro',
58-
'gpt-4o',
59-
'gpt-4.1',
60-
'o3',
61-
'claude-4-sonnet',
62-
'claude-4.5-haiku',
63-
'claude-4.5-sonnet',
64-
'claude-4.5-opus',
65-
'claude-4.1-opus',
66-
'gemini-3-pro',
67-
])
68-
.optional()
69-
.default('claude-4.5-opus'),
70-
mode: z.enum(['ask', 'agent', 'plan']).optional().default('agent'),
44+
model: z.enum(COPILOT_MODEL_IDS).optional().default('claude-4.5-opus'),
45+
mode: z.enum(COPILOT_REQUEST_MODES).optional().default('agent'),
7146
prefetch: z.boolean().optional(),
7247
createNewChat: z.boolean().optional().default(false),
7348
stream: z.boolean().optional().default(true),
@@ -295,7 +270,8 @@ export async function POST(req: NextRequest) {
295270
}
296271

297272
const defaults = getCopilotModel('chat')
298-
const modelToUse = env.COPILOT_MODEL || defaults.model
273+
const selectedModel = model || defaults.model
274+
const envModel = env.COPILOT_MODEL || defaults.model
299275

300276
let providerConfig: CopilotProviderConfig | undefined
301277
const providerEnv = env.COPILOT_PROVIDER as any
@@ -304,28 +280,31 @@ export async function POST(req: NextRequest) {
304280
if (providerEnv === 'azure-openai') {
305281
providerConfig = {
306282
provider: 'azure-openai',
307-
model: modelToUse,
283+
model: envModel,
308284
apiKey: env.AZURE_OPENAI_API_KEY,
309285
apiVersion: 'preview',
310286
endpoint: env.AZURE_OPENAI_ENDPOINT,
311287
}
312288
} else if (providerEnv === 'vertex') {
313289
providerConfig = {
314290
provider: 'vertex',
315-
model: modelToUse,
291+
model: envModel,
316292
apiKey: env.COPILOT_API_KEY,
317293
vertexProject: env.VERTEX_PROJECT,
318294
vertexLocation: env.VERTEX_LOCATION,
319295
}
320296
} else {
321297
providerConfig = {
322298
provider: providerEnv,
323-
model: modelToUse,
299+
model: selectedModel,
324300
apiKey: env.COPILOT_API_KEY,
325301
}
326302
}
327303
}
328304

305+
const effectiveMode = mode === 'agent' ? 'build' : mode
306+
const transportMode = effectiveMode === 'build' ? 'agent' : effectiveMode
307+
329308
// Determine conversationId to use for this request
330309
const effectiveConversationId =
331310
(currentChat?.conversationId as string | undefined) || conversationId
@@ -345,7 +324,7 @@ export async function POST(req: NextRequest) {
345324
}
346325
} | null = null
347326

348-
if (mode === 'agent') {
327+
if (effectiveMode === 'build') {
349328
// Build base tools (executed locally, not deferred)
350329
// Include function_execute for code execution capability
351330
baseTools = [
@@ -452,8 +431,8 @@ export async function POST(req: NextRequest) {
452431
userId: authenticatedUserId,
453432
stream: stream,
454433
streamToolCalls: true,
455-
model: model,
456-
mode: mode,
434+
model: selectedModel,
435+
mode: transportMode,
457436
messageId: userMessageIdToUse,
458437
version: SIM_AGENT_VERSION,
459438
...(providerConfig ? { provider: providerConfig } : {}),
@@ -477,7 +456,7 @@ export async function POST(req: NextRequest) {
477456
hasConversationId: !!effectiveConversationId,
478457
hasFileAttachments: processedFileContents.length > 0,
479458
messageLength: message.length,
480-
mode,
459+
mode: effectiveMode,
481460
hasTools: integrationTools.length > 0,
482461
toolCount: integrationTools.length,
483462
hasBaseTools: baseTools.length > 0,

apps/sim/app/api/copilot/chat/update-messages/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { createLogger } from '@sim/logger'
44
import { and, eq } from 'drizzle-orm'
55
import { type NextRequest, NextResponse } from 'next/server'
66
import { z } from 'zod'
7+
import { COPILOT_MODES } from '@/lib/copilot/models'
78
import {
89
authenticateCopilotRequestSessionOnly,
910
createInternalServerErrorResponse,
@@ -45,7 +46,7 @@ const UpdateMessagesSchema = z.object({
4546
planArtifact: z.string().nullable().optional(),
4647
config: z
4748
.object({
48-
mode: z.enum(['ask', 'build', 'plan']).optional(),
49+
mode: z.enum(COPILOT_MODES).optional(),
4950
model: z.string().optional(),
5051
})
5152
.nullable()

apps/sim/app/api/copilot/user-models/route.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import { createLogger } from '@sim/logger'
22
import { eq } from 'drizzle-orm'
33
import { type NextRequest, NextResponse } from 'next/server'
44
import { getSession } from '@/lib/auth'
5+
import type { CopilotModelId } from '@/lib/copilot/models'
56
import { db } from '@/../../packages/db'
67
import { settings } from '@/../../packages/db/schema'
78

89
const logger = createLogger('CopilotUserModelsAPI')
910

10-
const DEFAULT_ENABLED_MODELS: Record<string, boolean> = {
11+
const DEFAULT_ENABLED_MODELS: Record<CopilotModelId, boolean> = {
1112
'gpt-4o': false,
1213
'gpt-4.1': false,
1314
'gpt-5-fast': false,
@@ -28,7 +29,7 @@ const DEFAULT_ENABLED_MODELS: Record<string, boolean> = {
2829
'claude-4.5-haiku': true,
2930
'claude-4.5-sonnet': true,
3031
'claude-4.5-opus': true,
31-
// 'claude-4.1-opus': true,
32+
'claude-4.1-opus': false,
3233
'gemini-3-pro': true,
3334
}
3435

@@ -54,7 +55,9 @@ export async function GET(request: NextRequest) {
5455

5556
const mergedModels = { ...DEFAULT_ENABLED_MODELS }
5657
for (const [modelId, enabled] of Object.entries(userModelsMap)) {
57-
mergedModels[modelId] = enabled
58+
if (modelId in mergedModels) {
59+
mergedModels[modelId as CopilotModelId] = enabled
60+
}
5861
}
5962

6063
const hasNewModels = Object.keys(DEFAULT_ENABLED_MODELS).some(

apps/sim/app/api/mcp/serve/[serverId]/route.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { createLogger } from '@sim/logger'
2020
import { and, eq } from 'drizzle-orm'
2121
import { type NextRequest, NextResponse } from 'next/server'
2222
import { checkHybridAuth } from '@/lib/auth/hybrid'
23+
import { generateInternalToken } from '@/lib/auth/internal'
2324
import { getBaseUrl } from '@/lib/core/utils/urls'
2425

2526
const logger = createLogger('WorkflowMcpServeAPI')
@@ -52,6 +53,8 @@ async function getServer(serverId: string) {
5253
id: workflowMcpServer.id,
5354
name: workflowMcpServer.name,
5455
workspaceId: workflowMcpServer.workspaceId,
56+
isPublic: workflowMcpServer.isPublic,
57+
createdBy: workflowMcpServer.createdBy,
5558
})
5659
.from(workflowMcpServer)
5760
.where(eq(workflowMcpServer.id, serverId))
@@ -90,9 +93,11 @@ export async function POST(request: NextRequest, { params }: { params: Promise<R
9093
return NextResponse.json({ error: 'Server not found' }, { status: 404 })
9194
}
9295

93-
const auth = await checkHybridAuth(request, { requireWorkflowId: false })
94-
if (!auth.success || !auth.userId) {
95-
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
96+
if (!server.isPublic) {
97+
const auth = await checkHybridAuth(request, { requireWorkflowId: false })
98+
if (!auth.success || !auth.userId) {
99+
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
100+
}
96101
}
97102

98103
const body = await request.json()
@@ -138,7 +143,8 @@ export async function POST(request: NextRequest, { params }: { params: Promise<R
138143
id,
139144
serverId,
140145
rpcParams as { name: string; arguments?: Record<string, unknown> },
141-
apiKey
146+
apiKey,
147+
server.isPublic ? server.createdBy : undefined
142148
)
143149

144150
default:
@@ -200,7 +206,8 @@ async function handleToolsCall(
200206
id: RequestId,
201207
serverId: string,
202208
params: { name: string; arguments?: Record<string, unknown> } | undefined,
203-
apiKey?: string | null
209+
apiKey?: string | null,
210+
publicServerOwnerId?: string
204211
): Promise<NextResponse> {
205212
try {
206213
if (!params?.name) {
@@ -243,7 +250,13 @@ async function handleToolsCall(
243250

244251
const executeUrl = `${getBaseUrl()}/api/workflows/${tool.workflowId}/execute`
245252
const headers: Record<string, string> = { 'Content-Type': 'application/json' }
246-
if (apiKey) headers['X-API-Key'] = apiKey
253+
254+
if (publicServerOwnerId) {
255+
const internalToken = await generateInternalToken(publicServerOwnerId)
256+
headers.Authorization = `Bearer ${internalToken}`
257+
} else if (apiKey) {
258+
headers['X-API-Key'] = apiKey
259+
}
247260

248261
logger.info(`Executing workflow ${tool.workflowId} via MCP tool ${params.name}`)
249262

apps/sim/app/api/mcp/workflow-servers/[id]/route.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export const GET = withMcpAuth<RouteParams>('read')(
3131
createdBy: workflowMcpServer.createdBy,
3232
name: workflowMcpServer.name,
3333
description: workflowMcpServer.description,
34+
isPublic: workflowMcpServer.isPublic,
3435
createdAt: workflowMcpServer.createdAt,
3536
updatedAt: workflowMcpServer.updatedAt,
3637
})
@@ -98,6 +99,9 @@ export const PATCH = withMcpAuth<RouteParams>('write')(
9899
if (body.description !== undefined) {
99100
updateData.description = body.description?.trim() || null
100101
}
102+
if (body.isPublic !== undefined) {
103+
updateData.isPublic = body.isPublic
104+
}
101105

102106
const [updatedServer] = await db
103107
.update(workflowMcpServer)

apps/sim/app/api/mcp/workflow-servers/[id]/tools/[toolId]/route.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export const GET = withMcpAuth<RouteParams>('read')(
2626

2727
logger.info(`[${requestId}] Getting tool ${toolId} from server ${serverId}`)
2828

29-
// Verify server exists and belongs to workspace
3029
const [server] = await db
3130
.select({ id: workflowMcpServer.id })
3231
.from(workflowMcpServer)
@@ -72,7 +71,6 @@ export const PATCH = withMcpAuth<RouteParams>('write')(
7271

7372
logger.info(`[${requestId}] Updating tool ${toolId} in server ${serverId}`)
7473

75-
// Verify server exists and belongs to workspace
7674
const [server] = await db
7775
.select({ id: workflowMcpServer.id })
7876
.from(workflowMcpServer)
@@ -139,7 +137,6 @@ export const DELETE = withMcpAuth<RouteParams>('write')(
139137

140138
logger.info(`[${requestId}] Deleting tool ${toolId} from server ${serverId}`)
141139

142-
// Verify server exists and belongs to workspace
143140
const [server] = await db
144141
.select({ id: workflowMcpServer.id })
145142
.from(workflowMcpServer)

0 commit comments

Comments
 (0)