Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
8f0ef58
v0.5.7: combobox selectors, usage indicator, workflow loading race co…
icecrasher321 Nov 18, 2025
31c34b2
v0.5.8: notifications, billing, ui changes, store loading state machine
icecrasher321 Nov 20, 2025
842ef27
v0.5.9: add backwards compatibility for agent messages array
waleedlatif1 Nov 20, 2025
b7e814b
v0.5.10: copilot upgrade, preprocessor, logs search, UI, code hygiene
waleedlatif1 Nov 21, 2025
ebcd243
v0.5.11: stt, videogen, vllm, billing fixes, new models
waleedlatif1 Nov 25, 2025
1d08796
v0.5.12: memory optimizations, sentry, incidentio, posthog, zendesk, …
waleedlatif1 Nov 29, 2025
8c32ad4
v0.5.13: polling fixes, generic agent search tool, status page, smtp,…
waleedlatif1 Dec 1, 2025
54cc937
v0.5.14: fix issue with teams, google selectors + cleanup code
icecrasher321 Dec 1, 2025
774e5d5
v0.5.15: add tools, revert subblock prop change
icecrasher321 Dec 1, 2025
e157ce5
v0.5.16: MCP fixes, code refactors, jira fixes, new mistral models
waleedlatif1 Dec 3, 2025
3187493
v0.5.17: modals, billing fixes, bun update, zoom, dropbox, kalshi, po…
waleedlatif1 Dec 4, 2025
c3afbdd
Superagent poc
Sg312 Nov 26, 2025
04eeb59
Checkpoint brokeN
Sg312 Dec 1, 2025
7913c67
tool call rag
Sg312 Dec 2, 2025
a21b796
Fix
Sg312 Dec 2, 2025
0517d61
Fixes
Sg312 Dec 2, 2025
804c157
Improvements
Sg312 Dec 2, 2025
5ec85be
Creds stuff
Sg312 Dec 2, 2025
09bb84f
Fix
Sg312 Dec 2, 2025
dca8c78
Fix tools
Sg312 Dec 2, 2025
0258ca3
Fix stream
Sg312 Dec 3, 2025
88f5bfb
Prompt
Sg312 Dec 3, 2025
10ae3ed
Update sheets descriptions
Sg312 Dec 3, 2025
63d36b7
Better
Sg312 Dec 3, 2025
1f1a73e
Copilot components
Sg312 Dec 3, 2025
67ad858
Delete stuff
Sg312 Dec 3, 2025
d160090
Remove db migration
Sg312 Dec 3, 2025
9fe4cf4
Fix migrations
Sg312 Dec 3, 2025
5dced7f
Fix things
Sg312 Dec 3, 2025
3b56e01
Copilot side superagent
Sg312 Dec 3, 2025
b6ca604
Build workflow from chat
Sg312 Dec 3, 2025
114a224
Combine superagent into copilkot
Sg312 Dec 3, 2025
70b6a40
Render tools
Sg312 Dec 3, 2025
1c53dd7
Function execution
Sg312 Dec 3, 2025
c77405b
Max mode indicators
Sg312 Dec 3, 2025
e8c4f23
Tool call confirmations
Sg312 Dec 3, 2025
ab07356
Credential settings
Sg312 Dec 3, 2025
06aecd7
Remove betas
Sg312 Dec 3, 2025
67a8485
Bump version
Sg312 Dec 3, 2025
3af1a35
Dropdown options in block metadata
Sg312 Dec 3, 2025
23980a2
Copilot kb tools
Sg312 Dec 3, 2025
308847e
Fix lint
Sg312 Dec 4, 2025
1d22630
Credentials modal
Sg312 Dec 4, 2025
19bb425
Fix lint
Sg312 Dec 4, 2025
b0d27b9
Cleanup
Sg312 Dec 4, 2025
8331cc7
Env var resolution in superagent tools
Sg312 Dec 4, 2025
02b4035
Get id for workflow vars
Sg312 Dec 4, 2025
6e8b18c
Fix insert into subflow
Sg312 Dec 4, 2025
3241daf
Fix executor for while and do while loops
Sg312 Dec 4, 2025
756293b
Fix metadata for parallel
Sg312 Dec 5, 2025
1958448
Remove db migration
Sg312 Dec 5, 2025
de3457f
Rebase
Sg312 Dec 5, 2025
b5a8f1e
Add migrations back
Sg312 Dec 5, 2025
89e7a51
Clean up code
Sg312 Dec 5, 2025
71bcc2d
Fix executor logic issue
Sg312 Dec 5, 2025
8179e49
Cleanup
Sg312 Dec 5, 2025
f8b6e50
Diagram tool
Sg312 Dec 5, 2025
2c5d2e4
Fix tool naems
Sg312 Dec 5, 2025
813f519
Comment out g3p
Sg312 Dec 5, 2025
63a5efc
Remove popup option
Sg312 Dec 5, 2025
2009b0c
Hide o3
Sg312 Dec 5, 2025
8e64a55
Remove db migration
Sg312 Dec 5, 2025
65701c4
Merge remote-tracking branch 'origin' into feat/superagent
Sg312 Dec 5, 2025
95709c5
Merge branch 'staging' into feat/superagent
Sg312 Dec 5, 2025
fa65d31
Fix merge conflicts
Sg312 Dec 5, 2025
3eb448a
Fix lint
Sg312 Dec 5, 2025
f0bc5d0
Fix tests
Sg312 Dec 5, 2025
dafca72
Remove webhook change
Sg312 Dec 5, 2025
adae879
Remove cb change
Sg312 Dec 5, 2025
77de64b
Fix lint
Sg312 Dec 5, 2025
c2a81a6
Fix
Sg312 Dec 5, 2025
7e677d0
Fix lint
Sg312 Dec 5, 2025
833d301
Fix build
Sg312 Dec 5, 2025
3d8796c
comment out gemini
Sg312 Dec 5, 2025
8655975
Add gemini back
Sg312 Dec 5, 2025
dc27220
Merge branch 'staging' into feat/superagent
Sg312 Dec 5, 2025
2deb727
Remove bad test
Sg312 Dec 5, 2025
aca1fa6
Fix
Sg312 Dec 5, 2025
8696baa
Fix test
Sg312 Dec 5, 2025
e4fab34
Fix
Sg312 Dec 5, 2025
3d66f11
Nuke bad test
Sg312 Dec 5, 2025
6e55083
Fix lint
Sg312 Dec 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 150 additions & 0 deletions apps/sim/app/api/copilot/auto-allowed-tools/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import { db } from '@sim/db'
import { settings } from '@sim/db/schema'
import { eq } from 'drizzle-orm'
import { type NextRequest, NextResponse } from 'next/server'
import { auth } from '@/lib/auth'
import { createLogger } from '@/lib/logs/console/logger'

