Commit Graph

219 Commits

Author SHA1 Message Date
LittleLlama
54ecfa39cf Provider detection: match by hostname instead of substring (re #768) (#815)
* Dedupe URL routing helpers and tighten adjacent hostname checks

* Match providers by hostname, not substring, in _detect_provider

_detect_provider used `"anthropic.com" in url`-style substring checks, so a URL
that merely contained a provider's domain in its path or query — or a look-alike
host like `anthropic.com.example` — was misclassified and picked the wrong
auth-header/payload shape. Switch it to the existing `_host_match` helper
(hostname exact/subdomain match), the same way the human-readable labels and
curated model lists already work, finishing that migration. Also harden
`_host_match` against trailing-dot FQDNs.

Not a credential-leak fix: _detect_provider only classifies a URL the admin
already configured next to its key, and the URL — not this function — decides
where the request goes. This is a correctness/consistency cleanup.

Adds tests that import the real helpers (test_endpoint_resolver.py tests local
copies, so it can't catch this) covering the substring false-positives.

Refs #768.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Import build_headers under its real name in model_routes

It was imported as `build_headers as _provider_headers`, which collides with
the unrelated llm_core._provider_headers(provider, headers) — same name,
different signature. Use the real name to remove the confusion.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Use hostname matching in URL builders, not raw suffix checks

PR review flagged that _detect_provider() was hardened to match on
hostname, but several helpers still used raw host.endswith("anthropic.com")
/ host.endswith("ollama.com"), which match adjacent hosts like
notanthropic.com / notollama.com.

Route the remaining checks through _host_match(): _is_ollama_native_url
and _ollama_api_root in llm_core, and _anthropic_api_root / _ollama_api_root
in endpoint_resolver. With _detect_provider already hostname-correct, the
trailing "or host.endswith(...)" clauses in build_chat_url / build_models_url
are redundant, so drop them rather than fix the substring match in place.

Add builder-level tests asserting look-alike and domain-in-path hosts route
to the OpenAI-compatible default. They import the real builders and fail on
the pre-fix code.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 11:11:17 +09:00
wundervrc
3f6d630b56 Never resolve to a disabled endpoint model (#861)
Background tasks (e.g. the Email Tags / check_email_urgency action)
resolve their model through resolve_endpoint("utility") → Default Chat.
When the configured model is one the user has since disabled on the
endpoint, the resolver still dispatched to it — on Groq that surfaces as
every email failing with "HTTP 400: model ... requires terms acceptance".

Two paths fed this:
- The auto-pick fallback selected from cached_models without excluding
  the endpoint's hidden_models, so a disabled model listed first won.
- A stale default_model left pointing at a now-disabled model (seeded at
  endpoint registration from raw model_ids[0]) was used verbatim.

Fix resolve_endpoint / resolve_endpoint_by_id to drop a configured model
that's in hidden_models and to pick the first ENABLED chat model. Also
seed default_model on registration via _first_chat_model so we never pin
the global default to an embedding/tts entry a provider lists first.

Checks: python -m pytest tests/test_endpoint_resolver.py
        tests/test_model_routes.py tests/test_model_context.py (all pass);
        python -m py_compile app.py routes/model_routes.py
        src/endpoint_resolver.py.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 11:10:43 +09:00
Tatlatat
aba15e7b6d fix(cookbook): sort by Fit when the Fit header is clicked (#842) (#860)
The Cookbook Scan/Download (hwfit) table gave the Fit column key:'score', so
clicking the Fit header sorted by score instead of by fit. Give the Fit column
its own 'fit' sort key, add a matching option to the #hwfit-sort select, and
rank fit_level (perfect > good > marginal > too_tight > no_fit) in the
client-side sort. Default puts the best fit first; clicking again reverses it.
Score still sorts by score.

Closes #842
2026-06-02 11:09:18 +09:00
mist
5ebe9ee67a Fix invalidate_search_cache using a key that never matches stored entries (#852)
invalidate_search_cache(query) built its cache key as
generate_cache_key(f"{query}|10|None"), but the write path
(searxng_search_results) replaces the caller's default count of 10 with the
admin-configured _get_result_count() (default 5) before building the key.

So a default search for "X" is cached under "X|5|None", while invalidation
looked for "X|10|None" — they never match, and invalidate_search_cache
silently failed to remove anything in the default configuration, violating
its docstring ("invalidate ... just the given query").

Derive the count from _get_result_count() so invalidation matches the
default-search entry the write path actually stores. The same bug (and fix)
applies to both the src/search and services/search copies.

Note: time-filtered variants (e.g. "X|5|day") still aren't reachable from a
query-only signature, since cache keys are opaque SHA-256 hashes with no
stored query; clearing those would need a broader cache-index redesign and is
out of scope here.

Adds tests/test_search_cache_invalidation.py covering the default-count case.
2026-06-02 10:53:33 +09:00
ghreprimand
d44f40b724 Honor disabled speech service toggles (#814)
Co-authored-by: ghreprimand <203024559+ghreprimand@users.noreply.github.com>
2026-06-02 10:44:39 +09:00
pewdiepie-archdaemon
1c9623a81d Protect memory tidy owner scope 2026-06-02 09:52:52 +09:00
pewdiepie-archdaemon
da97f1b9ad Label Docker bind mounts for SELinux 2026-06-02 09:50:35 +09:00
pewdiepie-archdaemon
50b81622e0 Allow Docker startup without env file 2026-06-02 09:49:35 +09:00
pewdiepie-archdaemon
6a78b02976 Fix endpoint model preservation for tasks 2026-06-02 09:44:24 +09:00
PewDiePie
d60ff44c1b Merge pull request #797 from ErnestHysa/fix/research-path-traversal
fix(research): validate session_id to block path traversal
2026-06-02 09:42:23 +09:00
PewDiePie
7187118aa6 Merge pull request #782 from tanmayraut45/fix/active-streams-toctou
Fix TOCTOU race in chat stream status endpoint
2026-06-02 09:42:07 +09:00
PewDiePie
564e1ae3ff Merge pull request #776 from tanmayraut45/fix/searxng-container-caps
Fix searxng container permission errors during setup
2026-06-02 09:41:46 +09:00
PewDiePie
e84411b86e Merge pull request #809 from BSG-Walter/main
fix: resolve DuckDuckGo redirect URLs in HTML fallback search
2026-06-02 09:41:34 +09:00
PewDiePie
1ecff0ff8c Merge pull request #824 from ooovenenoso/fix/odysseus-issue-802-windows-js-mime
fix: normalize JS static MIME types on Windows
2026-06-02 09:41:18 +09:00
PewDiePie
6cdf3951f7 Merge pull request #837 from jamesarslan/fix/agent-toolcall-null-content
Fix tool-calling HTTP 400 on Gemini and Ollama (empty assistant content with tool_calls)
2026-06-02 09:41:01 +09:00
pewdiepie-archdaemon
96618b01c0 Polish task UI slash commands and Ollama serving 2026-06-02 09:36:03 +09:00
James Arslan
cb13d09029 Fix tool-calling HTTP 400 on Gemini and Ollama: send null, not empty, assistant content
When an agent turn uses native (OpenAI-style) function calling and the model
returns only tool calls with no prose, _append_tool_results built the follow-up
assistant message with content "" (empty string).

Google Gemini's OpenAI-compatible endpoint and Ollama both reject an assistant
message that carries tool_calls alongside an empty-string content with HTTP 400.
Because that message feeds the tool results back to the model, every tool-using
turn on these providers dies at the second round: the tool runs, but the agent
never produces a result.

Use None (JSON null) instead, which is the spec-correct form the OpenAI SDK
itself emits and which OpenAI and Anthropic accept too. Adds tests covering the
native tool-call content shaping.
2026-06-02 00:34:51 +00:00
Kevin
1494a0b7ee fix: normalize JS static MIME types on Windows
Refs #802
2026-06-02 01:32:00 +02:00
BSG-Walter
c0466274ed fix: resolve DuckDuckGo redirect URLs in HTML fallback search
The DuckDuckGo HTML fallback returns redirect URLs (//duckduckgo.com/l/?uddg=...)
instead of actual page URLs. This caused fetch_webpage_content() to reject them
instantly because _public_http_url() requires an http/https scheme, making search
results unfetchable in deep research mode.
Added _resolve_url() to:
- Convert protocol-relative URLs to absolute (https:)
- Convert path-relative URLs to absolute
- Extract the real URL from DuckDuckGo's /l/?uddg= redirect parameters
2026-06-01 19:42:01 -03:00
pewdiepie-archdaemon
ab0a480f30 Show Ollama models in Cookbook Serve 2026-06-02 07:38:45 +09:00
Ernest Hysa
cb6f6b65ea fix(research): validate session_id to block path traversal
Every research endpoint interpolates session_id into filesystem paths
(Path('data/deep_research') / f'{session_id}.json') without checking
for traversal sequences. A crafted ID like '../../data/auth' reaches
arbitrary JSON files — readable via research_detail (which also leaks
file paths in error messages), writable via research_archive, and
deletable via research_delete.

Add _validate_session_id() which rejects anything outside
[a-zA-Z0-9-]{1,128}. Called before filesystem access in all 12
endpoints that accept a session_id path parameter.
2026-06-01 23:25:38 +01:00
pewdiepie-archdaemon
cd53ad01e8 Clarify AI tasks and skipped activity rows 2026-06-02 07:11:40 +09:00
pewdiepie-archdaemon
81109b85d3 Fix Brain tab panel visibility 2026-06-02 07:07:51 +09:00
pewdiepie-archdaemon
cd0c5fec03 Match mobile task state button height 2026-06-02 07:06:17 +09:00
pewdiepie-archdaemon
ed946d8e61 Polish task activity icons 2026-06-02 07:04:52 +09:00
pewdiepie-archdaemon
1ff8669199 Compact mobile task controls 2026-06-02 07:02:26 +09:00
pewdiepie-archdaemon
7f9afe75e2 Remove mobile notes close button 2026-06-02 07:00:40 +09:00
pewdiepie-archdaemon
b7477d063a Clarify task status controls on mobile 2026-06-02 06:57:53 +09:00
pewdiepie-archdaemon
59516ec126 Make favorite dot feedback transient 2026-06-02 06:52:03 +09:00
pewdiepie-archdaemon
637c7511a2 Add model favorite dot feedback 2026-06-02 06:50:22 +09:00
pewdiepie-archdaemon
4a112175e2 Remove broken remind slash command 2026-06-02 06:48:41 +09:00
pewdiepie-archdaemon
eda0f1258a Nudge model picker favorite dots 2026-06-02 06:46:05 +09:00
pewdiepie-archdaemon
d5c7e3d3e4 Add direct tool slash commands 2026-06-02 06:44:29 +09:00
pewdiepie-archdaemon
3959eec602 Refresh slash command hints 2026-06-02 06:40:23 +09:00
pewdiepie-archdaemon
5a5e0e9823 Adjust model picker favorite dot alignment 2026-06-02 06:36:10 +09:00
pewdiepie-archdaemon
3c1e0edea3 Polish model picker favorites 2026-06-02 06:33:53 +09:00
tanmayraut45
2d7d7b2412 Fix TOCTOU race in chat stream status endpoint
The /api/chat/stream_status handler did a membership test against
_active_streams followed by an indexed read of the same key. Between
those two ops, a sibling stream's finally block (or a stop / cleanup
path) can pop the entry, turning the indexed read into a KeyError that
bubbles up as a 500. The race is the exact one _stream_set was already
written to avoid; the comment on the helper at the top of the module
spells out why a single .get() is the right pattern here too.

Collapse the two-step into a single .get() call so the lookup either
returns the live record or None, and report 'detached' / 404 based on
that single read. No behavior change on the happy path; the failure
mode under concurrent stream cleanup is now handled deterministically.

Closes #658.
2026-06-02 03:02:30 +05:30
pewdiepie-archdaemon
e5cae37d15 Merge branch 'pr-673' into visual-pr-playground 2026-06-02 06:26:32 +09:00
pewdiepie-archdaemon
5f2509d6a8 Merge branch 'pr-644' into visual-pr-playground 2026-06-02 06:26:32 +09:00
pewdiepie-archdaemon
7242431335 Merge branch 'pr-738' into visual-pr-playground 2026-06-02 06:26:32 +09:00
pewdiepie-archdaemon
2e0b384d72 Merge branch 'pr-480' into visual-pr-playground 2026-06-02 06:26:32 +09:00
pewdiepie-archdaemon
b3765c7b63 Merge branch 'pr-611' into visual-pr-playground 2026-06-02 06:26:32 +09:00
pewdiepie-archdaemon
b041e53c0b Merge branch 'pr-506' into visual-pr-playground 2026-06-02 06:26:32 +09:00
pewdiepie-archdaemon
0ae30211d8 Merge branch 'pr-550' into visual-pr-playground 2026-06-02 06:26:32 +09:00
pewdiepie-archdaemon
6873b60721 Merge branch 'pr-594' into visual-pr-playground 2026-06-02 06:26:31 +09:00
pewdiepie-archdaemon
c1cb6f0d55 Merge branch 'pr-575' into visual-pr-playground 2026-06-02 06:26:31 +09:00
pewdiepie-archdaemon
664acf73ee Merge branch 'pr-469' into visual-pr-playground 2026-06-02 06:26:31 +09:00
pewdiepie-archdaemon
7ef7791ac8 Merge branch 'pr-684' into visual-pr-playground 2026-06-02 06:26:31 +09:00
pewdiepie-archdaemon
3224cd2ec7 Merge branch 'pr-668' into visual-pr-playground 2026-06-02 06:26:31 +09:00
pewdiepie-archdaemon
49ae46001c Merge branch 'pr-696' into visual-pr-playground 2026-06-02 06:26:31 +09:00