4 Commits
Author SHA1 Message Date
CatoandClaude edf2cd32c5 release: informal address everywhere, engine clean-up, account limits, owner numbers (#358)
Claude-Session: https://claude.ai/code/session_019MDtmvb6xi489TfZMg7n9T

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-25 18:07:34 +01:00
CatoandClaude Opus 5.5 c19c9146a6 feat(model): bring your own key through ai-kit — every vendor, the key's own models, no paid check (#138)
Per the Loki session's fleet-wide request (loki#921 is the reference):
- Vendors come from @bitbaum/ai-kit BYOK_VENDORS (^1.17.0): ten instead of
  Heidi's own five, Anthropic and Gemini included; byokChain delegates to
  ai-kit's (dailyTokens pinned to 0 — Heidi's free chain shares provider ids).
- /api/model/check uses probeByokKey: no tokens spent (it made a real
  completion), the key's own model list with the strongest suggested, the
  vendor's words on failure (redacted again here), 'unreachable' kept apart
  from 'wrong key'.
- The sheet: paste -> auto-check (600 ms) -> a select of the key's models,
  strongest preselected and marked; free text only when no list. The key
  stays in this browser only.
- No per-vendor 'text only' guess: ai-kit routes images on observed capability.
- Also: 'no streaks' was still claimed in 7 languages (landing pillar, method
  claim) after streaks shipped — reworded to what is true.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 23:21:17 -07:00
CatoandClaude Opus 5 0a9c1cd43f fix(limits): every public endpoint ran with no rate limit (#16)
Found by being asked which shared packages Heidi actually uses. It uses
ai-kit and threadkit. It was not using limitkit, and the reason is the
one SHARED.md predicts: I did not grep the registry before building.

That was not a style miss. Three endpoints were reachable by anyone
with curl and none had a ceiling:

  /api/chat         spends from a free-tier AI budget shared with every
                    other visitor
  /api/model/check  makes a real outbound call with whatever key it is
                    handed — the one endpoint here that could be used
                    to test stolen credentials in bulk
  /api/check        pure and local, but still a way to occupy the box

limitkit ships the algorithm and the HTTP edges and deliberately NO
limit values, because how many a route allows is app semantics. So the
numbers live in lib/domain/limits.ts with the reason each one is what
it is — a limit with no stated reason is one that gets "temporarily"
raised.

  chat          30 / 5 min — generous: a real conversation is a dozen
                turns, and someone working through a long WhatsApp
                thread must never meet this
  model-check    6 / 5 min — nobody legitimately needs more than a few
                attempts to paste a key correctly
  dialect-check 120 / 1 min — free to run; only about not letting one
                client monopolise the box

Verified against a running server: six probes pass, the seventh gets
429 with Retry-After and X-RateLimit-*, and the same address still has
its full dialect-check allowance — budgets are per endpoint, so
spending one cannot lock someone out of another.

Stated plainly in the module: this reads forwarded headers, so it is a
rate limit and not a security boundary. It exists to stop accidental
and casual abuse from spending a budget that belongs to everybody.

pnpm-workspace.yaml gains an allowBuilds entry — limitkit is a git
dependency and pnpm 11 silently installs NOTHING without it, so the
install "succeeds" and the package is simply absent.

145 tests.


Claude-Session: https://claude.ai/code/session_01FzYBD3sZroCAYeRgTYrpfT

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-12 09:17:11 -07:00
CatoandClaude Opus 5 ef54559395 feat(byok): bring your own model, and Heidi can read a screenshot (#14)
Reading a picture is the highest-value thing someone can hand this
product — the WhatsApp message they cannot read IS the problem, and
making them retype dialect they cannot spell in order to ask about it
is a barrier we put there ourselves.

No model in the free chain can see. Paying for everyone's vision calls
would mean charging for Heidi, so the capability goes to whoever brings
a key. Everything else stays free, and the reason is stated in the UI
rather than implied.

It is not really "attachments" — it is USE YOUR OWN MODEL. Answers get
better across the board; pictures are the part you cannot get otherwise.

SECURITY, WHICH IS MOST OF THIS

- A fixed provider ALLOWLIST, never a base URL from the browser. The
  obvious design — paste your endpoint and your key — is a server-side
  request forgery hole with a friendly form around it: our server would
  post a credential to 169.254.169.254 because a visitor asked it to.
  Asserted by a test that tries exactly that.
- Keys live in the visitor's localStorage. Not a cookie: a cookie rides
  along on every request to this origin whether or not they chose to
  make it, which is precisely what a bearer credential must not do.
- The key is used for one request and dropped. Never stored, never
  logged, never echoed back — redact() runs before anything reaches a
  log line, because a vendor error can quote the request that carried
  the credential.
- A line break in a key is refused; that is where header injection
  starts. Images must be inline data URLs, never a remote URL we would
  then go and fetch.
- Their key, their quota: dailyTokens is 0, so our fair-share pool never
  believes it has capacity it does not own.
- One link, no fallback. Falling through to our free models after their
  paid model failed would answer a picture with something that cannot
  see, and bill our budget for it.

PRODUCT AND UX

- The attach button is ALWAYS visible and never disabled. Without a
  vision model it opens the explanation — a greyed-out button with a
  tooltip teaches nobody why.
- Nothing says "saved" without proof. Connecting makes one real,
  64-token call and reports what came back, including the vendor's own
  words on failure: "model not found" and "insufficient credit" are the
  two things a person actually needs to hear. Absence of failure is not
  evidence of success.
- Where the key goes is stated above the field, not linked from a footer.
- Screenshots arrive by paste, drag, or picker, and are downscaled to
  1024px IN THE BROWSER before upload. Vision models bill by tile and
  the person paying is the one who brought the key — sending a 4 MB
  phone screenshot charges them for detail no model needs to read a
  chat bubble. It also means the raw screenshot, which may show far more
  of their phone than the message, never leaves at full fidelity.
- The connected model shows in the header and on every answer, so it is
  visible that their key is actually being used.

ai-kit carries all of it: the BYOK chain is an ordinary Provider, so
timeouts, the three kinds of 429 and error shapes are unchanged. Its
ChatMessage.content is typed `string` while the implementation forwards
image parts untouched — widening that belongs in the fleet's AI layer,
and the one cast crossing the gap is named so it can be deleted in a
single edit.

Also fixed: two more setState-in-effect errors, both derived state
pretending to be synced; and the provider notes were English source
copy rendered into a German dropdown — the same leak class as before,
now asserted against.

137 tests.


Claude-Session: https://claude.ai/code/session_01FzYBD3sZroCAYeRgTYrpfT

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-12 03:39:59 -07:00