Zum Inhalt

Protocol Types

configuration for KEI-protocol-Integration.

Definiert welche protocole enabled are and theen specific Endpunkte. Ermöglicht automatische protocol-Auswahl and Fallback-Mechatismen.

Attributes:

NameTypeDescription
rpc_enabledbool

Enabled KEI-RPC protocol

stream_enabledbool

Enabled KEI-Stream protocol

bus_enabledbool

Enabled KEI-Bus protocol

mcp_enabledbool

Enabled KEI-MCP protocol

rpc_endpointstr

API-Endpunkt for RPC operationen

stream_endpointstr

WebSocket-Endpunkt for Streaming

bus_endpointstr

API-Endpunkt for Message-Bus

mcp_endpointstr

API-Endpunkt for MCP-Integration

auto_protocol_selectionbool

Automatische protocol-Auswahl aktivieren

protocol_fallback_enabledbool

Fallback on atthee protocole on errorn

Functions

get_enabled_protocols()

Gibt lis the enablethe protocole torück.

Returns:

TypeDescription
list[Protocoltypee]

lis the enablethe Protocoltypee Enums

Source code in kei_agent/protocol_types.py
def get_enabled_protocols(self) -> list[Protocoltypee]:
    """Gibt lis the enablethe protocole torück.

    Returns:
        lis the enablethe Protocoltypee Enums
    """
    enabled = []
    if self.rpc_enabled:
        enabled.append(Protocoltypee.RPC)
    if self.stream_enabled:
        enabled.append(Protocoltypee.STREAM)
    if self.bus_enabled:
        enabled.append(Protocoltypee.BUS)
    if self.mcp_enabled:
        enabled.append(Protocoltypee.MCP)
    return enabled

is_protocol_enabled(protocol)

Checks ob a specifics protocol enabled is.

Parameters:

NameTypeDescriptionDefault
protocolProtocoltypee

protocol to check

required

Returns:

TypeDescription
bool

True if protocol enabled is

Source code in kei_agent/protocol_types.py
def is_protocol_enabled(self, protocol: Protocoltypee) -> bool:
    """Checks ob a specifics protocol enabled is.

    Args:
        protocol: protocol to check

    Returns:
        True if protocol enabled is
    """
    protocol_map = {
        Protocoltypee.RPC: self.rpc_enabled,
        Protocoltypee.STREAM: self.stream_enabled,
        Protocoltypee.BUS: self.bus_enabled,
        Protocoltypee.MCP: self.mcp_enabled,
    }
    return protocol_map.get(protocol, False)

get_endpoint(protocol)

Gibt Endpunkt for specifics protocol torück.

Parameters:

NameTypeDescriptionDefault
protocolProtocoltypee

protocol for the the Endpunkt benötigt is

required

Returns:

TypeDescription
str

API-Endpunkt for the protocol

Raises:

TypeDescription
ValueError

If protocol not supported is

Source code in kei_agent/protocol_types.py
def get_endpoint(self, protocol: Protocoltypee) -> str:
    """Gibt Endpunkt for specifics protocol torück.

    Args:
        protocol: protocol for the the Endpunkt benötigt is

    Returns:
        API-Endpunkt for the protocol

    Raises:
        ValueError: If protocol not supported is
    """
    endpoint_map = {
        Protocoltypee.RPC: self.rpc_endpoint,
        Protocoltypee.STREAM: self.stream_endpoint,
        Protocoltypee.BUS: self.bus_endpoint,
        Protocoltypee.MCP: self.mcp_endpoint,
    }

    if protocol not in endpoint_map:
        raise ValueError(f"Unknown protocol: {protocol}")

    return endpoint_map[protocol]

security configuration for KEI-Agent.

Definiert authentication, Authorization and securitys-Features for the KEI-Agent SDK.

Attributes:

NameTypeDescription
auth_typeAuthtypee

type the authentication

api_tokenOptional[str]

Bearer Token for API-authentication

oidc_issuerOptional[str]

