Skip to content

Commit b768ca8

Browse files
v0.4.5: copilot updates, kb improvements, payment failure fix
2 parents 2175fd1 + 86ed32e commit b768ca8

File tree

59 files changed

+11160
-1409
lines changed

Some content is hidden

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

59 files changed

+11160
-1409
lines changed

.github/workflows/docs-embeddings.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ jobs:
3232
env:
3333
DATABASE_URL: ${{ github.ref == 'refs/heads/main' && secrets.DATABASE_URL || secrets.STAGING_DATABASE_URL }}
3434
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
35-
run: bun run scripts/process-docs-embeddings.ts --clear
35+
run: bun run scripts/process-docs.ts --clear

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ describe('Copilot Chat API Route', () => {
233233
model: 'claude-4.5-sonnet',
234234
mode: 'agent',
235235
messageId: 'mock-uuid-1234-5678',
236-
version: '1.0.0',
236+
version: '1.0.1',
237237
chatId: 'chat-123',
238238
}),
239239
})
@@ -303,7 +303,7 @@ describe('Copilot Chat API Route', () => {
303303
model: 'claude-4.5-sonnet',
304304
mode: 'agent',
305305
messageId: 'mock-uuid-1234-5678',
306-
version: '1.0.0',
306+
version: '1.0.1',
307307
chatId: 'chat-123',
308308
}),
309309
})
@@ -361,7 +361,7 @@ describe('Copilot Chat API Route', () => {
361361
model: 'claude-4.5-sonnet',
362362
mode: 'agent',
363363
messageId: 'mock-uuid-1234-5678',
364-
version: '1.0.0',
364+
version: '1.0.1',
365365
chatId: 'chat-123',
366366
}),
367367
})
@@ -453,7 +453,7 @@ describe('Copilot Chat API Route', () => {
453453
model: 'claude-4.5-sonnet',
454454
mode: 'ask',
455455
messageId: 'mock-uuid-1234-5678',
456-
version: '1.0.0',
456+
version: '1.0.1',
457457
chatId: 'chat-123',
458458
}),
459459
})
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
import { eq } from 'drizzle-orm'
2+
import { type NextRequest, NextResponse } from 'next/server'
3+
import { auth } from '@/lib/auth'
4+
import { createLogger } from '@/lib/logs/console/logger'
5+
import { db } from '@/../../packages/db'
6+
import { settings } from '@/../../packages/db/schema'
7+
8+
const logger = createLogger('CopilotUserModelsAPI')
9+
10+
const DEFAULT_ENABLED_MODELS: Record<string, boolean> = {
11+
'gpt-4o': false,
12+
'gpt-4.1': false,
13+
'gpt-5-fast': false,
14+
'gpt-5': true,
15+
'gpt-5-medium': true,
16+
'gpt-5-high': false,
17+
o3: true,
18+
'claude-4-sonnet': true,
19+
'claude-4.5-sonnet': true,
20+
'claude-4.1-opus': true,
21+
}
22+
23+
// GET - Fetch user's enabled models
24+
export async function GET(request: NextRequest) {
25+
try {
26+
const session = await auth.api.getSession({ headers: request.headers })
27+
28+
if (!session?.user?.id) {
29+
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
30+
}
31+
32+
const userId = session.user.id
33+
34+
// Try to fetch existing settings record
35+
const [userSettings] = await db
36+
.select()
37+
.from(settings)
38+
.where(eq(settings.userId, userId))
39+
.limit(1)
40+
41+
if (userSettings) {
42+
const userModelsMap = (userSettings.copilotEnabledModels as Record<string, boolean>) || {}
43+
44+
// Merge: start with defaults, then override with user's existing preferences
45+
const mergedModels = { ...DEFAULT_ENABLED_MODELS }
46+
for (const [modelId, enabled] of Object.entries(userModelsMap)) {
47+
mergedModels[modelId] = enabled
48+
}
49+
50+
// If we added any new models, update the database
51+
const hasNewModels = Object.keys(DEFAULT_ENABLED_MODELS).some(
52+
(key) => !(key in userModelsMap)
53+
)
54+
55+
if (hasNewModels) {
56+
await db
57+
.update(settings)
58+
.set({
59+
copilotEnabledModels: mergedModels,
60+
updatedAt: new Date(),
61+
})
62+
.where(eq(settings.userId, userId))
63+
}
64+
65+
return NextResponse.json({
66+
enabledModels: mergedModels,
67+
})
68+
}
69+
70+
// If no settings record exists, create one with empty object (client will use defaults)
71+
const [created] = await db
72+
.insert(settings)
73+
.values({
74+
id: userId,
75+
userId,
76+
copilotEnabledModels: {},
77+
})
78+
.returning()
79+
80+
return NextResponse.json({
81+
enabledModels: DEFAULT_ENABLED_MODELS,
82+
})
83+
} catch (error) {
84+
logger.error('Failed to fetch user models', { error })
85+
return NextResponse.json({ error: 'Internal server error' }, { status: 500 })
86+
}
87+
}
88+
89+
// PUT - Update user's enabled models
90+
export async function PUT(request: NextRequest) {
91+
try {
92+
const session = await auth.api.getSession({ headers: request.headers })
93+
94+
if (!session?.user?.id) {
95+
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
96+
}
97+
98+
const userId = session.user.id
99+
const body = await request.json()
100+
101+
if (!body.enabledModels || typeof body.enabledModels !== 'object') {
102+
return NextResponse.json({ error: 'enabledModels must be an object' }, { status: 400 })
103+
}
104+
105+
// Check if settings record exists
106+
const [existing] = await db.select().from(settings).where(eq(settings.userId, userId)).limit(1)
107+
108+
if (existing) {
109+
// Update existing record
110+
await db
111+
.update(settings)
112+
.set({
113+
copilotEnabledModels: body.enabledModels,
114+
updatedAt: new Date(),
115+
})
116+
.where(eq(settings.userId, userId))
117+
} else {
118+
// Create new settings record
119+
await db.insert(settings).values({
120+
id: userId,
121+
userId,
122+
copilotEnabledModels: body.enabledModels,
123+
})
124+
}
125+
126+
return NextResponse.json({ success: true })
127+
} catch (error) {
128+
logger.error('Failed to update user models', { error })
129+
return NextResponse.json({ error: 'Internal server error' }, { status: 500 })
130+
}
131+
}

