88import os
99import shutil
1010import sys
11+ from collections .abc import Iterable
1112from pathlib import Path
12- from typing import Any , Iterable
13+ from typing import Any
1314
1415from acp import (
15- Client ,
16- connect_to_agent ,
1716 PROTOCOL_VERSION ,
17+ Client ,
1818 RequestError ,
19+ connect_to_agent ,
1920 text_block ,
2021)
2122from acp .core import ClientSideConnection
2526 AgentThoughtChunk ,
2627 AllowedOutcome ,
2728 AvailableCommandsUpdate ,
28- CancelNotification ,
2929 ClientCapabilities ,
30+ CreateTerminalResponse ,
3031 CurrentModeUpdate ,
32+ DeniedOutcome ,
33+ EmbeddedResourceContentBlock ,
3134 EnvVariable ,
3235 FileEditToolCallContent ,
3336 FileSystemCapability ,
34- CreateTerminalResponse ,
35- DeniedOutcome ,
36- EmbeddedResourceContentBlock ,
3737 KillTerminalCommandResponse ,
38- InitializeRequest ,
39- NewSessionRequest ,
4038 PermissionOption ,
41- PromptRequest ,
4239 ReadTextFileResponse ,
40+ ReleaseTerminalResponse ,
4341 RequestPermissionResponse ,
4442 ResourceContentBlock ,
45- ReleaseTerminalResponse ,
46- TerminalToolCallContent ,
4743 TerminalOutputResponse ,
44+ TerminalToolCallContent ,
4845 TextContentBlock ,
4946 ToolCall ,
5047 ToolCallProgress ,
@@ -115,7 +112,7 @@ async def read_text_file(
115112 text = _slice_text (text , line , limit )
116113 return ReadTextFileResponse (content = text )
117114
118- async def session_update (
115+ async def session_update ( # noqa: C901
119116 self ,
120117 session_id : str ,
121118 update : UserMessageChunk
@@ -259,7 +256,7 @@ async def interactive_loop(conn: ClientSideConnection, session_id: str) -> None:
259256 )
260257 except RequestError as err :
261258 _print_request_error ("prompt" , err )
262- except Exception as exc : # noqa: BLE001
259+ except Exception as exc :
263260 print (f"Prompt failed: { exc } " , file = sys .stderr )
264261
265262
@@ -275,7 +272,7 @@ def _resolve_gemini_cli(binary: str | None) -> str:
275272 raise FileNotFoundError ("Unable to locate `gemini` CLI, provide --gemini path" )
276273
277274
278- async def run (argv : list [str ]) -> int :
275+ async def run (argv : list [str ]) -> int : # noqa: C901
279276 parser = argparse .ArgumentParser (description = "Interact with the Gemini CLI over ACP." )
280277 parser .add_argument ("--gemini" , help = "Path to the Gemini CLI binary" )
281278 parser .add_argument ("--model" , help = "Model identifier to pass to Gemini" )
@@ -331,7 +328,7 @@ async def run(argv: list[str]) -> int:
331328 _print_request_error ("initialize" , err )
332329 await _shutdown (proc , conn )
333330 return 1
334- except Exception as exc : # noqa: BLE001
331+ except Exception as exc :
335332 print (f"initialize error: { exc } " , file = sys .stderr )
336333 await _shutdown (proc , conn )
337334 return 1
@@ -347,7 +344,7 @@ async def run(argv: list[str]) -> int:
347344 _print_request_error ("new_session" , err )
348345 await _shutdown (proc , conn )
349346 return 1
350- except Exception as exc : # noqa: BLE001
347+ except Exception as exc :
351348 print (f"new_session error: { exc } " , file = sys .stderr )
352349 await _shutdown (proc , conn )
353350 return 1
0 commit comments