File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,7 +37,12 @@ export function isToolSearchCodeModeSupported(): boolean {
3737 if ( toolSearchCodeModeSupportedForTest !== undefined ) {
3838 return toolSearchCodeModeSupportedForTest ;
3939 }
40- return process . allowedNodeEnvironmentFlags . has ( "--permission" ) ;
40+ // Electron advertises Node flags but process.execPath remains the host binary,
41+ // so the isolated code child cannot be launched as a plain Node process.
42+ return (
43+ typeof process . versions . electron !== "string" &&
44+ process . allowedNodeEnvironmentFlags . has ( "--permission" )
45+ ) ;
4146}
4247
4348function resolveMinCodeTimeoutMs ( ) : number {
Original file line number Diff line number Diff line change @@ -1127,6 +1127,25 @@ describe("Tool Search", () => {
11271127 }
11281128 } ) ;
11291129
1130+ it ( "falls back to structured controls under Electron without changing Node mode" , ( ) => {
1131+ const electronDescriptor = Object . getOwnPropertyDescriptor ( process . versions , "electron" ) ;
1132+ Object . defineProperty ( process . versions , "electron" , {
1133+ configurable : true ,
1134+ value : "99.0.0" ,
1135+ } ) ;
1136+ try {
1137+ expect ( resolveToolSearchConfig ( { tools : { toolSearch : true } } as never ) . mode ) . toBe ( "tools" ) ;
1138+ } finally {
1139+ if ( electronDescriptor ) {
1140+ Object . defineProperty ( process . versions , "electron" , electronDescriptor ) ;
1141+ } else {
1142+ delete ( process . versions as NodeJS . ProcessVersions & { electron ?: string } ) . electron ;
1143+ }
1144+ }
1145+
1146+ expect ( resolveToolSearchConfig ( { tools : { toolSearch : true } } as never ) . mode ) . toBe ( "code" ) ;
1147+ } ) ;
1148+
11301149 it ( "guides structured control tools toward compact catalog calls" , ( ) => {
11311150 const tools = createToolSearchTools ( { config : { } as never } ) ;
11321151 const byName = new Map ( tools . map ( ( tool ) => [ tool . name , tool ] ) ) ;
You can’t perform that action at this time.
0 commit comments