Co-authored-by: Clément Sirieix <clement.sirieix@mistral.ai> Co-authored-by: Guillaume LE GOFF <guillaume.lgf@gmail.com> Co-authored-by: Hdandria <henri.dandria@mistral.ai> Co-authored-by: Ivana Dunisijevic <ivana.dunisijevic@mistral.ai> Co-authored-by: Jean Burellier <sheplu@users.noreply.github.com> Co-authored-by: Mathias Gesbert <mathias.gesbert@mistral.ai> Co-authored-by: Mert Unsal <mert.unsal@mistral.ai> Co-authored-by: Michel Thomazo <51709227+michelTho@users.noreply.github.com> Co-authored-by: Paul VEZIA <166131032+le-codeur-rapide@users.noreply.github.com> Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai> Co-authored-by: Val <102326092+vdeva@users.noreply.github.com> Co-authored-by: Vincent G <10739306+VinceOPS@users.noreply.github.com> Co-authored-by: renovate-mistral[bot] <253709520+renovate-mistral[bot]@users.noreply.github.com> Co-authored-by: Mistral Vibe <vibe@mistral.ai>
71 lines
2.4 KiB
Python
71 lines
2.4 KiB
Python
from __future__ import annotations
|
|
|
|
from acp.schema import ToolCallStart
|
|
|
|
from vibe.acp.tools.builtins.read import Read
|
|
from vibe.acp.tools.session_update import tool_call_session_update
|
|
from vibe.core.tools.builtins.read import ReadArgs
|
|
from vibe.core.types import ToolCallEvent
|
|
|
|
|
|
class TestToolCallSessionUpdate:
|
|
def _create_event(self) -> ToolCallEvent:
|
|
return ToolCallEvent(
|
|
tool_name="read",
|
|
tool_call_id="test_call_123",
|
|
args=ReadArgs(file_path="/tmp/test.txt"),
|
|
tool_class=Read,
|
|
)
|
|
|
|
def test_returns_tool_call_start(self) -> None:
|
|
event = self._create_event()
|
|
|
|
update = tool_call_session_update(event)
|
|
|
|
assert update is not None
|
|
assert isinstance(update, ToolCallStart)
|
|
assert update.session_update == "tool_call"
|
|
assert update.tool_call_id == "test_call_123"
|
|
|
|
def test_returns_tool_call_start_for_streaming_event(self) -> None:
|
|
event = ToolCallEvent(
|
|
tool_name="read", tool_call_id="test_call_123", tool_class=Read, args=None
|
|
)
|
|
|
|
update = tool_call_session_update(event)
|
|
|
|
assert update is not None
|
|
assert isinstance(update, ToolCallStart)
|
|
assert update.session_update == "tool_call"
|
|
assert update.tool_call_id == "test_call_123"
|
|
assert update.kind == "read"
|
|
assert update.raw_input is None
|
|
|
|
def test_whole_file_read_emits_plain_file_location(self) -> None:
|
|
event = self._create_event()
|
|
|
|
update = tool_call_session_update(event)
|
|
|
|
assert isinstance(update, ToolCallStart)
|
|
assert update.locations is not None
|
|
location = update.locations[0]
|
|
assert location.field_meta == {"type": "file"}
|
|
assert location.line is None
|
|
|
|
def test_bounded_read_emits_file_range_location(self) -> None:
|
|
event = ToolCallEvent(
|
|
tool_name="read",
|
|
tool_call_id="test_call_123",
|
|
args=ReadArgs(file_path="/tmp/test.txt", offset=10, limit=20),
|
|
tool_class=Read,
|
|
)
|
|
|
|
update = tool_call_session_update(event)
|
|
|
|
assert isinstance(update, ToolCallStart)
|
|
assert update.locations is not None
|
|
location = update.locations[0]
|
|
assert location.field_meta is not None
|
|
assert location.field_meta["type"] == "file_range"
|
|
assert location.field_meta["offset"] == 10
|
|
assert location.field_meta["limit"] == 20
|