rewrite phase 1

This commit is contained in:
2026-07-22 23:10:23 +02:00
parent 7527831af6
commit 98ac4abca1
89 changed files with 9179 additions and 2795 deletions
+50 -3
View File
@@ -3,11 +3,11 @@ from pathlib import Path
import httpx
import pytest
from agentci.adapters.opencode import OpenCodeClient, OpenCodeError
from agentci.opencode import OpenCode, OpenCodeError
def client(tmp_path: Path, status: int) -> OpenCodeClient:
return OpenCodeClient(
def client(tmp_path: Path, status: int) -> OpenCode:
return OpenCode(
base_url="http://opencode:4096",
username="opencode",
password="secret",
@@ -32,3 +32,50 @@ async def test_abort_failure_is_visible_for_retry(tmp_path: Path, status: int) -
with pytest.raises(OpenCodeError):
await value.abort("session", tmp_path)
await value.close()
async def test_abort_sends_authenticated_workspace_request(tmp_path: Path) -> None:
requests: list[httpx.Request] = []
async def handler(request: httpx.Request) -> httpx.Response:
requests.append(request)
return httpx.Response(204)
value = OpenCode(
base_url="http://opencode:4096/",
username="opencode",
password="secret",
schemas_dir=tmp_path,
health_directory=tmp_path,
required_models=(),
timeout_seconds=60,
transport=httpx.MockTransport(handler),
)
await value.abort("ses_123", tmp_path)
await value.close()
assert len(requests) == 1
request = requests[0]
assert request.method == "POST"
assert request.url == httpx.URL("http://opencode:4096/session/ses_123/abort")
assert request.headers["authorization"].startswith("Basic ")
assert request.headers["x-opencode-directory"] == str(tmp_path)
async def test_best_effort_abort_suppresses_transport_failure(tmp_path: Path) -> None:
async def handler(request: httpx.Request) -> httpx.Response:
raise httpx.ConnectError("connection refused", request=request)
value = OpenCode(
base_url="http://opencode:4096",
username="opencode",
password="secret",
schemas_dir=tmp_path,
health_directory=tmp_path,
required_models=(),
timeout_seconds=60,
transport=httpx.MockTransport(handler),
)
await value.abort("session", tmp_path, best_effort=True)
await value.close()