33 */
44import { beforeEach , describe , expect , it , vi } from 'vitest'
55import { transformBlockTool } from '@/providers/utils'
6+ import { normalizeToolId } from '@/tools/normalize'
67
78const mockResolve = vi . fn ( )
89
@@ -17,8 +18,8 @@ const options = {
1718 } ,
1819 ] ,
1920 getTool : ( id : string ) =>
20- id === 'custom_block_executor '
21- ? { id : 'custom_block_executor ' , description : 'exec' }
21+ id === 'deployed_block_executor '
22+ ? { id : 'deployed_block_executor ' , description : 'exec' }
2223 : undefined ,
2324 resolveCustomBlockBinding : mockResolve ,
2425}
@@ -28,7 +29,7 @@ describe('transformBlockTool — custom blocks', () => {
2829 vi . clearAllMocks ( )
2930 } )
3031
31- it ( 'builds an id-keyed custom_block_executor tool and omits file[] fields' , async ( ) => {
32+ it ( 'builds an id-keyed deployed_block_executor tool and omits file[] fields' , async ( ) => {
3233 mockResolve . mockResolvedValue ( {
3334 workflowId : 'wf-src' ,
3435 inputFields : [
@@ -45,7 +46,7 @@ describe('transformBlockTool — custom blocks', () => {
4546
4647 expect ( tool ) . not . toBeNull ( )
4748 // Unique per block, name/description from the block (never the source workflow).
48- expect ( tool ! . id ) . toBe ( 'custom_block_executor_custom_block_test ' )
49+ expect ( tool ! . id ) . toBe ( 'deployed_block_executor_custom_block_test ' )
4950 expect ( tool ! . name ) . toBe ( 'The Elder' )
5051 // Baked params: block type + assembled (id-keyed) input mapping.
5152 expect ( tool ! . params . blockType ) . toBe ( 'custom_block_test' )
@@ -59,6 +60,22 @@ describe('transformBlockTool — custom blocks', () => {
5960 expect ( mockResolve ) . toHaveBeenCalledWith ( 'custom_block_test' )
6061 } )
6162
63+ it ( 'keeps the tool id out of the user-defined custom-tool namespace' , async ( ) => {
64+ mockResolve . mockResolvedValue ( {
65+ workflowId : 'wf-src' ,
66+ inputFields : [ { id : 'q' , name : 'Question' , type : 'string' } ] ,
67+ requiredInputIds : [ ] ,
68+ } )
69+
70+ const tool = await transformBlockTool ( { type : 'custom_block_test' , params : { } } , options )
71+
72+ // `custom_` is the custom-tool prefix (`isCustomTool`). Colliding with it makes
73+ // executeTool resolve via the DB custom-tool lookup, skip internal-field
74+ // stripping, and let `disableCustomTools` block deploy-as-block tools.
75+ expect ( tool ! . id . startsWith ( 'custom_' ) ) . toBe ( false )
76+ expect ( normalizeToolId ( tool ! . id ) ) . toBe ( 'deployed_block_executor' )
77+ } )
78+
6279 it ( 'does not offer the tool when a required file input has no preset value' , async ( ) => {
6380 mockResolve . mockResolvedValue ( {
6481 workflowId : 'wf-src' ,
0 commit comments