@@ -44,11 +44,14 @@ import type {
4444 CommandExecutionRequestApprovalResponse ,
4545 FileChangeRequestApprovalParams ,
4646 FileChangeRequestApprovalResponse ,
47+ PermissionsRequestApprovalParams ,
48+ PermissionsRequestApprovalResponse ,
4749} from "./app-server/v2" ;
4850
4951export interface ApprovalHandler {
5052 handleCommandExecution ( params : CommandExecutionRequestApprovalParams ) : Promise < CommandExecutionRequestApprovalResponse > ;
5153 handleFileChange ( params : FileChangeRequestApprovalParams ) : Promise < FileChangeRequestApprovalResponse > ;
54+ handlePermissionsRequest ( params : PermissionsRequestApprovalParams ) : Promise < PermissionsRequestApprovalResponse > ;
5255}
5356
5457export interface ElicitationHandler {
@@ -78,6 +81,12 @@ const FileChangeApprovalRequest = new RequestType<
7881 void
7982> ( 'item/fileChange/requestApproval' ) ;
8083
84+ const PermissionsApprovalRequest = new RequestType <
85+ PermissionsRequestApprovalParams ,
86+ PermissionsRequestApprovalResponse ,
87+ void
88+ > ( 'item/permissions/requestApproval' ) ;
89+
8190const McpServerElicitationRequest = new RequestType <
8291 McpServerElicitationRequestParams ,
8392 McpServerElicitationRequestResponse ,
@@ -154,6 +163,17 @@ export class CodexAppServerClient {
154163 return await handler . handleFileChange ( params ) ;
155164 } ) ;
156165
166+ this . connection . onRequest ( PermissionsApprovalRequest , async ( params ) => {
167+ if ( this . isStaleTurn ( params . threadId , params . turnId ) ) {
168+ return { permissions : { } , scope : "turn" , strictAutoReview : true } ;
169+ }
170+ const handler = this . approvalHandlers . get ( params . threadId ) ;
171+ if ( ! handler ) {
172+ return { permissions : { } , scope : "turn" , strictAutoReview : true } ;
173+ }
174+ return await handler . handlePermissionsRequest ( params ) ;
175+ } ) ;
176+
157177 this . connection . onRequest ( McpServerElicitationRequest , async ( params ) => {
158178 if ( this . isStaleTurn ( params . threadId , params . turnId ) ) {
159179 return { action : "cancel" , content : null , _meta : null } ;
0 commit comments