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
6 changes: 0 additions & 6 deletions src/opencode_a2a/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ def build_static_auth_credentials(settings: Settings) -> tuple[StaticAuthCredent
return tuple(credentials)


def has_configured_auth_scheme(settings: Settings, scheme: str) -> bool:
return any(
credential.auth_scheme == scheme for credential in build_static_auth_credentials(settings)
)


def authenticate_static_credential(
*,
credentials: tuple[StaticAuthCredential, ...],
Expand Down
17 changes: 0 additions & 17 deletions src/opencode_a2a/extension_negotiation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,13 @@
from .a2a_utils import clone_proto
from .contracts.extensions import (
INTERRUPT_CALLBACK_EXTENSION_URI,
INTERRUPT_CALLBACK_METHODS,
INTERRUPT_RECOVERY_EXTENSION_URI,
INTERRUPT_RECOVERY_METHODS,
MODEL_SELECTION_EXTENSION_URI,
PROVIDER_DISCOVERY_EXTENSION_URI,
PROVIDER_DISCOVERY_METHODS,
SESSION_BINDING_EXTENSION_URI,
SESSION_MANAGEMENT_EXTENSION_URI,
SESSION_METHODS,
STREAMING_EXTENSION_URI,
WORKSPACE_CONTROL_EXTENSION_URI,
WORKSPACE_CONTROL_METHODS,
)

_STREAMING_SHARED_METADATA_KEYS = ("stream", "progress", "usage")

JSONRPC_EXTENSION_URI_BY_METHOD: dict[str, str] = {
**{method: SESSION_MANAGEMENT_EXTENSION_URI for method in SESSION_METHODS.values()},
**{method: PROVIDER_DISCOVERY_EXTENSION_URI for method in PROVIDER_DISCOVERY_METHODS.values()},
**{method: INTERRUPT_RECOVERY_EXTENSION_URI for method in INTERRUPT_RECOVERY_METHODS.values()},
**{method: INTERRUPT_CALLBACK_EXTENSION_URI for method in INTERRUPT_CALLBACK_METHODS.values()},
**{method: WORKSPACE_CONTROL_EXTENSION_URI for method in WORKSPACE_CONTROL_METHODS.values()},
}


@dataclass(frozen=True)
class ExtensionRequirement:
Expand Down
7 changes: 0 additions & 7 deletions src/opencode_a2a/jsonrpc/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ class ExtensionMethodSpec:
class ExtensionMethodRegistry:
def __init__(self, specs: Iterable[ExtensionMethodSpec]) -> None:
method_map: dict[str, ExtensionMethodSpec] = {}
normalized_specs: list[ExtensionMethodSpec] = []
for spec in specs:
normalized_specs.append(spec)
for method in spec.methods:
existing = method_map.get(method)
if existing is not None:
Expand All @@ -102,13 +100,8 @@ def __init__(self, specs: Iterable[ExtensionMethodSpec]) -> None:
f"{existing.name!r} and {spec.name!r}"
)
method_map[method] = spec
self._specs = tuple(normalized_specs)
self._method_map = method_map

@property
def specs(self) -> tuple[ExtensionMethodSpec, ...]:
return self._specs

def methods(self) -> frozenset[str]:
return frozenset(self._method_map)

Expand Down
9 changes: 6 additions & 3 deletions src/opencode_a2a/server/agent_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
SecurityScheme,
)

from ..auth import has_configured_auth_scheme
from ..auth import build_static_auth_credentials
from ..config import Settings
from ..contracts.extensions import (
AUTHENTICATED_ONLY_EXTENSION_URIS,
Expand Down Expand Up @@ -483,7 +483,10 @@ def build_agent_card(
runtime_profile = build_runtime_profile(settings)
security_schemes: dict[str, SecurityScheme] = {}
security_requirements: list[SecurityRequirement] = []
if has_configured_auth_scheme(settings, "bearer"):
configured_auth_schemes = {
credential.auth_scheme for credential in build_static_auth_credentials(settings)
}
if "bearer" in configured_auth_schemes:
security_schemes["bearerAuth"] = SecurityScheme(
http_auth_security_scheme=HTTPAuthSecurityScheme(
description="Bearer token authentication",
Expand All @@ -492,7 +495,7 @@ def build_agent_card(
)
)
security_requirements.append(SecurityRequirement(schemes=cast(Any, {"bearerAuth": {}})))
if has_configured_auth_scheme(settings, "basic"):
if "basic" in configured_auth_schemes:
security_schemes["basicAuth"] = SecurityScheme(
http_auth_security_scheme=HTTPAuthSecurityScheme(
description="Basic authentication",
Expand Down