mirror of
https://github.com/bitbaum/orangecat.git
synced 2026-12-04 06:49:58 +01:00
* feat(ai): wire Anthropic direct, kill the blind spot in model rot Follow-up to #1094, from the settings review. BRING YOUR OWN KEY Anthropic was in the provider registry, with the correct console URL, and was still unreachable: the add-key form renders `wiredProviders`, and `WIRED_PROVIDER_IDS` did not include it. So the provider people ask for by name could not be selected, and the form told them direct Anthropic support was "on the roadmap" while pointing them at OpenRouter. It is wired now because it can be. Anthropic serves an OpenAI-compatible surface — POST /v1/chat/completions with `Authorization: Bearer`, and GET /v1/models for key validation — which is exactly what OpenAICompatibleService speaks and what PROVIDER_AUTH_ENDPOINTS derives from WIRED_PROVIDER_IDS. Verified live against both endpoints on 2026-09-20: each answers 401 `authentication_error` on a bad key, the same shape as Groq. The only edits needed were a base URL, a default model and one array entry; validation, routing and quota priority all followed on their own. Google AI Studio serves the same kind of endpoint and is deliberately NOT wired: it validates the key before the model, so I could not confirm a current Gemini id without one, and guessing a model id in the commit that fixes model rot would be absurd. The key link was also in the wrong place — four words of grey text under the password field, below the fold on a phone, so "where do I get a key" was answered after the box demanding one. It is now the first thing after choosing a provider, and it names the host it opens (console.anthropic.com), so the link says where it is about to send you. MODEL ROT, THE HALF THAT WAS INVISIBLE `checkModelRot` asks whether a pinned id has gone MISSING from the vendor's catalogue. Fable 5.1 shipped while we pinned Fable 5; Fable 5 kept being listed and kept answering, so `missing` stayed empty and every signal stayed green. The registry sat a version behind indefinitely and a human reading a dropdown is what caught it. A check that only detects death cannot detect age. `findSupersededPins` adds the other direction, reading `verdict.live` that checkCatalog already fetched, so it costs no extra request. It is a nudge, never a failure — these models still serve, and being a version behind should be a decision rather than an oversight. The hard part is silence. A version checker that cries wolf gets muted, so the version must parse as purely numeric: `gpt-oss-120b` is not a successor to `gpt-oss-20b`, it is a different model at a different size, and six tests pin that it stays quiet. WHAT WE TELL PEOPLE ABOUT THEIR MONEY - CatCreditsPanel understated the markup in a hardcoded sentence while /settings/usage quoted the real figure from CREDIT_USAGE_MARKUP — two adjacent screens, two claims, one of them wrong. It now uses the derived label, which existed precisely so this could not happen. - "Image generation is free and doesn't count" was true about the daily message budget and false about money: it is billed to Cat Credits. - The BYOK plan bullet read "Six providers wired direct:" immediately before a DERIVED list of them, so wiring a seventh made the sentence contradict its own next clause. The count is derived now too. - Supporter is badged "Planned", not "Activating". SUPPORTER_PRICE_CHF is null and the checkout URL is unset; "Activating" reads as "any moment now" for something nobody can buy. The price itself remains a business decision. SEPARATION /settings/ai was eleven components answering three unrelated questions. Memory moved to /settings/memory — not for tidiness: billing is a setup surface configured once, while memory is a data surface you return to in order to read, correct and delete. Nobody expects to audit what a product knows about them by scrolling past their credit balance. ONE PLACE IT IS EXPLAINED /docs/how-cat-runs covers the four routes — free pool, credits, your own key, your own machine — with what each costs, where your words go, what each is good at and what each is BAD at. Local models get the honest version: they are weak at tool calling, which is most of what makes Cat useful, so Cat will chat well and then struggle to actually do the thing. Every figure on the page is derived from the config that governs it; the surfaces that used to restate this now link to it, which is the same rule this repo applies to entity lists and the rule the markup copy broke. 41 new tests (409 files, 3819 passing). pnpm run verify green; production build compiles and generates 267 static pages. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P5WYRJUgYyubGFT9w35yC7 * fix(test): the BTC round-trip assertion excluded the boundary it can hit `build-and-smoke` went red on #1095 in a file this PR does not touch: expected 9.42411171 to be close to 9.424111705, received difference is 5.000000413701855e-9, but expected 5e-9 Not a flake, and not this PR's change — a real defect in the assertion, which has been failing PRs at random and will keep doing so. A satoshi is the smallest unit there is, so `bitcoinToSats` QUANTISES: anything past the 8th decimal is rounded to the nearest sat, and the most a round trip can lose is therefore HALF a satoshi — exactly 5e-9. `toBeCloseTo(x, 8)` passes only when the difference is strictly BELOW 5e-9. So the tolerance was precisely the largest error the code is permitted to produce, with the boundary excluded, and any value landing on a half-sat (…5 at the ninth decimal) was a correct result the test called a failure. The fuzz draws 10 000 random values per run, so it found one eventually, on somebody's unrelated PR. Measured rather than guessed. Across 400 000 samples — uniform random plus exact half-sat boundaries — the worst excess over half a satoshi was 4.14e-16, or 0.69 × EPSILON×|btc|: the written value is not exactly representable as a double before the multiply/round/divide chain adds its own. The tolerance allows 4 × EPSILON×|btc|, 5.8× that worst case, and still ~1.9e-6 of ONE satoshi — an off-by-one-sat regression is five million times larger, so nothing real can hide inside it. Loosening to `toBeCloseTo(btc, 7)` would have been the easy fix and the wrong one: it permits a full satoshi of drift, which is the only failure here anybody would care about. Two tests added beside the fuzz, because a property that only holds sometimes is not pinned by a random draw: - exact equality for values already on the sat grid (nothing to quantise, so nothing may be lost — the stronger claim) - the four boundary values, including the 9.424111705 CI actually hit Verified with eight consecutive runs of the file and a full verify pass (409 files, 3821 tests). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P5WYRJUgYyubGFT9w35yC7 --------- Co-authored-by: Claude <noreply@anthropic.com>