Handle a permission request from the Copilot CLI. Note: This method is internal and should not be called directly. Args: request: The permission request data from the CLI. Returns: A dictionary containing the permission decision
(
self, request: PermissionRequest
)
| 2434 | self._permission_handler = handler |
| 2435 | |
| 2436 | async def _handle_permission_request( |
| 2437 | self, request: PermissionRequest |
| 2438 | ) -> PermissionRequestResult: |
| 2439 | """ |
| 2440 | Handle a permission request from the Copilot CLI. |
| 2441 | |
| 2442 | Note: |
| 2443 | This method is internal and should not be called directly. |
| 2444 | |
| 2445 | Args: |
| 2446 | request: The permission request data from the CLI. |
| 2447 | |
| 2448 | Returns: |
| 2449 | A dictionary containing the permission decision with a "kind" key. |
| 2450 | """ |
| 2451 | with self._permission_handler_lock: |
| 2452 | handler = self._permission_handler |
| 2453 | |
| 2454 | if not handler: |
| 2455 | # No handler registered, deny permission. |
| 2456 | return PermissionDecisionUserNotAvailable() |
| 2457 | |
| 2458 | try: |
| 2459 | handler_start = time.perf_counter() |
| 2460 | result = handler(request, {"session_id": self.session_id}) |
| 2461 | if inspect.isawaitable(result): |
| 2462 | result = await result |
| 2463 | log_timing( |
| 2464 | logger, |
| 2465 | logging.DEBUG, |
| 2466 | "CopilotSession._handle_permission_request dispatch", |
| 2467 | handler_start, |
| 2468 | session_id=self.session_id, |
| 2469 | ) |
| 2470 | return cast(PermissionRequestResult, result) |
| 2471 | except Exception: # pylint: disable=broad-except |
| 2472 | # Handler failed, deny permission. |
| 2473 | logger.debug( |
| 2474 | "Error handling permission request", |
| 2475 | extra={"session_id": self.session_id}, |
| 2476 | exc_info=True, |
| 2477 | ) |
| 2478 | return PermissionDecisionUserNotAvailable() |
| 2479 | |
| 2480 | def _register_user_input_handler(self, handler: UserInputHandler | None) -> None: |
| 2481 | """ |
nothing calls this directly
no test coverage detected