feat: add QR login and browser-backed web tools

This commit is contained in:
Azimkin
2026-09-14 14:19:20 +02:00
parent 3a8c198caa
commit b68e715267
19 changed files with 2740 additions and 8 deletions

View File

@@ -11,6 +11,7 @@ from app.agentic import (
AgentSessionStore,
AgentSyntaxError,
_build_context_messages,
_create_llm,
_download_message_media,
render_prompt_template,
parse_agent_invocation,
@@ -22,6 +23,26 @@ from app.config import AiConfig, AiProviderConfig
class AgentInvocationTests(unittest.TestCase):
def test_glm_uses_chat_completions_and_deepseek_uses_responses(self) -> None:
provider = AiProviderConfig("https://example.test", "key", "model")
with (
patch("app.agentic.ChatCompletionsLLM") as chat_llm,
patch("app.agentic.OpenAIBasedLLM") as responses_llm,
):
_create_llm(provider, parse_agent_invocation("prompt", AiConfig()))
_create_llm(provider, parse_agent_invocation(".ds prompt", AiConfig()))
chat_llm.assert_called_once_with(
api_url="https://example.test",
api_key="key",
model="model",
)
responses_llm.assert_called_once_with(
api_url="https://example.test",
api_key="key",
model="model",
)
def test_prompt_comments_are_removed_without_breaking_urls(self) -> None:
value = strip_prompt_comments(
"// first\nkeep https://example.com // trailing\n/* block\ncomment */\nlast"
@@ -168,9 +189,11 @@ class AgentContextTests(unittest.IsolatedAsyncioTestCase):
patch("app.agentic.OpenAIBasedLLM") as llm_class,
patch("app.agentic.Aggregator", return_value=agent) as aggregator_class,
patch("app.agentic.BraveSearchTools") as brave_tools,
patch("app.agentic.WebPageTools") as web_page_tools,
patch("app.agentic._build_context_messages", AsyncMock(return_value=[])),
):
brave_tools.return_value.tools.return_value = []
web_page_tools.return_value.tools.return_value = []
result = await run_agent_turn(
SimpleNamespace(),
command,
@@ -188,6 +211,7 @@ class AgentContextTests(unittest.IsolatedAsyncioTestCase):
)
self.assertTrue(aggregator_class.call_args.kwargs["thinking"])
brave_tools.assert_called_once_with(api_key="brave-key", timeout_seconds=10.0)
web_page_tools.assert_called_once_with(timeout_seconds=45.0, max_chars=60_000)
result.handle.close()
async def test_reply_to_ai_response_reuses_existing_session(self) -> None: