chore(*): ruff, ty, pre-commit and make check for config.py
This commit is contained in:
@@ -2,7 +2,7 @@ import os
|
||||
from datetime import date
|
||||
from pathlib import Path
|
||||
|
||||
from beaver_gateway.agents.base import ExposedMcp
|
||||
from beaver_gateway.agents.base import BaseAgent, ExposedMcp
|
||||
from beaver_gateway.agents.claude import ClaudeAgent, ClaudeOptions
|
||||
from beaver_gateway.agents.raycast import RaycastAgent, RemoteTool, UserPreferences
|
||||
from beaver_gateway.core.prompt import assemble
|
||||
@@ -10,10 +10,10 @@ from beaver_gateway.core.registry import Gateway
|
||||
from beaver_gateway.core.turn_record import TurnRecord, slugify
|
||||
from beaver_gateway.frontends.admin import AdminFrontend
|
||||
from beaver_gateway.frontends.anthropic import AnthropicMessagesFrontend
|
||||
from beaver_gateway.frontends.base import Frontend
|
||||
from beaver_gateway.frontends.markdown import MarkdownFrontend
|
||||
from beaver_gateway.frontends.mcp_server import McpServerFrontend
|
||||
from beaver_gateway.mcp.types import HttpMcp, McpServer
|
||||
|
||||
from beaver_gateway.mcp.types import HttpMcp, McpServer, McpServerT
|
||||
|
||||
VAULT = Path("/vault")
|
||||
CHATS_DIR = VAULT / "💬 чаты"
|
||||
@@ -78,13 +78,14 @@ def chat_log_path(record: TurnRecord, vault: Path) -> Path:
|
||||
def _calendar_mcps() -> list[HttpMcp]:
|
||||
raw = os.environ.get("CALENDAR_MCPS", "").strip()
|
||||
servers: list[HttpMcp] = []
|
||||
for entry in raw.split(","):
|
||||
entry = entry.strip()
|
||||
for raw_entry in raw.split(","):
|
||||
entry = raw_entry.strip()
|
||||
if not entry:
|
||||
continue
|
||||
name, sep, url = entry.partition("=")
|
||||
if not sep or not url.strip():
|
||||
raise ValueError(f"CALENDAR_MCPS entry must be `name=url`, got: {entry!r}")
|
||||
msg = f"CALENDAR_MCPS entry must be `name=url`, got: {entry!r}"
|
||||
raise ValueError(msg)
|
||||
servers.append(McpServer.http(name=f"calendar-{name.strip()}", url=url.strip()))
|
||||
return servers
|
||||
|
||||
@@ -94,15 +95,10 @@ calendar_exposed = tuple(ExposedMcp(name=m.name) for m in calendar_mcps)
|
||||
|
||||
# Секреты MCP - только через env подпроцесса (mcp stdio даёт ему белый список
|
||||
# + это), никогда argv: процесс модели видит `ps` всего контейнера.
|
||||
mcps = [
|
||||
mcps: list[McpServerT] = [
|
||||
McpServer.stdio(
|
||||
name="obsidian-fs",
|
||||
command=[
|
||||
"bunx",
|
||||
"-y",
|
||||
"@modelcontextprotocol/server-filesystem",
|
||||
"/vault",
|
||||
],
|
||||
command=["bunx", "-y", "@modelcontextprotocol/server-filesystem", "/vault"],
|
||||
lenient=True,
|
||||
),
|
||||
McpServer.stdio(
|
||||
@@ -128,9 +124,7 @@ CLAUDE_MCPS = (
|
||||
|
||||
|
||||
UserPrefsRu = lambda: UserPreferences( # noqa: E731
|
||||
locale="ru-RU",
|
||||
timezone="Europe/Warsaw",
|
||||
current_date=date.today().isoformat(), # noqa: DTZ011
|
||||
locale="ru-RU", timezone="Europe/Warsaw", current_date=date.today().isoformat()
|
||||
)
|
||||
|
||||
|
||||
@@ -173,7 +167,7 @@ def raycast(name: str, model: str, reasoning_effort: str | None = None) -> Rayca
|
||||
)
|
||||
|
||||
|
||||
agents = [
|
||||
agents: list[BaseAgent] = [
|
||||
deep("beaver-opus-high", "claude-opus-5", effort="high"),
|
||||
raycast("beaver-gemini-pro-high", "google-gemini-3.1-pro", reasoning_effort="high"),
|
||||
deep("beaver-fable-high", "claude-fable-5", effort="high"),
|
||||
@@ -196,7 +190,7 @@ def _public(suffix: str) -> str | None:
|
||||
return f"{PUBLIC_BASE_URL}{suffix}" if PUBLIC_BASE_URL else None
|
||||
|
||||
|
||||
frontends = [
|
||||
frontends: list[Frontend] = [
|
||||
AnthropicMessagesFrontend(
|
||||
host="0.0.0.0", port=62990, public_base_url=_public("/anthropic")
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user