vibe/tests/stubs/fake_client.py
Mathias Gesbert 51fecc67d9
2.1.0 (#317)
Co-authored-by: Quentin Torroba <quentin.torroba@mistral.ai>
Co-authored-by: Michel Thomazo <michel.thomazo@mistral.ai>
Co-authored-by: Clément Drouin <clement.drouin@mistral.ai>
Co-authored-by: Vincent Guilloux <vincent.guilloux@mistral.ai>
Co-authored-by: Clément Siriex <clement.sirieix@mistral.ai>
Co-authored-by: Kim-Adeline Miguel <kimadeline.miguel@mistral.ai>
Co-authored-by: Nicolas Karolak <nicolas@karolak.fr>
2026-02-11 18:17:30 +01:00

134 lines
3.5 KiB
Python

from __future__ import annotations
from typing import Any
from acp import (
Agent as AcpAgent,
Client,
CreateTerminalResponse,
KillTerminalCommandResponse,
ReadTextFileResponse,
ReleaseTerminalResponse,
RequestPermissionResponse,
SessionNotification,
TerminalOutputResponse,
WaitForTerminalExitResponse,
WriteTextFileResponse,
)
from acp.schema import (
AgentMessageChunk,
AgentPlanUpdate,
AgentThoughtChunk,
AvailableCommandsUpdate,
ConfigOptionUpdate,
CurrentModeUpdate,
EnvVariable,
PermissionOption,
SessionInfoUpdate,
ToolCallProgress,
ToolCallStart,
ToolCallUpdate,
UsageUpdate,
UserMessageChunk,
)
class FakeClient(Client):
agent: AcpAgent
def __init__(self) -> None:
self._session_updates = []
async def session_update(
self,
session_id: str,
update: UserMessageChunk
| AgentMessageChunk
| AgentThoughtChunk
| ToolCallStart
| ToolCallProgress
| AgentPlanUpdate
| AvailableCommandsUpdate
| CurrentModeUpdate
| SessionInfoUpdate
| ConfigOptionUpdate
| UsageUpdate,
**kwargs: Any,
) -> None:
self._session_updates.append(
SessionNotification(session_id=session_id, update=update)
)
async def request_permission(
self,
options: list[PermissionOption],
session_id: str,
tool_call: ToolCallUpdate,
**kwargs: Any,
) -> RequestPermissionResponse:
raise NotImplementedError()
async def read_text_file(
self,
path: str,
session_id: str,
limit: int | None = None,
line: int | None = None,
**kwargs: Any,
) -> ReadTextFileResponse:
raise NotImplementedError()
async def write_text_file(
self, content: str, path: str, session_id: str, **kwargs: Any
) -> WriteTextFileResponse | None:
raise NotImplementedError()
async def create_terminal(
self,
command: str,
session_id: str,
args: list[str] | None = None,
cwd: str | None = None,
env: list[EnvVariable] | None = None,
output_byte_limit: int | None = None,
**kwargs: Any,
) -> CreateTerminalResponse:
raise NotImplementedError()
async def terminal_output(
self, session_id: str, terminal_id: str, **kwargs: Any
) -> TerminalOutputResponse:
raise NotImplementedError()
async def release_terminal(
self, session_id: str, terminal_id: str, **kwargs: Any
) -> ReleaseTerminalResponse | None:
raise NotImplementedError()
async def wait_for_terminal_exit(
self, session_id: str, terminal_id: str, **kwargs: Any
) -> WaitForTerminalExitResponse:
raise NotImplementedError()
async def kill_terminal(
self, session_id: str, terminal_id: str, **kwargs: Any
) -> KillTerminalCommandResponse | None:
raise NotImplementedError()
async def ext_method(self, method: str, params: dict[str, Any]) -> dict[str, Any]:
raise NotImplementedError()
async def ext_notification(self, method: str, params: dict[str, Any]) -> None:
raise NotImplementedError()
async def close(self) -> None:
raise NotImplementedError()
def on_connect(self, conn: AcpAgent) -> None:
self.agent = conn
async def __aenter__(self) -> FakeClient:
return self
async def __aexit__(self, exc_type, exc, tb) -> None:
await self.close()