Skip to content

Commit 2548912

Browse files
committed
fix(build): fix type errors
1 parent 63e9dff commit 2548912

15 files changed

Lines changed: 66 additions & 61 deletions

File tree

apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,17 @@ import {
5252
taskKeys,
5353
useChatHistory,
5454
} from '@/hooks/queries/tasks'
55+
import { getFolderMap } from '@/hooks/queries/utils/folder-cache'
56+
import { invalidateWorkflowSelectors } from '@/hooks/queries/utils/invalidate-workflow-lists'
5557
import { getTopInsertionSortOrder } from '@/hooks/queries/utils/top-insertion-sort-order'
58+
import { getWorkflowById, getWorkflows } from '@/hooks/queries/utils/workflow-cache'
5659
import { workflowKeys } from '@/hooks/queries/workflows'
5760
import { useExecutionStream } from '@/hooks/use-execution-stream'
5861
import { useExecutionStore } from '@/stores/execution/store'
5962
import type { ChatContext } from '@/stores/panel'
6063
import { useTerminalConsoleStore } from '@/stores/terminal'
6164
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
65+
import type { WorkflowMetadata } from '@/stores/workflows/registry/types'
6266
import type {
6367
ChatMessage,
6468
ContentBlock,
@@ -390,7 +394,7 @@ export function useChat(
390394
? toolArgs.workflowId
391395
: useWorkflowRegistry.getState().activeWorkflowId
392396
if (targetWorkflowId) {
393-
const meta = useWorkflowRegistry.getState().workflows[targetWorkflowId]
397+
const meta = getWorkflowById(workspaceId, targetWorkflowId)
394398
const wasAdded = addResource({
395399
type: 'workflow',
396400
id: targetWorkflowId,
@@ -404,7 +408,7 @@ export function useChat(
404408

405409
executeRunToolOnClient(toolCallId, toolName, toolArgs)
406410
},
407-
[addResource]
411+
[addResource, workspaceId]
408412
)
409413

410414
const recoverPendingClientWorkflowTools = useCallback(
@@ -1444,8 +1448,6 @@ export function useChat(
14441448
}
14451449

14461450
if (options?.error) {
1447-
pendingRecoveryMessageRef.current = null
1448-
setPendingRecoveryMessage(null)
14491451
setMessageQueue([])
14501452
return
14511453
}

apps/sim/lib/copilot/chat/payload.test.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,17 @@ vi.mock('@/tools/registry', () => ({
3535
id: 'gmail_send',
3636
name: 'Gmail Send',
3737
description: 'Send emails using Gmail',
38-
executor: 'sim',
3938
},
4039
brandfetch_search: {
4140
id: 'brandfetch_search',
4241
name: 'Brandfetch Search',
4342
description: 'Search for brands by company name',
44-
executor: 'sim',
4543
},
46-
run_workflow_dynamic: {
47-
id: 'run_workflow_dynamic',
48-
name: 'Run Workflow Dynamic',
44+
// Catalog marks run_workflow as client / clientExecutable; registry ToolConfig has no executor fields.
45+
run_workflow: {
46+
id: 'run_workflow',
47+
name: 'Run Workflow',
4948
description: 'Run a workflow from the client',
50-
executor: 'client',
51-
clientExecutable: true,
5249
},
5350
},
5451
}))
@@ -113,7 +110,7 @@ describe('buildIntegrationToolSchemas', () => {
113110

114111
const toolSchemas = await buildIntegrationToolSchemas('user-client')
115112
const gmailTool = toolSchemas.find((tool) => tool.name === 'gmail_send')
116-
const runTool = toolSchemas.find((tool) => tool.name === 'run_workflow_dynamic')
113+
const runTool = toolSchemas.find((tool) => tool.name === 'run_workflow')
117114

118115
expect(gmailTool?.executeLocally).toBe(false)
119116
expect(runTool?.executeLocally).toBe(true)

apps/sim/lib/copilot/chat/payload.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createLogger } from '@sim/logger'
22
import { getUserSubscriptionState } from '@/lib/billing/core/subscription'
3+
import { getToolEntry } from '@/lib/copilot/tool-executor/router'
34
import { getCopilotToolDescription } from '@/lib/copilot/tools/descriptions'
45
import { isHosted } from '@/lib/core/config/feature-flags'
56
import { createMcpToolId } from '@/lib/mcp/utils'
@@ -75,6 +76,7 @@ export async function buildIntegrationToolSchemas(
7576
try {
7677
const userSchema = createUserToolSchema(toolConfig)
7778
const strippedName = stripVersionSuffix(toolId)
79+
const catalogEntry = getToolEntry(strippedName)
7880
integrationTools.push({
7981
name: strippedName,
8082
description: getCopilotToolDescription(toolConfig, {
@@ -84,7 +86,8 @@ export async function buildIntegrationToolSchemas(
8486
}),
8587
input_schema: userSchema as unknown as Record<string, unknown>,
8688
defer_loading: true,
87-
executeLocally: toolConfig.clientExecutable === true || toolConfig.executor === 'client',
89+
executeLocally:
90+
catalogEntry?.clientExecutable === true || catalogEntry?.executor === 'client',
8891
...(toolConfig.oauth?.required && {
8992
oauth: {
9093
required: true,

apps/sim/lib/copilot/tools/handlers/deployment/deploy.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import crypto from 'crypto'
22
import { db } from '@sim/db'
33
import { chat, workflowMcpTool } from '@sim/db/schema'
44
import { and, eq, isNull } from 'drizzle-orm'
5+
import { AuditAction, AuditResourceType, recordAudit } from '@/lib/audit/log'
56
import type { ExecutionContext, ToolCallResult } from '@/lib/copilot/request/types'
67
import { getBaseUrl } from '@/lib/core/utils/urls'
78
import { mcpPubSub } from '@/lib/mcp/pubsub'

apps/sim/lib/copilot/tools/handlers/deployment/manage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
workflowMcpTool,
99
} from '@sim/db/schema'
1010
import { and, eq, inArray, isNull } from 'drizzle-orm'
11+
import { AuditAction, AuditResourceType, recordAudit } from '@/lib/audit/log'
1112
import type { ExecutionContext, ToolCallResult } from '@/lib/copilot/request/types'
1213
import { mcpPubSub } from '@/lib/mcp/pubsub'
1314
import { generateParameterSchemaForWorkflow } from '@/lib/mcp/workflow-mcp-sync'

apps/sim/lib/copilot/tools/handlers/jobs.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { copilotChats, workflowSchedule } from '@sim/db/schema'
33
import { createLogger } from '@sim/logger'
44
import { and, eq, isNull } from 'drizzle-orm'
55
import { v4 as uuidv4 } from 'uuid'
6+
import { AuditAction, AuditResourceType, recordAudit } from '@/lib/audit/log'
67
import type { ExecutionContext, ToolCallResult } from '@/lib/copilot/request/types'
78
import { parseCronToHumanReadable, validateCronExpression } from '@/lib/workflows/schedules/utils'
89

apps/sim/lib/copilot/tools/handlers/materialize-file.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { db } from '@sim/db'
22
import { workflow, workspaceFiles } from '@sim/db/schema'
33
import { createLogger } from '@sim/logger'
44
import { and, eq, isNull } from 'drizzle-orm'
5+
import { AuditAction, AuditResourceType, recordAudit } from '@/lib/audit/log'
56
import type { ExecutionContext, ToolCallResult } from '@/lib/copilot/request/types'
67
import { findMothershipUploadRowByChatAndName } from '@/lib/copilot/tools/handlers/upload-file-reader'
78
import { getServePathPrefix } from '@/lib/uploads'

apps/sim/lib/copilot/tools/handlers/workflow/mutations.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import crypto from 'crypto'
22
import { createLogger } from '@sim/logger'
33
import { createWorkspaceApiKey } from '@/lib/api-key/auth'
4+
import { AuditAction, AuditResourceType, recordAudit } from '@/lib/audit/log'
45
import type { ExecutionContext, ToolCallResult } from '@/lib/copilot/request/types'
56
import { generateRequestId } from '@/lib/core/utils/request'
67
import { executeWorkflow } from '@/lib/workflows/executor/execute-workflow'

apps/sim/lib/copilot/tools/server/files/download-to-workspace-file.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export const downloadToWorkspaceFileServerTool: BaseServerTool<
178178
mimeType
179179
)
180180

181-
reqLogger.info('Downloaded remote file to workspace', {
181+
logger.info('Downloaded remote file to workspace', {
182182
sourceUrl: params.url,
183183
fileId: uploaded.id,
184184
fileName: uploaded.name,
@@ -195,7 +195,7 @@ export const downloadToWorkspaceFileServerTool: BaseServerTool<
195195
}
196196
} catch (error) {
197197
const msg = error instanceof Error ? error.message : 'Unknown error'
198-
reqLogger.error('Failed to download file to workspace', {
198+
logger.error('Failed to download file to workspace', {
199199
url: params.url,
200200
error: msg,
201201
})

apps/sim/lib/copilot/tools/server/files/workspace-file.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const workspaceFileServerTool: BaseServerTool<WorkspaceFileArgs, Workspac
5555
context?.messageId ? `${message} [messageId:${context.messageId}]` : message
5656

5757
if (!context?.userId) {
58-
reqLogger.error('Unauthorized attempt to access workspace files')
58+
logger.error('Unauthorized attempt to access workspace files')
5959
throw new Error('Authentication required')
6060
}
6161

@@ -94,7 +94,7 @@ export const workspaceFileServerTool: BaseServerTool<WorkspaceFileArgs, Workspac
9494
await generatePptxFromCode(content, workspaceId)
9595
} catch (err) {
9696
const msg = err instanceof Error ? err.message : String(err)
97-
reqLogger.error('PPTX code validation failed', { error: msg, fileName })
97+
logger.error('PPTX code validation failed', { error: msg, fileName })
9898
return {
9999
success: false,
100100
message: `PPTX generation failed: ${msg}. Fix the pptxgenjs code and retry.`,
@@ -116,7 +116,7 @@ export const workspaceFileServerTool: BaseServerTool<WorkspaceFileArgs, Workspac
116116
contentType
117117
)
118118

119-
reqLogger.info('Workspace file written via copilot', {
119+
logger.info('Workspace file written via copilot', {
120120
fileId: result.id,
121121
name: fileName,
122122
size: fileBuffer.length,
@@ -177,7 +177,7 @@ export const workspaceFileServerTool: BaseServerTool<WorkspaceFileArgs, Workspac
177177
isPptxUpdate ? PPTX_SOURCE_MIME : undefined
178178
)
179179

180-
reqLogger.info('Workspace file updated via copilot', {
180+
logger.info('Workspace file updated via copilot', {
181181
fileId,
182182
name: fileRecord.name,
183183
size: fileBuffer.length,
@@ -219,7 +219,7 @@ export const workspaceFileServerTool: BaseServerTool<WorkspaceFileArgs, Workspac
219219
assertServerToolNotAborted(context)
220220
await renameWorkspaceFile(workspaceId, fileId, newName)
221221

222-
reqLogger.info('Workspace file renamed via copilot', {
222+
logger.info('Workspace file renamed via copilot', {
223223
fileId,
224224
oldName,
225225
newName,
@@ -247,7 +247,7 @@ export const workspaceFileServerTool: BaseServerTool<WorkspaceFileArgs, Workspac
247247
assertServerToolNotAborted(context)
248248
await deleteWorkspaceFile(workspaceId, fileId)
249249

250-
reqLogger.info('Workspace file deleted via copilot', {
250+
logger.info('Workspace file deleted via copilot', {
251251
fileId,
252252
name: fileRecord.name,
253253
userId: context.userId,
@@ -324,7 +324,7 @@ export const workspaceFileServerTool: BaseServerTool<WorkspaceFileArgs, Workspac
324324
isPptxPatch ? PPTX_SOURCE_MIME : undefined
325325
)
326326

327-
reqLogger.info('Workspace file patched via copilot', {
327+
logger.info('Workspace file patched via copilot', {
328328
fileId,
329329
name: fileRecord.name,
330330
editCount: edits.length,
@@ -350,7 +350,7 @@ export const workspaceFileServerTool: BaseServerTool<WorkspaceFileArgs, Workspac
350350
}
351351
} catch (error) {
352352
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred'
353-
reqLogger.error('Error in workspace_file tool', {
353+
logger.error('Error in workspace_file tool', {
354354
operation,
355355
error: errorMessage,
356356
userId: context.userId,

0 commit comments

Comments
 (0)