@@ -68,6 +68,8 @@ import type {
6868 ListWorkspaceMcpServersParams ,
6969 MoveFolderParams ,
7070 MoveWorkflowParams ,
71+ OpenResourceParams ,
72+ OpenResourceType ,
7173 RenameFolderParams ,
7274 RenameWorkflowParams ,
7375 RunBlockParams ,
@@ -77,6 +79,7 @@ import type {
7779 SetGlobalWorkflowVariablesParams ,
7880 UpdateWorkflowParams ,
7981 UpdateWorkspaceMcpServerParams ,
82+ ValidOpenResourceParams ,
8083} from './param-types'
8184import { PLATFORM_ACTIONS_CONTENT } from './platform-actions'
8285import { executeVfsGlob , executeVfsGrep , executeVfsList , executeVfsRead } from './vfs-tools'
@@ -105,6 +108,36 @@ import {
105108} from './workflow-tools'
106109
107110const logger = createLogger ( 'CopilotToolExecutor' )
111+ const VALID_OPEN_RESOURCE_TYPES = new Set < OpenResourceType > ( [
112+ 'workflow' ,
113+ 'table' ,
114+ 'knowledgebase' ,
115+ 'file' ,
116+ ] )
117+
118+ function validateOpenResourceParams (
119+ params : OpenResourceParams
120+ ) : { success : true ; params : ValidOpenResourceParams } | { success : false ; error : string } {
121+ if ( ! params . type ) {
122+ return { success : false , error : 'type is required' }
123+ }
124+
125+ if ( ! VALID_OPEN_RESOURCE_TYPES . has ( params . type ) ) {
126+ return { success : false , error : `Invalid resource type: ${ params . type } ` }
127+ }
128+
129+ if ( ! params . id ) {
130+ return { success : false , error : `${ params . type } resources require \`id\`` }
131+ }
132+
133+ return {
134+ success : true ,
135+ params : {
136+ type : params . type ,
137+ id : params . id ,
138+ } ,
139+ }
140+ }
108141
109142type ManageCustomToolOperation = 'add' | 'edit' | 'delete' | 'list'
110143
@@ -996,16 +1029,16 @@ const SIM_WORKFLOW_TOOL_HANDLERS: Record<
9961029 list : ( p , c ) => executeVfsList ( p , c ) ,
9971030
9981031 // Resource visibility
999- open_resource : async ( p ) => {
1000- const resourceType = p . type as string | undefined
1001- const resourceId = p . id as string | undefined
1002- if ( ! resourceType || ! resourceId ) {
1003- return { success : false , error : 'type and id are required' }
1004- }
1005- const validTypes = new Set ( [ 'workflow' , 'table' , 'knowledgebase' , 'file' ] )
1006- if ( ! validTypes . has ( resourceType ) ) {
1007- return { success : false , error : `Invalid resource type: ${ resourceType } ` }
1032+ open_resource : async ( p : OpenResourceParams ) => {
1033+ const validated = validateOpenResourceParams ( p )
1034+ if ( ! validated . success ) {
1035+ return { success : false , error : validated . error }
10081036 }
1037+
1038+ const params = validated . params
1039+ const resourceType = params . type
1040+ const resourceId = params . id
1041+
10091042 return {
10101043 success : true ,
10111044 output : { message : `Opened ${ resourceType } ${ resourceId } for the user` } ,
0 commit comments