This commit introduces a comprehensive set of new features including API key authentication with CLI management commands (get, reset, backfill), a Devii agentic assistant with WebSocket terminal and session bootstrap, an OpenAI-compatible LLM gateway service, and an admin service management panel. It also adds Playwright browser automation for bot support, configures internal gateway URLs, refactors content editing/deletion to support JSON API responses, and updates documentation across AGENTS.md, README.md, and the developer docs site.
52 lines
1.1 KiB
Python
52 lines
1.1 KiB
Python
# retoor <retoor@molodetz.nl>
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from typing import Any
|
|
|
|
|
|
class DeviiError(Exception):
|
|
code: str = "error"
|
|
|
|
def __init__(self, message: str, **details: Any) -> None:
|
|
super().__init__(message)
|
|
self.message = message
|
|
self.details = details
|
|
|
|
def as_payload(self) -> dict[str, Any]:
|
|
payload: dict[str, Any] = {"error": self.code, "message": self.message}
|
|
payload.update(self.details)
|
|
return payload
|
|
|
|
|
|
class AuthRequiredError(DeviiError):
|
|
code = "auth_required"
|
|
|
|
|
|
class NetworkError(DeviiError):
|
|
code = "network_error"
|
|
|
|
|
|
class UpstreamError(DeviiError):
|
|
code = "upstream_error"
|
|
|
|
|
|
class ToolInputError(DeviiError):
|
|
code = "tool_input_error"
|
|
|
|
|
|
class LLMError(DeviiError):
|
|
code = "llm_error"
|
|
|
|
|
|
def error_result(error: DeviiError) -> str:
|
|
return json.dumps(error.as_payload(), ensure_ascii=False)
|
|
|
|
|
|
def unexpected_result(exc: Exception) -> str:
|
|
return json.dumps(
|
|
{"error": "unexpected", "message": str(exc), "type": type(exc).__name__},
|
|
ensure_ascii=False,
|
|
)
|