Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/a2acode/backends/acp.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ async def session_update(self, session_id: str, update: Any, **_: Any) -> None:

async def request_permission(
self,
options: list[s.PermissionOption],
session_id: str,
tool_call: s.ToolCallUpdate,
options: list[s.PermissionOption],
**_: Any,
) -> s.RequestPermissionResponse:
name = tool_call.title or (tool_call.kind or "tool")
Expand All @@ -165,10 +165,10 @@ async def request_permission(

async def read_text_file(
self,
path: str,
session_id: str,
limit: int | None = None,
path: str,
line: int | None = None,
limit: int | None = None,
**_: Any,
) -> s.ReadTextFileResponse:
# We advertise fs.readTextFile, so serve reads from disk. There are no
Expand Down Expand Up @@ -200,8 +200,8 @@ def _read() -> str:
return s.ReadTextFileResponse(content=text)

async def write_text_file(
self, content: str, path: str, session_id: str, **_: Any
) -> None:
self, session_id: str, path: str, content: str, **_: Any
) -> s.WriteTextFileResponse | None:
target = self._safe_path(path)

def _write() -> None:
Expand Down
20 changes: 10 additions & 10 deletions tests/test_acp.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ async def test_request_permission_allow_selects_allow_option():
client = _BridgeClient(session) # type: ignore[arg-type]
tool_call = s.ToolCallUpdate(tool_call_id="t1", title="Run ls", kind="execute")

resp = await client.request_permission(_opts(), "sess", tool_call)
resp = await client.request_permission("sess", tool_call, _opts())

assert isinstance(resp.outcome, s.AllowedOutcome)
assert resp.outcome.option_id == "a"
Expand All @@ -136,7 +136,7 @@ async def test_request_permission_deny_selects_reject_option():
client = _BridgeClient(session) # type: ignore[arg-type]
tool_call = s.ToolCallUpdate(tool_call_id="t1", title="rm -rf", kind="execute")

resp = await client.request_permission(_opts(), "sess", tool_call)
resp = await client.request_permission("sess", tool_call, _opts())

assert isinstance(resp.outcome, s.AllowedOutcome)
assert resp.outcome.option_id == "r"
Expand All @@ -149,7 +149,7 @@ async def test_request_permission_cancels_when_no_matching_option():
allow_only = [s.PermissionOption(option_id="a", name="Allow", kind="allow_once")]
tool_call = s.ToolCallUpdate(tool_call_id="t1", title="x")

resp = await client.request_permission(allow_only, "sess", tool_call)
resp = await client.request_permission("sess", tool_call, allow_only)

assert isinstance(resp.outcome, s.DeniedOutcome)

Expand All @@ -160,9 +160,9 @@ async def test_write_and_read_within_workspace(tmp_path):
client = _BridgeClient(session, str(tmp_path)) # type: ignore[arg-type]
target = tmp_path / "sub" / "a.txt"

await client.write_text_file("hello\n", str(target), "sess")
await client.write_text_file("sess", str(target), "hello\n")
assert target.read_text() == "hello\n"
resp = await client.read_text_file(str(target), "sess")
resp = await client.read_text_file("sess", str(target))
assert resp.content == "hello\n"


Expand All @@ -176,9 +176,9 @@ async def test_read_outside_workspace_is_rejected(tmp_path):
client = _BridgeClient(session, str(workspace)) # type: ignore[arg-type]

with pytest.raises(PermissionError):
await client.read_text_file(str(secret), "sess")
await client.read_text_file("sess", str(secret))
with pytest.raises(PermissionError):
await client.write_text_file("x", str(tmp_path / "escape.txt"), "sess")
await client.write_text_file("sess", str(tmp_path / "escape.txt"), "x")


@pytest.mark.asyncio
Expand All @@ -188,13 +188,13 @@ async def test_read_with_line_and_limit(tmp_path):
target = tmp_path / "a.txt"
target.write_text("l1\nl2\nl3\nl4\n")

resp = await client.read_text_file(str(target), "sess", line=2, limit=2)
resp = await client.read_text_file("sess", str(target), line=2, limit=2)
assert resp.content == "l2\nl3\n"
# A non-positive line number must not slice from the end.
resp = await client.read_text_file(str(target), "sess", line=0, limit=1)
resp = await client.read_text_file("sess", str(target), line=0, limit=1)
assert resp.content == "l1\n"
# A negative limit must not slice from the end; it yields nothing.
resp = await client.read_text_file(str(target), "sess", line=1, limit=-1)
resp = await client.read_text_file("sess", str(target), line=1, limit=-1)
assert resp.content == ""


Expand Down
Loading