Skip to content

Commit b468c00

Browse files
committed
address comments
1 parent a3d1010 commit b468c00

7 files changed

Lines changed: 47 additions & 25 deletions

File tree

apps/sim/app/api/workspaces/[id]/files/folders/[folderId]/restore/route.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import { parseRequest } from '@/lib/api/server'
55
import { getSession } from '@/lib/auth'
66
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
77
import { captureServerEvent } from '@/lib/posthog/server'
8-
import { performRestoreWorkspaceFileFolder } from '@/lib/workspace-files/orchestration'
8+
import {
9+
performRestoreWorkspaceFileFolder,
10+
workspaceFilesOrchestrationStatus,
11+
} from '@/lib/workspace-files/orchestration'
912
import { getUserEntityPermissions } from '@/lib/workspaces/permissions/utils'
1013

1114
const logger = createLogger('WorkspaceFileFolderRestoreAPI')
@@ -35,7 +38,7 @@ export const POST = withRouteHandler(
3538
if (!result.success) {
3639
return NextResponse.json(
3740
{ success: false, error: result.error },
38-
{ status: result.errorCode === 'conflict' ? 409 : 400 }
41+
{ status: workspaceFilesOrchestrationStatus(result.errorCode) }
3942
)
4043
}
4144
const { folder, restoredItems } = result

apps/sim/app/api/workspaces/[id]/files/folders/[folderId]/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { captureServerEvent } from '@/lib/posthog/server'
1111
import {
1212
performDeleteWorkspaceFileItems,
1313
performUpdateWorkspaceFileFolder,
14+
workspaceFilesOrchestrationStatus,
1415
} from '@/lib/workspace-files/orchestration'
1516
import { getUserEntityPermissions } from '@/lib/workspaces/permissions/utils'
1617

@@ -46,7 +47,7 @@ export const PATCH = withRouteHandler(
4647
if (!result.success || !result.folder) {
4748
return NextResponse.json(
4849
{ success: false, error: result.error },
49-
{ status: result.errorCode === 'conflict' ? 409 : 400 }
50+
{ status: workspaceFilesOrchestrationStatus(result.errorCode) }
5051
)
5152
}
5253
captureServerEvent(

apps/sim/app/api/workspaces/[id]/files/folders/route.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import { getSession } from '@/lib/auth'
99
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
1010
import { captureServerEvent } from '@/lib/posthog/server'
1111
import { listWorkspaceFileFolders } from '@/lib/uploads/contexts/workspace'
12-
import { performCreateWorkspaceFileFolder } from '@/lib/workspace-files/orchestration'
12+
import {
13+
performCreateWorkspaceFileFolder,
14+
workspaceFilesOrchestrationStatus,
15+
} from '@/lib/workspace-files/orchestration'
1316
import { getUserEntityPermissions } from '@/lib/workspaces/permissions/utils'
1417

1518
const logger = createLogger('WorkspaceFileFoldersAPI')
@@ -67,7 +70,7 @@ export const POST = withRouteHandler(
6770
if (!result.success || !result.folder) {
6871
return NextResponse.json(
6972
{ success: false, error: result.error },
70-
{ status: result.errorCode === 'conflict' ? 409 : 400 }
73+
{ status: workspaceFilesOrchestrationStatus(result.errorCode) }
7174
)
7275
}
7376
captureServerEvent(

apps/sim/lib/copilot/generated/tool-catalog-v1.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -473,20 +473,20 @@ export const CreateWorkspaceMcpServer: ToolCatalogEntry = {
473473
type: 'object',
474474
properties: {
475475
description: { type: 'string', description: 'Optional description for the server' },
476-
name: { type: 'string', description: 'Required: server name' },
477-
workspaceId: {
478-
type: 'string',
479-
description:
480-
'Workspace ID. Required when no current workspace context is available, such as headless MCP calls.',
476+
isPublic: {
477+
type: 'boolean',
478+
description: 'Whether the workflow MCP server is publicly accessible',
481479
},
480+
name: { type: 'string', description: 'Required: server name' },
482481
workflowIds: {
483482
type: 'array',
484483
description: 'Optional deployed workflow IDs to publish as tools on the new server',
485484
items: { type: 'string' },
486485
},
487-
isPublic: {
488-
type: 'boolean',
489-
description: 'Whether the workflow MCP server is publicly accessible',
486+
workspaceId: {
487+
type: 'string',
488+
description:
489+
'Workspace ID. Required when no current workspace context is available, such as headless MCP calls.',
490490
},
491491
},
492492
required: ['name'],
@@ -1597,7 +1597,7 @@ export const KnowledgeBase: ToolCatalogEntry = {
15971597
fileIds: {
15981598
type: 'array',
15991599
description:
1600-
'Canonical workspace file IDs to add as documents (for add_file). Discover via read("files/{name}/meta.json") or glob("files/by-id/*/meta.json").',
1600+
'Canonical workspace file IDs to add as documents (for add_file). Discover via read("files/{path}/{name}/meta.json") or glob("files/**/meta.json") / glob("files/by-id/*/meta.json").',
16011601
items: { type: 'string' },
16021602
},
16031603
filename: {
@@ -2167,7 +2167,11 @@ export const OpenResource: ToolCatalogEntry = {
21672167
items: {
21682168
type: 'object',
21692169
properties: {
2170-
id: { type: 'string', description: 'The resource ID.' },
2170+
id: {
2171+
type: 'string',
2172+
description:
2173+
'Canonical resource ID. For type "file" this must be a UUID from the workspace file meta.json "id" field—never a VFS path or display name.',
2174+
},
21712175
type: {
21722176
type: 'string',
21732177
description: 'The resource type.',

apps/sim/lib/copilot/generated/tool-schemas-v1.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -274,25 +274,25 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
274274
type: 'string',
275275
description: 'Optional description for the server',
276276
},
277+
isPublic: {
278+
type: 'boolean',
279+
description: 'Whether the workflow MCP server is publicly accessible',
280+
},
277281
name: {
278282
type: 'string',
279283
description: 'Required: server name',
280284
},
281-
workspaceId: {
282-
type: 'string',
283-
description:
284-
'Workspace ID. Required when no current workspace context is available, such as headless MCP calls.',
285-
},
286285
workflowIds: {
287286
type: 'array',
288287
description: 'Optional deployed workflow IDs to publish as tools on the new server',
289288
items: {
290289
type: 'string',
291290
},
292291
},
293-
isPublic: {
294-
type: 'boolean',
295-
description: 'Whether the workflow MCP server is publicly accessible',
292+
workspaceId: {
293+
type: 'string',
294+
description:
295+
'Workspace ID. Required when no current workspace context is available, such as headless MCP calls.',
296296
},
297297
},
298298
required: ['name'],
@@ -1390,7 +1390,7 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
13901390
fileIds: {
13911391
type: 'array',
13921392
description:
1393-
'Canonical workspace file IDs to add as documents (for add_file). Discover via read("files/{name}/meta.json") or glob("files/by-id/*/meta.json").',
1393+
'Canonical workspace file IDs to add as documents (for add_file). Discover via read("files/{path}/{name}/meta.json") or glob("files/**/meta.json") / glob("files/by-id/*/meta.json").',
13941394
items: {
13951395
type: 'string',
13961396
},
@@ -1957,7 +1957,8 @@ export const TOOL_RUNTIME_SCHEMAS: Record<string, ToolRuntimeSchemaEntry> = {
19571957
properties: {
19581958
id: {
19591959
type: 'string',
1960-
description: 'The resource ID.',
1960+
description:
1961+
'Canonical resource ID. For type "file" this must be a UUID from the workspace file meta.json "id" field—never a VFS path or display name.',
19611962
},
19621963
type: {
19631964
type: 'string',

apps/sim/lib/workspace-files/orchestration/file-folder-lifecycle.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ export type WorkspaceFilesOrchestrationErrorCode =
2626
| 'conflict'
2727
| 'internal'
2828

29+
export function workspaceFilesOrchestrationStatus(
30+
errorCode: WorkspaceFilesOrchestrationErrorCode | undefined
31+
): number {
32+
if (errorCode === 'validation') return 400
33+
if (errorCode === 'conflict') return 409
34+
if (errorCode === 'not_found') return 404
35+
return 500
36+
}
37+
2938
export interface PerformDeleteWorkspaceFileItemsParams {
3039
workspaceId: string
3140
userId: string

apps/sim/lib/workspace-files/orchestration/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ export {
2121
performRestoreWorkspaceFileFolder,
2222
performUpdateWorkspaceFileFolder,
2323
type WorkspaceFilesOrchestrationErrorCode,
24+
workspaceFilesOrchestrationStatus,
2425
} from './file-folder-lifecycle'

0 commit comments

Comments
 (0)