const logger = createLogger('CopilotAutoAllowedToolsAPI')

/**
* GET - Fetch user's auto-allowed integration tools
*/
export async function GET(request: NextRequest) {
try {
const session = await auth.api.getSession({ headers: request.headers })

if (!session?.user?.id) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
}

const userId = session.user.id

const [userSettings] = await db
.select()
.from(settings)
.where(eq(settings.userId, userId))
.limit(1)

if (userSettings) {
const autoAllowedTools = (userSettings.copilotAutoAllowedTools as string[]) || []
return NextResponse.json({ autoAllowedTools })
}

// If no settings record exists, create one with empty array
await db.insert(settings).values({
id: userId,
userId,
copilotAutoAllowedTools: [],
})

return NextResponse.json({ autoAllowedTools: [] })
} catch (error) {
logger.error('Failed to fetch auto-allowed tools', { error })
return NextResponse.json({ error: 'Internal server error' }, { status: 500 })
}
}

/**
* POST - Add a tool to the auto-allowed list
*/
export async function POST(request: NextRequest) {
try {
const session = await auth.api.getSession({ headers: request.headers })

if (!session?.user?.id) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
}

const userId = session.user.id
const body = await request.json()

if (!body.toolId || typeof body.toolId !== 'string') {
return NextResponse.json({ error: 'toolId must be a string' }, { status: 400 })
}

const toolId = body.toolId

// Get existing settings
const [existing] = await db.select().from(settings).where(eq(settings.userId, userId)).limit(1)

if (existing) {
const currentTools = (existing.copilotAutoAllowedTools as string[]) || []

// Add tool if not already present
if (!currentTools.includes(toolId)) {
const updatedTools = [...currentTools, toolId]
await db
.update(settings)
.set({
copilotAutoAllowedTools: updatedTools,
updatedAt: new Date(),
})
.where(eq(settings.userId, userId))

logger.info('Added tool to auto-allowed list', { userId, toolId })
return NextResponse.json({ success: true, autoAllowedTools: updatedTools })
}

return NextResponse.json({ success: true, autoAllowedTools: currentTools })
}

// Create new settings record with the tool
await db.insert(settings).values({
id: userId,
userId,
copilotAutoAllowedTools: [toolId],
})

logger.info('Created settings and added tool to auto-allowed list', { userId, toolId })
return NextResponse.json({ success: true, autoAllowedTools: [toolId] })
} catch (error) {
logger.error('Failed to add auto-allowed tool', { error })
return NextResponse.json({ error: 'Internal server error' }, { status: 500 })
}
}

/**
* DELETE - Remove a tool from the auto-allowed list
*/
export async function DELETE(request: NextRequest) {
try {
const session = await auth.api.getSession({ headers: request.headers })

if (!session?.user?.id) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
}

const userId = session.user.id
const { searchParams } = new URL(request.url)
const toolId = searchParams.get('toolId')

if (!toolId) {
return NextResponse.json({ error: 'toolId query parameter is required' }, { status: 400 })
}

// Get existing settings
const [existing] = await db.select().from(settings).where(eq(settings.userId, userId)).limit(1)

if (existing) {
const currentTools = (existing.copilotAutoAllowedTools as string[]) || []
const updatedTools = currentTools.filter((t) => t !== toolId)

await db
.update(settings)
.set({
copilotAutoAllowedTools: updatedTools,
updatedAt: new Date(),
})
.where(eq(settings.userId, userId))

logger.info('Removed tool from auto-allowed list', { userId, toolId })
return NextResponse.json({ success: true, autoAllowedTools: updatedTools })
}

return NextResponse.json({ success: true, autoAllowedTools: [] })
} catch (error) {
logger.error('Failed to remove auto-allowed tool', { error })
return NextResponse.json({ error: 'Internal server error' }, { status: 500 })
}
}
Loading