OIDC Ithetity Provithe URL

oidc_client_idOptional[str]

OIDC client-ID

oidc_client_secretOptional[str]

OIDC client-Secret

oidc_scopestr

OIDC Scopes for Token-Request

mtls_cert_pathOptional[str]

Path tom client-Zertifikat for mTLS

mtls_key_pathOptional[str]

Path tom Private Key for mTLS

mtls_ca_pathOptional[str]

Path tor Certificate Authority for mTLS

tls_verifybool

TLS-Zertifikatsprüfung aktivieren/deaktivieren

tls_ca_bundleOptional[str]

Pfad to benutzerdefiniertem CA-Bundle

tls_pinned_sha256Optional[str]

SHA-256 Fingerprint for Zertifikat-Pinning

rbac_enabledbool

Role-Based Access Control aktivieren

audit_enabledbool

Audit-Logging aktivieren

token_refresh_enabledbool

Automatische Token-Erneuerung aktivieren

token_cache_ttlint

Token-Cache Time-To-Live in Sekatthe

Functions

validate()

Validates the security configuration using Pydantic models.

Raises:

TypeDescription
ValidationError

On ungültiger configuration

Source code in kei_agent/protocol_types.py
def validate(self) -> None:
    """Validates the security configuration using Pydantic models.

    Raises:
        ValidationError: On ungültiger configuration
    """
    try:
        # Convert to dict for validation
        config_dict = {
            "auth_type": self.auth_type.value
            if hasattr(self.auth_type, "value")
            else str(self.auth_type),
            "api_token": self.api_token,
            "oidc_issuer": self.oidc_issuer,
            "oidc_client_id": self.oidc_client_id,
            "oidc_client_secret": self.oidc_client_secret,
            "oidc_scope": self.oidc_scope,
            "mtls_cert_path": self.mtls_cert_path,
            "mtls_key_path": self.mtls_key_path,
            "mtls_ca_path": self.mtls_ca_path,
            "rbac_enabled": self.rbac_enabled,
            "audit_enabled": self.audit_enabled,
            "token_refresh_enabled": self.token_refresh_enabled,
            "token_cache_ttl": self.token_cache_ttl,
        }

        # Validate using Pydantic model
        validate_configuration(config_dict, "security")

    except ValidationError:
        raise
    except Exception as e:
        raise ValidationError(
            f"Security configuration validation failed: {e}"
        ) from e

is_token_based()

Checks ob Token-basierte authentication verwendet is.

Returns:

TypeDescription
bool

True if Bearer or OIDC verwendet is

Source code in kei_agent/protocol_types.py
def is_token_based(self) -> bool:
    """Checks ob Token-basierte authentication verwendet is.

    Returns:
        True if Bearer or OIDC verwendet is
    """
    return self.auth_type in [Authtypee.BEARER, Authtypee.OIDC]

requires_refresh()

Checks ob Token-Refresh erforthelich is.

Returns:

TypeDescription
bool

True if Token-Refresh enabled and erforthelich is

Source code in kei_agent/protocol_types.py
def requires_refresh(self) -> bool:
    """Checks ob Token-Refresh erforthelich is.

    Returns:
        True if Token-Refresh enabled and erforthelich is
    """
    return self.token_refresh_enabled and self.is_token_based()

AgentClientConfig

Basis-Konfiguration für den KEI-Agent Client.

@dataclass
class AgentClientConfig:
    base_url: str
    api_token: str
    agent_id: str
    timeout: int = 30

ProtocolConfig

Konfiguration für Protokoll-spezifische Einstellungen.

@dataclass
class ProtocolConfig:
    rpc_enabled: bool = True
    stream_enabled: bool = True
    bus_enabled: bool = True
    mcp_enabled: bool = True

SecurityConfig

Sicherheitskonfiguration für Authentifizierung und Autorisierung.

@dataclass
class SecurityConfig:
    auth_type: AuthType
    rbac_enabled: bool = False
    audit_enabled: bool = False

Weitere Informationen