@@ -378,6 +378,64 @@ describe("CopilotClient", () => {
378378 } ) ;
379379 } ) ;
380380
381+ describe ( "skipPermission in tool definitions" , ( ) => {
382+ it ( "sends skipPermission in tool definition on session.create" , async ( ) => {
383+ const client = new CopilotClient ( ) ;
384+ await client . start ( ) ;
385+ onTestFinished ( ( ) => client . forceStop ( ) ) ;
386+
387+ const spy = vi . spyOn ( ( client as any ) . connection ! , "sendRequest" ) ;
388+ await client . createSession ( {
389+ onPermissionRequest : approveAll ,
390+ tools : [
391+ {
392+ name : "my_tool" ,
393+ description : "a tool that skips permission" ,
394+ handler : async ( ) => "ok" ,
395+ skipPermission : true ,
396+ } ,
397+ ] ,
398+ } ) ;
399+
400+ const payload = spy . mock . calls . find ( ( c ) => c [ 0 ] === "session.create" ) ! [ 1 ] as any ;
401+ expect ( payload . tools ) . toEqual ( [
402+ expect . objectContaining ( { name : "my_tool" , skipPermission : true } ) ,
403+ ] ) ;
404+ } ) ;
405+
406+ it ( "sends skipPermission in tool definition on session.resume" , async ( ) => {
407+ const client = new CopilotClient ( ) ;
408+ await client . start ( ) ;
409+ onTestFinished ( ( ) => client . forceStop ( ) ) ;
410+
411+ const session = await client . createSession ( { onPermissionRequest : approveAll } ) ;
412+ // Mock sendRequest to capture the call without hitting the runtime
413+ const spy = vi
414+ . spyOn ( ( client as any ) . connection ! , "sendRequest" )
415+ . mockImplementation ( async ( method : string , params : any ) => {
416+ if ( method === "session.resume" ) return { sessionId : params . sessionId } ;
417+ throw new Error ( `Unexpected method: ${ method } ` ) ;
418+ } ) ;
419+ await client . resumeSession ( session . sessionId , {
420+ onPermissionRequest : approveAll ,
421+ tools : [
422+ {
423+ name : "my_tool" ,
424+ description : "a tool that skips permission" ,
425+ handler : async ( ) => "ok" ,
426+ skipPermission : true ,
427+ } ,
428+ ] ,
429+ } ) ;
430+
431+ const payload = spy . mock . calls . find ( ( c ) => c [ 0 ] === "session.resume" ) ! [ 1 ] as any ;
432+ expect ( payload . tools ) . toEqual ( [
433+ expect . objectContaining ( { name : "my_tool" , skipPermission : true } ) ,
434+ ] ) ;
435+ spy . mockRestore ( ) ;
436+ } ) ;
437+ } ) ;
438+
381439 describe ( "agent parameter in session creation" , ( ) => {
382440 it ( "forwards agent in session.create request" , async ( ) => {
383441 const client = new CopilotClient ( ) ;
0 commit comments