apps/sim/app/api/workflows/[id]/state/route.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { getSession } from '@/lib/auth'
77
import { createLogger } from '@/lib/logs/console/logger'
88
import { getUserEntityPermissions } from '@/lib/permissions/utils'
99
import { generateRequestId } from '@/lib/utils'
10+
import { extractAndPersistCustomTools } from '@/lib/workflows/custom-tools-persistence'
1011
import { saveWorkflowToNormalizedTables } from '@/lib/workflows/db-helpers'
1112
import { sanitizeAgentToolsInBlocks } from '@/lib/workflows/validation'
1213

@@ -207,6 +208,21 @@ export async function PUT(request: NextRequest, { params }: { params: Promise<{
207208
)
208209
}
209210

211+
// Extract and persist custom tools to database
212+
try {
213+
const { saved, errors } = await extractAndPersistCustomTools(workflowState, userId)
214+
215+
if (saved > 0) {
216+
logger.info(`[${requestId}] Persisted ${saved} custom tool(s) to database`, { workflowId })
217+
}
218+
219+
if (errors.length > 0) {
220+
logger.warn(`[${requestId}] Some custom tools failed to persist`, { errors, workflowId })
221+
}
222+
} catch (error) {
223+
logger.error(`[${requestId}] Failed to persist custom tools`, { error, workflowId })
224+
}
225+
210226
// Update workflow's lastSynced timestamp
211227
await db
212228
.update(workflow)

apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/components/edit-chunk-modal/edit-chunk-modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ export function EditChunkModal({
312312
<Button
313313
onClick={handleSaveContent}
314314
disabled={!isFormValid || isSaving || !hasUnsavedChanges || isNavigating}
315-
className='bg-[var(--brand-primary-hex)] font-[480] text-muted-foreground shadow-[0_0_0_0_var(--brand-primary-hex)] transition-all duration-200 hover:bg-[var(--brand-primary-hover-hex)] hover:shadow-[0_0_0_4px_rgba(127,47,255,0.15)]'
315+
className='bg-[var(--brand-primary-hex)] font-[480] text-white shadow-[0_0_0_0_var(--brand-primary-hex)] transition-all duration-200 hover:bg-[var(--brand-primary-hover-hex)] hover:shadow-[0_0_0_4px_rgba(127,47,255,0.15)]'
316316
>
317317
{isSaving ? (
318318
<>

apps/sim/app/workspace/[workspaceId]/knowledge/[id]/components/upload-modal/upload-modal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export function UploadModal({
6464
return `File "${file.name}" is too large. Maximum size is 100MB.`
6565
}
6666
if (!ACCEPTED_FILE_TYPES.includes(file.type)) {
67-
return `File "${file.name}" has an unsupported format. Please use PDF, DOC, DOCX, TXT, CSV, XLS, XLSX, MD, PPT, PPTX, or HTML files.`
67+
return `File "${file.name}" has an unsupported format. Please use PDF, DOC, DOCX, TXT, CSV, XLS, XLSX, MD, PPT, PPTX, HTML, JSON, YAML, or YML files.`
6868
}
6969
return null
7070
}
@@ -193,8 +193,8 @@ export function UploadModal({
193193
{isDragging ? 'Drop files here!' : 'Drop files here or click to browse'}
194194
</p>
195195
<p className='text-muted-foreground text-xs'>
196-
Supports PDF, DOC, DOCX, TXT, CSV, XLS, XLSX, MD, PPT, PPTX, HTML (max 100MB
197-
each)
196+
Supports PDF, DOC, DOCX, TXT, CSV, XLS, XLSX, MD, PPT, PPTX, HTML, JSON, YAML,
197+
YML (max 100MB each)
198198
</p>
199199
</div>
200200
</div>

apps/sim/app/workspace/[workspaceId]/knowledge/components/create-modal/create-modal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export function CreateModal({ open, onOpenChange, onKnowledgeBaseCreated }: Crea
158158
// Check file type
159159
if (!ACCEPTED_FILE_TYPES.includes(file.type)) {
160160
setFileError(
161-
`File ${file.name} has an unsupported format. Please use PDF, DOC, DOCX, TXT, CSV, XLS, XLSX, MD, PPT, PPTX, or HTML.`
161+
`File ${file.name} has an unsupported format. Please use PDF, DOC, DOCX, TXT, CSV, XLS, XLSX, MD, PPT, PPTX, HTML, JSON, YAML, or YML.`
162162
)
163163
hasError = true
164164
continue
@@ -501,8 +501,8 @@ export function CreateModal({ open, onOpenChange, onKnowledgeBaseCreated }: Crea
501501
: 'Drop files here or click to browse'}
502502
</p>
503503
<p className='text-muted-foreground text-xs'>
504-
Supports PDF, DOC, DOCX, TXT, CSV, XLS, XLSX, MD, PPT, PPTX, HTML (max
505-
100MB each)
504+
Supports PDF, DOC, DOCX, TXT, CSV, XLS, XLSX, MD, PPT, PPTX, HTML,
505+
JSON, YAML, YML (max 100MB each)
506506
</p>
507507
</div>
508508
</div>

0 commit comments

Comments
 (0)