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
4 changes: 0 additions & 4 deletions src/opencode_a2a/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
A2AUnsupportedBindingError,
A2AUnsupportedOperationError,
)
from .types import A2AClientEvent, A2AClientEventStream, A2AClientMetadata

__all__ = [
"A2AClient",
Expand All @@ -21,8 +20,5 @@
"A2AUnsupportedBindingError",
"A2AUnsupportedOperationError",
"A2AClientSettings",
"A2AClientEvent",
"A2AClientEventStream",
"A2AClientMetadata",
"load_settings",
]
11 changes: 7 additions & 4 deletions src/opencode_a2a/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
from .errors import A2AUnsupportedBindingError
from .payload_text import extract_text as extract_text_from_payload
from .request_context import build_call_context, build_client_interceptors, split_request_metadata
from .types import A2AClientEvent


class A2AClient:
Expand Down Expand Up @@ -105,7 +104,9 @@ async def send_message(
message_id: str | None = None,
metadata: Mapping[str, Any] | None = None,
extensions: list[str] | None = None,
) -> AsyncIterator[A2AClientEvent]:
) -> AsyncIterator[
Message | tuple[Task, TaskStatusUpdateEvent | TaskArtifactUpdateEvent | None] | None
]:
"""Send one user message and stream protocol events."""
await self._acquire_operation()
try:
Expand Down Expand Up @@ -144,9 +145,11 @@ async def send(
message_id: str | None = None,
metadata: Mapping[str, Any] | None = None,
extensions: list[str] | None = None,
) -> A2AClientEvent:
) -> Message | tuple[Task, TaskStatusUpdateEvent | TaskArtifactUpdateEvent | None] | None:
"""Send a message and return the terminal response/event."""
last_event: A2AClientEvent = None
last_event: (
Message | tuple[Task, TaskStatusUpdateEvent | TaskArtifactUpdateEvent | None] | None
) = None
async for event in self.send_message(
text,
context_id=context_id,
Expand Down
21 changes: 0 additions & 21 deletions src/opencode_a2a/client/types.py

This file was deleted.

7 changes: 1 addition & 6 deletions src/opencode_a2a/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import json
from typing import Annotated, Any, Literal, cast
from typing import Annotated, Any, Literal

from pydantic import BeforeValidator, Field, model_validator
from pydantic_settings import BaseSettings, NoDecode, SettingsConfigDict
Expand Down Expand Up @@ -180,8 +180,3 @@ class Settings(BaseSettings):
def _validate_sandbox_policy(self) -> Settings:
SandboxPolicy.from_settings(self).validate_configuration()
return self

@classmethod
def from_env(cls) -> Settings:
settings_cls: type[BaseSettings] = cls
return cast(Settings, settings_cls())
6 changes: 4 additions & 2 deletions src/opencode_a2a/server/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from contextlib import asynccontextmanager
from contextvars import ContextVar, Token
from functools import partial
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, cast

import uvicorn
from a2a.server.apps.jsonrpc.fastapi_app import A2AFastAPI
Expand All @@ -29,6 +29,7 @@
from a2a.utils.errors import ServerError
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
from pydantic_settings import BaseSettings
from starlette.responses import StreamingResponse

from ..client import A2AClient
Expand Down Expand Up @@ -788,7 +789,8 @@ def _configure_logging(level: str) -> None:


def main() -> None:
settings = Settings.from_env()
settings_cls: type[BaseSettings] = Settings
settings = cast(Settings, settings_cls())
app = create_app(settings)
log_level = _normalize_log_level(settings.a2a_log_level)
_configure_logging(log_level)
Expand Down
2 changes: 1 addition & 1 deletion tests/server/test_app_behaviors.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ def _fake_get_logger(name: str | None = None) -> MagicMock:
)
captured: dict[str, object] = {}

monkeypatch.setattr(app_module.Settings, "from_env", lambda: settings)
monkeypatch.setattr(app_module, "Settings", lambda: settings)
monkeypatch.setattr(app_module, "create_app", lambda _settings: "app-object")
monkeypatch.setattr(
app_module,
Expand Down
Loading