@@ -32,63 +32,6 @@ describe("E2E: Headless Mode Permission Errors", () => {
3232 }
3333 await cleanupTestContext ( context ) ;
3434 } ) ;
35- it ( "should display error message with --auto suggestion when tool requires permission" , async ( ) => {
36- // Set up mock LLM to return a tool call that requires permission (Write tool)
37- mockServer = await setupMockLLMTest ( context , {
38- customHandler : ( req : http . IncomingMessage , res : http . ServerResponse ) => {
39- let body = "" ;
40- req . on ( "data" , ( chunk ) => {
41- body += chunk . toString ( ) ;
42- } ) ;
43-
44- req . on ( "end" , ( ) => {
45- if ( req . method === "POST" && req . url === "/chat/completions" ) {
46- res . writeHead ( 200 , {
47- "Content-Type" : "text/event-stream" ,
48- "Cache-Control" : "no-cache" ,
49- Connection : "keep-alive" ,
50- } ) ;
51-
52- // Send a Write tool call (requires permission by default)
53- res . write (
54- `data: {"choices":[{"delta":{"tool_calls":[{"index":0,"id":"call_write","type":"function","function":{"name":"Write"}}]},"index":0}]}\n\n` ,
55- ) ;
56- res . write (
57- `data: {"choices":[{"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\\"filepath\\":\\"test.txt\\",\\"content\\":\\"hello\\"}"}}]},"index":0}]}\n\n` ,
58- ) ;
59-
60- // Send usage data
61- res . write (
62- `data: {"usage":{"prompt_tokens":10,"completion_tokens":20}}\n\n` ,
63- ) ;
64-
65- // End the stream
66- res . write ( `data: [DONE]\n\n` ) ;
67- res . end ( ) ;
68- } else {
69- res . writeHead ( 404 ) ;
70- res . end ( "Not found" ) ;
71- }
72- } ) ;
73- } ,
74- } ) ;
75-
76- // Run CLI in headless mode without permission flags
77- const result = await runCLI ( context , {
78- args : [ "-p" , "--config" , context . configPath , "Create a file test.txt" ] ,
79- timeout : 15000 ,
80- } ) ;
81-
82- // Expect non-zero exit code
83- expect ( result . exitCode ) . toBe ( 1 ) ;
84-
85- // Verify the error message contains the expected information
86- expect ( result . stderr ) . toContain ( "requires permission" ) ;
87- expect ( result . stderr ) . toContain ( "headless mode" ) ;
88- expect ( result . stderr ) . toContain ( "--auto" ) ;
89- expect ( result . stderr ) . toContain ( "--allow" ) ;
90- expect ( result . stderr ) . toContain ( "--exclude" ) ;
91- } , 20000 ) ;
9235
9336 it ( "should succeed with --auto flag when tool requires permission" , async ( ) => {
9437 // Set up mock LLM to return a Write tool call
0 commit comments